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

2023-10-19 Thread Stephan Bergmann (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |6 +++---
 desktop/source/app/app.cxx  |2 +-
 desktop/source/app/check_ext_deps.cxx   |2 +-
 desktop/source/app/cmdlinehelp.cxx  |4 ++--
 desktop/source/app/crashreport.cxx  |4 ++--
 desktop/source/deployment/gui/dp_gui_dialog2.cxx|2 +-
 desktop/source/deployment/gui/dp_gui_theextmgr.cxx  |2 +-
 desktop/source/deployment/manager/dp_properties.cxx |2 +-
 desktop/source/deployment/misc/dp_dependencies.cxx  |8 
 desktop/source/deployment/registry/help/dp_help.cxx |2 +-
 desktop/source/lib/init.cxx |8 
 desktop/source/migration/migration.cxx  |8 
 desktop/source/migration/services/jvmfwk.cxx|2 +-
 13 files changed, 26 insertions(+), 26 deletions(-)

New commits:
commit 326a8d5dd2d01a2037f17a6fd921494937c134d4
Author: Stephan Bergmann 
AuthorDate: Thu Oct 19 10:30:11 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Oct 19 18:49:36 2023 +0200

Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: desktop

Change-Id: I896fb07e753bfd7be5df892b1608954ad6a9cece
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158188
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index dcb5c7192782..dd89ebf1eed0 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3044,7 +3044,7 @@ void DesktopLOKTest::testComplexSelection()
 {
 // Start with a blank text file and add contents.
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
-static constexpr OStringLiteral aText("hello world");
+static constexpr OString aText("hello world"_ostr);
 
 // Certainly not complex.
 CPPUNIT_ASSERT_EQUAL(static_cast(LOK_SELTYPE_NONE), 
pDocument->pClass->getSelectionType(pDocument));
@@ -3072,7 +3072,7 @@ void DesktopLOKTest::testComplexSelection()
 // Export as plain text, we should get only the text part "hello".
 char* pText = pDocument->pClass->getTextSelection(pDocument, 
"text/plain;charset=utf-8", nullptr);
 CPPUNIT_ASSERT(pText != nullptr);
-CPPUNIT_ASSERT_EQUAL(OString(aText), OString(pText));
+CPPUNIT_ASSERT_EQUAL(aText, OString(pText));
 free(pText);
 
 // Export as rtf, we should also get the image.
@@ -3128,7 +3128,7 @@ void DesktopLOKTest::testCalcSaveAs()
 
 void DesktopLOKTest::testSpellcheckerMultiView()
 {
-static constexpr OUStringLiteral aLangISO(u"en-US");
+static constexpr OUString aLangISO(u"en-US"_ustr);
 SvtSysLocaleOptions aSysLocaleOptions;
 aSysLocaleOptions.SetLocaleConfigString(aLangISO);
 aSysLocaleOptions.SetUILocaleConfigString(aLangISO);
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index cb3beaf0ae26..cd1d1de0d6ea 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -581,7 +581,7 @@ bool Desktop::QueryExit()
 {
 }
 
-static constexpr OUStringLiteral SUSPEND_QUICKSTARTVETO = 
u"SuspendQuickstartVeto";
+static constexpr OUString SUSPEND_QUICKSTARTVETO = 
u"SuspendQuickstartVeto"_ustr;
 
 Reference< XDesktop2 > xDesktop = css::frame::Desktop::create( 
::comphelper::getProcessComponentContext() );
 Reference< XPropertySet > xPropertySet(xDesktop, UNO_QUERY_THROW);
diff --git a/desktop/source/app/check_ext_deps.cxx 
b/desktop/source/app/check_ext_deps.cxx
index 8b53d564feb1..4a69a8cf79cc 100644
--- a/desktop/source/app/check_ext_deps.cxx
+++ b/desktop/source/app/check_ext_deps.cxx
@@ -208,7 +208,7 @@ void SilentCommandEnv::pop()
 } // end namespace
 
 
-constexpr OUStringLiteral aAccessSrvc = 
u"com.sun.star.configuration.ConfigurationUpdateAccess";
+constexpr OUString aAccessSrvc = 
u"com.sun.star.configuration.ConfigurationUpdateAccess"_ustr;
 
 static sal_Int16 impl_showExtensionDialog( uno::Reference< 
uno::XComponentContext > const  )
 {
diff --git a/desktop/source/app/cmdlinehelp.cxx 
b/desktop/source/app/cmdlinehelp.cxx
index 58b8b3abb566..9c9fd940f233 100644
--- a/desktop/source/app/cmdlinehelp.cxx
+++ b/desktop/source/app/cmdlinehelp.cxx
@@ -35,9 +35,9 @@
 
 namespace desktop
 {
-constexpr OUStringLiteral aCmdLineHelp_version =
+constexpr OUString aCmdLineHelp_version =
 u"%PRODUCTNAME %PRODUCTVERSION%PRODUCTEXTENSION %BUILDID\n"
-"\n";
+"\n"_ustr;
 constexpr OUStringLiteral aCmdLineHelp =
 u"Usage: %CMDNAME [argument...]\n"
 "   argument - switches, switch parameters and document URIs 
(filenames).   \n\n"
diff --git a/desktop/source/app/crashreport.cxx 
b/desktop/source/app/crashreport.cxx
index 680492b3b80a..186a59b02101 100644
--- a/desktop/source/app/crashreport.cxx
+++ b/desktop/source/app/crashreport.cxx
@@ -135,8 +135,8 @@ void 

[Libreoffice-commits] core.git: desktop/qa desktop/source docmodel/source include/docmodel include/LibreOfficeKit include/svx libreofficekit/source sd/source svx/source sw/inc sw/source

2023-06-05 Thread Tomaž Vajngerl (via logerrit)
 desktop/qa/data/ThemeDocument.docx |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx|   40 +++
 desktop/source/lib/init.cxx|2 +
 docmodel/source/color/ComplexColorJSON.cxx |   15 +---
 include/LibreOfficeKit/LibreOfficeKitEnums.h   |9 -
 include/docmodel/color/ComplexColorJSON.hxx|3 +
 include/svx/svdpage.hxx|1 
 include/svx/theme/ThemeColorPaletteManager.hxx |1 
 libreofficekit/source/gtk/lokdocview.cxx   |1 
 sd/source/ui/inc/ViewShellBase.hxx |2 +
 sd/source/ui/view/ViewShellBase.cxx|5 ++
 svx/source/svdraw/svdpage.cxx  |   19 +++
 svx/source/theme/ThemeColorPaletteManager.cxx  |   43 +
 sw/inc/view.hxx|2 +
 sw/source/uibase/uiview/view.cxx   |   15 
 15 files changed, 150 insertions(+), 8 deletions(-)

New commits:
commit e86a0236e69d76769b91f96d71fe852b91c5db6e
Author: Tomaž Vajngerl 
AuthorDate: Sun Jun 4 20:57:19 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 5 13:06:57 2023 +0200

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 

diff --git a/desktop/qa/data/ThemeDocument.docx 
b/desktop/qa/data/ThemeDocument.docx
new file mode 100644
index ..4dbba883d9b6
Binary files /dev/null and b/desktop/qa/data/ThemeDocument.docx differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 74db478c09a3..b698cc5976b7 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -219,6 +219,7 @@ public:
 void testRenderSearchResult_CommonNode();
 void testNoDuplicateTableSelection();
 void testMultiViewTableSelection();
+void testColorPaletteCallback();
 void testABI();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
@@ -291,6 +292,7 @@ public:
 CPPUNIT_TEST(testRenderSearchResult_CommonNode);
 CPPUNIT_TEST(testNoDuplicateTableSelection);
 CPPUNIT_TEST(testMultiViewTableSelection);
+CPPUNIT_TEST(testColorPaletteCallback);
 CPPUNIT_TEST(testABI);
 CPPUNIT_TEST_SUITE_END();
 
@@ -2160,12 +2162,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)
@@ -2245,6 +2249,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;
 }
 }
 };
@@ -3525,6 +3537,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());
+}
+}
+
 

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

2023-06-02 Thread Marco Cecchetti (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx  |8 
 desktop/source/lib/init.cxx  |  144 +++--
 include/LibreOfficeKit/LibreOfficeKit.h  |9 
 include/LibreOfficeKit/LibreOfficeKit.hxx|   30 +
 include/LibreOfficeKit/LibreOfficeKitEnums.h |   41 +
 include/sal/log-areas.dox|1 
 include/sfx2/lokhelper.hxx   |2 
 include/sfx2/viewsh.hxx  |   11 
 libreofficekit/source/gtk/lokdocview.cxx |3 
 sfx2/source/view/lokhelper.cxx   |   17 
 sfx2/source/view/viewsh.cxx  |  741 +++
 11 files changed, 968 insertions(+), 39 deletions(-)

New commits:
commit 14b3ad0b4e5a540f436db3467f8a4051392f8479
Author: Marco Cecchetti 
AuthorDate: Thu Mar 23 08:33:16 2023 +0100
Commit: Miklos Vajna 
CommitDate: Fri Jun 2 08:04:38 2023 +0200

lok: accessibility event listener for focused paragraph

LOKDocumentFocusListener keeps track of the currently focused
paragraph.

Also includes:

Author: Andras Timar 
Date:   Mon May 15 22:06:10 2023 +0200

fix unused exception parameter 'e'

Change-Id: Ibfee099e4e9b724648d7500b9ebb4e8ab84989b8

and:

Author: Marco Cecchetti 
Date:   Thu May 4 12:11:53 2023 +0200

lok: a11y: focused paragraph info sent to client

For the currently focused paragraph the following data is 
notified to
client:
paragraph content, caret position, text selection start/end
These data is kept as an instance state so the client can 
request such
info at any time.

Change-Id: Ic1a3be0d93472300b1b6a91fb0de5bad87c031aa

and:

Author: Marco Cecchetti 
Date:   Sun May 7 11:52:14 2023 +0200

fixup! lok: accessibility event listener for focused paragraph

It seems it was not a good idea using a unique_ptr as smart 
pointer
for an instance of LOKDocumentFocusListener

Change-Id: I8e6b0f48fee3c5db3c9b074a663f7f3fb96a601e

Change-Id: I0fa400694f3129608228ade0b96e0b4e0aee87e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152488
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 675ebfe82e8d..74db478c09a3 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3641,9 +3641,15 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), offsetof(struct 
_LibreOfficeKitDocumentClass, getEditMode));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(68),
  offsetof(struct _LibreOfficeKitDocumentClass, 
setViewTimezone));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(69),
+ offsetof(struct _LibreOfficeKitDocumentClass, 
setAccessibilityState));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(70),
+ offsetof(struct _LibreOfficeKitDocumentClass, 
getA11yFocusedParagraph));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(71),
+ offsetof(struct _LibreOfficeKitDocumentClass, 
getA11yCaretPosition));
 
 // As above
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(69), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(72), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 8561760febce..13922571d9ce 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1309,6 +1309,11 @@ static void 
doc_sendContentControlEvent(LibreOfficeKitDocument* pThis, const cha
 
 static void doc_setViewTimezone(LibreOfficeKitDocument* pThis, int nId, const 
char* timezone);
 
+static void doc_setAccessibilityState(LibreOfficeKitDocument* pThis, int nId, 
bool bEnabled);
+
+static char* doc_getA11yFocusedParagraph(LibreOfficeKitDocument* pThis);
+
+static int doc_getA11yCaretPosition(LibreOfficeKitDocument* pThis);
 } // extern "C"
 
 namespace {
@@ -1361,6 +1366,45 @@ vcl::Font FindFont_FallbackToDefault(std::u16string_view 
rFontName)
 return OutputDevice::GetDefaultFont(DefaultFontType::SANS_UNICODE, 
LANGUAGE_NONE,
 GetDefaultFontFlags::NONE);
 }
+
+int getDocumentType (LibreOfficeKitDocument* pThis)
+{
+SetLastExceptionMsg();
+
+LibLODocument_Impl* pDocument = static_cast(pThis);
+
+try
+{
+uno::Reference xDocument(pDocument->mxComponent, 
uno::UNO_QUERY_THROW);
+
+if 
(xDocument->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
+{
+return 

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

2023-03-11 Thread Michael Meeks (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 +-
 desktop/source/lib/init.cxx |8 ++
 include/LibreOfficeKit/LibreOfficeKit.h |4 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   17 +
 include/vcl/lok.hxx |4 +++
 vcl/inc/graphic/Manager.hxx |8 --
 vcl/inc/impgraph.hxx|2 +
 vcl/inc/svdata.hxx  |7 +
 vcl/source/app/svapp.cxx|   21 
 vcl/source/app/svdata.cxx   |   23 +
 vcl/source/gdi/impgraph.cxx |   25 +++
 vcl/source/graphic/Manager.cxx  |   36 +++-
 12 files changed, 149 insertions(+), 9 deletions(-)

New commits:
commit 4a4602ad7513262a6c0423f17b42791a852b7e23
Author: Michael Meeks 
AuthorDate: Fri Mar 10 10:36:22 2023 +
Commit: Michael Meeks 
CommitDate: Sat Mar 11 21:03:05 2023 +

lok: add trimMemory capability, and expand dumpState to caches.

Being able to trigger some more aggressive memory saving is
useful in for both online and mobile.

Change-Id: I9b91c9fe9eecec06c75112595deac0bfeb94c144
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148624
Tested-by: Jenkins

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 217b537fa214..a919dbcf4267 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3554,10 +3554,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(14), offsetof(struct 
_LibreOfficeKitClass, setOption));
 CPPUNIT_ASSERT_EQUAL(classOffset(15), offsetof(struct 
_LibreOfficeKitClass, dumpState));
 CPPUNIT_ASSERT_EQUAL(classOffset(16), offsetof(struct 
_LibreOfficeKitClass, extractRequest));
+CPPUNIT_ASSERT_EQUAL(classOffset(17), offsetof(struct 
_LibreOfficeKitClass, trimMemory));
 
 // When extending LibreOfficeKit with a new function pointer,  add new 
assert for the offsetof the
 // new function pointer and bump this assert for the size of the class.
-CPPUNIT_ASSERT_EQUAL(classOffset(17), sizeof(struct _LibreOfficeKitClass));
+CPPUNIT_ASSERT_EQUAL(classOffset(18), sizeof(struct _LibreOfficeKitClass));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cf23f09f1413..9722be530db2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2523,6 +2523,8 @@ static bool lo_signDocument(LibreOfficeKit* pThis,
 static char* lo_extractRequest(LibreOfficeKit* pThis,
const char* pFilePath);
 
+static void lo_trimMemory(LibreOfficeKit* pThis, int nTarget);
+
 static void lo_runLoop(LibreOfficeKit* pThis,
LibreOfficeKitPollCallback pPollCallback,
LibreOfficeKitWakeCallback pWakeCallback,
@@ -2564,6 +2566,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->setOption = lo_setOption;
 m_pOfficeClass->dumpState = lo_dumpState;
 m_pOfficeClass->extractRequest = lo_extractRequest;
+m_pOfficeClass->trimMemory = lo_trimMemory;
 
 gOfficeClass = m_pOfficeClass;
 }
@@ -3142,6 +3145,11 @@ static char* lo_extractRequest(LibreOfficeKit* 
/*pThis*/, const char* pFilePath)
 return convertOUString(result);
 }
 
+static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget)
+{
+vcl::lok::trimMemory(nTarget);
+}
+
 static void lo_registerCallback (LibreOfficeKit* pThis,
  LibreOfficeKitCallback pCallback,
  void* pData)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 3887d3d3c412..e98ea6f47f42 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -127,6 +127,10 @@ struct _LibreOfficeKitClass
  */
 char* (*extractRequest) (LibreOfficeKit* pThis,
const char* pFilePath);
+
+/// @see lok::Office::trimMemory
+/// @since LibreOffice 7.6
+void (*trimMemory) (LibreOfficeKit* pThis, int nTarget);
 };
 
 #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) 
LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index d3c2e5de78aa..bc3bbb98cc10 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -1146,6 +1146,23 @@ public:
 {
 return mpThis->pClass->extractRequest(mpThis, 

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

2023-03-07 Thread Tor Lillqvist (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 ---
 desktop/source/lib/init.cxx |   34 
 include/LibreOfficeKit/LibreOfficeKit.h |8 --
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   25 
 4 files changed, 1 insertion(+), 70 deletions(-)

New commits:
commit 1f4e9eacc36413bba92f119ebed931cfdb975e80
Author: Tor Lillqvist 
AuthorDate: Tue Mar 7 11:43:00 2023 +0200
Commit: Tor Lillqvist 
CommitDate: Tue Mar 7 14:40:02 2023 +

Drop the LibreOfficeKit paintThumbnail() API

It turns out that Mert's original idea is actually the simplest and it
is known to work. And in that, the separate paintThumbnail() is rather
pointless, as all paintThumbnail() did was to call paintTile(). The
caller (in Collabora Online) knows when a file is opened specifically
for thumbnailing, and can call paintTile() itself with the appropriate
parameters.

My misguided idea would have had paintThumbnail() somehow figure out
the physical Twip coordinates of the current location (for text
documents, the insertion caret location) in the document. (Or, as
LibreOfficeKit for some reason calls them, "logical" coordinates, even
if a Twip is a very physical length unit.) Then it would have called
paintTile() with those coordinates. But it turned out to be rather
hard to figure out the Twip coordinates of the current location in
the document.

Mert's idea was that when a document is opened for thumbnailing, only
Online actually needs to know that. From LibreOfficeKit's and core's
point of view it is a normal document load operation. Then Online
performs the .uno:OpenHyperlink magic, which makes core move the
current position to the requested "target" or "mark" (the terminology
varies) location. And then a "cursor" callback is used by Online to
get the Twip coordinates of the target. It is a bit unclear to me
whether .uno:HyperLink causes the document to be opened an extra time,
but whatever, this way is said to work. So let's do it like that.

This reverts the paintThumbnail part of
1aa37ca99112c0760552600d7774ba7224581c5b.

Change-Id: I8f3d9917ee362c1518834fc10a57c57ebc4a6edb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148390
Tested-by: Tor Lillqvist 
Reviewed-by: Tor Lillqvist 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index c143662d7dd4..217b537fa214 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3635,11 +3635,9 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), offsetof(struct 
_LibreOfficeKitDocumentClass, getEditMode));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(68),
  offsetof(struct _LibreOfficeKitDocumentClass, 
setViewTimezone));
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(69), offsetof(struct 
_LibreOfficeKitDocumentClass, paintThumbnail));
-
 
 // As above
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(70), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(69), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 903dc2b06687..ee1f47a8ea96 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1114,12 +1114,6 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
   const int nCanvasWidth, const int nCanvasHeight,
   const int nTilePosX, const int nTilePosY,
   const int nTileWidth, const int nTileHeight);
-static void doc_paintThumbnail(LibreOfficeKitDocument* pThis,
-   unsigned char* pBuffer,
-   int bufferWidth,
-   int bufferHeight,
-   int width,
-   const char* pURL);
 #ifdef IOS
 static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis,
  void* rCGContext,
@@ -1393,7 +1387,6 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference 
 xC
 m_pDocumentClass->setPartMode = doc_setPartMode;
 m_pDocumentClass->getEditMode = doc_getEditMode;
 m_pDocumentClass->paintTile = doc_paintTile;
-m_pDocumentClass->paintThumbnail = doc_paintThumbnail;
 #ifdef IOS
 m_pDocumentClass->paintTileToCGContext = doc_paintTileToCGContext;
 #endif
@@ -4015,33 +4008,6 @@ static void 
doc_paintTileToCGContext(LibreOfficeKitDocument* pThis,
 
 #endif
 
-static void doc_paintThumbnail(LibreOfficeKitDocument* pThis,
-   unsigned char* pBuffer,
-   int bufferWidth,
-  

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

2023-02-22 Thread Tor Lillqvist (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   16 ++
 desktop/source/lib/init.cxx |  175 
 include/LibreOfficeKit/LibreOfficeKit.h |   10 +
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   10 +
 4 files changed, 208 insertions(+), 3 deletions(-)

New commits:
commit 1aa37ca99112c0760552600d7774ba7224581c5b
Author: Tor Lillqvist 
AuthorDate: Tue Feb 21 13:19:42 2023 +0200
Commit: Tor Lillqvist 
CommitDate: Wed Feb 22 08:14:30 2023 +

Extend LOKit API with functionality to extract a request and paint 
thumbnails

Original author was Mert Tümer.

Change-Id: I181a9955bcce1d5ee4c81e2a52445ef318dc4823
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147396
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3d2fc3c0d2fb..c143662d7dd4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3549,6 +3549,15 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(9), offsetof(struct _LibreOfficeKitClass, 
getVersionInfo));
 CPPUNIT_ASSERT_EQUAL(classOffset(10), offsetof(struct 
_LibreOfficeKitClass, runMacro));
 CPPUNIT_ASSERT_EQUAL(classOffset(11), offsetof(struct 
_LibreOfficeKitClass, signDocument));
+CPPUNIT_ASSERT_EQUAL(classOffset(12), offsetof(struct 
_LibreOfficeKitClass, runLoop));
+CPPUNIT_ASSERT_EQUAL(classOffset(13), offsetof(struct 
_LibreOfficeKitClass, sendDialogEvent));
+CPPUNIT_ASSERT_EQUAL(classOffset(14), offsetof(struct 
_LibreOfficeKitClass, setOption));
+CPPUNIT_ASSERT_EQUAL(classOffset(15), offsetof(struct 
_LibreOfficeKitClass, dumpState));
+CPPUNIT_ASSERT_EQUAL(classOffset(16), offsetof(struct 
_LibreOfficeKitClass, extractRequest));
+
+// When extending LibreOfficeKit with a new function pointer,  add new 
assert for the offsetof the
+// new function pointer and bump this assert for the size of the class.
+CPPUNIT_ASSERT_EQUAL(classOffset(17), sizeof(struct _LibreOfficeKitClass));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
@@ -3626,10 +3635,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), offsetof(struct 
_LibreOfficeKitDocumentClass, getEditMode));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(68),
  offsetof(struct _LibreOfficeKitDocumentClass, 
setViewTimezone));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(69), offsetof(struct 
_LibreOfficeKitDocumentClass, paintThumbnail));
+
 
-// Extending is fine, update this, and add new assert for the offsetof the
-// new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(69), sizeof(struct 
_LibreOfficeKitDocumentClass));
+// As above
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(70), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ed601003d042..1a077ce19500 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -179,6 +180,7 @@
 // Needed for getUndoManager()
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -399,6 +401,97 @@ std::vector 
desktop::jsonToPropertyValuesVector(const char
 return aArguments;
 }
 
+static bool extractLinks(const uno::Reference< container::XNameAccess >& 
xLinks, bool subcontent, OUStringBuffer& jsonText)
+{
+const uno::Sequence< OUString > aNames( xLinks->getElementNames() );
+
+const sal_uLong nLinks = aNames.getLength();
+const OUString* pNames = aNames.getConstArray();
+const OUString aProp_LinkDisplayName( "LinkDisplayName" );
+const OUString aProp_LinkTarget( "com.sun.star.document.LinkTarget" );
+bool bIsTarget = false;
+for( sal_uLong i = 0; i < nLinks; i++ )
+{
+uno::Any aAny;
+OUString aLink( *pNames++ );
+
+bool bError = false;
+try
+{
+aAny = xLinks->getByName( aLink );
+}
+catch(const uno::Exception&)
+{
+// if the name of the target was invalid (like empty headings)
+// no object can be provided
+bError = true;
+}
+if(bError)
+continue;
+
+uno::Reference< beans::XPropertySet > xTarget;
+if( aAny >>= xTarget )
+{
+try
+{
+// get name to display
+aAny = xTarget->getPropertyValue( aProp_LinkDisplayName );
+OUString aDisplayName;
+aAny >>= aDisplayName;
+OUString aStrDisplayname ( 

[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 include/vcl sc/inc sc/source

2022-11-10 Thread Szymon Kłos (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 ++-
 desktop/source/lib/init.cxx |   28 
 include/LibreOfficeKit/LibreOfficeKit.h |6 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |6 ++
 include/vcl/ITiledRenderable.hxx|8 
 sc/inc/docuno.hxx   |3 +++
 sc/source/ui/unoobj/docuno.cxx  |   22 ++
 7 files changed, 75 insertions(+), 1 deletion(-)

New commits:
commit ff9b9944401a594ec4a67bca953b312f3a54e3f8
Author: Szymon Kłos 
AuthorDate: Fri Sep 2 11:35:42 2022 +0200
Commit: Szymon Kłos 
CommitDate: Thu Nov 10 10:16:52 2022 +0100

lok: Introudce getDataArea for Calc

It will share information about real size of a data inside
spreadsheet so we can easily check where data ends in online
side.

Change-Id: I376187a33c5c82d409f559d5cc826a4f36d4252e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139472
Reviewed-by: Gökay ŞATIR 
Tested-by: Jenkins CollaboraOffice 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142503
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 d7089d9243f0..dd84323f6c9b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3623,10 +3623,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(64),
  offsetof(struct _LibreOfficeKitDocumentClass, 
sendContentControlEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), offsetof(struct 
_LibreOfficeKitDocumentClass, getSelectionTypeAndText));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(66), offsetof(struct 
_LibreOfficeKitDocumentClass, getDataArea));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(66), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d4332d5c2926..f4aeaf2760cf 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1020,6 +1020,10 @@ static int doc_getTileMode(LibreOfficeKitDocument* 
pThis);
 static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
 long* pWidth,
 long* pHeight);
+static void doc_getDataArea(LibreOfficeKitDocument* pThis,
+long nTab,
+long* pCol,
+long* pRow);
 static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
const char* pArguments);
 
@@ -1272,6 +1276,7 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference 
 xC
 m_pDocumentClass->paintPartTile = doc_paintPartTile;
 m_pDocumentClass->getTileMode = doc_getTileMode;
 m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
+m_pDocumentClass->getDataArea = doc_getDataArea;
 m_pDocumentClass->initializeForRendering = doc_initializeForRendering;
 m_pDocumentClass->registerCallback = doc_registerCallback;
 m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
@@ -3919,6 +3924,29 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* 
pThis,
 }
 }
 
+static void doc_getDataArea(LibreOfficeKitDocument* pThis,
+long nTab,
+long* pCol,
+long* pRow)
+{
+comphelper::ProfileZone aZone("doc_getDataArea");
+
+SolarMutexGuard aGuard;
+SetLastExceptionMsg();
+
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (pDoc)
+{
+Size aDocumentSize = pDoc->getDataArea(nTab);
+*pCol = aDocumentSize.Width();
+*pRow = aDocumentSize.Height();
+}
+else
+{
+SetLastExceptionMsg("Document doesn't support tiled rendering");
+}
+}
+
 static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
const char* pArguments)
 {
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 3a706ba47091..2f57f744e1d4 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -483,6 +483,12 @@ struct _LibreOfficeKitDocumentClass
 char** pText,
 char** pUsedMimeType);
 
+/// @see lok::Document::getDataArea().
+void (*getDataArea) (LibreOfficeKitDocument* pThis,
+ long nPart,
+ long* pCol,
+ long* pRow);
+
 #endif // 

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

2022-09-05 Thread jsala (via logerrit)
 desktop/qa/deployment_misc/test_dp_version.cxx|2 +-
 desktop/source/app/officeipcthread.cxx|   12 ++--
 desktop/source/deployment/manager/dp_extensionmanager.cxx |2 +-
 desktop/source/deployment/misc/dp_misc.cxx|2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit 8dc57426c3bd3385c30b9007991af8496b315f9a
Author: jsala 
AuthorDate: Fri Jun 24 18:46:25 2022 +0200
Commit: Hossein 
CommitDate: Mon Sep 5 18:57:53 2022 +0200

tdf#147021 Use std::size() instead of SAL_N_ELEMENTS() macro

Also change some integer by std::size_t

Change-Id: Ia51b27bb99b8adda576394f9331345cb11149d6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137274
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/desktop/qa/deployment_misc/test_dp_version.cxx 
b/desktop/qa/deployment_misc/test_dp_version.cxx
index e896686865be..1b8fb9086769 100644
--- a/desktop/qa/deployment_misc/test_dp_version.cxx
+++ b/desktop/qa/deployment_misc/test_dp_version.cxx
@@ -60,7 +60,7 @@ void Test::test() {
   OUString("9223372036854775807"),
   ::dp_misc::GREATER }
 };
-for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
+for (std::size_t i = 0; i < std::size(data); ++i) {
 CPPUNIT_ASSERT_EQUAL(
 data[i].order,
 ::dp_misc::compareVersions(data[i].version1, data[i].version2));
diff --git a/desktop/source/app/officeipcthread.cxx 
b/desktop/source/app/officeipcthread.cxx
index e559f7253e53..6e3e97b06d19 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -72,7 +72,7 @@ char const PROCESSING_DONE[] = "InternalIPC::ProcessingDone";
 OString readStringFromPipe(osl::StreamPipe const & pipe) {
 for (OStringBuffer str;;) {
 char buf[1024];
-sal_Int32 n = pipe.recv(buf, SAL_N_ELEMENTS(buf));
+sal_Int32 n = pipe.recv(buf, std::size(buf));
 if (n <= 0) {
 SAL_INFO("desktop.app", "read empty string");
 return "";
@@ -1154,10 +1154,10 @@ void PipeIpcThread::execute()
 
 // notify client we're ready to process its args:
 SAL_INFO("desktop.app", "writing <" << SEND_ARGUMENTS << ">");
-sal_Int32 n = aStreamPipe.write(
-SEND_ARGUMENTS, SAL_N_ELEMENTS(SEND_ARGUMENTS));
+std::size_t n = aStreamPipe.write(
+SEND_ARGUMENTS, std::size(SEND_ARGUMENTS));
 // incl. terminating NUL
-if (n != SAL_N_ELEMENTS(SEND_ARGUMENTS)) {
+if (n != std::size(SEND_ARGUMENTS)) {
 SAL_WARN("desktop.app", "short write: " << n);
 continue;
 }
@@ -1186,9 +1186,9 @@ void PipeIpcThread::execute()
 {
 // processing finished, inform the requesting end:
 SAL_INFO("desktop.app", "writing <" << PROCESSING_DONE << ">");
-n = aStreamPipe.write(PROCESSING_DONE, 
SAL_N_ELEMENTS(PROCESSING_DONE));
+n = aStreamPipe.write(PROCESSING_DONE, 
std::size(PROCESSING_DONE));
 // incl. terminating NUL
-if (n != SAL_N_ELEMENTS(PROCESSING_DONE))
+if (n != std::size(PROCESSING_DONE))
 {
 SAL_WARN("desktop.app", "short write: " << n);
 continue;
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx 
b/desktop/source/deployment/manager/dp_extensionmanager.cxx
index fc7816f6a4c6..44bd4648eff0 100644
--- a/desktop/source/deployment/manager/dp_extensionmanager.cxx
+++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx
@@ -296,7 +296,7 @@ std::vector >
 std::vector > extensionList;
 Reference lRepos[] = {
   getUserRepository(), getSharedRepository(), getBundledRepository() };
-for (int i(0); i != SAL_N_ELEMENTS(lRepos); ++i)
+for (std::size_t i(0); i != std::size(lRepos); ++i)
 {
 Reference xPackage;
 try
diff --git a/desktop/source/deployment/misc/dp_misc.cxx 
b/desktop/source/deployment/misc/dp_misc.cxx
index f4437711dab5..df94e958292b 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -416,7 +416,7 @@ OUString generateRandomPipeId()
 throw RuntimeException( "cannot create random pool!?", nullptr );
 sal_uInt8 bytes[ 32 ];
 if (rtl_random_getBytes(
-s_hPool, bytes, SAL_N_ELEMENTS(bytes) ) != rtl_Random_E_None) {
+s_hPool, bytes, std::size(bytes) ) != rtl_Random_E_None) {
 throw RuntimeException( "random pool error!?", nullptr );
 }
 OUStringBuffer buf;


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

2022-05-31 Thread Luboš Luňák (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx  |9 +++
 desktop/source/lib/init.cxx  |   62 ++-
 include/LibreOfficeKit/LibreOfficeKit.h  |7 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx|   27 +++
 include/LibreOfficeKit/LibreOfficeKitEnums.h |2 
 5 files changed, 104 insertions(+), 3 deletions(-)

New commits:
commit e4842a4c520c68813f0567d34ad321de11c4f1c3
Author: Luboš Luňák 
AuthorDate: Thu May 19 09:15:46 2022 +0200
Commit: Luboš Luňák 
CommitDate: Tue May 31 17:03:02 2022 +0200

lok: add more efficient getSelectionType() replacement

The getSelectionType() function usually needs to be followed by a call
to getTextSelection(), which means having them as two functions
leads to duplicating to a number of calls, some of which may be
somewhat expensive (pDoc->getSelection() e.g. for Calc builds
another ScDocument for the selection, and then getFromTransferrable()
converts that to the given format).

Change-Id: Ib0a8844701d80eaaff4834dcd3633c09d6b921b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134603
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index f2fd0ab16173..54440df9266b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3040,12 +3040,16 @@ void DesktopLOKTest::testComplexSelection()
 
 // Certainly not complex.
 CPPUNIT_ASSERT_EQUAL(static_cast(LOK_SELTYPE_NONE), 
pDocument->pClass->getSelectionType(pDocument));
+CPPUNIT_ASSERT_EQUAL(static_cast(LOK_SELTYPE_NONE), 
pDocument->pClass->getSelectionTypeAndText(pDocument,
+ "", nullptr, 
nullptr));
 
 // Paste text.
 CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, 
"text/plain;charset=utf-8", aText.getStr(), aText.getLength()));
 
 // No selection.
 CPPUNIT_ASSERT_EQUAL(static_cast(LOK_SELTYPE_NONE), 
pDocument->pClass->getSelectionType(pDocument));
+CPPUNIT_ASSERT_EQUAL(static_cast(LOK_SELTYPE_NONE), 
pDocument->pClass->getSelectionTypeAndText(pDocument,
+ "", nullptr, 
nullptr));
 
 // Paste an image.
 OUString aFileURL;
@@ -3080,6 +3084,8 @@ void DesktopLOKTest::testComplexSelection()
 
 // We expect this to be complex.
 CPPUNIT_ASSERT_EQUAL(static_cast(LOK_SELTYPE_COMPLEX), 
pDocument->pClass->getSelectionType(pDocument));
+CPPUNIT_ASSERT_EQUAL(static_cast(LOK_SELTYPE_COMPLEX), 
pDocument->pClass->getSelectionTypeAndText(pDocument,
+ "", nullptr, 
nullptr));
 }
 
 void DesktopLOKTest::testCalcSaveAs()
@@ -3633,10 +3639,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(63), offsetof(struct 
_LibreOfficeKitDocumentClass, renderSearchResult));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(64),
  offsetof(struct _LibreOfficeKitDocumentClass, 
sendContentControlEvent));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), offsetof(struct 
_LibreOfficeKitDocumentClass, getSelectionTypeAndText));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(66), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e8bb8b44f6bf..ec97510b40e4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1048,6 +1048,10 @@ static char* 
doc_getTextSelection(LibreOfficeKitDocument* pThis,
   const char* pMimeType,
   char** pUsedMimeType);
 static int doc_getSelectionType(LibreOfficeKitDocument* pThis);
+static int doc_getSelectionTypeAndText(LibreOfficeKitDocument* pThis,
+   const char* pMimeType,
+   char** pText,
+   char** pUsedMimeType);
 static int doc_getClipboard (LibreOfficeKitDocument* pThis,
  const char **pMimeTypes,
  size_t  *pOutCount,
@@ -1242,6 +1246,7 @@ LibLODocument_Impl::LibLODocument_Impl(const 
uno::Reference setWindowTextSelection = doc_setWindowTextSelection;
 m_pDocumentClass->getTextSelection = doc_getTextSelection;
 m_pDocumentClass->getSelectionType = doc_getSelectionType;
+m_pDocumentClass->getSelectionTypeAndText = 
doc_getSelectionTypeAndText;
 m_pDocumentClass->getClipboard = doc_getClipboard;
 m_pDocumentClass->setClipboard = doc_setClipboard;
  

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/vcl libreofficekit/qa libreofficekit/source sw/inc sw/qa sw/source tools/qa

2022-05-13 Thread Miklos Vajna (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 
 desktop/source/lib/init.cxx |   32 
 include/LibreOfficeKit/LibreOfficeKit.h |3 
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   19 ++
 include/LibreOfficeKit/LibreOfficeKitGtk.h  |7 
 include/vcl/ITiledRenderable.hxx|6 
 libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx |2 
 libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx |   30 +++
 libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx |1 
 libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx   |4 
 libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.hxx   |1 
 libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx|   16 ++
 libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.hxx|2 
 libreofficekit/qa/gtktiledviewer/gtv.ui |   18 ++
 libreofficekit/source/gtk/lokdocview.cxx|   27 ++-
 sw/inc/unotxdoc.hxx |3 
 sw/qa/extras/tiledrendering/tiledrendering.cxx  |   77 
++
 sw/source/core/crsr/viscrs.cxx  |   10 +
 sw/source/uibase/uno/unotxdoc.cxx   |   46 
+
 tools/qa/cppunit/test_json_writer.cxx   |   17 ++
 20 files changed, 319 insertions(+), 6 deletions(-)

New commits:
commit c7d80d229a5660a0ee702477bfbd2ca137992a7d
Author: Miklos Vajna 
AuthorDate: Fri May 13 08:26:32 2022 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 13 09:10:25 2022 +0200

sw content controls, dropdown: add LOK API

- expose the available list items in a new "items" key of the
  LOK_CALLBACK_CONTENT_CONTROL callback

- add a new lok::Document::sendContentControlEvent() function to be able
  to select a list item from the current drop-down

- add a new listbox to the gtktiledviewer toolbar to select a content
  control list item when the cursor is inside a dropdown

- add tests for the array API of tools::JsonWriter

Change-Id: I47f1333a7815d67952f7c20a9cba1b248886f6dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134256
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 038ea2db6aca..f2fd0ab16173 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3631,10 +3631,12 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), offsetof(struct 
_LibreOfficeKitDocumentClass, sendFormFieldEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(62), offsetof(struct 
_LibreOfficeKitDocumentClass, setBlockedCommandList));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(63), offsetof(struct 
_LibreOfficeKitDocumentClass, renderSearchResult));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(64),
+ offsetof(struct _LibreOfficeKitDocumentClass, 
sendContentControlEvent));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(64), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 50ae3a5da400..45f059a73d7d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1143,6 +1143,8 @@ static bool 
doc_renderSearchResult(LibreOfficeKitDocument* pThis,
  const char* pSearchResult, unsigned char** 
pBitmapBuffer,
  int* pWidth, int* pHeight, size_t* pByteSize);
 
+static void doc_sendContentControlEvent(LibreOfficeKitDocument* pThis, const 
char* pArguments);
+
 } // extern "C"
 
 namespace {
@@ -1286,6 +1288,8 @@ LibLODocument_Impl::LibLODocument_Impl(const 
uno::Reference setBlockedCommandList = doc_setBlockedCommandList;
 
+m_pDocumentClass->sendContentControlEvent = 
doc_sendContentControlEvent;
+
 gDocumentClass = m_pDocumentClass;
 }
 pClass = m_pDocumentClass.get();
@@ -6070,6 +6074,34 @@ static bool 
doc_renderSearchResult(LibreOfficeKitDocument* pThis,
 return true;
 }
 
+static void doc_sendContentControlEvent(LibreOfficeKitDocument* pThis, const 
char* pArguments)
+{
+SolarMutexGuard aGuard;
+
+// Supported in Writer only
+if (doc_getDocumentType(pThis) != LOK_DOCTYPE_TEXT)
+{
+return;
+}
+
+StringMap aMap(jsdialog::jsonToStringMap(pArguments));
+

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

2022-01-26 Thread Miklos Vajna (via logerrit)
 desktop/qa/data/3page.odg   |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   29 
 desktop/source/lib/init.cxx |7 +-
 3 files changed, 35 insertions(+), 1 deletion(-)

New commits:
commit d0451dcf96508bf4d75c8147168f974ad3ebf03f
Author: Miklos Vajna 
AuthorDate: Wed Jan 26 08:38:59 2022 +0100
Commit: Miklos Vajna 
CommitDate: Wed Jan 26 09:31:21 2022 +0100

desktop lok, export options: allow passing through a JSON string as-is

setFormatSpecificFilterData() sets useful defaults, but the PDF export
code has the (sane) behavior of preferring FilterData over
FilterOptions, so in case we explicitly got a JSON string in
FilterOptions to in fact set FilterData, then leave FilterData empty.

Change-Id: I20e8094bf431782fe0f5d68e3ec630e1274e30c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128970
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/desktop/qa/data/3page.odg b/desktop/qa/data/3page.odg
new file mode 100644
index ..1fad913e0493
Binary files /dev/null and b/desktop/qa/data/3page.odg differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 689a406e4a07..76eccc8f4a6d 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if USE_TLS_NSS
 #include 
@@ -159,6 +160,7 @@ public:
 void testSearchAllNotificationsCalc();
 void testPaintTile();
 void testSaveAs();
+void testSaveAsJsonOptions();
 void testSaveAsCalc();
 void testPasteWriter();
 void testPasteWriterJPEG();
@@ -225,6 +227,7 @@ public:
 CPPUNIT_TEST(testSearchAllNotificationsCalc);
 CPPUNIT_TEST(testPaintTile);
 CPPUNIT_TEST(testSaveAs);
+CPPUNIT_TEST(testSaveAsJsonOptions);
 CPPUNIT_TEST(testSaveAsCalc);
 CPPUNIT_TEST(testPasteWriter);
 CPPUNIT_TEST(testPasteWriterJPEG);
@@ -675,6 +678,32 @@ void DesktopLOKTest::testSaveAs()
 CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, 
aTempFile.GetURL().toUtf8().getStr(), "png", nullptr));
 }
 
+void DesktopLOKTest::testSaveAsJsonOptions()
+{
+// Given a document with 3 pages:
+LibLODocument_Impl* pDocument = loadDoc("3page.odg");
+
+// When exporting that document to PDF, skipping the first page:
+utl::TempFile aTempFile;
+aTempFile.EnableKillingFile();
+OString aOptions("{\"PageRange\":{\"type\":\"string\",\"value\":\"2-\"}}");
+CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, 
aTempFile.GetURL().toUtf8().getStr(), "pdf", aOptions.getStr()));
+
+// Then make sure the resulting PDF has 2 pages:
+SvFileStream aFile(aTempFile.GetURL(), StreamMode::READ);
+SvMemoryStream aMemory;
+aMemory.WriteStream(aFile);
+std::shared_ptr pPDFium = vcl::pdf::PDFiumLibrary::get();
+std::unique_ptr pPdfDocument
+= pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize());
+CPPUNIT_ASSERT(pPdfDocument);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 2
+// - Actual  : 3
+// i.e. FilterOptions was ignored.
+CPPUNIT_ASSERT_EQUAL(2, pPdfDocument->getPageCount());
+}
+
 void DesktopLOKTest::testSaveAsCalc()
 {
 LibLODocument_Impl* pDocument = loadDoc("search.ods");
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index dfbf503b269f..f9b1d3e0ea96 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2897,7 +2897,12 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, 
const char* sUrl, const cha
 
 comphelper::SequenceAsHashMap aFilterDataMap;
 
-setFormatSpecificFilterData(sFormat, aFilterDataMap);
+// If filter options is JSON string, then make sure aFilterDataMap 
stays empty, otherwise we
+// would ignore the filter options.
+if (!aFilterOptions.startsWith("{"))
+{
+setFormatSpecificFilterData(sFormat, aFilterDataMap);
+}
 
 if (!watermarkText.isEmpty())
 aFilterDataMap["TiledWatermark"] <<= watermarkText;


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

2021-10-30 Thread Mike Kaganski (via logerrit)
 desktop/qa/unit/desktop-lok-init.cxx  |   44 
+++
 desktop/source/app/app.cxx|4 
 desktop/source/app/appinit.cxx|   10 -
 desktop/source/app/check_ext_deps.cxx |6 
 desktop/source/app/dispatchwatcher.cxx|   62 
--
 desktop/source/app/opencl.cxx |6 
 desktop/source/deployment/gui/dp_gui_updatedialog.cxx |   27 
+---
 desktop/source/deployment/manager/dp_extensionmanager.cxx |3 
 desktop/source/deployment/manager/dp_informationprovider.cxx  |8 -
 desktop/source/deployment/misc/dp_dependencies.cxx|3 
 desktop/source/deployment/misc/dp_descriptioninfoset.cxx  |3 
 desktop/source/deployment/registry/component/dp_component.cxx |   10 -
 desktop/source/deployment/registry/configuration/dp_configuration.cxx |5 
 desktop/source/deployment/registry/dp_registry.cxx|7 -
 desktop/source/deployment/registry/help/dp_help.cxx   |3 
 desktop/source/deployment/registry/package/dp_package.cxx |   19 
+--
 desktop/source/deployment/registry/script/dp_script.cxx   |5 
 desktop/source/lib/init.cxx   |   23 
+--
 desktop/source/lib/lokclipboard.cxx   |7 -
 desktop/source/migration/migration.cxx|   22 
++-
 20 files changed, 120 insertions(+), 157 deletions(-)

New commits:
commit 471f5ab323c5676ca22358ca67f4e6820b7e071c
Author: Mike Kaganski 
AuthorDate: Fri Oct 29 09:27:05 2021 +0300
Commit: Mike Kaganski 
CommitDate: Sat Oct 30 17:39:47 2021 +0200

Prepare for removal of non-const operator[] from Sequence in desktop

Change-Id: I76959f62d46e12d984fe4c7be74e5857399e9126
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124358
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/desktop/qa/unit/desktop-lok-init.cxx 
b/desktop/qa/unit/desktop-lok-init.cxx
index 7e6e266cf899..49971afc2e5c 100644
--- a/desktop/qa/unit/desktop-lok-init.cxx
+++ b/desktop/qa/unit/desktop-lok-init.cxx
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -61,9 +62,7 @@ void LOKInitTest::testJsonToPropertyValues()
  "\"value\":\"something.odt\""
  "}}";
 
-uno::Sequence aArgs(1);
-aArgs[0].Name = "FileName";
-aArgs[0].Value <<= OUString("something.odt");
+uno::Sequence aArgs{ comphelper::makePropertyValue("FileName", 
OUString("something.odt")) };
 
 assertSequencesEqual(
 aArgs, 
comphelper::containerToSequence(desktop::jsonToPropertyValuesVector(arguments)));
@@ -129,31 +128,26 @@ void LOKInitTest::testJsonToPropertyValuesBorder()
   "}}";
 
 // see SvxBoxItem::QueryValue for details
-uno::Sequence aOuterSeq(9);
 table::BorderLine2 aLine(sal_Int32(COL_BLACK), 0, 1, 0, 
table::BorderLineStyle::SOLID, 1);
-aOuterSeq[0] <<= aLine; // left
-aOuterSeq[1] <<= aLine; // right
-aOuterSeq[2] <<= aLine; // bottom
-aOuterSeq[3] <<= aLine; // top
-aOuterSeq[4] <<= static_cast(0);
-aOuterSeq[5] <<= static_cast(0);
-aOuterSeq[6] <<= static_cast(0);
-aOuterSeq[7] <<= static_cast(0);
-aOuterSeq[8] <<= static_cast(0);
+uno::Sequence aOuterSeq{ uno::Any(aLine), // left
+   uno::Any(aLine), // right
+   uno::Any(aLine), // bottom
+   uno::Any(aLine), // top
+   uno::Any(static_cast(0)),
+   uno::Any(static_cast(0)),
+   uno::Any(static_cast(0)),
+   uno::Any(static_cast(0)),
+   uno::Any(static_cast(0)) };
 
 // see SvxBoxInfoItem::QueryValue() for details
-uno::Sequence aInnerSeq(5);
-aInnerSeq[0] <<= aLine; // horizontal
-aInnerSeq[1] <<= aLine; // vertical
-aInnerSeq[2] <<= static_cast(0);
-aInnerSeq[3] <<= static_cast(0x7F);
-aInnerSeq[4] <<= static_cast(0);
-
-uno::Sequence aArgs(2);
-aArgs[0].Name = "OuterBorder";
-aArgs[0].Value <<= aOuterSeq;
-aArgs[1].Name = "InnerBorder";
-aArgs[1].Value <<= aInnerSeq;
+uno::Sequence aInnerSeq{ uno::Any(aLine), // horizontal
+   uno::Any(aLine), // vertical
+   uno::Any(static_cast(0)),
+   uno::Any(static_cast(0x7F)),
+   uno::Any(static_cast(0)) };
+
+uno::Sequence aArgs{ comphelper::makePropertyValue("OuterBorder", 

[Libreoffice-commits] core.git: desktop/qa desktop/source sw/inc sw/source test/source

2021-10-25 Thread Luboš Luňák (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   12 
 desktop/source/lib/init.cxx |   56 +-
 sw/inc/viscrs.hxx   |2 
 sw/source/core/crsr/viscrs.cxx  |   70 ++--
 sw/source/uibase/uiview/viewsrch.cxx|4 -
 sw/source/uibase/wrtsh/wrtsh4.cxx   |5 ++
 test/source/lokcallback.cxx |2 
 7 files changed, 121 insertions(+), 30 deletions(-)

New commits:
commit 4bb6533d398cc76d7ff292a9e47dae87fac74f83
Author: Luboš Luňák 
AuthorDate: Thu Oct 7 18:02:12 2021 +0200
Commit: Luboš Luňák 
CommitDate: Mon Oct 25 19:30:34 2021 +0200

use pull model also for LOK text selection

Make LOK_CALLBACK_TEXT_SELECTION, LOK_CALLBACK_TEXT_SELECTION_START,
LOK_CALLBACK_TEXT_SELECTION_END and LOK_CALLBACK_TEXT_VIEW_SELECTION
also use pull model, i.e. LO core will only set a flag and when
CallbackFlushHandler needs the actual data it'll use getLOKPayload().
This again avoids a large number of messages passed to
CallbackFlushHandler only for them to be sooner or later discarded.

Change-Id: Ia7528039be996a6e9e8491b4eba3f4133582fa56
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124146
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index cfa8e039a5d0..1144a5e48369 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1545,6 +1545,7 @@ void DesktopLOKTest::testNotificationCompression()
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
 std::vector> notifs;
 std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
+handler->setViewId(SfxLokHelper::getView());
 
 handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // 0
 handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15, 25, 15, 10"); // 
Superseded.
@@ -1640,6 +1641,7 @@ void DesktopLOKTest::testTileInvalidationCompression()
 {
 std::vector> notifs;
 std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
+handler->setViewId(SfxLokHelper::getView());
 
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
@@ -1660,6 +1662,7 @@ void DesktopLOKTest::testTileInvalidationCompression()
 {
 std::vector> notifs;
 std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
+handler->setViewId(SfxLokHelper::getView());
 
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 1"); // 
Different part
@@ -1683,6 +1686,7 @@ void DesktopLOKTest::testTileInvalidationCompression()
 {
 std::vector> notifs;
 std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
+handler->setViewId(SfxLokHelper::getView());
 
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0"); // 0
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 1"); // 
1: Different part
@@ -1709,6 +1713,7 @@ void DesktopLOKTest::testTileInvalidationCompression()
 {
 std::vector> notifs;
 std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
+handler->setViewId(SfxLokHelper::getView());
 
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 0"); // 0
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 100, 100, 1"); // 
1: Different part
@@ -1744,6 +1749,7 @@ void DesktopLOKTest::testTileInvalidationCompression()
 {
 std::vector> notifs;
 std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
+handler->setViewId(SfxLokHelper::getView());
 
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "EMPTY, 0");
@@ -1768,6 +1774,7 @@ void DesktopLOKTest::testPartInInvalidation()
 {
 std::vector> notifs;
 std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
+handler->setViewId(SfxLokHelper::getView());
 
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10");
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10");
@@ -1783,6 +1790,7 @@ void DesktopLOKTest::testPartInInvalidation()
 {
 std::vector> notifs;
 std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
+handler->setViewId(SfxLokHelper::getView());
 
 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10");
 

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/vcl sw/inc sw/source

2021-07-30 Thread Tomaž Vajngerl (via logerrit)
 desktop/qa/data/SearchIndexResultTest.odt   |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   49 +++-
 desktop/source/lib/init.cxx |   57 
 include/LibreOfficeKit/LibreOfficeKit.h |6 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   16 +++
 include/vcl/ITiledRenderable.hxx|9 
 sw/inc/unotxdoc.hxx |3 +
 sw/source/uibase/uno/unotxdoc.cxx   |   25 
 8 files changed, 164 insertions(+), 1 deletion(-)

New commits:
commit e1511ce551f27a5560600029193f076fd65ece17
Author: Tomaž Vajngerl 
AuthorDate: Fri Jul 9 14:41:21 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Jul 30 08:22:19 2021 +0200

indexing: add LOKit API to render the search result into a bitmap

This adds a new LOKit API to render the search result into a bitmap
buffer. It combines the SearchResultLocator to get the location
inside the document of the search result (a series of rectangles)
and the existing LOKit paintTile API to render the result into
a bitmap (byte) buffer.

It also adds a LOKit test to show how the API is used and to render
a search result of a example document.

Change-Id: I4284d90188777fd28158d029daa04151e71022bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118670
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/desktop/qa/data/SearchIndexResultTest.odt 
b/desktop/qa/data/SearchIndexResultTest.odt
new file mode 100644
index ..58ed3a0f5447
Binary files /dev/null and b/desktop/qa/data/SearchIndexResultTest.odt differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2a26b04dcfa0..dfbee77167b8 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -59,6 +59,8 @@
 #include 
 
 #include 
+#include 
+#include 
 
 #if USE_TLS_NSS
 #include 
@@ -205,6 +207,7 @@ public:
 void testMetricField();
 void testMultiDocuments();
 void testJumpCursor();
+void testRenderSearchResult();
 void testABI();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
@@ -268,6 +271,7 @@ public:
 CPPUNIT_TEST(testMetricField);
 CPPUNIT_TEST(testMultiDocuments);
 CPPUNIT_TEST(testJumpCursor);
+CPPUNIT_TEST(testRenderSearchResult);
 CPPUNIT_TEST(testABI);
 CPPUNIT_TEST_SUITE_END();
 
@@ -3103,6 +3107,48 @@ void DesktopLOKTest::testJumpCursor()
 comphelper::LibreOfficeKit::setTiledAnnotations(true);
 }
 
+void DesktopLOKTest::testRenderSearchResult()
+{
+constexpr const bool bDumpBitmap = false;
+
+LibLODocument_Impl* pDocument = loadDoc("SearchIndexResultTest.odt");
+pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+
+Scheduler::ProcessEventsToIdle();
+
+unsigned char* pBuffer = nullptr;
+OString aJSON = "{ \"node_index\" : 19 }";
+
+int nWidth = 0;
+int nHeight = 0;
+size_t nByteSize = 0;
+
+bool bResult = pDocument->m_pDocumentClass->renderSearchResult(pDocument, 
aJSON.getStr(), , , , );
+
+CPPUNIT_ASSERT(bResult);
+CPPUNIT_ASSERT(pBuffer);
+
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(642, nWidth);
+CPPUNIT_ASSERT_EQUAL(561, nHeight);
+CPPUNIT_ASSERT_EQUAL(size_t(1440648), nByteSize);
+
+const sal_uInt8* pD = reinterpret_cast(pBuffer);
+BitmapEx aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth 
* 4, vcl::PixelFormat::N32_BPP, true, true);
+
+if (bDumpBitmap)
+{
+SvFileStream aStream("~/SearchResultBitmap.png", StreamMode::WRITE | 
StreamMode::TRUNC);
+vcl::PNGWriter aPNGWriter(aBitmap);
+aPNGWriter.Write(aStream);
+}
+CPPUNIT_ASSERT_EQUAL(tools::Long(642), aBitmap.GetSizePixel().Width());
+CPPUNIT_ASSERT_EQUAL(tools::Long(561), aBitmap.GetSizePixel().Height());
+
+std::free(pBuffer);
+}
+
 namespace {
 
 constexpr size_t classOffset(int i)
@@ -3200,10 +3246,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), offsetof(struct 
_LibreOfficeKitDocumentClass, completeFunction));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), offsetof(struct 
_LibreOfficeKitDocumentClass, setWindowTextSelection));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), offsetof(struct 
_LibreOfficeKitDocumentClass, sendFormFieldEvent));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(62), offsetof(struct 
_LibreOfficeKitDocumentClass, renderSearchResult));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(62), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(63), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 

[Libreoffice-commits] core.git: desktop/qa desktop/source include/tools include/vcl sc/inc sc/qa sc/source sd/source sw/inc sw/qa sw/source tools/qa tools/source

2020-06-20 Thread Noel Grandin (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx|4 
 desktop/source/lib/init.cxx|   32 ++--
 include/tools/json_writer.hxx  |   65 +++-
 include/vcl/ITiledRenderable.hxx   |   18 --
 sc/inc/docuno.hxx  |8 -
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   29 +++
 sc/source/ui/inc/tabview.hxx   |3 
 sc/source/ui/unoobj/docuno.cxx |   70 +++--
 sc/source/ui/view/tabview.cxx  |  183 -
 sd/source/ui/inc/unomodel.hxx  |2 
 sd/source/ui/unoidl/unomodel.cxx   |   26 +--
 sw/inc/swmodule.hxx|3 
 sw/inc/unotxdoc.hxx|6 
 sw/qa/extras/tiledrendering/tiledrendering.cxx |6 
 sw/qa/extras/uiwriter/uiwriter2.cxx|8 -
 sw/qa/extras/uiwriter/uiwriter3.cxx|8 -
 sw/source/uibase/app/swmodul1.cxx  |   26 ---
 sw/source/uibase/inc/swruler.hxx   |3 
 sw/source/uibase/misc/swruler.cxx  |   47 ++
 sw/source/uibase/uno/unotxdoc.cxx  |   39 ++---
 tools/qa/cppunit/test_json_writer.cxx  |   38 -
 tools/source/misc/json_writer.cxx  |  117 ++-
 22 files changed, 444 insertions(+), 297 deletions(-)

New commits:
commit cb95276e6e6bf12a1c06d5c252551e55c788fcb2
Author: Noel Grandin 
AuthorDate: Thu Jun 18 21:39:30 2020 +0200
Commit: Noel Grandin 
CommitDate: Sat Jun 20 21:25:11 2020 +0200

use JsonWriter for the rest of ITiledRenderable

and fix bug in buffer reallacotion where mPos pointing
at the beginning of the new buffer instead of at the
correct index inside it.

Change-Id: Ie1ffaa176f6165e2cec85c93adc945312eff38e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96650
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 8a651ab764da..8e02686f7f57 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -818,11 +818,13 @@ void DesktopLOKTest::testHiddenRowHeaders()
 
 boost::property_tree::ptree aTree;
 char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, 
aPayload.str().c_str());
+SAL_WARN("desktop", "xxx " << pJSON);
 std::stringstream aStream(pJSON);
-free(pJSON);
+SAL_WARN("desktop", aStream.str());
 CPPUNIT_ASSERT(!aStream.str().empty());
 
 boost::property_tree::read_json(aStream, aTree);
+free(pJSON);
 sal_Int32 nPrevious = 0;
 sal_Int32 nIndex = 0;
 for (const boost::property_tree::ptree::value_type& rValue : 
aTree.get_child("rows"))
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 357111d220af..a9202a0c90b5 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3303,8 +3303,9 @@ static char* getPostIts(LibreOfficeKitDocument* pThis)
 SetLastExceptionMsg("Document doesn't support tiled rendering");
 return nullptr;
 }
-OUString aComments = pDoc->getPostIts();
-return strdup(aComments.toUtf8().getStr());
+tools::JsonWriter aJsonWriter;
+pDoc->getPostIts(aJsonWriter);
+return aJsonWriter.extractData();
 }
 
 /// Returns the JSON representation of the positions of all the comments in 
the document
@@ -3317,8 +3318,9 @@ static char* getPostItsPos(LibreOfficeKitDocument* pThis)
 SetLastExceptionMsg("Document doesn't support tiled rendering");
 return nullptr;
 }
-OUString aComments = pDoc->getPostItsPos();
-return strdup(aComments.toUtf8().getStr());
+tools::JsonWriter aJsonWriter;
+pDoc->getPostItsPos(aJsonWriter);
+return aJsonWriter.extractData();
 }
 
 static char* getRulerState(LibreOfficeKitDocument* pThis)
@@ -3330,8 +3332,9 @@ static char* getRulerState(LibreOfficeKitDocument* pThis)
 SetLastExceptionMsg("Document doesn't support tiled rendering");
 return nullptr;
 }
-OUString state = pDoc->getRulerState();
-return strdup(state.toUtf8().getStr());
+tools::JsonWriter aJsonWriter;
+pDoc->getRulerState(aJsonWriter);
+return aJsonWriter.extractData();
 }
 
 static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int 
nCharCode, int nKeyCode)
@@ -4781,8 +4784,9 @@ static char* 
getTrackedChangeAuthors(LibreOfficeKitDocument* pThis)
 SetLastExceptionMsg("Document doesn't support tiled rendering");
 return nullptr;
 }
-OUString aAuthors = pDoc->getTrackedChangeAuthors();
-return strdup(aAuthors.toUtf8().getStr());
+tools::JsonWriter aJsonWriter;
+pDoc->getTrackedChangeAuthors(aJsonWriter);
+return aJsonWriter.extractData();
 }
 
 static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* 
pCommand)
@@ -4885,11 +4889,9 @@ 

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/vcl sw/inc sw/source

2020-05-08 Thread Tamás Zolnai (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 +-
 desktop/source/lib/init.cxx |   33 +
 include/LibreOfficeKit/LibreOfficeKit.h |4 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   10 +++
 include/vcl/ITiledRenderable.hxx|   11 
 sw/inc/unotxdoc.hxx |3 ++
 sw/source/uibase/uno/unotxdoc.cxx   |   36 
 7 files changed, 99 insertions(+), 1 deletion(-)

New commits:
commit 36508d0110248f6683757602cd1668547dbfb253
Author: Tamás Zolnai 
AuthorDate: Wed May 6 14:33:10 2020 +0200
Commit: Tamás Zolnai 
CommitDate: Fri May 8 22:42:35 2020 +0200

lok: MSForms: Handle event about item selection of a drop-down field.

Change-Id: I095013097348c98361b6614e4ddf1e9029923c7f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93659
Tested-by: Tamás Zolnai 
Reviewed-by: Tamás Zolnai 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3344279f1a78..30dd2c60dc3c 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2923,10 +2923,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), offsetof(struct 
_LibreOfficeKitDocumentClass, paintWindowForView));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), offsetof(struct 
_LibreOfficeKitDocumentClass, completeFunction));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), offsetof(struct 
_LibreOfficeKitDocumentClass, setWindowTextSelection));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), offsetof(struct 
_LibreOfficeKitDocumentClass, sendFormFieldEvent));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(62), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ccd32a035ff5..c7763b608a28 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1137,6 +1137,10 @@ static void doc_resizeWindow(LibreOfficeKitDocument* 
pThis, unsigned nLOKWindowI
  const int nWidth, const int nHeight);
 
 static void doc_completeFunction(LibreOfficeKitDocument* pThis, int nIndex);
+
+
+static void doc_sendFormFieldEvent(LibreOfficeKitDocument* pThis,
+   const char* pArguments);
 } // extern "C"
 
 namespace {
@@ -1252,6 +1256,8 @@ LibLODocument_Impl::LibLODocument_Impl(const 
uno::Reference createViewWithOptions = doc_createViewWithOptions;
 m_pDocumentClass->completeFunction = doc_completeFunction;
 
+m_pDocumentClass->sendFormFieldEvent = doc_sendFormFieldEvent;
+
 gDocumentClass = m_pDocumentClass;
 }
 pClass = m_pDocumentClass.get();
@@ -5412,6 +5418,33 @@ static void doc_completeFunction(LibreOfficeKitDocument* 
pThis, int nIndex)
 pDoc->completeFunction(nIndex);
 }
 
+
+static void doc_sendFormFieldEvent(LibreOfficeKitDocument* pThis, const char* 
pArguments)
+{
+SolarMutexGuard aGuard;
+
+// Supported in Writer only
+if (doc_getDocumentType(pThis) != LOK_DOCTYPE_TEXT)
+return;
+
+StringMap aMap(jsonToStringMap(pArguments));
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+SetLastExceptionMsg("Document doesn't support tiled rendering!");
+return;
+}
+
+// Sanity check
+if (aMap.find("type") == aMap.end() || aMap.find("cmd") == aMap.end())
+{
+SetLastExceptionMsg("Wrong arguments for sendFormFieldEvent!");
+return;
+}
+
+pDoc->executeFromFieldEvent(aMap);
+}
+
 static char* lo_getError (LibreOfficeKit *pThis)
 {
 comphelper::ProfileZone aZone("lo_getError");
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 6203c11fb044..309744522004 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -446,6 +446,10 @@ struct _LibreOfficeKitDocumentClass
 int nX,
 int nY);
 
+/// @see lok::Document::sendFormFieldEvent
+void (*sendFormFieldEvent) (LibreOfficeKitDocument* pThis,
+const char* pArguments);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 4076637863fd..37eacdfb3649 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -779,6 +779,16 @@ public:
 mpDoc->pClass->setWindowTextSelection(mpDoc, nWindowId, bSwap, nX, nY);
 }
 

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

2020-02-06 Thread Marco Cecchetti (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 +-
 desktop/source/lib/init.cxx |   31 
 include/LibreOfficeKit/LibreOfficeKit.h |7 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   13 +++
 vcl/source/window/seleng.cxx|   11 +
 5 files changed, 63 insertions(+), 2 deletions(-)

New commits:
commit 814c69878b03cd053b53bcc81bbaeee02d416ce7
Author: Marco Cecchetti 
AuthorDate: Thu Feb 6 11:19:32 2020 +0100
Commit: Miklos Vajna 
CommitDate: Thu Feb 6 20:23:40 2020 +0100

lok: calc: formula input bar: set text selection as requested by client

Change-Id: If04ed3c1637249329530a73d20df9b9296d1004e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88089
Reviewed-by: Marco Cecchetti 
Tested-by: Marco Cecchetti 
(cherry picked from commit 01f0d42f5ca9fb0e6e45b7bfcf51cb33c1a27bec)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88117
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 14ecd2bcb196..a582ba764a01 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2902,10 +2902,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), offsetof(struct 
_LibreOfficeKitDocumentClass, renderFontOrientation));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), offsetof(struct 
_LibreOfficeKitDocumentClass, paintWindowForView));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), offsetof(struct 
_LibreOfficeKitDocumentClass, completeFunction));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), offsetof(struct 
_LibreOfficeKitDocumentClass, setWindowTextSelection));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 253ab51d2b29..65698eebbc37 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1037,6 +1037,11 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* 
pThis,
const char* pCommand,
const char* pArguments,
bool bNotifyWhenFinished);
+static void doc_setWindowTextSelection(LibreOfficeKitDocument* pThis,
+   unsigned nLOKWindowId,
+   bool swap,
+   int nX,
+   int nY);
 static void doc_setTextSelection (LibreOfficeKitDocument* pThis,
   int nType,
   int nX,
@@ -1201,6 +1206,7 @@ LibLODocument_Impl::LibLODocument_Impl(const 
uno::Reference sendDialogEvent = doc_sendDialogEvent;
 m_pDocumentClass->postUnoCommand = doc_postUnoCommand;
 m_pDocumentClass->setTextSelection = doc_setTextSelection;
+m_pDocumentClass->setWindowTextSelection = doc_setWindowTextSelection;
 m_pDocumentClass->getTextSelection = doc_getTextSelection;
 m_pDocumentClass->getSelectionType = doc_getSelectionType;
 m_pDocumentClass->getClipboard = doc_getClipboard;
@@ -3881,6 +3887,31 @@ static void doc_setTextSelection(LibreOfficeKitDocument* 
pThis, int nType, int n
 pDoc->setTextSelection(nType, nX, nY);
 }
 
+static void doc_setWindowTextSelection(LibreOfficeKitDocument* /*pThis*/, 
unsigned nLOKWindowId, bool swap, int nX, int nY)
+{
+comphelper::ProfileZone aZone("doc_setWindowTextSelection");
+
+SolarMutexGuard aGuard;
+SetLastExceptionMsg();
+
+VclPtr pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
+if (!pWindow)
+{
+SetLastExceptionMsg("Document doesn't support dialog rendering, or 
window not found.");
+return;
+}
+
+
+Size aOffset(pWindow->GetOutOffXPixel(), pWindow->GetOutOffYPixel());
+Point aCursorPos(nX, nY);
+aCursorPos.Move(aOffset);
+sal_uInt16 nModifier = swap ? KEY_MOD1 + KEY_MOD2 : KEY_SHIFT;
+
+MouseEvent aCursorEvent(aCursorPos, 1, MouseEventModifiers::SIMPLECLICK, 
0, nModifier);
+Application::PostMouseEvent(VclEventId::WindowMouseButtonDown, pWindow, 
);
+Application::PostMouseEvent(VclEventId::WindowMouseButtonUp, pWindow, 
);
+}
+
 static bool getFromTransferrable(
 const css::uno::Reference ,
 const OString , OString );
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index b4278625ccb0..6203c11fb044 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -439,6 

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/vcl sc/inc sc/source

2019-12-02 Thread Marco Cecchetti (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 ++-
 desktop/source/lib/init.cxx |   17 +
 include/LibreOfficeKit/LibreOfficeKit.h |3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   10 ++
 include/vcl/ITiledRenderable.hxx|5 +
 sc/inc/docuno.hxx   |3 +++
 sc/source/ui/app/inputhdl.cxx   |   16 
 sc/source/ui/inc/inputhdl.hxx   |2 ++
 sc/source/ui/unoobj/docuno.cxx  |   10 ++
 9 files changed, 68 insertions(+), 1 deletion(-)

New commits:
commit e5367efbd15e1d97f8d4de232df1c325d8fff2b8
Author: Marco Cecchetti 
AuthorDate: Wed Nov 27 22:53:38 2019 +0100
Commit: Miklos Vajna 
CommitDate: Tue Dec 3 07:28:36 2019 +0100

lok: formula bar: function completion

lok clients can request to complete a function name partially typed in
the formula input box.

Change-Id: I8771fd4d2a7f79c20138d9183162da23a92f2ba4
Reviewed-on: https://gerrit.libreoffice.org/83984
Reviewed-by: Marco Cecchetti 
Tested-by: Marco Cecchetti 
Reviewed-on: https://gerrit.libreoffice.org/84258
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 08fa6a54ab62..1effbc2669b8 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2751,10 +2751,11 @@ void DesktopLOKTest::testABI()
 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));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), offsetof(struct 
_LibreOfficeKitDocumentClass, completeFunction));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7fb08f0bec15..7ecc9fcdf78b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -933,6 +933,7 @@ static size_t 
doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu
 static void doc_resizeWindow(LibreOfficeKitDocument* pThis, unsigned 
nLOKWindowId,
  const int nWidth, const int nHeight);
 
+static void doc_completeFunction(LibreOfficeKitDocument* pThis, int nIndex);
 } // extern "C"
 
 namespace {
@@ -1044,6 +1045,7 @@ LibLODocument_Impl::LibLODocument_Impl(const 
uno::Reference postWindowGestureEvent = doc_postWindowGestureEvent;
 
 m_pDocumentClass->createViewWithOptions = doc_createViewWithOptions;
+m_pDocumentClass->completeFunction = doc_completeFunction;
 
 gDocumentClass = m_pDocumentClass;
 }
@@ -5144,6 +5146,21 @@ static void doc_resizeWindow(LibreOfficeKitDocument* 
/*pThis*/, unsigned nLOKWin
 pWindow->SetSizePixel(Size(nWidth, nHeight));
 }
 
+static void doc_completeFunction(LibreOfficeKitDocument* pThis, int nIndex)
+{
+SolarMutexGuard aGuard;
+SetLastExceptionMsg();
+
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+SetLastExceptionMsg("Document doesn't support tiled rendering");
+return;
+}
+
+pDoc->completeFunction(nIndex);
+}
+
 static char* lo_getError (LibreOfficeKit *pThis)
 {
 comphelper::ProfileZone aZone("lo_getError");
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index a486886c15de..b4278625ccb0 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -436,6 +436,9 @@ struct _LibreOfficeKitDocumentClass
 const double dpiscale,
 int viewId);
 
+/// @see lok::Document::completeFunction().
+void (*completeFunction) (LibreOfficeKitDocument* pThis, int nIndex);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 318bf943cca9..19f0b2663552 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -757,6 +757,16 @@ public:
 mpDoc->pClass->removeTextContext(mpDoc, nWindowId, nBefore, nAfter);
 }
 
+/**
+ * Select the Calc function to be pasted into the formula input box
+ *
+ * @param nIndex is the index of the selected function
+ */
+void 

[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 filter/source include/LibreOfficeKit

2019-11-10 Thread Mert Tumer (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 +--
 desktop/source/lib/init.cxx |   33 +++-
 filter/source/pdf/pdfexport.cxx |   23 +--
 include/LibreOfficeKit/LibreOfficeKit.h |8 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |8 +-
 5 files changed, 50 insertions(+), 26 deletions(-)

New commits:
commit 7c8450abac77a2e41f1068fb11d19c1c0c93783f
Author: Mert Tumer 
AuthorDate: Thu Oct 24 12:11:21 2019 +0300
Commit: Ashod Nakashian 
CommitDate: Sun Nov 10 22:39:55 2019 +0100

Added Orientation argument to LOKIT renderFont

method for rendering watermarks with angle

Change-Id: Id422ed62e4f78390661e4e1efa45101af9ecfc23
Reviewed-on: https://gerrit.libreoffice.org/81435
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 8200c7e1c859..e6207b2cf98a 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2743,11 +2743,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(54), offsetof(struct 
_LibreOfficeKitDocumentClass, getSelectionType));
 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));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5b5b301cdee9..bc0fd62eb78a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -879,6 +879,12 @@ static int doc_getView(LibreOfficeKitDocument* pThis);
 static int doc_getViewsCount(LibreOfficeKitDocument* pThis);
 static bool doc_getViewIds(LibreOfficeKitDocument* pThis, int* pArray, size_t 
nSize);
 static void doc_setViewLanguage(LibreOfficeKitDocument* pThis, int nId, const 
char* language);
+static unsigned char* doc_renderFontOrientation(LibreOfficeKitDocument* pThis,
+  const char *pFontName,
+  const char *pChar,
+  int* pFontWidth,
+  int* pFontHeight,
+  int pOrientation);
 static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
   const char *pFontName,
   const char *pChar,
@@ -895,7 +901,8 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* 
pThis, unsigned nLOKWindo
const int nWidth, const int nHeight,
const double fDPIScale);
 
-static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned 
nLOKWindowId, int nAction, const char* pData);
+static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned
+ nLOKWindowId, int nAction, const char* pData);
 
 static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart);
 
@@ -1001,6 +1008,7 @@ LibLODocument_Impl::LibLODocument_Impl(const 
uno::Reference getViewIds = doc_getViewIds;
 
 m_pDocumentClass->renderFont = doc_renderFont;
+m_pDocumentClass->renderFontOrientation = doc_renderFontOrientation;
 m_pDocumentClass->getPartHash = doc_getPartHash;
 
 m_pDocumentClass->paintWindow = doc_paintWindow;
@@ -4671,12 +4679,24 @@ static void doc_setViewLanguage(SAL_UNUSED_PARAMETER 
LibreOfficeKitDocument* /*p
 SfxLokHelper::setViewLanguage(nId, OStringToOUString(language, 
RTL_TEXTENCODING_UTF8));
 }
 
-unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* 
/*pThis*/,
+
+
+unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
   const char* pFontName,
   const char* pChar,
   int* pFontWidth,
   int* pFontHeight)
 {
+return doc_renderFontOrientation(pThis, pFontName, pChar, pFontWidth, 
pFontHeight, 0);
+}
+
+unsigned char* doc_renderFontOrientation(SAL_UNUSED_PARAMETER 
LibreOfficeKitDocument* /*pThis*/,
+  const char* pFontName,
+  const char* pChar,
+  int* pFontWidth,
+  int* pFontHeight,
+  int pOrientation)
+{
 comphelper::ProfileZone aZone("doc_renderFont");
 
 SolarMutexGuard aGuard;
@@ -4708,6 +4728,7 @@ 

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

2019-10-15 Thread Szymon Kłos (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 +-
 desktop/source/lib/init.cxx |   45 +++-
 include/LibreOfficeKit/LibreOfficeKit.h |5 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   11 ++
 4 files changed, 63 insertions(+), 2 deletions(-)

New commits:
commit ef433656498ce52b69849915671d4aa34ec59136
Author: Szymon Kłos 
AuthorDate: Fri Oct 11 08:53:14 2019 +0200
Commit: Szymon Kłos 
CommitDate: Tue Oct 15 15:59:07 2019 +0200

jsdialogs: handle dialog events

Change-Id: Icc092cd5b06168d9de8ebed891fc03491865dbad
Reviewed-on: https://gerrit.libreoffice.org/80788
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 5945a3bd378a..49a26253b388 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2742,10 +2742,12 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(53), offsetof(struct 
_LibreOfficeKitDocumentClass, setClipboard));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(54), offsetof(struct 
_LibreOfficeKitDocumentClass, getSelectionType));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(55), offsetof(struct 
_LibreOfficeKitDocumentClass, removeTextContext));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), offsetof(struct 
_LibreOfficeKitDocumentClass, sendDialogEvent));
+
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cd604f939d8b..1790bdbfa478 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -147,6 +147,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -768,7 +769,9 @@ static void doc_removeTextContext(LibreOfficeKitDocument* 
pThis,
   unsigned nLOKWindowId,
   int nCharBefore,
   int nCharAfter);
-
+static void doc_sendDialogEvent(LibreOfficeKitDocument* pThis,
+   unsigned nLOKWindowId,
+   const char* pArguments);
 static void doc_postWindowKeyEvent(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
int nType,
@@ -942,6 +945,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
postWindowKeyEvent = doc_postWindowKeyEvent;
 m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
 m_pDocumentClass->postWindowMouseEvent = doc_postWindowMouseEvent;
+m_pDocumentClass->sendDialogEvent = doc_sendDialogEvent;
 m_pDocumentClass->postUnoCommand = doc_postUnoCommand;
 m_pDocumentClass->setTextSelection = doc_setTextSelection;
 m_pDocumentClass->getTextSelection = doc_getTextSelection;
@@ -3256,6 +3260,45 @@ public:
 virtual void SAL_CALL disposing(const css::lang::EventObject&) override {}
 };
 
+static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned 
nWindowId, const char* pArguments)
+{
+SolarMutexGuard aGuard;
+
+char* pCopy = strdup(pArguments);
+if (!pCopy) {
+SetLastExceptionMsg("String copying error.");
+return;
+}
+
+char* pIdChar = strtok(pCopy, " ");
+
+if (!pIdChar) {
+SetLastExceptionMsg("Error parsing the command.");
+return;
+}
+
+OUString sId = OUString::createFromAscii(pIdChar);
+free(pCopy);
+
+VclPtr pWindow = vcl::Window::FindLOKWindow(nWindowId);
+if (!pWindow)
+{
+SetLastExceptionMsg("Document doesn't support dialog rendering, or 
window not found.");
+return;
+}
+else
+{
+OUString sAction("CLICK");
+WindowUIObject aUIObject(pWindow);
+std::unique_ptr pUIWindow(aUIObject.get_child(sId));
+if (pUIWindow)
+pUIWindow->execute(sAction, StringMap());
+
+// force resend
+pWindow->Resize();
+}
+}
+
 static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* 
pCommand, const char* pArguments, bool bNotifyWhenFinished)
 {
 comphelper::ProfileZone aZone("doc_postUnoCommand");
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 6060b015be01..29d834969ad6 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -414,6 +414,11 @@ struct _LibreOfficeKitDocumentClass
int nBefore,
int nAfter);
 
+/// @see lok::Document::sendDialogEvent
+void 

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

2019-10-01 Thread Marco Cecchetti (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 +
 desktop/source/lib/init.cxx |   44 
 include/LibreOfficeKit/LibreOfficeKit.h |6 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   13 
 include/sfx2/lokhelper.hxx  |2 -
 sfx2/source/view/lokhelper.cxx  |4 +-
 6 files changed, 68 insertions(+), 4 deletions(-)

New commits:
commit 9590e8d0a2194b36d5a025a21dc2e71f37f4f54b
Author: Marco Cecchetti 
AuthorDate: Wed Jul 10 10:32:07 2019 +0200
Commit: Michael Meeks 
CommitDate: Tue Oct 1 10:01:57 2019 +0200

lok: handling a single msg for deleting multiple characters

also includes:

lok: fixing testABI failure
Change-Id: I4df662a0df49a864c4b307efdd963b857bb77792

lok: missing removeTextContext implementation for Document class
Change-Id: I884ad07f330afc19dfe759c08c8a17bdb4f9dcf3

Change-Id: I045d89f9fa478f37fc2917e159e044eee7e1ab31
Reviewed-on: https://gerrit.libreoffice.org/79879
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 93e81b595f65..eb3c713560ee 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2782,10 +2782,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(52), offsetof(struct 
_LibreOfficeKitDocumentClass, getClipboard));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(53), offsetof(struct 
_LibreOfficeKitDocumentClass, setClipboard));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(54), offsetof(struct 
_LibreOfficeKitDocumentClass, getSelectionType));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(55), offsetof(struct 
_LibreOfficeKitDocumentClass, removeTextContext));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(55), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2af356e0bb7b..3b8e7eb128c7 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -764,6 +764,11 @@ static void 
doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis,
 unsigned nWindowId,
 int nType,
 const char* pText);
+static void doc_removeTextContext(LibreOfficeKitDocument* pThis,
+  unsigned nLOKWindowId,
+  int nCharBefore,
+  int nCharAfter);
+
 static void doc_postWindowKeyEvent(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
int nType,
@@ -933,6 +938,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
registerCallback = doc_registerCallback;
 m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
 m_pDocumentClass->postWindowExtTextInputEvent = 
doc_postWindowExtTextInputEvent;
+m_pDocumentClass->removeTextContext = doc_removeTextContext;
 m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent;
 m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
 m_pDocumentClass->postWindowMouseEvent = doc_postWindowMouseEvent;
@@ -3053,6 +3059,44 @@ static void 
doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsig
 }
 }
 
+static void doc_removeTextContext(LibreOfficeKitDocument* pThis, unsigned 
nLOKWindowId, int nCharBefore, int nCharAfter)
+{
+SolarMutexGuard aGuard;
+VclPtr pWindow;
+if (nLOKWindowId == 0)
+{
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+gImpl->maLastExceptionMsg = "Document doesn't support tiled 
rendering";
+return;
+}
+pWindow = pDoc->getDocWindow();
+}
+else
+{
+pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
+}
+
+if (!pWindow)
+{
+gImpl->maLastExceptionMsg = "No window found for window id: " + 
OUString::number(nLOKWindowId);
+return;
+}
+
+if (nCharBefore > 0)
+{
+// backspace
+SfxLokHelper::postKeyEventAsync(pWindow, LOK_EXT_TEXTINPUT, 8, 1283, 
nCharBefore - 1);
+}
+
+if (nCharAfter > 0)
+{
+// delete (forward)
+SfxLokHelper::postKeyEventAsync(pWindow, LOK_EXT_TEXTINPUT, 46, 1286, 
nCharAfter - 1);
+}
+}
+
 static void doc_postWindowKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned 
nLOKWindowId, int nType, int nCharCode, int nKeyCode)
 {
 comphelper::ProfileZone 

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

2019-07-30 Thread Ashod Nakashian (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 
 desktop/source/lib/init.cxx |   16 
 sfx2/source/sidebar/SidebarChildWindow.cxx  |   10 +++---
 3 files changed, 27 insertions(+), 3 deletions(-)

New commits:
commit 70d3bbe11e56f12a339a5b8759b53a96b4fe84ab
Author: Ashod Nakashian 
AuthorDate: Thu May 2 23:16:30 2019 -0400
Commit: Noel Grandin 
CommitDate: Tue Jul 30 18:52:48 2019 +0200

sfx2: Enable sidebar on calc and writer, but not in impress

Added by Noel to this commit:
And add a special deregister mode to doc_registerCallback
so we can unregister stack-based callback objects in the
presence of multiple views.

Reviewed-on: https://gerrit.libreoffice.org/71715
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 
(cherry picked from commit fba6d4267b3f827269d6550dcb003cc56b31e493)

Change-Id: I8d846bc1f794cf16fd45486fd83ef87f43fd52c7
Reviewed-on: https://gerrit.libreoffice.org/76555
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index e0647da2f6af..112f29f4c59e 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1939,6 +1939,7 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
 CPPUNIT_ASSERT(aView1.m_aOwnCursor.IsEmpty());
 
 Scheduler::ProcessEventsToIdle();
+pDocument->m_pDocumentClass->registerCallback(pDocument, nullptr, 
reinterpret_cast(1));
 }
 
 #if HAVE_MORE_FONTS
@@ -2210,6 +2211,8 @@ void DesktopLOKTest::testCommentsCallbacksWriter()
 CPPUNIT_ASSERT(!aStream.str().empty());
 boost::property_tree::read_json(aStream, aTree);
 CPPUNIT_ASSERT_EQUAL(static_cast(5), 
aTree.get_child("comments").size());
+
+pDocument->m_pDocumentClass->registerCallback(pDocument, nullptr, 
reinterpret_cast(1));
 }
 
 void DesktopLOKTest::testRunMacro()
@@ -2629,6 +2632,7 @@ void DesktopLOKTest::testShowHideDialog()
 Scheduler::ProcessEventsToIdle();
 
 CPPUNIT_ASSERT_EQUAL(std::string("invalidate"), 
aView.m_aCallbackWindowResult.get("action"));
+pDocument->m_pDocumentClass->registerCallback(pDocument, nullptr, 
reinterpret_cast(1));
 }
 
 namespace {
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index f8d93534f44a..89078209ef43 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2828,6 +2828,22 @@ static void doc_registerCallback(LibreOfficeKitDocument* 
pThis,
 
 LibLODocument_Impl* pDocument = static_cast(pThis);
 
+// This is used by unit-tests to unregister stack-local callback objects 
where we have multiple views
+// so we cannot rely on SfxLokHelper::getView
+if (pCallback == nullptr && pData != nullptr)
+{
+for (auto& pair1 : pDocument->mpCallbackFlushHandlers)
+{
+int nView = pair1.first;
+for (auto& pair2 : pDocument->mpCallbackFlushHandlers)
+{
+pair2.second->removeViewStates(nView);
+}
+pDocument->mpCallbackFlushHandlers[nView].reset(new 
CallbackFlushHandler(pThis, nullptr, nullptr));
+}
+return;
+}
+
 int nView = SfxLokHelper::getView();
 if (nView < 0)
 return;
diff --git a/sfx2/source/sidebar/SidebarChildWindow.cxx 
b/sfx2/source/sidebar/SidebarChildWindow.cxx
index 678c5538aa0b..b958d840dd3b 100644
--- a/sfx2/source/sidebar/SidebarChildWindow.cxx
+++ b/sfx2/source/sidebar/SidebarChildWindow.cxx
@@ -33,7 +33,7 @@ SFX_IMPL_DOCKINGWINDOW_WITHID(SidebarChildWindow, 
SID_SIDEBAR);
 SidebarChildWindow::SidebarChildWindow(vcl::Window* pParentWindow, sal_uInt16 
nId,
SfxBindings* pBindings, 
SfxChildWinInfo* pInfo)
 : SfxChildWindow(pParentWindow, nId)
-, mbSidebarVisibleInLOK(pInfo && pInfo->aModule == "simpress")
+, mbSidebarVisibleInLOK(pInfo && (pInfo->aModule == "scalc" || 
pInfo->aModule == "swriter"))
 {
 auto pDockWin = VclPtr::Create(
 pBindings, *this, pParentWindow, WB_STDDOCKWIN | 
WB_OWNERDRAWDECORATION | WB_CLIPCHILDREN
@@ -53,8 +53,12 @@ SidebarChildWindow::SidebarChildWindow(vcl::Window* 
pParentWindow, sal_uInt16 nI
 // HACK: unfortunately I haven't found a clean solution to do
 // this, so do it this way:
 //
-pDockWin->SetSizePixel(Size(TabBar::GetDefaultWidth() * 
GetWindow()->GetDPIScaleFactor(),
-pDockWin->GetSizePixel().Height()));
+if (!comphelper::LibreOfficeKit::isActive())
+{
+pDockWin->SetSizePixel(
+Size(TabBar::GetDefaultWidth() * 
GetWindow()->GetDPIScaleFactor(),
+ pDockWin->GetSizePixel().Height()));
+}
 }
 
 pDockWin->Initialize(pInfo);
___
Libreoffice-commits mailing list

[Libreoffice-commits] core.git: desktop/qa desktop/source sc/source sd/qa sfx2/source

2019-07-29 Thread Ashod Nakashian (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx  |   10 ++--
 desktop/source/lib/init.cxx  |   16 +-
 desktop/source/lib/lokinteractionhandler.cxx |2 
 sc/source/ui/app/inputwin.cxx|7 ++
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   64 ---
 sfx2/source/control/dispatch.cxx |4 -
 6 files changed, 27 insertions(+), 76 deletions(-)

New commits:
commit d2bb93e299f42e2ab4ea8940fb4dc5da01a386b6
Author: Ashod Nakashian 
AuthorDate: Thu Aug 9 23:14:34 2018 -0400
Commit: Noel Grandin 
CommitDate: Mon Jul 29 21:21:44 2019 +0200

sfx2: Re-enable the sidebars for LOK

This re-enables the sidebars for LOK, which were
disabled to avoid overheads.

Also, fixes a regression where editing stopped
when loading a new view because the sidebar window
creation killed the edit view.

Revert "Avoid various desktop GUI elements when used from LibreOfficeKit"
This reverts commit c0b70ec34d5e056bb92a66cbf83838923cb41fee.

Also (added by Noel to the above commit)

(1) Comment out parts DesktopLOKTest::testPaintPartTile test that
trigger a crash. We are installing a callback that points to something
on the stack, and then not removing that callback, resulting in calls
to random stack memory. There is a further problem in the LOK code in
that we cannot uninstall a callback when we have multiple views
because the uninstall code in doc_registerCallback can only remove a
callback for the __current__ view, which I do not fix here.

(2) prevent code from accidentally creating empty entries in the
mpCallbackFlushHandlers map, which is what happens when you use
the index operator on map, which results in a crash in
doc_registerCallback because the std::shared_ptr is empty.

(3) In SdTiledRenderingTest, only turn off LOK via
LibreOfficeKit::setActive(false) once the document has been torn down.
Otherwise, we don't remove entries from the statically allocated
s_pLOKWindowsMap map in vcl/source/window/window.cxx, which
means that at process exit, we have dangling Window objects.

Reviewed-on: https://gerrit.libreoffice.org/71165
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 
(cherry picked from commit 88565c3662c6fde240c98a9b4f2ce6dfbcf4094e)

Change-Id: I06b06a990f05c06b1889fa89b698dff6f494e09c
Reviewed-on: https://gerrit.libreoffice.org/76466
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index f10e1fb0f035..e0647da2f6af 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1865,17 +1865,17 @@ void DesktopLOKTest::testPaintPartTile()
 // Load an impress doc of 2 slides.
 comphelper::LibreOfficeKit::setActive();
 
-ViewCallback aView1;
-ViewCallback aView2;
+//ViewCallback aView1;
+//ViewCallback aView2;
 LibLODocument_Impl* pDocument = loadDoc("2slides.odp");
 pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
-pDocument->m_pDocumentClass->registerCallback(pDocument, 
::callback, );
+//pDocument->m_pDocumentClass->registerCallback(pDocument, 
::callback, );
 int nView1 = pDocument->m_pDocumentClass->getView(pDocument);
 
 // Create a second view.
 pDocument->m_pDocumentClass->createView(pDocument);
 pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
-pDocument->m_pDocumentClass->registerCallback(pDocument, 
::callback, );
+//pDocument->m_pDocumentClass->registerCallback(pDocument, 
::callback, );
 
 // Go to the second slide in the second view.
 pDocument->m_pDocumentClass->setPart(pDocument, 1);
@@ -1894,7 +1894,7 @@ void DesktopLOKTest::testPaintPartTile()
 
 // Type again.
 Scheduler::ProcessEventsToIdle();
-aView1.m_bTilesInvalidated = false;
+//aView1.m_bTilesInvalidated = false;
 pDocument->m_pDocumentClass->postKeyEvent(pDocument, 
LOK_KEYEVENT_KEYINPUT, 'x', 0);
 pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 
'x', 0);
 Scheduler::ProcessEventsToIdle();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6bed02b869e6..f8d93534f44a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2711,8 +2711,12 @@ static void doc_paintPartTile(LibreOfficeKitDocument* 
pThis,
 }
 
 // Disable callbacks while we are painting.
-if (nOrigViewId >= 0 && pDocument->mpCallbackFlushHandlers[nOrigViewId])
-
pDocument->mpCallbackFlushHandlers[nOrigViewId]->setPartTilePainting(true);
+if (nOrigViewId >= 0)
+{
+auto findIt = pDocument->mpCallbackFlushHandlers.find(nOrigViewId);
+if (findIt != pDocument->mpCallbackFlushHandlers.end())
+

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

2019-07-19 Thread Noel Grandin (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |2 -
 desktop/source/app/app.cxx  |2 -
 desktop/source/app/dispatchwatcher.cxx  |4 +-
 desktop/source/deployment/gui/dp_gui_updatedialog.cxx   |5 +--
 desktop/source/lib/init.cxx |   17 
 desktop/source/migration/migration.cxx  |   14 +++--
 desktop/source/migration/services/oo3extensionmigration.cxx |3 --
 7 files changed, 19 insertions(+), 28 deletions(-)

New commits:
commit 2ec1c7a69917ce39850addc49ea3eb8618869aac
Author: Noel Grandin 
AuthorDate: Fri Jul 19 14:03:53 2019 +0200
Commit: Noel Grandin 
CommitDate: Fri Jul 19 14:52:24 2019 +0200

loplugin:referencecasting in desktop

Change-Id: I9ba4243bc3d6b14e66694728deb270ed74a70d01
Reviewed-on: https://gerrit.libreoffice.org/75949
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a3db0fd57b1f..e590b0a7f974 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -878,7 +878,7 @@ void DesktopLOKTest::testWriterComments()
 
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
 pDocument->pClass->registerCallback(pDocument, ::callback, 
this);
-uno::Reference 
xToolkit(com::sun::star::awt::Toolkit::create(comphelper::getProcessComponentContext()),
 uno::UNO_QUERY);
+uno::Reference xToolkit = 
com::sun::star::awt::Toolkit::create(comphelper::getProcessComponentContext());
 
 // Insert a comment at the beginning of the document and wait till the main
 // loop grabs the focus, so characters end up in the annotation window.
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 0867f6b5e82d..4feef4a7c27b 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2291,7 +2291,7 @@ void Desktop::HandleAppEvent( const ApplicationEvent& 
rAppEvent )
 if ( !xTask.is() )
 {
 // get any task if there is no active one
-Reference< css::container::XIndexAccess > xList( 
xDesktop->getFrames(), css::uno::UNO_QUERY );
+Reference< css::container::XIndexAccess > xList = 
xDesktop->getFrames();
 if ( xList->getCount() > 0 )
 xList->getByIndex(0) >>= xTask;
 }
diff --git a/desktop/source/app/dispatchwatcher.cxx 
b/desktop/source/app/dispatchwatcher.cxx
index 96f0a7f69168..af0a6d9ffd93 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -771,7 +771,7 @@ bool DispatchWatcher::executeDispatchRequests( const 
std::vector xList( xDesktop->getFrames(), UNO_QUERY );
+Reference< XElementAccess > xList = xDesktop->getFrames();
 
 if ( !xList->hasElements() )
 {
@@ -799,7 +799,7 @@ void SAL_CALL DispatchWatcher::dispatchFinished( const 
DispatchResultEvent& )
 {
 // We have to check if we have an open task otherwise we have to 
shutdown the office.
 Reference< XDesktop2 > xDesktop = css::frame::Desktop::create( 
::comphelper::getProcessComponentContext() );
-Reference< XElementAccess > xList( xDesktop->getFrames(), UNO_QUERY );
+Reference< XElementAccess > xList = xDesktop->getFrames();
 
 if ( !xList->hasElements() )
 {
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx 
b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
index 3cff34b814ce..e55a7ea717eb 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
@@ -228,9 +228,8 @@ UpdateDialog::Thread::Thread(
 {
 if( m_context.is() )
 {
-m_xInteractionHdl.set(
-task::InteractionHandler::createWithParent(m_context, 
dialog.getDialog()->GetXWindow()),
-uno::UNO_QUERY );
+m_xInteractionHdl =
+task::InteractionHandler::createWithParent(m_context, 
dialog.getDialog()->GetXWindow());
 m_updateInformation->setInteractionHandler( m_xInteractionHdl );
 }
 }
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index f48f9846d063..1a18e296a092 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3484,11 +3484,9 @@ static char* getLanguages(const char* pCommand)
 css::uno::Reference xLangSrv 
= css::linguistic2::LinguServiceManager::create(xContext);
 if (xLangSrv.is())
 {
-css::uno::Reference 
xSpell(xLangSrv->getSpellChecker(), css::uno::UNO_QUERY);
-css::uno::Reference 
xLocales(xSpell, css::uno::UNO_QUERY);
-
-if (xLocales.is())
-aLocales = xLocales->getLocales();
+css::uno::Reference xSpell = 
xLangSrv->getSpellChecker();
+if (xSpell.is())
+

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

2019-07-17 Thread Ashod Nakashian (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 ++-
 desktop/source/lib/init.cxx |   18 ++
 include/LibreOfficeKit/LibreOfficeKit.h |3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |8 
 include/vcl/ITiledRenderable.hxx|6 ++
 sd/source/ui/inc/unomodel.hxx   |2 ++
 sd/source/ui/unoidl/unomodel.cxx|7 +++
 7 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 0e82806ed6841c0a6919f97660ed4622c89d2338
Author: Ashod Nakashian 
AuthorDate: Sun Sep 16 17:27:35 2018 -0400
Commit: Jan Holesovsky 
CommitDate: Wed Jul 17 09:46:17 2019 +0200

LOK: support for ordering/moving parts

Currently reordering of slides is only supported
for presentations, although it is provisioned for
spreadsheets as well.

Change-Id: I6c35066d6a5ef7586d34a8e8b89db69a20b86572
Reviewed-on: https://gerrit.libreoffice.org/69612
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
Reviewed-on: https://gerrit.libreoffice.org/73495
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 75b9143e4417..a3db0fd57b1f 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2716,9 +2716,10 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowGestureEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), offsetof(struct 
_LibreOfficeKitDocumentClass, createViewWithOptions));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), offsetof(struct 
_LibreOfficeKitDocumentClass, selectPart));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(50), offsetof(struct 
_LibreOfficeKitDocumentClass, moveSelectedParts));
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(50), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(51), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c8ec63210664..f48f9846d063 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -711,6 +711,7 @@ static char* 
doc_getPartPageRectangles(LibreOfficeKitDocument* pThis);
 static int doc_getPart(LibreOfficeKitDocument* pThis);
 static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
 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 void doc_paintTile(LibreOfficeKitDocument* pThis,
@@ -862,6 +863,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
getPart = doc_getPart;
 m_pDocumentClass->setPart = doc_setPart;
 m_pDocumentClass->selectPart = doc_selectPart;
+m_pDocumentClass->moveSelectedParts = doc_moveSelectedParts;
 m_pDocumentClass->getPartName = doc_getPartName;
 m_pDocumentClass->setPartMode = doc_setPartMode;
 m_pDocumentClass->paintTile = doc_paintTile;
@@ -2358,6 +2360,22 @@ static void doc_selectPart(LibreOfficeKitDocument* 
pThis, int nPart, int nSelect
 pDoc->selectPart( nPart, nSelect );
 }
 
+static void doc_moveSelectedParts(LibreOfficeKitDocument* pThis, int 
nPosition, bool bDuplicate)
+{
+SolarMutexGuard aGuard;
+if (gImpl)
+gImpl->maLastExceptionMsg.clear();
+
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+return;
+}
+
+pDoc->moveSelectedParts(nPosition, bDuplicate);
+}
+
 static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis)
 {
 comphelper::ProfileZone aZone("doc_getPartPageRectangles");
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 81a4787d24df..896b441ff715 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -381,6 +381,9 @@ struct _LibreOfficeKitDocumentClass
 /// @see lok::Document::selectPart().
 void (*selectPart) (LibreOfficeKitDocument* pThis, int nPart, int nSelect);
 
+/// @see lok::Document::moveSelectedParts().
+void (*moveSelectedParts) (LibreOfficeKitDocument* pThis, int nPosition, 
bool bDuplicate);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 

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

2019-07-10 Thread Ashod Nakashian (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |5 +--
 desktop/source/lib/init.cxx |   20 
 include/LibreOfficeKit/LibreOfficeKit.h |3 +
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   12 ++-
 include/vcl/ITiledRenderable.hxx|8 
 sd/source/ui/inc/DrawViewShell.hxx  |2 +
 sd/source/ui/inc/unomodel.hxx   |3 +
 sd/source/ui/unoidl/unomodel.cxx|9 +
 sd/source/ui/view/drviews1.cxx  |   46 
 9 files changed, 104 insertions(+), 4 deletions(-)

New commits:
commit 74d56d44804efa3424cff3434d2baf00c60b3cd5
Author: Ashod Nakashian 
AuthorDate: Tue Sep 11 08:11:47 2018 -0400
Commit: Jan Holesovsky 
CommitDate: Wed Jul 10 15:32:53 2019 +0200

slide-sorter: multiple selection

Change-Id: I8624de25b0bb66020002890f33758e52059a24ab
Reviewed-on: https://gerrit.libreoffice.org/69610
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
Reviewed-on: https://gerrit.libreoffice.org/73493
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index f3f09b71aa2a..e51346e22587 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -927,7 +927,7 @@ void DesktopLOKTest::testTrackChanges()
 pDocument->pClass->registerCallback(pDocument, ::callback, 
this);
 Scheduler::ProcessEventsToIdle();
 
-// Enable track changes and assert that both views get notified.
+// Enable trak changes and assert that both views get notified.
 m_nTrackChanges = 0;
 pDocument->pClass->postUnoCommand(pDocument, ".uno:TrackChanges", nullptr, 
false);
 Scheduler::ProcessEventsToIdle();
@@ -2715,9 +2715,10 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), offsetof(struct 
_LibreOfficeKitDocumentClass, renderShapeSelection));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowGestureEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), offsetof(struct 
_LibreOfficeKitDocumentClass, createViewWithOptions));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), offsetof(struct 
_LibreOfficeKitDocumentClass, selectPart));
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(50), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b014080b4aff..c8ec63210664 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -710,6 +710,7 @@ static int doc_getParts(LibreOfficeKitDocument* pThis);
 static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis);
 static int doc_getPart(LibreOfficeKitDocument* pThis);
 static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
+static void doc_selectPart(LibreOfficeKitDocument* pThis, int nPart, int 
nSelect);
 static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart);
 static void doc_setPartMode(LibreOfficeKitDocument* pThis, int nPartMode);
 static void doc_paintTile(LibreOfficeKitDocument* pThis,
@@ -860,6 +861,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
getPartPageRectangles = doc_getPartPageRectangles;
 m_pDocumentClass->getPart = doc_getPart;
 m_pDocumentClass->setPart = doc_setPart;
+m_pDocumentClass->selectPart = doc_selectPart;
 m_pDocumentClass->getPartName = doc_getPartName;
 m_pDocumentClass->setPartMode = doc_setPartMode;
 m_pDocumentClass->paintTile = doc_paintTile;
@@ -2340,6 +2342,22 @@ static char* doc_getPartInfo(LibreOfficeKitDocument* 
pThis, int nPart)
 return pMemory;
 }
 
+static void doc_selectPart(LibreOfficeKitDocument* pThis, int nPart, int 
nSelect)
+{
+SolarMutexGuard aGuard;
+if (gImpl)
+gImpl->maLastExceptionMsg.clear();
+
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+return;
+}
+
+pDoc->selectPart( nPart, nSelect );
+}
+
 static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis)
 {
 comphelper::ProfileZone aZone("doc_getPartPageRectangles");
@@ -2696,6 +2714,8 @@ static void 
doc_initializeForRendering(LibreOfficeKitDocument* pThis,
 if (pDoc)
 {
 doc_iniUnoCommands();
+// Create the SlideSorter which is used for multiselection and 
reordering.
+doc_postUnoCommand(pThis, ".uno:LeftPaneImpress", nullptr, false);
 pDoc->initializeForTiledRendering(
 

[Libreoffice-commits] core.git: desktop/qa desktop/source sfx2/sdi sw/source

2019-05-23 Thread Miklos Vajna (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   18 ++
 desktop/source/lib/init.cxx |1 +
 sfx2/sdi/sfx.sdi|2 +-
 sw/source/uibase/dochdl/swdtflvr.cxx|   15 ++-
 sw/source/uibase/inc/swdtflvr.hxx   |5 +++--
 sw/source/uibase/shells/basesh.cxx  |   10 +++---
 6 files changed, 40 insertions(+), 11 deletions(-)

New commits:
commit dd5c9897c4930cb30bd8e5d6a0018b9515970111
Author: Miklos Vajna 
AuthorDate: Thu May 23 13:06:54 2019 +0200
Commit: Miklos Vajna 
CommitDate: Thu May 23 13:41:39 2019 +0200

sw: add IgnoreComments parameter to .uno:Paste

Which allows not hardcoding true for LOK.

Change-Id: I644763ba052b148fc34283e361aa02f9bba2c5ee
Reviewed-on: https://gerrit.libreoffice.org/72832
Reviewed-by: Miklos Vajna 
Tested-by: Michael Meeks 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d57ae546c7de..280e0336f8bb 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -586,6 +586,24 @@ void DesktopLOKTest::testPasteWriter()
 CPPUNIT_ASSERT(!pDocument->pClass->paste(pDocument, 
"textt/plain;charset=utf-8", aText.getStr(), aText.getLength()));
 // Writer is expected to support text/html.
 CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", 
aText.getStr(), aText.getLength()));
+
+// Overwrite doc contents with a HTML paste.
+pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, 
false);
+Scheduler::ProcessEventsToIdle();
+OString aComment("foo  baz");
+CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", 
aComment.getStr(), aComment.getLength()));
+
+// Check if we have a comment.
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xParagraphEnumerationAccess(xTextDocument->getText(), uno::UNO_QUERY);
+uno::Reference xParagraphEnumeration = 
xParagraphEnumerationAccess->createEnumeration();
+uno::Reference 
xParagraph(xParagraphEnumeration->nextElement(), uno::UNO_QUERY);
+uno::Reference xTextPortionEnumeration = 
xParagraph->createEnumeration();
+uno::Reference 
xTextPortion(xTextPortionEnumeration->nextElement(), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("Text"), 
xTextPortion->getPropertyValue("TextPortionType").get());
+// Without the accompanying fix in place, this test would have failed, as 
we had a comment
+// between "foo" and "baz".
+CPPUNIT_ASSERT(!xTextPortionEnumeration->hasMoreElements());
 }
 
 void DesktopLOKTest::testPasteWriterJPEG()
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 646505603311..755d980139a2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3295,6 +3295,7 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, 
const char* pMimeType, cons
 uno::Sequence 
aPropertyValues(comphelper::InitPropertySequence(
 {
 {"AnchorType", 
uno::makeAny(static_cast(text::TextContentAnchorType_AS_CHARACTER))},
+{"IgnoreComments", uno::makeAny(true)},
 }));
 if (!comphelper::dispatchCommand(".uno:Paste", aPropertyValues))
 {
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index d3e1157d96e2..3d8cade70309 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3022,7 +3022,7 @@ SfxTemplateItem ParaStyle SID_STYLE_FAMILY2
 
 
 SfxVoidItem Paste SID_PASTE
-(SfxUInt16Item AnchorType FN_PARAM_1)
+(SfxUInt16Item AnchorType FN_PARAM_1, SfxBoolItem IgnoreComments FN_PARAM_2)
 [
 AutoUpdate = FALSE,
 FastCall = TRUE,
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx 
b/sw/source/uibase/dochdl/swdtflvr.cxx
index 6912152d8f56..e5e71a251629 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1249,7 +1249,7 @@ bool SwTransferable::IsPaste( const SwWrtShell& rSh,
 return bIsPaste;
 }
 
-bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, 
RndStdIds nAnchorType)
+bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, 
RndStdIds nAnchorType, bool bIgnoreComments)
 {
 SwPasteContext aPasteContext(rSh);
 
@@ -1321,7 +1321,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, 
TransferableDataHelper& rData, RndSt
 nLevel++;
 } while (rSh.GetDoc()->IsIdxInTable(rSh.GetCursor()->GetNode()) != 
nullptr);
 if ( SwTransferable::PasteData( rData, rSh, 
EXCHG_OUT_ACTION_INSERT_STRING, nActionFlags, SotClipboardFormatId::HTML,
-nDestination, false, false, nullptr, 
0, false, nAnchorType,  ))
+nDestination, false, false, nullptr, 
0, false, nAnchorType, bIgnoreComments,  ))
 {
 pDispatch->Execute(FN_CHAR_LEFT, SfxCallMode::SYNCHRON);
 

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

2019-05-09 Thread Miklos Vajna (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |  112 ++--
 desktop/source/lib/init.cxx |   10 ++
 2 files changed, 18 insertions(+), 104 deletions(-)

New commits:
commit da17ccaec39f50de68c3fdd431bc66a2bec04127
Author: Miklos Vajna 
AuthorDate: Thu May 9 18:13:20 2019 +0200
Commit: Miklos Vajna 
CommitDate: Thu May 9 22:22:29 2019 +0200

CppunitTest_desktop_lib: close the document while LOK is still active

Otherwise the LOK notifiers won't be released (since LOK is not active),
and we leak vcl::Windows in GetLOKWindowsMap()::s_pLOKWindowsMap.

In dbgutil builds, this leads to an assertion failure if the sidebar is
active.

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

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index e18cda94bb7d..9240785d10c1 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -78,7 +78,11 @@ public:
 
 virtual void tearDown() override
 {
+if (m_pDocument)
+m_pDocument->pClass->registerCallback(m_pDocument.get(), nullptr, 
nullptr);
 closeDoc();
+comphelper::LibreOfficeKit::setActive(false);
+
 UnoApiTest::tearDown();
 };
 
@@ -211,6 +215,7 @@ public:
 osl::Condition m_aContextMenuCondition;
 boost::property_tree::ptree m_aContextMenuResult;
 
+std::unique_ptr m_pDocument;
 };
 
 static Control* GetFocusControl(vcl::Window const * pParent)
@@ -255,7 +260,8 @@ LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* 
pName, LibreOfficeKitDoc
 {
 CPPUNIT_ASSERT(false);
 }
-return new LibLODocument_Impl(mxComponent);
+m_pDocument.reset(new LibLODocument_Impl(mxComponent));
+return m_pDocument.get();
 }
 
 void DesktopLOKTest::closeDoc()
@@ -367,7 +373,6 @@ void DesktopLOKTest::testGetStyles()
 CPPUNIT_FAIL("Unknown style family: " + rPair.first);
 }
 }
-comphelper::LibreOfficeKit::setActive(false);
 }
 
 void DesktopLOKTest::testGetFonts()
@@ -389,7 +394,6 @@ void DesktopLOKTest::testGetFonts()
 CPPUNIT_ASSERT( !rPair.second.empty());
 }
 free(pJSON);
-comphelper::LibreOfficeKit::setActive(false);
 }
 
 void DesktopLOKTest::testCreateView()
@@ -416,7 +420,6 @@ void DesktopLOKTest::testCreateView()
 
 pDocument->m_pDocumentClass->destroyView(pDocument, nId1);
 CPPUNIT_ASSERT_EQUAL(1, 
pDocument->m_pDocumentClass->getViewsCount(pDocument));
-comphelper::LibreOfficeKit::setActive(false);
 }
 
 void DesktopLOKTest::testGetPartPageRectangles()
@@ -440,7 +443,6 @@ void DesktopLOKTest::testGetPartPageRectangles()
 CPPUNIT_ASSERT_EQUAL(static_cast(1), aRectangles.size());
 
 free(pRectangles);
-comphelper::LibreOfficeKit::setActive(false);
 }
 
 void DesktopLOKTest::testGetFilterTypes()
@@ -456,7 +458,6 @@ void DesktopLOKTest::testGetFilterTypes()
 CPPUNIT_ASSERT(!aTree.empty());
 
CPPUNIT_ASSERT_EQUAL(std::string("application/vnd.oasis.opendocument.text"), 
aTree.get_child("writer8").get_child("MediaType").get_value());
 free(pJSON);
-comphelper::LibreOfficeKit::setActive(false);
 }
 
 void DesktopLOKTest::testSearchCalc()
@@ -490,9 +491,6 @@ void DesktopLOKTest::testSearchCalc()
 CPPUNIT_ASSERT_EQUAL(static_cast(2), 
m_aSearchResultSelection.size());
 // Result is on the first sheet.
 CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]);
-
-pDocument->pClass->registerCallback(pDocument, nullptr, nullptr);
-comphelper::LibreOfficeKit::setActive(false);
 }
 
 void DesktopLOKTest::testSearchAllNotificationsCalc()
@@ -517,9 +515,6 @@ void DesktopLOKTest::testSearchAllNotificationsCalc()
 CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult);
 // But we do get the selection afterwards.
 CPPUNIT_ASSERT(m_nSelectionAfterSearchResult > 0);
-
-pDocument->pClass->registerCallback(pDocument, nullptr, nullptr);
-comphelper::LibreOfficeKit::setActive(false);
 }
 
 void DesktopLOKTest::testPaintTile()
@@ -548,8 +543,6 @@ void DesktopLOKTest::testPaintTile()
 nTileHeight = 4000;
 aBuffer.resize(nCanvasWidth * nCanvasHeight * 4);
 pDocument->pClass->paintTile(pDocument, aBuffer.data(), nCanvasWidth, 
nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
-
-comphelper::LibreOfficeKit::setActive(false);
 }
 
 void DesktopLOKTest::testSaveAs()
@@ -560,8 +553,6 @@ void DesktopLOKTest::testSaveAs()
 utl::TempFile aTempFile;
 aTempFile.EnableKillingFile();
 CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, 
aTempFile.GetURL().toUtf8().getStr(), "png", nullptr));
-
-comphelper::LibreOfficeKit::setActive(false);
 }
 
 void DesktopLOKTest::testSaveAsCalc()
@@ -572,8 +563,6 @@ void DesktopLOKTest::testSaveAsCalc()
 utl::TempFile aTempFile;
 

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit ios/LibreOfficeLight libreofficekit/qa

2019-04-26 Thread Henry Castro (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   51 
 desktop/source/lib/init.cxx |   37 
 desktop/source/lib/lokclipboard.cxx |   10 +-
 desktop/source/lib/lokclipboard.hxx |3 
 include/LibreOfficeKit/LibreOfficeKit.h |2 
 include/LibreOfficeKit/LibreOfficeKit.hxx   |4 
 include/LibreOfficeKit/LibreOfficeKitEnums.h|3 
 ios/LibreOfficeLight/LibreOfficeLight/LOKit/Document.swift  |8 -
 libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx |2 
 libreofficekit/qa/tilebench/tilebench.cxx   |2 
 10 files changed, 107 insertions(+), 15 deletions(-)

New commits:
commit 2ead533d2383083925537832b473e3264811d454
Author: Henry Castro 
AuthorDate: Thu Apr 18 18:10:13 2019 -0400
Commit: Henry Castro 
CommitDate: Fri Apr 26 15:28:11 2019 +0200

lok: allow paste content to popup dialog

Change-Id: I1893d52df505bc43428c37a624ca05c569ba1bc0
Reviewed-on: https://gerrit.libreoffice.org/70958
Tested-by: Jenkins
Reviewed-by: Henry Castro 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a08d476a8bac..e18cda94bb7d 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -22,7 +22,11 @@
 
 #include 
 
+#include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -130,6 +134,7 @@ public:
 void testInsertCertificate_PEM_DOCX();
 void testSignDocument_PEM_PDF();
 void testTextSelectionHandles();
+void testDialogPaste();
 void testABI();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
@@ -180,6 +185,7 @@ public:
 CPPUNIT_TEST(testInsertCertificate_PEM_DOCX);
 CPPUNIT_TEST(testSignDocument_PEM_PDF);
 CPPUNIT_TEST(testTextSelectionHandles);
+CPPUNIT_TEST(testDialogPaste);
 CPPUNIT_TEST(testABI);
 CPPUNIT_TEST_SUITE_END();
 
@@ -207,6 +213,23 @@ public:
 
 };
 
+static Control* GetFocusControl(vcl::Window const * pParent)
+{
+sal_uInt16 nChildren = pParent->GetChildCount();
+for (sal_uInt16 nChild = 0; nChild < nChildren; ++nChild)
+{
+vcl::Window* pChild = pParent->GetChild( nChild );
+Control* pCtrl = dynamic_cast(pChild);
+if (pCtrl && pCtrl->HasControlFocus())
+return pCtrl;
+
+Control* pSubCtrl = GetFocusControl( pChild );
+if (pSubCtrl)
+return pSubCtrl;
+}
+return nullptr;
+}
+
 LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, 
LibreOfficeKitDocumentType eType)
 {
 OUString aFileURL;
@@ -2616,6 +2639,34 @@ void DesktopLOKTest::testTextSelectionHandles()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testDialogPaste()
+{
+comphelper::LibreOfficeKit::setActive();
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+pDocument->pClass->postUnoCommand(pDocument, ".uno:HyperlinkDialog", 
nullptr, false);
+Scheduler::ProcessEventsToIdle();
+
+SfxViewShell* pViewShell = SfxViewShell::Current();
+pViewShell->GetViewFrame()->GetBindings().Update();
+
+VclPtr pWindow(Application::GetActiveTopWindow());
+CPPUNIT_ASSERT(pWindow);
+
+pDocument->pClass->postWindow(pDocument, pWindow->GetLOKWindowId(), 
LOK_WINDOW_PASTE,
+"{ \"MimeType\" : { \"type\" : \"string\", \"value\" : 
\"text/plain;charset=utf-8\" }, \"Data\" : { \"type\" : \"[]byte\", \"value\" : 
\"www.softwarelibre.org.bo\" } }");
+Scheduler::ProcessEventsToIdle();
+
+Control* pCtrlFocused = GetFocusControl(pWindow.get());
+CPPUNIT_ASSERT(pCtrlFocused);
+ComboBox* pCtrlURL = dynamic_cast(pCtrlFocused);
+CPPUNIT_ASSERT(pCtrlURL);
+CPPUNIT_ASSERT_EQUAL(OUString("www.softwarelibre.org.bo"), 
pCtrlURL->GetText());
+
+static_cast(pWindow.get())->Close();
+Scheduler::ProcessEventsToIdle();
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 namespace {
 
 constexpr size_t classOffset(int i)
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c4a36e9e182e..937331376024 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -358,6 +358,15 @@ std::vector 
desktop::jsonToPropertyValuesVector(const char
 aValue.Value <<= 
static_cast(OString(rValue.c_str()).toInt32());
 else if (rType == "unsigned short")
 aValue.Value <<= 
static_cast(OString(rValue.c_str()).toUInt32());
+else if (rType == "[]byte")
+{
+aNodeValue = rPair.second.get_child("value", aNodeNull);
+if (aNodeValue != aNodeNull && aNodeValue.size() == 0)
+{
+uno::Sequence< sal_Int8 > aSeqByte(reinterpret_cast(rValue.c_str()), rValue.size());
+aValue.Value <<= aSeqByte;
+

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

2019-04-23 Thread Ashod Nakashian (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 ++-
 desktop/source/lib/init.cxx |   22 --
 include/LibreOfficeKit/LibreOfficeKit.h |3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   10 +++---
 4 files changed, 32 insertions(+), 6 deletions(-)

New commits:
commit 6a2382c64f65d433d44ce74f936e42f744f04e21
Author: Ashod Nakashian 
AuthorDate: Thu Jan 24 06:51:46 2019 -0500
Commit: Michael Meeks 
CommitDate: Tue Apr 23 11:58:54 2019 +0200

LOK: support creating view with options

This adds a new API createViewWithOptions
that make createView similar to documentLoad,
which also has documentViewWithOptions version.
This is primarily to support setting per-view
language and similar settings.

Change-Id: I0ae5a5b2410cf9e053aee8f7c8a6204af9038a31
Reviewed-on: https://gerrit.libreoffice.org/68261
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 
Reviewed-on: https://gerrit.libreoffice.org/7
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a688350cb386..a08d476a8bac 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2699,9 +2699,10 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), offsetof(struct 
_LibreOfficeKitDocumentClass, getSignatureState));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), offsetof(struct 
_LibreOfficeKitDocumentClass, renderShapeSelection));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowGestureEvent));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), offsetof(struct 
_LibreOfficeKitDocumentClass, createViewWithOptions));
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0853678a0008..7fcf018813d4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -783,6 +783,7 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis,
 static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, 
int nY, int nWidth, int nHeight);
 static void doc_setOutlineState(LibreOfficeKitDocument* pThis, bool bColumn, 
int nLevel, int nIndex, bool bHidden);
 static int doc_createView(LibreOfficeKitDocument* pThis);
+static int doc_createViewWithOptions(LibreOfficeKitDocument* pThis, const 
char* pOptions);
 static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
 static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
 static int doc_getView(LibreOfficeKitDocument* pThis);
@@ -891,6 +892,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
renderShapeSelection = doc_renderShapeSelection;
 m_pDocumentClass->postWindowGestureEvent = doc_postWindowGestureEvent;
 
+m_pDocumentClass->createViewWithOptions = doc_createViewWithOptions;
+
 gDocumentClass = m_pDocumentClass;
 }
 pClass = m_pDocumentClass.get();
@@ -1615,7 +1618,7 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 // 'Language=...' is an option that LOK consumes by itself, and does
 // not pass it as a parameter to the filter
 OUString aOptions = getUString(pOptions);
-OUString aLanguage = extractParameter(aOptions, "Language");
+const OUString aLanguage = extractParameter(aOptions, "Language");
 
 if (!aLanguage.isEmpty())
 {
@@ -3866,7 +3869,8 @@ static void doc_setOutlineState(LibreOfficeKitDocument* 
pThis, bool bColumn, int
 pDoc->setOutlineState(bColumn, nLevel, nIndex, bHidden);
 }
 
-static int doc_createView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* 
/*pThis*/)
+static int doc_createViewWithOptions(SAL_UNUSED_PARAMETER 
LibreOfficeKitDocument* /*pThis*/,
+ const char* pOptions)
 {
 comphelper::ProfileZone aZone("doc_createView");
 
@@ -3874,9 +3878,23 @@ static int doc_createView(SAL_UNUSED_PARAMETER 
LibreOfficeKitDocument* /*pThis*/
 if (gImpl)
 gImpl->maLastExceptionMsg.clear();
 
+OUString aOptions = getUString(pOptions);
+const OUString aLanguage = extractParameter(aOptions, "Language");
+
+if (!aLanguage.isEmpty())
+{
+// Set the LOK language tag, used for dialog tunneling.
+comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(aLanguage));
+}
+
 return SfxLokHelper::createView();
 }
 
+static int doc_createView(LibreOfficeKitDocument* pThis)
+{
+return 

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

2019-04-17 Thread Tamás Zolnai (via logerrit)
 desktop/qa/desktop_app/test_desktop_app.cxx |2 +-
 desktop/source/app/cmdlineargs.cxx  |8 
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit f6dc5636c1eda8aebeac3f7b85dd61499523d6a3
Author: Tamás Zolnai 
AuthorDate: Wed Apr 17 12:33:13 2019 +0200
Commit: Tamás Zolnai 
CommitDate: Wed Apr 17 23:36:58 2019 +0200

SharePoint connection: Better handling of encoded URLs

Handle %7c with small letters.
Make sure that the output parameter's content is not
affected by decoding.

Change-Id: Ie3faad2461815497c0edfb04a589fc57aeb7d66b
Reviewed-on: https://gerrit.libreoffice.org/70873
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai 

diff --git a/desktop/qa/desktop_app/test_desktop_app.cxx 
b/desktop/qa/desktop_app/test_desktop_app.cxx
index 055c8cf5434e..1a027dfade78 100644
--- a/desktop/qa/desktop_app/test_desktop_app.cxx
+++ b/desktop/qa/desktop_app/test_desktop_app.cxx
@@ -113,7 +113,7 @@ void Test::testTdf100837() {
 
 {
 // 3. Test enocded URLs
-TestSupplier supplier{ "foo", "ms-word:ofe%7Cu%7Cbar1", 
"ms-word:ofv%7Cu%7Cbar2", "ms-word:nft%7Cu%7Cbar3", "baz" };
+TestSupplier supplier{ "foo", "ms-word:ofe%7Cu%7cbar1", 
"ms-word:ofv%7cu%7Cbar2", "ms-word:nft%7Cu%7cbar3", "baz" };
 desktop::CommandLineArgs args(supplier);
 auto vOpenList = args.GetOpenList();
 auto vForceOpenList = args.GetForceOpenList();
diff --git a/desktop/source/app/cmdlineargs.cxx 
b/desktop/source/app/cmdlineargs.cxx
old mode 100755
new mode 100644
index acb266eb335e..30d0c3f4cced
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -131,25 +131,25 @@ CommandLineEvent CheckOfficeURI(/* in,out */ OUString& 
arg, CommandLineEvent cur
 long nURIlen = -1;
 
 // URL might be encoded
-rest1 = rest1.replaceAll("%7C", "|");
+OUString decoded_rest = rest1.replaceAll("%7C", "|").replaceAll("%7c", 
"|");
 
 // 2. Discriminate by command name (incl. 1st command argument descriptor)
 //Extract URI: everything up to possible next argument
-if (rest1.startsWith("ofv|u|", ))
+if (decoded_rest.startsWith("ofv|u|", ))
 {
 // Open for view - override only in default mode
 if (curEvt == CommandLineEvent::Open)
 curEvt = CommandLineEvent::View;
 nURIlen = rest2.indexOf("|");
 }
-else if (rest1.startsWith("ofe|u|", ))
+else if (decoded_rest.startsWith("ofe|u|", ))
 {
 // Open for editing - override only in default mode
 if (curEvt == CommandLineEvent::Open)
 curEvt = CommandLineEvent::ForceOpen;
 nURIlen = rest2.indexOf("|");
 }
-else if (rest1.startsWith("nft|u|", ))
+else if (decoded_rest.startsWith("nft|u|", ))
 {
 // New from template - override only in default mode
 if (curEvt == CommandLineEvent::Open)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-04-16 Thread Tamás Zolnai (via logerrit)
 desktop/qa/desktop_app/test_desktop_app.cxx |   23 +++
 desktop/source/app/cmdlineargs.cxx  |4 
 2 files changed, 27 insertions(+)

New commits:
commit 2317ad572cc330c4c2de95065ef275f58a9c83a1
Author: Tamás Zolnai 
AuthorDate: Tue Apr 16 10:45:12 2019 +0200
Commit: Tamás Zolnai 
CommitDate: Tue Apr 16 22:00:48 2019 +0200

SharePoint connection: Handle encoded URL passed as command line argument

Change-Id: I3352bf9ade88bd86f7ca3d53238364216547d52b
Reviewed-on: https://gerrit.libreoffice.org/70830
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai 

diff --git a/desktop/qa/desktop_app/test_desktop_app.cxx 
b/desktop/qa/desktop_app/test_desktop_app.cxx
index ef588a580266..055c8cf5434e 100644
--- a/desktop/qa/desktop_app/test_desktop_app.cxx
+++ b/desktop/qa/desktop_app/test_desktop_app.cxx
@@ -110,6 +110,29 @@ void Test::testTdf100837() {
 CPPUNIT_ASSERT_EQUAL(OUString("bar"),  vForceOpenList[0]);
 CPPUNIT_ASSERT_EQUAL(OUString("baz"), vForceOpenList[1]);
 }
+
+{
+// 3. Test enocded URLs
+TestSupplier supplier{ "foo", "ms-word:ofe%7Cu%7Cbar1", 
"ms-word:ofv%7Cu%7Cbar2", "ms-word:nft%7Cu%7Cbar3", "baz" };
+desktop::CommandLineArgs args(supplier);
+auto vOpenList = args.GetOpenList();
+auto vForceOpenList = args.GetForceOpenList();
+auto vViewList = args.GetViewList();
+auto vForceNewList = args.GetForceNewList();
+// 2 documents go to Open list: foo; baz
+CPPUNIT_ASSERT_EQUAL(decltype(vOpenList.size())(2), vOpenList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("foo"), vOpenList[0]);
+CPPUNIT_ASSERT_EQUAL(OUString("baz"), vOpenList[1]);
+// 1 document goes to ForceOpen list: bar1
+CPPUNIT_ASSERT_EQUAL(decltype(vForceOpenList.size())(1), 
vForceOpenList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("bar1"), vForceOpenList[0]);
+// 1 document goes to View list: bar2
+CPPUNIT_ASSERT_EQUAL(decltype(vViewList.size())(1), vViewList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("bar2"), vViewList[0]);
+// 1 document goes to ForceNew list: bar3
+CPPUNIT_ASSERT_EQUAL(decltype(vForceNewList.size())(1), 
vForceNewList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("bar3"), vForceNewList[0]);
+}
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/desktop/source/app/cmdlineargs.cxx 
b/desktop/source/app/cmdlineargs.cxx
old mode 100644
new mode 100755
index 52f96dd84d88..acb266eb335e
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -129,6 +129,10 @@ CommandLineEvent CheckOfficeURI(/* in,out */ OUString& 
arg, CommandLineEvent cur
 
 OUString rest2;
 long nURIlen = -1;
+
+// URL might be encoded
+rest1 = rest1.replaceAll("%7C", "|");
+
 // 2. Discriminate by command name (incl. 1st command argument descriptor)
 //Extract URI: everything up to possible next argument
 if (rest1.startsWith("ofv|u|", ))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-03-25 Thread Tomaž Vajngerl (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 +
 desktop/source/lib/init.cxx |   45 
 include/LibreOfficeKit/LibreOfficeKit.h |9 +
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   16 +
 4 files changed, 72 insertions(+), 1 deletion(-)

New commits:
commit 4a68361d578fe3bf313f80d8e186079bd34b2300
Author: Tomaž Vajngerl 
AuthorDate: Mon Mar 25 18:23:36 2019 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Mar 26 01:31:46 2019 +0100

tdf#124146 support posting of gesture event for LOKit

Change-Id: I51845f2e41dbcbe1ae6cb0a18cf9f42d5549968b
Reviewed-on: https://gerrit.libreoffice.org/69657
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 445901108ed4..413b697be70a 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2696,9 +2696,10 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), offsetof(struct 
_LibreOfficeKitDocumentClass, addCertificate));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), offsetof(struct 
_LibreOfficeKitDocumentClass, getSignatureState));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), offsetof(struct 
_LibreOfficeKitDocumentClass, renderShapeSelection));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowGestureEvent));
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a83af85d4441..dfbbdd8386dc 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -107,6 +107,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -744,6 +745,12 @@ static void doc_postWindowMouseEvent 
(LibreOfficeKitDocument* pThis,
   int nCount,
   int nButtons,
   int nModifier);
+static void doc_postWindowGestureEvent(LibreOfficeKitDocument* pThis,
+  unsigned nLOKWindowId,
+  const char* pType,
+  int nX,
+  int nY,
+  int nOffset);
 static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
const char* pCommand,
const char* pArguments,
@@ -879,6 +886,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
getSignatureState = doc_getSignatureState;
 
 m_pDocumentClass->renderShapeSelection = doc_renderShapeSelection;
+m_pDocumentClass->postWindowGestureEvent = doc_postWindowGestureEvent;
 
 gDocumentClass = m_pDocumentClass;
 }
@@ -3020,6 +3028,43 @@ static void 
doc_postWindowMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned
 }
 }
 
+static void doc_postWindowGestureEvent(LibreOfficeKitDocument* /*pThis*/, 
unsigned nLOKWindowId, const char* pType, int nX, int nY, int nOffset)
+{
+SolarMutexGuard aGuard;
+if (gImpl)
+gImpl->maLastExceptionMsg.clear();
+
+VclPtr pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
+if (!pWindow)
+{
+gImpl->maLastExceptionMsg = "Document doesn't support dialog 
rendering, or window not found.";
+return;
+}
+
+OString aType(pType);
+GestureEventType eEventType = GestureEventType::PanningUpdate;
+
+if (aType == "panBegin")
+eEventType = GestureEventType::PanningBegin;
+else if (aType == "panEnd")
+eEventType = GestureEventType::PanningEnd;
+
+GestureEvent aEvent {
+sal_Int32(nX),
+sal_Int32(nY),
+eEventType,
+sal_Int32(nOffset),
+PanningOrientation::Vertical,
+};
+
+if (Dialog* pDialog = dynamic_cast(pWindow.get()))
+{
+pDialog->EnableInput();
+}
+
+Application::PostGestureEvent(VclEventId::WindowGestureEvent, pWindow, 
);
+}
+
 static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int 
nX, int nY)
 {
 SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 2df1cea6dd31..0e596f5067ba 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -356,10 +356,19 @@ struct _LibreOfficeKitDocumentClass
 
 /// @see lok::Document::getSignatureState().
 int (*getSignatureState) (LibreOfficeKitDocument* pThis);
+// END CERTIFICATE 

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

2019-01-17 Thread Libreoffice Gerrit user
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   53 
 desktop/source/lib/init.cxx |2 -
 2 files changed, 53 insertions(+), 2 deletions(-)

New commits:
commit fe9b4067e00015975e0a99f3f127b93338aa4269
Author: Jan Holesovsky 
AuthorDate: Fri Jan 11 11:39:29 2019 +0100
Commit: Jan Holesovsky 
CommitDate: Thu Jan 17 10:17:47 2019 +0100

lok: We cannot skip duplicates of SELECTION_START / _END.

The scenario is like this (see the unit test):

* double-click a word to select it (the handles appear)
* click somewhere else (the selection and handles disappear)
* double-click the same word again (the handles did not appear in this
  case)

The reason was that the old state was remembered and the now thought
duplicate state was discarded.

Change-Id: Ia49200f12907c520067258b7570d4e21b365a8dd
Reviewed-on: https://gerrit.libreoffice.org/66171
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 55d8c6761420..c6678704f3e4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -127,6 +127,7 @@ public:
 void testInsertCertificate_PEM_ODT();
 void testInsertCertificate_PEM_DOCX();
 void testSignDocument_PEM_PDF();
+void testTextSelectionHandles();
 void testABI();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
@@ -176,11 +177,14 @@ public:
 CPPUNIT_TEST(testInsertCertificate_PEM_ODT);
 CPPUNIT_TEST(testInsertCertificate_PEM_DOCX);
 CPPUNIT_TEST(testSignDocument_PEM_PDF);
+CPPUNIT_TEST(testTextSelectionHandles);
 CPPUNIT_TEST(testABI);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
 OString m_aTextSelection;
+OString m_aTextSelectionStart;
+OString m_aTextSelectionEnd;
 std::vector m_aSearchResultSelection;
 std::vector m_aSearchResultPart;
 int m_nSelectionBeforeSearchResult;
@@ -256,6 +260,12 @@ void DesktopLOKTest::callbackImpl(int nType, const char* 
pPayload)
 ++m_nSelectionAfterSearchResult;
 }
 break;
+case LOK_CALLBACK_TEXT_SELECTION_START:
+m_aTextSelectionStart = pPayload;
+break;
+case LOK_CALLBACK_TEXT_SELECTION_END:
+m_aTextSelectionEnd = pPayload;
+break;
 case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
 {
 m_aSearchResultSelection.clear();
@@ -2547,6 +2557,49 @@ void DesktopLOKTest::testSignDocument_PEM_PDF()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testTextSelectionHandles()
+{
+comphelper::LibreOfficeKit::setActive();
+
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+pDocument->pClass->registerCallback(pDocument, ::callback, 
this);
+
+OString aText("hello");
+CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, 
"text/plain;charset=utf-8", aText.getStr(), aText.getLength()));
+
+// select the inserted text
+pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, 
false);
+Scheduler::ProcessEventsToIdle();
+char* pText = pDocument->pClass->getTextSelection(pDocument, 
"text/plain;charset=utf-8", nullptr);
+CPPUNIT_ASSERT_EQUAL(aText, OString(pText));
+free(pText);
+CPPUNIT_ASSERT_EQUAL(OString("1418, 1418, 0, 275"), m_aTextSelectionStart);
+CPPUNIT_ASSERT_EQUAL(OString("1898, 1418, 0, 275"), m_aTextSelectionEnd);
+
+// deselect & check
+m_aTextSelectionStart = "";
+m_aTextSelectionEnd = "";
+pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 0, 
com::sun::star::awt::Key::ESCAPE);
+Scheduler::ProcessEventsToIdle();
+pText = pDocument->pClass->getTextSelection(pDocument, 
"text/plain;charset=utf-8", nullptr);
+CPPUNIT_ASSERT_EQUAL(OString(), OString(pText));
+free(pText);
+CPPUNIT_ASSERT_EQUAL(OString(), m_aTextSelectionStart);
+CPPUNIT_ASSERT_EQUAL(OString(), m_aTextSelectionEnd);
+
+// select again; the positions of the selection handles have to be sent
+// again
+pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, 
false);
+Scheduler::ProcessEventsToIdle();
+pText = pDocument->pClass->getTextSelection(pDocument, 
"text/plain;charset=utf-8", nullptr);
+CPPUNIT_ASSERT_EQUAL(aText, OString(pText));
+free(pText);
+CPPUNIT_ASSERT_EQUAL(OString("1418, 1418, 0, 275"), m_aTextSelectionStart);
+CPPUNIT_ASSERT_EQUAL(OString("1898, 1418, 0, 275"), m_aTextSelectionEnd);
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 namespace {
 
 constexpr size_t classOffset(int i)
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7b3a8a81c945..c10283321221 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -843,8 +843,6 @@ 
CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, Li
 
 // Add the states 

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

2019-01-01 Thread Libreoffice Gerrit user
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   63 ++
 desktop/source/lib/init.cxx |   78 +
 include/LibreOfficeKit/LibreOfficeKit.h |   10 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   12 ++
 include/sfx2/DocumentSigner.hxx |   41 +
 sfx2/Library_sfx.mk |1 
 sfx2/source/doc/DocumentSigner.cxx  |  125 
 7 files changed, 330 insertions(+)

New commits:
commit a8cb7cf68ff661b502e7c006fe4330098b5b0944
Author: Tomaž Vajngerl 
AuthorDate: Mon Dec 31 12:27:39 2018 +0100
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 1 09:53:20 2019 +0100

lok: add signDocument to "Office" iface - to sign not opened docs.

LOKit function "signDocument" can sign document without the need
to open them. This is useful to sign PDF documents after they are
created from a currently opened (ODF, DOCX) document.

This adds DocumentDigner to sfx2, which could also be used in
desktop LibreOffice without opening them and in further tests.

Change-Id: Id6f242e817f594aa672f94f9c6f9b34e4035d46a
Reviewed-on: https://gerrit.libreoffice.org/65767
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 740e2d4fdecf..55d8c6761420 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -126,6 +126,7 @@ public:
 void testInsertCertificate_DER_ODT();
 void testInsertCertificate_PEM_ODT();
 void testInsertCertificate_PEM_DOCX();
+void testSignDocument_PEM_PDF();
 void testABI();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
@@ -174,6 +175,7 @@ public:
 CPPUNIT_TEST(testInsertCertificate_DER_ODT);
 CPPUNIT_TEST(testInsertCertificate_PEM_ODT);
 CPPUNIT_TEST(testInsertCertificate_PEM_DOCX);
+CPPUNIT_TEST(testSignDocument_PEM_PDF);
 CPPUNIT_TEST(testABI);
 CPPUNIT_TEST_SUITE_END();
 
@@ -2485,6 +2487,66 @@ void DesktopLOKTest::testInsertCertificate_PEM_DOCX()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testSignDocument_PEM_PDF()
+{
+comphelper::LibreOfficeKit::setActive();
+
+// Load the document, save it into a temp file and load that file again
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+utl::TempFile aTempFile;
+aTempFile.EnableKillingFile();
+
+Scheduler::ProcessEventsToIdle();
+CPPUNIT_ASSERT(mxComponent.is());
+pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+Scheduler::ProcessEventsToIdle();
+
+std::vector aCertificate;
+std::vector aPrivateKey;
+
+{
+readFileIntoByteVector("test-cert-chain-1.pem", aCertificate);
+
+bool bResult = pDocument->m_pDocumentClass->addCertificate(
+pDocument, aCertificate.data(), 
int(aCertificate.size()));
+CPPUNIT_ASSERT(bResult);
+}
+
+{
+readFileIntoByteVector("test-cert-chain-2.pem", aCertificate);
+
+bool bResult = pDocument->m_pDocumentClass->addCertificate(
+pDocument, aCertificate.data(), 
int(aCertificate.size()));
+CPPUNIT_ASSERT(bResult);
+}
+
+{
+readFileIntoByteVector("test-cert-chain-3.pem", aCertificate);
+
+bool bResult = pDocument->m_pDocumentClass->addCertificate(
+pDocument, aCertificate.data(), 
int(aCertificate.size()));
+CPPUNIT_ASSERT(bResult);
+}
+
+CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, 
aTempFile.GetURL().toUtf8().getStr(), "pdf", nullptr));
+
+closeDoc();
+
+Scheduler::ProcessEventsToIdle();
+
+readFileIntoByteVector("test-cert-signing.pem", aCertificate);
+readFileIntoByteVector("test-PK-signing.pem", aPrivateKey);
+
+LibLibreOffice_Impl aOffice;
+bool bResult = aOffice.m_pOfficeClass->signDocument(, 
aTempFile.GetURL().toUtf8().getStr(),
+ aCertificate.data(), 
int(aCertificate.size()),
+ aPrivateKey.data(), 
int(aPrivateKey.size()));
+
+CPPUNIT_ASSERT(bResult);
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 namespace {
 
 constexpr size_t classOffset(int i)
@@ -2513,6 +2575,7 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(8), offsetof(struct _LibreOfficeKitClass, 
setDocumentPassword));
 CPPUNIT_ASSERT_EQUAL(classOffset(9), offsetof(struct _LibreOfficeKitClass, 
getVersionInfo));
 CPPUNIT_ASSERT_EQUAL(classOffset(10), offsetof(struct 
_LibreOfficeKitClass, runMacro));
+CPPUNIT_ASSERT_EQUAL(classOffset(11), offsetof(struct 
_LibreOfficeKitClass, signDocument));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 

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

2018-12-13 Thread Libreoffice Gerrit user
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   37 
 desktop/source/lib/init.cxx |   22 
 include/LibreOfficeKit/LibreOfficeKit.h |   10 ---
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   29 -
 4 files changed, 98 deletions(-)

New commits:
commit ef9e7c83267d9bfa7f225a25fceafa1027a21a6a
Author: Tor Lillqvist 
AuthorDate: Thu Dec 13 13:18:46 2018 +0200
Commit: Tor Lillqvist 
CommitDate: Thu Dec 13 13:20:30 2018 +0200

Revert adding the tanslateGet() and translateNGet() API to LibreOfficeKit

Will handle it another way instead that isn't so visible and annoying.

This reverts commit 5f0dda8e9f2e35e1fdb5750089a70543478fa8a1.
This reverts commit 4f1a341bc312673b8d92e4474cc39bc3ab69aa5b.

Change-Id: If456d2792a5f2793ee6337898aaa4a55637f8522

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 067541dd345d..74e2c09bb5af 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -33,7 +33,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -119,7 +118,6 @@ public:
 void testCommentsImpress();
 void testCommentsCallbacksWriter();
 void testRunMacro();
-void testTranslate();
 void testExtractParameter();
 void testGetSignatureState_NonSigned();
 void testGetSignatureState_Signed();
@@ -167,7 +165,6 @@ public:
 CPPUNIT_TEST(testCommentsImpress);
 CPPUNIT_TEST(testCommentsCallbacksWriter);
 CPPUNIT_TEST(testRunMacro);
-CPPUNIT_TEST(testTranslate);
 CPPUNIT_TEST(testExtractParameter);
 CPPUNIT_TEST(testGetSignatureState_Signed);
 CPPUNIT_TEST(testGetSignatureState_NonSigned);
@@ -,20 +2219,6 @@ void DesktopLOKTest::testRunMacro()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
-void DesktopLOKTest::testTranslate()
-{
-comphelper::LibreOfficeKit::setActive();
-
-LibLibreOffice_Impl aOffice;
-
-// Try translating to a non-existent locale, should return the English 
string
-char *translated = aOffice.m_pOfficeClass->translateGet(, 
STR_DESCRIPTION_FACTORY_WRITER, "svt", "foo");
-CPPUNIT_ASSERT_EQUAL(0, strcmp(translated, "Text Document"));
-free(translated);
-
-comphelper::LibreOfficeKit::setActive(false);
-}
-
 void DesktopLOKTest::testExtractParameter()
 {
 comphelper::LibreOfficeKit::setActive();
@@ -2480,11 +2463,6 @@ void DesktopLOKTest::testInsertCertificatePEM()
 
 namespace {
 
-constexpr size_t classOffset(int i)
-{
-return sizeof(static_cast(nullptr)->nSize) + 
i * sizeof(void*);
-}
-
 constexpr size_t documentClassOffset(int i)
 {
 return sizeof(static_cast(nullptr)->nSize) + i * sizeof(void*);
@@ -2495,21 +2473,6 @@ constexpr size_t documentClassOffset(int i)
 void DesktopLOKTest::testABI()
 {
 // STABLE ABI, NEVER CHANGE (unless there's a very good reason, agreed by 
ESC, etc.)
-
-CPPUNIT_ASSERT_EQUAL(classOffset(0), offsetof(struct _LibreOfficeKitClass, 
destroy));
-CPPUNIT_ASSERT_EQUAL(classOffset(1), offsetof(struct _LibreOfficeKitClass, 
documentLoad));
-CPPUNIT_ASSERT_EQUAL(classOffset(2), offsetof(struct _LibreOfficeKitClass, 
getError));
-CPPUNIT_ASSERT_EQUAL(classOffset(3), offsetof(struct _LibreOfficeKitClass, 
documentLoadWithOptions));
-CPPUNIT_ASSERT_EQUAL(classOffset(4), offsetof(struct _LibreOfficeKitClass, 
freeError));
-CPPUNIT_ASSERT_EQUAL(classOffset(5), offsetof(struct _LibreOfficeKitClass, 
registerCallback));
-CPPUNIT_ASSERT_EQUAL(classOffset(6), offsetof(struct _LibreOfficeKitClass, 
getFilterTypes));
-CPPUNIT_ASSERT_EQUAL(classOffset(7), offsetof(struct _LibreOfficeKitClass, 
setOptionalFeatures));
-CPPUNIT_ASSERT_EQUAL(classOffset(8), offsetof(struct _LibreOfficeKitClass, 
setDocumentPassword));
-CPPUNIT_ASSERT_EQUAL(classOffset(9), offsetof(struct _LibreOfficeKitClass, 
getVersionInfo));
-CPPUNIT_ASSERT_EQUAL(classOffset(10), offsetof(struct 
_LibreOfficeKitClass, runMacro));
-CPPUNIT_ASSERT_EQUAL(classOffset(11), offsetof(struct 
_LibreOfficeKitClass, translateGet));
-CPPUNIT_ASSERT_EQUAL(classOffset(12), offsetof(struct 
_LibreOfficeKitClass, translateNGet));
-
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cf9352f3b2cc..90994a92c257 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1422,8 +1422,6 @@ static void
lo_setDocumentPassword(LibreOfficeKit* pThis,
const char* pPassword);
 static char*   lo_getVersionInfo(LibreOfficeKit* pThis);
 static int lo_runMacro  

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

2018-12-10 Thread Libreoffice Gerrit user
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   37 
 desktop/source/lib/init.cxx |   22 
 include/LibreOfficeKit/LibreOfficeKit.h |   10 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   23 +
 4 files changed, 92 insertions(+)

New commits:
commit 4f1a341bc312673b8d92e4474cc39bc3ab69aa5b
Author: Tor Lillqvist 
AuthorDate: Mon Dec 10 16:12:08 2018 +0200
Commit: Tor Lillqvist 
CommitDate: Mon Dec 10 18:31:18 2018 +0100

Add a localisation API to LibreOfficeKitClass

Combines the LanguageTag::Create() and Translate::get() (or nget())
functionality.

Also add an ABI test for the Kit class in the LibreOfficeKit unit
test, and a test for the translation function.

Change-Id: I78c48a8bbb434d6f204869290822830288022a53
Reviewed-on: https://gerrit.libreoffice.org/64882
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 74e2c09bb5af..067541dd345d 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -118,6 +119,7 @@ public:
 void testCommentsImpress();
 void testCommentsCallbacksWriter();
 void testRunMacro();
+void testTranslate();
 void testExtractParameter();
 void testGetSignatureState_NonSigned();
 void testGetSignatureState_Signed();
@@ -165,6 +167,7 @@ public:
 CPPUNIT_TEST(testCommentsImpress);
 CPPUNIT_TEST(testCommentsCallbacksWriter);
 CPPUNIT_TEST(testRunMacro);
+CPPUNIT_TEST(testTranslate);
 CPPUNIT_TEST(testExtractParameter);
 CPPUNIT_TEST(testGetSignatureState_Signed);
 CPPUNIT_TEST(testGetSignatureState_NonSigned);
@@ -2219,6 +,20 @@ void DesktopLOKTest::testRunMacro()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testTranslate()
+{
+comphelper::LibreOfficeKit::setActive();
+
+LibLibreOffice_Impl aOffice;
+
+// Try translating to a non-existent locale, should return the English 
string
+char *translated = aOffice.m_pOfficeClass->translateGet(, 
STR_DESCRIPTION_FACTORY_WRITER, "svt", "foo");
+CPPUNIT_ASSERT_EQUAL(0, strcmp(translated, "Text Document"));
+free(translated);
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 void DesktopLOKTest::testExtractParameter()
 {
 comphelper::LibreOfficeKit::setActive();
@@ -2463,6 +2480,11 @@ void DesktopLOKTest::testInsertCertificatePEM()
 
 namespace {
 
+constexpr size_t classOffset(int i)
+{
+return sizeof(static_cast(nullptr)->nSize) + 
i * sizeof(void*);
+}
+
 constexpr size_t documentClassOffset(int i)
 {
 return sizeof(static_cast(nullptr)->nSize) + i * sizeof(void*);
@@ -2473,6 +2495,21 @@ constexpr size_t documentClassOffset(int i)
 void DesktopLOKTest::testABI()
 {
 // STABLE ABI, NEVER CHANGE (unless there's a very good reason, agreed by 
ESC, etc.)
+
+CPPUNIT_ASSERT_EQUAL(classOffset(0), offsetof(struct _LibreOfficeKitClass, 
destroy));
+CPPUNIT_ASSERT_EQUAL(classOffset(1), offsetof(struct _LibreOfficeKitClass, 
documentLoad));
+CPPUNIT_ASSERT_EQUAL(classOffset(2), offsetof(struct _LibreOfficeKitClass, 
getError));
+CPPUNIT_ASSERT_EQUAL(classOffset(3), offsetof(struct _LibreOfficeKitClass, 
documentLoadWithOptions));
+CPPUNIT_ASSERT_EQUAL(classOffset(4), offsetof(struct _LibreOfficeKitClass, 
freeError));
+CPPUNIT_ASSERT_EQUAL(classOffset(5), offsetof(struct _LibreOfficeKitClass, 
registerCallback));
+CPPUNIT_ASSERT_EQUAL(classOffset(6), offsetof(struct _LibreOfficeKitClass, 
getFilterTypes));
+CPPUNIT_ASSERT_EQUAL(classOffset(7), offsetof(struct _LibreOfficeKitClass, 
setOptionalFeatures));
+CPPUNIT_ASSERT_EQUAL(classOffset(8), offsetof(struct _LibreOfficeKitClass, 
setDocumentPassword));
+CPPUNIT_ASSERT_EQUAL(classOffset(9), offsetof(struct _LibreOfficeKitClass, 
getVersionInfo));
+CPPUNIT_ASSERT_EQUAL(classOffset(10), offsetof(struct 
_LibreOfficeKitClass, runMacro));
+CPPUNIT_ASSERT_EQUAL(classOffset(11), offsetof(struct 
_LibreOfficeKitClass, translateGet));
+CPPUNIT_ASSERT_EQUAL(classOffset(12), offsetof(struct 
_LibreOfficeKitClass, translateNGet));
+
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 90994a92c257..cf9352f3b2cc 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1422,6 +1422,8 @@ static void
lo_setDocumentPassword(LibreOfficeKit* pThis,
const char* pPassword);
 static char*   

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

2018-11-06 Thread Libreoffice Gerrit user
 desktop/qa/data/signed.odt  |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   50 ++--
 desktop/source/lib/init.cxx |2 +
 3 files changed, 49 insertions(+), 3 deletions(-)

New commits:
commit 28a698db6f604137443053144dde94c9e553c0ef
Author: Tomaž Vajngerl 
AuthorDate: Wed Oct 24 11:29:32 2018 +0200
Commit: Miklos Vajna 
CommitDate: Tue Nov 6 17:20:41 2018 +0100

lok: trigger sign. verification in getSignatureState + update test

As the certificate chain can be added after the document was
opened, we need to trigger signature verification every time the
LOK API method getSignatureState is called.

In addition update the tests so that they check the status of a
document that's not signed, a document that was signed but the
certificate chain is not available so the verification fails and
later adding the certificate chain and the verification returns
an OK status.

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

diff --git a/desktop/qa/data/signed.odt b/desktop/qa/data/signed.odt
new file mode 100644
index ..49bd9dd240fe
Binary files /dev/null and b/desktop/qa/data/signed.odt differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index ab0e98033b55..389d84a0cc31 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -118,7 +118,8 @@ public:
 void testCommentsCallbacksWriter();
 void testRunMacro();
 void testExtractParameter();
-void testGetSignatureState();
+void testGetSignatureState_NonSigned();
+void testGetSignatureState_Signed();
 void testInsertCertificate();
 void testABI();
 
@@ -163,7 +164,8 @@ public:
 CPPUNIT_TEST(testCommentsCallbacksWriter);
 CPPUNIT_TEST(testRunMacro);
 CPPUNIT_TEST(testExtractParameter);
-CPPUNIT_TEST(testGetSignatureState);
+CPPUNIT_TEST(testGetSignatureState_Signed);
+CPPUNIT_TEST(testGetSignatureState_NonSigned);
 CPPUNIT_TEST(testInsertCertificate);
 CPPUNIT_TEST(testABI);
 CPPUNIT_TEST_SUITE_END();
@@ -2246,7 +2248,49 @@ void DesktopLOKTest::testExtractParameter()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
-void DesktopLOKTest::testGetSignatureState()
+void DesktopLOKTest::testGetSignatureState_Signed()
+{
+comphelper::LibreOfficeKit::setActive();
+LibLODocument_Impl* pDocument = loadDoc("signed.odt");
+Scheduler::ProcessEventsToIdle();
+pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument);
+CPPUNIT_ASSERT_EQUAL(int(4), nState);
+
+{
+OUString aCertificateURL;
+createFileURL("rootCA.der", aCertificateURL);
+SvFileStream aCertificateStream(aCertificateURL, StreamMode::READ);
+std::vector aCertificate;
+aCertificate.resize(aCertificateStream.remainingSize());
+aCertificateStream.ReadBytes(aCertificate.data(), 
aCertificateStream.remainingSize());
+
+bool bResult = pDocument->m_pDocumentClass->addCertificate(
+pDocument, aCertificate.data(), 
int(aCertificate.size()));
+CPPUNIT_ASSERT(bResult);
+}
+
+{
+OUString aCertificateURL;
+createFileURL("intermediateRootCA.der", aCertificateURL);
+SvFileStream aCertificateStream(aCertificateURL, StreamMode::READ);
+std::vector aCertificate;
+aCertificate.resize(aCertificateStream.remainingSize());
+aCertificateStream.ReadBytes(aCertificate.data(), 
aCertificateStream.remainingSize());
+
+
+bool bResult = pDocument->m_pDocumentClass->addCertificate(
+pDocument, aCertificate.data(), 
int(aCertificate.size()));
+CPPUNIT_ASSERT(bResult);
+}
+
+nState = pDocument->m_pDocumentClass->getSignatureState(pDocument);
+CPPUNIT_ASSERT_EQUAL(int(1), nState);
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
+void DesktopLOKTest::testGetSignatureState_NonSigned()
 {
 comphelper::LibreOfficeKit::setActive();
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cc49f86e6d85..faf1dfa40936 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3752,6 +3752,8 @@ static int doc_getSignatureState(LibreOfficeKitDocument* 
pThis)
 if (!pObjectShell)
 return int(SignatureState::UNKNOWN);
 
+pObjectShell->RecheckSignature(false);
+
 return int(pObjectShell->GetDocumentSignatureState());
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit offapi/com xmlsecurity/source

2018-10-31 Thread Libreoffice Gerrit user
 desktop/qa/desktop_lib/test_desktop_lib.cxx   |6 -
 desktop/source/lib/init.cxx   |   52 ++
 include/LibreOfficeKit/LibreOfficeKit.h   |5 
 include/LibreOfficeKit/LibreOfficeKit.hxx |   15 ++
 offapi/com/sun/star/xml/crypto/XCertificateCreator.idl|9 +
 xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx |7 +
 xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx |4 
 7 files changed, 92 insertions(+), 6 deletions(-)

New commits:
commit 08c3c504644ee978c2ec75ba083765b6ffddf08c
Author: Tomaž Vajngerl 
AuthorDate: Wed Oct 24 10:56:15 2018 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Oct 31 09:08:20 2018 +0100

lok: new function to add certificate to certificate DB

Also needed to extend XCertificateCreator with a new method
"addDERCertificateToTheDatabase".

Change-Id: I7b4df65365893bd5a0628aeec30b3156584849fe
Reviewed-on: https://gerrit.libreoffice.org/62273
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index aeb4f0692c42..a225fb6ad85d 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2356,11 +2356,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(40), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowExtTextInputEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(41), offsetof(struct 
_LibreOfficeKitDocumentClass, getPartInfo));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(42), offsetof(struct 
_LibreOfficeKitDocumentClass, insertCertificate));
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(43), offsetof(struct 
_LibreOfficeKitDocumentClass, getSignatureState));
-
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(43), offsetof(struct 
_LibreOfficeKitDocumentClass, addCertificate));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), offsetof(struct 
_LibreOfficeKitDocumentClass, getSignatureState));
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1119886763ce..040218c1e314 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -696,6 +696,10 @@ static bool doc_insertCertificate(LibreOfficeKitDocument* 
pThis,
   const unsigned char* pPrivateKeyBinary,
   const int nPrivateKeyBinarySize);
 
+static bool doc_addCertificate(LibreOfficeKitDocument* pThis,
+ const unsigned char* pCertificateBinary,
+ const int nCertificateBinarySize);
+
 static int doc_getSignatureState(LibreOfficeKitDocument* pThis);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
 )
@@ -759,6 +763,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
getPartInfo = doc_getPartInfo;
 
 m_pDocumentClass->insertCertificate = doc_insertCertificate;
+m_pDocumentClass->addCertificate = doc_addCertificate;
 m_pDocumentClass->getSignatureState = doc_getSignatureState;
 
 gDocumentClass = m_pDocumentClass;
@@ -3653,6 +3658,53 @@ static bool 
doc_insertCertificate(LibreOfficeKitDocument* pThis,
 return pObjectShell->SignDocumentContentUsingCertificate(xCertificate);
 }
 
+static bool doc_addCertificate(LibreOfficeKitDocument* pThis,
+  const unsigned char* pCertificateBinary, 
const int nCertificateBinarySize)
+{
+if (!xContext.is())
+return false;
+
+LibLODocument_Impl* pDocument = static_cast(pThis);
+
+if (!pDocument->mxComponent.is())
+return false;
+
+SfxBaseModel* pBaseModel = 
dynamic_cast(pDocument->mxComponent.get());
+if (!pBaseModel)
+return false;
+
+SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
+
+if (!pObjectShell)
+return false;
+
+uno::Reference xSEInitializer = 
xml::crypto::SEInitializer::create(xContext);
+uno::Reference xSecurityContext;
+xSecurityContext = xSEInitializer->createSecurityContext(OUString());
+if (!xSecurityContext.is())
+return false;
+
+uno::Reference xSecurityEnvironment;
+xSecurityEnvironment = xSecurityContext->getSecurityEnvironment();
+uno::Reference 
xCertificateCreator(xSecurityEnvironment, uno::UNO_QUERY);
+
+if (!xCertificateCreator.is())
+return false;
+
+uno::Sequence aCertificateSequence(nCertificateBinarySize);
+std::copy(pCertificateBinary, pCertificateBinary + 

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

2018-10-29 Thread Libreoffice Gerrit user
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   35 +++-
 desktop/source/lib/init.cxx |   19 ---
 include/LibreOfficeKit/LibreOfficeKit.h |4 ++-
 include/LibreOfficeKit/LibreOfficeKit.hxx   |8 --
 4 files changed, 49 insertions(+), 17 deletions(-)

New commits:
commit c2ceb1f54e85ebc8b38df3f2e4d1113a2fe1cc64
Author: Tomaž Vajngerl 
AuthorDate: Thu Oct 18 10:35:25 2018 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Oct 29 19:35:04 2018 +0100

lok: create certificate and private key with insertCertificate

Change-Id: Ie114068d9aec5259f9f7ed395c5dfeecf8bb787d
Reviewed-on: https://gerrit.libreoffice.org/61915
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index bd8b08f9fac8..aeb4f0692c42 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2261,24 +2261,37 @@ void DesktopLOKTest::testInsertCertificate()
 {
 comphelper::LibreOfficeKit::setActive();
 
+// Load the document, save it into a temp file and load that file again
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+utl::TempFile aTempFile;
+aTempFile.EnableKillingFile();
+CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, 
aTempFile.GetURL().toUtf8().getStr(), "odt", nullptr));
+closeDoc();
+
+mxComponent = loadFromDesktop(aTempFile.GetURL(), 
"com.sun.star.text.TextDocument");
+pDocument = new LibLODocument_Impl(mxComponent);
 
 Scheduler::ProcessEventsToIdle();
 CPPUNIT_ASSERT(mxComponent.is());
 pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
 
-OUString aFileURL;
-createFileURL("certificate.der", aFileURL);
-
-SvFileStream aStream(aFileURL, StreamMode::READ);
-sal_uInt64 nSize = aStream.remainingSize();
-
+OUString aCertificateURL;
+createFileURL("certificate.der", aCertificateURL);
+SvFileStream aCertificateStream(aCertificateURL, StreamMode::READ);
 std::vector aCertificate;
-aCertificate.resize(nSize);
-aStream.ReadBytes(aCertificate.data(), nSize);
-
-bool bResult = pDocument->m_pDocumentClass->insertCertificate(pDocument, 
aCertificate.data(), int(aCertificate.size()));
-CPPUNIT_ASSERT(bResult);
+aCertificate.resize(aCertificateStream.remainingSize());
+aCertificateStream.ReadBytes(aCertificate.data(), 
aCertificateStream.remainingSize());
+
+OUString aPrivateKeyURL;
+createFileURL("pkey.der", aPrivateKeyURL);
+SvFileStream aPrivateKeyStream(aPrivateKeyURL, StreamMode::READ);
+std::vector aPrivateKey;
+aPrivateKey.resize(aPrivateKeyStream.remainingSize());
+aPrivateKeyStream.ReadBytes(aPrivateKey.data(), 
aPrivateKeyStream.remainingSize());
+
+pDocument->m_pDocumentClass->insertCertificate(pDocument,
+aCertificate.data(), int(aCertificate.size()),
+aPrivateKey.data(), int(aPrivateKey.size()));
 
 comphelper::LibreOfficeKit::setActive(false);
 }
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2a13775dcc64..b08c6d694f4a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -76,6 +76,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -691,7 +692,9 @@ static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, 
int nPart);
 
 static bool doc_insertCertificate(LibreOfficeKitDocument* pThis,
   const unsigned char* pCertificateBinary,
-  const int pCertificateBinarySize);
+  const int nCertificateBinarySize,
+  const unsigned char* pPrivateKeyBinary,
+  const int nPrivateKeyBinarySize);
 
 static int doc_getSignatureState(LibreOfficeKitDocument* pThis);
 
@@ -3601,7 +3604,9 @@ static void doc_postWindow(LibreOfficeKitDocument* 
/*pThis*/, unsigned nLOKWindo
 }
 
 // CERTIFICATE AND DOCUMENT SIGNING
-static bool doc_insertCertificate(LibreOfficeKitDocument* /*pThis*/, const 
unsigned char* pCertificateBinary, const int nCertificateBinarySize)
+static bool doc_insertCertificate(LibreOfficeKitDocument* /*pThis*/,
+  const unsigned char* pCertificateBinary, 
const int nCertificateBinarySize,
+  const unsigned char* pPrivateKeyBinary, 
const int nPrivateKeySize)
 {
 if (!xContext.is())
 return false;
@@ -3614,11 +3619,19 @@ static bool 
doc_insertCertificate(LibreOfficeKitDocument* /*pThis*/, const unsig
 
 uno::Reference xSecurityEnvironment;
 xSecurityEnvironment = xSecurityContext->getSecurityEnvironment();
+uno::Reference 
xCertificateCreator(xSecurityEnvironment, uno::UNO_QUERY);
+
+if (!xCertificateCreator.is())
+return false;
 
 

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

2018-10-28 Thread Libreoffice Gerrit user
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 
 desktop/source/lib/init.cxx |   69 
 include/LibreOfficeKit/LibreOfficeKit.h |   10 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   19 
 include/sfx2/docfile.hxx|4 
 include/sfx2/objsh.hxx  |3 
 sfx2/source/doc/docfile.cxx |  117 
 sfx2/source/doc/objserv.cxx |   79 ++
 8 files changed, 304 insertions(+), 1 deletion(-)

New commits:
commit 23a2312344ac961ead9ee14140c0b3e879bb7a41
Author: Tomaž Vajngerl 
AuthorDate: Mon Oct 15 10:09:15 2018 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Oct 28 21:29:19 2018 +0100

lokit: add funct. to insert, sign and verify signature

A lot of signing code paths trigger a GUI dialog (to select the
certificate for example) which aren't acceptable when triggering
through the LOKit. This code paths needed to be duplicated and
reworked to not trigger any GUI action.

Change-Id: I2f0d6038fb1bcd00adcdf86e432f9df8858cc21c
Reviewed-on: https://gerrit.libreoffice.org/61780
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 69f2b3ac2bfb..9a8d7b88b0b7 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2299,10 +2299,12 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(39), offsetof(struct 
_LibreOfficeKitDocumentClass, setViewLanguage));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(40), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowExtTextInputEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(41), offsetof(struct 
_LibreOfficeKitDocumentClass, getPartInfo));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(42), offsetof(struct 
_LibreOfficeKitDocumentClass, insertCertificate));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(43), offsetof(struct 
_LibreOfficeKitDocumentClass, getSignatureState));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(42), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a2182e9ea2a8..2a13775dcc64 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -73,6 +73,13 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -682,6 +689,12 @@ static void doc_postWindow(LibreOfficeKitDocument* pThis, 
unsigned nLOKWindowId,
 
 static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart);
 
+static bool doc_insertCertificate(LibreOfficeKitDocument* pThis,
+  const unsigned char* pCertificateBinary,
+  const int pCertificateBinarySize);
+
+static int doc_getSignatureState(LibreOfficeKitDocument* pThis);
+
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
 )
 : mxComponent(xComponent)
 {
@@ -742,6 +755,9 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
getPartInfo = doc_getPartInfo;
 
+m_pDocumentClass->insertCertificate = doc_insertCertificate;
+m_pDocumentClass->getSignatureState = doc_getSignatureState;
+
 gDocumentClass = m_pDocumentClass;
 }
 pClass = m_pDocumentClass.get();
@@ -3584,6 +3600,59 @@ static void doc_postWindow(LibreOfficeKitDocument* 
/*pThis*/, unsigned nLOKWindo
 }
 }
 
+// CERTIFICATE AND DOCUMENT SIGNING
+static bool doc_insertCertificate(LibreOfficeKitDocument* /*pThis*/, const 
unsigned char* pCertificateBinary, const int nCertificateBinarySize)
+{
+if (!xContext.is())
+return false;
+
+uno::Reference xSEInitializer = 
xml::crypto::SEInitializer::create(xContext);
+uno::Reference xSecurityContext;
+xSecurityContext = xSEInitializer->createSecurityContext(OUString());
+if (!xSecurityContext.is())
+return false;
+
+uno::Reference xSecurityEnvironment;
+xSecurityEnvironment = xSecurityContext->getSecurityEnvironment();
+
+uno::Sequence aCertificateSequence(nCertificateBinarySize);
+std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, 
aCertificateSequence.begin());
+
+uno::Reference xCertificate = 
xSecurityEnvironment->createCertificateFromRaw(aCertificateSequence);
+
+if (!xCertificate.is())
+return false;
+
+printf("CERTIFICATE\n\tIssuerName: %s \n\tSubjectName: %s\n\tPK %s\n\n",
+xCertificate->getIssuerName().toUtf8().getStr(),
+xCertificate->getSubjectName().toUtf8().getStr(),
+

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/vcl sc/inc sc/source

2018-04-03 Thread Marco Cecchetti
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 ++-
 desktop/source/lib/init.cxx |   22 ++
 include/LibreOfficeKit/LibreOfficeKit.h |3 +++
 include/vcl/ITiledRenderable.hxx|9 +
 sc/inc/docuno.hxx   |3 +++
 sc/source/ui/unoobj/docuno.cxx  |   12 
 6 files changed, 51 insertions(+), 1 deletion(-)

New commits:
commit 8ffbb86b30e2c1674ba32e9e29447cbea3585d03
Author: Marco Cecchetti 
Date:   Thu Feb 1 12:17:45 2018 +0100

lok - calc: add support for show/hide tabs in online

Change-Id: Ibd061414a0c3a5fad83d03f7047831cef62076d2
Reviewed-on: https://gerrit.libreoffice.org/49083
Tested-by: Jenkins 
Reviewed-by: Marco Cecchetti 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 0714b6804ca0..51e048d04af4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2298,10 +2298,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(38), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowMouseEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(39), offsetof(struct 
_LibreOfficeKitDocumentClass, setViewLanguage));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(40), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowExtTextInputEvent));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(41), offsetof(struct 
_LibreOfficeKitDocumentClass, getPartInfo));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(41), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(42), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5959f4237738..67beb36d3a56 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -579,6 +579,8 @@ static void doc_paintWindow(LibreOfficeKitDocument* pThis, 
unsigned nLOKWindowId
 
 static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned 
nLOKWindowId, int nAction);
 
+static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart);
+
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
 )
 : mxComponent(xComponent)
 {
@@ -634,6 +636,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
setViewLanguage = doc_setViewLanguage;
 
+m_pDocumentClass->getPartInfo = doc_getPartInfo;
+
 gDocumentClass = m_pDocumentClass;
 }
 pClass = m_pDocumentClass.get();
@@ -1856,6 +1860,24 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, 
int nPart)
 pDoc->setPart( nPart );
 }
 
+static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart)
+{
+SolarMutexGuard aGuard;
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+return nullptr;
+}
+
+OUString aPartInfo = pDoc->getPartInfo( nPart );
+OString aString = OUStringToOString(aPartInfo, RTL_TEXTENCODING_UTF8);
+
+char* pMemory = static_cast(malloc(aString.getLength() + 1));
+strcpy(pMemory, aString.getStr());
+return pMemory;
+}
+
 static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis)
 {
 SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index d465d541b0e0..0799584d3097 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -306,6 +306,9 @@ struct _LibreOfficeKitDocumentClass
  int nType,
  const char* pText);
 
+/// @see lok::Document::getPartInfo().
+char* (*getPartInfo) (LibreOfficeKitDocument* pThis, int nPart);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index e25cdd67506a..0b6b52373316 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -360,6 +360,15 @@ public:
 {
 return OUString();
 }
+
+/*
+ * Used for sheets in spreadsheet documents.
+ */
+virtual OUString getPartInfo(int /*nPart*/)
+{
+return OUString();
+}
+
 };
 } // namespace vcl
 
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 5e1ce12bd37a..f86c9048fe03 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -313,6 +313,9 @@ public:
 /// @see vcl::ITiledRenderable::getParts().
 virtual int getParts() override;
 
+/// @see vcl::ITiledRenderable::getPartInfo().
+virtual OUString 

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/vcl sw/inc sw/qa sw/source vcl/source

2018-02-07 Thread Pranav Kant
 desktop/qa/desktop_lib/test_desktop_lib.cxx|3 +-
 desktop/source/lib/init.cxx|   19 ++
 include/LibreOfficeKit/LibreOfficeKit.h|5 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx  |   11 
 include/LibreOfficeKit/LibreOfficeKitEnums.h   |   11 
 include/vcl/ITiledRenderable.hxx   |7 +
 include/vcl/vclevent.hxx   |2 +
 include/vcl/window.hxx |1 
 sw/inc/unotxdoc.hxx|2 +
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   33 +
 sw/source/uibase/uno/unotxdoc.cxx  |   22 
 vcl/source/window/window.cxx   |   20 ++-
 12 files changed, 134 insertions(+), 2 deletions(-)

New commits:
commit 7f9f58f3a304733f7089719a5a65eef8c68c2b8d
Author: Pranav Kant 
Date:   Wed Feb 7 17:19:58 2018 +0530

sw lok: IME support + unit test

Change-Id: I557493db23dfa3529606050c86161628dbd722e7
Reviewed-on: https://gerrit.libreoffice.org/49354
Reviewed-by: pranavk 
Tested-by: pranavk 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 4488aa8c155c..4d2d50644b16 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2291,10 +2291,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(37), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowKeyEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(38), offsetof(struct 
_LibreOfficeKitDocumentClass, postWindowMouseEvent));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(39), offsetof(struct 
_LibreOfficeKitDocumentClass, setViewLanguage));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(40), offsetof(struct 
_LibreOfficeKitDocumentClass, postExtTextInputEvent));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(40), sizeof(struct 
_LibreOfficeKitDocumentClass));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(41), sizeof(struct 
_LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ab7b72d526dc..2165a781725a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -540,6 +540,9 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
  int nType,
  int nCharCode,
  int nKeyCode);
+static void doc_postExtTextInputEvent(LibreOfficeKitDocument* pThis,
+  int nType,
+  const char* pText);
 static void doc_postWindowKeyEvent(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
int nType,
@@ -633,6 +636,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
initializeForRendering = doc_initializeForRendering;
 m_pDocumentClass->registerCallback = doc_registerCallback;
 m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
+m_pDocumentClass->postExtTextInputEvent = doc_postExtTextInputEvent;
 m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent;
 m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
 m_pDocumentClass->postWindowMouseEvent = doc_postWindowMouseEvent;
@@ -2288,9 +2292,24 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* 
pThis, int nType, int nChar
 gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
 return;
 }
+
 pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
 }
 
+static void doc_postExtTextInputEvent(LibreOfficeKitDocument* pThis, int 
nType, const char* pText)
+{
+SolarMutexGuard aGuard;
+
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+return;
+}
+
+pDoc->postExtTextInputEvent(nType, OUString::fromUtf8(OString(pText, 
strlen(pText;
+}
+
 static void doc_postWindowKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned 
nLOKWindowId, int nType, int nCharCode, int nKeyCode)
 {
 SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index d42bd3434689..ebc112fb7bd5 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -300,6 +300,11 @@ struct _LibreOfficeKitDocumentClass
 /// @see lok::Document::setViewLanguage().
 void (*setViewLanguage) (LibreOfficeKitDocument* pThis, int nId, const 
char* language);
 
+/// @see lok::Document::postExtTextInputEvent
+void 

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

2018-01-18 Thread Henry Castro
 desktop/qa/desktop_lib/test_desktop_lib.cxx|1 
 desktop/source/lib/init.cxx|   29 +++
 sfx2/source/control/unoctitm.cxx   |   25 ++--
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   27 +-
 sw/source/uibase/shells/textsh1.cxx|   37 +++--
 5 files changed, 101 insertions(+), 18 deletions(-)

New commits:
commit 252ce90e39648c47bcfdb39547d0ac82bacdbae6
Author: Henry Castro 
Date:   Tue Jan 9 22:17:23 2018 -0400

sw lokit: add page syles to header & footer

Change-Id: I3c0b0603d1e03f1cc19af4324dd2b909320d9d4a
Reviewed-on: https://gerrit.libreoffice.org/47687
Tested-by: Jenkins 
Reviewed-by: Henry Castro 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d5d7cb26f18b..4488aa8c155c 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -309,6 +309,7 @@ void DesktopLOKTest::testGetStyles()
 rPair.first != "CellStyles" &&
 rPair.first != "ShapeStyles" &&
 rPair.first != "TableStyles" &&
+rPair.first != "HeaderFooter" &&
 rPair.first != "Commands")
 {
 CPPUNIT_FAIL("Unknown style family: " + rPair.first);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4c0b96b85951..126861d7877a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2769,6 +2769,35 @@ static char* getStyles(LibreOfficeKitDocument* pThis, 
const char* pCommand)
 aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren);
 }
 
+// Header & Footer Styles
+{
+OUString sName;
+bool bIsPhysical;
+boost::property_tree::ptree aChild;
+uno::Reference xProperty;
+boost::property_tree::ptree aChildren;
+uno::Reference xContainer;
+
+if (xStyleFamilies->getByName("PageStyles") >>= xContainer)
+{
+uno::Sequence aSeqNames = xContainer->getElementNames();
+for (sal_Int32 itName = 0; itName < aSeqNames.getLength(); 
itName++)
+{
+sName = aSeqNames[itName];
+xProperty.set(xContainer->getByName(sName), uno::UNO_QUERY);
+if (xProperty.is() && 
(xProperty->getPropertyValue("IsPhysical") >>= bIsPhysical) && bIsPhysical)
+{
+xProperty->getPropertyValue("DisplayName") >>= sName;
+aChild.put("", sName.toUtf8());
+aChildren.push_back(std::make_pair("", aChild));
+}
+else
+bIsPhysical = false;
+}
+aValues.add_child("HeaderFooter", aChildren);
+}
+}
+
 {
 boost::property_tree::ptree aCommandList;
 
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 63df319437a5..2193914465f2 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1019,9 +1019,7 @@ static void InterceptLOKStateChangeEvent(const 
SfxViewFrame* pViewFrame, const c
 aEvent.FeatureURL.Path == "AlignLeft" ||
 aEvent.FeatureURL.Path == "AlignHorizontalCenter" ||
 aEvent.FeatureURL.Path == "AlignRight" ||
-aEvent.FeatureURL.Path == "DocumentRepair" ||
-aEvent.FeatureURL.Path == "InsertPageHeader" ||
-aEvent.FeatureURL.Path == "InsertPageFooter")
+aEvent.FeatureURL.Path == "DocumentRepair")
 {
 bool bTemp = false;
 aEvent.State >>= bTemp;
@@ -1197,6 +1195,27 @@ static void InterceptLOKStateChangeEvent(const 
SfxViewFrame* pViewFrame, const c
 }
 }
 }
+else if (aEvent.FeatureURL.Path == "InsertPageHeader" ||
+ aEvent.FeatureURL.Path == "InsertPageFooter")
+{
+if (aEvent.IsEnabled)
+{
+css::uno::Sequence< OUString > aSeq;
+if (aEvent.State >>= aSeq)
+{
+aBuffer.append(u'{');
+for (sal_Int32 itSeq = 0; itSeq < aSeq.getLength(); itSeq++)
+{
+aBuffer.append("\"" + aSeq[itSeq]);
+if (itSeq != aSeq.getLength() - 1)
+aBuffer.append("\":true,");
+else
+aBuffer.append("\":true");
+}
+aBuffer.append(u'}');
+}
+}
+}
 else
 {
 return;
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 3dd1335e50f9..3a9c1c6f9985 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

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

2017-12-04 Thread Pranav Kant
 desktop/qa/desktop_lib/test_desktop_lib.cxx |2 ++
 desktop/source/lib/init.cxx |6 ++
 2 files changed, 8 insertions(+)

New commits:
commit 1fdd9b3fbfac165e944516d87f02d2f9ff6e3a58
Author: Pranav Kant 
Date:   Thu Nov 30 01:22:33 2017 +0530

lokdialog: Execute all UNO commands asynchronously for LOK

Especially in case of dialogs, Online cannot afford to wait till the
call to UNO command returns as the same thread is responsible for doing
many more tasks as well.

And just adding this check doesn't seem to have any repurcussions, so I
guess we are fine.

Change-Id: Iac7c1413d90e8a264502dcf2bc280e09fd52683b
Reviewed-on: https://gerrit.libreoffice.org/45527
Tested-by: Jenkins 
Reviewed-by: Jan Holesovsky 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2a995277081a..81a9f11e7eb5 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -529,6 +529,7 @@ void DesktopLOKTest::testPasteWriter()
 CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, 
"text/plain;charset=utf-8", aText.getStr(), aText.getLength()));
 
 pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, 
false);
+Scheduler::ProcessEventsToIdle();
 char* pText = pDocument->pClass->getTextSelection(pDocument, 
"text/plain;charset=utf-8", nullptr);
 CPPUNIT_ASSERT_EQUAL(OString("hello"), OString(pText));
 free(pText);
@@ -902,6 +903,7 @@ void DesktopLOKTest::testSheetOperations()
 pDocument->pClass->postUnoCommand(pDocument, ".uno:Remove",
   "{ \"Index\": { \"type\": \"long\", \"value\": 3 } }", false);
 
+Scheduler::ProcessEventsToIdle();
 CPPUNIT_ASSERT_EQUAL(pDocument->pClass->getParts(pDocument), 6);
 
 std::vector aExpected = { "FirstSheet", "Renamed", "Sheet3", 
"Sheet4", "Sheet5", "LastSheet" };
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c4b922c75332..1c4922eacacf 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2329,6 +2329,12 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* 
pThis, const char* pComma
 LibLODocument_Impl* pDocument = static_cast(pThis);
 
 std::vector 
aPropertyValuesVector(jsonToPropertyValuesVector(pArguments));
+
+beans::PropertyValue aSynchronMode;
+aSynchronMode.Name = "SynchronMode";
+aSynchronMode.Value <<= false;
+aPropertyValuesVector.push_back(aSynchronMode);
+
 int nView = SfxLokHelper::getView();
 if (nView < 0)
 return;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: desktop/qa desktop/source include/vcl sc/inc sc/qa sc/source

2017-05-16 Thread Marco Cecchetti
 desktop/qa/desktop_lib/test_desktop_lib.cxx  |4 -
 desktop/source/lib/init.cxx  |   16 +++
 include/vcl/ITiledRenderable.hxx |7 +++
 sc/inc/docuno.hxx|3 +
 sc/inc/postit.hxx|   15 ---
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   20 +
 sc/source/core/data/postit.cxx   |   21 ++
 sc/source/ui/docshell/docfunc.cxx|4 +
 sc/source/ui/docshell/docsh4.cxx |6 +-
 sc/source/ui/unoobj/docuno.cxx   |   55 +--
 sc/source/ui/view/cellsh1.cxx|   45 ++
 11 files changed, 150 insertions(+), 46 deletions(-)

New commits:
commit cb33a0fb8b7d9fcdf7ef26ac690842574d359f4b
Author: Marco Cecchetti 
Date:   Tue Apr 25 19:25:11 2017 +0200

lok: sc: misplaced comment mark on inserting/deleting/resizing row/col

A unique id has been introduced, in a similar way of what occurs in
Writer.

Change-Id: I7b2ef694867fb4184c4cfc616fe1c8f12da3b676
Reviewed-on: https://gerrit.libreoffice.org/36962
Tested-by: Jenkins 
Reviewed-by: Jan Holesovsky 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 8d85a078efc0..79ec0ba54e3b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1933,14 +1933,14 @@ void DesktopLOKTest::testCommentsCalc()
 {
 case 0:
 {
-CPPUNIT_ASSERT_EQUAL(std::string("Sheet5.G15"), 
rComment.second.get("id"));
+CPPUNIT_ASSERT_EQUAL(std::string("4"), 
rComment.second.get("tab"));
 CPPUNIT_ASSERT_EQUAL(std::string("Comment1"), 
rComment.second.get("text"));
 CPPUNIT_ASSERT_EQUAL(std::string("7650, 3570, 1274, 254"), 
rComment.second.get("cellPos"));
 }
 break;
 case 1:
 {
-CPPUNIT_ASSERT_EQUAL(std::string("Sheet5.H18"), 
rComment.second.get("id"));
+CPPUNIT_ASSERT_EQUAL(std::string("4"), 
rComment.second.get("tab"));
 CPPUNIT_ASSERT_EQUAL(std::string("Comment2"), 
rComment.second.get("text"));
 CPPUNIT_ASSERT_EQUAL(std::string("8925, 4335, 1274, 254"), 
rComment.second.get("cellPos"));
 }
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b090ae4e377c..ebfe46a7efe3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2049,6 +2049,18 @@ static char* getPostIts(LibreOfficeKitDocument* pThis)
 return strdup(aComments.toUtf8().getStr());
 }
 
+/// Returns the JSON representation of the positions of all the comments in 
the document
+static char* getPostItsPos(LibreOfficeKitDocument* pThis)
+{
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+return nullptr;
+}
+OUString aComments = pDoc->getPostItsPos();
+return strdup(aComments.toUtf8().getStr());
+}
 
 static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int 
nCharCode, int nKeyCode)
 {
@@ -2653,6 +2665,10 @@ static char* 
doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
 {
 return getPostIts(pThis);
 }
+else if (aCommand == ".uno:ViewAnnotationsPosition")
+{
+return getPostItsPos(pThis);
+}
 else if (aCommand.startsWith(aViewRowColumnHeaders))
 {
 ITiledRenderable* pDoc = getTiledRenderable(pThis);
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 9645d2392743..5c5d8339b8a1 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -226,6 +226,13 @@ public:
 {
 return OUString();
 }
+
+/// Implementation for
+/// lok::Document::getCommandValues(".uno:ViewAnnotationsPosition");
+virtual OUString getPostItsPos()
+{
+return OUString();
+}
 };
 
 } // namespace vcl
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 55f6afb99858..00ff88999bd0 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -359,6 +359,9 @@ public:
 
 /// @see vcl::ITiledRenderable::getPostIts().
 OUString getPostIts() override;
+
+/// @see vcl::ITiledRenderable::getPostItsPos().
+OUString getPostItsPos() override;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper<
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index d9584e1e7005..ba7d2705fb04 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -160,13 +160,14 @@ struct SC_DLLPUBLIC ScNoteData
 class SC_DLLPUBLIC ScPostIt
 {
 public:
+static sal_uInt32 mnLastPostItId;
 
 /** Creates an empty note and its caption object and places it according to
 

[Libreoffice-commits] core.git: desktop/qa desktop/source desktop/test

2017-03-25 Thread Andrea Gelmini
 desktop/qa/desktop_lib/test_desktop_lib.cxx   |4 
++--
 desktop/source/app/dispatchwatcher.hxx|2 +-
 desktop/source/app/officeipcthread.cxx|2 +-
 desktop/source/deployment/inc/lockfile.hxx|2 +-
 desktop/source/deployment/manager/dp_activepackages.hxx   |2 +-
 desktop/source/deployment/manager/dp_extensionmanager.cxx |2 +-
 desktop/source/deployment/manager/dp_manager.cxx  |2 +-
 desktop/source/deployment/misc/dp_misc.cxx|2 +-
 desktop/source/deployment/misc/dp_ucb.cxx |2 +-
 desktop/source/deployment/registry/configuration/dp_configuration.cxx |2 +-
 desktop/source/deployment/registry/package/dp_package.cxx |2 +-
 desktop/source/deployment/registry/script/dp_script.cxx   |2 +-
 desktop/source/deployment/registry/sfwk/dp_sfwk.cxx   |2 +-
 desktop/source/lib/init.cxx   |4 
++--
 desktop/source/pkgchk/unopkg/unopkg_app.cxx   |2 +-
 desktop/test/deployment/update/license/readme.txt |2 +-
 desktop/test/deployment/update/wrong_url/readme.txt   |2 +-
 17 files changed, 19 insertions(+), 19 deletions(-)

New commits:
commit b93201ffc6ab4908e25bbfbf4337354c09b5c07a
Author: Andrea Gelmini 
Date:   Fri Mar 24 10:40:07 2017 +0100

Fix typos

Change-Id: I4b2eac5c999771b10e65fedebdab1d4ef435b367
Reviewed-on: https://gerrit.libreoffice.org/35626
Reviewed-by: Julien Nabet 
Tested-by: Julien Nabet 
Tested-by: Jenkins 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index bbf8ac91afc7..aac2b3ad078b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -459,7 +459,7 @@ void DesktopLOKTest::testPaintTile()
 int nTileWidth = 1000;
 int nTileHeight = 3000;
 
-// This used to crash: painTile() implementation did not handle
+// This used to crash: paintTile() implementation did not handle
 // nCanvasWidth != nCanvasHeight correctly, as usually both are just always
 // 256.
 pDocument->pClass->paintTile(pDocument, aBuffer.data(), nCanvasWidth, 
nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
@@ -1362,7 +1362,7 @@ void DesktopLOKTest::testNotificationCompression()
 handler->queue(LOK_CALLBACK_MOUSE_POINTER, "text"); // Should be dropped.
 handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15, 25, 15, 10"); // 
Superseded.
 handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15, 25, 15, 10"); // 
Superseded.
-handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15, 25, 15, 10"); // 
Superseedd.
+handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15, 25, 15, 10"); // 
Superseded.
 handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15, 25, 15, 10"); // 
Should be dropped.
 handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15, 25, 15, 10"); // 
Should be dropped.
 handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // 7
diff --git a/desktop/source/app/dispatchwatcher.hxx 
b/desktop/source/app/dispatchwatcher.hxx
index 45f66201c83b..b8a70c08e33b 100644
--- a/desktop/source/app/dispatchwatcher.hxx
+++ b/desktop/source/app/dispatchwatcher.hxx
@@ -34,7 +34,7 @@ namespace desktop
 /*
 Class for controls dispatching of command URL through office command line. 
There
 are "dangerous" command URLs, that can result in a running office without 
UI. To prevent
-this situation the implementation surveille all dispatches and looks for 
an open task if
+this situation the implementation monitors all dispatches and looks for an 
open task if
 there is arose a problem. If there is none the office will be shutdown to 
prevent a
 running office without UI.
 */
diff --git a/desktop/source/app/officeipcthread.cxx 
b/desktop/source/app/officeipcthread.cxx
index d431e299f10a..f48260507dca 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -1198,7 +1198,7 @@ void PipeIpcThread::execute()
 // we might have decided to shutdown while we were sleeping
 if (!RequestHandler::pGlobal.is()) return;
 
-// only lock the mutex when processing starts, othewise we 
deadlock when the office goes
+// only lock the mutex when processing starts, otherwise we 
deadlock when the office goes
 // down during wait
 osl::ClearableMutexGuard aGuard( RequestHandler::GetMutex() );
 
diff --git a/desktop/source/deployment/inc/lockfile.hxx 
b/desktop/source/deployment/inc/lockfile.hxx
index f3f1da28d07a..68dbb8ee0df2 100644
--- 

[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 

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

2017-02-01 Thread Caolán McNamara
 desktop/qa/desktop_lib/test_desktop_lib.cxx |8 
 desktop/source/lib/init.cxx |2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 2562ad74d1945322e9fdf8af5fc0b1f17e854c9b
Author: Caolán McNamara 
Date:   Wed Feb 1 10:22:17 2017 +

stoi not a member of std under android toolchain

Change-Id: I73a4e7894e33dd95ca50ea25f5f95bf94a43531e

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 4312089..175947b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -863,13 +863,13 @@ void DesktopLOKTest::testSheetSelections()
 {
 char* pUsedMimeType = nullptr;
 char* pCopiedContent = pDocument->pClass->getTextSelection(pDocument, 
nullptr, );
-std::vector aExpected = {5, 6, 7, 8, 9};
+std::vector aExpected = {5, 6, 7, 8, 9};
 std::istringstream iss(pCopiedContent);
 for (size_t i = 0; i < aExpected.size(); i++)
 {
 std::string token;
 iss >> token;
-CPPUNIT_ASSERT_EQUAL(aExpected[i], std::stoi(token));
+CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 
10));
 }
 
 free(pUsedMimeType);
@@ -909,13 +909,13 @@ void DesktopLOKTest::testSheetSelections()
 {
 char* pUsedMimeType  = nullptr;
 char* pCopiedContent = pDocument->pClass->getTextSelection(pDocument, 
nullptr, );
-std::vector aExpected = { 8 };
+std::vector aExpected = { 8 };
 std::istringstream iss(pCopiedContent);
 for (size_t i = 0; i < aExpected.size(); i++)
 {
 std::string token;
 iss >> token;
-CPPUNIT_ASSERT_EQUAL(aExpected[i], std::stoi(token));
+CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 
10));
 }
 
 free(pUsedMimeType);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d879798..c11e161 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -463,7 +463,7 @@ int lcl_getViewId(const std::string& payload)
 }
 
 if (numberPos < payload.length() && payload[numberPos] >= '0' && 
payload[numberPos] <= '9')
-return std::stoi(payload.substr(numberPos));
+return strtol(payload.substr(numberPos).c_str(), nullptr, 10);
 
 return 0;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-01-16 Thread Ashod Nakashian
 desktop/qa/desktop_lib/test_desktop_lib.cxx |  174 +-
 desktop/source/lib/init.cxx |  183 +++-
 include/sfx2/lokhelper.hxx  |4 
 3 files changed, 270 insertions(+), 91 deletions(-)

New commits:
commit 3db1ce30ab235ad22aed71c22e4f6f52b7b88829
Author: Ashod Nakashian 
Date:   Tue Dec 6 00:42:58 2016 -0500

Lok: improved tile invalidation compression

Handle corner cases better and eliminate
invalid rects and out-of-bounds coordinates.

Change-Id: Ib9247ae4f0306cf68937cd2678f6386fe7710eec
Reviewed-on: https://gerrit.libreoffice.org/31665
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 9219a17..59bf620 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1295,29 +1295,29 @@ void DesktopLOKTest::testNotificationCompression()
 std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
 
 handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // 0
-handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Superseeded.
+handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15, 25, 15, 10"); // 
Superseeded.
 handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // Should be 
dropped.
-handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 
Superseeded.
-handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Should be 
dropped.
+handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15, 25, 15, 10"); // 1
+handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15, 25, 15, 10"); // Should 
be dropped.
 handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // Superseeded.
 handler->queue(LOK_CALLBACK_STATE_CHANGED, ""); // 2
 handler->queue(LOK_CALLBACK_STATE_CHANGED, ".uno:Bold"); // 3
 handler->queue(LOK_CALLBACK_STATE_CHANGED, ""); // 4
 handler->queue(LOK_CALLBACK_MOUSE_POINTER, "text"); // 5
-handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 6
-handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // Should be 
dropped.
+handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15, 25, 15, 10"); // Should 
be dropped.
+handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15, 25, 15, 10"); // Should 
be dropped.
 handler->queue(LOK_CALLBACK_MOUSE_POINTER, "text"); // Should be dropped.
-handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 
Superseeded.
-handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 
Superseeded.
-handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Superseedd.
-handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 
Should be dropped.
-handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // Should 
be dropped.
+handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15, 25, 15, 10"); // 
Superseeded.
+handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15, 25, 15, 10"); // 
Superseeded.
+handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15, 25, 15, 10"); // 
Superseedd.
+handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15, 25, 15, 10"); // 
Should be dropped.
+handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15, 25, 15, 10"); // 
Should be dropped.
 handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // 7
-handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 8
-handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 9
-handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // 10
+handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15, 25, 15, 10"); // 8
+handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15, 25, 15, 10"); // 9
+handler->queue(LOK_CALLBACK_CELL_CURSOR, "15, 25, 15, 10"); // 10
 handler->queue(LOK_CALLBACK_CURSOR_VISIBLE, ""); // 11
-handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // Should be 
dropped.
+handler->queue(LOK_CALLBACK_CELL_CURSOR, "15, 25, 15, 10"); // Should be 
dropped.
 handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // 12
 handler->queue(LOK_CALLBACK_SET_PART, "1"); // 13
 handler->queue(LOK_CALLBACK_STATE_CHANGED, ".uno:AssignLayout=20"); // 
Superseeded
@@ -1334,6 +1334,9 @@ void DesktopLOKTest::testNotificationCompression()
 CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, 
(int)std::get<0>(notifs[i]));
 CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++]));
 
+CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, 
(int)std::get<0>(notifs[i]));
+CPPUNIT_ASSERT_EQUAL(std::string("15, 25, 15, 10"), 
std::get<1>(notifs[i++]));
+
 CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, 
(int)std::get<0>(notifs[i]));
 

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

2016-12-02 Thread Ashod Nakashian
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   29 
 desktop/source/lib/init.cxx |   16 ---
 2 files changed, 42 insertions(+), 3 deletions(-)

New commits:
commit 9c218858f1bd83ffdd72dd943a841cffa5a93b8c
Author: Ashod Nakashian 
Date:   Thu Dec 1 00:53:11 2016 -0500

Lok: correct tile invalidation merging

Rectangles that are empty (i.e. IsEmpty() returns true)
were incorrectly considered to mean equivalent to "EMPTY".
The latter means full-area, while the former mean zero-area.

This fixes the issue by restrict full-area to rectangles
with 2 billion units on the each side (roughly INT_MAX) or
more, and using this new check rather than IsEmpty().

Change-Id: I12aca17267f5dd33b2932012d1d9db3545f9af6f
Reviewed-on: https://gerrit.libreoffice.org/31458
Tested-by: Jenkins 
Reviewed-by: Ashod Nakashian 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3abc841..53fa667 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -94,6 +94,7 @@ public:
 void testContextMenuWriter();
 void testContextMenuImpress();
 void testNotificationCompression();
+void testTileInvalidationCompression();
 void testPartInInvalidation();
 void testRedlineWriter();
 void testTrackChanges();
@@ -127,6 +128,7 @@ public:
 CPPUNIT_TEST(testContextMenuWriter);
 CPPUNIT_TEST(testContextMenuImpress);
 CPPUNIT_TEST(testNotificationCompression);
+CPPUNIT_TEST(testTileInvalidationCompression);
 CPPUNIT_TEST(testPartInInvalidation);
 CPPUNIT_TEST(testRedlineWriter);
 CPPUNIT_TEST(testTrackChanges);
@@ -1372,6 +1374,33 @@ void DesktopLOKTest::testNotificationCompression()
 CPPUNIT_ASSERT_EQUAL(std::string(".uno:AssignLayout=1"), 
std::get<1>(notifs[i++]));
 }
 
+void DesktopLOKTest::testTileInvalidationCompression()
+{
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+std::vector> notifs;
+std::unique_ptr handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, ));
+
+comphelper::LibreOfficeKit::setPartInInvalidation(true);
+comphelper::ScopeGuard aGuard([]()
+{
+comphelper::LibreOfficeKit::setPartInInvalidation(false);
+});
+
+handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
+handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 2147483767, 
2147483767, 0");
+handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
+handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-121, -121, 300, 300, 0");
+handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 0");
+
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(static_cast(1), notifs.size());
+
+size_t i = 0;
+CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, 
(int)std::get<0>(notifs[i]));
+CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 2147483767, 2147483767, 0"), 
std::get<1>(notifs[i++]));
+}
+
 void DesktopLOKTest::testPartInInvalidation()
 {
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index fe73f17..defc79b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -361,11 +361,20 @@ struct RectangleAndPart
 return ss.str().c_str();
 }
 
+/// Infinite Rectangle is when both dimensions are >= 2e7.
+// ~2 billion twips is INT_MAX, which is full-area.
+bool isInfinite() const
+{
+return m_aRectangle.GetWidth() >= 2e7 &&
+   m_aRectangle.GetHeight() >= 2e7;
+}
+
 static RectangleAndPart Create(const std::string& rPayload)
 {
 RectangleAndPart aRet;
 if (rPayload.find("EMPTY") == 0) // payload starts with "EMPTY"
 {
+aRet.m_aRectangle = Rectangle(0, 0, INT_MAX, INT_MAX);
 if (comphelper::LibreOfficeKit::isPartInInvalidation())
 aRet.m_nPart = std::stol(rPayload.substr(6));
 
@@ -678,9 +687,9 @@ void CallbackFlushHandler::queue(const int type, const 
char* data)
 {
 RectangleAndPart rcOld = RectangleAndPart::Create(pos->second);
 RectangleAndPart rcNew = RectangleAndPart::Create(payload);
-if (rcOld.m_aRectangle.IsEmpty() && rcOld.m_nPart == rcNew.m_nPart)
+if (rcOld.isInfinite() && rcOld.m_nPart == rcNew.m_nPart)
 {
-//SAL_WARN("lok", "Skipping queue [" + std::to_string(type) + 
"]: [" + payload + "] since all tiles need to be invalidated.");
+SAL_WARN("lok", "Skipping queue [" << type << "]: [" << 
payload << "] since all tiles need to be invalidated.");
 return;
 }
 }
@@ -767,8 +776,9 @@ void 

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

2016-11-27 Thread Ashod Nakashian
 desktop/qa/desktop_lib/test_desktop_lib.cxx |7 ++-
 desktop/source/lib/init.cxx |   18 ++
 2 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit f80140bf3a4fa2d809167825ee04ffd0a0c19c6c
Author: Ashod Nakashian 
Date:   Sat Nov 26 21:55:41 2016 -0500

Lok: compress duplicate state-changed events

STATE_CHANGED callback events that have the form
of name=value are only removed when newer ones
are identical. This is not very helpful since
often the same name (i.e. state type) changes
its value and we need to superseed older ones
with new values.

This patch makes sure that a STATE_CHANGED with
a given name has its latest value and doesn't
change multiple times while in the queue.

Change-Id: Ibfa18359464d7137411e5846b1c6d415a0aad43d
Reviewed-on: https://gerrit.libreoffice.org/31258
Tested-by: Jenkins 
Reviewed-by: Ashod Nakashian 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 308492b..93ad652 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1318,13 +1318,15 @@ void DesktopLOKTest::testNotificationCompression()
 handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // Should be 
dropped.
 handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // 12
 handler->queue(LOK_CALLBACK_SET_PART, "1"); // 13
+handler->queue(LOK_CALLBACK_STATE_CHANGED, ".uno:AssignLayout=20"); // 
Superseeded
 handler->queue(LOK_CALLBACK_CURSOR_VISIBLE, ""); // Should be dropped.
 handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // Should be dropped.
 handler->queue(LOK_CALLBACK_SET_PART, "1"); // Should be dropped.
+handler->queue(LOK_CALLBACK_STATE_CHANGED, ".uno:AssignLayout=1"); // 14
 
 Scheduler::ProcessEventsToIdle();
 
-CPPUNIT_ASSERT_EQUAL(static_cast(13), notifs.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(14), notifs.size());
 
 size_t i = 0;
 CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, 
(int)std::get<0>(notifs[i]));
@@ -1365,6 +1367,9 @@ void DesktopLOKTest::testNotificationCompression()
 
 CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_SET_PART, 
(int)std::get<0>(notifs[i]));
 CPPUNIT_ASSERT_EQUAL(std::string("1"), std::get<1>(notifs[i++]));
+
+CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, 
(int)std::get<0>(notifs[i]));
+CPPUNIT_ASSERT_EQUAL(std::string(".uno:AssignLayout=1"), 
std::get<1>(notifs[i++]));
 }
 
 void DesktopLOKTest::testPartInInvalidation()
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 9df6471..362ee61 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -815,6 +815,24 @@ void CallbackFlushHandler::queue(const int type, const 
char* data)
 }
 }
 break;
