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 :
21 : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
22 : #include <svx/svdomedia.hxx>
23 : #include <sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
24 : #include <drawinglayer/primitive2d/mediaprimitive2d.hxx>
25 : #include <avmedia/mediawindow.hxx>
26 :
27 : namespace sdr { namespace contact {
28 :
29 :
30 : // - ViewContactOfSdrMediaObj -
31 :
32 :
33 14 : ViewContactOfSdrMediaObj::ViewContactOfSdrMediaObj( SdrMediaObj& rMediaObj ) :
34 14 : ViewContactOfSdrObj( rMediaObj )
35 : {
36 14 : }
37 :
38 :
39 :
40 28 : ViewContactOfSdrMediaObj::~ViewContactOfSdrMediaObj()
41 : {
42 28 : }
43 :
44 :
45 :
46 0 : ViewObjectContact& ViewContactOfSdrMediaObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
47 : {
48 0 : return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) );
49 : }
50 :
51 :
52 :
53 0 : Size ViewContactOfSdrMediaObj::getPreferredSize() const
54 : {
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 0 : const sal_uInt32 nCount(getViewObjectContactCount());
58 :
59 0 : for(sal_uInt32 a(0); a < nCount; a++)
60 : {
61 0 : ViewObjectContact* pCandidate = getViewObjectContact(a);
62 0 : Size aSize(pCandidate ? static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->getPreferredSize() : Size());
63 :
64 0 : if(0 != aSize.getWidth() || 0 != aSize.getHeight())
65 : {
66 0 : return aSize;
67 : }
68 : }
69 :
70 0 : return Size();
71 : }
72 :
73 :
74 :
75 0 : void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const
76 : {
77 : // #i71805# Since we may have a whole bunch of VOCs here, make a loop
78 0 : const sal_uInt32 nCount(getViewObjectContactCount());
79 :
80 0 : for(sal_uInt32 a(0); a < nCount; a++)
81 : {
82 0 : ViewObjectContact* pCandidate = getViewObjectContact(a);
83 :
84 0 : if(pCandidate)
85 : {
86 0 : static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
87 : }
88 : }
89 0 : }
90 :
91 :
92 :
93 92 : void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
94 : {
95 92 : const sal_uInt32 nCount(getViewObjectContactCount());
96 :
97 92 : for(sal_uInt32 a(0); a < nCount; a++)
98 : {
99 0 : ViewObjectContact* pCandidate = getViewObjectContact(a);
100 :
101 0 : if(pCandidate)
102 : {
103 0 : static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(rItem);
104 : }
105 : }
106 92 : }
107 :
108 :
109 :
110 0 : void ViewContactOfSdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState )
111 : {
112 0 : static_cast< SdrMediaObj& >(GetSdrObject()).mediaPropertiesChanged(rNewState);
113 0 : }
114 :
115 : }} // end of namespace sdr::contact
116 :
117 : namespace sdr
118 : {
119 : namespace contact
120 : {
121 0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMediaObj::createViewIndependentPrimitive2DSequence() const
122 : {
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 0 : 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 0 : aRectangle += GetSdrMediaObj().GetGridOffset();
130 : const basegfx::B2DRange aRange(
131 0 : aRectangle.Left(), aRectangle.Top(),
132 0 : aRectangle.Right(), aRectangle.Bottom());
133 :
134 : // create object transform
135 0 : basegfx::B2DHomMatrix aTransform;
136 0 : aTransform.set(0, 0, aRange.getWidth());
137 0 : aTransform.set(1, 1, aRange.getHeight());
138 0 : aTransform.set(0, 2, aRange.getMinX());
139 0 : aTransform.set(1, 2, aRange.getMinY());
140 :
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 0 : const basegfx::BColor aBackgroundColor(67.0 / 255.0, 67.0 / 255.0, 67.0 / 255.0);
145 0 : const OUString& rURL(GetSdrMediaObj().getURL());
146 0 : const sal_uInt32 nPixelBorder(4L);
147 : const drawinglayer::primitive2d::Primitive2DReference xRetval(
148 : new drawinglayer::primitive2d::MediaPrimitive2D(
149 : aTransform, rURL, aBackgroundColor, nPixelBorder,
150 0 : GetSdrMediaObj().getSnapshot()));
151 :
152 0 : return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
153 : }
154 : } // end of namespace contact
155 651 : } // end of namespace sdr
156 :
157 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|