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