summaryrefslogtreecommitdiffstats
path: root/helpcompiler/source/HelpCompiler.cxx
diff options
context:
space:
mode:
authorDávid Vastag <davewwpublic@gmail.com>2013-02-11 16:49:40 +0100
committerAndras Timar <atimar@suse.com>2013-02-13 10:19:14 +0100
commitd06c698b799e0e4ceaf3a3760c9589fe29dc29a9 (patch)
tree3bfb9ee128aa58f2dd0d436dba1ffe04df933bc4 /helpcompiler/source/HelpCompiler.cxx
parentUpdated core (diff)
downloadcore-d06c698b799e0e4ceaf3a3760c9589fe29dc29a9.tar.gz
core-d06c698b799e0e4ceaf3a3760c9589fe29dc29a9.zip
Basic code syntaxhighlighting added to LibreOffice help
Change-Id: Id47172d0386e7aa28d82178f04b5f626f0c441fe
Diffstat (limited to 'helpcompiler/source/HelpCompiler.cxx')
-rw-r--r--helpcompiler/source/HelpCompiler.cxx42
1 files changed, 37 insertions, 5 deletions
diff --git a/helpcompiler/source/HelpCompiler.cxx b/helpcompiler/source/HelpCompiler.cxx
index 74b29f59ba52..8c6f66b49977 100644
--- a/helpcompiler/source/HelpCompiler.cxx
+++ b/helpcompiler/source/HelpCompiler.cxx
@@ -19,6 +19,7 @@
#include <helpcompiler/HelpCompiler.hxx>
+#include <helpcompiler/BasCodeTagger.hxx>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
@@ -36,25 +37,55 @@ static void impl_sleep( sal_uInt32 nSec )
osl::Thread::wait( aTime );
}
-
HelpCompiler::HelpCompiler(StreamTable &in_streamTable, const fs::path &in_inputFile,
- const fs::path &in_src, const fs::path &in_resEmbStylesheet,
+ const fs::path &in_src, const fs::path &in_zipdir, const fs::path &in_resEmbStylesheet,
const std::string &in_module, const std::string &in_lang, bool in_bExtensionMode)
: streamTable(in_streamTable), inputFile(in_inputFile),
- src(in_src), module(in_module), lang(in_lang), resEmbStylesheet(in_resEmbStylesheet),
+ src(in_src), zipdir(in_zipdir), module(in_module), lang(in_lang), resEmbStylesheet(in_resEmbStylesheet),
bExtensionMode( in_bExtensionMode )
{
xmlKeepBlanksDefaultValue = 0;
char* guitmp = getenv("GUI");
if (guitmp)
{
- // WTF?
gui = (strcmp(guitmp, "UNX") ? gui : "UNIX");
gui = (strcmp(guitmp, "MAC") ? gui : "MAC");
gui = (strcmp(guitmp, "WNT") ? gui : "WIN");
}
}
+void HelpCompiler::sourceDocumentPreWorks( xmlDocPtr doc, const fs::path &filePath )
+{
+ if ( doc )
+ {
+ if ( module == "sbasic" )
+ {
+ try
+ {
+ BasicCodeTagger bct( doc );
+ bct.tagBasicCodes();
+ }
+ catch ( BasicCodeTagger::TaggerException ex )
+ {
+ if ( ex != BasicCodeTagger::EMPTY_DOCUMENT )
+ throw;
+ }
+ //save document in ziptmp<modul>_<lang>/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;
+ }
+ }
+}
+
xmlDocPtr HelpCompiler::getSourceDocument(const fs::path &filePath)
{
static const char *params[4 + 1];
@@ -68,6 +99,7 @@ xmlDocPtr HelpCompiler::getSourceDocument(const fs::path &filePath)
impl_sleep( 3 );
res = xmlParseFile(filePath.native_file_string().c_str());
}
+ sourceDocumentPreWorks( res, filePath );
}
else
{
@@ -93,7 +125,7 @@ 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());
res = xsltApplyStylesheet(cur, doc, params);