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