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

Generated by: LCOV version 1.10