Commits

Oliver-Rainer Wittmann  committed 766a0b3

sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines

  • Participants
  • Parent commits c2ceb43

Comments (0)

Files changed (6)

File sfx2/source/view/viewprn.cxx

                     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 );
                 }
             }
         }

File sw/inc/unotxdoc.hxx

 
 	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;
 

File sw/source/ui/uno/unotxdoc.cxx

 #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>
     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---------------------------------------------------
 			}
 		}
 
-
+        // --> OD #i117783#
+        bApplyPagePrintSettingsFromXPagePrintable = sal_True;
+        // <--
 		pFrame->GetViewShell()->ExecuteSlot(aReq);
 		// Frame schliessen
 		pFrame->DoClose();
         }    
     }
 
+    // --> 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;

File vcl/inc/vcl/print.hxx

        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
     */

File vcl/source/gdi/print3.cxx

         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() )
     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
 **/

File vcl/source/window/printdlg.cxx

     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()