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 "xmlFormatCondition.hxx"
25 #include "xmlfilter.hxx"
26 #include <xmloff/xmltoken.hxx>
27 #include <xmloff/xmlnmspe.hxx>
28 #include <xmloff/nmspmap.hxx>
29 #include <xmloff/xmluconv.hxx>
30 #include "xmlEnums.hxx"
31 #include "xmlHelper.hxx"
32 #include <com/sun/star/report/XReportControlFormat.hpp>
33 #include <comphelper/genericpropertyset.hxx>
34 #include <com/sun/star/awt/FontDescriptor.hpp>
35 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_
36 #include <com/sun/star/beans/PropertyAttribute.hpp>
37 #endif
38 #ifndef RPT_SHARED_XMLSTRINGS_HRC
39 #include "xmlstrings.hrc"
40 #endif
41 #include "xmlStyleImport.hxx"
42 #include <tools/debug.hxx>
43
44 namespace rptxml
45 {
46 using namespace ::comphelper;
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::report;
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::xml::sax;
51 using namespace ::com::sun::star::beans;
52
DBG_NAME(rpt_OXMLFormatCondition)53 DBG_NAME( rpt_OXMLFormatCondition )
54
55 OXMLFormatCondition::OXMLFormatCondition( ORptFilter& rImport,
56 sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
57 const Reference< XAttributeList > & _xAttrList
58 ,const Reference< XFormatCondition > & _xComponent ) :
59 SvXMLImportContext( rImport, nPrfx, rLName )
60 ,m_rImport(rImport)
61 ,m_xComponent(_xComponent)
62 {
63 DBG_CTOR( rpt_OXMLFormatCondition,NULL);
64
65 OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
66 const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
67 const SvXMLTokenMap& rTokenMap = rImport.GetFormatElemTokenMap();
68 static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
69 const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
70 try
71 {
72 for(sal_Int16 i = 0; i < nLength; ++i)
73 {
74 ::rtl::OUString sLocalName;
75 const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
76 const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
77 const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
78
79 switch( rTokenMap.Get( nPrefix, sLocalName ) )
80 {
81 case XML_TOK_ENABLED:
82 m_xComponent->setEnabled(sValue == s_sTRUE);
83 break;
84 case XML_TOK_FORMULA:
85 m_xComponent->setFormula(ORptFilter::convertFormula(sValue));
86 break;
87 case XML_TOK_FORMAT_STYLE_NAME:
88 m_sStyleName = sValue;
89 break;
90 default:
91 break;
92 }
93 }
94 }
95 catch(Exception&)
96 {
97 OSL_ENSURE(0,"Exception catched while filling the report definition props");
98 }
99 }
100 // -----------------------------------------------------------------------------
101
~OXMLFormatCondition()102 OXMLFormatCondition::~OXMLFormatCondition()
103 {
104
105 DBG_DTOR( rpt_OXMLFormatCondition,NULL);
106 }
107 // -----------------------------------------------------------------------------
EndElement()108 void OXMLFormatCondition::EndElement()
109 {
110 OXMLHelper::copyStyleElements(m_rImport.isOldFormat(),m_sStyleName,GetImport().GetAutoStyles(),m_xComponent.get());
111 }
112 //----------------------------------------------------------------------------
113 } // namespace rptxml
114 // -----------------------------------------------------------------------------
115