sw/inc/textboxhelper.hxx                     |    3 ++
 sw/source/core/doc/textboxhelper.cxx         |   26 ++++++++++++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   29 +--------------------------
 sw/source/filter/ww8/docxattributeoutput.hxx |    1 
 4 files changed, 31 insertions(+), 28 deletions(-)

New commits:
commit 309aded3145f8ecec9e9af61a3c64804258f8336
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Thu Aug 29 17:44:20 2024 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Sep 4 14:32:46 2024 +0200

    NFC prep for tdf#143899: move TextBoxIsFramePr into SwTextBoxHelper
    
    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 <jl...@mail.com>

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 4afd6fa9960c..a43777c2e519 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -187,6 +187,9 @@ public:
 
     // Compares the anchor of the first and second given formats, and decides 
whether sync needed.
     static bool isAnchorSyncNeeded(const SwFrameFormat* pFirst, const 
SwFrameFormat* pSecond);
+
+    /// Was the textbox created from a Microsoft import by a paragraph frame 
property (framePr)
+    static bool TextBoxIsFramePr(const SwFrameFormat& rFrameFormat);
 };
 
 /// Textboxes are basically textframe + shape pairs. This means one shape has 
one frame.
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 8e10623b445d..ebb380ae6d39 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -1723,6 +1723,32 @@ bool SwTextBoxHelper::isAnchorSyncNeeded(const 
SwFrameFormat* pFirst, const SwFr
     return false;
 }
 
+bool SwTextBoxHelper::TextBoxIsFramePr(const SwFrameFormat& rFrameFormat)
+{
+    SdrObject* pSdrObj = 
const_cast<SdrObject*>(rFrameFormat.FindRealSdrObject());
+    if (!pSdrObj)
+        return false;
+
+    uno::Reference<beans::XPropertySet> xPropertySet(pSdrObj->getUnoShape(), 
uno::UNO_QUERY);
+    if (!xPropertySet.is())
+        return false;
+
+    uno::Reference<beans::XPropertySetInfo> 
xPropSetInfo(xPropertySet->getPropertySetInfo());
+    if (!xPropSetInfo.is() || 
!xPropSetInfo->hasPropertyByName(u"FrameInteropGrabBag"_ustr))
+        return false;
+
+    bool bRet = false;
+    uno::Sequence<beans::PropertyValue> propList;
+    xPropertySet->getPropertyValue(u"FrameInteropGrabBag"_ustr) >>= propList;
+    auto pProp = std::find_if(
+        std::cbegin(propList), std::cend(propList),
+        [](const beans::PropertyValue& rProp) { return rProp.Name == 
"ParaFrameProperties"; });
+    if (pProp != std::cend(propList))
+        pProp->Value >>= bRet;
+
+    return bRet;
+}
+
 SwTextBoxNode::SwTextBoxNode(SwFrameFormat* pOwnerShape)
 {
     assert(pOwnerShape);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 2a684a266f84..e3b2d9869b4e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1100,31 +1100,6 @@ void DocxAttributeOutput::PopulateFrameProperties(const 
SwFrameFormat* pFrameFor
     m_pSerializer->singleElementNS( XML_w, XML_framePr, attrList );
 }
 
-bool DocxAttributeOutput::TextBoxIsFramePr(const SwFrameFormat& rFrameFormat)
-{
-    SdrObject* pSdrObj = 
const_cast<SdrObject*>(rFrameFormat.FindRealSdrObject());
-    if (!pSdrObj)
-        return false;
-
-    uno::Reference<beans::XPropertySet> xPropertySet(pSdrObj->getUnoShape(), 
uno::UNO_QUERY);
-    if (!xPropertySet.is())
-        return false;
-
-    uno::Reference<beans::XPropertySetInfo> 
xPropSetInfo(xPropertySet->getPropertySetInfo());
-    if (!xPropSetInfo.is() || 
!xPropSetInfo->hasPropertyByName(u"FrameInteropGrabBag"_ustr))
-        return false;
-
-    bool bRet = false;
-    uno::Sequence<beans::PropertyValue> propList;
-    xPropertySet->getPropertyValue(u"FrameInteropGrabBag"_ustr) >>= propList;
-    auto pProp = std::find_if(std::cbegin(propList), std::cend(propList),
-        [](const beans::PropertyValue& rProp) { return rProp.Name == 
"ParaFrameProperties"; });
-    if (pProp != std::cend(propList))
-        pProp->Value >>= bRet;
-
-    return bRet;
-}
-
 void DocxAttributeOutput::EndParagraph( const 
ww8::WW8TableNodeInfoInner::Pointer_t& pTextNodeInfoInner )
 {
     // write the paragraph properties + the run, already in the correct order
@@ -1148,7 +1123,7 @@ void DocxAttributeOutput::EndParagraph( const 
ww8::WW8TableNodeInfoInner::Pointe
             ww8::Frame aFrame = m_aFramesOfParagraph.top()[nIndex];
             const SwFrameFormat& rFrameFormat = aFrame.GetFrameFormat();
 
-            if (!m_bWritingHeaderFooter && TextBoxIsFramePr(rFrameFormat))
+            if (!m_bWritingHeaderFooter && 
SwTextBoxHelper::TextBoxIsFramePr(rFrameFormat))
             {
                 std::shared_ptr<ww8::Frame> pFramePr = 
std::make_shared<ww8::Frame>(aFrame);
                 aFramePrTextbox.push_back(pFramePr);
@@ -1666,7 +1641,7 @@ void DocxAttributeOutput::EndParagraphProperties(const 
SfxItemSet& rParagraphMar
     if (!m_bWritingHeaderFooter && m_aFramePr.Frame())
     {
         const SwFrameFormat& rFrameFormat = 
m_aFramePr.Frame()->GetFrameFormat();
-        assert(TextBoxIsFramePr(rFrameFormat) && "by definition, because 
Frame()");
+        assert(SwTextBoxHelper::TextBoxIsFramePr(rFrameFormat) && "by 
definition, because Frame()");
 
         const Size aSize = m_aFramePr.Frame()->GetSize();
         PopulateFrameProperties(&rFrameFormat, aSize);
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 8fc216f973b5..1dd29a81dbe8 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -505,7 +505,6 @@ private:
     void EndTable();
     void SyncNodelessCells(ww8::WW8TableNodeInfoInner::Pointer_t const & 
pInner, sal_Int32 nCell, sal_uInt32 nRow);
     void PopulateFrameProperties(const SwFrameFormat* pFrameFormat, const 
Size& rSize);
-    static bool TextBoxIsFramePr(const SwFrameFormat& rFrameFormat);
     /// End cell, row, and even the entire table if necessary.
     void FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t const & 
pInner, bool bForceEmptyParagraph = false );
 

Reply via email to