update dev300-m58
[ooovba.git] / svx / source / sdr / contact / sdrmediawindow.cxx
blobff3320f74ee074554ae7e5c3043a62f7eee0ab66
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrmediawindow.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include "sdrmediawindow.hxx"
35 #include <svtools/transfer.hxx>
37 #include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
38 #include <vcl/window.hxx>
40 namespace sdr { namespace contact {
42 // ------------------
43 // - SdrMediaWindow -
44 // ------------------
46 SdrMediaWindow::SdrMediaWindow( Window* pParent, ViewObjectContactOfSdrMediaObj& rViewObjContact ) :
47 ::avmedia::MediaWindow( pParent, false ),
48 mrViewObjectContactOfSdrMediaObj( rViewObjContact )
52 // ------------------------------------------------------------------------------
54 SdrMediaWindow::~SdrMediaWindow()
58 // ------------------------------------------------------------------------------
60 void SdrMediaWindow::MouseMove( const MouseEvent& rMEvt )
62 Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
64 if( pWindow && getWindow() )
66 const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
67 rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
69 pWindow->MouseMove( aTransformedEvent );
70 setPointer( pWindow->GetPointer() );
74 // ------------------------------------------------------------------------------
76 void SdrMediaWindow::MouseButtonDown( const MouseEvent& rMEvt )
78 Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
80 if( pWindow && getWindow() )
82 const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
83 rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
85 pWindow->MouseButtonDown( aTransformedEvent );
89 // ------------------------------------------------------------------------------
91 void SdrMediaWindow::MouseButtonUp( const MouseEvent& rMEvt )
93 Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
95 if( pWindow && getWindow() )
97 const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
98 rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
100 pWindow->MouseButtonUp( aTransformedEvent );
104 // ------------------------------------------------------------------------------
106 void SdrMediaWindow::KeyInput( const KeyEvent& rKEvt )
108 Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
110 if( pWindow )
111 pWindow->KeyInput( rKEvt );
114 // ------------------------------------------------------------------------------
116 void SdrMediaWindow::KeyUp( const KeyEvent& rKEvt )
118 Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
120 if( pWindow )
121 pWindow->KeyUp( rKEvt );
124 // ------------------------------------------------------------------------------
126 void SdrMediaWindow::Command( const CommandEvent& rCEvt )
128 Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
130 if( pWindow && getWindow() )
132 const CommandEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ),
133 rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() );
135 pWindow->Command( aTransformedEvent );
139 // ------------------------------------------------------------------------------
141 sal_Int8 SdrMediaWindow::AcceptDrop( const AcceptDropEvent& rEvt )
143 Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
144 sal_Int8 nRet = DND_ACTION_NONE;
146 if( pWindow )
148 DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
150 if( pDropTargetHelper )
152 nRet = pDropTargetHelper->AcceptDrop( rEvt );
156 return( nRet );
159 // ------------------------------------------------------------------------------
161 sal_Int8 SdrMediaWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
163 Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
164 sal_Int8 nRet = DND_ACTION_NONE;
166 if( pWindow )
168 DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
170 if( pDropTargetHelper )
172 nRet = pDropTargetHelper->ExecuteDrop( rEvt );
176 return( nRet );
179 // ------------------------------------------------------------------------------
181 void SdrMediaWindow::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
183 Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
185 if( pWindow )
187 DragSourceHelper* pDragSourceHelper = dynamic_cast< DragSourceHelper* >( pWindow );
189 if( pDragSourceHelper )
191 pDragSourceHelper->StartDrag( nAction, rPosPixel );