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

Generated by: LCOV version 1.10