summaryrefslogtreecommitdiff
path: root/framework/source/dispatch/closedispatcher.cxx
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2007-04-16 15:37:38 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2007-04-16 15:37:38 +0000
commit257697d049be392de11f9fa061edfa9d5a3481bd (patch)
treeb4f53f56c9dd266f9a8b1f4fd4ca28a8d73f4ea0 /framework/source/dispatch/closedispatcher.cxx
parent33b7f723ba413e1aa8c0ca44b7df3f55429eb532 (diff)
INTEGRATION: CWS fwkdbdesign01 (1.15.78); FILE MERGED
2007/03/29 06:26:44 as 1.15.78.2: #i75596#, #i75591# let close dispatcher decide which frame will be closed 2007/02/14 14:26:22 as 1.15.78.1: #i74541# new API (and some small code changes) to support real sub frames greater level 1
Diffstat (limited to 'framework/source/dispatch/closedispatcher.cxx')
-rw-r--r--framework/source/dispatch/closedispatcher.cxx71
1 files changed, 64 insertions, 7 deletions
diff --git a/framework/source/dispatch/closedispatcher.cxx b/framework/source/dispatch/closedispatcher.cxx
index a2dceea74e1a..7a10d1800e93 100644
--- a/framework/source/dispatch/closedispatcher.cxx
+++ b/framework/source/dispatch/closedispatcher.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: closedispatcher.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: obo $ $Date: 2006-10-13 09:42:39 $
+ * last change: $Author: ihi $ $Date: 2007-04-16 16:37:38 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -82,12 +82,20 @@
#include <com/sun/star/frame/CommandGroup.hpp>
#endif
+#ifndef __COM_SUN_STAR_AWT_XTOPWINDOW_HPP_
+#include <com/sun/star/awt/XTopWindow.hpp>
+#endif
+
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+
//_______________________________________________
// includes of other projects
-#ifndef _SV_SVAPP_HXX
+#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
-#endif
+#include <vos/mutex.hxx>
//_______________________________________________
// namespace
@@ -124,15 +132,16 @@ DEFINE_XTYPEPROVIDER_4(CloseDispatcher ,
css::frame::XDispatch )
//-----------------------------------------------
-CloseDispatcher::CloseDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
- const css::uno::Reference< css::frame::XFrame >& xCloseFrame)
+CloseDispatcher::CloseDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
+ const css::uno::Reference< css::frame::XFrame >& xFrame ,
+ const ::rtl::OUString& sTarget)
: ThreadHelpBase (&Application::GetSolarMutex() )
, ::cppu::OWeakObject( )
, m_xSMGR (xSMGR )
- , m_xCloseFrame (xCloseFrame )
, m_aAsyncCallback (LINK( this, CloseDispatcher, impl_asyncCallback))
, m_lStatusListener (m_aLock.getShareableOslMutex() )
{
+ m_xCloseFrame = CloseDispatcher::static_impl_searchRightTargetFrame(xFrame, sTarget);
}
//-----------------------------------------------
@@ -380,6 +389,7 @@ IMPL_LINK( CloseDispatcher, impl_asyncCallback, void*, EMPTYARG )
)
bCloseFrame = sal_True;
+ else
// c3) there is no other (visible) frame open ...
// The help module will be ignored everytimes!
// But we have to decide if we must terminate the
@@ -577,4 +587,51 @@ void CloseDispatcher::implts_notifyResultListener(const css::uno::Reference< css
xListener->dispatchFinished(aEvent);
}
+//-----------------------------------------------
+css::uno::Reference< css::frame::XFrame > CloseDispatcher::static_impl_searchRightTargetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame ,
+ const ::rtl::OUString& sTarget)
+{
+ if (sTarget.equalsIgnoreAsciiCaseAscii("_self"))
+ return xFrame;
+
+ OSL_ENSURE((sTarget.getLength() < 1), "CloseDispatch used for unexpected target. Magic things will happen now .-)");
+
+ css::uno::Reference< css::frame::XFrame > xTarget = xFrame;
+ while(sal_True)
+ {
+ // a) top frames wil be closed
+ if (xTarget->isTop())
+ return xTarget;
+
+ // b) even child frame containing top level windows (e.g. query designer of database) will be closed
+ css::uno::Reference< css::awt::XWindow > xWindow = xTarget->getContainerWindow();
+ css::uno::Reference< css::awt::XTopWindow > xTopWindowCheck(xWindow, css::uno::UNO_QUERY);
+ if (xTopWindowCheck.is())
+ {
+ // b1) Note: Toolkit interface XTopWindow sometimes is used by real VCL-child-windows also .-)
+ // Be sure that these window is realy a "top system window".
+ // Attention ! Checking Window->GetParent() isnt the right approach here.
+ // Because sometimes VCL create "implicit border windows" as parents even we created
+ // a simple XWindow using the toolkit only .-(
+ ::vos::OGuard aSolarLock(&Application::GetSolarMutex());
+ Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+ if (
+ (pWindow ) &&
+ (pWindow->IsSystemWindow())
+ )
+ return xTarget;
+ }
+
+ // c) try to find better results on parent frame
+ // If no parent frame exists (because this frame is used outside the desktop tree)
+ // the given frame must be used directly.
+ css::uno::Reference< css::frame::XFrame > xParent(xTarget->getCreator(), css::uno::UNO_QUERY);
+ if ( ! xParent.is())
+ return xTarget;
+
+ // c1) check parent frame inside next loop ...
+ xTarget = xParent;
+ }
+}
+
} // namespace framework