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 "xmlImage.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 "xmlComponent.hxx"
27 : #include "xmlReportElement.hxx"
28 : #include "xmlControlProperty.hxx"
29 : #include "xmlHelper.hxx"
30 : #include <tools/debug.hxx>
31 : #include <unotools/pathoptions.hxx>
32 :
33 : #include <com/sun/star/awt/ImageScaleMode.hpp>
34 :
35 : namespace rptxml
36 : {
37 : using namespace ::com::sun::star;
38 : using namespace ::com::sun::star::uno;
39 : using namespace ::com::sun::star::xml::sax;
40 :
41 :
42 :
43 0 : OXMLImage::OXMLImage( ORptFilter& rImport,
44 : sal_uInt16 nPrfx, const OUString& rLName,
45 : const Reference< XAttributeList > & _xAttrList
46 : ,const Reference< XImageControl > & _xComponent
47 : ,OXMLTable* _pContainer) :
48 0 : OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
49 : {
50 :
51 : OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
52 0 : const SvXMLNamespaceMap& rMap = m_rImport.GetNamespaceMap();
53 0 : const SvXMLTokenMap& rTokenMap = m_rImport.GetControlElemTokenMap();
54 0 : static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
55 :
56 0 : const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
57 : try
58 : {
59 0 : for(sal_Int16 i = 0; i < nLength; ++i)
60 : {
61 0 : OUString sLocalName;
62 0 : const OUString sAttrName = _xAttrList->getNameByIndex( i );
63 0 : const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
64 0 : /* const */ OUString sValue = _xAttrList->getValueByIndex( i );
65 :
66 0 : switch( rTokenMap.Get( nPrefix, sLocalName ) )
67 : {
68 : case XML_TOK_IMAGE_DATA:
69 : {
70 0 : SvtPathOptions aPathOptions;
71 0 : sValue = aPathOptions.SubstituteVariable(sValue);
72 0 : _xComponent->setImageURL(rImport.GetAbsoluteReference( sValue ));
73 : }
74 :
75 0 : break;
76 : case XML_TOK_PRESERVE_IRI:
77 0 : _xComponent->setPreserveIRI(s_sTRUE == sValue);
78 0 : break;
79 : case XML_TOK_SCALE:
80 : {
81 0 : sal_uInt16 nRet = awt::ImageScaleMode::NONE;
82 0 : if ( s_sTRUE == sValue )
83 : {
84 0 : nRet = awt::ImageScaleMode::ANISOTROPIC;
85 : }
86 : else
87 : {
88 0 : const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetImageScaleOptions();
89 0 : SvXMLUnitConverter::convertEnum( nRet, sValue, aXML_EnumMap );
90 : }
91 0 : _xComponent->setScaleMode( nRet );
92 : }
93 0 : break;
94 : case XML_TOK_DATA_FORMULA:
95 0 : _xComponent->setDataField(ORptFilter::convertFormula(sValue));
96 0 : break;
97 : default:
98 0 : break;
99 : }
100 0 : }
101 : }
102 0 : catch(Exception&)
103 : {
104 : OSL_FAIL("Exception catched while filling the image props");
105 : }
106 0 : }
107 :
108 :
109 0 : OXMLImage::~OXMLImage()
110 : {
111 :
112 0 : }
113 :
114 :
115 :
116 : } // namespace rptxml
117 :
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|