1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_dbaccess.hxx" 30 #ifndef DBAUI_TABLEROW_EXCHANGE_HXX 31 #include "TableRowExchange.hxx" 32 #endif 33 #ifndef _SOT_FORMATS_HXX 34 #include <sot/formats.hxx> 35 #endif 36 #ifndef _SOT_STORAGE_HXX 37 #include <sot/storage.hxx> 38 #endif 39 #ifndef DBAUI_TABLEROW_HXX 40 #include "TableRow.hxx" 41 #endif 42 43 namespace dbaui 44 { 45 using namespace ::com::sun::star::uno; 46 using namespace ::com::sun::star::beans; 47 OTableRowExchange::OTableRowExchange(const ::std::vector< ::boost::shared_ptr<OTableRow> >& _rvTableRow) 48 : m_vTableRow(_rvTableRow) 49 { 50 } 51 // ----------------------------------------------------------------------------- 52 sal_Bool OTableRowExchange::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& /*rFlavor*/ ) 53 { 54 if(nUserObjectId == SOT_FORMATSTR_ID_SBA_TABED) 55 { 56 ::std::vector< ::boost::shared_ptr<OTableRow> >* pRows = reinterpret_cast< ::std::vector< ::boost::shared_ptr<OTableRow> >* >(pUserObject); 57 if(pRows) 58 { 59 (*rxOStm) << (sal_Int32)pRows->size(); // first stream the size 60 ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = pRows->begin(); 61 ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = pRows->end(); 62 for(;aIter != aEnd;++aIter) 63 (*rxOStm) << *(*aIter); 64 return sal_True; 65 } 66 } 67 return sal_False; 68 } 69 // ----------------------------------------------------------------------------- 70 void OTableRowExchange::AddSupportedFormats() 71 { 72 if ( !m_vTableRow.empty() ) 73 AddFormat(SOT_FORMATSTR_ID_SBA_TABED); 74 } 75 // ----------------------------------------------------------------------------- 76 sal_Bool OTableRowExchange::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) 77 { 78 sal_uLong nFormat = SotExchange::GetFormat(rFlavor); 79 if(nFormat == SOT_FORMATSTR_ID_SBA_TABED) 80 return SetObject(&m_vTableRow,SOT_FORMATSTR_ID_SBA_TABED,rFlavor); 81 return sal_False; 82 } 83 // ----------------------------------------------------------------------------- 84 void OTableRowExchange::ObjectReleased() 85 { 86 m_vTableRow.clear(); 87 } 88 // ----------------------------------------------------------------------------- 89 } 90 91 92 93 94 95 96 97 98