| commit | 810f7e4e0b61ee7cb3a7d6a1b503782d7248a4b1 | [log] |
|---|---|---|
| author | Michael Stahl <michael.stahl@allotropia.de> | Tue Apr 13 20:13:51 2021 +0200 |
| committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | Fri Apr 23 17:03:13 2021 +0200 |
| tree | bd37437cda74a38f9d3e85afa2fc0dcbc459b05c | |
| parent | 7d610d0bba0953e42f357d5deaecc6eabb76985e [diff] |
sw: layout: if fly's anchor moves forward, move fly off SwPageFrame The problem is that on Show Changes->Hide Changes->Show Changes in a 311 page document, the fly "Grafik1" was initially on page 203 but ends up on page 204, with a fly-sized gap on page 194. In a 25 page cut down version of the bugdoc, on layout action 659 the fly's anchor SwTextFrame moves from page 21 to page 22, but the fly remains in the SwPageFrame's m_pSortedObjs, because it's not the anchor frame itself that moves but a distant previous frame, and page 21 goes valid. 0 SwFlowFrame::PasteTree(SwFrame*, SwLayoutFrame*, SwFrame*, SwFrame*) (pStart=0x57c9e30, pParent=0xba15c50, pSibling=0x5a0f920, pOldParent=0xb057690) at sw/source/core/layout/flowfrm.cxx:586 1 SwFlowFrame::MoveSubTree(SwLayoutFrame*, SwFrame*) (this=0x57c9f48, pParent=0xba15c50, pSibling=0x5a0f920) at sw/source/core/layout/flowfrm.cxx:677 2 SwFlowFrame::MoveFwd(bool, bool, bool) (this=0x57c9f48, bMakePage=true, bPageBreak=false, bMoveAlways=false) at sw/source/core/layout/flowfrm.cxx:2061 3 SwContentFrame::MakeAll(OutputDevice*) (this=0x57c9e30) at sw/source/core/layout/calcmove.cxx:1831 4 SwFrame::OptPrepareMake() (this=0x57c9e30) at sw/source/core/layout/calcmove.cxx:399 5 SwFrame::OptCalc() const (this=0x57c9e30) at sw/source/core/inc/frame.hxx:1065 6 SwLayAction::FormatContent_(SwContentFrame const*, SwPageFrame const*) (this=0x7ffec0191b30, pContent=0x57c9e30, pPage=0xb9a1fd0) at sw/source/core/layout/layact.cxx:1833 In subsequent layout actions the anchor frame moves forward one page at a time, until in action 665, when things get really interesting. On page 24, the anchor text frame 582 is formatted for the first time, and it moves the fly to page 24, after positioning it on the page. 2 SwPageFrame::MoveFly(SwFlyFrame*, SwPageFrame*) (this=0xb9a1fd0, pToMove=0x641d310, pDest=0x9125bb0) at sw/source/core/layout/flylay.cxx:972 3 SwFlyAtContentFrame::RegisterAtCorrectPage() (this=0x641d310) at sw/source/core/layout/flycnt.cxx:1432 4 SwAnchoredObject::SetVertPosOrientFrame(SwLayoutFrame const&) (this=0x641d468, _rVertPosOrientFrame=...) at sw/source/core/layout/anchoredobject.cxx:195 5 SwFlyAtContentFrame::MakeObjPos() (this=0x641d310) at sw/source/core/layout/flycnt.cxx:1466 6 SwFlyFreeFrame::MakeAll(OutputDevice*) (this=0x641d310) at sw/source/core/layout/flylay.cxx:223 7 SwFlyAtContentFrame::MakeAll(OutputDevice*) (this=0x641d310, pRenderContext=0x55b1f00) at sw/source/core/layout/flycnt.cxx:384 8 SwFrame::PrepareMake(OutputDevice*) (this=0x641d310, pRenderContext=0x55b1f00) at sw/source/core/layout/calcmove.cxx:375 9 SwFrame::Calc(OutputDevice*) const (this=0x641d310, pRenderContext=0x55b1f00) at sw/source/core/layout/trvlfrm.cxx:1791 10 SwFlyFrame::Calc(OutputDevice*) const (this=0x641d310, pRenderContext=0x55b1f00) at sw/source/core/layout/fly.cxx:2874 11 SwLayAction::FormatLayoutFly(SwFlyFrame*) (this=0x7ffec0191b30, pFly=0x641d310) at sw/source/core/layout/layact.cxx:1455 12 SwObjectFormatter::FormatObj_(SwAnchoredObject&) (this=0xa5c0d10, _rAnchoredObj=...) at sw/source/core/layout/objectformatter.cxx:286 13 SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject&, bool) (this=0xa5c0d10, _rAnchoredObj=..., _bCheckForMovedFwd=false) at sw/source/core/layout/objectformattertxtfrm.cxx:135 14 SwObjectFormatter::FormatObjsAtFrame_(SwTextFrame*) (this=0xa5c0d10, _pMasterTextFrame=0x0) at sw/source/core/layout/objectformatter.cxx:408 15 SwObjectFormatterTextFrame::DoFormatObjs() (this=0xa5c0d10) at sw/source/core/layout/objectformattertxtfrm.cxx:337 16 SwObjectFormatter::FormatObjsAtFrame(SwFrame&, SwPageFrame const&, SwLayAction*) (_rAnchorFrame=..., _rPageFrame=..., _pLayAction=0x7ffec0191b30) at sw/source/core/layout/objectformatter.cxx:160 17 SwLayAction::FormatContent(SwPageFrame const*) (this=0x7ffec0191b30, pPage=0x9125bb0) at sw/source/core/layout/layact.cxx:1675 18 SwLayAction::InternalAction(OutputDevice*) (this=0x7ffec0191b30, pRenderContext=0x55b1f00) at sw/source/core/layout/layact.cxx:771 Nothing invalidates page 21 now that the fly is gone, and formatting on page 24 is kind of pointless now because everything from page 21 on is wrongly positioned. (It's possible to skip out of the main layout action loop via SetNextCycle()/IsAgain(), but at this point it's in layact:771 in the layout-all-the-visible-pages loop that follows the main loop, and that one can't be cancelled.) Then DoFormatObjs() is called on frame 582, and this calls FormatAnchorFrameForCheckMoveFwd(), which formats previous frame 581, splitting it and moving its follow along with 582 to page 25. Here SwMovedFwdFramesByObjPos::Insert() is called, and now the anchor text frame 582 cannot move back to page 24 because it's prevented by SwMovedFwdFramesByObjPos::FrameMovedFwdByObjPos(), but that was all based on the wrong assumption that the pages before 24 were completely formatted (this happens in action 670). Something later formats page 21 again, and so at the end there is a fly-sized hole at the bottom of page 24, with frame 582 at the top of page 25. It won't help to detect a situation where the fly is on a page previous to the page it's anchor frame is on in DoFormatObjs() because it was actually moved to the same page in a previous formatting of the anchor frame, in the same layout action. To fix this, try to detect in SwLayAction::FormatContent() if the anchor frame of any fly on the page has moved forward, and move those flys off the page; this is enough for the 25 page document. The 311 page document still has a hole on page 194 though; apparently the last content frame on the page is never reformatted, so invalidate its size. Change-Id: I232c6b305e8593bfecd885c36058777f3980f82f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114066 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit eb85de8e6b61fb3fcb6c03ae0145f7fe5478bccf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114519 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
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.
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.
These are the current minimal operating system and compiler versions to run and compile LibreOffice, also used by the TDF builds:
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.
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:
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:
| Module | Description |
|---|---|
| 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 |
| framework | UNO 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
| Module | Description |
|---|---|
| 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:
| Module | Description |
|---|---|
| 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. |
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.
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.