fdo#66929: fix for default textbox inset values
Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Change-Id: I0e9fa5e73e802f85f02c3fcc5c276ed0c1cb2a58
This commit is contained in:
parent
56ee768bfd
commit
1a37ca65b8
@ -171,18 +171,27 @@ TextBoxContext::TextBoxContext( ContextHandler2Helper& rParent, TextBox& rTextBo
|
|||||||
{
|
{
|
||||||
OUString inset = rAttribs.getString( XML_inset ).get();
|
OUString inset = rAttribs.getString( XML_inset ).get();
|
||||||
OUString value;
|
OUString value;
|
||||||
ConversionHelper::separatePair( value, inset, inset, ',' );
|
OUString remainingStr;
|
||||||
|
|
||||||
|
ConversionHelper::separatePair( value, remainingStr, inset, ',' );
|
||||||
rTextBox.borderDistanceLeft = ConversionHelper::decodeMeasureToHmm( graphicHelper,
|
rTextBox.borderDistanceLeft = ConversionHelper::decodeMeasureToHmm( graphicHelper,
|
||||||
value.isEmpty() ? "0.1in" : value, 0, false, false );
|
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,
|
rTextBox.borderDistanceTop = ConversionHelper::decodeMeasureToHmm( graphicHelper,
|
||||||
value.isEmpty() ? "0.05in" : value, 0, false, false );
|
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,
|
rTextBox.borderDistanceRight = ConversionHelper::decodeMeasureToHmm( graphicHelper,
|
||||||
value.isEmpty() ? "0.1in" : value, 0, false, false );
|
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,
|
rTextBox.borderDistanceBottom = ConversionHelper::decodeMeasureToHmm( graphicHelper,
|
||||||
value.isEmpty() ? "0.05in" : value, 0, false, false );
|
value.isEmpty() ? "0.05in" : value, 0, false, false );
|
||||||
|
|
||||||
rTextBox.borderDistanceSet = true;
|
rTextBox.borderDistanceSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
sw/qa/extras/ooxmlexport/data/fdo66929.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/fdo66929.docx
Normal file
Binary file not shown.
@ -95,6 +95,7 @@ public:
|
|||||||
void testFdo66773();
|
void testFdo66773();
|
||||||
void testFdo58577();
|
void testFdo58577();
|
||||||
void testBnc581614();
|
void testBnc581614();
|
||||||
|
void testFdo66929();
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(Test);
|
CPPUNIT_TEST_SUITE(Test);
|
||||||
#if !defined(MACOSX) && !defined(WNT)
|
#if !defined(MACOSX) && !defined(WNT)
|
||||||
@ -160,6 +161,7 @@ void Test::run()
|
|||||||
{"fdo66773.docx", &Test::testFdo66773},
|
{"fdo66773.docx", &Test::testFdo66773},
|
||||||
{"fdo58577.odt", &Test::testFdo58577},
|
{"fdo58577.odt", &Test::testFdo58577},
|
||||||
{"bnc581614.doc", &Test::testBnc581614},
|
{"bnc581614.doc", &Test::testBnc581614},
|
||||||
|
{"fdo66929.docx", &Test::testFdo66929},
|
||||||
};
|
};
|
||||||
// Don't test the first import of these, for some reason those tests fail
|
// Don't test the first import of these, for some reason those tests fail
|
||||||
const char* aBlacklist[] = {
|
const char* aBlacklist[] = {
|
||||||
@ -953,6 +955,20 @@ void Test::testBnc581614()
|
|||||||
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
|
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_TEST_SUITE_REGISTRATION(Test);
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@ -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;
|
OStringBuffer aInset;
|
||||||
aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_LEFT))/20) + "pt,");
|
if(!aInset.isEmpty() || aDistanceBottomInch != double(0.05))
|
||||||
aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_TOP))/20) + "pt,");
|
aInset.insert(0, "," + OString::number(aDistanceBottomInch) + "in");
|
||||||
aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_RIGHT))/20) + "pt,");
|
|
||||||
aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_BOTTOM))/20) + "pt");
|
if(!aInset.isEmpty() || aDistanceRightInch != double(0.1))
|
||||||
m_pTextboxAttrList->add(XML_inset, aInset.makeStringAndClear());
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user