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 "xmlCondPrtExpr.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 "xmlComponent.hxx"
32 #ifndef REPORTDESIGN_SHARED_XMLSTRINGS_HRC
33 #include "xmlstrings.hrc"
34 #endif
35 #include <tools/debug.hxx>
36 
37 namespace rptxml
38 {
39 	using namespace ::com::sun::star;
40 	using namespace report;
41 	using namespace uno;
42 	using namespace xml::sax;
DBG_NAME(rpt_OXMLCondPrtExpr)43 DBG_NAME( rpt_OXMLCondPrtExpr )
44 
45 OXMLCondPrtExpr::OXMLCondPrtExpr( ORptFilter& _rImport,
46 				sal_uInt16 nPrfx
47                 ,const ::rtl::OUString& rLName
48                 ,const uno::Reference< xml::sax::XAttributeList > & _xAttrList
49 				,const Reference< XPropertySet > & _xComponent ) :
50 	SvXMLImportContext( _rImport, nPrfx, rLName )
51 ,m_xComponent(_xComponent)
52 {
53     DBG_CTOR( rpt_OXMLCondPrtExpr,NULL);
54 
55 	OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
56     const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap();
57 	const SvXMLTokenMap& rTokenMap = _rImport.GetFunctionElemTokenMap();
58     const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
59     try
60 	{
61 	    for(sal_Int16 i = 0; i < nLength; ++i)
62 	    {
63 		    ::rtl::OUString sLocalName;
64 		    const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
65 		    const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
66 		    const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
67 
68 			switch( rTokenMap.Get( nPrefix, sLocalName ) )
69 			{
70                 case XML_TOK_FUNCTION_FORMULA:
71                     m_xComponent->setPropertyValue(PROPERTY_CONDITIONALPRINTEXPRESSION,uno::makeAny(ORptFilter::convertFormula(sValue)));
72 					break;
73                 default:
74                     break;
75             }
76 
77 	    }
78     }
79 	catch(const Exception&)
80 	{
81 		OSL_ENSURE(0,"Exception catched while putting Function props!");
82 	}
83 }
84 // -----------------------------------------------------------------------------
85 
~OXMLCondPrtExpr()86 OXMLCondPrtExpr::~OXMLCondPrtExpr()
87 {
88 
89     DBG_DTOR( rpt_OXMLCondPrtExpr,NULL);
90 }
91 // -----------------------------------------------------------------------------
92 // -----------------------------------------------------------------------------
Characters(const::rtl::OUString & rChars)93 void OXMLCondPrtExpr::Characters( const ::rtl::OUString& rChars )
94 {
95 	m_xComponent->setPropertyValue(PROPERTY_CONDITIONALPRINTEXPRESSION,makeAny(rChars));
96 }
97 //----------------------------------------------------------------------------
98 } // namespace rptxml
99 // -----------------------------------------------------------------------------
100