1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #include "precompiled_reportdesign.hxx" 24 #include "dlgedclip.hxx" 25 #include <comphelper/processfactory.hxx> 26 #include <com/sun/star/datatransfer/XMimeContentType.hpp> 27 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp> 28 29 namespace rptui 30 { 31 32 using namespace comphelper; 33 using namespace ::com::sun::star; 34 35 //============================================================================ 36 // OReportExchange 37 //============================================================================ 38 //---------------------------------------------------------------------------- 39 OReportExchange::OReportExchange(const TSectionElements& _rCopyElements ) 40 : m_aCopyElements(_rCopyElements) 41 { 42 } 43 //-------------------------------------------------------------------- 44 sal_uInt32 OReportExchange::getDescriptorFormatId() 45 { 46 static sal_uInt32 s_nFormat = (sal_uInt32)-1; 47 if ((sal_uInt32)-1 == s_nFormat) 48 { 49 s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"report.ReportObjectsTransfer\"")); 50 OSL_ENSURE((sal_uInt32)-1 != s_nFormat, "OReportExchange::getDescriptorFormatId: bad exchange id!"); 51 } 52 return s_nFormat; 53 } 54 //-------------------------------------------------------------------- 55 void OReportExchange::AddSupportedFormats() 56 { 57 AddFormat(getDescriptorFormatId()); 58 } 59 //-------------------------------------------------------------------- 60 sal_Bool OReportExchange::GetData( const datatransfer::DataFlavor& _rFlavor ) 61 { 62 const sal_uInt32 nFormatId = SotExchange::GetFormat(_rFlavor); 63 return (nFormatId == getDescriptorFormatId()) ? 64 SetAny( uno::Any(m_aCopyElements), _rFlavor ) 65 : sal_False; 66 } 67 // ----------------------------------------------------------------------------- 68 sal_Bool OReportExchange::canExtract(const DataFlavorExVector& _rFlavor) 69 { 70 return IsFormatSupported(_rFlavor,getDescriptorFormatId()); 71 } 72 // ----------------------------------------------------------------------------- 73 OReportExchange::TSectionElements OReportExchange::extractCopies(const TransferableDataHelper& _rData) 74 { 75 sal_Int32 nKnownFormatId = getDescriptorFormatId(); 76 if ( _rData.HasFormat( nKnownFormatId ) ) 77 { 78 // extract the any from the transferable 79 datatransfer::DataFlavor aFlavor; 80 #if OSL_DEBUG_LEVEL > 0 81 sal_Bool bSuccess = 82 #endif 83 SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor); 84 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid data format (no flavor)!"); 85 86 uno::Any aDescriptor = _rData.GetAny(aFlavor); 87 88 TSectionElements aCopies; 89 #if OSL_DEBUG_LEVEL > 0 90 bSuccess = 91 #endif 92 aDescriptor >>= aCopies; 93 OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid clipboard format!"); 94 95 // build the real descriptor 96 return aCopies; 97 } 98 99 return TSectionElements(); 100 } 101 //============================================================================ 102 } // rptui 103 //============================================================================ 104