LibreOffice Module reportdesign (master) 1
xmlMasterFields.cxx
Go to the documentation of this file.
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 "xmlMasterFields.hxx"
21#include "xmlfilter.hxx"
22#include <xmloff/xmltoken.hxx>
25#include "xmlEnums.hxx"
26
27
28namespace rptxml
29{
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::xml::sax;
33
34OXMLMasterFields::OXMLMasterFields( ORptFilter& rImport,
35 const Reference< XFastAttributeList > & _xAttrList
36 ,IMasterDetailFieds* _pReport
37 ) :
38 SvXMLImportContext( rImport )
39,m_pReport(_pReport)
40{
41 OUString sMasterField,sDetailField;
42 for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
43 {
44 OUString sValue = aIter.toString();
45
46 switch( aIter.getToken() )
47 {
48 case XML_ELEMENT(REPORT, XML_MASTER):
49 sMasterField = sValue;
50 break;
51 case XML_ELEMENT(REPORT, XML_DETAIL):
52 sDetailField = sValue;
53 break;
54 default:
55 XMLOFF_WARN_UNKNOWN("reportdesign", aIter);
56 break;
57 }
58 }
59 if ( sDetailField.isEmpty() )
60 sDetailField = sMasterField;
61 if ( !sMasterField.isEmpty() )
62 m_pReport->addMasterDetailPair(::std::pair< OUString,OUString >(sMasterField,sDetailField));
63}
64
65
66OXMLMasterFields::~OXMLMasterFields()
67{
68}
69
70css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLMasterFields::createFastChildContext(
71 sal_Int32 nElement,
72 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
73{
74 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
75
76 switch( nElement )
77 {
79 {
80 GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
81 xContext = new OXMLMasterFields(static_cast<ORptFilter&>(GetImport()),xAttrList ,m_pReport);
82 }
83 break;
84 default:
85 break;
86 }
87
88 return xContext;
89}
90
91
92} // namespace rptxml
93
94
95/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OXMLMasterFields(const OXMLMasterFields &)=delete
REPORT
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_MASTER_DETAIL_FIELD
#define PROGRESS_BAR_STEP
Definition: xmlEnums.hxx:22
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)