diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-01-09 15:45:32 +0100 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-01-10 09:28:50 +0000 |
commit | b58dc1b9aee370a1a2aa9d8f951cede3ae24d61d (patch) | |
tree | c1990e721d8002665b3f29a20b236fa60a2ae39b | |
parent | 35ddd4eecf3db609368428470dff74188e59b037 (diff) |
fdo#58242: sw: fix more crashes when not on SwTxtNode
In getCrsrPropertyValue etc.; also add a unit test for the problem.
(cherry picked from commit 68d40d2cae3700f4134375fcaf9649ac626ada7d)
Conflicts:
sw/qa/complex/writer/CheckTable.java
Change-Id: Ibd459a43393c39b4fed9fb89aae4a5f7bacff007
Reviewed-on: https://gerrit.libreoffice.org/1615
Reviewed-by: Noel Power <noel.power@suse.com>
Tested-by: Noel Power <noel.power@suse.com>
-rw-r--r-- | sw/source/core/unocore/unocrsrhelper.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj2.cxx | 7 |
3 files changed, 16 insertions, 6 deletions
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index e41d237d7cd4..aa9cc45becac 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -497,9 +497,9 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry case FN_UNO_CHARFMT_SEQUENCE: { - SwTxtNode* pTxtNode; - if((pTxtNode = (SwTxtNode*)rPam.GetNode( sal_True )) == rPam.GetNode(sal_False) && - pTxtNode->GetpSwpHints()) + SwTxtNode *const pTxtNode = rPam.GetNode()->GetTxtNode(); + if (rPam.GetNode(sal_True) == rPam.GetNode(sal_False) + && pTxtNode && pTxtNode->GetpSwpHints()) { sal_uInt16 nPaMStart = rPam.GetPoint()->nContent.GetIndex(); sal_uInt16 nPaMEnd = rPam.GetMark() ? rPam.GetMark()->nContent.GetIndex() : nPaMStart; @@ -951,6 +951,11 @@ sal_Bool DocInsertStringSplitCR( xub_StrLen nStartIdx = 0; SwTxtNode* const pTxtNd = rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode(); + if (!pTxtNd) + { + SAL_INFO("sw.uno", "DocInsertStringSplitCR: need a text node"); + return false; + } const xub_StrLen nMaxLength = ( pTxtNd ) ? STRING_LEN - pTxtNd->GetTxt().Len() : STRING_LEN; diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 3bba0848c948..d400286e2ed6 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -556,6 +556,10 @@ throw (lang::IllegalArgumentException) { // multi selection is not considered SwTxtNode *const pTxtNd = rPam.GetNode()->GetTxtNode(); + if (!pTxtNd) + { + throw lang::IllegalArgumentException(); + } if (FN_UNO_NUM_LEVEL == rEntry.nWID) { sal_Int16 nLevel = 0; diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index ea121c15581e..6e0bf2f017d2 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1851,9 +1851,10 @@ lcl_FillFrame(SwClient & rEnum, SwUnoCrsr& rUnoCrsr, FrameDependList_t & rFrames) { // search for objects at the cursor - anchored at/as char - SwTxtAttr const*const pTxtAttr = - rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - rUnoCrsr.GetPoint()->nContent.GetIndex(), RES_TXTATR_FLYCNT); + SwTxtAttr const*const pTxtAttr = (rUnoCrsr.GetNode()->IsTxtNode()) + ? rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + rUnoCrsr.GetPoint()->nContent.GetIndex(), RES_TXTATR_FLYCNT) + : 0; if (pTxtAttr) { const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt(); |