LibreOffice Module sc (master) 1
drwlayer.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 <svx/fmmodel.hxx>
23#include <svx/svdundo.hxx>
24#include "global.hxx"
25
26class ScDocument;
27class SfxObjectShell;
28class ScDrawObjData;
29class ScMacroInfo;
30class ScMarkData;
31enum class SdrObjKind : sal_uInt16;
32
33class ScTabDeletedHint final : public SfxHint
34{
35private:
37public:
38 ScTabDeletedHint( SCTAB nTabNo );
39 virtual ~ScTabDeletedHint() override;
40
41 SCTAB GetTab() const { return nTab; }
42};
43
44class ScTabSizeChangedHint final : public SfxHint
45{
46private:
48public:
50 virtual ~ScTabSizeChangedHint() override;
51
52 SCTAB GetTab() const { return nTab; }
53};
54
55// Adjusting of detective UserData and draw undo's both have to be in SdrUndoGroup;
56// therefore derived from SdrUndoAction
57
58class ScUndoObjData final : public SdrUndoObj
59{
60private:
65public:
66 ScUndoObjData( SdrObject* pObj, const ScAddress& rOS, const ScAddress& rOE,
67 const ScAddress& rNS, const ScAddress& rNE );
68 virtual ~ScUndoObjData() override;
69
70 virtual void Undo() override;
71 virtual void Redo() override;
72};
73
74class ScUndoAnchorData final : public SdrUndoObj
75{
76private:
81public:
82 ScUndoAnchorData( SdrObject* pObj, ScDocument* pDoc, SCTAB nTab );
83 virtual ~ScUndoAnchorData() override;
84
85 virtual void Undo() override;
86 virtual void Redo() override;
87};
88
89// for ScDrawLayer::SetPageSize
91{
92 RecalcPosMode, // used for row height or col width changes
93 MoveRTLMode, // used for switch to RTL during import of right-to-left sheet
94 MirrorRTLMode // used for switch between RTL and LTR by .uno:SheetRightToLeft
95};
96
98{
99private:
100 OUString aName;
102 std::unique_ptr<SdrUndoGroup> pUndoGroup;
106
107private:
108 void MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
109 SCCOL nDx,SCROW nDy, bool bUpdateNoteCaptionPos );
110
111 void ResizeLastRectFromAnchor( const SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bCanResize );
112
113public:
114 ScDrawLayer( ScDocument* pDocument, OUString aName );
115 virtual ~ScDrawLayer() override;
116
117 virtual rtl::Reference<SdrPage> AllocPage(bool bMasterPage) override;
118 virtual SdrModel* AllocModel() const override;
119 virtual void SetChanged( bool bFlg = true ) override;
120
121 void CreateDefaultStyles();
122 bool HasObjects() const;
123
124 bool ScAddPage( SCTAB nTab );
125 void ScRemovePage( SCTAB nTab );
126 void ScRenamePage( SCTAB nTab, const OUString& rNewName );
127 void ScMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos );
128 void ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos );
129 void ResetTab( SCTAB nStart, SCTAB nEnd );
130
131 ScDocument* GetDocument() const { return pDoc; }
132
133 void UseHyphenator();
134
135 bool GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const;
136
137 // automatic adjustments
138
139 void EnableAdjust( bool bSet ) { bAdjustEnabled = bSet; }
140
141 void BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager);
142 std::unique_ptr<SdrUndoGroup> GetCalcUndo();
143 bool IsRecording() const { return bRecording; }
144 void AddCalcUndo( std::unique_ptr<SdrUndoAction> pUndo );
145
146 void MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
147 SCCOL nDx,SCROW nDy, bool bInsDel, bool bUpdateNoteCaptionPos );
148 void InitializeCellAnchoredObj(SdrObject* pObj, ScDrawObjData& rData);
149 void RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos );
150
151 bool HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow );
152
153 void DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
154 SCCOL nCol2,SCROW nRow2, bool bAnchored = false );
155 void DeleteObjectsInSelection( const ScMarkData& rMark );
156
157 void CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rectangle& rRange );
158 void CopyFromClip( ScDrawLayer* pClipModel,
159 SCTAB nSourceTab, const ScRange& rSourceRange,
160 const ScAddress& rDestPos, const ScRange& rDestRange,
161 bool bTransposing = false);
162
163 void SetPageSize(sal_uInt16 nPageNo, const Size& rSize, bool bUpdateNoteCaptionPos,
164 const ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode);
165
166 // mirror or move between positive and negative positions for RTL
167 void MirrorRTL( SdrObject* pObj );
168 void MoveRTL(SdrObject* pObj);
169 static void MirrorRectRTL( tools::Rectangle& rRect ); // for bounding rectangles etc.
170
173 static tools::Rectangle GetCellRect( const ScDocument& rDoc, const ScAddress& rPos, bool bMergedCell );
174
175 // GetVisibleName: name for navigator etc: GetPersistName or GetName
176 // (ChartListenerCollection etc. must use GetPersistName directly)
177 static OUString GetVisibleName( const SdrObject* pObj );
178
179 SdrObject* GetNamedObject( std::u16string_view rName, SdrObjKind nId, SCTAB& rFoundTab ) const;
180 // if pnCounter != NULL, the search for a name starts with this index + 1,
181 // and the index really used is returned.
182 OUString GetNewGraphicName( tools::Long* pnCounter = nullptr ) const;
183 void EnsureGraphicNames();
184
185 static bool IsCellAnchored( const SdrObject& rObj );
186 static bool IsResizeWithCell( const SdrObject& rObj );
187 static void SetPageAnchored( SdrObject& );
188 static void SetCellAnchored( SdrObject&, const ScDrawObjData &rAnchor );
189 static void SetNonRotatedAnchor( SdrObject&, const ScDrawObjData &rAnchor );
190
191 // Updates rAnchor based on position of rObj
192 static void GetCellAnchorFromPosition(
193 const tools::Rectangle &rRectangle,
194 ScDrawObjData &rAnchor,
195 const ScDocument &rDoc,
196 SCTAB nTab,
197 bool bHiddenAsZero = true);
198
199 static void SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab, bool bResizeWithCell );
200 static void UpdateCellAnchorFromPositionEnd( const SdrObject &rObj, ScDrawObjData &rAnchor, const ScDocument &rDoc, SCTAB nTab, bool bUseLogicRect = true );
201 static ScAnchorType GetAnchorType( const SdrObject& );
202 std::vector<SdrObject*> GetObjectsAnchoredToRows(SCTAB nTab, SCROW nStartRow, SCROW nEndRow);
203 std::map<SCROW, std::vector<SdrObject*>> GetObjectsAnchoredToRange(SCTAB nTab, SCCOL nCol, SCROW nStartRow, SCROW nEndRow);
204 bool HasObjectsAnchoredInRange(const ScRange& rRange);
205 std::vector<SdrObject*> GetObjectsAnchoredToCols(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol);
206 void MoveObject(SdrObject* pObj, const ScAddress& rNewPosition);
207
208 // positions for detective lines
209 static ScDrawObjData* GetObjData( SdrObject* pObj, bool bCreate=false );
210 static ScDrawObjData* GetNonRotatedObjData( SdrObject* pObj, bool bCreate=false );
211
212 // The sheet information in ScDrawObjData isn't updated when sheets are inserted/deleted.
213 // Use this method to get an object with positions on the specified sheet (should be the
214 // sheet on which the object is inserted).
215 static ScDrawObjData* GetObjDataTab( SdrObject* pObj, SCTAB nTab );
216
218 static bool IsNoteCaption( SdrObject* pObj );
219
221 static ScDrawObjData* GetNoteCaptionData( SdrObject* pObj, SCTAB nTab );
222
223 static ScMacroInfo* GetMacroInfo( SdrObject* pObj, bool bCreate = false );
224
225private:
226 static SfxObjectShell* pGlobalDrawPersist; // for AllocModel
227public:
228 static void SetGlobalDrawPersist(SfxObjectShell* pPersist);
229private:
230 virtual css::uno::Reference< css::uno::XInterface > createUnoModel() override;
231};
232
233extern bool bDrawIsInUndo; // somewhere as member!
234
235/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual rtl::Reference< SdrPage > AllocPage(bool bMasterPage) override
static SfxObjectShell * pGlobalDrawPersist
Definition: drwlayer.hxx:226
void EnableAdjust(bool bSet)
Definition: drwlayer.hxx:139
bool bAdjustEnabled
Definition: drwlayer.hxx:104
ScDocument * GetDocument() const
Definition: drwlayer.hxx:131
bool IsRecording() const
Definition: drwlayer.hxx:143
std::unique_ptr< SdrUndoGroup > pUndoGroup
Definition: drwlayer.hxx:102
bool bRecording
Definition: drwlayer.hxx:103
ScDocument * pDoc
Definition: drwlayer.hxx:101
OUString aName
Definition: drwlayer.hxx:100
bool bHyphenatorSet
Definition: drwlayer.hxx:105
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
ScTabDeletedHint(SCTAB nTabNo)
Definition: drwlayer.cxx:204
virtual ~ScTabDeletedHint() override
Definition: drwlayer.cxx:209
SCTAB GetTab() const
Definition: drwlayer.hxx:41
virtual ~ScTabSizeChangedHint() override
Definition: drwlayer.cxx:218
SCTAB GetTab() const
Definition: drwlayer.hxx:52
ScTabSizeChangedHint(SCTAB nTabNo)
Definition: drwlayer.cxx:213
virtual void Redo() override
Definition: drwlayer.cxx:189
ScDocument * mpDoc
Definition: drwlayer.hxx:79
virtual ~ScUndoAnchorData() override
Definition: drwlayer.cxx:170
bool mbWasResizeWithCell
Definition: drwlayer.hxx:78
virtual void Undo() override
Definition: drwlayer.cxx:174
bool mbWasCellAnchored
Definition: drwlayer.hxx:77
ScUndoAnchorData(SdrObject *pObj, ScDocument *pDoc, SCTAB nTab)
Definition: drwlayer.cxx:161
virtual ~ScUndoObjData() override
Definition: drwlayer.cxx:119
ScAddress aOldEnd
Definition: drwlayer.hxx:62
ScAddress aNewStt
Definition: drwlayer.hxx:63
ScAddress aNewEnd
Definition: drwlayer.hxx:64
virtual void Redo() override
Definition: drwlayer.cxx:142
virtual void Undo() override
Definition: drwlayer.cxx:123
ScAddress aOldStt
Definition: drwlayer.hxx:61
ScUndoObjData(SdrObject *pObj, const ScAddress &rOS, const ScAddress &rOE, const ScAddress &rNS, const ScAddress &rNE)
Definition: drwlayer.cxx:109
virtual void SetChanged(bool bFlg=true)
virtual css::uno::Reference< css::uno::XInterface > createUnoModel()
virtual SdrModel * AllocModel() const
bool bDrawIsInUndo
Definition: drwlayer.cxx:107
ScObjectHandling
Definition: drwlayer.hxx:91
ScAnchorType
Definition: global.hxx:374
long Long
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
SdrObjKind
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17