calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / inc / svdata.hxx
blobf05d3eb3cec92b261f88c37af1e86ffe85989004
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include <sal/config.h>
23 #include <config_version.h>
25 #include <o3tl/lru_map.hxx>
26 #include <o3tl/hash_combine.hxx>
27 #include <tools/fldunit.hxx>
28 #include <unotools/options.hxx>
29 #include <vcl/bitmapex.hxx>
30 #include <vcl/settings.hxx>
31 #include <vcl/svapp.hxx>
32 #include <vcl/window.hxx>
33 #include <vcl/task.hxx>
34 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
35 #include <unotools/resmgr.hxx>
37 #include <com/sun/star/lang/XComponent.hpp>
38 #include <com/sun/star/i18n/XCharacterClassification.hpp>
40 #include "vcleventlisteners.hxx"
41 #include "salwtype.hxx"
42 #include "displayconnectiondispatch.hxx"
44 #include <mutex>
45 #include <vector>
46 #include <unordered_map>
47 #include "ControlCacheKey.hxx"
48 #include "schedulerimpl.hxx"
49 #include <basegfx/DrawCommands.hxx>
51 struct ImplPostEventData;
52 struct ImplTimerData;
53 struct ImplIdleData;
54 struct ImplConfigData;
55 namespace rtl
57 class OStringBuffer;
59 namespace vcl::font
61 class DirectFontSubstitution;
62 class PhysicalFontCollection;
64 struct ImplHotKey;
65 struct ImplEventHook;
66 class Point;
67 class ImplAccelManager;
68 class ImplFontCache;
69 class HelpTextWindow;
70 class ImplTBDragMgr;
71 class ImplIdleMgr;
72 class FloatingWindow;
73 class AllSettings;
74 class NotifyEvent;
75 class Timer;
76 class AutoTimer;
77 class Idle;
78 class Help;
79 class Image;
80 class PopupMenu;
81 class Application;
82 class OutputDevice;
83 class SvFileStream;
84 class SystemWindow;
85 class WorkWindow;
86 class Dialog;
87 class VirtualDevice;
88 class Printer;
89 class SalFrame;
90 class SalInstance;
91 class SalSystem;
92 class ImplPrnQueueList;
93 class UnoWrapperBase;
94 class GraphicConverter;
95 class ImplWheelWindow;
96 class SalTimer;
97 class DockingManager;
98 class VclEventListeners2;
99 class SalData;
100 class OpenGLContext;
101 class UITestLogger;
103 #define SV_ICON_ID_OFFICE 1
104 #define SV_ICON_ID_TEXT 2
105 #define SV_ICON_ID_TEXT_TEMPLATE 3
106 #define SV_ICON_ID_SPREADSHEET 4
107 #define SV_ICON_ID_SPREADSHEET_TEMPLATE 5
108 #define SV_ICON_ID_DRAWING 6
109 #define SV_ICON_ID_PRESENTATION 8
110 #define SV_ICON_ID_MASTER_DOCUMENT 10
111 #define SV_ICON_ID_TEMPLATE 11
112 #define SV_ICON_ID_DATABASE 12
113 #define SV_ICON_ID_FORMULA 13
115 namespace com::sun::star::datatransfer::clipboard { class XClipboard; }
117 namespace vcl
119 class DisplayConnectionDispatch;
120 class SettingsConfigItem;
121 class DeleteOnDeinitBase;
122 class Window;
125 namespace basegfx
127 class SystemDependentDataManager;
130 class LocaleConfigurationListener final : public utl::ConfigurationListener
132 public:
133 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
136 typedef std::pair<VclPtr<vcl::Window>, ImplPostEventData *> ImplPostEventPair;
138 struct ImplSVAppData
140 ImplSVAppData();
141 ~ImplSVAppData();
143 std::optional<AllSettings> mxSettings; // Application settings
144 LocaleConfigurationListener* mpCfgListener = nullptr;
145 VclEventListeners maEventListeners; // listeners for vcl events (eg, extended toolkit)
146 std::vector<Link<VclWindowEvent&,bool> >
147 maKeyListeners; // listeners for key events only (eg, extended toolkit)
148 std::vector<ImplPostEventPair> maPostedEventList;
149 ImplAccelManager* mpAccelMgr = nullptr; // Accelerator Manager
150 std::optional<OUString> mxAppName; // Application name
151 std::optional<OUString> mxAppFileName; // Abs. Application FileName
152 std::optional<OUString> mxDisplayName; // Application Display Name
153 std::optional<OUString> mxToolkitName; // Toolkit Name
154 Help* mpHelp = nullptr; // Application help
155 VclPtr<PopupMenu> mpActivePopupMenu; // Actives Popup-Menu (in Execute)
156 VclPtr<ImplWheelWindow> mpWheelWindow; // WheelWindow
157 sal_uInt64 mnLastInputTime = 0; // GetLastInputTime()
158 sal_uInt16 mnDispatchLevel = 0; // DispatchLevel
159 sal_uInt16 mnModalMode = 0; // ModalMode Count
160 SystemWindowFlags mnSysWinMode = SystemWindowFlags(0); // Mode, when SystemWindows should be created
161 bool mbInAppMain = false; // is Application::Main() on stack
162 bool mbInAppExecute = false; // is Application::Execute() on stack
163 volatile bool mbAppQuit = false; // is Application::Quit() called, volatile because we read/write from different threads
164 bool mbSettingsInit = false; // true: Settings are initialized
165 DialogCancelMode meDialogCancel = DialogCancelMode::Off; // true: All Dialog::Execute() calls will be terminated immediately with return false
166 bool mbRenderToBitmaps = false; // set via svp / headless plugin
167 bool m_bUseSystemLoop = false;
169 SvFileStream* mpEventTestInput = nullptr;
170 Idle* mpEventTestingIdle = nullptr;
171 int mnEventTestLimit = 0;
173 DECL_STATIC_LINK(ImplSVAppData, ImplQuitMsg, void*, void);
174 DECL_STATIC_LINK(ImplSVAppData, ImplPrepareExitMsg, void*, void);
175 DECL_STATIC_LINK(ImplSVAppData, ImplEndAllDialogsMsg, void*, void);
176 DECL_STATIC_LINK(ImplSVAppData, ImplEndAllPopupsMsg, void*, void);
177 DECL_STATIC_LINK(ImplSVAppData, ImplVclEventTestingHdl, void*, void);
178 DECL_LINK(VclEventTestingHdl, Timer*, void);
181 /// Cache multiple scalings for the same bitmap
182 struct ScaleCacheKey {
183 SalBitmap *mpBitmap;
184 Size maDestSize;
185 ScaleCacheKey(SalBitmap *pBitmap, const Size &aDestSize)
187 mpBitmap = pBitmap;
188 maDestSize = aDestSize;
190 ScaleCacheKey(const ScaleCacheKey &key)
192 mpBitmap = key.mpBitmap;
193 maDestSize = key.maDestSize;
195 bool operator==(ScaleCacheKey const& rOther) const
197 return mpBitmap == rOther.mpBitmap && maDestSize == rOther.maDestSize;
201 namespace std
203 template <> struct hash<ScaleCacheKey>
205 std::size_t operator()(ScaleCacheKey const& k) const noexcept
207 std::size_t seed = 0;
208 o3tl::hash_combine(seed, k.mpBitmap);
209 o3tl::hash_combine(seed, k.maDestSize.getWidth());
210 o3tl::hash_combine(seed, k.maDestSize.getHeight());
211 return seed;
215 } // end std namespace
217 typedef o3tl::lru_map<ScaleCacheKey, BitmapEx> lru_scale_cache;
219 struct ImplSVGDIData
221 ~ImplSVGDIData();
223 VclPtr<vcl::WindowOutputDevice> mpFirstWinGraphics; // First OutputDevice with a Frame Graphics
224 VclPtr<vcl::WindowOutputDevice> mpLastWinGraphics; // Last OutputDevice with a Frame Graphics
225 VclPtr<OutputDevice> mpFirstVirGraphics; // First OutputDevice with a VirtualDevice Graphics
226 VclPtr<OutputDevice> mpLastVirGraphics; // Last OutputDevice with a VirtualDevice Graphics
227 VclPtr<Printer> mpFirstPrnGraphics; // First OutputDevice with an InfoPrinter Graphics
228 VclPtr<Printer> mpLastPrnGraphics; // Last OutputDevice with an InfoPrinter Graphics
229 VclPtr<VirtualDevice> mpFirstVirDev; // First VirtualDevice
230 OpenGLContext* mpLastContext = nullptr; // Last OpenGLContext
231 VclPtr<Printer> mpFirstPrinter; // First Printer
232 std::unique_ptr<ImplPrnQueueList> mpPrinterQueueList; // List of all printer queue
233 std::shared_ptr<vcl::font::PhysicalFontCollection> mxScreenFontList; // Screen-Font-List
234 std::shared_ptr<ImplFontCache> mxScreenFontCache; // Screen-Font-Cache
235 lru_scale_cache maScaleCache = lru_scale_cache(10); // Cache for scaled images
236 vcl::font::DirectFontSubstitution* mpDirectFontSubst = nullptr; // Font-Substitutions defined in Tools->Options->Fonts
237 std::unique_ptr<GraphicConverter> mxGrfConverter; // Converter for graphics
238 tools::Long mnAppFontX = 0; // AppFont X-Numenator for 40/tel Width
239 tools::Long mnAppFontY = 0; // AppFont Y-Numenator for 80/tel Height
240 bool mbFontSubChanged = false; // true: FontSubstitution was changed between Begin/End
242 o3tl::lru_map<OUString, BitmapEx> maThemeImageCache = o3tl::lru_map<OUString, BitmapEx>(10);
243 o3tl::lru_map<OUString, gfx::DrawRoot> maThemeDrawCommandsCache = o3tl::lru_map<OUString, gfx::DrawRoot>(50);
246 struct ImplSVFrameData
248 ~ImplSVFrameData();
249 VclPtr<vcl::Window> mpFirstFrame; // First FrameWindow
250 VclPtr<vcl::Window> mpActiveApplicationFrame; // the last active application frame, can be used as DefModalDialogParent if no focuswin set
251 VclPtr<WorkWindow> mpAppWin; // Application-Window
253 std::unique_ptr<UITestLogger> m_pUITestLogger;
256 struct ImplSVWinData
258 ~ImplSVWinData();
259 VclPtr<vcl::Window> mpFocusWin; // window, that has the focus
260 VclPtr<vcl::Window> mpCaptureWin; // window, that has the mouse capture
261 VclPtr<vcl::Window> mpLastDeacWin; // Window, that need a deactivate (FloatingWindow-Handling)
262 VclPtr<FloatingWindow> mpFirstFloat; // First FloatingWindow in PopupMode
263 std::vector<VclPtr<Dialog>> mpExecuteDialogs; ///< Stack of dialogs that are Execute()'d - the last one is the top most one.
264 VclPtr<vcl::Window> mpExtTextInputWin; // Window, which is in ExtTextInput
265 VclPtr<vcl::Window> mpTrackWin; // window, that is in tracking mode
266 AutoTimer* mpTrackTimer = nullptr; // tracking timer
267 std::vector<Image> maMsgBoxImgList; // ImageList for MessageBox
268 VclPtr<vcl::Window> mpAutoScrollWin; // window, that is in AutoScrollMode mode
269 VclPtr<vcl::Window> mpLastWheelWindow; // window, that last received a mouse wheel event
270 SalWheelMouseEvent maLastWheelEvent; // the last received mouse wheel event
272 StartTrackingFlags mnTrackFlags = StartTrackingFlags::NONE; // tracking flags
273 StartAutoScrollFlags mnAutoScrollFlags = StartAutoScrollFlags::NONE; // auto scroll flags
274 bool mbNoDeactivate = false; // true: do not execute Deactivate
275 bool mbNoSaveFocus = false; // true: menus must not save/restore focus
276 bool mbIsLiveResize = false; // true: skip waiting for events and low priority timers
279 typedef std::vector< std::pair< OUString, FieldUnit > > FieldUnitStringList;
281 struct ImplSVCtrlData
283 std::vector<Image> maCheckImgList; // ImageList for CheckBoxes
284 std::vector<Image> maRadioImgList; // ImageList for RadioButtons
285 std::unique_ptr<Image> mpDisclosurePlus;
286 std::unique_ptr<Image> mpDisclosureMinus;
287 ImplTBDragMgr* mpTBDragMgr = nullptr; // DragMgr for ToolBox
288 sal_uInt16 mnCheckStyle = 0; // CheckBox-Style for ImageList-Update
289 sal_uInt16 mnRadioStyle = 0; // Radio-Style for ImageList-Update
290 Color mnLastCheckFColor; // Last FaceColor for CheckImage
291 Color mnLastCheckWColor; // Last WindowColor for CheckImage
292 Color mnLastCheckLColor; // Last LightColor for CheckImage
293 Color mnLastRadioFColor; // Last FaceColor for RadioImage
294 Color mnLastRadioWColor; // Last WindowColor for RadioImage
295 Color mnLastRadioLColor; // Last LightColor for RadioImage
296 FieldUnitStringList maFieldUnitStrings; // list with field units
297 FieldUnitStringList maCleanUnitStrings; // same list but with some "fluff" like spaces removed
300 struct ImplSVHelpData
302 ~ImplSVHelpData();
303 bool mbContextHelp = false; // is ContextHelp enabled
304 bool mbExtHelp = false; // is ExtendedHelp enabled
305 bool mbExtHelpMode = false; // is in ExtendedHelp Mode
306 bool mbOldBalloonMode = false; // BalloonMode, before ExtHelpMode started
307 bool mbBalloonHelp = false; // is BalloonHelp enabled
308 bool mbQuickHelp = false; // is QuickHelp enabled
309 bool mbSetKeyboardHelp = false; // tiphelp was activated by keyboard
310 bool mbKeyboardHelp = false; // tiphelp was activated by keyboard
311 bool mbRequestingHelp = false; // In Window::RequestHelp
312 VclPtr<HelpTextWindow> mpHelpWin; // HelpWindow
313 sal_uInt64 mnLastHelpHideTime = 0; // ticks of last show
316 // "NWF" means "Native Widget Framework" and was the term used for the
317 // idea that StarView/OOo "widgets" should *look* (and feel) like the
318 // "native widgets" on each platform, even if not at all implemented
319 // using them. See http://people.redhat.com/dcbw/ooo-nwf.html .
321 struct ImplSVNWFData
323 int mnStatusBarLowerRightOffset = 0; // amount in pixel to avoid in the lower righthand corner
324 int mnMenuFormatBorderX = 0; // horizontal inner popup menu border
325 int mnMenuFormatBorderY = 0; // vertical inner popup menu border
326 ::Color maMenuBarHighlightTextColor = COL_TRANSPARENT; // override highlight text color
327 // in menubar if not transparent
328 bool mbMenuBarDockingAreaCommonBG = false; // e.g. WinXP default theme
329 bool mbDockingAreaSeparateTB = false; // individual toolbar backgrounds
330 // instead of one for docking area
331 bool mbDockingAreaAvoidTBFrames = false; ///< don't draw frames around the individual toolbars if mbDockingAreaSeparateTB is false
332 bool mbFlatMenu = false; // no popup 3D border
333 bool mbNoFocusRects = false; // on Aqua/Gtk3 use native focus rendering, except for flat buttons
334 bool mbNoFocusRectsForFlatButtons = false; // on Gtk3 native focusing is also preferred for flat buttons
335 bool mbNoFrameJunctionForPopups = false; // on Gtk4 popups are done via popovers and a toolbar menu won't align to its toolitem, so
336 // omit the effort the creation a visual junction
337 bool mbCenteredTabs = false; // on Aqua, tabs are centered
338 bool mbNoActiveTabTextRaise = false; // on Aqua the text for the selected tab
339 // should not "jump up" a pixel
340 bool mbProgressNeedsErase = false; // set true for platforms that should draw the
341 // window background before drawing the native
342 // progress bar
343 bool mbCanDrawWidgetAnySize = false; // set to true currently on gtk
345 /// entire drop down listbox resembles a button, no textarea/button parts (as currently on Windows)
346 bool mbDDListBoxNoTextArea = false;
347 bool mbAutoAccel = false; // whether accelerators are only shown when Alt is held down
348 bool mbRolloverMenubar = false; // theming engine supports rollover in menubar
349 // gnome#768128 I cannot see a route under wayland at present to support
350 // floating toolbars that can be redocked because there's no way to track
351 // that the toolbar is over a dockable area.
352 bool mbCanDetermineWindowPosition = true;
354 int mnListBoxEntryMargin = 0;
357 struct BlendFrameCache
359 Size m_aLastSize;
360 sal_uInt8 m_nLastAlpha;
361 Color m_aLastColorTopLeft;
362 Color m_aLastColorTopRight;
363 Color m_aLastColorBottomRight;
364 Color m_aLastColorBottomLeft;
365 BitmapEx m_aLastResult;
367 BlendFrameCache()
368 : m_aLastSize(0, 0)
369 , m_nLastAlpha(0)
370 , m_aLastColorTopLeft(COL_BLACK)
371 , m_aLastColorTopRight(COL_BLACK)
372 , m_aLastColorBottomRight(COL_BLACK)
373 , m_aLastColorBottomLeft(COL_BLACK)
378 struct ImplSchedulerContext
380 ImplSchedulerData* mpFirstSchedulerData[PRIO_COUNT] = { nullptr, }; ///< list of all active tasks per priority
381 ImplSchedulerData* mpLastSchedulerData[PRIO_COUNT] = { nullptr, }; ///< last item of each mpFirstSchedulerData list
382 ImplSchedulerData* mpSchedulerStack = nullptr; ///< stack of invoked tasks
383 ImplSchedulerData* mpSchedulerStackTop = nullptr; ///< top most stack entry to detect needed rescheduling during pop
384 SalTimer* mpSalTimer = nullptr; ///< interface to sal event loop / system timer
385 sal_uInt64 mnTimerStart = 0; ///< start time of the timer
386 sal_uInt64 mnTimerPeriod = SAL_MAX_UINT64; ///< current timer period
387 std::mutex maMutex; ///< the "scheduler mutex" (see
388 ///< vcl/README.scheduler)
389 bool mbActive = true; ///< is the scheduler active?
392 struct ImplSVData
394 ImplSVData();
395 ~ImplSVData();
396 SalData* mpSalData = nullptr;
397 SalInstance* mpDefInst = nullptr; // Default SalInstance
398 Application* mpApp = nullptr; // pApp
399 VclPtr<WorkWindow> mpDefaultWin; // Default-Window
400 bool mbDeInit = false; // Is VCL deinitializing
401 std::unique_ptr<SalSystem> mpSalSystem; // SalSystem interface
402 bool mbResLocaleSet = false; // SV-Resource-Manager
403 std::locale maResLocale; // Resource locale
404 ImplSchedulerContext maSchedCtx; // Data for class Scheduler
405 ImplSVAppData maAppData; // Data for class Application
406 ImplSVGDIData maGDIData; // Data for Output classes
407 ImplSVFrameData maFrameData; // Data for Frame classes
408 ImplSVWinData* mpWinData = nullptr; // Data for per-view Windows classes
409 ImplSVCtrlData maCtrlData; // Data for Control classes
410 ImplSVHelpData* mpHelpData; // Data for Help classes
411 ImplSVNWFData maNWFData;
412 UnoWrapperBase* mpUnoWrapper = nullptr;
413 VclPtr<vcl::Window> mpIntroWindow; // the splash screen
414 std::unique_ptr<DockingManager> mpDockingManager;
415 std::unique_ptr<BlendFrameCache> mpBlendFrameCache;
417 oslThreadIdentifier mnMainThreadId = 0;
418 rtl::Reference< vcl::DisplayConnectionDispatch > mxDisplayConnection;
420 css::uno::Reference< css::lang::XComponent > mxAccessBridge;
421 std::unique_ptr<vcl::SettingsConfigItem> mpSettingsConfigItem;
422 std::vector< vcl::DeleteOnDeinitBase* > maDeinitDeleteList;
423 std::unordered_map< int, OUString > maPaperNames;
425 css::uno::Reference<css::i18n::XCharacterClassification> m_xCharClass;
427 #if defined _WIN32
428 css::uno::Reference<css::datatransfer::clipboard::XClipboard> m_xSystemClipboard;
429 #endif
431 Link<LinkParamNone*,void> maDeInitHook;
433 // LOK & headless backend specific hooks
434 LibreOfficeKitPollCallback mpPollCallback = nullptr;
435 LibreOfficeKitWakeCallback mpWakeCallback = nullptr;
436 void *mpPollClosure = nullptr;
438 void dropCaches();
439 void dumpState(rtl::OStringBuffer &rState);
442 css::uno::Reference<css::i18n::XCharacterClassification> const& ImplGetCharClass();
444 void ImplDeInitSVData();
445 VCL_PLUGIN_PUBLIC basegfx::SystemDependentDataManager& ImplGetSystemDependentDataManager();
446 VCL_PLUGIN_PUBLIC vcl::Window* ImplGetDefaultWindow();
447 vcl::Window* ImplGetDefaultContextWindow();
448 const std::locale& ImplGetResLocale();
449 VCL_PLUGIN_PUBLIC OUString VclResId(TranslateId sContextAndId);
450 DockingManager* ImplGetDockingManager();
451 BlendFrameCache* ImplGetBlendFrameCache();
452 void GenerateAutoMnemonicsOnHierarchy(const vcl::Window* pWindow);
454 VCL_PLUGIN_PUBLIC ImplSVHelpData& ImplGetSVHelpData();
456 VCL_DLLPUBLIC bool ImplCallPreNotify( NotifyEvent& rEvt );
458 VCL_PLUGIN_PUBLIC ImplSVData* ImplGetSVData();
459 VCL_PLUGIN_PUBLIC void ImplHideSplash();
461 #ifdef _WIN32
462 bool ImplInitAccessBridge();
463 #endif
465 const FieldUnitStringList& ImplGetFieldUnits();
466 const FieldUnitStringList& ImplGetCleanedFieldUnits();
468 struct ImplSVEvent
470 void* mpData;
471 Link<void*,void> maLink;
472 VclPtr<vcl::Window> mpInstanceRef;
473 VclPtr<vcl::Window> mpWindow;
474 bool mbCall;
477 extern int nImplSysDialog;
479 inline SalData* GetSalData() { return ImplGetSVData()->mpSalData; }
480 inline void SetSalData(SalData* pData) { ImplGetSVData()->mpSalData = pData; }
481 inline SalInstance* GetSalInstance() { return ImplGetSVData()->mpDefInst; }
483 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */