svtools/source/config/apearcfg.cxx        |    5 +++--
 svtools/source/config/fontsubstconfig.cxx |    7 ++++---
 svtools/source/config/htmlcfg.cxx         |   16 +++++++++-------
 svtools/source/uno/treecontrolpeer.cxx    |   23 ++++++++++-------------
 4 files changed, 26 insertions(+), 25 deletions(-)

New commits:
commit 11f623a32540d822d539b7f3978363892feb9fe4
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Mon Jun 27 11:59:30 2016 +0200

    Clean up uses of Any::getValue() in svtools
    
    Change-Id: Id11dc4724fed4e43981534ffac5ec5358f9387b2

diff --git a/svtools/source/config/apearcfg.cxx 
b/svtools/source/config/apearcfg.cxx
index 19f16b4..bba8cd0a 100644
--- a/svtools/source/config/apearcfg.cxx
+++ b/svtools/source/config/apearcfg.cxx
@@ -20,6 +20,7 @@
 
 #include <svtools/apearcfg.hxx>
 
+#include <o3tl/any.hxx>
 #include <tools/debug.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
@@ -71,7 +72,7 @@ SvtTabAppearanceCfg::SvtTabAppearanceCfg()
                             nDragMode = (DragMode)nTmp;
                         break;
                     }
-                    case  2: bMenuMouseFollow = *static_cast<sal_Bool const 
*>(pValues->getValue()); break; //"Menu/FollowMouse",
+                    case  2: bMenuMouseFollow = 
*o3tl::doAccess<bool>(*pValues); break; //"Menu/FollowMouse",
                     case  3:
                     {
                         short nTmp;
@@ -81,7 +82,7 @@ SvtTabAppearanceCfg::SvtTabAppearanceCfg()
                     }
                     case  4: { short nTmp = 0; *pValues >>= nTmp; nMiddleMouse 
= static_cast<MouseMiddleButtonAction>(nTmp); break; } 
//"Dialog/MiddleMouseButton",
 #if defined( UNX )
-                    case  5: bFontAntialiasing = *static_cast<sal_Bool const 
*>(pValues->getValue()); break;    // "FontAntialising/Enabled",
+                    case  5: bFontAntialiasing = 
*o3tl::doAccess<bool>(*pValues); break;    // "FontAntialising/Enabled",
                     case  6: *pValues >>= nAAMinPixelHeight; break;            
             // "FontAntialising/MinPixelHeight",
 #endif
                 }
diff --git a/svtools/source/config/fontsubstconfig.cxx 
b/svtools/source/config/fontsubstconfig.cxx
index 473c20b..6785a3f 100644
--- a/svtools/source/config/fontsubstconfig.cxx
+++ b/svtools/source/config/fontsubstconfig.cxx
@@ -20,6 +20,7 @@
 #include <svtools/fontsubstconfig.hxx>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/uno/Sequence.hxx>
+#include <o3tl/any.hxx>
 #include <tools/debug.hxx>
 #include <vcl/outdev.hxx>
 
@@ -55,7 +56,7 @@ SvtFontSubstConfig::SvtFontSubstConfig() :
     Sequence<Any> aValues = GetProperties(aNames);
     DBG_ASSERT(aValues.getConstArray()[0].hasValue(), "no value available");
     if(aValues.getConstArray()[0].hasValue())
-        bIsEnabled = *static_cast<sal_Bool const 
*>(aValues.getConstArray()[0].getValue());
+        bIsEnabled = *o3tl::doAccess<bool>(aValues.getConstArray()[0]);
 
     OUString sPropPrefix(cFontPairs);
     Sequence<OUString> aNodeNames = GetNodeNames(sPropPrefix, 
CONFIG_NAME_LOCAL_PATH);
@@ -81,8 +82,8 @@ SvtFontSubstConfig::SvtFontSubstConfig() :
         SubstitutionStruct aInsert;
         pNodeValues[nName++] >>= aInsert.sFont;
         pNodeValues[nName++] >>= aInsert.sReplaceBy;
-        aInsert.bReplaceAlways = *static_cast<sal_Bool const 
*>(pNodeValues[nName++].getValue());
-        aInsert.bReplaceOnScreenOnly = *static_cast<sal_Bool const 
*>(pNodeValues[nName++].getValue());
+        aInsert.bReplaceAlways = *o3tl::doAccess<bool>(pNodeValues[nName++]);
+        aInsert.bReplaceOnScreenOnly = 
*o3tl::doAccess<bool>(pNodeValues[nName++]);
         pImpl->aSubstArr.push_back(aInsert);
     }
 }
diff --git a/svtools/source/config/htmlcfg.cxx 
b/svtools/source/config/htmlcfg.cxx
index 53f6a8f..a558b0a 100644
--- a/svtools/source/config/htmlcfg.cxx
+++ b/svtools/source/config/htmlcfg.cxx
@@ -17,7 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
+#include <o3tl/any.hxx>
 #include <osl/thread.h>
 #include <svtools/htmlcfg.hxx>
 #include <svtools/parhtml.hxx>
