summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lange [tl] <tl@openoffice.org>2009-12-11 16:17:51 +0100
committerThomas Lange [tl] <tl@openoffice.org>2009-12-11 16:17:51 +0100
commitaf8a4cf23931e9b26d31683292dfe56cec2e97cb (patch)
tree6ab56dbd984aa80629df63b947888b704414ed7d
parent466a6474b0f79bfddeb242552a5b88a9ae42b7b0 (diff)
#i106926# fixing view settings after rendering
-rwxr-xr-xsw/inc/printdata.hxx3
-rwxr-xr-xsw/inc/unotxdoc.hxx8
-rwxr-xr-xsw/source/core/view/vprint.cxx12
-rwxr-xr-xsw/source/ui/uno/unotxdoc.cxx80
4 files changed, 56 insertions, 47 deletions
diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx
index 75f16d01ace3..3368418354cf 100755
--- a/sw/inc/printdata.hxx
+++ b/sw/inc/printdata.hxx
@@ -267,7 +267,8 @@ public:
void DeletePostItData();
bool IsViewOptionAdjust() const { return m_pViewOptionAdjust != 0; }
- void ViewOptionAdjustStart( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions );
+ void ViewOptionAdjustStart( SwWrtShell &rSh, const SwViewOption &rViewOptions );
+ void ViewOptionAdjust( const SwPrtOptions *pPrtOptions );
void ViewOptionAdjustStop();
bool HasSwPrtOptions() const { return m_pPrtOptions != 0; }
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 45a890aeab7d..39438bbc3add 100755
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -602,12 +602,14 @@ class SwViewOptionAdjust_Impl
{
SwWrtShell & m_rShell;
SwViewOption m_aOldViewOptions;
- SwViewOption m_aRenderViewOptions; // view options to use when rendering for PDF export or printing
- bool m_bRestoreViewOptions;
+// SwViewOption m_aRenderViewOptions; // view options to use when rendering for PDF export or printing
+// bool m_bRestoreViewOptions;
public:
- SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions );
+ SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwViewOption &rViewOptions );
~SwViewOptionAdjust_Impl();
+
+ void AdjustViewOptions( const SwPrtOptions *pPrtOptions );
};
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 );
-}
-
/*****************************************************************************/