Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #include "xmlReportElementBase.hxx"
20 : #include "xmlfilter.hxx"
21 : #include "xmlControlProperty.hxx"
22 : #include "xmlReportElement.hxx"
23 : #include "xmlEnums.hxx"
24 : #include "xmlTable.hxx"
25 :
26 : namespace rptxml
27 : {
28 : using namespace ::com::sun::star;
29 : using namespace ::com::sun::star::report;
30 : using namespace ::com::sun::star::uno;
31 : using namespace ::com::sun::star::xml::sax;
32 :
33 0 : OXMLReportElementBase::OXMLReportElementBase( ORptFilter& rImport
34 : ,sal_uInt16 nPrfx
35 : , const OUString& rLName
36 : ,const Reference< XReportComponent > & _xComponent
37 : ,OXMLTable* _pContainer) :
38 : SvXMLImportContext( rImport, nPrfx, rLName )
39 : ,m_rImport(rImport)
40 : ,m_pContainer(_pContainer)
41 0 : ,m_xComponent(_xComponent)
42 : {
43 0 : }
44 :
45 :
46 0 : OXMLReportElementBase::~OXMLReportElementBase()
47 : {
48 0 : }
49 :
50 0 : SvXMLImportContext* OXMLReportElementBase::CreateChildContext(
51 : sal_uInt16 nPrefix,
52 : const OUString& rLocalName,
53 : const Reference< XAttributeList > & xAttrList )
54 : {
55 0 : SvXMLImportContext *pContext = _CreateChildContext(nPrefix,rLocalName,xAttrList);
56 0 : if( !pContext )
57 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
58 0 : return pContext;
59 : }
60 :
61 0 : SvXMLImportContext* OXMLReportElementBase::_CreateChildContext(
62 : sal_uInt16 nPrefix,
63 : const OUString& rLocalName,
64 : const Reference< XAttributeList > & xAttrList )
65 : {
66 0 : SvXMLImportContext *pContext = 0;
67 0 : const SvXMLTokenMap& rTokenMap = m_rImport.GetControlElemTokenMap();
68 :
69 0 : switch( rTokenMap.Get( nPrefix, rLocalName ) )
70 : {
71 : case XML_TOK_REPORT_ELEMENT:
72 : {
73 0 : uno::Reference<report::XReportControlModel> xReportModel(m_xComponent,uno::UNO_QUERY);
74 0 : if ( xReportModel.is() )
75 : {
76 0 : m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
77 0 : pContext = new OXMLReportElement( m_rImport, nPrefix, rLocalName,xAttrList,xReportModel);
78 0 : }
79 : }
80 0 : break;
81 : case XML_TOK_PROPERTIES:
82 0 : m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
83 0 : pContext = new OXMLControlProperty( m_rImport, nPrefix, rLocalName,xAttrList,m_xComponent.get());
84 0 : break;
85 : default:
86 0 : break;
87 : }
88 :
89 0 : return pContext;
90 : }
91 :
92 0 : void OXMLReportElementBase::EndElement()
93 : {
94 : try
95 : {
96 0 : if ( m_pContainer && m_pContainer->getSection().is() && m_xComponent.is() )
97 0 : m_pContainer->getSection()->add(m_xComponent.get());
98 : }
99 0 : catch(Exception&)
100 : {
101 : OSL_FAIL("Exception caught while inserting a new control!");
102 : }
103 0 : }
104 :
105 : } // namespace rptxml
106 :
107 :
108 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|