summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/DomainMapper_Impl.cxx
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-04-13 10:59:29 -0400
committerJustin Luth <jluth@mail.com>2023-04-16 03:50:57 +0200
commit1d12d12598927ef8a74dd648632112ceb16bdf78 (patch)
tree3e063637900d71b95eae8eec49dab032fae83632 /writerfilter/source/dmapper/DomainMapper_Impl.cxx
parent96c4c0fcffc4f0a1f5a49be576646d15d613228e (diff)
tdf#154703 DOCX {im,ex}port framePr: adjust framesize by para spacing
The specified frame size does not seem to account for left and right paragraph border spacing. At first I assumed it was just RTF, but DOCX needed it as well. This is all VERY nasty. In practice, the paragraph border spacing normally matches the frame's border spacing, but not necessarily. Plus, the user might have interferred. MS Word must know that this is a special kind of frame. LO doesn't. To handle this properly, LO frame UI would need to adjust ALL of the paragraphs' border properties when any changes are made to the frame. For the present, we have to import the frame properly, and export as well as possible. RTF export is losing paragraph borders already, so it has been excluded from consideration. No other unit tests were found that had a significant border spacing. make CppunitTest_sw_ooxmlexport10 CPPUNIT_TEST_NAME=testLibreOfficeHang Change-Id: I03d801ff0ec3c2b93a77761da8ad1f43aeaacf42 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150357 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapper_Impl.cxx')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx31
1 files changed, 29 insertions, 2 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 068347f52347..3bca3186ca82 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1554,6 +1554,21 @@ static void lcl_MoveBorderPropertiesToFrame(std::vector<beans::PropertyValue>& r
PROP_BOTTOM_BORDER_DISTANCE
};
+ // The frame width specified does not include border spacing,
+ // so the frame needs to be increased by the left/right para border spacing amount
+ sal_Int32 nWidth = 0;
+ sal_Int32 nIndexOfWidthProperty = -1;
+ sal_Int16 nType = text::SizeType::FIX;
+ for (size_t i = 0; nType == text::SizeType::FIX && i < rFrameProperties.size(); ++i)
+ {
+ if (rFrameProperties[i].Name == "WidthType")
+ rFrameProperties[i].Value >>= nType;
+ else if (rFrameProperties[i].Name == "Width")
+ nIndexOfWidthProperty = i;
+ }
+ if (nIndexOfWidthProperty > -1 && nType == text::SizeType::FIX)
+ rFrameProperties[nIndexOfWidthProperty].Value >>= nWidth;
+
for( size_t nProperty = 0; nProperty < SAL_N_ELEMENTS( aBorderProperties ); ++nProperty)
{
OUString sPropertyName = getPropertyName(aBorderProperties[nProperty]);
@@ -1562,11 +1577,23 @@ static void lcl_MoveBorderPropertiesToFrame(std::vector<beans::PropertyValue>& r
aValue.Value = xTextRangeProperties->getPropertyValue(sPropertyName);
if( nProperty < 4 )
xTextRangeProperties->setPropertyValue( sPropertyName, uno::Any(table::BorderLine2()));
- else if (nProperty > 5 || bIsRTFImport)
+ else // border spacing
{
+ sal_Int32 nDistance = 0;
+ aValue.Value >>= nDistance;
+
// left4/right5 need to be duplicated because of INVERT_BORDER_SPACING (DOCX only)
// Do not duplicate the top6/bottom7 border spacing.
- aValue.Value <<= sal_Int32(0);
+ if (nProperty > 5 || bIsRTFImport)
+ aValue.Value <<= sal_Int32(0);
+
+ // frames need to be increased by the left/right para border spacing amount
+ // This is needed for RTF as well, but that requires other export/import fixes.
+ if (!bIsRTFImport && nProperty < 6 && nWidth && nDistance)
+ {
+ nWidth += nDistance;
+ rFrameProperties[nIndexOfWidthProperty].Value <<= nWidth;
+ }
}
if (aValue.Value.hasValue())
rFrameProperties.push_back(aValue);