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