Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
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>
23 :
24 : namespace rptui
25 : {
26 :
27 : using namespace comphelper;
28 : using namespace ::com::sun::star;
29 :
30 : //============================================================================
31 : // OReportExchange
32 : //============================================================================
33 : //----------------------------------------------------------------------------
34 0 : OReportExchange::OReportExchange(const TSectionElements& _rCopyElements )
35 0 : : m_aCopyElements(_rCopyElements)
36 : {
37 0 : }
38 : //--------------------------------------------------------------------
39 0 : sal_uInt32 OReportExchange::getDescriptorFormatId()
40 : {
41 : static sal_uInt32 s_nFormat = (sal_uInt32)-1;
42 0 : if ((sal_uInt32)-1 == s_nFormat)
43 : {
44 0 : s_nFormat = SotExchange::RegisterFormatName(rtl::OUString("application/x-openoffice;windows_formatname=\"report.ReportObjectsTransfer\""));
45 : OSL_ENSURE((sal_uInt32)-1 != s_nFormat, "OReportExchange::getDescriptorFormatId: bad exchange id!");
46 : }
47 0 : return s_nFormat;
48 : }
49 : //--------------------------------------------------------------------
50 0 : void OReportExchange::AddSupportedFormats()
51 : {
52 0 : AddFormat(getDescriptorFormatId());
53 0 : }
54 : //--------------------------------------------------------------------
55 0 : sal_Bool OReportExchange::GetData( const datatransfer::DataFlavor& _rFlavor )
56 : {
57 0 : const sal_uInt32 nFormatId = SotExchange::GetFormat(_rFlavor);
58 0 : return (nFormatId == getDescriptorFormatId()) ?
59 0 : SetAny( uno::Any(m_aCopyElements), _rFlavor )
60 0 : : sal_False;
61 : }
62 : // -----------------------------------------------------------------------------
63 0 : sal_Bool OReportExchange::canExtract(const DataFlavorExVector& _rFlavor)
64 : {
65 0 : return IsFormatSupported(_rFlavor,getDescriptorFormatId());
66 : }
67 : // -----------------------------------------------------------------------------
68 0 : OReportExchange::TSectionElements OReportExchange::extractCopies(const TransferableDataHelper& _rData)
69 : {
70 0 : sal_Int32 nKnownFormatId = getDescriptorFormatId();
71 0 : if ( _rData.HasFormat( nKnownFormatId ) )
72 : {
73 : // extract the any from the transferable
74 0 : datatransfer::DataFlavor aFlavor;
75 : #if OSL_DEBUG_LEVEL > 0
76 : sal_Bool bSuccess =
77 : #endif
78 0 : SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor);
79 : OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid data format (no flavor)!");
80 :
81 0 : uno::Any aDescriptor = _rData.GetAny(aFlavor);
82 :
83 0 : TSectionElements aCopies;
84 : #if OSL_DEBUG_LEVEL > 0
85 : bSuccess =
86 : #endif
87 0 : aDescriptor >>= aCopies;
88 : OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid clipboard format!");
89 :
90 : // build the real descriptor
91 0 : return aCopies;
92 : }
93 :
94 0 : return TSectionElements();
95 : }
96 : //============================================================================
97 : } // rptui
98 : //============================================================================
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|