office-gobmx/vcl
Caolán McNamara b6ff644abc Resolves: tdf#148830 ensure SplitWindow has enough space for splitter
Change-Id: Ib60b0e8acdffcda5b6835ff7207fffc4123d5c63
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172086
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-08-20 09:34:29 +02:00
..
android split Point/Size/Rectangle into AbsoluteScreenPixel* types 2023-08-02 08:13:15 +02:00
backendtest qt: Remove "5" from render backend name 2024-08-14 14:01:03 +02:00
headless Related: cool#9735 vcl lok: add an AnyInput() callback 2024-08-14 11:17:33 +02:00
inc Implement Custom Font Collections on pre-Windows 10 systems 2024-08-20 04:34:26 +02:00
ios Move break inside conditional statement to match macOS code 2024-07-11 15:58:59 +02:00
jsdialog LOKit: Enable the "Interaction..." command for Impress. 2024-08-18 11:05:06 +02:00
null tdf#156230 remove now unused various bit and pieces 2023-07-31 02:18:25 +02:00
osx tdf#162190 handle Command-w 2024-07-27 03:06:28 +02:00
qa qt: Remove "5" from render backend name 2024-08-14 14:01:03 +02:00
qt5 Emscripten: Clean up SolarMutex 2024-08-18 15:10:00 +02:00
qt6 tdf#162351 tdf#130857 qt weld: Add basic QtInstanceButton 2024-08-07 07:08:35 +02:00
quartz Remove now unneeded osl/diagnose.h 2024-07-20 10:20:31 +02:00
skia Implement Custom Font Collections on pre-Windows 10 systems 2024-08-20 04:34:26 +02:00
source Resolves: tdf#148830 ensure SplitWindow has enough space for splitter 2024-08-20 09:34:29 +02:00
uiconfig Fix regression Gtk-CRITICAL+Gtk-WARNING on vcl/wizard.ui 2024-07-04 13:46:43 +02:00
unx cid#1557699 COPY_INSTEAD_OF_MOVE 2024-08-18 11:04:45 +02:00
win Make sure to anti-alias fonts on Windows, when required 2024-08-19 16:00:22 +02:00
workben Simplify initialization of font name vector in vcldemo 2024-08-14 23:42:49 +02:00
AllLangMoTarget_vcl.mk
commonfuzzer.mk move writerfilter inside sw 2024-04-18 09:16:12 +02:00
CppunitTest_vcl_animation.mk editeng: Use Tools::Point::RotateAround instead of our own 2023-07-16 12:54:58 +02:00
CppunitTest_vcl_apitests.mk
CppunitTest_vcl_app_test.mk tdf#124672 for hicontrast white/black bg select either Sifr vs Sifr Dark 2022-10-08 17:34:34 +02:00
CppunitTest_vcl_backend_test.mk
CppunitTest_vcl_bitmap_render_test.mk
CppunitTest_vcl_bitmap_test.mk Use less epoxy external headers dependency 2023-09-23 10:38:36 +02:00
CppunitTest_vcl_bitmapprocessor_test.mk
CppunitTest_vcl_blocklistparser_test.mk
CppunitTest_vcl_cjk.mk
CppunitTest_vcl_dialogs_test.mk
CppunitTest_vcl_drawmode.mk
CppunitTest_vcl_errorhandler.mk
CppunitTest_vcl_filter_igif.mk
CppunitTest_vcl_filter_ipdf.mk CppunitTest_vcl_filter_ipdf: inherit from UnoApiTest 2022-11-22 14:19:44 +01:00
CppunitTest_vcl_filters_test.mk
CppunitTest_vcl_font.mk vcl: test getting glyph boundary rect from LogicalFontInstance 2022-11-27 10:40:17 +01:00
CppunitTest_vcl_fontcharmap.mk
CppunitTest_vcl_fontfeature.mk
CppunitTest_vcl_fontmetric.mk
CppunitTest_vcl_gen.mk UnoApiTest: simplify code by using tempfile member 2022-11-08 11:54:22 +01:00
CppunitTest_vcl_gradient.mk
CppunitTest_vcl_graphic_test.mk vcl: change (graphic) Manager into a general memory manager 2024-03-30 15:21:10 +01:00
CppunitTest_vcl_gtk3_a11y.mk gtk3 a11y tests: Always use dbus-daemon for the AT-SPI bus 2024-08-01 10:18:19 +02:00
CppunitTest_vcl_jpeg_read_write_test.mk
CppunitTest_vcl_lifecycle.mk
CppunitTest_vcl_mnemonic.mk
CppunitTest_vcl_outdev.mk
CppunitTest_vcl_pdfexport.mk tdf#153040 PDF export: disable export of form fields as PDF forms by default 2024-07-30 12:16:50 +02:00
CppunitTest_vcl_pdfexport2.mk tdf#113866 Add test. 2023-12-12 10:15:05 +01:00
CppunitTest_vcl_pdfium_library_test.mk
CppunitTest_vcl_png_test.mk
CppunitTest_vcl_skia.mk
CppunitTest_vcl_svm_test.mk Use less epoxy external headers dependency 2023-09-23 10:38:36 +02:00
CppunitTest_vcl_text.mk tdf#124116 Correct Writer text shaping across formatting changes 2024-05-22 19:20:38 +02:00
CppunitTest_vcl_textlayout.mk vcl: test BreakLinesWithIterator with hyphens 2023-12-28 02:33:50 +01:00
CppunitTest_vcl_timer.mk
CppunitTest_vcl_type_serializer_test.mk
CppunitTest_vcl_unx_generic.mk Fix typo 2024-07-19 10:10:46 +02:00
CppunitTest_vcl_widget_definition_reader_test.mk
CustomTarget_gtk3_kde5_moc.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
CustomTarget_kf5_moc.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
CustomTarget_kf6_moc.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
CustomTarget_nativecalc.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
CustomTarget_nativecore.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
CustomTarget_nativedraw.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
CustomTarget_nativemath.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
CustomTarget_nativewriter.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
CustomTarget_qt5_moc.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
CustomTarget_qt6_moc.mk makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo) 2024-05-03 16:06:14 +02:00
Executable_602fuzzer.mk
Executable_bmpfuzzer.mk
Executable_cgmfuzzer.mk
Executable_dbffuzzer.mk
Executable_diffuzzer.mk
Executable_docxfuzzer.mk
Executable_dxffuzzer.mk
Executable_epsfuzzer.mk
Executable_fftester.mk
Executable_fodpfuzzer.mk
Executable_fods2xlsfuzzer.mk fods2xls fuzzer 2024-03-19 22:35:06 +01:00
Executable_fodsfuzzer.mk
Executable_fodt2pdffuzzer.mk add a fodt to pdf fuzzer 2023-04-29 20:42:51 +02:00
Executable_fodtfuzzer.mk
Executable_giffuzzer.mk
Executable_htmlfuzzer.mk
Executable_hwpfuzzer.mk
Executable_icontest.mk Use less epoxy external headers dependency 2023-09-23 10:38:36 +02:00
Executable_jpgfuzzer.mk
Executable_listfonts.mk
Executable_listglyphs.mk vcl: list the glyphs and bound rects of a specified font 2022-11-25 14:04:20 +01:00
Executable_lo_kde5filepicker.mk Use less epoxy external headers dependency 2023-09-23 10:38:36 +02:00
Executable_lwpfuzzer.mk
Executable_metfuzzer.mk
Executable_minvcl.mk
Executable_mmlfuzzer.mk
Executable_mtfdemo.mk
Executable_mtpfuzzer.mk
Executable_olefuzzer.mk
Executable_pcdfuzzer.mk
Executable_pctfuzzer.mk
Executable_pcxfuzzer.mk
Executable_pngfuzzer.mk
Executable_ppmfuzzer.mk
Executable_pptfuzzer.mk
Executable_pptxfuzzer.mk
Executable_psdfuzzer.mk
Executable_qpwfuzzer.mk
Executable_rasfuzzer.mk
Executable_rtffuzzer.mk
Executable_schtmlfuzzer.mk add a sc-html fuzzer 2024-03-20 18:24:17 +01:00
Executable_scrtffuzzer.mk
Executable_sftfuzzer.mk
Executable_slkfuzzer.mk
Executable_svdemo.mk
Executable_svgfuzzer.mk add a svg fuzzer 2023-04-26 17:41:41 +02:00
Executable_svmfuzzer.mk
Executable_svpclient.mk
Executable_svptest.mk
Executable_tgafuzzer.mk
Executable_tiffuzzer.mk
Executable_vcldemo.mk Use less epoxy external headers dependency 2023-09-23 10:38:36 +02:00
Executable_visualbackendtest.mk
Executable_webpfuzzer.mk
Executable_wksfuzzer.mk
Executable_wmffuzzer.mk
Executable_ww2fuzzer.mk
Executable_ww6fuzzer.mk
Executable_ww8fuzzer.mk
Executable_xbmfuzzer.mk
Executable_xlsfuzzer.mk
Executable_xlsxfuzzer.mk
Executable_xpmfuzzer.mk
Executable_zipfuzzer.mk add a fuzzer to test zip recovery mode 2023-04-25 19:20:47 +02:00
IwyuFilter_vcl.yaml tdf#146619 Remove unused includes from vcl/inc 2023-08-23 08:06:43 +02:00
Library_vcl.mk vcl: Allow DBus-based session inhibition without requiring X11 2024-08-15 20:36:35 +02:00
Library_vclplug_gen.mk Revert "make skia into static library" 2024-05-07 20:34:39 +02:00
Library_vclplug_gtk3.mk gtk3 a11y: Drop WindowEventHandler completely 2024-05-07 16:16:55 +02:00
Library_vclplug_gtk3_kde5.mk gtk3 a11y: Drop WindowEventHandler completely 2024-05-07 16:16:55 +02:00
Library_vclplug_gtk4.mk gtk4 a11y: Implement new GtkAccessibleTextInterface 2024-02-22 15:20:36 +01:00
Library_vclplug_kf5.mk kf5: Drop "5" from VCLPLUG_KF5_{IMPLEMENTATION,PUBLIC} defines 2023-06-22 22:15:19 +02:00
Library_vclplug_kf6.mk kf6: Add a kf6 VCL plugin 2023-06-22 22:16:11 +02:00
Library_vclplug_osx.mk Revert "make skia into static library" 2024-05-07 20:34:39 +02:00
Library_vclplug_qt5.mk tdf#162351 tdf#130857 qt weld: Add basic QtInstanceButton 2024-08-07 07:08:35 +02:00
Library_vclplug_qt6.mk tdf#162351 tdf#130857 qt weld: Add basic QtInstanceButton 2024-08-07 07:08:35 +02:00
Library_vclplug_win.mk Revert "make skia into static library" 2024-05-07 20:34:39 +02:00
Makefile
Module_vcl.mk tdf#162072 vcl, fontconfig: consider font-family-generic for substitute 2024-07-18 17:45:14 +02:00
Package_fontunxppds.mk
Package_fontunxpsprint.mk
Package_opengl_denylist.mk
Package_osxres.mk
Package_skia_denylist.mk
Package_theme_definitions.mk
Package_tipoftheday.mk Resolves tdf#131177 - Replace Hard-Coded TotD bulb by themeable icon 2023-03-09 17:07:04 +00:00
Package_toolbarmode.mk
README.GDIMetaFile.md Fix typo 2024-03-04 10:37:13 +01:00
README.lifecycle.md Fix "lets" -> "let's" 2024-06-29 17:22:12 +02:00
README.md Update vcl README wrt VCL plugins 2023-11-23 19:01:58 +01:00
README.scheduler.md
README.vars.md tdf#130857 Use native qt widgets - simple message dialog 2024-01-08 22:52:59 +01:00
StaticLibrary_fuzzer_calc.mk
StaticLibrary_fuzzer_core.mk
StaticLibrary_fuzzer_draw.mk
StaticLibrary_fuzzer_math.mk
StaticLibrary_fuzzer_writer.mk
StaticLibrary_vclmain.mk
UIConfig_vcl.mk
vcl.common.component
vcl.common.component.android
vcl.common.component.headless
vcl.common.component.ios
vcl.common.component.macosx
vcl.common.component.unx
vcl.common.component.windows
vclplug_win.component
WinResTarget_vcl.mk

Visual Class Library (VCL)

Visual Class Library (VCL) is responsible for the widgets (windowing, buttons, controls, file-pickers etc.), operating system abstraction, including basic rendering (e.g. the output device).

It should not be confused with Borland's Visual Component Library, which is entirely unrelated.

VCL provides a graphical toolkit similar to gtk+, Qt, SWING etc.

  • source/

    • the main cross-platform chunk of source
  • inc/

    • cross-platform abstraction headers
  • headless/

    • a backend renderer that draws to bitmaps
  • android/

    • Android backend
  • osx/

    • macOS backend
  • ios/

    • iOS backend
  • quartz/

    • code common to macOS and iOS
  • win/

    • Windows backend
  • qt5/

    • Qt5
  • qt6/

    • Qt6
  • unx/

    • X11 backend and its sub-platforms
  • How the platform abstraction works

    • InitVCL calls 'CreateSalInstance'
      • this is implemented by the compiled platform backends
    • the SalInstance vtable is the primary outward facing gateway API for platform backends
      • It is a factory for: SalFrames, SalVirtualDevices, SalPrinters, Timers, the SolarMutex, Drag&Drop and other objects, as well as the primary event loop wrapper.

Note: references to "SV" in the code mean StarView, which was a portable C++ class library for GUIs, with very old roots, that was developed by StarDivision. Nowadays it is not used by anything except LibreOffice (and OpenOffice).

"svp" stands for "StarView Plugin".

SalData implementations

Each backend must provide an implementation of the SalData class. There is no defined interface, so feel free to implement whatever suits your platform.

If your platform does font handling based on Freetype and Fontconfig, it's highly recommended to use GenericUnixSalData as the base class; there isn't really much *nix stuff in it.

Currently Windows, iOS and MacOSX have independent SalData implementations.

COM Threading

The way COM is used in LO generally:

  • vcl puts main thread into Single-threaded Apartment (STA)
  • oslWorkerWrapperFunction() puts every thread spawned via oslCreateThread() into MTA (free-threaded)

GDIMetafile

GDIMetafile is a vector drawing representation that corresponds directly to the SVM (StarView Metafile) format; it is extremely important as an intermediate format in all sorts of drawing and printing operations.

There is a class MetafileXmlDump in include/vcl/mtfxmldump.hxx that can store a GDIMetafile as XML, which makes debugging much easier since you can just use "diff" to see changes.

EMF+

emf+ is vector file format used by MSO and is successor of wmf and emf formats. see http://msdn.microsoft.com/en-us/library/cc230724.aspx for documentation. note that we didn't have this documentation from start, so part of the code predates to the time when we had guessed some parts and can be enhanced today. there also still many thing not complete

emf+ is handled a bit differently compared to original emf/wmf files, because GDIMetafile is missing features we need (mostly related to transparency, argb colors, etc.)

