Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "xmlReportElementBase.hxx"
29 : : #include "xmlfilter.hxx"
30 : : #include "xmlControlProperty.hxx"
31 : : #include "xmlReportElement.hxx"
32 : : #include "xmlEnums.hxx"
33 : : #include "xmlTable.hxx"
34 : :
35 : : namespace rptxml
36 : : {
37 : : using namespace ::com::sun::star;
38 : : using namespace ::com::sun::star::report;
39 : : using namespace ::com::sun::star::uno;
40 : : using namespace ::com::sun::star::xml::sax;
41 : :
42 : 0 : OXMLReportElementBase::OXMLReportElementBase( ORptFilter& rImport
43 : : ,sal_uInt16 nPrfx
44 : : , const ::rtl::OUString& rLName
45 : : ,const Reference< XReportComponent > & _xComponent
46 : : ,OXMLTable* _pContainer) :
47 : : SvXMLImportContext( rImport, nPrfx, rLName )
48 : : ,m_rImport(rImport)
49 : : ,m_pContainer(_pContainer)
50 : 0 : ,m_xComponent(_xComponent)
51 : : {
52 : 0 : }
53 : : // -----------------------------------------------------------------------------
54 : :
55 : 0 : OXMLReportElementBase::~OXMLReportElementBase()
56 : : {
57 [ # # ]: 0 : }
58 : : // -----------------------------------------------------------------------------
59 : 0 : SvXMLImportContext* OXMLReportElementBase::CreateChildContext(
60 : : sal_uInt16 nPrefix,
61 : : const ::rtl::OUString& rLocalName,
62 : : const Reference< XAttributeList > & xAttrList )
63 : : {
64 : 0 : SvXMLImportContext *pContext = _CreateChildContext(nPrefix,rLocalName,xAttrList);
65 [ # # ]: 0 : if( !pContext )
66 [ # # ]: 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
67 : 0 : return pContext;
68 : : }
69 : : // -----------------------------------------------------------------------------
70 : 0 : SvXMLImportContext* OXMLReportElementBase::_CreateChildContext(
71 : : sal_uInt16 nPrefix,
72 : : const ::rtl::OUString& rLocalName,
73 : : const Reference< XAttributeList > & xAttrList )
74 : : {
75 : 0 : SvXMLImportContext *pContext = 0;
76 : 0 : const SvXMLTokenMap& rTokenMap = m_rImport.GetControlElemTokenMap();
77 : :
78 [ # # # ]: 0 : switch( rTokenMap.Get( nPrefix, rLocalName ) )
79 : : {
80 : : case XML_TOK_REPORT_ELEMENT:
81 : : {
82 [ # # ]: 0 : uno::Reference<report::XReportControlModel> xReportModel(m_xComponent,uno::UNO_QUERY);
83 [ # # ]: 0 : if ( xReportModel.is() )
84 : : {
85 [ # # ][ # # ]: 0 : m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
86 [ # # ][ # # ]: 0 : pContext = new OXMLReportElement( m_rImport, nPrefix, rLocalName,xAttrList,xReportModel);
87 : 0 : }
88 : : }
89 : 0 : break;
90 : : case XML_TOK_PROPERTIES:
91 : 0 : m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
92 [ # # ][ # # ]: 0 : pContext = new OXMLControlProperty( m_rImport, nPrefix, rLocalName,xAttrList,m_xComponent.get());
[ # # ]
93 : 0 : break;
94 : : default:
95 : 0 : break;
96 : : }
97 : :
98 : 0 : return pContext;
99 : : }
100 : : // -----------------------------------------------------------------------------
101 : 0 : void OXMLReportElementBase::EndElement()
102 : : {
103 : : try
104 : : {
105 [ # # ][ # # ]: 0 : if ( m_pContainer && m_pContainer->getSection().is() && m_xComponent.is() )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
106 [ # # ][ # # ]: 0 : m_pContainer->getSection()->add(m_xComponent.get());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
107 : : }
108 : 0 : catch(Exception&)
109 : : {
110 : : OSL_FAIL("Exception caught while inserting a new control!");
111 : : }
112 : 0 : }
113 : : //----------------------------------------------------------------------------
114 : : } // namespace rptxml
115 : : // -----------------------------------------------------------------------------
116 : :
117 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|