From 182ccac47d8bb9b0c04078a893b31f99d31c9654 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 8 Jun 2005 17:50:40 +0000 Subject: Fix problem with certain paragraph attributes leaking into adjacent paras. --- src/xmlcomposer.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/xmlcomposer.cpp') diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index 6b1b725..f94ce29 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -364,6 +364,13 @@ void XmlComposer::BaseAnalyser::applyParaFormatting(RtfFormatting* format, if(format == NULL) format = &(m_composer->getTextFormatting()); + /* + * NOTE: All attributes set in this method must be reversible + * by calling again with different formatting. This is called + * multiple times per paragraph. Once when the paragraph is + * created, and again after the formatting has been finalized. + */ + string fix = kValPara; // Is it a list? @@ -391,6 +398,9 @@ void XmlComposer::BaseAnalyser::applyParaFormatting(RtfFormatting* format, // Paragraph alignment switch(format->paraAlign()) { + case RtfFormatting::LEFT: + el.removeAttribute(kAtAlign); + break; case RtfFormatting::CENTER: el.setAttribute(kAtAlign, kValCenter); break; @@ -403,7 +413,9 @@ void XmlComposer::BaseAnalyser::applyParaFormatting(RtfFormatting* format, }; // Paragraph left indent - if(format->paraIndent() != 0) + if(format->paraIndent() == 0) + el.removeAttribute(kAtIndent); + else el.setAttribute(kAtIndent, formatInt(format->paraIndent())); } @@ -439,6 +451,10 @@ bool XmlComposer::BaseAnalyser::processTextContent(const string& cw, int flags, applyParaFormatting(&format, el); } + // Clears all paragraph formatting + if(cw == "pard") + format.resetPara(); + // Cells (used later in applyParaFormatting) else if(cw == "intbl") format.paraSetTable(true); @@ -544,10 +560,7 @@ bool XmlComposer::BaseAnalyser::processTextFormatting(const string& cw, int flag // Clears all paragraph formatting if(cw == "pard") - { format.resetPara(); - // applyParaFormatting(); - } // Rest are pretty much self-explanatory else if(cw == "plain") -- cgit v1.2.3