[Libreoffice-commits] core.git: starmath/inc starmath/source

Takeshi Abe tabe at fixedpoint.jp
Sun Jun 26 20:15:55 UTC 2016


 starmath/inc/node.hxx    |    6 +++---
 starmath/source/node.cxx |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit b075882016d8388d20cc7490eb0733a9d0d97a5f
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sun Jun 26 18:25:36 2016 +0900

    starmath: Fix invalid static_cast
    
    It was an undefined behavior that static_cast'ing a pointer to
    SmVisibleNode to SmStructureNode's.
    
    Change-Id: Ic391175a5535cec84bd7f9ec58fa13a411398331
    Reviewed-on: https://gerrit.libreoffice.org/26676
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index fa79f55..72da13b 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -114,13 +114,12 @@ class SmNode : public SmRect
     FontAttribute   mnAttributes;
     bool            mbIsPhantom;
     bool            mbIsSelected;
+    // index in accessible text; -1 if not (yet) applicable
+    sal_Int32       mnAccIndex;
 
 protected:
     SmNode(SmNodeType eNodeType, const SmToken &rNodeToken);
 
-    // index in accessible text -1 if not (yet) applicable
-    sal_Int32       mnAccIndex;
-
 public:
     SmNode(const SmNode&) = delete;
     SmNode& operator=(const SmNode&) = delete;
@@ -174,6 +173,7 @@ public:
 
     virtual void    GetAccessibleText( OUStringBuffer &rText ) const = 0;
     sal_Int32       GetAccessibleIndex() const { return mnAccIndex; }
+    void            SetAccessibleIndex(sal_Int32 nAccIndex) { mnAccIndex = nAccIndex; }
     const SmNode *  FindNodeWithAccessibleIndex(sal_Int32 nAccIndex) const;
 
     sal_uInt16  GetRow() const    { return sal::static_int_cast<sal_uInt16>(maNodeToken.nRow); }
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index f378e4d..8300752 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -429,7 +429,7 @@ void SmStructureNode::GetAccessibleText( OUStringBuffer &rText ) const
                    [&rText](SmNode *pNode)
         {
             if (pNode->IsVisible())
-                static_cast<SmStructureNode *>(pNode)->mnAccIndex = rText.getLength();
+                pNode->SetAccessibleIndex(rText.getLength());
             pNode->GetAccessibleText( rText );
         });
 }


More information about the Libreoffice-commits mailing list