xref: /AOO42X/main/sd/source/ui/inc/WindowUpdater.hxx (revision 1a03dc2c489554774abaf88ae3ad43d8cca28144)
1c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c45d927aSAndrew Rist  * distributed with this work for additional information
6c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17c45d927aSAndrew Rist  * specific language governing permissions and limitations
18c45d927aSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20c45d927aSAndrew Rist  *************************************************************/
21c45d927aSAndrew Rist 
22cdf0e10cSrcweir #ifndef SD_OUTPUT_DEVICE_UPDATER_HXX
23cdf0e10cSrcweir #define SD_OUTPUT_DEVICE_UPDATER_HXX
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <svl/lstner.hxx>
26cdf0e10cSrcweir #include <svl/ctloptions.hxx>
27cdf0e10cSrcweir #include "sddllapi.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #ifndef INCLUDED_VECTOR
30cdf0e10cSrcweir #include <vector>
31cdf0e10cSrcweir #define INCLUDED_VECTOR
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir 
34cdf0e10cSrcweir class Window;
35cdf0e10cSrcweir class OutputDevice;
36cdf0e10cSrcweir class SdDrawDocument;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace sd {
39cdf0e10cSrcweir 
40cdf0e10cSrcweir class ViewShell;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir /** The purpose of the <type>WindowUpdater</type> is to update output
43cdf0e10cSrcweir     devices to take care of modified global values. These values are
44cdf0e10cSrcweir     monitored for changes. At the moment this is
45cdf0e10cSrcweir     the digit language that defines the glyphs to use to render digits.
46cdf0e10cSrcweir     Other values may be added in the future.
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     <p>The methods of this class have not been included into the
49cdf0e10cSrcweir     <type>ViewShell</type> class in order to not clutter its interface any
50cdf0e10cSrcweir     further. This class accesses some of <type>ViewShell</type> data
51cdf0e10cSrcweir     members directly and thus is declared as its friend.</p>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     <p>Windows that are to be kept up-to-date have to be registered via the
54cdf0e10cSrcweir     <member>RegisterWindow()</member> method. When a document is given then
55cdf0e10cSrcweir     this document is reformatted when the monitored option changes.</p>
56cdf0e10cSrcweir  */
57cdf0e10cSrcweir class SD_DLLPUBLIC WindowUpdater
58cdf0e10cSrcweir     : public utl::ConfigurationListener
59cdf0e10cSrcweir {
60cdf0e10cSrcweir public:
61cdf0e10cSrcweir     explicit WindowUpdater (void);
62cdf0e10cSrcweir     virtual ~WindowUpdater (void) throw();
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     /** Add the given device to the list of devices which will be updated
65cdf0e10cSrcweir         when one of the monitored values changes.
66cdf0e10cSrcweir         @param pWindow
67cdf0e10cSrcweir             This device is added to the device list if it is not <null/> and
68cdf0e10cSrcweir             when it is not already a member of that list.
69cdf0e10cSrcweir      */
70cdf0e10cSrcweir     void RegisterWindow (::Window* pWindow);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     /** Remove the given device from the list of devices which will be updated
73cdf0e10cSrcweir         when one of the monitored values changes.
74cdf0e10cSrcweir         @param pWindow
75cdf0e10cSrcweir             This device is removed from the device list when it is a member
76cdf0e10cSrcweir             of that list.
77cdf0e10cSrcweir      */
78cdf0e10cSrcweir     void UnregisterWindow (::Window* pWindow);
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     /** Set the view shell whose output devices shall be kept up to date.
81cdf0e10cSrcweir         It is used to clear the master page cache so that a redraw affects
82cdf0e10cSrcweir         the master page content as well.
83cdf0e10cSrcweir      */
84cdf0e10cSrcweir     void SetViewShell (ViewShell& rViewShell);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     /** Set the document so that it is reformatted when one of the monitored
87cdf0e10cSrcweir         values changes.
88cdf0e10cSrcweir         @param pDocument
89cdf0e10cSrcweir             When <null/> is given document reformatting will not take
90cdf0e10cSrcweir             place in the future.
91cdf0e10cSrcweir      */
92cdf0e10cSrcweir     void SetDocument (SdDrawDocument* pDocument);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     /** Update the given output device and update all text objects of the
95cdf0e10cSrcweir         view shell if not told otherwise.
96cdf0e10cSrcweir         @param pWindow
97cdf0e10cSrcweir             The device to update. When the given pointer is NULL then
98cdf0e10cSrcweir             nothing is done.
99cdf0e10cSrcweir         @param pDocument
100cdf0e10cSrcweir             When given a pointer to a document then tell it to reformat all
101*1a03dc2cSmseidel             text objects. This reformatting is necessary for the new values
102cdf0e10cSrcweir             to take effect.
103cdf0e10cSrcweir      */
104cdf0e10cSrcweir     void Update (OutputDevice* pDevice, SdDrawDocument* pDocument=0) const;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     /** Callback that waits for notifications of a
107cdf0e10cSrcweir         <type>SvtCTLOptions</type> object.
108cdf0e10cSrcweir      */
109cdf0e10cSrcweir     virtual void ConfigurationChanged ( utl::ConfigurationBroadcaster*, sal_uInt32 nHint);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir private:
112*1a03dc2cSmseidel     // Options to monitor for changes.
113cdf0e10cSrcweir     SvtCTLOptions maCTLOptions;
114cdf0e10cSrcweir 
115*1a03dc2cSmseidel     // Keep the output devices of this view shell up to date.
116cdf0e10cSrcweir     ViewShell* mpViewShell;
117cdf0e10cSrcweir 
118*1a03dc2cSmseidel     // The document rendered in the output devices.
119cdf0e10cSrcweir     SdDrawDocument* mpDocument;
120cdf0e10cSrcweir 
121*1a03dc2cSmseidel     // Copy constructor not supported.
122cdf0e10cSrcweir     WindowUpdater (const WindowUpdater& rUpdater);
123cdf0e10cSrcweir 
124*1a03dc2cSmseidel     // Assignment operator not supported.
125cdf0e10cSrcweir     WindowUpdater operator= (const WindowUpdater& rUpdater);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     /** Type and data member for a list of devices that have to be kept
128cdf0e10cSrcweir         up-to-date.
129cdf0e10cSrcweir      */
130cdf0e10cSrcweir     typedef ::std::vector< ::Window*> tWindowList;
131cdf0e10cSrcweir     tWindowList maWindowList;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     /** The central method of this class. Update the given output device.
134*1a03dc2cSmseidel         It is the task of the caller to initiate a reformatting of the
135cdf0e10cSrcweir         document that is rendered on this device to reflect the changes.
136cdf0e10cSrcweir         @param pWindow
137cdf0e10cSrcweir             The output device to update. When it is <null/> then the call
138cdf0e10cSrcweir             is ignored.
139cdf0e10cSrcweir      */
140cdf0e10cSrcweir     SD_DLLPRIVATE void UpdateWindow (OutputDevice* pDevice) const;
141cdf0e10cSrcweir };
142cdf0e10cSrcweir 
143cdf0e10cSrcweir } // end of namespace sd
144cdf0e10cSrcweir 
145cdf0e10cSrcweir #endif
146*1a03dc2cSmseidel 
147*1a03dc2cSmseidel /* vim: set noet sw=4 ts=4: */
148