filters
TableStyle.cxx00001
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 #include <cstring>
00031 #include <math.h>
00032 #include "FilterInternal.hxx"
00033 #include "TableStyle.hxx"
00034 #include "DocumentElement.hxx"
00035
00036 #ifdef _MSC_VER
00037 #include <minmax.h>
00038 #endif
00039
00040 TableCellStyle::TableCellStyle(const WPXPropertyList &xPropList, const char *psName) :
00041 Style(psName),
00042 mPropList(xPropList)
00043 {
00044 }
00045
00046 void TableCellStyle::write(DocumentHandler &xHandler) const
00047 {
00048 TagOpenElement styleOpen("style:style");
00049 styleOpen.addAttribute("style:name", getName());
00050 styleOpen.addAttribute("style:family", "table-cell");
00051 styleOpen.write(xHandler);
00052
00053
00054
00055 WPXPropertyList stylePropList;
00056 WPXPropertyList::Iter i(mPropList);
00057 for (i.rewind(); i.next();)
00058 {
00059 if (strlen(i.key()) > 2 && strncmp(i.key(), "fo", 2) == 0)
00060 stylePropList.insert(i.key(), i()->clone());
00061 }
00062 stylePropList.insert("fo:padding", "0.0382inch");
00063 xHandler.startElement("style:properties", stylePropList);
00064 xHandler.endElement("style:properties");
00065
00066 xHandler.endElement("style:style");
00067 }
00068
00069 TableRowStyle::TableRowStyle(const WPXPropertyList &propList, const char *psName) :
00070 Style(psName),
00071 mPropList(propList)
00072 {
00073 }
00074
00075 void TableRowStyle::write(DocumentHandler &xHandler) const
00076 {
00077 TagOpenElement styleOpen("style:style");
00078 styleOpen.addAttribute("style:name", getName());
00079 styleOpen.addAttribute("style:family", "table-row");
00080 styleOpen.write(xHandler);
00081
00082 TagOpenElement stylePropertiesOpen("style:properties");
00083 if (mPropList["style:min-row-height"])
00084 stylePropertiesOpen.addAttribute("style:min-row-height", mPropList["style:min-row-height"]->getStr());
00085 else if (mPropList["style:row-height"])
00086 stylePropertiesOpen.addAttribute("style:row-height", mPropList["style:row-height"]->getStr());
00087 stylePropertiesOpen.write(xHandler);
00088 xHandler.endElement("style:properties");
00089
00090 xHandler.endElement("style:style");
00091 }
00092
00093
00094 TableStyle::TableStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &columns, const char *psName) :
00095 Style(psName),
00096 mPropList(xPropList),
00097 mColumns(columns)
00098 {
00099 }
00100
00101 TableStyle::~TableStyle()
00102 {
00103 typedef std::vector<TableCellStyle *>::iterator TCSVIter;
00104 for (TCSVIter iterTableCellStyles = mTableCellStyles.begin() ; iterTableCellStyles != mTableCellStyles.end(); iterTableCellStyles++)
00105 delete(*iterTableCellStyles);
00106
00107 }
00108
00109 void TableStyle::write(DocumentHandler &xHandler) const
00110 {
00111 TagOpenElement styleOpen("style:style");
00112 styleOpen.addAttribute("style:name", getName());
00113 styleOpen.addAttribute("style:family", "table");
00114 if (getMasterPageName())
00115 styleOpen.addAttribute("style:master-page-name", getMasterPageName()->cstr());
00116 styleOpen.write(xHandler);
00117
00118 TagOpenElement stylePropertiesOpen("style:properties");
00119 if (mPropList["table:align"])
00120 stylePropertiesOpen.addAttribute("table:align", mPropList["table:align"]->getStr());
00121 if (mPropList["fo:margin-left"])
00122 stylePropertiesOpen.addAttribute("fo:margin-left", mPropList["fo:margin-left"]->getStr());
00123 if (mPropList["fo:margin-right"])
00124 stylePropertiesOpen.addAttribute("fo:margin-right", mPropList["fo:margin-right"]->getStr());
00125 if (mPropList["style:width"])
00126 stylePropertiesOpen.addAttribute("style:width", mPropList["style:width"]->getStr());
00127 if (mPropList["fo:break-before"])
00128 stylePropertiesOpen.addAttribute("fo:break-before", mPropList["fo:break-before"]->getStr());
00129 stylePropertiesOpen.write(xHandler);
00130
00131 xHandler.endElement("style:properties");
00132
00133 xHandler.endElement("style:style");
00134
00135 int i=1;
00136 WPXPropertyListVector::Iter j(mColumns);
00137 for (j.rewind(); j.next();)
00138 {
00139 TagOpenElement styleOpen("style:style");
00140 WPXString sColumnName;
00141 sColumnName.sprintf("%s.Column%i", getName().cstr(), i);
00142 styleOpen.addAttribute("style:name", sColumnName);
00143 styleOpen.addAttribute("style:family", "table-column");
00144 styleOpen.write(xHandler);
00145
00146 xHandler.startElement("style:properties", j());
00147 xHandler.endElement("style:properties");
00148
00149 xHandler.endElement("style:style");
00150
00151 i++;
00152 }
00153
00154 typedef std::vector<TableRowStyle *>::const_iterator TRSVIter;
00155 for (TRSVIter iterTableRow = mTableRowStyles.begin() ; iterTableRow != mTableRowStyles.end(); iterTableRow++)
00156 (*iterTableRow)->write(xHandler);
00157
00158 typedef std::vector<TableCellStyle *>::const_iterator TCSVIter;
00159 for (TCSVIter iterTableCell = mTableCellStyles.begin() ; iterTableCell != mTableCellStyles.end(); iterTableCell++)
00160 (*iterTableCell)->write(xHandler);
00161 }
|