summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-01-09 14:40:10 +0100
committerMichael Stahl <mstahl@redhat.com>2013-01-09 15:57:50 +0100
commit11b380874a36869452246cc77c392d1767e60e95 (patch)
tree34630480c9dfd03d5fb98167f312615471a0154a
parent555bc780c83114220012e198b5471a0d7452fb32 (diff)
fdo#58242: getCrsrPropertyValue: fix crashes when PaM not on SwTxtNode
Change-Id: I67042b5d689457921a928454c9051f0402be17e6
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx28
1 files changed, 19 insertions, 9 deletions
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 584b2d746436..21f553a7f778 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -292,9 +292,12 @@ bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
break;
case FN_UNO_DOCUMENT_INDEX_MARK:
{
- ::std::vector<SwTxtAttr *> const marks(
- rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt(
- rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_TOXMARK));
+ ::std::vector<SwTxtAttr *> marks;
+ if (rPam.GetNode()->IsTxtNode())
+ {
+ marks = rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt(
+ rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_TOXMARK);
+ }
if (marks.size())
{
if( pAny )
@@ -418,9 +421,9 @@ bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
case FN_UNO_ENDNOTE:
case FN_UNO_FOOTNOTE:
{
- SwTxtAttr *const pTxtAttr =
+ SwTxtAttr *const pTxtAttr = rPam.GetNode()->IsTxtNode() ?
rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
- rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN);
+ rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN) : 0;
if(pTxtAttr)
{
const SwFmtFtn& rFtn = pTxtAttr->GetFtn();
@@ -442,9 +445,13 @@ bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
break;
case FN_UNO_REFERENCE_MARK:
{
- ::std::vector<SwTxtAttr *> const marks(
+ ::std::vector<SwTxtAttr *> marks;
+ if (rPam.GetNode()->IsTxtNode())
+ {
+ marks = (
rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt(
rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_REFMARK));
+ }
if (marks.size())
{
if( pAny )
@@ -460,9 +467,10 @@ bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
break;
case FN_UNO_NESTED_TEXT_CONTENT:
{
- uno::Reference<XTextContent> const xRet(
- GetNestedTextContent(*rPam.GetNode()->GetTxtNode(),
- rPam.GetPoint()->nContent.GetIndex(), false));
+ uno::Reference<XTextContent> const xRet(rPam.GetNode()->IsTxtNode()
+ ? GetNestedTextContent(*rPam.GetNode()->GetTxtNode(),
+ rPam.GetPoint()->nContent.GetIndex(), false)
+ : 0);
if (xRet.is())
{
if (pAny)
@@ -711,6 +719,8 @@ void getNumberingProperty(SwPaM& rPam, PropertyState& eState, Any * pAny )
void GetCurPageStyle(SwPaM& rPaM, String &rString)
{
+ if (!rPaM.GetCntntNode())
+ return; // TODO: is there an easy way to get it for tables/sections?
const SwPageFrm* pPage = rPaM.GetCntntNode()->getLayoutFrm(rPaM.GetDoc()->GetCurrentLayout())->FindPageFrm();
if(pPage)
SwStyleNameMapper::FillProgName( pPage->GetPageDesc()->GetName(), rString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );