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