diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2012-09-02 21:10:35 +0200 |
---|---|---|
committer | Andras Timar <atimar@suse.com> | 2012-09-03 10:48:07 +0000 |
commit | 42a2fb1c24750dde53b737d1fb45e2bb7286a3f2 (patch) | |
tree | a97d5abd1512797fb5434f098e3ba280206bf26b | |
parent | dd83185b004e08fe0b291ede225d0e93be27c819 (diff) |
Make interface for PoEntry
Use composition insted of inheritance
Make all necessary method.
Make header file clear
Make header file clear
Plus cleanup.
Change-Id: Idfcc7a4a4f51b402ec86a9685e8ad9fdb23fea71
Reviewed-on: https://gerrit.libreoffice.org/530
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
-rw-r--r-- | l10ntools/inc/po.hxx | 61 | ||||
-rw-r--r-- | l10ntools/source/po.cxx | 120 | ||||
-rw-r--r-- | regexp/inc/regexp/reclass.hxx | 6 |
3 files changed, 119 insertions, 68 deletions
diff --git a/l10ntools/inc/po.hxx b/l10ntools/inc/po.hxx index df3004c1fe5e..b4b18c49d980 100644 --- a/l10ntools/inc/po.hxx +++ b/l10ntools/inc/po.hxx @@ -39,27 +39,20 @@ public: virtual OString getTransStr() const { return m_sTransStr; } virtual bool getFuzzy() const { return m_bFuzzy; } - virtual void setWhiteSpace(const OString& rWhiteSpace) - { m_sWhiteSpace = rWhiteSpace; } - virtual void setExtractCom(const OString& rExtractCom) - { m_sExtractCom = rExtractCom; } - virtual void setReference(const OString& rReference) - { m_sReference = rReference; } - virtual void setContext(const OString& rContext) - { m_sContext = rContext; } - virtual void setUnTransStr(const OString& rUnTransStr) - { m_sUnTransStr = rUnTransStr; } - virtual void setTransStr(const OString& rTransStr) - { m_sTransStr = rTransStr; } - virtual void setFuzzy(bool bFuzzy) - { m_bFuzzy = bFuzzy; } + virtual void setWhiteSpace(const OString& rWhiteSpace); + virtual void setExtractCom(const OString& rExtractCom); + virtual void setReference(const OString& rReference); + virtual void setContext(const OString& rContext); + virtual void setUnTransStr(const OString& rUnTransStr); + virtual void setTransStr(const OString& rTransStr); + virtual void setFuzzy(const bool bFuzzy); virtual void genKeyId(); virtual void writeToFile(std::ofstream& rOFStream); virtual void readFromFile(std::ifstream& rIFStream); }; -class PoEntry: public GenPoEntry +class PoEntry { public: enum SDFPARTS { PROJECT, SOURCEFILE, DUMMY, RESOURCETYPE, GROUPID, @@ -68,34 +61,43 @@ public: enum TYPE { TTEXT=TEXT, TQUICKHELPTEXT=QUICKHELPTEXT, TTITLE=TITLE }; private: + GenPoEntry m_aGenPo; OString m_sSourceFile; OString m_sGroupId; OString m_sLocalId; OString m_sResourceType; TYPE m_eType; OString m_sHelpText; - public: - PoEntry(); - PoEntry(const OString& i_rSDFLine, - const TYPE eType = TTEXT); - virtual ~PoEntry(); - - virtual OString getUnTransStr() const; - virtual OString getTransStr() const; - virtual void setUnTransStr(const OString& rUnTransStr); - virtual void setTransStr(const OString& rTransStr); - - virtual void writeToFile(std::ofstream& rOFStream); - virtual void readFromFile(std::ifstream& rIFStream); + PoEntry(); + PoEntry(const OString& i_rSDFLine, + const TYPE eType = TTEXT); + virtual ~PoEntry(); + + OString getSourceFile() const { return m_sSourceFile; } + OString getGroupId() const { return m_sGroupId; } + OString getLocalId() const { return m_sLocalId; } + OString getResourceType() const { return m_sResourceType; } + TYPE getType() const { return m_eType; } + OString getHelpText() const { return m_sHelpText; } + OString getUnTransStr() const; + OString getTransStr() const; + bool getFuzzy() const { return m_aGenPo.getFuzzy(); } + void setUnTransStr(const OString& rUnTransStr); + void setTransStr(const OString& rTransStr); + void setFuzzy(const bool bFuzzy); + + void writeToFile(std::ofstream& rOFStream); + void readFromFile(std::ifstream& rIFStream); }; -class PoHeader: public GenPoEntry +class PoHeader { private: + GenPoEntry m_aGenPo; OString m_sExtractionSource; OString m_sProjectIdVersion; OString m_sReportMsgidBugsTo; @@ -114,6 +116,7 @@ private: public: PoHeader( const OString& rExtSrc ); ~PoHeader(); + void writeToFile(std::ofstream& rOFStream); }; #endif // _PO_INCLUDED diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx index 59199c22c293..1a7c5aead7df 100644 --- a/l10ntools/source/po.cxx +++ b/l10ntools/source/po.cxx @@ -39,7 +39,7 @@ OString ImplGenKeyId(const OString& rGenerator) sKeyId[nIndex] = static_cast<char>((nCRC & 255) % 93 + 33); nCRC >>= 8; } - sKeyId[4] = 0; + sKeyId[4] = '\0'; return OString(sKeyId); } @@ -130,6 +130,42 @@ GenPoEntry::~GenPoEntry() { } +//Set class members +void GenPoEntry::setWhiteSpace(const OString& rWhiteSpace) +{ + m_sWhiteSpace = rWhiteSpace; +} + +void GenPoEntry::setExtractCom(const OString& rExtractCom) +{ + m_sExtractCom = rExtractCom; +} + +void GenPoEntry::setReference(const OString& rReference) +{ + m_sReference = rReference; +} + +void GenPoEntry::setContext(const OString& rContext) +{ + m_sContext = rContext; +} + +void GenPoEntry::setUnTransStr(const OString& rUnTransStr) +{ + m_sUnTransStr = rUnTransStr; +} + +void GenPoEntry::setTransStr(const OString& rTransStr) +{ + m_sTransStr = rTransStr; +} + +void GenPoEntry::setFuzzy(const bool bFuzzy) +{ + m_bFuzzy = bFuzzy; +} + //Set keyid void GenPoEntry::genKeyId() { @@ -337,7 +373,7 @@ OString ImplEscapeSDFText(const OString& rText,const bool bHelpText = false) //Default constructor PoEntry::PoEntry() - : GenPoEntry() + : m_aGenPo( GenPoEntry() ) , m_sSourceFile( OString() ) , m_sGroupId( OString() ) , m_sLocalId( OString() ) @@ -349,7 +385,8 @@ PoEntry::PoEntry() //Construct PoEntry from sdfline PoEntry::PoEntry(const OString& rSDFLine, const TYPE eType) - : m_sSourceFile( OString() ) + : m_aGenPo( GenPoEntry() ) + , m_sSourceFile( OString() ) , m_sGroupId( OString() ) , m_sLocalId( OString() ) , m_sResourceType(OString() ) @@ -378,14 +415,14 @@ PoEntry::~PoEntry() //Get translation string in sdf/merge format OString PoEntry::getUnTransStr() const { - return ImplEscapeSDFText(GenPoEntry::getUnTransStr(), + return ImplEscapeSDFText(m_aGenPo.getUnTransStr(), m_sSourceFile.endsWith(".xhp")); } //Get translated string in sdf/merge format OString PoEntry::getTransStr() const { - return ImplEscapeSDFText(GenPoEntry::getTransStr(), + return ImplEscapeSDFText(m_aGenPo.getTransStr(), m_sSourceFile.endsWith(".xhp")); } @@ -393,25 +430,31 @@ OString PoEntry::getTransStr() const //Set translation string when input is in sdf format void PoEntry::setUnTransStr(const OString& rUnTransStr) { - GenPoEntry::setUnTransStr( - ImplUnEscapeSDFText( - rUnTransStr,m_sSourceFile.endsWith(".xhp"))); + m_aGenPo.setUnTransStr( + ImplUnEscapeSDFText( + rUnTransStr,m_sSourceFile.endsWith(".xhp"))); } //Set translated string when input is in sdf format void PoEntry::setTransStr(const OString& rTransStr) { - GenPoEntry::setTransStr( - ImplUnEscapeSDFText( - rTransStr,m_sSourceFile.endsWith(".xhp"))); + m_aGenPo.setTransStr( + ImplUnEscapeSDFText( + rTransStr,m_sSourceFile.endsWith(".xhp"))); +} + +//Set fuzzy flag +void PoEntry::setFuzzy(const bool bFuzzy) +{ + m_aGenPo.setFuzzy(bFuzzy); } //Write to file void PoEntry::writeToFile(std::ofstream& rOFStream) { - setWhiteSpace("\n"); - setExtractCom(m_sHelpText); - setReference(m_sSourceFile); + m_aGenPo.setWhiteSpace("\n"); + m_aGenPo.setExtractCom(m_sHelpText); + m_aGenPo.setReference(m_sSourceFile); OString sContext = m_sGroupId + "\n" + (m_sLocalId.isEmpty() ? "" : m_sLocalId + "\n") + @@ -426,19 +469,19 @@ void PoEntry::writeToFile(std::ofstream& rOFStream) default: throw; break; } - setContext(sContext); - genKeyId(); - GenPoEntry::writeToFile(rOFStream); + m_aGenPo.setContext(sContext); + m_aGenPo.genKeyId(); + m_aGenPo.writeToFile(rOFStream); } //Read from file void PoEntry::readFromFile(std::ifstream& rIFStream) { - GenPoEntry::readFromFile(rIFStream); - m_sSourceFile = getReference(); + m_aGenPo.readFromFile(rIFStream); + m_sSourceFile = m_aGenPo.getReference(); - OString sContext = getContext(); + OString sContext = m_aGenPo.getContext(); m_sGroupId = sContext.getToken(0,'\n'); if (sContext.indexOf('\n')==sContext.lastIndexOf('\n')) @@ -457,7 +500,7 @@ void PoEntry::readFromFile(std::ifstream& rIFStream) else throw; - m_sHelpText = getExtractCom(); + m_sHelpText = m_aGenPo.getExtractCom(); } //Class PoHeader @@ -474,7 +517,8 @@ OString ImplGetTime() //Constructor PoHeader::PoHeader( const OString& rExtSrc ) - : m_sExtractionSource( rExtSrc ) + : m_aGenPo( GenPoEntry() ) + , m_sExtractionSource( rExtSrc ) , m_sProjectIdVersion( "PACKAGE VERSION" ) , m_sReportMsgidBugsTo( OString("https://bugs.freedesktop.org/") + "enter_bug.cgi?product=LibreOffice&" + @@ -490,23 +534,29 @@ PoHeader::PoHeader( const OString& rExtSrc ) , m_sXGenerator( "LibreOffice" ) , m_sXAcceleratorMarker( "~" ) { - setExtractCom("extracted from " + rExtSrc); - setTransStr("Project-Id-Version: " + m_sProjectIdVersion + "\n" + - "Report-Msgid-Bugs-To: " + m_sReportMsgidBugsTo + "\n" + - "POT-Creation-Date: " + m_sPotCreationDate + "\n" + - "PO-Revision-Date: " + m_sPoRevisionDate + "\n" + - "Last-Translator: " + m_sLastTranslator + "\n" + - "Language-Team: " + m_sLanguageTeam + "\n" + - "MIME-Version: " + m_sMimeVersion + "\n" + - "Content-Type: " + m_sContentType + "; " + - "charset=" + m_sCharset + "\n" + - "Content-Transfer-Encoding: " + m_sEncoding + "\n" + - "X-Genarator: " + m_sXGenerator + "\n" + - "X-Accelerator_Marker: " + m_sXAcceleratorMarker + "\n"); + m_aGenPo.setExtractCom("extracted from " + rExtSrc); + m_aGenPo.setTransStr( + "Project-Id-Version: " + m_sProjectIdVersion + "\n" + + "Report-Msgid-Bugs-To: " + m_sReportMsgidBugsTo + "\n" + + "POT-Creation-Date: " + m_sPotCreationDate + "\n" + + "PO-Revision-Date: " + m_sPoRevisionDate + "\n" + + "Last-Translator: " + m_sLastTranslator + "\n" + + "Language-Team: " + m_sLanguageTeam + "\n" + + "MIME-Version: " + m_sMimeVersion + "\n" + + "Content-Type: " + m_sContentType + "; " + + "charset=" + m_sCharset + "\n" + + "Content-Transfer-Encoding: " + m_sEncoding + "\n" + + "X-Genarator: " + m_sXGenerator + "\n" + + "X-Accelerator_Marker: " + m_sXAcceleratorMarker + "\n"); } PoHeader::~PoHeader() { } +void PoHeader::writeToFile(std::ofstream& rOFStream) +{ + m_aGenPo.writeToFile(rOFStream); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/regexp/inc/regexp/reclass.hxx b/regexp/inc/regexp/reclass.hxx index 4be52bbe6503..ce4f50ef3b7b 100644 --- a/regexp/inc/regexp/reclass.hxx +++ b/regexp/inc/regexp/reclass.hxx @@ -33,6 +33,7 @@ #include <com/sun/star/util/SearchOptions.hpp> #include <sal/types.h> #include <com/sun/star/i18n/XExtendedTransliteration.hpp> +#include <boost/noncopyable.hpp> #if defined REGEXP_DLLIMPLEMENTATION #define REGEXP_DLLPUBLIC SAL_DLLPUBLIC_EXPORT @@ -295,7 +296,7 @@ typedef union } register_info_type; -class REGEXP_DLLPUBLIC Regexpr +class REGEXP_DLLPUBLIC Regexpr: private boost::noncopyable { ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XExtendedTransliteration > translit; @@ -357,9 +358,6 @@ class REGEXP_DLLPUBLIC Regexpr sal_Bool iswordend(const sal_Unicode *d, sal_Unicode *string, sal_Int32 ssize); void set_list_bit(sal_Unicode c, sal_Unicode *b); - Regexpr(const Regexpr&); - Regexpr& operator=(const Regexpr&); - public: // constructors Regexpr( const ::com::sun::star::util::SearchOptions & rOptions, |