xref: /trunk/main/sc/inc/drwlayer.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_DRWLAYER_HXX
25 #define SC_DRWLAYER_HXX
26 
27 #include <vcl/graph.hxx>
28 #include <svx/fmmodel.hxx>
29 #include <svx/svdundo.hxx>
30 #include "global.hxx"
31 
32 class ScDocument;
33 class SfxViewShell;
34 class SfxObjectShell;
35 class ScDrawObjData;
36 class ScIMapInfo;
37 class ScMacroInfo;
38 class IMapObject;
39 class ScMarkData;
40 class SdrOle2Obj;
41 class ScRange;
42 class ScAddress;
43 
44 // -----------------------------------------------------------------------
45 
46 class ScTabDeletedHint : public SfxHint
47 {
48 private:
49 	SCTAB	nTab;
50 public:
51 			TYPEINFO();
52 			ScTabDeletedHint( SCTAB nTabNo = SCTAB_MAX );
53 	virtual	~ScTabDeletedHint();
54 
55 	SCTAB	GetTab()	{ return nTab; }
56 };
57 
58 class ScTabSizeChangedHint : public SfxHint
59 {
60 private:
61 	SCTAB	nTab;
62 public:
63 			TYPEINFO();
64 			ScTabSizeChangedHint( SCTAB nTabNo = SCTAB_MAX );
65 	virtual	~ScTabSizeChangedHint();
66 
67 	SCTAB	GetTab()	{ return nTab; }
68 };
69 
70 // -----------------------------------------------------------------------
71 //
72 //  Das Anpassen der Detektiv-UserData muss zusammen mit den Draw-Undo's
73 //  in der SdrUndoGroup liegen, darum von SdrUndoAction abgeleitet:
74 
75 class ScUndoObjData : public SdrUndoObj
76 {
77 private:
78     ScAddress   aOldStt;
79     ScAddress   aOldEnd;
80     ScAddress   aNewStt;
81     ScAddress   aNewEnd;
82     sal_Bool        bHasNew;
83 public:
84                 ScUndoObjData( SdrObject* pObj, const ScAddress& rOS, const ScAddress& rOE,
85                                                 const ScAddress& rNS, const ScAddress& rNE );
86                 ~ScUndoObjData();
87 
88     virtual void     Undo();
89     virtual void     Redo();
90 };
91 
92 // -----------------------------------------------------------------------
93 
94 class SC_DLLPUBLIC ScDrawLayer : public FmFormModel
95 {
96 private:
97 //REMOVE		SotStorageRef	xPictureStorage;
98 	String			aName;
99 	ScDocument*		pDoc;
100 	SdrUndoGroup*	pUndoGroup;
101 	sal_Bool			bRecording;
102 	sal_Bool			bAdjustEnabled;
103 	sal_Bool			bHyphenatorSet;
104 
105 private:
106 	void			MoveAreaTwips( SCTAB nTab, const Rectangle& rArea, const Point& rMove,
107 								const Point& rTopLeft );
108 	void			MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
109 								SCsCOL nDx,SCsROW nDy, bool bUpdateNoteCaptionPos );
110 
111     void            RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos );
112 
113 public:
114 					ScDrawLayer( ScDocument* pDocument, const String& rName );
115 	virtual			~ScDrawLayer();
116 
117 	virtual SdrPage*  AllocPage(FASTBOOL bMasterPage);
118 	virtual SdrModel* AllocModel() const;
119 	virtual void	SetChanged( sal_Bool bFlg = sal_True );
120 
121 	virtual Window* GetCurDocViewWin();
122 	virtual SvStream* GetDocumentStream(SdrDocumentStreamInfo& rStreamInfo) const;
123 
124 	virtual SdrLayerID GetControlExportLayerId( const SdrObject & ) const;
125 
126 //REMOVE		void			ReleasePictureStorage();
127 
128 	sal_Bool			HasObjects() const;
129 
130     sal_Bool            ScAddPage( SCTAB nTab );
131 	void			ScRemovePage( SCTAB nTab );
132 	void			ScRenamePage( SCTAB nTab, const String& rNewName );
133 	void			ScMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos );
134 					// inkl. Inhalt, bAlloc=sal_False -> nur Inhalt
135 	void			ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos, sal_Bool bAlloc );
136 
137 	ScDocument*		GetDocument() const { return pDoc; }
138 
139 	void			UpdateBasic();				// DocShell-Basic in DrawPages setzen
140 	void			UseHyphenator();
141 
142 	sal_Bool			GetPrintArea( ScRange& rRange, sal_Bool bSetHor, sal_Bool bSetVer ) const;
143 
144 					//		automatische Anpassungen
145 
146 	void			EnableAdjust( sal_Bool bSet = sal_True )	{ bAdjustEnabled = bSet; }
147 
148 	void			BeginCalcUndo();
149 	SdrUndoGroup*	GetCalcUndo();
150 	sal_Bool			IsRecording() const			{ return bRecording; }
151 	void			AddCalcUndo( SdrUndoAction* pUndo );
152 
153 	void			MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
154 								SCsCOL nDx,SCsROW nDy, sal_Bool bInsDel, bool bUpdateNoteCaptionPos = true );
155 	void			WidthChanged( SCTAB nTab, SCCOL nCol, long nDifTwips );
156 	void			HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips );
157 
158         sal_Bool            HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow, bool bIncludeNotes = true );
159 
160 	void			DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
161 											SCCOL nCol2,SCROW nRow2 );
162 	void			DeleteObjectsInSelection( const ScMarkData& rMark );
163 #if 0
164 	void			DeleteObjects( SCTAB nTab );
165 #endif
166 
167 	void			CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const Rectangle& rRange );
168 	void			CopyFromClip( ScDrawLayer* pClipModel,
169 									SCTAB nSourceTab, const Rectangle& rSourceRange,
170 									const ScAddress& rDestPos, const Rectangle& rDestRange );
171 
172 	void			SetPageSize( sal_uInt16 nPageNo, const Size& rSize, bool bUpdateNoteCaptionPos = true );
173 
174 					//	mirror or move between positive and negative positions for RTL
175 	void			MirrorRTL( SdrObject* pObj );
176 	static void		MirrorRectRTL( Rectangle& rRect );		// for bounding rectangles etc.
177 
178     /** Returns the rectangle for the passed cell address in 1/100 mm.
179         @param bMergedCell  True = regards merged cells. False = use single column/row size. */
180     static Rectangle GetCellRect( ScDocument& rDoc, const ScAddress& rPos, bool bMergedCell );
181 
182 					//	GetVisibleName: name for navigator etc: GetPersistName or GetName
183 					//	(ChartListenerCollection etc. must use GetPersistName directly)
184 	static String	GetVisibleName( SdrObject* pObj );
185 
186 	SdrObject*		GetNamedObject( const String& rName, sal_uInt16 nId, SCTAB& rFoundTab ) const;
187                     // if pnCounter != NULL, the search for a name starts with this index + 1,
188                     // and the index really used is returned.
189     String          GetNewGraphicName( long* pnCounter = NULL ) const;
190 	void			EnsureGraphicNames();
191 
192 	// Verankerung setzen und ermitteln
193 	static void		SetAnchor( SdrObject*, ScAnchorType );
194 	static ScAnchorType	GetAnchor( const SdrObject* );
195 
196 	// Positionen fuer Detektivlinien
197 	static ScDrawObjData* GetObjData( SdrObject* pObj, sal_Bool bCreate=sal_False );
198 
199     // The sheet information in ScDrawObjData isn't updated when sheets are inserted/deleted.
200     // Use this method to get an object with positions on the specified sheet (should be the
201     // sheet on which the object is inserted).
202     static ScDrawObjData* GetObjDataTab( SdrObject* pObj, SCTAB nTab );
203 
204     /** Returns true, if the passed object is the caption of a cell note. */
205     static bool     IsNoteCaption( SdrObject* pObj );
206 
207     /** Returns the object data, if the passed object is a cell note caption. */
208     static ScDrawObjData* GetNoteCaptionData( SdrObject* pObj, SCTAB nTab );
209 
210 	// Image-Map
211 	static ScIMapInfo* GetIMapInfo( SdrObject* pObj );
212 
213 	static IMapObject* GetHitIMapObject( SdrObject* pObject,
214 							const Point& rWinPoint, const Window& rCmpWnd );
215 
216     static ScMacroInfo* GetMacroInfo( SdrObject* pObj, sal_Bool bCreate = sal_False );
217 
218 private:
219 	static SfxObjectShell* pGlobalDrawPersist;			// fuer AllocModel
220 public:
221 	static void		SetGlobalDrawPersist(SfxObjectShell* pPersist);
222 protected:
223 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel();
224 };
225 
226 
227 #endif
228 
229 
230