LibreOffice Module editeng (master) 1
eeobj.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#include <sal/config.h>
21
22#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
23#include "eeobj.hxx"
24#include <sot/exchange.hxx>
25#include <sot/formats.hxx>
26
27using namespace ::com::sun::star;
28
29
31{
32}
33
35{
36}
37
38// datatransfer::XTransferable
39uno::Any EditDataObject::getTransferData( const datatransfer::DataFlavor& rFlavor )
40{
41 uno::Any aAny;
42
44 if ( nT == SotClipboardFormatId::STRING )
45 {
46 aAny <<= GetString();
47 }
48 else if ( ( nT == SotClipboardFormatId::RTF ) || ( nT == SotClipboardFormatId::RICHTEXT ) || ( nT == SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT ) )
49 {
50 // No RTF on demand any more:
51 // 1) Was not working, because I had to flush() the clipboard immediately anyway
52 // 2) Don't have the old pool defaults and the StyleSheetPool here.
53
54 SvMemoryStream* pStream = (nT == SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT ) ? &GetODFStream() : &GetRTFStream();
55 sal_Int32 nLen = pStream->TellEnd();
56 if (nLen < 0) { abort(); }
57
58 aAny <<= uno::Sequence< sal_Int8 >( static_cast< const sal_Int8* >(pStream->GetData()), pStream->TellEnd() );
59 }
60 else
61 {
62 datatransfer::UnsupportedFlavorException aException;
63 throw aException;
64 }
65
66 return aAny;
67}
68
69uno::Sequence< datatransfer::DataFlavor > EditDataObject::getTransferDataFlavors( )
70{
71 uno::Sequence< datatransfer::DataFlavor > aDataFlavors(4);
72 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT, aDataFlavors.getArray()[0] );
73 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aDataFlavors.getArray()[1] );
74 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::RTF, aDataFlavors.getArray()[2] );
75 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::RICHTEXT, aDataFlavors.getArray()[3] );
76
77 return aDataFlavors;
78}
79
80sal_Bool EditDataObject::isDataFlavorSupported( const datatransfer::DataFlavor& rFlavor )
81{
82 bool bSupported = false;
83
85 if ( ( nT == SotClipboardFormatId::STRING ) || ( nT == SotClipboardFormatId::RTF ) || ( nT == SotClipboardFormatId::RICHTEXT )
86 || ( nT == SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT ) )
87 bSupported = true;
88
89 return bSupported;
90}
91
92/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString & GetString()
Definition: eeobj.hxx:41
css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override
Definition: eeobj.cxx:69
SvMemoryStream & GetODFStream()
Definition: eeobj.hxx:40
SvMemoryStream & GetRTFStream()
Definition: eeobj.hxx:39
virtual ~EditDataObject() override
Definition: eeobj.cxx:34
css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor &aFlavor) override
Definition: eeobj.cxx:39
sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor &aFlavor) override
Definition: eeobj.cxx:80
EditDataObject()
Definition: eeobj.cxx:30
static bool GetFormatDataFlavor(SotClipboardFormatId nFormat, css::datatransfer::DataFlavor &rFlavor)
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
const void * GetData()
virtual sal_uInt64 TellEnd() override
SotClipboardFormatId
unsigned char sal_Bool
signed char sal_Int8