core.git: oox/source sw/qa

2024-03-06 Thread Justin Luth (via logerrit)
 oox/source/vml/vmlshape.cxx  |   17 +--
 sw/qa/extras/ooxmlexport/data/tdf160049_anchorMarginVML.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport21.cxx   |   13 
 3 files changed, 27 insertions(+), 3 deletions(-)

New commits:
commit e0ef7d54b4e4ccbaaada5d2c4a42ba41d961ea69
Author: Justin Luth 
AuthorDate: Tue Mar 5 19:05:29 2024 -0500
Commit: Miklos Vajna 
CommitDate: Wed Mar 6 11:22:31 2024 +0100

tdf#160049 oox import: use margins with left/right HoriOrientRelation

I'm really surprised this wasn't found much earlier.
Even DOC format isn't handling this.

make CppunitTest_sw_ooxmlexport21 \
CPPUNIT_TEST_NAME=testTdf160049_anchorMarginVML

Change-Id: I92ee8eceb6c6bab5f027663bae94d7acdf01be3d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164442
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 5284de176839..8f16c6267211 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -647,8 +647,13 @@ static void lcl_SetAnchorType(PropertySet& rPropSet, const 
ShapeTypeModel& rType
 rPropSet.setAnyProperty(PROP_VertOrient, 
Any(text::VertOrientation::TOP));
 }
 
+// if the anchor is not inline, and is relative to left or right, then 
apply the margins
+bool bHonorMargins = rTypeModel.maPosition == "relative" || 
rTypeModel.maPosition == "absolute";
 if ( rTypeModel.maPositionHorizontal == "center" )
+{
 rPropSet.setAnyProperty(PROP_HoriOrient, 
Any(text::HoriOrientation::CENTER));
+bHonorMargins = false;
+}
 else if ( rTypeModel.maPositionHorizontal == "left" )
 rPropSet.setAnyProperty(PROP_HoriOrient, 
Any(text::HoriOrientation::LEFT));
 else if ( rTypeModel.maPositionHorizontal == "right" )
@@ -663,6 +668,8 @@ static void lcl_SetAnchorType(PropertySet& rPropSet, const 
ShapeTypeModel& rType
 rPropSet.setAnyProperty(PROP_HoriOrient, 
Any(text::HoriOrientation::RIGHT));
 rPropSet.setAnyProperty(PROP_PageToggle, Any(true));
 }
+else
+bHonorMargins = false;
 
 if ( rTypeModel.maPositionHorizontalRelative == "page" )
 rPropSet.setAnyProperty(PROP_HoriOrientRelation, 
Any(text::RelOrientation::PAGE_FRAME));
@@ -674,9 +681,13 @@ static void lcl_SetAnchorType(PropertySet& rPropSet, const 
ShapeTypeModel& rType
 else if (rTypeModel.maPositionHorizontalRelative == "left-margin-area" ||
  rTypeModel.maPositionHorizontalRelative == "outer-margin-area")
 rPropSet.setProperty(PROP_HoriOrientRelation, 
text::RelOrientation::PAGE_LEFT);
-else if ( rTypeModel.maPositionHorizontalRelative == "text" )
-rPropSet.setProperty(PROP_HoriOrientRelation, 
text::RelOrientation::FRAME);
-
+else // "text"
+{
+if (bHonorMargins)
+rPropSet.setProperty(PROP_HoriOrientRelation, 
text::RelOrientation::PRINT_AREA);
+else
+rPropSet.setProperty(PROP_HoriOrientRelation, 
text::RelOrientation::FRAME);
+}
 if ( rTypeModel.maPositionVertical == "center" )
 rPropSet.setAnyProperty(PROP_VertOrient, 
Any(text::VertOrientation::CENTER));
 else if ( rTypeModel.maPositionVertical == "top" )
diff --git a/sw/qa/extras/ooxmlexport/data/tdf160049_anchorMarginVML.docx 
b/sw/qa/extras/ooxmlexport/data/tdf160049_anchorMarginVML.docx
new file mode 100644
index ..f8cb262f53c8
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf160049_anchorMarginVML.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index 2e6c10c99031..d045e18efa32 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -292,6 +293,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf158597, "tdf158597.docx")
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMarginVML, 
"tdf160049_anchorMarginVML.docx")
+{
+// given a VML (Word 2003) document with a LEFT "column/text" anchored 
image
+// (which will import as DML compat12 on the round-trip)
+if (isExported())
+return;
+// The image takes into account the margin, so it looks like it is in the 
middle of the doc,
+// which is "Paragraph text area"/PRINT_AREA/1, not "Entire paragraph 
area"/FRAME/0
+CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PRINT_AREA,
+ getProperty(getShape(1), 
"HoriOrientRelation"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf153909_followTextFlow, 
"tdf153909_followTextFlow.docx")
 {
 // Although MSO's UI reports "layoutInCell" for the rectangle, it isn't 
specified or honored


core.git: oox/source sw/qa

2024-02-26 Thread Justin Luth (via logerrit)
 oox/source/drawingml/fillproperties.cxx   |2 +
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx |   30 +++
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx |   26 +++-
 sw/qa/extras/rtfexport/rtfexport.cxx  |   47 +++---
 sw/qa/extras/rtfexport/rtfexport8.cxx |   15 +
 5 files changed, 42 insertions(+), 78 deletions(-)

New commits:
commit 38083e4c0b5638d69162593c3fbf599da6cd499f
Author: Justin Luth 
AuthorDate: Tue Feb 20 16:11:08 2024 -0500
Commit: Miklos Vajna 
CommitDate: Tue Feb 27 08:40:50 2024 +0100

related tdf#126533 dml/vml import: import radials as radials

... and not as symmetrical linear gradients.

The benefit is that our export code
will be able to intelligently export it.

Apparently RTF export code does not intelligently export axials,
(now fixed - tdf#159824)
but VML and DML (and doc) do it well.

Unfortunately charts can be badly affected,
(avoided by ignoring when transparent)
and unit tests are implementation-tested...

This affects existing unit tests:
-tdf128345_Legend_CS_TG_axial.pptx: label imports fine:
lost on export (no change)
-tdf128345_ChartWall_CS_TG.pptx: wall gradient now looks axial:
lost on export (no change)
-textframe-gradient.docx: still round-trips OK: no change
-textframe-gradient.rtf: round-trips as linear: lost axial-ness
 (now fixed: tdf#159824)
-fdo78663.docx: textbox font fill: still exports as solid: no change

I ran the assert check against chart2, oox, and sw

Change-Id: Ib16e9488a76b006bf335ff01a38acf7cde69cccb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163675
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index dec9ab9672cc..f24208722cb5 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -543,6 +543,8 @@ void FillProperties::pushToPropMap(ShapePropertyMap& 
rPropMap, const GraphicHelp
 
 // convert DrawingML angle (in 1/6 degrees) to API 
angle (in 1/10 degrees)
 aGradient.SetAngle(Degree10(static_cast< sal_Int16 >( 
(8100 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 )));
+if (!bContainsTransparency)
+aGradient.tryToConvertToAxial();
 }
 
 if (awt::GradientStyle_RECT == aGradient.GetGradientStyle())
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index f8defa15d1a2..72072bc5bb03 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -577,34 +577,16 @@ DECLARE_OOXMLEXPORT_TEST(testTextframeGradient, 
"textframe-gradient.docx")
 uno::Reference xFrame(getShape(1), uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, 
getProperty(xFrame, "FillStyle"));
 awt::Gradient2 aGradient(getProperty(xFrame, 
"FillGradient"));
-
-// MCGR: Use the completely imported transparency gradient to check for 
correctness
-basegfx::BColorStops aColorStops = 
model::gradient::getColorStopsFromUno(aGradient.ColorStops);
-
-CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
-CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 
0.0));
-CPPUNIT_ASSERT_EQUAL(Color(0xd99594), 
Color(aColorStops[0].getStopColor()));
-CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 
0.5));
-CPPUNIT_ASSERT_EQUAL(Color(0xc0504d), 
Color(aColorStops[1].getStopColor()));
-CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 
1.0));
-CPPUNIT_ASSERT_EQUAL(Color(0xd99594), 
Color(aColorStops[2].getStopColor()));
-CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
+CPPUNIT_ASSERT_EQUAL(Color(0xC0504D), Color(ColorTransparency, 
aGradient.StartColor));
+CPPUNIT_ASSERT_EQUAL(Color(0xD99594), Color(ColorTransparency, 
aGradient.EndColor));
+CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);;
 
 xFrame.set(getShape(2), uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, 
getProperty(xFrame, "FillStyle"));
 aGradient = getProperty(xFrame, "FillGradient");
-
-// MCGR: Use the completely imported transparency gradient to check for 
correctness
-aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
-
-CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
-CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 
0.0));
-CPPUNIT_ASSERT_EQUAL(Color(0x66), 
Color(aColorStops[0].getStopColor()));
-CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 
0.5));
-CPPUNIT_ASSERT_EQUAL(Color(0x00), 
Color(aColorStops[1].getStopColor()));
-

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

2024-02-23 Thread Justin Luth (via logerrit)
 oox/source/vml/vmlformatting.cxx |   17 ++--
 sw/qa/extras/ooxmlexport/data/tdf126533_axialAngle2.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx|   27 +-
 sw/qa/extras/rtfexport/data/tdf159824_gradientAngle3.rtf |   17 
 sw/qa/extras/rtfexport/data/tdf159824_gradientAngle4.rtf |   17 
 sw/qa/extras/rtfexport/rtfexport8.cxx|   62 +--
 sw/source/filter/ww8/docxattributeoutput.cxx |   23 ++---
 sw/source/filter/ww8/rtfattributeoutput.cxx  |   37 
 8 files changed, 153 insertions(+), 47 deletions(-)

New commits:
commit 6dd6891a3deed8718bf2b0fcf564f229f676f8ba
Author: Justin Luth 
AuthorDate: Thu Feb 22 09:24:12 2024 -0500
Commit: Justin Luth 
CommitDate: Fri Feb 23 20:28:31 2024 +0100

related tdf#126533 tdf#159824 VML: don't export: negative angles

and stop an automatic 180 reversal on import.

Some documents had gradient reversals on every round trip,
typically when the angle was 0-179
(mainly seen in ODT examples,
since DOCX/RTF imports defaulted to be angle 180).

The negative sign has special meaning,
indicating that the start and end colors
should be swapped.

Well, swapping colors was not intentional in the export logic.
Previously there was a mistaken idea
that any angles > 180 needed to be swapped on import,
and likely that is what prompted this overly complicated formula
to try to avoid any angle > 180 during export
by allowing negative angles.

This tdf#126533 patchset has already eliminated import checks
for angles > 180, so now a sane formula can be applied on export.

In order to do that, we have to avoid emulating color swaps
with 180 degree rotations at import time.
So ONLY do color swapping with start/end,
and leave the angle alone.
That GREATLY helps unit tests (which otherwise would flip-flop
the angle and the color start/stop).

Very unhelpful was an undocumented, indecipherable
inversion when converting to DML angle.

Boy, I hope I got this right...

make CppunitTest_sw_rtfexport8 \
   CPPUNIT_TEST_NAME=testTdf159824_gradientAngle3
make CppunitTest_sw_rtfexport8 \
   CPPUNIT_TEST_NAME=testTdf159824_gradientAngle4
make CppunitTest_sw_ooxmlexport7 \
   CPPUNIT_TEST_NAME=testTdf126533_axialAngle2

Eliminating the inversion for ooxml7 test is fine
since inversion does nothing to an axial.

Otherwise, eliminating inversions corresponds to a color swap.

Change-Id: I2aae0a7595807569ffc740689ff3840692d6159d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163798
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index f4022d0639d6..5fb422e63b9d 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -800,22 +800,29 @@ void FillModel::pushToPropMap( ShapePropertyMap& 
rPropMap, const GraphicHelper&
 }
 else// focus of -100%, 0%, and 100% is linear gradient
 {
+// LO linear gradients: top == start, but for MSO 
bottom == start == moColor
+bool bSwapColors = true;
+
 /*  According to spec, a focus of -100% or 100% swaps 
the
 start and stop colors, effectively reversing the 
gradient.
 If the angle was provided as a negative,
 then the colors are also (again) reversed. */
 if( fFocus < -0.5 || fFocus > 0.5 )
-nVmlAngle = (nVmlAngle + 180) % 360;
+bSwapColors = !bSwapColors;
 if (moAngle.value_or(0) < 0)
-nVmlAngle = (nVmlAngle + 180) % 360;
+bSwapColors = !bSwapColors;
 
+const Color& rStartColor = bSwapColors ? aColor2 : 
aColor1;
+const Color& rEndColor = bSwapColors ? aColor1 : 
aColor2;
 // set the start and stop colors
-lcl_setGradientStop( 
aFillProps.maGradientProps.maGradientStops, 0.0, aColor1 );
-lcl_setGradientStop( 
aFillProps.maGradientProps.maGradientStops, 1.0, aColor2 );
+
lcl_setGradientStop(aFillProps.maGradientProps.maGradientStops, 0.0,
+rStartColor);
+
lcl_setGradientStop(aFillProps.maGradientProps.maGradientStops, 1.0,
+rEndColor);
 }
 
 // VML counts counterclockwise from bottom, DrawingML 
clockwise from left
-sal_Int32 nDmlAngle = (630 - nVmlAngle) 

core.git: oox/source sw/qa

2024-02-23 Thread Justin Luth (via logerrit)
 oox/source/vml/vmlformatting.cxx|   27 +++---
 sw/qa/extras/ooxmlexport/data/tdf126533_negativeAxialAngle.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx   |   45 
++
 3 files changed, 61 insertions(+), 11 deletions(-)

New commits:
commit 396ece804b3a31e4eddf56de4e557f3755331d8c
Author: Justin Luth 
AuthorDate: Wed Feb 14 18:16:29 2024 -0500
Commit: Miklos Vajna 
CommitDate: Fri Feb 23 10:53:40 2024 +0100

related tdf#126533 vml import: fix gradient color swapping

tdf#65295 already fixed one case
by removing the test for degrees > 180
for the linear-equivalent gradients.
Unfortunately the comment wasn't also removed,
so that was confusing: removed comment.

The test for degrees > 180 is not needed
for the axial-equivalent case either: removed.

The reason for that degrees > 180 case is likely due to
negative degrees, which is a documented reason
for swapping the colors: added swap if negative degrees.

All the affected, existing unit tests are improved now:
-tdf81345.docx: famous MS example: improved header gradient
-fdo78300.docx: fontworks: hard to tell without MCGR...

make CppunitTest_sw_ooxmlexport7 \
CPPUNIT_TEST_NAME=testTdf126533_negativeAxialAngle

make CppunitTest_sw_ooxmlexport7 \
CPPUNIT_TEST_NAME=testTdf77219_backgroundShape

Change-Id: I9f4d56375bb2cec28ffbd93df419d586da465b78
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163417
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 6182950973ee..f4022d0639d6 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -777,15 +777,18 @@ void FillModel::pushToPropMap( ShapePropertyMap& 
rPropMap, const GraphicHelper&
 sal_Int32 nVmlAngle = getIntervalValue< sal_Int32, 
sal_Int32 >( moAngle.value_or( 0 ), 0, 360 );
 
 // focus of -50% or 50% is axial gradient
+// so approximate anything with a similar focus by using 
LO's axial gradient,
+// (otherwise drop the radial aspect; linear gradient 
becomes the closest match)
 if( ((-0.75 <= fFocus) && (fFocus <= -0.25)) || ((0.25 <= 
fFocus) && (fFocus <= 0.75)) )
 {
-/*  According to spec, focus of 50% is outer-to-inner,
+/*  According to spec, a focus of positive 50% is 
outer-to-inner,
 and -50% is inner-to-outer (color to color2).
-BUT: For angles >= 180 deg., the behaviour is
-reversed... that's not spec'ed of course. So,
-[0;180) deg. and 50%, or [180;360) deg. and -50% is
-outer-to-inner in fact. */
-bool bOuterToInner = (fFocus > 0.0) == (nVmlAngle < 
180);
+If the angle was provided as a negative,
+then the colors are also (again) reversed. */
+bool bOuterToInner = fFocus > 0.0;
+if (moAngle.value_or(0) < 0)
+bOuterToInner = !bOuterToInner;
+
 // simulate axial gradient by 3-step DrawingML gradient
 const Color& rOuterColor = bOuterToInner ? aColor1 : 
aColor2;
 const Color& rInnerColor = bOuterToInner ? aColor2 : 
aColor1;
@@ -797,13 +800,15 @@ void FillModel::pushToPropMap( ShapePropertyMap& 
rPropMap, const GraphicHelper&
 }
 else// focus of -100%, 0%, and 100% is linear gradient
 {
-/*  According to spec, focus of -100% or 100% swaps the
-start and stop colors, effectively reversing the
-gradient. BUT: For angles >= 180 deg., the
-behaviour is reversed. This means that in this case
-a focus of 0% swaps the gradient. */
+/*  According to spec, a focus of -100% or 100% swaps 
the
+start and stop colors, effectively reversing the 
gradient.
+If the angle was provided as a negative,
+then the colors are also (again) reversed. */
 if( fFocus < -0.5 || fFocus > 0.5 )
 nVmlAngle = (nVmlAngle + 180) % 360;
+if (moAngle.value_or(0) < 0)
+nVmlAngle = (nVmlAngle + 180) % 360;
+
 // set the start and stop colors
 lcl_setGradientStop( 
aFillProps.maGradientProps.maGradientStops, 0.0, aColor1 );
   

core.git: oox/source sw/qa

2024-02-20 Thread Justin Luth (via logerrit)
 oox/source/vml/vmlformatting.cxx   |   48 
 sw/qa/extras/tiledrendering/data/tdf159626_blackPatternFill.docx   |binary
 sw/qa/extras/tiledrendering/data/tdf159626_yellowPatternFill.docx  |binary
 sw/qa/extras/tiledrendering/data/tdf159626_yellowPatternFillB.docx |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   97 
++
 5 files changed, 145 insertions(+)

New commits:
commit 07521972bcd1cfbbd15b2f60ada84ffc69f8f997
Author: Justin Luth 
AuthorDate: Wed Feb 7 17:25:50 2024 -0500
Commit: Miklos Vajna 
CommitDate: Wed Feb 21 08:46:39 2024 +0100

tdf#159626 vml pattern import: add color, fix back/foreground

This depends on tdf#126533 which imports page style v:fill,
BUT ONLY IN ORDER TO support the unit tests.
The patch itself can stand alone
and fixes vml import into textboxes/shapes etc.
i.e. backporting could be possible by dropping the unit tests.

The pattern that VML uses to indicate foreground
and background is very different from what LO needs.
[Fortunately LO does not use the _guess_ from
vcl::bitmap::isHistorical8x8 to determine which
color is the background. Instead it always uses the first pixel.]

Documentation says that unspecified XML_fillcolor
and XML_color should be white, but observation
says it should be 25% gray (Word 2003).
25% gray == C0C0C0 == fillcolor="silver" == COL_LIGHTGRAY

Currently, we simply export as a colored, tiled image,
and not as a B type="pattern"
so no corresponding export changes need to be made to export.

Existing unit test documents that are affected:
-chart2export's PieChartDataLabels.docx (page background)
-ooxmlexport5's fdo77725.docx (minimized PieChartDataLabels.docx)
 * both foreground and background are set to white => solid white
-sw/qa/core/data/ooxml/pass/fdo79131.docx (shape "inline")

make CppunitTest_sw_tiledrendering \
CPPUNIT_TEST_NAME=testTdf159626_yellowPatternFill
make CppunitTest_sw_tiledrendering \
CPPUNIT_TEST_NAME=testTdf159626_yellowPatternFillB
make CppunitTest_sw_tiledrendering \
CPPUNIT_TEST_NAME=testTdf159626_blackPatternFill

Change-Id: I9533ac4a7489081ffc62a10e900f5526abb906db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163106
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 029d5429d921..6182950973ee 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+
 #include 
 #include 
 #include 
@@ -46,6 +47,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 namespace oox::vml {
@@ -843,6 +846,51 @@ void FillModel::pushToPropMap( ShapePropertyMap& rPropMap, 
const GraphicHelper&
 aFillProps.maBlipProps.mxFillGraphic = 
rGraphicHelper.importEmbeddedGraphic(moBitmapPath.value());
 if (aFillProps.maBlipProps.mxFillGraphic.is())
 {
+if (nFillType == XML_pattern)
+{
+// VML provides an 8x8 black(background) and 
white(foreground) pattern
+// along with specified background(color2) and 
foreground(color) colors,
+// while LO needs the color applied directly to 
the pattern.
+const Graphic 
aGraphic(aFillProps.maBlipProps.mxFillGraphic);
+::Color nBackColor;
+::Color nPixelColor;
+bool bIs8x8 = 
vcl::bitmap::isHistorical8x8(aGraphic.GetBitmapEx(),
+   
nBackColor, nPixelColor);
+if (bIs8x8)
+{
+nBackColor
+= 
ConversionHelper::decodeColor(rGraphicHelper, moColor2,
+
moOpacity2, API_RGB_WHITE)
+  .getColor(rGraphicHelper);
+// Documentation says undefined == white; 
observation says lightgray
+nPixelColor
+= 
ConversionHelper::decodeColor(rGraphicHelper, moColor,
+moOpacity, 
COL_LIGHTGRAY)
+  .getColor(rGraphicHelper);
+
+XOBitmap aXOB(aGraphic.GetBitmapEx());
+aXOB.Bitmap2Array();
+// LO uses the first pixel's color to 
represent background pixels
+if (aXOB.GetBackgroundColor() == 

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

2024-02-20 Thread Justin Luth (via logerrit)
 oox/source/vml/vmlshapecontext.cxx|1 
 sw/qa/extras/ooxmlexport/data/tdf126533_noPageBitmap.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport21.cxx|   21 +
 writerfilter/source/dmapper/DomainMapper.cxx  |   58 ++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |1 
 writerfilter/source/dmapper/PropertyMap.cxx   |   33 +++
 writerfilter/source/ooxml/model.xml   |3 
 7 files changed, 115 insertions(+), 2 deletions(-)

New commits:
commit c14574e7ad2d3ec2ada40808be3332fac71e9767
Author: Justin Luth 
AuthorDate: Sat Feb 3 10:08:56 2024 -0500
Commit: Miklos Vajna 
CommitDate: Tue Feb 20 16:54:57 2024 +0100

tdf#126533 docx import: page background vml fill

This patch imports bitmaps/tiled textures (primarily),
but also somewhat for gradients
(because of a gradient2 -> gradient mismatch somewhere)
and somewhat for patterns
(because patterns are not well imported in general).

Note that the imported fill likely will NOT match MSO,
because their background CHANGES BASED ON THE ZOOM LEVEL.
For example, my primary testing file (A6 landscape)
has a logo which is only 25% visible in Word 2003 at 100%,
but shows 90% of the logo at 200%, and many tiles of logos
when exported as PDF.
The same is true for gradients etc.

Changing background on zoom is an absolutely bizarre implementation,
and naturally LO could only accidentally look identical
(and should never try to do so).

make CppunitTest_sw_ooxmlexport21 \
CPPUNIT_TEST_NAME=testTdf126533_noPageBitmap

make CppunitTest_sw_ooxmlexport21 \
CPPUNIT_TEST_NAME=testTdf126533_pageGradient

This is slightly ugly, but I don't know how to make a COPY
of the XPropertySet UNO junk. All I have is references,
and dispose deletes everything, even the references.

I took some inspiration from RTF
which just disposes the shape after grabbing the background color.

Thus, just change the page style known to exist and be used,
and then simply remove the fill if it isn't needed in the end.
Any new page styles can just copy the default page style fill.

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

diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index e3242368a334..20ce2fa37434 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -251,6 +251,7 @@ ContextHandlerRef ShapeContextBase::createShapeContext( 
ContextHandler2Helper co
 return new ShapeContext( rParent, rShapes.createShape< 
BezierShape >(), rAttribs );
 else
 return new ShapeContext( rParent, rShapes.createShape< 
ComplexShape >(), rAttribs );
+case VML_TOKEN(background):
 case VML_TOKEN( rect ):
 return new RectangleShapeContext( rParent, rAttribs, 
rShapes.createShape< RectangleShape >() );
 case VML_TOKEN( roundrect ):
diff --git a/sw/qa/core/data/ooxml/pass/fill.docx 
b/sw/qa/extras/ooxmlexport/data/fill.docx
similarity index 100%
rename from sw/qa/core/data/ooxml/pass/fill.docx
rename to sw/qa/extras/ooxmlexport/data/fill.docx
diff --git a/sw/qa/extras/ooxmlexport/data/tdf126533_noPageBitmap.docx 
b/sw/qa/extras/ooxmlexport/data/tdf126533_noPageBitmap.docx
new file mode 100644
index ..87dfff296be5
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf126533_noPageBitmap.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index f1d4a5e7121a..e455467a74ef 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -366,6 +367,26 @@ CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaData)
 assertXPath(pCoreDoc, "/cp:coreProperties/cp:revision"_ostr, 0);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf126533_noPageBitmap, 
"tdf126533_noPageBitmap.docx")
+{
+// given a document with a v:background bitmap, but no w:background 
fillcolor
+uno::Reference 
xPageStyle(getStyles("PageStyles")->getByName("Standard"),
+   uno::UNO_QUERY);
+// the image (or any fill for that matter) should be ignored.
+CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE,
+ getProperty(xPageStyle, 
"FillStyle"));
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf126533_pageGradient)
+{
+// given a document with a gradient page background
+loadFromFile(u"fill.docx");
+uno::Reference 
xPageStyle(getStyles("PageStyles")->getByName("Standard"),
+   

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

2023-08-15 Thread Mike Kaganski (via logerrit)
 oox/source/drawingml/fillproperties.cxx   |   24 
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |8 
 2 files changed, 16 insertions(+), 16 deletions(-)

New commits:
commit d2c7cbc7d724d608f6d37bbb0233ad2b39eb938e
Author: Mike Kaganski 
AuthorDate: Tue Aug 15 21:09:27 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Aug 15 21:41:24 2023 +0200

Simplify and improve conversion

Using o3tl::convert makes sure that rounding is correct, which
shows in the improved unit test, that now doesn't need different
values before and after roundtrip.

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

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index a11aeb6236ee..8cc400257155 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -105,9 +105,9 @@ std::optional 
CropQuotientsFromSrcRect(geometry::IntegerRectangle2D a
 aSrcRect.X2 = std::max(aSrcRect.X2, sal_Int32(0));
 aSrcRect.Y1 = std::max(aSrcRect.Y1, sal_Int32(0));
 aSrcRect.Y2 = std::max(aSrcRect.Y2, sal_Int32(0));
-if (aSrcRect.X1 + aSrcRect.X2 >= 100'000 || aSrcRect.Y1 + aSrcRect.Y2 >= 
100'000)
+if (aSrcRect.X1 + aSrcRect.X2 >= MAX_PERCENT || aSrcRect.Y1 + aSrcRect.Y2 
>= MAX_PERCENT)
 return {}; // Cropped everything
-return getQuotients(aSrcRect, 100'000.0, 100'000.0);
+return getQuotients(aSrcRect, MAX_PERCENT, MAX_PERCENT);
 }
 
 // ECMA-376 Part 1 20.1.8.30 fillRect (Fill Rectangle)
@@ -118,8 +118,8 @@ std::optional 
CropQuotientsFromFillRect(geometry::IntegerRectangle2D
 aFillRect.Y1 = std::min(aFillRect.Y1, sal_Int32(0));
 aFillRect.Y2 = std::min(aFillRect.Y2, sal_Int32(0));
 // Negative divisor and negative relative offset give positive value 
wanted in lclCropGraphic
-return getQuotients(aFillRect, -100'000.0 + aFillRect.X1 + aFillRect.X2,
--100'000.0 + aFillRect.Y1 + aFillRect.Y2);
+return getQuotients(aFillRect, -MAX_PERCENT + aFillRect.X1 + aFillRect.X2,
+-MAX_PERCENT + aFillRect.Y1 + aFillRect.Y2);
 }
 
 // Crops a piece of the bitmap. lclCropGraphic doesn't handle growing.
@@ -624,13 +624,13 @@ void FillProperties::pushToPropMap(ShapePropertyMap& 
rPropMap, const GraphicHelp
 {
 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
 if ( aFillRect.X1 )
-aGraphCrop.Left = static_cast< sal_Int32 >( ( 
static_cast< double >( aOriginalSize.Width ) * aFillRect.X1 ) / 10 );
+aGraphCrop.Left = o3tl::convert(aFillRect.X1, 
aOriginalSize.Width, MAX_PERCENT);
 if ( aFillRect.Y1 )
-aGraphCrop.Top = static_cast< sal_Int32 >( ( 
static_cast< double >( aOriginalSize.Height ) * aFillRect.Y1 ) / 10 );
+aGraphCrop.Top = o3tl::convert(aFillRect.Y1, 
aOriginalSize.Height, MAX_PERCENT);
 if ( aFillRect.X2 )
-aGraphCrop.Right = static_cast< sal_Int32 >( ( 
static_cast< double >( aOriginalSize.Width ) * aFillRect.X2 ) / 10 );
+aGraphCrop.Right = o3tl::convert(aFillRect.X2, 
aOriginalSize.Width, MAX_PERCENT);
 if ( aFillRect.Y2 )
-aGraphCrop.Bottom = static_cast< sal_Int32 >( 
( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 10 );
+aGraphCrop.Bottom = 
o3tl::convert(aFillRect.Y2, aOriginalSize.Height, MAX_PERCENT);
 
 bool bHasCropValues = aGraphCrop.Left != 0 || 
aGraphCrop.Right !=0 || aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0;
 // Negative GraphicCrop values means "crop" here.
@@ -817,13 +817,13 @@ void GraphicProperties::pushToPropMap( PropertyMap& 
rPropMap, const GraphicHelpe
 {
 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
 if ( oClipRect.X1 )
-aGraphCrop.Left = rtl::math::round( ( static_cast< double 
>( aOriginalSize.Width ) * oClipRect.X1 ) / 10 );
+aGraphCrop.Left = o3tl::convert(oClipRect.X1, 
aOriginalSize.Width, MAX_PERCENT);
 if ( oClipRect.Y1 )
-aGraphCrop.Top = rtl::math::round( ( static_cast< double 
>( aOriginalSize.Height ) * oClipRect.Y1 ) / 10 );
+aGraphCrop.Top = o3tl::convert(oClipRect.Y1, 
aOriginalSize.Height, MAX_PERCENT);
 if ( oClipRect.X2 )
-aGraphCrop.Right = rtl::math::round( ( static_cast< double 
>( aOriginalSize.Width ) * oClipRect.X2 ) / 10 );
+

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

2023-06-28 Thread Tünde Tóth (via logerrit)
 oox/source/export/shapes.cxx|5 -
 sw/qa/extras/ooxmlexport/data/tdf155903.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx  |6 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 863a32171ed8efdf1aaee59918e49613e7ccd7a9
Author: Tünde Tóth 
AuthorDate: Mon Jun 26 15:01:26 2023 +0200
Commit: László Németh 
CommitDate: Wed Jun 28 13:38:22 2023 +0200

tdf155903 DOCX export: fix corrupt file with embedded media

Regression from commit bc72514f90d90e1ab3fed8167663e835edf03508
"tdf#53970 PPTX: fix export of embedded media files".

Change-Id: I04521227346817d91f720b1f6a77beb7f4a01f83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153619
Tested-by: László Németh 
Reviewed-by: László Németh 
Tested-by: Jenkins

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index dceb4ee706f8..efde8de56f72 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1272,7 +1272,10 @@ void ShapeExport::WriteGraphicObjectShapePart( const 
Reference< XShape >& xShape
 xShapeProps->getPropertyValue("Graphic") >>= xGraphic;
 }
 
-bool bHasMediaURL = xShapeProps.is() && 
xShapeProps->getPropertySetInfo()->hasPropertyByName("MediaURL") && 
(xShapeProps->getPropertyValue("MediaURL") >>= sMediaURL);
+// tdf#155903 Only for PPTX, Microsoft does not support this feature in 
Word and Excel.
+bool bHasMediaURL = GetDocumentType() == DOCUMENT_PPTX && xShapeProps.is()
+&& 
xShapeProps->getPropertySetInfo()->hasPropertyByName("MediaURL")
+&& (xShapeProps->getPropertyValue("MediaURL") >>= 
sMediaURL);
 
 if (!xGraphic.is() && !bHasMediaURL)
 {
diff --git a/sw/qa/extras/ooxmlexport/data/tdf155903.odt 
b/sw/qa/extras/ooxmlexport/data/tdf155903.odt
new file mode 100644
index ..97ba58d892dd
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf155903.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 9183863c8af7..4d1136f24c42 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -864,6 +864,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf155736, 
"tdf155736_PageNumbers_footer.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("Page * of *"), 
parseDump("/root/page[2]/footer/txt/text()"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf155903, "tdf155903.odt")
+{
+// Without the accompanying fix in place, this test would have crashed,
+// because the exported file was corrupted.
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: oox/source sw/qa sw/source writerfilter/source

2023-06-11 Thread Tomaž Vajngerl (via logerrit)
 oox/source/drawingml/textcharacterproperties.cxx|2 
 oox/source/token/properties.txt |1 
 sw/qa/extras/ooxmlexport/data/Test_CharUnderlineThemeColor.docx |binary
 sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx  |   16 +++
 sw/source/filter/ww8/docxattributeoutput.cxx|   10 +-
 writerfilter/source/dmapper/DomainMapper.cxx|   42 
++
 writerfilter/source/dmapper/PropertyIds.cxx |1 
 writerfilter/source/dmapper/PropertyIds.hxx |1 
 8 files changed, 70 insertions(+), 3 deletions(-)

New commits:
commit 953ef30494661788b2e980ece84b62c653d77321
Author: Tomaž Vajngerl 
AuthorDate: Sun Jun 11 00:50:08 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 12 05:26:11 2023 +0200

ooxml: import and export char underline theme colors

This adds support to import and export char underline theme color
properties.

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

diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index 0e1e2830a67f..1217c19441ae 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -206,6 +206,8 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
 {
 rPropMap.setProperty( PROP_CharUnderlineHasColor, true);
 rPropMap.setProperty( PROP_CharUnderlineColor, 
maUnderlineColor.getColor( rFilter.getGraphicHelper() ));
+model::ComplexColor aComplexColor = maUnderlineColor.getComplexColor();
+rPropMap.setProperty( PROP_CharUnderlineComplexColor, 
model::color::createXComplexColor(aComplexColor));
 }
 else
 {
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 40988ffb0222..025b0628b9d8 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -91,6 +91,7 @@ CharStyleName
 CharTransparence
 CharUnderline
 CharUnderlineColor
+CharUnderlineComplexColor
 CharUnderlineHasColor
 CharWeight
 CharWeightAsian
diff --git a/sw/qa/extras/ooxmlexport/data/Test_CharUnderlineThemeColor.docx 
b/sw/qa/extras/ooxmlexport/data/Test_CharUnderlineThemeColor.docx
new file mode 100644
index ..3ee3cdf457f0
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/Test_CharUnderlineThemeColor.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx 
b/sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx
index 3804f4606187..f9e7155859ea 100644
--- a/sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx
@@ -81,6 +81,22 @@ DECLARE_SW_ROUNDTRIP_TEST(testThemePortionBorderColor_DOCX, 
"Test_ThemeBorderCol
 CPPUNIT_ASSERT(isPropertyVoid(xParagraph, "RightBorderComplexColor"));
 }
 
+DECLARE_SW_ROUNDTRIP_TEST(testCharUnderlineTheme_DOCX, 
"Test_CharUnderlineThemeColor.docx", nullptr,
+  Test)
+{
+auto xParagraph = getParagraph(1);
+CPPUNIT_ASSERT(xParagraph.is());
+auto xRun = getRun(xParagraph, 1);
+auto xComplexColor
+= getProperty>(xRun, 
"CharUnderlineComplexColor");
+auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, 
aComplexColor.getSchemeType());
+auto const& rTransforms = aComplexColor.getTransformations();
+CPPUNIT_ASSERT_EQUAL(size_t(1), rTransforms.size());
+CPPUNIT_ASSERT_EQUAL(model::TransformationType::Shade, 
rTransforms[0].meType);
+CPPUNIT_ASSERT_EQUAL(sal_Int16(2509), rTransforms[0].mnValue);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index f5742eae4515..a75682761d84 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7953,10 +7953,14 @@ void DocxAttributeOutput::CharUnderline( const 
SvxUnderlineItem& rUnderline )
 bool  bUnderlineHasColor = !aUnderlineColor.IsTransparent();
 if (bUnderlineHasColor)
 {
+model::ComplexColor const& rComplexColor = 
rUnderline.getComplexColor();
 // Underline has a color
-m_pSerializer->singleElementNS( XML_w, XML_u,
-FSNS( XML_w, XML_val ), 
pUnderlineValue,
-FSNS( XML_w, XML_color ), 
msfilter::util::ConvertColor(aUnderlineColor) );
+rtl::Reference pAttrList = 
FastSerializerHelper::createAttrList();
+pAttrList->add(FSNS(XML_w, XML_val), pUnderlineValue);
+pAttrList->add(FSNS(XML_w, XML_color), 
msfilter::util::ConvertColor(aUnderlineColor));
+ 

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

2023-04-09 Thread Tomaž Vajngerl (via logerrit)
 oox/source/drawingml/colorchoicecontext.cxx |   56 +
 sw/qa/core/theme/ThemeTest.cxx  |  163 
 2 files changed, 197 insertions(+), 22 deletions(-)

New commits:
commit f707834e8538c0a183716b26ebdf04381482ca6d
Author: Tomaž Vajngerl 
AuthorDate: Mon Feb 27 21:20:49 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Apr 9 15:39:29 2023 +0200

oox: write color transforms to model::ColorDefinition

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

diff --git a/oox/source/drawingml/colorchoicecontext.cxx 
b/oox/source/drawingml/colorchoicecontext.cxx
index 3d559299f4c2..927ff41de9c0 100644
--- a/oox/source/drawingml/colorchoicecontext.cxx
+++ b/oox/source/drawingml/colorchoicecontext.cxx
@@ -30,7 +30,7 @@ namespace oox::drawingml {
 namespace
 {
 
-std::unordered_map constSystemColorMap =
+const std::unordered_map 
constSystemColorMap =
 {
 { XML_scrollBar, model::SystemColorType::ScrollBar },
 { XML_background, model::SystemColorType::Background },
@@ -63,6 +63,39 @@ std::unordered_map 
constSystemColorMap =
 { XML_menuHighlight, model::SystemColorType::MenuHighlight },
 { XML_menuBar, model::SystemColorType::MenuBar }
 };
+
+const std::unordered_map 
constTransformTypeMap =
+{
+{ XML_alpha, model::TransformationType::Alpha },
+{ XML_alphaMod, model::TransformationType::AlphaMod },
+{ XML_alphaOff, model::TransformationType::AlphaOff },
+{ XML_blue, model::TransformationType::Blue },
+{ XML_blueMod, model::TransformationType::BlueMod },
+{ XML_blueOff, model::TransformationType::BlueOff },
+{ XML_hue, model::TransformationType::Hue },
+{ XML_hueMod, model::TransformationType::HueMod},
+{ XML_hueOff, model::TransformationType::HueOff },
+{ XML_lum, model::TransformationType::Lum },
+{ XML_lumMod, model::TransformationType::LumMod },
+{ XML_lumOff, model::TransformationType::LumOff },
+{ XML_green, model::TransformationType::Green },
+{ XML_greenMod, model::TransformationType::GreenMod },
+{ XML_greenOff, model::TransformationType::GreenOff },
+{ XML_red, model::TransformationType::Red },
+{ XML_redMod, model::TransformationType::RedMod },
+{ XML_redOff, model::TransformationType::RedOff },
+{ XML_sat, model::TransformationType::Sat },
+{ XML_satMod, model::TransformationType::SatMod },
+{ XML_satOff, model::TransformationType::SatMod },
+{ XML_shade, model::TransformationType::Shade },
+{ XML_tint, model::TransformationType::Tint },
+{ XML_comp, model::TransformationType::Comp },
+{ XML_gamma, model::TransformationType::Gamma },
+{ XML_gray, model::TransformationType::Gray },
+{ XML_inv, model::TransformationType::Inv },
+{ XML_invGamma, model::TransformationType::InvGamma }
+};
+
 }
 
 ColorValueContext::ColorValueContext(ContextHandler2Helper const & rParent, 
Color& rColor, model::ColorDefinition* pColorDefinition)
@@ -168,6 +201,7 @@ void ColorValueContext::onStartElement( const 
AttributeList& rAttribs )
 mrColor.setPrstClr(nToken);
 if (mpColorDefinition)
 {
+// TODO - just converted to RGB for now
 ::Color nRgbValue = Color::getDmlPresetColor(nToken, 
API_RGB_TRANSPARENT);
 mpColorDefinition->mnComponent1 = nRgbValue.GetRed();
 mpColorDefinition->mnComponent2 = nRgbValue.GetGreen();
@@ -227,6 +261,26 @@ void ColorValueContext::onStartElement( const 
AttributeList& rAttribs )
 mrColor.addTransformation( nElement );
 break;
 }
+
+if (mpColorDefinition)
+{
+auto aIterator = constTransformTypeMap.find(getBaseToken(nElement));
+if (aIterator != constTransformTypeMap.end())
+{
+auto const& aPair = *aIterator;
+model::TransformationType eType = aPair.second;
+
+OUString aValueString = rAttribs.getStringDefaulted(XML_val);
+sal_Int32 nValue = 0;
+if (aValueString.endsWith("%"))
+nValue = aValueString.toDouble() * PER_PERCENT;
+else
+nValue = rAttribs.getInteger(XML_val, 0);
+
+mpColorDefinition->maTransformations.push_back({eType, 
sal_Int16(nValue / 10.0)});
+}
+}
+
 return nullptr;
 }
 
diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx
index c94b195eef0e..f9270663a5bb 100644
--- a/sw/qa/core/theme/ThemeTest.cxx
+++ b/sw/qa/core/theme/ThemeTest.cxx
@@ -87,54 +87,175 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, 
testDrawPageThemeExistsDOCX)
 CPPUNIT_ASSERT_EQUAL(size_t(3), rFormatScheme.getFillStyleList().size());
 CPPUNIT_ASSERT_EQUAL(size_t(3), 
rFormatScheme.getBackgroundFillStyleList().size());
 
+// Fill style 1
 {
 model::FillStyle const& rFillStyle = 

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

2023-03-27 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 7f4f88b883f81fbce975f72aea0f66a54e269ead
Author: Tünde Tóth 
AuthorDate: Thu Mar 9 16:01:03 2023 +0100
Commit: László Németh 
CommitDate: Mon Mar 27 14:22:05 2023 +

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 

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b8cac0d8f385..e3923c1b647d 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -406,6 +406,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 6436d68ec89e..c201e585e997 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -1092,6 +1092,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: oox/source sw/qa

2023-02-24 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 c15412eb96bda1037c12811f5818ed8ce1e603bd
Author: Mike Kaganski 
AuthorDate: Fri Feb 24 15:27:07 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Feb 24 15:00:08 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 

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 9fb3812923b2..ca87085165d8 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -677,62 +677,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") >>= aColor)
+&& aColor != COL_AUTO)
 continue;
 
-uno::Reference runEnum
-  

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

2022-12-15 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 fd831c28bfc29d9d5fe2b3074324d4cbc4a70689
Author: Tünde Tóth 
AuthorDate: Thu Dec 1 16:15:42 2022 +0100
Commit: László Németh 
CommitDate: Thu Dec 15 08:21:12 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 

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: */


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

2022-11-24 Thread Jan Holesovsky (via logerrit)
 oox/source/drawingml/fillproperties.cxx   |6 +-
 sw/qa/extras/ooxmlexport/data/crop-roundtrip.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   15 +++
 3 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit ab080ab1ab3100d9702a745287566b78b8d59e54
Author: Jan Holesovsky 
AuthorDate: Thu Nov 24 11:22:49 2022 +0100
Commit: Jan Holesovsky 
CommitDate: Thu Nov 24 21:58:46 2022 +0100

tdf#152199: Don't crop twice

We have a "GraphicCrop" property that is supposed to roundtrip the
cropping in OOXML, but there is no core feature backing it (ie. the
image is not shown cropped when this is imported and set).

Instead, to show the image "cropped", we crop the image physically on
import (throw away pixels that are 'outside' of the cropped area).

But - the "GraphicCrop" is then saved on export, together with the image
already physically cropped, which leads to garbled DOCX on re-import.

Given that the core feature to show image cropped when the "GraphicCrop"
is set, let's avoid setting it when we physically crop the image.

Change-Id: Ia1090ea9c6d22e60c77d52bf65281f6588d07d4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143216
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 75da3836b6f5..329d5d3bb4b1 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -853,7 +853,6 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 aGraphCrop.Right = static_cast< sal_Int32 >( ( 
static_cast< double >( aOriginalSize.Width ) * aFillRect.X2 ) / 10 );
 if ( aFillRect.Y2 )
 aGraphCrop.Bottom = static_cast< sal_Int32 >( 
( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 10 );
-rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
 
 bool bHasCropValues = aGraphCrop.Left != 0 || 
aGraphCrop.Right !=0 || aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0;
 // Negative GraphicCrop values means "crop" here.
@@ -861,12 +860,17 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 
 if(bIsCustomShape && bHasCropValues && bNeedCrop)
 {
+// Physically crop the image
+// In this case, don't set the 
PROP_GraphicCrop because that
+// would lead to applying the crop twice after 
roundtrip
 xGraphic = lclCropGraphic(xGraphic, 
CropQuotientsFromFillRect(aFillRect));
 if 
(rPropMap.supportsProperty(ShapeProperty::FillBitmapName))
 
rPropMap.setProperty(ShapeProperty::FillBitmapName, xGraphic);
 else
 
rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
 }
+else
+rPropMap.setProperty(PROP_GraphicCrop, 
aGraphCrop);
 }
 }
 }
diff --git a/sw/qa/extras/ooxmlexport/data/crop-roundtrip.docx 
b/sw/qa/extras/ooxmlexport/data/crop-roundtrip.docx
new file mode 100644
index ..6db60d0e8c60
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/crop-roundtrip.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 71d28b313d2a..04c775fa8fcb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -172,6 +173,20 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtDuplicatedId)
 assertXPath(pXmlDoc, "//w:sdt", 2);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testImageCropping)
+{
+loadAndReload("crop-roundtrip.docx");
+
+// the image has no cropping after roundtrip, because it has been 
physically cropped
+// NB: this test should be fixed when the core feature to show image 
cropped when it
+// has the "GraphicCrop" is set is implemented
+auto aGraphicCropStruct = getProperty(getShape(1), 
"GraphicCrop");
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGraphicCropStruct.Left);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGraphicCropStruct.Right);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGraphicCropStruct.Top);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGraphicCropStruct.Bottom);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2022-07-28 Thread Justin Luth (via logerrit)
 dev/null  |binary
 oox/source/drawingml/fillproperties.cxx   |5 -
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |   10 --
 3 files changed, 4 insertions(+), 11 deletions(-)

New commits:
commit be39a3d8c1bf9b134839a90e52ccabb2101421f4
Author: Justin Luth 
AuthorDate: Thu Jul 28 16:45:41 2022 -0400
Commit: Justin Luth 
CommitDate: Fri Jul 29 00:08:54 2022 +0200

Revert "tdf#141652 partial revert "Reset ShapeProperty priority..."

This reverts 7.4 commit 18cc1240565e697859dd7d17058f91d5e01df929.

Someone backported it to 7.3 as well.

Change-Id: Ie04595e11dd9d2e15fa940b8ada71714bd434f6a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137581
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index f7dc16bf231b..fef43b0ca238 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -811,7 +811,10 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 if(bIsCustomShape && bHasCropValues && bNeedCrop)
 {
 xGraphic = lclCropGraphic(xGraphic, 
CropQuotientsFromFillRect(aFillRect));
-
rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
+if 
(rPropMap.supportsProperty(ShapeProperty::FillBitmapName))
+
rPropMap.setProperty(ShapeProperty::FillBitmapName, xGraphic);
+else
+
rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
 }
 }
 }
diff --git a/sw/qa/extras/ooxmlexport/data/tdf141652_fillBitmapName.docx 
b/sw/qa/extras/ooxmlexport/data/tdf141652_fillBitmapName.docx
deleted file mode 100644
index 4a47a544d6bb..
Binary files a/sw/qa/extras/ooxmlexport/data/tdf141652_fillBitmapName.docx and 
/dev/null differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index 6c35215f584a..c54580ee766a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -274,16 +274,6 @@ DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillBitmapCrop, 
"dml-shape-fillbitmapcrop.d
 
 }
 
-DECLARE_OOXMLEXPORT_TEST(test141652_fillBitmapName, 
"tdf141652_fillBitmapName.docx")
-{
-text::GraphicCrop aGraphicCropStruct = 
getProperty(getShape(1), "GraphicCrop");
-CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(-769), aGraphicCropStruct.Right, 
10);
-
-CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Left );
-CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Top );
-CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Bottom );
-}
-
 DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillPattern, "dml-shape-fillpattern.docx")
 {
 // Hatching was ignored by the export.


[Libreoffice-commits] core.git: oox/source sw/qa sw/source writerfilter/qa writerfilter/source

2022-07-25 Thread Miklos Vajna (via logerrit)
 oox/source/export/vmlexport.cxx   |5 -
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|   25 
++--
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |2 
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |6 +-
 sw/source/filter/ww8/attributeoutputbase.hxx  |2 
 sw/source/filter/ww8/docxattributeoutput.cxx  |   16 -
 sw/source/filter/ww8/docxattributeoutput.hxx  |2 
 sw/source/filter/ww8/wrtw8nds.cxx |2 
 writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx|   30 
++
 writerfilter/qa/cppunittests/dmapper/data/sdt-run-plain-text.docx |binary
 writerfilter/source/dmapper/DomainMapper.cxx  |   20 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |5 +
 writerfilter/source/dmapper/SdtHelper.cxx |1 
 writerfilter/source/dmapper/SdtHelper.hxx |4 +
 14 files changed, 100 insertions(+), 20 deletions(-)

New commits:
commit 9700c1b2170ad04453a361ed5647937833ac3c18
Author: Miklos Vajna 
AuthorDate: Mon Jul 25 09:13:03 2022 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jul 25 09:51:22 2022 +0200

sw content controls, plain text: add DOCX import

- the core of this is the writerfilter/ change to call PopSdt() for
  SdtControlType::plainText, which maps inline plain text SDTs to Writer 
content
  controls, not to input fields

- disable the grab-bag in this case, otherwise we would run duplicated 

  elements on export

- fix CppunitTest_sw_ooxmlexport7's testSdtAndShapeOverlapping by postponing
  the SDT start in DocxAttributeOutput::WriteContentControlStart() in case a
  shape is anchored at the same position as the SDT start: if the shape 
should
  start inside the content control, then it should be anchored after the 
dummy
  character

- reduce the debug output in VMLExport::Commit(), which could write control
  characters to the terminal on test failure, potentially breaking it 
(requiring
  a 'reset' to recover)

- fix CppunitTest_sw_ooxmlexport5's testSdt2Run: now we merge two runs 
inside a
  plain text content control into a single one, and there is no problem with
  that, so adapt the test instead

- fix CppunitTest_sw_ooxmlexport17's testTdf148361: plain text inline SDT is
  now a content control, not a field

- fix CppunitTest_sw_ooxmlfieldexport's testfdo82492: explicitly assert that
  there is 1 text run inside the SDT and there is a shape after it 
(outside).
  Also extend DocxAttributeOutput::EndContentControl(), so it ends the 
content
  control at the correct, earlier position in case it's followed by an 
as-char
  shape

- fix CppunitTest_sw_ooxmlfieldexport's testfdo82123: again assert that the 
SDT
  has 1 run with text, and there is a drawing after the SDT

- fix CppunitTest_sw_ooxmlfieldexport's testTdf104823: this revealed that 
some
  more complex logic is needed to support data bindings, so exclude
  text-with-databinding from the scope of this commit and continue to map 
those
  to input fields for now

- fix CppunitTest_sw_ooxmlfieldexport's testFdo81945: this had a similar
  problem as as-char shapes, but this time a new SDT is starting right 
after a
  previous SDT. Adapt DocxAttributeOutput::EndContentControl() accordingly,
  though perhaps this should be generalized later, so we always close SDTs 
in the
  previous run, unless this is the last run, or something similar

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

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 47a196908a4d..1bfc59ee13db 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1008,12 +1008,9 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, 
const tools::Rectangle&
 default:
 #if OSL_DEBUG_LEVEL > 0
 const size_t opt_nProp_size(opt.nProp.size());
-const sal_uInt8 opt_nProp_empty(0);
 SAL_WARN( "oox.vml", "TODO VMLExport::Commit(), unimplemented 
id: " << nId
 << ", value: " << opt.nPropValue
-<< ", data: [" << opt_nProp_size << ", "
-<< (0 == opt_nProp_size ? _nProp_empty : 
opt.nProp.data())
-<< "]");
+<< ", data: [" << opt_nProp_size << "]");
 if ( opt.nProp.size() )
 {
 const sal_uInt8 *pIt = opt.nProp.data();
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 

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

2022-04-06 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/shapes.cxx   |3 +-
 sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |   30 +
 3 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit 9592da0a8e596869a1cd0859619dd28a541d7234
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Apr 5 10:13:02 2022 +0200
Commit: Regina Henschel 
CommitDate: Wed Apr 6 19:07:34 2022 +0200

tdf#148327 docx export: fix puzzle shape

There is an exporter class for preset shapes,
namely the DMLPresetShapeExporter, which in
its ctor calls the msfilter::GetShapeName()
converter method where the puzzle cause
exception. To avoid this return with false
to export it with custgeom in time.

Change-Id: I8d29bf551638a66abf381c9cb8f6a0eebc881195
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132567
Tested-by: Jenkins
Reviewed-by: Attila Bakos 
Reviewed-by: Regina Henschel 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 0405c975db0a..e4d378bd6111 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -928,7 +928,8 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 // as preset ones with parameters. Try that with this converter class.
 if (!sShapeType.startsWith("ooxml") && sShapeType != "non-primitive"
 && GetDocumentType() == DOCUMENT_DOCX && !mbUserShapes
-&& xShape->getShapeType() == "com.sun.star.drawing.CustomShape")
+&& xShape->getShapeType() == "com.sun.star.drawing.CustomShape"
+&& !lcl_IsOnAllowlist(sShapeType))
 {
 DMLPresetShapeExporter aCustomShapeConverter(this, xShape);
 bPresetWriteSuccessful = aCustomShapeConverter.WriteShape();
diff --git a/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt 
b/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt
new file mode 100644
index ..6f7a62deecd2
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 21f81b619bda..9765cc62a24c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -1300,6 +1300,36 @@ DECLARE_OOXMLEXPORT_TEST( testTableCellMargin, 
"table-cell-margin.docx" )
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(TestPuzzleExport, "TestPuzzleExport.odt")
+{
+// See tdf#148342 fo details
+// Get the doc
+uno::Reference< text::XTextDocument > xTextDoc(mxComponent, 
uno::UNO_QUERY_THROW);
+auto pSwDoc = dynamic_cast(xTextDoc.get());
+CPPUNIT_ASSERT(pSwDoc);
+// Create a metafile
+auto pMeta = pSwDoc->GetDocShell()->GetPreviewMetaFile();
+CPPUNIT_ASSERT(pMeta);
+MetafileXmlDump aDumper;
+auto pMetaXml = dumpAndParse(aDumper, *pMeta);
+CPPUNIT_ASSERT(pMetaXml);
+// After parsing check that node...
+auto pXNode = getXPathNode(pMetaXml, 
"/metafile/push/push/push/push[4]/push/push/polypolygon/polygon");
+CPPUNIT_ASSERT(pXNode);
+auto pNode = pXNode->nodesetval->nodeTab[0];
+CPPUNIT_ASSERT(pNode);
+auto it = pNode->children;
+int nCount = 0;
+// .. and count the children
+while (it != nullptr)
+{
+nCount++;
+it = it->next;
+}
+// In case of puzzle thre will be so many... Without the fix there was a 
rectangle with 4 points.
+CPPUNIT_ASSERT_GREATER(300, nCount);
+}
+
 // tdf#106742 for DOCX with compatibility level <= 14 (MS Word up to and incl. 
ver.2010), we should use cell margins when calculating table left border 
position
 DECLARE_OOXMLEXPORT_TEST( testTablePosition14, "table-position-14.docx" )
 {


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

2022-03-29 Thread Tünde Tóth (via logerrit)
 oox/source/shape/WpsContext.cxx  |   64 ++-
 sw/qa/extras/ooxmlexport/data/tdf135923-min.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   11 +++
 3 files changed, 63 insertions(+), 12 deletions(-)

New commits:
commit 49a40e3ed200e7c6d728f36d0b4be22dd85c51be
Author: Tünde Tóth 
AuthorDate: Thu Mar 3 11:25:31 2022 +0100
Commit: László Németh 
CommitDate: Tue Mar 29 13:01:18 2022 +0200

tdf#135923 DOCX shape import: set text color

to the character color of the shape if it is not comes
from direct formatting.

Change-Id: I3f0a3e952b5449a6d92c5bb273d353a561f3e3dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130922
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index d39f93fc8402..604065be9aad 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -155,20 +156,59 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 uno::Reference xTextCursor = 
xText->createTextCursor();
 xTextCursor->gotoStart(false);
 xTextCursor->gotoEnd(true);
-const uno::Reference 
xPropertyState(xTextCursor,
-   
uno::UNO_QUERY);
-const beans::PropertyState ePropertyState
-= xPropertyState->getPropertyState("CharColor");
-if (ePropertyState == beans::PropertyState_DEFAULT_VALUE)
+uno::Reference 
xTextBoxPropertySet(xTextCursor,
+
uno::UNO_QUERY);
+uno::Any xCharColor = 
xPropertySet->getPropertyValue("CharColor");
+Color aColor = COL_AUTO;
+if ((xCharColor >>= aColor) && aColor != COL_AUTO)
 {
-uno::Reference 
xTextBoxPropertySet(xTextCursor,
-
uno::UNO_QUERY);
-uno::Any xCharColor = 
xPropertySet->getPropertyValue("CharColor");
-Color aColor = COL_AUTO;
-if (xCharColor >>= aColor)
+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
 {
-if (aColor != COL_AUTO)
-xTextBoxPropertySet->setPropertyValue("CharColor", 
xCharColor);
+// 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());
+
+while (paraEnum->hasMoreElements())
+{
+uno::Reference 
xParagraph(paraEnum->nextElement(),
+
uno::UNO_QUERY);
+uno::Reference 
runEnumAccess(
+xParagraph, uno::UNO_QUERY);
+if (!runEnumAccess.is())
+continue;
+
+uno::Reference runEnum
+= runEnumAccess->createEnumeration();
+
+while (runEnum->hasMoreElements())
+{
+uno::Reference 
xRun(runEnum->nextElement(),
+  
uno::UNO_QUERY);
+const 
uno::Reference xRunState(
+xRun, uno::UNO_QUERY);
+if 
(xRunState->getPropertyState("CharColor")
+== beans::PropertyState_DEFAULT_VALUE)
+{
+uno::Reference 
xRunPropSet(
+ 

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

2022-03-27 Thread Andrea Gelmini (via logerrit)
 oox/source/drawingml/diagram/datamodel.hxx |2 +-
 oox/source/export/drawingml.cxx|4 ++--
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit f46068f963ab546f2f125e130ccd88bd119aa794
Author: Andrea Gelmini 
AuthorDate: Sun Mar 27 14:27:00 2022 +0200
Commit: Julien Nabet 
CommitDate: Sun Mar 27 15:17:01 2022 +0200

Fix typos

Change-Id: I003bd994be4a6a089dfacca1558e84324bf7fc1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132145
Reviewed-by: Julien Nabet 
Tested-by: Jenkins

diff --git a/oox/source/drawingml/diagram/datamodel.hxx 
b/oox/source/drawingml/diagram/datamodel.hxx
index 292b31c6dabd..8c8a9e8e165d 100644
--- a/oox/source/drawingml/diagram/datamodel.hxx
+++ b/oox/source/drawingml/diagram/datamodel.hxx
@@ -204,7 +204,7 @@ private:
 // the model definition,
 // - FillStyle
 // - Texts for oox::drawingml::Points/dgm::Points, associated by ModelId
-// - logic connections/assoziations
+// - logic connections/associations
 // - data point entries
 FillPropertiesPtr mpFillProperties;
 PointTextMap  maPointTextMap;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index d2f8f3be3c63..912f3921d406 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3897,7 +3897,7 @@ bool DrawingML::WriteCustomGeometry(
 return false;
 }
 
-// A EnhancedCustomShape2d caches the equation results. Therefor we use 
only one of it for the
+// A EnhancedCustomShape2d caches the equation results. Therefore we use 
only one of it for the
 // entire method.
 const EnhancedCustomShape2d 
aCustomShape2d(const_cast(rSdrObjCustomShape));
 
@@ -4279,7 +4279,7 @@ bool DrawingML::WriteCustomGeometry(
 double fHR = std::abs(fCurrentY - fY);
 double fStartAngle(0.0);
 double fSwingAngle(0.0);
-// The starting direction of the arc toggles 
beween X and Y
+// The starting direction of the arc toggles 
between X and Y
 if ((rSegment.Command == ELLIPTICALQUADRANTX 
&& !(k % 2))
 || (rSegment.Command == 
ELLIPTICALQUADRANTY && (k % 2)))
 {
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 8162b8fbb414..6d62d866f4b2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -53,7 +53,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf147861_customField, 
"tdf147861_customField.docx"
 {
 // These should each be specific values, not a shared DocProperty
 getParagraph(1, "CustomEditedTitle"); // edited
-// A couple of nulls at the end of the string thwarted all attemps at an 
"equals" comparison.
+// A couple of nulls at the end of the string thwarted all attempts at an 
"equals" comparison.
 CPPUNIT_ASSERT(getParagraph(2)->getString().startsWith(" INSERT Custom 
Title here"));
 getParagraph(3, "My Title"); // edited
 


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

2022-02-02 Thread Tünde Tóth (via logerrit)
 oox/source/drawingml/fillproperties.cxx |2 ++
 oox/source/export/drawingml.cxx |   15 +++
 sw/qa/extras/uiwriter/uiwriter4.cxx |   10 +++---
 3 files changed, 20 insertions(+), 7 deletions(-)

New commits:
commit b8925251e48534706c6960a54c320d3879317321
Author: Tünde Tóth 
AuthorDate: Mon Jan 17 15:00:13 2022 +0100
Commit: László Németh 
CommitDate: Thu Feb 3 08:59:10 2022 +0100

tdf#146822 OOXML: fix export of the transparency in hatch fill

The transparency value of the hatch was not exported.

Follow-up to commit 001afbed910b7e565f602c1b11b1b4538cd59442
"tdf#127989 OOXML: fix import of transparent hatching".

Change-Id: I9b82a3422de8e4f85c534f861c45c0c097ceb02f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128504
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 5d17c321d0f8..2b682bcd1b99 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -812,6 +812,8 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 {
 eFillStyle = FillStyle_HATCH;
 rPropMap.setProperty( ShapeProperty::FillHatch, 
createHatch( maPatternProps.moPattPreset.get(), aColor.getColor( 
rGraphicHelper, nPhClr ) ) );
+if( aColor.hasTransparency() )
+rPropMap.setProperty( ShapeProperty::FillTransparency, 
aColor.getTransparency() );
 
 // Set background color for hatch
 if(maPatternProps.maPattBgColor.isUsed())
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 09ca9c22915a..87bbe81bd88a 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1658,12 +1658,19 @@ void DrawingML::WritePattFill(const 
Reference& rXPropSet, const cs
 {
 mpFS->startElementNS(XML_a, XML_pattFill, XML_prst, 
GetHatchPattern(rHatch));
 
+sal_Int32 nAlpha = MAX_PERCENT;
+if (GetProperty(rXPropSet, "FillTransparence"))
+{
+sal_Int32 nTransparency = 0;
+mAny >>= nTransparency;
+nAlpha = (MAX_PERCENT - (PER_PERCENT * nTransparency));
+}
+
 mpFS->startElementNS(XML_a, XML_fgClr);
-WriteColor(::Color(ColorTransparency, rHatch.Color));
+WriteColor(::Color(ColorTransparency, rHatch.Color), nAlpha);
 mpFS->endElementNS( XML_a , XML_fgClr );
 
 ::Color nColor = COL_WHITE;
-sal_Int32 nAlpha  = 0;
 
 if ( GetProperty( rXPropSet, "FillBackground" ) )
 {
@@ -1671,13 +1678,13 @@ void DrawingML::WritePattFill(const 
Reference& rXPropSet, const cs
 mAny >>= isBackgroundFilled;
 if( isBackgroundFilled )
 {
-nAlpha = MAX_PERCENT;
-
 if( GetProperty( rXPropSet, "FillColor" ) )
 {
 mAny >>= nColor;
 }
 }
+else
+nAlpha = 0;
 }
 
 mpFS->startElementNS(XML_a, XML_bgClr);
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index c1635b64ffad..29d31a0940b2 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -3681,7 +3681,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, 
testTdf143760WrapContourToOff)
 CPPUNIT_ASSERT_EQUAL(false, getProperty(getShape(1), 
"SurroundContour"));
 }
 
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf127989)
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testHatchFill)
 {
 createSwDoc();
 
@@ -3695,16 +3695,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf127989)
 xShapeProps->setPropertyValue("FillStyle", 
uno::makeAny(drawing::FillStyle_HATCH));
 xShapeProps->setPropertyValue("FillHatchName", 
uno::makeAny(OUString("Black 0 Degrees")));
 xShapeProps->setPropertyValue("FillBackground", uno::makeAny(false));
+xShapeProps->setPropertyValue("FillTransparence", 
uno::makeAny(sal_Int32(30)));
 uno::Reference xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
 uno::Reference xDrawPage = 
xDrawPageSupplier->getDrawPage();
 xDrawPage->add(xShape);
 
 // Save it as DOCX and load it again.
-reload("Office Open XML Text", "tdf127989.docx");
+reload("Office Open XML Text", "hatchFill.docx");
 CPPUNIT_ASSERT_EQUAL(1, getShapes());
 
-// Without fix this had failed, because the background of the hatch was 
not set as 'no background'.
+// tdf#127989 Without fix this had failed, because the background of the 
hatch was not set as 'no background'.
 CPPUNIT_ASSERT(!getProperty(getShape(1), "FillBackground"));
+
+// tdf#146822 Without fix this had failed, because the transparency value 
of the hatch was not exported.
+CPPUNIT_ASSERT_EQUAL(sal_Int32(30), getProperty(getShape(1), 

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

2022-02-01 Thread Justin Luth (via logerrit)
 oox/source/drawingml/fillproperties.cxx |5 +
 sw/qa/extras/ooxmlexport/data/tdf141652_fillBitmapName.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx   |   10 ++
 3 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 18cc1240565e697859dd7d17058f91d5e01df929
Author: Justin Luth 
AuthorDate: Mon Jan 10 20:42:17 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue Feb 1 13:31:33 2022 +0100

tdf#141652 partial revert "Reset ShapeProperty priority...

... and handle only crop case."

This reverts a portion of a tdf#134210 related, LO 7.2/7.1.2ish
commit b90a67838e189f3aee6a50724c78c0a50d416970
that was introduced for no apparent reason.

I have no understanding about shapes, and so
I have no idea why setting FillBitmap to an xGraphic
is different from setting it to a name, but it makes
a huge difference on the image size,
and the crop values aren't scaled to the reduced size.

Since this section of code looks like a cut/paste
relic of early stages of developing the fix,
lets just revert this portion since the original
author has made no response at all to the regression report.

Change-Id: I9488c419ceb41bd4ebd7b10494a52fb816654832
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128260
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 6a60a685c84f..480bbe641737 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -789,10 +789,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 if(bIsCustomShape && bHasCropValues && bNeedCrop)
 {
 xGraphic = lclCropGraphic(xGraphic, aFillRect);
-if 
(rPropMap.supportsProperty(ShapeProperty::FillBitmapName))
-
rPropMap.setProperty(ShapeProperty::FillBitmapName, xGraphic);
-else
-
rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
+
rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
 }
 }
 }
diff --git a/sw/qa/extras/ooxmlexport/data/tdf141652_fillBitmapName.docx 
b/sw/qa/extras/ooxmlexport/data/tdf141652_fillBitmapName.docx
new file mode 100644
index ..4a47a544d6bb
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf141652_fillBitmapName.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index cb8d8b4cb4c7..e79b531b39ac 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -282,6 +282,16 @@ DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillBitmapCrop, 
"dml-shape-fillbitmapcrop.d
 
 }
 
+DECLARE_OOXMLEXPORT_TEST(test141652_fillBitmapName, 
"tdf141652_fillBitmapName.docx")
+{
+text::GraphicCrop aGraphicCropStruct = 
getProperty(getShape(1), "GraphicCrop");
+CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(-769), aGraphicCropStruct.Right, 
10);
+
+CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Left );
+CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Top );
+CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Bottom );
+}
+
 DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillPattern, "dml-shape-fillpattern.docx")
 {
 // Hatching was ignored by the export.


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

2022-01-03 Thread Tünde Tóth (via logerrit)
 oox/source/export/shapes.cxx|5 +
 sw/qa/extras/uiwriter/uiwriter4.cxx |   23 +++
 2 files changed, 28 insertions(+)

New commits:
commit 87db920b141fe9846cbd1b37fff3a9806a9b5c2d
Author: Tünde Tóth 
AuthorDate: Tue Nov 30 11:59:55 2021 +0100
Commit: László Németh 
CommitDate: Mon Jan 3 13:37:29 2022 +0100

tdf#98736 OOXML export: keep CaptionShape as TextShape

Caption shapes were lost during OOXML export. As a
workaround, export them as text shapes, losing
only the leader lines, but not their text shapes and
text content.

Change-Id: I372708fa4c9356c807a0a239c722691fd88ec1a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126123
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 35b7a4bd4c9d..997a6e949b76 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1668,6 +1668,11 @@ static const NameToConvertMapType& lcl_GetConverters()
 {
 static NameToConvertMapType const shape_converters
 {
+// tdf#98736 export CaptionShape as TextShape, because it is non-ooxml 
shape and
+//   we can't export this shape as CustomShape
+// TODO: WriteCaptionShape
+{ "com.sun.star.drawing.CaptionShape"  , 
::WriteTextShape },
+
 { "com.sun.star.drawing.ClosedBezierShape" , 
::WriteClosedPolyPolygonShape },
 { "com.sun.star.drawing.ConnectorShape", 
::WriteConnectorShape },
 { "com.sun.star.drawing.CustomShape"   , 
::WriteCustomShape },
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index fa9258949c07..0101e246a42d 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -290,6 +290,7 @@ public:
 void testInsertPdf();
 void testTdf143760WrapContourToOff();
 void testTdf127989();
+void testCaptionShape();
 
 CPPUNIT_TEST_SUITE(SwUiWriterTest4);
 CPPUNIT_TEST(testTdf96515);
@@ -413,6 +414,7 @@ public:
 CPPUNIT_TEST(testInsertPdf);
 CPPUNIT_TEST(testTdf143760WrapContourToOff);
 CPPUNIT_TEST(testTdf127989);
+CPPUNIT_TEST(testCaptionShape);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -4067,6 +4069,27 @@ void SwUiWriterTest4::testTdf127989()
 CPPUNIT_ASSERT(!getProperty(getShape(1), "FillBackground"));
 }
 
+void SwUiWriterTest4::testCaptionShape()
+{
+createSwDoc();
+
+// Add a caption shape to the document.
+uno::Reference xFactory(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xShape(
+xFactory->createInstance("com.sun.star.drawing.CaptionShape"), 
uno::UNO_QUERY);
+xShape->setSize(awt::Size(1, 1));
+xShape->setPosition(awt::Point(1000, 1000));
+uno::Reference xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xDrawPage = 
xDrawPageSupplier->getDrawPage();
+xDrawPage->add(xShape);
+
+// Save it as DOCX and load it again.
+reload("Office Open XML Text", "captionshape.docx");
+
+// Without fix in place, the shape was lost on export.
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest4);
 CPPUNIT_PLUGIN_IMPLEMENT();
 


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

2021-12-21 Thread Tünde Tóth (via logerrit)
 oox/source/drawingml/fillproperties.cxx |5 +++--
 sw/qa/extras/uiwriter/uiwriter4.cxx |   28 
 2 files changed, 31 insertions(+), 2 deletions(-)

New commits:
commit 001afbed910b7e565f602c1b11b1b4538cd59442
Author: Tünde Tóth 
AuthorDate: Wed Dec 8 11:13:24 2021 +0100
Commit: László Németh 
CommitDate: Tue Dec 21 16:00:54 2021 +0100

tdf#127989 OOXML: fix import of transparent hatching

Set FillBackground property of hatching fill to false,
if the alpha value is 0 in the  element, i.e.
if it's a transparent hatching. This way the previous
non-transparent hatching is transparent now.

Change-Id: I483d5c654be55e74c9073769b06f185526429635
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126550
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 12d2cd9ad2fd..6a60a685c84f 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -816,8 +816,9 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 // Set background color for hatch
 if(maPatternProps.maPattBgColor.isUsed())
 {
-rPropMap.setProperty( ShapeProperty::FillBackground, 
true );
-rPropMap.setProperty( ShapeProperty::FillColor, 
maPatternProps.maPattBgColor.getColor( rGraphicHelper, nPhClr ) );
+aColor = maPatternProps.maPattBgColor;
+rPropMap.setProperty( ShapeProperty::FillBackground, 
aColor.getTransparency() != 100 );
+rPropMap.setProperty( ShapeProperty::FillColor, 
aColor.getColor( rGraphicHelper, nPhClr ) );
 }
 }
 else if ( maPatternProps.maPattBgColor.isUsed() )
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index 726a939a55c9..fa9258949c07 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -289,6 +289,7 @@ public:
 void testTdf129270();
 void testInsertPdf();
 void testTdf143760WrapContourToOff();
+void testTdf127989();
 
 CPPUNIT_TEST_SUITE(SwUiWriterTest4);
 CPPUNIT_TEST(testTdf96515);
@@ -411,6 +412,7 @@ public:
 CPPUNIT_TEST(testTdf129270);
 CPPUNIT_TEST(testInsertPdf);
 CPPUNIT_TEST(testTdf143760WrapContourToOff);
+CPPUNIT_TEST(testTdf127989);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -4039,6 +4041,32 @@ void SwUiWriterTest4::testTdf143760WrapContourToOff()
 CPPUNIT_ASSERT_EQUAL(false, getProperty(getShape(1), 
"SurroundContour"));
 }
 
+void SwUiWriterTest4::testTdf127989()
+{
+createSwDoc();
+
+// Add a rectangle shape to the document.
+uno::Reference xFactory(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xShape(
+xFactory->createInstance("com.sun.star.drawing.RectangleShape"), 
uno::UNO_QUERY);
+xShape->setSize(awt::Size(1, 1));
+xShape->setPosition(awt::Point(1000, 1000));
+uno::Reference xShapeProps(xShape, uno::UNO_QUERY);
+xShapeProps->setPropertyValue("FillStyle", 
uno::makeAny(drawing::FillStyle_HATCH));
+xShapeProps->setPropertyValue("FillHatchName", 
uno::makeAny(OUString("Black 0 Degrees")));
+xShapeProps->setPropertyValue("FillBackground", uno::makeAny(false));
+uno::Reference xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xDrawPage = 
xDrawPageSupplier->getDrawPage();
+xDrawPage->add(xShape);
+
+// Save it as DOCX and load it again.
+reload("Office Open XML Text", "tdf127989.docx");
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+
+// Without fix this had failed, because the background of the hatch was 
not set as 'no background'.
+CPPUNIT_ASSERT(!getProperty(getShape(1), "FillBackground"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest4);
 CPPUNIT_PLUGIN_IMPLEMENT();
 


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

2021-09-10 Thread Vasily Melenchuk (via logerrit)
 oox/source/drawingml/textbodycontext.cxx |   11 +++
 oox/source/drawingml/textrun.cxx |8 -
 sw/qa/extras/ooxmlimport/data/tdf126426.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx|   38 +++
 4 files changed, 56 insertions(+), 1 deletion(-)

New commits:
commit 14d299f8f1e19b39dfa81e143762c6b277c1ae9a
Author: Vasily Melenchuk 
AuthorDate: Fri Aug 27 18:10:15 2021 +0300
Commit: Thorsten Behrens 
CommitDate: Fri Sep 10 12:27:14 2021 +0200

tdf#126426: support for hyperlinks in TextParagraphContext

Usually hyperlinks are processed by TextBodyContext, but
for grouped shape we accidentaly gone into TextParagraphContext
It has almost all possibilities to process txbxContent,
but not hyperlinks.

Additionally some hyperlink char attributes (color and underline)
can expand to follow up ordinal text. Additional small hack applied
to avoid this.

Unfortunately this is not a final solution: such document fails
roundtrip and hyperlinks are lost after saving to DOCX.

Change-Id: Ie954f53696bd872cb1f59cb586fb55f6cd7c73bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121172
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 

diff --git a/oox/source/drawingml/textbodycontext.cxx 
b/oox/source/drawingml/textbodycontext.cxx
index 0492ac22e44a..b1e5241aa19a 100644
--- a/oox/source/drawingml/textbodycontext.cxx
+++ b/oox/source/drawingml/textbodycontext.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include "hyperlinkcontext.hxx"
 
 #include 
 
@@ -104,6 +105,16 @@ ContextHandlerRef TextParagraphContext::onCreateContext( 
sal_Int32 aElementToken
 return this;
 case OOX_TOKEN(a14, m):
 return CreateLazyMathBufferingContext(*this, mrParagraph);
+case W_TOKEN( hyperlink ):
+{
+TextRunPtr pRun = std::make_shared();
+mrParagraph.addRun(pRun);
+// parse hyperlink attributes: use HyperLinkContext for that
+rtl::Reference pContext(new HyperLinkContext(
+*this, rAttribs, 
pRun->getTextCharacterProperties().maHyperlinkPropertyMap));
+// but create text run context because HyperLinkContext can't 
process internal w:r, w:t, etc
+return new RegularTextRunContext(*this, pRun);
+}
 default:
 SAL_WARN("oox", "TextParagraphContext::onCreateContext: unhandled 
element: " << getBaseToken(aElementToken));
 }
diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx
index ab87fb732141..e3bcecb745d5 100644
--- a/oox/source/drawingml/textrun.cxx
+++ b/oox/source/drawingml/textrun.cxx
@@ -69,7 +69,13 @@ sal_Int32 TextRun::insertAt(
 Any aOldFontFamily = xState->getPropertyDefault("CharFontFamily");
 
 TextCharacterProperties aTextCharacterProps( rTextCharacterStyle );
-aTextCharacterProps.assignUsed( maTextCharacterProperties );
+
+// If no text color specified lets anyway initialize it as default:
+// this will help to recover after hyperlink
+if (!aTextCharacterProps.maFillProperties.maFillColor.isUsed())
+aTextCharacterProps.maFillProperties.moFillType = XML_solidFill;
+
+aTextCharacterProps.assignUsed(maTextCharacterProperties);
 if ( aTextCharacterProps.moHeight.has() )
 nCharHeight = aTextCharacterProps.moHeight.get();
 else
diff --git a/sw/qa/extras/ooxmlimport/data/tdf126426.docx 
b/sw/qa/extras/ooxmlimport/data/tdf126426.docx
new file mode 100644
index ..d77051365ca2
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf126426.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index e132befdd09f..03f6b21d8c9f 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -903,6 +904,43 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf129912)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf126426)
+{
+load(mpTestDocumentPath, "tdf126426.docx");
+
+uno::Reference xGroup(getShape(1), 
uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroup->getCount());
+
+// get second shape in group
+uno::Reference 
xParaEnumAccess(xGroup->getByIndex(1),
+  
uno::UNO_QUERY_THROW);
+uno::Reference xParaEnum = 
xParaEnumAccess->createEnumeration();
+
+uno::Reference xPara(xParaEnum->nextElement(), 
uno::UNO_QUERY_THROW);
+uno::Reference xRunEnumAccess(xPara, 
uno::UNO_QUERY_THROW);
+
+uno::Reference xRunEnum = 
xRunEnumAccess->createEnumeration();
+{
+// Text before: was before this bugfix
+uno::Reference xRun(xRunEnum->nextElement(), 
uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(OUString("Some text 

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

2021-08-15 Thread Regina Henschel (via logerrit)
 oox/source/export/shapes.cxx|3 +-
 sw/qa/extras/ooxmlexport/data/tdf143860_NonPrimitiveCustomShape.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx  |   11 
++
 3 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit 24a8e3209b1d7c2f4f13d5cc3f69726253af9eff
Author: Regina Henschel 
AuthorDate: Sun Aug 15 18:48:32 2021 +0200
Commit: Regina Henschel 
CommitDate: Sun Aug 15 21:40:07 2021 +0200

tdf#143860 non-primitive needs custGeom not prstGeom

Error was, that for a custom shape with type 'non-primitive' method
DMLPresetShapeExporter::WriteShape() was called. For such shapes the
method GetOOXMLPresetGeometry() returns preset type 'rect' and in case
the shape had no handles, that preset geometry was written.
In my solution I exclude shapes of type 'non-primitive' from using
DMLPresetShapeExporter, because such shapes never belong to a OOXML
preset shape.

Change-Id: I714f69c98fe15c2b7e70dc0a474a7f85ad757034
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120511
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 325387f4991d..9b6bb4f8ed4f 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -843,7 +843,8 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 bool bPresetWriteSuccessful = false;
 // Let the custom shapes what has name and preset information in OOXML, to 
be written
 // as preset ones with parameters. Try that with this converter class.
-if (!sShapeType.startsWith("ooxml") && GetDocumentType() == DOCUMENT_DOCX
+if (!sShapeType.startsWith("ooxml") && sShapeType != "non-primitive"
+&& GetDocumentType() == DOCUMENT_DOCX
 && xShape->getShapeType() == "com.sun.star.drawing.CustomShape")
 {
 DMLPresetShapeExporter aCustomShapeConverter(this, xShape);
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf143860_NonPrimitiveCustomShape.odt 
b/sw/qa/extras/ooxmlexport/data/tdf143860_NonPrimitiveCustomShape.odt
new file mode 100644
index ..6a1222877031
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf143860_NonPrimitiveCustomShape.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 17d6204f97fd..51b713dc0d68 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -73,6 +73,17 @@ protected:
 }
 };
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf143860NonPrimitiveCustomShape,
+"tdf143860_NonPrimitiveCustomShape.odt")
+{
+// The document has a custom shape of type non-primitive without handles. 
Make sure that the shape
+// is not exported with preset but with custom geometry.
+xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
+CPPUNIT_ASSERT(pXmlDocument);
+assertXPath(pXmlDocument, "//a:prstGeom", 0);
+assertXPath(pXmlDocument, "//a:custGeom", 1);
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testWrapPolygonCurve, 
"tdf136386_WrapPolygonCurve.odt")
 {
 // Document has a curve with contour wrap and 'outside only'. Error was, 
that type 'square' was


[Libreoffice-commits] core.git: oox/source sw/qa writerfilter/source

2021-08-04 Thread Regina Henschel (via logerrit)
 oox/source/shape/LockedCanvasContext.cxx |   64 
+++---
 oox/source/shape/LockedCanvasContext.hxx |4 
 sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_image_line.docx |binary
 sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_position.docx   |binary
 sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_twoShapes.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |3 
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx|   38 
+
 writerfilter/source/dmapper/GraphicImport.cxx|6 
 8 files changed, 96 insertions(+), 19 deletions(-)

New commits:
commit 4fb5817ecb614bd0c83afb3627d7caadbfe8c082
Author: Regina Henschel 
AuthorDate: Thu Jul 29 22:02:25 2021 +0200
Commit: Miklos Vajna 
CommitDate: Wed Aug 4 14:39:34 2021 +0200

tdf#143476 improve import of lockedCanvas

A lockedCanvas is used in Word 2007 to include dml-shapes. It is
treated similar to a group, only that its content is not editable.

This patch changes the implementation so, that the lockedCanvas is
imported as group. Prior only content was imported in the case the
content was a single custom-shape or a single group.
That has resulted in these errors:
Image or line in a lockedCanvas were not imported at all.
Only one of several shapes in a lockedCanvas was imported.

I have changed mpShape to mpShapePtr to reflect the data type and be
consistent with ShapeContext.

The patch changes GraphicImport so, that lockedCanvas as special
version of a group is detected and handled. That solves regression
from commit 3262fc5ef3bde5b158909d11ccb008161ea95519

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

diff --git a/oox/source/shape/LockedCanvasContext.cxx 
b/oox/source/shape/LockedCanvasContext.cxx
index 0a56a42eda46..88a3de0040e7 100644
--- a/oox/source/shape/LockedCanvasContext.cxx
+++ b/oox/source/shape/LockedCanvasContext.cxx
@@ -9,9 +9,13 @@
 
 #include "LockedCanvasContext.hxx"
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -22,34 +26,64 @@ namespace oox::shape
 LockedCanvasContext::LockedCanvasContext(FragmentHandler2 const& rParent)
 : FragmentHandler2(rParent)
 {
+mpShapePtr = 
std::make_shared("com.sun.star.drawing.GroupShape");
+mpShapePtr->setLockedCanvas(true); // will be "LockedCanvas" in 
InteropGrabBag
 }
 
 LockedCanvasContext::~LockedCanvasContext() = default;
 
 ::oox::core::ContextHandlerRef
-LockedCanvasContext::onCreateContext(sal_Int32 nElementToken,
- const ::oox::AttributeList& /*rAttribs*/)
+LockedCanvasContext::onCreateContext(sal_Int32 nElementToken, const 
::oox::AttributeList& rAttribs)
 {
 switch (getBaseToken(nElementToken))
 {
-case XML_lockedCanvas:
-case XML_nvGrpSpPr:
-case XML_grpSpPr:
+case XML_nvGrpSpPr: // CT_GvmlGroupShapeNonVisual, child see at end
+return this;
+case XML_grpSpPr: // CT_GroupShapeProporties
+return new oox::drawingml::ShapePropertiesContext(*this, 
*mpShapePtr);
+case XML_txSp: // CT_GvmlTextShape
 break;
-case XML_sp:
+case XML_sp: // CT_GvmlShape
 {
-oox::drawingml::ShapePtr pMasterShape;
-mpShape = 
std::make_shared("com.sun.star.drawing.CustomShape");
-mpShape->setLockedCanvas(true);
-return new oox::drawingml::ShapeContext(*this, pMasterShape, 
mpShape);
+return new oox::drawingml::ShapeContext(
+*this, mpShapePtr,
+
std::make_shared("com.sun.star.drawing.CustomShape", 
true));
 }
-case XML_grpSp:
+case XML_cxnSp: // CT_GvmlConnector
 {
-oox::drawingml::ShapePtr pMasterShape;
-mpShape = 
std::make_shared("com.sun.star.drawing.GroupShape");
-mpShape->setLockedCanvas(true);
-return new oox::drawingml::ShapeGroupContext(*this, pMasterShape, 
mpShape);
+return new oox::drawingml::ConnectorShapeContext(
+*this, mpShapePtr,
+
std::make_shared("com.sun.star.drawing.ConnectorShape"));
 }
+case XML_pic: // CT_GvmlPicture
+{
+return new oox::drawingml::GraphicShapeContext(
+*this, mpShapePtr,
+
std::make_shared("com.sun.star.drawing.GraphicObjectShape"));
+}
+case XML_graphicFrame: // CT_GvmlGraphicObjectFrame
+{
+return new oox::drawingml::GraphicalObjectFrameContext(
+*this, mpShapePtr,
+
std::make_shared("com.sun.star.drawing.GraphicObjectShape"),
+   

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

2021-07-04 Thread Andreas Heinisch (via logerrit)
 oox/source/core/xmlfilterbase.cxx|   10 --
 sw/qa/extras/ooxmlexport/data/tdf143175.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx|   13 +
 3 files changed, 17 insertions(+), 6 deletions(-)

New commits:
commit 965639aec1407c25bed1716a1f2c3ee19923ec1a
Author: Andreas Heinisch 
AuthorDate: Sat Jul 3 21:00:20 2021 +0200
Commit: Noel Grandin 
CommitDate: Sun Jul 4 09:10:32 2021 +0200

tdf#143175 - Join elements including a delimiter using a standard iterator

Otherwise, the document's keywords will be duplicated since the first
keyword is written twice. Regression from 
I19eba57bc6058c317473d0746f06699a09ba2830.

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

diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index 307949ae4076..b2184e7a97d8 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -598,12 +599,9 @@ writeElement( const FSHelperPtr& pDoc, sal_Int32 
nXmlElement, const Sequence< OU
 return;
 
 OUStringBuffer sRep;
-sRep.append( aItems[ 0 ] );
-
-for( const OUString& rItem : aItems )
-{
-sRep.append( " " + rItem );
-}
+// tdf#143175 - join elements including a delimiter using a standard 
iterator
+::comphelper::intersperse(aItems.begin(), aItems.end(),
+  ::comphelper::OUStringBufferAppender(sRep), 
OUString(" "));
 
 writeElement( pDoc, nXmlElement, sRep.makeStringAndClear() );
 }
diff --git a/sw/qa/extras/ooxmlexport/data/tdf143175.docx 
b/sw/qa/extras/ooxmlexport/data/tdf143175.docx
new file mode 100644
index ..bcfbd2db763b
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf143175.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index fb21f41284b4..24c4ecbce63d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -166,6 +166,19 @@ DECLARE_OOXMLEXPORT_TEST(testUTF8CustomProperties, 
"tdf127864.docx")
 CPPUNIT_ASSERT_EQUAL(OUString(u"первый"), 
getProperty(xPropertySet, u"первый"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testKeywords, "tdf143175.docx")
+{
+uno::Reference 
xDocumentPropertiesSupplier(
+mxComponent, uno::UNO_QUERY);
+uno::Reference xDocumentProperties
+= xDocumentPropertiesSupplier->getDocumentProperties();
+uno::Sequence aKeywords(xDocumentProperties->getKeywords());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aKeywords.getLength());
+CPPUNIT_ASSERT_EQUAL(OUString("One"), aKeywords[0]);
+CPPUNIT_ASSERT_EQUAL(OUString("Two"), aKeywords[1]);
+CPPUNIT_ASSERT_EQUAL(OUString("Three"), aKeywords[2]);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testZoom, "zoom.docx")
 {
 uno::Reference xModel(mxComponent, uno::UNO_QUERY);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sw/qa sw/source writerfilter/qa writerfilter/source

2021-06-28 Thread Regina Henschel (via logerrit)
 oox/source/export/drawingml.cxx  |
4 
 sw/qa/extras/ooxmlexport/data/tdf142486_FrameShadow.odt  
|binary
 sw/qa/extras/ooxmlexport/data/tdf142486_LeftMarginShadowLeft.docx
|binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx |
4 
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx   |
2 
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx   |   
31 
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx|
4 
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx|
7 
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx|   
22 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |
2 
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx|   
14 
 sw/source/filter/ww8/docxsdrexport.cxx   |  
476 +++---
 writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx   |   
60 +
 writerfilter/qa/cppunittests/dmapper/data/tdf142304GroupPosition.docx
|binary
 writerfilter/qa/cppunittests/dmapper/data/tdf142305SquareWrapMargin.docx 
|binary
 writerfilter/qa/cppunittests/dmapper/data/tdf142305StrokeGlowMargin.docx 
|binary
 writerfilter/source/dmapper/GraphicImport.cxx|  
290 --
 writerfilter/source/dmapper/GraphicImport.hxx|
2 
 18 files changed, 671 insertions(+), 247 deletions(-)

New commits:
commit 3262fc5ef3bde5b158909d11ccb008161ea95519
Author: Regina Henschel 
AuthorDate: Sat May 15 23:40:34 2021 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jun 28 09:49:00 2021 +0200

tdf#142304 a.o. Improve wrap margins in docx filters

LO uses the bounding box of the shape in case of type 'Parallel'. Word
uses in the corresponding wrap 'square' a box based on the full size
of the shape. That will be very different in some cases, e.g. for an
arc. And Word exchanges width and height in case of rotation angle in
[45°;135°[ and [225°; 315°[. To get the same appearance as in Word,
the wrap margins are suitable expanded on import.

Word puts the additional space needed for fat strokes into effectExtent
in case of wrap 'inline', so there is no need to add the half strokes
width in addition. Word determines the area for the shape depending
on rotation angle. Both are now considered. Total same appearance is
not possible because it would need negative vertical wrap margins,
which are currently faulty in LO, see tdf#141880.

Patch solves in addition tdf#142486, tdf#142305

The export to Word would require negative values in effectExtent in
some cases. They are allowed in OOXML but not supported in Word. My
idea is to switch to wrap mode 'Tight' if needed. But export of wrap
has so many bad parts, that it needs separate work and is not
included here.

Handling of border width for export of own frames is missing.

Unittest changes

testDmlTextshapeB and TestDmlTextshape in ooxmlexport6.cxx are set to
current values. Import and Export still have large errors with these
shapes and correct value from file is unknown. So an exact value is
pointless. Only the original problem needs to be still fixed, which
is the case.

testWpsOnly in ooxmlexport10.cxx. I have removed the test for
LeftMargin equals 0. The test makes no sense, because the original
file has distL=114300.

testTdf124600 in ooxmlimport2.cxx.
I have added a tolerance. It would fail with Expected: 2029,
Actual:2028, likely a rounding problem somewhere.

testTdf124600 in ooxmlimport2.cxx
Word refers to outer edge of the border for align='left', LO aligns
at snap rectangle. The different intepretations become visible if a
thick line is used. LO needs a margin to get the same rendering as in
Word. So an expected value of 0 is wrong and I have disabled the test
for now. ToDo: tdf#142798. Get the correct margin and activate the
test then.

testTextframeGradient in ooxmlexport2.cxx. I didn't find any reference
for a default value. The test is not reliable, I get both 316 and 318
as actual value. Handling of shadow in VML shapes is buggy, the values
for margin and shadow are wrong anyway. Reports are e.g. tdf#142486,
tdf#142558. For now I have added a tolerance of 2.

testDMLGroupShapeChildPosition in ooxmlexport6.cxx. The accuracy has
become better. After reload we get the same values as before.

testEffectExtent in ooxmlexport.cxx. tdf#142805. I have disabled the
test, because the image is not loaded at all, and therefore it makes
no sense to test a margin of it. And you can only test the sum of
distL and effectExtent l, because LO has only one 

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

2021-06-18 Thread Andreas Heinisch (via logerrit)
 oox/source/core/xmlfilterbase.cxx|3 ++-
 sw/qa/extras/ooxmlexport/data/tdf127864.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx|   11 +++
 3 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit d50501d1b4c015232c31c75a16b96143d43f7a3f
Author: Andreas Heinisch 
AuthorDate: Fri Jun 11 21:40:35 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Fri Jun 18 12:10:17 2021 +0200

tdf#127864 - Export custom document properties using utf8 text encoding

Change-Id: Iaca1f9251e87ec199b55888c1ab6421a654d1f9f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117071
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index a8532d206d31..307949ae4076 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -858,7 +858,8 @@ writeCustomProperties( XmlFilterBase& rSelf, const 
Reference< XDocumentPropertie
 {
 if ( !rProp.Name.isEmpty() )
 {
-OString aName = OUStringToOString( rProp.Name, 
RTL_TEXTENCODING_ASCII_US );
+// tdf#127864 - export custom document properties using utf8 text 
encoding
+OString aName = OUStringToOString(rProp.Name, 
RTL_TEXTENCODING_UTF8);
 // Skip storing these values in Custom Properties as it will be 
stored in Core/Extended Properties
 if (( aName == "OOXMLCorePropertyCategory" ) || // stored in 
cp:category
 ( aName == "OOXMLCorePropertyContentStatus" ) || // stored in 
cp:contentStatus
diff --git a/sw/qa/extras/ooxmlexport/data/tdf127864.docx 
b/sw/qa/extras/ooxmlexport/data/tdf127864.docx
new file mode 100644
index ..a9e59d933186
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf127864.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index aa1378398992..aaecebc5cf94 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -155,6 +155,17 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testCustomProperties, 
"custom-properties.doc
 assertXPathContent(pXmlDoc, "/cp:coreProperties/dc:identifier", 
"identifier");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testUTF8CustomProperties, "tdf127864.docx")
+{
+uno::Reference 
xDocumentPropertiesSupplier(
+mxComponent, uno::UNO_QUERY);
+uno::Reference xDocumentProperties
+= xDocumentPropertiesSupplier->getDocumentProperties();
+uno::Reference xPropertySet(
+xDocumentProperties->getUserDefinedProperties(), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString(u"первый"), 
getProperty(xPropertySet, u"первый"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testZoom, "zoom.docx")
 {
 uno::Reference xModel(mxComponent, uno::UNO_QUERY);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-06-15 Thread Regina Henschel (via logerrit)
 oox/source/export/drawingml.cxx|4 +++-
 sw/qa/extras/ooxmlexport/data/tdf142361ShadowDirection.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx |   13 +
 3 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 58eeec036c3780188feccb0e1a752cfdee90a49b
Author: Regina Henschel 
AuthorDate: Tue Jun 15 01:47:44 2021 +0200
Commit: Regina Henschel 
CommitDate: Tue Jun 15 18:26:50 2021 +0200

tdf#142361 export: prevent shadow to rotate with shape

OOXML has the feature to rotate a shadow together with the shape. The
associated attribute rotWithShape has the default value 'true'. So
if this attribute is missing, MS Office shows the shadow rotated. As
LibreOffice never rotates a shadow, we need to write this attribute
always. Because LibreOffice cannot rotate shadows, the error is only
visible in MS Office.

Here the attribute is added for the case of documents, which have no
InteropGrabBag or no effects in it.

When a shadow is generated in MS Office, MSO adds the attribute with
value 'false' (0) to the file. MS Office has no UI to set this
attribute. Problem is with cases, where the document comes from
MS Office, has effects in InteropGrabBag, but the shadow was set in
LibreOffice. To add the attribute in such cases too, bug tdf#142858
has to be fixed.

Change-Id: I5f1df416bca8ea15a305242afb140d852cfd84c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117206
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 385af08d590b..5f42dc18cd75 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -4241,7 +4241,7 @@ void DrawingML::WriteShapeEffects( const Reference< 
XPropertySet >& rXPropSet )
 if( bHasShadow )
 {
 Sequence< PropertyValue > aShadowGrabBag( 3 );
-Sequence< PropertyValue > aShadowAttribsGrabBag( 3 );
+Sequence< PropertyValue > aShadowAttribsGrabBag( 4 );
 
 double dX = +0.0, dY = +0.0;
 sal_Int32 nBlur =0;
@@ -4255,6 +4255,8 @@ void DrawingML::WriteShapeEffects( const Reference< 
XPropertySet >& rXPropSet )
 aShadowAttribsGrabBag[1].Value <<= lcl_CalculateDir(dX, dY);
 aShadowAttribsGrabBag[2].Name = "blurRad";
 aShadowAttribsGrabBag[2].Value <<=  
oox::drawingml::convertHmmToEmu(nBlur);
+aShadowAttribsGrabBag[3].Name = "rotWithShape";
+aShadowAttribsGrabBag[3].Value <<= false; //ooxml default is 
'true', so must write it
 
 aShadowGrabBag[0].Name = "Attribs";
 aShadowGrabBag[0].Value <<= aShadowAttribsGrabBag;
diff --git a/sw/qa/extras/ooxmlexport/data/tdf142361ShadowDirection.odt 
b/sw/qa/extras/ooxmlexport/data/tdf142361ShadowDirection.odt
new file mode 100644
index ..78372e603542
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf142361ShadowDirection.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index f75faf8bbe04..b550e62ef6a2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -505,6 +505,19 @@ DECLARE_OOXMLEXPORT_TEST(testCommentDoneModel, 
"CommentDone.docx")
 }
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(Test_ShadowDirection, 
"tdf142361ShadowDirection.odt")
+{
+// The attribute 'rotWithShape' has the default value 'true' in OOXML, so 
Words interprets a
+// missing attribute as 'true'. That means that Word rotates the shadow if 
the shape is
+// rotated. Because in LibreOffice a shadow is never rotated, we must not 
omit this
+// attribute.
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+assertXPath(pXmlDoc,
+
"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/"
+
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw",
+"rotWithShape", "0");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-06-10 Thread Tünde Tóth (via logerrit)
 oox/source/drawingml/chart/axisconverter.cxx |   10 ++
 sw/qa/extras/layout/data/tdf15.docx  |binary
 sw/qa/extras/layout/layout2.cxx  |   16 +++-
 3 files changed, 17 insertions(+), 9 deletions(-)

New commits:
commit 6185d1ff0130b3d178d5e50eeb6944ab70db41f9
Author: Tünde Tóth 
AuthorDate: Wed Jun 2 11:51:13 2021 +0200
Commit: László Németh 
CommitDate: Thu Jun 10 15:03:52 2021 +0200

tdf#140623 Chart OOXML import: set text overlap to false

of category axis label unless the rotation is 0 in xml.

Regression from commit: 21620f9d2f50e66dffc45a5afb539edb8d54434c
(tdf#138194 Chart OOXML import: set text break to true)

Change-Id: I18db7483f49c84a83760200037f8858a3b471994
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116575
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/chart/axisconverter.cxx 
b/oox/source/drawingml/chart/axisconverter.cxx
index 1a8e23024612..7aa141c0f798 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -271,10 +271,12 @@ void AxisConverter::convertFromModel(const 
Reference& rxCoord
 }
 else
 {
-// do not overlap text when the rotation is undefined in 
xml
-bool bTextOverlap
-= mrModel.mxTextProp.is()
-  && 
mrModel.mxTextProp->getTextProperties().moRotation.has();
+// do not overlap text unless the rotation is 0 in xml
+bool bTextOverlap = false;
+if (mrModel.mxTextProp.is()
+&& 
mrModel.mxTextProp->getTextProperties().moRotation.has())
+bTextOverlap
+= 
mrModel.mxTextProp->getTextProperties().moRotation.get() == 0;
 aAxisProp.setProperty(PROP_TextOverlap, bTextOverlap);
 /* do not break text into several lines unless the 
rotation is 0 degree,
or the rotation is 90 degree and the inner size of the 
chart is not fixed,
diff --git a/sw/qa/extras/layout/data/tdf15.docx 
b/sw/qa/extras/layout/data/tdf15.docx
index 2b2b24a5548d..e4f0cc35f0e8 100644
Binary files a/sw/qa/extras/layout/data/tdf15.docx and 
b/sw/qa/extras/layout/data/tdf15.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 27488737e536..3b14e16ac943 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -409,7 +409,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf131707)
 assertXPath(pXmlDoc, 
"//body/tab/row[3]/cell[2]/txt/anchored/fly/infos/bounds", "top", "2185");
 }
 
-#if HAVE_MORE_FONTS
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf15)
 {
 SwDoc* pDoc = createDoc("tdf15.docx");
@@ -421,12 +420,19 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf15)
 xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
 CPPUNIT_ASSERT(pXmlDoc);
 
-assertXPathContent(pXmlDoc,
-   
"/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[8]/text",
-   "Advanced Diploma");
+// Bug 15 - FILEOPEN DOCX Textbox of Column chart legend reduces and 
text of legend disappears
+const sal_Int32 nLegendLabelLines
+= getXPathContent(pXmlDoc, "count(//text[contains(text(),\"Advanced 
Diploma\")])")
+  .toInt32();
 // This failed, if the legend label is not "Advanced Diploma".
+CPPUNIT_ASSERT_EQUAL(static_cast(1), nLegendLabelLines);
+
+// Bug 140623 - Fileopen DOCX: Text Orientation of X-Axis 0 instead of 45 
degrees
+const sal_Int32 nThirdLabelLines
+= getXPathContent(pXmlDoc, 
"count(//text[contains(text(),\"Hispanic\")])").toInt32();
+// This failed, if the third X axis label broke to multiple lines.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), nThirdLabelLines);
 }
-#endif
 
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125335)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sw/qa writerfilter/qa writerfilter/source

2021-04-22 Thread Regina Henschel (via logerrit)
 oox/source/drawingml/shape.cxx   |
4 
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx|
3 
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx|
8 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |
3 
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx|   
15 -
 writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx   |   
65 +
 writerfilter/qa/cppunittests/dmapper/data/tdf141540ChildRotation.docx
|binary
 writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupLinePosSize.docx 
|binary
 writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupRotation.docx
|binary
 writerfilter/source/dmapper/GraphicImport.cxx|  
121 +-
 10 files changed, 203 insertions(+), 16 deletions(-)

New commits:
commit 2a70cfb09c4d89154d229b6a95cf076e8bd76798
Author: Regina Henschel 
AuthorDate: Sun Apr 11 13:03:27 2021 +0200
Commit: Miklos Vajna 
CommitDate: Thu Apr 22 10:12:32 2021 +0200

tdf#141540 fix docx import of group or line with rotation

... and fix case wrap 'Square' and 'in Line' with them.
Non-uniform scaling of a rotated shape might produce skew. Such had
happened, when setting group or line to the size contained in
GraphicImport. Avoid it.
Writer has special rules for shape position and marging in case of wrap
'Square' and 'in Line', depending on rotation angle. The patch adds
the needed margins.
The patch changes some unit tests where we now get slightly different
values.
The patch fixes the wrong skew in sample document of tdf#73022.

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

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 729fb3c3712f..49f82a6fd137 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -982,6 +982,10 @@ Reference< XShape > const & Shape::createAndInsert(
 // TODO: use ph color when applying effect properties
 //sal_Int32 nEffectPhClr = -1;
 
+// dmapper needs the original rotation angle for calculating square 
wrap. This angle is not
+// available as property there, so store it in InteropGrabBag.
+putPropertyToGrabBag("mso-rotation-angle", Any(mnRotation));
+
 if( pTheme )
 {
 if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 03eff3c65513..603b1010b59a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -77,6 +77,9 @@ DECLARE_OOXMLEXPORT_TEST(testRelorientation, 
"relorientation.docx")
 uno::Reference 
xShapeDescriptor(xGroup->getByIndex(0), uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), 
xShapeDescriptor->getShapeType());
 
+// 'actual child size' = 'group ext' * 'child ext' / 'chExt from group', 
see section 'chExt' in
+// [MS-OI29500]. Here for width from file 3108960 * 4896 / 4911 = 3099464 
EMU. That corresponds to
+// width 8.61cm and 325px in UI in Word and rounds down to 8609 Hmm. 
FIXME: Expected value is wrong.
 // Right after import we get a rounding error: 8662 vs 8664.
 if (mbExported)
 {
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index 7639e995b86a..0a71b2535587 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -125,12 +125,14 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testDmlTextshapeB, 
"dml-textshapeB.docx")
 uno::Reference xGroup(getShape(1), 
uno::UNO_QUERY);
 uno::Reference xShape(xGroup->getByIndex(3), 
uno::UNO_QUERY);
 // Connector was incorrectly shifted towards the top left corner, X was 
192, Y was -5743.
-CPPUNIT_ASSERT_EQUAL(sal_Int32(3778), xShape->getPosition().X);
-CPPUNIT_ASSERT_EQUAL(sal_Int32(-5066), xShape->getPosition().Y);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3776), xShape->getPosition().X);
+// Value as of LO7.2. Whole group is still shifted 3mm to rigth and 5mm 
down.
+CPPUNIT_ASSERT_EQUAL(sal_Int32(-5063), xShape->getPosition().Y);
 
 xShape.set(xGroup->getByIndex(5), uno::UNO_QUERY);
 // This was incorrectly shifted towards the top of the page, Y was -5011.
-CPPUNIT_ASSERT_EQUAL(sal_Int32(-4715), xShape->getPosition().Y);
+// Value as of LO 7.2
+CPPUNIT_ASSERT_EQUAL(sal_Int32(-4712), xShape->getPosition().Y);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testDMLSolidfillAlpha, "dml-solidfill-alpha.docx")
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index fe15ef8d94de..84183572cefd 100644

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

2021-03-26 Thread Xisco Fauli (via logerrit)
 oox/source/drawingml/shape.cxx   |   13 ++---
 sw/qa/extras/ooxmlimport/data/tdf122717.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |   13 +
 3 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit 3e4eb070787d4d44b3bdc95046e5b231dbbef42b
Author: Xisco Fauli 
AuthorDate: Thu Mar 25 17:38:20 2021 +0100
Commit: Miklos Vajna 
CommitDate: Fri Mar 26 09:10:17 2021 +0100

tdf#122717: fix handling of zero width/height lines

The code was introduced in 627c2469843c9461b665c4571f1214aca7fc36a4
< tdf#96674 drawingML import: fix handling of zero width/height lines >
and later on removed by 36bade04d3780bc54c51b46bb0b63e69789658a5
< tdf106792 Get rid of SvxShapePolyPolygonBezier > with the comment

"I doubt that the additional code to make a line not exactly hor/ver is 
needed.
Checked and it is not needed, thus removed the change from
tdf#96674 in shape.cxx."

it turned out, it's still needed

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

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index bc2d7b59f1d8..819d117d4fa9 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -856,10 +856,17 @@ Reference< XShape > const & Shape::createAndInsert(
 uno::Reference xModelInfo(rFilterBase.getModel(), 
uno::UNO_QUERY);
 for( i = 0; i < nNumPoints; ++i )
 {
-const basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
+basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
 
-// tdf#106792 Not needed anymore due to the change in 
SdrPathObj::NbcResize:
-// tdf#96674: Guard against zero width or height.
+// Guard against zero width or height.
+if (i)
+{
+const basegfx::B2DPoint& rPreviousPoint = aPoly.getB2DPoint(i 
- 1);
+if (aPoint.getX() - rPreviousPoint.getX() == 0)
+aPoint.setX(aPoint.getX() + 1);
+if (aPoint.getY() - rPreviousPoint.getY() == 0)
+aPoint.setY(aPoint.getY() + 1);
+}
 
 pPoints[i] = awt::Point(static_cast(aPoint.getX()), 
static_cast(aPoint.getY()));
 }
diff --git a/sw/qa/extras/ooxmlimport/data/tdf122717.docx 
b/sw/qa/extras/ooxmlimport/data/tdf122717.docx
new file mode 100644
index ..9a2098272c75
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf122717.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index b8f725a9d109..216fb0de07c0 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1429,6 +1429,19 @@ DECLARE_OOXMLIMPORT_TEST(testTdf96674, "tdf96674.docx")
 CPPUNIT_ASSERT(aActualSize.Height > 0);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf122717, "tdf122717.docx")
+{
+uno::Reference xShape = getShape(1);
+CPPUNIT_ASSERT(xShape.is());
+awt::Size aActualSize(xShape->getSize());
+// Without the fix in place, this test would have failed with
+// - Expected: 2
+// - Actual  : 8160
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aActualSize.Width);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(8160), aActualSize.Height);
+
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf98882, "tdf98882.docx")
 {
 sal_Int32 nFlyHeight = parseDump("//fly/infos/bounds", "height").toInt32();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-03-18 Thread Xisco Fauli (via logerrit)
 oox/source/drawingml/shape.cxx   |9 --
 sw/qa/extras/ooxmlimport/data/tdf118693.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |   12 +---
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx|   37 +++
 4 files changed, 40 insertions(+), 18 deletions(-)

New commits:
commit c9e5640c8fcad7beb42a66f9bee0252eee9fe323
Author: Xisco Fauli 
AuthorDate: Thu Mar 18 00:48:49 2021 +0100
Commit: Miklos Vajna 
CommitDate: Thu Mar 18 09:15:32 2021 +0100

tdf#118693: no need to use convertMm100ToTwip() for line shapes anymore

It was introduced in 11129d89b152db54c86bb2bda58c24b8abb6c5a8
< tdf#85232 WPG import: fix handling of line shapes >
and later in 36bade04d3780bc54c51b46bb0b63e69789658a5
< tdf106792 Get rid of SvxShapePolyPolygonBezier >
ForceMetricToItemPoolMetric was added to 
SvxShapePolyPolygon::setPropertyValueImpl
to convert from 100thmm to twips as can be read
in the comment in testTdf85232
With this change, xShape->getPosition().X in testTdf85232
is 2267, which was already in twips

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

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 469dc7c30c17..45a7a7e64307 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -852,7 +852,6 @@ Reference< XShape > const & Shape::createAndInsert(
 uno::Sequence< awt::Point > aPointSequence( nNumPoints );
 awt::Point* pPoints = aPointSequence.getArray();
 uno::Reference xModelInfo(rFilterBase.getModel(), 
uno::UNO_QUERY);
-bool bIsWriter = 
xModelInfo->supportsService("com.sun.star.text.TextDocument");
 for( i = 0; i < nNumPoints; ++i )
 {
 const basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
@@ -860,13 +859,7 @@ Reference< XShape > const & Shape::createAndInsert(
 // tdf#106792 Not needed anymore due to the change in 
SdrPathObj::NbcResize:
 // tdf#96674: Guard against zero width or height.
 
-if (bIsWriter && bNoTranslation)
-// Writer's draw page is in twips, and these points get passed
-// to core without any unit conversion when Writer
-// postprocesses only the group shape itself.
-pPoints[i] = 
awt::Point(static_cast(convertMm100ToTwip(aPoint.getX())), 
static_cast(convertMm100ToTwip(aPoint.getY(;
-else
-pPoints[i] = awt::Point(static_cast(aPoint.getX()), 
static_cast(aPoint.getY()));
+pPoints[i] = awt::Point(static_cast(aPoint.getX()), 
static_cast(aPoint.getY()));
 }
 uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( 1 );
 aPolyPolySequence.getArray()[ 0 ] = aPointSequence;
diff --git a/sw/qa/extras/ooxmlimport/data/tdf118693.docx 
b/sw/qa/extras/ooxmlimport/data/tdf118693.docx
new file mode 100644
index ..4e832398bcd5
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf118693.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 16351d9fcb35..8163c0c10377 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1346,16 +1346,8 @@ DECLARE_OOXMLIMPORT_TEST(testTdf85232, "tdf85232.docx")
 // Make sure we're not testing the ellipse child.
 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.LineShape"), 
xShapeDescriptor->getShapeType());
 
-// tdf#106792 checked that during load of tdf85232.docx the method
-// SvxShapePolyPolygon::setPropertyValueImpl is used three times. In
-// that method, a call to ForceMetricToItemPoolMetric was missing so
-// that the import did not convert the input values from 100thmm
-// to twips what is needed due to the object residing in Writer. The
-// UNO API by definition is in 100thmm. Result is that in 
SwXShape::getPosition
-// the offset (aOffset) now is (0, 0) instead of an existing offset in
-// the load of the document before (what is plausible for a GroupObject).
-// Thus, I will adapt the result value here to the now (hopefully) correct 
one.
-CPPUNIT_ASSERT_EQUAL(static_cast(1630), 
xShape->getPosition().X); // was: 2267
+// This was 2900: horizontal position of the line was incorrect, the 3 
children were not connected visually.
+CPPUNIT_ASSERT_EQUAL(static_cast(2267), 
xShape->getPosition().X);
 }
 
 DECLARE_OOXMLIMPORT_TEST(testTdf95755, "tdf95755.docx")
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 474cfbe2b13d..fcfaccafb774 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -196,6 +196,43 @@ DECLARE_OOXMLIMPORT_TEST(testTdf120547, 

[Libreoffice-commits] core.git: oox/source sw/qa writerfilter/source

2021-02-25 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/vml/vmlshape.cxx   |2 -
 sw/qa/extras/layout/data/tdf138465min.docx|binary
 sw/qa/extras/layout/layout2.cxx   |   16 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   29 ++
 4 files changed, 36 insertions(+), 11 deletions(-)

New commits:
commit ca7855c24af858f52a11a593761ee9e6b9d6ba79
Author: Attila Bakos (NISZ) 
AuthorDate: Thu Feb 18 13:42:00 2021 +0100
Commit: László Németh 
CommitDate: Thu Feb 25 16:23:50 2021 +0100

tdf#136570 OOXML import: fix height of OLE objects

e.g. OLE icons or math formulas by skipping unset
border properties.

Regression from 636d16efe45a55c1a5a7a451c46fbb8618bf0393
(tdf#135653 OOXML import: fix OLE background color).

Change-Id: I64bd68037d063de81fbb302b90d65b77af50a622
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/19
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index b6caaa0f3214..2d4e99c7be3f 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1457,7 +1457,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( 
const Reference< XShapes
 oox::drawingml::ShapePropertyMap 
aPropMap(mrDrawing.getFilter().getModelObjectHelper());
 const GraphicHelper& rGraphicHelper = 
mrDrawing.getFilter().getGraphicHelper();
 maTypeModel.maStrokeModel.pushToPropMap(aPropMap, rGraphicHelper);
-//And, fill-color properties as well...
+// And, fill-color properties as well...
 maTypeModel.maFillModel.pushToPropMap(aPropMap, rGraphicHelper);
 PropertySet(xShape).setProperties(aPropMap);
 
diff --git a/sw/qa/extras/layout/data/tdf138465min.docx 
b/sw/qa/extras/layout/data/tdf138465min.docx
new file mode 100755
index ..d576a54f281f
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf138465min.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index de6c48d56783..0b3f23d48bc7 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -518,6 +518,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf126425)
 assertXPath(pXmlDoc, "//textarray", 14);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testUnusedOLEprops)
+{
+CPPUNIT_ASSERT(createDoc("tdf138465min.docx"));
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+CPPUNIT_ASSERT(pXmlDoc);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: >300
+// - Actual  : 142
+// i.e. the formula squashed
+CPPUNIT_ASSERT_GREATEREQUAL(
+double(300),
+getXPath(pXmlDoc, 
"/root/page/body/txt[2]/anchored/fly/notxt/infos/bounds", "height")
+.toDouble());
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf123268)
 {
 SwDoc* pDoc = createDoc("tdf123268.odt");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 8ace7179ad18..c102d7bcc565 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2321,11 +2321,13 @@ void DomainMapper_Impl::appendOLE( const OUString& 
rStreamName, const std::share
 xReplacementProperties->getPropertyValue("LineWidth") >>= 
aBorderProps.LineWidth;
 xReplacementProperties->getPropertyValue("LineStyle") >>= 
aBorderProps.LineStyle;
 
-xOLEProperties->setPropertyValue("RightBorder", 
uno::Any(aBorderProps));
-xOLEProperties->setPropertyValue("TopBorder", 
uno::Any(aBorderProps));
-xOLEProperties->setPropertyValue("LeftBorder", 
uno::Any(aBorderProps));
-xOLEProperties->setPropertyValue("BottomBorder", 
uno::Any(aBorderProps));
-
+if (aBorderProps.LineStyle) // Set line props only if LineStyle is 
set
+{
+xOLEProperties->setPropertyValue("RightBorder", 
uno::Any(aBorderProps));
+xOLEProperties->setPropertyValue("TopBorder", 
uno::Any(aBorderProps));
+xOLEProperties->setPropertyValue("LeftBorder", 
uno::Any(aBorderProps));
+xOLEProperties->setPropertyValue("BottomBorder", 
uno::Any(aBorderProps));
+}
 OUString pProperties[] = {
 "AnchorType",
 "Surround",
@@ -2339,17 +2341,24 @@ void DomainMapper_Impl::appendOLE( const OUString& 
rStreamName, const std::share
 "LeftMargin",
 "RightMargin",
 "TopMargin",
-"BottomMargin",
-"FillStyle",
-"FillColor",
-"FillColor2",
-"LineStyle",
+"BottomMargin"
 };
 for (const OUString& s : pProperties)
 {
 const uno::Any aVal = 

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

2021-01-08 Thread Tünde Tóth (via logerrit)
 oox/source/drawingml/chart/axisconverter.cxx |7 ++-
 sw/qa/extras/layout/data/tdf138773.docx  |binary
 sw/qa/extras/layout/layout2.cxx  |   18 ++
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit 2752fd1b665694a4db3a4e34c7fdc8780a86492e
Author: Tünde Tóth 
AuthorDate: Tue Jan 5 09:19:40 2021 +0100
Commit: László Németh 
CommitDate: Fri Jan 8 13:53:42 2021 +0100

tdf138773 Chart OOXML import: set text overlap to false

of category axis label, if the rotation is undefined in xml,
to avoid e.g. missing rotation of them.

Regression from commit: 21620f9d2f50e66dffc45a5afb539edb8d54434c
(tdf#138194 Chart OOXML import: set text break to true)

Change-Id: I5b03614eca547a206afc0d8118e3f6c055ed5348
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108792
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/chart/axisconverter.cxx 
b/oox/source/drawingml/chart/axisconverter.cxx
index 8f062d001eeb..1a8e23024612 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -270,7 +271,11 @@ void AxisConverter::convertFromModel(const 
Reference& rxCoord
 }
 else
 {
-aAxisProp.setProperty(PROP_TextOverlap, true);
+// do not overlap text when the rotation is undefined in 
xml
+bool bTextOverlap
+= mrModel.mxTextProp.is()
+  && 
mrModel.mxTextProp->getTextProperties().moRotation.has();
+aAxisProp.setProperty(PROP_TextOverlap, bTextOverlap);
 /* do not break text into several lines unless the 
rotation is 0 degree,
or the rotation is 90 degree and the inner size of the 
chart is not fixed,
or the rotation is 270 degree and the inner size of the 
chart is not fixed */
diff --git a/sw/qa/extras/layout/data/tdf138773.docx 
b/sw/qa/extras/layout/data/tdf138773.docx
new file mode 100644
index ..656c596bc458
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf138773.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 4ce216cf112e..bcb1f4c0f074 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -733,6 +733,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194)
 assertXPath(pXmlDoc, "//textarray", 8);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138773)
+{
+SwDoc* pDoc = createDoc("tdf138773.docx");
+SwDocShell* pShell = pDoc->GetDocShell();
+
+// Dump the rendering of the first page as an XML file.
+std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile();
+MetafileXmlDump dumper;
+xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+CPPUNIT_ASSERT(pXmlDoc);
+
+const sal_Int32 nFirstLabelLines
+= getXPathContent(pXmlDoc, 
"count(//text[contains(text(),\"2000-01\")])").toInt32();
+
+// This failed, if the first X axis label broke to multiple lines.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), nFirstLabelLines);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124796)
 {
 SwDoc* pDoc = createDoc("tdf124796.odt");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-10-30 Thread Szabolcs Toth (via logerrit)
 oox/source/vml/vmlshape.cxx |4 
+
 sw/qa/extras/ooxmlexport/data/tdf137642_Vertical_Alignment_toppage.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx   |   34 
+-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 799522882159b839cc7aeec2fbc48f767507a30c
Author: Szabolcs Toth 
AuthorDate: Wed Oct 28 09:50:00 2020 +0100
Commit: Balazs Varga 
CommitDate: Fri Oct 30 11:53:40 2020 +0100

tdf#137642 VML shape import: fix alignment from top margin

Use the new define PAGE_PRINT_AREA_TOP at import.
Everything else is handled in the previous patches.

Change-Id: Ie801ab71a33a657551dbc5bfb63d1491aaa73abd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104923
Tested-by: Jenkins
Reviewed-by: Balazs Varga 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index a83cb6b2c76c..1e3e1f72e64d 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -608,6 +608,10 @@ static void lcl_SetAnchorType(PropertySet& rPropSet, const 
ShapeTypeModel& rType
 {
 rPropSet.setProperty(PROP_VertOrientRelation, 
text::RelOrientation::PAGE_PRINT_AREA);
 }
+else if (rTypeModel.maPositionVerticalRelative == "top-margin-area")
+{
+rPropSet.setProperty(PROP_VertOrientRelation, 
text::RelOrientation::PAGE_PRINT_AREA_TOP);
+}
 else if (rTypeModel.maPositionVerticalRelative == "bottom-margin-area")
 {
 rPropSet.setProperty(PROP_VertOrientRelation, 
text::RelOrientation::PAGE_PRINT_AREA_BOTTOM);
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf137642_Vertical_Alignment_toppage.docx 
b/sw/qa/extras/ooxmlexport/data/tdf137642_Vertical_Alignment_toppage.docx
new file mode 100644
index ..fbe8b264bbc4
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf137642_Vertical_Alignment_toppage.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 4c0dfbf9ebbb..b9f01391e3f2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -1560,8 +1560,9 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf115557, 
"tdf115557.docx")
 assertXPath(pXmlDoc, "//w:footnote/w:p/w:r/w:drawing", 1);
 }
 
-DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testAlignmentRelativeFromTopMargin, 
"tdf137641_RelativeFromTopMargin.docx")
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testAlignmentRelativeFromTopMarginDML, 
"tdf137641_RelativeFromTopMargin.docx")
 {
+// Import as DML.
 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
 
 assertXPath(pXmlDoc,
@@ -1590,6 +1591,37 @@ 
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testAlignmentRelativeFromTopMargin, "tdf1376
"center");
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testAlignmentRelativeFromTopMarginVML, 
"tdf137642_Vertical_Alignment_toppage.docx")
+{
+// Import as VML.
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+
+assertXPath(pXmlDoc,
+
"/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/"
+"wp:anchor/wp:positionV",
+"relativeFrom", "topMargin");
+assertXPathContent(pXmlDoc,
+   
"/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/"
+   "wp:anchor/wp:positionV/wp:align",
+   "top");
+assertXPath(pXmlDoc,
+
"/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/"
+"wp:anchor/wp:positionV",
+"relativeFrom", "topMargin");
+assertXPathContent(pXmlDoc,
+   
"/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/"
+   "wp:anchor/wp:positionV/wp:align",
+   "bottom");
+assertXPath(pXmlDoc,
+
"/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/"
+"wp:anchor/wp:positionV",
+"relativeFrom", "topMargin");
+assertXPathContent(pXmlDoc,
+   
"/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/"
+   "wp:anchor/wp:positionV/wp:align",
+   "center");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-10-29 Thread Regényi Balázs (via logerrit)
 oox/source/vml/vmlshape.cxx  |   34 
++
 sw/qa/extras/ooxmlexport/data/tdf137765_testVmlLineShapeRotated.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |   16 

 3 files changed, 37 insertions(+), 13 deletions(-)

New commits:
commit 7774d01891df6787058677dee4bc449cd5841c59
Author: Regényi Balázs 
AuthorDate: Mon Oct 26 11:52:29 2020 +0100
Commit: László Németh 
CommitDate: Thu Oct 29 15:18:22 2020 +0100

tdf#137765 DOCX VML shape import: fix rotation handling

Change-Id: I78c89d4f795a67ff44ae9cef9daf44bf9f1d5c8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104807
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 43b54a658db6..a83cb6b2c76c 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -679,7 +679,8 @@ Reference< XShape > SimpleShape::implConvertAndInsert( 
const Reference< XShapes
 awt::Rectangle aShapeRect(rShapeRect);
 std::optional oRotation;
 bool bFlipX = false, bFlipY = false;
-if (!maTypeModel.maRotation.isEmpty())
+// tdf#137765: skip this rotation for line shapes
+if (!maTypeModel.maRotation.isEmpty() && maService != 
"com.sun.star.drawing.LineShape")
 oRotation = ConversionHelper::decodeRotation(maTypeModel.maRotation);
 if (!maTypeModel.maFlip.isEmpty())
 {
@@ -1035,6 +1036,22 @@ namespace
 }
 }
 }
+
+void handleRotation(const ShapeTypeModel& rTypeModel, Reference& 
rxShape)
+{
+if (!rTypeModel.maRotation.isEmpty())
+{
+if (SdrObject* pShape = GetSdrObjectFromXShape(rxShape))
+{
+// -1 is required because the direction of MSO rotation is the 
opposite of ours
+// 100 is required because in this part of the code the angle 
is in a hundredth of
+// degrees.
+auto nAngle = -1 * 100.0 * rTypeModel.maRotation.toDouble();
+double nHRad = nAngle * F_PI18000;
+pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle, 
sin(nHRad), cos(nHRad));
+}
+}
+}
 }
 
 LineShape::LineShape(Drawing& rDrawing)
@@ -1045,6 +1062,8 @@ LineShape::LineShape(Drawing& rDrawing)
 Reference LineShape::implConvertAndInsert(const Reference& 
rxShapes, const awt::Rectangle& rShapeRect) const
 {
 Reference xShape = SimpleShape::implConvertAndInsert(rxShapes, 
rShapeRect);
+// tdf#137765
+handleRotation(maTypeModel, xShape);
 // tdf#97517 tdf#137678
 // The MirroredX and MirroredY properties (in the CustomShapeGeometry 
property) are not
 // supported for the LineShape by UNO, so we have to make the mirroring 
here.
@@ -1174,18 +1193,7 @@ Reference< XShape > BezierShape::implConvertAndInsert( 
const Reference< XShapes
 
 // tdf#105875 handle rotation
 // Note: must rotate before flip!
-if (!maTypeModel.maRotation.isEmpty())
-{
-if (SdrObject* pShape = GetSdrObjectFromXShape(xShape))
-{
-// -1 is required because the direction of MSO rotation is the 
opposite of ours
-// 100 is required because in this part of the code the angle is 
in a hundredth of
-// degrees.
-auto nAngle = -1 * 100.0 * maTypeModel.maRotation.toDouble();
-double nHRad = nAngle * F_PI18000;
-pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle, 
sin(nHRad), cos(nHRad));
-}
-}
+handleRotation(maTypeModel, xShape);
 
 // Handle horizontal and vertical flip.
 handleMirroring(maTypeModel, xShape);
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf137765_testVmlLineShapeRotated.docx 
b/sw/qa/extras/ooxmlexport/data/tdf137765_testVmlLineShapeRotated.docx
new file mode 100644
index ..d411d7cda6fe
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf137765_testVmlLineShapeRotated.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index d38b5cfcd605..d7d76898c86a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1313,6 +1313,22 @@ DECLARE_OOXMLEXPORT_TEST(testVmlLineShapeMirroredY, 
"tdf137678_testVmlLineShapeM
 CPPUNIT_ASSERT(sStyle.indexOf("flip:y") > 0);
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testVmlLineShapeRotated, 
"tdf137765_testVmlLineShapeRotated.docx")
+{
+// tdf#137765 The "rotation" (in style attribute) was not handled 
correctly for VML line shapes.
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// it was 1.55pt,279.5pt
+assertXPath(pXmlDoc,
+
"/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:line",
+"from",
+"-9pt,296.75pt");
+// it was 25.5pt,317.8pt
+assertXPath(pXmlDoc,
+

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

2020-10-27 Thread Regényi Balázs (via logerrit)
 oox/source/vml/vmlshape.cxx|   53 
+-
 sw/qa/extras/ooxmlexport/data/tdf137678_testVmlLineShapeMirroredY.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx |   12 
++
 3 files changed, 39 insertions(+), 26 deletions(-)

New commits:
commit ca83804ffcd0d6f81fa7c32be990c4ceeb4a60b7
Author: Regényi Balázs 
AuthorDate: Thu Oct 22 16:12:11 2020 +0200
Commit: László Németh 
CommitDate: Tue Oct 27 14:05:55 2020 +0100

tdf#137678 DOCX VML shape import: fix missing horizontal mirroring

The MirroredY property is set (in the CustomShapeGeometry property), but
it is not supported for the LineShape by UNO, so we have to make the
mirroring during importing.

Change-Id: Iaa7e3a352598ad12c5e0d40b4fcd43fd197c4df9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104662
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 54f1fcec5ae6..43b54a658db6 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1013,6 +1013,28 @@ namespace
 aPoint2.setY(aPoint2.getY() + 1);
 pShape->NbcMirror(aCenter, aPoint2);
 }
+
+void doMirrorY(SdrObject* pShape)
+{
+Point aCenter(pShape->GetSnapRect().Center());
+Point aPoint2(aCenter);
+aPoint2.setX(aPoint2.getX() + 1);
+pShape->NbcMirror(aCenter, aPoint2);
+}
+
+void handleMirroring(const ShapeTypeModel& rTypeModel, Reference& 
rxShape)
+{
+if (!rTypeModel.maFlip.isEmpty())
+{
+if (SdrObject* pShape = GetSdrObjectFromXShape(rxShape))
+{
+if (rTypeModel.maFlip.startsWith("x"))
+doMirrorX(pShape);
+if (rTypeModel.maFlip.endsWith("y"))
+doMirrorY(pShape);
+}
+}
+}
 }
 
 LineShape::LineShape(Drawing& rDrawing)
@@ -1023,17 +1045,10 @@ LineShape::LineShape(Drawing& rDrawing)
 Reference LineShape::implConvertAndInsert(const Reference& 
rxShapes, const awt::Rectangle& rShapeRect) const
 {
 Reference xShape = SimpleShape::implConvertAndInsert(rxShapes, 
rShapeRect);
-// Handle vertical flip.
-// tdf#97517 The MirroredX property (in the CustomShapeGeometry property) 
is not supported for
-// the LineShape by UNO, so we have to make the mirroring here
-if (!maTypeModel.maFlip.isEmpty())
-{
-if (SdrObject* pShape = GetSdrObjectFromXShape(xShape))
-{
-if (maTypeModel.maFlip.startsWith("x"))
-doMirrorX(pShape);
-}
-}
+// tdf#97517 tdf#137678
+// The MirroredX and MirroredY properties (in the CustomShapeGeometry 
property) are not
+// supported for the LineShape by UNO, so we have to make the mirroring 
here.
+handleMirroring(maTypeModel, xShape);
 return xShape;
 }
 
@@ -1173,21 +1188,7 @@ Reference< XShape > BezierShape::implConvertAndInsert( 
const Reference< XShapes
 }
 
 // Handle horizontal and vertical flip.
-if (!maTypeModel.maFlip.isEmpty())
-{
-if (SdrObject* pShape = GetSdrObjectFromXShape(xShape))
-{
-if (maTypeModel.maFlip.startsWith("x"))
-doMirrorX(pShape);
-if (maTypeModel.maFlip.endsWith("y"))
-{
-Point aCenter(pShape->GetSnapRect().Center());
-Point aPoint2(aCenter);
-aPoint2.setX(aPoint2.getX() + 1);
-pShape->NbcMirror(aCenter, aPoint2);
-}
-}
-}
+handleMirroring(maTypeModel, xShape);
 
 return xShape;
 }
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf137678_testVmlLineShapeMirroredY.docx 
b/sw/qa/extras/ooxmlexport/data/tdf137678_testVmlLineShapeMirroredY.docx
new file mode 100644
index ..1559358b562b
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf137678_testVmlLineShapeMirroredY.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 8fa7391abcc7..ba955f016cce 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1299,6 +1299,18 @@ DECLARE_OOXMLEXPORT_TEST(testVmlLineShapeMirroredX, 
"tdf97517_testVmlLineShapeMi
 CPPUNIT_ASSERT(sStyle.indexOf("flip:x") > 0);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testVmlLineShapeMirroredY, 
"tdf137678_testVmlLineShapeMirroredY.docx")
+{
+// tdf#137678 The "flip:y" was not handled for VML line shapes.
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+if (!pXmlDoc)
+return;
+OUString sStyle = getXPath(pXmlDoc,
+
"/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:line",
+"style");
+CPPUNIT_ASSERT(sStyle.indexOf("flip:y") > 0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 

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

2020-10-22 Thread Bartosz Kosiorek (via logerrit)
 oox/source/core/xmlfilterbase.cxx|  126 +++
 oox/source/docprop/docprophandler.cxx|   51 +--
 sw/qa/extras/ooxmlexport/data/custom-properties.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx|   51 +--
 4 files changed, 175 insertions(+), 53 deletions(-)

New commits:
commit a87af93ff874a55b81e55b46b63798fde4cefc4f
Author: Bartosz Kosiorek 
AuthorDate: Thu Oct 15 19:57:45 2020 +0200
Commit: Bartosz Kosiorek 
CommitDate: Thu Oct 22 14:42:27 2020 +0200

tdf#103987 Avoid duplication of the Custom Properties during OOXML export

The MS Office is case insensitive for Properties.
As a result properties names: ContentType and contentType
are treated as the same properties.
Additionally some Core and Extended File Properties does not exist
in LibreOffice standard.

To resolve that such properties are stored in LibreOffice Custom File 
Properties.
For example:
 - category
 - contentStatus
 - contentType
 - identifier
 - version

Unfortunately if user specify Custom Property which differ only with case,
there will be conflict. To solve that the properties were renamed to be 
unique:
 - OOXMLCorePropertiesCategory
 - OOXMLCorePropertiesContentStatus
 - OOXMLCorePropertiesContentType
 - OOXMLCorePropertiesIdentifier
 - OOXMLCorePropertiesVersion

Additionally if internal property have default value, then the value will
not be imported into Custom File Property.
During export to OOXML (eg. docx) The values which are already stored
in Core or Extended File Properties, are not stored
into Custom File Properties to avoid duplication.

Change-Id: Ifc2b88ab74aa41d12ba968fff199062ce8dc96ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104384
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
Reviewed-by: Bartosz Kosiorek 

diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index 43f4e573229a..259e0bf2e406 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -640,17 +640,44 @@ writeCoreProperties( XmlFilterBase& rSelf, const 
Reference< XDocumentProperties
 FSNS(XML_xmlns, XML_dcmitype), rSelf.getNamespaceURL(OOX_NS(dcmiType)),
 FSNS(XML_xmlns, XML_xsi),  rSelf.getNamespaceURL(OOX_NS(xsi)));
 
-#ifdef OOXTODO
-writeElement( pCoreProps, FSNS( XML_cp, XML_category ), "category" 
);
-writeElement( pCoreProps, FSNS( XML_cp, XML_contentStatus ),"status" );
-writeElement( pCoreProps, FSNS( XML_cp, XML_contentType ),  
"contentType" );
-#endif  /* def OOXTODO */
+uno::Reference 
xUserDefinedProperties(xProperties->getUserDefinedProperties(), uno::UNO_QUERY);
+comphelper::SequenceAsHashMap 
aUserDefinedProperties(xUserDefinedProperties->getPropertyValues());
+comphelper::SequenceAsHashMap::iterator it;
+
+it = aUserDefinedProperties.find("OOXMLCorePropertyCategory");
+if (it != aUserDefinedProperties.end())
+{
+OUString aValue;
+if (it->second >>= aValue)
+writeElement( pCoreProps, FSNS( XML_cp, XML_category ), aValue );
+}
+
+it = aUserDefinedProperties.find("OOXMLCorePropertyContentStatus");
+if (it != aUserDefinedProperties.end())
+{
+OUString aValue;
+if (it->second >>= aValue)
+writeElement( pCoreProps, FSNS( XML_cp, XML_contentStatus ), 
aValue );
+}
+
+it = aUserDefinedProperties.find("OOXMLCorePropertyContentType");
+if (it != aUserDefinedProperties.end())
+{
+OUString aValue;
+if (it->second >>= aValue)
+writeElement( pCoreProps, FSNS( XML_cp, XML_contentType ), aValue 
);
+}
 writeElement( pCoreProps, FSNS( XML_dcterms, XML_created ), 
xProperties->getCreationDate() );
 writeElement( pCoreProps, FSNS( XML_dc, XML_creator ),  
xProperties->getAuthor() );
 writeElement( pCoreProps, FSNS( XML_dc, XML_description ),  
xProperties->getDescription() );
-#ifdef OOXTODO
-writeElement( pCoreProps, FSNS( XML_dc, XML_identifier ),   "ident" );
-#endif  /* def OOXTODO */
+
+it = aUserDefinedProperties.find("OOXMLCorePropertyIdentifier");
+if (it != aUserDefinedProperties.end())
+{
+OUString aValue;
+if (it->second >>= aValue)
+writeElement( pCoreProps, FSNS( XML_dc, XML_identifier ), aValue );
+}
 writeElement( pCoreProps, FSNS( XML_cp, XML_keywords ), 
xProperties->getKeywords() );
 writeElement( pCoreProps, FSNS( XML_dc, XML_language ), 
LanguageTag( xProperties->getLanguage()) );
 writeElement( pCoreProps, FSNS( XML_cp, XML_lastModifiedBy ),   
xProperties->getModifiedBy() );
@@ -659,9 +686,14 @@ writeCoreProperties( XmlFilterBase& rSelf, const 
Reference< XDocumentProperties
 writeElement( pCoreProps, FSNS( XML_cp, XML_revision ), 

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

2020-10-17 Thread Bartosz Kosiorek (via logerrit)
 oox/source/core/xmlfilterbase.cxx|4 +
 sw/qa/extras/ooxmlexport/data/custom-properties.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx|   47 +++
 sw/qa/unit/swmodeltestbase.cxx   |   10 
 4 files changed, 60 insertions(+), 1 deletion(-)

New commits:
commit f25f804b0009f026cfac665bb8ec03b4656d81fb
Author: Bartosz Kosiorek 
AuthorDate: Fri Oct 16 16:46:52 2020 +0200
Commit: Michael Stahl 
CommitDate: Sat Oct 17 12:44:48 2020 +0200

tdf#133377 OOXML Fix storage of date in Custom Properties

During exporting documents into OOXML formats (docx, xlsx, pptx),
if custom properties have Date format, the day and year were switched.

This commit fixes that.

Change-Id: Id497602eb3354de78bfd52bf5ef61d32aafd957d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104450
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index dbc419c28a3e..43f4e573229a 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -826,11 +826,13 @@ writeCustomProperties( XmlFilterBase& rSelf, const 
Reference< XDocumentPropertie
 util::DateTime aDateTime;
 if ( rProp.Value >>= num )
 {
+// i4 - 4-byte signed integer
+// r8 - 8-byte real number
 writeElement( pAppProps, FSNS( XML_vt, XML_i4 ), num );
 }
 else if ( rProp.Value >>= aDate )
 {
-aDateTime = util::DateTime( 0, 0 , 0, 0, aDate.Year, 
aDate.Month, aDate.Day, true );
+aDateTime = util::DateTime( 0, 0 , 0, 0, aDate.Day, 
aDate.Month, aDate.Year, true );
 writeElement( pAppProps, FSNS( XML_vt, XML_filetime ), 
aDateTime);
 }
 else if ( rProp.Value >>= aDuration )
diff --git a/sw/qa/extras/ooxmlexport/data/custom-properties.docx 
b/sw/qa/extras/ooxmlexport/data/custom-properties.docx
new file mode 100644
index ..33cce91f7ec4
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/custom-properties.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index f05f6251ed48..a77d41b64094 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -85,6 +85,53 @@ DECLARE_OOXMLEXPORT_TEST(testPageGraphicBackground, 
"page-graphic-background.odt
 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty(xPageStyle, 
"BackColor"));
 }
 
+
+DECLARE_OOXMLEXPORT_TEST(testCustomProperties, "custom-properties.docx")
+{
+// tdf#133377 FILESAVE XLSX: Make sure the custom/core/application file 
properties
+// are stored correctly after roundtrip to .docx
+
+// Extended file properties - specific to Office package,
+// eg. docx - Number of Pages, pptx - Number of Slides
+xmlDocUniquePtr pXmlDoc = parseExport("docProps/app.xml");
+if (!pXmlDoc)
+return;
+
+assertXPathContent(pXmlDoc, 
"/extended-properties:Properties/extended-properties:Paragraphs", "1");
+//assertXPathContent(pXmlDoc, 
"/extended-properties:Properties/extended-properties:Lines", "1");
+assertXPathContent(pXmlDoc, 
"/extended-properties:Properties/extended-properties:Pages", "1");
+assertXPathContent(pXmlDoc, 
"/extended-properties:Properties/extended-properties:Words", "3");
+assertXPathContent(pXmlDoc, 
"/extended-properties:Properties/extended-properties:Characters", "21");
+assertXPathContent(pXmlDoc, 
"/extended-properties:Properties/extended-properties:CharactersWithSpaces", 
"23");
+assertXPathContent(pXmlDoc, 
"/extended-properties:Properties/extended-properties:Company", "kompany");
+
+// Custom file properties - defined by user
+xmlDocUniquePtr pCustomXml = parseExport("docProps/custom.xml");
+assertXPath(pCustomXml, 
"/custom-properties:Properties/custom-properties:property[12]",
+"name", "testDateProperty");
+assertXPathContent(pCustomXml, 
"/custom-properties:Properties/custom-properties:property[12]/vt:filetime",
+   "1982-04-19T10:00:00Z");
+assertXPath(pCustomXml, 
"/custom-properties:Properties/custom-properties:property[14]",
+"name", "testNegativeNumberProperty");
+assertXPathContent(pCustomXml, 
"/custom-properties:Properties/custom-properties:property[14]/vt:i4",
+   "-100");
+assertXPath(pCustomXml, 
"/custom-properties:Properties/custom-properties:property[17]",
+"name", "testTextProperty");
+assertXPathContent(pCustomXml, 
"/custom-properties:Properties/custom-properties:property[17]/vt:lpwstr",
+   "testPropertyValue");
+assertXPath(pCustomXml, 

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

2020-10-09 Thread Regényi Balázs (via logerrit)
 oox/source/export/shapes.cxx  |   36 +++---
 sw/qa/extras/ooxmlexport/data/tdf99810-lost-arrow.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx |   10 +
 3 files changed, 33 insertions(+), 13 deletions(-)

New commits:
commit 7b2f0094f86266c64972d3e505a28b2d4e5caef6
Author: Regényi Balázs 
AuthorDate: Tue Oct 6 15:52:18 2020 +0200
Commit: László Németh 
CommitDate: Fri Oct 9 10:31:20 2020 +0200

tdf#99810 DOCX export: fix lost arrow shape

by saving connector shape as shape element
wps:wps instead of the invalid wps:cxnSp.

Co-author-by: Szabolcs Tóth

Change-Id: I0ed435eff8e4284f04f71f8fa8c1dc4cfbee5af9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104032
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 215d56595ebc..00a44d3fccfa 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1309,19 +1309,29 @@ ShapeExport& ShapeExport::WriteConnectorShape( const 
Reference< XShape >& xShape
 aRect.setHeight( aStartPoint.Y - aEndPoint.Y );
 }
 
-pFS->startElementNS(mnXmlNamespace, XML_cxnSp);
+// tdf#99810 connector shape (cxnSp) is not valid with namespace 'wps'
+const auto nShapeNode = (mnXmlNamespace == XML_wps ? XML_wsp : XML_cxnSp);
+pFS->startElementNS(mnXmlNamespace, nShapeNode);
 
-// non visual shape properties
-pFS->startElementNS(mnXmlNamespace, XML_nvCxnSpPr);
-pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
-  XML_id, OString::number(GetNewShapeID(xShape)),
-  XML_name, GetShapeName(xShape));
-// non visual connector shape drawing properties
-pFS->startElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
-WriteConnectorConnections( aConnectorEntry, GetShapeID( rXShapeA ), 
GetShapeID( rXShapeB ) );
-pFS->endElementNS( mnXmlNamespace, XML_cNvCxnSpPr );
-pFS->singleElementNS(mnXmlNamespace, XML_nvPr);
-pFS->endElementNS( mnXmlNamespace, XML_nvCxnSpPr );
+if (mnXmlNamespace == XML_wps)
+{
+// non visual connector shape drawing properties
+pFS->singleElementNS(mnXmlNamespace, XML_cNvCnPr);
+}
+else
+{
+// non visual shape properties
+pFS->startElementNS(mnXmlNamespace, XML_nvCxnSpPr);
+pFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
+XML_id, OString::number(GetNewShapeID(xShape)),
+XML_name, GetShapeName(xShape));
+// non visual connector shape drawing properties
+pFS->startElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
+WriteConnectorConnections(aConnectorEntry, GetShapeID(rXShapeA), 
GetShapeID(rXShapeB));
+pFS->endElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
+pFS->singleElementNS(mnXmlNamespace, XML_nvPr);
+pFS->endElementNS(mnXmlNamespace, XML_nvCxnSpPr);
+}
 
 // visual shape properties
 pFS->startElementNS(mnXmlNamespace, XML_spPr);
@@ -1336,7 +1346,7 @@ ShapeExport& ShapeExport::WriteConnectorShape( const 
Reference< XShape >& xShape
 // write text
 WriteTextBox( xShape, mnXmlNamespace );
 
-pFS->endElementNS( mnXmlNamespace, XML_cxnSp );
+pFS->endElementNS(mnXmlNamespace, nShapeNode);
 
 return *this;
 }
diff --git a/sw/qa/extras/ooxmlexport/data/tdf99810-lost-arrow.odt 
b/sw/qa/extras/ooxmlexport/data/tdf99810-lost-arrow.odt
new file mode 100644
index ..20e60f6cef06
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf99810-lost-arrow.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 200d34033ede..ec359b119b58 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1152,6 +1152,16 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testBodyPrUpright, 
"tdf123610_handle_upright
 "/a:graphic/a:graphicData/wps:wsp/wps:bodyPr", "upright", "1");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testLostArrow, "tdf99810-lost-arrow.odt")
+{
+// tdf#99810: check whether we use normal shape instead of connector shape 
if the XML namespace
+// is wps, because wps:
+xmlDocUniquePtr pDoc = parseExport("word/document.xml");
+
+assertXPath(pDoc, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
+"/a:graphic/a:graphicData/wps:wsp");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-10-06 Thread Regényi Balázs (via logerrit)
 oox/source/vml/vmlshape.cxx   |   26 
---
 sw/qa/extras/ooxmlexport/data/tdf105875_VmlShapeRotationWithFlip.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx|   34 
++
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |4 -
 4 files changed, 51 insertions(+), 13 deletions(-)

New commits:
commit 3b6de95a0d59cf5942af5ecf4a402c224b76f8a3
Author: Regényi Balázs 
AuthorDate: Wed Sep 30 15:19:36 2020 +0200
Commit: László Németh 
CommitDate: Tue Oct 6 11:22:17 2020 +0200

tdf#105875 DOCX VML shape import: fix missing rotation

Also to avoid bad resizing of the rotated
shape, remove obsolete(?) code part from
commit 0423a6741fc08a35b123556f9b10219d090ee42a
(Import bezier curves from .docx.).

Co-authored-by: Szabolcs Toth

Change-Id: I77266ba65e558cf9e6dd0e1c37fad85abd038819
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103693
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 6cd5aff9110d..d70a9563e106 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1129,6 +1129,21 @@ Reference< XShape > BezierShape::implConvertAndInsert( 
const Reference< XShapes
 aPropSet.setProperty( PROP_PolyPolygonBezier, aBezierCoords );
 }
 
+// tdf#105875 handle rotation
+// Note: must rotate before flip!
+if (!maTypeModel.maRotation.isEmpty())
+{
+if (SdrObject* pShape = GetSdrObjectFromXShape(xShape))
+{
+// -1 is required because the direction of MSO rotation is the 
opposite of ours
+// 100 is required because in this part of the code the angle is 
in a hundredth of
+// degrees.
+auto nAngle = -1 * 100.0 * maTypeModel.maRotation.toDouble();
+double nHRad = nAngle * F_PI18000;
+pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle, 
sin(nHRad), cos(nHRad));
+}
+}
+
 // Handle horizontal and vertical flip.
 if (!maTypeModel.maFlip.isEmpty())
 {
@@ -1151,17 +1166,6 @@ Reference< XShape > BezierShape::implConvertAndInsert( 
const Reference< XShapes
 }
 }
 
-// Hacky way of ensuring the shape is correctly sized/positioned
-try
-{
-// E.g. SwXFrame::setPosition() unconditionally throws
-xShape->setSize( awt::Size( rShapeRect.Width, rShapeRect.Height ) );
-xShape->setPosition( awt::Point( rShapeRect.X, rShapeRect.Y ) );
-}
-catch (const ::css::uno::Exception&)
-{
-// TODO: try some other way to ensure size/position
-}
 return xShape;
 }
 
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf105875_VmlShapeRotationWithFlip.docx 
b/sw/qa/extras/ooxmlexport/data/tdf105875_VmlShapeRotationWithFlip.docx
new file mode 100644
index ..e6512e075c21
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf105875_VmlShapeRotationWithFlip.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 4f77681d2eaf..27a651d2dde7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -1347,6 +1347,40 @@ DECLARE_OOXMLEXPORT_TEST(testTdf77236_MissingSolidFill, 
"tdf77236_MissingSolidFi
 assertXPath(pXmlDoc, 
"//mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill",
 1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf105875_VmlShapeRotationWithFlip, 
"tdf105875_VmlShapeRotationWithFlip.docx")
+{
+// tdf#105875: check whether the rotation of the VML bezier shape is ok 
(with flip too)
+// TODO: fix export too
+if (mbExported)
+return;
+
+{
+uno::Reference xPropertySet(getShape(1), 
uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), 
xPropertySet->getPropertyValue("RotateAngle").get());
+}
+
+{
+uno::Reference xPropertySet(getShape(2), 
uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(220 * 100), 
xPropertySet->getPropertyValue("RotateAngle").get(), 1);
+}
+
+{
+uno::Reference xPropertySet(getShape(3), 
uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(320 * 100), 
xPropertySet->getPropertyValue("RotateAngle").get(), 1);
+}
+
+{
+uno::Reference xPropertySet(getShape(4), 
uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(140 * 100), 
xPropertySet->getPropertyValue("RotateAngle").get(), 1);
+}
+
+{
+uno::Reference xPropertySet(getShape(5), 
uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(40 * 100), 
xPropertySet->getPropertyValue("RotateAngle").get(), 1);
+}
+
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 

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

2020-09-29 Thread Regényi Balázs (via logerrit)
 oox/source/shape/WpsContext.cxx   |5 +
 sw/qa/extras/ooxmlexport/data/tdf80526_word_wrap.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx|   10 ++
 3 files changed, 15 insertions(+)

New commits:
commit 61291a63c0f9a57064300e7afc8222b4ae4e155a
Author: Regényi Balázs 
AuthorDate: Mon Sep 21 15:20:25 2020 +0200
Commit: László Németh 
CommitDate: Tue Sep 29 12:25:07 2020 +0200

tdf#80526 DOCX: import word-wrap textbox setting

See option "Word wrap text in shape" in Format->Text Box
and Shape->Text Attributes... of the selected textbox.

Co-authored-by: Szabolcs Toth

Change-Id: I7f2ca392089043c4bec20b943aa8c1975de72e5f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103109
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 076fd1124307..cb47692d4c95 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -160,6 +160,11 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 xTextBoxPropertySet->setPropertyValue("CharColor", 
xCharColor);
 }
 }
+
+auto nWrappingType = rAttribs.getToken(XML_wrap, XML_square);
+xPropertySet->setPropertyValue("TextWordWrap",
+   uno::makeAny(nWrappingType == 
XML_square));
+
 return this;
 }
 break;
diff --git a/sw/qa/extras/ooxmlexport/data/tdf80526_word_wrap.docx 
b/sw/qa/extras/ooxmlexport/data/tdf80526_word_wrap.docx
new file mode 100644
index ..abf5ee5ed2c8
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf80526_word_wrap.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 682343c782af..f1934775b1c1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -1086,6 +1086,16 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf131420, 
"tdf131420.docx")
 assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:pPr/w:pBdr[2]");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf80526_word_wrap, "tdf80526_word_wrap.docx")
+{
+// tdf#80526: check whether the "wrap" property has been set
+// TODO: fix export too
+if (mbExported)
+return;
+uno::Reference xShape = getShape(1);
+CPPUNIT_ASSERT_EQUAL(false, getProperty(xShape, "TextWordWrap"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-09-22 Thread Szabolcs Toth (via logerrit)
 oox/source/export/drawingml.cxx |   19 
 oox/source/shape/WpsContext.cxx |   11 ++
 sw/qa/extras/ooxmlexport/data/tdf123610_handle_upright.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx   |   10 ++
 4 files changed, 40 insertions(+)

New commits:
commit d3094b98231730b8e6d863c6a2fc0dd62f3e991a
Author: Szabolcs Toth 
AuthorDate: Mon Sep 14 17:16:51 2020 +0200
Commit: László Németh 
CommitDate: Tue Sep 22 09:48:30 2020 +0200

tdf#123610 DOCX shape import: keep text upright

Grab-bag attribute upright to keep text upright
regardless of shape rotation, fixing the text
direction in MSO after a round-trip.

Co-authored-by: Balázs Regényi

Change-Id: If18a12c7728317a7af093048b07bc392d2964389
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102690
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index c02cfac613a8..87e80e4ce12a 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2891,6 +2891,24 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
 else if( bVertical && eHorizontalAlignment == TextHorizontalAdjust_LEFT )
 sVerticalAlignment = "b";
 
+bool isUpright = false;
+if (GetProperty(rXPropSet, "InteropGrabBag"))
+{
+if 
(rXPropSet->getPropertySetInfo()->hasPropertyByName("InteropGrabBag"))
+{
+uno::Sequence aGrabBag;
+rXPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
+for (auto& aProp : aGrabBag)
+{
+if (aProp.Name == "Upright")
+{
+aProp.Value >>= isUpright;
+break;
+}
+}
+}
+}
+
 bool bHasWrap = false;
 bool bWrap = false;
 // Only custom shapes obey the TextWordWrap option, normal text always 
wraps.
@@ -2922,6 +2940,7 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
XML_anchor, sVerticalAlignment,
XML_anchorCtr, sax_fastparser::UseIf("1", 
bHorizontalCenter),
XML_vert, sWritingMode,
+   XML_upright, isUpright ? "1" : "0",
XML_rot, 
sax_fastparser::UseIf(oox::drawingml::calcRotationValue((nTextPreRotateAngle + 
nTextRotateAngle) * 100), (nTextPreRotateAngle + nTextRotateAngle) != 0));
 if (bIsFontworkShape)
 {
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index f78c38ff91e9..076fd1124307 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -96,6 +96,17 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 }
 }
 
+if (bool bUpright = rAttribs.getBool(XML_upright, false))
+{
+uno::Sequence aGrabBag;
+xPropertySet->getPropertyValue("InteropGrabBag") >>= 
aGrabBag;
+sal_Int32 length = aGrabBag.getLength();
+aGrabBag.realloc(length + 1);
+aGrabBag[length].Name = "Upright";
+aGrabBag[length].Value <<= bUpright;
+xPropertySet->setPropertyValue("InteropGrabBag", 
uno::makeAny(aGrabBag));
+}
+
 if (xServiceInfo.is())
 {
 // Handle inset attributes for Writer textframes.
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123610_handle_upright.docx 
b/sw/qa/extras/ooxmlexport/data/tdf123610_handle_upright.docx
new file mode 100644
index ..d7dc1978a067
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf123610_handle_upright.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 76ccf318e8c9..0085734450c0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1142,6 +1142,16 @@ 
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testRelativeAnchorWidthFromInsideOutsideMarg
 assertXPath(pXmlDoc, "(//SwAnchoredDrawObject)[4]/bounds", "width", 
"1440");
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testBodyPrUpright, 
"tdf123610_handle_upright.docx")
+{
+// tdf#123610: Check grab-bag attribute upright to keep text upright 
regardless of shape rotation.
+
+xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
+
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
+"/a:graphic/a:graphicData/wps:wsp/wps:bodyPr", "upright", "1");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

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

2020-09-18 Thread Regényi Balázs (via logerrit)
 oox/source/export/drawingml.cxx   |   28 +---
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |2 +-
 2 files changed, 2 insertions(+), 28 deletions(-)

New commits:
commit c1376ad6f52d04c1c29e73bc5b312744c74f8bdd
Author: Regényi Balázs 
AuthorDate: Wed Sep 16 14:48:33 2020 +0200
Commit: László Németh 
CommitDate: Fri Sep 18 15:22:15 2020 +0200

tdf#124013 XLSX shape export: fix missing solidFill

of the inside of the shape (resulting for example,
invisible shapes).

See also commit 83c30743eaf44d8eded4a73e3ac2585b5bdbaffc
(tdf#77236 DOCX shape export: fix missing solidFill).

Co-authored-by: Szabolcs Toth

Change-Id: I4efde86f82e22e1aa49b89dc13557ef5f238ba83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102871
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 17352ddb152a..c02cfac613a8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -441,36 +441,10 @@ void DrawingML::WriteSolidFill( const Reference< 
XPropertySet >& rXPropSet )
 // the shape had a scheme color and the user didn't change it
 WriteSolidFill( sColorFillScheme, aTransformations, nAlpha );
 }
-else if ( aStyleProperties.hasElements() )
-{
-sal_uInt32 nThemeColor = 0;
-sal_Int32 nThemeAlpha = MAX_PERCENT;
-for( const auto& rStyleProp : std::as_const(aStyleProperties) )
-{
-if( rStyleProp.Name == "Color" )
-{
-rStyleProp.Value >>= nThemeColor;
-}
-else if(rStyleProp.Name == "Transformations" )
-{
-Sequence< PropertyValue > aStyleTransformations;
-rStyleProp.Value >>= aStyleTransformations;
-auto pProp = std::find_if(std::cbegin(aStyleTransformations), 
std::cend(aStyleTransformations),
-[](const PropertyValue& rProp) { return rProp.Name == 
"alpha"; });
-if (pProp != std::cend(aStyleTransformations))
-pProp->Value >>= nThemeAlpha;
-}
-}
-if ( nFillColor != nThemeColor || nAlpha != nThemeAlpha )
-// the shape contains a theme but it wasn't being used
-WriteSolidFill( ::Color(nFillColor & 0xff), nAlpha );
-
-// in case the shape used the style color and the user didn't change 
it,
-// we must not write a  tag.
-}
 else
 {
 // the shape had a custom color and the user didn't change it
+// tdf#124013
 WriteSolidFill( ::Color(nFillColor & 0xff), nAlpha );
 }
 }
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index eafdf88ea788..e5bc49ddd189 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -780,7 +780,7 @@ 
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testShapeThemePreservation, "shape-theme-pre
 // check shape style hasn't been overwritten
 assertXPath(pXmlDocument,
 
"/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:solidFill",
-0);
+1);
 assertXPath(pXmlDocument,
 
"/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill",
 1);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-09-11 Thread Regényi Balázs (via logerrit)
 oox/source/export/drawingml.cxx  |   19 ++-
 sw/qa/extras/ooxmlexport/data/tdf77236_MissingSolidFill.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx   |9 +
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx|2 -
 4 files changed, 21 insertions(+), 9 deletions(-)

New commits:
commit 83c30743eaf44d8eded4a73e3ac2585b5bdbaffc
Author: Regényi Balázs 
AuthorDate: Mon Sep 7 19:54:19 2020 +0200
Commit: László Németh 
CommitDate: Fri Sep 11 15:36:15 2020 +0200

tdf#77236 DOCX shape export: fix missing solidFill

(resulting for example, invisible shapes).

Co-authored-by: Szabolcs Tóth

Change-Id: I328514022f4a594c374d5a97db39d1cf3a954e02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102195
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 06bbfea85d61..605e85ffa087 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -926,14 +926,17 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 // the line had a scheme color and the user didn't change it
 WriteSolidFill( sColorFillScheme, aTransformations );
 }
-else if( aStyleProperties.hasElements() )
-{
-if( nColor != nStyleColor )
-// the line style defines some color but it wasn't being used
-WriteSolidFill( nColor );
-// in case the shape used the style color and the user didn't 
change it,
-// we must not write a  tag.
-}
+// tdf#77236: I do not understand why this condition is required.
+// The original docx document of bug tdf#77236 includes the native 
colors in both places,
+// so, I think, we can export this color too (not only schema ones).
+//else if( aStyleProperties.hasElements() )
+//{
+//if( nColor != nStyleColor )
+//// the line style defines some color but it wasn't being used
+//WriteSolidFill( nColor );
+//// in case the shape used the style color and the user didn't 
change it,
+//// we must not write a  tag.
+//}
 else
 {
 WriteSolidFill( nColor, nColorAlpha );
diff --git a/sw/qa/extras/ooxmlexport/data/tdf77236_MissingSolidFill.docx 
b/sw/qa/extras/ooxmlexport/data/tdf77236_MissingSolidFill.docx
new file mode 100644
index ..2bb2c097838d
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf77236_MissingSolidFill.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index da998b01bb5f..4f77681d2eaf 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -1338,6 +1338,15 @@ DECLARE_OOXMLEXPORT_TEST( testTdf107359, 
"tdf107359-char-pitch.docx" )
 CPPUNIT_ASSERT_EQUAL( sal_Int32(convertTwipToMm100(24 * 20)), nBaseWidth );
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf77236_MissingSolidFill, 
"tdf77236_MissingSolidFill.docx")
+{
+// tdf#77236: solidFill of VML shape was not exported if the colors of 
line and style were the same
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+if (!pXmlDoc)
+return;
+assertXPath(pXmlDoc, 
"//mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill",
 1);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index d1091c949bb6..eafdf88ea788 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -783,7 +783,7 @@ 
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testShapeThemePreservation, "shape-theme-pre
 0);
 assertXPath(pXmlDocument,
 
"/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:solidFill",
-0);
+1);
 
 // check direct theme assignments have been preserved
 assertXPath(pXmlDocument,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sw/qa writerfilter/source

2020-09-11 Thread Daniel Arato (NISZ) (via logerrit)
 oox/source/vml/vmlshape.cxx   |9 +
 sw/qa/extras/ooxmlexport/data/tdf135660.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx|   20 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |4 
 4 files changed, 33 insertions(+)

New commits:
commit 8ee88230c110ae90b439a52bc2906d6c5383967f
Author: Daniel Arato (NISZ) 
AuthorDate: Mon Sep 7 11:50:53 2020 +0200
Commit: László Németh 
CommitDate: Fri Sep 11 10:19:18 2020 +0200

tdf#135660 DOCX import: fix OLE icon wrap distance

The text wrap distance (also sometimes called "margin") of
OLE VML icons used to be thrown away when a .docx file is opened.

Change-Id: I79837421470dde5e68e916f87924b170ebf1d734
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102159
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index f8a4c9000e66..905548bafb9e 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -911,6 +911,15 @@ Reference< XShape > SimpleShape::createPictureObject(const 
Reference< XShapes >&
 const GraphicHelper& rGraphicHelper = 
mrDrawing.getFilter().getGraphicHelper();
 lcl_SetAnchorType(aPropSet, maTypeModel, rGraphicHelper);
 
+const sal_Int32 nWrapDistanceLeft = 
ConversionHelper::decodeMeasureToHmm(rGraphicHelper, 
maTypeModel.maWrapDistanceLeft, 0, true, true);
+const sal_Int32 nWrapDistanceRight = 
ConversionHelper::decodeMeasureToHmm(rGraphicHelper, 
maTypeModel.maWrapDistanceRight, 0, true, true);
+const sal_Int32 nWrapDistanceTop = 
ConversionHelper::decodeMeasureToHmm(rGraphicHelper, 
maTypeModel.maWrapDistanceTop, 0, false, true);
+const sal_Int32 nWrapDistanceBottom = 
ConversionHelper::decodeMeasureToHmm(rGraphicHelper, 
maTypeModel.maWrapDistanceBottom, 0, false, true);
+aPropSet.setProperty(PROP_LeftMargin, uno::makeAny(nWrapDistanceLeft));
+aPropSet.setProperty(PROP_RightMargin, 
uno::makeAny(nWrapDistanceRight));
+aPropSet.setProperty(PROP_TopMargin, uno::makeAny(nWrapDistanceTop));
+aPropSet.setProperty(PROP_BottomMargin, 
uno::makeAny(nWrapDistanceBottom));
+
 if (maTypeModel.moCropBottom.has() || maTypeModel.moCropLeft.has() || 
maTypeModel.moCropRight.has() || maTypeModel.moCropTop.has())
 {
 text::GraphicCrop aGraphicCrop;
diff --git a/sw/qa/extras/ooxmlexport/data/tdf135660.docx 
b/sw/qa/extras/ooxmlexport/data/tdf135660.docx
new file mode 100644
index ..2309c9b0ac09
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135660.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 104e867a33ba..5aad7cc44f0e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -674,6 +674,26 @@ DECLARE_OOXMLEXPORT_TEST(testImageSpaceSettings, 
"tdf135047_ImageSpaceSettings.f
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:anchor", "distR", "90170");
 }
 
+// TODO: change this to an export test once wrap distance export (TDF#135663) 
is implemented
+DECLARE_OOXMLIMPORT_TEST(testTdf13660, "tdf135660.docx")
+{
+CPPUNIT_ASSERT_EQUAL(1, getShapes());
+const uno::Reference xShape = getShape(1);
+const uno::Reference xOLEProps(xShape, 
uno::UNO_QUERY_THROW);
+sal_Int32 nWrapDistanceLeft = -1;
+sal_Int32 nWrapDistanceRight = -1;
+sal_Int32 nWrapDistanceTop = -1;
+sal_Int32 nWrapDistanceBottom = -1;
+xOLEProps->getPropertyValue("LeftMargin") >>= nWrapDistanceLeft;
+xOLEProps->getPropertyValue("RightMargin") >>= nWrapDistanceRight;
+xOLEProps->getPropertyValue("TopMargin") >>= nWrapDistanceTop;
+xOLEProps->getPropertyValue("BottomMargin") >>= nWrapDistanceBottom;
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Left wrap distance is wrong", 
static_cast(0), nWrapDistanceLeft);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Right wrap distance is wrong", 
static_cast(400), nWrapDistanceRight);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Top wrap distance is wrong", 
static_cast(300), nWrapDistanceTop);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Bottom wrap distance is wrong", 
static_cast(199), nWrapDistanceBottom);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6387d22b12a3..fc9c13e9c562 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2271,6 +2271,10 @@ void DomainMapper_Impl::appendOLE( const OUString& 
rStreamName, const std::share
 "VertOrientPosition",
 "VertOrientRelation",
 "HoriOrientRelation",
+"LeftMargin",
+"RightMargin",
+

[Libreoffice-commits] core.git: oox/source sw/qa sw/source writerfilter/source

2020-09-07 Thread Daniel Arato (NISZ) (via logerrit)
 oox/source/token/properties.txt   |1 +
 oox/source/vml/vmlshape.cxx   |1 +
 sw/qa/extras/ooxmlexport/data/tdf135665.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx|   13 +
 sw/source/core/unocore/unoframe.cxx   |8 ++--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |1 +
 6 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit 4b7ee7bd61f78be60211cc72ba36da987191266e
Author: Daniel Arato (NISZ) 
AuthorDate: Wed Sep 2 15:46:56 2020 +0200
Commit: László Németh 
CommitDate: Mon Sep 7 13:11:44 2020 +0200

tdf#135665 DOCX: import tight wrap setting of VML shapes

The wrap setting that OOXML calls "tight" and LibreOffice calls
"contour" (== true) was not supported by the import code, only
the export.

Change-Id: I48739ffaad48e28df05fd87a9b51a14238dc47e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101932
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 46200bf221ff..d50cd4bb124d 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -509,6 +509,7 @@ SubViewSize
 Subtotals
 Suffix
 Surround
+SurroundContour
 SwapXAndYAxis
 Symbol
 SymbolColor
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 85ad112bcfae..f8a4c9000e66 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -588,6 +588,7 @@ static void lcl_setSurround(PropertySet& rPropSet, const 
ShapeTypeModel& rTypeMo
 nSurround = css::text::WrapTextMode_NONE;
 
 rPropSet.setProperty(PROP_Surround, static_cast(nSurround));
+rPropSet.setProperty(PROP_SurroundContour, aWrapType == "tight");
 }
 
 static void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& 
rTypeModel, const GraphicHelper& rGraphicHelper)
diff --git a/sw/qa/extras/ooxmlexport/data/tdf135665.docx 
b/sw/qa/extras/ooxmlexport/data/tdf135665.docx
new file mode 100644
index ..2400a1c1a46c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135665.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 4e39a5af0297..95770433a6ab 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -513,6 +513,19 @@ DECLARE_OOXMLIMPORT_TEST(TestTdf135653, "tdf135653.docx")
 CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE bg color does not match!", 
aExpectedColor, aFillColor);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf135665, "tdf135665.docx")
+{
+uno::Reference xOLEProps1(getShape(1), 
uno::UNO_QUERY_THROW);
+uno::Reference xOLEProps2(getShape(2), 
uno::UNO_QUERY_THROW);
+bool bSurroundContour1 = false;
+bool bSurroundContour2 = false;
+xOLEProps1->getPropertyValue("SurroundContour") >>= bSurroundContour1;
+xOLEProps2->getPropertyValue("SurroundContour") >>= bSurroundContour2;
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE tight wrap setting not imported 
correctly", true, bSurroundContour1);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE tight wrap setting not imported 
correctly", false, bSurroundContour2);
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testAtPageShapeRelOrientation, 
"rotated_shape.fodt")
 {
 // invalid combination of at-page anchor and horizontal-rel="paragraph"
diff --git a/sw/source/core/unocore/unoframe.cxx 
b/sw/source/core/unocore/unoframe.cxx
index 2d122992d840..5d7b86fc37e0 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -752,15 +752,19 @@ bool 
BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
 bRet &= aSh.PutValue(*pShTr, MID_SHADOW_TRANSPARENCE);
 rToSet.Put(aSh);
 }
-const ::uno::Any* pSur  = nullptr;
+const ::uno::Any* pSur = nullptr;
 GetProperty(RES_SURROUND, MID_SURROUND_SURROUNDTYPE, pSur);
+const ::uno::Any* pSurCont = nullptr;
+GetProperty(RES_SURROUND, MID_SURROUND_CONTOUR, pSurCont);
 const ::uno::Any* pSurAnch = nullptr;
 GetProperty(RES_SURROUND, MID_SURROUND_ANCHORONLY, pSurAnch);
 if(pSur || pSurAnch)
 {
 SwFormatSurround aSrnd ( rFromSet.Get ( RES_SURROUND ) );
 if(pSur)
-bRet &= static_cast(aSrnd).PutValue(*pSur, 
MID_SURROUND_SURROUNDTYPE );
+bRet &= static_cast(aSrnd).PutValue(*pSur, 
MID_SURROUND_SURROUNDTYPE);
+if(pSurCont)
+bRet &= static_cast(aSrnd).PutValue(*pSurCont, 
MID_SURROUND_CONTOUR);
 if(pSurAnch)
 bRet &= static_cast(aSrnd).PutValue(*pSurAnch, 
MID_SURROUND_ANCHORONLY);
 rToSet.Put(aSrnd);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0347453d6704..ec83a7c2d5f9 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ 

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

2020-08-31 Thread Regényi Balázs (via logerrit)
 oox/source/vml/vmlshape.cxx  |4 +++
 sw/qa/extras/ooxmlexport/data/tdf97618_testVmlShapeTextWordWrap.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |   13 
++
 3 files changed, 17 insertions(+)

New commits:
commit 0d773f0b07798a59f7cf31207813aaf6bc9bb922
Author: Regényi Balázs 
AuthorDate: Sat Aug 29 09:11:46 2020 +0200
Commit: László Németh 
CommitDate: Mon Aug 31 16:04:01 2020 +0200

tdf#97618 DOCX import: VML shape: fix missing square wrap

Co-authored-by: Szabolcs Tóth

Change-Id: Ib9db4b0270ed7d4b3d47406f2384276cafdd7249
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101632
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 362f02c7cabf..85ad112bcfae 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -791,6 +791,10 @@ Reference< XShape > SimpleShape::implConvertAndInsert( 
const Reference< XShapes
 eTextVerticalAdjust = drawing::TextVerticalAdjust_BOTTOM;
 PropertySet(xShape).setAnyProperty(PROP_TextVerticalAdjust, 
makeAny(eTextVerticalAdjust));
 
+// tdf#97618
+if(!maTypeModel.maWrapStyle.isEmpty())
+PropertySet(xShape).setAnyProperty(PROP_TextWordWrap, 
makeAny(maTypeModel.maWrapStyle == "square"));
+
 PropertySet(xShape).setAnyProperty(PROP_TextAutoGrowHeight,
makeAny(maTypeModel.mbAutoHeight));
 
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf97618_testVmlShapeTextWordWrap.docx 
b/sw/qa/extras/ooxmlexport/data/tdf97618_testVmlShapeTextWordWrap.docx
new file mode 100644
index ..eb31a1244c01
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf97618_testVmlShapeTextWordWrap.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index e68dde7499e7..30a27a22e1ce 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1264,6 +1264,19 @@ 
DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorHeightFromTopMarginNoHeader,
 assertXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "height", "2551");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testVmlShapeTextWordWrap, 
"tdf97618_testVmlShapeTextWordWrap.docx")
+{
+// tdf#97618 The text wraping of a shape was not handled in a canvas.
+// TODO: fix export too
+if (mbExported)
+return;
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+if (!pXmlDoc)
+return;
+// The bound rect of shape will be wider if wrap does not work (the wrong 
value is 3167).
+assertXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "width", "2500");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sw/qa writerfilter/source

2020-08-27 Thread Attila Bakos (via logerrit)
 oox/source/vml/vmlshape.cxx   |9 -
 sw/qa/extras/ooxmlexport/data/tdf135653.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx|   19 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   38 --
 4 files changed, 55 insertions(+), 11 deletions(-)

New commits:
commit 636d16efe45a55c1a5a7a451c46fbb8618bf0393
Author: Attila Bakos 
AuthorDate: Thu Aug 13 16:37:58 2020 +0200
Commit: László Németh 
CommitDate: Thu Aug 27 11:29:51 2020 +0200

tdf#135653 OOXML import: fix OLE background color

When importing a .docx file Writer used to ignore the 'filled' and
'fillcolor' attributes in the 'shape' tag belonging to an OLE object.
Now both these are imported and displayed correctly.

Co-authored-by: Daniel Arato (NISZ)

Change-Id: I2e6b880d88e4c46af6f3f2316ee966bac1a1f2e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100922
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index f22a98576a16..362f02c7cabf 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -293,13 +293,18 @@ void ShapeBase::finalizeFragmentImport()
 aType = aType.copy(1);
 if( const ShapeType* pShapeType = mrDrawing.getShapes().getShapeTypeById( 
aType ) )
 {
-// Make sure that the stroke props from maTypeModel have priority over 
the stroke props from
+// Make sure that the props from maTypeModel have priority over the 
props from
 // the shape type.
 StrokeModel aMergedStrokeModel;
 
aMergedStrokeModel.assignUsed(pShapeType->getTypeModel().maStrokeModel);
 aMergedStrokeModel.assignUsed(maTypeModel.maStrokeModel);
+FillModel aMergedFillModel;
+aMergedFillModel.assignUsed(pShapeType->getTypeModel().maFillModel);
+aMergedFillModel.assignUsed(maTypeModel.maFillModel);
+
 maTypeModel.assignUsed( pShapeType->getTypeModel() );
 maTypeModel.maStrokeModel = aMergedStrokeModel;
+maTypeModel.maFillModel = aMergedFillModel;
 }
 else {
 // Temporary fix, shapetype not found if referenced from different 
substream
@@ -1359,6 +1364,8 @@ Reference< XShape > ComplexShape::implConvertAndInsert( 
const Reference< XShapes
 oox::drawingml::ShapePropertyMap 
aPropMap(mrDrawing.getFilter().getModelObjectHelper());
 const GraphicHelper& rGraphicHelper = 
mrDrawing.getFilter().getGraphicHelper();
 maTypeModel.maStrokeModel.pushToPropMap(aPropMap, rGraphicHelper);
+//And, fill-color properties as well...
+maTypeModel.maFillModel.pushToPropMap(aPropMap, rGraphicHelper);
 PropertySet(xShape).setProperties(aPropMap);
 
 return xShape;
diff --git a/sw/qa/extras/ooxmlexport/data/tdf135653.docx 
b/sw/qa/extras/ooxmlexport/data/tdf135653.docx
new file mode 100644
index ..b53777f81952
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135653.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index e78e7fba8179..818664f384f1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -9,6 +9,8 @@
 
 #include 
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -369,6 +371,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf134063, "tdf134063.docx")
 CPPUNIT_ASSERT_EQUAL(sal_Int32(720), getXPath(pDump, 
"//page[1]/body/txt[1]/Text[3]", "nWidth").toInt32());
 }
 
+DECLARE_OOXMLIMPORT_TEST(TestTdf135653, "tdf135653.docx")
+{
+uno::Reference xOLEProps(getShape(1), 
uno::UNO_QUERY_THROW);
+drawing::FillStyle nFillStyle = static_cast(-1);
+xOLEProps->getPropertyValue("FillStyle") >>= nFillStyle;
+Color aFillColor(COL_AUTO);
+xOLEProps->getPropertyValue("FillColor") >>= aFillColor;
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill style setting does not match!",
+ drawing::FillStyle::FillStyle_SOLID, 
nFillStyle);
+Color aExpectedColor;
+aExpectedColor.SetRed(255);
+aExpectedColor.SetGreen(0);
+aExpectedColor.SetBlue(0);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE bg color does not match!", 
aExpectedColor, aFillColor);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testAtPageShapeRelOrientation, "rotated_shape.fodt")
 {
 // invalid combination of at-page anchor and horizontal-rel="paragraph"
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index ce3fd3fbe3a8..1ddf7f941956 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -101,6 +101,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2246,18 +2247,35 @@ void DomainMapper_Impl::appendOLE( const OUString& 
rStreamName, const std::share
 uno::Reference 

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

2020-08-07 Thread Michael Stahl (via logerrit)
 oox/source/export/vmlexport.cxx|   41 +
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx |4 ++
 2 files changed, 44 insertions(+), 1 deletion(-)

New commits:
commit 8d83c29905ca6c4067ae0330d3544ddb983cafbc
Author: Michael Stahl 
AuthorDate: Fri Aug 7 15:50:12 2020 +0200
Commit: Michael Stahl 
CommitDate: Fri Aug 7 18:26:46 2020 +0200

oox: VML export: convert ESCHER_Prop_AnchorText to v-text-anchor

Change-Id: I903cac8d7b02138680613b5a1b6dab4b1c448158
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100333
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index bb5e2b8eee50..0a0a634708bf 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -430,6 +430,47 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, 
const tools::Rectangle&
 bAlreadyWritten[ ESCHER_Prop_WrapText ] = true;
 break;
 
+case ESCHER_Prop_AnchorText: // 135
+{
+char const* pValue(nullptr);
+switch (opt.nPropValue)
+{
+case ESCHER_AnchorTop:
+pValue = "top";
+break;
+case ESCHER_AnchorMiddle:
+pValue = "middle";
+break;
+case ESCHER_AnchorBottom:
+pValue = "bottom";
+break;
+case ESCHER_AnchorTopCentered:
+pValue = "top-center";
+break;
+case ESCHER_AnchorMiddleCentered:
+pValue = "middle-center";
+break;
+case ESCHER_AnchorBottomCentered:
+pValue = "bottom-center";
+break;
+case ESCHER_AnchorTopBaseline:
+pValue = "top-baseline";
+break;
+case ESCHER_AnchorBottomBaseline:
+pValue = "bottom-baseline";
+break;
+case ESCHER_AnchorTopCenteredBaseline:
+pValue = "top-center-baseline";
+break;
+case ESCHER_AnchorBottomCenteredBaseline:
+pValue = "bottom-center-baseline";
+break;
+}
+m_ShapeStyle.append(";v-text-anchor:");
+m_ShapeStyle.append(pValue);
+}
+break;
+
 case ESCHER_Prop_txflTextFlow: // 136
 {
 // at least "bottom-to-top" only has an effect when it's 
on the v:textbox element, not on v:shape
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 9643439d1f69..f8dc2b8e9fd8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -281,7 +281,9 @@ DECLARE_OOXMLEXPORT_TEST(testAtPageShapeRelOrientation, 
"rotated_shape.fodt")
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape/v:textbox",
 "style", "mso-layout-flow-alt:bottom-to-top");
 // text wrap -> VML
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape/w10:wrap",
 "type", "none");
-
+// vertical alignment -> VML
+OUString const style = getXPath(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape", 
"style");
+CPPUNIT_ASSERT(style.indexOf("v-text-anchor:middle") != -1);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorHeightFromBottomMarginHasFooter,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-08-06 Thread Michael Stahl (via logerrit)
 oox/source/export/vmlexport.cxx|   17 -
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx |4 
 2 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit 090c61eb93db4302d4565d5f11f7673190835fdb
Author: Michael Stahl 
AuthorDate: Thu Aug 6 14:11:38 2020 +0200
Commit: Michael Stahl 
CommitDate: Thu Aug 6 17:56:32 2020 +0200

oox: VML export: for rotated text shape, produce bottom-to-top

This is for shapes that fail the lcl_isTextBox() check in
VMLExport::StartShape(), they can be rotated too but with a different
property than the "TextPreRotateAngle" that is used in
VMLExport::EndShape().

Change-Id: I530aae8b7138f47bae8434e205632f5f4adbb231
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100249
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index c0e2f65db2c0..22dcc871ab83 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1369,8 +1369,23 @@ sal_Int32 VMLExport::StartShape()
 
 if( pParaObj )
 {
+uno::Reference 
xPropertySet(const_cast(m_pSdrObject)->getUnoShape(), 
uno::UNO_QUERY);
+sax_fastparser::FastAttributeList* pTextboxAttrList = 
FastSerializerHelper::createAttrList();
+sax_fastparser::XFastAttributeListRef 
xTextboxAttrList(pTextboxAttrList);
+if 
(xPropertySet->getPropertySetInfo()->hasPropertyByName("RotateAngle"))
+{
+sal_Int32 nTextRotateAngle = sal_Int32();
+if (xPropertySet->getPropertyValue("RotateAngle") >>= 
nTextRotateAngle)
+{
+if (nTextRotateAngle == 9000)
+{
+pTextboxAttrList->add(XML_style, 
"mso-layout-flow-alt:bottom-to-top");
+}
+}
+}
+
 // this is reached only in case some text is attached to the shape
-m_pSerializer->startElementNS(XML_v, XML_textbox);
+m_pSerializer->startElementNS(XML_v, XML_textbox, 
xTextboxAttrList);
 m_pTextExport->WriteOutliner(*pParaObj);
 m_pSerializer->endElementNS(XML_v, XML_textbox);
 if( bOwnParaObj )
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 3c75d8fe30aa..009867c72f11 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -230,6 +230,10 @@ DECLARE_OOXMLEXPORT_TEST(testAtPageShapeRelOrientation, 
"rotated_shape.fodt")
 "/wp:positionV/wp:posOffset", "1080135");
 assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor"
 "/wp:positionV", "relativeFrom", "page");
+
+// now test text rotation -> VML writing direction
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape/v:textbox",
 "style", "mso-layout-flow-alt:bottom-to-top");
+
 }
 
 DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorHeightFromBottomMarginHasFooter,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-03 Thread Regényi Balázs (via logerrit)
 oox/source/export/drawingml.cxx|7 +
 sw/qa/extras/ooxmlexport/data/tdf112312_AutoFitForLegacyShapes.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx  |   12 
++
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit cab956c480eb4f619580285c7b9a15b9e6d9b780
Author: Regényi Balázs 
AuthorDate: Thu Jun 25 15:15:46 2020 +0200
Commit: László Németh 
CommitDate: Fri Jul 3 13:33:16 2020 +0200

tdf#112312 DOCX legacy shape export: keep fixed size

Classical/legacy shapes lost their fixed size when exporting them with the
option "Resize shape to fit text" because they do not have the ability to
resize to content.

Co-authored-by: Szabolcs Tóth

Change-Id: Idd84dea040f9607d0d498e591601a8648a605a2e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97127
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index a5a44cc3e7fe..4adf7a9406b5 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2901,9 +2901,14 @@ void DrawingML::WriteText( const Reference< XInterface 
>& rXIface, const OUStrin
 
 if (GetDocumentType() == DOCUMENT_DOCX || GetDocumentType() == 
DOCUMENT_XLSX)
 {
+// tdf#112312: only custom shapes obey the TextAutoGrowHeight 
option
 bool bTextAutoGrowHeight = false;
-if (GetProperty(rXPropSet, "TextAutoGrowHeight"))
+uno::Reference xShape(rXIface, uno::UNO_QUERY);
+auto pSdrObjCustomShape = xShape.is() ? 
dynamic_cast(GetSdrObjectFromXShape(xShape)) : nullptr;
+if (pSdrObjCustomShape && GetProperty(rXPropSet, 
"TextAutoGrowHeight"))
+{
 mAny >>= bTextAutoGrowHeight;
+}
 mpFS->singleElementNS(XML_a, (bTextAutoGrowHeight ? XML_spAutoFit 
: XML_noAutofit));
 }
 if (GetDocumentType() == DOCUMENT_PPTX)
diff --git a/sw/qa/extras/ooxmlexport/data/tdf112312_AutoFitForLegacyShapes.odt 
b/sw/qa/extras/ooxmlexport/data/tdf112312_AutoFitForLegacyShapes.odt
new file mode 100644
index ..b5ccb356203e
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf112312_AutoFitForLegacyShapes.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index db5add6d8014..e89522670483 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -1269,6 +1269,18 @@ 
DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorWidthFromRightMargin, "tdf133670_test
 CPPUNIT_ASSERT_EQUAL(static_cast(2408), nAnchoredWidth);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testAutoFitForLegacyShapes, 
"tdf112312_AutoFitForLegacyShapes.odt")
+{
+// tdf#112312: check if noAutoFit is used instead of spAutoFit even if the 
TextAutoGrowHeight is set
+xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
+if (!pXmlDocument)
+return;
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
+"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr/a:noAutofit");
+assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
+"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr", "a:spAutofit");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-05-20 Thread Regényi Balázs (via logerrit)
 oox/source/drawingml/shape.cxx |1 +
 oox/source/export/drawingml.cxx|8 +++-
 sw/qa/extras/ooxmlexport/data/tdf126363_LineWidthRounding.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx |   10 
++
 4 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit c28d6b99599eaeb923804547c3ac849b6feec044
Author: Regényi Balázs 
AuthorDate: Mon May 11 16:16:59 2020 +0200
Commit: László Németh 
CommitDate: Wed May 20 17:01:05 2020 +0200

tdf#126363 DOCX shape round-trip: keep original line width

to avoid of rounding error of EMU -> 1/100 mm -> EMU
conversions, which messed up recognition of preset
line widths in MSO.

Co-authored-by: Szabolcs Tóth

Change-Id: Ide0e393e667848683f00f9ba7a73ff8a45a908b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94043
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 202e2927e80c..cd7c289e9efa 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1251,6 +1251,7 @@ Reference< XShape > const & Shape::createAndInsert(
 
 // Store original fill and line colors of the shape and the theme 
color name to InteropGrabBag
 std::vector aProperties;
+
aProperties.push_back(comphelper::makePropertyValue("EmuLineWidth", 
aLineProperties.moLineWidth.get(0)));
 
aProperties.push_back(comphelper::makePropertyValue("OriginalSolidFillClr", 
aShapeProps.getProperty(PROP_FillColor)));
 
aProperties.push_back(comphelper::makePropertyValue("OriginalLnSolidFillClr", 
aShapeProps.getProperty(PROP_LineColor)));
 OUString sColorFillScheme = 
aFillProperties.maFillColor.getSchemeName();
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index c925819dd9f8..2d44aec64465 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -748,6 +748,7 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 mAny >>= aLineStyle;
 
 sal_uInt32 nLineWidth = 0;
+sal_uInt32 nEmuLineWidth = 0;
 ::Color nColor;
 sal_Int32 nColorAlpha = MAX_PERCENT;
 bool bColorSet = false;
@@ -784,6 +785,8 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 rProp.Value >>= aStyleProperties;
 else if( rProp.Name == "SpPrLnSolidFillSchemeClrTransformations" )
 rProp.Value >>= aTransformations;
+else if( rProp.Name == "EmuLineWidth" )
+rProp.Value >>= nEmuLineWidth;
 }
 for (const auto& rStyleProp : std::as_const(aStyleProperties))
 {
@@ -864,10 +867,13 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 break;
 }
 
+// if the line-width was not modified after importing then the original 
EMU value will be exported to avoid unexpected conversion (rounding) error
+if (nEmuLineWidth == 0 || 
static_cast(oox::drawingml::convertEmuToHmm(nEmuLineWidth)) != 
nLineWidth)
+nEmuLineWidth = oox::drawingml::convertHmmToEmu(nLineWidth);
 mpFS->startElementNS( XML_a, XML_ln,
   XML_cap, cap,
   XML_w, nLineWidth == 0 || (nLineWidth > 1 && 
nStyleLineWidth != nLineWidth) ?
-  
OString::number(oox::drawingml::convertHmmToEmu(nLineWidth)).getStr() : nullptr 
);
+  OString::number(nEmuLineWidth).getStr() : 
nullptr );
 
 if( bColorSet )
 {
diff --git a/sw/qa/extras/ooxmlexport/data/tdf126363_LineWidthRounding.docx 
b/sw/qa/extras/ooxmlexport/data/tdf126363_LineWidthRounding.docx
new file mode 100644
index ..180383ec6842
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf126363_LineWidthRounding.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index a591a3caa8fe..dd6544eb3173 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -971,6 +971,16 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf131539, 
"tdf131539.odt")
 CPPUNIT_ASSERT(aXmlVal.indexOf("margin-left:139.95")>-1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testLineWidthRounding, 
"tdf126363_LineWidthRounding.docx")
+{
+// tdf#126363: check if line with stays the same after export
+xmlDocUniquePtr pXml = parseExport("word/document.xml");
+if (!pXml)
+return;
+// this was 57240 (it differs from the original 57150, losing the preset 
line width)
+assertXPath(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln",
 "w", "57150");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

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

2020-05-18 Thread Szabolcs Toth (via logerrit)
 oox/source/export/drawingml.cxx   |2 +-
 sw/qa/extras/ooxmlexport/data/tdf92526_ShapeLineWidth.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx |   12 
 3 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit 96319d662dca12616eb52c601a2d5b5adca3ae57
Author: Szabolcs Toth 
AuthorDate: Mon May 11 15:56:27 2020 +0200
Commit: László Németh 
CommitDate: Mon May 18 15:55:41 2020 +0200

tdf#92526 DrawingML shape export: fix 0 line width

0 line width is the thinnest possible line width,
but without its explicit export (a:ln w="0"), shape
outline was imported with 0.75 pt line width by MSO.

Co-authored-by: Balázs Regényi

Change-Id: I40f7aefe6358bebe9a3853fe3e7d6faa170bc34c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93968
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 12a4506a8e75..c925819dd9f8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -866,7 +866,7 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 
 mpFS->startElementNS( XML_a, XML_ln,
   XML_cap, cap,
-  XML_w, nLineWidth > 1 && nStyleLineWidth != 
nLineWidth ?
+  XML_w, nLineWidth == 0 || (nLineWidth > 1 && 
nStyleLineWidth != nLineWidth) ?
   
OString::number(oox::drawingml::convertHmmToEmu(nLineWidth)).getStr() : nullptr 
);
 
 if( bColorSet )
diff --git a/sw/qa/extras/ooxmlexport/data/tdf92526_ShapeLineWidth.odt 
b/sw/qa/extras/ooxmlexport/data/tdf92526_ShapeLineWidth.odt
new file mode 100644
index ..fffd9b9b2037
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf92526_ShapeLineWidth.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 6993eb54c273..48b2cef55586 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1135,6 +1135,18 @@ DECLARE_OOXMLEXPORT_TEST(testArrowMarker, 
"tdf123346_ArrowMarker.docx")
 "/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:tailEnd", "type", 
"arrow");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testShapeLineWidth, "tdf92526_ShapeLineWidth.odt")
+{
+// tdf#92526: Make sure that line with stays 0.
+xmlDocUniquePtr pXml = parseExport("word/document.xml");
+if (!pXml)
+return;
+
+// "w" attribute was not exported.
+assertXPath(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing"
+"/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln", "w", "0");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-05-18 Thread Tibor Nagy (via logerrit)
 oox/source/vml/vmlshape.cxx  |   14 ++
 sw/qa/extras/ooxmlexport/data/tdf123622.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |   15 ++-
 3 files changed, 24 insertions(+), 5 deletions(-)

New commits:
commit 52442a4c0192cbedafe7b77459dd2c3d1cf3614b
Author: Tibor Nagy 
AuthorDate: Fri May 8 10:32:09 2020 +0200
Commit: László Németh 
CommitDate: Mon May 18 10:51:03 2020 +0200

tdf#123622 DOCX VML import: fix relative horizontal alignment

Margin (left, right, inner, outer) alignments of VML shapes
weren't handled.

Co-authored-by: Attila Bakos (NISZ)

Change-Id: I5f8ece64707a2d699b71d6151887db05ac39c4f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93723
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index a6687ab65100..55eb9020ae11 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -632,10 +632,16 @@ static void lcl_SetAnchorType(PropertySet& rPropSet, 
const ShapeTypeModel& rType
 
 if ( rTypeModel.maPositionHorizontalRelative == "page" )
 rPropSet.setAnyProperty(PROP_HoriOrientRelation, 
makeAny(text::RelOrientation::PAGE_FRAME));
-else if ( rTypeModel.maPositionVerticalRelative == "margin" )
-rPropSet.setProperty(PROP_VertOrientRelation, 
text::RelOrientation::PAGE_PRINT_AREA);
-else if ( rTypeModel.maPositionVerticalRelative == "text" )
-rPropSet.setProperty(PROP_VertOrientRelation, 
text::RelOrientation::FRAME);
+else if ( rTypeModel.maPositionHorizontalRelative == "margin" )
+rPropSet.setProperty(PROP_HoriOrientRelation, 
text::RelOrientation::PAGE_PRINT_AREA);
+else if (rTypeModel.maPositionHorizontalRelative == "right-margin-area" ||
+ rTypeModel.maPositionHorizontalRelative == "inner-margin-area")
+rPropSet.setProperty(PROP_HoriOrientRelation, 
text::RelOrientation::PAGE_RIGHT);
+else if (rTypeModel.maPositionHorizontalRelative == "left-margin-area" ||
+ rTypeModel.maPositionHorizontalRelative == "outer-margin-area")
+rPropSet.setProperty(PROP_HoriOrientRelation, 
text::RelOrientation::PAGE_LEFT);
+else if ( rTypeModel.maPositionHorizontalRelative == "text" )
+rPropSet.setProperty(PROP_HoriOrientRelation, 
text::RelOrientation::FRAME);
 
 if ( rTypeModel.maPositionVertical == "center" )
 rPropSet.setAnyProperty(PROP_VertOrient, 
makeAny(text::VertOrientation::CENTER));
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123622.docx 
b/sw/qa/extras/ooxmlexport/data/tdf123622.docx
new file mode 100644
index ..54ef0cbd7670
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf123622.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index cf6d3f6e2671..a591a3caa8fe 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -44,7 +44,7 @@ protected:
 }
 };
 
-DECLARE_OOXMLIMPORT_TEST(Tdf130907,"tdf130907.docx")
+DECLARE_OOXMLIMPORT_TEST(Tdf130907, "tdf130907.docx")
 {
 uno::Reference xPara1 = getParagraph(2);
 CPPUNIT_ASSERT(xPara1.is());
@@ -74,6 +74,19 @@ DECLARE_OOXMLIMPORT_TEST(Tdf130907,"tdf130907.docx")
 sal_Int16(style::ParagraphAdjust::ParagraphAdjust_RIGHT), nHOri3);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf123622, "tdf123622.docx")
+{
+uno::Reference 
XPropsRight(getShape(1),uno::UNO_QUERY);
+sal_Int16 nRelativePosR = 0;
+XPropsRight->getPropertyValue("HoriOrientRelation")>>=nRelativePosR;
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape inside the margin", sal_Int16(4), 
nRelativePosR);
+
+uno::Reference XPropsLeft(getShape(2), 
uno::UNO_QUERY);
+sal_Int16 nRelativePosL = 0;
+XPropsLeft->getPropertyValue("HoriOrientRelation") >>= nRelativePosL;
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape inside the margin", sal_Int16(3), 
nRelativePosL);
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf78749, "tdf78749.docx")
 {
 //Shape lost the background image before, now check if it still has...
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-29 Thread Regényi Balázs (via logerrit)
 oox/source/drawingml/textcharacterpropertiescontext.cxx  |
7 +
 sw/qa/extras/ooxmlexport/data/tdf132491_UnderlineColorGroupedShapes.docx 
|binary
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx|   
14 ++
 3 files changed, 21 insertions(+)

New commits:
commit d0124728059088cd72cb173e33df89d785ae2ab5
Author: Regényi Balázs 
AuthorDate: Tue Apr 28 09:18:24 2020 +0200
Commit: László Németh 
CommitDate: Wed Apr 29 16:20:37 2020 +0200

tdf#132491 DOCX DrawingML shape import: fix missing underline color

The import of underline color was unhandled.
Co-Author: Szabolcs Toth

Change-Id: I47dce90966c7130ca67941ee47b0e4b2ba7eb972
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93108
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx 
b/oox/source/drawingml/textcharacterpropertiescontext.cxx
index 8c6eb4aee22a..8fecb8bd2735 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -201,6 +201,13 @@ ContextHandlerRef 
TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
 mrTextCharacterProperties.moUnderline = XML_dash;
 else if (attrib == "none")
 mrTextCharacterProperties.moUnderline = XML_none;
+auto colorAttrib = rAttribs.getIntegerHex(W_TOKEN(color));
+if (colorAttrib.has())
+{
+oox::drawingml::Color theColor;
+theColor.setSrgbClr(colorAttrib.get());
+mrTextCharacterProperties.maUnderlineColor = theColor;
+}
 break;
 }
 case W_TOKEN( spacing ):
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf132491_UnderlineColorGroupedShapes.docx 
b/sw/qa/extras/ooxmlexport/data/tdf132491_UnderlineColorGroupedShapes.docx
new file mode 100644
index ..aa5528b31093
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf132491_UnderlineColorGroupedShapes.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index e73e7dcfddab..a6352c767335 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -1198,6 +1198,20 @@ DECLARE_OOXMLEXPORT_TEST(testUnderlineGroupShapeText, 
"tdf123351_UnderlineGroupS
 
"/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u",
 "val", "single");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testUnderlineColorGroupedShapes, 
"tdf132491_UnderlineColorGroupedShapes.docx")
+{
+// tdf#132491 : Check if correct color is used for underline.
+xmlDocPtr pXmlDocument = parseExport("word/document.xml");
+if (!pXmlDocument)
+return;
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
+
"/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u",
 "color", "FF");
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
+
"/a:graphic/a:graphicData/wpg:wgp/wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u",
 "color", "00B050");
+assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
+
"/a:graphic/a:graphicData/wpg:wgp/wps:wsp[3]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:u",
 "color");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-21 Thread Tibor Nagy (via logerrit)
 oox/source/drawingml/textcharacterpropertiescontext.cxx|8 
+-
 sw/qa/extras/ooxmlexport/data/tdf131775_SpacingGroupShapeText.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx  |   12 
++
 3 files changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 9b7a2d33e9dcb5e4131e4901969d5853efdaf6e8
Author: Tibor Nagy 
AuthorDate: Wed Apr 1 15:04:22 2020 +0200
Commit: László Németh 
CommitDate: Tue Apr 21 09:51:35 2020 +0200

tdf#131775 DOCX DrawingML shape import: fix missing spacing

Character spacing of grouped shapes wasn't imported.

Co-Author: Balazs Regenyi, Szabolcs Toth

Change-Id: I9c4f204a5ab7c7e55e26968a71b315d84e5d8515
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91490
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx 
b/oox/source/drawingml/textcharacterpropertiescontext.cxx
old mode 100644
new mode 100755
index 7658d41031f0..5198b65b61ab
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -165,7 +165,7 @@ ContextHandlerRef 
TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
 case W_TOKEN( u ):
 {
 // If you add here, check if it is in drawingmltypes.cxx 113.
-auto attrib = rAttribs.getString(W_TOKEN( val ), OUString());
+auto attrib = rAttribs.getString(W_TOKEN(val), OUString());
 if (attrib == "single" || attrib == "words") // TODO: implement 
words properly. Now it is a single line.
 mrTextCharacterProperties.moUnderline = XML_sng;
 else if (attrib == "wavyHeavy")
@@ -202,6 +202,12 @@ ContextHandlerRef 
TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
 mrTextCharacterProperties.moUnderline = XML_none;
 break;
 }
+case W_TOKEN( spacing ):
+{
+auto attrib = rAttribs.getInteger(W_TOKEN( val ), 0);
+mrTextCharacterProperties.moSpacing = attrib;
+break;
+}
 case W_TOKEN( b ):
 mrTextCharacterProperties.moBold = rAttribs.getBool(W_TOKEN( val 
), true);
 break;
diff --git a/sw/qa/extras/ooxmlexport/data/tdf131775_SpacingGroupShapeText.docx 
b/sw/qa/extras/ooxmlexport/data/tdf131775_SpacingGroupShapeText.docx
new file mode 100644
index ..a7d34d6f24c6
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf131775_SpacingGroupShapeText.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index ee4b35698533..8f800ef1a17d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1243,6 +1243,18 @@ DECLARE_OOXMLEXPORT_TEST(testNonBMPChar, 
"nonbmpchar.docx")
 CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange1->getString());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testSpaceingGroupShapeText, 
"tdf131775_SpacingGroupShapeText.docx")
+{
+// tdf#131775: Check if correct spaceing.
+
+xmlDocPtr pXmlDocument = parseExport("word/document.xml");
+if (!pXmlDocument)
+return;
+
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
+
"/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:spacing",
 "val", "71");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-20 Thread Attila Bakos (via logerrit)
 oox/source/vml/vmlshapecontext.cxx  |9 +++--
 sw/qa/extras/ooxmlexport/data/tdf78749.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx  |   10 ++
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 9283cd9e13cd3e0dd7d6b831d930128931862a40
Author: Attila Bakos 
AuthorDate: Wed Apr 8 14:50:07 2020 +0200
Commit: László Németh 
CommitDate: Mon Apr 20 10:55:53 2020 +0200

tdf#78749 DOCX: import VML background image

of text boxes. DOCX relationship identifier
wasn't handled earlier, only XLSX.

Co-developer: Tibor Nagy

Change-Id: I72f246e6f69d70d1e203087516ee93a57563f777
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91933
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index dbec50102fd1..ce8805f6621c 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -354,6 +354,10 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( 
sal_Int32 nElement, const A
 mrTypeModel.maStrokeModel.moJoinStyle = rAttribs.getToken( 
XML_joinstyle );
 break;
 case VML_TOKEN( fill ):
+{
+// in DOCX shapes use r:id for the relationship id
+// in XLSX they use o:relid
+bool bHasORelId = rAttribs.hasAttribute( O_TOKEN(relid) );
 mrTypeModel.maFillModel.moFilled.assignIfUsed( lclDecodeBool( 
rAttribs, XML_on ) );
 mrTypeModel.maFillModel.moColor.assignIfUsed( rAttribs.getString( 
XML_color ) );
 mrTypeModel.maFillModel.moOpacity = lclDecodeOpacity( rAttribs, 
XML_opacity, 1.0 );
@@ -364,9 +368,10 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( 
sal_Int32 nElement, const A
 mrTypeModel.maFillModel.moFocus = lclDecodePercent( rAttribs, 
XML_focus, 0.0 );
 mrTypeModel.maFillModel.moFocusPos = lclDecodePercentPair( 
rAttribs, XML_focusposition );
 mrTypeModel.maFillModel.moFocusSize = lclDecodePercentPair( 
rAttribs, XML_focussize );
-mrTypeModel.maFillModel.moBitmapPath = decodeFragmentPath( 
rAttribs, O_TOKEN( relid ) );
+mrTypeModel.maFillModel.moBitmapPath = decodeFragmentPath( 
rAttribs, bHasORelId ? O_TOKEN(relid) : R_TOKEN(id) );
 mrTypeModel.maFillModel.moRotate = lclDecodeBool( rAttribs, 
XML_rotate );
-break;
+break;
+}
 case VML_TOKEN( imagedata ):
 {
 // shapes in docx use r:id for the relationship id
diff --git a/sw/qa/extras/ooxmlexport/data/tdf78749.docx 
b/sw/qa/extras/ooxmlexport/data/tdf78749.docx
new file mode 100644
index ..db498849e645
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf78749.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index ba54c33e115a..6c43dda43653 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -44,6 +44,16 @@ protected:
 }
 };
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf78749, "tdf78749.docx")
+{
+//Shape lost the background image before, now check if it still has...
+auto xShape = getShape(1);
+uno::Reference xShpProps(xShape, uno::UNO_QUERY);
+OUString aPropertyVal;
+xShpProps->getPropertyValue("FillBitmapName") >>= aPropertyVal;
+CPPUNIT_ASSERT(!aPropertyVal.isEmpty());
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128207, "tdf128207.docx")
 {
 //There was the charts on each other, because their horizontal and 
vertical position was 0!
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-17 Thread Regényi Balázs (via logerrit)
 oox/source/drawingml/textcharacterpropertiescontext.cxx   |3 ++
 sw/qa/extras/ooxmlexport/data/tdf131922_LanguageInGroupShape.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx|   13 
++
 3 files changed, 16 insertions(+)

New commits:
commit 01752af18d623676c4ebc7a8a4a47f69dfb79057
Author: Regényi Balázs 
AuthorDate: Tue Apr 7 10:01:15 2020 +0200
Commit: László Németh 
CommitDate: Fri Apr 17 13:50:54 2020 +0200

tdf#131922 DOCX DrawingML shape import: fix lang-id

The language identifier of text of grouped shapes wasn't imported.

Co-Author: Szabolcs Tóth

Change-Id: Ic71ea1bdf3aed27ad813cfa33659921060c0ec0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91801
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx 
b/oox/source/drawingml/textcharacterpropertiescontext.cxx
index 4533a96e1cca..7658d41031f0 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -262,6 +262,9 @@ ContextHandlerRef 
TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
 mrTextCharacterProperties.moBaseline = -25000;
 break;
 }
+case W_TOKEN(lang):
+mrTextCharacterProperties.moLang = 
rAttribs.getString(W_TOKEN(val), OUString());
+break;
 case OOX_TOKEN(w14, glow):
 case OOX_TOKEN(w14, shadow):
 case OOX_TOKEN(w14, reflection):
diff --git a/sw/qa/extras/ooxmlexport/data/tdf131922_LanguageInGroupShape.docx 
b/sw/qa/extras/ooxmlexport/data/tdf131922_LanguageInGroupShape.docx
new file mode 100644
index ..afd5ec57aedc
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf131922_LanguageInGroupShape.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index a8588a0ddf68..19582a7990eb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -989,6 +989,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf122594, "tdf122594.docx")
 CPPUNIT_ASSERT_EQUAL(static_cast(3), nCheck);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testLanguageInGroupShape, 
"tdf131922_LanguageInGroupShape.docx")
+{
+// tdf#131922: Check if good language is used in shape group texts
+xmlDocPtr pXml = parseExport("word/document.xml");
+if (!pXml)
+return;
+assertXPath(pXml,
+
"/w:document/w:body/w:p[7]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/"
+"a:graphic/a:graphicData/wpg:wgp/"
+"wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:lang",
+"val", "de-DE");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-09 Thread Regényi Balázs (via logerrit)
 oox/source/drawingml/textcharacterpropertiescontext.cxx  |6 +-
 sw/qa/extras/ooxmlexport/data/tdf131776_StrikeoutGroupShapeText.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |   28 
--
 3 files changed, 28 insertions(+), 6 deletions(-)

New commits:
commit 3bf68bfa4a6376857ed65e768722607ee7287dfa
Author: Regényi Balázs 
AuthorDate: Tue Apr 7 09:12:07 2020 +0200
Commit: László Németh 
CommitDate: Thu Apr 9 09:52:13 2020 +0200

tdf#131776 DOCX grouped shape import: fix regression for strikeouts

Because of previous commit we applied strikeout
on shape text if its attribute "val" was false.

Regression from commit 143e6641cea7a06faeec8b3b65aa09b153a6490f
(tdf#131776 DOCX DrawingML shape import: fix missing strikeout).

Co-Author: Szabolcs Toth

Change-Id: Iff2331cc183be59aee66a7f6f0ad65af89b13093
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91796
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx 
b/oox/source/drawingml/textcharacterpropertiescontext.cxx
index cd98b9564825..4533a96e1cca 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -211,10 +211,12 @@ ContextHandlerRef 
TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
 case W_TOKEN( bCs ):
 break;
 case W_TOKEN( strike ):
-mrTextCharacterProperties.moStrikeout = XML_sngStrike;
+if (rAttribs.getBool(W_TOKEN(val), true))
+mrTextCharacterProperties.moStrikeout = XML_sngStrike;
 break;
 case W_TOKEN( dstrike ):
-mrTextCharacterProperties.moStrikeout = XML_dblStrike;
+if (rAttribs.getBool(W_TOKEN(val), true))
+mrTextCharacterProperties.moStrikeout = XML_dblStrike;
 break;
 case W_TOKEN( color ):
 if (rAttribs.getInteger(W_TOKEN(val)).has())
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf131776_StrikeoutGroupShapeText.docx 
b/sw/qa/extras/ooxmlexport/data/tdf131776_StrikeoutGroupShapeText.docx
index b464f35e2f7e..3fd4ab1f5f59 100644
Binary files 
a/sw/qa/extras/ooxmlexport/data/tdf131776_StrikeoutGroupShapeText.docx and 
b/sw/qa/extras/ooxmlexport/data/tdf131776_StrikeoutGroupShapeText.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index e88b902aee0a..ba54c33e115a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -780,17 +780,37 @@ DECLARE_OOXMLEXPORT_TEST(testStrikeoutGroupShapeText, 
"tdf131776_StrikeoutGroupS
 if (!pXml)
 return;
 
-// double strike
+// double strike (dstrike)
+//   no "val" attribute
 assertXPath(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
 "wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:dstrike");
 assertXPathNoAttribute(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
 "wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:dstrike", "val");
+//   "val" attribute is true, this is used in this test file. However, LO 
is going to export this element without the "val" attribute
+//   because if the element appears, but without an attribute its "val" 
true by default.
+assertXPath(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
+"wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:dstrike");
+assertXPathNoAttribute(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
+"wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:dstrike", "val");
+//   "val" attribute is false (this was missing, resulting the regression)
+assertXPath(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
+"wps:wsp[3]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:dstrike", "val", 
"false");
 
-// simple strike
+// simple strike (strike)
+//   no "val" attribute
 assertXPath(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
-"wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:strike");
+"wps:wsp[4]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:strike");
 assertXPathNoAttribute(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
-"wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:strike", "val");
+"wps:wsp[4]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:strike", "val");
+//   "val" attribute 

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

2020-04-03 Thread Regényi Balázs (via logerrit)
 oox/source/drawingml/textcharacterpropertiescontext.cxx  |6 +++
 sw/qa/extras/ooxmlexport/data/tdf131776_StrikeoutGroupShapeText.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |   20 
++
 3 files changed, 26 insertions(+)

New commits:
commit 143e6641cea7a06faeec8b3b65aa09b153a6490f
Author: Regényi Balázs 
AuthorDate: Thu Apr 2 10:56:08 2020 +0200
Commit: László Németh 
CommitDate: Fri Apr 3 14:34:48 2020 +0200

tdf#131776 DOCX DrawingML shape import: fix missing strikeout

The absence of simple and double strikeouts is fixed.
Co-Author: Szabolcs Toth
Co-Author: Tibor Nagy

Change-Id: I5d7eef660f87c67855bce9847ad8e07d074183e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91555
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx 
b/oox/source/drawingml/textcharacterpropertiescontext.cxx
index b7bb876044cf..cd98b9564825 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -210,6 +210,12 @@ ContextHandlerRef 
TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
 break;
 case W_TOKEN( bCs ):
 break;
+case W_TOKEN( strike ):
+mrTextCharacterProperties.moStrikeout = XML_sngStrike;
+break;
+case W_TOKEN( dstrike ):
+mrTextCharacterProperties.moStrikeout = XML_dblStrike;
+break;
 case W_TOKEN( color ):
 if (rAttribs.getInteger(W_TOKEN(val)).has())
 {
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf131776_StrikeoutGroupShapeText.docx 
b/sw/qa/extras/ooxmlexport/data/tdf131776_StrikeoutGroupShapeText.docx
new file mode 100644
index ..b464f35e2f7e
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf131776_StrikeoutGroupShapeText.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index cff728463f28..fafe1cfe2b02 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -759,6 +759,26 @@ DECLARE_OOXMLEXPORT_TEST(testHyphenationAuto, 
"hyphenation.odt")
 assertXPath(pXmlStyles, 
"/w:styles/w:docDefaults/w:pPrDefault/w:pPr/w:suppressAutoHyphens", "val", 
"true");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testStrikeoutGroupShapeText, 
"tdf131776_StrikeoutGroupShapeText.docx")
+{
+// tdf#131776: Check if strikeout is used in shape group texts
+xmlDocPtr pXml = parseExport("word/document.xml");
+if (!pXml)
+return;
+
+// double strike
+assertXPath(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
+"wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:dstrike");
+assertXPathNoAttribute(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
+"wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:dstrike", "val");
+
+// simple strike
+assertXPath(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
+"wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:strike");
+assertXPathNoAttribute(pXml, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/"
+"wps:wsp[2]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:strike", "val");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-03-31 Thread Szabolcs Toth (via logerrit)
 oox/source/vml/vmlshape.cxx|   19 -
 sw/qa/extras/ooxmlexport/data/tdf100751_arrowBothFlip.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx  |   12 
 3 files changed, 18 insertions(+), 13 deletions(-)

New commits:
commit cb441c4d0adf698e6af9073c6c3285a66b76871e
Author: Szabolcs Toth 
AuthorDate: Tue Mar 17 11:39:33 2020 +0100
Commit: Balazs Varga 
CommitDate: Tue Mar 31 10:09:13 2020 +0200

tdf#100751 DOCX VML shape import: fix arrow direction

Flips along both the y- and x-axis weren't imported,
resulting wrong direction of arrow and other shapes.

Co-Author: Balázs Regényi

Change-Id: Iac222ac2a6a6110289969c32b40828b83da0aefd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90646
Tested-by: Jenkins
Reviewed-by: Balazs Varga 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 1c53a87b463e..bdd9ac593dd6 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -660,11 +660,11 @@ Reference< XShape > SimpleShape::implConvertAndInsert( 
const Reference< XShapes
 oRotation = ConversionHelper::decodeRotation(maTypeModel.maRotation);
 if (!maTypeModel.maFlip.isEmpty())
 {
-if (maTypeModel.maFlip == "x")
+if (maTypeModel.maFlip.startsWith("x"))
 {
 bFlipX = true;
 }
-else if (maTypeModel.maFlip == "y")
+if (maTypeModel.maFlip.endsWith("y"))
 {
 bFlipY = true;
 }
@@ -820,17 +820,10 @@ Reference< XShape > SimpleShape::implConvertAndInsert( 
const Reference< XShapes
 // When flip has 'x' or 'y', the associated ShapeRect will be changed 
but direction change doesn't occur.
 // It might occur internally in SdrObject of "sw" module, not here.
 // The associated properties "PROP_MirroredX" and "PROP_MirroredY" 
have to be set here so that direction change will occur internally.
-if (bFlipX || bFlipY)
-{
-assert(!(bFlipX && bFlipY));
-css::beans::PropertyValue aProp;
-if (bFlipX)
-aProp.Name = "MirroredX";
-else
-aProp.Name = "MirroredY";
-aProp.Value <<= true;
-aPropVec.push_back(aProp);
-}
+if (bFlipX)
+aPropVec.push_back(comphelper::makePropertyValue("MirroredX", 
true));
+if (bFlipY)
+aPropVec.push_back(comphelper::makePropertyValue("MirroredY", 
true));
 
 if (!maTypeModel.maAdjustments.isEmpty())
 {
diff --git a/sw/qa/extras/ooxmlexport/data/tdf100751_arrowBothFlip.docx 
b/sw/qa/extras/ooxmlexport/data/tdf100751_arrowBothFlip.docx
new file mode 100644
index ..8a57f69eaef0
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf100751_arrowBothFlip.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 4a7219a90a86..498cf8a95772 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1103,6 +1103,18 @@ DECLARE_OOXMLEXPORT_TEST(testVerticalBorders, 
"calendar3.docx")
 assertXPathChildren(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[3]/w:tc[3]/w:tcPr/w:tcBorders", 2);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testArrowFlipXY, "tdf100751_arrowBothFlip.docx")
+{
+// tdf#100751: Both x and y flip should happen.
+
+xmlDocPtr pXmlDocument = parseExport("word/document.xml");
+if (!pXmlDocument)
+return;
+
+OUString arrowStyle = getXPath(pXmlDocument, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:group/v:shape[2]",
 "style");
+CPPUNIT_ASSERT(arrowStyle.indexOf(u"flip:xy") != sal_Int32(-1));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-01-20 Thread Miklos Vajna (via logerrit)
 oox/source/vml/vmlshape.cxx  |3 +++
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

New commits:
commit b92293b3943423324064a8513c2e114d18817179
Author: Miklos Vajna 
AuthorDate: Mon Jan 20 21:21:17 2020 +0100
Commit: Miklos Vajna 
CommitDate: Tue Jan 21 08:41:42 2020 +0100

tdf#103983 VML import: handle 

We used to always always set TextAutoGrowHeight to true, only do that
when the matching VML attribute is detected, default to false.

This helps the exporter, so it writes the correct markup on save of the
bugdoc.

Also adapt testGroupshapeChildRotation, which in practice tested the
automatic height of the shape. The point of "auto" is that it changes as
needed, hardcoding that value in a test is not a great idea. Rather test
that the height is no longer automatic (there is no explicit markup in
the file, and the default is false).

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

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 15972cd0ff08..70b673258dc6 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -792,6 +792,9 @@ Reference< XShape > SimpleShape::implConvertAndInsert( 
const Reference< XShapes
 xShape->setSize(aSize);
 }
 }
+
+PropertySet(xShape).setAnyProperty(PROP_TextAutoGrowHeight,
+   makeAny(maTypeModel.mbAutoHeight));
 }
 
 // Import Legacy Fragments (if any)
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 956f75414488..a9edd2b66eb1 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -569,8 +569,9 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeChildRotation, 
"groupshape-child-rotation
 
 #if HAVE_MORE_FONTS
 xShape.set(xGroupShape->getByIndex(4), uno::UNO_QUERY);
-// This was 887, i.e. border distances were included in the height.
-CPPUNIT_ASSERT_EQUAL(sal_Int32(661), xShape->getSize().Height);
+// This was true, a VML textbox without  had
+// auto-grow on.
+CPPUNIT_ASSERT(!getProperty(xShape, "TextAutoGrowHeight"));
 // Paragraph Style Normal should provide the font name - which slightly 
affects the shape's height (was 686)
 uno::Reference xText = 
uno::Reference(xShape, uno::UNO_QUERY_THROW)->getText();
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Font", OUString("Times New Roman"), 
getProperty(getRun(xText, 1), "CharFontName"));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-01-14 Thread Mark Hung (via logerrit)
 oox/source/export/drawingml.cxx |2 -
 oox/source/shape/WpsContext.cxx |8 ++-
 sw/qa/extras/ooxmlexport/data/tdf128304.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx  |   29 +++-
 sw/source/filter/ww8/docxsdrexport.cxx  |2 -
 5 files changed, 33 insertions(+), 8 deletions(-)

New commits:
commit b203b9c83dc8465dcd92fb6b029a2f28c724
Author: Mark Hung 
AuthorDate: Fri Dec 13 07:23:35 2019 +0800
Commit: Miklos Vajna 
CommitDate: Tue Jan 14 10:23:19 2020 +0100

tdf#128304 export TB_RL writing mode as eaVirt

and import eaVirt to TextWritingMode instead of TextPreRotateAngle
(-90) degree of CustomShapeGeometry. CJK text in TB_RL writing mode
are upright in Writer. It corresponds to eaVirt by its defintion.

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

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 087c51da5541..8c9f641b5d4f 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2692,7 +2692,7 @@ void DrawingML::WriteText( const Reference< XInterface >& 
rXIface, const OUStrin
 
 if( ( mAny >>= eMode ) && eMode == WritingMode_TB_RL )
 {
-sWritingMode = "vert";
+sWritingMode = "eaVert";
 bVertical = true;
 }
 }
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index cf637eae0606..863621b3931c 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -57,7 +58,12 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 uno::Reference xServiceInfo(mxShape, 
uno::UNO_QUERY);
 uno::Reference xPropertySet(mxShape, 
uno::UNO_QUERY);
 sal_Int32 nVert = rAttribs.getToken(XML_vert, XML_horz);
-if (nVert != XML_horz)
+if (nVert == XML_eaVert)
+{
+xPropertySet->setPropertyValue("TextWritingMode",
+   
uno::makeAny(text::WritingMode_TB_RL));
+}
+else if (nVert != XML_horz)
 {
 // Get the existing rotation of the shape.
 drawing::HomogenMatrix3 aMatrix;
diff --git a/sw/qa/extras/ooxmlexport/data/tdf128304.odt 
b/sw/qa/extras/ooxmlexport/data/tdf128304.odt
new file mode 100644
index ..6c5cbd1200aa
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf128304.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 18e957bbcb09..81687683ec63 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -639,12 +640,10 @@ DECLARE_OOXMLEXPORT_TEST(testTbrlFrameVml, 
"tbrl-frame-vml.docx")
 
 if (mbExported)
 {
-// DML import: creates a TextBox.
+// DML import: creates a TextBox, eaVert read back as TB_RL in 
TextWritingMode
 
-comphelper::SequenceAsHashMap 
aGeometry(xTextFrame->getPropertyValue("CustomShapeGeometry"));
-// Without the accompanying fix in place, this test would have failed 
with 'Expected: -90;
-// Actual: 0', i.e. the tblr writing mode was lost during DML export 
of a TextFrame.
-CPPUNIT_ASSERT_EQUAL(static_cast(-90), 
aGeometry["TextPreRotateAngle"].get());
+auto eMode = getProperty(xTextFrame, 
"TextWritingMode");
+CPPUNIT_ASSERT_EQUAL(text::WritingMode::WritingMode_TB_RL, eMode);
 }
 else
 {
@@ -993,6 +992,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf127579, "tdf127579.odt")
 assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:hyperlink/w:r/w:rPr/w:rStyle", "val", "InternetLink");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf128304, "tdf128304.odt")
+{
+css::text::WritingMode eMode;
+uno::Reference xProps1(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xProps1->getPropertyValue("TextWritingMode") >>= eMode);
+CPPUNIT_ASSERT_EQUAL(css::text::WritingMode::WritingMode_TB_RL, eMode);
+
+uno::Reference xProps2(getShape(2), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xProps1->getPropertyValue("TextWritingMode") >>= eMode);
+CPPUNIT_ASSERT_EQUAL(css::text::WritingMode::WritingMode_TB_RL, eMode);
+
+uno::Reference xProps3(getShape(3), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xProps1->getPropertyValue("TextWritingMode") >>= eMode);
+CPPUNIT_ASSERT_EQUAL(css::text::WritingMode::WritingMode_TB_RL, eMode);
+
+uno::Reference xProps4(getShape(4), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xProps1->getPropertyValue("TextWritingMode") 

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

2019-11-16 Thread Mike Kaganski (via logerrit)
 oox/source/export/shapes.cxx |   35 
 sw/qa/extras/ooxmlexport/data/tdf128820.fodt | 1353 +++
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |5 
 3 files changed, 1376 insertions(+), 17 deletions(-)

New commits:
commit b699a693cabf307418d3aa2c159d58a4bedd43a4
Author: Mike Kaganski 
AuthorDate: Sat Nov 16 15:02:35 2019 +0300
Commit: Mike Kaganski 
CommitDate: Sat Nov 16 16:55:19 2019 +0100

tdf#128820: use wps namespace for simple text shapes

Without that, simple text shapes inside groups were written in
 elements, with many child elements also having pic::
prefix.

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

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index ebab46728bef..9f69e316cbec 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -381,6 +381,14 @@ awt::Size ShapeExport::MapSize( const awt::Size& rSize ) 
const
 return awt::Size( aRetSize.Width(), aRetSize.Height() );
 }
 
+static bool IsNonEmptySimpleText(const Reference& xIface)
+{
+if (Reference xText{ xIface, UNO_QUERY })
+return xText->getString().getLength();
+
+return false;
+}
+
 bool ShapeExport::NonEmptyText( const Reference< XInterface >& xIface )
 {
 Reference< XPropertySet > xPropSet( xIface, UNO_QUERY );
@@ -414,12 +422,7 @@ bool ShapeExport::NonEmptyText( const Reference< 
XInterface >& xIface )
 }
 }
 
-Reference< XSimpleText > xText( xIface, UNO_QUERY );
-
-if( xText.is() )
-return xText->getString().getLength();
-
-return false;
+return IsNonEmptySimpleText(xIface);
 }
 
 ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& 
xShape, const bool bClosed )
@@ -529,7 +532,11 @@ ShapeExport& ShapeExport::WriteGroupShape(const 
uno::Reference&
 uno::Reference xServiceInfo(xChild, 
uno::UNO_QUERY_THROW);
 if (GetDocumentType() == DOCUMENT_DOCX)
 {
-if 
(xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
+// tdf#128820: WriteGraphicObjectShapePart calls WriteTextShape 
for non-empty simple
+// text objects, which needs writing into wps::wsp element, so 
make sure to use wps
+// namespace for those objects
+if 
(xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape")
+&& !IsNonEmptySimpleText(xChild))
 mnXmlNamespace = XML_pic;
 else
 mnXmlNamespace = XML_wps;
@@ -1165,19 +1172,13 @@ void ShapeExport::WriteGraphicObjectShapePart( const 
Reference< XShape >& xShape
 {
 SAL_INFO("oox.shape", "write graphic object shape");
 
-if( NonEmptyText( xShape ) )
+if (IsNonEmptySimpleText(xShape))
 {
-// avoid treating all 'IsPresentationObject' objects as having text.
-Reference< XSimpleText > xText( xShape, UNO_QUERY );
+SAL_INFO("oox.shape", "graphicObject: wrote only text");
 
-if( xText.is() && !xText->getString().isEmpty() )
-{
-SAL_INFO("oox.shape", "graphicObject: wrote only text");
+WriteTextShape(xShape);
 
-WriteTextShape( xShape );
-
-return;
-}
+return;
 }
 
 SAL_INFO("oox.shape", "graphicObject without text");
diff --git a/sw/qa/extras/ooxmlexport/data/tdf128820.fodt 
b/sw/qa/extras/ooxmlexport/data/tdf128820.fodt
new file mode 100644
index ..bb39fee02534
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf128820.fodt
@@ -0,0 +1,1353 @@
+
+
+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:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
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:rpt="http://openoffice.org/2005/report; 
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:css3t="http://www.w3.org/TR/css3-text/; 
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; 

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

2019-08-28 Thread Tamás Zolnai (via logerrit)
 oox/source/ole/axbinarywriter.cxx|4 ++--
 sw/qa/extras/ooxmlexport/data/tdf118169.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx   |   10 ++
 3 files changed, 12 insertions(+), 2 deletions(-)

New commits:
commit 4b82652c4de94db553dfd7a63801ea81d366315a
Author: Tamás Zolnai 
AuthorDate: Wed Aug 28 16:24:59 2019 +0200
Commit: Tamás Zolnai 
CommitDate: Wed Aug 28 21:34:52 2019 +0200

tdf#118169: ActiveX form control saved incorrectly with accented letters

Write out unicode strings without any compression.

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

diff --git a/oox/source/ole/axbinarywriter.cxx 
b/oox/source/ole/axbinarywriter.cxx
index 89d2dc25351a..400e6fbde551 100644
--- a/oox/source/ole/axbinarywriter.cxx
+++ b/oox/source/ole/axbinarywriter.cxx
@@ -144,8 +144,8 @@ void AxBinaryPropertyWriter::writePairProperty( AxPairData& 
orPairData )
 
 void AxBinaryPropertyWriter::writeStringProperty( OUString& orValue )
 {
-sal_uInt32 nSize = orValue.getLength();
-setFlag(  nSize, AX_STRING_COMPRESSED );
+sal_uInt32 nSize = orValue.getLength() * 2;
+setFlag(  nSize, AX_STRING_COMPRESSED, false );
 maOutStrm.writeAligned< sal_uInt32 >( nSize );
 maLargeProps.push_back( ComplexPropVector::value_type( new StringProperty( 
orValue, nSize ) ) );
 startNextProperty();
diff --git a/sw/qa/extras/ooxmlexport/data/tdf118169.docx 
b/sw/qa/extras/ooxmlexport/data/tdf118169.docx
new file mode 100644
index ..2510fb3e59eb
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf118169.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index ea5b48b33397..804ec41a4bed 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -596,6 +596,16 @@ DECLARE_OOXMLEXPORT_TEST(tdf119809, "tdf119809.docx")
 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty< uno::Sequence 
>(xPropertySet, "StringItemList").getLength());
 }
 
+DECLARE_OOXMLEXPORT_TEST(tdf118169, "tdf118169.docx")
+{
+// Unicode characters were converted to question marks.
+uno::Reference xControlShape(getShape(1), 
uno::UNO_QUERY);
+uno::Reference 
xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
+uno::Reference xServiceInfo(xPropertySet, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(true, 
bool(xServiceInfo->supportsService("com.sun.star.form.component.CheckBox")));
+CPPUNIT_ASSERT_EQUAL(OUString(u"őőő"), 
getProperty(xPropertySet, "Label"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-08-22 Thread Tamás Zolnai (via logerrit)
 oox/source/export/drawingml.cxx  |   10 +++---
 sw/qa/extras/ooxmlexport/data/tdf127085.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx   |7 +++
 3 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit 505cbb9c3d2771a12c989515663cc1eb73dd0c2f
Author: Tamás Zolnai 
AuthorDate: Thu Aug 22 15:57:41 2019 +0200
Commit: Tamás Zolnai 
CommitDate: Thu Aug 22 17:21:19 2019 +0200

tdf#127085: FILESAVE: Transparency is lost after RT

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

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index d4b35c8988f6..6f975a298e50 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1274,14 +1274,18 @@ void 
DrawingML::WriteImageBrightnessContrastTransparence(uno::Reference();
 if (GetProperty(rXPropSet, "AdjustContrast"))
 nContrast = mAny.get();
-if (GetProperty(rXPropSet, "Transparency"))
-nTransparence = mAny.get();
+// Used for shapes with picture fill
+if (GetProperty(rXPropSet, "FillTransparence"))
+nTransparence = mAny.get();
+// Used for pictures
+if (nTransparence == 0 && GetProperty(rXPropSet, "Transparency"))
+nTransparence = static_cast(mAny.get());
 
 
 if (nBright || nContrast)
diff --git a/sw/qa/extras/ooxmlexport/data/tdf127085.docx 
b/sw/qa/extras/ooxmlexport/data/tdf127085.docx
new file mode 100644
index ..65556fe38abd
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf127085.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index e59e65e19312..5666f4fae730 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -579,6 +579,13 @@ DECLARE_OOXMLIMPORT_TEST(testInvalidDateFormField, 
"invalid_date_form_field.docx
 CPPUNIT_ASSERT_EQUAL(int(3), nIndex);
 }
 
+DECLARE_OOXMLEXPORT_TEST(tdf127085, "tdf127085.docx")
+{
+// Fill transparency was lost during export
+uno::Reference xShape(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty(xShape, 
"FillTransparence"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-08-21 Thread Stephan Bergmann (via logerrit)
 oox/source/core/xmlfilterbase.cxx   |2 +-
 sw/qa/extras/ooxmlexport/ooxmllinks.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 10e972c5fba698b287b6f19d7b249e38b18f8895
Author: Stephan Bergmann 
AuthorDate: Wed Aug 21 15:19:30 2019 +0200
Commit: Stephan Bergmann 
CommitDate: Wed Aug 21 17:21:14 2019 +0200

Better use DecodeMechanims ToIUri rather than Unambiguous here

...to avoid erroneously un-escaping input like "file:///%3C" to "file:///<"

Change-Id: I973208dac38799794216e1ee36a63662d434e8cf
Reviewed-on: https://gerrit.libreoffice.org/77886
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index a5d565e93839..d62250344686 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -517,7 +517,7 @@ OUString lclAddRelation( const Reference< 
XRelationshipAccess >& rRelations, sal
 aEntry[0].First = "Type";
 aEntry[0].Second = rType;
 aEntry[1].First = "Target";
-aEntry[1].Second = INetURLObject::decode(rTarget, 
INetURLObject::DecodeMechanism::Unambiguous, RTL_TEXTENCODING_UTF8);
+aEntry[1].Second = INetURLObject::decode(rTarget, 
INetURLObject::DecodeMechanism::ToIUri, RTL_TEXTENCODING_UTF8);
 if( bExternal )
 {
 aEntry[2].First = "TargetMode";
diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx 
b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
index 3939fc69b723..476c4fc5408d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
@@ -267,7 +267,7 @@ DECLARE_LINKS_EXPORT_TEST(testNon_ascii_link_export, 
"non_ascii_link.docx", USE_
 
 OUString sTarget = "file:///C:/TEMP/%C3%A9kezet.docx";
 assertXPath(pXmlDoc, 
"/rels:Relationships/rels:Relationship[@TargetMode='External']", "Target",
-INetURLObject::decode( sTarget, 
INetURLObject::DecodeMechanism::Unambiguous,
+INetURLObject::decode( sTarget, 
INetURLObject::DecodeMechanism::ToIUri,
 RTL_TEXTENCODING_UTF8));
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-08-21 Thread Tünde Tóth (via logerrit)
 oox/source/core/xmlfilterbase.cxx |3 ++-
 sw/qa/extras/ooxmlexport/data/non_ascii_link.docx |binary
 sw/qa/extras/ooxmlexport/ooxmllinks.cxx   |   14 ++
 3 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit d053d573d8bb70ba02ed60eecc590485e2e19497
Author: Tünde Tóth 
AuthorDate: Wed Aug 14 12:37:00 2019 +0200
Commit: László Németh 
CommitDate: Wed Aug 21 12:30:28 2019 +0200

tdf#127070 DOCX export:fix encoding of hyperlinks with non-ASCII letters

Non-ASCII file links in DOCX documents created with Microsoft Word
didn't work in Word after export.

non_ascii_link.docx: Test file from Word 2016.

Change-Id: Ib8c4e2e7b0402b88419d200c55cc1b881a4cde86
Reviewed-on: https://gerrit.libreoffice.org/77450
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index 54f8b9f6ca83..a5d565e93839 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -516,7 +517,7 @@ OUString lclAddRelation( const Reference< 
XRelationshipAccess >& rRelations, sal
 aEntry[0].First = "Type";
 aEntry[0].Second = rType;
 aEntry[1].First = "Target";
-aEntry[1].Second = rTarget;
+aEntry[1].Second = INetURLObject::decode(rTarget, 
INetURLObject::DecodeMechanism::Unambiguous, RTL_TEXTENCODING_UTF8);
 if( bExternal )
 {
 aEntry[2].First = "TargetMode";
diff --git a/sw/qa/extras/ooxmlexport/data/non_ascii_link.docx 
b/sw/qa/extras/ooxmlexport/data/non_ascii_link.docx
new file mode 100644
index ..345a55b5cff7
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/non_ascii_link.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx 
b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
index 406af22d6ada..4be6351a12f1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
@@ -259,6 +259,20 @@ DECLARE_LINKS_EXPORT_TEST(testTdf126768_export, 
"tdf126768.docx", USE_ABSOLUTE,
 assertXPath(pXmlDoc, 
"/rels:Relationships/rels:Relationship[@TargetMode='External']", "Target",
 "file:///C:/TEMP/test.docx");
 }
+
+DECLARE_LINKS_EXPORT_TEST(testNon_ascii_link_export, "non_ascii_link.docx", 
USE_ABSOLUTE,
+  DONT_MODIFY_LINK)
+{
+xmlDocPtr pXmlDoc = parseExport("word/_rels/document.xml.rels");
+if (!pXmlDoc)
+return;
+
+OUString sTarget = "file:///C:/TEMP/%C3%A9kezet.docx";
+assertXPath(pXmlDoc, 
"/rels:Relationships/rels:Relationship[@TargetMode='External']", "Target",
+INetURLObject::decode( sTarget, 
INetURLObject::DecodeMechanism::Unambiguous,
+RTL_TEXTENCODING_UTF8));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: oox/source sw/qa writerfilter/source

2019-07-05 Thread Miklos Vajna (via logerrit)
 oox/source/vml/vmlshape.cxx   |   29 +++---
 sw/qa/extras/ooxmlimport/data/btlr-frame-vml.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |   11 
 writerfilter/source/dmapper/DomainMapper.cxx  |3 --
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   13 -
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |1 
 6 files changed, 17 insertions(+), 40 deletions(-)

New commits:
commit bffe6a496fb1c69499770d96fefd7a3609712676
Author: Miklos Vajna 
AuthorDate: Thu Jul 4 21:37:14 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri Jul 5 09:04:03 2019 +0200

sw btlr writing mode: handle import from VML

Instead of the character-level rotation added in commit
8738ded7bb1bb6262fe1038e310b5110407f4cfa (fdo#69636 VML import: handle
mso-layout-flow-alt shape prop for sw frames, 2013-09-26) which does not
work for multiple paragraphs.

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

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index a7529493e401..eca5399bf72c 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -728,33 +728,14 @@ Reference< XShape > SimpleShape::implConvertAndInsert( 
const Reference< XShapes
 PropertySet( xShape ).setAnyProperty( PROP_BottomBorderDistance, 
makeAny( sal_Int32( getTextBox()->borderDistanceBottom )));
 }
 
-if (getTextBox()->maLayoutFlow == "vertical" && 
maTypeModel.maLayoutFlowAlt.isEmpty())
+if (getTextBox()->maLayoutFlow == "vertical")
 {
-PropertySet(xShape).setAnyProperty(PROP_WritingMode,
-   
uno::makeAny(text::WritingMode2::TB_RL));
-}
-
-if (!maTypeModel.maLayoutFlowAlt.isEmpty())
-{
-// Can't handle this property here, as the frame is not attached 
yet: pass it to writerfilter.
-uno::Reference xPropertySet(xShape, 
uno::UNO_QUERY);
-uno::Sequence aGrabBag;
-xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
-beans::PropertyValue aPair;
-aPair.Name = "mso-layout-flow-alt";
-aPair.Value <<= maTypeModel.maLayoutFlowAlt;
-if (aGrabBag.hasElements())
-{
-sal_Int32 nLength = aGrabBag.getLength();
-aGrabBag.realloc(nLength + 1);
-aGrabBag[nLength] = aPair;
-}
-else
+sal_Int16 nWritingMode = text::WritingMode2::TB_RL;
+if (maTypeModel.maLayoutFlowAlt == "bottom-to-top")
 {
-aGrabBag.realloc(1);
-aGrabBag[0] = aPair;
+nWritingMode = text::WritingMode2::BT_LR;
 }
-xPropertySet->setPropertyValue("FrameInteropGrabBag", 
uno::makeAny(aGrabBag));
+PropertySet(xShape).setAnyProperty(PROP_WritingMode, 
uno::makeAny(nWritingMode));
 }
 }
 else
diff --git a/sw/qa/extras/ooxmlimport/data/btlr-frame-vml.docx 
b/sw/qa/extras/ooxmlimport/data/btlr-frame-vml.docx
new file mode 100644
index ..a93703c75526
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/btlr-frame-vml.docx 
differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index b447c3f7273f..65750d5952f9 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -233,6 +233,17 @@ DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx")
 // and as result only one page should be generated.
 DECLARE_OOXMLIMPORT_TEST(testTdf113182, "tdf113182.docx") { 
CPPUNIT_ASSERT_EQUAL(1, getPages()); }
 
+DECLARE_OOXMLIMPORT_TEST(testBtlrFrameVml, "btlr-frame-vml.docx")
+{
+uno::Reference xTextFrame(getShape(1), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xTextFrame.is());
+
+auto nActual = getProperty(xTextFrame, "WritingMode");
+// Without the accompanying fix in place, this test would have failed with 
'Expected: 5; Actual:
+// 4', i.e. writing direction was inherited from page, instead of explicit 
btlr.
+CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, nActual);
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf124398, "tdf124398.docx")
 {
 uno::Reference xGroup(getShape(1), 
uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 54e4a7bdd7a1..1b24e0624dc8 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3052,9 +3052,6 @@ void DomainMapper::PopListProperties()
 void DomainMapper::lcl_startCharacterGroup()
 {
 m_pImpl->PushProperties(CONTEXT_CHARACTER);
-if (m_pImpl->m_bFrameBtLr)
-// No support for this in core, work around by char rotation, as we do 

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

2019-06-14 Thread Miklos Vajna (via logerrit)
 oox/source/vml/vmlshape.cxx   |8 
 sw/qa/extras/ooxmlimport/data/tbrl-frame-vml.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |   12 
 3 files changed, 20 insertions(+)

New commits:
commit 31b44f010557c43d8b02cc3be590ed1629bf1ca5
Author: Miklos Vajna 
AuthorDate: Thu Jun 13 23:17:34 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri Jun 14 09:07:14 2019 +0200

sw btlr writing mode: fix tbrl import from VML

Wanted to do btlr, but even tbrl (e.g. Japanese text) is not working, so
let's do that first.

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

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 27d7b51959ca..a7529493e401 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -726,6 +727,13 @@ Reference< XShape > SimpleShape::implConvertAndInsert( 
const Reference< XShapes
 PropertySet( xShape ).setAnyProperty( PROP_RightBorderDistance, 
makeAny( sal_Int32( getTextBox()->borderDistanceRight )));
 PropertySet( xShape ).setAnyProperty( PROP_BottomBorderDistance, 
makeAny( sal_Int32( getTextBox()->borderDistanceBottom )));
 }
+
+if (getTextBox()->maLayoutFlow == "vertical" && 
maTypeModel.maLayoutFlowAlt.isEmpty())
+{
+PropertySet(xShape).setAnyProperty(PROP_WritingMode,
+   
uno::makeAny(text::WritingMode2::TB_RL));
+}
+
 if (!maTypeModel.maLayoutFlowAlt.isEmpty())
 {
 // Can't handle this property here, as the frame is not attached 
yet: pass it to writerfilter.
diff --git a/sw/qa/extras/ooxmlimport/data/tbrl-frame-vml.docx 
b/sw/qa/extras/ooxmlimport/data/tbrl-frame-vml.docx
new file mode 100644
index ..c697e5846ce6
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tbrl-frame-vml.docx 
differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 1c7282623b00..80967be606d7 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 class Test : public SwModelTestBase
 {
@@ -255,6 +256,17 @@ DECLARE_OOXMLIMPORT_TEST(testTdf113946, "tdf113946.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("1695"), aTop);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTbrlFrameVml, "tbrl-frame-vml.docx")
+{
+uno::Reference xTextFrame(getShape(1), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xTextFrame.is());
+
+auto nActual = getProperty(xTextFrame, "WritingMode");
+// Without the accompanying fix in place, this test would have failed with 
'Expected: 2; Actual:
+// 4', i.e. writing direction was inherited from page, instead of explicit 
tbrl.
+CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, nActual);
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf121804, "tdf121804.docx")
 {
 uno::Reference xGroup(getShape(1), 
uno::UNO_QUERY);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-05-14 Thread Serge Krot (via logerrit)
 oox/source/shape/WpsContext.cxx  |9 +++--
 sw/qa/extras/ooxmlimport/data/tdf124754.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx|   15 +++
 3 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit e24707d64d2d4c59c2aedf0235f5b1a694ec5f65
Author: Serge Krot 
AuthorDate: Mon May 13 15:43:44 2019 +0200
Commit: Thorsten Behrens 
CommitDate: Tue May 14 11:03:57 2019 +0200

tdf#124754 sw docx import: do not override text color with -1 (auto) color

Change-Id: Id821b0d8bef69a7124ee41558e822cf8b025df9d
Reviewed-on: https://gerrit.libreoffice.org/72232
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 0f39a850b0ee..0692ea43777d 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -140,8 +140,13 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 {
 uno::Reference 
xTextBoxPropertySet(xTextCursor,
 
uno::UNO_QUERY);
-xTextBoxPropertySet->setPropertyValue(
-"CharColor", 
xPropertySet->getPropertyValue("CharColor"));
+uno::Any xCharColor = 
xPropertySet->getPropertyValue("CharColor");
+Color aColor = COL_AUTO;
+if (xCharColor >>= aColor)
+{
+if (aColor != COL_AUTO)
+xTextBoxPropertySet->setPropertyValue("CharColor", 
xCharColor);
+}
 }
 return this;
 }
diff --git a/sw/qa/extras/ooxmlimport/data/tdf124754.docx 
b/sw/qa/extras/ooxmlimport/data/tdf124754.docx
new file mode 100644
index ..2f7f4e14bda5
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf124754.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index fcd6d8d34d91..1c7282623b00 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -194,6 +194,7 @@ DECLARE_OOXMLIMPORT_TEST(testTdf117843, "tdf117843.docx")
 getProperty(getParagraphOfText(1, xHeaderText), 
"ParaTopMargin"));
 }
 
+// related tdf#124754
 DECLARE_OOXMLIMPORT_TEST(testTdf43017, "tdf43017.docx")
 {
 uno::Reference xParagraph = getParagraph(1);
@@ -204,6 +205,20 @@ DECLARE_OOXMLIMPORT_TEST(testTdf43017, "tdf43017.docx")
  getProperty(xText, "CharColor"));
 }
 
+// related tdf#43017
+DECLARE_OOXMLIMPORT_TEST(testTdf124754, "tdf124754.docx")
+{
+uno::Reference textbox(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(1, getParagraphs(textbox));
+
+uno::Reference xParagraph = getParagraphOfText(1, 
textbox);
+uno::Reference xText = getRun(xParagraph, 2);
+
+// Ensure that hyperlink text color is not black
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Hyperlink color should be not black!", 
sal_Int32(353217),
+ getProperty(xText, "CharColor"));
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx")
 {
 // the position of the flying text frame should be off page
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-04-29 Thread Miklos Vajna (via logerrit)
 oox/source/drawingml/shape.cxx   |5 -
 oox/source/shape/WpgContext.cxx  |6 +-
 sw/qa/extras/ooxmlimport/data/tdf124398.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx|   12 
 4 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit fdf4aaa3dc5cc1d2e7a112e6c32d7845f13caef8
Author: Miklos Vajna 
AuthorDate: Mon Apr 29 08:35:29 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Apr 29 09:57:04 2019 +0200

tdf#124398 DOCX drawingML import: handle charts in group shapes

Regression from commit 8c73b16f5f18f3bc1dbf9ff6c1475db56b44d304 (DOCX
import: declare wpg as a supported feature, 2013-12-05), the problem was
that  did not forward to to the relevant oox context,
and also Writer had no idea how to create a
com.sun.star.drawing.OLE2Shape. Fix the later by using the same service
name that's in use for the non-groupshape case.

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

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 3c84428389a5..41c8d9493dcf 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -220,7 +220,10 @@ ChartShapeInfo& Shape::setChartType( bool bEmbedShapes )
 {
 OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setChartType - 
multiple frame types" );
 meFrameType = FRAMETYPE_CHART;
-msServiceName = "com.sun.star.drawing.OLE2Shape";
+if (mbWps)
+msServiceName = "com.sun.star.drawing.temporaryForXMLImportOLE2Shape";
+else
+msServiceName = "com.sun.star.drawing.OLE2Shape";
 mxChartShapeInfo.reset( new ChartShapeInfo( bEmbedShapes ) );
 return *mxChartShapeInfo;
 }
diff --git a/oox/source/shape/WpgContext.cxx b/oox/source/shape/WpgContext.cxx
index c297ff16d822..33fb318e73e8 100644
--- a/oox/source/shape/WpgContext.cxx
+++ b/oox/source/shape/WpgContext.cxx
@@ -61,7 +61,11 @@ oox::core::ContextHandlerRef 
WpgContext::onCreateContext(sal_Int32 nElementToken
 return new oox::drawingml::ShapeGroupContext(*this, mpShape, 
std::make_shared("com.sun.star.drawing.GroupShape"));
 }
 case XML_graphicFrame:
-break;
+{
+auto pShape = 
std::make_shared("com.sun.star.drawing.GraphicObjectShape");
+pShape->setWps(true);
+return new oox::drawingml::GraphicalObjectFrameContext(*this, mpShape, 
pShape, /*bEmbedShapesInChart=*/true);
+}
 default:
 SAL_WARN("oox", "WpgContext::createFastChildContext: unhandled 
element: " << getBaseToken(nElementToken));
 break;
diff --git a/sw/qa/extras/ooxmlimport/data/tdf124398.docx 
b/sw/qa/extras/ooxmlimport/data/tdf124398.docx
new file mode 100644
index ..4d1855347fd6
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf124398.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 3df3f1adf8db..fcd6d8d34d91 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -217,6 +217,18 @@ DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx")
 // and as result only one page should be generated.
 DECLARE_OOXMLIMPORT_TEST(testTdf113182, "tdf113182.docx") { 
CPPUNIT_ASSERT_EQUAL(1, getPages()); }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf124398, "tdf124398.docx")
+{
+uno::Reference xGroup(getShape(1), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xGroup.is());
+// Without the accompanying fix in place, this test would have failed with 
'Expected: 2; Actual:
+// 1', i.e. the chart children of the group shape was lost.
+CPPUNIT_ASSERT_EQUAL(static_cast(2), xGroup->getCount());
+
+uno::Reference xShape(xGroup->getByIndex(1), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.OLE2Shape"), 
xShape->getShapeType());
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf113946, "tdf113946.docx")
 {
 OUString aTop = 
parseDump("/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "top");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-04-26 Thread Miklos Vajna (via logerrit)
 oox/source/shape/WpsContext.cxx |   84 
 sw/qa/extras/ooxmlexport/data/tbrl-textbox.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx  |   10 ++
 sw/source/core/doc/textboxhelper.cxx|   62 -
 4 files changed, 84 insertions(+), 72 deletions(-)

New commits:
commit ff17478e069cc82681df62514876c06365dd5cd6
Author: Miklos Vajna 
AuthorDate: Thu Apr 25 21:05:43 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri Apr 26 09:05:04 2019 +0200

sw btlr writing mode: implement DOCX shape import for tbrl

Now that the btlr writing mode works reasonably well in table cells, the
next context is shape text. But turns out that DOCX shape text lacked
support in the easier tbrl case, so add that first.

Also remove the char-level text rotation code in oox, that is
effectively dead code since we import drawingML shapes as shape +
Writer TextBox.

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

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 19b413f5c329..0f39a850b0ee 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -59,61 +59,39 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 {
 uno::Reference xServiceInfo(mxShape, 
uno::UNO_QUERY);
 uno::Reference xPropertySet(mxShape, 
uno::UNO_QUERY);
-OptValue oVert = rAttribs.getString(XML_vert);
-if (oVert.has() && oVert.get() == "vert270")
+sal_Int32 nVert = rAttribs.getToken(XML_vert, XML_horz);
+if (nVert != XML_horz)
 {
-if 
(xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
-{
-// No support for this in core, work around by char 
rotation, as we do so for table cells already.
-uno::Reference xText(mxShape, 
uno::UNO_QUERY);
-uno::Reference xTextCursor = 
xText->createTextCursor();
-xTextCursor->gotoStart(false);
-xTextCursor->gotoEnd(true);
-uno::Reference 
xPropertyState(xTextCursor,
- 
uno::UNO_QUERY);
-beans::PropertyState aState
-= xPropertyState->getPropertyState("CharRotation");
-if (aState == beans::PropertyState_DEFAULT_VALUE)
-{
-uno::Reference 
xTextCursorPropertySet(
-xTextCursor, uno::UNO_QUERY);
-
xTextCursorPropertySet->setPropertyValue("CharRotation",
- 
uno::makeAny(sal_Int16(900)));
-}
-}
-else
-{
-// Get the existing rotation of the shape.
-drawing::HomogenMatrix3 aMatrix;
-xPropertySet->getPropertyValue("Transformation") >>= 
aMatrix;
-basegfx::B2DHomMatrix aTransformation;
-aTransformation.set(0, 0, aMatrix.Line1.Column1);
-aTransformation.set(0, 1, aMatrix.Line1.Column2);
-aTransformation.set(0, 2, aMatrix.Line1.Column3);
-aTransformation.set(1, 0, aMatrix.Line1.Column1);
-aTransformation.set(1, 1, aMatrix.Line2.Column2);
-aTransformation.set(1, 2, aMatrix.Line3.Column3);
-aTransformation.set(2, 0, aMatrix.Line1.Column1);
-aTransformation.set(2, 1, aMatrix.Line2.Column2);
-aTransformation.set(2, 2, aMatrix.Line3.Column3);
-basegfx::B2DTuple aScale;
-basegfx::B2DTuple aTranslate;
-double fRotate = 0;
-double fShearX = 0;
-aTransformation.decompose(aScale, aTranslate, fRotate, 
fShearX);
+// Get the existing rotation of the shape.
+drawing::HomogenMatrix3 aMatrix;
+xPropertySet->getPropertyValue("Transformation") >>= 
aMatrix;
+basegfx::B2DHomMatrix aTransformation;
+aTransformation.set(0, 0, aMatrix.Line1.Column1);
+aTransformation.set(0, 1, aMatrix.Line1.Column2);
+aTransformation.set(0, 2, aMatrix.Line1.Column3);
+aTransformation.set(1, 0, aMatrix.Line1.Column1);
+aTransformation.set(1, 

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

2019-04-25 Thread Caolán McNamara (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |6 ++
 sw/qa/core/data/ooxml/fail/ofz14422-1.docx  |binary
 2 files changed, 6 insertions(+)

New commits:
commit 8b20381b936f643c0d6f7525a2acdbdc20366493
Author: Caolán McNamara 
AuthorDate: Wed Apr 24 11:38:53 2019 +0100
Commit: Caolán McNamara 
CommitDate: Thu Apr 25 16:08:12 2019 +0200

ofz#14422 null deref

Change-Id: Icd00e2aaa5932564668cd12ce4ee63aecc34419a
Reviewed-on: https://gerrit.libreoffice.org/71226
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 96e305b46a00..323fafe12045 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -1290,6 +1290,12 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, 
const dgm::Point* pPresNode
 continue;
 }
 
+if (!aDataNode2->second->mpShape)
+{
+//busted, skip it
+continue;
+}
+
 rShape->setDataNodeType(aDataNode2->second->mnType);
 
 if (rItem.mnDepth == 0)
diff --git a/sw/qa/core/data/ooxml/fail/ofz14422-1.docx 
b/sw/qa/core/data/ooxml/fail/ofz14422-1.docx
new file mode 100644
index ..8284f6afc4b3
Binary files /dev/null and b/sw/qa/core/data/ooxml/fail/ofz14422-1.docx differ
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-01-10 Thread Libreoffice Gerrit user
 oox/source/vml/vmlshapecontext.cxx   |4 +++-
 sw/qa/extras/ooxmlexport/data/tdf122563.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |   11 +++
 3 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit bdb0177b550d27a541cdfc0668714b2e9ac28540
Author: László Németh 
AuthorDate: Wed Jan 9 22:15:26 2019 +0100
Commit: László Németh 
CommitDate: Thu Jan 10 17:27:27 2019 +0100

tdf#122563 DOCX import: fix OLE size after roundtrip

Embedded XLSX spreadsheets and other OLE objects
became small in Writer after a roundtrip between
LibO and MSO, caused by the empty drawing path of
OLE shapes.

Change-Id: I4cd39d4bcd6707cc5a3b8e40dde8c6148a20cabc
Reviewed-on: https://gerrit.libreoffice.org/66053
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index f5f4bf884e31..621f20d29895 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -240,7 +240,9 @@ ContextHandlerRef ShapeContextBase::createShapeContext( 
ContextHandler2Helper co
 case VML_TOKEN( group ):
 return new GroupShapeContext( rParent, rShapes.createShape< 
GroupShape >(), rAttribs );
 case VML_TOKEN( shape ):
-if (rAttribs.hasAttribute(XML_path))
+if (rAttribs.hasAttribute(XML_path) &&
+// tdf#122563 skip in the case of empty path
+!rAttribs.getString(XML_path, "").isEmpty())
 return new ShapeContext( rParent, rShapes.createShape< 
BezierShape >(), rAttribs );
 else
 return new ShapeContext( rParent, rShapes.createShape< 
ComplexShape >(), rAttribs );
diff --git a/sw/qa/extras/ooxmlexport/data/tdf122563.docx 
b/sw/qa/extras/ooxmlexport/data/tdf122563.docx
new file mode 100644
index ..69168a382623
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf122563.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 3e90ed1b4d9d..a91fe0c3b67b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -936,6 +936,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf99631, "tdf99631.docx")
 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:object[1]", 
"dyaOrig", "768");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf122563, "tdf122563.docx")
+{
+xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+if (!pXmlDoc)
+return;
+assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object", 1);
+// Size of the embedded OLE spreadsheet was the bad 
"width:28.35pt;height:28.35pt"
+assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/w:object/v:shape", 
"style",
+"width:255.75pt;height:63.75pt");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-12-18 Thread Libreoffice Gerrit user
 oox/source/drawingml/textcharacterpropertiescontext.cxx |   11 +
 sw/qa/extras/ooxmlimport/data/tdf121804.docx|binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx   |   18 
 3 files changed, 29 insertions(+)

New commits:
commit dafbc86037d63e938967c0f501bdfe3ae19fa992
Author: Miklos Vajna 
AuthorDate: Mon Dec 17 21:13:00 2018 +0100
Commit: Miklos Vajna 
CommitDate: Tue Dec 18 09:08:16 2018 +0100

tdf#121804 DOCX import: handle sub/superscript inside group shapes

Regression from commit d5c934d150cb6cea5f96cbbee4fb5e8312bf027e
(n#792778 DOCX import: parse group shapes in oox only, 2012-12-14),
where where manual wordprocessingML -> drawingML translation did not
handle this character property.

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

diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx 
b/oox/source/drawingml/textcharacterpropertiescontext.cxx
index 2b63f9f5237b..236219d844cf 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -205,6 +205,17 @@ ContextHandlerRef 
TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
 mrTextCharacterProperties.moCaseMap = XML_none;
 }
 break;
+case W_TOKEN(vertAlign):
+{
+// Map wordprocessingML  to drawingML
+// .
+sal_Int32 nVal = rAttribs.getToken(W_TOKEN(val), 0);
+if (nVal == XML_superscript)
+mrTextCharacterProperties.moBaseline = 3;
+else if (nVal == XML_subscript)
+mrTextCharacterProperties.moBaseline = -25000;
+break;
+}
 case OOX_TOKEN(w14, glow):
 case OOX_TOKEN(w14, shadow):
 case OOX_TOKEN(w14, reflection):
diff --git a/sw/qa/extras/ooxmlimport/data/tdf121804.docx 
b/sw/qa/extras/ooxmlimport/data/tdf121804.docx
new file mode 100644
index ..af3f0d247952
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf121804.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index fea9c91dfced..347fa0c96aeb 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -222,6 +222,24 @@ DECLARE_OOXMLIMPORT_TEST(testTdf113946, "tdf113946.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("1695"), aTop);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf121804, "tdf121804.docx")
+{
+uno::Reference xGroup(getShape(1), 
uno::UNO_QUERY);
+uno::Reference xShape(xGroup->getByIndex(0), 
uno::UNO_QUERY);
+uno::Reference xFirstPara = getParagraphOfText(1, 
xShape->getText());
+uno::Reference xFirstRun = getRun(xFirstPara, 1);
+CPPUNIT_ASSERT_EQUAL(static_cast(0),
+ getProperty(xFirstRun, "CharEscapement"));
+// This failed with a NoSuchElementException, super/subscript property was
+// lost on import, so the whole paragraph was a single run.
+uno::Reference xSecondRun = getRun(xFirstPara, 2);
+CPPUNIT_ASSERT_EQUAL(static_cast(30),
+ getProperty(xSecondRun, "CharEscapement"));
+uno::Reference xThirdRun = getRun(xFirstPara, 3);
+CPPUNIT_ASSERT_EQUAL(static_cast(-25),
+ getProperty(xThirdRun, "CharEscapement"));
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf114217, "tdf114217.docx")
 {
 uno::Reference xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-11-30 Thread Libreoffice Gerrit user
 oox/source/export/drawingml.cxx|   25 
+++---
 sw/qa/extras/ooxmlexport/data/Chart_Plot_BorderLine_Style.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx |   14 +
 3 files changed, 32 insertions(+), 7 deletions(-)

New commits:
commit 5bdc78f65da36d65e94de1e2dde5659f0563f08f
Author: Adam Kovacs 
AuthorDate: Thu Nov 15 13:36:45 2018 +0100
Commit: László Németh 
CommitDate: Fri Nov 30 09:07:15 2018 +0100

tdf#121435 OOXML export: fixing linestyle export in charts

Fixing linestyle export of chart wall (plot area) and chart page.

Change-Id: Id5265110352d393d9c3e01ff55cea0770d4e0cef
Reviewed-on: https://gerrit.libreoffice.org/63418
Tested-by: Jenkins
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 58164ba4065a..a797adbc1f1e 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -671,15 +671,26 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 aAny >>= aLineDash;
 }
 }
-bDashSet = true;
-if (aLineDash.Style == DashStyle_ROUND || aLineDash.Style == 
DashStyle_ROUNDRELATIVE)
-{
-cap = "rnd";
+}
+else
+{
+//export the linestyle of chart wall (plot area) and chart page
+OUString aLineDashName;
+GET(aLineDashName, LineDashName);
+if (!aLineDashName.isEmpty() && xModel) {
+css::uno::Any aAny = getLineDash(xModel, aLineDashName);
+aAny >>= aLineDash;
 }
-
-SAL_INFO("oox.shape", "dash dots: " << aLineDash.Dots << " 
dashes: " << aLineDash.Dashes
-<< " dotlen: " << aLineDash.DotLen << " dashlen: " << 
aLineDash.DashLen <<  " distance: " <<  aLineDash.Distance);
 }
+bDashSet = true;
+if (aLineDash.Style == DashStyle_ROUND || aLineDash.Style == 
DashStyle_ROUNDRELATIVE)
+{
+cap = "rnd";
+}
+
+SAL_INFO("oox.shape", "dash dots: " << aLineDash.Dots << " dashes: 
" << aLineDash.Dashes
+<< " dotlen: " << aLineDash.DotLen << " dashlen: " << 
aLineDash.DashLen << " distance: " <<  aLineDash.Distance);
+
 SAL_FALLTHROUGH;
 case drawing::LineStyle_SOLID:
 default:
diff --git a/sw/qa/extras/ooxmlexport/data/Chart_Plot_BorderLine_Style.docx 
b/sw/qa/extras/ooxmlexport/data/Chart_Plot_BorderLine_Style.docx
new file mode 100755
index ..d1f0f97f1063
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/Chart_Plot_BorderLine_Style.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index c7e6bac3a8ea..d7fd52d87b6d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -747,6 +747,20 @@ DECLARE_OOXMLEXPORT_TEST(testChart_BorderLine_Style, 
"Chart_BorderLine_Style.doc
 assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:spPr/a:ln/a:prstDash", 
"val", "dash");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testChart_Plot_BorderLine_Style, 
"Chart_Plot_BorderLine_Style.docx")
+{
+/* DOCX containing Chart wall (plot area) and Chart Page with BorderLine 
Style as Dash Type
+ * should get preserved inside an XML tag  with value "dash", 
"sysDot, "lgDot", etc.
+ */
+xmlDocPtr pXmlDoc = parseExport("word/charts/chart1.xml");
+if (!pXmlDoc)
+return;
+
+assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:spPr/a:ln/a:prstDash", "val", "lgDashDot");
+assertXPath(pXmlDoc, "/c:chartSpace/c:spPr/a:ln/a:prstDash", "val", 
"sysDash");
+
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedEmptyParagraph, 
"testTrackChangesDeletedEmptyParagraph.docx")
 {
 xmlDocPtr pXmlDoc = parseExport("word/document.xml");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-11-14 Thread Libreoffice Gerrit user
 oox/source/vml/vmlformatting.cxx  |   11 +--
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit ac43eb0fc9e19178257b601ba12b196625d696fe
Author: Stephan Bergmann 
AuthorDate: Wed Nov 14 08:28:51 2018 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Nov 14 10:02:40 2018 +0100

Map VML shadow more properly to css::table::ShadowFormat

For one, CppunitTest_sw_ooxmlexport6 failed under
-fsanitize=implicit-signed-integer-truncation when passing a negative
ShadowFormat.ShadowWidth into a sal_uInt16 SvxShadowItem (see below).

Fixing the mapping from VML shadow to ShadowFormat in
ShadowModel::pushToPropMap caused ShadowModel::pushToPropMap to fail again,
however, testing against 57811035 in testOuterShdw
(sw/qa/extras/ooxmlexport/ooxmlexport6.cxx).
fa9d574ae1656b64670fbbac64ddd85461698149 "Code changes for fdo#74107:File
Corruption - Issue with outerShdw" doesn't explain how that value came 
about, so
assume that it was just whatever value happened to be observed in LO at that
time, and now adjust it accordingly.  And, for another, opening
sw/qa/extras/ooxmlexport/data/testOuterShdw.docx in LO now produces a green 
bar
with red shadow at the top of the first page that better resembles the 
original.

> editeng/source/items/frmitems.cxx:1154:18: runtime error: implicit 
conversion from type 'long' of value -1160 (64-bit, signed) to type 
'sal_uInt16' (aka 'unsigned short') changed the value to 64376 (16-bit, 
unsigned)
>  #0 in SvxShadowItem::PutValue(com::sun::star::uno::Any const&, unsigned 
char) at editeng/source/items/frmitems.cxx:1154:18 
(instdir/program/libeditenglo.so +0x16716ea)
>  #1 in BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet&, 
SfxItemSet const&, bool&) at sw/source/core/unocore/unoframe.cxx:759:48 
(instdir/program/libswlo.so +0xba32230)
>  #2 in SwFrameProperties_Impl::AnyToItemSet(SwDoc*, SfxItemSet&, 
SfxItemSet&, bool&) at sw/source/core/unocore/unoframe.cxx:1004:19 
(instdir/program/libswlo.so +0xba3cbb9)
>  #3 in 
SwXFrame::attachToRange(com::sun::star::uno::Reference
 const&) at sw/source/core/unocore/unoframe.cxx:2665:20 
(instdir/program/libswlo.so +0xba78d71)
>  #4 in 
SwXFrame::attach(com::sun::star::uno::Reference
 const&) at sw/source/core/unocore/unoframe.cxx:3003:9 
(instdir/program/libswlo.so +0xba877fa)
>  #5 in 
SwXTextFrame::attach(com::sun::star::uno::Reference
 const&) at sw/source/core/unocore/unoframe.cxx:3242:15 
(instdir/program/libswlo.so +0xba926a2)
>  #6 in 
SwXText::insertTextContent(com::sun::star::uno::Reference
 const&, com::sun::star::uno::Reference 
const&, unsigned char) at sw/source/core/unocore/unotext.cxx:619:15 
(instdir/program/libswlo.so +0xc2dc17f)
>  #7 in 
writerfilter::dmapper::DomainMapper_Impl::PushShapeContext(com::sun::star::uno::Reference
 const&) at writerfilter/source/dmapper/DomainMapper_Impl.cxx:2330:30 
(instdir/program/libwriterfilterlo.so +0x14d2953)
>  #8 in 
writerfilter::dmapper::DomainMapper::lcl_startShape(com::sun::star::uno::Reference
 const&) at writerfilter/source/dmapper/DomainMapper.cxx:2964:18 
(instdir/program/libwriterfilterlo.so +0x132c46f)
>  #9 in 
writerfilter::LoggedStream::startShape(com::sun::star::uno::Reference
 const&) at writerfilter/source/dmapper/LoggedResources.cxx:151:5 
(instdir/program/libwriterfilterlo.so +0x1763e70)
>  #10 in writerfilter::ooxml::OOXMLFastContextHandlerShape::sendShape(int) 
at writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:1678:27 
(instdir/program/libwriterfilterlo.so +0x1ad7fba)
>  #11 in 
writerfilter::ooxml::OOXMLFastContextHandlerWrapper::lcl_createFastChildContext(int,
 com::sun::star::uno::Reference 
const&) at writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:1917:63 
(instdir/program/libwriterfilterlo.so +0x1ae026e)
>  #12 in 
writerfilter::ooxml::OOXMLFastContextHandler::createFastChildContext(int, 
com::sun::star::uno::Reference 
const&) at writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:208:21 
(instdir/program/libwriterfilterlo.so +0x1aa90d7)
>  #13 in non-virtual thunk to 
writerfilter::ooxml::OOXMLFastContextHandler::createFastChildContext(int, 
com::sun::star::uno::Reference 
const&) at writerfilter/source/ooxml/OOXMLFastContextHandler.cxx 
(instdir/program/libwriterfilterlo.so +0x1aa9378)
>  #14 in (anonymous namespace)::Entity::startElement((anonymous 
namespace)::Event const*) at sax/source/fastparser/fastparser.cxx:439:44 
(instdir/program/libexpwraplo.so +0x24df4c)
>  #15 in sax_fastparser::FastSaxParserImpl::callbackStartElement(unsigned 
char const*, unsigned char const*, unsigned char const*, int, unsigned char 
const**, int, unsigned char const**) at 
sax/source/fastparser/fastparser.cxx:1254:21 (instdir/program/libexpwraplo.so 
+0x249499)
>  #16 in (anonymous namespace)::call_callbackStartElement(void*, 

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

2018-10-25 Thread Libreoffice Gerrit user
 oox/source/export/drawingml.cxx   |   30 +++---
 sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx |binary
 2 files changed, 6 insertions(+), 24 deletions(-)

New commits:
commit ba60a132e788201d4074c576352b4f462c16a9c6
Author: Adam Kovacs 
AuthorDate: Sat Oct 13 07:06:47 2018 -0400
Commit: László Németh 
CommitDate: Thu Oct 25 08:59:51 2018 +0200

tdf#108064 OOXML export: keep preset dashes with linewidth < 1pt

Before this patch prstDash xml tags were preserved only with linewidth 1/4 
pt, 1/2 pt or 3/4 pt below 1 pt. Now it is working for example with 0.33 pt.

Change-Id: I36372edfaea560d8913cd4aa8ee551ee059ec682
Reviewed-on: https://gerrit.libreoffice.org/61737
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8d68fce8072e..5968cd9dd67c 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -661,6 +661,7 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 if (GetProperty(rXPropSet, "LineDash"))
 {
 aLineDash = mAny.get();
+//this query is good for shapes, but in the case of charts it 
returns 0 values
 if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 0) {
 OUString aLineDashName;
 GET(aLineDashName, LineDashName);
@@ -733,31 +734,12 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 int relDotLen = nLineWidth ? aLineDash.DotLen / nLineWidth : 0;
 int relDashLen = nLineWidth ? aLineDash.DashLen / nLineWidth : 0;
 int relDistance = nLineWidth ? aLineDash.Distance / nLineWidth : 0;
-// fixing relative values in the case of mso preset linewidths
-//todo: fix relDotLen, relDashLen and relDistance in every case of 0-1 
linewidth
-switch (nLineWidth)
+// fixing relative values in the case of linewidths smaller than 1 pt
+if (0 < nLineWidth && nLineWidth < 35) //35 HMM == 1 pt
 {
-case 9: // 1/4 pt
-{
-relDotLen = relDotLen ? (relDotLen + 1) / 4 : 0;
-relDashLen = relDashLen ? (relDashLen + 1) / 4 : 0;
-relDistance = relDistance ? (relDistance + 1) / 4 : 0;
-break;
-}
-case 18: // 1/2 pt
-{
-relDotLen = relDotLen ? (relDotLen + 1) / 2 : 0;
-relDashLen = relDashLen ? (relDashLen + 1) / 2 : 0;
-relDistance = relDistance ? (relDistance + 1) / 2 : 0;
-break;
-}
-case 26: // 3/4 pt
-{
-relDotLen = relDotLen ? (relDotLen + 1) * 3 / 4 : 0;
-relDashLen = relDashLen ? (relDashLen + 1) * 3 / 4 : 0;
-relDistance = relDistance ? (relDistance + 1) *3 / 4 : 0;
-break;
-}
+relDotLen = relDotLen ? (relDotLen + 1) * (nLineWidth * 360.0 / 
12700) : 0;
+relDashLen = relDashLen ? (relDashLen + 1) * (nLineWidth * 360.0 / 
12700) : 0;
+relDistance = relDistance ? (relDistance + 1) * (nLineWidth * 
360.0 / 12700) : 0;
 }
 // keep default mso preset linestyles (instead of custdash)
 if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 0 && 
relDashLen == 0 && relDistance == 3)
diff --git a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx 
b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx
index f9a0e11d78e2..b8eceb92de90 100644
Binary files a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx and 
b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx differ
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-10-08 Thread Libreoffice Gerrit user
 oox/source/export/drawingml.cxx|   29 +
 sw/qa/extras/ooxmlexport/data/lo_preset_dashes.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx |   15 ++
 3 files changed, 44 insertions(+)

New commits:
commit 47c3b0390e5ad5a894488c47f014cdd7ecba7d2e
Author: Adam Kovacs 
AuthorDate: Fri Oct 5 08:24:08 2018 -0400
Commit: László Németh 
CommitDate: Mon Oct 8 16:34:31 2018 +0200

tdf#108064 OOXML export: convert LO preset dashes to equivalent MSO presets

Change-Id: I967dfdc6a49cf04d98ea9fa9b57bf4669126a585
Reviewed-on: https://gerrit.libreoffice.org/61417
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 2f67b1fe7420..4eef5ecd2ff1 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -801,6 +801,35 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 {
 mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, 
"sysDashDotDot", FSEND);
 }
+/*convert some LO preset dashes to MSO preset dashes for oox 
interoperability
+LO preset dashes which don't have equivalent in MSO preset dashes: 2 
Dots 3 Dashes, Line with Fine Dots, 3 Dashes 3 Dots*/
+//ultrafine Dashed, Ultrafine Dotted -> sysDot
+else if ((aLineDash.Dots == 1 && aLineDash.DotLen == 51 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 51 && aLineDash.Distance == 51) ||
+ (aLineDash.Dots == 1 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 50))
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDot", 
FSEND);
+}
+//Fine Dashed -> dash
+else if (aLineDash.Dots == 1 && aLineDash.DotLen == 197 && 
aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 197)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dash", FSEND);
+}
+//Fine Dotted -> dot
+else if (aLineDash.Dots == 1 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 457)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dot", FSEND);
+}
+//Line Style 9, Dashed -> sysDash
+else if ((aLineDash.Dots == 1 && aLineDash.DotLen == 197 && 
aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 120) ||
+ (aLineDash.Dots == 1 && aLineDash.DotLen == 197 && 
aLineDash.Dashes == 0 && aLineDash.DashLen == 0  && aLineDash.Distance == 127))
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDash", 
FSEND);
+}
+//2 Dots 1 Dash -> sysDashDotDot
+else if (aLineDash.Dots == 2 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 203 && aLineDash.Distance == 203)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, 
"sysDashDotDot", FSEND);
+}
 else
 {
 mpFS->startElementNS( XML_a, XML_custDash, FSEND );
diff --git a/sw/qa/extras/ooxmlexport/data/lo_preset_dashes.odt 
b/sw/qa/extras/ooxmlexport/data/lo_preset_dashes.odt
new file mode 100755
index ..b9b8a79d46da
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/lo_preset_dashes.odt 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 812ff0c09f45..dd9a6c8ceb12 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -783,6 +783,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf64264, "tdf64264.docx")
  
parseDump("/root/page[2]/body/tab/row[2]/cell[1]/txt/text()"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testLOPresetDashesConvert, "lo_preset_dashes.odt")
+{
+// File asserting while saving in LO.
+xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+if (!pXmlDoc)
+return;
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash",
 "val", "sysDot");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash",
 "val", "sysDash");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash",
 "val", "sysDot");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash",
 "val", "dot");
+assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash",
 "val", "dash");
+

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

2018-10-03 Thread Libreoffice Gerrit user
 oox/source/export/drawingml.cxx   |   32 --
 sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx |binary
 2 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit d5cc52fec12e3c8d1c3561f172d3e1c5434290b3
Author: Adam Kovacs 
AuthorDate: Fri Sep 21 08:45:24 2018 -0400
Commit: László Németh 
CommitDate: Wed Oct 3 11:26:31 2018 +0200

tdf#108064 OOXML export: keep preset dashes with mso preset linewidths

Change-Id: Ie87544850c494d946ea43b984aeff8666e08d738
Reviewed-on: https://gerrit.libreoffice.org/60874
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 5824f51e19b6..2f67b1fe7420 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -731,9 +731,35 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 if( bDashSet && aStyleLineStyle != drawing::LineStyle_DASH )
 {
 // convert absolute dash/dot length to relative length
-int relDotLen = nLineWidth ? aLineDash.DotLen / nLineWidth : -1;
-int relDashLen = nLineWidth ? aLineDash.DashLen / nLineWidth : -1;
-int relDistance = nLineWidth ? aLineDash.Distance / nLineWidth : -1;
+int relDotLen = nLineWidth ? aLineDash.DotLen / nLineWidth : 0;
+int relDashLen = nLineWidth ? aLineDash.DashLen / nLineWidth : 0;
+int relDistance = nLineWidth ? aLineDash.Distance / nLineWidth : 0;
+// fixing relative values in the case of mso preset linewidths
+//todo: fix relDotLen, relDashLen and relDistance in every case of 0-1 
linewidth
+switch (nLineWidth)
+{
+case 9: // 1/4 pt
+{
+relDotLen = relDotLen ? (relDotLen + 1) / 4 : 0;
+relDashLen = relDashLen ? (relDashLen + 1) / 4 : 0;
+relDistance = relDistance ? (relDistance + 1) / 4 : 0;
+break;
+}
+case 18: // 1/2 pt
+{
+relDotLen = relDotLen ? (relDotLen + 1) / 2 : 0;
+relDashLen = relDashLen ? (relDashLen + 1) / 2 : 0;
+relDistance = relDistance ? (relDistance + 1) / 2 : 0;
+break;
+}
+case 26: // 3/4 pt
+{
+relDotLen = relDotLen ? (relDotLen + 1) * 3 / 4 : 0;
+relDashLen = relDashLen ? (relDashLen + 1) * 3 / 4 : 0;
+relDistance = relDistance ? (relDistance + 1) *3 / 4 : 0;
+break;
+}
+}
 // keep default mso preset linestyles (instead of custdash)
 if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 0 && 
relDashLen == 0 && relDistance == 3)
 {
diff --git a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx 
b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx
index 11b5788317c1..f9a0e11d78e2 100644
Binary files a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx and 
b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx differ
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-09-10 Thread Libreoffice Gerrit user
 oox/source/export/drawingml.cxx   |   
40 +++---
 sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx 
|binary
 sw/qa/extras/ooxmlexport/data/dashed_line_custdash_1000th_of_percent.docx 
|binary
 sw/qa/extras/ooxmlexport/data/dashed_line_custdash_percentage.docx
|binary
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |
2 
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx |   
29 ---
 6 files changed, 32 insertions(+), 39 deletions(-)

New commits:
commit f3d6c44c9cb533fe4f1cd28fc95adc36cac4bfd5
Author: Adam Kovacs 
AuthorDate: Mon Sep 3 11:05:44 2018 -0400
Commit: László Németh 
CommitDate: Mon Sep 10 08:50:43 2018 +0200

tdf#108064 OOXML export: keep preset dashes with any line width

Change-Id: I496e1cbac527383837a4e8fcdee42967ecf555e4
Reviewed-on: https://gerrit.libreoffice.org/59968
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index c42a74a95267..eb3eb27c85d9 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -700,35 +700,51 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet )
 
 if( bDashSet && aStyleLineStyle != drawing::LineStyle_DASH )
 {
-// keep default preset linestyles (instead of custdash)
-if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes 
== 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 141)
+// convert absolute dash/dot length to relative length
+int relDotLen = aLineDash.DotLen / nLineWidth;
+int relDashLen = aLineDash.DashLen / nLineWidth;
+int relDistance = aLineDash.Distance / nLineWidth;
+// keep default mso preset linestyles (instead of custdash)
+if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 0 && 
relDashLen == 0 && relDistance == 3)
 {
-mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDot", 
FSEND);
-}
-else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 423 && aLineDash.Distance == 141)
-{
-mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDash", 
FSEND);
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dot", FSEND);
 }
-else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423)
+else if (aLineDash.Dots == 0 && relDotLen == 0 && aLineDash.Dashes == 
1 && relDashLen == 4 && relDistance == 3)
 {
 mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dash", FSEND);
 }
-else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423)
+else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 
1 && relDashLen == 4 && relDistance == 3)
 {
 mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dashDot", 
FSEND);
 }
-else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423)
+else if (aLineDash.Dots == 0 && relDotLen == 0 && aLineDash.Dashes == 
1 && relDashLen == 8 && relDistance == 3)
 {
 mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDash", 
FSEND);
 }
-else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423)
+else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 
1 && relDashLen == 8 && relDistance == 3)
 {
 mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDot", 
FSEND);
 }
-else if (aLineDash.Dots == 2 && aLineDash.DotLen == 141 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423)
+else if (aLineDash.Dots == 2 && relDotLen == 1 && aLineDash.Dashes == 
1 && relDashLen == 8 && relDistance == 3)
 {
 mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, 
"lgDashDotDot", FSEND);
 }
+else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 
0 && relDashLen == 0 && relDistance == 1)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDot", 
FSEND);
+}
+else if (aLineDash.Dots == 0 && relDotLen == 0 && aLineDash.Dashes == 
1 && relDashLen == 3 && relDistance == 1)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDash", 
FSEND);
+}
+else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 
1 && relDashLen == 3 && relDistance == 1)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDashDot", 

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

2018-08-30 Thread Libreoffice Gerrit user
 oox/source/vml/vmlshapecontext.cxx|2 +-
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |4 
 2 files changed, 5 insertions(+), 1 deletion(-)

New commits:
commit b914c4c98bfca32168ff05fec7cc687c95754d36
Author: Justin Luth 
AuthorDate: Wed Aug 22 20:57:19 2018 +0300
Commit: Miklos Vajna 
CommitDate: Thu Aug 30 15:39:25 2018 +0200

tdf#115670 vml shadow: shadow is off unless explicitly set on

The absence of "on=" is treated in Word (tested 2003) as off.

Change-Id: Ibc6b0e5ca0f25a9c3ca1b9505fa24c4d821bfd0
Reviewed-on: https://gerrit.libreoffice.org/59457
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index d1237eb8615d..efeb188a42b5 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -389,7 +389,7 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( 
sal_Int32 nElement, const A
 case VML_TOKEN( shadow ):
 {
 mrTypeModel.maShadowModel.mbHasShadow = true;
-
mrTypeModel.maShadowModel.moShadowOn.assignIfUsed(lclDecodeBool(rAttribs, 
XML_on));
+mrTypeModel.maShadowModel.moShadowOn = lclDecodeBool(rAttribs, 
XML_on).get(false);
 
mrTypeModel.maShadowModel.moColor.assignIfUsed(rAttribs.getString(XML_color));
 
mrTypeModel.maShadowModel.moOffset.assignIfUsed(rAttribs.getString(XML_offset));
 mrTypeModel.maShadowModel.moOpacity = lclDecodePercent(rAttribs, 
XML_opacity, 1.0);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 51287c7035cd..ed841f245459 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -580,6 +580,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103982, "tdf103982.docx")
 sal_Int32 nDistB = getXPath(pXmlDoc, "//wp:anchor", "distB").toInt32();
 // This was -260350, which is not a valid value for an unsigned type.
 CPPUNIT_ASSERT(nDistB >= 0);
+
+// tdf#115670 the shadow should not be enabled (no on="t")
+uno::Reference xPropertySet(getShape(1), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(!getProperty(xPropertySet, "Shadow"));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf104115, "tdf104115.docx")
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-08-24 Thread Libreoffice Gerrit user
 oox/source/drawingml/lineproperties.cxx  |   86 +--
 oox/source/export/drawingml.cxx  |   11 +-
 sw/qa/extras/ooxmlexport/data/tdf73547-dash.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |   11 ++
 4 files changed, 52 insertions(+), 56 deletions(-)

New commits:
commit 34dff8df7b9fc46fed6e6ffbaa8b6847ad6ed1b1
Author: Mark Hung 
AuthorDate: Sun Aug 19 23:49:26 2018 +0800
Commit: Mark Hung 
CommitDate: Fri Aug 24 15:07:14 2018 +0200

tdf#73547 fix ooxml export / import custom dashes.

Fix import logic as well as arithmatic precion of both import
and export.

Change-Id: I97e9bde847e0a2425421af2f2175d4d0b7af0cab
Reviewed-on: https://gerrit.libreoffice.org/59306
Tested-by: Jenkins
Reviewed-by: Mark Hung 

diff --git a/oox/source/drawingml/lineproperties.cxx 
b/oox/source/drawingml/lineproperties.cxx
index 25bbbcd25f1e..2b5de7a1f8c0 100644
--- a/oox/source/drawingml/lineproperties.cxx
+++ b/oox/source/drawingml/lineproperties.cxx
@@ -55,11 +55,8 @@ void lclSetDashData( LineDash& orLineDash, sal_Int16 nDots, 
sal_Int32 nDotLen,
 }
 
 /** Converts the specified preset dash to API dash.
-
-Line length and dot length are set relative to line width and have to be
-multiplied by the actual line width after this function.
  */
-void lclConvertPresetDash( LineDash& orLineDash, sal_Int32 nPresetDash )
+void lclConvertPresetDash(LineDash& orLineDash, sal_Int32 nPresetDash, 
sal_Int32 nLineWidth)
 {
 switch( nPresetDash )
 {
@@ -80,54 +77,41 @@ void lclConvertPresetDash( LineDash& orLineDash, sal_Int32 
nPresetDash )
 OSL_FAIL( "lclConvertPresetDash - unsupported preset dash" );
 lclSetDashData( orLineDash, 0, 0, 1, 4, 3 );
 }
+// convert relative dash/dot length to absolute length
+orLineDash.DotLen *= nLineWidth;
+orLineDash.DashLen *= nLineWidth;
+orLineDash.Distance *= nLineWidth;
 }
 
-/** Converts the passed custom dash to API dash.
-
-Line length and dot length are set relative to line width and have to be
-multiplied by the actual line width after this function.
+/** Converts the passed custom dash to API dash. rCustomDash should not be 
empty.
  */
-void lclConvertCustomDash( LineDash& orLineDash, const 
LineProperties::DashStopVector& rCustomDash )
+void lclConvertCustomDash(LineDash& orLineDash, const 
LineProperties::DashStopVector& rCustomDash, sal_Int32 nLineWidth)
 {
-if( rCustomDash.empty() )
+OSL_ASSERT(!rCustomDash.empty());
+orLineDash.Dashes = 0;
+// Follow the order we export custDash: dashes first.
+orLineDash.DashLen = rCustomDash[0].first;
+// Also assume dash and dot have the same sp values.
+orLineDash.Distance = rCustomDash[0].second;
+orLineDash.DotLen = 0;
+
+for(const auto& rIt : rCustomDash)
 {
-OSL_FAIL( "lclConvertCustomDash - unexpected empty custom dash" );
-lclSetDashData( orLineDash, 0, 0, 1, 4, 3 );
-return;
-}
-
-// count dashes and dots (stops equal or less than 2 are assumed to be 
dots)
-sal_Int16 nDots = 0;
-sal_Int32 nDotLen = 0;
-sal_Int16 nDashes = 0;
-sal_Int32 nDashLen = 0;
-sal_Int32 nDistance = 0;
-sal_Int32 nConvertedLen = 0;
-sal_Int32 nConvertedDistance = 0;
-for( LineProperties::DashStopVector::const_iterator aIt = 
rCustomDash.begin(), aEnd = rCustomDash.end(); aIt != aEnd; ++aIt )
-{
-// Get from "1000th of percent" ==> percent ==> multiplier
-nConvertedLen  = aIt->first  / 1000 / 100;
-nConvertedDistance = aIt->second / 1000 / 100;
-
-// Check if it is a dot (100% = dot)
-if( nConvertedLen == 1 )
-{
-++nDots;
-nDotLen += nConvertedLen;
-}
-else
+sal_Int32 nLen = rIt.first;
+if (nLen != orLineDash.DashLen)
 {
-++nDashes;
-nDashLen += nConvertedLen;
+orLineDash.DotLen = nLen;
+break;
 }
-nDistance += nConvertedDistance;
+++orLineDash.Dashes;
 }
-orLineDash.DotLen = (nDots > 0) ? ::std::max< sal_Int32 >( nDotLen / 
nDots, 1 ) : 0;
-orLineDash.Dots = nDots;
-orLineDash.DashLen = (nDashes > 0) ? ::std::max< sal_Int32 >( nDashLen / 
nDashes, 1 ) : 0;
-orLineDash.Dashes = nDashes;
-orLineDash.Distance = ::std::max< sal_Int32 >( nDistance / 
rCustomDash.size(), 1 );
+// TODO: verify the assumption and approximate complex line patterns.
+
+// Assume we only have two types of dash stops, the rest are all dots.
+orLineDash.Dots = rCustomDash.size() - orLineDash.Dashes;
+orLineDash.DashLen = orLineDash.DashLen / 10.0 * nLineWidth;
+orLineDash.DotLen = orLineDash.DotLen / 10.0 * nLineWidth;
+orLineDash.Distance = orLineDash.Distance / 10.0 * nLineWidth;
 }
 
 DashStyle lclGetDashStyle( sal_Int32 nToken )
@@ -386,16 +370,14 @@ void 

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

2018-08-17 Thread Libreoffice Gerrit user
 oox/source/export/drawingml.cxx   |   34 ++
 sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |   10 -
 3 files changed, 35 insertions(+), 9 deletions(-)

New commits:
commit f5f235051055d24c8aced602078c54261603efea
Author: Adam Kovacs 
AuthorDate: Thu Aug 16 09:32:17 2018 -0400
Commit: László Németh 
CommitDate: Fri Aug 17 09:37:05 2018 +0200

tdf108064 OOXML export: keep preset dashes in shape outlines

Extending commit d7551e32609d0e0de8ac419576ca42d65c5015be
to all default MSO 2016 preset dashes:

Saving an ooxml file with LibreOffice now preserves the
prstDash tags with the values sysDot, sysDash, dash, dashDot,
lgDash, lgDashDot, lgDashDotDot, instead of converting them
to custDash tags.

Note: the import of the preset dash outlines are still not
relative to the line width, in spite of their original
behaviour in MSO.

Change-Id: I65eaf06952a968019495664067010c874fce1352
Reviewed-on: https://gerrit.libreoffice.org/59203
Tested-by: Jenkins
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index b19042e1c140..6536798be85b 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -700,14 +700,34 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet )
 
 if( bDashSet && aStyleLineStyle != drawing::LineStyle_DASH )
 {
-// line style is a dash and it was not set by the shape style
-
-if (aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && 
aLineDash.Distance == 423)
+// keep default preset linestyles (instead of custdash)
+if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes 
== 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 141)
 {
-// That's exactly the predefined "dash" value.
-mpFS->singleElementNS(XML_a, XML_prstDash,
-  XML_val, "dash",
-  FSEND);
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDot", 
FSEND);
+}
+else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 423 && aLineDash.Distance == 141)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDash", 
FSEND);
+}
+else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dash", FSEND);
+}
+else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dashDot", 
FSEND);
+}
+else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDash", 
FSEND);
+}
+else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDot", 
FSEND);
+}
+else if (aLineDash.Dots == 2 && aLineDash.DotLen == 141 && 
aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423)
+{
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, 
"lgDashDotDot", FSEND);
 }
 else
 {
diff --git a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx 
b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx
index 9256c3ec7a4e..d7997ddc63c6 100644
Binary files a/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx and 
b/sw/qa/extras/ooxmlexport/data/LineStyle_DashType.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index 3a20b765f934..a41dd05501f4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -840,13 +840,19 @@ DECLARE_OOXMLEXPORT_TEST(testAlignForShape,"Shape.docx")
 DECLARE_OOXMLEXPORT_TEST(testLineStyle_DashType, "LineStyle_DashType.docx")
 {
 /* DOCX contatining Shape with LineStyle as Dash Type should get preserved 
inside
- * an XMl tag  with value "dash".
+ * an XMl tag  with value "dash", "sysDot", "lgDot", etc.
  */
 xmlDocPtr pXmlDoc = parseExport("word/document.xml");
 if (!pXmlDoc)
 return;
 
-assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash",
 "val", "dash");
+

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

2018-06-26 Thread Miklos Vajna
 oox/source/helper/graphichelper.cxx|8 +++-
 sw/qa/extras/ww8export/data/tdf118133.docx |binary
 sw/qa/extras/ww8export/ww8export2.cxx  |7 +++
 3 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit fa356008b08a8a5b5556aa8f89ca8f7989c53516
Author: Miklos Vajna 
Date:   Mon Jun 25 22:13:24 2018 +0200

tdf#118133 DOCX import: disable lazy-loading of tiff images

The same code that works for jpeg/png doesn't work for tiff, go back to
synchronous loading there for now.

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

diff --git a/oox/source/helper/graphichelper.cxx 
b/oox/source/helper/graphichelper.cxx
index 073cfe6d694f..6500f82e9a44 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -242,7 +242,8 @@ Reference< XGraphic > GraphicHelper::importGraphic( const 
Reference< XInputStrea
 aArgs[ 0 ].Name = "InputStream";
 aArgs[ 0 ].Value <<= rxInStrm;
 aArgs[ 1 ].Name = "LazyRead";
-aArgs[ 1 ].Value <<= true;
+bool bLazyRead = !pExtHeader;
+aArgs[ 1 ].Value <<= bLazyRead;
 
 if ( pExtHeader && pExtHeader->mapMode > 0 )
 {
@@ -341,6 +342,11 @@ Reference< XGraphic > 
GraphicHelper::importEmbeddedGraphic( const OUString& rStr
 EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find( 
rStreamName );
 if( aIt == maEmbeddedGraphics.end() )
 {
+// Lazy-loading doesn't work with TIFF at the moment.
+WmfExternal aHeader;
+if (rStreamName.endsWith(".tiff") && !pExtHeader)
+pExtHeader = 
+
 xGraphic = importGraphic(mxStorage->openInputStream(rStreamName), 
pExtHeader);
 if( xGraphic.is() )
 maEmbeddedGraphics[ rStreamName ] = xGraphic;
diff --git a/sw/qa/extras/ww8export/data/tdf118133.docx 
b/sw/qa/extras/ww8export/data/tdf118133.docx
new file mode 100644
index ..613aa1bd73c9
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf118133.docx differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx 
b/sw/qa/extras/ww8export/ww8export2.cxx
index 66b9a02612ef..e4e61cb6a084 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -852,6 +852,13 @@ DECLARE_WW8EXPORT_TEST(testTdf117885, "tdf117885.doc")
 CPPUNIT_ASSERT_EQUAL(nParaA_Top, nParaB_Top);
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf118133, "tdf118133.docx")
+{
+// This was 0, doc import + doc export resulted in lost image due to broken
+// lazy-loading of tiff images.
+CPPUNIT_ASSERT_EQUAL(static_cast(15240), 
getShape(1)->getSize().Width);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-04-20 Thread Miklos Vajna
 oox/source/helper/graphichelper.cxx|   15 +++
 sw/qa/extras/ooxmlimport/data/image-lazy-read.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx   |8 
 vcl/source/filter/graphicfilter2.cxx   |9 -
 vcl/source/gdi/impgraph.cxx|   16 ++--
 vcl/source/graphic/UnoGraphicProvider.cxx  |   19 +--
 6 files changed, 58 insertions(+), 9 deletions(-)

New commits:
commit edda1e5fc8113aa4744e32f97c96a3cc311485ca
Author: Miklos Vajna 
Date:   Fri Apr 20 16:32:00 2018 +0200

DOCX import: lazy-read images without external headers

So that similar to ODT, images are not loaded on file open, only when
the user scrolls there.

Notes:

1) GraphicDescriptor::ImpDetectJPG() would try to calculate the logic
size before the pixel size is available, so the logic size would be 0x0.
Also, ImpGraphic::ImplSetPrepared() would always work with a pixel map
mode. Any of these two would result in a failure of
testDMLShapeFillBitmapCrop in CppunitTest_sw_ooxmlexport6.

2) Lazy-loading seems to (at the moment) not recognize EMF files, so
don't lazy-load in case an external header is provided. This probably
has to be revisited, since the ODF import doesn't go via
GraphicProvider::queryGraphic().

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

diff --git a/oox/source/helper/graphichelper.cxx 
b/oox/source/helper/graphichelper.cxx
index 7f4262de787c..002d54b946b5 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -238,11 +238,13 @@ Reference< XGraphic > GraphicHelper::importGraphic( const 
Reference< XInputStrea
 Reference< XGraphic > xGraphic;
 if( rxInStrm.is() && mxGraphicProvider.is() ) try
 {
-Sequence< PropertyValue > aArgs( 1 );
+Sequence< PropertyValue > aArgs( 2 );
 aArgs[ 0 ].Name = "InputStream";
 aArgs[ 0 ].Value <<= rxInStrm;
+aArgs[ 1 ].Name = "LazyRead";
+aArgs[ 1 ].Value <<= true;
 
-if ( pExtHeader && pExtHeader->mapMode > 0 )
+if ( pExtHeader )
 {
 aArgs.realloc( aArgs.getLength() + 1 );
 Sequence< PropertyValue > aFilterData( 3 );
@@ -252,8 +254,8 @@ Reference< XGraphic > GraphicHelper::importGraphic( const 
Reference< XInputStrea
 aFilterData[ 1 ].Value <<= pExtHeader->yExt;
 aFilterData[ 2 ].Name = "ExternalMapMode";
 aFilterData[ 2 ].Value <<= pExtHeader->mapMode;
-aArgs[ 1 ].Name = "FilterData";
-aArgs[ 1 ].Value <<= aFilterData;
+aArgs[ 2 ].Name = "FilterData";
+aArgs[ 2 ].Value <<= aFilterData;
 }
 
 xGraphic = mxGraphicProvider->queryGraphic( aArgs );
@@ -339,6 +341,11 @@ Reference< XGraphic > 
GraphicHelper::importEmbeddedGraphic( const OUString& rStr
 EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find( 
rStreamName );
 if( aIt == maEmbeddedGraphics.end() )
 {
+// TODO make lazy-load work for EMF as well.
+WmfExternal aHeader;
+if (rStreamName.endsWith(".emf") && !pExtHeader)
+pExtHeader = 
+
 xGraphic = importGraphic(mxStorage->openInputStream(rStreamName), 
pExtHeader);
 if( xGraphic.is() )
 maEmbeddedGraphics[ rStreamName ] = xGraphic;
diff --git a/sw/qa/extras/ooxmlimport/data/image-lazy-read.docx 
b/sw/qa/extras/ooxmlimport/data/image-lazy-read.docx
new file mode 100644
index ..faf80e41dcd6
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/image-lazy-read.docx 
differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 439658a63b39..7b60b191df67 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1422,6 +1422,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108714, "tdf108714.docx")
 CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testImageLazyRead, "image-lazy-read.docx")
+{
+auto xGraphic = 
getProperty(getShape(1), "Graphic");
+Graphic aGraphic(xGraphic);
+// This failed, import loaded the graphic, it wasn't lazy-read.
+CPPUNIT_ASSERT(!aGraphic.isAvailable());
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf108995, "xml_space.docx")
 {
 CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
diff --git a/vcl/source/filter/graphicfilter2.cxx 
b/vcl/source/filter/graphicfilter2.cxx
index f35ac1c37c81..4439c2ab8b50 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -262,6 +262,7 @@ bool GraphicDescriptor::ImpDetectJPG( 

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

2017-12-22 Thread martinb214
 oox/source/export/drawingml.cxx   |   83 +-
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx |6 +-
 2 files changed, 74 insertions(+), 15 deletions(-)

New commits:
commit 7f42b0f96a2798ae99aa65b84b0db3b2af2b282b
Author: martinb214 
Date:   Wed Dec 6 20:58:45 2017 +0100

tdf#111790: Shadow imported from a PPTX file is not overriden

by the settings while saving back to PPTX

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

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 17fc99acbc7f..f0f9bee96125 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3181,18 +3181,36 @@ void DrawingML::WriteShapeEffect( const OUString& 
sName, const Sequence< Propert
 }
 }
 
+sal_Int32 lcl_CalculateDist(const double dX, const double dY)
+{
+return static_cast< sal_Int32 >(sqrt(dX*dX + dY*dY) * 360);
+}
+
+sal_Int32 lcl_CalculateDir(const double dX, const double dY)
+{
+return (static_cast< sal_Int32 >(atan2(dY,dX) * 180 * 6 / M_PI) + 
2160) % 2160;
+}
+
 void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
 {
 if( !GetProperty( rXPropSet, "InteropGrabBag" ) )
 return;
 
-Sequence< PropertyValue > aGrabBag, aEffects;
+Sequence< PropertyValue > aGrabBag, aEffects, aOuterShdwProps;
 mAny >>= aGrabBag;
 for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
 {
 if( aGrabBag[i].Name == "EffectProperties" )
 {
 aGrabBag[i].Value >>= aEffects;
+for( sal_Int32 j=0; j < aEffects.getLength(); ++j )
+{
+if( aEffects[j].Name == "outerShdw" )
+{
+aEffects[j].Value >>= aOuterShdwProps;
+break;
+}
+}
 break;
 }
 }
@@ -3210,9 +3228,9 @@ void DrawingML::WriteShapeEffects( const Reference< 
XPropertySet >& rXPropSet )
 rXPropSet->getPropertyValue( "ShadowYDistance" ) >>= dY;
 
 aShadowAttribsGrabBag[0].Name = "dist";
-aShadowAttribsGrabBag[0].Value <<= static_cast< sal_Int32 
>(sqrt(dX*dX + dY*dY) * 360);
+aShadowAttribsGrabBag[0].Value <<= lcl_CalculateDist(dX, dY);
 aShadowAttribsGrabBag[1].Name = "dir";
-aShadowAttribsGrabBag[1].Value <<= (static_cast< sal_Int32 
>(atan2(dY,dX) * 180 * 6 / M_PI) + 2160) % 2160;
+aShadowAttribsGrabBag[1].Value <<= lcl_CalculateDir(dX, dY);;
 
 aShadowGrabBag[0].Name = "Attribs";
 aShadowGrabBag[0].Value <<= aShadowAttribsGrabBag;
@@ -3225,19 +3243,60 @@ void DrawingML::WriteShapeEffects( const Reference< 
XPropertySet >& rXPropSet )
 WriteShapeEffect( "outerShdw", aShadowGrabBag );
 mpFS->endElementNS(XML_a, XML_effectLst);
 }
-return;
 }
+else
+{
+for( sal_Int32 i=0; i < aOuterShdwProps.getLength(); ++i )
+{
+if( aOuterShdwProps[i].Name == "Attribs" )
+{
+Sequence< PropertyValue > aAttribsProps;
+aOuterShdwProps[i].Value >>= aAttribsProps;
 
-mpFS->startElementNS(XML_a, XML_effectLst, FSEND);
+double dX = +0.0, dY = +0.0;
+rXPropSet->getPropertyValue( "ShadowXDistance" ) >>= dX;
+rXPropSet->getPropertyValue( "ShadowYDistance" ) >>= dY;
 
-for( sal_Int32 i=0; i < aEffects.getLength(); ++i )
-{
-Sequence< PropertyValue > aEffectProps;
-aEffects[i].Value >>= aEffectProps;
-WriteShapeEffect( aEffects[i].Name, aEffectProps );
-}
+for( sal_Int32 j=0; j < aAttribsProps.getLength(); ++j )
+{
+if( aAttribsProps[j].Name == "dist" )
+{
+aAttribsProps[j].Value <<= lcl_CalculateDist(dX, dY);
+}
+else if( aAttribsProps[j].Name == "dir" )
+{
+aAttribsProps[j].Value <<= lcl_CalculateDir(dX, dY);
+}
+}
 
-mpFS->endElementNS(XML_a, XML_effectLst);
+aOuterShdwProps[i].Value <<= aAttribsProps;
+}
+else if( aOuterShdwProps[i].Name == "RgbClr" )
+{
+aOuterShdwProps[i].Value = rXPropSet->getPropertyValue( 
"ShadowColor" );
+}
+else if( aOuterShdwProps[i].Name == "RgbClrTransparency" )
+{
+aOuterShdwProps[i].Value = rXPropSet->getPropertyValue( 
"ShadowTransparence" );
+}
+}
+
+mpFS->startElementNS(XML_a, XML_effectLst, FSEND);
+for( sal_Int32 i=0; i < aEffects.getLength(); 

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

2017-12-16 Thread Justin Luth
 oox/source/vml/vmlshapecontext.cxx|2 ++
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |   11 +++
 2 files changed, 13 insertions(+)

New commits:
commit 610d98bd93e8032b9bfb48dc2ed0cd4d35c23ddd
Author: Justin Luth 
Date:   Mon Sep 18 18:33:13 2017 -0400

tdf#97648 ooxmlimport: horizontal line's horiOrient

Although LO won't visually do anything with this property
(because o:hr is improperly imported AS_CHAR), at least
import and assign the property so that it is there for
the future if o:hr is changed from AS_CHAR to AT_*.

The unit test just adds a test for the existing status - to
highlight what still needs to be fixed.

o:hr probably ought to be AT_CHAR, with no wrapping. However,
simply doing that wraps text the wrong way (always underneath)
which seems to be a LO limitation of not putting preceeding
chars above an AT_CHAR fly. So that's why I'm not implementing
a change to AT_CHAR.

Change-Id: I4aec99d3976c6d461715dba304cdf9ad98ab12b6
Reviewed-on: https://gerrit.libreoffice.org/42440
Tested-by: Jenkins 
Reviewed-by: Justin Luth 

diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index 18dc68dbc2f5..d1237eb8615d 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -310,6 +310,8 @@ ShapeTypeContext::ShapeTypeContext(ContextHandler2Helper 
const & rParent,
 mrTypeModel.maWidthPercent = OUString::number( hrpct.toInt32() );
 mrTypeModel.maWrapDistanceLeft = "0";
 mrTypeModel.maWrapDistanceRight = "0";
+mrTypeModel.maPositionHorizontal = rAttribs.getString( O_TOKEN( 
hralign ), "left" );
+mrTypeModel.moWrapType = "topAndBottom";
 }
 
 // stroke settings (may be overridden by v:stroke element later)
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index bbcaf277cb79..86785a00bff0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -231,9 +232,19 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf97648_relativeWidth,"tdf97648_relativeWidth.docx
 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(7616), 
getShape(1)->getSize().Width, 10);
 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(8001), 
getShape(2)->getSize().Width, 10);
 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(4001), 
getShape(3)->getSize().Width, 10);
+CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_LEFT, 
static_cast(getProperty(getParagraph(6), 
"ParaAdjust")) );
 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(1600), 
getShape(4)->getSize().Width, 10);
+CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_RIGHT, 
static_cast(getProperty(getParagraph(8), 
"ParaAdjust")) );
+
 
 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), getProperty(getShape(1), 
"LeftMargin") );
+if (!mbExported)
+{
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Text should wrap above/below the line", 
text::WrapTextMode_NONE, getProperty(getShape(1), 
"Surround"));
+CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, 
getProperty(getShape(2), "HoriOrient"));
+CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT, 
getProperty(getShape(3), "HoriOrient"));
+CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::LEFT, 
getProperty(getShape(4), "HoriOrient"));
+}
 }
 
 
DECLARE_OOXMLEXPORT_TEST(testTdf104061_tableSectionColumns,"tdf104061_tableSectionColumns.docx")
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-12-06 Thread Justin Luth
 oox/source/vml/vmlshapecontext.cxx|2 ++
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |2 ++
 2 files changed, 4 insertions(+)

New commits:
commit 9644f506ae31f1cacd6ab4c24b2591179791eebd
Author: Justin Luth 
Date:   Mon Sep 18 15:57:51 2017 -0400

tdf#97648 ooxmlimport: horizontal lines have no margins

Change-Id: I170ab7a742f8e9d8029512592abda9fc54edda18
Reviewed-on: https://gerrit.libreoffice.org/42437
Tested-by: Jenkins 
Reviewed-by: Justin Luth 

diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index 423ba1458053..8181c982780d 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -308,6 +308,8 @@ ShapeTypeContext::ShapeTypeContext(ContextHandler2Helper 
const & rParent,
 OUString hrpct = rAttribs.getString( O_TOKEN( hrpct ), "1000" );
 if( hrpct != "0" )
 mrTypeModel.maWidthPercent = OUString::number( hrpct.toInt32() );
+mrTypeModel.maWrapDistanceLeft = "0";
+mrTypeModel.maWrapDistanceRight = "0";
 }
 
 // stroke settings (may be overridden by v:stroke element later)
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 66eda44719f8..bbcaf277cb79 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -232,6 +232,8 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf97648_relativeWidth,"tdf97648_relativeWidth.docx
 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(8001), 
getShape(2)->getSize().Width, 10);
 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(4001), 
getShape(3)->getSize().Width, 10);
 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(1600), 
getShape(4)->getSize().Width, 10);
+
+CPPUNIT_ASSERT_EQUAL( sal_Int32(0), getProperty(getShape(1), 
"LeftMargin") );
 }
 
 
DECLARE_OOXMLEXPORT_TEST(testTdf104061_tableSectionColumns,"tdf104061_tableSectionColumns.docx")
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-11-28 Thread Samuel Mehrbrodt
 oox/source/vml/vmlshape.cxx |   69 
++
 sw/qa/extras/ooxmlexport/data/signature-line-all-props-set.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx  |   38 +
 3 files changed, 80 insertions(+), 27 deletions(-)

New commits:
commit d3440e0ebfa68ac8d2cbec9b44d0fc491162ee0e
Author: Samuel Mehrbrodt 
Date:   Thu Nov 23 15:05:03 2017 +0100

tdf#83877 Unit test for OOXML SignatureLine Roundtrip

Change-Id: I40c116f28c0e8efe81e33e48fa05098d1dd76731
Reviewed-on: https://gerrit.libreoffice.org/45152
Reviewed-by: Samuel Mehrbrodt 
Tested-by: Samuel Mehrbrodt 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 1cec9461e2df..8079f5ef179d 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1311,40 +1311,55 @@ Reference< XShape > ComplexShape::implConvertAndInsert( 
const Reference< XShapes
 
 if( getShapeModel().mbIsSignatureLine )
 {
-// Get the document signatures
-Reference< security::XDocumentDigitalSignatures > xSignatures(
-security::DocumentDigitalSignatures::createWithVersion(
-comphelper::getProcessComponentContext(), "1.2" ) );
-
-uno::Reference xStorage = 
comphelper::OStorageHelper::GetStorageOfFormatFromURL(
-ZIP_STORAGE_FORMAT_STRING, mrDrawing.getFilter().getFileUrl(), 
embed::ElementModes::READ);
-SAL_WARN_IF(!xStorage.is(), "oox.vml", "No xStorage!");
-
-uno::Sequence< security::DocumentSignatureInformation > xSignatureInfo 
=
-xSignatures->verifyScriptingContentSignatures(xStorage, 
uno::Reference< io::XInputStream >());
-
 OUString aGraphicUrl;
-for (int i=0; iverifyScriptingContentSignatures(xStorage,
+
uno::Reference());
+
+for (int i = 0; i < xSignatureInfo.getLength(); i++)
 {
-if (xSignatureInfo[i].SignatureIsValid)
-{
-// Signature is valid, use the 'valid' image
-
SAL_WARN_IF(!xSignatureInfo[i].ValidSignatureLineImage.is(), "oox.vml", "No 
ValidSignatureLineImage!");
-aGraphicUrl = 
rFilter.getGraphicHelper().createGraphicObject(xSignatureInfo[i].ValidSignatureLineImage);
-}
-else
+// Try to find matching signature line image - if none exists 
that is fine,
+// then the signature line is not digitally signed.
+if (xSignatureInfo[i].SignatureLineId == 
getShapeModel().maSignatureId)
 {
-// Signature is invalid, use the 'invalid' image
-
SAL_WARN_IF(!xSignatureInfo[i].InvalidSignatureLineImage.is(), "oox.vml", "No 
InvalidSignatureLineImage!");
-aGraphicUrl = 
rFilter.getGraphicHelper().createGraphicObject(xSignatureInfo[i].InvalidSignatureLineImage);
+if (xSignatureInfo[i].SignatureIsValid)
+{
+// Signature is valid, use the 'valid' image
+
SAL_WARN_IF(!xSignatureInfo[i].ValidSignatureLineImage.is(), "oox.vml",
+"No ValidSignatureLineImage!");
+aGraphicUrl = 
rFilter.getGraphicHelper().createGraphicObject(
+xSignatureInfo[i].ValidSignatureLineImage);
+}
+else
+{
+// Signature is invalid, use the 'invalid' image
+
SAL_WARN_IF(!xSignatureInfo[i].InvalidSignatureLineImage.is(), "oox.vml",
+"No InvalidSignatureLineImage!");
+aGraphicUrl = 
rFilter.getGraphicHelper().createGraphicObject(
+xSignatureInfo[i].InvalidSignatureLineImage);
+}
+ 

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

2017-11-14 Thread Szymon Kłos
 oox/source/export/vmlexport.cxx  |   18 ++-
 oox/source/vml/vmlshape.cxx  |   68 ++-
 sw/qa/extras/ooxmlexport/data/watermark.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx   |   18 +++
 4 files changed, 102 insertions(+), 2 deletions(-)

New commits:
commit a3a917748892a6a3194ebfc4db64cfd764cc054a
Author: Szymon Kłos 
Date:   Thu Nov 2 19:53:53 2017 +0100

tdf#113037 DOCX Watermark correct ratio

Import and export Watermark with padding like MSO does.
Shape is scaled to save correct ratio.

Change-Id: Iebd8eb5f168e0030320406d4fd6b287e451267bd
Reviewed-on: https://gerrit.libreoffice.org/44319
Tested-by: Jenkins 
Reviewed-by: Szymon Kłos 

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 363dd363cffb..a290db597df7 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -382,7 +383,22 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, 
const tools::Rectangle&
 if ( m_nShapeType == ESCHER_ShpInst_Line )
 AddLineDimensions( rRect );
 else
-AddRectangleDimensions( m_ShapeStyle, rRect );
+{
+if ( IsWaterMarkShape( m_pSdrObject->GetName() ) )
+{
+// Watermark need some padding to be compatible with MSO
+long nPaddingY = 0;
+const SfxItemSet& rSet = m_pSdrObject->GetMergedItemSet();
+if ( const SdrMetricItem* pItem = static_cast( rSet.GetItem( SDRATTR_TEXT_UPPERDIST ) ) )
+nPaddingY += pItem->GetValue();
+
+tools::Rectangle aRect( rRect );
+aRect.setHeight( aRect.getHeight() + nPaddingY );
+AddRectangleDimensions( m_ShapeStyle, aRect );
+}
+else
+AddRectangleDimensions( m_ShapeStyle, rRect );
+}
 
 // properties
 bool bAlreadyWritten[ 0xFFF ];
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 7679ca838f67..f9fa58669c35 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -72,6 +72,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using ::com::sun::star::beans::XPropertySet;
 using ::com::sun::star::uno::Any;
@@ -1139,12 +1140,77 @@ CustomShape::CustomShape( Drawing& rDrawing ) :
 {
 }
 
+static OUString lcl_getFontFamily( const oox::OptValue& rStyle )
+{
+OUString sFont = "";
+
+if( rStyle.has() )
+{
+OUString aStyle = rStyle.get( OUString() );
+
+sal_Int32 nIndex = 0;
+while( nIndex >= 0 )
+{
+OUString aName;
+if( ConversionHelper::separatePair( aName, sFont, aStyle.getToken( 
0, ';', nIndex ), ':' ) )
+{
+if( aName == "font-family" )
+{
+// remove " (first, and last character)
+if( sFont.getLength() > 2 )
+sFont = sFont.copy( 1, sFont.getLength() - 2 );
+}
+}
+}
+}
+
+return sFont;
+}
+
+/// modifies rShapeRect's height and returns difference
+sal_Int32 lcl_correctWatermarkRect( awt::Rectangle& rShapeRect, const 
OUString& sFont, const OUString& sText )
+{
+sal_Int32 nPaddingY = 0;
+double fRatio = 0;
+OutputDevice* pOut = Application::GetDefaultDevice();
+vcl::Font aFont( pOut->GetFont() );
+aFont.SetFamilyName( sFont );
+
+tools::Rectangle aBoundingRect;
+pOut->GetTextBoundRect( aBoundingRect, sText );
+if( aBoundingRect.GetWidth() )
+{
+fRatio = (double)aBoundingRect.GetHeight() / aBoundingRect.GetWidth();
+
+sal_Int32 nNewHeight = fRatio * rShapeRect.Width;
+nPaddingY = rShapeRect.Height - nNewHeight;
+rShapeRect.Height = nNewHeight;
+}
+
+return nPaddingY;
+}
+
 Reference< XShape > CustomShape::implConvertAndInsert( const Reference< 
XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
 {
+awt::Rectangle aShapeRect( rShapeRect );
+
+// Add padding for Watermark like Word does
+sal_Int32 nPaddingY = 0;
+if( getShapeName().match( "PowerPlusWaterMarkObject" ) && 
maTypeModel.maTextpathModel.moString.has() )
+{
+OUString sText = maTypeModel.maTextpathModel.moString.get();
+OUString sFont = lcl_getFontFamily( 
maTypeModel.maTextpathModel.moStyle );
+nPaddingY = lcl_correctWatermarkRect( aShapeRect, sFont, sText );
+}
+
 // try to create a custom shape
-Reference< XShape > xShape = SimpleShape::implConvertAndInsert( rxShapes, 
rShapeRect );
+Reference< XShape > xShape = SimpleShape::implConvertAndInsert( rxShapes, 
aShapeRect );
 if( xShape.is() ) try
 {
+// Remember padding for Watermark
+if( nPaddingY )
+PropertySet( xShape ).setAnyProperty( 

[Libreoffice-commits] core.git: oox/source sw/qa sw/source writerfilter/source

2017-11-02 Thread Michael Stahl
 oox/source/vml/vmlshape.cxx   |   61 +-
 sw/qa/extras/odfimport/data/Word2010AsCharShape.odt   |binary
 sw/qa/extras/odfimport/odfimport.cxx  |9 ++
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |6 +
 sw/source/core/unocore/unodraw.cxx|   10 ++
 writerfilter/source/rtftok/rtfdispatchdestination.cxx |3 
 6 files changed, 57 insertions(+), 32 deletions(-)

New commits:
commit c79467ba954987f1d239c594c1e1b3af3f5515f6
Author: Michael Stahl 
Date:   Thu Nov 2 22:13:32 2017 +0100

sw: ODF import: default as-char shapes to vertical-pos="top"

The problem is that we don't render ShapesWithWrapping.odt
the same as Word does:

https://beta.opendocumentformat.org/rendercompare/upload/223/86/191/1

The first shape in the file is anchored "as-char" and has no
style:vertical-rel or style:vertical-pos attribute affecting it.

If Word would write either style:vertical-rel="baseline" or
style:vertical-pos="top" explicitly, the rendering in LO would
be the same.

So the problem is that, for drawing shapes (note, text frames are
images, embedded objects handled differently), LO's default
vertical alignment is different, it is hard-coded in
SwShapeDescriptor_Impl::GetVOrient() as
SwFormatVertOrient(0, text::VertOrientation::NONE, 
text::RelOrientation::FRAME)

This effectively positions as-char shapes *below* the baseline,
which, while technically allowed, isn't really a good default.

So fix this by making the default alignment dependent on the anchor
type, so that as-char shapes sit on top of the baseline.

The ODF filter sets the anchor type before inserting the shape in
XMLTextShapeImportHelper::addShape(), however as it turns out the
various MSO filters insert the shape before setting the anchor,
which means the new default in SwXShape has an unwanted effect
on them, as inserting the shape causes the default to be created.

This requires changes to VML import to always set the VertOrient
property, and to RTF import to set the anchor type before inserting.

The DrawingML import is unaffected as it already sets VertOrient
for every non-as-char shape.

The testDmlTextshape "dml-textshape.docx" test still fails, but it
turns out that the change in alignment for this test document is
a bugfix, as it now has the same vertical alignment as in Word,
so adapt the test.

Change-Id: Ifcabd96a037515f7803f5474ec995f968b3b4de1

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 2c1acb029916..74ae15f848f3 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -564,6 +564,39 @@ void lcl_setSurround(PropertySet& rPropSet, const 
ShapeTypeModel& rTypeModel, co
 
 void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& 
rTypeModel, const GraphicHelper& rGraphicHelper)
 {
+if ( rTypeModel.maPosition == "absolute" )
+{
+// Word supports as-character (inline) and at-character only, absolute 
can't be inline.
+rPropSet.setProperty(PROP_AnchorType, 
text::TextContentAnchorType_AT_CHARACTER);
+// anchor is set after insertion, so reset to NONE
+rPropSet.setAnyProperty(PROP_VertOrient, 
makeAny(text::VertOrientation::NONE));
+
+if ( rTypeModel.maPositionVerticalRelative == "page" )
+{
+rPropSet.setProperty(PROP_VertOrientRelation, 
text::RelOrientation::PAGE_FRAME);
+}
+else if ( rTypeModel.maPositionVerticalRelative == "margin" )
+{
+rPropSet.setProperty(PROP_VertOrientRelation, 
text::RelOrientation::PAGE_PRINT_AREA);
+}
+else
+{
+rPropSet.setProperty(PROP_VertOrientRelation, 
text::RelOrientation::FRAME);
+}
+}
+else if( rTypeModel.maPosition == "relative" )
+{   // I'm not very sure this is correct either.
+rPropSet.setProperty(PROP_AnchorType, 
text::TextContentAnchorType_AT_PARAGRAPH);
+// anchor is set after insertion, so reset to NONE
+rPropSet.setAnyProperty(PROP_VertOrient, 
makeAny(text::VertOrientation::NONE));
+}
+else // static (is the default) means anchored inline
+{
+rPropSet.setProperty(PROP_AnchorType, 
text::TextContentAnchorType_AS_CHARACTER);
+// Use top orientation, this one seems similar to what MSO uses as 
inline
+rPropSet.setAnyProperty(PROP_VertOrient, 
makeAny(text::VertOrientation::TOP));
+}
+
 if ( rTypeModel.maPositionHorizontal == "center" )
 rPropSet.setAnyProperty(PROP_HoriOrient, 
makeAny(text::HoriOrientation::CENTER));
 else if ( rTypeModel.maPositionHorizontal == "left" )
@@ -599,34 +632,6 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const 
ShapeTypeModel& rTypeModel,
 else if ( rTypeModel.maPositionVertical == 

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

2017-09-11 Thread Justin Luth
 oox/source/vml/vmlshapecontext.cxx|2 +-
 sw/qa/extras/ooxmlexport/data/tdf97648_relativeWidth.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |   11 +++
 3 files changed, 12 insertions(+), 1 deletion(-)

New commits:
commit c14be5f5545768fc06bd1e3900e076dc28be2649
Author: Justin Luth 
Date:   Thu Sep 7 21:07:40 2017 -0400

tdf#97648 vml import: fix horizontalLine percentage

o:hrpct (horizontal line width as a percentage) was
overwriting valid widths with an invalid string since 2012.

For some reason, commit 96c7ab19b77c2f90acd4c34552474b0f616f48a7
thought it would be a good idea to set the width as a
percent string, even though the code doesn't seem to
handle percent strings. (like "100%").

The logic was that since 100% width is saved as nWidth=0 by
Microsoft, so it doesn't make a difference.  Well, it does make
a difference for every other percentage, since nWidth IS provided
for those. That width value is the only thing LO can currently
handle - it does nothing with the maWidthPercent for these
horizontal lines.

Saving hrpct to maWidthPercent seems like the proper variable
for this data, but once again, this doesn't in fact change much
in LO. It certainly doesn't affect the width of the line.

Since this patch only affects o:hr shapes, this is a pretty
safe change, for the benefit of all <100% o:hrpct's.

An "assert false" and "make check" only showed docs containing
100%, width=0 samples. I added a unit test for several other
lengths. I also hacked that test to provide a width value for the
100% line - even though that is not natural - just so it can be
seen in LO.

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

diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index f49d0ddfae04..4ddd8c5d8e0a 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -304,7 +304,7 @@ ShapeTypeContext::ShapeTypeContext( ContextHandler2Helper 
const & rParent, Shape
 // - given width is used only if explicit o:hrpct="0" is given
 OUString hrpct = rAttribs.getString( O_TOKEN( hrpct ), "1000" );
 if( hrpct != "0" )
-mrTypeModel.maWidth = OUString::number( hrpct.toInt32() / 10 ) + 
"%";
+mrTypeModel.maWidthPercent = OUString::number( hrpct.toInt32() );
 }
 
 // stroke settings (may be overridden by v:stroke element later)
diff --git a/sw/qa/extras/ooxmlexport/data/tdf97648_relativeWidth.docx 
b/sw/qa/extras/ooxmlexport/data/tdf97648_relativeWidth.docx
new file mode 100644
index ..8419113f1617
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf97648_relativeWidth.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 693d18d59fb4..a89799b87e39 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -9,6 +9,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -204,6 +205,16 @@ DECLARE_OOXMLEXPORT_TEST(tdf105490_negativeMargins, 
"tdf105490_negativeMargins.d
 }
 #endif
 
+DECLARE_OOXMLEXPORT_TEST(testTdf97648_relativeWidth,"tdf97648_relativeWidth.docx")
+{
+int i = mbExported ? 0 : 1;
+//divide everything by 10 to avoid rounding errors etc
+CPPUNIT_ASSERT_EQUAL( sal_Int32(15995/10), 
getShape(++i)->getSize().Width/10);
+CPPUNIT_ASSERT_EQUAL( sal_Int32(8001/10),  
getShape(++i)->getSize().Width/10);
+CPPUNIT_ASSERT_EQUAL( sal_Int32(4001/10),  
getShape(++i)->getSize().Width/10);
+CPPUNIT_ASSERT_EQUAL( sal_Int32(1600/10),  
getShape(++i)->getSize().Width/10);
+}
+
 
DECLARE_OOXMLEXPORT_TEST(testTdf104061_tableSectionColumns,"tdf104061_tableSectionColumns.docx")
 {
 CPPUNIT_ASSERT_MESSAGE("There should be two or three pages", getPages() <= 
3 );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-08-23 Thread Tamás Zolnai
 oox/source/export/vmlexport.cxx  |5 +
 sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx|   34 +++
 sw/source/filter/ww8/docxattributeoutput.cxx |   20 +-
 sw/source/filter/ww8/docxattributeoutput.hxx |4 -
 5 files changed, 57 insertions(+), 6 deletions(-)

New commits:
commit b129421764ae78a1422812169fce8eb4914a6b22
Author: Tamás Zolnai 
Date:   Wed Aug 23 20:09:35 2017 +0200

DOCX: Fix an other test case of ActiveX control export

When LO control is anchored to the end of the run, it
is exported into a new run.

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

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index f45edde6cc86..c4c3f3679861 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1311,6 +1311,7 @@ OString VMLExport::AddSdrObject( const SdrObject& rObj, 
sal_Int16 eHOri, sal_Int
 m_eVOri = eVOri;
 m_eHRel = eHRel;
 m_eVRel = eVRel;
+m_bInline = false;
 EscherEx::AddSdrObject(rObj, bOOxmlExport);
 return m_sShapeId;
 }
@@ -1318,6 +1319,10 @@ OString VMLExport::AddSdrObject( const SdrObject& rObj, 
sal_Int16 eHOri, sal_Int
 OString VMLExport::AddInlineSdrObject( const SdrObject& rObj, const bool 
bOOxmlExport )
 {
 m_pSdrObject = 
+m_eHOri = -1;
+m_eVOri = -1;
+m_eHRel = -1;
+m_eVRel = -1;
 m_bInline = true;
 EscherEx::AddSdrObject(rObj, bOOxmlExport);
 return m_sShapeId;
diff --git a/sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt 
b/sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt
new file mode 100755
index ..9008cb90a530
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 0fac9847dd6e..4e961079b829 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -959,6 +959,40 @@ DECLARE_OOXMLEXPORT_TEST(testWatermark, 
"watermark-shapetype.docx")
 
CPPUNIT_ASSERT_EQUAL(xPropertySet1->getPropertyValue("TextAutoGrowHeight"), 
xPropertySet2->getPropertyValue("TextAutoGrowHeight"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testActiveXControlAtRunEnd, 
"activex_control_at_run_end.odt")
+{
+// Two issues were here:
+//  1) second shape was not export (it is anchored to the end of the run)
+//  2) inline property was inherited to the second shape by mistake
+
+// First checkbox is the inlined one
+uno::Reference xControlShape(getShape(1), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xControlShape.is());
+
+// Check whether we have the right control
+uno::Reference 
xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
+uno::Reference xServiceInfo(xPropertySet, 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService( 
"com.sun.star.form.component.CheckBox")));
+CPPUNIT_ASSERT_EQUAL(OUString("Inline Checkbox"), 
getProperty(xPropertySet, "Label"));
+
+// Check anchor type
+uno::Reference xPropertySet2(xControlShape, 
uno::UNO_QUERY);
+
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER,getProperty(xPropertySet2,"AnchorType"));
+
+// Second check box anchored to character
+xControlShape.set(getShape(2), uno::UNO_QUERY);
+
+// Check whether we have the right control
+xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
+xServiceInfo.set(xPropertySet, uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(true, 
bool(xServiceInfo->supportsService("com.sun.star.form.component.CheckBox")));
+CPPUNIT_ASSERT_EQUAL(OUString("Floating Checkbox"), 
getProperty(xPropertySet, "Label"));
+
+// Check anchor type
+xPropertySet2.set(xControlShape, uno::UNO_QUERY);
+
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty(xPropertySet2,"AnchorType"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 5d9bf2b040be..1332baf8f628 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1320,6 +1320,8 @@ void DocxAttributeOutput::EndRun()
 WritePostponedFormControl(*it);
 m_aPostponedFormControls.clear();
 
+WritePostponedActiveXControl(false);
+
 WritePendingPlaceholder();
 
 m_pRedlineData = nullptr;
@@ -2045,7 +2047,7 @@ void DocxAttributeOutput::EndRunProperties( const 
SwRedlineData* pRedlineData )
 
 WritePostponedOLE();
 
-

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

2017-08-23 Thread Szymon Kłos
 oox/source/vml/vmlshape.cxx|8 
 sw/qa/extras/ooxmlexport/data/watermark-shapetype.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx  |   13 +
 3 files changed, 21 insertions(+)

New commits:
commit 87f1f7fdb34fe452ac540524224e1e808ce5d3a2
Author: Szymon Kłos 
Date:   Mon Aug 21 16:06:43 2017 +0200

VML, Watermark: detect shapetype from other subdocuments

In some documents Watermark wasn't visible
because shapetype wasn't detected.
It was impossible to use shapetype defined in header1.xml
in shape placed in the header2.xml.

Change-Id: Ib406c8fc702968684ad46efd0857b768af2820f5
Reviewed-on: https://gerrit.libreoffice.org/41395
Reviewed-by: Tamás Zolnai 
Tested-by: Tamás Zolnai 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index e1d0cf6d9a41..d6a14caf16b5 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -283,6 +283,14 @@ void ShapeBase::finalizeFragmentImport()
 aType = aType.copy(1);
 if( const ShapeType* pShapeType = 
mrDrawing.getShapes().getShapeTypeById( aType ) )
 maTypeModel.assignUsed( pShapeType->getTypeModel() );
+else {
+// Temporary fix, shapetype not found if referenced from different 
substream
+// FIXME: extend scope of ShapeContainer to store all shapetypes 
from the document
+const OUString sShapeTypePrefix = "shapetype_";
+if (aType.startsWith(sShapeTypePrefix)) {
+maTypeModel.moShapeType = 
aType.copy(sShapeTypePrefix.getLength()).toInt32();
+}
+}
 }
 }
 
diff --git a/sw/qa/extras/ooxmlexport/data/watermark-shapetype.docx 
b/sw/qa/extras/ooxmlexport/data/watermark-shapetype.docx
new file mode 100755
index ..423f3cf7184f
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/watermark-shapetype.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index f9cb088d5068..0fac9847dd6e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -946,6 +946,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf111964, "tdf111964.docx")
 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[4]/w:t", 
sWSReference);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark-shapetype.docx")
+{
+uno::Reference xShape1(getShape(1), uno::UNO_QUERY);
+uno::Reference xPropertySet1(xShape1, uno::UNO_QUERY);
+xShape1.is();
+
+uno::Reference xShape2(getShape(2), uno::UNO_QUERY);
+uno::Reference xPropertySet2(xShape2, uno::UNO_QUERY);
+xShape2.is();
+
+
CPPUNIT_ASSERT_EQUAL(xPropertySet1->getPropertyValue("TextAutoGrowHeight"), 
xPropertySet2->getPropertyValue("TextAutoGrowHeight"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-05-26 Thread Szymon Kłos
 oox/source/export/vmlexport.cxx   |4 +++-
 oox/source/vml/vmlshapecontext.cxx|   11 +--
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx |4 
 sw/qa/extras/uiwriter/data/watermark.docx |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|   23 +++
 sw/source/core/edit/edfcol.cxx|   17 +++--
 6 files changed, 50 insertions(+), 9 deletions(-)

New commits:
commit 271094ad8f9e334d17176744b90b35e80528bcb2
Author: Szymon Kłos 
Date:   Wed May 24 00:15:15 2017 +0200

Watermark: docx interoperability

Before patch:

Document created in MS Word:



Imported to LO and exported:



Then again imported to MS Word and exported:



In this moment LO after import had shape in the navigator but it wasn't 
visible.

Patch:
* vmshapecontext.cxx is changed to read ShapeType from id instead of o:spt
 when o:spid is present.
* vmlexport.cxx added o:spid for Word to identify inserted watermark
* edfxol.cxx changed name of shape to "PowerPlusWaterMarkObject" for Word
* tests

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

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index ef400be64f7c..623beaaa88ec 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -190,8 +190,10 @@ void VMLExport::AddShape( sal_uInt32 nShapeType, 
sal_uInt32 nShapeFlags, sal_uIn
 }
 else
 {
-// A watermark object - store the optional shape ID also ('o:spid')
+// A watermark object - store the optional shape ID
 m_pShapeAttrList->add( XML_id, 
OUStringToOString(m_pSdrObject->GetName(), RTL_TEXTENCODING_UTF8) );
+// also ('o:spid')
+m_pShapeAttrList->addNS( XML_o, XML_spid, ShapeIdString( nShapeId ) );
 }
 }
 
diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index dc654223aca6..ed369ae1c7d9 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -275,11 +275,18 @@ ShapeTypeContext::ShapeTypeContext( 
ContextHandler2Helper& rParent, ShapeType& r
 mrTypeModel.maShapeId = rAttribs.getXString( bHasOspid ? O_TOKEN( spid ) : 
XML_id, OUString() );
 mrTypeModel.maLegacyId = rAttribs.getString( XML_id, OUString() );
 OSL_ENSURE( !mrTypeModel.maShapeId.isEmpty(), 
"ShapeTypeContext::ShapeTypeContext - missing shape identifier" );
+// builtin shape type identifier
+mrTypeModel.moShapeType = rAttribs.getInteger( O_TOKEN( spt ) );
 // if the o:spid attribute exists, the id attribute contains the 
user-defined shape name
 if( bHasOspid )
+{
 mrTypeModel.maShapeName = rAttribs.getXString( XML_id, OUString() );
-// builtin shape type identifier
-mrTypeModel.moShapeType = rAttribs.getInteger( O_TOKEN( spt ) );
+// get ShapeType and ShapeId from name for compatibility
+mrTypeModel.maShapeId = mrTypeModel.maShapeName;
+static const OUString sShapeTypePrefix = "shapetype_";
+if( mrTypeModel.maShapeName.startsWith( sShapeTypePrefix ) )
+mrTypeModel.moShapeType = 
mrTypeModel.maShapeName.copy(sShapeTypePrefix.getLength()).toInt32();
+}
 
 // coordinate system position/size, CSS style
 mrTypeModel.moCoordPos = lclDecodeInt32Pair( rAttribs, XML_coordorigin );
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index f9b851175202..67179b5c14a0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -108,6 +108,10 @@ DECLARE_OOXMLEXPORT_TEST(testTextWatermark, 
"textWatermark.docx")
return;
 
 assertXPath(pXmlHeader1, 
"/w:hdr[1]/w:p[1]/w:r[1]/w:pict[1]/v:shape[1]","id","PowerPlusWaterMarkObject93701316");
+
+//The second problem was that Word uses also "o:spid"
+const OUString& sSpid = getXPath(pXmlHeader1, 
"/w:hdr[1]/w:p[1]/w:r[1]/w:pict[1]/v:shape[1]","spid");
+CPPUNIT_ASSERT(!sSpid.isEmpty());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testPictureWatermark, "pictureWatermark.docx")
diff --git a/sw/qa/extras/uiwriter/data/watermark.docx 
b/sw/qa/extras/uiwriter/data/watermark.docx
new file mode 100644
index ..0b26d4442e98
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/watermark.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 8621a81884a9..1e482e1ac87d 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -104,6 +104,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static const char* const DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/";
 
@@ -125,6 +126,7 @@ public:
 void 

  1   2   >