LibreOffice Module svx (master)  1
viewcontactofsdrobj.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 
23 #include <svx/svdobj.hxx>
25 #include <tools/debug.hxx>
26 #include <vcl/outdev.hxx>
27 #include <svx/svdoole2.hxx>
28 #include <svx/svdpage.hxx>
30 #include <basegfx/color/bcolor.hxx>
34 #include <svx/sdrpagewindow.hxx>
35 #include <svx/sdrpaintwindow.hxx>
36 #include <svx/svdhdl.hxx>
37 
38 namespace sdr { namespace contact {
39 
40 // Create an Object-Specific ViewObjectContact, set ViewContact and
41 // ObjectContact. Always needs to return something.
43 {
44  ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this);
45  DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
46 
47  return *pRetval;
48 }
49 
51 : ViewContact(),
52  mrObject(rObj),
53  meRememberedAnimationKind(SdrTextAniKind::NONE)
54 {
55  // init AnimationKind
56  if(dynamic_cast<const SdrTextObj*>( &GetSdrObject() ) != nullptr)
57  {
58  SdrTextObj& rTextObj = static_cast<SdrTextObj&>(GetSdrObject());
60  }
61 }
62 
64 {
65 }
66 
67 // Access to possible sub-hierarchy
69 {
70  if(GetSdrObject().GetSubList())
71  {
72  return GetSdrObject().GetSubList()->GetObjCount();
73  }
74 
75  return 0L;
76 }
77 
79 {
80  assert(GetSdrObject().GetSubList() &&
81  "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
82  SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
83  assert(pObj && "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
84  return pObj->GetViewContact();
85 }
86 
88 {
89  ViewContact* pRetval = nullptr;
91 
92  if(pObjList)
93  {
94  if(dynamic_cast<const SdrPage*>( pObjList) != nullptr)
95  {
96  // Is a page
97  pRetval = &(static_cast<SdrPage*>(pObjList)->GetViewContact());
98  }
99  else
100  {
101  // Is a group?
102  if(pObjList->getSdrObjectFromSdrObjList())
103  {
104  pRetval = &(pObjList->getSdrObjectFromSdrObjList()->GetViewContact());
105  }
106  }
107  }
108 
109  return pRetval;
110 }
111 
112 // React on changes of the object of this ViewContact
114 {
115  // look for own changes
116  if(dynamic_cast<const SdrTextObj*>( &GetSdrObject() ) != nullptr)
117  {
118  SdrTextObj& rTextObj = static_cast<SdrTextObj&>(GetSdrObject());
119 
120  if(rTextObj.GetTextAniKind() != meRememberedAnimationKind)
121  {
122  // #i38135# now remember new type
124  }
125  }
126 
127  // call parent
129 }
130 
131 // override for accessing the SdrObject
133 {
134  return &GetSdrObject();
135 }
136 
137 
138 // primitive stuff
139 
140 // add Gluepoints (if available)
142 {
144  const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
145 
146  if(pGluePointList)
147  {
148  const sal_uInt32 nCount(pGluePointList->GetCount());
149 
150  if(nCount)
151  {
152  // prepare point vector
153  std::vector< basegfx::B2DPoint > aGluepointVector;
154 
155  // create GluePoint primitives. ATM these are relative to the SnapRect
156  for(sal_uInt32 a(0); a < nCount; a++)
157  {
158  const SdrGluePoint& rCandidate = (*pGluePointList)[static_cast<sal_uInt16>(a)];
159  const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
160 
161  aGluepointVector.emplace_back(aPosition.X(), aPosition.Y());
162  }
163 
164  if(!aGluepointVector.empty())
165  {
168  aGluepointVector, SdrHdl::createGluePointBitmap()));
169  xRetval = drawinglayer::primitive2d::Primitive2DContainer{ xReference };
170  }
171  }
172  }
173 
174  return xRetval;
175 }
176 
178 {
179  if(!aSource.empty() &&
180  (!GetSdrObject().GetName().isEmpty() ||
181  !GetSdrObject().GetTitle().isEmpty() ||
182  !GetSdrObject().GetDescription().isEmpty()))
183  {
186  aSource,
187  GetSdrObject().GetName(),
189  GetSdrObject().GetDescription()));
190 
192  }
193 
194  return aSource;
195 }
196 
197 }}
198 
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetDescription() const
Definition: svdobj.cxx:813
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:773
size_t GetObjCount() const
Definition: svdpage.cxx:767
SdrTextAniKind GetTextAniKind() const
Definition: svdotext.cxx:1770
virtual drawinglayer::primitive2d::Primitive2DContainer createGluePointPrimitive2DSequence() const override
sal_uInt16 GetCount() const
Definition: svdglue.hxx:126
virtual ViewContact & GetViewContact(sal_uInt32 nIndex) const override
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:674
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:271
SdrTextAniKind
Animation type for text frame.
Definition: sdtakitm.hxx:29
NONE
UNOTOOLS_DLLPUBLIC bool GetTitle(OUString const &url, OUString *title)
virtual ViewObjectContact & CreateObjectSpecificViewObjectContact(ObjectContact &rObjectContact) override
int nCount
virtual SdrObject * TryToGetSdrObject() const override
override for accessing the SdrObject
virtual const SdrGluePointList * GetGluePointList() const
Definition: svdobj.cxx:2225
#define DBG_ASSERT(sCon, aError)
uno_Any a
OUString GetTitle() const
Definition: svdobj.cxx:769
Abstract DrawObject.
Definition: svdobj.hxx:312
virtual void ActionChanged()
Point GetAbsolutePos(const SdrObject &rObj) const
Definition: svdglue.cxx:47
OUString GetName() const
Definition: svdobj.cxx:725
virtual ViewContact * GetParentContact() const override
virtual drawinglayer::primitive2d::Primitive2DContainer embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer aSource) const override
virtual sal_uInt32 GetObjectCount() const override
css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference
static BitmapEx createGluePointBitmap()
Definition: svdhdl.cxx:1078
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
SdrObjList * getParentSdrObjListFromSdrObject() const
Definition: svdobj.cxx:325
virtual SdrObject * getSdrObjectFromSdrObjList() const
Definition: svdpage.cxx:152