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