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