/src/libreoffice/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.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 | | #include <RegressionEquationItemConverter.hxx> |
21 | | #include "SchWhichPairs.hxx" |
22 | | #include <ItemPropertyMap.hxx> |
23 | | #include <GraphicPropertyItemConverter.hxx> |
24 | | #include <CharacterPropertyItemConverter.hxx> |
25 | | #include <ChartModel.hxx> |
26 | | #include <unonames.hxx> |
27 | | #include <com/sun/star/beans/XPropertySet.hpp> |
28 | | |
29 | | #include <svl/intitem.hxx> |
30 | | |
31 | | #include <memory> |
32 | | |
33 | | using namespace ::com::sun::star; |
34 | | |
35 | | namespace chart::wrapper { |
36 | | |
37 | | namespace { |
38 | | |
39 | | ItemPropertyMapType & lcl_GetEquationPropertyMap() |
40 | 0 | { |
41 | 0 | static ItemPropertyMapType aEquationPropertyMap; |
42 | |
|
43 | 0 | return aEquationPropertyMap; |
44 | 0 | }; |
45 | | |
46 | | } // anonymous namespace |
47 | | |
48 | | RegressionEquationItemConverter::RegressionEquationItemConverter( |
49 | | const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, |
50 | | SfxItemPool& rItemPool, |
51 | | SdrModel& rDrawModel, |
52 | | const rtl::Reference< ChartModel > & xChartModel, |
53 | | const std::optional<awt::Size>& pRefSize ) : |
54 | 0 | ItemConverter( rPropertySet, rItemPool ) |
55 | 0 | { |
56 | 0 | m_aConverters.emplace_back( new GraphicPropertyItemConverter( |
57 | 0 | rPropertySet, rItemPool, rDrawModel, |
58 | 0 | xChartModel, |
59 | 0 | GraphicObjectType::LineAndFillProperties )); |
60 | |
|
61 | 0 | m_aConverters.emplace_back( |
62 | 0 | new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, u"ReferencePageSize"_ustr)); |
63 | 0 | } |
64 | | |
65 | | RegressionEquationItemConverter::~RegressionEquationItemConverter() |
66 | 0 | { |
67 | 0 | } |
68 | | |
69 | | void RegressionEquationItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const |
70 | 0 | { |
71 | 0 | for( const auto& pConv : m_aConverters ) |
72 | 0 | pConv->FillItemSet( rOutItemSet ); |
73 | | |
74 | | // own items |
75 | 0 | ItemConverter::FillItemSet( rOutItemSet ); |
76 | 0 | } |
77 | | |
78 | | bool RegressionEquationItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) |
79 | 0 | { |
80 | 0 | bool bResult = false; |
81 | |
|
82 | 0 | for( const auto& pConv : m_aConverters ) |
83 | 0 | bResult = pConv->ApplyItemSet( rItemSet ); |
84 | | |
85 | | // own items |
86 | 0 | return ItemConverter::ApplyItemSet( rItemSet ) || bResult; |
87 | 0 | } |
88 | | |
89 | | const WhichRangesContainer& RegressionEquationItemConverter::GetWhichPairs() const |
90 | 0 | { |
91 | | // must span all used items! |
92 | 0 | return nRegEquationWhichPairs; |
93 | 0 | } |
94 | | |
95 | | bool RegressionEquationItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const |
96 | 0 | { |
97 | 0 | ItemPropertyMapType & rMap( lcl_GetEquationPropertyMap()); |
98 | 0 | ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId )); |
99 | |
|
100 | 0 | if( aIt == rMap.end()) |
101 | 0 | return false; |
102 | | |
103 | 0 | rOutProperty =(*aIt).second; |
104 | 0 | return true; |
105 | 0 | } |
106 | | |
107 | | bool RegressionEquationItemConverter::ApplySpecialItem( |
108 | | sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) |
109 | 0 | { |
110 | 0 | bool bChanged = false; |
111 | |
|
112 | 0 | switch( nWhichId ) |
113 | 0 | { |
114 | 0 | case SID_ATTR_NUMBERFORMAT_VALUE: |
115 | 0 | { |
116 | 0 | uno::Any aValue( static_cast< sal_Int32 >( |
117 | 0 | static_cast< const SfxUInt32Item & >( |
118 | 0 | rItemSet.Get( nWhichId )).GetValue())); |
119 | 0 | if (GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) != aValue) |
120 | 0 | { |
121 | 0 | GetPropertySet()->setPropertyValue(CHART_UNONAME_NUMFMT, aValue); |
122 | 0 | bChanged = true; |
123 | 0 | } |
124 | 0 | } |
125 | 0 | break; |
126 | 0 | } |
127 | | |
128 | 0 | return bChanged; |
129 | 0 | } |
130 | | |
131 | | void RegressionEquationItemConverter::FillSpecialItem( |
132 | | sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const |
133 | 0 | { |
134 | 0 | switch( nWhichId ) |
135 | 0 | { |
136 | 0 | case SID_ATTR_NUMBERFORMAT_VALUE: |
137 | 0 | { |
138 | 0 | sal_Int32 nFormatKey = 0; |
139 | 0 | if (GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nFormatKey) |
140 | 0 | { |
141 | 0 | rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); |
142 | 0 | } |
143 | 0 | } |
144 | 0 | break; |
145 | 0 | } |
146 | 0 | } |
147 | | |
148 | | } |
149 | | |
150 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |