diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2023-02-11 14:53:44 -0500 |
---|---|---|
committer | Aron Budea <aron.budea@collabora.com> | 2023-06-27 06:26:51 +0200 |
commit | 097cf021cb946da7ebc6fe548fb035aec2d4eaa5 (patch) | |
tree | e1fc3e4c01f22ac8be759401536493e3eb627ecc /svx/source | |
parent | 609a1567d0e60ca11800df56059b97b6a61ad117 (diff) |
lok: only publish MEDIA_SHAPE to selecting view
We now publish the url for the media shape
in the LOK_CALLBACK_GRAPHIC_SELECTION message.
This has many advantages, most notably that it
only sends the URL to the view selecting the
media. Also, it is now easier to handle
the message as there is no need for both
a LOK_CALLBACK_GRAPHIC_SELECTION and
a LOK_CALLBACK_MEDIA_SHAPE. However, the
latter is still defined as we might still
use it at some point.
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: I8d4b8794d8e590628630f2b0bfbfb5debe02515f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146848
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153009
Reviewed-by: Pranam Lashkari <lpranam@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153369
Tested-by: Jenkins
Reviewed-by: Aron Budea <aron.budea@collabora.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 25 | ||||
-rw-r--r-- | svx/source/svdraw/svdomedia.cxx | 23 |
2 files changed, 15 insertions, 33 deletions
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index fa0ec5aa084f..7a623dca9c92 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -823,10 +823,12 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S } { + OStringBuffer aExtraInfo; OString sSelectionText; OString sSelectionTextView; boost::property_tree::ptree aTableJsonTree; boost::property_tree::ptree aGluePointsTree; + const bool bMediaObj = (mpMarkedObj && mpMarkedObj->GetObjIdentifier() == SdrObjKind::Media); bool bTableSelection = false; bool bConnectorSelection = false; @@ -839,6 +841,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S { bConnectorSelection = dumpGluePointsToJSON(aGluePointsTree); } + if (GetMarkedObjectCount()) { SdrMark* pM = GetSdrMarkByIndex(0); @@ -848,7 +851,6 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S // (SwVirtFlyDrawObj with a SwGrfNode) bool bWriterGraphic = pO->HasLimitedRotation(); - OStringBuffer aExtraInfo; OString handleArrayStr; aExtraInfo.append("{\"id\":\"" @@ -1101,13 +1103,23 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S sSelectionText = aSelection.toString() + ", " + OString::number(nRotAngle.get()); } + if (!aExtraInfo.isEmpty()) { sSelectionTextView = sSelectionText + ", " + aExtraInfo + "}"; + + if (bMediaObj && pOtherShell == nullptr) + { + // Add the URL only if we have a Media Object and + // we are the selecting view. + SdrMediaObj* mediaObj = dynamic_cast<SdrMediaObj*>(mpMarkedObj); + if (mediaObj) + aExtraInfo.append(", \"url\": \"" + mediaObj->getTempURL().toUtf8() + "\""); + } + aExtraInfo.append(handleArrayStr + "}"); sSelectionText += ", " + aExtraInfo; - aExtraInfo.setLength(0); } } @@ -1149,15 +1161,8 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S // We have a new selection, so both pViewShell and the // other views want to know about it. pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelectionText); - SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelectionTextView); - } - if (comphelper::LibreOfficeKit::isActive() && mpMarkedObj - && mpMarkedObj->GetObjIdentifier() == SdrObjKind::Media) - { - SdrMediaObj* mediaObj = dynamic_cast<SdrMediaObj*>(mpMarkedObj); - if (mediaObj) - mediaObj->notifyPropertiesForLOKit(); + SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelectionTextView); } } } diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx index 0bb99f1ae46f..125b69312c41 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -469,27 +469,4 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper } } -void SdrMediaObj::notifyPropertiesForLOKit() -{ -#if HAVE_FEATURE_AVMEDIA - if (!m_xImpl->m_MediaProperties.getTempURL().isEmpty()) - { - const auto mediaId = reinterpret_cast<std::size_t>(this); - - boost::property_tree::ptree json; - json.put("action", "update"); - json.put("id", mediaId); - json.put("url", m_xImpl->m_MediaProperties.getTempURL()); - - const tools::Rectangle aRect = o3tl::convert(getRectangle(), o3tl::Length::mm100, o3tl::Length::twip); - json.put("x", aRect.getX()); - json.put("y", aRect.getY()); - json.put("w", aRect.getOpenWidth()); - json.put("h", aRect.getOpenHeight()); - - SfxLokHelper::notifyMediaUpdate(json); - } -#endif -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |