Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / svtools / openfiledroptargetlistener.hxx
blob49459f559acb7a80f12ca27bd9017ccdc81d6805
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <config_options.h>
23 #include <svtools/svtdllapi.h>
25 #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
27 #include <cppuhelper/implbase.hxx>
28 #include <cppuhelper/weakref.hxx>
30 #include <sot/exchange.hxx>
32 namespace com :: sun :: star :: frame { class XFrame; }
34 namespace com::sun::star::uno {
35 class XComponentContext;
38 /** DropTargetListener that takes care of opening a file when it is dropped in the frame.
40 class UNLESS_MERGELIBS(SVT_DLLPUBLIC) OpenFileDropTargetListener final : public cppu::WeakImplHelper< css::datatransfer::dnd::XDropTargetListener >
42 private:
43 /// uno service manager to create necessary services
44 css::uno::Reference< css::uno::XComponentContext > m_xContext;
46 /// weakreference to target frame (Don't use a hard reference. Owner can't delete us then!)
47 css::uno::WeakReference< css::frame::XFrame > m_xTargetFrame;
49 /// drag/drop info
50 DataFlavorExVector m_aFormats;
52 public:
53 OpenFileDropTargetListener( css::uno::Reference< css::uno::XComponentContext > xContext,
54 const css::uno::Reference< css::frame::XFrame >& xFrame );
55 virtual ~OpenFileDropTargetListener() override;
57 public:
58 // XEventListener
59 virtual void SAL_CALL disposing ( const css::lang::EventObject& Source ) override;
61 // XDropTargetListener
62 virtual void SAL_CALL drop ( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override;
63 virtual void SAL_CALL dragEnter ( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override;
64 virtual void SAL_CALL dragExit ( const css::datatransfer::dnd::DropTargetEvent& dte ) override;
65 virtual void SAL_CALL dragOver ( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
66 virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
68 private:
69 void implts_BeginDrag( const css::uno::Sequence< css::datatransfer::DataFlavor >& rSupportedDataFlavors );
70 void implts_EndDrag();
71 bool implts_IsDropFormatSupported( SotClipboardFormatId nFormat );
72 void implts_OpenFile( const OUString& rFilePath );
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */