diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2009-06-12 09:36:34 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2009-06-12 09:36:34 +0000 |
commit | 4a3b7bff01e0e97e88f7718314208c4c7d262276 (patch) | |
tree | 30f31d397a265bcd4a059e1ee2527a8efdf28352 /vcl/unx | |
parent | f06a4979f9e2474d1b0e446121cdec03eaf070cf (diff) |
CWS-TOOLING: integrate CWS unifypaper01
2009-05-27 17:14:41 +0200 cmc r272362 : #i92819#, psprint moved into vcl
2009-05-19 15:45:46 +0200 cmc r272083 : #i92819# having difficultly in getting this right under windows
2009-05-18 18:04:22 +0200 cmc r272043 : #i92819# missing some export magic somewhere
2009-05-18 15:34:18 +0200 cmc r272028 : #i92819# get depends right
2009-05-18 11:50:43 +0200 cmc r272010 : ##i92819# fix import/export stuff
2009-05-18 10:07:00 +0200 cmc r272000 : #i92819# fix window imp name
2009-05-16 15:17:23 +0200 cmc r271975 : #i92819# fix win paper names
2009-05-16 11:11:29 +0200 cmc r271974 : #i92819# std::abs prolematic for msvc
2009-05-15 15:36:56 +0200 cmc r271941 : #i92819# handle missing setting, at least on mac
2009-05-15 10:13:44 +0200 cmc r271927 : #i92819# adjust for moved page dialog
2009-05-14 13:47:14 +0200 cmc r271887 : remove dead files that reappeared
2009-05-14 09:57:17 +0200 cmc r271872 : CWS-TOOLING: rebase CWS unifypaper01 to trunk@271830 (milestone: DEV300:m48)
2009-05-11 12:27:18 +0200 cmc r271763 : #i92819# check return value
2009-05-06 17:28:25 +0200 cmc r271602 : #i92819# these B4/B5s are the JIS ones according to their dimensions
2009-05-06 17:17:03 +0200 cmc r271601 : #i92819# micro-optimization
2009-05-03 18:20:48 +0200 cmc r271434 : #i92819# paper libs
2009-05-03 16:08:32 +0200 cmc r271433 : CWS-TOOLING: rebase CWS unifypaper01 to trunk@271427 (milestone: DEV300:m47)
2009-04-06 15:33:37 +0200 cmc r270556 : CWS-TOOLING: rebase CWS unifypaper01 to trunk@270033 (milestone: DEV300:m45)
2009-03-12 14:36:35 +0100 cmc r269415 : #i92819# merge paper utilities
2009-03-11 13:44:27 +0100 cmc r269328 : CWS-TOOLING: rebase CWS unifypaper01 to trunk@269297 (milestone: DEV300:m43)
2009-03-09 14:42:07 +0100 cmc r269190 : remove config_office from synced version
2009-03-09 14:34:50 +0100 cmc r269187 : CWS-TOOLING: rebase CWS unifypaper01 to trunk@268395 (milestone: DEV300:m42)
2009-03-09 12:11:29 +0100 cmc r269077 : CWS-TOOLING: rebase CWS unifypaper01 to trunk@265758 (milestone: DEV300:m38)
2009-03-06 17:17:39 +0100 cmc r269027 : #i92819# paper goo
2008-12-04 11:29:30 +0100 cmc r264826 : CWS-TOOLING: rebase CWS unifypaper01 to trunk@264807 (milestone: DEV300:m37)
2008-11-26 10:33:06 +0100 cmc r264357 : CWS-TOOLING: rebase CWS unifypaper01 to trunk@264325 (milestone: DEV300:m36)
2008-11-21 14:09:36 +0100 cmc r264138 : #i92819# paper consolidation
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); } // ----------------------------------------------------------------- |