core.git: Branch 'libreoffice-24-2' - 2 commits - oox/qa sw/source writerfilter/source

2024-02-21 Thread Ashod Nakashian (via logerrit)
 oox/qa/unit/export.cxx|   58 ++
 sw/source/filter/ww8/docxattributeoutput.cxx  |   28 --
 sw/source/filter/ww8/wrtw8nds.cxx |8 +++
 sw/source/uibase/wrtsh/wrtsh1.cxx |5 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   35 -
 5 files changed, 128 insertions(+), 6 deletions(-)

New commits:
commit 19883f7c86882f0367d072a0af034810c636c208
Author: Ashod Nakashian 
AuthorDate: Sat Feb 17 11:25:37 2024 -0500
Commit: Miklos Vajna 
CommitDate: Wed Feb 21 15:38:33 2024 +0100

docx import: correct redline content-controls

When inserting and deleting content-controls
with change-tracking enabled, we hit a few
corner-cases that we need to handle more
smartly.

First, we shouldn't redline the controls
themselves, just the placeholder text.
Second, we have to take special care
to create valid XML structure with
the redline tags.

Includes unit-test that reproduces the
issues and verifies that both saving
and loading work as expected.

Change-Id: I6af4d0d2c3f0661e7990d5414cc93effc96f0469
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163647
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163688

diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index 4ad6dce4e288..bfee2e7ef8b3 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -9,6 +9,9 @@
 
 #include 
 
+#include 
+#include 
+
 using namespace ::com::sun::star;
 
 namespace
@@ -97,14 +100,30 @@ CPPUNIT_TEST_FIXTURE(Test, 
testInsertCheckboxContentControlDocx)
 {
 loadFromFile(u"dml-groupshape-polygon.docx");
 
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+
 // With TrackChanges, the Checkbox causes an assertion in the sax 
serializer,
 // in void 
sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32).
 // Element == maMarkStack.top()->m_DebugStartedElements.back()
 // sax/source/tools/fastserializer.cxx#402
 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+
+xText->insertControlCharacter(xCursor, 
text::ControlCharacter::PARAGRAPH_BREAK, false);
+
 dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
 
-save("Office Open XML Text");
+// Loading should not show the "corrupted" dialog, which would assert.
+saveAndReload("Office Open XML Text");
+
+// Now that we loaded it successfully, delete the controls,
+// still with change-tracking enabled, and save.
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+dispatchCommand(mxComponent, ".uno:Delete", {});
+
+// Loading should not show the "corrupted" dialog, which would assert.
+saveAndReload("Office Open XML Text");
 // validate(maTempFile.GetFileName(), test::OOXML); // Enable when 
unrelated errors are fixed.
 }
 }
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index d84549d43066..fe78cb16b420 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1965,7 +1965,22 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 }
 
 // if there is some redlining in the document, output it
-StartRedline( m_pRedlineData, bLastRun );
+bool bSkipRedline = false;
+if (nLen == 1)
+{
+// Don't redline content-controls--Word doesn't do them.
+SwTextAttr* pAttr
+= pNode->GetTextAttrAt(nPos, RES_TXTATR_CONTENTCONTROL, 
sw::GetTextAttrMode::Default);
+if (pAttr && pAttr->GetStart() == nPos)
+{
+bSkipRedline = true;
+}
+}
+
+if (!bSkipRedline)
+{
+StartRedline(m_pRedlineData, bLastRun);
+}
 
 // XML_r node should be surrounded with bookmark-begin and bookmark-end 
nodes if it has bookmarks.
 // The same is applied for permission ranges.
@@ -2042,6 +2057,13 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 // append the actual run end
 m_pSerializer->endElementNS( XML_w, XML_r );
 
+// if there is some redlining in the document, output it
+// (except in the case of fields with multiple runs)
+if (!bSkipRedline)
+{
+EndRedline(m_pRedlineData, bLastRun);
+}
+
 if (nLen != -1)
 {
 sal_Int32 nEnd = nPos + nLen;
@@ -2052,10 +2074,6 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nP

core.git: Branch 'distro/collabora/co-24.04' - oox/qa sw/source writerfilter/source

2024-02-21 Thread Ashod Nakashian (via logerrit)
 oox/qa/unit/export.cxx|   21 -
 sw/source/filter/ww8/docxattributeoutput.cxx  |   28 ++---
 sw/source/filter/ww8/wrtw8nds.cxx |8 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   35 +-
 4 files changed, 85 insertions(+), 7 deletions(-)

New commits:
commit 23a662af7d9385bf20afeab36a684bbdfe48045d
Author: Ashod Nakashian 
AuthorDate: Sat Feb 17 11:25:37 2024 -0500
Commit: Miklos Vajna 
CommitDate: Wed Feb 21 13:34:07 2024 +0100

docx import: correct redline content-controls

When inserting and deleting content-controls
with change-tracking enabled, we hit a few
corner-cases that we need to handle more
smartly.

First, we shouldn't redline the controls
themselves, just the placeholder text.
Second, we have to take special care
to create valid XML structure with
the redline tags.

Includes unit-test that reproduces the
issues and verifies that both saving
and loading work as expected.

(cherry picked from commit 1b0f67018fa1d514ebca59e081efdd24c1d7811b)

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

diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index 4ad6dce4e288..bfee2e7ef8b3 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -9,6 +9,9 @@
 
 #include 
 
+#include 
+#include 
+
 using namespace ::com::sun::star;
 
 namespace
@@ -97,14 +100,30 @@ CPPUNIT_TEST_FIXTURE(Test, 
testInsertCheckboxContentControlDocx)
 {
 loadFromFile(u"dml-groupshape-polygon.docx");
 
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+
 // With TrackChanges, the Checkbox causes an assertion in the sax 
serializer,
 // in void 
sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32).
 // Element == maMarkStack.top()->m_DebugStartedElements.back()
 // sax/source/tools/fastserializer.cxx#402
 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+
+xText->insertControlCharacter(xCursor, 
text::ControlCharacter::PARAGRAPH_BREAK, false);
+
 dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
 
-save("Office Open XML Text");
+// Loading should not show the "corrupted" dialog, which would assert.
+saveAndReload("Office Open XML Text");
+
+// Now that we loaded it successfully, delete the controls,
+// still with change-tracking enabled, and save.
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+dispatchCommand(mxComponent, ".uno:Delete", {});
+
+// Loading should not show the "corrupted" dialog, which would assert.
+saveAndReload("Office Open XML Text");
 // validate(maTempFile.GetFileName(), test::OOXML); // Enable when 
unrelated errors are fixed.
 }
 }
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 2bd25dba7b5e..03ada68bcb2d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1965,7 +1965,22 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 }
 
 // if there is some redlining in the document, output it
-StartRedline( m_pRedlineData, bLastRun );
+bool bSkipRedline = false;
+if (nLen == 1)
+{
+// Don't redline content-controls--Word doesn't do them.
+SwTextAttr* pAttr
+= pNode->GetTextAttrAt(nPos, RES_TXTATR_CONTENTCONTROL, 
sw::GetTextAttrMode::Default);
+if (pAttr && pAttr->GetStart() == nPos)
+{
+bSkipRedline = true;
+}
+}
+
+if (!bSkipRedline)
+{
+StartRedline(m_pRedlineData, bLastRun);
+}
 
 // XML_r node should be surrounded with bookmark-begin and bookmark-end 
nodes if it has bookmarks.
 // The same is applied for permission ranges.
@@ -2042,6 +2057,13 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 // append the actual run end
 m_pSerializer->endElementNS( XML_w, XML_r );
 
+// if there is some redlining in the document, output it
+// (except in the case of fields with multiple runs)
+if (!bSkipRedline)
+{
+EndRedline(m_pRedlineData, bLastRun);
+}
+
 if (nLen != -1)
 {
 sal_Int32 nEnd = nPos + nLen;
@@ -2052,10 +2074,6 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 }
 }
 
-// if there 

core.git: oox/qa sw/source writerfilter/source

2024-02-20 Thread Ashod Nakashian (via logerrit)
 oox/qa/unit/export.cxx|   21 -
 sw/source/filter/ww8/docxattributeoutput.cxx  |   28 ++---
 sw/source/filter/ww8/wrtw8nds.cxx |8 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   35 +-
 4 files changed, 85 insertions(+), 7 deletions(-)

New commits:
commit 1b0f67018fa1d514ebca59e081efdd24c1d7811b
Author: Ashod Nakashian 
AuthorDate: Sat Feb 17 11:25:37 2024 -0500
Commit: Miklos Vajna 
CommitDate: Tue Feb 20 17:02:42 2024 +0100

docx import: correct redline content-controls

When inserting and deleting content-controls
with change-tracking enabled, we hit a few
corner-cases that we need to handle more
smartly.

First, we shouldn't redline the controls
themselves, just the placeholder text.
Second, we have to take special care
to create valid XML structure with
the redline tags.

Includes unit-test that reproduces the
issues and verifies that both saving
and loading work as expected.

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

diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index 4ad6dce4e288..bfee2e7ef8b3 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -9,6 +9,9 @@
 
 #include 
 
+#include 
+#include 
+
 using namespace ::com::sun::star;
 
 namespace
@@ -97,14 +100,30 @@ CPPUNIT_TEST_FIXTURE(Test, 
testInsertCheckboxContentControlDocx)
 {
 loadFromFile(u"dml-groupshape-polygon.docx");
 
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+
 // With TrackChanges, the Checkbox causes an assertion in the sax 
serializer,
 // in void 
sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32).
 // Element == maMarkStack.top()->m_DebugStartedElements.back()
 // sax/source/tools/fastserializer.cxx#402
 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+
+xText->insertControlCharacter(xCursor, 
text::ControlCharacter::PARAGRAPH_BREAK, false);
+
 dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
 
-save("Office Open XML Text");
+// Loading should not show the "corrupted" dialog, which would assert.
+saveAndReload("Office Open XML Text");
+
+// Now that we loaded it successfully, delete the controls,
+// still with change-tracking enabled, and save.
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+dispatchCommand(mxComponent, ".uno:Delete", {});
+
+// Loading should not show the "corrupted" dialog, which would assert.
+saveAndReload("Office Open XML Text");
 // validate(maTempFile.GetFileName(), test::OOXML); // Enable when 
unrelated errors are fixed.
 }
 }
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 3e0389f8a199..c2b7ea47d395 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1963,7 +1963,22 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 }
 
 // if there is some redlining in the document, output it
-StartRedline( m_pRedlineData, bLastRun );
+bool bSkipRedline = false;
+if (nLen == 1)
+{
+// Don't redline content-controls--Word doesn't do them.
+SwTextAttr* pAttr
+= pNode->GetTextAttrAt(nPos, RES_TXTATR_CONTENTCONTROL, 
sw::GetTextAttrMode::Default);
+if (pAttr && pAttr->GetStart() == nPos)
+{
+bSkipRedline = true;
+}
+}
+
+if (!bSkipRedline)
+{
+StartRedline(m_pRedlineData, bLastRun);
+}
 
 // XML_r node should be surrounded with bookmark-begin and bookmark-end 
nodes if it has bookmarks.
 // The same is applied for permission ranges.
@@ -2040,6 +2055,13 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 // append the actual run end
 m_pSerializer->endElementNS( XML_w, XML_r );
 
+// if there is some redlining in the document, output it
+// (except in the case of fields with multiple runs)
+if (!bSkipRedline)
+{
+EndRedline(m_pRedlineData, bLastRun);
+}
+
 if (nLen != -1)
 {
 sal_Int32 nEnd = nPos + nLen;
@@ -2050,10 +2072,6 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 }
 }
 
-// if there is some redlining in the document, output it
-// (except in the case of fields with multiple run

core.git: Branch 'distro/collabora/co-23.05' - oox/qa sw/source writerfilter/source

2024-02-20 Thread Ashod Nakashian (via logerrit)
 oox/qa/unit/export.cxx|   21 -
 sw/source/filter/ww8/docxattributeoutput.cxx  |   28 ++---
 sw/source/filter/ww8/wrtw8nds.cxx |8 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   35 +-
 4 files changed, 85 insertions(+), 7 deletions(-)

New commits:
commit 4e3fc95767048b6813519efd6c5d7a97484c37ed
Author: Ashod Nakashian 
AuthorDate: Sat Feb 17 11:25:37 2024 -0500
Commit: Ashod Nakashian 
CommitDate: Tue Feb 20 12:00:32 2024 +0100

docx import: correct redline content-controls

When inserting and deleting content-controls
with change-tracking enabled, we hit a few
corner-cases that we need to handle more
smartly.

First, we shouldn't redline the controls
themselves, just the placeholder text.
Second, we have to take special care
to create valid XML structure with
the redline tags.

Includes unit-test that reproduces the
issues and verifies that both saving
and loading work as expected.

Signed-off-by: Ashod Nakashian 
Change-Id: I6af4d0d2c3f0661e7990d5414cc93effc96f0469
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163555
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
Reviewed-by: Ashod Nakashian 

diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index d8be16ba8000..f00b2da9ab3c 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -9,6 +9,9 @@
 
 #include 
 
+#include 
+#include 
+
 using namespace ::com::sun::star;
 
 namespace
@@ -108,14 +111,30 @@ CPPUNIT_TEST_FIXTURE(Test, 
testInsertCheckboxContentControlDocx)
 {
 loadFromURL(u"dml-groupshape-polygon.docx");
 
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xText = xTextDocument->getText();
+uno::Reference xCursor = xText->createTextCursor();
+
 // With TrackChanges, the Checkbox causes an assertion in the sax 
serializer,
 // in void 
sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32).
 // Element == maMarkStack.top()->m_DebugStartedElements.back()
 // sax/source/tools/fastserializer.cxx#402
 dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+
+xText->insertControlCharacter(xCursor, 
text::ControlCharacter::PARAGRAPH_BREAK, false);
+
 dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
 
-save("Office Open XML Text");
+// Loading should not show the "corrupted" dialog, which would assert.
+saveAndReload("Office Open XML Text");
+
+// Now that we loaded it successfully, delete the controls,
+// still with change-tracking enabled, and save.
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+dispatchCommand(mxComponent, ".uno:Delete", {});
+
+// Loading should not show the "corrupted" dialog, which would assert.
+saveAndReload("Office Open XML Text");
 }
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 394d4a715e1a..1ae2a8ae6071 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1919,7 +1919,22 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 }
 
 // if there is some redlining in the document, output it
-StartRedline( m_pRedlineData, bLastRun );
+bool bSkipRedline = false;
+if (nLen == 1)
+{
+// Don't redline content-controls--Word doesn't do them.
+SwTextAttr* pAttr
+= pNode->GetTextAttrAt(nPos, RES_TXTATR_CONTENTCONTROL, 
sw::GetTextAttrMode::Default);
+if (pAttr && pAttr->GetStart() == nPos)
+{
+bSkipRedline = true;
+}
+}
+
+if (!bSkipRedline)
+{
+StartRedline(m_pRedlineData, bLastRun);
+}
 
 // XML_r node should be surrounded with bookmark-begin and bookmark-end 
nodes if it has bookmarks.
 // The same is applied for permission ranges.
@@ -1992,6 +2007,13 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 // append the actual run end
 m_pSerializer->endElementNS( XML_w, XML_r );
 
+// if there is some redlining in the document, output it
+// (except in the case of fields with multiple runs)
+if (!bSkipRedline)
+{
+EndRedline(m_pRedlineData, bLastRun);
+}
+
 if (nLen != -1)
 {
 sal_Int32 nEnd = nPos + nLen;
@@ -2002,10 +2024,6 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 }
 }
 
-// if there is some redlining in the document, output it
-// (except in the case of fields with multiple runs)
-

core.git: Branch 'distro/collabora/co-23.05' - oox/qa sw/source

2024-02-08 Thread Ashod Nakashian (via logerrit)
 oox/qa/unit/export.cxx|   42 ++
 sw/source/uibase/wrtsh/wrtsh1.cxx |5 
 2 files changed, 47 insertions(+)

New commits:
commit d30e4ada63bb05489174d2bf0b3a30d0ded86a77
Author: Ashod Nakashian 
AuthorDate: Wed Jan 31 05:53:56 2024 -0500
Commit: Miklos Vajna 
CommitDate: Fri Feb 9 08:11:32 2024 +0100

sw: do not redline ContentControl items

When we redline the ContentControl item
itself, we break docx XML. Instead, we
only need to redline the placeholder,
which we already do.

This simply disables redlining when
inserting the ContentControl item
while leaving it otherwise enabled
while inserting the placeholder.

Before:







==> 












==> 
==> 


☐

==> 








The first  and its closing tag
is not seen in the reference docx
file, and we can see that it's invalid
XML here.

After:


















==> 


☐

==> 








Only the valid  around the
placeholder exists.
    
    Signed-off-by: Ashod Nakashian 
Change-Id: I1404e41aec3b5efdc2e4115236102ffa2733b15c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162802
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit 7a3e9c66baff8554d1267bc98c9c69e763bc8bdc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163050
Tested-by: Jenkins CollaboraOffice 

diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index 6ad32c2981e3..d8be16ba8000 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -77,6 +77,48 @@ CPPUNIT_TEST_FIXTURE(Test, testRotatedShapePosition)
 assertXPath(pXmlDoc, "//wpg:wgp/wps:wsp[1]/wps:spPr/a:xfrm/a:off", "y", 
"469440");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlOdt)
+{
+loadFromURL(u"tdf141786_RotatedShapeInGroup.odt");
+
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
+
+// FIXME: validation error in OOXML export: Errors: 3
+skipValidation();
+
+save("Office Open XML Text");
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlDocx)
+{
+{
+loadFromURL(u"dml-groupshape-polygon.docx");
+
+// Without TrackChanges, inserting the Checkbox works just fine
+// when exporting to docx.
+dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
+
+// FIXME: validation error in OOXML export: Errors: 9
+skipValidation();
+
+save("Office Open XML Text");
+}
+
+{
+loadFromURL(u"dml-groupshape-polygon.docx");
+
+// With TrackChanges, the Checkbox causes an assertion in the sax 
serializer,
+// in void 
sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32).
+// Element == maMarkStack.top()->m_DebugStartedElements.back()
+// sax/source/tools/fastserializer.cxx#402
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
+
+save("Office Open XML Text");
+}
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testDmlGroupshapePolygon)
 {
 // Given a document with a group shape, containing a single polygon child 
shape:
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 5fc8c7948480..61fbce892540 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -112,6 +112,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -1164,8 +1165,12 @@ void 
SwWrtShell::InsertContentControl(SwContentControlType eType)
 Left(SwCursorSkipMode::Chars, /*bSelect=*/tr

core.git: Branch 'distro/collabora/co-24.04' - oox/qa sw/source

2024-02-07 Thread Ashod Nakashian (via logerrit)
 oox/qa/unit/export.cxx|   39 ++
 sw/source/uibase/wrtsh/wrtsh1.cxx |5 
 2 files changed, 44 insertions(+)

New commits:
commit ac5237c5a0bb79a8cc07b2643a6da685006dd602
Author: Ashod Nakashian 
AuthorDate: Wed Jan 31 05:53:56 2024 -0500
Commit: Miklos Vajna 
CommitDate: Wed Feb 7 09:36:54 2024 +0100

sw: do not redline ContentControl items

When we redline the ContentControl item
itself, we break docx XML. Instead, we
only need to redline the placeholder,
which we already do.

This simply disables redlining when
inserting the ContentControl item
while leaving it otherwise enabled
while inserting the placeholder.

Before:







==> 












==> 
==> 


☐

==> 








The first  and its closing tag
is not seen in the reference docx
file, and we can see that it's invalid
XML here.

After:


















==> 


☐

==> 








Only the valid  around the
placeholder exists.
    
    Signed-off-by: Ashod Nakashian 
Change-Id: I1404e41aec3b5efdc2e4115236102ffa2733b15c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162802
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit 7a3e9c66baff8554d1267bc98c9c69e763bc8bdc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163047
Tested-by: Jenkins CollaboraOffice 

diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index aa9690efdb4a..4ad6dce4e288 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -70,6 +70,45 @@ CPPUNIT_TEST_FIXTURE(Test, testRotatedShapePosition)
 assertXPath(pXmlDoc, "//wpg:wgp/wps:wsp[1]/wps:spPr/a:xfrm/a:off"_ostr, 
"y"_ostr, "469440");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlOdt)
+{
+loadFromFile(u"tdf141786_RotatedShapeInGroup.odt");
+
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
+
+save("Office Open XML Text");
+// validate(maTempFile.GetFileName(), test::OOXML); // Enable when 
unrelated errors are fixed.
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlDocx)
+{
+{
+loadFromFile(u"dml-groupshape-polygon.docx");
+
+// Without TrackChanges, inserting the Checkbox works just fine
+// when exporting to docx.
+dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
+
+save("Office Open XML Text");
+// validate(maTempFile.GetFileName(), test::OOXML); // Enable when 
unrelated errors are fixed.
+}
+
+{
+loadFromFile(u"dml-groupshape-polygon.docx");
+
+// With TrackChanges, the Checkbox causes an assertion in the sax 
serializer,
+// in void 
sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32).
+// Element == maMarkStack.top()->m_DebugStartedElements.back()
+// sax/source/tools/fastserializer.cxx#402
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
+
+save("Office Open XML Text");
+// validate(maTempFile.GetFileName(), test::OOXML); // Enable when 
unrelated errors are fixed.
+}
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testDmlGroupshapePolygon)
 {
 // Given a document with a group shape, containing a single polygon child 
shape:
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 4b2402fc93c8..0054eca4cb34 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -115,6 +115,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -

core.git: oox/qa sw/source

2024-02-02 Thread Ashod Nakashian (via logerrit)
 oox/qa/unit/export.cxx|   39 ++
 sw/source/uibase/wrtsh/wrtsh1.cxx |5 
 2 files changed, 44 insertions(+)

New commits:
commit 7a3e9c66baff8554d1267bc98c9c69e763bc8bdc
Author: Ashod Nakashian 
AuthorDate: Wed Jan 31 05:53:56 2024 -0500
Commit: Miklos Vajna 
CommitDate: Fri Feb 2 13:26:16 2024 +0100

sw: do not redline ContentControl items

When we redline the ContentControl item
itself, we break docx XML. Instead, we
only need to redline the placeholder,
which we already do.

This simply disables redlining when
inserting the ContentControl item
while leaving it otherwise enabled
while inserting the placeholder.

Before:







==> 












==> 
==> 


☐

==> 








The first  and its closing tag
is not seen in the reference docx
file, and we can see that it's invalid
XML here.

After:


















==> 


☐

==> 








Only the valid  around the
placeholder exists.
    
    Signed-off-by: Ashod Nakashian 
Change-Id: I1404e41aec3b5efdc2e4115236102ffa2733b15c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162802
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index aa9690efdb4a..4ad6dce4e288 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -70,6 +70,45 @@ CPPUNIT_TEST_FIXTURE(Test, testRotatedShapePosition)
 assertXPath(pXmlDoc, "//wpg:wgp/wps:wsp[1]/wps:spPr/a:xfrm/a:off"_ostr, 
"y"_ostr, "469440");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlOdt)
+{
+loadFromFile(u"tdf141786_RotatedShapeInGroup.odt");
+
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
+
+save("Office Open XML Text");
+// validate(maTempFile.GetFileName(), test::OOXML); // Enable when 
unrelated errors are fixed.
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlDocx)
+{
+{
+loadFromFile(u"dml-groupshape-polygon.docx");
+
+// Without TrackChanges, inserting the Checkbox works just fine
+// when exporting to docx.
+dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
+
+save("Office Open XML Text");
+// validate(maTempFile.GetFileName(), test::OOXML); // Enable when 
unrelated errors are fixed.
+}
+
+{
+loadFromFile(u"dml-groupshape-polygon.docx");
+
+// With TrackChanges, the Checkbox causes an assertion in the sax 
serializer,
+// in void 
sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32).
+// Element == maMarkStack.top()->m_DebugStartedElements.back()
+// sax/source/tools/fastserializer.cxx#402
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
+
+save("Office Open XML Text");
+// validate(maTempFile.GetFileName(), test::OOXML); // Enable when 
unrelated errors are fixed.
+}
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testDmlGroupshapePolygon)
 {
 // Given a document with a group shape, containing a single polygon child 
shape:
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 4b2402fc93c8..0054eca4cb34 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -115,6 +115,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -1177,8 +1178,12 @@ void 
SwWrtShell::InsertContentControl(SwContentControlType eType)
 Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 
aPlaceholder.getLength(),
   

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

2023-10-11 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx|   36 +
 svx/source/sdr/contact/viewcontact.cxx |2 +
 vcl/source/filter/graphicfilter.cxx|2 +
 3 files changed, 40 insertions(+)

New commits:
commit 01e89930f8a0d50758ed23b0cf2bfd7b9ee47b9b
Author: Ashod Nakashian 
AuthorDate: Sun Jul 23 10:07:04 2023 -0400
Commit: Caolán McNamara 
CommitDate: Wed Oct 11 12:45:49 2023 +0200

lok: flush the VOC primitives when trimming memory

Signed-off-by: Ashod Nakashian 
Change-Id: I0a7748a1fb1b58b3bcfc6b8fdfa1410a345849a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154812
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 5fba074e7f22ff0e5d5b9591a912193f7be8c08c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154868
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 67957a370751..40c11e54d080 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -8,6 +8,11 @@
  */
 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -3170,6 +3175,37 @@ static char* lo_extractRequest(LibreOfficeKit* 
/*pThis*/, const char* pFilePath)
 static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget)
 {
 vcl::lok::trimMemory(nTarget);
+
+if (nTarget > 2000)
+{
+SolarMutexGuard aGuard;
+
+// Flush all buffered VOC primitives from the pages.
+SfxViewShell* pViewShell = SfxViewShell::Current();
+if (pViewShell)
+{
+const SdrView* pView = pViewShell->GetDrawView();
+if (pView)
+{
+SdrPageView* pPageView = pView->GetSdrPageView();
+if (pPageView)
+{
+SdrPage* pCurPage = pPageView->GetPage();
+if (pCurPage)
+{
+SdrModel& sdrModel = 
pCurPage->getSdrModelFromSdrPage();
+for (sal_uInt16 i = 0; i < sdrModel.GetPageCount(); 
++i)
+{
+SdrPage* pPage = sdrModel.GetPage(i);
+if (pPage)
+
pPage->GetViewContact().flushViewObjectContacts();
+}
+}
+}
+}
+}
+}
+
 if (nTarget > 1000)
 {
 #ifdef HAVE_MALLOC_TRIM
diff --git a/svx/source/sdr/contact/viewcontact.cxx 
b/svx/source/sdr/contact/viewcontact.cxx
index 3529f98cf385..99106d0d6ed0 100644
--- a/svx/source/sdr/contact/viewcontact.cxx
+++ b/svx/source/sdr/contact/viewcontact.cxx
@@ -58,6 +58,8 @@ void ViewContact::deleteAllVOCs()
 
 // assert when there were new entries added during deletion
 DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted 
ViewObjectContactList in VC (!)");
+
+mxViewIndependentPrimitive2DSequence = 
drawinglayer::primitive2d::Primitive2DContainer();
 }
 
 // get an Object-specific ViewObjectContact for a specific
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index e323418674c8..f082e5b17d8b 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -694,12 +694,14 @@ void 
GraphicFilter::MakeGraphicsAvailableThreaded(std::vector& graphic
 if( toLoad.empty())
 return;
 std::vector< std::unique_ptr> streams;
+streams.reserve(toLoad.size());
 for( auto graphic : toLoad )
 {
 streams.push_back( std::make_unique( 
const_cast(graphic->GetSharedGfxLink()->GetData()),
 graphic->GetSharedGfxLink()->GetDataSize(), StreamMode::READ | 
StreamMode::WRITE));
 }
 std::vector< std::shared_ptr> loadedGraphics;
+loadedGraphics.reserve(streams.size());
 ImportGraphics(loadedGraphics, std::move(streams));
 assert(loadedGraphics.size() == toLoad.size());
 for( size_t i = 0; i < toLoad.size(); ++i )


[Libreoffice-commits] core.git: vcl/source

2023-10-10 Thread Ashod Nakashian (via logerrit)
 vcl/source/gdi/impgraph.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 27b05720c99b933a6cbb7a881433a70766962195
Author: Ashod Nakashian 
AuthorDate: Tue Jul 18 21:23:13 2023 -0400
Commit: Caolán McNamara 
CommitDate: Tue Oct 10 20:50:09 2023 +0200

vcl: swap out the BinaryDataContainer too

Signed-off-by: Ashod Nakashian 
Change-Id: I2e6ac88ff95903acf2df2070a7c23f4fc135c253
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154606
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit 896fc921cd72b5f0198772f2d4c569b59f51222c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154615
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 35a2145aa8e4..f3f877d3b939 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1308,6 +1308,8 @@ bool ImpGraphic::swapOut()
 // reset the swap file
 mpSwapFile.reset();
 
+mpGfxLink->getDataContainer().swapOut();
+
 // mark as swapped out
 mbSwapOut = true;
 


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - desktop/source svx/source vcl/source

2023-07-23 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx|   35 +
 svx/source/sdr/contact/viewcontact.cxx |2 +
 vcl/source/filter/graphicfilter.cxx|2 +
 3 files changed, 39 insertions(+)

New commits:
commit 5fba074e7f22ff0e5d5b9591a912193f7be8c08c
Author: Ashod Nakashian 
AuthorDate: Sun Jul 23 10:07:04 2023 -0400
Commit: Tomaž Vajngerl 
CommitDate: Sun Jul 23 21:18:39 2023 +0200

lok: flush the VOC primitives when trimming memory

Signed-off-by: Ashod Nakashian 
Change-Id: I0a7748a1fb1b58b3bcfc6b8fdfa1410a345849a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154812
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tomaž Vajngerl 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 81f797e5f197..c1ebf5d934ea 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7,7 +7,11 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include "sal/types.h"
 #include "sfx2/lokhelper.hxx"
+#include "svx/sdr/contact/viewcontact.hxx"
+#include "svx/svdpage.hxx"
+#include "svx/svdpagv.hxx"
 #include 
 #include 
 #include 
@@ -3151,6 +3155,37 @@ static char* lo_extractRequest(LibreOfficeKit* 
/*pThis*/, const char* pFilePath)
 static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget)
 {
 vcl::lok::trimMemory(nTarget);
+
+if (nTarget > 2000)
+{
+SolarMutexGuard aGuard;
+
+// Flush all buffered VOC primitives from the pages.
+SfxViewShell* pViewShell = SfxViewShell::Current();
+if (pViewShell)
+{
+const SdrView* pView = pViewShell->GetDrawView();
+if (pView)
+{
+SdrPageView* pPageView = pView->GetSdrPageView();
+if (pPageView)
+{
+SdrPage* pCurPage = pPageView->GetPage();
+if (pCurPage)
+{
+SdrModel& sdrModel = 
pCurPage->getSdrModelFromSdrPage();
+for (sal_uInt16 i = 0; i < sdrModel.GetPageCount(); 
++i)
+{
+SdrPage* pPage = sdrModel.GetPage(i);
+if (pPage)
+
pPage->GetViewContact().flushViewObjectContacts();
+}
+}
+}
+}
+}
+}
+
 if (nTarget > 1000)
 {
 #ifdef HAVE_MALLOC_TRIM
diff --git a/svx/source/sdr/contact/viewcontact.cxx 
b/svx/source/sdr/contact/viewcontact.cxx
index 2a5d73e509c3..9ecb324e200f 100644
--- a/svx/source/sdr/contact/viewcontact.cxx
+++ b/svx/source/sdr/contact/viewcontact.cxx
@@ -58,6 +58,8 @@ void ViewContact::deleteAllVOCs()
 
 // assert when there were new entries added during deletion
 DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted 
ViewObjectContactList in VC (!)");
+
+mxViewIndependentPrimitive2DSequence = 
drawinglayer::primitive2d::Primitive2DContainer();
 }
 
 // get an Object-specific ViewObjectContact for a specific
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index 6160493c3ec0..b113946c6ce8 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -716,12 +716,14 @@ void 
GraphicFilter::MakeGraphicsAvailableThreaded(std::vector& graphic
 if( toLoad.empty())
 return;
 std::vector< std::unique_ptr> streams;
+streams.reserve(toLoad.size());
 for( auto graphic : toLoad )
 {
 streams.push_back( std::make_unique( 
const_cast(graphic->GetSharedGfxLink()->GetData()),
 graphic->GetSharedGfxLink()->GetDataSize(), StreamMode::READ | 
StreamMode::WRITE));
 }
 std::vector< std::shared_ptr> loadedGraphics;
+loadedGraphics.reserve(streams.size());
 ImportGraphics(loadedGraphics, std::move(streams));
 assert(loadedGraphics.size() == toLoad.size());
 for( size_t i = 0; i < toLoad.size(); ++i )


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - vcl/source

2023-07-19 Thread Ashod Nakashian (via logerrit)
 vcl/source/gdi/impgraph.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 896fc921cd72b5f0198772f2d4c569b59f51222c
Author: Ashod Nakashian 
AuthorDate: Tue Jul 18 21:23:13 2023 -0400
Commit: Szymon Kłos 
CommitDate: Wed Jul 19 11:39:02 2023 +0200

vcl: swap out the BinaryDataContainer too

Signed-off-by: Ashod Nakashian 
Change-Id: I2e6ac88ff95903acf2df2070a7c23f4fc135c253
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154606
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 3b06fbe94787..54adbbf5bf5a 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1313,6 +1313,8 @@ bool ImpGraphic::swapOut()
 // reset the swap file
 mpSwapFile.reset();
 
+mpGfxLink->getDataContainer().swapOut();
+
 // mark as swapped out
 mbSwapOut = true;
 


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sfx2/source

2023-07-07 Thread Ashod Nakashian (via logerrit)
 sfx2/source/dialog/dinfdlg.cxx |   10 ++
 1 file changed, 10 insertions(+)

New commits:
commit 8017dc98b9037fff3df24ef7cc5a575dc40d2bb8
Author: Ashod Nakashian 
AuthorDate: Tue Jul 4 02:13:28 2023 -0400
Commit: Ashod Nakashian 
CommitDate: Fri Jul 7 21:37:04 2023 +0200

sfx2: disable setting password on text documents

Since we can't preserve the password in a plain-text
file, we should disable the ability to set/change
it. Otherwise, it's misleading to users.

Signed-off-by: Ashod Nakashian 
Change-Id: I3176243ddd2826eb07def1ff5ab251e33cb7125e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153918
Reviewed-by: Jaume Pujantell 
Tested-by: Jenkins CollaboraOffice 

diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 71eeafc6ff6f..c8f68fdaa9ba 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1025,6 +1025,16 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
 {
 m_xFileValEd->set_label(aName);
 m_xFileValEd->set_uri(aName);
+
+// Disable setting/changing password on text files.
+// Perhaps this needs to be done for both Online and Desktop.
+OUString sExtension(INetURLObject(rMainURL).getExtension());
+if (!sExtension.isEmpty())
+{
+sExtension = sExtension.toAsciiLowerCase();
+if (sExtension.equalsAscii("txt") || sExtension.equalsAscii("csv"))
+m_xChangePassBtn->set_sensitive(false);
+}
 }
 else
 {


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sfx2/source

2023-07-06 Thread Ashod Nakashian (via logerrit)
 sfx2/source/dialog/dinfdlg.cxx |   10 ++
 1 file changed, 10 insertions(+)

New commits:
commit 1b7d41abd0f281651dca1c8c7b7b62f952e8022b
Author: Ashod Nakashian 
AuthorDate: Tue Jul 4 02:13:28 2023 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Jul 6 11:26:26 2023 +0200

sfx2: disable setting password on text documents

Since we can't preserve the password in a plain-text
file, we should disable the ability to set/change
it. Otherwise, it's misleading to users.

Signed-off-by: Ashod Nakashian 
Change-Id: I3176243ddd2826eb07def1ff5ab251e33cb7125e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153941
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jaume Pujantell 

diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 85b9e50fc941..52416c1f55d0 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1025,6 +1025,16 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
 {
 m_xFileValEd->set_label(aName);
 m_xFileValEd->set_uri(aName);
+
+// Disable setting/changing password on text files.
+// Perhaps this needs to be done for both Online and Desktop.
+OUString sExtension(INetURLObject(rMainURL).getExtension());
+if (!sExtension.isEmpty())
+{
+sExtension = sExtension.toAsciiLowerCase();
+if (sExtension.equalsAscii("txt") || sExtension.equalsAscii("csv"))
+m_xChangePassBtn->set_sensitive(false);
+}
 }
 else
 {


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

2023-07-06 Thread Ashod Nakashian (via logerrit)
 sfx2/source/dialog/dinfdlg.cxx |   10 ++
 1 file changed, 10 insertions(+)

New commits:
commit 45d7ffb7f238fbb8cf99cdcd386c496223915ab7
Author: Ashod Nakashian 
AuthorDate: Tue Jul 4 02:13:28 2023 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Jul 6 11:25:04 2023 +0200

sfx2: disable setting password on text documents

Since we can't preserve the password in a plain-text
file, we should disable the ability to set/change
it. Otherwise, it's misleading to users.

Signed-off-by: Ashod Nakashian 
Change-Id: I3176243ddd2826eb07def1ff5ab251e33cb7125e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153917
Tested-by: Jenkins
Reviewed-by: Jaume Pujantell 

diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index f8caa35aad90..800f912b2ac9 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1024,6 +1024,16 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
 {
 m_xFileValEd->set_label(aName);
 m_xFileValEd->set_uri(aName);
+
+// Disable setting/changing password on text files.
+// Perhaps this needs to be done for both Online and Desktop.
+OUString sExtension(INetURLObject(rMainURL).getExtension());
+if (!sExtension.isEmpty())
+{
+sExtension = sExtension.toAsciiLowerCase();
+if (sExtension == "txt" || sExtension == "csv")
+m_xChangePassBtn->set_sensitive(false);
+}
 }
 else
 {


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

2023-06-26 Thread Ashod Nakashian (via logerrit)
 include/sfx2/lokhelper.hxx  |4 
 include/svx/svdomedia.hxx   |3 ---
 sfx2/source/view/lokhelper.cxx  |9 -
 svx/source/svdraw/svdmrkv.cxx   |   25 +++--
 svx/source/svdraw/svdomedia.cxx |   23 ---
 5 files changed, 15 insertions(+), 49 deletions(-)

New commits:
commit 097cf021cb946da7ebc6fe548fb035aec2d4eaa5
Author: Ashod Nakashian 
AuthorDate: Sat Feb 11 14:53:44 2023 -0500
Commit: Aron Budea 
CommitDate: Tue Jun 27 06:26:51 2023 +0200

lok: only publish MEDIA_SHAPE to selecting view

We now publish the url for the media shape
in the LOK_CALLBACK_GRAPHIC_SELECTION message.

This has many advantages, most notably that it
only sends the URL to the view selecting the
media. Also, it is now easier to handle
the message as there is no need for both
a LOK_CALLBACK_GRAPHIC_SELECTION and
a LOK_CALLBACK_MEDIA_SHAPE. However, the
latter is still defined as we might still
use it at some point.

Signed-off-by: Ashod Nakashian 
Change-Id: I8d4b8794d8e590628630f2b0bfbfb5debe02515f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146848
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153009
Reviewed-by: Pranam Lashkari 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153369
Tested-by: Jenkins
Reviewed-by: Aron Budea 

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 08d66fd538cc..b46097938695 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -182,10 +182,6 @@ public:
 /// Helper for diagnosing run-time problems
 static void dumpState(rtl::OStringBuffer &rState);
 
-/// Notify all views of a media update.
-/// This could be a new insertion or property modifications to an existing 
one.
-static void notifyMediaUpdate(boost::property_tree::ptree& json);
-
 /// Process the mouse event in the currently active in-place component (if 
any).
 /// Returns true if the event has been processed, and no further 
processing is necessary.
 static bool testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, 
int nType, int nX,
diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx
index e3120c672f3d..aead70568511 100644
--- a/include/svx/svdomedia.hxx
+++ b/include/svx/svdomedia.hxx
@@ -75,9 +75,6 @@ public:
 
 virtual bool shouldKeepAspectRatio() const override { return true; }
 
-/// When Lokit is enabled, notify the media details.
-void notifyPropertiesForLOKit();
-
 private:
 voidmediaPropertiesChanged( const 
::avmedia::MediaItem& rNewState );
 virtual std::unique_ptr 
CreateObjectSpecificViewContact() override;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 356925a6a341..0d598460d7c1 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -983,15 +983,6 @@ void SfxLokHelper::dumpState(rtl::OStringBuffer &rState)
 }
 }
 
-void SfxLokHelper::notifyMediaUpdate(boost::property_tree::ptree& json)
-{
-std::stringstream aStream;
-boost::property_tree::write_json(aStream, json, /*pretty=*/ false);
-const std::string str = aStream.str();
-
-SfxLokHelper::notifyAllViews(LOK_CALLBACK_MEDIA_SHAPE, OString(str));
-}
-
 bool SfxLokHelper::testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, 
int nType, int nX,
  int nY, int nCount, int 
nButtons,
  int nModifier, double 
fScaleX, double fScaleY,
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index fa0ec5aa084f..7a623dca9c92 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -823,10 +823,12 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 }
 
 {
+OStringBuffer aExtraInfo;
 OString sSelectionText;
 OString sSelectionTextView;
 boost::property_tree::ptree aTableJsonTree;
 boost::property_tree::ptree aGluePointsTree;
+const bool bMediaObj = (mpMarkedObj && mpMarkedObj->GetObjIdentifier() 
== SdrObjKind::Media);
 bool bTableSelection = false;
 bool bConnectorSelection = false;
 
@@ -839,6 +841,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 {
 bConnectorSelection = dumpGluePointsToJSON(aGluePointsTree);
 }
+
 if (GetMarkedObjectCount())
 {
 SdrMark* pM = GetSdrMarkByIndex(0);
@@ -848,7 +851,6 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 // (SwVirtFlyDrawObj with a SwGrfNode)
 bool bWriterGraphic = pO->HasLimitedRotat

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - include/sfx2 include/svx sfx2/source svx/source

2023-06-20 Thread Ashod Nakashian (via logerrit)
 include/sfx2/lokhelper.hxx  |4 
 include/svx/svdomedia.hxx   |3 ---
 sfx2/source/view/lokhelper.cxx  |9 -
 svx/source/svdraw/svdmrkv.cxx   |   33 +
 svx/source/svdraw/svdomedia.cxx |   23 ---
 5 files changed, 21 insertions(+), 51 deletions(-)

New commits:
commit f4f9e9d472ee6a9a029ddca78374cbb948c8c73c
Author: Ashod Nakashian 
AuthorDate: Sat Feb 11 14:53:44 2023 -0500
Commit: Pranam Lashkari 
CommitDate: Tue Jun 20 19:03:13 2023 +0200

lok: only publish MEDIA_SHAPE to selecting view

We now publish the url for the media shape
in the LOK_CALLBACK_GRAPHIC_SELECTION message.

This has many advantages, most notably that it
only sends the URL to the view selecting the
media. Also, it is now easier to handle
the message as there is no need for both
a LOK_CALLBACK_GRAPHIC_SELECTION and
a LOK_CALLBACK_MEDIA_SHAPE. However, the
latter is still defined as we might still
use it at some point.

Signed-off-by: Ashod Nakashian 
Change-Id: I8d4b8794d8e590628630f2b0bfbfb5debe02515f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146848
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153009
Reviewed-by: Pranam Lashkari 

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index d2adacad55e6..3e94854f6d46 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -182,10 +182,6 @@ public:
 /// Helper for diagnosing run-time problems
 static void dumpState(rtl::OStringBuffer &rState);
 
-/// Notify all views of a media update.
-/// This could be a new insertion or property modifications to an existing 
one.
-static void notifyMediaUpdate(boost::property_tree::ptree& json);
-
 /// Process the mouse event in the currently active in-place component (if 
any).
 /// Returns true if the event has been processed, and no further 
processing is necessary.
 static bool testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, 
int nType, int nX,
diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx
index 6f08611a7002..6e0925d68188 100644
--- a/include/svx/svdomedia.hxx
+++ b/include/svx/svdomedia.hxx
@@ -75,9 +75,6 @@ public:
 
 virtual bool shouldKeepAspectRatio() const override { return true; }
 
-/// When Lokit is enabled, notify the media details.
-void notifyPropertiesForLOKit();
-
 private:
 voidmediaPropertiesChanged( const 
::avmedia::MediaItem& rNewState );
 virtual std::unique_ptr 
CreateObjectSpecificViewContact() override;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 3fd57f32200e..83f05008a19b 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -988,15 +988,6 @@ void SfxLokHelper::dumpState(rtl::OStringBuffer &rState)
 }
 }
 
-void SfxLokHelper::notifyMediaUpdate(boost::property_tree::ptree& json)
-{
-std::stringstream aStream;
-boost::property_tree::write_json(aStream, json, /*pretty=*/ false);
-const std::string str = aStream.str();
-
-SfxLokHelper::notifyAllViews(LOK_CALLBACK_MEDIA_SHAPE, str.c_str());
-}
-
 bool SfxLokHelper::testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, 
int nType, int nX,
  int nY, int nCount, int 
nButtons,
  int nModifier, double 
fScaleX, double fScaleY,
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 76fad2bbfee4..5aea593f5f80 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -823,10 +823,12 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 }
 
 {
+OStringBuffer aExtraInfo;
 OString sSelectionText;
 OString sSelectionTextView;
 boost::property_tree::ptree aTableJsonTree;
 boost::property_tree::ptree aGluePointsTree;
+const bool bMediaObj = (mpMarkedObj && mpMarkedObj->GetObjIdentifier() 
== SdrObjKind::Media);
 bool bTableSelection = false;
 bool bConnectorSelection = false;
 
@@ -839,6 +841,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 {
 bConnectorSelection = dumpGluePointsToJSON(aGluePointsTree);
 }
+
 if (GetMarkedObjectCount())
 {
 SdrMark* pM = GetSdrMarkByIndex(0);
@@ -848,7 +851,6 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 // (SwVirtFlyDrawObj with a SwGrfNode)
 bool bWriterGraphic = pO->HasLimitedRotation();
 
-OStringBuffer aExtraInfo;
 OString handleArrayStr;
 
 aExtraInfo.appe

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - desktop/source

2023-04-26 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx |   21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

New commits:
commit 8143148f6d7d3237ae1e438f3ed0a637a21549b8
Author: Ashod Nakashian 
AuthorDate: Sat Mar 11 10:11:07 2023 -0500
Commit: Miklos Vajna 
CommitDate: Wed Apr 26 13:56:09 2023 +0200

lok: capture and publish the modified status in save result

This is necessary to flag to the storage whether or not
the contents of the file being uploaded has any user
modifications or not. This is typically used to optimize
the versioning and storage utilization.

We also add the time when saving started and the duration
it took. The timestamp is to figure out if there has been
subsequent activity/commands that could have modified
the document. The duration is to help Online throttle
saving if too frequent.

Signed-off-by: Ashod Nakashian 
Change-Id: Id6d8e629ef9b6e723d1d8b84d64fc7741b997bc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150035
Tested-by: Miklos Vajna 
Reviewed-by: Miklos Vajna 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d6a0904210a2..9dc5b6bf66f2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4598,13 +4598,18 @@ namespace {
 */
 class DispatchResultListener : public 
cppu::WeakImplHelper
 {
-OString maCommand; ///< Command for which this is the 
result.
-std::shared_ptr mpCallback; ///< Callback to call.
+const OString maCommand; ///< Command for which this is the result.
+const std::shared_ptr mpCallback; ///< Callback to 
call.
+const std::chrono::steady_clock::time_point mSaveTime; //< The time we 
started saving.
+const bool mbWasModified; //< Whether or not the document was modified 
before saving.
 
 public:
-DispatchResultListener(const char* pCommand, 
std::shared_ptr const & pCallback)
+DispatchResultListener(const char* pCommand,
+   std::shared_ptr const& 
pCallback)
 : maCommand(pCommand)
 , mpCallback(pCallback)
+, mSaveTime(std::chrono::steady_clock::now())
+, mbWasModified(SfxObjectShell::Current()->IsModified())
 {
 assert(mpCallback);
 }
@@ -4621,6 +4626,16 @@ public:
 }
 
 unoAnyToJson(aJson, "result", rEvent.Result);
+aJson.put("wasModified", mbWasModified);
+
+const auto saveTime = 
std::chrono::time_point_cast(mSaveTime);
+aJson.put("startUnixTimeMics",
+  static_cast(saveTime.time_since_epoch().count()));
+
+const auto saveDuration = 
std::chrono::duration_cast(
+std::chrono::steady_clock::now() - mSaveTime);
+aJson.put("saveDurationMics", 
static_cast(saveDuration.count()));
+
 mpCallback->queue(LOK_CALLBACK_UNO_COMMAND_RESULT, 
aJson.extractData());
 }
 


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - desktop/source

2023-04-17 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx |   18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

New commits:
commit 5700349951fa4bba750836d6f4b0979b005e11c0
Author: Ashod Nakashian 
AuthorDate: Sat Mar 11 10:11:07 2023 -0500
Commit: Miklos Vajna 
CommitDate: Mon Apr 17 11:49:17 2023 +0200

lok: capture and publish the modified status in save result

This is necessary to flag to the storage whether or not
the contents of the file being uploaded has any user
modifications or not. This is typically used to optimize
the versioning and storage utilization.

We also add the time when saving started and the duration
it took. The timestamp is to figure out if there has been
subsequent activity/commands that could have modified
the document. The duration is to help Online throttle
saving if too frequent.

Signed-off-by: Ashod Nakashian 
Change-Id: Id6d8e629ef9b6e723d1d8b84d64fc7741b997bc5
(cherry picked from commit 26742677b53a33e1aaee191750f7af51e4b56844)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150380
Reviewed-by: Miklos Vajna 
Tested-by: Ashod Nakashian 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 20cc63231cbd..918a4fe04368 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4631,13 +4631,17 @@ namespace {
 */
 class DispatchResultListener : public 
cppu::WeakImplHelper
 {
-OString maCommand; ///< Command for which this is the 
result.
-std::shared_ptr mpCallback; ///< Callback to call.
+const OString maCommand; ///< Command for which this is the result.
+const std::shared_ptr mpCallback; ///< Callback to 
call.
+const std::chrono::steady_clock::time_point mSaveTime; //< The time we 
started saving.
+const bool mbWasModified; //< Whether or not the document was modified 
before saving.
 
 public:
 DispatchResultListener(const char* pCommand, 
std::shared_ptr pCallback)
 : maCommand(pCommand)
 , mpCallback(std::move(pCallback))
+, mSaveTime(std::chrono::steady_clock::now())
+, mbWasModified(SfxObjectShell::Current()->IsModified())
 {
 assert(mpCallback);
 }
@@ -4654,6 +4658,16 @@ public:
 }
 
 unoAnyToJson(aJson, "result", rEvent.Result);
+aJson.put("wasModified", mbWasModified);
+
+const auto saveTime = 
std::chrono::time_point_cast(mSaveTime);
+aJson.put("startUnixTimeMics",
+  static_cast(saveTime.time_since_epoch().count()));
+
+const auto saveDuration = 
std::chrono::duration_cast(
+std::chrono::steady_clock::now() - mSaveTime);
+aJson.put("saveDurationMics", 
static_cast(saveDuration.count()));
+
 mpCallback->queue(LOK_CALLBACK_UNO_COMMAND_RESULT, 
aJson.extractData());
 }
 


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

2023-04-12 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx |   16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 81dc568ab3f504bca58810da0b0bd3c4c2737096
Author: Ashod Nakashian 
AuthorDate: Sat Mar 11 10:11:07 2023 -0500
Commit: Miklos Vajna 
CommitDate: Wed Apr 12 14:03:55 2023 +0200

lok: capture and publish the modified status in save result

This is necessary to flag to the storage whether or not
the contents of the file being uploaded has any user
modifications or not. This is typically used to optimize
the versioning and storage utilization.

We also add the time when saving started and the duration
it took. The timestamp is to figure out if there has been
subsequent activity/commands that could have modified
the document. The duration is to help Online throttle
saving if too frequent.

Signed-off-by: Ashod Nakashian 
Change-Id: Id6d8e629ef9b6e723d1d8b84d64fc7741b997bc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149985
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0521af8b427a..49d4298c7a66 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4612,13 +4612,17 @@ namespace {
 */
 class DispatchResultListener : public 
cppu::WeakImplHelper
 {
-OString maCommand; ///< Command for which this is the 
result.
-std::shared_ptr mpCallback; ///< Callback to call.
+const OString maCommand; ///< Command for which this is the result.
+const std::shared_ptr mpCallback; ///< Callback to 
call.
+const std::chrono::steady_clock::time_point mSaveTime; //< The time we 
started saving.
+const bool mbWasModified; //< Whether or not the document was modified 
before saving.
 
 public:
 DispatchResultListener(const char* pCommand, 
std::shared_ptr pCallback)
 : maCommand(pCommand)
 , mpCallback(std::move(pCallback))
+, mSaveTime(std::chrono::steady_clock::now())
+, mbWasModified(SfxObjectShell::Current()->IsModified())
 {
 assert(mpCallback);
 }
@@ -4635,6 +4639,14 @@ public:
 }
 
 unoAnyToJson(aJson, "result", rEvent.Result);
+aJson.put("wasModified", mbWasModified);
+aJson.put("startUnixTimeMics",
+  
std::chrono::time_point_cast(mSaveTime)
+  .time_since_epoch()
+  .count());
+aJson.put("saveDurationMics", 
std::chrono::duration_cast(
+  std::chrono::steady_clock::now() - 
mSaveTime)
+  .count());
 mpCallback->queue(LOK_CALLBACK_UNO_COMMAND_RESULT, 
aJson.finishAndGetAsOString());
 }
 


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - include/sfx2 include/svx sfx2/source svx/source

2023-02-14 Thread Ashod Nakashian (via logerrit)
 include/sfx2/lokhelper.hxx  |4 
 include/svx/svdomedia.hxx   |3 ---
 sfx2/source/view/lokhelper.cxx  |9 -
 svx/source/svdraw/svdmrkv.cxx   |   31 +--
 svx/source/svdraw/svdomedia.cxx |   23 ---
 5 files changed, 21 insertions(+), 49 deletions(-)

New commits:
commit 0cea676ceb46dcdb9ba739db79dbc6f0d7b3dc29
Author: Ashod Nakashian 
AuthorDate: Sat Feb 11 14:53:44 2023 -0500
Commit: Szymon Kłos 
CommitDate: Tue Feb 14 11:56:22 2023 +

lok: only publish MEDIA_SHAPE to selecting view

We now publish the url for the media shape
in the LOK_CALLBACK_GRAPHIC_SELECTION message.

This has many advantages, most notably that it
only sends the URL to the view selecting the
media. Also, it is now easier to handle
the message as there is no need for both
a LOK_CALLBACK_GRAPHIC_SELECTION and
a LOK_CALLBACK_MEDIA_SHAPE. However, the
latter is still defined as we might still
use it at some point.

Signed-off-by: Ashod Nakashian 
Change-Id: I8d4b8794d8e590628630f2b0bfbfb5debe02515f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146848
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 16e48c791d65..95eb0a9f9f6f 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -172,10 +172,6 @@ public:
 /// Helper for diagnosing run-time problems
 static void dumpState(rtl::OStringBuffer &rState);
 
-/// Notify all views of a media update.
-/// This could be a new insertion or property modifications to an existing 
one.
-static void notifyMediaUpdate(boost::property_tree::ptree& json);
-
 /// Process the mouse event in the currently active in-place component (if 
any).
 /// Returns true if the event has been processed, and no further 
processing is necessary.
 static bool testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, 
int nType, int nX,
diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx
index 36b00f276d80..629ad980e6b3 100644
--- a/include/svx/svdomedia.hxx
+++ b/include/svx/svdomedia.hxx
@@ -75,9 +75,6 @@ public:
 
 virtual bool shouldKeepAspectRatio() const override { return true; }
 
-/// When Lokit is enabled, notify the media details.
-void notifyPropertiesForLOKit();
-
 private:
 voidmediaPropertiesChanged( const 
::avmedia::MediaItem& rNewState );
 virtual std::unique_ptr 
CreateObjectSpecificViewContact() override;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index e61263acc8c6..166aa124777e 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -960,15 +960,6 @@ void SfxLokHelper::dumpState(rtl::OStringBuffer &rState)
 }
 }
 
-void SfxLokHelper::notifyMediaUpdate(boost::property_tree::ptree& json)
-{
-std::stringstream aStream;
-boost::property_tree::write_json(aStream, json, /*pretty=*/ false);
-const std::string str = aStream.str();
-
-SfxLokHelper::notifyAllViews(LOK_CALLBACK_MEDIA_SHAPE, str.c_str());
-}
-
 bool SfxLokHelper::testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, 
int nType, int nX,
  int nY, int nCount, int 
nButtons,
  int nModifier, double 
fScaleX, double fScaleY,
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index f48051e974c0..bd0fe4c8993c 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -825,10 +825,12 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 }
 
 {
+OStringBuffer aExtraInfo;
 OString sSelectionText;
 OString sSelectionTextView;
 boost::property_tree::ptree aTableJsonTree;
 boost::property_tree::ptree aGluePointsTree;
+const bool bMediaObj = (mpMarkedObj && mpMarkedObj->GetObjIdentifier() 
== OBJ_MEDIA);
 bool bTableSelection = false;
 bool bConnectorSelection = false;
 
@@ -841,6 +843,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 {
 bConnectorSelection = dumpGluePointsToJSON(aGluePointsTree);
 }
+
 if (GetMarkedObjectCount())
 {
 SdrMark* pM = GetSdrMarkByIndex(0);
@@ -850,7 +853,6 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 // (SwVirtFlyDrawObj with a SwGrfNode)
 bool bWriterGraphic = pO->HasLimitedRotation();
 
-OStringBuffer aExtraInfo;
 OString handleArrayStr;
 
 aExtraInfo.append("{\"id\":\"");
@@ -1009,6 +1011,7 @@ void SdrMa

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

2023-01-29 Thread Ashod Nakashian (via logerrit)
 comphelper/source/misc/lok.cxx  |   19 ++
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 +-
 desktop/source/lib/init.cxx |   49 
 include/LibreOfficeKit/LibreOfficeKit.h |3 +
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   11 ++
 include/comphelper/lok.hxx  |3 +
 include/sfx2/lokhelper.hxx  |   11 ++
 include/sfx2/viewsh.hxx |   17 +
 sc/source/ui/view/viewfun6.cxx  |   19 ++
 sfx2/source/view/lokhelper.cxx  |   42 
 sfx2/source/view/viewsh.cxx |4 ++
 11 files changed, 181 insertions(+), 1 deletion(-)

New commits:
commit e2d646665c4cb4c7eeb0a73cb5f460838589bef0
Author: Ashod Nakashian 
AuthorDate: Fri Dec 23 13:02:57 2022 -0500
Commit: Andras Timar 
CommitDate: Sun Jan 29 13:22:28 2023 +

lok: support per-user timezone

This adds support for user-specific timezone.

When none is provided during loading, the
system default is used.

Signed-off-by: Ashod Nakashian 
Change-Id: Ie863450687eb82bc475268a09c9112e9fd50020f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144816
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 
(cherry picked from commit abaf8c0af1c6c7fe01276fdf2ae62419c7b0f654)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146211
Tested-by: Jenkins
Reviewed-by: Andras Timar 

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index b11bf4e83582..1f07cd2614eb 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
@@ -255,6 +256,24 @@ bool isAllowlistedLanguage(const OUString& lang)
 #endif
 }
 
+void setTimezone(bool isSet, const OUString& rTimezone)
+{
+if (isSet)
+{
+// Set the given timezone, even if empty.
+osl_setEnvironment(OUString("TZ").pData, rTimezone.pData);
+}
+else
+{
+// Unset and empty aren't the same.
+// When unset, it means default to the system configured timezone.
+osl_clearEnvironment(OUString("TZ").pData);
+}
+
+// Update the timezone data.
+::tzset();
+}
+
 static void (*pStatusIndicatorCallback)(void *data, 
statusIndicatorCallbackType type, int percent, const char* pText)(nullptr);
 static void *pStatusIndicatorCallbackData(nullptr);
 
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 98c734c8190a..a5560dd6be8d 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3629,10 +3629,12 @@ void DesktopLOKTest::testABI()
 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));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(68),
+ offsetof(struct _LibreOfficeKitDocumentClass, 
setViewTimezone));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(68), 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 97d74bc4682d..db9a9632e4c3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7,6 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include 
 #include 
 #include 
 
@@ -1203,6 +1204,8 @@ static bool 
doc_renderSearchResult(LibreOfficeKitDocument* pThis,
 
 static void doc_sendContentControlEvent(LibreOfficeKitDocument* pThis, const 
char* pArguments);
 
+static void doc_setViewTimezone(LibreOfficeKitDocument* pThis, int nId, const 
char* timezone);
+
 } // extern "C"
 
 namespace {
@@ -1353,6 +1356,8 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference 
 xC
 
 m_pDocumentClass->sendContentControlEvent = 
doc_sendContentControlEvent;
 
+m_pDocumentClass->setViewTimezone = doc_setViewTimezone;
+
 gDocumentClass = m_pDocumentClass;
 }
 pClass = m_pDocumentClass.get();
@@ -2600,6 +2605,27 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 SvNumberFormatter::resetTheCurrencyTable();
 }
 
+// Set the timezone, if not empty.
+const OUString aTimezone = extractParameter(aOptions, u"Timezone");
+if 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - comphelper/source desktop/qa desktop/source include/comphelper include/LibreOfficeKit include/sfx2 sc/source sfx2/source

2023-01-13 Thread Ashod Nakashian (via logerrit)
 comphelper/source/misc/lok.cxx  |   19 ++
 desktop/qa/desktop_lib/test_desktop_lib.cxx |4 +-
 desktop/source/lib/init.cxx |   49 
 include/LibreOfficeKit/LibreOfficeKit.h |3 +
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   11 ++
 include/comphelper/lok.hxx  |3 +
 include/sfx2/lokhelper.hxx  |   11 ++
 include/sfx2/viewsh.hxx |   17 +
 sc/source/ui/view/viewfun6.cxx  |   19 ++
 sfx2/source/view/lokhelper.cxx  |   42 
 sfx2/source/view/viewsh.cxx |4 ++
 11 files changed, 181 insertions(+), 1 deletion(-)

New commits:
commit abaf8c0af1c6c7fe01276fdf2ae62419c7b0f654
Author: Ashod Nakashian 
AuthorDate: Fri Dec 23 13:02:57 2022 -0500
Commit: Ashod Nakashian 
CommitDate: Fri Jan 13 12:48:58 2023 +

lok: support per-user timezone

This adds support for user-specific timezone.

When none is provided during loading, the
system default is used.

Signed-off-by: Ashod Nakashian 
Change-Id: Ie863450687eb82bc475268a09c9112e9fd50020f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144816
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index 45037f862bd7..816239e91c2e 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -256,6 +257,24 @@ bool isAllowlistedLanguage(const OUString& lang)
 #endif
 }
 
+void setTimezone(bool isSet, const OUString& rTimezone)
+{
+if (isSet)
+{
+// Set the given timezone, even if empty.
+osl_setEnvironment(OUString("TZ").pData, rTimezone.pData);
+}
+else
+{
+// Unset and empty aren't the same.
+// When unset, it means default to the system configured timezone.
+osl_clearEnvironment(OUString("TZ").pData);
+}
+
+// Update the timezone data.
+::tzset();
+}
+
 static void (*pStatusIndicatorCallback)(void *data, 
statusIndicatorCallbackType type, int percent, const char* pText)(nullptr);
 static void *pStatusIndicatorCallbackData(nullptr);
 
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 46812f7f05ee..b41a9c16f8d8 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3660,10 +3660,12 @@ void DesktopLOKTest::testABI()
 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));
+CPPUNIT_ASSERT_EQUAL(documentClassOffset(68),
+ offsetof(struct _LibreOfficeKitDocumentClass, 
setViewTimezone));
 
 // Extending is fine, update this, and add new assert for the offsetof the
 // new method
-CPPUNIT_ASSERT_EQUAL(documentClassOffset(68), 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 75a0748fee84..377667804e74 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7,6 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include "sfx2/lokhelper.hxx"
 #include 
 #include 
 
@@ -1204,6 +1205,8 @@ static bool 
doc_renderSearchResult(LibreOfficeKitDocument* pThis,
 
 static void doc_sendContentControlEvent(LibreOfficeKitDocument* pThis, const 
char* pArguments);
 
+static void doc_setViewTimezone(LibreOfficeKitDocument* pThis, int nId, const 
char* timezone);
+
 } // extern "C"
 
 namespace {
@@ -1352,6 +1355,8 @@ LibLODocument_Impl::LibLODocument_Impl(const 
uno::Reference sendContentControlEvent = 
doc_sendContentControlEvent;
 
+m_pDocumentClass->setViewTimezone = doc_setViewTimezone;
+
 gDocumentClass = m_pDocumentClass;
 }
 pClass = m_pDocumentClass.get();
@@ -2599,6 +2604,27 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 SvNumberFormatter::resetTheCurrencyTable();
 }
 
+// Set the timezone, if not empty.
+const OUString aTimezone = extractParameter(aOptions, u"Timezone");
+if (!aTimezone.isEmpty())
+{
+SfxLokHelper::setDefaultTimezone(true, aTimezone);
+}
+else
+{
+// Default to the TZ envar, if set.

[Libreoffice-commits] core.git: filter/source include/svx sd/qa svx/source

2022-11-04 Thread Ashod Nakashian (via logerrit)
 filter/source/svg/svgwriter.cxx   |   46 +++---
 include/svx/svdomedia.hxx |3 +
 sd/qa/unit/SVGExportTests.cxx |   35 +++
 sd/qa/unit/data/odp/slide-video-thumbnail.odp |binary
 svx/source/svdraw/svdomedia.cxx   |   10 +
 5 files changed, 90 insertions(+), 4 deletions(-)

New commits:
commit f994f4312d8e166e79b36f7bf0f8c41c3f1082f4
Author: Ashod Nakashian 
AuthorDate: Sun Oct 23 17:56:50 2022 -0400
Commit: Miklos Vajna 
CommitDate: Fri Nov 4 08:28:25 2022 +0100

svg: export embedded video

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

diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index fb0193e15418..14e355f3916e 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2997,12 +2998,49 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& 
rBmpEx,
 mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, 
OUString::number( aSz.Width() ) );
 mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, 
OUString::number( aSz.Height() ) );
 
-// the image must be scaled to aSz in a non-uniform way
-mrExport.AddAttribute( XML_NAMESPACE_NONE, "preserveAspectRatio", "none" );
+// If we have a media object (a video), export the video.
+// Also, use the image generated above as the video poster (thumbnail).
+SdrMediaObj* pMediaObj
+= pShape ? 
dynamic_cast(SdrObject::getSdrObjectFromXShape(*pShape)) : 
nullptr;
+const bool embedVideo = (pMediaObj && !pMediaObj->getTempURL().isEmpty());
 
-mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, 
aBuffer.makeStringAndClear() );
+if (!embedVideo)
 {
-SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, "image", true, 
true );
+// the image must be scaled to aSz in a non-uniform way
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "preserveAspectRatio", 
"none");
+
+mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, 
aBuffer.makeStringAndClear());
+
+SvXMLElementExport aElem(mrExport, XML_NAMESPACE_NONE, "image", true, 
true);
+}
+else
+{
+// http://www.w3.org/2000/svg"; 
overflow="visible" width="499.6" height="374.37" x="705" y="333">
+// http://www.w3.org/1999/xhtml";>
+// 
+// 
+// 
+// 
+// 
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "xmlns", 
"http://www.w3.org/2000/svg";);
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "overflow", "visible");
+SvXMLElementExport aForeignObject(mrExport, XML_NAMESPACE_NONE, 
"foreignObject", true,
+  true);
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "xmlns", 
"http://www.w3.org/1999/xhtml";);
+SvXMLElementExport aBody(mrExport, XML_NAMESPACE_NONE, "body", true, 
true);
+
+mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrWidth, 
OUString::number(aSz.Width()));
+mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrHeight, 
OUString::number(aSz.Height()));
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "autoplay", "autoplay");
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "controls", "controls");
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "loop", "loop");
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "preload", "auto");
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "poster", 
aBuffer.makeStringAndClear());
+SvXMLElementExport aVideo(mrExport, XML_NAMESPACE_NONE, "video", true, 
true);
+
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "src", 
pMediaObj->getTempURL());
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "type", "video/mp4"); 
//FIXME: set mime type.
+SvXMLElementExport aSource(mrExport, XML_NAMESPACE_NONE, "source", 
true, true);
 }
 }
 
diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx
index 6199fcaffe5b..6f08611a7002 100644
--- a/include/svx/svdomedia.hxx
+++ b/include/svx/svdomedia.hxx
@@ -61,6 +61,9 @@ public:
 voidsetURL( const OUString& rURL, const 
OUString& rReferer, const OUString& rMimeType = OUString() );
 const OUString&  getURL() const;
 
+/// Returns the URL to the temporary extracted media file.
+const OUStri

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - svx/source

2022-11-01 Thread Ashod Nakashian (via logerrit)
 svx/source/svdraw/svdomedia.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 883991127988582d952abd29e0282ab5b5a916b8
Author: Ashod Nakashian 
AuthorDate: Fri Oct 28 07:35:26 2022 -0400
Commit: Andras Timar 
CommitDate: Tue Nov 1 21:11:13 2022 +0100

svx: minor simplification

Hoping this might help the iOS build, which says:

Undefined symbols for architecture arm64:
  "avmedia::MediaItem::getTempURL() const", referenced from:
SdrMediaObj::notifyPropertiesForLOKit() in
libsvxcorelo.a(svdomedia.o)

ld: symbol(s) not found for architecture arm64

Signed-off-by: Ashod Nakashian 
Change-Id: Ie12ac09063a07cea566cdda066b03ca1e3cd5296
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141971
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 

diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 54ebed5425db..75bfce24428c 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -445,14 +445,14 @@ void SdrMediaObj::mediaPropertiesChanged( const 
::avmedia::MediaItem& rNewProper
 void SdrMediaObj::notifyPropertiesForLOKit()
 {
 #if HAVE_FEATURE_AVMEDIA
-if (!m_xImpl->m_MediaProperties.getTempURL().isEmpty())
+if (!getTempURL().isEmpty())
 {
 const auto mediaId = reinterpret_cast(this);
 
 boost::property_tree::ptree json;
 json.put("action", "update");
 json.put("id", mediaId);
-json.put("url", m_xImpl->m_MediaProperties.getTempURL());
+json.put("url", getTempURL());
 
 const tools::Rectangle aRect = o3tl::convert(maRect, 
o3tl::Length::mm100, o3tl::Length::twip);
 json.put("x", aRect.getX());


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

2022-10-25 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx  |1 +
 include/LibreOfficeKit/LibreOfficeKitEnums.h |   19 +++
 include/sfx2/lokhelper.hxx   |4 
 include/svx/svdomedia.hxx|3 +++
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 sfx2/source/view/lokhelper.cxx   |9 +
 svx/source/svdraw/svdmrkv.cxx|9 +
 svx/source/svdraw/svdomedia.cxx  |   25 +
 svx/source/svdraw/svdxcgv.cxx|   13 +
 9 files changed, 84 insertions(+)

New commits:
commit 038c4a42834014b421a2e8a99ae436eb2dc8f8c5
Author: Ashod Nakashian 
AuthorDate: Sun May 15 10:05:54 2022 -0400
Commit: Miklos Vajna 
CommitDate: Wed Oct 26 08:18:55 2022 +0200

lok: support embedded media

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

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ee6802ebb24e..b0ebc21138eb 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1545,6 +1545,7 @@ void CallbackFlushHandler::queue(const int type, 
CallbackData& aCallbackData)
 type != LOK_CALLBACK_TEXT_SELECTION &&
 type != LOK_CALLBACK_TEXT_SELECTION_START &&
 type != LOK_CALLBACK_TEXT_SELECTION_END &&
+type != LOK_CALLBACK_MEDIA_SHAPE &&
 type != LOK_CALLBACK_REFERENCE_MARKS)
 {
 SAL_INFO("lok", "Skipping while painting [" << type << "]: [" << 
aCallbackData.getPayload() << "].");
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h 
b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 3bc0ad940b18..1e9821204c0b 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -882,6 +882,23 @@ typedef enum
  *
  */
 LOK_CALLBACK_FONTS_MISSING = 57,
+
+/**
+ * Insertion, removal, movement, and selection of a media shape.
+ * The payload is a json with the relevant details.
+ *
+ *  {
+ *  "action": "insert",
+ *  "id": 123456,
+ *  "url": "file:// ..."
+ *  "x": ...,
+ *  "y": ...,
+ *  }
+ *
+ *  where the "svg" property is a string containing an svg document
+ *  which is a representation of the pie segment.
+ */
+LOK_CALLBACK_MEDIA_SHAPE = 58,
 }
 LibreOfficeKitCallbackType;
 
@@ -1026,6 +1043,8 @@ static inline const char* lokCallbackTypeToString(int 
nType)
 return "LOK_CALLBACK_PRINT_RANGES";
 case LOK_CALLBACK_FONTS_MISSING:
 return "LOK_CALLBACK_FONTS_MISSING";
+case LOK_CALLBACK_MEDIA_SHAPE:
+return "LOK_CALLBACK_MEDIA_SHAPE";
 }
 
 assert(!"Unknown LibreOfficeKitCallbackType type.");
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 1c5a94966776..eaa7abe9785c 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -157,6 +157,10 @@ public:
 /// Helper for diagnosing run-time problems
 static void dumpState(rtl::OStringBuffer &rState);
 
+/// Notify all views of a media update.
+/// This could be a new insertion or property modifications to an existing 
one.
+static void notifyMediaUpdate(boost::property_tree::ptree& json);
+
 private:
 static int createView(SfxViewFrame* pViewFrame, ViewShellDocId docId);
 };
diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx
index 020f4d56c947..6199fcaffe5b 100644
--- a/include/svx/svdomedia.hxx
+++ b/include/svx/svdomedia.hxx
@@ -72,6 +72,9 @@ public:
 
 virtual bool shouldKeepAspectRatio() const override { return true; }
 
+/// When Lokit is enabled, notify the media details.
+void notifyPropertiesForLOKit();
+
 private:
 voidmediaPropertiesChanged( const 
::avmedia::MediaItem& rNewState );
 virtual std::unique_ptr 
CreateObjectSpecificViewContact() override;
diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index fba48d9293ef..ce4bd1890619 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1485,6 +1485,7 @@ callback (gpointer pData)
 case LOK_CALLBACK_SC_FOLLOW_JUMP:
 case LOK_CALLBACK_PRINT_RANGES:
 case LOK_CALLBACK_FONTS_MISSING:
+case LOK_CALLBACK_MEDIA_SHAPE:
 {
 // TODO: Implement me
 break;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index e0cdb25505ec..b168538fe0c8 100644
--- a/sfx2/source/view/lokhelper.cxx
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - filter/source include/svx sd/qa svx/source

2022-10-24 Thread Ashod Nakashian (via logerrit)
 filter/source/svg/svgwriter.cxx   |   46 +++---
 include/svx/svdomedia.hxx |3 +
 sd/qa/unit/SVGExportTests.cxx |   34 +++
 sd/qa/unit/data/odp/slide-video-thumbnail.odp |binary
 svx/source/svdraw/svdomedia.cxx   |   10 +
 5 files changed, 89 insertions(+), 4 deletions(-)

New commits:
commit 77f9b14071fd5361f3c2d7eba8a9799d41bf3159
Author: Ashod Nakashian 
AuthorDate: Sun Oct 23 17:56:50 2022 -0400
Commit: Miklos Vajna 
CommitDate: Tue Oct 25 08:22:14 2022 +0200

svg: export embedded video

Signed-off-by: Ashod Nakashian 
Change-Id: Ie5dcd1fb4abbaf53f48107e7def0f42daad24596
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141690
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index e43ff6fce264..1cb2076f4480 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2995,12 +2996,49 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& 
rBmpEx,
 mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, 
OUString::number( aSz.Width() ) );
 mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, 
OUString::number( aSz.Height() ) );
 
-// the image must be scaled to aSz in a non-uniform way
-mrExport.AddAttribute( XML_NAMESPACE_NONE, "preserveAspectRatio", "none" );
+// If we have a media object (a video), export the video.
+// Also, use the image generated above as the video poster (thumbnail).
+SdrMediaObj* pMediaObj
+= pShape ? 
dynamic_cast(SdrObject::getSdrObjectFromXShape(*pShape)) : 
nullptr;
+const bool embedVideo = (pMediaObj && !pMediaObj->getTempURL().isEmpty());
 
-mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, 
aBuffer.makeStringAndClear() );
+if (!embedVideo)
 {
-SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, "image", true, 
true );
+// the image must be scaled to aSz in a non-uniform way
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "preserveAspectRatio", 
"none");
+
+mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, 
aBuffer.makeStringAndClear());
+
+SvXMLElementExport aElem(mrExport, XML_NAMESPACE_NONE, "image", true, 
true);
+}
+else
+{
+// http://www.w3.org/2000/svg"; 
overflow="visible" width="499.6" height="374.37" x="705" y="333">
+// http://www.w3.org/1999/xhtml";>
+// 
+// 
+// 
+// 
+// 
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "xmlns", 
"http://www.w3.org/2000/svg";);
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "overflow", "visible");
+SvXMLElementExport aForeignObject(mrExport, XML_NAMESPACE_NONE, 
"foreignObject", true,
+  true);
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "xmlns", 
"http://www.w3.org/1999/xhtml";);
+SvXMLElementExport aBody(mrExport, XML_NAMESPACE_NONE, "body", true, 
true);
+
+mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrWidth, 
OUString::number(aSz.Width()));
+mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrHeight, 
OUString::number(aSz.Height()));
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "autoplay", "autoplay");
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "controls", "controls");
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "loop", "loop");
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "preload", "auto");
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "poster", 
aBuffer.makeStringAndClear());
+SvXMLElementExport aVideo(mrExport, XML_NAMESPACE_NONE, "video", true, 
true);
+
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "src", 
pMediaObj->getTempURL());
+mrExport.AddAttribute(XML_NAMESPACE_NONE, "type", "video/mp4"); 
//FIXME: set mime type.
+SvXMLElementExport aSource(mrExport, XML_NAMESPACE_NONE, "source", 
true, true);
 }
 }
 
diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx
index c47dda4d4717..36b00f276d80 100644
--- a/include/svx/svdomedia.hxx
+++ b/include/svx/svdomedia.hxx
@@ -61,6 +61,9 @@ public:
 voidsetURL( const OUString& rURL, const 
OUString& rReferer, const OUString& rMimeType = OUString() );
 const OUString&  getURL() const;
 
+/// Returns the URL to th

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - desktop/source include/LibreOfficeKit include/sfx2 include/svx libreofficekit/source sfx2/source svx/source

2022-10-23 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx  |1 +
 include/LibreOfficeKit/LibreOfficeKitEnums.h |   19 +++
 include/sfx2/lokhelper.hxx   |4 
 include/svx/svdomedia.hxx|3 +++
 libreofficekit/source/gtk/lokdocview.cxx |1 +
 sfx2/source/view/lokhelper.cxx   |9 +
 svx/source/svdraw/svdmrkv.cxx|9 +
 svx/source/svdraw/svdomedia.cxx  |   25 +
 svx/source/svdraw/svdxcgv.cxx|   13 +
 9 files changed, 84 insertions(+)

New commits:
commit 8c20411adedb38453968f9ba5dbbbf196a51bd9d
Author: Ashod Nakashian 
AuthorDate: Sun May 15 10:05:54 2022 -0400
Commit: Miklos Vajna 
CommitDate: Mon Oct 24 08:16:55 2022 +0200

lok: support embedded media

Signed-off-by: Ashod Nakashian 
Change-Id: Ie8f3ed188cec0050a10a5d49325756931b902ef1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141502
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c2e8a285663a..1621d8a70e02 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1577,6 +1577,7 @@ void CallbackFlushHandler::queue(const int type, 
CallbackData& aCallbackData)
 type != LOK_CALLBACK_TEXT_SELECTION &&
 type != LOK_CALLBACK_TEXT_SELECTION_START &&
 type != LOK_CALLBACK_TEXT_SELECTION_END &&
+type != LOK_CALLBACK_MEDIA_SHAPE &&
 type != LOK_CALLBACK_REFERENCE_MARKS)
 {
 SAL_INFO("lok", "Skipping while painting [" << type << "]: [" << 
aCallbackData.getPayload() << "].");
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h 
b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 8323b160a00c..bd6a15243c48 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -882,6 +882,23 @@ typedef enum
  *
  */
 LOK_CALLBACK_FONTS_MISSING = 57,
+
+/**
+ * Insertion, removal, movement, and selection of a media shape.
+ * The payload is a json with the relevant details.
+ *
+ *  {
+ *  "action": "insert",
+ *  "id": 123456,
+ *  "url": "file:// ..."
+ *  "x": ...,
+ *  "y": ...,
+ *  }
+ *
+ *  where the "svg" property is a string containing an svg document
+ *  which is a representation of the pie segment.
+ */
+LOK_CALLBACK_MEDIA_SHAPE = 58,
 }
 LibreOfficeKitCallbackType;
 
@@ -1026,6 +1043,8 @@ static inline const char* lokCallbackTypeToString(int 
nType)
 return "LOK_CALLBACK_PRINT_RANGES";
 case LOK_CALLBACK_FONTS_MISSING:
 return "LOK_CALLBACK_FONTS_MISSING";
+case LOK_CALLBACK_MEDIA_SHAPE:
+return "LOK_CALLBACK_MEDIA_SHAPE";
 }
 
 assert(!"Unknown LibreOfficeKitCallbackType type.");
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 7e899766785d..b8d584ac8ecc 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -157,6 +157,10 @@ public:
 /// Helper for diagnosing run-time problems
 static void dumpState(rtl::OStringBuffer &rState);
 
+/// Notify all views of a media update.
+/// This could be a new insertion or property modifications to an existing 
one.
+static void notifyMediaUpdate(boost::property_tree::ptree& json);
+
 private:
 static int createView(SfxViewFrame* pViewFrame, ViewShellDocId docId);
 };
diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx
index d80ec5a577b9..c47dda4d4717 100644
--- a/include/svx/svdomedia.hxx
+++ b/include/svx/svdomedia.hxx
@@ -72,6 +72,9 @@ public:
 
 virtual bool shouldKeepAspectRatio() const override { return true; }
 
+/// When Lokit is enabled, notify the media details.
+void notifyPropertiesForLOKit();
+
 private:
 voidmediaPropertiesChanged( const 
::avmedia::MediaItem& rNewState );
 virtual std::unique_ptr 
CreateObjectSpecificViewContact() override;
diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index d138aa0b1630..9e9e5195d307 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1479,6 +1479,7 @@ callback (gpointer pData)
 case LOK_CALLBACK_SC_FOLLOW_JUMP:
 case LOK_CALLBACK_PRINT_RANGES:
 case LOK_CALLBACK_FONTS_MISSING:
+case LOK_CALLBACK_MEDIA_SHAPE:
 {
 // TODO: Implement me
 break;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index d65303762

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

2022-09-21 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit ddc5a7bb10c6229018dbdb3192740b6d893fa08b
Author: Ashod Nakashian 
AuthorDate: Sun Jul 24 08:46:38 2022 -0400
Commit: Miklos Vajna 
CommitDate: Thu Sep 22 08:30:12 2022 +0200

lok: initialize the load-language

We need to use the load-language for
saving the document. This is to avoid
using the language of the view that is
issuing the save, which causes all sorts
of issues (language-translation related).
This logic was implemented in 4b7b449bbdc5
but for some reason the load-language
wasn't set.

This patch sets the load-language.

Signed-off-by: Ashod Nakashian 
Change-Id: I0cd1574d48a99e6ee84bacf75fc0d9ebe26e526b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137391
Reviewed-by: Michael Meeks 
Tested-by: Jenkins CollaboraOffice 
(cherry picked from commit a0b2739b2354b622538304c0846606247bcf09c0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140362
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5e562862da53..7d9c4cfc3643 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2513,6 +2513,14 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 
 if (!aLanguage.isEmpty() && isValidLangTag)
 {
+static bool isLoading = true;
+if (isLoading)
+{
+// Capture the language used to load the document.
+SfxLokHelper::setLoadLanguage(aLanguage);
+isLoading = false;
+}
+
 SfxLokHelper::setDefaultLanguage(aLanguage);
 // Set the LOK language tag, used for dialog tunneling.
 comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(aLanguage));


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

2022-09-21 Thread Ashod Nakashian (via logerrit)
 include/sfx2/lokhelper.hxx |4 
 sfx2/source/doc/objstor.cxx|   33 +
 sfx2/source/view/lokhelper.cxx |8 
 3 files changed, 45 insertions(+)

New commits:
commit 90e3244aa6c15a42c5c86ebe5b36592085de9c79
Author: Ashod Nakashian 
AuthorDate: Sun May 1 16:52:30 2022 -0400
Commit: Miklos Vajna 
CommitDate: Thu Sep 22 08:29:16 2022 +0200

sw: restore UI language to en while saving

Because the XML writer used in sw invokes the
translation logic, which uses the UI language,
saving can fail in case there are multiple
views with different langauges. This restores
the language used for loading before saving
to avoid such issues.

Signed-off-by: Ashod Nakashian 
Change-Id: I6675204bb68ea33b1395c779a64ab3e9b339d73e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135482
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
(cherry picked from commit 4b7b449bbdc51557f62131a3b467b34ad39e8547)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140361
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 909b6335733d..1c5a94966776 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -76,6 +76,10 @@ public:
 static void setViewLanguage(int nId, const OUString& rBcp47LanguageTag);
 /// Set the default language for views.
 static void setDefaultLanguage(const OUString& rBcp47LanguageTag);
+/// Get the language used by the loading view (used for all save 
operations).
+static const LanguageTag & getLoadLanguage();
+/// Set the language used by the loading view (used for all save 
operations).
+static void setLoadLanguage(const OUString& rBcp47LanguageTag);
 /// Set the locale for the given view.
 static void setViewLocale(int nId, const OUString& rBcp47LanguageTag);
 /// Get the device form factor that should be used for a new view.
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 275f693a23f9..83d28956ebee 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -92,6 +92,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -103,6 +104,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3208,6 +3210,37 @@ bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium 
)
 pImpl->aBasicManager.storeLibrariesToStorage( xStorage );
 }
 #endif
+
+if (comphelper::LibreOfficeKit::isActive())
+{
+// Because XMLTextFieldExport::ExportFieldDeclarations (called 
from SwXMLExport)
+// calls SwXTextFieldMasters::getByName, which in turn maps 
property names by
+// calling SwStyleNameMapper::GetTextUINameArray, which uses
+// SvtSysLocale().GetUILanguageTag() to do the mapping, saving 
indirectly depends
+// on the UI language. This is an unfortunate depenency. Here we 
use the loader's language.
+const LanguageTag viewLanguage = 
comphelper::LibreOfficeKit::getLanguageTag();
+const LanguageTag loadLanguage = SfxLokHelper::getLoadLanguage();
+
+// Use the default language for saving and restore later if 
necessary.
+bool restoreLanguage = false;
+if (viewLanguage != loadLanguage)
+{
+restoreLanguage = true;
+comphelper::LibreOfficeKit::setLanguageTag(loadLanguage);
+}
+
+// Restore the view's original language automatically and as 
necessary.
+const ::comphelper::ScopeGuard aGuard(
+[&viewLanguage, restoreLanguage]()
+{
+if (restoreLanguage
+&& viewLanguage != 
comphelper::LibreOfficeKit::getLanguageTag())
+
comphelper::LibreOfficeKit::setLanguageTag(viewLanguage);
+});
+
+return SaveAs(rMedium);
+}
+
 return SaveAs( rMedium );
 }
 else return false;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index aa38c5dbee98..a082aeff110d 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -73,6 +73,7 @@ int DisableCallbacks::m_nDisabled = 0;
 namespace
 {
 LanguageTag g_defaultLanguageTag("en-US", true);
+LanguageTag g_loadLanguageTag("en-US", true); //< The language used to load.
 LOKDeviceFormFactor g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN;
 }
 
@@ -279,6 +280,13 @@ void SfxLokHelper::setDefaultLanguage(const OUString& 
rBcp47LanguageTag)
 g_defaultLanguageTag = LanguageTag(rBcp47LanguageTag, true);
 }
 
+const LanguageTag& SfxLokHelper::getLoadLanguage() { return g_loadLanguageTag; 
}
+
+void SfxLokHelper::setLoadLan

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/sfx2 sfx2/source

2022-07-28 Thread Ashod Nakashian (via logerrit)
 include/sfx2/lokhelper.hxx |4 
 sfx2/source/doc/objstor.cxx|   33 +
 sfx2/source/view/lokhelper.cxx |8 
 3 files changed, 45 insertions(+)

New commits:
commit 469ea15f388c8c8fc263324b6be77e5bfa941b71
Author: Ashod Nakashian 
AuthorDate: Sun May 1 16:52:30 2022 -0400
Commit: Michael Meeks 
CommitDate: Thu Jul 28 12:53:22 2022 +0200

sw: restore UI language to en while saving

Because the XML writer used in sw invokes the
translation logic, which uses the UI language,
saving can fail in case there are multiple
views with different langauges. This restores
the language used for loading before saving
to avoid such issues.

Signed-off-by: Ashod Nakashian 
Change-Id: I6675204bb68ea33b1395c779a64ab3e9b339d73e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135482
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137547

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index d5c3adbf9d95..d0ca34125354 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -72,6 +72,10 @@ public:
 static void setViewLanguage(int nId, const OUString& rBcp47LanguageTag);
 /// Set the default language for views.
 static void setDefaultLanguage(const OUString& rBcp47LanguageTag);
+/// Get the language used by the loading view (used for all save 
operations).
+static const LanguageTag & getLoadLanguage();
+/// Set the language used by the loading view (used for all save 
operations).
+static void setLoadLanguage(const OUString& rBcp47LanguageTag);
 /// Set the locale for the given view.
 static void setViewLocale(int nId, const OUString& rBcp47LanguageTag);
 /// Get the device form factor that should be used for a new view.
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 7ccee4f3a970..cee35fc3443c 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -91,6 +91,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -102,6 +103,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3190,6 +3192,37 @@ bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium 
)
 pImpl->aBasicManager.storeLibrariesToStorage( xStorage );
 }
 #endif
+
+if (comphelper::LibreOfficeKit::isActive())
+{
+// Because XMLTextFieldExport::ExportFieldDeclarations (called 
from SwXMLExport)
+// calls SwXTextFieldMasters::getByName, which in turn maps 
property names by
+// calling SwStyleNameMapper::GetTextUINameArray, which uses
+// SvtSysLocale().GetUILanguageTag() to do the mapping, saving 
indirectly depends
+// on the UI language. This is an unfortunate depenency. Here we 
use the loader's language.
+const LanguageTag viewLanguage = 
comphelper::LibreOfficeKit::getLanguageTag();
+const LanguageTag loadLanguage = SfxLokHelper::getLoadLanguage();
+
+// Use the default language for saving and restore later if 
necessary.
+bool restoreLanguage = false;
+if (viewLanguage != loadLanguage)
+{
+restoreLanguage = true;
+comphelper::LibreOfficeKit::setLanguageTag(loadLanguage);
+}
+
+// Restore the view's original language automatically and as 
necessary.
+const ::comphelper::ScopeGuard aGuard(
+[&viewLanguage, restoreLanguage]()
+{
+if (restoreLanguage
+&& viewLanguage != 
comphelper::LibreOfficeKit::getLanguageTag())
+
comphelper::LibreOfficeKit::setLanguageTag(viewLanguage);
+});
+
+return SaveAs(rMedium);
+}
+
 return SaveAs( rMedium );
 }
 else return false;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index a8dc5b5bf3b7..100cb3595e46 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -69,6 +69,7 @@ int DisableCallbacks::m_nDisabled = 0;
 namespace
 {
 LanguageTag g_defaultLanguageTag("en-US", true);
+LanguageTag g_loadLanguageTag("en-US", true); //< The language used to load.
 LOKDeviceFormFactor g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN;
 }
 
@@ -275,6 +276,13 @@ void SfxLokHelper::setDefaultLanguage(const OUString& 
rBcp47LanguageTag)
 g_defaultLanguageTag = LanguageTag(rBcp47LanguageTag, true);
 }
 
+const LanguageTag& SfxLokHelper::getLoadLanguage() { return g_loadLanguageTag; 
}
+
+void SfxLokHelper::setLoadLanguage(const OUString& rBcp47LanguageTag)
+{
+g_loadLanguageTag = LanguageTag(rBcp47LanguageTag, true);
+}
+
 void SfxLokHelper::setV

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - desktop/source

2022-07-28 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit b69ad8f8e7a0aa06cac724ffb93ee58cd7e4cb07
Author: Ashod Nakashian 
AuthorDate: Sun Jul 24 08:46:38 2022 -0400
Commit: Michael Meeks 
CommitDate: Thu Jul 28 12:52:44 2022 +0200

lok: initialize the load-language

We need to use the load-language for
saving the document. This is to avoid
using the language of the view that is
issuing the save, which causes all sorts
of issues (language-translation related).
This logic was implemented in 4b7b449bbdc5
but for some reason the load-language
wasn't set.

This patch sets the load-language.

Signed-off-by: Ashod Nakashian 
Change-Id: I0cd1574d48a99e6ee84bacf75fc0d9ebe26e526b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137391
Reviewed-by: Michael Meeks 
Tested-by: Jenkins CollaboraOffice 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137548

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 9d88234bdb21..e787252525fb 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2519,6 +2519,14 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 
 if (!aLanguage.isEmpty() && isValidLangTag)
 {
+static bool isLoading = true;
+if (isLoading)
+{
+// Capture the language used to load the document.
+SfxLokHelper::setLoadLanguage(aLanguage);
+isLoading = false;
+}
+
 SfxLokHelper::setDefaultLanguage(aLanguage);
 // Set the LOK language tag, used for dialog tunneling.
 comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(aLanguage));


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - desktop/source

2022-07-25 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit a0b2739b2354b622538304c0846606247bcf09c0
Author: Ashod Nakashian 
AuthorDate: Sun Jul 24 08:46:38 2022 -0400
Commit: Ashod Nakashian 
CommitDate: Mon Jul 25 15:34:33 2022 +0200

lok: initialize the load-language

We need to use the load-language for
saving the document. This is to avoid
using the language of the view that is
issuing the save, which causes all sorts
of issues (language-translation related).
This logic was implemented in 4b7b449bbdc5
but for some reason the load-language
wasn't set.

This patch sets the load-language.

Signed-off-by: Ashod Nakashian 
Change-Id: I0cd1574d48a99e6ee84bacf75fc0d9ebe26e526b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137391
Reviewed-by: Michael Meeks 
Tested-by: Jenkins CollaboraOffice 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4ab030388e7f..3f708aa781c9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2495,6 +2495,14 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 
 if (!aLanguage.isEmpty() && isValidLangTag)
 {
+static bool isLoading = true;
+if (isLoading)
+{
+// Capture the language used to load the document.
+SfxLokHelper::setLoadLanguage(aLanguage);
+isLoading = false;
+}
+
 SfxLokHelper::setDefaultLanguage(aLanguage);
 // Set the LOK language tag, used for dialog tunneling.
 comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(aLanguage));


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - include/sfx2 sfx2/source

2022-06-10 Thread Ashod Nakashian (via logerrit)
 include/sfx2/lokhelper.hxx |4 
 sfx2/source/doc/objstor.cxx|   33 +
 sfx2/source/view/lokhelper.cxx |8 
 3 files changed, 45 insertions(+)

New commits:
commit 4b7b449bbdc51557f62131a3b467b34ad39e8547
Author: Ashod Nakashian 
AuthorDate: Sun May 1 16:52:30 2022 -0400
Commit: Michael Meeks 
CommitDate: Fri Jun 10 14:09:54 2022 +0200

sw: restore UI language to en while saving

Because the XML writer used in sw invokes the
translation logic, which uses the UI language,
saving can fail in case there are multiple
views with different langauges. This restores
the language used for loading before saving
to avoid such issues.

Signed-off-by: Ashod Nakashian 
Change-Id: I6675204bb68ea33b1395c779a64ab3e9b339d73e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135482
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 4ac50a19cc69..2a40344cd70a 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -73,6 +73,10 @@ public:
 static void setViewLanguage(int nId, const OUString& rBcp47LanguageTag);
 /// Set the default language for views.
 static void setDefaultLanguage(const OUString& rBcp47LanguageTag);
+/// Get the language used by the loading view (used for all save 
operations).
+static const LanguageTag & getLoadLanguage();
+/// Set the language used by the loading view (used for all save 
operations).
+static void setLoadLanguage(const OUString& rBcp47LanguageTag);
 /// Set the locale for the given view.
 static void setViewLocale(int nId, const OUString& rBcp47LanguageTag);
 /// Get the device form factor that should be used for a new view.
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 548ce34b1c21..9ec5d7980296 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -91,6 +91,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -102,6 +103,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3197,6 +3199,37 @@ bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium 
)
 pImpl->aBasicManager.storeLibrariesToStorage( xStorage );
 }
 #endif
+
+if (comphelper::LibreOfficeKit::isActive())
+{
+// Because XMLTextFieldExport::ExportFieldDeclarations (called 
from SwXMLExport)
+// calls SwXTextFieldMasters::getByName, which in turn maps 
property names by
+// calling SwStyleNameMapper::GetTextUINameArray, which uses
+// SvtSysLocale().GetUILanguageTag() to do the mapping, saving 
indirectly depends
+// on the UI language. This is an unfortunate depenency. Here we 
use the loader's language.
+const LanguageTag viewLanguage = 
comphelper::LibreOfficeKit::getLanguageTag();
+const LanguageTag loadLanguage = SfxLokHelper::getLoadLanguage();
+
+// Use the default language for saving and restore later if 
necessary.
+bool restoreLanguage = false;
+if (viewLanguage != loadLanguage)
+{
+restoreLanguage = true;
+comphelper::LibreOfficeKit::setLanguageTag(loadLanguage);
+}
+
+// Restore the view's original language automatically and as 
necessary.
+const ::comphelper::ScopeGuard aGuard(
+[&viewLanguage, restoreLanguage]()
+{
+if (restoreLanguage
+&& viewLanguage != 
comphelper::LibreOfficeKit::getLanguageTag())
+
comphelper::LibreOfficeKit::setLanguageTag(viewLanguage);
+});
+
+return SaveAs(rMedium);
+}
+
 return SaveAs( rMedium );
 }
 else return false;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index cb8194c1cabf..f1617c461004 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -73,6 +73,7 @@ int DisableCallbacks::m_nDisabled = 0;
 namespace
 {
 LanguageTag g_defaultLanguageTag("en-US", true);
+LanguageTag g_loadLanguageTag("en-US", true); //< The language used to load.
 LOKDeviceFormFactor g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN;
 }
 
@@ -279,6 +280,13 @@ void SfxLokHelper::setDefaultLanguage(const OUString& 
rBcp47LanguageTag)
 g_defaultLanguageTag = LanguageTag(rBcp47LanguageTag, true);
 }
 
+const LanguageTag& SfxLokHelper::getLoadLanguage() { return g_loadLanguageTag; 
}
+
+void SfxLokHelper::setLoadLanguage(const OUString& rBcp47LanguageTag)
+{
+g_loadLanguageTag = LanguageTag(rBcp47LanguageTag, true);
+}
+
 void SfxLokHelper::setViewLanguage(int nId, const OUString& rBcp47LanguageTag)
 {
 std::vector& rViewArr = SfxGetpApp()->GetViewShells_Impl();


[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-4' - 15 commits - sc/source sfx2/source sw/source sw/uiconfig vcl/source

2022-05-24 Thread Ashod Nakashian (via logerrit)
 sc/source/core/data/dociter.cxx|8 ++--
 sc/source/ui/view/cellsh.cxx   |3 ++-
 sc/source/ui/view/viewfunc.cxx |3 ++-
 sfx2/source/sidebar/SidebarController.cxx  |   11 +++
 sw/source/core/doc/docfmt.cxx  |9 +
 sw/source/core/frmedt/feshview.cxx |8 +++-
 sw/source/uibase/uiview/viewdraw.cxx   |2 ++
 sw/uiconfig/swxform/toolbar/formdesign.xml |2 +-
 vcl/source/control/button.cxx  |8 +++-
 vcl/source/window/cursor.cxx   |5 +++--
 vcl/source/window/dockmgr.cxx  |4 
 vcl/source/window/event.cxx|3 ++-
 vcl/source/window/floatwin.cxx |2 ++
 vcl/source/window/window.cxx   |5 +++--
 vcl/source/window/window2.cxx  |3 ++-
 15 files changed, 59 insertions(+), 17 deletions(-)

New commits:
commit afc5889493a16a74dd8086ddc02c84fa78fd401d
Author: Ashod Nakashian 
AuthorDate: Sat Mar 21 11:48:40 2020 -0400
Commit: Samuel Mehrbrodt 
CommitDate: Mon May 23 11:24:52 2022 +0200

sw: check for null SdrObject before accessing

Change-Id: I30f1cc658450982232feea10dbe9c5bfefe07d91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90896
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 
(cherry picked from commit 8ed4ac6152c96280616a784b47c4f75df147501a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90946
Tested-by: Jenkins

diff --git a/sw/source/uibase/uiview/viewdraw.cxx 
b/sw/source/uibase/uiview/viewdraw.cxx
index 6866b31cd3b1..465ab3dfc82d 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -668,6 +668,8 @@ bool SwView::AreOnlyFormsSelected() const
 {
 // Except controls, are still normal draw objects selected?
 SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+if (!pSdrObj)
+continue;
 
 if (!HasOnlyObj(pSdrObj, SdrInventor::FmForm))
 {
commit 25ba49d3de229f940fa7271beb0a84c2ff297618
Author:     Ashod Nakashian 
AuthorDate: Sun Feb 2 14:37:38 2020 -0500
Commit: Samuel Mehrbrodt 
CommitDate: Mon May 23 11:21:41 2022 +0200

vcl: avoid accessing null member on unloading views

Change-Id: If4e416c7257c861b9e13352b3329d9719b159e61
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87830
Reviewed-by: Michael Meeks 
Tested-by: Aron Budea 
(cherry picked from commit 9ec3d637c1c99c729da67eafc375efce1cc7f026)

diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx
index 3bdd19b08ddf..708fb19793fc 100644
--- a/vcl/source/window/cursor.cxx
+++ b/vcl/source/window/cursor.cxx
@@ -193,8 +193,9 @@ void vcl::Cursor::ImplDoShow( bool bDrawDirect, bool 
bRestore )
 // show the cursor, if there is an active window and the cursor
 // has been selected in this window
 pWindow = Application::GetFocusWindow();
-if ( !pWindow || (pWindow->mpWindowImpl->mpCursor != this) || 
pWindow->mpWindowImpl->mbInPaint
-|| !pWindow->mpWindowImpl->mpFrameData->mbHasFocus )
+if (!pWindow || !pWindow->mpWindowImpl || 
(pWindow->mpWindowImpl->mpCursor != this)
+|| pWindow->mpWindowImpl->mbInPaint
+|| !pWindow->mpWindowImpl->mpFrameData->mbHasFocus)
 pWindow = nullptr;
 }
 
commit e901a1e3a6914da49cc69fbb898cf2df1e9e92c7
Author: Ashod Nakashian 
AuthorDate: Wed Dec 18 07:30:14 2019 -0500
Commit: Samuel Mehrbrodt 
CommitDate: Mon May 23 11:21:16 2022 +0200

vcl: don't use null window in FloatingWindow HitTest

Change-Id: I551f31cf30c7a58642becebe0256684055d0703a
Reviewed-on: https://gerrit.libreoffice.org/85383
    Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 
(cherry picked from commit 65685bac09a4320602f4dda5151d247c5a83a75c)

diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index baa3a46bc978..4eef15b88be2 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -520,6 +520,8 @@ FloatingWindow* FloatingWindow::ImplFloatHitTest( 
vcl::Window* pReference, const
 
 // use the border window to have the exact position
 vcl::Window *pBorderWin = pWin->GetWindow( GetWindowType::Border );
+if (!pBorderWin)
+break;
 
 // the top-left corner in output coordinates ie (0,0)
 tools::Rectangle devRect( 
pBorderWin->ImplOutputToUnmirroredAbsoluteScreenPixel( tools::Rectangle( 
Point(), pBorderWin->GetSizePixel()) ) ) ;
commit 3fee58e0194ccc375a6fd3fc35197229df2518b0
Author: Szymon Kłos 
AuthorDate: Fri Dec 4 12:24:27 2020 +0100
Commit: Samuel Mehrbrodt 
CommitDate: Mon May 23 11:00:59 2022 +0200

Avoid crash on closing docking window

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sfx2/source

2022-05-02 Thread Ashod Nakashian (via logerrit)
 sfx2/source/doc/objstor.cxx |   31 +++
 1 file changed, 31 insertions(+)

New commits:
commit 01a9f402db5840801e0eb004112bf19d5225f32c
Author: Ashod Nakashian 
AuthorDate: Sun May 1 16:52:30 2022 -0400
Commit: Michael Meeks 
CommitDate: Mon May 2 20:02:03 2022 +0200

sw: restore UI language to en while saving

Because the XML writer used in sw invokes the
translation logic, which uses the UI language,
saving can fail in case there are multiple
views with different langauges. This restores
the default language before saving to avoid
such issues and to make sure the document
xml is generated in the default language.

Signed-off-by: Ashod Nakashian 
Change-Id: Ibc0813de33cf7cf3528b0ff1d95560e799903fb0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133676
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
(cherry picked from commit f4ef1e3e580f7a590496d62aaa3dc7e092510a9c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133611

diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 8d101e8aac04..e456f5ea951a 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -105,6 +105,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -3158,6 +3159,11 @@ bool SfxObjectShell::LoadOwnFormat( SfxMedium& rMedium )
 return false;
 }
 
+namespace
+{
+static LanguageTag g_defaultLanguageTag("en-US", true);
+}
+
 bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium )
 {
 uno::Reference< embed::XStorage > xStorage = rMedium.GetStorage();
@@ -3180,6 +3186,31 @@ bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium 
)
 pImpl->aBasicManager.storeLibrariesToStorage( xStorage );
 }
 #endif
+
+// Because XMLTextFieldExport::ExportFieldDeclarations (called from 
SwXMLExport)
+// calls SwXTextFieldMasters::getByName, which in turn maps property 
names by
+// calling SwStyleNameMapper::GetTextUINameArray, which uses
+// SvtSysLocale().GetUILanguageTag() to do the mapping, saving 
indirectly depends
+// on the UI language. This is an unfortunate depenency.
+// Here we restore to English
+const auto viewLanguage = comphelper::LibreOfficeKit::getLanguageTag();
+
+// Use the default language for saving and restore later if necessary.
+bool restoreLanguage = false;
+if (comphelper::LibreOfficeKit::isActive() && viewLanguage != 
g_defaultLanguageTag)
+{
+restoreLanguage = true;
+comphelper::LibreOfficeKit::setLanguageTag(g_defaultLanguageTag);
+}
+
+// Restore the view's original language automatically and as necessary.
+const ::comphelper::ScopeGuard aGuard(
+[&viewLanguage, restoreLanguage]()
+{
+if (restoreLanguage && viewLanguage != 
comphelper::LibreOfficeKit::getLanguageTag())
+comphelper::LibreOfficeKit::setLanguageTag(viewLanguage);
+});
+
 return SaveAs( rMedium );
 }
 else return false;


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sfx2/source

2022-05-02 Thread Ashod Nakashian (via logerrit)
 sfx2/source/doc/objstor.cxx |   31 +++
 1 file changed, 31 insertions(+)

New commits:
commit 7e088fe43ae7c2647e634faa57e5905f39c4a522
Author: Ashod Nakashian 
AuthorDate: Sun May 1 16:52:30 2022 -0400
Commit: Michael Meeks 
CommitDate: Mon May 2 20:02:19 2022 +0200

sw: restore UI language to en while saving

Because the XML writer used in sw invokes the
translation logic, which uses the UI language,
saving can fail in case there are multiple
views with different langauges. This restores
the default language before saving to avoid
such issues and to make sure the document
xml is generated in the default language.

Signed-off-by: Ashod Nakashian 
Change-Id: Ibc0813de33cf7cf3528b0ff1d95560e799903fb0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133676
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
(cherry picked from commit f4ef1e3e580f7a590496d62aaa3dc7e092510a9c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133610

diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 548ce34b1c21..65a340221223 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -91,6 +91,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -3175,6 +3176,11 @@ bool SfxObjectShell::LoadOwnFormat( SfxMedium& rMedium )
 return false;
 }
 
+namespace
+{
+static LanguageTag g_defaultLanguageTag("en-US", true);
+}
+
 bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium )
 {
 uno::Reference< embed::XStorage > xStorage = rMedium.GetStorage();
@@ -3197,6 +3203,31 @@ bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium 
)
 pImpl->aBasicManager.storeLibrariesToStorage( xStorage );
 }
 #endif
+
+// Because XMLTextFieldExport::ExportFieldDeclarations (called from 
SwXMLExport)
+// calls SwXTextFieldMasters::getByName, which in turn maps property 
names by
+// calling SwStyleNameMapper::GetTextUINameArray, which uses
+// SvtSysLocale().GetUILanguageTag() to do the mapping, saving 
indirectly depends
+// on the UI language. This is an unfortunate depenency.
+// Here we restore to English
+const auto viewLanguage = comphelper::LibreOfficeKit::getLanguageTag();
+
+// Use the default language for saving and restore later if necessary.
+bool restoreLanguage = false;
+if (comphelper::LibreOfficeKit::isActive() && viewLanguage != 
g_defaultLanguageTag)
+{
+restoreLanguage = true;
+comphelper::LibreOfficeKit::setLanguageTag(g_defaultLanguageTag);
+}
+
+// Restore the view's original language automatically and as necessary.
+const ::comphelper::ScopeGuard aGuard(
+[&viewLanguage, restoreLanguage]()
+{
+if (restoreLanguage && viewLanguage != 
comphelper::LibreOfficeKit::getLanguageTag())
+comphelper::LibreOfficeKit::setLanguageTag(viewLanguage);
+});
+
 return SaveAs( rMedium );
 }
 else return false;


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - sfx2/source

2022-05-02 Thread Ashod Nakashian (via logerrit)
 sfx2/source/doc/objstor.cxx |   31 +++
 1 file changed, 31 insertions(+)

New commits:
commit f4ef1e3e580f7a590496d62aaa3dc7e092510a9c
Author: Ashod Nakashian 
AuthorDate: Sun May 1 16:52:30 2022 -0400
Commit: Michael Meeks 
CommitDate: Mon May 2 10:43:13 2022 +0200

sw: restore UI language to en while saving

Because the XML writer used in sw invokes the
translation logic, which uses the UI language,
saving can fail in case there are multiple
views with different langauges. This restores
the default language before saving to avoid
such issues and to make sure the document
xml is generated in the default language.

Signed-off-by: Ashod Nakashian 
Change-Id: Ibc0813de33cf7cf3528b0ff1d95560e799903fb0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133676
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 7ccee4f3a970..238369b746e6 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -91,6 +91,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -3168,6 +3169,11 @@ bool SfxObjectShell::LoadOwnFormat( SfxMedium& rMedium )
 return false;
 }
 
+namespace
+{
+static LanguageTag g_defaultLanguageTag("en-US", true);
+}
+
 bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium )
 {
 uno::Reference< embed::XStorage > xStorage = rMedium.GetStorage();
@@ -3190,6 +3196,31 @@ bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium 
)
 pImpl->aBasicManager.storeLibrariesToStorage( xStorage );
 }
 #endif
+
+// Because XMLTextFieldExport::ExportFieldDeclarations (called from 
SwXMLExport)
+// calls SwXTextFieldMasters::getByName, which in turn maps property 
names by
+// calling SwStyleNameMapper::GetTextUINameArray, which uses
+// SvtSysLocale().GetUILanguageTag() to do the mapping, saving 
indirectly depends
+// on the UI language. This is an unfortunate depenency.
+// Here we restore to English
+const auto viewLanguage = comphelper::LibreOfficeKit::getLanguageTag();
+
+// Use the default language for saving and restore later if necessary.
+bool restoreLanguage = false;
+if (comphelper::LibreOfficeKit::isActive() && viewLanguage != 
g_defaultLanguageTag)
+{
+restoreLanguage = true;
+comphelper::LibreOfficeKit::setLanguageTag(g_defaultLanguageTag);
+}
+
+// Restore the view's original language automatically and as necessary.
+const ::comphelper::ScopeGuard aGuard(
+[&viewLanguage, restoreLanguage]()
+{
+if (restoreLanguage && viewLanguage != 
comphelper::LibreOfficeKit::getLanguageTag())
+comphelper::LibreOfficeKit::setLanguageTag(viewLanguage);
+});
+
 return SaveAs( rMedium );
 }
 else return false;


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - desktop/source

2022-02-20 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8b7420a422f5e17124a30dc936d130edd86c96e9
Author: Ashod Nakashian 
AuthorDate: Sun Mar 10 12:21:33 2019 -0400
Commit: Andras Timar 
CommitDate: Sun Feb 20 11:21:29 2022 +0100

LOK: don't segfault when reporting error

Change-Id: Ia6d614eb15b15f43ddd3e0b5742b888060dfd581
Reviewed-on: https://gerrit.libreoffice.org/69069
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 
(cherry picked from commit 9fa568dced78011072390320f64eae28dd06d2b9)
Reviewed-on: https://gerrit.libreoffice.org/78443
(cherry picked from commit fa18cdce824525ebd76b542a44741a35062741ce)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b365f90d14b9..719013274be3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4301,7 +4301,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* 
pThis, const char* pComma
 else
 bResult = comphelper::dispatchCommand(aCommand, 
comphelper::containerToSequence(aPropertyValuesVector));
 
-if (!bResult)
+if (!bResult && gImpl)
 {
 SetLastExceptionMsg("Failed to dispatch " + aCommand);
 }


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - vcl/source

2021-04-29 Thread Ashod Nakashian (via logerrit)
 vcl/source/window/window.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 4e3186e82891c8a8108a45d31dea2a32472a2733
Author: Ashod Nakashian 
AuthorDate: Sun Nov 8 09:15:25 2020 -0500
Commit: Andras Timar 
CommitDate: Thu Apr 29 10:49:24 2021 +0200

vcl: lok: don't use window impl after destroy

When destroying floating windows, accessing the GetLOKNotifier
can segfault. The following is the stack-trace from such
a case.

/usr/bin/loolforkit(_ZN7SigUtil13dumpBacktraceEv+0x5e)[0x55cbf9da62fe]
/usr/bin/loolforkit(+0x1d0af5)[0x55cbf9da6af5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x128a0)[0x7fe0a125f8a0]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZNK3vcl6Window14GetLOKNotifierEv+0x7)[0x7fe09e67b827]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN3vcl6Window24GetParentWithLOKNotifierEv+0x2b)[0x7fe09e67b86b]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN14FloatingWindow12StateChangedE16StateChangedType+0x43)[0x7fe09e609a13]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN3vcl6Window4ShowEb9ShowFlags+0x2ba)[0x7fe09e67cd5a]

/opt/collaboraoffice6.4/program/libmergedlo.so(_Z21ImplDestroyHelpWindowR14ImplSVHelpDatab+0xe3)[0x7fe09e90c193]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN9Scheduler21ProcessTaskSchedulingEv+0x8ea)[0x7fe09e93817a]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN14SvpSalInstance12CheckTimeoutEb+0x107)[0x7fe09ea06807]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN14SvpSalInstance7DoYieldEbb+0x85)[0x7fe09ea06905]
/opt/collaboraoffice6.4/program/libmergedlo.so(+0x2f5d6fb)[0x7fe09e94f6fb]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN11Application7ExecuteEv+0x45)[0x7fe09e950295]
/opt/collaboraoffice6.4/program/libmergedlo.so(+0x1f6d545)[0x7fe09d95f545]

/opt/collaboraoffice6.4/program/libmergedlo.so(_Z10ImplSVMainv+0x51)[0x7fe09e957321]

/opt/collaboraoffice6.4/program/libmergedlo.so(soffice_main+0x98)[0x7fe09d980b88]
/opt/collaboraoffice6.4/program/libmergedlo.so(+0x1f9e7c1)[0x7fe09d9907c1]

/usr/bin/loolforkit(_Z10lokit_mainRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_S6_S6_S6_m+0x2562)[0x55cbf9d4c792]
/usr/bin/loolforkit(+0x15fc77)[0x55cbf9d35c77]

/usr/bin/loolforkit(_Z18forkLibreOfficeKitRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_S6_S6_i+0xb44)[0x55cbf9d36b24]
/usr/bin/loolforkit(main+0x18a7)[0x55cbf9d00e17]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fe0a0e7db97]
/usr/bin/loolforkit(_start+0x2a)[0x55cbf9d07efa]

Change-Id: Ia467d51896d1ac657bde5ae2803fcb2557ebd3fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105445
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
(cherry picked from commit 5a3837034960327743154887732c4cae04cfc971)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114727
Reviewed-by: Andras Timar 

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 10638fa43957..bf270d6f2ffb 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3236,12 +3236,12 @@ void Window::ReleaseLOKNotifier()
 
 const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
 {
-return mpWindowImpl->mpLOKNotifier;
+return mpWindowImpl ? mpWindowImpl->mpLOKNotifier : nullptr;
 }
 
 vcl::LOKWindowId Window::GetLOKWindowId() const
 {
-return mpWindowImpl->mnLOKWindowId;
+return mpWindowImpl ? mpWindowImpl->mnLOKWindowId : 0;
 }
 
 VclPtr Window::GetParentWithLOKNotifier()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/source

2021-04-10 Thread Ashod Nakashian (via logerrit)
 vcl/source/filter/ipdf/pdfread.cxx |   18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 2a44f2e9b4b139b6f5cc7b9a283cb11a5641a10d
Author: Ashod Nakashian 
AuthorDate: Sun Mar 28 09:38:01 2021 -0400
Commit: Andras Timar 
CommitDate: Sat Apr 10 23:22:35 2021 +0200

vcl: allow for overriding the default PDF rendering resolution

Change-Id: Ibd75c6dd71d93322bd77995547e735c2d4849602
Signed-off-by: Ashod Nakashian 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113223
Tested-by: Jenkins
Reviewed-by: Andras Timar 

diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index 9cdb10070ef6..be9738a9f32f 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -116,10 +116,26 @@ BinaryDataContainer createBinaryDataContainer(SvStream& 
rStream)
 
 namespace vcl
 {
+/// Get the default PDF rendering resolution in DPI.
+static double getDefaultPdfResolutionDpi()
+{
+// If an overriding default is set, use it.
+const char* envar = ::getenv("PDFIMPORT_RESOLUTION_DPI");
+if (envar)
+{
+const double dpi = atof(envar);
+if (dpi > 0)
+return dpi;
+}
+
+// Fallback to a sensible default.
+return 96.;
+}
+
 size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector& 
rBitmaps,
 const size_t nFirstPage, int nPages, const 
basegfx::B2DTuple* pSizeHint)
 {
-const double fResolutionDPI = 96;
+static const double fResolutionDPI = getDefaultPdfResolutionDpi();
 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
 if (!pPdfium)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - vcl/source

2021-04-09 Thread Ashod Nakashian (via logerrit)
 vcl/source/filter/ipdf/pdfread.cxx |   18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit fc793fef7b81f47aab80fd6f1f128780a7a22aa5
Author: Ashod Nakashian 
AuthorDate: Sun Mar 28 09:38:01 2021 -0400
Commit: Andras Timar 
CommitDate: Sat Apr 10 00:05:24 2021 +0200

vcl: allow for overriding the default PDF rendering resolution

Change-Id: Ibd75c6dd71d93322bd77995547e735c2d4849602
Signed-off-by: Ashod Nakashian 

diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index 80f207a68196..715333b2d561 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -132,11 +132,27 @@ VectorGraphicDataArray 
createVectorGraphicDataArray(SvStream& rStream)
 
 namespace vcl
 {
+/// Get the default PDF rendering resolution in DPI.
+static double getDefaultPdfResolutionDpi()
+{
+// If an overriding default is set, use it.
+const char* envar = ::getenv("PDFIMPORT_RESOLUTION_DPI");
+if (envar)
+{
+const double dpi = atof(envar);
+if (dpi > 0)
+return dpi;
+}
+
+// Fallback to a sensible default.
+return 96.;
+}
+
 size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector& 
rBitmaps,
 const size_t nFirstPage, int nPages, const 
basegfx::B2DTuple* pSizeHint)
 {
 #if HAVE_FEATURE_PDFIUM
-const double fResolutionDPI = 96;
+static const double fResolutionDPI = getDefaultPdfResolutionDpi();
 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
 
 // Load the buffer using pdfium.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - desktop/source

2021-04-07 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 3a6544f89c438fcddd72efe216fb26b827e13bd5
Author: Ashod Nakashian 
AuthorDate: Sun Mar 10 12:21:33 2019 -0400
Commit: Andras Timar 
CommitDate: Thu Apr 8 08:56:09 2021 +0200

LOK: don't segfault when reporting error

Change-Id: Ia6d614eb15b15f43ddd3e0b5742b888060dfd581
Reviewed-on: https://gerrit.libreoffice.org/69069
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 
(cherry picked from commit 9fa568dced78011072390320f64eae28dd06d2b9)
Reviewed-on: https://gerrit.libreoffice.org/78443
(cherry picked from commit fa18cdce824525ebd76b542a44741a35062741ce)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 55d5f00ae874..352dc13d5576 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3989,7 +3989,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* 
pThis, const char* pComma
 else
 bResult = comphelper::dispatchCommand(aCommand, 
comphelper::containerToSequence(aPropertyValuesVector));
 
-if (!bResult)
+if (!bResult && gImpl)
 {
 SetLastExceptionMsg("Failed to dispatch " + aCommand);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/source

2021-03-31 Thread Ashod Nakashian (via logerrit)
 vcl/source/filter/ipdf/pdfread.cxx |   18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 860ea6c6693608165cfde42656d6c48c3bde91eb
Author: Ashod Nakashian 
AuthorDate: Sun Mar 28 09:38:01 2021 -0400
Commit: Jan Holesovsky 
CommitDate: Wed Mar 31 10:59:11 2021 +0200

vcl: allow for overriding the default PDF rendering resolution

Change-Id: Ibd75c6dd71d93322bd77995547e735c2d4849602
Signed-off-by: Ashod Nakashian 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113255
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index 2fb7a11bb681..e4af2a0e865b 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -146,11 +146,27 @@ VectorGraphicDataArray 
createVectorGraphicDataArray(SvStream& rStream)
 
 namespace vcl
 {
+/// Get the default PDF rendering resolution in DPI.
+static double getDefaultPdfResolutionDpi()
+{
+// If an overriding default is set, use it.
+const char* envar = ::getenv("PDFIMPORT_RESOLUTION_DPI");
+if (envar)
+{
+const double dpi = atof(envar);
+if (dpi > 0)
+return dpi;
+}
+
+// Fallback to a sensible default.
+return 96.;
+}
+
 size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector& 
rBitmaps,
 const size_t nFirstPage, int nPages, const 
basegfx::B2DTuple* pSizeHint)
 {
 #if HAVE_FEATURE_PDFIUM
-const double fResolutionDPI = 96;
+static const double fResolutionDPI = getDefaultPdfResolutionDpi();
 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
 
 // Load the buffer using pdfium.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/source

2021-03-24 Thread Ashod Nakashian (via logerrit)
 vcl/source/window/window.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit a025ac482a8d21a517bbc2ef0ef2177dd6351689
Author: Ashod Nakashian 
AuthorDate: Sun Nov 8 09:15:25 2020 -0500
Commit: Ashod Nakashian 
CommitDate: Thu Mar 25 01:42:11 2021 +0100

vcl: lok: don't use window impl after destroy

When destroying floating windows, accessing the GetLOKNotifier
can segfault. The following is the stack-trace from such
a case.

/usr/bin/loolforkit(_ZN7SigUtil13dumpBacktraceEv+0x5e)[0x55cbf9da62fe]
/usr/bin/loolforkit(+0x1d0af5)[0x55cbf9da6af5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x128a0)[0x7fe0a125f8a0]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZNK3vcl6Window14GetLOKNotifierEv+0x7)[0x7fe09e67b827]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN3vcl6Window24GetParentWithLOKNotifierEv+0x2b)[0x7fe09e67b86b]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN14FloatingWindow12StateChangedE16StateChangedType+0x43)[0x7fe09e609a13]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN3vcl6Window4ShowEb9ShowFlags+0x2ba)[0x7fe09e67cd5a]

/opt/collaboraoffice6.4/program/libmergedlo.so(_Z21ImplDestroyHelpWindowR14ImplSVHelpDatab+0xe3)[0x7fe09e90c193]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN9Scheduler21ProcessTaskSchedulingEv+0x8ea)[0x7fe09e93817a]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN14SvpSalInstance12CheckTimeoutEb+0x107)[0x7fe09ea06807]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN14SvpSalInstance7DoYieldEbb+0x85)[0x7fe09ea06905]
/opt/collaboraoffice6.4/program/libmergedlo.so(+0x2f5d6fb)[0x7fe09e94f6fb]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN11Application7ExecuteEv+0x45)[0x7fe09e950295]
/opt/collaboraoffice6.4/program/libmergedlo.so(+0x1f6d545)[0x7fe09d95f545]

/opt/collaboraoffice6.4/program/libmergedlo.so(_Z10ImplSVMainv+0x51)[0x7fe09e957321]

/opt/collaboraoffice6.4/program/libmergedlo.so(soffice_main+0x98)[0x7fe09d980b88]
/opt/collaboraoffice6.4/program/libmergedlo.so(+0x1f9e7c1)[0x7fe09d9907c1]

/usr/bin/loolforkit(_Z10lokit_mainRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_S6_S6_S6_m+0x2562)[0x55cbf9d4c792]
/usr/bin/loolforkit(+0x15fc77)[0x55cbf9d35c77]

/usr/bin/loolforkit(_Z18forkLibreOfficeKitRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_S6_S6_i+0xb44)[0x55cbf9d36b24]
/usr/bin/loolforkit(main+0x18a7)[0x55cbf9d00e17]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fe0a0e7db97]
/usr/bin/loolforkit(_start+0x2a)[0x55cbf9d07efa]

Change-Id: Ia467d51896d1ac657bde5ae2803fcb2557ebd3fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105366
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 9c874c1487b8..4c1b8c72d699 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3230,12 +3230,12 @@ ILibreOfficeKitNotifier::~ILibreOfficeKitNotifier()
 
 const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
 {
-return mpWindowImpl->mpLOKNotifier;
+return mpWindowImpl ? mpWindowImpl->mpLOKNotifier : nullptr;
 }
 
 vcl::LOKWindowId Window::GetLOKWindowId() const
 {
-return mpWindowImpl->mnLOKWindowId;
+return mpWindowImpl ? mpWindowImpl->mnLOKWindowId : 0;
 }
 
 VclPtr Window::GetParentWithLOKNotifier()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/source

2020-12-17 Thread Ashod Nakashian (via logerrit)
 vcl/source/window/window.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 5a3837034960327743154887732c4cae04cfc971
Author: Ashod Nakashian 
AuthorDate: Sun Nov 8 09:15:25 2020 -0500
Commit: Michael Meeks 
CommitDate: Thu Dec 17 09:53:50 2020 +0100

vcl: lok: don't use window impl after destroy

When destroying floating windows, accessing the GetLOKNotifier
can segfault. The following is the stack-trace from such
a case.

/usr/bin/loolforkit(_ZN7SigUtil13dumpBacktraceEv+0x5e)[0x55cbf9da62fe]
/usr/bin/loolforkit(+0x1d0af5)[0x55cbf9da6af5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x128a0)[0x7fe0a125f8a0]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZNK3vcl6Window14GetLOKNotifierEv+0x7)[0x7fe09e67b827]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN3vcl6Window24GetParentWithLOKNotifierEv+0x2b)[0x7fe09e67b86b]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN14FloatingWindow12StateChangedE16StateChangedType+0x43)[0x7fe09e609a13]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN3vcl6Window4ShowEb9ShowFlags+0x2ba)[0x7fe09e67cd5a]

/opt/collaboraoffice6.4/program/libmergedlo.so(_Z21ImplDestroyHelpWindowR14ImplSVHelpDatab+0xe3)[0x7fe09e90c193]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN9Scheduler21ProcessTaskSchedulingEv+0x8ea)[0x7fe09e93817a]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN14SvpSalInstance12CheckTimeoutEb+0x107)[0x7fe09ea06807]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN14SvpSalInstance7DoYieldEbb+0x85)[0x7fe09ea06905]
/opt/collaboraoffice6.4/program/libmergedlo.so(+0x2f5d6fb)[0x7fe09e94f6fb]

/opt/collaboraoffice6.4/program/libmergedlo.so(_ZN11Application7ExecuteEv+0x45)[0x7fe09e950295]
/opt/collaboraoffice6.4/program/libmergedlo.so(+0x1f6d545)[0x7fe09d95f545]

/opt/collaboraoffice6.4/program/libmergedlo.so(_Z10ImplSVMainv+0x51)[0x7fe09e957321]

/opt/collaboraoffice6.4/program/libmergedlo.so(soffice_main+0x98)[0x7fe09d980b88]
/opt/collaboraoffice6.4/program/libmergedlo.so(+0x1f9e7c1)[0x7fe09d9907c1]

/usr/bin/loolforkit(_Z10lokit_mainRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_S6_S6_S6_m+0x2562)[0x55cbf9d4c792]
/usr/bin/loolforkit(+0x15fc77)[0x55cbf9d35c77]

/usr/bin/loolforkit(_Z18forkLibreOfficeKitRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_S6_S6_i+0xb44)[0x55cbf9d36b24]
/usr/bin/loolforkit(main+0x18a7)[0x55cbf9d00e17]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fe0a0e7db97]
/usr/bin/loolforkit(_start+0x2a)[0x55cbf9d07efa]

Change-Id: Ia467d51896d1ac657bde5ae2803fcb2557ebd3fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105445
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 012c4389e2ce..b3f6ce9e9a29 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3243,12 +3243,12 @@ ILibreOfficeKitNotifier::~ILibreOfficeKitNotifier()
 
 const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
 {
-return mpWindowImpl->mpLOKNotifier;
+return mpWindowImpl ? mpWindowImpl->mpLOKNotifier : nullptr;
 }
 
 vcl::LOKWindowId Window::GetLOKWindowId() const
 {
-return mpWindowImpl->mnLOKWindowId;
+return mpWindowImpl ? mpWindowImpl->mnLOKWindowId : 0;
 }
 
 VclPtr Window::GetParentWithLOKNotifier()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-11-21 Thread Ashod Nakashian (via logerrit)
 desktop/inc/lib/init.hxx   |3 
 desktop/qa/desktop_lib/test_desktop_lib.cxx|  100 
 desktop/source/lib/init.cxx|   36 ---
 include/editeng/outliner.hxx   |1 
 include/sfx2/lokhelper.hxx |   17 ++-
 include/sfx2/viewsh.hxx|   15 ++-
 sc/source/ui/view/tabvwshc.cxx |3 
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx  |1 
 sd/source/ui/unoidl/unomodel.cxx   |3 
 sfx2/source/view/lokhelper.cxx |  120 +
 sfx2/source/view/viewimp.hxx   |4 
 sfx2/source/view/viewsh.cxx|   13 +-
 sw/qa/extras/tiledrendering/tiledrendering.cxx |2 
 13 files changed, 249 insertions(+), 69 deletions(-)

New commits:
commit e82335afd6e3e9a75275865661cf14a0a2959603
Author: Ashod Nakashian 
AuthorDate: Sun Aug 2 14:52:02 2020 -0400
Commit: Tor Lillqvist 
CommitDate: Sat Nov 21 22:26:19 2020 +0100

sfx2: lok: reliably support multi-documents

Instead of using the current view to set
the DocId, we instead make sure that the ShellView
object has the DocId set at construction time.
This turned out to be necessary in at least one
case (which has a unit-test that failed), which
is when events fired during the creation of a
new view. The cursor position is notified
before we have a chance to set the DocId and
because of that we miss the notifications (or
worse, we end up sending them to all other
documents' views in an effort to fix this bug).

This approach is clean and always guarantees that
all views have the correct DocId set as soon as
possible and that all notifications are sent
as expected.

A unit-test is added to exercise mult-document
usage, which exposed a number of bugs and issues
that have been addressed in this patch.

Change-Id: Icf5145fb1dabd0d029368310c2b9bf73ae927ccc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99975
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
Reviewed-by: Ashod Nakashian 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106252
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index a71ecae79f83..84d9d5299fd4 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -150,7 +150,8 @@ namespace desktop {
 std::map> 
mpCallbackFlushHandlers;
 const int mnDocumentId;
 
-explicit LibLODocument_Impl(const css::uno::Reference 
 &xComponent, int nDocumentId = -1);
+explicit LibLODocument_Impl(const 
css::uno::Reference& xComponent,
+int nDocumentId);
 ~LibLODocument_Impl();
 };
 
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a02347450a38..0a19d5582e80 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -195,6 +195,7 @@ public:
 void testCalcSaveAs();
 void testControlState();
 void testMetricField();
+void testMultiDocuments();
 void testABI();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
@@ -257,6 +258,7 @@ public:
 CPPUNIT_TEST(testCalcSaveAs);
 CPPUNIT_TEST(testControlState);
 CPPUNIT_TEST(testMetricField);
+CPPUNIT_TEST(testMultiDocuments);
 CPPUNIT_TEST(testABI);
 CPPUNIT_TEST_SUITE_END();
 
@@ -322,10 +324,13 @@ DesktopLOKTest::loadDocUrlImpl(const OUString& rFileURL, 
LibreOfficeKitDocumentT
 break;
 }
 
+static int nDocumentIdCounter = 0;
+SfxViewShell::SetCurrentDocId(ViewShellDocId(nDocumentIdCounter));
 uno::Reference xComponent = loadFromDesktop(rFileURL, 
aService);
 CPPUNIT_ASSERT(xComponent.is());
 
-std::unique_ptr pDocument(new 
LibLODocument_Impl(xComponent));
+std::unique_ptr pDocument(new 
LibLODocument_Impl(xComponent, nDocumentIdCounter));
+++nDocumentIdCounter;
 
 return std::make_pair(std::move(pDocument), xComponent);
 }
@@ -2933,6 +2938,99 @@ void DesktopLOKTest::testSpellcheckerMultiView()
 CPPUNIT_ASSERT_EQUAL(1, 
pDocument->m_pDocumentClass->getViewsCount(pDocument));
 }
 
+void DesktopLOKTest::testMultiDocuments()
+{
+// Load a document.
+uno::Reference xComponent1;
+std::unique_ptr document1;
+std::tie(document1, xComponent1) = loadDocImpl("blank_text.odt");
+LibLODocument_Impl* pDocument1 = document1.get();
+CPPUNIT_ASSERT_EQUAL(1, 
pDocument1->m_pDocumentClass->getViewsCount(pDocument1));
+const int nDocId1 = pDocument1->mnDocumentId;
+
+const int nDoc1View0 = pDocument1->m_pDocumentClass->getView(pDocument1);
+CPPUNIT_ASSERT_EQUAL(nDocId1, 
SfxLokHelper::getDocumentIdOfView(nDoc1View0));
+const int nDoc1View1 = 

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

2020-11-21 Thread Ashod Nakashian (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |  117 +---
 1 file changed, 91 insertions(+), 26 deletions(-)

New commits:
commit 23951bdc3836b252aab0e7628d8839e89b5a9f6d
Author: Ashod Nakashian 
AuthorDate: Sun Aug 2 12:41:19 2020 -0400
Commit: Tor Lillqvist 
CommitDate: Sat Nov 21 22:25:05 2020 +0100

DesktopLOKTest: cleanup

Refactor the handling of document loading
and unloading and cleanup to allow more flexibility
when loading multiple documents and for manual
destruction.

Also, correctly set the document type when loading,
which was defaulted to TEXT even when loading
spreadsheet and presentation documents.

Minor misc cleanup such as dangling semicolons and
unregistering the callback twice.

Change-Id: Ia244aafd526d60f73c46e99fb8c7e63f63b0a8f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99974
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106225
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 74d9bcede0cf..a02347450a38 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -55,9 +55,34 @@
 #include 
 #include 
 
+#include 
+
 using namespace com::sun::star;
 using namespace desktop;
 
+static LibreOfficeKitDocumentType getDocumentTypeFromName(const char* pName)
+{
+CPPUNIT_ASSERT_MESSAGE("Document name must be valid.", pName != nullptr);
+
+const std::string name(pName);
+CPPUNIT_ASSERT_MESSAGE("Document name must include extension.", 
name.size() > 4);
+
+const auto it = name.rfind('.');
+if (it != std::string::npos)
+{
+const std::string ext = name.substr(it);
+
+if (ext == ".ods")
+return LOK_DOCTYPE_SPREADSHEET;
+
+if (ext == ".odp")
+return LOK_DOCTYPE_PRESENTATION;
+}
+
+CPPUNIT_ASSERT_MESSAGE("Document name must include extension.", it != 
std::string::npos);
+return LOK_DOCTYPE_TEXT;
+}
+
 class DesktopLOKTest : public UnoApiTest
 {
 public:
@@ -78,22 +103,38 @@ public:
 UnoApiTest::setUp();
 
mxDesktop.set(frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory(;
 SfxApplication::GetOrCreate();
-};
+}
 
 virtual void tearDown() override
 {
-if (m_pDocument)
-m_pDocument->pClass->registerCallback(m_pDocument.get(), nullptr, 
nullptr);
 closeDoc();
 
 UnoApiTest::tearDown();
 
 comphelper::LibreOfficeKit::setActive(false);
-};
+}
+
+std::pair, 
uno::Reference>
+loadDocImpl(const char* pName, LibreOfficeKitDocumentType eType);
+
+private:
+std::pair, 
uno::Reference>
+loadDocImpl(const char* pName);
+
+public:
+std::pair, 
uno::Reference>
+loadDocUrlImpl(const OUString& rFileURL, LibreOfficeKitDocumentType eType);
 
 LibLODocument_Impl* loadDocUrl(const OUString& rFileURL, 
LibreOfficeKitDocumentType eType);
-LibLODocument_Impl* loadDoc(const char* pName, LibreOfficeKitDocumentType 
eType = LOK_DOCTYPE_TEXT);
-void closeDoc();
+LibLODocument_Impl* loadDoc(const char* pName, LibreOfficeKitDocumentType 
eType);
+LibLODocument_Impl* loadDoc(const char* pName)
+{
+return loadDoc(pName, getDocumentTypeFromName(pName));
+}
+
+void closeDoc(std::unique_ptr& loDocument,
+  uno::Reference& xComponent);
+void closeDoc() { closeDoc(m_pDocument, mxComponent); }
 static void callback(int nType, const char* pPayload, void* pData);
 void callbackImpl(int nType, const char* pPayload);
 
@@ -261,7 +302,8 @@ static Control* GetFocusControl(vcl::Window const * pParent)
 return nullptr;
 }
 
-LibLODocument_Impl* DesktopLOKTest::loadDocUrl(const OUString& rFileURL, 
LibreOfficeKitDocumentType eType)
+std::pair, 
uno::Reference>
+DesktopLOKTest::loadDocUrlImpl(const OUString& rFileURL, 
LibreOfficeKitDocumentType eType)
 {
 OUString aService;
 switch (eType)
@@ -279,28 +321,54 @@ LibLODocument_Impl* DesktopLOKTest::loadDocUrl(const 
OUString& rFileURL, LibreOf
 CPPUNIT_ASSERT(false);
 break;
 }
-mxComponent = loadFromDesktop(rFileURL, aService);
-if (!mxComponent.is())
-{
-CPPUNIT_ASSERT(false);
-}
-m_pDocument.reset(new LibLODocument_Impl(mxComponent));
-return m_pDocument.get();
+
+uno::Reference xComponent = loadFromDesktop(rFileURL, 
aService);
+CPPUNIT_ASSERT(xComponent.is());
+
+std::unique_ptr pDocument(new 
LibLODocument_Impl(xComponent));
+
+return std::make_pair(std::move(pDocument), xComponent);
 }
 
-LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, 

[Libreoffice-commits] core.git: sc/qa sd/qa sw/qa

2020-11-20 Thread Ashod Nakashian (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |2 
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |2 
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   69 -
 3 files changed, 37 insertions(+), 36 deletions(-)

New commits:
commit 02cb3f9f9c651d23de3fd80b04380e3d7314250e
Author: Ashod Nakashian 
AuthorDate: Sat Aug 1 16:09:00 2020 -0400
Commit: Tor Lillqvist 
CommitDate: Fri Nov 20 14:49:58 2020 +0100

lok: minor cleanup of ViewCallback in tiledrendering tests

Change-Id: I39b964a7aa7d181083a153283f38c1a5bc64de58
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99973
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106222
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 8c03a19902d5..bb34928fef7d 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -452,7 +452,7 @@ void ScTiledRenderingTest::testEmptyColumnSelection()
 }
 
 /// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback
+class ViewCallback final
 {
 SfxViewShell* mpViewShell;
 int mnView;
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index d03e1be8341e..1aba4c65a77a 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -842,7 +842,7 @@ void SdTiledRenderingTest::testResizeTableColumn()
 namespace {
 
 /// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback
+class ViewCallback final
 {
 SfxViewShell* mpViewShell;
 int mnView;
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 9f8f074a4568..7b497ae8c600 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -760,7 +760,7 @@ void SwTiledRenderingTest::testPartHash()
 namespace {
 
 /// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback
+class ViewCallback final
 {
 SfxViewShell* mpViewShell;
 int mnView;
@@ -788,7 +788,7 @@ public:
 /// Post-it / annotation payload.
 boost::property_tree::ptree m_aComment;
 
-ViewCallback(SfxViewShell* pViewShell, std::function 
const & rBeforeInstallFunc = {})
+ViewCallback(SfxViewShell* pViewShell = nullptr, 
std::function const & rBeforeInstallFunc = {})
 : m_bOwnCursorInvalidated(false),
   m_nOwnCursorInvalidatedBy(-1),
   m_bOwnCursorAtOrigin(false),
@@ -806,7 +806,7 @@ public:
 if (rBeforeInstallFunc)
 rBeforeInstallFunc(*this);
 
-mpViewShell = pViewShell;
+mpViewShell = pViewShell ? pViewShell : SfxViewShell::Current();
 
mpViewShell->registerLibreOfficeKitViewCallback(&ViewCallback::callback, this);
 mnView = SfxLokHelper::getView();
 }
@@ -974,10 +974,10 @@ void SwTiledRenderingTest::testMissingInvalidation()
 {
 // Create two views.
 SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-ViewCallback aView1(SfxViewShell::Current());
+ViewCallback aView1;
 int nView1 = SfxLokHelper::getView();
 SfxLokHelper::createView();
-ViewCallback aView2(SfxViewShell::Current());
+ViewCallback aView2;
 int nView2 = SfxLokHelper::getView();
 
 // First view: put the cursor into the first word.
@@ -1005,9 +1005,10 @@ void SwTiledRenderingTest::testMissingInvalidation()
 void SwTiledRenderingTest::testViewCursors()
 {
 SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-ViewCallback aView1(SfxViewShell::Current());
+ViewCallback aView1;
 SfxLokHelper::createView();
-ViewCallback aView2(SfxViewShell::Current());
+ViewCallback aView2;
+
 CPPUNIT_ASSERT(aView1.m_bOwnCursorInvalidated);
 CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
 CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
@@ -1041,10 +1042,10 @@ void SwTiledRenderingTest::testShapeViewCursors()
 {
 // Load a document and create a view, so we have 2 ones.
 SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
-ViewCallback aView1(SfxViewShell::Current());
+ViewCallback aView1;
 SfxLokHelper::createView();
 
pXTextDocument->initializeForTiledRendering(uno::Sequence());
-ViewCallback aView2(SfxViewShell::Current());
+ViewCallback aView2;
 SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
 
 // Start shape text in the second view.
@@ -1078,10 +1079,10 @@ void SwTiledRenderingTest::testViewCursorVisibility()
 {
 // Load a document that has a shape and create two views.
 SwXTextDocument* pXTextDocument = createDoc("s

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

2020-11-20 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx|4 +-
 include/sfx2/lokhelper.hxx |   17 +++---
 sfx2/source/view/lokhelper.cxx |   69 -
 sw/source/core/crsr/crsrsh.cxx |2 -
 4 files changed, 56 insertions(+), 36 deletions(-)

New commits:
commit 44f6329330e8c8f000cb310b04ac13777e8bfff3
Author: Ashod Nakashian 
AuthorDate: Fri Jul 24 11:33:46 2020 -0400
Commit: Tor Lillqvist 
CommitDate: Fri Nov 20 14:34:00 2020 +0100

sfx2: lok: refactor notifications and const correctness

This reduces the stringification and reuses the notificaiton
helpers to reduce code duplication.

Change-Id: Icf9f9c50f361a0ded741d39fed37cfcc8da1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99972
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106221
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 8f82d577f3cc..6fe7347e9b70 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2195,7 +2195,7 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 LibLibreOffice_Impl* pLib = static_cast(pThis);
 pLib->maLastExceptionMsg.clear();
 
-OUString aURL(getAbsoluteURL(pURL));
+const OUString aURL(getAbsoluteURL(pURL));
 if (aURL.isEmpty())
 {
 pLib->maLastExceptionMsg = "Filename to load was not provided.";
@@ -2291,7 +2291,7 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 
 LibLODocument_Impl* pDocument = new LibLODocument_Impl(xComponent, 
nDocumentIdCounter++);
 
-// Do we know that after loading the document, its initial view is the 
"current" view?
+// After loading the document, its initial view is the "current" view.
 SfxLokHelper::setDocumentIdOfView(pDocument->mnDocumentId);
 if (pLib->mpCallback)
 {
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 79052a0d6e04..2aad968681b8 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -51,7 +51,7 @@ public:
 /// Set a view shell as current one.
 static void setView(int nId);
 /// Get the currently active view.
-static int getView(SfxViewShell* pViewShell = nullptr);
+static int getView(const SfxViewShell* pViewShell = nullptr);
 /// Get the number of views of the current object shell.
 static std::size_t getViewsCount();
 /// Get viewIds of views of the current object shell.
@@ -72,17 +72,24 @@ public:
 static LOKDeviceFormFactor getDeviceFormFactor();
 /// Set the device form factor that should be used for a new view.
 static void setDeviceFormFactor(const OUString& rDeviceFormFactor);
+
 /// Iterate over any view shell, except pThisViewShell, passing it to the 
f function.
 template
 static void forEachOtherView(ViewShellType* pThisViewShell, FunctionType 
f);
+
 /// Invoke the LOK callback of all other views showing the same document 
as pThisView, with a payload of rKey-rPayload.
-static void notifyOtherViews(SfxViewShell* pThisView, int nType, const 
OString& rKey, const OString& rPayload);
+static void notifyOtherViews(const SfxViewShell* pThisView, int nType, 
const OString& rKey,
+ const OString& rPayload);
 /// Invoke the LOK callback of all views except pThisView, with a JSON 
payload created from the given property tree.
-static void notifyOtherViews(SfxViewShell* pThisView, int nType, const 
boost::property_tree::ptree& rTree);
+static void notifyOtherViews(const SfxViewShell* pThisView, int nType,
+ const boost::property_tree::ptree& rTree);
 /// Same as notifyOtherViews(), but works on a selected "other" view, not 
on all of them.
-static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* 
pOtherView, int nType, const OString& rKey, const OString& rPayload);
+static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell 
const* pOtherView,
+int nType, const OString& rKey, const OString& 
rPayload);
 /// Same as notifyOtherViews(), the property-tree version, but works on a 
selected "other" view, not on all of them.
-static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* 
pOtherView, int nType, const boost::property_tree::ptree& rTree);
+static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell 
const* pOtherView,
+int nType, const boost::property_tree::ptree& 
rTree);
+
 /// Emits a LOK_CALLBACK_STATE_CHANGED
 static void sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* 
pItem);
 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/comphelper

2020-11-19 Thread Ashod Nakashian (via logerrit)
 include/comphelper/lok.hxx |   10 --
 1 file changed, 10 deletions(-)

New commits:
commit 1a5681c92469f8cf445c42ff99f5a2a87bae3705
Author: Ashod Nakashian 
AuthorDate: Fri Sep 18 17:11:09 2020 -0400
Commit: Andras Timar 
CommitDate: Thu Nov 19 20:57:47 2020 +0100

lok: remove unused API

Change-Id: Ibf3039f0f5d8b580e8d93c77d7adb9c4b90ba67a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105444
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index dfbc1a2ce6c0..e9fb004511e5 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -29,16 +29,6 @@ namespace LibreOfficeKit
 
 COMPHELPER_DLLPUBLIC void setActive(bool bActive = true);
 
-// Call either setMobilePhone() or setTablet() for a view, and at most once. 
(If neither is called,
-// the view is assumed to be on a desktop browser.) In the future, this will 
possibly be changed
-// into using an enum for the kind of the view, that can be DESKTOP, 
MOBILEPHONE, or TABLET.
-
-// Tell that LOK view is on a mobile phone (regardless what its pixel 
resolution is, whether its form factor is "phablet" or not)
-COMPHELPER_DLLPUBLIC void setMobilePhone(int nViewId);
-
-// Tell that LOK view is on a tablet
-COMPHELPER_DLLPUBLIC void setTablet(int nViewId);
-
 enum class statusIndicatorCallbackType { Start, SetValue, Finish };
 
 COMPHELPER_DLLPUBLIC void setStatusIndicatorCallback(void (*callback)(void 
*data, statusIndicatorCallbackType type, int percent), void *data);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/comphelper

2020-11-18 Thread Ashod Nakashian (via logerrit)
 include/comphelper/lok.hxx |   10 --
 1 file changed, 10 deletions(-)

New commits:
commit 8f79f590662145b054661846e018a4fc1837db8a
Author: Ashod Nakashian 
AuthorDate: Fri Sep 18 17:11:09 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Nov 19 05:55:00 2020 +0100

lok: remove unused API

Change-Id: Ibf3039f0f5d8b580e8d93c77d7adb9c4b90ba67a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105365
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index b8276ea49fc6..2391ceab3661 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -26,16 +26,6 @@ namespace comphelper::LibreOfficeKit
 
 COMPHELPER_DLLPUBLIC void setActive(bool bActive = true);
 
-// Call either setMobilePhone() or setTablet() for a view, and at most once. 
(If neither is called,
-// the view is assumed to be on a desktop browser.) In the future, this will 
possibly be changed
-// into using an enum for the kind of the view, that can be DESKTOP, 
MOBILEPHONE, or TABLET.
-
-// Tell that LOK view is on a mobile phone (regardless what its pixel 
resolution is, whether its form factor is "phablet" or not)
-COMPHELPER_DLLPUBLIC void setMobilePhone(int nViewId);
-
-// Tell that LOK view is on a tablet
-COMPHELPER_DLLPUBLIC void setTablet(int nViewId);
-
 enum class statusIndicatorCallbackType { Start, SetValue, Finish };
 
 COMPHELPER_DLLPUBLIC void setStatusIndicatorCallback(void (*callback)(void 
*data, statusIndicatorCallbackType type, int percent), void *data);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - net/WebSocketHandler.hpp

2020-09-18 Thread Ashod Nakashian (via logerrit)
 net/WebSocketHandler.hpp |   22 +++---
 1 file changed, 7 insertions(+), 15 deletions(-)

New commits:
commit 3956aa7cba09cada02873b624e05d7c436c98c28
Author: Ashod Nakashian 
AuthorDate: Thu Sep 17 07:54:00 2020 -0400
Commit: Michael Meeks 
CommitDate: Fri Sep 18 12:05:46 2020 +0200

wsd: allow pings from clients

Per the rfc (https://tools.ietf.org/html/rfc6455#section-5.5.2):
"An endpoint MAY send a Ping frame any time after the connection
is established and before the connection is closed."

And "Upon receipt of a Ping frame, an endpoint MUST send a Pong
frame in response, unless it already received a Close frame."

Here we allow for pings to come from clients and we respond
to them by pongs, as required by rfc 6455.

Change-Id: I8e285f095526e4b67373ecb3ae1efc9c8717d756
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102948
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102990
Reviewed-by: Michael Meeks 

diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index 77ae3a264..62cd53c0b 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -287,33 +287,25 @@ public:
 switch (code)
 {
 case WSOpCode::Pong:
-if (_isClient)
-{
-LOG_ERR('#' << socket->getFD() << ": Servers should not 
send pongs, only clients");
-shutdown(StatusCodes::POLICY_VIOLATION);
-return true;
-}
-else
 {
+if (_isClient)
+LOG_WRN('#' << socket->getFD() << ": Servers should 
not send pongs, only clients");
+
 _pingTimeUs = 
std::chrono::duration_cast
 (std::chrono::steady_clock::now() - 
_lastPingSentTime).count();
 LOG_TRC('#' << socket->getFD() << ": Pong received: " << 
_pingTimeUs << " microseconds");
 }
 break;
 case WSOpCode::Ping:
-if (_isClient)
 {
-auto now = std::chrono::steady_clock::now();
+if (!_isClient)
+LOG_ERR('#' << socket->getFD() << ": Clients should 
not send pings, only servers");
+
+const auto now = std::chrono::steady_clock::now();
 _pingTimeUs = 
std::chrono::duration_cast
 (now - _lastPingSentTime).count();
 sendPong(now, &ctrlPayload[0], payloadLen, socket);
 }
-else
-{
-LOG_ERR('#' << socket->getFD() << ": Clients should not 
send pings, only servers");
-shutdown(StatusCodes::POLICY_VIOLATION);
-return true;
-}
 break;
 case WSOpCode::Close:
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: net/WebSocketHandler.hpp

2020-09-17 Thread Ashod Nakashian (via logerrit)
 net/WebSocketHandler.hpp |   22 +++---
 1 file changed, 7 insertions(+), 15 deletions(-)

New commits:
commit 4c954973273624f80d92cf6190ea064bac41bdb9
Author: Ashod Nakashian 
AuthorDate: Thu Sep 17 07:54:00 2020 -0400
Commit: Andras Timar 
CommitDate: Thu Sep 17 15:37:21 2020 +0200

wsd: allow pings from clients

Per the rfc (https://tools.ietf.org/html/rfc6455#section-5.5.2):
"An endpoint MAY send a Ping frame any time after the connection
is established and before the connection is closed."

And "Upon receipt of a Ping frame, an endpoint MUST send a Pong
frame in response, unless it already received a Close frame."

Here we allow for pings to come from clients and we respond
to them by pongs, as required by rfc 6455.

Change-Id: I8e285f095526e4b67373ecb3ae1efc9c8717d756
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102948
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index 7fb38c86d..7a9ec902c 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -287,33 +287,25 @@ public:
 switch (code)
 {
 case WSOpCode::Pong:
-if (_isClient)
-{
-LOG_ERR('#' << socket->getFD() << ": Servers should not 
send pongs, only clients");
-shutdown(StatusCodes::POLICY_VIOLATION);
-return true;
-}
-else
 {
+if (_isClient)
+LOG_WRN('#' << socket->getFD() << ": Servers should 
not send pongs, only clients");
+
 _pingTimeUs = 
std::chrono::duration_cast
 (std::chrono::steady_clock::now() - 
_lastPingSentTime).count();
 LOG_TRC('#' << socket->getFD() << ": Pong received: " << 
_pingTimeUs << " microseconds");
 }
 break;
 case WSOpCode::Ping:
-if (_isClient)
 {
-auto now = std::chrono::steady_clock::now();
+if (!_isClient)
+LOG_ERR('#' << socket->getFD() << ": Clients should 
not send pings, only servers");
+
+const auto now = std::chrono::steady_clock::now();
 _pingTimeUs = 
std::chrono::duration_cast
 (now - _lastPingSentTime).count();
 sendPong(now, &ctrlPayload[0], payloadLen, socket);
 }
-else
-{
-LOG_ERR('#' << socket->getFD() << ": Clients should not 
send pings, only servers");
-shutdown(StatusCodes::POLICY_VIOLATION);
-return true;
-}
 break;
 case WSOpCode::Close:
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd-systemplate-setup

2020-08-26 Thread Ashod Nakashian (via logerrit)
 loolwsd-systemplate-setup |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit b6da68b0f75b313294b42cf782420d0a30422058
Author: Ashod Nakashian 
AuthorDate: Wed Aug 26 11:52:39 2020 -0400
Commit: Andras Timar 
CommitDate: Wed Aug 26 18:00:18 2020 +0200

systemplate: do not soft-link to host filesystem in the jail

Files soft-linked from the jail will reference those in the
chroot and not the real/root filesystem. We can only get
away with hard-links in this case. Failing that, we must
copy the file and check at runtime. Hard-linking most
commonly fails due to cross-device linkage, which is
prohibited.

Change-Id: I4d43fd2ac47c42edd59de9baba5b38a78c879f6e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101417
Tested-by: Andras Timar 
Reviewed-by: Andras Timar 

diff --git a/loolwsd-systemplate-setup b/loolwsd-systemplate-setup
index ea04a03de..649b1efd5 100755
--- a/loolwsd-systemplate-setup
+++ b/loolwsd-systemplate-setup
@@ -69,8 +69,8 @@ cpio -p -d -L $CHROOT
 for file in hosts nsswitch.conf resolv.conf passwd group host.conf timezone 
localtime
 do
 #echo "Linking/Copying /etc/$file"
-# Prefer hard linking, fallback to soft linking, and finally to just 
copying.
-ln -f /etc/$file $CHROOT/etc/ 2> /dev/null || ln -f -s /etc/$file 
$CHROOT/etc/ || cp /etc/$file $CHROOT/etc/ || echo "Failed to link or copy 
$file"
+# Prefer hard-linking, fallback to just copying (do *not* use soft-linking 
because that would be relative to the jail).
+ln -f /etc/$file $CHROOT/etc/ 2> /dev/null || cp /etc/$file $CHROOT/etc/ 
|| echo "Failed to link or copy $file"
 done
 
 # Link dev/random and dev/urandom to ../tmp/dev/.
@@ -79,6 +79,7 @@ mkdir -p $CHROOT/dev
 mkdir -p $CHROOT/tmp/dev
 for file in random urandom
 do
+# This link is relative anyway, so can be soft.
 ln -f ../tmp/dev/$file $CHROOT/dev/ 2> /dev/null || ln -f -s 
../tmp/dev/$file $CHROOT/dev/ || echo "Failed to link dev/$file"
 done
 
@@ -89,6 +90,7 @@ mkdir -p $CHROOT/lo
 # In case the original path is different from
 for path in $INSTDIR $INSTDIR_LOGICAL
 do
+# Create a soft-link, as it's a relative directory path (can't be a 
hard-link).
 INSTDIR_PARENT="$(dirname "$CHROOT/$path")"
 mkdir -p $INSTDIR_PARENT
 ln -f -s `realpath --relative-to=$INSTDIR_PARENT $CHROOT/lo` $CHROOT/$path
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/Common.hpp kit/Kit.cpp wsd/DocumentBroker.cpp

2020-08-26 Thread Ashod Nakashian (via logerrit)
 common/Common.hpp  |   14 ++
 kit/Kit.cpp|2 +-
 wsd/DocumentBroker.cpp |2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)

New commits:
commit 9f5bd850080ef6b258d6e9f7b43b1148f23bc52c
Author: Ashod Nakashian 
AuthorDate: Mon Aug 24 00:17:49 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Aug 26 17:47:50 2020 +0200

wsd: use a shared threadname suffix for each document

The use of a common threadname suffix in the WSD and Kit
processes is intentional. It is designed to help filter
for a single document's logs across both processes.

The thread name has nothing to do with the classes in
the code, nor is it intended to imply any relationship
except with the process and the document in question.

As the comment in this patch explains, the choice of
the suffix is arbitrary and while it may be changed,
it has to be sensible and common between the two threads
to allow for easy grepping.

Historically, there were in fact dedicated threads
within the respective "broker" classes, but this
fact should be safely ignored, since at the log level
we care less about which part of the code generates a
log entry (that info, if needed, is at the end of each
log entry, in the form of filename and line number),
rather we care more about which document it relates to,
which is crucial in investigating production issues.

Logs and code structure are only incidentally related.
Logs are (or at least should be) designed around
the execution structure, not code architecture.

(This reverts 2a16f34812cf69bbe0f21b7e7d048fdb3271fa9d)

Change-Id: Ic6fe2f9425998824774d2644fe4362e75dea6b88
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101261
Tested-by: Jenkins
Tested-by: Tor Lillqvist 
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tor Lillqvist 

diff --git a/common/Common.hpp b/common/Common.hpp
index d2cc933d6..f036f9219 100644
--- a/common/Common.hpp
+++ b/common/Common.hpp
@@ -40,6 +40,20 @@ constexpr const char FORKIT_URI[] = "/loolws/forkit";
 
 constexpr const char CAPABILITIES_END_POINT[] = "/hosting/capabilities";
 
+/// A shared threadname suffix in both the WSD and Kit processes
+/// is highly helpful for filtering the logs for the same document
+/// by simply grepping for this shared suffix+ID. e.g. 'grep "broker_123" 
loolwsd.log'
+/// Unfortunately grepping for only "_123" would include more noise than 
desirable.
+/// This also makes the threadname symmetric and the entries aligned.
+/// The choice of "broker" as the suffix is historic: it implies the controller
+/// of which there are two: one in WSD called DocumentBroker and one in Kit
+/// called Document, which wasn't called DocumentBroker to avoid confusing it
+/// with the one in WSD. No such confusion should be expected in the logs, 
since
+/// the prefix is "doc" and "kit" respectively, and each log entry has the 
process
+/// name prefixed. And of course these threads are unrelated to the classes in
+/// the code: they are logical execution unit names.
+#define SHARED_DOC_THREADNAME_SUFFIX "broker_"
+
 /// The HTTP response User-Agent.
 #define HTTP_AGENT_STRING "LOOLWSD HTTP Agent " LOOLWSD_VERSION
 
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 30cd4e5f8..87335ecaa 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1879,7 +1879,7 @@ protected:
 URI::decode(docKey, url);
 LOG_INF("New session [" << sessionId << "] request on url [" << 
url << "].");
 #ifndef IOS
-Util::setThreadName("kit_" + docId);
+Util::setThreadName("kit" SHARED_DOC_THREADNAME_SUFFIX + docId);
 #endif
 if (!_document)
 {
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 4218b9fb4..4924d5c9f 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -187,7 +187,7 @@ DocumentBroker::DocumentBroker(ChildType type,
 _cursorPosY(0),
 _cursorWidth(0),
 _cursorHeight(0),
-_poll(new DocumentBrokerPoll("docbroker_" + _docId, *this)),
+_poll(new DocumentBrokerPoll("doc" SHARED_DOC_THREADNAME_SUFFIX + _docId, 
*this)),
 _stop(false),
 _closeReason("stopped"),
 _lockCtx(new LockContext()),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/JailUtil.cpp common/JailUtil.hpp kit/ForKit.cpp kit/Kit.cpp loolwsd-systemplate-setup Makefile.am

2020-08-24 Thread Ashod Nakashian (via logerrit)
 Makefile.am   |   32 +--
 common/JailUtil.cpp   |  131 +-
 common/JailUtil.hpp   |   35 ++--
 kit/ForKit.cpp|   15 ++---
 kit/Kit.cpp   |  114 +---
 loolwsd-systemplate-setup |   34 ++-
 6 files changed, 219 insertions(+), 142 deletions(-)

New commits:
commit 29a5a1f1e97e10aa6f9bdbed0b1062e2ab4e128b
Author: Ashod Nakashian 
AuthorDate: Sun Aug 23 12:11:23 2020 -0400
Commit: Andras Timar 
CommitDate: Tue Aug 25 07:58:30 2020 +0200

wsd: move jail setup to the script to support readonly systemplate

We now gracefully fallback to copying when/if systemplate
is readonly.

The bulk of the change is to support proper cleanup in
both cases.

First, we had to move as much of the jail bootstrapping
into the loolwsd-systemplate-setup script, so systemplate
will be as complete as possible before it is locked down.
Next, we needed to update the jail with graceful fallback
to linking/copying upon failure. For that, the jail setup
logic in Kit.cpp has been reworked to support not just
update failures, but also more comprehensive mounting
failures as well.

Finally, jail cleanup now is seamless. To support proper
cleanup when we had mounting enabled but had to fallback,
we mark jails that aren't mounted so we can 'rm -rf' the
contents safely and without fear or causing undue damage
(as unlikely as that is, technically we wouldn't want to
rm systemplate files, if mounting read-only had failed).

There are a few minor refactorings of JailUtil to make
it cleaner and more robust.

Change-Id: Iac34869cb84f45acf64fbbc46d46898367b496d2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101260
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/Makefile.am b/Makefile.am
index e2c4b57e6..e50b68022 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -335,27 +335,26 @@ SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp
 CAPABILITIES = $(if @ENABLE_SETCAP@,true,false)
 RUN_GDB = $(if $(GDB_FRONTEND),$(GDB_FRONTEND),gdb --tui --args)
 
-# Add caps to the binaries that need them.
-caps_bins: loolforkit loolmount
 if ENABLE_SETCAP
-   sudo @SETCAP@ cap_fowner,cap_mknod,cap_sys_chroot=ep loolforkit
-   sudo @SETCAP@ cap_sys_admin=ep loolmount
+SET_CAPS_COMMAND=sudo @SETCAP@ cap_fowner,cap_mknod,cap_sys_chroot=ep 
loolforkit && sudo @SETCAP@ cap_sys_admin=ep loolmount
 else
-   echo "Skipping capability setting"
+SET_CAPS_COMMAND=
+echo "Skipping capability setting"
 endif
 
 if ENABLE_LIBFUZZER
 CLEANUP_DEPS=
 else
-CLEANUP_DEPS=loolwsd
+CLEANUP_DEPS=loolwsd loolmount loolforkit
 endif
 
 # Build loolwsd and loolmount first, so we can cleanup before updating
 # the systemplate directory, which we can't rm if it's mounted.
-$(SYSTEM_STAMP): ${top_srcdir}/loolwsd-systemplate-setup $(CLEANUP_DEPS) 
caps_bins
+$(SYSTEM_STAMP): ${top_srcdir}/loolwsd-systemplate-setup $(CLEANUP_DEPS)
+   $(SET_CAPS_COMMAND)
$(CLEANUP_COMMAND)
-   if test "z@SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@"; 
fi
-   ${top_srcdir}/loolwsd-systemplate-setup "@SYSTEMPLATE_PATH@" 
"@LO_PATH@" && touch $@
+   if test "z@SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@" 
&& \
+   ${top_srcdir}/loolwsd-systemplate-setup "@SYSTEMPLATE_PATH@" 
"@LO_PATH@" && touch $@; fi
 
 @JAILS_PATH@:
$(CLEANUP_COMMAND)
@@ -486,12 +485,7 @@ SYSTEM_STAMP =
 
 endif
 
-# After building loolforkit, set its capabilities as required. Do it
-# already after a plain 'make' to allow for testing without
-# installing. When building for packaging, no need for this, as the
-# capabilities won't survive packaging anyway. Instead, handle it when
-# installing the RPM or Debian package.
-.PHONY: caps_bins cleanup
+.PHONY: cleanup
 
 if ENABLE_LIBFUZZER
 ALL_LOCAL_DEPS=
@@ -499,7 +493,13 @@ else
 ALL_LOCAL_DEPS=loolwsd
 endif
 
-all-local: $(ALL_LOCAL_DEPS) caps_bins @JAILS_PATH@ $(SYSTEM_STAMP)
+# After building loolforkit, set its capabilities as required. Do it
+# already after a plain 'make' to allow for testing without
+# installing. When building for packaging, no need for this, as the
+# capabilities won't survive packaging anyway. Instead, handle it when
+# installing the RPM or Debian package.
+all-local: $(ALL_LOCAL_DEPS) @JAILS_PATH@ $(SYSTEM_STAMP)
+   $(SET_CAPS_COMMAND)
 
 # just run the build without any tests
 build-nocheck: all-am
diff --git a/common/JailUtil.cpp b/common/JailUtil.cpp
index c7ce612df..7b313d470 100644
--- a/common/JailUtil.cpp
+++ b/common/JailU

[Libreoffice-commits] online.git: loleaflet/src

2020-08-17 Thread Ashod Nakashian (via logerrit)
 loleaflet/src/control/Control.TopToolbar.js |8 
 1 file changed, 8 insertions(+)

New commits:
commit 0d2a32fe2a030c5c7f02cbb0912434844d240db9
Author: Ashod Nakashian 
AuthorDate: Tue Aug 11 13:51:19 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Aug 18 02:28:26 2020 +0200

leaflet: hide the splitter on the toolbar if the first

When the toobar buttons to the left of the first splitter
are hidden, we start the toolbar with a splitter, which
is aesthetically unpleasant.

Here we special case for the desktop only, because
tablets and mobiles have a slightly different toolbar.
Although we should have a similar logic for them too.

Change-Id: I9869433f3ca3391d7ee899a77bb1466fe456f9f2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100832
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/loleaflet/src/control/Control.TopToolbar.js 
b/loleaflet/src/control/Control.TopToolbar.js
index 34450e934..2f896e778 100644
--- a/loleaflet/src/control/Control.TopToolbar.js
+++ b/loleaflet/src/control/Control.TopToolbar.js
@@ -373,6 +373,14 @@ L.Control.TopToolbar = L.Control.extend({
if (e.HidePrintOption) {
w2ui['editbar'].hide('print');
}
+
+   // On desktop we only have Save and Print buttons before the 
first
+   // splitter/break. Hide the splitter if we hid both save and 
print.
+   // TODO: Apply the same logic to mobile/tablet to avoid 
beginning with a splitter.
+   if (window.mode.isDesktop() && e.HideSaveOption && 
e.HidePrintOption) {
+   w2ui['editbar'].hide('savebreak');
+   }
+
if (e.EnableInsertRemoteImage === true && w2ui['editbar']) {
w2ui['editbar'].hide('insertgraphic');
w2ui['editbar'].show('menugraphic');
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/JsonUtil.hpp wsd/ClientSession.cpp

2020-08-17 Thread Ashod Nakashian (via logerrit)
 common/JsonUtil.hpp   |5 ++---
 wsd/ClientSession.cpp |2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

New commits:
commit 3cf27ee2c26ce82c417d18089fc0d8a3ce1c93fc
Author: Ashod Nakashian 
AuthorDate: Sat Aug 15 12:40:42 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Mon Aug 17 14:15:37 2020 +0200

wsd: minor cosmetics

Change-Id: I9e67cf870c92197a5c53d45f479d8c9f70818049
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100833
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/common/JsonUtil.hpp b/common/JsonUtil.hpp
index 8f4e9d926..4fdc260c1 100644
--- a/common/JsonUtil.hpp
+++ b/common/JsonUtil.hpp
@@ -26,7 +26,6 @@ namespace JsonUtil
 // Returns true if parsing successful otherwise false
 inline bool parseJSON(const std::string& json, Poco::JSON::Object::Ptr& object)
 {
-bool success = false;
 const size_t index = json.find_first_of('{');
 if (index != std::string::npos)
 {
@@ -34,10 +33,10 @@ inline bool parseJSON(const std::string& json, 
Poco::JSON::Object::Ptr& object)
 Poco::JSON::Parser parser;
 const Poco::Dynamic::Var result = parser.parse(stringJSON);
 object = result.extract();
-success = true;
+return true;
 }
 
-return success;
+return false;
 }
 
 inline
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index a3fa8e078..7c4ac6fdb 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -207,7 +207,7 @@ void ClientSession::rotateClipboardKey(bool notifyClient)
 std::string ClientSession::getClipboardURI(bool encode)
 {
 if (_wopiFileInfo && _wopiFileInfo->getDisableCopy())
-return "";
+return std::string();
 
 std::string encodedFrom;
 Poco::URI wopiSrc = getDocumentBroker()->getPublicUri();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/FileUtil.cpp common/JailUtil.cpp common/JailUtil.hpp kit/Kit.cpp loolwsd-systemplate-setup

2020-08-17 Thread Ashod Nakashian (via logerrit)
 common/FileUtil.cpp   |   48 +++---
 common/JailUtil.cpp   |   84 ++
 common/JailUtil.hpp   |3 +
 kit/Kit.cpp   |   15 ++--
 loolwsd-systemplate-setup |   11 --
 5 files changed, 83 insertions(+), 78 deletions(-)

New commits:
commit bc8da0cb339cc685f9a24c78e8a92aadcd690479
Author: Ashod Nakashian 
AuthorDate: Sun Aug 16 22:46:33 2020 -0400
Commit: Andras Timar 
CommitDate: Mon Aug 17 13:51:56 2020 +0200

wsd: support read-only systemplate

For various reasons, systemplate may be read-only
or under a different owner and therefore impossible
to update the dynamic files in it.

To support such a scenario, we first link the
eight dynamic files in /etc when creating systemplate.
If this fails, we copy the files.

When creating jails, we always check that all the
dynamic files are up-to-date. If they are, nothing
further is necessary and we bind-mount, if enabled
and possible.

However, if the dynamic files are not up-to-date,
we disable bind-mounting and force linking
the files in the jails. Failing that, we copy them,
which is not ideal, but allows us to ensure the
dynamic files are up-to-date as we copy them too.

Ideally, the dynamic files in question would be
hard-link (or at least soft-linked) in systemplate
at creation. From then on we would bind-mount
the jails and everything would work perfectly and
no files would need updating. This patch is fallback
for when this scheme fails, which should be exceedingly
rare anyway, but which still ensures correct operation.

Change-Id: I09c6f057c49396579aaddb1b8bf4af0930dd4247
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100834
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Andras Timar 

diff --git a/common/FileUtil.cpp b/common/FileUtil.cpp
index 6a61b926e..7f8e767d7 100644
--- a/common/FileUtil.cpp
+++ b/common/FileUtil.cpp
@@ -12,7 +12,9 @@
 #include "FileUtil.hpp"
 
 #include 
+#include 
 #include 
+#include 
 #include 
 #ifdef __linux
 #include 
@@ -89,27 +91,19 @@ namespace FileUtil
 bool copy(const std::string& fromPath, const std::string& toPath, bool 
log, bool throw_on_error)
 {
 int from = -1, to = -1;
-try {
+try
+{
 from = open(fromPath.c_str(), O_RDONLY);
 if (from < 0)
-{
-LOG_SYS("Failed to open src " << anonymizeUrl(fromPath));
-throw;
-}
+throw std::runtime_error("Failed to open src " + 
anonymizeUrl(fromPath));
 
 struct stat st;
 if (fstat(from, &st) != 0)
-{
-LOG_SYS("Failed to fstat src " << anonymizeUrl(fromPath));
-throw;
-}
+throw std::runtime_error("Failed to fstat src " + 
anonymizeUrl(fromPath));
 
 to = open(toPath.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 
st.st_mode);
 if (to < 0)
-{
-LOG_SYS("Failed to fstat dest " << anonymizeUrl(toPath));
-throw;
-}
+throw std::runtime_error("Failed to open dest " + 
anonymizeUrl(toPath));
 
 // Logging may be redundant and/or noisy.
 if (log)
@@ -120,14 +114,14 @@ namespace FileUtil
 
 int n;
 off_t bytesIn = 0;
-do {
+do
+{
 while ((n = ::read(from, buffer, sizeof(buffer))) < 0 && errno 
== EINTR)
 LOG_TRC("EINTR reading from " << anonymizeUrl(fromPath));
 if (n < 0)
-{
-LOG_SYS("Failed to read from " << anonymizeUrl(fromPath) 
<< " at " << bytesIn << " bytes in");
-throw;
-}
+throw std::runtime_error("Failed to read from " + 
anonymizeUrl(fromPath)
+ + " at " + 
std::to_string(bytesIn) + " bytes in");
+
 bytesIn += n;
 if (n == 0) // EOF
 break;
@@ -140,13 +134,14 @@ namespace FileUtil
 LOG_TRC("EINTR writing to " << anonymizeUrl(toPath));
 if (written < 0)
 {
-LOG_SYS("Failed to write " << n << " bytes to " << 
anonymizeUrl(toPath) << " at " <<
-bytesIn << " bytes into " << 
anonymizeUrl(fr

[Libreoffice-commits] online.git: kit/Kit.cpp loolwsd.xml.in wsd/LOOLWSD.cpp wsd/Storage.cpp wsd/Storage.hpp

2020-08-11 Thread Ashod Nakashian (via logerrit)
 kit/Kit.cpp |1 -
 loolwsd.xml.in  |1 +
 wsd/LOOLWSD.cpp |1 +
 wsd/Storage.cpp |8 +++-
 wsd/Storage.hpp |   10 +-
 5 files changed, 18 insertions(+), 3 deletions(-)

New commits:
commit c5f9d605e433701680a533fa20a3390f1e7ff5eb
Author: Ashod Nakashian 
AuthorDate: Thu Jul 16 10:44:41 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Aug 11 20:11:14 2020 +0200

wsd: make outgoing connection timeout configurable

The default Poco connection timeout is 60 seconds,
which is probably excessive. The current configurable
default is a more reasonable 30 seconds.

Currently we set this timeout on Storage connections
going out (i.e. WOPI connections).

Change-Id: Ie80a9141ca9bf721addc74baf94e62e0ad72fdd2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98913
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 2ad1c545a..42af4b531 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index ceb78992e..f1235d618 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -99,6 +99,7 @@
 :::172\.17\.[0-9]{1,3}\.[0-9]{1,3}
   
   
+  
 
 
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3756db0fb..806c22a0d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -928,6 +928,7 @@ void LOOLWSD::initialize(Application& self)
 { "loleaflet_html", "loleaflet.html" },
 { "loleaflet_logging", "false" },
 { "mount_jail_tree", "true" },
+{ "net.connection_timeout_secs", "30" },
 { "net.listen", "any" },
 { "net.proto", "all" },
 { "net.service_root", "" },
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 08a974d0d..9e3854d99 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -422,10 +422,16 @@ Poco::Net::HTTPClientSession* 
StorageBase::getHTTPClientSession(const Poco::URI&
 // We decoupled the Wopi communication from client communication because
 // the Wopi communication must have an independent policy.
 // So, we will use here only Storage settings.
-return useSSL
+Poco::Net::HTTPClientSession* session = useSSL
 ? new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort(),
 
Poco::Net::SSLManager::instance().defaultClientContext())
 : new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
+
+// Set the timeout to the configured value.
+static int timeoutSec = 
LOOLWSD::getConfigValue("net.connection_timeout_secs", 30);
+session->setTimeout(Poco::Timespan(timeoutSec, 0));
+
+return session;
 }
 
 namespace
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index df1b59e5e..652b9bb17 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -17,7 +17,6 @@
 
 #include 
 #include 
-#include 
 #include 
 
 #include "Auth.hpp"
@@ -26,6 +25,15 @@
 #include "Util.hpp"
 #include 
 
+namespace Poco
+{
+namespace Net
+{
+class HTTPClientSession;
+}
+
+} // namespace Poco
+
 /// Represents whether the underlying file is locked
 /// and with what token.
 struct LockContext
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loleaflet/src

2020-08-11 Thread Ashod Nakashian (via logerrit)
 loleaflet/src/core/Socket.js |5 +
 1 file changed, 5 insertions(+)

New commits:
commit b8fd4328afb4e0ed1dc93ecb6a4f8917455ccb5b
Author: Ashod Nakashian 
AuthorDate: Thu Jul 2 14:21:35 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Aug 11 20:05:17 2020 +0200

leaflet: copy the reuse_cookies param from URI to map.options

Change-Id: I1eee6d2cda3809aeeb2de015c7e18b2c14291bf9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97783
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 310dbbd22..fa78bf1a3 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -768,6 +768,11 @@ L.Socket = L.Class.extend({
this._map.options.docParams = {};
}
 
+   var reuseCookies = 
this._getParameterByName(url, 'reuse_cookies');
+   if (reuseCookies !== '') {
+   
this._map.options.docParams['reuse_cookies'] = reuseCookies;
+   }
+
// setup for loading the new document, and 
trigger the load
var docUrl = url.split('?')[0];
this._map.options.doc = docUrl;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/Authorization.cpp common/Util.cpp common/Util.hpp test/WhiteBoxTests.cpp

2020-08-11 Thread Ashod Nakashian (via logerrit)
 common/Authorization.cpp |   33 +++--
 common/Util.cpp  |   34 +-
 common/Util.hpp  |7 +++
 test/WhiteBoxTests.cpp   |   12 
 4 files changed, 55 insertions(+), 31 deletions(-)

New commits:
commit dbc562d9abc997b196fd6d4e5e71f42d442488d0
Author: Ashod Nakashian 
AuthorDate: Sat Jun 20 11:32:09 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Aug 11 20:04:20 2020 +0200

wsd: parse headers with Poco::MessageHeader

Our header parses was overly simplistic and
didn't support a number of corner cases that
rfc2616 specifies (folding, for example). The
new approach is to simply normalize the headers by
removing invalid line-breaks and then let the
MessageHeader parser take care of parsing the
headers individually, which we then set on the request.

The new utility setHttpHeaders should be used
whenever we need to set a header in an request
to make sure it are sanitized and valid.

Change-Id: Ifa16fa9364f42183316749276c5d0a4c556cb740
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96371
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/common/Authorization.cpp b/common/Authorization.cpp
index 93c5704fc..5613aa91a 100644
--- a/common/Authorization.cpp
+++ b/common/Authorization.cpp
@@ -45,42 +45,15 @@ void 
Authorization::authorizeRequest(Poco::Net::HTTPRequest& request) const
 switch (_type)
 {
 case Type::Token:
-request.set("Authorization", "Bearer " + _data);
+Util::setHttpHeaders(request, "Authorization: Bearer " + _data);
+assert(request.has("Authorization") && "HTTPRequest missing 
Authorization header");
 break;
 case Type::Header:
-{
 // there might be more headers in here; like
 //   Authorization: Basic 
 //   X-Something-Custom: Huh
-// Split based on \n's or \r's and trim, to avoid nonsense in the
-// headers
-StringVector tokens(Util::tokenizeAnyOf(_data, "\n\r"));
-for (auto it = tokens.begin(); it != tokens.end(); ++it)
-{
-std::string token = tokens.getParam(*it);
-
-size_t separator = token.find_first_of(':');
-if (separator != std::string::npos)
-{
-size_t headerStart = token.find_first_not_of(' ', 0);
-size_t headerEnd = token.find_last_not_of(' ', separator - 
1);
-
-size_t valueStart = token.find_first_not_of(' ', separator 
+ 1);
-size_t valueEnd = token.find_last_not_of(' ');
-
-// set the header
-if (headerStart != std::string::npos && headerEnd != 
std::string::npos &&
-valueStart != std::string::npos && valueEnd != 
std::string::npos)
-{
-size_t headerLength = headerEnd - headerStart + 1;
-size_t valueLength = valueEnd - valueStart + 1;
-
-request.set(token.substr(headerStart, headerLength), 
token.substr(valueStart, valueLength));
-}
-}
-}
+Util::setHttpHeaders(request, _data);
 break;
-}
 default:
 // assert(false);
 throw BadRequestException("Invalid HTTP request type");
diff --git a/common/Util.cpp b/common/Util.cpp
index e0ce00250..f1cd61b69 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -59,7 +59,7 @@
 #include 
 
 #include "Common.hpp"
-#include "Log.hpp"
+#include 
 #include "Protocol.hpp"
 #include "Util.hpp"
 
@@ -953,6 +953,38 @@ namespace Util
 return std::ctime(&t);
 }
 
+void setHttpHeaders(Poco::Net::HTTPRequest& request, const std::string& 
headers)
+{
+// Look for either \r or \n and replace them with a single \r\n
+// as prescribed by rfc2616 as valid header delimeter, removing
+// any invalid line breaks, to avoid nonsense in the headers.
+const StringVector tokens = Util::tokenizeAnyOf(headers, "\n\r");
+const std::string header = tokens.cat("\r\n", 0);
+try
+{
+// Now parse to preserve folded headers and other
+// corner cases that is conformant to the rfc,
+// detecting any errors and/or invalid entries.
+// NB: request.read() expects full message and will fail.
+Poco::Net::MessageHeader msgHeader;
+std::istringst

[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - common/Rectangle.hpp test/TileCacheTests.cpp wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp wsd/DocumentBroker.

2020-08-11 Thread Ashod Nakashian (via logerrit)
 common/Rectangle.hpp|   60 +++
 test/TileCacheTests.cpp |9 +-
 wsd/ClientSession.cpp   |6 -
 wsd/ClientSession.hpp   |2 
 wsd/DocumentBroker.cpp  |   10 ---
 wsd/DocumentBroker.hpp  |7 +-
 wsd/TileCache.cpp   |  146 
 wsd/TileCache.hpp   |   74 ++--
 wsd/TileDesc.hpp|   19 ++
 9 files changed, 147 insertions(+), 186 deletions(-)

New commits:
commit c7b4e28e385809de15b5a463596e8506be560850
Author: Ashod Nakashian 
AuthorDate: Sun Jul 12 12:25:49 2020 -0400
Commit: Jan Holesovsky 
CommitDate: Tue Aug 11 18:58:00 2020 +0200

wsd: improved TileCache

* Excised TileCacheDesc to improve performance and simplify code.
* clang-tidy suggestions and auto-rewrite fixes.
* Const-correctness.
* Inlined and improved a couple of trivial functions (that are called
often).
* Reduced some logs from INF to DBG as they are only meaningful to devs.

Change-Id: I1c4eb8c63da49aa061afbf3eb68cae23d4d5e7f3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98661
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100505
Tested-by: Jan Holesovsky 
Reviewed-by: Jan Holesovsky 

diff --git a/common/Rectangle.hpp b/common/Rectangle.hpp
index 0869d207f..05099312a 100644
--- a/common/Rectangle.hpp
+++ b/common/Rectangle.hpp
@@ -51,65 +51,29 @@ public:
 _y2 = rectangle._y2;
 }
 
-void setLeft(int x1)
-{
-_x1 = x1;
-}
+void setLeft(int x1) { _x1 = x1; }
 
-int getLeft() const
-{
-return _x1;
-}
+int getLeft() const { return _x1; }
 
-void setRight(int x2)
-{
-_x2 = x2;
-}
+void setRight(int x2) { _x2 = x2; }
 
-int getRight() const
-{
-return _x2;
-}
+int getRight() const { return _x2; }
 
-void setTop(int y1)
-{
-_y1 = y1;
-}
+void setTop(int y1) { _y1 = y1; }
 
-int getTop() const
-{
-return _y1;
-}
+int getTop() const { return _y1; }
 
-void setBottom(int y2)
-{
-_y2 = y2;
-}
+void setBottom(int y2) { _y2 = y2; }
 
-int getBottom() const
-{
-return _y2;
-}
+int getBottom() const { return _y2; }
 
-int getWidth()
-{
-return _x2 - _x1;
-}
+int getWidth() const { return _x2 - _x1; }
 
-int getHeight()
-{
-return _y2 - _y1;
-}
+int getHeight() const { return _y2 - _y1; }
 
-bool isValid()
-{
-return _x1 <= _x2 && _y1 <= _y2;
-}
+bool isValid() const { return _x1 <= _x2 && _y1 <= _y2; }
 
-bool hasSurface()
-{
-return _x1 < _x2 && _y1 < _y2;
-}
+bool hasSurface() const { return _x1 < _x2 && _y1 < _y2; }
 
 bool intersects(const Rectangle& rOther)
 {
diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index 5a14a4c09..a98dcbe21 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -180,11 +180,12 @@ public:
 
 void TileCacheTests::testDesc()
 {
-TileCacheDesc descA = TileDesc(0, 0, 256, 256, 0, 0, 3200, 3200, /* 
ignored in cache */ 0, 1234, 1, true);
-TileCacheDesc descB = TileDesc(0, 0, 256, 256, 0, 0, 3200, 3200, /* 
ignored in cache */ 1, 1235, 2, false);
+TileDesc descA = TileDesc(0, 0, 256, 256, 0, 0, 3200, 3200, /* ignored in 
cache */ 0, 1234, 1, true);
+TileDesc descB = TileDesc(0, 0, 256, 256, 0, 0, 3200, 3200, /* ignored in 
cache */ 1, 1235, 2, false);
 
-LOK_ASSERT_MESSAGE("versions do match", descA.getVersion() != 
descB.getVersion());
-LOK_ASSERT_MESSAGE("Compare includes fields it should not", descA == 
descB);
+TileDescCacheCompareEq pred;
+LOK_ASSERT_MESSAGE("TileDesc versions do match", descA.getVersion() != 
descB.getVersion());
+LOK_ASSERT_MESSAGE("TileDesc should match, ignoring unimportant fields", 
pred(descA, descB));
 }
 
 void TileCacheTests::testSimple()
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 7e9cf8d40..3173154d1 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1663,10 +1663,10 @@ void ClientSession::removeOutdatedTilesOnFly()
 size_t ClientSession::countIdenticalTilesOnFly(const TileDesc& tile) const
 {
 size_t count = 0;
-std::string tileID = tile.generateID();
-for(auto& tileItem : _tilesOnFly)
+const std::string tileID = tile.generateID();
+for (const auto& tileItem : _tilesOnFly)
 {
-if(tileItem.first == tileID)
+if (tileItem.first == tileID)
 ++count;
 }
 return count;
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 810c71156..3982e2c56 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -282,7 +282,7 @

[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - wsd/ClientSession.cpp wsd/TileCache.cpp

2020-08-11 Thread Ashod Nakashian (via logerrit)
 wsd/ClientSession.cpp |2 +-
 wsd/TileCache.cpp |5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

New commits:
commit 4c52584ae14593e8756bcde0b094998238a0ff97
Author: Ashod Nakashian 
AuthorDate: Tue Jun 9 22:24:13 2020 -0400
Commit: Jan Holesovsky 
CommitDate: Tue Aug 11 18:52:13 2020 +0200

wsd: prefer emplace_back where possible

emplace_back avoids copy-construction when
the argument is a temporary instance created
at call-site.

Change-Id: I127fddd308d710af9ea65a86db1b03347e9c3d87
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96829
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100504
Tested-by: Jan Holesovsky 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index a03bf5927..7e9cf8d40 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1632,7 +1632,7 @@ Authorization ClientSession::getAuthorization() const
 
 void ClientSession::addTileOnFly(const TileDesc& tile)
 {
-_tilesOnFly.push_back({tile.generateID(), 
std::chrono::steady_clock::now()});
+_tilesOnFly.emplace_back(tile.generateID(), 
std::chrono::steady_clock::now());
 }
 
 void ClientSession::clearTilesOnFly()
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index 12231a383..4e9773499 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -589,9 +589,8 @@ void TileCache::ensureCacheSize()
 WidSize(TileWireId w, size_t s) : _wid(w), _size(s) {}
 };
 std::vector wids;
-for (auto &it : _cache)
-wids.push_back(WidSize(it.first.getWireId(),
-   itemCacheSize(it.second)));
+for (const auto& it : _cache)
+wids.emplace_back(it.first.getWireId(), itemCacheSize(it.second));
 std::sort(wids.begin(), wids.end(),
   [](const WidSize &a, const WidSize &b) { return a._wid < b._wid; 
});
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/inc desktop/qa desktop/source include/editeng include/sfx2 sc/source sd/qa sd/source sfx2/source sw/qa

2020-08-11 Thread Ashod Nakashian (via logerrit)
 desktop/inc/lib/init.hxx   |3 
 desktop/qa/desktop_lib/test_desktop_lib.cxx|  100 
 desktop/source/lib/init.cxx|   36 ---
 include/editeng/outliner.hxx   |1 
 include/sfx2/lokhelper.hxx |   17 ++-
 include/sfx2/viewsh.hxx|   15 ++-
 sc/source/ui/view/tabvwshc.cxx |3 
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx  |1 
 sd/source/ui/unoidl/unomodel.cxx   |3 
 sfx2/source/view/lokhelper.cxx |  123 +
 sfx2/source/view/viewimp.hxx   |4 
 sfx2/source/view/viewsh.cxx|   13 +-
 sw/qa/extras/tiledrendering/tiledrendering.cxx |2 
 13 files changed, 250 insertions(+), 71 deletions(-)

New commits:
commit 4fd2679a7a2b0494da84f344ab97b835edf73377
Author: Ashod Nakashian 
AuthorDate: Sun Aug 2 14:52:02 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Aug 11 17:34:47 2020 +0200

sfx2: lok: reliably support multi-documents

Instead of using the current view to set
the DocId, we instead make sure that the ShellView
object has the DocId set at construction time.
This turned out to be necessary in at least one
case (which has a unit-test that failed), which
is when events fired during the creation of a
new view. The cursor position is notified
before we have a chance to set the DocId and
because of that we miss the notifications (or
worse, we end up sending them to all other
documents' views in an effort to fix this bug).

This approach is clean and always guarantees that
all views have the correct DocId set as soon as
possible and that all notifications are sent
as expected.

A unit-test is added to exercise mult-document
usage, which exposed a number of bugs and issues
that have been addressed in this patch.

Change-Id: Icf5145fb1dabd0d029368310c2b9bf73ae927ccc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99975
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
Reviewed-by: Ashod Nakashian 

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 237a17a59eee..1a927280e24b 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -151,7 +151,8 @@ namespace desktop {
 std::map> 
mpCallbackFlushHandlers;
 const int mnDocumentId;
 
-explicit LibLODocument_Impl(const css::uno::Reference 
 &xComponent, int nDocumentId = -1);
+explicit LibLODocument_Impl(const 
css::uno::Reference& xComponent,
+int nDocumentId);
 ~LibLODocument_Impl();
 };
 
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 7acb50499ae9..f448965c02d7 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -225,6 +225,7 @@ public:
 void testCalcSaveAs();
 void testControlState();
 void testMetricField();
+void testMultiDocuments();
 void testABI();
 
 CPPUNIT_TEST_SUITE(DesktopLOKTest);
@@ -287,6 +288,7 @@ public:
 CPPUNIT_TEST(testCalcSaveAs);
 CPPUNIT_TEST(testControlState);
 CPPUNIT_TEST(testMetricField);
+CPPUNIT_TEST(testMultiDocuments);
 CPPUNIT_TEST(testABI);
 CPPUNIT_TEST_SUITE_END();
 
@@ -352,10 +354,13 @@ DesktopLOKTest::loadDocUrlImpl(const OUString& rFileURL, 
LibreOfficeKitDocumentT
 break;
 }
 
+static int nDocumentIdCounter = 0;
+SfxViewShell::SetCurrentDocId(ViewShellDocId(nDocumentIdCounter));
 uno::Reference xComponent = loadFromDesktop(rFileURL, 
aService);
 CPPUNIT_ASSERT(xComponent.is());
 
-std::unique_ptr pDocument(new 
LibLODocument_Impl(xComponent));
+std::unique_ptr pDocument(new 
LibLODocument_Impl(xComponent, nDocumentIdCounter));
+++nDocumentIdCounter;
 
 return std::make_pair(std::move(pDocument), xComponent);
 }
@@ -2987,6 +2992,99 @@ void DesktopLOKTest::testSpellcheckerMultiView()
 CPPUNIT_ASSERT_EQUAL(1, 
pDocument->m_pDocumentClass->getViewsCount(pDocument));
 }
 
+void DesktopLOKTest::testMultiDocuments()
+{
+// Load a document.
+uno::Reference xComponent1;
+std::unique_ptr document1;
+std::tie(document1, xComponent1) = loadDocImpl("blank_text.odt");
+LibLODocument_Impl* pDocument1 = document1.get();
+CPPUNIT_ASSERT_EQUAL(1, 
pDocument1->m_pDocumentClass->getViewsCount(pDocument1));
+const int nDocId1 = pDocument1->mnDocumentId;
+
+const int nDoc1View0 = pDocument1->m_pDocumentClass->getView(pDocument1);
+CPPUNIT_ASSERT_EQUAL(nDocId1, 
SfxLokHelper::getDocumentIdOfView(nDoc1View0));
+const int nDoc1View1 = 
pDocument1->m_pDocumentClass->createView(pDocument1);
+CPPUNIT_ASSERT_EQUAL(nDoc1View1, 
pDocument1->m_pDo

[Libreoffice-commits] online.git: wsd/TileCache.cpp wsd/TileDesc.hpp

2020-08-10 Thread Ashod Nakashian (via logerrit)
 wsd/TileCache.cpp |2 +-
 wsd/TileDesc.hpp  |   12 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 999df3fffb9c100a86acd200fdc9066203a13553
Author: Ashod Nakashian 
AuthorDate: Sun Aug 9 17:55:56 2020 -0400
Commit: Michael Meeks 
CommitDate: Mon Aug 10 16:00:27 2020 +0200

wsd: hashmaps have better data locality

They are especially efficient for small lookups.

Change-Id: Ia005f40127cf222debe185515fc45cd92b8ae752
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100413
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index 982cd985b..d36ca1aa6 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -552,7 +552,7 @@ void TileCache::saveDataToCache(const TileDesc &desc, const 
char *data, const si
 
 TileCache::Tile tile = std::make_shared>(size);
 std::memcpy(tile->data(), data, size);
-auto res = _cache.insert(std::make_pair(desc, tile));
+auto res = _cache.emplace(desc, tile);
 if (!res.second)
 {
 _cacheSize -= itemCacheSize(res.first->second);
diff --git a/wsd/TileDesc.hpp b/wsd/TileDesc.hpp
index 28ecc4256..e60984359 100644
--- a/wsd/TileDesc.hpp
+++ b/wsd/TileDesc.hpp
@@ -10,7 +10,7 @@
 #pragma once
 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -24,7 +24,7 @@ using TileBinaryHash = uint64_t;
 
 /// Tile Descriptor
 /// Represents a tile's coordinates and dimensions.
-class TileDesc
+class TileDesc final
 {
 public:
 TileDesc(int normalizedViewId, int part, int width, int height, int 
tilePosX, int tilePosY, int tileWidth,
@@ -206,7 +206,7 @@ public:
 {
 // We don't expect undocumented fields and
 // assume all values to be int.
-std::map pairs;
+std::unordered_map pairs(16);
 
 // Optional.
 pairs["ver"] = -1;
@@ -261,7 +261,7 @@ public:
 return tileID.str();
 }
 
-protected:
+private:
 int _normalizedViewId;
 int _part;
 int _width;
@@ -281,7 +281,7 @@ protected:
 /// One or more tile header.
 /// Used to request the rendering of multiple
 /// tiles as well as the header of the response.
-class TileCombined
+class TileCombined final
 {
 private:
 TileCombined(int normalizedViewId, int part, int width, int height,
@@ -465,7 +465,7 @@ public:
 {
 // We don't expect undocumented fields and
 // assume all values to be int.
-std::map pairs;
+std::unordered_map pairs(16);
 
 std::string tilePositionsX;
 std::string tilePositionsY;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/qa

2020-08-09 Thread Ashod Nakashian (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |  112 +---
 1 file changed, 86 insertions(+), 26 deletions(-)

New commits:
commit 347e0d5336ccd881356c89ecc5d8186dd9b773ad
Author: Ashod Nakashian 
AuthorDate: Sun Aug 2 12:41:19 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Mon Aug 10 04:50:20 2020 +0200

DesktopLOKTest: cleanup

Refactor the handling of document loading
and unloading and cleanup to allow more flexibility
when loading multiple documents and for manual
destruction.

Also, correctly set the document type when loading,
which was defaulted to TEXT even when loading
spreadsheet and presentation documents.

Minor misc cleanup such as dangling semicolons and
unregistering the callback twice.

Change-Id: Ia244aafd526d60f73c46e99fb8c7e63f63b0a8f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99974
Tested-by: Jenkins CollaboraOffice 
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 0123037ec75d..864041b71d49 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -59,9 +59,34 @@
 #include 
 #include 
 
+#include 
+
 using namespace com::sun::star;
 using namespace desktop;
 
+static LibreOfficeKitDocumentType getDocumentTypeFromName(const char* pName)
+{
+CPPUNIT_ASSERT_MESSAGE("Document name must be valid.", pName != nullptr);
+
+const std::string name(pName);
+CPPUNIT_ASSERT_MESSAGE("Document name must include extension.", 
name.size() > 4);
+
+const auto it = name.rfind('.');
+if (it != name.npos)
+{
+const std::string ext = name.substr(it);
+
+if (ext == ".ods")
+return LOK_DOCTYPE_SPREADSHEET;
+
+if (ext == ".odp")
+return LOK_DOCTYPE_PRESENTATION;
+}
+
+CPPUNIT_ASSERT_MESSAGE("Document name must include extension.", it != 
name.npos);
+return LOK_DOCTYPE_TEXT;
+}
+
 class DesktopLOKTest : public UnoApiTest
 {
 class Resetter
@@ -106,22 +131,39 @@ public:
 UnoApiTest::setUp();
 
mxDesktop.set(frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory(;
 SfxApplication::GetOrCreate();
-};
+}
 
 virtual void tearDown() override
 {
-if (m_pDocument)
-m_pDocument->pClass->registerCallback(m_pDocument.get(), nullptr, 
nullptr);
 closeDoc();
 
 UnoApiTest::tearDown();
 
 comphelper::LibreOfficeKit::setActive(false);
-};
+}
+
+std::pair, 
uno::Reference>
+loadDocImpl(const char* pName, LibreOfficeKitDocumentType eType);
+
+std::pair, 
uno::Reference>
+loadDocImpl(const char* pName)
+{
+return loadDocImpl(pName, getDocumentTypeFromName(pName));
+}
+
+std::pair, 
uno::Reference>
+loadDocUrlImpl(const OUString& rFileURL, LibreOfficeKitDocumentType eType);
 
 LibLODocument_Impl* loadDocUrl(const OUString& rFileURL, 
LibreOfficeKitDocumentType eType);
-LibLODocument_Impl* loadDoc(const char* pName, LibreOfficeKitDocumentType 
eType = LOK_DOCTYPE_TEXT);
-void closeDoc();
+LibLODocument_Impl* loadDoc(const char* pName, LibreOfficeKitDocumentType 
eType);
+LibLODocument_Impl* loadDoc(const char* pName)
+{
+return loadDoc(pName, getDocumentTypeFromName(pName));
+}
+
+void closeDoc(std::unique_ptr& loDocument,
+  uno::Reference& xComponent);
+void closeDoc() { closeDoc(m_pDocument, mxComponent); }
 static void callback(int nType, const char* pPayload, void* pData);
 void callbackImpl(int nType, const char* pPayload);
 
@@ -287,7 +329,8 @@ static Control* GetFocusControl(vcl::Window const * pParent)
 return nullptr;
 }
 
-LibLODocument_Impl* DesktopLOKTest::loadDocUrl(const OUString& rFileURL, 
LibreOfficeKitDocumentType eType)
+std::pair, 
uno::Reference>
+DesktopLOKTest::loadDocUrlImpl(const OUString& rFileURL, 
LibreOfficeKitDocumentType eType)
 {
 OUString aService;
 switch (eType)
@@ -305,28 +348,48 @@ LibLODocument_Impl* DesktopLOKTest::loadDocUrl(const 
OUString& rFileURL, LibreOf
 CPPUNIT_ASSERT(false);
 break;
 }
-mxComponent = loadFromDesktop(rFileURL, aService);
-if (!mxComponent.is())
-{
-CPPUNIT_ASSERT(false);
-}
-m_pDocument.reset(new LibLODocument_Impl(mxComponent));
-return m_pDocument.get();
+
+uno::Reference xComponent = loadFromDesktop(rFileURL, 
aService);
+CPPUNIT_ASSERT(xComponent.is());
+
+std::unique_ptr pDocument(new 
LibLODocument_Impl(xComponent));
+
+return std::make_pair(std::move(pDocument), xComponent);
 }
 
-LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, 
LibreOfficeKitDocumentType eType)
+std::pair, 
uno::Reference&

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sc/qa sd/qa sw/qa

2020-08-09 Thread Ashod Nakashian (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |2 
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |2 
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   69 -
 3 files changed, 37 insertions(+), 36 deletions(-)

New commits:
commit afaed0b1141d67c36ff0714be5d7eb2825a79bdd
Author: Ashod Nakashian 
AuthorDate: Sat Aug 1 16:09:00 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Mon Aug 10 04:49:44 2020 +0200

lok: minor cleanup of ViewCallback in tiledrendering tests

Change-Id: I39b964a7aa7d181083a153283f38c1a5bc64de58
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99973
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 625f506bfe50..4962ebc5fb68 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -450,7 +450,7 @@ void ScTiledRenderingTest::testEmptyColumnSelection()
 }
 
 /// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback
+class ViewCallback final
 {
 SfxViewShell* mpViewShell;
 int mnView;
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index a3dddaa78bb2..b6090961ebb7 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -838,7 +838,7 @@ void SdTiledRenderingTest::testResizeTableColumn()
 }
 
 /// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback
+class ViewCallback final
 {
 SfxViewShell* mpViewShell;
 int mnView;
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 7cb4978be44c..4b4f00887a74 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -752,7 +752,7 @@ void SwTiledRenderingTest::testPartHash()
 }
 
 /// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback
+class ViewCallback final
 {
 SfxViewShell* mpViewShell;
 int mnView;
@@ -780,7 +780,7 @@ public:
 /// Post-it / annotation payload.
 boost::property_tree::ptree m_aComment;
 
-ViewCallback(SfxViewShell* pViewShell, std::function 
const & rBeforeInstallFunc = {})
+ViewCallback(SfxViewShell* pViewShell = nullptr, 
std::function const & rBeforeInstallFunc = {})
 : m_bOwnCursorInvalidated(false),
   m_nOwnCursorInvalidatedBy(-1),
   m_bOwnCursorAtOrigin(false),
@@ -798,7 +798,7 @@ public:
 if (rBeforeInstallFunc)
 rBeforeInstallFunc(*this);
 
-mpViewShell = pViewShell;
+mpViewShell = pViewShell ? pViewShell : SfxViewShell::Current();
 
mpViewShell->registerLibreOfficeKitViewCallback(&ViewCallback::callback, this);
 mnView = SfxLokHelper::getView();
 }
@@ -966,10 +966,10 @@ void SwTiledRenderingTest::testMissingInvalidation()
 
 // Create two views.
 SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-ViewCallback aView1(SfxViewShell::Current());
+ViewCallback aView1;
 int nView1 = SfxLokHelper::getView();
 SfxLokHelper::createView();
-ViewCallback aView2(SfxViewShell::Current());
+ViewCallback aView2;
 int nView2 = SfxLokHelper::getView();
 
 // First view: put the cursor into the first word.
@@ -999,9 +999,10 @@ void SwTiledRenderingTest::testViewCursors()
 comphelper::LibreOfficeKit::setActive();
 
 SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
-ViewCallback aView1(SfxViewShell::Current());
+ViewCallback aView1;
 SfxLokHelper::createView();
-ViewCallback aView2(SfxViewShell::Current());
+ViewCallback aView2;
+
 CPPUNIT_ASSERT(aView1.m_bOwnCursorInvalidated);
 CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
 CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
@@ -1037,10 +1038,10 @@ void SwTiledRenderingTest::testShapeViewCursors()
 
 // Load a document and create a view, so we have 2 ones.
 SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
-ViewCallback aView1(SfxViewShell::Current());
+ViewCallback aView1;
 SfxLokHelper::createView();
 
pXTextDocument->initializeForTiledRendering(uno::Sequence());
-ViewCallback aView2(SfxViewShell::Current());
+ViewCallback aView2;
 SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
 
 // Start shape text in the second view.
@@ -1076,10 +1077,10 @@ void SwTiledRenderingTest::testViewCursorVisibility()
 
 // Load a document that has a shape and create two views.
 SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
-ViewCallback aView1(SfxViewShell::Current());
+ViewCallback aView1;
 SfxLokHelper::createView();
 
pXTextDocument->initializeForTil

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sfx2/source

2020-08-09 Thread Ashod Nakashian (via logerrit)
 sfx2/source/view/viewsh.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 02cde0be4fec9f4c77f535e5053888ef1e37fad6
Author: Ashod Nakashian 
AuthorDate: Sat Jul 25 16:51:47 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Mon Aug 10 04:44:41 2020 +0200

sfx2: lok: more informative warning

Include the LOK callback even type as readable name
instead of its numeric ID.

Change-Id: I7865ae24878124b850468bcaa630ca444f4b2a96
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99971
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 978c1cca5d20..b9abc8833573 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1496,7 +1496,7 @@ void SfxViewShell::libreOfficeKitViewCallback(int nType, 
const char* pPayload) c
 SAL_WARN(
 "sfx.view",
 "SfxViewShell::libreOfficeKitViewCallback no callback set! Dropped 
payload of type "
-<< nType << ": [" << pPayload << ']');
+<< lokCallbackTypeToString(nType) << ": [" << pPayload << ']');
 }
 
 void SfxViewShell::afterCallbackRegistered()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/source include/sfx2 sfx2/source sw/source

2020-08-09 Thread Ashod Nakashian (via logerrit)
 desktop/source/lib/init.cxx|4 +-
 include/sfx2/lokhelper.hxx |   17 +++---
 sfx2/source/view/lokhelper.cxx |   69 -
 sw/source/core/crsr/crsrsh.cxx |2 -
 4 files changed, 56 insertions(+), 36 deletions(-)

New commits:
commit b7b81c68dc406cfa16d959f22417a3c3ed7888d5
Author: Ashod Nakashian 
AuthorDate: Fri Jul 24 11:33:46 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Mon Aug 10 04:45:07 2020 +0200

sfx2: lok: refactor notifications and const correctness

This reduces the stringification and reuses the notificaiton
helpers to reduce code duplication.

Change-Id: Icf9f9c50f361a0ded741d39fed37cfcc8da1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99972
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 89269803af04..906d3c4c6baa 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2169,7 +2169,7 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 LibLibreOffice_Impl* pLib = static_cast(pThis);
 pLib->maLastExceptionMsg.clear();
 
-OUString aURL(getAbsoluteURL(pURL));
+const OUString aURL(getAbsoluteURL(pURL));
 if (aURL.isEmpty())
 {
 pLib->maLastExceptionMsg = "Filename to load was not provided.";
@@ -2264,7 +2264,7 @@ static LibreOfficeKitDocument* 
lo_documentLoadWithOptions(LibreOfficeKit* pThis,
 
 LibLODocument_Impl* pDocument = new LibLODocument_Impl(xComponent, 
nDocumentIdCounter++);
 
-// Do we know that after loading the document, its initial view is the 
"current" view?
+// After loading the document, its initial view is the "current" view.
 SfxLokHelper::setDocumentIdOfView(pDocument->mnDocumentId);
 if (pLib->mpCallback)
 {
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 57aee1bb3a5d..e3c75b4191c3 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -51,7 +51,7 @@ public:
 /// Set a view shell as current one.
 static void setView(int nId);
 /// Get the currently active view.
-static int getView(SfxViewShell* pViewShell = nullptr);
+static int getView(const SfxViewShell* pViewShell = nullptr);
 /// Get the number of views of the current object shell.
 static std::size_t getViewsCount();
 /// Get viewIds of views of the current object shell.
@@ -72,17 +72,24 @@ public:
 static LOKDeviceFormFactor getDeviceFormFactor();
 /// Set the device form factor that should be used for a new view.
 static void setDeviceFormFactor(const OUString& rDeviceFormFactor);
+
 /// Iterate over any view shell, except pThisViewShell, passing it to the 
f function.
 template
 static void forEachOtherView(ViewShellType* pThisViewShell, FunctionType 
f);
+
 /// Invoke the LOK callback of all other views showing the same document 
as pThisView, with a payload of rKey-rPayload.
-static void notifyOtherViews(SfxViewShell* pThisView, int nType, const 
OString& rKey, const OString& rPayload);
+static void notifyOtherViews(const SfxViewShell* pThisView, int nType, 
const OString& rKey,
+ const OString& rPayload);
 /// Invoke the LOK callback of all views except pThisView, with a JSON 
payload created from the given property tree.
-static void notifyOtherViews(SfxViewShell* pThisView, int nType, const 
boost::property_tree::ptree& rTree);
+static void notifyOtherViews(const SfxViewShell* pThisView, int nType,
+ const boost::property_tree::ptree& rTree);
 /// Same as notifyOtherViews(), but works on a selected "other" view, not 
on all of them.
-static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* 
pOtherView, int nType, const OString& rKey, const OString& rPayload);
+static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell 
const* pOtherView,
+int nType, const OString& rKey, const OString& 
rPayload);
 /// Same as notifyOtherViews(), the property-tree version, but works on a 
selected "other" view, not on all of them.
-static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* 
pOtherView, int nType, const boost::property_tree::ptree& rTree);
+static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell 
const* pOtherView,
+int nType, const boost::property_tree::ptree& 
rTree);
+
 /// Emits a LOK_CALLBACK_STATE_CHANGED
 static void sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* 
pItem);
 /// Emits a LOK_CALLBACK_WINDOW
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 03241d06

[Libreoffice-commits] online.git: common/Rectangle.hpp test/TileCacheTests.cpp wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/TileCache.cpp wsd/TileCache

2020-07-14 Thread Ashod Nakashian (via logerrit)
 common/Rectangle.hpp|   60 +++
 test/TileCacheTests.cpp |9 +-
 wsd/ClientSession.cpp   |6 -
 wsd/ClientSession.hpp   |2 
 wsd/DocumentBroker.cpp  |   10 ---
 wsd/DocumentBroker.hpp  |7 +-
 wsd/TileCache.cpp   |  146 
 wsd/TileCache.hpp   |   74 ++--
 wsd/TileDesc.hpp|   19 ++
 9 files changed, 147 insertions(+), 186 deletions(-)

New commits:
commit aba09e165b64be795ff21eaa6e23b292bd3f23ff
Author: Ashod Nakashian 
AuthorDate: Sun Jul 12 12:25:49 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jul 14 15:35:20 2020 +0200

wsd: improved TileCache

* Excised TileCacheDesc to improve performance and simplify code.
* clang-tidy suggestions and auto-rewrite fixes.
* Const-correctness.
* Inlined and improved a couple of trivial functions (that are called
often).
* Reduced some logs from INF to DBG as they are only meaningful to devs.

Change-Id: I1c4eb8c63da49aa061afbf3eb68cae23d4d5e7f3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98661
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/common/Rectangle.hpp b/common/Rectangle.hpp
index 0869d207f..05099312a 100644
--- a/common/Rectangle.hpp
+++ b/common/Rectangle.hpp
@@ -51,65 +51,29 @@ public:
 _y2 = rectangle._y2;
 }
 
-void setLeft(int x1)
-{
-_x1 = x1;
-}
+void setLeft(int x1) { _x1 = x1; }
 
-int getLeft() const
-{
-return _x1;
-}
+int getLeft() const { return _x1; }
 
-void setRight(int x2)
-{
-_x2 = x2;
-}
+void setRight(int x2) { _x2 = x2; }
 
-int getRight() const
-{
-return _x2;
-}
+int getRight() const { return _x2; }
 
-void setTop(int y1)
-{
-_y1 = y1;
-}
+void setTop(int y1) { _y1 = y1; }
 
-int getTop() const
-{
-return _y1;
-}
+int getTop() const { return _y1; }
 
-void setBottom(int y2)
-{
-_y2 = y2;
-}
+void setBottom(int y2) { _y2 = y2; }
 
-int getBottom() const
-{
-return _y2;
-}
+int getBottom() const { return _y2; }
 
-int getWidth()
-{
-return _x2 - _x1;
-}
+int getWidth() const { return _x2 - _x1; }
 
-int getHeight()
-{
-return _y2 - _y1;
-}
+int getHeight() const { return _y2 - _y1; }
 
-bool isValid()
-{
-return _x1 <= _x2 && _y1 <= _y2;
-}
+bool isValid() const { return _x1 <= _x2 && _y1 <= _y2; }
 
-bool hasSurface()
-{
-return _x1 < _x2 && _y1 < _y2;
-}
+bool hasSurface() const { return _x1 < _x2 && _y1 < _y2; }
 
 bool intersects(const Rectangle& rOther)
 {
diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index 5a14a4c09..a98dcbe21 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -180,11 +180,12 @@ public:
 
 void TileCacheTests::testDesc()
 {
-TileCacheDesc descA = TileDesc(0, 0, 256, 256, 0, 0, 3200, 3200, /* 
ignored in cache */ 0, 1234, 1, true);
-TileCacheDesc descB = TileDesc(0, 0, 256, 256, 0, 0, 3200, 3200, /* 
ignored in cache */ 1, 1235, 2, false);
+TileDesc descA = TileDesc(0, 0, 256, 256, 0, 0, 3200, 3200, /* ignored in 
cache */ 0, 1234, 1, true);
+TileDesc descB = TileDesc(0, 0, 256, 256, 0, 0, 3200, 3200, /* ignored in 
cache */ 1, 1235, 2, false);
 
-LOK_ASSERT_MESSAGE("versions do match", descA.getVersion() != 
descB.getVersion());
-LOK_ASSERT_MESSAGE("Compare includes fields it should not", descA == 
descB);
+TileDescCacheCompareEq pred;
+LOK_ASSERT_MESSAGE("TileDesc versions do match", descA.getVersion() != 
descB.getVersion());
+LOK_ASSERT_MESSAGE("TileDesc should match, ignoring unimportant fields", 
pred(descA, descB));
 }
 
 void TileCacheTests::testSimple()
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 76e93fa33..293fff67d 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1615,10 +1615,10 @@ void ClientSession::removeOutdatedTilesOnFly()
 size_t ClientSession::countIdenticalTilesOnFly(const TileDesc& tile) const
 {
 size_t count = 0;
-std::string tileID = tile.generateID();
-for(auto& tileItem : _tilesOnFly)
+const std::string tileID = tile.generateID();
+for (const auto& tileItem : _tilesOnFly)
 {
-if(tileItem.first == tileID)
+if (tileItem.first == tileID)
 ++count;
 }
 return count;
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 6304cd4a9..9802e889c 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -297,7 +297,7 @@ private:
 std::string _clipboardKeys[2];
 
 /// TileID's of the sent tiles. Push by sending and pop by tileprocessed 

[Libreoffice-commits] online.git: common/FileUtil.cpp common/FileUtil.hpp common/JailUtil.cpp loolwsd-systemplate-setup

2020-07-07 Thread Ashod Nakashian (via logerrit)
 common/FileUtil.cpp   |  119 ++
 common/FileUtil.hpp   |   47 +-
 common/JailUtil.cpp   |   88 +-
 loolwsd-systemplate-setup |   12 +---
 4 files changed, 195 insertions(+), 71 deletions(-)

New commits:
commit d6259d6a54e0e7873b2f4eb844c75bf0003245c6
Author: Ashod Nakashian 
AuthorDate: Thu Jul 2 17:54:28 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jul 7 19:05:23 2020 +0200

wsd: support parallel systemplate setup

When tests are run in parallel, they will all
compete to update and set up the systemplate
directory, which has a handful of files that
need to be up-to-date. This is a source of errors.

Normally, these files are linked (hard- or soft-
link, whichever succeeds). With linking, we
only need to worry about the initial setup,
as the files will never be out-of-date from
then on. However, when linking fails, we need
to copy the files, and update them (by copying
over fresh versions of the files, if necessary)
every time a new kit is forked. Copying over
is tricky, as it's not atomic. To make it
atomic, we copy the files to the destination
directory under a temporary (random) name,
and then rename to the final name (which is
atomic, including replacing the target file,
if it exists).

No such race exists in production, where there
is (or should be) but one instance of loolwsd
(which does the initial setup) and forkit
(which updates systemplate before forking
new kit instances).
This is an issue with parallel tests only.

Change-Id: I6ba1514d00a84da7397d28efeb6378619711d52f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97785
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/common/FileUtil.cpp b/common/FileUtil.cpp
index 560a1b659..1f31e536d 100644
--- a/common/FileUtil.cpp
+++ b/common/FileUtil.cpp
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 #ifdef __linux
 #include 
 #elif defined IOS
@@ -85,7 +86,7 @@ namespace FileUtil
 return name;
 }
 
-void copyFileTo(const std::string &fromPath, const std::string &toPath)
+bool copy(const std::string& fromPath, const std::string& toPath, bool 
log, bool throw_on_error)
 {
 int from = -1, to = -1;
 try {
@@ -110,7 +111,10 @@ namespace FileUtil
 throw;
 }
 
-LOG_INF("Copying " << st.st_size << " bytes from " << 
anonymizeUrl(fromPath) << " to " << anonymizeUrl(toPath));
+// Logging may be redundant and/or noisy.
+if (log)
+LOG_INF("Copying " << st.st_size << " bytes from " << 
anonymizeUrl(fromPath)
+   << " to " << anonymizeUrl(toPath));
 
 char buffer[64 * 1024];
 
@@ -150,15 +154,24 @@ namespace FileUtil
 }
 close(from);
 close(to);
+return true;
 }
 catch (...)
 {
-LOG_SYS("Failed to copy from " << anonymizeUrl(fromPath) << " to " 
<< anonymizeUrl(toPath));
+std::ostringstream oss;
+oss << "Failed to copy from " << anonymizeUrl(fromPath) << " to "
+<< anonymizeUrl(toPath);
+const std::string err = oss.str();
+
+LOG_SYS(err);
 close(from);
 close(to);
 unlink(toPath.c_str());
-throw Poco::Exception("failed to copy");
+if (throw_on_error)
+throw Poco::Exception(err);
 }
+
+return false;
 }
 
 std::string getTempFilePath(const std::string& srcDir, const std::string& 
srcFilename, const std::string& dstFilenamePrefix)
@@ -252,6 +265,69 @@ namespace FileUtil
 return path;
 }
 
+bool isEmptyDirectory(const char* path)
+{
+DIR* dir = opendir(path);
+if (dir == nullptr)
+return errno != EACCES; // Assume it's not empty when EACCES.
+
+int count = 0;
+while (readdir(dir) && ++count < 3)
+;
+
+closedir(dir);
+return count <= 2; // Discounting . and ..
+}
+
+bool updateTimestamps(const std::string& filename, timespec tsAccess, 
timespec tsModified)
+{
+// The timestamp is in seconds and microseconds.
+timeval timestamps[2]{ { tsAccess.tv_sec, tsAccess.tv_nsec / 1000 },
+   { tsModified.tv_sec, tsModified.tv_nsec / 1000 
} };
+if (utimes(filename.c_str(), timestamps) != 0)
+{
+LOG_SYS("Failed to upda

[Libreoffice-commits] online.git: common/FileUtil.cpp common/FileUtil.hpp common/JailUtil.cpp gtk/mobile.cpp kit/Kit.cpp

2020-07-06 Thread Ashod Nakashian (via logerrit)
 common/FileUtil.cpp |   14 ++
 common/FileUtil.hpp |7 +++
 common/JailUtil.cpp |   10 +++---
 gtk/mobile.cpp  |2 +-
 kit/Kit.cpp |7 +++
 5 files changed, 28 insertions(+), 12 deletions(-)

New commits:
commit 9f7f6dca6ab13a671228a07547c16fbed8cfc0a7
Author: Ashod Nakashian 
AuthorDate: Sun Jul 5 17:51:02 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Mon Jul 6 13:54:54 2020 +0200

wsd: cleanup realpath call

The new utility is safer and more readable.

Change-Id: I3a86675378d458cb004e5534dbf2b401936d0e57
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98183
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/common/FileUtil.cpp b/common/FileUtil.cpp
index ac980b5f3..560a1b659 100644
--- a/common/FileUtil.cpp
+++ b/common/FileUtil.cpp
@@ -238,6 +238,20 @@ namespace FileUtil
 #endif
 }
 
+std::string realpath(const char* path)
+{
+char* resolved = ::realpath(path, nullptr);
+if (resolved)
+{
+std::string real = resolved;
+free(resolved);
+return real;
+}
+
+LOG_SYS("Failed to get the realpath of [" << path << "]");
+return path;
+}
+
 } // namespace FileUtil
 
 namespace
diff --git a/common/FileUtil.hpp b/common/FileUtil.hpp
index 1ef60a843..79342a46d 100644
--- a/common/FileUtil.hpp
+++ b/common/FileUtil.hpp
@@ -89,6 +89,13 @@ namespace FileUtil
 /// Link source to target, and copy if linking fails.
 bool linkOrCopyFile(const char* source, const char* target);
 
+/// Returns the realpath(3) of the provided path.
+std::string realpath(const char* path);
+inline std::string realpath(const std::string& path)
+{
+return realpath(path.c_str());
+}
+
 /// File/Directory stat helper.
 class Stat
 {
diff --git a/common/JailUtil.cpp b/common/JailUtil.cpp
index 95927c476..a104b91b1 100644
--- a/common/JailUtil.cpp
+++ b/common/JailUtil.cpp
@@ -312,13 +312,9 @@ void setupLoSymlink(const std::string& sysTemplate, const 
std::string& loTemplat
 symlinkPathToJail(sysTemplate, loTemplate, loSubPath);
 
 // Font paths can end up as realpaths so match that too.
-char* resolved = realpath(loTemplate.c_str(), nullptr);
-if (resolved)
-{
-if (strcmp(loTemplate.c_str(), resolved) != 0)
-symlinkPathToJail(sysTemplate, std::string(resolved), loSubPath);
-free(resolved);
-}
+const std::string resolved = FileUtil::realpath(loTemplate);
+if (loTemplate != resolved)
+symlinkPathToJail(sysTemplate, resolved, loSubPath);
 }
 
 void setupRandomDeviceLink(const std::string& sysTemplate, const std::string& 
name)
diff --git a/gtk/mobile.cpp b/gtk/mobile.cpp
index 929e07d17..e467a71c2 100644
--- a/gtk/mobile.cpp
+++ b/gtk/mobile.cpp
@@ -324,7 +324,7 @@ int main(int argc, char* argv[])
 
 gtk_container_add(GTK_CONTAINER(mainWindow), GTK_WIDGET(webView));
 
-fileURL = "file://" + std::string(realpath(argv[1], nullptr));
+fileURL = "file://" + FileUtil::realpath(argv[1]);
 
 std::string urlAndQuery =
 "file://" TOPSRCDIR "/loleaflet/dist/loleaflet.html"
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 5eefa30f9..d14a28a81 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -338,13 +338,12 @@ namespace
 const Path& destination,
 LinkOrCopyType type)
 {
-char* resolved = realpath(source.c_str(), nullptr);
-if (resolved && resolved != source)
+std::string resolved = FileUtil::realpath(source);
+if (resolved != source)
 {
 LOG_DBG("linkOrCopy: Using real path [" << resolved << "] instead 
of original link ["
 << source << "].");
-source = resolved;
-free(resolved);
+source = std::move(resolved);
 }
 
 LOG_INF("linkOrCopy " << linkOrCopyTypeString(type) << " from [" << 
source << "] to ["
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Makefile.am

2020-07-06 Thread Ashod Nakashian (via logerrit)
 Makefile.am |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 71a9d21d3e4d99739663aab133a4a0379aef91fe
Author: Ashod Nakashian 
AuthorDate: Sun Jul 5 22:45:48 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Mon Jul 6 13:47:27 2020 +0200

make: don't clean compile_commands.json

Since this file is only created manually,
it shouldn't be removed automatically.

Change-Id: I8d26b7bfc7f7cd899318b2edd3e5ef9bd462cc99
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98184
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/Makefile.am b/Makefile.am
index 2f6761771..ce77b2926 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -361,7 +361,6 @@ clean-local:
$(CLEANUP_COMMAND)
if test "z@JAILS_PATH@" != "z"; then rm -rf "@JAILS_PATH@"; fi
if test "z@SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@"; 
fi
-   rm -f $(abs_srcdir)/compile_commands.json
 
 run: all @JAILS_PATH@
@echo "Launching loolwsd"
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Makefile.am

2020-07-02 Thread Ashod Nakashian (via logerrit)
 Makefile.am |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 9041f14f00d5a111877caac0ae1d476f8c6034c5
Author: Ashod Nakashian 
AuthorDate: Thu Jul 2 14:17:37 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Fri Jul 3 02:03:39 2020 +0200

make: cleanup before removing loolwsd binary

Change-Id: I28dbb165a716646ce5e423e28980ba41ca81d18f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97782
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/Makefile.am b/Makefile.am
index 074f05376..f6dfcfb3d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -349,6 +349,13 @@ $(SYSTEM_STAMP): ${top_srcdir}/loolwsd-systemplate-setup 
loolwsd caps_bins
$(CLEANUP_COMMAND)
mkdir -p $@
 
+cleanup:
+   $(CLEANUP_COMMAND)
+
+# Always cleanup before removing the binaries.
+# Note: this can break with -j option!
+clean-am: cleanup clean-binPROGRAMS clean-generic clean-libtool clean-local 
clean-noinstPROGRAMS mostlyclean-am
+
 clean-local:
$(CLEANUP_COMMAND)
if test "z@JAILS_PATH@" != "z"; then rm -rf "@JAILS_PATH@"; fi
@@ -473,7 +480,7 @@ endif
 # installing. When building for packaging, no need for this, as the
 # capabilities won't survive packaging anyway. Instead, handle it when
 # installing the RPM or Debian package.
-.PHONY: caps_bins
+.PHONY: caps_bins cleanup
 
 all-local: loolwsd caps_bins @JAILS_PATH@ $(SYSTEM_STAMP)
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/MessageQueue.cpp

2020-07-02 Thread Ashod Nakashian (via logerrit)
 common/MessageQueue.cpp |  342 +---
 1 file changed, 184 insertions(+), 158 deletions(-)

New commits:
commit 39d34cbab4715ba10d5bab10c82746cb4605baca
Author: Ashod Nakashian 
AuthorDate: Tue Jun 2 23:16:47 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Jul 2 21:49:31 2020 +0200

wsd: match LOK callback type as integer

String comparisons are costly and much
less readable. Now we have a fast switch
with LOK_CALLBACK enum values.

Change-Id: Icc24b91b174cd9bbb7e0d64039df080c0a4338f2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96375
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/common/MessageQueue.cpp b/common/MessageQueue.cpp
index 064a27717..f239a2e9c 100644
--- a/common/MessageQueue.cpp
+++ b/common/MessageQueue.cpp
@@ -192,207 +192,233 @@ std::string TileQueue::removeCallbackDuplicate(const 
std::string& callbackMsg)
 return std::string();
 
 // the message is "callback   ..."
-const std::string& callbackType = tokens[2];
-
-// FIXME: Good grief, why don't we use the symbolic LOK_CALLBACK_FOO names 
here? Doing it this
-// way is somewhat fragile and certainly bad style.
-if (callbackType == "0")// invalidation
-{
-int msgX, msgY, msgW, msgH, msgPart;
-
-if (!extractRectangle(tokens, msgX, msgY, msgW, msgH, msgPart))
-return std::string();
+const auto pair = Util::i32FromString(tokens[2]);
+if (!pair.second)
+return std::string();
 
-bool performedMerge = false;
+const auto callbackType = 
static_cast(pair.first);
 
-// we always travel the entire queue
-size_t i = 0;
-while (i < getQueue().size())
+switch (callbackType)
+{
+case LOK_CALLBACK_INVALIDATE_TILES: // invalidation
 {
-auto& it = getQueue()[i];
+int msgX, msgY, msgW, msgH, msgPart;
 
-StringVector queuedTokens = Util::tokenize(it.data(), it.size());
-if (queuedTokens.size() < 3)
-{
-++i;
-continue;
-}
-
-// not a invalidation callback
-if (queuedTokens[0] != tokens[0] || queuedTokens[1] != tokens[1] 
|| queuedTokens[2] != tokens[2])
-{
-++i;
-continue;
-}
+if (!extractRectangle(tokens, msgX, msgY, msgW, msgH, msgPart))
+return std::string();
 
-int queuedX, queuedY, queuedW, queuedH, queuedPart;
+bool performedMerge = false;
 
-if (!extractRectangle(queuedTokens, queuedX, queuedY, queuedW, 
queuedH, queuedPart))
+// we always travel the entire queue
+std::size_t i = 0;
+while (i < getQueue().size())
 {
-++i;
-continue;
-}
+auto& it = getQueue()[i];
 
-if (msgPart != queuedPart)
-{
-++i;
-continue;
-}
+StringVector queuedTokens = Util::tokenize(it.data(), 
it.size());
+if (queuedTokens.size() < 3)
+{
+++i;
+continue;
+}
 
-// the invalidation in the queue is fully covered by the message,
-// just remove it
-if (msgX <= queuedX && queuedX + queuedW <= msgX + msgW && msgY <= 
queuedY && queuedY + queuedH <= msgY + msgH)
-{
-LOG_TRC("Removing smaller invalidation: "
-<< std::string(it.data(), it.size()) << " -> " << 
tokens[0] << ' '
-<< tokens[1] << ' ' << tokens[2] << ' ' << msgX << ' ' 
<< msgY << ' '
-<< msgW << ' ' << msgH << ' ' << msgPart);
-
-// remove from the queue
-getQueue().erase(getQueue().begin() + i);
-continue;
-}
+// not a invalidation callback
+if (queuedTokens[0] != tokens[0] || queuedTokens[1] != 
tokens[1]
+|| queuedTokens[2] != tokens[2])
+{
+++i;
+continue;
+}
 
-// the invalidation just intersects, join those (if the result is
-// small)
-if (TileDesc::rectanglesIntersect(msgX, msgY, msgW, msgH, queuedX, 
queuedY, queuedW, queuedH))
-{
-int joinX = std::min(msgX, queuedX);
-int joinY = std::min(msgY, queuedY);
-in

[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp

2020-07-02 Thread Ashod Nakashian (via logerrit)
 wsd/LOOLWSD.cpp |   33 ++---
 1 file changed, 14 insertions(+), 19 deletions(-)

New commits:
commit 3cee55872ba7a6c59126a13373e2cd3852fda932
Author: Ashod Nakashian 
AuthorDate: Wed Jun 3 10:39:25 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Jul 2 21:47:08 2020 +0200

wsd: minor cleanup

* Use const where possible.
* Remove dead-code (clang-tidy error).
* Don't use hungarian notation.
* Avoid single-use variables (if redundant).
* Declare variables closest to use-site.
* Avoid unecessary temporaries.
* Avoid explicit true/false when the statement is boolean already.

Change-Id: I154dc2a7d4bcbd39f73f42e12a101a7e4eb0fd33
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96378
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Muhammet Kara 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 6efb55655..da8487ddd 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2802,14 +2802,12 @@ private:
 
 static bool isSpreadsheet(const std::string& fileName)
 {
-std::string sContentType = getContentType(fileName);
+const std::string sContentType = getContentType(fileName);
 
-if (sContentType == "application/vnd.oasis.opendocument.spreadsheet"
-|| sContentType == 
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
-|| sContentType == "application/vnd.ms-excel")
-return true;
-else
-return false;
+return sContentType == "application/vnd.oasis.opendocument.spreadsheet"
+   || sContentType
+  == 
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+   || sContentType == "application/vnd.ms-excel";
 }
 
 void handlePostRequest(const RequestDetails &requestDetails,
@@ -2844,29 +2842,26 @@ private:
 ConvertToPartHandler handler(/*convertTo =*/ true);
 HTMLForm form(request, message, handler);
 
-std::string sOptions;
 std::string format = (form.has("format") ? form.get("format") : 
"");
-std::string sFullSheetPreview = (form.has("FullSheetPreview") ? 
form.get("FullSheetPreview") : "");
-bool bFullSheetPreview = sFullSheetPreview == "true" ? true : 
false;
-
 // prefer what is in the URI
 if (requestDetails.size() > 2)
 format = requestDetails[2];
 
-std::string fromPath = handler.getFilename();
+const std::string fromPath = handler.getFilename();
 LOG_INF("Conversion request for URI [" << fromPath << "] format [" 
<< format << "].");
 if (!fromPath.empty() && !format.empty())
 {
 Poco::URI uriPublic = DocumentBroker::sanitizeURI(fromPath);
 const std::string docKey = 
DocumentBroker::getDocKey(uriPublic);
 
-if (bFullSheetPreview && format == "pdf" && 
isSpreadsheet(fromPath))
-{
-sOptions += std::string(",FullSheetPreview=") + 
sFullSheetPreview + std::string("FULLSHEETPREVEND");
-}
-else
+std::string options;
+const bool fullSheetPreview
+= (form.has("FullSheetPreview") && 
form.get("FullSheetPreview") == "true");
+if (fullSheetPreview && format == "pdf" && 
isSpreadsheet(fromPath))
 {
-bFullSheetPreview = false;
+//FIXME: We shouldn't have "true" as having the option 
already implies that
+// we want it enabled (i.e. we shouldn't set the option if 
we don't want it).
+options = ",FullSheetPreview=trueFULLSHEETPREVEND";
 }
 
 // This lock could become a bottleneck.
@@ -2874,7 +2869,7 @@ private:
 std::unique_lock docBrokersLock(DocBrokersMutex);
 
 LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
-auto docBroker = std::make_shared(fromPath, 
uriPublic, docKey, format, sOptions);
+auto docBroker = std::make_shared(fromPath, 
uriPublic, docKey, format, options);
 handler.takeFile();
 
 cleanupDocBrokers();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loleaflet/src

2020-07-01 Thread Ashod Nakashian (via logerrit)
 loleaflet/src/control/Control.DocumentNameInput.js |2 +-
 loleaflet/src/control/Control.Toolbar.js   |7 ---
 loleaflet/src/map/Map.js   |4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 0b80c4b3270f004278521e06afcf3dec6ff99cd9
Author: Ashod Nakashian 
AuthorDate: Thu Jun 25 21:53:26 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Jul 2 02:44:29 2020 +0200

leaflet: set renameFilename before saving

There is a race between the time we set the
renameFilename value and the uno:Save response
arrives. If renameFilename is not set by then
we miss the opportunity to rename and instead
simply end up saving the file.

Change-Id: I8d7acbc95cef264de4385d506bfa34458ba80283
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97189
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/loleaflet/src/control/Control.DocumentNameInput.js 
b/loleaflet/src/control/Control.DocumentNameInput.js
index cfc4e5998..3ad053094 100644
--- a/loleaflet/src/control/Control.DocumentNameInput.js
+++ b/loleaflet/src/control/Control.DocumentNameInput.js
@@ -27,8 +27,8 @@ L.Control.DocumentNameInput = L.Control.extend({
// same extension, just rename 
the file
// file name must be without 
the extension for rename
value = value.substr(0, 
value.lastIndexOf('.'));
+   this.map._renameFilename = 
value;

this.map.sendUnoCommand('.uno:Save');
-   this.map._RenameFile = value;
}
}
} else {
diff --git a/loleaflet/src/control/Control.Toolbar.js 
b/loleaflet/src/control/Control.Toolbar.js
index 1eccdce82..e8dce9bc3 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -924,9 +924,10 @@ function onCommandResult(e) {
map._everModified = true;
 
// document is saved for rename
-   if (map._RenameFile) {
-   map.renameFile(map._RenameFile);
-   map._RenameFile = '';
+   if (map._renameFilename) {
+   var renameFilename = map._renameFilename;
+   map._renameFilename = '';
+   map.renameFile(renameFilename);
}
}
var postMessageObj = {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 5f9882a53..285e4954d 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -259,8 +259,8 @@ L.Map = L.Evented.extend({
// This becomes true if document was ever modified by the user
this._everModified = false;
 
-   // This becomes new file name if document is renamed which used 
later on uno:Save result
-   this._RenameFile = '';
+   // This is the new file name, if the document is renamed, which 
is used on uno:Save's result.
+   this._renameFilename = '';
 
// Document is completely loaded or not
this._docLoaded = false;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/Protocol.cpp common/Protocol.hpp common/Util.hpp

2020-07-01 Thread Ashod Nakashian (via logerrit)
 common/Protocol.cpp |   42 -
 common/Protocol.hpp |   23 -
 common/Util.hpp |   86 +---
 3 files changed, 102 insertions(+), 49 deletions(-)

New commits:
commit 65c245eab0b9c43866cfa7069cdd6f3889a0a23e
Author: Ashod Nakashian 
AuthorDate: Tue Jun 2 18:19:23 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Jul 2 02:38:35 2020 +0200

wsd: move string-to-integer helper to Util

Improved implementation.

Change-Id: I0b426f8742c8b718f8c939d271f6645a8ed466d4
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96374
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/common/Protocol.cpp b/common/Protocol.cpp
index 771b87b49..d02f2d340 100644
--- a/common/Protocol.cpp
+++ b/common/Protocol.cpp
@@ -48,48 +48,6 @@ namespace LOOLProtocol
 return std::make_tuple(major, minor, patch);
 }
 
-bool stringToInteger(const std::string& input, int& value)
-{
-try
-{
-value = std::stoi(input);
-}
-catch (std::invalid_argument&)
-{
-return false;
-}
-
-return true;
-}
-
-bool stringToUInt32(const std::string& input, uint32_t& value)
-{
-try
-{
-value = std::stoul(input);
-}
-catch (std::invalid_argument&)
-{
-return false;
-}
-
-return true;
-}
-
-bool stringToUInt64(const std::string& input, uint64_t& value)
-{
-try
-{
-value = std::stoull(input);
-}
-catch (std::invalid_argument&)
-{
-return false;
-}
-
-return true;
-}
-
 bool getTokenInteger(const std::string& token, const std::string& name, 
int& value)
 {
 if (token.size() > (name.size() + 1) &&
diff --git a/common/Protocol.hpp b/common/Protocol.hpp
index 5eb90941b..367d9ff27 100644
--- a/common/Protocol.hpp
+++ b/common/Protocol.hpp
@@ -41,9 +41,26 @@ namespace LOOLProtocol
 // Negative numbers for error.
 std::tuple ParseVersion(const std::string& version);
 
-bool stringToInteger(const std::string& input, int& value);
-bool stringToUInt32(const std::string& input, uint32_t& value);
-bool stringToUInt64(const std::string& input, uint64_t& value);
+inline bool stringToInteger(const std::string& input, int& value)
+{
+bool res;
+std::tie(value, res) = Util::i32FromString(input);
+return res;
+}
+
+inline bool stringToUInt32(const std::string& input, uint32_t& value)
+{
+bool res;
+std::tie(value, res) = Util::i32FromString(input);
+return res;
+}
+
+inline bool stringToUInt64(const std::string& input, uint64_t& value)
+{
+bool res;
+std::tie(value, res) = Util::u64FromString(input);
+return res;
+}
 
 inline
 bool parseNameValuePair(const std::string& token, std::string& name, 
std::string& value, const char delim = '=')
diff --git a/common/Util.hpp b/common/Util.hpp
index ba70cba47..6dcfa3d48 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -22,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -1129,10 +1131,86 @@ int main(int argc, char**argv)
  */
 std::map 
stringVectorToMap(std::vector sVector, const char delimiter);
 
-#if !MOBILEAPP
-// If OS is not mobile, it must be Linux.
-std::string getLinuxVersion();
-#endif
+#if !MOBILEAPP
+// If OS is not mobile, it must be Linux.
+std::string getLinuxVersion();
+#endif
+
+/// Convert a string to 32-bit signed int.
+/// Returs the parsed value and a boolean indiciating success or failure.
+inline std::pair i32FromString(const std::string& 
input)
+{
+const char* str = input.data();
+char* endptr = nullptr;
+const auto value = std::strtol(str, &endptr, 10);
+return std::make_pair(value, endptr > str && errno != ERANGE);
+}
+
+/// Convert a string to 32-bit signed int. On failure, returns the default
+/// value, and sets the bool to false (to signify that parsing had failed).
+inline std::pair i32FromString(const std::string& 
input,
+   const std::int32_t def)
+{
+const auto pair = i32FromString(input);
+return pair.second ? pair : std::make_pair(def, false);
+}
+
+/// Convert a string to 32-bit unsigned int.
+/// Returs the parsed value and a boolean indiciating success or failure.
+inline std::pair u32FromString(const std

[Libreoffice-commits] online.git: wsd/Admin.cpp

2020-07-01 Thread Ashod Nakashian (via logerrit)
 wsd/Admin.cpp |   24 
 1 file changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 4082a462dad52151907fe71f5780cb82b0d272a7
Author: Ashod Nakashian 
AuthorDate: Sat Jun 27 16:56:51 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Jul 2 02:33:25 2020 +0200

wsd: admin: don't poll rapidly when cleanup is disabled

When per_document.cleanup is disabled, the time
between the last cleanup (which never happened)
grows indefinitely, which results in minimal
polling time intervals. This wastes valuable
cpu cycles unnecessarily.

When cleanup is disabled, there is no need to
calculate the next cleanup time. The maximum
is reasonable (although it should really be
infinity).

Change-Id: I71d065441c4c2ff96fe31e6a45a5ecfdd2f85d49
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97471
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 996e7b75c..02be6fcfd 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -415,14 +415,12 @@ Admin::~Admin()
 
 void Admin::pollingThread()
 {
-std::chrono::steady_clock::time_point lastCPU, lastMem, lastNet, 
lastCleanup;
-
 _model.setThreadOwner(std::this_thread::get_id());
 
-lastCPU = std::chrono::steady_clock::now();
-lastMem = lastCPU;
-lastNet = lastCPU;
-lastCleanup = lastCPU;
+std::chrono::steady_clock::time_point lastCPU = 
std::chrono::steady_clock::now();
+std::chrono::steady_clock::time_point lastMem = lastCPU;
+std::chrono::steady_clock::time_point lastNet = lastCPU;
+std::chrono::steady_clock::time_point lastCleanup = lastCPU;
 
 while (!isStop() && !SigUtil::getTerminationFlag() && 
!SigUtil::getShutdownRequestFlag())
 {
@@ -484,14 +482,15 @@ void Admin::pollingThread()
 lastNet = now;
 }
 
-int cleanupWait = _cleanupIntervalMs -
-std::chrono::duration_cast(now - 
lastCleanup).count();
-if (cleanupWait <= MinStatsIntervalMs / 2) // Close enough
+int cleanupWait = _cleanupIntervalMs;
+if (_defDocProcSettings.getCleanupSettings().getEnable())
 {
-if (_defDocProcSettings.getCleanupSettings().getEnable())
+cleanupWait
+-= std::chrono::duration_cast(now - 
lastCleanup).count();
+if (cleanupWait <= MinStatsIntervalMs / 2) // Close enough
 {
 cleanupResourceConsumingDocs();
-
+
 cleanupWait += _cleanupIntervalMs;
 lastCleanup = now;
 }
@@ -509,7 +508,8 @@ void Admin::pollingThread()
 }
 
 // Handle websockets & other work.
-const int timeout = 
capAndRoundInterval(std::min(std::min(std::min(cpuWait, memWait), netWait), 
cleanupWait));
+const int timeout = capAndRoundInterval(
+std::min(std::min(std::min(cpuWait, memWait), netWait), 
cleanupWait));
 LOG_TRC("Admin poll for " << timeout << "ms.");
 poll(timeout * 1000); // continue with ms for admin, settings etc.
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Makefile.am test/Makefile.am

2020-07-01 Thread Ashod Nakashian (via logerrit)
 Makefile.am  |   28 +++-
 test/Makefile.am |2 ++
 2 files changed, 17 insertions(+), 13 deletions(-)

New commits:
commit a062581be6b55d9c498c8f1d4e5cec9c4126e234
Author: Ashod Nakashian 
AuthorDate: Wed Jul 1 13:06:46 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Jul 2 02:32:43 2020 +0200

make: improve cleanup dependency graph

Change-Id: I8a7edd3b49a272cb7bd8bff4d91b189a5856c5c8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97647
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/Makefile.am b/Makefile.am
index 0eba81cf5..074f05376 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -329,14 +329,25 @@ SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp
 CAPABILITIES = $(if @ENABLE_SETCAP@,true,false)
 RUN_GDB = $(if $(GDB_FRONTEND),$(GDB_FRONTEND),gdb --tui --args)
 
-$(SYSTEM_STAMP) : ${top_srcdir}/loolwsd-systemplate-setup
-   if test -s ./loolwsd; then ./loolwsd --cleanup; fi
+# Add caps to the binaries that need them.
+caps_bins: loolforkit loolmount
+if ENABLE_SETCAP
+   sudo @SETCAP@ cap_fowner,cap_mknod,cap_sys_chroot=ep loolforkit
+   sudo @SETCAP@ cap_sys_admin=ep loolmount
+else
+   echo "Skipping capability setting"
+endif
+
+# Build loolwsd and loolmount first, so we can cleanup before updating
+# the systemplate directory, which we can't rm if it's mounted.
+$(SYSTEM_STAMP): ${top_srcdir}/loolwsd-systemplate-setup loolwsd caps_bins
+   $(CLEANUP_COMMAND)
if test "z@SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@"; 
fi
${top_srcdir}/loolwsd-systemplate-setup "@SYSTEMPLATE_PATH@" 
"@LO_PATH@" && touch $@
 
-@JAILS_PATH@ :
-   mkdir -p $@
+@JAILS_PATH@:
$(CLEANUP_COMMAND)
+   mkdir -p $@
 
 clean-local:
$(CLEANUP_COMMAND)
@@ -464,16 +475,7 @@ endif
 # installing the RPM or Debian package.
 .PHONY: caps_bins
 
-caps_bins: loolforkit loolmount
-if ENABLE_SETCAP
-   sudo @SETCAP@ cap_fowner,cap_mknod,cap_sys_chroot=ep loolforkit
-   sudo @SETCAP@ cap_sys_admin=ep loolmount
-else
-   echo "Skipping capability setting"
-endif
-
 all-local: loolwsd caps_bins @JAILS_PATH@ $(SYSTEM_STAMP)
-   $(CLEANUP_COMMAND)
 
 # just run the build without any tests
 build-nocheck: all-am
diff --git a/test/Makefile.am b/test/Makefile.am
index c12038b0d..327832f79 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -309,3 +309,5 @@ all-local: unittest
@echo
@fc-cache "@LO_PATH@"/share/fonts/truetype
@UNITTEST=1 ${top_builddir}/test/unittest
+   echo "Done test all-local"
+   $(CLEANUP_COMMAND)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp

2020-06-30 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit e93f7039c13d2b5326d22eaf14a6e801eba0cb9a
Author: Ashod Nakashian 
AuthorDate: Thu Jun 25 21:55:30 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 07:42:46 2020 +0200

wsd: anonymize the filename only when anonymization is enabled

Change-Id: I0649788d38492b66aeb9cc4716dcbd23cd76cb4e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97190
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 4b3a61d39..8a41a6dd9 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1002,9 +1002,13 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 const std::string newFilename = Util::getFilenameFromURL(uri);
 const std::string fileId = Util::getFilenameFromURL(_docKey);
 if (LOOLWSD::AnonymizeUserData)
-LOG_DBG("New filename [" << LOOLWSD::anonymizeUrl(newFilename) << "] 
will be known by its fileId [" << fileId << ']');
+{
+LOG_DBG("New filename [" << LOOLWSD::anonymizeUrl(newFilename)
+ << "] will be known by its fileId [" << 
fileId << ']');
+
+Util::mapAnonymized(newFilename, fileId);
+}
 
-Util::mapAnonymized(newFilename, fileId);
 const std::string uriAnonym = LOOLWSD::anonymizeUrl(uri);
 
 // If the file timestamp hasn't changed, skip saving.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/ClientSession.cpp wsd/TileCache.cpp

2020-06-30 Thread Ashod Nakashian (via logerrit)
 wsd/ClientSession.cpp |2 +-
 wsd/TileCache.cpp |5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

New commits:
commit a77208ddfba03faf2df575d9a43cc21d65f93fd0
Author: Ashod Nakashian 
AuthorDate: Tue Jun 9 22:24:13 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 07:40:54 2020 +0200

wsd: prefer emplace_back where possible

emplace_back avoids copy-construction when
the argument is a temporary instance created
at call-site.

Change-Id: I127fddd308d710af9ea65a86db1b03347e9c3d87
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96829
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 26f9e9c8b..5f79a07fa 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1574,7 +1574,7 @@ void ClientSession::enqueueSendMessage(const 
std::shared_ptr& data)
 
 void ClientSession::addTileOnFly(const TileDesc& tile)
 {
-_tilesOnFly.push_back({tile.generateID(), 
std::chrono::steady_clock::now()});
+_tilesOnFly.emplace_back(tile.generateID(), 
std::chrono::steady_clock::now());
 }
 
 void ClientSession::clearTilesOnFly()
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index 12231a383..4e9773499 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -589,9 +589,8 @@ void TileCache::ensureCacheSize()
 WidSize(TileWireId w, size_t s) : _wid(w), _size(s) {}
 };
 std::vector wids;
-for (auto &it : _cache)
-wids.push_back(WidSize(it.first.getWireId(),
-   itemCacheSize(it.second)));
+for (const auto& it : _cache)
+wids.emplace_back(it.first.getWireId(), itemCacheSize(it.second));
 std::sort(wids.begin(), wids.end(),
   [](const WidSize &a, const WidSize &b) { return a._wid < b._wid; 
});
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/ChildSession.cpp net/Ssl.hpp wsd/AdminModel.cpp wsd/AdminModel.hpp wsd/LOOLWSD.cpp wsd/TestStubs.cpp

2020-06-30 Thread Ashod Nakashian (via logerrit)
 kit/ChildSession.cpp |2 +-
 net/Ssl.hpp  |1 +
 wsd/AdminModel.cpp   |4 ++--
 wsd/AdminModel.hpp   |   12 +++-
 wsd/LOOLWSD.cpp  |2 +-
 wsd/TestStubs.cpp|2 +-
 6 files changed, 13 insertions(+), 10 deletions(-)

New commits:
commit 02da27a4364b44ddb57936070d6b36a7d53d3498
Author: Ashod Nakashian 
AuthorDate: Wed Jun 3 10:43:52 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 07:40:10 2020 +0200

wsd: improve readability

Change-Id: I2f85ebff783ebb799324b0aa95f5d0d023c19231
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96381
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index cc8f7413e..6d6344cef 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1643,7 +1643,7 @@ bool ChildSession::renderWindow(const char* /*buffer*/, 
int /*length*/, const St
 
 bool ChildSession::resizeWindow(const char* /*buffer*/, int /*length*/, const 
StringVector& tokens)
 {
-const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1].c_str(), 
nullptr, 10) : 0);
+const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1], nullptr, 
10) : 0);
 
 getLOKitDocument()->setView(_viewId);
 
diff --git a/net/Ssl.hpp b/net/Ssl.hpp
index 25bcc318a..a5fd70a76 100644
--- a/net/Ssl.hpp
+++ b/net/Ssl.hpp
@@ -10,6 +10,7 @@
 #pragma once
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index 893c7739a..415350b52 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -1019,10 +1019,10 @@ struct KitProcStats
 void AdminModel::CalcDocAggregateStats(DocumentAggregateStats& stats)
 {
 for (auto& d : _documents)
-stats.Update(*d.second.get(), true);
+stats.Update(*d.second, true);
 
 for (auto& d : _expiredDocuments)
-stats.Update(*d.second.get(), false);
+stats.Update(*d.second, false);
 }
 
 void CalcKitStats(KitProcStats& stats)
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index 43da0cd1d..d4a4513ce 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -9,15 +9,17 @@
 
 #pragma once
 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
 
-#include "Log.hpp"
-#include "net/WebSocketHandler.hpp"
+#include 
 #include "Util.hpp"
+#include "net/WebSocketHandler.hpp"
 
 struct DocumentAggregateStats;
 
@@ -161,7 +163,7 @@ public:
 fclose(_procSMaps);
 }
 
-const std::string getDocKey() const { return _docKey; }
+std::string getDocKey() const { return _docKey; }
 
 pid_t getPid() const { return _pid; }
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 6b1900443..5d3b17808 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2412,7 +2412,7 @@ private:
 throw Poco::FileAccessDeniedException("Admin console 
disabled");
 
 try{
-if (!FileServerRequestHandler::isAdminLoggedIn(request, 
*response.get()))
+if (!FileServerRequestHandler::isAdminLoggedIn(request, 
*response))
 throw Poco::Net::NotAuthenticatedException("Invalid 
admin login");
 }
 catch (const Poco::Net::NotAuthenticatedException& exc)
diff --git a/wsd/TestStubs.cpp b/wsd/TestStubs.cpp
index ca04416da..ad0859a8e 100644
--- a/wsd/TestStubs.cpp
+++ b/wsd/TestStubs.cpp
@@ -23,7 +23,7 @@ void ClientSession::traceTileBySend(const TileDesc& /*tile*/, 
bool /*deduplicate
 
 void ClientSession::enqueueSendMessage(const std::shared_ptr& 
/*data*/) {};
 
-ClientSession::~ClientSession() {}
+ClientSession::~ClientSession() = default;
 
 void ClientSession::onDisconnect() {}
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/Unit.cpp common/Unit.hpp test/Makefile.am test/UnitWOPIHttpHeaders.cpp test/WopiTestServer.hpp wsd/FileServer.cpp wsd/Storage.cpp

2020-06-30 Thread Ashod Nakashian (via logerrit)
 common/Unit.cpp  |2 
 common/Unit.hpp  |   16 +
 test/Makefile.am |   13 +++-
 test/UnitWOPIHttpHeaders.cpp |  116 +++
 test/WopiTestServer.hpp  |   13 
 wsd/FileServer.cpp   |3 +
 wsd/Storage.cpp  |2 
 7 files changed, 159 insertions(+), 6 deletions(-)

New commits:
commit e68be80496e775e18edb5cbc7d3f229603fa2a2c
Author: Ashod Nakashian 
AuthorDate: Mon Jun 22 08:24:11 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 07:37:10 2020 +0200

wsd: add http-headers unit-test

This is to defend the sneaking of extra http-headers
in the access_header URI param that was recently fixed.

Change-Id: Ic28cf58854847ac278bed8043f398b107f7992b3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96862
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/common/Unit.cpp b/common/Unit.cpp
index 19cacc8aa..ff94d63f5 100644
--- a/common/Unit.cpp
+++ b/common/Unit.cpp
@@ -203,7 +203,7 @@ void UnitBase::exitTest(TestResult result)
 return;
 }
 
-LOG_INF("exitTest: " << (int)result << ". Flagging to shutdown.");
+LOG_INF("exitTest: " << testResultAsString(result) << ". Flagging to 
shutdown.");
 _setRetValue = true;
 _retValue = result == TestResult::Ok ? EX_OK : EX_SOFTWARE;
 #if !MOBILEAPP
diff --git a/common/Unit.hpp b/common/Unit.hpp
index 9b6a88ece..3e65d7b23 100644
--- a/common/Unit.hpp
+++ b/common/Unit.hpp
@@ -70,6 +70,22 @@ protected:
 TimedOut
 };
 
+static const std::string testResultAsString(TestResult res)
+{
+switch (res)
+{
+case TestResult::Failed:
+return "Failed";
+case TestResult::Ok:
+return "Ok";
+case TestResult::TimedOut:
+return "TimedOut";
+}
+
+assert(!"Unknown TestResult entry.");
+return std::to_string(static_cast(res));
+}
+
 /// Encourages the process to exit with this value (unless hooked)
 void exitTest(TestResult result);
 
diff --git a/test/Makefile.am b/test/Makefile.am
index e05dfdf3f..c12038b0d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -41,7 +41,9 @@ noinst_LTLIBRARIES = \
unit-close.la \
unit-bad-doc-load.la \
unit-hosting.la \
-   unit-wopi-loadencoded.la unit-wopi-temp.la
+   unit-wopi-loadencoded.la \
+   unit-wopi-temp.la \
+   unit-wopi-httpheaders.la
 
 MAGIC_TO_FORCE_SHLIB_CREATION = -rpath /dummy
 AM_LDFLAGS = -pthread -module $(MAGIC_TO_FORCE_SHLIB_CREATION) $(ZLIB_LIBS)
@@ -148,6 +150,8 @@ unit_wopi_loadencoded_la_SOURCES = UnitWOPILoadEncoded.cpp
 unit_wopi_loadencoded_la_LIBADD = $(CPPUNIT_LIBS)
 unit_wopi_temp_la_SOURCES = UnitWOPITemplate.cpp
 unit_wopi_temp_la_LIBADD = $(CPPUNIT_LIBS)
+unit_wopi_httpheaders_la_SOURCES = UnitWOPIHttpHeaders.cpp
+unit_wopi_httpheaders_la_LIBADD = $(CPPUNIT_LIBS)
 unit_tiff_load_la_SOURCES = UnitTiffLoad.cpp
 unit_tiff_load_la_LIBADD = $(CPPUNIT_LIBS)
 unit_large_paste_la_SOURCES = UnitLargePaste.cpp
@@ -225,7 +229,9 @@ TESTS = \
unit-close.la \
unit-bad-doc-load.la \
unit-hosting.la \
-   unit-wopi-loadencoded.la unit-wopi-temp.la
+   unit-wopi-loadencoded.la \
+   unit-wopi-temp.la \
+   unit-wopi-httpheaders
 # TESTS += unit-admin.test
 # TESTS += unit-storage.test
 
@@ -276,9 +282,10 @@ unit-convert.log : group0.log
 unit-typing.log : group0.log
 unit-tilecache.log : group0.log
 unit-timeout.log : group0.log
+unit-wopi-httpheaders.log: group0.log
 unit-base.log: group0.log
 
-group1.log: unit-crash.log unit-tiletest.log unit-insert-delete.log 
unit-each-view.log unit-httpws.log unit-close.log 
unit-wopi-documentconflict.log unit-prefork.log unit-wopi-versionrestore.log 
unit-wopi-temp.log unit_wopi_renamefile.log unit_wopi_watermark.log 
unit-wopi.log unit-wopi-ownertermination.log unit-load-torture.log 
unit-wopi-saveas.log unit-password-protected.log unit-http.log 
unit-tiff-load.log unit-render-shape.log unit-oauth.log unit-large-paste.log 
unit-paste.log unit-rendering-options.log unit-session.log unit-uno-command.log 
unit-load.log unit-cursor.log unit-calc.log unit-bad-doc-load.log 
unit-hosting.log unit-wopi-loadencoded.log unit-integration.log 
unit-convert.log unit-typing.log unit-tilecache.log unit-timeout.log 
unit-base.log
+group1.log: unit-crash.log unit-tiletest.log unit-insert-delete.log 
unit-each-view.log unit-httpws.log unit-close.log 
unit-wopi-documentconflict.log unit-prefork.log unit-wopi-versionrestore.log 
unit-wopi-temp.log unit_wopi_renamefile.log unit_wopi_watermark.log 
unit-wopi.log unit-wopi-ownertermination.log unit-load-torture.log 
unit-wopi-saveas.log unit-password-protected.log unit-http.log 
unit-tiff-load.

[Libreoffice-commits] online.git: wsd/Storage.cpp

2020-06-30 Thread Ashod Nakashian (via logerrit)
 wsd/Storage.cpp |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

New commits:
commit 77aa8161807d3e934c9bad48d6494fe9ca029277
Author: Ashod Nakashian 
AuthorDate: Sat Jun 20 14:07:13 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 07:35:53 2020 +0200

wsd: log the response from WOPI CheckFileInfo separately

Change-Id: I8af28a7332903e6ed36dfba6bbd6bfbb5ebbd4db
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96828
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index fbda5edb8..6c5a14878 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -587,15 +587,17 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 std::istream& rs = psession->receiveResponse(response);
 callDuration = (std::chrono::steady_clock::now() - startTime);
 
-if (logger.enabled())
+Log::StreamLogger logRes = Log::trace();
+if (logRes.enabled())
 {
-logger << "WOPI::CheckFileInfo response header for URI [" << 
uriAnonym << "]:\n";
+logRes << "WOPI::CheckFileInfo response header for URI [" << 
uriAnonym
+   << "]: " << response.getStatus() << '\n';
 for (const auto& pair : response)
 {
-logger << '\t' << pair.first << ": " << pair.second << " / ";
+logRes << '\t' << pair.first << ": " << pair.second << " / ";
 }
 
-LOG_END(logger, true);
+LOG_END(logRes, true);
 }
 
 if (response.getStatus() != Poco::Net::HTTPResponse::HTTP_OK)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: test/WhiteBoxTests.cpp wsd/RequestDetails.cpp wsd/RequestDetails.hpp

2020-06-30 Thread Ashod Nakashian (via logerrit)
 test/WhiteBoxTests.cpp |   16 
 wsd/RequestDetails.cpp |   35 +--
 wsd/RequestDetails.hpp |3 +++
 3 files changed, 44 insertions(+), 10 deletions(-)

New commits:
commit 5cf0273c7fcc10b85a4aeaaef20d602dd1bd1969
Author: Ashod Nakashian 
AuthorDate: Sat Jun 20 15:12:13 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 07:35:00 2020 +0200

wsd: parse the URI params of the URI and DocumentURI

Change-Id: Iefc8c10ff85270aa95f255cef29b3427a0efcfe6
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96826
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp
index dd32dbdd6..13a4ac572 100644
--- a/test/WhiteBoxTests.cpp
+++ b/test/WhiteBoxTests.cpp
@@ -1509,6 +1509,22 @@ void WhiteBoxTests::testRequestDetails()
 // LOK_ASSERT_EQUAL(docUri, details.getLegacyDocumentURI()); // Broken.
 LOK_ASSERT_EQUAL(docUri, details.getDocumentURI());
 
+const std::map& params = 
details.getDocumentURIParams();
+LOK_ASSERT_EQUAL(static_cast(3), params.size());
+auto it = params.find("access_header");
+const std::string access_header
+= "Authorization: Bearer poiuytrewq\r\n\r\nX-Requested-With: 
XMLHttpRequest";
+LOK_ASSERT_EQUAL(access_header, it != params.end() ? it->second : "");
+it = params.find("reuse_cookies");
+const std::string reuse_cookies
+= 
"lang=en-us:_ga_LMX4TVJ02K=GS1.1:Token=eyJhbGciOiJIUzUxMiJ9.vajknfkfajksdljfiwjek-"
+  
"W90fmgVb3C-00-eSkJBDqDNSYA:PublicToken=abc:ZNPCQ003-32383700=e9c71c3b:JSESSIONID="
+  "node0.node0";
+LOK_ASSERT_EQUAL(reuse_cookies, it != params.end() ? it->second : "");
+it = params.find("permission");
+const std::string permission = "edit";
+LOK_ASSERT_EQUAL(permission, it != params.end() ? it->second : "");
+
 LOK_ASSERT_EQUAL(static_cast(11), details.size());
 LOK_ASSERT_EQUAL(std::string("lool"), details[0]);
 LOK_ASSERT(details.equals(0, "lool"));
diff --git a/wsd/RequestDetails.cpp b/wsd/RequestDetails.cpp
index 9caf03f29..edb5c1c8c 100644
--- a/wsd/RequestDetails.cpp
+++ b/wsd/RequestDetails.cpp
@@ -15,6 +15,27 @@
 #include 
 #include "Exceptions.hpp"
 
+namespace
+{
+
+std::map getParams(const std::string& uri)
+{
+std::map result;
+for (const auto& param : Poco::URI(uri).getQueryParameters())
+{
+std::string key;
+Poco::URI::decode(param.first, key);
+std::string value;
+Poco::URI::decode(param.second, value);
+LOG_TRC("Decoding param [" << param.first << "] = [" << param.second 
<< "] -> [" << key
+   << "] = [" << value << "].");
+
+result.emplace(key, value);
+}
+
+return result;
+}
+
 /// Returns true iff the two containers are equal.
 template  bool equal(const T& lhs, const T& rhs)
 {
@@ -42,6 +63,7 @@ template  bool equal(const T& lhs, const T& rhs)
 
 return true;
 }
+}
 
 RequestDetails::RequestDetails(Poco::Net::HTTPRequest &request, const 
std::string& serviceRoot)
 : _isMobile(false)
@@ -86,16 +108,7 @@ RequestDetails::RequestDetails(const std::string &mobileURI)
 void RequestDetails::processURI()
 {
 // Poco::SyntaxException is thrown when the syntax is invalid.
-Poco::URI uri(_uriString);
-for (const auto& param : uri.getQueryParameters())
-{
-LOG_TRC("Decoding param [" << param.first << "] = [" << param.second 
<< "].");
-
-std::string value;
-Poco::URI::decode(param.second, value);
-
-_params.emplace(param.first, value);
-}
+_params = getParams(_uriString);
 
 // First tokenize by '/' then by '?'.
 std::vector tokens;
@@ -169,6 +182,8 @@ void RequestDetails::processURI()
 _fields[Field::DocumentURI] = _uriString;
 }
 
+_docUriParams = getParams(_fields[Field::DocumentURI]);
+
 _fields[Field::WOPISrc] = getParam("WOPISrc");
 
 // &compat=
diff --git a/wsd/RequestDetails.hpp b/wsd/RequestDetails.hpp
index e55f28535..93dd4ff50 100644
--- a/wsd/RequestDetails.hpp
+++ b/wsd/RequestDetails.hpp
@@ -119,6 +119,7 @@ private:
 StringVector _pathSegs;
 std::map _params;
 std::map _fields;
+std::map _docUriParams;
 
 void processURI();
 
@@ -134,6 +135,8 @@ public:
 /// The DocumentURI, decoded. Doesn't contain WOPISrc or any other 
appendages.
 std::string getDocumentURI() const { return getField(Field::DocumentURI); }
 
+const std::map& getDocumentURIParams() const { 
return _docUriParams; }
+
 std::string getURI() const
 {
 return _uriString;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: android/lib common/Authorization.cpp common/Authorization.hpp test/Makefile.am test/WhiteBoxTests.cpp wsd/Admin.cpp wsd/ClientSession.cpp wsd/ClientSession.hpp

2020-06-30 Thread Ashod Nakashian (via logerrit)
 android/lib/src/main/cpp/CMakeLists.txt.in |5 -
 common/Authorization.cpp   |   22 ++
 common/Authorization.hpp   |   10 ++
 test/Makefile.am   |2 
 test/WhiteBoxTests.cpp |  105 -
 wsd/Admin.cpp  |1 
 wsd/ClientSession.cpp  |   31 
 wsd/ClientSession.hpp  |4 -
 8 files changed, 142 insertions(+), 38 deletions(-)

New commits:
commit fa96934861b075cffd980cdfa98f61dee82fc012
Author: Ashod Nakashian 
AuthorDate: Sat Jun 20 14:09:21 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 07:33:57 2020 +0200

wsd: Authorization parsing and creation improvements

Authorization class now handles the parsing and creation
of its instances, which makes it centralized.

We also avoid repeatedly constructing Authorization objects
in ClientSession and instead do it once at construction
and cache it.

A bunch of new unit-tests added.

Change-Id: I9b5939be51a5957214d07ed8f1096efd179686c6
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96825
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/android/lib/src/main/cpp/CMakeLists.txt.in 
b/android/lib/src/main/cpp/CMakeLists.txt.in
index 56b5a8a52..53a3fafd7 100644
--- a/android/lib/src/main/cpp/CMakeLists.txt.in
+++ b/android/lib/src/main/cpp/CMakeLists.txt.in
@@ -3,12 +3,13 @@ cmake_minimum_required(VERSION 3.4.1)
 
 add_library(androidapp SHARED
 androidapp.cpp
+../../../../../common/Authorization.cpp
 ../../../../../common/FileUtil.cpp
 ../../../../../common/JailUtil.cpp
 ../../../../../common/Log.cpp
 ../../../../../common/MessageQueue.cpp
 ../../../../../common/Protocol.cpp
-   ../../../../../common/StringVector.cpp
+../../../../../common/StringVector.cpp
 ../../../../../common/Session.cpp
 ../../../../../common/SigUtil.cpp
 ../../../../../common/SpookyV2.cpp
@@ -21,7 +22,7 @@ add_library(androidapp SHARED
 ../../../../../wsd/ClientSession.cpp
 ../../../../../wsd/DocumentBroker.cpp
 ../../../../../wsd/LOOLWSD.cpp
-   ../../../../../wsd/RequestDetails.cpp
+../../../../../wsd/RequestDetails.cpp
 ../../../../../wsd/Storage.cpp
 ../../../../../wsd/TileCache.cpp)
 
diff --git a/common/Authorization.cpp b/common/Authorization.cpp
index ad4381ef5..93c5704fc 100644
--- a/common/Authorization.cpp
+++ b/common/Authorization.cpp
@@ -88,4 +88,26 @@ void Authorization::authorizeRequest(Poco::Net::HTTPRequest& 
request) const
 }
 }
 
+Authorization Authorization::create(const Poco::URI::QueryParameters& 
queryParams)
+{
+// prefer the access_token
+std::string decoded;
+for (const auto& param : queryParams)
+{
+if (param.first == "access_token")
+{
+Poco::URI::decode(param.second, decoded);
+return Authorization(Authorization::Type::Token, decoded);
+}
+
+if (param.first == "access_header")
+Poco::URI::decode(param.second, decoded);
+}
+
+if (!decoded.empty())
+return Authorization(Authorization::Type::Header, decoded);
+
+return Authorization();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/common/Authorization.hpp b/common/Authorization.hpp
index 4fd2f3671..14accb236 100644
--- a/common/Authorization.hpp
+++ b/common/Authorization.hpp
@@ -28,8 +28,8 @@ public:
 };
 
 private:
-Type _type;
-std::string _data;
+const Type _type;
+const std::string _data;
 
 public:
 Authorization()
@@ -43,6 +43,12 @@ public:
 {
 }
 
+/// Create an Authorization instance from the URI query parameters.
+/// Expects access_token (preferred) or access_header.
+static Authorization create(const Poco::URI::QueryParameters& queryParams);
+static Authorization create(const Poco::URI& uri) { return 
create(uri.getQueryParameters()); }
+static Authorization create(const std::string& uri) { return 
create(Poco::URI(uri)); }
+
 /// Set the access_token parametr to the given uri.
 void authorizeURI(Poco::URI& uri) const;
 
diff --git a/test/Makefile.am b/test/Makefile.am
index ad48899a1..e05dfdf3f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -75,7 +75,7 @@ test_base_source = \
WopiProofTests.cpp \
$(wsd_sources)
 
-unittest_CPPFLAGS = -I$(top_srcdir) -DBUILDING_TESTS -DSTANDALONE_CPPUNIT
+unittest_CPPFLAGS = -I$(top_srcdir) -DBUILDING_TESTS -DSTANDALONE_CPPUNIT -g
 unittest_SOURCES = \
 $(test_base_source) \
 ../common/Log.cpp \
diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.

[Libreoffice-commits] online.git: configure.ac Makefile.am test/Makefile.am test/run_unit.sh.in wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp

2020-06-30 Thread Ashod Nakashian (via logerrit)
 Makefile.am |   11 -
 configure.ac|2 
 test/Makefile.am|  109 +++-
 test/run_unit.sh.in |2 
 wsd/LOOLWSD.cpp |   16 +++
 wsd/LOOLWSD.hpp |1 
 6 files changed, 76 insertions(+), 65 deletions(-)

New commits:
commit 9a427524d11908e2b8c475e7c6328563f300f076
Author: Ashod Nakashian 
AuthorDate: Sun Jun 28 11:30:22 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 06:14:39 2020 +0200

wsd: support --cleanup in loolwsd

Leaving behind jails with bind-mount
entries makes build-workspace removal
complicated, and jenkins builds start failing.

The cleanup stage is integrated in Makefiles
and should be transparent.

In the event that manual cleanup is necessary,
'loolwsd --cleanup' can be invoked.

Change-Id: Ia4b99b0c66e56dfa2d50e79b0ba98f714cf32886
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97470
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/Makefile.am b/Makefile.am
index d3f18e6a3..0eba81cf5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -321,6 +321,8 @@ EXTRA_DIST = discovery.xml \
  scripts/unocommands.py \
  $(man_MANS)
 
+CLEANUP_COMMAND=if test -s ./loolwsd; then echo "Cleaning up..." && ./loolwsd 
--cleanup --o:logging.level=trace; fi
+
 if HAVE_LO_PATH
 
 SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp
@@ -328,13 +330,16 @@ CAPABILITIES = $(if @ENABLE_SETCAP@,true,false)
 RUN_GDB = $(if $(GDB_FRONTEND),$(GDB_FRONTEND),gdb --tui --args)
 
 $(SYSTEM_STAMP) : ${top_srcdir}/loolwsd-systemplate-setup
+   if test -s ./loolwsd; then ./loolwsd --cleanup; fi
if test "z@SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@"; 
fi
${top_srcdir}/loolwsd-systemplate-setup "@SYSTEMPLATE_PATH@" 
"@LO_PATH@" && touch $@
 
 @JAILS_PATH@ :
mkdir -p $@
+   $(CLEANUP_COMMAND)
 
 clean-local:
+   $(CLEANUP_COMMAND)
if test "z@JAILS_PATH@" != "z"; then rm -rf "@JAILS_PATH@"; fi
if test "z@SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@"; 
fi
rm -f $(abs_srcdir)/compile_commands.json
@@ -457,8 +462,9 @@ endif
 # installing. When building for packaging, no need for this, as the
 # capabilities won't survive packaging anyway. Instead, handle it when
 # installing the RPM or Debian package.
+.PHONY: caps_bins
 
-all-local: loolforkit loolmount @JAILS_PATH@ $(SYSTEM_STAMP)
+caps_bins: loolforkit loolmount
 if ENABLE_SETCAP
sudo @SETCAP@ cap_fowner,cap_mknod,cap_sys_chroot=ep loolforkit
sudo @SETCAP@ cap_sys_admin=ep loolmount
@@ -466,6 +472,9 @@ else
echo "Skipping capability setting"
 endif
 
+all-local: loolwsd caps_bins @JAILS_PATH@ $(SYSTEM_STAMP)
+   $(CLEANUP_COMMAND)
+
 # just run the build without any tests
 build-nocheck: all-am
 
diff --git a/configure.ac b/configure.ac
index 740dc2e3c..7a8177e91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1140,7 +1140,7 @@ if test "$enable_androidapp" = "yes"; then
  
$srcdir/android/lib/src/main/cpp/CMakeLists.txt:android/lib/src/main/cpp/CMakeLists.txt.in])
 fi
 
-AC_CONFIG_FILES([test/run_unit.sh:test/run_unit.sh.in],[chmod +x 
test/run_unit.sh])
+AC_CONFIG_FILES([test/run_unit.sh],[chmod +x test/run_unit.sh])
 
 AC_OUTPUT
 
diff --git a/test/Makefile.am b/test/Makefile.am
index 275a214c2..ad48899a1 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -189,8 +189,11 @@ else
 SYSTEM_STAMP =
 endif
 
+CLEANUP_COMMAND=if test -s ../loolwsd; then echo "Cleaning up..." && 
../loolwsd --cleanup --o:logging.level=trace; fi
+
 if HAVE_LO_PATH
 check-local:
+   $(CLEANUP_COMMAND)
./fakesockettest
@fc-cache "@LO_PATH@"/share/fonts/truetype
 
@@ -228,71 +231,57 @@ TESTS = \
 
 # Start forced grouping of tests using stamp files
 
-# unit-base.log
-unit-tiletest.log : unit-base.log
-unit-integration.log : unit-base.log
-unit-httpws.log : unit-base.log
-unit-crash.log : unit-base.log
-
-group1.log: unit-httpws.log unit-crash.log unit-tiletest.log 
unit-integration.log
-   touch $@
-
-unit-typing.log : group1.log
-unit-convert.log: group1.log
-unit-tilecache.log  : group1.log
-unit-timeout.log: group1.log
-
-group1a.log: unit-typing.log unit-convert.log unit-tilecache.log 
unit-timeout.log
-   touch $@
-
 # isolate this one - it's not a happy test.
-unit-copy-paste.log : group1a.log
-
-group2.log: unit-copy-paste.log
-   touch $@
-
-unit-prefork.log : group2.log
-unit-oauth.log : group2.log
-unit-wopi.log : group2.log
-unit-wopi-saveas.log : group2.log
-unit-wopi-ownertermination.log : group2.log
-unit-wopi-versionrestore.log : group2.log
-uni

[Libreoffice-commits] online.git: android/lib common/Common.hpp common/FileUtil.cpp common/FileUtil.hpp common/JailUtil.cpp common/JailUtil.hpp common/Log.hpp common/security.h common/Session.cpp comm

2020-06-30 Thread Ashod Nakashian (via logerrit)
 Makefile.am|4 
 android/lib/src/main/cpp/CMakeLists.txt.in |1 
 common/Common.hpp  |2 
 common/FileUtil.cpp|   52 +++-
 common/FileUtil.hpp|   43 +++
 common/JailUtil.cpp|  364 +
 common/JailUtil.hpp|   70 +
 common/Log.hpp |1 
 common/Session.cpp |1 
 common/SigUtil.cpp |1 
 common/Util.cpp|   26 +-
 common/Util.hpp|   23 +
 common/security.h  |1 
 configure.ac   |2 
 debian/loolwsd.postinst.in |1 
 docker/Ubuntu  |1 
 kit/ForKit.cpp |   21 +
 kit/Kit.cpp|  199 ++-
 loolwsd-systemplate-setup  |5 
 loolwsd.spec.in|2 
 loolwsd.xml.in |1 
 net/Socket.cpp |1 
 net/Socket.hpp |1 
 test/run_unit.sh.in|2 
 tools/mount.cpp|  124 +
 wsd/LOOLWSD.cpp|   89 +++
 wsd/Storage.hpp|4 
 27 files changed, 836 insertions(+), 206 deletions(-)

New commits:
commit 5c9988f2e345ca82e7bb5f5e9bf66a30b82a0446
Author: Ashod Nakashian 
AuthorDate: Thu Apr 9 09:02:58 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 05:42:43 2020 +0200

wsd: faster jail setup via bind-mount

loolmount now works and supports mounting and
unmounting, plus numerous improvements,
refactoring, logging, etc..  When enabled,
binding improves the jail setup time by anywhere
from 2x to orders of magnitude (in docker, f.e.).

A new config entry mount_jail_tree controls
whether mounting is used or the old method of
linking/copying of jail contents. It is set to
true by default and falls back to linking/copying.
A test mount is done when the setting is enabled,
and if mounting fails, it's disabled to avoid noise.

Temporarily disabled for unit-tests until we can
cleanup lingering mounts after Jenkins aborts our
build job. In a future patch we will have mount/jail
cleanup as part of make.

The network/system files in /etc that need frequent
refreshing are now updated in systemplate to make
their most recent version available in the jails.
These files can change during the course of loolwsd
lifetime, and are unlikely to be updated in
systemplate after installation at all. We link to
them in the systemplate/etc directory, and if that
fails, we copy them before forking each kit
instance to have the latest.

This reworks the approach used to bind-mount the
jails and the templates such that the total is
now down to only three mounts: systemplate, lo, tmp.

As now systemplate and lotemplate are shared, they
must be mounted as readonly, this means that user/
must now be moved into tmp/user/ which is writable.

The mount-points must be recursive, because we mount
lo/ within the mount-point of systemplate (which is
the root of the jail). But because we (re)bind
recursively, and because both systemplate and
lotemplate are mounted for each jails, we need to
make them unbindable, so they wouldn't multiply the
mount-points for each jails (an explosive growth!)
Contrarywise, we don't want the mount-points to
be shared, because we don't expect to add/remove
mounts after a jail is created.

The random temp directory is now created and set
correctly, plus many logging and other improvements.

Change-Id: Iae3fda5e876cf47d2cae6669a87b5b826a8748df
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92829
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
    Reviewed-by: Ashod Nakashian 

diff --git a/Makefile.am b/Makefile.am
index 171a07e36..d3f18e6a3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@ export ENABLE_DEBUG
 
 bin_PROGRAMS = \
loolforkit \
+   loolmount \
loolconvert loolconfig
 
 if ENABLE_LIBFUZZER
@@ -87,6 +88,7 @@ AM_ETAGSFLAGS = --c++-kinds=+p --fields=+iaS --extra=+q -R 
--totals=yes --exclud
 AM_CTAGSFLAGS = $(AM_ETAGSFLAGS)
 
 shared_sources = common/FileUtil.cpp \
+ common/JailUtil.cpp \
  common/Log.cpp \
  common/Protocol.cpp \
  common/StringVector.cpp \
@@ -131,7 +133,6 @@ noinst_PROGRAMS = clientnb \
   lokitclient \
   loolmap \
   loolstress \
-   

[Libreoffice-commits] online.git: wsd/AdminModel.hpp

2020-06-22 Thread Ashod Nakashian (via logerrit)
 wsd/AdminModel.hpp |   72 +
 1 file changed, 35 insertions(+), 37 deletions(-)

New commits:
commit fa749d0a355ec3b0a2437d8cfc663e4ab2a3e0e9
Author: Ashod Nakashian 
AuthorDate: Wed Jun 3 10:46:23 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 23 06:43:38 2020 +0200

wsd: std::move rather than copy

Change-Id: Ie5e3f711d4cda686408624f849f3f7d7dfb549b8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96380
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index 0a038ad20..43da0cd1d 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -25,12 +25,12 @@ struct DocumentAggregateStats;
 class View
 {
 public:
-View(const std::string& sessionId, const std::string& userName, const 
std::string& userId) :
-_sessionId(sessionId),
-_userName(userName),
-_userId(userId),
-_start(std::time(nullptr)),
-_loadDuration(0)
+View(std::string sessionId, std::string userName, std::string userId)
+: _sessionId(std::move(sessionId))
+, _userName(std::move(userName))
+, _userId(std::move(userId))
+, _start(std::time(nullptr))
+, _loadDuration(0)
 {
 }
 
@@ -106,11 +106,11 @@ class DocBasicInfo
 bool _saved;
 
 public:
-DocBasicInfo(const std::string& docKey, std::time_t idleTime, int mem, 
bool saved) :
-_docKey(docKey),
-_idleTime(idleTime),
-_mem(mem),
-_saved(saved)
+DocBasicInfo(std::string docKey, std::time_t idleTime, int mem, bool saved)
+: _docKey(std::move(docKey))
+, _idleTime(idleTime)
+, _mem(mem)
+, _saved(saved)
 {
 }
 
@@ -131,29 +131,27 @@ class Document
 Document& operator = (const Document &) = delete;
 
 public:
-Document(const std::string& docKey,
- pid_t pid,
- const std::string& filename)
-: _docKey(docKey),
-  _pid(pid),
-  _activeViews(0),
-  _filename(filename),
-  _memoryDirty(0),
-  _lastJiffy(0),
-  _lastCpuPercentage(0),
-  _start(std::time(nullptr)),
-  _lastActivity(_start),
-  _end(0),
-  _sentBytes(0),
-  _recvBytes(0),
-  _wopiDownloadDuration(0),
-  _wopiUploadDuration(0),
-  _procSMaps(nullptr),
-  _lastTimeSMapsRead(0),
-  _isModified(false),
-  _hasMemDirtyChanged(true),
-  _badBehaviorDetectionTime(0),
-  _abortTime(0)
+Document(std::string docKey, pid_t pid, std::string filename)
+: _docKey(std::move(docKey))
+, _pid(pid)
+, _activeViews(0)
+, _filename(std::move(filename))
+, _memoryDirty(0)
+, _lastJiffy(0)
+, _lastCpuPercentage(0)
+, _start(std::time(nullptr))
+, _lastActivity(_start)
+, _end(0)
+, _sentBytes(0)
+, _recvBytes(0)
+, _wopiDownloadDuration(0)
+, _wopiUploadDuration(0)
+, _procSMaps(nullptr)
+, _lastTimeSMapsRead(0)
+, _isModified(false)
+, _hasMemDirtyChanged(true)
+, _badBehaviorDetectionTime(0)
+, _abortTime(0)
 {
 }
 
@@ -264,9 +262,9 @@ private:
 class Subscriber
 {
 public:
-Subscriber(const std::weak_ptr& ws)
-: _ws(ws),
-  _start(std::time(nullptr))
+explicit Subscriber(std::weak_ptr ws)
+: _ws(std::move(ws))
+, _start(std::time(nullptr))
 {
 LOG_INF("Subscriber ctor.");
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp

2020-06-22 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |2 ++
 wsd/DocumentBroker.hpp |2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 17044ade27ec94f135b95350a8a96ae7696049a2
Author: Ashod Nakashian 
AuthorDate: Wed Jun 3 12:30:40 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 23 06:42:53 2020 +0200

wsd: fix: call to virtual function during destruction

Change-Id: I914025fe642f6c78d4a5731fdb8e8920a62838b1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96379
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index f62241808..c242da586 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -2325,6 +2325,8 @@ void ConvertToBroker::dispose()
 
 ConvertToBroker::~ConvertToBroker()
 {
+// Calling a virtual function from a dtor
+// is only valid if there are no inheritors.
 dispose();
 }
 
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 17300d0cb..42d506629 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -442,7 +442,7 @@ private:
 };
 
 #if !MOBILEAPP
-class ConvertToBroker : public DocumentBroker
+class ConvertToBroker final : public DocumentBroker
 {
 const std::string _format;
 const std::string _sOptions;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/MessageQueue.cpp test/UnitCopyPaste.cpp wsd/Admin.cpp wsd/ClientSession.cpp wsd/LOOLWSD.cpp

2020-06-22 Thread Ashod Nakashian (via logerrit)
 common/MessageQueue.cpp |2 +-
 test/UnitCopyPaste.cpp  |2 +-
 wsd/Admin.cpp   |2 +-
 wsd/ClientSession.cpp   |2 +-
 wsd/LOOLWSD.cpp |2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 4a57654d884539406f6b87f937f7d3b79e780545
Author: Ashod Nakashian 
AuthorDate: Tue Jun 2 23:17:04 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 23 06:41:58 2020 +0200

wsd: avoid unnecessary string ops

Change-Id: Ia5a6f2d7a260edaf8bb294693be12a434a2c30fe
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96376
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/common/MessageQueue.cpp b/common/MessageQueue.cpp
index a57525984..064a27717 100644
--- a/common/MessageQueue.cpp
+++ b/common/MessageQueue.cpp
@@ -162,7 +162,7 @@ bool extractRectangle(const StringVector& tokens, int& x, 
int& y, int& w, int& h
 if (tokens.size() < 5)
 return false;
 
-if (tokens[3] == "EMPTY,")
+if (tokens.equals(3, "EMPTY,"))
 {
 part = std::atoi(tokens[4].c_str());
 return true;
diff --git a/test/UnitCopyPaste.cpp b/test/UnitCopyPaste.cpp
index 17f7ba381..8b8e6af70 100644
--- a/test/UnitCopyPaste.cpp
+++ b/test/UnitCopyPaste.cpp
@@ -108,7 +108,7 @@ public:
 std::string value;
 
 // allow empty clipboards
-if (clipboard && mimeType == "" && content == "")
+if (clipboard && mimeType.empty() && content.empty())
 return true;
 
 if (!clipboard || !clipboard->findType(mimeType, value))
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index c1aec45da..8d0c9373d 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -606,7 +606,7 @@ unsigned Admin::getNetStatsInterval()
 
 std::string Admin::getChannelLogLevels()
 {
-std::string result = "";
+std::string result;
 // Get the list of channels..
 std::vector nameList;
 Log::logger().names(nameList);
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 904867b18..614a75fed 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -452,7 +452,7 @@ bool ClientSession::_handleInput(const char *buffer, int 
length)
 sendTextFrameAndLogError("error: cmd=" + tokens[0] + " kind=unknown");
 return false;
 }
-else if (getDocURL() == "")
+else if (getDocURL().empty())
 {
 sendTextFrameAndLogError("error: cmd=" + tokens[0] + " 
kind=nodocloaded");
 return false;
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 587c22160..96be14b4e 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2769,7 +2769,7 @@ private:
 ConvertToPartHandler handler(/*convertTo =*/ true);
 HTMLForm form(request, message, handler);
 
-std::string sOptions("");
+std::string sOptions;
 std::string format = (form.has("format") ? form.get("format") : 
"");
 std::string sFullSheetPreview = (form.has("FullSheetPreview") ? 
form.get("FullSheetPreview") : "");
 bool bFullSheetPreview = sFullSheetPreview == "true" ? true : 
false;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/Message.hpp common/StringVector.hpp

2020-06-22 Thread Ashod Nakashian (via logerrit)
 common/Message.hpp  |8 
 common/StringVector.hpp |   13 +
 2 files changed, 17 insertions(+), 4 deletions(-)

New commits:
commit f7d42c045ab1e52c9eaa6f4aa0ce7ed910b026c5
Author: Ashod Nakashian 
AuthorDate: Wed Jun 3 17:54:57 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 23 06:42:25 2020 +0200

wsd: use more efficient StringVector::equals

Change-Id: Ib9a431fa5f8ba95a2ef76baca22b05ed28ebad79
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96377
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/common/Message.hpp b/common/Message.hpp
index 7bbadd172..c02625dfb 100644
--- a/common/Message.hpp
+++ b/common/Message.hpp
@@ -140,10 +140,10 @@ private:
 
 Type detectType() const
 {
-if (_tokens[0] == "tile:" ||
-_tokens[0] == "tilecombine:" ||
-_tokens[0] == "renderfont:" ||
-_tokens[0] == "windowpaint:")
+if (_tokens.equals(0, "tile:") ||
+_tokens.equals(0, "tilecombine:") ||
+_tokens.equals(0, "renderfont:") ||
+_tokens.equals(0, "windowpaint:"))
 {
 return Type::Binary;
 }
diff --git a/common/StringVector.hpp b/common/StringVector.hpp
index f995c0b0f..c414beb4f 100644
--- a/common/StringVector.hpp
+++ b/common/StringVector.hpp
@@ -125,6 +125,19 @@ public:
 return _string.compare(token._index, token._length, string) == 0;
 }
 
+/// Compares the nth token with string.
+template 
+bool equals(std::size_t index, const char (&string)[N]) const
+{
+if (index >= _tokens.size())
+{
+return false;
+}
+
+const StringToken& token = _tokens[index];
+return _string.compare(token._index, token._length, string, N) == 0;
+}
+
 /// Compares the nth token with the mth token from an other StringVector.
 bool equals(std::size_t index, const StringVector& other, std::size_t 
otherIndex);
 };
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: common/Util.hpp

2020-06-22 Thread Ashod Nakashian (via logerrit)
 common/Util.hpp |   48 
 1 file changed, 48 insertions(+)

New commits:
commit 8e784f2bdd9cc789fe896a31d13d22aa8d39e0bb
Author: Ashod Nakashian 
AuthorDate: Sat Jun 20 14:06:41 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 23 06:38:34 2020 +0200

wsd: tokenization and hexify utils

Change-Id: I3a8eb39092ad5ed1a8589c05a893fd0ce6445e8b
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96827
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/common/Util.hpp b/common/Util.hpp
index 9c82b3068..f6ca50825 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -224,6 +224,21 @@ namespace Util
 return os.str();
 }
 
+/// Dump a string as hex by splitting on multiple lines per width.
+/// Useful for debugging and logging data that contain non-printables.
+inline std::string stringifyHexLine(const std::string& s, const 
std::size_t width = 16)
+{
+std::ostringstream oss;
+for (std::size_t i = 0; i < s.size(); i += width)
+{
+const std::size_t rem = std::min(width, s.size() - i);
+oss << stringifyHexLine(std::vector(s.data(), s.data() + 
s.size()), i, rem);
+oss << '\n';
+}
+
+return oss.str();
+}
+
 /// Dump data as hex and chars to stream
 inline void dumpHex (std::ostream &os, const char *legend, const char 
*prefix,
  const std::vector &buffer, bool skipDup = true,
@@ -433,6 +448,39 @@ namespace Util
 return StringVector(s, std::move(tokens));
 }
 
+/// Tokenize by the delimiter string.
+inline StringVector tokenize(const std::string& s, const char* delimiter, 
int len = -1)
+{
+if (s.empty() || len == 0 || delimiter == nullptr || *delimiter == 
'\0')
+return StringVector();
+
+if (len < 0)
+len = std::strlen(delimiter);
+
+std::size_t start = 0;
+std::size_t end = s.find(delimiter, start);
+
+std::vector tokens;
+tokens.reserve(16);
+
+tokens.emplace_back(start, end - start);
+start = end + len;
+
+while (end != std::string::npos)
+{
+end = s.find(delimiter, start);
+tokens.emplace_back(start, end - start);
+start = end + len;
+}
+
+return StringVector(s, std::move(tokens));
+}
+
+inline StringVector tokenize(const std::string& s, const std::string& 
delimiter)
+{
+return tokenize(s, delimiter.data(), delimiter.size());
+}
+
 /** Tokenize based on any of the characters in 'delimiters'.
 
 Ie. when there is '\n\r' in there, any of them means a delimiter.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp wsd/Storage.hpp

2020-06-20 Thread Ashod Nakashian (via logerrit)
 wsd/Storage.cpp |   71 
 wsd/Storage.hpp |6 
 2 files changed, 42 insertions(+), 35 deletions(-)

New commits:
commit 2c73b622d75ee6fa62b7d74e1548cda877201af8
Author: Ashod Nakashian 
AuthorDate: Sun Jun 14 12:44:10 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Sat Jun 20 16:33:20 2020 +0200

wsd: extract WOPI HTTP request construction

This hoists the common parts of the HTTPRequest
for all WOPI requests to avoid errors when changing them.

Change-Id: Ia02ef657a43b7a7d2fc13be3da012836fa0d7650
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96372
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 1da4eaf74..61823d67e 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -529,6 +529,23 @@ void LockContext::dumpState(std::ostream& os) const
 
 #if !MOBILEAPP
 
+void WopiStorage::initHttpRequest(Poco::Net::HTTPRequest& request, const 
Poco::URI& uri,
+  const Authorization& auth, const 
std::string& cookies) const
+{
+request.set("User-Agent", WOPI_AGENT_STRING);
+
+auth.authorizeRequest(request);
+
+addStorageDebugCookie(request);
+
+// TODO: Avoid repeated parsing.
+std::map params = GetQueryParams(uri);
+addWopiProof(request, uri, params["access_token"]);
+
+if (_reuseCookies)
+addStorageReuseCookie(request, cookies);
+}
+
 std::unique_ptr WopiStorage::getWOPIFileInfo(const 
Authorization& auth,
 const 
std::string& cookies,
 
LockContext& lockCtx)
@@ -537,7 +554,6 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 Poco::URI uriObject(getUri());
 auth.authorizeURI(uriObject);
 const std::string uriAnonym = LOOLWSD::anonymizeUrl(uriObject.toString());
-std::map params = GetQueryParams(uriObject);
 
 LOG_DBG("Getting info for wopi uri [" << uriAnonym << "].");
 
@@ -545,13 +561,11 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 std::chrono::duration callDuration(0);
 try
 {
-Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
-request.set("User-Agent", WOPI_AGENT_STRING);
-auth.authorizeRequest(request);
-addStorageDebugCookie(request);
-if (_reuseCookies)
-addStorageReuseCookie(request, cookies);
-addWopiProof(request, uriObject, params["access_token"]);
+Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET,
+   uriObject.getPathAndQuery(),
+   Poco::Net::HTTPMessage::HTTP_1_1);
+initHttpRequest(request, uriObject, auth, cookies);
+
 const auto startTime = std::chrono::steady_clock::now();
 
 std::unique_ptr 
psession(getHTTPClientSession(uriObject));
@@ -760,8 +774,6 @@ bool WopiStorage::updateLockState(const Authorization& 
auth, const std::string&
 Poco::URI uriObject(getUri());
 auth.authorizeURI(uriObject);
 
-std::map params = GetQueryParams(uriObject);
-
 Poco::URI uriObjectAnonym(getUri());
 uriObjectAnonym.setPath(LOOLWSD::anonymizeUrl(uriObjectAnonym.getPath()));
 const std::string uriAnonym = uriObjectAnonym.toString();
@@ -773,18 +785,15 @@ bool WopiStorage::updateLockState(const Authorization& 
auth, const std::string&
 {
 std::unique_ptr 
psession(getHTTPClientSession(uriObject));
 
-Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, 
uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
-request.set("User-Agent", WOPI_AGENT_STRING);
-auth.authorizeRequest(request);
+Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST,
+   uriObject.getPathAndQuery(),
+   Poco::Net::HTTPMessage::HTTP_1_1);
+initHttpRequest(request, uriObject, auth, cookies);
 
 request.set("X-WOPI-Override", lock ? "LOCK" : "UNLOCK");
 request.set("X-WOPI-Lock", lockCtx._lockToken);
 if (!getExtendedData().empty())
 request.set("X-LOOL-WOPI-ExtendedData", getExtendedData());
-addStorageDebugCookie(request);
-if (_reuseCookies)
-addStorageReuseCookie(request, cookies);
-addWopiProof(request, uriObject, params["access_token"]);
 
 psession->sendRequest(request);
 Poco::Net::HTTPResponse response;
@@ -833,8 +842,6 @@ std::string WopiStorage::loadStorageFile

[Libreoffice-commits] online.git: loleaflet/js wsd/LOOLWSD.cpp

2020-06-02 Thread Ashod Nakashian (via logerrit)
 loleaflet/js/global.js |   11 +--
 wsd/LOOLWSD.cpp|6 +++---
 2 files changed, 12 insertions(+), 5 deletions(-)

New commits:
commit 4513318e58ed22709637374918fec3a95ad5dcab
Author: Ashod Nakashian 
AuthorDate: Mon Jun 1 08:18:13 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 2 20:05:19 2020 +0200

wsd: leaflet: fix reuse_cookies support

reuse_cookies is now always encoded in the URL.

And, there is no need for the WOPISrc in the three cases
in this patch, and by passing the DocumentURI proper
(without /ws?WOPISrc=...) ensures that all query-params
in the DocumentURI are properly processed.

This fixes the reuse_cookies regression where it
wasn't passed to WOPI requests.

Change-Id: I8dccfb09a7b4102d10c1aef24f43b699a07bfed8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95293
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index 20757e2a5..1c951b089 100644
--- a/loleaflet/js/global.js
+++ b/loleaflet/js/global.js
@@ -653,9 +653,16 @@
else if (global.accessHeader !== '') {
wopiParams = { 'access_header': global.accessHeader };
}
-   else if (global.reuseCookies !== '') {
-   wopiParams = { 'reuse_cookies': global.reuseCookies };
+
+   if (global.reuseCookies !== '') {
+   if (wopiParams) {
+   wopiParams['reuse_cookies'] = 
global.reuseCookies;
+   }
+   else {
+   wopiParams = { 'reuse_cookies': 
global.reuseCookies };
+   }
}
+
if (wopiParams) {
docParams = Object.keys(wopiParams).map(function(key) {
return encodeURIComponent(key) + '=' + 
encodeURIComponent(wopiParams[key]);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 51bd22e38..db7bfbaef 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2810,7 +2810,7 @@ private:
 const std::string formName(form.get("name"));
 
 // Validate the docKey
-const std::string decodedUri = 
requestDetails.getLegacyDocumentURI();
+const std::string decodedUri = requestDetails.getDocumentURI();
 const std::string docKey = 
DocumentBroker::getDocKey(DocumentBroker::sanitizeURI(decodedUri));
 
 std::unique_lock docBrokersLock(DocBrokersMutex);
@@ -2846,7 +2846,7 @@ private:
 // TODO: Check that the user in question has access to this file!
 
 // 1. Validate the dockey
-const std::string decodedUri = 
requestDetails.getLegacyDocumentURI();
+const std::string decodedUri = requestDetails.getDocumentURI();
 const std::string docKey = 
DocumentBroker::getDocKey(DocumentBroker::sanitizeURI(decodedUri));
 
 std::unique_lock docBrokersLock(DocBrokersMutex);
@@ -3025,7 +3025,7 @@ private:
SocketDisposition& disposition,
const std::shared_ptr& socket)
 {
-const std::string url = requestDetails.getLegacyDocumentURI();
+const std::string url = requestDetails.getDocumentURI();
 assert(socket && "Must have a valid socket");
 
 // must be trace for anonymization
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: test/WhiteBoxTests.cpp wsd/LOOLWSD.cpp wsd/ProxyProtocol.cpp wsd/RequestDetails.cpp wsd/RequestDetails.hpp

2020-06-02 Thread Ashod Nakashian (via logerrit)
 test/WhiteBoxTests.cpp |  262 +
 wsd/LOOLWSD.cpp|   27 ++---
 wsd/ProxyProtocol.cpp  |   13 --
 wsd/RequestDetails.cpp |  146 ++-
 wsd/RequestDetails.hpp |  142 --
 5 files changed, 513 insertions(+), 77 deletions(-)

New commits:
commit d06ad733c50e2d34cebcae445716fb5110242006
Author: Ashod Nakashian 
AuthorDate: Mon May 25 10:52:37 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 2 20:04:48 2020 +0200

wsd: improved RequestDetails parsing and documentation

...with support for properly extracting the different
fields with unit-test.

URIs are quite complex and varied. For historic reasons
they have all been treated without distinction, which
makes support for all variants difficult. RequestDetails
encapsulates this complexity, and now it is almost
completely documented both descriptively and functionally
(via extensive unit-tests).

Parsing of the URIs is now more structured by having
named fields instead of relying on knowing which
token should contain which field, which is error-prone
and very opaque.

Change-Id: I68d07c2e00baf43f0ade97d20f62691ffb3bf576
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95292
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp
index e8290cd2f..bb2f57e4c 100644
--- a/test/WhiteBoxTests.cpp
+++ b/test/WhiteBoxTests.cpp
@@ -879,8 +879,12 @@ void WhiteBoxTests::testRequestDetails_DownloadURI()
 
 RequestDetails details(request, "");
 
+// LOK_ASSERT_EQUAL(URI, details.getDocumentURI());
+
 LOK_ASSERT_EQUAL(static_cast(5), details.size());
 LOK_ASSERT_EQUAL(std::string("loleaflet"), details[0]);
+LOK_ASSERT_EQUAL(std::string("loleaflet"), 
details.getField(RequestDetails::Field::Type));
+LOK_ASSERT(details.equals(RequestDetails::Field::Type, "loleaflet"));
 LOK_ASSERT(details.equals(0, "loleaflet"));
 LOK_ASSERT_EQUAL(std::string("49c225146"), details[1]);
 LOK_ASSERT_EQUAL(std::string("src"), details[2]);
@@ -897,8 +901,12 @@ void WhiteBoxTests::testRequestDetails_DownloadURI()
 
 RequestDetails details(request, "");
 
+// LOK_ASSERT_EQUAL(URI, details.getDocumentURI());
+
 LOK_ASSERT_EQUAL(static_cast(3), details.size());
 LOK_ASSERT_EQUAL(std::string("loleaflet"), details[0]);
+LOK_ASSERT_EQUAL(std::string("loleaflet"), 
details.getField(RequestDetails::Field::Type));
+LOK_ASSERT(details.equals(RequestDetails::Field::Type, "loleaflet"));
 LOK_ASSERT(details.equals(0, "loleaflet"));
 LOK_ASSERT_EQUAL(std::string("49c225146"), details[1]);
 LOK_ASSERT_EQUAL(std::string("select2.css"), details[2]);
@@ -921,8 +929,15 @@ void WhiteBoxTests::testRequestDetails_loleafletURI()
 
 RequestDetails details(request, "");
 
+const std::string wopiSrc
+= 
"http://localhost/nextcloud/index.php/apps/richdocuments/wopi/files/593_ocqiesh0cngs";;
+
+LOK_ASSERT_EQUAL(wopiSrc, 
details.getField(RequestDetails::Field::WOPISrc));
+
 LOK_ASSERT_EQUAL(static_cast(4), details.size());
 LOK_ASSERT_EQUAL(std::string("loleaflet"), details[0]);
+LOK_ASSERT_EQUAL(std::string("loleaflet"), 
details.getField(RequestDetails::Field::Type));
+LOK_ASSERT(details.equals(RequestDetails::Field::Type, "loleaflet"));
 LOK_ASSERT(details.equals(0, "loleaflet"));
 LOK_ASSERT_EQUAL(std::string("49c225146"), details[1]);
 LOK_ASSERT_EQUAL(std::string("loleaflet.html"), details[2]);
@@ -960,6 +975,7 @@ void WhiteBoxTests::testRequestDetails_local()
 
 const std::string docUri = 
"file:///home/ash/prj/lo/online/test/data/hello-world.odt";
 
+LOK_ASSERT_EQUAL(docUri, details.getLegacyDocumentURI());
 LOK_ASSERT_EQUAL(docUri, details.getDocumentURI());
 
 LOK_ASSERT_EQUAL(static_cast(6), details.size());
@@ -973,9 +989,19 @@ void WhiteBoxTests::testRequestDetails_local()
 LOK_ASSERT_EQUAL(std::string("open"), details[3]);
 LOK_ASSERT_EQUAL(std::string("open"), details[4]);
 LOK_ASSERT_EQUAL(std::string("0"), details[5]);
+
+LOK_ASSERT_EQUAL(std::string("lool"), 
details.getField(RequestDetails::Field::Type));
+LOK_ASSERT(details.equals(RequestDetails::Field::Type, "lool"));
+LOK_ASSERT_EQUAL(std::string("open"), 
details.getField(RequestDetails::Field::SessionId));
+LOK_ASSERT(details.equals(RequestDetails::Field::SessionId, "open"));
+LOK_ASSERT_EQUAL(std::stri

[Libreoffice-commits] online.git: test/WhiteBoxTests.cpp wsd/RequestDetails.cpp

2020-06-02 Thread Ashod Nakashian (via logerrit)
 test/WhiteBoxTests.cpp |   41 +++--
 wsd/RequestDetails.cpp |4 ++--
 2 files changed, 17 insertions(+), 28 deletions(-)

New commits:
commit 1ee57ba1d043df8681793b15f08e3a7359fcccad
Author: Ashod Nakashian 
AuthorDate: Mon May 25 07:51:04 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 2 20:01:59 2020 +0200

wsd: proxy: correctly parse single-char fields in the URI

...instead of skipping them.

And add tests to defend the fix.

Change-Id: I8585cc3592841c8ad16d3804dc09a2a3b3a3bb71
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95291
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp
index a97451172..e8290cd2f 100644
--- a/test/WhiteBoxTests.cpp
+++ b/test/WhiteBoxTests.cpp
@@ -940,7 +940,9 @@ void WhiteBoxTests::testRequestDetails_local()
 = "http://localhost/nextcloud/apps/richdocuments/proxy.php?req=";;
 
 {
-static const std::string URI = 
"/lool/file%3A%2F%2F%2Fhome%2Fash%2Fprj%2Flo%2Fonline%2Ftest%2Fdata%2Fhello-world.odt/ws/open/open/0";
+static const std::string URI = "/lool/"
+   
"file%3A%2F%2F%2Fhome%2Fash%2Fprj%2Flo%2Fonline%2Ftest%"
+   
"2Fdata%2Fhello-world.odt/ws/open/open/0";
 
 Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, URI,
Poco::Net::HTTPMessage::HTTP_1_1);
@@ -960,7 +962,7 @@ void WhiteBoxTests::testRequestDetails_local()
 
 LOK_ASSERT_EQUAL(docUri, details.getDocumentURI());
 
-LOK_ASSERT_EQUAL(static_cast(5), details.size());
+LOK_ASSERT_EQUAL(static_cast(6), details.size());
 LOK_ASSERT_EQUAL(std::string("lool"), details[0]);
 LOK_ASSERT(details.equals(0, "lool"));
 LOK_ASSERT_EQUAL(
@@ -970,18 +972,13 @@ void WhiteBoxTests::testRequestDetails_local()
 LOK_ASSERT_EQUAL(std::string("ws"), details[2]);
 LOK_ASSERT_EQUAL(std::string("open"), details[3]);
 LOK_ASSERT_EQUAL(std::string("open"), details[4]);
+LOK_ASSERT_EQUAL(std::string("0"), details[5]);
 }
 
 {
-static const std::string URI
-= "/lool/"
-  
"http%3A%2F%2Flocalhost%2Fowncloud%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%"
-  
"2F165_ocgdpzbkm39u%3Faccess_token%3DODhIXdJdbsVYQoKKCuaYofyzrovxD3MQ%26access_token_"
-  "ttl%"
-  
"3D0%26reuse_cookies%3DXCookieName%253DXCookieValue%253ASuperCookieName%253DBAZINGA/"
-  
"ws?WOPISrc=http%3A%2F%2Flocalhost%2Fowncloud%2Findex.php%2Fapps%2Frichdocuments%"
-  "2Fwopi%"
-  
"2Ffiles%2F165_ocgdpzbkm39u&compat=/ws/1c99a7bcdbf3209782d7eb38512e6564/write/2";
+static const std::string URI = "/lool/"
+   
"file%3A%2F%2F%2Fhome%2Fash%2Fprj%2Flo%2Fonline%2Ftest%"
+   "2Fdata%2Fhello-world.odt/ws//write/2";
 
 Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, URI,
Poco::Net::HTTPMessage::HTTP_1_1);
@@ -997,12 +994,7 @@ void WhiteBoxTests::testRequestDetails_local()
 LOK_ASSERT_EQUAL(false, details.isWebSocket());
 LOK_ASSERT_EQUAL(true, details.isGet());
 
-const std::string docUri
-= 
"http://localhost/owncloud/index.php/apps/richdocuments/wopi/files/";
-  
"165_ocgdpzbkm39u?access_token=ODhIXdJdbsVYQoKKCuaYofyzrovxD3MQ&access_token_ttl=0&"
-  
"reuse_cookies=XCookieName%3DXCookieValue%3ASuperCookieName%3DBAZINGA/"
-  
"ws?WOPISrc=http://localhost/owncloud/index.php/apps/richdocuments/wopi/files/";
-  "165_ocgdpzbkm39u&compat=";
+const std::string docUri = 
"file:///home/ash/prj/lo/online/test/data/hello-world.odt";
 
 LOK_ASSERT_EQUAL(docUri, details.getDocumentURI());
 
@@ -1010,16 +1002,12 @@ void WhiteBoxTests::testRequestDetails_local()
 LOK_ASSERT_EQUAL(std::string("lool"), details[0]);
 LOK_ASSERT(details.equals(0, "lool"));
 LOK_ASSERT_EQUAL(
-
std::string("http%3A%2F%2Flocalhost%2Fowncloud%2Findex.php%2Fapps%2Frichdocuments%"
-"2Fwopi%2Ffiles%2F165_ocgdpzbkm39u%3Faccess_token%"
-
"3DODhIXdJdbsVYQoKKCuaYofyzrovxD3MQ%26access_token_ttl%3D0%26reuse_cookies%"
-
"3DXCookieName%253DXCookieValue%253ASuperCookieName%253DBAZINGA/"
-  

[Libreoffice-commits] online.git: common/Rectangle.hpp common/Util.hpp kit/Kit.cpp wsd/Admin.cpp wsd/Admin.hpp wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/LOOLWSD.cpp wsd/ProxyProtocol.cpp

2020-06-02 Thread Ashod Nakashian (via logerrit)
 common/Rectangle.hpp  |1 +
 common/Util.hpp   |5 ++---
 kit/Kit.cpp   |3 ++-
 wsd/Admin.cpp |2 +-
 wsd/Admin.hpp |2 +-
 wsd/ClientSession.cpp |4 ++--
 wsd/ClientSession.hpp |2 +-
 wsd/LOOLWSD.cpp   |3 ++-
 wsd/ProxyProtocol.cpp |6 +++---
 9 files changed, 15 insertions(+), 13 deletions(-)

New commits:
commit 4a8937d0d1a2665f3700c4ea14d5f70e844b7064
Author: Ashod Nakashian 
AuthorDate: Tue Jun 2 03:44:08 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 2 20:01:39 2020 +0200

wsd: performance improvements

Change-Id: I137dc67b4231df1cd23a9dce72e6b12dc1bf364e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95343
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/common/Rectangle.hpp b/common/Rectangle.hpp
index 3e73bc251..0869d207f 100644
--- a/common/Rectangle.hpp
+++ b/common/Rectangle.hpp
@@ -9,6 +9,7 @@
 
 #pragma once
 
+#include  // std::min, std::max
 #include 
 
 namespace Util
diff --git a/common/Util.hpp b/common/Util.hpp
index d41f81319..fed1525e6 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -382,9 +382,8 @@ namespace Util
 return false;
 }
 
-/// Tokenize space-delimited values until we hit new-line or the end.
-template 
-inline void tokenize(const char* data, const std::size_t size, const T& 
delimiter,
+/// Tokenize delimited values until we hit new-line or the end.
+inline void tokenize(const char* data, const std::size_t size, const char 
delimiter,
  std::vector& tokens)
 {
 if (size == 0 || data == nullptr || *data == '\0')
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 9fbc658b4..743251fef 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -69,6 +69,7 @@
 #if !MOBILEAPP
 #include 
 #include 
+#include 
 #endif
 
 #ifdef FUZZER
@@ -2226,7 +2227,7 @@ public:
 
 void setDocument(std::shared_ptr document)
 {
-_document = document;
+_document = std::move(document);
 }
 };
 
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 3f48a0d8a..8d85dfbc7 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -602,7 +602,7 @@ std::string Admin::getChannelLogLevels()
 return result;
 }
 
-void Admin::setChannelLogLevel(std::string _channelName, std::string _level)
+void Admin::setChannelLogLevel(const std::string& _channelName, std::string 
_level)
 {
 assertCorrectThread();
 
diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp
index ae3967e06..42e7a247a 100644
--- a/wsd/Admin.hpp
+++ b/wsd/Admin.hpp
@@ -107,7 +107,7 @@ public:
 
 std::string getChannelLogLevels();
 
-void setChannelLogLevel(std::string _channelName, std::string _level);
+void setChannelLogLevel(const std::string& _channelName, std::string 
_level);
 
 std::string getLogLines();
 
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index d164a0d45..d534a2656 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1034,7 +1034,7 @@ void ClientSession::writeQueuedMessages()
 }
 
 // NB. also see loleaflet/src/map/Clipboard.js that does this in JS for stubs.
-void ClientSession::postProcessCopyPayload(std::shared_ptr payload)
+void ClientSession::postProcessCopyPayload(const std::shared_ptr& 
payload)
 {
 // Insert our meta origin if we can
 payload->rewriteDataBody([=](std::vector& data) {
@@ -1359,7 +1359,7 @@ bool ClientSession::handleKitToClientMessage(const char* 
buffer, const int lengt
 LOOLWSD::SavedClipboards->insertClipboard(
 _clipboardKeys, &payload->data()[header], payload->size() - 
header);
 
-for (auto it : _clipSockets)
+for (const auto& it : _clipSockets)
 {
 std::ostringstream oss;
 oss << "HTTP/1.1 200 OK\r\n"
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index c7d4e66ed..6103d0550 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -163,7 +163,7 @@ public:
 std::string getClipboardURI(bool encode = true);
 
 /// Adds and/or modified the copied payload before sending on to the 
client.
-void postProcessCopyPayload(std::shared_ptr payload);
+void postProcessCopyPayload(const std::shared_ptr& payload);
 
 /// Returns true if we're expired waiting for a clipboard and should be 
removed
 bool staleWaitDisconnect(const std::chrono::steady_clock::time_point &now);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 2b6bb013e..917ef33fb 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2567,7 +2567,7 @@ private:
 Poco::URI requestUri(request.getURI());
 Poco::URI::QueryParameters params = requestUri.getQueryParameters();
 std::string WOPISrc, serverId, viewId, tag, mime;
-for (auto it : params)
+for (const auto& it : params)
 {
 if (it.first == "WOPISrc")
   

  1   2   3   4   5   6   7   8   9   10   >