1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: window.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_PATTERN_WINDOW_HXX_
32 #define __FRAMEWORK_PATTERN_WINDOW_HXX_
34 //_______________________________________________
39 //_______________________________________________
41 #include <com/sun/star/awt/XWindow.hpp>
42 #include <com/sun/star/awt/XTopWindow.hpp>
44 //_______________________________________________
47 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
48 #include <toolkit/unohlp.hxx>
50 #include <vcl/window.hxx>
51 #include <vcl/syswin.hxx>
52 #include <vcl/wrkwin.hxx>
53 #include <vcl/svapp.hxx>
54 #include <vos/mutex.hxx>
55 #include <rtl/ustring.hxx>
57 //_______________________________________________
61 namespace css
= ::com::sun::star
;
66 //_______________________________________________
73 //-----------------------------------------------
74 static ::rtl::OUString
getWindowState(const css::uno::Reference
< css::awt::XWindow
>& xWindow
)
77 return ::rtl::OUString();
79 // SOLAR SAFE -> ----------------------------
80 ::vos::OClearableGuard
aSolarGuard(Application::GetSolarMutex());
82 ByteString sWindowState
;
83 Window
* pWindow
= VCLUnoHelper::GetWindow(xWindow
);
84 // check for system window is neccessary to guarantee correct pointer cast!
85 if (pWindow
!=NULL
&& pWindow
->IsSystemWindow())
87 ULONG nMask
= WINDOWSTATE_MASK_ALL
;
88 nMask
&= ~(WINDOWSTATE_MASK_MINIMIZED
);
89 sWindowState
= ((SystemWindow
*)pWindow
)->GetWindowState(nMask
);
93 // <- SOLAR SAFE ----------------------------
95 return B2U_ENC(sWindowState
,RTL_TEXTENCODING_UTF8
);
98 //-----------------------------------------------
99 static void setWindowState(const css::uno::Reference
< css::awt::XWindow
>& xWindow
,
100 const ::rtl::OUString
& sWindowState
)
104 (!sWindowState
.getLength())
108 // SOLAR SAFE -> ----------------------------
109 ::vos::OClearableGuard
aSolarGuard(Application::GetSolarMutex());
111 Window
* pWindow
= VCLUnoHelper::GetWindow(xWindow
);
112 // check for system window is neccessary to guarantee correct pointer cast!
115 (pWindow
->IsSystemWindow()) &&
117 // dont overwrite a might existing minimized mode!
118 (pWindow
->GetType() != WINDOW_WORKWINDOW
) ||
119 (!((WorkWindow
*)pWindow
)->IsMinimized() )
123 ((SystemWindow
*)pWindow
)->SetWindowState(U2B_ENC(sWindowState
,RTL_TEXTENCODING_UTF8
));
127 // <- SOLAR SAFE ----------------------------
130 //-----------------------------------------------
131 static ::sal_Bool
isTopWindow(const css::uno::Reference
< css::awt::XWindow
>& xWindow
)
133 // even child frame containing top level windows (e.g. query designer of database) will be closed
134 css::uno::Reference
< css::awt::XTopWindow
> xTopWindowCheck(xWindow
, css::uno::UNO_QUERY
);
135 if (xTopWindowCheck
.is())
137 // Note: Toolkit interface XTopWindow sometimes is used by real VCL-child-windows also .-)
138 // Be sure that these window is realy a "top system window".
139 // Attention ! Checking Window->GetParent() isnt the right approach here.
140 // Because sometimes VCL create "implicit border windows" as parents even we created
141 // a simple XWindow using the toolkit only .-(
142 ::vos::OGuard
aSolarLock(&Application::GetSolarMutex());
143 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
146 (pWindow
->IsSystemWindow())
156 } // namespace framework
158 #endif // __FRAMEWORK_PATTERN_WINDOW_HXX_