summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorMichael E. Bohn <mbn@openoffice.org>2010-08-24 13:30:45 +0200
committerMichael E. Bohn <mbn@openoffice.org>2010-08-24 13:30:45 +0200
commite006704bd75e642edbed5c3bd33d7c3d24ef38a1 (patch)
treeb7c656301e33146941ada530f86a580c3760d2ce /vbahelper
parent586a71afdb0bed549f59eeb9b8b1fbf7290c8f0d (diff)
parent3a174f37ece7030171f7ca4907bccfaf065ccf5c (diff)
merged heads
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/source/msforms/vbauserform.cxx19
1 files changed, 18 insertions, 1 deletions
diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx
index a1333e0a655b..ae0ecce0a955 100644
--- a/vbahelper/source/msforms/vbauserform.cxx
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/awt/XControlContainer.hpp>
#include <com/sun/star/beans/PropertyConcept.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
#include <basic/sbx.hxx>
#include <basic/sbstar.hxx>
#include <basic/sbmeth.hxx>
@@ -64,9 +65,25 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException)
{
OSL_TRACE("ScVbaUserForm::Show( )");
short aRet = 0;
- mbDispose = true;
+ mbDispose = true;
+
if ( m_xDialog.is() )
+ {
+ // try to center dialog on model window
+ if( m_xModel.is() ) try
+ {
+ uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_SET_THROW );
+ uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
+ uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
+ awt::Rectangle aPosSize = xWindow->getPosSize(); // already in pixel
+ setLeft( (aPosSize.Width - getWidth()) / 2.0 );
+ setTop( (aPosSize.Height - getHeight()) / 2.0 );
+ }
+ catch( uno::Exception& )
+ {
+ }
aRet = m_xDialog->execute();
+ }
OSL_TRACE("ScVbaUserForm::Show() execute returned %d", aRet);
if ( mbDispose )
{