summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/textboxhelper.hxx39
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf141550.docxbin0 -> 18735 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport16.cxx17
-rw-r--r--sw/qa/extras/uiwriter/data3/tdf140975.docxbin0 -> 5124 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx30
-rw-r--r--sw/qa/uitest/data/tdf141557.docxbin0 -> 5394 bytes
-rw-r--r--sw/source/core/doc/textboxhelper.cxx362
-rw-r--r--sw/source/core/text/porfly.cxx1
8 files changed, 344 insertions, 105 deletions
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 2043b1ffcfb3..aa1940b5dd60 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -79,9 +79,48 @@ public:
/// Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& rSet);
+ /// Returns the SwFrameFormat* of the given UNO-XShape if exists otherwise nullptr.
+ static SwFrameFormat* getShapeFormat(css::uno::Reference<css::drawing::XShape> xShape);
+
/// Copy shape attributes to the text frame
static void updateTextBoxMargin(SdrObject* pObj);
+ /// Sets the surround to through for the textframe of the given shape,
+ /// not to interfere with the layout. Returns true on success.
+ static bool setWrapThrough(SwFrameFormat* pShape);
+
+ /// Sets the surround to through for the textframe of the given shape,
+ /// not to interfere with the layout. Returns true on success.
+ static bool setWrapThrough(css::uno::Reference<css::drawing::XShape> xShape);
+
+ /// Sets the anchor of the associated textframe of the given shape, and
+ /// returns true on success.
+ static bool changeAnchor(SwFrameFormat* pShape);
+
+ /// Sets the anchor of the associated textframe of the given shape, and
+ /// returns true on success.
+ static bool changeAnchor(css::uno::Reference<css::drawing::XShape> xShape);
+
+ /// Does the positioning for the associated textframe of the shape, and
+ /// returns true on success.
+ static bool doTextBoxPositioning(SwFrameFormat* pShape);
+
+ /// Does the positioning for the associated textframe of the shape, and
+ /// returns true on success.
+ static bool doTextBoxPositioning(css::uno::Reference<css::drawing::XShape> xShape);
+
+ /// Returns true if the anchor different for the given shape, and the
+ /// associated textframe of the given shape.
+ /// Note: In case of AS_CHAR anchor the anchor type must be different,
+ /// because if not, layout breaks, but this situation also handled by
+ /// this function, and returns true in that case too.
+ static std::optional<bool> isAnchorTypeDifferent(SwFrameFormat* pShape);
+
+ /// Returns true if the given shape has a valid textframe.
+ static bool isTextBoxShapeHasValidTextFrame(SwFrameFormat* pShape);
+ /// Returns true if the given shape has a valid textframe.
+ static bool isTextBoxShapeHasValidTextFrame(css::uno::Reference<css::drawing::XShape> xShape);
+
/**
* If we have an associated TextFrame, then return that.
*
diff --git a/sw/qa/extras/ooxmlexport/data/tdf141550.docx b/sw/qa/extras/ooxmlexport/data/tdf141550.docx
new file mode 100644
index 000000000000..170ebebba689
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf141550.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 0b3f2321c4c6..d71c466258c3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -21,6 +21,8 @@
#include <com/sun/star/text/XTextTablesSupplier.hpp>
#include <comphelper/propertysequence.hxx>
#include <editeng/escapementitem.hxx>
+#include <textboxhelper.hxx>
+#include <unoprnms.hxx>
char const DATA_DIRECTORY[] = "/sw/qa/extras/ooxmlexport/data/";
@@ -180,6 +182,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133473_shadowSize, "tdf133473.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(200000), nSize1);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf141550, "tdf141550.docx")
+{
+ uno::Reference<drawing::XShape> xShape(getShape(1));
+ uno::Reference<text::XTextFrame> xFrame = SwTextBoxHelper::getUnoTextFrame(xShape);
+
+ CPPUNIT_ASSERT(xShape);
+ CPPUNIT_ASSERT(xFrame);
+
+ const sal_uInt16 nShapeRelOri = getProperty<sal_uInt16>(xShape, UNO_NAME_HORI_ORIENT_RELATION);
+ const sal_uInt16 nFrameRelOri = getProperty<sal_uInt16>(xFrame, UNO_NAME_HORI_ORIENT_RELATION);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox fallen apart!", nShapeRelOri, nFrameRelOri);
+ // Without the fix in place it fails with difference.
+}
+
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testCommentDone, "CommentDone.docx")
{
xmlDocUniquePtr pXmlComm = parseExport("word/comments.xml");
diff --git a/sw/qa/extras/uiwriter/data3/tdf140975.docx b/sw/qa/extras/uiwriter/data3/tdf140975.docx
new file mode 100644
index 000000000000..d11a912d34a6
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf140975.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index eedba24768a7..8ecfea76adbf 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -778,6 +778,36 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, TestAsCharTextBox)
// Without the fix in place the two texboxes has been fallen apart, and asserts will broken.
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf140975)
+{
+ // Load the bugdoc
+ load(DATA_DIRECTORY, "tdf140975.docx");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ // Set the Anchor of the shape to As_Char
+ dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {});
+ Scheduler::ProcessEventsToIdle();
+ dispatchCommand(mxComponent, ".uno:SetAnchorToChar", {});
+ Scheduler::ProcessEventsToIdle();
+
+ // Get the layout of the textbox
+ auto pExportDump = parseLayoutDump();
+ CPPUNIT_ASSERT(pExportDump);
+
+ const sal_Int32 nShpTop
+ = getXPath(pExportDump, "/root/page/body/txt[4]/anchored/SwAnchoredDrawObject/bounds",
+ "top")
+ .toInt32();
+ const sal_Int32 nFrmTop
+ = getXPath(pExportDump, "/root/page/body/txt[4]/anchored/fly/infos/bounds", "top")
+ .toInt32();
+
+ // Without the fix in place, the frame has less value for Top than
+ // the shape. This means the frame is outside from the shape.
+ CPPUNIT_ASSERT_GREATER(nShpTop, nFrmTop);
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf76636)
{
load(DATA_DIRECTORY, "tdf76636.doc");
diff --git a/sw/qa/uitest/data/tdf141557.docx b/sw/qa/uitest/data/tdf141557.docx
new file mode 100644
index 000000000000..9b0c6849bd44
--- /dev/null
+++ b/sw/qa/uitest/data/tdf141557.docx
Binary files differ
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 6b9f87655d8d..186db15c75c2 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -616,7 +616,10 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
aPropertyName = UNO_NAME_HORI_ORIENT;
break;
case MID_HORIORIENT_RELATION:
- aPropertyName = UNO_NAME_HORI_ORIENT_RELATION;
+ if (pShape->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
+ aPropertyName = UNO_NAME_HORI_ORIENT_RELATION;
+ else
+ return;
break;
case MID_HORIORIENT_POSITION:
aPropertyName = UNO_NAME_HORI_ORIENT_POSITION;
@@ -644,7 +647,10 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
aPropertyName = UNO_NAME_VERT_ORIENT;
break;
case MID_VERTORIENT_RELATION:
- aPropertyName = UNO_NAME_VERT_ORIENT_RELATION;
+ if (pShape->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
+ aPropertyName = UNO_NAME_VERT_ORIENT_RELATION;
+ else
+ return;
break;
case MID_VERTORIENT_POSITION:
aPropertyName = UNO_NAME_VERT_ORIENT_POSITION;
@@ -675,110 +681,10 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
{
case MID_ANCHOR_ANCHORTYPE:
{
- uno::Reference<beans::XPropertySet> const xPropertySet(
- SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat),
- uno::UNO_QUERY);
- // Surround (Wrap) has to be THROUGH always:
- xPropertySet->setPropertyValue(UNO_NAME_SURROUND,
- uno::makeAny(text::WrapTextMode_THROUGH));
- // Use At_Char anchor instead of As_Char anchoring:
- if (aValue.get<text::TextContentAnchorType>()
- == text::TextContentAnchorType::TextContentAnchorType_AS_CHARACTER)
- {
- if (const auto aPos = pShape->GetAnchor().GetContentAnchor())
- {
- xPropertySet->setPropertyValue(
- UNO_NAME_ANCHOR_TYPE,
- uno::makeAny(text::TextContentAnchorType::
- TextContentAnchorType_AT_CHARACTER));
- xPropertySet->setPropertyValue(
- UNO_NAME_HORI_ORIENT_RELATION,
- uno::makeAny(text::RelOrientation::CHAR));
-
- auto pAnch = pFormat->GetAnchor();
- pAnch.SetAnchor(pShape->GetAnchor().GetContentAnchor());
- tools::Rectangle aRect(getTextRectangle(pShape, false));
-
- SwFormatHoriOrient aNewHOri(pFormat->GetHoriOrient());
- aNewHOri.SetPos(aRect.getX());
-
- SwFormatVertOrient aNewVOri(pFormat->GetVertOrient());
- aNewVOri.SetPos(aRect.getY());
-
- pFormat->SetFormatAttr(pAnch);
- // tdf#140598: Do not apply wrong rectangle position.
- if (aRect.TopLeft() != Point(0, 0))
- {
- pFormat->SetFormatAttr(aNewHOri);
- pFormat->SetFormatAttr(aNewVOri);
- }
- else
- SAL_WARN("sw.core",
- "SwTextBoxHelper::syncProperty: Repositioning failed!");
- }
-
- return;
- }
- 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:
- if (aValue.get<text::TextContentAnchorType>()
- == text::TextContentAnchorType::TextContentAnchorType_AT_PAGE)
- {
- if (pShape->GetAnchor().GetPageNum())
- xPropertySet->setPropertyValue(
- UNO_NAME_ANCHOR_PAGE_NO,
- uno::makeAny(pShape->GetAnchor().GetPageNum()));
- else
- {
- SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: Invalid Page Num!");
- return;
- }
- }
+ setWrapThrough(pShape);
+ changeAnchor(pShape);
+ doTextBoxPositioning(pShape);
- // At-Content Anchors have to be synced:
- if (aValue.get<text::TextContentAnchorType>()
- == text::TextContentAnchorType::TextContentAnchorType_AT_PARAGRAPH
- || aValue.get<text::TextContentAnchorType>()
- == text::TextContentAnchorType::TextContentAnchorType_AT_CHARACTER)
- {
- // If the shape has content...
- if (auto aPos = pShape->GetAnchor().GetContentAnchor())
- {
- SwFormatAnchor aAnch(pFormat->GetAnchor());
- // ...set it for the textframe too.
- aAnch.SetAnchor(aPos);
- pFormat->SetFormatAttr(aAnch);
- }
- else
- SAL_WARN("sw.core",
- "SwTextBoxHelper::syncProperty: Anchor without content!");
- }
- // And the repositioning:
- if (pShape->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
- {
- tools::Rectangle aRect(getTextRectangle(pShape, false));
-
- // tdf#140598: Do not apply wrong rectangle position.
- if (aRect.TopLeft() != Point(0, 0))
- {
- SwFormatHoriOrient aNewHOri(pShape->GetHoriOrient());
- aNewHOri.SetPos(aNewHOri.GetPos() + aRect.getX());
- SwFormatVertOrient aNewVOri(pShape->GetVertOrient());
- aNewVOri.SetPos(aNewVOri.GetPos() + aRect.getY());
-
- pFormat->SetFormatAttr(aNewHOri);
- pFormat->SetFormatAttr(aNewVOri);
- }
- else
- SAL_WARN("sw.core",
- "SwTextBoxHelper::syncProperty: Repositioning failed!");
- }
return;
}
break;
@@ -1051,6 +957,16 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const&
pFormat->GetDoc()->SetFlyFrameAttr(*pFormat, aTextBoxSet);
}
+SwFrameFormat* SwTextBoxHelper::getShapeFormat(uno::Reference<drawing::XShape> xShape)
+{
+ if (xShape)
+ if (auto pShape = dynamic_cast<SwXShape*>(xShape.get()))
+ if (SwFrameFormat* pFormat = pShape->GetFrameFormat())
+ return pFormat;
+ SAL_WARN("sw.core", "SwTextBoxHelper::getShapeFormat: No Shape Format!");
+ return nullptr;
+}
+
void SwTextBoxHelper::updateTextBoxMargin(SdrObject* pObj)
{
if (!pObj)
@@ -1085,4 +1001,240 @@ void SwTextBoxHelper::updateTextBoxMargin(SdrObject* pObj)
// xPropertySet->getPropertyValue(UNO_NAME_TEXT_AUTOGROWHEIGHT));
}
+bool SwTextBoxHelper::setWrapThrough(SwFrameFormat* pShape)
+{
+ OUString sErrMsg;
+ if (isTextBoxShapeHasValidTextFrame(pShape))
+ {
+ if (auto pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT))
+ {
+ if (auto xFrame = SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat))
+ try
+ {
+ uno::Reference<beans::XPropertySet> const xPropertySet(xFrame, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue(UNO_NAME_SURROUND,
+ uno::makeAny(text::WrapTextMode_THROUGH));
+ return true;
+ }
+ catch (uno::Exception& e)
+ {
+ sErrMsg = "Exception caught: " + e.Message;
+ }
+ else
+ sErrMsg = "No XTextFrame!";
+ }
+ else
+ sErrMsg = "No Other TextBox Format!";
+ }
+ else
+ sErrMsg = "Not a Valid TextBox object!";
+
+ SAL_WARN("sw.core", "SwTextBoxHelper::setWrapThrough: " << sErrMsg);
+ return false;
+}
+
+bool SwTextBoxHelper::setWrapThrough(uno::Reference<drawing::XShape> xShape)
+{
+ if (auto pShape = getShapeFormat(xShape))
+ return setWrapThrough(pShape);
+ return false;
+}
+
+bool SwTextBoxHelper::changeAnchor(SwFrameFormat* pShape)
+{
+ if (isTextBoxShapeHasValidTextFrame(pShape))
+ {
+ if (auto pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT))
+ {
+ const SwFormatAnchor& rOldAnch = pFormat->GetAnchor();
+ const SwFormatAnchor& rNewAnch = pShape->GetAnchor();
+
+ const auto pOldCnt = rOldAnch.GetContentAnchor();
+ const auto pNewCnt = rNewAnch.GetContentAnchor();
+
+ const uno::Any aShapeHorRelOrient
+ = uno::makeAny(pShape->GetHoriOrient().GetRelationOrient());
+
+ if (isAnchorTypeDifferent(pShape))
+ {
+ try
+ {
+ uno::Reference<beans::XPropertySet> const xPropertySet(
+ SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat),
+ uno::UNO_QUERY);
+ if (pOldCnt && rNewAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE
+ && rNewAnch.GetPageNum())
+ {
+ uno::Any aValue(text::TextContentAnchorType_AT_PAGE);
+ xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION,
+ aShapeHorRelOrient);
+ xPropertySet->setPropertyValue(UNO_NAME_ANCHOR_TYPE, aValue);
+ xPropertySet->setPropertyValue(UNO_NAME_ANCHOR_PAGE_NO,
+ uno::Any(rNewAnch.GetPageNum()));
+ }
+ else if (rOldAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE && pNewCnt)
+ {
+ if (rNewAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR)
+ {
+ uno::Any aValue(text::TextContentAnchorType_AT_CHARACTER);
+ xPropertySet->setPropertyValue(UNO_NAME_ANCHOR_TYPE, aValue);
+ xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION,
+ uno::Any(text::RelOrientation::CHAR));
+ xPropertySet->setPropertyValue(
+ UNO_NAME_VERT_ORIENT_RELATION,
+ uno::Any(text::RelOrientation::PRINT_AREA));
+ SwFormatAnchor aPos(pFormat->GetAnchor());
+ aPos.SetAnchor(pNewCnt);
+ pFormat->SetFormatAttr(aPos);
+ }
+ else
+ {
+ uno::Any aValue(mapAnchorType(rNewAnch.GetAnchorId()));
+ xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION,
+ aShapeHorRelOrient);
+ xPropertySet->setPropertyValue(UNO_NAME_ANCHOR_TYPE, aValue);
+ pFormat->SetFormatAttr(rNewAnch);
+ }
+ }
+ else
+ {
+ if (rNewAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR)
+ {
+ uno::Any aValue(text::TextContentAnchorType_AT_CHARACTER);
+ xPropertySet->setPropertyValue(UNO_NAME_ANCHOR_TYPE, aValue);
+ xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION,
+ uno::Any(text::RelOrientation::CHAR));
+ xPropertySet->setPropertyValue(
+ UNO_NAME_VERT_ORIENT_RELATION,
+ uno::Any(text::RelOrientation::PRINT_AREA));
+ SwFormatAnchor aPos(pFormat->GetAnchor());
+ aPos.SetAnchor(pNewCnt);
+ pFormat->SetFormatAttr(aPos);
+ }
+ else
+ {
+ xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION,
+ aShapeHorRelOrient);
+ pFormat->SetFormatAttr(pShape->GetAnchor());
+ }
+ }
+ }
+ catch (uno::Exception& e)
+ {
+ SAL_WARN("sw.core", "SwTextBoxHelper::changeAnchor(): " << e.Message);
+ }
+ }
+
+ return doTextBoxPositioning(pShape);
+ }
+ }
+ return false;
+}
+
+bool SwTextBoxHelper::changeAnchor(uno::Reference<drawing::XShape> xShape)
+{
+ if (auto pShape = getShapeFormat(xShape))
+ return changeAnchor(pShape);
+ return false;
+}
+
+bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape)
+{
+ if (isTextBoxShapeHasValidTextFrame(pShape))
+ {
+ if (auto pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT))
+ {
+ if (pShape->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR)
+ {
+ tools::Rectangle aRect(getTextRectangle(pShape, false));
+
+ SwFormatHoriOrient aNewHOri(pFormat->GetHoriOrient());
+ aNewHOri.SetPos(aRect.getX());
+
+ SwFormatVertOrient aNewVOri(pFormat->GetVertOrient());
+ aNewVOri.SetPos(aRect.getY() + pShape->GetVertOrient().GetPos());
+
+ // tdf#140598: Do not apply wrong rectangle position.
+ if (aRect.TopLeft() != Point(0, 0))
+ {
+ pFormat->SetFormatAttr(aNewHOri);
+ pFormat->SetFormatAttr(aNewVOri);
+ }
+ else
+ SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: Repositioning failed!");
+ }
+ else
+ {
+ tools::Rectangle aRect(getTextRectangle(pShape, false));
+
+ // tdf#140598: Do not apply wrong rectangle position.
+ if (aRect.TopLeft() != Point(0, 0))
+ {
+ SwFormatHoriOrient aNewHOri(pShape->GetHoriOrient());
+ aNewHOri.SetPos(aNewHOri.GetPos() + aRect.getX());
+ SwFormatVertOrient aNewVOri(pShape->GetVertOrient());
+ aNewVOri.SetPos(aNewVOri.GetPos() + aRect.getY());
+
+ pFormat->SetFormatAttr(aNewHOri);
+ pFormat->SetFormatAttr(aNewVOri);
+ }
+ else
+ SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: Repositioning failed!");
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+bool SwTextBoxHelper::doTextBoxPositioning(uno::Reference<drawing::XShape> xShape)
+{
+ if (auto pShape = getShapeFormat(xShape))
+ return doTextBoxPositioning(pShape);
+ return false;
+}
+
+std::optional<bool> SwTextBoxHelper::isAnchorTypeDifferent(SwFrameFormat* pShape)
+{
+ std::optional<bool> bRet;
+ if (isTextBoxShapeHasValidTextFrame(pShape))
+ {
+ if (auto pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT))
+ {
+ if (pShape->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR)
+ bRet = (pFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AT_CHAR
+ && pFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR);
+ else
+ bRet = pFormat->GetAnchor().GetAnchorId() != pShape->GetAnchor().GetAnchorId();
+ }
+ }
+ return bRet;
+}
+
+bool SwTextBoxHelper::isTextBoxShapeHasValidTextFrame(SwFrameFormat* pShape)
+{
+ OUString sErrMsg;
+ if (pShape && pShape->Which() == RES_DRAWFRMFMT)
+ if (auto pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT))
+ if (pFormat && pFormat->Which() == RES_FLYFRMFMT)
+ return true;
+ else
+ sErrMsg = "Shape do not have valid textframe!";
+ else
+ sErrMsg = "Shape do not have associated frame!";
+ else
+ sErrMsg = "Not valid shape!";
+
+ SAL_WARN("sw.core", "SwTextBoxHelper::isTextBoxShapeHasValidTextFrame: " << sErrMsg);
+ return false;
+}
+
+bool SwTextBoxHelper::isTextBoxShapeHasValidTextFrame(uno::Reference<drawing::XShape> xShape)
+{
+ if (auto pShape = getShapeFormat(xShape))
+ return isTextBoxShapeHasValidTextFrame(pShape);
+
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 9426359156f1..96bdebd58adc 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -363,6 +363,7 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase,
if (!aPos->nNode.GetNode().FindFooterStartNode())
{
aVert.SetVertOrient(css::text::VertOrientation::NONE);
+ aVert.SetRelationOrient(css::text::RelOrientation::FRAME);
sal_Int32 const nTop = aTextRectangle.getY() - rFrame.getFrameArea().Top()
- rFrame.getFramePrintArea().Top();
aVert.SetPos(nTop);