xref: /aoo42x/main/sd/source/ui/inc/WindowUpdater.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SD_OUTPUT_DEVICE_UPDATER_HXX
29*cdf0e10cSrcweir #define SD_OUTPUT_DEVICE_UPDATER_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <svl/lstner.hxx>
32*cdf0e10cSrcweir #include <svl/ctloptions.hxx>
33*cdf0e10cSrcweir #include "sddllapi.h"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef INCLUDED_VECTOR
36*cdf0e10cSrcweir #include <vector>
37*cdf0e10cSrcweir #define INCLUDED_VECTOR
38*cdf0e10cSrcweir #endif
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir class Window;
41*cdf0e10cSrcweir class OutputDevice;
42*cdf0e10cSrcweir class SdDrawDocument;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace sd {
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir class ViewShell;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir /** The purpose of the <type>WindowUpdater</type> is to update output
50*cdf0e10cSrcweir     devices to take care of modified global values.  These values are
51*cdf0e10cSrcweir     monitored for changes.  At the moment this is
52*cdf0e10cSrcweir     the digit language that defines the glyphs to use to render digits.
53*cdf0e10cSrcweir     Other values may be added in the future.
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir     <p>The methods of this class have not been included into the
56*cdf0e10cSrcweir     <type>ViewShell</type> class in order to not clutter its interface any
57*cdf0e10cSrcweir     further.  This class accesses some of <type>ViewShell</type> data
58*cdf0e10cSrcweir     members directly and thus is declared as its friend.</p>
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir     <p>Windows that are to be kept up-to-date have to be registered via the
61*cdf0e10cSrcweir     <member>RegisterWindow()</member> method.  When a document is given then
62*cdf0e10cSrcweir     this document is reformatted when the monitored option changes.</p>
63*cdf0e10cSrcweir */
64*cdf0e10cSrcweir class SD_DLLPUBLIC WindowUpdater
65*cdf0e10cSrcweir     : public utl::ConfigurationListener
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir public:
68*cdf0e10cSrcweir     explicit WindowUpdater (void);
69*cdf0e10cSrcweir     virtual ~WindowUpdater (void) throw();
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     /** Add the given device to the list of devices which will be updated
72*cdf0e10cSrcweir         when one of the monitored values changes.
73*cdf0e10cSrcweir         @param pWindow
74*cdf0e10cSrcweir             This device is added to the device list if it is not <null/> and
75*cdf0e10cSrcweir             when it is not already a member of that list.
76*cdf0e10cSrcweir     */
77*cdf0e10cSrcweir     void RegisterWindow (::Window* pWindow);
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir     /** Remove the given device from the list of devices which will be updated
80*cdf0e10cSrcweir         when one of the monitored values changes.
81*cdf0e10cSrcweir         @param pWindow
82*cdf0e10cSrcweir             This device is removed from the device list when it is a member
83*cdf0e10cSrcweir             of that list.
84*cdf0e10cSrcweir     */
85*cdf0e10cSrcweir     void UnregisterWindow (::Window* pWindow);
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     /** Set the view shell whose output devices shall be kept up to date.
88*cdf0e10cSrcweir         It is used to clear the master page cache so that a redraw affects
89*cdf0e10cSrcweir         the master page content as well.
90*cdf0e10cSrcweir     */
91*cdf0e10cSrcweir     void SetViewShell (ViewShell& rViewShell);
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     /** Set the document so that it is reformatted when one of the monitored
94*cdf0e10cSrcweir         values changes.
95*cdf0e10cSrcweir         @param pDocument
96*cdf0e10cSrcweir             When <null/> is given document reformatting will not take
97*cdf0e10cSrcweir             place in the future.
98*cdf0e10cSrcweir     */
99*cdf0e10cSrcweir     void SetDocument (SdDrawDocument* pDocument);
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     /** Update the given output device and update all text objects of the
102*cdf0e10cSrcweir         view shell if not told otherwise.
103*cdf0e10cSrcweir         @param pWindow
104*cdf0e10cSrcweir             The device to update.  When the given pointer is NULL then
105*cdf0e10cSrcweir             nothing is done.
106*cdf0e10cSrcweir         @param pDocument
107*cdf0e10cSrcweir             When given a pointer to a document then tell it to reformat all
108*cdf0e10cSrcweir             text objects.  This refromatting is necessary for the new values
109*cdf0e10cSrcweir             to take effect.
110*cdf0e10cSrcweir     */
111*cdf0e10cSrcweir     void Update (OutputDevice* pDevice, SdDrawDocument* pDocument=0) const;
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     /** Callback that waits for notifications of a
114*cdf0e10cSrcweir         <type>SvtCTLOptions</type> object.
115*cdf0e10cSrcweir     */
116*cdf0e10cSrcweir     virtual void ConfigurationChanged ( utl::ConfigurationBroadcaster*, sal_uInt32 nHint);
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir private:
119*cdf0e10cSrcweir     /// Options to monitor for changes.
120*cdf0e10cSrcweir     SvtCTLOptions maCTLOptions;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     /// Keep the output devices of this view shell up to date.
123*cdf0e10cSrcweir     ViewShell* mpViewShell;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     /// The document rendered in the output devices.
126*cdf0e10cSrcweir     SdDrawDocument* mpDocument;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     /// Copy constructor not supported.
129*cdf0e10cSrcweir     WindowUpdater (const WindowUpdater& rUpdater);
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     /// Assignment operator not supported.
132*cdf0e10cSrcweir     WindowUpdater operator= (const WindowUpdater& rUpdater);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     /** Type and data member for a list of devices that have to be kept
135*cdf0e10cSrcweir         up-to-date.
136*cdf0e10cSrcweir     */
137*cdf0e10cSrcweir     typedef ::std::vector< ::Window*> tWindowList;
138*cdf0e10cSrcweir     tWindowList maWindowList;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     /** The central method of this class.  Update the given output device.
141*cdf0e10cSrcweir         It is the task of the caller to initiate a refrormatting of the
142*cdf0e10cSrcweir         document that is rendered on this device to reflect the changes.
143*cdf0e10cSrcweir         @param pWindow
144*cdf0e10cSrcweir             The output device to update.  When it is <null/> then the call
145*cdf0e10cSrcweir             is ignored.
146*cdf0e10cSrcweir     */
147*cdf0e10cSrcweir     SD_DLLPRIVATE void UpdateWindow (OutputDevice* pDevice) const;
148*cdf0e10cSrcweir };
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir } // end of namespace sd
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir #endif
153