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