/* -*- 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/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #ifdef _WIN32 #if !defined WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN #endif #include #undef CopyFile #include #endif #include #include #include #include #if OSL_DEBUG_LEVEL > 2 void HelpParser::Dump(XMLHashMap* rElem_in) { for (auto const& pos : *rElem_in) { Dump(pos.second,pos.first); } } void HelpParser::Dump(LangHashMap* rElem_in,const OString & sKey_in) { OString x; OString y; fprintf(stdout,"+------------%s-----------+\n",sKey_in.getStr() ); for (auto const& posn : *rElem_in) { x=posn.first; y=posn.second->ToOString(); fprintf(stdout,"key=%s value=%s\n",x.getStr(),y.getStr()); } fprintf(stdout,"+--------------------------+\n"); } #endif HelpParser::HelpParser( OString _sHelpFile ) : sHelpFile(std::move( _sHelpFile )) {}; /*****************************************************************************/ bool HelpParser::CreatePO( /*****************************************************************************/ const OString &rPOFile_in, const OString &sHelpFile, XMLFile* pXmlFile, std::string_view rGsi1){ SimpleXMLParser aParser; //TODO: explicit BOM handling? if (!aParser.Execute( sHelpFile, pXmlFile )) { printf( "%s: %s\n", sHelpFile.getStr(), aParser.GetError().m_sMessage.getStr()); exit(-1); } pXmlFile->Extract(); if( !pXmlFile->CheckExportStatus() ){ return true; } PoOfstream aPoOutput( rPOFile_in, PoOfstream::APP ); if (!aPoOutput.isOpen()) { fprintf(stdout,"Can't open file %s\n",rPOFile_in.getStr()); return false; } XMLHashMap* aXMLStrHM = pXmlFile->GetStrings(); std::vector order = pXmlFile->getOrder(); for (auto const& pos : order) { auto posm = aXMLStrHM->find(pos); LangHashMap* pElem = posm->second; XMLElement* pXMLElement = (*pElem)[ "en-US"_ostr ]; if( pXMLElement != nullptr ) { OString data( pXMLElement->ToOString(). replaceAll("\n"_ostr,OString()). replaceAll("\t"_ostr,OString()).trim()); common::writePoEntry( "Helpex"_ostr, aPoOutput, sHelpFile, rGsi1, posm->first, OString(), OString(), data); pXMLElement=nullptr; } else { // If this is something totally unexpected, wouldn't an assert() be in order? // On the other hand, if this is expected, why the printf? fprintf(stdout,"\nDBG: NullPointer in HelpParser::CreatePO, File %s\n", sHelpFile.getStr()); } } aPoOutput.close(); return true; } bool HelpParser::Merge( const OString &rDestinationFile, const OString& rLanguage , MergeDataFile* pMergeDataFile ) { SimpleXMLParser aParser; //TODO: explicit BOM handling? XMLFile xmlfile( OString('0') ); if (!aParser.Execute( sHelpFile, &xmlfile)) { SAL_WARN("l10ntools", "could not parse " << sHelpFile); return false; } MergeSingleFile( &xmlfile , pMergeDataFile , rLanguage , rDestinationFile ); return true; } void HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile* pMergeDataFile , const OString& sLanguage , OString const & sPath ) { file->Extract(); XMLHashMap* aXMLStrHM = file->GetStrings(); static ResData s_ResData(""_ostr,""_ostr); s_ResData.sResTyp = "help"_ostr; std::vector order = file->getOrder(); for (auto const& pos : order) // Merge every l10n related string in the same order as export { auto posm = aXMLStrHM->find(pos); LangHashMap* aLangHM = posm->second; #if OSL_DEBUG_LEVEL > 2 printf("*********************DUMPING HASHMAP***************************************"); Dump(aXMLStrHM); printf("DBG: sHelpFile = %s\n",sHelpFile.getStr() ); #endif s_ResData.sGId = posm->first; s_ResData.sFilename = sHelpFile; ProcessHelp( aLangHM , sLanguage, &s_ResData , pMergeDataFile ); } file->Write(sPath); } /* ProcessHelp method: search for en-US entry and replace it with the current language*/ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const OString& sCur , ResData *pResData , MergeDataFile* pMergeDataFile ){ XMLElement* pXMLElement = nullptr; if( sCur.equalsIgnoreAsciiCase("en-US") ) return; pXMLElement = (*aLangHM)[ "en-US"_ostr ]; if( pXMLElement == nullptr ) { printf("Error: Can't find en-US entry\n"); return; } OString sNewText; OString sNewdata; OString sSourceText( pXMLElement->ToOString(). replaceAll( "\n"_ostr, OString()). replaceAll( "\t"_ostr, OString())); // re-add spaces to the beginning of translated string, // important for indentation of Basic code examples sal_Int32 nPreSpaces = 0; sal_Int32 nLen = sSourceText.getLength(); while ( (nPreSpaces < nLen) && (sSourceText[nPreSpaces] == ' ') ) nPreSpaces++; if( sCur == "qtz" ) { sNewText = MergeEntrys::GetQTZText(*pResData, sSourceText); sNewdata = sNewText; } else if( pMergeDataFile ) { MergeEntrys *pEntrys = pMergeDataFile->GetMergeEntrys( pResData ); if( pEntrys != nullptr) { pEntrys->GetText( sNewText, sCur, true ); if (helper::isWellFormedXML(XMLUtil::QuotHTML(sNewText))) { sNewdata = sSourceText.subView(0,nPreSpaces) + sNewText; } } } if (!sNewdata.isEmpty()) { XMLData *data = new XMLData( sNewdata , nullptr ); // Add new one pXMLElement->RemoveAndDeleteAllChildren(); pXMLElement->AddChild( data ); aLangHM->erase( sCur ); } else { SAL_WARN( "l10ntools", "Can't find GID=" << pResData->sGId << " TYP=" << pResData->sResTyp); } pXMLElement->ChangeLanguageTag(sCur); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ n value='distro/mimo/mimo-6-2'>distro/mimo/mimo-6-2 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/osx
AgeCommit message (Expand)Author
2024-10-24Remove archaic xmergeCaolán McNamara
2023-07-05Add all source directories as folder references to the Xcode projectKhaled Hosny
2022-09-01Add all vcl subdirs to soffice.xcodeprojKhaled Hosny
2022-08-31tdf#30731: Improve caret travelling in WriterKhaled Hosny
2022-06-07tdf#129674 Add GoTo Sheet commandLaurent BP
2022-02-02Add some source files for debugging convenienceTor Lillqvist
2022-01-27Add more source files for debugging convenienceTor Lillqvist
2022-01-27Add more source files for debugging convenienceTor Lillqvist
2021-12-30use concrete types in chart2, SvxShapeRectNoel Grandin
2021-12-30use concrete types in chart2, SvxGroupShape and SvxShapePolyPolygonNoel Grandin
2021-12-06Retire build-nocheckThorsten Behrens
2021-11-24Add source files from basic/source/sbxTor Lillqvist
2021-10-21Add source files from fpicker/source/aquaTor Lillqvist
2021-04-07Updated README.md files to represent current code / use Markdown formatHossein
2021-03-24Using .md extension/Markdown syntax for modules READMEHossein
2021-01-14Add more source files for breakpointing convenienceTor Lillqvist
2021-01-14Add some more source files and drop dead onesTor Lillqvist
2020-12-08Add source files from svx/source/tbxctrlsTor Lillqvist
2020-12-06Add source files from dbaccess/source/ui/miscTor Lillqvist
2020-12-06Fix some bogus pathsTor Lillqvist
2020-10-16Rename CLANG_CC, CLANG_CXX configuration vars (avoid clash with scan-build)Stephan Bergmann
2020-06-12PopupMenuFloatingWindow is now unusedCaolán McNamara
2020-05-25Add source files from sfx2/source/applTor Lillqvist
2020-05-22Add source files from xmlsecurity/source/xmlsecTor Lillqvist
2020-05-22Add source files from desktop for breakpointing convenienceTor Lillqvist
2020-05-12Add some more source files for breakpointing convenienceTor Lillqvist
2020-05-11Add some more source files for breakpointing convenienceTor Lillqvist
2020-05-06Add source files from cui/source/options and unotools/source/i18nTor Lillqvist
2020-04-29Add source files in the C++/UNO bridge for easier breakpointingTor Lillqvist
2019-11-20Add some more source files for breakpointing convenienceTor Lillqvist
2019-10-08Add missing source files in vcl/source/gdiTor Lillqvist
2018-11-29Rename Mac OS X to official name macOS in comments and documentationBartosz Kosiorek
2018-05-21Add sal/osl/unx/file.cxx for debugging convenienceTor Lillqvist
2018-05-21Updates by Xcode 9.3Tor Lillqvist
2018-01-08Add a few Mac-specific source files in avmedia for easier breakpointingTor Lillqvist
2017-02-02gbuild-to-ide added -DLIBO_INTERNAL_ONLY to CXXFLAGSjan Iversen
2017-01-29gbuild-to-ide xcode, added targets in menujan Iversen
2016-10-20Add some more source files for breakpointing convenienceTor Lillqvist
2016-02-08vcl: cmdevt.[hc]xx -> commandevent.[hc]xxChris Sherlock
2014-03-06Add an Xcode project to make it easier to debug a running soffice on OS XTor Lillqvist