diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-03-15 15:42:05 +0100 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-03-16 12:27:32 +0100 |
commit | 15a13bafccb96e6ab0cc5a23af6dd46715fa22c5 (patch) | |
tree | 91b93ddc0f731aec2d5b19f1895545550872a119 /l10ntools/inc | |
parent | 516118b515fb577b1cc40e4b8d7dc06919b64675 (diff) |
Get rid of generating temporary sdf file
Working:
1. Localize add header to po files.
2. Executables append po entries to po files.
3. Localize delete entryless po files and empty directories
Plus a bunch of clean up.
Change-Id: I58e300eaee4cee948203cc9d3e642ca9462d0d26
Diffstat (limited to 'l10ntools/inc')
-rw-r--r-- | l10ntools/inc/cfgmerge.hxx | 23 | ||||
-rw-r--r-- | l10ntools/inc/export.hxx | 12 | ||||
-rw-r--r-- | l10ntools/inc/helpmerge.hxx | 10 | ||||
-rw-r--r-- | l10ntools/inc/lngmerge.hxx | 12 | ||||
-rwxr-xr-x | l10ntools/inc/po.hxx | 29 | ||||
-rw-r--r-- | l10ntools/inc/propmerge.hxx | 3 | ||||
-rw-r--r-- | l10ntools/inc/stringmerge.hxx | 3 | ||||
-rw-r--r-- | l10ntools/inc/treemerge.hxx | 3 | ||||
-rw-r--r-- | l10ntools/inc/xrmmerge.hxx | 28 |
9 files changed, 52 insertions, 71 deletions
diff --git a/l10ntools/inc/cfgmerge.hxx b/l10ntools/inc/cfgmerge.hxx index 316c9dee2181..05987281cc71 100644 --- a/l10ntools/inc/cfgmerge.hxx +++ b/l10ntools/inc/cfgmerge.hxx @@ -26,6 +26,7 @@ #include <vector> #include "boost/unordered_map.hpp" +#include "po.hxx" typedef boost::unordered_map<rtl::OString, rtl::OString, rtl::OStringHash> OStringHashMap; @@ -137,28 +138,18 @@ public: }; // -// class CfgOutputParser -// - -class CfgOutputParser : public CfgParser -{ -protected: - std::ofstream pOutputStream; -public: - CfgOutputParser(const rtl::OString &rOutputFile); - virtual ~CfgOutputParser(); -}; - -// // class CfgExport // -class CfgExport : public CfgOutputParser +class CfgExport : public CfgParser { private: rtl::OString sPrj; rtl::OString sPath; std::vector<rtl::OString> aLanguages; + + PoOfstream pOutputStream; + protected: virtual void WorkOnText( rtl::OString &rText, @@ -180,7 +171,7 @@ public: // class CfgMerge // -class CfgMerge : public CfgOutputParser +class CfgMerge : public CfgParser { private: MergeDataFile *pMergeDataFile; @@ -190,6 +181,8 @@ private: rtl::OString sFilename; sal_Bool bEnglish; + std::ofstream pOutputStream; + protected: virtual void WorkOnText(rtl::OString &rText, const rtl::OString &rLangIndex); diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx index 409e6169b904..050ded578b87 100644 --- a/l10ntools/inc/export.hxx +++ b/l10ntools/inc/export.hxx @@ -21,6 +21,7 @@ #define _EXPORT_HXX #include "sal/config.h" +#include "po.hxx" #include <cstddef> #include <fstream> @@ -274,7 +275,12 @@ class Export private: WordTransformer *pWordTransformer; - std::ofstream aOutput; + union + { + std::ofstream* mSimple; + PoOfstream* mPo; + + } aOutput; ResStack aResStack; // stack for parsing recursive @@ -307,6 +313,10 @@ public: static bool handleArguments(int argc, char * argv[], HandledArgs& o_aHandledArgs); static void writeUsage(const OString& rName, const OString& rFileType); + static void writePoEntry(const OString& rExecutable, PoOfstream& rPoStream, const OString& rSourceFile, + const OString& rResType, const OString& rGroupId, const OString& rLocalId, + const OString& rHelpText, const OString& rText, + const PoEntry::TYPE eType = PoEntry::TTEXT); static void InitLanguages( bool bMergeMode = false ); static void InitForcedLanguages( bool bMergeMode = false ); diff --git a/l10ntools/inc/helpmerge.hxx b/l10ntools/inc/helpmerge.hxx index 77f1dd8df7c9..d248d9c84460 100644 --- a/l10ntools/inc/helpmerge.hxx +++ b/l10ntools/inc/helpmerge.hxx @@ -42,14 +42,14 @@ public: HelpParser( const rtl::OString &rHelpFile ); ~HelpParser(){}; -/// Method creates/append a SDF file with the content of a parsed XML file +/// Method append a PO file with the content of a parsed XML file /// @PRECOND rHelpFile is valid - static bool CreateSDF( const rtl::OString &rSDFFile_in, const rtl::OString &rPrj_in, const rtl::OString &rRoot_in, - const rtl::OString &sHelpFile, XMLFile *pXmlFile, const rtl::OString &rGsi1 ); + static bool CreatePO( const rtl::OString &rPOFile_in, const rtl::OString &sHelpFile, + XMLFile *pXmlFile, const rtl::OString &rGsi1 ); -/// Method merges the String from the SDFfile into XMLfile. Both Strings must +/// Method merges the String from the POfile into XMLfile. Both Strings must /// point to existing files. - bool Merge( const rtl::OString &rSDFFile_in, const rtl::OString &rDestinationFile_in , + bool Merge( const rtl::OString &rPOFile_in, const rtl::OString &rDestinationFile_in , const rtl::OString& sLanguage , MergeDataFile& aMergeDataFile ); private: diff --git a/l10ntools/inc/lngmerge.hxx b/l10ntools/inc/lngmerge.hxx index 3995bd73c8c0..d18bce3bdd97 100644 --- a/l10ntools/inc/lngmerge.hxx +++ b/l10ntools/inc/lngmerge.hxx @@ -23,13 +23,12 @@ #include <vector> #include "export.hxx" +#include "po.hxx" typedef std::vector< rtl::OString* > LngLineList; #define LNG_OK 0x0000 #define LNG_COULD_NOT_OPEN 0x0001 -#define SDF_OK 0x0002 -#define SDF_COULD_NOT_OPEN 0x0003 // // class LngParser @@ -47,18 +46,15 @@ private: bool isNextGroup(rtl::OString &sGroup_out, const rtl::OString &sLine_in); void ReadLine(const rtl::OString &rLine_in, OStringHashMap &rText_inout); - void WriteSDF(std::ofstream &aSDFStream, OStringHashMap &rText_inout, - const rtl::OString &rPrj, const rtl::OString &rRoot, + void WritePO(PoOfstream &aPOStream, OStringHashMap &rText_inout, const rtl::OString &rActFileName, const rtl::OString &rID); public: LngParser(const rtl::OString &rLngFile, sal_Bool bULFFormat); ~LngParser(); - sal_Bool CreateSDF(const rtl::OString &rSDFFile, - const rtl::OString &rPrj, - const rtl::OString &rRoot); - sal_Bool Merge(const rtl::OString &rSDFFile, + sal_Bool CreatePO( const rtl::OString &rPOFile ); + sal_Bool Merge(const rtl::OString &rPOFile, const rtl::OString &rDestinationFile); }; diff --git a/l10ntools/inc/po.hxx b/l10ntools/inc/po.hxx index f2edb0684ee2..5ffad8e48554 100755 --- a/l10ntools/inc/po.hxx +++ b/l10ntools/inc/po.hxx @@ -40,15 +40,13 @@ public: friend class PoOfstream; friend class PoIfstream; - enum SDFPART { PROJECT, SOURCEFILE, DUMMY, RESOURCETYPE, GROUPID, - LOCALID, HELPID, PLATFORM, WIDTH, LANGUAGEID, - TEXT, HELPTEXT, QUICKHELPTEXT, TITLE, TIMESTAMP }; - enum TYPE { TTEXT=TEXT, TQUICKHELPTEXT=QUICKHELPTEXT, TTITLE=TITLE }; - enum Exception { INVALIDSDFLINE }; + enum TYPE { TTEXT, TQUICKHELPTEXT, TTITLE }; + enum Exception { NOSOURCFILE, NORESTYPE, NOGROUPID, NOSTRING, WRONGHELPTEXT }; PoEntry(); - PoEntry(const OString& rSDFLine, - const TYPE eType = TTEXT); + PoEntry( const OString& rSourceFile, const OString& rResType, const OString& rGroupId, + const OString& rLocalId, const OString& rHelpText, const OString& rText, + const TYPE eType = TTEXT ); ~PoEntry(); PoEntry( const PoEntry& rPo ); @@ -63,8 +61,8 @@ public: OString getMsgStr() const; bool isFuzzy() const; OString getKeyId() const; - void setMsgId(const OString& rUnTransStr); - void setMsgStr(const OString& rTransStr); + void setMsgId(const OString& rMsgId); + void setMsgStr(const OString& rMsgStr); void setFuzzy(const bool bFuzzy); static bool IsInSameComp(const PoEntry& rPo1,const PoEntry& rPo2); @@ -93,8 +91,7 @@ public: ~PoHeader(); }; -/** Interface to write po entry to files as output streams -*/ +/// Interface to write po entry to files as output streams class PoOfstream: private boost::noncopyable { private: @@ -103,18 +100,21 @@ private: bool m_bIsAfterHeader; public: + + enum OpenMode { TRUNC, APP }; + PoOfstream(); + PoOfstream(const OString& rFileName, OpenMode aMode = TRUNC ); ~PoOfstream(); bool isOpen() const { return m_aOutPut.is_open(); } - void open(const OString& rFileName); + void open(const OString& rFileName, OpenMode aMode = TRUNC ); void close(); void writeHeader(const PoHeader& rHeader); void writeEntry(const PoEntry& rPo); }; -/** Interface to read po entry from files as input streams -*/ +/// Interface to read po entry from files as input streams class PoIfstream: private boost::noncopyable { private: @@ -127,6 +127,7 @@ public: enum Exception { INVALIDENTRY }; PoIfstream(); + PoIfstream( const OString& rFileName ); ~PoIfstream(); bool isOpen() const { return m_aInPut.is_open(); } bool eof() const { return m_bEof; } diff --git a/l10ntools/inc/propmerge.hxx b/l10ntools/inc/propmerge.hxx index a44649cfb91b..b6e2a0b3b85f 100644 --- a/l10ntools/inc/propmerge.hxx +++ b/l10ntools/inc/propmerge.hxx @@ -33,8 +33,7 @@ public: ~PropParser(); bool isInitialized() const { return m_bIsInitialized; } - void Extract( - const OString& rSDFFile, const OString& rPrj, const OString& rRoot ); + void Extract( const OString& rPOFile ); void Merge( const OString &rMergeSrc, const OString &rDestinationFile ); }; diff --git a/l10ntools/inc/stringmerge.hxx b/l10ntools/inc/stringmerge.hxx index 01a7b9b719cd..be18904be48f 100644 --- a/l10ntools/inc/stringmerge.hxx +++ b/l10ntools/inc/stringmerge.hxx @@ -32,8 +32,7 @@ public: ~StringParser(); bool isInitialized() const { return m_bIsInitialized; } - void Extract( - const OString& rSDFFile, const OString& rPrj, const OString& rRoot ); + void Extract( const OString& rPOFile ); void Merge( const OString &rMergeSrc, const OString &rDestinationFile ); }; diff --git a/l10ntools/inc/treemerge.hxx b/l10ntools/inc/treemerge.hxx index 98f5a0218c1a..d3d15af0b3dc 100644 --- a/l10ntools/inc/treemerge.hxx +++ b/l10ntools/inc/treemerge.hxx @@ -33,8 +33,7 @@ public: ~TreeParser(); bool isInitialized() const { return m_bIsInitialized; } - void Extract( - const OString& rSDFFile, const OString& rPrj, const OString& rRoot ); + void Extract( const OString& rPOFile ); void Merge( const OString &rMergeSrc, const OString &rDestinationFile, const OString &rXhpRoot ); diff --git a/l10ntools/inc/xrmmerge.hxx b/l10ntools/inc/xrmmerge.hxx index e9839cee2288..c5671eb4255c 100644 --- a/l10ntools/inc/xrmmerge.hxx +++ b/l10ntools/inc/xrmmerge.hxx @@ -20,6 +20,7 @@ #include "sal/config.h" #include <fstream> +#include "po.hxx" // // XRMResParser @@ -37,9 +38,8 @@ private: rtl::OString sCurrentOpenTag; rtl::OString sCurrentCloseTag; rtl::OString sCurrentText; - std::vector<rtl::OString> aLanguages; - protected: + std::vector<rtl::OString> aLanguages; rtl::OString GetAttribute( const rtl::OString &rToken, const rtl::OString &rAttribute ); void Error( const rtl::OString &rError ); @@ -74,32 +74,16 @@ public: }; // -// class XRMResOutputParser -// - -class XRMResOutputParser : public XRMResParser -{ -private: - std::vector<rtl::OString> aLanguages; -protected: - std::ofstream pOutputStream; -public: - XRMResOutputParser ( const rtl::OString &rOutputFile ); - virtual ~XRMResOutputParser(); -}; - -// // XRMResExport // -class XRMResExport : public XRMResOutputParser +class XRMResExport : public XRMResParser { private: ResData *pResData; rtl::OString sPrj; rtl::OString sPath; - std::vector<rtl::OString> aLanguages; - + PoOfstream pOutputStream; protected: void WorkOnDesc( const rtl::OString &rOpenTag, @@ -128,13 +112,13 @@ public: // class XRMResMerge // -class XRMResMerge : public XRMResOutputParser +class XRMResMerge : public XRMResParser { private: MergeDataFile *pMergeDataFile; rtl::OString sFilename; ResData *pResData; - std::vector<rtl::OString> aLanguages; + std::ofstream pOutputStream; protected: void WorkOnDesc( |