[Libreoffice-commits] libvisio.git: src/lib
Fridrich Štrba
fridrich.strba at bluewin.ch
Fri Feb 24 09:36:12 UTC 2017
src/lib/VSDXTheme.cpp | 120 +++++++++++++++++++++++++++++++++++++++++++++++++-
src/lib/VSDXTheme.h | 25 ++++++++++
src/lib/tokens.txt | 30 ++++++++++++
3 files changed, 174 insertions(+), 1 deletion(-)
New commits:
commit ca14a80bcb129878bb95d1187a8f3761e65b0842
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Fri Feb 24 10:35:45 2017 +0100
Parse Font scheme
Change-Id: If2de16033a921443025f582431c4a4b03a9e7145
diff --git a/src/lib/VSDXTheme.cpp b/src/lib/VSDXTheme.cpp
index edf395c..a05484b 100644
--- a/src/lib/VSDXTheme.cpp
+++ b/src/lib/VSDXTheme.cpp
@@ -46,8 +46,24 @@ libvisio::VSDXClrScheme::VSDXClrScheme()
{
}
+libvisio::VSDXFont::VSDXFont()
+ : m_latinTypeFace(),
+ m_eaTypeFace(),
+ m_csTypeFace(),
+ m_typeFaces()
+{
+}
+
+libvisio::VSDXFontScheme::VSDXFontScheme()
+ : m_majorFont(),
+ m_minorFont(),
+ m_schemeId(0)
+{
+}
+
libvisio::VSDXTheme::VSDXTheme()
- : m_clrScheme()
+ : m_clrScheme(),
+ m_fontScheme()
{
}
@@ -63,6 +79,7 @@ int libvisio::VSDXTheme::getElementToken(xmlTextReaderPtr reader)
bool libvisio::VSDXTheme::parse(librevenge::RVNGInputStream *input)
{
+ VSD_DEBUG_MSG(("VSDXTheme::parse\n"));
if (!input)
return false;
@@ -84,6 +101,9 @@ bool libvisio::VSDXTheme::parse(librevenge::RVNGInputStream *input)
case XML_A_CLRSCHEME:
readClrScheme(reader.get());
break;
+ case XML_A_FONTSCHEME:
+ readFontScheme(reader.get());
+ break;
default:
break;
}
@@ -137,8 +157,104 @@ boost::optional<libvisio::Colour> libvisio::VSDXTheme::readSysClr(xmlTextReaderP
return retVal;
}
+void libvisio::VSDXTheme::readFontScheme(xmlTextReaderPtr reader)
+{
+ VSD_DEBUG_MSG(("VSDXTheme::readFontScheme\n"));
+ int ret = 1;
+ int tokenId = XML_TOKEN_INVALID;
+ int tokenType = -1;
+ do
+ {
+ ret = xmlTextReaderRead(reader);
+ tokenId = getElementToken(reader);
+ if (XML_TOKEN_INVALID == tokenId)
+ {
+ VSD_DEBUG_MSG(("VSDXTheme::readFontScheme: unknown token %s\n", xmlTextReaderConstName(reader)));
+ }
+ tokenType = xmlTextReaderNodeType(reader);
+ switch (tokenId)
+ {
+ case XML_A_MAJORFONT:
+ readFont(reader, tokenId, m_fontScheme.m_majorFont);
+ break;
+ case XML_A_MINORFONT:
+ readFont(reader, tokenId, m_fontScheme.m_minorFont);
+ break;
+ case XML_VT_SCHEMEID:
+ break;
+ default:
+ break;
+ }
+ }
+ while ((XML_A_FONTSCHEME != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
+}
+
+void libvisio::VSDXTheme::readFont(xmlTextReaderPtr reader, int idToken, VSDXFont &font)
+{
+ VSD_DEBUG_MSG(("VSDXTheme::readFont\n"));
+ int ret = 1;
+ int tokenId = XML_TOKEN_INVALID;
+ int tokenType = -1;
+ do
+ {
+ ret = xmlTextReaderRead(reader);
+ tokenId = getElementToken(reader);
+ if (XML_TOKEN_INVALID == tokenId)
+ {
+ VSD_DEBUG_MSG(("VSDXTheme::readFont: unknown token %s\n", xmlTextReaderConstName(reader)));
+ }
+ tokenType = xmlTextReaderNodeType(reader);
+ switch (tokenId)
+ {
+ case XML_A_LATIN:
+ readTypeFace(reader, font.m_latinTypeFace);
+ break;
+ case XML_A_EA:
+ readTypeFace(reader, font.m_eaTypeFace);
+ break;
+ case XML_A_CS:
+ readTypeFace(reader, font.m_csTypeFace);
+ break;
+ case XML_A_FONT:
+ {
+ int script;
+ librevenge::RVNGString typeFace;
+ readTypeFace(reader, script, typeFace);
+ font.m_typeFaces[script] = typeFace;
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ while ((idToken != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
+}
+
+void libvisio::VSDXTheme::readTypeFace(xmlTextReaderPtr reader, librevenge::RVNGString &typeFace)
+{
+ const shared_ptr<xmlChar> sTypeFace(xmlTextReaderGetAttribute(reader, BAD_CAST("typeface")), xmlFree);
+ if (sTypeFace)
+ {
+ typeFace.clear();
+ typeFace.sprintf("%s", (const char *)sTypeFace.get());
+ }
+}
+
+void libvisio::VSDXTheme::readTypeFace(xmlTextReaderPtr reader, int &script, librevenge::RVNGString &typeFace)
+{
+ const shared_ptr<xmlChar> sScript(xmlTextReaderGetAttribute(reader, BAD_CAST("script")), xmlFree);
+ if (sScript)
+ {
+ int token = libvisio::VSDXMLTokenMap::getTokenId(sScript.get());
+ if (XML_TOKEN_INVALID != token)
+ script = token;
+ }
+ readTypeFace(reader, typeFace);
+}
+
void libvisio::VSDXTheme::readClrScheme(xmlTextReaderPtr reader)
{
+ VSD_DEBUG_MSG(("VSDXTheme::readClrScheme\n"));
int ret = 1;
int tokenId = XML_TOKEN_INVALID;
int tokenType = -1;
@@ -238,6 +354,7 @@ void libvisio::VSDXTheme::readThemeColour(xmlTextReaderPtr reader, int idToken,
void libvisio::VSDXTheme::readVariationClrSchemeLst(xmlTextReaderPtr reader)
{
+ VSD_DEBUG_MSG(("VSDXTheme::readVariationClrSchemeLst\n"));
int ret = 1;
int tokenId = XML_TOKEN_INVALID;
int tokenType = -1;
@@ -268,6 +385,7 @@ void libvisio::VSDXTheme::readVariationClrSchemeLst(xmlTextReaderPtr reader)
void libvisio::VSDXTheme::readVariationClrScheme(xmlTextReaderPtr reader, VSDXVariationClrScheme &varClrSch)
{
+ VSD_DEBUG_MSG(("VSDXTheme::readVariationClrScheme\n"));
int ret = 1;
int tokenId = XML_TOKEN_INVALID;
int tokenType = -1;
diff --git a/src/lib/VSDXTheme.h b/src/lib/VSDXTheme.h
index 4f251cb..e0de7c3 100644
--- a/src/lib/VSDXTheme.h
+++ b/src/lib/VSDXTheme.h
@@ -11,6 +11,7 @@
#define __VSDXTHEME_H__
#include <vector>
+#include <map>
#include <boost/optional.hpp>
#include <librevenge-stream/librevenge-stream.h>
#include "VSDXMLHelper.h"
@@ -53,6 +54,25 @@ struct VSDXClrScheme
VSDXClrScheme();
};
+struct VSDXFont
+{
+ librevenge::RVNGString m_latinTypeFace;
+ librevenge::RVNGString m_eaTypeFace;
+ librevenge::RVNGString m_csTypeFace;
+ std::map<unsigned, librevenge::RVNGString> m_typeFaces;
+
+ VSDXFont();
+};
+
+struct VSDXFontScheme
+{
+ VSDXFont m_majorFont;
+ VSDXFont m_minorFont;
+ unsigned m_schemeId;
+
+ VSDXFontScheme();
+};
+
class VSDXTheme
{
public:
@@ -72,10 +92,15 @@ private:
void readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr);
void readVariationClrSchemeLst(xmlTextReaderPtr reader);
void readVariationClrScheme(xmlTextReaderPtr reader, VSDXVariationClrScheme &varClrSch);
+ void readFontScheme(xmlTextReaderPtr reader);
+ void readFont(xmlTextReaderPtr reader, int idToken, VSDXFont &font);
+ void readTypeFace(xmlTextReaderPtr reader, librevenge::RVNGString &typeFace);
+ void readTypeFace(xmlTextReaderPtr reader, int &script, librevenge::RVNGString &typeFace);
int getElementToken(xmlTextReaderPtr reader);
VSDXClrScheme m_clrScheme;
+ VSDXFontScheme m_fontScheme;
};
} // namespace libvisio
diff --git a/src/lib/tokens.txt b/src/lib/tokens.txt
index 661093c..c15e7ef 100644
--- a/src/lib/tokens.txt
+++ b/src/lib/tokens.txt
@@ -41,6 +41,7 @@ Angle
a:objectDefaults
a:outerShdw
a:prstDash
+ARAB
ArcTo
a:satMod
a:schemeClr
@@ -56,16 +57,19 @@ BeginArrow
BeginX
BeginY
BegTrigger
+BENG
BottomMargin
Bullet
BulletFont
BulletFontSize
BulletStr
C
+CANS
Case
Cell
Char
Character
+CHER
Color
ColorEntry
Colors
@@ -88,6 +92,7 @@ dcterms:created
dcterms:modified
dc:title
DefaultTabStop
+DEVA
DoubleStrikethrough
DrawingScale
E
@@ -99,6 +104,7 @@ EndArrow
EndTrigger
EndX
EndY
+ETHI
FaceName
FaceNames
Fill
@@ -117,6 +123,13 @@ Foreign
ForeignData
Geom
Geometry
+GEOR
+GUJR
+GURU
+HANG
+HANS
+HANT
+HEBR
Height
HideText
Highlight
@@ -129,6 +142,10 @@ IndFirst
IndLeft
IndRight
InfiniteLine
+JPAN
+KHMR
+KNDA
+LAOO
Layer
LayerMem
LayerMember
@@ -145,11 +162,14 @@ LocPinY
Master
Masters
Misc
+MLYM
+MONG
MoveTo
NoFill
NoLine
NoShow
NURBSTo
+ORYA
Overline
Page
PageHeight
@@ -197,6 +217,7 @@ ShdwForegnd
ShdwOffsetX
ShdwOffsetY
ShdwPattern
+SINH
Size
SolutionXML
SpAfter
@@ -208,8 +229,11 @@ Strikethru
Style
StyleSheet
StyleSheets
+SYRC
Tab
Tabs
+TAML
+TELU
Template
Text
TextBkgnd
@@ -218,7 +242,10 @@ TextBlock
TextDirection
TextPosAfterBullet
TextXForm
+THAA
+THAI
ThemeIndex
+TIBT
TopMargin
tp
TxtAngle
@@ -228,9 +255,11 @@ TxtLocPinY
TxtPinX
TxtPinY
TxtWidth
+UIGH
VariationColorIndex
VariationStyleIndex
VerticalAlign
+VIET
Visible
vt:bkgnd
vt:color
@@ -267,3 +296,4 @@ X
XForm
XForm1D
Y
+YIII
More information about the Libreoffice-commits
mailing list