office-gobmx/vcl
Caolán McNamara 2beb392239 Related: tdf#141197 critical a11y warning
** (soffice:19098): CRITICAL **: 13:44:40.365:
AtkObject* atk_object_wrapper_ref(const com::sun::uno::Reference<com::sun::accessibility::XAccessible>&, bool):
assertion 'bool(rxAccessible)' failed

probably since...

commit cbc18cc904
Date:   Mon Nov 23 21:03:28 2020 +0100

    tdf#138425 vcl/gtk activate main menu in UpdateFull

Change-Id: Ieb181e02bb0d2a907aec8534349ec2a80fd9c7e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113000
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-03-24 10:13:24 +01:00
..
android
backendtest add PixelFormat enum that replaces bit count in Bitmap/BitmapEx 2021-03-13 12:17:49 +01:00
headless do not enable mbSupportsBitmap32 for headless (tdf#141171) 2021-03-23 10:58:45 +01:00
inc use unique_ptr in AbstractTrueTypeFont 2021-03-23 09:07:43 +01:00
ios Log successful mapping from system pasteboard format to internal MIME type 2021-03-23 10:41:25 +01:00
jsdialog jsdialog: fix free JsonWriter assertion 2021-03-08 09:00:21 +01:00
null
osx tdf#140856 macOS listbox rendering 2021-03-07 18:48:57 +01:00
qa tdf#141171: vcl_pdfexport: Add unittest 2021-03-24 08:38:37 +01:00
qt5 vcl/floatwin.hxx can be toolkit only now 2021-03-03 15:54:56 +01:00
quartz tdf#141063 Always use region rectangles for clipping on macOS 2021-03-23 10:06:39 +01:00
skia round polygon points before merging them for Skia drawing (tdf#140848) 2021-03-17 18:01:00 +01:00
source Related: tdf#141197 critical a11y warning 2021-03-24 10:13:24 +01:00
uiconfig factor out as a ResizableDockingWindow 2021-02-22 15:14:04 +01:00
unx cid#707834 silence Uninitialized scalar field 2021-03-22 15:05:49 +01:00
win Drop 'static_cast<cppu::OWeakObject*>' syntactic noise 2021-03-10 08:22:26 +01:00
workben Add -a option to dump all pasteboard types plus some minor cleanup 2021-03-23 16:10:41 +02:00
AllLangMoTarget_vcl.mk
commonfuzzer.mk Move GIF writer from filter module into VCL 2021-02-18 04:12:27 +01:00
CppunitTest_vcl_apitests.mk
CppunitTest_vcl_app_test.mk
CppunitTest_vcl_backend_test.mk
CppunitTest_vcl_bitmap_render_test.mk
CppunitTest_vcl_bitmap_test.mk vcl: test for reading the XPM format 2021-03-18 04:02:36 +01:00
CppunitTest_vcl_bitmapprocessor_test.mk
CppunitTest_vcl_blocklistparser_test.mk
CppunitTest_vcl_complextext.mk
CppunitTest_vcl_dialogs_test.mk
CppunitTest_vcl_errorhandler.mk
CppunitTest_vcl_filter_igif.mk
CppunitTest_vcl_filter_ipdf.mk
CppunitTest_vcl_filters_test.mk
CppunitTest_vcl_font.mk
CppunitTest_vcl_fontcharmap.mk
CppunitTest_vcl_fontfeature.mk
CppunitTest_vcl_fontmetric.mk
CppunitTest_vcl_gen.mk
CppunitTest_vcl_graphic_test.mk Move GIF writer from filter module into VCL 2021-02-18 04:12:27 +01:00
CppunitTest_vcl_jpeg_read_write_test.mk
CppunitTest_vcl_lifecycle.mk
CppunitTest_vcl_mnemonic.mk
CppunitTest_vcl_outdev.mk
CppunitTest_vcl_pdfexport.mk
CppunitTest_vcl_pdfium_library_test.mk
CppunitTest_vcl_png_test.mk
CppunitTest_vcl_skia.mk
CppunitTest_vcl_svm_test.mk
CppunitTest_vcl_timer.mk
CppunitTest_vcl_type_serializer_test.mk
CppunitTest_vcl_widget_definition_reader_test.mk
CustomTarget_gtk3_kde5_moc.mk
CustomTarget_kf5_moc.mk
CustomTarget_nativecalc.mk
CustomTarget_nativecore.mk
CustomTarget_nativedraw.mk
CustomTarget_nativemath.mk
CustomTarget_nativewriter.mk
CustomTarget_qt5_moc.mk
Executable_602fuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_bmpfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_cgmfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_diffuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_docxfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_dxffuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_epsfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_fftester.mk
Executable_fodpfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_fodsfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_fodtfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_giffuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_htmlfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_hwpfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_icontest.mk
Executable_jpgfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_lo_kde5filepicker.mk
Executable_lwpfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_metfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_mmlfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_mtfdemo.mk
Executable_mtpfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_olefuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_pcdfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_pctfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_pcxfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_pngfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_ppmfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_pptfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_pptxfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_psdfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_qpwfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_rasfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_rtffuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_scrtffuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_sftfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_slkfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_svdemo.mk
Executable_svmfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_svpclient.mk
Executable_svptest.mk
Executable_tgafuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_tiffuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_ui-previewer.mk
Executable_vcldemo.mk
Executable_visualbackendtest.mk
Executable_wksfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_wmffuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_ww2fuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_ww6fuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_ww8fuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_xbmfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_xlsfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_xlsxfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
Executable_xpmfuzzer.mk Upgrade fuzzers to LIB_FUZZING_ENGINE 2021-02-28 19:46:58 +01:00
IwyuFilter_vcl.yaml
Library_desktop_detector.mk
Library_vcl.mk vcl: add BmpReader{Writer} and many BMP format test 2021-03-16 09:46:37 +01:00
Library_vclplug_gen.mk vcl/floatwin.hxx can be toolkit only now 2021-03-03 15:54:56 +01:00
Library_vclplug_gtk3.mk vcl/floatwin.hxx can be toolkit only now 2021-03-03 15:54:56 +01:00
Library_vclplug_gtk3_kde5.mk vcl/floatwin.hxx can be toolkit only now 2021-03-03 15:54:56 +01:00
Library_vclplug_kf5.mk
Library_vclplug_osx.mk vcl/floatwin.hxx can be toolkit only now 2021-03-03 15:54:56 +01:00
Library_vclplug_qt5.mk vcl/floatwin.hxx can be toolkit only now 2021-03-03 15:54:56 +01:00
Library_vclplug_win.mk vcl/floatwin.hxx can be toolkit only now 2021-03-03 15:54:56 +01:00
Makefile
Module_vcl.mk
Package_fontunxppds.mk
Package_fontunxpsprint.mk
Package_opengl_denylist.mk
Package_osxres.mk
Package_skia_denylist.mk
Package_theme_definitions.mk
Package_tipoftheday.mk ToD previews added 2021-02-27 13:11:05 +01:00
Package_toolbarmode.mk
README
README.GDIMetaFile
README.lifecycle Fix typo 2021-03-19 07:53:41 +01:00
README.scheduler
README.vars
StaticLibrary_fuzzer_calc.mk
StaticLibrary_fuzzer_core.mk
StaticLibrary_fuzzer_draw.mk
StaticLibrary_fuzzer_math.mk
StaticLibrary_fuzzer_writer.mk
StaticLibrary_fuzzerstubs.mk
StaticLibrary_glxtest.mk
StaticLibrary_vclmain.mk
UIConfig_vcl.mk move dockingwindow.ui to vcl 2021-02-22 15:13:41 +01:00
vcl.android.component
vcl.common.component
vcl.headless.component
vcl.ios.component
vcl.macosx.component
vcl.unx.component
vcl.windows.component
vclplug_win.component
WinResTarget_vcl.mk

Visual Class Library 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 (under construction)

unx/
	+ X11 backend and its sub-platforms
	gtk3/
		+ GTK3 support
	kf5/
		+ KF5 support (based on qt5 VCL plugin mentioned above)
	gtk3_kde5/
		+ GTK3 support with KDE5 file pickers (alternative to native kf5 one)
	generic/
		+ raw X11 support

		plugadapt/
			+ pluggable framework to select correct unx backend

		dtrans/
			+ "data transfer" - clipboard handling
			+ http://stackoverflow.com/questions/3261379/getting-html-source-or-rich-text-from-the-x-clipboard
			  for tips how to show the current content of the
			  clipboard


How the platform abstraction works

	+ InitVCL calls 'CreateSalInstance'
		+ this is implemented by the compiled-in platform backend
		+ it stores various bits of global state in the
		  'SalData' (inc/saldatabasic.hxx) structure but:
	+ 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".

== 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
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:

3) 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.