summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/textboxhelper.cxx
AgeCommit message (Collapse)AuthorFilesLines
2025-06-05SwAttrPool: pass SwDoc by refXisco Fauli1-18/+18
After commit ca6b1677cc3d923f0c13b2253b48a0ea90485b41 Author: Xisco Fauli <xiscofauli@libreoffice.org> Date: Tue Jun 3 11:59:57 2025 +0200 sw: no need to create a dummy attr pool Change-Id: Iadc9df6ffab9f479355cd3e2c649a2d3f9c1dbfb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186203 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-04-16Make UINames and Programmatic Names typesafeNoel Grandin1-1/+1
by wrapping up OUStrings inside some type-safe wrappers to make it obvious in the code what kind of name we are dealing with. The new classes are in sw/inc/names.hxx Note that I spun the names for table formats out into their own name class TableStyleName, becuase they are weird. Most of the time they are UINames, but not always. Change-Id: Iaf320639fd1aae8ba0f99866ff206906544c42be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178839 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-03-12use more concrete UNO class in swNoel Grandin1-24/+19
Change-Id: If5839135eba9e82516c29441d28938e73570d7f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182837 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
2025-02-14use more concrete UNO in writerNoel Grandin1-1/+2
Change-Id: I5a177f6bf1a0dc134ed1b0cf80f0e99cc1fcb937 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181667 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
2024-11-28tdf#163913 Implement font-relative marginsJonathan Clark1-2/+2
This change adds loext:margin-left and loext:margin-right, which implement margins that support font-relative units. See tdf#36709 for additional details. Change-Id: I31b0dd2b6f98cb5b02fd4dca3608db6fdee4054c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177473 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
2024-11-19improve loplugin passparamsbyrefNoel Grandin1-1/+1
I think I managed to disable this when I converted it to use the shared plugin infrastructure. So fix that, and then make it much smarter to avoid various false positives. Change-Id: I0a4657cff3b40a00434924bf764d024dbfd7d5b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176646 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-11-18tdf#163486: PVS: dereferencing of a potential null pointerXisco Fauli1-2/+5
V522 There might be dereferencing of a potential null pointer. Change-Id: I23e4eba0399243ca67ecaa3101a327eece825687 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176722 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2024-11-12loplugin:reftotemp in swNoel Grandin1-6/+6
Change-Id: I370d18643b0c83c60846a0b6f051440a043c647a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176486 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-11-12sw: use SAL_RET_MAYBENULL in GetDocShell()Xisco Fauli1-3/+5
similar to commit c796878e6af0fc7c886e813a0010d9402312eb5c Author: Xisco Fauli <xiscofauli@libreoffice.org> Date: Mon Oct 21 15:56:25 2024 +0200 tdf#163543: check GetDocShell() Change-Id: I4b489c59b7596466aea6b5c7b78248d82f193a0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175628 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Jenkins
2024-09-17use more concrete UNO types in swNoel Grandin1-2/+3
Change-Id: I0f84ce7116441abb2359ee756c912ae663baa2fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173545 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-09-06tdf#152142 sw: fix RTL as-char textbox compat flag special caseJonathan Clark1-2/+13
Fixes an issue causing incorrect textbox positions when the containing shape is anchored 'as character' inside RTL text, with the DoNotMirrorRtlDrawObjs compatibility flag set. Change-Id: I58cade8b91925dda188a1ef8fd078ccfdc3fea56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172938 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
2024-09-04NFC prep for tdf#143899: move TextBoxIsFramePr into SwTextBoxHelperJustin Luth1-0/+26
Now that writerfilter is part of sw, this helper function can be moved into a generic location so it can be used elsewhere. It will be needed for a layout exception, where floating tables and framePr frames are laid out differently from all other floating objects thanks to some new Microsoft inconsistencies. Change-Id: Ibb30a8831426b9dfd3e86ed082ecef22476fe018 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172620 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2024-08-29tdf#152142 sw: fix RTL as-char anchored textbox positioningJonathan Clark1-5/+15
Fixes an issue causing incorrect textbox positions when the containing shape is anchored 'as character' inside RTL text. Change-Id: I4a68348b778adbdb893a62a29a1fb31ffbcf55e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172529 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
2024-08-17tdf#162211 tdf#158384 layoutInCell: doTextBoxPositioning betterJustin Luth1-6/+25
by simply honouring FollowTextFlow as the comment states. I needed to look into this because of a failing unit test. I can't say I understand why sync needs to lay out two things instead of just laying out one and copying the screen position, but bug 158384 indicated that the wrong value was added, so I looked for alternatives to use instead of nLeftSpace. A better sounding alternative was textbox spacing to border, but that is already taken into account. Then I realized a negative offset was being applied against the cell edge - which is only allowed for bWrapThrough. Unfortunately, that once again breaks the unit test I have been trying to accommodate. I can only assume that the unit test's pressuppositions are false. So I'm changing the unit test to test things that are certain! make CppunitTest_sw_layoutwriter2 CPPUNIT_TEST_NAME=testTdf116256 Given how wonky textbox sync is, I'm not confident that ANYTHING here is actually correct. Change-Id: I2e73b7345b4d4c3da78d62644032cb573dc6821e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171577 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2024-08-17Fix wrong = where == was intendedMike Kaganski1-1/+1
Introduced in commit cd740ff560a88a62bc79f5ea5b92bdadf71ba728. Thanks Caolan for spotting this! Change-Id: Ieb046013f7bd09b539b01b5d360f52a9cb39e245 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171783 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
2024-08-15tdf#162480: Make sure to use correct anchor point for text box creationMike Kaganski1-5/+31
In the ODF import, when importing a table, initially a placeholder 1x1 table is created. When this is done from SwView::InsertMedium, frames are created for the table and its single cell at that stage. Then the actual table nodes are created, but frames are not created in parallel, until the table import is finished. Importing a text box, it used to be created anchored at the end of the document, and then the anchor was moved to the correct place. When a text box was anchored to a cell, the process was like this: the text content was inserted in the last paragraph outside of the current table; and then it was moved to the current cell. When this was done from SwView::InsertMedium, creation of the text content also created the frame; then the movement fired client notifications, including the SwFlyAtContentFrame::SwClientNotify, which needs the new anchor frame. With cell other than A1, there was no frames for the new anchor in the table, and that crashed. This change inserts the text content into the correct place from start, which avoids the need to move the anchor later. Co-authored-by: Miklos Vajna <vmiklos@collabora.com> Change-Id: I9dd3a2c5527f3c2dd860244456c617558943453a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171898 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
2024-08-09It seems that SdrPage must not contain nullptrMike Kaganski1-8/+6
It takes precautions to not insert nullptr (see SdrObjList::InsertObject), so it would be a programming error to find one here. Change-Id: If5e267743ac6d786575f2c7ca6e7b3e9cc67b082 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171671 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
2024-08-09Simplify a bitMike Kaganski1-7/+5
Change-Id: I5d876ce05f070df48d36acbd988de5781fcd1543 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171670 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-08-05tdf#162075 sw textbox: map a shape's wordwrap=no to the frame's width typeMiklos Vajna1-0/+14
Regression from commit c761df1e42fd11acc5fc05b0baacd803c3788ca6 (tdf#84678 DOCX import: fix handling of textbox margins, 2016-10-25), the header hape was supposed to have a single line, but it had a separate line for each character in the shape text. What happened is that the nominal size of the shape was not enough to provide enough space for the text, now that we handle spacing between the frame border and text, and the shape had automatic height set, instead of automatic width. Fix the problem by extending SwTextBoxHelper::create() to map the shape's TextWordWrap property to the inner frame's WidthType. As the tdf#81567 testcase points out, this requires extending the matching shape update code as well, because word wrap is always disabled initially, and it's enabled only after the shape's text is processed. Also adjust sw/qa/extras/layout/data/tdf138951.odt, which expected word wrap but didn't request it -- the original tdf#138951 bugdoc keeps working after this commit. Change-Id: I17c896f83731a6653e3a0a1493949e27d5259232 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171475 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2024-07-22crashtesting tdf135164-3.docxNoel Grandin1-32/+38
./instdir/program/soffice --headless --convert-to odt ~/Downloads/tdf135164-3.docx fails after commit f98f684d22e6323185104ca9c082241c53dfc2b3 Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Sat Jul 13 18:50:34 2024 +0200 remove RecalcObjOrdNums in DoTextBoxZOrderCorrection add a check to catch this case and flatten the method to make it more readable Change-Id: I7827807c77f51b28f16b1042b77b8211ab5416ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170839 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-07-15remove RecalcObjOrdNums in DoTextBoxZOrderCorrectionNoel Grandin1-8/+1
(1) We already do this recalculation automatically using a dirty flag. (2) Add a custom method so we don't trigger that recalculation here Speeds up display of a complex DOCX file load by 10% Change-Id: I2a8c975ba0711172bc3e0c20c0e89f08351b6126 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170431 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-06-26simplify logic in DoTextBoxZOrderCorrectionNoel Grandin1-16/+4
which is doing things in an unnecessarily complex way. The simpler way makes a complex DOCX file load 20% faster Change-Id: I507e2bfd5e315f50e4fa790711286785e0f11445 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169529 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
2024-06-13loplugin:ostr in sw/../coreNoel Grandin1-2/+2
Change-Id: I69cf0cc769861a24a7239ad82c0c46a12dbed5f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168811 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
2024-01-01Replace "size() != 0 with !empty()" (sw)Julien Nabet1-1/+1
Change-Id: Iaa94c0b057694429b327cbca847fee06ad74256a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161489 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-10-22Use getXWeak in swMike Kaganski1-2/+1
Change-Id: I49d2d1a00928c4cea68164e8c91fd9a6bb4b3b94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150875 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-10-18use more SdrObjList::begin/end in swNoel Grandin1-14/+11
Change-Id: If882c1c7863618a313b2e06abacdbfa756dfff3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158114 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-05-12drop solarmutex guard from SwTextBoxHelper::isTextBoxNoel Grandin1-1/+1
this path is very hot on some workloads, and AFAICT the SolarMutex is already taken on all paths leading here. But leave a DBG_TESTSOLARMUTEX just to be sure. Change-Id: Ida278360a8f740b2490574eea5411d952287b10c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151690 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-04-28Revert "Revert "introduce sw::SpzFrameFormat ...""Bjoern Michaelsen1-3/+2
apparently, in SwHistoryChangeFlyAnchor::SetInDoc, m_rFormat might actually reference a DrawFormat, not a FlyFormat, and that is likely fundamentally broken. But for now, lets just make m_rFormat a sw::SpzFrameFormat -- this already removes some pointless up and downcasting. This reverts commit 52acefd6024ec79f8333ba40eef83816eda3046f. Change-Id: I040d98548bf9ac1c25b93214224eb0812f8cb653 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151150 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
2023-04-27Revert "introduce sw::SpzFrameFormat ..."Stephan Bergmann1-2/+3
This reverts commit 09cdcb5f37bb4e42da7b28db6e757b9f2affed14. It broke at least CppunitTest_sw_uiwriter3 (<https://ci.libreoffice.org//job/lo_ubsan/2756/>), > /sw/source/core/undo/rolbck.cxx:938:46: runtime error: downcast of address 0x61300041fd00 which does not point to an object of type 'SwFlyFrameFormat' > 0x61300041fd00: note: object is of type 'SwDrawFrameFormat' > 00 00 00 00 70 83 cf 09 25 7f 00 00 00 83 47 00 30 61 00 00 40 e5 43 00 30 61 00 00 80 66 5d 00 > ^~~~~~~~~~~~~~~~~~~~~~~ > vptr for 'SwDrawFrameFormat' > #0 0x7f24fca9c5b9 in SwHistoryChangeFlyAnchor::SetInDoc(SwDoc*, bool) /sw/source/core/undo/rolbck.cxx:938:46 > #1 0x7f24fca880f3 in SwHistory::Rollback(SwDoc*, unsigned short) /sw/source/core/undo/rolbck.cxx:1208:15 > #2 0x7f24fcb47832 in SwUndoDelete::UndoImpl(sw::UndoRedoContext&) /sw/source/core/undo/undel.cxx:1031:33 > #3 0x7f24fcb703c2 in SwUndo::UndoWithContext(SfxUndoContext&) /sw/source/core/undo/undobj.cxx:225:5 > #4 0x7f2543b8b57c in SfxUndoManager::ImplUndo(SfxUndoContext*) /svl/source/undo/undo.cxx:712:22 > #5 0x7f2543b8c4f8 in SfxUndoManager::UndoWithContext(SfxUndoContext&) /svl/source/undo/undo.cxx:664:12 > #6 0x7f24fca6a074 in sw::UndoManager::impl_DoUndoRedo(sw::UndoManager::UndoOrRedoType, unsigned long) /sw/source/core/undo/docundo.cxx:696:32 > #7 0x7f24fca6b38f in sw::UndoManager::UndoWithOffset(unsigned long) /sw/source/core/undo/docundo.cxx:731:16 > #8 0x7f24fa830b18 in SwEditShell::Undo(unsigned short, unsigned short) /sw/source/core/edit/edundo.cxx:141:57 > #9 0x7f250088f448 in SwWrtShell::Do(SwWrtShell::DoType, unsigned short, unsigned short) /sw/source/uibase/wrtsh/wrtundo.cxx:45:26 > #10 0x7f24ff7f16e2 in SwBaseShell::ExecUndo(SfxRequest&) /sw/source/uibase/shells/basesh.cxx:651:27 > #11 0x7f24ff7eea14 in SfxStubSwBaseShellExecUndo(SfxShell*, SfxRequest&) /workdir/SdiTarget/sw/sdi/swslots.hxx:2203:1 > #12 0x7f2523fbc059 in SfxDispatcher::Call_Impl(SfxShell&, SfxSlot const&, SfxRequest&, bool) /sfx2/source/control/dispatch.cxx:254:9 > #13 0x7f2523fd1ced in SfxDispatcher::Execute_(SfxShell&, SfxSlot const&, SfxRequest&, SfxCallMode) /sfx2/source/control/dispatch.cxx:753:9 > #14 0x7f2523f61333 in SfxBindings::Execute_Impl(SfxRequest&, SfxSlot const*, SfxShell*) /sfx2/source/control/bindings.cxx:1060:22 > #15 0x7f252437496b in SfxDispatchController_Impl::dispatch(com::sun::star::util::URL const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> const&) /sfx2/source/control/unoctitm.cxx:688:53 > #16 0x7f2524377211 in SfxOfficeDispatch::dispatchWithNotification(com::sun::star::util::URL const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> const&) /sfx2/source/control/unoctitm.cxx:266:16 > #17 0x7f24cad28dd6 in framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatch> const&, com::sun::star::util::URL const&, bool, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /framework/source/services/dispatchhelper.cxx:163:30 > #18 0x7f24cad27cb2 in framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /framework/source/services/dispatchhelper.cxx:120:16 > #19 0x7f24cad29684 in non-virtual thunk to framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /framework/source/services/dispatchhelper.cxx > #20 0x7f24e91d386d in unotest::MacrosTest::dispatchCommand(com::sun::star::uno::Reference<com::sun::star::lang::XComponent> const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /unotest/source/cpp/macros_test.cxx:94:33 > #21 0x7f25319b2012 in testTdf132321::TestBody() /sw/qa/extras/uiwriter/uiwriter3.cxx:982:5 Change-Id: Ibeb181bc38cd6f88df76403cca8a15b45090633f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151027 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-04-24introduce sw::SpzFrameFormat ...Bjoern Michaelsen1-3/+2
- ... as a base class of frame formats allowed into the spz frame format container - with a private ctor and friends SwDrawFrameFormat and SwFlyFrameFormat so only these two classes derive from it - with that, switch over the SpzFrameFormats to only ever allow these types into the container - in followups, likely quite a bit of stronger typing can be introduced. - ultimately, it would be nice to have each SwDrawFrameFormats and SwFlyFrameFormats in their own strongly typed container in the end. Change-Id: Ic30efc1220aded701533c9ca5003d2aaf8bbdaec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150452 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
2023-01-31tdf#153289: remove problematic assertionMike Kaganski1-1/+0
It is unclear what it should guarantee; but at least when ungrouping, SwDoc::UnGroupSelection copy-constructs a shared pointer (increasing the refcount), then a copy-constructed argument passed to lcl_CollectTextBoxesForSubGroupObj increases it once again, and then the assertion expectedly fails. Change-Id: I0cb5f303c67b2dc67d5583a9eb03fe405af3573d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146377 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-11-24add SwFormatAnchor::GetAnchorNode methodNoel Grandin1-13/+9
as a step towards switching away from using SwPosition inside SwFormatAnchor (because SwFormatAnchor wants to do weird stuff with the internals of SwPosition) Change-Id: I1527b6585d1e130b46e1e51b1e40eea043339d8f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143205 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-11-24Remove some unused includesMiklos Vajna1-1/+0
Mostly com/sun/star/frame/Desktop.hpp is unused after inheriting from UnoApiTest. Change-Id: Ifba307353a11a14e033a230a291314bee86b51c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143190 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-11-02tdf#54857 elide more dynamic_castNoel Grandin1-1/+1
Change-Id: I42bef355eeef15e3733a5ee57b0569887cfa5e84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142183 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-14tdf#149551 use 'WritingMode' instead of TextPreRotateAngleRegina Henschel1-1/+10
Commit 7e23cbdbb6ec0247a29ed8a8f744c01e10963ea0 changed the code so, that TextPreRotateAngle is used to track ooxml vert attribute. This patch changes it so, that the style attribute WritingMode is used. Now text direction can be written in 'writing-mode' attribute in the graphic properties in ODF, same for shapes as for frames. The needed conversion from WritingMode BT-LR and TB_LR90 to TextPreRotateAngle for rendering of text in custom shapes is now in one place in class SdrObjectCustomshape. The shape edit engine cannot yet render it itself. Some unit tests are adapted to use WritingMode property instead of TextPreRotateAngle. The value text::WritingMode2::TB_RL90 is introduced, corresponding to vert='vert' and textDirection='tbRl' or ='rl' in OOXML. It is used for frames too, so that the original text direction is preserved and vert='eaVert' can be distinguished from vert='vert'. TextPreRotateAngle is currently still used in SmartArt import for 'upr' and 'grav' and in emulating 'upright' but no longer to emulate text direction. Change-Id: Idc4339bbfc3592fe90b154d75e2c404a1fa30856 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138813 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-08-19use more SwPosition::GetContentIndexNoel Grandin1-12/+2
part of the process of hiding the internals of SwPosition Change-Id: Iaf038c006fc9f82073664536278aac4d44754340 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138512 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-14rename SwPaM::GetNode to GetPointNode/GetContentNodeNoel Grandin1-1/+1
Using a parameter to select point/mark makes the code much harder to read Change-Id: I4ac8b904ac423e2b99253b7e4b6adc72c8afe1a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138083 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-03tdf#143703 sw: always assign name for fly sectionVasily Melenchuk1-2/+4
Previously generated name was assigned only if not in doc reading mode. But there is no guarantee that it will be assigned later. Better to insert any name in SwDoc::MakeFlySection_() and later it can be overwritten, but fly will definitely have any unique name. * Some test failed because GraphicImport_Impl::applyName() overwrote the name with a different generated one. * This breaks chaining of VML shapes, see test testTDF87348. The code introduced in commit 091fe76b6329b4bb974987554369cbfadd8f2401 in DomainMapper_Impl::ChainTextFrames() breaks if the text frame already has a name; it's a bit confusing which names there come from the file and which come from the API, and it also mixes 2 different cases of VML chaining and DrawingML chaining that look like they should be using different data. * This also breaks moving flys anchored at-char in flys into them in SwXText::convertToTextFrame(), see ooxmlexport13 testFlyInFly. This kind of worked by accident before: the fly is copied and then the original deleted, keeping the same name (with help of SwDoc::mbCopyIsMove); with no name it would compare the SdrObject pointer, which is different for the new copy, now the name is the same. Fix this by only moving flys anchored at the edge of the selection back inoto the body; it turns out that Word actually supports at-char anchors in text frames, but only if it's a VML shape or Compatibility Mode or whatever; i wasn't able to do it in a document created from scratch. This is a bit tricky to ignore the nodes added for floating tables as seen in ooxmlexport10 testFloatingTablesAnchor. * Another change is required in SwDoc::SetFlyName() because of testTdf127732, as it would rename a frame named "Frame1" to "Frame2" when called to rename it to "Frame1". * Some tests failed because after MakeFlySection_() assigns a name it is immediately unconditionally overwritten; replace that with asserts Change-Id: I46752a4413ba3a9e981eccd1e153b3aaf8053781 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127556 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-02introduce SwPosition::GetNodeNoel Grandin1-6/+6
as part of the process of hiding the internals of SwPosition largely done by doing: git grep -lF 'nNode.GetNode' | xargs perl -pi -e 's/nNode\.GetNode/GetNode/g' Change-Id: Id1937df1bd5a54677c2c1bbfb2d693a4e22a7b98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137671 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-21use more concrete UNO classes in writerNoel Grandin1-7/+9
as opposed to opaque UNO interfaces. This is a prelude which enables performance work because now I can regular C++ method Change-Id: I9bcfdca1000b4439431c9ea3b17bed081d80f0b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137275 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-12tdf#142715 sw: fix crash on exit when textbox inserted to tableAttila Bakos (NISZ)1-11/+2
This reverts commit 06e2cbb31d0ea703df872b91eb8eacdcaced7653 "tdf#130805 SwTextBoxHelper::create: fix frame position in shape" which caused this regression. That fix is not necessary any more: synchronization does the same without crashing. Note: according to this, unit test of commit 06e2cbb31d0ea703df872b91eb8eacdcaced7653 wasn't removed. Change-Id: I45bc15d3cf6a5d93b8c54cb4e68018702e58efff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136674 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
2022-07-11tdf#148687 tdf#149173 tdf#149546 sw: fix crash with textboxesAttila Bakos (NISZ)1-100/+209
Regression from 2110597ac730fa07dbbdd603fda82b182ed27c9e "tdf#147485 sw: fix group shape crash using std::shared_ptr". Details: 1) Using reference instead of copy assignment in SwTextBoxHelper. 2) Cleanup: Unused parts of SwTextBoxHelper were removed. 3) Fixing destruction of textboxes, in case when first the shape is removed, with clearing all textboxes from the doc and the shape before the pointer is released. All of this only have to be done if the call is not coming from the swdoc dtor, unless there will be double freeing. 4) Missing style conversion was fixed in writerfilter. 5) Don't import sections in textboxes, unless the hack of dummy paragraph before tables in sections will be applied and the paragraph with anchored objects inside will be removed with the objects; 6) ConvertTextRangeToTextFrame also fixed, so embed frames in frames are imported from now. (Also textboxes in frames, this can be useful when there is a floating table having group textbox with nested complex content inside, or floating table in floating table, etc...) Note: Follow up commit will enable group textbox import in frames and tables. 7) Import of group textboxes with complex content in header/footer was impossible, from now this is also supported both from DOCX and ODT (test included). 8) Guard class for blocking unwanted recursive textbox sync has been introduced, and maybe some speedup with group textbox import has been achieved. 9) The anchor sync method got a new function which avoids unnecessary sync when the anchor is the same. 10) Sync of As_char textboxes during layout calculation caused crash so that has a workaround from now, for DOCX import anchor change and Undo. That syncs starts before the layout calculation so sync not needed later. 11) A memory leak was found in Undo, which has been fixed. Note: layout test "testTdf147485Forcepoint" has to be limited to Windows and Mac builds, because font substitution causes crash on the Unix based systems. Change-Id: I69d5d79cc120e3a70ba9285be32ec36a434b2a04 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136192 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
2022-07-11tools: rename getHeight/Width() to GetOpenHeight/Width()Chris Sherlock1-5/+5
By default Rectangle uses closed interval, if we really want to use half open intervals then we should specifically say as such in the name. Change-Id: Id7a91120ba1a1a4bc330014216b73a692dbf03a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136575 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2022-06-29tdf#149550 sw: fix crash by implementing nested textbox copyAttila Bakos (NISZ)1-1/+80
Grouped shapes with a nested textbox were copied without the textbox with frequent crashing. Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834 "tdf#143574 OOXML export/import of textboxes in group shapes". Change-Id: Ie2cc24f10706d8999026dc92ebad21f2c5673003 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135815 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
2022-05-19tdf#148720 sw DOCX: fix jumbled group textbox regressionAttila Bakos (NISZ)1-0/+5
Left-aligned group shape was synced to the textbox, resulting jumbled positions after DOCX export/import. To fix it, set horizontal orientation of the textbox back to NONE. Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834 "tdf#143574 OOXML export/import of textboxes in group shapes". Change-Id: I02ee79862344f3495846091e3eef27c24d8ef162 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134149 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
2022-05-03Just use Any ctor instead of makeAny in swStephan Bergmann1-29/+25
Change-Id: I2c9023ba8d07314d23ae7a65e670e8748c5e9322 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133766 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-04-27tdf#146449 sw: fix Z-order after undoingAttila Bakos (NISZ)1-6/+5
Textbox z-order synchronization was missing in case of Undo, resulting broken text boxes. Regression from 504d78acb866495fd954fcd6db22ea68f174a5ab "tdf#143574 sw: textboxes in group shapes - part 1". Change-Id: I2632b7fb40e327f083e680e10b19c8f405df1875 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130875 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: Attila Bakos <bakos.attilakaroly@nisz.hu> Reviewed-by: László Németh <nemeth@numbertext.org>
2022-04-01tdf#147485 sw: fix group shape crash using std::shared_ptrAttila Bakos (NISZ)1-31/+61
for SwFrameFormat::m_pOtherTextBoxeFormats. Before there was broken manual handling of this member, resulting random crashes. Details: Writer textboxes are textframe + shape pairs. Accordingly the shape has a draw format, the frame has a fly format. In case of group shapes the paired structure doesn't work, because there is one shape format and many fly formats. To handle this there is a class (SwTextBoxNode) which has a small frame format table inside. This cache gives the possibility to handle each frame shape pairs inside the group depending on what SdrObject owns that textbox. However there is another place where these formats stored, namely the SpzFrameFormatTable in SwDoc. The only problem is that, when a flyframe removed, it has to be deleted from both tables, but if the DelLayoutFormat() is called, that will call the ~FrameFormat(), and if the format already deleted from the SwTextBoxNode, there will be double deleting for the same address, which caused the crash. To avoid this the following is present: When fly deletion occurs, first the format is deleted from the doc, then via the ~SwFrameFomat() will be deleted from the TextBoxNode. If the deleted format is a drawing, the whole node will be destructed via the shared_ptr. Hopefully that will be fine, without any leak. Change-Id: I007724695bc035998cb35efeefecd308aae36e85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132308 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
2022-03-24loplugin:constantparamNoel Grandin1-14/+14
Change-Id: Ib863ea852792635e521050019a3a190b3eeb681e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132031 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-03-11loplugin:constparamsNoel Grandin1-1/+1
Change-Id: I5f184f93dbdb414514855c85c9dc1624e7ec8636 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131337 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>