diff --git a/helpcompiler/inc/BasCodeTagger.hxx b/helpcompiler/inc/BasCodeTagger.hxx index 3cf9261ed8db..9ff376aa8ad3 100644 --- a/helpcompiler/inc/BasCodeTagger.hxx +++ b/helpcompiler/inc/BasCodeTagger.hxx @@ -34,7 +34,6 @@ class L10N_DLLPUBLIC BasicCodeTagger BasicCodeTagger( xmlDocPtr rootDoc ); ~BasicCodeTagger(); void tagBasicCodes(); - void saveTreeToFile( const std::string& filePath, const std::string& encoding ); }; //================LibXmlTreeWalker=========================================================== diff --git a/helpcompiler/inc/HelpCompiler.hxx b/helpcompiler/inc/HelpCompiler.hxx index 034a629c25e6..8a5dda170747 100644 --- a/helpcompiler/inc/HelpCompiler.hxx +++ b/helpcompiler/inc/HelpCompiler.hxx @@ -245,7 +245,8 @@ public: const std::string &entryName, const Hashtable &bytesToAdd); private: xmlDocPtr getSourceDocument(const fs::path &filePath); - void sourceDocumentPreWorks( xmlDocPtr doc , const fs::path &filePath); + void tagBasicCodeExamples(xmlDocPtr doc); + void saveXhpForJar(xmlDocPtr doc, const fs::path &filePath); xmlNodePtr clone(xmlNodePtr node, const std::string& appl); StreamTable &streamTable; const fs::path inputFile, src, zipdir; diff --git a/helpcompiler/source/BasCodeTagger.cxx b/helpcompiler/source/BasCodeTagger.cxx index 339d96bb1ef6..585291288342 100644 --- a/helpcompiler/source/BasCodeTagger.cxx +++ b/helpcompiler/source/BasCodeTagger.cxx @@ -137,15 +137,9 @@ void BasicCodeTagger::tagParagraph( xmlNodePtr paragraph ) } //3. create new paragraph content - String strLine( - OUString( - reinterpret_cast(codeSnippet), - strlen( - reinterpret_cast(codeSnippet) - ), - RTL_TEXTENCODING_UTF8 - ) - ) ; + OUString strLine( reinterpret_cast(codeSnippet), + strlen(reinterpret_cast(codeSnippet)), + RTL_TEXTENCODING_UTF8 ); m_Highlighter.notifyChange ( 0, 0, &strLine, 1 ); HighlightPortions portions; m_Highlighter.getHighlightPortions( 0, strLine, portions ); @@ -155,7 +149,7 @@ void BasicCodeTagger::tagParagraph( xmlNodePtr paragraph ) for ( size_t i=0; i_/text directory - //1. construct new path - const std::string& pth = filePath.native_file_string(); - std::string sourceNativeXhpPath = pth.substr( pth.rfind( lang+"/text/" ) ).substr( lang.length() ); - std::string xhpFileName = sourceNativeXhpPath.substr( sourceNativeXhpPath.rfind( '/' ) + 1 ); - sourceNativeXhpPath = sourceNativeXhpPath.substr( 0, sourceNativeXhpPath.rfind( '/' ) ); - //2. save xml doc with the new path - // -create directory hierachy - fs::create_directory( fs::path( zipdir.native_file_string() + sourceNativeXhpPath, fs::native ) ); - // -save document - if ( -1 == xmlSaveFormatFileEnc( (zipdir.native_file_string() + sourceNativeXhpPath + '/' + xhpFileName).c_str(), doc, "utf-8", 0 ) ) - throw BasicCodeTagger::FILE_WRITING; - } + BasicCodeTagger bct( doc ); + bct.tagBasicCodes(); + } + catch ( BasicCodeTagger::TaggerException &ex ) + { + if ( ex != BasicCodeTagger::EMPTY_DOCUMENT ) + throw; } } +void HelpCompiler::saveXhpForJar( xmlDocPtr doc, const fs::path &filePath ) +{ + //save processed xhp document in ziptmp_/text directory +#ifdef WNT + std::string pathSep = "\\"; +#else + std::string pathSep = "/"; +#endif + const std::string& sourceXhpPath = filePath.native_file_string(); + std::string zipdirPath = zipdir.native_file_string(); + std::string jarXhpPath = sourceXhpPath.substr( sourceXhpPath.rfind( lang + pathSep + "text" + pathSep ) ).substr( lang.length() ); + std::string xhpFileName = jarXhpPath.substr( jarXhpPath.rfind( pathSep ) + 1 ); + jarXhpPath = jarXhpPath.substr( 0, jarXhpPath.rfind( pathSep ) ); + if ( !jarXhpPath.compare( 1, 11, "text" + pathSep + "sbasic" ) ) + { + tagBasicCodeExamples( doc ); + } + if ( !jarXhpPath.compare( 1, 11, "text" + pathSep + "shared" ) ) + { + size_t pos = zipdirPath.find( "ziptmp" ) + 6; + zipdirPath.replace( pos, module.length(), "shared" ); + } + fs::create_directory( fs::path( zipdirPath + jarXhpPath, fs::native ) ); + if ( -1 == xmlSaveFormatFileEnc( (zipdirPath + jarXhpPath + pathSep + xhpFileName).c_str(), doc, "utf-8", 0 ) ) + std::cerr << "Error saving file to " << (zipdirPath + jarXhpPath + pathSep + xhpFileName).c_str() << std::endl; +} + + xmlDocPtr HelpCompiler::getSourceDocument(const fs::path &filePath) { - static const char *params[4 + 1]; static xsltStylesheetPtr cur = NULL; xmlDocPtr res; @@ -99,22 +108,19 @@ xmlDocPtr HelpCompiler::getSourceDocument(const fs::path &filePath) impl_sleep( 3 ); res = xmlParseFile(filePath.native_file_string().c_str()); } - sourceDocumentPreWorks( res, filePath ); } else { + static const char *params[2 + 1]; if (!cur) { static std::string fsroot('\'' + src.toUTF8() + '\''); - static std::string esclang('\'' + lang + '\''); xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; cur = xsltParseStylesheetFile((const xmlChar *)resEmbStylesheet.native_file_string().c_str()); int nbparams = 0; - params[nbparams++] = "Language"; - params[nbparams++] = esclang.c_str(); params[nbparams++] = "fsroot"; params[nbparams++] = fsroot.c_str(); params[nbparams] = NULL; @@ -125,8 +131,8 @@ xmlDocPtr HelpCompiler::getSourceDocument(const fs::path &filePath) impl_sleep( 3 ); doc = xmlParseFile(filePath.native_file_string().c_str()); } - sourceDocumentPreWorks( doc, filePath ); - //???res = xmlParseFile(filePath.native_file_string().c_str()); + + saveXhpForJar( doc, filePath ); res = xsltApplyStylesheet(cur, doc, params); xmlFreeDoc(doc);