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