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 "xmlMasterFields.hxx"
29 : : #include "xmlfilter.hxx"
30 : : #include <xmloff/xmltoken.hxx>
31 : : #include <xmloff/xmlnmspe.hxx>
32 : : #include <xmloff/nmspmap.hxx>
33 : : #include "xmlEnums.hxx"
34 : : #include "xmlReport.hxx"
35 : : #include <tools/debug.hxx>
36 : :
37 : :
38 : : namespace rptxml
39 : : {
40 : : using namespace ::com::sun::star;
41 : : using namespace ::com::sun::star::report;
42 : : using namespace ::com::sun::star::uno;
43 : : using namespace ::com::sun::star::xml::sax;
44 : : DBG_NAME( rpt_OXMLMasterFields )
45 : :
46 : 0 : OXMLMasterFields::OXMLMasterFields( ORptFilter& rImport,
47 : : sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
48 : : const Reference< XAttributeList > & _xAttrList
49 : : ,IMasterDetailFieds* _pReport
50 : : ) :
51 : : SvXMLImportContext( rImport, nPrfx, rLName)
52 : 0 : ,m_pReport(_pReport)
53 : : {
54 : : DBG_CTOR( rpt_OXMLMasterFields,NULL);
55 : :
56 : 0 : const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
57 [ # # ]: 0 : const SvXMLTokenMap& rTokenMap = rImport.GetSubDocumentElemTokenMap();
58 : :
59 : 0 : ::rtl::OUString sMasterField,sDetailField;
60 [ # # ][ # # ]: 0 : const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
[ # # ]
61 [ # # ]: 0 : for(sal_Int16 i = 0; i < nLength; ++i)
62 : : {
63 : 0 : ::rtl::OUString sLocalName;
64 [ # # ][ # # ]: 0 : const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
65 [ # # ]: 0 : const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
66 [ # # ][ # # ]: 0 : const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
67 : :
68 [ # # ]: 0 : switch( rTokenMap.Get( nPrefix, sLocalName ) )
[ # # # ]
69 : : {
70 : : case XML_TOK_MASTER:
71 : 0 : sMasterField = sValue;
72 : 0 : break;
73 : : case XML_TOK_SUB_DETAIL:
74 : 0 : sDetailField = sValue;
75 : 0 : break;
76 : : default:
77 : 0 : break;
78 : : }
79 : 0 : }
80 [ # # ]: 0 : if ( sDetailField.isEmpty() )
81 : 0 : sDetailField = sMasterField;
82 [ # # ]: 0 : if ( !sMasterField.isEmpty() )
83 [ # # ]: 0 : m_pReport->addMasterDetailPair(::std::pair< ::rtl::OUString,::rtl::OUString >(sMasterField,sDetailField));
84 : 0 : }
85 : : // -----------------------------------------------------------------------------
86 : :
87 : 0 : OXMLMasterFields::~OXMLMasterFields()
88 : : {
89 : : DBG_DTOR( rpt_OXMLMasterFields,NULL);
90 [ # # ]: 0 : }
91 : :
92 : : // -----------------------------------------------------------------------------
93 : 0 : SvXMLImportContext* OXMLMasterFields::CreateChildContext(
94 : : sal_uInt16 _nPrefix,
95 : : const ::rtl::OUString& _rLocalName,
96 : : const Reference< XAttributeList > & xAttrList )
97 : : {
98 : 0 : SvXMLImportContext *pContext = 0;
99 : 0 : const SvXMLTokenMap& rTokenMap = static_cast<ORptFilter&>(GetImport()).GetSubDocumentElemTokenMap();
100 : :
101 [ # # ]: 0 : switch( rTokenMap.Get( _nPrefix, _rLocalName ) )
102 : : {
103 : : case XML_TOK_MASTER_DETAIL_FIELD:
104 : : {
105 : 0 : GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
106 [ # # ]: 0 : pContext = new OXMLMasterFields(static_cast<ORptFilter&>(GetImport()), _nPrefix, _rLocalName,xAttrList ,m_pReport);
107 : : }
108 : 0 : break;
109 : : default:
110 : 0 : break;
111 : : }
112 : :
113 [ # # ]: 0 : if( !pContext )
114 [ # # ]: 0 : pContext = new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName );
115 : :
116 : 0 : return pContext;
117 : : }
118 : :
119 : : //----------------------------------------------------------------------------
120 : : } // namespace rptxml
121 : : // -----------------------------------------------------------------------------
122 : :
123 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|