LibreOffice: Hermenutical keys to a complex code-base #2

Similar documents
LibreOffice: Hermenutical keys to a complex code-base

Exploiting Concurrency

Easy Hacks or how to make a difference in LibreOffice.

A Threading Snarl. Michael Stahl, Red Hat, Inc LibreOffice Bern 2014 Conference: A Threading Snarl

LibreOffice: Code Structure Hermenutical keys to a complex code-base

LibreOffice: Code Structure

Rendercontext & Double-Buffering

Collaborative Editing, Status & Future...

UI, Graphics & EFL. Carsten Haitzler Principal Engineer Samsung Electronics Korea Founder/Leader Enlightenment / EFL

Dialog Tunneling in LibreOffice Online

Improving LibreOffice usability: fixing symlink / hyperlink issues on Linux

Advanced Systems Programming

Accelerated, Threaded XML Parsing

Status of the Project

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,

Embedded Linux UI Comparison. Tim Bird Senior Staff Software Engineer Sony Electronics

Integrating LibreOffice with Gnome Documents

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

From extension to core

Introduction to Asynchronous Programming Fall 2014

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures

GUI in C++ PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill. Faculty of Informatics, Masaryk University.

Vector and Free Store (Pointers and Memory Allocation)

[Course Overview] After completing this module you are ready to: Develop Desktop applications, Networking & Multi-threaded programs in java.

CS 4300 Computer Graphics

Kotlin/Native concurrency model. nikolay

Calc: The challenges of scalable arithmetic How threading can be challenging

Online: Unit Testing

Supporting Materials

Background Information About GTK+ and Related Libraries

Chapter 17 vector and Free Store. Bjarne Stroustrup

Qt + Maemo development

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

Advanced Programming & C++ Language

GUI Implementation Support

The Dynamic Typing Interlude

Grand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015

Collaboration & Hacking with us

Overview of Writer Text Grid Formatting

COMP 215: INTRO TO PROGRAM DESIGN. Prof. Chris Jermaine Chris Prof. Chris Dr. Chris

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Grand Central Dispatch

Black Hat Webcast Series. C/C++ AppSec in 2014

Remote Procedure Call (RPC) and Transparency

PowerVR Framework. October 2015

Hacking in C. Pointers. Radboud University, Nijmegen, The Netherlands. Spring 2019

Cross-platform software development in practice. Object-Oriented approach.

Introduction to C++ with content from

Short Notes of CS201

The Myx Architectural Style

Adobe Fireworks CS Essential Techniques

CS201 - Introduction to Programming Glossary By

Widget Toolkits CS MVC

Implementing Symmetric Multiprocessing in LispWorks

C SCI The X Window System Stewart Weiss

OOoCon BOF Session. New Toolkit/Canvas for OpenOffice.org Thorsten Behrens

CSE 331 Software Design & Implementation

SEVEN ADVANCED ACADEMY

CS 300 Leftovers. CS460 Pacific University 1

Review. Designing Interactive Systems II. Review. Base Window System. Apps UITK BWS GEL. 4-Layer Model Graphics and Event Library BWS GEL

Overload Resolution. Ansel Sermersheim & Barbara Geller Amsterdam C++ Group March 2019

Stream Computing using Brook+

08/10/2018. Istanbul Now Platform User Interface

Bruce Merry. IOI Training Dec 2013

Integrating DMA Into the Generic Device Model

SELF-STUDY. Glossary

CS 220: Introduction to Parallel Computing. Introduction to CUDA. Lecture 28

Image creation with PHP

eswt Requirements and High-Level Architecture Abstract Document Information Change History

My malloc: mylloc and mhysa. Johan Montelius HT2016

Approaches to wrapping React. Thursday 3 September 15

Designing Interactive Systems II

Chapter 1 Getting Started

Quo Vadis Helpcontent? OLIVIER HALLOT The Document Foundation

Chapter 17 vector and Free Store

InDesign CC 2014 Intermediate Skills

COMP6700/2140 GUI and Event Driven Programming

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

Fractal: A Software Toolchain for Mapping Applications to Diverse, Heterogeneous Architecures

CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers

Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads.

OpenOffice.org as a platform for developers

Chapter 2. Operating-System Structures

Scientific Computing

Java SDK Guide. SAP Sybase Event Stream Processor 5.1 SP03

Ext3/4 file systems. Don Porter CSE 506

SPU Render. Arseny Zeux Kapoulkine CREAT Studios

Foundational Design Patterns for Moving Beyond One Loop

Today CSCI Communication. Communication in Distributed Systems. Communication in Distributed Systems. Remote Procedure Calls (RPC)

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

A Proposal to Add a Const-Propagating Wrapper to the Standard Library

CS371m - Mobile Computing. Responsiveness

Creating a nice GUI. OpenGL and Windows. Note: VS 2003 shown. Create a new Project

CS-XXX: Graduate Programming Languages. Lecture 22 Class-Based Object-Oriented Programming. Dan Grossman 2012

Sparklet Embedded GUI Library User Manual

Thrift specification - Remote Procedure Call

CPSC 427: Object-Oriented Programming

Pointers (continued), arrays and strings

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

Transcription:

LibreOffice: Hermenutical keys to a complex code-base #2 Michael Meeks <michael.meeks@suse.com> mmeeks,#libreoffice-dev, irc.freenode.net Stand at the crossroads and look; ask for the ancient paths, ask where the good way is, and walk in it, and you will find rest for your souls... - Jeremiah 6:16 1

Overview / Agenda Chunk #2 System abstractions, basic types sal / tools strings, translations Rendering / GUI pieces Vcl Widget layout / old-style dialogs Main-loop & thread / locking Images basebmp, basegfx, canvas, cppcanvas, drawinglayer 2

Chunk #2 grokking the code

Sal pieces

Strings include/rtl/ustring.hxx... Three important string classes but converging on two New sal / immutable strings: ref-counted OUString UTF16, 32bit lengths OString unspecified 8bit encoding, 32bit length String ('UniString') Internally re-uses OUString data structures old 'mutable' string but uniquifies on change 16bit length enforcement on underlying 32bit len UTF16 ( if you're lucky ) Writer's limit of 64k chars per paragraph: is here. 5

Strings constructing & mutating OUStringBuffer include/rtl/ustrbuf.hxx Used to construct strings, concatenate them etc. steal to an OUString with 'makestringandclear()' Conversion OUString String is fast Construction from const char foo[n] is implicit String required for translation: String(ResId(STR_FOO)) ResId etc. lives in tools/ ie. high above sal/ include/comphelper/string.hxx lots of good helpers. Debugging - python needed... 6

Strings Translation... Translated resources keyed from a unique integer ID This is scoped to the module / resource file eg. sw/inc/access.hrc shared between.src and.cxx #define STR_ACCESS_DOC_NAME (RC_ACCESS_BEGIN + 1) sw/source/ui/docvw/access.src define the US val: String STR_ACCESS_DOC_NAME { Text [ en-us ] = "Document view"; }; sw/source/core/access/accdoc.cxx: SetName( GetResource( STR_ACCESS_DOC_NAME ) ); Should be easy to extend Resource files compiled by rsc/ code to a binary.res file eg. program/resource/swen-us.res in the install 7

Stream APIs - all URL based include/osl/file.hxx (from sal/osl) C++ Volume / File / DirectoryItem API include/tools/stream.hxx (SvStream) C++ more traditional stream object lots of variants, buffering operator overloads for << and >> [urgh!] udkapi/com/sun/star/io/xinputstream.idl UNO stream impl. - as implemented by UCB, and package code. include/unotools/streamwrap.hxx Convert SvStream UNO 8

VCL...

Visual Class Libraries (VCL) The LibreOffice toolkit Lots of backends: headless/ - ie. No display pixel-bashing android/ & quartz/ - for Android /ios both ultimately 'headless' sub-classes. unx/ pluggable backends for gtk2, gtk3, KDE3, KDE4 win/ & aqua/ - Windows / Mac backends generic/ shared code between unx-like backends 10

VCL main-loop / mutex / events... LibreOffice is fundamentally single threaded the one big lock: is the 'SolarMutex' This is recursive 'Application::Yield' VCL (or Application::Reschedule) releases the lock while we wait for input / timeout code in vcl/source/ defers to backends for this eg. vcl/headless/svpinst.cxx Yield / DoReleaseYield Unfortunately VCL is explicitly lifecycle managed: New / delete which causes some problems... 11

VCL event emission... main-loop dispatches timeouts, user events input events associated with a SalFrame sub-class vcl/inc/salframe.hxx class SalFrame { // Callbacks (indepent part in // vcl/source/window/winproc.cxx) // for default message handling return 0 void SetCallback( Window* pwindow, SALFRAMEPROC pproc ) { m_pwindow = pwindow; m_pproc = pproc; } long CallCallback( sal_uint16 nevent, { const void* pevent ) const return m_pproc? m_pproc( m_pwindow, const_cast<salframe*>(this), nevent, pevent ) : 0; } 12

VCL event emission... After mapping the input: eg. vcl/unx/gtk/window/gtksalframe.cxx SalWheelMouseEvent aevent; aevent.mntime = psevent->time; aevent.mnx = (sal_ulong)psevent->x; aevent.mny = (sal_ulong)psevent->y; Call the callback: pthis->callcallback( SALEVENT_WHEELMOUSE, &aevent ); This enters: vcl/source/window/winproc.cxx Multiplexed outwards to the VCL / Window internals & listeners. 13

Tools / links wrapping a fn. Ptr... ImplCallEventListenersAndHandler Uses include/tools/link.hxx include/vcl/button.hxx class Button { Link maclickhdl;... void SetClickHdl( const Link& rlink ) { maclickhdl = rlink; } User does: Button mabutton; mabutton.setclickhdl( LINK(this, NewObjectDialog, OkButtonHandler) );... IMPL_LINK_NOARG(NewObjectDialog, OkButtonHandler) { SAL_DEBUG( ok pressed ); 14

VCL event emission a control... eg. Button vcl/source/control/button.cxx void PushButton::MouseButtonDown( const MouseEvent& rmevt ) {... if ( ) Click(); } void Button::Click() { ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, maclickhdl, this ); } 15

VCL: Rendering model... Unlike modern toolkits VCL has two rendering models: Immediate rendering: Render anything, at any time on your Window. All Windows are an 'OutputDevice' sub-class void DrawLine( const Point& rstartpt, const Point& rendpt ); Invalidate Idle re-render Wait for the app to be ready to render Window::Invalidate( const Rectangle& rrect, sal_uint16 nflags = 0 ); This causes some issues. cf. basebmp/source/bitmapdevice.cxx (setdamagetracker) 16

VCL: Images split Alpha... include/vcl/bitmapex.hxx / bitmap.hxx Unfortunately VCL was started 20+ years ago No full alpha transparency then. separate 'mask' with a different bit-depth (1bit) was. In consequence: Bitmap is a non-alpha transparent bitmap (or mask) BitmapEx combines two Bitmaps: a Bitmap + an AlphaMask This makes pixel operations somewhat complicated Bitmaps have different platform representations: BitmapReadAccess / BitmapWriteAccess to access the underlying pixels eg. vcl/source/gdi/impimage.cxx ImplUpdateDisabledBmpEx 'Image' class wraps this giving a cut-out of an image-strip (obsolete) All Image/Bitmap/BitmapEx primitives are pimpl + ref-counted 17

VCL: Bitmaps getting stock images vcl/source/gdi/bitmapex.cxx (BitmapEx::BitmapEx (ResId ) gets string name from resource loads image from 'image tree' singleton. vcl/source/gdi/impimagetree.cxx Some nice sample code to read through Used to load themed images. Look for /.zip/ Notice the SvStream vs. XinputStream 18

VCL: Layout / graphical look... Well documented elsewhere Recommend presentations from Caolan on this and/or his write-ups: http://blogs.linux.ie/caolan/2013/01/24/converting-libreoffic e-dialogs-to-ui-format-100-conversions-milestone/ Finally we have a UI dialog / toolkit layout approach. Hopefully in the end this will lead to smart pointers everywhere and an end to lifecycle issues. 19

Questions / conclusions VCL is a 20+ year old toolkit The code-base is no worse than can be expected Everything needs some love & understanding No reason why we can' t do radical things with the API Things are improving over time All text and image content in this document is licensed under the Creative Commons Attribution-Share Alike 3.0 License (unless otherwise specified). "LibreOffice" and "The Document Foundation" are registered trademarks. Their respective logos and icons are subject to international copyright laws. The use of these therefore is subject to the trademark policy. 20