1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_WINDOW_HXX
21 #define INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_WINDOW_HXX
25 #include <com/sun/star/awt/XWindow.hpp>
26 #include <com/sun/star/awt/XTopWindow.hpp>
28 #include <toolkit/helper/vclunohelper.hxx>
29 #include <vcl/window.hxx>
30 #include <vcl/syswin.hxx>
31 #include <vcl/wrkwin.hxx>
32 #include <vcl/svapp.hxx>
33 #include <osl/mutex.hxx>
34 #include <rtl/ustring.hxx>
44 static OUString
getWindowState(const css::uno::Reference
< css::awt::XWindow
>& xWindow
)
50 // SOLAR SAFE -> ----------------------------
52 SolarMutexGuard aSolarGuard
;
54 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow(xWindow
);
55 // check for system window is necessary to guarantee correct pointer cast!
56 if (pWindow
!=NULL
&& pWindow
->IsSystemWindow())
58 sal_uLong nMask
= WINDOWSTATE_MASK_ALL
;
59 nMask
&= ~(WINDOWSTATE_MASK_MINIMIZED
);
60 sWindowState
= static_cast<SystemWindow
*>(pWindow
)->GetWindowState(nMask
);
63 // <- SOLAR SAFE ----------------------------
65 return OStringToOUString(sWindowState
,RTL_TEXTENCODING_UTF8
);
68 static void setWindowState(const css::uno::Reference
< css::awt::XWindow
>& xWindow
,
69 const OUString
& sWindowState
)
73 (!sWindowState
.getLength())
77 // SOLAR SAFE -> ----------------------------
78 SolarMutexGuard aSolarGuard
;
80 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow(xWindow
);
81 // check for system window is necessary to guarantee correct pointer cast!
84 (pWindow
->IsSystemWindow()) &&
86 // dont overwrite a might existing minimized mode!
87 (pWindow
->GetType() != WINDOW_WORKWINDOW
) ||
88 (!static_cast<WorkWindow
*>(pWindow
)->IsMinimized() )
92 static_cast<SystemWindow
*>(pWindow
)->SetWindowState(OUStringToOString(sWindowState
,RTL_TEXTENCODING_UTF8
));
95 // <- SOLAR SAFE ----------------------------
98 static bool isTopWindow(const css::uno::Reference
< css::awt::XWindow
>& xWindow
)
100 // even child frame containing top level windows (e.g. query designer of database) will be closed
101 css::uno::Reference
< css::awt::XTopWindow
> xTopWindowCheck(xWindow
, css::uno::UNO_QUERY
);
102 if (xTopWindowCheck
.is())
104 // Note: Toolkit interface XTopWindow sometimes is used by real VCL-child-windows also .-)
105 // Be sure that these window is really a "top system window".
106 // Attention ! Checking Window->GetParent() is not the right approach here.
107 // Because sometimes VCL create "implicit border windows" as parents even we created
108 // a simple XWindow using the toolkit only .-(
109 SolarMutexGuard aSolarGuard
;
110 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
113 (pWindow
->IsSystemWindow())
123 } // namespace framework
125 #endif // INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_WINDOW_HXX
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */