forms/source/component/clickableimage.cxx          |    2 
 forms/source/helper/controlfeatureinterception.cxx |    4 -
 forms/source/helper/formnavigation.cxx             |   81 ++++++++-------------
 forms/source/helper/urltransformer.cxx             |    6 -
 forms/source/inc/controlfeatureinterception.hxx    |    2 
 forms/source/inc/formnavigation.hxx                |    4 -
 forms/source/inc/frm_strings.hxx                   |   24 ------
 forms/source/inc/urltransformer.hxx                |    5 -
 8 files changed, 39 insertions(+), 89 deletions(-)

New commits:
commit f2545fffcbdd9d88a57abd4842719b40d0ed45ec
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed May 8 09:56:13 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat May 11 19:27:55 2024 +0200

    replace createFromAscii with OUString literals in ControlFeatureInterception
    
    Change-Id: If0fbaafbaa318ec541341fde723f92f3e8e92cfa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167510
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/forms/source/component/clickableimage.cxx 
b/forms/source/component/clickableimage.cxx
index 6ab579072e1b..9d57272274a0 100644
--- a/forms/source/component/clickableimage.cxx
+++ b/forms/source/component/clickableimage.cxx
@@ -233,7 +233,7 @@ namespace frm
             case FormButtonType_SUBMIT:
             {
                 // if some outer component can provide an interaction handler, 
use it
-                Reference< XInteractionHandler > xHandler( 
m_aFeatureInterception.queryDispatch( "private:/InteractionHandler" ), 
UNO_QUERY );
+                Reference< XInteractionHandler > xHandler( 
m_aFeatureInterception.queryDispatch( u"private:/InteractionHandler"_ustr ), 
UNO_QUERY );
                 try
                 {
                     implSubmit( rEvt, xHandler );
diff --git a/forms/source/helper/controlfeatureinterception.cxx 
b/forms/source/helper/controlfeatureinterception.cxx
index e8a4ebb337d3..c83b61308395 100644
--- a/forms/source/helper/controlfeatureinterception.cxx
+++ b/forms/source/helper/controlfeatureinterception.cxx
@@ -133,9 +133,9 @@ namespace frm
     }
 
 
-    Reference< XDispatch > ControlFeatureInterception::queryDispatch( const 
char* _pAsciiURL )
+    Reference< XDispatch > ControlFeatureInterception::queryDispatch( const 
OUString& _rURL )
     {
-        return queryDispatch( m_pUrlTransformer->getStrictURLFromAscii( 
_pAsciiURL ) );
+        return queryDispatch( m_pUrlTransformer->getStrictURL( _rURL ) );
     }
 
 
diff --git a/forms/source/helper/formnavigation.cxx 
b/forms/source/helper/formnavigation.cxx
index a43287463b40..8178382d5fb5 100644
--- a/forms/source/helper/formnavigation.cxx
+++ b/forms/source/helper/formnavigation.cxx
@@ -364,11 +364,11 @@ namespace frm
     bool OFormNavigationMapper::getFeatureURL( sal_Int16 _nFeatureId, URL& /* 
[out] */ _rURL )
     {
         // get the ascii version of the URL
-        const char* pAsciiURL = getFeatureURLAscii( _nFeatureId );
+        std::optional<OUString> pAsciiURL = getFeatureURL( _nFeatureId );
         if ( pAsciiURL )
-            _rURL = m_pUrlTransformer->getStrictURLFromAscii( pAsciiURL );
+            _rURL = m_pUrlTransformer->getStrictURL( *pAsciiURL );
 
-        return ( pAsciiURL != nullptr );
+        return pAsciiURL.has_value();
     }
 
 
@@ -377,65 +377,50 @@ namespace frm
         struct FeatureURL
         {
             const sal_Int16 nFormFeature;
-            const char*     pAsciiURL;
-
-            FeatureURL( const sal_Int16 _nFormFeature, const char* _pAsciiURL )
-                :nFormFeature( _nFormFeature )
-                ,pAsciiURL( _pAsciiURL )
-            {
-            }
+            OUString   aAsciiURL;
         };
-        const FeatureURL* lcl_getFeatureTable()
+        constexpr FeatureURL s_aFeatureURLs[]
         {
-            static const FeatureURL s_aFeatureURLs[] =
-            {
-                FeatureURL( FormFeature::MoveAbsolute,            
URL_FORM_POSITION ),
-                FeatureURL( FormFeature::TotalRecords,            
URL_FORM_RECORDCOUNT ),
-                FeatureURL( FormFeature::MoveToFirst,             
URL_RECORD_FIRST ),
-                FeatureURL( FormFeature::MoveToPrevious,          
URL_RECORD_PREV ),
-                FeatureURL( FormFeature::MoveToNext,              
URL_RECORD_NEXT ),
-                FeatureURL( FormFeature::MoveToLast,              
URL_RECORD_LAST ),
-                FeatureURL( FormFeature::SaveRecordChanges,       
URL_RECORD_SAVE ),
-                FeatureURL( FormFeature::UndoRecordChanges,       
URL_RECORD_UNDO ),
-                FeatureURL( FormFeature::MoveToInsertRow,         
URL_RECORD_NEW ),
-                FeatureURL( FormFeature::DeleteRecord,            
URL_RECORD_DELETE ),
-                FeatureURL( FormFeature::ReloadForm,              
URL_FORM_REFRESH ),
-                FeatureURL( FormFeature::RefreshCurrentControl,   
URL_FORM_REFRESH_CURRENT_CONTROL ),
-                FeatureURL( FormFeature::SortAscending,           
URL_FORM_SORT_UP ),
-                FeatureURL( FormFeature::SortDescending,          
URL_FORM_SORT_DOWN ),
-                FeatureURL( FormFeature::InteractiveSort,         
URL_FORM_SORT ),
-                FeatureURL( FormFeature::AutoFilter,              
URL_FORM_AUTO_FILTER ),
-                FeatureURL( FormFeature::InteractiveFilter,       
URL_FORM_FILTER ),
-                FeatureURL( FormFeature::ToggleApplyFilter,       
URL_FORM_APPLY_FILTER ),
-                FeatureURL( FormFeature::RemoveFilterAndSort,     
URL_FORM_REMOVE_FILTER ),
-                FeatureURL( 0, nullptr )
-            };
-            return s_aFeatureURLs;
-        }
+            { FormFeature::MoveAbsolute,            
u".uno:FormController/positionForm"_ustr },
+            { FormFeature::TotalRecords,            
u".uno:FormController/RecordCount"_ustr },
+            { FormFeature::MoveToFirst,             
u".uno:FormController/moveToFirst"_ustr },
+            { FormFeature::MoveToPrevious,          
u".uno:FormController/moveToPrev"_ustr },
+            { FormFeature::MoveToNext,              
u".uno:FormController/moveToNext"_ustr },
+            { FormFeature::MoveToLast,              
u".uno:FormController/moveToLast"_ustr },
+            { FormFeature::SaveRecordChanges,       
u".uno:FormController/saveRecord"_ustr },
+            { FormFeature::UndoRecordChanges,       
u".uno:FormController/undoRecord"_ustr },
+            { FormFeature::MoveToInsertRow,         
u".uno:FormController/moveToNew"_ustr },
+            { FormFeature::DeleteRecord,            
u".uno:FormController/deleteRecord"_ustr },
+            { FormFeature::ReloadForm,              
u".uno:FormController/refreshForm"_ustr },
+            { FormFeature::RefreshCurrentControl,   
u".uno:FormController/refreshCurrentControl"_ustr },
+            { FormFeature::SortAscending,           
u".uno:FormController/sortUp"_ustr },
+            { FormFeature::SortDescending,          
u".uno:FormController/sortDown"_ustr },
+            { FormFeature::InteractiveSort,         
u".uno:FormController/sort"_ustr },
+            { FormFeature::AutoFilter,              
u".uno:FormController/autoFilter"_ustr },
+            { FormFeature::InteractiveFilter,       
u".uno:FormController/filter"_ustr },
+            { FormFeature::ToggleApplyFilter,       
u".uno:FormController/applyFilter"_ustr },
+            { FormFeature::RemoveFilterAndSort,     
u".uno:FormController/removeFilterOrder"_ustr },
+        };
     }
 
 
-    const char* OFormNavigationMapper::getFeatureURLAscii( sal_Int16 
_nFeatureId )
+    std::optional<OUString> OFormNavigationMapper::getFeatureURL( sal_Int16 
_nFeatureId )
     {
-        const FeatureURL* pFeatures = lcl_getFeatureTable();
-        while ( pFeatures->pAsciiURL )
+        for (const FeatureURL& rFeature : s_aFeatureURLs)
         {
-            if ( pFeatures->nFormFeature == _nFeatureId )
-                return pFeatures->pAsciiURL;
-            ++pFeatures;
+            if ( rFeature.nFormFeature == _nFeatureId )
+                return rFeature.aAsciiURL;
         }
-        return nullptr;
+        return std::nullopt;
     }
 
 
     sal_Int16 OFormNavigationMapper::getFeatureId( std::u16string_view 
_rCompleteURL )
     {
-        const FeatureURL* pFeatures = lcl_getFeatureTable();
-        while ( pFeatures->pAsciiURL )
+        for (const FeatureURL& rFeature : s_aFeatureURLs)
         {
-            if ( o3tl::equalsAscii( _rCompleteURL, pFeatures->pAsciiURL ) )
-                return pFeatures->nFormFeature;
-            ++pFeatures;
+            if ( rFeature.aAsciiURL == _rCompleteURL )
+                return rFeature.nFormFeature;
         }
         return -1;
     }
