diff options
author | Attila Bakos (NISZ) <bakos.attilakaroly@nisz.hu> | 2021-03-09 16:32:27 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-03-29 11:33:52 +0200 |
commit | ff321dd36554d25f0817903becf4598065e0a194 (patch) | |
tree | e7d348490b7b3040abb99d69af3b6a24108e1139 /sw | |
parent | 3d844a131d7d2d2c82d865d17ad7657c7e8a185c (diff) |
tdf#140828 sw textbox: fix AS_CHAR regression
Textboxes anchored as characters don't lose
their text frames after changing the anchor
"To character".
Regression from commit 493a916a3113e877835c9bc7c93faef0d29f9a33
(tdf#140158 tdf#138598 tdf#140598 sw: fix sync of AS_CHAR textboxes).
Change-Id: I0e6d88c9dcdeff515744bc4c201a5640eb810d1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112209
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rwxr-xr-x | sw/qa/extras/uiwriter/data3/tdf140828.docx | bin | 0 -> 5393 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 32 | ||||
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/text/porfly.cxx | 4 |
4 files changed, 39 insertions, 2 deletions
diff --git a/sw/qa/extras/uiwriter/data3/tdf140828.docx b/sw/qa/extras/uiwriter/data3/tdf140828.docx Binary files differnew file mode 100755 index 000000000000..bfdabc5d77ea --- /dev/null +++ b/sw/qa/extras/uiwriter/data3/tdf140828.docx diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 63a322af868e..cf14ac853264 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <IDocumentDrawModelAccess.hxx> #include <com/sun/star/text/TextContentAnchorType.hpp> +#include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> @@ -1089,6 +1090,37 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf76636_2) CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getColumns()->getCount()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf140828) +{ + load(DATA_DIRECTORY, "tdf140828.docx"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + uno::Reference<drawing::XShape> xShp = getShape(1); + CPPUNIT_ASSERT(xShp); + + uno::Reference<beans::XPropertySet> ShpProps(xShp, uno::UNO_QUERY_THROW); + dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:SetAnchorAtChar", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT(ShpProps->getPropertyValue("AnchorType").get<text::TextContentAnchorType>() + != text::TextContentAnchorType::TextContentAnchorType_AS_CHARACTER); + + uno::Reference<text::XTextFrame> xTxBx(SwTextBoxHelper::getUnoTextFrame(xShp)); + CPPUNIT_ASSERT(xTxBx); + + uno::Reference<beans::XPropertySet> TxBxProps(xTxBx, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(OUString("top left image"), xTxBx->getText()->getString()); + + CPPUNIT_ASSERT_MESSAGE("Bad Relative Orientation and Position!", + TxBxProps->getPropertyValue("HoriOrientRelation").get<sal_Int16>() + != text::RelOrientation::CHAR); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132725) { load(DATA_DIRECTORY, "tdf132725.odt"); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 9bcd522e4277..08fccb737b6c 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -165,8 +165,6 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, bool bCopyText) if (xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_WRITINGMODE) >>= eMode) syncProperty(pShape, RES_FRAMEDIR, 0, uno::makeAny(sal_Int16(eMode))); - // TODO: Text dialog attr setting to frame - // Check if the shape had text before and move it to the new textframe if (!bCopyText || sCopyableText.isEmpty()) return; @@ -747,6 +745,9 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u } else // Otherwise copy the anchor type of the shape { + // tdf#140828: Do not keep CHAR rel-orientation: + xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION, + uno::Any(text::RelOrientation::FRAME)); xPropertySet->setPropertyValue(UNO_NAME_ANCHOR_TYPE, aValue); } // After anchoring the position must be set as well: diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index e41afd83d7cb..cb071be3c512 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -351,9 +351,11 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase, // Both rectangles are absolute, SwFormatHori/VertOrient's position // is relative to the print area of the anchor text frame. tools::Rectangle aTextRectangle = SwTextBoxHelper::getTextRectangle(pShape); + tools::Long nXoffs = SwTextBoxHelper::getTextRectangle(pShape, false).getX(); const auto aPos(pShape->GetAnchor().GetContentAnchor()); SwFormatVertOrient aVert(pTextBox->GetVertOrient()); + SwFormatHoriOrient aHori(pTextBox->GetHoriOrient()); // tdf#138598 Replace vertical alignment of As_char textboxes in footer // tdf#140158 Remove horizontal positioning of As_char textboxes, because @@ -373,10 +375,12 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase, SwFormatAnchor aNewTxBxAnchor(pTextBox->GetAnchor()); aNewTxBxAnchor.SetAnchor(aPos); + aHori.SetPos(nXoffs); pTextBox->LockModify(); pTextBox->SetFormatAttr(aNewTxBxAnchor); pTextBox->SetFormatAttr(aVert); + pTextBox->SetFormatAttr(aHori); pTextBox->UnlockModify(); } } |