[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 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 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 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 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 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 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 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 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 

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

2015-07-15 Thread Joren De Cuyper
 oox/source/drawingml/fillproperties.cxx   |   30 ++
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx |2 -
 sw/source/filter/ww8/docxattributeoutput.cxx  |2 -
 writerfilter/source/dmapper/GraphicImport.cxx |5 +---
 4 files changed, 21 insertions(+), 18 deletions(-)

New commits:
commit d151ed35ad4c4e7aa9fbb807930fcf91dea2eba7
Author: Joren De Cuyper jore...@libreoffice.org
Date:   Tue Jun 2 22:26:29 2015 +0200

tdf#87539 map MSO washout filter to LO's watermark colormode

Change-Id: Id28e301a74a729245b20ba6cd2adecf203633f0e
Reviewed-on: https://gerrit.libreoffice.org/16048
Tested-by: Jenkins c...@libreoffice.org
Reviewed-by: Thorsten Behrens thorsten.behr...@cib.de

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 1302a07..6879896 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -696,17 +696,29 @@ void GraphicProperties::pushToPropMap( PropertyMap 
rPropMap, const GraphicHelpe
 {
 sal_Int16 nBrightness = getLimitedValue sal_Int16, sal_Int32 ( 
maBlipProps.moBrightness.get( 0 ) / PER_PERCENT, -100, 100 );
 sal_Int16 nContrast = getLimitedValue sal_Int16, sal_Int32 ( 
maBlipProps.moContrast.get( 0 ) / PER_PERCENT, -100, 100 );
+ColorMode eColorMode = ColorMode_STANDARD;
+
+switch( maBlipProps.moColorEffect.get( XML_TOKEN_INVALID ) )
+{
+case XML_biLevel:   eColorMode = ColorMode_MONO;break;
+case XML_grayscl:   eColorMode = ColorMode_GREYS;   break;
+}
+
 if( maBlipProps.mxGraphic.is() )
 {
 // created transformed graphic
 Reference XGraphic  xGraphic = lclCheckAndApplyDuotoneTransform( 
maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr );
 xGraphic = lclCheckAndApplyChangeColorTransform( maBlipProps, 
xGraphic, rGraphicHelper, nPhClr );
-// MSO uses a different algorithm for contrast+brightness, LO applies 
contrast before brightness,
-// while MSO apparently applies half of brightness before contrast and 
half after. So if only
-// contrast or brightness need to be altered, the result is the same, 
but if both are involved,
-// there's no way to map that, so just force a conversion of the image.
-if( nBrightness != 0  nContrast != 0 )
+
+if (eColorMode == ColorMode_STANDARD  nBrightness == 70  nContrast 
== -70)
+// map MSO 'washout' to our Watermark colormode
+eColorMode = ColorMode_WATERMARK;
+else if( nBrightness != 0  nContrast != 0 )
 {
+// MSO uses a different algorithm for contrast+brightness, LO 
applies contrast before brightness,
+// while MSO apparently applies half of brightness before contrast 
and half after. So if only
+// contrast or brightness need to be altered, the result is the 
same, but if both are involved,
+// there's no way to map that, so just force a conversion of the 
image.
 xGraphic = applyBrightnessContrast( xGraphic, nBrightness, 
nContrast );
 nBrightness = 0;
 nContrast = 0;
@@ -738,14 +750,6 @@ void GraphicProperties::pushToPropMap( PropertyMap 
rPropMap, const GraphicHelpe
 }
 }
 }
-
-// color effect
-ColorMode eColorMode = ColorMode_STANDARD;
-switch( maBlipProps.moColorEffect.get( XML_TOKEN_INVALID ) )
-{
-case XML_biLevel:   eColorMode = ColorMode_MONO;break;
-case XML_grayscl:   eColorMode = ColorMode_GREYS;   break;
-}
 rPropMap.setProperty(PROP_GraphicColorMode, eColorMode);
 
 // brightness and contrast
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index 47b47b8..727d448 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -973,7 +973,7 @@ DECLARE_OOXMLEXPORT_TEST(testPictureColormodeWatermark, 
picture_colormode_water
 if (!pXmlDoc)
 return;
 
-assertXPath(pXmlDoc, 
/w:document/w:body/w:p/w:r/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:lum,
 bright, 5);
+assertXPath(pXmlDoc, 
/w:document/w:body/w:p/w:r/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:lum,
 bright, 7);
 assertXPath(pXmlDoc, 
/w:document/w:body/w:p/w:r/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:lum,
 contrast, -7);
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index ddad776..710c862 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4246,7 +4246,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const 
SwGrfNode* pGrfNode, const Size
 else if (nMode == GRAPHICDRAWMODE_MONO) //black/white has a 0,5 
threshold in LibreOffice
 

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

2014-07-27 Thread Miklos Vajna
 oox/source/shape/WpsContext.cxx|4 ++--
 sw/qa/extras/rtfimport/rtfimport.cxx   |3 +--
 sw/source/filter/ww8/docxsdrexport.cxx |2 +-
 writerfilter/source/dmapper/SdtHelper.cxx  |7 ++-
 writerfilter/source/dmapper/SdtHelper.hxx  |7 ++-
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |7 ++-
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |2 +-
 writerfilter/source/rtftok/rtfsdrimport.cxx|3 +--
 writerfilter/source/rtftok/rtfvalue.hxx|8 
 9 files changed, 16 insertions(+), 27 deletions(-)

New commits:
commit 2198168af134e7f72afcc07ff5062324a19d
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Sun Jul 27 17:30:48 2014 +0200

indentation fixes

Change-Id: I0a0f04d0f0e008e8947a5a7e3ed6083c1589e61b

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 89ed320..fb42e62 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -128,10 +128,10 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 }
 break;
 case XML_prstTxWarp:
-if( rAttribs.hasAttribute( XML_prst ) )
+if (rAttribs.hasAttribute(XML_prst))
 {
 uno::Referencebeans::XPropertySet xPropertySet(mxShape, 
uno::UNO_QUERY);
-oox::OptValueOUString presetShapeName = rAttribs.getString( 
XML_prst );
+oox::OptValueOUString presetShapeName = 
rAttribs.getString(XML_prst);
 OUString preset = presetShapeName.get();
 comphelper::SequenceAsHashMap 
aCustomShapeGeometry(xPropertySet-getPropertyValue(CustomShapeGeometry));
 aCustomShapeGeometry[PresetTextWarp] = uno::makeAny(preset);
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx 
b/sw/qa/extras/rtfimport/rtfimport.cxx
index 289cce8..f7763b3 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1337,8 +1337,7 @@ DECLARE_RTFIMPORT_TEST(testFdo77996, fdo77996.rtf)
 uno::Referencedocument::XDocumentPropertiesSupplier 
xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
 uno::Referencedocument::XDocumentProperties 
xProps(xDocumentPropertiesSupplier-getDocumentProperties());
 CPPUNIT_ASSERT_EQUAL(OUString(Aln Lin (Bei Jing)), xProps-getAuthor());
-OUString 
aTitle(\xe5\x8e\xa6\xe9\x97\xa8\xe9\x92\xa8\xe4\xb8\x9a\xe8\x82\xa1\xe4\xbb\xbd\xe6\x9c\x89\xe9\x99\x90\xe5\x85\xac\xe5\x8f\xb8,
 30,
-RTL_TEXTENCODING_UTF8);
+OUString 
aTitle(\xe5\x8e\xa6\xe9\x97\xa8\xe9\x92\xa8\xe4\xb8\x9a\xe8\x82\xa1\xe4\xbb\xbd\xe6\x9c\x89\xe9\x99\x90\xe5\x85\xac\xe5\x8f\xb8,
 30, RTL_TEXTENCODING_UTF8);
 CPPUNIT_ASSERT_EQUAL(aTitle, xProps-getTitle());
 uno::Referencebeans::XPropertySet 
xUDProps(xProps-getUserDefinedProperties(), uno::UNO_QUERY);
 CPPUNIT_ASSERT_EQUAL(OUString(jay), getPropertyOUString(xUDProps, 
Operator));
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx 
b/sw/source/filter/ww8/docxsdrexport.cxx
index 8e137d9..9429443 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -853,7 +853,7 @@ void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* 
sdrObj, const SwFrmFm
 
 // In case we are already inside a DML block, then write the shape only as 
VML, turn out that's allowed to do.
 // A common service created in util to check for VML shapes which are 
allowed to have textbox in content
-if ( (msfilter::util::HasTextBoxContent(eShapeType))  
m_pImpl-isSupportedDMLShape(xShape)  !bDMLAndVMLDrawingOpen)
+if ((msfilter::util::HasTextBoxContent(eShapeType))  
m_pImpl-isSupportedDMLShape(xShape)  !bDMLAndVMLDrawingOpen)
 {
 m_pImpl-m_pSerializer-startElementNS(XML_mc, XML_AlternateContent, 
FSEND);
 
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index 671e4c2..ce57d60 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -135,15 +135,12 @@ void SdtHelper::createDateControl(OUString rContentText, 
beans::PropertyValue a
 createControlShape(lcl_getOptimalWidth(m_rDM_Impl.GetStyleSheetTable(), 
rContentText, aItems), xControlModel, aGrabBag.getAsConstPropertyValueList());
 }
 
-void SdtHelper::createControlShape(awt::Size aSize,
-uno::Referenceawt::XControlModel const xControlModel)
+void SdtHelper::createControlShape(awt::Size aSize, 
uno::Referenceawt::XControlModel const xControlModel)
 {
 createControlShape(aSize, xControlModel, 
uno::Sequencebeans::PropertyValue());
 }
 
-void SdtHelper::createControlShape(awt::Size aSize,
-uno::Referenceawt::XControlModel const xControlModel,
-const uno::Sequencebeans::PropertyValue rGrabBag)
+void SdtHelper::createControlShape(awt::Size aSize, 
uno::Referenceawt::XControlModel const xControlModel, const 
uno::Sequencebeans::PropertyValue rGrabBag)
 {
 

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

2014-06-20 Thread Dinesh Patil
 oox/source/export/vmlexport.cxx |2 +-
 sw/qa/extras/ooxmlexport/data/fdo79591.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx |   15 +++
 sw/source/filter/ww8/docxsdrexport.cxx  |2 +-
 4 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 7ea1bbe712cef48a97faffdf03b45f2812a93e62
Author: Dinesh Patil dinesh.pa...@synerzip.com
Date:   Thu Jun 12 11:34:32 2014 +0530

fdo#79591 Values for docPr name and shape ID attributes were set invalid

Values set for docPr name and shape ID attributes in RT file were not valid
as per UTF-8 encoding format and hence was showing RT document as corrupt 
with
error message invalid character.

Calling add() function with current parameters is causing issue and
setting invalid values so modified the second parameter which will
set valid values to the specified parameters.

Reviewed on:
https://gerrit.libreoffice.org/9746

Change-Id: I3b48e53adbe5ed844235e596bb98eb396133845a

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 490bc7b..69242d6 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -821,7 +821,7 @@ void VMLExport::Commit( EscherPropertyContainer rProps, 
const Rectangle rRect
 OUString idStr = 
SvxMSDffManager::MSDFFReadZString(aStream, it-nPropSize, true);
 aStream.Seek(0);
 if (!IsWaterMarkShape(m_pSdrObject-GetName()))
- m_pShapeAttrList-add(XML_ID, 
OUStringToOString(idStr, RTL_TEXTENCODING_UTF8));
+ m_pShapeAttrList-add(XML_ID, 
OUStringToOString(idStr, RTL_TEXTENCODING_UTF8).getStr());
 
 bAlreadyWritten[ESCHER_Prop_wzName] = true;
 }
diff --git a/sw/qa/extras/ooxmlexport/data/fdo79591.docx 
b/sw/qa/extras/ooxmlexport/data/fdo79591.docx
new file mode 100644
index 000..32a61de
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo79591.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 25a6cf7..20ee7c3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -1811,6 +1811,21 @@ DECLARE_OOXMLEXPORT_TEST(testTextboxRoundedCorners, 
textbox-rounded-corners.doc
 CPPUNIT_ASSERT_EQUAL(OUString(a), xCell-getString());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testfdo79591, fdo79591.docx)
+{
+/* Values set for docPr name and shape ID attributes
+ * in RT file were not valid as per UTF-8 encoding format
+ * and hence was showing RT document as corrupt with error
+ * message invalid character
+ */
+xmlDocPtr pXmlDoc = parseExport(word/document.xml);
+if (!pXmlDoc)
+  return;
+
+assertXPath(pXmlDoc, 
/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr,
 name, );
+assertXPath(pXmlDoc, 
/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape, 
ID, );
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx 
b/sw/source/filter/ww8/docxsdrexport.cxx
index 42e9f9c..d3efe2a 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -724,7 +724,7 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* 
pSdrObject, const SwFrmFmt*
 
 sax_fastparser::FastAttributeList* pDocPrAttrList = pFS-createAttrList();
 pDocPrAttrList-add(XML_id, OString::number(nAnchorId).getStr());
-pDocPrAttrList-add(XML_name, OUStringToOString(pSdrObject-GetName(), 
RTL_TEXTENCODING_UTF8));
+pDocPrAttrList-add(XML_name, OUStringToOString(pSdrObject-GetName(), 
RTL_TEXTENCODING_UTF8).getStr());
 if (!pSdrObject-GetTitle().isEmpty())
 pDocPrAttrList-add(XML_title, 
OUStringToOString(pSdrObject-GetTitle(), RTL_TEXTENCODING_UTF8));
 if (!pSdrObject-GetDescription().isEmpty())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-06-10 Thread Miklos Vajna
 oox/source/export/shapes.cxx |1 +
 oox/source/shape/WpsContext.cxx  |3 +++
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx |   23 ++-
 sw/source/filter/ww8/docxsdrexport.cxx   |   12 ++--
 4 files changed, 28 insertions(+), 11 deletions(-)

New commits:
commit 2b076a0d91ade62e678d42eb61153bf4de4531a2
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Tue Jun 10 17:00:49 2014 +0200

DOCX drawingML export of textboxes: write wps:bodyPr in oox

It's possible to write this tag in oox (so it represents the properties
of the shape) or in sw (so it represents the properties of the shape's
textbox). Do the previous, as the textbox is really just a container in
this use case, nothing more.

If we are at it, also fix the default value of wps:bodyPr's l/r/t/bIns
attributes.

Change-Id: I0571b9d8ea7dc0acd5c61f3e28e18400d305eab3

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 7c3627e..02b005b 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -822,6 +822,7 @@ ShapeExport ShapeExport::WriteTextBox( Reference 
XInterface  xIface, sal_Int3
 if (xPropertySetInfo-hasPropertyByName(TextBox)  
xPropertySet-getPropertyValue(TextBox).getbool())
 {
 
GetTextExport()-WriteTextBox(uno::Referencedrawing::XShape(xIface, 
uno::UNO_QUERY_THROW));
+WriteText( xIface, /*bBodyPr=*/true, /*bText=*/false, 
/*nXmlNamespace=*/nXmlNamespace );
 return *this;
 }
 }
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 90628b2..0163a50 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -86,6 +86,9 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 OptValueOUString oValue = rAttribs.getString(aInsets[i]);
 if (oValue.has())
 oInsets[i] = 
oox::drawingml::GetCoordinate(oValue.get());
+else
+// Defaults from the spec: left/right: 91440 EMU, 
top/bottom: 45720 EMU
+oInsets[i] = (aInsets[i] == XML_lIns || aInsets[i] == 
XML_rIns) ? 254 : 127;
 }
 OUString aProps[] = { OUString(LeftBorderDistance), 
OUString(TopBorderDistance), OUString(RightBorderDistance), 
OUString(BottomBorderDistance) };
 OUString aShapeProps[] = { OUString(TextLeftDistance), 
OUString(TextUpperDistance), OUString(TextRightDistance), 
OUString(TextLowerDistance) };
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 33556d1..c106f3c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -900,11 +900,24 @@ DECLARE_OOXMLEXPORT_TEST(testFdo66929, fdo66929.docx)
 // This is wrong because the original node denotes a specific 'left' 
inset, and a default 'top','right','bottom' inset
 uno::Referencetext::XTextFramesSupplier xTextFramesSupplier(mxComponent, 
uno::UNO_QUERY);
 uno::Referencecontainer::XIndexAccess 
xIndexAccess(xTextFramesSupplier-getTextFrames(), uno::UNO_QUERY);
-uno::Referencebeans::XPropertySet xFrame(xIndexAccess-getByIndex(0), 
uno::UNO_QUERY);
-CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 )  , getProperty sal_Int32 ( xFrame, 
LeftBorderDistance ) );
-CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty sal_Int32 ( xFrame, 
TopBorderDistance ) );
-CPPUNIT_ASSERT_EQUAL( sal_Int32( 254 ), getProperty sal_Int32 ( xFrame, 
RightBorderDistance ) );
-CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty sal_Int32 ( xFrame, 
BottomBorderDistance ) );
+if (xIndexAccess-getCount())
+{
+// VML import - TextFrame
+uno::Referencebeans::XPropertySet 
xFrame(xIndexAccess-getByIndex(0), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 )  , getProperty sal_Int32 ( 
xFrame, LeftBorderDistance ) );
+CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty sal_Int32 ( 
xFrame, TopBorderDistance ) );
+CPPUNIT_ASSERT_EQUAL( sal_Int32( 254 ), getProperty sal_Int32 ( 
xFrame, RightBorderDistance ) );
+CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty sal_Int32 ( 
xFrame, BottomBorderDistance ) );
+}
+else
+{
+// drawingML import - shape with TextBox
+uno::Referencebeans::XPropertySet xShape(getShape(1), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getPropertysal_Int32(xShape, 
TextLeftDistance));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getPropertysal_Int32(xShape, 
TextUpperDistance));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(254), getPropertysal_Int32(xShape, 
TextRightDistance));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getPropertysal_Int32(xShape, 
TextLowerDistance));
+}
 }
 
 

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

