Kaydet (Commit) c14be5f5 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

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 96c7ab19
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/42088Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 020c3eeb
......@@ -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)
......
......@@ -9,6 +9,7 @@
#include <swmodeltestbase.hxx>
#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <com/sun/star/text/XFootnote.hpp>
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment