summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-02-26 11:57:43 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-02-26 14:48:41 +0100
commit500d54ca97137473a9d78956381386d70c01ccbf (patch)
tree32e6ad35178d9007c1572e0128bac2591a91589e /desktop
parent8d3f85cf1d1eaa489b468c66dee465f67e0a5fe1 (diff)
return early without error if no shape it selected on generating preview
of current selection. Which can arise in calc on repeatedly double-clicking on a shape and pressing esc. Eventually there will be a case where the shape isn't selected by the time the preview generation is attempted. Change-Id: Ic92149b5e12f35fe69265b6c8df289819313a899 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163847 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index da46761b085c..65e131cc48a3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -133,6 +133,8 @@
#include <com/sun/star/i18n/LocaleCalendar2.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <editeng/flstitem.hxx>
#ifdef IOS
@@ -4820,6 +4822,37 @@ static void doc_postWindowKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned n
}
}
+// To be an exportable selection, there must be something selected and that
+// selection can't be "ScCellObj" which doesn't can't provide a svg.
+//
+// Typically a problem arises when double clicking a shape in calc. The 1st
+// click selects the shape, triggering generation of a preview, but the second
+// shape engers into edit mode befoce doc_renderShapeSelection has a chance to
+// fire, at which point the shape is no longer selected. Rather than generate
+// an error just return a 0 length result if there is no shape selected, so we
+// continue to generate an error if a shape is selected, but could not provide
+// an svg.
+static bool doc_hasShapeSelection(const css::uno::Reference<css::lang::XComponent>& rComponent)
+{
+ uno::Reference<frame::XModel> xModel(rComponent, uno::UNO_QUERY);
+ if (!xModel.is())
+ return false;
+
+ uno::Reference<frame::XController> xController(xModel->getCurrentController());
+ if (!xController.is())
+ return false;
+
+ uno::Reference<view::XSelectionSupplier> xSelectionSupplier(xController, uno::UNO_QUERY);
+ if (!xSelectionSupplier.is())
+ return false;
+
+ Any selection = xSelectionSupplier->getSelection();
+ uno::Reference<lang::XServiceInfo> xSelection;
+ selection >>= xSelection;
+
+ return xSelection && xSelection->getImplementationName() != "ScCellObj";
+}
+
static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOutput)
{
comphelper::ProfileZone aZone("doc_renderShapeSelection");
@@ -4836,6 +4869,9 @@ static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+ if (!doc_hasShapeSelection(pDocument->mxComponent))
+ return 0;
+
uno::Reference<frame::XStorable> xStorable(pDocument->mxComponent, uno::UNO_QUERY_THROW);
SvMemoryStream aOutStream;