Hi Mikhail,

Thanks for your suggestions, I am sorry for ignoring the cases you mentioned in the last patch, and I am looking forward to further suggestions from you on this new patch.

This time I have some questions:
- Could you give me some explanations on XWindow::setPosSize() method, and the position of it's implementation please? There are something I don't quite understand about it, like: - Are all parameters not covered by the flag, e.g. WIDTH and HEIGHT for POS, totally ignored by the method? - I tried to test the method by giving it fixed numbers as parameters, when a size bigger than the working area is given in the parameters, the method acts as if it just ignores the parameter and defaultedly sets the window's position and size to the same as WorkArea , is that true the method is designed this way?
- Should we handle the case when the container window reference IS empty?
- What is the difference between ScreenArea and WorkArea?

And there is a little problem with the implementation, even after the window is adjusted according to WorkArea, e.g. in 1024x768 or a lower resolution in Windows XP, as in the patch:
=======================================
xHWindow->setPosSize( aWorkRect.X, aWorkRect.Y, aWorkRect.Width, aWorkRect.Height, awt::PosSize::POSSIZE );
---------------------------------------
it is still slightly bigger than WorkArea, the bottom and right borders are out of the screen, and part of the toolbar and the statusbar to the bottom are not visible in WorkArea. I tried to set it to a smaller rectangle, but keeping the bottom and right borders at the same postions:
=======================================
const long nIncre;
xHWindow->setPosSize( aWorkRect.X + nIncre, aWorkRect.Y + nIncre, aWorkRect.Width - nIncre, aWorkRect.Height - nIncre, awt::PosSize::POSSIZE );
---------------------------------------
to my surprise when nIncre is big enough(say, 200), the problem above disappears, however, when it is small(say, 10, or worse, 0), the problem appears. I'm confused about the phenomenon, could you help me to analyze it please?

Best Regards,
Felix.


Mikhail Voitenko 写道:
Hi Felix,

The patch looks good. Sorry, I have forgot to mention, the window size should be checked whether it is smaller than WorkArea, otherwise the window should get the size of the WorkArea and be moved to the top-left corner of the WorkArea.

Additionally, there are some small changes that probably could make sense: - there is no need to create the DisplayAccess service second time, it is just enough to get the required interface from the existing instance - it probably could make sense to check whether the container window reference is not empty

Best Regards,
Mikhail.

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 <com/sun/star/embed/StateChangeInProgressException.hpp>
 #endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
 
 #include <com/sun/star/embed/EmbedMisc.hpp>
 #include <com/sun/star/embed/EmbedStates.hpp>
@@ -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 );
+        }
+        else
+        {
+        }
+    }
+    catch ( uno::Exception& )
+    {          
+    }
+    
        return m_xFrame;
 }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to