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

View File

@@ -1004,81 +1004,25 @@ UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComp
//--------------------------------------------- //---------------------------------------------
double UserFormGeometryHelper::getLeft() 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; return mxWindow->getPosSize().X;
} }
//--------------------------------------------- //---------------------------------------------
void UserFormGeometryHelper::setLeft( double nLeft ) void UserFormGeometryHelper::setLeft( double nLeft )
{ {
sal_Int64 nNewLeft = nLeft; mxWindow->setPosSize( nLeft, 0, 0, 0, awt::PosSize::X );
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 );
} }
//--------------------------------------------- //---------------------------------------------
double UserFormGeometryHelper::getTop() 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; return mxWindow->getPosSize().Y;
} }
//--------------------------------------------- //---------------------------------------------
void UserFormGeometryHelper::setTop( double nTop ) void UserFormGeometryHelper::setTop( double nTop )
{ {
sal_Int64 nNewTop = nTop; mxWindow->setPosSize( 0, nTop, 0, 0, awt::PosSize::Y );
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 );
} }
//--------------------------------------------- //---------------------------------------------