[Libreoffice-commits] core.git: writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Apr 7 15:55:05 UTC 2016


 writerfilter/source/dmapper/PropertyMap.cxx |   55 ++++++++++++++++++----------
 writerfilter/source/dmapper/PropertyMap.hxx |    3 +
 2 files changed, 39 insertions(+), 19 deletions(-)

New commits:
commit d56deaeb2a1e8007e50fc2334f416fddd4e3cde3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 7 16:47:23 2016 +0200

    tdf#99140 Factor out FloatingTableConversion() from CloseSectionGroup()
    
    No logic changes intended, but makes it easier to add new rules when
    making the decision.
    
    Change-Id: I84d8e6a2b8a4b9ae6fe5cefd381292c2f68be45f
    Reviewed-on: https://gerrit.libreoffice.org/23901
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 56e99b6..ff8e5f3 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1038,34 +1038,51 @@ void SectionPropertyMap::HandleMarginsHeaderFooter(DomainMapper_Impl& rDM_Impl)
     PrepareHeaderFooterProperties( false );
 }
 
+bool SectionPropertyMap::FloatingTableConversion(FloatingTableInfo& rInfo)
+{
+    // Note that this is just a list of heuristics till sw core can have a
+    // table that is floating and can span over multiple pages at the same
+    // time.
+
+    sal_Int32 nTextAreaWidth = GetPageWidth() - GetLeftMargin() - GetRightMargin();
+    // Count the layout width of the table.
+    sal_Int32 nTableWidth = rInfo.m_nTableWidth;
+    sal_Int32 nLeftMargin = 0;
+    if (rInfo.getPropertyValue("LeftMargin") >>= nLeftMargin)
+        nTableWidth += nLeftMargin;
+    sal_Int32 nRightMargin = 0;
+    if (rInfo.getPropertyValue("RightMargin") >>= nRightMargin)
+        nTableWidth += nRightMargin;
+
+    // If the table is wider than the text area, then don't create a fly
+    // for the table: no wrapping will be performed anyway, but multi-page
+    // tables will be broken.
+    if (nTableWidth < nTextAreaWidth)
+        return true;
+
+    // If the position is relative to the edge of the page, then we always
+    // create the fly.
+    if (rInfo.getPropertyValue("HoriOrientRelation") == text::RelOrientation::PAGE_FRAME)
+        return true;
+
+    // If there are columns, always create the fly, otherwise the columns would
+    // restrict geometry of the table.
+    if (ColumnCount() + 1 >= 2)
+        return true;
+
+    return false;
+}
+
 void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
 {
     // Text area width is known at the end of a section: decide if tables should be converted or not.
     std::vector<FloatingTableInfo>& rPendingFloatingTables = rDM_Impl.m_aPendingFloatingTables;
-    sal_Int32 nTextAreaWidth = GetPageWidth() - GetLeftMargin() - GetRightMargin();
     uno::Reference<text::XTextAppendAndConvert> xBodyText( rDM_Impl.GetBodyText(), uno::UNO_QUERY );
     for (size_t i = 0; i < rPendingFloatingTables.size(); ++i)
     {
         FloatingTableInfo& rInfo = rPendingFloatingTables[i];
 
-        // Count the layout width of the table.
-        sal_Int32 nTableWidth = rInfo.m_nTableWidth;
-        sal_Int32 nLeftMargin = 0;
-        if (rInfo.getPropertyValue("LeftMargin") >>= nLeftMargin)
-            nTableWidth += nLeftMargin;
-        sal_Int32 nRightMargin = 0;
-        if (rInfo.getPropertyValue("RightMargin") >>= nRightMargin)
-            nTableWidth += nRightMargin;
-
-        // If the table is wider than the text area, then don't create a fly
-        // for the table: no wrapping will be performed anyway, but multi-page
-        // tables will be broken.
-        // If the position is relative to the edge of the page, then we always
-        // create the fly.
-        // If there are columns, always create the fly, otherwise the columns would
-        // restrict geometry of the table.
-        if ( ( rInfo.getPropertyValue("HoriOrientRelation") == text::RelOrientation::PAGE_FRAME ) ||
-             nTableWidth < nTextAreaWidth || ColumnCount() + 1 >= 2 )
+        if (FloatingTableConversion(rInfo))
             xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd, rInfo.m_aFrameProperties);
     }
     rPendingFloatingTables.clear();
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index a3a9be1..ac2b8b5 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -57,6 +57,7 @@ namespace com{namespace sun{namespace star{
 namespace writerfilter {
 namespace dmapper{
 class DomainMapper_Impl;
+struct FloatingTableInfo;
 
 enum BorderPosition
 {
@@ -267,6 +268,8 @@ class SectionPropertyMap : public PropertyMap
                            sal_Int32 nDistance,
                            sal_Int32 nOffsetFrom,
                            sal_uInt32 nLineWidth);
+    /// Determintes if conversion of a given floating table is wanted or not.
+    bool FloatingTableConversion(FloatingTableInfo& rInfo);
 
 public:
         explicit SectionPropertyMap(bool bIsFirstSection);


More information about the Libreoffice-commits mailing list