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(auto pTextObj = dynamic_cast<const SdrTextObj*>( &GetSdrObject() ))
50  {
51  meRememberedAnimationKind = pTextObj->GetTextAniKind();
52  }
53 }
54 
56 {
57 }
58 
59 // Access to possible sub-hierarchy
61 {
62  if(GetSdrObject().GetSubList())
63  {
64  return GetSdrObject().GetSubList()->GetObjCount();
65  }
66 
67  return 0;
68 }
69 
71 {
72  assert(GetSdrObject().GetSubList() &&
73  "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
74  SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
75  assert(pObj && "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
76  return pObj->GetViewContact();
77 }
78 
80 {
81  ViewContact* pRetval = nullptr;
83 
84  if(pObjList)
85  {
86  if(auto pPage = dynamic_cast<SdrPage*>( pObjList))
87  {
88  // Is a page
89  pRetval = &(pPage->GetViewContact());
90  }
91  else
92  {
93  // Is a group?
94  if(pObjList->getSdrObjectFromSdrObjList())
95  {
96  pRetval = &(pObjList->getSdrObjectFromSdrObjList()->GetViewContact());
97  }
98  }
99  }
100 
101  return pRetval;
102 }
103 
104 // React on changes of the object of this ViewContact
106 {
107  // look for own changes
108  if (SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(&GetSdrObject()))
109  {
110  if (pTextObj->GetTextAniKind() != meRememberedAnimationKind)
111  {
112  // #i38135# now remember new type
113  meRememberedAnimationKind = pTextObj->GetTextAniKind();
114  }
115  }
116 
117  // call parent
119 }
120 
121 // override for accessing the SdrObject
123 {
124  return &GetSdrObject();
125 }
126 
127 
128 // primitive stuff
129 
130 // add Gluepoints (if available)
132 {
134  const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
135 
136  if(pGluePointList)
137  {
138  const sal_uInt32 nCount(pGluePointList->GetCount());
139 
140  if(nCount)
141  {
142  // prepare point vector
143  std::vector< basegfx::B2DPoint > aGluepointVector;
144 
145  // create GluePoint primitives. ATM these are relative to the SnapRect
146  for(sal_uInt32 a(0); a < nCount; a++)
147  {
148  const SdrGluePoint& rCandidate = (*pGluePointList)[static_cast<sal_uInt16>(a)];
149  const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
150 
151  aGluepointVector.emplace_back(aPosition.X(), aPosition.Y());
152  }
153 
154  if(!aGluepointVector.empty())
155  {
158  aGluepointVector, SdrHdl::createGluePointBitmap()));
159  xRetval = drawinglayer::primitive2d::Primitive2DContainer{ xReference };
160  }
161  }
162  }
163 
164  return xRetval;
165 }
166 
168 {
169  if(!aSource.empty() &&
170  (!GetSdrObject().GetName().isEmpty() ||
171  !GetSdrObject().GetTitle().isEmpty() ||
172  !GetSdrObject().GetDescription().isEmpty()))
173  {
176  aSource,
177  GetSdrObject().GetName(),
179  GetSdrObject().GetDescription()));
180 
182  }
183 
184  return aSource;
185 }
186 
187 }
188 
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetDescription() const
Definition: svdobj.cxx:786
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:758
size_t GetObjCount() const
Definition: svdpage.cxx:752
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)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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:2204
#define DBG_ASSERT(sCon, aError)
uno_Any a
OUString GetTitle() const
Definition: svdobj.cxx:742
Abstract DrawObject.
Definition: svdobj.hxx:260
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:1072
SdrObjList * getParentSdrObjListFromSdrObject() const
Definition: svdobj.cxx:299
virtual SdrObject * getSdrObjectFromSdrObjList() const
Definition: svdpage.cxx:137