LibreOffice Module chart2 (master) 1
LinePropertiesHelper.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
21#include <com/sun/star/beans/PropertyAttribute.hpp>
22#include <com/sun/star/beans/XPropertySet.hpp>
23#include <com/sun/star/drawing/LineStyle.hpp>
24#include <com/sun/star/drawing/LineDash.hpp>
25#include <com/sun/star/drawing/LineCap.hpp>
26#include <com/sun/star/drawing/LineJoint.hpp>
28#include <tools/color.hxx>
29
30using namespace ::com::sun::star;
31
32using ::com::sun::star::beans::Property;
33
34namespace chart
35{
36
38 std::vector< Property > & rOutProperties )
39{
40 // Line Properties see service drawing::LineProperties
41 rOutProperties.emplace_back( "LineStyle",
44 beans::PropertyAttribute::BOUND
45 | beans::PropertyAttribute::MAYBEDEFAULT );
46
47 rOutProperties.emplace_back( "LineDash",
50 beans::PropertyAttribute::BOUND
51 | beans::PropertyAttribute::MAYBEVOID );
52
53//not in service description
54 rOutProperties.emplace_back( "LineDashName",
57 beans::PropertyAttribute::BOUND
58 | beans::PropertyAttribute::MAYBEDEFAULT
59 | beans::PropertyAttribute::MAYBEVOID );
60
61 rOutProperties.emplace_back( "LineColor",
64 beans::PropertyAttribute::BOUND
65 | beans::PropertyAttribute::MAYBEDEFAULT );
66
67 rOutProperties.emplace_back( "LineTransparence",
70 beans::PropertyAttribute::BOUND
71 | beans::PropertyAttribute::MAYBEDEFAULT );
72
73 rOutProperties.emplace_back( "LineWidth",
76 beans::PropertyAttribute::BOUND
77 | beans::PropertyAttribute::MAYBEDEFAULT );
78
79 rOutProperties.emplace_back( "LineJoint",
82 beans::PropertyAttribute::BOUND
83 | beans::PropertyAttribute::MAYBEDEFAULT );
84
85 rOutProperties.emplace_back( "LineCap",
88 beans::PropertyAttribute::BOUND
89 | beans::PropertyAttribute::MAYBEDEFAULT );
90}
91
94{
95 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
99 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
100 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_CAP, drawing::LineCap_BUTT );
101}
102
103bool LinePropertiesHelper::IsLineVisible( const css::uno::Reference<
104 css::beans::XPropertySet >& xLineProperties )
105{
106 bool bRet = false;
107 try
108 {
109 if( xLineProperties.is() )
110 {
111 drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
112 xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
113 if( aLineStyle != drawing::LineStyle_NONE )
114 {
115 sal_Int16 nLineTransparence=0;
116 xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
117 if(nLineTransparence!=100)
118 {
119 bRet = true;
120 }
121 }
122 }
123 }
124 catch( const uno::Exception & )
125 {
126 DBG_UNHANDLED_EXCEPTION("chart2");
127 }
128 return bRet;
129}
130
131void LinePropertiesHelper::SetLineVisible( const css::uno::Reference<
132 css::beans::XPropertySet >& xLineProperties )
133{
134 try
135 {
136 if( xLineProperties.is() )
137 {
138 drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
139 xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
140 if( aLineStyle == drawing::LineStyle_NONE )
141 xLineProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID ) );
142
143 sal_Int16 nLineTransparence=0;
144 xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
145 if(nLineTransparence==100)
146 xLineProperties->setPropertyValue( "LineTransparence", uno::Any( sal_Int16(0) ) );
147 }
148 }
149 catch( const uno::Exception & )
150 {
151 DBG_UNHANDLED_EXCEPTION("chart2");
152 }
153}
154
155void LinePropertiesHelper::SetLineInvisible( const css::uno::Reference<
156 css::beans::XPropertySet >& xLineProperties )
157{
158 try
159 {
160 if( xLineProperties.is() )
161 {
162 drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
163 xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
164 if( aLineStyle != drawing::LineStyle_NONE )
165 xLineProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ) );
166 }
167 }
168 catch( const uno::Exception & )
169 {
170 DBG_UNHANDLED_EXCEPTION("chart2");
171 }
172}
173
174void LinePropertiesHelper::SetLineColor( const css::uno::Reference<
175 css::beans::XPropertySet >& xLineProperties, sal_Int32 nColor )
176{
177 try
178 {
179 if( xLineProperties.is() )
180 {
181 xLineProperties->setPropertyValue( "LineColor", uno::Any( nColor ) );
182 }
183 }
184 catch( const uno::Exception & )
185 {
186 DBG_UNHANDLED_EXCEPTION("chart2");
187 }
188}
189
190
191} // namespace chart
192
193/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define DBG_UNHANDLED_EXCEPTION(...)
OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap(::chart::tPropertyValueMap &rOutMap)
OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector(std::vector< css::beans::Property > &rOutProperties)
void SetLineColor(const css::uno::Reference< css::beans::XPropertySet > &xGridProperties, sal_Int32 nColor)
void SetLineVisible(const css::uno::Reference< css::beans::XPropertySet > &xLineProperties)
void SetLineInvisible(const css::uno::Reference< css::beans::XPropertySet > &xLineProperties)
bool IsLineVisible(const css::uno::Reference< css::beans::XPropertySet > &xLineProperties)
void setPropertyValueDefault(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Calls setPropertyValue() but asserts that the given property hasn't been set before.
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap