Line data Source code
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 "ViewShell.hxx"
22 : #include "Window.hxx"
23 : #include "drawdoc.hxx"
24 : #include "View.hxx"
25 :
26 : #include <vcl/split.hxx>
27 : #include <sfx2/childwin.hxx>
28 : #include <sfx2/viewfrm.hxx>
29 : #include <svl/smplhint.hxx>
30 :
31 : #include <algorithm>
32 :
33 : namespace sd {
34 :
35 338 : WindowUpdater::WindowUpdater (void)
36 : : mpViewShell (NULL),
37 338 : mpDocument (NULL)
38 : {
39 338 : maCTLOptions.AddListener(this);
40 338 : }
41 :
42 1014 : WindowUpdater::~WindowUpdater (void) throw ()
43 : {
44 338 : maCTLOptions.RemoveListener(this);
45 676 : }
46 :
47 464 : void WindowUpdater::RegisterWindow (vcl::Window* pWindow)
48 : {
49 464 : if (pWindow != NULL)
50 : {
51 : tWindowList::iterator aWindowIterator (
52 : ::std::find (
53 464 : maWindowList.begin(), maWindowList.end(), pWindow));
54 464 : if (aWindowIterator == maWindowList.end())
55 : {
56 : // Update the device once right now and add it to the list.
57 464 : Update (pWindow);
58 464 : maWindowList.push_back (pWindow);
59 : }
60 : }
61 464 : }
62 :
63 464 : void WindowUpdater::UnregisterWindow (vcl::Window* pWindow)
64 : {
65 : tWindowList::iterator aWindowIterator (
66 : ::std::find (
67 464 : maWindowList.begin(), maWindowList.end(), pWindow));
68 464 : if (aWindowIterator != maWindowList.end())
69 : {
70 464 : maWindowList.erase (aWindowIterator);
71 : }
72 464 : }
73 :
74 338 : void WindowUpdater::SetViewShell (ViewShell& rViewShell)
75 : {
76 338 : mpViewShell = &rViewShell;
77 338 : }
78 :
79 338 : void WindowUpdater::SetDocument (SdDrawDocument* pDocument)
80 : {
81 338 : mpDocument = pDocument;
82 338 : }
83 :
84 464 : void WindowUpdater::Update (
85 : OutputDevice* pDevice,
86 : SdDrawDocument* pDocument) const
87 : {
88 464 : if (pDevice != NULL)
89 : {
90 464 : UpdateWindow (pDevice);
91 464 : if (pDocument != NULL)
92 0 : pDocument->ReformatAllTextObjects();
93 : }
94 464 : }
95 :
96 464 : void WindowUpdater::UpdateWindow (OutputDevice* pDevice) const
97 : {
98 464 : if (pDevice != NULL)
99 : {
100 464 : SvtCTLOptions::TextNumerals aNumeralMode (maCTLOptions.GetCTLTextNumerals());
101 :
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 464 : switch (aNumeralMode)
108 : {
109 : case SvtCTLOptions::NUMERALS_HINDI:
110 0 : aLanguage = LANGUAGE_ARABIC_SAUDI_ARABIA;
111 0 : break;
112 :
113 : case SvtCTLOptions::NUMERALS_SYSTEM:
114 0 : aLanguage = LANGUAGE_SYSTEM;
115 0 : break;
116 :
117 : case SvtCTLOptions::NUMERALS_ARABIC:
118 : default:
119 464 : aLanguage = LANGUAGE_ENGLISH;
120 464 : break;
121 : }
122 :
123 464 : pDevice->SetDigitLanguage (aLanguage);
124 : }
125 464 : }
126 :
127 0 : void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
128 : {
129 : // Set the current state at all registered output devices.
130 0 : tWindowList::iterator aWindowIterator (maWindowList.begin());
131 0 : while (aWindowIterator != maWindowList.end())
132 0 : Update (*aWindowIterator++);
133 :
134 : // Reformat the document for the modified state to take effect.
135 0 : if (mpDocument != NULL)
136 0 : mpDocument->ReformatAllTextObjects();
137 :
138 : // Invalidate the windows to make the modified state visible.
139 0 : aWindowIterator = maWindowList.begin();
140 0 : while (aWindowIterator != maWindowList.end())
141 0 : (*aWindowIterator++)->Invalidate();
142 0 : }
143 :
144 114 : } // end of namespace sd
145 :
146 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|