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