Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <vcl/wrkwin.hxx>
30 : : #include <vcl/dialog.hxx>
31 : : #include <vcl/msgbox.hxx>
32 : : #include <vcl/svapp.hxx>
33 : : #include <eeobj.hxx>
34 : : #include <sot/exchange.hxx>
35 : : #include <sot/formats.hxx>
36 : : #include <editeng/editeng.hxx>
37 : : #include <svl/itempool.hxx>
38 : : #include <osl/mutex.hxx>
39 : :
40 : : using namespace ::com::sun::star;
41 : :
42 : :
43 [ # # ][ # # ]: 0 : EditDataObject::EditDataObject()
[ # # ][ # # ]
44 : : {
45 : 0 : }
46 : :
47 [ # # ][ # # ]: 0 : EditDataObject::~EditDataObject()
[ # # ][ # # ]
[ # # ]
48 : : {
49 [ # # ]: 0 : }
50 : :
51 : : // uno::XInterface
52 : 0 : uno::Any EditDataObject::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
53 : : {
54 [ # # ]: 0 : uno::Any aRet = ::cppu::queryInterface( rType, (static_cast< datatransfer::XTransferable* >(this)) );
55 [ # # ][ # # ]: 0 : return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
56 : : }
57 : :
58 : : // datatransfer::XTransferable
59 : 0 : uno::Any EditDataObject::getTransferData( const datatransfer::DataFlavor& rFlavor ) throw(datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException)
60 : : {
61 : 0 : uno::Any aAny;
62 : :
63 [ # # ]: 0 : sal_uLong nT = SotExchange::GetFormat( rFlavor );
64 [ # # ]: 0 : if ( nT == SOT_FORMAT_STRING )
65 : : {
66 [ # # ][ # # ]: 0 : aAny <<= (::rtl::OUString)GetString();
67 : : }
68 [ # # ][ # # ]: 0 : else if ( ( nT == SOT_FORMATSTR_ID_EDITENGINE ) || ( nT == SOT_FORMAT_RTF ) )
69 : : {
70 : : // No RTF on demand any more:
71 : : // 1) Was not working, because I had to flush() the clipboard immediately anyway
72 : : // 2) Don't have the old pool defaults and the StyleSheetPool here.
73 : :
74 [ # # ]: 0 : SvMemoryStream* pStream = ( nT == SOT_FORMATSTR_ID_EDITENGINE ) ? &GetStream() : &GetRTFStream();
75 [ # # ]: 0 : pStream->Seek( STREAM_SEEK_TO_END );
76 : 0 : sal_uLong nLen = pStream->Tell();
77 [ # # ]: 0 : pStream->Seek(0);
78 : :
79 [ # # ]: 0 : uno::Sequence< sal_Int8 > aSeq( nLen );
80 [ # # ][ # # ]: 0 : memcpy( aSeq.getArray(), pStream->GetData(), nLen );
81 [ # # ][ # # ]: 0 : aAny <<= aSeq;
82 : : }
83 : : else
84 : : {
85 [ # # ]: 0 : datatransfer::UnsupportedFlavorException aException;
86 [ # # ]: 0 : throw( aException );
87 : : }
88 : :
89 : 0 : return aAny;
90 : : }
91 : :
92 : 0 : uno::Sequence< datatransfer::DataFlavor > EditDataObject::getTransferDataFlavors( ) throw(uno::RuntimeException)
93 : : {
94 : 0 : uno::Sequence< datatransfer::DataFlavor > aDataFlavors(3);
95 [ # # ][ # # ]: 0 : SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_EDITENGINE, aDataFlavors.getArray()[0] );
96 [ # # ][ # # ]: 0 : SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aDataFlavors.getArray()[1] );
97 [ # # ][ # # ]: 0 : SotExchange::GetFormatDataFlavor( SOT_FORMAT_RTF, aDataFlavors.getArray()[2] );
98 : :
99 : 0 : return aDataFlavors;
100 : : }
101 : :
102 : 0 : sal_Bool EditDataObject::isDataFlavorSupported( const datatransfer::DataFlavor& rFlavor ) throw(uno::RuntimeException)
103 : : {
104 : 0 : sal_Bool bSupported = sal_False;
105 : :
106 : 0 : sal_uLong nT = SotExchange::GetFormat( rFlavor );
107 [ # # ][ # # ]: 0 : if ( ( nT == SOT_FORMAT_STRING ) || ( nT == SOT_FORMAT_RTF ) || ( nT == SOT_FORMATSTR_ID_EDITENGINE ) )
[ # # ]
108 : 0 : bSupported = sal_True;
109 : :
110 : 0 : return bSupported;
111 : : }
112 : :
113 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|