LCOV - code coverage report
Current view: top level - basctl/source/dlged - dlgedobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 905 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 68 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11