Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
67b8c033
Kaydet (Commit)
67b8c033
authored
Şub 12, 2013
tarafından
Andras Timar
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#41737 syntax highlighting of Basic code examples in offline help
Change-Id: I7dc5b189e98a0351bac0eab28c1161b5893f5ef1
üst
fb1f3db0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
57 deletions
+48
-57
BasCodeTagger.hxx
helpcompiler/inc/BasCodeTagger.hxx
+0
-1
HelpCompiler.hxx
helpcompiler/inc/HelpCompiler.hxx
+2
-1
BasCodeTagger.cxx
helpcompiler/source/BasCodeTagger.cxx
+6
-21
HelpCompiler.cxx
helpcompiler/source/HelpCompiler.cxx
+40
-34
No files found.
helpcompiler/inc/BasCodeTagger.hxx
Dosyayı görüntüle @
67b8c033
...
...
@@ -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===========================================================
...
...
helpcompiler/inc/HelpCompiler.hxx
Dosyayı görüntüle @
67b8c033
...
...
@@ -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
;
...
...
helpcompiler/source/BasCodeTagger.cxx
Dosyayı görüntüle @
67b8c033
...
...
@@ -137,15 +137,9 @@ void BasicCodeTagger::tagParagraph( xmlNodePtr paragraph )
}
//3. create new paragraph content
String
strLine
(
OUString
(
reinterpret_cast
<
const
sal_Char
*>
(
codeSnippet
),
strlen
(
reinterpret_cast
<
const
char
*>
(
codeSnippet
)
),
RTL_TEXTENCODING_UTF8
)
)
;
OUString
strLine
(
reinterpret_cast
<
const
sal_Char
*>
(
codeSnippet
),
strlen
(
reinterpret_cast
<
const
char
*>
(
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
<
portions
.
size
();
i
++
)
{
HighlightPortion
&
r
=
portions
[
i
];
subStr
=
xmlStrsub
(
codeSnippet
,
r
.
nBegin
,
r
.
nEnd
-
r
.
nBegin
);
subStr
=
(
xmlChar
*
)
OUStringToOString
(
strLine
.
copy
(
r
.
nBegin
,
r
.
nEnd
-
r
.
nBegin
),
RTL_TEXTENCODING_UTF8
).
getStr
(
);
text
=
xmlNewText
(
subStr
);
if
(
r
.
tokenType
!=
TT_WHITESPACE
)
{
...
...
@@ -185,7 +179,7 @@ void BasicCodeTagger::tagBasicCodes()
{
getBasicCodeContainerNodes
();
}
catch
(
TaggerException
ex
)
catch
(
TaggerException
&
ex
)
{
std
::
cout
<<
"BasCodeTagger error occured. Error code:"
<<
ex
<<
std
::
endl
;
}
...
...
@@ -229,7 +223,7 @@ xmlChar* BasicCodeTagger::getTypeString( TokenTypes tokenType )
str
=
"operator"
;
break
;
case
TT_KEYWORDS
:
str
=
"keyword
s
"
;
str
=
"keyword"
;
break
;
case
TT_PARAMETER
:
str
=
"parameter"
;
...
...
@@ -240,12 +234,3 @@ xmlChar* BasicCodeTagger::getTypeString( TokenTypes tokenType )
}
return
xmlCharStrdup
(
str
);
}
//! Saves the current xml DOM to file with the provided libxml2 encoding string in an unformatted way.
void
BasicCodeTagger
::
saveTreeToFile
(
const
std
::
string
&
filePath
,
const
std
::
string
&
encoding
)
{
//saveDocument
int
ret
=
xmlSaveFormatFileEnc
(
filePath
.
c_str
(),
m_pDocument
,
encoding
.
c_str
(),
0
);
if
(
ret
==
-
1
)
throw
FILE_WRITING
;
}
helpcompiler/source/HelpCompiler.cxx
Dosyayı görüntüle @
67b8c033
...
...
@@ -54,41 +54,50 @@ HelpCompiler::HelpCompiler(StreamTable &in_streamTable, const fs::path &in_input
}
}
void
HelpCompiler
::
sourceDocumentPreWorks
(
xmlDocPtr
doc
,
const
fs
::
path
&
filePath
)
void
HelpCompiler
::
tagBasicCodeExamples
(
xmlDocPtr
doc
)
{
if
(
doc
)
try
{
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
;
}
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<module>_<lang>/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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment