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 /sw | |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unotxdoc.hxx | 8 | ||||
-rwxr-xr-x | sw/source/ui/uno/unotxdoc.cxx | 67 |
2 files changed, 73 insertions, 2 deletions
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; |