office-gobmx/vcl
Noel Grandin bacee60a59 ref-counting vcl::Window subclasses
Points of discussion
--------------------

(*) where in the Window destructor should dispose() be called?
   It's a seriously large method.

(*) we're going to need similar typedefs and declarations for every
single sub-class of vcl::Window, I assume that I will need to create a
macro to make it less verbose.

TODO
----

Update clang plugin to verify that:
(a) dispose() methods always call their superclass dispose()
(b) dispose() methods don't forget to clear any references owned
    by that class.

Change-Id: I873d5d5166f811e2f65e49327cc98862559fcf30
2014-10-29 09:36:17 +02:00
..
android
generic cid#735557 Logically dead code 2014-10-27 15:43:51 +02:00
headless Fix -fsanitize=signed-integer-overflow (when long int is 32-bit) 2014-10-28 17:42:48 +01:00
inc Fraction: Revert "fdo#81356: convert Fraction to boost::rational<long> - wip" 2014-10-23 18:34:39 +02:00
ios vcl/layout.hxx was included twice 2014-10-18 11:19:27 +02:00
null
osx fdo#84938: replace MENUITEM constants with enum 2014-10-23 12:55:35 +02:00
qa coverity#982593 experiment with silencing Infinite loop 2014-10-28 15:06:36 +00:00
quartz
source ref-counting vcl::Window subclasses 2014-10-29 09:36:17 +02:00
test
uiconfig/ui
unx coverity#735350 silence Unchecked return value from library 2014-10-28 10:31:27 +00:00
win/source fdo#84938: replace MENUITEM constants with enum 2014-10-23 12:55:35 +02:00
workben Include <iostream> explicitly 2014-10-23 21:58:03 +03:00
AllLangResTarget_vcl.mk
CppunitTest_vcl_app_test.mk
CppunitTest_vcl_complextext.mk
CppunitTest_vcl_filters_test.mk
CppunitTest_vcl_fontcharmap.mk
CppunitTest_vcl_timer.mk
CppunitTest_vcl_wmf_test.mk
CustomTarget_afm_hash.mk
CustomTarget_kde4_moc.mk
CustomTarget_kde_moc.mk
CustomTarget_tde_moc.mk
Executable_icontest.mk
Executable_kdefilepicker.mk
Executable_svdemo.mk
Executable_svpclient.mk
Executable_svptest.mk
Executable_tdefilepicker.mk
Executable_ui-previewer.mk
Executable_vcldemo.mk
Executable_xid_fullscreen_on_all_monitors.mk
Library_desktop_detector.mk
Library_vcl.mk
Library_vclopengl.mk
Library_vclplug_gen.mk
Library_vclplug_gtk.mk
Library_vclplug_gtk3.mk
Library_vclplug_kde.mk
Library_vclplug_kde4.mk
Library_vclplug_svp.mk
Library_vclplug_tde.mk
Makefile
Module_vcl.mk
Package_fontunxppds.mk remove --without-ppds option now 2014-10-23 14:54:52 +01:00
Package_fontunxpsprint.mk
Package_osxres.mk
README
StaticLibrary_headless.mk
StaticLibrary_vclmain.mk
UIConfig_vcl.mk
vcl.android.component
vcl.headless.component
vcl.ios.component
vcl.macosx.component
vcl.unx.component
vcl.windows.component
WinResTarget_vcl.mk

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

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

source/
	+ the main cross-platform chunk of source

inc/
	+ cross-platform abstraction headers

generic/
	+ shared helper code for *some* of the backends, actually built into vcl.

headless/
	+ a backend renderer that draws to bitmaps

android/
	+ Android backend

osx/
	+ OS X backend

ios/
	+ iOS backend

quartz/
	+ code common to OS X and iOS

win/
	+ Windows backend

unx/
	+ X11 backend and its sub-platforms

	plugadapt/
		+ pluggable framework to select correct unx backend
	gtk/
		+ GTK2 support
	gtk3/
		+ GTK3.2+ support
	kde/
		+ KDE3 support
	kde4/
		+ KDE4 support
	generic/
		+ raw X11 support

		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'
		+ ths 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 SolarMutexe, 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).

== COM threading ==

The way COM is used in LO generally:
- vcl InitSalData() puts main thread into Single-threaded Apartment (STA)
- oslWorkerWrapperFunction() puts every thread spawned via oslCreateThread()
  into MTA (free-threaded)

== 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 MetaFile)
3) the pages' MetaFiles 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 MetaFile 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 in higher debug-levels, where
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.

touch vcl/source/gdi/pdfwriter* && make vcl dbglevel=3

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

LD_LIBRARY_PATH=$PWD/instdir/ure/lib workdir/LinkTarget/Executable/pdfunzip input.pdf output.pdf