vcl/headless/svpprn.cxx      |   39 +++------------------------------------
 vcl/qt5/QtInstance_Print.cxx |   39 +++------------------------------------
 2 files changed, 6 insertions(+), 72 deletions(-)

New commits:
commit 6623639d21838489736626812b663cc01ae6e422
Author:     Michael Weghorn <[email protected]>
AuthorDate: Mon Mar 2 03:16:34 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Mar 2 17:15:06 2026 +0100

    vcl: Consolidate to one getPdfDir helper
    
    Reuse the existing SalGenericInstance::getPdfDir
    in subclasses. The getPdfDir version they were
    using resembles the copy used in SalGenericInstance
    before
    
        commit 284e998aae8f65857a6ef8df965e03910fc4bef0
        Author: Matteo Casalin <[email protected]>
        Date:   Sat Jan 12 17:29:06 2019 +0100
    
            No need to loop twice on the same tokens
    
    , so adjust the calling code in subclasses as
    that commit had done in SalGenericInstance as well.
    
    Drop the now unused copies of the helper function.
    
    Change-Id: Id87c9952f55158fddee3d97038fc0cc7ecae02e0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200747
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx
index 1efa82544ebc..997148a76d2c 100644
--- a/vcl/headless/svpprn.cxx
+++ b/vcl/headless/svpprn.cxx
@@ -34,32 +34,6 @@
 
 using namespace psp;
 
-/*
- *  static helpers
- */
-
-static OUString getPdfDir( const PrinterInfo& rInfo )
-{
-    OUString aDir;
-    sal_Int32 nIndex = 0;
-    while( nIndex != -1 )
-    {
-        OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) );
-        if( aToken.startsWith( "pdf=" ) )
-        {
-            sal_Int32 nPos = 0;
-            aDir = aToken.getToken( 1, '=', nPos );
-            if( aDir.isEmpty() )
-                if (auto const env = getenv( "HOME" )) {
-                    aDir = OStringToOUString(
-                        std::string_view( env ), osl_getThreadTextEncoding() );
-                }
-            break;
-        }
-    }
-    return aDir;
-}
-
 static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
 {
     pJobSetup->SetOrientation( rData.m_eOrientation == orientation::Landscape 
? Orientation::Landscape : Orientation::Portrait );
@@ -207,16 +181,9 @@ void SvpSalInstance::GetPrinterQueueInfo( 
ImplPrnQueueList* pList )
         pInfo->maLocation       = rInfo.m_aLocation;
         pInfo->maComment        = rInfo.m_aComment;
 
-        sal_Int32 nIndex = 0;
-        while( nIndex != -1 )
-        {
-            OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) );
-            if( aToken.startsWith( "pdf=" ) )
-            {
-                pInfo->maLocation = ::getPdfDir(rInfo);
-                break;
-            }
-        }
+        OUString sPdfDir;
+        if (getPdfDir(rInfo, sPdfDir))
+            pInfo->maLocation = sPdfDir;
 
         pList->Add( std::move(pInfo) );
     }
diff --git a/vcl/qt5/QtInstance_Print.cxx b/vcl/qt5/QtInstance_Print.cxx
index f677bafe415f..397ec06c6119 100644
--- a/vcl/qt5/QtInstance_Print.cxx
+++ b/vcl/qt5/QtInstance_Print.cxx
@@ -31,32 +31,6 @@
 
 using namespace psp;
 
-/*
- *  static helpers
- */
-
-static OUString getPdfDir(const PrinterInfo& rInfo)
-{
-    OUString aDir;
-    sal_Int32 nIndex = 0;
-    while (nIndex != -1)
-    {
-        OUString aToken(rInfo.m_aFeatures.getToken(0, ',', nIndex));
-        if (aToken.startsWith("pdf="))
-        {
-            sal_Int32 nPos = 0;
-            aDir = aToken.getToken(1, '=', nPos);
-            if (aDir.isEmpty())
-                if (auto const env = getenv("HOME"))
-                {
-                    aDir = OStringToOUString(std::string_view(env), 
osl_getThreadTextEncoding());
-                }
-            break;
-        }
-    }
-    return aDir;
-}
-
 SalInfoPrinter* QtInstance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
                                               ImplJobSetup* pJobSetup)
 {
@@ -98,16 +72,9 @@ void QtInstance::GetPrinterQueueInfo(ImplPrnQueueList* pList)
         pInfo->maLocation = rInfo.m_aLocation;
         pInfo->maComment = rInfo.m_aComment;
 
-        sal_Int32 nIndex = 0;
-        while (nIndex != -1)
-        {
-            OUString aToken(rInfo.m_aFeatures.getToken(0, ',', nIndex));
-            if (aToken.startsWith("pdf="))
-            {
-                pInfo->maLocation = ::getPdfDir(rInfo);
-                break;
-            }
-        }
+        OUString sPdfDir;
+        if (getPdfDir(rInfo, sPdfDir))
+            pInfo->maLocation = sPdfDir;
 
         pList->Add(std::move(pInfo));
     }

Reply via email to