Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LibreOffice Writer: How the Text Gets on the Sc...

LibreOffice Writer: How the Text Gets on the Screen

This short presentation describes what happens when a piece of text in your document is being drawn in LibreOffice Writer. It is basically a summary of backtrace & what happens when you walk it from Writer down to VCL.

Jan Holesovsky

February 01, 2014
Tweet

More Decks by Jan Holesovsky

Other Decks in Programming

Transcript

  1. How the Text in Writer Gets on the Screen? Jan

    Holesovsky <kendy@collabora.com>
  2. 2 / 14 Event Name | Your Name It all

    starts with a draw request • Window::ImplCallPaint( • const Region* pRegion, – [can be more rectangles etc.] • sal_uInt16 nPaintFlags ) – [whether to paint children etc.]
  3. 3 / 14 Event Name | Your Name It gets

    to the Writer's edit window • SwEditWin = Window class for the Writer edit area • handling mouse and keyboard events and doing the final painting of the document from the buffered layout. • SwEditWin::Paint( • const Rectangle& rRect) – [rectangle to repaint]
  4. 4 / 14 Event Name | Your Name SwCrsrShell –

    ancestor of SwWrtShell • SwWrtShell is used by the UI to modify the document model • SwCrsrShell::Paint( • const Rectangle &rRect)
  5. 5 / 14 Event Name | Your Name SwViewShell –

    ancestor of SwCrsrShell • SwViewShell::Paint( • const Rectangle &rRect) • The “real” drawing starts here • Toplevel – draws the shadows around the document etc. • Very ugly, actually – part of the code in the class, part is global in the .cxx • Many OutputDevices out there, etc.
  6. 6 / 14 Event Name | Your Name Now we

    are getting to the document model • SwRootFrm – the root element of a Writer document layout • SwRootFrm::Paint( • SwRect const& rRect, – Rectangle to paint • SwPrintData const*const pPrintData) const – Gets NULL here
  7. 7 / 14 Event Name | Your Name Getting deeper

    into the model • Calling hierarchically (more times in the backtrace) • SwLayoutFrm::Paint( • SwRect const& rRect, • SwPrintData const*const) const
  8. 8 / 14 Event Name | Your Name Finally we

    got to the text frame • SwTxtFrm::Paint( • SwRect const& rRect, • SwPrintData const*const) const • We split the frame to lines
  9. 9 / 14 Event Name | Your Name And then

    split the line to portions • SwTxtPainter::DrawTextLine( • const SwRect &rPaint – [rectangle to paint] • SwSaveClip &rClip, – [clipping] • const sal_Bool bUnderSz ) – [paint the entire line, or by portions?]
  10. 10 / 14 Event Name | Your Name And now

    “only” draw the portions • SwTxtPortion::Paint( • const SwTxtPaintInfo &rInf ) const • SwTxtPaintInfo::DrawText( • const SwLinePortion &rPor, • const sal_Int32 nLength, • const sal_Bool bKern ) const • [just a wrapper for the next one]
  11. 11 / 14 Event Name | Your Name “Just do

    it” kind of method • SwTxtPaintInfo::_DrawText( • const OUString &rText, • const SwLinePortion &rPor, • const sal_Int32 nStart, • const sal_Int32 nLength, • const sal_Bool bKern, • const sal_Bool bWrong, • const sal_Bool bSmartTag, • const sal_Bool bGrammarCheck )
  12. 12 / 14 Event Name | Your Name Getting closer

    to actual drawing • SwFont::_DrawText( • SwDrawTextInfo &rInf) • [just a wrapper] • SwSubFont::_DrawText( • SwDrawTextInfo &rInf, • const sal_Bool bGrey ) • [takes care of the underlining, etc.]
  13. 13 / 14 Event Name | Your Name Compute the

    positions of the glyphs • SwFntObj::DrawText( • SwDrawTextInfo &rInf )
  14. 14 / 14 Event Name | Your Name And finally

    – draw the text! • OutputDevice::DrawTextArray( • const Point& rStartPt, • const OUString& rStr, • const sal_Int32* pDXAry, – [offsets of the letters] • sal_Int32 nIndex, • sal_Int32 nLen )