diff options
author | Adam Co <rattles2013@gmail.com> | 2013-07-15 18:40:08 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-07-16 09:46:48 +0200 |
commit | 1a37ca65b896a5ba100d46c7cde0793f62bc546b (patch) | |
tree | 555972e7a4d59217516dc1a2c52d1cf9e78cab6b | |
parent | 56ee768bfd912c3c4278056a4712c1108ec38af4 (diff) |
fdo#66929: fix for default textbox inset values
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Change-Id: I0e9fa5e73e802f85f02c3fcc5c276ed0c1cb2a58
-rw-r--r-- | oox/source/vml/vmltextboxcontext.cxx | 17 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo66929.docx | bin | 0 -> 21624 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 16 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 37 |
4 files changed, 60 insertions, 10 deletions
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx index d91c66ade821..fbb701f67ca5 100644 --- a/oox/source/vml/vmltextboxcontext.cxx +++ b/oox/source/vml/vmltextboxcontext.cxx @@ -171,18 +171,27 @@ TextBoxContext::TextBoxContext( ContextHandler2Helper& rParent, TextBox& rTextBo { OUString inset = rAttribs.getString( XML_inset ).get(); OUString value; - ConversionHelper::separatePair( value, inset, inset, ',' ); + OUString remainingStr; + + ConversionHelper::separatePair( value, remainingStr, inset, ',' ); rTextBox.borderDistanceLeft = ConversionHelper::decodeMeasureToHmm( graphicHelper, value.isEmpty() ? "0.1in" : value, 0, false, false ); - ConversionHelper::separatePair( value, inset, inset, ',' ); + + inset = remainingStr; + ConversionHelper::separatePair( value, remainingStr, inset, ',' ); rTextBox.borderDistanceTop = ConversionHelper::decodeMeasureToHmm( graphicHelper, value.isEmpty() ? "0.05in" : value, 0, false, false ); - ConversionHelper::separatePair( value, inset, inset, ',' ); + + inset = remainingStr; + ConversionHelper::separatePair( value, remainingStr, inset, ',' ); rTextBox.borderDistanceRight = ConversionHelper::decodeMeasureToHmm( graphicHelper, value.isEmpty() ? "0.1in" : value, 0, false, false ); - ConversionHelper::separatePair( value, inset, inset, ',' ); + + inset = remainingStr; + ConversionHelper::separatePair( value, remainingStr, inset, ',' ); rTextBox.borderDistanceBottom = ConversionHelper::decodeMeasureToHmm( graphicHelper, value.isEmpty() ? "0.05in" : value, 0, false, false ); + rTextBox.borderDistanceSet = true; } diff --git a/sw/qa/extras/ooxmlexport/data/fdo66929.docx b/sw/qa/extras/ooxmlexport/data/fdo66929.docx Binary files differnew file mode 100644 index 000000000000..7f0afac3cb00 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo66929.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ff5dc8f7e2ee..86d6e39efe5b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -95,6 +95,7 @@ public: void testFdo66773(); void testFdo58577(); void testBnc581614(); + void testFdo66929(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -160,6 +161,7 @@ void Test::run() {"fdo66773.docx", &Test::testFdo66773}, {"fdo58577.odt", &Test::testFdo58577}, {"bnc581614.doc", &Test::testBnc581614}, + {"fdo66929.docx", &Test::testFdo66929}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -953,6 +955,20 @@ void Test::testBnc581614() CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xFrame, "FillStyle")); } +void Test::testFdo66929() +{ + // The problem was that the default 'inset' attribute of the 'textbox' node was exported incorrectly. + // A node like '<v:textbox inset="0">' was exported back as '<v:textbox inset="0pt,0pt,0pt,0pt">' + // This is wrong because the original node denotes a specific 'left' inset, and a default 'top','right','bottom' inset + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + uno::Reference<beans::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" ) ); +} + 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 1c0e257f35ce..768235ee90a5 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4965,13 +4965,38 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) } } - // v:textbox's inset attribute: inner margin values for textbox text + // v:textbox's inset attribute: inner margin values for textbox text - write only non-default values + double aDistanceLeftTwips = double(rBox.GetDistance(BOX_LINE_LEFT)); + double aDistanceTopTwips = double(rBox.GetDistance(BOX_LINE_TOP)); + double aDistanceRightTwips = double(rBox.GetDistance(BOX_LINE_RIGHT)); + double aDistanceBottomTwips = double(rBox.GetDistance(BOX_LINE_BOTTOM)); + + // Convert 'TWIPS' to 'INCH' (because in Word the default values are in Inches) + double aDistanceLeftInch = aDistanceLeftTwips / 1440; + double aDistanceTopInch = aDistanceTopTwips / 1440; + double aDistanceRightInch = aDistanceRightTwips / 1440; + double aDistanceBottomInch = aDistanceBottomTwips / 1440; + + // This code will write ONLY the non-default values. The values are in 'left','top','right','bottom' order. + // so 'bottom' is checked if it is default and if it is non-default - all the values will be written + // otherwise - 'right' is checked if it is default and if it is non-default - all the values except for 'bottom' will be written + // and so on. OStringBuffer aInset; - aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_LEFT))/20) + "pt,"); - aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_TOP))/20) + "pt,"); - aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_RIGHT))/20) + "pt,"); - aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_BOTTOM))/20) + "pt"); - m_pTextboxAttrList->add(XML_inset, aInset.makeStringAndClear()); + if(!aInset.isEmpty() || aDistanceBottomInch != double(0.05)) + aInset.insert(0, "," + OString::number(aDistanceBottomInch) + "in"); + + if(!aInset.isEmpty() || aDistanceRightInch != double(0.1)) + aInset.insert(0, "," + OString::number(aDistanceRightInch) + "in"); + + if(!aInset.isEmpty() || aDistanceTopInch != double(0.05)) + aInset.insert(0, "," + OString::number(aDistanceTopInch) + "in"); + + if(!aInset.isEmpty() || aDistanceLeftInch != double(0.1)) + aInset.insert(0, OString::number(aDistanceLeftInch) + "in"); + + if (!aInset.isEmpty()) + m_pTextboxAttrList->add(XML_inset, aInset.makeStringAndClear()); + return; } |