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_SVDOTABLE_HXX
21 : #define _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 "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 633 : CellPos() : mnCol( 0 ), mnRow( 0 ) {}
70 2878 : 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();
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 : CellPos getFirstCell() const;
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 : void getCellBounds( const sdr::table::CellPos& rPos, ::Rectangle& rCellRect );
150 :
151 : const SfxItemSet& GetActiveCellItemSet() const;
152 :
153 : void setTableStyle( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xAutoFormatStyle );
154 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& getTableStyle() const;
155 :
156 : // text stuff
157 :
158 : /** returns the currently active text. */
159 : virtual SdrText* getActiveText() const;
160 :
161 : /** returns the nth available text. */
162 : virtual SdrText* getText( sal_Int32 nIndex ) const;
163 :
164 : /** returns the number of texts available for this object. */
165 : virtual sal_Int32 getTextCount() const;
166 :
167 : /** changes the current active text */
168 : virtual void setActiveText( sal_Int32 nIndex );
169 :
170 : /** returns the index of the text that contains the given point or -1 */
171 : virtual sal_Int32 CheckTextHit(const Point& rPnt) const;
172 :
173 : virtual bool HasText() const;
174 0 : sal_Bool IsTextEditActive() const { return (pEdtOutl != 0L); }
175 : bool IsTextEditActive( const sdr::table::CellPos& rPos );
176 :
177 : /** returns true only if we are in edit mode and the user actually changed anything */
178 : virtual bool IsRealyEdited() const;
179 :
180 : // Gleichzeitig wird der Text in den Outliner gesetzt (ggf.
181 : // der des EditOutliners) und die PaperSize gesetzt.
182 : virtual void TakeTextRect( const sdr::table::CellPos& rPos, SdrOutliner& rOutliner, ::Rectangle& rTextRect, bool bNoEditText = false, ::Rectangle* pAnchorRect=NULL, bool bLineWidth = true ) const;
183 : virtual void TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText = false, Rectangle* pAnchorRect=NULL, bool bLineWidth = true ) const;
184 : virtual void TakeTextAnchorRect(const sdr::table::CellPos& rPos, ::Rectangle& rAnchorRect ) const;
185 : virtual void TakeTextAnchorRect(::Rectangle& rAnchorRect) const;
186 :
187 : virtual bool IsAutoGrowHeight() const;
188 : long GetMinTextFrameHeight() const;
189 : long GetMaxTextFrameHeight() const;
190 : virtual bool IsAutoGrowWidth() const;
191 : long GetMinTextFrameWidth() const;
192 : long GetMaxTextFrameWidth() const;
193 :
194 : virtual bool IsFontwork() const;
195 :
196 : virtual void SetPage(SdrPage* pNewPage);
197 : virtual void SetModel(SdrModel* pNewModel);
198 : virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
199 : virtual sal_uInt16 GetObjIdentifier() const;
200 : virtual void SetChanged();
201 :
202 : virtual bool AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt = true, bool bWdt = true) const;
203 : virtual bool AdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true);
204 : virtual void TakeObjNameSingul(String& rName) const;
205 : virtual void TakeObjNamePlural(String& rName) const;
206 : virtual SdrTableObj* Clone() const;
207 : SdrTableObj& operator=(const SdrTableObj& rObj);
208 : virtual basegfx::B2DPolyPolygon TakeXorPoly() const;
209 : virtual basegfx::B2DPolyPolygon TakeContour() const;
210 : virtual void RecalcSnapRect();
211 : virtual const Rectangle& GetSnapRect() const;
212 : virtual void NbcSetSnapRect(const Rectangle& rRect);
213 :
214 : virtual const Rectangle& GetLogicRect() const;
215 : virtual void NbcSetLogicRect(const Rectangle& rRect);
216 : virtual void AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly = false );
217 :
218 : virtual sal_uInt32 GetSnapPointCount() const;
219 : virtual Point GetSnapPoint(sal_uInt32 i) const;
220 :
221 : virtual sal_uInt32 GetHdlCount() const;
222 : virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const;
223 : virtual void AddToHdlList(SdrHdlList& rHdlList) const;
224 :
225 : // special drag methods
226 : virtual bool hasSpecialDrag() const;
227 : virtual bool beginSpecialDrag(SdrDragStat& rDrag) const;
228 : virtual bool applySpecialDrag(SdrDragStat& rDrag);
229 : virtual String getSpecialDragComment(const SdrDragStat& rDrag) const;
230 : virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const;
231 :
232 : virtual bool BegCreate(SdrDragStat& rStat);
233 : virtual bool MovCreate(SdrDragStat& rStat);
234 : virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
235 : virtual bool BckCreate(SdrDragStat& rStat);
236 : virtual void BrkCreate(SdrDragStat& rStat);
237 : virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const;
238 : virtual Pointer GetCreatePointer() const;
239 :
240 : virtual void NbcMove(const Size& rSiz);
241 : virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
242 :
243 : virtual sal_Bool BegTextEdit(SdrOutliner& rOutl);
244 : virtual void EndTextEdit(SdrOutliner& rOutl);
245 : virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const;
246 : virtual void TakeTextEditArea(const sdr::table::CellPos& rPos, Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const;
247 : virtual sal_uInt16 GetOutlinerViewAnchorMode() const;
248 :
249 : virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject);
250 :
251 : virtual OutlinerParaObject* GetOutlinerParaObject() const;
252 : virtual OutlinerParaObject* GetEditOutlinerParaObject() const;
253 :
254 : virtual void NbcReformatText();
255 : virtual void ReformatText();
256 :
257 : void SetTextEditOutliner(SdrOutliner* pOutl) { pEdtOutl=pOutl; }
258 :
259 : virtual sal_Bool IsVerticalWriting() const;
260 : virtual void SetVerticalWriting(sal_Bool bVertical);
261 :
262 : com::sun::star::text::WritingMode GetWritingMode() const;
263 :
264 : virtual void onEditOutlinerStatusEvent( EditStatus* pEditStatus );
265 :
266 :
267 : ////////////////////////////////////////////////////////////////////////////////////////////////////
268 : //
269 : // transformation interface for StarOfficeAPI. This implements support for
270 : // homogen 3x3 matrices containing the transformation of the SdrObject. At the
271 : // moment it contains a shearX, rotation and translation, but for setting all linear
272 : // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
273 : //
274 : ////////////////////////////////////////////////////////////////////////////////////////////////////
275 : // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
276 : // with the base geometry and returns TRUE. Otherwise it returns FALSE.
277 : virtual sal_Bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const;
278 :
279 : // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
280 : // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
281 : // to use (0,0) as upper left and will be scaled to the given size in the matrix.
282 : virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon);
283 :
284 : // #103836# iterates over the paragraphs of a given SdrObject and removes all
285 : // hard set character attributes with the which ids contained in the
286 : // given vector
287 : // virtual void RemoveOutlinerCharacterAttribs( const std::vector<sal_uInt16>& rCharWhichIds );
288 :
289 : /** hack for clipboard with calc and writer, export and import table content as rtf table */
290 : static void ExportAsRTF( SvStream& rStrm, SdrTableObj& rObj );
291 : static void ImportAsRTF( SvStream& rStrm, SdrTableObj& rObj );
292 :
293 : private:
294 : void init( sal_Int32 nColumns, sal_Int32 nRows );
295 :
296 : protected:
297 : virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
298 : virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
299 :
300 : virtual SdrObjGeoData* NewGeoData() const;
301 : virtual void SaveGeoData(SdrObjGeoData& rGeo) const;
302 : virtual void RestGeoData(const SdrObjGeoData& rGeo);
303 :
304 : private:
305 : SdrOutliner* GetCellTextEditOutliner( const ::sdr::table::Cell& rCell ) const;
306 :
307 : private:
308 : // for the ViewContactOfTableObj to build the primitive representation, it is necessary to access the
309 : // TableLayouter for position and attribute informations
310 : friend class sdr::contact::ViewContactOfTableObj;
311 : const TableLayouter& getTableLayouter() const;
312 :
313 : Rectangle maLogicRect;
314 : private:
315 : SdrTableObjImpl* mpImpl;
316 : };
317 :
318 : ////////////////////////////////////////////////////////////////////////////////////////////////////
319 :
320 : } }
321 :
322 : #endif
323 :
324 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|