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 0 : OXMLFormatCondition::OXMLFormatCondition( ORptFilter& rImport,
45 : sal_uInt16 nPrfx, const OUString& rLName,
46 : const Reference< XAttributeList > & _xAttrList
47 : ,const Reference< XFormatCondition > & _xComponent ) :
48 : SvXMLImportContext( rImport, nPrfx, rLName )
49 : ,m_rImport(rImport)
50 0 : ,m_xComponent(_xComponent)
51 : {
52 :
53 : OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
54 0 : const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
55 0 : const SvXMLTokenMap& rTokenMap = rImport.GetFormatElemTokenMap();
56 0 : static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
57 0 : const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
58 : try
59 : {
60 0 : for(sal_Int16 i = 0; i < nLength; ++i)
61 : {
62 0 : OUString sLocalName;
63 0 : const OUString sAttrName = _xAttrList->getNameByIndex( i );
64 0 : const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
65 0 : const OUString sValue = _xAttrList->getValueByIndex( i );
66 :
67 0 : switch( rTokenMap.Get( nPrefix, sLocalName ) )
68 : {
69 : case XML_TOK_ENABLED:
70 0 : m_xComponent->setEnabled(sValue == s_sTRUE);
71 0 : break;
72 : case XML_TOK_FORMULA:
73 0 : m_xComponent->setFormula(ORptFilter::convertFormula(sValue));
74 0 : break;
75 : case XML_TOK_FORMAT_STYLE_NAME:
76 0 : m_sStyleName = sValue;
77 0 : break;
78 : default:
79 0 : break;
80 : }
81 0 : }
82 : }
83 0 : catch(Exception&)
84 : {
85 : OSL_FAIL("Exception catched while filling the report definition props");
86 : }
87 0 : }
88 :
89 :
90 0 : OXMLFormatCondition::~OXMLFormatCondition()
91 : {
92 0 : }
93 :
94 0 : void OXMLFormatCondition::EndElement()
95 : {
96 0 : OXMLHelper::copyStyleElements(m_rImport.isOldFormat(),m_sStyleName,GetImport().GetAutoStyles(),m_xComponent.get());
97 0 : }
98 :
99 : } // namespace rptxml
100 :
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|