Add a MailMerge class and object to the Writer VBA API
Just a dummy implementation so far. Needed because customer Automation client software seems to access it (through the very obsolete WordBasic API, even). It remains to be seen whether any actual mail merge functionality is needed. Change-Id: I40419da544f61173e4bcf759b887997c7f233b02 Reviewed-on: https://gerrit.libreoffice.org/55727 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com>
This commit is contained in:
parent
dc2d19b17c
commit
d1601e5d95
@ -1070,6 +1070,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,oovbaapi,ooo/vba/word,\
|
||||
XListLevels \
|
||||
XListTemplate \
|
||||
XListTemplates \
|
||||
XMailMerge \
|
||||
XOptions \
|
||||
XPageSetup \
|
||||
XPane \
|
||||
|
@ -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 );
|
||||
|
40
oovbaapi/ooo/vba/word/XMailMerge.idl
Normal file
40
oovbaapi/ooo/vba/word/XMailMerge.idl
Normal file
@ -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: */
|
@ -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 );
|
||||
};
|
||||
|
||||
}; }; };
|
||||
|
@ -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 \
|
||||
|
@ -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: */
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
61
sw/source/ui/vba/vbamailmerge.cxx
Normal file
61
sw/source/ui/vba/vbamailmerge.cxx
Normal file
@ -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: */
|
55
sw/source/ui/vba/vbamailmerge.hxx
Normal file
55
sw/source/ui/vba/vbamailmerge.hxx
Normal file
@ -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: */
|
Loading…
x
Reference in New Issue
Block a user