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