xref: /aoo4110/main/sc/inc/drwlayer.hxx (revision b1cdbd2c)
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 
GetTab()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 
GetTab()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     bool            mbUndoAllowed;
105 
106 private:
107 	void			MoveAreaTwips( SCTAB nTab, const Rectangle& rArea, const Point& rMove,
108 								const Point& rTopLeft );
109 	void			MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
110 								SCsCOL nDx,SCsROW nDy, bool bUpdateNoteCaptionPos );
111 
112     void            RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos );
113 
114 public:
115 					ScDrawLayer( ScDocument* pDocument, const String& rName );
116 	virtual			~ScDrawLayer();
117 
118 	virtual SdrPage*  AllocPage(FASTBOOL bMasterPage);
119 	virtual SdrModel* AllocModel() const;
120 	virtual void	SetChanged( sal_Bool bFlg = sal_True );
121 
122 	virtual Window* GetCurDocViewWin();
123 	virtual SvStream* GetDocumentStream(SdrDocumentStreamInfo& rStreamInfo) const;
124 
125 	virtual SdrLayerID GetControlExportLayerId( const SdrObject & ) const;
126 
127 //REMOVE		void			ReleasePictureStorage();
128 
129 	sal_Bool			HasObjects() const;
130 
131     sal_Bool            ScAddPage( SCTAB nTab );
132 	void			ScRemovePage( SCTAB nTab );
133 	void			ScRenamePage( SCTAB nTab, const String& rNewName );
134 	void			ScMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos );
135 					// inkl. Inhalt, bAlloc=sal_False -> nur Inhalt
136 	void			ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos, sal_Bool bAlloc );
137 
GetDocument() const138 	ScDocument*		GetDocument() const { return pDoc; }
139 
140 	void			UpdateBasic();				// DocShell-Basic in DrawPages setzen
141 	void			UseHyphenator();
142 
143 	sal_Bool			GetPrintArea( ScRange& rRange, sal_Bool bSetHor, sal_Bool bSetVer ) const;
144 
145 					//		automatische Anpassungen
146 
EnableAdjust(sal_Bool bSet=sal_True)147 	void			EnableAdjust( sal_Bool bSet = sal_True )	{ bAdjustEnabled = bSet; }
148 
149 	void			BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager);
150 	SdrUndoGroup*	GetCalcUndo();
IsRecording() const151 	sal_Bool			IsRecording() const			{ return bRecording; }
152 	void			AddCalcUndo( SdrUndoAction* pUndo );
153 
154     template< typename TUndoAction, typename TArg >
AddCalcUndo(const TArg & rArg)155     inline void			AddCalcUndo( const TArg & rArg )    {   if( this->IsUndoAllowed() )  this->AddCalcUndo( new TUndoAction( rArg ) ); }
156 
157     template< typename TUndoAction, typename TArg >
AddCalcUndo(TArg & rArg)158     inline void			AddCalcUndo( TArg & rArg )    {   if( this->IsUndoAllowed() )  this->AddCalcUndo( new TUndoAction( rArg ) ); }
159 
160     template< typename TUndoAction, typename TArg1, typename TArg2 >
AddCalcUndo(TArg1 & rArg1,TArg2 & rArg2)161     inline void			AddCalcUndo( TArg1 & rArg1, TArg2 & rArg2 ) {   if( this->IsUndoAllowed() )  this->AddCalcUndo( new TUndoAction( rArg1, rArg2 ) ); }
162 
163     template< typename TUndoAction, typename TArg1, typename TArg2 >
AddCalcUndo(const TArg1 & rArg1,const TArg2 & rArg2)164     inline void			AddCalcUndo( const TArg1 & rArg1, const TArg2 & rArg2 ) {   if( this->IsUndoAllowed() )  this->AddCalcUndo( new TUndoAction( rArg1, rArg2 ) ); }
165 
166     template< typename TUndoAction, typename TArg1, typename TArg2, typename TArg3, typename TArg4, typename TArg5 >
AddCalcUndo(const TArg1 & rArg1,const TArg2 & rArg2,const TArg3 & rArg3,const TArg4 & rArg4,const TArg5 & rArg5)167     inline void			AddCalcUndo( const TArg1 & rArg1, const TArg2 & rArg2, const TArg3 & rArg3, const TArg4 & rArg4, const TArg5 & rArg5 )    {   if( this->IsUndoAllowed() )  this->AddCalcUndo( new TUndoAction( rArg1, rArg2, rArg3, rArg4, rArg5 ) ); }
168 
169 	void			MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
170 								SCsCOL nDx,SCsROW nDy, sal_Bool bInsDel, bool bUpdateNoteCaptionPos = true );
171 	void			WidthChanged( SCTAB nTab, SCCOL nCol, long nDifTwips );
172 	void			HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips );
173 
174         sal_Bool            HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow, bool bIncludeNotes = true );
175 
176 	void			DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
177 											SCCOL nCol2,SCROW nRow2 );
178 	void			DeleteObjectsInSelection( const ScMarkData& rMark );
179 #if 0
180 	void			DeleteObjects( SCTAB nTab );
181 #endif
182 
183 	void			CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const Rectangle& rRange );
184 	void			CopyFromClip( ScDrawLayer* pClipModel,
185 									SCTAB nSourceTab, const Rectangle& rSourceRange,
186 									const ScAddress& rDestPos, const Rectangle& rDestRange );
187 
188 	void			SetPageSize( sal_uInt16 nPageNo, const Size& rSize, bool bUpdateNoteCaptionPos = true );
189 
190 					//	mirror or move between positive and negative positions for RTL
191 	void			MirrorRTL( SdrObject* pObj );
192 	static void		MirrorRectRTL( Rectangle& rRect );		// for bounding rectangles etc.
193 
194     /** Returns the rectangle for the passed cell address in 1/100 mm.
195         @param bMergedCell  True = regards merged cells. False = use single column/row size. */
196     static Rectangle GetCellRect( ScDocument& rDoc, const ScAddress& rPos, bool bMergedCell );
197 
198 					//	GetVisibleName: name for navigator etc: GetPersistName or GetName
199 					//	(ChartListenerCollection etc. must use GetPersistName directly)
200 	static String	GetVisibleName( SdrObject* pObj );
201 
202 	SdrObject*		GetNamedObject( const String& rName, sal_uInt16 nId, SCTAB& rFoundTab ) const;
203                     // if pnCounter != NULL, the search for a name starts with this index + 1,
204                     // and the index really used is returned.
205     String          GetNewGraphicName( long* pnCounter = NULL ) const;
206 	void			EnsureGraphicNames();
207 
208 	// Verankerung setzen und ermitteln
209 	static void		SetAnchor( SdrObject*, ScAnchorType );
210 	static ScAnchorType	GetAnchor( const SdrObject* );
211 
212 	// Positionen fuer Detektivlinien
213 	static ScDrawObjData* GetObjData( SdrObject* pObj, sal_Bool bCreate=sal_False );
214 
215     // The sheet information in ScDrawObjData isn't updated when sheets are inserted/deleted.
216     // Use this method to get an object with positions on the specified sheet (should be the
217     // sheet on which the object is inserted).
218     static ScDrawObjData* GetObjDataTab( SdrObject* pObj, SCTAB nTab );
219 
220     /** Returns true, if the passed object is the caption of a cell note. */
221     static bool     IsNoteCaption( SdrObject* pObj );
222 
223     /** Returns the object data, if the passed object is a cell note caption. */
224     static ScDrawObjData* GetNoteCaptionData( SdrObject* pObj, SCTAB nTab );
225 
226 	// Image-Map
227 	static ScIMapInfo* GetIMapInfo( SdrObject* pObj );
228 
229 	static IMapObject* GetHitIMapObject( SdrObject* pObject,
230 							const Point& rWinPoint, const Window& rCmpWnd );
231 
232     static ScMacroInfo* GetMacroInfo( SdrObject* pObj, sal_Bool bCreate = sal_False );
233 	virtual ImageMap* GetImageMapForObject(SdrObject* pObj);
234 	virtual sal_Int32 GetHyperlinkCount(SdrObject* pObj);
235 
236 private:
237 	static SfxObjectShell* pGlobalDrawPersist;			// fuer AllocModel
238 public:
239 	static void		SetGlobalDrawPersist(SfxObjectShell* pPersist);
240 protected:
241 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel();
242 public:
SetUndoAllowed(bool bUndoAllowed)243     inline void SetUndoAllowed( bool bUndoAllowed ){ mbUndoAllowed = bUndoAllowed; }
IsUndoAllowed() const244     inline bool IsUndoAllowed() const{ return mbUndoAllowed; }
245 };
246 
247 
248 #endif
249 
250 
251