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 : #include "LinePropertiesHelper.hxx"
21 : #include "macros.hxx"
22 : #include <com/sun/star/beans/PropertyAttribute.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 :
27 : using namespace ::com::sun::star;
28 :
29 : using ::com::sun::star::beans::Property;
30 :
31 : namespace chart
32 : {
33 :
34 344 : void LinePropertiesHelper::AddPropertiesToVector(
35 : ::std::vector< Property > & rOutProperties )
36 : {
37 : // Line Properties see service drawing::LineProperties
38 : rOutProperties.push_back(
39 : Property( "LineStyle",
40 : PROP_LINE_STYLE,
41 344 : cppu::UnoType<drawing::LineStyle>::get(),
42 : beans::PropertyAttribute::BOUND
43 688 : | beans::PropertyAttribute::MAYBEDEFAULT ));
44 :
45 : rOutProperties.push_back(
46 : Property( "LineDash",
47 : PROP_LINE_DASH,
48 344 : cppu::UnoType<drawing::LineDash>::get(),
49 : beans::PropertyAttribute::BOUND
50 688 : | beans::PropertyAttribute::MAYBEVOID ));
51 :
52 : //not in service description
53 : rOutProperties.push_back(
54 : Property( "LineDashName",
55 : PROP_LINE_DASH_NAME,
56 344 : cppu::UnoType<OUString>::get(),
57 : beans::PropertyAttribute::BOUND
58 : | beans::PropertyAttribute::MAYBEDEFAULT
59 688 : | beans::PropertyAttribute::MAYBEVOID ));
60 :
61 : rOutProperties.push_back(
62 : Property( "LineColor",
63 : PROP_LINE_COLOR,
64 344 : cppu::UnoType<sal_Int32>::get(),
65 : beans::PropertyAttribute::BOUND
66 688 : | beans::PropertyAttribute::MAYBEDEFAULT ));
67 :
68 : rOutProperties.push_back(
69 : Property( "LineTransparence",
70 : PROP_LINE_TRANSPARENCE,
71 344 : cppu::UnoType<sal_Int16>::get(),
72 : beans::PropertyAttribute::BOUND
73 688 : | beans::PropertyAttribute::MAYBEDEFAULT ));
74 :
75 : rOutProperties.push_back(
76 : Property( "LineWidth",
77 : PROP_LINE_WIDTH,
78 344 : cppu::UnoType<sal_Int32>::get(),
79 : beans::PropertyAttribute::BOUND
80 688 : | beans::PropertyAttribute::MAYBEDEFAULT ));
81 :
82 : rOutProperties.push_back(
83 : Property( "LineJoint",
84 : PROP_LINE_JOINT,
85 344 : cppu::UnoType<drawing::LineJoint>::get(),
86 : beans::PropertyAttribute::BOUND
87 688 : | beans::PropertyAttribute::MAYBEDEFAULT ));
88 344 : }
89 :
90 174 : void LinePropertiesHelper::AddDefaultsToMap(
91 : ::chart::tPropertyValueMap & rOutMap )
92 : {
93 174 : ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
94 174 : ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
95 174 : ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 ); // black
96 174 : ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
97 174 : ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
98 174 : }
99 :
100 10279 : bool LinePropertiesHelper::IsLineVisible( const ::com::sun::star::uno::Reference<
101 : ::com::sun::star::beans::XPropertySet >& xLineProperties )
102 : {
103 10279 : bool bRet = false;
104 : try
105 : {
106 10279 : if( xLineProperties.is() )
107 : {
108 10279 : drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
109 10279 : xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
110 10279 : if( aLineStyle != drawing::LineStyle_NONE )
111 : {
112 9894 : sal_Int16 nLineTransparence=0;
113 9894 : xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
114 9894 : if(100!=nLineTransparence)
115 : {
116 9894 : bRet = true;
117 : }
118 : }
119 : }
120 : }
121 0 : catch( const uno::Exception & ex )
122 : {
123 : ASSERT_EXCEPTION( ex );
124 : }
125 10279 : return bRet;
126 : }
127 :
128 942 : void LinePropertiesHelper::SetLineVisible( const ::com::sun::star::uno::Reference<
129 : ::com::sun::star::beans::XPropertySet >& xLineProperties )
130 : {
131 : try
132 : {
133 942 : if( xLineProperties.is() )
134 : {
135 942 : drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
136 942 : xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
137 942 : if( aLineStyle == drawing::LineStyle_NONE )
138 24 : xLineProperties->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_SOLID ) );
139 :
140 942 : sal_Int16 nLineTransparence=0;
141 942 : xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
142 942 : if(100==nLineTransparence)
143 0 : xLineProperties->setPropertyValue( "LineTransparence", uno::makeAny( sal_Int16(0) ) );
144 : }
145 : }
146 0 : catch( const uno::Exception & ex )
147 : {
148 : ASSERT_EXCEPTION( ex );
149 : }
150 942 : }
151 :
152 2252 : void LinePropertiesHelper::SetLineInvisible( const ::com::sun::star::uno::Reference<
153 : ::com::sun::star::beans::XPropertySet >& xLineProperties )
154 : {
155 : try
156 : {
157 2252 : if( xLineProperties.is() )
158 : {
159 2252 : drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
160 2252 : xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
161 2252 : if( aLineStyle != drawing::LineStyle_NONE )
162 2252 : xLineProperties->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_NONE ) );
163 : }
164 : }
165 0 : catch( const uno::Exception & ex )
166 : {
167 : ASSERT_EXCEPTION( ex );
168 : }
169 2252 : }
170 :
171 : } // namespace chart
172 :
173 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|