sw/source/filter/html/htmlsect.cxx |   10 ++++++++--
 sw/source/filter/html/svxcss1.cxx  |   22 ++++++++++++++++++++++
 sw/source/filter/html/svxcss1.hxx  |    2 ++
 sw/source/filter/html/swhtml.hxx   |    2 +-
 sw/source/filter/html/wrthtml.cxx  |   18 +++++-------------
 5 files changed, 38 insertions(+), 16 deletions(-)

New commits:
commit 15f8a130e2e1a3c920b02ad034d09e547e69ea57
Author: Harri Pitkänen <hatap...@iki.fi>
Date:   Sat Apr 20 12:53:53 2013 +0300

    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
    Reviewed-on: https://gerrit.libreoffice.org/3610
    Reviewed-by: Tor Lillqvist <t...@iki.fi>
    Tested-by: Tor Lillqvist <t...@iki.fi>

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 @@ void SwHTMLParser::NewDivision( int nToken )
                                           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 @@ sal_Bool SwHTMLParser::EndSections( sal_Bool bLFStripped )
     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 @@ void SvxCSS1PropertyInfo::Merge( const SvxCSS1PropertyInfo& 
rProp )
     if( USHRT_MAX != rProp.nRightBorderDistance )
         nRightBorderDistance = rProp.nRightBorderDistance;
 
+    nColumnCount = rProp.nColumnCount;
+
     if( rProp.eFloat != SVX_ADJUST_END )
         eFloat = rProp.eFloat;
 
@@ -1359,6 +1361,25 @@ static void ParseCSS1_color( const CSS1Expression *pExpr,
     }
 }
 
+
+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,
                              SvxCSS1PropertyInfo& /*rPropInfo*/,
@@ -3123,6 +3144,7 @@ static CSS1PropEntry aCSS1PropFnTab[] =
     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 @@ public:
     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 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
     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 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& 
rHTMLWrt,
     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 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& 
rHTMLWrt,
     }
     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 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& 
rHTMLWrt,
     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 @@ static Writer& OutHTML_Section( Writer& rWrt, const 
SwSectionNode& rSectNd )
     // 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 @@ static Writer& OutHTML_Section( Writer& rWrt, const 
SwSectionNode& rSectNd )
     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.
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to