bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / view / WindowUpdater.cxx
blob4a2e0aa0f6aa2905a7436de725d2970bc21d2f34
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "ViewShell.hxx"
22 #include "Window.hxx"
23 #include "drawdoc.hxx"
24 #include "View.hxx"
26 #include <vcl/split.hxx>
27 #include <sfx2/childwin.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <svl/smplhint.hxx>
31 #include <algorithm>
33 namespace sd {
35 WindowUpdater::WindowUpdater()
36 : mpViewShell (NULL),
37 mpDocument (NULL)
39 maCTLOptions.AddListener(this);
42 WindowUpdater::~WindowUpdater() throw ()
44 maCTLOptions.RemoveListener(this);
47 void WindowUpdater::RegisterWindow (vcl::Window* pWindow)
49 if (pWindow != NULL)
51 tWindowList::iterator aWindowIterator (
52 ::std::find (
53 maWindowList.begin(), maWindowList.end(), pWindow));
54 if (aWindowIterator == maWindowList.end())
56 // Update the device once right now and add it to the list.
57 Update (pWindow);
58 maWindowList.push_back (pWindow);
63 void WindowUpdater::UnregisterWindow (vcl::Window* pWindow)
65 tWindowList::iterator aWindowIterator (
66 ::std::find (
67 maWindowList.begin(), maWindowList.end(), pWindow));
68 if (aWindowIterator != maWindowList.end())
70 maWindowList.erase (aWindowIterator);
74 void WindowUpdater::SetViewShell (ViewShell& rViewShell)
76 mpViewShell = &rViewShell;
79 void WindowUpdater::SetDocument (SdDrawDocument* pDocument)
81 mpDocument = pDocument;
84 void WindowUpdater::Update (
85 OutputDevice* pDevice,
86 SdDrawDocument* pDocument) const
88 if (pDevice != NULL)
90 UpdateWindow (pDevice);
91 if (pDocument != NULL)
92 pDocument->ReformatAllTextObjects();
96 void WindowUpdater::UpdateWindow (OutputDevice* pDevice) const
98 if (pDevice != NULL)
100 SvtCTLOptions::TextNumerals aNumeralMode (maCTLOptions.GetCTLTextNumerals());
102 LanguageType aLanguage;
103 // Now this is a bit confusing. The numerals in arabic languages
104 // are Hindi numerals and what the western world generally uses are
105 // arabic numerals. The digits used in the Hindi language are not
106 // used at all.
107 switch (aNumeralMode)
109 case SvtCTLOptions::NUMERALS_HINDI:
110 aLanguage = LANGUAGE_ARABIC_SAUDI_ARABIA;
111 break;
113 case SvtCTLOptions::NUMERALS_SYSTEM:
114 aLanguage = LANGUAGE_SYSTEM;
115 break;
117 case SvtCTLOptions::NUMERALS_ARABIC:
118 default:
119 aLanguage = LANGUAGE_ENGLISH;
120 break;
123 pDevice->SetDigitLanguage (aLanguage);
127 void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
129 // Set the current state at all registered output devices.
130 tWindowList::iterator aWindowIterator (maWindowList.begin());
131 while (aWindowIterator != maWindowList.end())
132 Update (*aWindowIterator++);
134 // Reformat the document for the modified state to take effect.
135 if (mpDocument != NULL)
136 mpDocument->ReformatAllTextObjects();
138 // Invalidate the windows to make the modified state visible.
139 aWindowIterator = maWindowList.begin();
140 while (aWindowIterator != maWindowList.end())
141 (*aWindowIterator++)->Invalidate();
144 } // end of namespace sd
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */