LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - WW8TableInfo.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 21 0.0 %
Date: 2012-08-25 Functions: 0 13 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef WW8_TABLE_INFO_HXX
      30                 :            : #define WW8_TABLE_INFO_HXX
      31                 :            : #include <boost/unordered_map.hpp>
      32                 :            : #include <string>
      33                 :            : #include <map>
      34                 :            : #include <set>
      35                 :            : #include <functional>
      36                 :            : #include <boost/shared_ptr.hpp>
      37                 :            : #include <vector>
      38                 :            : #include <sal/types.h>
      39                 :            : #include <swrect.hxx>
      40                 :            : 
      41                 :            : class SwTable;
      42                 :            : class SwTableLine;
      43                 :            : class SwTableBox;
      44                 :            : class SwNode;
      45                 :            : class AttributeOutputBase;
      46                 :            : 
      47                 :            : namespace ww8
      48                 :            : {
      49                 :            : using namespace ::std;
      50                 :            : 
      51                 :            : const unsigned int MAXTABLECELLS = 63;
      52                 :            : 
      53                 :            : class WW8TableNodeInfo;
      54                 :            : typedef boost::shared_ptr<SwRect> SwRectPtr;
      55                 :            : typedef ::std::vector<const SwTableBox *> TableBoxVector;
      56                 :            : typedef boost::shared_ptr<TableBoxVector> TableBoxVectorPtr;
      57                 :            : typedef ::std::vector<sal_uInt32> GridCols;
      58                 :            : typedef boost::shared_ptr<GridCols> GridColsPtr;
      59                 :            : typedef ::std::vector<sal_uInt32> RowSpans;
      60                 :            : typedef boost::shared_ptr<RowSpans> RowSpansPtr;
      61                 :            : typedef ::std::vector<sal_uInt32> Widths;
      62                 :            : typedef boost::shared_ptr<Widths> WidthsPtr;
      63                 :            : 
      64                 :            : class WW8TableNodeInfoInner
      65                 :            : {
      66                 :            :     WW8TableNodeInfo * mpParent;
      67                 :            :     sal_uInt32 mnDepth;
      68                 :            :     sal_uInt32 mnCell;
      69                 :            :     sal_uInt32 mnRow;
      70                 :            :     sal_uInt32 mnShadowsBefore;
      71                 :            :     sal_uInt32 mnShadowsAfter;
      72                 :            :     bool mbEndOfLine;
      73                 :            :     bool mbEndOfCell;
      74                 :            :     bool mbFirstInTable;
      75                 :            :     bool mbVertMerge;
      76                 :            :     const SwTableBox * mpTableBox;
      77                 :            :     const SwTable * mpTable;
      78                 :            :     SwRect maRect;
      79                 :            : 
      80                 :            : public:
      81                 :            :     typedef boost::shared_ptr<WW8TableNodeInfoInner> Pointer_t;
      82                 :            : 
      83                 :            :     WW8TableNodeInfoInner(WW8TableNodeInfo * pParent);
      84                 :            :     ~WW8TableNodeInfoInner();
      85                 :            : 
      86                 :            :     void setDepth(sal_uInt32 nDepth);
      87                 :            :     void setCell(sal_uInt32 nCell);
      88                 :            :     void setRow(sal_uInt32 nRow);
      89                 :            :     void setShadowsBefore(sal_uInt32 nShadowsBefore);
      90                 :            :     void setShadowsAfter(sal_uInt32 nShadowsAfter);
      91                 :            :     void setEndOfLine(bool bEndOfLine);
      92                 :            :     void setEndOfCell(bool bEndOfCell);
      93                 :            :     void setFirstInTable(bool bFirstInTable);
      94                 :            :     void setVertMerge(bool bVertMErge);
      95                 :            :     void setTableBox(const SwTableBox * pTableBox);
      96                 :            :     void setTable(const SwTable * pTable);
      97                 :            :     void setRect(const SwRect & rRect);
      98                 :            : 
      99                 :            :     sal_uInt32 getDepth() const;
     100                 :            :     sal_uInt32 getCell() const;
     101                 :            :     sal_uInt32 getRow() const;
     102                 :            :     sal_uInt32 getShadowsBefore() const;
     103                 :            :     sal_uInt32 getShadowsAfter() const;
     104                 :            :     bool isEndOfCell() const;
     105                 :            :     bool isEndOfLine() const;
     106                 :            :     bool isFirstInTable() const;
     107                 :            :     bool isVertMerge() const;
     108                 :            :     const SwTableBox * getTableBox() const;
     109                 :            :     const SwTable * getTable() const;
     110                 :            :     const SwRect & getRect() const;
     111                 :            : 
     112                 :            :     const SwNode * getNode() const;
     113                 :            : 
     114                 :            :     TableBoxVectorPtr getTableBoxesOfRow();
     115                 :            :     WidthsPtr getWidthsOfRow();
     116                 :            :     GridColsPtr getGridColsOfRow(AttributeOutputBase & rBase);
     117                 :            :     RowSpansPtr getRowSpansOfRow();
     118                 :            : 
     119                 :            : #ifdef DBG_UTIL
     120                 :            :     ::std::string toString() const;
     121                 :            : #endif
     122                 :            : };
     123                 :            : 
     124                 :            : class CellInfo;
     125                 :            : typedef ::std::multiset<CellInfo, less<CellInfo> > CellInfoMultiSet;
     126                 :            : typedef boost::shared_ptr<CellInfoMultiSet> CellInfoMultiSetPtr;
     127                 :            : 
     128                 :            : class WW8TableInfo;
     129                 :            : class WW8TableNodeInfo
     130                 :            : {
     131                 :            : public:
     132                 :            :     typedef map<sal_uInt32, WW8TableNodeInfoInner::Pointer_t,
     133                 :            :                 greater<sal_uInt32> > Inners_t;
     134                 :            : 
     135                 :            : private:
     136                 :            :     WW8TableInfo * mpParent;
     137                 :            :     sal_uInt32 mnDepth;
     138                 :            :     const SwNode * mpNode;
     139                 :            :     Inners_t mInners;
     140                 :            :     WW8TableNodeInfo * mpNext;
     141                 :            :     const SwNode * mpNextNode;
     142                 :            : 
     143                 :            : public:
     144                 :            :     typedef boost::shared_ptr<WW8TableNodeInfo> Pointer_t;
     145                 :            : 
     146                 :            :     WW8TableNodeInfo(WW8TableInfo * pParent, const SwNode * pTxtNode);
     147                 :            :     virtual ~WW8TableNodeInfo();
     148                 :            : 
     149                 :            :     void setDepth(sal_uInt32 nDepth);
     150                 :            :     void setEndOfLine(bool bEndOfLine);
     151                 :            :     void setEndOfCell(bool bEndOfCell);
     152                 :            :     void setFirstInTable(bool bFirstInTable);
     153                 :            :     void setVertMerge(bool bVertMerge);
     154                 :            :     void setTableBox(const SwTableBox *pTableBox);
     155                 :            :     void setTable(const SwTable * pTable);
     156                 :            :     void setCell(sal_uInt32 nCell);
     157                 :            :     void setRow(sal_uInt32 nRow);
     158                 :            :     void setShadowsBefore(sal_uInt32 nShadowsBefore);
     159                 :            :     void setShadowsAfter(sal_uInt32 nShadowsAfter);
     160                 :            :     void setNext(WW8TableNodeInfo * pNext);
     161                 :            :     void setNextNode(const SwNode * pNode);
     162                 :            :     void setRect(const SwRect & rRect);
     163                 :            : 
     164                 :            :     WW8TableInfo * getParent() const;
     165                 :            :     sal_uInt32 getDepth() const;
     166                 :            :     bool isEndOfLine() const;
     167                 :            :     bool isEndOfCell() const;
     168                 :            :     bool isFirstInTable() const;
     169                 :            :     const SwNode * getNode() const;
     170                 :            :     const SwTableBox * getTableBox() const;
     171                 :            :     WW8TableNodeInfo * getNext() const;
     172                 :            :     const SwNode * getNextNode() const;
     173                 :            :     const SwRect & getRect() const;
     174                 :            : 
     175                 :            :     const Inners_t & getInners() const;
     176                 :            :     const WW8TableNodeInfoInner::Pointer_t getFirstInner() const;
     177                 :            :     const WW8TableNodeInfoInner::Pointer_t getInnerForDepth(sal_uInt32 nDepth) const;
     178                 :            : 
     179                 :            :     sal_uInt32 getCell() const;
     180                 :            :     sal_uInt32 getRow() const;
     181                 :            : 
     182                 :            : #ifdef DBG_UTIL
     183                 :            :     ::std::string toString() const;
     184                 :            : #endif
     185                 :            : 
     186                 :            :     bool operator < (const WW8TableNodeInfo & rInfo) const;
     187                 :            : };
     188                 :            : 
     189                 :            : struct hashNode
     190                 :            : {
     191                 :          0 :     size_t operator()(const SwNode * pNode) const
     192                 :          0 :     { return reinterpret_cast<size_t>(pNode); }
     193                 :            : };
     194                 :            : 
     195                 :            : struct hashTable
     196                 :            : {
     197                 :          0 :     size_t operator()(const SwTable * pTable) const
     198                 :          0 :     { return reinterpret_cast<size_t>(pTable); }
     199                 :            : };
     200                 :            : 
     201                 :            : class WW8TableCellGridRow
     202                 :            : {
     203                 :            :     CellInfoMultiSetPtr m_pCellInfos;
     204                 :            :     TableBoxVectorPtr m_pTableBoxVector;
     205                 :            :     WidthsPtr m_pWidths;
     206                 :            :     RowSpansPtr m_pRowSpans;
     207                 :            : 
     208                 :            : public:
     209                 :            :     typedef boost::shared_ptr<WW8TableCellGridRow> Pointer_t;
     210                 :            :     WW8TableCellGridRow();
     211                 :            :     ~WW8TableCellGridRow();
     212                 :            : 
     213                 :            :     void insert(const CellInfo & rCellInfo);
     214                 :            :     CellInfoMultiSet::const_iterator begin() const;
     215                 :            :     CellInfoMultiSet::const_iterator end() const;
     216                 :            : 
     217                 :            :     void setTableBoxVector(TableBoxVectorPtr pTableBoxVector);
     218                 :            :     void setWidths(WidthsPtr pGridCols);
     219                 :            :     void setRowSpans(RowSpansPtr pRowSpans);
     220                 :            : 
     221                 :            :     TableBoxVectorPtr getTableBoxVector() const;
     222                 :            :     WidthsPtr getWidths() const;
     223                 :            :     RowSpansPtr getRowSpans() const;
     224                 :            : };
     225                 :            : 
     226                 :            : class WW8TableCellGrid
     227                 :            : {
     228                 :            :     typedef ::std::set<long> RowTops_t;
     229                 :            :     typedef ::std::map<long, WW8TableCellGridRow::Pointer_t> Rows_t;
     230                 :            : 
     231                 :            :     RowTops_t m_aRowTops;
     232                 :            :     Rows_t m_aRows;
     233                 :            : 
     234                 :            :     WW8TableCellGridRow::Pointer_t getRow(long nTop, bool bCreate = true);
     235                 :            :     RowTops_t::const_iterator getRowTopsBegin() const;
     236                 :            :     RowTops_t::const_iterator getRowTopsEnd() const;
     237                 :            :     CellInfoMultiSet::const_iterator getCellsBegin(long nTop);
     238                 :            :     CellInfoMultiSet::const_iterator getCellsEnd(long nTop);
     239                 :            : 
     240                 :            : public:
     241                 :            :     typedef ::boost::shared_ptr<WW8TableCellGrid> Pointer_t;
     242                 :            : 
     243                 :            :     WW8TableCellGrid();
     244                 :            :     ~WW8TableCellGrid();
     245                 :            : 
     246                 :            :     void insert(const SwRect & rRect, WW8TableNodeInfo * pNodeInfo,
     247                 :            :                 unsigned long * pFmtFrmWidth = NULL);
     248                 :            :     void addShadowCells();
     249                 :            :     WW8TableNodeInfo * connectCells();
     250                 :            : 
     251                 :            : #ifdef DBG_UTIL
     252                 :            :     ::std::string toString();
     253                 :            : #endif
     254                 :            : 
     255                 :            :     TableBoxVectorPtr getTableBoxesOfRow(WW8TableNodeInfoInner * pNodeInfo);
     256                 :            :     WidthsPtr getWidthsOfRow(WW8TableNodeInfoInner * pNodeInfo);
     257                 :            :     RowSpansPtr getRowSpansOfRow(WW8TableNodeInfoInner * pNodeInfo);
     258                 :            : };
     259                 :            : 
     260                 :            : class WW8TableInfo
     261                 :            : {
     262                 :            :     friend class WW8TableNodeInfoInner;
     263                 :            :     typedef boost::unordered_map<const SwNode *, WW8TableNodeInfo::Pointer_t, hashNode > Map_t;
     264                 :            :     Map_t mMap;
     265                 :            : 
     266                 :            :     typedef boost::unordered_map<const SwTable *, WW8TableCellGrid::Pointer_t, hashTable > CellGridMap_t;
     267                 :            :     CellGridMap_t mCellGridMap;
     268                 :            : 
     269                 :            :     typedef boost::unordered_map<const SwTable *, const SwNode *, hashTable > FirstInTableMap_t;
     270                 :            :     FirstInTableMap_t mFirstInTableMap;
     271                 :            : 
     272                 :            :     WW8TableNodeInfo *
     273                 :            :     processTableLine(const SwTable * pTable,
     274                 :            :                      const SwTableLine * pTableLine,
     275                 :            :                      sal_uInt32 nRow,
     276                 :            :                      sal_uInt32 nDepth, WW8TableNodeInfo * pPrev);
     277                 :            : 
     278                 :            :     WW8TableNodeInfo *
     279                 :            :     processTableBox(const SwTable * pTable,
     280                 :            :                     const SwTableBox * pTableBox,
     281                 :            :                     sal_uInt32 nRow,
     282                 :            :                     sal_uInt32 nCell,
     283                 :            :                     sal_uInt32 nDepth, bool bEndOfLine, WW8TableNodeInfo * pPrev);
     284                 :            : 
     285                 :            :     WW8TableNodeInfo::Pointer_t
     286                 :            :     processTableBoxLines(const SwTableBox * pBox,
     287                 :            :                          const SwTable * pTable,
     288                 :            :                          const SwTableBox * pBoxToSet,
     289                 :            :                          sal_uInt32 nRow,
     290                 :            :                          sal_uInt32 nCell,
     291                 :            :                          sal_uInt32 nDepth);
     292                 :            : 
     293                 :            :     WW8TableNodeInfo::Pointer_t
     294                 :            :     insertTableNodeInfo(const SwNode * pNode,
     295                 :            :                         const SwTable * pTable,
     296                 :            :                         const SwTableBox * pTableBox,
     297                 :            :                         sal_uInt32 nRow,
     298                 :            :                         sal_uInt32 nCell,
     299                 :            :                         sal_uInt32 nDepth,
     300                 :            :                         SwRect * pRect = NULL);
     301                 :            : 
     302                 :            :     WW8TableCellGrid::Pointer_t getCellGridForTable(const SwTable * pTable,
     303                 :            :                                                     bool bCreate = true);
     304                 :            : 
     305                 :            : public:
     306                 :            :     typedef boost::shared_ptr<WW8TableInfo> Pointer_t;
     307                 :            : 
     308                 :            :     WW8TableInfo();
     309                 :            :     virtual ~WW8TableInfo();
     310                 :            : 
     311                 :            :     void processSwTable(const SwTable * pTable);
     312                 :            :     WW8TableNodeInfo * processSwTableByLayout(const SwTable * pTable);
     313                 :            :     WW8TableNodeInfo::Pointer_t getTableNodeInfo(const SwNode * pNode);
     314                 :            :     const SwNode * getNextNode(const SwNode * pNode);
     315                 :            :     const WW8TableNodeInfo * getFirstTableNodeInfo() const;
     316                 :            : 
     317                 :            :     WW8TableNodeInfo * reorderByLayout(const SwTable * pTable);
     318                 :            : };
     319                 :            : 
     320                 :            : class CellInfo
     321                 :            : {
     322                 :            :     SwRect m_aRect;
     323                 :            :     WW8TableNodeInfo * m_pNodeInfo;
     324                 :            :     unsigned long m_nFmtFrmWidth;
     325                 :            : 
     326                 :            : public:
     327                 :            :     CellInfo(const SwRect & aRect, WW8TableNodeInfo * pNodeInfo);
     328                 :            : 
     329                 :          0 :     CellInfo(const CellInfo & aRectAndTableInfo)
     330                 :            :         : m_aRect(aRectAndTableInfo.m_aRect),
     331                 :            :           m_pNodeInfo(aRectAndTableInfo.m_pNodeInfo),
     332                 :          0 :           m_nFmtFrmWidth(aRectAndTableInfo.m_nFmtFrmWidth)
     333                 :            :     {
     334                 :          0 :     }
     335                 :            : 
     336                 :          0 :     ~CellInfo() {}
     337                 :            : 
     338                 :            :     bool operator < (const CellInfo & aCellInfo) const;
     339                 :            : 
     340                 :          0 :     long top() const { return m_aRect.Top(); }
     341                 :          0 :     long bottom() const { return m_aRect.Bottom(); }
     342                 :          0 :     long left() const { return m_aRect.Left(); }
     343                 :            :     long right() const { return m_aRect.Right(); }
     344                 :          0 :     long width() const { return m_aRect.Width(); }
     345                 :          0 :     long height() const { return m_aRect.Height(); }
     346                 :          0 :     SwRect getRect() const { return m_aRect; }
     347                 :          0 :     WW8TableNodeInfo * getTableNodeInfo() const
     348                 :          0 :     { return m_pNodeInfo; }
     349                 :          0 :     unsigned long getFmtFrmWidth() const
     350                 :            :     {
     351                 :          0 :         return m_nFmtFrmWidth;
     352                 :            :     }
     353                 :            : 
     354                 :          0 :     void setFmtFrmWidth(unsigned long nFmtFrmWidth)
     355                 :            :     {
     356                 :          0 :         m_nFmtFrmWidth = nFmtFrmWidth;
     357                 :          0 :     }
     358                 :            : 
     359                 :            : #ifdef DBG_UTIL
     360                 :            :     ::std::string toString() const;
     361                 :            : #endif
     362                 :            : };
     363                 :            : 
     364                 :            : }
     365                 :            : #endif // WW8_TABLE_INFO_HXX
     366                 :            : 
     367                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10