2014-03-18 Thread Vinaya Mandke
 oox/source/drawingml/shape.cxx  |   12 --
 oox/source/token/tokens.txt |1 
 sw/qa/extras/inc/swmodeltestbase.hxx|1 
 sw/qa/extras/ooxmlexport/data/fdo76249.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx |   15 
 sw/source/filter/ww8/docxsdrexport.cxx  |   49 +++-
 sw/source/filter/ww8/docxsdrexport.hxx  |2 +
 7 files changed, 75 insertions(+), 5 deletions(-)

New commits:
commit 17d31e6fb316da2bf1267c337eed88165dfa1a54
Author: Vinaya Mandke vinaya.man...@synerzip.com
Date:   Mon Mar 17 13:01:37 2014 +0530

fdo#76249 DOCX export DML Drawing as lockedCanvas if it's inside 
DMLTextFrame

The Locked Canvas is imported correctly,
but while exporting the drawing is exported inside a textbox.
However a locked Canvas has to be exported inside a text-box
for the RT file to work in MS Word 2010.
As dml drawing elements are not allowed in the dml textboxes.

Export as Locked Canvas iff the drawing was originally a Locked Canvas
and is now inside a DML Text Frame.
As otherwise the Locked Canvas is exported correctly as a DMLDrawing.

