summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEilidh McAdam <eilidh.mcadam@gmail.com>2014-07-25 20:38:08 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2014-09-30 09:49:01 +0200
commita23a9b548f388c15342febc148043b9601180a61 (patch)
tree52a9ee8326fa9d1a294dd1148dec41bca25bb4c1
parent139221df5e020fb4ec7a8192e6d908b713a448e7 (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> (cherry picked from commit 126b4407bade85298f983f545d6f507534fab61d) Conflicts: sw/source/uibase/dbui/dbmgr.cxx
-rw-r--r--sw/inc/dbmgr.hxx2
-rw-r--r--sw/source/ui/dbui/dbmgr.cxx254
2 files changed, 0 insertions, 256 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 15e4658186ca..79bcddf38bfc 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -378,8 +378,6 @@ public:
sal_Int32 _nCommandType,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
);
- //merge into one document - returns the number of merged docs
- sal_Int32 MergeDocuments( SwMailMergeConfigItem& rMMConfig, SwView& rSourceView );
};
#endif
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 5fd1f72049e8..50b7e9b2c203 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -2790,260 +2790,6 @@ uno::Reference<XResultSet> SwNewDBMgr::createCursor(const OUString& _sDataSource
return xResultSet;
}
-
-// merge all data into one resulting document and return the number of merged documents
-sal_Int32 SwNewDBMgr::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 false;
- bInMerge = sal_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 = sal_True;
- }
- else
- {
- pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
- pImpl->pMergeData->CheckEndOfDB();
- }
- }
- catch(const Exception&)
- {
- pImpl->pMergeData->bEndOfDB = sal_True;
- pImpl->pMergeData->CheckEndOfDB();
- OSL_FAIL("exception in MergeNew()");
- }
-
- //bCancel is set from the PrintMonitor
- bCancel = sal_False;
-
- CreateMonitor aMonitorDlg(&rSourceView.GetEditWin());
- aMonitorDlg.SetCancelHdl(LINK(this, SwNewDBMgr, 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(sal_True);
- sal_uInt16 nStartingPageNo = rSourceShell.GetVirtPageNum();
- String sModifiedStartingPageDesc;
- String 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();
- SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
- pWorkDoc->SetNewDBMgr( this );
- pWorkDoc->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();
-
- SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
- rWorkShell.ViewShell::UpdateFlds();
- SFX_APP()->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
- String 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->Append( *(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 DBMgr
- pWorkDoc->SetNewDBMgr( pWorkDBMgr );
- // 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 SwNewDBMgr::MergeDocuments");
- }
- DELETEZ(pImpl->pMergeData);
- bInMerge = sal_False;
- return nRet;
-}
-
SwConnectionDisposedListener_Impl::SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr) :
rDBMgr(rMgr)
{