1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_basctl.hxx"
26
27
28 #include "propbrw.hxx"
29 #include "dlgedobj.hxx"
30
31 #include "basidesh.hxx"
32 #include <iderid.hxx>
33
34 #ifndef _BASCTL_DLGRESID_HRC
35 #include <dlgresid.hrc>
36 #endif
37 #include <tools/debug.hxx>
38 #include <tools/diagnose_ex.h>
39 #include <sfx2/bindings.hxx>
40 #include <sfx2/childwin.hxx>
41 #include <sfx2/objitem.hxx>
42
43 #ifndef _SVX_SVXIDS_HRC
44 #include <svx/svxids.hrc>
45 #endif
46 #include <tools/shl.hxx>
47 #include <vcl/stdtext.hxx>
48 #include <svx/svdview.hxx>
49 #include <svx/svdogrp.hxx>
50 #include <svx/svdpage.hxx>
51 #include <svx/svditer.hxx>
52 #include <sfx2/viewsh.hxx>
53
54 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
55 #include <toolkit/helper/vclunohelper.hxx>
56 #endif
57 #include <comphelper/property.hxx>
58 #include <comphelper/composedprops.hxx>
59 #include <comphelper/stl_types.hxx>
60 #include <comphelper/types.hxx>
61 #include <com/sun/star/beans/PropertyValue.hpp>
62 #include <com/sun/star/awt/PosSize.hpp>
63 #include <com/sun/star/lang/XServiceInfo.hpp>
64 #include <com/sun/star/inspection/XObjectInspector.hpp>
65 #include <comphelper/processfactory.hxx>
66 #include <cppuhelper/component_context.hxx>
67
68 #include <sfx2/dispatch.hxx>
69 #include <sfx2/viewfrm.hxx>
70
71 using namespace ::com::sun::star;
72 using namespace ::com::sun::star::uno;
73 using namespace ::com::sun::star::lang;
74 using namespace ::com::sun::star::frame;
75 using namespace ::com::sun::star::beans;
76 using namespace ::com::sun::star::container;
77 using namespace ::comphelper;
78
79 //============================================================================
80 // PropBrwMgr
81 //============================================================================
82
SFX_IMPL_FLOATINGWINDOW(PropBrwMgr,SID_SHOW_PROPERTYBROWSER)83 SFX_IMPL_FLOATINGWINDOW(PropBrwMgr, SID_SHOW_PROPERTYBROWSER)
84
85 //----------------------------------------------------------------------------
86
87 PropBrwMgr::PropBrwMgr( Window* _pParent, sal_uInt16 nId,
88 SfxBindings *pBindings, SfxChildWinInfo* pInfo)
89 :SfxChildWindow( _pParent, nId )
90 {
91 // set current selection
92 SfxViewShell* pShell = SfxViewShell::Current();
93 pWindow = new PropBrw(
94 ::comphelper::getProcessServiceFactory(),
95 pBindings,
96 this,
97 _pParent,
98 pShell ? pShell->GetCurrentDocument() : Reference< XModel >()
99 );
100
101 eChildAlignment = SFX_ALIGN_NOALIGNMENT;
102 ((SfxFloatingWindow*)pWindow)->Initialize( pInfo );
103
104 ((PropBrw*)pWindow)->Update( pShell );
105 }
106
107 //----------------------------------------------------------------------------
Update(const SfxViewShell * _pShell)108 void PropBrw::Update( const SfxViewShell* _pShell )
109 {
110 const BasicIDEShell* pBasicIDEShell = dynamic_cast< const BasicIDEShell* >( _pShell );
111 OSL_ENSURE( pBasicIDEShell || !_pShell, "PropBrw::Update: invalid shell!" );
112 if ( pBasicIDEShell )
113 {
114 ImplUpdate( pBasicIDEShell->GetCurrentDocument(), pBasicIDEShell->GetCurDlgView() );
115 }
116 else if ( _pShell )
117 {
118 ImplUpdate( NULL, _pShell->GetDrawView() );
119 }
120 else
121 {
122 ImplUpdate( NULL, NULL );
123 }
124 }
125
126 //----------------------------------------------------------------------------
127
128 const long STD_WIN_SIZE_X = 300;
129 const long STD_WIN_SIZE_Y = 350;
130
131 const long STD_MIN_SIZE_X = 250;
132 const long STD_MIN_SIZE_Y = 250;
133
134 const long STD_WIN_POS_X = 50;
135 const long STD_WIN_POS_Y = 50;
136 const long WIN_BORDER = 2;
137 const long MIN_WIN_SIZE_X = 50;
138 const long MIN_WIN_SIZE_Y = 50;
139
140 //----------------------------------------------------------------------------
141
142 //============================================================================
143 // PropBrw
144 //============================================================================
145
DBG_NAME(PropBrw)146 DBG_NAME(PropBrw)
147
148 //----------------------------------------------------------------------------
149
150 PropBrw::PropBrw( const Reference< XMultiServiceFactory >& _xORB, SfxBindings* _pBindings, PropBrwMgr* _pMgr, Window* _pParent,
151 const Reference< XModel >& _rxContextDocument )
152 :SfxFloatingWindow( _pBindings, _pMgr, _pParent, WinBits( WB_STDMODELESS | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE ) )
153 ,m_bInitialStateChange(sal_True)
154 ,m_xORB(_xORB)
155 ,m_xContextDocument( _rxContextDocument )
156 ,pView( NULL )
157 {
158 DBG_CTOR(PropBrw,NULL);
159
160 Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
161 SetMinOutputSizePixel(Size(STD_MIN_SIZE_X,STD_MIN_SIZE_Y));
162 SetOutputSizePixel(aPropWinSize);
163
164 try
165 {
166 // create a frame wrapper for myself
167 m_xMeAsFrame = Reference< XFrame >(m_xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Frame")), UNO_QUERY);
168 if (m_xMeAsFrame.is())
169 {
170 m_xMeAsFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
171 m_xMeAsFrame->setName(::rtl::OUString::createFromAscii("form property browser")); // change name!
172 }
173 }
174 catch (Exception&)
175 {
176 DBG_ERROR("PropBrw::PropBrw: could not create/initialize my frame!");
177 m_xMeAsFrame.clear();
178 }
179
180 ImplReCreateController();
181 }
182
183 //----------------------------------------------------------------------------
184
ImplReCreateController()185 void PropBrw::ImplReCreateController()
186 {
187 OSL_PRECOND( m_xMeAsFrame.is(), "PropBrw::ImplCreateController: no frame for myself!" );
188 if ( !m_xMeAsFrame.is() )
189 return;
190
191 if ( m_xBrowserController.is() )
192 ImplDestroyController();
193
194 try
195 {
196 Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW );
197 Reference< XComponentContext > xOwnContext(
198 xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
199 UNO_QUERY_THROW );
200
201 // a ComponentContext for the
202 ::cppu::ContextEntry_Init aHandlerContextInfo[] =
203 {
204 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface ( this ) ) ),
205 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( m_xContextDocument ) )
206 };
207 Reference< XComponentContext > xInspectorContext(
208 ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ),
209 xOwnContext ) );
210
211 // create a property browser controller
212 Reference< XMultiComponentFactory > xFactory( xInspectorContext->getServiceManager(), UNO_QUERY_THROW );
213 static const ::rtl::OUString s_sControllerServiceName = ::rtl::OUString::createFromAscii("com.sun.star.awt.PropertyBrowserController");
214 m_xBrowserController = Reference< XPropertySet >(
215 xFactory->createInstanceWithContext( s_sControllerServiceName, xInspectorContext ), UNO_QUERY
216 );
217 if ( !m_xBrowserController.is() )
218 {
219 ShowServiceNotAvailableError( GetParent(), s_sControllerServiceName, sal_True );
220 }
221 else
222 {
223 Reference< XController > xAsXController( m_xBrowserController, UNO_QUERY );
224 DBG_ASSERT(xAsXController.is(), "PropBrw::PropBrw: invalid controller object!");
225 if (!xAsXController.is())
226 {
227 ::comphelper::disposeComponent(m_xBrowserController);
228 m_xBrowserController.clear();
229 }
230 else
231 {
232 xAsXController->attachFrame(m_xMeAsFrame);
233 m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow();
234 DBG_ASSERT(m_xBrowserComponentWindow.is(), "PropBrw::PropBrw: attached the controller, but have no component window!");
235 }
236 }
237
238 Point aPropWinPos = Point( WIN_BORDER, WIN_BORDER );
239 Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
240 aPropWinSize.Width() -= (2*WIN_BORDER);
241 aPropWinSize.Height() -= (2*WIN_BORDER);
242
243 if ( m_xBrowserComponentWindow.is() )
244 {
245 m_xBrowserComponentWindow->setPosSize(aPropWinPos.X(), aPropWinPos.Y(), aPropWinSize.Width(), aPropWinSize.Height(),
246 ::com::sun::star::awt::PosSize::WIDTH | ::com::sun::star::awt::PosSize::HEIGHT |
247 ::com::sun::star::awt::PosSize::X | ::com::sun::star::awt::PosSize::Y);
248 m_xBrowserComponentWindow->setVisible(sal_True);
249 }
250 }
251 catch (Exception&)
252 {
253 DBG_ERROR("PropBrw::PropBrw: could not create/initialize the browser controller!");
254 try
255 {
256 ::comphelper::disposeComponent(m_xBrowserController);
257 ::comphelper::disposeComponent(m_xBrowserComponentWindow);
258 }
259 catch(Exception&)
260 {
261 }
262
263 m_xBrowserController.clear();
264 m_xBrowserComponentWindow.clear();
265 }
266
267 Resize();
268 }
269
270 //----------------------------------------------------------------------------
271
~PropBrw()272 PropBrw::~PropBrw()
273 {
274 if ( m_xBrowserController.is() )
275 ImplDestroyController();
276
277 DBG_DTOR(PropBrw,NULL);
278 }
279
280 //----------------------------------------------------------------------------
281
ImplDestroyController()282 void PropBrw::ImplDestroyController()
283 {
284 implSetNewObject( Reference< XPropertySet >() );
285
286 if ( m_xMeAsFrame.is() )
287 m_xMeAsFrame->setComponent( NULL, NULL );
288
289 Reference< XController > xAsXController( m_xBrowserController, UNO_QUERY );
290 if ( xAsXController.is() )
291 xAsXController->attachFrame( NULL );
292
293 try
294 {
295 ::comphelper::disposeComponent( m_xBrowserController );
296 }
297 catch( const Exception& )
298 {
299 DBG_UNHANDLED_EXCEPTION();
300 }
301
302 m_xBrowserController.clear();
303 }
304
305 //----------------------------------------------------------------------------
306
Close()307 sal_Bool PropBrw::Close()
308 {
309 ImplDestroyController();
310
311 if( IsRollUp() )
312 RollDown();
313
314 sal_Bool bClose = SfxFloatingWindow::Close();
315
316 return bClose;
317 }
318
319 //----------------------------------------------------------------------------
320 Sequence< Reference< XInterface > >
CreateMultiSelectionSequence(const SdrMarkList & _rMarkList)321 PropBrw::CreateMultiSelectionSequence( const SdrMarkList& _rMarkList )
322 {
323 Sequence< Reference< XInterface > > aSeq;
324 InterfaceArray aInterfaces;
325
326 sal_uInt32 nMarkCount = _rMarkList.GetMarkCount();
327 for( sal_uInt32 i = 0 ; i < nMarkCount ; i++ )
328 {
329 SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj();
330
331 SdrObjListIter* pGroupIterator = NULL;
332 if (pCurrent->IsGroupObject())
333 {
334 pGroupIterator = new SdrObjListIter(*pCurrent->GetSubList());
335 pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
336 }
337
338 while (pCurrent)
339 {
340 DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pCurrent);
341 if (pDlgEdObj)
342 {
343 Reference< XInterface > xControlInterface(pDlgEdObj->GetUnoControlModel(), UNO_QUERY);
344 if (xControlInterface.is())
345 aInterfaces.push_back(xControlInterface);
346 }
347
348 // next element
349 pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
350 }
351 if (pGroupIterator)
352 delete pGroupIterator;
353 }
354
355 sal_Int32 nCount = aInterfaces.size();
356 aSeq.realloc( nCount );
357 Reference< XInterface >* pInterfaces = aSeq.getArray();
358 for( sal_Int32 i = 0 ; i < nCount ; i++ )
359 pInterfaces[i] = aInterfaces[i];
360
361 return aSeq;
362 }
363
364 //----------------------------------------------------------------------------
implSetNewObjectSequence(const Sequence<Reference<XInterface>> & _rObjectSeq)365 void PropBrw::implSetNewObjectSequence
366 ( const Sequence< Reference< XInterface > >& _rObjectSeq )
367 {
368 Reference< inspection::XObjectInspector > xObjectInspector(m_xBrowserController, UNO_QUERY);
369 if ( xObjectInspector.is() )
370 {
371 xObjectInspector->inspect( _rObjectSeq );
372
373 ::rtl::OUString aText = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_PROPERTIES)));
374 aText += ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_MULTISELECT)));
375 SetText( aText );
376 }
377 }
378
379 //----------------------------------------------------------------------------
380
implSetNewObject(const Reference<XPropertySet> & _rxObject)381 void PropBrw::implSetNewObject( const Reference< XPropertySet >& _rxObject )
382 {
383 if ( m_xBrowserController.is() )
384 {
385 m_xBrowserController->setPropertyValue(
386 ::rtl::OUString::createFromAscii( "IntrospectedObject" ),
387 makeAny( _rxObject )
388 );
389
390 // set the new title according to the selected object
391 SetText( GetHeadlineName( _rxObject ) );
392 }
393 }
394
395 //----------------------------------------------------------------------------
396
GetHeadlineName(const Reference<XPropertySet> & _rxObject)397 ::rtl::OUString PropBrw::GetHeadlineName( const Reference< XPropertySet >& _rxObject )
398 {
399 ::rtl::OUString aName;
400 Reference< lang::XServiceInfo > xServiceInfo( _rxObject, UNO_QUERY );
401
402 if (xServiceInfo.is()) // single selection
403 {
404 sal_uInt16 nResId = 0;
405 aName = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_PROPERTIES)));
406
407 if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ) )
408 {
409 nResId = RID_STR_CLASS_DIALOG;
410 }
411 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ) )
412 {
413 nResId = RID_STR_CLASS_BUTTON;
414 }
415 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ) ) )
416 {
417 nResId = RID_STR_CLASS_RADIOBUTTON;
418 }
419 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ) ) )
420 {
421 nResId = RID_STR_CLASS_CHECKBOX;
422 }
423 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ) ) )
424 {
425 nResId = RID_STR_CLASS_LISTBOX;
426 }
427 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ) ) )
428 {
429 nResId = RID_STR_CLASS_COMBOBOX;
430 }
431 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" ) ) ) )
432 {
433 nResId = RID_STR_CLASS_GROUPBOX;
434 }
435 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ) )
436 {
437 nResId = RID_STR_CLASS_EDIT;
438 }
439 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ) ) )
440 {
441 nResId = RID_STR_CLASS_FIXEDTEXT;
442 }
443 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ) ) )
444 {
445 nResId = RID_STR_CLASS_IMAGECONTROL;
446 }
447 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" ) ) ) )
448 {
449 nResId = RID_STR_CLASS_PROGRESSBAR;
450 }
451 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" ) ) ) )
452 {
453 nResId = RID_STR_CLASS_SCROLLBAR;
454 }
455 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" ) ) ) )
456 {
457 nResId = RID_STR_CLASS_FIXEDLINE;
458 }
459 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDateFieldModel" ) ) ) )
460 {
461 nResId = RID_STR_CLASS_DATEFIELD;
462 }
463 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlTimeFieldModel" ) ) ) )
464 {
465 nResId = RID_STR_CLASS_TIMEFIELD;
466 }
467 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlNumericFieldModel" ) ) ) )
468 {
469 nResId = RID_STR_CLASS_NUMERICFIELD;
470 }
471 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCurrencyFieldModel" ) ) ) )
472 {
473 nResId = RID_STR_CLASS_CURRENCYFIELD;
474 }
475 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFormattedFieldModel" ) ) ) )
476 {
477 nResId = RID_STR_CLASS_FORMATTEDFIELD;
478 }
479 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlPatternFieldModel" ) ) ) )
480 {
481 nResId = RID_STR_CLASS_PATTERNFIELD;
482 }
483 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFileControlModel" ) ) ) )
484 {
485 nResId = RID_STR_CLASS_FILECONTROL;
486 }
487 else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.tree.TreeControlModel" ) ) ) )
488 {
489 nResId = RID_STR_CLASS_TREECONTROL;
490 }
491 else
492 {
493 nResId = RID_STR_CLASS_CONTROL;
494 }
495
496 if (nResId)
497 {
498 aName += ::rtl::OUString( String(IDEResId(nResId)) );
499 }
500 }
501 else if (!_rxObject.is()) // no properties
502 {
503 aName = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_NO_PROPERTIES)));
504 }
505 // #i73075 Handled in implSetNewObjectSequence
506 //else // multiselection
507 //{
508 // aName = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_PROPERTIES)));
509 // aName += ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_MULTISELECT)));
510 //}
511
512 return aName;
513 }
514
515 //----------------------------------------------------------------------------
516
FillInfo(SfxChildWinInfo & rInfo) const517 void PropBrw::FillInfo( SfxChildWinInfo& rInfo ) const
518 {
519 rInfo.bVisible = sal_False;
520 }
521
522 //----------------------------------------------------------------------------
523
Resize()524 void PropBrw::Resize()
525 {
526 SfxFloatingWindow::Resize();
527
528 // adjust size
529 Size aSize_ = GetOutputSizePixel();
530 Size aPropWinSize( aSize_ );
531 aPropWinSize.Width() -= (2*WIN_BORDER);
532 aPropWinSize.Height() -= (2*WIN_BORDER);
533
534 if (m_xBrowserComponentWindow.is())
535 {
536 m_xBrowserComponentWindow->setPosSize(0, 0, aPropWinSize.Width(), aPropWinSize.Height(),
537 ::com::sun::star::awt::PosSize::WIDTH | ::com::sun::star::awt::PosSize::HEIGHT);
538 }
539 }
540
541 //----------------------------------------------------------------------------
542
ImplUpdate(const Reference<XModel> & _rxContextDocument,SdrView * pNewView)543 void PropBrw::ImplUpdate( const Reference< XModel >& _rxContextDocument, SdrView* pNewView )
544 {
545 Reference< XModel > xContextDocument( _rxContextDocument );
546
547 // if we should simply "empty" ourself, assume the context document didn't change
548 if ( !pNewView )
549 {
550 OSL_ENSURE( !_rxContextDocument.is(), "PropBrw::ImplUpdate: no view, but a document?!" );
551 xContextDocument = m_xContextDocument;
552 }
553
554 if ( xContextDocument != m_xContextDocument )
555 {
556 m_xContextDocument = xContextDocument;
557 ImplReCreateController();
558 }
559
560 try
561 {
562 if ( pView )
563 {
564 EndListening( *(pView->GetModel()) );
565 pView = NULL;
566 }
567
568 if ( !pNewView )
569 return;
570
571 pView = pNewView;
572
573 // set focus on initialization
574 if ( m_bInitialStateChange )
575 {
576 if ( m_xBrowserComponentWindow.is() )
577 m_xBrowserComponentWindow->setFocus();
578 m_bInitialStateChange = sal_False;
579 }
580
581 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
582 sal_uInt32 nMarkCount = rMarkList.GetMarkCount();
583
584 if ( nMarkCount == 0 )
585 {
586 EndListening( *(pView->GetModel()) );
587 pView = NULL;
588 implSetNewObject( NULL );
589 return;
590 }
591
592 Reference< XPropertySet > xNewObject;
593 Sequence< Reference< XInterface > > aNewObjects;
594 if ( nMarkCount == 1 )
595 {
596 DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, rMarkList.GetMark(0)->GetMarkedSdrObj() );
597 if ( pDlgEdObj )
598 {
599 if ( pDlgEdObj->IsGroupObject() ) // group object
600 aNewObjects = CreateMultiSelectionSequence( rMarkList );
601 else // single selection
602 xNewObject = xNewObject.query( pDlgEdObj->GetUnoControlModel() );
603 }
604 }
605 else if ( nMarkCount > 1 ) // multiple selection
606 {
607 aNewObjects = CreateMultiSelectionSequence( rMarkList );
608 }
609
610 if ( aNewObjects.getLength() )
611 implSetNewObjectSequence( aNewObjects );
612 else
613 implSetNewObject( xNewObject );
614
615 StartListening( *(pView->GetModel()) );
616 }
617 catch ( const PropertyVetoException& ) { /* silence */ }
618 catch ( const Exception& )
619 {
620 DBG_UNHANDLED_EXCEPTION();
621 }
622 }
623
624 //----------------------------------------------------------------------------
625