summaryrefslogtreecommitdiff
path: root/sw/source/ui/uno/unotxdoc.cxx
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2010-11-03 15:31:40 +0100
committerMathias Bauer <mba@openoffice.org>2010-11-03 15:31:40 +0100
commit2f9f480b22f2fff59d9c48b4b46706c3d5223e66 (patch)
treeafa230a86cd485ff91f1c4f79b9d72e66b89948a /sw/source/ui/uno/unotxdoc.cxx
parentf9ae468e1cb8242ce7a9b1b33ca202fd0f649841 (diff)
CWS swlayoutrefactoring: found logical conflict after resync: not every view has a WrtShell, so try to do printing with ViewShell where possible
Diffstat (limited to 'sw/source/ui/uno/unotxdoc.cxx')
-rw-r--r--sw/source/ui/uno/unotxdoc.cxx103
1 files changed, 59 insertions, 44 deletions
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index 0a047fb7679c..e038b00577b2 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -2375,10 +2375,10 @@ void SwXTextDocument::refresh(void) throw( RuntimeException )
::vos::OGuard aGuard(Application::GetSolarMutex());
if(!IsValid())
throw RuntimeException();
- SwWrtShell *pWrtShell = pDocShell->GetWrtShell();
+ ViewShell *pViewShell = pDocShell->GetWrtShell();
notifyRefreshListeners();
- if(pWrtShell)
- pWrtShell->CalcLayout();
+ if(pViewShell)
+ pViewShell->CalcLayout();
}
/*-- 21.02.00 08:41:06---------------------------------------------------
@@ -2685,48 +2685,59 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
else
{
SwDocShell *pRenderDocShell = pDoc->GetDocShell();
- SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell();
- if (!pWrtShell->GetLayout())
+
+ // TODO/mba: we really need a generic way to get the ViewShell!
+ ViewShell* pViewShell = 0;
+ SwView* pSwView = PTR_CAST(SwView, pView);
+ if ( pSwView )
+ {
+ pViewShell = pSwView->GetWrtShellPtr();
+ }
+ else
+ {
+ if ( bIsPDFExport && bFormat )
+ {
+ //create a hidden view to be able to export as PDF also in print preview
+ //pView and pSwView are not changed intentionally!
+ m_pHiddenViewFrame = SfxViewFrame::LoadHiddenDocument( *pRenderDocShell, 2 );
+ pViewShell = ((SwView*)m_pHiddenViewFrame->GetViewShell())->GetWrtShellPtr();
+ }
+ else
+ pViewShell = ((SwPagePreView*)pView)->GetViewShell();
+ }
+
+ if (!pViewShell || !pViewShell->GetLayout())
return 0;
if (bFormat)
{
// #i38289
- if( pWrtShell && pWrtShell->GetViewOptions()->getBrowseMode() )
+ if( pViewShell->GetViewOptions()->getBrowseMode() )
{
- SwViewOption aOpt( *pWrtShell->GetViewOptions() );
+ SwViewOption aOpt( *pViewShell->GetViewOptions() );
aOpt.setBrowseMode( false );
- pWrtShell->ApplyViewOptions( aOpt );
- pWrtShell->GetView().RecheckBrowseMode();
- }
-
- if (!pWrtShell)
- {
- //create a hidden view to be able to export as PDF also in print preview
- m_pHiddenViewFrame = SfxViewFrame::LoadHiddenDocument( *pRenderDocShell, 2 );
- SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell();
- pWrtShell = pSwView->GetWrtShellPtr();
+ pViewShell->ApplyViewOptions( aOpt );
+ pSwView->RecheckBrowseMode();
}
// reformating the document for printing will show the changes in the view
// which is likely to produce many unwanted and not nice to view actions.
// We don't want that! Thus we disable updating of the view.
- pWrtShell->StartAction();
+ pViewShell->StartAction();
- const TypeId aSwViewTypeId = TYPE(SwView);
- if (pView->IsA(aSwViewTypeId))
+ if (pSwView)
{
- if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pWrtShell ) )
+ if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pViewShell ) )
m_pRenderData->ViewOptionAdjustStop();
if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust())
- m_pRenderData->ViewOptionAdjustStart( *pWrtShell, *pWrtShell->GetViewOptions() );
+ m_pRenderData->ViewOptionAdjustStart( *pViewShell, *pViewShell->GetViewOptions() );
}
m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) );
m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell,
m_pPrintUIOptions, m_pRenderData, bIsPDFExport );
- if (pView->IsA(aSwViewTypeId))
+ if (pSwView)
{
// PDF export should not make use of the SwPrtOptions
const SwPrtOptions *pPrtOptions = bIsPDFExport? NULL : m_pRenderData->GetSwPrtOptions();
@@ -2735,7 +2746,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
// since printing now also use the API for PDF export this option
// should be set for printing as well ...
- pWrtShell->SetPDFExportOption( sal_True );
+ pViewShell->SetPDFExportOption( sal_True );
bool bOrigStatus = pRenderDocShell->IsEnableSetModified();
// check configuration: shall update of printing information in DocInfo set the document to "modified"?
bool bStateChanged = false;
@@ -2745,9 +2756,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
bStateChanged = true;
}
-
// --> FME 2005-05-23 #122919# Force field update before PDF export:
- pWrtShell->ViewShell::UpdateFlds(TRUE);
+ pViewShell->UpdateFlds(TRUE);
// <--
if( bStateChanged )
pRenderDocShell->EnableSetModified( sal_True );
@@ -2755,17 +2765,16 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
// there is some redundancy between those two function calls, but right now
// there is no time to sort this out.
//TODO: check what exatly needs to be done and make just one function for that
- pWrtShell->CalcLayout();
- pWrtShell->CalcPagesForPrint( pWrtShell->GetPageCount() );
-
- pWrtShell->SetPDFExportOption( sal_False );
+ pViewShell->CalcLayout();
+ pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );
+ pViewShell->SetPDFExportOption( sal_False );
// enable view again
- pWrtShell->EndAction();
+ pViewShell->EndAction();
}
- const sal_Int32 nPageCount = pWrtShell->GetPageCount();
+ const sal_Int32 nPageCount = pViewShell->GetPageCount();
//
// get number of pages to be rendered
@@ -2773,7 +2782,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
if (bPrintProspect)
{
- pDoc->CalculatePagePairsForProspectPrinting( *pWrtShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, nPageCount );
+ pDoc->CalculatePagePairsForProspectPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, nPageCount );
nRet = m_pRenderData->GetPagePairsForProspectPrinting().size();
}
else
@@ -2782,12 +2791,12 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
if (nPostItMode != POSTITS_NONE)
{
OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
- m_pRenderData->CreatePostItData( pDoc, pWrtShell->GetViewOptions(), pOutDev );
+ m_pRenderData->CreatePostItData( pDoc, pViewShell->GetViewOptions(), pOutDev );
}
// get set of valid document pages (according to the current settings)
// and their start frames
- pDoc->CalculatePagesForPrinting( *pWrtShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount );
+ pDoc->CalculatePagesForPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount );
if (nPostItMode != POSTITS_NONE)
{
@@ -2844,10 +2853,13 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
if (0 > nRenderer)
throw IllegalArgumentException();
- const TypeId aSwViewTypeId = TYPE(SwView);
- ViewShell* pVwSh = pView->IsA(aSwViewTypeId) ?
- ((SwView*)pView)->GetWrtShellPtr() :
- ((SwPagePreView*)pView)->GetViewShell();
+ // TODO/mba: we really need a generic way to get the ViewShell!
+ ViewShell* pVwSh = 0;
+ SwView* pSwView = PTR_CAST(SwView, pView);
+ if ( pSwView )
+ pVwSh = pSwView->GetWrtShellPtr();
+ else
+ pVwSh = ((SwPagePreView*)pView)->GetViewShell();
sal_Int32 nMaxRenderer = 0;
if (!bIsSwSrcView && m_pRenderData)
@@ -3061,9 +3073,12 @@ void SAL_CALL SwXTextDocument::render(
ViewShell* pVwSh = 0;
if (pView)
{
- pVwSh = pView->IsA(aSwViewTypeId) ?
- ((SwView*)pView)->GetWrtShellPtr() :
- ((SwPagePreView*)pView)->GetViewShell();
+ // TODO/mba: we really need a generic way to get the ViewShell!
+ SwView* pSwView = PTR_CAST(SwView, pView);
+ if ( pSwView )
+ pVwSh = pSwView->GetWrtShellPtr();
+ else
+ pVwSh = ((SwPagePreView*)pView)->GetViewShell();
}
// get output device to use
@@ -3327,7 +3342,7 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
}
}
- //get languages from "drawobject"
+ //TODO/mba: it's a strange concept that a view is needed to retrieve core data
SwWrtShell *pWrtSh = pDocShell->GetWrtShell();
SdrView *pSdrView = pWrtSh->GetDrawView();
@@ -4109,7 +4124,7 @@ void SwXDocumentPropertyHelper::onChange()
/*****************************************************************************/
-SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwViewOption &rViewOptions ) :
+SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( ViewShell& rSh, const SwViewOption &rViewOptions ) :
m_rShell( rSh ),
m_aOldViewOptions( rViewOptions )
{