1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDMODEL_HXX
21 #define INCLUDED_SVX_SVDMODEL_HXX
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <cppuhelper/weakref.hxx>
25 #include <rtl/ustring.hxx>
26 #include <sot/storage.hxx>
27 #include <tools/link.hxx>
28 #include <tools/weakbase.hxx>
29 #include <vcl/mapmod.hxx>
30 #include <svl/brdcst.hxx>
31 #include <tools/datetime.hxx>
32 #include <svl/hint.hxx>
34 #include <svl/style.hxx>
35 #include <svx/xtable.hxx>
36 #include <svx/pageitem.hxx>
37 #include <vcl/field.hxx>
39 #include <boost/shared_ptr.hpp>
42 #include <svx/svdtypes.hxx>
43 #include <svx/svxdllapi.h>
45 #include <rtl/ref.hxx>
48 #define DEGREE_CHAR ((sal_Unicode)0x00B0) /* U+00B0 DEGREE SIGN */
62 class SfxRepeatTarget
;
72 class SvxForbiddenCharactersTable
;
73 class SvNumberFormatter
;
75 class SdrOutlinerCache
;
80 class IEmbeddedHelper
;
89 #define SDR_SWAPGRAPHICSMODE_NONE 0x00000000
90 #define SDR_SWAPGRAPHICSMODE_TEMP 0x00000001
91 #define SDR_SWAPGRAPHICSMODE_DOC 0x00000002
92 #define SDR_SWAPGRAPHICSMODE_PURGE 0x00000100
93 #define SDR_SWAPGRAPHICSMODE_DEFAULT (SDR_SWAPGRAPHICSMODE_TEMP|SDR_SWAPGRAPHICSMODE_DOC|SDR_SWAPGRAPHICSMODE_PURGE)
99 HINT_UNKNOWN
, // Unknown
100 HINT_LAYERCHG
, // changed layer definition
101 HINT_LAYERORDERCHG
, // order of layer changed (Insert/Remove/ChangePos)
102 HINT_PAGEORDERCHG
, // order of pages (object pages or master pages) changed (Insert/Remove/ChangePos)
103 HINT_OBJCHG
, // object changed
104 HINT_OBJINSERTED
, // new object inserted
105 HINT_OBJREMOVED
, // symbol object removed from list
106 HINT_MODELCLEARED
, // deleted the whole model (no pages exist anymore). not impl.
107 HINT_REFDEVICECHG
, // RefDevice changed
108 HINT_DEFAULTTABCHG
, // Default tabulator width changed
109 HINT_DEFFONTHGTCHG
, // Default FontHeight changed
110 HINT_MODELSAVED
, // Document was saved
111 HINT_SWITCHTOPAGE
, // #94278# UNDO/REDO at an object evtl. on another page
112 HINT_BEGEDIT
, // Is called after the object has entered text edit mode
113 HINT_ENDEDIT
// Is called after the object has left text edit mode
116 class SVX_DLLPUBLIC SdrHint
: public SfxHint
119 Rectangle maRectangle
;
120 const SdrPage
* mpPage
;
121 const SdrObject
* mpObj
;
122 const SdrObjList
* mpObjList
;
128 explicit SdrHint(SdrHintKind eNewHint
);
129 explicit SdrHint(const SdrObject
& rNewObj
);
131 void SetPage(const SdrPage
* pNewPage
);
132 void SetObject(const SdrObject
* pNewObj
);
133 void SetKind(SdrHintKind eNewKind
);
135 const SdrPage
* GetPage() const;
136 const SdrObject
* GetObject() const;
137 SdrHintKind
GetKind() const;
142 // Flag for cleaning up after the loading of the pools, meaning the
143 // recalculate the RefCounts and dispose unused items)
144 // sal_False == active
145 #define LOADREFCOUNTS (false)
149 class SVX_DLLPUBLIC SdrModel
: public SfxBroadcaster
, public tools::WeakBase
< SdrModel
>
152 DateTime aReadDate
; // date of the incoming stream
153 std::vector
<SdrPage
*> maMaPag
; // master pages
154 std::vector
<SdrPage
*> maPages
;
155 Link aUndoLink
; // link to a NotifyUndo-Handler
156 Link aIOProgressLink
;
158 Size aMaxObjSize
; // e.g. for auto-growing text
159 Fraction aObjUnit
; // description of the coordinate units for ClipBoard, Drag&Drop, ...
160 MapUnit eObjUnit
; // see above
161 FieldUnit eUIUnit
; // unit, scale (e.g. 1/1000) for the UI (status bar) is set by ImpSetUIUnit()
162 Fraction aUIScale
; // see above
163 OUString aUIUnitStr
; // see above
164 Fraction aUIUnitFact
; // see above
165 int nUIUnitKomma
; // see above
167 SdrLayerAdmin
* pLayerAdmin
;
168 SfxItemPool
* pItemPool
;
169 comphelper::IEmbeddedHelper
*
170 m_pEmbeddedHelper
; // helper for embedded objects to get rid of the SfxObjectShell
171 SdrOutliner
* pDrawOutliner
; // an Outliner for outputting text
172 SdrOutliner
* pHitTestOutliner
;// an Outliner for the HitTest
173 sal_uIntPtr nDefTextHgt
; // Default text heigth in logical units
174 OutputDevice
* pRefOutDev
; // ReferenceDevice for the EditEngine
175 sal_uIntPtr nProgressAkt
; // for the
176 sal_uIntPtr nProgressMax
; // ProgressBar-
177 sal_uIntPtr nProgressOfs
; // -Handler
178 rtl::Reference
< SfxStyleSheetBasePool
> mxStyleSheetPool
;
179 SfxStyleSheet
* pDefaultStyleSheet
;
180 SfxStyleSheet
* mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj
; // #i119287#
181 sfx2::LinkManager
* pLinkManager
; // LinkManager
182 std::deque
<SfxUndoAction
*>* pUndoStack
;
183 std::deque
<SfxUndoAction
*>* pRedoStack
;
184 SdrUndoGroup
* pAktUndoGroup
; // for deeper
185 sal_uInt16 nUndoLevel
; // undo nesting
186 sal_uInt16 nProgressPercent
; // for the ProgressBar-Handler
187 sal_uInt16 nLoadVersion
; // version number of the loaded file
188 bool bMyPool
:1; // to clean up pMyPool from 303a
189 bool bUIOnlyKomma
:1; // see eUIUnit
190 bool mbUndoEnabled
:1; // If false no undo is recorded or we are during the execution of an undo action
191 bool bExtColorTable
:1; // ne separate ColorTable
194 bool bPagNumsDirty
:1;
195 bool bMPgNumsDirty
:1;
196 bool bPageNotValid
:1; // TRUE=Doc is only object container. Page is invalid.
197 bool bSavePortable
:1; // save metafiles portably
198 bool bNoBitmapCaching
:1; // cache bitmaps for screen output
200 bool bTransparentTextFrames
:1;
201 bool bSaveCompressed
:1;
202 bool bSwapGraphics
:1;
203 bool bPasteResize
:1; // Objects are beingresized due to Paste with different MapMode
204 bool bSaveOLEPreview
:1; // save preview metafile of OLE objects
206 bool bStarDrawPreviewMode
:1;
207 bool mbDisableTextEditUsesCommonUndoManager
:1;
208 sal_uInt16 nStreamCompressMode
; // write compressedly?
209 sal_uInt16 nStreamNumberFormat
;
210 sal_uInt16 nDefaultTabulator
;
211 sal_uInt32 nMaxUndoCount
;
215 // sdr::Comment interface
217 // the next unique comment ID, used for counting added comments. Initialized
218 // to 0. UI shows one more due to the fact that 0 is a no-no for users.
219 sal_uInt32 mnUniqueCommentID
;
222 // create a new, unique comment ID
223 sal_uInt32
GetNextUniqueCommentID();
226 sal_uInt32
GetUniqueCommentID() const { return mnUniqueCommentID
; }
229 void SetUniqueCommentID(sal_uInt32 nNewID
) { if(nNewID
!= mnUniqueCommentID
) { mnUniqueCommentID
= nNewID
; } }
231 sal_uInt16 nStarDrawPreviewMasterPageNum
;
232 SvxForbiddenCharactersTable
* mpForbiddenCharactersTable
;
233 sal_uIntPtr nSwapGraphicsMode
;
235 SdrOutlinerCache
* mpOutlinerCache
;
236 SdrModelImpl
* mpImpl
;
237 sal_uInt16 mnCharCompressType
;
238 sal_uInt16 mnHandoutPageCount
;
239 sal_uInt16 nReserveUInt6
;
240 sal_uInt16 nReserveUInt7
;
242 bool mbKernAsianPunctuation
;
243 bool mbAddExtLeading
;
244 bool mbInDestruction
;
246 // Color, Dash, Line-End, Hatch, Gradient, Bitmap property lists ...
247 XPropertyListRef maProperties
[XPROPERTY_LIST_COUNT
];
249 // New src638: NumberFormatter for drawing layer and
250 // method for getting it. It is constructed on demand
251 // and destroyed when destroying the SdrModel.
252 SvNumberFormatter
* mpNumberFormatter
;
254 sal_uInt16
getHandoutPageCount() const { return mnHandoutPageCount
; }
255 void setHandoutPageCount( sal_uInt16 nHandoutPageCount
) { mnHandoutPageCount
= nHandoutPageCount
; }
259 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> createUnoModel();
263 SVX_DLLPRIVATE
SdrModel(const SdrModel
& rSrcModel
);
264 SVX_DLLPRIVATE
void operator=(const SdrModel
& rSrcModel
);
265 SVX_DLLPRIVATE
bool operator==(const SdrModel
& rCmpModel
) const;
266 SVX_DLLPRIVATE
void ImpPostUndoAction(SdrUndoAction
* pUndo
);
267 SVX_DLLPRIVATE
void ImpSetUIUnit();
268 SVX_DLLPRIVATE
void ImpSetOutlinerDefaults( SdrOutliner
* pOutliner
, bool bInit
= false );
269 SVX_DLLPRIVATE
void ImpReformatAllTextObjects();
270 SVX_DLLPRIVATE
void ImpReformatAllEdgeObjects(); // #103122#
271 SVX_DLLPRIVATE
void ImpCreateTables();
272 SVX_DLLPRIVATE
void ImpCtor(SfxItemPool
* pPool
, ::comphelper::IEmbeddedHelper
* pPers
, bool bUseExtColorTable
,
273 bool bLoadRefCounts
= true);
276 // this is a weak reference to a possible living api wrapper for this model
277 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> mxUnoModel
;
280 bool IsPasteResize() const { return bPasteResize
; }
281 void SetPasteResize(bool bOn
) { bPasteResize
=bOn
; }
283 // If a custom Pool is put here, the class will call methods
284 // on it (Put(), Remove()). On disposal of SdrModel the pool
285 // will be deleted with delete.
286 // If you give NULL instead, it will create an own pool (SdrItemPool)
287 // which will also be disposed in the destructor.
288 // If you do use a custom Pool, make sure you inherit from SdrItemPool,
289 // if you want to use symbol objects inherited from SdrAttrObj.
290 // If, however, you use objects inheriting from SdrObject you are free
291 // to chose a pool of your liking.
293 explicit SdrModel(SfxItemPool
* pPool
, ::comphelper::IEmbeddedHelper
* pPers
, bool bUseExtColorTable
, bool bLoadRefCounts
);
294 explicit SdrModel(const OUString
& rPath
, SfxItemPool
* pPool
, ::comphelper::IEmbeddedHelper
* pPers
, bool bUseExtColorTable
, bool bLoadRefCounts
);
296 void ClearModel(bool bCalledFromDestructor
);
298 // Whether the model is being streamed in at the moment
299 bool IsLoading() const { return false /*BFS01 bLoading */; }
300 // Needs to be overladed to enable the Swap/LoadOnDemand of graphics.
301 // If rbDeleteAfterUse is set to sal_True the SvStream instance from
302 // the caller will be disposed after use.
303 // If this method returns NULL, a temporary file will be allocated for
305 // The stream from which the model was loaded or in which is was saved last
306 // needs to be delivered
307 virtual ::com::sun::star::uno::Reference
<
308 ::com::sun::star::embed::XStorage
> GetDocumentStorage() const;
309 ::com::sun::star::uno::Reference
<
310 ::com::sun::star::io::XInputStream
>
311 GetDocumentStream(OUString
const& rURL
,
312 ::comphelper::LifecycleProxy
& rProxy
) const;
313 // Change the template attributes of the symbol objects to hard attributes
314 void BurnInStyleSheetAttributes();
315 // If you inherit from SdrPage you also need to inherit from SdrModel
316 // and implement both VM AllocPage() and AllocModel()...
317 virtual SdrPage
* AllocPage(bool bMasterPage
);
318 virtual SdrModel
* AllocModel() const;
320 // Changes on the layers set the modified flag and broadcast on the model!
321 const SdrLayerAdmin
& GetLayerAdmin() const { return *pLayerAdmin
; }
322 SdrLayerAdmin
& GetLayerAdmin() { return *pLayerAdmin
; }
324 const SfxItemPool
& GetItemPool() const { return *pItemPool
; }
325 SfxItemPool
& GetItemPool() { return *pItemPool
; }
327 SdrOutliner
& GetDrawOutliner(const SdrTextObj
* pObj
=NULL
) const;
329 SdrOutliner
& GetHitTestOutliner() const { return *pHitTestOutliner
; }
330 const SdrTextObj
* GetFormattingTextObj() const;
331 // put the TextDefaults (Font,Height,Color) in a Set
332 void SetTextDefaults() const;
333 static void SetTextDefaults( SfxItemPool
* pItemPool
, sal_uIntPtr nDefTextHgt
);
335 // ReferenceDevice for the EditEngine
336 void SetRefDevice(OutputDevice
* pDev
);
337 OutputDevice
* GetRefDevice() const { return pRefOutDev
; }
338 // If a new MapMode is set on the RefDevice (or similar)
339 void RefDeviceChanged(); // not yet implemented
340 // default font heigth in logical units
341 void SetDefaultFontHeight(sal_uIntPtr nVal
);
342 sal_uIntPtr
GetDefaultFontHeight() const { return nDefTextHgt
; }
343 // default tabulator width for the EditEngine
344 void SetDefaultTabulator(sal_uInt16 nVal
);
345 sal_uInt16
GetDefaultTabulator() const { return nDefaultTabulator
; }
347 // The DefaultStyleSheet will be used in every symbol object which is inserted
348 // in this model and does not have a StyleSheet set.
349 SfxStyleSheet
* GetDefaultStyleSheet() const { return pDefaultStyleSheet
; }
350 void SetDefaultStyleSheet(SfxStyleSheet
* pDefSS
) { pDefaultStyleSheet
= pDefSS
; }
352 // #i119287# default StyleSheet for SdrGrafObj and SdrOle2Obj
353 SfxStyleSheet
* GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj() const { return mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj
; }
354 void SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(SfxStyleSheet
* pDefSS
) { mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj
= pDefSS
; }
356 sfx2::LinkManager
* GetLinkManager() { return pLinkManager
; }
357 void SetLinkManager( sfx2::LinkManager
* pLinkMgr
) { pLinkManager
= pLinkMgr
; }
359 ::comphelper::IEmbeddedHelper
* GetPersist() const { return m_pEmbeddedHelper
; }
360 void ClearPersist() { m_pEmbeddedHelper
= 0; }
361 void SetPersist( ::comphelper::IEmbeddedHelper
*p
) { m_pEmbeddedHelper
= p
; }
363 // Unit for the symbol coordination
364 // Default is 1 logical unit = 1/100mm (Unit=MAP_100TH_MM, Fract=(1,1)).
366 // MAP_POINT, Fraction(72,1) : 1 log Einh = 72 Point = 1 Inch
367 // MAP_POINT, Fraction(1,20) : 1 log Einh = 1/20 Point = 1 Twip
368 // MAP_TWIP, Fraction(1,1) : 1 log Einh = 1 Twip
369 // MAP_100TH_MM, Fraction(1,10) : 1 log Einh = 1/1000mm
370 // MAP_MM, Fraction(1000,1) : 1 log Einh = 1000mm = 1m
371 // MAP_CM, Fraction(100,1) : 1 log Einh = 100cm = 1m
372 // MAP_CM, Fraction(100000,1): 1 log Einh = 100000cm = 1km
373 // (FWIW: you cannot represent light years).
374 // The scaling unit is needed for the Engine to serve the Clipboard
375 // with the correct sizes.
376 MapUnit
GetScaleUnit() const { return eObjUnit
; }
377 void SetScaleUnit(MapUnit eMap
);
378 const Fraction
& GetScaleFraction() const { return aObjUnit
; }
379 void SetScaleFraction(const Fraction
& rFrac
);
380 // Setting both simultaneously performs a little better
381 void SetScaleUnit(MapUnit eMap
, const Fraction
& rFrac
);
383 // maximal size e.g. for auto growing texts
384 const Size
& GetMaxObjSize() const { return aMaxObjSize
; }
385 void SetMaxObjSize(const Size
& rSiz
) { aMaxObjSize
=rSiz
; }
387 // For the View! to display sane numbers in the status bar: Default is mm.
388 void SetUIUnit(FieldUnit eUnit
);
389 FieldUnit
GetUIUnit() const { return eUIUnit
; }
390 // The scale of the drawing. Default 1/1.
391 void SetUIScale(const Fraction
& rScale
);
392 const Fraction
& GetUIScale() const { return aUIScale
; }
393 // Setting both simultaneously performs a little better
394 void SetUIUnit(FieldUnit eUnit
, const Fraction
& rScale
);
396 const Fraction
& GetUIUnitFact() const { return aUIUnitFact
; }
397 const OUString
& GetUIUnitStr() const { return aUIUnitStr
; }
398 int GetUIUnitKomma() const { return nUIUnitKomma
; }
399 bool IsUIOnlyKomma() const { return bUIOnlyKomma
; }
401 static void TakeUnitStr(FieldUnit eUnit
, OUString
& rStr
);
402 void TakeMetricStr(long nVal
, OUString
& rStr
, bool bNoUnitChars
= false, sal_Int32 nNumDigits
= -1) const;
403 void TakeWinkStr(long nWink
, OUString
& rStr
, bool bNoDegChar
= false) const;
404 void TakePercentStr(const Fraction
& rVal
, OUString
& rStr
, bool bNoPercentChar
= false) const;
406 // RecalcPageNums is ordinarily only called by the Page.
407 bool IsPagNumsDirty() const { return bPagNumsDirty
; };
408 bool IsMPgNumsDirty() const { return bMPgNumsDirty
; };
409 void RecalcPageNums(bool bMaster
);
410 // After the Insert the Page belongs to the SdrModel.
411 virtual void InsertPage(SdrPage
* pPage
, sal_uInt16 nPos
=0xFFFF);
412 virtual void DeletePage(sal_uInt16 nPgNum
);
413 // Remove means transferring ownership to the caller (opposite of Insert)
414 virtual SdrPage
* RemovePage(sal_uInt16 nPgNum
);
415 virtual void MovePage(sal_uInt16 nPgNum
, sal_uInt16 nNewPos
);
416 const SdrPage
* GetPage(sal_uInt16 nPgNum
) const;
417 SdrPage
* GetPage(sal_uInt16 nPgNum
);
418 sal_uInt16
GetPageCount() const;
420 virtual void PageListChanged();
423 virtual void InsertMasterPage(SdrPage
* pPage
, sal_uInt16 nPos
=0xFFFF);
424 virtual void DeleteMasterPage(sal_uInt16 nPgNum
);
425 // Remove means transferring ownership to the caller (opposite of Insert)
426 virtual SdrPage
* RemoveMasterPage(sal_uInt16 nPgNum
);
427 virtual void MoveMasterPage(sal_uInt16 nPgNum
, sal_uInt16 nNewPos
);
428 const SdrPage
* GetMasterPage(sal_uInt16 nPgNum
) const;
429 SdrPage
* GetMasterPage(sal_uInt16 nPgNum
);
430 sal_uInt16
GetMasterPageCount() const;
432 virtual void MasterPageListChanged();
434 // modified flag. Is set automatically when something changes on the Pages
435 // symbol objects. You need to reset it yourself, however, e.g. on Save().
436 bool IsChanged() const { return mbChanged
; }
437 virtual void SetChanged(bool bFlg
= true);
439 // PageNotValid means that the model carries objects which are
440 // anchored on a Page but the Page is invalid. This mark is needed for
441 // Clipboard/Drag&Drop.
442 bool IsPageNotValid() const { return bPageNotValid
; }
443 void SetPageNotValid(bool bJa
= true) { bPageNotValid
=bJa
; }
445 // Setting this flag to sal_True, graphic objects are saved
446 // portably. Meta files will eventually implicitly changed, i.e. during save.
447 // Default=FALSE. Flag is not persistent.
448 bool IsSavePortable() const { return bSavePortable
; }
449 void SetSavePortable(bool bJa
= true) { bSavePortable
=bJa
; }
451 // If you set this flag to sal_True, the
452 // pixel objects will be saved (heavily) compressed.
453 // Default=FALSE. Flag is not persistent.
454 bool IsSaveCompressed() const { return bSaveCompressed
; }
455 void SetSaveCompressed(bool bJa
= true) { bSaveCompressed
=bJa
; }
457 // If true, graphic objects with set Native-Link
458 // native will be saved.
459 // Default=FALSE. Flag is not persistent.
460 bool IsSaveNative() const { return bSaveNative
; }
461 void SetSaveNative(bool bJa
= true) { bSaveNative
=bJa
; }
463 // If set to sal_True, graphics from graphics objects will:
464 // - not be loaded immediately when loading a document,
465 // but only once they are needed (e.g. displayed).
466 // - be pruned from memory if they are not needed.
467 // For that to work, the virtual method
468 // GetDocumentStream() needs to be overloaded.
469 // Default=FALSE. Flag is not persistent.
470 bool IsSwapGraphics() const { return bSwapGraphics
; }
471 void SetSwapGraphics(bool bJa
= true);
472 void SetSwapGraphicsMode(sal_uIntPtr nMode
) { nSwapGraphicsMode
= nMode
; }
473 sal_uIntPtr
GetSwapGraphicsMode() const { return nSwapGraphicsMode
; }
475 bool IsSaveOLEPreview() const { return bSaveOLEPreview
; }
476 void SetSaveOLEPreview( bool bSet
) { bSaveOLEPreview
= bSet
; }
478 // To accelarate the screen output of Bitmaps (especially rotated ones)
479 // they will be cached. The existence of that cache can be toggled with this
480 // flag. During the next Paint an image will be remembered or freed.
481 // If a Bitmap object is placed in Undo its Cache for this object is turned off
482 // immediately to save memory.
483 // Default=Cache activated. Flag is not persistent.
484 bool IsBitmapCaching() const { return !bNoBitmapCaching
; }
485 void SetBitmapCaching(bool bJa
= true) { bNoBitmapCaching
=!bJa
; }
487 // Text frames without filling can be select with a mouse click by default (sal_False).
488 // With this flag set to true you can hit them only in the area in which text is to be
490 bool IsPickThroughTransparentTextFrames() const { return bTransparentTextFrames
; }
491 void SetPickThroughTransparentTextFrames(bool bOn
) { bTransparentTextFrames
=bOn
; }
493 // Can the model be changed at all?
494 // Is only evaluated by the possibility methods of the View.
495 // Direct manipulations on the model, ... do not respect this flag.
496 // Should be overloaded and return the appriopriate ReadOnly status
497 // of the files, i.e. sal_True or sal_False. (Method is called multiple
498 // times, so use one flag only!)
499 virtual bool IsReadOnly() const;
500 virtual void SetReadOnly(bool bYes
);
502 // Mixing two SdrModels. Mind that rSourceModel is not const.
503 // The pages will not be copied but moved, when inserted.
504 // rSourceModel may very well be empty afterwards.
505 // nFirstPageNum,nLastPageNum: The pages to take from rSourceModel
506 // nDestPos..................: position to insert
507 // bMergeMasterPages.........: sal_True = needed MasterPages will be taken
509 // sal_False= the MasterPageDescriptors of
510 // the pages of the rSourceModel will be
511 // mapped on the exisiting MasterPages.
512 // bUndo.....................: An undo action is generated for the merging.
513 // Undo is only for the target model, not for the
515 // bTreadSourceAsConst.......: sal_True=the SourceModel will not be changed,
516 // so pages will be copied.
517 virtual void Merge(SdrModel
& rSourceModel
,
518 sal_uInt16 nFirstPageNum
=0, sal_uInt16 nLastPageNum
=0xFFFF,
519 sal_uInt16 nDestPos
=0xFFFF,
520 bool bMergeMasterPages
= false, bool bAllMasterPages
= false,
521 bool bUndo
= true, bool bTreadSourceAsConst
= false);
523 // Behaves like Merge(SourceModel=DestModel,nFirst,nLast,nDest,sal_False,sal_False,bUndo,!bMoveNoCopy);
524 void CopyPages(sal_uInt16 nFirstPageNum
, sal_uInt16 nLastPageNum
,
526 bool bUndo
= true, bool bMoveNoCopy
= false);
528 // BegUndo() / EndUndo() enables you to group arbitrarily many UndoActions
529 // arbitrarily deeply. As comment for the UndoAction the first BegUndo(String) of all
530 // nestings will be used.
531 // In that case the NotifyUndoActionHdl will be called on the last EndUndo().
532 // No UndoAction will be generated for an empty group.
533 // All direct modifications on the SdrModel do not create an UndoActions.
534 // Actions on the SdrView however do generate those.
535 void BegUndo(); // open Undo group
536 void BegUndo(const OUString
& rComment
); // open Undo group
537 void BegUndo(const OUString
& rComment
, const OUString
& rObjDescr
, SdrRepeatFunc eFunc
=SDRREPFUNC_OBJ_NONE
); // open Undo group
538 void EndUndo(); // close Undo group
539 void AddUndo(SdrUndoAction
* pUndo
);
540 sal_uInt16
GetUndoBracketLevel() const { return nUndoLevel
; }
541 const SdrUndoGroup
* GetAktUndoGroup() const { return pAktUndoGroup
; }
542 // only after the first BegUndo or before the last EndUndo:
543 void SetUndoComment(const OUString
& rComment
);
544 void SetUndoComment(const OUString
& rComment
, const OUString
& rObjDescr
);
546 // The Undo management is only done if not NotifyUndoAction-Handler is set.
547 // Default is 16. Minimal MaxUndoActionCount is 1!
548 void SetMaxUndoActionCount(sal_uIntPtr nAnz
);
549 sal_uIntPtr
GetMaxUndoActionCount() const { return nMaxUndoCount
; }
550 void ClearUndoBuffer();
552 bool HasUndoActions() const;
553 bool HasRedoActions() const;
556 bool Repeat(SfxRepeatTarget
&);
558 // The application can set a handler here which collects the UndoActions einsammelt.
559 // The handler has the following signature:
560 // void NotifyUndoActionHdl(SfxUndoAction* pUndoAction);
561 // When calling the handler ownership is transferred;
562 // The UndoAction belongs to the Handler, not the SdrModel.
563 void SetNotifyUndoActionHdl(const Link
& rLink
) { aUndoLink
=rLink
; }
564 const Link
& GetNotifyUndoActionHdl() const { return aUndoLink
; }
566 /** application can set its own undo manager, BegUndo, EndUndo and AddUndoAction
567 calls are routet to this interface if given */
568 void SetSdrUndoManager( SfxUndoManager
* pUndoManager
);
569 SfxUndoManager
* GetSdrUndoManager() const;
571 /** applications can set their own undo factory to overide creation of
572 undo actions. The SdrModel will become owner of the given SdrUndoFactory
573 and delete it upon its destruction. */
574 void SetSdrUndoFactory( SdrUndoFactory
* pUndoFactory
);
576 /** returns the models undo factory. This must be used to create
577 undo actions for this model. */
578 SdrUndoFactory
& GetSdrUndoFactory() const;
580 // You can set a handler which will be called multiple times while
581 // streaming and which estimates the progress of the function.
582 // The handler needs to have this signature:
583 // void class::IOProgressHdl(const USHORT& nPercent);
584 // The first call of the handler will be with 0. The last call with 100.
585 // In between there will at most be 99 calls with 1..99.
586 // You can thus initialise the progres bar with 0 and close it on 100.
587 // Mind that the handler will also be called if the App serves Draw data in the
588 // office wide Draw-Exchange-Format because that happens through streaming into
590 void SetIOProgressHdl(const Link
& rLink
) { aIOProgressLink
=rLink
; }
591 const Link
& GetIOProgressHdl() const { return aIOProgressLink
; }
593 // Accessor methods for Palettes, Lists and Tabeles
594 // FIXME: this badly needs re-factoring ...
595 XPropertyListRef
GetPropertyList( XPropertyListType t
) const { return maProperties
[ t
]; }
596 void SetPropertyList( XPropertyListRef p
) { maProperties
[ p
->Type() ] = p
; }
598 // friendlier helpers
599 XDashListRef
GetDashList() const { return GetPropertyList( XDASH_LIST
)->AsDashList(); }
600 XHatchListRef
GetHatchList() const { return GetPropertyList( XHATCH_LIST
)->AsHatchList(); }
601 XColorListRef
GetColorList() const { return GetPropertyList( XCOLOR_LIST
)->AsColorList(); }
602 XBitmapListRef
GetBitmapList() const { return GetPropertyList( XBITMAP_LIST
)->AsBitmapList(); }
603 XLineEndListRef
GetLineEndList() const { return GetPropertyList( XLINE_END_LIST
)->AsLineEndList(); }
604 XGradientListRef
GetGradientList() const { return GetPropertyList( XGRADIENT_LIST
)->AsGradientList(); }
606 // The DrawingEngine only references the StyleSheetPool, whoever
607 // made it needs to delete it.
608 SfxStyleSheetBasePool
* GetStyleSheetPool() const { return mxStyleSheetPool
.get(); }
609 void SetStyleSheetPool(SfxStyleSheetBasePool
* pPool
) { mxStyleSheetPool
=pPool
; }
611 void SetStarDrawPreviewMode(bool bPreview
);
612 bool IsStarDrawPreviewMode() { return bStarDrawPreviewMode
; }
614 bool GetDisableTextEditUsesCommonUndoManager() const { return mbDisableTextEditUsesCommonUndoManager
; }
615 void SetDisableTextEditUsesCommonUndoManager(bool bNew
) { mbDisableTextEditUsesCommonUndoManager
= bNew
; }
617 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getUnoModel();
618 void setUnoModel( ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> xModel
);
620 // these functions are used by the api to disable repaints during a
622 bool isLocked() const { return mbModelLocked
; }
623 void setLock( bool bLock
);
625 void SetForbiddenCharsTable( rtl::Reference
<SvxForbiddenCharactersTable
> xForbiddenChars
);
626 rtl::Reference
<SvxForbiddenCharactersTable
> GetForbiddenCharsTable() const;
628 void SetCharCompressType( sal_uInt16 nType
);
629 sal_uInt16
GetCharCompressType() const { return mnCharCompressType
; }
631 void SetKernAsianPunctuation( bool bEnabled
);
632 bool IsKernAsianPunctuation() const { return mbKernAsianPunctuation
; }
634 void SetAddExtLeading( bool bEnabled
);
635 bool IsAddExtLeading() const { return mbAddExtLeading
; }
637 void ReformatAllTextObjects();
639 SdrOutliner
* createOutliner( sal_uInt16 nOutlinerMode
);
640 void disposeOutliner( SdrOutliner
* pOutliner
);
642 bool IsWriter() const { return !bMyPool
; }
644 /** returns the numbering type that is used to format page fields in drawing shapes */
645 virtual SvxNumType
GetPageNumType() const;
647 /** copies the items from the source set to the destination set. Both sets must have
648 same ranges but can have different pools. If pNewModel is optional. If it is null,
649 this model is used. */
651 void MigrateItemSet( const SfxItemSet
* pSourceSet
, SfxItemSet
* pDestSet
, SdrModel
* pNewModel
);
653 bool IsInDestruction() const;
655 static const ::com::sun::star::uno::Sequence
< sal_Int8
>& getUnoTunnelImplementationId();
657 virtual ImageMap
* GetImageMapForObject(SdrObject
*){return NULL
;};
658 virtual sal_Int32
GetHyperlinkCount(SdrObject
*){return 0;}
660 /** enables (true) or disables (false) recording of undo actions
661 If undo actions are added while undo is disabled, they are deleted.
662 Disabling undo does not clear the current undo buffer! */
663 void EnableUndo( bool bEnable
);
665 /** returns true if undo is currently enabled
666 This returns false if undo was disabled using EnableUndo( false ) and
667 also during the runtime of the Undo() and Redo() methods. */
668 bool IsUndoEnabled() const;
671 typedef tools::WeakReference
< SdrModel
> SdrModelWeakRef
;
675 #endif // INCLUDED_SVX_SVDMODEL_HXX
684 +----+---+ +----+---+ +-----+--------+
685 |SdrPage | |SdrPage | |SdrLayerAdmin |
686 +---+----+ +-+--+--++ +---+-------+--+
687 | | | | | +-------------------+
688 +----+----+ +-----+-----+ +-------+-------+
689 | ... | | ... | | ... |
690 +---+---+ +---+---+ +----+----+ +----+----+ +-----+------+ +------+-----+
691 |SdrObj | |SdrObj | |SdrLayer | |SdrLayer | |SdrLayerSet | |SdrLayerSet |
692 +-------+ +-------+ +---------+ +---------+ +------------+ +------------+
693 This class: SdrModel is the head of the data models for the StarView Drawing Engine.
695 ///////////////////////////////////////////////////////////////////////////////////////////////// */
697 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */