merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / tools / LineProperties.cxx
blob291652e3cd1fea464ac349a15c92d7c97fdc1cee
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: LineProperties.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "LineProperties.hxx"
34 #include "macros.hxx"
35 #include <com/sun/star/beans/PropertyAttribute.hpp>
36 #include <com/sun/star/drawing/LineStyle.hpp>
37 #include <com/sun/star/drawing/LineDash.hpp>
38 #include <com/sun/star/drawing/LineJoint.hpp>
40 using namespace ::com::sun::star;
42 using ::com::sun::star::beans::Property;
44 namespace chart
47 void LineProperties::AddPropertiesToVector(
48 ::std::vector< Property > & rOutProperties )
50 // Line Properties see service drawing::LineProperties
51 // ---------------
52 rOutProperties.push_back(
53 Property( C2U( "LineStyle" ),
54 PROP_LINE_STYLE,
55 ::getCppuType( reinterpret_cast< const drawing::LineStyle * >(0)),
56 beans::PropertyAttribute::BOUND
57 | beans::PropertyAttribute::MAYBEDEFAULT ));
59 rOutProperties.push_back(
60 Property( C2U( "LineDash" ),
61 PROP_LINE_DASH,
62 ::getCppuType( reinterpret_cast< const drawing::LineDash * >(0)),
63 beans::PropertyAttribute::BOUND
64 | beans::PropertyAttribute::MAYBEVOID ));
66 //not in service description
67 rOutProperties.push_back(
68 Property( C2U( "LineDashName" ),
69 PROP_LINE_DASH_NAME,
70 ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
71 beans::PropertyAttribute::BOUND
72 | beans::PropertyAttribute::MAYBEDEFAULT
73 | beans::PropertyAttribute::MAYBEVOID ));
75 rOutProperties.push_back(
76 Property( C2U( "LineColor" ),
77 PROP_LINE_COLOR,
78 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
79 beans::PropertyAttribute::BOUND
80 | beans::PropertyAttribute::MAYBEDEFAULT ));
82 rOutProperties.push_back(
83 Property( C2U( "LineTransparence" ),
84 PROP_LINE_TRANSPARENCE,
85 ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
86 beans::PropertyAttribute::BOUND
87 | beans::PropertyAttribute::MAYBEDEFAULT ));
89 rOutProperties.push_back(
90 Property( C2U( "LineWidth" ),
91 PROP_LINE_WIDTH,
92 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
93 beans::PropertyAttribute::BOUND
94 | beans::PropertyAttribute::MAYBEDEFAULT ));
96 rOutProperties.push_back(
97 Property( C2U( "LineJoint" ),
98 PROP_LINE_JOINT,
99 ::getCppuType( reinterpret_cast< const drawing::LineJoint * >(0)),
100 beans::PropertyAttribute::BOUND
101 | beans::PropertyAttribute::MAYBEDEFAULT ));
104 void LineProperties::AddDefaultsToMap(
105 ::chart::tPropertyValueMap & rOutMap )
107 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
108 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
109 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 ); // black
110 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
111 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_NONE );
114 //static
115 bool LineProperties::IsLineVisible( const ::com::sun::star::uno::Reference<
116 ::com::sun::star::beans::XPropertySet >& xLineProperties )
118 bool bRet = false;
121 if( xLineProperties.is() )
123 drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
124 xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
125 if( aLineStyle != drawing::LineStyle_NONE )
127 sal_Int16 nLineTransparence=0;
128 xLineProperties->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence;
129 if(100!=nLineTransparence)
131 bRet = true;
136 catch( const uno::Exception & ex )
138 ASSERT_EXCEPTION( ex );
140 return bRet;
143 //static
144 void LineProperties::SetLineVisible( const ::com::sun::star::uno::Reference<
145 ::com::sun::star::beans::XPropertySet >& xLineProperties )
149 if( xLineProperties.is() )
151 drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
152 xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
153 if( aLineStyle == drawing::LineStyle_NONE )
154 xLineProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID ) );
156 sal_Int16 nLineTransparence=0;
157 xLineProperties->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence;
158 if(100==nLineTransparence)
159 xLineProperties->setPropertyValue( C2U( "LineTransparence" ), uno::makeAny( sal_Int16(0) ) );
162 catch( const uno::Exception & ex )
164 ASSERT_EXCEPTION( ex );
168 //static
169 void LineProperties::SetLineInvisible( const ::com::sun::star::uno::Reference<
170 ::com::sun::star::beans::XPropertySet >& xLineProperties )
174 if( xLineProperties.is() )
176 drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
177 xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
178 if( aLineStyle != drawing::LineStyle_NONE )
179 xLineProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
182 catch( const uno::Exception & ex )
184 ASSERT_EXCEPTION( ex );
188 } // namespace chart