summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rtfformatting.h22
-rw-r--r--src/tags.h4
-rw-r--r--src/xmlcomposer.cpp29
3 files changed, 52 insertions, 3 deletions
diff --git a/src/rtfformatting.h b/src/rtfformatting.h
index db687eb..cab1e4f 100644
--- a/src/rtfformatting.h
+++ b/src/rtfformatting.h
@@ -79,7 +79,8 @@ public:
{
return m_style == format.m_style &&
m_list == format.m_list &&
- m_inTbl == format.m_inTbl;
+ m_inTbl == format.m_inTbl &&
+ m_align == format.m_align;
}
void copy(const RtfFormatting& format)
@@ -99,12 +100,13 @@ public:
m_style = format.m_style;
m_list = format.m_list;
m_inTbl = format.m_inTbl;
+ m_align = format.m_align;
}
void resetText()
{
m_bold = m_italic = m_strike =
- m_underline = m_hidden = false;
+ m_underline = m_hidden = false;
m_color = -1;
m_highlight = -1;
m_suscript = 0;
@@ -117,6 +119,7 @@ public:
{
m_style = m_list = -1;
m_inTbl = false;
+ m_align = LEFT;
}
bool textIsBold() const
@@ -147,6 +150,8 @@ public:
{ return m_list; }
bool paraInTable() const
{ return m_inTbl; }
+ int paraAlign() const
+ { return m_align; }
void textSetBold(bool bold)
{ m_bold = bold; }
@@ -176,6 +181,8 @@ public:
{ m_list = list; }
void paraSetTable(bool inTable)
{ m_inTbl = inTable; }
+ void paraSetAlign(int align)
+ { m_align = align; }
enum
{
@@ -183,13 +190,21 @@ public:
SUBSCRIPT
};
+ enum
+ {
+ LEFT = 0,
+ CENTER,
+ RIGHT,
+ JUSTIFY
+ };
+
protected:
bool m_bold;
bool m_italic;
bool m_strike;
bool m_underline;
bool m_hidden;
- int m_suscript;
+ int m_suscript;
int m_color;
int m_highlight;
int m_font;
@@ -199,6 +214,7 @@ protected:
int m_style;
int m_list;
bool m_inTbl;
+ int m_align;
};
#endif // __RTFFORMATTING_H__
diff --git a/src/tags.h b/src/tags.h
index fca0e89..a1638ca 100644
--- a/src/tags.h
+++ b/src/tags.h
@@ -105,6 +105,7 @@ static const char* kAtId = "id";
static const char* kAtTo = "to";
static const char* kAtSize = "size";
static const char* kAtHref = "href";
+static const char* kAtAlign = "align";
// Values
static const char* kValDisc = "disc";
@@ -120,5 +121,8 @@ static const char* kValPara = "para";
static const char* kValTable = "table";
static const char* kValTrue = "true";
static const char* kValZero = "0";
+static const char* kValCenter = "center";
+static const char* kValRight = "right";
+static const char* kValJustify = "justify";
#endif // __TAGS_H__
diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp
index aa7485f..2f0a5ee 100644
--- a/src/xmlcomposer.cpp
+++ b/src/xmlcomposer.cpp
@@ -382,6 +382,19 @@ void XmlComposer::BaseAnalyser::applyParaFormatting(RtfFormatting* format,
else
el.removeAttribute(kElStyle);
+ switch(format->paraAlign())
+ {
+ case RtfFormatting::CENTER:
+ el.setAttribute(kAtAlign, kValCenter);
+ break;
+ case RtfFormatting::RIGHT:
+ el.setAttribute(kAtAlign, kValRight);
+ break;
+ case RtfFormatting::JUSTIFY:
+ el.setAttribute(kAtAlign, kValJustify);
+ break;
+ };
+
// These fix elements are later picked up in XmlFixups::fixBlocks
el.setAttribute(kAtFix, fix);
}
@@ -452,6 +465,22 @@ bool XmlComposer::BaseAnalyser::processTextContent(const string& cw, int flags,
else if(cw == "s" && HAS_PARAM)
format.paraSetStyle(param);
+ // Left para alignment
+ else if(cw == "ql")
+ format.paraSetAlign(RtfFormatting::LEFT);
+
+ // Center para alignment
+ else if(cw == "qc")
+ format.paraSetAlign(RtfFormatting::CENTER);
+
+ // Right para alignment
+ else if(cw == "qr")
+ format.paraSetAlign(RtfFormatting::RIGHT);
+
+ // Justify para alignment
+ else if(cw == "qj")
+ format.paraSetAlign(RtfFormatting::JUSTIFY);
+
// A line break
else if(cw == "line")
el = m_composer->createElement(kElLine);