mib19: #i163287# fix the dialog position handling, change position after the dialog has been started

This commit is contained in:
Mikhail Voytenko
2010-08-27 15:51:26 +02:00
parent 6e9b786ff6
commit 99523481ef
2 changed files with 3 additions and 59 deletions

View File

@@ -69,6 +69,7 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException)
if ( m_xDialog.is() )
{
aRet = m_xDialog->execute();
// try to center dialog on model window
if( m_xModel.is() ) try
{
@@ -82,7 +83,6 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException)
catch( uno::Exception& )
{
}
aRet = m_xDialog->execute();
}
OSL_TRACE("ScVbaUserForm::Show() execute returned %d", aRet);
if ( mbDispose )

View File

@@ -1004,81 +1004,25 @@ UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComp
//---------------------------------------------
double UserFormGeometryHelper::getLeft()
{
if ( mbDialog )
{
const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
if ( pWindow )
{
// get the size with decoration
Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL );
return aResult.getX();
}
}
return mxWindow->getPosSize().X;
}
//---------------------------------------------
void UserFormGeometryHelper::setLeft( double nLeft )
{
sal_Int64 nNewLeft = nLeft;
if ( mbDialog )
{
const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
if ( pWindow )
{
// set the size with decoration
Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL );
if ( !aRDecor.IsEmpty() )
{
sal_Int64 nDecor = aRDecor.getX();
sal_Int64 nUnDecor = mxWindow->getPosSize().X;
nNewLeft = nLeft + nUnDecor - nDecor;
}
}
}
mxWindow->setPosSize( nNewLeft, 0, 0, 0, awt::PosSize::X );
mxWindow->setPosSize( nLeft, 0, 0, 0, awt::PosSize::X );
}
//---------------------------------------------
double UserFormGeometryHelper::getTop()
{
if ( mbDialog )
{
const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
if ( pWindow )
{
// get the size with decoration
Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL );
return aResult.getY();
}
}
return mxWindow->getPosSize().Y;
}
//---------------------------------------------
void UserFormGeometryHelper::setTop( double nTop )
{
sal_Int64 nNewTop = nTop;
if ( mbDialog )
{
const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
if ( pWindow )
{
// set the size with decoration
Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL );
if ( !aRDecor.IsEmpty() )
{
sal_Int64 nDecor = aRDecor.getY();
sal_Int64 nUnDecor = mxWindow->getPosSize().Y;
nNewTop = nTop + nUnDecor - nDecor;
}
}
}
mxWindow->setPosSize( 0, nNewTop, 0, 0, awt::PosSize::Y );
mxWindow->setPosSize( 0, nTop, 0, 0, awt::PosSize::Y );
}
//---------------------------------------------