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