diff options
Diffstat (limited to 'l10ntools/source')
-rw-r--r-- | l10ntools/source/localize.cxx | 2 | ||||
-rw-r--r-- | l10ntools/source/stringex.cxx | 42 | ||||
-rw-r--r-- | l10ntools/source/stringmerge.cxx | 193 |
3 files changed, 0 insertions, 237 deletions
diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 4b7afd7b92d1..5bd55b43d928 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -186,7 +186,6 @@ bool handleFile( { RTL_CONSTASCII_STRINGPARAM(".xcu"), "cfgex", false }, { RTL_CONSTASCII_STRINGPARAM(".xrm"), "xrmex", false }, { RTL_CONSTASCII_STRINGPARAM("description.xml"), "xrmex", true }, - { RTL_CONSTASCII_STRINGPARAM("strings.xml"), "stringex", true }, { RTL_CONSTASCII_STRINGPARAM(".xhp"), "helpex", false }, { RTL_CONSTASCII_STRINGPARAM(".properties"), "propex", false }, { RTL_CONSTASCII_STRINGPARAM(".ui"), "uiex", false }, @@ -270,7 +269,6 @@ void handleFilesOfDir( bool includeProject(const OString& rProject) { static const OString projects[] = { "accessibility", - "android", "avmedia", "basctl", "basic", diff --git a/l10ntools/source/stringex.cxx b/l10ntools/source/stringex.cxx deleted file mode 100644 index 1b507f82eca3..000000000000 --- a/l10ntools/source/stringex.cxx +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- 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/. - */ - -#include <iostream> -#include "sal/main.h" - -#include "common.hxx" -#include "stringmerge.hxx" - -SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) -{ - common::HandledArgs aArgs; - if( !common::handleArguments(argc, argv, aArgs) ) - { - common::writeUsage("stringex","string.xml"); - return 1; - } - - StringParser aParser(aArgs.m_sInputFile, aArgs.m_sLanguage); - if( !aParser.isInitialized() ) - { - return 1; - } - - if( aArgs.m_bMergeMode ) - { - aParser.Merge( aArgs.m_sMergeSrc, aArgs.m_sOutputFile ); - } - else - { - aParser.Extract( aArgs.m_sOutputFile ); - } - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/source/stringmerge.cxx b/l10ntools/source/stringmerge.cxx deleted file mode 100644 index 7cc5d0100c7b..000000000000 --- a/l10ntools/source/stringmerge.cxx +++ /dev/null @@ -1,193 +0,0 @@ -/* -*- 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/. - */ - -#include <iostream> -#include <fstream> -#include <cassert> -#include <cstring> - -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> -#include <libxml/xmlstring.h> - -#include "export.hxx" -#include "helper.hxx" -#include "common.hxx" -#include "po.hxx" -#include "stringmerge.hxx" - -//Parse strings.xml file -StringParser::StringParser( - const OString& rInputFile, const OString& rLang ) - : m_pSource( 0 ) - , m_sLang( rLang ) - , m_bIsInitialized( false ) -{ - m_pSource = xmlParseFile( rInputFile.getStr() ); - if ( !m_pSource ) { - std::cerr - << "Stringx error: Cannot open source file: " - << rInputFile.getStr() << std::endl; - return; - } - if( !m_pSource->name ) - { - m_pSource->name = new char[strlen(rInputFile.getStr())+1]; - strcpy( m_pSource->name, rInputFile.getStr() ); - } - m_bIsInitialized = true; -} - -StringParser::~StringParser() -{ -} - -//Extract strings form source file -void StringParser::Extract( const OString& rPOFile ) -{ - assert( m_bIsInitialized ); - PoOfstream aPOStream( rPOFile, PoOfstream::APP ); - if( !aPOStream.isOpen() ) - { - std::cerr - << "stringex error: Cannot open po file for extract: " - << rPOFile.getStr() << std::endl; - return; - } - - xmlNodePtr pRootNode = xmlDocGetRootElement( m_pSource ); // <resource> - for( xmlNodePtr pCurrent = pRootNode->children->next; - pCurrent; pCurrent = pCurrent->next) - { - if (!xmlStrcmp(pCurrent->name, (const xmlChar*)("string"))) - { - xmlChar* pTranslatable = xmlGetProp(pCurrent, (const xmlChar*)("translatable")); - if (xmlStrcmp(pTranslatable, (const xmlChar*)("false"))) - { - xmlChar* pID = xmlGetProp(pCurrent, (const xmlChar*)("name")); - xmlChar* pText = xmlNodeGetContent(pCurrent); - const OString sTemp = - helper::unEscapeAll(helper::xmlStrToOString( pText ),"\\n""\\t""\\\"""\\\'","\n""\t""\"""\'"); - common::writePoEntry( - "Stringex", aPOStream, m_pSource->name, "string", - helper::xmlStrToOString( pID ), OString(), OString(), - sTemp); - - xmlFree( pID ); - xmlFree( pText ); - } - xmlFree( pTranslatable ); - } - } - - xmlFreeDoc( m_pSource ); - xmlCleanupParser(); - aPOStream.close(); - m_bIsInitialized = false; -} - -//Merge strings to localized strings.xml file -void StringParser::Merge( - const OString &rMergeSrc, const OString &rDestinationFile ) -{ - assert( m_bIsInitialized ); - - MergeDataFile* pMergeDataFile = 0; - if( m_sLang != "qtz" ) - { - pMergeDataFile = new MergeDataFile( - rMergeSrc, static_cast<OString>( m_pSource->name ), false, false ); - const std::vector<OString> vLanguages = pMergeDataFile->GetLanguages(); - if( vLanguages.size()>=1 && vLanguages[0] != m_sLang ) - { - std::cerr - << "stringex error: given language conflicts with " - << "language of Mergedata file: " - << m_sLang.getStr() << " - " - << vLanguages[0].getStr() << std::endl; - delete pMergeDataFile; - return; - } - } - - xmlNodePtr pRootNode = xmlDocGetRootElement( m_pSource ); //<resource> - - for( xmlNodePtr pCurrent = pRootNode->children; - pCurrent; pCurrent = pCurrent->next) - { - if (!xmlStrcmp(pCurrent->name, (const xmlChar*)("string"))) - { - xmlChar* pID = xmlGetProp(pCurrent, (const xmlChar*)("name")); - ResData aResData( - helper::xmlStrToOString( pID ), - static_cast<OString>(m_pSource->name) ); - xmlFree( pID ); - aResData.sResTyp = "string"; - OString sNewText; - if( m_sLang == "qtz" ) - { - xmlChar* pText = xmlNodeGetContent(pCurrent); - const OString sOriginText = - helper::unEscapeAll(helper::xmlStrToOString( pText ),"\\n""\\t""\\\"""\\\'","\n""\t""\"""\'"); - xmlFree( pText ); - sNewText = MergeEntrys::GetQTZText(aResData, sOriginText); - } - else if( pMergeDataFile ) - { - MergeEntrys* pEntrys = pMergeDataFile->GetMergeEntrys( &aResData ); - if( pEntrys ) - { - pEntrys->GetText( sNewText, STRING_TYP_TEXT, m_sLang ); - sNewText = helper::escapeAll(sNewText, "\n""\t""\'""\"","\\n""\\t""\\\'""\\\""); - } - } - if( !sNewText.isEmpty() ) - { - xmlNodeSetContent( - pCurrent, - xmlEncodeSpecialChars( NULL, - reinterpret_cast<const xmlChar*>( - sNewText.getStr() ))); - } - } - } - - for( xmlNodePtr pCurrent = pRootNode->children; pCurrent; ) - { - if (!xmlStrcmp(pCurrent->name, (const xmlChar*)("string"))) - { - xmlChar* pTranslatable = xmlGetProp(pCurrent, (const xmlChar*)("translatable")); - if (!xmlStrcmp(pTranslatable, (const xmlChar*)("false"))) - { - xmlNodePtr pNonTranslatable = pCurrent; - pCurrent = pCurrent->next; - xmlUnlinkNode( pNonTranslatable ); - xmlFreeNode( pNonTranslatable ); - } - else - { - pCurrent = pCurrent->next; - } - xmlFree( pTranslatable ); - } - else - { - pCurrent = pCurrent->next; - } - } - - delete pMergeDataFile; - xmlSaveFile( rDestinationFile.getStr(), m_pSource ); - xmlFreeDoc( m_pSource ); - xmlCleanupParser(); - m_bIsInitialized = false; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |