diff options
-rw-r--r-- | oovbaapi/UnoApi_oovbaapi.mk | 1 | ||||
-rw-r--r-- | oovbaapi/ooo/vba/word/XDocument.idl | 1 | ||||
-rw-r--r-- | oovbaapi/ooo/vba/word/XMailMerge.idl | 40 | ||||
-rw-r--r-- | oovbaapi/ooo/vba/word/XWordBasic.idl | 18 | ||||
-rw-r--r-- | sw/Library_vbaswobj.mk | 1 | ||||
-rw-r--r-- | sw/source/ui/vba/vbaapplication.cxx | 50 | ||||
-rw-r--r-- | sw/source/ui/vba/vbaapplication.hxx | 3 | ||||
-rw-r--r-- | sw/source/ui/vba/vbadocument.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/vba/vbadocument.hxx | 2 | ||||
-rw-r--r-- | sw/source/ui/vba/vbamailmerge.cxx | 61 | ||||
-rw-r--r-- | sw/source/ui/vba/vbamailmerge.hxx | 55 |
11 files changed, 237 insertions, 1 deletions
diff --git a/oovbaapi/UnoApi_oovbaapi.mk b/oovbaapi/UnoApi_oovbaapi.mk index 421dd057a347..400528dd75c6 100644 --- a/oovbaapi/UnoApi_oovbaapi.mk +++ b/oovbaapi/UnoApi_oovbaapi.mk @@ -1070,6 +1070,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,oovbaapi,ooo/vba/word,\ XListLevels \ XListTemplate \ XListTemplates \ + XMailMerge \ XOptions \ XPageSetup \ XPane \ diff --git a/oovbaapi/ooo/vba/word/XDocument.idl b/oovbaapi/ooo/vba/word/XDocument.idl index b6cb4fc45def..9259fc9fa4a9 100644 --- a/oovbaapi/ooo/vba/word/XDocument.idl +++ b/oovbaapi/ooo/vba/word/XDocument.idl @@ -38,6 +38,7 @@ interface XDocument [attribute] boolean AutoHyphenation; [attribute] long HyphenationZone; [attribute] long ConsecutiveHyphensLimit; + [attribute, readonly] XMailMerge MailMerge; XRange Range( [in] any Start, [in] any End ) raises (com::sun::star::script::BasicErrorException); any BuiltInDocumentProperties( [in] any Index ); diff --git a/oovbaapi/ooo/vba/word/XMailMerge.idl b/oovbaapi/ooo/vba/word/XMailMerge.idl new file mode 100644 index 000000000000..203ffe2dfaa6 --- /dev/null +++ b/oovbaapi/ooo/vba/word/XMailMerge.idl @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef __ooo_vba_word_XMailMerge_idl__ +#define __ooo_vba_word_XMailMerge_idl__ + +module ooo { module vba { module word { + +interface XMailMerge : XHelperInterface +{ + [attribute] long MainDocumentType; + + void OpenDataSource( [in] string Name, + [in] any Format, + [in] any ConfirmConversions, + [in] any ReadOnly, + [in] any LinkToSource, + [in] any AddToRecentFiles, + [in] any PasswordDocument, + [in] any PasswordTemplate, + [in] any Revert, + [in] any WritePasswordDocument, + [in] any WritePasswordTemplate, + [in] any Connection, + [in] any SQLStatement, + [in] any SQLStatement1, + [in] any OpenExclusive, + [in] any SubType ); +}; + +}; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oovbaapi/ooo/vba/word/XWordBasic.idl b/oovbaapi/ooo/vba/word/XWordBasic.idl index 31484c98d445..769d8aad3faf 100644 --- a/oovbaapi/ooo/vba/word/XWordBasic.idl +++ b/oovbaapi/ooo/vba/word/XWordBasic.idl @@ -14,9 +14,27 @@ module ooo { module vba { module word { interface XWordBasic { + [attribute] long MailMergeMainDocumentType; + void FileOpen( [in] string Name, [in] any ConfirmConversions, [in] any ReadOnly, [in] any AddToMru, [in] any PasswordDoc, [in] any PasswordDot, [in] any Revert, [in] any WritePasswordDoc, [in] any WritePasswordDot ); string WindowName(); boolean ExistingBookmark( [in] string Name ); + void MailMergeOpenDataSource( [in] string Name, + [in] any Format, + [in] any ConfirmConversions, + [in] any ReadOnly, + [in] any LinkToSource, + [in] any AddToRecentFiles, + [in] any PasswordDocument, + [in] any PasswordTemplate, + [in] any Revert, + [in] any WritePasswordDocument, + [in] any WritePasswordTemplate, + [in] any Connection, + [in] any SQLStatement, + [in] any SQLStatement1, + [in] any OpenExclusive, + [in] any SubType ); }; }; }; }; diff --git a/sw/Library_vbaswobj.mk b/sw/Library_vbaswobj.mk index ac06758fa9fa..28d4a867b8b1 100644 --- a/sw/Library_vbaswobj.mk +++ b/sw/Library_vbaswobj.mk @@ -78,6 +78,7 @@ $(eval $(call gb_Library_add_exception_objects,vbaswobj,\ sw/source/ui/vba/vbalistlevels \ sw/source/ui/vba/vbalisttemplate \ sw/source/ui/vba/vbalisttemplates \ + sw/source/ui/vba/vbamailmerge \ sw/source/ui/vba/vbarevision \ sw/source/ui/vba/vbarevisions \ sw/source/ui/vba/vbarow \ diff --git a/sw/source/ui/vba/vbaapplication.cxx b/sw/source/ui/vba/vbaapplication.cxx index 441f1b6841af..e4f0363ede4b 100644 --- a/sw/source/ui/vba/vbaapplication.cxx +++ b/sw/source/ui/vba/vbaapplication.cxx @@ -30,6 +30,7 @@ #include "vbaselection.hxx" #include "vbadocuments.hxx" #include "vbaaddins.hxx" +#include "vbamailmerge.hxx" #include "vbadialogs.hxx" #include <ooo/vba/XConnectionPoint.hpp> #include <ooo/vba/word/WdEnableCancelKey.hpp> @@ -70,9 +71,20 @@ public: SwWordBasic( SwVbaApplication* pApp ); // XWordBasic + virtual sal_Int32 SAL_CALL getMailMergeMainDocumentType() override; + virtual void SAL_CALL setMailMergeMainDocumentType( sal_Int32 _mailmergemaindocumenttype ) override; + virtual void SAL_CALL FileOpen( const OUString& Name, const uno::Any& ConfirmConversions, const uno::Any& ReadOnly, const uno::Any& AddToMru, const uno::Any& PasswordDoc, const uno::Any& PasswordDot, const uno::Any& Revert, const uno::Any& WritePasswordDoc, const uno::Any& WritePasswordDot ) override; virtual OUString SAL_CALL WindowName() override; virtual sal_Bool SAL_CALL ExistingBookmark( const OUString& Name ) override; + virtual void SAL_CALL MailMergeOpenDataSource(const OUString& Name, const css::uno::Any& Format, + const css::uno::Any& ConfirmConversions, const css::uno::Any& ReadOnly, + const css::uno::Any& LinkToSource, const css::uno::Any& AddToRecentFiles, + const css::uno::Any& PasswordDocument, const css::uno::Any& PasswordTemplate, + const css::uno::Any& Revert, const css::uno::Any& WritePasswordDocument, + const css::uno::Any& WritePasswordTemplate, const css::uno::Any& Connection, + const css::uno::Any& SQLStatement, const css::uno::Any& SQLStatement1, + const css::uno::Any& OpenExclusive, const css::uno::Any& SubType) override; }; SwVbaApplication::SwVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): @@ -127,6 +139,12 @@ SwVbaApplication::getActiveSwVbaWindow() return new SwVbaWindow( uno::Reference< XHelperInterface >(), mxContext, xModel, xController ); } +uno::Reference< css::uno::XComponentContext > +SwVbaApplication::getContext() +{ + return mxContext; +} + uno::Reference< word::XWindow > SAL_CALL SwVbaApplication::getActiveWindow() { @@ -451,6 +469,19 @@ SwWordBasic::SwWordBasic( SwVbaApplication* pApp ) : } // XWordBasic +sal_Int32 SAL_CALL +SwWordBasic::getMailMergeMainDocumentType() +{ + return SwVbaMailMerge::get( mpApp->getParent(), mpApp->getContext() )->getMainDocumentType(); +} + +// XWordBasic +void SAL_CALL +SwWordBasic::setMailMergeMainDocumentType( sal_Int32 _mailmergemaindocumenttype ) +{ + SwVbaMailMerge::get( mpApp->getParent(), mpApp->getContext() )->setMainDocumentType( _mailmergemaindocumenttype ); +} + void SAL_CALL SwWordBasic::FileOpen( const OUString& Name, const uno::Any& ConfirmConversions, const uno::Any& ReadOnly, const uno::Any& AddToMru, const uno::Any& PasswordDoc, const uno::Any& PasswordDot, const uno::Any& Revert, const uno::Any& WritePasswordDoc, const uno::Any& WritePasswordDot ) { @@ -475,4 +506,23 @@ SwWordBasic::ExistingBookmark( const OUString& Name ) return xBookmarks.is() && xBookmarks->Exists( Name ); } +void SAL_CALL +SwWordBasic::MailMergeOpenDataSource( const OUString& Name, const css::uno::Any& Format, + const css::uno::Any& ConfirmConversions, const css::uno::Any& ReadOnly, + const css::uno::Any& LinkToSource, const css::uno::Any& AddToRecentFiles, + const css::uno::Any& PasswordDocument, const css::uno::Any& PasswordTemplate, + const css::uno::Any& Revert, const css::uno::Any& WritePasswordDocument, + const css::uno::Any& WritePasswordTemplate, const css::uno::Any& Connection, + const css::uno::Any& SQLStatement, const css::uno::Any& SQLStatement1, + const css::uno::Any& OpenExclusive, const css::uno::Any& SubType ) +{ + mpApp->getActiveDocument()->getMailMerge()->OpenDataSource( Name, Format, ConfirmConversions, ReadOnly, + LinkToSource, AddToRecentFiles, + PasswordDocument, PasswordTemplate, + Revert, WritePasswordDocument, + WritePasswordTemplate, Connection, + SQLStatement, SQLStatement1, + OpenExclusive, SubType ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaapplication.hxx b/sw/source/ui/vba/vbaapplication.hxx index c032ea546dfe..6ef51fec5d37 100644 --- a/sw/source/ui/vba/vbaapplication.hxx +++ b/sw/source/ui/vba/vbaapplication.hxx @@ -51,13 +51,14 @@ class SwVbaApplication : public SwVbaApplication_BASE std::vector<css::uno::Reference< ooo::vba::XSink >> mvSinks; public: - explicit SwVbaApplication( css::uno::Reference< css::uno::XComponentContext >& m_xContext ); + explicit SwVbaApplication( css::uno::Reference< css::uno::XComponentContext >& xContext ); virtual ~SwVbaApplication() override; sal_uInt32 AddSink( const css::uno::Reference< ooo::vba::XSink >& xSink ); void RemoveSink( sal_uInt32 nNumber ); SwVbaWindow* getActiveSwVbaWindow(); + css::uno::Reference< css::uno::XComponentContext > getContext(); // XApplication virtual OUString SAL_CALL getName() override; diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx index 9a1fcf39ae9a..18273d813e91 100644 --- a/sw/source/ui/vba/vbadocument.cxx +++ b/sw/source/ui/vba/vbadocument.cxx @@ -25,6 +25,7 @@ #include "vbarangehelper.hxx" #include "vbadocumentproperties.hxx" #include "vbabookmarks.hxx" +#include "vbamailmerge.hxx" #include "vbavariables.hxx" #include <com/sun/star/text/XBookmarksSupplier.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -399,6 +400,11 @@ void SAL_CALL SwVbaDocument::setConsecutiveHyphensLimit( ::sal_Int32 _consecutiv xParaProps->setPropertyValue("ParaHyphenationMaxHyphens", uno::makeAny( nHyphensLimit ) ); } +uno::Reference< ooo::vba::word::XMailMerge > SAL_CALL SwVbaDocument::getMailMerge() +{ + return uno::Reference< ooo::vba::word::XMailMerge >(SwVbaMailMerge::get(mxParent, mxContext).get()); +} + void SAL_CALL SwVbaDocument::Protect( ::sal_Int32 /*Type*/, const uno::Any& /*NOReset*/, const uno::Any& /*Password*/, const uno::Any& /*UseIRM*/, const uno::Any& /*EnforceStyleLock*/ ) { // Seems not support in Writer diff --git a/sw/source/ui/vba/vbadocument.hxx b/sw/source/ui/vba/vbadocument.hxx index 7cbc63773319..3bb31edd030b 100644 --- a/sw/source/ui/vba/vbadocument.hxx +++ b/sw/source/ui/vba/vbadocument.hxx @@ -77,6 +77,8 @@ public: virtual void SAL_CALL setHyphenationZone( ::sal_Int32 _hyphenationzone ) override; virtual ::sal_Int32 SAL_CALL getConsecutiveHyphensLimit() override; virtual void SAL_CALL setConsecutiveHyphensLimit( ::sal_Int32 _consecutivehyphenslimit ) override; + virtual css::uno::Reference< ooo::vba::word::XMailMerge > SAL_CALL getMailMerge() override; + using VbaDocumentBase::Protect; virtual void SAL_CALL Protect( ::sal_Int32 Type, const css::uno::Any& NOReset, const css::uno::Any& Password, const css::uno::Any& UseIRM, const css::uno::Any& EnforceStyleLock ) override; virtual void SAL_CALL PrintOut( const css::uno::Any& Background, const css::uno::Any& Append, const css::uno::Any& Range, const css::uno::Any& OutputFileName, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Item, const css::uno::Any& Copies, const css::uno::Any& Pages, const css::uno::Any& PageType, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& FileName, const css::uno::Any& ActivePrinterMacGX, const css::uno::Any& ManualDuplexPrint, const css::uno::Any& PrintZoomColumn, const css::uno::Any& PrintZoomRow, const css::uno::Any& PrintZoomPaperWidth, const css::uno::Any& PrintZoomPaperHeight ) override; diff --git a/sw/source/ui/vba/vbamailmerge.cxx b/sw/source/ui/vba/vbamailmerge.cxx new file mode 100644 index 000000000000..59711d7de8a8 --- /dev/null +++ b/sw/source/ui/vba/vbamailmerge.cxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column:100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "vbamailmerge.hxx" + +#include <ooo/vba/word/WdMailMergeMainDocType.hpp> + +SwVbaMailMerge::SwVbaMailMerge(const css::uno::Reference<ooo::vba::XHelperInterface>& xParent, + const css::uno::Reference<css::uno::XComponentContext>& xContext) + : SwVbaMailMerge_BASE(xParent, xContext) + , m_nMainDocType(ooo::vba::word::WdMailMergeMainDocType::wdNotAMergeDocument) +{ +} + +SwVbaMailMerge::~SwVbaMailMerge() {} + +rtl::Reference<SwVbaMailMerge> +SwVbaMailMerge::get(const css::uno::Reference<ooo::vba::XHelperInterface>& xParent, + const css::uno::Reference<css::uno::XComponentContext>& xContext) +{ + static rtl::Reference<SwVbaMailMerge> xInstance(new SwVbaMailMerge(xParent, xContext)); + + return xInstance; +} + +sal_Int32 SAL_CALL SwVbaMailMerge::getMainDocumentType() { return m_nMainDocType; } + +void SAL_CALL SwVbaMailMerge::setMainDocumentType(sal_Int32 _maindocumenttype) +{ + m_nMainDocType = _maindocumenttype; +} + +// Completely dummy, no-op. +void SAL_CALL SwVbaMailMerge::OpenDataSource( + const OUString&, const css::uno::Any&, const css::uno::Any&, const css::uno::Any&, + const css::uno::Any&, const css::uno::Any&, const css::uno::Any&, const css::uno::Any&, + const css::uno::Any&, const css::uno::Any&, const css::uno::Any&, const css::uno::Any&, + const css::uno::Any&, const css::uno::Any&, const css::uno::Any&, const css::uno::Any&) +{ +} + +OUString SwVbaMailMerge::getServiceImplName() { return OUString("SwVbaMailMerge"); } + +css::uno::Sequence<OUString> SwVbaMailMerge::getServiceNames() +{ + static css::uno::Sequence<OUString> aServiceNames; + if (aServiceNames.getLength() == 0) + { + aServiceNames.realloc(1); + aServiceNames[0] = "ooo.vba.word.MailMerge"; + } + return aServiceNames; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbamailmerge.hxx b/sw/source/ui/vba/vbamailmerge.hxx new file mode 100644 index 000000000000..7718815da344 --- /dev/null +++ b/sw/source/ui/vba/vbamailmerge.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef INCLUDED_SW_SOURCE_UI_VBA_VBAMAILMERGE_HXX +#define INCLUDED_SW_SOURCE_UI_VBA_VBAMAILMERGE_HXX + +#include <ooo/vba/word/XMailMerge.hpp> +#include <rtl/ref.hxx> +#include <vbahelper/vbahelperinterface.hxx> + +typedef InheritedHelperInterfaceWeakImpl<ooo::vba::word::XMailMerge> SwVbaMailMerge_BASE; + +// Singleton class. Get the single instance using the get() method. + +class SwVbaMailMerge : public SwVbaMailMerge_BASE +{ + sal_Int32 m_nMainDocType; + + SwVbaMailMerge(const css::uno::Reference<ooo::vba::XHelperInterface>& xParent, + const css::uno::Reference<css::uno::XComponentContext>& xContext); + +public: + virtual ~SwVbaMailMerge() override; + + static rtl::Reference<SwVbaMailMerge> + get(const css::uno::Reference<ooo::vba::XHelperInterface>& xParent, + const css::uno::Reference<css::uno::XComponentContext>& xContext); + + // XMailMerge + virtual sal_Int32 SAL_CALL getMainDocumentType() override; + virtual void SAL_CALL setMainDocumentType(sal_Int32 _maindocumenttype) override; + + virtual void SAL_CALL + OpenDataSource(const OUString& Name, const css::uno::Any& Format, + const css::uno::Any& ConfirmConversions, const css::uno::Any& ReadOnly, + const css::uno::Any& LinkToSource, const css::uno::Any& AddToRecentFiles, + const css::uno::Any& PasswordDocument, const css::uno::Any& PasswordTemplate, + const css::uno::Any& Revert, const css::uno::Any& WritePasswordDocument, + const css::uno::Any& WritePasswordTemplate, const css::uno::Any& Connection, + const css::uno::Any& SQLStatement, const css::uno::Any& SQLStatement1, + const css::uno::Any& OpenExclusive, const css::uno::Any& SubType) override; + + // XHelperInterface + virtual OUString getServiceImplName() override; + virtual css::uno::Sequence<OUString> getServiceNames() override; +}; + +#endif // INCLUDED_SW_SOURCE_UI_VBA_VBAMAILMERGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |