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 16:13:24 +0100
commite5add879def40a7695fb506b42c024ef9f776062 (patch)
treec4272bc1b2ad9d005e93b47e086bb907d66a5dc0
parente5dcec6e58b4bd8582380dd1f97957c369ba9182 (diff)
fdo#58242: getCrsrPropertyValue: fix crashes when PaM not on SwTxtNode
Change-Id: I67042b5d689457921a928454c9051f0402be17e6 (cherry picked from commit 11b380874a36869452246cc77c392d1767e60e95) Signed-off-by: Michael Stahl <mstahl@redhat.com>
-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 0993721b22f1..e41d237d7cd4 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -302,9 +302,12 @@ sal_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 )
@@ -428,9 +431,9 @@ sal_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();
@@ -452,9 +455,13 @@ sal_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 )
@@ -470,9 +477,10 @@ sal_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)
@@ -721,6 +729,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, sal_True );