@@ -127,11 +129,11 @@ void SvxHtmlOptions::Load( const Sequence< OUString >& 
aNames )
                 switch(nProp)
                 {
                     case  0:
-                        if(*static_cast<sal_Bool const 
*>(pValues[nProp].getValue()))
+                        if(*o3tl::doAccess<bool>(pValues[nProp]))
                             pImpl->nFlags |= HTMLCFG_UNKNOWN_TAGS;
                     break;//"Import/UnknownTag",
                     case  1:
-                        if(*static_cast<sal_Bool const 
*>(pValues[nProp].getValue()))
+                        if(*o3tl::doAccess<bool>(pValues[nProp]))
                             pImpl->nFlags |= HTMLCFG_IGNORE_FONT_FAMILY;
                     break;//"Import/FontSetting",
                     case  2: pValues[nProp] >>= pImpl->aFontSizeArr[0]; 
break;//"Import/FontSize/Size_1",
@@ -157,19 +159,19 @@ void SvxHtmlOptions::Load( const Sequence< OUString >& 
aNames )
                         }
                         break;
                     case 10:
-                        if(*static_cast<sal_Bool const 
*>(pValues[nProp].getValue()))
+                        if(*o3tl::doAccess<bool>(pValues[nProp]))
                             pImpl->nFlags |= HTMLCFG_STAR_BASIC;
                     break;//"Export/Basic",
                     case 11:
-                        if(*static_cast<sal_Bool const 
*>(pValues[nProp].getValue()))
+                        if(*o3tl::doAccess<bool>(pValues[nProp]))
                             pImpl->nFlags |= HTMLCFG_PRINT_LAYOUT_EXTENSION;
                     break;//"Export/PrintLayout",
                     case 12:
-                        if(*static_cast<sal_Bool const 
*>(pValues[nProp].getValue()))
+                        if(*o3tl::doAccess<bool>(pValues[nProp]))
                             pImpl->nFlags |= HTMLCFG_LOCAL_GRF;
                     break;//"Export/LocalGraphic",
                     case 13:
-                        if(*static_cast<sal_Bool const 
*>(pValues[nProp].getValue()))
+                        if(*o3tl::doAccess<bool>(pValues[nProp]))
                             pImpl->nFlags |= HTMLCFG_IS_BASIC_WARNING;
                     break;//"Export/Warning"
 
@@ -178,7 +180,7 @@ void SvxHtmlOptions::Load( const Sequence< OUString >& 
aNames )
                     break;//"Export/Encoding"
 
                     case 15:
-                        if(*static_cast<sal_Bool const 
*>(pValues[nProp].getValue()))
+                        if(*o3tl::doAccess<bool>(pValues[nProp]))
                             pImpl->nFlags |= HTMLCFG_NUMBERS_ENGLISH_US;
                     break;//"Import/NumbersEnglishUS"
                 }
diff --git a/svtools/source/uno/treecontrolpeer.cxx 
b/svtools/source/uno/treecontrolpeer.cxx
index 0df10e9..b6b5fa5 100644
--- a/svtools/source/uno/treecontrolpeer.cxx
+++ b/svtools/source/uno/treecontrolpeer.cxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
 #include <com/sun/star/view/SelectionType.hpp>
+#include <o3tl/any.hxx>
 #include <toolkit/helper/property.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 
@@ -437,7 +438,7 @@ void TreeControlPeer::ChangeNodesSelection( const Any& 
rSelection, bool bSelect,
 
     Reference< XTreeNode > xTempNode;
 
-    const Reference< XTreeNode > *pNodes = nullptr;
+    Sequence<Reference<XTreeNode>> pNodes;
     sal_Int32 nCount = 0;
 
     if( rSelection.hasValue() )
@@ -450,18 +451,17 @@ void TreeControlPeer::ChangeNodesSelection( const Any& 
rSelection, bool bSelect,
                 if( xTempNode.is() )
                 {
                     nCount = 1;
-                    pNodes = &xTempNode;
+                    pNodes = {xTempNode};
                 }
                 break;
             }
         case TypeClass_SEQUENCE:
             {
-                if( rSelection.getValueType() == cppu::UnoType<Sequence< 
Reference< XTreeNode > >>::get() )
+                if( auto rSeq = 
o3tl::tryAccess<Sequence<Reference<XTreeNode>>>(
+                        rSelection) )
                 {
-                    const Sequence< Reference< XTreeNode > >& rSeq( 
*static_cast<const Sequence< Reference< XTreeNode > > *>(rSelection.getValue()) 
);
-                    nCount = rSeq.getLength();
-                    if( nCount )
-                        pNodes = rSeq.getConstArray();
+                    nCount = rSeq->getLength();
+                    pNodes = *rSeq;
                 }
                 break;
             }
@@ -476,13 +476,10 @@ void TreeControlPeer::ChangeNodesSelection( const Any& 
rSelection, bool bSelect,
     if( bSetSelection )
         rTree.SelectAll( false );
 
-    if( pNodes && nCount )
+    for( sal_Int32 i = 0; i != nCount; ++i )
     {
-        while( nCount-- )
-        {
-            UnoTreeListEntry* pEntry = getEntry( *pNodes++ );
-            rTree.Select( pEntry, bSelect );
-        }
+        UnoTreeListEntry* pEntry = getEntry( pNodes[i] );
+        rTree.Select( pEntry, bSelect );
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to