Reviewed on:
https://gerrit.libreoffice.org/8618

Change-Id: Ifa350d8922a22c4e480411530aa4d953bd3ed2ac

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 56342dd..c6f14e9 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -790,11 +790,15 @@ Reference XShape  Shape::createAndInsert(
 }
 
 PropertySet( xSet ).setProperties( aShapeProps );
-if (mbLockedCanvas  aServiceName == 
com.sun.star.drawing.LineShape)
+if (mbLockedCanvas)
 {
-// It seems the position and size for lines inside a locked 
canvas is absolute.
-mxShape-setPosition(awt::Point(aShapeRectHmm.X, 
aShapeRectHmm.Y));
-mxShape-setSize(awt::Size(aShapeRectHmm.Width, 
aShapeRectHmm.Height));
+putPropertyToGrabBag( LockedCanvas, Any( true ) );
+if (aServiceName == com.sun.star.drawing.LineShape)
+{
+// It seems the position and size for lines inside a 
locked canvas is absolute.
+mxShape-setPosition(awt::Point(aShapeRectHmm.X, 
aShapeRectHmm.Y));
+mxShape-setSize(awt::Size(aShapeRectHmm.Width, 
aShapeRectHmm.Height));
+}
 }
 
 // Store original fill and line colors of the shape and the theme 
