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

Generated by: LCOV version 1.11