fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / svx / svdotable.hxx
blob6ec0334c2d216e30d6bf0bb3cdca22e8d7f4080c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _SVX_SVDOTABLE_HXX
21 #define _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 "svdotext.hxx"
28 #include "svx/svxdllapi.h"
30 //------------------------------------------------------------------------
32 class SvStream;
33 class SfxStyleSheet;
35 namespace sdr { namespace contact {
36 class ViewContactOfTableObj;
39 namespace sdr { namespace table {
41 class TableLayouter;
42 struct ImplTableShadowPaintInfo;
44 #ifndef CellRef
45 class Cell;
46 typedef rtl::Reference< Cell > CellRef;
47 #endif
49 //------------------------------------------------------------------------
50 // SdrTableHitKind
51 //------------------------------------------------------------------------
53 enum TableHitKind
55 SDRTABLEHIT_NONE,
56 SDRTABLEHIT_CELL,
57 SDRTABLEHIT_CELLTEXTAREA,
58 SDRTABLEHIT_HORIZONTAL_BORDER,
59 SDRTABLEHIT_VERTICAL_BORDER
62 //------------------------------------------------------------------------
64 struct CellPos
66 sal_Int32 mnCol;
67 sal_Int32 mnRow;
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); }
76 //------------------------------------------------------------------------
77 // TableStyleSettings
78 //------------------------------------------------------------------------
80 struct SVX_DLLPUBLIC TableStyleSettings
82 bool mbUseFirstRow;
83 bool mbUseLastRow;
84 bool mbUseFirstColumn;
85 bool mbUseLastColumn;
86 bool mbUseRowBanding;
87 bool mbUseColumnBanding;
89 TableStyleSettings();
90 TableStyleSettings( const TableStyleSettings& rStyle );
91 TableStyleSettings& operator=(const TableStyleSettings& rStyle);
93 bool operator==( const TableStyleSettings& r ) const;
96 //------------------------------------------------------------------------
97 // SdrTableObj
98 //------------------------------------------------------------------------
100 class SdrTableObjImpl;
102 class SVX_DLLPUBLIC SdrTableObj : public ::SdrTextObj
104 friend class Cell;
105 friend class SdrTableObjImpl;
107 public:
108 SdrTableObj(SdrModel* _pModel);
109 SdrTableObj(SdrModel* _pModel, const ::Rectangle& rNewRect, sal_Int32 nColumns, sal_Int32 nRows);
110 virtual ~SdrTableObj();
112 TYPEINFO();
114 // table stuff
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 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;
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;
141 void uno_lock();
142 void uno_unlock();
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 getRowCount() const;
150 sal_Int32 getColumnCount() const;
151 void getCellBounds( const sdr::table::CellPos& rPos, ::Rectangle& rCellRect );
153 const SfxItemSet& GetActiveCellItemSet() const;
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;
158 // text stuff
160 /** returns the currently active text. */
161 virtual SdrText* getActiveText() const;
163 /** returns the nth available text. */
164 virtual SdrText* getText( sal_Int32 nIndex ) const;
166 /** returns the number of texts available for this object. */
167 virtual sal_Int32 getTextCount() const;
169 /** changes the current active text */
170 virtual void setActiveText( sal_Int32 nIndex );
172 /** returns the index of the text that contains the given point or -1 */
173 virtual sal_Int32 CheckTextHit(const Point& rPnt) const;
175 virtual bool HasText() const;
176 sal_Bool IsTextEditActive() const { return (pEdtOutl != 0L); }
177 bool IsTextEditActive( const sdr::table::CellPos& rPos );
179 /** returns true only if we are in edit mode and the user actually changed anything */
180 virtual bool IsRealyEdited() const;
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;
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;
196 virtual bool IsFontwork() const;
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();
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);
216 virtual const Rectangle& GetLogicRect() const;
217 virtual void NbcSetLogicRect(const Rectangle& rRect);
218 virtual void AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly = false );
220 virtual sal_uInt32 GetSnapPointCount() const;
221 virtual Point GetSnapPoint(sal_uInt32 i) const;
223 virtual sal_uInt32 GetHdlCount() const;
224 virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const;
225 virtual void AddToHdlList(SdrHdlList& rHdlList) const;
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;
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;
242 virtual void NbcMove(const Size& rSiz);
243 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
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;
251 virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject);
253 virtual OutlinerParaObject* GetOutlinerParaObject() const;
254 virtual OutlinerParaObject* GetEditOutlinerParaObject() const;
256 virtual void NbcReformatText();
257 virtual void ReformatText();
259 void SetTextEditOutliner(SdrOutliner* pOutl) { pEdtOutl=pOutl; }
261 virtual sal_Bool IsVerticalWriting() const;
262 virtual void SetVerticalWriting(sal_Bool bVertical);
264 com::sun::star::text::WritingMode GetWritingMode() const;
266 virtual void onEditOutlinerStatusEvent( EditStatus* pEditStatus );
269 ////////////////////////////////////////////////////////////////////////////////////////////////////
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.
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;
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);
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 );
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 );
295 private:
296 void init( sal_Int32 nColumns, sal_Int32 nRows );
298 protected:
299 virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
300 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
302 virtual SdrObjGeoData* NewGeoData() const;
303 virtual void SaveGeoData(SdrObjGeoData& rGeo) const;
304 virtual void RestGeoData(const SdrObjGeoData& rGeo);
306 private:
307 SdrOutliner* GetCellTextEditOutliner( const ::sdr::table::Cell& rCell ) const;
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;
315 Rectangle maLogicRect;
316 private:
317 SdrTableObjImpl* mpImpl;
320 ////////////////////////////////////////////////////////////////////////////////////////////////////
324 #endif
326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */