1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVTOOLS_OPENFILEDROPTARGETLISTENER_HXX
21 #define INCLUDED_SVTOOLS_OPENFILEDROPTARGETLISTENER_HXX
23 #include <svtools/svtdllapi.h>
25 #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
26 #include <com/sun/star/frame/XFrame.hpp>
28 #include <cppuhelper/implbase1.hxx>
30 #include <sot/exchange.hxx>
32 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{
33 class XComponentContext
;
36 /** DropTargetListener that takes care of opening a file when it is dropped in the frame.
38 class SVT_DLLPUBLIC OpenFileDropTargetListener
: public ::cppu::WeakImplHelper1
< ::com::sun::star::datatransfer::dnd::XDropTargetListener
>
41 /// uno service manager to create necessary services
42 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
44 /// weakreference to target frame (Don't use a hard reference. Owner can't delete us then!)
45 css::uno::WeakReference
< css::frame::XFrame
> m_xTargetFrame
;
48 DataFlavorExVector
* m_pFormats
;
51 OpenFileDropTargetListener( const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
52 const css::uno::Reference
< css::frame::XFrame
>& xFrame
);
53 virtual ~OpenFileDropTargetListener();
57 virtual void SAL_CALL
disposing ( const css::lang::EventObject
& Source
) throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
59 // XDropTargetListener
60 virtual void SAL_CALL
drop ( const css::datatransfer::dnd::DropTargetDropEvent
& dtde
) throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
61 virtual void SAL_CALL
dragEnter ( const css::datatransfer::dnd::DropTargetDragEnterEvent
& dtdee
) throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
62 virtual void SAL_CALL
dragExit ( const css::datatransfer::dnd::DropTargetEvent
& dte
) throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
63 virtual void SAL_CALL
dragOver ( const css::datatransfer::dnd::DropTargetDragEvent
& dtde
) throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
64 virtual void SAL_CALL
dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent
& dtde
) throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
67 void implts_BeginDrag( const css::uno::Sequence
< css::datatransfer::DataFlavor
>& rSupportedDataFlavors
);
68 void implts_EndDrag();
69 bool implts_IsDropFormatSupported( SotClipboardFormatId nFormat
);
70 void implts_OpenFile( const OUString
& rFilePath
);
73 #endif // INCLUDED_SVTOOLS_OPENFILEDROPTARGETLISTENER_HXX
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */