Click here to Skip to main content
15,885,670 members
Articles / Programming Languages / Visual Basic

EfTidy: The Tidy Library Wrapper

Rate me:
Please Sign up or sign in to vote.
4.91/5 (36 votes)
6 Sep 2013GPL310 min read 185K   5K   88  
A free component for HTML parsing and cleaning
// EfTidy.idl : IDL source for EfTidy.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (EfTidy.tlb) and marshalling code.

/**

  Author :Alok Gupta
  Email  :thatsalok@gmail.com
  Personel Homepage :http://www.thatsalok.com

  You are Free to Modify,use code etc,till above name is not removed.
  I am not responisible for problem coming while using above code+
   it will cool, if you notify me about using this component!
   thanks


*/
import "oaidl.idl";
import "ocidl.idl";

//new Char Encoding
typedef [public] enum tagCharEncodingType
{
 ASCII,
 LATIN1, 
 RAW, 
 UTF8, 
 ISO2022,
 MAC,
 WIN1252,
 UTF16LE,
 UTF16BE,
 UTF16,
 BIG5,
 SHIFTJIS
} CharEncodingType;

typedef [public] enum tagOutputType {
  XmlOut,          /**< Create output as XML */
  XhtmlOut,        /**< Output extensible HTML */
  HtmlOut         /**< Output plain HTML, even for XHTML input.*/
}OutputType;

typedef [public] enum IndentScheme {
	NOINDENT=0,
	INDENTBLOCKS,
	AUTOINDENT
} IndentScheme;

typedef [public] enum
{
    DoctypeOmit,    /**< Omit DOCTYPE altogether */
    DoctypeAuto,    /**< Keep DOCTYPE in input.  Set version to content */
    DoctypeStrict,  /**< Convert document to HTML 4 strict content model */
    DoctypeLoose,   /**< Convert document to HTML 4 transitional
                            content model */
    DoctypeUser     /**< Set DOCTYPE FPI explicitly */
} DoctypeModes;

typedef [public] enum
{
  TIDY_ROOT,
  TIDY_HTML,
  TIDY_HEAD,
  TIDY_BODY
}EfTidyMainNode;



//forward Defination
interface IEfTidyAttr;
interface IEfTidyNode;


interface ItidyOption;

	[
		object,
		uuid(BD053321-ADA9-4795-ABE6-55EEFBCC5D60),
		dual,
		helpstring("ItidyCom Interface"),
		pointer_default(unique)
	]
	interface ItidyCom : IDispatch
	{
		[id(1), helpstring("method TidyFiletoMem")] HRESULT TidyFiletoMem([in] BSTR sourceFile,[out, retval] BSTR* result);
		[id(2), helpstring("method TidyFileToFile")] HRESULT TidyFileToFile([in] BSTR sourceFile,[in] BSTR destFile);
		[id(3), helpstring("method TidyMemToMem")] HRESULT TidyMemToMem([in] BSTR sourceStr,[out, retval] BSTR* result);
		[id(4), helpstring("method TidyMemtoFile")] HRESULT TidyMemtoFile([in] BSTR buffer,[in] BSTR destFile);
		[propget, id(5), helpstring("property TotalWarnings")] HRESULT TotalWarnings([out, retval] long *pVal);
		[propget, id(6), helpstring("property TotalErrors")] HRESULT TotalErrors([out, retval] long *pVal);
		[propget, id(7), helpstring("property ErrorWarning")] HRESULT ErrorWarning([out, retval] BSTR *pVal);
		[propget, id(8), helpstring("property Option")] HRESULT Option([out, retval] ItidyOption* *pVal);
		[id(9), helpstring("method EfTidyNode")] HRESULT EfTidyNode([in]EfTidyMainNode Type,[out,retval]IEfTidyNode **ppNewEfTidyNode);
	};
	[
		object,
		uuid(F3651919-EF0D-4685-8A67-BE1F280288AD),
		dual,
		helpstring("ItidyOption Interface"),
		pointer_default(unique)
	]
	interface ItidyOption : IDispatch
	{ 

	//Configuration Settings
		[id(1), helpstring("method LoadConfigFile :Load option settings from a configuration file")]
		HRESULT LoadConfigFile([in]BSTR ConfigFile);

		[id(2), helpstring("method ResetToDefaultValue : Reset options to default settings")] 
		HRESULT ResetToDefaultValue();
	

	//MarkUp
		[propget, id(3), helpstring("property Doctype:Doctype declaration generated by Tidy")]
		 HRESULT Doctype([out, retval] BSTR *pVal);
		[propput, id(3), helpstring("property Doctype:Doctype declaration generated by Tidy")] 
		HRESULT Doctype([in] BSTR newVal);
		
		  
		[propget, id(4), helpstring("property TidyMark: Add meta element indicating tidied doc")]
		 HRESULT TidyMark([out, retval] VARIANT_BOOL *pVal);
		[propput, id(4), helpstring("property TidyMark: Add meta element indicating tidied doc")] 
		HRESULT TidyMark([in] VARIANT_BOOL newVal);
		
		
		[propget, id(5), helpstring("property HideEndTag")] HRESULT HideEndTag([out, retval] VARIANT_BOOL *pVal);
		[propput, id(5), helpstring("property HideEndTag")] HRESULT HideEndTag([in] VARIANT_BOOL newVal);
		[propget, id(6), helpstring("property EncloseText")] HRESULT EncloseText([out, retval] VARIANT_BOOL *pVal);
		[propput, id(6), helpstring("property EncloseText")] HRESULT EncloseText([in] VARIANT_BOOL newVal);
		[propget, id(7), helpstring("property EncloseBlockText")] HRESULT EncloseBlockText([out, retval] VARIANT_BOOL *pVal);
		[propput, id(7), helpstring("property EncloseBlockText")] HRESULT EncloseBlockText([in] VARIANT_BOOL newVal);

	//CleanUP
	    [propget, id(8), helpstring("property LogicalEmphasis")] HRESULT LogicalEmphasis([out, retval] VARIANT_BOOL *pVal);
		[propput, id(8), helpstring("property LogicalEmphasis")] HRESULT LogicalEmphasis([in] VARIANT_BOOL newVal);
		[propget, id(9), helpstring("property DefaultAltText")] HRESULT DefaultAltText([out, retval] BSTR *pVal);
		[propput, id(9), helpstring("property DefaultAltText")] HRESULT DefaultAltText([in] BSTR newVal);
		[propget, id(10), helpstring("property Clean")] HRESULT Clean([out, retval] VARIANT_BOOL *pVal);
		[propput, id(10), helpstring("property Clean")] HRESULT Clean([in] VARIANT_BOOL newVal);
		[propget, id(11), helpstring("property DropFontTags")] HRESULT DropFontTags([out, retval] VARIANT_BOOL *pVal);
		[propput, id(11), helpstring("property DropFontTags")] HRESULT DropFontTags([in] VARIANT_BOOL newVal);
		[propget, id(12), helpstring("property DropEmptyParas")] HRESULT DropEmptyParas([out, retval] VARIANT_BOOL *pVal);
		[propput, id(12), helpstring("property DropEmptyParas")] HRESULT DropEmptyParas([in] VARIANT_BOOL newVal);
		[propget, id(13), helpstring("property Word2000")] HRESULT Word2000([out, retval] VARIANT_BOOL *pVal);
		[propput, id(13), helpstring("property Word2000")] HRESULT Word2000([in] VARIANT_BOOL newVal);
		[propget, id(14), helpstring("property FixBadComment")] HRESULT FixBadComment([out, retval] VARIANT_BOOL *pVal);
		[propput, id(14), helpstring("property FixBadComment")] HRESULT FixBadComment([in] VARIANT_BOOL newVal);
		[propget, id(15), helpstring("property FixBackslash")] HRESULT FixBackslash([out, retval] VARIANT_BOOL *pVal);
		[propput, id(15), helpstring("property FixBackslash")] HRESULT FixBackslash([in] VARIANT_BOOL newVal);
		[propget, id(16), helpstring("property NewEmptyTags")] HRESULT NewEmptyTags([out, retval] BSTR *pVal);
		[propput, id(16), helpstring("property NewEmptyTags")] HRESULT NewEmptyTags([in] BSTR newVal);
		[propget, id(17), helpstring("property NewInlineTags")] HRESULT NewInlineTags([out, retval] BSTR *pVal);
		[propput, id(17), helpstring("property NewInlineTags")] HRESULT NewInlineTags([in] BSTR newVal);
		[propget, id(18), helpstring("property NewBlockLevelTags")] HRESULT NewBlockLevelTags([out, retval] BSTR *pVal);
		[propput, id(18), helpstring("property NewBlockLevelTags")] HRESULT NewBlockLevelTags([in] BSTR newVal);
		[propget, id(19), helpstring("property NewPreTags")] HRESULT NewPreTags([out, retval] BSTR *pVal);
		[propput, id(19), helpstring("property NewPreTags")] HRESULT NewPreTags([in] BSTR newVal);
	    //new Added
		[propget, id(33), helpstring("property Bare")] HRESULT Bare([out, retval] VARIANT_BOOL *pVal);
		[propput, id(33), helpstring("property Bare")] HRESULT Bare([in] VARIANT_BOOL newVal);
		[propget, id(34), helpstring("property DropPropAttr")] HRESULT DropPropAttr([out, retval] VARIANT_BOOL *pVal);
		[propput, id(34), helpstring("property DropPropAttr")] HRESULT DropPropAttr([in] VARIANT_BOOL newVal);
			
	//XML
		[propget, id(20), helpstring("property OutputType")] HRESULT OutputType([out, retval] OutputType *pVal);
		[propput, id(20), helpstring("property OutputType")] HRESULT OutputType([in] OutputType newVal);
		[propget, id(21), helpstring("property InputAsXML")] HRESULT InputAsXML([out, retval] VARIANT_BOOL *pVal);
		[propput, id(21), helpstring("property InputAsXML")] HRESULT InputAsXML([in] VARIANT_BOOL newVal);
		[propget, id(22), helpstring("property ADDXmlDecl")] HRESULT ADDXmlDecl([out, retval] VARIANT_BOOL *pVal);
		[propput, id(22), helpstring("property ADDXmlDecl")] HRESULT ADDXmlDecl([in] VARIANT_BOOL newVal);
		[propget, id(23), helpstring("property AddXmlSpace")] HRESULT AddXmlSpace([out, retval] VARIANT_BOOL *pVal);
		[propput, id(23), helpstring("property AddXmlSpace")] HRESULT AddXmlSpace([in] VARIANT_BOOL newVal);
		[propget, id(24), helpstring("property AssumeXmlProcins")] HRESULT AssumeXmlProcins([out, retval] VARIANT_BOOL *pVal);
		[propput, id(24), helpstring("property AssumeXmlProcins")] HRESULT AssumeXmlProcins([in] VARIANT_BOOL newVal);
	//EnCoding
		[propget, id(43), helpstring("property CharEncoding")] HRESULT CharEncoding([out, retval] CharEncodingType *pVal);
		[propput, id(43), helpstring("property CharEncoding")] HRESULT CharEncoding([in] CharEncodingType newVal);
		[propget, id(46), helpstring("property NumericsEntities")] HRESULT NumericsEntities([out, retval] VARIANT_BOOL *pVal);
		[propput, id(46), helpstring("property NumericsEntities")] HRESULT NumericsEntities([in] VARIANT_BOOL newVal);
		[propget, id(47), helpstring("property QuoteMarks")] HRESULT QuoteMarks([out, retval] VARIANT_BOOL *pVal);
		[propput, id(47), helpstring("property QuoteMarks")] HRESULT QuoteMarks([in] VARIANT_BOOL newVal);
		[propget, id(48), helpstring("property QuoteNBSP")] HRESULT QuoteNBSP([out, retval] VARIANT_BOOL *pVal);
		[propput, id(48), helpstring("property QuoteNBSP")] HRESULT QuoteNBSP([in] VARIANT_BOOL newVal);
		[propget, id(49), helpstring("property QuoteAmpersand")] HRESULT QuoteAmpersand([out, retval] VARIANT_BOOL *pVal);
		[propput, id(49), helpstring("property QuoteAmpersand")] HRESULT QuoteAmpersand([in] VARIANT_BOOL newVal);
		
	  //New Added in encoding
		[propget, id(44), helpstring("property InCharEncoding")] HRESULT InCharEncoding([out, retval] CharEncodingType *pVal);
		[propput, id(44), helpstring("property InCharEncoding")] HRESULT InCharEncoding([in] CharEncodingType newVal);
		[propget, id(45), helpstring("property OutCharEncoding")] HRESULT OutCharEncoding([out, retval] CharEncodingType *pVal);
		[propput, id(45), helpstring("property OutCharEncoding")] HRESULT OutCharEncoding([in] CharEncodingType newVal);
	
		//Layout
		[propget, id(35), helpstring("property OutputTagInUpperCase")] HRESULT OutputTagInUpperCase([out, retval] VARIANT_BOOL *pVal);
		[propput, id(35), helpstring("property OutputTagInUpperCase")] HRESULT OutputTagInUpperCase([in] VARIANT_BOOL newVal);
		[propget, id(36), helpstring("property OutputAttrInUpperCase")] HRESULT OutputAttrInUpperCase([out, retval] VARIANT_BOOL *pVal);
		[propput, id(36), helpstring("property OutputAttrInUpperCase")] HRESULT OutputAttrInUpperCase([in] VARIANT_BOOL newVal);
		[propget, id(37), helpstring("property WrapScriptlets")] HRESULT WrapScriptlets([out, retval] VARIANT_BOOL *pVal);
		[propput, id(37), helpstring("property WrapScriptlets")] HRESULT WrapScriptlets([in] VARIANT_BOOL newVal);
		[propget, id(38), helpstring("property WrapAttVals")] HRESULT WrapAttVals([out, retval] VARIANT_BOOL *pVal);
		[propput, id(38), helpstring("property WrapAttVals")] HRESULT WrapAttVals([in] VARIANT_BOOL newVal);
		[propget, id(39), helpstring("property WrapSection")] HRESULT WrapSection([out, retval] VARIANT_BOOL *pVal);
		[propput, id(39), helpstring("property WrapSection")] HRESULT WrapSection([in] VARIANT_BOOL newVal);
		[propget, id(40), helpstring("property WrapAsp")] HRESULT WrapAsp([out, retval] VARIANT_BOOL *pVal);
		[propput, id(40), helpstring("property WrapAsp")] HRESULT WrapAsp([in] VARIANT_BOOL newVal);
		[propget, id(41), helpstring("property WrapJste")] HRESULT WrapJste([out, retval] VARIANT_BOOL *pVal);
		[propput, id(41), helpstring("property WrapJste")] HRESULT WrapJste([in] VARIANT_BOOL newVal);
		[propget, id(42), helpstring("property WrapPhp")] HRESULT WrapPhp([out, retval] VARIANT_BOOL *pVal);
		[propput, id(42), helpstring("property WrapPhp")] HRESULT WrapPhp([in] VARIANT_BOOL newVal);
		[propget, id(50), helpstring("property Indent")] HRESULT Indent([out, retval] IndentScheme *pVal);
		[propput, id(50), helpstring("property Indent")] HRESULT Indent([in] IndentScheme newVal);
		[propget, id(51), helpstring("property IndentSpace")] HRESULT IndentSpace([out, retval] long *pVal);
		[propput, id(51), helpstring("property IndentSpace")] HRESULT IndentSpace([in] long newVal);
		[propget, id(52), helpstring("property WrapLen")] HRESULT WrapLen([out, retval] long *pVal);
		[propput, id(52), helpstring("property WrapLen")] HRESULT WrapLen([in] long newVal);
		[propget, id(53), helpstring("property TabSize")] HRESULT TabSize([out, retval] long *pVal);
		[propput, id(53), helpstring("property TabSize")] HRESULT TabSize([in] long newVal);
		[propget, id(54), helpstring("property IndentAttributes")] HRESULT IndentAttributes([out, retval] VARIANT_BOOL *pVal);
		[propput, id(54), helpstring("property IndentAttributes")] HRESULT IndentAttributes([in] VARIANT_BOOL newVal);
		[propget, id(55), helpstring("property BreakBeforeBR")] HRESULT BreakBeforeBR([out, retval] VARIANT_BOOL *pVal);
		[propput, id(55), helpstring("property BreakBeforeBR")] HRESULT BreakBeforeBR([in] VARIANT_BOOL newVal);
		[propget, id(56), helpstring("property LiteralAttribs")] HRESULT LiteralAttribs([out, retval] VARIANT_BOOL *pVal);
		[propput, id(56), helpstring("property LiteralAttribs")] HRESULT LiteralAttribs([in] VARIANT_BOOL newVal);
	
	//Operation
		[propget, id(57), helpstring("property MarkUp")] HRESULT MarkUp([out, retval] VARIANT_BOOL *pVal);
		[propput, id(57), helpstring("property MarkUp")] HRESULT MarkUp([in] VARIANT_BOOL newVal);
		[propget, id(58), helpstring("property ShowWarnings")] HRESULT ShowWarnings([out, retval] VARIANT_BOOL *pVal);
		[propput, id(58), helpstring("property ShowWarnings")] HRESULT ShowWarnings([in] VARIANT_BOOL newVal);
		[propget, id(59), helpstring("property Quiet")] HRESULT Quiet([out, retval] VARIANT_BOOL *pVal);
		[propput, id(59), helpstring("property Quiet")] HRESULT Quiet([in] VARIANT_BOOL newVal);
		[propget, id(60), helpstring("property KeepTime")] HRESULT KeepTime([out, retval] VARIANT_BOOL *pVal);
		[propput, id(60), helpstring("property KeepTime")] HRESULT KeepTime([in] VARIANT_BOOL newVal);
		[propget, id(61), helpstring("property ErrorFile")] HRESULT ErrorFile([out, retval] BSTR *pVal);
		[propput, id(61), helpstring("property ErrorFile")] HRESULT ErrorFile([in] BSTR newVal);
		[propget, id(62), helpstring("property GnuEmacs")] HRESULT GnuEmacs([out, retval] VARIANT_BOOL *pVal);
		[propput, id(62), helpstring("property GnuEmacs")] HRESULT GnuEmacs([in] VARIANT_BOOL newVal);
		
		//newly added
		[propget, id(63), helpstring("property FixUrl")] HRESULT FixUrl([out, retval] VARIANT_BOOL *pVal);
		[propput, id(63), helpstring("property FixUrl")] HRESULT FixUrl([in] VARIANT_BOOL newVal);
		[propget, id(64), helpstring("property BodyOnly")] HRESULT BodyOnly([out, retval] VARIANT_BOOL *pVal);
		[propput, id(64), helpstring("property BodyOnly")] HRESULT BodyOnly([in] VARIANT_BOOL newVal);
		[propget, id(65), helpstring("property HideComments")] HRESULT HideComments([out, retval] VARIANT_BOOL *pVal);
		[propput, id(65), helpstring("property HideComments")] HRESULT HideComments([in] VARIANT_BOOL newVal);
		[propget, id(66), helpstring("property DoctypeMode")] HRESULT DoctypeMode([out, retval] DoctypeModes *pVal);
		[propput, id(66), helpstring("property DoctypeMode")] HRESULT DoctypeMode([in] DoctypeModes newVal);
	
	};
	[
		object,
		uuid(AD02C5B4-4F57-48CE-8EBF-FDFCC91C6827),
		dual,
		helpstring("IEfTidyNode Interface"),
		pointer_default(unique)
	]

	interface IEfTidyNode : IDispatch
	{
		[propget, id(1), helpstring("property Name")] HRESULT Name([out, retval] BSTR *pVal);
		[id(2), helpstring("method GetFirstChildNode")] HRESULT GetFirstChildNode([out,retval]IEfTidyNode **ppNewNode);
		[id(3), helpstring("method GetNextChildNode")] HRESULT GetNextChildNode([out,retval]IEfTidyNode **ppNewNode);
		[id(4), helpstring("method GetFirstAttribute")] HRESULT GetFirstAttribute([out,retval]IEfTidyAttr  **ppNewAttr);
		[id(5), helpstring("method GetNextAttribute")] HRESULT GetNextAttribute([out,retval]IEfTidyAttr  **ppNewAttr);
		
	};
	[
		object,
		uuid(FCDBA5A8-E9E6-49B2-A7F7-BE7204A6D8E7),
		dual,
		helpstring("IEfTidyAttr Interface"),
		pointer_default(unique)
	]
	interface IEfTidyAttr : IDispatch
	{
		[propget, id(1), helpstring("property Name")] HRESULT Name([out, retval] BSTR *pVal);
		[propget, id(2), helpstring("property Value")] HRESULT Value([out, retval] BSTR *pVal);
	};

