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