00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "FilterInternal.hxx"
00032 #include "TextRunStyle.hxx"
00033 #include "WriterProperties.hxx"
00034 #include "DocumentElement.hxx"
00035
00036 #ifdef _MSC_VER
00037 #include <minmax.h>
00038 #endif
00039
00040 ParagraphStyle::ParagraphStyle(WPXPropertyList *pPropList, const WPXPropertyListVector &xTabStops, const WPXString &sName) :
00041 mpPropList(pPropList),
00042 mxTabStops(xTabStops),
00043 msName(sName)
00044 {
00045 }
00046
00047 ParagraphStyle::~ParagraphStyle()
00048 {
00049 delete mpPropList;
00050 }
00051
00052 void ParagraphStyle::write(DocumentHandler &xHandler) const
00053 {
00054 WRITER_DEBUG_MSG(("Writing a paragraph style..\n"));
00055
00056 WPXPropertyList propList;
00057 propList.insert("style:name", msName.cstr());
00058 propList.insert("style:family", "paragraph");
00059 propList.insert("style:parent-style-name", (*mpPropList)["style:parent-style-name"]->getStr());
00060 if ((*mpPropList)["style:master-page-name"])
00061 propList.insert("style:master-page-name", (*mpPropList)["style:master-page-name"]->getStr());
00062 xHandler.startElement("style:style", propList);
00063
00064 propList.clear();
00065 WPXPropertyList::Iter i((*mpPropList));
00066 for (i.rewind(); i.next(); )
00067 {
00068 if (strcmp(i.key(), "style:list-style-name") == 0)
00069 propList.insert("style:list-style-name", i()->getStr());
00070 if (strcmp(i.key(), "fo:margin-left") == 0)
00071 propList.insert("fo:margin-left", i()->getStr());
00072 if (strcmp(i.key(), "fo:margin-right") == 0)
00073 propList.insert("fo:margin-right", i()->getStr());
00074 if (strcmp(i.key(), "fo:text-indent") == 0)
00075 propList.insert("fo:text-indent", i()->getStr());
00076 if (strcmp(i.key(), "fo:margin-top") == 0)
00077 propList.insert("fo:margin-top", i()->getStr());
00078 if (strcmp(i.key(), "fo:margin-bottom") == 0)
00079 propList.insert("fo:margin-bottom", i()->getStr());
00080 if (strcmp(i.key(), "fo:line-height") == 0)
00081 propList.insert("fo:line-height", i()->getStr());
00082 if (strcmp(i.key(), "fo:break-before") == 0)
00083 propList.insert("fo:break-before", i()->getStr());
00084 if (strcmp(i.key(), "fo:text-align") == 0)
00085 propList.insert("fo:text-align", i()->getStr());
00086 if (strcmp(i.key(), "fo:text-align-last") == 0)
00087 propList.insert("fo:text-align-last", i()->getStr());
00088 }
00089
00090 propList.insert("style:justify-single-word", "false");
00091 xHandler.startElement("style:properties", propList);
00092
00093 if (mxTabStops.count() > 0)
00094 {
00095 TagOpenElement tabListOpen("style:tab-stops");
00096 tabListOpen.write(xHandler);
00097 WPXPropertyListVector::Iter i(mxTabStops);
00098 for (i.rewind(); i.next();)
00099 {
00100 TagOpenElement tabStopOpen("style:tab-stop");
00101
00102 WPXPropertyList::Iter j(i());
00103 for (j.rewind(); j.next(); )
00104 {
00105 tabStopOpen.addAttribute(j.key(), j()->getStr().cstr());
00106 }
00107 tabStopOpen.write(xHandler);
00108 xHandler.endElement("style:tab-stop");
00109 }
00110 xHandler.endElement("style:tab-stops");
00111 }
00112
00113 xHandler.endElement("style:properties");
00114 xHandler.endElement("style:style");
00115 }
00116
00117 SpanStyle::SpanStyle(const char *psName, const WPXPropertyList &xPropList) :
00118 Style(psName),
00119 mPropList(xPropList)
00120 {
00121 }
00122
00123 void SpanStyle::write(DocumentHandler &xHandler) const
00124 {
00125 WRITER_DEBUG_MSG(("Writing a span style..\n"));
00126 WPXPropertyList styleOpenList;
00127 styleOpenList.insert("style:name", getName());
00128 styleOpenList.insert("style:family", "text");
00129 xHandler.startElement("style:style", styleOpenList);
00130
00131 WPXPropertyList propList(mPropList);
00132
00133 if (mPropList["style:font-name"])
00134 {
00135 propList.insert("style:font-name-asian", mPropList["style:font-name"]->getStr());
00136 propList.insert("style:font-name-complex", mPropList["style:font-name"]->getStr());
00137 }
00138
00139 if (mPropList["fo:font-size"])
00140 {
00141 propList.insert("style:font-size-asian", mPropList["fo:font-size"]->getStr());
00142 propList.insert("style:font-size-complex", mPropList["fo:font-size"]->getStr());
00143 }
00144
00145 if (mPropList["fo:font-weight"])
00146 {
00147 propList.insert("style:font-weight-asian", mPropList["fo:font-weight"]->getStr());
00148 propList.insert("style:font-weight-complex", mPropList["fo:font-weight"]->getStr());
00149 }
00150
00151 if (mPropList["fo:font-style"])
00152 {
00153 propList.insert("style:font-style-asian", mPropList["fo:font-style"]->getStr());
00154 propList.insert("style:font-style-complex", mPropList["fo:font-style"]->getStr());
00155 }
00156
00157 xHandler.startElement("style:properties", propList);
00158
00159 xHandler.endElement("style:properties");
00160 xHandler.endElement("style:style");
00161 }