Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


So,

        I'm no writer filter expert; but it seems like there is a rather
incomplete attempt in this code to cope with a NULL mpEditSource - that
I finish off. But of course, perhaps there is a much cleaner / easier
fix elsewhere.

        HTH,

                Michael.

-- 
michael.meeks@suse.com  <><, Pseudo Engineer, itinerant idiot
From 6ef46645e145f59b83b63b3a14c940725076eac8 Mon Sep 17 00:00:00 2001
From: Michael Meeks <michael.meeks@suse.com>
Date: Sat, 12 Nov 2011 11:15:19 +0000
Subject: [PATCH] avoid crasher from unusual odt document fdo#42785

---
 editeng/source/uno/unotext.cxx    |   34 ++++++++++++++++++++--------------
 sw/source/filter/xml/xmltexti.cxx |    2 +-
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index ac241d2..5933da3 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -183,6 +183,13 @@ void CheckSelection( struct ESelection& rSel, SvxTextForwarder* pForwarder ) 
thr
     }
 }
 
+void CheckSelection( struct ESelection& rSel, SvxEditSource *pEdit ) throw()
+{
+    if (!pEdit)
+        return;
+    CheckSelection( rSel, pEdit->GetTextForwarder() );
+}
+
 // ====================================================================
 // class SvxUnoTextRangeBase
 // ====================================================================
@@ -275,8 +282,7 @@ void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw()
     SolarMutexGuard aGuard;
 
     maSelection = rSelection;
-    if (mpEditSource != NULL)
-        CheckSelection( maSelection, mpEditSource->GetTextForwarder() );
+    CheckSelection( maSelection, mpEditSource );
 }
 
 // Interface XTextRange ( XText )
@@ -291,7 +297,6 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getStart(void)
     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     if( pForwarder )
     {
-
         CheckSelection( maSelection, pForwarder );
 
         SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( getText() );
@@ -406,7 +411,6 @@ void SAL_CALL SvxUnoTextRangeBase::_setPropertyValue( const OUString& PropertyNa
     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     if( pForwarder )
     {
-
         CheckSelection( maSelection, pForwarder );
 
         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName );
@@ -1308,7 +1312,7 @@ uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( 
con
 // internal
 void SvxUnoTextRangeBase::CollapseToStart(void) throw()
 {
-    CheckSelection( maSelection, mpEditSource->GetTextForwarder() );
+    CheckSelection( maSelection, mpEditSource );
 
     maSelection.nEndPara = maSelection.nStartPara;
     maSelection.nEndPos  = maSelection.nStartPos;
@@ -1316,7 +1320,7 @@ void SvxUnoTextRangeBase::CollapseToStart(void) throw()
 
 void SvxUnoTextRangeBase::CollapseToEnd(void) throw()
 {
-    CheckSelection( maSelection, mpEditSource->GetTextForwarder() );
+    CheckSelection( maSelection, mpEditSource );
 
     maSelection.nStartPara = maSelection.nEndPara;
     maSelection.nStartPos  = maSelection.nEndPos;
@@ -1324,7 +1328,7 @@ void SvxUnoTextRangeBase::CollapseToEnd(void) throw()
 
 sal_Bool SvxUnoTextRangeBase::IsCollapsed(void) throw()
 {
-    CheckSelection( maSelection, mpEditSource->GetTextForwarder() );
+    CheckSelection( maSelection, mpEditSource );
 
     return ( maSelection.nStartPara == maSelection.nEndPara &&
              maSelection.nStartPos  == maSelection.nEndPos );
@@ -1332,7 +1336,7 @@ sal_Bool SvxUnoTextRangeBase::IsCollapsed(void) throw()
 
 sal_Bool SvxUnoTextRangeBase::GoLeft(sal_Int16 nCount, sal_Bool Expand) throw()
 {
-    CheckSelection( maSelection, mpEditSource->GetTextForwarder() );
+    CheckSelection( maSelection, mpEditSource );
 
     //  #75098# use end position, as in Writer (start is anchor, end is cursor)
     sal_uInt16 nNewPos = maSelection.nEndPos;
@@ -1375,7 +1379,6 @@ sal_Bool SvxUnoTextRangeBase::GoRight(sal_Int16 nCount, sal_Bool Expand)  
throw(
     {
         CheckSelection( maSelection, pForwarder );
 
-
         sal_uInt16 nNewPos = maSelection.nEndPos + nCount; //! Overflow???
         sal_uInt16 nNewPar = maSelection.nEndPara;
 
@@ -1419,7 +1422,7 @@ void SvxUnoTextRangeBase::GotoStart(sal_Bool Expand) throw()
 
 void SvxUnoTextRangeBase::GotoEnd(sal_Bool Expand) throw()
 {
-    CheckSelection( maSelection, mpEditSource->GetTextForwarder() );
+    CheckSelection( maSelection, mpEditSource );
 
     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     if( pForwarder )
@@ -1670,8 +1673,11 @@ void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< 
text::XTextRan
         return;
 
     ESelection aSelection;
-    ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
-    SetSelection( aSelection );
+    if (GetEditSource())
+    {
+        ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
+        SetSelection( aSelection );
+    }
 
     SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
     if(pRange)
@@ -1771,10 +1777,10 @@ void SAL_CALL SvxUnoTextBase::insertControlCharacter( const uno::Reference< 
text
                 return;
             }
         }
+        default:
+            throw lang::IllegalArgumentException();
         }
     }
-
-    throw lang::IllegalArgumentException();
 }
 
 // XText
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
index 291665e..11dcd4f 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -206,7 +206,7 @@ sal_Bool SwXMLTextImportHelper::IsInHeaderFooter() const
     OTextCursorHelper *pTxtCrsr = reinterpret_cast< OTextCursorHelper * >(
                 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( 
OTextCursorHelper::getUnoTunnelId() )));
     OSL_ENSURE( pTxtCrsr, "SwXTextCursor missing" );
-    SwDoc *pDoc = pTxtCrsr->GetDoc();
+    SwDoc *pDoc = pTxtCrsr ? pTxtCrsr->GetDoc() : NULL;
 
     return pDoc && pDoc->IsInHeaderFooter( pTxtCrsr->GetPaM()->GetPoint()->nNode );
 }
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.