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