xref: /aoo42x/main/sd/source/ui/view/WindowUpdater.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #include "WindowUpdater.hxx"
32 #include "ViewShell.hxx"
33 #include "Window.hxx"
34 #include "drawdoc.hxx"
35 #include "View.hxx"
36 
37 #ifndef _SPLIT_HXX
38 #include <vcl/split.hxx>
39 #endif
40 #include <sfx2/childwin.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <svl/smplhint.hxx>
43 
44 #include <algorithm>
45 
46 namespace sd {
47 
48 WindowUpdater::WindowUpdater (void)
49     : mpViewShell (NULL),
50       mpDocument (NULL)
51 {
52     maCTLOptions.AddListener(this);
53 }
54 
55 
56 
57 
58 WindowUpdater::~WindowUpdater (void) throw ()
59 {
60     maCTLOptions.RemoveListener(this);
61 }
62 
63 
64 
65 
66 void WindowUpdater::RegisterWindow (::Window* pWindow)
67 {
68     if (pWindow != NULL)
69     {
70         tWindowList::iterator aWindowIterator (
71             ::std::find (
72                 maWindowList.begin(), maWindowList.end(), pWindow));
73         if (aWindowIterator == maWindowList.end())
74         {
75             // Update the device once right now and add it to the list.
76             Update (pWindow);
77             maWindowList.push_back (pWindow);
78         }
79     }
80 }
81 
82 
83 
84 
85 void WindowUpdater::UnregisterWindow (::Window* pWindow)
86 {
87     tWindowList::iterator aWindowIterator (
88         ::std::find (
89             maWindowList.begin(), maWindowList.end(), pWindow));
90     if (aWindowIterator != maWindowList.end())
91     {
92         maWindowList.erase (aWindowIterator);
93     }
94 }
95 
96 
97 
98 void WindowUpdater::SetViewShell (ViewShell& rViewShell)
99 {
100     mpViewShell = &rViewShell;
101 }
102 
103 
104 
105 
106 void WindowUpdater::SetDocument (SdDrawDocument* pDocument)
107 {
108     mpDocument = pDocument;
109 }
110 
111 
112 
113 
114 void WindowUpdater::Update (
115     OutputDevice* pDevice,
116     SdDrawDocument* pDocument) const
117 {
118     if (pDevice != NULL)
119     {
120         UpdateWindow (pDevice);
121         if (pDocument != NULL)
122             pDocument->ReformatAllTextObjects();
123     }
124 }
125 
126 
127 
128 
129 void WindowUpdater::UpdateWindow (OutputDevice* pDevice) const
130 {
131     if (pDevice != NULL)
132     {
133         SvtCTLOptions::TextNumerals aNumeralMode (maCTLOptions.GetCTLTextNumerals());
134 
135         LanguageType aLanguage;
136         // Now this is a bit confusing.  The numerals in arabic languages
137         // are Hindi numerals and what the western world generally uses are
138         // arabic numerals.  The digits used in the Hindi language are not
139         // used at all.
140         switch (aNumeralMode)
141         {
142             case SvtCTLOptions::NUMERALS_HINDI:
143                 aLanguage = LANGUAGE_ARABIC_SAUDI_ARABIA;
144                 break;
145 
146             case SvtCTLOptions::NUMERALS_SYSTEM:
147                 aLanguage = LANGUAGE_SYSTEM;
148                 break;
149 
150             case SvtCTLOptions::NUMERALS_ARABIC:
151             default:
152                 aLanguage = LANGUAGE_ENGLISH;
153                 break;
154         }
155 
156         pDevice->SetDigitLanguage (aLanguage);
157     }
158 }
159 
160 
161 
162 
163 void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
164 {
165 	// #110094#-7
166     // Clear the master page cache so that master pages will be redrawn.
167     //if (mpViewShell != NULL)
168     //{
169     //    SdView* pView = mpViewShell->GetView();
170     //    if (pView != NULL)
171     //        pView->ReleaseMasterPagePaintCache ();
172     //}
173     // Set the current state at all registered output devices.
174     tWindowList::iterator aWindowIterator (maWindowList.begin());
175     while (aWindowIterator != maWindowList.end())
176         Update (*aWindowIterator++);
177 
178     // Reformat the document for the modified state to take effect.
179     if (mpDocument != NULL)
180         mpDocument->ReformatAllTextObjects();
181 
182     // Invalidate the windows to make the modified state visible.
183     aWindowIterator = maWindowList.begin();
184     while (aWindowIterator != maWindowList.end())
185         (*aWindowIterator++)->Invalidate();
186 }
187 
188 
189 } // end of namespace sd
190