Bump for 3.6-28
[LibreOffice.git] / xmloff / source / style / XMLBitmapRepeatOffsetPropertyHandler.cxx
blob567b17ba335631648ce1cf2acd6993a3a362fec3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
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"
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::uno;
38 using ::rtl::OUString;
39 using ::rtl::OUStringBuffer;
42 using ::xmloff::token::GetXMLToken;
43 using ::xmloff::token::XML_VERTICAL;
44 using ::xmloff::token::XML_HORIZONTAL;
47 XMLBitmapRepeatOffsetPropertyHandler::XMLBitmapRepeatOffsetPropertyHandler( sal_Bool bX )
48 : mbX( bX ),
49 msVertical( GetXMLToken(XML_VERTICAL) ),
50 msHorizontal( GetXMLToken(XML_HORIZONTAL) )
54 XMLBitmapRepeatOffsetPropertyHandler::~XMLBitmapRepeatOffsetPropertyHandler()
58 sal_Bool XMLBitmapRepeatOffsetPropertyHandler::importXML(
59 const OUString& rStrImpValue,
60 Any& rValue,
61 const SvXMLUnitConverter& ) const
63 SvXMLTokenEnumerator aTokenEnum( rStrImpValue );
64 OUString aToken;
65 if( aTokenEnum.getNextToken( aToken ) )
67 sal_Int32 nValue;
68 if (::sax::Converter::convertPercent( nValue, aToken ))
70 if( aTokenEnum.getNextToken( aToken ) )
72 if( ( mbX && ( aToken == msHorizontal ) ) || ( !mbX && ( aToken == msVertical ) ) )
74 rValue <<= nValue;
75 return sal_True;
81 return sal_False;
85 sal_Bool XMLBitmapRepeatOffsetPropertyHandler::exportXML(
86 OUString& rStrExpValue,
87 const Any& rValue,
88 const SvXMLUnitConverter& ) const
90 OUStringBuffer aOut;
92 sal_Int32 nValue = 0;
93 if( rValue >>= nValue )
95 ::sax::Converter::convertPercent( aOut, nValue );
96 aOut.append( sal_Unicode( ' ' ) );
97 aOut.append( mbX ? msHorizontal : msVertical );
98 rStrExpValue = aOut.makeStringAndClear();
100 return sal_True;
103 return sal_False;
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */