Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #include "xmlFormatCondition.hxx"
20 : #include "xmlfilter.hxx"
21 : #include <xmloff/xmltoken.hxx>
22 : #include <xmloff/xmlnmspe.hxx>
23 : #include <xmloff/nmspmap.hxx>
24 : #include <xmloff/xmluconv.hxx>
25 : #include "xmlEnums.hxx"
26 : #include "xmlHelper.hxx"
27 : #include <com/sun/star/report/XReportControlFormat.hpp>
28 : #include <comphelper/genericpropertyset.hxx>
29 : #include <com/sun/star/awt/FontDescriptor.hpp>
30 : #include <com/sun/star/beans/PropertyAttribute.hpp>
31 : #include "xmlstrings.hrc"
32 : #include "xmlStyleImport.hxx"
33 : #include <tools/debug.hxx>
34 :
35 : namespace rptxml
36 : {
37 : using namespace ::comphelper;
38 : using namespace ::com::sun::star;
39 : using namespace ::com::sun::star::report;
40 : using namespace ::com::sun::star::uno;
41 : using namespace ::com::sun::star::xml::sax;
42 : using namespace ::com::sun::star::beans;
43 :
44 : DBG_NAME( rpt_OXMLFormatCondition )
45 :
46 0 : OXMLFormatCondition::OXMLFormatCondition( ORptFilter& rImport,
47 : sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
48 : const Reference< XAttributeList > & _xAttrList
49 : ,const Reference< XFormatCondition > & _xComponent ) :
50 : SvXMLImportContext( rImport, nPrfx, rLName )
51 : ,m_rImport(rImport)
52 0 : ,m_xComponent(_xComponent)
53 : {
54 : DBG_CTOR( rpt_OXMLFormatCondition,NULL);
55 :
56 : OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
57 0 : const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
58 0 : const SvXMLTokenMap& rTokenMap = rImport.GetFormatElemTokenMap();
59 0 : static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
60 0 : const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
61 : try
62 : {
63 0 : for(sal_Int16 i = 0; i < nLength; ++i)
64 : {
65 0 : ::rtl::OUString sLocalName;
66 0 : const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
67 0 : const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
68 0 : const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
69 :
70 0 : switch( rTokenMap.Get( nPrefix, sLocalName ) )
71 : {
72 : case XML_TOK_ENABLED:
73 0 : m_xComponent->setEnabled(sValue == s_sTRUE);
74 0 : break;
75 : case XML_TOK_FORMULA:
76 0 : m_xComponent->setFormula(ORptFilter::convertFormula(sValue));
77 0 : break;
78 : case XML_TOK_FORMAT_STYLE_NAME:
79 0 : m_sStyleName = sValue;
80 0 : break;
81 : default:
82 0 : break;
83 : }
84 0 : }
85 : }
86 0 : catch(Exception&)
87 : {
88 : OSL_FAIL("Exception catched while filling the report definition props");
89 : }
90 0 : }
91 : // -----------------------------------------------------------------------------
92 :
93 0 : OXMLFormatCondition::~OXMLFormatCondition()
94 : {
95 :
96 : DBG_DTOR( rpt_OXMLFormatCondition,NULL);
97 0 : }
98 : // -----------------------------------------------------------------------------
99 0 : void OXMLFormatCondition::EndElement()
100 : {
101 0 : OXMLHelper::copyStyleElements(m_rImport.isOldFormat(),m_sStyleName,GetImport().GetAutoStyles(),m_xComponent.get());
102 0 : }
103 : //----------------------------------------------------------------------------
104 : } // namespace rptxml
105 : // -----------------------------------------------------------------------------
106 :
107 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|