bump product version to 6.3.0.0.beta1
[LibreOffice.git] / reportdesign / source / ui / report / dlgedclip.cxx
blob03e54fa6910c35cb06c00411691de6c7106f20a9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
25 namespace rptui
28 using namespace ::com::sun::star;
31 // OReportExchange
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!");
47 return s_nFormat;
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;
73 bool bSuccess =
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
84 return aCopies;
87 return TSectionElements();
90 } // rptui
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */