[PATCH] Use <div> instead of <multicol> when exporting multi-column ...

Harri Pitkänen (via_Code_Review) gerrit at gerrit.libreoffice.org
Thu Apr 25 11:47:06 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3610

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/10/3610/1

Use <div> instead of <multicol> when exporting multi-column sections

Commit da45a0e255f77d002c35438e9c2a17fecdde6d81 added CSS column-count
property to the exported non-standard MULTICOL element. With this change
we are also able to import multi-column DIVs into multi-column sections.
Now we can change the exported element from MULTICOL into DIV which
actually works in browsers supporting this feature. Importing legacy
MULTICOL elements is still supported.

Change-Id: I55bea40326904de7f137e996a000a7d213fa0593
---
M sw/source/filter/html/htmlsect.cxx
M sw/source/filter/html/svxcss1.cxx
M sw/source/filter/html/svxcss1.hxx
M sw/source/filter/html/swhtml.hxx
M sw/source/filter/html/wrthtml.cxx
5 files changed, 38 insertions(+), 16 deletions(-)



diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx
index 025c513..82a4b80 100644
--- a/sw/source/filter/html/htmlsect.cxx
+++ b/sw/source/filter/html/htmlsect.cxx
@@ -128,6 +128,12 @@
                                           aItemSet, aPropInfo, &aLang, &aDir );
         if( bStyleParsed )
         {
+            if ( aPropInfo.nColumnCount >= 2 )
+            {
+                delete pCntxt;
+                NewMultiCol( aPropInfo.nColumnCount );
+                return;
+            }
             bPositioned = HTML_DIVISION_ON == nToken && aClass.Len() &&
                           CreateContainer( aClass, aItemSet, aPropInfo,
                                            pCntxt );
@@ -532,11 +538,11 @@
     return bSectionClosed;
 }
 
-void SwHTMLParser::NewMultiCol()
+void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss )
 {
     String aId, aStyle, aClass, aLang, aDir;
     long nWidth = 100;
-    sal_uInt16 nCols = 0, nGutter = 10;
+    sal_uInt16 nCols = columnsFromCss, nGutter = 10;
     sal_Bool bPrcWidth = sal_True;
 
     const HTMLOptions& rHTMLOptions = GetOptions();
diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
index 7a5c944..600b447 100644
--- a/sw/source/filter/html/svxcss1.cxx
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -471,6 +471,8 @@
     if( USHRT_MAX != rProp.nRightBorderDistance )
         nRightBorderDistance = rProp.nRightBorderDistance;
 
+    nColumnCount = rProp.nColumnCount;
+
     if( rProp.eFloat != SVX_ADJUST_END )
         eFloat = rProp.eFloat;
 
@@ -1358,6 +1360,25 @@
         ;
     }
 }
+
+
+static void ParseCSS1_column_count( const CSS1Expression *pExpr,
+                             SfxItemSet& /*rItemSet*/,
+                             SvxCSS1PropertyInfo &rPropInfo,
+                             const SvxCSS1Parser& /*rParser*/ )
+{
+    OSL_ENSURE( pExpr, "no expression" );
+
+    if ( pExpr->GetType() == CSS1_NUMBER )
+    {
+        double columnCount = pExpr->GetNumber();
+        if ( columnCount >= 2 )
+        {
+            rPropInfo.nColumnCount = columnCount;
+        }
+    }
+}
+
 
 static void ParseCSS1_direction( const CSS1Expression *pExpr,
                              SfxItemSet &rItemSet,
@@ -3123,6 +3144,7 @@
     CSS1_PROP_ENTRY(border_left),
     CSS1_PROP_ENTRY(border),
     CSS1_PROP_ENTRY(color),
+    CSS1_PROP_ENTRY(column_count),
     CSS1_PROP_ENTRY(direction),
     CSS1_PROP_ENTRY(float),
     CSS1_PROP_ENTRY(font_size),
diff --git a/sw/source/filter/html/svxcss1.hxx b/sw/source/filter/html/svxcss1.hxx
index 05d1c53..91af20a 100644
--- a/sw/source/filter/html/svxcss1.hxx
+++ b/sw/source/filter/html/svxcss1.hxx
@@ -119,6 +119,8 @@
     sal_uInt16 nLeftBorderDistance;
     sal_uInt16 nRightBorderDistance;
 
+    sal_uInt16 nColumnCount;
+
     long nLeft, nTop;
     long nWidth, nHeight;
     long nLeftMargin, nRightMargin;
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index d628185..33af70b 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -601,7 +601,7 @@
     sal_Bool EndSections( sal_Bool bLFStripped );
 
     // <MULTICOL>
-    void NewMultiCol();
+    void NewMultiCol( sal_uInt16 columnsFromCss=0 );
     void EndMultiCol();
 
     // <MARQUEE>
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 3f3368d..8042027 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -524,10 +524,8 @@
     if( rHTMLWrt.bLFPossible )
         rHTMLWrt.OutNewLine();
 
-    const sal_Char *pTag = pCol ? OOO_STRING_SVTOOLS_HTML_multicol : OOO_STRING_SVTOOLS_HTML_division;
-
     OStringBuffer sOut;
-    sOut.append('<').append(pTag);
+    sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_division);
 
     const String& rName = rSection.GetSectionName();
     if( rName.Len() && !bContinued )
@@ -593,9 +591,6 @@
     }
     else if( pCol )
     {
-        sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cols).
-            append('=').append(static_cast<sal_Int32>(pCol->GetNumCols()));
-
         // minumum gutter width
         sal_uInt16 nGutter = pCol->GetGutterWidth( sal_True );
         if( nGutter!=USHRT_MAX )
@@ -624,15 +619,12 @@
     rHTMLWrt.IncIndentLevel();
 }
 
-static void lcl_html_OutSectionEndTag( SwHTMLWriter& rHTMLWrt,
-                                const SwFmtCol *pCol )
+static void lcl_html_OutSectionEndTag( SwHTMLWriter& rHTMLWrt )
 {
-    const sal_Char *pTag = pCol ? OOO_STRING_SVTOOLS_HTML_multicol : OOO_STRING_SVTOOLS_HTML_division;
-
     rHTMLWrt.DecIndentLevel();
     if( rHTMLWrt.bLFPossible )
         rHTMLWrt.OutNewLine();
-    HTMLOutFuncs::Out_AsciiTag( rHTMLWrt.Strm(), pTag, sal_False );
+    HTMLOutFuncs::Out_AsciiTag( rHTMLWrt.Strm(), OOO_STRING_SVTOOLS_HTML_division, sal_False );
     rHTMLWrt.bLFPossible = sal_True;
 }
 
@@ -696,7 +688,7 @@
     // another end immediately before the current one
     if( pSurrCol && nSectSttIdx - pSurrSectNd->GetIndex() > 1 &&
         !lcl_html_IsMultiColEnd( rHTMLWrt, nSectSttIdx-1 ) )
-        lcl_html_OutSectionEndTag( rHTMLWrt, pSurrCol );
+        lcl_html_OutSectionEndTag( rHTMLWrt );
 
     if( bStartTag )
         lcl_html_OutSectionStartTag( rHTMLWrt, rSection, *pFmt, pCol );
@@ -712,7 +704,7 @@
     rHTMLWrt.pCurPam->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
 
     if( bEndTag )
-        lcl_html_OutSectionEndTag( rHTMLWrt, pCol );
+        lcl_html_OutSectionEndTag( rHTMLWrt );
 
     // The surrounding section must be started again, except that it ends
     // immeditaly behind the current one.

-- 
To view, visit https://gerrit.libreoffice.org/3610
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I55bea40326904de7f137e996a000a7d213fa0593
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Harri Pitkänen <hatapitk at iki.fi>



More information about the LibreOffice mailing list