[Libreoffice-commits] core.git: 2 commits - oox/source sw/qa sw/source
Miklos Vajna
vmiklos at suse.cz
Tue Jul 16 00:47:33 PDT 2013
oox/source/vml/vmltextboxcontext.cxx | 17 +++++++++---
sw/qa/extras/ooxmlexport/data/fdo66929.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 16 +++++++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 37 ++++++++++++++++++++++-----
4 files changed, 60 insertions(+), 10 deletions(-)
New commits:
commit db610b4a9202a9bb6393b1bcfc7dd56d21bd8112
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jul 16 09:43:56 2013 +0200
DocxAttributeOutput: avoid 'a' prefix for double
Change-Id: I1601f2d2926ca62aae8e7c48b1b2147ebed01002
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 768235e..0169cf8 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4966,33 +4966,33 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
}
// 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));
+ double fDistanceLeftTwips = double(rBox.GetDistance(BOX_LINE_LEFT));
+ double fDistanceTopTwips = double(rBox.GetDistance(BOX_LINE_TOP));
+ double fDistanceRightTwips = double(rBox.GetDistance(BOX_LINE_RIGHT));
+ double fDistanceBottomTwips = 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;
+ double fDistanceLeftInch = fDistanceLeftTwips / 1440;
+ double fDistanceTopInch = fDistanceTopTwips / 1440;
+ double fDistanceRightInch = fDistanceRightTwips / 1440;
+ double fDistanceBottomInch = fDistanceBottomTwips / 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;
- if(!aInset.isEmpty() || aDistanceBottomInch != double(0.05))
- aInset.insert(0, "," + OString::number(aDistanceBottomInch) + "in");
+ if(!aInset.isEmpty() || fDistanceBottomInch != double(0.05))
+ aInset.insert(0, "," + OString::number(fDistanceBottomInch) + "in");
- if(!aInset.isEmpty() || aDistanceRightInch != double(0.1))
- aInset.insert(0, "," + OString::number(aDistanceRightInch) + "in");
+ if(!aInset.isEmpty() || fDistanceRightInch != double(0.1))
+ aInset.insert(0, "," + OString::number(fDistanceRightInch) + "in");
- if(!aInset.isEmpty() || aDistanceTopInch != double(0.05))
- aInset.insert(0, "," + OString::number(aDistanceTopInch) + "in");
+ if(!aInset.isEmpty() || fDistanceTopInch != double(0.05))
+ aInset.insert(0, "," + OString::number(fDistanceTopInch) + "in");
- if(!aInset.isEmpty() || aDistanceLeftInch != double(0.1))
- aInset.insert(0, OString::number(aDistanceLeftInch) + "in");
+ if(!aInset.isEmpty() || fDistanceLeftInch != double(0.1))
+ aInset.insert(0, OString::number(fDistanceLeftInch) + "in");
if (!aInset.isEmpty())
m_pTextboxAttrList->add(XML_inset, aInset.makeStringAndClear());
commit 1a37ca65b896a5ba100d46c7cde0793f62bc546b
Author: Adam Co <rattles2013 at gmail.com>
Date: Mon Jul 15 18:40:08 2013 +0300
fdo#66929: fix for default textbox inset values
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Change-Id: I0e9fa5e73e802f85f02c3fcc5c276ed0c1cb2a58
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index d91c66a..fbb701f 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
new file mode 100644
index 0000000..7f0afac
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo66929.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ff5dc8f..86d6e39 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 1c0e257..768235e 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;
}
More information about the Libreoffice-commits
mailing list