LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmltbli.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 15 66.7 %
Date: 2012-08-25 Functions: 8 11 72.7 %
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 _XMLTBLI_HXX
      30                 :            : #define _XMLTBLI_HXX
      31                 :            : 
      32                 :            : #include <xmloff/XMLTextTableContext.hxx>
      33                 :            : 
      34                 :            : // STL include
      35                 :            : #include <boost/unordered_map.hpp>
      36                 :            : #include <boost/ptr_container/ptr_vector.hpp>
      37                 :            : #include <vector>
      38                 :            : 
      39                 :            : class SwXMLImport;
      40                 :            : class SwTableNode;
      41                 :            : class SwTableBox;
      42                 :            : class SwTableLine;
      43                 :            : class SwStartNode;
      44                 :            : class SwTableBoxFmt;
      45                 :            : class SwTableLineFmt;
      46                 :            : class SwXMLTableCell_Impl;
      47                 :            : class SwXMLTableRow_Impl;
      48                 :            : typedef boost::ptr_vector<SwXMLTableRow_Impl> SwXMLTableRows_Impl;
      49                 :            : class SwXMLDDETableContext_Impl;
      50                 :            : class TableBoxIndexHasher;
      51                 :            : class TableBoxIndex;
      52                 :            : 
      53                 :            : namespace com { namespace sun { namespace star {
      54                 :            :     namespace text { class XTextContent; }
      55                 :            :     namespace text { class XTextCursor; }
      56                 :            : } } }
      57                 :            : 
      58                 :            : 
      59                 :            : 
      60                 :            : class SwXMLTableContext : public XMLTextTableContext
      61                 :            : {
      62                 :            :     ::rtl::OUString     aStyleName;
      63                 :            :     ::rtl::OUString     aDfltCellStyleName;
      64                 :            :     /// NB: this contains the xml:id only if this table is a subtable!
      65                 :            :     ::rtl::OUString     mXmlId;
      66                 :            : 
      67                 :            :     //! Holds basic information about a column's width.
      68                 :            :     struct ColumnWidthInfo {
      69                 :            :         sal_uInt16 width;      //!< Column width (absolute or relative).
      70                 :            :         bool   isRelative; //!< True for a relative width, false for absolute.
      71                 :         15 :         inline ColumnWidthInfo(sal_uInt16 wdth, bool isRel) : width(wdth), isRelative(isRel) {};
      72                 :            :     };
      73                 :            :     std::vector<ColumnWidthInfo> aColumnWidths;
      74                 :            :     std::vector<String> *pColumnDefaultCellStyleNames;
      75                 :            : 
      76                 :            :     ::com::sun::star::uno::Reference <
      77                 :            :         ::com::sun::star::text::XTextCursor > xOldCursor;
      78                 :            :     ::com::sun::star::uno::Reference <
      79                 :            :         ::com::sun::star::text::XTextContent > xTextContent;
      80                 :            : 
      81                 :            :     SwXMLTableRows_Impl *pRows;
      82                 :            : 
      83                 :            :     SwTableNode         *pTableNode;
      84                 :            :     SwTableBox          *pBox1;
      85                 :            :     const SwStartNode   *pSttNd1;
      86                 :            : 
      87                 :            :     SwTableBoxFmt       *pBoxFmt;
      88                 :            :     SwTableLineFmt      *pLineFmt;
      89                 :            : 
      90                 :            :     // hash map of shared format, indexed by the (XML) style name,
      91                 :            :     // the column width, and protection flag
      92                 :            :     typedef boost::unordered_map<TableBoxIndex,SwTableBoxFmt*,
      93                 :            :                           TableBoxIndexHasher> map_BoxFmt;
      94                 :            :     map_BoxFmt* pSharedBoxFormats;
      95                 :            : 
      96                 :            :     SvXMLImportContextRef   xParentTable;   // if table is a sub table
      97                 :            : 
      98                 :            :     SwXMLDDETableContext_Impl   *pDDESource;
      99                 :            : 
     100                 :            :     sal_Bool            bFirstSection : 1;
     101                 :            :     sal_Bool            bRelWidth : 1;
     102                 :            :     sal_Bool            bHasSubTables : 1;
     103                 :            : 
     104                 :            :     sal_uInt16              nHeaderRows;
     105                 :            :     sal_uInt32          nCurRow;
     106                 :            :     sal_uInt32          nCurCol;
     107                 :            :     sal_Int32           nWidth;
     108                 :            : 
     109                 :            :     SwTableBox *NewTableBox( const SwStartNode *pStNd,
     110                 :            :                              SwTableLine *pUpper );
     111                 :            :     SwTableBox *MakeTableBox( SwTableLine *pUpper,
     112                 :            :                               const SwXMLTableCell_Impl *pStartNode,
     113                 :            :                               sal_uInt32 nTopRow, sal_uInt32 nLeftCol,
     114                 :            :                               sal_uInt32 nBottomRow, sal_uInt32 nRightCol );
     115                 :            :     SwTableBox *MakeTableBox( SwTableLine *pUpper,
     116                 :            :                               sal_uInt32 nTopRow, sal_uInt32 nLeftCol,
     117                 :            :                               sal_uInt32 nBottomRow, sal_uInt32 nRightCol );
     118                 :            :     SwTableLine *MakeTableLine( SwTableBox *pUpper,
     119                 :            :                                 sal_uInt32 nTopRow, sal_uInt32 nLeftCol,
     120                 :            :                                 sal_uInt32 nBottomRow, sal_uInt32 nRightCol );
     121                 :            : 
     122                 :            :     void _MakeTable( SwTableBox *pBox=0 );
     123                 :            :     void MakeTable( SwTableBox *pBox, sal_Int32 nWidth );
     124                 :            :     void MakeTable();
     125                 :            : 
     126                 :            :     inline SwXMLTableContext *GetParentTable() const;
     127                 :            : 
     128                 :            :     const SwStartNode *GetPrevStartNode( sal_uInt32 nRow,
     129                 :            :                                          sal_uInt32 nCol ) const;
     130                 :            :     inline const SwStartNode *GetLastStartNode() const;
     131                 :            :     void FixRowSpan( sal_uInt32 nRow, sal_uInt32 nCol, sal_uInt32 nColSpan );
     132                 :            :     void ReplaceWithEmptyCell( sal_uInt32 nRow, sal_uInt32 nCol, bool bRows );
     133                 :            : 
     134                 :            :     /** sets the appropriate SwTblBoxFmt at pBox. */
     135                 :            :     SwTableBoxFmt* GetSharedBoxFormat(
     136                 :            :         SwTableBox* pBox,   /// the table box
     137                 :            :         const ::rtl::OUString& rStyleName, /// XML style name
     138                 :            :         sal_Int32 nColumnWidth,     /// width of column
     139                 :            :         sal_Bool bProtected,        /// is cell protected?
     140                 :            :         sal_Bool bMayShare, /// may the format be shared (no value, formula...)
     141                 :            :         sal_Bool& bNew,     /// true, if the format it not from the cache
     142                 :            :         sal_Bool* pModifyLocked );  /// if set, call pBox->LockModify() and return old lock status
     143                 :            : 
     144                 :            : public:
     145                 :            : 
     146                 :            :     TYPEINFO();
     147                 :            : 
     148                 :            :     SwXMLTableContext( SwXMLImport& rImport, sal_uInt16 nPrfx,
     149                 :            :                    const ::rtl::OUString& rLName,
     150                 :            :                 const ::com::sun::star::uno::Reference<
     151                 :            :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     152                 :            :     SwXMLTableContext( SwXMLImport& rImport, sal_uInt16 nPrfx,
     153                 :            :                    const ::rtl::OUString& rLName,
     154                 :            :                   const ::com::sun::star::uno::Reference<
     155                 :            :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
     156                 :            :                 SwXMLTableContext *pTable,
     157                 :            :                 const ::rtl::OUString& i_rXmlId );
     158                 :            : 
     159                 :            :     virtual ~SwXMLTableContext();
     160                 :            : 
     161                 :            :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
     162                 :            :                 const ::rtl::OUString& rLocalName,
     163                 :            :                 const ::com::sun::star::uno::Reference<
     164                 :            :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     165                 :            : 
     166                 :        543 :     SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
     167                 :            : 
     168                 :            :     void InsertColumn( sal_Int32 nWidth, sal_Bool bRelWidth,
     169                 :            :                        const ::rtl::OUString *pDfltCellStyleName = 0 );
     170                 :            :     sal_Int32 GetColumnWidth( sal_uInt32 nCol, sal_uInt32 nColSpan=1UL ) const;
     171                 :            :     ::rtl::OUString GetColumnDefaultCellStyleName( sal_uInt32 nCol ) const;
     172                 :            :     inline sal_uInt32 GetColumnCount() const;
     173                 :            :     inline sal_Bool HasColumnDefaultCellStyleNames() const;
     174                 :            : 
     175                 :        345 :     sal_Bool IsInsertCellPossible() const { return nCurCol < GetColumnCount(); }
     176                 :         18 :     sal_Bool IsInsertColPossible() const { return nCurCol < USHRT_MAX; }
     177                 :         69 :     sal_Bool IsInsertRowPossible() const { return nCurRow < USHRT_MAX; }
     178                 :       1179 :     sal_Bool IsValid() const { return pTableNode != 0; }
     179                 :            : 
     180                 :            :     void InsertCell( const ::rtl::OUString& rStyleName,
     181                 :            :                      sal_uInt32 nRowSpan=1U, sal_uInt32 nColSpan=1U,
     182                 :            :                      const SwStartNode *pStNd=0,
     183                 :            :                      const ::rtl::OUString & i_rXmlId = ::rtl::OUString(),
     184                 :            :                      SwXMLTableContext *pTable=0,
     185                 :            :                      sal_Bool bIsProtected = sal_False,
     186                 :            :                      const ::rtl::OUString *pFormula=0,
     187                 :            :                      sal_Bool bHasValue = sal_False,
     188                 :            :                      double fValue = 0.0,
     189                 :            :                      sal_Bool bTextValue = sal_False );
     190                 :            :     void InsertRow( const ::rtl::OUString& rStyleName,
     191                 :            :                     const ::rtl::OUString& rDfltCellStyleName,
     192                 :            :                     sal_Bool bInHead,
     193                 :            :                     const ::rtl::OUString & i_rXmlId = ::rtl::OUString() );
     194                 :            :     void FinishRow();
     195                 :            :     void InsertRepRows( sal_uInt32 nCount );
     196                 :            :     const SwXMLTableCell_Impl *GetCell( sal_uInt32 nRow, sal_uInt32 nCol ) const;
     197                 :            :     SwXMLTableCell_Impl *GetCell( sal_uInt32 nRow, sal_uInt32 nCol );
     198                 :            :     const SwStartNode *InsertTableSection( const SwStartNode *pPrevSttNd=0 );
     199                 :            : 
     200                 :            :     virtual void EndElement();
     201                 :            : 
     202                 :            :     virtual ::com::sun::star::uno::Reference <
     203                 :            :             ::com::sun::star::text::XTextContent > GetXTextContent() const;
     204                 :            : 
     205                 :          0 :     void SetHasSubTables( sal_Bool bNew ) { bHasSubTables = bNew; }
     206                 :            : };
     207                 :            : 
     208                 :          0 : inline SwXMLTableContext *SwXMLTableContext::GetParentTable() const
     209                 :            : {
     210                 :          0 :     return (SwXMLTableContext *)&xParentTable;
     211                 :            : }
     212                 :            : 
     213                 :       1596 : inline sal_uInt32 SwXMLTableContext::GetColumnCount() const
     214                 :            : {
     215                 :       1596 :     return aColumnWidths.size();
     216                 :            : }
     217                 :            : 
     218                 :          0 : inline const SwStartNode *SwXMLTableContext::GetLastStartNode() const
     219                 :            : {
     220                 :          0 :     return GetPrevStartNode( 0UL, GetColumnCount() );
     221                 :            : }
     222                 :            : 
     223                 :        294 : inline sal_Bool SwXMLTableContext::HasColumnDefaultCellStyleNames() const
     224                 :            : {
     225                 :        294 :     return pColumnDefaultCellStyleNames != 0;
     226                 :            : }
     227                 :            : 
     228                 :            : #endif
     229                 :            : 
     230                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10