summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-06-04 20:57:19 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-06-06 08:36:41 +0200
commit405f9f02e202c10d43c3de715f4efc97ab1f6f59 (patch)
tree6c4a8c6a6de85261f6636cd77fa25f1dff8ebd2f /desktop
parent677761a10059c33ba25df7daeee4e72e199248e4 (diff)
lok: callback to send the updated theme palette when theme changes
The callback sends the updated theme color palette when the theme changes or initially when the view is registered, so the client should always have the up-to-date theme color palette stored, so it can just show the color picker with the theme at any time without the need to call the server. Change-Id: I7cceccc46c2fad23ba89e6d3f3643e37f8dab292 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152589 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit e86a0236e69d76769b91f96d71fe852b91c5db6e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152625 Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/data/ThemeDocument.docxbin0 -> 13121 bytes
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx40
-rw-r--r--desktop/source/lib/init.cxx2
3 files changed, 42 insertions, 0 deletions
diff --git a/desktop/qa/data/ThemeDocument.docx b/desktop/qa/data/ThemeDocument.docx
new file mode 100644
index 000000000000..4dbba883d9b6
--- /dev/null
+++ b/desktop/qa/data/ThemeDocument.docx
Binary files differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d04c59aae76a..3fe78d8cb2d4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -217,6 +217,7 @@ public:
void testRenderSearchResult_CommonNode();
void testNoDuplicateTableSelection();
void testMultiViewTableSelection();
+ void testColorPaletteCallback();
void testABI();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
@@ -287,6 +288,7 @@ public:
CPPUNIT_TEST(testRenderSearchResult_CommonNode);
CPPUNIT_TEST(testNoDuplicateTableSelection);
CPPUNIT_TEST(testMultiViewTableSelection);
+ CPPUNIT_TEST(testColorPaletteCallback);
CPPUNIT_TEST(testABI);
CPPUNIT_TEST_SUITE_END();
@@ -2159,12 +2161,14 @@ class ViewCallback
public:
OString m_aCellFormula;
int m_nTableSelectionCount;
+ int m_nColorPaletteCallbackCount = 0;
bool m_bEmptyTableSelection;
bool m_bTilesInvalidated;
bool m_bZeroCursor;
tools::Rectangle m_aOwnCursor;
boost::property_tree::ptree m_aCommentCallbackResult;
boost::property_tree::ptree m_aCallbackWindowResult;
+ boost::property_tree::ptree m_aColorPaletteCallbackResult;
bool m_bWindowHidden;
ViewCallback(LibLODocument_Impl* pDocument)
@@ -2244,6 +2248,14 @@ public:
++m_nTableSelectionCount;
}
break;
+ case LOK_CALLBACK_COLOR_PALETTES:
+ {
+ m_aColorPaletteCallbackResult.clear();
+ std::stringstream aStream(pPayload);
+ boost::property_tree::read_json(aStream, m_aColorPaletteCallbackResult);
+ ++m_nColorPaletteCallbackCount;
+ }
+ break;
}
}
};
@@ -3524,6 +3536,34 @@ void DesktopLOKTest::testMultiViewTableSelection()
CPPUNIT_ASSERT(!aView1.m_bEmptyTableSelection);
}
+void DesktopLOKTest::testColorPaletteCallback()
+{
+ LibLODocument_Impl* pDocument = loadDoc("ThemeDocument.docx");
+
+ // Create view 1.
+ pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+ ViewCallback aView1(pDocument);
+ Scheduler::ProcessEventsToIdle();
+ {
+ CPPUNIT_ASSERT_EQUAL(1, aView1.m_nColorPaletteCallbackCount);
+ boost::property_tree::ptree aValues = aView1.m_aColorPaletteCallbackResult.get_child("ThemeColors");
+ CPPUNIT_ASSERT(!aValues.empty());
+ CPPUNIT_ASSERT_EQUAL(size_t(6), aValues.size());
+ }
+
+ // Create view 2.
+ pDocument->m_pDocumentClass->createView(pDocument);
+ pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+ ViewCallback aView2(pDocument);
+ Scheduler::ProcessEventsToIdle();
+ {
+ CPPUNIT_ASSERT_EQUAL(1, aView2.m_nColorPaletteCallbackCount);
+ boost::property_tree::ptree aValues = aView1.m_aColorPaletteCallbackResult.get_child("ThemeColors");
+ CPPUNIT_ASSERT(!aValues.empty());
+ CPPUNIT_ASSERT_EQUAL(size_t(6), aValues.size());
+ }
+}
+
namespace {
constexpr size_t classOffset(int i)
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 38283c2deef8..743881175763 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1799,6 +1799,7 @@ void CallbackFlushHandler::queue(const int type, CallbackData& aCallbackData)
case LOK_CALLBACK_A11Y_FOCUS_CHANGED:
case LOK_CALLBACK_A11Y_CARET_CHANGED:
case LOK_CALLBACK_A11Y_TEXT_SELECTION_CHANGED:
+ case LOK_CALLBACK_COLOR_PALETTES:
{
const auto& pos = std::find(m_queue1.rbegin(), m_queue1.rend(), type);
auto pos2 = toQueue2(pos);
@@ -1860,6 +1861,7 @@ void CallbackFlushHandler::queue(const int type, CallbackData& aCallbackData)
case LOK_CALLBACK_A11Y_FOCUS_CHANGED:
case LOK_CALLBACK_A11Y_CARET_CHANGED:
case LOK_CALLBACK_A11Y_TEXT_SELECTION_CHANGED:
+ case LOK_CALLBACK_COLOR_PALETTES:
{
if (removeAll(type))
SAL_INFO("lok", "Removed dups of [" << type << "]: [" << aCallbackData.getPayload() << "].");