LCOV - code coverage report
Current view: top level - libreoffice/svx/source/table - tablelayouter.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 8 100.0 %
Date: 2012-12-27 Functions: 8 8 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 _SVX_TABLE_TABLELAYOUTER_HXX_
      21             : #define _SVX_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 <basegfx/range/b2irectangle.hxx>
      27             : #include <basegfx/tuple/b2ituple.hxx>
      28             : #include <tools/gen.hxx>
      29             : #include <boost/shared_ptr.hpp>
      30             : #include <vector>
      31             : #include <map>
      32             : 
      33             : #include "svx/svdotable.hxx"
      34             : 
      35             : // -----------------------------------------------------------------------------
      36             : 
      37             : namespace editeng {
      38             :     class SvxBorderLine;
      39             : }
      40             : 
      41             : namespace sdr { namespace table {
      42             : 
      43             : /** returns true if the cell(nMergedCol,nMergedRow) is merged with other cells.
      44             :     the returned cell( rOriginCol, rOriginRow ) is the origin( top left cell ) of the merge.
      45             : */
      46             : bool findMergeOrigin( const TableModelRef& xTable, sal_Int32 nMergedCol, sal_Int32 nMergedRow, sal_Int32& rOriginCol, sal_Int32& rOriginRow );
      47             : 
      48             : typedef std::vector< editeng::SvxBorderLine* > BorderLineVector;
      49             : typedef std::vector< BorderLineVector > BorderLineMap;
      50             : 
      51             : // -----------------------------------------------------------------------------
      52             : // TableModel
      53             : // -----------------------------------------------------------------------------
      54             : 
      55             : class TableLayouter
      56             : {
      57             : public:
      58             :     TableLayouter( const TableModelRef& xTableModel );
      59             :     virtual ~TableLayouter();
      60             : 
      61             :     /** try to fit the table into the given rectangle.
      62             :         If the rectangle is to small, it will be grown to fit the table.
      63             : 
      64             :         if bFitWidth or bFitHeight is set, the layouter tries to scale
      65             :         the rows and/or columns to the given area. The result my be bigger
      66             :         to fullfill constrains.
      67             : 
      68             :         if bFitWidth or bFitHeight is set, the model is changed.
      69             :     */
      70             :     void LayoutTable( ::Rectangle& rRectangle, bool bFitWidth, bool bFitHeight );
      71             : 
      72             :     void UpdateBorderLayout();
      73             : 
      74             :     basegfx::B2ITuple getCellSize( const CellPos& rPos ) const;
      75             :     bool getCellArea( const CellRef& xCell, basegfx::B2IRectangle& rArea ) const;
      76             :     bool getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rArea ) const;
      77             : 
      78        3780 :     ::sal_Int32 getRowCount() const { return static_cast< ::sal_Int32 >( maRows.size() ); }
      79        3721 :     ::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        4250 :     com::sun::star::text::WritingMode GetWritingMode() const { return meWritingMode; }
     103             :     void SetWritingMode( com::sun::star::text::WritingMode eWritingMode );
     104             : 
     105             : private:
     106             :     CellRef getCell( const CellPos& rPos ) const;
     107             : 
     108             :     void LayoutTableWidth( ::Rectangle& rArea, bool bFit );
     109             :     void LayoutTableHeight( ::Rectangle& rArea, bool bFit );
     110             : 
     111        2322 :     inline bool isValidColumn( sal_Int32 nColumn ) const { return (nColumn >= 0) && (nColumn < static_cast<sal_Int32>( maColumns.size())); }
     112        2322 :     inline bool isValidRow( sal_Int32 nRow ) const { return (nRow >= 0) && (nRow < static_cast<sal_Int32>( maRows.size())); }
     113        2322 :     inline bool isValid( const CellPos& rPos ) const { return isValidColumn( rPos.mnCol ) && isValidRow( rPos.mnRow ); }
     114             : 
     115             :     void ClearBorderLayout();
     116             :     void ClearBorderLayout(BorderLineMap& rMap);
     117             :     void ResizeBorderLayout();
     118             :     void ResizeBorderLayout( BorderLineMap& rMap );
     119             : 
     120             :     void SetBorder( sal_Int32 nCol, sal_Int32 nRow, bool bHorizontal, const editeng::SvxBorderLine* pLine );
     121             : 
     122             :     static bool HasPriority( const editeng::SvxBorderLine* pThis, const editeng::SvxBorderLine* pOther );
     123             : 
     124             :     struct Layout
     125             :     {
     126             :         sal_Int32 mnPos;
     127             :         sal_Int32 mnSize;
     128             :         sal_Int32 mnMinSize;
     129             : 
     130         266 :         Layout() : mnPos( 0 ), mnSize( 0 ), mnMinSize( 0 ) {}
     131         336 :         void clear() { mnPos = 0; mnSize = 0; mnMinSize = 0; }
     132             :     };
     133             :     typedef std::vector< Layout > LayoutVector;
     134             : 
     135             :     sal_Int32 distribute( LayoutVector& rLayouts, sal_Int32 nDistribute );
     136             : 
     137             :     TableModelRef mxTable;
     138             :     LayoutVector maRows;
     139             :     LayoutVector maColumns;
     140             : 
     141             :     BorderLineMap maHorizontalBorders;
     142             :     BorderLineMap maVerticalBorders;
     143             : 
     144             :     com::sun::star::text::WritingMode   meWritingMode;
     145             : 
     146             :     const rtl::OUString msSize;
     147             : };
     148             : 
     149             : } }
     150             : 
     151             : #endif
     152             : 
     153             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10