xref: /aoo41x/main/basctl/source/dlged/dlgedobj.cxx (revision 0848378b)
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 #include <vector>
28cdf0e10cSrcweir #include <algorithm>
29cdf0e10cSrcweir #include <dlgeddef.hxx>
30cdf0e10cSrcweir #include "dlgedobj.hxx"
31cdf0e10cSrcweir #include "dlged.hxx"
32cdf0e10cSrcweir #include "dlgedmod.hxx"
33cdf0e10cSrcweir #include "dlgedpage.hxx"
34cdf0e10cSrcweir #include "dlgedview.hxx"
35cdf0e10cSrcweir #include "dlgedlist.hxx"
36cdf0e10cSrcweir #include <iderid.hxx>
37cdf0e10cSrcweir #include <localizationmgr.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #ifndef _BASCTL_DLGRESID_HRC
40cdf0e10cSrcweir #include <dlgresid.hrc>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <tools/resmgr.hxx>
43cdf0e10cSrcweir #include <tools/shl.hxx>
44cdf0e10cSrcweir #include <unotools/sharedunocomponent.hxx>
45cdf0e10cSrcweir #include <com/sun/star/awt/XTabControllerModel.hpp>
46cdf0e10cSrcweir #include <com/sun/star/awt/XUnoControlContainer.hpp>
47cdf0e10cSrcweir #include <com/sun/star/awt/XVclContainerPeer.hpp>
48cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
49cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
50cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
51cdf0e10cSrcweir #include <com/sun/star/script/XScriptEventsSupplier.hpp>
52cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp>
53cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
54cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
55cdf0e10cSrcweir #include <comphelper/types.hxx>
56cdf0e10cSrcweir #include <vcl/svapp.hxx>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #include <algorithm>
59cdf0e10cSrcweir #include <functional>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir using namespace ::com::sun::star;
62cdf0e10cSrcweir using namespace ::com::sun::star::uno;
63cdf0e10cSrcweir using namespace ::com::sun::star::beans;
64cdf0e10cSrcweir using namespace ::com::sun::star::container;
65cdf0e10cSrcweir using namespace ::com::sun::star::script;
66cdf0e10cSrcweir using ::rtl::OUString;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
69cdf0e10cSrcweir TYPEINIT1(DlgEdObj, SdrUnoObj);
70cdf0e10cSrcweir DBG_NAME(DlgEdObj);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir //----------------------------------------------------------------------------
73cdf0e10cSrcweir 
DlgEdObj()74cdf0e10cSrcweir DlgEdObj::DlgEdObj()
75cdf0e10cSrcweir 		  :SdrUnoObj(String(), sal_False)
76cdf0e10cSrcweir 		  ,bIsListening(sal_False)
77cdf0e10cSrcweir           ,pDlgEdForm( NULL )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	DBG_CTOR(DlgEdObj, NULL);
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir //----------------------------------------------------------------------------
83cdf0e10cSrcweir 
DlgEdObj(const::rtl::OUString & rModelName,const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> & rxSFac)84cdf0e10cSrcweir DlgEdObj::DlgEdObj(const ::rtl::OUString& rModelName,
85cdf0e10cSrcweir 				   const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac)
86cdf0e10cSrcweir 		  :SdrUnoObj(rModelName, rxSFac, sal_False)
87cdf0e10cSrcweir 		  ,bIsListening(sal_False)
88cdf0e10cSrcweir           ,pDlgEdForm( NULL )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	DBG_CTOR(DlgEdObj, NULL);
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir //----------------------------------------------------------------------------
94cdf0e10cSrcweir 
~DlgEdObj()95cdf0e10cSrcweir DlgEdObj::~DlgEdObj()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	DBG_DTOR(DlgEdObj, NULL);
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	if ( isListening() )
100cdf0e10cSrcweir 		EndListening();
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir //----------------------------------------------------------------------------
104cdf0e10cSrcweir 
SetPage(SdrPage * _pNewPage)105cdf0e10cSrcweir void DlgEdObj::SetPage(SdrPage* _pNewPage)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir 	// now set the page
108cdf0e10cSrcweir 	SdrUnoObj::SetPage(_pNewPage);
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir //----------------------------------------------------------------------------
112cdf0e10cSrcweir 
113cdf0e10cSrcweir namespace
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     /** returns the DlgEdForm which the given DlgEdObj belongs to
116cdf0e10cSrcweir         (which might in fact be the object itself)
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         Failure to obtain the form will be reported with an assertion in the non-product
119cdf0e10cSrcweir         version.
120cdf0e10cSrcweir      */
lcl_getDlgEdForm(DlgEdObj * _pObject,DlgEdForm * & _out_pDlgEdForm)121cdf0e10cSrcweir     bool lcl_getDlgEdForm( DlgEdObj* _pObject, DlgEdForm*& _out_pDlgEdForm )
122cdf0e10cSrcweir     {
123cdf0e10cSrcweir         _out_pDlgEdForm = dynamic_cast< DlgEdForm* >( _pObject );
124cdf0e10cSrcweir         if ( !_out_pDlgEdForm )
125cdf0e10cSrcweir             _out_pDlgEdForm = _pObject->GetDlgEdForm();
126cdf0e10cSrcweir         DBG_ASSERT( _out_pDlgEdForm, "lcl_getDlgEdForm: no form!" );
127cdf0e10cSrcweir         return ( _out_pDlgEdForm != NULL );
128cdf0e10cSrcweir     }
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir //----------------------------------------------------------------------------
132cdf0e10cSrcweir 
GetControl() const133cdf0e10cSrcweir uno::Reference< awt::XControl > DlgEdObj::GetControl() const
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     const DlgEdForm* pForm = GetDlgEdForm();
136cdf0e10cSrcweir     const DlgEditor* pEditor = pForm ? pForm->GetDlgEditor() : NULL;
137cdf0e10cSrcweir     SdrView* pView = pEditor ? pEditor->GetView() : NULL;
138cdf0e10cSrcweir     Window* pWindow = pEditor ? pEditor->GetWindow() : NULL;
139cdf0e10cSrcweir     OSL_ENSURE( ( pView && pWindow ) || !pForm, "DlgEdObj::GetControl: no view or no window!" );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     uno::Reference< awt::XControl > xControl;
142cdf0e10cSrcweir     if ( pView && pWindow )
143cdf0e10cSrcweir         xControl = GetUnoControl( *pView, *pWindow );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     return xControl;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir //----------------------------------------------------------------------------
149cdf0e10cSrcweir 
TransformSdrToControlCoordinates(sal_Int32 nXIn,sal_Int32 nYIn,sal_Int32 nWidthIn,sal_Int32 nHeightIn,sal_Int32 & nXOut,sal_Int32 & nYOut,sal_Int32 & nWidthOut,sal_Int32 & nHeightOut)150cdf0e10cSrcweir bool DlgEdObj::TransformSdrToControlCoordinates(
151cdf0e10cSrcweir     sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
152cdf0e10cSrcweir     sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     // input position and size
155cdf0e10cSrcweir     Size aPos( nXIn, nYIn );
156cdf0e10cSrcweir     Size aSize( nWidthIn, nHeightIn );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     // form position
159cdf0e10cSrcweir     DlgEdForm* pForm = NULL;
160cdf0e10cSrcweir     if ( !lcl_getDlgEdForm( this, pForm ) )
161cdf0e10cSrcweir         return false;
162cdf0e10cSrcweir     Rectangle aFormRect = pForm->GetSnapRect();
163cdf0e10cSrcweir     Size aFormPos( aFormRect.Left(), aFormRect.Top() );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     // convert 100th_mm to pixel
166cdf0e10cSrcweir     OutputDevice* pDevice = Application::GetDefaultDevice();
167cdf0e10cSrcweir     DBG_ASSERT( pDevice, "DlgEdObj::TransformSdrToControlCoordinates: missing default device!" );
168cdf0e10cSrcweir     if ( !pDevice )
169cdf0e10cSrcweir         return false;
170cdf0e10cSrcweir     aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_100TH_MM ) );
171cdf0e10cSrcweir     aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
172cdf0e10cSrcweir     aFormPos = pDevice->LogicToPixel( aFormPos, MapMode( MAP_100TH_MM ) );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     // subtract form position
175cdf0e10cSrcweir     aPos.Width() -= aFormPos.Width();
176cdf0e10cSrcweir     aPos.Height() -= aFormPos.Height();
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     // take window borders into account
179cdf0e10cSrcweir     Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
180cdf0e10cSrcweir     DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
181cdf0e10cSrcweir     if ( !xPSetForm.is() )
182cdf0e10cSrcweir         return false;
183cdf0e10cSrcweir 	bool bDecoration = true;
184cdf0e10cSrcweir     xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
185cdf0e10cSrcweir 	if( bDecoration )
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir 		awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
188cdf0e10cSrcweir 		aPos.Width() -= aDeviceInfo.LeftInset;
189cdf0e10cSrcweir 		aPos.Height() -= aDeviceInfo.TopInset;
190cdf0e10cSrcweir 	}
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     // convert pixel to logic units
193cdf0e10cSrcweir     aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) );
194cdf0e10cSrcweir     aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     // set out parameters
197cdf0e10cSrcweir     nXOut = aPos.Width();
198cdf0e10cSrcweir     nYOut = aPos.Height();
199cdf0e10cSrcweir     nWidthOut = aSize.Width();
200cdf0e10cSrcweir     nHeightOut = aSize.Height();
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     return true;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir //----------------------------------------------------------------------------
206cdf0e10cSrcweir 
TransformSdrToFormCoordinates(sal_Int32 nXIn,sal_Int32 nYIn,sal_Int32 nWidthIn,sal_Int32 nHeightIn,sal_Int32 & nXOut,sal_Int32 & nYOut,sal_Int32 & nWidthOut,sal_Int32 & nHeightOut)207cdf0e10cSrcweir bool DlgEdObj::TransformSdrToFormCoordinates(
208cdf0e10cSrcweir     sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
209cdf0e10cSrcweir     sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     // input position and size
212cdf0e10cSrcweir     Size aPos( nXIn, nYIn );
213cdf0e10cSrcweir     Size aSize( nWidthIn, nHeightIn );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     // convert 100th_mm to pixel
216cdf0e10cSrcweir     OutputDevice* pDevice = Application::GetDefaultDevice();
217cdf0e10cSrcweir     DBG_ASSERT( pDevice, "DlgEdObj::TransformSdrToFormCoordinates: missing default device!" );
218cdf0e10cSrcweir     if ( !pDevice )
219cdf0e10cSrcweir         return false;
220cdf0e10cSrcweir     aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_100TH_MM ) );
221cdf0e10cSrcweir     aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
222cdf0e10cSrcweir 
223cdf0e10cSrcweir     // take window borders into account
224cdf0e10cSrcweir     DlgEdForm* pForm = NULL;
225cdf0e10cSrcweir     if ( !lcl_getDlgEdForm( this, pForm ) )
226cdf0e10cSrcweir         return false;
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     // take window borders into account
229cdf0e10cSrcweir     Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
230cdf0e10cSrcweir     DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
231cdf0e10cSrcweir     if ( !xPSetForm.is() )
232cdf0e10cSrcweir         return false;
233cdf0e10cSrcweir 	bool bDecoration = true;
234cdf0e10cSrcweir     xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
235cdf0e10cSrcweir 	if( bDecoration )
236cdf0e10cSrcweir 	{
237cdf0e10cSrcweir 		awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
238cdf0e10cSrcweir 		aSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
239cdf0e10cSrcweir 		aSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
240cdf0e10cSrcweir 	}
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     // convert pixel to logic units
243cdf0e10cSrcweir     aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) );
244cdf0e10cSrcweir     aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) );
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     // set out parameters
247cdf0e10cSrcweir     nXOut = aPos.Width();
248cdf0e10cSrcweir     nYOut = aPos.Height();
249cdf0e10cSrcweir     nWidthOut = aSize.Width();
250cdf0e10cSrcweir     nHeightOut = aSize.Height();
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     return true;
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir //----------------------------------------------------------------------------
256cdf0e10cSrcweir 
TransformControlToSdrCoordinates(sal_Int32 nXIn,sal_Int32 nYIn,sal_Int32 nWidthIn,sal_Int32 nHeightIn,sal_Int32 & nXOut,sal_Int32 & nYOut,sal_Int32 & nWidthOut,sal_Int32 & nHeightOut)257cdf0e10cSrcweir bool DlgEdObj::TransformControlToSdrCoordinates(
258cdf0e10cSrcweir     sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
259cdf0e10cSrcweir     sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir     // input position and size
262cdf0e10cSrcweir     Size aPos( nXIn, nYIn );
263cdf0e10cSrcweir     Size aSize( nWidthIn, nHeightIn );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     // form position
266cdf0e10cSrcweir     DlgEdForm* pForm = NULL;
267cdf0e10cSrcweir     if ( !lcl_getDlgEdForm( this, pForm ) )
268cdf0e10cSrcweir         return false;
269cdf0e10cSrcweir 
270cdf0e10cSrcweir     Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
271cdf0e10cSrcweir     DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformControlToSdrCoordinates: no form property set!" );
272cdf0e10cSrcweir     if ( !xPSetForm.is() )
273cdf0e10cSrcweir         return false;
274cdf0e10cSrcweir     sal_Int32 nFormX = 0, nFormY = 0, nFormWidth, nFormHeight;
275cdf0e10cSrcweir     xPSetForm->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nFormX;
276cdf0e10cSrcweir     xPSetForm->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nFormY;
277cdf0e10cSrcweir     xPSetForm->getPropertyValue( DLGED_PROP_WIDTH ) >>= nFormWidth;
278cdf0e10cSrcweir     xPSetForm->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nFormHeight;
279cdf0e10cSrcweir     Size aFormPos( nFormX, nFormY );
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     // convert logic units to pixel
282cdf0e10cSrcweir     OutputDevice* pDevice = Application::GetDefaultDevice();
283cdf0e10cSrcweir     DBG_ASSERT( pDevice, "DlgEdObj::TransformControlToSdrCoordinates: missing default device!" );
284cdf0e10cSrcweir     if ( !pDevice )
285cdf0e10cSrcweir         return false;
286cdf0e10cSrcweir     aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) );
287cdf0e10cSrcweir     aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) );
288cdf0e10cSrcweir     aFormPos = pDevice->LogicToPixel( aFormPos, MapMode( MAP_APPFONT ) );
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     // add form position
291cdf0e10cSrcweir     aPos.Width() += aFormPos.Width();
292cdf0e10cSrcweir     aPos.Height() += aFormPos.Height();
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     // take window borders into account
295cdf0e10cSrcweir 	bool bDecoration = true;
296cdf0e10cSrcweir     xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
297cdf0e10cSrcweir 	if( bDecoration )
298cdf0e10cSrcweir 	{
299cdf0e10cSrcweir 		awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
300cdf0e10cSrcweir 		aPos.Width() += aDeviceInfo.LeftInset;
301cdf0e10cSrcweir 		aPos.Height() += aDeviceInfo.TopInset;
302cdf0e10cSrcweir 	}
303cdf0e10cSrcweir 
304cdf0e10cSrcweir     // convert pixel to 100th_mm
305cdf0e10cSrcweir     aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_100TH_MM ) );
306cdf0e10cSrcweir     aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_100TH_MM ) );
307cdf0e10cSrcweir 
308cdf0e10cSrcweir     // set out parameters
309cdf0e10cSrcweir     nXOut = aPos.Width();
310cdf0e10cSrcweir     nYOut = aPos.Height();
311cdf0e10cSrcweir     nWidthOut = aSize.Width();
312cdf0e10cSrcweir     nHeightOut = aSize.Height();
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     return true;
315cdf0e10cSrcweir }
316cdf0e10cSrcweir 
317cdf0e10cSrcweir //----------------------------------------------------------------------------
318cdf0e10cSrcweir 
TransformFormToSdrCoordinates(sal_Int32 nXIn,sal_Int32 nYIn,sal_Int32 nWidthIn,sal_Int32 nHeightIn,sal_Int32 & nXOut,sal_Int32 & nYOut,sal_Int32 & nWidthOut,sal_Int32 & nHeightOut)319cdf0e10cSrcweir bool DlgEdObj::TransformFormToSdrCoordinates(
320cdf0e10cSrcweir     sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
321cdf0e10cSrcweir     sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir     // input position and size
324cdf0e10cSrcweir     Size aPos( nXIn, nYIn );
325cdf0e10cSrcweir     Size aSize( nWidthIn, nHeightIn );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     // convert logic units to pixel
328cdf0e10cSrcweir     OutputDevice* pDevice = Application::GetDefaultDevice();
329cdf0e10cSrcweir     DBG_ASSERT( pDevice, "DlgEdObj::TransformFormToSdrCoordinates: missing default device!" );
330cdf0e10cSrcweir     if ( !pDevice )
331cdf0e10cSrcweir         return false;
332cdf0e10cSrcweir     aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) );
333cdf0e10cSrcweir     aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) );
334cdf0e10cSrcweir 
335cdf0e10cSrcweir     // take window borders into account
336cdf0e10cSrcweir     DlgEdForm* pForm = NULL;
337cdf0e10cSrcweir     if ( !lcl_getDlgEdForm( this, pForm ) )
338cdf0e10cSrcweir         return false;
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     // take window borders into account
341cdf0e10cSrcweir     Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
342cdf0e10cSrcweir     DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
343cdf0e10cSrcweir     if ( !xPSetForm.is() )
344cdf0e10cSrcweir         return false;
345cdf0e10cSrcweir 	bool bDecoration = true;
346cdf0e10cSrcweir     xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
347cdf0e10cSrcweir 	if( bDecoration )
348cdf0e10cSrcweir 	{
349cdf0e10cSrcweir 		awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
350cdf0e10cSrcweir 		aSize.Width() += aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
351cdf0e10cSrcweir 		aSize.Height() += aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
352cdf0e10cSrcweir 	}
353cdf0e10cSrcweir 
354cdf0e10cSrcweir     // convert pixel to 100th_mm
355cdf0e10cSrcweir     aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_100TH_MM ) );
356cdf0e10cSrcweir     aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_100TH_MM ) );
357cdf0e10cSrcweir 
358cdf0e10cSrcweir     // set out parameters
359cdf0e10cSrcweir     nXOut = aPos.Width();
360cdf0e10cSrcweir     nYOut = aPos.Height();
361cdf0e10cSrcweir     nWidthOut = aSize.Width();
362cdf0e10cSrcweir     nHeightOut = aSize.Height();
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     return true;
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir //----------------------------------------------------------------------------
368cdf0e10cSrcweir 
SetRectFromProps()369cdf0e10cSrcweir void DlgEdObj::SetRectFromProps()
370cdf0e10cSrcweir {
371cdf0e10cSrcweir     // get control position and size from properties
372cdf0e10cSrcweir     Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
373cdf0e10cSrcweir     if ( xPSet.is() )
374cdf0e10cSrcweir     {
375cdf0e10cSrcweir         sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
376cdf0e10cSrcweir         xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
377cdf0e10cSrcweir         xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
378cdf0e10cSrcweir         xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
379cdf0e10cSrcweir         xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir         // transform coordinates
382cdf0e10cSrcweir         sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
383cdf0e10cSrcweir         if ( TransformControlToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
384cdf0e10cSrcweir         {
385cdf0e10cSrcweir             // set rectangle position and size
386cdf0e10cSrcweir             Point aPoint( nXOut, nYOut );
387cdf0e10cSrcweir             Size aSize( nWidthOut, nHeightOut );
388cdf0e10cSrcweir             SetSnapRect( Rectangle( aPoint, aSize ) );
389cdf0e10cSrcweir         }
390cdf0e10cSrcweir     }
391cdf0e10cSrcweir }
392cdf0e10cSrcweir 
393cdf0e10cSrcweir //----------------------------------------------------------------------------
394cdf0e10cSrcweir 
SetPropsFromRect()395cdf0e10cSrcweir void DlgEdObj::SetPropsFromRect()
396cdf0e10cSrcweir {
397cdf0e10cSrcweir     // get control position and size from rectangle
398cdf0e10cSrcweir     Rectangle aRect_ = GetSnapRect();
399cdf0e10cSrcweir     sal_Int32 nXIn = aRect_.Left();
400cdf0e10cSrcweir     sal_Int32 nYIn = aRect_.Top();
401cdf0e10cSrcweir     sal_Int32 nWidthIn = aRect_.GetWidth();
402cdf0e10cSrcweir     sal_Int32 nHeightIn = aRect_.GetHeight();
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     // transform coordinates
405cdf0e10cSrcweir     sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
406cdf0e10cSrcweir     if ( TransformSdrToControlCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
407cdf0e10cSrcweir     {
408cdf0e10cSrcweir         // set properties
409cdf0e10cSrcweir         Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
410cdf0e10cSrcweir         if ( xPSet.is() )
411cdf0e10cSrcweir         {
412cdf0e10cSrcweir             Any aValue;
413cdf0e10cSrcweir             aValue <<= nXOut;
414cdf0e10cSrcweir             xPSet->setPropertyValue( DLGED_PROP_POSITIONX, aValue );
415cdf0e10cSrcweir             aValue <<= nYOut;
416cdf0e10cSrcweir             xPSet->setPropertyValue( DLGED_PROP_POSITIONY, aValue );
417cdf0e10cSrcweir             aValue <<= nWidthOut;
418cdf0e10cSrcweir             xPSet->setPropertyValue( DLGED_PROP_WIDTH, aValue );
419cdf0e10cSrcweir             aValue <<= nHeightOut;
420cdf0e10cSrcweir             xPSet->setPropertyValue( DLGED_PROP_HEIGHT, aValue );
421cdf0e10cSrcweir         }
422cdf0e10cSrcweir     }
423cdf0e10cSrcweir }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir //----------------------------------------------------------------------------
426cdf0e10cSrcweir 
PositionAndSizeChange(const beans::PropertyChangeEvent & evt)427cdf0e10cSrcweir void DlgEdObj::PositionAndSizeChange( const beans::PropertyChangeEvent& evt )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir     DlgEdPage* pPage_ = 0;
430cdf0e10cSrcweir     if ( pDlgEdForm )
431cdf0e10cSrcweir     {
432cdf0e10cSrcweir         DlgEditor* pEditor = pDlgEdForm->GetDlgEditor();
433cdf0e10cSrcweir         if ( pEditor )
434cdf0e10cSrcweir             pPage_ = pEditor->GetPage();
435cdf0e10cSrcweir     }
436cdf0e10cSrcweir     DBG_ASSERT( pPage_, "DlgEdObj::PositionAndSizeChange: no page!" );
437cdf0e10cSrcweir     if ( pPage_ )
438cdf0e10cSrcweir     {
439cdf0e10cSrcweir         sal_Int32 nPageXIn = 0;
440cdf0e10cSrcweir         sal_Int32 nPageYIn = 0;
441cdf0e10cSrcweir         Size aPageSize = pPage_->GetSize();
442cdf0e10cSrcweir         sal_Int32 nPageWidthIn = aPageSize.Width();
443cdf0e10cSrcweir         sal_Int32 nPageHeightIn = aPageSize.Height();
444cdf0e10cSrcweir         sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
445cdf0e10cSrcweir         if ( TransformSdrToControlCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
446cdf0e10cSrcweir         {
447cdf0e10cSrcweir             Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
448cdf0e10cSrcweir             if ( xPSet.is() )
449cdf0e10cSrcweir             {
450cdf0e10cSrcweir                 sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0;
451cdf0e10cSrcweir                 xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nX;
452cdf0e10cSrcweir                 xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nY;
453cdf0e10cSrcweir                 xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
454cdf0e10cSrcweir                 xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
455cdf0e10cSrcweir 
456cdf0e10cSrcweir                 sal_Int32 nValue = 0;
457cdf0e10cSrcweir                 evt.NewValue >>= nValue;
458cdf0e10cSrcweir                 sal_Int32 nNewValue = nValue;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir                 if ( evt.PropertyName == DLGED_PROP_POSITIONX )
461cdf0e10cSrcweir                 {
462cdf0e10cSrcweir                     if ( nNewValue + nWidth > nPageX + nPageWidth )
463cdf0e10cSrcweir                         nNewValue = nPageX + nPageWidth - nWidth;
464cdf0e10cSrcweir                     if ( nNewValue < nPageX )
465cdf0e10cSrcweir                         nNewValue = nPageX;
466cdf0e10cSrcweir                 }
467cdf0e10cSrcweir                 else if ( evt.PropertyName == DLGED_PROP_POSITIONY )
468cdf0e10cSrcweir                 {
469cdf0e10cSrcweir                     if ( nNewValue + nHeight > nPageY + nPageHeight )
470cdf0e10cSrcweir                         nNewValue = nPageY + nPageHeight - nHeight;
471cdf0e10cSrcweir                     if ( nNewValue < nPageY )
472cdf0e10cSrcweir                         nNewValue = nPageY;
473cdf0e10cSrcweir                 }
474cdf0e10cSrcweir                 else if ( evt.PropertyName == DLGED_PROP_WIDTH )
475cdf0e10cSrcweir                 {
476cdf0e10cSrcweir                     if ( nX + nNewValue > nPageX + nPageWidth )
477cdf0e10cSrcweir                         nNewValue = nPageX + nPageWidth - nX;
478cdf0e10cSrcweir                     if ( nNewValue < 1 )
479cdf0e10cSrcweir                         nNewValue = 1;
480cdf0e10cSrcweir                 }
481cdf0e10cSrcweir                 else if ( evt.PropertyName == DLGED_PROP_HEIGHT )
482cdf0e10cSrcweir                 {
483cdf0e10cSrcweir                     if ( nY + nNewValue > nPageY + nPageHeight )
484cdf0e10cSrcweir                         nNewValue = nPageY + nPageHeight - nY;
485cdf0e10cSrcweir                     if ( nNewValue < 1 )
486cdf0e10cSrcweir                         nNewValue = 1;
487cdf0e10cSrcweir                 }
488cdf0e10cSrcweir 
489cdf0e10cSrcweir                 if ( nNewValue != nValue )
490cdf0e10cSrcweir                 {
491cdf0e10cSrcweir                     Any aNewValue;
492cdf0e10cSrcweir                     aNewValue <<= nNewValue;
493cdf0e10cSrcweir                     EndListening( sal_False );
494cdf0e10cSrcweir                     xPSet->setPropertyValue( evt.PropertyName, aNewValue );
495cdf0e10cSrcweir                     StartListening();
496cdf0e10cSrcweir                 }
497cdf0e10cSrcweir             }
498cdf0e10cSrcweir         }
499cdf0e10cSrcweir     }
500cdf0e10cSrcweir 
501cdf0e10cSrcweir     SetRectFromProps();
502cdf0e10cSrcweir }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir //----------------------------------------------------------------------------
505cdf0e10cSrcweir 
NameChange(const::com::sun::star::beans::PropertyChangeEvent & evt)506cdf0e10cSrcweir void SAL_CALL DlgEdObj::NameChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
507cdf0e10cSrcweir {
508cdf0e10cSrcweir 	// get old name
509cdf0e10cSrcweir 	::rtl::OUString aOldName;
510cdf0e10cSrcweir 	evt.OldValue >>= aOldName;
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 	// get new name
513cdf0e10cSrcweir 	::rtl::OUString aNewName;
514cdf0e10cSrcweir 	evt.NewValue >>= aNewName;
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 	if ( !aNewName.equals(aOldName) )
517cdf0e10cSrcweir 	{
518cdf0e10cSrcweir 		Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), UNO_QUERY);
519cdf0e10cSrcweir 		if ( xNameAcc.is() && xNameAcc->hasByName(aOldName) )
520cdf0e10cSrcweir 		{
521*0848378bSHerbert Dürr 			if ( !xNameAcc->hasByName(aNewName) && !aNewName.isEmpty() )
522cdf0e10cSrcweir 			{
523cdf0e10cSrcweir 				// remove the control by the old name and insert the control by the new name in the container
524cdf0e10cSrcweir 				Reference< container::XNameContainer > xCont(xNameAcc, UNO_QUERY );
525cdf0e10cSrcweir 				if ( xCont.is() )
526cdf0e10cSrcweir 				{
527cdf0e10cSrcweir 					Reference< awt::XControlModel > xCtrl(GetUnoControlModel(), UNO_QUERY);
528cdf0e10cSrcweir 					Any aAny;
529cdf0e10cSrcweir 					aAny <<= xCtrl;
530cdf0e10cSrcweir 					xCont->removeByName( aOldName );
531cdf0e10cSrcweir 					xCont->insertByName( aNewName , aAny );
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 					DlgEditor* pEditor;
534cdf0e10cSrcweir 					if ( ISA(DlgEdForm) )
535cdf0e10cSrcweir 						pEditor = ((DlgEdForm*)this)->GetDlgEditor();
536cdf0e10cSrcweir 					else
537cdf0e10cSrcweir 						pEditor = GetDlgEdForm()->GetDlgEditor();
538cdf0e10cSrcweir 					LocalizationMgr::renameControlResourceIDsForEditorObject( pEditor, aAny, aNewName );
539cdf0e10cSrcweir 				}
540cdf0e10cSrcweir 			}
541cdf0e10cSrcweir 			else
542cdf0e10cSrcweir 			{
543cdf0e10cSrcweir 				// set old name property
544cdf0e10cSrcweir 				EndListening(sal_False);
545cdf0e10cSrcweir 				Reference< beans::XPropertySet >  xPSet(GetUnoControlModel(), UNO_QUERY);
546cdf0e10cSrcweir 				Any aName;
547cdf0e10cSrcweir 				aName <<= aOldName;
548cdf0e10cSrcweir 				xPSet->setPropertyValue( DLGED_PROP_NAME, aName );
549cdf0e10cSrcweir 				StartListening();
550cdf0e10cSrcweir 			}
551cdf0e10cSrcweir 		}
552cdf0e10cSrcweir 	}
553cdf0e10cSrcweir }
554cdf0e10cSrcweir 
555cdf0e10cSrcweir //----------------------------------------------------------------------------
556cdf0e10cSrcweir 
GetStep() const557cdf0e10cSrcweir sal_Int32 DlgEdObj::GetStep() const
558cdf0e10cSrcweir {
559cdf0e10cSrcweir 	// get step property
560cdf0e10cSrcweir 	sal_Int32 nStep = 0;
561cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet >  xPSet( GetUnoControlModel(), uno::UNO_QUERY );
562cdf0e10cSrcweir 	if (xPSet.is())
563cdf0e10cSrcweir 	{
564cdf0e10cSrcweir 		xPSet->getPropertyValue( DLGED_PROP_STEP ) >>= nStep;
565cdf0e10cSrcweir 	}
566cdf0e10cSrcweir 	return nStep;
567cdf0e10cSrcweir }
568cdf0e10cSrcweir 
569cdf0e10cSrcweir //----------------------------------------------------------------------------
570cdf0e10cSrcweir 
UpdateStep()571cdf0e10cSrcweir void DlgEdObj::UpdateStep()
572cdf0e10cSrcweir {
573cdf0e10cSrcweir 	sal_Int32 nCurStep = GetDlgEdForm()->GetStep();
574cdf0e10cSrcweir 	sal_Int32 nStep = GetStep();
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 	SdrLayerAdmin& rLayerAdmin = GetModel()->GetLayerAdmin();
577cdf0e10cSrcweir 	SdrLayerID nHiddenLayerId   = rLayerAdmin.GetLayerID( String( RTL_CONSTASCII_USTRINGPARAM( "HiddenLayer" ) ), sal_False );
578cdf0e10cSrcweir 	SdrLayerID nControlLayerId   = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName(), sal_False );
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 	if( nCurStep )
581cdf0e10cSrcweir 	{
582cdf0e10cSrcweir 		if ( nStep && (nStep != nCurStep) )
583cdf0e10cSrcweir 		{
584cdf0e10cSrcweir 			SetLayer( nHiddenLayerId );
585cdf0e10cSrcweir 		}
586cdf0e10cSrcweir 		else
587cdf0e10cSrcweir 		{
588cdf0e10cSrcweir 			SetLayer( nControlLayerId );
589cdf0e10cSrcweir 		}
590cdf0e10cSrcweir 	}
591cdf0e10cSrcweir 	else
592cdf0e10cSrcweir 	{
593cdf0e10cSrcweir 		SetLayer( nControlLayerId );
594cdf0e10cSrcweir 	}
595cdf0e10cSrcweir }
596cdf0e10cSrcweir 
597cdf0e10cSrcweir //----------------------------------------------------------------------------
598cdf0e10cSrcweir 
TabIndexChange(const beans::PropertyChangeEvent & evt)599cdf0e10cSrcweir void DlgEdObj::TabIndexChange( const beans::PropertyChangeEvent& evt ) throw (RuntimeException)
600cdf0e10cSrcweir {
601cdf0e10cSrcweir     DlgEdForm* pForm = GetDlgEdForm();
602cdf0e10cSrcweir     if ( pForm )
603cdf0e10cSrcweir     {
604cdf0e10cSrcweir 	    // stop listening with all children
605cdf0e10cSrcweir 	    ::std::vector<DlgEdObj*> aChildList = pForm->GetChilds();
606cdf0e10cSrcweir 	    ::std::vector<DlgEdObj*>::iterator aIter;
607cdf0e10cSrcweir 	    for ( aIter = aChildList.begin() ; aIter != aChildList.end() ; ++aIter )
608cdf0e10cSrcweir 	    {
609cdf0e10cSrcweir 		    (*aIter)->EndListening( sal_False );
610cdf0e10cSrcweir 	    }
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 	    Reference< container::XNameAccess > xNameAcc( pForm->GetUnoControlModel() , UNO_QUERY );
613cdf0e10cSrcweir 	    if ( xNameAcc.is() )
614cdf0e10cSrcweir 	    {
615cdf0e10cSrcweir 		    // get sequence of control names
616cdf0e10cSrcweir 		    Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
617cdf0e10cSrcweir 		    const ::rtl::OUString* pNames = aNames.getConstArray();
618cdf0e10cSrcweir 		    sal_Int32 nCtrls = aNames.getLength();
619cdf0e10cSrcweir 		    sal_Int16 i;
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 		    // create a map of tab indices and control names, sorted by tab index
622cdf0e10cSrcweir 		    IndexToNameMap aIndexToNameMap;
623cdf0e10cSrcweir 		    for ( i = 0; i < nCtrls; ++i )
624cdf0e10cSrcweir 		    {
625cdf0e10cSrcweir 			    // get control name
626cdf0e10cSrcweir 			    ::rtl::OUString aName( pNames[i] );
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 			    // get tab index
629cdf0e10cSrcweir 			    sal_Int16 nTabIndex = -1;
630cdf0e10cSrcweir 			    Any aCtrl = xNameAcc->getByName( aName );
631cdf0e10cSrcweir 			    Reference< beans::XPropertySet > xPSet;
632cdf0e10cSrcweir    			    aCtrl >>= xPSet;
633cdf0e10cSrcweir 			    if ( xPSet.is() && xPSet == Reference< beans::XPropertySet >( evt.Source, UNO_QUERY ) )
634cdf0e10cSrcweir 				    evt.OldValue >>= nTabIndex;
635cdf0e10cSrcweir 			    else if ( xPSet.is() )
636cdf0e10cSrcweir 				    xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 			    // insert into map
639cdf0e10cSrcweir 			    aIndexToNameMap.insert( IndexToNameMap::value_type( nTabIndex, aName ) );
640cdf0e10cSrcweir 		    }
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 		    // create a helper list of control names, sorted by tab index
643cdf0e10cSrcweir 		    ::std::vector< ::rtl::OUString > aNameList( aIndexToNameMap.size() );
644cdf0e10cSrcweir 		    ::std::transform(
645cdf0e10cSrcweir 				    aIndexToNameMap.begin(), aIndexToNameMap.end(),
646cdf0e10cSrcweir 				    aNameList.begin(),
647cdf0e10cSrcweir 				    ::std::select2nd< IndexToNameMap::value_type >( )
648cdf0e10cSrcweir 			    );
649cdf0e10cSrcweir 
650cdf0e10cSrcweir 		    // check tab index
651cdf0e10cSrcweir 		    sal_Int16 nOldTabIndex = 0;
652cdf0e10cSrcweir 		    evt.OldValue >>= nOldTabIndex;
653cdf0e10cSrcweir 		    sal_Int16 nNewTabIndex = 0;
654cdf0e10cSrcweir 		    evt.NewValue >>= nNewTabIndex;
655cdf0e10cSrcweir 		    if ( nNewTabIndex < 0 )
656cdf0e10cSrcweir 			    nNewTabIndex = 0;
657cdf0e10cSrcweir 		    else if ( nNewTabIndex > nCtrls - 1 )
658cdf0e10cSrcweir 			    nNewTabIndex = sal::static_int_cast<sal_Int16>( nCtrls - 1 );
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 		    // reorder helper list
661cdf0e10cSrcweir 		    ::rtl::OUString aCtrlName = aNameList[nOldTabIndex];
662cdf0e10cSrcweir 		    aNameList.erase( aNameList.begin() + nOldTabIndex );
663cdf0e10cSrcweir 		    aNameList.insert( aNameList.begin() + nNewTabIndex , aCtrlName );
664cdf0e10cSrcweir 
665cdf0e10cSrcweir 		    // set new tab indices
666cdf0e10cSrcweir 		    for ( i = 0; i < nCtrls; ++i )
667cdf0e10cSrcweir 		    {
668cdf0e10cSrcweir 			    Any aCtrl = xNameAcc->getByName( aNameList[i] );
669cdf0e10cSrcweir 			    Reference< beans::XPropertySet > xPSet;
670cdf0e10cSrcweir    			    aCtrl >>= xPSet;
671cdf0e10cSrcweir 			    if ( xPSet.is() )
672cdf0e10cSrcweir 			    {
673cdf0e10cSrcweir 				    Any aTabIndex;
674cdf0e10cSrcweir 				    aTabIndex <<= (sal_Int16) i;
675cdf0e10cSrcweir 				    xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
676cdf0e10cSrcweir 			    }
677cdf0e10cSrcweir 		    }
678cdf0e10cSrcweir 
679cdf0e10cSrcweir 		    // reorder objects in drawing page
680cdf0e10cSrcweir 		    GetModel()->GetPage(0)->SetObjectOrdNum( nOldTabIndex + 1, nNewTabIndex + 1 );
681cdf0e10cSrcweir 
682cdf0e10cSrcweir             // #110559#
683cdf0e10cSrcweir             pForm->UpdateTabOrderAndGroups();
684cdf0e10cSrcweir 	    }
685cdf0e10cSrcweir 
686cdf0e10cSrcweir 	    // start listening with all children
687cdf0e10cSrcweir 	    for ( aIter = aChildList.begin() ; aIter != aChildList.end() ; ++aIter )
688cdf0e10cSrcweir 	    {
689cdf0e10cSrcweir 		    (*aIter)->StartListening();
690cdf0e10cSrcweir 	    }
691cdf0e10cSrcweir     }
692cdf0e10cSrcweir }
693cdf0e10cSrcweir 
694cdf0e10cSrcweir //----------------------------------------------------------------------------
695cdf0e10cSrcweir 
supportsService(const sal_Char * _pServiceName) const696cdf0e10cSrcweir sal_Bool DlgEdObj::supportsService( const sal_Char* _pServiceName ) const
697cdf0e10cSrcweir {
698cdf0e10cSrcweir 	sal_Bool bSupports = sal_False;
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 	Reference< lang::XServiceInfo > xServiceInfo( GetUnoControlModel() , UNO_QUERY );
701cdf0e10cSrcweir 		// TODO: cache xServiceInfo as member?
702cdf0e10cSrcweir 	if ( xServiceInfo.is() )
703cdf0e10cSrcweir 		bSupports = xServiceInfo->supportsService( ::rtl::OUString::createFromAscii( _pServiceName ) );
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 	return bSupports;
706cdf0e10cSrcweir }
707cdf0e10cSrcweir 
708cdf0e10cSrcweir //----------------------------------------------------------------------------
709cdf0e10cSrcweir 
GetDefaultName() const710cdf0e10cSrcweir ::rtl::OUString DlgEdObj::GetDefaultName() const
711cdf0e10cSrcweir {
712cdf0e10cSrcweir 	sal_uInt16 nResId = 0;
713cdf0e10cSrcweir 	::rtl::OUString aDefaultName;
714cdf0e10cSrcweir 	if ( supportsService( "com.sun.star.awt.UnoControlDialogModel" ) )
715cdf0e10cSrcweir 	{
716cdf0e10cSrcweir 		nResId = RID_STR_CLASS_DIALOG;
717cdf0e10cSrcweir 	}
718cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ) )
719cdf0e10cSrcweir 	{
720cdf0e10cSrcweir 		nResId = RID_STR_CLASS_BUTTON;
721cdf0e10cSrcweir 	}
722cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) )
723cdf0e10cSrcweir 	{
724cdf0e10cSrcweir 		nResId = RID_STR_CLASS_RADIOBUTTON;
725cdf0e10cSrcweir 	}
726cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ) )
727cdf0e10cSrcweir 	{
728cdf0e10cSrcweir 		nResId = RID_STR_CLASS_CHECKBOX;
729cdf0e10cSrcweir 	}
730cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlListBoxModel" ) )
731cdf0e10cSrcweir 	{
732cdf0e10cSrcweir 		nResId = RID_STR_CLASS_LISTBOX;
733cdf0e10cSrcweir 	}
734cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlComboBoxModel" ) )
735cdf0e10cSrcweir 	{
736cdf0e10cSrcweir 		nResId = RID_STR_CLASS_COMBOBOX;
737cdf0e10cSrcweir 	}
738cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ) )
739cdf0e10cSrcweir 	{
740cdf0e10cSrcweir 		nResId = RID_STR_CLASS_GROUPBOX;
741cdf0e10cSrcweir 	}
742cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlEditModel" ) )
743cdf0e10cSrcweir 	{
744cdf0e10cSrcweir 		nResId = RID_STR_CLASS_EDIT;
745cdf0e10cSrcweir 	}
746cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
747cdf0e10cSrcweir 	{
748cdf0e10cSrcweir 		nResId = RID_STR_CLASS_FIXEDTEXT;
749cdf0e10cSrcweir 	}
750cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlImageControlModel" ) )
751cdf0e10cSrcweir 	{
752cdf0e10cSrcweir 		nResId = RID_STR_CLASS_IMAGECONTROL;
753cdf0e10cSrcweir 	}
754cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlProgressBarModel" ) )
755cdf0e10cSrcweir 	{
756cdf0e10cSrcweir 		nResId = RID_STR_CLASS_PROGRESSBAR;
757cdf0e10cSrcweir 	}
758cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlScrollBarModel" ) )
759cdf0e10cSrcweir 	{
760cdf0e10cSrcweir 		nResId = RID_STR_CLASS_SCROLLBAR;
761cdf0e10cSrcweir 	}
762cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlFixedLineModel" ) )
763cdf0e10cSrcweir 	{
764cdf0e10cSrcweir 		nResId = RID_STR_CLASS_FIXEDLINE;
765cdf0e10cSrcweir 	}
766cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlDateFieldModel" ) )
767cdf0e10cSrcweir 	{
768cdf0e10cSrcweir 		nResId = RID_STR_CLASS_DATEFIELD;
769cdf0e10cSrcweir 	}
770cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlTimeFieldModel" ) )
771cdf0e10cSrcweir 	{
772cdf0e10cSrcweir 		nResId = RID_STR_CLASS_TIMEFIELD;
773cdf0e10cSrcweir 	}
774cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlNumericFieldModel" ) )
775cdf0e10cSrcweir 	{
776cdf0e10cSrcweir 		nResId = RID_STR_CLASS_NUMERICFIELD;
777cdf0e10cSrcweir 	}
778cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlCurrencyFieldModel" ) )
779cdf0e10cSrcweir 	{
780cdf0e10cSrcweir 		nResId = RID_STR_CLASS_CURRENCYFIELD;
781cdf0e10cSrcweir 	}
782cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ) )
783cdf0e10cSrcweir 	{
784cdf0e10cSrcweir 		nResId = RID_STR_CLASS_FORMATTEDFIELD;
785cdf0e10cSrcweir 	}
786cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlPatternFieldModel" ) )
787cdf0e10cSrcweir 	{
788cdf0e10cSrcweir 		nResId = RID_STR_CLASS_PATTERNFIELD;
789cdf0e10cSrcweir 	}
790cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.UnoControlFileControlModel" ) )
791cdf0e10cSrcweir 	{
792cdf0e10cSrcweir 		nResId = RID_STR_CLASS_FILECONTROL;
793cdf0e10cSrcweir 	}
794cdf0e10cSrcweir     else if ( supportsService( "com.sun.star.awt.tree.TreeControlModel" ) )
795cdf0e10cSrcweir 	{
796cdf0e10cSrcweir 		nResId = RID_STR_CLASS_TREECONTROL;
797cdf0e10cSrcweir 	}
798cdf0e10cSrcweir 
799cdf0e10cSrcweir     else
800cdf0e10cSrcweir     {
801cdf0e10cSrcweir 		nResId = RID_STR_CLASS_CONTROL;
802cdf0e10cSrcweir     }
803cdf0e10cSrcweir 
804cdf0e10cSrcweir 	if (nResId)
805cdf0e10cSrcweir 	{
806cdf0e10cSrcweir 		aDefaultName = ::rtl::OUString( String(IDEResId(nResId)) );
807cdf0e10cSrcweir 	}
808cdf0e10cSrcweir 
809cdf0e10cSrcweir 	return aDefaultName;
810cdf0e10cSrcweir }
811cdf0e10cSrcweir 
812cdf0e10cSrcweir //----------------------------------------------------------------------------
813cdf0e10cSrcweir 
GetUniqueName() const814cdf0e10cSrcweir ::rtl::OUString DlgEdObj::GetUniqueName() const
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	::rtl::OUString aUniqueName;
817cdf0e10cSrcweir 	uno::Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), uno::UNO_QUERY);
818cdf0e10cSrcweir 
819cdf0e10cSrcweir 	if ( xNameAcc.is() )
820cdf0e10cSrcweir 	{
821cdf0e10cSrcweir 		sal_Int32 n = 0;
822cdf0e10cSrcweir 		::rtl::OUString aDefaultName = GetDefaultName();
823cdf0e10cSrcweir 
824cdf0e10cSrcweir 		do
825cdf0e10cSrcweir 		{
826cdf0e10cSrcweir 			aUniqueName = aDefaultName + ::rtl::OUString::valueOf(++n);
827cdf0e10cSrcweir 		}	while (xNameAcc->hasByName(aUniqueName));
828cdf0e10cSrcweir 	}
829cdf0e10cSrcweir 
830cdf0e10cSrcweir 	return aUniqueName;
831cdf0e10cSrcweir }
832cdf0e10cSrcweir 
833cdf0e10cSrcweir //----------------------------------------------------------------------------
834cdf0e10cSrcweir 
GetObjInventor() const835cdf0e10cSrcweir sal_uInt32 DlgEdObj::GetObjInventor()   const
836cdf0e10cSrcweir {
837cdf0e10cSrcweir 	return DlgInventor;
838cdf0e10cSrcweir }
839cdf0e10cSrcweir 
840cdf0e10cSrcweir //----------------------------------------------------------------------------
841cdf0e10cSrcweir 
GetObjIdentifier() const842cdf0e10cSrcweir sal_uInt16 DlgEdObj::GetObjIdentifier() const
843cdf0e10cSrcweir {
844cdf0e10cSrcweir 	if ( supportsService( "com.sun.star.awt.UnoControlDialogModel" ))
845cdf0e10cSrcweir 	{
846cdf0e10cSrcweir 		return OBJ_DLG_DIALOG;
847cdf0e10cSrcweir 	}
848cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ))
849cdf0e10cSrcweir 	{
850cdf0e10cSrcweir 		return OBJ_DLG_PUSHBUTTON;
851cdf0e10cSrcweir 	}
852cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ))
853cdf0e10cSrcweir 	{
854cdf0e10cSrcweir 		return OBJ_DLG_RADIOBUTTON;
855cdf0e10cSrcweir 	}
856cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ))
857cdf0e10cSrcweir 	{
858cdf0e10cSrcweir 		return OBJ_DLG_CHECKBOX;
859cdf0e10cSrcweir 	}
860cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlListBoxModel" ))
861cdf0e10cSrcweir 	{
862cdf0e10cSrcweir 		return OBJ_DLG_LISTBOX;
863cdf0e10cSrcweir 	}
864cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlComboBoxModel" ))
865cdf0e10cSrcweir 	{
866cdf0e10cSrcweir 		return OBJ_DLG_COMBOBOX;
867cdf0e10cSrcweir 	}
868cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ))
869cdf0e10cSrcweir 	{
870cdf0e10cSrcweir 		return OBJ_DLG_GROUPBOX;
871cdf0e10cSrcweir 	}
872cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlEditModel" ))
873cdf0e10cSrcweir 	{
874cdf0e10cSrcweir 		return OBJ_DLG_EDIT;
875cdf0e10cSrcweir 	}
876cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ))
877cdf0e10cSrcweir 	{
878cdf0e10cSrcweir 		return OBJ_DLG_FIXEDTEXT;
879cdf0e10cSrcweir 	}
880cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlImageControlModel" ))
881cdf0e10cSrcweir 	{
882cdf0e10cSrcweir 		return OBJ_DLG_IMAGECONTROL;
883cdf0e10cSrcweir 	}
884cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlProgressBarModel" ))
885cdf0e10cSrcweir 	{
886cdf0e10cSrcweir 		return OBJ_DLG_PROGRESSBAR;
887cdf0e10cSrcweir 	}
888cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlScrollBarModel" ))
889cdf0e10cSrcweir 	{
890cdf0e10cSrcweir 		return OBJ_DLG_HSCROLLBAR;
891cdf0e10cSrcweir 	}
892cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlFixedLineModel" ))
893cdf0e10cSrcweir 	{
894cdf0e10cSrcweir 		return OBJ_DLG_HFIXEDLINE;
895cdf0e10cSrcweir 	}
896cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlDateFieldModel" ))
897cdf0e10cSrcweir 	{
898cdf0e10cSrcweir 		return OBJ_DLG_DATEFIELD;
899cdf0e10cSrcweir 	}
900cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlTimeFieldModel" ))
901cdf0e10cSrcweir 	{
902cdf0e10cSrcweir 		return OBJ_DLG_TIMEFIELD;
903cdf0e10cSrcweir 	}
904cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlNumericFieldModel" ))
905cdf0e10cSrcweir 	{
906cdf0e10cSrcweir 		return OBJ_DLG_NUMERICFIELD;
907cdf0e10cSrcweir 	}
908cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlCurrencyFieldModel" ))
909cdf0e10cSrcweir 	{
910cdf0e10cSrcweir 		return OBJ_DLG_CURRENCYFIELD;
911cdf0e10cSrcweir 	}
912cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ))
913cdf0e10cSrcweir 	{
914cdf0e10cSrcweir 		return OBJ_DLG_FORMATTEDFIELD;
915cdf0e10cSrcweir 	}
916cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlPatternFieldModel" ))
917cdf0e10cSrcweir 	{
918cdf0e10cSrcweir 		return OBJ_DLG_PATTERNFIELD;
919cdf0e10cSrcweir 	}
920cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.UnoControlFileControlModel" ))
921cdf0e10cSrcweir 	{
922cdf0e10cSrcweir 		return OBJ_DLG_FILECONTROL;
923cdf0e10cSrcweir 	}
924cdf0e10cSrcweir 	else if ( supportsService( "com.sun.star.awt.tree.TreeControlModel" ))
925cdf0e10cSrcweir 	{
926cdf0e10cSrcweir 		return OBJ_DLG_TREECONTROL;
927cdf0e10cSrcweir 	}
928cdf0e10cSrcweir     else
929cdf0e10cSrcweir 	{
930cdf0e10cSrcweir 		return OBJ_DLG_CONTROL;
931cdf0e10cSrcweir 	}
932cdf0e10cSrcweir }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir //----------------------------------------------------------------------------
935cdf0e10cSrcweir 
clonedFrom(const DlgEdObj * _pSource)936cdf0e10cSrcweir void DlgEdObj::clonedFrom(const DlgEdObj* _pSource)
937cdf0e10cSrcweir {
938cdf0e10cSrcweir 	// set parent form
939cdf0e10cSrcweir 	pDlgEdForm = _pSource->pDlgEdForm;
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 	// add child to parent form
942cdf0e10cSrcweir 	pDlgEdForm->AddChild( this );
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 	Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
945cdf0e10cSrcweir 	if ( xPSet.is() )
946cdf0e10cSrcweir 	{
947cdf0e10cSrcweir 		// set new name
948cdf0e10cSrcweir 		::rtl::OUString aOUniqueName( GetUniqueName() );
949cdf0e10cSrcweir 		Any aUniqueName;
950cdf0e10cSrcweir 		aUniqueName <<= aOUniqueName;
951cdf0e10cSrcweir 		xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName );
952cdf0e10cSrcweir 
953cdf0e10cSrcweir 		Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
954cdf0e10cSrcweir 		if ( xCont.is() )
955cdf0e10cSrcweir 		{
956cdf0e10cSrcweir 			// set tabindex
957cdf0e10cSrcweir    			Sequence< OUString > aNames = xCont->getElementNames();
958cdf0e10cSrcweir 			Any aTabIndex;
959cdf0e10cSrcweir 			aTabIndex <<= (sal_Int16) aNames.getLength();
960cdf0e10cSrcweir 			xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
961cdf0e10cSrcweir 
962cdf0e10cSrcweir 			// insert control model in dialog model
963cdf0e10cSrcweir 			Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY );
964cdf0e10cSrcweir 			Any aCtrl;
965cdf0e10cSrcweir 			aCtrl <<= xCtrl;
966cdf0e10cSrcweir 			xCont->insertByName( aOUniqueName , aCtrl );
967cdf0e10cSrcweir 
968cdf0e10cSrcweir             // #110559#
969cdf0e10cSrcweir             pDlgEdForm->UpdateTabOrderAndGroups();
970cdf0e10cSrcweir 		}
971cdf0e10cSrcweir 	}
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 	// start listening
974cdf0e10cSrcweir 	StartListening();
975cdf0e10cSrcweir }
976cdf0e10cSrcweir 
977cdf0e10cSrcweir //----------------------------------------------------------------------------
978cdf0e10cSrcweir 
Clone() const979cdf0e10cSrcweir SdrObject* DlgEdObj::Clone() const
980cdf0e10cSrcweir {
981cdf0e10cSrcweir 	SdrObject* pReturn = SdrUnoObj::Clone();
982cdf0e10cSrcweir 
983cdf0e10cSrcweir 	DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pReturn);
984cdf0e10cSrcweir 	DBG_ASSERT( pDlgEdObj != NULL, "DlgEdObj::Clone: invalid clone!" );
985cdf0e10cSrcweir 	if ( pDlgEdObj )
986cdf0e10cSrcweir 		pDlgEdObj->clonedFrom( this );
987cdf0e10cSrcweir 
988cdf0e10cSrcweir 	return pReturn;
989cdf0e10cSrcweir }
990cdf0e10cSrcweir 
991cdf0e10cSrcweir //----------------------------------------------------------------------------
992cdf0e10cSrcweir 
getFullDragClone() const993cdf0e10cSrcweir SdrObject* DlgEdObj::getFullDragClone() const
994cdf0e10cSrcweir {
995cdf0e10cSrcweir 	// no need to really add the clone for dragging, it's a temporary
996cdf0e10cSrcweir     // object
997cdf0e10cSrcweir     SdrObject* pObj = new SdrUnoObj(String());
998cdf0e10cSrcweir     *pObj = *((const SdrUnoObj*)this);
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir     return pObj;
1001cdf0e10cSrcweir }
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir //----------------------------------------------------------------------------
1004cdf0e10cSrcweir 
operator =(const SdrObject & rObj)1005cdf0e10cSrcweir void DlgEdObj::operator= (const SdrObject& rObj)
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir 	SdrUnoObj::operator= (rObj);
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir //----------------------------------------------------------------------------
1011cdf0e10cSrcweir 
NbcMove(const Size & rSize)1012cdf0e10cSrcweir void DlgEdObj::NbcMove( const Size& rSize )
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir 	SdrUnoObj::NbcMove( rSize );
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir 	// stop listening
1017cdf0e10cSrcweir 	EndListening(sal_False);
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir 	// set geometry properties
1020cdf0e10cSrcweir 	SetPropsFromRect();
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir 	// start listening
1023cdf0e10cSrcweir 	StartListening();
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir 	// dialog model changed
1026cdf0e10cSrcweir 	GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir //----------------------------------------------------------------------------
1030cdf0e10cSrcweir 
NbcResize(const Point & rRef,const Fraction & xFract,const Fraction & yFract)1031cdf0e10cSrcweir void DlgEdObj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir 	SdrUnoObj::NbcResize( rRef, xFract, yFract );
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir 	// stop listening
1036cdf0e10cSrcweir 	EndListening(sal_False);
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir 	// set geometry properties
1039cdf0e10cSrcweir 	SetPropsFromRect();
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 	// start listening
1042cdf0e10cSrcweir 	StartListening();
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 	// dialog model changed
1045cdf0e10cSrcweir 	GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir //----------------------------------------------------------------------------
1049cdf0e10cSrcweir 
EndCreate(SdrDragStat & rStat,SdrCreateCmd eCmd)1050cdf0e10cSrcweir FASTBOOL DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir 	FASTBOOL bResult = SdrUnoObj::EndCreate(rStat, eCmd);
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir 	SetDefaults();
1055cdf0e10cSrcweir 	StartListening();
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 	return bResult;
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir //----------------------------------------------------------------------------
1061cdf0e10cSrcweir 
SetDefaults()1062cdf0e10cSrcweir void DlgEdObj::SetDefaults()
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir 	// set parent form
1065cdf0e10cSrcweir 	pDlgEdForm = ((DlgEdPage*)GetPage())->GetDlgEdForm();
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir     if ( pDlgEdForm )
1068cdf0e10cSrcweir     {
1069cdf0e10cSrcweir 	    // add child to parent form
1070cdf0e10cSrcweir 	    pDlgEdForm->AddChild( this );
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir 	    Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
1073cdf0e10cSrcweir 	    if ( xPSet.is() )
1074cdf0e10cSrcweir 	    {
1075cdf0e10cSrcweir 		    // get unique name
1076cdf0e10cSrcweir 		    ::rtl::OUString aOUniqueName( GetUniqueName() );
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 		    // set name property
1079cdf0e10cSrcweir 		    Any aUniqueName;
1080cdf0e10cSrcweir 		    aUniqueName <<= aOUniqueName;
1081cdf0e10cSrcweir 		    xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName );
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir 		    // set labels
1084cdf0e10cSrcweir 		    if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ) ||
1085cdf0e10cSrcweir 			    supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) ||
1086cdf0e10cSrcweir 			    supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ) ||
1087cdf0e10cSrcweir 			    supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ) ||
1088cdf0e10cSrcweir 			    supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
1089cdf0e10cSrcweir 		    {
1090cdf0e10cSrcweir 			    xPSet->setPropertyValue( DLGED_PROP_LABEL, aUniqueName );
1091cdf0e10cSrcweir 		    }
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir 		    // set number formats supplier for formatted field
1094cdf0e10cSrcweir 		    if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ) )
1095cdf0e10cSrcweir 		    {
1096cdf0e10cSrcweir 			    Reference< util::XNumberFormatsSupplier > xSupplier = GetDlgEdForm()->GetDlgEditor()->GetNumberFormatsSupplier();
1097cdf0e10cSrcweir 			    if ( xSupplier.is() )
1098cdf0e10cSrcweir 			    {
1099cdf0e10cSrcweir 				    Any aSupplier;
1100cdf0e10cSrcweir 				    aSupplier <<= xSupplier;
1101cdf0e10cSrcweir 				    xPSet->setPropertyValue( DLGED_PROP_FORMATSSUPPLIER, aSupplier );
1102cdf0e10cSrcweir 			    }
1103cdf0e10cSrcweir 		    }
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir 		    // set geometry properties
1106cdf0e10cSrcweir 		    SetPropsFromRect();
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir 		    Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
1109cdf0e10cSrcweir 		    if ( xCont.is() )
1110cdf0e10cSrcweir 		    {
1111cdf0e10cSrcweir 			    // set tabindex
1112cdf0e10cSrcweir    			    Sequence< OUString > aNames = xCont->getElementNames();
1113cdf0e10cSrcweir 			    uno::Any aTabIndex;
1114cdf0e10cSrcweir 			    aTabIndex <<= (sal_Int16) aNames.getLength();
1115cdf0e10cSrcweir 			    xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 			    // set step
1118cdf0e10cSrcweir 			    Reference< beans::XPropertySet > xPSetForm( xCont, UNO_QUERY );
1119cdf0e10cSrcweir 			    if ( xPSetForm.is() )
1120cdf0e10cSrcweir 			    {
1121cdf0e10cSrcweir 				    Any aStep = xPSetForm->getPropertyValue( DLGED_PROP_STEP );
1122cdf0e10cSrcweir 				    xPSet->setPropertyValue( DLGED_PROP_STEP, aStep );
1123cdf0e10cSrcweir 			    }
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir 			    // insert control model in dialog model
1126cdf0e10cSrcweir 			    Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY );
1127cdf0e10cSrcweir 			    Any aAny;
1128cdf0e10cSrcweir 			    aAny <<= xCtrl;
1129cdf0e10cSrcweir 			    xCont->insertByName( aOUniqueName , aAny );
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir 				DlgEditor* pEditor;
1132cdf0e10cSrcweir 				if ( ISA(DlgEdForm) )
1133cdf0e10cSrcweir 					pEditor = ((DlgEdForm*)this)->GetDlgEditor();
1134cdf0e10cSrcweir 				else
1135cdf0e10cSrcweir 					pEditor = GetDlgEdForm()->GetDlgEditor();
1136cdf0e10cSrcweir 				LocalizationMgr::setControlResourceIDsForNewEditorObject( pEditor, aAny, aOUniqueName );
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir                 // #110559#
1139cdf0e10cSrcweir                 pDlgEdForm->UpdateTabOrderAndGroups();
1140cdf0e10cSrcweir 		    }
1141cdf0e10cSrcweir 	    }
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 	    // dialog model changed
1144cdf0e10cSrcweir 	    pDlgEdForm->GetDlgEditor()->SetDialogModelChanged( sal_True );
1145cdf0e10cSrcweir     }
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir //----------------------------------------------------------------------------
1149cdf0e10cSrcweir 
IMPL_LINK(DlgEdObj,OnCreate,void *,EMPTYTAG)1150cdf0e10cSrcweir IMPL_LINK(DlgEdObj, OnCreate, void*, EMPTYTAG)
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir 	(void)EMPTYTAG;
1153cdf0e10cSrcweir 	/*
1154cdf0e10cSrcweir 	if (pTempView)
1155cdf0e10cSrcweir 		pTempView->ObjectCreated(this);
1156cdf0e10cSrcweir 	*/
1157cdf0e10cSrcweir 	return 0;
1158cdf0e10cSrcweir }
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir //----------------------------------------------------------------------------
1161cdf0e10cSrcweir 
StartListening()1162cdf0e10cSrcweir void DlgEdObj::StartListening()
1163cdf0e10cSrcweir {
1164cdf0e10cSrcweir 	DBG_ASSERT(!isListening(), "DlgEdObj::StartListening: already listening!");
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir 	if (!isListening())
1167cdf0e10cSrcweir 	{
1168cdf0e10cSrcweir 		bIsListening = sal_True;
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir 		// XPropertyChangeListener
1171cdf0e10cSrcweir 		Reference< XPropertySet > xControlModel( GetUnoControlModel() , UNO_QUERY );
1172cdf0e10cSrcweir 		if (!m_xPropertyChangeListener.is() && xControlModel.is())
1173cdf0e10cSrcweir 		{
1174cdf0e10cSrcweir 			// create listener
1175cdf0e10cSrcweir 			m_xPropertyChangeListener = static_cast< ::com::sun::star::beans::XPropertyChangeListener*>( new DlgEdPropListenerImpl( (DlgEdObj*)this ) );
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir 			// register listener to properties
1178cdf0e10cSrcweir 			xControlModel->addPropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener );
1179cdf0e10cSrcweir 		}
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 		// XContainerListener
1182cdf0e10cSrcweir 		Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
1183cdf0e10cSrcweir 		if( !m_xContainerListener.is() && xEventsSupplier.is() )
1184cdf0e10cSrcweir 		{
1185cdf0e10cSrcweir 			// create listener
1186cdf0e10cSrcweir 			m_xContainerListener = static_cast< ::com::sun::star::container::XContainerListener*>( new DlgEdEvtContListenerImpl( (DlgEdObj*)this ) );
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir 			// register listener to script event container
1189cdf0e10cSrcweir 			Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
1190cdf0e10cSrcweir 			DBG_ASSERT(xEventCont.is(), "DlgEdObj::StartListening: control model has no script event container!");
1191cdf0e10cSrcweir 			Reference< XContainer > xCont( xEventCont , UNO_QUERY );
1192cdf0e10cSrcweir 			if (xCont.is())
1193cdf0e10cSrcweir 				xCont->addContainerListener( m_xContainerListener );
1194cdf0e10cSrcweir 		}
1195cdf0e10cSrcweir 	}
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir //----------------------------------------------------------------------------
1199cdf0e10cSrcweir 
EndListening(sal_Bool bRemoveListener)1200cdf0e10cSrcweir void DlgEdObj::EndListening(sal_Bool bRemoveListener)
1201cdf0e10cSrcweir {
1202cdf0e10cSrcweir 	DBG_ASSERT(isListening(), "DlgEdObj::EndListening: not listening currently!");
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 	if (isListening())
1205cdf0e10cSrcweir 	{
1206cdf0e10cSrcweir 		bIsListening = sal_False;
1207cdf0e10cSrcweir 
1208cdf0e10cSrcweir 		if (bRemoveListener)
1209cdf0e10cSrcweir 		{
1210cdf0e10cSrcweir 			// XPropertyChangeListener
1211cdf0e10cSrcweir 			Reference< XPropertySet > xControlModel(GetUnoControlModel(), UNO_QUERY);
1212cdf0e10cSrcweir 			if ( m_xPropertyChangeListener.is() && xControlModel.is() )
1213cdf0e10cSrcweir 			{
1214cdf0e10cSrcweir 				// remove listener
1215cdf0e10cSrcweir 				xControlModel->removePropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener );
1216cdf0e10cSrcweir 			}
1217cdf0e10cSrcweir 			m_xPropertyChangeListener.clear();
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir 			// XContainerListener
1220cdf0e10cSrcweir 			Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
1221cdf0e10cSrcweir 			if( m_xContainerListener.is() && xEventsSupplier.is() )
1222cdf0e10cSrcweir 			{
1223cdf0e10cSrcweir 				// remove listener
1224cdf0e10cSrcweir 				Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
1225cdf0e10cSrcweir 				DBG_ASSERT(xEventCont.is(), "DlgEdObj::EndListening: control model has no script event container!");
1226cdf0e10cSrcweir 				Reference< XContainer > xCont( xEventCont , UNO_QUERY );
1227cdf0e10cSrcweir 				if (xCont.is())
1228cdf0e10cSrcweir 					xCont->removeContainerListener( m_xContainerListener );
1229cdf0e10cSrcweir 			}
1230cdf0e10cSrcweir 			m_xContainerListener.clear();
1231cdf0e10cSrcweir 		}
1232cdf0e10cSrcweir 	}
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir //----------------------------------------------------------------------------
1236cdf0e10cSrcweir 
_propertyChange(const::com::sun::star::beans::PropertyChangeEvent & evt)1237cdf0e10cSrcweir void SAL_CALL DlgEdObj::_propertyChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir 	if (isListening())
1240cdf0e10cSrcweir 	{
1241cdf0e10cSrcweir 		DlgEdForm* pRealDlgEdForm = dynamic_cast< DlgEdForm* >(this);
1242cdf0e10cSrcweir 		if( pRealDlgEdForm == 0 )
1243cdf0e10cSrcweir 			pRealDlgEdForm = GetDlgEdForm();
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir 		DlgEditor* pDlgEditor = pRealDlgEdForm ? pRealDlgEdForm->GetDlgEditor() : 0;
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir 		if( !pDlgEditor || pDlgEditor->isInPaint() )
1248cdf0e10cSrcweir 			return;
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir 		// dialog model changed
1251cdf0e10cSrcweir 		pDlgEditor->SetDialogModelChanged(sal_True);
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir         // update position and size
1254cdf0e10cSrcweir         if ( evt.PropertyName == DLGED_PROP_POSITIONX || evt.PropertyName == DLGED_PROP_POSITIONY ||
1255cdf0e10cSrcweir              evt.PropertyName == DLGED_PROP_WIDTH || evt.PropertyName == DLGED_PROP_HEIGHT ||
1256cdf0e10cSrcweir 			 evt.PropertyName == DLGED_PROP_DECORATION )
1257cdf0e10cSrcweir         {
1258cdf0e10cSrcweir             PositionAndSizeChange( evt );
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir 			if ( evt.PropertyName == DLGED_PROP_DECORATION )
1261cdf0e10cSrcweir 			{
1262cdf0e10cSrcweir 				if ( ISA(DlgEdForm) )
1263cdf0e10cSrcweir 					((DlgEdForm*)this)->GetDlgEditor()->ResetDialog();
1264cdf0e10cSrcweir 				else
1265cdf0e10cSrcweir 					GetDlgEdForm()->GetDlgEditor()->ResetDialog();
1266cdf0e10cSrcweir 			}
1267cdf0e10cSrcweir 		}
1268cdf0e10cSrcweir 		// change name of control in dialog model
1269cdf0e10cSrcweir 		else if ( evt.PropertyName == DLGED_PROP_NAME )
1270cdf0e10cSrcweir 		{
1271cdf0e10cSrcweir 			if ( !ISA(DlgEdForm) )
1272cdf0e10cSrcweir 			{
1273cdf0e10cSrcweir 				NameChange(evt);
1274cdf0e10cSrcweir 			}
1275cdf0e10cSrcweir 		}
1276cdf0e10cSrcweir 		// update step
1277cdf0e10cSrcweir 		else if ( evt.PropertyName == DLGED_PROP_STEP )
1278cdf0e10cSrcweir 		{
1279cdf0e10cSrcweir 			UpdateStep();
1280cdf0e10cSrcweir 		}
1281cdf0e10cSrcweir 		// change tabindex
1282cdf0e10cSrcweir 		else if ( evt.PropertyName == DLGED_PROP_TABINDEX )
1283cdf0e10cSrcweir 		{
1284cdf0e10cSrcweir 			if ( !ISA(DlgEdForm) )
1285cdf0e10cSrcweir 			{
1286cdf0e10cSrcweir 				TabIndexChange(evt);
1287cdf0e10cSrcweir 			}
1288cdf0e10cSrcweir 		}
1289cdf0e10cSrcweir 	}
1290cdf0e10cSrcweir }
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir //----------------------------------------------------------------------------
1293cdf0e10cSrcweir 
_elementInserted(const::com::sun::star::container::ContainerEvent &)1294cdf0e10cSrcweir void SAL_CALL DlgEdObj::_elementInserted(const ::com::sun::star::container::ContainerEvent& ) throw(::com::sun::star::uno::RuntimeException)
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir 	if (isListening())
1297cdf0e10cSrcweir 	{
1298cdf0e10cSrcweir 		// dialog model changed
1299cdf0e10cSrcweir 		if ( ISA(DlgEdForm) )
1300cdf0e10cSrcweir 		{
1301cdf0e10cSrcweir 			((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(sal_True);
1302cdf0e10cSrcweir 		}
1303cdf0e10cSrcweir 		else
1304cdf0e10cSrcweir 		{
1305cdf0e10cSrcweir 			GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
1306cdf0e10cSrcweir 		}
1307cdf0e10cSrcweir 	}
1308cdf0e10cSrcweir }
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir //----------------------------------------------------------------------------
1311cdf0e10cSrcweir 
_elementReplaced(const::com::sun::star::container::ContainerEvent &)1312cdf0e10cSrcweir void SAL_CALL DlgEdObj::_elementReplaced(const ::com::sun::star::container::ContainerEvent& ) throw(::com::sun::star::uno::RuntimeException)
1313cdf0e10cSrcweir {
1314cdf0e10cSrcweir 	if (isListening())
1315cdf0e10cSrcweir 	{
1316cdf0e10cSrcweir 		// dialog model changed
1317cdf0e10cSrcweir 		if ( ISA(DlgEdForm) )
1318cdf0e10cSrcweir 		{
1319cdf0e10cSrcweir 			((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(sal_True);
1320cdf0e10cSrcweir 		}
1321cdf0e10cSrcweir 		else
1322cdf0e10cSrcweir 		{
1323cdf0e10cSrcweir 			GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
1324cdf0e10cSrcweir 		}
1325cdf0e10cSrcweir 	}
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir //----------------------------------------------------------------------------
1329cdf0e10cSrcweir 
_elementRemoved(const::com::sun::star::container::ContainerEvent &)1330cdf0e10cSrcweir void SAL_CALL DlgEdObj::_elementRemoved(const ::com::sun::star::container::ContainerEvent& ) throw(::com::sun::star::uno::RuntimeException)
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir 	if (isListening())
1333cdf0e10cSrcweir 	{
1334cdf0e10cSrcweir 		// dialog model changed
1335cdf0e10cSrcweir 		if ( ISA(DlgEdForm) )
1336cdf0e10cSrcweir 		{
1337cdf0e10cSrcweir 			((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(sal_True);
1338cdf0e10cSrcweir 		}
1339cdf0e10cSrcweir 		else
1340cdf0e10cSrcweir 		{
1341cdf0e10cSrcweir 			GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
1342cdf0e10cSrcweir 		}
1343cdf0e10cSrcweir 	}
1344cdf0e10cSrcweir }
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir //----------------------------------------------------------------------------
1347cdf0e10cSrcweir 
SetLayer(SdrLayerID nLayer)1348cdf0e10cSrcweir void DlgEdObj::SetLayer(SdrLayerID nLayer)
1349cdf0e10cSrcweir {
1350cdf0e10cSrcweir 	SdrLayerID nOldLayer = GetLayer();
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir 	if ( nLayer != nOldLayer )
1353cdf0e10cSrcweir 	{
1354cdf0e10cSrcweir 		SdrUnoObj::SetLayer( nLayer );
1355cdf0e10cSrcweir 
1356cdf0e10cSrcweir 		DlgEdHint aHint( DLGED_HINT_LAYERCHANGED, this );
1357cdf0e10cSrcweir 		GetDlgEdForm()->GetDlgEditor()->Broadcast( aHint );
1358cdf0e10cSrcweir 	}
1359cdf0e10cSrcweir }
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir //----------------------------------------------------------------------------
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir TYPEINIT1(DlgEdForm, DlgEdObj);
1364cdf0e10cSrcweir DBG_NAME(DlgEdForm);
1365cdf0e10cSrcweir 
1366cdf0e10cSrcweir //----------------------------------------------------------------------------
1367cdf0e10cSrcweir 
DlgEdForm()1368cdf0e10cSrcweir DlgEdForm::DlgEdForm()
1369cdf0e10cSrcweir 		  :DlgEdObj()
1370cdf0e10cSrcweir {
1371cdf0e10cSrcweir 	DBG_CTOR(DlgEdForm, NULL);
1372cdf0e10cSrcweir }
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir //----------------------------------------------------------------------------
1375cdf0e10cSrcweir 
~DlgEdForm()1376cdf0e10cSrcweir DlgEdForm::~DlgEdForm()
1377cdf0e10cSrcweir {
1378cdf0e10cSrcweir 	DBG_DTOR(DlgEdForm, NULL);
1379cdf0e10cSrcweir }
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir //----------------------------------------------------------------------------
1382cdf0e10cSrcweir 
SetDlgEditor(DlgEditor * pEditor)1383cdf0e10cSrcweir void DlgEdForm::SetDlgEditor( DlgEditor* pEditor )
1384cdf0e10cSrcweir {
1385cdf0e10cSrcweir     pDlgEditor = pEditor;
1386cdf0e10cSrcweir     ImplInvalidateDeviceInfo();
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir //----------------------------------------------------------------------------
1390cdf0e10cSrcweir 
ImplInvalidateDeviceInfo()1391cdf0e10cSrcweir void DlgEdForm::ImplInvalidateDeviceInfo()
1392cdf0e10cSrcweir {
1393cdf0e10cSrcweir     mpDeviceInfo.reset();
1394cdf0e10cSrcweir }
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir //----------------------------------------------------------------------------
1397cdf0e10cSrcweir 
SetRectFromProps()1398cdf0e10cSrcweir void DlgEdForm::SetRectFromProps()
1399cdf0e10cSrcweir {
1400cdf0e10cSrcweir     // get form position and size from properties
1401cdf0e10cSrcweir     Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
1402cdf0e10cSrcweir     if ( xPSet.is() )
1403cdf0e10cSrcweir     {
1404cdf0e10cSrcweir         sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
1405cdf0e10cSrcweir         xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
1406cdf0e10cSrcweir         xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
1407cdf0e10cSrcweir         xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
1408cdf0e10cSrcweir         xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir         // transform coordinates
1411cdf0e10cSrcweir         sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
1412cdf0e10cSrcweir         if ( TransformFormToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
1413cdf0e10cSrcweir         {
1414cdf0e10cSrcweir             // set rectangle position and size
1415cdf0e10cSrcweir             Point aPoint( nXOut, nYOut );
1416cdf0e10cSrcweir             Size aSize( nWidthOut, nHeightOut );
1417cdf0e10cSrcweir             SetSnapRect( Rectangle( aPoint, aSize ) );
1418cdf0e10cSrcweir         }
1419cdf0e10cSrcweir     }
1420cdf0e10cSrcweir }
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir //----------------------------------------------------------------------------
1423cdf0e10cSrcweir 
SetPropsFromRect()1424cdf0e10cSrcweir void DlgEdForm::SetPropsFromRect()
1425cdf0e10cSrcweir {
1426cdf0e10cSrcweir     // get form position and size from rectangle
1427cdf0e10cSrcweir     Rectangle aRect_ = GetSnapRect();
1428cdf0e10cSrcweir     sal_Int32 nXIn = aRect_.Left();
1429cdf0e10cSrcweir     sal_Int32 nYIn = aRect_.Top();
1430cdf0e10cSrcweir     sal_Int32 nWidthIn = aRect_.GetWidth();
1431cdf0e10cSrcweir     sal_Int32 nHeightIn = aRect_.GetHeight();
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir     // transform coordinates
1434cdf0e10cSrcweir     sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
1435cdf0e10cSrcweir     if ( TransformSdrToFormCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
1436cdf0e10cSrcweir     {
1437cdf0e10cSrcweir         // set properties
1438cdf0e10cSrcweir         Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
1439cdf0e10cSrcweir         if ( xPSet.is() )
1440cdf0e10cSrcweir         {
1441cdf0e10cSrcweir             Any aValue;
1442cdf0e10cSrcweir             aValue <<= nXOut;
1443cdf0e10cSrcweir             xPSet->setPropertyValue( DLGED_PROP_POSITIONX, aValue );
1444cdf0e10cSrcweir             aValue <<= nYOut;
1445cdf0e10cSrcweir             xPSet->setPropertyValue( DLGED_PROP_POSITIONY, aValue );
1446cdf0e10cSrcweir             aValue <<= nWidthOut;
1447cdf0e10cSrcweir             xPSet->setPropertyValue( DLGED_PROP_WIDTH, aValue );
1448cdf0e10cSrcweir             aValue <<= nHeightOut;
1449cdf0e10cSrcweir             xPSet->setPropertyValue( DLGED_PROP_HEIGHT, aValue );
1450cdf0e10cSrcweir         }
1451cdf0e10cSrcweir     }
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir //----------------------------------------------------------------------------
1455cdf0e10cSrcweir 
AddChild(DlgEdObj * pDlgEdObj)1456cdf0e10cSrcweir void DlgEdForm::AddChild( DlgEdObj* pDlgEdObj )
1457cdf0e10cSrcweir {
1458cdf0e10cSrcweir 	pChilds.push_back( pDlgEdObj );
1459cdf0e10cSrcweir }
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir //----------------------------------------------------------------------------
1462cdf0e10cSrcweir 
RemoveChild(DlgEdObj * pDlgEdObj)1463cdf0e10cSrcweir void DlgEdForm::RemoveChild( DlgEdObj* pDlgEdObj )
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir 	pChilds.erase( ::std::find( pChilds.begin() , pChilds.end() , pDlgEdObj ) );
1466cdf0e10cSrcweir }
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir //----------------------------------------------------------------------------
1469cdf0e10cSrcweir 
PositionAndSizeChange(const beans::PropertyChangeEvent & evt)1470cdf0e10cSrcweir void DlgEdForm::PositionAndSizeChange( const beans::PropertyChangeEvent& evt )
1471cdf0e10cSrcweir {
1472cdf0e10cSrcweir     DlgEditor* pEditor = GetDlgEditor();
1473cdf0e10cSrcweir     DBG_ASSERT( pEditor, "DlgEdForm::PositionAndSizeChange: no dialog editor!" );
1474cdf0e10cSrcweir     if ( pEditor )
1475cdf0e10cSrcweir     {
1476cdf0e10cSrcweir         DlgEdPage* pPage_ = pEditor->GetPage();
1477cdf0e10cSrcweir         DBG_ASSERT( pPage_, "DlgEdForm::PositionAndSizeChange: no page!" );
1478cdf0e10cSrcweir         if ( pPage_ )
1479cdf0e10cSrcweir         {
1480cdf0e10cSrcweir             sal_Int32 nPageXIn = 0;
1481cdf0e10cSrcweir             sal_Int32 nPageYIn = 0;
1482cdf0e10cSrcweir             Size aPageSize = pPage_->GetSize();
1483cdf0e10cSrcweir             sal_Int32 nPageWidthIn = aPageSize.Width();
1484cdf0e10cSrcweir             sal_Int32 nPageHeightIn = aPageSize.Height();
1485cdf0e10cSrcweir             sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
1486cdf0e10cSrcweir             if ( TransformSdrToFormCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
1487cdf0e10cSrcweir             {
1488cdf0e10cSrcweir                 Reference< beans::XPropertySet > xPSetForm( GetUnoControlModel(), UNO_QUERY );
1489cdf0e10cSrcweir                 if ( xPSetForm.is() )
1490cdf0e10cSrcweir                 {
1491cdf0e10cSrcweir                     sal_Int32 nValue = 0;
1492cdf0e10cSrcweir                     evt.NewValue >>= nValue;
1493cdf0e10cSrcweir                     sal_Int32 nNewValue = nValue;
1494cdf0e10cSrcweir 
1495cdf0e10cSrcweir                     if ( evt.PropertyName == DLGED_PROP_POSITIONX )
1496cdf0e10cSrcweir                     {
1497cdf0e10cSrcweir                         if ( nNewValue < nPageX )
1498cdf0e10cSrcweir                             nNewValue = nPageX;
1499cdf0e10cSrcweir                     }
1500cdf0e10cSrcweir                     else if ( evt.PropertyName == DLGED_PROP_POSITIONY )
1501cdf0e10cSrcweir                     {
1502cdf0e10cSrcweir                         if ( nNewValue < nPageY )
1503cdf0e10cSrcweir                             nNewValue = nPageY;
1504cdf0e10cSrcweir                     }
1505cdf0e10cSrcweir                     else if ( evt.PropertyName == DLGED_PROP_WIDTH )
1506cdf0e10cSrcweir                     {
1507cdf0e10cSrcweir                         if ( nNewValue < 1 )
1508cdf0e10cSrcweir                             nNewValue = 1;
1509cdf0e10cSrcweir                     }
1510cdf0e10cSrcweir                     else if ( evt.PropertyName == DLGED_PROP_HEIGHT )
1511cdf0e10cSrcweir                     {
1512cdf0e10cSrcweir                         if ( nNewValue < 1 )
1513cdf0e10cSrcweir                             nNewValue = 1;
1514cdf0e10cSrcweir                     }
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir                     if ( nNewValue != nValue )
1517cdf0e10cSrcweir                     {
1518cdf0e10cSrcweir                         Any aNewValue;
1519cdf0e10cSrcweir                         aNewValue <<= nNewValue;
1520cdf0e10cSrcweir                         EndListening( sal_False );
1521cdf0e10cSrcweir                         xPSetForm->setPropertyValue( evt.PropertyName, aNewValue );
1522cdf0e10cSrcweir                         StartListening();
1523cdf0e10cSrcweir                     }
1524cdf0e10cSrcweir                 }
1525cdf0e10cSrcweir             }
1526cdf0e10cSrcweir 
1527cdf0e10cSrcweir             bool bAdjustedPageSize = pEditor->AdjustPageSize();
1528cdf0e10cSrcweir             SetRectFromProps();
1529cdf0e10cSrcweir             ::std::vector< DlgEdObj* >::iterator aIter;
1530cdf0e10cSrcweir             ::std::vector< DlgEdObj* > aChildList = ((DlgEdForm*)this)->GetChilds();
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir             if ( bAdjustedPageSize )
1533cdf0e10cSrcweir             {
1534cdf0e10cSrcweir                 pEditor->InitScrollBars();
1535cdf0e10cSrcweir                 aPageSize = pPage_->GetSize();
1536cdf0e10cSrcweir                 nPageWidthIn = aPageSize.Width();
1537cdf0e10cSrcweir                 nPageHeightIn = aPageSize.Height();
1538cdf0e10cSrcweir                 if ( TransformSdrToControlCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
1539cdf0e10cSrcweir                 {
1540cdf0e10cSrcweir                     for ( aIter = aChildList.begin(); aIter != aChildList.end(); aIter++ )
1541cdf0e10cSrcweir                     {
1542cdf0e10cSrcweir                         Reference< beans::XPropertySet > xPSet( (*aIter)->GetUnoControlModel(), UNO_QUERY );
1543cdf0e10cSrcweir                         if ( xPSet.is() )
1544cdf0e10cSrcweir                         {
1545cdf0e10cSrcweir                             sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0;
1546cdf0e10cSrcweir                             xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nX;
1547cdf0e10cSrcweir                             xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nY;
1548cdf0e10cSrcweir                             xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
1549cdf0e10cSrcweir                             xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir                             sal_Int32 nNewX = nX;
1552cdf0e10cSrcweir                             if ( nX + nWidth > nPageX + nPageWidth )
1553cdf0e10cSrcweir                             {
1554cdf0e10cSrcweir                                 nNewX = nPageX + nPageWidth - nWidth;
1555cdf0e10cSrcweir                                 if ( nNewX < nPageX )
1556cdf0e10cSrcweir                                     nNewX = nPageX;
1557cdf0e10cSrcweir                             }
1558cdf0e10cSrcweir                             if ( nNewX != nX )
1559cdf0e10cSrcweir                             {
1560cdf0e10cSrcweir                                 Any aValue;
1561cdf0e10cSrcweir                                 aValue <<= nNewX;
1562cdf0e10cSrcweir                                 EndListening( sal_False );
1563cdf0e10cSrcweir                                 xPSet->setPropertyValue( DLGED_PROP_POSITIONX, aValue );
1564cdf0e10cSrcweir                                 StartListening();
1565cdf0e10cSrcweir                             }
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir                             sal_Int32 nNewY = nY;
1568cdf0e10cSrcweir                             if ( nY + nHeight > nPageY + nPageHeight )
1569cdf0e10cSrcweir                             {
1570cdf0e10cSrcweir                                 nNewY = nPageY + nPageHeight - nHeight;
1571cdf0e10cSrcweir                                 if ( nNewY < nPageY )
1572cdf0e10cSrcweir                                     nNewY = nPageY;
1573cdf0e10cSrcweir                             }
1574cdf0e10cSrcweir                             if ( nNewY != nY )
1575cdf0e10cSrcweir                             {
1576cdf0e10cSrcweir                                 Any aValue;
1577cdf0e10cSrcweir                                 aValue <<= nNewY;
1578cdf0e10cSrcweir                                 EndListening( sal_False );
1579cdf0e10cSrcweir                                 xPSet->setPropertyValue( DLGED_PROP_POSITIONY, aValue );
1580cdf0e10cSrcweir                                 StartListening();
1581cdf0e10cSrcweir                             }
1582cdf0e10cSrcweir                         }
1583cdf0e10cSrcweir                     }
1584cdf0e10cSrcweir                 }
1585cdf0e10cSrcweir             }
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir             for ( aIter = aChildList.begin(); aIter != aChildList.end(); aIter++ )
1588cdf0e10cSrcweir             {
1589cdf0e10cSrcweir                 (*aIter)->SetRectFromProps();
1590cdf0e10cSrcweir             }
1591cdf0e10cSrcweir         }
1592cdf0e10cSrcweir     }
1593cdf0e10cSrcweir }
1594cdf0e10cSrcweir 
1595cdf0e10cSrcweir //----------------------------------------------------------------------------
1596cdf0e10cSrcweir 
UpdateStep()1597cdf0e10cSrcweir void DlgEdForm::UpdateStep()
1598cdf0e10cSrcweir {
1599cdf0e10cSrcweir 	sal_uLong nObjCount;
1600cdf0e10cSrcweir 	SdrPage* pSdrPage = GetPage();
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir 	if ( pSdrPage && ( ( nObjCount = pSdrPage->GetObjCount() ) > 0 ) )
1603cdf0e10cSrcweir 	{
1604cdf0e10cSrcweir 		for ( sal_uLong i = 0 ; i < nObjCount ; i++ )
1605cdf0e10cSrcweir 		{
1606cdf0e10cSrcweir 			SdrObject* pObj = pSdrPage->GetObj(i);
1607cdf0e10cSrcweir 			DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
1608cdf0e10cSrcweir 			if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
1609cdf0e10cSrcweir 				pDlgEdObj->UpdateStep();
1610cdf0e10cSrcweir 		}
1611cdf0e10cSrcweir 	}
1612cdf0e10cSrcweir }
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir //----------------------------------------------------------------------------
1615cdf0e10cSrcweir 
UpdateTabIndices()1616cdf0e10cSrcweir void DlgEdForm::UpdateTabIndices()
1617cdf0e10cSrcweir {
1618cdf0e10cSrcweir 	// stop listening with all children
1619cdf0e10cSrcweir 	::std::vector<DlgEdObj*>::iterator aIter;
1620cdf0e10cSrcweir 	for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; ++aIter )
1621cdf0e10cSrcweir 	{
1622cdf0e10cSrcweir 		(*aIter)->EndListening( sal_False );
1623cdf0e10cSrcweir 	}
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir 	Reference< ::com::sun::star::container::XNameAccess > xNameAcc( GetUnoControlModel() , UNO_QUERY );
1626cdf0e10cSrcweir 	if ( xNameAcc.is() )
1627cdf0e10cSrcweir 	{
1628cdf0e10cSrcweir 		// get sequence of control names
1629cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
1630cdf0e10cSrcweir 		const ::rtl::OUString* pNames = aNames.getConstArray();
1631cdf0e10cSrcweir 		sal_Int32 nCtrls = aNames.getLength();
1632cdf0e10cSrcweir 
1633cdf0e10cSrcweir 		// create a map of tab indices and control names, sorted by tab index
1634cdf0e10cSrcweir 		IndexToNameMap aIndexToNameMap;
1635cdf0e10cSrcweir 		for ( sal_Int16 i = 0; i < nCtrls; ++i )
1636cdf0e10cSrcweir 		{
1637cdf0e10cSrcweir 			// get name
1638cdf0e10cSrcweir 			::rtl::OUString aName( pNames[i] );
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir 			// get tab index
1641cdf0e10cSrcweir 			sal_Int16 nTabIndex = -1;
1642cdf0e10cSrcweir 			Any aCtrl = xNameAcc->getByName( aName );
1643cdf0e10cSrcweir 			Reference< ::com::sun::star::beans::XPropertySet > xPSet;
1644cdf0e10cSrcweir    			aCtrl >>= xPSet;
1645cdf0e10cSrcweir 			if ( xPSet.is() )
1646cdf0e10cSrcweir 				xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir 			// insert into map
1649cdf0e10cSrcweir 			aIndexToNameMap.insert( IndexToNameMap::value_type( nTabIndex, aName ) );
1650cdf0e10cSrcweir 		}
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir 		// set new tab indices
1653cdf0e10cSrcweir 		sal_Int16 nNewTabIndex = 0;
1654cdf0e10cSrcweir 		for ( IndexToNameMap::iterator aIt = aIndexToNameMap.begin(); aIt != aIndexToNameMap.end(); ++aIt )
1655cdf0e10cSrcweir 		{
1656cdf0e10cSrcweir 			Any aCtrl = xNameAcc->getByName( aIt->second );
1657cdf0e10cSrcweir 			Reference< beans::XPropertySet > xPSet;
1658cdf0e10cSrcweir    			aCtrl >>= xPSet;
1659cdf0e10cSrcweir 			if ( xPSet.is() )
1660cdf0e10cSrcweir 			{
1661cdf0e10cSrcweir 				Any aTabIndex;
1662cdf0e10cSrcweir 				aTabIndex <<= (sal_Int16) nNewTabIndex++;
1663cdf0e10cSrcweir 				xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
1664cdf0e10cSrcweir 			}
1665cdf0e10cSrcweir 		}
1666cdf0e10cSrcweir 
1667cdf0e10cSrcweir         // #110559#
1668cdf0e10cSrcweir         UpdateTabOrderAndGroups();
1669cdf0e10cSrcweir 	}
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir 	// start listening with all children
1672cdf0e10cSrcweir 	for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; ++aIter )
1673cdf0e10cSrcweir 	{
1674cdf0e10cSrcweir 		(*aIter)->StartListening();
1675cdf0e10cSrcweir 	}
1676cdf0e10cSrcweir }
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir //----------------------------------------------------------------------------
1679cdf0e10cSrcweir 
UpdateTabOrder()1680cdf0e10cSrcweir void DlgEdForm::UpdateTabOrder()
1681cdf0e10cSrcweir {
1682cdf0e10cSrcweir     // #110559#
1683cdf0e10cSrcweir     // When the tabindex of a control model changes, the dialog control is
1684cdf0e10cSrcweir     // notified about those changes. Due to #109067# (bad performance of
1685cdf0e10cSrcweir     // dialog editor) the dialog control doesn't activate the tab order
1686cdf0e10cSrcweir     // in design mode. When the dialog editor has reordered all
1687cdf0e10cSrcweir     // tabindices, this method allows to activate the taborder afterwards.
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir     Reference< awt::XUnoControlContainer > xCont( GetControl(), UNO_QUERY );
1690cdf0e10cSrcweir     if ( xCont.is() )
1691cdf0e10cSrcweir     {
1692cdf0e10cSrcweir         Sequence< Reference< awt::XTabController > > aSeqTabCtrls = xCont->getTabControllers();
1693cdf0e10cSrcweir         const Reference< awt::XTabController >* pTabCtrls = aSeqTabCtrls.getConstArray();
1694cdf0e10cSrcweir         sal_Int32 nCount = aSeqTabCtrls.getLength();
1695cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < nCount; ++i )
1696cdf0e10cSrcweir             pTabCtrls[i]->activateTabOrder();
1697cdf0e10cSrcweir     }
1698cdf0e10cSrcweir }
1699cdf0e10cSrcweir 
1700cdf0e10cSrcweir //----------------------------------------------------------------------------
1701cdf0e10cSrcweir 
UpdateGroups()1702cdf0e10cSrcweir void DlgEdForm::UpdateGroups()
1703cdf0e10cSrcweir {
1704cdf0e10cSrcweir     // #110559#
1705cdf0e10cSrcweir     // The grouping of radio buttons in a dialog is done by vcl.
1706cdf0e10cSrcweir     // In the dialog editor we have two views (=controls) for one
1707cdf0e10cSrcweir     // radio button model. One control is owned by the dialog control,
1708cdf0e10cSrcweir     // but not visible in design mode. The other control is owned by
1709cdf0e10cSrcweir     // the drawing layer object. Whereas the grouping of the first
1710cdf0e10cSrcweir     // control is done by vcl, the grouping of the control in the
1711cdf0e10cSrcweir     // drawing layer has to be done here.
1712cdf0e10cSrcweir 
1713cdf0e10cSrcweir     Reference< awt::XTabControllerModel > xTabModel( GetUnoControlModel() , UNO_QUERY );
1714cdf0e10cSrcweir     if ( xTabModel.is() )
1715cdf0e10cSrcweir     {
1716cdf0e10cSrcweir         // create a global list of controls that belong to the dialog
1717cdf0e10cSrcweir         ::std::vector<DlgEdObj*> aChildList = GetChilds();
1718cdf0e10cSrcweir         sal_uInt32 nSize = aChildList.size();
1719cdf0e10cSrcweir         Sequence< Reference< awt::XControl > > aSeqControls( nSize );
1720cdf0e10cSrcweir         for ( sal_uInt32 i = 0; i < nSize; ++i )
1721cdf0e10cSrcweir             aSeqControls.getArray()[i] = Reference< awt::XControl >( aChildList[i]->GetControl(), UNO_QUERY );
1722cdf0e10cSrcweir 
1723cdf0e10cSrcweir         sal_Int32 nGroupCount = xTabModel->getGroupCount();
1724cdf0e10cSrcweir         for ( sal_Int32 nGroup = 0; nGroup < nGroupCount; ++nGroup )
1725cdf0e10cSrcweir         {
1726cdf0e10cSrcweir             // get a list of control models that belong to this group
1727cdf0e10cSrcweir             ::rtl::OUString aName;
1728cdf0e10cSrcweir             Sequence< Reference< awt::XControlModel > > aSeqModels;
1729cdf0e10cSrcweir             xTabModel->getGroup( nGroup, aSeqModels, aName );
1730cdf0e10cSrcweir             const Reference< awt::XControlModel >* pModels = aSeqModels.getConstArray();
1731cdf0e10cSrcweir             sal_Int32 nModelCount = aSeqModels.getLength();
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir             // create a list of peers that belong to this group
1734cdf0e10cSrcweir             Sequence< Reference< awt::XWindow > > aSeqPeers( nModelCount );
1735cdf0e10cSrcweir             for ( sal_Int32 nModel = 0; nModel < nModelCount; ++nModel )
1736cdf0e10cSrcweir             {
1737cdf0e10cSrcweir                 // for each control model find the corresponding control in the global list
1738cdf0e10cSrcweir                 const Reference< awt::XControl >* pControls = aSeqControls.getConstArray();
1739cdf0e10cSrcweir                 sal_Int32 nControlCount = aSeqControls.getLength();
1740cdf0e10cSrcweir                 for ( sal_Int32 nControl = 0; nControl < nControlCount; ++nControl )
1741cdf0e10cSrcweir                 {
1742cdf0e10cSrcweir                     const Reference< awt::XControl > xCtrl( pControls[nControl] );
1743cdf0e10cSrcweir                     if ( xCtrl.is() )
1744cdf0e10cSrcweir                     {
1745cdf0e10cSrcweir                         Reference< awt::XControlModel > xCtrlModel( xCtrl->getModel() );
1746cdf0e10cSrcweir                         if ( (awt::XControlModel*)xCtrlModel.get() == (awt::XControlModel*)pModels[nModel].get() )
1747cdf0e10cSrcweir                         {
1748cdf0e10cSrcweir                             // get the control peer and insert into the list of peers
1749cdf0e10cSrcweir                             aSeqPeers.getArray()[ nModel ] = Reference< awt::XWindow >( xCtrl->getPeer(), UNO_QUERY );
1750cdf0e10cSrcweir                             break;
1751cdf0e10cSrcweir                         }
1752cdf0e10cSrcweir                     }
1753cdf0e10cSrcweir                 }
1754cdf0e10cSrcweir             }
1755cdf0e10cSrcweir 
1756cdf0e10cSrcweir             // set the group at the dialog peer
1757cdf0e10cSrcweir             Reference< awt::XControl > xDlg( GetControl(), UNO_QUERY );
1758cdf0e10cSrcweir             if ( xDlg.is() )
1759cdf0e10cSrcweir             {
1760cdf0e10cSrcweir                 Reference< awt::XVclContainerPeer > xDlgPeer( xDlg->getPeer(), UNO_QUERY );
1761cdf0e10cSrcweir                 if ( xDlgPeer.is() )
1762cdf0e10cSrcweir                     xDlgPeer->setGroup( aSeqPeers );
1763cdf0e10cSrcweir             }
1764cdf0e10cSrcweir         }
1765cdf0e10cSrcweir     }
1766cdf0e10cSrcweir }
1767cdf0e10cSrcweir 
1768cdf0e10cSrcweir //----------------------------------------------------------------------------
1769cdf0e10cSrcweir 
UpdateTabOrderAndGroups()1770cdf0e10cSrcweir void DlgEdForm::UpdateTabOrderAndGroups()
1771cdf0e10cSrcweir {
1772cdf0e10cSrcweir     UpdateTabOrder();
1773cdf0e10cSrcweir     UpdateGroups();
1774cdf0e10cSrcweir }
1775cdf0e10cSrcweir 
1776cdf0e10cSrcweir //----------------------------------------------------------------------------
1777cdf0e10cSrcweir 
NbcMove(const Size & rSize)1778cdf0e10cSrcweir void DlgEdForm::NbcMove( const Size& rSize )
1779cdf0e10cSrcweir {
1780cdf0e10cSrcweir 	SdrUnoObj::NbcMove( rSize );
1781cdf0e10cSrcweir 
1782cdf0e10cSrcweir 	// set geometry properties of form
1783cdf0e10cSrcweir 	EndListening(sal_False);
1784cdf0e10cSrcweir 	SetPropsFromRect();
1785cdf0e10cSrcweir 	StartListening();
1786cdf0e10cSrcweir 
1787cdf0e10cSrcweir 	// set geometry properties of all childs
1788cdf0e10cSrcweir 	::std::vector<DlgEdObj*>::iterator aIter;
1789cdf0e10cSrcweir 	for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; aIter++ )
1790cdf0e10cSrcweir 	{
1791cdf0e10cSrcweir 		(*aIter)->EndListening(sal_False);
1792cdf0e10cSrcweir 		(*aIter)->SetPropsFromRect();
1793cdf0e10cSrcweir 		(*aIter)->StartListening();
1794cdf0e10cSrcweir 	}
1795cdf0e10cSrcweir 
1796cdf0e10cSrcweir 	// dialog model changed
1797cdf0e10cSrcweir 	GetDlgEditor()->SetDialogModelChanged(sal_True);
1798cdf0e10cSrcweir }
1799cdf0e10cSrcweir 
1800cdf0e10cSrcweir //----------------------------------------------------------------------------
1801cdf0e10cSrcweir 
NbcResize(const Point & rRef,const Fraction & xFract,const Fraction & yFract)1802cdf0e10cSrcweir void DlgEdForm::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
1803cdf0e10cSrcweir {
1804cdf0e10cSrcweir 	SdrUnoObj::NbcResize( rRef, xFract, yFract );
1805cdf0e10cSrcweir 
1806cdf0e10cSrcweir 	// set geometry properties of form
1807cdf0e10cSrcweir 	EndListening(sal_False);
1808cdf0e10cSrcweir 	SetPropsFromRect();
1809cdf0e10cSrcweir 	StartListening();
1810cdf0e10cSrcweir 
1811cdf0e10cSrcweir 	// set geometry properties of all childs
1812cdf0e10cSrcweir 	::std::vector<DlgEdObj*>::iterator aIter;
1813cdf0e10cSrcweir 	for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; aIter++ )
1814cdf0e10cSrcweir 	{
1815cdf0e10cSrcweir 		(*aIter)->EndListening(sal_False);
1816cdf0e10cSrcweir 		(*aIter)->SetPropsFromRect();
1817cdf0e10cSrcweir 		(*aIter)->StartListening();
1818cdf0e10cSrcweir 	}
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir 	// dialog model changed
1821cdf0e10cSrcweir 	GetDlgEditor()->SetDialogModelChanged(sal_True);
1822cdf0e10cSrcweir }
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir //----------------------------------------------------------------------------
1825cdf0e10cSrcweir 
EndCreate(SdrDragStat & rStat,SdrCreateCmd eCmd)1826cdf0e10cSrcweir FASTBOOL DlgEdForm::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
1827cdf0e10cSrcweir {
1828cdf0e10cSrcweir 	FASTBOOL bResult = SdrUnoObj::EndCreate(rStat, eCmd);
1829cdf0e10cSrcweir 
1830cdf0e10cSrcweir 	// stop listening
1831cdf0e10cSrcweir 	EndListening(sal_False);
1832cdf0e10cSrcweir 
1833cdf0e10cSrcweir 	// set geometry properties
1834cdf0e10cSrcweir 	SetPropsFromRect();
1835cdf0e10cSrcweir 
1836cdf0e10cSrcweir 	// dialog model changed
1837cdf0e10cSrcweir 	GetDlgEditor()->SetDialogModelChanged(sal_True);
1838cdf0e10cSrcweir 
1839cdf0e10cSrcweir 	// start listening
1840cdf0e10cSrcweir 	StartListening();
1841cdf0e10cSrcweir 
1842cdf0e10cSrcweir 	return bResult;
1843cdf0e10cSrcweir }
1844cdf0e10cSrcweir 
1845cdf0e10cSrcweir //----------------------------------------------------------------------------
1846cdf0e10cSrcweir 
getDeviceInfo() const1847cdf0e10cSrcweir awt::DeviceInfo DlgEdForm::getDeviceInfo() const
1848cdf0e10cSrcweir {
1849cdf0e10cSrcweir     awt::DeviceInfo aDeviceInfo;
1850cdf0e10cSrcweir 
1851cdf0e10cSrcweir     DlgEditor* pEditor = GetDlgEditor();
1852cdf0e10cSrcweir     DBG_ASSERT( pEditor, "DlgEdForm::getDeviceInfo: no editor associated with the form object!" );
1853cdf0e10cSrcweir     if ( !pEditor )
1854cdf0e10cSrcweir         return aDeviceInfo;
1855cdf0e10cSrcweir 
1856cdf0e10cSrcweir     Window* pWindow = pEditor->GetWindow();
1857cdf0e10cSrcweir     DBG_ASSERT( pWindow, "DlgEdForm::getDeviceInfo: no window associated with the editor!" );
1858cdf0e10cSrcweir     if ( !pWindow )
1859cdf0e10cSrcweir         return aDeviceInfo;
1860cdf0e10cSrcweir 
1861cdf0e10cSrcweir     // obtain an XControl
1862cdf0e10cSrcweir     ::utl::SharedUNOComponent< awt::XControl > xDialogControl; // ensures auto-disposal, if needed
1863cdf0e10cSrcweir     xDialogControl.reset( GetControl(), ::utl::SharedUNOComponent< awt::XControl >::NoTakeOwnership );
1864cdf0e10cSrcweir     if ( !xDialogControl.is() )
1865cdf0e10cSrcweir     {
1866cdf0e10cSrcweir         // don't create a temporary control all the time, this method here is called
1867cdf0e10cSrcweir         // way too often. Instead, use a cached DeviceInfo.
1868cdf0e10cSrcweir         // 2007-02-05 / i74065 / frank.schoenheit@sun.com
1869cdf0e10cSrcweir         if ( !!mpDeviceInfo )
1870cdf0e10cSrcweir             return *mpDeviceInfo;
1871cdf0e10cSrcweir 
1872cdf0e10cSrcweir         Reference< awt::XControlContainer > xEditorControlContainer( pEditor->GetWindowControlContainer() );
1873cdf0e10cSrcweir         xDialogControl.reset(
1874cdf0e10cSrcweir             GetTemporaryControlForWindow( *pWindow, xEditorControlContainer ),
1875cdf0e10cSrcweir             ::utl::SharedUNOComponent< awt::XControl >::TakeOwnership );
1876cdf0e10cSrcweir     }
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir     Reference< awt::XDevice > xDialogDevice;
1879cdf0e10cSrcweir     if ( xDialogControl.is() )
1880cdf0e10cSrcweir         xDialogDevice.set( xDialogControl->getPeer(), UNO_QUERY );
1881cdf0e10cSrcweir     DBG_ASSERT( xDialogDevice.is(), "DlgEdForm::getDeviceInfo: no device!" );
1882cdf0e10cSrcweir     if ( xDialogDevice.is() )
1883cdf0e10cSrcweir         aDeviceInfo = xDialogDevice->getInfo();
1884cdf0e10cSrcweir 
1885cdf0e10cSrcweir     mpDeviceInfo.reset( aDeviceInfo );
1886cdf0e10cSrcweir 
1887cdf0e10cSrcweir     return aDeviceInfo;
1888cdf0e10cSrcweir }
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir //----------------------------------------------------------------------------
1891cdf0e10cSrcweir 
1892cdf0e10cSrcweir 
1893