/src/libreoffice/framework/source/fwe/helper/windowstatehelper.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
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 | | #include <com/sun/star/awt/XWindow.hpp> |
21 | | #include <com/sun/star/frame/XFrame.hpp> |
22 | | #include <com/sun/star/frame/XModel.hpp> |
23 | | #include <com/sun/star/uno/Reference.hxx> |
24 | | |
25 | | #include <framework/windowstatehelper.hxx> |
26 | | #include <toolkit/helper/vclunohelper.hxx> |
27 | | #include <vcl/svapp.hxx> |
28 | | #include <vcl/syswin.hxx> |
29 | | #include <vcl/vclptr.hxx> |
30 | | #include <vcl/window.hxx> |
31 | | |
32 | | namespace framework |
33 | | { |
34 | | // for use from SfxViewShell inherited classes |
35 | | OUString WindowStateHelper::GetFromWindow(vcl::Window* pWin) |
36 | 3.36k | { |
37 | | // SOLAR SAFE -> ------------------------ |
38 | 3.36k | SolarMutexGuard aSolarGuard; |
39 | | |
40 | | // getting to system window here is necessary |
41 | 13.4k | while (pWin && !pWin->IsSystemWindow()) |
42 | 10.1k | { |
43 | 10.1k | pWin = pWin->GetParent(); |
44 | 10.1k | } |
45 | 3.36k | if (pWin) |
46 | 3.36k | { |
47 | 3.36k | vcl::WindowDataMask const nMask |
48 | 3.36k | = vcl::WindowDataMask::All & ~vcl::WindowDataMask::Minimized; |
49 | 3.36k | return static_cast<SystemWindow*>(pWin)->GetWindowState(nMask); |
50 | 3.36k | } |
51 | | |
52 | 0 | return {}; |
53 | | // <- SOLAR SAFE ------------------------ |
54 | 3.36k | } |
55 | | |
56 | | // for use from application exports |
57 | | OUString WindowStateHelper::GetFromModel(const css::uno::Reference<css::frame::XModel>& xModel) |
58 | 0 | { |
59 | 0 | if (!xModel) |
60 | 0 | return {}; |
61 | | |
62 | 0 | auto xController = xModel->getCurrentController(); |
63 | 0 | if (!xController) |
64 | 0 | return {}; |
65 | | |
66 | 0 | auto xFrame = xController->getFrame(); |
67 | 0 | if (!xFrame) |
68 | 0 | return {}; |
69 | | |
70 | 0 | if (auto xWindow = xFrame->getContainerWindow()) |
71 | 0 | { |
72 | | // SOLAR SAFE FOR VCL HELPER -> ------------------------ |
73 | 0 | SolarMutexGuard aSolarGuard; |
74 | 0 | return WindowStateHelper::GetFromWindow(VCLUnoHelper::GetWindow(xWindow)); |
75 | | // <- SOLAR SAFE ------------------------ |
76 | 0 | } |
77 | | |
78 | 0 | return {}; |
79 | 0 | } |
80 | | } |
81 | | |
82 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |