1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "LineProperties.hxx"
32 #include <com/sun/star/beans/PropertyAttribute.hpp>
33 #include <com/sun/star/drawing/LineStyle.hpp>
34 #include <com/sun/star/drawing/LineDash.hpp>
35 #include <com/sun/star/drawing/LineJoint.hpp>
37 using namespace ::com::sun::star
;
39 using ::com::sun::star::beans::Property
;
44 void LineProperties::AddPropertiesToVector(
45 ::std::vector
< Property
> & rOutProperties
)
47 // Line Properties see service drawing::LineProperties
49 rOutProperties
.push_back(
50 Property( C2U( "LineStyle" ),
52 ::getCppuType( reinterpret_cast< const drawing::LineStyle
* >(0)),
53 beans::PropertyAttribute::BOUND
54 | beans::PropertyAttribute::MAYBEDEFAULT
));
56 rOutProperties
.push_back(
57 Property( C2U( "LineDash" ),
59 ::getCppuType( reinterpret_cast< const drawing::LineDash
* >(0)),
60 beans::PropertyAttribute::BOUND
61 | beans::PropertyAttribute::MAYBEVOID
));
63 //not in service description
64 rOutProperties
.push_back(
65 Property( C2U( "LineDashName" ),
67 ::getCppuType( reinterpret_cast< const ::rtl::OUString
* >(0)),
68 beans::PropertyAttribute::BOUND
69 | beans::PropertyAttribute::MAYBEDEFAULT
70 | beans::PropertyAttribute::MAYBEVOID
));
72 rOutProperties
.push_back(
73 Property( C2U( "LineColor" ),
75 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
76 beans::PropertyAttribute::BOUND
77 | beans::PropertyAttribute::MAYBEDEFAULT
));
79 rOutProperties
.push_back(
80 Property( C2U( "LineTransparence" ),
81 PROP_LINE_TRANSPARENCE
,
82 ::getCppuType( reinterpret_cast< const sal_Int16
* >(0)),
83 beans::PropertyAttribute::BOUND
84 | beans::PropertyAttribute::MAYBEDEFAULT
));
86 rOutProperties
.push_back(
87 Property( C2U( "LineWidth" ),
89 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
90 beans::PropertyAttribute::BOUND
91 | beans::PropertyAttribute::MAYBEDEFAULT
));
93 rOutProperties
.push_back(
94 Property( C2U( "LineJoint" ),
96 ::getCppuType( reinterpret_cast< const drawing::LineJoint
* >(0)),
97 beans::PropertyAttribute::BOUND
98 | beans::PropertyAttribute::MAYBEDEFAULT
));
101 void LineProperties::AddDefaultsToMap(
102 ::chart::tPropertyValueMap
& rOutMap
)
104 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_LINE_STYLE
, drawing::LineStyle_SOLID
);
105 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_LINE_WIDTH
, 0 );
106 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_LINE_COLOR
, 0x000000 ); // black
107 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int16
>( rOutMap
, PROP_LINE_TRANSPARENCE
, 0 );
108 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_LINE_JOINT
, drawing::LineJoint_ROUND
);
112 bool LineProperties::IsLineVisible( const ::com::sun::star::uno::Reference
<
113 ::com::sun::star::beans::XPropertySet
>& xLineProperties
)
118 if( xLineProperties
.is() )
120 drawing::LineStyle
aLineStyle(drawing::LineStyle_SOLID
);
121 xLineProperties
->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle
;
122 if( aLineStyle
!= drawing::LineStyle_NONE
)
124 sal_Int16 nLineTransparence
=0;
125 xLineProperties
->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence
;
126 if(100!=nLineTransparence
)
133 catch( const uno::Exception
& ex
)
135 ASSERT_EXCEPTION( ex
);
141 void LineProperties::SetLineVisible( const ::com::sun::star::uno::Reference
<
142 ::com::sun::star::beans::XPropertySet
>& xLineProperties
)
146 if( xLineProperties
.is() )
148 drawing::LineStyle
aLineStyle(drawing::LineStyle_SOLID
);
149 xLineProperties
->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle
;
150 if( aLineStyle
== drawing::LineStyle_NONE
)
151 xLineProperties
->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID
) );
153 sal_Int16 nLineTransparence
=0;
154 xLineProperties
->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence
;
155 if(100==nLineTransparence
)
156 xLineProperties
->setPropertyValue( C2U( "LineTransparence" ), uno::makeAny( sal_Int16(0) ) );
159 catch( const uno::Exception
& ex
)
161 ASSERT_EXCEPTION( ex
);
166 void LineProperties::SetLineInvisible( const ::com::sun::star::uno::Reference
<
167 ::com::sun::star::beans::XPropertySet
>& xLineProperties
)
171 if( xLineProperties
.is() )
173 drawing::LineStyle
aLineStyle(drawing::LineStyle_SOLID
);
174 xLineProperties
->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle
;
175 if( aLineStyle
!= drawing::LineStyle_NONE
)
176 xLineProperties
->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE
) );
179 catch( const uno::Exception
& ex
)
181 ASSERT_EXCEPTION( ex
);