Line data Source code
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/xmlnmspe.hxx>
23 : #include <xmloff/nmspmap.hxx>
24 : #include <xmloff/xmluconv.hxx>
25 : #include "xmlHelper.hxx"
26 : #include "xmlEnums.hxx"
27 : #include "xmlColumn.hxx"
28 : #include "xmlCondPrtExpr.hxx"
29 : #include "xmlStyleImport.hxx"
30 : #include <connectivity/dbtools.hxx>
31 : #include <tools/debug.hxx>
32 : #include <com/sun/star/report/ReportPrintOption.hpp>
33 : #include "xmlstrings.hrc"
34 : #include "xmlTable.hxx"
35 :
36 :
37 : namespace rptxml
38 : {
39 : using namespace ::xmloff;
40 : using namespace ::com::sun::star;
41 : using namespace ::com::sun::star::uno;
42 : using namespace ::com::sun::star::xml::sax;
43 :
44 0 : sal_uInt16 lcl_getReportPrintOption(const OUString& _sValue)
45 : {
46 0 : sal_uInt16 nRet = report::ReportPrintOption::ALL_PAGES;
47 0 : const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions();
48 0 : SvXMLUnitConverter::convertEnum( nRet, _sValue, aXML_EnumMap );
49 0 : return nRet;
50 : }
51 :
52 :
53 :
54 0 : OXMLSection::OXMLSection( ORptFilter& rImport,
55 : sal_uInt16 nPrfx, const OUString& _sLocalName,
56 : const uno::Reference< xml::sax::XAttributeList > & _xAttrList
57 : ,const uno::Reference< report::XSection >& _xSection
58 : ,sal_Bool _bPageHeader)
59 : :SvXMLImportContext( rImport, nPrfx, _sLocalName )
60 : ,m_xSection(_xSection)
61 0 : ,m_bPageHeader(_bPageHeader)
62 : {
63 :
64 : OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
65 0 : const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
66 0 : const SvXMLTokenMap& rTokenMap = rImport.GetSectionElemTokenMap();
67 :
68 0 : const sal_Int16 nLength = (m_xSection.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
69 0 : static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
70 : try
71 : {
72 0 : for(sal_Int16 i = 0; i < nLength; ++i)
73 : {
74 0 : OUString sLocalName;
75 0 : const OUString sAttrName = _xAttrList->getNameByIndex( i );
76 0 : const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
77 0 : const OUString sValue = _xAttrList->getValueByIndex( i );
78 :
79 0 : switch( rTokenMap.Get( nPrefix, sLocalName ) )
80 : {
81 :
82 : case XML_TOK_PAGE_PRINT_OPTION:
83 0 : if ( _bPageHeader )
84 0 : m_xSection->getReportDefinition()->setPageHeaderOption(lcl_getReportPrintOption(sValue));
85 : else
86 0 : m_xSection->getReportDefinition()->setPageFooterOption(lcl_getReportPrintOption(sValue));
87 0 : break;
88 : case XML_TOK_REPEAT_SECTION:
89 0 : m_xSection->setRepeatSection(sValue == s_sTRUE );
90 0 : break;
91 :
92 : default:
93 : OSL_FAIL("OXMLSection: Unknown attribute!");
94 : }
95 0 : }
96 : }
97 0 : catch(Exception&)
98 : {
99 : OSL_FAIL("Exception catched while filling the section props");
100 : }
101 0 : }
102 :
103 0 : OXMLSection::~OXMLSection()
104 : {
105 0 : }
106 :
107 :
108 0 : SvXMLImportContext* OXMLSection::CreateChildContext(
109 : sal_uInt16 _nPrefix,
110 : const OUString& _rLocalName,
111 : const uno::Reference< xml::sax::XAttributeList > & xAttrList )
112 : {
113 0 : SvXMLImportContext *pContext = 0;
114 0 : ORptFilter& rImport = GetOwnImport();
115 0 : const SvXMLTokenMap& rTokenMap = rImport.GetSectionElemTokenMap();
116 :
117 0 : switch( rTokenMap.Get( _nPrefix, _rLocalName ) )
118 : {
119 : case XML_TOK_TABLE:
120 0 : pContext = new OXMLTable( rImport, _nPrefix, _rLocalName, xAttrList, m_xSection);
121 0 : break;
122 : default:
123 0 : break;
124 : }
125 :
126 0 : if( !pContext )
127 0 : pContext = new SvXMLImportContext( rImport, _nPrefix, _rLocalName );
128 :
129 0 : return pContext;
130 : }
131 :
132 0 : ORptFilter& OXMLSection::GetOwnImport()
133 : {
134 0 : return static_cast<ORptFilter&>(GetImport());
135 : }
136 :
137 :
138 : } // namespace rptxml
139 :
140 :
141 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|