+
+// State changes with same name override previous ones with a 
different value.
+// Ex. ".uno:PageStatus=Slide 20 of 83" overwrites any previous 
PageStatus.
+case LOK_CALLBACK_STATE_CHANGED:
+{
+// Compare the state name=value and overwrite earlier entries 
with same name.
+const auto pos = payload.find('=');
+if (pos != std::string::npos)
+{
+const std::string name = payload.substr(0, pos + 1);
+removeAll(
+[type, , ] (const queue_type::value_type& 
elem) {
+return (elem.first == type) && 
(elem.second.compare(0, name.size(), name) == 0);
+}
+);
+}
+}
+break;
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: desktop/qa desktop/source desktop/uiconfig desktop/UIConfig_deployment.mk l10ntools/source

2016-11-23 Thread Mike Kaganski
 desktop/UIConfig_deployment.mk|1 
 desktop/qa/unit/data/desktop-dialogs-test.txt |1 
 desktop/source/app/cmdlinehelp.cxx|  310 +++---
 desktop/source/app/cmdlinehelp.hxx|   21 -
 desktop/uiconfig/ui/cmdlinehelp.ui|  137 ---
 l10ntools/source/gRun.sh  |2 
 6 files changed, 134 insertions(+), 338 deletions(-)

New commits:
commit 24a24e65cafffe137d76de0a6eb5270ea88ebffd
Author: Mike Kaganski 
Date:   Tue Nov 22 02:59:29 2016 +0300

tdf#100826: use console for -h and --version also on Windows

This removes the dialog used to show version information and
command line help on Windows. Now, selecting and scrolling becomes
possible, code is simplified and unified under all platforms.

Change-Id: Ia749bbb62d697eff655b3a646859c1986a023ec0
Reviewed-on: https://gerrit.libreoffice.org/31059
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 

diff --git a/desktop/UIConfig_deployment.mk b/desktop/UIConfig_deployment.mk
index d5cb72c..a1e08c8 100644
--- a/desktop/UIConfig_deployment.mk
+++ b/desktop/UIConfig_deployment.mk
@@ -10,7 +10,6 @@
 $(eval $(call gb_UIConfig_UIConfig,desktop))
 
 $(eval $(call gb_UIConfig_add_uifiles,desktop,\
-desktop/uiconfig/ui/cmdlinehelp \
 desktop/uiconfig/ui/dependenciesdialog \
 desktop/uiconfig/ui/extensionmanager \
 desktop/uiconfig/ui/installforalldialog \
diff --git a/desktop/qa/unit/data/desktop-dialogs-test.txt 
b/desktop/qa/unit/data/desktop-dialogs-test.txt
index b07bff1..cdcf922 100644
--- a/desktop/qa/unit/data/desktop-dialogs-test.txt
+++ b/desktop/qa/unit/data/desktop-dialogs-test.txt
@@ -35,7 +35,6 @@
 # test case since they need some document and model data to work
 # desktop/ui/extensionmanager.ui
 
-desktop/ui/cmdlinehelp.ui
 desktop/ui/dependenciesdialog.ui
 desktop/ui/updaterequireddialog.ui
 desktop/ui/showlicensedialog.ui
diff --git a/desktop/source/app/cmdlinehelp.cxx 
b/desktop/source/app/cmdlinehelp.cxx
index aaa6af9..122238c 100644
--- a/desktop/source/app/cmdlinehelp.cxx
+++ b/desktop/source/app/cmdlinehelp.cxx
@@ -19,213 +19,167 @@
 
 
 #include 
-#ifdef UNX
 #include 
-#endif
 #include 
 #include 
-#include 
-#include 
 #include 
 
-#include "desktopresid.hxx"
-#include "desktop.hrc"
 #include "cmdlinehelp.hxx"
 
+#ifdef _WIN32
+#include "windows.h"
+#include "io.h"
+#include "Fcntl.h"
+#endif
+
 namespace desktop
 {
-// to be able to display the help nicely in a dialog box with proportional 
font,
-// we need to split it in chunks...
-//  ___HEAD___
-//  LEFT RIGHT
-//  LEFT RIGHT
-//  LEFT RIGHT
-//  __BOTTOM__
-// [OK]
-
 const char aCmdLineHelp_version[] =
-"%PRODUCTNAME %PRODUCTVERSION%PRODUCTEXTENSION %BUILDID\n"\
+"%PRODUCTNAME %PRODUCTVERSION%PRODUCTEXTENSION %BUILDID\n"
 "\n";
-const char aCmdLineHelp_head[] =
-"Usage: %CMDNAME [options] [documents...]\n"\
-"\n"\
-"Options:\n";
-const char aCmdLineHelp_left[] =
-"--minimized\n"\
-"--invisible\n"\
-"--norestore\n"\
-"--quickstart   \n"\
-"--safe-mode\n"\
-"--nologo   \n"\
-"--nolockcheck  \n"\
-"--nodefault\n"\
-"--headless \n"\
-"--help/-h/-?   \n"\
-"--version  \n"\
-"--writer   \n"\
-"--calc \n"\
-"--draw \n"\
-"--impress  \n"\
-"--base \n"\
-"--math \n"\
-"--global   \n"\
-"--web  \n"\
-"-o \n"\
-"-n \n";
-const char aCmdLineHelp_right[] =
-"keep startup bitmap minimized.\n"\
-"no startup screen, no default document and no UI.\n"\
-"suppress restart/restore after fatal errors.\n"\
-"starts the quickstart service\n"\
-"starts the safe mode\n"\
-"don't show startup screen.\n"\
-"don't check for remote instances using the installation\n"\
-"don't start with an empty document\n"\
-"like invisible but no user interaction at all.\n"\
-"show this message and exit.\n"\
-"display the version information.\n"\
-"create new text document.\n"\
-"create new spreadsheet document.\n"\
-"create new drawing.\n"\
-"create new presentation.\n"\
-"create new database.\n"\
-"create new formula.\n"\
-"create new global document.\n"\
-"create new HTML document.\n"\
-"open documents regardless whether they are templates or not.\n"\
-"always open documents as new files (use as template).\n";
-const char aCmdLineHelp_bottom[] =
-"--display \n"\
+const char aCmdLineHelp[] =
+"Usage: %CMDNAME [options] [documents...]\n"
+

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

2016-09-16 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |6 ++
 desktop/source/lib/init.cxx |8 
 include/LibreOfficeKit/LibreOfficeKit.h |5 +
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   16 
 include/sfx2/lokhelper.hxx  |2 ++
 sfx2/source/view/lokhelper.cxx  |   14 ++
 6 files changed, 51 insertions(+)

New commits:
commit dcc92a7cb5aa1faa711c8da7f7d8ecee0a192c25
Author: Miklos Vajna 
Date:   Fri Sep 16 12:38:31 2016 +0200

sfx2: add SfxLokHelper::getViewIds

and also expose it in the LOK API. This way clients don't have to keep
track of what views they created / destroyed, they can also get an up to
date list with this method.

Change-Id: Ibaee42c545803e04a31e7c13ab6ec370b99465c4

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 8f3807e..a7e24fc 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -316,6 +316,12 @@ void DesktopLOKTest::testCreateView()
 int nId1 = pDocument->m_pDocumentClass->createView(pDocument);
 CPPUNIT_ASSERT_EQUAL(2, 
pDocument->m_pDocumentClass->getViewsCount(pDocument));
 
+// Test getViewIds().
+std::vector aViewIds(2);
+CPPUNIT_ASSERT(pDocument->m_pDocumentClass->getViewIds(pDocument, 
aViewIds.data(), aViewIds.size()));
+CPPUNIT_ASSERT_EQUAL(nId0, aViewIds[0]);
+CPPUNIT_ASSERT_EQUAL(nId1, aViewIds[1]);
+
 // Make sure the created view is the active one, then switch to the old
 // one.
 CPPUNIT_ASSERT_EQUAL(nId1, 
pDocument->m_pDocumentClass->getView(pDocument));
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 967d730..39e6c65 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -438,6 +438,7 @@ static void doc_destroyView(LibreOfficeKitDocument* pThis, 
int nId);
 static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
 static int doc_getView(LibreOfficeKitDocument* pThis);
 static int doc_getViewsCount(LibreOfficeKitDocument* pThis);
+static bool doc_getViewIds(LibreOfficeKitDocument* pThis, int* pArray, size_t 
nSize);
 static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
   const char *pFontName,
   int* pFontWidth,
@@ -485,6 +486,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
setView = doc_setView;
 m_pDocumentClass->getView = doc_getView;
 m_pDocumentClass->getViewsCount = doc_getViewsCount;
+m_pDocumentClass->getViewIds = doc_getViewIds;
 
 m_pDocumentClass->renderFont = doc_renderFont;
 m_pDocumentClass->getPartHash = doc_getPartHash;
@@ -2313,6 +2315,12 @@ static int doc_getViewsCount(LibreOfficeKitDocument* 
/*pThis*/)
 return SfxLokHelper::getViewsCount();
 }
 
+static bool doc_getViewIds(LibreOfficeKitDocument* /*pThis*/, int* pArray, 
size_t nSize)
+{
+SolarMutexGuard aGuard;
+return SfxLokHelper::getViewIds(pArray, nSize);
+}
+
 unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
 const char* pFontName,
 int* pFontWidth,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index a0ed819..c97655f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -244,6 +244,11 @@ struct _LibreOfficeKitDocumentClass
const int nTileWidth,
const int nTileHeight);
 
+/// @see lok::Document::getViewIds().
+bool (*getViewIds) (LibreOfficeKitDocument* pThis,
+   int* pArray,
+   size_t nSize);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index cd34885..7c90df5 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -435,6 +435,22 @@ public:
 nTileWidth, nTileHeight);
 }
 
+/**
+ * Returns the viewID for each existing view. Since viewIDs are not reused,
+ * viewIDs are not the same as the index of the view in the view array over
+ * time. Use getViewsCount() to know the minimal nSize that's large enough.
+ *
+ * @param pArray the array to write the viewIDs into
+ * @param nSize the size of pArray
+ * @returns true if pArray was large enough and result is written, false
+ * otherwise.
+ */
+inline bool getViewIds(int* pArray,
+   size_t nSize)
+{
+return mpDoc->pClass->getViewIds(mpDoc, pArray, nSize);
+}
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/sfx2/lokhelper.hxx 

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

2016-09-16 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx|6 +++---
 desktop/source/lib/init.cxx|8 
 include/LibreOfficeKit/LibreOfficeKit.h|4 ++--
 include/LibreOfficeKit/LibreOfficeKit.hxx  |   12 ++--
 include/sfx2/lokhelper.hxx |2 +-
 libreofficekit/source/gtk/lokdocview.cxx   |2 +-
 sfx2/source/view/lokhelper.cxx |4 ++--
 sw/qa/extras/tiledrendering/tiledrendering.cxx |2 +-
 8 files changed, 20 insertions(+), 20 deletions(-)

New commits:
commit dc00592b4e48a111efc6ff78bdbf7af998e58e22
Author: Miklos Vajna 
Date:   Fri Sep 16 10:15:31 2016 +0200

lok::Document: rename getViews() to getViewsCount()

As this only returns the number of views, not the actual views. Since
it's a rename, it's just an API (but not an ABI) change.

Change-Id: Ib4f0ea56a90e5ae9c80ee1781aa2f29aff4259e7

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 28d78bc..8f3807e 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -310,11 +310,11 @@ void DesktopLOKTest::testGetFonts()
 void DesktopLOKTest::testCreateView()
 {
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
-CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument));
+CPPUNIT_ASSERT_EQUAL(1, 
pDocument->m_pDocumentClass->getViewsCount(pDocument));
 
 int nId0 = pDocument->m_pDocumentClass->getView(pDocument);
 int nId1 = pDocument->m_pDocumentClass->createView(pDocument);
-CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViews(pDocument));
+CPPUNIT_ASSERT_EQUAL(2, 
pDocument->m_pDocumentClass->getViewsCount(pDocument));
 
 // Make sure the created view is the active one, then switch to the old
 // one.
@@ -323,7 +323,7 @@ void DesktopLOKTest::testCreateView()
 CPPUNIT_ASSERT_EQUAL(nId0, 
pDocument->m_pDocumentClass->getView(pDocument));
 
 pDocument->m_pDocumentClass->destroyView(pDocument, nId1);
-CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument));
+CPPUNIT_ASSERT_EQUAL(1, 
pDocument->m_pDocumentClass->getViewsCount(pDocument));
 }
 
 void DesktopLOKTest::testGetPartPageRectangles()
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index affc019..967d730 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -437,7 +437,7 @@ static int doc_createView(LibreOfficeKitDocument* pThis);
 static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
 static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
 static int doc_getView(LibreOfficeKitDocument* pThis);
-static int doc_getViews(LibreOfficeKitDocument* pThis);
+static int doc_getViewsCount(LibreOfficeKitDocument* pThis);
 static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
   const char *pFontName,
   int* pFontWidth,
@@ -484,7 +484,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
destroyView = doc_destroyView;
 m_pDocumentClass->setView = doc_setView;
 m_pDocumentClass->getView = doc_getView;
-m_pDocumentClass->getViews = doc_getViews;
+m_pDocumentClass->getViewsCount = doc_getViewsCount;
 
 m_pDocumentClass->renderFont = doc_renderFont;
 m_pDocumentClass->getPartHash = doc_getPartHash;
@@ -2306,11 +2306,11 @@ static int doc_getView(LibreOfficeKitDocument* 
/*pThis*/)
 return SfxLokHelper::getView();
 }
 
-static int doc_getViews(LibreOfficeKitDocument* /*pThis*/)
+static int doc_getViewsCount(LibreOfficeKitDocument* /*pThis*/)
 {
 SolarMutexGuard aGuard;
 
-return SfxLokHelper::getViews();
+return SfxLokHelper::getViewsCount();
 }
 
 unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 81d65c1..a0ed819 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -219,8 +219,8 @@ struct _LibreOfficeKitDocumentClass
 void (*setView) (LibreOfficeKitDocument* pThis, int nId);
 /// @see lok::Document::getView().
 int (*getView) (LibreOfficeKitDocument* pThis);
-/// @see lok::Document::getViews().
-int (*getViews) (LibreOfficeKitDocument* pThis);
+/// @see lok::Document::getViewsCount().
+int (*getViewsCount) (LibreOfficeKitDocument* pThis);
 
 /// @see lok::Document::renderFont().
 unsigned char* (*renderFont) (LibreOfficeKitDocument* pThis,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index eae43af..cd34885 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -363,7 +363,7 @@ public:
  * By default a loaded document has 1 view.
  * @return the ID 

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

2016-09-14 Thread Miklos Vajna
 desktop/qa/data/2slides.odp |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   74 
 desktop/source/lib/init.cxx |   24 +
 3 files changed, 98 insertions(+)

New commits:
commit bee4ff508a456a1552aacdf6fc838b8b7cffb9ec
Author: Miklos Vajna 
Date:   Wed Sep 14 19:47:47 2016 +0200

desktop lok: avoid unnecessary setPart() in paintPartTile()

If possible, switch views, not parts, that way started Impress text
edits don't end as a side-effect.

Change-Id: I3f18d4dda6bc24235bf1219416f153248a867fa4

diff --git a/desktop/qa/data/2slides.odp b/desktop/qa/data/2slides.odp
new file mode 100644
index 000..8be376f
Binary files /dev/null and b/desktop/qa/data/2slides.odp differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 9e58327..28d78bc 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -99,6 +99,7 @@ public:
 void testRedlineWriter();
 void testTrackChanges();
 void testRedlineCalc();
+void testPaintPartTile();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
 CPPUNIT_TEST(testGetStyles);
@@ -129,6 +130,7 @@ public:
 CPPUNIT_TEST(testRedlineWriter);
 CPPUNIT_TEST(testTrackChanges);
 CPPUNIT_TEST(testRedlineCalc);
+CPPUNIT_TEST(testPaintPartTile);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
@@ -1472,6 +1474,78 @@ void DesktopLOKTest::testRedlineCalc()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+class ViewCallback
+{
+public:
+bool m_bTilesInvalidated;
+
+ViewCallback()
+: m_bTilesInvalidated(false)
+{
+}
+
+static void callback(int nType, const char* pPayload, void* pData)
+{
+static_cast(pData)->callbackImpl(nType, pPayload);
+}
+
+void callbackImpl(int nType, const char* /*pPayload*/)
+{
+switch (nType)
+{
+case LOK_CALLBACK_INVALIDATE_TILES:
+{
+m_bTilesInvalidated = true;
+}
+break;
+}
+}
+};
+
+void DesktopLOKTest::testPaintPartTile()
+{
+// Load an impress doc of 2 slides.
+comphelper::LibreOfficeKit::setActive();
+LibLODocument_Impl* pDocument = loadDoc("2slides.odp");
+pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+ViewCallback aView1;
+pDocument->m_pDocumentClass->registerCallback(pDocument, 
::callback, );
+int nView1 = pDocument->m_pDocumentClass->getView(pDocument);
+
+// Create a second view.
+pDocument->m_pDocumentClass->createView(pDocument);
+pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+ViewCallback aView2;
+pDocument->m_pDocumentClass->registerCallback(pDocument, 
::callback, );
+
+// Go to the second slide in the second view.
+pDocument->m_pDocumentClass->setPart(pDocument, 1);
+
+// Switch back to the first view and start typing.
+pDocument->m_pDocumentClass->setView(pDocument, nView1);
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, 
LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 
0, awt::Key::TAB);
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, 
LOK_KEYEVENT_KEYINPUT, 'x', 0);
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 
'x', 0);
+
+// 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);
+
+// Type again.
+Scheduler::ProcessEventsToIdle();
+aView1.m_bTilesInvalidated = false;
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, 
LOK_KEYEVENT_KEYINPUT, 'x', 0);
+pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 
'x', 0);
+Scheduler::ProcessEventsToIdle();
+// This failed: paintPartTile() (as a side-effect) ended the text edit of
+// the first view, so there were no invalidations.
+CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
+
+mxComponent->dispose();
+mxComponent.clear();
+comphelper::LibreOfficeKit::setActive(false);
+}
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 37a65d1..18cb053 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1483,6 +1483,7 @@ static void doc_paintPartTile(LibreOfficeKitDocument* 
pThis,
   const int nTilePosX, const int nTilePosY,
   const int nTileWidth, const int nTileHeight)
 {
+SolarMutexGuard aGuard;
 SAL_INFO( "lok.tiledrendering", "paintPartTile: painting @ " << nPart << " 
["
<< nTileWidth << "x" << 

[Libreoffice-commits] core.git: desktop/qa desktop/source include/vcl sc/inc sc/source

2016-08-30 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   31 
 desktop/source/lib/init.cxx |   72 
 include/vcl/ITiledRenderable.hxx|8 +++
 sc/inc/chgtrack.hxx |2 
 sc/inc/docuno.hxx   |3 +
 sc/source/core/tool/chgtrack.cxx|   52 
 sc/source/ui/unoobj/docuno.cxx  |   14 +
 7 files changed, 152 insertions(+), 30 deletions(-)

New commits:
commit 3ab2b0625bb8ab8447a508d654d6e8c95d50dbd5
Author: Miklos Vajna 
Date:   Tue Aug 30 15:34:11 2016 +0200

sc lok: implement getCommandValues(.uno:AcceptTrackedChanges) API

Unlike in Writer, there doesn't seem to be an existing UNO API that can
be reused here.

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

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d3888ff..aa8286e 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -98,6 +98,7 @@ public:
 void testNotificationCompression();
 void testRedlineWriter();
 void testTrackChanges();
+void testRedlineCalc();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
 CPPUNIT_TEST(testGetStyles);
@@ -127,6 +128,7 @@ public:
 CPPUNIT_TEST(testNotificationCompression);
 CPPUNIT_TEST(testRedlineWriter);
 CPPUNIT_TEST(testTrackChanges);
+CPPUNIT_TEST(testRedlineCalc);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
@@ -1441,6 +1443,35 @@ void DesktopLOKTest::testRedlineWriter()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testRedlineCalc()
+{
+// Load a Writer document, enable change recording and press a key.
+comphelper::LibreOfficeKit::setActive();
+LibLODocument_Impl* pDocument = loadDoc("sheets.ods");
+uno::Reference xPropertySet(mxComponent, 
uno::UNO_QUERY);
+xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
+pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0);
+pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 't', 0);
+pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 0, 
KEY_RETURN);
+pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 0, 
KEY_RETURN);
+
+// Get redline info.
+boost::property_tree::ptree aTree;
+char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, 
".uno:AcceptTrackedChanges");
+std::stringstream aStream(pJSON);
+free(pJSON);
+CPPUNIT_ASSERT(!aStream.str().empty());
+boost::property_tree::read_json(aStream, aTree);
+// Make sure that pressing a key creates exactly one redline.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aTree.get_child("redlines").size());
+
+for (boost::property_tree::ptree::value_type& rRedline : 
aTree.get_child("redlines"))
+// This failed with boost::property_tree::ptree_bad_path, as there 
were no description field.
+CPPUNIT_ASSERT_EQUAL(std::string("Cell B4 changed from '5' to 't'"), 
rRedline.second.get("description"));
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1de564f..6ab1cf3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1820,45 +1820,57 @@ static char* getTrackedChanges(LibreOfficeKitDocument* 
pThis)
 LibLODocument_Impl* pDocument = static_cast(pThis);
 
 uno::Reference 
xRedlinesSupplier(pDocument->mxComponent, uno::UNO_QUERY);
-if (!xRedlinesSupplier.is())
-return nullptr;
-
-uno::Reference xRedlines = 
xRedlinesSupplier->getRedlines()->createEnumeration();
-boost::property_tree::ptree aRedlines;
-for (size_t nIndex = 0; xRedlines->hasMoreElements(); ++nIndex)
+std::stringstream aStream;
+if (xRedlinesSupplier.is())
 {
-uno::Reference xRedline(xRedlines->nextElement(), 
uno::UNO_QUERY);
-boost::property_tree::ptree aRedline;
-aRedline.put("index", nIndex);
+uno::Reference xRedlines = 
xRedlinesSupplier->getRedlines()->createEnumeration();
+boost::property_tree::ptree aRedlines;
+for (size_t nIndex = 0; xRedlines->hasMoreElements(); ++nIndex)
+{
+uno::Reference 
xRedline(xRedlines->nextElement(), uno::UNO_QUERY);
+boost::property_tree::ptree aRedline;
+aRedline.put("index", nIndex);
+
+OUString sAuthor;
+xRedline->getPropertyValue("RedlineAuthor") >>= sAuthor;
+aRedline.put("author", sAuthor.toUtf8().getStr());
 
-OUString 

[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit libreofficekit/qa sw/inc sw/source

2016-08-19 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 
 desktop/source/lib/init.cxx |4 
 include/LibreOfficeKit/LibreOfficeKitEnums.h|1 +
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |7 ---
 sw/inc/unoprnms.hxx |1 +
 sw/source/core/doc/docredln.cxx |2 ++
 sw/source/core/unocore/unomapproperties.hxx |1 +
 sw/source/core/unocore/unoredline.cxx   |   10 +-
 8 files changed, 26 insertions(+), 4 deletions(-)

New commits:
commit 9e310a4705ce956551059040696166aefb2388cb
Author: Miklos Vajna 
Date:   Fri Aug 19 16:46:15 2016 +0200

sw redlines: expose description as part of the UNO/LOK API

A redline can have a manual comment and also an autogenerated
description, like "Insert 'abc'". Expose this later property as well, as
it provides useful additional information, especially when the comment
property is empty.

Change-Id: Id0f0ff62aef58d96b9b6071706c6f5b4a0d74800

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index b356535..d3888ff 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1434,6 +1434,10 @@ void DesktopLOKTest::testRedlineWriter()
 // Make sure that pressing a key creates exactly one redline.
 CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aTree.get_child("redlines").size());
 
+for (boost::property_tree::ptree::value_type& rRedline : 
aTree.get_child("redlines"))
+// This failed with boost::property_tree::ptree_bad_path, as there 
were no description field.
+CPPUNIT_ASSERT_EQUAL(std::string("Insert 't'"), 
rRedline.second.get("description"));
+
 comphelper::LibreOfficeKit::setActive(false);
 }
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index dfad9b2..79129d7 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1843,6 +1843,10 @@ static char* getTrackedChanges(LibreOfficeKitDocument* 
pThis)
 xRedline->getPropertyValue("RedlineComment") >>= sComment;
 aRedline.put("comment", sComment.toUtf8().getStr());
 
+OUString sDescription;
+xRedline->getPropertyValue("RedlineDescription") >>= sDescription;
+aRedline.put("description", sDescription.toUtf8().getStr());
+
 util::DateTime aDateTime;
 xRedline->getPropertyValue("RedlineDateTime") >>= aDateTime;
 OUString sDateTime = utl::toISO8601(aDateTime);
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h 
b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 2c3bcab..0805e62 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -417,6 +417,7 @@ typedef enum
  * "author": "Unknown Author",
  * "type": "Delete",
  * "comment": "",
+ * "description": "Delete 'abc'",
  * "dateTime": "2016-08-18T12:14:00"
  * }
  * }
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx 
b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 5a134d0..9bfaa85 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -485,7 +485,7 @@ static void documentRedline(GtkWidget* pButton, gpointer 
/*pItem*/)
 GtkWidget* pContentArea = gtk_dialog_get_content_area(GTK_DIALOG 
(pDialog));
 
 // Build the table.
-GtkTreeStore* pTreeStore = gtk_tree_store_new(5, G_TYPE_INT, 
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+GtkTreeStore* pTreeStore = gtk_tree_store_new(6, G_TYPE_INT, 
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
 for (const auto& rValue : aTree.get_child("redlines"))
 {
 GtkTreeIter aTreeIter;
@@ -495,11 +495,12 @@ static void documentRedline(GtkWidget* pButton, gpointer 
/*pItem*/)
1, rValue.second.get("author").c_str(),
2, rValue.second.get("type").c_str(),
3, 
rValue.second.get("comment").c_str(),
-   4, 
rValue.second.get("dateTime").c_str(),
+   4, 
rValue.second.get("description").c_str(),
+   5, 
rValue.second.get("dateTime").c_str(),
-1);
 }
 GtkWidget* pTreeView = 
gtk_tree_view_new_with_model(GTK_TREE_MODEL(pTreeStore));
-std::vector aColumns = {"Index", "Author", "Type", "Comment", 
"Timestamp"};
+std::vector aColumns = {"Index", "Author", "Type", "Comment", 
"Description", "Timestamp"};
 for (size_t nColumn = 0; nColumn < aColumns.size(); ++nColumn)
 {
 GtkCellRenderer* pRenderer = gtk_cell_renderer_text_new();
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 0d1322d..c4020c5 100644

[Libreoffice-commits] core.git: desktop/qa desktop/source libreofficekit/qa sfx2/source sw/source

2016-08-19 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   34 +++-
 desktop/source/lib/init.cxx |3 +
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   12 +++
 sfx2/source/control/unoctitm.cxx|3 +
 sw/source/uibase/uiview/view2.cxx   |8 
 5 files changed, 57 insertions(+), 3 deletions(-)

New commits:
commit d890ec2f130188af9d998abf5968f06e7218b7a4
Author: Miklos Vajna 
Date:   Fri Aug 19 09:58:33 2016 +0200

tdf#101592 sw: track changes state is doc-specific, not view-specific

So update the bindings of all views after changing it.

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

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a1e7cc0..b356535 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -29,6 +29,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 #include 
@@ -42,7 +45,8 @@ public:
 DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"),
 m_nSelectionBeforeSearchResult(0),
 m_nSelectionAfterSearchResult(0),
-m_bModified(false)
+m_bModified(false),
+m_nTrackChanges(0)
 {
 }
 
@@ -93,6 +97,7 @@ public:
 void testContextMenuImpress();
 void testNotificationCompression();
 void testRedlineWriter();
+void testTrackChanges();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
 CPPUNIT_TEST(testGetStyles);
@@ -121,6 +126,7 @@ public:
 CPPUNIT_TEST(testContextMenuImpress);
 CPPUNIT_TEST(testNotificationCompression);
 CPPUNIT_TEST(testRedlineWriter);
+CPPUNIT_TEST(testTrackChanges);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
@@ -137,6 +143,7 @@ public:
 // for testModifiedStatus
 osl::Condition m_aStateChangedCondition;
 bool m_bModified;
+int m_nTrackChanges;
 
 // for testContextMenu{Calc, Writer}
 osl::Condition m_aContextMenuCondition;
@@ -226,6 +233,8 @@ void DesktopLOKTest::callbackImpl(int nType, const char* 
pPayload)
 m_bModified = aPayload.copy(aPrefix.getLength()).toBoolean();
 m_aStateChangedCondition.set();
 }
+else if (aPayload.startsWith(".uno:TrackChanges=") && 
aPayload.endsWith("=true"))
+++m_nTrackChanges;
 }
 break;
 case LOK_CALLBACK_CONTEXT_MENU:
@@ -790,6 +799,29 @@ void DesktopLOKTest::testModifiedStatus()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testTrackChanges()
+{
+// Load a document and create two views.
+LibLibreOffice_Impl aOffice;
+comphelper::LibreOfficeKit::setActive();
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+pDocument->pClass->initializeForRendering(pDocument, nullptr);
+pDocument->pClass->registerCallback(pDocument, ::callback, 
this);
+pDocument->pClass->createView(pDocument);
+pDocument->pClass->initializeForRendering(pDocument, nullptr);
+pDocument->pClass->registerCallback(pDocument, ::callback, 
this);
+Scheduler::ProcessEventsToIdle();
+
+// Enable trak changes and assert that both views get notified.
+m_nTrackChanges = 0;
+pDocument->pClass->postUnoCommand(pDocument, ".uno:TrackChanges", nullptr, 
false);
+Scheduler::ProcessEventsToIdle();
+// This was 1, only the active view was notified.
+CPPUNIT_ASSERT_EQUAL(2, m_nTrackChanges);
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 void DesktopLOKTest::testSheetOperations()
 {
 comphelper::LibreOfficeKit::setActive();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 17955e8..6199979 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1032,7 +1032,8 @@ static void doc_iniUnoCommands ()
 OUString(".uno:NumberFormatPercent"),
 OUString(".uno:NumberFormatDate"),
 OUString(".uno:SortAscending"),
-OUString(".uno:SortDescending")
+OUString(".uno:SortDescending"),
+OUString(".uno:TrackChanges"),
 };
 
 util::URL aCommandURL;
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx 
b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index bd6650b..5a134d0 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -116,6 +116,7 @@ public:
 GtkToolItem* m_pJustifypara;
 GtkToolItem* m_pInsertAnnotation;
 GtkToolItem* m_pDeleteComment;
+GtkToolItem* m_pTrackChanges;
 GtkWidget* m_pFormulabarEntry;
 GtkWidget* m_pScrolledWindow;
 std::map m_aToolItemCommandNames;
@@ -165,6 +166,7 @@ public:
 m_pJustifypara(nullptr),
 

[Libreoffice-commits] core.git: desktop/qa desktop/source libreofficekit/qa

2016-08-17 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   25 +++
 desktop/source/lib/init.cxx |   53 +++
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   68 +++-
 3 files changed, 145 insertions(+), 1 deletion(-)

New commits:
commit 69fb6a307172e244497bc618a102afccdd7c93b7
Author: Miklos Vajna 
Date:   Wed Aug 17 12:17:19 2016 +0200

lok::Document::getCommandValues: expose redline info

Index is added as a property for each item, so that later changes can be
identified by the index when they are accepted/rejected.

Change-Id: I9362d208fdbed1f46d64558d44498d2b19150c81

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 0174391..a1e7cc0 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -92,6 +92,7 @@ public:
 void testContextMenuWriter();
 void testContextMenuImpress();
 void testNotificationCompression();
+void testRedlineWriter();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
 CPPUNIT_TEST(testGetStyles);
@@ -119,6 +120,7 @@ public:
 CPPUNIT_TEST(testContextMenuWriter);
 CPPUNIT_TEST(testContextMenuImpress);
 CPPUNIT_TEST(testNotificationCompression);
+CPPUNIT_TEST(testRedlineWriter);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
@@ -1380,6 +1382,29 @@ void DesktopLOKTest::testNotificationCompression()
 CPPUNIT_ASSERT_EQUAL(std::string("1"), std::get<1>(notifs[i++]));
 }
 
+void DesktopLOKTest::testRedlineWriter()
+{
+// Load a Writer document, enable change recording and press a key.
+comphelper::LibreOfficeKit::setActive();
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+uno::Reference xPropertySet(mxComponent, 
uno::UNO_QUERY);
+xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
+pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0);
+pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 't', 0);
+
+// Get redline info.
+boost::property_tree::ptree aTree;
+char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, 
".uno:AcceptTrackedChanges");
+std::stringstream aStream(pJSON);
+free(pJSON);
+CPPUNIT_ASSERT(!aStream.str().empty());
+boost::property_tree::read_json(aStream, aTree);
+// Make sure that pressing a key creates exactly one redline.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aTree.get_child("redlines").size());
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0d4fb4f..17955e8 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -80,6 +81,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -1810,8 +1812,55 @@ static char* getUndoOrRedo(LibreOfficeKitDocument* 
pThis, UndoOrRedo eCommand)
 return pJson;
 }
 
+/// Returns the JSON representation of the redline stack.
+static char* getTrackedChanges(LibreOfficeKitDocument* pThis)
+{
+LibLODocument_Impl* pDocument = static_cast(pThis);
+
+uno::Reference 
xRedlinesSupplier(pDocument->mxComponent, uno::UNO_QUERY);
+if (!xRedlinesSupplier.is())
+return nullptr;
+
+uno::Reference xRedlines = 
xRedlinesSupplier->getRedlines()->createEnumeration();
+boost::property_tree::ptree aRedlines;
+for (size_t nIndex = 0; xRedlines->hasMoreElements(); ++nIndex)
+{
+uno::Reference xRedline(xRedlines->nextElement(), 
uno::UNO_QUERY);
+boost::property_tree::ptree aRedline;
+aRedline.put("index", nIndex);
+
+OUString sAuthor;
+xRedline->getPropertyValue("RedlineAuthor") >>= sAuthor;
+aRedline.put("author", sAuthor.toUtf8().getStr());
+
+OUString sType;
+xRedline->getPropertyValue("RedlineType") >>= sType;
+aRedline.put("type", sType.toUtf8().getStr());
+
+OUString sComment;
+xRedline->getPropertyValue("RedlineComment") >>= sComment;
+aRedline.put("comment", sComment.toUtf8().getStr());
+
+util::DateTime aDateTime;
+xRedline->getPropertyValue("RedlineDateTime") >>= aDateTime;
+OUString sDateTime = utl::toISO8601(aDateTime);
+aRedline.put("dateTime", sDateTime.toUtf8().getStr());
+
+aRedlines.push_back(std::make_pair("", aRedline));
+}
+
+boost::property_tree::ptree aTree;
+aTree.add_child("redlines", aRedlines);
+std::stringstream aStream;
+boost::property_tree::write_json(aStream, aTree);
+char* pJson = strdup(aStream.str().c_str());
+return pJson;
+}
+
 static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* 
