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