summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2005-06-07 23:19:51 +0000
committerStef Walter <stef@memberwebs.com>2005-06-07 23:19:51 +0000
commit651b7adf13ebc575b4685254c675cc7d35b7fbed (patch)
treeb0f635a5d8b78a78fa8b1d0f6fa7c246b5578ecb
parent56f7f66eb13eefb3ea86e9280e321751d8df2761 (diff)
Add 'align' attribute to <para> tag for paragraph alignment.
-rw-r--r--ChangeLog1
-rw-r--r--doc/rtfx.xsd5
-rw-r--r--src/rtfformatting.h22
-rw-r--r--src/tags.h4
-rw-r--r--src/xmlcomposer.cpp29
5 files changed, 58 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e457460..ae94e22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@ Version 0.9.6
- Add character styles
- Add <highlight> tag for highlighted text
- Add <link> tag for hyperlink fields
+ - Add 'align' attribute to <para> tags for paragraph alignment
Version 0.9.5
- Allow conversions on stdin and stdout
diff --git a/doc/rtfx.xsd b/doc/rtfx.xsd
index 2efbe90..70e981d 100644
--- a/doc/rtfx.xsd
+++ b/doc/rtfx.xsd
@@ -250,6 +250,11 @@
<xs:documentation>The paragraph style name.</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute name="align" type="xs:string" default="left">
+ <xs:annotation>
+ <xs:documentation>The paragraph alignment. Either 'left', 'center', 'right' or 'justify'</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
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);