color name to InteropGrabBag
diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt
index 84f28c1..8d40a4b 100644
--- a/oox/source/token/tokens.txt
+++ b/oox/source/token/tokens.txt
@@ -2885,6 +2885,7 @@ ky
 l
 lB
 lBounds
+lc
 lCtrCh
 lCtrDes
 lIns
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx 
b/sw/qa/extras/inc/swmodeltestbase.hxx
index c82ae7c..e079810 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -553,6 +553,7 @@ protected:
 xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST(w14), 
BAD_CAST(http://schemas.microsoft.com/office/word/2010/wordml;));
 xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST(m), 
BAD_CAST(http://schemas.openxmlformats.org/officeDocument/2006/math;));
 xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST(ContentType), 
BAD_CAST(http://schemas.openxmlformats.org/package/2006/content-types;));
+xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST(lc), 
BAD_CAST(http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas;));
 xmlXPathObjectPtr pXmlXpathObj = 
xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx);
 return pXmlXpathObj-nodesetval;
 }
diff --git a/sw/qa/extras/ooxmlexport/data/fdo76249.docx 
b/sw/qa/extras/ooxmlexport/data/fdo76249.docx
new file mode 100644
index 000..9b50f5d
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo76249.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 361b523..918af37 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -937,6 +937,21 @@ DECLARE_OOXMLEXPORT_TEST(testPictureWatermark, 
pictureWatermark.docx)
 assertXPath(pXmlHeader1, 
/w:hdr[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Fallback[1]/w:pict[1]/v:rect[1],id,WordPictureWatermark11962361);
 }
 
