diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-05-06 14:33:10 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-05-08 22:42:35 +0200 |
commit | 36508d0110248f6683757602cd1668547dbfb253 (patch) | |
tree | 778f624fa5dbab2da79d9762b3f6895024a76a1a /sw | |
parent | 4259509aa4f11cbcd63299bd17a4503ebdc22fc0 (diff) |
lok: MSForms: Handle event about item selection of a drop-down field.
Change-Id: I095013097348c98361b6614e4ddf1e9029923c7f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93659
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unotxdoc.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 36 |
2 files changed, 39 insertions, 0 deletions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 59b859504ae1..dca0df658a8d 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -444,6 +444,9 @@ public: /// @see vcl::ITiledRenderable::getPostIts(). OUString getPostIts() override; + /// @see vcl::ITiledRenderable::executeFromFieldEvent(). + virtual void executeFromFieldEvent(const StringMap& aArguments) override; + // css::tiledrendering::XTiledRenderable virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) override; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 063af2f70ccd..7c18ed5de296 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -160,6 +160,7 @@ #include <memory> #include <redline.hxx> #include <DocumentRedlineManager.hxx> +#include <xmloff/odffields.hxx> #define TWIPS_PER_PIXEL 15 @@ -3374,6 +3375,41 @@ OUString SwXTextDocument::getPostIts() return OUString::fromUtf8(aStream.str().c_str()); } +void SwXTextDocument::executeFromFieldEvent(const StringMap& aArguments) +{ + auto aIter = aArguments.find("type"); + if (aIter != aArguments.end() && aIter->second == "drop-down") + { + aIter = aArguments.find("cmd"); + if (aIter != aArguments.end() && aIter->second == "selected") + { + aIter = aArguments.find("data"); + if (aIter != aArguments.end()) + { + sal_Int32 nSelection = aIter->second.toInt32(); + SwPosition aPos(*pDocShell->GetWrtShell()->GetCursor()->GetPoint()); + sw::mark::IFieldmark* pFieldBM = pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos); + if ( !pFieldBM ) + { + --aPos.nContent; + pFieldBM = pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos); + if (pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDROPDOWN) + { + if (nSelection >= 0) + { + OUString sKey = ODF_FORMDROPDOWN_RESULT; + (*pFieldBM->GetParameters())[sKey] <<= nSelection; + pFieldBM->Invalidate(); + pDocShell->GetWrtShell()->SetModified(); + pDocShell->GetView()->GetEditWin().LogicInvalidate(nullptr); + } + } + } + } + } + } +} + int SwXTextDocument::getPart() { SolarMutexGuard aGuard; |