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
31namespace 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{
46}
47
49{
50}
51
52// Access to possible sub-hierarchy
54{
55 if(GetSdrObject().GetSubList())
56 {
58 }
59
60 return 0;
61}
62
64{
65 assert(GetSdrObject().GetSubList() &&
66 "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
68 assert(pObj && "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
69 return pObj->GetViewContact();
70}
71
73{
74 ViewContact* pRetval = nullptr;
76
77 if(pObjList)
78 {
79 if(auto pPage = dynamic_cast<SdrPage*>( pObjList))
80 {
81 // Is a page
82 pRetval = &(pPage->GetViewContact());
83 }
84 else
85 {
86 // Is a group?
87 if(pObjList->getSdrObjectFromSdrObjList())
88 {
89 pRetval = &(pObjList->getSdrObjectFromSdrObjList()->GetViewContact());
90 }
91 }
92 }
93
94 return pRetval;
95}
96
97// React on changes of the object of this ViewContact
99{
100 // look for own changes
101 if (SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(&GetSdrObject()))
102 {
103 // tdf#146860 no idea why, but calling this makes the text boxes render properly
104 pTextObj->GetTextAniKind();
105 }
106
107 // call parent
109}
110
111// override for accessing the SdrObject
113{
114 return &GetSdrObject();
115}
116
117
118// primitive stuff
119
120// add Gluepoints (if available)
122{
124 const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
125
126 if(pGluePointList)
127 {
128 const sal_uInt32 nCount(pGluePointList->GetCount());
129
130 if(nCount)
131 {
132 // prepare point vector
133 std::vector< basegfx::B2DPoint > aGluepointVector;
134
135 // create GluePoint primitives. ATM these are relative to the SnapRect
136 for(sal_uInt32 a(0); a < nCount; a++)
137 {
138 const SdrGluePoint& rCandidate = (*pGluePointList)[static_cast<sal_uInt16>(a)];
139 const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
140
141 aGluepointVector.emplace_back(aPosition.X(), aPosition.Y());
142 }
143
144 if(!aGluepointVector.empty())
145 {
148 std::move(aGluepointVector), SdrHdl::createGluePointBitmap()));
150 }
151 }
152 }
153
154 return xRetval;
155}
156
158{
159 if(!aSource.empty() &&
160 (!GetSdrObject().GetName().isEmpty() ||
161 !GetSdrObject().GetTitle().isEmpty() ||
162 !GetSdrObject().GetDescription().isEmpty()))
163 {
166 std::move(aSource),
170
172 }
173
174 return aSource;
175}
176
177}
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 GetCount() const
Definition: svdglue.hxx:194
Point GetAbsolutePos(const SdrObject &rObj) const
Definition: svdglue.cxx:48
static BitmapEx createGluePointBitmap()
Definition: svdhdl.cxx:1075
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:822
size_t GetObjCount() const
Definition: svdpage.cxx:816
virtual SdrObject * getSdrObjectFromSdrObjList() const
Definition: svdpage.cxx:128
Abstract DrawObject.
Definition: svdobj.hxx:257
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:710
SdrObjList * getParentSdrObjListFromSdrObject() const
Definition: svdobj.cxx:313
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:256
virtual const SdrGluePointList * GetGluePointList() const
Definition: svdobj.cxx:2310
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:377
virtual ViewObjectContact & CreateObjectSpecificViewObjectContact(ObjectContact &rObjectContact) override
virtual SdrObject * TryToGetSdrObject() const override
override for accessing the SdrObject
virtual ViewContact & GetViewContact(sal_uInt32 nIndex) const override
virtual drawinglayer::primitive2d::Primitive2DContainer createGluePointPrimitive2DSequence() const override
virtual sal_uInt32 GetObjectCount() const override
virtual ViewContact * GetParentContact() const override
virtual drawinglayer::primitive2d::Primitive2DContainer embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer aSource) const override
virtual void ActionChanged()
int nCount
#define DBG_ASSERT(sCon, aError)
virtual OUString GetName() const override
virtual void GetDescription(OUString &rName) override
sal_Int32 nIndex
uno_Any a
UNOTOOLS_DLLPUBLIC bool GetTitle(OUString const &url, OUString *title)