[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - oox/source sw/qa

2023-04-06 Thread Tünde Tóth (via logerrit)
 oox/source/drawingml/shape.cxx  |   12 
 sw/qa/extras/ooxmlimport/data/grouped_link.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx   |   10 ++
 3 files changed, 22 insertions(+)

New commits:
commit e17a67735ffe8e0feeef8daddf2667d3e432f6cd
Author: Tünde Tóth 
AuthorDate: Thu Mar 9 16:01:03 2023 +0100
Commit: Caolán McNamara 
CommitDate: Thu Apr 6 11:35:43 2023 +0200

tdf#145147 DOCX import: fix hyperlink in group shape

Hyperlink inserted to shape lost, if the shape was
inside a group shape.

Test: ungroup the grouped shape and move the mouse
over the shapes, or use Edit Hyperlink... in their
context menu.

Change-Id: I45d816f18a1e1bc1c442943b31c9e0ae7de199e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148552
Reviewed-by: László Németh 
Tested-by: László Németh 
(cherry picked from commit b5a0fa42adf68b33970da93c2b04f935f72cffde)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149608
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index fad591a93d04..4e4836fdf8b4 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -405,6 +405,18 @@ void Shape::addShape(
  ? 
*getTextBody()->getTextProperties().moInsets[3]
  : 0));
 }
+
+// tdf#145147 Set the Hyperlink property to the child wps 
shape.
+if (getShapeProperties().hasProperty(PROP_URL)) try
+{
+uno::Any aAny = getShapeProperties().getProperty(PROP_URL);
+OUString sUrl = aAny.get();
+if (!sUrl.isEmpty())
+
xChildWPSProperties->setPropertyValue(UNO_NAME_HYPERLINK, aAny);
+}
+catch (const Exception&)
+{
+}
 }
 
 if( meFrameType == FRAMETYPE_DIAGRAM )
