[Libreoffice-commits] .: editeng/source sw/source

Michael Meeks michael at kemper.freedesktop.org
Tue Nov 15 03:11:09 PST 2011


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

New commits:
commit aa0b7b033098bfc1bf3f06cd112691abc862bd20
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Sat Nov 12 11:15:19 2011 +0000

    avoid crasher from unusual odt document fdo#42785

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 );
 }


More information about the Libreoffice-commits mailing list