[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit sfx2/source

2022-11-19 Thread Szymon Kłos (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |5 -
 desktop/source/lib/init.cxx |  113 +---
 include/LibreOfficeKit/LibreOfficeKit.h |4 
 include/LibreOfficeKit/LibreOfficeKit.hxx   |8 +
 sfx2/source/view/lokhelper.cxx  |6 -
 5 files changed, 103 insertions(+), 33 deletions(-)

New commits:
commit 931e3d204e59ccb2e9c479477e6e66b2c098924f
Author: Szymon Kłos 
AuthorDate: Mon Aug 29 09:34:53 2022 +0200
Commit: Szymon Kłos 
CommitDate: Sat Nov 19 18:16:16 2022 +0100

lok: masterpage: Introduce mode property to tile rendering

This is needed for Impress which can have slides in
two Edit Modes: Master Page and Page.

Change-Id: I3eca0f51ba7970e793026d1ac6aa09b19b7a904b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137869
Reviewed-by: Ashod Nakashian 
Tested-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142969
Tested-by: Jenkins
Reviewed-by: Szymon Kłos 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index dd84323f6c9b..e7762753775f 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2275,7 +2275,7 @@ void DesktopLOKTest::testPaintPartTile()
 
 // Call paintPartTile() to paint the second part (in whichever view it 
finds suitable for this).
 unsigned char pPixels[256 * 256 * 4];
-pDocument->m_pDocumentClass->paintPartTile(pDocument, pPixels, 1, 256, 
256, 0, 0, 256, 256);
+pDocument->m_pDocumentClass->paintPartTile(pDocument, pPixels, 1, 0, 256, 
256, 0, 0, 256, 256);
 
 // Type again.
 Scheduler::ProcessEventsToIdle();
@@ -3624,10 +3624,11 @@ void DesktopLOKTest::testABI()
  offsetof(struct _LibreOfficeKitDocumentClass, 
sendContentControlEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), offsetof(struct 
_LibreOfficeKitDocumentClass, getSelectionTypeAndText));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(66), offsetof(struct 
_LibreOfficeKitDocumentClass, getDataArea));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), offsetof(struct 
_LibreOfficeKitDocumentClass, getEditMode));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(68), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1163ef2a638f..766248ef00ef 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -998,6 +998,7 @@ static void doc_selectPart(LibreOfficeKitDocument* pThis, 
int nPart, int nSelect
 static void doc_moveSelectedParts(LibreOfficeKitDocument* pThis, int 
nPosition, bool bDuplicate);
 static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart);
 static void doc_setPartMode(LibreOfficeKitDocument* pThis, int nPartMode);
