1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <svl/ctloptions.hxx>
23 #include <vcl/vclptr.hxx>
36 /** The purpose of the <type>WindowUpdater</type> is to update output
37 devices to take care of modified global values. These values are
38 monitored for changes. At the moment this is
39 the digit language that defines the glyphs to use to render digits.
40 Other values may be added in the future.
42 <p>The methods of this class have not been included into the
43 <type>ViewShell</type> class in order to not clutter its interface any
44 further. This class accesses some of <type>ViewShell</type> data
45 members directly and thus is declared as its friend.</p>
47 <p>Windows that are to be kept up-to-date have to be registered via the
48 <member>RegisterWindow()</member> method. When a document is given then
49 this document is reformatted when the monitored option changes.</p>
51 class WindowUpdater final
: public utl::ConfigurationListener
54 explicit WindowUpdater();
55 virtual ~WindowUpdater() noexcept override
;
57 /** Add the given device to the list of devices which will be updated
58 when one of the monitored values changes.
60 This device is added to the device list if it is not <null/> and
61 when it is not already a member of that list.
63 void RegisterWindow(vcl::Window
* pWindow
);
65 /** Remove the given device from the list of devices which will be updated
66 when one of the monitored values changes.
68 This device is removed from the device list when it is a member
71 void UnregisterWindow(vcl::Window
* pWindow
);
73 /** Set the document so that it is reformatted when one of the monitored
76 When <null/> is given document reformatting will not take
79 void SetDocument(SdDrawDocument
* pDocument
);
81 /** Update the given output device and update all text objects of the
82 view shell if not told otherwise.
84 The device to update. When the given pointer is NULL then
87 static void Update(OutputDevice
* pDevice
);
89 /** Callback that waits for notifications of a
90 <type>SvtCTLOptions</type> object.
92 virtual void ConfigurationChanged(utl::ConfigurationBroadcaster
*,
93 ConfigurationHints nHint
) override
;
96 /// Options to monitor for changes.
97 SvtCTLOptions maCTLOptions
;
99 /// The document rendered in the output devices.
100 SdDrawDocument
* mpDocument
;
102 WindowUpdater(const WindowUpdater
& rUpdater
) = delete;
104 WindowUpdater
operator=(const WindowUpdater
& rUpdater
) = delete;
106 /** Type and data member for a list of devices that have to be kept
109 typedef ::std::vector
<VclPtr
<vcl::Window
>> tWindowList
;
110 tWindowList maWindowList
;
112 /** The central method of this class. Update the given output device.
113 It is the task of the caller to initiate a reformatting of the
114 document that is rendered on this device to reflect the changes.
116 The output device to update. When it is <null/> then the call
119 static void UpdateWindow(OutputDevice
* pDevice
);
122 } // end of namespace sd
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */