Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / xmloff / source / chart / XMLErrorIndicatorPropertyHdl.cxx
blob7b95f63a4099f5ca79b4bacbc134a28e7aecc63f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "XMLErrorIndicatorPropertyHdl.hxx"
23 #include <rtl/ustrbuf.hxx>
25 #include <com/sun/star/uno/Any.hxx>
26 #include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
28 #include <sax/tools/converter.hxx>
31 using namespace com::sun::star;
33 XMLErrorIndicatorPropertyHdl::~XMLErrorIndicatorPropertyHdl()
36 bool XMLErrorIndicatorPropertyHdl::importXML( const OUString& rStrImpValue,
37 uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
39 bool bValue(false);
40 ::sax::Converter::convertBool( bValue, rStrImpValue );
42 // modify existing value
43 chart::ChartErrorIndicatorType eType = chart::ChartErrorIndicatorType_NONE;
44 if( rValue.hasValue())
45 rValue >>= eType;
47 if( bValue ) // enable flag
49 if( eType != chart::ChartErrorIndicatorType_TOP_AND_BOTTOM )
51 if( mbUpperIndicator )
52 eType = ( eType == chart::ChartErrorIndicatorType_LOWER )
53 ? chart::ChartErrorIndicatorType_TOP_AND_BOTTOM
54 : chart::ChartErrorIndicatorType_UPPER;
55 else
56 eType = ( eType == chart::ChartErrorIndicatorType_UPPER )
57 ? chart::ChartErrorIndicatorType_TOP_AND_BOTTOM
58 : chart::ChartErrorIndicatorType_LOWER;
61 else // disable flag
63 if( eType != chart::ChartErrorIndicatorType_NONE )
65 if( mbUpperIndicator )
66 eType = ( eType == chart::ChartErrorIndicatorType_UPPER )
67 ? chart::ChartErrorIndicatorType_NONE
68 : chart::ChartErrorIndicatorType_LOWER;
69 else
70 eType = ( eType == chart::ChartErrorIndicatorType_LOWER )
71 ? chart::ChartErrorIndicatorType_NONE
72 : chart::ChartErrorIndicatorType_UPPER;
76 rValue <<= eType;
78 return true;
81 bool XMLErrorIndicatorPropertyHdl::exportXML( OUString& rStrExpValue,
82 const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
84 OUStringBuffer aBuffer;
85 chart::ChartErrorIndicatorType eType;
87 rValue >>= eType;
88 bool bValue = ( eType == chart::ChartErrorIndicatorType_TOP_AND_BOTTOM ||
89 ( mbUpperIndicator
90 ? ( eType == chart::ChartErrorIndicatorType_UPPER )
91 : ( eType == chart::ChartErrorIndicatorType_LOWER )));
93 if( bValue )
95 ::sax::Converter::convertBool( aBuffer, bValue );
96 rStrExpValue = aBuffer.makeStringAndClear();
99 // only export if set to true
100 return bValue;
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */