2001-02-26 09:47:06 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: dlgedobj.cxx,v $
|
|
|
|
*
|
2001-03-02 13:02:06 +00:00
|
|
|
* $Revision: 1.4 $
|
2001-02-26 09:47:06 +00:00
|
|
|
*
|
2001-03-02 13:02:06 +00:00
|
|
|
* last change: $Author: tbe $ $Date: 2001-03-02 14:02:06 $
|
2001-02-26 09:47:06 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _BASCTL_DLGEDOBJ_HXX
|
|
|
|
#include "dlgedobj.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SVX_FMPROP_HXX
|
|
|
|
//#include "fmprop.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _TOOLS_RESMGR_HXX
|
|
|
|
#include <tools/resmgr.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SVX_FMPROP_HRC
|
|
|
|
//#include "fmprop.hrc"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SVDIO_HXX //autogen
|
|
|
|
#include <svx/svdio.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SVX_FMTOOLS_HXX
|
|
|
|
//#include "fmtools.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SHL_HXX
|
|
|
|
#include <tools/shl.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-03-01 08:50:51 +00:00
|
|
|
#ifndef _STRING_HXX
|
|
|
|
//#include <tools/string.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-02-26 09:47:06 +00:00
|
|
|
#ifndef _SVX_FMRESIDS_HRC
|
2001-03-01 08:50:51 +00:00
|
|
|
//#include <svx/fmresids.hrc>
|
2001-02-26 09:47:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SVX_FMGLOB_HXX
|
|
|
|
#include <svx/fmglob.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _BASCTL_DLGED_HXX
|
|
|
|
#include "dlged.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _BASCTL_DLGEDMOD_HXX
|
|
|
|
#include "dlgedmod.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _BASCTL_DLGEDPAGE_HXX
|
|
|
|
#include "dlgedpage.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _BASCTL_DLGEDVIEW_HXX
|
|
|
|
#include "dlgedview.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _BASCTL_DLGEDLIST_HXX
|
|
|
|
#include "dlgedlist.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "vcsbxdef.hxx"
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::rtl;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
TYPEINIT1(DlgEdObj, SdrUnoObj);
|
|
|
|
DBG_NAME(DlgEdObj);
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DlgEdObj::DlgEdObj()
|
|
|
|
:SdrUnoObj(String(), sal_False)
|
|
|
|
,bIsListening(sal_False)
|
|
|
|
{
|
|
|
|
DBG_CTOR(DlgEdObj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DlgEdObj::DlgEdObj(const ::rtl::OUString& rModelName)
|
|
|
|
:SdrUnoObj(rModelName, sal_False)
|
|
|
|
,bIsListening(sal_False)
|
|
|
|
{
|
|
|
|
DBG_CTOR(DlgEdObj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DlgEdObj::DlgEdObj(const ::rtl::OUString& rModelName,
|
|
|
|
const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac)
|
|
|
|
:SdrUnoObj(rModelName, rxSFac, sal_False)
|
|
|
|
,bIsListening(sal_False)
|
|
|
|
{
|
|
|
|
DBG_CTOR(DlgEdObj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DlgEdObj::~DlgEdObj()
|
|
|
|
{
|
|
|
|
DBG_DTOR(DlgEdObj, NULL);
|
|
|
|
|
|
|
|
EndPropertyListening();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::SetPage(SdrPage* _pNewPage)
|
|
|
|
{
|
|
|
|
// now set the page
|
|
|
|
SdrUnoObj::SetPage(_pNewPage);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::SetRectFromProps()
|
|
|
|
{
|
|
|
|
// get property set
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSet(GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
|
|
|
|
if (xPSet.is())
|
|
|
|
{
|
|
|
|
// get position and size from properties
|
|
|
|
sal_Int32 nX, nY, nWidth, nHeight;
|
|
|
|
xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ) ) >>= nX;
|
|
|
|
xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ) ) >>= nY;
|
|
|
|
xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) >>= nWidth;
|
|
|
|
xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) >>= nHeight;
|
|
|
|
|
|
|
|
Size aPos( nX, nY );
|
|
|
|
Size aSize( nWidth, nHeight );
|
|
|
|
|
|
|
|
// convert logic units
|
|
|
|
OutputDevice* pDevice = Application::GetDefaultDevice();
|
|
|
|
DBG_ASSERT( pDevice, "Missing Default Device!" );
|
|
|
|
if( pDevice )
|
|
|
|
{
|
|
|
|
aPos = pDevice->LogicToPixel( aPos, MapMode(MAP_APPFONT) );
|
|
|
|
aPos = pDevice->PixelToLogic( aPos, MapMode(MAP_100TH_MM) );
|
|
|
|
aSize = pDevice->LogicToPixel( aSize, MapMode(MAP_APPFONT) );
|
|
|
|
aSize = pDevice->PixelToLogic( aSize, MapMode(MAP_100TH_MM) );
|
|
|
|
}
|
|
|
|
|
|
|
|
Point aPoint;
|
|
|
|
aPoint.X() = aPos.Width();
|
|
|
|
aPoint.Y() = aPos.Height();
|
|
|
|
|
|
|
|
if ( !ISA(DlgEdForm) )
|
|
|
|
{
|
|
|
|
Point aFormPos = (GetDlgEdForm()->GetSnapRect()).TopLeft();
|
|
|
|
aPoint += aFormPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set rectangle position and size
|
|
|
|
SetSnapRect( Rectangle( aPoint, aSize ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::SetPropsFromRect()
|
|
|
|
{
|
|
|
|
EndPropertyListening(sal_False);
|
|
|
|
|
|
|
|
// get property set
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSet(GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
|
|
|
|
if (xPSet.is())
|
|
|
|
{
|
|
|
|
// get position and size from rectangle
|
|
|
|
Rectangle aRect = GetSnapRect();
|
|
|
|
Point aPoint = aRect.TopLeft();
|
|
|
|
Size aSize = aRect.GetSize();
|
|
|
|
|
|
|
|
if ( !ISA(DlgEdForm) )
|
|
|
|
{
|
|
|
|
Point aFormPos = (GetDlgEdForm()->GetSnapRect()).TopLeft();
|
|
|
|
aPoint -= aFormPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
Size aPos;
|
|
|
|
aPos.Width() = aPoint.X();
|
|
|
|
aPos.Height() = aPoint.Y();
|
|
|
|
|
|
|
|
// convert logic units
|
|
|
|
OutputDevice* pDevice = Application::GetDefaultDevice();
|
|
|
|
DBG_ASSERT( pDevice, "Missing Default Device!" );
|
|
|
|
if( pDevice )
|
|
|
|
{
|
|
|
|
aPos = pDevice->LogicToPixel( aPos, MapMode(MAP_100TH_MM) );
|
|
|
|
aPos = pDevice->PixelToLogic( aPos, MapMode(MAP_APPFONT) );
|
|
|
|
aSize = pDevice->LogicToPixel( aSize, MapMode(MAP_100TH_MM) );
|
|
|
|
aSize = pDevice->PixelToLogic( aSize, MapMode(MAP_APPFONT) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// set properties
|
|
|
|
Any aValue;
|
|
|
|
aValue <<= aPos.Width();
|
|
|
|
xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ), aValue );
|
|
|
|
aValue <<= aPos.Height();
|
|
|
|
xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ), aValue );
|
|
|
|
aValue <<= aSize.Width();
|
|
|
|
xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Width" ) ), aValue );
|
|
|
|
aValue <<= aSize.Height();
|
|
|
|
xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Height" ) ), aValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
StartPropertyListening();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2001-03-01 08:50:51 +00:00
|
|
|
void SAL_CALL DlgEdObj::SetNameFromProp( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2001-03-02 13:02:06 +00:00
|
|
|
if ( !ISA(DlgEdForm) )
|
|
|
|
{
|
|
|
|
// get old name
|
|
|
|
::rtl::OUString aOldName;
|
|
|
|
evt.OldValue >>= aOldName;
|
2001-03-01 08:50:51 +00:00
|
|
|
|
2001-03-02 13:02:06 +00:00
|
|
|
// get new name
|
|
|
|
::rtl::OUString aNewName;
|
|
|
|
evt.NewValue >>= aNewName;
|
2001-03-01 08:50:51 +00:00
|
|
|
|
2001-03-02 13:02:06 +00:00
|
|
|
// remove the control by the old name and insert the control by the new name in the container
|
|
|
|
uno::Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), uno::UNO_QUERY);
|
|
|
|
if ( xNameAcc.is() && xNameAcc->hasByName(aOldName) )
|
2001-03-01 08:50:51 +00:00
|
|
|
{
|
2001-03-02 13:02:06 +00:00
|
|
|
uno::Reference< container::XNameContainer > xCont(xNameAcc, uno::UNO_QUERY );
|
|
|
|
if ( xCont.is() )
|
|
|
|
{
|
|
|
|
uno::Reference< awt::XControlModel > xCtrl(GetUnoControlModel(), uno::UNO_QUERY);
|
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= xCtrl;
|
|
|
|
xCont->removeByName( aOldName );
|
|
|
|
xCont->insertByName( aNewName , aAny );
|
|
|
|
}
|
2001-03-01 08:50:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
String DlgEdObj::GetDefaultName()
|
|
|
|
{
|
|
|
|
String aStr = GetUnoControlTypeName();
|
|
|
|
|
|
|
|
sal_Unicode pDelims[] = { '.' , 0 };
|
|
|
|
xub_StrLen nPos = aStr.SearchCharBackward( pDelims );
|
|
|
|
if( nPos != STRING_NOTFOUND )
|
|
|
|
{
|
|
|
|
aStr.Erase( 0, ++nPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
return aStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
String DlgEdObj::GetUniqueName()
|
|
|
|
{
|
|
|
|
String sUniqueName;
|
|
|
|
uno::Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), uno::UNO_QUERY);
|
|
|
|
|
|
|
|
if ( xNameAcc.is() )
|
|
|
|
{
|
|
|
|
sal_Int32 n = 0;
|
|
|
|
String sDefaultName = GetDefaultName();
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
sUniqueName = sDefaultName + String::CreateFromInt32(++n);
|
|
|
|
} while (xNameAcc->hasByName(sUniqueName));
|
|
|
|
}
|
|
|
|
|
|
|
|
return sUniqueName;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2001-02-26 09:47:06 +00:00
|
|
|
sal_uInt32 DlgEdObj::GetObjInventor() const
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
if( GetModel() && ((FmFormModel*)GetModel())->IsStreamingOldVersion() )
|
|
|
|
return SdrInventor;
|
|
|
|
return FmFormInventor;
|
|
|
|
*/
|
|
|
|
return VCSbxInventor;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_uInt16 DlgEdObj::GetObjIdentifier() const
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
if( GetModel() && ((FmFormModel*)GetModel())->IsStreamingOldVersion() )
|
|
|
|
return OBJ_RECT;
|
|
|
|
return OBJ_FM_CONTROL;
|
|
|
|
*/
|
|
|
|
return OBJ_FM_CONTROL; // change this
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::clonedFrom(const DlgEdObj* _pSource)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SdrObject* DlgEdObj::Clone() const
|
|
|
|
{
|
|
|
|
SdrObject* pReturn = SdrUnoObj::Clone();
|
|
|
|
|
|
|
|
DlgEdObj* pFormObject = PTR_CAST(DlgEdObj, pReturn);
|
|
|
|
DBG_ASSERT(pFormObject != NULL, "DlgEdObj::Clone : invalid clone !");
|
|
|
|
if (pFormObject)
|
|
|
|
pFormObject->clonedFrom(this);
|
|
|
|
|
|
|
|
return pReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SdrObject* DlgEdObj::Clone(SdrPage* _pPage, SdrModel* _pModel) const
|
|
|
|
{
|
|
|
|
SdrObject* pReturn = SdrUnoObj::Clone(_pPage, _pModel);
|
|
|
|
if (!pReturn)
|
|
|
|
return pReturn;
|
|
|
|
|
|
|
|
return pReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::operator= (const SdrObject& rObj)
|
|
|
|
{
|
|
|
|
SdrUnoObj::operator= (rObj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::WriteData(SvStream& rOut) const
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
FmFormModel* pModel = (FmFormModel*)GetModel();
|
|
|
|
if( pModel && pModel->IsStreamingOldVersion() )
|
|
|
|
{
|
|
|
|
SdrLayerID nOld = GetLayer();
|
|
|
|
((FmFormObj*)this)->NbcSetLayer( pModel->GetControlExportLayerId( *this ) );
|
|
|
|
SdrUnoObj::WriteData( rOut );
|
|
|
|
((FmFormObj*)this)->NbcSetLayer( nOld );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
SdrUnoObj::WriteData(rOut);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::ReadData(const SdrObjIOHeader& rHead, SvStream& rIn)
|
|
|
|
{
|
|
|
|
SdrUnoObj::ReadData(rHead,rIn);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::NbcMove( const Size& rSize )
|
|
|
|
{
|
|
|
|
SdrUnoObj::NbcMove( rSize );
|
|
|
|
SetPropsFromRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
|
|
|
|
{
|
|
|
|
SdrUnoObj::NbcResize( rRef, xFract, yFract );
|
|
|
|
SetPropsFromRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
FASTBOOL DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
|
|
|
|
{
|
|
|
|
sal_Bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
|
|
|
|
|
2001-03-02 13:02:06 +00:00
|
|
|
// set parent form
|
|
|
|
pDlgEdForm = ((DlgEdPage*)GetPage())->GetDlgEd()->GetDlgEdForm();
|
|
|
|
|
2001-03-01 08:50:51 +00:00
|
|
|
// get unique name
|
|
|
|
::rtl::OUString aOUniqueName( GetUniqueName() );
|
|
|
|
|
|
|
|
// set name property
|
|
|
|
uno::Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), uno::UNO_QUERY );
|
|
|
|
uno::Any aUniqueName;
|
|
|
|
aUniqueName <<= aOUniqueName;
|
|
|
|
xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), aUniqueName );
|
|
|
|
|
|
|
|
// set geometry properties
|
2001-02-26 09:47:06 +00:00
|
|
|
SetPropsFromRect();
|
|
|
|
|
2001-03-01 08:50:51 +00:00
|
|
|
// set labels
|
|
|
|
String sDefaultName = GetDefaultName();
|
|
|
|
if (sDefaultName.EqualsAscii("Button") ||
|
|
|
|
sDefaultName.EqualsAscii("RadioButton") ||
|
|
|
|
sDefaultName.EqualsAscii("CheckBox") ||
|
|
|
|
sDefaultName.EqualsAscii("GroupBox") ||
|
|
|
|
sDefaultName.EqualsAscii("FixedText") )
|
|
|
|
{
|
|
|
|
xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Label" ) ), aUniqueName );
|
|
|
|
}
|
|
|
|
|
2001-02-26 09:47:06 +00:00
|
|
|
// insert control model in dialog model
|
|
|
|
uno::Reference< container::XNameContainer > xC((GetDlgEdForm()->GetUnoControlModel()), uno::UNO_QUERY);
|
|
|
|
uno::Reference< awt::XControlModel > xCtrl(GetUnoControlModel(), uno::UNO_QUERY);
|
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= xCtrl;
|
2001-03-01 08:50:51 +00:00
|
|
|
xC->insertByName( aOUniqueName , aAny );
|
2001-02-26 09:47:06 +00:00
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPL_LINK(DlgEdObj, OnCreate, void*, EMPTYTAG)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
nEvent = 0;
|
|
|
|
if (pTempView)
|
|
|
|
pTempView->ObjectCreated(this);
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
if (isListening())
|
|
|
|
{
|
|
|
|
// set rectangle, if geometry information in the model changed
|
|
|
|
if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")) ||
|
|
|
|
evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")) ||
|
|
|
|
evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX")) ||
|
|
|
|
evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY")) )
|
|
|
|
{
|
|
|
|
SetRectFromProps();
|
|
|
|
}
|
2001-03-01 08:50:51 +00:00
|
|
|
else if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) )
|
|
|
|
{
|
|
|
|
SetNameFromProp(evt);
|
|
|
|
}
|
2001-02-26 09:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::StartPropertyListening()
|
|
|
|
{
|
|
|
|
DBG_ASSERT(!isListening(), "DlgEdObj::StartPropertyListening: already listening!");
|
|
|
|
|
|
|
|
if (!isListening())
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xControlModel(GetUnoControlModel(), UNO_QUERY);
|
|
|
|
|
|
|
|
if (!m_xListener.is() && xControlModel.is())
|
|
|
|
{
|
|
|
|
// create listener
|
2001-02-27 13:50:51 +00:00
|
|
|
m_xListener = static_cast< ::com::sun::star::beans::XPropertyChangeListener*>( new DlgEdListenerImpl( (DlgEdObj*)this ) );
|
2001-02-26 09:47:06 +00:00
|
|
|
|
|
|
|
// register listener to properties
|
|
|
|
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), m_xListener);
|
|
|
|
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")), m_xListener);
|
|
|
|
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX")), m_xListener);
|
|
|
|
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY")), m_xListener);
|
2001-03-01 08:50:51 +00:00
|
|
|
xControlModel->addPropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), m_xListener);
|
2001-02-26 09:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bIsListening = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DlgEdObj::EndPropertyListening(sal_Bool bRemoveListener)
|
|
|
|
{
|
|
|
|
DBG_ASSERT(isListening(), "DlgEdObj::EndPropertyListening: not listening currently!");
|
|
|
|
|
|
|
|
if (isListening())
|
|
|
|
{
|
|
|
|
bIsListening = sal_False;
|
|
|
|
|
|
|
|
if (bRemoveListener)
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xControlModel(GetUnoControlModel(), UNO_QUERY);
|
|
|
|
if (m_xListener.is() && xControlModel.is())
|
|
|
|
{
|
|
|
|
// remove listener
|
|
|
|
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), m_xListener);
|
|
|
|
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height")), m_xListener);
|
|
|
|
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX")), m_xListener);
|
|
|
|
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY")), m_xListener);
|
2001-03-01 08:50:51 +00:00
|
|
|
xControlModel->removePropertyChangeListener(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), m_xListener);
|
2001-02-26 09:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_xListener.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
TYPEINIT1(DlgEdForm, DlgEdObj);
|
|
|
|
DBG_NAME(DlgEdForm);
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DlgEdForm::DlgEdForm(const ::rtl::OUString& rModelName)
|
|
|
|
:DlgEdObj(rModelName)
|
|
|
|
{
|
|
|
|
DBG_CTOR(DlgEdForm, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DlgEdForm::DlgEdForm(const ::rtl::OUString& rModelName,
|
|
|
|
const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac)
|
|
|
|
:DlgEdObj(rModelName, rxSFac)
|
|
|
|
{
|
|
|
|
DBG_CTOR(DlgEdForm, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DlgEdForm::DlgEdForm()
|
|
|
|
:DlgEdObj()
|
|
|
|
{
|
|
|
|
DBG_CTOR(DlgEdForm, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DlgEdForm::~DlgEdForm()
|
|
|
|
{
|
|
|
|
DBG_DTOR(DlgEdForm, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SdrObject* DlgEdForm::CheckHit( const Point& rPnt, USHORT nTol,
|
|
|
|
const SetOfByte* pSet ) const
|
|
|
|
{
|
|
|
|
Rectangle aROuter = aOutRect;
|
|
|
|
aROuter.Left() -= nTol;
|
|
|
|
aROuter.Right() += nTol;
|
|
|
|
aROuter.Top() -= nTol;
|
|
|
|
aROuter.Bottom() += nTol;
|
|
|
|
|
|
|
|
Rectangle aRInner = aOutRect;
|
|
|
|
if( (aRInner.GetSize().Height() > (long)nTol*2) &&
|
|
|
|
(aRInner.GetSize().Width() > (long)nTol*2) )
|
|
|
|
{
|
|
|
|
aRInner.Left() += nTol;
|
|
|
|
aRInner.Right() -= nTol;
|
|
|
|
aRInner.Top() += nTol;
|
|
|
|
aRInner.Bottom() -= nTol;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aROuter.IsInside( rPnt ) && !aRInner.IsInside( rPnt ) )
|
|
|
|
return (SdrObject*)this;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
FASTBOOL DlgEdForm::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
|
|
|
|
{
|
|
|
|
sal_Bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
|
|
|
|
|
|
|
|
SetPropsFromRect();
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|