Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / tools / LinePropertiesHelper.cxx
blob227ec99b638350e8875b1f9050b9f62b9ce96d6e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <LinePropertiesHelper.hxx>
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/LineJoint.hpp>
26 #include <tools/diagnose_ex.h>
28 using namespace ::com::sun::star;
30 using ::com::sun::star::beans::Property;
32 namespace chart
35 void LinePropertiesHelper::AddPropertiesToVector(
36 std::vector< Property > & rOutProperties )
38 // Line Properties see service drawing::LineProperties
39 rOutProperties.emplace_back( "LineStyle",
40 PROP_LINE_STYLE,
41 cppu::UnoType<drawing::LineStyle>::get(),
42 beans::PropertyAttribute::BOUND
43 | beans::PropertyAttribute::MAYBEDEFAULT );
45 rOutProperties.emplace_back( "LineDash",
46 PROP_LINE_DASH,
47 cppu::UnoType<drawing::LineDash>::get(),
48 beans::PropertyAttribute::BOUND
49 | beans::PropertyAttribute::MAYBEVOID );
51 //not in service description
52 rOutProperties.emplace_back( "LineDashName",
53 PROP_LINE_DASH_NAME,
54 cppu::UnoType<OUString>::get(),
55 beans::PropertyAttribute::BOUND
56 | beans::PropertyAttribute::MAYBEDEFAULT
57 | beans::PropertyAttribute::MAYBEVOID );
59 rOutProperties.emplace_back( "LineColor",
60 PROP_LINE_COLOR,
61 cppu::UnoType<sal_Int32>::get(),
62 beans::PropertyAttribute::BOUND
63 | beans::PropertyAttribute::MAYBEDEFAULT );
65 rOutProperties.emplace_back( "LineTransparence",
66 PROP_LINE_TRANSPARENCE,
67 cppu::UnoType<sal_Int16>::get(),
68 beans::PropertyAttribute::BOUND
69 | beans::PropertyAttribute::MAYBEDEFAULT );
71 rOutProperties.emplace_back( "LineWidth",
72 PROP_LINE_WIDTH,
73 cppu::UnoType<sal_Int32>::get(),
74 beans::PropertyAttribute::BOUND
75 | beans::PropertyAttribute::MAYBEDEFAULT );
77 rOutProperties.emplace_back( "LineJoint",
78 PROP_LINE_JOINT,
79 cppu::UnoType<drawing::LineJoint>::get(),
80 beans::PropertyAttribute::BOUND
81 | beans::PropertyAttribute::MAYBEDEFAULT );
84 void LinePropertiesHelper::AddDefaultsToMap(
85 ::chart::tPropertyValueMap & rOutMap )
87 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
88 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
89 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 ); // black
90 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
91 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
94 bool LinePropertiesHelper::IsLineVisible( const css::uno::Reference<
95 css::beans::XPropertySet >& xLineProperties )
97 bool bRet = false;
98 try
100 if( xLineProperties.is() )
102 drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
103 xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
104 if( aLineStyle != drawing::LineStyle_NONE )
106 sal_Int16 nLineTransparence=0;
107 xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
108 if(nLineTransparence!=100)
110 bRet = true;
115 catch( const uno::Exception & )
117 DBG_UNHANDLED_EXCEPTION("chart2");
119 return bRet;
122 void LinePropertiesHelper::SetLineVisible( const css::uno::Reference<
123 css::beans::XPropertySet >& xLineProperties )
127 if( xLineProperties.is() )
129 drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
130 xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
131 if( aLineStyle == drawing::LineStyle_NONE )
132 xLineProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID ) );
134 sal_Int16 nLineTransparence=0;
135 xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
136 if(nLineTransparence==100)
137 xLineProperties->setPropertyValue( "LineTransparence", uno::Any( sal_Int16(0) ) );
140 catch( const uno::Exception & )
142 DBG_UNHANDLED_EXCEPTION("chart2");
146 void LinePropertiesHelper::SetLineInvisible( const css::uno::Reference<
147 css::beans::XPropertySet >& xLineProperties )
151 if( xLineProperties.is() )
153 drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
154 xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
155 if( aLineStyle != drawing::LineStyle_NONE )
156 xLineProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ) );
159 catch( const uno::Exception & )
161 DBG_UNHANDLED_EXCEPTION("chart2");
165 void LinePropertiesHelper::SetLineColor( const css::uno::Reference<
166 css::beans::XPropertySet >& xLineProperties, sal_Int32 nColor )
170 if( xLineProperties.is() )
172 xLineProperties->setPropertyValue( "LineColor", uno::Any( nColor ) );
175 catch( const uno::Exception & )
177 DBG_UNHANDLED_EXCEPTION("chart2");
182 } // namespace chart
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */