diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-03-27 20:08:50 +0100 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-03-27 20:09:31 +0100 |
commit | 8e26b4783f1f47ff5d489e7df5869240eefd1071 (patch) | |
tree | 80c4c9899fb3b05fcadc845444b06e1e3221e1c2 /l10ntools/inc | |
parent | 239fb4cb41cb0d1ed42bf5cf8ecdabdca4a28a68 (diff) |
Refactor l10ntools
Delete unused functions.
Make Export class more encapsulated.
Move to local that functions which are used only in one file.
Common contans method which are used by all executables.
Helper contains methods belong to xml parsing.
Change-Id: I28773a2c7eea90da7df7f32720fd38de2cb661ac
Diffstat (limited to 'l10ntools/inc')
-rw-r--r-- | l10ntools/inc/common.hxx | 53 | ||||
-rw-r--r-- | l10ntools/inc/export.hxx | 122 | ||||
-rw-r--r-- | l10ntools/inc/helper.hxx | 39 | ||||
-rw-r--r-- | l10ntools/inc/helpmerge.hxx | 1 | ||||
-rw-r--r-- | l10ntools/inc/lngmerge.hxx | 2 | ||||
-rw-r--r-- | l10ntools/inc/xrmmerge.hxx | 1 |
6 files changed, 103 insertions, 115 deletions
diff --git a/l10ntools/inc/common.hxx b/l10ntools/inc/common.hxx new file mode 100644 index 000000000000..93f2d008cb82 --- /dev/null +++ b/l10ntools/inc/common.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/// Methods used by all of executables + +#ifndef INCLUDED_L10NTOOLS_SOURCE_COMMON_HXX +#define INCLUDED_L10NTOOLS_SOURCE_COMMON_HXX + +#include "sal/config.h" + +#include <iostream> +#include <rtl/string.hxx> +#include "po.hxx" + +namespace common { + +//result type of handleArguments() +struct HandledArgs +{ + OString m_sInputFile; + OString m_sOutputFile; + OString m_sMergeSrc; + OString m_sLanguage; + bool m_bMergeMode; + HandledArgs() + : m_sInputFile( OString() ) + , m_sOutputFile( OString() ) + , m_sMergeSrc( OString() ) + , m_sLanguage( OString() ) + , m_bMergeMode( false ) + {} +}; + +bool handleArguments(int argc, char * argv[], HandledArgs& o_aHandledArgs); + +void writeUsage(const OString& rName, const OString& rFileType); + +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 ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx index fbe7adac497c..e3a0913515e6 100644 --- a/l10ntools/inc/export.hxx +++ b/l10ntools/inc/export.hxx @@ -109,6 +109,8 @@ public: class ResData { public: + ResData(const rtl::OString &rPF, const rtl::OString &rGId); + ResData(const rtl::OString &rPF, const rtl::OString &rGId , const rtl::OString &rFilename); ~ResData(); sal_Bool SetId(const rtl::OString &rId, sal_uInt16 nLevel); @@ -153,67 +155,6 @@ public: ExportList *pPairedList; rtl::OString sPForm; - - ResData(const rtl::OString &rPF, const rtl::OString &rGId) - : - nWidth( 0 ), - nChildIndex( 0 ), - nIdLevel( ID_LEVEL_NULL ), - bChild( sal_False ), - bChildWithText( sal_False ), - bText( sal_False ), - bHelpText( sal_False ), - bQuickHelpText( sal_False ), - bTitle( sal_False ), - bList( sal_False ), - bRestMerged( sal_False ), - sGId( rGId ), - nTextRefId( REFID_NONE ), - nHelpTextRefId( REFID_NONE ), - nQuickHelpTextRefId( REFID_NONE ), - nTitleRefId( REFID_NONE ), - sTextTyp( "Text" ), - pStringList( NULL ), - pUIEntries( NULL ), - pItemList( NULL ), - pFilterList( NULL ), - pPairedList( NULL ), - sPForm( rPF ) - { - sGId = sGId.replaceAll("\r", rtl::OString()); - sPForm = sPForm.replaceAll("\r", rtl::OString()); - } - - ResData(const rtl::OString &rPF, const rtl::OString &rGId , const rtl::OString &rFilename) - : - nWidth( 0 ), - nChildIndex( 0 ), - nIdLevel( ID_LEVEL_NULL ), - bChild( sal_False ), - bChildWithText( sal_False ), - bText( sal_False ), - bHelpText( sal_False ), - bQuickHelpText( sal_False ), - bTitle( sal_False ), - bList( sal_False ), - bRestMerged( sal_False ), - sGId( rGId ), - sFilename( rFilename ), - nTextRefId( REFID_NONE ), - nHelpTextRefId( REFID_NONE ), - nQuickHelpTextRefId( REFID_NONE ), - nTitleRefId( REFID_NONE ), - sTextTyp( "Text" ), - pStringList( NULL ), - pUIEntries( NULL ), - pItemList( NULL ), - pFilterList( NULL ), - pPairedList( NULL ), - sPForm( rPF ) - { - sGId = sGId.replaceAll("\r", rtl::OString()); - sPForm = sPForm.replaceAll("\r", rtl::OString()); - } }; @@ -244,23 +185,6 @@ typedef ::std::vector< ResData* > ResStack; class WordTransformer; class ParserQueue; -//result type of handleArguments() -struct HandledArgs -{ - OString m_sInputFile; - OString m_sOutputFile; - OString m_sMergeSrc; - OString m_sLanguage; - bool m_bMergeMode; - HandledArgs() - : m_sInputFile( OString() ) - , m_sOutputFile( OString() ) - , m_sMergeSrc( OString() ) - , m_sLanguage( OString() ) - , m_bMergeMode( false ) - {} -}; - class Export { private: @@ -292,40 +216,11 @@ private: sal_Bool bReadOver; sal_Bool bDontWriteOutput; rtl::OString sLastTextTyp; - static bool isInitialized; + bool isInitialized; rtl::OString sFilename; + rtl::OString sLanguages; - -public: - ParserQueue* pParseQueue; // public ? - static rtl::OString sLanguages; // 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 ); - static std::vector<rtl::OString> GetLanguages(); - - static void SetLanguages( std::vector<rtl::OString> val ); - static void RemoveUTF8ByteOrderMarker( rtl::OString &rString ); - static bool hasUTF8ByteOrderMarker( const rtl::OString &rString ); - static rtl::OString QuoteHTML( rtl::OString const &rString ); - - static rtl::OString UnquoteHTML( rtl::OString const &rString ); - - static bool isSourceLanguage(const rtl::OString &rLanguage); - static bool isAllowed(const rtl::OString &rLanguage); - - static void Languages( std::vector<rtl::OString>::const_iterator& begin , std::vector<rtl::OString>::const_iterator& end ); - -private: - static std::vector<rtl::OString> aLanguages; - static std::vector<rtl::OString> aForcedLanguages; + std::vector<rtl::OString> aLanguages; sal_Bool WriteData( ResData *pResData, sal_Bool bCreateNew = sal_False );// called befor dest. cur ResData sal_Bool WriteExportList( ResData *pResData, ExportList *pExportList, @@ -352,17 +247,20 @@ private: void WriteToMerged(const rtl::OString &rText , bool bSDFContent); void SetChildWithText(); + void InitLanguages( bool bMergeMode = false ); + void CutComment( rtl::OString &rText ); public: - Export(const rtl::OString &rOutput); - Export(const rtl::OString &rMergeSource, const rtl::OString &rOutput); + Export(const OString &rOutput, const OString &rLanguage); + Export(const OString &rMergeSource, const OString &rOutput, const OString &rLanguage); ~Export(); void Init(); int Execute( int nToken, const char * pToken ); // called from lexer void SetError() { bError = sal_True; } sal_Bool GetError() { return bError; } + ParserQueue* pParseQueue; // public!! }; diff --git a/l10ntools/inc/helper.hxx b/l10ntools/inc/helper.hxx new file mode 100644 index 000000000000..4dd2dd137937 --- /dev/null +++ b/l10ntools/inc/helper.hxx @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/// Helper methods to work with xml files + +#ifndef INCLUDED_L10NTOOLS_SOURCE_HELPER_HXX +#define INCLUDED_L10NTOOLS_SOURCE_HELPER_HXX + +#include "sal/config.h" +#include "sal/types.h" + +#include <cassert> + +#include <libxml/parser.h> + +#include <rtl/string.hxx> +#include <rtl/strbuf.hxx> + + +namespace helper { + +OString QuotHTML(const rtl::OString &rString); + +bool isWellFormedXML( OString const & text ); + +//Convert xmlChar* to OString +OString xmlStrToOString( const xmlChar* pString ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/inc/helpmerge.hxx b/l10ntools/inc/helpmerge.hxx index fd11609a9a59..1f11726182f6 100644 --- a/l10ntools/inc/helpmerge.hxx +++ b/l10ntools/inc/helpmerge.hxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "export.hxx" #include "xmlparse.hxx" #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> diff --git a/l10ntools/inc/lngmerge.hxx b/l10ntools/inc/lngmerge.hxx index 4631bb3536f8..8c5940cbdfee 100644 --- a/l10ntools/inc/lngmerge.hxx +++ b/l10ntools/inc/lngmerge.hxx @@ -22,8 +22,8 @@ #include <iosfwd> #include <vector> +#include "common.hxx" #include "export.hxx" -#include "po.hxx" typedef std::vector< rtl::OString* > LngLineList; diff --git a/l10ntools/inc/xrmmerge.hxx b/l10ntools/inc/xrmmerge.hxx index 83736263796c..8659fe1f4f19 100644 --- a/l10ntools/inc/xrmmerge.hxx +++ b/l10ntools/inc/xrmmerge.hxx @@ -20,7 +20,6 @@ #include "sal/config.h" #include <fstream> -#include "po.hxx" // // XRMResParser |