filter/source/pdf/impdialog.cxx                      |   22 ++++-------
 filter/source/pdf/pdfexport.cxx                      |    4 --
 filter/source/t602/t602filter.cxx                    |   16 ++------
 filter/source/t602/t602filter.hxx                    |    4 --
 filter/source/xsltdialog/xmlfiltercommon.hxx         |    2 -
 filter/source/xsltdialog/xmlfiltersettingsdialog.cxx |   38 ++++++++-----------
 filter/source/xsltdialog/xmlfiltertabdialog.cxx      |    3 -
 7 files changed, 32 insertions(+), 57 deletions(-)

New commits:
commit 5e3e507b1a68f5b9883337f1e55c54c2fc9de9fc
Author:     Kevin Suo <suokunl...@126.com>
AuthorDate: Mon Oct 24 10:42:05 2022 +0800
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Oct 24 12:41:00 2022 +0200

    Drop {PDFFilterResId, getResStr, XsltResId} and use FilterResId in "filter"
    
    This is a followup to commit a97bae545d72d8b19f39aa9280c0f284c79d0f6c.
    
    Previously different areas within the "filter" module used their own 
"*ResId" code
    to get the translated string. They did the same thing without any 
difference in
    purpose and implementation.
    
    Unify this to use FilterResId instead.
    
    Change-Id: Idccf74601a89b5786e1f61a04631436147710bb9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141692
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index f5f128fbb508..eaa3385ab16f 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -24,7 +24,6 @@
 #include <vcl/svapp.hxx>
 #include <vcl/weld.hxx>
 #include <sfx2/passwd.hxx>
-#include <unotools/resmgr.hxx>
 #include <comphelper/diagnose_ex.hxx>
 #include <sfx2/objsh.hxx>
 #include <svx/AccessibilityCheckDialog.hxx>
@@ -42,11 +41,6 @@
 #include <com/sun/star/beans/XMaterialHolder.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 
-static OUString PDFFilterResId(TranslateId aId)
-{
-    return Translate::get(aId, Translate::Create("flt"));
-}
-
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 
@@ -863,7 +857,7 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, 
TogglePDFVersionOrUniversalAccessibilityHa
         {
             std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(m_xContainer.get(),
                                                       VclMessageType::Warning, 
VclButtonsType::Ok,
-                                                      
PDFFilterResId(STR_WARN_PASSWORD_PDFA)));
+                                                      
FilterResId(STR_WARN_PASSWORD_PDFA)));
             xBox->run();
         }
     }
@@ -1114,10 +1108,10 @@ void ImpPDFTabViewerPage::SetFilterConfigItem( const  
ImpPDFTabDialog* pParent )
 /// The Security preferences tab page
 ImpPDFTabSecurityPage::ImpPDFTabSecurityPage(weld::Container* pPage, 
weld::DialogController* pController, const SfxItemSet& i_rCoreSet)
     : SfxTabPage(pPage, pController, "filter/ui/pdfsecuritypage.ui", 
"PdfSecurityPage", &i_rCoreSet)
-    , msUserPwdTitle( PDFFilterResId( STR_PDF_EXPORT_UDPWD ) )
+    , msUserPwdTitle( FilterResId( STR_PDF_EXPORT_UDPWD ) )
     , mbHaveOwnerPassword( false )
     , mbHaveUserPassword( false )
-    , msOwnerPwdTitle( PDFFilterResId( STR_PDF_EXPORT_ODPWD ) )
+    , msOwnerPwdTitle( FilterResId( STR_PDF_EXPORT_ODPWD ) )
     , mxPbSetPwd(m_xBuilder->weld_button("setpassword"))
     , mxUserPwdSet(m_xBuilder->weld_widget("userpwdset"))
     , mxUserPwdUnset(m_xBuilder->weld_widget("userpwdunset"))
