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