LCOV - code coverage report
Current view: top level - writerperfect/source/filter - TableStyle.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 85 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 388 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /* TableStyle: Stores (and writes) table-based information that is
       3                 :            :  * needed at the head of an OO document.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * For further information visit http://libwpd.sourceforge.net
      10                 :            :  */
      11                 :            : 
      12                 :            : /* "This product is not manufactured, approved, or supported by
      13                 :            :  * Corel Corporation or Corel Corporation Limited."
      14                 :            :  */
      15                 :            : #include <math.h>
      16                 :            : #include "FilterInternal.hxx"
      17                 :            : #include "TableStyle.hxx"
      18                 :            : #include "DocumentElement.hxx"
      19                 :            : 
      20                 :            : #ifdef _MSC_VER
      21                 :            : #include <minmax.h>
      22                 :            : #endif
      23                 :            : 
      24                 :            : #include <string.h>
      25                 :            : 
      26                 :          0 : TableCellStyle::TableCellStyle(const WPXPropertyList &xPropList, const char *psName) :
      27                 :            :     Style(psName),
      28 [ #  # ][ #  # ]:          0 :     mPropList(xPropList)
      29                 :            : {
      30                 :          0 : }
      31                 :            : 
      32                 :          0 : void TableCellStyle::write(OdfDocumentHandler *pHandler) const
      33                 :            : {
      34 [ #  # ][ #  # ]:          0 :     TagOpenElement styleOpen("style:style");
                 [ #  # ]
      35 [ #  # ][ #  # ]:          0 :     styleOpen.addAttribute("style:name", getName());
                 [ #  # ]
      36 [ #  # ][ #  # ]:          0 :     styleOpen.addAttribute("style:family", "table-cell");
         [ #  # ][ #  # ]
                 [ #  # ]
      37         [ #  # ]:          0 :     styleOpen.write(pHandler);
      38                 :            : 
      39                 :            :     // WLACH_REFACTORING: Only temporary.. a much better solution is to
      40                 :            :     // generalize this sort of thing into the "Style" superclass
      41         [ #  # ]:          0 :     WPXPropertyList stylePropList;
      42         [ #  # ]:          0 :     WPXPropertyList::Iter i(mPropList);
      43 [ #  # ][ #  # ]:          0 :     for (i.rewind(); i.next();)
                 [ #  # ]
      44                 :            :     {
      45 [ #  # ][ #  # ]:          0 :         if (strlen(i.key()) > 2 && strncmp(i.key(), "fo", 2) == 0)
         [ #  # ][ #  # ]
                 [ #  # ]
      46 [ #  # ][ #  # ]:          0 :             stylePropList.insert(i.key(), i()->clone());
         [ #  # ][ #  # ]
      47                 :            :     }
      48         [ #  # ]:          0 :     stylePropList.insert("fo:padding", "0.0382in");
      49         [ #  # ]:          0 :     pHandler->startElement("style:table-cell-properties", stylePropList);
      50         [ #  # ]:          0 :     pHandler->endElement("style:table-cell-properties");
      51                 :            : 
      52 [ #  # ][ #  # ]:          0 :     pHandler->endElement("style:style");
         [ #  # ][ #  # ]
      53                 :          0 : }
      54                 :            : 
      55                 :          0 : TableRowStyle::TableRowStyle(const WPXPropertyList &propList, const char *psName) :
      56                 :            :     Style(psName),
      57 [ #  # ][ #  # ]:          0 :     mPropList(propList)
      58                 :            : {
      59                 :          0 : }
      60                 :            : 
      61                 :          0 : void TableRowStyle::write(OdfDocumentHandler *pHandler) const
      62                 :            : {
      63 [ #  # ][ #  # ]:          0 :     TagOpenElement styleOpen("style:style");
                 [ #  # ]
      64 [ #  # ][ #  # ]:          0 :     styleOpen.addAttribute("style:name", getName());
                 [ #  # ]
      65 [ #  # ][ #  # ]:          0 :     styleOpen.addAttribute("style:family", "table-row");
         [ #  # ][ #  # ]
                 [ #  # ]
      66         [ #  # ]:          0 :     styleOpen.write(pHandler);
      67                 :            : 
      68 [ #  # ][ #  # ]:          0 :     TagOpenElement stylePropertiesOpen("style:table-row-properties");
                 [ #  # ]
      69 [ #  # ][ #  # ]:          0 :     if (mPropList["style:min-row-height"])
      70 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("style:min-row-height", mPropList["style:min-row-height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      71 [ #  # ][ #  # ]:          0 :     else if (mPropList["style:row-height"])
      72 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("style:row-height", mPropList["style:row-height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      73 [ #  # ][ #  # ]:          0 :     stylePropertiesOpen.addAttribute("fo:keep-together", "auto");
         [ #  # ][ #  # ]
                 [ #  # ]
      74         [ #  # ]:          0 :     stylePropertiesOpen.write(pHandler);
      75         [ #  # ]:          0 :     pHandler->endElement("style:table-row-properties");
      76                 :            : 
      77 [ #  # ][ #  # ]:          0 :     pHandler->endElement("style:style");
                 [ #  # ]
      78                 :          0 : }
      79                 :            : 
      80                 :            : 
      81                 :          0 : TableStyle::TableStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &columns, const char *psName) :
      82                 :            :     Style(psName),
      83                 :            :     mPropList(xPropList),
      84 [ #  # ][ #  # ]:          0 :     mColumns(columns)
         [ #  # ][ #  # ]
                 [ #  # ]
      85                 :            : {
      86                 :          0 : }
      87                 :            : 
      88 [ #  # ][ #  # ]:          0 : TableStyle::~TableStyle()
                 [ #  # ]
      89                 :            : {
      90                 :            :     typedef std::vector<TableCellStyle *>::iterator TCSVIter;
      91                 :            :     typedef std::vector<TableRowStyle *>::iterator TRSVIter;
      92 [ #  # ][ #  # ]:          0 :     for (TCSVIter iterTableCellStyles = mTableCellStyles.begin() ; iterTableCellStyles != mTableCellStyles.end(); ++iterTableCellStyles)
      93 [ #  # ][ #  # ]:          0 :         delete(*iterTableCellStyles);
      94 [ #  # ][ #  # ]:          0 :     for (TRSVIter iterTableRowStyles = mTableRowStyles.begin() ; iterTableRowStyles != mTableRowStyles.end(); ++iterTableRowStyles)
      95 [ #  # ][ #  # ]:          0 :         delete(*iterTableRowStyles);
      96         [ #  # ]:          0 : }
      97                 :            : 
      98                 :          0 : void TableStyle::write(OdfDocumentHandler *pHandler) const
      99                 :            : {
     100 [ #  # ][ #  # ]:          0 :     TagOpenElement styleOpen("style:style");
                 [ #  # ]
     101 [ #  # ][ #  # ]:          0 :     styleOpen.addAttribute("style:name", getName());
                 [ #  # ]
     102 [ #  # ][ #  # ]:          0 :     styleOpen.addAttribute("style:family", "table");
         [ #  # ][ #  # ]
                 [ #  # ]
     103         [ #  # ]:          0 :     if (getMasterPageName())
     104 [ #  # ][ #  # ]:          0 :         styleOpen.addAttribute("style:master-page-name", getMasterPageName()->cstr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     105         [ #  # ]:          0 :     styleOpen.write(pHandler);
     106                 :            : 
     107 [ #  # ][ #  # ]:          0 :     TagOpenElement stylePropertiesOpen("style:table-properties");
                 [ #  # ]
     108 [ #  # ][ #  # ]:          0 :     if (mPropList["table:align"])
     109 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("table:align", mPropList["table:align"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     110 [ #  # ][ #  # ]:          0 :     if (mPropList["fo:margin-left"])
     111 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("fo:margin-left", mPropList["fo:margin-left"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     112 [ #  # ][ #  # ]:          0 :     if (mPropList["fo:margin-right"])
     113 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("fo:margin-right", mPropList["fo:margin-right"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     114 [ #  # ][ #  # ]:          0 :     if (mPropList["style:width"])
     115 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("style:width", mPropList["style:width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     116 [ #  # ][ #  # ]:          0 :     if (mPropList["fo:break-before"])
     117 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("fo:break-before", mPropList["fo:break-before"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     118         [ #  # ]:          0 :     stylePropertiesOpen.write(pHandler);
     119                 :            : 
     120         [ #  # ]:          0 :     pHandler->endElement("style:table-properties");
     121                 :            : 
     122         [ #  # ]:          0 :     pHandler->endElement("style:style");
     123                 :            : 
     124                 :          0 :     int i=1;
     125         [ #  # ]:          0 :     WPXPropertyListVector::Iter j(mColumns);
     126 [ #  # ][ #  # ]:          0 :     for (j.rewind(); j.next();)
                 [ #  # ]
     127                 :            :     {
     128 [ #  # ][ #  # ]:          0 :         TagOpenElement columnStyleOpen("style:style");
                 [ #  # ]
     129         [ #  # ]:          0 :         WPXString sColumnName;
     130 [ #  # ][ #  # ]:          0 :         sColumnName.sprintf("%s.Column%i", getName().cstr(), i);
     131 [ #  # ][ #  # ]:          0 :         columnStyleOpen.addAttribute("style:name", sColumnName);
                 [ #  # ]
     132 [ #  # ][ #  # ]:          0 :         columnStyleOpen.addAttribute("style:family", "table-column");
         [ #  # ][ #  # ]
                 [ #  # ]
     133         [ #  # ]:          0 :         columnStyleOpen.write(pHandler);
     134                 :            : 
     135 [ #  # ][ #  # ]:          0 :         pHandler->startElement("style:table-column-properties", j());
     136         [ #  # ]:          0 :         pHandler->endElement("style:table-column-properties");
     137                 :            : 
     138         [ #  # ]:          0 :         pHandler->endElement("style:style");
     139                 :            : 
     140                 :          0 :         i++;
     141 [ #  # ][ #  # ]:          0 :     }
     142                 :            : 
     143                 :            :     typedef std::vector<TableRowStyle *>::const_iterator TRSVIter;
     144 [ #  # ][ #  # ]:          0 :     for (TRSVIter iterTableRow = mTableRowStyles.begin() ; iterTableRow != mTableRowStyles.end(); ++iterTableRow)
     145         [ #  # ]:          0 :         (*iterTableRow)->write(pHandler);
     146                 :            : 
     147                 :            :     typedef std::vector<TableCellStyle *>::const_iterator TCSVIter;
     148 [ #  # ][ #  # ]:          0 :     for (TCSVIter iterTableCell = mTableCellStyles.begin() ; iterTableCell != mTableCellStyles.end(); ++iterTableCell)
     149 [ #  # ][ #  # ]:          0 :         (*iterTableCell)->write(pHandler);
         [ #  # ][ #  # ]
     150                 :          0 : }
     151                 :            : 
     152                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10