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 #ifndef INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_WINDOW_HXX 21 #define INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_WINDOW_HXX 22 23 #include <com/sun/star/awt/XWindow.hpp> 24 #include <com/sun/star/awt/XTopWindow.hpp> 25 26 #include <toolkit/helper/vclunohelper.hxx> 27 #include <vcl/window.hxx> 28 #include <vcl/svapp.hxx> 29 30 // namespaces 31 32 namespace framework{ 33 34 class WindowHelper 35 { 36 public: 37 38 isTopWindow(const css::uno::Reference<css::awt::XWindow> & xWindow)39static bool isTopWindow(const css::uno::Reference< css::awt::XWindow >& xWindow) 40 { 41 // even child frame containing top level windows (e.g. query designer of database) will be closed 42 css::uno::Reference< css::awt::XTopWindow > xTopWindowCheck(xWindow, css::uno::UNO_QUERY); 43 if (xTopWindowCheck.is()) 44 { 45 // Note: Toolkit interface XTopWindow sometimes is used by real VCL-child-windows also .-) 46 // Be sure that these window is really a "top system window". 47 // Attention ! Checking Window->GetParent() is not the right approach here. 48 // Because sometimes VCL create "implicit border windows" as parents even we created 49 // a simple XWindow using the toolkit only .-( 50 SolarMutexGuard aSolarGuard; 51 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); 52 if ( pWindow && pWindow->IsSystemWindow() ) 53 return true; 54 } 55 56 return false; 57 } 58 59 }; 60 61 } // namespace framework 62 63 #endif // INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_WINDOW_HXX 64 65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 66