diff options
-rw-r--r-- | sw/inc/dbmgr.hxx | 2 | ||||
-rw-r--r-- | sw/inc/swabstdlg.hxx | 2 | ||||
-rw-r--r-- | sw/inc/view.hxx | 6 | ||||
-rw-r--r-- | sw/source/ui/dbui/mailmergewizard.cxx | 44 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmresultdialogs.cxx | 116 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/app/apphdl.cxx | 127 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 29 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx | 36 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mmconfigitem.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/inc/mailmergewizard.hxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/inc/uivwimp.hxx | 18 | ||||
-rw-r--r-- | sw/source/uibase/uiview/uivwimp.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view0.cxx | 8 |
15 files changed, 208 insertions, 198 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index af2f73aa7319..af22755f2a21 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -293,7 +293,7 @@ public: inline bool IsMergeOk() { return MergeStatus::OK == m_aMergeStatus; }; inline bool IsMergeError() { return MergeStatus::ERROR <= m_aMergeStatus; }; - static SwMailMergeConfigItem* PerformMailMerge(SwView* pView); + static std::shared_ptr<SwMailMergeConfigItem> PerformMailMerge(SwView* pView); /// Initialize data fields that lack name of database. inline bool IsInitDBFields() const { return bInitDBFields; } diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index e62002b6314b..16ed380f1567 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -448,7 +448,7 @@ public: virtual VclAbstractDialog * CreateIndexMarkModalDlg( vcl::Window *pParent, SwWrtShell& rSh, SwTOXMark* pCurTOXMark) = 0; - virtual AbstractMailMergeWizard* CreateMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rConfigItem) = 0; + virtual AbstractMailMergeWizard* CreateMailMergeWizard(SwView& rView, std::shared_ptr<SwMailMergeConfigItem>& rConfigItem) = 0; virtual GlossaryGetCurrGroup GetGlossaryCurrGroupFunc() = 0; virtual GlossarySetActGroup SetGlossaryActGroupFunc() = 0; diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index 38f7c6cac032..2493d96ce1fc 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -613,9 +613,9 @@ public: // store MailMerge data while "Back to Mail Merge Wizard" FloatingWindow is active // or to support printing - void SetMailMergeConfigItem(SwMailMergeConfigItem* pConfigItem, sal_uInt16 nRestart, bool bIsSource); - SwMailMergeConfigItem* GetMailMergeConfigItem(); - SwMailMergeConfigItem* EnsureMailMergeConfigItem(const SfxItemSet* pArgs = nullptr, sal_uInt16 nWizardRestartPage = 0); + void SetMailMergeConfigItem(std::shared_ptr<SwMailMergeConfigItem>& rConfigItem, sal_uInt16 nRestart); + std::shared_ptr<SwMailMergeConfigItem> GetMailMergeConfigItem(); + std::shared_ptr<SwMailMergeConfigItem> EnsureMailMergeConfigItem(const SfxItemSet* pArgs = nullptr, sal_uInt16 nWizardRestartPage = 0); void ExecFormatPaintbrush(SfxRequest &); void StateFormatPaintbrush(SfxItemSet &); diff --git a/sw/source/ui/dbui/mailmergewizard.cxx b/sw/source/ui/dbui/mailmergewizard.cxx index d013c0779ec0..968c71e201ee 100644 --- a/sw/source/ui/dbui/mailmergewizard.cxx +++ b/sw/source/ui/dbui/mailmergewizard.cxx @@ -38,12 +38,12 @@ using namespace svt; using namespace ::com::sun::star; -SwMailMergeWizard::SwMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rItem) : +SwMailMergeWizard::SwMailMergeWizard(SwView& rView, std::shared_ptr<SwMailMergeConfigItem>& rItem) : RoadmapWizard(&rView.GetViewFrame()->GetWindow(), WizardButtonFlags::NEXT|WizardButtonFlags::PREVIOUS|WizardButtonFlags::FINISH|WizardButtonFlags::CANCEL|WizardButtonFlags::HELP), m_pSwView(&rView), m_bDocumentLoad( false ), - m_rConfigItem(rItem), + m_xConfigItem(rItem), m_sStarting( SW_RES( ST_STARTING )), m_sDocumentType( SW_RES( ST_DOCUMENTTYPE )), m_sAddressBlock( SW_RES( ST_ADDRESSBLOCK )), @@ -61,7 +61,7 @@ SwMailMergeWizard::SwMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rItem m_pPrevPage->SetHelpId(HID_MM_PREV_PAGE); //#i51949# no output type page visible if e-Mail is not supported - if(rItem.IsMailAvailable()) + if (m_xConfigItem->IsMailAvailable()) declarePath( 0, {MM_DOCUMENTSELECTPAGE, @@ -111,20 +111,20 @@ void SwMailMergeWizard::enterState( WizardState _nState ) of greeting and address block - if not yet done entering the merge or output page requires to create the output document */ - if(_nState > MM_LAYOUTPAGE && m_rConfigItem.GetSourceView() && - ((m_rConfigItem.IsAddressBlock() && !m_rConfigItem.IsAddressInserted()) || - (m_rConfigItem.IsGreetingLine(false) && !m_rConfigItem.IsGreetingInserted() ))) + if(_nState > MM_LAYOUTPAGE && m_xConfigItem->GetSourceView() && + ((m_xConfigItem->IsAddressBlock() && !m_xConfigItem->IsAddressInserted()) || + (m_xConfigItem->IsGreetingLine(false) && !m_xConfigItem->IsGreetingInserted() ))) { - SwMailMergeLayoutPage::InsertAddressAndGreeting(m_rConfigItem.GetSourceView(), - m_rConfigItem, Point(-1, -1), true); + SwMailMergeLayoutPage::InsertAddressAndGreeting(m_xConfigItem->GetSourceView(), + *m_xConfigItem, Point(-1, -1), true); } - if(m_rConfigItem.GetTargetView()) + if (m_xConfigItem->GetTargetView()) { //close the dialog, remove the target view, show the source view m_nRestartPage = _nState; //set ResultSet back to start - m_rConfigItem.MoveResultSet(1); + m_xConfigItem->MoveResultSet(1); EndDialog(RET_REMOVE_TARGET); return; } @@ -136,7 +136,7 @@ void SwMailMergeWizard::enterState( WizardState _nState ) bEnablePrev = false; // the first page break; case MM_ADDRESSBLOCKPAGE : - bEnableNext = m_rConfigItem.GetResultSet().is(); + bEnableNext = m_xConfigItem->GetResultSet().is(); break; case MM_LAYOUTPAGE: bEnableNext = false; // the last page @@ -157,7 +157,7 @@ OUString SwMailMergeWizard::getStateDisplayName( WizardState _nState ) const case MM_OUTPUTTYPETPAGE: return m_sDocumentType; case MM_ADDRESSBLOCKPAGE: - return m_rConfigItem.IsOutputToLetter() ? + return m_xConfigItem->IsOutputToLetter() ? m_sAddressBlock : m_sAddressList; case MM_GREETINGSPAGE: return m_sGreetingsLine; @@ -185,12 +185,12 @@ void SwMailMergeWizard::UpdateRoadmap() TabPage* pCurPage = GetPage( nCurPage ); if(!pCurPage) return; - bool bAddressFieldsConfigured = !m_rConfigItem.IsOutputToLetter() || - !m_rConfigItem.IsAddressBlock() || - m_rConfigItem.IsAddressFieldsAssigned(); - bool bGreetingFieldsConfigured = !m_rConfigItem.IsGreetingLine(false) || - !m_rConfigItem.IsIndividualGreeting(false)|| - m_rConfigItem.IsGreetingFieldsAssigned(); + bool bAddressFieldsConfigured = !m_xConfigItem->IsOutputToLetter() || + !m_xConfigItem->IsAddressBlock() || + m_xConfigItem->IsAddressFieldsAssigned(); + bool bGreetingFieldsConfigured = !m_xConfigItem->IsGreetingLine(false) || + !m_xConfigItem->IsIndividualGreeting(false) || + m_xConfigItem->IsGreetingFieldsAssigned(); //#i97436# if a document has to be loaded then enable output type page only m_bDocumentLoad = false; @@ -199,7 +199,7 @@ void SwMailMergeWizard::UpdateRoadmap() // handle the Finish button bool bCanFinish = !m_bDocumentLoad && bEnableOutputTypePage && - m_rConfigItem.GetResultSet().is() && + m_xConfigItem->GetResultSet().is() && bAddressFieldsConfigured && bGreetingFieldsConfigured; enableButtons(WizardButtonFlags::FINISH, (nCurPage != MM_DOCUMENTSELECTPAGE) && bCanFinish); @@ -220,13 +220,13 @@ void SwMailMergeWizard::UpdateRoadmap() break; case MM_GREETINGSPAGE: bEnable = !m_bDocumentLoad && bEnableOutputTypePage && - m_rConfigItem.GetResultSet().is() && + m_xConfigItem->GetResultSet().is() && bAddressFieldsConfigured; break; case MM_LAYOUTPAGE: bEnable = bCanFinish && - ((m_rConfigItem.IsAddressBlock() && !m_rConfigItem.IsAddressInserted()) || - (m_rConfigItem.IsGreetingLine(false) && !m_rConfigItem.IsGreetingInserted() )); + ((m_xConfigItem->IsAddressBlock() && !m_xConfigItem->IsAddressInserted()) || + (m_xConfigItem->IsGreetingLine(false) && !m_xConfigItem->IsGreetingInserted() )); break; } enableState( nPage, bEnable ); diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx index 66bb81a65e80..2b66f5d1ff0b 100644 --- a/sw/source/ui/dbui/mmresultdialogs.cxx +++ b/sw/source/ui/dbui/mmresultdialogs.cxx @@ -237,9 +237,9 @@ SwMMResultSaveDialog::SwMMResultSaveDialog(vcl::Window* pParent) // m_pSaveAsOneRB is the default, so disable m_pFromNF and m_pToNF initially. aLink.Call(m_pSaveAsOneRB); SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); - assert(pConfigItem); - sal_Int32 nCount = pConfigItem->GetMergedDocumentCount();; + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); + assert(xConfigItem); + sal_Int32 nCount = xConfigItem->GetMergedDocumentCount();; m_pToNF->SetMax(nCount); m_pToNF->SetValue(nCount); @@ -381,7 +381,7 @@ void SwMMResultPrintDialog::FillInPrinterSettings() { //fill printer ListBox SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); const std::vector<OUString>& rPrinters = Printer::GetPrinterQueues(); unsigned int nCount = rPrinters.size(); bool bMergePrinterExists = false; @@ -390,13 +390,13 @@ void SwMMResultPrintDialog::FillInPrinterSettings() for( unsigned int i = 0; i < nCount; i++ ) { m_pPrinterLB->InsertEntry( rPrinters[i] ); - if( !bMergePrinterExists && rPrinters[i] == pConfigItem->GetSelectedPrinter() ) + if( !bMergePrinterExists && rPrinters[i] == xConfigItem->GetSelectedPrinter() ) bMergePrinterExists = true; } } - assert(pConfigItem); + assert(xConfigItem); if(!bMergePrinterExists) { SfxPrinter* pPrinter = pView->GetWrtShell().getIDocumentDeviceAccess().getPrinter( true ); @@ -404,23 +404,23 @@ void SwMMResultPrintDialog::FillInPrinterSettings() } else { - m_pPrinterLB->SelectEntry(pConfigItem->GetSelectedPrinter()); + m_pPrinterLB->SelectEntry(xConfigItem->GetSelectedPrinter()); } - sal_Int32 count = pConfigItem->GetMergedDocumentCount();; + sal_Int32 count = xConfigItem->GetMergedDocumentCount();; m_pToNF->SetValue(count); m_pToNF->SetMax(count); - m_pPrinterLB->SelectEntry(pConfigItem->GetSelectedPrinter()); + m_pPrinterLB->SelectEntry(xConfigItem->GetSelectedPrinter()); } void SwMMResultEmailDialog::FillInEmailSettings() { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); - assert(pConfigItem); + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); + assert(xConfigItem); - SwView* pSourceView = pConfigItem->GetSourceView(); + SwView* pSourceView = xConfigItem->GetSourceView(); OSL_ENSURE(pSourceView, "no source view exists"); if (pSourceView) { @@ -447,7 +447,7 @@ void SwMMResultEmailDialog::FillInEmailSettings() if (!m_pMailToLB->GetEntryCount()) { //select first column - uno::Reference< sdbcx::XColumnsSupplier > xColsSupp(pConfigItem->GetResultSet(), uno::UNO_QUERY); + uno::Reference< sdbcx::XColumnsSupplier > xColsSupp(xConfigItem->GetResultSet(), uno::UNO_QUERY); //get the name of the actual columns uno::Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : nullptr; uno::Sequence< OUString > aFields; @@ -459,9 +459,9 @@ void SwMMResultEmailDialog::FillInEmailSettings() m_pMailToLB->SelectEntryPos(0); // then select the right one - may not be available - const ResStringArray& rHeaders = pConfigItem->GetDefaultAddressHeaders(); + const ResStringArray& rHeaders = xConfigItem->GetDefaultAddressHeaders(); OUString sEMailColumn = rHeaders.GetString( MM_PART_E_MAIL ); - Sequence< OUString> aAssignment = pConfigItem->GetColumnAssignment(pConfigItem->GetCurrentDBData()); + Sequence< OUString> aAssignment = xConfigItem->GetColumnAssignment(xConfigItem->GetCurrentDBData()); if (aAssignment.getLength() > MM_PART_E_MAIL && !aAssignment[MM_PART_E_MAIL].isEmpty()) sEMailColumn = aAssignment[MM_PART_E_MAIL]; m_pMailToLB->SelectEntry(sEMailColumn); @@ -571,12 +571,12 @@ void endDialog(Button* pButton) IMPL_LINK_TYPED(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void) { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); - assert(pConfigItem); - if(!pConfigItem->GetTargetView()) + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); + assert(xConfigItem); + if (!xConfigItem->GetTargetView()) SwDBManager::PerformMailMerge(pView); - SwView* pTargetView = pConfigItem->GetTargetView(); + SwView* pTargetView = xConfigItem->GetTargetView(); assert(pTargetView); if(m_pSaveAsOneRB->IsChecked()) @@ -617,7 +617,7 @@ IMPL_LINK_TYPED(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void { sal_uInt32 nBegin = 0; sal_uInt32 nEnd = 0; - sal_uInt32 documentCount = pConfigItem->GetMergedDocumentCount(); + sal_uInt32 documentCount = xConfigItem->GetMergedDocumentCount(); if(m_pSaveIndividualRB->IsChecked()) { @@ -670,7 +670,7 @@ IMPL_LINK_TYPED(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void ErrorHandler::HandleError( nErrorCode ); } - SwView* pSourceView = pConfigItem->GetSourceView(); + SwView* pSourceView = xConfigItem->GetSourceView(); ScopedVclPtrInstance< PrintMonitor > aSaveMonitor(this, false, PrintMonitor::MONITOR_TYPE_SAVE); aSaveMonitor->m_pDocName->SetText(pSourceView->GetDocShell()->GetTitle(22)); aSaveMonitor->SetCancelHdl(LINK(this, SwMMResultSaveDialog, SaveCancelHdl_Impl)); @@ -710,7 +710,7 @@ IMPL_LINK_TYPED(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void pTempView->GetDocShell()->GetDoc()->ReplaceDocumentProperties( *pTargetView->GetDocShell()->GetDoc(), true ); pTargetView->GetWrtShell().PastePages(pTempView->GetWrtShell(), - documentStartPageNumber(pConfigItem, nDoc), documentEndPageNumber(pConfigItem, nDoc)); + documentStartPageNumber(xConfigItem.get(), nDoc), documentEndPageNumber(xConfigItem.get(), nDoc)); pTargetView->GetWrtShell().EndAction(); //then save it OUString sOutPath = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI); @@ -763,8 +763,8 @@ IMPL_LINK_TYPED(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void IMPL_LINK_TYPED(SwMMResultPrintDialog, PrinterChangeHdl_Impl, ListBox&, rBox, void) { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); - assert(pConfigItem); + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); + assert(xConfigItem); if (rBox.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND) { const QueueInfo* pInfo = Printer::GetQueueInfo( rBox.GetSelectEntry(), false ); @@ -793,23 +793,23 @@ IMPL_LINK_TYPED(SwMMResultPrintDialog, PrinterChangeHdl_Impl, ListBox&, rBox, vo else m_pPrinterSettingsPB->Disable(); - pConfigItem->SetSelectedPrinter(rBox.GetSelectEntry()); + xConfigItem->SetSelectedPrinter(rBox.GetSelectEntry()); } IMPL_LINK_TYPED(SwMMResultPrintDialog, PrintHdl_Impl, Button*, pButton, void) { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); - assert(pConfigItem); - if(!pConfigItem->GetTargetView()) + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); + assert(xConfigItem); + if(!xConfigItem->GetTargetView()) SwDBManager::PerformMailMerge(pView); - SwView* pTargetView = pConfigItem->GetTargetView(); + SwView* pTargetView = xConfigItem->GetTargetView(); assert(pTargetView); sal_uInt32 nBegin = 0; sal_uInt32 nEnd = 0; - sal_uInt32 documentCount = pConfigItem->GetMergedDocumentCount(); + sal_uInt32 documentCount = xConfigItem->GetMergedDocumentCount(); if(m_pPrintAllRB->IsChecked()) { @@ -823,13 +823,13 @@ IMPL_LINK_TYPED(SwMMResultPrintDialog, PrintHdl_Impl, Button*, pButton, void) if(nEnd > documentCount) nEnd = documentCount; } - pConfigItem->SetPrintRange((sal_uInt16)nBegin, (sal_uInt16)nEnd); + xConfigItem->SetPrintRange((sal_uInt16)nBegin, (sal_uInt16)nEnd); - OUString sPages(OUString::number(documentStartPageNumber(pConfigItem, nBegin))); + OUString sPages(OUString::number(documentStartPageNumber(xConfigItem.get(), nBegin))); sPages += " - "; - sPages += OUString::number(documentEndPageNumber(pConfigItem, nEnd - 1)); + sPages += OUString::number(documentEndPageNumber(xConfigItem.get(), nEnd - 1)); - pTargetView->SetMailMergeConfigItem(pConfigItem, 0, false); + pTargetView->SetMailMergeConfigItem(xConfigItem, 0); if(m_pTempPrinter) { SfxPrinter *const pDocumentPrinter = pTargetView->GetWrtShell() @@ -902,17 +902,17 @@ IMPL_LINK_TYPED(SwMMResultEmailDialog, SendAsHdl_Impl, Button*, pButton, void) IMPL_LINK_TYPED(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, void) { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); - assert(pConfigItem); - if(!pConfigItem->GetTargetView()) + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); + assert(xConfigItem); + if (!xConfigItem->GetTargetView()) SwDBManager::PerformMailMerge(pView); //get the composed document - SwView* pTargetView = pConfigItem->GetTargetView(); + SwView* pTargetView = xConfigItem->GetTargetView(); assert(pTargetView); - if(pConfigItem->GetMailServer().isEmpty() || - !SwMailMergeHelper::CheckMailAddress(pConfigItem->GetMailAddress()) ) + if (xConfigItem->GetMailServer().isEmpty() || + !SwMailMergeHelper::CheckMailAddress(xConfigItem->GetMailAddress()) ) { ScopedVclPtrInstance< QueryBox > aQuery(pButton, WB_YES_NO_CANCEL, m_sConfigureMail); sal_uInt16 nRet = aQuery->Execute(); @@ -932,14 +932,14 @@ IMPL_LINK_TYPED(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, if(m_pSendAllRB->IsChecked()) { nBegin = 0; - nEnd = pConfigItem->GetMergedDocumentCount(); + nEnd = xConfigItem->GetMergedDocumentCount(); } else { nBegin = static_cast< sal_Int32 >(m_pFromNF->GetValue() - 1); nEnd = static_cast< sal_Int32 >(m_pToNF->GetValue()); - if(nEnd > pConfigItem->GetMergedDocumentCount()) - nEnd = pConfigItem->GetMergedDocumentCount(); + if(nEnd > xConfigItem->GetMergedDocumentCount()) + nEnd = xConfigItem->GetMergedDocumentCount(); } bool bAsBody = false; rtl_TextEncoding eEncoding = ::osl_getThreadTextEncoding(); @@ -1047,7 +1047,7 @@ IMPL_LINK_TYPED(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, SfxStringItem aFilterName( SID_FILTER_NAME, pSfxFlt->GetFilterName() ); OUString sEMailColumn = m_pMailToLB->GetSelectEntry(); OSL_ENSURE( !sEMailColumn.isEmpty(), "No email column selected"); - Reference< sdbcx::XColumnsSupplier > xColsSupp( pConfigItem->GetResultSet(), UNO_QUERY); + Reference< sdbcx::XColumnsSupplier > xColsSupp( xConfigItem->GetResultSet(), UNO_QUERY); Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : nullptr; if(sEMailColumn.isEmpty() || !xColAccess.is() || !xColAccess->hasByName(sEMailColumn)) { @@ -1086,7 +1086,7 @@ IMPL_LINK_TYPED(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, xStore->storeToURL( sTargetTempURL, aValues ); //create the send dialog - VclPtr<SwSendMailDialog> pDlg = VclPtr<SwSendMailDialog>::Create(pButton, *pConfigItem); + VclPtr<SwSendMailDialog> pDlg = VclPtr<SwSendMailDialog>::Create(pButton, *xConfigItem); pDlg->SetDocumentCount( nEnd ); pDlg->ShowDialog(); //help to force painting the dialog @@ -1096,7 +1096,7 @@ IMPL_LINK_TYPED(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, Application::Reschedule(); for(sal_uInt32 nDoc = nBegin; nDoc < nEnd; ++nDoc) { - SwDocMergeInfo& rInfo = pConfigItem->GetDocumentMergeInfo(nDoc); + SwDocMergeInfo& rInfo = xConfigItem->GetDocumentMergeInfo(nDoc); //now extract a document from the target document // the shell will be closed at the end, but it is more safe to use SfxObjectShellLock here @@ -1117,7 +1117,7 @@ IMPL_LINK_TYPED(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, pTempView->GetDocShell()->GetDoc()->ReplaceDefaults( *pTargetView->GetDocShell()->GetDoc()); pTempView->GetDocShell()->GetDoc()->ReplaceDocumentProperties( *pTargetView->GetDocShell()->GetDoc(), true ); pTargetView->GetWrtShell().PastePages(pTempView->GetWrtShell(), - documentStartPageNumber(pConfigItem, nDoc), documentEndPageNumber(pConfigItem, nDoc)); + documentStartPageNumber(xConfigItem.get(), nDoc), documentEndPageNumber(xConfigItem.get(), nDoc)); pTargetView->GetWrtShell().EndAction(); //then save it @@ -1143,7 +1143,7 @@ IMPL_LINK_TYPED(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, } xTempDocShell->DoClose(); - sal_Int32 nTarget = pConfigItem->MoveResultSet(rInfo.nDBRow); + sal_Int32 nTarget = xConfigItem->MoveResultSet(rInfo.nDBRow); OSL_ENSURE( nTarget == rInfo.nDBRow, "row of current document could not be selected"); (void)nTarget; OSL_ENSURE( !sEMailColumn.isEmpty(), "No email column selected"); @@ -1192,30 +1192,30 @@ IMPL_LINK_TYPED(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, aDesc.sAttachmentName = sAttachment; aDesc.sMimeType = sMimeType; - if(pConfigItem->IsGreetingLine(true)) + if (xConfigItem->IsGreetingLine(true)) { - OUString sNameColumn = pConfigItem->GetAssignedColumn(MM_PART_LASTNAME); + OUString sNameColumn = xConfigItem->GetAssignedColumn(MM_PART_LASTNAME); OUString sName = lcl_GetColumnValueOf(sNameColumn, xColAccess); OUString sGreeting; - if(!sName.isEmpty() && pConfigItem->IsIndividualGreeting(true)) + if(!sName.isEmpty() && xConfigItem->IsIndividualGreeting(true)) { - OUString sGenderColumn = pConfigItem->GetAssignedColumn(MM_PART_GENDER); - const OUString& sFemaleValue = pConfigItem->GetFemaleGenderValue(); + OUString sGenderColumn = xConfigItem->GetAssignedColumn(MM_PART_GENDER); + const OUString& sFemaleValue = xConfigItem->GetFemaleGenderValue(); OUString sGenderValue = lcl_GetColumnValueOf(sGenderColumn, xColAccess); SwMailMergeConfigItem::Gender eGenderType = sGenderValue == sFemaleValue ? SwMailMergeConfigItem::FEMALE : SwMailMergeConfigItem::MALE; sGreeting = SwAddressPreview::FillData( - pConfigItem->GetGreetings(eGenderType) - [pConfigItem->GetCurrentGreeting(eGenderType)], - *pConfigItem); + xConfigItem->GetGreetings(eGenderType) + [xConfigItem->GetCurrentGreeting(eGenderType)], + *xConfigItem); } else { sGreeting = - pConfigItem->GetGreetings(SwMailMergeConfigItem::NEUTRAL) - [pConfigItem->GetCurrentGreeting(SwMailMergeConfigItem::NEUTRAL)]; + xConfigItem->GetGreetings(SwMailMergeConfigItem::NEUTRAL) + [xConfigItem->GetCurrentGreeting(SwMailMergeConfigItem::NEUTRAL)]; } sGreeting += "\n"; diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 02d250d80d7f..f3f71dd0dfa4 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -1116,7 +1116,7 @@ VclAbstractDialog * SwAbstractDialogFactory_Impl::CreateIndexMarkModalDlg( } AbstractMailMergeWizard* SwAbstractDialogFactory_Impl::CreateMailMergeWizard( - SwView& rView, SwMailMergeConfigItem& rConfigItem) + SwView& rView, std::shared_ptr<SwMailMergeConfigItem>& rConfigItem) { return new AbstractMailMergeWizard_Impl( VclPtr<SwMailMergeWizard>::Create(rView, rConfigItem)); } diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index d087c47a782e..3b365b433989 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -486,7 +486,7 @@ public: virtual VclAbstractDialog * CreateIndexMarkModalDlg( vcl::Window *pParent, SwWrtShell& rSh, SwTOXMark* pCurTOXMark ) override; - virtual AbstractMailMergeWizard* CreateMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rConfigItem) override; + virtual AbstractMailMergeWizard* CreateMailMergeWizard(SwView& rView, std::shared_ptr<SwMailMergeConfigItem>& rConfigItem) override; virtual GlossaryGetCurrGroup GetGlossaryCurrGroupFunc() override; virtual GlossarySetActGroup SetGlossaryActGroupFunc() override; diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index 20a794807d39..fc088df0496b 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -208,13 +208,15 @@ void SwModule::StateOther(SfxItemSet &rSet) case FN_MAILMERGE_LAST_ENTRY: { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView?pView->GetMailMergeConfigItem():nullptr; - if (!pConfigItem) + std::shared_ptr<SwMailMergeConfigItem> xConfigItem; + if (pView) + xConfigItem = pView->GetMailMergeConfigItem(); + if (!xConfigItem) rSet.DisableItem(nWhich); else { bool bFirst, bLast; - bool bValid = pConfigItem->IsResultSetFirstLast(bFirst, bLast); + bool bValid = xConfigItem->IsResultSetFirstLast(bFirst, bLast); if (!bValid || (bFirst && (nWhich == FN_MAILMERGE_FIRST_ENTRY || nWhich == FN_MAILMERGE_PREV_ENTRY)) || @@ -239,13 +241,15 @@ void SwModule::StateOther(SfxItemSet &rSet) case FN_MAILMERGE_EMAIL_DOCUMENTS: { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView ? pView->EnsureMailMergeConfigItem() : nullptr; + std::shared_ptr<SwMailMergeConfigItem> xConfigItem; + if (pView) + xConfigItem = pView->EnsureMailMergeConfigItem(); // #i51949# hide e-Mail option if e-Mail is not supported // #i63267# printing might be disabled - if (!pConfigItem || + if (!xConfigItem || (nWhich == FN_MAILMERGE_PRINT_DOCUMENTS && Application::GetSettings().GetMiscSettings().GetDisablePrinting()) || - (nWhich == FN_MAILMERGE_EMAIL_DOCUMENTS && !pConfigItem->IsMailAvailable())) + (nWhich == FN_MAILMERGE_EMAIL_DOCUMENTS && !xConfigItem->IsMailAvailable())) { rSet.DisableItem(nWhich); } @@ -263,14 +267,14 @@ void NewXForms( SfxRequest& rReq ); // implementation: below #if HAVE_FEATURE_DBCONNECTIVITY -SwMailMergeConfigItem* SwView::EnsureMailMergeConfigItem(const SfxItemSet* pArgs, sal_uInt16 nWizardRestartPage) +std::shared_ptr<SwMailMergeConfigItem> SwView::EnsureMailMergeConfigItem(const SfxItemSet* pArgs, sal_uInt16 nWizardRestartPage) { // create if it does not exist yet - SwMailMergeConfigItem* pMMConfig = GetMailMergeConfigItem(); - if (!pMMConfig) + std::shared_ptr<SwMailMergeConfigItem> xMMConfig = GetMailMergeConfigItem(); + if (!xMMConfig) { - pMMConfig = new SwMailMergeConfigItem; - pMMConfig->SetSourceView(this); + xMMConfig.reset(new SwMailMergeConfigItem); + xMMConfig->SetSourceView(this); //set the first used database as default source on the config item const SfxPoolItem* pItem = nullptr; @@ -298,7 +302,7 @@ SwMailMergeConfigItem* SwView::EnsureMailMergeConfigItem(const SfxItemSet* pArgs uno::Reference<container::XChild> xChild(xConnection, uno::UNO_QUERY); if (xChild.is()) xSource.set(xChild->getParent(), uno::UNO_QUERY); - pMMConfig->SetCurrentConnection( + xMMConfig->SetCurrentConnection( xSource, SharedConnection(xConnection, SharedConnection::NoTakeOwnership), xColumnsSupplier, aDBData); } @@ -316,13 +320,13 @@ SwMailMergeConfigItem* SwView::EnsureMailMergeConfigItem(const SfxItemSet* pArgs aDBData.sCommand = sDBName.getToken(1, DB_DELIM); aDBData.nCommandType = sDBName.getToken(2, DB_DELIM).toInt32(); //set the currently used database for the wizard - pMMConfig->SetCurrentDBData(aDBData); + xMMConfig->SetCurrentDBData(aDBData); } } - SetMailMergeConfigItem(pMMConfig, nWizardRestartPage, true); + SetMailMergeConfigItem(xMMConfig, nWizardRestartPage); } - return pMMConfig; + return xMMConfig; } namespace @@ -447,10 +451,10 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs acquire(); // create if it does not exist yet - SwMailMergeConfigItem* pMMConfig = m_pView->EnsureMailMergeConfigItem(pArgs, m_pWizard ? m_pWizard->GetRestartPage() : 0); + std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->EnsureMailMergeConfigItem(pArgs, m_pWizard ? m_pWizard->GetRestartPage() : 0); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *pMMConfig); + m_pWizard = pFact->CreateMailMergeWizard(*m_pView, xMMConfig); uno::Reference<beans::XPropertySet> xPropSet(m_pView->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY); if (!xPropSet.is()) @@ -476,9 +480,9 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs void SwMailMergeWizardExecutor::ExecutionFinished() { - SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem(); - if (pMMConfig) - pMMConfig->Commit(); + std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem(); + if (xMMConfig) + xMMConfig->Commit(); // release/destroy asynchronously Application::PostUserEvent( LINK( this, SwMailMergeWizardExecutor, DestroyDialogHdl ) ); @@ -506,19 +510,19 @@ IMPL_LINK_NOARG_TYPED( SwMailMergeWizardExecutor, EndDialogHdl, Dialog&, void ) LINK( this, SwMailMergeWizardExecutor, DestroyWizardHdl ), m_pWizard ); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem(); + std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem(); if (pNewView) { m_pView = pNewView; - pMMConfig->DocumentReloaded(); + xMMConfig->DocumentReloaded(); //new source view! - pMMConfig->SetSourceView( m_pView ); - m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *pMMConfig); + xMMConfig->SetSourceView( m_pView ); + m_pWizard = pFact->CreateMailMergeWizard(*m_pView, xMMConfig); m_pWizard->ShowPage( nRestartPage ); } else { - m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *pMMConfig); + m_pWizard = pFact->CreateMailMergeWizard(*m_pView, xMMConfig); } // execute the wizard again @@ -527,8 +531,8 @@ IMPL_LINK_NOARG_TYPED( SwMailMergeWizardExecutor, EndDialogHdl, Dialog&, void ) } case RET_TARGET_CREATED: { - SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem(); - SwView* pTargetView = pMMConfig->GetTargetView(); + std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem(); + SwView* pTargetView = xMMConfig->GetTargetView(); OSL_ENSURE(pTargetView, "No target view has been created"); if(pTargetView) { @@ -537,7 +541,7 @@ IMPL_LINK_NOARG_TYPED( SwMailMergeWizardExecutor, EndDialogHdl, Dialog&, void ) LINK( this, SwMailMergeWizardExecutor, DestroyWizardHdl ), m_pWizard ); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - m_pWizard = pFact->CreateMailMergeWizard(*pTargetView, *pMMConfig); + m_pWizard = pFact->CreateMailMergeWizard(*pTargetView, xMMConfig); m_pWizard->ShowPage( nRestartPage ); // execute the wizard again @@ -552,9 +556,9 @@ IMPL_LINK_NOARG_TYPED( SwMailMergeWizardExecutor, EndDialogHdl, Dialog&, void ) } case RET_REMOVE_TARGET: { - SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem(); - SwView* pTargetView = pMMConfig->GetTargetView(); - SwView* pSourceView = pMMConfig->GetSourceView(); + std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem(); + SwView* pTargetView = xMMConfig->GetTargetView(); + SwView* pSourceView = xMMConfig->GetSourceView(); OSL_ENSURE(pTargetView && pSourceView, "source or target view not available" ); if(pTargetView && pSourceView) { @@ -563,14 +567,14 @@ IMPL_LINK_NOARG_TYPED( SwMailMergeWizardExecutor, EndDialogHdl, Dialog&, void ) pSourceView->GetViewFrame()->GetFrame().AppearWithUpdate(); // the current view has be set when the target is destroyed m_pView = pSourceView; - pMMConfig->SetTargetView(nullptr); + xMMConfig->SetTargetView(nullptr); // destroy wizard asynchronously Application::PostUserEvent( LINK( this, SwMailMergeWizardExecutor, CloseFrameHdl ), m_pWizard ); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - m_pWizard = pFact->CreateMailMergeWizard(*pSourceView, *pMMConfig); + m_pWizard = pFact->CreateMailMergeWizard(*pSourceView, xMMConfig); m_pWizard->ShowPage( nRestartPage ); // execute the wizard again @@ -592,11 +596,11 @@ IMPL_LINK_NOARG_TYPED( SwMailMergeWizardExecutor, EndDialogHdl, Dialog&, void ) } default: // finish { - SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem(); - SwView* pSourceView = pMMConfig->GetSourceView(); + std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem(); + SwView* pSourceView = xMMConfig->GetSourceView(); if(pSourceView) { - pMMConfig->GetSourceView()->GetViewFrame()->GetFrame().Appear(); + xMMConfig->GetSourceView()->GetViewFrame()->GetFrame().Appear(); } ExecutionFinished(); break; @@ -620,16 +624,17 @@ IMPL_STATIC_LINK_TYPED(SwMailMergeWizardExecutor, DestroyWizardHdl, void*, pDial IMPL_LINK_NOARG_TYPED(SwMailMergeWizardExecutor, CancelHdl, void*, void) { - if (SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem()) + std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem(); + if (xMMConfig) { - if (pMMConfig->GetTargetView()) + if (xMMConfig->GetTargetView()) { - pMMConfig->GetTargetView()->GetViewFrame()->DoClose(); - pMMConfig->SetTargetView(nullptr); + xMMConfig->GetTargetView()->GetViewFrame()->DoClose(); + xMMConfig->SetTargetView(nullptr); } - if (pMMConfig->GetSourceView()) + if (xMMConfig->GetSourceView()) { - auto pViewFrame(pMMConfig->GetSourceView()->GetViewFrame()); + auto pViewFrame(xMMConfig->GetSourceView()->GetViewFrame()); pViewFrame->GetFrame().AppearWithUpdate(); uno::Reference<beans::XPropertySet> xPropSet(pViewFrame->GetFrame().GetFrameInterface(), uno::UNO_QUERY); if (xPropSet.is() && m_bDestroyMMToolbarOnCancel) @@ -645,7 +650,7 @@ IMPL_LINK_NOARG_TYPED(SwMailMergeWizardExecutor, CancelHdl, void*, void) } } } - pMMConfig->Commit(); + xMMConfig->Commit(); } delete m_pWizard; @@ -737,33 +742,33 @@ void SwModule::ExecOther(SfxRequest& rReq) case FN_MAILMERGE_CURRENT_ENTRY: { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); - if (!pConfigItem) + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); + if (!xConfigItem) return; - sal_Int32 nPos = pConfigItem->GetResultSetPosition(); + sal_Int32 nPos = xConfigItem->GetResultSetPosition(); switch (nWhich) { - case FN_MAILMERGE_FIRST_ENTRY: pConfigItem->MoveResultSet(1); break; - case FN_MAILMERGE_PREV_ENTRY: pConfigItem->MoveResultSet(nPos - 1); break; - case FN_MAILMERGE_NEXT_ENTRY: pConfigItem->MoveResultSet(nPos + 1); break; - case FN_MAILMERGE_LAST_ENTRY: pConfigItem->MoveResultSet(-1); break; + case FN_MAILMERGE_FIRST_ENTRY: xConfigItem->MoveResultSet(1); break; + case FN_MAILMERGE_PREV_ENTRY: xConfigItem->MoveResultSet(nPos - 1); break; + case FN_MAILMERGE_NEXT_ENTRY: xConfigItem->MoveResultSet(nPos + 1); break; + case FN_MAILMERGE_LAST_ENTRY: xConfigItem->MoveResultSet(-1); break; case FN_MAILMERGE_CURRENT_ENTRY: /* don't move the result set, just update the document */ break; default: break; } // now the record has to be merged into the source document // TODO can we re-use PerformMailMerge() here somehow? - const SwDBData& rDBData = pConfigItem->GetCurrentDBData(); - uno::Sequence<uno::Any> vSelection({ uno::makeAny(pConfigItem->GetResultSetPosition()) }); + const SwDBData& rDBData = xConfigItem->GetCurrentDBData(); + uno::Sequence<uno::Any> vSelection({ uno::makeAny(xConfigItem->GetResultSetPosition()) }); svx::ODataAccessDescriptor aDescriptor(::comphelper::InitPropertySequence({ {"Selection", uno::makeAny(vSelection)}, {"DataSourceName", uno::makeAny(rDBData.sDataSource)}, {"Command", uno::makeAny(rDBData.sCommand)}, {"CommandType", uno::makeAny(rDBData.nCommandType)}, - {"ActiveConnection", uno::makeAny(pConfigItem->GetConnection().getTyped())}, - {"Filter", uno::makeAny(pConfigItem->GetFilter())}, - {"Cursor", uno::makeAny(pConfigItem->GetResultSet())} + {"ActiveConnection", uno::makeAny(xConfigItem->GetConnection().getTyped())}, + {"Filter", uno::makeAny(xConfigItem->GetFilter())}, + {"Cursor", uno::makeAny(xConfigItem->GetResultSet())} })); SwWrtShell& rSh = pView->GetWrtShell(); @@ -783,20 +788,20 @@ void SwModule::ExecOther(SfxRequest& rReq) break; case FN_MAILMERGE_CREATE_DOCUMENTS: { - SwMailMergeConfigItem* pConfigItem = SwDBManager::PerformMailMerge(GetActiveView()); + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = SwDBManager::PerformMailMerge(GetActiveView()); - if (pConfigItem && pConfigItem->GetTargetView()) - pConfigItem->GetTargetView()->GetViewFrame()->GetFrame().Appear(); + if (xConfigItem && xConfigItem->GetTargetView()) + xConfigItem->GetTargetView()->GetViewFrame()->GetFrame().Appear(); } break; case FN_MAILMERGE_SAVE_DOCUMENTS: case FN_MAILMERGE_PRINT_DOCUMENTS: case FN_MAILMERGE_EMAIL_DOCUMENTS: { - SwMailMergeConfigItem* pConfigItem = GetActiveView()->GetMailMergeConfigItem(); - if(!pConfigItem) + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = GetActiveView()->GetMailMergeConfigItem(); + if(!xConfigItem) return; - pConfigItem->SetTargetView(nullptr); + xConfigItem->SetTargetView(nullptr); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); switch (nWhich) { diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index afae323ff76a..0f1c18d71d50 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -3070,31 +3070,32 @@ void SwConnectionDisposedListener_Impl::disposing( const lang::EventObject& rSou } } } -SwMailMergeConfigItem* SwDBManager::PerformMailMerge(SwView* pView) + +std::shared_ptr<SwMailMergeConfigItem> SwDBManager::PerformMailMerge(SwView* pView) { - SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); - if (!pConfigItem) - return nullptr; + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); + if (!xConfigItem) + return xConfigItem; svx::ODataAccessDescriptor aDescriptor; - aDescriptor.setDataSource(pConfigItem->GetCurrentDBData().sDataSource); - aDescriptor[ svx::daConnection ] <<= pConfigItem->GetConnection().getTyped(); - aDescriptor[ svx::daCursor ] <<= pConfigItem->GetResultSet(); - aDescriptor[ svx::daCommand ] <<= pConfigItem->GetCurrentDBData().sCommand; - aDescriptor[ svx::daCommandType ] <<= pConfigItem->GetCurrentDBData().nCommandType; - aDescriptor[ svx::daSelection ] <<= pConfigItem->GetSelection(); + aDescriptor.setDataSource(xConfigItem->GetCurrentDBData().sDataSource); + aDescriptor[ svx::daConnection ] <<= xConfigItem->GetConnection().getTyped(); + aDescriptor[ svx::daCursor ] <<= xConfigItem->GetResultSet(); + aDescriptor[ svx::daCommand ] <<= xConfigItem->GetCurrentDBData().sCommand; + aDescriptor[ svx::daCommandType ] <<= xConfigItem->GetCurrentDBData().nCommandType; + aDescriptor[ svx::daSelection ] <<= xConfigItem->GetSelection(); SwWrtShell& rSh = pView->GetWrtShell(); - pConfigItem->SetTargetView(nullptr); + xConfigItem->SetTargetView(nullptr); SwMergeDescriptor aMergeDesc(DBMGR_MERGE_SHELL, rSh, aDescriptor); - aMergeDesc.pMailMergeConfigItem = pConfigItem; + aMergeDesc.pMailMergeConfigItem = xConfigItem.get(); aMergeDesc.bCreateSingleFile = true; rSh.GetDBManager()->Merge(aMergeDesc); - pConfigItem->SetMergeDone(); + xConfigItem->SetMergeDone(); - return pConfigItem; + return xConfigItem; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx index fff50a68abc7..c3b866f7fd12 100644 --- a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx +++ b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx @@ -194,16 +194,18 @@ uno::Reference<awt::XWindow> MMCurrentEntryController::createItemWindow(const un IMPL_LINK_TYPED(MMCurrentEntryController, CurrentEditUpdatedHdl, Edit&, rEdit, void) { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView ? pView->GetMailMergeConfigItem() : nullptr; + std::shared_ptr<SwMailMergeConfigItem> xConfigItem; + if (pView) + xConfigItem = pView->GetMailMergeConfigItem(); - if (!pConfigItem) + if (!xConfigItem) return; OUString aText(rEdit.GetText()); sal_Int32 nEntry = aText.toInt32(); - if (!aText.isEmpty() && nEntry != pConfigItem->GetResultSetPosition()) + if (!aText.isEmpty() && nEntry != xConfigItem->GetResultSetPosition()) { - pConfigItem->MoveResultSet(nEntry); + xConfigItem->MoveResultSet(nEntry); // notify about the change dispatchCommand(".uno:MailMergeCurrentEntry", uno::Sequence<beans::PropertyValue>()); } @@ -215,9 +217,11 @@ void MMCurrentEntryController::statusChanged(const frame::FeatureStateEvent& rEv return; SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView ? pView->GetMailMergeConfigItem() : nullptr; + std::shared_ptr<SwMailMergeConfigItem> xConfigItem; + if (pView) + xConfigItem = pView->GetMailMergeConfigItem(); - if (!pConfigItem || !rEvent.IsEnabled) + if (!xConfigItem || !rEvent.IsEnabled) { m_pCurrentEdit->Disable(); m_pCurrentEdit->SetText(""); @@ -225,10 +229,10 @@ void MMCurrentEntryController::statusChanged(const frame::FeatureStateEvent& rEv else { sal_Int32 nEntry = m_pCurrentEdit->GetText().toInt32(); - if (!m_pCurrentEdit->IsEnabled() || nEntry != pConfigItem->GetResultSetPosition()) + if (!m_pCurrentEdit->IsEnabled() || nEntry != xConfigItem->GetResultSetPosition()) { m_pCurrentEdit->Enable(); - m_pCurrentEdit->SetText(OUString::number(pConfigItem->GetResultSetPosition())); + m_pCurrentEdit->SetText(OUString::number(xConfigItem->GetResultSetPosition())); } } } @@ -261,10 +265,12 @@ uno::Reference<awt::XWindow> MMExcludeEntryController::createItemWindow(const un IMPL_STATIC_LINK_TYPED(MMExcludeEntryController, ExcludeHdl, CheckBox&, rCheckbox, void) { SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView ? pView->GetMailMergeConfigItem() : nullptr; + std::shared_ptr<SwMailMergeConfigItem> xConfigItem; + if (pView) + xConfigItem = pView->GetMailMergeConfigItem(); - if (pConfigItem) - pConfigItem->ExcludeRecord(pConfigItem->GetResultSetPosition(), rCheckbox.IsChecked()); + if (xConfigItem) + xConfigItem->ExcludeRecord(xConfigItem->GetResultSetPosition(), rCheckbox.IsChecked()); }; void MMExcludeEntryController::statusChanged(const frame::FeatureStateEvent& rEvent) throw (uno::RuntimeException, std::exception) @@ -273,9 +279,11 @@ void MMExcludeEntryController::statusChanged(const frame::FeatureStateEvent& rEv return; SwView* pView = ::GetActiveView(); - SwMailMergeConfigItem* pConfigItem = pView ? pView->GetMailMergeConfigItem() : nullptr; + std::shared_ptr<SwMailMergeConfigItem> xConfigItem; + if (pView) + xConfigItem = pView->GetMailMergeConfigItem(); - if (!pConfigItem || !rEvent.IsEnabled) + if (!xConfigItem || !rEvent.IsEnabled) { m_pExcludeCheckbox->Disable(); m_pExcludeCheckbox->Check(false); @@ -283,7 +291,7 @@ void MMExcludeEntryController::statusChanged(const frame::FeatureStateEvent& rEv else { m_pExcludeCheckbox->Enable(); - m_pExcludeCheckbox->Check(pConfigItem->IsRecordExcluded(pConfigItem->GetResultSetPosition())); + m_pExcludeCheckbox->Check(xConfigItem->IsRecordExcluded(xConfigItem->GetResultSetPosition())); } } diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx index c5c833cd2c79..14b13a1aecf7 100644 --- a/sw/source/uibase/dbui/mmconfigitem.cxx +++ b/sw/source/uibase/dbui/mmconfigitem.cxx @@ -732,7 +732,8 @@ SwMailMergeConfigItem::SwMailMergeConfigItem() : m_nEndPrint(0), m_pSourceView(nullptr), m_pTargetView(nullptr) -{} +{ +} void SwMailMergeConfigItem::stopDBChangeListening() { diff --git a/sw/source/uibase/inc/mailmergewizard.hxx b/sw/source/uibase/inc/mailmergewizard.hxx index ec8ab14f9fcf..5f8b5b7b7eab 100644 --- a/sw/source/uibase/inc/mailmergewizard.hxx +++ b/sw/source/uibase/inc/mailmergewizard.hxx @@ -37,7 +37,7 @@ class SwMailMergeWizard : public ::svt::RoadmapWizard OUString sDocumentURL; bool m_bDocumentLoad; - SwMailMergeConfigItem& m_rConfigItem; + std::shared_ptr<SwMailMergeConfigItem> m_xConfigItem; OUString m_sStarting; OUString m_sDocumentType; @@ -60,11 +60,11 @@ protected: virtual OUString getStateDisplayName( WizardState _nState ) const override; public: - SwMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rConfigItem); + SwMailMergeWizard(SwView& rView, std::shared_ptr<SwMailMergeConfigItem>& rConfigItem); virtual ~SwMailMergeWizard(); SwView* GetSwView() {return m_pSwView;} - SwMailMergeConfigItem& GetConfigItem() { return m_rConfigItem;} + SwMailMergeConfigItem& GetConfigItem() { return *m_xConfigItem.get();} void SetReloadDocument(const OUString& rURL) {sDocumentURL = rURL;} const OUString& GetReloadDocument() const {return sDocumentURL;} diff --git a/sw/source/uibase/inc/uivwimp.hxx b/sw/source/uibase/inc/uivwimp.hxx index 1d28e428ee5b..e7dddba5f8e8 100644 --- a/sw/source/uibase/inc/uivwimp.hxx +++ b/sw/source/uibase/inc/uivwimp.hxx @@ -106,9 +106,8 @@ class SwView_Impl ShellModes eShellMode; #if HAVE_FEATURE_DBCONNECTIVITY - SwMailMergeConfigItem* pConfigItem; - sal_uInt16 nMailMergeRestartPage; - bool bMailMergeSourceView; + std::shared_ptr<SwMailMergeConfigItem> xConfigItem; + sal_uInt16 nMailMergeRestartPage; #endif sfx2::DocumentInserter* m_pDocInserter; @@ -139,13 +138,12 @@ public: void AddTransferable(SwTransferable& rTransferable); #if HAVE_FEATURE_DBCONNECTIVITY - void SetMailMergeConfigItem(SwMailMergeConfigItem* pItem, - sal_uInt16 nRestart, bool bIsSource) - { pConfigItem = pItem; - nMailMergeRestartPage = nRestart; - bMailMergeSourceView = bIsSource; - } - SwMailMergeConfigItem* GetMailMergeConfigItem() {return pConfigItem;} + void SetMailMergeConfigItem(std::shared_ptr<SwMailMergeConfigItem>& rItem, sal_uInt16 nRestart) + { + xConfigItem = rItem; + nMailMergeRestartPage = nRestart; + } + std::shared_ptr<SwMailMergeConfigItem> GetMailMergeConfigItem() {return xConfigItem;} #endif //#i33307# restore editing position diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx index 5a0b42d8811b..60bcbc615579 100644 --- a/sw/source/uibase/uiview/uivwimp.cxx +++ b/sw/source/uibase/uiview/uivwimp.cxx @@ -61,9 +61,7 @@ SwView_Impl::SwView_Impl(SwView* pShell) , pClipEvtLstnr(nullptr) , eShellMode(SHELL_MODE_TEXT) #if HAVE_FEATURE_DBCONNECTIVITY - , pConfigItem(nullptr) , nMailMergeRestartPage(0) - , bMailMergeSourceView(true) #endif , m_pDocInserter(nullptr) , m_pRequest(nullptr) @@ -97,8 +95,7 @@ SwView_Impl::~SwView_Impl() pClipEvtLstnr->ViewDestroyed(); } #if HAVE_FEATURE_DBCONNECTIVITY - if(bMailMergeSourceView) - delete pConfigItem; + xConfigItem.reset(); #endif delete m_pDocInserter; delete m_pRequest; diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx index 75cfffedcdfd..bd4798e500b6 100644 --- a/sw/source/uibase/uiview/view0.cxx +++ b/sw/source/uibase/uiview/view0.cxx @@ -139,14 +139,14 @@ void SwView::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOpt #if HAVE_FEATURE_DBCONNECTIVITY -void SwView::SetMailMergeConfigItem(SwMailMergeConfigItem* pConfigItem, - sal_uInt16 nRestart, bool bIsSource) +void SwView::SetMailMergeConfigItem(std::shared_ptr<SwMailMergeConfigItem>& rConfigItem, + sal_uInt16 nRestart) { - m_pViewImpl->SetMailMergeConfigItem(pConfigItem, nRestart, bIsSource); + m_pViewImpl->SetMailMergeConfigItem(rConfigItem, nRestart); UIFeatureChanged(); } -SwMailMergeConfigItem* SwView::GetMailMergeConfigItem() +std::shared_ptr<SwMailMergeConfigItem> SwView::GetMailMergeConfigItem() { return m_pViewImpl->GetMailMergeConfigItem(); } |