Kaydet (Commit) 5bed080c authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

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
üst efb68beb
......@@ -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();
......
......@@ -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;
......
......@@ -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());
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment