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 : : #include <xmloff/xmltoken.hxx>
30 : : #include <xmloff/xmluconv.hxx>
31 : : #include <sax/tools/converter.hxx>
32 : : #include <rtl/ustrbuf.hxx>
33 : : #include <com/sun/star/uno/Any.hxx>
34 : : #include "XMLBitmapRepeatOffsetPropertyHandler.hxx"
35 : :
36 : : using namespace ::com::sun::star;
37 : : using namespace ::com::sun::star::uno;
38 : : using ::rtl::OUString;
39 : : using ::rtl::OUStringBuffer;
40 : :
41 : :
42 : : using ::xmloff::token::GetXMLToken;
43 : : using ::xmloff::token::XML_VERTICAL;
44 : : using ::xmloff::token::XML_HORIZONTAL;
45 : :
46 : :
47 : 1488 : XMLBitmapRepeatOffsetPropertyHandler::XMLBitmapRepeatOffsetPropertyHandler( sal_Bool bX )
48 : : : mbX( bX ),
49 [ + - ]: 1488 : msVertical( GetXMLToken(XML_VERTICAL) ),
50 [ + - ]: 2976 : msHorizontal( GetXMLToken(XML_HORIZONTAL) )
51 : : {
52 : 1488 : }
53 : :
54 : 1468 : XMLBitmapRepeatOffsetPropertyHandler::~XMLBitmapRepeatOffsetPropertyHandler()
55 : : {
56 [ - + ]: 2936 : }
57 : :
58 : 0 : sal_Bool XMLBitmapRepeatOffsetPropertyHandler::importXML(
59 : : const OUString& rStrImpValue,
60 : : Any& rValue,
61 : : const SvXMLUnitConverter& ) const
62 : : {
63 [ # # ]: 0 : SvXMLTokenEnumerator aTokenEnum( rStrImpValue );
64 : 0 : OUString aToken;
65 [ # # ][ # # ]: 0 : if( aTokenEnum.getNextToken( aToken ) )
66 : : {
67 : : sal_Int32 nValue;
68 [ # # ][ # # ]: 0 : if (::sax::Converter::convertPercent( nValue, aToken ))
69 : : {
70 [ # # ][ # # ]: 0 : if( aTokenEnum.getNextToken( aToken ) )
71 : : {
72 [ # # ][ # # ]: 0 : if( ( mbX && ( aToken == msHorizontal ) ) || ( !mbX && ( aToken == msVertical ) ) )
[ # # ][ # # ]
[ # # ]
73 : : {
74 [ # # ]: 0 : rValue <<= nValue;
75 : 0 : return sal_True;
76 : : }
77 : : }
78 : : }
79 : : }
80 : :
81 : 0 : return sal_False;
82 : :
83 : : }
84 : :
85 : 0 : sal_Bool XMLBitmapRepeatOffsetPropertyHandler::exportXML(
86 : : OUString& rStrExpValue,
87 : : const Any& rValue,
88 : : const SvXMLUnitConverter& ) const
89 : : {
90 : 0 : OUStringBuffer aOut;
91 : :
92 : 0 : sal_Int32 nValue = 0;
93 [ # # ]: 0 : if( rValue >>= nValue )
94 : : {
95 [ # # ]: 0 : ::sax::Converter::convertPercent( aOut, nValue );
96 [ # # ]: 0 : aOut.append( sal_Unicode( ' ' ) );
97 [ # # ][ # # ]: 0 : aOut.append( mbX ? msHorizontal : msVertical );
98 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
99 : :
100 : 0 : return sal_True;
101 : : }
102 : :
103 : 0 : return sal_False;
104 : : }
105 : :
106 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|