LibreOffice Module svtools (master) 1
cliplistener.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
22
23#include <vcl/svapp.hxx>
24#include <vcl/window.hxx>
25
27#include <vcl/transfer.hxx>
28
29using namespace ::com::sun::star;
30
31
33 aLink( rCallback )
34{
35}
36
38{
39}
40
41void SAL_CALL TransferableClipboardListener::disposing( const lang::EventObject& )
42{
43}
44
46 const datatransfer::clipboard::ClipboardEvent& rEventObject )
47{
48 if ( aLink.IsSet() )
49 {
50 const SolarMutexGuard aGuard;
51
52 TransferableDataHelper aDataHelper( rEventObject.Contents );
53 aLink.Call( &aDataHelper );
54 }
55}
56
58{
59 try
60 {
61 if ( pWin )
62 {
63 uno::Reference<datatransfer::clipboard::XClipboard> xClipboard = pWin->GetClipboard();
64 uno::Reference<datatransfer::clipboard::XClipboardNotifier> xClpbrdNtfr( xClipboard, uno::UNO_QUERY );
65 if( xClpbrdNtfr.is() )
66 {
67 uno::Reference<datatransfer::clipboard::XClipboardListener> xClipEvtLstnr( this );
68 if( bAdd )
69 xClpbrdNtfr->addClipboardListener( xClipEvtLstnr );
70 else
71 xClpbrdNtfr->removeClipboardListener( xClipEvtLstnr );
72 }
73 }
74 }
75 catch( const css::uno::Exception& )
76 {
77 }
78}
79
81{
83}
84
85/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Link< TransferableDataHelper *, void > aLink
virtual void SAL_CALL changedContents(const css::datatransfer::clipboard::ClipboardEvent &event) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void AddRemoveListener(vcl::Window *pWin, bool bAdd)
TransferableClipboardListener(const Link< TransferableDataHelper *, void > &rCallback)
virtual ~TransferableClipboardListener() override
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard()