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