From 651b7adf13ebc575b4685254c675cc7d35b7fbed Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 7 Jun 2005 23:19:51 +0000 Subject: Add 'align' attribute to tag for paragraph alignment. --- ChangeLog | 1 + doc/rtfx.xsd | 5 +++++ src/rtfformatting.h | 22 +++++++++++++++++++--- src/tags.h | 4 ++++ src/xmlcomposer.cpp | 29 +++++++++++++++++++++++++++++ 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 tag for highlighted text - Add tag for hyperlink fields + - Add 'align' attribute to 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 @@ The paragraph style name. + + + The paragraph alignment. Either 'left', 'center', 'right' or 'justify' + + 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); -- cgit v1.2.3