bump product version to 4.1.6.2
[LibreOffice.git] / reportdesign / source / ui / report / dlgedclip.cxx
blob48b334e9cbd550083b173abb12a383fa07e041a4
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 <comphelper/processfactory.hxx>
21 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
22 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
24 namespace rptui
27 using namespace comphelper;
28 using namespace ::com::sun::star;
30 //============================================================================
31 // OReportExchange
32 //============================================================================
33 //----------------------------------------------------------------------------
34 OReportExchange::OReportExchange(const TSectionElements& _rCopyElements )
35 : m_aCopyElements(_rCopyElements)
38 //--------------------------------------------------------------------
39 sal_uInt32 OReportExchange::getDescriptorFormatId()
41 static sal_uInt32 s_nFormat = (sal_uInt32)-1;
42 if ((sal_uInt32)-1 == s_nFormat)
44 s_nFormat = SotExchange::RegisterFormatName(OUString("application/x-openoffice;windows_formatname=\"report.ReportObjectsTransfer\""));
45 OSL_ENSURE((sal_uInt32)-1 != s_nFormat, "OReportExchange::getDescriptorFormatId: bad exchange id!");
47 return s_nFormat;
49 //--------------------------------------------------------------------
50 void OReportExchange::AddSupportedFormats()
52 AddFormat(getDescriptorFormatId());
54 //--------------------------------------------------------------------
55 sal_Bool OReportExchange::GetData( const datatransfer::DataFlavor& _rFlavor )
57 const sal_uInt32 nFormatId = SotExchange::GetFormat(_rFlavor);
58 return (nFormatId == getDescriptorFormatId()) ?
59 SetAny( uno::Any(m_aCopyElements), _rFlavor )
60 : sal_False;
62 // -----------------------------------------------------------------------------
63 sal_Bool OReportExchange::canExtract(const DataFlavorExVector& _rFlavor)
65 return IsFormatSupported(_rFlavor,getDescriptorFormatId());
67 // -----------------------------------------------------------------------------
68 OReportExchange::TSectionElements OReportExchange::extractCopies(const TransferableDataHelper& _rData)
70 sal_Int32 nKnownFormatId = getDescriptorFormatId();
71 if ( _rData.HasFormat( nKnownFormatId ) )
73 // extract the any from the transferable
74 datatransfer::DataFlavor aFlavor;
75 #if OSL_DEBUG_LEVEL > 0
76 sal_Bool bSuccess =
77 #endif
78 SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor);
79 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid data format (no flavor)!");
81 uno::Any aDescriptor = _rData.GetAny(aFlavor);
83 TSectionElements aCopies;
84 #if OSL_DEBUG_LEVEL > 0
85 bSuccess =
86 #endif
87 aDescriptor >>= aCopies;
88 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid clipboard format!");
90 // build the real descriptor
91 return aCopies;
94 return TSectionElements();
96 //============================================================================
97 } // rptui
98 //============================================================================
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */