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 <comphelper/processfactory.hxx>
21 #include <osl/diagnose.h>
22 #include <sot/exchange.hxx>
23 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
24 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
29 using namespace comphelper
;
30 using namespace ::com::sun::star
;
36 OReportExchange::OReportExchange(const TSectionElements
& _rCopyElements
)
37 : m_aCopyElements(_rCopyElements
)
41 SotClipboardFormatId
OReportExchange::getDescriptorFormatId()
43 static SotClipboardFormatId s_nFormat
= static_cast<SotClipboardFormatId
>(-1);
44 if (static_cast<SotClipboardFormatId
>(-1) == s_nFormat
)
46 s_nFormat
= SotExchange::RegisterFormatName(OUString("application/x-openoffice;windows_formatname=\"report.ReportObjectsTransfer\""));
47 OSL_ENSURE(static_cast<SotClipboardFormatId
>(-1) != s_nFormat
, "OReportExchange::getDescriptorFormatId: bad exchange id!");
52 void OReportExchange::AddSupportedFormats()
54 AddFormat(getDescriptorFormatId());
57 bool OReportExchange::GetData( const datatransfer::DataFlavor
& _rFlavor
, const OUString
& /*rDestDoc*/ )
59 const SotClipboardFormatId nFormatId
= SotExchange::GetFormat(_rFlavor
);
60 return (nFormatId
== getDescriptorFormatId()) && SetAny( uno::Any(m_aCopyElements
), _rFlavor
);
63 bool OReportExchange::canExtract(const DataFlavorExVector
& _rFlavor
)
65 return IsFormatSupported(_rFlavor
,getDescriptorFormatId());
68 OReportExchange::TSectionElements
OReportExchange::extractCopies(const TransferableDataHelper
& _rData
)
70 SotClipboardFormatId nKnownFormatId
= getDescriptorFormatId();
71 if ( _rData
.HasFormat( nKnownFormatId
) )
73 // extract the any from the transferable
74 datatransfer::DataFlavor aFlavor
;
75 #if OSL_DEBUG_LEVEL > 0
78 SotExchange::GetFormatDataFlavor(nKnownFormatId
, aFlavor
);
79 OSL_ENSURE(bSuccess
, "OReportExchange::extractCopies: invalid data format (no flavor)!");
81 uno::Any aDescriptor
= _rData
.GetAny(aFlavor
, OUString());
83 TSectionElements aCopies
;
84 #if OSL_DEBUG_LEVEL > 0
87 aDescriptor
>>= aCopies
;
88 OSL_ENSURE(bSuccess
, "OReportExchange::extractCopies: invalid clipboard format!");
90 // build the real descriptor
94 return TSectionElements();
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */