diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2016-07-22 17:23:40 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2016-08-29 13:13:14 +0200 |
commit | 5bed080c77f99f22fd52ad6cf2d6274e7c1e12a8 (patch) | |
tree | 47db3e1951143cfa5357522aafa18c22acec6865 | |
parent | efb68beb538b97148c3dbf54ce46c3a8bc49cd92 (diff) |
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.
Change-Id: Iefba2d153d9d8b3f1185aa305e9f463a50e78f89
-rw-r--r-- | sw/inc/frmfmt.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentLayoutManager.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 27 |
4 files changed, 48 insertions, 2 deletions
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index 35f84107d57e..88c77f5b09a9 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -43,6 +43,7 @@ class SW_DLLPUBLIC SwFrameFormat: public SwFormat friend class SwPageDesc; ///< Is allowed to call protected CTor. friend class ::sw::DocumentLayoutManager; ///< Is allowed to call protected CTor. friend class SwFrameFormats; ///< Is allowed to update the list backref. + friend class SwTextBoxHelper; css::uno::WeakReference<css::uno::XInterface> m_wXObject; @@ -52,6 +53,8 @@ class SW_DLLPUBLIC SwFrameFormat: public SwFormat // The assigned SwFrmFmt list. SwFrameFormats *m_ffList; + SwFrameFormat *m_pOtherTextBoxFormat; + struct change_name { change_name(const OUString &rName) : mName(rName) {} @@ -76,6 +79,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 0296a18a5364..ce18cd058aeb 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 54dd491bd5f3..42a876fc384e 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2500,7 +2500,8 @@ SwFrameFormat::SwFrameFormat( : SwFormat(rPool, pFormatNm, (pWhichRange ? pWhichRange : aFrameFormatSetRange), pDrvdFrame, nFormatWhich), m_wXObject(), maFillAttributes(), - m_ffList(nullptr) + m_ffList(nullptr), + m_pOtherTextBoxFormat(nullptr) { } @@ -2513,7 +2514,8 @@ SwFrameFormat::SwFrameFormat( : SwFormat(rPool, rFormatNm, (pWhichRange ? pWhichRange : aFrameFormatSetRange), pDrvdFrame, nFormatWhich), m_wXObject(), maFillAttributes(), - m_ffList(nullptr) + m_ffList(nullptr), + m_pOtherTextBoxFormat(nullptr) { } @@ -2527,6 +2529,12 @@ SwFrameFormat::~SwFrameFormat() rAnchor.GetContentAnchor()->nNode.GetNode().RemoveAnchoredFly(this); } } + + if( nullptr != m_pOtherTextBoxFormat ) + { + m_pOtherTextBoxFormat->SetOtherTextBoxFormat( nullptr ); + m_pOtherTextBoxFormat = nullptr; + } } void SwFrameFormat::SetName( const OUString& rNewName, bool bBroadcast ) @@ -2553,6 +2561,21 @@ void SwFrameFormat::SetName( const OUString& rNewName, bool bBroadcast ) SwFormat::SetName( rNewName, bBroadcast ); } +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 { return true; |