Refactor calc non-linear ViewToDevice transform

This change solves the non-linear World-To-View trans-
formation that calc uses due to it's screen rendering
as good as currently possible (AFAIK).
Calcv view  is layouted on pixel base (due to better
homogen distances and full pixel lines between cells),
but this leads to having a non-linear transformation
between discrete units (pixels, view) and model coordinates
(World). In principle, each cell has it's own (so called)
ViewTransformation -> the position on screen depends on
the mappings of all cells top/left from it. This is
obvioulsly non-linear and can sometimes be seen by
producing 'offset' errors when many cells (small and thin)
are shown in low zoom stages.
No better solution for this comes to mind easily. The
extremes are - on the one hand AntiAliasing the whole
calc edit view and accept 'unsharp/AAed' lines - on the
other hand what we have now.
Maybe a future solution could find a mapping that gets
close to linear mapping for the full view. On the long
run this state is hard to keep correct. Even with this
extended solution the mapping of SdrObjects spawning
mutiple cells is assumed 'linear' in that area - which
is in reality currently not the case (!)
Note: This is only true for the screen visualization,
print and/or PDF export do not do that pixel-based
layouting.
Note2: This mechanism is general in DrawingLayer (look
for '.*GridOffset.*'. If it is deactivated by providing
no offsets, the result is the unchanged, linear mapping.

First step: Add interfaces to get a possible GridOffset
at ViewObjectContact. There it belongs, we have a view-
dependent offset per object and view. Add mechanisms to
create on-demand and reach back to the view (aka calc's
derivation of it).

Second step: Implement the on-demand creation, adapt to
use it in ViewObjectContact::getPrimitive2DSequence, add
stuff to reset on zoom change, disable temporarily old
mechanism -> paint already works. Need to adapt the
places from old mechanism where the GridOffset was used,
but no longer the geometry creations.

Third step: Isolated and disabled old mechanism (by
already removing SetGridOffset). Marked all places that
possibly need change with '//Z' tag. Main work now will
be to adapt in the SdrView implementations in svx to know
about having a SdrObject-dependent ViewTransformation
at all (currently not known, was hard-coded at some places
from the old code, ViewTransformation set as MapMode at
a target OutputDevice, not member at SdrView at all...).

Fourth step: Adapt the Handles and OverlayObjects to
use an evtl. existing GridOffset. The mechanism is that
the SdrHdl(s) can be seen as 'Model-Objects', these get
converted to OverlayObjects in the ::CreateB2dIAObject()
implementations, for all SdrMarkView and SdrPageView,
so this is the place where the ObjectContact is known
(the SdrPageWindow *is* a ObjectContact) and the view-
dependent GridOffset can be calculated per SdrObject.
I modified OverlayObject to be able to work with a
set Offset that embeds the created visualization using
this additionally.
Handles get now correctly set and have a working HitTest
(due to that already using the primitives). Some inter-
action stuff already working, some will need more
adaption. We simply have no concept for this stuff...
Refactored to not get dependencies to SdrObject in
ObjectContact.

Fifth Step: Make HitTest work by adding the View-And-
Object dependent GridOffset in the View when HitTest
is triggered. This is in SdrMarkView::CheckSingleSdrObjectHit
where pObj->GetCurrentBoundRect() is used that gets the
view-independent form. To make HitTest work, add a possible
GridOffset.
Since this will be necessary more often in SdrView hierarchy,
added a tooling method (getPossibleGridOffsetForSdrObject)
at that level after checking that at that level will be
reachable at all potential spots.
Inside that method the correct ObjectContact will be identified
and the object-specific offset requested there.

Sixth Step: Adaptions and started some cleanups. Still some
adaptions needed:
- After creation of new object, need to relocate from
  used GridOffset setting to WorldCoordinates
- Interactions, e.g. start with dragging handles or full
  object/points

Seventh Step: React on EndCreateObj. Here, the created
SdrObject is in model coordinates and needs to be adapted
to evtl. GridOffset. This is 'tricky' due to calculating
the possible offset based on new coordinates 'close'
to the target position, but may be in the wrong cell.
Nonetheless this is the best we can do here.
Last (hopefully) missing are now all interaction
viszualizations. They already work and are applied
correctly, but wrong visualized.
Have taken the time to unify adding OverlayObjects for
selection visualization to OverlayManager, see
handleNewOverlayObject. This does all needed when adding
OverlayObjects in one place where the GridOffset can
also be handled. It makles things more safe - not possible
to forget one of the three steps for others.

Eighth Step: Do the same unification for creating the
OverlayGeometry, also rename methods to make usage more
clear. We now have
  SdrHdl::insertNewlyCreatedOverlayObjectForSdrHdl
  SdrDragMethod::insertNewlyCreatedOverlayObjectForSdrDragMethod
which can do the needed GridOffset changes centralized.
Needed to get a ObjectContact for this at SdrDragMethod,
so adapted ::CreateOverlayGeometry implementations
accordingly. Missing is now the implementation in
insertNewlyCreatedOverlayObjectForSdrDragMethod to add
the GridOffset - if used. This has no SdrObject at this
time, so we will need a fallback to do the same using a
Range (Rectangle). The stuff doing this for SdrObject
already has a fallback and is based on using the Rectangle
from the SdrObject anyways, so this will be possible.

Ninth Step: Cleanup of old stuff (no more //Z), adapted
some usages of OverlayObject creations to use
getViewIndependentPrimitive2DContainer instead of the
view dependent parts so that offset applied to
drag-overlays is correct and not already added. Adapted
insertNewlyCreatedOverlayObjectForSdrDragMethod to use
calculateGridOffsetForB2DRange. Use now that instead of
SdrObject-based approach in calc - is more generic.
Getting closer, but still not complete - there is an
error with dragging the grepped handle somehow - the
offset for drag is somehow wrong.

Tenth Step: Corrected that offset error. Of course at
interaction start and progress (move) the coordinates
are in GrifOffset coordinates and need to be corrected
to Model coordinates. Done that at ::BegDragObj and
::MovDragObj, works well.
Of course there are exceptions for the crop-handles, so
needed to add setting the correct parameters at SdrHdl
when these got created, then all works as expected.

The strategy is to *not* change the model data itself
in any way, instead do all changes/adaptions in the
view-only code. This has minimal impact and is needed
due to having a 1:n relationship between model and
views anyways.
There are two directions: All visualizations are adapted
to take the GridOffset into account (SdrObjects, overlay,
handles, InteractionObjects, ...). In the other direction
input like MousePosition is in principle in calc EditView
in 'GridOffset'-coordinates and needs to be mapped back
before usage.

Change-Id: I2ecdd409def96a7248a26a65a22e59eb962880a0
Reviewed-on: https://gerrit.libreoffice.org/64057
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
68 files changed
tree: 3bf7db8591172bf948198f19d36df5df886486bb
  1. .git-hooks/
  2. accessibility/
  3. android/
  4. animations/
  5. apple_remote/
  6. avmedia/
  7. basctl/
  8. basegfx/
  9. basic/
  10. bean/
  11. bin/
  12. binaryurp/
  13. bridges/
  14. canvas/
  15. chart2/
  16. cli_ure/
  17. codemaker/
  18. comphelper/
  19. compilerplugins/
  20. config_host/
  21. configmgr/
  22. connectivity/
  23. cppcanvas/
  24. cppu/
  25. cppuhelper/
  26. cpputools/
  27. cui/
  28. dbaccess/
  29. desktop/
  30. distro-configs/
  31. drawinglayer/
  32. dtrans/
  33. editeng/
  34. embeddedobj/
  35. embedserv/
  36. emfio/
  37. eventattacher/
  38. extensions/
  39. external/
  40. extras/
  41. filter/
  42. forms/
  43. formula/
  44. fpicker/
  45. framework/
  46. helpcompiler/
  47. hwpfilter/
  48. i18nlangtag/
  49. i18npool/
  50. i18nutil/
  51. icon-themes/
  52. idl/
  53. idlc/
  54. include/
  55. instsetoo_native/
  56. io/
  57. ios/
  58. javaunohelper/
  59. jurt/
  60. jvmaccess/
  61. jvmfwk/
  62. l10ntools/
  63. librelogo/
  64. libreofficekit/
  65. lingucomponent/
  66. linguistic/
  67. lotuswordpro/
  68. m4/
  69. nlpsolver/
  70. o3tl/
  71. odk/
  72. offapi/
  73. officecfg/
  74. onlineupdate/
  75. oovbaapi/
  76. oox/
  77. opencl/
  78. osx/
  79. package/
  80. postprocess/
  81. pyuno/
  82. qadevOOo/
  83. readlicense_oo/
  84. registry/
  85. remotebridges/
  86. reportbuilder/
  87. reportdesign/
  88. ridljar/
  89. sal/
  90. salhelper/
  91. sax/
  92. sc/
  93. scaddins/
  94. sccomp/
  95. schema/
  96. scp2/
  97. scripting/
  98. sd/
  99. sdext/
  100. setup_native/
  101. sfx2/
  102. shell/
  103. slideshow/
  104. smoketest/
  105. solenv/
  106. soltools/
  107. sot/
  108. starmath/
  109. stoc/
  110. store/
  111. svgio/
  112. svl/
  113. svtools/
  114. svx/
  115. sw/
  116. swext/
  117. sysui/
  118. test/
  119. testtools/
  120. toolkit/
  121. tools/
  122. ucb/
  123. ucbhelper/
  124. udkapi/
  125. uitest/
  126. UnoControls/
  127. unodevtools/
  128. unoidl/
  129. unoil/
  130. unotest/
  131. unotools/
  132. unoxml/
  133. ure/
  134. uui/
  135. vbahelper/
  136. vcl/
  137. winaccessibility/
  138. wizards/
  139. writerfilter/
  140. writerperfect/
  141. xmerge/
  142. xmlhelp/
  143. xmloff/
  144. xmlreader/
  145. xmlscript/
  146. xmlsecurity/
  147. .buckconfig
  148. .buckversion
  149. .clang-format
  150. .editorconfig
  151. .gitattributes
  152. .gitignore
  153. .gitmodules
  154. .gitreview
  155. autogen.sh
  156. BUCK
  157. config.guess
  158. config.sub
  159. config_host.mk.in
  160. config_host_lang.mk.in
  161. configure.ac
  162. COPYING
  163. COPYING.LGPL
  164. COPYING.MPL
  165. download.lst
  166. g
  167. install-sh
  168. leak-suppress.txt
  169. Library_merged.mk
  170. lo.xcent.in
  171. logerrit
  172. Makefile.fetch
  173. Makefile.gbuild
  174. Makefile.in
  175. README.cross
  176. README.md
  177. README.Solaris
  178. Repository.mk
  179. RepositoryExternal.mk
  180. RepositoryFixes.mk
  181. RepositoryModule_build.mk
  182. RepositoryModule_host.mk
  183. sanitize-ubsan-blacklist
  184. setup.cfg
  185. TEMPLATE.SOURCECODE.HEADER
README.md

LibreOffice

Coverity Scan Build Status CII Best Practices

LibreOffice is an integrated office suite based on copyleft licenses and compatible with most document formats and standards. Libreoffice is backed by The Document Foundation, which represents a large independent community of enterprises, developers and other volunteers moved by the common goal of bringing to the market the best software for personal productivity. LibreOffice is open source, and free to download, use and distribute.

A quick overview of the LibreOffice code structure.

Overview

You can develop for LibreOffice in one of two ways, one recommended and one much less so. First the somewhat less recommended way: it is possible to use the SDK to develop an extension, for which you can read the API docs here and here. This re-uses the (extremely generic) UNO APIs that are also used by macro scripting in StarBasic.

The best way to add a generally useful feature to LibreOffice is to work on the code base however. Overall this way makes it easier to compile and build your code, it avoids any arbitrary limitations of our scripting APIs, and in general is far more simple and intuitive - if you are a reasonably able C++ programmer.

The build chain and runtime baselines

These are the current minimal operating system and compiler versions to run and compile LibreOffice, also used by the TDF builds:

  • Windows:
    • Runtime: Windows 7
    • Build: Cygwin + Visual Studio 2017
  • macOS:
    • Runtime: 10.10
    • Build: 10.12 + Xcode 9.3
  • Linux:
    • Runtime: RHEL 6 or CentOS 6
    • Build: GCC 4.8.1 or Clang
  • iOS (only for LibreOfficeKit):
    • Runtime: 11.4 (only support for newer i devices == 64 bit)
    • Build: Xcode 9.3 and iPhone SDK 11.4

At least Clang 3.4.2 is known to be too old to pass the configure.ac check "whether $CXX supports C++17, C++14, or C++11" in its current form (due to the #pragma GCC diagnostic ignored "-Wpragmas" that it does not understand).

If you want to use Clang with the LibreOffice compiler plugins, the minimal version of Clang is 5.0.2. Since Xcode doesn't provide the compiler plugin headers, you have to compile your own Clang to use them on macOS.

You can find the TDF configure switches in the distro-configs/ directory.

To setup your initial build environment on Windows and macOS, we provide the LibreOffice Development Environment (LODE) scripts.

For more information see the build instructions for your platform in the TDF wiki.

The important bits of code

Each module should have a README file inside it which has some degree of documentation for that module; patches are most welcome to improve those. We have those turned into a web page here:

https://docs.libreoffice.org/

However, there are two hundred modules, many of them of only peripheral interest for a specialist audience. So - where is the good stuff, the code that is most useful. Here is a quick overview of the most important ones:

ModuleDescription
sal/this provides a simple System Abstraction Layer
tools/this provides basic internal types: 'Rectangle', 'Color' etc.
vcl/this is the widget toolkit library and one rendering abstraction
frameworkUNO framework, responsible for building toolbars, menus, status bars, and the chrome around the document using widgets from VCL, and XML descriptions from /uiconfig/ files
sfx2/legacy core framework used by Writer/Calc/Draw: document model / load/save / signals for actions etc.
svx/drawing model related helper code, including much of Draw/Impress

Then applications

ModuleDescription
desktop/this is where the 'main' for the application lives, init / bootstrap. the name dates back to an ancient StarOffice that also drew a desktop
sw/Writer
sc/Calc
sd/Draw / Impress

There are several other libraries that are helpful from a graphical perspective:

ModuleDescription
basegfx/algorithms and data-types for graphics as used in the canvas
canvas/new (UNO) canvas rendering model with various backends
cppcanvas/C++ helper classes for using the UNO canvas
drawinglayer/View code to render drawable objects and break them down into primitives we can render more easily.

Rules for #include directives (C/C++)

Use the "..." form if and only if the included file is found next to the including file. Otherwise, use the <...> form. (For further details, see the mail Re: C[++]: Normalizing include syntax ("" vs <>).)

The UNO API include files should consistently use double quotes, for the benefit of external users of this API.

loplugin:includeform (compilerplugins/clang/includeform.cxx) enforces these rules.

Finding out more

Beyond this, you can read the README files, send us patches, ask on the mailing list libreoffice@lists.freedesktop.org (no subscription required) or poke people on IRC #libreoffice-dev on irc.freenode.net - we're a friendly and generally helpful mob. We know the code can be hard to get into at first, and so there are no silly questions.