+static int doc_getEditMode(LibreOfficeKitDocument* pThis);
 static void doc_paintTile(LibreOfficeKitDocument* pThis,
   unsigned char* pBuffer,
   const int nCanvasWidth, const int nCanvasHeight,
@@ -1013,6 +1014,7 @@ static void 
doc_paintTileToCGContext(LibreOfficeKitDocument* pThis,
 static void doc_paintPartTile(LibreOfficeKitDocument* pThis,
   unsigned char* pBuffer,
   const int nPart,
+  const int nMode,
   const int nCanvasWidth, const int nCanvasHeight,
   const int nTilePosX, const int nTilePosY,
   const int nTileWidth, const int nTileHeight);
@@ -1269,6 +1271,7 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference 
 xC
 m_pDocumentClass->moveSelectedParts = doc_moveSelectedParts;
 m_pDocumentClass->getPartName = doc_getPartName;
 m_pDocumentClass->setPartMode = doc_setPartMode;
+m_pDocumentClass->getEditMode = doc_getEditMode;
 m_pDocumentClass->paintTile = doc_paintTile;
 #ifdef IOS
 m_pDocumentClass->paintTileToCGContext = doc_paintTileToCGContext;
@@ -3641,6 +3644,23 @@ static void doc_setPartMode(LibreOfficeKitDocument* 
pThis,
 }
 }
 
+static int doc_getEditMode(LibreOfficeKitDocument* pThis)
+{
+comphelper::ProfileZone aZone("doc_getEditMode");
+
+SolarMutexGuard aGuard;
+SetLastExceptionMsg();
+
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+SetLastExceptionMsg("Document doesn't support tiled rendering");
+return 0;
+}
+
+return pDoc->getEditMode();
+}
+
 static void doc_paintTile(LibreOfficeKitDocument* pThis,
   unsigned char* pBuffer,
  

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit sfx2/source

2019-11-30 Thread Michael Meeks (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 +-
 desktop/source/lib/init.cxx |   29 ++--
 include/LibreOfficeKit/LibreOfficeKit.h |9 
 include/LibreOfficeKit/LibreOfficeKit.hxx   |7 +++---
 sfx2/source/control/shell.cxx   |7 ++
 5 files changed, 45 insertions(+), 10 deletions(-)

New commits:
commit 71c5b374deb35993d0af3e953ff0cdfc64d76aab
Author: Michael Meeks 
AuthorDate: Sat Nov 30 14:59:02 2019 +
Commit: Michael Meeks 
CommitDate: Sat Nov 30 22:58:58 2019 +0100

lok: add viewId to window painting, to allow special-casing on render.

View switching should not cause the sidebar UX to re-build at all.
Particularly it should not do this when we switch view just to render
a sidebar.

Change-Id: Iec0427cdc8308fc273d73ea56dd208bfa7036471
Reviewed-on: https://gerrit.libreoffice.org/84120
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
(cherry picked from commit 92814f3389de346f3ae32cddb38f079763e68ddf)
Reviewed-on: https://gerrit.libreoffice.org/84129
Tested-by: Jenkins

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 242a539cf08e..08fa6a54ab62 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2750,10 +2750,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(55), offsetof(struct 
_LibreOfficeKitDocumentClass, removeTextContext));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), offsetof(struct 
_LibreOfficeKitDocumentClass, sendDialogEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), offsetof(struct 
_LibreOfficeKitDocumentClass, renderFontOrientation));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), offsetof(struct 
_LibreOfficeKitDocumentClass, paintWindowForView));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2d8f7290a05d..8f05cc487672 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -905,6 +905,11 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* 
pThis, unsigned nLOKWindo
const int nWidth, const int nHeight,
const double fDPIScale);
 
+static void doc_paintWindowForView(LibreOfficeKitDocument* pThis, unsigned 
nLOKWindowId, unsigned char* pBuffer,
+   const int nX, const int nY,
+   const int nWidth, const int nHeight,
+   const double fDPIScale, int viewId);
+
 static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned
  nLOKWindowId, int nAction, const char* pData);
 
@@ -1022,6 +1027,7 @@ LibLODocument_Impl::LibLODocument_Impl(const 
uno::Reference paintWindow = doc_paintWindow;
 m_pDocumentClass->paintWindowDPI = doc_paintWindowDPI;
+m_pDocumentClass->paintWindowForView = doc_paintWindowForView;
 m_pDocumentClass->postWindow = doc_postWindow;
 m_pDocumentClass->resizeWindow = doc_resizeWindow;
 
@@ -4850,12 +4856,20 @@ static void doc_paintWindow(LibreOfficeKitDocument* 
pThis, unsigned nLOKWindowId
 doc_paintWindowDPI(pThis, nLOKWindowId, pBuffer, nX, nY, nWidth, nHeight, 
1.0);
 }
 
-static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned 
nLOKWindowId,
+static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis, unsigned 
nLOKWindowId,
unsigned char* pBuffer,
const int nX, const int nY,
const int nWidth, const int nHeight,
const double fDPIScale)
 {
+doc_paintWindowForView(pThis, nLOKWindowId, pBuffer, nX, nY, nWidth, 
nHeight, fDPIScale, -1);
+}
+
+static void doc_paintWindowForView(LibreOfficeKitDocument* pThis, unsigned 
nLOKWindowId,
+   unsigned char* pBuffer, const int nX, const 
int nY,
+   const int nWidth, const int nHeight,
+   const double fDPIScale, int viewId)
+{
 comphelper::ProfileZone aZone("doc_paintWindowDPI");
 
 SolarMutexGuard aGuard;
@@ -4868,6 +4882,12 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* 
/*pThis*/, unsigned nLOKW
 return;
 }
 
+// Used to avoid work in setView if set.
+comphelper::LibreOfficeKit::setDialogPainting(true);
+
+if (viewId >= 0)
+doc_setView(pThis, viewId);
+
 // Setup cairo (or CoreGraphics, in the iOS case) 

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit sfx2/source

2017-02-28 Thread Katarina Behrens
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   15 
 desktop/source/lib/init.cxx |   88 
 include/LibreOfficeKit/LibreOfficeKit.h |2 
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   13 
 sfx2/source/appl/macroloader.cxx|   18 +
 5 files changed, 135 insertions(+), 1 deletion(-)

New commits:
commit e7729f458409f7fef2b7dab752205e3b230acb65
Author: Katarina Behrens 
Date:   Sun Feb 19 23:58:52 2017 +0100

Run macro:// via LOKit

Change-Id: I54d3c734d86d4b44e1dfe1ad7728e2f51cd26d53
Reviewed-on: https://gerrit.libreoffice.org/34538
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 62ec69d..81cbece 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -107,6 +107,7 @@ public:
 void testCommentsCalc();
 void testCommentsImpress();
 void testCommentsCallbacksWriter();
+void testRunMacro();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
 CPPUNIT_TEST(testGetStyles);
@@ -145,6 +146,7 @@ public:
 CPPUNIT_TEST(testCommentsCalc);
 CPPUNIT_TEST(testCommentsImpress);
 CPPUNIT_TEST(testCommentsCallbacksWriter);
+CPPUNIT_TEST(testRunMacro);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
@@ -2096,6 +2098,19 @@ void DesktopLOKTest::testCommentsCallbacksWriter()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testRunMacro()
+{
+LibLibreOffice_Impl aOffice;
+bool bGoodMacro, bNonExistentMacro;
+
+// Tools macros come pre-installed in system share/basic folder,
+bGoodMacro = aOffice.m_pOfficeClass->runMacro(, 
OString("macro:///Tools.Debug.ActivateReadOnlyFlag()").getStr());
+CPPUNIT_ASSERT(bGoodMacro);
+
+bNonExistentMacro = aOffice.m_pOfficeClass->runMacro(, 
OString("macro:///I.Am.Not(There)").getStr());
+CPPUNIT_ASSERT(!bNonExistentMacro);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 61fbc61..56d70b2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -40,6 +40,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -1054,6 +1056,7 @@ static void doc_destroy(LibreOfficeKitDocument *pThis)
 static voidlo_destroy   (LibreOfficeKit* pThis);
 static int lo_initialize(LibreOfficeKit* pThis, const 
char* pInstallPath, const char* pUserProfilePath);
 static LibreOfficeKitDocument* lo_documentLoad  (LibreOfficeKit* pThis, const 
char* pURL);
+static boollo_runMacro  (LibreOfficeKit* pThis, const 
char* pURL);
 static char *  lo_getError  (LibreOfficeKit* pThis);
 static voidlo_freeError (char* pFree);
 static LibreOfficeKitDocument* lo_documentLoadWithOptions  (LibreOfficeKit* 
pThis,
@@ -1082,6 +1085,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 
 m_pOfficeClass->destroy = lo_destroy;
 m_pOfficeClass->documentLoad = lo_documentLoad;
+m_pOfficeClass->runMacro = lo_runMacro;
 m_pOfficeClass->getError = lo_getError;
 m_pOfficeClass->freeError = lo_freeError;
 m_pOfficeClass->documentLoadWithOptions = lo_documentLoadWithOptions;
@@ -1211,6 +1215,90 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 return nullptr;
 }
 
+static bool lo_runMacro( LibreOfficeKit* pThis, const char *pURL)
+{
+SolarMutexGuard aGuard;
+
+LibLibreOffice_Impl* pLib = static_cast(pThis);
+
+OUString sURL( pURL, strlen(pURL), RTL_TEXTENCODING_UTF8 );
+if (sURL.isEmpty())
+{
+pLib->maLastExceptionMsg = "Macro to run was not provided.";
+SAL_INFO("lok", "Macro URL is empty");
+return false;
+}
+
+if (!sURL.startsWith("macro://"))
+{
+pLib->maLastExceptionMsg = "This doesn't look like macro URL";
+SAL_INFO("lok", "Macro URL is invalid");
+return false;
+}
+
+pLib->maLastExceptionMsg.clear();
+
+if (!xContext.is())
+{
+pLib->maLastExceptionMsg = "ComponentContext is not available";
+SAL_INFO("lok", "ComponentContext is not available");
+return false;
+}
+
+util::URL aURL;
+aURL.Complete = sURL;
+
+uno::Reference < util::XURLTransformer > xParser( 
util::URLTransformer::create( xContext ) );
+
+if( xParser.is() )
+xParser->parseStrict( aURL );
+
+uno::Reference xComponentLoader = 
frame::Desktop::create(xContext);
+
+if (!xComponentLoader.is())
+{
+pLib->maLastExceptionMsg = "ComponentLoader is not available";
+SAL_INFO("lok", "ComponentLoader is