LibreOffice Module svx (master)  1
svdpage.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_SVDPAGE_HXX
21 #define INCLUDED_SVX_SVDPAGE_HXX
22 
23 #include <svl/stylesheetuser.hxx>
24 #include <vcl/prntypes.hxx>
25 #include <tools/weakbase.h>
26 #include <svl/itemset.hxx>
27 #include <svx/sdrpageuser.hxx>
30 #include <svx/svxdllapi.h>
31 #include <com/sun/star/container/XIndexAccess.hpp>
32 #include <com/sun/star/drawing/XDrawPage.hpp>
33 #include <svx/svdobj.hxx>
34 #include <memory>
35 #include <vector>
36 
37 
38 // predefines
39 namespace reportdesign { class OSection; }
40 namespace sdr { namespace contact { class ViewContact; }}
41 class SdrPage;
42 class SdrModel;
43 class SfxItemPool;
44 class SdrPageView;
45 class SdrLayerAdmin;
46 class SdrLayerIDSet;
47 class Color;
48 class SfxStyleSheet;
50 
52 //
53 // SdrObjList
54 // E3dObjList
55 // SdrPage -> see continuation there
56 
57 // class SdrObjList
59 {
60 friend class SdrObjListIter;
61 friend class SdrEditView;
62 
63 private:
64  SdrObjList(const SdrObjList& rSrcList) = delete;
65  SdrObjList &operator=(const SdrObjList& rSrcList) = delete;
66 
67  ::std::vector<SdrObject*> maList;
68 
73 
74 protected:
75  void RecalcRects();
76 
77 private:
79  static void impChildInserted(SdrObject const & rChild);
80 
81  // tdf#116879 Clear SdrObjList, no Undo done. Used from destructor, but also
82  // from other places. When used from destructor, suppress broadcasts
83  // to not get callbacks to evtl. derived objects already in destruction
84  // (e.g. SdrPage)
85  void impClearSdrObjList(bool bBroadcast);
86 
87 protected:
88  // protected constructor to make clear that this class should only
89  // be used as base for derivations, not naked. See getSdrModelFromSdrObjList
90  // which is pure virtual to force this, too
91  SdrObjList();
92  virtual ~SdrObjList();
93 
94 public:
95  // SdrModel/SdrPage access on SdrObjList level
96  virtual SdrPage* getSdrPageFromSdrObjList() const;
97  virtual SdrObject* getSdrObjectFromSdrObjList() const;
98 
99  void CopyObjects(const SdrObjList& rSrcList);
100 
101  // tdf#116879 clean up everything (without Undo), plus broadcasting
102  // changes. Split to this call and a private one (impClearSdrObjList)
103  // that allows cleanup without broadcasting in the destructor
104  void ClearSdrObjList();
105 
107  void RecalcObjOrdNums();
108  bool IsObjOrdNumsDirty() const { return mbObjOrdNumsDirty; }
109  virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE);
110  virtual void InsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE);
111  void sort( std::vector<sal_Int32>& sortOrder );
112 
113  void InsertObjectThenMakeNameUnique(SdrObject* pObj);
114  void InsertObjectThenMakeNameUnique(SdrObject* pObj, std::unordered_set<rtl::OUString>& rNameSet, size_t nPos=SAL_MAX_SIZE);
115 
117  virtual SdrObject* NbcRemoveObject(size_t nObjNum);
118  virtual SdrObject* RemoveObject(size_t nObjNum);
119 
123  virtual SdrObject* ReplaceObject(SdrObject* pNewObj, size_t nObjNum);
124 
126  virtual SdrObject* SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum);
127 
128  void SetSdrObjListRectsDirty();
129 
130  const tools::Rectangle& GetAllObjSnapRect() const;
131  const tools::Rectangle& GetAllObjBoundRect() const;
132 
134  void NbcReformatAllTextObjects();
135  void ReformatAllTextObjects();
136 
138  void ReformatAllEdgeObjects();
139 
141  void BurnInStyleSheetAttributes();
142 
143  size_t GetObjCount() const;
144  SdrObject* GetObj(size_t nNum) const;
145 
147  virtual bool IsReadOnly() const;
148 
156  void FlattenGroups();
157 
167  void UnGroupObj( size_t nObjNum );
168 
176  bool HasObjectNavigationOrder() const;
177 
182  void SetObjectNavigationPosition (
183  SdrObject& rObject,
184  const sal_uInt32 nNewNavigationPosition);
185 
196  SdrObject* GetObjectForNavigationPosition (const sal_uInt32 nNavigationPosition) const;
197 
200  void ClearObjectNavigationOrder();
201 
212  bool RecalcNavigationPositions();
213 
223  void SetNavigationOrder (const css::uno::Reference<
224  css::container::XIndexAccess>& rxOrder);
225 
226  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
227 
228 private:
232  std::unique_ptr<WeakSdrObjectContainerType> mxNavigationOrder;
233 
237 
249  void InsertObjectIntoContainer (
250  SdrObject& rObject,
251  const sal_uInt32 nInsertPosition);
252 
262  void ReplaceObjectInContainer (
263  SdrObject& rObject,
264  const sal_uInt32 nObjectPosition);
265 
273  void RemoveObjectFromContainer (
274  const sal_uInt32 nObjectPosition);
275 };
276 
277 // Used for all methods which return a page number
278 #define SDRPAGE_NOTFOUND 0xFFFF
279 
282 {
285 public:
286  SdrPageGridFrame(const tools::Rectangle& rPaper, const tools::Rectangle& rUser): aPaper(rPaper), aUserArea(rUser) {}
287  const tools::Rectangle& GetPaperRect() const { return aPaper; }
288  const tools::Rectangle& GetUserArea() const { return aUserArea; }
289 };
290 
292 {
293  std::vector<SdrPageGridFrame*> aList;
294 
295  SdrPageGridFrameList(const SdrPageGridFrameList& rSrcList) = delete;
296  void operator=(const SdrPageGridFrameList& rSrcList) = delete;
297  SdrPageGridFrame* GetObject(sal_uInt16 i) const { return aList[i]; }
298 
299 public:
300  SdrPageGridFrameList(): aList() {}
301  ~SdrPageGridFrameList() { Clear(); }
302  void Clear();
303  sal_uInt16 GetCount() const { return sal_uInt16(aList.size()); }
304  void Insert(const SdrPageGridFrame& rGF) { aList.push_back(new SdrPageGridFrame(rGF)); }
305  SdrPageGridFrame& operator[](sal_uInt16 nPos) { return *GetObject(nPos); }
306  const SdrPageGridFrame& operator[](sal_uInt16 nPos) const { return *GetObject(nPos); }
307 };
308 
309 // class SdrPageProperties
311 {
312 private:
313  // data
317 
318  // internal helpers
319  void ImpRemoveStyleSheet();
320  void ImpAddStyleSheet(SfxStyleSheet& rNewStyleSheet);
321 
322  SdrPageProperties& operator=(const SdrPageProperties& rCandidate) = delete;
323 
324 public:
325  // construct/destruct
326  SdrPageProperties(SdrPage& rSdrPage);
327  virtual ~SdrPageProperties() override;
328 
329  // Notify(...) from baseclass SfxListener
330  virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
331 
332  virtual bool isUsedByModel() const override;
333 
334  // data read/write
335  const SfxItemSet& GetItemSet() const { return maProperties;}
336  void PutItemSet(const SfxItemSet& rSet);
337  void PutItem(const SfxPoolItem& rItem);
338  void ClearItem(const sal_uInt16 nWhich = 0);
339 
340  // StyleSheet access
341  void SetStyleSheet(SfxStyleSheet* pStyleSheet);
342  SfxStyleSheet* GetStyleSheet() const { return mpStyleSheet;}
343 };
344 
345 
356 //
358 // SdrPage
359 // DlgEdPage
360 // FmFormPage
361 // ScDrawPage
362 // SdPage
363 // SwDPage
364 // OReportPage
365 
367 {
368  // #i9076#
369  friend class SdrModel;
370  friend class SvxUnoDrawPagesAccess;
371 
372  // this class uses its own UNO wrapper
373  // and thus has to set mxUnoPage (it also relies on mxUnoPage not being WeakRef)
375 
376  SdrPage& operator=(const SdrPage&) = delete;
377  SdrPage(const SdrPage&) = delete;
378 
379  // start PageUser section
380 private:
381  // #111111# PageUser section
383 
384  std::unique_ptr<sdr::contact::ViewContact> mpViewContact;
385 
386 public:
387  void AddPageUser(sdr::PageUser& rNewUser);
388  void RemovePageUser(sdr::PageUser& rOldUser);
389 
390  // SdrModel access on SdrPage level
391  SdrModel& getSdrModelFromSdrPage() const { return mrSdrModelFromSdrPage; }
392 
393 protected:
394  std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact();
395 public:
396  const sdr::contact::ViewContact& GetViewContact() const;
397  sdr::contact::ViewContact& GetViewContact();
398 
399  // #110094# DrawContact support: Methods for handling Page changes
400  void ActionChanged();
401 
402 private:
403  // the SdrModel this page was created with, unchanged during SdrPage lifetime
405 
406 private:
407  sal_Int32 mnWidth; // page size
408  sal_Int32 mnHeight; // page size
409  sal_Int32 mnBorderLeft; // left page margin
410  sal_Int32 mnBorderUpper; // top page margin
411  sal_Int32 mnBorderRight; // right page margin
412  sal_Int32 mnBorderLower; // bottom page margin
413 
414  std::unique_ptr<SdrLayerAdmin> mpLayerAdmin;
415  std::unique_ptr<SdrPageProperties> mpSdrPageProperties;
416  css::uno::Reference< css::uno::XInterface > mxUnoPage;
417 
418 public:
419  SdrPageProperties& getSdrPageProperties();
420  const SdrPageProperties& getSdrPageProperties() const;
421  const SdrPageProperties* getCorrectSdrPageProperties() const;
422 
423 protected:
424  // new MasterPageDescriptorVector
425  std::unique_ptr<sdr::MasterPageDescriptor> mpMasterPageDescriptor;
426 
427  sal_uInt16 nPageNum;
428 
429  bool mbMaster : 1; // flag if this is a MasterPage
430  bool mbInserted : 1;
431  bool mbObjectsNotPersistent : 1;
432 
433  // #i93597#
434  bool mbPageBorderOnlyLeftRight : 1;
435 
436  void SetUnoPage(css::uno::Reference<css::drawing::XDrawPage> const&);
437  virtual css::uno::Reference< css::uno::XInterface > createUnoPage();
438 
439  // Copying of pages is split into two parts: construction and copying of page objects,
440  // because the copying might need access to fully initialized page. CloneSdrPage() is responsible
441  // to call lateInit() after copy-construction of a new object. Any initialization in derived
442  // classes that needs access to the page objects must be deferred to lateInit. And it must
443  // call lateInit() of its parent class.
444  void lateInit(const SdrPage& rSrcPage);
445 
446 public:
447  explicit SdrPage(SdrModel& rModel, bool bMasterPage=false);
448  virtual ~SdrPage() override;
449 
450  virtual SdrPage* CloneSdrPage(SdrModel& rTargetModel) const;
451  bool IsMasterPage() const { return mbMaster; }
452  void SetInserted(bool bNew = true);
453  bool IsInserted() const { return mbInserted; }
454  void SetChanged();
455 
456  // derived from SdrObjList, returns this
457  virtual SdrPage* getSdrPageFromSdrObjList() const override;
458 
459  // #i68775# React on PageNum changes (from Model in most cases)
460  void SetPageNum(sal_uInt16 nNew);
461  sal_uInt16 GetPageNum() const;
462 
463  // #i93597# Allow page border definition to not be the full rectangle but to
464  // use only the left and right vertical edges (reportdesigner)
465  void setPageBorderOnlyLeftRight(bool bNew) { mbPageBorderOnlyLeftRight = bNew; }
466  bool getPageBorderOnlyLeftRight() const { return mbPageBorderOnlyLeftRight; }
467 
468  virtual void SetSize(const Size& aSiz);
469  Size GetSize() const;
470  virtual void SetOrientation(Orientation eOri);
471  virtual Orientation GetOrientation() const;
472  sal_Int32 GetWidth() const;
473  sal_Int32 GetHeight() const;
474  virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr);
475  virtual void SetLeftBorder(sal_Int32 nBorder);
476  virtual void SetUpperBorder(sal_Int32 nBorder);
477  virtual void SetRightBorder(sal_Int32 nBorder);
478  virtual void SetLowerBorder(sal_Int32 nBorder);
479  sal_Int32 GetLeftBorder() const;
480  sal_Int32 GetUpperBorder() const;
481  sal_Int32 GetRightBorder() const;
482  sal_Int32 GetLowerBorder() const;
483 
484  // New MasterPage interface
485  bool TRG_HasMasterPage() const { return (nullptr != mpMasterPageDescriptor); }
486  void TRG_SetMasterPage(SdrPage& rNew);
487  void TRG_ClearMasterPage();
488  SdrPage& TRG_GetMasterPage() const;
489  const SdrLayerIDSet& TRG_GetMasterPageVisibleLayers() const;
490  void TRG_SetMasterPageVisibleLayers(const SdrLayerIDSet& rNew);
491  sdr::contact::ViewContact& TRG_GetMasterPageDescriptorViewContact() const;
492 
493  void MakePageObjectsNamesUnique();
494 
495 protected:
496  void TRG_ImpMasterPageRemoved(const SdrPage& rRemovedPage);
497 public:
498 
500  const SdrLayerAdmin& GetLayerAdmin() const;
501  SdrLayerAdmin& GetLayerAdmin();
502 
503  virtual OUString GetLayoutName() const;
504 
508  virtual const SdrPageGridFrameList* GetGridFrameList(const SdrPageView* pPV, const tools::Rectangle* pRect) const;
509 
510  css::uno::Reference< css::uno::XInterface > const & getUnoPage();
511 
512  virtual SfxStyleSheet* GetTextStyleSheetForObject( SdrObject* pObj ) const;
513 
515  // #i75566# GetBackgroundColor -> GetPageBackgroundColor
516  Color GetPageBackgroundColor() const;
517 
519  // #i75566# GetBackgroundColor -> GetPageBackgroundColor and bScreenDisplay hint value
520  Color GetPageBackgroundColor( SdrPageView const * pView, bool bScreenDisplay = true) const;
521 
527  virtual bool checkVisibility(
528  const sdr::contact::ViewObjectContact& rOriginal,
529  const sdr::contact::DisplayInfo& rDisplayInfo,
530  bool bEdit );
531 };
532 
533 
534 #endif // INCLUDED_SVX_SVDPAGE_HXX
535 
536 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< sdr::MasterPageDescriptor > mpMasterPageDescriptor
Definition: svdpage.hxx:425
const SdrPageGridFrame & operator[](sal_uInt16 nPos) const
Definition: svdpage.hxx:306
::std::vector< PageUser * > PageUserVector
Definition: sdrpageuser.hxx:46
sal_Int32 mnWidth
Definition: svdpage.hxx:407
tools::Rectangle maSdrObjListOutRect
Definition: svdpage.hxx:69
Orientation
sdr::PageUserVector maPageUsers
Definition: svdpage.hxx:382
for the snap-to-grid in Writer
Definition: svdpage.hxx:281
bool mbObjOrdNumsDirty
Definition: svdpage.hxx:71
bool IsReadOnly(const OUString &rURL, bool *pbExist)
sal_Int32 mnBorderRight
Definition: svdpage.hxx:411
sal_Int32 mnHeight
Definition: svdpage.hxx:408
tools::Rectangle const aUserArea
Definition: svdpage.hxx:284
const SfxListener & operator=(const SfxListener &)=delete
bool mbRectsDirty
Definition: svdpage.hxx:72
const tools::Rectangle & GetUserArea() const
Definition: svdpage.hxx:288
bool lateInit
const SfxBroadcaster & operator=(const SfxBroadcaster &)=delete
const tools::Rectangle & GetPaperRect() const
Definition: svdpage.hxx:287
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
struct _xmlTextWriter * xmlTextWriterPtr
virtual bool isUsedByModel() const =0
SfxStyleSheet * mpStyleSheet
Definition: svdpage.hxx:315
bool IsObjOrdNumsDirty() const
Definition: svdpage.hxx:108
SdrModel & mrSdrModelFromSdrPage
Definition: svdpage.hxx:404
css::uno::Reference< css::uno::XInterface > mxUnoPage
Definition: svdpage.hxx:416
SdrPageGridFrame & operator[](sal_uInt16 nPos)
Definition: svdpage.hxx:305
sal_Int32 mnBorderLeft
Definition: svdpage.hxx:409
sal_Int32 mnBorderUpper
Definition: svdpage.hxx:410
SdrPageGridFrame(const tools::Rectangle &rPaper, const tools::Rectangle &rUser)
Definition: svdpage.hxx:286
tools::Rectangle const aPaper
Definition: svdpage.hxx:283
SdrObjList & operator=(const SdrObjList &rSrcList)=delete
std::vector< SdrPageGridFrame * > aList
Definition: svdpage.hxx:293
std::unique_ptr< SdrLayerAdmin > mpLayerAdmin
Definition: svdpage.hxx:414
void Insert(const SdrPageGridFrame &rGF)
Definition: svdpage.hxx:304
SdrPage * mpSdrPage
Definition: svdpage.hxx:314
bool IsMasterPage() const
Definition: svdpage.hxx:451
::std::vector< SdrObject * > maList
Definition: svdpage.hxx:67
const SfxItemSet & GetItemSet() const
Definition: svdpage.hxx:335
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:485
Abstract DrawObject.
Definition: svdobj.hxx:312
sal_uInt16 GetCount() const
Definition: svdpage.hxx:303
void setPageBorderOnlyLeftRight(bool bNew)
Definition: svdpage.hxx:465
SdrPageGridFrame * GetObject(sal_uInt16 i) const
Definition: svdpage.hxx:297
sal_Int32 mnBorderLower
Definition: svdpage.hxx:412
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:391
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
bool IsInserted() const
Definition: svdpage.hxx:453
SfxStyleSheet * GetStyleSheet() const
Definition: svdpage.hxx:342
std::unique_ptr< sdr::contact::ViewContact > mpViewContact
Definition: svdpage.hxx:384
virtual SdrPage * getSdrPageFromSdrObjList() const
Definition: svdpage.cxx:146
std::unique_ptr< WeakSdrObjectContainerType > mxNavigationOrder
This list, if it exists, defines the navigation order.
Definition: svdpage.hxx:229
bool getPageBorderOnlyLeftRight() const
Definition: svdpage.hxx:466
bool mbIsNavigationOrderDirty
This flag is when the mpNavigation list has been changed but the indices of the referenced Sdr...
Definition: svdpage.hxx:236
SfxItemSet maProperties
Definition: svdpage.hxx:316
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
std::unique_ptr< SdrPageProperties > mpSdrPageProperties
Definition: svdpage.hxx:415
tools::Rectangle maSdrObjListSnapRect
Definition: svdpage.hxx:70
sal_uInt16 nPageNum
Definition: svdpage.hxx:427