summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorThomas Lange [tl] <tl@openoffice.org>2009-12-11 11:34:10 +0100
committerThomas Lange [tl] <tl@openoffice.org>2009-12-11 11:34:10 +0100
commit9195c2b45eb5488e939bb88281d45cb45fbe4861 (patch)
tree4e3c94c1a3ea8cdb9dd98b94d45e73afd2fe256e /sw
parentaf1e3ee0d10c10d6f30d8700ddc677a86dbf82c3 (diff)
#i106926# fixed hidden text in view when cancelling print to file
Diffstat (limited to 'sw')
-rwxr-xr-xsw/inc/unotxdoc.hxx24
-rwxr-xr-xsw/inc/viewopt.hxx3
-rwxr-xr-xsw/source/core/view/vprint.cxx6
-rwxr-xr-xsw/source/ui/uno/unotxdoc.cxx121
4 files changed, 68 insertions, 86 deletions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index a5c39b2d928d..45a890aeab7d 100755
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -29,9 +29,11 @@
************************************************************************/
#ifndef _UNOTXDOC_HXX
#define _UNOTXDOC_HXX
+
#include "swdllapi.h"
#include <svtools/svarray.hxx>
#include <sfx2/sfxbasemodel.hxx>
+
#include <com/sun/star/beans/PropertyValues.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/style/XAutoStylesSupplier.hpp>
@@ -79,6 +81,8 @@
#include <cppuhelper/implbase4.hxx> // helper for implementations
#include <RefreshListenerContainer.hxx>
+#include <viewopt.hxx>
+
#define __IFC32 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \
Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31, Ifc32
@@ -129,7 +133,6 @@ class SwPrintUIOptions;
class SwPrintData;
class SwRenderData;
class SwPrtOptions;
-class SwViewOption;
class SwWrtShell;
@@ -597,20 +600,11 @@ public:
-----------------------------------------------------------------------*/
class SwViewOptionAdjust_Impl
{
- // options not available in the File/Print UI, should be turned off for
- // printing and PDF export if they are enabled
- bool m_bSwitchOff_IsFldName;
-
- // options available in the File/Print UI, should be turned of for PDF export
- // and otherwise set (or not) according to
- // pPrtOptions->bPrintHiddenText and pPrtOptions->bPrintTextPlaceholder
- bool m_bToggle_HiddenChar;
- bool m_bToggle_HiddenField;
- bool m_bToggle_HiddenParagraphs;
- bool m_bToggle_PlaceHolderView;
-
- SwViewOption* m_pViewOption;
- SwWrtShell& m_rShell;
+ SwWrtShell & m_rShell;
+ SwViewOption m_aOldViewOptions;
+ 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();
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index 2ac47e284b49..8b2e4d5aa6fa 100755
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -455,7 +455,8 @@ public:
SwViewOption& operator=( const SwViewOption &rOpt );
// Vergleichsmethoden
BOOL IsEqualFlags ( const SwViewOption &rOpt ) const;
- inline BOOL operator==( const SwViewOption &rOpt ) const;
+ inline BOOL operator == ( const SwViewOption &rOpt ) const;
+ inline BOOL operator != ( const SwViewOption &rOpt ) const { return !(*this == rOpt); }
/*---------------------------------------------------------------------------
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index 87b8c5177e26..0de4da31370d 100755
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -285,14 +285,16 @@ void SwRenderData::DeletePostItData()
void SwRenderData::ViewOptionAdjustStart( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions )
{
if (m_pViewOptionAdjust)
- delete m_pViewOptionAdjust;
+ {
+ DBG_ASSERT( 0, "error: there should be no ViewOptionAdjustStart active when calling it again" );
+ }
m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh, pPrtOptions );
}
void SwRenderData::ViewOptionAdjustStop()
{
- if (IsViewOptionAdjust())
+ if (m_pViewOptionAdjust)
{
delete m_pViewOptionAdjust;
m_pViewOptionAdjust = 0;
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index 2ac3e7f64508..4c3a86b97dce 100755
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -2720,12 +2720,19 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
// We don't want that! Thus we disable updating of the view.
pWrtShell->StartAction();
+ 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();
+ }
+
m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) );
m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell,
m_pPrintUIOptions, m_pRenderData, bIsPDFExport );
- //SwViewOptionAdjust_Impl aAdjust(*pWrtShell);
- const TypeId aSwViewTypeId = TYPE(SwView);
if (pView->IsA(aSwViewTypeId))
{
// PDF export should not make use of the SwPrtOptions
@@ -4057,11 +4064,12 @@ void SwXDocumentPropertyHelper::onChange()
SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(
SwWrtShell& rSh,
const SwPrtOptions *pPrtOptions ) :
- m_pViewOption(0),
- m_rShell(rSh)
+ m_rShell(rSh),
+ m_aOldViewOptions( *rSh.GetViewOptions() ),
+ m_bRestoreViewOptions( false )
{
- const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions();
-
+ // to avoid unnecessary reformatting the view options related to the content
+ // below should only change if necessary, that is if respective content is present
const bool bContainsHiddenChars = m_rShell.GetDoc()->ContainsHiddenChars();
const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENTXTFLD );
const bool bContainsHiddenFields = pFldType && pFldType->GetDepends();
@@ -4069,54 +4077,47 @@ SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(
const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends();
pFldType = m_rShell.GetDoc()->GetSysFldType( RES_JUMPEDITFLD );
const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends();
-
- m_bSwitchOff_IsFldName = m_rShell.IsAnyFieldInDoc() && pCurrentViewOptions->IsFldName();
-
- // for printing only (not PDF export) take print options into account
- if (pPrtOptions)
- {
- m_bToggle_PlaceHolderView = bContainsPlaceHolders && pPrtOptions->bPrintTextPlaceholder != pCurrentViewOptions->IsShowPlaceHolderFields();
- m_bToggle_HiddenChar = bContainsHiddenChars && pPrtOptions->bPrintHiddenText != pCurrentViewOptions->IsShowHiddenChar( TRUE );
- m_bToggle_HiddenField = bContainsHiddenFields && pPrtOptions->bPrintHiddenText != pCurrentViewOptions->IsShowHiddenField();
- m_bToggle_HiddenParagraphs = bContainsHiddenParagraphs && pPrtOptions->bPrintHiddenText != pCurrentViewOptions->IsShowHiddenPara();
- }
- else
+ const bool bContainsFields = m_rShell.IsAnyFieldInDoc();
+
+ // 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)
+ BOOL bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : FALSE;
+ if (bContainsHiddenChars)
+ m_aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text
+ if (bContainsHiddenFields)
+ m_aRenderViewOptions.SetShowHiddenField( bVal );
+ if (bContainsHiddenParagraphs)
+ m_aRenderViewOptions.SetShowHiddenPara( bVal );
+
+ if (bContainsPlaceHolders)
{
- //toggle painting of placeholder fields
- m_bToggle_PlaceHolderView = bContainsPlaceHolders && pCurrentViewOptions->IsShowPlaceHolderFields();
- //toggle display of hidden characters if on and hidden characters are in use
- m_bToggle_HiddenChar = bContainsHiddenChars && pCurrentViewOptions->IsShowHiddenChar( FALSE );
- //toggle display of hidden fields if on and hidden fields are in use
- m_bToggle_HiddenField = bContainsHiddenFields && pCurrentViewOptions->IsShowHiddenField();
- //toggle display of hidden paragraphs if on and hidden paragraphs are in use
- m_bToggle_HiddenParagraphs = bContainsHiddenParagraphs && pCurrentViewOptions->IsShowHiddenPara();
+ // should always be printed in PDF export!
+ bVal = pPrtOptions ? pPrtOptions->bPrintTextPlaceholder : TRUE;
+ m_aRenderViewOptions.SetShowPlaceHolderFields( bVal );
}
- // bApplyViewOptions should only be true if necessary to avoid reformating if not required,
- bool bApplyViewOptions = m_bSwitchOff_IsFldName;
- bApplyViewOptions |= m_bToggle_PlaceHolderView;
- bApplyViewOptions |= m_bToggle_HiddenChar;
- bApplyViewOptions |= m_bToggle_HiddenField;
- bApplyViewOptions |= m_bToggle_HiddenParagraphs;
- if(bApplyViewOptions)
+ if (bContainsFields)
+ m_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 );
+
+ if (m_aOldViewOptions != m_aRenderViewOptions) // check if reformatting is necessary
{
- m_pViewOption = new SwViewOption( *pCurrentViewOptions );
-
- // set flag to hint that everything should be formatted for printing,
- // (needed at some places to print hidden text if that option is set in the dialog, etc.)
- m_pViewOption->SetPrinting( TRUE );
-
- if(m_bSwitchOff_IsFldName)
- m_pViewOption->SetFldName(FALSE);
- if(m_bToggle_PlaceHolderView)
- m_pViewOption->SetShowPlaceHolderFields( !pCurrentViewOptions->IsShowPlaceHolderFields() );
- if(m_bToggle_HiddenChar)
- m_pViewOption->SetShowHiddenChar( !pCurrentViewOptions->IsShowHiddenChar( TRUE ) );
- if(m_bToggle_HiddenField)
- m_pViewOption->SetShowHiddenField( !pCurrentViewOptions->IsShowHiddenField() );
- if(m_bToggle_HiddenParagraphs)
- m_pViewOption->SetShowHiddenPara( !pCurrentViewOptions->IsShowHiddenPara() );
- SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY );
+ m_aRenderViewOptions.SetPrinting( pPrtOptions != NULL );
+ m_bRestoreViewOptions = true;
+ SW_MOD()->ApplyUsrPref( m_aRenderViewOptions, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY );
}
}
@@ -4124,24 +4125,8 @@ SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(
SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl()
{
- if(m_pViewOption)
- {
- m_pViewOption->SetPrinting( FALSE );
-
- const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions();
- if(m_bSwitchOff_IsFldName)
- m_pViewOption->SetFldName(TRUE);
- if(m_bToggle_HiddenChar)
- m_pViewOption->SetShowHiddenChar( !pCurrentViewOptions->IsShowHiddenChar() );
- if(m_bToggle_HiddenField)
- m_pViewOption->SetShowHiddenField( !pCurrentViewOptions->IsShowHiddenField() );
- if(m_bToggle_HiddenParagraphs)
- m_pViewOption->SetShowHiddenPara( !pCurrentViewOptions->IsShowHiddenPara() );
- if(m_bToggle_PlaceHolderView)
- m_pViewOption->SetShowPlaceHolderFields( !pCurrentViewOptions->IsShowPlaceHolderFields() );
- SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY );
- delete m_pViewOption; m_pViewOption = NULL;
- }
+ if (m_bRestoreViewOptions)
+ SW_MOD()->ApplyUsrPref( m_aOldViewOptions, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY );
}
/*****************************************************************************/