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 SC_DRWLAYER_HXX
21 #define SC_DRWLAYER_HXX
23 #include <vcl/graph.hxx>
24 #include <svx/fmmodel.hxx>
25 #include <svx/svdundo.hxx>
38 class ScTabDeletedHint
: public SfxHint
44 ScTabDeletedHint( SCTAB nTabNo
= SCTAB_MAX
);
45 virtual ~ScTabDeletedHint();
47 SCTAB
GetTab() { return nTab
; }
50 class ScTabSizeChangedHint
: public SfxHint
56 ScTabSizeChangedHint( SCTAB nTabNo
= SCTAB_MAX
);
57 virtual ~ScTabSizeChangedHint();
59 SCTAB
GetTab() { return nTab
; }
62 // Adjusting of detective UserData and draw undo's both have to be in SdrUndoGroup;
63 // therefore derived from SdrUndoAction
65 class ScUndoObjData
: public SdrUndoObj
73 ScUndoObjData( SdrObject
* pObj
, const ScAddress
& rOS
, const ScAddress
& rOE
,
74 const ScAddress
& rNS
, const ScAddress
& rNE
);
81 class SC_DLLPUBLIC ScDrawLayer
: public FmFormModel
86 SdrUndoGroup
* pUndoGroup
;
88 sal_Bool bAdjustEnabled
;
89 sal_Bool bHyphenatorSet
;
92 void MoveCells( SCTAB nTab
, SCCOL nCol1
,SCROW nRow1
, SCCOL nCol2
,SCROW nRow2
,
93 SCsCOL nDx
,SCsROW nDy
, bool bUpdateNoteCaptionPos
);
95 void RecalcPos( SdrObject
* pObj
, ScDrawObjData
& rData
, bool bNegativePage
, bool bUpdateNoteCaptionPos
);
96 void ResizeLastRectFromAnchor( SdrObject
* pObj
, ScDrawObjData
& rData
, bool bUseLogicRect
, bool bNegativePage
, bool bCanResize
, bool bHiddenAsZero
= true );
99 ScDrawLayer( ScDocument
* pDocument
, const OUString
& rName
);
100 virtual ~ScDrawLayer();
102 virtual SdrPage
* AllocPage(bool bMasterPage
);
103 virtual SdrModel
* AllocModel() const;
104 virtual void SetChanged( sal_Bool bFlg
= sal_True
);
106 virtual SdrLayerID
GetControlExportLayerId( const SdrObject
& ) const;
108 sal_Bool
HasObjects() const;
110 sal_Bool
ScAddPage( SCTAB nTab
);
111 void ScRemovePage( SCTAB nTab
);
112 void ScRenamePage( SCTAB nTab
, const OUString
& rNewName
);
113 void ScMovePage( sal_uInt16 nOldPos
, sal_uInt16 nNewPos
);
114 // incl. content, bAlloc=FALSE -> only content
115 void ScCopyPage( sal_uInt16 nOldPos
, sal_uInt16 nNewPos
, sal_Bool bAlloc
);
116 void ResetTab( SCTAB nStart
, SCTAB nEnd
);
118 ScDocument
* GetDocument() const { return pDoc
; }
120 void UseHyphenator();
122 sal_Bool
GetPrintArea( ScRange
& rRange
, sal_Bool bSetHor
, sal_Bool bSetVer
) const;
124 // automatic adjustments
126 void EnableAdjust( sal_Bool bSet
= sal_True
) { bAdjustEnabled
= bSet
; }
128 void BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager
);
129 SdrUndoGroup
* GetCalcUndo();
130 sal_Bool
IsRecording() const { return bRecording
; }
131 void AddCalcUndo( SdrUndoAction
* pUndo
);
133 void MoveArea( SCTAB nTab
, SCCOL nCol1
,SCROW nRow1
, SCCOL nCol2
,SCROW nRow2
,
134 SCsCOL nDx
,SCsROW nDy
, sal_Bool bInsDel
, bool bUpdateNoteCaptionPos
= true );
136 sal_Bool
HasObjectsInRows( SCTAB nTab
, SCROW nStartRow
, SCROW nEndRow
);
138 void DeleteObjectsInArea( SCTAB nTab
, SCCOL nCol1
,SCROW nRow1
,
139 SCCOL nCol2
,SCROW nRow2
);
140 void DeleteObjectsInSelection( const ScMarkData
& rMark
);
142 void CopyToClip( ScDocument
* pClipDoc
, SCTAB nTab
, const Rectangle
& rRange
);
143 void CopyFromClip( ScDrawLayer
* pClipModel
,
144 SCTAB nSourceTab
, const Rectangle
& rSourceRange
,
145 const ScAddress
& rDestPos
, const Rectangle
& rDestRange
);
147 void SetPageSize( sal_uInt16 nPageNo
, const Size
& rSize
, bool bUpdateNoteCaptionPos
= true );
149 // mirror or move between positive and negative positions for RTL
150 void MirrorRTL( SdrObject
* pObj
);
151 static void MirrorRectRTL( Rectangle
& rRect
); // for bounding rectangles etc.
153 /** Returns the rectangle for the passed cell address in 1/100 mm.
154 @param bMergedCell True = regards merged cells. False = use single column/row size. */
155 static Rectangle
GetCellRect( ScDocument
& rDoc
, const ScAddress
& rPos
, bool bMergedCell
);
157 // GetVisibleName: name for navigator etc: GetPersistName or GetName
158 // (ChartListenerCollection etc. must use GetPersistName directly)
159 static OUString
GetVisibleName( SdrObject
* pObj
);
161 SdrObject
* GetNamedObject( const OUString
& rName
, sal_uInt16 nId
, SCTAB
& rFoundTab
) const;
162 // if pnCounter != NULL, the search for a name starts with this index + 1,
163 // and the index really used is returned.
164 OUString
GetNewGraphicName( long* pnCounter
= NULL
) const;
165 void EnsureGraphicNames();
167 static bool IsCellAnchored( const SdrObject
& rObj
);
168 static void SetPageAnchored( SdrObject
& );
169 static void SetCellAnchored( SdrObject
&, const ScDrawObjData
&rAnchor
);
170 static void SetVisualCellAnchored( SdrObject
&, const ScDrawObjData
&rAnchor
);
171 // Updates rAnchor based on position of rObj
172 static void GetCellAnchorFromPosition( SdrObject
&rObj
, ScDrawObjData
&rAnchor
, const ScDocument
&rDoc
, SCTAB nTab
, bool bUseLogicRect
= true, bool bHiddenAsZero
= true );
173 static void SetCellAnchoredFromPosition( SdrObject
&rObj
, const ScDocument
&rDoc
, SCTAB nTab
);
174 static void UpdateCellAnchorFromPositionEnd( SdrObject
&rObj
, ScDrawObjData
&rAnchor
, const ScDocument
&rDoc
, SCTAB nTab
, bool bUseLogicRect
= true );
175 static ScAnchorType
GetAnchorType( const SdrObject
& );
177 // positions for detektive lines
178 static ScDrawObjData
* GetObjData( SdrObject
* pObj
, sal_Bool bCreate
=false );
179 static ScDrawObjData
* GetNonRotatedObjData( SdrObject
* pObj
, sal_Bool bCreate
=false );
181 // The sheet information in ScDrawObjData isn't updated when sheets are inserted/deleted.
182 // Use this method to get an object with positions on the specified sheet (should be the
183 // sheet on which the object is inserted).
184 static ScDrawObjData
* GetObjDataTab( SdrObject
* pObj
, SCTAB nTab
);
186 /** Returns true, if the passed object is the caption of a cell note. */
187 static bool IsNoteCaption( SdrObject
* pObj
);
189 /** Returns the object data, if the passed object is a cell note caption. */
190 static ScDrawObjData
* GetNoteCaptionData( SdrObject
* pObj
, SCTAB nTab
);
193 static ScIMapInfo
* GetIMapInfo( SdrObject
* pObj
);
195 static IMapObject
* GetHitIMapObject( SdrObject
* pObject
,
196 const Point
& rWinPoint
, const Window
& rCmpWnd
);
198 static ScMacroInfo
* GetMacroInfo( SdrObject
* pObj
, sal_Bool bCreate
= false );
201 static SfxObjectShell
* pGlobalDrawPersist
; // for AllocModel
203 static void SetGlobalDrawPersist(SfxObjectShell
* pPersist
);
205 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> createUnoModel();
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */