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 "xmlFormattedField.hxx"
20 : #include "xmlfilter.hxx"
21 : #include <xmloff/xmltoken.hxx>
22 : #include <xmloff/xmlnmspe.hxx>
23 : #include <xmloff/nmspmap.hxx>
24 : #include "xmlEnums.hxx"
25 : #include "xmlControlProperty.hxx"
26 : #include "xmlHelper.hxx"
27 : #include <xmloff/xmluconv.hxx>
28 : #include "xmlReportElement.hxx"
29 : #include "xmlComponent.hxx"
30 : #include <tools/debug.hxx>
31 :
32 :
33 : namespace rptxml
34 : {
35 : using namespace ::com::sun::star;
36 : using namespace xml::sax;
37 : DBG_NAME( rpt_OXMLFormattedField )
38 :
39 0 : OXMLFormattedField::OXMLFormattedField( ORptFilter& rImport,
40 : sal_uInt16 nPrfx, const ::rtl::OUString& rLName
41 : ,const uno::Reference< xml::sax::XAttributeList > & _xAttrList
42 : ,const uno::Reference< XFormattedField > & _xComponent
43 : ,OXMLTable* _pContainer
44 : ,bool _bPageCount) :
45 0 : OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
46 : {
47 : DBG_CTOR( rpt_OXMLFormattedField,NULL);
48 : OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
49 0 : const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
50 0 : const SvXMLTokenMap& rTokenMap = rImport.GetControlElemTokenMap();
51 :
52 0 : const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
53 : try
54 : {
55 0 : for(sal_Int16 i = 0; i < nLength; ++i)
56 : {
57 0 : ::rtl::OUString sLocalName;
58 0 : const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
59 0 : const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
60 0 : const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
61 :
62 0 : switch( rTokenMap.Get( nPrefix, sLocalName ) )
63 : {
64 : case XML_TOK_DATA_FORMULA:
65 0 : _xComponent->setDataField(ORptFilter::convertFormula(sValue));
66 0 : break;
67 : case XML_TOK_SELECT_PAGE:
68 : {
69 0 : static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("rpt:PageNumber()"));
70 0 : _xComponent->setDataField(s_sPageNumber);
71 : }
72 0 : break;
73 : default:
74 0 : break;
75 : }
76 0 : }
77 0 : if ( _bPageCount )
78 : {
79 0 : static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("rpt:PageCount()"));
80 0 : _xComponent->setDataField(s_sPageNumber);
81 : }
82 : }
83 0 : catch(Exception&)
84 : {
85 : OSL_FAIL("Exception catched while filling the report definition props");
86 : }
87 0 : }
88 : // -----------------------------------------------------------------------------
89 0 : OXMLFormattedField::~OXMLFormattedField()
90 : {
91 : DBG_DTOR( rpt_OXMLFormattedField,NULL);
92 0 : }
93 : // -----------------------------------------------------------------------------
94 : //----------------------------------------------------------------------------
95 : } // namespace rptxml
96 : // -----------------------------------------------------------------------------
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|