Kaydet (Commit) 50a1df36 authored tarafından Miklos Vajna's avatar Miklos Vajna

n#775899 sw: add FloattableNomargins compat flag

The DOCX filter imports floating tables as frames containing a table.
Word ignores the margins of paragraphs next to such a table, Writer does
not. Add a compatibility flag the import filter can set that triggers
this weird behaviour.

Change-Id: Iaaa1d2a2e2f9d0eaea17832b2e418f9a845efffd
üst 333f9d30
......@@ -94,7 +94,8 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
PURGE_OLE,
KERN_ASIAN_PUNCTUATION,
MATH_BASELINE_ALIGNMENT,
STYLES_NODEFAULT
STYLES_NODEFAULT,
FLOATTABLE_NOMARGINS
};
public:
......
......@@ -567,6 +567,7 @@ private:
// attribute 'WrapInfluenceOnObjPos'.
bool mbMathBaselineAlignment : 1; // TL 2010-10-29 #i972#
bool mbStylesNoDefault : 1;
bool mbFloattableNomargins : 1; ///< If paragraph margins next to a floating table should be ignored.
// non-ui-compatibility flags:
bool mbOldNumbering : 1;
......
......@@ -210,6 +210,7 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: return mbDoNotResetParaAttrsForNumFont;
case MATH_BASELINE_ALIGNMENT: return mbMathBaselineAlignment;
case STYLES_NODEFAULT: return mbStylesNoDefault;
case FLOATTABLE_NOMARGINS: return mbFloattableNomargins;
default:
OSL_FAIL("Invalid setting id");
}
......@@ -381,6 +382,9 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
case STYLES_NODEFAULT:
mbStylesNoDefault = value;
break;
case FLOATTABLE_NOMARGINS:
mbFloattableNomargins = value;
break;
default:
OSL_FAIL("Invalid setting id");
}
......
......@@ -356,6 +356,7 @@ SwDoc::SwDoc()
mbSmallCapsPercentage66 = false; // hidden
mbTabOverflow = true;
mbUnbreakableNumberings = false;
mbFloattableNomargins = false;
//
// COMPATIBILITY FLAGS END
......
......@@ -1928,6 +1928,26 @@ long SwBorderAttrs::CalcRight( const SwFrm* pCaller ) const
return nRight;
}
/// Tries to detect if this paragraph has a floating table attached.
bool lcl_hasTabFrm(const SwTxtFrm* pTxtFrm)
{
if (pTxtFrm->GetDrawObjs())
{
const SwSortedObjs* pSortedObjs = pTxtFrm->GetDrawObjs();
if (pSortedObjs->Count() > 0)
{
SwAnchoredObject* pObject = (*pSortedObjs)[0];
if (pObject->IsA(TYPE(SwFlyFrm)))
{
SwFlyFrm* pFly = (SwFlyFrm*)pObject;
if (pFly->Lower()->IsTabFrm())
return true;
}
}
}
return false;
}
long SwBorderAttrs::CalcLeft( const SwFrm *pCaller ) const
{
long nLeft=0;
......@@ -1945,7 +1965,24 @@ long SwBorderAttrs::CalcLeft( const SwFrm *pCaller ) const
if ( pCaller->IsTxtFrm() && pCaller->IsRightToLeft() )
nLeft += rLR.GetRight();
else
nLeft += rLR.GetLeft();
{
bool bIgnoreMargin = false;
if (pCaller->IsTxtFrm())
{
const SwTxtFrm* pTxtFrm = (const SwTxtFrm*)pCaller;
if (pTxtFrm->GetTxtNode()->GetDoc()->get(IDocumentSettingAccess::FLOATTABLE_NOMARGINS))
{
// If this is explicitly requested, ignore the margins next to the floating table.
if (lcl_hasTabFrm(pTxtFrm))
bIgnoreMargin = true;
// TODO here we only handle the first two paragraphs, would be nice to generalize this.
else if (pTxtFrm->FindPrev() && pTxtFrm->FindPrev()->IsTxtFrm() && lcl_hasTabFrm((const SwTxtFrm*)pTxtFrm->FindPrev()))
bIgnoreMargin = true;
}
}
if (!bIgnoreMargin)
nLeft += rLR.GetLeft();
}
// correction: do not retrieve left margin for numbering in R2L-layout
......
......@@ -126,7 +126,8 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_SMALL_CAPS_PERCENTAGE_66,
HANDLE_TAB_OVERFLOW,
HANDLE_UNBREAKABLE_NUMBERINGS,
HANDLE_STYLES_NODEFAULT
HANDLE_STYLES_NODEFAULT,
HANDLE_FLOATTABLE_NOMARGINS
};
MasterPropertySetInfo * lcl_createSettingsInfo()
......@@ -190,6 +191,7 @@ MasterPropertySetInfo * lcl_createSettingsInfo()
{ RTL_CONSTASCII_STRINGPARAM("TabOverflow"), HANDLE_TAB_OVERFLOW, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("UnbreakableNumberings"), HANDLE_UNBREAKABLE_NUMBERINGS, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, CPPUTYPE_BOOLEAN, 0, 0},
/*
* As OS said, we don't have a view when we need to set this, so I have to
* find another solution before adding them to this property set - MTG
......@@ -755,6 +757,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
mpDoc->set(IDocumentSettingAccess::STYLES_NODEFAULT, bTmp);
}
break;
case HANDLE_FLOATTABLE_NOMARGINS:
{
sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
mpDoc->set(IDocumentSettingAccess::FLOATTABLE_NOMARGINS, bTmp);
}
break;
default:
throw UnknownPropertyException();
}
......@@ -1133,6 +1141,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
rValue.setValue( &bTmp, ::getBooleanCppuType() );
}
break;
case HANDLE_FLOATTABLE_NOMARGINS:
{
sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::FLOATTABLE_NOMARGINS );
rValue.setValue( &bTmp, ::getBooleanCppuType() );
}
break;
default:
throw UnknownPropertyException();
}
......
......@@ -176,6 +176,8 @@ void WriterFilter::setTargetDocument( const uno::Reference< lang::XComponent >&
// Don't load the default style definitions to avoid weird mix
xSettings->setPropertyValue( "StylesNoDefault", uno::makeAny( sal_True ) );
xSettings->setPropertyValue("FloattableNomargins", uno::makeAny( sal_True ));
}
void WriterFilter::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment