xref: /trunk/main/sd/source/ui/view/WindowUpdater.cxx (revision 5b190011)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "WindowUpdater.hxx"
28 #include "ViewShell.hxx"
29 #include "Window.hxx"
30 #include "drawdoc.hxx"
31 #include "View.hxx"
32 
33 #ifndef _SPLIT_HXX
34 #include <vcl/split.hxx>
35 #endif
36 #include <sfx2/childwin.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <svl/smplhint.hxx>
39 
40 #include <algorithm>
41 
42 namespace sd {
43 
44 WindowUpdater::WindowUpdater (void)
45     : mpViewShell (NULL),
46       mpDocument (NULL)
47 {
48     maCTLOptions.AddListener(this);
49 }
50 
51 
52 
53 
54 WindowUpdater::~WindowUpdater (void) throw ()
55 {
56     maCTLOptions.RemoveListener(this);
57 }
58 
59 
60 
61 
62 void WindowUpdater::RegisterWindow (::Window* pWindow)
63 {
64     if (pWindow != NULL)
65     {
66         tWindowList::iterator aWindowIterator (
67             ::std::find (
68                 maWindowList.begin(), maWindowList.end(), pWindow));
69         if (aWindowIterator == maWindowList.end())
70         {
71             // Update the device once right now and add it to the list.
72             Update (pWindow);
73             maWindowList.push_back (pWindow);
74         }
75     }
76 }
77 
78 
79 
80 
81 void WindowUpdater::UnregisterWindow (::Window* pWindow)
82 {
83     tWindowList::iterator aWindowIterator (
84         ::std::find (
85             maWindowList.begin(), maWindowList.end(), pWindow));
86     if (aWindowIterator != maWindowList.end())
87     {
88         maWindowList.erase (aWindowIterator);
89     }
90 }
91 
92 
93 
94 void WindowUpdater::SetViewShell (ViewShell& rViewShell)
95 {
96     mpViewShell = &rViewShell;
97 }
98 
99 
100 
101 
102 void WindowUpdater::SetDocument (SdDrawDocument* pDocument)
103 {
104     mpDocument = pDocument;
105 }
106 
107 
108 
109 
110 void WindowUpdater::Update (
111     OutputDevice* pDevice,
112     SdDrawDocument* pDocument) const
113 {
114     if (pDevice != NULL)
115     {
116         UpdateWindow (pDevice);
117         if (pDocument != NULL)
118             pDocument->ReformatAllTextObjects();
119     }
120 }
121 
122 
123 
124 
125 void WindowUpdater::UpdateWindow (OutputDevice* pDevice) const
126 {
127     if (pDevice != NULL)
128     {
129         SvtCTLOptions::TextNumerals aNumeralMode (maCTLOptions.GetCTLTextNumerals());
130 
131         LanguageType aLanguage;
132         // Now this is a bit confusing.  The numerals in arabic languages
133         // are Hindi numerals and what the western world generally uses are
134         // arabic numerals.  The digits used in the Hindi language are not
135         // used at all.
136         switch (aNumeralMode)
137         {
138             case SvtCTLOptions::NUMERALS_HINDI:
139                 aLanguage = LANGUAGE_ARABIC_SAUDI_ARABIA;
140                 break;
141 
142             case SvtCTLOptions::NUMERALS_SYSTEM:
143                 aLanguage = LANGUAGE_SYSTEM;
144                 break;
145 
146             case SvtCTLOptions::NUMERALS_ARABIC:
147             default:
148                 aLanguage = LANGUAGE_ENGLISH;
149                 break;
150         }
151 
152         pDevice->SetDigitLanguage (aLanguage);
153     }
154 }
155 
156 
157 
158 
159 void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
160 {
161 	// #110094#-7
162     // Clear the master page cache so that master pages will be redrawn.
163     //if (mpViewShell != NULL)
164     //{
165     //    SdView* pView = mpViewShell->GetView();
166     //    if (pView != NULL)
167     //        pView->ReleaseMasterPagePaintCache ();
168     //}
169     // Set the current state at all registered output devices.
170     tWindowList::iterator aWindowIterator (maWindowList.begin());
171     while (aWindowIterator != maWindowList.end())
172         Update (*aWindowIterator++);
173 
174     // Reformat the document for the modified state to take effect.
175     if (mpDocument != NULL)
176         mpDocument->ReformatAllTextObjects();
177 
178     // Invalidate the windows to make the modified state visible.
179     aWindowIterator = maWindowList.begin();
180     while (aWindowIterator != maWindowList.end())
181         (*aWindowIterator++)->Invalidate();
182 }
183 
184 
185 } // end of namespace sd
186