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