LCOV - code coverage report
Current view: top level - sw/source/filter/inc - wrtswtbl.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 45 0.0 %
Date: 2014-04-14 Functions: 0 34 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_SW_SOURCE_FILTER_INC_WRTSWTBL_HXX
      20             : #define INCLUDED_SW_SOURCE_FILTER_INC_WRTSWTBL_HXX
      21             : 
      22             : #include <tools/solar.h>
      23             : #include <tools/color.hxx>
      24             : #include <boost/ptr_container/ptr_vector.hpp>
      25             : #include <o3tl/sorted_vector.hxx>
      26             : 
      27             : #include <swdllapi.h>
      28             : 
      29             : class SwTableBox;
      30             : class SwTableLine;
      31             : class SwTableLines;
      32             : class SwHTMLTableLayout;
      33             : class SvxBrushItem;
      34             : 
      35             : namespace editeng { class SvxBorderLine; }
      36             : 
      37             : //       Code aus dem HTML-Filter fuers schreiben von Tabellen
      38             : 
      39             : #define COLFUZZY 20
      40             : #define ROWFUZZY 20
      41             : #define COL_DFLT_WIDTH ((2*COLFUZZY)+1)
      42             : #define ROW_DFLT_HEIGHT (2*ROWFUZZY)+1
      43             : 
      44             : class SW_DLLPUBLIC SwWriteTableCell
      45             : {
      46             :     const SwTableBox *pBox;     // SwTableBox der Zelle
      47             :     const SvxBrushItem *pBackground;    // geerbter Hintergrund einer Zeile
      48             : 
      49             :     long nHeight;               // fixe/Mindest-Hoehe der Zeile
      50             : 
      51             :     sal_uInt32 nWidthOpt;          // Breite aus Option;
      52             : 
      53             :     sal_uInt16 nRow;                // Start-Zeile
      54             :     sal_uInt16 nCol;                // Start-Spalte
      55             : 
      56             :     sal_uInt16 nRowSpan;            // ueberspannte Zeilen
      57             :     sal_uInt16 nColSpan;            // ueberspannte Spalten
      58             : 
      59             :     bool bPrcWidthOpt;
      60             : 
      61             : public:
      62             : 
      63           0 :     SwWriteTableCell(const SwTableBox *pB, sal_uInt16 nR, sal_uInt16 nC, sal_uInt16 nRSpan,
      64             :         sal_uInt16 nCSpan, long nHght, const SvxBrushItem *pBGround)
      65             :     : pBox( pB ), pBackground( pBGround ), nHeight( nHght ), nWidthOpt( 0 ),
      66             :     nRow( nR ), nCol( nC ), nRowSpan( nRSpan ), nColSpan( nCSpan ),
      67           0 :     bPrcWidthOpt( false )
      68           0 :     {}
      69             : 
      70           0 :     const SwTableBox *GetBox() const { return pBox; }
      71             : 
      72           0 :     sal_uInt16 GetRow() const { return nRow; }
      73           0 :     sal_uInt16 GetCol() const { return nCol; }
      74             : 
      75           0 :     sal_uInt16 GetRowSpan() const { return nRowSpan; }
      76           0 :     sal_uInt16 GetColSpan() const { return nColSpan; }
      77             : 
      78           0 :     long GetHeight() const { return nHeight; }
      79             :     sal_Int16 GetVertOri() const;
      80             : 
      81           0 :     const SvxBrushItem *GetBackground() const { return pBackground; }
      82             : 
      83           0 :     void SetWidthOpt( sal_uInt16 nWidth, bool bPrc )
      84             :     {
      85           0 :         nWidthOpt = nWidth; bPrcWidthOpt = bPrc;
      86           0 :     }
      87             : 
      88           0 :     sal_uInt32 GetWidthOpt() const { return nWidthOpt; }
      89           0 :     bool HasPrcWidthOpt() const { return bPrcWidthOpt; }
      90             : };
      91             : 
      92             : typedef boost::ptr_vector<SwWriteTableCell> SwWriteTableCells;
      93             : 
      94           0 : class SW_DLLPUBLIC SwWriteTableRow
      95             : {
      96             :     SwWriteTableCells aCells;       // Alle Zellen der Rows
      97             :     const SvxBrushItem *pBackground;// Hintergrund
      98             : 
      99             :     long nPos;                  // End-Position (twips) der Zeile
     100             :     bool mbUseLayoutHeights;
     101             : 
     102             :     // Forbidden and not implemented.
     103             :     SwWriteTableRow();
     104             : 
     105             :     SwWriteTableRow & operator= (const SwWriteTableRow &);
     106             : 
     107             : protected:
     108             :     // GCC >= 3.4 needs accessible T (const T&) to pass T as const T& argument.
     109             :     SwWriteTableRow( const SwWriteTableRow & );
     110             : 
     111             : public:
     112             : 
     113             :     sal_uInt16 nTopBorder;              // Dicke der oberen/unteren Umrandugen
     114             :     sal_uInt16 nBottomBorder;
     115             : 
     116             :     bool bTopBorder : 1;            // Welche Umrandungen sind da?
     117             :     bool bBottomBorder : 1;
     118             : 
     119             :     SwWriteTableRow( long nPos, bool bUseLayoutHeights );
     120             : 
     121             :     SwWriteTableCell *AddCell( const SwTableBox *pBox,
     122             :                                  sal_uInt16 nRow, sal_uInt16 nCol,
     123             :                                  sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
     124             :                                  long nHeight,
     125             :                                  const SvxBrushItem *pBackground );
     126             : 
     127           0 :     void SetBackground( const SvxBrushItem *pBGround )
     128             :     {
     129           0 :         pBackground = pBGround;
     130           0 :     }
     131           0 :     const SvxBrushItem *GetBackground() const { return pBackground; }
     132             : 
     133           0 :     bool HasTopBorder() const                   { return bTopBorder; }
     134           0 :     bool HasBottomBorder() const                { return bBottomBorder; }
     135             : 
     136             :     long GetPos() const                         { return nPos; }
     137           0 :     const SwWriteTableCells& GetCells() const   { return aCells; }
     138             : 
     139             :     inline bool operator==( const SwWriteTableRow& rRow ) const;
     140             :     inline bool operator<( const SwWriteTableRow& rRow2 ) const;
     141             : };
     142             : 
     143             : inline bool SwWriteTableRow::operator==( const SwWriteTableRow& rRow ) const
     144             : {
     145             :     // etwas Unschaerfe zulassen
     146             :     return (nPos >= rRow.nPos ?  nPos - rRow.nPos : rRow.nPos - nPos ) <=
     147             :         (mbUseLayoutHeights ? 0 : ROWFUZZY);
     148             : }
     149             : 
     150           0 : inline bool SwWriteTableRow::operator<( const SwWriteTableRow& rRow ) const
     151             : {
     152             :     // Da wir hier nur die Wahrheits-Grade 0 und 1 kennen, lassen wir lieber
     153             :     // auch nicht zu, dass x==y und x<y gleichzeitig gilt ;-)
     154           0 :     return nPos < rRow.nPos - (mbUseLayoutHeights ? 0 : ROWFUZZY);
     155             : }
     156             : 
     157           0 : class SwWriteTableRows : public o3tl::sorted_vector<SwWriteTableRow*, o3tl::less_ptr_to<SwWriteTableRow> > {
     158             : public:
     159           0 :     ~SwWriteTableRows() { DeleteAndDestroyAll(); }
     160             : };
     161             : 
     162             : class SW_DLLPUBLIC SwWriteTableCol
     163             : {
     164             :     sal_uInt32 nPos;                        // End Position der Spalte
     165             : 
     166             :     sal_uInt32 nWidthOpt;
     167             : 
     168             :     bool bRelWidthOpt : 1;
     169             :     bool bOutWidth : 1;                 // Spaltenbreite ausgeben?
     170             : 
     171             : public:
     172             :     bool bLeftBorder : 1;               // Welche Umrandungen sind da?
     173             :     bool bRightBorder : 1;
     174             : 
     175             :     SwWriteTableCol( sal_uInt32 nPosition );
     176             : 
     177           0 :     sal_uInt32 GetPos() const                       { return nPos; }
     178             : 
     179           0 :     bool HasLeftBorder() const                  { return bLeftBorder; }
     180             : 
     181           0 :     bool HasRightBorder() const                 { return bRightBorder; }
     182             : 
     183           0 :     void SetOutWidth( bool bSet )               { bOutWidth = bSet; }
     184             : 
     185             :     inline bool operator==( const SwWriteTableCol& rCol ) const;
     186             :     inline bool operator<( const SwWriteTableCol& rCol ) const;
     187             : 
     188           0 :     void SetWidthOpt( sal_uInt32 nWidth, bool bRel )
     189             :     {
     190           0 :         nWidthOpt = nWidth; bRelWidthOpt = bRel;
     191           0 :     }
     192           0 :     sal_uInt32 GetWidthOpt() const                 { return nWidthOpt; }
     193           0 :     bool HasRelWidthOpt() const                 { return bRelWidthOpt; }
     194             : };
     195             : 
     196             : inline bool SwWriteTableCol::operator==( const SwWriteTableCol& rCol ) const
     197             : {
     198             :     // etwas Unschaerfe zulassen
     199             :     return (nPos >= rCol.nPos ? nPos - rCol.nPos
     200             :                                      : rCol.nPos - nPos ) <= COLFUZZY;
     201             : }
     202             : 
     203           0 : inline bool SwWriteTableCol::operator<( const SwWriteTableCol& rCol ) const
     204             : {
     205             :     // Da wir hier nur die Wahrheits-Grade 0 und 1 kennen, lassen wir lieber
     206             :     // auch nicht zu, dass x==y und x<y gleichzeitig gilt ;-)
     207           0 :     return nPos < rCol.nPos - COLFUZZY;
     208             : }
     209             : 
     210             : struct SwWriteTableColLess {
     211           0 :     bool operator()(SwWriteTableCol const * lhs, SwWriteTableCol const * rhs) {
     212           0 :         return lhs->GetPos() < rhs->GetPos();
     213             :     }
     214             : };
     215             : 
     216           0 : class SwWriteTableCols : public o3tl::sorted_vector<SwWriteTableCol*, SwWriteTableColLess> {
     217             : public:
     218           0 :     ~SwWriteTableCols() { DeleteAndDestroyAll(); }
     219             : };
     220             : 
     221             : class SW_DLLPUBLIC SwWriteTable
     222             : {
     223             : protected:
     224             :     SwWriteTableCols aCols; // alle Spalten
     225             :     SwWriteTableRows aRows; // alle Zellen
     226             : 
     227             :     sal_uInt32 nBorderColor;        // Umrandungsfarbe
     228             : 
     229             :     sal_uInt16 nCellSpacing;        // Dicke der inneren Umrandung
     230             :     sal_uInt16 nCellPadding;        // Absatnd Umrandung-Inhalt
     231             : 
     232             :     sal_uInt16 nBorder;             // Dicke der ausseren Umrandung
     233             :     sal_uInt16 nInnerBorder;        // Dicke der inneren Umrandung
     234             :     sal_uInt32 nBaseWidth;            // Bezugsgroesse fur Breiten SwFmtFrmSize
     235             : 
     236             :     sal_uInt16 nHeadEndRow;         // letzte Zeile des Tabellen-Kopfes
     237             : 
     238             :     sal_uInt16 nLeftSub;
     239             :     sal_uInt16 nRightSub;
     240             : 
     241             :     sal_uInt32 nTabWidth;              // Absolute/Relative Breite der Tabelle
     242             : 
     243             :     bool bRelWidths : 1;        // Breiten relativ ausgeben?
     244             :     bool bUseLayoutHeights : 1; // Layout zur Hoehenbestimmung nehmen?
     245             : #ifdef DBG_UTIL
     246             :     bool m_bGetLineHeightCalled : 1;
     247             : #endif
     248             : 
     249             :     bool bColsOption : 1;
     250             :     bool bColTags : 1;
     251             :     bool bLayoutExport : 1;
     252             :     bool bCollectBorderWidth : 1;
     253             : 
     254             :     virtual sal_Bool ShouldExpandSub( const SwTableBox *pBox,
     255             :                                 sal_Bool bExpandedBefore, sal_uInt16 nDepth ) const;
     256             : 
     257             :     void CollectTableRowsCols( long nStartRPos, sal_uInt32 nStartCPos,
     258             :                                long nParentLineHeight,
     259             :                                sal_uInt32 nParentLineWidth,
     260             :                                const SwTableLines& rLines,
     261             :                                sal_uInt16 nDepth );
     262             : 
     263             :     void FillTableRowsCols( long nStartRPos, sal_uInt16 nStartRow,
     264             :                             sal_uInt32 nStartCPos, sal_uInt16 nStartCol,
     265             :                             long nParentLineHeight,
     266             :                             sal_uInt32 nParentLineWidth,
     267             :                             const SwTableLines& rLines,
     268             :                             const SvxBrushItem* pLineBrush,
     269             :                             sal_uInt16 nDepth,
     270             :                             sal_uInt16 nNumOfHeaderRows );
     271             : 
     272             :     void MergeBorders( const editeng::SvxBorderLine* pBorderLine, bool bTable );
     273             : 
     274             :     sal_uInt16 MergeBoxBorders(const SwTableBox *pBox, size_t nRow, size_t nCol,
     275             :                             sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
     276             :                             sal_uInt16 &rTopBorder, sal_uInt16 &rBottomBorder );
     277             : 
     278           0 :     sal_uInt32 GetBaseWidth() const { return nBaseWidth; }
     279             : 
     280           0 :     bool HasRelWidths() const { return bRelWidths; }
     281             : 
     282             : public:
     283             :     static sal_uInt32 GetBoxWidth( const SwTableBox *pBox );
     284             : 
     285             :     sal_uInt32 GetRawWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) const;
     286             :     sal_uInt16 GetAbsWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) const;
     287             :     sal_uInt16 GetRelWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) const;
     288             :     sal_uInt16 GetPrcWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) const;
     289             : 
     290             :     long GetAbsHeight(long nRawWidth, size_t nRow, sal_uInt16 nRowSpan) const;
     291             : 
     292             : protected:
     293             :     long GetLineHeight( const SwTableLine *pLine );
     294             :     long GetLineHeight( const SwTableBox *pBox ) const;
     295             :     const SvxBrushItem *GetLineBrush( const SwTableBox *pBox,
     296             :                                       SwWriteTableRow *pRow );
     297             : 
     298             :     sal_uInt16 GetLeftSpace( sal_uInt16 nCol ) const;
     299             :     sal_uInt16 GetRightSpace(size_t nCol, sal_uInt16 nColSpan) const;
     300             : 
     301             : public:
     302             :     SwWriteTable( const SwTableLines& rLines, long nWidth, sal_uInt32 nBWidth,
     303             :                     bool bRel, sal_uInt16 nMaxDepth = USHRT_MAX,
     304             :                     sal_uInt16 nLeftSub=0, sal_uInt16 nRightSub=0, sal_uInt32 nNumOfRowsToRepeat=0 );
     305             :     SwWriteTable( const SwHTMLTableLayout *pLayoutInfo );
     306             :     virtual ~SwWriteTable();
     307             : 
     308             :     const SwWriteTableCols& GetCols() const { return aCols; }
     309           0 :     const SwWriteTableRows& GetRows() const { return aRows; }
     310             : };
     311             : 
     312             : #endif
     313             : 
     314             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10