Update ooo320-m1
[ooovba.git] / reportdesign / source / ui / report / dlgedclip.cxx
blobd92c030831bf6ef22e30746d5c0704287ac4c5f5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlgedclip.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
31 #include "dlgedclip.hxx"
32 #include <comphelper/processfactory.hxx>
33 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
34 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
36 namespace rptui
39 using namespace comphelper;
40 using namespace ::com::sun::star;
42 //============================================================================
43 // OReportExchange
44 //============================================================================
45 //----------------------------------------------------------------------------
46 OReportExchange::OReportExchange(const TSectionElements& _rCopyElements )
47 : m_aCopyElements(_rCopyElements)
50 //--------------------------------------------------------------------
51 sal_uInt32 OReportExchange::getDescriptorFormatId()
53 static sal_uInt32 s_nFormat = (sal_uInt32)-1;
54 if ((sal_uInt32)-1 == s_nFormat)
56 s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"report.ReportObjectsTransfer\""));
57 OSL_ENSURE((sal_uInt32)-1 != s_nFormat, "OReportExchange::getDescriptorFormatId: bad exchange id!");
59 return s_nFormat;
61 //--------------------------------------------------------------------
62 void OReportExchange::AddSupportedFormats()
64 AddFormat(getDescriptorFormatId());
66 //--------------------------------------------------------------------
67 sal_Bool OReportExchange::GetData( const datatransfer::DataFlavor& _rFlavor )
69 const sal_uInt32 nFormatId = SotExchange::GetFormat(_rFlavor);
70 return (nFormatId == getDescriptorFormatId()) ?
71 SetAny( uno::Any(m_aCopyElements), _rFlavor )
72 : sal_False;
74 // -----------------------------------------------------------------------------
75 sal_Bool OReportExchange::canExtract(const DataFlavorExVector& _rFlavor)
77 return IsFormatSupported(_rFlavor,getDescriptorFormatId());
79 // -----------------------------------------------------------------------------
80 OReportExchange::TSectionElements OReportExchange::extractCopies(const TransferableDataHelper& _rData)
82 sal_Int32 nKnownFormatId = getDescriptorFormatId();
83 if ( _rData.HasFormat( nKnownFormatId ) )
85 // extract the any from the transferable
86 datatransfer::DataFlavor aFlavor;
87 #if OSL_DEBUG_LEVEL > 0
88 sal_Bool bSuccess =
89 #endif
90 SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor);
91 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid data format (no flavor)!");
93 uno::Any aDescriptor = _rData.GetAny(aFlavor);
95 TSectionElements aCopies;
96 #if OSL_DEBUG_LEVEL > 0
97 bSuccess =
98 #endif
99 aDescriptor >>= aCopies;
100 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid clipboard format!");
102 // build the real descriptor
103 return aCopies;
106 return TSectionElements();
108 //============================================================================
109 } // rptui
110 //============================================================================