LibreOffice Module svx (master)  1
svdopage.cxx
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 
21 #include <svx/svdopage.hxx>
22 #include <svx/dialmgr.hxx>
23 #include <svx/strings.hrc>
24 #include <svx/svdmodel.hxx>
25 #include <svx/svdpage.hxx>
28 #include <rtl/ustrbuf.hxx>
29 
30 
31 // BaseProperties section
32 
33 std::unique_ptr<sdr::properties::BaseProperties> SdrPageObj::CreateObjectSpecificProperties()
34 {
35  return std::make_unique<sdr::properties::PageProperties>(*this);
36 }
37 
38 
39 // DrawContact section
40 
41 std::unique_ptr<sdr::contact::ViewContact> SdrPageObj::CreateObjectSpecificViewContact()
42 {
43  return std::make_unique<sdr::contact::ViewContactOfPageObj>(*this);
44 }
45 
46 
47 // this method is called from the destructor of the referenced page.
48 // do all necessary action to forget the page. It is not necessary to call
49 // RemovePageUser(), that is done from the destructor.
51 {
52  if(mpShownPage && mpShownPage == &rPage)
53  {
54  // #i58769# Do not call ActionChanged() here, because that would
55  // lead to the construction of a view contact object for a page that
56  // is being destroyed.
57 
58  mpShownPage = nullptr;
59  }
60 }
61 
63  SdrModel& rSdrModel,
64  SdrPage* pNewPage)
65 : SdrObject(rSdrModel),
66  mpShownPage(pNewPage)
67 {
68  if(mpShownPage)
69  {
70  mpShownPage->AddPageUser(*this);
71  }
72 }
73 
74 SdrPageObj::SdrPageObj(SdrModel& rSdrModel, SdrPageObj const & rSource)
75 : SdrObject(rSdrModel, rSource),
76  mpShownPage(nullptr)
77 {
79 }
80 
82  SdrModel& rSdrModel,
83  const tools::Rectangle& rRect,
84  SdrPage* pNewPage)
85 : SdrObject(rSdrModel),
86  mpShownPage(pNewPage)
87 {
88  if(mpShownPage)
89  {
90  mpShownPage->AddPageUser(*this);
91  }
92 
93  m_aOutRect = rRect;
94 }
95 
97 {
98  if(mpShownPage)
99  {
100  mpShownPage->RemovePageUser(*this);
101  }
102 }
103 
104 
106 {
107  if(mpShownPage == pNewPage)
108  return;
109 
110  if(mpShownPage)
111  {
112  mpShownPage->RemovePageUser(*this);
113  }
114 
115  mpShownPage = pNewPage;
116 
117  if(mpShownPage)
118  {
119  mpShownPage->AddPageUser(*this);
120  }
121 
122  SetChanged();
124 }
125 
126 // #i96598#
128 {
129  // avoid resetting aOutRect which in case of this object is model data,
130  // not re-creatable view data
131 }
132 
134 {
135  return OBJ_PAGE;
136 }
137 
139 {
140  rInfo.bRotateFreeAllowed=false;
141  rInfo.bRotate90Allowed =false;
142  rInfo.bMirrorFreeAllowed=false;
143  rInfo.bMirror45Allowed =false;
144  rInfo.bMirror90Allowed =false;
145  rInfo.bTransparenceAllowed = false;
146  rInfo.bShearAllowed =false;
147  rInfo.bEdgeRadiusAllowed=false;
148  rInfo.bNoOrthoDesired =false;
149  rInfo.bCanConvToPath =false;
150  rInfo.bCanConvToPoly =false;
151  rInfo.bCanConvToPathLineToArea=false;
152  rInfo.bCanConvToPolyLineToArea=false;
153 }
154 
156 {
157  return new SdrPageObj(rTargetModel, *this);
158 }
159 
161 {
162  OUStringBuffer sName(SvxResId(STR_ObjNameSingulPAGE));
163 
164  OUString aName(GetName());
165  if (!aName.isEmpty())
166  {
167  sName.append(' ');
168  sName.append('\'');
169  sName.append(aName);
170  sName.append('\'');
171  }
172 
173  return sName.makeStringAndClear();
174 }
175 
177 {
178  return SvxResId(STR_ObjNamePluralPAGE);
179 }
180 
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddPageUser(sdr::PageUser &rNewUser)
Definition: svdpage.cxx:1089
virtual ~SdrPageObj() override
Definition: svdopage.cxx:96
tools::Rectangle m_aOutRect
Definition: svdobj.hxx:872
SdrObjKind
Definition: svdobjkind.hxx:24
Provides information about various ZObject properties.
Definition: svdobj.hxx:194
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:25
virtual OUString TakeObjNameSingul() const override
Definition: svdopage.cxx:160
void RemovePageUser(sdr::PageUser &rOldUser)
Definition: svdpage.cxx:1094
Polyline represented by SdrPathObj.
Definition: svdobjkind.hxx:51
virtual void SetBoundRectDirty() override
Definition: svdopage.cxx:127
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdopage.cxx:41
OUString sName
void BroadcastObjectChange() const
Definition: svdobj.cxx:982
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdopage.cxx:138
virtual void PageInDestruction(const SdrPage &rPage) override
Definition: svdopage.cxx:50
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdopage.cxx:33
Abstract DrawObject.
Definition: svdobj.hxx:258
virtual OUString TakeObjNamePlural() const override
Definition: svdopage.cxx:176
OUString GetName() const
Definition: svdobj.cxx:775
virtual SdrObjKind GetObjIdentifier() const override
Definition: svdopage.cxx:133
void SetReferencedPage(SdrPage *pNewPage)
Definition: svdopage.cxx:105
SdrPage * GetReferencedPage() const
Definition: svdopage.hxx:56
OUString aName
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
virtual void SetChanged()
Definition: svdobj.cxx:1006
virtual SdrPageObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdopage.cxx:155
SdrPage * mpShownPage
Definition: svdopage.hxx:37
SdrPageObj(SdrModel &rSdrModel, SdrPage *pNewPage=nullptr)
Definition: svdopage.cxx:62