diff options
author | Eilidh McAdam <eilidh.mcadam@gmail.com> | 2014-07-25 20:38:08 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2014-09-16 08:39:06 +0000 |
commit | 126b4407bade85298f983f545d6f507534fab61d (patch) | |
tree | 6cf74fac89624451047a57df3b266474f6770ed8 /sw/source | |
parent | 636718c960a36bc28d37a69ac102dd6cb696bfba (diff) |
Remove superfluous merge function.
The only caller of MergeDocuments now uses MergeMailFiles instead,
so MergeDocuments can be removed.
Change-Id: I03903a7f85c8328ab3f28cb1d23130557a1be7b4
Reviewed-on: https://gerrit.libreoffice.org/10982
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 252 |
1 files changed, 0 insertions, 252 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index fdd8e6956ce0..b28cfc5f22c4 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -2772,258 +2772,6 @@ uno::Reference<XResultSet> SwDBManager::createCursor(const OUString& _sDataSourc return xResultSet; } -// merge all data into one resulting document and return the number of merged documents -sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig, - SwView& rSourceView ) -{ -#ifdef DBG_UTIL - lcl_SaveDoc( rSourceView.GetDocShell(), "MergeSource" ); -#endif - - // check the availability of all data in the config item - uno::Reference< XResultSet> xResultSet = rMMConfig.GetResultSet(); - if(!xResultSet.is()) - return 0; - bInMerge = true; - sal_Int32 nRet = 0; - pImpl->pMergeData = new SwDSParam( - rMMConfig.GetCurrentDBData(), xResultSet, rMMConfig.GetSelection()); - - try{ - //set to start position - if(pImpl->pMergeData->aSelection.getLength()) - { - sal_Int32 nPos = 0; - pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos; - pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos ); - pImpl->pMergeData->CheckEndOfDB(); - if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength()) - pImpl->pMergeData->bEndOfDB = true; - } - else - { - pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first(); - pImpl->pMergeData->CheckEndOfDB(); - } - } - catch(const Exception&) - { - pImpl->pMergeData->bEndOfDB = true; - pImpl->pMergeData->CheckEndOfDB(); - OSL_FAIL("exception in MergeNew()"); - } - - //bCancel is set from the PrintMonitor - bCancel = false; - - CreateMonitor aMonitorDlg(&rSourceView.GetEditWin()); - aMonitorDlg.SetCancelHdl(LINK(this, SwDBManager, PrtCancelHdl)); - if (!IsMergeSilent()) - { - aMonitorDlg.Show(); - aMonitorDlg.Invalidate(); - aMonitorDlg.Update(); - // the print monitor needs some time to act - for( sal_uInt16 i = 0; i < 25; i++) - Application::Reschedule(); - } - - SwWrtShell& rSourceShell = rSourceView.GetWrtShell(); - bool bSynchronizedDoc = rSourceShell.IsLabelDoc() && rSourceShell.GetSectionFmtCount() > 1; - - //determine the page style and number used at the start of the source document - rSourceShell.SttEndDoc(true); - sal_uInt16 nStartingPageNo = rSourceShell.GetVirtPageNum(); - OUString sModifiedStartingPageDesc; - OUString sStartingPageDesc = sModifiedStartingPageDesc = rSourceShell.GetPageDesc( - rSourceShell.GetCurPageDesc()).GetName(); - - try - { - // create a target docshell to put the merged document into - SfxObjectShellRef xTargetDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) ); - xTargetDocShell->DoInitNew( 0 ); -#ifdef DBG_UTIL - lcl_SaveDoc( xTargetDocShell, "MergeDoc" ); -#endif - SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 ); - - //the created window has to be located at the same position as the source window - Window& rTargetWindow = pTargetFrame->GetFrame().GetWindow(); - Window& rSourceWindow = rSourceView.GetViewFrame()->GetFrame().GetWindow(); - rTargetWindow.SetPosPixel(rSourceWindow.GetPosPixel()); - - SwView* pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() ); - rMMConfig.SetTargetView(pTargetView); - - //initiate SelectShell() to create sub shells - pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() ); - SwWrtShell* pTargetShell = pTargetView->GetWrtShellPtr(); - SwDoc* pTargetDoc = pTargetShell->GetDoc(); - - //copy the styles from the source to the target document - pTargetView->GetDocShell()->_LoadStyles( *rSourceView.GetDocShell(), true ); - - // #i63806# - const SwPageDesc* pSourcePageDesc = rSourceShell.FindPageDescByName( sStartingPageDesc ); - const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster(); - bool bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() || - rMaster.GetFooter().IsActive(); - - // copy compatibility options - lcl_CopyCompatibilityOptions( rSourceShell, *pTargetShell); - // #72821# copy dynamic defaults - lcl_CopyDynamicDefaults( *rSourceShell.GetDoc(), *pTargetShell->GetDoc() ); - - long nStartRow, nEndRow; - sal_uLong nDocNo = 1; - sal_Int32 nDocCount = 0; - if( !IsMergeSilent() && lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) ) - aMonitorDlg.SetTotalCount( nDocCount ); - - do - { - nStartRow = pImpl->pMergeData->xResultSet->getRow(); - if (!IsMergeSilent()) - { - aMonitorDlg.SetCurrentPosition( nDocNo ); - aMonitorDlg.Invalidate(); - aMonitorDlg.Update(); - // the print monitor needs some time to act - for( sal_uInt16 i = 0; i < 25; i++) - Application::Reschedule(); - } - - // copy the source document - // the copy will be closed later, but it is more safe to use SfxObjectShellLock here - SfxObjectShellLock xWorkDocSh = rSourceView.GetDocShell()->GetDoc()->CreateCopy(true); -#ifdef DBG_UTIL - if ( nDocNo <= MAX_DOC_DUMP ) - lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo ); -#endif - - //create a ViewFrame - SwView* pWorkView = static_cast< SwView* >( SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 )->GetViewShell() ); - SwWrtShell& rWorkShell = pWorkView->GetWrtShell(); - pWorkView->AttrChangedNotify( &rWorkShell );// in order for SelectShell to be called - - // merge the data - SwDoc* pWorkDoc = rWorkShell.GetDoc(); - SwDBManager* pWorkDBManager = pWorkDoc->GetDBManager(); - pWorkDoc->SetDBManager( this ); - pWorkDoc->getIDocumentLinksAdministration().EmbedAllLinks(); - - SwUndoId nLastUndoId(UNDO_EMPTY); - if (rWorkShell.GetLastUndoInfo(0, & nLastUndoId)) - { - if (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId) - { - rWorkShell.Undo(); - } - } - - // #i69458# lock fields to prevent access to the result set while calculating layout - rWorkShell.LockExpFlds(); - // create a layout - rWorkShell.CalcLayout(); - rWorkShell.UnlockExpFlds(); - - SfxGetpApp()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), rWorkShell.GetView().GetViewFrame()->GetObjectShell())); - rWorkShell.SwViewShell::UpdateFlds(); - SfxGetpApp()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), rWorkShell.GetView().GetViewFrame()->GetObjectShell())); - - // strip invisible content and convert fields to text - rWorkShell.RemoveInvisibleContent(); - rWorkShell.ConvertFieldsToText(); - rWorkShell.SetNumberingRestart(); - if( bSynchronizedDoc ) - { - lcl_RemoveSectionLinks( rWorkShell ); - } - - // insert the document into the target document - - //#i63806# put the styles to the target document - //if the source uses headers or footers each new copy need to copy a new page styles - SwPageDesc* pTargetPageDesc; - if(bPageStylesWithHeaderFooter) - { - //create a new pagestyle - //copy the pagedesc from the current document to the new document and change the name of the to-be-applied style - OUString sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo ); - pTargetPageDesc = pTargetDoc->MakePageDesc( sNewPageDescName ); - const SwPageDesc* pWorkPageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc ); - - if(pWorkPageDesc && pTargetPageDesc) - { - pTargetDoc->CopyPageDesc( *pWorkPageDesc, *pTargetPageDesc, false ); - sModifiedStartingPageDesc = sNewPageDescName; - lcl_CopyFollowPageDesc( *pTargetShell, *pWorkPageDesc, *pTargetPageDesc, nDocNo ); - } - } - else - pTargetPageDesc = pTargetShell->FindPageDescByName( sModifiedStartingPageDesc ); - - sal_uInt16 nPageCountBefore = pTargetShell->GetPageCnt(); - OSL_ENSURE(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended"); - -#ifdef DBG_UTIL - if ( nDocNo <= MAX_DOC_DUMP ) - lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo ); -#endif - pTargetDoc->AppendDoc(*rWorkShell.GetDoc(), - nStartingPageNo, pTargetPageDesc, nDocNo == 1); - - // #i72820# calculate layout to be able to find the correct page index - pTargetShell->CalcLayout(); -#ifdef DBG_UTIL - if ( nDocNo <= MAX_DOC_DUMP ) - lcl_SaveDoc( xTargetDocShell, "MergeDoc" ); -#endif - - // add the document info to the config item - SwDocMergeInfo aMergeInfo; - aMergeInfo.nStartPageInTarget = nPageCountBefore; - aMergeInfo.nEndPageInTarget = pTargetShell->GetPageCnt(); - aMergeInfo.nDBRow = nStartRow; - rMMConfig.AddMergedDocument( aMergeInfo ); - ++nRet; - - // the print monitor needs some time to act - for( sal_uInt16 i = 0; i < 25; i++) - Application::Reschedule(); - - // restore the old DBManager - pWorkDoc->SetDBManager( pWorkDBManager ); - // close the temporary document - xWorkDocSh->DoClose(); - - nEndRow = pImpl->pMergeData->xResultSet->getRow(); - ++nDocNo; - } while( !bCancel && - (bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord())); - - // deselect all, go out of the frame and go to the beginning of the document - Point aPt(LONG_MIN, LONG_MIN); - pTargetShell->SelectObj(aPt, SW_LEAVE_FRAME); - if (pTargetShell->IsSelFrmMode()) - { - pTargetShell->UnSelectFrm(); - pTargetShell->LeaveSelFrmMode(); - } - pTargetShell->EnterStdMode(); - pTargetShell->SttDoc(); - - } - catch(const Exception&) - { - OSL_FAIL("exception caught in SwDBManager::MergeDocuments"); - } - DELETEZ(pImpl->pMergeData); - bInMerge = false; - return nRet; -} - SwConnectionDisposedListener_Impl::SwConnectionDisposedListener_Impl(SwDBManager& rMgr) : rDBManager(rMgr) { |