Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __FRAMEWORK_PATTERN_WINDOW_HXX_
30 : : #define __FRAMEWORK_PATTERN_WINDOW_HXX_
31 : :
32 : : #include <general.h>
33 : :
34 : : #include <com/sun/star/awt/XWindow.hpp>
35 : : #include <com/sun/star/awt/XTopWindow.hpp>
36 : :
37 : : #include <toolkit/unohlp.hxx>
38 : : #include <vcl/window.hxx>
39 : : #include <vcl/syswin.hxx>
40 : : #include <vcl/wrkwin.hxx>
41 : : #include <vcl/svapp.hxx>
42 : : #include <osl/mutex.hxx>
43 : : #include <rtl/ustring.hxx>
44 : :
45 : : //_______________________________________________
46 : : // namespaces
47 : :
48 : : #ifndef css
49 : : namespace css = ::com::sun::star;
50 : : #endif
51 : :
52 : : namespace framework{
53 : :
54 : :
55 : : class WindowHelper
56 : : {
57 : : public:
58 : :
59 : : //-----------------------------------------------
60 : : static ::rtl::OUString getWindowState(const css::uno::Reference< css::awt::XWindow >& xWindow)
61 : : {
62 : : if (!xWindow.is())
63 : : return ::rtl::OUString();
64 : :
65 : : rtl::OString sWindowState;
66 : : // SOLAR SAFE -> ----------------------------
67 : : {
68 : : SolarMutexGuard aSolarGuard;
69 : :
70 : : Window* pWindow = VCLUnoHelper::GetWindow(xWindow);
71 : : // check for system window is neccessary to guarantee correct pointer cast!
72 : : if (pWindow!=NULL && pWindow->IsSystemWindow())
73 : : {
74 : : sal_uLong nMask = WINDOWSTATE_MASK_ALL;
75 : : nMask &= ~(WINDOWSTATE_MASK_MINIMIZED);
76 : : sWindowState = ((SystemWindow*)pWindow)->GetWindowState(nMask);
77 : : }
78 : : }
79 : : // <- SOLAR SAFE ----------------------------
80 : :
81 : : return rtl::OStringToOUString(sWindowState,RTL_TEXTENCODING_UTF8);
82 : : }
83 : :
84 : : //-----------------------------------------------
85 : : static void setWindowState(const css::uno::Reference< css::awt::XWindow >& xWindow ,
86 : : const ::rtl::OUString& sWindowState)
87 : : {
88 : : if (
89 : : (!xWindow.is() ) ||
90 : : (!sWindowState.getLength())
91 : : )
92 : : return;
93 : :
94 : : // SOLAR SAFE -> ----------------------------
95 : : SolarMutexGuard aSolarGuard;
96 : :
97 : : Window* pWindow = VCLUnoHelper::GetWindow(xWindow);
98 : : // check for system window is neccessary to guarantee correct pointer cast!
99 : : if (
100 : : (pWindow ) &&
101 : : (pWindow->IsSystemWindow()) &&
102 : : (
103 : : // dont overwrite a might existing minimized mode!
104 : : (pWindow->GetType() != WINDOW_WORKWINDOW) ||
105 : : (!((WorkWindow*)pWindow)->IsMinimized() )
106 : : )
107 : : )
108 : : {
109 : : ((SystemWindow*)pWindow)->SetWindowState(OUStringToOString(sWindowState,RTL_TEXTENCODING_UTF8));
110 : : }
111 : :
112 : : // <- SOLAR SAFE ----------------------------
113 : : }
114 : :
115 : : //-----------------------------------------------
116 : 1358 : static ::sal_Bool isTopWindow(const css::uno::Reference< css::awt::XWindow >& xWindow)
117 : : {
118 : : // even child frame containing top level windows (e.g. query designer of database) will be closed
119 [ + - ]: 1358 : css::uno::Reference< css::awt::XTopWindow > xTopWindowCheck(xWindow, css::uno::UNO_QUERY);
120 [ + - ]: 1358 : if (xTopWindowCheck.is())
121 : : {
122 : : // Note: Toolkit interface XTopWindow sometimes is used by real VCL-child-windows also .-)
123 : : // Be sure that these window is realy a "top system window".
124 : : // Attention ! Checking Window->GetParent() isnt the right approach here.
125 : : // Because sometimes VCL create "implicit border windows" as parents even we created
126 : : // a simple XWindow using the toolkit only .-(
127 [ + - ]: 1358 : SolarMutexGuard aSolarGuard;
128 [ + - ]: 1358 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
129 [ + - ][ + + ]: 2716 : if (
[ + + ]
130 : : (pWindow ) &&
131 [ + - ]: 1358 : (pWindow->IsSystemWindow())
132 : : )
133 [ + - ][ + + ]: 1358 : return sal_True;
134 : : }
135 : :
136 : 1358 : return sal_False;
137 : : }
138 : :
139 : : };
140 : :
141 : : } // namespace framework
142 : :
143 : : #endif // __FRAMEWORK_PATTERN_WINDOW_HXX_
144 : :
145 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|