diff --git a/forms/source/helper/urltransformer.cxx 
b/forms/source/helper/urltransformer.cxx
index e112041c2256..0ce12c63ee46 100644
--- a/forms/source/helper/urltransformer.cxx
+++ b/forms/source/helper/urltransformer.cxx
@@ -65,12 +65,6 @@ namespace frm
     }
 
 
-    URL UrlTransformer::getStrictURLFromAscii( const char* _pAsciiURL ) const
-    {
-        return getStrictURL( OUString::createFromAscii( _pAsciiURL ) );
-    }
-
-
     void UrlTransformer::parseSmartWithProtocol( css::util::URL& _rURL, const 
OUString& _rProtocol ) const
     {
         if ( implEnsureTransformer() )
diff --git a/forms/source/inc/controlfeatureinterception.hxx 
b/forms/source/inc/controlfeatureinterception.hxx
index 1e58ffb63233..8603a4594e2d 100644
--- a/forms/source/inc/controlfeatureinterception.hxx
+++ b/forms/source/inc/controlfeatureinterception.hxx
@@ -77,7 +77,7 @@ namespace frm
             with a blank target frame and no frame search flags
         */
         css::uno::Reference< css::frame::XDispatch >
-            queryDispatch( const char* _pAsciiURL );
+            queryDispatch( const OUString& _rURL );
     };
 
 
diff --git a/forms/source/inc/formnavigation.hxx 
b/forms/source/inc/formnavigation.hxx
index a0ef8a0b638e..50f313325b24 100644
--- a/forms/source/inc/formnavigation.hxx
+++ b/forms/source/inc/formnavigation.hxx
@@ -28,7 +28,7 @@
 #include <vector>
 #include <map>
 #include <memory>
-
+#include <optional>
 
 namespace frm
 {
@@ -185,7 +185,7 @@ namespace frm
             @complexity O(log n)
             @return NULL if the given id is not a known feature id (which is a 
valid usage)
         */
-        static const char* getFeatureURLAscii( sal_Int16 _nFeatureId );
+        static std::optional<OUString> getFeatureURL( sal_Int16 _nFeatureId );
 
         /** retrieves the feature URL belonging to a feature id
 
diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx
index 90edf195d20e..709f3529db9d 100644
--- a/forms/source/inc/frm_strings.hxx
+++ b/forms/source/inc/frm_strings.hxx
@@ -260,28 +260,4 @@ inline constexpr OUString PROPERTY_CONTROL_TYPE_IN_MSO = 
u"ControlTypeinMSO"_ust
 inline constexpr OUString PROPERTY_OBJ_ID_IN_MSO = u"ObjIDinMSO"_ustr;
 
 
-//- URLs
-
-#define URL_FORM_POSITION     ".uno:FormController/positionForm"
-#define URL_FORM_RECORDCOUNT  ".uno:FormController/RecordCount"
-#define URL_RECORD_FIRST      ".uno:FormController/moveToFirst"
-#define URL_RECORD_PREV       ".uno:FormController/moveToPrev"
-#define URL_RECORD_NEXT       ".uno:FormController/moveToNext"
-#define URL_RECORD_LAST       ".uno:FormController/moveToLast"
-#define URL_RECORD_SAVE       ".uno:FormController/saveRecord"
-#define URL_RECORD_UNDO       ".uno:FormController/undoRecord"
-#define URL_RECORD_NEW        ".uno:FormController/moveToNew"
-#define URL_RECORD_DELETE     ".uno:FormController/deleteRecord"
-#define URL_FORM_REFRESH      ".uno:FormController/refreshForm"
-#define URL_FORM_REFRESH_CURRENT_CONTROL 
".uno:FormController/refreshCurrentControl"
-
-#define URL_FORM_SORT_UP      ".uno:FormController/sortUp"
-#define URL_FORM_SORT_DOWN    ".uno:FormController/sortDown"
-#define URL_FORM_SORT         ".uno:FormController/sort"
-#define URL_FORM_AUTO_FILTER  ".uno:FormController/autoFilter"
-#define URL_FORM_FILTER       ".uno:FormController/filter"
-#define URL_FORM_APPLY_FILTER ".uno:FormController/applyFilter"
-#define URL_FORM_REMOVE_FILTER ".uno:FormController/removeFilterOrder"
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/inc/urltransformer.hxx 
b/forms/source/inc/urltransformer.hxx
index 3cfe225945bb..5855cac23be2 100644
--- a/forms/source/inc/urltransformer.hxx
+++ b/forms/source/inc/urltransformer.hxx
@@ -44,11 +44,6 @@ namespace frm
         css::util::URL
             getStrictURL( const OUString& _rURL ) const;
 
-        /** returns a URL object for the given URL ASCII string
-        */
-        css::util::URL
-            getStrictURLFromAscii( const char* _pAsciiURL ) const;
-
         /** parses a given URL smartly, with a given protocol
         */
         void

Reply via email to