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