/src/libreoffice/sd/source/ui/view/WindowUpdater.cxx
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 | | #include <WindowUpdater.hxx> |
21 | | #include <drawdoc.hxx> |
22 | | |
23 | | #include <vcl/outdev.hxx> |
24 | | #include <vcl/vclptr.hxx> |
25 | | #include <vcl/window.hxx> |
26 | | |
27 | | #include <algorithm> |
28 | | |
29 | | namespace sd { |
30 | | |
31 | | WindowUpdater::WindowUpdater() |
32 | 0 | : mpDocument (nullptr) |
33 | 0 | { |
34 | 0 | maCTLOptions.AddListener(this); |
35 | 0 | } |
36 | | |
37 | | WindowUpdater::~WindowUpdater() noexcept |
38 | 0 | { |
39 | 0 | maCTLOptions.RemoveListener(this); |
40 | 0 | } |
41 | | |
42 | | void WindowUpdater::RegisterWindow (vcl::Window* pWindow) |
43 | 0 | { |
44 | 0 | if (pWindow != nullptr) |
45 | 0 | { |
46 | 0 | tWindowList::iterator aWindowIterator ( |
47 | 0 | ::std::find ( |
48 | 0 | maWindowList.begin(), maWindowList.end(), pWindow)); |
49 | 0 | if (aWindowIterator == maWindowList.end()) |
50 | 0 | { |
51 | | // Update the device once right now and add it to the list. |
52 | 0 | Update (pWindow->GetOutDev()); |
53 | 0 | maWindowList.emplace_back(pWindow); |
54 | 0 | } |
55 | 0 | } |
56 | 0 | } |
57 | | |
58 | | void WindowUpdater::UnregisterWindow (vcl::Window* pWindow) |
59 | 0 | { |
60 | 0 | tWindowList::iterator aWindowIterator ( |
61 | 0 | ::std::find ( |
62 | 0 | maWindowList.begin(), maWindowList.end(), pWindow)); |
63 | 0 | if (aWindowIterator != maWindowList.end()) |
64 | 0 | { |
65 | 0 | maWindowList.erase (aWindowIterator); |
66 | 0 | } |
67 | 0 | } |
68 | | |
69 | | void WindowUpdater::SetDocument (SdDrawDocument* pDocument) |
70 | 0 | { |
71 | 0 | mpDocument = pDocument; |
72 | 0 | } |
73 | | |
74 | | /*static*/ void WindowUpdater::Update (OutputDevice* pDevice) |
75 | 0 | { |
76 | 0 | if (pDevice != nullptr) |
77 | 0 | { |
78 | 0 | UpdateWindow (pDevice); |
79 | 0 | } |
80 | 0 | } |
81 | | |
82 | | /*static*/ void WindowUpdater::UpdateWindow (OutputDevice* pDevice) |
83 | 0 | { |
84 | 0 | if (pDevice == nullptr) |
85 | 0 | return; |
86 | | |
87 | 0 | SvtCTLOptions::TextNumerals aNumeralMode (SvtCTLOptions::GetCTLTextNumerals()); |
88 | |
|
89 | 0 | LanguageType aLanguage; |
90 | | // Now this is a bit confusing. The numerals in arabic languages |
91 | | // are Hindi numerals and what the western world generally uses are |
92 | | // arabic numerals. The digits used in the Hindi language are not |
93 | | // used at all. |
94 | 0 | switch (aNumeralMode) |
95 | 0 | { |
96 | 0 | case SvtCTLOptions::NUMERALS_HINDI: |
97 | 0 | aLanguage = LANGUAGE_ARABIC_SAUDI_ARABIA; |
98 | 0 | break; |
99 | | |
100 | 0 | case SvtCTLOptions::NUMERALS_SYSTEM: |
101 | 0 | aLanguage = LANGUAGE_SYSTEM; |
102 | 0 | break; |
103 | | |
104 | 0 | case SvtCTLOptions::NUMERALS_ARABIC: |
105 | 0 | default: |
106 | 0 | aLanguage = LANGUAGE_ENGLISH; |
107 | 0 | break; |
108 | 0 | } |
109 | | |
110 | 0 | pDevice->SetDigitLanguage (aLanguage); |
111 | 0 | } |
112 | | |
113 | | void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) |
114 | 0 | { |
115 | | // Set the current state at all registered output devices. |
116 | 0 | for (auto& rxWindow : maWindowList) |
117 | 0 | Update (rxWindow->GetOutDev()); |
118 | | |
119 | | // Reformat the document for the modified state to take effect. |
120 | 0 | if (mpDocument != nullptr) |
121 | 0 | mpDocument->ReformatAllTextObjects(); |
122 | | |
123 | | // Invalidate the windows to make the modified state visible. |
124 | 0 | for (auto& rxWindow : maWindowList) |
125 | 0 | rxWindow->Invalidate(); |
126 | 0 | } |
127 | | |
128 | | } // end of namespace sd |
129 | | |
130 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |