[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - xmloff/qa xmloff/source

2023-09-01 Thread Regina Henschel (via logerrit)
 xmloff/qa/unit/data/tdf157018_CustomTheme.fodg |  338 +
 xmloff/qa/unit/draw.cxx|   33 ++
 xmloff/source/draw/ximpstyl.cxx|7 
 3 files changed, 373 insertions(+), 5 deletions(-)

New commits:
commit f6004caf2c1f6b4935d6cb49284303ee34744919
Author: Regina Henschel 
AuthorDate: Thu Aug 31 01:15:26 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Sep 1 14:40:05 2023 +0200

tdf#157018 Enable import of color theme for Draw

Use the color theme import in Draw too, otherwise we will not be able
to detect theme colors.

Change-Id: I8f01ba69848a6265193407a952144b31e3a7fdb2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156313
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156394

diff --git a/xmloff/qa/unit/data/tdf157018_CustomTheme.fodg 
b/xmloff/qa/unit/data/tdf157018_CustomTheme.fodg
new file mode 100644
index ..49673ca66793
--- /dev/null
+++ b/xmloff/qa/unit/data/tdf157018_CustomTheme.fodg
@@ -0,0 +1,338 @@
+
+http://openoffice.org/2004/office; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:rpt="http://openoffice.org/2005/report; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:xforms="http://www.w3.org/2002/xforms; 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:dom="http://www.w3.org/2001/xml-events; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns
 :css3t="http://www.w3.org/TR/css3-text/; 
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" 
xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" 
xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.graphics">
+
+2023-08-29T21:49:18.19200
+PT1S
+1
+B2020/24.2.0.0.alpha0$Windows_X86_64 
LibreOffice_project/aa3eea21fcf302ef4ddbba5841037378945f9d5e
+
+
+
+
+13970
+10795
+0
+0
+
+
+view1
+false
+false
+true
+true
+false
+false
+false
+false
+true
+1500
+false
+Hw==
+Hw==
+
+false
+true
+true
+0
+0
+true
+true
+true
+4
+0
+-407
+-9321
+40625
+29064
+1270
+1270
+317
+317
+1270
+4
+1270
+4
+false
+1500
+true
+false
+false
+false
+false
+
+
+
+
+true
+  

[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - xmloff/qa xmloff/source

2023-09-01 Thread Regina Henschel (via logerrit)
 xmloff/qa/unit/draw.cxx |   57 
 xmloff/source/draw/sdxmlexp.cxx |5 ---
 2 files changed, 58 insertions(+), 4 deletions(-)

New commits:
commit 332c37dc19e0c0dc01258c09d2c1cfbf51840301
Author: Regina Henschel 
AuthorDate: Tue Aug 29 22:18:29 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Sep 1 13:33:33 2023 +0200

tdf#156975 Save a Theme in Draw too not only in Impress

Draw and Impress have many things in common and should therefore be
treated equally where possible.

Only if the theme colors are present in the document, colors can be
recognized as theme colors during import.

Change-Id: Ia1fae2aff989ae305c210efa3f925a80898880e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156267
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156393

diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx
index d71b41722783..cfb68ed0a109 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -668,6 +668,63 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, 
testTextRotationPlusPre)
 // But reload catches it.
 saveAndReload("writer8");
 }
+
+CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf156975_ThemeExport)
+{
+// It tests, that a theme is written to master page in Draw documents.
+// Without fix for tdf#156975 it was not written at all.
+// The test needs to be adapted, when themes are available in ODF.
+
+mxComponent = loadFromDesktop("private:factory/sdraw");
+// generate a theme to be sure we have got one and know the values
+uno::Reference 
xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
+uno::Reference xDrawPage(
+xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
+uno::Reference 
xMasterPageProps(xDrawPage->getMasterPage(),
+ uno::UNO_QUERY);
+
+auto pTheme = std::make_shared("Custom");
+auto pColorSet = std::make_shared("My Colors");
+pColorSet->add(model::ThemeColorType::Dark1, 0x00);
+pColorSet->add(model::ThemeColorType::Light1, 0x11);
+pColorSet->add(model::ThemeColorType::Dark2, 0x002200);
+pColorSet->add(model::ThemeColorType::Light2, 0xff33ff);
+pColorSet->add(model::ThemeColorType::Accent1, 0x44);
+pColorSet->add(model::ThemeColorType::Accent2, 0x005500);
+pColorSet->add(model::ThemeColorType::Accent3, 0x66);
+pColorSet->add(model::ThemeColorType::Accent4, 0x00);
+pColorSet->add(model::ThemeColorType::Accent5, 0x880088);
+pColorSet->add(model::ThemeColorType::Accent6, 0x00);
+pColorSet->add(model::ThemeColorType::Hyperlink, 0x0a0a0a);
+pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xb0b0b0);
+pTheme->setColorSet(pColorSet);
+
+uno::Reference xTheme = model::theme::createXTheme(pTheme);
+xMasterPageProps->setPropertyValue("Theme", uno::Any(xTheme));
+
+// save as odg
+save("draw8");
+
+// and check the markup.
+xmlDocUniquePtr pXmlDoc = parseExport("styles.xml");
+static constexpr OStringLiteral sThemePath
+= "//office:master-styles/style:master-page/loext:theme";
+assertXPath(pXmlDoc, sThemePath, 1);
+assertXPath(pXmlDoc, sThemePath + "[@loext:name='Custom']");
+
+const OString sThemeColorsPath = sThemePath + "/loext:theme-colors";
+assertXPath(pXmlDoc, sThemeColorsPath, 1);
+assertXPath(pXmlDoc, sThemeColorsPath + "[@loext:name='My Colors']");
+
+const OString sThemeColorPath = sThemeColorsPath + "/loext:color";
+assertXPath(pXmlDoc, sThemeColorPath, 12);
+assertXPath(pXmlDoc, sThemeColorPath + "[3]", "name", "dark2");
+assertXPath(pXmlDoc, sThemeColorPath + "[3]", "color", "#002200");
+assertXPath(pXmlDoc, sThemeColorPath + "[9]", "name", "accent5");
+assertXPath(pXmlDoc, sThemeColorPath + "[9]", "color", "#880088");
+assertXPath(pXmlDoc, sThemeColorPath + "[12]", "name", 
"followed-hyperlink");
+assertXPath(pXmlDoc, sThemeColorPath + "[12]", "color", "#b0b0b0");
+}
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 915c3e9360c0..6df6ade09d61 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -2301,10 +2301,7 @@ void SdXMLExport::ExportMasterStyles_()
 exportFormsElement( xMasterPage );
 
 // write optional loext:theme
