summaryrefslogtreecommitdiff
path: root/src/xmlcomposer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmlcomposer.cpp')
-rw-r--r--src/xmlcomposer.cpp140
1 files changed, 96 insertions, 44 deletions
diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp
index cce87d4..cb1bf16 100644
--- a/src/xmlcomposer.cpp
+++ b/src/xmlcomposer.cpp
@@ -330,7 +330,7 @@ void XmlComposer::incrementAutoCount(int type)
#define DEFAULT_CONTROLWORD processDefault(cw, flags, param)
#define DUMMY 1 == 1
#define NUM_ATTR(x) formatInt(x)
-
+#define DO_EXTRAS() (m_composer->GetOptions().extras)
/* ----------------------------------------------------------------------------------
* BASE ANALYSER
@@ -512,12 +512,16 @@ bool XmlComposer::BaseAnalyser::processTextFormatting(const string& cw, int flag
format.textSetHidden(on);
else if(cw == "ul")
format.textSetUnderline(on);
- else if(cw == "cf" && HAS_PARAM)
- format.textSetColor(param);
else if(cw == "super")
format.textSetSuScript(RtfFormatting::SUPERSCRIPT);
else if(cw == "sub")
format.textSetSuScript(RtfFormatting::SUBSCRIPT);
+ else if(cw == "cf" && HAS_PARAM)
+ format.textSetColor(param);
+ else if(cw == "f" && HAS_PARAM)
+ format.textSetFont(param);
+ else if(cw == "fs" && HAS_PARAM)
+ format.textSetFontSize(param);
else
return false;
@@ -536,6 +540,7 @@ bool XmlComposer::BaseAnalyser::processTextAutoContent(const string& cw, int fla
dest->charData(kValNull);
// Auto generated content
+
if(cw == "chftn")
{
// Footnote auto numbering
@@ -544,7 +549,11 @@ bool XmlComposer::BaseAnalyser::processTextAutoContent(const string& cw, int fla
AN_ELEMENT(kElRef);
AN_ATTRIBUTE(kAtType, kValFootNote);
AN_ATTRIBUTE(kAtTo, ac);
- dest->charData(formatInt(ac));
+
+ // Only output the actual link text in this case
+ if(DO_EXTRAS())
+ dest->charData(formatInt(ac));
+
AN_POP_ELEMENT();
return true;
}
@@ -677,8 +686,14 @@ ON_GROUPEND(Style)
AN_ATTRIBUTE(kAtStrike, L"1");
if(props.textIsUnderline())
AN_ATTRIBUTE(kAtUnderline, L"1");
- if(props.textColor() != -1 && m_composer->getOptions().doColors)
- AN_ATTRIBUTE(kAtColor, props.textColor());
+
+ if(DO_EXTRAS())
+ {
+ // TODO: Do fonts here
+
+ if(props.textColor() != -1)
+ AN_ATTRIBUTE(kAtColor, props.textColor());
+ }
}
@@ -687,15 +702,13 @@ ON_GROUPEND(Style)
ON_INITIALIZE(FontTable)
{
AN_ELEMENT(kElFontTable);
+ AN_DESTINATION(Null);
}
ON_GROUPSTART(FontTable)
{
// Each group should be a style
AN_ANALYSER(Font);
-
- // Without any character data
- AN_DESTINATION(Null);
}
@@ -768,30 +781,33 @@ ON_CONTROLWORD(List)
// The list type
else if(cw == "levelnfc" && HAS_PARAM)
{
- switch(param)
- {
- case 0: // 1, 2, 3
- case 5: // 1st, 2nd, 3rd
- case 6: // One, Two, Three
- case 7: // First, Second, Third
- case 22: // 01, 02, 03
- AN_ATTRIBUTE(kAtType, kValArabic);
- break;
- case 1: // I, II, III
- AN_ATTRIBUTE(kAtType, kValUpperRoman);
- break;
- case 2: // i, ii, iii
- AN_ATTRIBUTE(kAtType, kValLowerRoman);
- break;
- case 3: // A, B, C
- AN_ATTRIBUTE(kAtType, kValUpperAlpha);
- break;
- case 4: // a, b, c
- AN_ATTRIBUTE(kAtType, kValLowerAlpha);
- break;
- default:
- AN_ATTRIBUTE(kAtType, kValDisc);
- break;
+ if(DO_EXTRAS())
+ {
+ switch(param)
+ {
+ case 0: // 1, 2, 3
+ case 5: // 1st, 2nd, 3rd
+ case 6: // One, Two, Three
+ case 7: // First, Second, Third
+ case 22: // 01, 02, 03
+ AN_ATTRIBUTE(kAtType, kValArabic);
+ break;
+ case 1: // I, II, III
+ AN_ATTRIBUTE(kAtType, kValUpperRoman);
+ break;
+ case 2: // i, ii, iii
+ AN_ATTRIBUTE(kAtType, kValLowerRoman);
+ break;
+ case 3: // A, B, C
+ AN_ATTRIBUTE(kAtType, kValUpperAlpha);
+ break;
+ case 4: // a, b, c
+ AN_ATTRIBUTE(kAtType, kValLowerAlpha);
+ break;
+ default:
+ AN_ATTRIBUTE(kAtType, kValDisc);
+ break;
+ }
}
switch(param)
@@ -959,7 +975,12 @@ ON_CONTROLWORD(Root)
else if(cw == "info")
AN_ANALYSER(Info);
else if(cw == "fonttbl")
- AN_ANALYSER(FontTable);
+ {
+ if(DO_EXTRAS())
+ AN_ANALYSER(FontTable);
+ else
+ AN_ANALYSER(Skip);
+ }
else if(cw == "colortbl")
AN_ANALYSER(Skip);
else if(cw == "footnote")
@@ -992,6 +1013,8 @@ ON_INITIALIZE(Content)
ON_CHARDATA(Content)
{
+ int v;
+
// Create the first time we get content
if(!created)
{
@@ -1015,7 +1038,28 @@ ON_CHARDATA(Content)
// Extra elements written out here are consolidated in
// XmlFixups::combineDuplicates
+ // Handle fonts etc...
+ if(DO_EXTRAS())
+ {
+ int font = format.textFont();
+ int fontsize = format.textFontSize();
+
+ if(font != -1 || fontsize != -1)
+ {
+ AN_ELEMENT(kElFont);
+
+ if(font != -1)
+ AN_ATTRIBUTE(kAtId, font);
+
+ if(fontsize != -1)
+ AN_ATTRIBUTE(kAtSize, fontsize);
+
+ elements++;
+ }
+ }
+
// Now do text Properties if necessary
+
if(format.textIsBold())
{
AN_ELEMENT(kElB);
@@ -1046,12 +1090,15 @@ ON_CHARDATA(Content)
elements++;
}
- if(format.textColor() != -1 && m_composer->getOptions().doColors)
- {
- AN_ELEMENT(kElColor);
- AN_ATTRIBUTE(kAtIndex, format.textColor());
- elements++;
- }
+ if(DO_EXTRAS())
+ {
+ if(format.textColor() != -1)
+ {
+ AN_ELEMENT(kElColor);
+ AN_ATTRIBUTE(kAtIndex, format.textColor());
+ elements++;
+ }
+ }
if(format.textSuScript() == RtfFormatting::SUPERSCRIPT)
{
@@ -1091,10 +1138,15 @@ ON_CONTROLWORD(FootNote)
// Inside foot notes there's no link to the foot note
if(cw == "chftn")
{
- DestinationPtr dest = m_composer->getDestination();
- ASSERT(dest != NULL);
- int ac = m_composer->getAutoCount(AUTOCOUNT_FOOTNOTE);
- dest->charData(formatInt(ac));
+ // Only put actual text when in extras mode
+ if(DO_EXTRAS())
+ {
+ DestinationPtr dest = m_composer->getDestination();
+ ASSERT(dest != NULL);
+ int ac = m_composer->getAutoCount(AUTOCOUNT_FOOTNOTE);
+ dest->charData(formatInt(ac));
+ }
+
return;
}