/src/libreoffice/framework/source/inc/pattern/window.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <com/sun/star/awt/XWindow.hpp> |
23 | | #include <com/sun/star/awt/XTopWindow.hpp> |
24 | | |
25 | | #include <toolkit/helper/vclunohelper.hxx> |
26 | | #include <vcl/window.hxx> |
27 | | #include <vcl/svapp.hxx> |
28 | | |
29 | | // namespaces |
30 | | |
31 | | namespace framework{ |
32 | | |
33 | | class WindowHelper |
34 | | { |
35 | | public: |
36 | | |
37 | | |
38 | | static bool isTopWindow(const css::uno::Reference< css::awt::XWindow >& xWindow) |
39 | 4.57k | { |
40 | | // even child frame containing top level windows (e.g. query designer of database) will be closed |
41 | 4.57k | css::uno::Reference< css::awt::XTopWindow > xTopWindowCheck(xWindow, css::uno::UNO_QUERY); |
42 | 4.57k | if (xTopWindowCheck.is()) |
43 | 4.57k | { |
44 | | // Note: Toolkit interface XTopWindow sometimes is used by real VCL-child-windows also .-) |
45 | | // Be sure that these window is really a "top system window". |
46 | | // Attention ! Checking Window->GetParent() is not the right approach here. |
47 | | // Because sometimes VCL create "implicit border windows" as parents even we created |
48 | | // a simple XWindow using the toolkit only .-( |
49 | 4.57k | SolarMutexGuard aSolarGuard; |
50 | 4.57k | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); |
51 | 4.57k | if ( pWindow && pWindow->IsSystemWindow() ) |
52 | 4.57k | return true; |
53 | 4.57k | } |
54 | | |
55 | 0 | return false; |
56 | 4.57k | } |
57 | | |
58 | | }; |
59 | | |
60 | | } // namespace framework |
61 | | |
62 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |