summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-08-23 12:11:08 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-09-28 14:31:36 +0200
commitcbf529659b1aaa9f4806462d5ea5ac8db1c876c2 (patch)
tree0c88eb1d9ba4d49389c91937a088a1a0fe0dbeb8 /sw/source
parent453821351238d81f7707c4e205a6ed82f884eca5 (diff)
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. (cherry picked from commit 50a1df360c907d8419ce49f098b6bc87a37a9956) Conflicts: sw/inc/IDocumentSettingAccess.hxx sw/inc/doc.hxx sw/source/core/doc/doc.cxx sw/source/ui/uno/SwXDocumentSettings.cxx writerfilter/source/filter/ImportFilter.cxx Change-Id: Iaaa1d2a2e2f9d0eaea17832b2e418f9a845efffd
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/doc.cxx4
-rw-r--r--sw/source/core/doc/docnew.cxx1
-rw-r--r--sw/source/core/layout/frmtool.cxx39
-rw-r--r--sw/source/ui/uno/SwXDocumentSettings.cxx16
4 files changed, 58 insertions, 2 deletions
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index b7414dbedc02..2a6567e185b9 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -209,6 +209,7 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
case KERN_ASIAN_PUNCTUATION: return mbKernAsianPunctuation;
case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: return mbDoNotResetParaAttrsForNumFont;
case MATH_BASELINE_ALIGNMENT: return mbMathBaselineAlignment;
+ case FLOATTABLE_NOMARGINS: return mbFloattableNomargins;
default:
OSL_FAIL("Invalid setting id");
}
@@ -377,6 +378,9 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
case MATH_BASELINE_ALIGNMENT:
mbMathBaselineAlignment = value;
break;
+ case FLOATTABLE_NOMARGINS:
+ mbFloattableNomargins = value;
+ break;
default:
OSL_FAIL("Invalid setting id");
}
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 3ed8f0aae473..b52855ea3a42 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -360,6 +360,7 @@ SwDoc::SwDoc()
mbSmallCapsPercentage66 = false; // hidden
mbTabOverflow = true;
mbUnbreakableNumberings = false;
+ mbFloattableNomargins = false;
//
// COMPATIBILITY FLAGS END
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 4cf9a6c8c755..407f10b2e512 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1925,6 +1925,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;
@@ -1942,7 +1962,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
diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx
index fa8a704247f8..dda7834dff93 100644
--- a/sw/source/ui/uno/SwXDocumentSettings.cxx
+++ b/sw/source/ui/uno/SwXDocumentSettings.cxx
@@ -125,7 +125,8 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_COLLAPSE_EMPTY_CELL_PARA,
HANDLE_SMALL_CAPS_PERCENTAGE_66,
HANDLE_TAB_OVERFLOW,
- HANDLE_UNBREAKABLE_NUMBERINGS
+ HANDLE_UNBREAKABLE_NUMBERINGS,
+ HANDLE_FLOATTABLE_NOMARGINS
};
MasterPropertySetInfo * lcl_createSettingsInfo()
@@ -188,6 +189,7 @@ MasterPropertySetInfo * lcl_createSettingsInfo()
{ RTL_CONSTASCII_STRINGPARAM("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, CPPUTYPE_BOOLEAN, 0, 0},
{ 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("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
@@ -747,6 +749,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
mpDoc->set(IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS, bTmp);
}
break;
+ case HANDLE_FLOATTABLE_NOMARGINS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::FLOATTABLE_NOMARGINS, bTmp);
+ }
+ break;
default:
throw UnknownPropertyException();
}
@@ -1119,6 +1127,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();
}