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::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:
231  std::unique_ptr<std::vector<tools::WeakReference<SdrObject>>> mxNavigationOrder;
232 
236 
248  void InsertObjectIntoContainer (
249  SdrObject& rObject,
250  const sal_uInt32 nInsertPosition);
251 
261  void ReplaceObjectInContainer (
262  SdrObject& rObject,
263  const sal_uInt32 nObjectPosition);
264 
272  void RemoveObjectFromContainer (
273  const sal_uInt32 nObjectPosition);
274 };
275 
276 // Used for all methods which return a page number
277 #define SDRPAGE_NOTFOUND 0xFFFF
278 
281 {
284 public:
285  SdrPageGridFrame(const tools::Rectangle& rPaper, const tools::Rectangle& rUser): aPaper(rPaper), aUserArea(rUser) {}
286  const tools::Rectangle& GetPaperRect() const { return aPaper; }
287  const tools::Rectangle& GetUserArea() const { return aUserArea; }
288 };
289 
291 {
292  std::vector<SdrPageGridFrame*> aList;
293 
294  SdrPageGridFrameList(const SdrPageGridFrameList& rSrcList) = delete;
295  void operator=(const SdrPageGridFrameList& rSrcList) = delete;
296  SdrPageGridFrame* GetObject(sal_uInt16 i) const { return aList[i]; }
297 
298 public:
299  SdrPageGridFrameList(): aList() {}
301  void Clear();
302  sal_uInt16 GetCount() const { return sal_uInt16(aList.size()); }
303  void Insert(const SdrPageGridFrame& rGF) { aList.push_back(new SdrPageGridFrame(rGF)); }
304  SdrPageGridFrame& operator[](sal_uInt16 nPos) { return *GetObject(nPos); }
305  const SdrPageGridFrame& operator[](sal_uInt16 nPos) const { return *GetObject(nPos); }
306 };
307 
308 // class SdrPageProperties
310 {
311 private:
312  // data
316 
317  // internal helpers
318  void ImpRemoveStyleSheet();
319  void ImpAddStyleSheet(SfxStyleSheet& rNewStyleSheet);
320 
321  SdrPageProperties& operator=(const SdrPageProperties& rCandidate) = delete;
322 
323 public:
324  // construct/destruct
325  SdrPageProperties(SdrPage& rSdrPage);
326  virtual ~SdrPageProperties() override;
327 
328  // Notify(...) from baseclass SfxListener
329  virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
330 
331  virtual bool isUsedByModel() const override;
332 
333  // data read/write
334  const SfxItemSet& GetItemSet() const { return maProperties;}
335  void PutItemSet(const SfxItemSet& rSet);
336  void PutItem(const SfxPoolItem& rItem);
337  void ClearItem(const sal_uInt16 nWhich = 0);
338 
339  // StyleSheet access
340  void SetStyleSheet(SfxStyleSheet* pStyleSheet);
341  SfxStyleSheet* GetStyleSheet() const { return mpStyleSheet;}
342 };
343 
344 
355 //
357 // SdrPage
358 // DlgEdPage
359 // FmFormPage
360 // ScDrawPage
361 // SdPage
362 // SwDPage
363 // OReportPage
364 
366 {
367  // #i9076#
368  friend class SdrModel;
369  friend class SvxUnoDrawPagesAccess;
370 
371  // this class uses its own UNO wrapper
372  // and thus has to set mxUnoPage (it also relies on mxUnoPage not being WeakRef)
374 
375  SdrPage& operator=(const SdrPage&) = delete;
376  SdrPage(const SdrPage&) = delete;
377 
378  // start PageUser section
379 private:
380  // #111111# PageUser section
382 
383  std::unique_ptr<sdr::contact::ViewContact> mpViewContact;
384 
385 public:
386  void AddPageUser(sdr::PageUser& rNewUser);
387  void RemovePageUser(sdr::PageUser& rOldUser);
388 
389  // SdrModel access on SdrPage level
390  SdrModel& getSdrModelFromSdrPage() const { return mrSdrModelFromSdrPage; }
391 
392 protected:
393  std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact();
394 public:
395  const sdr::contact::ViewContact& GetViewContact() const;
396  sdr::contact::ViewContact& GetViewContact();
397 
398  // #110094# DrawContact support: Methods for handling Page changes
399  void ActionChanged();
400 
401 private:
402  // the SdrModel this page was created with, unchanged during SdrPage lifetime
404 
405 private:
406  sal_Int32 mnWidth; // page size
407  sal_Int32 mnHeight; // page size
408  sal_Int32 mnBorderLeft; // left page margin
409  sal_Int32 mnBorderUpper; // top page margin
410  sal_Int32 mnBorderRight; // right page margin
411  sal_Int32 mnBorderLower; // bottom page margin
412 
413  std::unique_ptr<SdrLayerAdmin> mpLayerAdmin;
414  std::unique_ptr<SdrPageProperties> mpSdrPageProperties;
415  css::uno::Reference< css::uno::XInterface > mxUnoPage;
416 
417 public:
418  SdrPageProperties& getSdrPageProperties();
419  const SdrPageProperties& getSdrPageProperties() const;
420  const SdrPageProperties* getCorrectSdrPageProperties() const;
421 
422 protected:
423  // new MasterPageDescriptorVector
424  std::unique_ptr<sdr::MasterPageDescriptor> mpMasterPageDescriptor;
425 
426  sal_uInt16 nPageNum;
427 
428  bool mbMaster : 1; // flag if this is a MasterPage
429  bool mbInserted : 1;
430  bool mbObjectsNotPersistent : 1;
431 
432  // #i93597#
433  bool mbPageBorderOnlyLeftRight : 1;
434 
435  void SetUnoPage(css::uno::Reference<css::drawing::XDrawPage> const&);
436  virtual css::uno::Reference< css::uno::XInterface > createUnoPage();
437 
438  // Copying of pages is split into two parts: construction and copying of page objects,
439  // because the copying might need access to fully initialized page. CloneSdrPage() is responsible
440  // to call lateInit() after copy-construction of a new object. Any initialization in derived
441  // classes that needs access to the page objects must be deferred to lateInit. And it must
442  // call lateInit() of its parent class.
443  void lateInit(const SdrPage& rSrcPage);
444 
445 public:
446  explicit SdrPage(SdrModel& rModel, bool bMasterPage=false);
447  virtual ~SdrPage() override;
448 
449  virtual SdrPage* CloneSdrPage(SdrModel& rTargetModel) const;
450  bool IsMasterPage() const { return mbMaster; }
451  void SetInserted(bool bNew = true);
452  bool IsInserted() const { return mbInserted; }
453  void SetChanged();
454 
455  // derived from SdrObjList, returns this
456  virtual SdrPage* getSdrPageFromSdrObjList() const override;
457 
458  // #i68775# React on PageNum changes (from Model in most cases)
459  void SetPageNum(sal_uInt16 nNew);
460  sal_uInt16 GetPageNum() const;
461 
462  // #i93597# Allow page border definition to not be the full rectangle but to
463  // use only the left and right vertical edges (reportdesigner)
464  void setPageBorderOnlyLeftRight(bool bNew) { mbPageBorderOnlyLeftRight = bNew; }
465  bool getPageBorderOnlyLeftRight() const { return mbPageBorderOnlyLeftRight; }
466 
467  virtual void SetSize(const Size& aSiz);
468  Size GetSize() const;
469  virtual void SetOrientation(Orientation eOri);
470  virtual Orientation GetOrientation() const;
471  sal_Int32 GetWidth() const;
472  sal_Int32 GetHeight() const;
473  virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr);
474  virtual void SetLeftBorder(sal_Int32 nBorder);
475  virtual void SetUpperBorder(sal_Int32 nBorder);
476  virtual void SetRightBorder(sal_Int32 nBorder);
477  virtual void SetLowerBorder(sal_Int32 nBorder);
478  sal_Int32 GetLeftBorder() const;
479  sal_Int32 GetUpperBorder() const;
480  sal_Int32 GetRightBorder() const;
481  sal_Int32 GetLowerBorder() const;
482 
483  // New MasterPage interface
484  bool TRG_HasMasterPage() const { return (nullptr != mpMasterPageDescriptor); }
485  void TRG_SetMasterPage(SdrPage& rNew);
486  void TRG_ClearMasterPage();
487  SdrPage& TRG_GetMasterPage() const;
488  const SdrLayerIDSet& TRG_GetMasterPageVisibleLayers() const;
489  void TRG_SetMasterPageVisibleLayers(const SdrLayerIDSet& rNew);
490  sdr::contact::ViewContact& TRG_GetMasterPageDescriptorViewContact() const;
491 
492  void MakePageObjectsNamesUnique();
493 
494 protected:
495  void TRG_ImpMasterPageRemoved(const SdrPage& rRemovedPage);
496 public:
497 
499  const SdrLayerAdmin& GetLayerAdmin() const;
500  SdrLayerAdmin& GetLayerAdmin();
501 
502  virtual OUString GetLayoutName() const;
503 
507  virtual const SdrPageGridFrameList* GetGridFrameList(const SdrPageView* pPV, const tools::Rectangle* pRect) const;
508 
509  css::uno::Reference< css::uno::XInterface > const & getUnoPage();
510 
511  virtual SfxStyleSheet* GetTextStyleSheetForObject( SdrObject* pObj ) const;
512 
514  // #i75566# GetBackgroundColor -> GetPageBackgroundColor
515  Color GetPageBackgroundColor() const;
516 
518  // #i75566# GetBackgroundColor -> GetPageBackgroundColor and bScreenDisplay hint value
519  Color GetPageBackgroundColor( SdrPageView const * pView, bool bScreenDisplay = true) const;
520 
526  virtual bool checkVisibility(
527  const sdr::contact::ViewObjectContact& rOriginal,
528  const sdr::contact::DisplayInfo& rDisplayInfo,
529  bool bEdit );
530 };
531 
532 
533 #endif // INCLUDED_SVX_SVDPAGE_HXX
534 
535 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< sdr::MasterPageDescriptor > mpMasterPageDescriptor
Definition: svdpage.hxx:424
const SdrPageGridFrame & operator[](sal_uInt16 nPos) const
Definition: svdpage.hxx:305
::std::vector< PageUser * > PageUserVector
Definition: sdrpageuser.hxx:46
sal_Int32 mnWidth
Definition: svdpage.hxx:406
tools::Rectangle maSdrObjListOutRect
Definition: svdpage.hxx:69
sdr::PageUserVector maPageUsers
Definition: svdpage.hxx:381
const OUStringLiteral IsReadOnly("IsReadOnly")
struct _xmlTextWriter * xmlTextWriterPtr
for the snap-to-grid in Writer
Definition: svdpage.hxx:280
bool mbObjOrdNumsDirty
Definition: svdpage.hxx:71
sal_Int32 mnBorderRight
Definition: svdpage.hxx:410
sal_Int32 mnHeight
Definition: svdpage.hxx:407
const SfxListener & operator=(const SfxListener &)=delete
bool mbRectsDirty
Definition: svdpage.hxx:72
const tools::Rectangle & GetUserArea() const
Definition: svdpage.hxx:287
bool lateInit
const SfxBroadcaster & operator=(const SfxBroadcaster &)=delete
const tools::Rectangle & GetPaperRect() const
Definition: svdpage.hxx:286
virtual bool isUsedByModel() const =0
SfxStyleSheet * mpStyleSheet
Definition: svdpage.hxx:314
tools::Rectangle aUserArea
Definition: svdpage.hxx:283
bool IsObjOrdNumsDirty() const
Definition: svdpage.hxx:108
SdrModel & mrSdrModelFromSdrPage
Definition: svdpage.hxx:403
css::uno::Reference< css::uno::XInterface > mxUnoPage
Definition: svdpage.hxx:415
SdrPageGridFrame & operator[](sal_uInt16 nPos)
Definition: svdpage.hxx:304
sal_Int32 mnBorderLeft
Definition: svdpage.hxx:408
sal_Int32 mnBorderUpper
Definition: svdpage.hxx:409
SdrPageGridFrame(const tools::Rectangle &rPaper, const tools::Rectangle &rUser)
Definition: svdpage.hxx:285
SdrObjList & operator=(const SdrObjList &rSrcList)=delete
std::vector< SdrPageGridFrame * > aList
Definition: svdpage.hxx:292
Orientation
std::unique_ptr< SdrLayerAdmin > mpLayerAdmin
Definition: svdpage.hxx:413
void Insert(const SdrPageGridFrame &rGF)
Definition: svdpage.hxx:303
SdrPage * mpSdrPage
Definition: svdpage.hxx:313
tools::Rectangle aPaper
Definition: svdpage.hxx:282
std::unique_ptr< std::vector< tools::WeakReference< SdrObject > > > mxNavigationOrder
This list, if it exists, defines the navigation order.
Definition: svdpage.hxx:231
bool IsMasterPage() const
Definition: svdpage.hxx:450
::std::vector< SdrObject * > maList
Definition: svdpage.hxx:67
const SfxItemSet & GetItemSet() const
Definition: svdpage.hxx:334
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:484
Abstract DrawObject.
Definition: svdobj.hxx:312
sal_uInt16 GetCount() const
Definition: svdpage.hxx:302
void setPageBorderOnlyLeftRight(bool bNew)
Definition: svdpage.hxx:464
SdrPageGridFrame * GetObject(sal_uInt16 i) const
Definition: svdpage.hxx:296
sal_Int32 mnBorderLower
Definition: svdpage.hxx:411
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:390
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
bool IsInserted() const
Definition: svdpage.hxx:452
SfxStyleSheet * GetStyleSheet() const
Definition: svdpage.hxx:341
std::unique_ptr< sdr::contact::ViewContact > mpViewContact
Definition: svdpage.hxx:383
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
virtual SdrPage * getSdrPageFromSdrObjList() const
Definition: svdpage.cxx:131
bool getPageBorderOnlyLeftRight() const
Definition: svdpage.hxx:465
bool mbIsNavigationOrderDirty
This flag is when the mpNavigation list has been changed but the indices of the referenced Sdr...
Definition: svdpage.hxx:235
SfxItemSet maProperties
Definition: svdpage.hxx:315
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
std::unique_ptr< SdrPageProperties > mpSdrPageProperties
Definition: svdpage.hxx:414
tools::Rectangle maSdrObjListSnapRect
Definition: svdpage.hxx:70
sal_uInt16 nPageNum
Definition: svdpage.hxx:426