1f6e50924SAndrew Rist /**************************************************************
2*672a9062Smseidel *
3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5f6e50924SAndrew Rist * distributed with this work for additional information
6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10*672a9062Smseidel *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*672a9062Smseidel *
13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist * software distributed under the License is distributed on an
15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17f6e50924SAndrew Rist * specific language governing permissions and limitations
18f6e50924SAndrew Rist * under the License.
19*672a9062Smseidel *
20f6e50924SAndrew Rist *************************************************************/
21f6e50924SAndrew Rist
22f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
28cdf0e10cSrcweir #include <svx/svdomedia.hxx>
29cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
30cdf0e10cSrcweir #include <drawinglayer/primitive2d/mediaprimitive2d.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir namespace sdr { namespace contact {
33cdf0e10cSrcweir
34cdf0e10cSrcweir // ----------------------------
35cdf0e10cSrcweir // - ViewContactOfSdrMediaObj -
36cdf0e10cSrcweir // ----------------------------
37cdf0e10cSrcweir
ViewContactOfSdrMediaObj(SdrMediaObj & rMediaObj)38cdf0e10cSrcweir ViewContactOfSdrMediaObj::ViewContactOfSdrMediaObj( SdrMediaObj& rMediaObj ) :
39cdf0e10cSrcweir ViewContactOfSdrObj( rMediaObj )
40cdf0e10cSrcweir {
41cdf0e10cSrcweir }
42cdf0e10cSrcweir
43cdf0e10cSrcweir // ------------------------------------------------------------------------------
44cdf0e10cSrcweir
~ViewContactOfSdrMediaObj()45cdf0e10cSrcweir ViewContactOfSdrMediaObj::~ViewContactOfSdrMediaObj()
46cdf0e10cSrcweir {
47cdf0e10cSrcweir }
48cdf0e10cSrcweir
49cdf0e10cSrcweir // ------------------------------------------------------------------------------
50cdf0e10cSrcweir
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)51cdf0e10cSrcweir ViewObjectContact& ViewContactOfSdrMediaObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
52cdf0e10cSrcweir {
53cdf0e10cSrcweir return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) );
54cdf0e10cSrcweir }
55cdf0e10cSrcweir
56cdf0e10cSrcweir // ------------------------------------------------------------------------------
57cdf0e10cSrcweir
hasPreferredSize() const58cdf0e10cSrcweir bool ViewContactOfSdrMediaObj::hasPreferredSize() const
59cdf0e10cSrcweir {
60cdf0e10cSrcweir // #i71805# Since we may have a whole bunch of VOCs here, make a loop
61cdf0e10cSrcweir // return true if all have their preferred size
62cdf0e10cSrcweir const sal_uInt32 nCount(getViewObjectContactCount());
63cdf0e10cSrcweir bool bRetval(true);
64cdf0e10cSrcweir
65cdf0e10cSrcweir for(sal_uInt32 a(0); bRetval && a < nCount; a++)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir ViewObjectContact* pCandidate = getViewObjectContact(a);
68cdf0e10cSrcweir
69cdf0e10cSrcweir if(pCandidate && !static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->hasPreferredSize())
70cdf0e10cSrcweir {
71cdf0e10cSrcweir bRetval = false;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir return bRetval;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir // ------------------------------------------------------------------------------
79cdf0e10cSrcweir
getPreferredSize() const80cdf0e10cSrcweir Size ViewContactOfSdrMediaObj::getPreferredSize() const
81cdf0e10cSrcweir {
82cdf0e10cSrcweir // #i71805# Since we may have a whole bunch of VOCs here, make a loop
83cdf0e10cSrcweir // return first useful size -> the size from the first which is visualized as a window
84cdf0e10cSrcweir const sal_uInt32 nCount(getViewObjectContactCount());
85cdf0e10cSrcweir
86cdf0e10cSrcweir for(sal_uInt32 a(0); a < nCount; a++)
87cdf0e10cSrcweir {
88cdf0e10cSrcweir ViewObjectContact* pCandidate = getViewObjectContact(a);
89cdf0e10cSrcweir Size aSize(pCandidate ? static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->getPreferredSize() : Size());
90*672a9062Smseidel
91cdf0e10cSrcweir if(0 != aSize.getWidth() || 0 != aSize.getHeight())
92cdf0e10cSrcweir {
93cdf0e10cSrcweir return aSize;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
97cdf0e10cSrcweir return Size();
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
100cdf0e10cSrcweir // ------------------------------------------------------------------------------
101*672a9062Smseidel
updateMediaItem(::avmedia::MediaItem & rItem) const102cdf0e10cSrcweir void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const
103cdf0e10cSrcweir {
104cdf0e10cSrcweir // #i71805# Since we may have a whole bunch of VOCs here, make a loop
105cdf0e10cSrcweir const sal_uInt32 nCount(getViewObjectContactCount());
106cdf0e10cSrcweir
107cdf0e10cSrcweir for(sal_uInt32 a(0); a < nCount; a++)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir ViewObjectContact* pCandidate = getViewObjectContact(a);
110cdf0e10cSrcweir
111cdf0e10cSrcweir if(pCandidate)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
114cdf0e10cSrcweir }
115cdf0e10cSrcweir }
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
118cdf0e10cSrcweir // ------------------------------------------------------------------------------
119*672a9062Smseidel
executeMediaItem(const::avmedia::MediaItem & rItem)120cdf0e10cSrcweir void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir const sal_uInt32 nCount(getViewObjectContactCount());
123cdf0e10cSrcweir
124cdf0e10cSrcweir for(sal_uInt32 a(0); a < nCount; a++)
125cdf0e10cSrcweir {
126cdf0e10cSrcweir ViewObjectContact* pCandidate = getViewObjectContact(a);
127cdf0e10cSrcweir
128cdf0e10cSrcweir if(pCandidate)
129cdf0e10cSrcweir {
130cdf0e10cSrcweir static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(rItem);
131cdf0e10cSrcweir }
132cdf0e10cSrcweir }
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir // ------------------------------------------------------------------------------
136cdf0e10cSrcweir
mediaPropertiesChanged(const::avmedia::MediaItem & rNewState)137cdf0e10cSrcweir void ViewContactOfSdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir static_cast< SdrMediaObj& >(GetSdrObject()).mediaPropertiesChanged(rNewState);
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
142cdf0e10cSrcweir }} // end of namespace sdr::contact
143cdf0e10cSrcweir
144cdf0e10cSrcweir namespace sdr
145cdf0e10cSrcweir {
146cdf0e10cSrcweir namespace contact
147cdf0e10cSrcweir {
createViewIndependentPrimitive2DSequence() const148cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMediaObj::createViewIndependentPrimitive2DSequence() const
149cdf0e10cSrcweir {
150cdf0e10cSrcweir // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
151*672a9062Smseidel // GetGeoRect() to not trigger any calculations. It's the unrotated geometry which is okay for MediaObjects ATM.
152cdf0e10cSrcweir const Rectangle& rRectangle(GetSdrMediaObj().GetGeoRect());
153cdf0e10cSrcweir const basegfx::B2DRange aRange(
154*672a9062Smseidel rRectangle.Left(), rRectangle.Top(),
155*672a9062Smseidel rRectangle.Right(), rRectangle.Bottom());
156cdf0e10cSrcweir
157cdf0e10cSrcweir // create object transform
158cdf0e10cSrcweir basegfx::B2DHomMatrix aTransform;
159cdf0e10cSrcweir aTransform.set(0, 0, aRange.getWidth());
160cdf0e10cSrcweir aTransform.set(1, 1, aRange.getHeight());
161cdf0e10cSrcweir aTransform.set(0, 2, aRange.getMinX());
162cdf0e10cSrcweir aTransform.set(1, 2, aRange.getMinY());
163cdf0e10cSrcweir
164*672a9062Smseidel // create media primitive. Always create primitives to allow the
165cdf0e10cSrcweir // decomposition of MediaPrimitive2D to create needed invisible elements for HitTest
166cdf0e10cSrcweir // and/or BoundRect
167cdf0e10cSrcweir const basegfx::BColor aBackgroundColor(67.0 / 255.0, 67.0 / 255.0, 67.0 / 255.0);
168cdf0e10cSrcweir const rtl::OUString& rURL(GetSdrMediaObj().getURL());
169cdf0e10cSrcweir const sal_uInt32 nPixelBorder(4L);
170cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xRetval(
171*672a9062Smseidel new drawinglayer::primitive2d::MediaPrimitive2D(
172*672a9062Smseidel aTransform, rURL, aBackgroundColor, nPixelBorder));
173cdf0e10cSrcweir
174cdf0e10cSrcweir return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
175cdf0e10cSrcweir }
176cdf0e10cSrcweir } // end of namespace contact
177cdf0e10cSrcweir } // end of namespace sdr
178cdf0e10cSrcweir
179cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
180cdf0e10cSrcweir // eof
181