LibreOffice Module reportdesign (master)  1
xmlCondPrtExpr.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 "xmlCondPrtExpr.hxx"
20 #include "xmlfilter.hxx"
21 #include <xmloff/xmltoken.hxx>
22 #include <xmloff/xmlnamespace.hxx>
23 #include <strings.hxx>
24 #include <osl/diagnose.h>
25 #include <tools/diagnose_ex.h>
26 
27 namespace rptxml
28 {
29  using namespace ::com::sun::star;
30  using namespace report;
31  using namespace uno;
32  using namespace xml::sax;
33 
34 OXMLCondPrtExpr::OXMLCondPrtExpr( ORptFilter& _rImport
35  ,const uno::Reference< xml::sax::XFastAttributeList > & _xAttrList
36  ,const Reference< XPropertySet > & _xComponent ) :
37  SvXMLImportContext( _rImport )
38 ,m_xComponent(_xComponent)
39 {
40  OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
41  try
42  {
43  for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
44  {
45  switch( aIter.getToken() )
46  {
47  case XML_ELEMENT(REPORT, XML_FORMULA):
48  m_xComponent->setPropertyValue(PROPERTY_CONDITIONALPRINTEXPRESSION,uno::Any(ORptFilter::convertFormula(aIter.toString())));
49  break;
50  default:
51  XMLOFF_WARN_UNKNOWN("reportdesign", aIter);
52  break;
53  }
54 
55  }
56  }
57  catch(const Exception&)
58  {
59  TOOLS_WARN_EXCEPTION( "reportdesign", "Exception caught while putting Function props!");
60  }
61 }
62 
63 
65 {
66 }
67 
68 
69 void OXMLCondPrtExpr::characters( const OUString& rChars )
70 {
71  m_aCharBuffer.append(rChars);
72 }
73 
75 {
76  if (m_aCharBuffer.getLength())
77  m_xComponent->setPropertyValue(PROPERTY_CONDITIONALPRINTEXPRESSION,Any(m_aCharBuffer.makeStringAndClear()));
78 }
79 
80 } // namespace rptxml
81 
82 
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUStringBuffer m_aCharBuffer
css::uno::Reference< css::beans::XPropertySet > m_xComponent
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual ~OXMLCondPrtExpr() override
#define XMLOFF_WARN_UNKNOWN(area, rIter)
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
css::uno::Reference< css::report::XReportComponent > m_xComponent
#define TOOLS_WARN_EXCEPTION(area, stream)
OXMLCondPrtExpr(const OXMLCondPrtExpr &)=delete
bool setPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
#define XML_ELEMENT(prefix, name)
virtual void SAL_CALL characters(const OUString &rChars) override
#define PROPERTY_CONDITIONALPRINTEXPRESSION
Definition: strings.hxx:108
OUString toString(OptionInfo const *info)