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