1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WindowUpdater.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_OUTPUT_DEVICE_UPDATER_HXX
32 #define SD_OUTPUT_DEVICE_UPDATER_HXX
34 #include <svtools/lstner.hxx>
35 #include <svtools/ctloptions.hxx>
38 #ifndef INCLUDED_VECTOR
40 #define INCLUDED_VECTOR
52 /** The purpose of the <type>WindowUpdater</type> is to update output
53 devices to take care of modified global values. These values are
54 monitored for changes. At the moment this is
55 the digit language that defines the glyphs to use to render digits.
56 Other values may be added in the future.
58 <p>The methods of this class have not been included into the
59 <type>ViewShell</type> class in order to not clutter its interface any
60 further. This class accesses some of <type>ViewShell</type> data
61 members directly and thus is declared as its friend.</p>
63 <p>Windows that are to be kept up-to-date have to be registered via the
64 <member>RegisterWindow()</member> method. When a document is given then
65 this document is reformatted when the monitored option changes.</p>
67 class SD_DLLPUBLIC WindowUpdater
71 explicit WindowUpdater (void);
72 virtual ~WindowUpdater (void) throw();
74 /** Add the given device to the list of devices which will be updated
75 when one of the monitored values changes.
77 This device is added to the device list if it is not <null/> and
78 when it is not already a member of that list.
80 void RegisterWindow (::Window
* pWindow
);
82 /** Remove the given device from the list of devices which will be updated
83 when one of the monitored values changes.
85 This device is removed from the device list when it is a member
88 void UnregisterWindow (::Window
* pWindow
);
90 /** Set the view shell whose output devices shall be kept up to date.
91 It is used to clear the master page cache so that a redraw affects
92 the master page content as well.
94 void SetViewShell (ViewShell
& rViewShell
);
96 /** Set the document so that it is reformatted when one of the monitored
99 When <null/> is given document reformatting will not take
102 void SetDocument (SdDrawDocument
* pDocument
);
104 /** Update the given output device and update all text objects of the
105 view shell if not told otherwise.
107 The device to update. When the given pointer is NULL then
110 When given a pointer to a document then tell it to reformat all
111 text objects. This refromatting is necessary for the new values
114 void Update (OutputDevice
* pDevice
, SdDrawDocument
* pDocument
=0) const;
116 /** Callback that waits for notifications of a
117 <type>SvtCTLOptions</type> object.
119 virtual void Notify (SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
122 /// Options to monitor for changes.
123 SvtCTLOptions maCTLOptions
;
125 /// Keep the output devices of this view shell up to date.
126 ViewShell
* mpViewShell
;
128 /// The document rendered in the output devices.
129 SdDrawDocument
* mpDocument
;
131 /// Copy constructor not supported.
132 WindowUpdater (const WindowUpdater
& rUpdater
);
134 /// Assignment operator not supported.
135 WindowUpdater
operator= (const WindowUpdater
& rUpdater
);
137 /** Type and data member for a list of devices that have to be kept
140 typedef ::std::vector
< ::Window
*> tWindowList
;
141 tWindowList maWindowList
;
143 /** The central method of this class. Update the given output device.
144 It is the task of the caller to initiate a refrormatting of the
145 document that is rendered on this device to reflect the changes.
147 The output device to update. When it is <null/> then the call
150 SD_DLLPRIVATE
void UpdateWindow (OutputDevice
* pDevice
) const;
153 } // end of namespace sd