fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / sdr / contact / viewcontactofsdrmediaobj.cxx
blob8aa9abe902887b203ab566b4d22a28b855479b25
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
22 #include <svx/svdomedia.hxx>
23 #include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
24 #include <drawinglayer/primitive2d/mediaprimitive2d.hxx>
25 #include <avmedia/mediawindow.hxx>
27 namespace sdr { namespace contact {
29 // ----------------------------
30 // - ViewContactOfSdrMediaObj -
31 // ----------------------------
33 ViewContactOfSdrMediaObj::ViewContactOfSdrMediaObj( SdrMediaObj& rMediaObj ) :
34 ViewContactOfSdrObj( rMediaObj )
38 // ------------------------------------------------------------------------------
40 ViewContactOfSdrMediaObj::~ViewContactOfSdrMediaObj()
44 // ------------------------------------------------------------------------------
46 ViewObjectContact& ViewContactOfSdrMediaObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
48 return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) );
51 // ------------------------------------------------------------------------------
53 Size ViewContactOfSdrMediaObj::getPreferredSize() const
55 // #i71805# Since we may have a whole bunch of VOCs here, make a loop
56 // return first useful size -> the size from the first which is visualized as a window
57 const sal_uInt32 nCount(getViewObjectContactCount());
59 for(sal_uInt32 a(0); a < nCount; a++)
61 ViewObjectContact* pCandidate = getViewObjectContact(a);
62 Size aSize(pCandidate ? static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->getPreferredSize() : Size());
64 if(0 != aSize.getWidth() || 0 != aSize.getHeight())
66 return aSize;
70 return Size();
73 // ------------------------------------------------------------------------------
75 void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const
77 // #i71805# Since we may have a whole bunch of VOCs here, make a loop
78 const sal_uInt32 nCount(getViewObjectContactCount());
80 for(sal_uInt32 a(0); a < nCount; a++)
82 ViewObjectContact* pCandidate = getViewObjectContact(a);
84 if(pCandidate)
86 static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
91 // ------------------------------------------------------------------------------
93 void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
95 const sal_uInt32 nCount(getViewObjectContactCount());
97 for(sal_uInt32 a(0); a < nCount; a++)
99 ViewObjectContact* pCandidate = getViewObjectContact(a);
101 if(pCandidate)
103 static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(rItem);
108 // ------------------------------------------------------------------------------
110 void ViewContactOfSdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState )
112 static_cast< SdrMediaObj& >(GetSdrObject()).mediaPropertiesChanged(rNewState);
115 }} // end of namespace sdr::contact
117 namespace sdr
119 namespace contact
121 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMediaObj::createViewIndependentPrimitive2DSequence() const
123 // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
124 // GetGeoRect() to not trigger any calculations. It's the unrotated geometry which is okay for MediaObjects ATM.
125 Rectangle aRectangle(GetSdrMediaObj().GetGeoRect());
126 // Hack for calc, transform position of object according
127 // to current zoom so as objects relative position to grid
128 // appears stable
129 aRectangle += GetSdrMediaObj().GetGridOffset();
130 const basegfx::B2DRange aRange(
131 aRectangle.Left(), aRectangle.Top(),
132 aRectangle.Right(), aRectangle.Bottom());
134 // create object transform
135 basegfx::B2DHomMatrix aTransform;
136 aTransform.set(0, 0, aRange.getWidth());
137 aTransform.set(1, 1, aRange.getHeight());
138 aTransform.set(0, 2, aRange.getMinX());
139 aTransform.set(1, 2, aRange.getMinY());
141 // create media primitive. Always create primitives to allow the
142 // decomposition of MediaPrimitive2D to create needed invisible elements for HitTest
143 // and/or BoundRect
144 const basegfx::BColor aBackgroundColor(67.0 / 255.0, 67.0 / 255.0, 67.0 / 255.0);
145 const OUString& rURL(GetSdrMediaObj().getURL());
146 const sal_uInt32 nPixelBorder(4L);
147 const drawinglayer::primitive2d::Primitive2DReference xRetval(
148 new drawinglayer::primitive2d::MediaPrimitive2D(
149 aTransform, rURL, aBackgroundColor, nPixelBorder,
150 GetSdrMediaObj().getSnapshot()));
152 return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
154 } // end of namespace contact
155 } // end of namespace sdr
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */