diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2021-08-12 15:58:15 +0530 |
---|---|---|
committer | Dennis Francis <dennis.francis@collabora.com> | 2021-09-07 07:08:54 +0200 |
commit | 9cc818355dad271c030af611862f15c0e081321a (patch) | |
tree | 1e6553fc6ebd1b9121d629eaac29babe5324f406 | |
parent | 48beccf52413981d3d1c525a81a2c57048abe261 (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>
(cherry picked from commit 5f2d669a51a91b21196eecb935aa55d3fc1aa7be)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120736
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitEnums.h | 8 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 19 |
3 files changed, 28 insertions, 0 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index ae8eacd9151f..c9d694ca8b4d 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -772,6 +772,12 @@ typedef enum * The payload format is JSON: { "title": "title text", "content": "content text" } */ LOK_CALLBACK_VALIDITY_INPUT_HELP = 51, + + /** + * This is currently Calc only. Indicates the document background + * color in the payload as a RGB hex string (RRGGBB). + */ + LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR = 52, } LibreOfficeKitCallbackType; @@ -904,6 +910,8 @@ static inline const char* lokCallbackTypeToString(int nType) return "LOK_CALLBACK_FORM_FIELD_BUTTON"; case LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY: return "LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY"; + case LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR: + return "LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR"; } assert(!"Unknown LibreOfficeKitCallbackType type."); diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 156224b57351..9102672e12ec 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -1414,6 +1414,7 @@ callback (gpointer pData) case LOK_CALLBACK_TAB_STOP_LIST: case LOK_CALLBACK_FORM_FIELD_BUTTON: case LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY: + case LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR: { // TODO: Implement me break; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index e0de184bfcea..6237277c8498 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> @@ -965,6 +966,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(); @@ -972,6 +986,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_); |