diff options
author | Michael Stahl <mst@apache.org> | 2011-09-17 21:39:52 +0000 |
---|---|---|
committer | Michael Stahl <mst@apache.org> | 2011-09-17 21:39:52 +0000 |
commit | b744fca2055659e09187512f474d7da5ef6e8cfc (patch) | |
tree | bd18b42c8263bc8fd2b97de9dc4056cafac5626f | |
parent | a38ca8647f8199a0aade3579747437d9a68e51bc (diff) |
sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines
# HG changeset patch
# User Oliver-Rainer Wittmann <od@openoffice.org>
# Date 1304508061 -7200
# Node ID 766a0b3ad79f0aba468ae8ca769cad4906057167
# Parent c2ceb432950c99187e6924defb187fbf049d76cc
-rwxr-xr-x | sfx2/source/view/viewprn.cxx | 5 | ||||
-rw-r--r-- | sw/inc/unotxdoc.hxx | 8 | ||||
-rwxr-xr-x | sw/source/ui/uno/unotxdoc.cxx | 67 | ||||
-rw-r--r-- | vcl/inc/vcl/print.hxx | 4 | ||||
-rwxr-xr-x | vcl/source/gdi/print3.cxx | 49 | ||||
-rwxr-xr-x | vcl/source/window/printdlg.cxx | 12 |
6 files changed, 142 insertions, 3 deletions
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index b91e8b4848ba..4656e62afa5b 100755 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -158,7 +158,10 @@ SfxPrinterController::SfxPrinterController( const boost::shared_ptr<Printer>& i_ Sequence< beans::PropertyValue > aUIProps; aRenderParms[i].Value >>= aUIProps; setUIOptions( aUIProps ); - break; + } + else if( aRenderParms[i].Name.compareToAscii( "NUp", 3 ) == 0 ) + { + setValue( aRenderParms[i].Name, aRenderParms[i].Value ); } } } diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index bb5168a16c1c..8649fab1f55a 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -238,6 +238,14 @@ class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass, rtl::OUString maBuildId; + // --> OD #i117783# + // boolean for XPagePrintable + // set in XPagePrintable::printPages(..) to indicate that the PagePrintSettings + // has to be applied in XRenderable::getRenderer(..) through which the printing + // is implemented. + sal_Bool bApplyPagePrintSettingsFromXPagePrintable; + // <-- + using SfxBaseModel::addEventListener; using SfxBaseModel::removeEventListener; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 97d3f0756001..b85e660b88c7 100755 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -36,6 +36,7 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/sfxbasecontroller.hxx> #include <sfx2/docfile.hxx> +#include <sfx2/printer.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <toolkit/awt/vclxdevice.hxx> #include <cmdid.h> @@ -400,7 +401,10 @@ SwXTextDocument::SwXTextDocument(SwDocShell* pShell) : pxXRedlines(0), m_pHiddenViewFrame(0), m_pPrintUIOptions( NULL ), - m_pRenderData( NULL ) + m_pRenderData( NULL ), + // --> OD #i117783# + bApplyPagePrintSettingsFromXPagePrintable( sal_False ) + // <-- { } /*-- 18.12.98 11:53:00--------------------------------------------------- @@ -1292,7 +1296,9 @@ void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOption } } - + // --> OD #i117783# + bApplyPagePrintSettingsFromXPagePrintable = sal_True; + // <-- pFrame->GetViewShell()->ExecuteSlot(aReq); // Frame schliessen pFrame->DoClose(); @@ -2972,6 +2978,63 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( } } + // --> OD #i117783# + if ( bApplyPagePrintSettingsFromXPagePrintable ) + { + const SwPagePreViewPrtData* pPagePrintSettings = + pDocShell->GetDoc()->GetPreViewPrtData(); + if ( pPagePrintSettings && + ( pPagePrintSettings->GetRow() > 1 || + pPagePrintSettings->GetCol() > 1 ) ) + { + // extend render data by page print settings attributes + sal_Int32 nLen = aRenderer.getLength(); + const sal_Int32 nRenderDataIdxStart = nLen; + nLen += 9; + aRenderer.realloc( nLen ); + // put page print settings attribute into render data + const sal_Int32 nRow = pPagePrintSettings->GetRow(); + aRenderer[ nRenderDataIdxStart + 0 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpRows" ) ); + aRenderer[ nRenderDataIdxStart + 0 ].Value <<= ( nRow > 1 ? nRow : 1 ); + const sal_Int32 nCol = pPagePrintSettings->GetCol(); + aRenderer[ nRenderDataIdxStart + 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpColumns" ) ); + aRenderer[ nRenderDataIdxStart + 1 ].Value <<= ( nCol > 1 ? nCol : 1 ); + aRenderer[ nRenderDataIdxStart + 2 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginLeft" ) ); + aRenderer[ nRenderDataIdxStart + 2 ].Value <<= pPagePrintSettings->GetLeftSpace(); + aRenderer[ nRenderDataIdxStart + 3 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginRight" ) ); + aRenderer[ nRenderDataIdxStart + 3 ].Value <<= pPagePrintSettings->GetRightSpace(); + aRenderer[ nRenderDataIdxStart + 4 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginTop" ) ); + aRenderer[ nRenderDataIdxStart + 4 ].Value <<= pPagePrintSettings->GetTopSpace(); + aRenderer[ nRenderDataIdxStart + 5 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginBottom" ) ); + aRenderer[ nRenderDataIdxStart + 5 ].Value <<= pPagePrintSettings->GetBottomSpace(); + aRenderer[ nRenderDataIdxStart + 6 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpHorizontalSpacing" ) ); + aRenderer[ nRenderDataIdxStart + 6 ].Value <<= pPagePrintSettings->GetHorzSpace(); + aRenderer[ nRenderDataIdxStart + 7 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpVerticalSpacing" ) ); + aRenderer[ nRenderDataIdxStart + 7 ].Value <<= pPagePrintSettings->GetVertSpace(); + { + Printer* pPrinter = pDocShell->GetDoc()->getPrinter( false ); + if ( pPrinter ) + { + awt::Size aNewPageSize; + const Size aPageSize = pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); + aNewPageSize = awt::Size( aPageSize.Width(), aPageSize.Height() ); + if ( ( pPagePrintSettings->GetLandscape() && + aPageSize.Width() < aPageSize.Height() ) || + ( !pPagePrintSettings->GetLandscape() && + aPageSize.Width() > aPageSize.Height() ) ) + { + aNewPageSize = awt::Size( aPageSize.Height(), aPageSize.Width() ); + } + aRenderer[ nRenderDataIdxStart + 8 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPaperSize" ) ); + aRenderer[ nRenderDataIdxStart + 8 ].Value <<= aNewPageSize; + } + } + } + + bApplyPagePrintSettingsFromXPagePrintable = sal_False; + } + // <-- + m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); return aRenderer; diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 2ce69ab0b660..19de244349a6 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -470,6 +470,10 @@ public: in case the property is unknown or not convertible to bool, i_bFallback is returned */ sal_Bool getBoolProperty( const rtl::OUString& i_rPropertyName, sal_Bool i_bFallback ) const; + /* get an int property + in case the property is unknown or not convertible to bool, i_nFallback is returned + */ + sal_Int32 getIntProperty( const rtl::OUString& i_rPropertyName, sal_Int32 i_nFallback ) const; /* set a property value - can also be used to add another UI property */ diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 3bc47e6cf8fb..1d17432591c4 100755 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -419,6 +419,46 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr pController->setReversePrint( bReverse ); } + // setup NUp printing from properties + sal_Int32 nRows = i_pController->getIntProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpRows" ) ), 1 ); + sal_Int32 nCols = i_pController->getIntProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpColumns" ) ), 1 ); + if( nRows > 1 || nCols > 1 ) + { + PrinterController::MultiPageSetup aMPS; + aMPS.nRows = nRows > 1 ? nRows : 1; + aMPS.nColumns = nCols > 1 ? nCols : 1; + sal_Int32 nValue = i_pController->getIntProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginLeft" ) ), aMPS.nLeftMargin ); + if( nValue >= 0 ) + aMPS.nLeftMargin = nValue; + nValue = i_pController->getIntProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginRight" ) ), aMPS.nRightMargin ); + if( nValue >= 0 ) + aMPS.nRightMargin = nValue; + nValue = i_pController->getIntProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginTop" ) ), aMPS.nTopMargin ); + if( nValue >= 0 ) + aMPS.nTopMargin = nValue; + nValue = i_pController->getIntProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginBottom" ) ), aMPS.nBottomMargin ); + if( nValue >= 0 ) + aMPS.nBottomMargin = nValue; + nValue = i_pController->getIntProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpHorizontalSpacing" ) ), aMPS.nHorizontalSpacing ); + if( nValue >= 0 ) + aMPS.nHorizontalSpacing = nValue; + nValue = i_pController->getIntProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpVerticalSpacing" ) ), aMPS.nVerticalSpacing ); + if( nValue >= 0 ) + aMPS.nVerticalSpacing = nValue; + aMPS.bDrawBorder = i_pController->getBoolProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpDrawBorder" ) ), aMPS.bDrawBorder ); + aMPS.nOrder = static_cast<PrinterController::NupOrderType>(i_pController->getIntProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpSubPageOrder" ) ), aMPS.nOrder )); + aMPS.aPaperSize = i_pController->getPrinter()->PixelToLogic( i_pController->getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); + beans::PropertyValue* pPgSizeVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPaperSize" ) ) ); + awt::Size aSizeVal; + if( pPgSizeVal && (pPgSizeVal->Value >>= aSizeVal) ) + { + aMPS.aPaperSize.Width() = aSizeVal.Width; + aMPS.aPaperSize.Height() = aSizeVal.Height; + } + + i_pController->setMultipage( aMPS ); + } + // in direct print case check whether there is anything to print. // if not, show an errorbox (if appropriate) if( pController->isShowDialogs() && pController->isDirectPrint() ) @@ -1633,6 +1673,15 @@ sal_Bool PrinterController::getBoolProperty( const rtl::OUString& i_rProperty, s return bRet; } +sal_Int32 PrinterController::getIntProperty( const rtl::OUString& i_rProperty, sal_Int32 i_nFallback ) const +{ + sal_Int32 nRet = i_nFallback; + const com::sun::star::beans::PropertyValue* pVal = getValue( i_rProperty ); + if( pVal ) + pVal->Value >>= nRet; + return nRet; +} + /* * PrinterOptionsHelper **/ diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 094567c7f15c..9efaa7d7273f 100755 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -593,6 +593,18 @@ void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterControll maBorderCB.Check( i_rMPS.bDrawBorder ); maNupRowsEdt.SetValue( i_rMPS.nRows ); maNupColEdt.SetValue( i_rMPS.nColumns ); + maBorderCB.Check( i_rMPS.bDrawBorder ); + for( sal_uInt16 i = 0; i < maNupOrderBox.GetEntryCount(); i++ ) + { + if( int(sal_IntPtr(maNupOrderBox.GetEntryData( i ))) == i_rMPS.nOrder ) + maNupOrderBox.SelectEntryPos( i ); + } + if( i_rMPS.nRows != 1 || i_rMPS.nColumns != 1 ) + { + maNupPagesBox.SelectEntryPos( maNupPagesBox.GetEntryCount()-1 ); + showAdvancedControls( true ); + maNupOrderWin.setValues( i_rMPS.nOrder, i_rMPS.nColumns, i_rMPS.nRows ); + } } void PrintDialog::NUpTabPage::readFromSettings() |