Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "xmlImage.hxx"
29 : : #include "xmlfilter.hxx"
30 : : #include <xmloff/xmltoken.hxx>
31 : : #include <xmloff/xmlnmspe.hxx>
32 : : #include <xmloff/nmspmap.hxx>
33 : : #include <xmloff/xmluconv.hxx>
34 : : #include "xmlEnums.hxx"
35 : : #include "xmlComponent.hxx"
36 : : #include "xmlReportElement.hxx"
37 : : #include "xmlControlProperty.hxx"
38 : : #include "xmlHelper.hxx"
39 : : #include <tools/debug.hxx>
40 : : #include <unotools/pathoptions.hxx>
41 : :
42 : : #include <comphelper/componentcontext.hxx>
43 : : #include <com/sun/star/awt/ImageScaleMode.hpp>
44 : :
45 : : namespace rptxml
46 : : {
47 : : using namespace ::com::sun::star;
48 : : using namespace ::com::sun::star::uno;
49 : : using namespace ::com::sun::star::xml::sax;
50 : : DBG_NAME( rpt_OXMLImage )
51 : :
52 : :
53 : : // -----------------------------------------------------------------------------
54 : 0 : OXMLImage::OXMLImage( ORptFilter& rImport,
55 : : sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
56 : : const Reference< XAttributeList > & _xAttrList
57 : : ,const Reference< XImageControl > & _xComponent
58 : : ,OXMLTable* _pContainer) :
59 [ # # ]: 0 : OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
60 : : {
61 : : DBG_CTOR( rpt_OXMLImage,NULL);
62 : :
63 : : OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
64 : 0 : const SvXMLNamespaceMap& rMap = m_rImport.GetNamespaceMap();
65 [ # # ]: 0 : const SvXMLTokenMap& rTokenMap = m_rImport.GetControlElemTokenMap();
66 [ # # ][ # # ]: 0 : static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
[ # # ][ # # ]
67 : :
68 [ # # ][ # # ]: 0 : const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
[ # # ]
69 : : try
70 : : {
71 [ # # ]: 0 : for(sal_Int16 i = 0; i < nLength; ++i)
72 : : {
73 : 0 : ::rtl::OUString sLocalName;
74 [ # # ][ # # ]: 0 : const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
75 [ # # ]: 0 : const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
76 [ # # ][ # # ]: 0 : /* const */ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
77 : :
78 [ # # ][ # # : 0 : switch( rTokenMap.Get( nPrefix, sLocalName ) )
# # # ]
79 : : {
80 : : case XML_TOK_IMAGE_DATA:
81 : : {
82 [ # # ]: 0 : SvtPathOptions aPathOptions;
83 [ # # ][ # # ]: 0 : sValue = aPathOptions.SubstituteVariable(sValue);
[ # # ][ # # ]
[ # # ]
84 [ # # ][ # # ]: 0 : _xComponent->setImageURL(rImport.GetAbsoluteReference( sValue ));
[ # # ][ # # ]
85 : : }
86 : :
87 : 0 : break;
88 : : case XML_TOK_PRESERVE_IRI:
89 [ # # ][ # # ]: 0 : _xComponent->setPreserveIRI(s_sTRUE == sValue);
90 : 0 : break;
91 : : case XML_TOK_SCALE:
92 : : {
93 : 0 : sal_uInt16 nRet = awt::ImageScaleMode::None;
94 [ # # ]: 0 : if ( s_sTRUE == sValue )
95 : : {
96 : 0 : nRet = awt::ImageScaleMode::Anisotropic;
97 : : }
98 : : else
99 : : {
100 [ # # ]: 0 : const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetImageScaleOptions();
101 [ # # ]: 0 : SvXMLUnitConverter::convertEnum( nRet, sValue, aXML_EnumMap );
102 : : }
103 [ # # ][ # # ]: 0 : _xComponent->setScaleMode( nRet );
104 : : }
105 : 0 : break;
106 : : case XML_TOK_DATA_FORMULA:
107 [ # # ][ # # ]: 0 : _xComponent->setDataField(ORptFilter::convertFormula(sValue));
[ # # ]
108 : 0 : break;
109 : : default:
110 : 0 : break;
111 : : }
112 [ # # ]: 0 : }
113 : : }
114 [ # # ]: 0 : catch(Exception&)
115 : : {
116 : : OSL_FAIL("Exception catched while filling the image props");
117 : : }
118 : 0 : }
119 : : // -----------------------------------------------------------------------------
120 : :
121 : 0 : OXMLImage::~OXMLImage()
122 : : {
123 : :
124 : : DBG_DTOR( rpt_OXMLImage,NULL);
125 [ # # ]: 0 : }
126 : : // -----------------------------------------------------------------------------
127 : :
128 : : //----------------------------------------------------------------------------
129 : : } // namespace rptxml
130 : : // -----------------------------------------------------------------------------
131 : :
132 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|