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/objectcontactofpageview.hxx>
31 : : #include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
32 : : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
33 : : #include <svx/sdr/contact/displayinfo.hxx>
34 : : #include <svx/svdomedia.hxx>
35 : : #include <svx/svdpagv.hxx>
36 : : #include <vcl/outdev.hxx>
37 : : #include <vcl/window.hxx>
38 : : #include <avmedia/mediaitem.hxx>
39 : : #include "sdrmediawindow.hxx"
40 : : #include <svx/sdrpagewindow.hxx>
41 : : #include <svx/sdrpaintwindow.hxx>
42 : :
43 : : //////////////////////////////////////////////////////////////////////////////
44 : :
45 : : namespace sdr { namespace contact {
46 : :
47 : : // ----------------------------------
48 : : // - ViewObjectContactOfSdrMediaObj -
49 : : // ----------------------------------
50 : :
51 : 0 : ViewObjectContactOfSdrMediaObj::ViewObjectContactOfSdrMediaObj( ObjectContact& rObjectContact,
52 : : ViewContact& rViewContact,
53 : : const ::avmedia::MediaItem& rMediaItem ) :
54 : : ViewObjectContactOfSdrObj( rObjectContact, rViewContact ),
55 : 0 : mpMediaWindow( NULL )
56 : : {
57 : 0 : Window* pWindow = getWindow();
58 : :
59 [ # # ]: 0 : if( pWindow )
60 : : {
61 [ # # ][ # # ]: 0 : mpMediaWindow = new SdrMediaWindow( pWindow, *this );
62 [ # # ]: 0 : mpMediaWindow->hide();
63 [ # # ]: 0 : executeMediaItem( rMediaItem );
64 : : }
65 : 0 : }
66 : :
67 : : // ------------------------------------------------------------------------------
68 : :
69 : 0 : ViewObjectContactOfSdrMediaObj::~ViewObjectContactOfSdrMediaObj()
70 : : {
71 [ # # ][ # # ]: 0 : delete mpMediaWindow;
72 : 0 : mpMediaWindow = NULL;
73 [ # # ]: 0 : }
74 : :
75 : : // ------------------------------------------------------------------------------
76 : :
77 : 0 : Window* ViewObjectContactOfSdrMediaObj::getWindow() const
78 : : {
79 : 0 : Window* pRetval = 0;
80 : :
81 [ # # ]: 0 : const ObjectContactOfPageView* pObjectContactOfPageView = dynamic_cast< const ObjectContactOfPageView* >(&GetObjectContact());
82 : :
83 [ # # ]: 0 : if(pObjectContactOfPageView)
84 : : {
85 : 0 : const SdrPageWindow& rPageWindow = pObjectContactOfPageView->GetPageWindow();
86 : 0 : const SdrPaintWindow* pPaintWindow = &rPageWindow.GetPaintWindow();
87 : :
88 [ # # ]: 0 : if(rPageWindow.GetOriginalPaintWindow())
89 : : {
90 : : // #i83183# prefer OriginalPaintWindow if set; this is
91 : : // the real target device. GetPaintWindow() may return
92 : : // the current buffer device instead
93 : 0 : pPaintWindow = rPageWindow.GetOriginalPaintWindow();
94 : : }
95 : :
96 : 0 : OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
97 : :
98 [ # # ]: 0 : if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
99 : : {
100 : 0 : pRetval = static_cast< Window* >(&rOutDev);
101 : : }
102 : : }
103 : :
104 : 0 : return pRetval;
105 : : }
106 : :
107 : : // ------------------------------------------------------------------------------
108 : :
109 : 0 : Size ViewObjectContactOfSdrMediaObj::getPreferredSize() const
110 : : {
111 : 0 : Size aRet;
112 : :
113 [ # # ]: 0 : if( mpMediaWindow )
114 : 0 : aRet = mpMediaWindow->getPreferredSize();
115 : :
116 : 0 : return aRet;
117 : : }
118 : :
119 : : // ------------------------------------------------------------------------------
120 : :
121 : 0 : void ViewObjectContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const
122 : : {
123 [ # # ]: 0 : if( mpMediaWindow )
124 : : {
125 : 0 : mpMediaWindow->updateMediaItem( rItem );
126 : :
127 : : // show/hide is now dependent of play state
128 [ # # ]: 0 : if(avmedia::MEDIASTATE_STOP == rItem.getState())
129 : : {
130 : 0 : mpMediaWindow->hide();
131 : : }
132 : : else
133 : : {
134 [ # # ]: 0 : basegfx::B2DRange aViewRange(getObjectRange());
135 [ # # ][ # # ]: 0 : aViewRange.transform(GetObjectContact().getViewInformation2D().getViewTransformation());
136 : :
137 : : const Rectangle aViewRectangle(
138 [ # # ][ # # ]: 0 : (sal_Int32)floor(aViewRange.getMinX()), (sal_Int32)floor(aViewRange.getMinY()),
139 [ # # ][ # # ]: 0 : (sal_Int32)ceil(aViewRange.getMaxX()), (sal_Int32)ceil(aViewRange.getMaxY()));
[ # # ]
140 : :
141 [ # # ]: 0 : mpMediaWindow->setPosSize(aViewRectangle);
142 [ # # ]: 0 : mpMediaWindow->show();
143 : : }
144 : : }
145 : 0 : }
146 : :
147 : : // ------------------------------------------------------------------------------
148 : :
149 : 0 : void ViewObjectContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
150 : : {
151 [ # # ]: 0 : if( mpMediaWindow )
152 : : {
153 [ # # ]: 0 : ::avmedia::MediaItem aUpdatedItem;
154 : :
155 [ # # ]: 0 : mpMediaWindow->executeMediaItem( rItem );
156 : :
157 : : // query new properties after trying to set the new properties
158 [ # # ]: 0 : updateMediaItem( aUpdatedItem );
159 [ # # ][ # # ]: 0 : static_cast< ViewContactOfSdrMediaObj& >( GetViewContact() ).mediaPropertiesChanged( aUpdatedItem );
160 : : }
161 : 0 : }
162 : :
163 : : // ------------------------------------------------------------------------------
164 : :
165 : : }} // end of namespace sdr::contact
166 : :
167 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|