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 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbaccess.hxx"
26 #ifndef DBAUI_TABLEROW_EXCHANGE_HXX
27 #include "TableRowExchange.hxx"
28 #endif
29 #ifndef _SOT_FORMATS_HXX
30 #include <sot/formats.hxx>
31 #endif
32 #ifndef _SOT_STORAGE_HXX
33 #include <sot/storage.hxx>
34 #endif
35 #ifndef DBAUI_TABLEROW_HXX
36 #include "TableRow.hxx"
37 #endif
38 
39 namespace dbaui
40 {
41 	using namespace ::com::sun::star::uno;
42 	using namespace ::com::sun::star::beans;
43 	OTableRowExchange::OTableRowExchange(const ::std::vector< ::boost::shared_ptr<OTableRow> >& _rvTableRow)
44 		: m_vTableRow(_rvTableRow)
45 	{
46 	}
47 	// -----------------------------------------------------------------------------
48 	sal_Bool OTableRowExchange::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& /*rFlavor*/ )
49 	{
50 		if(nUserObjectId == SOT_FORMATSTR_ID_SBA_TABED)
51 		{
52 			::std::vector< ::boost::shared_ptr<OTableRow> >* pRows = reinterpret_cast< ::std::vector< ::boost::shared_ptr<OTableRow> >* >(pUserObject);
53 			if(pRows)
54 			{
55 				(*rxOStm) << (sal_Int32)pRows->size(); // first stream the size
56 				::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = pRows->begin();
57                 ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = pRows->end();
58 				for(;aIter != aEnd;++aIter)
59 					(*rxOStm) << *(*aIter);
60 				return sal_True;
61 			}
62 		}
63 		return sal_False;
64 	}
65 	// -----------------------------------------------------------------------------
66 	void OTableRowExchange::AddSupportedFormats()
67 	{
68 		if ( !m_vTableRow.empty() )
69 			AddFormat(SOT_FORMATSTR_ID_SBA_TABED);
70 	}
71 	// -----------------------------------------------------------------------------
72 	sal_Bool OTableRowExchange::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
73 	{
74 		sal_uLong nFormat = SotExchange::GetFormat(rFlavor);
75 		if(nFormat == SOT_FORMATSTR_ID_SBA_TABED)
76 			return SetObject(&m_vTableRow,SOT_FORMATSTR_ID_SBA_TABED,rFlavor);
77 		return sal_False;
78 	}
79 	// -----------------------------------------------------------------------------
80 	void OTableRowExchange::ObjectReleased()
81 	{
82 		m_vTableRow.clear();
83 	}
84 	// -----------------------------------------------------------------------------
85 }
86 
87 
88 
89 
90 
91 
92 
93 
94