diff options
author | Thomas Lange [tl] <tl@openoffice.org> | 2009-12-11 16:17:51 +0100 |
---|---|---|
committer | Thomas Lange [tl] <tl@openoffice.org> | 2009-12-11 16:17:51 +0100 |
commit | af8a4cf23931e9b26d31683292dfe56cec2e97cb (patch) | |
tree | 6ab56dbd984aa80629df63b947888b704414ed7d /sw/source | |
parent | 466a6474b0f79bfddeb242552a5b88a9ae42b7b0 (diff) |
#i106926# fixing view settings after rendering
Diffstat (limited to 'sw/source')
-rwxr-xr-x | sw/source/core/view/vprint.cxx | 12 | ||||
-rwxr-xr-x | sw/source/ui/uno/unotxdoc.cxx | 80 |
2 files changed, 49 insertions, 43 deletions
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 0de4da31370d..bab2428c0b67 100755 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -282,13 +282,19 @@ void SwRenderData::DeletePostItData() } -void SwRenderData::ViewOptionAdjustStart( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ) +void SwRenderData::ViewOptionAdjustStart( SwWrtShell &rSh, const SwViewOption &rViewOptions ) { if (m_pViewOptionAdjust) { - DBG_ASSERT( 0, "error: there should be no ViewOptionAdjustStart active when calling it again" ); + DBG_ASSERT( 0, "error: there should be no ViewOptionAdjust active when calling this function" ); } - m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh, pPrtOptions ); + m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh, rViewOptions ); +} + + +void SwRenderData::ViewOptionAdjust( const SwPrtOptions *pPrtOptions ) +{ + m_pViewOptionAdjust->AdjustViewOptions( pPrtOptions ); } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 1917228b347b..6c6194555559 100755 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2723,10 +2723,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( const TypeId aSwViewTypeId = TYPE(SwView); if (pView->IsA(aSwViewTypeId)) { - // if there already is a not stopped view options adjustment we should return to - // the original values before calculating the new ones. - if (m_pRenderData->IsViewOptionAdjust()) - m_pRenderData->ViewOptionAdjustStop(); + if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust()) + m_pRenderData->ViewOptionAdjustStart( *pWrtShell, *pWrtShell->GetViewOptions() ); } m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); @@ -2737,7 +2735,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( { // PDF export should not make use of the SwPrtOptions const SwPrtOptions *pPrtOptions = bIsPDFExport? NULL : m_pRenderData->GetSwPrtOptions(); - m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr(), pPrtOptions ); + m_pRenderData->ViewOptionAdjust( pPrtOptions ); } // since printing now also use the API for PDF export this option @@ -3078,7 +3076,7 @@ void SAL_CALL SwXTextDocument::render( // -> do clean-up of data if (bLastPage) { - // #i96167# haggai: delete pViewOptionsAdjust here because it makes use + // #i96167# haggai: delete ViewOptionsAdjust here because it makes use // of the shell, which might get destroyed in lcl_DisposeView! if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) m_pRenderData->ViewOptionAdjustStop(); @@ -4061,12 +4059,21 @@ void SwXDocumentPropertyHelper::onChange() /*****************************************************************************/ -SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( - SwWrtShell& rSh, - const SwPrtOptions *pPrtOptions ) : - m_rShell(rSh), - m_aOldViewOptions( *rSh.GetViewOptions() ), - m_bRestoreViewOptions( false ) +SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwViewOption &rViewOptions ) :
+ m_rShell( rSh ), + m_aOldViewOptions( rViewOptions ) +{
+}
+
+ +SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() +{ + m_rShell.ApplyViewOptions( m_aOldViewOptions ); +} + + +void SwViewOptionAdjust_Impl::AdjustViewOptions( + const SwPrtOptions *pPrtOptions ) { // to avoid unnecessary reformatting the view options related to the content // below should only change if necessary, that is if respective content is present @@ -4079,56 +4086,49 @@ SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends(); const bool bContainsFields = m_rShell.IsAnyFieldInDoc(); + SwViewOption aRenderViewOptions( m_aOldViewOptions ); + // disable anything in the view that should not be printed (or exported to PDF) by default // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids" // in section "Display of ...") - m_aRenderViewOptions = m_aOldViewOptions; - m_aRenderViewOptions.SetParagraph( FALSE ); // paragraph end - m_aRenderViewOptions.SetSoftHyph( FALSE ); // aka custom hyphens - m_aRenderViewOptions.SetBlank( FALSE ); // spaces - m_aRenderViewOptions.SetHardBlank( FALSE ); // non-breaking spaces - m_aRenderViewOptions.SetTab( FALSE ); // tabs - m_aRenderViewOptions.SetLineBreak( FALSE ); // breaks (type 1) - m_aRenderViewOptions.SetPageBreak( FALSE ); // breaks (type 2) - m_aRenderViewOptions.SetColumnBreak( FALSE ); // breaks (type 3) + aRenderViewOptions.SetParagraph( FALSE ); // paragraph end + aRenderViewOptions.SetSoftHyph( FALSE ); // aka custom hyphens + aRenderViewOptions.SetBlank( FALSE ); // spaces + aRenderViewOptions.SetHardBlank( FALSE ); // non-breaking spaces + aRenderViewOptions.SetTab( FALSE ); // tabs + aRenderViewOptions.SetLineBreak( FALSE ); // breaks (type 1) + aRenderViewOptions.SetPageBreak( FALSE ); // breaks (type 2) + aRenderViewOptions.SetColumnBreak( FALSE ); // breaks (type 3) BOOL bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : FALSE; if (bContainsHiddenChars) - m_aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text + aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text if (bContainsHiddenFields) - m_aRenderViewOptions.SetShowHiddenField( bVal ); + aRenderViewOptions.SetShowHiddenField( bVal ); if (bContainsHiddenParagraphs) - m_aRenderViewOptions.SetShowHiddenPara( bVal ); + aRenderViewOptions.SetShowHiddenPara( bVal ); if (bContainsPlaceHolders) { // should always be printed in PDF export! bVal = pPrtOptions ? pPrtOptions->bPrintTextPlaceholder : TRUE; - m_aRenderViewOptions.SetShowPlaceHolderFields( bVal ); + aRenderViewOptions.SetShowPlaceHolderFields( bVal ); } if (bContainsFields) - m_aRenderViewOptions.SetFldName( FALSE ); + aRenderViewOptions.SetFldName( FALSE ); - // we don't want to print those. - // Also this flag has effect on printing of other content e.g. hidden text - m_aRenderViewOptions.SetViewMetaChars( FALSE ); + // we need to set this flag in order to get to see the visible effect of + // some of the above settings (needed for correct rendering) + aRenderViewOptions.SetViewMetaChars( TRUE ); - if (m_aOldViewOptions != m_aRenderViewOptions) // check if reformatting is necessary + if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary { - m_aRenderViewOptions.SetPrinting( pPrtOptions != NULL ); - m_bRestoreViewOptions = true; - SW_MOD()->ApplyUsrPref( m_aRenderViewOptions, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); + aRenderViewOptions.SetPrinting( pPrtOptions != NULL ); + m_rShell.ApplyViewOptions( aRenderViewOptions ); } - } -SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() -{ - if (m_bRestoreViewOptions) - SW_MOD()->ApplyUsrPref( m_aOldViewOptions, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); -} - /*****************************************************************************/ |