1cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5cde9e8dcSAndrew Rist * distributed with this work for additional information
6cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10cde9e8dcSAndrew Rist *
11cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cde9e8dcSAndrew Rist *
13cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18cde9e8dcSAndrew Rist * under the License.
19cde9e8dcSAndrew Rist *
20cde9e8dcSAndrew Rist *************************************************************/
21cde9e8dcSAndrew Rist
22cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "WrappedSymbolProperties.hxx"
28cdf0e10cSrcweir #include "WrappedSeriesOrDiagramProperty.hxx"
29cdf0e10cSrcweir #include "macros.hxx"
30cdf0e10cSrcweir #include "FastPropertyIdRanges.hxx"
31cdf0e10cSrcweir #include "ChartTypeHelper.hxx"
32cdf0e10cSrcweir #include <com/sun/star/chart2/Symbol.hpp>
33cdf0e10cSrcweir #include <com/sun/star/chart2/SymbolStyle.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
35cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
36cdf0e10cSrcweir #include <com/sun/star/chart/ChartSymbolType.hpp>
37cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp>
40cdf0e10cSrcweir
41cdf0e10cSrcweir // for UNO_NAME_GRAPHOBJ_URLPREFIX
42cdf0e10cSrcweir #include <editeng/unoprnms.hxx>
43cdf0e10cSrcweir
44cdf0e10cSrcweir // for Graphic
45cdf0e10cSrcweir #include <vcl/graph.hxx>
46cdf0e10cSrcweir // for GraphicObject
47cdf0e10cSrcweir #include <svtools/grfmgr.hxx>
48cdf0e10cSrcweir #include <vcl/outdev.hxx>
49cdf0e10cSrcweir
50cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
51cdf0e10cSrcweir
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir using ::com::sun::star::uno::Any;
54cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
55cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
56cdf0e10cSrcweir using ::com::sun::star::beans::Property;
57cdf0e10cSrcweir using ::rtl::OUString;
58cdf0e10cSrcweir
59cdf0e10cSrcweir //.............................................................................
60cdf0e10cSrcweir namespace chart
61cdf0e10cSrcweir {
62cdf0e10cSrcweir namespace wrapper
63cdf0e10cSrcweir {
64cdf0e10cSrcweir
65cdf0e10cSrcweir
66cdf0e10cSrcweir //-----------------------------------------------------------------------------
67cdf0e10cSrcweir //-----------------------------------------------------------------------------
68cdf0e10cSrcweir //-----------------------------------------------------------------------------
69cdf0e10cSrcweir
70cdf0e10cSrcweir class WrappedSymbolTypeProperty : public WrappedSeriesOrDiagramProperty< sal_Int32 >
71cdf0e10cSrcweir {
72cdf0e10cSrcweir public:
73cdf0e10cSrcweir virtual sal_Int32 getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const;
74cdf0e10cSrcweir virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 aNewValue ) const;
75cdf0e10cSrcweir
76cdf0e10cSrcweir virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
77cdf0e10cSrcweir throw ( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
78cdf0e10cSrcweir virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
79cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException);
80cdf0e10cSrcweir
81cdf0e10cSrcweir explicit WrappedSymbolTypeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
82cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType );
83cdf0e10cSrcweir virtual ~WrappedSymbolTypeProperty();
84cdf0e10cSrcweir };
85cdf0e10cSrcweir
86cdf0e10cSrcweir class WrappedSymbolBitmapURLProperty : public WrappedSeriesOrDiagramProperty< OUString >
87cdf0e10cSrcweir {
88cdf0e10cSrcweir public:
89cdf0e10cSrcweir virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const;
90cdf0e10cSrcweir virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, OUString aNewGraphicURL ) const;
91cdf0e10cSrcweir
92cdf0e10cSrcweir explicit WrappedSymbolBitmapURLProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
93cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType );
94cdf0e10cSrcweir virtual ~WrappedSymbolBitmapURLProperty();
95cdf0e10cSrcweir };
96cdf0e10cSrcweir
97cdf0e10cSrcweir class WrappedSymbolSizeProperty : public WrappedSeriesOrDiagramProperty< awt::Size >
98cdf0e10cSrcweir {
99cdf0e10cSrcweir public:
100cdf0e10cSrcweir virtual awt::Size getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const;
101cdf0e10cSrcweir virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, awt::Size aNewSize ) const;
102cdf0e10cSrcweir virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
103cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException);
104cdf0e10cSrcweir
105cdf0e10cSrcweir explicit WrappedSymbolSizeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
106cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType );
107cdf0e10cSrcweir virtual ~WrappedSymbolSizeProperty();
108cdf0e10cSrcweir };
109cdf0e10cSrcweir
110cdf0e10cSrcweir class WrappedSymbolAndLinesProperty : public WrappedSeriesOrDiagramProperty< sal_Bool >
111cdf0e10cSrcweir {
112cdf0e10cSrcweir public:
113cdf0e10cSrcweir virtual sal_Bool getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const;
114cdf0e10cSrcweir virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Bool bDrawLines ) const;
115cdf0e10cSrcweir virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
116cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException);
117cdf0e10cSrcweir
118cdf0e10cSrcweir explicit WrappedSymbolAndLinesProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
119cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType );
120cdf0e10cSrcweir virtual ~WrappedSymbolAndLinesProperty();
121cdf0e10cSrcweir };
122cdf0e10cSrcweir
123cdf0e10cSrcweir namespace
124cdf0e10cSrcweir {
125cdf0e10cSrcweir enum
126cdf0e10cSrcweir {
127cdf0e10cSrcweir //symbol properties
128cdf0e10cSrcweir PROP_CHART_SYMBOL_TYPE = FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP,
129cdf0e10cSrcweir PROP_CHART_SYMBOL_BITMAP_URL,
130cdf0e10cSrcweir PROP_CHART_SYMBOL_SIZE,
131cdf0e10cSrcweir PROP_CHART_SYMBOL_AND_LINES
132cdf0e10cSrcweir };
133cdf0e10cSrcweir
lcl_getSymbolType(const::com::sun::star::chart2::Symbol & rSymbol)134cdf0e10cSrcweir sal_Int32 lcl_getSymbolType( const ::com::sun::star::chart2::Symbol& rSymbol )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir sal_Int32 nSymbol = ::com::sun::star::chart::ChartSymbolType::NONE;
137cdf0e10cSrcweir switch( rSymbol.Style )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir case chart2::SymbolStyle_NONE:
140cdf0e10cSrcweir break;
141cdf0e10cSrcweir case chart2::SymbolStyle_AUTO:
142cdf0e10cSrcweir nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO;
143cdf0e10cSrcweir break;
144cdf0e10cSrcweir case chart2::SymbolStyle_STANDARD:
145*3a5971bbSRegina Henschel nSymbol = rSymbol.StandardSymbol%15;
146cdf0e10cSrcweir break;
147cdf0e10cSrcweir case chart2::SymbolStyle_POLYGON://new feature
148cdf0e10cSrcweir nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO;
149cdf0e10cSrcweir break;
150cdf0e10cSrcweir case chart2::SymbolStyle_GRAPHIC:
151cdf0e10cSrcweir nSymbol = ::com::sun::star::chart::ChartSymbolType::BITMAPURL;
152cdf0e10cSrcweir break;
153cdf0e10cSrcweir default:
154cdf0e10cSrcweir nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO;
155cdf0e10cSrcweir break;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir return nSymbol;
158cdf0e10cSrcweir }
lcl_setSymbolTypeToSymbol(sal_Int32 nSymbolType,chart2::Symbol & rSymbol)159cdf0e10cSrcweir void lcl_setSymbolTypeToSymbol( sal_Int32 nSymbolType, chart2::Symbol& rSymbol )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir switch( nSymbolType )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir case ::com::sun::star::chart::ChartSymbolType::NONE:
164cdf0e10cSrcweir rSymbol.Style = chart2::SymbolStyle_NONE;
165cdf0e10cSrcweir break;
166cdf0e10cSrcweir case ::com::sun::star::chart::ChartSymbolType::AUTO:
167cdf0e10cSrcweir rSymbol.Style = chart2::SymbolStyle_AUTO;
168cdf0e10cSrcweir break;
169cdf0e10cSrcweir case ::com::sun::star::chart::ChartSymbolType::BITMAPURL:
170cdf0e10cSrcweir rSymbol.Style = chart2::SymbolStyle_GRAPHIC;
171cdf0e10cSrcweir break;
172cdf0e10cSrcweir default:
173cdf0e10cSrcweir rSymbol.Style = chart2::SymbolStyle_STANDARD;
174cdf0e10cSrcweir rSymbol.StandardSymbol = nSymbolType;
175cdf0e10cSrcweir break;
176cdf0e10cSrcweir }
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
lcl_addWrappedProperties(std::vector<WrappedProperty * > & rList,::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact,tSeriesOrDiagramPropertyType ePropertyType)179cdf0e10cSrcweir void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList
180cdf0e10cSrcweir , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
181cdf0e10cSrcweir , tSeriesOrDiagramPropertyType ePropertyType )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir rList.push_back( new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) );
184cdf0e10cSrcweir rList.push_back( new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) );
185cdf0e10cSrcweir rList.push_back( new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) );
186cdf0e10cSrcweir rList.push_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) );
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
189cdf0e10cSrcweir }//anonymous namespace
190cdf0e10cSrcweir
191cdf0e10cSrcweir //-----------------------------------------------------------------------------
192cdf0e10cSrcweir //-----------------------------------------------------------------------------
193cdf0e10cSrcweir //-----------------------------------------------------------------------------
addProperties(::std::vector<Property> & rOutProperties)194cdf0e10cSrcweir void WrappedSymbolProperties::addProperties( ::std::vector< Property > & rOutProperties )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir rOutProperties.push_back(
197cdf0e10cSrcweir Property( C2U( "SymbolType" ),
198cdf0e10cSrcweir PROP_CHART_SYMBOL_TYPE,
199cdf0e10cSrcweir ::getCppuType( reinterpret_cast< sal_Int32 * >(0)),
200cdf0e10cSrcweir beans::PropertyAttribute::BOUND
201cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
202cdf0e10cSrcweir
203cdf0e10cSrcweir rOutProperties.push_back(
204cdf0e10cSrcweir Property( C2U( "SymbolBitmapURL" ),
205cdf0e10cSrcweir PROP_CHART_SYMBOL_BITMAP_URL,
206cdf0e10cSrcweir ::getCppuType( reinterpret_cast< ::rtl::OUString * >(0)),
207cdf0e10cSrcweir beans::PropertyAttribute::BOUND
208cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
209cdf0e10cSrcweir
210cdf0e10cSrcweir rOutProperties.push_back(
211cdf0e10cSrcweir Property( C2U( "SymbolSize" ),
212cdf0e10cSrcweir PROP_CHART_SYMBOL_SIZE,
213cdf0e10cSrcweir ::getCppuType( reinterpret_cast< awt::Size * >(0)),
214cdf0e10cSrcweir beans::PropertyAttribute::BOUND
215cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
216cdf0e10cSrcweir
217cdf0e10cSrcweir rOutProperties.push_back(
218cdf0e10cSrcweir Property( C2U( "Lines" ),
219cdf0e10cSrcweir PROP_CHART_SYMBOL_AND_LINES,
220cdf0e10cSrcweir ::getBooleanCppuType(),
221cdf0e10cSrcweir beans::PropertyAttribute::BOUND
222cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
223cdf0e10cSrcweir }
224cdf0e10cSrcweir
225cdf0e10cSrcweir //-----------------------------------------------------------------------------
226cdf0e10cSrcweir //-----------------------------------------------------------------------------
227cdf0e10cSrcweir
addWrappedPropertiesForSeries(std::vector<WrappedProperty * > & rList,::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact)228cdf0e10cSrcweir void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList
229cdf0e10cSrcweir , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES );
232cdf0e10cSrcweir }
233cdf0e10cSrcweir
234cdf0e10cSrcweir //-----------------------------------------------------------------------------
235cdf0e10cSrcweir //-----------------------------------------------------------------------------
236cdf0e10cSrcweir
addWrappedPropertiesForDiagram(std::vector<WrappedProperty * > & rList,::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact)237cdf0e10cSrcweir void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList
238cdf0e10cSrcweir , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM );
241cdf0e10cSrcweir }
242cdf0e10cSrcweir
243cdf0e10cSrcweir //-----------------------------------------------------------------------------
244cdf0e10cSrcweir //-----------------------------------------------------------------------------
245cdf0e10cSrcweir //-----------------------------------------------------------------------------
246cdf0e10cSrcweir
WrappedSymbolTypeProperty(::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact,tSeriesOrDiagramPropertyType ePropertyType)247cdf0e10cSrcweir WrappedSymbolTypeProperty::WrappedSymbolTypeProperty(
248cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
249cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType )
250cdf0e10cSrcweir : WrappedSeriesOrDiagramProperty< sal_Int32 >( C2U("SymbolType")
251cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartSymbolType::NONE )
252cdf0e10cSrcweir , spChart2ModelContact
253cdf0e10cSrcweir , ePropertyType )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir }
~WrappedSymbolTypeProperty()256cdf0e10cSrcweir WrappedSymbolTypeProperty::~WrappedSymbolTypeProperty()
257cdf0e10cSrcweir {
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
getValueFromSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet) const260cdf0e10cSrcweir sal_Int32 WrappedSymbolTypeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
261cdf0e10cSrcweir {
262cdf0e10cSrcweir sal_Int32 aRet = 0;
263cdf0e10cSrcweir m_aDefaultValue >>= aRet;
264cdf0e10cSrcweir chart2::Symbol aSymbol;
265cdf0e10cSrcweir if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ) )
266cdf0e10cSrcweir aRet = lcl_getSymbolType( aSymbol );
267cdf0e10cSrcweir return aRet;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir
setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet,sal_Int32 nSymbolType) const270cdf0e10cSrcweir void WrappedSymbolTypeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 nSymbolType ) const
271cdf0e10cSrcweir {
272cdf0e10cSrcweir if(!xSeriesPropertySet.is())
273cdf0e10cSrcweir return;
274cdf0e10cSrcweir
275cdf0e10cSrcweir chart2::Symbol aSymbol;
276cdf0e10cSrcweir xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol;
277cdf0e10cSrcweir
278cdf0e10cSrcweir lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol );
279cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
getPropertyValue(const Reference<beans::XPropertySet> & xInnerPropertySet) const282cdf0e10cSrcweir Any WrappedSymbolTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
283cdf0e10cSrcweir throw ( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
284cdf0e10cSrcweir {
285cdf0e10cSrcweir //the old chart (< OOo 2.3) needs symbol-type="automatic" at the plot-area if any of the series should be able to have symbols
286cdf0e10cSrcweir if( m_ePropertyType == DIAGRAM )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir bool bHasAmbiguousValue = false;
289cdf0e10cSrcweir sal_Int32 aValue = 0;
290cdf0e10cSrcweir if( detectInnerValue( aValue, bHasAmbiguousValue ) )
291cdf0e10cSrcweir {
292cdf0e10cSrcweir if(bHasAmbiguousValue)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::AUTO );
295cdf0e10cSrcweir }
296cdf0e10cSrcweir else
297cdf0e10cSrcweir {
298cdf0e10cSrcweir if( ::com::sun::star::chart::ChartSymbolType::NONE == aValue )
299cdf0e10cSrcweir m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::NONE );
300cdf0e10cSrcweir else
301cdf0e10cSrcweir m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::AUTO );
302cdf0e10cSrcweir }
303cdf0e10cSrcweir }
304cdf0e10cSrcweir return m_aOuterValue;
305cdf0e10cSrcweir }
306cdf0e10cSrcweir else
307cdf0e10cSrcweir {
308cdf0e10cSrcweir ::com::sun::star::uno::Any aRet( m_aDefaultValue );
309cdf0e10cSrcweir aRet <<= getValueFromSeries( xInnerPropertySet );
310cdf0e10cSrcweir return aRet;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir }
313cdf0e10cSrcweir
getPropertyState(const Reference<beans::XPropertyState> & xInnerPropertyState) const314cdf0e10cSrcweir beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
315cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir //the special situation for this property here is that the diagram default can be
318cdf0e10cSrcweir //different from the normal default and different from all sinlges series values
319cdf0e10cSrcweir //so we need to return PropertyState_DIRECT_VALUE for more cases
320cdf0e10cSrcweir
321cdf0e10cSrcweir if( m_ePropertyType == DATA_SERIES && //single series or point
322cdf0e10cSrcweir m_spChart2ModelContact.get())
323cdf0e10cSrcweir {
324cdf0e10cSrcweir Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
325cdf0e10cSrcweir Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY );
326cdf0e10cSrcweir Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
327cdf0e10cSrcweir if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) )
328cdf0e10cSrcweir return beans::PropertyState_DIRECT_VALUE;
329cdf0e10cSrcweir }
330cdf0e10cSrcweir return WrappedProperty::getPropertyState( xInnerPropertyState );
331cdf0e10cSrcweir }
332cdf0e10cSrcweir
333cdf0e10cSrcweir //-----------------------------------------------------------------------------
334cdf0e10cSrcweir //-----------------------------------------------------------------------------
335cdf0e10cSrcweir //-----------------------------------------------------------------------------
336cdf0e10cSrcweir
WrappedSymbolBitmapURLProperty(::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact,tSeriesOrDiagramPropertyType ePropertyType)337cdf0e10cSrcweir WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty(
338cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
339cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType )
340cdf0e10cSrcweir : WrappedSeriesOrDiagramProperty< OUString >( C2U("SymbolBitmapURL")
341cdf0e10cSrcweir , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
~WrappedSymbolBitmapURLProperty()345cdf0e10cSrcweir WrappedSymbolBitmapURLProperty::~WrappedSymbolBitmapURLProperty()
346cdf0e10cSrcweir {
347cdf0e10cSrcweir }
348cdf0e10cSrcweir
getValueFromSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet) const349cdf0e10cSrcweir OUString WrappedSymbolBitmapURLProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
350cdf0e10cSrcweir {
351cdf0e10cSrcweir OUString aRet;
352cdf0e10cSrcweir m_aDefaultValue >>= aRet;
353cdf0e10cSrcweir chart2::Symbol aSymbol;
354cdf0e10cSrcweir if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol )
355cdf0e10cSrcweir && aSymbol.Graphic.is())
356cdf0e10cSrcweir {
357cdf0e10cSrcweir GraphicObject aGrObj( Graphic( aSymbol.Graphic ));
358cdf0e10cSrcweir aRet = OUString( RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_GRAPHOBJ_URLPREFIX ));
359cdf0e10cSrcweir aRet += OUString::createFromAscii( aGrObj.GetUniqueID().GetBuffer());
360cdf0e10cSrcweir }
361cdf0e10cSrcweir return aRet;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir
setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet,OUString aNewGraphicURL) const364cdf0e10cSrcweir void WrappedSymbolBitmapURLProperty::setValueToSeries(
365cdf0e10cSrcweir const Reference< beans::XPropertySet >& xSeriesPropertySet,
366cdf0e10cSrcweir OUString aNewGraphicURL ) const
367cdf0e10cSrcweir {
368cdf0e10cSrcweir if(!xSeriesPropertySet.is())
369cdf0e10cSrcweir return;
370cdf0e10cSrcweir
371cdf0e10cSrcweir chart2::Symbol aSymbol;
372cdf0e10cSrcweir if( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir bool bMatchesPrefix =
375cdf0e10cSrcweir aNewGraphicURL.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( UNO_NAME_GRAPHOBJ_URLPREFIX ));
376cdf0e10cSrcweir if( bMatchesPrefix )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir GraphicObject aGrObj = GraphicObject(
379cdf0e10cSrcweir ByteString( U2C( aNewGraphicURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 ))));
380cdf0e10cSrcweir aSymbol.Graphic.set( aGrObj.GetGraphic().GetXGraphic());
381cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) );
382cdf0e10cSrcweir }
383cdf0e10cSrcweir else
384cdf0e10cSrcweir {
385cdf0e10cSrcweir try
386cdf0e10cSrcweir {
387cdf0e10cSrcweir // @todo: get factory from some context?
388cdf0e10cSrcweir Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
389cdf0e10cSrcweir Reference< graphic::XGraphicProvider > xGraphProv(
390cdf0e10cSrcweir xFact->createInstance( C2U("com.sun.star.graphic.GraphicProvider")), uno::UNO_QUERY_THROW );
391cdf0e10cSrcweir Sequence< beans::PropertyValue > aArgs(1);
392cdf0e10cSrcweir aArgs[0] = beans::PropertyValue(
393cdf0e10cSrcweir C2U("URL"), -1, uno::makeAny( aNewGraphicURL ),
394cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE );
395cdf0e10cSrcweir aSymbol.Graphic.set( xGraphProv->queryGraphic( aArgs ));
396cdf0e10cSrcweir OSL_ENSURE( aSymbol.Graphic.is(), "Invalid URL for Symbol Bitmap" );
397cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) );
398cdf0e10cSrcweir }
399cdf0e10cSrcweir catch( const uno::Exception & ex )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
402cdf0e10cSrcweir }
403cdf0e10cSrcweir }
404cdf0e10cSrcweir }
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
407cdf0e10cSrcweir
408cdf0e10cSrcweir //-----------------------------------------------------------------------------
409cdf0e10cSrcweir //-----------------------------------------------------------------------------
410cdf0e10cSrcweir //-----------------------------------------------------------------------------
411cdf0e10cSrcweir
412cdf0e10cSrcweir namespace
413cdf0e10cSrcweir {
414cdf0e10cSrcweir
lcl_correctSymbolSizeForBitmaps(chart2::Symbol & rSymbol)415cdf0e10cSrcweir void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir if( rSymbol.Style != chart2::SymbolStyle_GRAPHIC )
418cdf0e10cSrcweir return;
419cdf0e10cSrcweir if( rSymbol.Size.Width != -1 )
420cdf0e10cSrcweir return;
421cdf0e10cSrcweir if( rSymbol.Size.Height != -1 )
422cdf0e10cSrcweir return;
423cdf0e10cSrcweir
424cdf0e10cSrcweir //find a good automatic size
425cdf0e10cSrcweir try
426cdf0e10cSrcweir {
427cdf0e10cSrcweir const awt::Size aDefaultSize(250,250);
428cdf0e10cSrcweir awt::Size aSize = aDefaultSize;
429cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( rSymbol.Graphic, uno::UNO_QUERY );
430cdf0e10cSrcweir if( xProp.is() )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir bool bFoundSize = false;
433cdf0e10cSrcweir try
434cdf0e10cSrcweir {
435cdf0e10cSrcweir if( (xProp->getPropertyValue( C2U( "Size100thMM" ) ) >>= aSize) )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir if( aSize.Width == 0 && aSize.Height == 0 )
438cdf0e10cSrcweir aSize = aDefaultSize;
439cdf0e10cSrcweir else
440cdf0e10cSrcweir bFoundSize = true;
441cdf0e10cSrcweir }
442cdf0e10cSrcweir }
443cdf0e10cSrcweir catch( uno::Exception& e )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir ASSERT_EXCEPTION( e );
446cdf0e10cSrcweir }
447cdf0e10cSrcweir
448cdf0e10cSrcweir if(!bFoundSize)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir awt::Size aAWTPixelSize(10,10);
451cdf0e10cSrcweir if( (xProp->getPropertyValue( C2U( "SizePixel" ) ) >>= aAWTPixelSize) )
452cdf0e10cSrcweir {
453cdf0e10cSrcweir Size aPixelSize(aAWTPixelSize.Width,aAWTPixelSize.Height);
454cdf0e10cSrcweir Size aNewSize = ( OutputDevice::LogicToLogic( aPixelSize, MAP_PIXEL, MAP_100TH_MM ));
455cdf0e10cSrcweir aSize = awt::Size( aNewSize.Width(), aNewSize.Height() );
456cdf0e10cSrcweir
457cdf0e10cSrcweir if( aSize.Width == 0 && aSize.Height == 0 )
458cdf0e10cSrcweir aSize = aDefaultSize;
459cdf0e10cSrcweir }
460cdf0e10cSrcweir }
461cdf0e10cSrcweir }
462cdf0e10cSrcweir rSymbol.Size = aSize;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir catch( uno::Exception& e )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir ASSERT_EXCEPTION( e );
467cdf0e10cSrcweir }
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
470cdf0e10cSrcweir }//end anonymous namespace
471cdf0e10cSrcweir
WrappedSymbolSizeProperty(::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact,tSeriesOrDiagramPropertyType ePropertyType)472cdf0e10cSrcweir WrappedSymbolSizeProperty::WrappedSymbolSizeProperty(
473cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
474cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType )
475cdf0e10cSrcweir : WrappedSeriesOrDiagramProperty< awt::Size >( C2U("SymbolSize")
476cdf0e10cSrcweir , uno::makeAny( awt::Size(250,250) ), spChart2ModelContact, ePropertyType )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir }
479cdf0e10cSrcweir
~WrappedSymbolSizeProperty()480cdf0e10cSrcweir WrappedSymbolSizeProperty::~WrappedSymbolSizeProperty()
481cdf0e10cSrcweir {
482cdf0e10cSrcweir }
483cdf0e10cSrcweir
getValueFromSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet) const484cdf0e10cSrcweir awt::Size WrappedSymbolSizeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
485cdf0e10cSrcweir {
486cdf0e10cSrcweir awt::Size aRet;
487cdf0e10cSrcweir m_aDefaultValue >>= aRet;
488cdf0e10cSrcweir chart2::Symbol aSymbol;
489cdf0e10cSrcweir if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ))
490cdf0e10cSrcweir aRet = aSymbol.Size;
491cdf0e10cSrcweir return aRet;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir
setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet,awt::Size aNewSize) const494cdf0e10cSrcweir void WrappedSymbolSizeProperty::setValueToSeries(
495cdf0e10cSrcweir const Reference< beans::XPropertySet >& xSeriesPropertySet,
496cdf0e10cSrcweir awt::Size aNewSize ) const
497cdf0e10cSrcweir {
498cdf0e10cSrcweir if(!xSeriesPropertySet.is())
499cdf0e10cSrcweir return;
500cdf0e10cSrcweir
501cdf0e10cSrcweir chart2::Symbol aSymbol;
502cdf0e10cSrcweir if( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir aSymbol.Size = aNewSize;
505cdf0e10cSrcweir lcl_correctSymbolSizeForBitmaps(aSymbol);
506cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) );
507cdf0e10cSrcweir }
508cdf0e10cSrcweir }
509cdf0e10cSrcweir
getPropertyState(const Reference<beans::XPropertyState> & xInnerPropertyState) const510cdf0e10cSrcweir beans::PropertyState WrappedSymbolSizeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
511cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
512cdf0e10cSrcweir {
513cdf0e10cSrcweir //only export symbol size if necessary
514cdf0e10cSrcweir if( m_ePropertyType == DIAGRAM )
515cdf0e10cSrcweir return beans::PropertyState_DEFAULT_VALUE;
516cdf0e10cSrcweir
517cdf0e10cSrcweir try
518cdf0e10cSrcweir {
519cdf0e10cSrcweir chart2::Symbol aSymbol;
520cdf0e10cSrcweir Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY );
521cdf0e10cSrcweir if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ))
522cdf0e10cSrcweir {
523cdf0e10cSrcweir if( chart2::SymbolStyle_NONE != aSymbol.Style )
524cdf0e10cSrcweir return beans::PropertyState_DIRECT_VALUE;
525cdf0e10cSrcweir }
526cdf0e10cSrcweir }
527cdf0e10cSrcweir catch( const uno::Exception & ex )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
530cdf0e10cSrcweir }
531cdf0e10cSrcweir return beans::PropertyState_DEFAULT_VALUE;
532cdf0e10cSrcweir }
533cdf0e10cSrcweir
534cdf0e10cSrcweir //-----------------------------------------------------------------------------
535cdf0e10cSrcweir //-----------------------------------------------------------------------------
536cdf0e10cSrcweir //-----------------------------------------------------------------------------
537cdf0e10cSrcweir
WrappedSymbolAndLinesProperty(::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact,tSeriesOrDiagramPropertyType ePropertyType)538cdf0e10cSrcweir WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty(
539cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
540cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType )
541cdf0e10cSrcweir : WrappedSeriesOrDiagramProperty< sal_Bool >( C2U("Lines")
542cdf0e10cSrcweir , uno::makeAny( sal_True ), spChart2ModelContact, ePropertyType )
543cdf0e10cSrcweir {
544cdf0e10cSrcweir }
545cdf0e10cSrcweir
~WrappedSymbolAndLinesProperty()546cdf0e10cSrcweir WrappedSymbolAndLinesProperty::~WrappedSymbolAndLinesProperty()
547cdf0e10cSrcweir {
548cdf0e10cSrcweir }
549cdf0e10cSrcweir
getValueFromSeries(const Reference<beans::XPropertySet> &) const550cdf0e10cSrcweir sal_Bool WrappedSymbolAndLinesProperty::getValueFromSeries( const Reference< beans::XPropertySet >& /*xSeriesPropertySet*/ ) const
551cdf0e10cSrcweir {
552cdf0e10cSrcweir //do not export this property anymore, instead use a linestyle none for no lines
553cdf0e10cSrcweir return sal_True;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir
setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet,sal_Bool bDrawLines) const556cdf0e10cSrcweir void WrappedSymbolAndLinesProperty::setValueToSeries(
557cdf0e10cSrcweir const Reference< beans::XPropertySet >& xSeriesPropertySet,
558cdf0e10cSrcweir sal_Bool bDrawLines ) const
559cdf0e10cSrcweir {
560cdf0e10cSrcweir if(!xSeriesPropertySet.is())
561cdf0e10cSrcweir return;
562cdf0e10cSrcweir
563cdf0e10cSrcweir drawing::LineStyle eOldLineStyle( drawing::LineStyle_SOLID );
564cdf0e10cSrcweir xSeriesPropertySet->getPropertyValue( C2U("LineStyle") ) >>= eOldLineStyle;
565cdf0e10cSrcweir if( bDrawLines )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir //#i114298# don't overwrite dashed lines with solid lines here
568cdf0e10cSrcweir if( eOldLineStyle == drawing::LineStyle_NONE )
569cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("LineStyle"), uno::makeAny( drawing::LineStyle_SOLID ) );
570cdf0e10cSrcweir }
571cdf0e10cSrcweir else
572cdf0e10cSrcweir {
573cdf0e10cSrcweir if( eOldLineStyle != drawing::LineStyle_NONE )
574cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("LineStyle"), uno::makeAny( drawing::LineStyle_NONE ) );
575cdf0e10cSrcweir }
576cdf0e10cSrcweir }
577cdf0e10cSrcweir
getPropertyState(const Reference<beans::XPropertyState> &) const578cdf0e10cSrcweir beans::PropertyState WrappedSymbolAndLinesProperty::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
579cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
580cdf0e10cSrcweir {
581cdf0e10cSrcweir //do not export this property anymore, instead use a linestyle none for no lines
582cdf0e10cSrcweir return beans::PropertyState_DEFAULT_VALUE;
583cdf0e10cSrcweir }
584cdf0e10cSrcweir
585cdf0e10cSrcweir //-----------------------------------------------------------------------------
586cdf0e10cSrcweir //-----------------------------------------------------------------------------
587cdf0e10cSrcweir //-----------------------------------------------------------------------------
588cdf0e10cSrcweir
589cdf0e10cSrcweir } //namespace wrapper
590cdf0e10cSrcweir } //namespace chart
591cdf0e10cSrcweir //.............................................................................
592