LibreOffice Module svx (master)
1
svx
source
sdr
contact
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
20
#include <
svx/sdr/contact/viewcontactofsdrobj.hxx
>
21
#include <
svx/sdr/contact/viewobjectcontactofsdrobj.hxx
>
22
#include <
svx/sdr/contact/viewobjectcontact.hxx
>
23
#include <
svx/svdobj.hxx
>
24
#include <
tools/debug.hxx
>
25
#include <
svx/svdpage.hxx
>
26
#include <
svx/sdr/contact/objectcontact.hxx
>
27
#include <
drawinglayer/primitive2d/markerarrayprimitive2d.hxx
>
28
#include <
drawinglayer/primitive2d/objectinfoprimitive2d.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.
35
ViewObjectContact
&
ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact
(
ObjectContact
& rObjectContact)
36
{
37
ViewObjectContact
* pRetval =
new
ViewObjectContactOfSdrObj
(rObjectContact, *
this
);
38
DBG_ASSERT
(pRetval,
"ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)"
);
39
40
return
*pRetval;
41
}
42
43
ViewContactOfSdrObj::ViewContactOfSdrObj
(
SdrObject
& rObj)
44
: mrObject(rObj)
45
{
46
}
47
48
ViewContactOfSdrObj::~ViewContactOfSdrObj
()
49
{
50
}
51
52
// Access to possible sub-hierarchy
53
sal_uInt32
ViewContactOfSdrObj::GetObjectCount
()
const
54
{
55
if
(
GetSdrObject
().GetSubList())
56
{
57
return
GetSdrObject
().
GetSubList
()->
GetObjCount
();
58
}
59
60
return
0;
61
}
62
63
ViewContact
&
ViewContactOfSdrObj::GetViewContact
(sal_uInt32 nIndex)
const
64
{
65
assert(
GetSdrObject
().GetSubList() &&
66
"ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)"
);
67
SdrObject
* pObj =
GetSdrObject
().
GetSubList
()->
GetObj
(
nIndex
);
68
assert(pObj &&
"ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)"
);
69
return
pObj->
GetViewContact
();
70
}
71
72
ViewContact
*
ViewContactOfSdrObj::GetParentContact
()
const
73
{
74
ViewContact
* pRetval =
nullptr
;
75
SdrObjList
* pObjList =
GetSdrObject
().
getParentSdrObjListFromSdrObject
();
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
98
void
ViewContactOfSdrObj::ActionChanged
()
99
{
100
// look for own changes
101
if
(
SdrTextObj
* pTextObj =
DynCastSdrTextObj
(&
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
108
ViewContact::ActionChanged
();
109
}
110
111
// override for accessing the SdrObject
112
SdrObject
*
ViewContactOfSdrObj::TryToGetSdrObject
()
const
113
{
114
return
&
GetSdrObject
();
115
}
116
117
118
// primitive stuff
119
120
// add Gluepoints (if available)
121
drawinglayer::primitive2d::Primitive2DContainer
ViewContactOfSdrObj::createGluePointPrimitive2DSequence
()
const
122
{
123
drawinglayer::primitive2d::Primitive2DContainer
xRetval;
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
{
146
const
drawinglayer::primitive2d::Primitive2DReference
xReference(
147
new
drawinglayer::primitive2d::MarkerArrayPrimitive2D
(
148
std::move(aGluepointVector),
SdrHdl::createGluePointBitmap
()));
149
xRetval =
drawinglayer::primitive2d::Primitive2DContainer
{ xReference };
150
}
151
}
152
}
153
154
return
xRetval;
155
}
156
157
drawinglayer::primitive2d::Primitive2DContainer
ViewContactOfSdrObj::embedToObjectSpecificInformation
(
drawinglayer::primitive2d::Primitive2DContainer
aSource)
const
158
{
159
if
(!aSource.empty() &&
160
(!
GetSdrObject
().
GetName
().isEmpty() ||
161
!
GetSdrObject
().
GetTitle
().isEmpty() ||
162
!
GetSdrObject
().
GetDescription
().isEmpty()))
163
{
164
const
drawinglayer::primitive2d::Primitive2DReference
xRef(
165
new
drawinglayer::primitive2d::ObjectInfoPrimitive2D
(
166
std::move(aSource),
167
GetSdrObject
().
GetName
(),
168
GetSdrObject
().
GetTitle
(),
169
GetSdrObject
().
GetDescription
()));
170
171
return
drawinglayer::primitive2d::Primitive2DContainer
{ xRef };
172
}
173
174
return
aSource;
175
}
176
177
}
178
179
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Point
SdrGluePointList
Definition:
svdglue.hxx:184
SdrGluePointList::GetCount
sal_uInt16 GetCount() const
Definition:
svdglue.hxx:194
SdrGluePoint
Definition:
svdglue.hxx:67
SdrGluePoint::GetAbsolutePos
Point GetAbsolutePos(const SdrObject &rObj) const
Definition:
svdglue.cxx:48
SdrHdl::createGluePointBitmap
static BitmapEx createGluePointBitmap()
Definition:
svdhdl.cxx:1075
SdrObjList
Definition:
svdpage.hxx:62
SdrObjList::GetObj
SdrObject * GetObj(size_t nNum) const
Definition:
svdpage.cxx:785
SdrObjList::GetObjCount
size_t GetObjCount() const
Definition:
svdpage.cxx:779
SdrObjList::getSdrObjectFromSdrObjList
virtual SdrObject * getSdrObjectFromSdrObjList() const
Definition:
svdpage.cxx:128
SdrObject
Abstract DrawObject.
Definition:
svdobj.hxx:260
SdrObject::GetSubList
virtual SdrObjList * GetSubList() const
Definition:
svdobj.cxx:717
SdrObject::getParentSdrObjListFromSdrObject
SdrObjList * getParentSdrObjListFromSdrObject() const
Definition:
svdobj.cxx:318
SdrObject::GetViewContact
sdr::contact::ViewContact & GetViewContact() const
Definition:
svdobj.cxx:261
SdrObject::GetGluePointList
virtual const SdrGluePointList * GetGluePointList() const
Definition:
svdobj.cxx:2312
SdrPage
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition:
svdpage.hxx:379
SdrTextObj
Definition:
svdotext.hxx:124
drawinglayer::primitive2d::MarkerArrayPrimitive2D
drawinglayer::primitive2d::ObjectInfoPrimitive2D
drawinglayer::primitive2d::Primitive2DContainer
rtl::Reference
sdr::contact::ObjectContact
Definition:
objectcontact.hxx:49
sdr::contact::ViewContactOfSdrObj::ViewContactOfSdrObj
ViewContactOfSdrObj(SdrObject &rObj)
Definition:
viewcontactofsdrobj.cxx:43
sdr::contact::ViewContactOfSdrObj::~ViewContactOfSdrObj
virtual ~ViewContactOfSdrObj() override
Definition:
viewcontactofsdrobj.cxx:48
sdr::contact::ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact
virtual ViewObjectContact & CreateObjectSpecificViewObjectContact(ObjectContact &rObjectContact) override
Definition:
viewcontactofsdrobj.cxx:35
sdr::contact::ViewContactOfSdrObj::TryToGetSdrObject
virtual SdrObject * TryToGetSdrObject() const override
override for accessing the SdrObject
Definition:
viewcontactofsdrobj.cxx:112
sdr::contact::ViewContactOfSdrObj::ActionChanged
virtual void ActionChanged() override
Definition:
viewcontactofsdrobj.cxx:98
sdr::contact::ViewContactOfSdrObj::GetViewContact
virtual ViewContact & GetViewContact(sal_uInt32 nIndex) const override
Definition:
viewcontactofsdrobj.cxx:63
sdr::contact::ViewContactOfSdrObj::createGluePointPrimitive2DSequence
virtual drawinglayer::primitive2d::Primitive2DContainer createGluePointPrimitive2DSequence() const override
Definition:
viewcontactofsdrobj.cxx:121
sdr::contact::ViewContactOfSdrObj::GetObjectCount
virtual sal_uInt32 GetObjectCount() const override
Definition:
viewcontactofsdrobj.cxx:53
sdr::contact::ViewContactOfSdrObj::GetSdrObject
SdrObject & GetSdrObject() const
Definition:
viewcontactofsdrobj.hxx:44
sdr::contact::ViewContactOfSdrObj::GetParentContact
virtual ViewContact * GetParentContact() const override
Definition:
viewcontactofsdrobj.cxx:72
sdr::contact::ViewContactOfSdrObj::embedToObjectSpecificInformation
virtual drawinglayer::primitive2d::Primitive2DContainer embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer aSource) const override
Definition:
viewcontactofsdrobj.cxx:157
sdr::contact::ViewContact
Definition:
viewcontact.hxx:37
sdr::contact::ViewContact::ActionChanged
virtual void ActionChanged()
Definition:
viewcontact.cxx:185
sdr::contact::ViewObjectContactOfSdrObj
Definition:
viewobjectcontactofsdrobj.hxx:32
sdr::contact::ViewObjectContact
Definition:
viewobjectcontact.hxx:42
nCount
int nCount
debug.hxx
DBG_ASSERT
#define DBG_ASSERT(sCon, aError)
GetName
virtual OUString GetName() const override
GetDescription
virtual void GetDescription(OUString &rName) override
nIndex
sal_Int32 nIndex
a
uno_Any a
markerarrayprimitive2d.hxx
sdr::contact
GetTitle
UNOTOOLS_DLLPUBLIC bool GetTitle(OUString const &url, OUString *title)
objectcontact.hxx
objectinfoprimitive2d.hxx
svdhdl.hxx
DynCastSdrTextObj
SdrTextObj * DynCastSdrTextObj(SdrObject *pObj)
Definition:
svdobj.cxx:3212
svdobj.hxx
svdpage.hxx
viewcontactofsdrobj.hxx
viewobjectcontact.hxx
viewobjectcontactofsdrobj.hxx
Generated on Sun Jul 30 2023 04:28:12 for LibreOffice Module svx (master) by
1.9.3