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_rptui.hxx"
24 #include "GroupExchange.hxx"
25 #include <sot/formats.hxx>
26 #include <sot/storage.hxx>
27 
28 namespace rptui
29 {
30 	using namespace ::com::sun::star;
31 	using namespace ::com::sun::star::uno;
32 	using namespace ::com::sun::star::beans;
33 
getReportGroupId()34     sal_uInt32 OGroupExchange::getReportGroupId()
35     {
36         static sal_uInt32 s_nReportFormat = (sal_uInt32)-1;
37 		if ( (sal_uInt32)-1 == s_nReportFormat )
38 		{
39 			s_nReportFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"reportdesign.GroupFormat\"" ));
40 			OSL_ENSURE((sal_uInt32)-1 != s_nReportFormat, "Bad exchange id!");
41         }
42         return s_nReportFormat;
43     }
OGroupExchange(const uno::Sequence<uno::Any> & _aGroupRow)44 	OGroupExchange::OGroupExchange(const uno::Sequence< uno::Any >& _aGroupRow)
45 		: m_aGroupRow(_aGroupRow)
46 	{
47 	}
48 	// -----------------------------------------------------------------------------
AddSupportedFormats()49 	void OGroupExchange::AddSupportedFormats()
50 	{
51 		if ( m_aGroupRow.getLength() )
52         {
53 			AddFormat(OGroupExchange::getReportGroupId());
54         }
55 	}
56 	// -----------------------------------------------------------------------------
GetData(const::com::sun::star::datatransfer::DataFlavor & rFlavor)57 	sal_Bool OGroupExchange::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
58 	{
59 		sal_uLong nFormat = SotExchange::GetFormat(rFlavor);
60 		if(nFormat == OGroupExchange::getReportGroupId() )
61 		{
62 			return SetAny(uno::makeAny(m_aGroupRow),rFlavor);
63 		}
64 		return sal_False;
65 	}
66 	// -----------------------------------------------------------------------------
ObjectReleased()67 	void OGroupExchange::ObjectReleased()
68 	{
69 		m_aGroupRow.realloc(0);
70 	}
71 	// -----------------------------------------------------------------------------
72 }
73