[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - sw/inc sw/source
Michael Stahl
mstahl at redhat.com
Thu Jul 2 08:52:11 PDT 2015
sw/inc/unobaseclass.hxx | 4 ++
sw/source/core/unocore/unochart.cxx | 4 +-
sw/source/core/unocore/unoobj2.cxx | 40 ++++++++++++++++++++----
sw/source/core/unocore/unosect.cxx | 2 +
sw/source/core/unocore/unotbl.cxx | 59 ++++++++++++++++++------------------
sw/source/uibase/uno/unotxvw.cxx | 2 -
6 files changed, 73 insertions(+), 38 deletions(-)
New commits:
commit d97f2ae363f26a6bfaa6da854d2c6721043114f8
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Jun 30 13:09:32 2015 +0200
sw: avoid layout recursion when loading documents with charts...
... that have a Writer table as data source, such as ooo38798-1.sxw.
The problem is that during layouting, the SwWrtShell::CalcAndSetScale()
wants to call setVisualAreaSize() on the embedded chart object.
This switches the state of the object to RUNNING, which loads it from
the file, and during that the ODF filter calls into SwChartDataProvider
and that uses a UnoActionRemoveContext; unfortunately that ends all
pending Actions, so we get a recursive layout action.
Apparently the UnoActionRemoveContext is required to call
SwUnoTableCrsr::MakeBoxSels() for old-style tables, which need layout
frames for selection?!?
Try to avoid the problem by disabling UnoActionRemoveContext in case a
new-style table will be selected, which can be done without layout.
(cherry picked from commit b6cefd5e8b5086619e591385a0d7a6ffcd9783b9)
Conflicts:
sw/source/core/unocore/unochart.cxx
sw/source/core/unocore/unotbl.cxx
Change-Id: I097991ffb2e78ddf011db7575f7bb63ae8aa7005
Reviewed-on: https://gerrit.libreoffice.org/16617
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx
index a4f8abd..0b12f25 100644
--- a/sw/inc/unobaseclass.hxx
+++ b/sw/inc/unobaseclass.hxx
@@ -29,6 +29,7 @@
class SfxPoolItem;
class SwClient;
class SwDoc;
+class SwUnoTableCrsr;
typedef ::cppu::WeakImplHelper
< ::com::sun::star::lang::XServiceInfo
@@ -70,6 +71,8 @@ class UnoActionContext
/*
interrupt Actions for a little while
+ FIXME: this is a vile abomination that may cause recursive layout actions!
+ C'thulhu fhtagn.
*/
class UnoActionRemoveContext
{
@@ -78,6 +81,7 @@ class UnoActionRemoveContext
public:
UnoActionRemoveContext(SwDoc *const pDoc);
+ UnoActionRemoveContext(SwUnoTableCrsr const& rCursor);
~UnoActionRemoveContext();
};
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 82e1d3c..e1d979b 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -407,8 +407,6 @@ static void GetFormatAndCreateCursorFromRangeRep(
pTable ? pTable->GetTableBox( aStartCell, true ) : 0;
if(pTLBox)
{
- // The Actions need to be removed here
- UnoActionRemoveContext aRemoveContext(pTableFormat->GetDoc());
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
@@ -427,6 +425,8 @@ static void GetFormatAndCreateCursorFromRangeRep(
pUnoCrsr->Move( fnMoveForward, fnGoNode );
SwUnoTableCrsr* pCrsr =
dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ // HACK: remove pending actions for old style tables
+ UnoActionRemoveContext aRemoveContext(*pCrsr);
pCrsr->MakeBoxSels();
if (ppUnoCrsr)
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 82d79d0..1ba755f 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -265,22 +265,50 @@ UnoActionContext::~UnoActionContext()
}
}
-UnoActionRemoveContext::UnoActionRemoveContext(SwDoc *const pDoc)
- : m_pDoc(pDoc)
+static void lcl_RemoveImpl(SwDoc *const pDoc)
{
- SwRootFrm *const pRootFrm = m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ assert(pDoc);
+ SwRootFrm *const pRootFrm = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
if (pRootFrm)
{
pRootFrm->UnoRemoveAllActions();
}
}
+UnoActionRemoveContext::UnoActionRemoveContext(SwDoc *const pDoc)
+ : m_pDoc(pDoc)
+{
+ lcl_RemoveImpl(m_pDoc);
+}
+
+static SwDoc * lcl_IsNewStyleTable(SwUnoTableCrsr const& rCursor)
+{
+ SwTableNode *const pTableNode = rCursor.GetNode().FindTableNode();
+ return (pTableNode && !pTableNode->GetTable().IsNewModel())
+ ? rCursor.GetDoc()
+ : nullptr;
+}
+
+UnoActionRemoveContext::UnoActionRemoveContext(SwUnoTableCrsr const& rCursor)
+ : m_pDoc(lcl_IsNewStyleTable(rCursor))
+{
+ // this insanity is only necessary for old-style tables
+ // because SwRootFrm::MakeTableCrsrs() creates the table cursor for these
+ if (m_pDoc)
+ {
+ lcl_RemoveImpl(m_pDoc);
+ }
+}
+
UnoActionRemoveContext::~UnoActionRemoveContext()
{
- SwRootFrm *const pRootFrm = m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
- if (pRootFrm)
+ if (m_pDoc)
{
- pRootFrm->UnoRestoreAllActions();
+ SwRootFrm *const pRootFrm = m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ if (pRootFrm)
+ {
+ pRootFrm->UnoRestoreAllActions();
+ }
}
}
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx
index 72c22f6..78dcf44 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -531,6 +531,7 @@ lcl_UpdateSection(SwSectionFormat *const pFormat,
pDoc->IsInReading());
{
// temporarily remove actions to allow cursor update
+ // TODO: why? no table cursor here!
UnoActionRemoveContext aRemoveContext( pDoc );
}
@@ -1702,6 +1703,7 @@ throw (uno::RuntimeException, std::exception)
}
{
// temporarily remove actions to allow cursor update
+ // TODO: why? no table cursor here!
UnoActionRemoveContext aRemoveContext( pFormat->GetDoc() );
}
}
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 622d40b..3437d84 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1566,11 +1566,12 @@ sal_Bool SwXTextTableCursor::mergeRange()
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(!pUnoCrsr)
return false;
+
+ SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
{
- // The Actions need to be revoked here
- UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
+ // HACK: remove pending actions for selecting old style tables
+ UnoActionRemoveContext aRemoveContext(rTableCrsr);
}
- SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
rTableCrsr.MakeBoxSels();
bool bResult;
{
@@ -1596,11 +1597,11 @@ sal_Bool SwXTextTableCursor::splitRange(sal_Int16 Count, sal_Bool Horizontal)
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(!pUnoCrsr)
return false;
+ SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
{
- // here, all actions need to be revoked
- UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
+ // HACK: remove pending actions for selecting old style tables
+ UnoActionRemoveContext aRemoveContext(rTableCrsr);
}
- SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
rTableCrsr.MakeBoxSels();
bool bResult;
{
@@ -2197,8 +2198,6 @@ uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrameFormat* p
const SwTableBox* pTLBox = pTable->GetTableBox(rTLName);
if(!pTLBox)
return nullptr;
- // invalidate all actions
- UnoActionRemoveContext aRemoveContext(pFormat->GetDoc());
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
@@ -2215,6 +2214,8 @@ uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrameFormat* p
pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
pUnoCrsr->Move( fnMoveForward, fnGoNode );
SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ // HACK: remove pending actions for selecting old style tables
+ UnoActionRemoveContext aRemoveContext(*pCrsr);
pCrsr->MakeBoxSels();
// pUnoCrsr will be provided and will not be deleted
return new SwXCellRange(pUnoCrsr, *pFormat, rDesc);
@@ -2576,8 +2577,6 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
SwTable* pTable = SwTable::FindTable( pFormat );
SwTableLines &rLines = pTable->GetTabLines();
- // invalidate all actions
- UnoActionRemoveContext aRemoveContext(pDoc);
const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
@@ -2591,6 +2590,8 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
pUnoCrsr->Move( fnMoveForward, fnGoNode );
SwUnoTableCrsr& rCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
+ // HACK: remove pending actions for selecting old style tables
+ UnoActionRemoveContext aRemoveContext(rCrsr);
rCrsr.MakeBoxSels();
SfxItemSet aSet(pDoc->GetAttrPool(),
@@ -2766,8 +2767,6 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
SwTable* pTable = SwTable::FindTable( pFormat );
SwTableLines &rLines = pTable->GetTabLines();
- // invalidate all actions
- UnoActionRemoveContext aRemoveContext(pDoc);
const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
@@ -2783,6 +2782,8 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
pUnoCrsr->Move( fnMoveForward, fnGoNode );
SwUnoTableCrsr& rCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
+ // HACK: remove pending actions for selecting old style tables
+ UnoActionRemoveContext aRemoveContext(rCrsr);
rCrsr.MakeBoxSels();
SfxItemSet aSet(pDoc->GetAttrPool(),
@@ -3225,8 +3226,6 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
if(pTLBox)
{
- // invalidate all actions
- UnoActionRemoveContext aRemoveContext(pFormat->GetDoc());
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor in the upper-left cell of the range
@@ -3240,6 +3239,8 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
pUnoCrsr->Move( fnMoveForward, fnGoNode );
SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ // HACK: remove pending actions for selecting old style tables
+ UnoActionRemoveContext aRemoveContext(*pCrsr);
pCrsr->MakeBoxSels();
// pUnoCrsr will be provided and will not be deleted
SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFormat, aNewDesc);
@@ -3299,11 +3300,11 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
SwDoc* pDoc = pTableCrsr->GetDoc();
+ SwUnoTableCrsr& rCrsr = dynamic_cast<SwUnoTableCrsr&>(*pTableCrsr);
{
- // remove actions to enable box selection
- UnoActionRemoveContext aRemoveContext(pDoc);
+ // HACK: remove pending actions for selecting old style tables
+ UnoActionRemoveContext aRemoveContext(rCrsr);
}
- SwUnoTableCrsr& rCrsr = dynamic_cast<SwUnoTableCrsr&>(*pTableCrsr);
rCrsr.MakeBoxSels();
switch(pEntry->nWID )
{
@@ -3999,7 +4000,7 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwUnoCrsr* pUnoCrsr = pFrameFormat->GetDoc()->CreateUnoCrsr(aPos, true);
pUnoCrsr->Move( fnMoveForward, fnGoNode );
{
- // remove actions
+ // remove actions - TODO: why?
UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
}
pFrameFormat->GetDoc()->InsertRow(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
@@ -4020,10 +4021,6 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
const SwTableBox* pTLBox = pTable->GetTableBox(sTLName);
if(!pTLBox)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
- {
- // invalidate all actions
- UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
- }
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
@@ -4038,6 +4035,10 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd();
pUnoCrsr->Move(fnMoveForward, fnGoNode);
SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ {
+ // HACK: remove pending actions for selecting old style tables
+ UnoActionRemoveContext aRemoveContext(*pCrsr);
+ }
pCrsr->MakeBoxSels();
{ // these braces are important
UnoActionContext aAction(pFrameFormat->GetDoc());
@@ -4045,7 +4046,7 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
delete pUnoCrsr;
}
{
- // invalidate all actions
+ // invalidate all actions - TODO: why?
UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
}
}
@@ -4139,7 +4140,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
pUnoCrsr->Move(fnMoveForward, fnGoNode);
{
- // remove actions
+ // remove actions - TODO: why?
UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
}
@@ -4162,10 +4163,6 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
if(!pTLBox)
throw uno::RuntimeException("Cell not found", static_cast<cppu::OWeakObject*>(this));
- {
- // invalidate all actions
- UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
- }
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
@@ -4180,6 +4177,10 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
pUnoCrsr->GetPoint()->nNode = *pTRBox->GetSttNd();
pUnoCrsr->Move(fnMoveForward, fnGoNode);
SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ {
+ // HACK: remove pending actions for selecting old style tables
+ UnoActionRemoveContext aRemoveContext(*pCrsr);
+ }
pCrsr->MakeBoxSels();
{ // these braces are important
UnoActionContext aAction(pFrameFormat->GetDoc());
@@ -4187,7 +4188,7 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
delete pUnoCrsr;
}
{
- // invalidate all actions
+ // invalidate all actions - TODO: why?
UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
}
}
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index b81fd2e..d434967 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -283,7 +283,7 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface)
}
else if (pTableCursor)
{
- UnoActionRemoveContext const aContext(pDoc);
+ UnoActionRemoveContext const aContext(*pTableCursor);
rSh.EnterStdMode();
rSh.SetSelection(*pTableCursor);
return sal_True;
More information about the Libreoffice-commits
mailing list