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>
35 class ScTabDeletedHint
: public SfxHint
40 ScTabDeletedHint( SCTAB nTabNo
);
41 virtual ~ScTabDeletedHint() override
;
43 SCTAB
GetTab() const { return nTab
; }
46 class ScTabSizeChangedHint
: public SfxHint
51 ScTabSizeChangedHint( SCTAB nTabNo
);
52 virtual ~ScTabSizeChangedHint() override
;
54 SCTAB
GetTab() const { return nTab
; }
57 // Adjusting of detective UserData and draw undo's both have to be in SdrUndoGroup;
58 // therefore derived from SdrUndoAction
60 class ScUndoObjData
: public SdrUndoObj
63 ScAddress
const aOldStt
;
64 ScAddress
const aOldEnd
;
65 ScAddress
const aNewStt
;
66 ScAddress
const aNewEnd
;
68 ScUndoObjData( SdrObject
* pObj
, const ScAddress
& rOS
, const ScAddress
& rOE
,
69 const ScAddress
& rNS
, const ScAddress
& rNE
);
70 virtual ~ScUndoObjData() override
;
72 virtual void Undo() override
;
73 virtual void Redo() override
;
76 class ScUndoAnchorData
: public SdrUndoObj
79 bool mbWasCellAnchored
;
80 bool mbWasResizeWithCell
;
81 ScDocument
* const mpDoc
;
84 ScUndoAnchorData( SdrObject
* pObj
, ScDocument
* pDoc
, SCTAB nTab
);
85 virtual ~ScUndoAnchorData() override
;
87 virtual void Undo() override
;
88 virtual void Redo() override
;
91 class SC_DLLPUBLIC ScDrawLayer
: public FmFormModel
96 std::unique_ptr
<SdrUndoGroup
> pUndoGroup
;
102 void MoveCells( SCTAB nTab
, SCCOL nCol1
,SCROW nRow1
, SCCOL nCol2
,SCROW nRow2
,
103 SCCOL nDx
,SCROW nDy
, bool bUpdateNoteCaptionPos
);
105 void ResizeLastRectFromAnchor( const SdrObject
* pObj
, ScDrawObjData
& rData
, bool bUseLogicRect
, bool bNegativePage
, bool bCanResize
, bool bHiddenAsZero
= true );
108 ScDrawLayer( ScDocument
* pDocument
, const OUString
& rName
);
109 virtual ~ScDrawLayer() override
;
111 virtual SdrPage
* AllocPage(bool bMasterPage
) override
;
112 virtual SdrModel
* AllocModel() const override
;
113 virtual void SetChanged( bool bFlg
= true ) override
;
115 bool HasObjects() const;
117 bool ScAddPage( SCTAB nTab
);
118 void ScRemovePage( SCTAB nTab
);
119 void ScRenamePage( SCTAB nTab
, const OUString
& rNewName
);
120 void ScMovePage( sal_uInt16 nOldPos
, sal_uInt16 nNewPos
);
121 void ScCopyPage( sal_uInt16 nOldPos
, sal_uInt16 nNewPos
);
122 void ResetTab( SCTAB nStart
, SCTAB nEnd
);
124 ScDocument
* GetDocument() const { return pDoc
; }
126 void UseHyphenator();
128 bool GetPrintArea( ScRange
& rRange
, bool bSetHor
, bool bSetVer
) const;
130 // automatic adjustments
132 void EnableAdjust( bool bSet
) { bAdjustEnabled
= bSet
; }
134 void BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager
);
135 std::unique_ptr
<SdrUndoGroup
> GetCalcUndo();
136 bool IsRecording() const { return bRecording
; }
137 void AddCalcUndo( std::unique_ptr
<SdrUndoAction
> pUndo
);
139 void MoveArea( SCTAB nTab
, SCCOL nCol1
,SCROW nRow1
, SCCOL nCol2
,SCROW nRow2
,
140 SCCOL nDx
,SCROW nDy
, bool bInsDel
, bool bUpdateNoteCaptionPos
);
141 void RecalcPos( SdrObject
* pObj
, ScDrawObjData
& rData
, bool bNegativePage
, bool bUpdateNoteCaptionPos
);
143 bool HasObjectsInRows( SCTAB nTab
, SCROW nStartRow
, SCROW nEndRow
);
145 void DeleteObjectsInArea( SCTAB nTab
, SCCOL nCol1
,SCROW nRow1
,
146 SCCOL nCol2
,SCROW nRow2
);
147 void DeleteObjectsInSelection( const ScMarkData
& rMark
);
149 void CopyToClip( ScDocument
* pClipDoc
, SCTAB nTab
, const tools::Rectangle
& rRange
);
150 void CopyFromClip( ScDrawLayer
* pClipModel
,
151 SCTAB nSourceTab
, const tools::Rectangle
& rSourceRange
,
152 const ScAddress
& rDestPos
, const tools::Rectangle
& rDestRange
);
154 void SetPageSize( sal_uInt16 nPageNo
, const Size
& rSize
, bool bUpdateNoteCaptionPos
);
156 // mirror or move between positive and negative positions for RTL
157 void MirrorRTL( SdrObject
* pObj
);
158 static void MirrorRectRTL( tools::Rectangle
& rRect
); // for bounding rectangles etc.
160 /** Returns the rectangle for the passed cell address in 1/100 mm.
161 @param bMergedCell True = regards merged cells. False = use single column/row size. */
162 static tools::Rectangle
GetCellRect( const ScDocument
& rDoc
, const ScAddress
& rPos
, bool bMergedCell
);
164 // GetVisibleName: name for navigator etc: GetPersistName or GetName
165 // (ChartListenerCollection etc. must use GetPersistName directly)
166 static OUString
GetVisibleName( const SdrObject
* pObj
);
168 SdrObject
* GetNamedObject( const OUString
& rName
, sal_uInt16 nId
, SCTAB
& rFoundTab
) const;
169 // if pnCounter != NULL, the search for a name starts with this index + 1,
170 // and the index really used is returned.
171 OUString
GetNewGraphicName( long* pnCounter
= nullptr ) const;
172 void EnsureGraphicNames();
174 static bool IsCellAnchored( const SdrObject
& rObj
);
175 static bool IsResizeWithCell( const SdrObject
& rObj
);
176 static void SetPageAnchored( SdrObject
& );
177 static void SetCellAnchored( SdrObject
&, const ScDrawObjData
&rAnchor
);
178 static void SetVisualCellAnchored( SdrObject
&, const ScDrawObjData
&rAnchor
);
180 // Updates rAnchor based on position of rObj
181 static void GetCellAnchorFromPosition(
182 const tools::Rectangle
&rRectangle
,
183 ScDrawObjData
&rAnchor
,
184 const ScDocument
&rDoc
,
186 bool bHiddenAsZero
= true);
188 static void SetCellAnchoredFromPosition( SdrObject
&rObj
, const ScDocument
&rDoc
, SCTAB nTab
, bool bResizeWithCell
);
189 static void UpdateCellAnchorFromPositionEnd( const SdrObject
&rObj
, ScDrawObjData
&rAnchor
, const ScDocument
&rDoc
, SCTAB nTab
, bool bUseLogicRect
= true );
190 static ScAnchorType
GetAnchorType( const SdrObject
& );
191 std::vector
<SdrObject
*> GetObjectsAnchoredToRows(SCTAB nTab
, SCROW nStartRow
, SCROW nEndRow
);
192 std::map
<SCROW
, std::vector
<SdrObject
*>> GetObjectsAnchoredToRange(SCTAB nTab
, SCCOL nCol
, SCROW nStartRow
, SCROW nEndRow
);
193 bool HasObjectsAnchoredInRange(const ScRange
& rRange
);
194 void MoveObject(SdrObject
* pObj
, const ScAddress
& rNewPosition
);
196 // positions for detektive 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
);
212 static ScIMapInfo
* GetIMapInfo( const SdrObject
* pObj
);
214 static IMapObject
* GetHitIMapObject( const SdrObject
* pObject
,
215 const Point
& rWinPoint
, const vcl::Window
& rCmpWnd
);
217 static ScMacroInfo
* GetMacroInfo( SdrObject
* pObj
, bool bCreate
= false );
219 virtual ImageMap
* GetImageMapForObject(SdrObject
* pObj
) override
;
222 static SfxObjectShell
* pGlobalDrawPersist
; // for AllocModel
224 static void SetGlobalDrawPersist(SfxObjectShell
* pPersist
);
226 virtual css::uno::Reference
< css::uno::XInterface
> createUnoModel() override
;
229 extern bool bDrawIsInUndo
; // somewhere as member!
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */