From 29400c568a84339066ef238e836cfeb19f732873 Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Thu, 2 May 2013 15:06:23 +0200 Subject: Some code scrubing Add doxygen documentation for classes and methods Delete useless comments. Add include guards where missing. Delete some useless typedef. Change-Id: I9bba16560790239d7775fcd40981465e70e5d437 --- l10ntools/inc/cfgmerge.hxx | 19 +++-------- l10ntools/inc/common.hxx | 7 +++-- l10ntools/inc/export.hxx | 70 +++++++++++++++++------------------------ l10ntools/inc/helper.hxx | 9 ++++-- l10ntools/inc/lngmerge.hxx | 14 +++++++-- l10ntools/inc/po.hxx | 10 +++--- l10ntools/inc/propmerge.hxx | 10 +++--- l10ntools/inc/treemerge.hxx | 18 ++++++----- l10ntools/inc/xmlparse.hxx | 25 +++++++-------- l10ntools/inc/xrmmerge.hxx | 17 +++++----- l10ntools/source/cfgmerge.cxx | 30 +++--------------- l10ntools/source/export.cxx | 39 +++++------------------ l10ntools/source/merge.cxx | 10 +++--- l10ntools/source/po.cxx | 69 +++++++++++++--------------------------- l10ntools/source/treemerge.cxx | 15 ++++----- l10ntools/source/xrmmerge.cxx | 71 ++++++------------------------------------ 16 files changed, 151 insertions(+), 282 deletions(-) diff --git a/l10ntools/inc/cfgmerge.hxx b/l10ntools/inc/cfgmerge.hxx index 9710008707aa..03addd1ada04 100644 --- a/l10ntools/inc/cfgmerge.hxx +++ b/l10ntools/inc/cfgmerge.hxx @@ -64,12 +64,10 @@ public: // class CfgStack // -typedef std::vector< CfgStackData* > CfgStackList; - class CfgStack { private: - CfgStackList maList; + std::vector< CfgStackData* > maList; public: CfgStack() {} @@ -92,10 +90,7 @@ public: size_t size() const { return maList.size(); } }; -// -// class CfgParser -// - +/// Parser for *.xcu files class CfgParser { protected: @@ -136,10 +131,7 @@ public: int Execute( int nToken, char * pToken ); }; -// -// class CfgExport -// - +/// Export strings from *.xcu files class CfgExport : public CfgParser { private: @@ -162,10 +154,7 @@ public: ~CfgExport(); }; -// -// class CfgMerge -// - +/// Merge strings to *.xcu files class CfgMerge : public CfgParser { private: diff --git a/l10ntools/inc/common.hxx b/l10ntools/inc/common.hxx index 93f2d008cb82..5a12bbbbebe4 100644 --- a/l10ntools/inc/common.hxx +++ b/l10ntools/inc/common.hxx @@ -7,7 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/// Methods used by all of executables +// Methods used by all of executables #ifndef INCLUDED_L10NTOOLS_SOURCE_COMMON_HXX #define INCLUDED_L10NTOOLS_SOURCE_COMMON_HXX @@ -20,7 +20,7 @@ namespace common { -//result type of handleArguments() +/// Result type of handleArguments() struct HandledArgs { OString m_sInputFile; @@ -37,10 +37,13 @@ struct HandledArgs {} }; +/// Handle command line parameters bool handleArguments(int argc, char * argv[], HandledArgs& o_aHandledArgs); +/// Write out a help about usage void writeUsage(const OString& rName, const OString& rFileType); +/// Write out a PoEntry with attention to excaptions void writePoEntry( const OString& rExecutable, PoOfstream& rPoStream, const OString& rSourceFile, const OString& rResType, const OString& rGroupId, const OString& rLocalId, diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx index a7f8ea126583..d23cc6f29e5e 100644 --- a/l10ntools/inc/export.hxx +++ b/l10ntools/inc/export.hxx @@ -30,9 +30,9 @@ #include #include -#include /* std::iterator*/ -#include /* std::set*/ -#include /* std::vector*/ +#include +#include +#include #include #include @@ -44,7 +44,6 @@ #define NO_TRANSLATE_ISO "x-no-translate" class MergeEntrys; -class MergeData; typedef boost::unordered_map OStringHashMap; @@ -56,17 +55,18 @@ typedef boost::unordered_map #define X_COMMENT "x-comment" #define LIST_REFID "LIST_REFID" -typedef OStringHashMap ExportListEntry; -typedef ::std::vector< ExportListEntry* > ExportListBase; - // // class ExportList // +typedef OStringHashMap ExportListEntry; + + +/// Container for parse different types of string lists class ExportList { private: - ExportListBase maList; + std::vector< ExportListEntry* > maList; std::size_t nSourceLanguageListEntryCount; public: @@ -85,13 +85,9 @@ public: #define REFID_NONE 0xFFFF // -// struct ResData +// class ResData // -/****************************************************************************** -* Purpose: holds mandatory data to export a single res (used with ResStack) -******************************************************************************/ - #define ID_LEVEL_NULL 0x0000 #define ID_LEVEL_AUTOID 0x0001 #define ID_LEVEL_TEXT 0x0002 @@ -100,6 +96,8 @@ public: #define ID_LEVEL_IDENTIFIER 0x0005 #define ID_LEVEL_LISTINDEX 0x0006 + +/// Purpose: holds mandatory data to export a single res (used with ResStack) class ResData { public: @@ -146,10 +144,6 @@ public: // class Export // -/****************************************************************************** -* Purpose: syntax check and export of *.src, called from lexer -******************************************************************************/ - #define LIST_NON 0x0000 #define LIST_STRING 0x0001 #define LIST_FILTER 0x0002 @@ -165,9 +159,9 @@ public: #define MERGE_MODE_LIST 0x0001 typedef ::std::vector< ResData* > ResStack; -// forwards class ParserQueue; +/// Purpose: syntax check and export of *.src, called from lexer class Export { private: @@ -178,12 +172,12 @@ private: } aOutput; - ResStack aResStack; // stack for parsing recursive + ResStack aResStack; ///< stack for parsing recursive sal_Bool bDefine; // cur. res. in a define? - sal_Bool bNextMustBeDefineEOL; // define but no \ at lineend + sal_Bool bNextMustBeDefineEOL; ///< define but no \ at lineend std::size_t nLevel; // res. recursiv? how deep? - sal_uInt16 nList; // cur. res. is String- or FilterList + sal_uInt16 nList; ///< cur. res. is List OString m_sListLang; std::size_t nListIndex; std::size_t nListLevel; @@ -199,13 +193,13 @@ private: std::vector aLanguages; - sal_Bool WriteData( ResData *pResData, sal_Bool bCreateNew = sal_False );// called befor dest. cur ResData + sal_Bool WriteData( ResData *pResData, sal_Bool bCreateNew = sal_False ); ///< called befor dest. cur ResData sal_Bool WriteExportList( ResData *pResData, ExportList *pExportList, const OString &rTyp, sal_Bool bCreateNew = sal_False ); OString MergePairedList( OString const & sLine , OString const & sText ); - OString FullId(); // creates cur. GID + OString FullId(); ///< creates cur. GID OString GetPairedListID(const OString & rText); OString GetPairedListString(const OString& rText); @@ -237,7 +231,7 @@ public: ~Export(); void Init(); - int Execute( int nToken, const char * pToken ); // called from lexer + int Execute( int nToken, const char * pToken ); ///< called from lexer void SetError() { bError = sal_True; } sal_Bool GetError() { return bError; } ParserQueue* pParseQueue; // public!! @@ -248,10 +242,7 @@ public: // class MergeEntrys // -/** - * Purpose: holds information of data to merge - */ - +/// Purpose: holds information of data to merge class MergeEntrys { friend class MergeDataFile; @@ -286,6 +277,12 @@ public: }; +// +// class MergeDataHashMap +// + +class MergeData; + /** Container for MergeData This class is an HashMap with a hidden insertion @@ -331,12 +328,7 @@ class MergeDataHashMap // class MergeData // -/****************************************************************************** -* Purpose: holds information of data to merge (one resource) -******************************************************************************/ - -class MergeDataFile; - +/// Purpose: holds information of data to merge (one resource) class MergeData { friend class MergeDataHashMap; @@ -361,10 +353,7 @@ public: // class MergeDataFile // -/****************************************************************************** -* Purpose: holds information of data to merge -******************************************************************************/ - +/// Purpose: holds information of data to merge, read from PO file class MergeDataFile { private: @@ -421,11 +410,8 @@ public: void Close(); private: - // Future / Next std::queue* aQueueNext; - // Current std::queue* aQueueCur; - // Ref std::queue* aQref; Export& aExport; @@ -434,6 +420,6 @@ private: inline void Pop( std::queue& aQueue ); }; -#endif +#endif // _EXPORT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/helper.hxx b/l10ntools/inc/helper.hxx index 9ec399647c49..936010343f8f 100644 --- a/l10ntools/inc/helper.hxx +++ b/l10ntools/inc/helper.hxx @@ -7,7 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/// Helper methods to work with xml files +// Helper string methods #ifndef INCLUDED_L10NTOOLS_SOURCE_HELPER_HXX #define INCLUDED_L10NTOOLS_SOURCE_HELPER_HXX @@ -25,17 +25,22 @@ namespace helper { +/// Escape all given character in the text OString escapeAll( const OString& rText, const OString& rUnEscaped, const OString& rEscaped ); +/// Unescape all given character in the text OString unEscapeAll( const OString& rText, const OString& rEscaped, const OString& rUnEscaped ); +/// Convert special characters to XML entity references OString QuotHTML( const OString &rString ); +/// Convert XML entity references to single characters OString UnQuotHTML( const OString& rString ); +/// Check whether text is a valid XML expression bool isWellFormedXML( OString const & text ); -//Convert xmlChar* to OString +/// Convert xmlChar* to OString OString xmlStrToOString( const xmlChar* pString ); } diff --git a/l10ntools/inc/lngmerge.hxx b/l10ntools/inc/lngmerge.hxx index 0f98eac2dc9c..968bb3e4cd12 100644 --- a/l10ntools/inc/lngmerge.hxx +++ b/l10ntools/inc/lngmerge.hxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#ifndef LNGMERGE_INCLUDED +#define LNGMERGE_INCLUDED + #include "sal/config.h" #include @@ -30,10 +33,13 @@ typedef std::vector< OString* > LngLineList; #define LNG_OK 0x0000 #define LNG_COULD_NOT_OPEN 0x0001 -// -// class LngParser -// +/** + Class for localization of *.ulf files + + Parse *.ulf files, extract translatable strings + and merge translated strings. +*/ class LngParser { private: @@ -58,4 +64,6 @@ public: const OString &rLanguage ); }; +#endif // LNGMERGE_INCLUDED + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/po.hxx b/l10ntools/inc/po.hxx index 603727d8583b..1ec3b33e7861 100755 --- a/l10ntools/inc/po.hxx +++ b/l10ntools/inc/po.hxx @@ -52,16 +52,16 @@ public: PoEntry( const PoEntry& rPo ); PoEntry& operator=( const PoEntry& rPo ); - OString getSourceFile() const; + OString getSourceFile() const; ///< Get name of file from which entry is extracted OString getGroupId() const; OString getLocalId() const; - OString getResourceType() const; - TYPE getType() const; + OString getResourceType() const; ///< Get the type of component from which entry is extracted + TYPE getType() const; ///< Get the type of entry OString getMsgId() const; OString getMsgStr() const; bool isFuzzy() const; - OString getKeyId() const; + /// Check whether po-s belong to the same localization component static bool IsInSameComp(const PoEntry& rPo1,const PoEntry& rPo2); static OString genKeyId(const OString& rGenerator); @@ -85,7 +85,7 @@ public: friend class PoOfstream; friend class PoIfstream; - PoHeader( const OString& rExtSrc ); + PoHeader( const OString& rExtSrc ); ///< Template Constructor ~PoHeader(); }; diff --git a/l10ntools/inc/propmerge.hxx b/l10ntools/inc/propmerge.hxx index b6e2a0b3b85f..b4289655ecd8 100644 --- a/l10ntools/inc/propmerge.hxx +++ b/l10ntools/inc/propmerge.hxx @@ -13,11 +13,13 @@ #include #include -/** Class for properties localization +/** + Class for localization of *.properties files - Parse *.properties files, extract translatable strings - and merge translated strings. + Parse *.properties files, extract translatable strings + and merge translated strings. */ + class PropParser { private: @@ -37,5 +39,5 @@ public: void Merge( const OString &rMergeSrc, const OString &rDestinationFile ); }; -#endif //_PROPMERGE_INCLUDED +#endif // _PROPMERGE_INCLUDED /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/treemerge.hxx b/l10ntools/inc/treemerge.hxx index d3d15af0b3dc..c98b77b07ec5 100644 --- a/l10ntools/inc/treemerge.hxx +++ b/l10ntools/inc/treemerge.hxx @@ -14,11 +14,12 @@ #include #include -/** Class for tree localization +/** + Class for localization of *.tree files - Parse *.tree files, extract translatable strings, - merge translated strings and update reference and title - of referred help files. + Parse *.tree files, extract translatable strings, + merge translated strings and update reference and title + of referred help files. */ class TreeParser { @@ -28,16 +29,19 @@ private: bool m_bIsInitialized; public: - TreeParser( - const OString& rInputFile, const OString& rLang ); + /// Parse tree file + TreeParser( const OString& rInputFile, const OString& rLang ); ~TreeParser(); bool isInitialized() const { return m_bIsInitialized; } + /// Export strings void Extract( const OString& rPOFile ); + /// Merge strings to tree file and update reference to help files(xhp) void Merge( const OString &rMergeSrc, const OString &rDestinationFile, const OString &rXhpRoot ); }; -#endif //_TREEMERGE_INCLUDED +#endif // _TREEMERGE_INCLUDED + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/xmlparse.hxx b/l10ntools/inc/xmlparse.hxx index 8daf546fcc7f..62c24b63f7ae 100644 --- a/l10ntools/inc/xmlparse.hxx +++ b/l10ntools/inc/xmlparse.hxx @@ -123,9 +123,10 @@ typedef std::vector< XMLChildNode* > XMLChildNodeList; //------------------------------------------------------------------------- +class XMLData; + /** Virtual base to handle different kinds of parent nodes */ -class XMLData; class XMLParentNode : public XMLChildNode { @@ -140,7 +141,7 @@ protected: } XMLParentNode(): pChildList(NULL){ } - /// Copyconstructor + XMLParentNode( const XMLParentNode& ); XMLParentNode& operator=(const XMLParentNode& obj); @@ -178,7 +179,6 @@ typedef boost::unordered_map TagMap; /** Holds information of a XML file, is root node of tree */ - class XMLFile : public XMLParentNode { public: @@ -208,7 +208,7 @@ public: const std::vector getOrder(){ return order; } protected: - // writes a string as UTF8 with dos line ends to a given stream + /// writes a string as UTF8 with dos line ends to a given stream void WriteString( ofstream &rStream, const OUString &sString ); void InsertL10NElement( XMLElement* pElement); @@ -225,7 +225,6 @@ protected: }; /// An Utility class for XML -/// See RFC 3066 / #i8252# for ISO codes class XMLUtil{ public: @@ -237,7 +236,6 @@ public: }; - //------------------------------------------------------------------------- /** Hold information of an element node @@ -258,7 +256,7 @@ private: protected: void Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement); public: - /// create a element node + /// create an element node XMLElement(){} XMLElement( const OUString &rName, // the element name @@ -293,7 +291,7 @@ public: void ChangeLanguageTag( const OUString &rValue ); - // Return a Unicode String representation of this object + /// Return a Unicode String representation of this object OUString ToOUString(); void SetProject ( OString const & prj ){ project = prj; } @@ -417,10 +415,10 @@ public: /** struct for error information, used by class SimpleXMLParser */ struct XMLError { - XML_Error eCode; // the error code - std::size_t nLine; // error line number - std::size_t nColumn; // error column number - OUString sMessage; // readable error message + XML_Error eCode; ///< the error code + std::size_t nLine; ///< error line number + std::size_t nColumn; ///< error column number + OUString sMessage; ///< readable error message }; //------------------------------------------------------------------------- @@ -428,7 +426,6 @@ struct XMLError { /** validating xml parser, creates a document tree with xml nodes */ - class SimpleXMLParser { private: @@ -468,6 +465,6 @@ public: const XMLError &GetError() { return aErrorInformation; } }; -#endif +#endif // BOOTSTRP_XMLPARSE_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/xrmmerge.hxx b/l10ntools/inc/xrmmerge.hxx index a2a8906a1b17..f5de9af9bc2e 100644 --- a/l10ntools/inc/xrmmerge.hxx +++ b/l10ntools/inc/xrmmerge.hxx @@ -17,14 +17,15 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#ifndef XRMMERGE_INCLUDED +#define XRMMERGE_INCLUDED + #include "sal/config.h" #include -// -// XRMResParser -// +/// Parser for *.xrm and description.xml files class XRMResParser { private: @@ -68,10 +69,8 @@ public: sal_Bool GetError() { return bError; } }; -// -// XRMResExport -// +/// Export strings from *.xrm and description.xml files class XRMResExport : public XRMResParser { private: @@ -101,10 +100,8 @@ public: virtual ~XRMResExport(); }; -// -// class XRMResMerge -// +/// Merge strings to *.xrm and description.xml files class XRMResMerge : public XRMResParser { private: @@ -137,4 +134,6 @@ public: virtual ~XRMResMerge(); }; +#endif // XRMMERGE_INCLUDED + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx index 6a8d2d719bdc..98778a78b19e 100644 --- a/l10ntools/source/cfgmerge.cxx +++ b/l10ntools/source/cfgmerge.cxx @@ -99,9 +99,7 @@ CfgStackData* CfgStack::Push(const OString &rTag, const OString &rId) // class CfgStack // -/*****************************************************************************/ CfgStack::~CfgStack() -/*****************************************************************************/ { for ( size_t i = 0, n = maList.size(); i < n; i++ ) delete maList[ i ]; @@ -121,9 +119,7 @@ OString CfgStack::GetAccessPath( size_t nPos ) return sReturn.makeStringAndClear(); } -/*****************************************************************************/ CfgStackData *CfgStack::GetStackData() -/*****************************************************************************/ { if (!maList.empty()) return maList[maList.size() - 1]; @@ -135,9 +131,7 @@ CfgStackData *CfgStack::GetStackData() // class CfgParser // -/*****************************************************************************/ CfgParser::CfgParser() -/*****************************************************************************/ : pStackData( NULL ), bLocalize( sal_False ) { @@ -152,13 +146,10 @@ sal_Bool CfgParser::IsTokenClosed(const OString &rToken) return rToken[rToken.getLength() - 2] == '/'; } -/*****************************************************************************/ void CfgParser::AddText( OString &rText, const OString &rIsoLang, - const OString &rResTyp -) -/*****************************************************************************/ + const OString &rResTyp ) { rText = rText.replaceAll(OString('\n'), OString()). replaceAll(OString('\r'), OString()). @@ -168,9 +159,7 @@ void CfgParser::AddText( pStackData->sText[ rIsoLang ] = rText; } -/*****************************************************************************/ int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken ) -/*****************************************************************************/ { OString sToken( pToken ); @@ -312,9 +301,7 @@ void CfgExport::Output(const OString&) { } -/*****************************************************************************/ int CfgParser::Execute( int nToken, char * pToken ) -/*****************************************************************************/ { OString sToken( pToken ); @@ -346,12 +333,10 @@ void CfgParser::Error(const OString& rError) // class CfgExport // -/*****************************************************************************/ CfgExport::CfgExport( const OString &rOutputFile, - const OString &rFilePath -) -/*****************************************************************************/ + const OString &rFilePath ) + : sPath( rFilePath ) { pOutputStream.open( rOutputFile, PoOfstream::APP ); @@ -362,16 +347,13 @@ CfgExport::CfgExport( } } -/*****************************************************************************/ CfgExport::~CfgExport() -/*****************************************************************************/ { pOutputStream.close(); } -/*****************************************************************************/ + void CfgExport::WorkOnResourceEnd() -/*****************************************************************************/ { if ( bLocalize ) { if ( pStackData->sText[OString(RTL_CONSTASCII_STRINGPARAM("en-US"))].getLength() ) @@ -441,9 +423,7 @@ CfgMerge::CfgMerge( aLanguages.push_back(rLanguage); } -/*****************************************************************************/ CfgMerge::~CfgMerge() -/*****************************************************************************/ { pOutputStream.close(); delete pMergeDataFile; @@ -480,9 +460,7 @@ void CfgMerge::Output(const OString& rOutput) pOutputStream << rOutput.getStr(); } -/*****************************************************************************/ void CfgMerge::WorkOnResourceEnd() -/*****************************************************************************/ { if ( pMergeDataFile && pResData && bLocalize && bEnglish ) { diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index a27be62a1b94..f817e21974ea 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -100,9 +100,8 @@ int WorkOnTokenSet( int nTyp, char *pTokenText ) } // extern extern "C" { -/*****************************************************************************/ + int SetError() -/*****************************************************************************/ { // set error at global instance of class Export global::exporter->SetError(); @@ -111,9 +110,8 @@ int SetError() } extern "C" { -/*****************************************************************************/ + int GetError() -/*****************************************************************************/ { // get error at global instance of class Export if (global::exporter->GetError()) @@ -126,9 +124,7 @@ int GetError() // class ResData // -/*****************************************************************************/ sal_Bool ResData::SetId( const OString& rId, sal_uInt16 nLevel ) -/*****************************************************************************/ { if ( nLevel > nIdLevel ) { @@ -224,9 +220,7 @@ Export::Export( aOutput.mSimple->open(rOutput.getStr(), std::ios_base::out | std::ios_base::trunc); } -/*****************************************************************************/ void Export::Init() -/*****************************************************************************/ { // resets the internal status, used before parseing another file bDefine = sal_False; @@ -240,9 +234,7 @@ void Export::Init() aResStack.clear(); } -/*****************************************************************************/ Export::~Export() -/*****************************************************************************/ { if( pParseQueue ) delete pParseQueue; @@ -268,9 +260,7 @@ Export::~Export() } } -/*****************************************************************************/ int Export::Execute( int nToken, const char * pToken ) -/*****************************************************************************/ { OString sToken( pToken ); @@ -291,7 +281,7 @@ int Export::Execute( int nToken, const char * pToken ) (!(( bNextMustBeDefineEOL ) && ( sOrig == "\n" )))) { // this tokens are not mandatory for parsing, so ignore them ... if ( bMergeMode ) - WriteToMerged( sOrig , false ); // ... ore whrite them directly to dest. + WriteToMerged( sOrig , false ); // ... or write them directly to dest. return 0; } @@ -588,7 +578,6 @@ int Export::Execute( int nToken, const char * pToken ) nListIndex = 0; nListLevel = 0; } - // PairedList else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("PAIREDLIST"))) { pResData->bList = sal_True; @@ -794,9 +783,7 @@ int Export::Execute( int nToken, const char * pToken ) return 1; } -/*****************************************************************************/ void Export::CutComment( OString &rText ) -/*****************************************************************************/ { if (rText.indexOf("//") != -1) { OString sWork(rText.replaceAll("\\\"", "XX")); @@ -812,9 +799,7 @@ void Export::CutComment( OString &rText ) } } -/*****************************************************************************/ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew ) -/*****************************************************************************/ { if ( bMergeMode ) { MergeRest( pResData ); @@ -1079,9 +1064,7 @@ void Export::InsertListEntry(const OString &rText, const OString &rLine) nListIndex++; } -/*****************************************************************************/ void Export::CleanValue( OString &rValue ) -/*****************************************************************************/ { while ( !rValue.isEmpty()) { if (( rValue[0] == ' ' ) || ( rValue[0] == '\t' )) @@ -1212,16 +1195,14 @@ void Export::WriteToMerged(const OString &rText , bool bSDFContent) } } -/*****************************************************************************/ void Export::ConvertMergeContent( OString &rText ) -/*****************************************************************************/ { sal_Bool bNoOpen = ( rText.indexOf( "\\\"" ) != 0 ); sal_Bool bNoClose = !rText.endsWith("\\\""); - rText = rText.replaceAll("\\\"'","\'"); /// Temporary: until PO files contain escaped single quotes - /// (Maybe next PO update solve this) + rText = rText.replaceAll("\\\"'","\'"); // Temporary: until PO files contain escaped single quotes + // (Maybe next PO update solve this) rText = helper::escapeAll( rText.replaceAll("","\\0x7F"), @@ -1248,7 +1229,7 @@ bool Export::GetAllMergeEntrysOfList(ResData *pResData, std::vectorsGId = pResData->sGId + OString('.'); pResData->sGId = pResData->sGId + pResData->sId; - ///Find out the type of List + // Find out the type of List MergeEntrys* pEntrysOfFirstItem = 0; sal_uInt16 nType = LIST_STRING; bool bPairedList = false; @@ -1298,12 +1279,12 @@ bool Export::GetAllMergeEntrysOfList(ResData *pResData, std::vectorsId = OString::number(nMaxIndex+1); pEntrys = pMergeDataFile->GetMergeEntrys( pResData ); if ( pEntrys ) return false; - ///MergeData contains shorter list + // MergeData contains shorter list pResData->sId = OString::number(nMaxIndex); pEntrys = pMergeDataFile->GetMergeEntrys( pResData ); if ( !pEntrys ) @@ -1388,9 +1369,7 @@ void Export::ResData2Output( MergeEntrys *pEntry, sal_uInt16 nType, const OStrin } } -/*****************************************************************************/ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode ) -/*****************************************************************************/ { if ( !pMergeDataFile ){ pMergeDataFile = new MergeDataFile( sMergeSrc, global::inputPathname, false ); @@ -1552,9 +1531,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode ) pParseQueue->bMflag = false; } -/*****************************************************************************/ void Export::SetChildWithText() -/*****************************************************************************/ { if ( aResStack.size() > 1 ) { for ( size_t i = 0; i < aResStack.size() - 1; i++ ) { diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx index ce2864a8a7eb..f9dd4da5d2be 100644 --- a/l10ntools/source/merge.cxx +++ b/l10ntools/source/merge.cxx @@ -196,12 +196,12 @@ std::pair MergeDataHashMap::insert(const OStrin std::pair aTemp = m_aHashMap.insert(HashMap_t::value_type( rKey, pMergeData )); if( m_aHashMap.size() == 1 ) { - ///When first insert, set an iterator to the first element + // When first insert, set an iterator to the first element aFirstInOrder = aTemp.first; } else { - ///Define insertion order by setting an iterator to the next element. + // Define insertion order by setting an iterator to the next element. aLastInsertion->second->m_aNextData = aTemp.first; } aLastInsertion = aTemp.first; @@ -212,14 +212,14 @@ MergeDataHashMap::iterator MergeDataHashMap::find(const OString& rKey) { iterator aHint = m_aHashMap.end(); - ///Add a hint + // Add a hint if( bFirstSearch && !m_aHashMap.empty() ) { aHint = aFirstInOrder; } else if( aLastFound == aLastInsertion ) { - /// Next to the last element is the first element + // Next to the last element is the first element aHint = aFirstInOrder; } else if( aLastFound != m_aHashMap.end() && aLastFound != aLastInsertion ) @@ -227,7 +227,7 @@ MergeDataHashMap::iterator MergeDataHashMap::find(const OString& rKey) aHint = aLastFound->second->m_aNextData; } - ///If hint works than no need for search + // If hint works than no need for search if( aHint != m_aHashMap.end() && aHint->first == rKey ) { aLastFound = aHint; diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx index 030950a2fe42..7b4a94c0e8b3 100755 --- a/l10ntools/source/po.cxx +++ b/l10ntools/source/po.cxx @@ -42,7 +42,7 @@ public: GenPoEntry(); virtual ~GenPoEntry(); - //Default copy constructor and copy operator work well + // Default copy constructor and copy operator work well virtual OString getExtractCom() const { return m_sExtractCom; } virtual OString getReference() const { return m_sReference; } @@ -83,7 +83,7 @@ public: namespace { - //Convert a normal string to msg/po output string + // Convert a normal string to msg/po output string static OString lcl_GenMsgString(const OString& rString) { if ( rString.isEmpty() ) @@ -110,7 +110,7 @@ namespace return sResult; } - //Convert msg string to normal form + // Convert msg string to normal form static OString lcl_GenNormString(const OString& rString) { return @@ -121,7 +121,6 @@ namespace } } -//Default constructor GenPoEntry::GenPoEntry() : m_sExtractCom( OString() ) , m_sReference( OString() ) @@ -133,12 +132,10 @@ GenPoEntry::GenPoEntry() { } -//Destructor GenPoEntry::~GenPoEntry() { } -//Write to file void GenPoEntry::writeToFile(std::ofstream& rOFStream) const { if ( rOFStream.tellp() != std::ofstream::pos_type( 0 )) @@ -161,7 +158,6 @@ void GenPoEntry::writeToFile(std::ofstream& rOFStream) const << lcl_GenMsgString(m_sMsgStr).getStr() << std::endl; } -//Read from file void GenPoEntry::readFromFile(std::ifstream& rIFStream) { *this = GenPoEntry(); @@ -220,9 +216,10 @@ void GenPoEntry::readFromFile(std::ifstream& rIFStream) } } -//Class PoEntry +// +// Class PoEntry +// -//Default constructor PoEntry::PoEntry() : m_pGenPo( 0 ) , m_bIsInitialized( false ) @@ -261,8 +258,7 @@ PoEntry::PoEntry( sMsgCtxt += ".quickhelptext"; break; case TTITLE: sMsgCtxt += ".title"; break; - /*Default case is unneeded because the type of eType has - only three element*/ + // Default case is unneeded because the type of eType has only three element } m_pGenPo->setMsgCtxt(sMsgCtxt); m_pGenPo->setMsgId(rText); @@ -272,20 +268,17 @@ PoEntry::PoEntry( m_bIsInitialized = true; } -//Destructor PoEntry::~PoEntry() { delete m_pGenPo; } -//Copy constructor PoEntry::PoEntry( const PoEntry& rPo ) : m_pGenPo( rPo.m_pGenPo ? new GenPoEntry( *(rPo.m_pGenPo) ) : 0 ) , m_bIsInitialized( rPo.m_bIsInitialized ) { } -//Copy operator PoEntry& PoEntry::operator=(const PoEntry& rPo) { if( this == &rPo ) @@ -312,21 +305,18 @@ PoEntry& PoEntry::operator=(const PoEntry& rPo) return *this; } -//Get name of file from which entry is extracted OString PoEntry::getSourceFile() const { assert( m_bIsInitialized ); return m_pGenPo->getReference(); } -//Get groupid OString PoEntry::getGroupId() const { assert( m_bIsInitialized ); return m_pGenPo->getMsgCtxt().getToken(0,'\n'); } -//Get localid OString PoEntry::getLocalId() const { assert( m_bIsInitialized ); @@ -337,7 +327,6 @@ OString PoEntry::getLocalId() const return sMsgCtxt.getToken(1,'\n'); } -//Get the type of component from which entry is extracted OString PoEntry::getResourceType() const { assert( m_bIsInitialized ); @@ -348,7 +337,6 @@ OString PoEntry::getResourceType() const return sMsgCtxt.getToken(2,'\n').getToken(0,'.'); } -//Get the type of entry PoEntry::TYPE PoEntry::getType() const { assert( m_bIsInitialized ); @@ -364,37 +352,20 @@ PoEntry::TYPE PoEntry::getType() const return TTITLE; } -//Check wheather entry is fuzzy bool PoEntry::isFuzzy() const { assert( m_bIsInitialized ); return m_pGenPo->isFuzzy(); } -//Get keyid -OString PoEntry::getKeyId() const -{ - assert( m_bIsInitialized ); - const OString sExtractCom = m_pGenPo->getExtractCom(); - if( sExtractCom.indexOf("\n") == -1 ) - { - return sExtractCom; - } - else - { - return sExtractCom.getToken(1,'\n'); - } -} - - -//Get translation string in merge format +// Get translation string in merge format OString PoEntry::getMsgId() const { assert( m_bIsInitialized ); return m_pGenPo->getMsgId(); } -//Get translated string in merge format +// Get translated string in merge format OString PoEntry::getMsgStr() const { assert( m_bIsInitialized ); @@ -402,7 +373,6 @@ OString PoEntry::getMsgStr() const } -//Check whether po-s belong to the same localization component bool PoEntry::IsInSameComp(const PoEntry& rPo1,const PoEntry& rPo2) { assert( rPo1.m_bIsInitialized && rPo2.m_bIsInitialized ); @@ -417,7 +387,7 @@ OString PoEntry::genKeyId(const OString& rGenerator) boost::crc_32_type aCRC32; aCRC32.process_bytes(rGenerator.getStr(), rGenerator.getLength()); sal_uInt32 nCRC = aCRC32.checksum(); - ///Use simple ASCII characters, exclude I, l, 1 and O, 0 to avoid confusing IDs + // Use simple ASCII characters, exclude I, l, 1 and O, 0 to avoid confusing IDs static const OString sSymbols = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789"; char sKeyId[6]; @@ -430,12 +400,13 @@ OString PoEntry::genKeyId(const OString& rGenerator) return OString(sKeyId); } - -//Class PoHeader +// +// Class PoHeader +// namespace { - //Get actual time in "YEAR-MO-DA HO:MI+ZONE" form + // Get actual time in "YEAR-MO-DA HO:MI+ZONE" form static OString lcl_GetTime() { time_t aNow = time(NULL); @@ -446,7 +417,6 @@ namespace } } -//Template Constructor PoHeader::PoHeader( const OString& rExtSrc ) : m_pGenPo( new GenPoEntry() ) , m_bIsInitialized( false ) @@ -473,7 +443,9 @@ PoHeader::~PoHeader() delete m_pGenPo; } -//Class PoOfstream +// +// Class PoOfstream +// PoOfstream::PoOfstream() : m_aOutPut() @@ -532,11 +504,14 @@ void PoOfstream::writeEntry( const PoEntry& rPoEntry ) rPoEntry.m_pGenPo->writeToFile( m_aOutPut ); } -//Class PoIfstream +// +// Class PoIfstream +// namespace { +// Check the validity of read entry static bool lcl_CheckInputEntry(const GenPoEntry& rEntry) { const OString sMsgCtxt = rEntry.getMsgCtxt(); @@ -580,7 +555,7 @@ void PoIfstream::open( const OString& rFileName ) assert( !isOpen() ); m_aInPut.open( rFileName.getStr(), std::ios_base::in ); - //Skip header + // Skip header std::string sTemp; std::getline(m_aInPut,sTemp); while( !sTemp.empty() && !m_aInPut.eof() ) diff --git a/l10ntools/source/treemerge.cxx b/l10ntools/source/treemerge.cxx index 2870a2e7b5b9..8f65ece5a061 100644 --- a/l10ntools/source/treemerge.cxx +++ b/l10ntools/source/treemerge.cxx @@ -26,7 +26,7 @@ namespace { - //Extract strings from nodes on all level recursively + // Extract strings from nodes on all level recursively static void lcl_ExtractLevel( const xmlDocPtr pSource, const xmlNodePtr pRoot, const xmlChar* pNodeName, PoOfstream& rPOStream ) @@ -58,7 +58,7 @@ namespace } } - //Update id and content of the topic + // Update id and content of the topic static xmlNodePtr lcl_UpdateTopic( const xmlNodePtr pCurrent, const OString& rXhpRoot ) { @@ -69,7 +69,7 @@ namespace xmlFree( pID ); const sal_Int32 nFirstSlash = sID.indexOf("/"); - //Update id attribute of topic + // Update id attribute of topic { OString sNewID = sID.copy( 0, nFirstSlash + 1 ) + @@ -84,7 +84,7 @@ namespace rXhpRoot + sID.copy(sID.indexOf("/", nFirstSlash + 1)); xmlDocPtr pXhpFile = xmlParseFile( sXhpPath.getStr() ); - //if xhpfile is missing than we put this topic into comment + // if xhpfile is missing than put this topic into comment if ( !pXhpFile ) { xmlNodePtr pTemp = pReturn; @@ -98,7 +98,7 @@ namespace xmlFree( sNewID ); xmlFree( sComment ); } - //update topic's content on the basis of xhpfile's title + // update topic's content on the basis of xhpfile's title else { xmlNodePtr pXhpNode = xmlDocGetRootElement( pXhpFile ); @@ -138,7 +138,7 @@ namespace } return pReturn; } - //Localize title attribute of help_section and node tags + // Localize title attribute of help_section and node tags static void lcl_MergeLevel( xmlDocPtr io_pSource, const xmlNodePtr pRoot, const xmlChar * pNodeName, MergeDataFile* pMergeDataFile, @@ -198,7 +198,6 @@ namespace } } -//Parse tree file TreeParser::TreeParser( const OString& rInputFile, const OString& rLang ) : m_pSource( 0 ) @@ -224,7 +223,6 @@ TreeParser::~TreeParser() { } -//Extract strings form source file void TreeParser::Extract( const OString& rPOFile ) { assert( m_bIsInitialized ); @@ -248,7 +246,6 @@ void TreeParser::Extract( const OString& rPOFile ) m_bIsInitialized = false; } -//Merge strings to tree file and update reference to help files(xhp) void TreeParser::Merge( const OString &rMergeSrc, const OString &rDestinationFile, const OString &rXhpRoot ) diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index 46bcd2e6da41..1d8945e2950d 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -53,9 +53,7 @@ XRMResParser *pParser = NULL; extern "C" { // the whole interface to lexer is in this extern "C" section -/*****************************************************************************/ extern char *GetOutputFile( int argc, char* argv[]) -/*****************************************************************************/ { bDisplayName = sal_False; bExtensionDescription = sal_False; @@ -63,7 +61,6 @@ extern char *GetOutputFile( int argc, char* argv[]) common::HandledArgs aArgs; if ( common::handleArguments(argc, argv, aArgs) ) { - // command line is valid bMergeMode = aArgs.m_bMergeMode; sLanguage = aArgs.m_sLanguage; sInputFileName = aArgs.m_sInputFile; @@ -81,9 +78,7 @@ extern char *GetOutputFile( int argc, char* argv[]) } } -/*****************************************************************************/ int InitXrmExport( char*, char* pFilename) -/*****************************************************************************/ { // instanciate Export OString sFilename( pFilename ); @@ -97,9 +92,7 @@ int InitXrmExport( char*, char* pFilename) return 1; } -/*****************************************************************************/ int EndXrmExport() -/*****************************************************************************/ { delete pParser; return 1; @@ -108,9 +101,8 @@ extern const char* getFilename() { return sInputFileName.getStr(); } -/*****************************************************************************/ + extern FILE *GetXrmFile() -/*****************************************************************************/ { // look for valid filename if (!sInputFileName.isEmpty()) { @@ -128,9 +120,7 @@ extern FILE *GetXrmFile() return NULL; } -/*****************************************************************************/ int WorkOnTokenSet( int nTyp, char *pTokenText ) -/*****************************************************************************/ { //printf("Typ = %d , text = '%s'\n",nTyp , pTokenText ); pParser->Execute( nTyp, pTokenText ); @@ -138,9 +128,7 @@ int WorkOnTokenSet( int nTyp, char *pTokenText ) return 1; } -/*****************************************************************************/ int SetError() -/*****************************************************************************/ { pParser->SetError(); return 1; @@ -148,9 +136,8 @@ int SetError() } extern "C" { -/*****************************************************************************/ + int GetError() -/*****************************************************************************/ { return pParser->GetError(); } @@ -161,23 +148,17 @@ int GetError() // -/*****************************************************************************/ XRMResParser::XRMResParser() -/*****************************************************************************/ - : bError( sal_False ), - bText( sal_False ) + : bError( sal_False ), + bText( sal_False ) { } -/*****************************************************************************/ XRMResParser::~XRMResParser() -/*****************************************************************************/ { } -/*****************************************************************************/ int XRMResParser::Execute( int nToken, char * pToken ) -/*****************************************************************************/ { OString rToken( pToken ); @@ -284,9 +265,7 @@ int XRMResParser::Execute( int nToken, char * pToken ) return 0; } -/*****************************************************************************/ OString XRMResParser::GetAttribute( const OString &rToken, const OString &rAttribute ) -/*****************************************************************************/ { OString sTmp( rToken ); sTmp = sTmp.replace('\t', ' '); @@ -306,9 +285,7 @@ OString XRMResParser::GetAttribute( const OString &rToken, const OString &rAttri } -/*****************************************************************************/ void XRMResParser::Error( const OString &rError ) -/*****************************************************************************/ { yyerror(( char * ) rError.getStr()); } @@ -317,10 +294,8 @@ void XRMResParser::Error( const OString &rError ) // class XMLResExport // -/*****************************************************************************/ XRMResExport::XRMResExport( const OString &rOutputFile, const OString &rFilePath ) -/*****************************************************************************/ : XRMResParser(), pResData( NULL ), sPath( rFilePath ) @@ -334,9 +309,7 @@ XRMResExport::XRMResExport( } } -/*****************************************************************************/ XRMResExport::~XRMResExport() -/*****************************************************************************/ { pOutputStream.close(); delete pResData; @@ -344,12 +317,9 @@ XRMResExport::~XRMResExport() void XRMResExport::Output( const OString& ) {} -/*****************************************************************************/ void XRMResExport::WorkOnDesc( const OString &rOpenTag, - OString &rText -) -/*****************************************************************************/ + OString &rText ) { OString sDescFileName( sInputFileName.replaceAll("description.xml", OString())); @@ -369,12 +339,9 @@ void XRMResExport::WorkOnDesc( EndOfText( rOpenTag, rOpenTag ); } -//*****************************************************************************/ void XRMResExport::WorkOnText( const OString &rOpenTag, - OString &rText -) -/*****************************************************************************/ + OString &rText ) { OString sLang( GetAttribute( rOpenTag, sLangAttribute )); @@ -385,12 +352,9 @@ void XRMResExport::WorkOnText( pResData->sText[sLang] = rText; } -/*****************************************************************************/ void XRMResExport::EndOfText( const OString &, - const OString & -) -/*****************************************************************************/ + const OString & ) { if ( pResData ) { @@ -409,11 +373,9 @@ void XRMResExport::EndOfText( // class XRMResMerge // -/*****************************************************************************/ XRMResMerge::XRMResMerge( const OString &rMergeSource, const OString &rOutputFile, const OString &rFilename ) -/*****************************************************************************/ : XRMResParser(), pMergeDataFile( NULL ), sFilename( rFilename ) , @@ -437,21 +399,16 @@ XRMResMerge::XRMResMerge( } } -/*****************************************************************************/ XRMResMerge::~XRMResMerge() -/*****************************************************************************/ { pOutputStream.close(); delete pMergeDataFile; delete pResData; } -/*****************************************************************************/ void XRMResMerge::WorkOnDesc( const OString &rOpenTag, - OString &rText -) -/*****************************************************************************/ + OString &rText ) { WorkOnText( rOpenTag, rText); if ( pMergeDataFile && pResData ) { @@ -520,12 +477,9 @@ void XRMResMerge::WorkOnDesc( pResData = NULL; } -/*****************************************************************************/ void XRMResMerge::WorkOnText( const OString &rOpenTag, - OString & -) -/*****************************************************************************/ + OString & ) { OString sLang( GetAttribute( rOpenTag, sLangAttribute )); @@ -537,20 +491,15 @@ void XRMResMerge::WorkOnText( } } -/*****************************************************************************/ void XRMResMerge::Output( const OString& rOutput ) -/*****************************************************************************/ { if (!rOutput.isEmpty()) pOutputStream << rOutput.getStr(); } -/*****************************************************************************/ void XRMResMerge::EndOfText( const OString &rOpenTag, - const OString &rCloseTag -) -/*****************************************************************************/ + const OString &rCloseTag ) { Output( rCloseTag ); -- cgit v1.2.3