LibreOffice Module reportdesign (master) 1
xmlReportElement.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 "xmlReportElement.hxx"
20#include "xmlfilter.hxx"
21#include <xmloff/xmltoken.hxx>
24#include "xmlEnums.hxx"
25#include "xmlComponent.hxx"
26#include "xmlCondPrtExpr.hxx"
28#include <osl/diagnose.h>
30
31namespace rptxml
32{
33 using namespace ::com::sun::star;
34 using namespace report;
35 using namespace uno;
36 using namespace xml::sax;
37
38OXMLReportElement::OXMLReportElement( ORptFilter& rImport,
39 const Reference< XFastAttributeList > & _xAttrList
40 ,const Reference< XReportControlModel > & _xComponent) :
41 SvXMLImportContext( rImport )
42,m_xComponent(_xComponent)
43{
44
45 OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
46
47 try
48 {
49 for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
50 {
51 switch( aIter.getToken() )
52 {
53 case XML_ELEMENT(REPORT, XML_PRINT_WHEN_GROUP_CHANGE):
54 m_xComponent->setPrintWhenGroupChange(IsXMLToken(aIter, XML_TRUE));
55 break;
56 case XML_ELEMENT(REPORT, XML_PRINT_REPEATED_VALUES):
57 m_xComponent->setPrintRepeatedValues(IsXMLToken(aIter, XML_TRUE));
58 break;
59 default:
60 XMLOFF_WARN_UNKNOWN("reportdesign", aIter);
61 break;
62 }
63 }
64 }
65 catch(Exception&)
66 {
67 TOOLS_WARN_EXCEPTION( "reportdesign", "Exception caught while filling the report definition props");
68 }
69}
70
71
72OXMLReportElement::~OXMLReportElement()
73{
74}
75
76css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLReportElement::createFastChildContext(
77 sal_Int32 nElement,
78 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
79{
80 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
81 ORptFilter& rImport = GetOwnImport();
82
83 switch( nElement )
84 {
86 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
87 xContext = new OXMLComponent( rImport,xAttrList,m_xComponent);
88 break;
90 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
91 xContext = new OXMLCondPrtExpr( rImport,xAttrList,m_xComponent);
92 break;
94 {
95 uno::Reference< report::XFormatCondition > xNewCond = m_xComponent->createFormatCondition();
96 m_xComponent->insertByIndex(m_xComponent->getCount(),uno::Any(xNewCond));
97 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
98 xContext = new OXMLFormatCondition( rImport,xAttrList,xNewCond);
99 }
100 break;
101 default:
102 break;
103 }
104
105 return xContext;
106}
107
108ORptFilter& OXMLReportElement::GetOwnImport()
109{
110 return static_cast<ORptFilter&>(GetImport());
111}
112
113} // namespace rptxml
114
115
116/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OXMLReportElement(const OXMLReportElement &)=delete
#define TOOLS_WARN_EXCEPTION(area, stream)
REPORT
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_REPORT_COMPONENT
XML_TRUE
XML_CONDITIONAL_PRINT_EXPRESSION
XML_FORMAT_CONDITION
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
#define PROGRESS_BAR_STEP
Definition: xmlEnums.hxx:22
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)