1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RptObject.cxx,v $
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 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
31 #include "RptObject.hxx"
36 #include <svx/unoshape.hxx>
37 #include "RptModel.hxx"
38 #include "RptObjectListener.hxx"
39 #include <toolkit/helper/vclunohelper.hxx>
40 #include <toolkit/helper/convert.hxx>
41 #include "RptPage.hxx"
42 #include "corestrings.hrc"
43 #include <dbaccess/singledoccontroller.hxx>
44 #include "ModuleHelper.hxx"
46 #include <RptResId.hrc>
47 #include <svx/xflclit.hxx>
48 #include <svx/xlnclit.hxx>
49 #include <svx/xlndsit.hxx>
50 #include <svx/xlineit0.hxx>
51 #include <svx/sderitm.hxx>
52 #include <svx/xlnwtit.hxx>
53 #include <svx/xlntrit.hxx>
54 #include <com/sun/star/style/XStyle.hpp>
55 #include <com/sun/star/awt/XTabControllerModel.hpp>
56 #include <com/sun/star/awt/XUnoControlContainer.hpp>
57 #include <com/sun/star/awt/XVclContainerPeer.hpp>
58 #include <com/sun/star/awt/XWindow.hpp>
59 #include <com/sun/star/awt/TextAlign.hpp>
60 #include <com/sun/star/beans/XPropertySet.hpp>
61 #include <com/sun/star/beans/PropertyAttribute.hpp>
62 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
63 #include <com/sun/star/container/XContainer.hpp>
64 #include <com/sun/star/lang/XServiceInfo.hpp>
65 #include <com/sun/star/report/XShape.hpp>
66 #include <com/sun/star/report/XFixedLine.hpp>
67 #include <com/sun/star/chart/ChartDataRowSource.hpp>
68 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
69 #include <com/sun/star/chart2/data/DatabaseDataProvider.hpp>
70 #include <com/sun/star/chart2/XChartDocument.hpp>
71 #include <com/sun/star/style/VerticalAlignment.hpp>
72 #include <com/sun/star/style/ParagraphAdjust.hpp>
73 #include <com/sun/star/report/XFormattedField.hpp>
74 #include <comphelper/genericpropertyset.hxx>
75 #include <comphelper/processfactory.hxx>
76 #include <comphelper/property.hxx>
77 #include <tools/diagnose_ex.h>
78 #include "PropertyForward.hxx"
79 #include <connectivity/dbtools.hxx>
80 #include <connectivity/dbconversion.hxx>
81 #include "UndoActions.hxx"
82 #include "UndoEnv.hxx"
89 using namespace ::com::sun::star
;
91 using namespace beans
;
92 using namespace reportdesign
;
93 using namespace container
;
94 using namespace script
;
95 using namespace report
;
96 //----------------------------------------------------------------------------
97 sal_uInt16
OObjectBase::getObjectType(const uno::Reference
< report::XReportComponent
>& _xComponent
)
99 uno::Reference
< lang::XServiceInfo
> xServiceInfo( _xComponent
, uno::UNO_QUERY
);
100 OSL_ENSURE(xServiceInfo
.is(),"Who deletes the XServiceInfo interface!");
101 if ( xServiceInfo
.is() )
103 if ( xServiceInfo
->supportsService( SERVICE_FIXEDTEXT
))
104 return OBJ_DLG_FIXEDTEXT
;
105 if ( xServiceInfo
->supportsService( SERVICE_FIXEDLINE
))
107 uno::Reference
< report::XFixedLine
> xFixedLine(_xComponent
,uno::UNO_QUERY
);
108 return xFixedLine
->getOrientation() ? OBJ_DLG_HFIXEDLINE
: OBJ_DLG_VFIXEDLINE
;
110 if ( xServiceInfo
->supportsService( SERVICE_IMAGECONTROL
))
111 return OBJ_DLG_IMAGECONTROL
;
112 if ( xServiceInfo
->supportsService( SERVICE_FORMATTEDFIELD
))
113 return OBJ_DLG_FORMATTEDFIELD
;
114 if ( xServiceInfo
->supportsService( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")) ) )
116 if ( xServiceInfo
->supportsService( SERVICE_SHAPE
))
117 return OBJ_CUSTOMSHAPE
;
118 if ( xServiceInfo
->supportsService( SERVICE_REPORTDEFINITION
) )
119 return OBJ_DLG_SUBREPORT
;
124 // -----------------------------------------------------------------------------
125 SdrObject
* OObjectBase::createObject(const uno::Reference
< report::XReportComponent
>& _xComponent
)
127 SdrObject
* pNewObj
= NULL
;
128 sal_uInt16 nType
= OObjectBase::getObjectType(_xComponent
);
131 case OBJ_DLG_FIXEDTEXT
:
133 OUnoObject
* pUnoObj
= new OUnoObject( _xComponent
134 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))
138 uno::Reference
<beans::XPropertySet
> xControlModel(pUnoObj
->GetUnoControlModel(),uno::UNO_QUERY
);
139 if ( xControlModel
.is() )
140 xControlModel
->setPropertyValue( PROPERTY_MULTILINE
,uno::makeAny(sal_True
));
143 case OBJ_DLG_IMAGECONTROL
:
144 pNewObj
= new OUnoObject(_xComponent
145 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl"))
146 ,OBJ_DLG_IMAGECONTROL
);
148 case OBJ_DLG_FORMATTEDFIELD
:
149 pNewObj
= new OUnoObject( _xComponent
150 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField"))
151 ,OBJ_DLG_FORMATTEDFIELD
);
153 case OBJ_DLG_HFIXEDLINE
:
154 case OBJ_DLG_VFIXEDLINE
:
155 pNewObj
= new OUnoObject( _xComponent
156 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel"))
159 case OBJ_CUSTOMSHAPE
:
160 pNewObj
= OCustomShape::Create( _xComponent
);
163 sal_Bool bOpaque
= sal_False
;
164 _xComponent
->getPropertyValue(PROPERTY_OPAQUE
) >>= bOpaque
;
165 pNewObj
->SetLayer(bOpaque
? RPT_LAYER_FRONT
: RPT_LAYER_BACK
);
167 catch(const uno::Exception
&)
169 DBG_UNHANDLED_EXCEPTION();
172 case OBJ_DLG_SUBREPORT
:
174 pNewObj
= OOle2Obj::Create( _xComponent
,nType
);
177 OSL_ENSURE(0,"Unknown object id");
181 ensureSdrObjectOwnership( _xComponent
);
185 // -----------------------------------------------------------------------------
188 class ParaAdjust
: public AnyConverter
191 virtual ::com::sun::star::uno::Any
operator() (const ::rtl::OUString
& _sPropertyName
,const ::com::sun::star::uno::Any
& lhs
) const
194 if ( _sPropertyName
.equalsAscii(PROPERTY_PARAADJUST
) )
196 sal_Int16 nTextAlign
= 0;
200 case awt::TextAlign::LEFT
:
201 nTextAlign
= style::ParagraphAdjust_LEFT
;
203 case awt::TextAlign::CENTER
:
204 nTextAlign
= style::ParagraphAdjust_CENTER
;
206 case awt::TextAlign::RIGHT
:
207 nTextAlign
= style::ParagraphAdjust_RIGHT
;
210 OSL_ENSURE(0,"Illegal text alignment value!");
212 } // switch(nTextAlign)
213 aRet
<<= (style::ParagraphAdjust
)nTextAlign
;
217 sal_Int16 nTextAlign
= 0;
218 sal_Int16 eParagraphAdjust
= 0;
219 lhs
>>= eParagraphAdjust
;
220 switch(eParagraphAdjust
)
222 case style::ParagraphAdjust_LEFT
:
223 case style::ParagraphAdjust_BLOCK
:
224 nTextAlign
= awt::TextAlign::LEFT
;
226 case style::ParagraphAdjust_CENTER
:
227 nTextAlign
= awt::TextAlign::CENTER
;
229 case style::ParagraphAdjust_RIGHT
:
230 nTextAlign
= awt::TextAlign::RIGHT
;
233 OSL_ENSURE(0,"Illegal text alignment value!");
235 } // switch(eParagraphAdjust)
242 // -----------------------------------------------------------------------------
243 const TPropertyNamePair
& getPropertyNameMap(sal_uInt16 _nObjectId
)
247 case OBJ_DLG_IMAGECONTROL
:
249 static TPropertyNamePair s_aNameMap
;
250 if ( s_aNameMap
.empty() )
252 ::boost::shared_ptr
<AnyConverter
> aNoConverter(new AnyConverter());
253 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND
,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR
,aNoConverter
)));
254 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER
,TPropertyConverter(PROPERTY_BORDER
,aNoConverter
)));
255 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR
,TPropertyConverter(PROPERTY_BORDERCOLOR
,aNoConverter
)));
256 //s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,PROPERTY_ALIGN));
261 case OBJ_DLG_FIXEDTEXT
:
263 static TPropertyNamePair s_aNameMap
;
264 if ( s_aNameMap
.empty() )
266 ::boost::shared_ptr
<AnyConverter
> aNoConverter(new AnyConverter());
267 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARCOLOR
,TPropertyConverter(PROPERTY_TEXTCOLOR
,aNoConverter
)));
268 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND
,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR
,aNoConverter
)));
269 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARUNDERLINECOLOR
,TPropertyConverter(PROPERTY_TEXTLINECOLOR
,aNoConverter
)));
270 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARRELIEF
,TPropertyConverter(PROPERTY_FONTRELIEF
,aNoConverter
)));
271 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARFONTHEIGHT
,TPropertyConverter(PROPERTY_FONTHEIGHT
,aNoConverter
)));
272 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARSTRIKEOUT
,TPropertyConverter(PROPERTY_FONTSTRIKEOUT
,aNoConverter
)));
273 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLTEXTEMPHASISMARK
,TPropertyConverter(PROPERTY_FONTEMPHASISMARK
,aNoConverter
)));
274 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER
,TPropertyConverter(PROPERTY_BORDER
,aNoConverter
)));
275 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR
,TPropertyConverter(PROPERTY_BORDERCOLOR
,aNoConverter
)));
277 ::boost::shared_ptr
<AnyConverter
> aParaAdjust(new ParaAdjust());
278 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST
,TPropertyConverter(PROPERTY_ALIGN
,aParaAdjust
)));
282 case OBJ_DLG_FORMATTEDFIELD
:
284 static TPropertyNamePair s_aNameMap
;
285 if ( s_aNameMap
.empty() )
287 ::boost::shared_ptr
<AnyConverter
> aNoConverter(new AnyConverter());
288 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARCOLOR
,TPropertyConverter(PROPERTY_TEXTCOLOR
,aNoConverter
)));
289 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND
,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR
,aNoConverter
)));
290 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARUNDERLINECOLOR
,TPropertyConverter(PROPERTY_TEXTLINECOLOR
,aNoConverter
)));
291 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARRELIEF
,TPropertyConverter(PROPERTY_FONTRELIEF
,aNoConverter
)));
292 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARFONTHEIGHT
,TPropertyConverter(PROPERTY_FONTHEIGHT
,aNoConverter
)));
293 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CHARSTRIKEOUT
,TPropertyConverter(PROPERTY_FONTSTRIKEOUT
,aNoConverter
)));
294 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLTEXTEMPHASISMARK
,TPropertyConverter(PROPERTY_FONTEMPHASISMARK
,aNoConverter
)));
295 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER
,TPropertyConverter(PROPERTY_BORDER
,aNoConverter
)));
296 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR
,TPropertyConverter(PROPERTY_BORDERCOLOR
,aNoConverter
)));
297 //s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aNoConverter)));
298 ::boost::shared_ptr
<AnyConverter
> aParaAdjust(new ParaAdjust());
299 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST
,TPropertyConverter(PROPERTY_ALIGN
,aParaAdjust
)));
304 case OBJ_CUSTOMSHAPE
:
306 static TPropertyNamePair s_aNameMap
;
307 if ( s_aNameMap
.empty() )
309 ::boost::shared_ptr
<AnyConverter
> aNoConverter(new AnyConverter());
310 s_aNameMap
.insert(TPropertyNamePair::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillColor")),TPropertyConverter(PROPERTY_CONTROLBACKGROUND
,aNoConverter
)));
311 s_aNameMap
.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST
,TPropertyConverter(PROPERTY_ALIGN
,aNoConverter
)));
319 static TPropertyNamePair s_aEmptyNameMap
;
320 return s_aEmptyNameMap
;
322 // -----------------------------------------------------------------------------
324 DBG_NAME( rpt_OObjectBase
)
325 OObjectBase::OObjectBase(const uno::Reference
< report::XReportComponent
>& _xComponent
)
326 :m_bIsListening(sal_False
)
328 DBG_CTOR( rpt_OObjectBase
,NULL
);
329 m_xReportComponent
= _xComponent
;
331 //----------------------------------------------------------------------------
332 OObjectBase::OObjectBase(const ::rtl::OUString
& _sComponentName
)
333 :m_sComponentName(_sComponentName
)
334 ,m_bIsListening(sal_False
)
336 DBG_CTOR( rpt_OObjectBase
,NULL
);
338 //----------------------------------------------------------------------------
339 OObjectBase::~OObjectBase()
341 DBG_DTOR( rpt_OObjectBase
,NULL
);
345 m_xReportComponent
.clear();
347 // -----------------------------------------------------------------------------
348 uno::Reference
< report::XSection
> OObjectBase::getSection() const
350 uno::Reference
< report::XSection
> xSection
;
351 OReportPage
* pPage
= dynamic_cast<OReportPage
*>(GetImplPage());
353 xSection
= pPage
->getSection();
356 // -----------------------------------------------------------------------------
357 uno::Reference
< report::XReportComponent
> OObjectBase::getReportComponent() const
359 return m_xReportComponent
;
361 // -----------------------------------------------------------------------------
362 uno::Reference
< beans::XPropertySet
> OObjectBase::getAwtComponent()
364 return uno::Reference
< beans::XPropertySet
>();
366 // -----------------------------------------------------------------------------
367 sal_Bool
OObjectBase::IsInside(const Rectangle
& _rRect
,const Point
& rPnt
,USHORT nTol
) const
369 sal_Bool bRet
= sal_False
;
370 Rectangle
aRect( _rRect
);
371 if ( !aRect
.IsEmpty() )
373 aRect
.Left() -= nTol
;
375 aRect
.Right() = ( aRect
.Right() == RECT_EMPTY
? _rRect
.Left() + nTol
: aRect
.Right() + nTol
);
376 aRect
.Bottom() = ( aRect
.Bottom() == RECT_EMPTY
? _rRect
.Top() + nTol
: aRect
.Bottom() + nTol
);
378 bRet
= aRect
.IsInside( rPnt
);
382 //----------------------------------------------------------------------------
383 void OObjectBase::StartListening()
385 DBG_CHKTHIS( rpt_OObjectBase
,NULL
);
386 OSL_ENSURE(!isListening(), "OUnoObject::StartListening: already listening!");
388 if ( !isListening() && m_xReportComponent
.is() )
390 m_bIsListening
= sal_True
;
392 if ( !m_xPropertyChangeListener
.is() )
394 m_xPropertyChangeListener
= new OObjectListener( this );
395 // register listener to all properties
396 m_xReportComponent
->addPropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener
);
400 //----------------------------------------------------------------------------
401 void OObjectBase::EndListening(sal_Bool
/*bRemoveListener*/)
403 DBG_CHKTHIS( rpt_OObjectBase
,NULL
);
404 OSL_ENSURE(!m_xReportComponent
.is() || isListening(), "OUnoObject::EndListening: not listening currently!");
406 m_bIsListening
= sal_False
;
407 if ( isListening() && m_xReportComponent
.is() )
409 // XPropertyChangeListener
410 if ( m_xPropertyChangeListener
.is() )
415 m_xReportComponent
->removePropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener
);
417 catch(uno::Exception
)
419 OSL_ENSURE(0,"OObjectBase::EndListening: Exception caught!");
422 m_xPropertyChangeListener
.clear();
425 //----------------------------------------------------------------------------
426 void OObjectBase::SetPropsFromRect(const Rectangle
& _rRect
)
428 DBG_CHKTHIS( rpt_OObjectBase
,NULL
);
430 OReportPage
* pPage
= dynamic_cast<OReportPage
*>(GetImplPage());
431 if ( pPage
&& !_rRect
.IsEmpty() )
433 uno::Reference
<report::XSection
> xSection
= pPage
->getSection();
434 if ( xSection
.is() && (static_cast<sal_uInt32
>(_rRect
.getHeight() + _rRect
.Top()) > xSection
->getHeight()) )
435 xSection
->setHeight(_rRect
.getHeight() + _rRect
.Top());
438 //pModel->GetRefDevice()->Invalidate(INVALIDATE_CHILDREN);
441 //----------------------------------------------------------------------------
442 void OObjectBase::_propertyChange( const beans::PropertyChangeEvent
& /*evt*/ ) throw( uno::RuntimeException
)
444 DBG_CHKTHIS( rpt_OObjectBase
,NULL
);
446 //----------------------------------------------------------------------------
447 void OObjectBase::SetObjectItemHelper(const SfxPoolItem
& /*rItem*/)
452 //----------------------------------------------------------------------------
453 sal_Bool
OObjectBase::supportsService( const ::rtl::OUString
& _sServiceName
) const
455 DBG_CHKTHIS( rpt_OObjectBase
,NULL
);
456 sal_Bool bSupports
= sal_False
;
458 Reference
< lang::XServiceInfo
> xServiceInfo( m_xReportComponent
, UNO_QUERY
);
459 // TODO: cache xServiceInfo as member?
460 if ( xServiceInfo
.is() )
461 bSupports
= xServiceInfo
->supportsService( _sServiceName
);
466 //----------------------------------------------------------------------------
467 void OObjectBase::ensureSdrObjectOwnership( const uno::Reference
< uno::XInterface
>& _rxShape
)
469 // UNDO in the report designer is implemented at the level of the XShapes, not
470 // at the level of SdrObjects. That is, if an object is removed from the report
471 // design, then this happens by removing the XShape from the UNO DrawPage, and
472 // putting this XShape (resp. the ReportComponent which wraps it) into an UNDO
474 // Unfortunately, the SvxDrawPage implementation usually deletes SdrObjects
475 // which are removed from it, which is deadly for us. To prevent this,
476 // we give the XShape implementation the ownership of the SdrObject, which
477 // ensures the SvxDrawPage won't delete it.
478 SvxShape
* pShape
= SvxShape::getImplementation( _rxShape
);
479 OSL_ENSURE( pShape
, "OObjectBase::ensureSdrObjectOwnership: can't access the SvxShape!" );
482 OSL_ENSURE( !pShape
->HasSdrObjectOwnership(), "OObjectBase::ensureSdrObjectOwnership: called twice?" );
483 pShape
->TakeSdrObjectOwnership();
487 //----------------------------------------------------------------------------
488 uno::Reference
< uno::XInterface
> OObjectBase::getUnoShapeOf( SdrObject
& _rSdrObject
)
490 uno::Reference
< uno::XInterface
> xShape( _rSdrObject
.getWeakUnoShape() );
494 xShape
= _rSdrObject
.SdrObject::getUnoShape();
498 ensureSdrObjectOwnership( xShape
);
500 m_xKeepShapeAlive
= xShape
;
504 //----------------------------------------------------------------------------
505 TYPEINIT1(OCustomShape
, SdrObjCustomShape
);
506 DBG_NAME( rpt_OCustomShape
);
507 OCustomShape::OCustomShape(const uno::Reference
< report::XReportComponent
>& _xComponent
510 ,OObjectBase(_xComponent
)
512 DBG_CTOR( rpt_OCustomShape
, NULL
);
513 impl_setUnoShape( uno::Reference
< uno::XInterface
>(_xComponent
,uno::UNO_QUERY
) );
514 m_bIsListening
= sal_True
;
516 //----------------------------------------------------------------------------
517 OCustomShape::OCustomShape(const ::rtl::OUString
& _sComponentName
)
519 ,OObjectBase(_sComponentName
)
521 DBG_CTOR( rpt_OCustomShape
, NULL
);
522 m_bIsListening
= sal_True
;
525 //----------------------------------------------------------------------------
526 OCustomShape::~OCustomShape()
528 DBG_DTOR( rpt_OCustomShape
, NULL
);
530 // -----------------------------------------------------------------------------
531 UINT16
OCustomShape::GetObjIdentifier() const
533 return UINT16(OBJ_CUSTOMSHAPE
);
535 //----------------------------------------------------------------------------
536 UINT32
OCustomShape::GetObjInventor() const
538 return ReportInventor
;
540 //----------------------------------------------------------------------------
541 SdrPage
* OCustomShape::GetImplPage() const
545 //----------------------------------------------------------------------------
546 void OCustomShape::SetSnapRectImpl(const Rectangle
& _rRect
)
548 SetSnapRect( _rRect
);
550 //----------------------------------------------------------------------------
551 sal_Int32
OCustomShape::GetStep() const
555 OSL_ENSURE(0,"Who called me!");
558 //----------------------------------------------------------------------------
559 void OCustomShape::NbcMove( const Size
& rSize
)
561 if ( m_bIsListening
)
563 m_bIsListening
= sal_False
;
565 if ( m_xReportComponent
.is() )
567 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
568 OXUndoEnvironment::OUndoEnvLock
aLock(pRptModel
->GetUndoEnv());
569 m_xReportComponent
->setPositionX(m_xReportComponent
->getPositionX() + rSize
.A());
570 m_xReportComponent
->setPositionY(m_xReportComponent
->getPositionY() + rSize
.B());
573 // set geometry properties
574 SetPropsFromRect(GetSnapRect());
576 m_bIsListening
= sal_True
;
579 SdrObjCustomShape::NbcMove( rSize
);
581 //----------------------------------------------------------------------------
582 void OCustomShape::NbcResize(const Point
& rRef
, const Fraction
& xFract
, const Fraction
& yFract
)
584 SdrObjCustomShape::NbcResize( rRef
, xFract
, yFract
);
586 SetPropsFromRect(GetSnapRect());
588 //----------------------------------------------------------------------------
589 void OCustomShape::NbcSetLogicRect(const Rectangle
& rRect
)
591 SdrObjCustomShape::NbcSetLogicRect(rRect
);
592 SetPropsFromRect(rRect
);
594 //----------------------------------------------------------------------------
595 FASTBOOL
OCustomShape::EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
)
597 FASTBOOL bResult
= SdrObjCustomShape::EndCreate(rStat
, eCmd
);
600 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
603 OXUndoEnvironment::OUndoEnvLock
aLock(pRptModel
->GetUndoEnv());
604 if ( !m_xReportComponent
.is() )
605 m_xReportComponent
.set(getUnoShape(),uno::UNO_QUERY
);
607 SetPropsFromRect(GetSnapRect());
613 //----------------------------------------------------------------------------
614 void OCustomShape::SetObjectItemHelper(const SfxPoolItem
& rItem
)
616 SetObjectItem(rItem
);
618 //getSectionWindow()->getView()->AdjustMarkHdl();
621 // -----------------------------------------------------------------------------
622 uno::Reference
< beans::XPropertySet
> OCustomShape::getAwtComponent()
624 return uno::Reference
< beans::XPropertySet
>(m_xReportComponent
,uno::UNO_QUERY
);
627 //----------------------------------------------------------------------------
628 uno::Reference
< uno::XInterface
> OCustomShape::getUnoShape()
630 uno::Reference
< uno::XInterface
> xShape
= OObjectBase::getUnoShapeOf( *this );
631 if ( !m_xReportComponent
.is() )
633 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
634 OXUndoEnvironment::OUndoEnvLock
aLock(pRptModel
->GetUndoEnv());
635 m_xReportComponent
.set(xShape
,uno::UNO_QUERY
);
640 //----------------------------------------------------------------------------
641 //----------------------------------------------------------------------------
642 TYPEINIT1(OUnoObject
, SdrUnoObj
);
643 DBG_NAME( rpt_OUnoObject
);
644 //----------------------------------------------------------------------------
645 OUnoObject::OUnoObject(const ::rtl::OUString
& _sComponentName
646 ,const ::rtl::OUString
& rModelName
647 ,sal_uInt16 _nObjectType
)
648 :SdrUnoObj(rModelName
, sal_True
)
649 ,OObjectBase(_sComponentName
)
650 ,m_nObjectType(_nObjectType
)
652 DBG_CTOR( rpt_OUnoObject
, NULL
);
653 if ( rModelName
.getLength() )
654 impl_initializeModel_nothrow();
656 //----------------------------------------------------------------------------
657 OUnoObject::OUnoObject(const uno::Reference
< report::XReportComponent
>& _xComponent
658 ,const ::rtl::OUString
& rModelName
659 ,sal_uInt16 _nObjectType
)
660 :SdrUnoObj(rModelName
, sal_True
)
661 ,OObjectBase(_xComponent
)
662 ,m_nObjectType(_nObjectType
)
664 DBG_CTOR( rpt_OUnoObject
, NULL
);
665 impl_setUnoShape( uno::Reference
< uno::XInterface
>( _xComponent
, uno::UNO_QUERY
) );
667 if ( rModelName
.getLength() )
668 impl_initializeModel_nothrow();
670 if ( rModelName
.getLength() )
671 impl_initializeModel_nothrow();
673 //----------------------------------------------------------------------------
674 OUnoObject::~OUnoObject()
676 DBG_DTOR( rpt_OUnoObject
, NULL
);
678 // -----------------------------------------------------------------------------
679 void OUnoObject::impl_initializeModel_nothrow()
683 Reference
< XFormattedField
> xFormatted( m_xReportComponent
, UNO_QUERY
);
684 if ( xFormatted
.is() )
686 const Reference
< XPropertySet
> xModelProps( GetUnoControlModel(), UNO_QUERY_THROW
);
687 const ::rtl::OUString sTreatAsNumberProperty
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TreatAsNumber" ) );
688 xModelProps
->setPropertyValue( sTreatAsNumberProperty
, makeAny( sal_False
) );
691 catch( const Exception
& )
693 DBG_UNHANDLED_EXCEPTION();
696 // -----------------------------------------------------------------------------
697 void OUnoObject::impl_setReportComponent_nothrow()
699 if ( m_xReportComponent
.is() )
702 OReportModel
* pReportModel
= static_cast<OReportModel
*>(GetModel());
703 OSL_ENSURE( pReportModel
, "OUnoObject::impl_setReportComponent_nothrow: no report model!" );
707 OXUndoEnvironment::OUndoEnvLock
aLock( pReportModel
->GetUndoEnv() );
708 m_xReportComponent
.set(getUnoShape(),uno::UNO_QUERY
);
710 impl_initializeModel_nothrow();
712 // -----------------------------------------------------------------------------
713 UINT16
OUnoObject::GetObjIdentifier() const
715 return UINT16(m_nObjectType
);
717 //----------------------------------------------------------------------------
718 UINT32
OUnoObject::GetObjInventor() const
720 return ReportInventor
;
722 //----------------------------------------------------------------------------
723 SdrPage
* OUnoObject::GetImplPage() const
725 DBG_CHKTHIS( rpt_OUnoObject
,NULL
);
728 //----------------------------------------------------------------------------
729 void OUnoObject::SetSnapRectImpl(const Rectangle
& _rRect
)
731 DBG_CHKTHIS( rpt_OUnoObject
,NULL
);
732 SetSnapRect( _rRect
);
734 //----------------------------------------------------------------------------
735 sal_Int32
OUnoObject::GetStep() const
737 DBG_CHKTHIS( rpt_OUnoObject
,NULL
);
740 OSL_ENSURE(0,"Who called me!");
744 //----------------------------------------------------------------------------
745 void OUnoObject::NbcMove( const Size
& rSize
)
747 DBG_CHKTHIS( rpt_OUnoObject
,NULL
);
749 if ( m_bIsListening
)
752 OObjectBase::EndListening(sal_False
);
754 bool bPositionFixed
= false;
756 bool bUndoMode
= false;
757 if ( m_xReportComponent
.is() )
759 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
760 if (pRptModel
->GetUndoEnv().IsUndoMode())
762 // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode
765 OXUndoEnvironment::OUndoEnvLock
aLock(pRptModel
->GetUndoEnv());
767 // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point?
768 int nNewX
= m_xReportComponent
->getPositionX() + rSize
.A();
769 // can this hinder us to set components outside the area?
774 m_xReportComponent
->setPositionX(nNewX
);
775 int nNewY
= m_xReportComponent
->getPositionY() + rSize
.B();
776 if (nNewY
< 0 && !bUndoMode
)
778 aUndoSize
.B() = abs(nNewY
);
779 bPositionFixed
= true;
782 m_xReportComponent
->setPositionY(nNewY
);
786 // OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
789 // if (! pRptModel->GetUndoEnv().IsLocked())
791 GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize
));
795 // set geometry properties
796 SetPropsFromRect(GetLogicRect());
799 OObjectBase::StartListening();
802 SdrUnoObj::NbcMove( rSize
);
805 //----------------------------------------------------------------------------
807 void OUnoObject::NbcResize(const Point
& rRef
, const Fraction
& xFract
, const Fraction
& yFract
)
809 DBG_CHKTHIS( rpt_OUnoObject
,NULL
);
810 SdrUnoObj::NbcResize( rRef
, xFract
, yFract
);
813 OObjectBase::EndListening(sal_False
);
815 // set geometry properties
816 SetPropsFromRect(GetLogicRect());
819 OObjectBase::StartListening();
821 //----------------------------------------------------------------------------
822 void OUnoObject::NbcSetLogicRect(const Rectangle
& rRect
)
824 SdrUnoObj::NbcSetLogicRect(rRect
);
826 OObjectBase::EndListening(sal_False
);
828 // set geometry properties
829 SetPropsFromRect(rRect
);
832 OObjectBase::StartListening();
834 //----------------------------------------------------------------------------
836 FASTBOOL
OUnoObject::EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
)
838 DBG_CHKTHIS( rpt_OUnoObject
,NULL
);
839 FASTBOOL bResult
= SdrUnoObj::EndCreate(rStat
, eCmd
);
842 impl_setReportComponent_nothrow();
844 if ( m_xReportComponent
.is() )
848 if ( supportsService( SERVICE_FIXEDTEXT
) )
850 m_xReportComponent
->setPropertyValue( PROPERTY_LABEL
, uno::makeAny(GetDefaultName(this)) );
853 catch(const uno::Exception
&)
855 DBG_UNHANDLED_EXCEPTION();
858 impl_initializeModel_nothrow();
860 // set geometry properties
861 SetPropsFromRect(GetLogicRect());
866 //----------------------------------------------------------------------------
867 ::rtl::OUString
OUnoObject::GetDefaultName(const OUnoObject
* _pObj
)
869 sal_uInt16 nResId
= 0;
870 ::rtl::OUString aDefaultName
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HERE WE HAVE TO INSERT OUR NAME!"));
871 if ( _pObj
->supportsService( SERVICE_FIXEDTEXT
) )
873 nResId
= RID_STR_CLASS_FIXEDTEXT
;
875 else if ( _pObj
->supportsService( SERVICE_FIXEDLINE
) )
877 nResId
= RID_STR_CLASS_FIXEDLINE
;
879 else if ( _pObj
->supportsService( SERVICE_IMAGECONTROL
) )
881 nResId
= RID_STR_CLASS_IMAGECONTROL
;
883 else if ( _pObj
->supportsService( SERVICE_FORMATTEDFIELD
) )
885 nResId
= RID_STR_CLASS_FORMATTEDFIELD
;
889 aDefaultName
= ::rtl::OUString( String(ModuleRes(nResId
)) );
894 // -----------------------------------------------------------------------------
895 void OUnoObject::_propertyChange( const beans::PropertyChangeEvent
& evt
) throw( uno::RuntimeException
)
897 DBG_CHKTHIS( rpt_OUnoObject
,NULL
);
898 OObjectBase::_propertyChange(evt
);
901 if ( evt
.PropertyName
== PROPERTY_CHARCOLOR
)
903 Reference
<XPropertySet
> xControlModel(GetUnoControlModel(),uno::UNO_QUERY
);
904 if ( xControlModel
.is() )
906 OObjectBase::EndListening(sal_False
);
909 xControlModel
->setPropertyValue(PROPERTY_TEXTCOLOR
,evt
.NewValue
);
911 catch(uno::Exception
&)
914 OObjectBase::StartListening();
917 else if ( evt
.PropertyName
== PROPERTY_NAME
)
919 Reference
<XPropertySet
> xControlModel(GetUnoControlModel(),uno::UNO_QUERY
);
920 if ( xControlModel
.is() && xControlModel
->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME
) )
923 ::rtl::OUString aOldName
;
924 evt
.OldValue
>>= aOldName
;
927 ::rtl::OUString aNewName
;
928 evt
.NewValue
>>= aNewName
;
930 if ( !aNewName
.equals(aOldName
) )
932 // set old name property
933 OObjectBase::EndListening(sal_False
);
934 if ( m_xMediator
.is() )
935 m_xMediator
.get()->stopListening();
938 xControlModel
->setPropertyValue( PROPERTY_NAME
, evt
.NewValue
);
940 catch(uno::Exception
&)
943 if ( m_xMediator
.is() )
944 m_xMediator
.get()->startListening();
945 OObjectBase::StartListening();
951 // -----------------------------------------------------------------------------
952 void OUnoObject::CreateMediator(sal_Bool _bReverse
)
954 if ( !m_xMediator
.is() )
956 impl_setReportComponent_nothrow();
958 Reference
<XPropertySet
> xControlModel(GetUnoControlModel(),uno::UNO_QUERY
);
959 if ( !m_xMediator
.is() && m_xReportComponent
.is() && xControlModel
.is() )
960 m_xMediator
= TMediator::createFromQuery(new OPropertyMediator(m_xReportComponent
.get(),xControlModel
,getPropertyNameMap(GetObjIdentifier()),_bReverse
));
961 OObjectBase::StartListening();
964 // -----------------------------------------------------------------------------
965 uno::Reference
< beans::XPropertySet
> OUnoObject::getAwtComponent()
967 return Reference
<XPropertySet
>(GetUnoControlModel(),uno::UNO_QUERY
);
970 // -----------------------------------------------------------------------------
971 uno::Reference
< uno::XInterface
> OUnoObject::getUnoShape()
973 return OObjectBase::getUnoShapeOf( *this );
975 // -----------------------------------------------------------------------------
976 SdrObject
* OUnoObject::Clone() const
978 SdrObject
* pClone
= SdrUnoObj::Clone();
981 Reference
<XPropertySet
> xSource(const_cast<OUnoObject
*>(this)->getUnoShape(),uno::UNO_QUERY
);
982 Reference
<XPropertySet
> xDest(pClone
->getUnoShape(),uno::UNO_QUERY
);
983 if ( xSource
.is() && xDest
.is() )
984 comphelper::copyProperties(xSource
.get(),xDest
.get());
988 //----------------------------------------------------------------------------
990 //----------------------------------------------------------------------------
991 TYPEINIT1(OOle2Obj
, SdrOle2Obj
);
992 DBG_NAME( rpt_OOle2Obj
);
993 OOle2Obj::OOle2Obj(const uno::Reference
< report::XReportComponent
>& _xComponent
,UINT16 _nType
)
995 ,OObjectBase(_xComponent
)
999 DBG_CTOR( rpt_OOle2Obj
, NULL
);
1001 impl_setUnoShape( uno::Reference
< uno::XInterface
>( _xComponent
, uno::UNO_QUERY
) );
1002 m_bIsListening
= sal_True
;
1004 //----------------------------------------------------------------------------
1005 OOle2Obj::OOle2Obj(const ::rtl::OUString
& _sComponentName
,UINT16 _nType
)
1007 ,OObjectBase(_sComponentName
)
1011 DBG_CTOR( rpt_OOle2Obj
, NULL
);
1012 m_bIsListening
= sal_True
;
1014 //----------------------------------------------------------------------------
1015 OOle2Obj::~OOle2Obj()
1017 DBG_DTOR( rpt_OOle2Obj
, NULL
);
1019 // -----------------------------------------------------------------------------
1020 UINT16
OOle2Obj::GetObjIdentifier() const
1024 //----------------------------------------------------------------------------
1025 UINT32
OOle2Obj::GetObjInventor() const
1027 return ReportInventor
;
1029 //----------------------------------------------------------------------------
1030 SdrPage
* OOle2Obj::GetImplPage() const
1032 DBG_CHKTHIS( rpt_OOle2Obj
,NULL
);
1035 //----------------------------------------------------------------------------
1036 void OOle2Obj::SetSnapRectImpl(const Rectangle
& _rRect
)
1038 DBG_CHKTHIS( rpt_OOle2Obj
,NULL
);
1039 SetSnapRect( _rRect
);
1041 //----------------------------------------------------------------------------
1042 sal_Int32
OOle2Obj::GetStep() const
1044 DBG_CHKTHIS( rpt_OOle2Obj
,NULL
);
1045 // get step property
1046 sal_Int32 nStep
= 0;
1047 OSL_ENSURE(0,"Who called me!");
1051 //----------------------------------------------------------------------------
1052 void OOle2Obj::NbcMove( const Size
& rSize
)
1054 DBG_CHKTHIS( rpt_OOle2Obj
,NULL
);
1056 if ( m_bIsListening
)
1059 OObjectBase::EndListening(sal_False
);
1061 if ( m_xReportComponent
.is() )
1063 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
1064 OXUndoEnvironment::OUndoEnvLock
aLock(pRptModel
->GetUndoEnv());
1065 m_xReportComponent
->setPositionX(m_xReportComponent
->getPositionX() + rSize
.A());
1066 m_xReportComponent
->setPositionY(m_xReportComponent
->getPositionY() + rSize
.B());
1069 // set geometry properties
1070 SetPropsFromRect(GetLogicRect());
1073 OObjectBase::StartListening();
1076 SdrOle2Obj::NbcMove( rSize
);
1079 //----------------------------------------------------------------------------
1081 void OOle2Obj::NbcResize(const Point
& rRef
, const Fraction
& xFract
, const Fraction
& yFract
)
1083 DBG_CHKTHIS( rpt_OOle2Obj
,NULL
);
1084 SdrOle2Obj::NbcResize( rRef
, xFract
, yFract
);
1087 OObjectBase::EndListening(sal_False
);
1089 // set geometry properties
1090 SetPropsFromRect(GetLogicRect());
1093 OObjectBase::StartListening();
1095 //----------------------------------------------------------------------------
1096 void OOle2Obj::NbcSetLogicRect(const Rectangle
& rRect
)
1098 SdrOle2Obj::NbcSetLogicRect(rRect
);
1100 OObjectBase::EndListening(sal_False
);
1102 // set geometry properties
1103 SetPropsFromRect(rRect
);
1106 OObjectBase::StartListening();
1108 //----------------------------------------------------------------------------
1110 FASTBOOL
OOle2Obj::EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
)
1112 DBG_CHKTHIS( rpt_OOle2Obj
,NULL
);
1113 FASTBOOL bResult
= SdrOle2Obj::EndCreate(rStat
, eCmd
);
1116 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
1119 OXUndoEnvironment::OUndoEnvLock
aLock(pRptModel
->GetUndoEnv());
1120 if ( !m_xReportComponent
.is() )
1121 m_xReportComponent
.set(getUnoShape(),uno::UNO_QUERY
);
1123 // set geometry properties
1124 SetPropsFromRect(GetLogicRect());
1130 uno::Reference
< beans::XPropertySet
> OOle2Obj::getAwtComponent()
1132 return uno::Reference
< beans::XPropertySet
>(m_xReportComponent
,uno::UNO_QUERY
);
1135 // -----------------------------------------------------------------------------
1136 uno::Reference
< uno::XInterface
> OOle2Obj::getUnoShape()
1138 uno::Reference
< uno::XInterface
> xShape
= OObjectBase::getUnoShapeOf( *this );
1139 if ( !m_xReportComponent
.is() )
1141 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
1142 OXUndoEnvironment::OUndoEnvLock
aLock(pRptModel
->GetUndoEnv());
1143 m_xReportComponent
.set(xShape
,uno::UNO_QUERY
);
1147 // -----------------------------------------------------------------------------
1148 uno::Reference
< chart2::data::XDatabaseDataProvider
> lcl_getDataProvider(const uno::Reference
< embed::XEmbeddedObject
>& _xObj
)
1150 uno::Reference
< chart2::data::XDatabaseDataProvider
> xSource
;
1151 uno::Reference
< embed::XComponentSupplier
> xCompSupp(_xObj
,uno::UNO_QUERY
);
1154 uno::Reference
< chart2::XChartDocument
> xChartDoc( xCompSupp
->getComponent(), uno::UNO_QUERY
);
1155 if ( xChartDoc
.is() )
1157 xSource
.set(xChartDoc
->getDataProvider(),uno::UNO_QUERY
);
1159 } // if( xCompSupp.is())
1162 // -----------------------------------------------------------------------------
1163 // Clone() soll eine komplette Kopie des Objektes erzeugen.
1164 SdrObject
* OOle2Obj::Clone() const
1166 OOle2Obj
* pObj
= static_cast<OOle2Obj
*>(SdrOle2Obj::Clone());
1167 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
1168 svt::EmbeddedObjectRef::TryRunningState( pObj
->GetObjRef() );
1169 pObj
->impl_createDataProvider_nothrow(pRptModel
->getReportDefinition().get());
1171 uno::Reference
< chart2::data::XDatabaseDataProvider
> xSource( lcl_getDataProvider(GetObjRef()) );
1172 uno::Reference
< chart2::data::XDatabaseDataProvider
> xDest( lcl_getDataProvider(pObj
->GetObjRef()) );
1173 if ( xSource
.is() && xDest
.is() )
1174 comphelper::copyProperties(xSource
.get(),xDest
.get());
1176 pObj
->initializeChart(pRptModel
->getReportDefinition().get());
1179 // -----------------------------------------------------------------------------
1180 void OOle2Obj::impl_createDataProvider_nothrow(const uno::Reference
< frame::XModel
>& _xModel
)
1184 uno::Reference
< embed::XEmbeddedObject
> xObj
= GetObjRef();
1185 uno::Reference
< chart2::data::XDataReceiver
> xReceiver
;
1186 uno::Reference
< embed::XComponentSupplier
> xCompSupp( xObj
, uno::UNO_QUERY
);
1188 xReceiver
.set( xCompSupp
->getComponent(), uno::UNO_QUERY
);
1189 OSL_ASSERT( xReceiver
.is());
1190 if( xReceiver
.is() )
1192 uno::Reference
< lang::XMultiServiceFactory
> xFac(_xModel
,uno::UNO_QUERY
);
1193 uno::Reference
< chart2::data::XDatabaseDataProvider
> xDataProvider( xFac
->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider"))),uno::UNO_QUERY
);
1194 xReceiver
->attachDataProvider( xDataProvider
.get() );
1195 } // if( xReceiver.is() )
1197 catch(uno::Exception
)
1201 // -----------------------------------------------------------------------------
1202 void OOle2Obj::initializeOle()
1206 m_bOnlyOnce
= false;
1207 uno::Reference
< embed::XEmbeddedObject
> xObj
= GetObjRef();
1208 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
1209 pRptModel
->GetUndoEnv().AddElement(lcl_getDataProvider(xObj
));
1211 uno::Reference
< embed::XComponentSupplier
> xCompSupp( xObj
, uno::UNO_QUERY
);
1212 if( xCompSupp
.is() )
1214 uno::Reference
< beans::XPropertySet
> xChartProps( xCompSupp
->getComponent(), uno::UNO_QUERY
);
1215 if ( xChartProps
.is() )
1216 xChartProps
->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NullDate")),uno::makeAny(util::DateTime(0,0,0,0,1,1,1900)));
1220 // -----------------------------------------------------------------------------
1221 void OOle2Obj::initializeChart( const uno::Reference
< frame::XModel
>& _xModel
)
1223 uno::Reference
< embed::XEmbeddedObject
> xObj
= GetObjRef();
1224 uno::Reference
< chart2::data::XDataReceiver
> xReceiver
;
1225 uno::Reference
< embed::XComponentSupplier
> xCompSupp( xObj
, uno::UNO_QUERY
);
1227 xReceiver
.set( xCompSupp
->getComponent(), uno::UNO_QUERY
);
1228 OSL_ASSERT( xReceiver
.is());
1229 if( xReceiver
.is() )
1231 // lock the model to suppress any internal updates
1232 uno::Reference
< frame::XModel
> xChartModel( xReceiver
, uno::UNO_QUERY
);
1233 if( xChartModel
.is() )
1234 xChartModel
->lockControllers();
1236 if ( !lcl_getDataProvider(xObj
).is() )
1237 impl_createDataProvider_nothrow(_xModel
);
1239 OReportModel
* pRptModel
= static_cast<OReportModel
*>(GetModel());
1240 pRptModel
->GetUndoEnv().AddElement(lcl_getDataProvider(xObj
));
1242 uno::Sequence
< beans::PropertyValue
> aArgs( 4 );
1243 aArgs
[0] = beans::PropertyValue(
1244 ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
1245 uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE
);
1246 aArgs
[1] = beans::PropertyValue(
1247 ::rtl::OUString::createFromAscii("HasCategories"), -1,
1248 uno::makeAny( sal_True
), beans::PropertyState_DIRECT_VALUE
);
1249 aArgs
[2] = beans::PropertyValue(
1250 ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
1251 uno::makeAny( sal_True
), beans::PropertyState_DIRECT_VALUE
);
1252 aArgs
[3] = beans::PropertyValue(
1253 ::rtl::OUString::createFromAscii("DataRowSource"), -1,
1254 uno::makeAny( chart::ChartDataRowSource_COLUMNS
), beans::PropertyState_DIRECT_VALUE
);
1255 xReceiver
->setArguments( aArgs
);
1257 if( xChartModel
.is() )
1258 xChartModel
->unlockControllers();
1261 // -----------------------------------------------------------------------------
1262 uno::Reference
< style::XStyle
> getUsedStyle(const uno::Reference
< report::XReportDefinition
>& _xReport
)
1264 uno::Reference
<container::XNameAccess
> xStyles
= _xReport
->getStyleFamilies();
1265 uno::Reference
<container::XNameAccess
> xPageStyles(xStyles
->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageStyles"))),uno::UNO_QUERY
);
1267 uno::Reference
< style::XStyle
> xReturn
;
1268 uno::Sequence
< ::rtl::OUString
> aSeq
= xPageStyles
->getElementNames();
1269 const ::rtl::OUString
* pIter
= aSeq
.getConstArray();
1270 const ::rtl::OUString
* pEnd
= pIter
+ aSeq
.getLength();
1271 for(;pIter
!= pEnd
&& !xReturn
.is() ;++pIter
)
1273 uno::Reference
< style::XStyle
> xStyle(xPageStyles
->getByName(*pIter
),uno::UNO_QUERY
);
1274 if ( xStyle
->isInUse() )
1279 //----------------------------------------------------------------------------
1280 //============================================================================
1282 //============================================================================