diff -urNpw @embeddedobj/source/general/docholder.cxx embeddedobj/source/general/docholder.cxx --- @embeddedobj/source/general/docholder.cxx 2007-07-30 12:42:04.000000000 +0800 +++ embeddedobj/source/general/docholder.cxx 2007-11-08 13:26:26.000000000 +0800 @@ -162,6 +162,9 @@ #ifndef _COM_SUN_STAR_EMBED_STATECHANGEINPROGRESSEXCEPTION_HPP_ #include #endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include +#endif #include #include @@ -271,13 +274,17 @@ DocumentHolder::DocumentHolder( const un m_nNoBorderResizeReact( 0 ), m_nNoResizeReact( 0 ) { - m_aOutplaceFrameProps.realloc( 2 ); + m_aOutplaceFrameProps.realloc( 3 ); beans::NamedValue aArg; aArg.Name = ::rtl::OUString::createFromAscii("TopWindow"); aArg.Value <<= sal_True; m_aOutplaceFrameProps[0] <<= aArg; + aArg.Name = ::rtl::OUString::createFromAscii("MakeVisible"); + aArg.Value <<= sal_False; + m_aOutplaceFrameProps[1] <<= aArg; + const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) ); uno::Reference< frame::XDesktop > xDesktop( m_xFactory->createInstance( aServiceName ), uno::UNO_QUERY ); if ( xDesktop.is() ) @@ -294,10 +301,10 @@ DocumentHolder::DocumentHolder( const un aArg.Name = ::rtl::OUString::createFromAscii("ParentFrame"); aArg.Value <<= xDesktop; //TODO/LATER: should use parent document frame - m_aOutplaceFrameProps[1] <<= aArg; + m_aOutplaceFrameProps[2] <<= aArg; } else - m_aOutplaceFrameProps.realloc( 1 ); + m_aOutplaceFrameProps.realloc( 2 ); } //--------------------------------------------------------------------------- @@ -1025,6 +1032,42 @@ uno::Reference< frame::XFrame > Document xOwnLM->unlock(); } + try + { + uno::Reference< awt::XWindow > xHWindow = m_xFrame->getContainerWindow(); + + if( xHWindow.is() ) + { + uno::Reference< beans::XPropertySet > xMonProps( m_xFactory->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess" ) ) ), uno::UNO_QUERY_THROW ); + const rtl::OUString sPropName( RTL_CONSTASCII_USTRINGPARAM( "DefaultDisplay" ) ); + sal_Int32 nDisplay = 0; + xMonProps->getPropertyValue( sPropName ) >>= nDisplay; + + uno::Reference< container::XIndexAccess > xMultiMon( xMonProps, uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xMonitor( xMultiMon->getByIndex( nDisplay ), uno::UNO_QUERY_THROW ); + awt::Rectangle aWorkRect; + xMonitor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WorkArea" ) ) ) >>= aWorkRect; + awt::Rectangle aWindowRect = xHWindow->getPosSize(); + + if (( aWindowRect.Width < aWorkRect.Width) && ( aWindowRect.Height < aWorkRect.Height )) + { + int OffsetX = ( aWorkRect.Width - aWindowRect.Width ) / 2 + aWorkRect.X; + int OffsetY = ( aWorkRect.Height - aWindowRect.Height ) /2 + aWorkRect.Y; + xHWindow->setPosSize( OffsetX, OffsetY, aWindowRect.Width, aWindowRect.Height, awt::PosSize::POS ); + } + else + { + xHWindow->setPosSize( aWorkRect.X, aWorkRect.Y, aWorkRect.Width, aWorkRect.Height, awt::PosSize::POSSIZE ); + } + + xHWindow->setVisible( sal_True ); + } + } + catch ( uno::Exception& ) + { + } + return m_xFrame; }