+
+DECLARE_OOXMLEXPORT_TEST(testFdo76249, fdo76249.docx)
+{
+/*
+ * The Locked Canvas is imported correctly, but while exporting
+ * the drawing element is exported inside a textbox. However a the drawing 
has to exported
+ * as a Locked Canvas inside a text-box for the RT file to work in MS 
Word, as drawing elements
+ * are not allowed inside the textboxes.
+ */
+xmlDocPtr pXmlDoc = parseExport(word/document.xml);
+if (!pXmlDoc)
+   return;
+assertXPath(pXmlDoc, 

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

2014-03-17 Thread umeshkadam
 oox/source/export/drawingml.cxx |7 -
 sw/qa/extras/ooxmlexport/data/FileWithInvalidImageLink.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx|   13 +
 sw/source/filter/ww8/docxattributeoutput.cxx|   16 +---
 4 files changed, 31 insertions(+), 5 deletions(-)

New commits:
commit 881ca9d48fc67665559484901ce6a670dc331ab8
Author: umeshkadam umesh.ka...@synerzip.com
Date:   Tue Mar 11 20:42:31 2014 +0530

FDO#76013 : If original file has image whose link is broken RT gets 
corrupted.

- The original file contains an image which has invalid link.
- since the link is invalid the import throws an exception while loading
  the image  the link is lost.
- while exporting the system used to write an empty image for an unhandled
  graphic type, which is incorrect and the RT file would result in corrupt.
- Fixed this issue and added UT.

Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/8549

Change-Id: If884f154d1fba921280d63930e7fccb979ea5608

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index aeeff25..7d8ea84 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -779,7 +779,12 @@ OUString DrawingML::WriteImage( const Graphic rGraphic , 
bool bRelPathToMedia )
 pExtension = .emf;
 } else {
 OSL_TRACE( unhandled graphic type );
-break;
+/*Earlier, even in case of unhandled graphic types we were
+  proceeding to write the image, which would eventually
+  write an empty image with a zero size, and return a valid
+  relationID, which is incorrect.
+  */
+return sRelId;
 }
 
 aData = aStream.GetData();
diff --git a/sw/qa/extras/ooxmlexport/data/FileWithInvalidImageLink.docx 
b/sw/qa/extras/ooxmlexport/data/FileWithInvalidImageLink.docx
new file mode 100644
index 000..6ad5cac
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/FileWithInvalidImageLink.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 9a43735..2a2f7c8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2791,6 +2791,19 @@ DECLARE_OOXMLEXPORT_TEST(testFdo76016, fdo76016.docx)
 assertXPath(pXmlDoc, 
//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2], 
name, adj2);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFileWithInvalidImageLink, 
FileWithInvalidImageLink.docx)
+{
+/* In case if the original file has an image whose link is
+   invalid, then the RT file used to result in corruption
+   since the exported image would be an empty image.
+ */
+xmlDocPtr pXmlDoc = parseExport(word/document.xml);
+if (!pXmlDoc)
+  return;
+
+assertXPath(pXmlDoc, 
/w:document/w:body/w:p[2]/w:r[2]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/pic:pic[1]/pic:blipFill[1]/a:blip[1],
 embed, );
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index a380dd0..cfa3b47 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3319,9 +3319,6 @@ void DocxAttributeOutput::FlyFrameGraphic( const 
SwGrfNode* pGrfNode, const Size
 nImageType = XML_embed;
 }
 
-if ( aRelId.isEmpty() )
-return;
-
 m_rExport.SdrExporter().startDMLAnchorInline(pFrmFmt, rSize);
 
 // picture description (used for pic:cNvPr later too)
@@ -3383,7 +3380,18 @@ void DocxAttributeOutput::FlyFrameGraphic( const 
SwGrfNode* pGrfNode, const Size
 // the actual picture
 m_pSerializer-startElementNS( XML_pic, XML_blipFill,
 FSEND );
-m_pSerializer-singleElementNS( XML_a, XML_blip,
+
+/* At this point we are certain that, WriteImage returns empty RelId
+   for unhandled graphic type. Therefore we write the picture description
+   and not the relation( coz there ain't any), so that the user knows
+   there is a image/graphic in the doc but it is broken instead of
+   completely discarding it.
+*/
+if ( aRelId.isEmpty() )
+m_pSerializer-singleElementNS( XML_a, XML_blip,
+FSEND );
+else
+m_pSerializer-singleElementNS( XML_a, XML_blip,
 FSNS( XML_r, nImageType ), aRelId.getStr(),
 FSEND );
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-01-13 Thread YogeshBharate
 oox/source/drawingml/shape.cxx|   23 +-
 sw/qa/extras/ooxmlexport/data/fdo73247.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx  |9 +
 sw/source/filter/ww8/docxattributeoutput.cxx  |   36 +-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |8 +++-
 5 files changed, 72 insertions(+), 4 deletions(-)

New commits:
commit b23867abd8427da361dfa5edb9b41fbbd064ae10
Author: YogeshBharate yogesh.bhar...@synerzip.com
Date:   Fri Jan 10 19:15:10 2014 +0530

fdo#73247: Code fixed for Shape rotation not preserved in RT

Problem Description:
- When we create the shape with text, rotated it with some angle,
the rotation angle is not preserved after roundtrip.

Implementation:
- Use the FrameInteroGrabBag to preserve  the rotation angle.

Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7367

Change-Id: I8a44e82d21f08ecb221cdbfef73f02a652f2bad3

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b191762..9437f02 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -657,7 +657,28 @@ Reference XShape  Shape::createAndInsert(
 }
 aShapeProps.erase(PROP_LineColor);
 }
-
+if(mnRotation)
+{
+uno::Referencebeans::XPropertySet xPropertySet(mxShape, 
uno::UNO_QUERY);
+const OUString aGrabBagPropName = FrameInteropGrabBag;
+uno::Sequencebeans::PropertyValue aGrabBag;
+xPropertySet-getPropertyValue(aGrabBagPropName) = 
aGrabBag;
+beans::PropertyValue aPair;
+aPair.Name = mso-rotation-angle;
+aPair.Value = uno::makeAny(mnRotation);
+if (aGrabBag.hasElements())
+{
+sal_Int32 nLength = aGrabBag.getLength();
+aGrabBag.realloc(nLength + 1);
+aGrabBag[nLength] = aPair;
+}
+else
+{
+aGrabBag.realloc(1);
+aGrabBag[0] = aPair;
+}
+xPropertySet-setPropertyValue(aGrabBagPropName, 
uno::makeAny(aGrabBag));
+}
 // TextFrames have ShadowFormat, not individual shadow 
properties.
 boost::optionalsal_Int32 oShadowDistance;
 if (aShapeProps.hasProperty(PROP_ShadowXDistance))
diff --git a/sw/qa/extras/ooxmlexport/data/fdo73247.docx 
b/sw/qa/extras/ooxmlexport/data/fdo73247.docx
new file mode 100644
index 000..63ad782
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo73247.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 46488de..d4f5e3f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2404,6 +2404,15 @@ DECLARE_OOXMLEXPORT_TEST(testFdo65833, fdo65833.docx)
 assertXPath(pXmlDoc, 
/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:group, 
editas, canvas);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFdo73247, fdo73247.docx)
+{
+xmlDocPtr pXmlDoc = parseExport(word/document.xml);
+if (!pXmlDoc)
+return;
+assertXPath(pXmlDoc, 
/w:document/w:body/w:p[2]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:xfrm,
+rot, 1969698);
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index a94cd68..e498c09 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -304,9 +304,43 @@ void DocxAttributeOutput::WriteDMLTextFrame(sw::Frame* 
pParentFrame)
 XML_txBox, 1,
 FSEND);
 
+uno::Any aRotation ;
+const SdrObject* pSdrObj = rFrmFmt.FindRealSdrObject();
+uno::Reference drawing::XShape  xShape( 
((SdrObject*)pSdrObj)-getUnoShape(), uno::UNO_QUERY );
+uno::Reference beans::XPropertySet  xPropertySet( xShape, uno::UNO_QUERY 
);
+uno::Reference beans::XPropertySetInfo  xPropSetInfo = 
xPropertySet-getPropertySetInfo();
+OUString pName = FrameInteropGrabBag;
+sal_Int32 nRotation = 0;
+
+if ( xPropSetInfo-hasPropertyByName( pName ) )
+{
+uno::Sequence beans::PropertyValue  propList;
+xPropertySet-getPropertyValue( pName ) = propList;
+for ( sal_Int32 nProp=0; nProp  propList.getLength(); ++nProp )
+{
+OUString propName = propList[nProp].Name;
+if ( propName == mso-rotation-angle)
+{
+aRotation = propList[nProp].Value ;
+break;
+   

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

2014-01-06 Thread sushil_shinde
 oox/source/drawingml/shape.cxx |6 ++
 oox/source/export/drawingml.cxx|2 
 sw/qa/extras/ooxmlexport/data/textbox_picturefill.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx   |7 ++
 sw/source/filter/ww8/docxattributeoutput.cxx   |   41 -
 5 files changed, 45 insertions(+), 11 deletions(-)

New commits:
commit 854d7a1cc77b82ef6b5d72a7889743c1ebe6fe6e
Author: sushil_shinde sushil.shi...@synerzip.com
Date:   Thu Jan 2 16:31:26 2014 +0530

fdo#73217  : Textbox with picture fill are rendered and saved properly.

   - Bitmap url was not stored propertly for textframes.
   - Exported background image fill for text box properly.
   - Added unit test.

Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7259

Change-Id: I1fbab24b2a83b22be04fd6950c80ddf274436738

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b42e27e..b191762 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -633,6 +633,12 @@ Reference XShape  Shape::createAndInsert(
 aShapeProps.setProperty(PROP_BackColorTransparency, 
aShapeProps[PROP_FillTransparence]);
 aShapeProps.erase(PROP_FillTransparence);
 }
+// TextFrames have BackGrahicURL, not FillBitmapURL
+if (aShapeProps.hasProperty(PROP_FillBitmapURL))
+{
+aShapeProps.setProperty(PROP_BackGraphicURL, 
aShapeProps[PROP_FillBitmapURL]);
+aShapeProps.erase(PROP_FillBitmapURL);
+}
 // And no LineColor property; individual borders can have 
colors
 if (aShapeProps.hasProperty(PROP_LineColor))
 {
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 030beb5..b533d747 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -608,7 +608,7 @@ void DrawingML::WriteBlipFill( Reference XPropertySet  
rXPropSet, OUString sUR
 
 WriteBlip( rXPropSet, aURL );
 
-if( sURLPropName == FillBitmapURL )
+if( sURLPropName == FillBitmapURL || sURLPropName == 
BackGraphicURL)
 WriteBlipMode( rXPropSet );
 else if( GetProperty( rXPropSet, FillBitmapStretch ) ) {
 bool bStretch = false;
diff --git a/sw/qa/extras/ooxmlexport/data/textbox_picturefill.docx 
b/sw/qa/extras/ooxmlexport/data/textbox_picturefill.docx
new file mode 100644
index 000..f4fab1b
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/textbox_picturefill.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 126516f..dc8726c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2253,6 +2253,13 @@ DECLARE_OOXMLEXPORT_TEST(testFdo69649, fdo69649.docx)
 CPPUNIT_ASSERT(contents.match(15));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTextBoxPictureFill, textbox_picturefill.docx)
+{
+uno::Referencebeans::XPropertySet xFrame(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, 
getPropertydrawing::FillStyle(xFrame, FillStyle));
+
CPPUNIT_ASSERT(!(getPropertyOUString(xFrame,BackGraphicURL)).isEmpty());
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index d1d617e..0aa7e36 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5716,16 +5716,29 @@ void DocxAttributeOutput::FormatBackground( const 
SvxBrushItem rBrush )
 }
 else if (m_bDMLTextFrameSyntax)
 {
-m_pSerializer-startElementNS(XML_a, XML_solidFill, FSEND);
-m_pSerializer-startElementNS(XML_a, XML_srgbClr,
-  XML_val, sColor,
-  FSEND);
-if (oAlpha)
-m_pSerializer-singleElementNS(XML_a, XML_alpha,
-   XML_val, OString::number(*oAlpha),
-   FSEND);
-m_pSerializer-endElementNS(XML_a, XML_srgbClr);
-m_pSerializer-endElementNS(XML_a, XML_solidFill);
+bool bImageBackground = false;
+const SfxPoolItem* pItem = GetExport().HasItem(RES_FILL_STYLE);
+if (pItem)
+{
+const XFillStyleItem* pFillStyle = static_castconst 
XFillStyleItem*(pItem);
+if(pFillStyle-GetValue() == XFILL_BITMAP)
+{
+bImageBackground = true;
+}
+}
+if (!bImageBackground)
+{
+m_pSerializer-startElementNS(XML_a, XML_solidFill, FSEND);
+m_pSerializer-startElementNS(XML_a, XML_srgbClr,
+ 

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

2013-11-12 Thread sushil_shinde
 oox/source/export/vmlexport.cxx   |9 +++--
 sw/qa/extras/ooxmlexport/data/image_data.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx  |8 
 sw/source/filter/ww8/docxattributeoutput.cxx  |4 ++--
 4 files changed, 17 insertions(+), 4 deletions(-)

New commits:
commit 965d29d00eb14250a994393f5d6b437e49760830
Author: sushil_shinde sushil.shi...@synerzip.com
Date:   Mon Oct 21 21:34:55 2013 +0530

 #65836- Fix for exporting image inside vml data was corrupting file.

- Handled exporting of image for all type of format in vmlexport.
- fixed issue - .rels file was not getting exported for vmlexport.
- Not handled for .wmf image (will work on it)

Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/6369

Change-Id: I9ccf7a36ae316a658f06d1074caa4e4b2f5d271f

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 6274e19..8eeb9dc 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -555,6 +555,7 @@ void VMLExport::Commit( EscherPropertyContainer rProps, 
const Rectangle rRect
 if ( rProps.GetOpt( ESCHER_Prop_fillBackColor, nValue ) )
 impl_AddColor( pAttrList, XML_color2, nValue );
 
+bool imageData = false;
 EscherPropSortStruct aStruct;
 if ( rProps.GetOpt( ESCHER_Prop_fillBlip, aStruct )  
m_pTextExport)
 {
@@ -563,9 +564,10 @@ void VMLExport::Commit( EscherPropertyContainer rProps, 
const Rectangle rRect
 aStream.Write(aStruct.pBuf + nHeaderSize, 
aStruct.nPropSize - nHeaderSize);
 aStream.Seek(0);
 Graphic aGraphic;
-GraphicConverter::Import(aStream, aGraphic, CVT_PNG);
+GraphicConverter::Import(aStream, aGraphic);
 OUString aImageId = 
m_pTextExport-GetDrawingML().WriteImage( aGraphic );
 pAttrList-add(FSNS(XML_r, XML_id), 
OUStringToOString(aImageId, RTL_TEXTENCODING_UTF8));
+imageData = true;
 }
 
 if ( rProps.GetOpt( ESCHER_Prop_fNoFillHitTest, nValue ) )
@@ -575,7 +577,10 @@ void VMLExport::Commit( EscherPropertyContainer rProps, 
const Rectangle rRect
 // Partly undo the transformation at the end of 
EscherPropertyContainer::CreateFillProperties(): VML opacity is 0..1.
 pAttrList-add(XML_opacity, 
OString::number(double((nValue * 100)  16) / 100));
 
-m_pSerializer-singleElementNS( XML_v, XML_fill, 
XFastAttributeListRef( pAttrList ) );
+if (imageData)
+m_pSerializer-singleElementNS( XML_v, XML_imagedata, 
XFastAttributeListRef( pAttrList ) );
+else
+m_pSerializer-singleElementNS( XML_v, XML_fill, 
XFastAttributeListRef( pAttrList ) );
 }
 bAlreadyWritten[ ESCHER_Prop_fillType ] = true;
 bAlreadyWritten[ ESCHER_Prop_fillColor ] = true;
diff --git a/sw/qa/extras/ooxmlexport/data/image_data.docx 
b/sw/qa/extras/ooxmlexport/data/image_data.docx
new file mode 100644
index 000..a2f89b1
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/image_data.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index c19a70a..94b48a0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1588,6 +1588,14 @@ DECLARE_OOXML_TEST(testVMLData, TestVMLData.docx)
 CPPUNIT_ASSERT(getXPath(pXmlDoc, /w:hdr/w:p/w:r/w:pict/v:shape, 
stroked).match(f));
 }
 
+DECLARE_OOXML_TEST(testImageData, image_data.docx)
+{
+// The problem was exporter was exporting v:imagedata data for shape in 
w:pict as v:fill w element.
+
+xmlDocPtr pXmlDoc = parseExport(word/header1.xml);
+CPPUNIT_ASSERT(getXPath(pXmlDoc, 
/w:hdr/w:p/w:r/w:pict/v:shape/v:imagedata, detectmouseclick).match(t));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 19f80e7..2712f75 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1158,7 +1158,7 @@ void DocxAttributeOutput::EndRunProperties( const 
SwRedlineData* pRedlineData )
 //We need to write w:drawing tag after the w:rPr.
 WritePostponedChart();
 
-//We need to write w:drawing tag after the w:rPr.
+//We need to write w:pict tag after the w:rPr.
 WritePostponedVMLDrawing();
 
 // merge the properties _before_ the run text (strictly speaking, just
@@ -3260,7 +3260,7 @@ void DocxAttributeOutput::WriteVMLDrawing( const 
SdrObject* sdrObj, 

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

2013-07-10 Thread Adam Co
 oox/source/token/properties.txt  |1 
 oox/source/vml/vmlshape.cxx  |6 +++
 sw/qa/extras/ooxmlexport/data/fdo66688.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx |   12 ++
 sw/source/filter/ww8/docxattributeoutput.cxx |   50 +++
 5 files changed, 63 insertions(+), 6 deletions(-)

New commits:
commit 728f10576807970b3356eb0d5ad01722b977
Author: Adam Co rattles2...@gmail.com
Date:   Tue Jul 9 10:18:05 2013 +0300

fdo#66688: fix for crash on exit and opacity issue

Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx

Change-Id: I32db54e2c49b40bf41005baeba380a4f631d615a
Reviewed-on: https://gerrit.libreoffice.org/4780

diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 0acfe06..d89ae44 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -20,6 +20,7 @@ AutoFilter
 AutoShowInfo
 Autocomplete
 BackColor
+BackColorTransparency
 BackGraphicLocation
 BackGraphicURL
 Background
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index efd5d75..bcf93b6 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -390,6 +390,12 @@ void ShapeBase::convertShapeProperties( const Reference 
XShape  rxShape ) con
 aPropMap.setProperty(PROP_BackColor, aPropMap[PROP_FillColor]);
 aPropMap.erase(PROP_FillColor);
 }
+// TextFrames have BackColorTransparency, not FillTransparence
+if (aPropMap.hasProperty(PROP_FillTransparence))
+{
+aPropMap.setProperty(PROP_BackColorTransparency, 
aPropMap[PROP_FillTransparence]);
+aPropMap.erase(PROP_FillTransparence);
+}
 // And no LineColor property; individual borders can have colors and 
widths
 boost::optionalsal_Int32 oLineWidth;
 if (maTypeModel.maStrokeModel.moWeight.has())
diff --git a/sw/qa/extras/ooxmlexport/data/fdo66688.docx 
b/sw/qa/extras/ooxmlexport/data/fdo66688.docx
new file mode 100644
index 000..300b915
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo66688.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 7230a4c..6b65c90 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -89,6 +89,7 @@ public:
 void testFdo65400();
 void testFdo66543();
 void testN822175();
+void testFdo66688();
 
 CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX)  !defined(WNT)
@@ -150,6 +151,7 @@ void Test::run()
 {fdo65400.docx, Test::testFdo65400},
 {fdo66543.docx, Test::testFdo66543},
 {n822175.odt, Test::testN822175},
+{fdo66688.docx, Test::testFdo66688},
 };
 // Don't test the first import of these, for some reason those tests fail
 const char* aBlacklist[] = {
@@ -902,6 +904,16 @@ void Test::testN822175()
 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_PARALLEL, 
getPropertytext::WrapTextMode(xFrame, Surround));
 }
 
+void Test::testFdo66688()
+{
+// The problem was that TextFrame imported and exported the wrong value 
for transparency
+// (was stored as 'FillTransparence' instead of 'BackColorTransparency'
+uno::Referencetext::XTextFramesSupplier xFramesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Referencecontainer::XIndexAccess 
xIndexAccess(xFramesSupplier-getTextFrames(), uno::UNO_QUERY);
+uno::Referencebeans::XPropertySet xFrame(xIndexAccess-getByIndex(0), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL( sal_Int32( 80 ), getProperty sal_Int32 ( xFrame, 
BackColorTransparency ) );
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 6bd05a4..5a0f8a0 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -32,6 +32,7 @@
 #include oox/token/tokens.hxx
 #include oox/export/utils.hxx
 #include oox/mathml/export.hxx
+#include oox/drawingml/drawingmltypes.hxx
 
 #include i18nlangtag/languagetag.hxx
 
@@ -4857,7 +4858,32 @@ void DocxAttributeOutput::FormatBackground( const 
SvxBrushItem rBrush )
 {
 OString sColor = msfilter::util::ConvertColor( rBrush.GetColor( ) );
 if (m_bTextFrameSyntax)
+{
+// Handle 'Opacity'
+sal_Int32 nTransparency = rBrush.GetColor().GetTransparency();
+if (nTransparency)
+{
+// Convert transparency to percent
+// Consider editeng/source/items/frmitems.cxx : 
lcl_TransparencyToPercent() function.
+sal_Int8 nTransparencyPercent = (sal_Int8)((nTransparency * 100 + 
127) / 254);
+
+// Calculate alpha value
+// Consider oox/source/drawingml/color.cxx : getTransparency() 
function.
+sal_Int32 nAlpha = (::oox::drawingml::MAX_PERCENT - (