Line data Source code
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 SC_DRWLAYER_HXX
21 : #define SC_DRWLAYER_HXX
22 :
23 : #include <vcl/graph.hxx>
24 : #include <svx/fmmodel.hxx>
25 : #include <svx/svdundo.hxx>
26 : #include "global.hxx"
27 :
28 : class ScDocument;
29 : class SfxObjectShell;
30 : class ScDrawObjData;
31 : class ScIMapInfo;
32 : class ScMacroInfo;
33 : class IMapObject;
34 : class ScMarkData;
35 : class ScRange;
36 : class ScAddress;
37 :
38 : class ScTabDeletedHint : public SfxHint
39 : {
40 : private:
41 : SCTAB nTab;
42 : public:
43 : TYPEINFO_OVERRIDE();
44 : ScTabDeletedHint( SCTAB nTabNo = SCTAB_MAX );
45 : virtual ~ScTabDeletedHint();
46 :
47 0 : SCTAB GetTab() { return nTab; }
48 : };
49 :
50 : class ScTabSizeChangedHint : public SfxHint
51 : {
52 : private:
53 : SCTAB nTab;
54 : public:
55 : TYPEINFO_OVERRIDE();
56 : ScTabSizeChangedHint( SCTAB nTabNo = SCTAB_MAX );
57 : virtual ~ScTabSizeChangedHint();
58 :
59 0 : SCTAB GetTab() { return nTab; }
60 : };
61 :
62 : // Adjusting of detective UserData and draw undo's both have to be in SdrUndoGroup;
63 : // therefore derived from SdrUndoAction
64 :
65 : class ScUndoObjData : public SdrUndoObj
66 : {
67 : private:
68 : ScAddress aOldStt;
69 : ScAddress aOldEnd;
70 : ScAddress aNewStt;
71 : ScAddress aNewEnd;
72 : public:
73 : ScUndoObjData( SdrObject* pObj, const ScAddress& rOS, const ScAddress& rOE,
74 : const ScAddress& rNS, const ScAddress& rNE );
75 : virtual ~ScUndoObjData();
76 :
77 : virtual void Undo() SAL_OVERRIDE;
78 : virtual void Redo() SAL_OVERRIDE;
79 : };
80 :
81 : class SC_DLLPUBLIC ScDrawLayer : public FmFormModel
82 : {
83 : private:
84 : OUString aName;
85 : ScDocument* pDoc;
86 : SdrUndoGroup* pUndoGroup;
87 : bool bRecording;
88 : bool bAdjustEnabled;
89 : bool bHyphenatorSet;
90 :
91 : private:
92 : void MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
93 : SCsCOL nDx,SCsROW nDy, bool bUpdateNoteCaptionPos );
94 :
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 );
97 :
98 : public:
99 : ScDrawLayer( ScDocument* pDocument, const OUString& rName );
100 : virtual ~ScDrawLayer();
101 :
102 : virtual SdrPage* AllocPage(bool bMasterPage) SAL_OVERRIDE;
103 : virtual SdrModel* AllocModel() const SAL_OVERRIDE;
104 : virtual void SetChanged( bool bFlg = true ) SAL_OVERRIDE;
105 :
106 : virtual SdrLayerID GetControlExportLayerId( const SdrObject & ) const SAL_OVERRIDE;
107 :
108 : bool HasObjects() const;
109 :
110 : 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 : void ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos);
115 : void ResetTab( SCTAB nStart, SCTAB nEnd );
116 :
117 0 : ScDocument* GetDocument() const { return pDoc; }
118 :
119 : void UseHyphenator();
120 :
121 : bool GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const;
122 :
123 : // automatic adjustments
124 :
125 0 : void EnableAdjust( bool bSet = true ) { bAdjustEnabled = bSet; }
126 :
127 : void BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager);
128 : SdrUndoGroup* GetCalcUndo();
129 0 : bool IsRecording() const { return bRecording; }
130 : void AddCalcUndo( SdrUndoAction* pUndo );
131 :
132 : void MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
133 : SCsCOL nDx,SCsROW nDy, bool bInsDel, bool bUpdateNoteCaptionPos = true );
134 :
135 : bool HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow );
136 :
137 : void DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
138 : SCCOL nCol2,SCROW nRow2 );
139 : void DeleteObjectsInSelection( const ScMarkData& rMark );
140 :
141 : void CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const Rectangle& rRange );
142 : void CopyFromClip( ScDrawLayer* pClipModel,
143 : SCTAB nSourceTab, const Rectangle& rSourceRange,
144 : const ScAddress& rDestPos, const Rectangle& rDestRange );
145 :
146 : void SetPageSize( sal_uInt16 nPageNo, const Size& rSize, bool bUpdateNoteCaptionPos = true );
147 :
148 : // mirror or move between positive and negative positions for RTL
149 : void MirrorRTL( SdrObject* pObj );
150 : static void MirrorRectRTL( Rectangle& rRect ); // for bounding rectangles etc.
151 :
152 : /** Returns the rectangle for the passed cell address in 1/100 mm.
153 : @param bMergedCell True = regards merged cells. False = use single column/row size. */
154 : static Rectangle GetCellRect( ScDocument& rDoc, const ScAddress& rPos, bool bMergedCell );
155 :
156 : // GetVisibleName: name for navigator etc: GetPersistName or GetName
157 : // (ChartListenerCollection etc. must use GetPersistName directly)
158 : static OUString GetVisibleName( SdrObject* pObj );
159 :
160 : SdrObject* GetNamedObject( const OUString& rName, sal_uInt16 nId, SCTAB& rFoundTab ) const;
161 : // if pnCounter != NULL, the search for a name starts with this index + 1,
162 : // and the index really used is returned.
163 : OUString GetNewGraphicName( long* pnCounter = NULL ) const;
164 : void EnsureGraphicNames();
165 :
166 : static bool IsCellAnchored( const SdrObject& rObj );
167 : static void SetPageAnchored( SdrObject& );
168 : static void SetCellAnchored( SdrObject&, const ScDrawObjData &rAnchor );
169 : static void SetVisualCellAnchored( SdrObject&, const ScDrawObjData &rAnchor );
170 : // Updates rAnchor based on position of rObj
171 : static void GetCellAnchorFromPosition( SdrObject &rObj, ScDrawObjData &rAnchor, const ScDocument &rDoc, SCTAB nTab, bool bUseLogicRect = true, bool bHiddenAsZero = true );
172 : static void SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab );
173 : static void UpdateCellAnchorFromPositionEnd( SdrObject &rObj, ScDrawObjData &rAnchor, const ScDocument &rDoc, SCTAB nTab, bool bUseLogicRect = true );
174 : static ScAnchorType GetAnchorType( const SdrObject& );
175 :
176 : // positions for detektive lines
177 : static ScDrawObjData* GetObjData( SdrObject* pObj, bool bCreate=false );
178 : static ScDrawObjData* GetNonRotatedObjData( SdrObject* pObj, bool bCreate=false );
179 :
180 : // The sheet information in ScDrawObjData isn't updated when sheets are inserted/deleted.
181 : // Use this method to get an object with positions on the specified sheet (should be the
182 : // sheet on which the object is inserted).
183 : static ScDrawObjData* GetObjDataTab( SdrObject* pObj, SCTAB nTab );
184 :
185 : /** Returns true, if the passed object is the caption of a cell note. */
186 : static bool IsNoteCaption( SdrObject* pObj );
187 :
188 : /** Returns the object data, if the passed object is a cell note caption. */
189 : static ScDrawObjData* GetNoteCaptionData( SdrObject* pObj, SCTAB nTab );
190 :
191 : // Image-Map
192 : static ScIMapInfo* GetIMapInfo( SdrObject* pObj );
193 :
194 : static IMapObject* GetHitIMapObject( SdrObject* pObject,
195 : const Point& rWinPoint, const Window& rCmpWnd );
196 :
197 : static ScMacroInfo* GetMacroInfo( SdrObject* pObj, bool bCreate = false );
198 :
199 : virtual ImageMap* GetImageMapForObject(SdrObject* pObj) SAL_OVERRIDE;
200 : virtual sal_Int32 GetHyperlinkCount(SdrObject* pObj) SAL_OVERRIDE;
201 :
202 : private:
203 : static SfxObjectShell* pGlobalDrawPersist; // for AllocModel
204 : public:
205 : static void SetGlobalDrawPersist(SfxObjectShell* pPersist);
206 : protected:
207 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel() SAL_OVERRIDE;
208 : };
209 :
210 :
211 : #endif
212 :
213 :
214 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|