1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <WindowUpdater.hxx>
21 #include <drawdoc.hxx>
23 #include <vcl/outdev.hxx>
24 #include <vcl/vclptr.hxx>
25 #include <vcl/window.hxx>
31 WindowUpdater::WindowUpdater()
32 : mpDocument (nullptr)
34 maCTLOptions
.AddListener(this);
37 WindowUpdater::~WindowUpdater() noexcept
39 maCTLOptions
.RemoveListener(this);
42 void WindowUpdater::RegisterWindow (vcl::Window
* pWindow
)
44 if (pWindow
!= nullptr)
46 tWindowList::iterator
aWindowIterator (
48 maWindowList
.begin(), maWindowList
.end(), pWindow
));
49 if (aWindowIterator
== maWindowList
.end())
51 // Update the device once right now and add it to the list.
52 Update (pWindow
->GetOutDev());
53 maWindowList
.emplace_back(pWindow
);
58 void WindowUpdater::UnregisterWindow (vcl::Window
* pWindow
)
60 tWindowList::iterator
aWindowIterator (
62 maWindowList
.begin(), maWindowList
.end(), pWindow
));
63 if (aWindowIterator
!= maWindowList
.end())
65 maWindowList
.erase (aWindowIterator
);
69 void WindowUpdater::SetDocument (SdDrawDocument
* pDocument
)
71 mpDocument
= pDocument
;
74 /*static*/ void WindowUpdater::Update (OutputDevice
* pDevice
)
76 if (pDevice
!= nullptr)
78 UpdateWindow (pDevice
);
82 /*static*/ void WindowUpdater::UpdateWindow (OutputDevice
* pDevice
)
84 if (pDevice
== nullptr)
87 SvtCTLOptions::TextNumerals
aNumeralMode (SvtCTLOptions::GetCTLTextNumerals());
89 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
96 case SvtCTLOptions::NUMERALS_HINDI
:
97 aLanguage
= LANGUAGE_ARABIC_SAUDI_ARABIA
;
100 case SvtCTLOptions::NUMERALS_SYSTEM
:
101 aLanguage
= LANGUAGE_SYSTEM
;
104 case SvtCTLOptions::NUMERALS_ARABIC
:
106 aLanguage
= LANGUAGE_ENGLISH
;
110 pDevice
->SetDigitLanguage (aLanguage
);
113 void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster
*, ConfigurationHints
)
115 // Set the current state at all registered output devices.
116 for (auto& rxWindow
: maWindowList
)
117 Update (rxWindow
->GetOutDev());
119 // Reformat the document for the modified state to take effect.
120 if (mpDocument
!= nullptr)
121 mpDocument
->ReformatAllTextObjects();
123 // Invalidate the windows to make the modified state visible.
124 for (auto& rxWindow
: maWindowList
)
125 rxWindow
->Invalidate();
128 } // end of namespace sd
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */