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 /** DropTargetListener that takes care of opening a file when it is dropped in the frame.
34 class SVT_DLLPUBLIC OpenFileDropTargetListener
: public ::cppu::WeakImplHelper1
< ::com::sun::star::datatransfer::dnd::XDropTargetListener
>
37 /// uno service manager to create necessary services
38 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
40 /// weakreference to target frame (Don't use a hard reference. Owner can't delete us then!)
41 css::uno::WeakReference
< css::frame::XFrame
> m_xTargetFrame
;
44 DataFlavorExVector
* m_pFormats
;
47 OpenFileDropTargetListener( const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
48 const css::uno::Reference
< css::frame::XFrame
>& xFrame
);
49 ~OpenFileDropTargetListener();
53 virtual void SAL_CALL
disposing ( const css::lang::EventObject
& Source
) throw(css::uno::RuntimeException
);
55 // XDropTargetListener
56 virtual void SAL_CALL
drop ( const css::datatransfer::dnd::DropTargetDropEvent
& dtde
) throw(css::uno::RuntimeException
);
57 virtual void SAL_CALL
dragEnter ( const css::datatransfer::dnd::DropTargetDragEnterEvent
& dtdee
) throw(css::uno::RuntimeException
);
58 virtual void SAL_CALL
dragExit ( const css::datatransfer::dnd::DropTargetEvent
& dte
) throw(css::uno::RuntimeException
);
59 virtual void SAL_CALL
dragOver ( const css::datatransfer::dnd::DropTargetDragEvent
& dtde
) throw(css::uno::RuntimeException
);
60 virtual void SAL_CALL
dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent
& dtde
) throw(css::uno::RuntimeException
);
63 void implts_BeginDrag( const css::uno::Sequence
< css::datatransfer::DataFlavor
>& rSupportedDataFlavors
);
64 void implts_EndDrag();
65 sal_Bool
implts_IsDropFormatSupported( SotFormatStringId nFormat
);
66 void implts_OpenFile( const OUString
& rFilePath
);
69 #endif // INCLUDED_SVTOOLS_OPENFILEDROPTARGETLISTENER_HXX
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */