LCOV - code coverage report
Current view: top level - libreoffice/framework/source/inc/pattern - window.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 9 88.9 %
Date: 2012-12-27 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 __FRAMEWORK_PATTERN_WINDOW_HXX_
      21             : #define __FRAMEWORK_PATTERN_WINDOW_HXX_
      22             : 
      23             : #include <general.h>
      24             : 
      25             : #include <com/sun/star/awt/XWindow.hpp>
      26             : #include <com/sun/star/awt/XTopWindow.hpp>
      27             : 
      28             : #include <toolkit/unohlp.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>
      35             : 
      36             : //_______________________________________________
      37             : // namespaces
      38             : 
      39             : namespace framework{
      40             : 
      41             : 
      42             : class WindowHelper
      43             : {
      44             :     public:
      45             : 
      46             : //-----------------------------------------------
      47             : static ::rtl::OUString getWindowState(const css::uno::Reference< css::awt::XWindow >& xWindow)
      48             : {
      49             :     if (!xWindow.is())
      50             :         return ::rtl::OUString();
      51             : 
      52             :     rtl::OString sWindowState;
      53             :     // SOLAR SAFE -> ----------------------------
      54             :     {
      55             :         SolarMutexGuard aSolarGuard;
      56             : 
      57             :         Window*    pWindow     = VCLUnoHelper::GetWindow(xWindow);
      58             :         // check for system window is neccessary to guarantee correct pointer cast!
      59             :         if (pWindow!=NULL && pWindow->IsSystemWindow())
      60             :         {
      61             :             sal_uLong nMask  = WINDOWSTATE_MASK_ALL;
      62             :             nMask &= ~(WINDOWSTATE_MASK_MINIMIZED);
      63             :             sWindowState = ((SystemWindow*)pWindow)->GetWindowState(nMask);
      64             :         }
      65             :     }
      66             :     // <- SOLAR SAFE ----------------------------
      67             : 
      68             :     return rtl::OStringToOUString(sWindowState,RTL_TEXTENCODING_UTF8);
      69             : }
      70             : 
      71             : //-----------------------------------------------
      72             : static void setWindowState(const css::uno::Reference< css::awt::XWindow >& xWindow     ,
      73             :                            const ::rtl::OUString&                          sWindowState)
      74             : {
      75             :     if (
      76             :         (!xWindow.is()            ) ||
      77             :         (!sWindowState.getLength())
      78             :        )
      79             :         return;
      80             : 
      81             :     // SOLAR SAFE -> ----------------------------
      82             :     SolarMutexGuard aSolarGuard;
      83             : 
      84             :     Window* pWindow = VCLUnoHelper::GetWindow(xWindow);
      85             :     // check for system window is neccessary to guarantee correct pointer cast!
      86             :     if (
      87             :         (pWindow                  ) &&
      88             :         (pWindow->IsSystemWindow()) &&
      89             :         (
      90             :             // dont overwrite a might existing minimized mode!
      91             :             (pWindow->GetType() != WINDOW_WORKWINDOW) ||
      92             :             (!((WorkWindow*)pWindow)->IsMinimized() )
      93             :         )
      94             :        )
      95             :     {
      96             :         ((SystemWindow*)pWindow)->SetWindowState(OUStringToOString(sWindowState,RTL_TEXTENCODING_UTF8));
      97             :     }
      98             : 
      99             :     // <- SOLAR SAFE ----------------------------
     100             : }
     101             : 
     102             : //-----------------------------------------------
     103         240 : static ::sal_Bool isTopWindow(const css::uno::Reference< css::awt::XWindow >& xWindow)
     104             : {
     105             :     // even child frame containing top level windows (e.g. query designer of database) will be closed
     106         240 :     css::uno::Reference< css::awt::XTopWindow > xTopWindowCheck(xWindow, css::uno::UNO_QUERY);
     107         240 :     if (xTopWindowCheck.is())
     108             :     {
     109             :         // Note: Toolkit interface XTopWindow sometimes is used by real VCL-child-windows also .-)
     110             :         // Be sure that these window is realy a "top system window".
     111             :         // Attention ! Checking Window->GetParent() isnt the right approach here.
     112             :         // Because sometimes VCL create "implicit border windows" as parents even we created
     113             :         // a simple XWindow using the toolkit only .-(
     114         240 :         SolarMutexGuard aSolarGuard;
     115         240 :         Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
     116         480 :         if (
     117             :             (pWindow                  ) &&
     118         240 :             (pWindow->IsSystemWindow())
     119             :            )
     120         240 :             return sal_True;
     121             :     }
     122             : 
     123           0 :     return sal_False;
     124             : }
     125             : 
     126             : };
     127             : 
     128             : } // namespace framework
     129             : 
     130             : #endif // __FRAMEWORK_PATTERN_WINDOW_HXX_
     131             : 
     132             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10