Kaydet (Commit) 4edf26c3 authored tarafından Matteo Casalin's avatar Matteo Casalin

Reduce OUString operations

Change-Id: Ibc27a460b3394a90fc8ceef824acff87a80fd2cb
Reviewed-on: https://gerrit.libreoffice.org/66235
Tested-by: Jenkins
Reviewed-by: 's avatarMatteo Casalin <matteo.casalin@yahoo.com>
üst 6bedf7bd
...@@ -132,9 +132,8 @@ namespace ...@@ -132,9 +132,8 @@ namespace
int QueryFaxNumber(OUString& rNumber) int QueryFaxNumber(OUString& rNumber)
{ {
OUString aTmpString(VclResId(SV_PRINT_QUERYFAXNUMBER_TXT));
vcl::Window* pWin = Application::GetDefDialogParent(); vcl::Window* pWin = Application::GetDefDialogParent();
QueryString aQuery(pWin ? pWin->GetFrameWeld() : nullptr, aTmpString, rNumber); QueryString aQuery(pWin ? pWin->GetFrameWeld() : nullptr, VclResId(SV_PRINT_QUERYFAXNUMBER_TXT), rNumber);
return aQuery.run(); return aQuery.run();
} }
} }
...@@ -182,7 +181,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) ...@@ -182,7 +181,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
pJobSetup->SetPaperBin( 0 ); pJobSetup->SetPaperBin( 0 );
if( rData.m_pParser ) if( rData.m_pParser )
pKey = rData.m_pParser->getKey( OUString("InputSlot") ); pKey = rData.m_pParser->getKey( "InputSlot" );
if( pKey ) if( pKey )
pValue = rData.m_aContext.getValue( pKey ); pValue = rData.m_aContext.getValue( pKey );
if( pKey && pValue ) if( pKey && pValue )
...@@ -202,7 +201,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) ...@@ -202,7 +201,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
pJobSetup->SetDuplexMode( DuplexMode::Unknown ); pJobSetup->SetDuplexMode( DuplexMode::Unknown );
if( rData.m_pParser ) if( rData.m_pParser )
pKey = rData.m_pParser->getKey( OUString("Duplex") ); pKey = rData.m_pParser->getKey( "Duplex" );
if( pKey ) if( pKey )
pValue = rData.m_aContext.getValue( pKey ); pValue = rData.m_aContext.getValue( pKey );
if( pKey && pValue ) if( pKey && pValue )
...@@ -334,13 +333,8 @@ static std::vector<OUString> getFaxNumbers() ...@@ -334,13 +333,8 @@ static std::vector<OUString> getFaxNumbers()
OUString aNewNr; OUString aNewNr;
if (QueryFaxNumber(aNewNr)) if (QueryFaxNumber(aNewNr))
{ {
sal_Int32 nIndex = 0; for (sal_Int32 nIndex {0}; nIndex >= 0; )
do aFaxNumbers.push_back(aNewNr.getToken( 0, ';', nIndex ));
{
OUString sToken = aNewNr.getToken( 0, ';', nIndex );
aFaxNumbers.push_back(sToken);
}
while (nIndex >= 0);
} }
return aFaxNumbers; return aFaxNumbers;
...@@ -348,10 +342,7 @@ static std::vector<OUString> getFaxNumbers() ...@@ -348,10 +342,7 @@ static std::vector<OUString> getFaxNumbers()
static bool createPdf( const OUString& rToFile, const OUString& rFromFile, const OUString& rCommandLine ) static bool createPdf( const OUString& rToFile, const OUString& rFromFile, const OUString& rCommandLine )
{ {
OUString aCommandLine( return passFileToCommandLine( rFromFile, rCommandLine.replaceAll("(OUTFILE)", rToFile) );
rCommandLine.replaceAll("(OUTFILE)", rToFile));
return passFileToCommandLine( rFromFile, aCommandLine );
} }
/* /*
...@@ -469,7 +460,7 @@ void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* ) ...@@ -469,7 +460,7 @@ void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* )
if( m_aJobData.m_pParser ) if( m_aJobData.m_pParser )
{ {
const PPDKey* pKey = m_aJobData.m_pParser->getKey( OUString("PageSize") ); const PPDKey* pKey = m_aJobData.m_pParser->getKey( "PageSize" );
if( pKey ) if( pKey )
{ {
int nValues = pKey->countValues(); int nValues = pKey->countValues();
...@@ -593,7 +584,7 @@ bool PspSalInfoPrinter::SetData( ...@@ -593,7 +584,7 @@ bool PspSalInfoPrinter::SetData(
else else
aPaper = OStringToOUString(PaperInfo::toPSName(pJobSetup->GetPaperFormat()), RTL_TEXTENCODING_ISO_8859_1); aPaper = OStringToOUString(PaperInfo::toPSName(pJobSetup->GetPaperFormat()), RTL_TEXTENCODING_ISO_8859_1);
pKey = aData.m_pParser->getKey( OUString("PageSize") ); pKey = aData.m_pParser->getKey( "PageSize" );
pValue = pKey ? pKey->getValueCaseInsensitive( aPaper ) : nullptr; pValue = pKey ? pKey->getValueCaseInsensitive( aPaper ) : nullptr;
// some PPD files do not specify the standard paper names (e.g. C5 instead of EnvC5) // some PPD files do not specify the standard paper names (e.g. C5 instead of EnvC5)
...@@ -614,7 +605,7 @@ bool PspSalInfoPrinter::SetData( ...@@ -614,7 +605,7 @@ bool PspSalInfoPrinter::SetData(
// merge paperbin if necessary // merge paperbin if necessary
if( nSetDataFlags & JobSetFlags::PAPERBIN ) if( nSetDataFlags & JobSetFlags::PAPERBIN )
{ {
pKey = aData.m_pParser->getKey( OUString("InputSlot") ); pKey = aData.m_pParser->getKey( "InputSlot" );
if( pKey ) if( pKey )
{ {
int nPaperBin = pJobSetup->GetPaperBin(); int nPaperBin = pJobSetup->GetPaperBin();
...@@ -638,22 +629,22 @@ bool PspSalInfoPrinter::SetData( ...@@ -638,22 +629,22 @@ bool PspSalInfoPrinter::SetData(
// merge duplex if necessary // merge duplex if necessary
if( nSetDataFlags & JobSetFlags::DUPLEXMODE ) if( nSetDataFlags & JobSetFlags::DUPLEXMODE )
{ {
pKey = aData.m_pParser->getKey( OUString("Duplex") ); pKey = aData.m_pParser->getKey( "Duplex" );
if( pKey ) if( pKey )
{ {
pValue = nullptr; pValue = nullptr;
switch( pJobSetup->GetDuplexMode() ) switch( pJobSetup->GetDuplexMode() )
{ {
case DuplexMode::Off: case DuplexMode::Off:
pValue = pKey->getValue( OUString("None") ); pValue = pKey->getValue( "None" );
if( pValue == nullptr ) if( pValue == nullptr )
pValue = pKey->getValue( OUString("SimplexNoTumble") ); pValue = pKey->getValue( "SimplexNoTumble" );
break; break;
case DuplexMode::ShortEdge: case DuplexMode::ShortEdge:
pValue = pKey->getValue( OUString("DuplexTumble") ); pValue = pKey->getValue( "DuplexTumble" );
break; break;
case DuplexMode::LongEdge: case DuplexMode::LongEdge:
pValue = pKey->getValue( OUString("DuplexNoTumble") ); pValue = pKey->getValue( "DuplexNoTumble" );
break; break;
case DuplexMode::Unknown: case DuplexMode::Unknown:
default: default:
...@@ -725,7 +716,7 @@ sal_uInt16 PspSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup ) ...@@ -725,7 +716,7 @@ sal_uInt16 PspSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup )
JobData aData; JobData aData;
JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( OUString("InputSlot") ): nullptr; const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( "InputSlot" ): nullptr;
return pKey ? pKey->countValues() : 0; return pKey ? pKey->countValues() : 0;
} }
...@@ -734,21 +725,17 @@ OUString PspSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, sal_ ...@@ -734,21 +725,17 @@ OUString PspSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, sal_
JobData aData; JobData aData;
JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
OUString aRet;
if( aData.m_pParser ) if( aData.m_pParser )
{ {
const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( OUString("InputSlot") ): nullptr; const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( "InputSlot" ): nullptr;
if( ! pKey || nPaperBin >= static_cast<sal_uInt16>(pKey->countValues()) ) if( ! pKey || nPaperBin >= static_cast<sal_uInt16>(pKey->countValues()) )
aRet = aData.m_pParser->getDefaultInputSlot(); return aData.m_pParser->getDefaultInputSlot();
else const PPDValue* pValue = pKey->getValue( nPaperBin );
{ if( pValue )
const PPDValue* pValue = pKey->getValue( nPaperBin ); return aData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption );
if( pValue )
aRet = aData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption );
}
} }
return aRet; return OUString();
} }
sal_uInt32 PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, PrinterCapType nType ) sal_uInt32 PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, PrinterCapType nType )
...@@ -778,7 +765,7 @@ sal_uInt32 PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, Pr ...@@ -778,7 +765,7 @@ sal_uInt32 PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, Pr
JobData aData = PrinterInfoManager::get().getPrinterInfo(pJobSetup->GetPrinterName()); JobData aData = PrinterInfoManager::get().getPrinterInfo(pJobSetup->GetPrinterName());
if( pJobSetup->GetDriverData() ) if( pJobSetup->GetDriverData() )
JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey(OUString("Dial")) : nullptr; const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey("Dial") : nullptr;
const PPDValue* pValue = pKey ? aData.m_aContext.getValue(pKey) : nullptr; const PPDValue* pValue = pKey ? aData.m_aContext.getValue(pKey) : nullptr;
if (pValue && !pValue->m_aOption.equalsIgnoreAsciiCase("Manually")) if (pValue && !pValue->m_aOption.equalsIgnoreAsciiCase("Manually"))
return 1; return 1;
...@@ -880,13 +867,7 @@ bool PspSalPrinter::StartJob( ...@@ -880,13 +867,7 @@ bool PspSalPrinter::StartJob(
nMode = S_IRUSR | S_IWUSR; nMode = S_IRUSR | S_IWUSR;
if( m_aFileName.isEmpty() ) if( m_aFileName.isEmpty() )
{ m_aFileName = getPdfDir( rInfo ) + "/" + rJobName + ".pdf";
OUStringBuffer aFileName( getPdfDir( rInfo ) );
aFileName.append( '/' );
aFileName.append( rJobName );
aFileName.append( ".pdf" );
m_aFileName = aFileName.makeStringAndClear();
}
break; break;
} }
} }
...@@ -1000,7 +981,7 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo ...@@ -1000,7 +981,7 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo
// possibly create one job for collated output // possibly create one job for collated output
bool bSinglePrintJobs = false; bool bSinglePrintJobs = false;
beans::PropertyValue* pSingleValue = i_rController.getValue( OUString( "PrintCollateAsSingleJobs" ) ); beans::PropertyValue* pSingleValue = i_rController.getValue( "PrintCollateAsSingleJobs" );
if( pSingleValue ) if( pSingleValue )
{ {
pSingleValue->Value >>= bSinglePrintJobs; pSingleValue->Value >>= bSinglePrintJobs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment