summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2021-08-12 15:58:15 +0530
committerDennis Francis <dennis.francis@collabora.com>2021-08-18 13:49:33 +0200
commit5f2d669a51a91b21196eecb935aa55d3fc1aa7be (patch)
tree1ded4ca3148dcd90a5a4496568dd0af799679c5a /sc
parent5c84de37ada9f5835bf0a644b0d5b7f7c7dedd2c (diff)
sc: lok: introduce LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR callback
to send the document background color (Calc only for now). Change-Id: Ibd2f042a81c9bb714bed947c4ef92f82ff3e6f50 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120524 Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Tested-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/unoobj/docuno.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 8478211e2bca..186c4ffe9d39 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -23,6 +23,7 @@
#include <scitems.hxx>
#include <comphelper/sequence.hxx>
+#include <editeng/brushitem.hxx>
#include <editeng/editview.hxx>
#include <editeng/outliner.hxx>
#include <o3tl/any.hxx>
@@ -958,6 +959,19 @@ bool ScModelObj::isMimeTypeSupported()
return EditEngine::HasValidData(aDataHelper.GetTransferable());
}
+static void lcl_sendLOKDocumentBackground(const ScViewData* pViewData)
+{
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument& rDoc = pDocSh->GetDocument();
+ const ScPatternAttr *pAttr = rDoc.GetDefPattern();
+ const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND);
+ const SvxBrushItem& rBackground = static_cast<const SvxBrushItem&>(rItem);
+ const Color& rColor = rBackground.GetColor();
+
+ ScTabViewShell* pViewShell = pViewData->GetViewShell();
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR, rColor.AsRGBHexString().toUtf8().getStr());
+}
+
void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int nTileTwipWidth_, int nTileTwipHeight_)
{
ScViewData* pViewData = ScDocShell::GetViewData();
@@ -965,6 +979,11 @@ void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int
if (!pViewData)
return;
+ // Currently in LOK clients the doc background cannot be changed, so send this sparingly as possible but for every view.
+ // FIXME: Find a better place to trigger this callback where it would be called just once per view creation.
+ // Doing this in ScTabViewShell init code does not work because callbacks do not work at that point for the first view.
+ lcl_sendLOKDocumentBackground(pViewData);
+
const Fraction newZoomX(nTilePixelWidth_ * TWIPS_PER_PIXEL, nTileTwipWidth_);
const Fraction newZoomY(nTilePixelHeight_ * TWIPS_PER_PIXEL, nTileTwipHeight_);