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 :
21 : #include "XMLErrorIndicatorPropertyHdl.hxx"
22 :
23 : #include <rtl/ustrbuf.hxx>
24 :
25 : #include <com/sun/star/uno/Any.hxx>
26 : #include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
27 :
28 : #include <sax/tools/converter.hxx>
29 :
30 :
31 : using namespace com::sun::star;
32 :
33 0 : XMLErrorIndicatorPropertyHdl::~XMLErrorIndicatorPropertyHdl()
34 0 : {}
35 :
36 0 : sal_Bool XMLErrorIndicatorPropertyHdl::importXML( const ::rtl::OUString& rStrImpValue,
37 : uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
38 : {
39 0 : bool bValue(false);
40 0 : ::sax::Converter::convertBool( bValue, rStrImpValue );
41 :
42 : // modify existing value
43 0 : chart::ChartErrorIndicatorType eType = chart::ChartErrorIndicatorType_NONE;
44 0 : if( rValue.hasValue())
45 0 : rValue >>= eType;
46 :
47 0 : if( bValue ) // enable flag
48 : {
49 0 : if( eType != chart::ChartErrorIndicatorType_TOP_AND_BOTTOM )
50 : {
51 0 : if( mbUpperIndicator )
52 : eType = ( eType == chart::ChartErrorIndicatorType_LOWER )
53 : ? chart::ChartErrorIndicatorType_TOP_AND_BOTTOM
54 0 : : chart::ChartErrorIndicatorType_UPPER;
55 : else
56 : eType = ( eType == chart::ChartErrorIndicatorType_UPPER )
57 : ? chart::ChartErrorIndicatorType_TOP_AND_BOTTOM
58 0 : : chart::ChartErrorIndicatorType_LOWER;
59 : }
60 : }
61 : else // disable flag
62 : {
63 0 : if( eType != chart::ChartErrorIndicatorType_NONE )
64 : {
65 0 : if( mbUpperIndicator )
66 : eType = ( eType == chart::ChartErrorIndicatorType_UPPER )
67 : ? chart::ChartErrorIndicatorType_NONE
68 0 : : chart::ChartErrorIndicatorType_LOWER;
69 : else
70 : eType = ( eType == chart::ChartErrorIndicatorType_LOWER )
71 : ? chart::ChartErrorIndicatorType_NONE
72 0 : : chart::ChartErrorIndicatorType_UPPER;
73 : }
74 : }
75 :
76 0 : rValue <<= eType;
77 :
78 0 : return sal_True;
79 : }
80 :
81 0 : sal_Bool XMLErrorIndicatorPropertyHdl::exportXML( ::rtl::OUString& rStrExpValue,
82 : const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
83 : {
84 0 : rtl::OUStringBuffer aBuffer;
85 : chart::ChartErrorIndicatorType eType;
86 :
87 0 : rValue >>= eType;
88 : sal_Bool bValue = ( eType == chart::ChartErrorIndicatorType_TOP_AND_BOTTOM ||
89 : ( mbUpperIndicator
90 : ? ( eType == chart::ChartErrorIndicatorType_UPPER )
91 0 : : ( eType == chart::ChartErrorIndicatorType_LOWER )));
92 :
93 0 : if( bValue )
94 : {
95 0 : ::sax::Converter::convertBool( aBuffer, bValue );
96 0 : rStrExpValue = aBuffer.makeStringAndClear();
97 : }
98 :
99 : // only export if set to true
100 0 : return bValue;
101 : }
102 :
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|