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:02:39 +0100
commit9d1cdb4f42c3fee9f24020404ce8e3d378cb34f4 (patch)
tree01488ada5b96d2869f10c1503b0edd651a056d04
parent9b9d4a9472228a647d61edc428d542fd20bcb034 (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 d165d4bc4207..fbe46b9a208d 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -292,9 +292,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 )
@@ -418,9 +421,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();
@@ -442,9 +445,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 )
@@ -460,9 +467,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)
@@ -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 );