diff options
author | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2010-05-20 16:06:12 +0200 |
---|---|---|
committer | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2010-05-20 16:06:12 +0200 |
commit | 8c2460cc2c472d0edac48bd9a186f7d44a0563a6 (patch) | |
tree | 8b063a0056f476dbaa850c5f0278cdf6e42be110 /vcl/source/gdi | |
parent | e2c090708e089258087396d46acacf513f70e809 (diff) | |
parent | 51066323fd14918f65ea7ba66e14b9c7604eb978 (diff) |
rebase to DEV300_m78
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/bitmap.cxx | 18 | ||||
-rw-r--r-- | vcl/source/gdi/outdev3.cxx | 17 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/print3.cxx | 204 |
4 files changed, 188 insertions, 53 deletions
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index 51c76b5a4626..074935086b0b 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -323,7 +323,23 @@ BOOL Bitmap::HasGreyPalette() const BOOL bRet = FALSE; if( 1 == nBitCount ) - bRet = TRUE; + { + BitmapReadAccess* pRAcc = ( (Bitmap*) this )->AcquireReadAccess(); + + if( pRAcc ) + { + const BitmapColor& rCol0( pRAcc->GetPaletteColor( 0 ) ); + const BitmapColor& rCol1( pRAcc->GetPaletteColor( 1 ) ); + if( rCol0.GetRed() == rCol0.GetGreen() && rCol0.GetRed() == rCol0.GetBlue() && + rCol1.GetRed() == rCol1.GetGreen() && rCol1.GetRed() == rCol1.GetBlue() ) + { + bRet = TRUE; + } + ( (Bitmap*) this )->ReleaseAccess( pRAcc ); + } + else + bRet = TRUE; + } else if( 4 == nBitCount || 8 == nBitCount ) { BitmapReadAccess* pRAcc = ( (Bitmap*) this )->AcquireReadAccess(); diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 438f81bdc6c1..949d3df5275f 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -1673,6 +1673,18 @@ void ImplDevFontList::InitMatchData() const } } +//---------------------------------------------------------------------------- +ImplDevFontListData* ImplDevFontList::ImplFindByLocale(com::sun::star::lang::Locale lc) const +{ + // get the default font for a specified locale + const DefaultFontConfiguration& rDefaults = *DefaultFontConfiguration::get(); + String aDefault = rDefaults.getUserInterfaceFont( lc ); + ImplDevFontListData* pFontData = ImplFindByTokenNames( aDefault ); + if( pFontData ) + return pFontData; + return 0; +} + // ----------------------------------------------------------------------- ImplDevFontListData* ImplDevFontList::ImplFindByAttributes( ULONG nSearchType, @@ -2092,11 +2104,14 @@ ImplDevFontListData* ImplDevFontList::FindDefaultFont() const ImplDevFontList* ImplDevFontList::Clone( bool bScalable, bool bEmbeddable ) const { ImplDevFontList* pClonedList = new ImplDevFontList; - pClonedList->mbMatchData = mbMatchData; +// pClonedList->mbMatchData = mbMatchData; pClonedList->mbMapNames = mbMapNames; pClonedList->mpPreMatchHook = mpPreMatchHook; pClonedList->mpFallbackHook = mpFallbackHook; + // TODO: clone the config-font attributes too? + pClonedList->mbMatchData = false; + DevFontList::const_iterator it = maDevFontList.begin(); for(; it != maDevFontList.end(); ++it ) { diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index add53cdfaabf..77f7f74fc10e 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -11733,7 +11733,7 @@ sal_Int32 PDFWriterImpl::findRadioGroupWidget( const PDFWriter::RadioButtonWidge m_aWidgets.back().m_nPage = m_nCurrentPage; m_aWidgets.back().m_eType = PDFWriter::RadioButton; m_aWidgets.back().m_nRadioGroup = rBtn.RadioGroup; - m_aWidgets.back().m_nFlags |= 0x00008000; + m_aWidgets.back().m_nFlags |= 0x0000C000; // NoToggleToOff and Radio bits createWidgetFieldName( sal_Int32(m_aWidgets.size()-1), rBtn ); } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index de7cd2e139da..191f8f26dc75 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -36,6 +36,7 @@ #include "vcl/svids.hrc" #include "vcl/metaact.hxx" #include "vcl/msgbox.hxx" +#include "vcl/configsettings.hxx" #include "tools/urlobj.hxx" @@ -171,13 +172,15 @@ public: // set by user through printer config dialog // if set, pages are centered and trimmed onto the fixed page Size maFixedPageSize; + sal_Int32 mnDefaultPaperBin; ImplPrinterControllerData() : mbFirstPage( sal_True ), mbLastPage( sal_False ), mbReversePageOrder( sal_False ), meJobState( view::PrintableState_JOB_STARTED ), - mpProgress( NULL ) + mpProgress( NULL ), + mnDefaultPaperBin( -1 ) {} ~ImplPrinterControllerData() { delete mpProgress; } @@ -327,9 +330,25 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr // setup printer // if no specific printer is already set, create one + + // #i108686# + // in case of a UI (platform independent or system dialog) print job, make the printer persistent over jobs + // however if no printer was already set by the print job's originator, + // and this is an API job, then use the system default location (because + // this is the only sensible default available if the user has no means of changing + // the destination if( ! pController->getPrinter() ) { - boost::shared_ptr<Printer> pPrinter( new Printer( i_rInitSetup.GetPrinterName() ) ); + rtl::OUString aPrinterName( i_rInitSetup.GetPrinterName() ); + if( ! aPrinterName.getLength() && pController->isShowDialogs() && ! pController->isDirectPrint() ) + { + // get printer name from configuration + SettingsConfigItem* pItem = SettingsConfigItem::get(); + aPrinterName = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinterUsed" ) ) ); + } + + boost::shared_ptr<Printer> pPrinter( new Printer( aPrinterName ) ); pController->setPrinter( pPrinter ); } @@ -440,7 +459,12 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr return; } pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ), - makeAny( aFile ) ); + makeAny( aFile ) ); + } + else if( aDlg.isSingleJobs() ) + { + pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintCollateAsSingleJobs" ) ), + makeAny( sal_True ) ); } } catch( std::bad_alloc& ) @@ -501,6 +525,13 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: if ( !mpPrinter ) return FALSE; + sal_Bool bSinglePrintJobs = sal_False; + beans::PropertyValue* pSingleValue = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintCollateAsSingleJobs" ) ) ); + if( pSingleValue ) + { + pSingleValue->Value >>= bSinglePrintJobs; + } + // remark: currently it is still possible to use EnablePrintFile and // SetPrintFileName to redirect printout into file // it can be argued that those methods should be removed in favor @@ -514,6 +545,7 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: { mbPrintFile = TRUE; maPrintFile = aFile; + bSinglePrintJobs = sal_False; } } @@ -561,49 +593,90 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: i_pController->setJobState( view::PrintableState_JOB_STARTED ); i_pController->jobStarted(); - if( mpPrinter->StartJob( pPrintFile, - i_rJobName, - Application::GetDisplayName(), - nCopies, - bCollateCopy, - i_pController->isDirectPrint(), - maJobSetup.ImplGetConstData() ) ) + int nJobs = 1; + int nRepeatCount = bUserCopy ? mnCopyCount : 1; + if( bSinglePrintJobs ) { - mbJobActive = TRUE; - i_pController->createProgressDialog(); - int nPages = i_pController->getFilteredPageCount(); - int nRepeatCount = bUserCopy ? mnCopyCount : 1; - for( int nIteration = 0; nIteration < nRepeatCount; nIteration++ ) + nJobs = mnCopyCount; + nCopies = 1; + nRepeatCount = 1; + } + + for( int nJobIteration = 0; nJobIteration < nJobs; nJobIteration++ ) + { + bool bError = false; + if( mpPrinter->StartJob( pPrintFile, + i_rJobName, + Application::GetDisplayName(), + nCopies, + bCollateCopy, + i_pController->isDirectPrint(), + maJobSetup.ImplGetConstData() ) ) { - for( int nPage = 0; nPage < nPages; nPage++ ) + mbJobActive = TRUE; + i_pController->createProgressDialog(); + int nPages = i_pController->getFilteredPageCount(); + for( int nIteration = 0; nIteration < nRepeatCount; nIteration++ ) { - if( nPage == nPages-1 && nIteration == nRepeatCount-1 ) - i_pController->setLastPage( sal_True ); - i_pController->printFilteredPage( nPage ); + for( int nPage = 0; nPage < nPages; nPage++ ) + { + if( nPage == nPages-1 && nIteration == nRepeatCount-1 && nJobIteration == nJobs-1 ) + i_pController->setLastPage( sal_True ); + i_pController->printFilteredPage( nPage ); + } + // FIXME: duplex ? + } + EndJob(); + + if( nJobIteration < nJobs-1 ) + { + mpPrinter = pSVData->mpDefInst->CreatePrinter( mpInfoPrinter ); + + if ( mpPrinter ) + { + maJobName = i_rJobName; + mnCurPage = 1; + mnCurPrintPage = 1; + mbPrinting = TRUE; + } + else + bError = true; } - // FIXME: duplex ? } - EndJob(); + else + bError = true; - if( i_pController->getJobState() == view::PrintableState_JOB_STARTED ) - i_pController->setJobState( view::PrintableState_JOB_SPOOLED ); + if( bError ) + { + mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); + if ( !mnError ) + mnError = PRINTER_GENERALERROR; + i_pController->setJobState( mnError == PRINTER_ABORT + ? view::PrintableState_JOB_ABORTED + : view::PrintableState_JOB_FAILED ); + if( mpPrinter ) + pSVData->mpDefInst->DestroyPrinter( mpPrinter ); + mnCurPage = 0; + mnCurPrintPage = 0; + mbPrinting = FALSE; + mpPrinter = NULL; + + return false; + } } - else - { - mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); - if ( !mnError ) - mnError = PRINTER_GENERALERROR; - i_pController->setJobState( mnError == PRINTER_ABORT - ? view::PrintableState_JOB_ABORTED - : view::PrintableState_JOB_FAILED ); - pSVData->mpDefInst->DestroyPrinter( mpPrinter ); - mnCurPage = 0; - mnCurPrintPage = 0; - mbPrinting = FALSE; - mpPrinter = NULL; - return false; - } + if( i_pController->getJobState() == view::PrintableState_JOB_STARTED ) + i_pController->setJobState( view::PrintableState_JOB_SPOOLED ); + } + + // make last used printer persistent for UI jobs + if( i_pController->isShowDialogs() && ! i_pController->isDirectPrint() ) + { + SettingsConfigItem* pItem = SettingsConfigItem::get(); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinterUsed" ) ), + GetName() + ); } return true; @@ -634,6 +707,7 @@ void PrinterController::setPrinter( const boost::shared_ptr<Printer>& i_rPrinter mpImplData->mpPrinter = i_rPrinter; setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), makeAny( rtl::OUString( i_rPrinter->GetName() ) ) ); + mpImplData->mnDefaultPaperBin = mpImplData->mpPrinter->GetPaperBin(); } bool PrinterController::setupPrinter( Window* i_pParent ) @@ -668,27 +742,55 @@ PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( cons { PrinterController::PageSize aPageSize; aPageSize.aSize = mpPrinter->GetPaperSize(); + awt::Size aSetSize, aIsSize; + sal_Int32 nPaperBin = mnDefaultPaperBin; for( sal_Int32 nProperty = 0, nPropertyCount = i_rProps.getLength(); nProperty < nPropertyCount; ++nProperty ) { - if( i_rProps[ nProperty ].Name.equalsAscii( "PageSize" ) ) + if( i_rProps[ nProperty ].Name.equalsAscii( "PreferredPageSize" ) ) { - awt::Size aSize; - i_rProps[ nProperty].Value >>= aSize; - aPageSize.aSize.Width() = aSize.Width; - aPageSize.aSize.Height() = aSize.Height; - - Size aCurSize( mpPrinter->GetPaperSize() ); - Size aRealPaperSize( getRealPaperSize( aPageSize.aSize ) ); - if( aRealPaperSize != aCurSize ) - mpPrinter->SetPaperSizeUser( aRealPaperSize, ! isFixedPageSize() ); + i_rProps[ nProperty ].Value >>= aSetSize; } - if( i_rProps[ nProperty ].Name.equalsAscii( "PageIncludesNonprintableArea" ) ) + else if( i_rProps[ nProperty ].Name.equalsAscii( "PageSize" ) ) + { + i_rProps[ nProperty ].Value >>= aIsSize; + } + else if( i_rProps[ nProperty ].Name.equalsAscii( "PageIncludesNonprintableArea" ) ) { sal_Bool bVal = sal_False; - i_rProps[ nProperty].Value >>= bVal; + i_rProps[ nProperty ].Value >>= bVal; aPageSize.bFullPaper = static_cast<bool>(bVal); } + else if( i_rProps[ nProperty ].Name.equalsAscii( "PrinterPaperTray" ) ) + { + sal_Int32 nBin = -1; + i_rProps[ nProperty ].Value >>= nBin; + if( nBin >= 0 && nBin < mpPrinter->GetPaperBinCount() ) + nPaperBin = nBin; + } + } + + Size aCurSize( mpPrinter->GetPaperSize() ); + if( aSetSize.Width && aSetSize.Height ) + { + Size aSetPaperSize( aSetSize.Width, aSetSize.Height ); + Size aRealPaperSize( getRealPaperSize( aSetPaperSize ) ); + if( aRealPaperSize != aCurSize ) + aIsSize = aSetSize; } + + if( aIsSize.Width && aIsSize.Height ) + { + aPageSize.aSize.Width() = aIsSize.Width; + aPageSize.aSize.Height() = aIsSize.Height; + + Size aRealPaperSize( getRealPaperSize( aPageSize.aSize ) ); + if( aRealPaperSize != aCurSize ) + mpPrinter->SetPaperSizeUser( aRealPaperSize, ! isFixedPageSize() ); + } + + if( nPaperBin != -1 && nPaperBin != mpPrinter->GetPaperBin() ) + mpPrinter->SetPaperBin( nPaperBin ); + return aPageSize; } @@ -1393,6 +1495,8 @@ void PrinterController::createProgressDialog() mpImplData->mpProgress->Show(); } } + else + mpImplData->mpProgress->reset(); } void PrinterController::setMultipage( const MultiPageSetup& i_rMPS ) |