1*9e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9e0e4191SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9e0e4191SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9e0e4191SAndrew Rist * distributed with this work for additional information
6*9e0e4191SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9e0e4191SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9e0e4191SAndrew Rist * "License"); you may not use this file except in compliance
9*9e0e4191SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*9e0e4191SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*9e0e4191SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9e0e4191SAndrew Rist * software distributed under the License is distributed on an
15*9e0e4191SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9e0e4191SAndrew Rist * KIND, either express or implied. See the License for the
17*9e0e4191SAndrew Rist * specific language governing permissions and limitations
18*9e0e4191SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*9e0e4191SAndrew Rist *************************************************************/
21*9e0e4191SAndrew Rist
22*9e0e4191SAndrew Rist
23cdf0e10cSrcweir #include "precompiled_reportdesign.hxx"
24cdf0e10cSrcweir #include "RptObject.hxx"
25cdf0e10cSrcweir #include <vector>
26cdf0e10cSrcweir #include <algorithm>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <RptDef.hxx>
29cdf0e10cSrcweir #include <svx/unoshape.hxx>
30cdf0e10cSrcweir #include "RptModel.hxx"
31cdf0e10cSrcweir #include "RptObjectListener.hxx"
32cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
33cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
34cdf0e10cSrcweir #include "RptPage.hxx"
35cdf0e10cSrcweir #include "corestrings.hrc"
36cdf0e10cSrcweir #include <dbaccess/dbsubcomponentcontroller.hxx>
37cdf0e10cSrcweir #include "ModuleHelper.hxx"
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include <RptResId.hrc>
40cdf0e10cSrcweir #include <svx/xflclit.hxx>
41cdf0e10cSrcweir #include <svx/xlnclit.hxx>
42cdf0e10cSrcweir #include <svx/xlndsit.hxx>
43cdf0e10cSrcweir #include <svx/xlineit0.hxx>
44cdf0e10cSrcweir #include <svx/sderitm.hxx>
45cdf0e10cSrcweir #include <svx/xlnwtit.hxx>
46cdf0e10cSrcweir #include <svx/xlntrit.hxx>
47cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
48cdf0e10cSrcweir #include <com/sun/star/awt/XTabControllerModel.hpp>
49cdf0e10cSrcweir #include <com/sun/star/awt/XUnoControlContainer.hpp>
50cdf0e10cSrcweir #include <com/sun/star/awt/XVclContainerPeer.hpp>
51cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
52cdf0e10cSrcweir #include <com/sun/star/awt/TextAlign.hpp>
53cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
54cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
55cdf0e10cSrcweir #include <com/sun/star/script/XScriptEventsSupplier.hpp>
56cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp>
57cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
58cdf0e10cSrcweir #include <com/sun/star/report/XShape.hpp>
59cdf0e10cSrcweir #include <com/sun/star/report/XFixedLine.hpp>
60cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataRowSource.hpp>
61cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataReceiver.hpp>
62cdf0e10cSrcweir #include <com/sun/star/chart2/data/DatabaseDataProvider.hpp>
63cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp>
64cdf0e10cSrcweir #include <com/sun/star/style/VerticalAlignment.hpp>
65cdf0e10cSrcweir #include <com/sun/star/style/ParagraphAdjust.hpp>
66cdf0e10cSrcweir #include <com/sun/star/report/XFormattedField.hpp>
67cdf0e10cSrcweir #include <comphelper/genericpropertyset.hxx>
68cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
69cdf0e10cSrcweir #include <comphelper/property.hxx>
70cdf0e10cSrcweir #include <tools/diagnose_ex.h>
71cdf0e10cSrcweir #include "PropertyForward.hxx"
72cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
73cdf0e10cSrcweir #include <connectivity/dbconversion.hxx>
74cdf0e10cSrcweir #include "UndoActions.hxx"
75cdf0e10cSrcweir #include "UndoEnv.hxx"
76cdf0e10cSrcweir #include <algorithm>
77cdf0e10cSrcweir #include <functional>
78cdf0e10cSrcweir
79cdf0e10cSrcweir namespace rptui
80cdf0e10cSrcweir {
81cdf0e10cSrcweir
82cdf0e10cSrcweir using namespace ::com::sun::star;
83cdf0e10cSrcweir using namespace uno;
84cdf0e10cSrcweir using namespace beans;
85cdf0e10cSrcweir using namespace reportdesign;
86cdf0e10cSrcweir using namespace container;
87cdf0e10cSrcweir using namespace script;
88cdf0e10cSrcweir using namespace report;
89cdf0e10cSrcweir //----------------------------------------------------------------------------
getObjectType(const uno::Reference<report::XReportComponent> & _xComponent)90cdf0e10cSrcweir sal_uInt16 OObjectBase::getObjectType(const uno::Reference< report::XReportComponent>& _xComponent)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir uno::Reference< lang::XServiceInfo > xServiceInfo( _xComponent , uno::UNO_QUERY );
93cdf0e10cSrcweir OSL_ENSURE(xServiceInfo.is(),"Who deletes the XServiceInfo interface!");
94cdf0e10cSrcweir if ( xServiceInfo.is() )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir if ( xServiceInfo->supportsService( SERVICE_FIXEDTEXT ))
97cdf0e10cSrcweir return OBJ_DLG_FIXEDTEXT;
98cdf0e10cSrcweir if ( xServiceInfo->supportsService( SERVICE_FIXEDLINE ))
99cdf0e10cSrcweir {
100cdf0e10cSrcweir uno::Reference< report::XFixedLine> xFixedLine(_xComponent,uno::UNO_QUERY);
101cdf0e10cSrcweir return xFixedLine->getOrientation() ? OBJ_DLG_HFIXEDLINE : OBJ_DLG_VFIXEDLINE;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir if ( xServiceInfo->supportsService( SERVICE_IMAGECONTROL))
104cdf0e10cSrcweir return OBJ_DLG_IMAGECONTROL;
105cdf0e10cSrcweir if ( xServiceInfo->supportsService( SERVICE_FORMATTEDFIELD ))
106cdf0e10cSrcweir return OBJ_DLG_FORMATTEDFIELD;
107cdf0e10cSrcweir if ( xServiceInfo->supportsService( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")) ) )
108cdf0e10cSrcweir return OBJ_OLE2;
109cdf0e10cSrcweir if ( xServiceInfo->supportsService( SERVICE_SHAPE ))
110cdf0e10cSrcweir return OBJ_CUSTOMSHAPE;
111cdf0e10cSrcweir if ( xServiceInfo->supportsService( SERVICE_REPORTDEFINITION ) )
112cdf0e10cSrcweir return OBJ_DLG_SUBREPORT;
113cdf0e10cSrcweir return OBJ_OLE2;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir return 0;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir // -----------------------------------------------------------------------------
createObject(const uno::Reference<report::XReportComponent> & _xComponent)118cdf0e10cSrcweir SdrObject* OObjectBase::createObject(const uno::Reference< report::XReportComponent>& _xComponent)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir SdrObject* pNewObj = NULL;
121cdf0e10cSrcweir sal_uInt16 nType = OObjectBase::getObjectType(_xComponent);
122cdf0e10cSrcweir switch( nType )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir case OBJ_DLG_FIXEDTEXT:
125cdf0e10cSrcweir {
126cdf0e10cSrcweir OUnoObject* pUnoObj = new OUnoObject( _xComponent
127cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))
128cdf0e10cSrcweir ,OBJ_DLG_FIXEDTEXT);
129cdf0e10cSrcweir pNewObj = pUnoObj;
130cdf0e10cSrcweir
131cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xControlModel(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY);
132cdf0e10cSrcweir if ( xControlModel.is() )
133cdf0e10cSrcweir xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::makeAny(sal_True));
134cdf0e10cSrcweir }
135cdf0e10cSrcweir break;
136cdf0e10cSrcweir case OBJ_DLG_IMAGECONTROL:
137cdf0e10cSrcweir pNewObj = new OUnoObject(_xComponent
138cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl"))
139cdf0e10cSrcweir ,OBJ_DLG_IMAGECONTROL);
140cdf0e10cSrcweir break;
141cdf0e10cSrcweir case OBJ_DLG_FORMATTEDFIELD:
142cdf0e10cSrcweir pNewObj = new OUnoObject( _xComponent
143cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField"))
144cdf0e10cSrcweir ,OBJ_DLG_FORMATTEDFIELD);
145cdf0e10cSrcweir break;
146cdf0e10cSrcweir case OBJ_DLG_HFIXEDLINE:
147cdf0e10cSrcweir case OBJ_DLG_VFIXEDLINE:
148cdf0e10cSrcweir pNewObj = new OUnoObject( _xComponent
149cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel"))
150cdf0e10cSrcweir ,nType);
151cdf0e10cSrcweir break;
152cdf0e10cSrcweir case OBJ_CUSTOMSHAPE:
153cdf0e10cSrcweir pNewObj = OCustomShape::Create( _xComponent );
154cdf0e10cSrcweir try
155cdf0e10cSrcweir {
156cdf0e10cSrcweir sal_Bool bOpaque = sal_False;
157cdf0e10cSrcweir _xComponent->getPropertyValue(PROPERTY_OPAQUE) >>= bOpaque;
158cdf0e10cSrcweir pNewObj->SetLayer(bOpaque ? RPT_LAYER_FRONT : RPT_LAYER_BACK);
159cdf0e10cSrcweir }
160cdf0e10cSrcweir catch(const uno::Exception&)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
163cdf0e10cSrcweir }
164cdf0e10cSrcweir break;
165cdf0e10cSrcweir case OBJ_DLG_SUBREPORT:
166cdf0e10cSrcweir case OBJ_OLE2:
167cdf0e10cSrcweir pNewObj = OOle2Obj::Create( _xComponent,nType );
168cdf0e10cSrcweir break;
169cdf0e10cSrcweir default:
170cdf0e10cSrcweir OSL_ENSURE(0,"Unknown object id");
171cdf0e10cSrcweir break;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir ensureSdrObjectOwnership( _xComponent );
175cdf0e10cSrcweir
176cdf0e10cSrcweir return pNewObj;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir // -----------------------------------------------------------------------------
179cdf0e10cSrcweir namespace
180cdf0e10cSrcweir {
181cdf0e10cSrcweir class ParaAdjust : public AnyConverter
182cdf0e10cSrcweir {
183cdf0e10cSrcweir public:
operator ()(const::rtl::OUString & _sPropertyName,const::com::sun::star::uno::Any & lhs) const184cdf0e10cSrcweir virtual ::com::sun::star::uno::Any operator() (const ::rtl::OUString& _sPropertyName,const ::com::sun::star::uno::Any& lhs) const
185cdf0e10cSrcweir {
186cdf0e10cSrcweir uno::Any aRet;
187cdf0e10cSrcweir if ( _sPropertyName.equalsAscii(PROPERTY_PARAADJUST) )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir sal_Int16 nTextAlign = 0;
190cdf0e10cSrcweir lhs >>= nTextAlign;
191cdf0e10cSrcweir switch(nTextAlign)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir case awt::TextAlign::LEFT:
194cdf0e10cSrcweir nTextAlign = style::ParagraphAdjust_LEFT;
195cdf0e10cSrcweir break;
196cdf0e10cSrcweir case awt::TextAlign::CENTER:
197cdf0e10cSrcweir nTextAlign = style::ParagraphAdjust_CENTER;
198cdf0e10cSrcweir break;
199cdf0e10cSrcweir case awt::TextAlign::RIGHT:
200cdf0e10cSrcweir nTextAlign = style::ParagraphAdjust_RIGHT;
201cdf0e10cSrcweir break;
202cdf0e10cSrcweir default:
203cdf0e10cSrcweir OSL_ENSURE(0,"Illegal text alignment value!");
204cdf0e10cSrcweir break;
205cdf0e10cSrcweir } // switch(nTextAlign)
206cdf0e10cSrcweir aRet <<= (style::ParagraphAdjust)nTextAlign;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir else
209cdf0e10cSrcweir {
210cdf0e10cSrcweir sal_Int16 nTextAlign = 0;
211cdf0e10cSrcweir sal_Int16 eParagraphAdjust = 0;
212cdf0e10cSrcweir lhs >>= eParagraphAdjust;
213cdf0e10cSrcweir switch(eParagraphAdjust)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir case style::ParagraphAdjust_LEFT:
216cdf0e10cSrcweir case style::ParagraphAdjust_BLOCK:
217cdf0e10cSrcweir nTextAlign = awt::TextAlign::LEFT;
218cdf0e10cSrcweir break;
219cdf0e10cSrcweir case style::ParagraphAdjust_CENTER:
220cdf0e10cSrcweir nTextAlign = awt::TextAlign::CENTER;
221cdf0e10cSrcweir break;
222cdf0e10cSrcweir case style::ParagraphAdjust_RIGHT:
223cdf0e10cSrcweir nTextAlign = awt::TextAlign::RIGHT;
224cdf0e10cSrcweir break;
225cdf0e10cSrcweir default:
226cdf0e10cSrcweir OSL_ENSURE(0,"Illegal text alignment value!");
227cdf0e10cSrcweir break;
228cdf0e10cSrcweir } // switch(eParagraphAdjust)
229cdf0e10cSrcweir aRet <<= nTextAlign;
230cdf0e10cSrcweir }
231cdf0e10cSrcweir return aRet;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir };
234cdf0e10cSrcweir }
235cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertyNameMap(sal_uInt16 _nObjectId)236cdf0e10cSrcweir const TPropertyNamePair& getPropertyNameMap(sal_uInt16 _nObjectId)
237cdf0e10cSrcweir {
238cdf0e10cSrcweir switch(_nObjectId)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir case OBJ_DLG_IMAGECONTROL:
241cdf0e10cSrcweir {
242cdf0e10cSrcweir static TPropertyNamePair s_aNameMap;
243cdf0e10cSrcweir if ( s_aNameMap.empty() )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
246cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR,aNoConverter)));
247cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER,TPropertyConverter(PROPERTY_BORDER,aNoConverter)));
248cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR,TPropertyConverter(PROPERTY_BORDERCOLOR,aNoConverter)));
249cdf0e10cSrcweir //s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,PROPERTY_ALIGN));
250cdf0e10cSrcweir }
251cdf0e10cSrcweir return s_aNameMap;
252cdf0e10cSrcweir }
253cdf0e10cSrcweir
254cdf0e10cSrcweir case OBJ_DLG_FIXEDTEXT:
255cdf0e10cSrcweir {
256cdf0e10cSrcweir static TPropertyNamePair s_aNameMap;
257cdf0e10cSrcweir if ( s_aNameMap.empty() )
258cdf0e10cSrcweir {
259cdf0e10cSrcweir ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
260cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARCOLOR,TPropertyConverter(PROPERTY_TEXTCOLOR,aNoConverter)));
261cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR,aNoConverter)));
262cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARUNDERLINECOLOR,TPropertyConverter(PROPERTY_TEXTLINECOLOR,aNoConverter)));
263cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARRELIEF,TPropertyConverter(PROPERTY_FONTRELIEF,aNoConverter)));
264cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARFONTHEIGHT,TPropertyConverter(PROPERTY_FONTHEIGHT,aNoConverter)));
265cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARSTRIKEOUT,TPropertyConverter(PROPERTY_FONTSTRIKEOUT,aNoConverter)));
266cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLTEXTEMPHASISMARK,TPropertyConverter(PROPERTY_FONTEMPHASISMARK,aNoConverter)));
267cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER,TPropertyConverter(PROPERTY_BORDER,aNoConverter)));
268cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR,TPropertyConverter(PROPERTY_BORDERCOLOR,aNoConverter)));
269cdf0e10cSrcweir
270cdf0e10cSrcweir ::boost::shared_ptr<AnyConverter> aParaAdjust(new ParaAdjust());
271cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aParaAdjust)));
272cdf0e10cSrcweir }
273cdf0e10cSrcweir return s_aNameMap;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir case OBJ_DLG_FORMATTEDFIELD:
276cdf0e10cSrcweir {
277cdf0e10cSrcweir static TPropertyNamePair s_aNameMap;
278cdf0e10cSrcweir if ( s_aNameMap.empty() )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
281cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARCOLOR,TPropertyConverter(PROPERTY_TEXTCOLOR,aNoConverter)));
282cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR,aNoConverter)));
283cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARUNDERLINECOLOR,TPropertyConverter(PROPERTY_TEXTLINECOLOR,aNoConverter)));
284cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARRELIEF,TPropertyConverter(PROPERTY_FONTRELIEF,aNoConverter)));
285cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARFONTHEIGHT,TPropertyConverter(PROPERTY_FONTHEIGHT,aNoConverter)));
286cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARSTRIKEOUT,TPropertyConverter(PROPERTY_FONTSTRIKEOUT,aNoConverter)));
287cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLTEXTEMPHASISMARK,TPropertyConverter(PROPERTY_FONTEMPHASISMARK,aNoConverter)));
288cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER,TPropertyConverter(PROPERTY_BORDER,aNoConverter)));
289cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR,TPropertyConverter(PROPERTY_BORDERCOLOR,aNoConverter)));
290cdf0e10cSrcweir //s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aNoConverter)));
291cdf0e10cSrcweir ::boost::shared_ptr<AnyConverter> aParaAdjust(new ParaAdjust());
292cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aParaAdjust)));
293cdf0e10cSrcweir }
294cdf0e10cSrcweir return s_aNameMap;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
297cdf0e10cSrcweir case OBJ_CUSTOMSHAPE:
298cdf0e10cSrcweir {
299cdf0e10cSrcweir static TPropertyNamePair s_aNameMap;
300cdf0e10cSrcweir if ( s_aNameMap.empty() )
301cdf0e10cSrcweir {
302cdf0e10cSrcweir ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
303cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillColor")),TPropertyConverter(PROPERTY_CONTROLBACKGROUND,aNoConverter)));
304cdf0e10cSrcweir s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aNoConverter)));
305cdf0e10cSrcweir }
306cdf0e10cSrcweir return s_aNameMap;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir
309cdf0e10cSrcweir default:
310cdf0e10cSrcweir break;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir static TPropertyNamePair s_aEmptyNameMap;
313cdf0e10cSrcweir return s_aEmptyNameMap;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir // -----------------------------------------------------------------------------
316cdf0e10cSrcweir
DBG_NAME(rpt_OObjectBase)317cdf0e10cSrcweir DBG_NAME( rpt_OObjectBase )
318cdf0e10cSrcweir OObjectBase::OObjectBase(const uno::Reference< report::XReportComponent>& _xComponent)
319cdf0e10cSrcweir :m_bIsListening(sal_False)
320cdf0e10cSrcweir {
321cdf0e10cSrcweir DBG_CTOR( rpt_OObjectBase,NULL);
322cdf0e10cSrcweir m_xReportComponent = _xComponent;
323cdf0e10cSrcweir }
324cdf0e10cSrcweir //----------------------------------------------------------------------------
OObjectBase(const::rtl::OUString & _sComponentName)325cdf0e10cSrcweir OObjectBase::OObjectBase(const ::rtl::OUString& _sComponentName)
326cdf0e10cSrcweir :m_sComponentName(_sComponentName)
327cdf0e10cSrcweir ,m_bIsListening(sal_False)
328cdf0e10cSrcweir {
329cdf0e10cSrcweir DBG_CTOR( rpt_OObjectBase,NULL);
330cdf0e10cSrcweir }
331cdf0e10cSrcweir //----------------------------------------------------------------------------
~OObjectBase()332cdf0e10cSrcweir OObjectBase::~OObjectBase()
333cdf0e10cSrcweir {
334cdf0e10cSrcweir DBG_DTOR( rpt_OObjectBase,NULL);
335cdf0e10cSrcweir m_xMediator.reset();
336cdf0e10cSrcweir if ( isListening() )
337cdf0e10cSrcweir EndListening();
338cdf0e10cSrcweir m_xReportComponent.clear();
339cdf0e10cSrcweir }
340cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSection() const341cdf0e10cSrcweir uno::Reference< report::XSection> OObjectBase::getSection() const
342cdf0e10cSrcweir {
343cdf0e10cSrcweir uno::Reference< report::XSection> xSection;
344cdf0e10cSrcweir OReportPage* pPage = dynamic_cast<OReportPage*>(GetImplPage());
345cdf0e10cSrcweir if ( pPage )
346cdf0e10cSrcweir xSection = pPage->getSection();
347cdf0e10cSrcweir return xSection;
348cdf0e10cSrcweir }
349cdf0e10cSrcweir // -----------------------------------------------------------------------------
getReportComponent() const350cdf0e10cSrcweir uno::Reference< report::XReportComponent> OObjectBase::getReportComponent() const
351cdf0e10cSrcweir {
352cdf0e10cSrcweir return m_xReportComponent;
353cdf0e10cSrcweir }
354cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAwtComponent()355cdf0e10cSrcweir uno::Reference< beans::XPropertySet> OObjectBase::getAwtComponent()
356cdf0e10cSrcweir {
357cdf0e10cSrcweir return uno::Reference< beans::XPropertySet>();
358cdf0e10cSrcweir }
359cdf0e10cSrcweir //----------------------------------------------------------------------------
StartListening()360cdf0e10cSrcweir void OObjectBase::StartListening()
361cdf0e10cSrcweir {
362cdf0e10cSrcweir DBG_CHKTHIS( rpt_OObjectBase,NULL);
363cdf0e10cSrcweir OSL_ENSURE(!isListening(), "OUnoObject::StartListening: already listening!");
364cdf0e10cSrcweir
365cdf0e10cSrcweir if ( !isListening() && m_xReportComponent.is() )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir m_bIsListening = sal_True;
368cdf0e10cSrcweir
369cdf0e10cSrcweir if ( !m_xPropertyChangeListener.is() )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir m_xPropertyChangeListener = new OObjectListener( this );
372cdf0e10cSrcweir // register listener to all properties
373cdf0e10cSrcweir m_xReportComponent->addPropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener );
374cdf0e10cSrcweir }
375cdf0e10cSrcweir }
376cdf0e10cSrcweir }
377cdf0e10cSrcweir //----------------------------------------------------------------------------
EndListening(sal_Bool)378cdf0e10cSrcweir void OObjectBase::EndListening(sal_Bool /*bRemoveListener*/)
379cdf0e10cSrcweir {
380cdf0e10cSrcweir DBG_CHKTHIS( rpt_OObjectBase,NULL);
381cdf0e10cSrcweir OSL_ENSURE(!m_xReportComponent.is() || isListening(), "OUnoObject::EndListening: not listening currently!");
382cdf0e10cSrcweir
383cdf0e10cSrcweir m_bIsListening = sal_False;
384cdf0e10cSrcweir if ( isListening() && m_xReportComponent.is() )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir // XPropertyChangeListener
387cdf0e10cSrcweir if ( m_xPropertyChangeListener.is() )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir // remove listener
390cdf0e10cSrcweir try
391cdf0e10cSrcweir {
392cdf0e10cSrcweir m_xReportComponent->removePropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener );
393cdf0e10cSrcweir }
394cdf0e10cSrcweir catch(uno::Exception)
395cdf0e10cSrcweir {
396cdf0e10cSrcweir OSL_ENSURE(0,"OObjectBase::EndListening: Exception caught!");
397cdf0e10cSrcweir }
398cdf0e10cSrcweir }
399cdf0e10cSrcweir m_xPropertyChangeListener.clear();
400cdf0e10cSrcweir }
401cdf0e10cSrcweir }
402cdf0e10cSrcweir //----------------------------------------------------------------------------
SetPropsFromRect(const Rectangle & _rRect)403cdf0e10cSrcweir void OObjectBase::SetPropsFromRect(const Rectangle& _rRect)
404cdf0e10cSrcweir {
405cdf0e10cSrcweir DBG_CHKTHIS( rpt_OObjectBase,NULL);
406cdf0e10cSrcweir // set properties
407cdf0e10cSrcweir OReportPage* pPage = dynamic_cast<OReportPage*>(GetImplPage());
408cdf0e10cSrcweir if ( pPage && !_rRect.IsEmpty() )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir uno::Reference<report::XSection> xSection = pPage->getSection();
411cdf0e10cSrcweir if ( xSection.is() && (static_cast<sal_uInt32>(_rRect.getHeight() + _rRect.Top()) > xSection->getHeight()) )
412cdf0e10cSrcweir xSection->setHeight(_rRect.getHeight() + _rRect.Top());
413cdf0e10cSrcweir
414cdf0e10cSrcweir // TODO
415cdf0e10cSrcweir //pModel->GetRefDevice()->Invalidate(INVALIDATE_CHILDREN);
416cdf0e10cSrcweir }
417cdf0e10cSrcweir }
418cdf0e10cSrcweir //----------------------------------------------------------------------------
_propertyChange(const beans::PropertyChangeEvent &)419cdf0e10cSrcweir void OObjectBase::_propertyChange( const beans::PropertyChangeEvent& /*evt*/ ) throw( uno::RuntimeException)
420cdf0e10cSrcweir {
421cdf0e10cSrcweir DBG_CHKTHIS( rpt_OObjectBase,NULL);
422cdf0e10cSrcweir }
423cdf0e10cSrcweir //----------------------------------------------------------------------------
SetObjectItemHelper(const SfxPoolItem &)424cdf0e10cSrcweir void OObjectBase::SetObjectItemHelper(const SfxPoolItem& /*rItem*/)
425cdf0e10cSrcweir {
426cdf0e10cSrcweir // do nothing
427cdf0e10cSrcweir }
428cdf0e10cSrcweir
429cdf0e10cSrcweir //----------------------------------------------------------------------------
supportsService(const::rtl::OUString & _sServiceName) const430cdf0e10cSrcweir sal_Bool OObjectBase::supportsService( const ::rtl::OUString& _sServiceName ) const
431cdf0e10cSrcweir {
432cdf0e10cSrcweir DBG_CHKTHIS( rpt_OObjectBase,NULL);
433cdf0e10cSrcweir sal_Bool bSupports = sal_False;
434cdf0e10cSrcweir
435cdf0e10cSrcweir Reference< lang::XServiceInfo > xServiceInfo( m_xReportComponent , UNO_QUERY );
436cdf0e10cSrcweir // TODO: cache xServiceInfo as member?
437cdf0e10cSrcweir if ( xServiceInfo.is() )
438cdf0e10cSrcweir bSupports = xServiceInfo->supportsService( _sServiceName );
439cdf0e10cSrcweir
440cdf0e10cSrcweir return bSupports;
441cdf0e10cSrcweir }
442cdf0e10cSrcweir
443cdf0e10cSrcweir //----------------------------------------------------------------------------
ensureSdrObjectOwnership(const uno::Reference<uno::XInterface> & _rxShape)444cdf0e10cSrcweir void OObjectBase::ensureSdrObjectOwnership( const uno::Reference< uno::XInterface >& _rxShape )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir // UNDO in the report designer is implemented at the level of the XShapes, not
447cdf0e10cSrcweir // at the level of SdrObjects. That is, if an object is removed from the report
448cdf0e10cSrcweir // design, then this happens by removing the XShape from the UNO DrawPage, and
449cdf0e10cSrcweir // putting this XShape (resp. the ReportComponent which wraps it) into an UNDO
450cdf0e10cSrcweir // action.
451cdf0e10cSrcweir // Unfortunately, the SvxDrawPage implementation usually deletes SdrObjects
452cdf0e10cSrcweir // which are removed from it, which is deadly for us. To prevent this,
453cdf0e10cSrcweir // we give the XShape implementation the ownership of the SdrObject, which
454cdf0e10cSrcweir // ensures the SvxDrawPage won't delete it.
455cdf0e10cSrcweir SvxShape* pShape = SvxShape::getImplementation( _rxShape );
456cdf0e10cSrcweir OSL_ENSURE( pShape, "OObjectBase::ensureSdrObjectOwnership: can't access the SvxShape!" );
457cdf0e10cSrcweir if ( pShape )
458cdf0e10cSrcweir {
459cdf0e10cSrcweir OSL_ENSURE( !pShape->HasSdrObjectOwnership(), "OObjectBase::ensureSdrObjectOwnership: called twice?" );
460cdf0e10cSrcweir pShape->TakeSdrObjectOwnership();
461cdf0e10cSrcweir }
462cdf0e10cSrcweir }
463cdf0e10cSrcweir
464cdf0e10cSrcweir //----------------------------------------------------------------------------
getUnoShapeOf(SdrObject & _rSdrObject)465cdf0e10cSrcweir uno::Reference< uno::XInterface > OObjectBase::getUnoShapeOf( SdrObject& _rSdrObject )
466cdf0e10cSrcweir {
467cdf0e10cSrcweir uno::Reference< uno::XInterface > xShape( _rSdrObject.getWeakUnoShape() );
468cdf0e10cSrcweir if ( xShape.is() )
469cdf0e10cSrcweir return xShape;
470cdf0e10cSrcweir
471cdf0e10cSrcweir xShape = _rSdrObject.SdrObject::getUnoShape();
472cdf0e10cSrcweir if ( !xShape.is() )
473cdf0e10cSrcweir return xShape;
474cdf0e10cSrcweir
475cdf0e10cSrcweir ensureSdrObjectOwnership( xShape );
476cdf0e10cSrcweir
477cdf0e10cSrcweir m_xKeepShapeAlive = xShape;
478cdf0e10cSrcweir return xShape;
479cdf0e10cSrcweir }
480cdf0e10cSrcweir
481cdf0e10cSrcweir //----------------------------------------------------------------------------
482cdf0e10cSrcweir TYPEINIT1(OCustomShape, SdrObjCustomShape);
483cdf0e10cSrcweir DBG_NAME( rpt_OCustomShape );
OCustomShape(const uno::Reference<report::XReportComponent> & _xComponent)484cdf0e10cSrcweir OCustomShape::OCustomShape(const uno::Reference< report::XReportComponent>& _xComponent
485cdf0e10cSrcweir )
486cdf0e10cSrcweir :SdrObjCustomShape()
487cdf0e10cSrcweir ,OObjectBase(_xComponent)
488cdf0e10cSrcweir {
489cdf0e10cSrcweir DBG_CTOR( rpt_OCustomShape, NULL);
490cdf0e10cSrcweir impl_setUnoShape( uno::Reference< uno::XInterface >(_xComponent,uno::UNO_QUERY) );
491cdf0e10cSrcweir m_bIsListening = sal_True;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir //----------------------------------------------------------------------------
OCustomShape(const::rtl::OUString & _sComponentName)494cdf0e10cSrcweir OCustomShape::OCustomShape(const ::rtl::OUString& _sComponentName)
495cdf0e10cSrcweir :SdrObjCustomShape()
496cdf0e10cSrcweir ,OObjectBase(_sComponentName)
497cdf0e10cSrcweir {
498cdf0e10cSrcweir DBG_CTOR( rpt_OCustomShape, NULL);
499cdf0e10cSrcweir m_bIsListening = sal_True;
500cdf0e10cSrcweir }
501cdf0e10cSrcweir
502cdf0e10cSrcweir //----------------------------------------------------------------------------
~OCustomShape()503cdf0e10cSrcweir OCustomShape::~OCustomShape()
504cdf0e10cSrcweir {
505cdf0e10cSrcweir DBG_DTOR( rpt_OCustomShape, NULL);
506cdf0e10cSrcweir }
507cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetObjIdentifier() const508cdf0e10cSrcweir sal_uInt16 OCustomShape::GetObjIdentifier() const
509cdf0e10cSrcweir {
510cdf0e10cSrcweir return sal_uInt16(OBJ_CUSTOMSHAPE);
511cdf0e10cSrcweir }
512cdf0e10cSrcweir //----------------------------------------------------------------------------
GetObjInventor() const513cdf0e10cSrcweir sal_uInt32 OCustomShape::GetObjInventor() const
514cdf0e10cSrcweir {
515cdf0e10cSrcweir return ReportInventor;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir //----------------------------------------------------------------------------
GetImplPage() const518cdf0e10cSrcweir SdrPage* OCustomShape::GetImplPage() const
519cdf0e10cSrcweir {
520cdf0e10cSrcweir return GetPage();
521cdf0e10cSrcweir }
522cdf0e10cSrcweir //----------------------------------------------------------------------------
SetSnapRectImpl(const Rectangle & _rRect)523cdf0e10cSrcweir void OCustomShape::SetSnapRectImpl(const Rectangle& _rRect)
524cdf0e10cSrcweir {
525cdf0e10cSrcweir SetSnapRect( _rRect );
526cdf0e10cSrcweir }
527cdf0e10cSrcweir //----------------------------------------------------------------------------
GetStep() const528cdf0e10cSrcweir sal_Int32 OCustomShape::GetStep() const
529cdf0e10cSrcweir {
530cdf0e10cSrcweir // get step property
531cdf0e10cSrcweir sal_Int32 nStep = 0;
532cdf0e10cSrcweir OSL_ENSURE(0,"Who called me!");
533cdf0e10cSrcweir return nStep;
534cdf0e10cSrcweir }
535cdf0e10cSrcweir //----------------------------------------------------------------------------
NbcMove(const Size & rSize)536cdf0e10cSrcweir void OCustomShape::NbcMove( const Size& rSize )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir if ( m_bIsListening )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir m_bIsListening = sal_False;
541cdf0e10cSrcweir
542cdf0e10cSrcweir if ( m_xReportComponent.is() )
543cdf0e10cSrcweir {
544cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
545cdf0e10cSrcweir OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
546cdf0e10cSrcweir m_xReportComponent->setPositionX(m_xReportComponent->getPositionX() + rSize.A());
547cdf0e10cSrcweir m_xReportComponent->setPositionY(m_xReportComponent->getPositionY() + rSize.B());
548cdf0e10cSrcweir }
549cdf0e10cSrcweir
550cdf0e10cSrcweir // set geometry properties
551cdf0e10cSrcweir SetPropsFromRect(GetSnapRect());
552cdf0e10cSrcweir
553cdf0e10cSrcweir m_bIsListening = sal_True;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir else
556cdf0e10cSrcweir SdrObjCustomShape::NbcMove( rSize );
557cdf0e10cSrcweir }
558cdf0e10cSrcweir //----------------------------------------------------------------------------
NbcResize(const Point & rRef,const Fraction & xFract,const Fraction & yFract)559cdf0e10cSrcweir void OCustomShape::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
560cdf0e10cSrcweir {
561cdf0e10cSrcweir SdrObjCustomShape::NbcResize( rRef, xFract, yFract );
562cdf0e10cSrcweir
563cdf0e10cSrcweir SetPropsFromRect(GetSnapRect());
564cdf0e10cSrcweir }
565cdf0e10cSrcweir //----------------------------------------------------------------------------
NbcSetLogicRect(const Rectangle & rRect)566cdf0e10cSrcweir void OCustomShape::NbcSetLogicRect(const Rectangle& rRect)
567cdf0e10cSrcweir {
568cdf0e10cSrcweir SdrObjCustomShape::NbcSetLogicRect(rRect);
569cdf0e10cSrcweir SetPropsFromRect(rRect);
570cdf0e10cSrcweir }
571cdf0e10cSrcweir //----------------------------------------------------------------------------
EndCreate(SdrDragStat & rStat,SdrCreateCmd eCmd)572cdf0e10cSrcweir FASTBOOL OCustomShape::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
573cdf0e10cSrcweir {
574cdf0e10cSrcweir FASTBOOL bResult = SdrObjCustomShape::EndCreate(rStat, eCmd);
575cdf0e10cSrcweir if ( bResult )
576cdf0e10cSrcweir {
577cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
578cdf0e10cSrcweir if ( pRptModel )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
581cdf0e10cSrcweir if ( !m_xReportComponent.is() )
582cdf0e10cSrcweir m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY);
583cdf0e10cSrcweir }
584cdf0e10cSrcweir SetPropsFromRect(GetSnapRect());
585cdf0e10cSrcweir }
586cdf0e10cSrcweir
587cdf0e10cSrcweir return bResult;
588cdf0e10cSrcweir }
589cdf0e10cSrcweir
590cdf0e10cSrcweir //----------------------------------------------------------------------------
SetObjectItemHelper(const SfxPoolItem & rItem)591cdf0e10cSrcweir void OCustomShape::SetObjectItemHelper(const SfxPoolItem& rItem)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir SetObjectItem(rItem);
594cdf0e10cSrcweir // TODO
595cdf0e10cSrcweir //getSectionWindow()->getView()->AdjustMarkHdl();
596cdf0e10cSrcweir }
597cdf0e10cSrcweir
598cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAwtComponent()599cdf0e10cSrcweir uno::Reference< beans::XPropertySet> OCustomShape::getAwtComponent()
600cdf0e10cSrcweir {
601cdf0e10cSrcweir return uno::Reference< beans::XPropertySet>(m_xReportComponent,uno::UNO_QUERY);
602cdf0e10cSrcweir }
603cdf0e10cSrcweir
604cdf0e10cSrcweir //----------------------------------------------------------------------------
getUnoShape()605cdf0e10cSrcweir uno::Reference< uno::XInterface > OCustomShape::getUnoShape()
606cdf0e10cSrcweir {
607cdf0e10cSrcweir uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this );
608cdf0e10cSrcweir if ( !m_xReportComponent.is() )
609cdf0e10cSrcweir {
610cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
611cdf0e10cSrcweir OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
612cdf0e10cSrcweir m_xReportComponent.set(xShape,uno::UNO_QUERY);
613cdf0e10cSrcweir }
614cdf0e10cSrcweir return xShape;
615cdf0e10cSrcweir }
616cdf0e10cSrcweir
617cdf0e10cSrcweir //----------------------------------------------------------------------------
618cdf0e10cSrcweir //----------------------------------------------------------------------------
619cdf0e10cSrcweir TYPEINIT1(OUnoObject, SdrUnoObj);
620cdf0e10cSrcweir DBG_NAME( rpt_OUnoObject );
621cdf0e10cSrcweir //----------------------------------------------------------------------------
OUnoObject(const::rtl::OUString & _sComponentName,const::rtl::OUString & rModelName,sal_uInt16 _nObjectType)622cdf0e10cSrcweir OUnoObject::OUnoObject(const ::rtl::OUString& _sComponentName
623cdf0e10cSrcweir ,const ::rtl::OUString& rModelName
624cdf0e10cSrcweir ,sal_uInt16 _nObjectType)
625cdf0e10cSrcweir :SdrUnoObj(rModelName, sal_True)
626cdf0e10cSrcweir ,OObjectBase(_sComponentName)
627cdf0e10cSrcweir ,m_nObjectType(_nObjectType)
628cdf0e10cSrcweir {
629cdf0e10cSrcweir DBG_CTOR( rpt_OUnoObject, NULL);
630cdf0e10cSrcweir if ( rModelName.getLength() )
631cdf0e10cSrcweir impl_initializeModel_nothrow();
632cdf0e10cSrcweir }
633cdf0e10cSrcweir //----------------------------------------------------------------------------
OUnoObject(const uno::Reference<report::XReportComponent> & _xComponent,const::rtl::OUString & rModelName,sal_uInt16 _nObjectType)634cdf0e10cSrcweir OUnoObject::OUnoObject(const uno::Reference< report::XReportComponent>& _xComponent
635cdf0e10cSrcweir ,const ::rtl::OUString& rModelName
636cdf0e10cSrcweir ,sal_uInt16 _nObjectType)
637cdf0e10cSrcweir :SdrUnoObj(rModelName, sal_True)
638cdf0e10cSrcweir ,OObjectBase(_xComponent)
639cdf0e10cSrcweir ,m_nObjectType(_nObjectType)
640cdf0e10cSrcweir {
641cdf0e10cSrcweir DBG_CTOR( rpt_OUnoObject, NULL);
642cdf0e10cSrcweir impl_setUnoShape( uno::Reference< uno::XInterface >( _xComponent, uno::UNO_QUERY ) );
643cdf0e10cSrcweir
644cdf0e10cSrcweir if ( rModelName.getLength() )
645cdf0e10cSrcweir impl_initializeModel_nothrow();
646cdf0e10cSrcweir
647cdf0e10cSrcweir if ( rModelName.getLength() )
648cdf0e10cSrcweir impl_initializeModel_nothrow();
649cdf0e10cSrcweir }
650cdf0e10cSrcweir //----------------------------------------------------------------------------
~OUnoObject()651cdf0e10cSrcweir OUnoObject::~OUnoObject()
652cdf0e10cSrcweir {
653cdf0e10cSrcweir DBG_DTOR( rpt_OUnoObject, NULL);
654cdf0e10cSrcweir }
655cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_initializeModel_nothrow()656cdf0e10cSrcweir void OUnoObject::impl_initializeModel_nothrow()
657cdf0e10cSrcweir {
658cdf0e10cSrcweir try
659cdf0e10cSrcweir {
660cdf0e10cSrcweir Reference< XFormattedField > xFormatted( m_xReportComponent, UNO_QUERY );
661cdf0e10cSrcweir if ( xFormatted.is() )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir const Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY_THROW );
664cdf0e10cSrcweir const ::rtl::OUString sTreatAsNumberProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TreatAsNumber" ) );
665cdf0e10cSrcweir xModelProps->setPropertyValue( sTreatAsNumberProperty, makeAny( sal_False ) );
666cdf0e10cSrcweir xModelProps->setPropertyValue( PROPERTY_VERTICALALIGN,m_xReportComponent->getPropertyValue(PROPERTY_VERTICALALIGN));
667cdf0e10cSrcweir }
668cdf0e10cSrcweir }
669cdf0e10cSrcweir catch( const Exception& )
670cdf0e10cSrcweir {
671cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
672cdf0e10cSrcweir }
673cdf0e10cSrcweir }
674cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_setReportComponent_nothrow()675cdf0e10cSrcweir void OUnoObject::impl_setReportComponent_nothrow()
676cdf0e10cSrcweir {
677cdf0e10cSrcweir if ( m_xReportComponent.is() )
678cdf0e10cSrcweir return;
679cdf0e10cSrcweir
680cdf0e10cSrcweir OReportModel* pReportModel = static_cast<OReportModel*>(GetModel());
681cdf0e10cSrcweir OSL_ENSURE( pReportModel, "OUnoObject::impl_setReportComponent_nothrow: no report model!" );
682cdf0e10cSrcweir if ( !pReportModel )
683cdf0e10cSrcweir return;
684cdf0e10cSrcweir
685cdf0e10cSrcweir OXUndoEnvironment::OUndoEnvLock aLock( pReportModel->GetUndoEnv() );
686cdf0e10cSrcweir m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY);
687cdf0e10cSrcweir
688cdf0e10cSrcweir impl_initializeModel_nothrow();
689cdf0e10cSrcweir }
690cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetObjIdentifier() const691cdf0e10cSrcweir sal_uInt16 OUnoObject::GetObjIdentifier() const
692cdf0e10cSrcweir {
693cdf0e10cSrcweir return sal_uInt16(m_nObjectType);
694cdf0e10cSrcweir }
695cdf0e10cSrcweir //----------------------------------------------------------------------------
GetObjInventor() const696cdf0e10cSrcweir sal_uInt32 OUnoObject::GetObjInventor() const
697cdf0e10cSrcweir {
698cdf0e10cSrcweir return ReportInventor;
699cdf0e10cSrcweir }
700cdf0e10cSrcweir //----------------------------------------------------------------------------
GetImplPage() const701cdf0e10cSrcweir SdrPage* OUnoObject::GetImplPage() const
702cdf0e10cSrcweir {
703cdf0e10cSrcweir DBG_CHKTHIS( rpt_OUnoObject,NULL);
704cdf0e10cSrcweir return GetPage();
705cdf0e10cSrcweir }
706cdf0e10cSrcweir //----------------------------------------------------------------------------
SetSnapRectImpl(const Rectangle & _rRect)707cdf0e10cSrcweir void OUnoObject::SetSnapRectImpl(const Rectangle& _rRect)
708cdf0e10cSrcweir {
709cdf0e10cSrcweir DBG_CHKTHIS( rpt_OUnoObject,NULL);
710cdf0e10cSrcweir SetSnapRect( _rRect );
711cdf0e10cSrcweir }
712cdf0e10cSrcweir //----------------------------------------------------------------------------
GetStep() const713cdf0e10cSrcweir sal_Int32 OUnoObject::GetStep() const
714cdf0e10cSrcweir {
715cdf0e10cSrcweir DBG_CHKTHIS( rpt_OUnoObject,NULL);
716cdf0e10cSrcweir // get step property
717cdf0e10cSrcweir sal_Int32 nStep = 0;
718cdf0e10cSrcweir OSL_ENSURE(0,"Who called me!");
719cdf0e10cSrcweir return nStep;
720cdf0e10cSrcweir }
721cdf0e10cSrcweir
722cdf0e10cSrcweir //----------------------------------------------------------------------------
NbcMove(const Size & rSize)723cdf0e10cSrcweir void OUnoObject::NbcMove( const Size& rSize )
724cdf0e10cSrcweir {
725cdf0e10cSrcweir DBG_CHKTHIS( rpt_OUnoObject,NULL);
726cdf0e10cSrcweir
727cdf0e10cSrcweir if ( m_bIsListening )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir // stop listening
730cdf0e10cSrcweir OObjectBase::EndListening(sal_False);
731cdf0e10cSrcweir
732cdf0e10cSrcweir bool bPositionFixed = false;
733cdf0e10cSrcweir Size aUndoSize(0,0);
734cdf0e10cSrcweir bool bUndoMode = false;
735cdf0e10cSrcweir if ( m_xReportComponent.is() )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
738cdf0e10cSrcweir if (pRptModel->GetUndoEnv().IsUndoMode())
739cdf0e10cSrcweir {
740cdf0e10cSrcweir // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode
741cdf0e10cSrcweir bUndoMode = true;
742cdf0e10cSrcweir }
743cdf0e10cSrcweir OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
744cdf0e10cSrcweir
745cdf0e10cSrcweir // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point?
746cdf0e10cSrcweir int nNewX = m_xReportComponent->getPositionX() + rSize.A();
747cdf0e10cSrcweir // can this hinder us to set components outside the area?
748cdf0e10cSrcweir // if (nNewX < 0)
749cdf0e10cSrcweir // {
750cdf0e10cSrcweir // nNewX = 0;
751cdf0e10cSrcweir // }
752cdf0e10cSrcweir m_xReportComponent->setPositionX(nNewX);
753cdf0e10cSrcweir int nNewY = m_xReportComponent->getPositionY() + rSize.B();
754cdf0e10cSrcweir if (nNewY < 0 && !bUndoMode)
755cdf0e10cSrcweir {
756cdf0e10cSrcweir aUndoSize.B() = abs(nNewY);
757cdf0e10cSrcweir bPositionFixed = true;
758cdf0e10cSrcweir nNewY = 0;
759cdf0e10cSrcweir }
760cdf0e10cSrcweir m_xReportComponent->setPositionY(nNewY);
761cdf0e10cSrcweir }
762cdf0e10cSrcweir if (bPositionFixed)
763cdf0e10cSrcweir {
764cdf0e10cSrcweir GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize));
765cdf0e10cSrcweir }
766cdf0e10cSrcweir // set geometry properties
767cdf0e10cSrcweir SetPropsFromRect(GetLogicRect());
768cdf0e10cSrcweir
769cdf0e10cSrcweir // start listening
770cdf0e10cSrcweir OObjectBase::StartListening();
771cdf0e10cSrcweir }
772cdf0e10cSrcweir else
773cdf0e10cSrcweir SdrUnoObj::NbcMove( rSize );
774cdf0e10cSrcweir }
775cdf0e10cSrcweir
776cdf0e10cSrcweir //----------------------------------------------------------------------------
777cdf0e10cSrcweir
NbcResize(const Point & rRef,const Fraction & xFract,const Fraction & yFract)778cdf0e10cSrcweir void OUnoObject::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
779cdf0e10cSrcweir {
780cdf0e10cSrcweir DBG_CHKTHIS( rpt_OUnoObject,NULL);
781cdf0e10cSrcweir SdrUnoObj::NbcResize( rRef, xFract, yFract );
782cdf0e10cSrcweir
783cdf0e10cSrcweir // stop listening
784cdf0e10cSrcweir OObjectBase::EndListening(sal_False);
785cdf0e10cSrcweir
786cdf0e10cSrcweir // set geometry properties
787cdf0e10cSrcweir SetPropsFromRect(GetLogicRect());
788cdf0e10cSrcweir
789cdf0e10cSrcweir // start listening
790cdf0e10cSrcweir OObjectBase::StartListening();
791cdf0e10cSrcweir }
792cdf0e10cSrcweir //----------------------------------------------------------------------------
NbcSetLogicRect(const Rectangle & rRect)793cdf0e10cSrcweir void OUnoObject::NbcSetLogicRect(const Rectangle& rRect)
794cdf0e10cSrcweir {
795cdf0e10cSrcweir SdrUnoObj::NbcSetLogicRect(rRect);
796cdf0e10cSrcweir // stop listening
797cdf0e10cSrcweir OObjectBase::EndListening(sal_False);
798cdf0e10cSrcweir
799cdf0e10cSrcweir // set geometry properties
800cdf0e10cSrcweir SetPropsFromRect(rRect);
801cdf0e10cSrcweir
802cdf0e10cSrcweir // start listening
803cdf0e10cSrcweir OObjectBase::StartListening();
804cdf0e10cSrcweir }
805cdf0e10cSrcweir //----------------------------------------------------------------------------
806cdf0e10cSrcweir
EndCreate(SdrDragStat & rStat,SdrCreateCmd eCmd)807cdf0e10cSrcweir FASTBOOL OUnoObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
808cdf0e10cSrcweir {
809cdf0e10cSrcweir DBG_CHKTHIS( rpt_OUnoObject,NULL);
810cdf0e10cSrcweir FASTBOOL bResult = SdrUnoObj::EndCreate(rStat, eCmd);
811cdf0e10cSrcweir if ( bResult )
812cdf0e10cSrcweir {
813cdf0e10cSrcweir impl_setReportComponent_nothrow();
814cdf0e10cSrcweir // set labels
815cdf0e10cSrcweir if ( m_xReportComponent.is() )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir try
818cdf0e10cSrcweir {
819cdf0e10cSrcweir if ( supportsService( SERVICE_FIXEDTEXT ) )
820cdf0e10cSrcweir {
821cdf0e10cSrcweir m_xReportComponent->setPropertyValue( PROPERTY_LABEL, uno::makeAny(GetDefaultName(this)) );
822cdf0e10cSrcweir }
823cdf0e10cSrcweir }
824cdf0e10cSrcweir catch(const uno::Exception&)
825cdf0e10cSrcweir {
826cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
827cdf0e10cSrcweir }
828cdf0e10cSrcweir
829cdf0e10cSrcweir impl_initializeModel_nothrow();
830cdf0e10cSrcweir }
831cdf0e10cSrcweir // set geometry properties
832cdf0e10cSrcweir SetPropsFromRect(GetLogicRect());
833cdf0e10cSrcweir }
834cdf0e10cSrcweir
835cdf0e10cSrcweir return bResult;
836cdf0e10cSrcweir }
837cdf0e10cSrcweir //----------------------------------------------------------------------------
GetDefaultName(const OUnoObject * _pObj)838cdf0e10cSrcweir ::rtl::OUString OUnoObject::GetDefaultName(const OUnoObject* _pObj)
839cdf0e10cSrcweir {
840cdf0e10cSrcweir sal_uInt16 nResId = 0;
841cdf0e10cSrcweir ::rtl::OUString aDefaultName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HERE WE HAVE TO INSERT OUR NAME!"));
842cdf0e10cSrcweir if ( _pObj->supportsService( SERVICE_FIXEDTEXT ) )
843cdf0e10cSrcweir {
844cdf0e10cSrcweir nResId = RID_STR_CLASS_FIXEDTEXT;
845cdf0e10cSrcweir }
846cdf0e10cSrcweir else if ( _pObj->supportsService( SERVICE_FIXEDLINE ) )
847cdf0e10cSrcweir {
848cdf0e10cSrcweir nResId = RID_STR_CLASS_FIXEDLINE;
849cdf0e10cSrcweir }
850cdf0e10cSrcweir else if ( _pObj->supportsService( SERVICE_IMAGECONTROL ) )
851cdf0e10cSrcweir {
852cdf0e10cSrcweir nResId = RID_STR_CLASS_IMAGECONTROL;
853cdf0e10cSrcweir }
854cdf0e10cSrcweir else if ( _pObj->supportsService( SERVICE_FORMATTEDFIELD ) )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir nResId = RID_STR_CLASS_FORMATTEDFIELD;
857cdf0e10cSrcweir }
858cdf0e10cSrcweir
859cdf0e10cSrcweir if (nResId)
860cdf0e10cSrcweir aDefaultName = ::rtl::OUString( String(ModuleRes(nResId)) );
861cdf0e10cSrcweir
862cdf0e10cSrcweir return aDefaultName;
863cdf0e10cSrcweir }
864cdf0e10cSrcweir
865cdf0e10cSrcweir // -----------------------------------------------------------------------------
_propertyChange(const beans::PropertyChangeEvent & evt)866cdf0e10cSrcweir void OUnoObject::_propertyChange( const beans::PropertyChangeEvent& evt ) throw( uno::RuntimeException)
867cdf0e10cSrcweir {
868cdf0e10cSrcweir DBG_CHKTHIS( rpt_OUnoObject,NULL);
869cdf0e10cSrcweir OObjectBase::_propertyChange(evt);
870cdf0e10cSrcweir if (isListening())
871cdf0e10cSrcweir {
872cdf0e10cSrcweir if ( evt.PropertyName == PROPERTY_CHARCOLOR )
873cdf0e10cSrcweir {
874cdf0e10cSrcweir Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);
875cdf0e10cSrcweir if ( xControlModel.is() )
876cdf0e10cSrcweir {
877cdf0e10cSrcweir OObjectBase::EndListening(sal_False);
878cdf0e10cSrcweir try
879cdf0e10cSrcweir {
880cdf0e10cSrcweir xControlModel->setPropertyValue(PROPERTY_TEXTCOLOR,evt.NewValue);
881cdf0e10cSrcweir }
882cdf0e10cSrcweir catch(uno::Exception&)
883cdf0e10cSrcweir {
884cdf0e10cSrcweir }
885cdf0e10cSrcweir OObjectBase::StartListening();
886cdf0e10cSrcweir }
887cdf0e10cSrcweir }
888cdf0e10cSrcweir else if ( evt.PropertyName == PROPERTY_NAME )
889cdf0e10cSrcweir {
890cdf0e10cSrcweir Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);
891cdf0e10cSrcweir if ( xControlModel.is() && xControlModel->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir // get old name
894cdf0e10cSrcweir ::rtl::OUString aOldName;
895cdf0e10cSrcweir evt.OldValue >>= aOldName;
896cdf0e10cSrcweir
897cdf0e10cSrcweir // get new name
898cdf0e10cSrcweir ::rtl::OUString aNewName;
899cdf0e10cSrcweir evt.NewValue >>= aNewName;
900cdf0e10cSrcweir
901cdf0e10cSrcweir if ( !aNewName.equals(aOldName) )
902cdf0e10cSrcweir {
903cdf0e10cSrcweir // set old name property
904cdf0e10cSrcweir OObjectBase::EndListening(sal_False);
905cdf0e10cSrcweir if ( m_xMediator.is() )
906cdf0e10cSrcweir m_xMediator.get()->stopListening();
907cdf0e10cSrcweir try
908cdf0e10cSrcweir {
909cdf0e10cSrcweir xControlModel->setPropertyValue( PROPERTY_NAME, evt.NewValue );
910cdf0e10cSrcweir }
911cdf0e10cSrcweir catch(uno::Exception&)
912cdf0e10cSrcweir {
913cdf0e10cSrcweir }
914cdf0e10cSrcweir if ( m_xMediator.is() )
915cdf0e10cSrcweir m_xMediator.get()->startListening();
916cdf0e10cSrcweir OObjectBase::StartListening();
917cdf0e10cSrcweir }
918cdf0e10cSrcweir }
919cdf0e10cSrcweir }
920cdf0e10cSrcweir }
921cdf0e10cSrcweir }
922cdf0e10cSrcweir // -----------------------------------------------------------------------------
CreateMediator(sal_Bool _bReverse)923cdf0e10cSrcweir void OUnoObject::CreateMediator(sal_Bool _bReverse)
924cdf0e10cSrcweir {
925cdf0e10cSrcweir if ( !m_xMediator.is() )
926cdf0e10cSrcweir {
927cdf0e10cSrcweir impl_setReportComponent_nothrow();
928cdf0e10cSrcweir
929cdf0e10cSrcweir Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);
930cdf0e10cSrcweir if ( !m_xMediator.is() && m_xReportComponent.is() && xControlModel.is() )
931cdf0e10cSrcweir m_xMediator = TMediator::createFromQuery(new OPropertyMediator(m_xReportComponent.get(),xControlModel,getPropertyNameMap(GetObjIdentifier()),_bReverse));
932cdf0e10cSrcweir OObjectBase::StartListening();
933cdf0e10cSrcweir }
934cdf0e10cSrcweir }
935cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAwtComponent()936cdf0e10cSrcweir uno::Reference< beans::XPropertySet> OUnoObject::getAwtComponent()
937cdf0e10cSrcweir {
938cdf0e10cSrcweir return Reference<XPropertySet>(GetUnoControlModel(),uno::UNO_QUERY);
939cdf0e10cSrcweir }
940cdf0e10cSrcweir
941cdf0e10cSrcweir // -----------------------------------------------------------------------------
getUnoShape()942cdf0e10cSrcweir uno::Reference< uno::XInterface > OUnoObject::getUnoShape()
943cdf0e10cSrcweir {
944cdf0e10cSrcweir return OObjectBase::getUnoShapeOf( *this );
945cdf0e10cSrcweir }
946cdf0e10cSrcweir // -----------------------------------------------------------------------------
Clone() const947cdf0e10cSrcweir SdrObject* OUnoObject::Clone() const
948cdf0e10cSrcweir {
949cdf0e10cSrcweir SdrObject* pClone = SdrUnoObj::Clone();
950cdf0e10cSrcweir if ( pClone )
951cdf0e10cSrcweir {
952cdf0e10cSrcweir Reference<XPropertySet> xSource(const_cast<OUnoObject*>(this)->getUnoShape(),uno::UNO_QUERY);
953cdf0e10cSrcweir Reference<XPropertySet> xDest(pClone->getUnoShape(),uno::UNO_QUERY);
954cdf0e10cSrcweir if ( xSource.is() && xDest.is() )
955cdf0e10cSrcweir comphelper::copyProperties(xSource.get(),xDest.get());
956cdf0e10cSrcweir } // if ( pClone )
957cdf0e10cSrcweir return pClone;
958cdf0e10cSrcweir }
959cdf0e10cSrcweir //----------------------------------------------------------------------------
960cdf0e10cSrcweir // OOle2Obj
961cdf0e10cSrcweir //----------------------------------------------------------------------------
962cdf0e10cSrcweir TYPEINIT1(OOle2Obj, SdrOle2Obj);
963cdf0e10cSrcweir DBG_NAME( rpt_OOle2Obj );
OOle2Obj(const uno::Reference<report::XReportComponent> & _xComponent,sal_uInt16 _nType)964cdf0e10cSrcweir OOle2Obj::OOle2Obj(const uno::Reference< report::XReportComponent>& _xComponent,sal_uInt16 _nType)
965cdf0e10cSrcweir :SdrOle2Obj()
966cdf0e10cSrcweir ,OObjectBase(_xComponent)
967cdf0e10cSrcweir ,m_nType(_nType)
968cdf0e10cSrcweir ,m_bOnlyOnce(true)
969cdf0e10cSrcweir {
970cdf0e10cSrcweir DBG_CTOR( rpt_OOle2Obj, NULL);
971cdf0e10cSrcweir
972cdf0e10cSrcweir impl_setUnoShape( uno::Reference< uno::XInterface >( _xComponent, uno::UNO_QUERY ) );
973cdf0e10cSrcweir m_bIsListening = sal_True;
974cdf0e10cSrcweir }
975cdf0e10cSrcweir //----------------------------------------------------------------------------
OOle2Obj(const::rtl::OUString & _sComponentName,sal_uInt16 _nType)976cdf0e10cSrcweir OOle2Obj::OOle2Obj(const ::rtl::OUString& _sComponentName,sal_uInt16 _nType)
977cdf0e10cSrcweir :SdrOle2Obj()
978cdf0e10cSrcweir ,OObjectBase(_sComponentName)
979cdf0e10cSrcweir ,m_nType(_nType)
980cdf0e10cSrcweir ,m_bOnlyOnce(true)
981cdf0e10cSrcweir {
982cdf0e10cSrcweir DBG_CTOR( rpt_OOle2Obj, NULL);
983cdf0e10cSrcweir m_bIsListening = sal_True;
984cdf0e10cSrcweir }
985cdf0e10cSrcweir //----------------------------------------------------------------------------
~OOle2Obj()986cdf0e10cSrcweir OOle2Obj::~OOle2Obj()
987cdf0e10cSrcweir {
988cdf0e10cSrcweir DBG_DTOR( rpt_OOle2Obj, NULL);
989cdf0e10cSrcweir }
990cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetObjIdentifier() const991cdf0e10cSrcweir sal_uInt16 OOle2Obj::GetObjIdentifier() const
992cdf0e10cSrcweir {
993cdf0e10cSrcweir return m_nType;
994cdf0e10cSrcweir }
995cdf0e10cSrcweir //----------------------------------------------------------------------------
GetObjInventor() const996cdf0e10cSrcweir sal_uInt32 OOle2Obj::GetObjInventor() const
997cdf0e10cSrcweir {
998cdf0e10cSrcweir return ReportInventor;
999cdf0e10cSrcweir }
1000cdf0e10cSrcweir //----------------------------------------------------------------------------
GetImplPage() const1001cdf0e10cSrcweir SdrPage* OOle2Obj::GetImplPage() const
1002cdf0e10cSrcweir {
1003cdf0e10cSrcweir DBG_CHKTHIS( rpt_OOle2Obj,NULL);
1004cdf0e10cSrcweir return GetPage();
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir //----------------------------------------------------------------------------
SetSnapRectImpl(const Rectangle & _rRect)1007cdf0e10cSrcweir void OOle2Obj::SetSnapRectImpl(const Rectangle& _rRect)
1008cdf0e10cSrcweir {
1009cdf0e10cSrcweir DBG_CHKTHIS( rpt_OOle2Obj,NULL);
1010cdf0e10cSrcweir SetSnapRect( _rRect );
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir //----------------------------------------------------------------------------
GetStep() const1013cdf0e10cSrcweir sal_Int32 OOle2Obj::GetStep() const
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir DBG_CHKTHIS( rpt_OOle2Obj,NULL);
1016cdf0e10cSrcweir // get step property
1017cdf0e10cSrcweir sal_Int32 nStep = 0;
1018cdf0e10cSrcweir OSL_ENSURE(0,"Who called me!");
1019cdf0e10cSrcweir return nStep;
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir //----------------------------------------------------------------------------
NbcMove(const Size & rSize)1023cdf0e10cSrcweir void OOle2Obj::NbcMove( const Size& rSize )
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir DBG_CHKTHIS( rpt_OOle2Obj,NULL);
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir if ( m_bIsListening )
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir // stop listening
1030cdf0e10cSrcweir OObjectBase::EndListening(sal_False);
1031cdf0e10cSrcweir
1032cdf0e10cSrcweir bool bPositionFixed = false;
1033cdf0e10cSrcweir Size aUndoSize(0,0);
1034cdf0e10cSrcweir bool bUndoMode = false;
1035cdf0e10cSrcweir if ( m_xReportComponent.is() )
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
1038cdf0e10cSrcweir if (pRptModel->GetUndoEnv().IsUndoMode())
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode
1041cdf0e10cSrcweir bUndoMode = true;
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point?
1046cdf0e10cSrcweir int nNewX = m_xReportComponent->getPositionX() + rSize.A();
1047cdf0e10cSrcweir // can this hinder us to set components outside the area?
1048cdf0e10cSrcweir // if (nNewX < 0)
1049cdf0e10cSrcweir // {
1050cdf0e10cSrcweir // nNewX = 0;
1051cdf0e10cSrcweir // }
1052cdf0e10cSrcweir m_xReportComponent->setPositionX(nNewX);
1053cdf0e10cSrcweir int nNewY = m_xReportComponent->getPositionY() + rSize.B();
1054cdf0e10cSrcweir if (nNewY < 0 && !bUndoMode)
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir aUndoSize.B() = abs(nNewY);
1057cdf0e10cSrcweir bPositionFixed = true;
1058cdf0e10cSrcweir nNewY = 0;
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir m_xReportComponent->setPositionY(nNewY);
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir if (bPositionFixed)
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize));
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir // set geometry properties
1067cdf0e10cSrcweir SetPropsFromRect(GetLogicRect());
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir // start listening
1070cdf0e10cSrcweir OObjectBase::StartListening();
1071cdf0e10cSrcweir }
1072cdf0e10cSrcweir else
1073cdf0e10cSrcweir SdrOle2Obj::NbcMove( rSize );
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir //----------------------------------------------------------------------------
1077cdf0e10cSrcweir
NbcResize(const Point & rRef,const Fraction & xFract,const Fraction & yFract)1078cdf0e10cSrcweir void OOle2Obj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
1079cdf0e10cSrcweir {
1080cdf0e10cSrcweir DBG_CHKTHIS( rpt_OOle2Obj,NULL);
1081cdf0e10cSrcweir SdrOle2Obj::NbcResize( rRef, xFract, yFract );
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir // stop listening
1084cdf0e10cSrcweir OObjectBase::EndListening(sal_False);
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir // set geometry properties
1087cdf0e10cSrcweir SetPropsFromRect(GetLogicRect());
1088cdf0e10cSrcweir
1089cdf0e10cSrcweir // start listening
1090cdf0e10cSrcweir OObjectBase::StartListening();
1091cdf0e10cSrcweir }
1092cdf0e10cSrcweir //----------------------------------------------------------------------------
NbcSetLogicRect(const Rectangle & rRect)1093cdf0e10cSrcweir void OOle2Obj::NbcSetLogicRect(const Rectangle& rRect)
1094cdf0e10cSrcweir {
1095cdf0e10cSrcweir SdrOle2Obj::NbcSetLogicRect(rRect);
1096cdf0e10cSrcweir // stop listening
1097cdf0e10cSrcweir OObjectBase::EndListening(sal_False);
1098cdf0e10cSrcweir
1099cdf0e10cSrcweir // set geometry properties
1100cdf0e10cSrcweir SetPropsFromRect(rRect);
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir // start listening
1103cdf0e10cSrcweir OObjectBase::StartListening();
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir //----------------------------------------------------------------------------
1106cdf0e10cSrcweir
EndCreate(SdrDragStat & rStat,SdrCreateCmd eCmd)1107cdf0e10cSrcweir FASTBOOL OOle2Obj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
1108cdf0e10cSrcweir {
1109cdf0e10cSrcweir DBG_CHKTHIS( rpt_OOle2Obj,NULL);
1110cdf0e10cSrcweir FASTBOOL bResult = SdrOle2Obj::EndCreate(rStat, eCmd);
1111cdf0e10cSrcweir if ( bResult )
1112cdf0e10cSrcweir {
1113cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
1114cdf0e10cSrcweir if ( pRptModel )
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
1117cdf0e10cSrcweir if ( !m_xReportComponent.is() )
1118cdf0e10cSrcweir m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY);
1119cdf0e10cSrcweir }
1120cdf0e10cSrcweir // set geometry properties
1121cdf0e10cSrcweir SetPropsFromRect(GetLogicRect());
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir
1124cdf0e10cSrcweir return bResult;
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir
getAwtComponent()1127cdf0e10cSrcweir uno::Reference< beans::XPropertySet> OOle2Obj::getAwtComponent()
1128cdf0e10cSrcweir {
1129cdf0e10cSrcweir return uno::Reference< beans::XPropertySet>(m_xReportComponent,uno::UNO_QUERY);
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir
1132cdf0e10cSrcweir // -----------------------------------------------------------------------------
getUnoShape()1133cdf0e10cSrcweir uno::Reference< uno::XInterface > OOle2Obj::getUnoShape()
1134cdf0e10cSrcweir {
1135cdf0e10cSrcweir uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this );
1136cdf0e10cSrcweir if ( !m_xReportComponent.is() )
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
1139cdf0e10cSrcweir OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
1140cdf0e10cSrcweir m_xReportComponent.set(xShape,uno::UNO_QUERY);
1141cdf0e10cSrcweir }
1142cdf0e10cSrcweir return xShape;
1143cdf0e10cSrcweir }
1144cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_getDataProvider(const uno::Reference<embed::XEmbeddedObject> & _xObj)1145cdf0e10cSrcweir uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider(const uno::Reference < embed::XEmbeddedObject >& _xObj)
1146cdf0e10cSrcweir {
1147cdf0e10cSrcweir uno::Reference< chart2::data::XDatabaseDataProvider > xSource;
1148cdf0e10cSrcweir uno::Reference< embed::XComponentSupplier > xCompSupp(_xObj,uno::UNO_QUERY);
1149cdf0e10cSrcweir if( xCompSupp.is())
1150cdf0e10cSrcweir {
1151cdf0e10cSrcweir uno::Reference< chart2::XChartDocument> xChartDoc( xCompSupp->getComponent(), uno::UNO_QUERY );
1152cdf0e10cSrcweir if ( xChartDoc.is() )
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir xSource.set(xChartDoc->getDataProvider(),uno::UNO_QUERY);
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir } // if( xCompSupp.is())
1157cdf0e10cSrcweir return xSource;
1158cdf0e10cSrcweir }
1159cdf0e10cSrcweir // -----------------------------------------------------------------------------
1160cdf0e10cSrcweir // Clone() soll eine komplette Kopie des Objektes erzeugen.
Clone() const1161cdf0e10cSrcweir SdrObject* OOle2Obj::Clone() const
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir OOle2Obj* pObj = static_cast<OOle2Obj*>(SdrOle2Obj::Clone());
1164cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
1165cdf0e10cSrcweir svt::EmbeddedObjectRef::TryRunningState( pObj->GetObjRef() );
1166cdf0e10cSrcweir pObj->impl_createDataProvider_nothrow(pRptModel->getReportDefinition().get());
1167cdf0e10cSrcweir
1168cdf0e10cSrcweir uno::Reference< chart2::data::XDatabaseDataProvider > xSource( lcl_getDataProvider(GetObjRef()) );
1169cdf0e10cSrcweir uno::Reference< chart2::data::XDatabaseDataProvider > xDest( lcl_getDataProvider(pObj->GetObjRef()) );
1170cdf0e10cSrcweir if ( xSource.is() && xDest.is() )
1171cdf0e10cSrcweir comphelper::copyProperties(xSource.get(),xDest.get());
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir pObj->initializeChart(pRptModel->getReportDefinition().get());
1174cdf0e10cSrcweir return pObj;
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_createDataProvider_nothrow(const uno::Reference<frame::XModel> & _xModel)1177cdf0e10cSrcweir void OOle2Obj::impl_createDataProvider_nothrow(const uno::Reference< frame::XModel>& _xModel)
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir try
1180cdf0e10cSrcweir {
1181cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef();
1182cdf0e10cSrcweir uno::Reference< chart2::data::XDataReceiver > xReceiver;
1183cdf0e10cSrcweir uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
1184cdf0e10cSrcweir if( xCompSupp.is())
1185cdf0e10cSrcweir xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
1186cdf0e10cSrcweir OSL_ASSERT( xReceiver.is());
1187cdf0e10cSrcweir if( xReceiver.is() )
1188cdf0e10cSrcweir {
1189cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory> xFac(_xModel,uno::UNO_QUERY);
1190cdf0e10cSrcweir uno::Reference< chart2::data::XDatabaseDataProvider > xDataProvider( xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider"))),uno::UNO_QUERY);
1191cdf0e10cSrcweir xReceiver->attachDataProvider( xDataProvider.get() );
1192cdf0e10cSrcweir } // if( xReceiver.is() )
1193cdf0e10cSrcweir }
1194cdf0e10cSrcweir catch(uno::Exception)
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir // -----------------------------------------------------------------------------
initializeOle()1199cdf0e10cSrcweir void OOle2Obj::initializeOle()
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir if ( m_bOnlyOnce )
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir m_bOnlyOnce = false;
1204cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef();
1205cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
1206cdf0e10cSrcweir pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj));
1207cdf0e10cSrcweir
1208cdf0e10cSrcweir uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
1209cdf0e10cSrcweir if( xCompSupp.is() )
1210cdf0e10cSrcweir {
1211cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xChartProps( xCompSupp->getComponent(), uno::UNO_QUERY );
1212cdf0e10cSrcweir if ( xChartProps.is() )
1213cdf0e10cSrcweir xChartProps->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NullDate")),uno::makeAny(util::DateTime(0,0,0,0,1,1,1900)));
1214cdf0e10cSrcweir }
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir // -----------------------------------------------------------------------------
initializeChart(const uno::Reference<frame::XModel> & _xModel)1218cdf0e10cSrcweir void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel)
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef();
1221cdf0e10cSrcweir uno::Reference< chart2::data::XDataReceiver > xReceiver;
1222cdf0e10cSrcweir uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
1223cdf0e10cSrcweir if( xCompSupp.is())
1224cdf0e10cSrcweir xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
1225cdf0e10cSrcweir OSL_ASSERT( xReceiver.is());
1226cdf0e10cSrcweir if( xReceiver.is() )
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir // lock the model to suppress any internal updates
1229cdf0e10cSrcweir uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY );
1230cdf0e10cSrcweir if( xChartModel.is() )
1231cdf0e10cSrcweir xChartModel->lockControllers();
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir if ( !lcl_getDataProvider(xObj).is() )
1234cdf0e10cSrcweir impl_createDataProvider_nothrow(_xModel);
1235cdf0e10cSrcweir
1236cdf0e10cSrcweir OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
1237cdf0e10cSrcweir pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj));
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir ::comphelper::NamedValueCollection aArgs;
1240cdf0e10cSrcweir aArgs.put( "CellRangeRepresentation", uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) );
1241cdf0e10cSrcweir aArgs.put( "HasCategories", uno::makeAny( sal_True ) );
1242cdf0e10cSrcweir aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
1243cdf0e10cSrcweir aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
1244cdf0e10cSrcweir xReceiver->setArguments( aArgs.getPropertyValues() );
1245cdf0e10cSrcweir
1246cdf0e10cSrcweir if( xChartModel.is() )
1247cdf0e10cSrcweir xChartModel->unlockControllers();
1248cdf0e10cSrcweir }
1249cdf0e10cSrcweir }
1250cdf0e10cSrcweir // -----------------------------------------------------------------------------
getUsedStyle(const uno::Reference<report::XReportDefinition> & _xReport)1251cdf0e10cSrcweir uno::Reference< style::XStyle> getUsedStyle(const uno::Reference< report::XReportDefinition>& _xReport)
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir uno::Reference<container::XNameAccess> xStyles = _xReport->getStyleFamilies();
1254cdf0e10cSrcweir uno::Reference<container::XNameAccess> xPageStyles(xStyles->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageStyles"))),uno::UNO_QUERY);
1255cdf0e10cSrcweir
1256cdf0e10cSrcweir uno::Reference< style::XStyle> xReturn;
1257cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq = xPageStyles->getElementNames();
1258cdf0e10cSrcweir const ::rtl::OUString* pIter = aSeq.getConstArray();
1259cdf0e10cSrcweir const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
1260cdf0e10cSrcweir for(;pIter != pEnd && !xReturn.is() ;++pIter)
1261cdf0e10cSrcweir {
1262cdf0e10cSrcweir uno::Reference< style::XStyle> xStyle(xPageStyles->getByName(*pIter),uno::UNO_QUERY);
1263cdf0e10cSrcweir if ( xStyle->isInUse() )
1264cdf0e10cSrcweir xReturn = xStyle;
1265cdf0e10cSrcweir }
1266cdf0e10cSrcweir return xReturn;
1267cdf0e10cSrcweir }
1268cdf0e10cSrcweir //----------------------------------------------------------------------------
1269cdf0e10cSrcweir //============================================================================
1270cdf0e10cSrcweir } // rptui
1271cdf0e10cSrcweir //============================================================================
1272