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