diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-07-22 15:39:18 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-07-22 22:06:26 -0400 |
commit | 8ebb30fbc4e2f33bf76ccbacf1b569d68ae46e62 (patch) | |
tree | 0957131ab9e1265ab8af104d664b362cb561f999 /svtools | |
parent | 7e88c5ee4601fca83dede7dd170b8670e27c05b0 (diff) |
Converted HTMLOptions to boost::ptr_vector.
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/inc/svtools/parhtml.hxx | 14 | ||||
-rw-r--r-- | svtools/source/svhtml/htmlsupp.cxx | 22 | ||||
-rw-r--r-- | svtools/source/svhtml/parhtml.cxx | 47 |
3 files changed, 38 insertions, 45 deletions
diff --git a/svtools/inc/svtools/parhtml.hxx b/svtools/inc/svtools/parhtml.hxx index 4b8df0ac0cb3..627e7870e0ff 100644 --- a/svtools/inc/svtools/parhtml.hxx +++ b/svtools/inc/svtools/parhtml.hxx @@ -35,6 +35,7 @@ #include <svl/svarray.hxx> #include <svtools/svparser.hxx> +#include <boost/ptr_container/ptr_vector.hpp> namespace com { namespace sun { namespace star { namespace document { @@ -130,11 +131,13 @@ public: //SvxAdjust GetAdjust() const; // <P,TH,TD ALIGN=> }; -typedef HTMLOption* HTMLOptionPtr; -SV_DECL_PTRARR(HTMLOptions,HTMLOptionPtr,16,16) +typedef ::boost::ptr_vector<HTMLOption> HTMLOptions; class SVT_DLLPUBLIC HTMLParser : public SvParser { +private: + mutable HTMLOptions maOptions; // die Optionen des Start-Tags + bool bNewDoc : 1; // neues Doc lesen ? bool bIsInHeader : 1; // scanne Header-Bereich bool bIsInBody : 1; // scanne Body-Bereich @@ -152,7 +155,6 @@ class SVT_DLLPUBLIC HTMLParser : public SvParser sal_uInt32 nPre_LinePos; // Pos in der Line im PRE-Tag - HTMLOptions *pOptions; // die Optionen des Start-Tags String aEndToken; protected: @@ -223,7 +225,7 @@ public: // Ermitteln der Optionen. pNoConvertToken ist das optionale Token // einer Option, fuer die CR/LFs nicht aus dem Wert der Option // geloescht werden. - const HTMLOptions *GetOptions( sal_uInt16 *pNoConvertToken=0 ) const; + const HTMLOptions& GetOptions( sal_uInt16 *pNoConvertToken=0 ) const; // fuers asynchrone lesen aus dem SvStream virtual void Continue( int nToken ); @@ -241,7 +243,7 @@ private: bool ParseMetaOptionsImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties>&, SvKeyValueIterator*, - const HTMLOptions*, + const HTMLOptions&, rtl_TextEncoding& rEnc ); public: @@ -259,7 +261,7 @@ public: bool bSwitchToUCS2 = false, rtl_TextEncoding eEnc=RTL_TEXTENCODING_DONTKNOW ); - sal_Bool ParseScriptOptions( String& rLangString, const String&, HTMLScriptLanguage& rLang, + bool ParseScriptOptions( String& rLangString, const String&, HTMLScriptLanguage& rLang, String& rSrc, String& rLibrary, String& rModule ); // Einen Kommentar um den Inhalt von <SCRIPT> oder <STYLE> entfernen diff --git a/svtools/source/svhtml/htmlsupp.cxx b/svtools/source/svhtml/htmlsupp.cxx index 97867c1341bb..187273b434cd 100644 --- a/svtools/source/svhtml/htmlsupp.cxx +++ b/svtools/source/svhtml/htmlsupp.cxx @@ -51,13 +51,13 @@ static HTMLOptionEnum const aScriptLangOptEnums[] = { 0, 0 } }; -sal_Bool HTMLParser::ParseScriptOptions( String& rLangString, const String& rBaseURL, +bool HTMLParser::ParseScriptOptions( String& rLangString, const String& rBaseURL, HTMLScriptLanguage& rLang, String& rSrc, String& rLibrary, String& rModule ) { - const HTMLOptions *pScriptOptions = GetOptions(); + const HTMLOptions& aScriptOptions = GetOptions(); rLangString.Erase(); rLang = HTML_SL_JAVASCRIPT; @@ -65,16 +65,16 @@ sal_Bool HTMLParser::ParseScriptOptions( String& rLangString, const String& rBas rLibrary.Erase(); rModule.Erase(); - for( sal_uInt16 i = pScriptOptions->Count(); i; ) + for( size_t i = aScriptOptions.size(); i; ) { - const HTMLOption *pOption = (*pScriptOptions)[ --i ]; - switch( pOption->GetToken() ) + const HTMLOption& aOption = aScriptOptions[--i]; + switch( aOption.GetToken() ) { case HTML_O_LANGUAGE: { - rLangString = pOption->GetString(); + rLangString = aOption.GetString(); sal_uInt16 nLang; - if( pOption->GetEnum( nLang, aScriptLangOptEnums ) ) + if( aOption.GetEnum( nLang, aScriptLangOptEnums ) ) rLang = (HTMLScriptLanguage)nLang; else rLang = HTML_SL_UNKNOWN; @@ -82,19 +82,19 @@ sal_Bool HTMLParser::ParseScriptOptions( String& rLangString, const String& rBas break; case HTML_O_SRC: - rSrc = INetURLObject::GetAbsURL( rBaseURL, pOption->GetString() ); + rSrc = INetURLObject::GetAbsURL( rBaseURL, aOption.GetString() ); break; case HTML_O_SDLIBRARY: - rLibrary = pOption->GetString(); + rLibrary = aOption.GetString(); break; case HTML_O_SDMODULE: - rModule = pOption->GetString(); + rModule = aOption.GetString(); break; } } - return sal_True; + return true; } void HTMLParser::RemoveSGMLComment( String &rString, sal_Bool bFull ) diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index f49b9e31b765..acb8635cb536 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -52,6 +52,7 @@ #include <svtools/htmltokn.h> #include <svtools/htmlkywd.hxx> +#include <memory> using namespace ::com::sun::star; @@ -108,10 +109,6 @@ static HTMLOptionEnum const aTableRulesOptEnums[] = { 0, 0 } }; - -SV_IMPL_PTRARR(HTMLOptions,HTMLOptionPtr) - - sal_uInt16 HTMLOption::GetEnum( const HTMLOptionEnum *pOptEnums, sal_uInt16 nDflt ) const { sal_uInt16 nValue = nDflt; @@ -323,17 +320,12 @@ HTMLParser::HTMLParser( SvStream& rIn, bool bReadNewDoc ) : bReadNextChar(false), bReadComment(false) { - pOptions = new HTMLOptions; - //#i76649, default to UTF-8 for HTML unless we know differently SetSrcEncoding(RTL_TEXTENCODING_UTF8); } HTMLParser::~HTMLParser() { - if( pOptions && pOptions->Count() ) - pOptions->DeleteAndDestroy( 0, pOptions->Count() ); - delete pOptions; } SvParserState HTMLParser::CallParser() @@ -1085,8 +1077,8 @@ int HTMLParser::_GetNextToken() sSaveToken.Erase(); // Delete options - if( pOptions->Count() ) - pOptions->DeleteAndDestroy( 0, pOptions->Count() ); + if (!maOptions.empty()) + maOptions.clear(); if( !IsParserWorking() ) // Don't continue if already an error occured return 0; @@ -1459,12 +1451,12 @@ void HTMLParser::UnescapeToken() } } -const HTMLOptions *HTMLParser::GetOptions( sal_uInt16 *pNoConvertToken ) const +const HTMLOptions& HTMLParser::GetOptions( sal_uInt16 *pNoConvertToken ) const { // If the options for the current token have already been returned, // return them once again. - if( pOptions->Count() ) - return pOptions; + if (!maOptions.empty()) + return maOptions; xub_StrLen nPos = 0; while( nPos < aToken.Len() ) @@ -1613,11 +1605,10 @@ const HTMLOptions *HTMLParser::GetOptions( sal_uInt16 *pNoConvertToken ) const } // Token is known and can be saved - HTMLOption *pOption = - new HTMLOption( - sal::static_int_cast< sal_uInt16 >(nToken), sName, aValue ); + std::auto_ptr<HTMLOption> pOption( + new HTMLOption(sal::static_int_cast<sal_uInt16>(nToken), sName, aValue)); - pOptions->Insert( pOption, pOptions->Count() ); + maOptions.push_back(pOption); } else @@ -1625,7 +1616,7 @@ const HTMLOptions *HTMLParser::GetOptions( sal_uInt16 *pNoConvertToken ) const nPos++; } - return pOptions; + return maOptions; } int HTMLParser::FilterPRE( int nToken ) @@ -2100,32 +2091,32 @@ void HTMLParser::AddMetaUserDefined( ::rtl::OUString const & ) bool HTMLParser::ParseMetaOptionsImpl( const uno::Reference<document::XDocumentProperties> & i_xDocProps, SvKeyValueIterator *i_pHTTPHeader, - const HTMLOptions *i_pOptions, + const HTMLOptions& aOptions, rtl_TextEncoding& o_rEnc ) { String aName, aContent; sal_uInt16 nAction = HTML_META_NONE; bool bHTTPEquiv = false, bChanged = false; - for ( sal_uInt16 i = i_pOptions->Count(); i; ) + for ( size_t i = aOptions.size(); i; ) { - const HTMLOption *pOption = (*i_pOptions)[ --i ]; - switch ( pOption->GetToken() ) + const HTMLOption& aOption = aOptions[--i]; + switch ( aOption.GetToken() ) { case HTML_O_NAME: - aName = pOption->GetString(); + aName = aOption.GetString(); if ( HTML_META_NONE==nAction ) { - pOption->GetEnum( nAction, aHTMLMetaNameTable ); + aOption.GetEnum( nAction, aHTMLMetaNameTable ); } break; case HTML_O_HTTPEQUIV: - aName = pOption->GetString(); - pOption->GetEnum( nAction, aHTMLMetaNameTable ); + aName = aOption.GetString(); + aOption.GetEnum( nAction, aHTMLMetaNameTable ); bHTTPEquiv = true; break; case HTML_O_CONTENT: - aContent = pOption->GetString(); + aContent = aOption.GetString(); break; } } |