LCOV - code coverage report
Current view: top level - include/svx - svdotable.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 5 40.0 %
Date: 2015-06-13 12:38:46 Functions: 2 5 40.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_SVDOTABLE_HXX
      21             : #define INCLUDED_SVX_SVDOTABLE_HXX
      22             : 
      23             : #include <com/sun/star/text/WritingMode.hpp>
      24             : #include <com/sun/star/container/XIndexAccess.hpp>
      25             : #include <com/sun/star/table/XTable.hpp>
      26             : #include <rtl/ref.hxx>
      27             : #include <svx/svdotext.hxx>
      28             : #include <svx/svxdllapi.h>
      29             : 
      30             : 
      31             : 
      32             : class SvStream;
      33             : class SfxStyleSheet;
      34             : 
      35             : namespace sdr { namespace contact {
      36             :     class ViewContactOfTableObj;
      37             : }}
      38             : 
      39             : namespace sdr { namespace table {
      40             : 
      41             : class TableLayouter;
      42             : struct ImplTableShadowPaintInfo;
      43             : 
      44             : #ifndef CellRef
      45             :     class Cell;
      46             :     typedef rtl::Reference< Cell > CellRef;
      47             : #endif
      48             : 
      49             : 
      50             : // SdrTableHitKind
      51             : 
      52             : 
      53             : enum TableHitKind
      54             : {
      55             :     SDRTABLEHIT_NONE,
      56             :     SDRTABLEHIT_CELL,
      57             :     SDRTABLEHIT_CELLTEXTAREA,
      58             :     SDRTABLEHIT_HORIZONTAL_BORDER,
      59             :     SDRTABLEHIT_VERTICAL_BORDER
      60             : };
      61             : 
      62             : 
      63             : 
      64             : struct CellPos
      65             : {
      66             :     sal_Int32 mnCol;
      67             :     sal_Int32 mnRow;
      68             : 
      69        1712 :     CellPos() : mnCol( 0 ), mnRow( 0 ) {}
      70        6423 :     CellPos( sal_Int32 nCol, sal_Int32 nRow ) { mnCol = nCol; mnRow = nRow; }
      71             : 
      72           0 :     bool operator==( const CellPos& r ) const { return (r.mnCol == mnCol) && (r.mnRow == mnRow); }
      73           0 :     bool operator!=( const CellPos& r ) const { return (r.mnCol != mnCol) || (r.mnRow != mnRow); }
      74             : };
      75             : 
      76             : 
      77             : // TableStyleSettings
      78             : 
      79             : 
      80             : struct SVX_DLLPUBLIC TableStyleSettings
      81             : {
      82             :     bool mbUseFirstRow;
      83             :     bool mbUseLastRow;
      84             :     bool mbUseFirstColumn;
      85             :     bool mbUseLastColumn;
      86             :     bool mbUseRowBanding;
      87             :     bool mbUseColumnBanding;
      88             : 
      89             :     TableStyleSettings();
      90             :     TableStyleSettings( const TableStyleSettings& rStyle );
      91             :     TableStyleSettings& operator=(const TableStyleSettings& rStyle);
      92             : 
      93             :     bool operator==( const TableStyleSettings& r ) const;
      94             : };
      95             : 
      96             : 
      97             : //   SdrTableObj
      98             : 
      99             : 
     100             : class SdrTableObjImpl;
     101             : 
     102             : class SVX_DLLPUBLIC SdrTableObj : public ::SdrTextObj
     103             : {
     104             :     friend class Cell;
     105             :     friend class SdrTableObjImpl;
     106             : 
     107             : public:
     108             :     SdrTableObj(SdrModel* _pModel);
     109             :     SdrTableObj(SdrModel* _pModel, const ::Rectangle& rNewRect, sal_Int32 nColumns, sal_Int32 nRows);
     110             :     virtual ~SdrTableObj();
     111             : 
     112             :     TYPEINFO_OVERRIDE();
     113             : 
     114             :     // table stuff
     115             : 
     116             :     SdrTableObj* CloneRange( const CellPos& rStartPos, const CellPos& rEndPos );
     117             :     void DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn );
     118             :     void DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow );
     119             : 
     120             :     com::sun::star::uno::Reference< com::sun::star::table::XTable > getTable() const;
     121             : 
     122             :     bool isValid( const sdr::table::CellPos& rPos ) const;
     123             :     static CellPos getFirstCell();
     124             :     CellPos getLastCell() const;
     125             :     CellPos getLeftCell( const CellPos& rPos, bool bEdgeTravel ) const;
     126             :     CellPos getRightCell( const CellPos& rPos, bool bEdgeTravel  ) const;
     127             :     CellPos getUpCell( const CellPos& rPos, bool bEdgeTravel ) const;
     128             :     CellPos getDownCell( const CellPos& rPos, bool bEdgeTravel ) const;
     129             :     CellPos getPreviousCell( const CellPos& rPos, bool bEdgeTravel ) const;
     130             :     CellPos getNextCell( const CellPos& rPos, bool bEdgeTravel ) const;
     131             :     CellPos getPreviousRow( const CellPos& rPos, bool bEdgeTravel ) const;
     132             :     CellPos getNextRow( const CellPos& rPos, bool bEdgeTravel ) const;
     133             : 
     134             :     void createCell( sdr::table::CellRef& xCell );
     135             : 
     136             :     const sdr::table::TableStyleSettings& getTableStyleSettings() const;
     137             :     void setTableStyleSettings( const sdr::table::TableStyleSettings& rStyle );
     138             : 
     139             :     TableHitKind CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_Int32& rnY, int nTol ) const;
     140             : 
     141             :     void uno_lock();
     142             :     void uno_unlock();
     143             : 
     144             :     /** the active table has the focus or is currently edited */
     145             :     const sdr::table::CellRef& getActiveCell() const;
     146             : 
     147             :     void setActiveCell( const sdr::table::CellPos& rPos );
     148             :     void getActiveCellPos( sdr::table::CellPos& rPos ) const;
     149             :     sal_Int32 getColumnCount() const;
     150             :     void getCellBounds( const sdr::table::CellPos& rPos, ::Rectangle& rCellRect );
     151             : 
     152             :     const SfxItemSet& GetActiveCellItemSet() const;
     153             : 
     154             :      void setTableStyle( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xAutoFormatStyle );
     155             :      const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& getTableStyle() const;
     156             : 
     157             :      // text stuff
     158             : 
     159             :     /** returns the currently active text. */
     160             :     virtual SdrText* getActiveText() const SAL_OVERRIDE;
     161             : 
     162             :     /** returns the nth available text. */
     163             :     virtual SdrText* getText( sal_Int32 nIndex ) const SAL_OVERRIDE;
     164             : 
     165             :     /** returns the number of texts available for this object. */
     166             :     virtual sal_Int32 getTextCount() const SAL_OVERRIDE;
     167             : 
     168             :     /** changes the current active text */
     169             :     virtual void setActiveText( sal_Int32 nIndex ) SAL_OVERRIDE;
     170             : 
     171             :     /** returns the index of the text that contains the given point or -1 */
     172             :     virtual sal_Int32 CheckTextHit(const Point& rPnt) const SAL_OVERRIDE;
     173             : 
     174             :     // #i121917#
     175             :     virtual bool HasText() const SAL_OVERRIDE;
     176             : 
     177           0 :     bool IsTextEditActive() const { return (pEdtOutl != 0L); }
     178             :     bool IsTextEditActive( const sdr::table::CellPos& rPos );
     179             : 
     180             :     /** returns true only if we are in edit mode and the user actually changed anything */
     181             :     virtual bool IsReallyEdited() const SAL_OVERRIDE;
     182             : 
     183             :     // Gleichzeitig wird der Text in den Outliner gesetzt (ggf.
     184             :     // der des EditOutliners) und die PaperSize gesetzt.
     185             :     void TakeTextRect( const sdr::table::CellPos& rPos, SdrOutliner& rOutliner, ::Rectangle& rTextRect, bool bNoEditText = false, ::Rectangle* pAnchorRect=NULL, bool bLineWidth = true ) const;
     186             :     virtual void TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText = false, Rectangle* pAnchorRect=NULL, bool bLineWidth = true ) const SAL_OVERRIDE;
     187             :     void TakeTextAnchorRect(const sdr::table::CellPos& rPos, ::Rectangle& rAnchorRect ) const;
     188             :     virtual void TakeTextAnchorRect(::Rectangle& rAnchorRect) const SAL_OVERRIDE;
     189             : 
     190             :     virtual bool IsAutoGrowHeight() const SAL_OVERRIDE;
     191             :     long GetMinTextFrameHeight() const;
     192             :     long GetMaxTextFrameHeight() const;
     193             :     virtual bool IsAutoGrowWidth() const SAL_OVERRIDE;
     194             :     long GetMinTextFrameWidth() const;
     195             :     long GetMaxTextFrameWidth() const;
     196             : 
     197             :     virtual bool IsFontwork() const SAL_OVERRIDE;
     198             : 
     199             :     virtual void SetPage(SdrPage* pNewPage) SAL_OVERRIDE;
     200             :     virtual void SetModel(SdrModel* pNewModel) SAL_OVERRIDE;
     201             :     virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const SAL_OVERRIDE;
     202             :     virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
     203             :     virtual void SetChanged() SAL_OVERRIDE;
     204             : 
     205             :     virtual bool AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt = true, bool bWdt = true) const SAL_OVERRIDE;
     206             :     virtual bool AdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) SAL_OVERRIDE;
     207             :     virtual OUString TakeObjNameSingul() const SAL_OVERRIDE;
     208             :     virtual OUString TakeObjNamePlural() const SAL_OVERRIDE;
     209             :     virtual SdrTableObj* Clone() const SAL_OVERRIDE;
     210             :     SdrTableObj& operator=(const SdrTableObj& rObj);
     211             :     virtual basegfx::B2DPolyPolygon TakeXorPoly() const SAL_OVERRIDE;
     212             :     virtual basegfx::B2DPolyPolygon TakeContour() const SAL_OVERRIDE;
     213             :     virtual void RecalcSnapRect() SAL_OVERRIDE;
     214             :     virtual const Rectangle& GetSnapRect() const SAL_OVERRIDE;
     215             :     virtual void NbcSetSnapRect(const Rectangle& rRect) SAL_OVERRIDE;
     216             : 
     217             :     virtual const Rectangle& GetLogicRect() const SAL_OVERRIDE;
     218             :     virtual void NbcSetLogicRect(const Rectangle& rRect) SAL_OVERRIDE;
     219             :     virtual void AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly = false ) SAL_OVERRIDE;
     220             : 
     221             :     virtual sal_uInt32 GetSnapPointCount() const SAL_OVERRIDE;
     222             :     virtual Point GetSnapPoint(sal_uInt32 i) const SAL_OVERRIDE;
     223             : 
     224             :     virtual sal_uInt32 GetHdlCount() const SAL_OVERRIDE;
     225             :     virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const SAL_OVERRIDE;
     226             :     virtual void AddToHdlList(SdrHdlList& rHdlList) const SAL_OVERRIDE;
     227             : 
     228             :     // special drag methods
     229             :     virtual bool hasSpecialDrag() const SAL_OVERRIDE;
     230             :     virtual bool beginSpecialDrag(SdrDragStat& rDrag) const SAL_OVERRIDE;
     231             :     virtual bool applySpecialDrag(SdrDragStat& rDrag) SAL_OVERRIDE;
     232             :     virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const SAL_OVERRIDE;
     233             :     virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const SAL_OVERRIDE;
     234             : 
     235             :     virtual bool BegCreate(SdrDragStat& rStat) SAL_OVERRIDE;
     236             :     virtual bool MovCreate(SdrDragStat& rStat) SAL_OVERRIDE;
     237             :     virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
     238             :     virtual bool BckCreate(SdrDragStat& rStat) SAL_OVERRIDE;
     239             :     virtual void BrkCreate(SdrDragStat& rStat) SAL_OVERRIDE;
     240             :     virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const SAL_OVERRIDE;
     241             :     virtual Pointer GetCreatePointer() const SAL_OVERRIDE;
     242             : 
     243             :     virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE;
     244             :     virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
     245             : 
     246             :     virtual bool BegTextEdit(SdrOutliner& rOutl) SAL_OVERRIDE;
     247             :     virtual void EndTextEdit(SdrOutliner& rOutl) SAL_OVERRIDE;
     248             :     virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const SAL_OVERRIDE;
     249             :     void TakeTextEditArea(const sdr::table::CellPos& rPos, Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const;
     250             :     virtual sal_uInt16 GetOutlinerViewAnchorMode() const SAL_OVERRIDE;
     251             : 
     252             :     virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) SAL_OVERRIDE;
     253             : 
     254             :     virtual OutlinerParaObject* GetOutlinerParaObject() const SAL_OVERRIDE;
     255             :     virtual OutlinerParaObject* GetEditOutlinerParaObject() const SAL_OVERRIDE;
     256             : 
     257             :     virtual void NbcReformatText() SAL_OVERRIDE;
     258             :     virtual void ReformatText() SAL_OVERRIDE;
     259             : 
     260             :     void SetTextEditOutliner(SdrOutliner* pOutl) { pEdtOutl=pOutl; }
     261             : 
     262             :     virtual bool IsVerticalWriting() const SAL_OVERRIDE;
     263             :     virtual void SetVerticalWriting(bool bVertical) SAL_OVERRIDE;
     264             : 
     265             :     com::sun::star::text::WritingMode GetWritingMode() const;
     266             : 
     267             :     virtual void onEditOutlinerStatusEvent( EditStatus* pEditStatus ) SAL_OVERRIDE;
     268             : 
     269             : 
     270             : 
     271             : 
     272             :     // transformation interface for StarOfficeAPI. This implements support for
     273             :     // homogen 3x3 matrices containing the transformation of the SdrObject. At the
     274             :     // moment it contains a shearX, rotation and translation, but for setting all linear
     275             :     // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
     276             : 
     277             : 
     278             :     // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
     279             :     // with the base geometry and returns TRUE. Otherwise it returns FALSE.
     280             :     virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const SAL_OVERRIDE;
     281             : 
     282             :     // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
     283             :     // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
     284             :     // to use (0,0) as upper left and will be scaled to the given size in the matrix.
     285             :     virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) SAL_OVERRIDE;
     286             : 
     287             :     // #103836# iterates over the paragraphs of a given SdrObject and removes all
     288             :     //          hard set character attributes with the which ids contained in the
     289             :     //          given vector
     290             : //  virtual void RemoveOutlinerCharacterAttribs( const std::vector<sal_uInt16>& rCharWhichIds );
     291             : 
     292             :     /** hack for clipboard with calc and writer, export and import table content as rtf table */
     293             :     static void ExportAsRTF( SvStream& rStrm, SdrTableObj& rObj );
     294             :     static void ImportAsRTF( SvStream& rStrm, SdrTableObj& rObj );
     295             : 
     296             : private:
     297             :     void init( sal_Int32 nColumns, sal_Int32 nRows );
     298             : 
     299             : protected:
     300             :     virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() SAL_OVERRIDE;
     301             :     virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() SAL_OVERRIDE;
     302             : 
     303             :     virtual SdrObjGeoData* NewGeoData() const SAL_OVERRIDE;
     304             :     virtual void SaveGeoData(SdrObjGeoData& rGeo) const SAL_OVERRIDE;
     305             :     virtual void RestGeoData(const SdrObjGeoData& rGeo) SAL_OVERRIDE;
     306             : 
     307             : private:
     308             :     SdrOutliner* GetCellTextEditOutliner( const sdr::table::Cell& rCell ) const;
     309             : 
     310             : private:
     311             :     // for the ViewContactOfTableObj to build the primitive representation, it is necessary to access the
     312             :     // TableLayouter for position and attribute information
     313             :     friend class sdr::contact::ViewContactOfTableObj;
     314             :     const TableLayouter& getTableLayouter() const;
     315             : 
     316             :     Rectangle   maLogicRect;
     317             : private:
     318             :     SdrTableObjImpl*    mpImpl;
     319             : };
     320             : 
     321             : 
     322             : 
     323             : } }
     324             : 
     325             : #endif
     326             : 
     327             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11