1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrmediawindow.cxx,v $
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
{
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();
111 pWindow
->KeyInput( rKEvt
);
114 // ------------------------------------------------------------------------------
116 void SdrMediaWindow::KeyUp( const KeyEvent
& rKEvt
)
118 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
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
;
148 DropTargetHelper
* pDropTargetHelper
= dynamic_cast< DropTargetHelper
* >( pWindow
);
150 if( pDropTargetHelper
)
152 nRet
= pDropTargetHelper
->AcceptDrop( rEvt
);
159 // ------------------------------------------------------------------------------
161 sal_Int8
SdrMediaWindow::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
163 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
164 sal_Int8 nRet
= DND_ACTION_NONE
;
168 DropTargetHelper
* pDropTargetHelper
= dynamic_cast< DropTargetHelper
* >( pWindow
);
170 if( pDropTargetHelper
)
172 nRet
= pDropTargetHelper
->ExecuteDrop( rEvt
);
179 // ------------------------------------------------------------------------------
181 void SdrMediaWindow::StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
)
183 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
187 DragSourceHelper
* pDragSourceHelper
= dynamic_cast< DragSourceHelper
* >( pWindow
);
189 if( pDragSourceHelper
)
191 pDragSourceHelper
->StartDrag( nAction
, rPosPixel
);