diff options
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitEnums.h | 11 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 19 |
3 files changed, 29 insertions, 2 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index 4090fc8abbac..497a5eacc804 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -774,6 +774,12 @@ typedef enum 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, + + /** * The position of the cell cursor jumped to. * * Payload format: "x, y, width, height, column, row", where the first @@ -783,8 +789,7 @@ typedef enum * * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES. */ - LOK_CALLBACK_SC_FOLLOW_JUMP = 52, - + LOK_CALLBACK_SC_FOLLOW_JUMP = 53, } LibreOfficeKitCallbackType; @@ -917,6 +922,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"; case LOK_CALLBACK_SC_FOLLOW_JUMP: return "LOK_CALLBACK_SC_FOLLOW_JUMP"; } diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 3edc58bfe141..68c23ffa4e55 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: case LOK_CALLBACK_SC_FOLLOW_JUMP: { // TODO: Implement me diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index a320a76f5ae9..40d2b639738f 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -21,6 +21,7 @@ #include <scitems.hxx> #include <comphelper/sequence.hxx> +#include <editeng/brushitem.hxx> #include <editeng/editview.hxx> #include <editeng/outliner.hxx> #include <o3tl/any.hxx> @@ -957,6 +958,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(); @@ -964,6 +978,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_); |