tdf#115863: fix TIFF import
[LibreOffice.git] / vcl / README
blobd7d36044630adbdb64fc47c4661c01f61f86d1fb
1 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).
3 VCL provides a graphical toolkit similar to gtk+, Qt, SWING etc.
5 source/
6         + the main cross-platform chunk of source
8 inc/
9         + cross-platform abstraction headers
11 headless/
12         + a backend renderer that draws to bitmaps
14 android/
15         + Android backend
17 osx/
18         + OS X backend
20 ios/
21         + iOS backend
23 quartz/
24         + code common to OS X and iOS
26 win/
27         + Windows backend
29 qt5/
30         + Qt5 (under construction)
32 unx/
33         + X11 backend and its sub-platforms
35         gtk/
36                 + GTK2 support
37         gtk3/
38                 + GTK3 support
39         kde4/
40                 + KDE4 support
41         kde5/
42                 + KDE5 support (under construction)
43         gtk3_kde5/
44                 + GTK3 support with KDE5 file pickers (until kde5 is finished)
45         generic/
46                 + raw X11 support
48                 plugadapt/
49                         + pluggable framework to select correct unx backend
51                 dtrans/
52                         + "data transfer" - clipboard handling
53                         + http://stackoverflow.com/questions/3261379/getting-html-source-or-rich-text-from-the-x-clipboard
54                           for tips how to show the current content of the
55                           clipboard
58 How the platform abstraction works
60         + InitVCL calls 'CreateSalInstance'
61                 + this is implemented by the compiled-in platform backend
62                 + it stores various bits of global state in the
63                   'SalData' (inc/saldatabasic.hxx) structure but:
64         + the SalInstance vtable is the primary outward facing gateway
65           API for platform backends
66                 + It is a factory for:
67                   SalFrames, SalVirtualDevices, SalPrinters,
68                   Timers, the SolarMutex, Drag&Drop and other
69                   objects, as well as the primary event loop wrapper.
71 Note: references to "SV" in the code mean StarView, which was a
72 portable C++ class library for GUIs, with very old roots, that was
73 developed by StarDivision. Nowadays it is not used by anything except
74 LibreOffice (and OpenOffice).
76 "svp" stands for "StarView Plugin".
78 == COM threading ==
80 The way COM is used in LO generally:
81 - vcl InitSalData() puts main thread into Single-threaded Apartment (STA)
82 - oslWorkerWrapperFunction() puts every thread spawned via oslCreateThread()
83   into MTA (free-threaded)
85 == GDIMetafile ==
87 GDIMetafile is a vector drawing representation that corresponds directly
88 to the SVM (StarView Metafile) format; it is extremely important as
89 an intermediate format in all sorts of drawing and printing operations.
91 There is a class MetafileXmlDump in include/test/mtfxmldump.hxx that
92 can store a GDIMetafile as XML, which makes debugging much easier
93 since you can just use "diff" to see changes.
95 To use it you need to link against "test" library and then (because
96 "test" is not part of the installation) run with:
97 LD_LIBRARY_PATH=workdir/LinkTarget/Library:workdir/UnpackedTarball/cppunit/src/cppunit/.libs instdir/program/soffice
99 == EMF+ ==
101 emf+ is vector file format used by MSO and is successor of wmf and
102 emf formats. see
103 http://msdn.microsoft.com/en-us/library/cc230724.aspx for
104 documentation. note that we didn't have this documentation from
105 start, so part of the code predates to the time when we had guessed
106 some parts and can be enhanced today. there also still many thing not
107 complete
109 emf+ is handled a bit differently compared to original emf/wmf files,
110 because GDIMetafile is missing features we need (mostly related to
111 transparency, argb colors, etc.)
113 emf/wmf is translated to GDIMetafile in import filter
114 vcl/source/filter/wmf and so special handling ends here
116 emf+ is encapsulated into GDIMetafile inside comment records and
117 parsed/rendered later, when it reaches cppcanvas. it is parsed and
118 rendered in cppcanvas/source/mtfrenderer. also note that there are
119 emf+-only and emf+-dual files. dual files contains both types of
120 records (emf and emf+) for rendering the images. these can used also
121 in applications which don't know emf+. in that case we must ignore
122 emf records and use emf+ for rendering. for more details see
123 documentation
125 parsing:
127  wmf/emf filter --> GDI metafile with emf+ in comments --> cppcanvas metafile renderer
129 lately the GDIMetafile rendering path changed which also influenced
130 emf+ rendering. now many things happen in drawing layer, where
131 GDIMetafile is translated into drawing layer primitives. for
132 metafiles with emf+ we let the mtfrenderer render them into bitmap
133 (with transparency) and use this bitmap in drawinlayer. cleaner
134 solution for current state would be to extend the drawing layer for
135 missing features and move parsing into drawing layer (might be quite
136 a lot of work). intermediary enhancement would be to know better the
137 needed size/resolution of the bitmap, before we render emf+ into
138 bitmap in drawing layer. Thorsten is working on the same problem with
139 svg rendering, so hopefully his approach could be extended for emf+ as
140 well. the places in drawing layer where we use canvas mtfrenderer to
141 render into bitmaps can be found when you grep for GetUseCanvas. also
142 look at vcl/source/gdi/gdimetafile.cxx where you can look for
143 UseCanvas again. moving the parsing into drawinglayer might also have
144 nice side effect for emf+-dual metafiles. in case the emf+ records
145 are broken, it would be easier to use the duplicit emf
146 rendering. fortunately we didn't run into such a broken emf+ file
147 yet. but there were already few cases where we first though that the
148 problem might be because of broken emf+ part. so far it always turned
149 out to be another problem.
151 rendering:
153  before
155  vcl --> cppcanvas metafile renderer --> vcl
157  now
159  drawing layer --> vcl --> cppcanvas metafile renderer --> vcl --> drawing layer
161 another interesting part is actual rendering into canvas bitmap and
162 using that bitmap later in code using vcl API.
164 EMF+ implementation has some extensive logging, best if you do a dbgutil
165 build, and then
167 export SAL_LOG=+INFO.cppcanvas.emf+INFO.vcl.emf
169 before running LibreOffice; it will give you lots of useful hints.
171 You can also fallback to EMF (from EMF+) rendering via
173 export EMF_PLUS_DISABLE=1
176 == Printing/PDF export ==
178 Printing from Writer works like this:
180 1) individual pages print by passing an appropriate OutputDevice to XRenderable
181 2) in drawinglayer, a VclMetafileProcessor2D is used to record everything on
182    the page (because the OutputDevice has been set up to record a GDIMetaFile)
183 3) the pages' GDIMetaFiles are converted to PDF by the vcl::PDFWriter
184    in vcl/source/gdi/pdfwriter*
186 Creating the ODF thumbnail for the first page works as above except step 3 is:
188 3) the GDIMetaFile is replayed to create the thumbnail
190 On-screen display differs in step 1 and 2:
192 1) the VCL Window gets invalidated somehow and paints itself
193 2) in drawinglayer, a VclPixelProcessor2D is used to display the content
196 === Debugging PDF export ===
198 Debugging the PDF export becomes much easier when
199 compression is disabled (so the PDF file is directly readable) and
200 the MARK function puts comments into the PDF file about which method
201 generated the following PDF content.
203 The compression can be disabled even using a env. var:
205 export VCL_DEBUG_DISABLE_PDFCOMPRESSION=1
207 To de-compress the contents of a PDF file written by a release build or
208 other programs, use the "pdfunzip" tool:
210 bin/run pdfunzip input.pdf output.pdf