LCOV - code coverage report
Current view: top level - svx/source/table - tablelayouter.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 7 7 100.0 %
Date: 2014-11-03 Functions: 7 7 100.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             : 
      20             : #ifndef INCLUDED_SVX_SOURCE_TABLE_TABLELAYOUTER_HXX
      21             : #define INCLUDED_SVX_SOURCE_TABLE_TABLELAYOUTER_HXX
      22             : 
      23             : #include <com/sun/star/container/XIndexAccess.hpp>
      24             : #include <com/sun/star/text/WritingMode.hpp>
      25             : #include <com/sun/star/table/XTable.hpp>
      26             : #include <sal/types.h>
      27             : #include <basegfx/range/b2irectangle.hxx>
      28             : #include <basegfx/tuple/b2ituple.hxx>
      29             : #include <boost/shared_ptr.hpp>
      30             : #include <vector>
      31             : #include <map>
      32             : 
      33             : #include "svx/svdotable.hxx"
      34             : 
      35             : class Rectangle;
      36             : 
      37             : 
      38             : 
      39             : namespace editeng {
      40             :     class SvxBorderLine;
      41             : }
      42             : 
      43             : namespace sdr { namespace table {
      44             : 
      45             : /** returns true if the cell(nMergedCol,nMergedRow) is merged with other cells.
      46             :     the returned cell( rOriginCol, rOriginRow ) is the origin( top left cell ) of the merge.
      47             : */
      48             : bool findMergeOrigin( const TableModelRef& xTable, sal_Int32 nMergedCol, sal_Int32 nMergedRow, sal_Int32& rOriginCol, sal_Int32& rOriginRow );
      49             : 
      50             : typedef std::vector< editeng::SvxBorderLine* > BorderLineVector;
      51             : typedef std::vector< BorderLineVector > BorderLineMap;
      52             : 
      53             : 
      54             : // TableModel
      55             : 
      56             : 
      57             : class TableLayouter
      58             : {
      59             : public:
      60             :     TableLayouter( const TableModelRef& xTableModel );
      61             :     virtual ~TableLayouter();
      62             : 
      63             :     /** try to fit the table into the given rectangle.
      64             :         If the rectangle is to small, it will be grown to fit the table.
      65             : 
      66             :         if bFitWidth or bFitHeight is set, the layouter tries to scale
      67             :         the rows and/or columns to the given area. The result my be bigger
      68             :         to fulfill constrains.
      69             : 
      70             :         if bFitWidth or bFitHeight is set, the model is changed.
      71             :     */
      72             :     void LayoutTable( ::Rectangle& rRectangle, bool bFitWidth, bool bFitHeight );
      73             : 
      74             :     void UpdateBorderLayout();
      75             : 
      76             :     bool getCellArea( const CellRef& xCell, const CellPos& rPos, basegfx::B2IRectangle& rArea ) const;
      77             : 
      78       15596 :     ::sal_Int32 getRowCount() const { return static_cast< ::sal_Int32 >( maRows.size() ); }
      79       15442 :     ::sal_Int32 getColumnCount() const { return static_cast< ::sal_Int32 >( maColumns.size() ); }
      80             :     sal_Int32 getRowHeight( sal_Int32 nRow ) const;
      81             : 
      82             :     sal_Int32 getColumnWidth( sal_Int32 nColumn ) const;
      83             : 
      84             :     sal_Int32 getMinimumColumnWidth( sal_Int32 nColumn );
      85             : 
      86             :     /** checks if the given edge is visible.
      87             :         Edges between merged cells are not visible.
      88             :     */
      89             :     bool isEdgeVisible( sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal ) const;
      90             : 
      91             :     /** returns the requested borderline in rpBorderLine or a null pointer if there is no border at this edge */
      92             :     editeng::SvxBorderLine* getBorderLine( sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal )const;
      93             : 
      94             :     void updateCells( ::Rectangle& rRectangle );
      95             : 
      96             :     sal_Int32 getHorizontalEdge( int nEdgeY, sal_Int32* pnMin = 0, sal_Int32* pnMax = 0 );
      97             :     sal_Int32 getVerticalEdge( int nEdgeX , sal_Int32* pnMin = 0, sal_Int32* pnMax = 0);
      98             : 
      99             :     void DistributeColumns( ::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol );
     100             :     void DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow );
     101             : 
     102             : private:
     103             :     CellRef getCell( const CellPos& rPos ) const;
     104             :     basegfx::B2ITuple getCellSize( const CellRef& xCell, const CellPos& rPos ) const;
     105             : 
     106             :     void LayoutTableWidth( ::Rectangle& rArea, bool bFit );
     107             :     void LayoutTableHeight( ::Rectangle& rArea, bool bFit );
     108             : 
     109       10288 :     inline bool isValidColumn( sal_Int32 nColumn ) const { return (nColumn >= 0) && (nColumn < static_cast<sal_Int32>( maColumns.size())); }
     110       10288 :     inline bool isValidRow( sal_Int32 nRow ) const { return (nRow >= 0) && (nRow < static_cast<sal_Int32>( maRows.size())); }
     111       10288 :     inline bool isValid( const CellPos& rPos ) const { return isValidColumn( rPos.mnCol ) && isValidRow( rPos.mnRow ); }
     112             : 
     113             :     void ClearBorderLayout();
     114             :     void ClearBorderLayout(BorderLineMap& rMap);
     115             :     void ResizeBorderLayout();
     116             :     void ResizeBorderLayout( BorderLineMap& rMap );
     117             : 
     118             :     void SetBorder( sal_Int32 nCol, sal_Int32 nRow, bool bHorizontal, const editeng::SvxBorderLine* pLine );
     119             : 
     120             :     static bool HasPriority( const editeng::SvxBorderLine* pThis, const editeng::SvxBorderLine* pOther );
     121             : 
     122             :     struct Layout
     123             :     {
     124             :         sal_Int32 mnPos;
     125             :         sal_Int32 mnSize;
     126             :         sal_Int32 mnMinSize;
     127             : 
     128         596 :         Layout() : mnPos( 0 ), mnSize( 0 ), mnMinSize( 0 ) {}
     129         872 :         void clear() { mnPos = 0; mnSize = 0; mnMinSize = 0; }
     130             :     };
     131             :     typedef std::vector< Layout > LayoutVector;
     132             : 
     133             :     sal_Int32 distribute( LayoutVector& rLayouts, sal_Int32 nDistribute );
     134             : 
     135             :     TableModelRef mxTable;
     136             :     LayoutVector maRows;
     137             :     LayoutVector maColumns;
     138             : 
     139             :     BorderLineMap maHorizontalBorders;
     140             :     BorderLineMap maVerticalBorders;
     141             : 
     142             :     const OUString msSize;
     143             : };
     144             : 
     145             : } }
     146             : 
     147             : #endif
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10