pCommand)
 {
+ 

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

2016-08-05 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   23 ++
 desktop/source/lib/init.cxx |   44 ++
 include/svl/undo.hxx|6 +++
 svl/source/undo/undo.cxx|   46 
 4 files changed, 118 insertions(+), 1 deletion(-)

New commits:
commit 9dd8a0dcfdff21269f6423224d39d168519fb67e
Author: Miklos Vajna 
Date:   Fri Aug 5 13:53:57 2016 +0200

desktop: add undo/redo support to lok::Document::getCommandValues()

Expose the undo/redo stack and the metadata of each item.

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

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index f5faecf..0174391 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -79,6 +79,7 @@ public:
 void testSaveAsCalc();
 void testPasteWriter();
 void testPasteWriterJPEG();
+void testUndoWriter();
 void testRowColumnHeaders();
 void testHiddenRowHeaders();
 void testCellCursor();
@@ -105,6 +106,7 @@ public:
 CPPUNIT_TEST(testSaveAsCalc);
 CPPUNIT_TEST(testPasteWriter);
 CPPUNIT_TEST(testPasteWriterJPEG);
+CPPUNIT_TEST(testUndoWriter);
 CPPUNIT_TEST(testRowColumnHeaders);
 CPPUNIT_TEST(testHiddenRowHeaders);
 CPPUNIT_TEST(testCellCursor);
@@ -502,6 +504,27 @@ void DesktopLOKTest::testPasteWriterJPEG()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testUndoWriter()
+{
+// Load a Writer document and press a key.
+comphelper::LibreOfficeKit::setActive();
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0);
+pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 't', 0);
+
+// Get undo info.
+boost::property_tree::ptree aTree;
+char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, 
".uno:Undo");
+std::stringstream aStream(pJSON);
+free(pJSON);
+CPPUNIT_ASSERT(!aStream.str().empty());
+boost::property_tree::read_json(aStream, aTree);
+// Make sure that pressing a key creates exactly one undo action.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aTree.get_child("actions").size());
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 void DesktopLOKTest::testRowColumnHeaders()
 {
 /*
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5972424..0d4fb4f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -78,6 +78,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -85,7 +87,7 @@
 // We also need to hackily be able to start the main libreoffice thread:
 #include "../app/sofficemain.h"
 #include "../app/officeipcthread.hxx"
-#include "../../inc/lib/init.hxx"
+#include 
 
 #include "lokinteractionhandler.hxx"
 #include 
@@ -1776,6 +1778,38 @@ static char* getStyles(LibreOfficeKitDocument* pThis, 
const char* pCommand)
 return pJson;
 }
 
+enum class UndoOrRedo
+{
+UNDO,
+REDO
+};
+
+/// Returns the JSON representation of either an undo or a redo stack.
+static char* getUndoOrRedo(LibreOfficeKitDocument* pThis, UndoOrRedo eCommand)
+{
+LibLODocument_Impl* pDocument = static_cast(pThis);
+
+auto pBaseModel = 
dynamic_cast(pDocument->mxComponent.get());
+if (!pBaseModel)
+return nullptr;
+
+SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
+if (!pObjectShell)
+return nullptr;
+
+svl::IUndoManager* pUndoManager = pObjectShell->GetUndoManager();
+if (!pUndoManager)
+return nullptr;
+
+OUString aString;
+if (eCommand == UndoOrRedo::UNDO)
+aString = pUndoManager->GetUndoActionsInfo();
+else
+aString = pUndoManager->GetRedoActionsInfo();
+char* pJson = strdup(aString.toUtf8().getStr());
+return pJson;
+}
+
 static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* 
pCommand)
 {
 OString aCommand(pCommand);
@@ -1790,6 +1824,14 @@ static char* 
doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
 {
 return getStyles(pThis, pCommand);
 }
+else if (aCommand == ".uno:Undo")
+{
+return getUndoOrRedo(pThis, UndoOrRedo::UNDO);
+}
+else if (aCommand == ".uno:Redo")
+{
+return getUndoOrRedo(pThis, UndoOrRedo::REDO);
+}
 else if (aCommand.startsWith(aViewRowColumnHeaders))
 {
 ITiledRenderable* pDoc = getTiledRenderable(pThis);
diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx
index 789fd17..afe0955 100644
--- a/include/svl/undo.hxx
+++ b/include/svl/undo.hxx
@@ 

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

2016-07-31 Thread Mike Kaganski
 desktop/qa/desktop_app/test_desktop_app.cxx |   56 +++---
 desktop/source/app/cmdlineargs.cxx  |  147 
 2 files changed, 105 insertions(+), 98 deletions(-)

New commits:
commit 4311e8fb88c334cccad6f577610e1af8ae75bc59
Author: Mike Kaganski 
Date:   Thu Jul 28 21:41:11 2016 +1000

tdf#100837: honor LibreOffice command line arguments for Office URIs

This patch allows modifying open mode set in Office URI by using
LibreOffice usual command line arguments. For instance, if there is
-p "ofe:...", then the file won't be open for editing, but instead
will be printed.

Change-Id: I4bde9b6e1c0e92b63ee3834ee1fd8f6e1bd321f2
Reviewed-on: https://gerrit.libreoffice.org/27629
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 

diff --git a/desktop/qa/desktop_app/test_desktop_app.cxx 
b/desktop/qa/desktop_app/test_desktop_app.cxx
index c800b2c..9d8225e 100644
--- a/desktop/qa/desktop_app/test_desktop_app.cxx
+++ b/desktop/qa/desktop_app/test_desktop_app.cxx
@@ -47,6 +47,7 @@ public:
 
 class TestSupplier : public desktop::CommandLineArgs::Supplier {
 public:
+TestSupplier(std::initializer_list args) : m_args(args) {}
 virtual ~TestSupplier() {}
 virtual boost::optional< OUString > getCwdUrl() override { return 
boost::optional< OUString >(); }
 virtual bool next(OUString * argument) override {
@@ -59,7 +60,6 @@ public:
 return false;
 }
 }
-TestSupplier& operator << (const OUString& arg) { m_args.push_back(arg); 
return *this; }
 private:
 std::vector< OUString > m_args;
 std::vector< OUString >::size_type m_index = 0;
@@ -73,23 +73,43 @@ void Test::testTdf100837() {
 // Without this we're crashing because callees are using 
getProcessServiceFactory
 ::comphelper::setProcessServiceFactory(xSM);
 
-TestSupplier supplier;
-supplier << "--view" << "foo" << "ms-word:ofe|u|bar1" << 
"ms-word:ofv|u|bar2" << "ms-word:nft|u|bar3" << "baz";
-desktop::CommandLineArgs args(supplier);
-auto vViewList = args.GetViewList();
-auto vForceOpenList = args.GetForceOpenList();
-auto vForceNewList = args.GetForceNewList();
-// 3 documents go to View list: foo; bar2; baz
-CPPUNIT_ASSERT_EQUAL(decltype(vViewList.size())(3), vViewList.size());
-CPPUNIT_ASSERT_EQUAL(OUString("foo"),  vViewList[0]);
-CPPUNIT_ASSERT_EQUAL(OUString("bar2"), vViewList[1]);
-CPPUNIT_ASSERT_EQUAL(OUString("baz"),  vViewList[2]);
-// 1 document goes to ForceOpen list: bar1
-CPPUNIT_ASSERT_EQUAL(decltype(vForceOpenList.size())(1), 
vForceOpenList.size());
-CPPUNIT_ASSERT_EQUAL(OUString("bar1"), vForceOpenList[0]);
-// 1 document goes to ForceNew list: bar3
-CPPUNIT_ASSERT_EQUAL(decltype(vForceNewList.size())(1), 
vForceNewList.size());
-CPPUNIT_ASSERT_EQUAL(OUString("bar3"), vForceNewList[0]);
+{
+// 1. Test default behaviour: Office URIs define open mode
+TestSupplier supplier{ "foo", "ms-word:ofe|u|bar1", 
"ms-word:ofv|u|bar2", "ms-word:nft|u|bar3", "baz" };
+desktop::CommandLineArgs args(supplier);
+auto vOpenList  = args.GetOpenList();
+auto vForceOpenList = args.GetForceOpenList();
+auto vViewList  = args.GetViewList();
+auto vForceNewList  = args.GetForceNewList();
+// 2 documents go to Open list: foo; baz
+CPPUNIT_ASSERT_EQUAL(decltype(vOpenList.size())(2), vOpenList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("foo"), vOpenList[0]);
+CPPUNIT_ASSERT_EQUAL(OUString("baz"), vOpenList[1]);
+// 1 document goes to ForceOpen list: bar1
+CPPUNIT_ASSERT_EQUAL(decltype(vForceOpenList.size())(1), 
vForceOpenList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("bar1"), vForceOpenList[0]);
+// 1 document goes to View list: bar2
+CPPUNIT_ASSERT_EQUAL(decltype(vViewList.size())(1), vViewList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("bar2"), vViewList[0]);
+// 1 document goes to ForceNew list: bar3
+CPPUNIT_ASSERT_EQUAL(decltype(vForceNewList.size())(1), 
vForceNewList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("bar3"), vForceNewList[0]);
+}
+
+{
+// 2. Test explicit open mode arguments. Office URI commands should 
have no effect
+TestSupplier supplier{ "--view", "ms-word:ofe|u|foo", "-o", 
"ms-word:ofv|u|bar", "ms-word:nft|u|baz" };
+desktop::CommandLineArgs args(supplier);
+auto vViewList  = args.GetViewList();
+auto vForceOpenList = args.GetForceOpenList();
+// 1 document goes to View list: foo
+CPPUNIT_ASSERT_EQUAL(decltype(vViewList.size())(1), vViewList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("foo"), vViewList[0]);
+// 2 documents go to ForceOpen list: bar, baz
+CPPUNIT_ASSERT_EQUAL(decltype(vForceOpenList.size())(2), 
vForceOpenList.size());

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

2016-06-30 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 +--
 desktop/source/lib/init.cxx |   16 ++--
 include/LibreOfficeKit/LibreOfficeKit.h |8 +++---
 include/sfx2/lokhelper.hxx  |9 +++
 libreofficekit/source/gtk/lokdocview.cxx|   16 ++--
 sfx2/source/view/lokhelper.cxx  |   35 +---
 6 files changed, 53 insertions(+), 35 deletions(-)

New commits:
commit 615c37503cffa92a663245d7cb140f316ace0506
Author: Miklos Vajna 
Date:   Wed Jun 29 17:27:04 2016 +0200

LOK: change back type of view ids to int

Commit 45c2410041c48c22bd860efb42d4daadad7869b0 (LOK: change type of
view ids to uintptr_t, 2016-06-17) fixed the problem of view IDs being
reused for the price of random IDs, which makes debugging harder.

Implement a simple shellToView() function that makes sure view IDs are
not reused, and stop exposing view shell pointer addresses, which allows
reverting the LOK API change.

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

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d341c76..efe8601 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -295,8 +295,8 @@ void DesktopLOKTest::testCreateView()
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
 CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument));
 
-std::uintptr_t nId0 = pDocument->m_pDocumentClass->getView(pDocument);
-std::uintptr_t nId1 = pDocument->m_pDocumentClass->createView(pDocument);
+int nId0 = pDocument->m_pDocumentClass->getView(pDocument);
+int nId1 = pDocument->m_pDocumentClass->createView(pDocument);
 CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViews(pDocument));
 
 // Make sure the created view is the active one, then switch to the old
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ab765dc..10f3430 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -365,10 +365,10 @@ static void doc_setClientZoom(LibreOfficeKitDocument* 
pThis,
 int nTileTwipWidth,
 int nTileTwipHeight);
 static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, 
int nY, int nWidth, int nHeight);
-static uintptr_t doc_createView(LibreOfficeKitDocument* pThis);
-static void doc_destroyView(LibreOfficeKitDocument* pThis, uintptr_t nId);
-static void doc_setView(LibreOfficeKitDocument* pThis, uintptr_t nId);
-static uintptr_t doc_getView(LibreOfficeKitDocument* pThis);
+static int doc_createView(LibreOfficeKitDocument* pThis);
+static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
+static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
+static int doc_getView(LibreOfficeKitDocument* pThis);
 static int doc_getViews(LibreOfficeKitDocument* pThis);
 static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
   const char *pFontName,
@@ -1855,28 +1855,28 @@ static void 
doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int
 pDoc->setClientVisibleArea(aRectangle);
 }
 
-static uintptr_t doc_createView(LibreOfficeKitDocument* /*pThis*/)
+static int doc_createView(LibreOfficeKitDocument* /*pThis*/)
 {
 SolarMutexGuard aGuard;
 
 return SfxLokHelper::createView();
 }
 
-static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId)
+static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId)
 {
 SolarMutexGuard aGuard;
 
 SfxLokHelper::destroyView(nId);
 }
 
-static void doc_setView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId)
+static void doc_setView(LibreOfficeKitDocument* /*pThis*/, int nId)
 {
 SolarMutexGuard aGuard;
 
 SfxLokHelper::setView(nId);
 }
 
-static uintptr_t doc_getView(LibreOfficeKitDocument* /*pThis*/)
+static int doc_getView(LibreOfficeKitDocument* /*pThis*/)
 {
 SolarMutexGuard aGuard;
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 559d28a..81d65c1 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -212,13 +212,13 @@ struct _LibreOfficeKitDocumentClass
 void (*setClientVisibleArea) (LibreOfficeKitDocument* pThis, int nX, int 
nY, int nWidth, int nHeight);
 
 /// @see lok::Document::createView().
-uintptr_t (*createView) (LibreOfficeKitDocument* pThis);
+int (*createView) (LibreOfficeKitDocument* pThis);
 /// @see lok::Document::destroyView().
-void (*destroyView) (LibreOfficeKitDocument* pThis, uintptr_t nId);
+void (*destroyView) 

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

2016-06-17 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   11 ++---
 desktop/source/lib/init.cxx |   16 +++
 include/LibreOfficeKit/LibreOfficeKit.h |8 +--
 include/LibreOfficeKit/LibreOfficeKit.hxx   |8 +--
 include/sfx2/lokhelper.hxx  |9 ++--
 libreofficekit/source/gtk/lokdocview.cxx|7 ++-
 sfx2/source/view/lokhelper.cxx  |   59 ++--
 7 files changed, 62 insertions(+), 56 deletions(-)

New commits:
commit 45c2410041c48c22bd860efb42d4daadad7869b0
Author: Miklos Vajna 
Date:   Fri Jun 17 16:38:04 2016 +0200

LOK: change type of view ids to uintptr_t

This fixes the following problem:

- createView() = 1
- createView() = 2
- destroyView(1)

and then view #2 was renumbered to 1.

Instead expose the pointer address of the SfxViewShell as the ID, which
is not changing in such a situation.

Note that the SfxViewShell <-> ID mapping is an implementation detail of
SfxLokHelper, and only pointers are converted to IDs, user-supplied IDs
are never converted back to pointers.

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

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3fd6634..d341c76 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -295,16 +295,17 @@ void DesktopLOKTest::testCreateView()
 LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
 CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument));
 
-int nId = pDocument->m_pDocumentClass->createView(pDocument);
+std::uintptr_t nId0 = pDocument->m_pDocumentClass->getView(pDocument);
+std::uintptr_t nId1 = pDocument->m_pDocumentClass->createView(pDocument);
 CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViews(pDocument));
 
 // Make sure the created view is the active one, then switch to the old
 // one.
-CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getView(pDocument));
-pDocument->m_pDocumentClass->setView(pDocument, 0);
-CPPUNIT_ASSERT_EQUAL(0, pDocument->m_pDocumentClass->getView(pDocument));
+CPPUNIT_ASSERT_EQUAL(nId1, 
pDocument->m_pDocumentClass->getView(pDocument));
+pDocument->m_pDocumentClass->setView(pDocument, nId0);
+CPPUNIT_ASSERT_EQUAL(nId0, 
pDocument->m_pDocumentClass->getView(pDocument));
 
-pDocument->m_pDocumentClass->destroyView(pDocument, nId);
+pDocument->m_pDocumentClass->destroyView(pDocument, nId1);
 CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument));
 }
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a0aebee..c0477a5 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -364,10 +364,10 @@ static void doc_setClientZoom(LibreOfficeKitDocument* 
pThis,
 int nTileTwipWidth,
 int nTileTwipHeight);
 static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, 
int nY, int nWidth, int nHeight);
-static int doc_createView(LibreOfficeKitDocument* pThis);
-static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
-static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
-static int doc_getView(LibreOfficeKitDocument* pThis);
+static uintptr_t doc_createView(LibreOfficeKitDocument* pThis);
+static void doc_destroyView(LibreOfficeKitDocument* pThis, uintptr_t nId);
+static void doc_setView(LibreOfficeKitDocument* pThis, uintptr_t nId);
+static uintptr_t doc_getView(LibreOfficeKitDocument* pThis);
 static int doc_getViews(LibreOfficeKitDocument* pThis);
 static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
   const char *pFontName,
@@ -1850,28 +1850,28 @@ static void 
doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int
 pDoc->setClientVisibleArea(aRectangle);
 }
 
-static int doc_createView(LibreOfficeKitDocument* /*pThis*/)
+static uintptr_t doc_createView(LibreOfficeKitDocument* /*pThis*/)
 {
 SolarMutexGuard aGuard;
 
 return SfxLokHelper::createView();
 }
 
-static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId)
+static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId)
 {
 SolarMutexGuard aGuard;
 
 SfxLokHelper::destroyView(nId);
 }
 
-static void doc_setView(LibreOfficeKitDocument* /*pThis*/, int nId)
+static void doc_setView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId)
 {
 SolarMutexGuard aGuard;
 
 SfxLokHelper::setView(nId);
 }
 
-static int doc_getView(LibreOfficeKitDocument* /*pThis*/)
+static uintptr_t doc_getView(LibreOfficeKitDocument* /*pThis*/)
 {
 

[Libreoffice-commits] core.git: desktop/qa desktop/source sfx2/sdi sw/source

2016-01-28 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   11 +++
 desktop/source/lib/init.cxx |7 ++-
 sfx2/sdi/sfx.sdi|2 +-
 sw/source/uibase/dochdl/swdtflvr.cxx|   12 ++--
 sw/source/uibase/inc/swdtflvr.hxx   |6 +++---
 sw/source/uibase/inc/wrtsh.hxx  |2 +-
 sw/source/uibase/shells/basesh.cxx  |8 +++-
 sw/source/uibase/wrtsh/wrtsh1.cxx   |8 
 8 files changed, 39 insertions(+), 17 deletions(-)

New commits:
commit 552361aaad740e55fcfa7993b4111aba354f863f
Author: Miklos Vajna 
Date:   Thu Jan 28 13:31:52 2016 +0100

sw: add AnchorType parameter to .uno:Paste

Which allows not hardcoding as-char for LOK.

Change-Id: I3b2987abbaf1f259c614b7b2a8709f15048d362d

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 84fca2b..705fa24 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -455,6 +455,17 @@ void DesktopLOKTest::testPasteWriterJPEG()
 // This was text::TextContentAnchorType_AT_PARAGRAPH.
 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, 
xShape->getPropertyValue("AnchorType").get());
 
+// Delete the pasted picture, and paste again with a custom anchor type.
+uno::Reference(xShape, uno::UNO_QUERY)->dispose();
+uno::Sequence 
aPropertyValues(comphelper::InitPropertySequence(
+{
+{"AnchorType", 
uno::makeAny(static_cast(text::TextContentAnchorType_AT_CHARACTER))},
+}));
+comphelper::dispatchCommand(".uno:Paste", aPropertyValues);
+xShape.set(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+// This was text::TextContentAnchorType_AS_CHARACTER, AnchorType argument 
was ignored.
+CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, 
xShape->getPropertyValue("AnchorType").get());
+
 comphelper::LibreOfficeKit::setActive(false);
 }
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index eecb16a..dc1a04f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -47,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1176,7 +1178,10 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, 
const char* pMimeType, cons
 return false;
 }
 
-uno::Sequence aPropertyValues;
+uno::Sequence 
aPropertyValues(comphelper::InitPropertySequence(
+{
+{"AnchorType", 
uno::makeAny(static_cast(text::TextContentAnchorType_AS_CHARACTER))},
+}));
 if (!comphelper::dispatchCommand(".uno:Paste", aPropertyValues))
 {
 gImpl->maLastExceptionMsg = "Failed to dispatch the .uno: command";
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 0fd4262..08eddfc 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4133,7 +4133,7 @@ SfxBoolItem PartWindow SID_PARTWIN
 
 
 SfxVoidItem Paste SID_PASTE
-()
+(SfxUInt16Item AnchorType FN_PARAM_1)
 [
 /* flags: */
 AutoUpdate = FALSE,
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx 
b/sw/source/uibase/dochdl/swdtflvr.cxx
index 0c4e60e..1aa955a 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1131,7 +1131,7 @@ bool SwTransferable::IsPaste( const SwWrtShell& rSh,
 return bIsPaste;
 }
 
-bool SwTransferable::Paste( SwWrtShell& rSh, TransferableDataHelper& rData )
+bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, 
sal_uInt16 nAnchorType)
 {
 sal_uInt16 nEventAction, nAction=0;
 SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh );
@@ -1172,7 +1172,7 @@ bool SwTransferable::Paste( SwWrtShell& rSh, 
TransferableDataHelper& rData )
 
 return EXCHG_INOUT_ACTION_NONE != nAction &&
 SwTransferable::PasteData( rData, rSh, nAction, nFormat,
-nDestination, false, false );
+nDestination, false, false, nullptr, 
0, false, nAnchorType );
 }
 
 bool SwTransferable::PasteData( TransferableDataHelper& rData,
@@ -1180,7 +1180,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& 
rData,
 SotExchangeDest nDestination, bool bIsPasteFormat,
 bool bIsDefault,
 const Point* pPt, sal_Int8 nDropAction,
-bool bPasteSelection )
+bool bPasteSelection, sal_uInt16 nAnchorType )
 {
 SwWait aWait( *rSh.GetView().GetDocShell(), false );
 std::unique_ptr pAction;
@@ -1513,7 +1513,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& 
rData,
 case EXCHG_OUT_ACTION_INSERT_GRAPH:
 bRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,

[Libreoffice-commits] core.git: desktop/qa desktop/source filter/Configuration_filter.mk filter/source postprocess/CustomTarget_registry.mk svtools/source

2015-10-20 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx|   10 ++
 desktop/source/lib/init.cxx|1 
 filter/Configuration_filter.mk |9 +
 filter/source/config/fragments/filters/calc_png_Export.xcu |   20 +
 postprocess/CustomTarget_registry.mk   |2 +
 svtools/source/filter/DocumentToGraphicRenderer.cxx|2 +
 6 files changed, 44 insertions(+)

New commits:
commit 03bb5d52fecd6c613c6cc36508eb44e5e1c3456a
Author: Miklos Vajna 
Date:   Tue Oct 20 18:12:22 2015 +0200

sc: initial png export

Change-Id: Iae0e89646eab794879529274f09839ad34aa4696

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 204fc6d..3e8544c 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -64,6 +64,7 @@ public:
 void testSearchCalc();
 void testPaintTile();
 void testSaveAs();
+void testSaveAsCalc();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
 CPPUNIT_TEST(testGetStyles);
@@ -74,6 +75,7 @@ public:
 CPPUNIT_TEST(testSearchCalc);
 CPPUNIT_TEST(testPaintTile);
 CPPUNIT_TEST(testSaveAs);
+CPPUNIT_TEST(testSaveAsCalc);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
@@ -320,6 +322,14 @@ void DesktopLOKTest::testSaveAs()
 CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, 
aTempFile.GetURL().toUtf8().getStr(), "png", 0));
 }
 
+void DesktopLOKTest::testSaveAsCalc()
+{
+LibLODocument_Impl* pDocument = loadDoc("search.ods");
+utl::TempFile aTempFile;
+aTempFile.EnableKillingFile();
+CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, 
aTempFile.GetURL().toUtf8().getStr(), "png", 0));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 15c27ad..405e5ff 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -132,6 +132,7 @@ static const ExtensionMap aCalcExtensionMap[] =
 { "xhtml", "XHTML Calc File" },
 { "xls",   "MS Excel 97" },
 { "xlsx",  "Calc MS Excel 2007 XML" },
+{ "png",   "calc_png_Export" },
 { NULL, NULL }
 };
 
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index 0357926..5e093ca 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -843,6 +843,15 @@ $(eval $(call 
filter_Configuration_add_filters,fcfg_langpack,fcfg_writergraphics
writer_png_Export \
 ))
 
+# fcfg_calcgraphics
+$(eval $(call 
filter_Configuration_add_types,fcfg_langpack,fcfg_calcgraphics_types.xcu,filter/source/config/fragments/types,\
+   png_Portable_Network_Graphic \
+))
+
+$(eval $(call 
filter_Configuration_add_filters,fcfg_langpack,fcfg_calcgraphics_filters.xcu,filter/source/config/fragments/filters,\
+   calc_png_Export \
+))
+
 # fcfg_internalgraphics
 $(eval $(call 
filter_Configuration_add_types,fcfg_langpack,fcfg_internalgraphics_types.xcu,filter/source/config/fragments/types,\
bmp_MS_Windows \
diff --git a/filter/source/config/fragments/filters/calc_png_Export.xcu 
b/filter/source/config/fragments/filters/calc_png_Export.xcu
new file mode 100644
index 000..999bef2
--- /dev/null
+++ b/filter/source/config/fragments/filters/calc_png_Export.xcu
@@ -0,0 +1,20 @@
+
+
+EXPORT ALIEN 
3RDPARTYFILTER
+com.sun.star.comp.GraphicExportDialog
+com.sun.star.comp.GraphicExportFilter
+
+
+PNG - Portable Network Graphic
+
+0
+png_Portable_Network_Graphic
+
+com.sun.star.sheet.SpreadsheetDocument
+
diff --git a/postprocess/CustomTarget_registry.mk 
b/postprocess/CustomTarget_registry.mk
index 897ad6a..effafab 100644
--- a/postprocess/CustomTarget_registry.mk
+++ b/postprocess/CustomTarget_registry.mk
@@ -87,6 +87,8 @@ postprocess_FILES_graphicfilter := \
$(call gb_XcuFilterTypesTarget_get_target,fcfg_drawgraphics_types.xcu) \
$(call 
gb_XcuFilterFiltersTarget_get_target,fcfg_impressgraphics_filters.xcu) \
$(call 
gb_XcuFilterTypesTarget_get_target,fcfg_impressgraphics_types.xcu) \
+   $(call 
gb_XcuFilterFiltersTarget_get_target,fcfg_calcgraphics_filters.xcu) \
+   $(call gb_XcuFilterTypesTarget_get_target,fcfg_calcgraphics_types.xcu) \
$(call 
gb_XcuFilterFiltersTarget_get_target,fcfg_writergraphics_filters.xcu) \
$(call gb_XcuFilterTypesTarget_get_target,fcfg_writergraphics_types.xcu)
 
diff --git a/svtools/source/filter/DocumentToGraphicRenderer.cxx 
b/svtools/source/filter/DocumentToGraphicRenderer.cxx
index e33a94e..e78b0f1 100644
--- a/svtools/source/filter/DocumentToGraphicRenderer.cxx
+++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx
@@ -148,6 +148,8 @@ Graphic DocumentToGraphicRenderer::renderToGraphic(
 sal_Int32 

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

2015-10-15 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   21 +
 desktop/source/lib/init.cxx |2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit d30f5bc3e65463f28c3087acad6f88e12d60e53b
Author: Miklos Vajna 
Date:   Thu Oct 15 09:41:52 2015 +0200

lok::Document::paintTile: fix non-rectangular tiles wrt. transparency

When copying the alpha channel, the offset was incorrect when canvas
width/height did not equal.

Change-Id: If0ab3ec7a4ad4dd958419b566fd473732965cfda

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2894809..a8c2015 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -61,6 +61,7 @@ public:
 void testGetFilterTypes();
 void testGetPartPageRectangles();
 void testSearchCalc();
+void testPaintTile();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
 CPPUNIT_TEST(testGetStyles);
@@ -69,6 +70,7 @@ public:
 CPPUNIT_TEST(testGetFilterTypes);
 CPPUNIT_TEST(testGetPartPageRectangles);
 CPPUNIT_TEST(testSearchCalc);
+CPPUNIT_TEST(testPaintTile);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
@@ -280,6 +282,25 @@ void DesktopLOKTest::testSearchCalc()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testPaintTile()
+{
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+int nCanvasWidth = 100;
+int nCanvasHeight = 300;
+std::vector aBuffer(nCanvasWidth * nCanvasHeight * 4);
+int nTilePosX = 0;
+int nTilePosY = 0;
+int nTileWidth = 1000;
+int nTileHeight = 3000;
+
+// This used to crash: painTile() implementation did not handle
+// nCanvasWidth != nCanvasHeight correctly, as usually both are just always
+// 256.
+pDocument->pClass->paintTile(pDocument, aBuffer.data(), nCanvasWidth, 
nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+
+closeDoc();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index dc738921..8713bb5 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -789,7 +789,7 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
 {
 for (int nCol = 0; nCol < nCanvasWidth; ++nCol)
 {
-const int nOffset = (nCanvasHeight * nRow) + nCol;
+const int nOffset = (nCanvasWidth * nRow) + nCol;
 // VCL's transparent is 0, RGBA's transparent is 0xff.
 pBuffer[nOffset * 4 +3] = 0xff - aAlpha[nOffset];
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/vcl sw/inc sw/source

2015-09-29 Thread Miklos Vajna
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   25 +
 desktop/source/lib/init.cxx |   19 +++
 include/LibreOfficeKit/LibreOfficeKit.h |3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   14 ++
 include/vcl/ITiledRenderable.hxx|8 
 sw/inc/crsrsh.hxx   |2 ++
 sw/inc/unotxdoc.hxx |2 ++
 sw/source/core/crsr/crsrsh.cxx  |   14 ++
 sw/source/uibase/uno/unotxdoc.cxx   |   11 +++
 9 files changed, 98 insertions(+)

New commits:
commit d355207b45755cfe1eef0147bc25ead931741684
Author: Miklos Vajna 
Date:   Tue Sep 29 10:47:31 2015 +0200

lok: add Document::getPartPageRectangles()

Change-Id: I20acd44f7a81471982ba96ad3894a9124e035c5f

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d7b9347..a7696d8 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -52,12 +52,14 @@ public:
 void testGetFonts();
 void testCreateView();
 void testGetFilterTypes();
+void testGetPartPageRectangles();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
 CPPUNIT_TEST(testGetStyles);
 CPPUNIT_TEST(testGetFonts);
 CPPUNIT_TEST(testCreateView);
 CPPUNIT_TEST(testGetFilterTypes);
+CPPUNIT_TEST(testGetPartPageRectangles);
 CPPUNIT_TEST_SUITE_END();
 
 uno::Reference mxComponent;
@@ -152,6 +154,29 @@ void DesktopLOKTest::testCreateView()
 closeDoc();
 }
 
+void DesktopLOKTest::testGetPartPageRectangles()
+{
+// Test that we get as many page rectangles as expected: blank document is
+// one page.
+LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+char* pRectangles = pDocument->pClass->getPartPageRectangles(pDocument);
+OUString sRectangles = OUString::fromUtf8(pRectangles);
+
+std::vector aRectangles;
+sal_Int32 nIndex = 0;
+do
+{
+OUString aRectangle = sRectangles.getToken(0, ';', nIndex);
+if (!aRectangle.isEmpty())
+aRectangles.push_back(aRectangle);
+}
+while (nIndex >= 0);
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aRectangles.size());
+
+free(pRectangles);
+closeDoc();
+}
+
 void DesktopLOKTest::testGetFilterTypes()
 {
 LibLibreOffice_Impl aOffice;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b581bca..509983c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -204,6 +204,7 @@ static void doc_destroy(LibreOfficeKitDocument* pThis);
 static int  doc_saveAs(LibreOfficeKitDocument* pThis, const char* pUrl, const 
char* pFormat, const char* pFilterOptions);
 static int doc_getDocumentType(LibreOfficeKitDocument* pThis);
 static int doc_getParts(LibreOfficeKitDocument* pThis);
+static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis);
 static int doc_getPart(LibreOfficeKitDocument* pThis);
 static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
 static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart);
@@ -266,6 +267,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 
saveAs = doc_saveAs;
 m_pDocumentClass->getDocumentType = doc_getDocumentType;
 m_pDocumentClass->getParts = doc_getParts;
+m_pDocumentClass->getPartPageRectangles = doc_getPartPageRectangles;
 m_pDocumentClass->getPart = doc_getPart;
 m_pDocumentClass->setPart = doc_setPart;
 m_pDocumentClass->getPartName = doc_getPartName;
@@ -659,6 +661,23 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int 
nPart)
 pDoc->setPart( nPart );
 }
 
+static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis)
+{
+ITiledRenderable* pDoc = getTiledRenderable(pThis);
+if (!pDoc)
+{
+gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+return 0;
+}
+
+OUString sRectangles = pDoc->getPartPageRectangles();
+OString aString = OUStringToOString(sRectangles, RTL_TEXTENCODING_UTF8);
+char* pMemory = static_cast(malloc(aString.getLength() + 1));
+strcpy(pMemory, aString.getStr());
+return pMemory;
+
+}
+
 static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
 {
 ITiledRenderable* pDoc = getTiledRenderable(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index d5094bd..d83dd49 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -85,6 +85,9 @@ struct _LibreOfficeKitDocumentClass
 /// @see lok::Document::getParts().
 int (*getParts) (LibreOfficeKitDocument* pThis);
 
+/// @see lok::Document::getPartPageRectangles().
+char* (*getPartPageRectangles) (LibreOfficeKitDocument* pThis);
+
 /// @see lok::Document::getPart().
 int