update dev300-m58
[ooovba.git] / sd / source / ui / view / WindowUpdater.cxx
blob47174560d5ab050920a64a8bfea74f083b0c6e75
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WindowUpdater.cxx,v $
10 * $Revision: 1.11.138.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "WindowUpdater.hxx"
35 #include "ViewShell.hxx"
36 #include "Window.hxx"
37 #include "drawdoc.hxx"
38 #include "View.hxx"
40 #ifndef _SPLIT_HXX
41 #include <vcl/split.hxx>
42 #endif
43 #include <sfx2/childwin.hxx>
44 #include <sfx2/viewfrm.hxx>
45 #include <svtools/smplhint.hxx>
47 #include <algorithm>
49 namespace sd {
51 WindowUpdater::WindowUpdater (void)
52 : mpViewShell (NULL),
53 mpDocument (NULL)
55 StartListening (maCTLOptions);
61 WindowUpdater::~WindowUpdater (void) throw ()
63 EndListening (maCTLOptions);
69 void WindowUpdater::RegisterWindow (::Window* pWindow)
71 if (pWindow != NULL)
73 tWindowList::iterator aWindowIterator (
74 ::std::find (
75 maWindowList.begin(), maWindowList.end(), pWindow));
76 if (aWindowIterator == maWindowList.end())
78 // Update the device once right now and add it to the list.
79 Update (pWindow);
80 maWindowList.push_back (pWindow);
88 void WindowUpdater::UnregisterWindow (::Window* pWindow)
90 tWindowList::iterator aWindowIterator (
91 ::std::find (
92 maWindowList.begin(), maWindowList.end(), pWindow));
93 if (aWindowIterator != maWindowList.end())
95 maWindowList.erase (aWindowIterator);
101 void WindowUpdater::SetViewShell (ViewShell& rViewShell)
103 mpViewShell = &rViewShell;
109 void WindowUpdater::SetDocument (SdDrawDocument* pDocument)
111 mpDocument = pDocument;
117 void WindowUpdater::Update (
118 OutputDevice* pDevice,
119 SdDrawDocument* pDocument) const
121 if (pDevice != NULL)
123 UpdateWindow (pDevice);
124 if (pDocument != NULL)
125 pDocument->ReformatAllTextObjects();
132 void WindowUpdater::UpdateWindow (OutputDevice* pDevice) const
134 if (pDevice != NULL)
136 SvtCTLOptions::TextNumerals aNumeralMode (maCTLOptions.GetCTLTextNumerals());
138 LanguageType aLanguage;
139 // Now this is a bit confusing. The numerals in arabic languages
140 // are Hindi numerals and what the western world generally uses are
141 // arabic numerals. The digits used in the Hindi language are not
142 // used at all.
143 switch (aNumeralMode)
145 case SvtCTLOptions::NUMERALS_HINDI:
146 aLanguage = LANGUAGE_ARABIC_SAUDI_ARABIA;
147 break;
149 case SvtCTLOptions::NUMERALS_SYSTEM:
150 aLanguage = LANGUAGE_SYSTEM;
151 break;
153 case SvtCTLOptions::NUMERALS_ARABIC:
154 default:
155 aLanguage = LANGUAGE_ENGLISH;
156 break;
159 pDevice->SetDigitLanguage (aLanguage);
166 void WindowUpdater::Notify (SfxBroadcaster&, const SfxHint& rHint)
168 const SfxSimpleHint& rSimpleHint = static_cast<const SfxSimpleHint&>(rHint);
169 if (rSimpleHint.GetId() == SFX_HINT_CTL_SETTINGS_CHANGED)
171 // #110094#-7
172 // Clear the master page cache so that master pages will be redrawn.
173 //if (mpViewShell != NULL)
175 // SdView* pView = mpViewShell->GetView();
176 // if (pView != NULL)
177 // pView->ReleaseMasterPagePaintCache ();
179 // Set the current state at all registered output devices.
180 tWindowList::iterator aWindowIterator (maWindowList.begin());
181 while (aWindowIterator != maWindowList.end())
182 Update (*aWindowIterator++);
184 // Reformat the document for the modified state to take effect.
185 if (mpDocument != NULL)
186 mpDocument->ReformatAllTextObjects();
188 // Invalidate the windows to make the modified state visible.
189 aWindowIterator = maWindowList.begin();
190 while (aWindowIterator != maWindowList.end())
191 (*aWindowIterator++)->Invalidate();
196 } // end of namespace sd