Use o3tl::convert in Math
[LibreOffice.git] / reportdesign / source / ui / report / dlgedclip.cxx
blob1f36563fe8740d43d0329ee0b25248ad337fc6d9
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>
23 namespace rptui
26 using namespace ::com::sun::star;
29 // OReportExchange
32 OReportExchange::OReportExchange(const TSectionElements& _rCopyElements )
33 : m_aCopyElements(_rCopyElements)
37 SotClipboardFormatId OReportExchange::getDescriptorFormatId()
39 static SotClipboardFormatId s_nFormat = static_cast<SotClipboardFormatId>(-1);
40 if (static_cast<SotClipboardFormatId>(-1) == s_nFormat)
42 s_nFormat = SotExchange::RegisterFormatName("application/x-openoffice;windows_formatname=\"report.ReportObjectsTransfer\"");
43 OSL_ENSURE(static_cast<SotClipboardFormatId>(-1) != s_nFormat, "OReportExchange::getDescriptorFormatId: bad exchange id!");
45 return s_nFormat;
48 void OReportExchange::AddSupportedFormats()
50 AddFormat(getDescriptorFormatId());
53 bool OReportExchange::GetData( const datatransfer::DataFlavor& _rFlavor, const OUString& /*rDestDoc*/ )
55 const SotClipboardFormatId nFormatId = SotExchange::GetFormat(_rFlavor);
56 return (nFormatId == getDescriptorFormatId()) && SetAny( uno::Any(m_aCopyElements) );
59 bool OReportExchange::canExtract(const DataFlavorExVector& _rFlavor)
61 return IsFormatSupported(_rFlavor,getDescriptorFormatId());
64 OReportExchange::TSectionElements OReportExchange::extractCopies(const TransferableDataHelper& _rData)
66 SotClipboardFormatId nKnownFormatId = getDescriptorFormatId();
67 if ( _rData.HasFormat( nKnownFormatId ) )
69 // extract the any from the transferable
70 datatransfer::DataFlavor aFlavor;
71 bool bSuccess =
72 SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor);
73 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid data format (no flavor)!");
75 uno::Any aDescriptor = _rData.GetAny(aFlavor, OUString());
77 TSectionElements aCopies;
78 bSuccess = aDescriptor >>= aCopies;
79 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid clipboard format!");
81 // build the real descriptor
82 return aCopies;
85 return TSectionElements();
88 } // rptui
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */