diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-12-18 21:19:10 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-18 09:13:56 +0100 |
commit | 827ff2e8531619e96666a5690f538a0a27e5780f (patch) | |
tree | 0472e3a2be1e81bc4f8f87e4f9b8462b85567f3c /sw/source/uibase | |
parent | 299cc331bebe951b8b6fcfdd1e279ce6d2123ece (diff) |
mailmerge: Introduce buttons for first/prev/next/last mailmerge entry.
Change-Id: I3dc63d568dc4cd6f7e06b057ca4a387e4ad0677e
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/app/apphdl.cxx | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index 3bd9d4132d84..0f1209c2df0c 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -22,6 +22,7 @@ #include <hintids.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertysequence.hxx> #include <osl/diagnose.h> #include <tools/link.hxx> #include <svl/urihelper.hxx> @@ -201,6 +202,35 @@ void SwModule::StateOther(SfxItemSet &rSet) rSet.Put( SfxBoolItem( nWhich, m_pModuleConfig-> IsInsTableFormatNum( bWebView ))); break; + case FN_MAILMERGE_FIRST_ENTRY: + case FN_MAILMERGE_PREV_ENTRY: + case FN_MAILMERGE_NEXT_ENTRY: + case FN_MAILMERGE_LAST_ENTRY: + { + /* + SwView* pView = ::GetActiveView(); + SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); + if (!pConfigItem) + rSet.DisableItem(nWhich); + else + { + bool bFirst, bLast; + bool bValid = pConfigItem->IsResultSetFirstLast(bFirst, bLast); + + if (!bValid || + (bFirst && (nWhich == FN_MAILMERGE_FIRST_ENTRY || nWhich == FN_MAILMERGE_PREV_ENTRY)) || + (bLast && (nWhich == FN_MAILMERGE_LAST_ENTRY || nWhich == FN_MAILMERGE_NEXT_ENTRY))) + { + rSet.DisableItem(nWhich); + } + else + { + rSet.Put(SfxVoidItem(nWhich)); + } + } + */ + } + break; default: OSL_FAIL("::StateOther: default"); } @@ -699,6 +729,45 @@ void SwModule::ExecOther(SfxRequest& rReq) } } break; + case FN_MAILMERGE_FIRST_ENTRY: + case FN_MAILMERGE_PREV_ENTRY: + case FN_MAILMERGE_NEXT_ENTRY: + case FN_MAILMERGE_LAST_ENTRY: + { + SwView* pView = ::GetActiveView(); + SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem(); + if (!pConfigItem) + return; + + sal_Int32 nPos = pConfigItem->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; + default: break; + } + + //now the record has to be merged into the source document + const SwDBData& rDBData = pConfigItem->GetCurrentDBData(); + uno::Sequence<uno::Any> vSelection({ uno::makeAny(pConfigItem->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())} + })); + + SwView* pActView = ::GetActiveView(); + SwWrtShell& rSh = pActView->GetWrtShell(); + SwMergeDescriptor aMergeDesc(DBMGR_MERGE, rSh, aDescriptor); + rSh.GetDBManager()->MergeNew(aMergeDesc); + } + break; #endif } } |