framework/inc/uielement/fontsizemenucontroller.hxx    |    2 
 framework/source/uielement/fontsizemenucontroller.cxx |   67 ++++--------------
 2 files changed, 19 insertions(+), 50 deletions(-)

New commits:
commit 7e40111f3c5258cbe884c19bcb6617ad342aa5f3
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Nov 29 10:53:14 2021 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Nov 29 18:42:15 2021 +0100

    pAry is always FontList::GetStdSizeAry()
    
    so the other branch is bogus, this is (more obvious) since...
    
    commit f5a81a119cb63152c2c2e2473a1ea183a30c8db9
    Date:   Tue Sep 21 07:19:15 2021 +1000
    
        vcl: remove OutputDevice's GetDevFontSizeCount() and GetDevFontSize()
    
    Change-Id: I587f4b0ee33129b611ff00265a835071a8332b8b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126034
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/framework/source/uielement/fontsizemenucontroller.cxx 
b/framework/source/uielement/fontsizemenucontroller.cxx
index bc9f0b28b779..4c5c686888a9 100644
--- a/framework/source/uielement/fontsizemenucontroller.cxx
+++ b/framework/source/uielement/fontsizemenucontroller.cxx
@@ -153,9 +153,6 @@ void FontSizeMenuController::fillPopupMenu( Reference< 
css::awt::XPopupMenu > co
     // setup font size array
     m_aHeightArray.clear();
 
-    const int* pTempAry;
-    const int* pAry = FontList::GetStdSizeAry();
-
     sal_uInt16 nPos = 0; // Id is nPos+1
     static const OUStringLiteral aFontHeightCommand( 
u".uno:FontHeight?FontHeight.Height:float=" );
 
@@ -163,54 +160,30 @@ void FontSizeMenuController::fillPopupMenu( Reference< 
css::awt::XPopupMenu > co
     FontSizeNames   aFontSizeNames( 
Application::GetSettings().GetUILanguageTag().getLanguageType() );
     OUString   aCommand;
 
-    if ( !aFontSizeNames.IsEmpty() )
+    if (!aFontSizeNames.IsEmpty())
     {
-        if ( pAry == FontList::GetStdSizeAry() )
+        // for scalable fonts all font size names
+        sal_Int32 nCount = aFontSizeNames.Count();
+        for( sal_Int32 i = 0; i < nCount; i++ )
         {
-            // for scalable fonts all font size names
-            sal_Int32 nCount = aFontSizeNames.Count();
-            for( sal_Int32 i = 0; i < nCount; i++ )
-            {
-                OUString aSizeName = aFontSizeNames.GetIndexName( i );
-                sal_Int32 nSize = aFontSizeNames.GetIndexSize( i );
-                m_aHeightArray.push_back(nSize);
-                rPopupMenu->insertItem(nPos + 1, aSizeName, 
css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, nPos);
+            OUString aSizeName = aFontSizeNames.GetIndexName( i );
+            sal_Int32 nSize = aFontSizeNames.GetIndexSize( i );
+            m_aHeightArray.push_back(nSize);
+            rPopupMenu->insertItem(nPos + 1, aSizeName, 
css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, nPos);
 
-                // Create dispatchable .uno command and set it
-                float fPoint = float(nSize) / 10;
-                aCommand = aFontHeightCommand + OUString::number( fPoint );
-                rPopupMenu->setCommand(nPos + 1, aCommand);
+            // Create dispatchable .uno command and set it
+            float fPoint = float(nSize) / 10;
+            aCommand = aFontHeightCommand + OUString::number( fPoint );
+            rPopupMenu->setCommand(nPos + 1, aCommand);
 
-                ++nPos;
-            }
-        }
-        else
-        {
-            // for fixed size fonts only selectable font size names
-            pTempAry = pAry;
-            while ( *pTempAry )
-            {
-                OUString aSizeName = aFontSizeNames.Size2Name( *pTempAry );
-                if ( !aSizeName.isEmpty() )
-                {
-                    m_aHeightArray.push_back(*pTempAry);
-                    rPopupMenu->insertItem(nPos + 1, aSizeName, 
css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, nPos);
-
-                    // Create dispatchable .uno command and set it
-                    float fPoint = float(*pTempAry) / 10;
-                    aCommand = aFontHeightCommand + OUString::number( fPoint );
-                    rPopupMenu->setCommand(nPos + 1, aCommand);
-
-                    ++nPos;
-                }
-                pTempAry++;
-            }
+            ++nPos;
         }
     }
 
     // then insert numerical font size values
     const vcl::I18nHelper& rI18nHelper = 
Application::GetSettings().GetUILocaleI18nHelper();
-    pTempAry = pAry;
+    const int* pAry = FontList::GetStdSizeAry();
+    const int* pTempAry = pAry;
     while ( *pTempAry )
     {
         m_aHeightArray.push_back(*pTempAry);
commit 20685a37e53bbe82bf4d3d6b0b7d94b104dfdfb9
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Nov 29 10:45:42 2021 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Nov 29 18:41:58 2021 +0100

    m_pHeightArray can be a std::vector
    
    Change-Id: I406aadb0a907fc2ac554c88ce8dc60c4d444a1a3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126033
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/framework/inc/uielement/fontsizemenucontroller.hxx 
b/framework/inc/uielement/fontsizemenucontroller.hxx
index 28e64aa5741c..16d29a885db0 100644
--- a/framework/inc/uielement/fontsizemenucontroller.hxx
+++ b/framework/inc/uielement/fontsizemenucontroller.hxx
@@ -59,7 +59,7 @@ namespace framework
             void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > 
const & rPopupMenu );
             OUString retrievePrinterName( css::uno::Reference< 
css::frame::XFrame > const & rFrame );
 
-            std::unique_ptr<tools::Long[]>                   m_pHeightArray;
+            std::vector<tools::Long>                         m_aHeightArray;
             css::frame::status::FontHeight                   m_aFontHeight;
             css::uno::Reference< css::frame::XDispatch >     
m_xCurrentFontDispatch;
     };
diff --git a/framework/source/uielement/fontsizemenucontroller.cxx 
b/framework/source/uielement/fontsizemenucontroller.cxx
index 1d5d83967188..bc9f0b28b779 100644
--- a/framework/source/uielement/fontsizemenucontroller.cxx
+++ b/framework/source/uielement/fontsizemenucontroller.cxx
@@ -113,7 +113,7 @@ void FontSizeMenuController::setCurHeight( tools::Long 
nHeight, Reference< css::
     {
         sal_uInt16 nItemId = rPopupMenu->getItemId( i );
 
-        if ( m_pHeightArray[i] == nHeight )
+        if ( m_aHeightArray[i] == nHeight )
         {
             rPopupMenu->checkItem( nItemId, true );
             return;
@@ -151,20 +151,16 @@ void FontSizeMenuController::fillPopupMenu( Reference< 
css::awt::XPopupMenu > co
         pFontList.reset(new FontList( Application::GetDefaultDevice() ));
 
     // setup font size array
-    m_pHeightArray.reset();
+    m_aHeightArray.clear();
 
     const int* pTempAry;
     const int* pAry = FontList::GetStdSizeAry();
-    sal_uInt16 nSizeCount = 0;
-    while ( pAry[nSizeCount] )
-        nSizeCount++;
 
     sal_uInt16 nPos = 0; // Id is nPos+1
     static const OUStringLiteral aFontHeightCommand( 
u".uno:FontHeight?FontHeight.Height:float=" );
 
     // first insert font size names (for simplified/traditional chinese)
     FontSizeNames   aFontSizeNames( 
Application::GetSettings().GetUILanguageTag().getLanguageType() );
-    m_pHeightArray.reset(new tools::Long[nSizeCount + aFontSizeNames.Count()]);
     OUString   aCommand;
 
     if ( !aFontSizeNames.IsEmpty() )
@@ -177,7 +173,7 @@ void FontSizeMenuController::fillPopupMenu( Reference< 
css::awt::XPopupMenu > co
             {
                 OUString aSizeName = aFontSizeNames.GetIndexName( i );
                 sal_Int32 nSize = aFontSizeNames.GetIndexSize( i );
-                m_pHeightArray[nPos] = nSize;
+                m_aHeightArray.push_back(nSize);
                 rPopupMenu->insertItem(nPos + 1, aSizeName, 
css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, nPos);
 
                 // Create dispatchable .uno command and set it
@@ -197,7 +193,7 @@ void FontSizeMenuController::fillPopupMenu( Reference< 
css::awt::XPopupMenu > co
                 OUString aSizeName = aFontSizeNames.Size2Name( *pTempAry );
                 if ( !aSizeName.isEmpty() )
                 {
-                    m_pHeightArray[nPos] = *pTempAry;
+                    m_aHeightArray.push_back(*pTempAry);
                     rPopupMenu->insertItem(nPos + 1, aSizeName, 
css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, nPos);
 
                     // Create dispatchable .uno command and set it
@@ -217,7 +213,7 @@ void FontSizeMenuController::fillPopupMenu( Reference< 
css::awt::XPopupMenu > co
     pTempAry = pAry;
     while ( *pTempAry )
     {
-        m_pHeightArray[nPos] = *pTempAry;
+        m_aHeightArray.push_back(*pTempAry);
         rPopupMenu->insertItem(nPos + 1, rI18nHelper.GetNum(*pTempAry, 1, 
true, false),
                                css::awt::MenuItemStyle::RADIOCHECK | 
css::awt::MenuItemStyle::AUTOCHECK, nPos);
 

Reply via email to