LibreOffice Module svx (master)  1
svdotable.hxx
Go to the documentation of this file.
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 INCLUDED_SVX_SVDOTABLE_HXX
21 #define INCLUDED_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 <svx/svdotext.hxx>
28 #include <svx/svxdllapi.h>
29 #include <boost/property_tree/ptree_fwd.hpp>
30 
31 class SvStream;
32 class SfxStyleSheet;
33 class SdrUndoAction;
34 
35 namespace sdr::contact {
36  class ViewContactOfTableObj;
37 }
38 
39 namespace sdr::table {
40 
41 class TableLayouter;
42 struct ImplTableShadowPaintInfo;
43 
44 #ifndef CellRef
45  class Cell;
47 #endif
48 
49 
51 enum class TableHitKind
52 {
53  NONE,
54  Cell,
58 };
59 
60 
61 struct CellPos
62 {
63  sal_Int32 mnCol;
64  sal_Int32 mnRow;
65 
66  CellPos() : mnCol( 0 ), mnRow( 0 ) {}
67  CellPos( sal_Int32 nCol, sal_Int32 nRow ) { mnCol = nCol; mnRow = nRow; }
68 
69  bool operator==( const CellPos& r ) const { return (r.mnCol == mnCol) && (r.mnRow == mnRow); }
70  bool operator!=( const CellPos& r ) const { return (r.mnCol != mnCol) || (r.mnRow != mnRow); }
71 };
72 
73 
76 {
83 
85  TableStyleSettings( const TableStyleSettings& rStyle );
87 
88  bool operator==( const TableStyleSettings& r ) const;
89 };
90 
92 class SdrTableObjImpl;
93 
95 {
96  friend class Cell;
97  friend class SdrTableObjImpl;
98 
99  // protected destructor
100  virtual ~SdrTableObj() override;
101 
102 public:
103  SdrTableObj(SdrModel& rSdrModel);
104  // Copy constructor
105  SdrTableObj(SdrModel& rSdrModel, SdrTableObj const & rSource);
106  SdrTableObj(
107  SdrModel& rSdrModel,
108  const ::tools::Rectangle& rNewRect,
109  sal_Int32 nColumns,
110  sal_Int32 nRows);
111 
112  // helper to limit existing TableModel to a given selection
113  void CropTableModelToSelection(const CellPos& rStart, const CellPos& rEnd);
114 
115  // Table stuff
116  void DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn, const bool bOptimize, const bool bMinimize );
117  void DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow, const bool bOptimize, const bool bMinimize );
118 
119  css::uno::Reference< css::table::XTable > getTable() const;
120 
121  bool isValid( const sdr::table::CellPos& rPos ) const;
122  static CellPos getFirstCell();
123  CellPos getLastCell() const;
124  CellPos getLeftCell( const CellPos& rPos, bool bEdgeTravel ) const;
125  CellPos getRightCell( const CellPos& rPos, bool bEdgeTravel ) const;
126  CellPos getUpCell( const CellPos& rPos, bool bEdgeTravel ) const;
127  CellPos getDownCell( const CellPos& rPos, bool bEdgeTravel ) const;
128  CellPos getPreviousCell( const CellPos& rPos, bool bEdgeTravel ) const;
129  CellPos getNextCell( const CellPos& rPos, bool bEdgeTravel ) const;
130  CellPos getPreviousRow( const CellPos& rPos, bool bEdgeTravel ) const;
131  CellPos getNextRow( const CellPos& rPos, bool bEdgeTravel ) const;
132 
133  void createCell( sdr::table::CellRef& xCell );
134 
135  const sdr::table::TableStyleSettings& getTableStyleSettings() const;
136  void setTableStyleSettings( const sdr::table::TableStyleSettings& rStyle );
137 
138  TableHitKind CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_Int32& rnY, const sal_uInt16 aTol = 0 ) const;
139 
140  void uno_lock();
141  void uno_unlock();
142 
144  const sdr::table::CellRef& getActiveCell() const;
145 
146  void setActiveCell( const sdr::table::CellPos& rPos );
147  void getActiveCellPos( sdr::table::CellPos& rPos ) const;
148  sal_Int32 getColumnCount() const;
149  sal_Int32 getRowCount() const;
150 
151  bool createTableEdgesJson(boost::property_tree::ptree & rJsonRoot);
152  void changeEdge(bool bHorizontal, int nEdge, sal_Int32 nOffset);
153 
154  void getCellBounds( const sdr::table::CellPos& rPos, ::tools::Rectangle& rCellRect );
155 
156  const SfxItemSet& GetActiveCellItemSet() const;
157 
158  void setTableStyle( const css::uno::Reference< css::container::XIndexAccess >& xAutoFormatStyle );
159  const css::uno::Reference< css::container::XIndexAccess >& getTableStyle() const;
160 
161  // Text stuff
162 
164  virtual SdrText* getActiveText() const override;
165 
167  virtual SdrText* getText( sal_Int32 nIndex ) const override;
168 
170  virtual sal_Int32 getTextCount() const override;
171 
173  virtual void setActiveText( sal_Int32 nIndex ) override;
174 
176  virtual sal_Int32 CheckTextHit(const Point& rPnt) const override;
177 
178  // #i121917#
179  virtual bool HasText() const override;
180 
181  bool IsTextEditActive() const { return (pEdtOutl != nullptr); }
182  bool IsTextEditActive( const sdr::table::CellPos& rPos );
183 
185  virtual bool IsReallyEdited() const override;
186 
190  void TakeTextRect( const sdr::table::CellPos& rPos, SdrOutliner& rOutliner, ::tools::Rectangle& rTextRect, bool bNoEditText, ::tools::Rectangle* pAnchorRect ) const;
191  virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override;
192  void TakeTextAnchorRect(const sdr::table::CellPos& rPos, ::tools::Rectangle& rAnchorRect ) const;
193  virtual void TakeTextAnchorRect(::tools::Rectangle& rAnchorRect) const override;
194 
195  virtual bool IsAutoGrowHeight() const override;
196  virtual bool IsAutoGrowWidth() const override;
197 
198  virtual bool IsFontwork() const override;
199 
200  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
201  virtual SdrObjKind GetObjIdentifier() const override;
202  virtual void SetChanged() override;
203 
204  virtual bool AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool bHgt = true, bool bWdt = true) const override;
205  virtual bool AdjustTextFrameWidthAndHeight() override;
206  virtual OUString TakeObjNameSingul() const override;
207  virtual OUString TakeObjNamePlural() const override;
208  virtual SdrTableObj* CloneSdrObject(SdrModel& rTargetModel) const override;
209  virtual void RecalcSnapRect() override;
210  virtual const tools::Rectangle& GetSnapRect() const override;
211  virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
212 
213  virtual const tools::Rectangle& GetLogicRect() const override;
214  virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
215  virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
216 
217  virtual sal_uInt32 GetHdlCount() const override;
218  virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
219 
220  // Special drag methods
221  virtual bool hasSpecialDrag() const override;
222  virtual bool beginSpecialDrag(SdrDragStat& rDrag) const override;
223  virtual bool applySpecialDrag(SdrDragStat& rDrag) override;
224  virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const override;
225 
226  virtual bool BegCreate(SdrDragStat& rStat) override;
227  virtual bool MovCreate(SdrDragStat& rStat) override;
228  virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
229  virtual bool BckCreate(SdrDragStat& rStat) override;
230  virtual void BrkCreate(SdrDragStat& rStat) override;
231  virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
232  virtual PointerStyle GetCreatePointer() const override;
233 
234  virtual void NbcMove(const Size& rSiz) override;
235  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
236 
237  virtual bool BegTextEdit(SdrOutliner& rOutl) override;
238  virtual void EndTextEdit(SdrOutliner& rOutl) override;
239  virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const override;
240  void TakeTextEditArea(const sdr::table::CellPos& rPos, Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const;
241  virtual EEAnchorMode GetOutlinerViewAnchorMode() const override;
242 
243  virtual void NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject) override;
244 
245  virtual OutlinerParaObject* GetOutlinerParaObject() const override;
246 
247  virtual void NbcReformatText() override;
248 
249  virtual bool IsVerticalWriting() const override;
250  virtual void SetVerticalWriting(bool bVertical) override;
251 
252  css::text::WritingMode GetWritingMode() const;
253 
255  void AddUndo(SdrUndoAction* pUndo);
256 
258  void SetSkipChangeLayout(bool bSkipChangeLayout);
259 
260  virtual void onEditOutlinerStatusEvent( EditStatus* pEditStatus ) override;
261 
262  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
263 
264 private:
265  void init( sal_Int32 nColumns, sal_Int32 nRows );
266 
267  virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
268  virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
269 
270  virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
271  virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
272  virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override;
273 
274  SdrOutliner* GetCellTextEditOutliner( const sdr::table::Cell& rCell ) const;
275 
276  // For the ViewContactOfTableObj to build the primitive representation, it is necessary to access the
277  // TableLayouter for position and attribute information
279  const TableLayouter& getTableLayouter() const;
280 
283 };
284 
286 SVX_DLLPUBLIC void ExportAsRTF( SvStream& rStrm, SdrTableObj& rObj );
287 SVX_DLLPUBLIC void ImportAsRTF( SvStream& rStrm, SdrTableObj& rObj );
288 
289 }
290 
291 #endif
292 
293 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
Abstract base class (ABC) for all UndoActions of DrawingEngine.
Definition: svdundo.hxx:54
rtl::Reference< SdrTableObjImpl > mpImpl
Definition: svdotable.hxx:282
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:172
SdrObjKind
Definition: svdobjkind.hxx:24
Provides information about various ZObject properties.
Definition: svdobj.hxx:194
bool operator==(const CellPos &r) const
Definition: svdotable.hxx:69
rtl::Reference< Cell > CellRef
Definition: celltypes.hxx:33
TableHitKind
SdrTableHitKind.
Definition: svdotable.hxx:51
tools::Rectangle maLogicRect
Definition: svdotable.hxx:281
bool operator==(const TableStyleSettings &r) const
Definition: svdotable.cxx:181
void ExportAsRTF(SvStream &rStrm, SdrTableObj &rObj)
Hack for clipboard with calc and writer, export and import table content as rtf table.
bool IsTextEditActive() const
Definition: svdotable.hxx:181
bool operator!=(const CellPos &r) const
Definition: svdotable.hxx:70
CellPos(sal_Int32 nCol, sal_Int32 nRow)
Definition: svdotable.hxx:67
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
PointerStyle
FILE * init(int, char **)
TableStyleSettings.
Definition: svdotable.hxx:75
EEAnchorMode
SdrCreateCmd
Definition: svdtypes.hxx:27
void ImportAsRTF(SvStream &rStream, SdrTableObj &rObj)
TableStyleSettings & operator=(const TableStyleSettings &rStyle)
Definition: svdotable.cxx:170