LibreOffice Module xmloff (master) 1
XMLErrorIndicatorPropertyHdl.cxx
Go to the documentation of this file.
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
22
23#include <rtl/ustrbuf.hxx>
24
25#include <com/sun/star/uno/Any.hxx>
26#include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
27
29
30
31using namespace com::sun::star;
32
34{}
35
36bool XMLErrorIndicatorPropertyHdl::importXML( const OUString& rStrImpValue,
37 uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
38{
39 bool bValue(false);
40 (void)::sax::Converter::convertBool( bValue, rStrImpValue );
41
42 // modify existing value
43 chart::ChartErrorIndicatorType eType = chart::ChartErrorIndicatorType_NONE;
44 if( rValue.hasValue())
45 rValue >>= eType;
46
47 if( bValue ) // enable flag
48 {
49 if( eType != chart::ChartErrorIndicatorType_TOP_AND_BOTTOM )
50 {
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;
59 }
60 }
61 else // disable flag
62 {
63 if( eType != chart::ChartErrorIndicatorType_NONE )
64 {
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;
73 }
74 }
75
76 rValue <<= eType;
77
78 return true;
79}
80
81bool XMLErrorIndicatorPropertyHdl::exportXML( OUString& rStrExpValue,
82 const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
83{
84 chart::ChartErrorIndicatorType eType;
85
86 rValue >>= eType;
87 bool bValue = ( eType == chart::ChartErrorIndicatorType_TOP_AND_BOTTOM ||
89 ? ( eType == chart::ChartErrorIndicatorType_UPPER )
90 : ( eType == chart::ChartErrorIndicatorType_LOWER )));
91
92 if( bValue )
93 {
94 OUStringBuffer aBuffer;
96 rStrExpValue = aBuffer.makeStringAndClear();
97 }
98
99 // only export if set to true
100 return bValue;
101}
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:83
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
static bool convertBool(bool &rBool, std::u16string_view rString)
DocumentType eType
bool hasValue()
std::unique_ptr< char[]> aBuffer