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 "xmlReportElementBase.hxx"
25 #include "xmlfilter.hxx"
26 #include "xmlControlProperty.hxx"
27 #include "xmlReportElement.hxx"
28 #include "xmlEnums.hxx"
29 #include "xmlTable.hxx"
30
31 namespace rptxml
32 {
33 using namespace ::com::sun::star;
34 using namespace ::com::sun::star::report;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::xml::sax;
37
OXMLReportElementBase(ORptFilter & rImport,sal_uInt16 nPrfx,const::rtl::OUString & rLName,const Reference<XReportComponent> & _xComponent,OXMLTable * _pContainer)38 OXMLReportElementBase::OXMLReportElementBase( ORptFilter& rImport
39 ,sal_uInt16 nPrfx
40 , const ::rtl::OUString& rLName
41 ,const Reference< XReportComponent > & _xComponent
42 ,OXMLTable* _pContainer) :
43 SvXMLImportContext( rImport, nPrfx, rLName )
44 ,m_rImport(rImport)
45 ,m_pContainer(_pContainer)
46 ,m_xComponent(_xComponent)
47 {
48 }
49 // -----------------------------------------------------------------------------
50
~OXMLReportElementBase()51 OXMLReportElementBase::~OXMLReportElementBase()
52 {
53 }
54 // -----------------------------------------------------------------------------
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const Reference<XAttributeList> & xAttrList)55 SvXMLImportContext* OXMLReportElementBase::CreateChildContext(
56 sal_uInt16 nPrefix,
57 const ::rtl::OUString& rLocalName,
58 const Reference< XAttributeList > & xAttrList )
59 {
60 SvXMLImportContext *pContext = _CreateChildContext(nPrefix,rLocalName,xAttrList);
61 if( !pContext )
62 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
63 return pContext;
64 }
65 // -----------------------------------------------------------------------------
_CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const Reference<XAttributeList> & xAttrList)66 SvXMLImportContext* OXMLReportElementBase::_CreateChildContext(
67 sal_uInt16 nPrefix,
68 const ::rtl::OUString& rLocalName,
69 const Reference< XAttributeList > & xAttrList )
70 {
71 SvXMLImportContext *pContext = 0;
72 const SvXMLTokenMap& rTokenMap = m_rImport.GetControlElemTokenMap();
73
74 switch( rTokenMap.Get( nPrefix, rLocalName ) )
75 {
76 case XML_TOK_REPORT_ELEMENT:
77 {
78 uno::Reference<report::XReportControlModel> xReportModel(m_xComponent,uno::UNO_QUERY);
79 if ( xReportModel.is() )
80 {
81 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
82 pContext = new OXMLReportElement( m_rImport, nPrefix, rLocalName,xAttrList,xReportModel);
83 }
84 }
85 break;
86 case XML_TOK_PROPERTIES:
87 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
88 pContext = new OXMLControlProperty( m_rImport, nPrefix, rLocalName,xAttrList,m_xComponent.get());
89 break;
90 default:
91 break;
92 }
93
94 return pContext;
95 }
96 // -----------------------------------------------------------------------------
EndElement()97 void OXMLReportElementBase::EndElement()
98 {
99 try
100 {
101 if ( m_pContainer && m_pContainer->getSection().is() && m_xComponent.is() )
102 m_pContainer->getSection()->add(m_xComponent.get());
103 }
104 catch(Exception&)
105 {
106 OSL_ENSURE(0,"Exception caught while inserting a new control!");
107 }
108 }
109 //----------------------------------------------------------------------------
110 } // namespace rptxml
111 // -----------------------------------------------------------------------------
112