[
	uuid(7F1DF5A6-127B-41A5-98F1-21F07E40F9E0),
	version(1.0),
	helpstring("EfTidy 1.0 Type Library")
]
library EFTIDYLib
{
	importlib("stdole32.tlb");
	importlib("stdole2.tlb");

	[
		uuid(C7CB7E40-B6ED-4400-B1BD-4F84CB6D3CB0),
		helpstring("tidyCom Class")
	]
	coclass tidyCom
	{
		[default] interface ItidyCom;
	};
	[
		uuid(27185B44-3FBD-40BE-B6E9-BECD53FF19B9),
		helpstring("tidyOption Class"),
		noncreatable
	]
	coclass tidyOption
	{
		[default] interface ItidyOption;
	
	};
	[
		uuid(CF1F556D-8C33-421B-A6CA-D01207655A6D),
		helpstring("EfTidyNode Class")
	]
	coclass EfTidyNode
	{
		[default] interface IEfTidyNode;
	};
	[
		uuid(329BE6B4-8E18-41E5-A565-CBA306071361),
		helpstring("EfTidyAttr Class")
	]
	coclass EfTidyAttr
	{
		[default] interface IEfTidyAttr;
	};
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
India India
He used to have biography here Smile | :) , but now he will hire someone (for free offcourse Big Grin | :-D ), Who writes his biography on his behalf Smile | :)

He is Great Fan of Mr. Johan Rosengren (his idol),Lim Bio Liong, Nishant S and DavidCrow and Believes that, he will EXCEL in his life by following there steps!!!

He started with Visual C++ then moved to C# then he become language agnostic, you give him task,tell him the language or platform, he we start immediately, if he knows the language otherwise he quickly learn it and start contributing productively

Last but not the least, For good 8 years he was Visual CPP MSMVP!

Comments and Discussions