xref: /aoo42x/main/sd/source/ui/inc/WindowUpdater.hxx (revision 67e470da)
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 #ifndef SD_OUTPUT_DEVICE_UPDATER_HXX
25 #define SD_OUTPUT_DEVICE_UPDATER_HXX
26 
27 #include <svl/lstner.hxx>
28 #include <svl/ctloptions.hxx>
29 #include "sddllapi.h"
30 
31 #ifndef INCLUDED_VECTOR
32 #include <vector>
33 #define INCLUDED_VECTOR
34 #endif
35 
36 class Window;
37 class OutputDevice;
38 class SdDrawDocument;
39 
40 
41 namespace sd {
42 
43 class ViewShell;
44 
45 /** The purpose of the <type>WindowUpdater</type> is to update output
46     devices to take care of modified global values.  These values are
47     monitored for changes.  At the moment this is
48     the digit language that defines the glyphs to use to render digits.
49     Other values may be added in the future.
50 
51     <p>The methods of this class have not been included into the
52     <type>ViewShell</type> class in order to not clutter its interface any
53     further.  This class accesses some of <type>ViewShell</type> data
54     members directly and thus is declared as its friend.</p>
55 
56     <p>Windows that are to be kept up-to-date have to be registered via the
57     <member>RegisterWindow()</member> method.  When a document is given then
58     this document is reformatted when the monitored option changes.</p>
59 */
60 class SD_DLLPUBLIC WindowUpdater
61     : public utl::ConfigurationListener
62 {
63 public:
64     explicit WindowUpdater (void);
65     virtual ~WindowUpdater (void) throw();
66 
67     /** Add the given device to the list of devices which will be updated
68         when one of the monitored values changes.
69         @param pWindow
70             This device is added to the device list if it is not <null/> and
71             when it is not already a member of that list.
72     */
73     void RegisterWindow (::Window* pWindow);
74 
75     /** Remove the given device from the list of devices which will be updated
76         when one of the monitored values changes.
77         @param pWindow
78             This device is removed from the device list when it is a member
79             of that list.
80     */
81     void UnregisterWindow (::Window* pWindow);
82 
83     /** Set the view shell whose output devices shall be kept up to date.
84         It is used to clear the master page cache so that a redraw affects
85         the master page content as well.
86     */
87     void SetViewShell (ViewShell& rViewShell);
88 
89     /** Set the document so that it is reformatted when one of the monitored
90         values changes.
91         @param pDocument
92             When <null/> is given document reformatting will not take
93             place in the future.
94     */
95     void SetDocument (SdDrawDocument* pDocument);
96 
97     /** Update the given output device and update all text objects of the
98         view shell if not told otherwise.
99         @param pWindow
100             The device to update.  When the given pointer is NULL then
101             nothing is done.
102         @param pDocument
103             When given a pointer to a document then tell it to reformat all
104             text objects.  This refromatting is necessary for the new values
105             to take effect.
106     */
107     void Update (OutputDevice* pDevice, SdDrawDocument* pDocument=0) const;
108 
109     /** Callback that waits for notifications of a
110         <type>SvtCTLOptions</type> object.
111     */
112     virtual void ConfigurationChanged ( utl::ConfigurationBroadcaster*, sal_uInt32 nHint);
113 
114 private:
115     /// Options to monitor for changes.
116     SvtCTLOptions maCTLOptions;
117 
118     /// Keep the output devices of this view shell up to date.
119     ViewShell* mpViewShell;
120 
121     /// The document rendered in the output devices.
122     SdDrawDocument* mpDocument;
123 
124     /// Copy constructor not supported.
125     WindowUpdater (const WindowUpdater& rUpdater);
126 
127     /// Assignment operator not supported.
128     WindowUpdater operator= (const WindowUpdater& rUpdater);
129 
130     /** Type and data member for a list of devices that have to be kept
131         up-to-date.
132     */
133     typedef ::std::vector< ::Window*> tWindowList;
134     tWindowList maWindowList;
135 
136     /** The central method of this class.  Update the given output device.
137         It is the task of the caller to initiate a refrormatting of the
138         document that is rendered on this device to reflect the changes.
139         @param pWindow
140             The output device to update.  When it is <null/> then the call
141             is ignored.
142     */
143     SD_DLLPRIVATE void UpdateWindow (OutputDevice* pDevice) const;
144 };
145 
146 } // end of namespace sd
147 
148 #endif
149