1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_chart2.hxx"
30*cdf0e10cSrcweir #include "TitleWrapper.hxx"
31*cdf0e10cSrcweir #include "macros.hxx"
32*cdf0e10cSrcweir #include "ContainerHelper.hxx"
33*cdf0e10cSrcweir #include "ControllerLockGuard.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <comphelper/InlineContainer.hxx>
36*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/chart2/RelativePosition.hpp>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include "CharacterProperties.hxx"
40*cdf0e10cSrcweir #include "LineProperties.hxx"
41*cdf0e10cSrcweir #include "FillProperties.hxx"
42*cdf0e10cSrcweir #include "UserDefinedProperties.hxx"
43*cdf0e10cSrcweir #include "WrappedCharacterHeightProperty.hxx"
44*cdf0e10cSrcweir #include "WrappedTextRotationProperty.hxx"
45*cdf0e10cSrcweir #include "WrappedAutomaticPositionProperties.hxx"
46*cdf0e10cSrcweir #include "WrappedScaleTextProperties.hxx"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <algorithm>
49*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir using namespace ::com::sun::star;
52*cdf0e10cSrcweir using ::com::sun::star::beans::Property;
53*cdf0e10cSrcweir using ::osl::MutexGuard;
54*cdf0e10cSrcweir using ::rtl::OUString;
55*cdf0e10cSrcweir using ::com::sun::star::uno::Any;
56*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
57*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir namespace chart
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir class WrappedTitleStringProperty : public WrappedProperty
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir public:
65*cdf0e10cSrcweir     WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext );
66*cdf0e10cSrcweir     virtual ~WrappedTitleStringProperty();
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
69*cdf0e10cSrcweir                                     throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException);
70*cdf0e10cSrcweir     virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
71*cdf0e10cSrcweir                                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
72*cdf0e10cSrcweir     virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
73*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir protected:
76*cdf0e10cSrcweir     Reference< uno::XComponentContext > m_xContext;
77*cdf0e10cSrcweir };
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir WrappedTitleStringProperty::WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext )
80*cdf0e10cSrcweir     : ::chart::WrappedProperty( C2U( "String" ), OUString() )
81*cdf0e10cSrcweir     , m_xContext( xContext )
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir }
84*cdf0e10cSrcweir WrappedTitleStringProperty::~WrappedTitleStringProperty()
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir void WrappedTitleStringProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
89*cdf0e10cSrcweir                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir     Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY);
92*cdf0e10cSrcweir     if(xTitle.is())
93*cdf0e10cSrcweir     {
94*cdf0e10cSrcweir         OUString aString;
95*cdf0e10cSrcweir         rOuterValue >>= aString;
96*cdf0e10cSrcweir         TitleHelper::setCompleteString( aString, xTitle, m_xContext );
97*cdf0e10cSrcweir     }
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir Any WrappedTitleStringProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
100*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir     Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
103*cdf0e10cSrcweir     Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY);
104*cdf0e10cSrcweir     if(xTitle.is())
105*cdf0e10cSrcweir     {
106*cdf0e10cSrcweir         Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText());
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir         ::rtl::OUStringBuffer aBuf;
109*cdf0e10cSrcweir         for( sal_Int32 i = 0; i < aStrings.getLength(); ++i )
110*cdf0e10cSrcweir         {
111*cdf0e10cSrcweir             aBuf.append( aStrings[ i ]->getString());
112*cdf0e10cSrcweir         }
113*cdf0e10cSrcweir         aRet <<= aBuf.makeStringAndClear();
114*cdf0e10cSrcweir     }
115*cdf0e10cSrcweir     return aRet;
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir Any WrappedTitleStringProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
118*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir     return uno::makeAny( rtl::OUString() );//default title is a empty String
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir //-----------------------------------------------------------------------------
124*cdf0e10cSrcweir //-----------------------------------------------------------------------------
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir class WrappedStackedTextProperty : public WrappedProperty
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir public:
129*cdf0e10cSrcweir     WrappedStackedTextProperty();
130*cdf0e10cSrcweir     virtual ~WrappedStackedTextProperty();
131*cdf0e10cSrcweir };
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir WrappedStackedTextProperty::WrappedStackedTextProperty()
134*cdf0e10cSrcweir     : ::chart::WrappedProperty( C2U( "StackedText" ), C2U( "StackCharacters" ) )
135*cdf0e10cSrcweir {
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir WrappedStackedTextProperty::~WrappedStackedTextProperty()
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir }// end namespace chart
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir //-----------------------------------------------------------------------------
145*cdf0e10cSrcweir //-----------------------------------------------------------------------------
146*cdf0e10cSrcweir //-----------------------------------------------------------------------------
147*cdf0e10cSrcweir //-----------------------------------------------------------------------------
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir namespace
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir static const OUString lcl_aServiceName(
152*cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Title" ));
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir enum
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir     PROP_TITLE_STRING,
157*cdf0e10cSrcweir     PROP_TITLE_TEXT_ROTATION,
158*cdf0e10cSrcweir     PROP_TITLE_TEXT_STACKED
159*cdf0e10cSrcweir };
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir void lcl_AddPropertiesToVector(
162*cdf0e10cSrcweir     ::std::vector< Property > & rOutProperties )
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir     rOutProperties.push_back(
165*cdf0e10cSrcweir         Property( C2U( "String" ),
166*cdf0e10cSrcweir                   PROP_TITLE_STRING,
167*cdf0e10cSrcweir                   ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
168*cdf0e10cSrcweir                   beans::PropertyAttribute::BOUND
169*cdf0e10cSrcweir                   | beans::PropertyAttribute::MAYBEVOID ));
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     rOutProperties.push_back(
172*cdf0e10cSrcweir         Property( C2U( "TextRotation" ),
173*cdf0e10cSrcweir                   PROP_TITLE_TEXT_ROTATION,
174*cdf0e10cSrcweir                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
175*cdf0e10cSrcweir                   beans::PropertyAttribute::BOUND
176*cdf0e10cSrcweir                   | beans::PropertyAttribute::MAYBEDEFAULT ));
177*cdf0e10cSrcweir     rOutProperties.push_back(
178*cdf0e10cSrcweir         Property( C2U( "StackedText" ),
179*cdf0e10cSrcweir                   PROP_TITLE_TEXT_STACKED,
180*cdf0e10cSrcweir                   ::getBooleanCppuType(),
181*cdf0e10cSrcweir                   beans::PropertyAttribute::BOUND
182*cdf0e10cSrcweir                   | beans::PropertyAttribute::MAYBEDEFAULT ));
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir struct StaticTitleWrapperPropertyArray_Initializer
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir     Sequence< Property >* operator()()
188*cdf0e10cSrcweir     {
189*cdf0e10cSrcweir         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
190*cdf0e10cSrcweir         return &aPropSeq;
191*cdf0e10cSrcweir     }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir private:
194*cdf0e10cSrcweir     Sequence< Property > lcl_GetPropertySequence()
195*cdf0e10cSrcweir     {
196*cdf0e10cSrcweir         ::std::vector< beans::Property > aProperties;
197*cdf0e10cSrcweir         lcl_AddPropertiesToVector( aProperties );
198*cdf0e10cSrcweir         ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
199*cdf0e10cSrcweir         ::chart::LineProperties::AddPropertiesToVector( aProperties );
200*cdf0e10cSrcweir         ::chart::FillProperties::AddPropertiesToVector( aProperties );
201*cdf0e10cSrcweir         //::chart::NamedProperties::AddPropertiesToVector( aProperties );
202*cdf0e10cSrcweir         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
203*cdf0e10cSrcweir         ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties );
204*cdf0e10cSrcweir         ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties );
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir         ::std::sort( aProperties.begin(), aProperties.end(),
207*cdf0e10cSrcweir                      ::chart::PropertyNameLess() );
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
210*cdf0e10cSrcweir     }
211*cdf0e10cSrcweir };
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir struct StaticTitleWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticTitleWrapperPropertyArray_Initializer >
214*cdf0e10cSrcweir {
215*cdf0e10cSrcweir };
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir } // anonymous namespace
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir // --------------------------------------------------------------------------------
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir namespace chart
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir namespace wrapper
224*cdf0e10cSrcweir {
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir TitleWrapper::TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType,
227*cdf0e10cSrcweir     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
228*cdf0e10cSrcweir         m_spChart2ModelContact( spChart2ModelContact ),
229*cdf0e10cSrcweir         m_aEventListenerContainer( m_aMutex ),
230*cdf0e10cSrcweir         m_eTitleType(eTitleType)
231*cdf0e10cSrcweir {
232*cdf0e10cSrcweir     ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY ));
233*cdf0e10cSrcweir     if( !getTitleObject().is() ) //#i83831# create an empty title at the model, thus references to properties can be mapped mapped correctly
234*cdf0e10cSrcweir         TitleHelper::createTitle( m_eTitleType, OUString(), m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
235*cdf0e10cSrcweir }
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir TitleWrapper::~TitleWrapper()
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir // ____ XShape ____
242*cdf0e10cSrcweir awt::Point SAL_CALL TitleWrapper::getPosition()
243*cdf0e10cSrcweir     throw (uno::RuntimeException)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir     return m_spChart2ModelContact->GetTitlePosition( this->getTitleObject() );
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir void SAL_CALL TitleWrapper::setPosition( const awt::Point& aPosition )
249*cdf0e10cSrcweir     throw (uno::RuntimeException)
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir     Reference< beans::XPropertySet > xPropertySet( this->getInnerPropertySet() );
252*cdf0e10cSrcweir     if(xPropertySet.is())
253*cdf0e10cSrcweir     {
254*cdf0e10cSrcweir         awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() );
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir         chart2::RelativePosition aRelativePosition;
257*cdf0e10cSrcweir         aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT;
258*cdf0e10cSrcweir         aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width);
259*cdf0e10cSrcweir         aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height);
260*cdf0e10cSrcweir         xPropertySet->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) );
261*cdf0e10cSrcweir     }
262*cdf0e10cSrcweir }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir awt::Size SAL_CALL TitleWrapper::getSize()
265*cdf0e10cSrcweir     throw (uno::RuntimeException)
266*cdf0e10cSrcweir {
267*cdf0e10cSrcweir     return m_spChart2ModelContact->GetTitleSize( this->getTitleObject() );
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir void SAL_CALL TitleWrapper::setSize( const awt::Size& /*aSize*/ )
271*cdf0e10cSrcweir     throw (beans::PropertyVetoException,
272*cdf0e10cSrcweir            uno::RuntimeException)
273*cdf0e10cSrcweir {
274*cdf0e10cSrcweir     OSL_ENSURE( false, "trying to set size of title" );
275*cdf0e10cSrcweir }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir // ____ XShapeDescriptor (base of XShape) ____
278*cdf0e10cSrcweir OUString SAL_CALL TitleWrapper::getShapeType()
279*cdf0e10cSrcweir     throw (uno::RuntimeException)
280*cdf0e10cSrcweir {
281*cdf0e10cSrcweir     return C2U( "com.sun.star.chart.ChartTitle" );
282*cdf0e10cSrcweir }
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir // ____ XComponent ____
285*cdf0e10cSrcweir void SAL_CALL TitleWrapper::dispose()
286*cdf0e10cSrcweir     throw (uno::RuntimeException)
287*cdf0e10cSrcweir {
288*cdf0e10cSrcweir     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
289*cdf0e10cSrcweir     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir     // /--
292*cdf0e10cSrcweir     MutexGuard aGuard( GetMutex());
293*cdf0e10cSrcweir     clearWrappedPropertySet();
294*cdf0e10cSrcweir     // \--
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir void SAL_CALL TitleWrapper::addEventListener(
298*cdf0e10cSrcweir     const Reference< lang::XEventListener >& xListener )
299*cdf0e10cSrcweir     throw (uno::RuntimeException)
300*cdf0e10cSrcweir {
301*cdf0e10cSrcweir 	m_aEventListenerContainer.addInterface( xListener );
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir void SAL_CALL TitleWrapper::removeEventListener(
305*cdf0e10cSrcweir     const Reference< lang::XEventListener >& aListener )
306*cdf0e10cSrcweir     throw (uno::RuntimeException)
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	m_aEventListenerContainer.removeInterface( aListener );
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir // ================================================================================
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir Reference< beans::XPropertySet > TitleWrapper::getFirstCharacterPropertySet()
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir     Reference< beans::XPropertySet > xProp;
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir     Reference< chart2::XTitle > xTitle( this->getTitleObject() );
318*cdf0e10cSrcweir     if( xTitle.is())
319*cdf0e10cSrcweir     {
320*cdf0e10cSrcweir         Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText());
321*cdf0e10cSrcweir         if( aStrings.getLength() > 0 )
322*cdf0e10cSrcweir             xProp.set( aStrings[0], uno::UNO_QUERY );
323*cdf0e10cSrcweir     }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir     return xProp;
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue )
329*cdf0e10cSrcweir {
330*cdf0e10cSrcweir     OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
331*cdf0e10cSrcweir                 nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP );
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir     Reference< beans::XPropertySet > xProp( getFirstCharacterPropertySet(), uno::UNO_QUERY );
334*cdf0e10cSrcweir     Reference< beans::XFastPropertySet > xFastProp( xProp, uno::UNO_QUERY );
335*cdf0e10cSrcweir     if(xProp.is())
336*cdf0e10cSrcweir     {
337*cdf0e10cSrcweir         const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle );
338*cdf0e10cSrcweir         if( pWrappedProperty )
339*cdf0e10cSrcweir         {
340*cdf0e10cSrcweir             rValue = pWrappedProperty->getPropertyValue( xProp );
341*cdf0e10cSrcweir         }
342*cdf0e10cSrcweir         else if( xFastProp.is() )
343*cdf0e10cSrcweir         {
344*cdf0e10cSrcweir             rValue = xFastProp->getFastPropertyValue( nHandle );
345*cdf0e10cSrcweir         }
346*cdf0e10cSrcweir     }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir void TitleWrapper::setFastCharacterPropertyValue(
351*cdf0e10cSrcweir     sal_Int32 nHandle, const Any& rValue ) throw (uno::Exception)
352*cdf0e10cSrcweir {
353*cdf0e10cSrcweir     OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
354*cdf0e10cSrcweir                 nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP );
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     Reference< chart2::XTitle > xTitle( this->getTitleObject() );
357*cdf0e10cSrcweir     if( xTitle.is())
358*cdf0e10cSrcweir     {
359*cdf0e10cSrcweir         Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText());
360*cdf0e10cSrcweir         const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle );
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir         for( sal_Int32 i = 0; i < aStrings.getLength(); ++i )
363*cdf0e10cSrcweir         {
364*cdf0e10cSrcweir             Reference< beans::XFastPropertySet > xFastPropertySet( aStrings[ i ], uno::UNO_QUERY );
365*cdf0e10cSrcweir             Reference< beans::XPropertySet > xPropSet( xFastPropertySet, uno::UNO_QUERY );
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir             if( pWrappedProperty )
368*cdf0e10cSrcweir                 pWrappedProperty->setPropertyValue( rValue, xPropSet );
369*cdf0e10cSrcweir             else if( xFastPropertySet.is() )
370*cdf0e10cSrcweir                 xFastPropertySet->setFastPropertyValue( nHandle, rValue );
371*cdf0e10cSrcweir         }
372*cdf0e10cSrcweir     }
373*cdf0e10cSrcweir }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir // ================================================================================
376*cdf0e10cSrcweir // WrappedPropertySet
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir void SAL_CALL TitleWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
379*cdf0e10cSrcweir                                     throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
380*cdf0e10cSrcweir {
381*cdf0e10cSrcweir     sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
382*cdf0e10cSrcweir     if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
383*cdf0e10cSrcweir     {
384*cdf0e10cSrcweir         setFastCharacterPropertyValue( nHandle, rValue );
385*cdf0e10cSrcweir     }
386*cdf0e10cSrcweir     else
387*cdf0e10cSrcweir         WrappedPropertySet::setPropertyValue( rPropertyName, rValue );
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir Any SAL_CALL TitleWrapper::getPropertyValue( const OUString& rPropertyName )
391*cdf0e10cSrcweir                                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir     Any aRet;
394*cdf0e10cSrcweir     sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
395*cdf0e10cSrcweir     if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
396*cdf0e10cSrcweir         getFastCharacterPropertyValue( nHandle, aRet );
397*cdf0e10cSrcweir     else
398*cdf0e10cSrcweir         aRet = WrappedPropertySet::getPropertyValue( rPropertyName );
399*cdf0e10cSrcweir     return aRet;
400*cdf0e10cSrcweir }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir beans::PropertyState SAL_CALL TitleWrapper::getPropertyState( const OUString& rPropertyName )
403*cdf0e10cSrcweir                                     throw (beans::UnknownPropertyException, uno::RuntimeException)
404*cdf0e10cSrcweir {
405*cdf0e10cSrcweir     beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE );
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir     sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
408*cdf0e10cSrcweir     if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
409*cdf0e10cSrcweir     {
410*cdf0e10cSrcweir         Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY );
411*cdf0e10cSrcweir         if( xPropState.is() )
412*cdf0e10cSrcweir         {
413*cdf0e10cSrcweir             const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
414*cdf0e10cSrcweir             if( pWrappedProperty )
415*cdf0e10cSrcweir                 aState = pWrappedProperty->getPropertyState( xPropState );
416*cdf0e10cSrcweir             else
417*cdf0e10cSrcweir                 aState = xPropState->getPropertyState( rPropertyName );
418*cdf0e10cSrcweir         }
419*cdf0e10cSrcweir     }
420*cdf0e10cSrcweir     else
421*cdf0e10cSrcweir         aState = WrappedPropertySet::getPropertyState( rPropertyName );
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir     return aState;
424*cdf0e10cSrcweir }
425*cdf0e10cSrcweir void SAL_CALL TitleWrapper::setPropertyToDefault( const OUString& rPropertyName )
426*cdf0e10cSrcweir                                     throw (beans::UnknownPropertyException, uno::RuntimeException)
427*cdf0e10cSrcweir {
428*cdf0e10cSrcweir     sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
429*cdf0e10cSrcweir     if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
430*cdf0e10cSrcweir     {
431*cdf0e10cSrcweir         Any aDefault = getPropertyDefault( rPropertyName );
432*cdf0e10cSrcweir         setFastCharacterPropertyValue( nHandle, aDefault );
433*cdf0e10cSrcweir     }
434*cdf0e10cSrcweir     else
435*cdf0e10cSrcweir         WrappedPropertySet::setPropertyToDefault( rPropertyName );
436*cdf0e10cSrcweir }
437*cdf0e10cSrcweir Any SAL_CALL TitleWrapper::getPropertyDefault( const OUString& rPropertyName )
438*cdf0e10cSrcweir                                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
439*cdf0e10cSrcweir {
440*cdf0e10cSrcweir     Any aRet;
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir     sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
443*cdf0e10cSrcweir     if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
444*cdf0e10cSrcweir     {
445*cdf0e10cSrcweir         Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY );
446*cdf0e10cSrcweir         if( xPropState.is() )
447*cdf0e10cSrcweir         {
448*cdf0e10cSrcweir             const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
449*cdf0e10cSrcweir             if( pWrappedProperty )
450*cdf0e10cSrcweir                 aRet = pWrappedProperty->getPropertyDefault(xPropState);
451*cdf0e10cSrcweir             else
452*cdf0e10cSrcweir                 aRet = xPropState->getPropertyDefault( rPropertyName );
453*cdf0e10cSrcweir         }
454*cdf0e10cSrcweir     }
455*cdf0e10cSrcweir     else
456*cdf0e10cSrcweir         aRet = WrappedPropertySet::getPropertyDefault( rPropertyName );
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir     return aRet;
459*cdf0e10cSrcweir }
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir void SAL_CALL TitleWrapper::addPropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener )
462*cdf0e10cSrcweir                                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
463*cdf0e10cSrcweir {
464*cdf0e10cSrcweir     sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
465*cdf0e10cSrcweir     if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
466*cdf0e10cSrcweir     {
467*cdf0e10cSrcweir         Reference< beans::XPropertySet > xPropSet( getFirstCharacterPropertySet(), uno::UNO_QUERY );
468*cdf0e10cSrcweir         if( xPropSet.is() )
469*cdf0e10cSrcweir             xPropSet->addPropertyChangeListener( rPropertyName, xListener );
470*cdf0e10cSrcweir     }
471*cdf0e10cSrcweir     else
472*cdf0e10cSrcweir         WrappedPropertySet::addPropertyChangeListener( rPropertyName, xListener );
473*cdf0e10cSrcweir }
474*cdf0e10cSrcweir void SAL_CALL TitleWrapper::removePropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener )
475*cdf0e10cSrcweir                                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
476*cdf0e10cSrcweir {
477*cdf0e10cSrcweir     sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
478*cdf0e10cSrcweir     if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
479*cdf0e10cSrcweir     {
480*cdf0e10cSrcweir         Reference< beans::XPropertySet > xPropSet( getFirstCharacterPropertySet(), uno::UNO_QUERY );
481*cdf0e10cSrcweir         if( xPropSet.is() )
482*cdf0e10cSrcweir             xPropSet->removePropertyChangeListener( rPropertyName, xListener );
483*cdf0e10cSrcweir     }
484*cdf0e10cSrcweir     else
485*cdf0e10cSrcweir         WrappedPropertySet::removePropertyChangeListener( rPropertyName, xListener );
486*cdf0e10cSrcweir }
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir // ================================================================================
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir //ReferenceSizePropertyProvider
491*cdf0e10cSrcweir void TitleWrapper::updateReferenceSize()
492*cdf0e10cSrcweir {
493*cdf0e10cSrcweir     Reference< beans::XPropertySet > xProp( this->getTitleObject(), uno::UNO_QUERY );
494*cdf0e10cSrcweir     if( xProp.is() )
495*cdf0e10cSrcweir     {
496*cdf0e10cSrcweir         if( xProp->getPropertyValue( C2U("ReferencePageSize") ).hasValue() )
497*cdf0e10cSrcweir             xProp->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny(
498*cdf0e10cSrcweir                             m_spChart2ModelContact->GetPageSize() ));
499*cdf0e10cSrcweir     }
500*cdf0e10cSrcweir }
501*cdf0e10cSrcweir Any TitleWrapper::getReferenceSize()
502*cdf0e10cSrcweir {
503*cdf0e10cSrcweir     Any aRet;
504*cdf0e10cSrcweir     Reference< beans::XPropertySet > xProp( this->getTitleObject(), uno::UNO_QUERY );
505*cdf0e10cSrcweir     if( xProp.is() )
506*cdf0e10cSrcweir         aRet = xProp->getPropertyValue( C2U("ReferencePageSize") );
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir     return aRet;
509*cdf0e10cSrcweir }
510*cdf0e10cSrcweir awt::Size TitleWrapper::getCurrentSizeForReference()
511*cdf0e10cSrcweir {
512*cdf0e10cSrcweir     return m_spChart2ModelContact->GetPageSize();
513*cdf0e10cSrcweir }
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir // ================================================================================
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir Reference< chart2::XTitle > TitleWrapper::getTitleObject()
518*cdf0e10cSrcweir {
519*cdf0e10cSrcweir     return TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() );
520*cdf0e10cSrcweir }
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir // WrappedPropertySet
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir Reference< beans::XPropertySet > TitleWrapper::getInnerPropertySet()
525*cdf0e10cSrcweir {
526*cdf0e10cSrcweir     return Reference< beans::XPropertySet >( this->getTitleObject(), uno::UNO_QUERY );
527*cdf0e10cSrcweir }
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir const Sequence< beans::Property >& TitleWrapper::getPropertySequence()
530*cdf0e10cSrcweir {
531*cdf0e10cSrcweir     return *StaticTitleWrapperPropertyArray::get();
532*cdf0e10cSrcweir }
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir const std::vector< WrappedProperty* > TitleWrapper::createWrappedProperties()
535*cdf0e10cSrcweir {
536*cdf0e10cSrcweir     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir     aWrappedProperties.push_back( new WrappedTitleStringProperty( m_spChart2ModelContact->m_xContext ) );
539*cdf0e10cSrcweir     aWrappedProperties.push_back( new WrappedTextRotationProperty( m_eTitleType==TitleHelper::Y_AXIS_TITLE || m_eTitleType==TitleHelper::X_AXIS_TITLE ) );
540*cdf0e10cSrcweir     aWrappedProperties.push_back( new WrappedStackedTextProperty() );
541*cdf0e10cSrcweir     WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
542*cdf0e10cSrcweir     WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties );
543*cdf0e10cSrcweir     WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir     return aWrappedProperties;
546*cdf0e10cSrcweir }
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir // ================================================================================
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir Sequence< OUString > TitleWrapper::getSupportedServiceNames_Static()
551*cdf0e10cSrcweir {
552*cdf0e10cSrcweir     Sequence< OUString > aServices( 4 );
553*cdf0e10cSrcweir     aServices[ 0 ] = C2U( "com.sun.star.chart.ChartTitle" );
554*cdf0e10cSrcweir     aServices[ 1 ] = C2U( "com.sun.star.drawing.Shape" );
555*cdf0e10cSrcweir     aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
556*cdf0e10cSrcweir     aServices[ 3 ] = C2U( "com.sun.star.style.CharacterProperties" );
557*cdf0e10cSrcweir //     aServices[ 4 ] = C2U( "com.sun.star.beans.PropertySet" );
558*cdf0e10cSrcweir //     aServices[ 5 ] = C2U( "com.sun.star.drawing.FillProperties" );
559*cdf0e10cSrcweir //     aServices[ 6 ] = C2U( "com.sun.star.drawing.LineProperties" );
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir     return aServices;
562*cdf0e10cSrcweir }
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
565*cdf0e10cSrcweir APPHELPER_XSERVICEINFO_IMPL( TitleWrapper, lcl_aServiceName );
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir } //  namespace wrapper
568*cdf0e10cSrcweir } //  namespace chart
569