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>
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 <unotools/weakref.hxx>
34#include <memory>
35#include <optional>
36#include <vector>
37#include <deque>
38
39
40// predefines
41namespace model { class Theme; }
42namespace reportdesign { class OSection; }
43namespace sdr::contact { class ViewContact; }
44class SdrPage;
45class SdrModel;
46class SfxItemPool;
47class SdrPageView;
48class SdrLayerAdmin;
49class SdrLayerIDSet;
50class Color;
51class SfxStyleSheet;
53
55//
56// SdrObjList
57// E3dObjList
58// SdrPage -> see continuation there
59
60// class SdrObjList
62{
63friend class SdrObjListIter;
64friend class SdrEditView;
65
66private:
67 SdrObjList(const SdrObjList& rSrcList) = delete;
68 SdrObjList &operator=(const SdrObjList& rSrcList) = delete;
69
70protected:
71 void RecalcRects();
72
73private:
75 static void impChildInserted(SdrObject const & rChild);
76
77 // tdf#116879 Clear SdrObjList, no Undo done. Used from destructor, but also
78 // from other places. When used from destructor, suppress broadcasts
79 // to not get callbacks to evtl. derived objects already in destruction
80 // (e.g. SdrPage)
81 void impClearSdrObjList(bool bBroadcast);
82
83protected:
84 // protected constructor to make clear that this class should only
85 // be used as base for derivations, not naked. See getSdrModelFromSdrObjList
86 // which is pure virtual to force this, too
87 SdrObjList();
88 virtual ~SdrObjList();
89
90public:
91 // SdrModel/SdrPage access on SdrObjList level
92 virtual SdrPage* getSdrPageFromSdrObjList() const;
93 virtual SdrObject* getSdrObjectFromSdrObjList() const;
94
95 void CopyObjects(const SdrObjList& rSrcList);
96
97 // tdf#116879 clean up everything (without Undo), plus broadcasting
98 // changes. Split to this call and a private one (impClearSdrObjList)
99 // that allows cleanup without broadcasting in the destructor
100 void ClearSdrObjList();
101
103 void RecalcObjOrdNums();
104 bool IsObjOrdNumsDirty() const { return mbObjOrdNumsDirty; }
105 virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE);
106 virtual void InsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE);
107 void sort( std::vector<sal_Int32>& sortOrder );
108
109 void InsertObjectThenMakeNameUnique(SdrObject* pObj);
110 void InsertObjectThenMakeNameUnique(SdrObject* pObj, std::unordered_set<rtl::OUString>& rNameSet, size_t nPos=SAL_MAX_SIZE);
111
113 virtual rtl::Reference<SdrObject> NbcRemoveObject(size_t nObjNum);
114 virtual rtl::Reference<SdrObject> RemoveObject(size_t nObjNum);
115
119 virtual rtl::Reference<SdrObject> ReplaceObject(SdrObject* pNewObj, size_t nObjNum);
120
122 virtual SdrObject* SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum);
123
125 void SetExistingObjectOrdNum(SdrObject* pExistingObj, size_t nNewObjNum);
126
127 void SetSdrObjListRectsDirty();
128
129 const tools::Rectangle& GetAllObjSnapRect() const;
130 const tools::Rectangle& GetAllObjBoundRect() const;
131
133 void NbcReformatAllTextObjects();
134 void ReformatAllTextObjects();
135
137 void ReformatAllEdgeObjects();
138
140 void BurnInStyleSheetAttributes();
141
142 size_t GetObjCount() const;
143 SdrObject* GetObj(size_t nNum) const;
144 SdrObject* GetObjByName(std::u16string_view sName) 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
228private:
231 std::deque<rtl::Reference<SdrObject>> maList;
234 std::optional<std::vector<unotools::WeakReference<SdrObject>>> mxNavigationOrder;
240
252 void InsertObjectIntoContainer (
253 SdrObject& rObject,
254 const sal_uInt32 nInsertPosition);
255
265 void ReplaceObjectInContainer (
266 SdrObject& rObject,
267 const sal_uInt32 nObjectPosition);
268
276 void RemoveObjectFromContainer (
277 const sal_uInt32 nObjectPosition);
278
279 void ImplReformatAllEdgeObjects(const SdrObjList& );
280};
281
282// Used for all methods which return a page number
283#define SDRPAGE_NOTFOUND 0xFFFF
284
287{
290public:
291 SdrPageGridFrame(const tools::Rectangle& rPaper, const tools::Rectangle& rUser): aPaper(rPaper), aUserArea(rUser) {}
292 const tools::Rectangle& GetPaperRect() const { return aPaper; }
293 const tools::Rectangle& GetUserArea() const { return aUserArea; }
294};
295
297{
298 std::vector<SdrPageGridFrame*> aList;
299
301 void operator=(const SdrPageGridFrameList& rSrcList) = delete;
302 SdrPageGridFrame* GetObject(sal_uInt16 i) const { return aList[i]; }
303
304public:
307 void Clear();
308 sal_uInt16 GetCount() const { return sal_uInt16(aList.size()); }
309 void Insert(const SdrPageGridFrame& rGF) { aList.push_back(new SdrPageGridFrame(rGF)); }
310 SdrPageGridFrame& operator[](sal_uInt16 nPos) { return *GetObject(nPos); }
311 const SdrPageGridFrame& operator[](sal_uInt16 nPos) const { return *GetObject(nPos); }
312};
313
314// class SdrPageProperties
315class SVXCORE_DLLPUBLIC SdrPageProperties final : public SfxListener, public svl::StyleSheetUser
316{
317private:
318 // data
321 std::shared_ptr<model::Theme> mpTheme;
323
324 // internal helpers
325 void ImpRemoveStyleSheet();
326 void ImpAddStyleSheet(SfxStyleSheet& rNewStyleSheet);
327
328 SdrPageProperties& operator=(const SdrPageProperties& rCandidate) = delete;
329
331public:
332 // construct/destruct
333 SdrPageProperties(SdrPage& rSdrPage);
334 virtual ~SdrPageProperties() override;
335
336 // Notify(...) from baseclass SfxListener
337 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
338
339 virtual bool isUsedByModel() const override;
340
341 // data read/write
342 const SfxItemSet& GetItemSet() const { return maProperties;}
343 void PutItemSet(const SfxItemSet& rSet);
344 void PutItem(const SfxPoolItem& rItem);
345 void ClearItem(const sal_uInt16 nWhich = 0);
346
347 // StyleSheet access
348 void SetStyleSheet(SfxStyleSheet* pStyleSheet);
349 SfxStyleSheet* GetStyleSheet() const { return mpStyleSheet;}
350
351 void SetTheme(std::shared_ptr<model::Theme> const& pTheme);
352 std::shared_ptr<model::Theme> const& GetTheme() const;
353
354 void dumpAsXml(xmlTextWriterPtr pWriter) const;
355};
356
357
369//
370// SdrPage
371// DlgEdPage
372// FmFormPage
373// ScDrawPage
374// SdPage
375// SwDPage
376// OReportPage
377
379{
380 // #i9076#
381 friend class SdrModel;
383
384 // this class uses its own UNO wrapper
385 // and thus has to set mxUnoPage (it also relies on mxUnoPage not being WeakRef)
387
388 SdrPage& operator=(const SdrPage&) = delete;
389 SdrPage(const SdrPage&) = delete;
390
391 // start PageUser section
392private:
393 // #111111# PageUser section
395
396 std::unique_ptr<sdr::contact::ViewContact> mpViewContact;
397
398public:
399 void AddPageUser(sdr::PageUser& rNewUser);
400 void RemovePageUser(sdr::PageUser& rOldUser);
401
402 // SdrModel access on SdrPage level
403 SdrModel& getSdrModelFromSdrPage() const { return mrSdrModelFromSdrPage; }
404
405protected:
406 std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact();
407public:
408 const sdr::contact::ViewContact& GetViewContact() const;
409 sdr::contact::ViewContact& GetViewContact();
410
411 // #110094# DrawContact support: Methods for handling Page changes
412 void ActionChanged();
413
414private:
415 // the SdrModel this page was created with, unchanged during SdrPage lifetime
417
418private:
419 tools::Long mnWidth; // page size
420 tools::Long mnHeight; // page size
421 sal_Int32 mnBorderLeft; // left page margin
422 sal_Int32 mnBorderUpper; // top page margin
423 sal_Int32 mnBorderRight; // right page margin
424 sal_Int32 mnBorderLower; // bottom page margin
425 bool mbBackgroundFullSize = false;
426
427 std::unique_ptr<SdrLayerAdmin> mpLayerAdmin;
428 std::unique_ptr<SdrPageProperties> mpSdrPageProperties;
429 css::uno::Reference< css::uno::XInterface > mxUnoPage;
430
431public:
432 SdrPageProperties& getSdrPageProperties();
433 const SdrPageProperties& getSdrPageProperties() const;
434 const SdrPageProperties* getCorrectSdrPageProperties() const;
435
436protected:
437 // new MasterPageDescriptorVector
438 std::unique_ptr<sdr::MasterPageDescriptor> mpMasterPageDescriptor;
439
440 sal_uInt16 nPageNum;
441
442 bool mbMaster : 1; // flag if this is a MasterPage
443 bool mbInserted : 1;
445
446 // #i93597#
448
449 void SetUnoPage(css::uno::Reference<css::drawing::XDrawPage> const&);
450 virtual css::uno::Reference< css::uno::XInterface > createUnoPage();
451
452 // Copying of pages is split into two parts: construction and copying of page objects,
453 // because the copying might need access to fully initialized page. CloneSdrPage() is responsible
454 // to call lateInit() after copy-construction of a new object. Any initialization in derived
455 // classes that needs access to the page objects must be deferred to lateInit. And it must
456 // call lateInit() of its parent class.
457 void lateInit(const SdrPage& rSrcPage);
458
459public:
460 explicit SdrPage(SdrModel& rModel, bool bMasterPage=false);
461 virtual ~SdrPage() override;
462
463 virtual rtl::Reference<SdrPage> CloneSdrPage(SdrModel& rTargetModel) const;
464 bool IsMasterPage() const { return mbMaster; }
465 void SetInserted(bool bNew = true);
466 bool IsInserted() const { return mbInserted; }
467 void SetChanged();
468
469 // derived from SdrObjList, returns this
470 virtual SdrPage* getSdrPageFromSdrObjList() const override;
471
472 // #i68775# React on PageNum changes (from Model in most cases)
473 void SetPageNum(sal_uInt16 nNew);
474 sal_uInt16 GetPageNum() const;
475
476 // #i93597# Allow page border definition to not be the full rectangle but to
477 // use only the left and right vertical edges (reportdesigner)
478 void setPageBorderOnlyLeftRight(bool bNew) { mbPageBorderOnlyLeftRight = bNew; }
479 bool getPageBorderOnlyLeftRight() const { return mbPageBorderOnlyLeftRight; }
480
481 virtual void SetSize(const Size& aSiz);
482 Size GetSize() const;
483 virtual void SetOrientation(Orientation eOri);
484 virtual Orientation GetOrientation() const;
485 tools::Long GetWidth() const;
486 tools::Long GetHeight() const;
487 virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr);
488 virtual void SetLeftBorder(sal_Int32 nBorder);
489 virtual void SetUpperBorder(sal_Int32 nBorder);
490 virtual void SetRightBorder(sal_Int32 nBorder);
491 virtual void SetLowerBorder(sal_Int32 nBorder);
492 sal_Int32 GetLeftBorder() const;
493 sal_Int32 GetUpperBorder() const;
494 sal_Int32 GetRightBorder() const;
495 sal_Int32 GetLowerBorder() const;
496 void SetBackgroundFullSize(bool bIn);
497 bool IsBackgroundFullSize() const;
498
499 // New MasterPage interface
500 bool TRG_HasMasterPage() const { return (nullptr != mpMasterPageDescriptor); }
501 void TRG_SetMasterPage(SdrPage& rNew);
502 void TRG_ClearMasterPage();
503 SdrPage& TRG_GetMasterPage() const;
504 const SdrLayerIDSet& TRG_GetMasterPageVisibleLayers() const;
505 void TRG_SetMasterPageVisibleLayers(const SdrLayerIDSet& rNew);
506 sdr::contact::ViewContact& TRG_GetMasterPageDescriptorViewContact() const;
507
508 void MakePageObjectsNamesUnique();
509
510protected:
511 void TRG_ImpMasterPageRemoved(const SdrPage& rRemovedPage);
512public:
513
515 const SdrLayerAdmin& GetLayerAdmin() const;
516 SdrLayerAdmin& GetLayerAdmin();
517
518 virtual OUString GetLayoutName() const;
519
523 virtual const SdrPageGridFrameList* GetGridFrameList(const SdrPageView* pPV, const tools::Rectangle* pRect) const;
524
525 css::uno::Reference< css::uno::XInterface > const & getUnoPage();
526
527 virtual SfxStyleSheet* GetTextStyleSheetForObject( SdrObject* pObj ) const;
528
530 // #i75566# GetBackgroundColor -> GetPageBackgroundColor
531 Color GetPageBackgroundColor() const;
532
534 // #i75566# GetBackgroundColor -> GetPageBackgroundColor and bScreenDisplay hint value
535 Color GetPageBackgroundColor( SdrPageView const * pView, bool bScreenDisplay = true) const;
536
542 virtual bool checkVisibility(
543 const sdr::contact::ViewObjectContact& rOriginal,
544 const sdr::contact::DisplayInfo& rDisplayInfo,
545 bool bEdit );
546
547 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
548};
549
550/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbRectsDirty
Definition: svdpage.hxx:236
tools::Rectangle maSdrObjListOutRect
Definition: svdpage.hxx:229
void InsertObjectThenMakeNameUnique(SdrObject *pObj, std::unordered_set< rtl::OUString > &rNameSet, size_t nPos=SAL_MAX_SIZE)
std::deque< rtl::Reference< SdrObject > > maList
Definition: svdpage.hxx:231
std::optional< std::vector< unotools::WeakReference< SdrObject > > > mxNavigationOrder
This list, if it exists, defines the navigation order.
Definition: svdpage.hxx:234
SdrObjList & operator=(const SdrObjList &rSrcList)=delete
bool IsObjOrdNumsDirty() const
Definition: svdpage.hxx:104
bool mbObjOrdNumsDirty
Definition: svdpage.hxx:235
SdrObjList(const SdrObjList &rSrcList)=delete
tools::Rectangle maSdrObjListSnapRect
Definition: svdpage.hxx:230
bool mbIsNavigationOrderDirty
This flag is <TRUE> when the mpNavigation list has been changed but the indices of the referenced Sdr...
Definition: svdpage.hxx:239
Abstract DrawObject.
Definition: svdobj.hxx:260
SdrPageGridFrame * GetObject(sal_uInt16 i) const
Definition: svdpage.hxx:302
SdrPageGridFrame & operator[](sal_uInt16 nPos)
Definition: svdpage.hxx:310
SdrPageGridFrameList(const SdrPageGridFrameList &rSrcList)=delete
sal_uInt16 GetCount() const
Definition: svdpage.hxx:308
std::vector< SdrPageGridFrame * > aList
Definition: svdpage.hxx:298
void operator=(const SdrPageGridFrameList &rSrcList)=delete
const SdrPageGridFrame & operator[](sal_uInt16 nPos) const
Definition: svdpage.hxx:311
void Insert(const SdrPageGridFrame &rGF)
Definition: svdpage.hxx:309
for the snap-to-grid in Writer
Definition: svdpage.hxx:287
const tools::Rectangle & GetUserArea() const
Definition: svdpage.hxx:293
const tools::Rectangle & GetPaperRect() const
Definition: svdpage.hxx:292
tools::Rectangle aUserArea
Definition: svdpage.hxx:289
tools::Rectangle aPaper
Definition: svdpage.hxx:288
SdrPageGridFrame(const tools::Rectangle &rPaper, const tools::Rectangle &rUser)
Definition: svdpage.hxx:291
const SfxItemSet & GetItemSet() const
Definition: svdpage.hxx:342
SfxStyleSheet * mpStyleSheet
Definition: svdpage.hxx:320
SfxItemSet maProperties
Definition: svdpage.hxx:322
SdrPage * mpSdrPage
Definition: svdpage.hxx:319
SdrPageProperties & operator=(const SdrPageProperties &rCandidate)=delete
void sendLOKitThemeChangedCallback()
SfxStyleSheet * GetStyleSheet() const
Definition: svdpage.hxx:349
std::shared_ptr< model::Theme > mpTheme
Definition: svdpage.hxx:321
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:379
std::unique_ptr< SdrLayerAdmin > mpLayerAdmin
Definition: svdpage.hxx:427
sal_Int32 mnBorderRight
Definition: svdpage.hxx:423
sal_Int32 mnBorderLeft
Definition: svdpage.hxx:421
sal_Int32 mnBorderUpper
Definition: svdpage.hxx:422
sal_Int32 mnBorderLower
Definition: svdpage.hxx:424
bool IsInserted() const
Definition: svdpage.hxx:466
bool mbInserted
Definition: svdpage.hxx:443
sdr::PageUserVector maPageUsers
Definition: svdpage.hxx:394
bool mbPageBorderOnlyLeftRight
Definition: svdpage.hxx:447
bool getPageBorderOnlyLeftRight() const
Definition: svdpage.hxx:479
sal_uInt16 nPageNum
Definition: svdpage.hxx:440
css::uno::Reference< css::uno::XInterface > mxUnoPage
Definition: svdpage.hxx:429
tools::Long mnWidth
Definition: svdpage.hxx:419
bool mbMaster
Definition: svdpage.hxx:442
std::unique_ptr< SdrPageProperties > mpSdrPageProperties
Definition: svdpage.hxx:428
bool IsMasterPage() const
Definition: svdpage.hxx:464
void setPageBorderOnlyLeftRight(bool bNew)
Definition: svdpage.hxx:478
std::unique_ptr< sdr::MasterPageDescriptor > mpMasterPageDescriptor
Definition: svdpage.hxx:438
SdrModel & mrSdrModelFromSdrPage
Definition: svdpage.hxx:416
SdrPage & operator=(const SdrPage &)=delete
std::unique_ptr< sdr::contact::ViewContact > mpViewContact
Definition: svdpage.hxx:396
bool mbObjectsNotPersistent
Definition: svdpage.hxx:444
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:500
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:403
tools::Long mnHeight
Definition: svdpage.hxx:420
SdrPage(const SdrPage &)=delete
bool lateInit
virtual css::uno::Reference< css::embed::XEmbeddedObject > GetObject() override
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
struct _xmlTextWriter * xmlTextWriterPtr
OUString sName
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
sal_uInt16 nPos
SvGenericNameContainerMapImpl maProperties
void Clear(EHistoryType eHistory)
int i
::std::vector< PageUser * > PageUserVector
Definition: sdrpageuser.hxx:46
long Long
Orientation
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35