1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*190118d0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*190118d0SAndrew Rist * distributed with this work for additional information
6*190118d0SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*190118d0SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist * with the License. You may obtain a copy of the License at
10*190118d0SAndrew Rist *
11*190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*190118d0SAndrew Rist *
13*190118d0SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist * software distributed under the License is distributed on an
15*190118d0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist * KIND, either express or implied. See the License for the
17*190118d0SAndrew Rist * specific language governing permissions and limitations
18*190118d0SAndrew Rist * under the License.
19*190118d0SAndrew Rist *
20*190118d0SAndrew Rist *************************************************************/
21*190118d0SAndrew Rist
22*190118d0SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <eeng_pch.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <eeobj.hxx>
31cdf0e10cSrcweir #include <sot/exchange.hxx>
32cdf0e10cSrcweir #include <sot/formats.hxx>
33cdf0e10cSrcweir #include <editeng/editeng.hxx>
34cdf0e10cSrcweir #include <svl/itempool.hxx>
35cdf0e10cSrcweir #include <vos/mutex.hxx>
36cdf0e10cSrcweir #include <vcl/svapp.hxx>
37cdf0e10cSrcweir using namespace ::com::sun::star;
38cdf0e10cSrcweir
39cdf0e10cSrcweir
EditDataObject()40cdf0e10cSrcweir EditDataObject::EditDataObject()
41cdf0e10cSrcweir {
42cdf0e10cSrcweir }
43cdf0e10cSrcweir
~EditDataObject()44cdf0e10cSrcweir EditDataObject::~EditDataObject()
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir
48cdf0e10cSrcweir // uno::XInterface
queryInterface(const uno::Type & rType)49cdf0e10cSrcweir uno::Any EditDataObject::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( datatransfer::XTransferable*, this ) );
52cdf0e10cSrcweir return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
53cdf0e10cSrcweir }
54cdf0e10cSrcweir
55cdf0e10cSrcweir // datatransfer::XTransferable
getTransferData(const datatransfer::DataFlavor & rFlavor)56cdf0e10cSrcweir uno::Any EditDataObject::getTransferData( const datatransfer::DataFlavor& rFlavor ) throw(datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir uno::Any aAny;
59cdf0e10cSrcweir
60cdf0e10cSrcweir sal_uLong nT = SotExchange::GetFormat( rFlavor );
61cdf0e10cSrcweir if ( nT == SOT_FORMAT_STRING )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir aAny <<= (::rtl::OUString)GetString();
64cdf0e10cSrcweir }
65cdf0e10cSrcweir else if ( ( nT == SOT_FORMATSTR_ID_EDITENGINE ) || ( nT == SOT_FORMAT_RTF ) )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir // MT 01/2002: No RTF on demand any more:
68cdf0e10cSrcweir // 1) Was not working, because I had to flush() the clipboard immediately anyway
69cdf0e10cSrcweir // 2) Don't have the old pool defaults and the StyleSheetPool here.
70cdf0e10cSrcweir
71cdf0e10cSrcweir SvMemoryStream* pStream = ( nT == SOT_FORMATSTR_ID_EDITENGINE ) ? &GetStream() : &GetRTFStream();
72cdf0e10cSrcweir pStream->Seek( STREAM_SEEK_TO_END );
73cdf0e10cSrcweir sal_uLong nLen = pStream->Tell();
74cdf0e10cSrcweir pStream->Seek(0);
75cdf0e10cSrcweir
76cdf0e10cSrcweir uno::Sequence< sal_Int8 > aSeq( nLen );
77cdf0e10cSrcweir memcpy( aSeq.getArray(), pStream->GetData(), nLen );
78cdf0e10cSrcweir aAny <<= aSeq;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir else
81cdf0e10cSrcweir {
82cdf0e10cSrcweir datatransfer::UnsupportedFlavorException aException;
83cdf0e10cSrcweir throw( aException );
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86cdf0e10cSrcweir return aAny;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
getTransferDataFlavors()89cdf0e10cSrcweir uno::Sequence< datatransfer::DataFlavor > EditDataObject::getTransferDataFlavors( ) throw(uno::RuntimeException)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir uno::Sequence< datatransfer::DataFlavor > aDataFlavors(3);
92cdf0e10cSrcweir SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_EDITENGINE, aDataFlavors.getArray()[0] );
93cdf0e10cSrcweir SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aDataFlavors.getArray()[1] );
94cdf0e10cSrcweir SotExchange::GetFormatDataFlavor( SOT_FORMAT_RTF, aDataFlavors.getArray()[2] );
95cdf0e10cSrcweir
96cdf0e10cSrcweir return aDataFlavors;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
isDataFlavorSupported(const datatransfer::DataFlavor & rFlavor)99cdf0e10cSrcweir sal_Bool EditDataObject::isDataFlavorSupported( const datatransfer::DataFlavor& rFlavor ) throw(uno::RuntimeException)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir sal_Bool bSupported = sal_False;
102cdf0e10cSrcweir
103cdf0e10cSrcweir sal_uLong nT = SotExchange::GetFormat( rFlavor );
104cdf0e10cSrcweir if ( ( nT == SOT_FORMAT_STRING ) || ( nT == SOT_FORMAT_RTF ) /* || ( nT == SOT_FORMAT_XML ) */ || ( nT == SOT_FORMATSTR_ID_EDITENGINE ) )
105cdf0e10cSrcweir bSupported = sal_True;
106cdf0e10cSrcweir
107cdf0e10cSrcweir return bSupported;
108cdf0e10cSrcweir }
109