summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarri Pitkänen <hatapitk@iki.fi>2013-04-20 12:53:53 +0300
committerTor Lillqvist <tml@iki.fi>2013-04-26 07:53:03 +0000
commit15f8a130e2e1a3c920b02ad034d09e547e69ea57 (patch)
tree20a54575e2ea818457699be7d1dd6596174f8b78
parentbd1e5791951c0e8eae6e79f1789ba1115cdead53 (diff)
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 <tml@iki.fi> Tested-by: Tor Lillqvist <tml@iki.fi>
-rw-r--r--sw/source/filter/html/htmlsect.cxx10
-rw-r--r--sw/source/filter/html/svxcss1.cxx22
-rw-r--r--sw/source/filter/html/svxcss1.hxx2
-rw-r--r--sw/source/filter/html/swhtml.hxx2
-rw-r--r--sw/source/filter/html/wrthtml.cxx18
5 files changed, 38 insertions, 16 deletions
diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx
index 025c5133c88c..82a4b800ec4f 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 7a5c944fd5ba..600b447778c6 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 05d1c5339478..91af20afb447 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 d628185827ae..33af70bd10c8 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 3f3368dccaf6..8042027d5086 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.