/src/libreoffice/xmloff/source/chart/XMLErrorIndicatorPropertyHdl.cxx
Line | Count | Source |
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 | | XMLErrorIndicatorPropertyHdl::~XMLErrorIndicatorPropertyHdl() |
34 | 0 | {} |
35 | | |
36 | | bool XMLErrorIndicatorPropertyHdl::importXML( const OUString& rStrImpValue, |
37 | | uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const |
38 | 0 | { |
39 | 0 | bool bValue(false); |
40 | 0 | (void)::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 | 0 | { |
49 | 0 | if( eType != chart::ChartErrorIndicatorType_TOP_AND_BOTTOM ) |
50 | 0 | { |
51 | 0 | if( mbUpperIndicator ) |
52 | 0 | eType = ( eType == chart::ChartErrorIndicatorType_LOWER ) |
53 | 0 | ? chart::ChartErrorIndicatorType_TOP_AND_BOTTOM |
54 | 0 | : chart::ChartErrorIndicatorType_UPPER; |
55 | 0 | else |
56 | 0 | eType = ( eType == chart::ChartErrorIndicatorType_UPPER ) |
57 | 0 | ? chart::ChartErrorIndicatorType_TOP_AND_BOTTOM |
58 | 0 | : chart::ChartErrorIndicatorType_LOWER; |
59 | 0 | } |
60 | 0 | } |
61 | 0 | else // disable flag |
62 | 0 | { |
63 | 0 | if( eType != chart::ChartErrorIndicatorType_NONE ) |
64 | 0 | { |
65 | 0 | if( mbUpperIndicator ) |
66 | 0 | eType = ( eType == chart::ChartErrorIndicatorType_UPPER ) |
67 | 0 | ? chart::ChartErrorIndicatorType_NONE |
68 | 0 | : chart::ChartErrorIndicatorType_LOWER; |
69 | 0 | else |
70 | 0 | eType = ( eType == chart::ChartErrorIndicatorType_LOWER ) |
71 | 0 | ? chart::ChartErrorIndicatorType_NONE |
72 | 0 | : chart::ChartErrorIndicatorType_UPPER; |
73 | 0 | } |
74 | 0 | } |
75 | |
|
76 | 0 | rValue <<= eType; |
77 | |
|
78 | 0 | return true; |
79 | 0 | } |
80 | | |
81 | | bool XMLErrorIndicatorPropertyHdl::exportXML( OUString& rStrExpValue, |
82 | | const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const |
83 | 0 | { |
84 | 0 | chart::ChartErrorIndicatorType eType; |
85 | |
|
86 | 0 | rValue >>= eType; |
87 | 0 | bool bValue = ( eType == chart::ChartErrorIndicatorType_TOP_AND_BOTTOM || |
88 | 0 | ( mbUpperIndicator |
89 | 0 | ? ( eType == chart::ChartErrorIndicatorType_UPPER ) |
90 | 0 | : ( eType == chart::ChartErrorIndicatorType_LOWER ))); |
91 | |
|
92 | 0 | if( bValue ) |
93 | 0 | { |
94 | 0 | OUStringBuffer aBuffer; |
95 | 0 | ::sax::Converter::convertBool( aBuffer, bValue ); |
96 | 0 | rStrExpValue = aBuffer.makeStringAndClear(); |
97 | 0 | } |
98 | | |
99 | | // only export if set to true |
100 | 0 | return bValue; |
101 | 0 | } |
102 | | |
103 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |