1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDOTABLE_HXX
21 #define INCLUDED_SVX_SVDOTABLE_HXX
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>
35 namespace sdr
{ namespace contact
{
36 class ViewContactOfTableObj
;
39 namespace sdr
{ namespace table
{
42 struct ImplTableShadowPaintInfo
;
46 typedef rtl::Reference
< Cell
> CellRef
;
57 SDRTABLEHIT_CELLTEXTAREA
,
58 SDRTABLEHIT_HORIZONTAL_BORDER
,
59 SDRTABLEHIT_VERTICAL_BORDER
69 CellPos() : mnCol( 0 ), mnRow( 0 ) {}
70 CellPos( sal_Int32 nCol
, sal_Int32 nRow
) { mnCol
= nCol
; mnRow
= nRow
; }
72 bool operator==( const CellPos
& r
) const { return (r
.mnCol
== mnCol
) && (r
.mnRow
== mnRow
); }
73 bool operator!=( const CellPos
& r
) const { return (r
.mnCol
!= mnCol
) || (r
.mnRow
!= mnRow
); }
80 struct SVX_DLLPUBLIC TableStyleSettings
84 bool mbUseFirstColumn
;
87 bool mbUseColumnBanding
;
90 TableStyleSettings( const TableStyleSettings
& rStyle
);
91 TableStyleSettings
& operator=(const TableStyleSettings
& rStyle
);
93 bool operator==( const TableStyleSettings
& r
) const;
100 class SdrTableObjImpl
;
102 class SVX_DLLPUBLIC SdrTableObj
: public ::SdrTextObj
105 friend class SdrTableObjImpl
;
108 SdrTableObj(SdrModel
* _pModel
);
109 SdrTableObj(SdrModel
* _pModel
, const ::Rectangle
& rNewRect
, sal_Int32 nColumns
, sal_Int32 nRows
);
110 virtual ~SdrTableObj();
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
);
120 com::sun::star::uno::Reference
< com::sun::star::table::XTable
> getTable() const;
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;
134 void createCell( sdr::table::CellRef
& xCell
);
136 const sdr::table::TableStyleSettings
& getTableStyleSettings() const;
137 void setTableStyleSettings( const sdr::table::TableStyleSettings
& rStyle
);
139 TableHitKind
CheckTableHit( const Point
& rPos
, sal_Int32
& rnX
, sal_Int32
& rnY
, int nTol
) const;
144 /** the active table has the focus or is currently edited */
145 const sdr::table::CellRef
& getActiveCell() const;
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
);
152 const SfxItemSet
& GetActiveCellItemSet() const;
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;
159 /** returns the currently active text. */
160 virtual SdrText
* getActiveText() const SAL_OVERRIDE
;
162 /** returns the nth available text. */
163 virtual SdrText
* getText( sal_Int32 nIndex
) const SAL_OVERRIDE
;
165 /** returns the number of texts available for this object. */
166 virtual sal_Int32
getTextCount() const SAL_OVERRIDE
;
168 /** changes the current active text */
169 virtual void setActiveText( sal_Int32 nIndex
) SAL_OVERRIDE
;
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
;
175 virtual bool HasText() const SAL_OVERRIDE
;
177 bool IsTextEditActive() const { return (pEdtOutl
!= 0L); }
178 bool IsTextEditActive( const sdr::table::CellPos
& rPos
);
180 /** returns true only if we are in edit mode and the user actually changed anything */
181 virtual bool IsReallyEdited() const SAL_OVERRIDE
;
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
;
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;
197 virtual bool IsFontwork() const SAL_OVERRIDE
;
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
;
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
;
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
;
221 virtual sal_uInt32
GetSnapPointCount() const SAL_OVERRIDE
;
222 virtual Point
GetSnapPoint(sal_uInt32 i
) const SAL_OVERRIDE
;
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
;
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
;
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
;
243 virtual void NbcMove(const Size
& rSiz
) SAL_OVERRIDE
;
244 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) SAL_OVERRIDE
;
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
;
252 virtual void NbcSetOutlinerParaObject(OutlinerParaObject
* pTextObject
) SAL_OVERRIDE
;
254 virtual OutlinerParaObject
* GetOutlinerParaObject() const SAL_OVERRIDE
;
255 virtual OutlinerParaObject
* GetEditOutlinerParaObject() const SAL_OVERRIDE
;
257 virtual void NbcReformatText() SAL_OVERRIDE
;
258 virtual void ReformatText() SAL_OVERRIDE
;
260 void SetTextEditOutliner(SdrOutliner
* pOutl
) { pEdtOutl
=pOutl
; }
262 virtual bool IsVerticalWriting() const SAL_OVERRIDE
;
263 virtual void SetVerticalWriting(bool bVertical
) SAL_OVERRIDE
;
265 com::sun::star::text::WritingMode
GetWritingMode() const;
267 virtual void onEditOutlinerStatusEvent( EditStatus
* pEditStatus
) SAL_OVERRIDE
;
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.
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
;
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
;
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
290 // virtual void RemoveOutlinerCharacterAttribs( const std::vector<sal_uInt16>& rCharWhichIds );
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
);
297 void init( sal_Int32 nColumns
, sal_Int32 nRows
);
300 virtual sdr::properties::BaseProperties
* CreateObjectSpecificProperties() SAL_OVERRIDE
;
301 virtual sdr::contact::ViewContact
* CreateObjectSpecificViewContact() SAL_OVERRIDE
;
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
;
308 SdrOutliner
* GetCellTextEditOutliner( const sdr::table::Cell
& rCell
) const;
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;
316 Rectangle maLogicRect
;
318 SdrTableObjImpl
* mpImpl
;
327 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */