LibreOffice Module sd (master) 1
WindowUpdater.cxx
Go to the documentation of this file.
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
29namespace sd {
30
32 : mpDocument (nullptr)
33{
34 maCTLOptions.AddListener(this);
35}
36
38{
39 maCTLOptions.RemoveListener(this);
40}
41
43{
44 if (pWindow != nullptr)
45 {
46 tWindowList::iterator aWindowIterator (
47 ::std::find (
48 maWindowList.begin(), maWindowList.end(), pWindow));
49 if (aWindowIterator == maWindowList.end())
50 {
51 // Update the device once right now and add it to the list.
52 Update (pWindow->GetOutDev());
53 maWindowList.emplace_back(pWindow);
54 }
55 }
56}
57
59{
60 tWindowList::iterator aWindowIterator (
61 ::std::find (
62 maWindowList.begin(), maWindowList.end(), pWindow));
63 if (aWindowIterator != maWindowList.end())
64 {
65 maWindowList.erase (aWindowIterator);
66 }
67}
68
70{
71 mpDocument = pDocument;
72}
73
74/*static*/ void WindowUpdater::Update (OutputDevice* pDevice)
75{
76 if (pDevice != nullptr)
77 {
78 UpdateWindow (pDevice);
79 }
80}
81
82/*static*/ void WindowUpdater::UpdateWindow (OutputDevice* pDevice)
83{
84 if (pDevice == nullptr)
85 return;
86
88
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
93 // used at all.
94 switch (aNumeralMode)
95 {
98 break;
99
101 aLanguage = LANGUAGE_SYSTEM;
102 break;
103
105 default:
106 aLanguage = LANGUAGE_ENGLISH;
107 break;
108 }
109
110 pDevice->SetDigitLanguage (aLanguage);
111}
112
114{
115 // Set the current state at all registered output devices.
116 for (auto& rxWindow : maWindowList)
117 Update (rxWindow->GetOutDev());
118
119 // Reformat the document for the modified state to take effect.
120 if (mpDocument != nullptr)
122
123 // Invalidate the windows to make the modified state visible.
124 for (auto& rxWindow : maWindowList)
125 rxWindow->Invalidate();
126}
127
128} // end of namespace sd
129
130/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetDigitLanguage(LanguageType)
void ReformatAllTextObjects()
static TextNumerals GetCTLTextNumerals()
virtual ~WindowUpdater() noexcept override
tWindowList maWindowList
void SetDocument(SdDrawDocument *pDocument)
Set the document so that it is reformatted when one of the monitored values changes.
void RegisterWindow(vcl::Window *pWindow)
Add the given device to the list of devices which will be updated when one of the monitored values ch...
static void Update(OutputDevice *pDevice)
Update the given output device and update all text objects of the view shell if not told otherwise.
void UnregisterWindow(vcl::Window *pWindow)
Remove the given device from the list of devices which will be updated when one of the monitored valu...
static void UpdateWindow(OutputDevice *pDevice)
The central method of this class.
SvtCTLOptions maCTLOptions
Options to monitor for changes.
virtual void ConfigurationChanged(utl::ConfigurationBroadcaster *, ConfigurationHints nHint) override
Callback that waits for notifications of a <type>SvtCTLOptions</type> object.
SdDrawDocument * mpDocument
The document rendered in the output devices.
::OutputDevice const * GetOutDev() const
#define LANGUAGE_ENGLISH
#define LANGUAGE_SYSTEM
#define LANGUAGE_ARABIC_SAUDI_ARABIA
ConfigurationHints