19e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
39e0e4191SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49e0e4191SAndrew Rist * or more contributor license agreements. See the NOTICE file
59e0e4191SAndrew Rist * distributed with this work for additional information
69e0e4191SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79e0e4191SAndrew Rist * to you under the Apache License, Version 2.0 (the
89e0e4191SAndrew Rist * "License"); you may not use this file except in compliance
99e0e4191SAndrew Rist * with the License. You may obtain a copy of the License at
109e0e4191SAndrew Rist *
119e0e4191SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
129e0e4191SAndrew Rist *
139e0e4191SAndrew Rist * Unless required by applicable law or agreed to in writing,
149e0e4191SAndrew Rist * software distributed under the License is distributed on an
159e0e4191SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169e0e4191SAndrew Rist * KIND, either express or implied. See the License for the
179e0e4191SAndrew Rist * specific language governing permissions and limitations
189e0e4191SAndrew Rist * under the License.
199e0e4191SAndrew Rist *
209e0e4191SAndrew Rist *************************************************************/
219e0e4191SAndrew Rist
229e0e4191SAndrew Rist
23b63233d8Sdamjan #include "precompiled_rptxml.hxx"
24cdf0e10cSrcweir #include "xmlFormattedField.hxx"
25cdf0e10cSrcweir #include "xmlfilter.hxx"
26cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
27cdf0e10cSrcweir #include <xmloff/xmlnmspe.hxx>
28cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
29cdf0e10cSrcweir #include "xmlEnums.hxx"
30cdf0e10cSrcweir #include "xmlControlProperty.hxx"
31cdf0e10cSrcweir #include "xmlHelper.hxx"
32cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
33cdf0e10cSrcweir #include "xmlReportElement.hxx"
34cdf0e10cSrcweir #include "xmlComponent.hxx"
35cdf0e10cSrcweir #include <tools/debug.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir
38cdf0e10cSrcweir namespace rptxml
39cdf0e10cSrcweir {
40cdf0e10cSrcweir using namespace ::com::sun::star;
41cdf0e10cSrcweir using namespace xml::sax;
DBG_NAME(rpt_OXMLFormattedField)42cdf0e10cSrcweir DBG_NAME( rpt_OXMLFormattedField )
43cdf0e10cSrcweir
44cdf0e10cSrcweir OXMLFormattedField::OXMLFormattedField( ORptFilter& rImport,
45cdf0e10cSrcweir sal_uInt16 nPrfx, const ::rtl::OUString& rLName
46cdf0e10cSrcweir ,const uno::Reference< xml::sax::XAttributeList > & _xAttrList
47cdf0e10cSrcweir ,const uno::Reference< XFormattedField > & _xComponent
48cdf0e10cSrcweir ,OXMLTable* _pContainer
49cdf0e10cSrcweir ,bool _bPageCount) :
50cdf0e10cSrcweir OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir DBG_CTOR( rpt_OXMLFormattedField,NULL);
53cdf0e10cSrcweir OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
54cdf0e10cSrcweir const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
55cdf0e10cSrcweir const SvXMLTokenMap& rTokenMap = rImport.GetControlElemTokenMap();
56cdf0e10cSrcweir
57cdf0e10cSrcweir const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
58cdf0e10cSrcweir try
59cdf0e10cSrcweir {
60cdf0e10cSrcweir for(sal_Int16 i = 0; i < nLength; ++i)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir ::rtl::OUString sLocalName;
63cdf0e10cSrcweir const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
64cdf0e10cSrcweir const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
65cdf0e10cSrcweir const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
66cdf0e10cSrcweir
67cdf0e10cSrcweir switch( rTokenMap.Get( nPrefix, sLocalName ) )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir case XML_TOK_DATA_FORMULA:
70cdf0e10cSrcweir _xComponent->setDataField(ORptFilter::convertFormula(sValue));
71cdf0e10cSrcweir break;
72cdf0e10cSrcweir case XML_TOK_SELECT_PAGE:
73cdf0e10cSrcweir {
74cdf0e10cSrcweir static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("rpt:PageNumber()"));
75cdf0e10cSrcweir _xComponent->setDataField(s_sPageNumber);
76cdf0e10cSrcweir }
77cdf0e10cSrcweir break;
78cdf0e10cSrcweir default:
79cdf0e10cSrcweir break;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir }
82cdf0e10cSrcweir if ( _bPageCount )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("rpt:PageCount()"));
85cdf0e10cSrcweir _xComponent->setDataField(s_sPageNumber);
86cdf0e10cSrcweir }
87cdf0e10cSrcweir }
88cdf0e10cSrcweir catch(Exception&)
89cdf0e10cSrcweir {
90cdf0e10cSrcweir OSL_ENSURE(0,"Exception catched while filling the report definition props");
91cdf0e10cSrcweir }
92cdf0e10cSrcweir }
93cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OXMLFormattedField()94cdf0e10cSrcweir OXMLFormattedField::~OXMLFormattedField()
95cdf0e10cSrcweir {
96cdf0e10cSrcweir DBG_DTOR( rpt_OXMLFormattedField,NULL);
97cdf0e10cSrcweir }
98cdf0e10cSrcweir // -----------------------------------------------------------------------------
99cdf0e10cSrcweir //----------------------------------------------------------------------------
100cdf0e10cSrcweir } // namespace rptxml
101cdf0e10cSrcweir // -----------------------------------------------------------------------------
102