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 "ReportVisitor.hxx"
24 namespace reportdesign
25 {
26 using namespace com::sun::star;
27 
OReportVisitor(ITraverseReport * _pTraverseReport)28 OReportVisitor::OReportVisitor(ITraverseReport* _pTraverseReport)
29                        :m_pTraverseReport(_pTraverseReport)
30 {
31     OSL_ENSURE(m_pTraverseReport,"ReportDefintion must be not NULL!");
32 }
33 // -----------------------------------------------------------------------------
start(const uno::Reference<report::XReportDefinition> & _xReportDefinition)34 void OReportVisitor::start(const uno::Reference< report::XReportDefinition>& _xReportDefinition)
35 {
36     OSL_ENSURE(_xReportDefinition.is(),"ReportDefinition is NULL!");
37     if ( !_xReportDefinition.is() )
38         return;
39 
40     m_pTraverseReport->traverseReport(_xReportDefinition);
41     m_pTraverseReport->traverseReportFunctions(_xReportDefinition->getFunctions());
42     if ( _xReportDefinition->getPageHeaderOn() )
43         m_pTraverseReport->traversePageHeader(_xReportDefinition->getPageHeader());
44     if ( _xReportDefinition->getReportHeaderOn() )
45         m_pTraverseReport->traverseReportHeader(_xReportDefinition->getReportHeader());
46 
47     uno::Reference< report::XGroups > xGroups = _xReportDefinition->getGroups();
48     m_pTraverseReport->traverseGroups(xGroups);
49 	const sal_Int32 nCount = xGroups->getCount();
50     sal_Int32 i = 0;
51 	for (;i<nCount ; ++i)
52 	{
53 		uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY);
54         m_pTraverseReport->traverseGroup(xGroup);
55         m_pTraverseReport->traverseGroupFunctions(xGroup->getFunctions());
56         if ( xGroup->getHeaderOn() )
57             m_pTraverseReport->traverseGroupHeader(xGroup->getHeader());
58     }
59 
60     m_pTraverseReport->traverseDetail(_xReportDefinition->getDetail());
61 
62     for (i = 0;i<nCount ; ++i)
63 	{
64 		uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY);
65         if ( xGroup->getFooterOn() )
66             m_pTraverseReport->traverseGroupFooter(xGroup->getFooter());
67     }
68 
69     if ( _xReportDefinition->getPageFooterOn() )
70 		m_pTraverseReport->traversePageFooter(_xReportDefinition->getPageFooter());
71 	if ( _xReportDefinition->getReportFooterOn() )
72 		m_pTraverseReport->traverseReportFooter(_xReportDefinition->getReportFooter());
73 }
74 // -----------------------------------------------------------------------------
start(const uno::Reference<report::XGroup> & _xGroup)75 void OReportVisitor::start(const uno::Reference< report::XGroup>& _xGroup)
76 {
77     OSL_ENSURE(_xGroup.is(),"Group is NULL!");
78     if ( !_xGroup.is() )
79         return;
80     m_pTraverseReport->traverseGroup(_xGroup);
81     m_pTraverseReport->traverseGroupFunctions(_xGroup->getFunctions());
82     if ( _xGroup->getHeaderOn() )
83         m_pTraverseReport->traverseGroupHeader(_xGroup->getHeader());
84     if ( _xGroup->getFooterOn() )
85         m_pTraverseReport->traverseGroupFooter(_xGroup->getFooter());
86 }
87 // =============================================================================
88 } // namespace reportdesign
89 // =============================================================================
90