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 <svx/ColorSets.hxx>
34#include <unotools/weakref.hxx>
35#include <memory>
36#include <optional>
37#include <vector>
38#include <deque>
39
40
41// predefines
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
146 virtual bool IsReadOnly() const;
147
155 void FlattenGroups();
156
166 void UnGroupObj( size_t nObjNum );
167
175 bool HasObjectNavigationOrder() const;
176
181 void SetObjectNavigationPosition (
182 SdrObject& rObject,
183 const sal_uInt32 nNewNavigationPosition);
184
195 SdrObject* GetObjectForNavigationPosition (const sal_uInt32 nNavigationPosition) const;
196
199 void ClearObjectNavigationOrder();
200
211 bool RecalcNavigationPositions();
212
222 void SetNavigationOrder (const css::uno::Reference<
223 css::container::XIndexAccess>& rxOrder);
224
225 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
226
227private:
230 std::deque<rtl::Reference<SdrObject>> maList;
233 std::optional<std::vector<unotools::WeakReference<SdrObject>>> mxNavigationOrder;
239
251 void InsertObjectIntoContainer (
252 SdrObject& rObject,
253 const sal_uInt32 nInsertPosition);
254
264 void ReplaceObjectInContainer (
265 SdrObject& rObject,
266 const sal_uInt32 nObjectPosition);
267
275 void RemoveObjectFromContainer (
276 const sal_uInt32 nObjectPosition);
277
278 void ImplReformatAllEdgeObjects(const SdrObjList& );
279};
280
281// Used for all methods which return a page number
282#define SDRPAGE_NOTFOUND 0xFFFF
283
286{
289public:
290 SdrPageGridFrame(const tools::Rectangle& rPaper, const tools::Rectangle& rUser): aPaper(rPaper), aUserArea(rUser) {}
291 const tools::Rectangle& GetPaperRect() const { return aPaper; }
292 const tools::Rectangle& GetUserArea() const { return aUserArea; }
293};
294
296{
297 std::vector<SdrPageGridFrame*> aList;
298
300 void operator=(const SdrPageGridFrameList& rSrcList) = delete;
301 SdrPageGridFrame* GetObject(sal_uInt16 i) const { return aList[i]; }
302
303public:
306 void Clear();
307 sal_uInt16 GetCount() const { return sal_uInt16(aList.size()); }
308 void Insert(const SdrPageGridFrame& rGF) { aList.push_back(new SdrPageGridFrame(rGF)); }
309 SdrPageGridFrame& operator[](sal_uInt16 nPos) { return *GetObject(nPos); }
310 const SdrPageGridFrame& operator[](sal_uInt16 nPos) const { return *GetObject(nPos); }
311};
312
313// class SdrPageProperties
315{
316private:
317 // data
320 std::unique_ptr<svx::Theme> mpTheme;
322
323 // internal helpers
324 void ImpRemoveStyleSheet();
325 void ImpAddStyleSheet(SfxStyleSheet& rNewStyleSheet);
326
327 SdrPageProperties& operator=(const SdrPageProperties& rCandidate) = delete;
328
329public:
330 // construct/destruct
331 SdrPageProperties(SdrPage& rSdrPage);
332 virtual ~SdrPageProperties() override;
333
334 // Notify(...) from baseclass SfxListener
335 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
336
337 virtual bool isUsedByModel() const override;
338
339 // data read/write
340 const SfxItemSet& GetItemSet() const { return maProperties;}
341 void PutItemSet(const SfxItemSet& rSet);
342 void PutItem(const SfxPoolItem& rItem);
343 void ClearItem(const sal_uInt16 nWhich = 0);
344
345 // StyleSheet access
346 void SetStyleSheet(SfxStyleSheet* pStyleSheet);
347 SfxStyleSheet* GetStyleSheet() const { return mpStyleSheet;}
348
349 void SetTheme(std::unique_ptr<svx::Theme> pTheme);
350 svx::Theme* GetTheme();
351
352 void dumpAsXml(xmlTextWriterPtr pWriter) const;
353};
354
355
367//
368// SdrPage
369// DlgEdPage
370// FmFormPage
371// ScDrawPage
372// SdPage
373// SwDPage
374// OReportPage
375
377{
378 // #i9076#
379 friend class SdrModel;
381
382 // this class uses its own UNO wrapper
383 // and thus has to set mxUnoPage (it also relies on mxUnoPage not being WeakRef)
385
386 SdrPage& operator=(const SdrPage&) = delete;
387 SdrPage(const SdrPage&) = delete;
388
389 // start PageUser section
390private:
391 // #111111# PageUser section
393
394 std::unique_ptr<sdr::contact::ViewContact> mpViewContact;
395
396public:
397 void AddPageUser(sdr::PageUser& rNewUser);
398 void RemovePageUser(sdr::PageUser& rOldUser);
399
400 // SdrModel access on SdrPage level
401 SdrModel& getSdrModelFromSdrPage() const { return mrSdrModelFromSdrPage; }
402
403protected:
404 std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact();
405public:
406 const sdr::contact::ViewContact& GetViewContact() const;
407 sdr::contact::ViewContact& GetViewContact();
408
409 // #110094# DrawContact support: Methods for handling Page changes
410 void ActionChanged();
411
412private:
413 // the SdrModel this page was created with, unchanged during SdrPage lifetime
415
416private:
417 tools::Long mnWidth; // page size
418 tools::Long mnHeight; // page size
419 sal_Int32 mnBorderLeft; // left page margin
420 sal_Int32 mnBorderUpper; // top page margin
421 sal_Int32 mnBorderRight; // right page margin
422 sal_Int32 mnBorderLower; // bottom page margin
423 bool mbBackgroundFullSize = false;
424
425 std::unique_ptr<SdrLayerAdmin> mpLayerAdmin;
426 std::unique_ptr<SdrPageProperties> mpSdrPageProperties;
427 css::uno::Reference< css::uno::XInterface > mxUnoPage;
428
429public:
430 SdrPageProperties& getSdrPageProperties();
431 const SdrPageProperties& getSdrPageProperties() const;
432 const SdrPageProperties* getCorrectSdrPageProperties() const;
433
434protected:
435 // new MasterPageDescriptorVector
436 std::unique_ptr<sdr::MasterPageDescriptor> mpMasterPageDescriptor;
437
438 sal_uInt16 nPageNum;
439
440 bool mbMaster : 1; // flag if this is a MasterPage
441 bool mbInserted : 1;
443
444 // #i93597#
446
447 void SetUnoPage(css::uno::Reference<css::drawing::XDrawPage> const&);
448 virtual css::uno::Reference< css::uno::XInterface > createUnoPage();
449
450 // Copying of pages is split into two parts: construction and copying of page objects,
451 // because the copying might need access to fully initialized page. CloneSdrPage() is responsible
452 // to call lateInit() after copy-construction of a new object. Any initialization in derived
453 // classes that needs access to the page objects must be deferred to lateInit. And it must
454 // call lateInit() of its parent class.
455 void lateInit(const SdrPage& rSrcPage);
456
457public:
458 explicit SdrPage(SdrModel& rModel, bool bMasterPage=false);
459 virtual ~SdrPage() override;
460
461 virtual rtl::Reference<SdrPage> CloneSdrPage(SdrModel& rTargetModel) const;
462 bool IsMasterPage() const { return mbMaster; }
463 void SetInserted(bool bNew = true);
464 bool IsInserted() const { return mbInserted; }
465 void SetChanged();
466
467 // derived from SdrObjList, returns this
468 virtual SdrPage* getSdrPageFromSdrObjList() const override;
469
470 // #i68775# React on PageNum changes (from Model in most cases)
471 void SetPageNum(sal_uInt16 nNew);
472 sal_uInt16 GetPageNum() const;
473
474 // #i93597# Allow page border definition to not be the full rectangle but to
475 // use only the left and right vertical edges (reportdesigner)
476 void setPageBorderOnlyLeftRight(bool bNew) { mbPageBorderOnlyLeftRight = bNew; }
477 bool getPageBorderOnlyLeftRight() const { return mbPageBorderOnlyLeftRight; }
478
479 virtual void SetSize(const Size& aSiz);
480 Size GetSize() const;
481 virtual void SetOrientation(Orientation eOri);
482 virtual Orientation GetOrientation() const;
483 tools::Long GetWidth() const;
484 tools::Long GetHeight() const;
485 virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr);
486 virtual void SetLeftBorder(sal_Int32 nBorder);
487 virtual void SetUpperBorder(sal_Int32 nBorder);
488 virtual void SetRightBorder(sal_Int32 nBorder);
489 virtual void SetLowerBorder(sal_Int32 nBorder);
490 sal_Int32 GetLeftBorder() const;
491 sal_Int32 GetUpperBorder() const;
492 sal_Int32 GetRightBorder() const;
493 sal_Int32 GetLowerBorder() const;
494 void SetBackgroundFullSize(bool bIn);
495 bool IsBackgroundFullSize() const;
496
497 // New MasterPage interface
498 bool TRG_HasMasterPage() const { return (nullptr != mpMasterPageDescriptor); }
499 void TRG_SetMasterPage(SdrPage& rNew);
500 void TRG_ClearMasterPage();
501 SdrPage& TRG_GetMasterPage() const;
502 const SdrLayerIDSet& TRG_GetMasterPageVisibleLayers() const;
503 void TRG_SetMasterPageVisibleLayers(const SdrLayerIDSet& rNew);
504 sdr::contact::ViewContact& TRG_GetMasterPageDescriptorViewContact() const;
505
506 void MakePageObjectsNamesUnique();
507
508protected:
509 void TRG_ImpMasterPageRemoved(const SdrPage& rRemovedPage);
510public:
511
513 const SdrLayerAdmin& GetLayerAdmin() const;
514 SdrLayerAdmin& GetLayerAdmin();
515
516 virtual OUString GetLayoutName() const;
517
521 virtual const SdrPageGridFrameList* GetGridFrameList(const SdrPageView* pPV, const tools::Rectangle* pRect) const;
522
523 css::uno::Reference< css::uno::XInterface > const & getUnoPage();
524
525 virtual SfxStyleSheet* GetTextStyleSheetForObject( SdrObject* pObj ) const;
526
528 // #i75566# GetBackgroundColor -> GetPageBackgroundColor
529 Color GetPageBackgroundColor() const;
530
532 // #i75566# GetBackgroundColor -> GetPageBackgroundColor and bScreenDisplay hint value
533 Color GetPageBackgroundColor( SdrPageView const * pView, bool bScreenDisplay = true) const;
534
540 virtual bool checkVisibility(
541 const sdr::contact::ViewObjectContact& rOriginal,
542 const sdr::contact::DisplayInfo& rDisplayInfo,
543 bool bEdit );
544
545 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
546};
547
548/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbRectsDirty
Definition: svdpage.hxx:235
tools::Rectangle maSdrObjListOutRect
Definition: svdpage.hxx:228
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:230
std::optional< std::vector< unotools::WeakReference< SdrObject > > > mxNavigationOrder
This list, if it exists, defines the navigation order.
Definition: svdpage.hxx:233
SdrObjList & operator=(const SdrObjList &rSrcList)=delete
bool IsObjOrdNumsDirty() const
Definition: svdpage.hxx:104
bool mbObjOrdNumsDirty
Definition: svdpage.hxx:234
SdrObjList(const SdrObjList &rSrcList)=delete
tools::Rectangle maSdrObjListSnapRect
Definition: svdpage.hxx:229
bool mbIsNavigationOrderDirty
This flag is <TRUE> when the mpNavigation list has been changed but the indices of the referenced Sdr...
Definition: svdpage.hxx:238
Abstract DrawObject.
Definition: svdobj.hxx:257
SdrPageGridFrame * GetObject(sal_uInt16 i) const
Definition: svdpage.hxx:301
SdrPageGridFrame & operator[](sal_uInt16 nPos)
Definition: svdpage.hxx:309
SdrPageGridFrameList(const SdrPageGridFrameList &rSrcList)=delete
sal_uInt16 GetCount() const
Definition: svdpage.hxx:307
std::vector< SdrPageGridFrame * > aList
Definition: svdpage.hxx:297
void operator=(const SdrPageGridFrameList &rSrcList)=delete
const SdrPageGridFrame & operator[](sal_uInt16 nPos) const
Definition: svdpage.hxx:310
void Insert(const SdrPageGridFrame &rGF)
Definition: svdpage.hxx:308
for the snap-to-grid in Writer
Definition: svdpage.hxx:286
const tools::Rectangle & GetUserArea() const
Definition: svdpage.hxx:292
const tools::Rectangle & GetPaperRect() const
Definition: svdpage.hxx:291
tools::Rectangle aUserArea
Definition: svdpage.hxx:288
tools::Rectangle aPaper
Definition: svdpage.hxx:287
SdrPageGridFrame(const tools::Rectangle &rPaper, const tools::Rectangle &rUser)
Definition: svdpage.hxx:290
const SfxItemSet & GetItemSet() const
Definition: svdpage.hxx:340
SfxStyleSheet * mpStyleSheet
Definition: svdpage.hxx:319
SfxItemSet maProperties
Definition: svdpage.hxx:321
std::unique_ptr< svx::Theme > mpTheme
Definition: svdpage.hxx:320
SdrPage * mpSdrPage
Definition: svdpage.hxx:318
SdrPageProperties & operator=(const SdrPageProperties &rCandidate)=delete
SfxStyleSheet * GetStyleSheet() const
Definition: svdpage.hxx:347
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:377
std::unique_ptr< SdrLayerAdmin > mpLayerAdmin
Definition: svdpage.hxx:425
sal_Int32 mnBorderRight
Definition: svdpage.hxx:421
sal_Int32 mnBorderLeft
Definition: svdpage.hxx:419
sal_Int32 mnBorderUpper
Definition: svdpage.hxx:420
sal_Int32 mnBorderLower
Definition: svdpage.hxx:422
bool IsInserted() const
Definition: svdpage.hxx:464
bool mbInserted
Definition: svdpage.hxx:441
sdr::PageUserVector maPageUsers
Definition: svdpage.hxx:392
bool mbPageBorderOnlyLeftRight
Definition: svdpage.hxx:445
bool getPageBorderOnlyLeftRight() const
Definition: svdpage.hxx:477
sal_uInt16 nPageNum
Definition: svdpage.hxx:438
css::uno::Reference< css::uno::XInterface > mxUnoPage
Definition: svdpage.hxx:427
tools::Long mnWidth
Definition: svdpage.hxx:417
bool mbMaster
Definition: svdpage.hxx:440
std::unique_ptr< SdrPageProperties > mpSdrPageProperties
Definition: svdpage.hxx:426
bool IsMasterPage() const
Definition: svdpage.hxx:462
void setPageBorderOnlyLeftRight(bool bNew)
Definition: svdpage.hxx:476
std::unique_ptr< sdr::MasterPageDescriptor > mpMasterPageDescriptor
Definition: svdpage.hxx:436
SdrModel & mrSdrModelFromSdrPage
Definition: svdpage.hxx:414
SdrPage & operator=(const SdrPage &)=delete
std::unique_ptr< sdr::contact::ViewContact > mpViewContact
Definition: svdpage.hxx:394
bool mbObjectsNotPersistent
Definition: svdpage.hxx:442
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:498
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:401
tools::Long mnHeight
Definition: svdpage.hxx:418
SdrPage(const SdrPage &)=delete
A named theme has a named color set.
Definition: ColorSets.hxx:91
bool lateInit
virtual css::uno::Reference< css::embed::XEmbeddedObject > GetObject() override
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
struct _xmlTextWriter * xmlTextWriterPtr
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