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 : mrObject(rObj),
45  meRememberedAnimationKind(SdrTextAniKind::NONE)
46 {
47  // init AnimationKind
48  if(auto pTextObj = dynamic_cast<const SdrTextObj*>( &GetSdrObject() ))
49  {
50  meRememberedAnimationKind = pTextObj->GetTextAniKind();
51  }
52 }
53 
55 {
56 }
57 
58 // Access to possible sub-hierarchy
60 {
61  if(GetSdrObject().GetSubList())
62  {
63  return GetSdrObject().GetSubList()->GetObjCount();
64  }
65 
66  return 0;
67 }
68 
70 {
71  assert(GetSdrObject().GetSubList() &&
72  "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
73  SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
74  assert(pObj && "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
75  return pObj->GetViewContact();
76 }
77 
79 {
80  ViewContact* pRetval = nullptr;
82 
83  if(pObjList)
84  {
85  if(auto pPage = dynamic_cast<SdrPage*>( pObjList))
86  {
87  // Is a page
88  pRetval = &(pPage->GetViewContact());
89  }
90  else
91  {
92  // Is a group?
93  if(pObjList->getSdrObjectFromSdrObjList())
94  {
95  pRetval = &(pObjList->getSdrObjectFromSdrObjList()->GetViewContact());
96  }
97  }
98  }
99 
100  return pRetval;
101 }
102 
103 // React on changes of the object of this ViewContact
105 {
106  // look for own changes
107  if (SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(&GetSdrObject()))
108  {
109  if (pTextObj->GetTextAniKind() != meRememberedAnimationKind)
110  {
111  // #i38135# now remember new type
112  meRememberedAnimationKind = pTextObj->GetTextAniKind();
113  }
114  }
115 
116  // call parent
118 }
119 
120 // override for accessing the SdrObject
122 {
123  return &GetSdrObject();
124 }
125 
126 
127 // primitive stuff
128 
129 // add Gluepoints (if available)
131 {
133  const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
134 
135  if(pGluePointList)
136  {
137  const sal_uInt32 nCount(pGluePointList->GetCount());
138 
139  if(nCount)
140  {
141  // prepare point vector
142  std::vector< basegfx::B2DPoint > aGluepointVector;
143 
144  // create GluePoint primitives. ATM these are relative to the SnapRect
145  for(sal_uInt32 a(0); a < nCount; a++)
146  {
147  const SdrGluePoint& rCandidate = (*pGluePointList)[static_cast<sal_uInt16>(a)];
148  const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
149 
150  aGluepointVector.emplace_back(aPosition.X(), aPosition.Y());
151  }
152 
153  if(!aGluepointVector.empty())
154  {
157  aGluepointVector, SdrHdl::createGluePointBitmap()));
158  xRetval = drawinglayer::primitive2d::Primitive2DContainer{ xReference };
159  }
160  }
161  }
162 
163  return xRetval;
164 }
165 
167 {
168  if(!aSource.empty() &&
169  (!GetSdrObject().GetName().isEmpty() ||
170  !GetSdrObject().GetTitle().isEmpty() ||
171  !GetSdrObject().GetDescription().isEmpty()))
172  {
175  std::move(aSource),
176  GetSdrObject().GetName(),
178  GetSdrObject().GetDescription()));
179 
181  }
182 
183  return aSource;
184 }
185 
186 }
187 
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetDescription() const
Definition: svdobj.cxx:890
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:822
size_t GetObjCount() const
Definition: svdpage.cxx:816
virtual drawinglayer::primitive2d::Primitive2DContainer createGluePointPrimitive2DSequence() const override
sal_uInt16 GetCount() const
Definition: svdglue.hxx:196
virtual ViewContact & GetViewContact(sal_uInt32 nIndex) const override
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:748
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:251
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:2288
#define DBG_ASSERT(sCon, aError)
uno_Any a
OUString GetTitle() const
Definition: svdobj.cxx:846
Abstract DrawObject.
Definition: svdobj.hxx:259
virtual void ActionChanged()
Point GetAbsolutePos(const SdrObject &rObj) const
Definition: svdglue.cxx:48
OUString GetName() const
Definition: svdobj.cxx:802
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
SdrObjList * getParentSdrObjListFromSdrObject() const
Definition: svdobj.cxx:305
virtual SdrObject * getSdrObjectFromSdrObjList() const
Definition: svdpage.cxx:128