LibreOffice Module reportdesign (master)  1
xmlSection.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 "xmlSection.hxx"
20 #include "xmlfilter.hxx"
21 #include <xmloff/xmltoken.hxx>
22 #include <xmloff/xmlnamespace.hxx>
23 #include <xmloff/xmluconv.hxx>
24 #include "xmlHelper.hxx"
25 #include <com/sun/star/report/ReportPrintOption.hpp>
26 #include "xmlTable.hxx"
27 #include <tools/diagnose_ex.h>
28 
29 
30 namespace rptxml
31 {
32  using namespace ::xmloff;
33  using namespace ::com::sun::star;
34  using namespace ::com::sun::star::uno;
35  using namespace ::com::sun::star::xml::sax;
36 
37  static sal_Int16 lcl_getReportPrintOption(std::string_view _sValue)
38  {
39  sal_Int16 nRet = report::ReportPrintOption::ALL_PAGES;
41  (void)SvXMLUnitConverter::convertEnum( nRet, _sValue, aXML_EnumMap );
42  return nRet;
43  }
44 
45 
46 OXMLSection::OXMLSection( ORptFilter& rImport,
47  const uno::Reference< xml::sax::XFastAttributeList > & _xAttrList
48  ,const uno::Reference< report::XSection >& _xSection
49  ,bool _bPageHeader)
50 :SvXMLImportContext( rImport )
51 ,m_xSection(_xSection)
52 {
53 
54  if (!m_xSection.is())
55  return;
56  try
57  {
58  for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
59  {
60  switch( aIter.getToken() )
61  {
62  case XML_ELEMENT(REPORT, XML_PAGE_PRINT_OPTION):
63  if ( _bPageHeader )
64  m_xSection->getReportDefinition()->setPageHeaderOption(lcl_getReportPrintOption(aIter.toView()));
65  else
66  m_xSection->getReportDefinition()->setPageFooterOption(lcl_getReportPrintOption(aIter.toView()));
67  break;
68  case XML_ELEMENT(REPORT, XML_REPEAT_SECTION):
69  m_xSection->setRepeatSection(IsXMLToken(aIter, XML_TRUE));
70  break;
71  default:
72  XMLOFF_WARN_UNKNOWN("reportdesign", aIter);
73  }
74  }
75  }
76  catch(Exception&)
77  {
78  TOOLS_WARN_EXCEPTION( "reportdesign", "Exception caught while filling the section props");
79  }
80 }
81 
82 OXMLSection::~OXMLSection()
83 {
84 }
85 
86 css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLSection::createFastChildContext(
87  sal_Int32 nElement,
88  const Reference< XFastAttributeList > & xAttrList )
89 {
90  css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
91  ORptFilter& rImport = GetOwnImport();
92 
93  switch( nElement )
94  {
96  xContext = new OXMLTable( rImport, xAttrList, m_xSection);
97  break;
98  default:
99  break;
100  }
101 
102  return xContext;
103 }
104 
105 ORptFilter& OXMLSection::GetOwnImport()
106 {
107  return static_cast<ORptFilter&>(GetImport());
108 }
109 
110 
111 } // namespace rptxml
112 
113 
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OXMLSection(const OXMLSection &)=delete
static const SvXMLEnumMapEntry< sal_Int16 > * GetReportPrintOptions()
Definition: xmlHelper.cxx:185
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define TOOLS_WARN_EXCEPTION(area, stream)
static sal_Int16 lcl_getReportPrintOption(std::string_view _sValue)
Definition: xmlSection.cxx:37
XML_TABLE
XML_TRUE
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
#define XML_ELEMENT(prefix, name)
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
TABLE
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo