diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 08d66fd538cc..b46097938695 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -182,10 +182,6 @@ public: /// Helper for diagnosing run-time problems static void dumpState(rtl::OStringBuffer &rState); - /// Notify all views of a media update. - /// This could be a new insertion or property modifications to an existing one. - static void notifyMediaUpdate(boost::property_tree::ptree& json); - /// Process the mouse event in the currently active in-place component (if any). /// Returns true if the event has been processed, and no further processing is necessary. static bool testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, int nType, int nX, diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx index e3120c672f3d..aead70568511 100644 --- a/include/svx/svdomedia.hxx +++ b/include/svx/svdomedia.hxx @@ -75,9 +75,6 @@ public: virtual bool shouldKeepAspectRatio() const override { return true; } - /// When Lokit is enabled, notify the media details. - void notifyPropertiesForLOKit(); - private: void mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState ); virtual std::unique_ptr CreateObjectSpecificViewContact() override; diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 356925a6a341..0d598460d7c1 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -983,15 +983,6 @@ void SfxLokHelper::dumpState(rtl::OStringBuffer &rState) } } -void SfxLokHelper::notifyMediaUpdate(boost::property_tree::ptree& json) -{ - std::stringstream aStream; - boost::property_tree::write_json(aStream, json, /*pretty=*/ false); - const std::string str = aStream.str(); - - SfxLokHelper::notifyAllViews(LOK_CALLBACK_MEDIA_SHAPE, OString(str)); -} - bool SfxLokHelper::testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, int nType, int nX, int nY, int nCount, int nButtons, int nModifier, double fScaleX, double fScaleY, 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(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(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(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: */