LCOV - code coverage report
Current view: top level - sw/inc - tblsel.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 24 31 77.4 %
Date: 2015-06-13 12:38:46 Functions: 21 29 72.4 %
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_INC_TBLSEL_HXX
      20             : #define INCLUDED_SW_INC_TBLSEL_HXX
      21             : 
      22             : #include <swtable.hxx>
      23             : #include <swrect.hxx>
      24             : #include "swdllapi.h"
      25             : 
      26             : #include <deque>
      27             : #include <boost/ptr_container/ptr_vector.hpp>
      28             : #include <o3tl/sorted_vector.hxx>
      29             : 
      30             : class SwCrsrShell;
      31             : class SwCursor;
      32             : class SwTableCursor;
      33             : class SwFrm;
      34             : class SwTabFrm;
      35             : class SwTableBox;
      36             : class SwTableLine;
      37             : class SwLayoutFrm;
      38             : class SwPaM;
      39             : class SwNode;
      40             : class SwTable;
      41             : class SwUndoTableMerge;
      42             : class SwCellFrm;
      43             : 
      44             : typedef ::std::deque< SwCellFrm* > SwCellFrms;
      45             : 
      46             : struct CompareSwSelBoxes
      47             : {
      48       13143 :     bool operator()(SwTableBox* const& lhs, SwTableBox* const& rhs) const
      49             :     {
      50       13143 :         return lhs->GetSttIdx() < rhs->GetSttIdx();
      51             :     }
      52             : };
      53        1604 : class SwSelBoxes : public o3tl::sorted_vector<SwTableBox*, CompareSwSelBoxes> {};
      54             : 
      55             : // Collects all boxes in table that are selected.
      56             : // Selection gets extended in given direction according to enum-parameter.
      57             : // Boxes are collected via the Layout; works correctly if tables are split.
      58             : // (Cf. MakeSelUnions().)
      59             : typedef sal_uInt16 SwTableSearchType;
      60             : namespace nsSwTableSearchType
      61             : {
      62             :     const SwTableSearchType TBLSEARCH_NONE = 0x1;       // No extension.
      63             :     const SwTableSearchType TBLSEARCH_ROW  = 0x2;       // Extend to rows.
      64             :     const SwTableSearchType TBLSEARCH_COL  = 0x3;       // Extend to columns.
      65             : 
      66             :     // As flag to the other values!
      67             :     const SwTableSearchType TBLSEARCH_PROTECT = 0x8;      // Collect protected boxes too.
      68             :     const SwTableSearchType TBLSEARCH_NO_UNION_CORRECT = 0x10; // Do not correct collected Union.
      69             : }
      70             : 
      71             : SW_DLLPUBLIC void GetTableSel( const SwCrsrShell& rShell, SwSelBoxes& rBoxes,
      72             :                 const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
      73             : 
      74             : void GetTableSel( const SwCursor& rCrsr, SwSelBoxes& rBoxes,
      75             :                 const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
      76             : 
      77             : // As before, but don't start from selection but from Start- EndFrms.
      78             : void GetTableSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
      79             :                 SwSelBoxes& rBoxes, SwCellFrms* pCells,
      80             :                 const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
      81             : 
      82             : // As before but directly via PaMs.
      83             : void GetTableSelCrs( const SwCrsrShell& rShell, SwSelBoxes& rBoxes );
      84             : void GetTableSelCrs( const SwTableCursor& rTableCrsr, SwSelBoxes& rBoxes );
      85             : 
      86             : // Collect boxes relevant for auto sum.
      87             : bool GetAutoSumSel( const SwCrsrShell&, SwCellFrms& );
      88             : 
      89             : // Check if the SelBoxes contains protected Boxes.
      90             : bool HasProtectedCells( const SwSelBoxes& rBoxes );
      91             : 
      92             : // Check if selection is balanced.
      93             : bool ChkChartSel( const SwNode& rSttNd, const SwNode& rEndNd);
      94             : 
      95             : // Check if cell is part of SSelection.
      96             : // (Became a function, in order to make sure that GetTableSel() and MakeTableCrsr()
      97             : // have always the same concept of the selection.
      98             : bool IsFrmInTableSel( const SwRect& rUnion, const SwFrm* pCell );
      99             : 
     100             : // Determine boxes to be merged.
     101             : // In this process the rectangle gets "adapted" on the base of the layout,
     102             : // i.e. boxes are added if some overlap at the sides.
     103             : // Additionally a new box is created and filled with the relevant content.
     104             : void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes,
     105             :                   SwTableBox** ppMergeBox, SwUndoTableMerge* pUndo = 0 );
     106             : 
     107             : // Check if selected boxes allow for a valid merge.
     108             : sal_uInt16 CheckMergeSel( const SwPaM& rPam );
     109             : sal_uInt16 CheckMergeSel( const SwSelBoxes& rBoxes );
     110             : 
     111             : bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam );
     112             : 
     113             : // Check if Split or InsertCol lead to a box becoming smaller than MINLAY.
     114             : bool CheckSplitCells( const SwCrsrShell& rShell, sal_uInt16 nDiv,
     115             :                         const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
     116             : bool CheckSplitCells( const SwCursor& rCrsr, sal_uInt16 nDiv,
     117             :                         const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
     118             : 
     119             : // For working on tab selection also for split tables.
     120           0 : class SwSelUnion
     121             : {
     122             :     SwRect   aUnion;        // The rectangle enclosing the selection.
     123             :     SwTabFrm *pTable;       // The (Follow-)Table for the Union.
     124             : 
     125             : public:
     126          31 :     SwSelUnion( const SwRect &rRect, SwTabFrm *pTab ) :
     127          31 :         aUnion( rRect ), pTable( pTab ) {}
     128             : 
     129             :     const SwRect&   GetUnion() const { return aUnion; }
     130          36 :           SwRect&   GetUnion()       { return aUnion; }
     131             :     const SwTabFrm *GetTable() const { return pTable; }
     132          31 :           SwTabFrm *GetTable()       { return pTable; }
     133             : };
     134             : 
     135             : // Determines tables affected by a table selection and union rectangles
     136             : // of the selection (also for split tables)
     137             : typedef boost::ptr_vector<SwSelUnion> SwSelUnions;
     138             : 
     139             : // Gets the tables involved in a table selection and the union-rectangles of the selections
     140             : // - also for split tables.
     141             : // If a parameter is passed that != nsSwTableSearchType::TBLSEARCH_NONE
     142             : // the selection is extended in the given direction.
     143             : void MakeSelUnions( SwSelUnions&, const SwLayoutFrm *pStart,
     144             :                     const SwLayoutFrm *pEnd,
     145             :                     const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
     146             : 
     147             : // These classes copy the current table selections (rBoxes) into a
     148             : // separate structure while keeping the table structure.
     149             : 
     150             : class _FndBox;
     151             : class _FndLine;
     152             : 
     153             : typedef boost::ptr_vector<_FndBox> _FndBoxes;
     154             : typedef boost::ptr_vector<_FndLine> _FndLines;
     155             : 
     156          84 : class _FndBox
     157             : {
     158             :     SwTableBox* pBox;
     159             :     _FndLines aLines;
     160             :     _FndLine* pUpper;
     161             : 
     162             :     SwTableLine *pLineBefore;   // For deleting/restoring the layout.
     163             :     SwTableLine *pLineBehind;
     164             : 
     165             : public:
     166          84 :     _FndBox( SwTableBox* pB, _FndLine* pFL ) :
     167          84 :         pBox(pB), pUpper(pFL), pLineBefore( 0 ), pLineBehind( 0 ) {}
     168             : 
     169         208 :     const _FndLines&    GetLines() const    { return aLines; }
     170          73 :         _FndLines&      GetLines()          { return aLines; }
     171         380 :     const SwTableBox*   GetBox() const      { return pBox; }
     172          10 :         SwTableBox*     GetBox()            { return pBox; }
     173             :     const _FndLine*     GetUpper() const    { return pUpper; }
     174           7 :         _FndLine*       GetUpper()          { return pUpper; }
     175             : 
     176             :     void SetTableLines( const SwSelBoxes &rBoxes, const SwTable &rTable );
     177             :     void SetTableLines( const SwTable &rTable );
     178             :     //Add an input param to identify if acc table should be disposed
     179             :     void DelFrms ( SwTable &rTable, bool bAccTableDispose = false );
     180             :     void MakeFrms( SwTable &rTable );
     181             :     void MakeNewFrms( SwTable &rTable, const sal_uInt16 nNumber,
     182             :                                        const bool bBehind );
     183             :     bool AreLinesToRestore( const SwTable &rTable ) const;
     184             : 
     185           0 :     void ClearLineBehind() { pLineBehind = 0; }
     186             : };
     187             : 
     188          33 : class _FndLine
     189             : {
     190             :     SwTableLine* pLine;
     191             :     _FndBoxes aBoxes;
     192             :     _FndBox* pUpper;
     193             : public:
     194          33 :     _FndLine(SwTableLine* pL, _FndBox* pFB=0) : pLine(pL), pUpper(pFB) {}
     195         120 :     const _FndBoxes&    GetBoxes() const    { return aBoxes; }
     196         126 :         _FndBoxes&      GetBoxes()          { return aBoxes; }
     197           0 :     const SwTableLine*  GetLine() const     { return pLine; }
     198         140 :         SwTableLine*    GetLine()           { return pLine; }
     199             :     const _FndBox*      GetUpper() const    { return pUpper; }
     200           0 :         _FndBox*        GetUpper()          { return pUpper; }
     201             : 
     202           0 :     void SetUpper( _FndBox* pUp ) { pUpper = pUp; }
     203             : };
     204             : 
     205             : struct _FndPara
     206             : {
     207             :     const SwSelBoxes& rBoxes;
     208             :     _FndLine* pFndLine;
     209             :     _FndBox* pFndBox;
     210             : 
     211          10 :     _FndPara( const SwSelBoxes& rBxs, _FndBox* pFB )
     212          10 :         : rBoxes(rBxs), pFndLine(0), pFndBox(pFB) {}
     213           0 :     _FndPara( const _FndPara& rPara, _FndBox* pFB )
     214           0 :         : rBoxes(rPara.rBoxes), pFndLine(rPara.pFndLine), pFndBox(pFB) {}
     215          33 :     _FndPara( const _FndPara& rPara, _FndLine* pFL )
     216          33 :         : rBoxes(rPara.rBoxes), pFndLine(pFL), pFndBox(rPara.pFndBox) {}
     217             : };
     218             : 
     219             : SW_DLLPUBLIC void ForEach_FndLineCopyCol(SwTableLines& rLines, _FndPara* pFndPara );
     220             : 
     221             : #endif // INCLUDED_SW_INC_TBLSEL_HXX
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11