Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
31 : : #include <svx/svdomedia.hxx>
32 : : #include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
33 : : #include <drawinglayer/primitive2d/mediaprimitive2d.hxx>
34 : : #include <avmedia/mediawindow.hxx>
35 : :
36 : : namespace sdr { namespace contact {
37 : :
38 : : // ----------------------------
39 : : // - ViewContactOfSdrMediaObj -
40 : : // ----------------------------
41 : :
42 : 0 : ViewContactOfSdrMediaObj::ViewContactOfSdrMediaObj( SdrMediaObj& rMediaObj ) :
43 : 0 : ViewContactOfSdrObj( rMediaObj )
44 : : {
45 : 0 : }
46 : :
47 : : // ------------------------------------------------------------------------------
48 : :
49 : 0 : ViewContactOfSdrMediaObj::~ViewContactOfSdrMediaObj()
50 : : {
51 [ # # ]: 0 : }
52 : :
53 : : // ------------------------------------------------------------------------------
54 : :
55 : 0 : ViewObjectContact& ViewContactOfSdrMediaObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
56 : : {
57 [ # # ]: 0 : return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) );
58 : : }
59 : :
60 : : // ------------------------------------------------------------------------------
61 : :
62 : 0 : Size ViewContactOfSdrMediaObj::getPreferredSize() const
63 : : {
64 : : // #i71805# Since we may have a whole bunch of VOCs here, make a loop
65 : : // return first useful size -> the size from the first which is visualized as a window
66 : 0 : const sal_uInt32 nCount(getViewObjectContactCount());
67 : :
68 [ # # ]: 0 : for(sal_uInt32 a(0); a < nCount; a++)
69 : : {
70 [ # # ]: 0 : ViewObjectContact* pCandidate = getViewObjectContact(a);
71 [ # # ][ # # ]: 0 : Size aSize(pCandidate ? static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->getPreferredSize() : Size());
72 : :
73 [ # # ][ # # ]: 0 : if(0 != aSize.getWidth() || 0 != aSize.getHeight())
[ # # ]
74 : : {
75 : 0 : return aSize;
76 : : }
77 : : }
78 : :
79 : 0 : return Size();
80 : : }
81 : :
82 : : // ------------------------------------------------------------------------------
83 : :
84 : 0 : void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const
85 : : {
86 : : // #i71805# Since we may have a whole bunch of VOCs here, make a loop
87 : 0 : const sal_uInt32 nCount(getViewObjectContactCount());
88 : :
89 [ # # ]: 0 : for(sal_uInt32 a(0); a < nCount; a++)
90 : : {
91 : 0 : ViewObjectContact* pCandidate = getViewObjectContact(a);
92 : :
93 [ # # ]: 0 : if(pCandidate)
94 : : {
95 : 0 : static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
96 : : }
97 : : }
98 : 0 : }
99 : :
100 : : // ------------------------------------------------------------------------------
101 : :
102 : 0 : void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
103 : : {
104 : 0 : const sal_uInt32 nCount(getViewObjectContactCount());
105 : :
106 [ # # ]: 0 : for(sal_uInt32 a(0); a < nCount; a++)
107 : : {
108 : 0 : ViewObjectContact* pCandidate = getViewObjectContact(a);
109 : :
110 [ # # ]: 0 : if(pCandidate)
111 : : {
112 : 0 : static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(rItem);
113 : : }
114 : : }
115 : 0 : }
116 : :
117 : : // ------------------------------------------------------------------------------
118 : :
119 : 0 : void ViewContactOfSdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState )
120 : : {
121 : 0 : static_cast< SdrMediaObj& >(GetSdrObject()).mediaPropertiesChanged(rNewState);
122 : 0 : }
123 : :
124 : : }} // end of namespace sdr::contact
125 : :
126 : : namespace sdr
127 : : {
128 : : namespace contact
129 : : {
130 : 0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMediaObj::createViewIndependentPrimitive2DSequence() const
131 : : {
132 : : // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
133 : : // GetGeoRect() to not trigger any calculations. It's the unrotated geometry which is okay for MediaObjects ATM.
134 : 0 : const Rectangle& rRectangle(GetSdrMediaObj().GetGeoRect());
135 : : const basegfx::B2DRange aRange(
136 : 0 : rRectangle.Left(), rRectangle.Top(),
137 [ # # ]: 0 : rRectangle.Right(), rRectangle.Bottom());
138 : :
139 : : // create object transform
140 [ # # ]: 0 : basegfx::B2DHomMatrix aTransform;
141 [ # # ][ # # ]: 0 : aTransform.set(0, 0, aRange.getWidth());
142 [ # # ][ # # ]: 0 : aTransform.set(1, 1, aRange.getHeight());
143 [ # # ][ # # ]: 0 : aTransform.set(0, 2, aRange.getMinX());
144 [ # # ][ # # ]: 0 : aTransform.set(1, 2, aRange.getMinY());
145 : :
146 : : // create media primitive. Always create primitives to allow the
147 : : // decomposition of MediaPrimitive2D to create needed invisible elements for HitTest
148 : : // and/or BoundRect
149 : 0 : const basegfx::BColor aBackgroundColor(67.0 / 255.0, 67.0 / 255.0, 67.0 / 255.0);
150 [ # # ]: 0 : const rtl::OUString& rURL(GetSdrMediaObj().getURL());
151 : 0 : const sal_uInt32 nPixelBorder(4L);
152 : : const drawinglayer::primitive2d::Primitive2DReference xRetval(
153 : : new drawinglayer::primitive2d::MediaPrimitive2D(
154 : : aTransform, rURL, aBackgroundColor, nPixelBorder,
155 [ # # ][ # # ]: 0 : avmedia::MediaWindow::grabFrame(rURL, true)));
[ # # ][ # # ]
[ # # ][ # # ]
156 : :
157 [ # # ][ # # ]: 0 : return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
158 : : }
159 : : } // end of namespace contact
160 : : } // end of namespace sdr
161 : :
162 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|