sw/inc/frmfmt.hxx | 6 ++++++ sw/source/core/doc/DocumentLayoutManager.cxx | 4 ++++ sw/source/core/doc/textboxhelper.cxx | 13 +++++++++++++ sw/source/core/layout/atrfrm.cxx | 27 +++++++++++++++++++++++++-- 4 files changed, 48 insertions(+), 2 deletions(-)
New commits: commit 75bd6c311f518853fc31affe04fff717d741d575 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Fri Jul 22 17:23:40 2016 +0200 Link DRAW and FLY format for faster textbox lookup Currently we have to rebuild the list of text boxes for every lookup. Instead of a managed set, or a per-document list etc., this introduces direct pointers between the corresponding SwDrawFramFormat and SwFlyFrameFormat of a text box. (Manually cherry picked from commit 5bed080c77f99f22fd52ad6cf2d6274e7c1e12a8) Change-Id: Iefba2d153d9d8b3f1185aa305e9f463a50e78f89 Reviewed-on: https://gerrit.libreoffice.org/46305 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index 4291ced05f6e..c2a19706160c 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -41,12 +41,15 @@ class SW_DLLPUBLIC SwFrameFormat: public SwFormat friend class SwDoc; friend class SwPageDesc; ///< Is allowed to call protected CTor. friend class ::sw::DocumentLayoutManager; ///< Is allowed to call protected CTor. + friend class SwTextBoxHelper; css::uno::WeakReference<css::uno::XInterface> m_wXObject; //UUUU DrawingLayer FillAttributes in a preprocessed form for primitive usage drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes; + SwFrameFormat *m_pOtherTextBoxFormat; + protected: SwFrameFormat( SwAttrPool& rPool, @@ -64,6 +67,9 @@ protected: virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) override; + SwFrameFormat* GetOtherTextBoxFormat() const { return m_pOtherTextBoxFormat; } + void SetOtherTextBoxFormat( SwFrameFormat *pFormat ); + public: virtual ~SwFrameFormat(); diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index c5380df0b3de..5fc0d4cc7483 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -510,6 +510,10 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat( SwFormatContent aContent(pDestTextBox->GetContent().GetContentIdx()->GetNode().GetStartNode()); aSet.Put(aContent); pDest->SetFormatAttr(aSet); + + // Link FLY and DRAW formats, so it becomes a text box + pDest->SetOtherTextBoxFormat(pDestTextBox); + pDestTextBox->SetOtherTextBoxFormat(pDest); } return pDest; diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 61402fe02c94..c75908384ebf 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -28,6 +28,7 @@ #include <sortedobjs.hxx> #include <cntfrm.hxx> #include <fmtsrnd.hxx> +#include <frmfmt.hxx> #include <editeng/unoprnms.hxx> #include <editeng/charrotateitem.hxx> @@ -55,6 +56,18 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape) uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(), uno::UNO_QUERY); xTextContentAppend->appendTextContent(xTextFrame, uno::Sequence<beans::PropertyValue>()); + // Link FLY and DRAW formats, so it becomes a text box (needed for syncProperty calls). + uno::Reference<text::XTextFrame> xRealTextFrame(xTextFrame, uno::UNO_QUERY); + SwXTextFrame* pTextFrame = dynamic_cast<SwXTextFrame *>(xRealTextFrame.get()); + assert(nullptr != pTextFrame); + SwFrameFormat* pFormat = pTextFrame->GetFrameFormat(); + + assert(nullptr != dynamic_cast<SwDrawFrameFormat*>(pShape)); + assert(nullptr != dynamic_cast<SwFlyFrameFormat*>(pFormat)); + + pShape->SetOtherTextBoxFormat(pFormat); + pFormat->SetOtherTextBoxFormat(pShape); + // Initialize properties. uno::Reference<beans::XPropertySet> xPropertySet(xTextFrame, uno::UNO_QUERY); uno::Any aEmptyBorder = uno::makeAny(table::BorderLine2()); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 849af3b88ed0..4a67225681e4 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2502,7 +2502,8 @@ SwFrameFormat::SwFrameFormat( const sal_uInt16* pWhichRange) : SwFormat(rPool, pFormatNm, (pWhichRange ? pWhichRange : aFrameFormatSetRange), pDrvdFrame, nFormatWhich), m_wXObject(), - maFillAttributes() + maFillAttributes(), + m_pOtherTextBoxFormat(nullptr) { } @@ -2514,7 +2515,8 @@ SwFrameFormat::SwFrameFormat( const sal_uInt16* pWhichRange) : SwFormat(rPool, rFormatNm, (pWhichRange ? pWhichRange : aFrameFormatSetRange), pDrvdFrame, nFormatWhich), m_wXObject(), - maFillAttributes() + maFillAttributes(), + m_pOtherTextBoxFormat(nullptr) { } @@ -2528,6 +2530,27 @@ SwFrameFormat::~SwFrameFormat() rAnchor.GetContentAnchor()->nNode.GetNode().RemoveAnchoredFly(this); } } + + if( nullptr != m_pOtherTextBoxFormat ) + { + m_pOtherTextBoxFormat->SetOtherTextBoxFormat( nullptr ); + m_pOtherTextBoxFormat = nullptr; + } +} + +void SwFrameFormat::SetOtherTextBoxFormat( SwFrameFormat *pFormat ) +{ + if( nullptr != pFormat ) + { + assert( (Which() == RES_DRAWFRMFMT && pFormat->Which() == RES_FLYFRMFMT) + || (Which() == RES_FLYFRMFMT && pFormat->Which() == RES_DRAWFRMFMT) ); + assert( nullptr == m_pOtherTextBoxFormat ); + } + else + { + assert( nullptr != m_pOtherTextBoxFormat ); + } + m_pOtherTextBoxFormat = pFormat; } bool SwFrameFormat::supportsFullDrawingLayerFillAttributeSet() const _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits