[Libreoffice-commits] core.git: winaccessibility/source

Stephan Bergmann sbergman at redhat.com
Thu May 11 09:16:31 UTC 2017


 winaccessibility/source/UAccCOM/AccActionBase.cxx   |   26 --
 winaccessibility/source/UAccCOM/AccActionBase.h     |    2 
 winaccessibility/source/UAccCOM/AccEditableText.cxx |    6 
 winaccessibility/source/UAccCOM/AccImage.cxx        |    2 
 winaccessibility/source/UAccCOM/AccTable.cxx        |    4 
 winaccessibility/source/UAccCOM/AccTextBase.cxx     |   50 ++---
 winaccessibility/source/UAccCOM/MAccessible.cxx     |  182 +++++++++-----------
 winaccessibility/source/UAccCOM/MAccessible.h       |    7 
 winaccessibility/source/service/AccObject.cxx       |   25 +-
 9 files changed, 143 insertions(+), 161 deletions(-)

New commits:
commit 311a9126dca1273593ac8deade5cb36ec740d786
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu May 11 11:15:49 2017 +0200

    Clean up uses of SAL_U/SAL_W: winaccessibility
    
    Change-Id: I8f2abf0d338d01453f273b279e34c882de461b00

diff --git a/winaccessibility/source/UAccCOM/AccActionBase.cxx b/winaccessibility/source/UAccCOM/AccActionBase.cxx
index 5610ba4f3627..c873b44115c4 100644
--- a/winaccessibility/source/UAccCOM/AccActionBase.cxx
+++ b/winaccessibility/source/UAccCOM/AccActionBase.cxx
@@ -117,7 +117,7 @@ STDMETHODIMP CAccActionBase::get_description(long actionIndex,BSTR __RPC_FAR *de
     // #CHECK#
 
     SAFE_SYSFREESTRING(*description);
-    *description = SysAllocString(SAL_W(ouStr.getStr()));
+    *description = SysAllocString(reinterpret_cast<wchar_t const *>(ouStr.getStr()));
 
     return S_OK;
 
@@ -166,8 +166,6 @@ STDMETHODIMP CAccActionBase::get_keyBinding(
 
     long nCount = (binding.get())->getAccessibleKeyBindingCount();
 
-    OLECHAR wString[64];
-
     *keyBinding = static_cast<BSTR*>(::CoTaskMemAlloc(nCount*sizeof(BSTR)));
 
     // #CHECK Memory Allocation#
@@ -176,10 +174,10 @@ STDMETHODIMP CAccActionBase::get_keyBinding(
 
     for( int index = 0;index < nCount;index++ )
     {
-        memset(wString,0,sizeof(wString));
-        GetkeyBindingStrByXkeyBinding( (binding.get())->getAccessibleKeyBinding(index), wString );
+        auto const wString = GetkeyBindingStrByXkeyBinding( (binding.get())->getAccessibleKeyBinding(index) );
 
-        (*keyBinding)[index] = SysAllocString(wString);
+        (*keyBinding)[index] = SysAllocString(
+            reinterpret_cast<wchar_t const *>(wString.getStr()));
     }
 
     *nBinding = nCount;
@@ -222,23 +220,17 @@ STDMETHODIMP CAccActionBase::put_XInterface(hyper pXInterface)
  * Helper function used for converting keybinding to string.
  *
  * @param    keySet    the key stroke sequence.
- * @param    pString   the output keybinding string.
  */
-void CAccActionBase::GetkeyBindingStrByXkeyBinding( const Sequence< KeyStroke > &keySet, OLECHAR* pString )
+OUString CAccActionBase::GetkeyBindingStrByXkeyBinding( const Sequence< KeyStroke > &keySet )
 {
-    // #CHECK#
-    if(pString == nullptr)
-        return;
-
+    OUStringBuffer buf;
     for( int iIndex = 0;iIndex < keySet.getLength();iIndex++ )
     {
         KeyStroke stroke = keySet[iIndex];
-        OLECHAR wString[64] = {NULL};
-        wcscat(wString, OLESTR("\n"));
-        wcscat(wString, SAL_W(&stroke.KeyChar));
-
-        wcscat( pString, wString);
+        buf.append('\n');
+        buf.append(stroke.KeyChar);
     }
+    return buf.makeStringAndClear();
 }
 
 /**
diff --git a/winaccessibility/source/UAccCOM/AccActionBase.h b/winaccessibility/source/UAccCOM/AccActionBase.h
index 657d002c5f0b..9410012d41a5 100644
--- a/winaccessibility/source/UAccCOM/AccActionBase.h
+++ b/winaccessibility/source/UAccCOM/AccActionBase.h
@@ -64,7 +64,7 @@ public:
     // Override of IUNOXWrapper.
     STDMETHOD(put_XInterface)(hyper pXInterface) override;
 
-    static void GetkeyBindingStrByXkeyBinding( const css::uno::Sequence< css::awt::KeyStroke > &keySet, OLECHAR* pString );
+    static OUString GetkeyBindingStrByXkeyBinding( const css::uno::Sequence< css::awt::KeyStroke > &keySet );
 
 protected:
 
diff --git a/winaccessibility/source/UAccCOM/AccEditableText.cxx b/winaccessibility/source/UAccCOM/AccEditableText.cxx
index 47da0f2efae1..e2cf3d3729be 100644
--- a/winaccessibility/source/UAccCOM/AccEditableText.cxx
+++ b/winaccessibility/source/UAccCOM/AccEditableText.cxx
@@ -119,7 +119,7 @@ STDMETHODIMP CAccEditableText::insertText(long offset, BSTR * text)
     if( !pRXEdtTxt.is() )
         return E_FAIL;
 
-    ::rtl::OUString ouStr(SAL_U(*text));
+    ::rtl::OUString ouStr(reinterpret_cast<sal_Unicode const *>(*text));
 
     if( GetXInterface()->insertText( ouStr, offset ) )
         return S_OK;
@@ -196,7 +196,7 @@ STDMETHODIMP CAccEditableText::replaceText(long startOffset, long endOffset, BST
     if( !pRXEdtTxt.is() )
         return E_FAIL;
 
-    ::rtl::OUString ouStr(SAL_U(*text));
+    ::rtl::OUString ouStr(reinterpret_cast<sal_Unicode const *>(*text));
 
     if( GetXInterface()->replaceText( startOffset,endOffset, ouStr) )
         return S_OK;
@@ -225,7 +225,7 @@ STDMETHODIMP CAccEditableText::setAttributes(long startOffset, long endOffset, B
     if( !pRXEdtTxt.is() )
         return E_FAIL;
 
-    ::rtl::OUString ouStr(SAL_U(*attributes));
+    ::rtl::OUString ouStr(reinterpret_cast<sal_Unicode const *>(*attributes));
 
     sal_Int32 nIndex = 0;
     sal_Unicode cTok = ';';
diff --git a/winaccessibility/source/UAccCOM/AccImage.cxx b/winaccessibility/source/UAccCOM/AccImage.cxx
index 5b0e88fd47d1..4435841ed457 100644
--- a/winaccessibility/source/UAccCOM/AccImage.cxx
+++ b/winaccessibility/source/UAccCOM/AccImage.cxx
@@ -56,7 +56,7 @@ STDMETHODIMP CAccImage::get_description(BSTR * description)
 
     ::rtl::OUString ouStr = GetXInterface()->getAccessibleImageDescription();
     SAFE_SYSFREESTRING(*description);
-    *description = SysAllocString(SAL_W(ouStr.getStr()));
+    *description = SysAllocString(reinterpret_cast<wchar_t const *>(ouStr.getStr()));
 
     return S_OK;
 
diff --git a/winaccessibility/source/UAccCOM/AccTable.cxx b/winaccessibility/source/UAccCOM/AccTable.cxx
index 542a40ce9398..18c0f455ad5d 100644
--- a/winaccessibility/source/UAccCOM/AccTable.cxx
+++ b/winaccessibility/source/UAccCOM/AccTable.cxx
@@ -132,7 +132,7 @@ STDMETHODIMP CAccTable::get_columnDescription(long column, BSTR * description)
     // #CHECK#
 
     SAFE_SYSFREESTRING(*description);//??
-    *description = SysAllocString(SAL_W(ouStr.getStr()));
+    *description = SysAllocString(reinterpret_cast<wchar_t const *>(ouStr.getStr()));
     if(description==nullptr)
         return E_FAIL;
     return S_OK;
@@ -351,7 +351,7 @@ STDMETHODIMP CAccTable::get_rowDescription(long row, BSTR * description)
     // #CHECK#
 
     SAFE_SYSFREESTRING(*description);
-    *description = SysAllocString(SAL_W(ouStr.getStr()));
+    *description = SysAllocString(reinterpret_cast<wchar_t const *>(ouStr.getStr()));
     if(description==nullptr)
         return E_FAIL;
 
diff --git a/winaccessibility/source/UAccCOM/AccTextBase.cxx b/winaccessibility/source/UAccCOM/AccTextBase.cxx
index 6bed720c5389..0c7a58dbdade 100644
--- a/winaccessibility/source/UAccCOM/AccTextBase.cxx
+++ b/winaccessibility/source/UAccCOM/AccTextBase.cxx
@@ -21,7 +21,6 @@
 // AccTextBase.cpp: implementation of the CAccTextBase class.
 
 #include "stdafx.h"
-#include <string>
 
 #include "AccTextBase.h"
 
@@ -110,14 +109,12 @@ STDMETHODIMP CAccTextBase::get_attributes(long offset, long * startOffset, long
     if( offset < 0 || offset > GetXInterface()->getCharacterCount() )
         return E_FAIL;
 
-    std::wstring strAttrs;
-
-    strAttrs += L"Version:1;";
+    OUStringBuffer strAttrs("Version:1;");
 
     Sequence< css::beans::PropertyValue > pValues = GetXInterface()->getCharacterAttributes(offset, Sequence< rtl::OUString >());
     int nCount = pValues.getLength();
 
-    short numberingLevel = 0;
+    sal_Int16 numberingLevel = 0;
     OUString numberingPrefix;
     Any anyNumRule;
     bool bHaveNumberingPrefixAttr = false;
@@ -150,23 +147,19 @@ STDMETHODIMP CAccTextBase::get_attributes(long offset, long * startOffset, long
         }
         if (bHaveNumberingLevel && bHaveNumberingRules && bHaveNumberingPrefixAttr)
         {
-            OLECHAR numProps[512] = {0};
-            strAttrs+=L";";
+            strAttrs.append(';');
             numberingPrefix = ReplaceFourChar(numberingPrefix);
-            CMAccessible::get_OLECHAR4Numbering(anyNumRule,numberingLevel,numberingPrefix,numProps);
-            strAttrs += numProps;
+            strAttrs.append(CMAccessible::get_String4Numbering(anyNumRule,numberingLevel,numberingPrefix));
             bHaveNumberingLevel = false;
             bHaveNumberingRules = false;
         }
         if( (bHaveNumberingPrefixAttr && i > 1 ) ||
             (!bHaveNumberingPrefixAttr && i > 0 ) ) //element 0 is NumberingPrefix, not write alone
         {
-            strAttrs+=L";";
+            strAttrs.append(';');
         }
-        strAttrs += SAL_W(pValue.Name.getStr());
-        strAttrs += L":";
-
-        OLECHAR pTemp[2048] = {0};
+        strAttrs.append(pValue.Name);
+        strAttrs.append(':');
 
         if (pValue.Name == "CharBackColor" ||
                 pValue.Name == "CharColor" ||
@@ -174,24 +167,25 @@ STDMETHODIMP CAccTextBase::get_attributes(long offset, long * startOffset, long
         {
             unsigned long nColor;
             pValue.Value >>= nColor;
-            OLECHAR pBuf[64];
-            swprintf( pBuf, L"%08lX", nColor );
-            pTemp[0]=L'#';
-            wcscat( pTemp, pBuf );
-
+            strAttrs.append('#');
+            auto const hex = OUString::number(nColor, 16).toAsciiUpperCase();
+            for (sal_Int32 j = hex.getLength(); j < 8; ++j) {
+                strAttrs.append('0');
+            }
+            strAttrs.append(hex);
         }
         else
         {
-            CMAccessible::get_OLECHARFromAny(pValue.Value,pTemp);
+            strAttrs.append(CMAccessible::get_StringFromAny(pValue.Value));
         }
-
-        strAttrs +=pTemp;
     }
-    strAttrs +=L";";
+    strAttrs.append(';');
     // #CHECK#
     if(*textAttributes)
         SysFreeString(*textAttributes);
-    *textAttributes = SysAllocString(strAttrs.c_str());
+    *textAttributes = SysAllocString(
+        reinterpret_cast<wchar_t const *>(
+            strAttrs.makeStringAndClear().getStr()));
 
     if( offset < GetXInterface()->getCharacterCount() )
     {
@@ -499,7 +493,7 @@ STDMETHODIMP CAccTextBase::get_text(long startOffset, long endOffset, BSTR * tex
     }
 
     SysFreeString(*text);
-    *text = SysAllocString(SAL_W(ouStr.getStr()));
+    *text = SysAllocString(reinterpret_cast<wchar_t const *>(ouStr.getStr()));
     return S_OK;
 
     LEAVE_PROTECTED_BLOCK
@@ -584,7 +578,7 @@ STDMETHODIMP CAccTextBase::get_textBeforeOffset(long offset, IA2TextBoundaryType
     TextSegment segment = GetXInterface()->getTextBeforeIndex( offset, sal_Int16(lUnoBoundaryType));
     ::rtl::OUString ouStr = segment.SegmentText;
     SysFreeString(*text);
-    *text = SysAllocString(SAL_W(ouStr.getStr()));
+    *text = SysAllocString(reinterpret_cast<wchar_t const *>(ouStr.getStr()));
     *startOffset = segment.SegmentStart;
     *endOffset = segment.SegmentEnd;
 
@@ -670,7 +664,7 @@ STDMETHODIMP CAccTextBase::get_textAfterOffset(long offset, IA2TextBoundaryType
     TextSegment segment = GetXInterface()->getTextBehindIndex( offset, sal_Int16(lUnoBoundaryType));
     ::rtl::OUString ouStr = segment.SegmentText;
     SysFreeString(*text);
-    *text = SysAllocString(SAL_W(ouStr.getStr()));
+    *text = SysAllocString(reinterpret_cast<wchar_t const *>(ouStr.getStr()));
     *startOffset = segment.SegmentStart;
     *endOffset = segment.SegmentEnd;
 
@@ -757,7 +751,7 @@ STDMETHODIMP CAccTextBase::get_textAtOffset(long offset, IA2TextBoundaryType bou
     TextSegment segment = GetXInterface()->getTextAtIndex( offset, sal_Int16(lUnoBoundaryType));
     ::rtl::OUString ouStr = segment.SegmentText;
     SysFreeString(*text);
-    *text = SysAllocString(SAL_W(ouStr.getStr()));
+    *text = SysAllocString(reinterpret_cast<wchar_t const *>(ouStr.getStr()));
     *startOffset = segment.SegmentStart;
     *endOffset = segment.SegmentEnd;
 
diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx
index ec628099aab9..9fb55b34bac1 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.cxx
+++ b/winaccessibility/source/UAccCOM/MAccessible.cxx
@@ -591,17 +591,17 @@ STDMETHODIMP CMAccessible::get_accHelpTopic(BSTR *, VARIANT, long *)
     return E_NOTIMPL;
 }
 
-static void GetMnemonicChar( const ::rtl::OUString& aStr, WCHAR* wStr)
+static bool GetMnemonicChar( const ::rtl::OUString& aStr, sal_Unicode* wStr)
 {
     for (sal_Int32 i = 0;; i += 2) {
         i = aStr.indexOf('~', i);
         if (i == -1 || i == aStr.getLength() - 1) {
-            break;
+            return false;
         }
         auto c = aStr[i + 1];
         if (c != '~') {
             *wStr = c;
-            break;
+            return true;
         }
     }
 }
@@ -639,7 +639,7 @@ STDMETHODIMP CMAccessible::get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKe
 
                     Reference<XAccessibleAction> pRXI(pRContext,UNO_QUERY);
 
-                    OLECHAR wString[64]={0};
+                    OUString wString;
 
                     if( pRXI.is() && pRXI->getAccessibleActionCount() >= 1)
                     {
@@ -649,11 +649,11 @@ STDMETHODIMP CMAccessible::get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKe
                             long nCount = binding->getAccessibleKeyBindingCount();
                             if(nCount >= 1)
                             {
-                                CAccAction::GetkeyBindingStrByXkeyBinding( binding->getAccessibleKeyBinding(0),wString );
+                                wString = CAccAction::GetkeyBindingStrByXkeyBinding( binding->getAccessibleKeyBinding(0) );
                             }
                         }
                     }
-                    if(wString[0] == 0)
+                    if(wString.isEmpty())
                     {
                         Reference<XAccessibleRelationSet> pRrelationSet = pRContext->getAccessibleRelationSet();
                         if(!pRrelationSet.is())
@@ -727,19 +727,18 @@ STDMETHODIMP CMAccessible::get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKe
                             return S_FALSE;
 
                         ::rtl::OUString ouStr = pRXIE->getTitledBorderText();
-                        WCHAR key[2] = {NULL};
-                        GetMnemonicChar(ouStr, key);
-                        if(key[0] != 0)
+                        sal_Unicode key;
+                        if(GetMnemonicChar(ouStr, &key))
                         {
-                            wcscat(wString, L"Alt+");
-                            wcscat(wString, key);
+                            wString = "Alt+" + OUStringLiteral1(key);
                         }
                         else
                             return S_FALSE;
                     }
 
                     SAFE_SYSFREESTRING(*pszKeyboardShortcut);
-                    *pszKeyboardShortcut = SysAllocString(wString);
+                    *pszKeyboardShortcut = SysAllocString(
+                        reinterpret_cast<wchar_t const *>(wString.getStr()));
 
                     return S_OK;
                 }
@@ -2661,83 +2660,69 @@ CMAccessible::get_IAccessibleFromXAccessible(XAccessible * pXAcc, IAccessible **
         LEAVE_PROTECTED_BLOCK
 }
 
-void CMAccessible::get_OLECHARFromAny(Any& pAny, OLECHAR* pChar)
+OUString CMAccessible::get_StringFromAny(Any& pAny)
 {
-    // #CHECK#
-    if(pChar == nullptr)
-        return;
-
     switch(pAny.getValueTypeClass())
     {
     case TypeClass_CHAR:
         {
             sal_Int8 val;
             pAny >>= val;
-            swprintf( pChar, L"%d", val);
-            break;
+            return OUString::number(val);
         }
     case TypeClass_BOOLEAN:
         {
             bool val;
             pAny >>= val;
-            swprintf( pChar, L"%d", val);
-            break;
+            return OUString::number(int(val));
         }
     case TypeClass_BYTE:
         {
             sal_Int8 val;
             pAny >>= val;
-            swprintf( pChar, L"%d", val);
-            break;
+            return OUString::number(val);
         }
     case TypeClass_SHORT:
         {
-            SHORT val;
+            sal_Int16 val;
             pAny >>= val;
-            swprintf( pChar, L"%d", val);
-            break;
+            return OUString::number(val);
         }
     case TypeClass_UNSIGNED_SHORT:
         {
-            USHORT val;
+            sal_uInt16 val;
             pAny >>= val;
-            swprintf( pChar, L"%d", val);
-            break;
+            return OUString::number(val);
         }
     case TypeClass_LONG:
         {
-            LONG val;
+            sal_Int32 val;
             pAny >>= val;
-            swprintf( pChar, L"%ld", val);
-            break;
+            return OUString::number(val);
         }
     case TypeClass_UNSIGNED_LONG:
         {
-            ULONG val;
+            sal_uInt32 val;
             pAny >>= val;
-            swprintf( pChar, L"%ld", val);
-            break;
+            return OUString::number(val);
         }
     case TypeClass_FLOAT:
         {
-            FLOAT val;
+            float val;
             pAny >>= val;
-            swprintf( pChar, L"%.3f", val);
-            break;
+            return OUString::number(val);
         }
     case TypeClass_DOUBLE:
         {
-            DOUBLE val;
+            double val;
             pAny >>= val;
-            swprintf( pChar, L"%.6lf", val);
-            break;
+            return OUString::number(val);
         }
     case TypeClass_STRING:
         {
             ::rtl::OUString val;
             pAny >>= val;
-            wcscpy(pChar, SAL_W(val.getStr()));
-            break;
+            return val;
         }
     case TypeClass_SEQUENCE:
         {
@@ -2746,15 +2731,15 @@ void CMAccessible::get_OLECHARFromAny(Any& pAny, OLECHAR* pChar)
                 Sequence < ::rtl::OUString > val;
                 pAny >>= val;
 
-                ::rtl::OUString pString;
+                ::rtl::OUStringBuffer pString;
 
                 int count = val.getLength();
 
                 for( int iIndex = 0;iIndex < count;iIndex++ )
                 {
-                    pString += val[iIndex];
+                    pString.append(val[iIndex]);
                 }
-                wcscpy(pChar, SAL_W(pString.getStr()));
+                return pString.makeStringAndClear();
             }
             else if (pAny.getValueType() == cppu::UnoType<Sequence< css::style::TabStop >>::get())
             {
@@ -2762,35 +2747,32 @@ void CMAccessible::get_OLECHARFromAny(Any& pAny, OLECHAR* pChar)
                 pAny >>= val;
                 int count = val.getLength();
 
+                OUStringBuffer buf;
                 for( int iIndex = 0;iIndex < count;iIndex++ )
                 {
-                    OLECHAR pAttrs[512] = {NULL};
-
-                    OLECHAR pAttrsPosition[512] = {NULL};
-                    OLECHAR pAttrsDescimalChar[512] = {NULL};
-                    OLECHAR pAttrsFillChar[512] = {NULL};
-
                     css::style::TabStop sigleVal = val[iIndex];
 
-                    swprintf( pAttrsPosition, L"Position=%ld,TabAlign=%ld",
-                        sigleVal.Position, sigleVal.Alignment);
+                    buf.append("Position=");
+                    buf.append(sigleVal.Position);
+                    buf.append(",TabAlign=");
+                    buf.append(sal_Int32(sigleVal.Alignment));
+                    buf.append(",");
 
+                    buf.append("DecimalChar=");
                     if(sigleVal.DecimalChar==';' || sigleVal.DecimalChar == ':' || sigleVal.DecimalChar == ',' ||
                         sigleVal.DecimalChar == '=' || sigleVal.DecimalChar == '\\')
-                        swprintf( pAttrsDescimalChar, L"DecimalChar=\\%c",sigleVal.DecimalChar);
-                    else
-                        swprintf( pAttrsDescimalChar, L"DecimalChar=%c",sigleVal.DecimalChar);
+                        buf.append('\\');
+                    buf.append(sigleVal.DecimalChar);
+                    buf.append(",");
 
+                    buf.append("FillChar=");
                     if(sigleVal.FillChar==';' || sigleVal.FillChar == ':' || sigleVal.FillChar == ',' ||
                         sigleVal.FillChar == '=' || sigleVal.FillChar == '\\')
-                        swprintf( pAttrsFillChar, L"FillChar=\\%c",sigleVal.FillChar);
-                    else
-                        swprintf( pAttrsFillChar, L"FillChar=%c",sigleVal.FillChar);
-
-                    swprintf( pAttrs, L"%s,%s,%s,",pAttrsPosition,pAttrsDescimalChar,pAttrsFillChar);
-
-                    wcscat(pChar,pAttrs);
+                        buf.append('\\');
+                    buf.append(sigleVal.FillChar);
+                    buf.append(",");
                 }
+                return buf.makeStringAndClear();
             }
             break;
         }
@@ -2800,7 +2782,7 @@ void CMAccessible::get_OLECHARFromAny(Any& pAny, OLECHAR* pChar)
             {
                 css::awt::FontSlant val;
                 pAny >>= val;
-                swprintf( pChar, L"%d", val);
+                return OUString::number(sal_Int32(val));
             }
             break;
         }
@@ -2810,14 +2792,14 @@ void CMAccessible::get_OLECHARFromAny(Any& pAny, OLECHAR* pChar)
             {
                 css::style::LineSpacing val;
                 pAny >>= val;
-                swprintf( pChar, L"Mode=%ld,Height=%ld,", val.Mode, val.Height);
+                return "Mode=" + OUString::number(val.Mode) + ",Height="
+                    + OUString::number(val.Height) + ",";
             }
             else if (pAny.getValueType() == cppu::UnoType<css::accessibility::TextSegment>::get())
             {
                 css::accessibility::TextSegment val;
                 pAny >>= val;
-                ::rtl::OUString realVal(val.SegmentText);
-                wcscpy(pChar, SAL_W(realVal.getStr()));
+                return val.SegmentText;
             }
             break;
         }
@@ -2842,12 +2824,11 @@ void CMAccessible::get_OLECHARFromAny(Any& pAny, OLECHAR* pChar)
     default:
         break;
     }
+    return OUString();
 }
 
-void CMAccessible::get_OLECHAR4Numbering(const Any& pAny, short numberingLevel,const OUString& numberingPrefix,OLECHAR* pChar)
+OUString CMAccessible::get_String4Numbering(const Any& pAny, sal_Int16 numberingLevel,const OUString& numberingPrefix)
 {
-    if(pChar == nullptr)
-        return;
     Reference< css::container::XIndexReplace > pXIndex;
     if((pAny>>=pXIndex) && (numberingLevel !=-1))//numbering level is -1,means invalid value
     {
@@ -2856,7 +2837,9 @@ void CMAccessible::get_OLECHAR4Numbering(const Any& pAny, short numberingLevel,c
         aAny >>= aProps;
         const css::beans::PropertyValue* pPropArray = aProps.getConstArray();
         sal_Int32 nCount = aProps.getLength();
-        swprintf(pChar,L"Numbering:NumberingLevel=%d,",numberingLevel);
+        OUStringBuffer buf("Numbering:NumberingLevel=");
+        buf.append(sal_Int32(numberingLevel));
+        buf.append(',');
         for( sal_Int32 i=0; i<nCount; i++ )
         {
             css::beans::PropertyValue rProp = pPropArray[i];
@@ -2864,30 +2847,40 @@ void CMAccessible::get_OLECHAR4Numbering(const Any& pAny, short numberingLevel,c
                 (rProp.Name == "GraphicURL" ) ||
                 (rProp.Name == "NumberingType" ))
             {
-                OLECHAR propStr[512] = {NULL};
-                swprintf(propStr,L"%s=",rProp.Name.getStr());
-                OLECHAR pTemp[256] = {NULL};
-                CMAccessible::get_OLECHARFromAny(rProp.Value,pTemp);
+                buf.append(rProp.Name);
+                buf.append('=');
+                auto const pTemp = CMAccessible::get_StringFromAny(rProp.Value);
                 if(rProp.Name == "GraphicURL")
                 {
-                    OLECHAR* pOccur = wcschr(pTemp,':');
-                    if(pOccur)
-                        *pOccur = '.';
+                    auto const pOccur = pTemp.indexOf(':');
+                    if(pOccur != -1)
+                    {
+                        buf.append(pTemp.copy(0, pOccur));
+                        buf.append('.');
+                        buf.append(pTemp.copy(pOccur + 1));
+                    }
+                    else
+                    {
+                        buf.append(pTemp);
+                    }
+                }
+                else
+                {
+                    buf.append(pTemp);
                 }
-                wcscat(propStr,pTemp);
-                wcscat(pChar,propStr);
-                wcscat(pChar,L",");
+                buf.append(',');
 
                 if(rProp.Name == "NumberingType")
                 {
                     if(numberingPrefix.getLength()!=0)
                     {
-                        swprintf(pTemp,L"NumberingPrefix=%s,",numberingPrefix.getStr());
-                        wcscat(pChar,pTemp);
+                        buf.append("NumberingPrefix=");
+                        buf.append(numberingPrefix);
                     }
                 }
             }
         }
+        return buf.makeStringAndClear();
     }
 
     //Because now have three types numbering level:
@@ -2898,11 +2891,11 @@ void CMAccessible::get_OLECHAR4Numbering(const Any& pAny, short numberingLevel,c
     // so NumberingLevel value will be decreased 1 in bridge code.
     else if(numberingLevel >0)
     {
-        swprintf(pChar,L"Numbering:NumberingLevel=%d,NumberingType=4,NumberingPrefix=,",numberingLevel-1);
+        return "Numbering:NumberingLevel=" + OUString::number(numberingLevel-1) + ",NumberingType=4,NumberingPrefix=,";
     }
     else
     {
-        swprintf(pChar,L"Numbering:");
+        return OUString("Numbering:");
     }
 }
 
@@ -2966,7 +2959,8 @@ void CMAccessible::ConvertAnyToVariant(const css::uno::Any &rAnyVal, VARIANT *pv
                 pvData->vt = VT_BSTR;
                 ::rtl::OUString val;
                 rAnyVal >>= val;
-                pvData->bstrVal = SysAllocString(SAL_W(val.getStr()));
+                pvData->bstrVal = SysAllocString(
+                    reinterpret_cast<wchar_t const *>(val.getStr()));
                 break;
             }
 
@@ -3019,7 +3013,7 @@ void CMAccessible::ConvertAnyToVariant(const css::uno::Any &rAnyVal, VARIANT *pv
         case TypeClass::TypeClass_MAKE_FIXED_SIZE:
             // Output the type string, if there is other uno value type.
             pvData->vt = VT_BSTR;
-            pvData->bstrVal = SysAllocString(SAL_W(rAnyVal.getValueTypeName().getStr()));
+            pvData->bstrVal = SysAllocString(reinterpret_cast<wchar_t const *>(rAnyVal.getValueTypeName().getStr()));
             break;
 
         default:
@@ -3133,9 +3127,12 @@ STDMETHODIMP CMAccessible:: get_locale( IA2Locale __RPC_FAR *locale  )
         return E_FAIL;
 
     css::lang::Locale unoLoc = m_xContext.get()->getLocale();
-    locale->language = SysAllocString(SAL_W(unoLoc.Language.getStr()));
-    locale->country = SysAllocString(SAL_W(unoLoc.Country.getStr()));
-    locale->variant = SysAllocString(SAL_W(unoLoc.Variant.getStr()));
+    locale->language = SysAllocString(
+        reinterpret_cast<wchar_t const *>(unoLoc.Language.getStr()));
+    locale->country = SysAllocString(
+        reinterpret_cast<wchar_t const *>(unoLoc.Country.getStr()));
+    locale->variant = SysAllocString(
+        reinterpret_cast<wchar_t const *>(unoLoc.Variant.getStr()));
 
     return S_OK;
 
@@ -3222,7 +3219,8 @@ STDMETHODIMP CMAccessible::get_attributes(/*[out]*/ BSTR *pAttr)
 
         if(*pAttr)
             SAFE_SYSFREESTRING(*pAttr);
-        *pAttr = SysAllocString(SAL_W(val.getStr()));
+        *pAttr = SysAllocString(
+            reinterpret_cast<wchar_t const *>(val.getStr()));
 
         return S_OK;
     }
diff --git a/winaccessibility/source/UAccCOM/MAccessible.h b/winaccessibility/source/UAccCOM/MAccessible.h
index 85d561a16eba..3c7ba3ee826e 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.h
+++ b/winaccessibility/source/UAccCOM/MAccessible.h
@@ -242,11 +242,10 @@ public:
         return static_cast<CMAccessible*>(pv)->SmartQI(pv,iid,ppvObject);
     }
 
-    static void get_OLECHARFromAny(css::uno::Any& pAny, OLECHAR* pChar);
+    static OUString get_StringFromAny(css::uno::Any& pAny);
 
-    static void get_OLECHAR4Numbering(const css::uno::Any& pAny,
-            short numberingLevel, const OUString& numberingPrefix,
-            OLECHAR* pChar);
+    static OUString get_String4Numbering(const css::uno::Any& pAny,
+            sal_Int16 numberingLevel, const OUString& numberingPrefix);
 
     // Helper function for data conversion.
     static void ConvertAnyToVariant(const css::uno::Any &rAnyVal,
diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx
index a2b1b0c26f4e..a80db3bd2d0b 100644
--- a/winaccessibility/source/service/AccObject.cxx
+++ b/winaccessibility/source/service/AccObject.cxx
@@ -272,16 +272,15 @@ void  AccObject::UpdateName( )
     }
 
     if( ( TEXT_FRAME == m_accRole   ) && ( m_pParentObj !=nullptr )&& ( SCROLL_PANE == m_pParentObj -> m_accRole ) )
-        m_pIMAcc->Put_XAccName( SAL_W(m_pParentObj->m_xAccContextRef->getAccessibleName().getStr()) );
+        m_pIMAcc->Put_XAccName( reinterpret_cast<wchar_t const *>(m_pParentObj->m_xAccContextRef->getAccessibleName().getStr()) );
     //IAccessibility2 Implementation 2009-----
     if ( PARAGRAPH == m_accRole)
     {
-        ::rtl::OUString emptyStr("");
-        m_pIMAcc->Put_XAccName(SAL_W(emptyStr.getStr()));
+        m_pIMAcc->Put_XAccName(L"");
     }
     //-----IAccessibility2 Implementation 2009
     else
-        m_pIMAcc->Put_XAccName(SAL_W(m_xAccContextRef->getAccessibleName().getStr()));
+        m_pIMAcc->Put_XAccName(reinterpret_cast<wchar_t const *>(m_xAccContextRef->getAccessibleName().getStr()));
 
     return ;
 }
@@ -298,7 +297,7 @@ void AccObject::UpdateDescription()
         return;
     }
 
-    m_pIMAcc->Put_XAccDescription(SAL_W(m_xAccContextRef->getAccessibleDescription().getStr()));
+    m_pIMAcc->Put_XAccDescription(reinterpret_cast<wchar_t const *>(m_xAccContextRef->getAccessibleDescription().getStr()));
     return ;
 }
 
@@ -367,7 +366,7 @@ void AccObject::UpdateDefaultAction( )
     case CHECK_BOX:
     case TREE_ITEM:
     case BUTTON_DROPDOWN:
-        m_pIMAcc->Put_ActionDescription( SAL_W(m_xAccActionRef->getAccessibleActionDescription((sal_Int32)0).getStr()) );
+        m_pIMAcc->Put_ActionDescription( reinterpret_cast<wchar_t const *>(m_xAccActionRef->getAccessibleActionDescription((sal_Int32)0).getStr()) );
         return;
     }
 }
@@ -403,19 +402,19 @@ void  AccObject::SetValue( Any pAny )
         {
             val = pRText->getText();
         }
-        m_pIMAcc->Put_XAccValue( SAL_W(val.getStr()) );
+        m_pIMAcc->Put_XAccValue( reinterpret_cast<wchar_t const *>(val.getStr()) );
         break;
     case TREE_ITEM:
     //case CHECK_BOX:   //Commented by Li Xing to disable the value for general checkbox
     case COMBO_BOX:
     case NOTE:
     case SCROLL_BAR:
-        m_pIMAcc->Put_XAccValue( SAL_W(GetMAccessibleValueFromAny(pAny).getStr()) );
+        m_pIMAcc->Put_XAccValue( reinterpret_cast<wchar_t const *>(GetMAccessibleValueFromAny(pAny).getStr()) );
         break ;
     // Added by Li Xing, only the checkbox in tree should have the value.
     case CHECK_BOX:
         if( ( m_pParentObj !=nullptr ) && (TREE == m_pParentObj->m_accRole || TREE_ITEM == m_pParentObj->m_accRole ))
-            m_pIMAcc->Put_XAccValue( SAL_W(GetMAccessibleValueFromAny(pAny).getStr()) );
+            m_pIMAcc->Put_XAccValue( reinterpret_cast<wchar_t const *>(GetMAccessibleValueFromAny(pAny).getStr()) );
         break;
     default:
         break;
@@ -501,7 +500,7 @@ void  AccObject::SetName( Any pAny)
     if( nullptr == m_pIMAcc )
         return ;
 
-    m_pIMAcc->Put_XAccName( SAL_W(GetMAccessibleValueFromAny(pAny).getStr()) );
+    m_pIMAcc->Put_XAccName( reinterpret_cast<wchar_t const *>(GetMAccessibleValueFromAny(pAny).getStr()) );
 
 }
 
@@ -514,7 +513,7 @@ void  AccObject::SetDescription( Any pAny )
 {
     if( nullptr == m_pIMAcc )
         return ;
-    m_pIMAcc->Put_XAccDescription( SAL_W(GetMAccessibleValueFromAny(pAny).getStr()) );
+    m_pIMAcc->Put_XAccDescription( reinterpret_cast<wchar_t const *>(GetMAccessibleValueFromAny(pAny).getStr()) );
 }
 
 /**
@@ -756,7 +755,7 @@ void AccObject::UpdateActionDesc()
     }
 
     ::rtl::OUString pXString = m_xAccContextRef->getAccessibleDescription();
-    m_pIMAcc->Put_XAccDescription(SAL_W(pXString.getStr()));
+    m_pIMAcc->Put_XAccDescription(reinterpret_cast<wchar_t const *>(pXString.getStr()));
     long Role = m_accRole;
 
     if(  Role == PUSH_BUTTON || Role == RADIO_BUTTON || Role == MENU_ITEM ||
@@ -778,7 +777,7 @@ void AccObject::UpdateActionDesc()
                     pXString = m_xAccActionRef->getAccessibleActionDescription( 0 );
                     //Solution: if string length is more than zero, action is set.
                     if( pXString.getLength() > 0)
-                        m_pIMAcc->Put_ActionDescription( SAL_W(pXString.getStr()) );
+                        m_pIMAcc->Put_ActionDescription( reinterpret_cast<wchar_t const *>(pXString.getStr()) );
                 }
             }
         }


More information about the Libreoffice-commits mailing list