LCOV - code coverage report
Current view: top level - svx/source/table - tablelayouter.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 7 0.0 %
Date: 2014-04-14 Functions: 0 7 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             : 
      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 fullfill 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             :     basegfx::B2ITuple getCellSize( const CellPos& rPos ) const;
      77             :     bool getCellArea( const CellRef& xCell, basegfx::B2IRectangle& rArea ) const;
      78             :     bool getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rArea ) const;
      79             : 
      80           0 :     ::sal_Int32 getRowCount() const { return static_cast< ::sal_Int32 >( maRows.size() ); }
      81           0 :     ::sal_Int32 getColumnCount() const { return static_cast< ::sal_Int32 >( maColumns.size() ); }
      82             :     sal_Int32 getRowHeight( sal_Int32 nRow ) const;
      83             : 
      84             :     sal_Int32 getColumnWidth( sal_Int32 nColumn ) const;
      85             : 
      86             :     sal_Int32 getMinimumColumnWidth( sal_Int32 nColumn );
      87             : 
      88             :     /** checks if the given edge is visible.
      89             :         Edges between merged cells are not visible.
      90             :     */
      91             :     bool isEdgeVisible( sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal ) const;
      92             : 
      93             :     /** returns the requested borderline in rpBorderLine or a null pointer if there is no border at this edge */
      94             :     editeng::SvxBorderLine* getBorderLine( sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal )const;
      95             : 
      96             :     void updateCells( ::Rectangle& rRectangle );
      97             : 
      98             :     sal_Int32 getHorizontalEdge( int nEdgeY, sal_Int32* pnMin = 0, sal_Int32* pnMax = 0 );
      99             :     sal_Int32 getVerticalEdge( int nEdgeX , sal_Int32* pnMin = 0, sal_Int32* pnMax = 0);
     100             : 
     101             :     void DistributeColumns( ::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol );
     102             :     void DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow );
     103             : 
     104             : private:
     105             :     CellRef getCell( const CellPos& rPos ) const;
     106             : 
     107             :     void LayoutTableWidth( ::Rectangle& rArea, bool bFit );
     108             :     void LayoutTableHeight( ::Rectangle& rArea, bool bFit );
     109             : 
     110           0 :     inline bool isValidColumn( sal_Int32 nColumn ) const { return (nColumn >= 0) && (nColumn < static_cast<sal_Int32>( maColumns.size())); }
     111           0 :     inline bool isValidRow( sal_Int32 nRow ) const { return (nRow >= 0) && (nRow < static_cast<sal_Int32>( maRows.size())); }
     112           0 :     inline bool isValid( const CellPos& rPos ) const { return isValidColumn( rPos.mnCol ) && isValidRow( rPos.mnRow ); }
     113             : 
     114             :     void ClearBorderLayout();
     115             :     void ClearBorderLayout(BorderLineMap& rMap);
     116             :     void ResizeBorderLayout();
     117             :     void ResizeBorderLayout( BorderLineMap& rMap );
     118             : 
     119             :     void SetBorder( sal_Int32 nCol, sal_Int32 nRow, bool bHorizontal, const editeng::SvxBorderLine* pLine );
     120             : 
     121             :     static bool HasPriority( const editeng::SvxBorderLine* pThis, const editeng::SvxBorderLine* pOther );
     122             : 
     123             :     struct Layout
     124             :     {
     125             :         sal_Int32 mnPos;
     126             :         sal_Int32 mnSize;
     127             :         sal_Int32 mnMinSize;
     128             : 
     129           0 :         Layout() : mnPos( 0 ), mnSize( 0 ), mnMinSize( 0 ) {}
     130           0 :         void clear() { mnPos = 0; mnSize = 0; mnMinSize = 0; }
     131             :     };
     132             :     typedef std::vector< Layout > LayoutVector;
     133             : 
     134             :     sal_Int32 distribute( LayoutVector& rLayouts, sal_Int32 nDistribute );
     135             : 
     136             :     TableModelRef mxTable;
     137             :     LayoutVector maRows;
     138             :     LayoutVector maColumns;
     139             : 
     140             :     BorderLineMap maHorizontalBorders;
     141             :     BorderLineMap maVerticalBorders;
     142             : 
     143             :     const OUString msSize;
     144             : };
     145             : 
     146             : } }
     147             : 
     148             : #endif
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10