summaryrefslogtreecommitdiff
path: root/src/xmlcomposer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmlcomposer.cpp')
-rw-r--r--src/xmlcomposer.cpp64
1 files changed, 41 insertions, 23 deletions
diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp
index 398cb55..a90c25a 100644
--- a/src/xmlcomposer.cpp
+++ b/src/xmlcomposer.cpp
@@ -111,13 +111,18 @@ void XmlComposer::startDocument(RtfParser* reader)
ASSERT(m_document != NULL);
// Hook up the top level element
- m_curLevel->setElement(m_document.getDocumentElement(), true);
+ DOM::Element top = m_document.getDocumentElement();
+ m_curLevel->setElement(top, true);
// Set the attributes on the top level
setAnalyser(AnalyserPtr(new Root));
setDestination(DestinationPtr(new Content));
getTextFormatting().resetPara();
getTextFormatting().resetText();
+
+ // Create the options element
+ m_docOptions = m_document.createElement(kElOptions);
+ top.appendChild(m_docOptions);
}
void XmlComposer::endDocument()
@@ -151,6 +156,11 @@ void XmlComposer::endDocument()
// Pass 3: Final cleanup
// XmlFixups::combineDuplicates(m_document);
+
+ DOM::Element top = m_document.getDocumentElement();
+ ASSERT(top != NULL);
+ top.setAttribute(kNSPrefix, kNSRtfx);
+
return;
}
@@ -323,6 +333,12 @@ void XmlComposer::incrementAutoCount(int type)
m_autocount[type]++;
}
+void XmlComposer::addDocumentOption(DOM::Element& option)
+{
+ ASSERT(m_docOptions != NULL);
+ m_docOptions.appendChild(option);
+}
+
/* ----------------------------------------------------------------------------------
* CONVENIENCE MACROS USED BELOW
@@ -694,23 +710,17 @@ ON_GROUPEND(Style)
// Dig out all the formatting attributes
if(props.textIsBold())
- AN_ATTRIBUTE(kAtBold, L"1");
+ AN_ATTRIBUTE(kAtBold, kValTrue);
if(props.textIsHidden())
- AN_ATTRIBUTE(kAtHidden, L"1");
+ AN_ATTRIBUTE(kAtHidden, kValTrue);
if(props.textIsItalic())
- AN_ATTRIBUTE(kAtItalic, L"1");
+ AN_ATTRIBUTE(kAtItalic, kValTrue);
if(props.textIsStrike())
- AN_ATTRIBUTE(kAtStrike, L"1");
+ AN_ATTRIBUTE(kAtStrike, kValTrue);
if(props.textIsUnderline())
- AN_ATTRIBUTE(kAtUnderline, L"1");
+ AN_ATTRIBUTE(kAtUnderline, kValTrue);
- if(DO_EXTRAS())
- {
- // TODO: Do fonts here
-
- if(props.textColor() != -1)
- AN_ATTRIBUTE(kAtColor, props.textColor());
- }
+ // TODO: Do fonts and colors here
}
@@ -728,6 +738,21 @@ ON_GROUPSTART(FontTable)
AN_ANALYSER(Font);
}
+ON_DONE(FontTable)
+{
+ DOM::Element deffont = m_composer->createElement(kElFont);
+
+ // Default font is always the first in the list
+ deffont->setAttribute(kAtId, kValZero);
+
+ // Default size is always 12 pt
+ deffont->setAttribute(kAtSize, L"12");
+
+ // TODO: Is this correct?
+ deffont->setAttribute(kAtColor, kValZero);
+
+ m_composer->addDocumentOption(deffont);
+}
// Font Analyser --------------------------------------------------------------------
@@ -1072,6 +1097,9 @@ ON_CHARDATA(Content)
if(fontsize != -1)
AN_ATTRIBUTE(kAtSize, fontsize);
+ if(format.textColor() != -1)
+ AN_ATTRIBUTE(kAtColor, format.textColor());
+
elements++;
}
}
@@ -1108,16 +1136,6 @@ ON_CHARDATA(Content)
elements++;
}
- if(DO_EXTRAS())
- {
- if(format.textColor() != -1)
- {
- AN_ELEMENT(kElColor);
- AN_ATTRIBUTE(kAtIndex, format.textColor());
- elements++;
- }
- }
-
if(format.textSuScript() == RtfFormatting::SUPERSCRIPT)
{
AN_ELEMENT(kElSuper);