diff options
author | Stef <stef@ws.local> | 2004-07-24 00:45:18 +0000 |
---|---|---|
committer | Stef <stef@ws.local> | 2004-07-24 00:45:18 +0000 |
commit | ad2094feff861802c0d44ab3f5dbaf8e480866e8 (patch) | |
tree | 5f921032e9289e7376aea30750f05578ca440852 | |
parent | 497e93e4b335aafd983aa7019abc29788edb0e3e (diff) |
- More work on font support
- Addition of extras mode to XmlComposer
-rw-r--r-- | src/rtfformatting.h | 18 | ||||
-rw-r--r-- | src/tags.h | 1 | ||||
-rw-r--r-- | src/xmlcomposer.cpp | 140 | ||||
-rw-r--r-- | src/xmlcomposer.h | 2 |
4 files changed, 115 insertions, 46 deletions
diff --git a/src/rtfformatting.h b/src/rtfformatting.h index b718245..f2d0581 100644 --- a/src/rtfformatting.h +++ b/src/rtfformatting.h @@ -68,7 +68,9 @@ public: m_hidden == format.m_hidden && m_underline == format.m_underline && m_color == format.m_color && - m_suscript == format.m_suscript; + m_suscript == format.m_suscript && + m_font == format.m_font && + m_fsize == format.m_fsize; } bool paraEquals(RtfFormatting& format) const @@ -87,6 +89,8 @@ public: m_underline = format.m_underline; m_color = format.m_color; m_suscript = format.m_suscript; + m_font = format.m_font; + m_fsize = format.m_fsize; m_style = format.m_style; m_list = format.m_list; @@ -99,6 +103,8 @@ public: m_underline = m_hidden = false; m_color = -1; m_suscript = 0; + m_fsize = -1; + m_font = -1; } void resetPara() @@ -121,6 +127,10 @@ public: { return m_color; } int textSuScript() const { return m_suscript; } + int textFont() const + { return m_font; } + int textFontSize() const + { return m_fsize; } int paraStyle() const { return m_style; } int paraList() const @@ -142,6 +152,10 @@ public: { m_color = color; } void textSetSuScript(int suscript) { m_suscript = suscript; } + void textSetFont(int font) + { m_font = font; } + void textSetFontSize(int fsize) + { m_fsize = fsize; } void paraSetStyle(int style) { m_style = style; } void paraSetList(int list) @@ -163,6 +177,8 @@ protected: bool m_hidden; int m_suscript; int m_color; + int m_font; + int m_fsize; int m_style; int m_list; @@ -94,6 +94,7 @@ static const char* kAtStart = "start"; static const char* kAtId = "id"; static const char* kAtIndex = "id"; static const char* kAtTo = "to"; +static const char* kAtSize = "size"; // Values static const wchar_t* kValDisc = L"disc"; diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index cce87d4..cb1bf16 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -330,7 +330,7 @@ void XmlComposer::incrementAutoCount(int type) #define DEFAULT_CONTROLWORD processDefault(cw, flags, param) #define DUMMY 1 == 1 #define NUM_ATTR(x) formatInt(x) - +#define DO_EXTRAS() (m_composer->GetOptions().extras) /* ---------------------------------------------------------------------------------- * BASE ANALYSER @@ -512,12 +512,16 @@ bool XmlComposer::BaseAnalyser::processTextFormatting(const string& cw, int flag format.textSetHidden(on); else if(cw == "ul") format.textSetUnderline(on); - else if(cw == "cf" && HAS_PARAM) - format.textSetColor(param); else if(cw == "super") format.textSetSuScript(RtfFormatting::SUPERSCRIPT); else if(cw == "sub") format.textSetSuScript(RtfFormatting::SUBSCRIPT); + else if(cw == "cf" && HAS_PARAM) + format.textSetColor(param); + else if(cw == "f" && HAS_PARAM) + format.textSetFont(param); + else if(cw == "fs" && HAS_PARAM) + format.textSetFontSize(param); else return false; @@ -536,6 +540,7 @@ bool XmlComposer::BaseAnalyser::processTextAutoContent(const string& cw, int fla dest->charData(kValNull); // Auto generated content + if(cw == "chftn") { // Footnote auto numbering @@ -544,7 +549,11 @@ bool XmlComposer::BaseAnalyser::processTextAutoContent(const string& cw, int fla AN_ELEMENT(kElRef); AN_ATTRIBUTE(kAtType, kValFootNote); AN_ATTRIBUTE(kAtTo, ac); - dest->charData(formatInt(ac)); + + // Only output the actual link text in this case + if(DO_EXTRAS()) + dest->charData(formatInt(ac)); + AN_POP_ELEMENT(); return true; } @@ -677,8 +686,14 @@ ON_GROUPEND(Style) AN_ATTRIBUTE(kAtStrike, L"1"); if(props.textIsUnderline()) AN_ATTRIBUTE(kAtUnderline, L"1"); - if(props.textColor() != -1 && m_composer->getOptions().doColors) - AN_ATTRIBUTE(kAtColor, props.textColor()); + + if(DO_EXTRAS()) + { + // TODO: Do fonts here + + if(props.textColor() != -1) + AN_ATTRIBUTE(kAtColor, props.textColor()); + } } @@ -687,15 +702,13 @@ ON_GROUPEND(Style) ON_INITIALIZE(FontTable) { AN_ELEMENT(kElFontTable); + AN_DESTINATION(Null); } ON_GROUPSTART(FontTable) { // Each group should be a style AN_ANALYSER(Font); - - // Without any character data - AN_DESTINATION(Null); } @@ -768,30 +781,33 @@ ON_CONTROLWORD(List) // The list type else if(cw == "levelnfc" && HAS_PARAM) { - switch(param) - { - case 0: // 1, 2, 3 - case 5: // 1st, 2nd, 3rd - case 6: // One, Two, Three - case 7: // First, Second, Third - case 22: // 01, 02, 03 - AN_ATTRIBUTE(kAtType, kValArabic); - break; - case 1: // I, II, III - AN_ATTRIBUTE(kAtType, kValUpperRoman); - break; - case 2: // i, ii, iii - AN_ATTRIBUTE(kAtType, kValLowerRoman); - break; - case 3: // A, B, C - AN_ATTRIBUTE(kAtType, kValUpperAlpha); - break; - case 4: // a, b, c - AN_ATTRIBUTE(kAtType, kValLowerAlpha); - break; - default: - AN_ATTRIBUTE(kAtType, kValDisc); - break; + if(DO_EXTRAS()) + { + switch(param) + { + case 0: // 1, 2, 3 + case 5: // 1st, 2nd, 3rd + case 6: // One, Two, Three + case 7: // First, Second, Third + case 22: // 01, 02, 03 + AN_ATTRIBUTE(kAtType, kValArabic); + break; + case 1: // I, II, III + AN_ATTRIBUTE(kAtType, kValUpperRoman); + break; + case 2: // i, ii, iii + AN_ATTRIBUTE(kAtType, kValLowerRoman); + break; + case 3: // A, B, C + AN_ATTRIBUTE(kAtType, kValUpperAlpha); + break; + case 4: // a, b, c + AN_ATTRIBUTE(kAtType, kValLowerAlpha); + break; + default: + AN_ATTRIBUTE(kAtType, kValDisc); + break; + } } switch(param) @@ -959,7 +975,12 @@ ON_CONTROLWORD(Root) else if(cw == "info") AN_ANALYSER(Info); else if(cw == "fonttbl") - AN_ANALYSER(FontTable); + { + if(DO_EXTRAS()) + AN_ANALYSER(FontTable); + else + AN_ANALYSER(Skip); + } else if(cw == "colortbl") AN_ANALYSER(Skip); else if(cw == "footnote") @@ -992,6 +1013,8 @@ ON_INITIALIZE(Content) ON_CHARDATA(Content) { + int v; + // Create the first time we get content if(!created) { @@ -1015,7 +1038,28 @@ ON_CHARDATA(Content) // Extra elements written out here are consolidated in // XmlFixups::combineDuplicates + // Handle fonts etc... + if(DO_EXTRAS()) + { + int font = format.textFont(); + int fontsize = format.textFontSize(); + + if(font != -1 || fontsize != -1) + { + AN_ELEMENT(kElFont); + + if(font != -1) + AN_ATTRIBUTE(kAtId, font); + + if(fontsize != -1) + AN_ATTRIBUTE(kAtSize, fontsize); + + elements++; + } + } + // Now do text Properties if necessary + if(format.textIsBold()) { AN_ELEMENT(kElB); @@ -1046,12 +1090,15 @@ ON_CHARDATA(Content) elements++; } - if(format.textColor() != -1 && m_composer->getOptions().doColors) - { - AN_ELEMENT(kElColor); - AN_ATTRIBUTE(kAtIndex, format.textColor()); - elements++; - } + if(DO_EXTRAS()) + { + if(format.textColor() != -1) + { + AN_ELEMENT(kElColor); + AN_ATTRIBUTE(kAtIndex, format.textColor()); + elements++; + } + } if(format.textSuScript() == RtfFormatting::SUPERSCRIPT) { @@ -1091,10 +1138,15 @@ ON_CONTROLWORD(FootNote) // Inside foot notes there's no link to the foot note if(cw == "chftn") { - DestinationPtr dest = m_composer->getDestination(); - ASSERT(dest != NULL); - int ac = m_composer->getAutoCount(AUTOCOUNT_FOOTNOTE); - dest->charData(formatInt(ac)); + // Only put actual text when in extras mode + if(DO_EXTRAS()) + { + DestinationPtr dest = m_composer->getDestination(); + ASSERT(dest != NULL); + int ac = m_composer->getAutoCount(AUTOCOUNT_FOOTNOTE); + dest->charData(formatInt(ac)); + } + return; } diff --git a/src/xmlcomposer.h b/src/xmlcomposer.h index e14ecb7..e73c032 100644 --- a/src/xmlcomposer.h +++ b/src/xmlcomposer.h @@ -46,7 +46,7 @@ struct XmlComposerOptions XmlComposerOptions() { memset(this, 0, sizeof(*this)); } - bool doColors; + bool extras; }; /* |