summaryrefslogtreecommitdiff
path: root/src/xmlcomposer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmlcomposer.cpp')
-rw-r--r--src/xmlcomposer.cpp79
1 files changed, 23 insertions, 56 deletions
diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp
index c856d2d..e642acb 100644
--- a/src/xmlcomposer.cpp
+++ b/src/xmlcomposer.cpp
@@ -43,18 +43,12 @@
#include "tags.h"
-wstring formatInt(int num)
+string formatInt(int num)
{
- char buff[16];
-
// Certain OSs don't support swprintf :(
+ char buff[16];
sprintf(buff, "%d", num);
-
- wstring n;
- for(char* s = buff; *s; s++)
- n.append(1, *s);
-
- return n;
+ return string(buff);
}
/* ----------------------------------------------------------------------------------
@@ -74,23 +68,11 @@ XmlComposer::XmlComposer(const XmlComposerOptions& options)
XmlComposer::~XmlComposer()
{
clear();
-
- if(m_impl != NULL)
- m_impl.release();
}
void XmlComposer::clear()
{
- if(m_document != NULL)
- {
- try
- {
- m_document.release();
- }
- catch(...) { }
-
- m_document = NULL;
- }
+ m_document = NULL;
LevelHandler::clear();
}
@@ -131,32 +113,17 @@ void XmlComposer::endDocument()
XmlFixups fix;
- // Pass 0: Cleanup the tree
- // XmlFixups::combineDuplicates(m_document);
- // XmlFixups::consolidateStartTags(m_document);
- // XmlFixups::consolidateEndTags(m_document);
-
// Pass 1: Block breakout
- fix.breakTables(m_document);
+ /* fix.breakTables(m_document);
fix.breakTags(m_document, kElTable, kElRow);
fix.breakTags(m_document, kElRow, kElCell);
fix.wrapTags(m_document, kElCell, kElDest);
fix.breakBlocks(m_document);
- fix.breakLists(m_document);
+ fix.breakLists(m_document); */
// Pass 2: Fixups
fix.runPassTwo(m_document);
- // XmlFixups::fixLists(m_document);
- // XmlFixups::fixStyles(m_document);
- // XmlFixups::fixBlocks(m_document);
- // XmlFixups::removeTags(m_document);
- // XmlFixups::breakBreak(m_document, kElDoc, kElPage);
- // XmlFixups::breakBreak(m_document, kElDoc, kElSect);
-
- // Pass 3: Final cleanup
- // XmlFixups::combineDuplicates(m_document);
-
DOM::Element top = m_document.getDocumentElement();
ASSERT(top != NULL);
top.setAttribute(kNSPrefix, kNSRtfx);
@@ -164,7 +131,7 @@ void XmlComposer::endDocument()
return;
}
-void XmlComposer::charData(wstring data)
+void XmlComposer::charData(const string& data)
{
ASSERT(m_curLevel != NULL);
DestinationPtr destination = m_curLevel->getDestination();
@@ -255,7 +222,7 @@ DOM::Element XmlComposer::popElement()
return element;
}
-void XmlComposer::setAttribute(const string& name, const wstring& value, DOM::Element el)
+void XmlComposer::setAttribute(const string& name, const string& value, DOM::Element el)
{
ASSERT(name.length() > 0);
if(el == NULL)
@@ -390,7 +357,7 @@ void XmlComposer::BaseAnalyser::applyParaFormatting(RtfFormatting* format,
if(format == NULL)
format = &(m_composer->getTextFormatting());
- wstring fix = kValPara;
+ string fix = kValPara;
// Is it a list?
int list = format->paraList();
@@ -401,7 +368,7 @@ void XmlComposer::BaseAnalyser::applyParaFormatting(RtfFormatting* format,
// Is it a cell?
if(format->paraInTable())
- el.setAttribute(kAtCell, L"1");
+ el.setAttribute(kAtCell, "1");
else
el.removeAttribute(kAtCell);
@@ -603,7 +570,7 @@ bool XmlComposer::BaseAnalyser::processTextAutoContent(const string& cw, int fla
#define ON_CONTROLWORD(cls) \
void XmlComposer::cls::controlWord(const string& cw, int flags, int param)
#define ON_CHARDATA(cls) \
- void XmlComposer::cls::charData(wstring data)
+ void XmlComposer::cls::charData(const string& data)
#define ON_GROUPSTART(cls) \
void XmlComposer::cls::groupStart()
#define ON_GROUPEND(cls) \
@@ -746,7 +713,7 @@ ON_DONE(FontTable)
deffont->setAttribute(kAtId, kValZero);
// Default size is always 12 pt
- deffont->setAttribute(kAtSize, L"12");
+ deffont->setAttribute(kAtSize, "12");
// TODO: Is this correct?
deffont->setAttribute(kAtColor, kValZero);
@@ -805,7 +772,7 @@ ON_INITIALIZE(List)
if(DO_EXTRAS())
AN_ATTRIBUTE(kAtType, kValDisc);
- AN_ATTRIBUTE(kAtOrdered, L"0");
+ AN_ATTRIBUTE(kAtOrdered, "0");
levelsSeen = 0;
}
@@ -859,10 +826,10 @@ ON_CONTROLWORD(List)
{
case 0: case 5: case 6: case 7: case 22:
case 1: case 2: case 3: case 4:
- AN_ATTRIBUTE(kAtOrdered, L"1");
+ AN_ATTRIBUTE(kAtOrdered, "1");
break;
default:
- AN_ATTRIBUTE(kAtOrdered, L"0");
+ AN_ATTRIBUTE(kAtOrdered, "0");
}
}
@@ -907,7 +874,7 @@ ON_CONTROLWORD(ListOverrideTable)
// List id for current listoverride
else if(cw == "listid" && HAS_PARAM)
{
- wstring id = formatInt(param);
+ string id = formatInt(param);
if(lists != NULL)
{
@@ -1097,9 +1064,9 @@ ON_CHARDATA(Content)
if(fontsize != -1)
{
// Little hack for half point sizes
- wstring size = NUM_ATTR(fontsize / 2);
+ string size = NUM_ATTR(fontsize / 2);
if(fontsize % 2)
- size.append(L".5");
+ size.append(".5");
AN_ATTRIBUTE(kAtSize, size);
}
@@ -1231,13 +1198,13 @@ ON_INITIALIZE(Attribute)
ON_CHARDATA(Attribute)
{
// Get the current value
- wstring cur = element.getAttribute(name);
+ string cur = element.getAttribute(name);
+ // Append data
if(data.at(data.size() - 1) == L';')
- data.resize(data.size() - 1);
-
- // Append data
- cur.append(data);
+ cur.append(data.substr(data.size() - 1));
+ else
+ cur.append(data);
// Write it back
element.setAttribute(name, cur);