20#include <config_features.h>
21#include <config_fuzzers.h>
22#include <config_wasm_strip.h>
40#include <com/sun/star/document/UpdateDocMode.hpp>
72#include <com/sun/star/container/XChild.hpp>
73#include <com/sun/star/sdbc/XConnection.hpp>
74#include <com/sun/star/sdb/TextConnectionSettings.hpp>
75#include <com/sun/star/sdbc/XDataSource.hpp>
76#include <com/sun/star/task/OfficeRestartManager.hpp>
77#include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
82#include <LibreOfficeKit/LibreOfficeKitEnums.h>
87#include <officecfg/Office/Common.hxx>
95#define ShellClass_SwModule
103 GetStaticInterface()->RegisterStatusBar(StatusBarId::WriterStatusBar);
106 SfxVisibilityFlags::Standard | SfxVisibilityFlags::Client | SfxVisibilityFlags::Viewer,
107 ToolbarId::Module_Toolbox);
117 bool bWebView =
dynamic_cast<SwWebView*
>( pActView ) !=
nullptr;
123 case FN_BUSINESS_CARD:
127 bool bDisable =
false;
129 if( !pCurrView ||
dynamic_cast< const SwView *
>( pCurrView ) ==
nullptr )
156 case SID_ATTR_METRIC:
175 std::shared_ptr<SwMailMergeConfigItem> xConfigItem;
177 xConfigItem = pView->GetMailMergeConfigItem();
180 else if (xConfigItem->GetConnection().is()
181 && !xConfigItem->GetConnection()->isClosed())
184 bool bValid = xConfigItem->IsResultSetFirstLast(bFirst, bLast);
208 std::shared_ptr<SwMailMergeConfigItem> xConfigItem;
210 xConfigItem = pView->EnsureMailMergeConfigItem();
217 xConfigItem->GetCurrentDBData().sDataSource.isEmpty() ||
218 xConfigItem->GetCurrentDBData().sCommand.isEmpty() ||
219 (xConfigItem->GetConnection().is() && !xConfigItem->GetConnection()->isClosed() && !xConfigItem->GetResultSet().is()) ||
228 OSL_FAIL(
"::StateOther: default");
243 xMMConfig = std::make_shared<SwMailMergeConfigItem>();
244 xMMConfig->SetSourceView(
this);
252 uno::Sequence< beans::PropertyValue> aDBValues;
253 if (pItem->
GetValue() >>= aDBValues)
261 uno::Reference< sdbc::XConnection> xConnection;
262 uno::Reference< sdbc::XDataSource> xSource;
263 uno::Reference< sdbcx::XColumnsSupplier> xColumnsSupplier;
266 uno::Reference<container::XChild> xChild(xConnection, uno::UNO_QUERY);
268 xSource.set(xChild->getParent(), uno::UNO_QUERY);
269 xMMConfig->SetCurrentConnection(
271 xColumnsSupplier, aDBData);
276 std::vector<OUString> aDBNameList;
277 std::vector<OUString> aAllDBNames;
279 if (!aDBNameList.empty())
281 OUString sDBName(aDBNameList[0]);
288 xMMConfig->SetCurrentDBData(aDBData);
297#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
304 SwView* pNewView =
nullptr;
313 SfxCallMode::SYNCHRON,
314 { &
aURL, &aHidden, &aReferer, &aTargetFrameName }));
322 pNewView =
dynamic_cast<SwView*
>(pViewShell);
336 SfxStringItem aFactory(SID_NEWDOCDIRECT, SwDocShell::Factory().GetFilterContainer()->
GetName());
339 SID_NEWDOCDIRECT, SfxCallMode::SYNCHRON, { &aFactory }));
342 pNewView = pViewFrame ?
dynamic_cast<SwView*
>( pViewFrame->
GetViewShell() ) :
nullptr;
355 void EndDialogHdl(sal_Int32 nResponse);
356 DECL_LINK( DestroyDialogHdl,
void*,
void );
357 DECL_LINK( DestroyWizardHdl,
void*,
void );
361 void ExecutionFinished();
362 void ExecuteWizard();
365 SwMailMergeWizardExecutor();
366 virtual ~SwMailMergeWizardExecutor()
override;
368 void ExecuteMailMergeWizard(
const SfxItemSet * pArgs );
371SwMailMergeWizardExecutor::SwMailMergeWizardExecutor()
372 : m_pView( nullptr ),
373 m_pView2Close( nullptr ),
378SwMailMergeWizardExecutor::~SwMailMergeWizardExecutor()
380 OSL_ENSURE( m_pWizard ==
nullptr,
"SwMailMergeWizardExecutor: m_pWizard must be Null!" );
383bool lcl_hasAllComponentsAvailable()
389 catch (
const css::uno::Exception &)
392 "sw.core",
"assuming Base to be missing; caught ");
397void SwMailMergeWizardExecutor::ExecuteMailMergeWizard(
const SfxItemSet * pArgs )
399 if(!lcl_hasAllComponentsAvailable())
405 using namespace org::freedesktop::PackageKit;
408 const css::uno::Sequence< OUString > vPackages{
"libreoffice-base" };
409 xSyncDbusSessionHelper->InstallPackageNames(vPackages, OUString());
413 catch (
const css::uno::Exception &)
417 "trying to install LibreOffice Base, caught");
420 if (!xRestartManager->isRestartRequested(
false))
425 nullptr, VclMessageType::Info, VclButtonsType::Ok,
426 SwResId(STR_NO_BASE_FOR_MERGE)));
433 if (!xRestartManager->isRestartRequested(
false))
438 nullptr, VclMessageType::Info, VclButtonsType::Ok,
439 SwResId(STR_NO_BASE_FOR_MERGE)));
447 OSL_FAIL(
"SwMailMergeWizardExecutor::ExecuteMailMergeWizard: Already executing the wizard!" );
459 std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->EnsureMailMergeConfigItem(pArgs);
467void SwMailMergeWizardExecutor::ExecutionFinished()
469 std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem();
481 m_pView->ShowUIElement(
"private:resource/toolbar/mailmerge");
495 m_pView->GetViewFrame().GetBindings().Invalidate(slotIds);
502void SwMailMergeWizardExecutor::ExecuteWizard()
504 m_pWizard->StartExecuteAsync([
this](sal_Int32 nResult){
505 EndDialogHdl(nResult);
509void SwMailMergeWizardExecutor::EndDialogHdl(sal_Int32 nRet)
511 sal_uInt16 nRestartPage = m_pWizard->GetRestartPage();
517 SwView* pNewView = lcl_LoadDoc(m_pView, m_pWizard->GetReloadDocument());
521 m_pWizardToDestroyInCallback = m_pWizard;
523 LINK(
this, SwMailMergeWizardExecutor, DestroyWizardHdl ),
nullptr );
526 std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem();
531 xMMConfig->DocumentReloaded();
533 xMMConfig->SetSourceView( m_pView );
535 m_pWizard->ShowPage( nRestartPage );
548 std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem();
549 SwView* pTargetView = xMMConfig->GetTargetView();
550 OSL_ENSURE(pTargetView,
"No target view has been created");
554 m_pWizardToDestroyInCallback = m_pWizard;
556 LINK(
this, SwMailMergeWizardExecutor, DestroyWizardHdl ),
nullptr );
560 m_pWizard->ShowPage( nRestartPage );
574 std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem();
575 SwView* pTargetView = xMMConfig->GetTargetView();
576 SwView* pSourceView = xMMConfig->GetSourceView();
577 OSL_ENSURE(pTargetView && pSourceView,
"source or target view not available" );
578 if(pTargetView && pSourceView)
580 m_pView2Close = pTargetView;
584 m_pView = pSourceView;
585 xMMConfig->SetTargetView(
nullptr);
588 m_pWizardToDestroyInCallback = m_pWizard;
590 LINK(
this, SwMailMergeWizardExecutor, CloseFrameHdl ), m_pWizard );
594 m_pWizard->ShowPage( nRestartPage );
610 LINK(
this, SwMailMergeWizardExecutor, CancelHdl ), m_pWizard );
615 std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem();
616 SwView* pSourceView = xMMConfig ? xMMConfig->GetSourceView() :
nullptr;
628IMPL_LINK_NOARG(SwMailMergeWizardExecutor, DestroyDialogHdl,
void*,
void)
630 m_pWizard.disposeAndClear();
635IMPL_LINK_NOARG(SwMailMergeWizardExecutor, DestroyWizardHdl,
void*,
void)
637 m_pWizardToDestroyInCallback.disposeAndClear();
642 std::shared_ptr<SwMailMergeConfigItem> xMMConfig = m_pView->GetMailMergeConfigItem();
645 if (xMMConfig->GetTargetView())
647 xMMConfig->GetTargetView()->GetViewFrame().DoClose();
648 xMMConfig->SetTargetView(
nullptr);
650 if (xMMConfig->GetSourceView())
652 auto& rViewFrame(xMMConfig->GetSourceView()->GetViewFrame());
653 rViewFrame.GetFrame().AppearWithUpdate();
664 m_pWizard.disposeAndClear();
672 m_pView2Close->GetViewFrame().DoClose();
673 m_pView2Close =
nullptr;
675 m_pWizardToDestroyInCallback.disposeAndClear();
686 sal_uInt16 nWhich = rReq.
GetSlot();
693 case FN_BUSINESS_CARD:
702 case SID_ATTR_METRIC:
703 if(pArgs && SfxItemState::SET == pArgs->
GetItemState(nWhich,
false, &pItem))
710 case FieldUnit::INCH:
711 case FieldUnit::PICA:
712 case FieldUnit::POINT:
715 bool bWebView =
dynamic_cast<SwWebView*
>( pActView ) !=
nullptr;
730 nWhich,
false, &pItem ))
738#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
743 xEx->ExecuteMailMergeWizard( pArgs );
760 const bool bHadConnection
761 = xConfigItem->GetConnection().is() && !xConfigItem->GetConnection()->isClosed();
763 sal_Int32
nPos = xConfigItem->GetResultSetPosition();
776 const SwDBData& rDBData = xConfigItem->GetCurrentDBData();
777 uno::Sequence<uno::Any> vSelection({
uno::Any(xConfigItem->GetResultSetPosition()) });
779 {
"Selection",
uno::Any(vSelection)},
783 {
"ActiveConnection",
uno::Any(xConfigItem->GetConnection().getTyped())},
784 {
"Filter",
uno::Any(xConfigItem->GetFilter())},
785 {
"Cursor",
uno::Any(xConfigItem->GetResultSet())}
800 if (!bHadConnection && xConfigItem->GetConnection().is()
801 && !xConfigItem->GetConnection()->isClosed())
823 if (!xConfigItem->GetResultSet().is())
845 if (xConfigItem && xConfigItem->GetTargetView())
846 xConfigItem->GetTargetView()->GetViewFrame().GetFrame().Appear();
850 xConfigItem->SetTargetView(
nullptr);
876 switch( pEvHint->GetEventId() )
878 case SfxEventHintId::LoadFinished:
884 if (pTemplateItem && pTemplateItem->
GetValue())
893 case SfxEventHintId::CreateDoc:
898 bool bUpdateFields =
true;
899 if( pUpdateDocItem && pUpdateDocItem->
GetValue() == document::UpdateDocMode::NO_UPDATE)
900 bUpdateFields =
false;
908 std::vector<OUString> aDBNameList;
910 if(!aDBNameList.empty())
923 if (rHint.
GetId() == SfxHintId::Deinitializing)
975 auto pSwView =
dynamic_cast<SwView *
>(pViewShell);
978 SwViewOption aNewOptions = *pSwView->GetWrtShell().GetViewOptions();
982 pSwView->GetWrtShell().ApplyViewOptions(aNewOptions);
984 if (bOnlyInvalidateCurrentView)
992 if(pSwView !=
nullptr ||
993 dynamic_cast< const SwPagePreview *
>( pViewShell ) !=
nullptr ||
994 dynamic_cast< const SwSrcView *
>( pViewShell ) !=
nullptr)
999 if (bOnlyInvalidateCurrentView)
1004#if !ENABLE_WASM_STRIP_ACCESSIBILITY
1013 auto pSwView =
dynamic_cast<SwView *
>( pViewShell );
1014 auto pPagePreview =
dynamic_cast<SwPagePreview *
>( pViewShell );
1018 else if(pPagePreview)
1019 pPagePreview->ApplyAccessibilityOptions();
1021 if(pSwView || pPagePreview ||
dynamic_cast< const SwSrcView *
>( pViewShell ) !=
nullptr)
1035 if(
auto pDocShell =
dynamic_cast<const SwDocShell*
>(pObjSh) )
1098 xDocSh->DoInitNew();
1101 xDocSh->GetDoc()->initXForms(
true);
static void NewXForms(SfxRequest &rReq)
const MiscSettings & GetMiscSettings() const
static const AllSettings & GetSettings()
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
sal_uInt16 GetValue() const
OUString AsRGBHexString() const
virtual void SetFixFields(const DateTime *pNewDateTime)=0
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
bool GetDisablePrinting() const
void Update(sal_uInt16 nId)
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
SfxFrame * GetFrame() const
bool IsClosing_Impl() const
SAL_WARN_UNUSED_RESULT SfxViewFrame * GetCurrentViewFrame() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void DisableItem(sal_uInt16 nWhich)
void InvalidateItem(sal_uInt16 nWhich)
SfxItemSet & GetItemSet() const
SfxShell * GetShell() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
bool isExportLocked() const
SfxMedium * GetMedium() const
OUString GetTitle(sal_uInt16 nMaxLen=0) const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
SfxObjectCreateMode GetCreateMode() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
void SetReturnValue(const SfxPoolItem &)
weld::Window * GetFrameWeld() const
virtual SfxObjectShell * GetObjectShell()
SfxViewShell * GetViewShell() const
const css::uno::Any & GetValue() const
vcl::Window & GetWindow() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
SfxViewFrame * GetTopViewFrame() const
SfxFrame & GetFrame() const
static SfxViewFrame * DisplayNewDocument(SfxObjectShell const &i_rDoc, const SfxRequest &i_rCreateDocRequest)
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
SfxViewFrame & GetViewFrame() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
vcl::Window * GetWindow() const
virtual void ExecuteMMResultPrintDialog(weld::Window *pParent)=0
virtual void ExecuteMMResultEmailDialog(weld::Window *pParent)=0
virtual void ExecuteMMResultSaveDialog(weld::Window *pParent)=0
virtual VclPtr< AbstractMailMergeWizard > CreateMailMergeWizard(SwView &rView, std::shared_ptr< SwMailMergeConfigItem > &rConfigItem)=0
static SwAbstractDialogFactory * Create()
void RevokeLastRegistrations()
Revoke not committed registrations in case of mail merge cancel.
bool Merge(const SwMergeDescriptor &rMergeDesc)
Merging of data records into fields.
static std::shared_ptr< SwMailMergeConfigItem > PerformMailMerge(SwView const *pView)
void CommitLastRegistrations()
Accept not committed registrations.
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
SwDoc * GetDoc()
returns Doc. But be careful!
SwDBManager * GetDBManager() const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
void GetAllUsedDB(std::vector< OUString > &rDBNameList, const std::vector< OUString > *pAllDBNames=nullptr)
SwDocShell * GetDocShell()
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
void GetAllUsedDB(std::vector< OUString > &rDBNameList, std::vector< OUString > const *pAllDBNames)
std::unique_ptr< SwStdFontConfig > m_pStdFontConfig
std::unique_ptr< SwPrintOptions > m_pWebPrintOptions
virtual void ConfigurationChanged(utl::ConfigurationBroadcaster *, ConfigurationHints) override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
std::unique_ptr< SvtUserOptions > m_pUserOptions
SvtUserOptions & GetUserOptions()
svtools::ColorConfig & GetColorConfig()
std::unique_ptr< SvtCTLOptions > m_pCTLOptions
std::unique_ptr< SwNavigationConfig > m_pNavigationConfig
void ExecOther(SfxRequest &)
std::unique_ptr< SwToolbarConfigItem > m_pToolbarConfig
const SwMasterUsrPref * GetUsrPref(bool bWeb) const
void InsertEnv(SfxRequest &)
std::unique_ptr< SwToolbarConfigItem > m_pWebToolbarConfig
std::unique_ptr< SwMasterUsrPref, o3tl::default_delete< SwMasterUsrPref > > m_pWebUsrPref
SwDBConfig * GetDBConfig()
bool m_bAuthorInitialised
std::unique_ptr< SvtAccessibilityOptions > m_pAccessibilityOptions
std::unique_ptr< SwDBConfig > m_pDBConfig
std::unique_ptr< SwMasterUsrPref, o3tl::default_delete< SwMasterUsrPref > > m_pUsrPref
static void ShowDBObj(SwView const &rView, const SwDBData &rData)
std::unique_ptr< SwModuleOptions, o3tl::default_delete< SwModuleOptions > > m_pModuleConfig
std::unique_ptr< SwPrintOptions > m_pPrintOptions
void StateOther(SfxItemSet &)
void InsertLab(SfxRequest &, bool bLabel)
bool IsInsTableFormatNum(bool bHTML) const
std::unique_ptr< svtools::ColorConfig > m_pColorConfig
std::unique_ptr< SwChapterNumRules > m_pChapterNumRules
void ApplyAccessibilityOptions()
static void SetInitialColorConfig(const SwViewColors &rColorConfig)
void SetThemeName(const OUString &rThemeName)
void SetColorConfig(const SwViewColors &rColorConfig)
SwWrtShell & GetWrtShell() const
std::shared_ptr< SwMailMergeConfigItem > const & GetMailMergeConfigItem() const
std::shared_ptr< SwMailMergeConfigItem > EnsureMailMergeConfigItem(const SfxItemSet *pArgs=nullptr)
SwDocShell * GetDocShell()
void SetMailMergeConfigItem(std::shared_ptr< SwMailMergeConfigItem > const &rConfigItem)
Used by the UI to modify the document model.
SelectionType GetSelectionType() const
bool HasSelection() const
const SwView & GetView() const
bool has(DataAccessDescriptorProperty _eWhich) const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
#define FN_MAILMERGE_EMAIL_DOCUMENTS
#define FN_PARAM_DATABASE_PROPERTIES
#define FN_MAILMERGE_WIZARD
#define FN_MAILMERGE_PRINT_DOCUMENTS
#define FN_MAILMERGE_FIRST_ENTRY
#define FN_MAILMERGE_LAST_ENTRY
#define FN_SET_MODOPT_TBLNUMFMT
#define FN_MAILMERGE_CURRENT_ENTRY
#define FN_MAILMERGE_CREATE_DOCUMENTS
#define FN_MAILMERGE_EXCLUDE_ENTRY
#define FN_MAILMERGE_SAVE_DOCUMENTS
#define FN_MAILMERGE_PREV_ENTRY
#define FN_MAILMERGE_NEXT_ENTRY
IMPL_LINK_NOARG(SwContentControlButton, PopupModeEndHdl, weld::Popover &, void)
@ DBMGR_MERGE
Data records in fields.
#define TOOLS_INFO_EXCEPTION(area, stream)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
virtual OUString GetName() const override
#define LINK(Instance, Class, Member)
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
Reference< XComponentContext > getProcessComponentContext()
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define SFX_OBJECTBAR_APPLICATION
::utl::SharedUNOComponent< css::sdbc::XConnection > SharedConnection
#define SFX_IMPL_INTERFACE(Class, SuperClass)
Color m_aAppBackgroundColor
#define RET_TARGET_CREATED
#define RET_REMOVE_TARGET
OUString SwResId(TranslateId aId)