diff options
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/headless/svpprn.cxx | 42 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salprnpsp.cxx | 43 | ||||
-rw-r--r-- | vcl/unx/source/printer/printerinfomanager.cxx | 76 |
3 files changed, 12 insertions, 149 deletions
diff --git a/vcl/unx/headless/svpprn.cxx b/vcl/unx/headless/svpprn.cxx index 862eb99ab18d..c3253ed163e8 100644 --- a/vcl/unx/headless/svpprn.cxx +++ b/vcl/unx/headless/svpprn.cxx @@ -73,37 +73,6 @@ inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*35.27777778 inline int TenMuToPt( int nUnits ) { return (int)((((double)nUnits)/35.27777778)+0.5); } -static struct -{ - int width; - int height; - const char* name; - int namelength; - Paper paper; -} aPaperTab[] = -{ - { 29700, 42000, "A3", 2, PAPER_A3 }, - { 21000, 29700, "A4", 2, PAPER_A4 }, - { 14800, 21000, "A5", 2, PAPER_A5 }, - { 25000, 35300, "B4", 2, PAPER_B4 }, - { 17600, 25000, "B5", 2, PAPER_B5 }, - { 21600, 27900, "Letter", 6, PAPER_LETTER }, - { 21600, 35600, "Legal", 5, PAPER_LEGAL }, - { 27900, 43100, "Tabloid", 7, PAPER_TABLOID }, - { 0, 0, "USER", 4, PAPER_USER } -}; - -static Paper getPaperType( const String& rPaperName ) -{ - ByteString aPaper( rPaperName, RTL_TEXTENCODING_ISO_8859_1 ); - for( unsigned int i = 0; i < sizeof( aPaperTab )/sizeof( aPaperTab[0] ); i++ ) - { - if( ! strcmp( aPaper.GetBuffer(), aPaperTab[i].name ) ) - return aPaperTab[i].paper; - } - return PAPER_USER; -} - static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) { pJobSetup->meOrientation = (Orientation)(rData.m_eOrientation == orientation::Landscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT); @@ -113,7 +82,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) int width, height; rData.m_aContext.getPageSize( aPaper, width, height ); - pJobSetup->mePaperFormat = getPaperType( aPaper ); + pJobSetup->mePaperFormat = PaperInfo::fromPSName(OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 )); pJobSetup->mnPaperWidth = 0; pJobSetup->mnPaperHeight = 0; if( pJobSetup->mePaperFormat == PAPER_USER ) @@ -475,14 +444,9 @@ void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* ) for( int i = 0; i < nValues; i++ ) { const PPDValue* pValue = pKey->getValue( i ); - vcl::PaperInfo aInfo; - aInfo.m_aPaperName = pValue->m_aOptionTranslation; - if( ! aInfo.m_aPaperName.Len() ) - aInfo.m_aPaperName = pValue->m_aOption; int nWidth = 0, nHeight = 0; m_aJobData.m_pParser->getPaperDimension( pValue->m_aOption, nWidth, nHeight ); - aInfo.m_nPaperWidth = (unsigned long)((PtTo10Mu( nWidth )+50)/100); - aInfo.m_nPaperHeight = (unsigned long)((PtTo10Mu( nHeight )+50)/100); + PaperInfo aInfo(PtTo10Mu( nWidth ), PtTo10Mu( nHeight )); m_aPaperFormats.push_back( aInfo ); } } @@ -628,7 +592,7 @@ BOOL PspSalInfoPrinter::SetData( TenMuToPt( pJobSetup->mnPaperWidth ), TenMuToPt( pJobSetup->mnPaperHeight ) ); else - aPaper = String( ByteString( aPaperTab[ pJobSetup->mePaperFormat ].name ), RTL_TEXTENCODING_ISO_8859_1 ); + aPaper = rtl::OStringToOUString(PaperInfo::toPSName(pJobSetup->mePaperFormat), RTL_TEXTENCODING_ISO_8859_1); pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) ); pValue = pKey ? pKey->getValue( aPaper ) : NULL; diff --git a/vcl/unx/source/gdi/salprnpsp.cxx b/vcl/unx/source/gdi/salprnpsp.cxx index 5f8c76fdb16f..2cf4e3baedd3 100644 --- a/vcl/unx/source/gdi/salprnpsp.cxx +++ b/vcl/unx/source/gdi/salprnpsp.cxx @@ -126,37 +126,6 @@ inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*35.27777778 inline int TenMuToPt( int nUnits ) { return (int)((((double)nUnits)/35.27777778)+0.5); } -static struct -{ - int width; - int height; - const char* name; - int namelength; - Paper paper; -} aPaperTab[] = -{ - { 29700, 42000, "A3", 2, PAPER_A3 }, - { 21000, 29700, "A4", 2, PAPER_A4 }, - { 14800, 21000, "A5", 2, PAPER_A5 }, - { 25000, 35300, "B4", 2, PAPER_B4 }, - { 17600, 25000, "B5", 2, PAPER_B5 }, - { 21600, 27900, "Letter", 6, PAPER_LETTER }, - { 21600, 35600, "Legal", 5, PAPER_LEGAL }, - { 27900, 43100, "Tabloid", 7, PAPER_TABLOID }, - { 0, 0, "USER", 4, PAPER_USER } -}; - -static Paper getPaperType( const String& rPaperName ) -{ - ByteString aPaper( rPaperName, RTL_TEXTENCODING_ISO_8859_1 ); - for( unsigned int i = 0; i < sizeof( aPaperTab )/sizeof( aPaperTab[0] ); i++ ) - { - if( ! rtl_str_compareIgnoreAsciiCase( aPaper.GetBuffer(), aPaperTab[i].name ) ) - return aPaperTab[i].paper; - } - return PAPER_USER; -} - static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) { pJobSetup->meOrientation = (Orientation)(rData.m_eOrientation == orientation::Landscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT); @@ -166,7 +135,8 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) int width, height; rData.m_aContext.getPageSize( aPaper, width, height ); - pJobSetup->mePaperFormat = getPaperType( aPaper ); + pJobSetup->mePaperFormat = PaperInfo::fromPSName(OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 )); + pJobSetup->mnPaperWidth = 0; pJobSetup->mnPaperHeight = 0; if( pJobSetup->mePaperFormat == PAPER_USER ) @@ -544,14 +514,9 @@ void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* ) for( int i = 0; i < nValues; i++ ) { const PPDValue* pValue = pKey->getValue( i ); - vcl::PaperInfo aInfo; - aInfo.m_aPaperName = pValue->m_aOptionTranslation; - if( ! aInfo.m_aPaperName.Len() ) - aInfo.m_aPaperName = pValue->m_aOption; int nWidth = 0, nHeight = 0; m_aJobData.m_pParser->getPaperDimension( pValue->m_aOption, nWidth, nHeight ); - aInfo.m_nPaperWidth = (unsigned long)((PtTo10Mu( nWidth )+50)/100); - aInfo.m_nPaperHeight = (unsigned long)((PtTo10Mu( nHeight )+50)/100); + PaperInfo aInfo(PtTo10Mu( nWidth ), PtTo10Mu( nHeight )); m_aPaperFormats.push_back( aInfo ); } } @@ -730,7 +695,7 @@ BOOL PspSalInfoPrinter::SetData( TenMuToPt( pJobSetup->mnPaperWidth ), TenMuToPt( pJobSetup->mnPaperHeight ) ); else - aPaper = String( ByteString( aPaperTab[ pJobSetup->mePaperFormat ].name ), RTL_TEXTENCODING_ISO_8859_1 ); + aPaper = rtl::OStringToOUString(PaperInfo::toPSName(pJobSetup->mePaperFormat), RTL_TEXTENCODING_ISO_8859_1); pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) ); pValue = pKey ? pKey->getValueCaseInsensitive( aPaper ) : NULL; diff --git a/vcl/unx/source/printer/printerinfomanager.cxx b/vcl/unx/source/printer/printerinfomanager.cxx index cf5a4a886c41..b3e5b4667a6a 100644 --- a/vcl/unx/source/printer/printerinfomanager.cxx +++ b/vcl/unx/source/printer/printerinfomanager.cxx @@ -44,6 +44,8 @@ #include "tools/debug.hxx" #include "tools/config.hxx" +#include "i18npool/paper.hxx" + #include "rtl/strbuf.hxx" #include "osl/thread.hxx" @@ -154,77 +156,9 @@ void PrinterInfoManager::setCUPSDisabled( bool bDisable ) void PrinterInfoManager::initSystemDefaultPaper() { - bool bSuccess = false; - - // try libpaper - - // #i78617# workaround missing paperconf command - FILE* pPipe = popen( "sh -c paperconf 2>/dev/null", "r" ); - if( pPipe ) - { - char pBuffer[ 1024 ]; - *pBuffer = 0; - fgets( pBuffer, sizeof(pBuffer)-1, pPipe ); - pclose( pPipe ); - - ByteString aPaper( pBuffer ); - aPaper = WhitespaceToSpace( aPaper ); - if( aPaper.Len() ) - { - m_aSystemDefaultPaper = OUString( OStringToOUString( aPaper, osl_getThreadTextEncoding() ) ); - bSuccess = true; - #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "paper from paperconf = %s\n", aPaper.GetBuffer() ); - #endif - } - if( bSuccess ) - return; - } - - // default value is Letter for US (en_US), Cannada (en_CA, fr_CA); else A4 - // en will be interpreted as en_US - - // note: at this point m_aSystemDefaultPaper is set to "A4" from the constructor - - // check for LC_PAPER - const char* pPaperLang = getenv( "LC_PAPER" ); - if( pPaperLang && *pPaperLang ) - { - OString aLang( pPaperLang ); - if( aLang.getLength() > 5 ) - aLang = aLang.copy( 0, 5 ); - if( aLang.getLength() == 5 ) - { - if( aLang.equalsIgnoreAsciiCase( "en_us" ) - || aLang.equalsIgnoreAsciiCase( "en_ca" ) - || aLang.equalsIgnoreAsciiCase( "fr_ca" ) - ) - m_aSystemDefaultPaper = OUString( RTL_CONSTASCII_USTRINGPARAM( "Letter" ) ); - } - else if( aLang.getLength() == 2 && aLang.equalsIgnoreAsciiCase( "en" ) ) - m_aSystemDefaultPaper = OUString( RTL_CONSTASCII_USTRINGPARAM( "Letter" ) ); - return; - } - - // use process locale to determine paper - rtl_Locale* pLoc = NULL; - osl_getProcessLocale( &pLoc ); - if( pLoc ) - { - if( 0 == rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pLoc->Language->buffer, pLoc->Language->length, "en") ) - { - if( 0 == rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pLoc->Country->buffer, pLoc->Country->length, "us") - || 0 == rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pLoc->Country->buffer, pLoc->Country->length, "ca") - || pLoc->Country->length == 0 - ) - m_aSystemDefaultPaper = OUString( RTL_CONSTASCII_USTRINGPARAM( "Letter" ) ); - } - else if( 0 == rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pLoc->Language->buffer, pLoc->Language->length, "fr") ) - { - if( 0 == rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pLoc->Country->buffer, pLoc->Country->length, "ca") ) - m_aSystemDefaultPaper = OUString( RTL_CONSTASCII_USTRINGPARAM( "Letter" ) ); - } - } + m_aSystemDefaultPaper = rtl::OStringToOUString( + PaperInfo::toPSName(PaperInfo::getSystemDefaultPaper().getPaper()), + RTL_TEXTENCODING_UTF8); } // ----------------------------------------------------------------- |