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