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>
24 #include <tools/debug.hxx>
25 #include <svx/svdpage.hxx>
29 #include <svx/svdhdl.hxx>
30 
31 namespace sdr::contact {
32 
33 // Create an Object-Specific ViewObjectContact, set ViewContact and
34 // ObjectContact. Always needs to return something.
36 {
37  ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this);
38  DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
39 
40  return *pRetval;
41 }
42 
44 : ViewContact(),
45  mrObject(rObj),
46  meRememberedAnimationKind(SdrTextAniKind::NONE)
47 {
48  // init AnimationKind
49  if(dynamic_cast<const SdrTextObj*>( &GetSdrObject() ) != nullptr)
50  {
51  SdrTextObj& rTextObj = static_cast<SdrTextObj&>(GetSdrObject());
53  }
54 }
55 
57 {
58 }
59 
60 // Access to possible sub-hierarchy
62 {
63  if(GetSdrObject().GetSubList())
64  {
65  return GetSdrObject().GetSubList()->GetObjCount();
66  }
67 
68  return 0;
69 }
70 
72 {
73  assert(GetSdrObject().GetSubList() &&
74  "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
75  SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
76  assert(pObj && "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
77  return pObj->GetViewContact();
78 }
79 
81 {
82  ViewContact* pRetval = nullptr;
84 
85  if(pObjList)
86  {
87  if(dynamic_cast<const SdrPage*>( pObjList) != nullptr)
88  {
89  // Is a page
90  pRetval = &(static_cast<SdrPage*>(pObjList)->GetViewContact());
91  }
92  else
93  {
94  // Is a group?
95  if(pObjList->getSdrObjectFromSdrObjList())
96  {
97  pRetval = &(pObjList->getSdrObjectFromSdrObjList()->GetViewContact());
98  }
99  }
100  }
101 
102  return pRetval;
103 }
104 
105 // React on changes of the object of this ViewContact
107 {
108  // look for own changes
109  if (SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(&GetSdrObject()))
110  {
111  if (pTextObj->GetTextAniKind() != meRememberedAnimationKind)
112  {
113  // #i38135# now remember new type
114  meRememberedAnimationKind = pTextObj->GetTextAniKind();
115  }
116  }
117 
118  // call parent
120 }
121 
122 // override for accessing the SdrObject
124 {
125  return &GetSdrObject();
126 }
127 
128 
129 // primitive stuff
130 
131 // add Gluepoints (if available)
133 {
135  const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
136 
137  if(pGluePointList)
138  {
139  const sal_uInt32 nCount(pGluePointList->GetCount());
140 
141  if(nCount)
142  {
143  // prepare point vector
144  std::vector< basegfx::B2DPoint > aGluepointVector;
145 
146  // create GluePoint primitives. ATM these are relative to the SnapRect
147  for(sal_uInt32 a(0); a < nCount; a++)
148  {
149  const SdrGluePoint& rCandidate = (*pGluePointList)[static_cast<sal_uInt16>(a)];
150  const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
151 
152  aGluepointVector.emplace_back(aPosition.X(), aPosition.Y());
153  }
154 
155  if(!aGluepointVector.empty())
156  {
159  aGluepointVector, SdrHdl::createGluePointBitmap()));
160  xRetval = drawinglayer::primitive2d::Primitive2DContainer{ xReference };
161  }
162  }
163  }
164 
165  return xRetval;
166 }
167 
169 {
170  if(!aSource.empty() &&
171  (!GetSdrObject().GetName().isEmpty() ||
172  !GetSdrObject().GetTitle().isEmpty() ||
173  !GetSdrObject().GetDescription().isEmpty()))
174  {
177  aSource,
178  GetSdrObject().GetName(),
180  GetSdrObject().GetDescription()));
181 
183  }
184 
185  return aSource;
186 }
187 
188 }
189 
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetDescription() const
Definition: svdobj.cxx:786
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:766
size_t GetObjCount() const
Definition: svdpage.cxx:760
SdrTextAniKind GetTextAniKind() const
Definition: svdotext.cxx:1762
virtual drawinglayer::primitive2d::Primitive2DContainer createGluePointPrimitive2DSequence() const override
sal_uInt16 GetCount() const
Definition: svdglue.hxx:125
virtual ViewContact & GetViewContact(sal_uInt32 nIndex) const override
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:647
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:245
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:2198
#define DBG_ASSERT(sCon, aError)
uno_Any a
OUString GetTitle() const
Definition: svdobj.cxx:742
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:698
virtual ViewContact * GetParentContact() const override
css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference
virtual drawinglayer::primitive2d::Primitive2DContainer embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer aSource) const override
virtual sal_uInt32 GetObjectCount() const override
static BitmapEx createGluePointBitmap()
Definition: svdhdl.cxx:1073
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:299
virtual SdrObject * getSdrObjectFromSdrObjList() const
Definition: svdpage.cxx:145