diff options
author | Kurt Zenker <kz@openoffice.org> | 2005-03-01 16:06:47 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2005-03-01 16:06:47 +0000 |
commit | ebc0e10b84ae3d08e71e7ac187b0da0c404f0a1a (patch) | |
tree | 3ddd6d39d89101506c65e4bf6a9807ae92c7ae61 /writerperfect/source | |
parent | 78e89884dda443f7d7576997c32715fd6eb46f4f (diff) |
INTEGRATION: CWS libwpdupgrade (1.1.2); FILE MERGED
2005/02/08 18:55:21 rene 1.1.2.3: fix namespace problems on Solaris/SPARC
again from fridrich_strba@
2005/02/07 18:33:52 rene 1.1.2.2: adapt to newer libwpd CVS since before, nothing worked at all ;)
Submitted By (like the last patches, forgot to mention it :/) : fridrich_strba@
2005/02/02 20:44:44 rene 1.1.2.1: upgrade writerperfect to new libwpd API and implement --with-system-libwpd.
Remove old libwpd/ stuff, tarball will come when the actual release happened :-)
Diffstat (limited to 'writerperfect/source')
-rw-r--r-- | writerperfect/source/filter/TableStyle.cxx | 219 | ||||
-rw-r--r-- | writerperfect/source/filter/TableStyle.hxx | 53 |
2 files changed, 95 insertions, 177 deletions
diff --git a/writerperfect/source/filter/TableStyle.cxx b/writerperfect/source/filter/TableStyle.cxx index b7905c3a8079..5b7e06c2f3d8 100644 --- a/writerperfect/source/filter/TableStyle.cxx +++ b/writerperfect/source/filter/TableStyle.cxx @@ -1,7 +1,9 @@ /* TableStyle: Stores (and writes) table-based information that is * needed at the head of an OO document. * - * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca) + * Copyright (C) 2002-2004 William Lachance (william.lachance@sympatico.ca) + * Copyright (C) 2004 Net Integration Technologies, Inc. (http://www.net-itech.com) + * Copyright (C) 2004 Fridrich Strba (fridrich.strba@bluewin.ch) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -33,202 +35,123 @@ #include <minmax.h> #endif -using namespace ::rtl; -using rtl::OUString; - -TableCellStyle::TableCellStyle(const float fLeftBorderThickness, const float fRightBorderThickness, - const float fTopBorderThickness, const float fBottomBorderThickness, - const RGBSColor *pFgColor, const RGBSColor *pBgColor, const char *psName) : +TableCellStyle::TableCellStyle(const WPXPropertyList &xPropList, const char *psName) : Style(psName), - mfLeftBorderThickness(fLeftBorderThickness), - mfRightBorderThickness(fRightBorderThickness), - mfTopBorderThickness(fTopBorderThickness), - mfBottomBorderThickness(fBottomBorderThickness) + mPropList(xPropList) { - if (pFgColor != NULL) { - m_fgColor.m_r = pFgColor->m_r; - m_fgColor.m_g = pFgColor->m_g; - m_fgColor.m_b = pFgColor->m_b; - m_fgColor.m_s = pFgColor->m_s; - } - else { - m_fgColor.m_r = m_fgColor.m_g = m_fgColor.m_b = 0xFF; - m_fgColor.m_s = 0x64; // 100% - } - if (pBgColor != NULL) { - m_bgColor.m_r = pBgColor->m_r; - m_bgColor.m_g = pBgColor->m_g; - m_bgColor.m_b = pBgColor->m_b; - m_bgColor.m_s = pBgColor->m_s; - } - else { - m_bgColor.m_r = m_bgColor.m_g = m_bgColor.m_b = 0xFF; - m_bgColor.m_s = 0x64; // 100% - } } -void TableCellStyle::write(Reference < XDocumentHandler > &xHandler) const +void TableCellStyle::write(DocumentHandler &xHandler) const { TagOpenElement styleOpen("style:style"); styleOpen.addAttribute("style:name", getName()); styleOpen.addAttribute("style:family", "table-cell"); styleOpen.write(xHandler); - TagOpenElement stylePropertiesOpen("style:properties"); - UTF8String sBackgroundColor; - float fgAmount = (float)m_fgColor.m_s/100.0f; - float bgAmount = max(((float)m_bgColor.m_s-(float)m_fgColor.m_s)/100.0f, 0.0f); - - int bgRed = min((int)(((float)m_fgColor.m_r*fgAmount)+((float)m_bgColor.m_r*bgAmount)), 255); - int bgGreen = min((int)(((float)m_fgColor.m_g*fgAmount)+((float)m_bgColor.m_g*bgAmount)), 255); - int bgBlue = min((int)(((float)m_fgColor.m_b*fgAmount)+((float)m_bgColor.m_b*bgAmount)), 255); - sBackgroundColor.sprintf("#%.2x%.2x%.2x", bgRed, bgGreen, bgBlue); - stylePropertiesOpen.addAttribute("fo:background-color", sBackgroundColor.getUTF8()); - stylePropertiesOpen.addAttribute("fo:padding", "0.0382inch"); - UTF8String sBorderLeft; - sBorderLeft.sprintf("%finch solid #000000", mfLeftBorderThickness); - stylePropertiesOpen.addAttribute("fo:border-left", sBorderLeft.getUTF8()); - UTF8String sBorderRight; - sBorderRight.sprintf("%finch solid #000000", mfRightBorderThickness); - stylePropertiesOpen.addAttribute("fo:border-right", sBorderRight.getUTF8()); - UTF8String sBorderTop; - sBorderTop.sprintf("%finch solid #000000", mfTopBorderThickness); - stylePropertiesOpen.addAttribute("fo:border-top", sBorderTop.getUTF8()); - UTF8String sBorderBottom; - sBorderBottom.sprintf("%finch solid #000000", mfBottomBorderThickness); - stylePropertiesOpen.addAttribute("fo:border-bottom", sBorderBottom.getUTF8()); - stylePropertiesOpen.write(xHandler); - xHandler->endElement(OUString::createFromAscii("style:properties")); + // WLACH_REFACTORING: Only temporary.. a much better solution is to + // generalize this sort of thing into the "Style" superclass + WPXPropertyList stylePropList; + WPXPropertyList::Iter i(mPropList); + for (i.rewind(); i.next();) + { + if (strlen(i.key()) > 2 && strncmp(i.key(), "fo", 2) == 0) + stylePropList.insert(i.key(), i()->clone()); + } + stylePropList.insert("fo:padding", "0.0382inch"); + xHandler.startElement("style:properties", stylePropList); + xHandler.endElement("style:properties"); + + xHandler.endElement("style:style"); +} - xHandler->endElement(OUString::createFromAscii("style:style")); +TableRowStyle::TableRowStyle(const WPXPropertyList &propList, const char *psName) : + Style(psName), + mPropList(propList) +{ +} + +void TableRowStyle::write(DocumentHandler &xHandler) const +{ + TagOpenElement styleOpen("style:style"); + styleOpen.addAttribute("style:name", getName()); + styleOpen.addAttribute("style:family", "table-row"); + styleOpen.write(xHandler); -// xHandler->endElement(OUString::createFromAscii("<style:style style:name=\"%s\" style:family=\"%s\"><style:properties fo:background-color=\"#%.2x%.2x%.2x\" fo:padding=\"0.0382inch\" fo:border-left=\"%finch solid #000000\" fo:border-right=\"%finch solid #000000\" fo:border-top=\"%finch solid #000000\" fo:border-bottom=\"%finch solid #000000\"/></style:style>\n", getName(), "table-cell", -// m_fgColor.m_r, m_fgColor.m_g, m_fgColor.m_b, -// mfLeftBorderThickness, mfRightBorderThickness, -// mfTopBorderThickness, mfBottomBorderThickness); + TagOpenElement stylePropertiesOpen("style:properties"); + if (mPropList["style:min-row-height"]) + stylePropertiesOpen.addAttribute("style:min-row-height", mPropList["style:min-row-height"]->getStr()); + else if (mPropList["style:row-height"]) + stylePropertiesOpen.addAttribute("style:row-height", mPropList["style:row-height"]->getStr()); + stylePropertiesOpen.write(xHandler); + xHandler.endElement("style:properties"); + + xHandler.endElement("style:style"); } -TableStyle::TableStyle(const float fDocumentMarginLeft, const float fDocumentMarginRight, - const float fMarginLeftOffset, const float fMarginRightOffset, - const uint8_t iTablePositionBits, const float fLeftOffset, - const vector < WPXColumnDefinition > &columns, const char *psName) : +TableStyle::TableStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &columns, const char *psName) : Style(psName), - mfDocumentMarginLeft(fDocumentMarginLeft), - mfDocumentMarginRight(fDocumentMarginRight), - mfMarginLeftOffset(fMarginLeftOffset), - mfMarginRightOffset(fMarginRightOffset), - miTablePositionBits(iTablePositionBits), - mfLeftOffset(fLeftOffset), - miNumColumns(columns.size()) - + mPropList(xPropList), + mColumns(columns) { - WRITER_DEBUG_MSG(("WriterWordPerfect: Created a new set of table props with this no. of columns repeated: %i and this name: %s\n", - (int)miNumColumns, (const char *)getName())); - - typedef vector<WPXColumnDefinition>::const_iterator CDVIter; - for (CDVIter iterColumns = columns.begin() ; iterColumns != columns.end(); iterColumns++) - { - mColumns.push_back((*iterColumns)); - } } TableStyle::~TableStyle() { - typedef vector<TableCellStyle *>::iterator TCSVIter; + typedef std::vector<TableCellStyle *>::iterator TCSVIter; for (TCSVIter iterTableCellStyles = mTableCellStyles.begin() ; iterTableCellStyles != mTableCellStyles.end(); iterTableCellStyles++) delete(*iterTableCellStyles); } -void TableStyle::write(Reference < XDocumentHandler > &xHandler) const +void TableStyle::write(DocumentHandler &xHandler) const { TagOpenElement styleOpen("style:style"); styleOpen.addAttribute("style:name", getName()); styleOpen.addAttribute("style:family", "table"); if (getMasterPageName()) - styleOpen.addAttribute("style:master-page-name", getMasterPageName()->getUTF8()); + styleOpen.addAttribute("style:master-page-name", getMasterPageName()->cstr()); styleOpen.write(xHandler); TagOpenElement stylePropertiesOpen("style:properties"); - - UTF8String sTableMarginLeft; - UTF8String sTableMarginRight; - UTF8String sTableAlignment; - char *pTableAlignment = NULL; - if (miTablePositionBits == WPX_TABLE_POSITION_ALIGN_WITH_LEFT_MARGIN) { - sTableAlignment.sprintf("left"); - sTableMarginLeft.sprintf("0inch"); - } - else if (miTablePositionBits == WPX_TABLE_POSITION_ALIGN_WITH_RIGHT_MARGIN) { - sTableAlignment.sprintf("right"); - } - else if (miTablePositionBits == WPX_TABLE_POSITION_CENTER_BETWEEN_MARGINS) { - sTableAlignment.sprintf("center"); - } - else if (miTablePositionBits == WPX_TABLE_POSITION_ABSOLUTE_FROM_LEFT_MARGIN) { - sTableAlignment.sprintf("left"); - sTableMarginLeft.sprintf("%finch", (mfLeftOffset-mfDocumentMarginLeft+mfMarginLeftOffset)); - } - else if (miTablePositionBits == WPX_TABLE_POSITION_FULL) { - sTableAlignment.sprintf("margins"); - sTableMarginLeft.sprintf("%finch", mfMarginLeftOffset); - sTableMarginRight.sprintf("%finch", mfMarginRightOffset); - } - stylePropertiesOpen.addAttribute("table:align", sTableAlignment.getUTF8()); - if (sTableMarginLeft.getUTF8()) - stylePropertiesOpen.addAttribute("fo:margin-left", sTableMarginLeft.getUTF8()); - if (sTableMarginRight.getUTF8()) - stylePropertiesOpen.addAttribute("fo:margin-right", sTableMarginRight.getUTF8()); - - float fTableWidth = 0; - typedef vector<WPXColumnDefinition>::const_iterator CDVIter; - for (CDVIter iterColumns2 = mColumns.begin() ; iterColumns2 != mColumns.end(); iterColumns2++) - { - fTableWidth += (*iterColumns2).m_width; - } - UTF8String sTableWidth; - sTableWidth.sprintf("%finch", fTableWidth); - stylePropertiesOpen.addAttribute("style:width", sTableWidth.getUTF8()); + if (mPropList["table:align"]) + stylePropertiesOpen.addAttribute("table:align", mPropList["table:align"]->getStr()); + if (mPropList["fo:margin-left"]) + stylePropertiesOpen.addAttribute("fo:margin-left", mPropList["fo:margin-left"]->getStr()); + if (mPropList["fo:margin-right"]) + stylePropertiesOpen.addAttribute("fo:margin-right", mPropList["fo:margin-right"]->getStr()); + if (mPropList["style:width"]) + stylePropertiesOpen.addAttribute("style:width", mPropList["style:width"]->getStr()); stylePropertiesOpen.write(xHandler); - xHandler->endElement(OUString::createFromAscii("style:properties")); - - xHandler->endElement(OUString::createFromAscii("style:style")); + xHandler.endElement("style:properties"); - -// if (getMasterPageName()) { -// xHandler->endElement(OUString::createFromAscii("<style:style style:name=\"%s\" style:family=\"%s\" style:master-page-name=\"%s\"><style:properties table:align=\"%s\" %s %s style:width=\"%finch\"/></style:style>\n", getName(), "table", getMasterPageName()->getUTF8(), pTableAlignment, psTableMarginLeft, psTableMarginRight, fTableWidth); -// } -// else { -// xHandler->endElement(OUString::createFromAscii("<style:style style:name=\"%s\" style:family=\"%s\"><style:properties table:align=\"%s\" %s %s style:width=\"%finch\"/></style:style>\n", getName(), "table", pTableAlignment, psTableMarginLeft, psTableMarginRight, fTableWidth); -// } + xHandler.endElement("style:style"); int i=1; - typedef vector<WPXColumnDefinition>::const_iterator CDVIter; - for (CDVIter iterColumns = mColumns.begin() ; iterColumns != mColumns.end(); iterColumns++) + WPXPropertyListVector::Iter j(mColumns); + for (j.rewind(); j.next();) { TagOpenElement styleOpen("style:style"); - UTF8String sColumnName; - sColumnName.sprintf("%s.Column%i", (const char *)getName(), i); - styleOpen.addAttribute("style:name", sColumnName.getUTF8()); + WPXString sColumnName; + sColumnName.sprintf("%s.Column%i", getName().cstr(), i); + styleOpen.addAttribute("style:name", sColumnName); styleOpen.addAttribute("style:family", "table-column"); styleOpen.write(xHandler); - TagOpenElement stylePropertiesOpen("style:properties"); - UTF8String sColumnWidth; - sColumnWidth.sprintf("%finch", (*iterColumns).m_width); - stylePropertiesOpen.addAttribute("style:column-width", sColumnWidth.getUTF8()); - stylePropertiesOpen.write(xHandler); - xHandler->endElement(OUString::createFromAscii("style:properties")); + xHandler.startElement("style:properties", j()); + xHandler.endElement("style:properties"); - xHandler->endElement(OUString::createFromAscii("style:style")); + xHandler.endElement("style:style"); -//xHandler->endElement(OUString::createFromAscii("<style:style style:name=\"%s.Column%i\" style:family=\"%s\"><style:properties style:column-width=\"%finch\"/></style:style>\n", getName(), i, "table-column", (*iter).m_width); i++; } - typedef vector<TableCellStyle *>::const_iterator TCSVIter; + typedef std::vector<TableRowStyle *>::const_iterator TRSVIter; + for (TRSVIter iterTableRow = mTableRowStyles.begin() ; iterTableRow != mTableRowStyles.end(); iterTableRow++) + (*iterTableRow)->write(xHandler); + + typedef std::vector<TableCellStyle *>::const_iterator TCSVIter; for (TCSVIter iterTableCell = mTableCellStyles.begin() ; iterTableCell != mTableCellStyles.end(); iterTableCell++) (*iterTableCell)->write(xHandler); } diff --git a/writerperfect/source/filter/TableStyle.hxx b/writerperfect/source/filter/TableStyle.hxx index ecf5cfe85858..678c592272e8 100644 --- a/writerperfect/source/filter/TableStyle.hxx +++ b/writerperfect/source/filter/TableStyle.hxx @@ -2,6 +2,7 @@ * needed at the head of an OO document. * * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca) + * Copyright (C) 2004 Fridrich Strba (fridrich.strba@bluewin.ch) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,48 +33,42 @@ #include "Style.hxx" #include "WriterProperties.hxx" -using com::sun::star::uno::Reference; -using com::sun::star::xml::sax::XDocumentHandler; - class DocumentElement; +class DocumentHandler; class TableCellStyle : public Style { public: - TableCellStyle(const float fLeftBorderThickness, const float fRightBorderThickness, - const float fTopBorderThickness, const float fBottomBorderThickness, - const RGBSColor *pFgColor, const RGBSColor *pBgColor, const char *psName); - virtual void write(Reference < XDocumentHandler > &xHandler) const; + TableCellStyle(const WPXPropertyList &xPropList, const char *psName); + virtual void write(DocumentHandler &xHandler) const; +private: + WPXPropertyList mPropList; +}; + +class TableRowStyle : public Style +{ +public: + TableRowStyle(const WPXPropertyList &propList, const char *psName); + virtual void write(DocumentHandler &xHandler) const; private: - float mfLeftBorderThickness; - float mfRightBorderThickness; - float mfTopBorderThickness; - float mfBottomBorderThickness; - RGBSColor m_fgColor; - RGBSColor m_bgColor; + WPXPropertyList mPropList; }; class TableStyle : public Style, public TopLevelElementStyle { - public: - TableStyle(const float fDocumentMarginLeft, const float fDocumentMarginRight, - const float fMarginLeftOffset, const float fMarginRightOffset, - const uint8_t iTablePositionBits, const float fLeftOffset, - const vector < WPXColumnDefinition > &columns, - const char *psName); +public: + TableStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &columns, const char *psName); ~TableStyle(); - virtual void write(Reference < XDocumentHandler > &xHandler) const; - const int getNumColumns() const { return miNumColumns; } + virtual void write(DocumentHandler &xHandler) const; + const int getNumColumns() const { return mColumns.count(); } void addTableCellStyle(TableCellStyle *pTableCellStyle) { mTableCellStyles.push_back(pTableCellStyle); } int getNumTableCellStyles() { return mTableCellStyles.size(); } + void addTableRowStyle(TableRowStyle *pTableRowStyle) { mTableRowStyles.push_back(pTableRowStyle); } + int getNumTableRowStyles() { return mTableRowStyles.size(); } private: - float mfDocumentMarginLeft, mfDocumentMarginRight; - float mfMarginLeftOffset, mfMarginRightOffset; - vector< WPXColumnDefinition > mColumns; - unsigned int miTablePositionBits; - float mfLeftOffset; - vector<TableCellStyle *> mTableCellStyles; - int miNumColumns; + WPXPropertyList mPropList; + WPXPropertyListVector mColumns; + std::vector<TableCellStyle *> mTableCellStyles; + std::vector<TableRowStyle *> mTableRowStyles; }; - #endif |