[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sw/inc sw/source
Oliver-Rainer Wittmann
orw at apache.org
Tue Aug 20 03:10:33 PDT 2013
sw/inc/unotxdoc.hxx | 4 -
sw/source/ui/app/docsh.cxx | 50 ++++--------------
sw/source/ui/uno/unotxdoc.cxx | 113 +++++++++++++++++++++---------------------
3 files changed, 73 insertions(+), 94 deletions(-)
New commits:
commit 259d4118949dc89b6a6cbdcb51cafa809fd71594
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date: Tue Aug 20 09:02:15 2013 +0000
122868: PDF export - assure that rendering data are cleaned up by calling corresponding method in <SwDocShell::SaveCompleted(..)>
This changes the fix for issue 121125 which triggers 122868
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index f62f035..7a453e3 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -440,8 +440,8 @@ public:
SwXDrawPage* GetDrawPage();
SwDocShell* GetDocShell() {return pDocShell;}
- // #121125# react on ViewShell change
- void ReactOnViewShellChange();
+ // #121125#, #122868# - clean up rendering data
+ void CleanUpRenderingData();
void * SAL_CALL operator new( size_t ) throw();
void SAL_CALL operator delete( void * ) throw();
diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx
index 1e04d9d..5b39dda 100644
--- a/sw/source/ui/app/docsh.cxx
+++ b/sw/source/ui/app/docsh.cxx
@@ -77,6 +77,7 @@
#include <shellio.hxx> // I/O
#include <docstyle.hxx>
#include <doc.hxx>
+#include <unotxdoc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <docstat.hxx>
#include <pagedesc.hxx>
@@ -820,6 +821,18 @@ sal_Bool SwDocShell::SaveCompleted( const uno::Reference < embed::XStorage >& xS
if( bResetModified )
EnableSetModified( sal_True );
}
+
+ // #121125#, #122868#
+ // Clean up rendering data created by the usage of <XRenderable> interface
+ // of <SwXDocument> (e.g. export to PDF) and which is not cleaned up by
+ // "rendering the last page".
+ // This is needed to restore former <ViewOptions>. This is performed via
+ // a <ViewShell> reference hold by the rendering data. The rendering data
+ // also needs to loose the hold <ViewShell> reference. Otherwise, the application
+ // will crash on closing the document.
+ uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
+ ((SwXTextDocument*)xDoc.get())->CleanUpRenderingData();
+
return bRet;
}
@@ -1125,31 +1138,15 @@ SfxStyleSheetBasePool* SwDocShell::GetStyleSheetPool()
}
-#include <unotxdoc.hxx>
-
void SwDocShell::SetView(SwView* pVw)
{
- bool bChanged(false);
-
if(0 != (pView = pVw))
{
pWrtShell = &pView->GetWrtShell();
- bChanged = true;
}
else
{
pWrtShell = 0;
- bChanged = true;
- }
-
- if(bChanged)
- {
- // #121125# SwXTextDocument may hold references to the ViewShell, so inform
- // it about changes to allow to react on it. This happens e.g. when printing
- // and/or PDF export (SwViewOptionAdjust_Impl holds a reference to the view
- // and needs to be destroyed)
- uno::Reference< text::XTextDocument > xDoc(GetBaseModel(), uno::UNO_QUERY);
- ((SwXTextDocument*)xDoc.get())->ReactOnViewShellChange();
}
}
@@ -1159,37 +1156,18 @@ void SwDocShell::PrepareReload()
::DelAllGrfCacheEntries( pDoc );
}
-// --> OD 2006-11-07 #i59688#
// linked graphics are now loaded on demand.
// Thus, loading of linked graphics no longer needed and necessary for
// the load of document being finished.
void SwDocShell::LoadingFinished()
{
- // --> OD 2007-10-08 #i38810#
- // Original fix fails after integration of cws xmlsec11:
// interface <SfxObjectShell::EnableSetModified(..)> no longer works, because
// <SfxObjectShell::FinishedLoading(..)> doesn't care about its status and
// enables the document modification again.
// Thus, manuell modify the document, if its modified and its links are updated
// before <FinishedLoading(..)> is called.
const bool bHasDocToStayModified( pDoc->IsModified() && pDoc->LinksUpdated() );
-// // --> OD 2005-02-11 #i38810# - disable method <SetModified(..)>, if document
-// // has stay in modified state, due to the update of its links during load.
-// bool bResetEnableSetModified(false);
-// if ( IsEnableSetModified() &&
-// pDoc->IsModified() && pDoc->LinksUpdated() )
-// {
-// EnableSetModified( sal_False );
-// bResetEnableSetModified = true;
-// }
- // <--
FinishedLoading( SFX_LOADED_ALL );
-// // --> OD 2005-02-11 #i38810#
-// if ( bResetEnableSetModified )
-// {
-// EnableSetModified( sal_True );
-// }
-// // <--
SfxViewFrame* pVFrame = SfxViewFrame::GetFirst(this);
if(pVFrame)
{
@@ -1198,12 +1176,10 @@ void SwDocShell::LoadingFinished()
((SwSrcView*)pShell)->Load(this);
}
- // --> OD 2007-10-08 #i38810#
if ( bHasDocToStayModified && !pDoc->IsModified() )
{
pDoc->SetModified();
}
- // <--
}
// eine Uebertragung wird abgebrochen (wird aus dem SFX gerufen)
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index bdf4833..70c2b0a 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -2662,23 +2662,40 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
bool bIsSwSrcView = false;
SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
- if (!bIsSwSrcView && !m_pRenderData)
- m_pRenderData = new SwRenderData;
- if (!m_pPrintUIOptions)
- m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
- bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions );
- // const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
-
SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
DBG_ASSERT( pDoc && pView, "doc or view shell missing!" );
- if (!pDoc || !pView)
+ if ( pDoc == 0 || pView == 0 )
+ {
return 0;
+ }
+
+ // clean up <RenderData> and <PrintUIOptions>
+ {
+ if ( m_pRenderData )
+ {
+ delete m_pRenderData;
+ m_pRenderData = 0;
+ }
+ if ( m_pPrintUIOptions )
+ {
+ delete m_pPrintUIOptions;
+ m_pPrintUIOptions = 0;
+ }
+ }
+
+ if ( !bIsSwSrcView )
+ {
+ m_pRenderData = new SwRenderData;
+ }
+ // new <PrintUIOptions>
+ m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
+ const bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions );
// save current UI options from the print dialog for the next call to that dialog
lcl_SavePrintUIOptionsToDocumentPrintData( *pDoc, *m_pPrintUIOptions, bIsPDFExport );
sal_Int32 nRet = 0;
- if (bIsSwSrcView)
+ if ( bIsSwSrcView )
{
SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView);
OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
@@ -2711,7 +2728,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
if (!pViewShell || !pViewShell->GetLayout())
return 0;
- if (bFormat)
+ if ( bFormat )
{
// #i38289
if( pViewShell->GetViewOptions()->getBrowseMode() )
@@ -2727,7 +2744,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
// We don't want that! Thus we disable updating of the view.
pViewShell->StartAction();
- if (pSwView)
+ if ( pSwView )
{
if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pViewShell ) )
m_pRenderData->ViewOptionAdjustStop();
@@ -2739,11 +2756,12 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell,
m_pPrintUIOptions, m_pRenderData, bIsPDFExport );
- if (pSwView)
+ if ( pSwView )
{
// PDF export should not make use of the SwPrtOptions
const SwPrintData *pPrtOptions = (bIsPDFExport)
- ? NULL : m_pRenderData->GetSwPrtOptions();
+ ? NULL
+ : m_pRenderData->GetSwPrtOptions();
m_pRenderData->ViewOptionAdjust( pPrtOptions );
}
@@ -2854,10 +2872,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
if (!pDoc || !pView)
return uno::Sequence< beans::PropertyValue >();
- // due to #110067# (document page count changes sometimes during
- // PDF export/printing) we can not check for the upper bound properly.
- // Thus instead of throwing the exception we silently return.
- if (0 > nRenderer)
+ if ( nRenderer < 0 || nRenderer >= SAL_MAX_UINT16 )
throw IllegalArgumentException();
// TODO/mba: we really need a generic way to get the ViewShell!
@@ -2884,14 +2899,9 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
uno::Sequence< beans::PropertyValue > aRenderer;
if (m_pRenderData)
{
- // --> TL, OD 2010-09-07 #i114210#
- // determine the correct page number from the renderer index
- // --> OD 2010-10-01 #i114875
- // consider brochure print
- const sal_uInt16 nPage = bPrintProspect
- ? nRenderer + 1
- : m_pRenderData->GetPagesToPrint()[ nRenderer ];
- // <--
+ const sal_Int32 nPage = bPrintProspect
+ ? nRenderer + 1
+ : m_pRenderData->GetPagesToPrint()[ nRenderer ];
// get paper tray to use ...
sal_Int32 nPrinterPaperTray = -1;
@@ -2928,19 +2938,6 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
aTmpSize = pPrinter->LogicToLogic( aTmpSize,
pPrinter->GetMapMode(), MapMode( MAP_100TH_MM ));
aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() );
- #if 0
- // #i115048# it seems users didn't like getting double the formatted page size
- // revert to "old" behavior scaling to the current paper size of the printer
- if (bPrintProspect)
- {
- // we just state what output size we would need
- // which may cause vcl to set that page size on the printer
- // (if available and not overriden by the user)
- aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
- aPreferredPageSize = awt::Size ( TWIP_TO_MM100( 2 * aTmpSize.Width() ),
- TWIP_TO_MM100( aTmpSize.Height() ));
- }
- #else
if( bPrintProspect )
{
// just switch to an appropriate portrait/landscape format
@@ -2953,12 +2950,13 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
aPreferredPageSize.Height = aPageSize.Width;
}
}
- #endif
}
}
else
{
- aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
+ ASSERT( nPage > 0 && nPage <= SAL_MAX_UINT16,
+ "<SwXTextDocument::getRenderer(..)> - unexpected value for the page number, it does not fit into sal_uInt16." );
+ aTmpSize = pVwSh->GetPageSize( static_cast< sal_uInt16 >(nPage), bIsSkipEmptyPages );
aPageSize = awt::Size ( TWIP_TO_MM100( aTmpSize.Width() ),
TWIP_TO_MM100( aTmpSize.Height() ));
}
@@ -2985,7 +2983,6 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
}
}
- // --> OD #i117783#
if ( bApplyPagePrintSettingsFromXPagePrintable )
{
const SwPagePreViewPrtData* pPagePrintSettings =
@@ -3040,7 +3037,6 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
bApplyPagePrintSettingsFromXPagePrintable = sal_False;
}
- // <--
m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
@@ -3086,9 +3082,6 @@ SfxViewShell * SwXTextDocument::GuessViewShell(
if (pView)
rbIsSwSrcView = pSwSrcView != 0;
return pView;
-// return pSwView ? dynamic_cast< SfxViewShell * >(pSwView) :
-// (pSwSrcView ? dynamic_cast< SfxViewShell * >(pSwSrcView) :
-// dynamic_cast< SfxViewShell * >(pSwPagePreView) );
}
@@ -3112,12 +3105,18 @@ void SAL_CALL SwXTextDocument::render(
bool bIsSwSrcView = false;
SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
- DBG_ASSERT( m_pRenderData, "data should have been created already in getRendererCount..." );
- DBG_ASSERT( m_pPrintUIOptions, "data should have been created already in getRendererCount..." );
- if (!bIsSwSrcView && !m_pRenderData)
+ // error handling - avoid crash
+ if ( !bIsSwSrcView && m_pRenderData == NULL )
+ {
+ DBG_ASSERT( false, "data should have been created already in getRendererCount..." );
m_pRenderData = new SwRenderData;
- if (!m_pPrintUIOptions)
+ }
+ if ( m_pPrintUIOptions == 0 )
+ {
+ DBG_ASSERT( false, "data should have been created already in getRendererCount..." );
m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
+ }
+
m_pPrintUIOptions->processProperties( rxOptions );
const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False );
@@ -3236,7 +3235,6 @@ void SAL_CALL SwXTextDocument::render(
SwDocShell *pRenderDocShell = pDoc->GetDocShell();
SfxItemSet *pSet = pRenderDocShell->GetMedium()->GetItemSet();
pSet->Put( SfxBoolItem( SID_HIDDEN, sal_False ) );
-
}
}
}
@@ -3504,17 +3502,22 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
return aLanguages;
}
-// #121125# react on ViewShell change; a reference to the ViewShell is
-// held in SwViewOptionAdjust_Impl, thus needs to be cleaned up
-void SwXTextDocument::ReactOnViewShellChange()
+// #121125#, #122868#
+// method to assure clean up of the rendering data to restore view options
+// and to loose hold reference to the ViewShell in SwViewOptionAdjust_Impl.
+void SwXTextDocument::CleanUpRenderingData()
{
- if(m_pRenderData)
+ if( m_pRenderData != NULL )
{
+ if ( m_pRenderData->HasPostItData() )
+ {
+ m_pRenderData->DeletePostItData();
+ }
delete m_pRenderData;
m_pRenderData = NULL;
}
- if(m_pPrintUIOptions)
+ if( m_pPrintUIOptions != NULL )
{
delete m_pPrintUIOptions;
m_pPrintUIOptions = NULL;
More information about the Libreoffice-commits
mailing list