41#include <com/sun/star/container/XContainerQuery.hpp>
42#include <com/sun/star/container/XEnumeration.hpp>
43#include <com/sun/star/form/runtime/XFormController.hpp>
44#include <com/sun/star/frame/Frame.hpp>
45#include <com/sun/star/lang/XMultiServiceFactory.hpp>
46#include <com/sun/star/sdbcx/XRowLocate.hpp>
47#include <com/sun/star/sdb/XResultSetAccess.hpp>
48#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
49#include <com/sun/star/view/XSelectionSupplier.hpp>
77 view::XSelectionChangeListener
84 virtual void SAL_CALL
selectionChanged(
const EventObject& aEvent )
override;
85 virtual void SAL_CALL
disposing(
const EventObject& Source )
override;
95 Sequence <Any> aSelection;
99 bool bEnable = aSelection.hasElements();
111 OSL_FAIL(
"disposing");
115 const OUString& rSourceName,
116 const OUString& rTableName,
117 sal_Int32 nCommandType,
118 const uno::Reference< XConnection>& _xConnection,
119 Sequence< Any >
const * pSelection)
124 , m_xBeamerWin(m_xBuilder->weld_container(
"beamer"))
125 , m_xAllRB(m_xBuilder->weld_radio_button(
"all"))
126 , m_xMarkedRB(m_xBuilder->weld_radio_button(
"selected"))
127 , m_xFromRB(m_xBuilder->weld_radio_button(
"rbfrom"))
128 , m_xFromNF(m_xBuilder->weld_spin_button(
"from"))
129 , m_xToNF(m_xBuilder->weld_spin_button(
"to"))
130 , m_xPrinterRB(m_xBuilder->weld_radio_button(
"printer"))
131 , m_xMailingRB(m_xBuilder->weld_radio_button(
"electronic"))
132 , m_xFileRB(m_xBuilder->weld_radio_button(
"file"))
133 , m_xSingleJobsCB(m_xBuilder->weld_check_button(
"singlejobs"))
134 , m_xPasswordCB(m_xBuilder->weld_check_button(
"passwd-check"))
135 , m_xSaveMergedDocumentFT(m_xBuilder->weld_label(
"savemergeddoclabel"))
136 , m_xSaveSingleDocRB(m_xBuilder->weld_radio_button(
"singledocument"))
137 , m_xSaveIndividualRB(m_xBuilder->weld_radio_button(
"individualdocuments"))
138 , m_xGenerateFromDataBaseCB(m_xBuilder->weld_check_button(
"generate"))
139 , m_xColumnFT(m_xBuilder->weld_label(
"fieldlabel"))
140 , m_xColumnLB(m_xBuilder->weld_combo_box(
"field"))
141 , m_xPasswordFT(m_xBuilder->weld_label(
"passwd-label"))
142 , m_xPasswordLB(m_xBuilder->weld_combo_box(
"passwd-combobox"))
143 , m_xPathFT(m_xBuilder->weld_label(
"pathlabel"))
144 , m_xPathED(m_xBuilder->weld_entry(
"path"))
145 , m_xPathPB(m_xBuilder->weld_button(
"pathpb"))
146 , m_xFilterFT(m_xBuilder->weld_label(
"fileformatlabel"))
147 , m_xFilterLB(m_xBuilder->weld_combo_box(
"fileformat"))
148 , m_xAddressFieldLB(m_xBuilder->weld_combo_box(
"address"))
149 , m_xSubjectFT(m_xBuilder->weld_label(
"subjectlabel"))
150 , m_xSubjectED(m_xBuilder->weld_entry(
"subject"))
151 , m_xFormatFT(m_xBuilder->weld_label(
"mailformatlabel"))
152 , m_xAttachFT(m_xBuilder->weld_label(
"attachmentslabel"))
153 , m_xAttachED(m_xBuilder->weld_entry(
"attachments"))
154 , m_xAttachPB(m_xBuilder->weld_button(
"attach"))
155 , m_xFormatHtmlCB(m_xBuilder->weld_check_button(
"html"))
156 , m_xFormatRtfCB(m_xBuilder->weld_check_button(
"rtf"))
157 , m_xFormatSwCB(m_xBuilder->weld_check_button(
"swriter"))
158 , m_xOkBTN(m_xBuilder->weld_button(
"ok"))
190 aURL.Complete =
".component:DB/DataSourceBrowser";
191 uno::Reference<XDispatch> xD =
m_xFrame->queryDispatch(
aURL,
206 if(
m_pImpl->xFController.is()) {
207 uno::Reference< awt::XControl > xCtrl =
m_pImpl->xFController->getCurrentControl( );
208 m_pImpl->xSelSupp.set(xCtrl, UNO_QUERY);
211 m_pImpl->xSelSupp->addSelectionChangeListener(
m_pImpl->xChgLstnr );
254 m_xToNF->connect_value_changed(aLk2);
259 if(_xConnection.is())
263 for(sal_Int32 nEntry = 0, nEntryCount =
m_xAddressFieldLB->get_count(); nEntry < nEntryCount; ++nEntry)
272 if(sPath.isEmpty()) {
277 if(
aURL.GetProtocol() == INetProtocol::File)
309 uno::Reference< container::XNameContainer> xFilterFactory(
310 xMSF->createInstance(
"com.sun.star.document.FilterFactory"), UNO_QUERY_THROW);
311 uno::Reference< container::XContainerQuery > xQuery(xFilterFactory, UNO_QUERY_THROW);
312 const OUString sCommand(
"matchByDocumentService=com.sun.star.text.TextDocument:iflags="
313 + OUString::number(
static_cast<sal_Int32
>(SfxFilterFlags::EXPORT))
315 + OUString::number(
static_cast<sal_Int32
>(SfxFilterFlags::NOTINFILEDLG))
317 uno::Reference< container::XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
318 static constexpr OUStringLiteral
sName(
u"Name");
320 while(xList->hasMoreElements()) {
324 uno::Any aProps = xFilterFactory->getByName(sFilter);
325 uno::Sequence< beans::PropertyValue > aFilterProperties;
326 aProps >>= aFilterProperties;
328 auto pProp = std::find_if(std::cbegin(aFilterProperties), std::cend(aFilterProperties),
329 [](
const beans::PropertyValue& rProp) {
return rProp.Name ==
"UIName"; });
330 if (pProp != std::cend(aFilterProperties))
331 pProp->
Value >>= sUIName2;
332 if( !sUIName2.isEmpty() ) {
333 if( sFilter ==
"writer8" )
339 }
catch (
const uno::Exception&) {
346 m_xFrame->setComponent(
nullptr,
nullptr);
359 bool bPrint = m_xPrinterRB->get_active();
360 m_xSingleJobsCB->set_sensitive(bPrint);
362 m_xSaveMergedDocumentFT->set_sensitive( !bPrint );
363 m_xSaveSingleDocRB->set_sensitive( !bPrint );
364 m_xSaveIndividualRB->set_sensitive( !bPrint );
367 SaveTypeHdl( m_xSaveSingleDocRB->get_active() ? *m_xSaveSingleDocRB : *m_xSaveIndividualRB );
369 m_xPathFT->set_sensitive(
false);
370 m_xPathED->set_sensitive(
false);
371 m_xPathPB->set_sensitive(
false);
372 m_xColumnFT->set_sensitive(
false);
373 m_xColumnLB->set_sensitive(
false);
374 m_xFilterFT->set_sensitive(
false);
375 m_xFilterLB->set_sensitive(
false);
376 m_xGenerateFromDataBaseCB->set_sensitive(
false);
377 m_xPasswordCB->set_sensitive(
false );
378 m_xPasswordFT->set_sensitive(
false );
379 m_xPasswordLB->set_sensitive(
false );
385 bool bIndividual = m_xSaveIndividualRB->get_active();
387 m_xGenerateFromDataBaseCB->set_sensitive( bIndividual );
390 FilenameHdl(*m_xGenerateFromDataBaseCB);
394 m_xColumnFT->set_sensitive(
false);
395 m_xColumnLB->set_sensitive(
false);
396 m_xPathFT->set_sensitive(
false );
397 m_xPathED->set_sensitive(
false );
398 m_xPathPB->set_sensitive(
false );
399 m_xFilterFT->set_sensitive(
false );
400 m_xFilterLB->set_sensitive(
false );
401 m_xPasswordCB->set_sensitive(
false );
402 m_xPasswordFT->set_sensitive(
false );
403 m_xPasswordLB->set_sensitive(
false );
409 bool bEnable = rBox.get_active();
410 m_xColumnFT->set_sensitive( bEnable );
411 m_xColumnLB->set_sensitive(bEnable);
412 m_xPathFT->set_sensitive( bEnable );
413 m_xPathED->set_sensitive(bEnable);
414 m_xPathPB->set_sensitive( bEnable );
415 m_xFilterFT->set_sensitive( bEnable );
416 m_xFilterLB->set_sensitive( bEnable );
418 if(m_xFilterLB->get_active_id() ==
"writer_pdf_Export")
420 m_xPasswordCB->show();
421 m_xPasswordFT->show();
422 m_xPasswordLB->show();
424 m_xPasswordCB->set_sensitive( bEnable );
425 m_xPasswordFT->set_sensitive( bEnable );
426 m_xPasswordLB->set_sensitive( bEnable );
432 if(m_xFilterLB->get_active_id() ==
"writer_pdf_Export")
434 m_xPasswordCB->show();
435 m_xPasswordFT->show();
436 m_xPasswordLB->show();
438 m_xPasswordCB->set_sensitive(
true );
439 m_xPasswordFT->set_sensitive(
true );
440 m_xPasswordLB->set_sensitive(
true );
444 m_xPasswordCB->hide();
445 m_xPasswordFT->hide();
446 m_xPasswordLB->hide();
452 m_xFromRB->set_active(
true);
478 m_pImpl->xSelSupp->removeSelectionChangeListener(
m_pImpl->xChgLstnr );
511 sal_Int32 nStart =
m_xFromNF->get_value();
512 sal_Int32 nEnd =
m_xToNF->get_value();
515 std::swap(nEnd, nStart);
519 for (sal_Int32
i = nStart;
i <= nEnd; ++
i, ++pSelection)
526 uno::Reference< XRowLocate > xRowLocate(
GetResultSet(),UNO_QUERY);
527 uno::Reference< XResultSet > xRes(xRowLocate,UNO_QUERY);
529 if ( xRowLocate.is() ) {
531 if ( xRowLocate->moveToBookmark(rRow) )
532 rRow <<= xRes->getRow();
561 if( sPath.isEmpty() ) {
565 if( !sPath.endsWith(
"/") )
572 uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
574 xFP->setDisplayDirectory( GetURLfromPath() );
575 if( xFP->execute() ==
RET_OK ) {
577 if(
aURL.GetProtocol() == INetProtocol::File)
578 m_xPathED->set_text(
aURL.PathToFileName());
580 m_xPathED->set_text(
aURL.GetFull());
586 uno::Reference< XResultSet > xResSetClone;
587 if (
m_pImpl->xFController.is() ) {
589 uno::Reference< XResultSetAccess > xResultSetAccess(
m_pImpl->xFController->getModel(),UNO_QUERY);
590 if ( xResultSetAccess.is() )
591 xResSetClone = xResultSetAccess->createResultSet();
597 : GenericDialogController(pParent,
"modules/swriter/ui/mailmergedialog.ui",
"MailMergeDialog")
598 , m_xThisDocRB(m_xBuilder->weld_radio_button(
"document"))
607 : GenericDialogController(pParent,
"modules/swriter/ui/mergeconnectdialog.ui",
"MergeConnectDialog")
608 , m_xUseExistingRB(m_xBuilder->weld_radio_button(
"existing"))
PropertiesInfo aProperties
Reference< XExecutableDialog > m_xDialog
const MiscSettings & GetMiscSettings() const
static const AllSettings & GetSettings()
Provides access to the formatting devices of a document.
virtual void setPrintData(const SwPrintData &rPrtData)=0
Sets the PrintData.
virtual const SwPrintData & getPrintData() const =0
Returns the PrintData.
INetProtocol GetProtocol() const
bool SetURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
bool GetDisablePrinting() const
const INetURLObject & GetURLObject() const
SfxMedium * GetMedium() const
const OUString & GetWorkPath() const
void GetColumnNames(weld::ComboBox &rBox, const OUString &rDBName, const OUString &rTableName)
Fill listbox with all column names of a database table.
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
virtual ~SwMailMergeCreateFromDlg() override
SwMailMergeCreateFromDlg(weld::Window *pParent)
SwMailMergeDlg(weld::Window *pParent, SwWrtShell &rSh, const OUString &rSourceName, const OUString &rTableName, sal_Int32 nCommandType, const css::uno::Reference< css::sdbc::XConnection > &xConnection, css::uno::Sequence< css::uno::Any > const *pSelection)
std::unique_ptr< weld::CheckButton > m_xFormatRtfCB
std::unique_ptr< weld::SpinButton > m_xFromNF
std::unique_ptr< weld::RadioButton > m_xFileRB
std::unique_ptr< weld::RadioButton > m_xFromRB
std::unique_ptr< weld::CheckButton > m_xFormatSwCB
css::uno::Sequence< css::uno::Any > m_aSelection
std::unique_ptr< weld::CheckButton > m_xGenerateFromDataBaseCB
std::unique_ptr< weld::Label > m_xFormatFT
std::unique_ptr< weld::Entry > m_xSubjectED
std::unique_ptr< SwMailMergeDlg_Impl > m_pImpl
virtual ~SwMailMergeDlg() override
std::unique_ptr< weld::CheckButton > m_xSingleJobsCB
std::unique_ptr< weld::RadioButton > m_xAllRB
css::uno::Reference< css::frame::XFrame2 > m_xFrame
std::unique_ptr< weld::Label > m_xSubjectFT
std::unique_ptr< weld::Button > m_xAttachPB
std::unique_ptr< weld::RadioButton > m_xPrinterRB
std::unique_ptr< weld::Button > m_xOkBTN
std::unique_ptr< weld::ComboBox > m_xAddressFieldLB
std::unique_ptr< weld::ComboBox > m_xFilterLB
std::unique_ptr< weld::ComboBox > m_xColumnLB
OUString GetURLfromPath() const
bool AskUserFilename() const
OUString GetTargetURL() const
friend class SwXSelChgLstnr_Impl
std::unique_ptr< weld::Entry > m_xAttachED
std::unique_ptr< weld::Container > m_xBeamerWin
DBManagerOptions m_nMergeType
std::unique_ptr< weld::RadioButton > m_xSaveSingleDocRB
std::unique_ptr< weld::ComboBox > m_xPasswordLB
std::unique_ptr< weld::Button > m_xPathPB
std::unique_ptr< weld::CheckButton > m_xFormatHtmlCB
std::unique_ptr< weld::SpinButton > m_xToNF
std::unique_ptr< weld::Label > m_xPasswordFT
SwModuleOptions * m_pModOpt
std::unique_ptr< weld::CheckButton > m_xPasswordCB
std::unique_ptr< weld::Label > m_xAttachFT
css::uno::Reference< css::sdbc::XResultSet > GetResultSet() const
std::unique_ptr< weld::Entry > m_xPathED
std::unique_ptr< weld::RadioButton > m_xMarkedRB
std::unique_ptr< weld::RadioButton > m_xMailingRB
std::unique_ptr< weld::RadioButton > m_xSaveIndividualRB
virtual ~SwMailMergeFieldConnectionsDlg() override
SwMailMergeFieldConnectionsDlg(weld::Window *pParent)
const OUString & GetNameFromColumn() const
void SetIsFileEncryptedFromColumn(bool bSet)
void SetNameFromColumn(const OUString &rSet)
void SetIsNameFromColumn(bool bSet)
void SetMailingPath(const OUString &sPath)
void SetMailingFormats(MailTextFormats nSet)
MailTextFormats GetMailingFormats() const
void SetPasswordFromColumn(const OUString &rSet)
bool IsNameFromColumn() const
void SetSinglePrintJob(bool b)
const OUString & GetPasswordFromColumn() const
const OUString & GetMailingPath() const
void SetPrintSingleJobs(bool b)
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
SwDocShell * GetDocShell()
Used by the UI to modify the document model.
const SwView & GetView() const
virtual void SAL_CALL disposing(const EventObject &Source) override
SwXSelChgLstnr_Impl(SwMailMergeDlg &rParentDlg)
virtual void SAL_CALL selectionChanged(const EventObject &aEvent) override
SwMailMergeDlg & m_rParent
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
@ DBMGR_MERGE_EMAIL
Send mail merge as email.
@ DBMGR_MERGE_PRINTER
Print mail merge.
@ DBMGR_MERGE_FILE
Save mail merge as files.
#define LINK(Instance, Class, Member)
IMPL_LINK(SwMailMergeDlg, FilenameHdl, weld::Toggleable &, rBox, void)
IMPL_LINK_NOARG(SwMailMergeDlg, ButtonHdl, weld::Button &, void)
OUString CallSaveAsDialog(weld::Window *pParent, OUString &rFilter)
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
uno::Reference< XSelectionSupplier > xSelSupp
uno::Reference< runtime::XFormController > xFController
uno::Reference< XSelectionChangeListener > xChgLstnr
Reference< XController > xController