@@ -1485,19 +1479,19 @@ ImplErrorDialog::ImplErrorDialog(weld::Window* pParent, 
const std::set<vcl::PDFW
         switch(error)
         {
         case vcl::PDFWriter::Warning_Transparency_Omitted_PDFA:
-            m_xErrors->append(PDFFilterResId(STR_WARN_TRANSP_PDFA), 
PDFFilterResId(STR_WARN_TRANSP_PDFA_SHORT), "dialog-warning");
+            m_xErrors->append(FilterResId(STR_WARN_TRANSP_PDFA), 
FilterResId(STR_WARN_TRANSP_PDFA_SHORT), "dialog-warning");
             break;
         case vcl::PDFWriter::Warning_Transparency_Omitted_PDF13:
-            m_xErrors->append(PDFFilterResId(STR_WARN_TRANSP_VERSION), 
PDFFilterResId(STR_WARN_TRANSP_VERSION_SHORT), "dialog-warning");
+            m_xErrors->append(FilterResId(STR_WARN_TRANSP_VERSION), 
FilterResId(STR_WARN_TRANSP_VERSION_SHORT), "dialog-warning");
             break;
         case vcl::PDFWriter::Warning_FormAction_Omitted_PDFA:
-            m_xErrors->append(PDFFilterResId(STR_WARN_FORMACTION_PDFA), 
PDFFilterResId(STR_WARN_FORMACTION_PDFA_SHORT), "dialog-warning");
+            m_xErrors->append(FilterResId(STR_WARN_FORMACTION_PDFA), 
FilterResId(STR_WARN_FORMACTION_PDFA_SHORT), "dialog-warning");
             break;
         case vcl::PDFWriter::Warning_Transparency_Converted:
-            m_xErrors->append(PDFFilterResId(STR_WARN_TRANSP_CONVERTED), 
PDFFilterResId(STR_WARN_TRANSP_CONVERTED_SHORT), "dialog-warning");
+            m_xErrors->append(FilterResId(STR_WARN_TRANSP_CONVERTED), 
FilterResId(STR_WARN_TRANSP_CONVERTED_SHORT), "dialog-warning");
             break;
         case vcl::PDFWriter::Error_Signature_Failed:
-            m_xErrors->append(PDFFilterResId(STR_ERR_PDF_EXPORT_ABORTED), 
PDFFilterResId(STR_ERR_SIGNATURE_FAILED), "dialog-error");
+            m_xErrors->append(FilterResId(STR_ERR_PDF_EXPORT_ABORTED), 
FilterResId(STR_ERR_SIGNATURE_FAILED), "dialog-error");
             break;
         default:
             break;
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 4184d429333a..b02c200e7e85 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -23,7 +23,6 @@
 #include <tools/urlobj.hxx>
 #include <tools/poly.hxx>
 #include <comphelper/diagnose_ex.hxx>
-#include <unotools/resmgr.hxx>
 #include <utility>
 #include <vcl/canvastools.hxx>
 #include <vcl/mapmod.hxx>
@@ -981,11 +980,10 @@ bool PDFExport::Export( const OUString& rFile, const 
Sequence< PropertyValue >&
 
                 if ( mxStatusIndicator.is() )
                 {
-                    std::locale loc(Translate::Create("flt"));
                     sal_Int32 nTotalPageCount = aRangeEnum.size();
                     if ( bExportPages && bExportNotesPages )
                         nTotalPageCount *= 2;
-                    mxStatusIndicator->start(Translate::get(PDF_PROGRESS_BAR, 
loc), nTotalPageCount);
+                    mxStatusIndicator->start(FilterResId(PDF_PROGRESS_BAR), 
nTotalPageCount);
                 }
 
                 bRet = nPageCount > 0;
diff --git a/filter/source/t602/t602filter.cxx 
b/filter/source/t602/t602filter.cxx
index 7aced676430f..bea3d11b834b 100644
--- a/filter/source/t602/t602filter.cxx
+++ b/filter/source/t602/t602filter.cxx
@@ -35,7 +35,6 @@
 #include <osl/diagnose.h>
 #include <rtl/ref.hxx>
 #include <rtl/character.hxx>
-#include <unotools/resmgr.hxx>
 #include <unotools/streamwrap.hxx>
 #include <utility>
 
@@ -900,7 +899,7 @@ bool T602ImportFilterDialog::OptionsDlg()
     any <<= OUString(_val);\
     _prop->setPropertyValue(_nam, any);
 #define propStringFromResId_(_prop,_nam,_val) \
-    any <<= getResStr(_val);\
+    any <<= FilterResId(_val);\
     _prop->setPropertyValue(_nam, any);
 #define propGet_(_prop,_nam) \
     _prop->getPropertyValue(_nam);
@@ -953,10 +952,10 @@ bool T602ImportFilterDialog::OptionsDlg()
 
     Sequence< OUString > ous
     {
-        getResStr(T602FILTER_STR_ENCODING_AUTO),
-        getResStr(T602FILTER_STR_ENCODING_CP852),
-        getResStr(T602FILTER_STR_ENCODING_CP895),
-        getResStr(T602FILTER_STR_ENCODING_KOI8CS2)
+        FilterResId(T602FILTER_STR_ENCODING_AUTO),
+        FilterResId(T602FILTER_STR_ENCODING_CP852),
+        FilterResId(T602FILTER_STR_ENCODING_CP895),
+        FilterResId(T602FILTER_STR_ENCODING_KOI8CS2)
     };
     any <<= ous;
     xPSetCodeLB->setPropertyValue("StringItemList", any);
@@ -1078,11 +1077,6 @@ sal_Int16 SAL_CALL T602ImportFilterDialog::execute()
         return css::ui::dialogs::ExecutableDialogResults::CANCEL;
 }
 
-OUString T602ImportFilterDialog::getResStr(TranslateId resid)
-{
-    return Translate::get(resid, maResLocale);
-}
-
 uno::Sequence<beans::PropertyValue> SAL_CALL 
T602ImportFilterDialog::getPropertyValues()
 {
     return uno::Sequence<beans::PropertyValue>();
diff --git a/filter/source/t602/t602filter.hxx 
b/filter/source/t602/t602filter.hxx
index 26fa088faa4b..461876142a7e 100644
--- a/filter/source/t602/t602filter.hxx
+++ b/filter/source/t602/t602filter.hxx
@@ -34,7 +34,6 @@
 #include <xmloff/attrlist.hxx>
 #include <i18nlangtag/languagetag.hxx>
 #include <rtl/ref.hxx>
-#include <unotools/resmgr.hxx>
 
 namespace T602ImportFilter {
 
@@ -85,8 +84,7 @@ class T602ImportFilterDialog : public cppu::WeakImplHelper <
 {
     LanguageTag maLocale;
     std::locale maResLocale;
-    bool OptionsDlg();
-    OUString getResStr(TranslateId resid);
+    static bool OptionsDlg();
 
     virtual ~T602ImportFilterDialog() override;
 
diff --git a/filter/source/xsltdialog/xmlfiltercommon.hxx 
b/filter/source/xsltdialog/xmlfiltercommon.hxx
index 4ac225183e60..9482fb0b2b63 100644
--- a/filter/source/xsltdialog/xmlfiltercommon.hxx
+++ b/filter/source/xsltdialog/xmlfiltercommon.hxx
@@ -20,7 +20,6 @@
 
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
-#include <unotools/resmgr.hxx>
 
 #include <string_view>
 #include <vector>
@@ -78,6 +77,5 @@ struct application_info_impl
 extern std::vector< application_info_impl > const & getApplicationInfos();
 extern OUString getApplicationUIName( std::u16string_view rServiceName );
 extern const application_info_impl* getApplicationInfo( std::u16string_view 
rServiceName );
-OUString XsltResId(TranslateId pId);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx 
b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
index ab22263694d2..ce06b716e20b 100644
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
@@ -30,7 +30,6 @@
 #include <comphelper/diagnose_ex.hxx>
 #include <tools/urlobj.hxx>
 #include <unotools/pathoptions.hxx>
-#include <unotools/resmgr.hxx>
 #include <unotools/streamwrap.hxx>
 #include <osl/file.hxx>
 #include <o3tl/enumrange.hxx>
@@ -61,11 +60,6 @@ using namespace com::sun::star::util;
 
 using ::rtl::Uri;
 
-OUString XsltResId(TranslateId aId)
-{
-    return Translate::get(aId, Translate::Create("flt"));
-}
-
 XMLFilterSettingsDialog::XMLFilterSettingsDialog(weld::Window* pParent,
         const css::uno::Reference<css::uno::XComponentContext>& rxContext)
     : GenericDialogController(pParent, "filter/ui/xmlfiltersettings.ui", 
"XMLFilterSettingsDialog")
@@ -88,7 +82,7 @@ 
XMLFilterSettingsDialog::XMLFilterSettingsDialog(weld::Window* pParent,
 
     m_xFilterListBox->connect_changed( LINK( this, XMLFilterSettingsDialog, 
SelectionChangedHdl_Impl ) );
     m_xFilterListBox->connect_row_activated( LINK( this, 
XMLFilterSettingsDialog, DoubleClickHdl_Impl ) );
-    m_xFilterListBox->set_accessible_name(XsltResId(STR_XML_FILTER_LISTBOX));
+    m_xFilterListBox->set_accessible_name(FilterResId(STR_XML_FILTER_LISTBOX));
 
     m_xPBNew->connect_clicked(LINK( this, XMLFilterSettingsDialog, 
ClickHdl_Impl ) );
     m_xPBEdit->connect_clicked(LINK( this, XMLFilterSettingsDialog, 
ClickHdl_Impl ) );
@@ -209,13 +203,13 @@ void XMLFilterSettingsDialog::onNew()
     filter_info_impl aTempInfo;
 
     // create a unique filter name
-    aTempInfo.maFilterName = 
createUniqueFilterName(XsltResId(STR_DEFAULT_FILTER_NAME));
+    aTempInfo.maFilterName = 
createUniqueFilterName(FilterResId(STR_DEFAULT_FILTER_NAME));
 
     // init default extension
     aTempInfo.maExtension = STR_DEFAULT_EXTENSION;
 
     // set default ui name
-    aTempInfo.maInterfaceName = 
createUniqueInterfaceName(XsltResId(STR_DEFAULT_UI_NAME));
+    aTempInfo.maInterfaceName = 
createUniqueInterfaceName(FilterResId(STR_DEFAULT_UI_NAME));
 
     // set default application
     aTempInfo.maDocumentService = "com.sun.star.text.TextDocument";
@@ -730,7 +724,7 @@ void XMLFilterSettingsDialog::onDelete()
     filter_info_impl* pInfo = 
weld::fromId<filter_info_impl*>(m_xFilterListBox->get_id(nIndex));
     if (pInfo)
     {
-        OUString aMessage(XsltResId(STR_WARN_DELETE));
+        OUString aMessage(FilterResId(STR_WARN_DELETE));
         aMessage = aMessage.replaceFirst( "%s", pInfo->maFilterName );
 
         std::unique_ptr<weld::MessageDialog> 
xWarn(Application::CreateMessageDialog(m_xDialog.get(),
@@ -835,7 +829,7 @@ void XMLFilterSettingsDialog::onSave()
     aDlg.SetContext(sfx2::FileDialogHelper::XMLFilterSettings);
 
     OUString aExtensions( "*.jar" );
-    OUString aFilterName = XsltResId(STR_FILTER_PACKAGE) +
+    OUString aFilterName = FilterResId(STR_FILTER_PACKAGE) +
         " (" + aExtensions + ")";
 
     aDlg.AddFilter( aFilterName, aExtensions );
@@ -853,13 +847,13 @@ void XMLFilterSettingsDialog::onSave()
     OUString aMsg;
     if( nFilters > 0 )
     {
-        aMsg = XsltResId(STR_FILTERS_HAVE_BEEN_SAVED);
+        aMsg = FilterResId(STR_FILTERS_HAVE_BEEN_SAVED);
         aMsg = aMsg.replaceFirst( sPlaceholder, OUString::number( nFilters ) );
         aMsg = aMsg.replaceFirst(sPlaceholder, aURL.GetLastName());
     }
     else
     {
-        aMsg = XsltResId(STR_FILTER_HAS_BEEN_SAVED);
+        aMsg = FilterResId(STR_FILTER_HAS_BEEN_SAVED);
         aMsg = aMsg.replaceFirst( sPlaceholder, 
(*aFilters.begin())->maFilterName );
         aMsg = aMsg.replaceFirst(sPlaceholder, aURL.GetLastName());
     }
@@ -881,7 +875,7 @@ void XMLFilterSettingsDialog::onOpen()
     aDlg.SetContext(sfx2::FileDialogHelper::XMLFilterSettings);
 
     OUString aExtensions( "*.jar" );
-    OUString aFilterName = XsltResId(STR_FILTER_PACKAGE) +
+    OUString aFilterName = FilterResId(STR_FILTER_PACKAGE) +
         " (" + aExtensions + ")";
 
     aDlg.AddFilter( aFilterName, aExtensions );
@@ -914,18 +908,18 @@ void XMLFilterSettingsDialog::onOpen()
     if( nFilters == 0 )
     {
         INetURLObject aURLObj( aURL );
-        aMsg = XsltResId(STR_NO_FILTERS_FOUND);
+        aMsg = FilterResId(STR_NO_FILTERS_FOUND);
         aMsg = aMsg.replaceFirst(sPlaceholder, aURLObj.GetLastName());
     }
     else if( nFilters == 1 )
     {
-        aMsg = XsltResId(STR_FILTER_INSTALLED);
+        aMsg = FilterResId(STR_FILTER_INSTALLED);
         aMsg = aMsg.replaceFirst( sPlaceholder, aFilterName );
 
     }
     else
     {
-        aMsg = XsltResId(STR_FILTERS_INSTALLED);
+        aMsg = FilterResId(STR_FILTERS_INSTALLED);
         aMsg = aMsg.replaceFirst( sPlaceholder, OUString::number( nFilters ) );
     }
 
@@ -1197,7 +1191,7 @@ OUString getApplicationUIName( std::u16string_view 
rServiceName )
     }
     else
     {
-        OUString aRet = XsltResId(STR_UNKNOWN_APPLICATION);
+        OUString aRet = FilterResId(STR_UNKNOWN_APPLICATION);
         if( !rServiceName.empty() )
         {
             aRet += OUString::Concat(" (") + rServiceName + ")";
@@ -1243,20 +1237,20 @@ OUString XMLFilterSettingsDialog::getEntryString( const 
filter_info_impl* pInfo
     {
         if( pInfo->maFlags & 2 )
         {
-            aEntryStr += XsltResId(STR_IMPORT_EXPORT);
+            aEntryStr += FilterResId(STR_IMPORT_EXPORT);
         }
         else
         {
-            aEntryStr += XsltResId(STR_IMPORT_ONLY);
+            aEntryStr += FilterResId(STR_IMPORT_ONLY);
         }
     }
     else if( pInfo->maFlags & 2 )
     {
-        aEntryStr += XsltResId(STR_EXPORT_ONLY);
+        aEntryStr += FilterResId(STR_EXPORT_ONLY);
     }
     else
     {
-        aEntryStr += XsltResId(STR_UNDEFINED_FILTER);
+        aEntryStr += FilterResId(STR_UNDEFINED_FILTER);
     }
 
     return aEntryStr;
diff --git a/filter/source/xsltdialog/xmlfiltertabdialog.cxx 
b/filter/source/xsltdialog/xmlfiltertabdialog.cxx
index 675c7998a3ce..d7f9df437656 100644
--- a/filter/source/xsltdialog/xmlfiltertabdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltertabdialog.cxx
@@ -25,7 +25,6 @@
 #include <vcl/svapp.hxx>
 #include <vcl/weld.hxx>
 #include <osl/file.hxx>
-#include <unotools/resmgr.hxx>
 
 #include <strings.hrc>
 #include "xmlfiltertabdialog.hxx"
@@ -225,7 +224,7 @@ bool XMLFilterTabDialog::onOk()
     {
         m_xTabCtrl->set_current_page(sErrorPage);
 
-        OUString aMessage(XsltResId(pErrorId));
+        OUString aMessage(FilterResId(pErrorId));
 
         if( aReplace2.getLength() )
         {

Reply via email to