-if (IsImpress())
-{
-ExportThemeElement(xMasterPage);
-}
+ExportThemeElement(xMasterPage);
 
 // write graphic objects on this master page (if any)
 if(xMasterPage.is() && xMasterPage->getCount())


[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - xmloff/qa xmloff/source

2023-08-15 Thread Miklos Vajna (via logerrit)
 xmloff/qa/unit/data/nested-spans.odt |binary
 xmloff/qa/unit/text.cxx  |   26 ++
 xmloff/source/text/txtparai.cxx  |   24 ++--
 3 files changed, 48 insertions(+), 2 deletions(-)

New commits:
commit 17c441d09c98443ac0d209b6aa6caa95fefc033e
Author: Miklos Vajna 
AuthorDate: Mon Aug 14 08:10:51 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue Aug 15 12:10:21 2023 +0200

tdf#156321 ODT import: fix lost char format on outer span elements

Regression from commit 209dce614c43f63f63f5b42a746665c0ec1cbfe3 (sw: fix
ODT import of paragraph marker formatting, 2022-12-20), the bugdoc has a
first paragraph with nested spans (the outer sets the boldness) and the
text does not appear as bold in Writer anymore.

What appears to be the problem is that our model is just a list of spans
for a paragraph, so nesting is converted to a list of spans, but now the
outer span char format is lost.

Fix the problem by making the condition of the 'no upgrade from char
format to para format' more strict: do this in case we have empty spans.
That fixes this new use-case and leaves the original one fixed.

Note that in the long run it may make sense to always disable the
upgrade from char format to para format, but that has to be done in a
way that does not break the import of nested spans.

Change-Id: Ie6fafb3e9649e50790c7ecae8e136e6600f3341e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155648
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins
(cherry picked from commit 2d0f43befdaa1010062b534dffa82adad8c956c8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155604
Reviewed-by: Xisco Fauli 

diff --git a/xmloff/qa/unit/data/nested-spans.odt 
b/xmloff/qa/unit/data/nested-spans.odt
new file mode 100644
index ..3e7b1dc9eb55
Binary files /dev/null and b/xmloff/qa/unit/data/nested-spans.odt differ
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index abd4a0e07dea..8c500dccce24 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -9,6 +9,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -1249,6 +1250,31 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testParagraphScopedTabDistance)
 assertXPath(pXmlDoc, "//text:p[@text:style-name='P1']");
 }
 
+CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testNestedSpans)
+{
+// Given a document with a first paragraph that has a nested span, the 
outer span setting the
+// boldness:
+// When importing that document:
+loadFromURL(u"nested-spans.odt");
+
+// Then make sure the text portion is bold, not normal:
+uno::Reference xTextDocument(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xParagraphsAccess(xTextDocument->getText(),
+
uno::UNO_QUERY);
+uno::Reference xParagraphs = 
xParagraphsAccess->createEnumeration();
+uno::Reference 
xParagraph(xParagraphs->nextElement(),
+ uno::UNO_QUERY);
+uno::Reference xPortions = 
xParagraph->createEnumeration();
+uno::Reference xTextPortion(xPortions->nextElement(), 
uno::UNO_QUERY);
+float fWeight{};
+xTextPortion->getPropertyValue("CharWeight") >>= fWeight;
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 150 (awt::FontWeight::BOLD)
+// - Actual  : 100 (awt::FontWeight::NORMAL)
+// i.e. the boldness was lost on import.
+CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, fWeight);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 5dc1b882b1b2..c777fa0c2929 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1852,9 +1853,28 @@ void XMLParaContext::endFastElement(sal_Int32 )
 {
 bool bSetNoFormatAttr = false;
 uno::Reference xCursorProps(xAttrCursor, 
uno::UNO_QUERY);
-if (m_xHints->GetHints().size() > 1 || m_aMarkerStyleName.hasValue())
+int nEmptyHints = 0;
+uno::Reference 
xCompare(xTxtImport->GetText(), uno::UNO_QUERY);
+if (xCompare.is())
 {
-// We have multiple hints, then make try to ask the cursor to not 
upgrade our character
+try
+{
+for (const auto& pHint : m_xHints->GetHints())
+{
+if (xCompare->compareRegionStarts(pHint->GetStart(), 
pHint->GetEnd()) == 0)
+{
+++nEmptyHints;
+}
+}
+}
+catch (const uno::Exception&)
+{
+TOOLS_WARN_EXCEPTION("xmloff.text", "");
+}
+