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 #pragma once
21 
22 #include <cppuhelper/weak.hxx>
23 #include <svl/stylesheetuser.hxx>
24 #include <vcl/prntypes.hxx>
25 #include <svl/itemset.hxx>
26 #include <svx/sdrpageuser.hxx>
29 #include <svx/svxdllapi.h>
30 #include <com/sun/star/container/XIndexAccess.hpp>
31 #include <com/sun/star/drawing/XDrawPage.hpp>
32 #include <svx/svdobj.hxx>
33 #include <memory>
34 #include <optional>
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 protected:
68  void RecalcRects();
69 
70 private:
72  static void impChildInserted(SdrObject const & rChild);
73 
74  // tdf#116879 Clear SdrObjList, no Undo done. Used from destructor, but also
75  // from other places. When used from destructor, suppress broadcasts
76  // to not get callbacks to evtl. derived objects already in destruction
77  // (e.g. SdrPage)
78  void impClearSdrObjList(bool bBroadcast);
79 
80 protected:
81  // protected constructor to make clear that this class should only
82  // be used as base for derivations, not naked. See getSdrModelFromSdrObjList
83  // which is pure virtual to force this, too
84  SdrObjList();
85  virtual ~SdrObjList();
86 
87 public:
88  // SdrModel/SdrPage access on SdrObjList level
89  virtual SdrPage* getSdrPageFromSdrObjList() const;
90  virtual SdrObject* getSdrObjectFromSdrObjList() const;
91 
92  void CopyObjects(const SdrObjList& rSrcList);
93 
94  // tdf#116879 clean up everything (without Undo), plus broadcasting
95  // changes. Split to this call and a private one (impClearSdrObjList)
96  // that allows cleanup without broadcasting in the destructor
97  void ClearSdrObjList();
98 
100  void RecalcObjOrdNums();
101  bool IsObjOrdNumsDirty() const { return mbObjOrdNumsDirty; }
102  virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE);
103  virtual void InsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE);
104  void sort( std::vector<sal_Int32>& sortOrder );
105 
106  void InsertObjectThenMakeNameUnique(SdrObject* pObj);
107  void InsertObjectThenMakeNameUnique(SdrObject* pObj, std::unordered_set<rtl::OUString>& rNameSet, size_t nPos=SAL_MAX_SIZE);
108 
110  virtual SdrObject* NbcRemoveObject(size_t nObjNum);
111  virtual SdrObject* RemoveObject(size_t nObjNum);
112 
116  virtual SdrObject* ReplaceObject(SdrObject* pNewObj, size_t nObjNum);
117 
119  virtual SdrObject* SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum);
120 
122  void SetExistingObjectOrdNum(SdrObject* pExistingObj, size_t nNewObjNum);
123 
124  void SetSdrObjListRectsDirty();
125 
126  const tools::Rectangle& GetAllObjSnapRect() const;
127  const tools::Rectangle& GetAllObjBoundRect() const;
128 
130  void NbcReformatAllTextObjects();
131  void ReformatAllTextObjects();
132 
134  void ReformatAllEdgeObjects();
135 
137  void BurnInStyleSheetAttributes();
138 
139  size_t GetObjCount() const;
140  SdrObject* GetObj(size_t nNum) const;
141 
143  virtual bool IsReadOnly() const;
144 
152  void FlattenGroups();
153 
163  void UnGroupObj( size_t nObjNum );
164 
172  bool HasObjectNavigationOrder() const;
173 
178  void SetObjectNavigationPosition (
179  SdrObject& rObject,
180  const sal_uInt32 nNewNavigationPosition);
181 
192  SdrObject* GetObjectForNavigationPosition (const sal_uInt32 nNavigationPosition) const;
193 
196  void ClearObjectNavigationOrder();
197 
208  bool RecalcNavigationPositions();
209 
219  void SetNavigationOrder (const css::uno::Reference<
220  css::container::XIndexAccess>& rxOrder);
221 
222  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
223 
224 private:
227  std::vector<SdrObject*> maList;
230  std::optional<std::vector<tools::WeakReference<SdrObject>>> mxNavigationOrder;
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:
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  bool mbBackgroundFullSize = false;
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 rtl::Reference<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  void SetBackgroundFullSize(bool bIn);
484  bool IsBackgroundFullSize() const;
485 
486  // New MasterPage interface
487  bool TRG_HasMasterPage() const { return (nullptr != mpMasterPageDescriptor); }
488  void TRG_SetMasterPage(SdrPage& rNew);
489  void TRG_ClearMasterPage();
490  SdrPage& TRG_GetMasterPage() const;
491  const SdrLayerIDSet& TRG_GetMasterPageVisibleLayers() const;
492  void TRG_SetMasterPageVisibleLayers(const SdrLayerIDSet& rNew);
493  sdr::contact::ViewContact& TRG_GetMasterPageDescriptorViewContact() const;
494 
495  void MakePageObjectsNamesUnique();
496 
497 protected:
498  void TRG_ImpMasterPageRemoved(const SdrPage& rRemovedPage);
499 public:
500 
502  const SdrLayerAdmin& GetLayerAdmin() const;
503  SdrLayerAdmin& GetLayerAdmin();
504 
505  virtual OUString GetLayoutName() const;
506 
510  virtual const SdrPageGridFrameList* GetGridFrameList(const SdrPageView* pPV, const tools::Rectangle* pRect) const;
511 
512  css::uno::Reference< css::uno::XInterface > const & getUnoPage();
513 
514  virtual SfxStyleSheet* GetTextStyleSheetForObject( SdrObject* pObj ) const;
515 
517  // #i75566# GetBackgroundColor -> GetPageBackgroundColor
518  Color GetPageBackgroundColor() const;
519 
521  // #i75566# GetBackgroundColor -> GetPageBackgroundColor and bScreenDisplay hint value
522  Color GetPageBackgroundColor( SdrPageView const * pView, bool bScreenDisplay = true) const;
523 
529  virtual bool checkVisibility(
530  const sdr::contact::ViewObjectContact& rOriginal,
531  const sdr::contact::DisplayInfo& rDisplayInfo,
532  bool bEdit );
533 };
534 
535 /* 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:305
::std::vector< PageUser * > PageUserVector
Definition: sdrpageuser.hxx:46
sal_Int32 mnWidth
Definition: svdpage.hxx:406
tools::Rectangle maSdrObjListOutRect
Definition: svdpage.hxx:225
sdr::PageUserVector maPageUsers
Definition: svdpage.hxx:381
struct _xmlTextWriter * xmlTextWriterPtr
for the snap-to-grid in Writer
Definition: svdpage.hxx:280
bool mbObjOrdNumsDirty
Definition: svdpage.hxx:231
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:232
const tools::Rectangle & GetUserArea() const
Definition: svdpage.hxx:287
std::optional< std::vector< tools::WeakReference< SdrObject > > > mxNavigationOrder
This list, if it exists, defines the navigation order.
Definition: svdpage.hxx:230
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:101
SdrModel & mrSdrModelFromSdrPage
Definition: svdpage.hxx:403
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
css::uno::Reference< css::uno::XInterface > mxUnoPage
Definition: svdpage.hxx:416
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:414
void Insert(const SdrPageGridFrame &rGF)
Definition: svdpage.hxx:303
SdrPage * mpSdrPage
Definition: svdpage.hxx:313
std::vector< SdrObject * > maList
Definition: svdpage.hxx:227
tools::Rectangle aPaper
Definition: svdpage.hxx:282
bool IsMasterPage() const
Definition: svdpage.hxx:451
const SfxItemSet & GetItemSet() const
Definition: svdpage.hxx:334
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:487
Abstract DrawObject.
Definition: svdobj.hxx:259
void Clear(EHistoryType eHistory)
sal_uInt16 GetCount() const
Definition: svdpage.hxx:302
void setPageBorderOnlyLeftRight(bool bNew)
Definition: svdpage.hxx:465
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:453
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:122
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: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:415
tools::Rectangle maSdrObjListSnapRect
Definition: svdpage.hxx:226
sal_uInt16 nPageNum
Definition: svdpage.hxx:427