diff options
-rw-r--r-- | .cvsignore | 5 | ||||
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | doc/rtfx.xsd | 18 | ||||
-rw-r--r-- | src/rtfformatting.h | 12 | ||||
-rw-r--r-- | src/tags.h | 1 | ||||
-rw-r--r-- | src/xmlcomposer.cpp | 34 | ||||
-rw-r--r-- | src/xmlfixups.cpp | 15 |
8 files changed, 76 insertions, 16 deletions
@@ -19,5 +19,8 @@ stamp-* *.tar.gz .project .cdtproject - rtfx-* +*.pws +*.bak +*.prj +*.rtf @@ -1,3 +1,6 @@ +Version 0.9.6 + - Add character styles + Version 0.9.5 - Allow conversions on stdin and stdout - Fixed build problem with GCC 3.4 diff --git a/configure.in b/configure.in index 3ce26de..fe3ace8 100644 --- a/configure.in +++ b/configure.in @@ -36,8 +36,8 @@ dnl Nate Nielsen <nielsen@memberwebs.com> dnl dnl Process this file with autoconf to produce a configure script. -AC_INIT(rtfx, 0.9.5, nielsen@memberwebs.com) -AM_INIT_AUTOMAKE(rtfx, 0.9.5) +AC_INIT(rtfx, 0.9.5.90, nielsen@memberwebs.com) +AM_INIT_AUTOMAKE(rtfx, 0.9.5.90) LDFLAGS="$LDFLAGS -L/usr/local/lib" CPPFLAGS="$CPPFLAGS -I/usr/local/include" diff --git a/doc/rtfx.xsd b/doc/rtfx.xsd index 922b0a6..a0a209d 100644 --- a/doc/rtfx.xsd +++ b/doc/rtfx.xsd @@ -365,6 +365,7 @@ <xs:element ref="sub"/> <xs:element ref="ref"/> <xs:element ref="font"/> + <xs:element ref="span"/> </xs:choice> </xs:group> @@ -482,5 +483,22 @@ </xs:complexType> </xs:element> + <xs:element name="span"> + <xs:annotation> + <xs:documentation>A portion of content with a given style, or attributes.</xs:documentation> + </xs:annotation> + + <xs:complexType mixed="true"> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:group ref="inline"/> + </xs:choice> + <xs:attribute name="style" type="xs:string" use="optional"> + <xs:annotation> + <xs:documentation>Style name for the content.</xs:documentation> + </xs:annotation> + </xs:attribute> + + </xs:complexType> + </xs:element> </xs:schema> diff --git a/src/rtfformatting.h b/src/rtfformatting.h index aa5ac58..3085198 100644 --- a/src/rtfformatting.h +++ b/src/rtfformatting.h @@ -70,7 +70,8 @@ public: m_color == format.m_color && m_suscript == format.m_suscript && m_font == format.m_font && - m_fsize == format.m_fsize; + m_fsize == format.m_fsize && + m_charstyle == format.m_charstyle; } bool paraEquals(RtfFormatting& format) const @@ -91,6 +92,7 @@ public: m_suscript = format.m_suscript; m_font = format.m_font; m_fsize = format.m_fsize; + m_charstyle = format.m_charstyle; m_style = format.m_style; m_list = format.m_list; @@ -105,6 +107,7 @@ public: m_suscript = 0; m_fsize = -1; m_font = -1; + m_charstyle = -1; } void resetPara() @@ -131,6 +134,8 @@ public: { return m_font; } int textFontSize() const { return m_fsize; } + int textStyle() + { return m_charstyle; } int paraStyle() const { return m_style; } int paraList() const @@ -156,6 +161,8 @@ public: { m_font = font; } void textSetFontSize(int fsize) { m_fsize = fsize == 24 ? -1 : fsize; } // default font size is always 24 + void textSetStyle(int style) + { m_charstyle = style; } void paraSetStyle(int style) { m_style = style; } void paraSetList(int list) @@ -179,12 +186,11 @@ protected: int m_color; int m_font; int m_fsize; + int m_charstyle; int m_style; int m_list; bool m_inTbl; - - // TODO: Character styles }; #endif // __RTFFORMATTING_H__ @@ -65,6 +65,7 @@ static const char* kElTab = "tab"; static const char* kElSect = "sect"; static const char* kElPage = "page"; static const char* kElStyle = "style"; +static const char* kElSpan = "span"; static const char* kElLine = "line"; static const char* kElList = "list"; static const char* kElStylesheet = "stylesheet"; diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index 93bd8f3..10b476f 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -525,6 +525,8 @@ bool XmlComposer::BaseAnalyser::processTextFormatting(const string& cw, int flag format.textSetFont(param); else if(cw == "fs" && HAS_PARAM) format.textSetFontSize(param); + else if(cw == "cs" && HAS_PARAM) + format.textSetStyle(param); else return false; @@ -640,8 +642,16 @@ ON_INITIALIZE(Style) ON_CONTROLWORD(Style) { - // Get the style id - if(flags & kAsterisk) + bool use = false; + + // The style id + if((cw == "s" && (flags & kHasParam)) || + (cw == "cs" && (flags & kAsterisk) && (flags & kHasParam))) + { + use = true; + } + + else if (flags & kAsterisk) { AN_ANALYSER(Skip); return; @@ -655,18 +665,19 @@ ON_CONTROLWORD(Style) haveStyle = true; } - // The style id - if(cw == "s" && flags & kHasParam) + if (use) { AN_ATTRIBUTE(kAtId, param); } // Otherwise get as much formatting out of the tag as possible - else if(processTextFormatting(cw, flags, param)) - DUMMY; - else - DEFAULT_CONTROLWORD; + { + if(processTextFormatting(cw, flags, param)) + DUMMY; + else + DEFAULT_CONTROLWORD; + } } ON_GROUPSTART(Style) @@ -1081,6 +1092,13 @@ ON_CHARDATA(Content) } } + if(format.textStyle() != -1) + { + AN_ELEMENT(kElSpan); + AN_ATTRIBUTE(kElStyle, format.textStyle()); + elements++; + } + // Now do text Properties if necessary if(format.textIsBold()) diff --git a/src/xmlfixups.cpp b/src/xmlfixups.cpp index eb6fcb7..458798a 100644 --- a/src/xmlfixups.cpp +++ b/src/xmlfixups.cpp @@ -42,10 +42,10 @@ #include "tags.h" static const char* kNoDuplicates[] = - { kElB, kElU, kElI, kElFont, kElHide, kElSuper, kElSub, NULL }; + { kElB, kElU, kElI, kElFont, kElHide, kElSuper, kElSub, kElSpan, NULL }; static const char* kRequireAttrs[] = - { kElFont, NULL }; + { kElFont, kElSpan, NULL }; static const char* kRemoveTags[] = { kElDest, kElListdef, kElListtable, kElFontTable, kElFontDef, NULL }; @@ -503,6 +503,17 @@ void XmlFixups::runPassTwo(const DOM::Document& doc) continue; // Current element no longer valid } + else if(name == kElSpan) + { + // Change style attribute on spans to name + if(haveStyles && el.hasAttribute(kElStyle)) + { + DOM::Element style = styles.get(el.getAttribute(kElStyle)); + if(style != NULL) + el.setAttribute(kElStyle, style.getAttribute(kAtName)); + } + } + // Change id attribute on fonts to name if(haveFonts && name == kElFont) { |