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