1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: eeobj.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
35 #include <eeng_pch.hxx>
38 #include <sot/exchange.hxx>
39 #include <sot/formats.hxx>
40 #include <svx/editeng.hxx>
41 #include <svtools/itempool.hxx>
42 #include <vos/mutex.hxx>
43 #include <vcl/svapp.hxx>
44 using namespace ::com::sun::star
;
47 EditDataObject::EditDataObject()
51 EditDataObject::~EditDataObject()
56 uno::Any
EditDataObject::queryInterface( const uno::Type
& rType
) throw(uno::RuntimeException
)
58 uno::Any aRet
= ::cppu::queryInterface( rType
, SAL_STATIC_CAST( datatransfer::XTransferable
*, this ) );
59 return (aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
));
62 // datatransfer::XTransferable
63 uno::Any
EditDataObject::getTransferData( const datatransfer::DataFlavor
& rFlavor
) throw(datatransfer::UnsupportedFlavorException
, io::IOException
, uno::RuntimeException
)
67 ULONG nT
= SotExchange::GetFormat( rFlavor
);
68 if ( nT
== SOT_FORMAT_STRING
)
70 aAny
<<= (::rtl::OUString
)GetString();
72 else if ( ( nT
== SOT_FORMATSTR_ID_EDITENGINE
) || ( nT
== SOT_FORMAT_RTF
) )
74 // MT 01/2002: No RTF on demand any more:
75 // 1) Was not working, because I had to flush() the clipboard immediately anyway
76 // 2) Don't have the old pool defaults and the StyleSheetPool here.
78 SvMemoryStream
* pStream
= ( nT
== SOT_FORMATSTR_ID_EDITENGINE
) ? &GetStream() : &GetRTFStream();
79 pStream
->Seek( STREAM_SEEK_TO_END
);
80 ULONG nLen
= pStream
->Tell();
83 uno::Sequence
< sal_Int8
> aSeq( nLen
);
84 memcpy( aSeq
.getArray(), pStream
->GetData(), nLen
);
89 datatransfer::UnsupportedFlavorException aException
;
96 uno::Sequence
< datatransfer::DataFlavor
> EditDataObject::getTransferDataFlavors( ) throw(uno::RuntimeException
)
98 uno::Sequence
< datatransfer::DataFlavor
> aDataFlavors(3);
99 SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_EDITENGINE
, aDataFlavors
.getArray()[0] );
100 SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING
, aDataFlavors
.getArray()[1] );
101 SotExchange::GetFormatDataFlavor( SOT_FORMAT_RTF
, aDataFlavors
.getArray()[2] );
106 sal_Bool
EditDataObject::isDataFlavorSupported( const datatransfer::DataFlavor
& rFlavor
) throw(uno::RuntimeException
)
108 sal_Bool bSupported
= sal_False
;
110 ULONG nT
= SotExchange::GetFormat( rFlavor
);
111 if ( ( nT
== SOT_FORMAT_STRING
) || ( nT
== SOT_FORMAT_RTF
) /* || ( nT == SOT_FORMAT_XML ) */ || ( nT
== SOT_FORMATSTR_ID_EDITENGINE
) )
112 bSupported
= sal_True
;