loplugin:constmethod in editeng
[LibreOffice.git] / vcl / README
blobd37ffe9e84073564a69b02fb8b8cd92309406a72
1 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).
3 It should not be confused with Borland's Visual Component Library, which is entirely unrelated.
5 VCL provides a graphical toolkit similar to gtk+, Qt, SWING etc.
7 source/
8         + the main cross-platform chunk of source
10 inc/
11         + cross-platform abstraction headers
13 headless/
14         + a backend renderer that draws to bitmaps
16 android/
17         + Android backend
19 osx/
20         + macOS backend
22 ios/
23         + iOS backend
25 quartz/
26         + code common to macOS and iOS
28 win/
29         + Windows backend
31 qt5/
32         + Qt5 (under construction)
34 unx/
35         + X11 backend and its sub-platforms
37         gtk/
38                 + GTK2 support
39         gtk3/
40                 + GTK3 support
41         kf5/
42                 + KF5 support
43         gtk3_kde5/
44                 + GTK3 support with KDE5 file pickers (alternative to native kde5 one)
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 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/vcl/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 == EMF+ ==
97 emf+ is vector file format used by MSO and is successor of wmf and
98 emf formats. see
99 http://msdn.microsoft.com/en-us/library/cc230724.aspx for
100 documentation. note that we didn't have this documentation from
101 start, so part of the code predates to the time when we had guessed
102 some parts and can be enhanced today. there also still many thing not
103 complete
105 emf+ is handled a bit differently compared to original emf/wmf files,
106 because GDIMetafile is missing features we need (mostly related to
107 transparency, argb colors, etc.)
109 emf/wmf is translated to GDIMetafile in import filter
110 vcl/source/filter/wmf and so special handling ends here
112 emf+ is encapsulated into GDIMetafile inside comment records and
113 parsed/rendered later, when it reaches cppcanvas. It is parsed and
114 rendered in cppcanvas/source/mtfrenderer. also note that there are
115 emf+-only and emf+-dual files. dual files contains both types of
116 records (emf and emf+) for rendering the images. these can used also
117 in applications which don't know emf+. in that case we must ignore
118 emf records and use emf+ for rendering. for more details see
119 documentation
121 parsing:
123  wmf/emf filter --> GDI metafile with emf+ in comments --> cppcanvas metafile renderer
125 lately the GDIMetafile rendering path changed which also influenced
126 emf+ rendering. now many things happen in drawing layer, where
127 GDIMetafile is translated into drawing layer primitives. for
128 metafiles with emf+ we let the mtfrenderer render them into bitmap
129 (with transparency) and use this bitmap in drawinlayer. cleaner
130 solution for current state would be to extend the drawing layer for
131 missing features and move parsing into drawing layer (might be quite
132 a lot of work). intermediary enhancement would be to know better the
133 needed size/resolution of the bitmap, before we render emf+ into
134 bitmap in drawing layer. Thorsten is working on the same problem with
135 svg rendering, so hopefully his approach could be extended for emf+ as
136 well. the places in drawing layer where we use canvas mtfrenderer to
137 render into bitmaps can be found when you grep for GetUseCanvas. also
138 look at vcl/source/gdi/gdimetafile.cxx where you can look for
139 UseCanvas again. moving the parsing into drawinglayer might also have
140 nice side effect for emf+-dual metafiles. in case the emf+ records
141 are broken, it would be easier to use the duplicit emf
142 rendering. fortunately we didn't run into such a broken emf+ file
143 yet. but there were already few cases where we first though that the
144 problem might be because of broken emf+ part. so far it always turned
145 out to be another problem.
147 rendering:
149  before
151  vcl --> cppcanvas metafile renderer --> vcl
153  now
155  drawing layer --> vcl --> cppcanvas metafile renderer --> vcl --> drawing layer
157 another interesting part is actual rendering into canvas bitmap and
158 using that bitmap later in code using vcl API.
160 EMF+ implementation has some extensive logging, best if you do a dbgutil
161 build, and then
163 export SAL_LOG=+INFO.cppcanvas.emf+INFO.vcl.emf
165 before running LibreOffice; it will give you lots of useful hints.
167 You can also fallback to EMF (from EMF+) rendering via
169 export EMF_PLUS_DISABLE=1
172 == Printing/PDF export ==
174 Printing from Writer works like this:
176 1) individual pages print by passing an appropriate OutputDevice to XRenderable
177 2) in drawinglayer, a VclMetafileProcessor2D is used to record everything on
178    the page (because the OutputDevice has been set up to record a GDIMetaFile)
179 3) the pages' GDIMetaFiles are converted to PDF by the vcl::PDFWriter
180    in vcl/source/gdi/pdfwriter*
182 Creating the ODF thumbnail for the first page works as above except step 3 is:
184 3) the GDIMetaFile is replayed to create the thumbnail
186 On-screen display differs in step 1 and 2:
188 1) the VCL Window gets invalidated somehow and paints itself
189 2) in drawinglayer, a VclPixelProcessor2D is used to display the content
192 === Debugging PDF export ===
194 Debugging the PDF export becomes much easier when
195 compression is disabled (so the PDF file is directly readable) and
196 the MARK function puts comments into the PDF file about which method
197 generated the following PDF content.
199 The compression can be disabled even using an env. var:
201 export VCL_DEBUG_DISABLE_PDFCOMPRESSION=1
203 To de-compress the contents of a PDF file written by a release build or
204 other programs, use the "pdfunzip" tool:
206 bin/run pdfunzip input.pdf output.pdf