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