LCOV - code coverage report
Current view: top level - sw/inc - tblsel.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 30 0.0 %
Date: 2014-04-14 Functions: 0 28 0.0 %
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 SwUndoTblMerge;
      42             : class SwCellFrm;
      43             : 
      44             : typedef ::std::deque< SwCellFrm* > SwCellFrms;
      45             : 
      46             : struct CompareSwSelBoxes
      47             : {
      48           0 :     bool operator()(SwTableBox* const& lhs, SwTableBox* const& rhs) const
      49             :     {
      50           0 :         return lhs->GetSttIdx() < rhs->GetSttIdx();
      51             :     }
      52             : };
      53           0 : 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 SwTblSearchType;
      60             : namespace nsSwTblSearchType
      61             : {
      62             :     const SwTblSearchType TBLSEARCH_NONE = 0x1;       // No extension.
      63             :     const SwTblSearchType TBLSEARCH_ROW  = 0x2;       // Extend to rows.
      64             :     const SwTblSearchType TBLSEARCH_COL  = 0x3;       // Extend to columns.
      65             : 
      66             :     // As flag to the other values!
      67             :     const SwTblSearchType TBLSEARCH_PROTECT = 0x8;      // Collect protected boxes too.
      68             :     const SwTblSearchType TBLSEARCH_NO_UNION_CORRECT = 0x10; // Do not correct collected Union.
      69             : }
      70             : 
      71             : SW_DLLPUBLIC void GetTblSel( const SwCrsrShell& rShell, SwSelBoxes& rBoxes,
      72             :                 const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE );
      73             : 
      74             : void GetTblSel( const SwCursor& rCrsr, SwSelBoxes& rBoxes,
      75             :                 const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE );
      76             : 
      77             : // As before, but don't start from selection but from Start- EndFrms.
      78             : void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
      79             :                 SwSelBoxes& rBoxes, SwCellFrms* pCells,
      80             :                 const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE );
      81             : 
      82             : // As before but directly via PaMs.
      83             : void GetTblSelCrs( const SwCrsrShell& rShell, SwSelBoxes& rBoxes );
      84             : void GetTblSelCrs( const SwTableCursor& rTblCrsr, SwSelBoxes& rBoxes );
      85             : 
      86             : // Collect boxes relevant for auto sum.
      87             : sal_Bool GetAutoSumSel( const SwCrsrShell&, SwCellFrms& );
      88             : 
      89             : // Check if the SelBoxes contains protected Boxes.
      90             : sal_Bool HasProtectedCells( const SwSelBoxes& rBoxes );
      91             : 
      92             : // Check if selection is balanced.
      93             : sal_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 GetTblSel() and MakeTblCrsr()
      97             : // have always the same concept of the selection.
      98             : sal_Bool IsFrmInTblSel( 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, SwUndoTblMerge* 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             : sal_Bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam );
     112             : 
     113             : // Check if Split or InsertCol lead to a box becoming smaller than MINLAY.
     114             : sal_Bool CheckSplitCells( const SwCrsrShell& rShell, sal_uInt16 nDiv,
     115             :                         const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE );
     116             : sal_Bool CheckSplitCells( const SwCursor& rCrsr, sal_uInt16 nDiv,
     117             :                         const SwTblSearchType = nsSwTblSearchType::TBLSEARCH_NONE );
     118             : 
     119             : // For working on tab selection also for split tables.
     120             : class SwSelUnion
     121             : {
     122             :     SwRect   aUnion;        // The rectangle enclosing the selection.
     123             :     SwTabFrm *pTable;       // The (Follow-)Table for the Union.
     124             : 
     125             : public:
     126           0 :     SwSelUnion( const SwRect &rRect, SwTabFrm *pTab ) :
     127           0 :         aUnion( rRect ), pTable( pTab ) {}
     128             : 
     129             :     const SwRect&   GetUnion() const { return aUnion; }
     130           0 :           SwRect&   GetUnion()       { return aUnion; }
     131             :     const SwTabFrm *GetTable() const { return pTable; }
     132           0 :           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 != nsSwTblSearchType::TBLSEARCH_NONE
     142             : // the selection is extended in the given direction.
     143             : void MakeSelUnions( SwSelUnions&, const SwLayoutFrm *pStart,
     144             :                     const SwLayoutFrm *pEnd,
     145             :                     const SwTblSearchType = nsSwTblSearchType::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           0 : 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           0 :     _FndBox( SwTableBox* pB, _FndLine* pFL ) :
     167           0 :         pBox(pB), pUpper(pFL), pLineBefore( 0 ), pLineBehind( 0 ) {}
     168             : 
     169           0 :     const _FndLines&    GetLines() const    { return aLines; }
     170           0 :         _FndLines&      GetLines()          { return aLines; }
     171           0 :     const SwTableBox*   GetBox() const      { return pBox; }
     172           0 :         SwTableBox*     GetBox()            { return pBox; }
     173             :     const _FndLine*     GetUpper() const    { return pUpper; }
     174           0 :         _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,sal_Bool bAccTableDispose = sal_False );
     180             :     void MakeFrms( SwTable &rTable );
     181             :     void MakeNewFrms( SwTable &rTable, const sal_uInt16 nNumber,
     182             :                                        const sal_Bool bBehind );
     183             :     sal_Bool AreLinesToRestore( const SwTable &rTable ) const;
     184             : 
     185           0 :     void ClearLineBehind() { pLineBehind = 0; }
     186             : };
     187             : 
     188           0 : class _FndLine
     189             : {
     190             :     SwTableLine* pLine;
     191             :     _FndBoxes aBoxes;
     192             :     _FndBox* pUpper;
     193             : public:
     194           0 :     _FndLine(SwTableLine* pL, _FndBox* pFB=0) : pLine(pL), pUpper(pFB) {}
     195           0 :     const _FndBoxes&    GetBoxes() const    { return aBoxes; }
     196           0 :         _FndBoxes&      GetBoxes()          { return aBoxes; }
     197           0 :     const SwTableLine*  GetLine() const     { return pLine; }
     198           0 :         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           0 :     _FndPara( const SwSelBoxes& rBxs, _FndBox* pFB )
     212           0 :         : 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           0 :     _FndPara( const _FndPara& rPara, _FndLine* pFL )
     216           0 :         : 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.10