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(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 : bool OReportExchange::GetData( const datatransfer::DataFlavor& _rFlavor, const OUString& /*rDestDoc*/ )
56 : {
57 0 : const sal_uInt32 nFormatId = SotExchange::GetFormat(_rFlavor);
58 0 : return (nFormatId == getDescriptorFormatId()) && SetAny( uno::Any(m_aCopyElements), _rFlavor );
59 : }
60 :
61 0 : bool OReportExchange::canExtract(const DataFlavorExVector& _rFlavor)
62 : {
63 0 : return IsFormatSupported(_rFlavor,getDescriptorFormatId());
64 : }
65 :
66 0 : OReportExchange::TSectionElements OReportExchange::extractCopies(const TransferableDataHelper& _rData)
67 : {
68 0 : sal_Int32 nKnownFormatId = getDescriptorFormatId();
69 0 : if ( _rData.HasFormat( nKnownFormatId ) )
70 : {
71 : // extract the any from the transferable
72 0 : datatransfer::DataFlavor aFlavor;
73 : #if OSL_DEBUG_LEVEL > 0
74 : bool bSuccess =
75 : #endif
76 0 : SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor);
77 : OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid data format (no flavor)!");
78 :
79 0 : uno::Any aDescriptor = _rData.GetAny(aFlavor, OUString());
80 :
81 0 : TSectionElements aCopies;
82 : #if OSL_DEBUG_LEVEL > 0
83 : bSuccess =
84 : #endif
85 0 : aDescriptor >>= aCopies;
86 : OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid clipboard format!");
87 :
88 : // build the real descriptor
89 0 : return aCopies;
90 : }
91 :
92 0 : return TSectionElements();
93 : }
94 :
95 : } // rptui
96 :
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|