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


Folks,

Here are two patches for Writer/StarMath's accessibility.cxx.  (I
picked a random module and went for the first C++ file I could find
within.) One patch simply removes a whole bunch of dead code from
conditionals; the other is actually a minor bugfix, wherein someone
commented out a null-pointer check where they almost certainly just
meant to remove a refcounter.

I was wondering just how broad this patches should be; I have one that
removes a lot more dead code from accessibility.cxx, but should it also
do the same to the .hxx?  Other files at the same time?

These patches are released under the GPLv3+, if that's relevant for
something so basic.

P
From 7f68e8ea00e044ae7c17ccf3eef8c967ce89009f Mon Sep 17 00:00:00 2001
From: Phil Bordelon <phil@thenexusproject.org>
Date: Thu, 30 Sep 2010 10:40:05 -0500
Subject: [PATCH 1/2] Fix commented-out null-pointer check.

In SmEditAccessible::addEventListener(), a previous commenting-out
of a line also removed a null-pointer check.  This axes the
commented out code but restores the check.

Signed-off-by: Phil Bordelon <phil@thenexusproject.org>
---
 starmath/source/accessibility.cxx |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 36d943a..74c5f0f 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -1952,7 +1952,7 @@ Locale SAL_CALL SmEditAccessible::getLocale(  )
 void SAL_CALL SmEditAccessible::addEventListener( const uno::Reference< XAccessibleEventListener 
& xListener )
     throw (RuntimeException)
 {
-    //vos::OGuard aGuard(Application::GetSolarMutex());   if (pTextHelper)   // not disposing 
(about to destroy view shell)
+    if (pTextHelper)   // not disposing (about to destroy view shell)
         pTextHelper->AddEventListener( xListener );
 }
 
-- 
1.7.0.4

From dc8b54560bbff5395d178b7302c62f2d68bb430f Mon Sep 17 00:00:00 2001
From: Phil Bordelon <phil@thenexusproject.org>
Date: Thu, 30 Sep 2010 10:43:59 -0500
Subject: [PATCH 2/2] Remove dead less-than-zero conditional checks.

A large number of conditionals in accessibility.cxx checked that
their values were above zero at some point, but that code was
commented out; this removes those (unused) checks completely.

Signed-off-by: Phil Bordelon <phil@thenexusproject.org>
---
 starmath/source/accessibility.cxx |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 74c5f0f..55e9a02 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -464,7 +464,7 @@ sal_Bool SAL_CALL SmGraphicAccessible::setCaretPosition( sal_Int32 nIndex )
 {
     xub_StrLen nIdx = (xub_StrLen) nIndex;
     String aTxt( GetAccessibleText_Impl() );
-    if (!(/*0 <= nIdx  &&*/  nIdx < aTxt.Len()))
+    if (!(nIdx < aTxt.Len()))
         throw IndexOutOfBoundsException();
     return sal_False;
 }
@@ -476,7 +476,7 @@ sal_Unicode SAL_CALL SmGraphicAccessible::getCharacter( sal_Int32 nIndex )
 
     xub_StrLen nIdx = (xub_StrLen) nIndex;
     String aTxt( GetAccessibleText_Impl() );
-    if (!(/*0 <= nIdx  &&*/  nIdx < aTxt.Len()))
+    if (!(nIdx < aTxt.Len()))
         throw IndexOutOfBoundsException();
     return aTxt.GetChar( nIdx );
 }
@@ -694,8 +694,8 @@ OUString SAL_CALL SmGraphicAccessible::getTextRange(
     String aTxt( GetAccessibleText_Impl() );
     xub_StrLen nStart = (xub_StrLen) Min(nStartIndex, nEndIndex);
     xub_StrLen nEnd   = (xub_StrLen) Max(nStartIndex, nEndIndex);
-    if (!(/*0 <= nStart  &&*/  nStart <= aTxt.Len()) ||
-        !(/*0 <= nEnd    &&*/  nEnd   <= aTxt.Len()))
+    if (!(nStart <= aTxt.Len()) ||
+        !(nEnd   <= aTxt.Len()))
         throw IndexOutOfBoundsException();
     return aTxt.Copy( nStart, nEnd - nStart );
 }
@@ -706,7 +706,7 @@ OUString SAL_CALL SmGraphicAccessible::getTextRange(
     String aTxt( GetAccessibleText_Impl() );
     xub_StrLen nIdx = (xub_StrLen) nIndex;
     //!! nIndex is allowed to be the string length
-    if (!(/*0 <= nIdx  &&*/  nIdx <= aTxt.Len()))
+    if (!(nIdx <= aTxt.Len()))
         throw IndexOutOfBoundsException();
 
     ::com::sun::star::accessibility::TextSegment aResult;
@@ -727,7 +727,7 @@ OUString SAL_CALL SmGraphicAccessible::getTextRange(
     String aTxt( GetAccessibleText_Impl() );
     xub_StrLen nIdx = (xub_StrLen) nIndex;
     //!! nIndex is allowed to be the string length
-    if (!(/*0 <= nIdx  &&*/  nIdx <= aTxt.Len()))
+    if (!(nIdx <= aTxt.Len()))
         throw IndexOutOfBoundsException();
 
     ::com::sun::star::accessibility::TextSegment aResult;
@@ -749,7 +749,7 @@ OUString SAL_CALL SmGraphicAccessible::getTextRange(
     String aTxt( GetAccessibleText_Impl() );
     xub_StrLen nIdx = (xub_StrLen) nIndex;
     //!! nIndex is allowed to be the string length
-    if (!(/*0 <= nIdx  &&*/  nIdx <= aTxt.Len()))
+    if (!(nIdx <= aTxt.Len()))
         throw IndexOutOfBoundsException();
 
     ::com::sun::star::accessibility::TextSegment aResult;
-- 
1.7.0.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.