Line data Source code
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 <svx/sdr/contact/displayinfo.hxx>
25 : #include <vcl/outdev.hxx>
26 : #include <svx/svdoole2.hxx>
27 : #include <svx/svdpage.hxx>
28 : #include <svx/sdr/contact/objectcontact.hxx>
29 : #include <basegfx/color/bcolor.hxx>
30 : #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
31 : #include <svx/sdr/contact/objectcontactofpageview.hxx>
32 : #include <svx/sdrpagewindow.hxx>
33 : #include <svx/sdrpaintwindow.hxx>
34 : #include <svx/svdhdl.hxx>
35 :
36 : //////////////////////////////////////////////////////////////////////////////
37 :
38 : namespace sdr
39 : {
40 : namespace contact
41 : {
42 : // Create a Object-Specific ViewObjectContact, set ViewContact and
43 : // ObjectContact. Always needs to return something.
44 131 : ViewObjectContact& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
45 : {
46 131 : ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this);
47 : DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
48 :
49 131 : return *pRetval;
50 : }
51 :
52 5878 : ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject& rObj)
53 : : ViewContact(),
54 : mrObject(rObj),
55 5878 : meRememberedAnimationKind(SDRTEXTANI_NONE)
56 : {
57 : // init AnimationKind
58 5878 : if(GetSdrObject().ISA(SdrTextObj))
59 : {
60 4188 : SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
61 4188 : meRememberedAnimationKind = rTextObj.GetTextAniKind();
62 : }
63 5878 : }
64 :
65 5613 : ViewContactOfSdrObj::~ViewContactOfSdrObj()
66 : {
67 5613 : }
68 :
69 : // Access to possible sub-hierarchy
70 19194 : sal_uInt32 ViewContactOfSdrObj::GetObjectCount() const
71 : {
72 19194 : if(GetSdrObject().GetSubList())
73 : {
74 5074 : return GetSdrObject().GetSubList()->GetObjCount();
75 : }
76 :
77 14120 : return 0L;
78 : }
79 :
80 13198 : ViewContact& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex) const
81 : {
82 : DBG_ASSERT(GetSdrObject().GetSubList(),
83 : "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
84 13198 : SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
85 : DBG_ASSERT(pObj, "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
86 13198 : return pObj->GetViewContact();
87 : }
88 :
89 5535 : ViewContact* ViewContactOfSdrObj::GetParentContact() const
90 : {
91 5535 : ViewContact* pRetval = 0L;
92 5535 : SdrObjList* pObjList = GetSdrObject().GetObjList();
93 :
94 5535 : if(pObjList)
95 : {
96 5535 : if(pObjList->ISA(SdrPage))
97 : {
98 : // Is a page
99 1199 : pRetval = &(((SdrPage*)pObjList)->GetViewContact());
100 : }
101 : else
102 : {
103 : // Is a group?
104 4336 : if(pObjList->GetOwnerObj())
105 : {
106 4336 : pRetval = &(pObjList->GetOwnerObj()->GetViewContact());
107 : }
108 : }
109 : }
110 :
111 5535 : return pRetval;
112 : }
113 :
114 : // React on changes of the object of this ViewContact
115 53152 : void ViewContactOfSdrObj::ActionChanged()
116 : {
117 : // look for own changes
118 53152 : if(GetSdrObject().ISA(SdrTextObj))
119 : {
120 41692 : SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
121 :
122 41692 : if(rTextObj.GetTextAniKind() != meRememberedAnimationKind)
123 : {
124 : // #i38135# now remember new type
125 0 : meRememberedAnimationKind = rTextObj.GetTextAniKind();
126 : }
127 : }
128 :
129 : // call parent
130 53152 : ViewContact::ActionChanged();
131 53152 : }
132 :
133 : // overload for acessing the SdrObject
134 244 : SdrObject* ViewContactOfSdrObj::TryToGetSdrObject() const
135 : {
136 244 : return &GetSdrObject();
137 : }
138 :
139 : //////////////////////////////////////////////////////////////////////////////
140 : // primitive stuff
141 :
142 : // add Gluepoints (if available)
143 0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const
144 : {
145 0 : drawinglayer::primitive2d::Primitive2DSequence xRetval;
146 0 : const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
147 :
148 0 : if(pGluePointList)
149 : {
150 0 : const sal_uInt32 nCount(pGluePointList->GetCount());
151 :
152 0 : if(nCount)
153 : {
154 : // prepare point vector
155 0 : std::vector< basegfx::B2DPoint > aGluepointVector;
156 :
157 : // create GluePoint primitives. ATM these are relative to the SnapRect
158 0 : for(sal_uInt32 a(0L); a < nCount; a++)
159 : {
160 0 : const SdrGluePoint& rCandidate = (*pGluePointList)[(sal_uInt16)a];
161 0 : const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
162 :
163 0 : aGluepointVector.push_back(basegfx::B2DPoint(aPosition.X(), aPosition.Y()));
164 : }
165 :
166 0 : if(!aGluepointVector.empty())
167 : {
168 : const drawinglayer::primitive2d::Primitive2DReference xReference(
169 : new drawinglayer::primitive2d::MarkerArrayPrimitive2D(
170 0 : aGluepointVector, SdrHdl::createGluePointBitmap()));
171 0 : xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
172 0 : }
173 : }
174 : }
175 :
176 0 : return xRetval;
177 : }
178 : } // end of namespace contact
179 : } // end of namespace sdr
180 :
181 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|