diff --git a/sw/qa/extras/ooxmlimport/data/grouped_link.docx 
b/sw/qa/extras/ooxmlimport/data/grouped_link.docx
new file mode 100644
index ..8c5657b708b4
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/grouped_link.docx 
differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 04d23a4c1bc0..532ad030b28d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -1078,6 +1078,16 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf154319)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf145147)
+{
+createSwDoc("grouped_link.docx");
+uno::Reference xGroupShape(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("https://www.libreoffice.org";),
+ getProperty(xGroupShape->getByIndex(0), 
"Hyperlink"));
+CPPUNIT_ASSERT_EQUAL(OUString("https://www.documentfoundation.org";),
+ getProperty(xGroupShape->getByIndex(1), 
"Hyperlink"));
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - oox/source sw/qa

2023-03-09 Thread Mike Kaganski (via logerrit)
 oox/source/shape/WpsContext.cxx|   86 
--
 sw/qa/extras/ooxmlimport/data/tdf153791-shd_overrides_fontRef.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx  |   74 

 3 files changed, 114 insertions(+), 46 deletions(-)

New commits:
commit e8c46d0067d88832896798678993dc77edd9c493
Author: Mike Kaganski 
AuthorDate: Fri Feb 24 15:27:07 2023 +0300
Commit: Christian Lohmaier 
CommitDate: Thu Mar 9 12:44:43 2023 +

tdf#153791: paragraph's/character's shd overrides shape style's fontRef

I couldn't find any references to this in documentation (ECMA-376, MS-OE376)
regarding this, but Word ignores the font properties (including color) 
defined
in the shape style's fontRef for txbxContent's paragraphs / runs that have 
shd
elements with non-auto fill color.

Change-Id: Ice634a5eed7b51379649462303300f55358a566f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147630
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit c15412eb96bda1037c12811f5818ed8ce1e603bd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147844
Reviewed-by: Christian Lohmaier 

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 99656195075b..1d0ecfe95519 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -169,62 +169,56 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 
 // Apply character color of the shape to the shape's textbox.
 uno::Reference xText(mxShape, uno::UNO_QUERY);
-uno::Reference xTextCursor = 
xText->createTextCursor();
-xTextCursor->gotoStart(false);
-xTextCursor->gotoEnd(true);
-uno::Reference 
xTextBoxPropertySet(xTextCursor,
-
uno::UNO_QUERY);
 uno::Any xCharColor = 
xPropertySet->getPropertyValue("CharColor");
 Color aColor = COL_AUTO;
 if ((xCharColor >>= aColor) && aColor != COL_AUTO)
 {
-const uno::Reference 
xPropertyState(xTextCursor,
-   
uno::UNO_QUERY);
-const beans::PropertyState ePropertyState
-= xPropertyState->getPropertyState("CharColor");
-if (ePropertyState == beans::PropertyState_DEFAULT_VALUE)
-{
-xTextBoxPropertySet->setPropertyValue("CharColor", 
xCharColor);
-}
-else
+// tdf#135923 Apply character color of the shape to the 
textrun
+//when the character color of the textrun is 
default.
+// tdf#153791 But only if the run has no background color 
(shd element in OOXML)
+if (uno::Reference 
paraEnumAccess{
+xText, uno::UNO_QUERY })
 {
-// tdf#135923 Apply character color of the shape to 
the textrun
-//when the character color of the textrun 
is default.
-uno::Reference 
paraEnumAccess(
-xText, uno::UNO_QUERY);
-if (paraEnumAccess.is())
-{
-uno::Reference paraEnum(
-paraEnumAccess->createEnumeration());
+uno::Reference paraEnum(
+paraEnumAccess->createEnumeration());
 
-while (paraEnum->hasMoreElements())
-{
-uno::Reference 
xParagraph(paraEnum->nextElement(),
-
uno::UNO_QUERY);
-uno::Reference 
runEnumAccess(
-xParagraph, uno::UNO_QUERY);
-if (!runEnumAccess.is())
+while (paraEnum->hasMoreElements())
+{
+uno::Reference 
xParagraph(paraEnum->nextElement(),
+
uno::UNO_QUERY);
+uno::Reference 
runEnumAccess(
+xParagraph, uno::UNO_QUERY);
+if (!runEnumAccess.is())
+continue;
+if (uno::Reference 
xParaPropSet{ xParagraph,
+   
   uno::UNO_QUERY })
+if 
((xParaPropSet->getPropertyValue("ParaBackColor") >>= aC

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - oox/source sw/qa

2022-12-16 Thread Tünde Tóth (via logerrit)
 oox/source/shape/WpsContext.cxx |5 -
 sw/qa/extras/ooxmlexport/data/ColorOverwritten.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx  |   10 ++
 3 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit d3459346a6f4cf7650a03685bcc89c83716d98b1
Author: Tünde Tóth 
AuthorDate: Thu Dec 1 16:15:42 2022 +0100
Commit: Xisco Fauli 
CommitDate: Fri Dec 16 08:00:22 2022 +

tdf#152310 DOCX shape import: fix lost text color regression

Don't apply COL_AUTO as color of the run.

Regression from commit 49a40e3ed200e7c6d728f36d0b4be22dd85c51be
"tdf#135923 DOCX shape import: set text color".

Change-Id: I9c2088b4c531f09c80715bffdae225ac0987be79
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143533
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit fd831c28bfc29d9d5fe2b3074324d4cbc4a70689)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144179
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 9a7458ac6a85..99656195075b 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -220,7 +220,10 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 {
 uno::Reference 
xRunPropSet(
 xRun, uno::UNO_QUERY);
-
xRunPropSet->setPropertyValue("CharColor", xCharColor);
+Color aRunColor = COL_AUTO;
+
xRunPropSet->getPropertyValue("CharColor") >>= aRunColor;
+if (aRunColor == COL_AUTO)
+
xRunPropSet->setPropertyValue("CharColor", xCharColor);
 }
 }
 }
diff --git a/sw/qa/extras/ooxmlexport/data/ColorOverwritten.docx 
b/sw/qa/extras/ooxmlexport/data/ColorOverwritten.docx
new file mode 100644
index ..f1c8e527df96
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/ColorOverwritten.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 0f0af36ec7c7..4feae4b5d864 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -862,6 +862,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104348_contextMargin, 
"tdf104348_contextMargin.d
 CPPUNIT_ASSERT_EQUAL(nMargin, getProperty(getParagraph(2), 
"ParaBottomMargin"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf152310, "ColorOverwritten.docx")
+{
+uno::Reference xShape(getShape(1), uno::UNO_QUERY);
+
+CPPUNIT_ASSERT_EQUAL(Color(0xFF),
+ getProperty(getParagraphOfText(1, xShape), 
"CharColor"));
+CPPUNIT_ASSERT_EQUAL(Color(0x00b050),
+ getProperty(getParagraphOfText(2, xShape), 
"CharColor"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */