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 .
21 #include "WindowUpdater.hxx"
22 #include "ViewShell.hxx"
24 #include "drawdoc.hxx"
27 #include <vcl/split.hxx>
28 #include <sfx2/childwin.hxx>
29 #include <sfx2/viewfrm.hxx>
30 #include <svl/smplhint.hxx>
36 WindowUpdater::WindowUpdater (void)
40 maCTLOptions
.AddListener(this);
46 WindowUpdater::~WindowUpdater (void) throw ()
48 maCTLOptions
.RemoveListener(this);
54 void WindowUpdater::RegisterWindow (::Window
* pWindow
)
58 tWindowList::iterator
aWindowIterator (
60 maWindowList
.begin(), maWindowList
.end(), pWindow
));
61 if (aWindowIterator
== maWindowList
.end())
63 // Update the device once right now and add it to the list.
65 maWindowList
.push_back (pWindow
);
73 void WindowUpdater::UnregisterWindow (::Window
* pWindow
)
75 tWindowList::iterator
aWindowIterator (
77 maWindowList
.begin(), maWindowList
.end(), pWindow
));
78 if (aWindowIterator
!= maWindowList
.end())
80 maWindowList
.erase (aWindowIterator
);
86 void WindowUpdater::SetViewShell (ViewShell
& rViewShell
)
88 mpViewShell
= &rViewShell
;
94 void WindowUpdater::SetDocument (SdDrawDocument
* pDocument
)
96 mpDocument
= pDocument
;
102 void WindowUpdater::Update (
103 OutputDevice
* pDevice
,
104 SdDrawDocument
* pDocument
) const
108 UpdateWindow (pDevice
);
109 if (pDocument
!= NULL
)
110 pDocument
->ReformatAllTextObjects();
117 void WindowUpdater::UpdateWindow (OutputDevice
* pDevice
) const
121 SvtCTLOptions::TextNumerals
aNumeralMode (maCTLOptions
.GetCTLTextNumerals());
123 LanguageType aLanguage
;
124 // Now this is a bit confusing. The numerals in arabic languages
125 // are Hindi numerals and what the western world generally uses are
126 // arabic numerals. The digits used in the Hindi language are not
128 switch (aNumeralMode
)
130 case SvtCTLOptions::NUMERALS_HINDI
:
131 aLanguage
= LANGUAGE_ARABIC_SAUDI_ARABIA
;
134 case SvtCTLOptions::NUMERALS_SYSTEM
:
135 aLanguage
= LANGUAGE_SYSTEM
;
138 case SvtCTLOptions::NUMERALS_ARABIC
:
140 aLanguage
= LANGUAGE_ENGLISH
;
144 pDevice
->SetDigitLanguage (aLanguage
);
151 void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster
*, sal_uInt32
)
153 // Set the current state at all registered output devices.
154 tWindowList::iterator
aWindowIterator (maWindowList
.begin());
155 while (aWindowIterator
!= maWindowList
.end())
156 Update (*aWindowIterator
++);
158 // Reformat the document for the modified state to take effect.
159 if (mpDocument
!= NULL
)
160 mpDocument
->ReformatAllTextObjects();
162 // Invalidate the windows to make the modified state visible.
163 aWindowIterator
= maWindowList
.begin();
164 while (aWindowIterator
!= maWindowList
.end())
165 (*aWindowIterator
++)->Invalidate();
169 } // end of namespace sd
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */