Download presentation
Presentation is loading. Please wait.
1
Layercake: From UNO code to Writer Core
Bjoern Michaelsen Deputy Member, Board of Directors The Document Foundation Ubuntu LibreOffice package maintainer Canonical
3
Interfaces, Services and Implementations
A quick race through some UNO concepts ...
4
Interfaces, Services and Implementations
Interfaces say what you can do with a UNO-thing usually named com::sun::star... and then a name prefixed with X Services promise to provide a set of Interfaces and then a name not prefixed with X Implementations can provide a service or a set of Interfaces usually named … inconsistently have some some real core code behind it
5
XCargoStorage XTransport
6
Lorry service still abstract implements XTransport and XCargoStorage
7
Lorry implementation concrete implements a service
has some real code behind it
8
UNO Runtime Reflection
How to find out what kind of UNO thing you are holding ...
9
XInterface
10
XServiceInfo
11
The css.script.theServiceDocumenter singleton
Getting to the UNO documentation from your extension or script quickly ...
12
TheServiceDocumenter.showServiceDocs(...)
void showServiceDocs( [in] com::sun::star::lang::XServiceInfo xService ); opens documentation for all services supported by this implementation in a browser
13
TheServiceDocumenter.showInterfaceDocs(...)
void showInterfaceDocs( [in] com::sun::star::lang::XTypeProvider xTypeProvider ); opens documentation for all interfaces (types) supported by this implementation in a browser
14
Example Ad-hoc StarBasic
TheServiceDocumenter = GetDefaultContext().getValueByName( "/singletons/com.sun.star.util.theServiceDocumenter") ' old style reflection helpers MsgBox(TheServiceDocumenter.Dbg_Methods) MsgBox(TheServiceDocumenter.Dbg_Properties) MsgBox(TheServiceDocumenter.Dbg_SupportedInterfaces) ' using the Service Documenter TheServiceDocumenter.showServiceDocs(ThisComponent) 'TheServiceDocumenter.showInterfaceDocs(ThisComponent)
15
Hard Things There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors. – Phil Karlton
16
Interfaces, Services, UNO Wrappers and Core
Interfaces say what you can do with a UNO-thing usually named com::sun::star... and then a name prefixed with X Services promise to provide a set of Interfaces and then a name not prefixed with X UNO Wrappers (implementations) can provide a service or a set of Interfaces usually named … inconsistently call real core code behind it Core implementations do the real work and usually are older than UNO
17
Interfaces, Services, UNO Wrappers and Core
core implementation UNO Wrapper Interfaces and Services
18
Writer Python Tests Directory sw/qa/python has the tests
Makefile sw/PythonTest_sw_python triggers them So, to trigger them manually: make PythonTest_sw_python
19
Debugging Python Tests: symbols
./autogen.sh --enable-symbols && make make sw.clean && make sw DEBUG=T
20
Debugging Python Tests
Callgrinding tests: VALGRIND=callgrind make PythonTest_sw_python ls -lh ./workdir/PythonTest/sw_python/done.core/ callgrind_annotate $FILE \ --inclusive=yes \ --threshold=100 \ | grep sw/source/core/unocore \ | head -10 Debugging into tests: CPPUNITTRACE="gdb --args" make PythonTest_sw_python
21
check_styles.py: callgrind
32,453,621 unostyle.cxx:sw::XStyleFamily::getByName(rtl::OUString const&) [libswlo.so] 23,155,924 unostyle.cxx:non-virtual thunk to sw::XStyleFamily::getByName(rtl::OUString const&) [libswlo.so] 11,395,863 unostyle.cxx:com::sun::star::uno::Reference<com::sun::star::style::XStyle> lcl_CreateStyle<(SfxStyleFamily)2>(SfxStyleSheetBasePool*, SwDocShell*, rtl::OUString const&) [libswlo.so] 11,132,842 unostyle.cxx:SwXStyle::SwXStyle(SfxStyleSheetBasePool*, SfxStyleFamily, SwDoc*, rtl::OUString const&) [libswlo.so] 10,673,960 unostyle.cxx:non-virtual thunk to sw::XStyleFamily::getElementNames() [libswlo.so]
22
check_styles.py: backtrace
(gdb) bt #0 SwDocStyleSheet::PresetNameAndFamily (this=0x7fffe , rName=...) at ...sw/source/uibase/app/docstyle.cxx:2209 #1 0x00007fffdccad7f8 in SwStyleSheetIterator::Next (this=0x ) at ...sw/source/uibase/app/docstyle.cxx:3098 #2 0x00007fffdccad6df in SwStyleSheetIterator::First (this=0x ) at ...sw/source/uibase/app/docstyle.cxx:3087 #3 0x00007fffdca9da6d in sw::XStyleFamily::getElementNames (this=0x7fffd6da5998) at ...sw/source/core/unocore/unostyle.cxx:873 #4 0x00007ffff in gcc3::callVirtualMethod (pThis=0x7fffd6da59c0, nVtableIndex=6, pRegisterReturn=0x7fffffff1d40, pReturnTypeRef=0x862ed0, bSimpleReturn=false, pStack=0x7fffffff1ab0, nStack=0, pGPR=0x7fffffff1bd0, pFPR=0x7fffffff1c00) at ...bridges/source/cpp_uno/gcc3_linux_x86- 64/callvirtualmethod.cxx:133
24
Interfaces, Services, UNO Wrappers and Core
core implementation: SwDocStyleSheet, SwStyleSheetIterator UNO Wrapper: SwXStyleFamily Interfaces and Services: com::sun::star::text::Text::ParagraphStyle
25
check_table.py: callgrind
118,911,501 unotbl.cxx:SwXTextTable::getData() 109,031,858 unotbl.cxx:SwXCellRange::getData() 107,979,526 unotext.cxx:SwXText::getString() [libswlo.so] 101,504,055 unotbl.cxx:SwXCell::getValue() [libswlo.so] 88,469,311 unoobj.cxx:SwXTextCursor::getString() [libswlo.so]
26
check_table.py: backtrace
#0 sw_GetTableBoxColStr (nCol=0, rNm=...) at ...sw/source/core/table/swtable.cxx:1793 #1 0x00007fffdc6e7526 in sw_GetCellName (nColumn=0, nRow=0) at ...sw/source/core/unocore/unotbl.cxx:522 #2 0x00007fffdc6e7955 in lcl_CreateXCell (pFormat=0x7fffd69cf000, nColumn=0, nRow=0) at ...sw/source/core/unocore/unotbl.cxx:584 #3 0x00007fffdc6f8846 in SwXCellRange::GetCells (this=0x7fffd69f4698) at ...sw/source/core/unocore/unotbl.cxx:3342 #4 0x00007fffdc570ccc in SwChartDataSequence::GetCells (this=0x7fffd ) at ...sw/source/core/unocore/unochart.cxx:2149 #5 0x00007fffdc5710af in SwChartDataSequence::getNumericalData (this=0x7fffd ) at ...sw/source/core/unocore/unochart.cxx:2184 #6 0x00007ffff in gcc3::callVirtualMethod (pThis=0x7fffd , nVtableIndex=3, pRegisterReturn=0x7fffffff1e60, pReturnTypeRef=0x , bSimpleReturn=false, pStack=0x7fffffff1bd0, nStack=0, pGPR=0x7fffffff1cf0, pFPR=0x7fffffff1d20) at ...bridges/source/cpp_uno/gcc3_linux_x86- 64/callvirtualmethod.cxx:133
28
Interfaces, Services, UNO Wrappers and Core
core implementation: sw_GetTableBoxColString() UNO Wrapper: SwXCellRange Interfaces and Services Com::sun::star::text::XTextTable
29
Thank you! @Sweet5hark See you at the LibreOffice Conference in Brno 2016 Find out more at
30
Default Slide Example Here is space for your content … Some hints:
Use the master pages being the basis for the default slides It would be useful to add your presentation title to the footer. Add it via Insert – Page Number … – Footer Use the LibreOffice Color Palette delivered with LibreOffice (libreoffice.soc)
31
Pre-defined Shapes Here are some pre-defined shapes for your convenience: copy the shapes, copy their formatting, or use the LibO styles. Green Dark Green Bright You may add your code examples, XML statements, or debug output here ;-) Blue Dark Blue Bright Orange Dark Orange Bright Purple Dark Purple Bright Yellow Dark Yellow Bright
32
Section Header Example
You may add additional text here ...
34
XTypeProvider
35
WIP: using the css. script
WIP: using the css.script.theServiceDocumenter singleton for finding core implementations Getting to the C++ documentation of your implementation from your extension or script quickly ...
36
clang, the Ultimate: best solution: leak the information with a clang plugin triggering on getImplementationName(..) There might be some cases where the implementation name is dynamically generated That likely a bad idea anyway, so fix that then (or worst case: fallback on the scripted solution via component files)
37
The old manual ways: ad-hoc: Just search for the implementation name on lots of clutter from testcode etc. though somewhat more reliable: finding implementation in .component files, then find the implemenation in the cxx files of that library best solution: leak the information with a clang plugin triggering on getImplementationName(..)
38
Example Ad-hoc StarBasic
TheServiceDocumenter = GetDefaultContext().getValueByName( "/singletons/com.sun.star.util.theServiceDocumenter") ' old style reflection helpers MsgBox(TheServiceDocumenter.Dbg_Methods) MsgBox(TheServiceDocumenter.Dbg_Properties) MsgBox(TheServiceDocumenter.Dbg_SupportedInterfaces) ' using the Service Documenter TheServiceDocumenter.CoreBaseUrl = " TheServiceDocumenter.showCoreDocs(ThisComponent) WIP: only works for SwXTextDocument for now Opens
39
Finding implementation via .component files
for f in `git ls-tree -r --name-only HEAD|grep '.component$'` do grep 'implementation name' $f|nl -s ",$f," done > componentgrep.csv In the second row, we then find the path of the component file In the third row, we then find the implemenation name thus we can find the ${module}/Library_${libname}.mk for each implementation and the cxx files where it could be implemented f
40
How should the Core Documentation Reference work in the end?
It just opens “{$CoreBaseUrl}/{$ImplementationName}” in a browser and the URLs at ${CoreBaseUrl} are just statically generated redirects to (possibly we could also link to github or opengrok) later
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.