emf/wmf is translated to GDIMetafile in import filter vcl/source/filter/wmf and so special handling ends here

emf+ is encapsulated into GDIMetafile inside comment records and parsed/rendered later, when it reaches cppcanvas. It is parsed and rendered in cppcanvas/source/mtfrenderer. also note that there are emf+-only and emf+-dual files. dual files contains both types of records (emf and emf+) for rendering the images. these can used also in applications which don't know emf+. in that case we must ignore emf records and use emf+ for rendering. for more details see the documentation.

Parsing

wmf/emf filter --> GDI metafile with emf+ in comments --> cppcanvas metafile renderer

lately the GDIMetafile rendering path changed which also influenced emf+ rendering. now many things happen in drawing layer, where GDIMetafile is translated into drawing layer primitives. for metafiles with emf+ we let the mtfrenderer render them into bitmap (with transparency) and use this bitmap in drawinlayer. cleaner solution for current state would be to extend the drawing layer for missing features and move parsing into drawing layer (might be quite a lot of work). intermediary enhancement would be to know better the needed size/resolution of the bitmap, before we render emf+ into bitmap in drawing layer. Thorsten is working on the same problem with svg rendering, so hopefully his approach could be extended for emf+ as well. the places in drawing layer where we use canvas mtfrenderer to render into bitmaps can be found when you grep for GetUseCanvas. also look at vcl/source/gdi/gdimetafile.cxx where you can look for UseCanvas again. moving the parsing into drawinglayer might also have nice side effect for emf+-dual metafiles. in case the emf+ records are broken, it would be easier to use the duplicit emf rendering. fortunately we didn't run into such a broken emf+ file yet. but there were already few cases where we first though that the problem might be because of broken emf+ part. so far it always turned out to be another problem.

