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