summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2016-09-01 11:19:56 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-09-02 12:36:41 +0000
commit52b29c60801cf75364fd8275a22e812797cb184d (patch)
tree3943f82d250b0b8adeb6cb555edf58dd1c061285
parent91733eff7fba157daf88b092189d842f9d6f1b68 (diff)
tdf#76349 SpacingWithoutBorders: enable .doc RT
Microsoft allows spacing in textboxes even if the borders are not shown, but LO does not. Added a compatible setting, used an existing setting to allow the spacing, and changed .doc export not to zero out the spacing if the border was zero-width. Using the compatible setting in the export code is almost redundant, but it does require that the document was LOADED as .doc, and not "save as" from another format. This patch simply allows round-tripping - any user attempt to modify the border settings will enforce normal LO border rules. Change-Id: I60ac036e1bfac381eea15e33c21495ad3800277a Reviewed-on: https://gerrit.libreoffice.org/28601 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/inc/IDocumentSettingAccess.hxx1
-rwxr-xr-xsw/qa/extras/ww8export/data/tdf76349_textboxMargins.docbin0 -> 23552 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export.cxx6
-rw-r--r--sw/source/core/doc/DocumentSettingManager.cxx5
-rw-r--r--sw/source/core/inc/DocumentSettingManager.hxx3
-rw-r--r--sw/source/core/layout/frmtool.cxx10
-rw-r--r--sw/source/filter/ww8/wrtw8esh.cxx16
-rw-r--r--sw/source/filter/ww8/ww8par.cxx1
-rw-r--r--sw/source/uibase/uno/SwXDocumentSettings.cxx13
9 files changed, 49 insertions, 6 deletions
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index f16ae42f30dc..b158f443e3d9 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -39,6 +39,7 @@ enum class DocumentSettingId
ADD_FLY_OFFSETS,
ADD_VERTICAL_FLY_OFFSETS,
+ ALLOW_SPACING_WITHOUT_BORDERS,
OLD_NUMBERING,
ADD_EXT_LEADING,
diff --git a/sw/qa/extras/ww8export/data/tdf76349_textboxMargins.doc b/sw/qa/extras/ww8export/data/tdf76349_textboxMargins.doc
new file mode 100755
index 000000000000..95bc59807f94
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf76349_textboxMargins.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index f8fc27a5df69..7d3cf22131ec 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -734,6 +734,12 @@ DECLARE_WW8EXPORT_TEST(testTdf91083_tableKeep, "tdf91083_tableKeep.doc")
CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTable, "Split"));
}
+DECLARE_WW8EXPORT_TEST(testTdf76349_textboxMargins, "tdf76349_textboxMargins.doc")
+{
+ // textboxes without borders were losing their spacing items in round-tripping
+ CPPUNIT_ASSERT( 0 < parseDump("/root/page/body/txt/anchored/fly/infos/prtBounds", "left").toInt32() );
+}
+
DECLARE_WW8EXPORT_TEST(testMoveRange, "fdo66304-1.odt")
{
//the save must survive without asserting
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index 5cf29c0a4e8a..0055c7da3799 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -55,6 +55,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
mbAddFlyOffsets(false),
mbAddVerticalFlyOffsets(false),
+ mbAllowSpacingWithoutBorders( false ),
mbUseHiResolutionVirtualDevice(true),
mbMathBaselineAlignment(false), // default for *old* documents is 'off'
mbStylesNoDefault(false),
@@ -146,6 +147,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
case DocumentSettingId::TAB_COMPAT: return mbTabCompat; //(n8Dummy1 & DUMMY_TAB_COMPAT);
case DocumentSettingId::ADD_FLY_OFFSETS: return mbAddFlyOffsets; //(n8Dummy2 & DUMMY_ADD_FLY_OFFSETS);
case DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS: return mbAddVerticalFlyOffsets;
+ case DocumentSettingId::ALLOW_SPACING_WITHOUT_BORDERS: return mbAllowSpacingWithoutBorders;
case DocumentSettingId::ADD_EXT_LEADING: return mbAddExternalLeading; //(n8Dummy2 & DUMMY_ADD_EXTERNAL_LEADING);
case DocumentSettingId::USE_VIRTUAL_DEVICE: return mbUseVirtualDevice; //(n8Dummy1 & DUMMY_USE_VIRTUAL_DEVICE);
case DocumentSettingId::USE_HIRES_VIRTUAL_DEVICE: return mbUseHiResolutionVirtualDevice; //(n8Dummy2 & DUMMY_USE_HIRES_VIR_DEV);
@@ -221,6 +223,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
case DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS:
mbAddVerticalFlyOffsets = value;
break;
+ case DocumentSettingId::ALLOW_SPACING_WITHOUT_BORDERS:
+ mbAllowSpacingWithoutBorders = value;
+ break;
case DocumentSettingId::ADD_EXT_LEADING:
mbAddExternalLeading = value;
break;
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index b971cc568588..4159f5adde0a 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -109,6 +109,7 @@ class DocumentSettingManager :
bool mbUseVirtualDevice : 1;
bool mbAddFlyOffsets : 1;
bool mbAddVerticalFlyOffsets : 1;
+ bool mbAllowSpacingWithoutBorders : 1; // tdf#41542
bool mbAddExternalLeading : 1;
bool mbUseHiResolutionVirtualDevice : 1;
bool mbOldLineSpacing : 1; // #i11859#
@@ -147,7 +148,7 @@ class DocumentSettingManager :
bool mbClippedPictures;
bool mbBackgroundParaOverDrawings;
bool mbTabOverMargin;
- bool mbTreatSingleColumnBreakAsPageBreak;
+ bool mbTreatSingleColumnBreakAsPageBreak; // tdf#76349
bool mbSurroundTextWrapSmall;
bool mbPropLineSpacingShrinksFirstLine; // fdo#79602
bool mbSubtractFlys; // tdf#86578
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index b69d987b5348..1e98d75d9ab7 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1834,7 +1834,15 @@ SwBorderAttrs::SwBorderAttrs(const SwModify *pMod, const SwFrame *pConstructor)
m_bCachedJoinedWithPrev = false;
m_bCachedJoinedWithNext = false;
- m_bBorderDist = bool(pConstructor->GetType() & SwFrameType::Cell);
+ bool bAllowSpacingWithoutBorders = false;
+ if( (pConstructor->GetType() & SwFrameType::Fly)
+ && pConstructor->IsLayoutFrame()
+ && pConstructor->GetLower() && pConstructor->GetLower()->IsTextFrame() )
+ {
+ const SwFrameFormat* pFormat = static_cast<const SwLayoutFrame*>(pConstructor)->GetFormat();
+ bAllowSpacingWithoutBorders = pFormat->getIDocumentSettingAccess().get(DocumentSettingId::ALLOW_SPACING_WITHOUT_BORDERS);
+ }
+ m_bBorderDist = bool(pConstructor->GetType() & SwFrameType::Cell) || bAllowSpacingWithoutBorders;
}
SwBorderAttrs::~SwBorderAttrs()
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 2df3fe2ef0e2..0aa62eb85f57 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1967,6 +1967,7 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat,
sal_Int32 nLineWidth=0;
const SfxPoolItem* pItem;
bool bFirstLine = true;
+ const bool bAllowSpacingWithoutBorders = rFormat.getIDocumentSettingAccess().get(DocumentSettingId::ALLOW_SPACING_WITHOUT_BORDERS);
if (SfxItemState::SET == rFormat.GetItemState(RES_BOX, true, &pItem))
{
static const o3tl::enumarray<SvxBoxItemLine, sal_uInt16> aExhperProp =
@@ -2034,6 +2035,10 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat,
rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(
static_cast<const SvxBoxItem*>(pItem)->GetDistance( n ) ));
}
+ else if( bAllowSpacingWithoutBorders )
+ {
+ rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(static_cast<const SvxBoxItem*>(pItem)->GetDistance( n )) );
+ }
else
// MM If there is no line the distance should be set to 0
rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(0));
@@ -2041,10 +2046,13 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat,
if( bFirstLine ) // no valid line found
{
rPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
- rPropOpt.AddOpt( ESCHER_Prop_dyTextTop, 0 );
- rPropOpt.AddOpt( ESCHER_Prop_dyTextBottom, 0 );
- rPropOpt.AddOpt( ESCHER_Prop_dxTextLeft, 0 );
- rPropOpt.AddOpt( ESCHER_Prop_dxTextRight, 0 );
+ if( !bAllowSpacingWithoutBorders )
+ {
+ rPropOpt.AddOpt( ESCHER_Prop_dyTextTop, 0 );
+ rPropOpt.AddOpt( ESCHER_Prop_dyTextBottom, 0 );
+ rPropOpt.AddOpt( ESCHER_Prop_dxTextLeft, 0 );
+ rPropOpt.AddOpt( ESCHER_Prop_dxTextRight, 0 );
+ }
}
const SwAttrSet& rAttrSet = rFormat.GetAttrSet();
if (SfxItemState::SET == rAttrSet.GetItemState(RES_BOX, false, &pItem))
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 0c95f2227827..f1b7c73ee2e8 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1959,6 +1959,7 @@ void SwWW8ImplReader::ImportDop()
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::TAB_OVER_MARGIN, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::SURROUND_TEXT_WRAP_SMALL, true);
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::PROP_LINE_SPACING_SHRINKS_FIRST_LINE, true);
+ m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ALLOW_SPACING_WITHOUT_BORDERS, true);
// COMPATIBILITY FLAGS END
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 9918c9472969..46ec397055dd 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -90,6 +90,7 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_IS_LABEL_DOC,
HANDLE_IS_ADD_FLY_OFFSET,
HANDLE_IS_ADD_VERTICAL_FLY_OFFSET,
+ HANDLE_ALLOW_SPACING_WITHOUT_BORDERS,
HANDLE_IS_ADD_EXTERNAL_LEADING,
HANDLE_OLD_NUMBERING,
HANDLE_OUTLINELEVEL_YIELDS_NUMBERING,
@@ -166,6 +167,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
{ OUString("IsLabelDocument"), HANDLE_IS_LABEL_DOC, cppu::UnoType<bool>::get(), 0},
{ OUString("AddFrameOffsets"), HANDLE_IS_ADD_FLY_OFFSET, cppu::UnoType<bool>::get(), 0},
{ OUString("AddVerticalFrameOffsets"), HANDLE_IS_ADD_VERTICAL_FLY_OFFSET, cppu::UnoType<bool>::get(), 0},
+ { OUString("AllowSpacingWithoutBorders"), HANDLE_ALLOW_SPACING_WITHOUT_BORDERS, cppu::UnoType<bool>::get(), 0},
{ OUString("AddExternalLeading"), HANDLE_IS_ADD_EXTERNAL_LEADING, cppu::UnoType<bool>::get(), 0},
{ OUString("UseOldNumbering"), HANDLE_OLD_NUMBERING, cppu::UnoType<bool>::get(), 0},
{ OUString("OutlineLevelYieldsNumbering"), HANDLE_OUTLINELEVEL_YIELDS_NUMBERING, cppu::UnoType<bool>::get(), 0},
@@ -567,6 +569,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS, bTmp);
}
break;
+ case HANDLE_ALLOW_SPACING_WITHOUT_BORDERS:
+ {
+ bool bTmp = *o3tl::doAccess<bool>(rValue);
+ mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::ALLOW_SPACING_WITHOUT_BORDERS, bTmp);
+ }
+ break;
case HANDLE_IS_ADD_EXTERNAL_LEADING:
{
bool bTmp = *o3tl::doAccess<bool>(rValue);
@@ -1055,6 +1063,11 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS);
}
break;
+ case HANDLE_ALLOW_SPACING_WITHOUT_BORDERS:
+ {
+ rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::ALLOW_SPACING_WITHOUT_BORDERS);
+ }
+ break;
case HANDLE_IS_ADD_EXTERNAL_LEADING:
{
rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::ADD_EXT_LEADING);