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 : :
29 : :
30 : : #include "XMLFillBitmapSizePropertyHandler.hxx"
31 : : #include <rtl/ustrbuf.hxx>
32 : : #include <com/sun/star/uno/Any.hxx>
33 : : #include <comphelper/extract.hxx>
34 : : #include <sax/tools/converter.hxx>
35 : : #include <xmloff/xmluconv.hxx>
36 : :
37 : : using namespace ::com::sun::star;
38 : : using namespace ::com::sun::star::uno;
39 : : using ::rtl::OUString;
40 : : using ::rtl::OUStringBuffer;
41 : :
42 : :
43 : 744 : XMLFillBitmapSizePropertyHandler::XMLFillBitmapSizePropertyHandler()
44 : : {
45 : 744 : }
46 : :
47 : 734 : XMLFillBitmapSizePropertyHandler::~XMLFillBitmapSizePropertyHandler()
48 : : {
49 [ - + ]: 1468 : }
50 : :
51 : 94 : sal_Bool XMLFillBitmapSizePropertyHandler::importXML(
52 : : const OUString& rStrImpValue,
53 : : Any& rValue,
54 : : const SvXMLUnitConverter& rUnitConverter ) const
55 : : {
56 : : sal_Int32 nValue;
57 : : sal_Bool bRet;
58 : :
59 [ - + ]: 94 : if( rStrImpValue.indexOf( sal_Unicode('%') ) != -1 )
60 : : {
61 [ # # ]: 0 : bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
62 : 0 : nValue *= -1;
63 : : }
64 : : else
65 : : {
66 [ + - ]: 94 : bRet = rUnitConverter.convertMeasureToCore( nValue, rStrImpValue );
67 : : }
68 : :
69 [ + - ]: 94 : if( bRet )
70 [ + - ]: 94 : rValue <<= nValue;
71 : :
72 : 94 : return bRet;
73 : : }
74 : :
75 : 0 : sal_Bool XMLFillBitmapSizePropertyHandler::exportXML(
76 : : OUString& rStrExpValue,
77 : : const Any& rValue,
78 : : const SvXMLUnitConverter& rUnitConverter ) const
79 : : {
80 : 0 : OUStringBuffer aOut;
81 : :
82 : 0 : sal_Int32 nValue = 0;
83 [ # # ]: 0 : if( rValue >>= nValue )
84 : : {
85 [ # # ]: 0 : if( nValue < 0 )
86 : : {
87 [ # # ]: 0 : ::sax::Converter::convertPercent( aOut, -nValue );
88 : : }
89 : : else
90 : : {
91 [ # # ]: 0 : rUnitConverter.convertMeasureToXML( aOut, nValue );
92 : : }
93 : :
94 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
95 : 0 : return sal_True;
96 : : }
97 : :
98 : 0 : return sal_False;
99 : : }
100 : :
101 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|