Rendering

before

vcl --> cppcanvas metafile renderer --> vcl

now

drawing layer --> vcl --> cppcanvas metafile renderer --> vcl --> drawing layer

another interesting part is actual rendering into canvas bitmap and using that bitmap later in code using vcl API.

EMF+ implementation has some extensive logging, best if you do a dbgutil build, and then

export SAL_LOG=+INFO.cppcanvas.emf+INFO.vcl.emf

before running LibreOffice; it will give you lots of useful hints.

You can also fallback to EMF (from EMF+) rendering via

export EMF_PLUS_DISABLE=1

Printing/PDF Export

Printing from Writer works like this:

  1. individual pages print by passing an appropriate OutputDevice to XRenderable
  2. in drawinglayer, a VclMetafileProcessor2D is used to record everything on the page (because the OutputDevice has been set up to record a GDIMetaFile)
  3. the pages' GDIMetaFiles are converted to PDF by the vcl::PDFWriter in vcl/source/gdi/pdfwriter*

Creating the ODF thumbnail for the first page works as above except step 3 is:

  1. the GDIMetaFile is replayed to create the thumbnail

On-screen display differs in step 1 and 2:

  1. the VCL Window gets invalidated somehow and paints itself
  2. in drawinglayer, a VclPixelProcessor2D is used to display the content

Debugging PDF export

Debugging the PDF export becomes much easier when compression is disabled (so the PDF file is directly readable) and the MARK function puts comments into the PDF file about which method generated the following PDF content.

The compression can be disabled even using an env. var:

export VCL_DEBUG_DISABLE_PDFCOMPRESSION=1

To de-compress the contents of a PDF file written by a release build or other programs, use the "pdfunzip" tool:

bin/run pdfunzip input.pdf output.pdf

SolarMutexGuard

The solar mutex is the "big kernel lock" of LibreOffice, a global one. It's a recursive mutex, so it's allowed to take the lock on the same thread multiple times, and only the last unlock will actually release the mutex.

UNO methods on components can be called from multiple threads, while the majority of the codebase is not prepared for multi-threading. One way to get around this mismatch is to create a SolarMutexGuard instance at the start of each & every UNO method implementation, but only when it is necessary:

  • Only acquire the SolarMutex if you actually need it (e.g., not in functions that return static information).

  • Only around the code that actually needs it (i.e., never call out with it locked).

This way you ensure that code (not prepared for multithreading) is still executed only on a single thread.

In case you expect that your caller takes the solar mutex, then you can use the DBG_TESTSOLARMUTEX() macro to assert that in dbgutil builds.

Event listeners are a special (but frequent) case of the "never call out with a mutex (SolarMutex or other) locked" fundamental rule:

  • UNO methods can be called from multiple threads, so most implementations take the solar mutex as their first action when necessary.

  • This can be problematic if later calling out (an event handler is called), where the called function may be an UNO method implementation as well and may be invoked on a different thread.

  • So we try to not own the solar mutex, whenever we call out (invoke event listeners).

In short, never hold any mutex unless necessary, especially not when calling out.

Read More