1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SC_INC_DRWLAYER_HXX
21 #define INCLUDED_SC_INC_DRWLAYER_HXX
23 #include <svx/fmmodel.hxx>
24 #include <svx/svdundo.hxx>
33 class ScTabDeletedHint final
: public SfxHint
38 ScTabDeletedHint( SCTAB nTabNo
);
39 virtual ~ScTabDeletedHint() override
;
41 SCTAB
GetTab() const { return nTab
; }
44 class ScTabSizeChangedHint final
: public SfxHint
49 ScTabSizeChangedHint( SCTAB nTabNo
);
50 virtual ~ScTabSizeChangedHint() override
;
52 SCTAB
GetTab() const { return nTab
; }
55 // Adjusting of detective UserData and draw undo's both have to be in SdrUndoGroup;
56 // therefore derived from SdrUndoAction
58 class ScUndoObjData final
: public SdrUndoObj
61 ScAddress
const aOldStt
;
62 ScAddress
const aOldEnd
;
63 ScAddress
const aNewStt
;
64 ScAddress
const aNewEnd
;
66 ScUndoObjData( SdrObject
* pObj
, const ScAddress
& rOS
, const ScAddress
& rOE
,
67 const ScAddress
& rNS
, const ScAddress
& rNE
);
68 virtual ~ScUndoObjData() override
;
70 virtual void Undo() override
;
71 virtual void Redo() override
;
74 class ScUndoAnchorData final
: public SdrUndoObj
77 bool mbWasCellAnchored
;
78 bool mbWasResizeWithCell
;
79 ScDocument
* const mpDoc
;
82 ScUndoAnchorData( SdrObject
* pObj
, ScDocument
* pDoc
, SCTAB nTab
);
83 virtual ~ScUndoAnchorData() override
;
85 virtual void Undo() override
;
86 virtual void Redo() override
;
89 class SC_DLLPUBLIC ScDrawLayer final
: public FmFormModel
94 std::unique_ptr
<SdrUndoGroup
> pUndoGroup
;
100 void MoveCells( SCTAB nTab
, SCCOL nCol1
,SCROW nRow1
, SCCOL nCol2
,SCROW nRow2
,
101 SCCOL nDx
,SCROW nDy
, bool bUpdateNoteCaptionPos
);
103 void ResizeLastRectFromAnchor( const SdrObject
* pObj
, ScDrawObjData
& rData
, bool bUseLogicRect
, bool bNegativePage
, bool bCanResize
, bool bHiddenAsZero
= true );
106 ScDrawLayer( ScDocument
* pDocument
, const OUString
& rName
);
107 virtual ~ScDrawLayer() override
;
109 virtual SdrPage
* AllocPage(bool bMasterPage
) override
;
110 virtual SdrModel
* AllocModel() const override
;
111 virtual void SetChanged( bool bFlg
= true ) override
;
113 bool HasObjects() const;
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
);
122 ScDocument
* GetDocument() const { return pDoc
; }
124 void UseHyphenator();
126 bool GetPrintArea( ScRange
& rRange
, bool bSetHor
, bool bSetVer
) const;
128 // automatic adjustments
130 void EnableAdjust( bool bSet
) { bAdjustEnabled
= bSet
; }
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
);
137 void MoveArea( SCTAB nTab
, SCCOL nCol1
,SCROW nRow1
, SCCOL nCol2
,SCROW nRow2
,
138 SCCOL nDx
,SCROW nDy
, bool bInsDel
, bool bUpdateNoteCaptionPos
);
139 void InitializeCellAnchoredObj(SdrObject
* pObj
, ScDrawObjData
& rData
);
140 void RecalcPos( SdrObject
* pObj
, ScDrawObjData
& rData
, bool bNegativePage
, bool bUpdateNoteCaptionPos
);
142 bool HasObjectsInRows( SCTAB nTab
, SCROW nStartRow
, SCROW nEndRow
);
144 void DeleteObjectsInArea( SCTAB nTab
, SCCOL nCol1
,SCROW nRow1
,
145 SCCOL nCol2
,SCROW nRow2
, bool bAnchored
= false );
146 void DeleteObjectsInSelection( const ScMarkData
& rMark
);
148 void CopyToClip( ScDocument
* pClipDoc
, SCTAB nTab
, const tools::Rectangle
& rRange
);
149 void CopyFromClip( ScDrawLayer
* pClipModel
,
150 SCTAB nSourceTab
, const tools::Rectangle
& rSourceRange
,
151 const ScAddress
& rDestPos
, const tools::Rectangle
& rDestRange
);
153 void SetPageSize( sal_uInt16 nPageNo
, const Size
& rSize
, bool bUpdateNoteCaptionPos
);
155 // mirror or move between positive and negative positions for RTL
156 void MirrorRTL( SdrObject
* pObj
);
157 static void MirrorRectRTL( tools::Rectangle
& rRect
); // for bounding rectangles etc.
159 /** Returns the rectangle for the passed cell address in 1/100 mm.
160 @param bMergedCell True = regards merged cells. False = use single column/row size. */
161 static tools::Rectangle
GetCellRect( const ScDocument
& rDoc
, const ScAddress
& rPos
, bool bMergedCell
);
163 // GetVisibleName: name for navigator etc: GetPersistName or GetName
164 // (ChartListenerCollection etc. must use GetPersistName directly)
165 static OUString
GetVisibleName( const SdrObject
* pObj
);
167 SdrObject
* GetNamedObject( const OUString
& rName
, sal_uInt16 nId
, SCTAB
& rFoundTab
) const;
168 // if pnCounter != NULL, the search for a name starts with this index + 1,
169 // and the index really used is returned.
170 OUString
GetNewGraphicName( long* pnCounter
= nullptr ) const;
171 void EnsureGraphicNames();
173 static bool IsCellAnchored( const SdrObject
& rObj
);
174 static bool IsResizeWithCell( const SdrObject
& rObj
);
175 static void SetPageAnchored( SdrObject
& );
176 static void SetCellAnchored( SdrObject
&, const ScDrawObjData
&rAnchor
);
177 static void SetVisualCellAnchored( SdrObject
&, const ScDrawObjData
&rAnchor
);
179 // Updates rAnchor based on position of rObj
180 static void GetCellAnchorFromPosition(
181 const tools::Rectangle
&rRectangle
,
182 ScDrawObjData
&rAnchor
,
183 const ScDocument
&rDoc
,
185 bool bHiddenAsZero
= true);
187 static void SetCellAnchoredFromPosition( SdrObject
&rObj
, const ScDocument
&rDoc
, SCTAB nTab
, bool bResizeWithCell
);
188 static void UpdateCellAnchorFromPositionEnd( const SdrObject
&rObj
, ScDrawObjData
&rAnchor
, const ScDocument
&rDoc
, SCTAB nTab
, bool bUseLogicRect
= true );
189 static ScAnchorType
GetAnchorType( const SdrObject
& );
190 std::vector
<SdrObject
*> GetObjectsAnchoredToRows(SCTAB nTab
, SCROW nStartRow
, SCROW nEndRow
);
191 std::map
<SCROW
, std::vector
<SdrObject
*>> GetObjectsAnchoredToRange(SCTAB nTab
, SCCOL nCol
, SCROW nStartRow
, SCROW nEndRow
);
192 bool HasObjectsAnchoredInRange(const ScRange
& rRange
);
193 std::vector
<SdrObject
*> GetObjectsAnchoredToCols(SCTAB nTab
, SCCOL nStartCol
, SCCOL nEndCol
);
194 void MoveObject(SdrObject
* pObj
, const ScAddress
& rNewPosition
);
196 // positions for detective lines
197 static ScDrawObjData
* GetObjData( SdrObject
* pObj
, bool bCreate
=false );
198 static ScDrawObjData
* GetNonRotatedObjData( SdrObject
* pObj
, bool bCreate
=false );
200 // The sheet information in ScDrawObjData isn't updated when sheets are inserted/deleted.
201 // Use this method to get an object with positions on the specified sheet (should be the
202 // sheet on which the object is inserted).
203 static ScDrawObjData
* GetObjDataTab( SdrObject
* pObj
, SCTAB nTab
);
205 /** Returns true, if the passed object is the caption of a cell note. */
206 static bool IsNoteCaption( SdrObject
* pObj
);
208 /** Returns the object data, if the passed object is a cell note caption. */
209 static ScDrawObjData
* GetNoteCaptionData( SdrObject
* pObj
, SCTAB nTab
);
211 static ScMacroInfo
* GetMacroInfo( SdrObject
* pObj
, bool bCreate
= false );
214 static SfxObjectShell
* pGlobalDrawPersist
; // for AllocModel
216 static void SetGlobalDrawPersist(SfxObjectShell
* pPersist
);
218 virtual css::uno::Reference
< css::uno::XInterface
> createUnoModel() override
;
221 extern bool bDrawIsInUndo
; // somewhere as member!
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */