1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include <dlgedclip.hxx>
20 #include <osl/diagnose.h>
21 #include <sot/exchange.hxx>
22 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
23 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
28 using namespace ::com::sun::star
;
34 OReportExchange::OReportExchange(const TSectionElements
& _rCopyElements
)
35 : m_aCopyElements(_rCopyElements
)
39 SotClipboardFormatId
OReportExchange::getDescriptorFormatId()
41 static SotClipboardFormatId s_nFormat
= static_cast<SotClipboardFormatId
>(-1);
42 if (static_cast<SotClipboardFormatId
>(-1) == s_nFormat
)
44 s_nFormat
= SotExchange::RegisterFormatName("application/x-openoffice;windows_formatname=\"report.ReportObjectsTransfer\"");
45 OSL_ENSURE(static_cast<SotClipboardFormatId
>(-1) != s_nFormat
, "OReportExchange::getDescriptorFormatId: bad exchange id!");
50 void OReportExchange::AddSupportedFormats()
52 AddFormat(getDescriptorFormatId());
55 bool OReportExchange::GetData( const datatransfer::DataFlavor
& _rFlavor
, const OUString
& /*rDestDoc*/ )
57 const SotClipboardFormatId nFormatId
= SotExchange::GetFormat(_rFlavor
);
58 return (nFormatId
== getDescriptorFormatId()) && SetAny( uno::Any(m_aCopyElements
) );
61 bool OReportExchange::canExtract(const DataFlavorExVector
& _rFlavor
)
63 return IsFormatSupported(_rFlavor
,getDescriptorFormatId());
66 OReportExchange::TSectionElements
OReportExchange::extractCopies(const TransferableDataHelper
& _rData
)
68 SotClipboardFormatId nKnownFormatId
= getDescriptorFormatId();
69 if ( _rData
.HasFormat( nKnownFormatId
) )
71 // extract the any from the transferable
72 datatransfer::DataFlavor aFlavor
;
74 SotExchange::GetFormatDataFlavor(nKnownFormatId
, aFlavor
);
75 OSL_ENSURE(bSuccess
, "OReportExchange::extractCopies: invalid data format (no flavor)!");
77 uno::Any aDescriptor
= _rData
.GetAny(aFlavor
, OUString());
79 TSectionElements aCopies
;
80 bSuccess
= aDescriptor
>>= aCopies
;
81 OSL_ENSURE(bSuccess
, "OReportExchange::extractCopies: invalid clipboard format!");
83 // build the real descriptor
87 return TSectionElements();
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */