Kaydet (Commit) da45a0e2 authored tarafından Harri Pitkänen's avatar Harri Pitkänen Kaydeden (comit) Petr Mladek

Remove HTMLMODE_FRM_COLUMNS and export column-count CSS attribute

For multi-column sections in Writer, HTMLMODE_FRM_COLUMNS controlled
whether column settings for the section were exported to html or not.
This was disabled for Internet Explorer and enabled for other browsers.

The export was implemented using non-standard MULTICOL html element
and did not actually work in any modern browser (apparently only
some versions of Netscape have ever supported this). This patch

 - exports the column count also using "column-count" CSS attribute
   which is supported by latest versions of Opera and IE. Firefox and
   Webkit based browsers would currently require -moz-column-count and
   -webkit-column-count but I have not added these since the browsers
   will likely stop requiring the prefix in the future anyway.
 - removes HTMLMODE_FRM_COLUMNS conditional so that this export will
   happen with all html compatibility options, including IE.

Remaining issue: Using the MULTICOL element (as opposed to DIV element)
confuses at least Opera so that it ignores all style attributes applied
on the element. But corresponding html import code in LibreOffice still
relies on MULTICOL. I will work on a separate patch to add support for
column-count CSS attribute to the import code and switch export to use
DIV instead.

Change-Id: I82a065fdda0e074fbfcd0007e6ff6e46185be3f5
Reviewed-on: https://gerrit.libreoffice.org/2950Reviewed-by: 's avatarPetr Mladek <pmladek@suse.cz>
Tested-by: 's avatarPetr Mladek <pmladek@suse.cz>
üst f5442623
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#define HTMLMODE_ON 0x0001 #define HTMLMODE_ON 0x0001
#define HTMLMODE_PARA_DISTANCE 0x0004 #define HTMLMODE_PARA_DISTANCE 0x0004
#define HTMLMODE_FRM_COLUMNS 0x0010
#define HTMLMODE_SOME_STYLES 0x0020 /* mind. MS IE */ #define HTMLMODE_SOME_STYLES 0x0020 /* mind. MS IE */
#define HTMLMODE_FULL_STYLES 0x0040 /* == SW */ #define HTMLMODE_FULL_STYLES 0x0040 /* == SW */
#define HTMLMODE_PARA_BLOCK 0x0100 #define HTMLMODE_PARA_BLOCK 0x0100
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include <unotools/charclass.hxx> #include <unotools/charclass.hxx>
#include <i18npool/languagetag.hxx> #include <i18npool/languagetag.hxx>
#include <charfmt.hxx> #include <charfmt.hxx>
#include <fmtclds.hxx>
#include <fmtcol.hxx> #include <fmtcol.hxx>
#include <fmtfsize.hxx> #include <fmtfsize.hxx>
#include <fmtornt.hxx> #include <fmtornt.hxx>
...@@ -2271,7 +2272,7 @@ void SwHTMLWriter::OutCSS1_TableCellBorderHack(SwFrmFmt const& rFrmFmt) ...@@ -2271,7 +2272,7 @@ void SwHTMLWriter::OutCSS1_TableCellBorderHack(SwFrmFmt const& rFrmFmt)
} }
} }
void SwHTMLWriter::OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt ) void SwHTMLWriter::OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt, const SwFmtCol *pCol )
{ {
SwCSS1OutMode aMode( *this, CSS1_OUTMODE_STYLE_OPT_ON | SwCSS1OutMode aMode( *this, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE| CSS1_OUTMODE_ENCODE|
...@@ -2282,6 +2283,12 @@ void SwHTMLWriter::OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt ) ...@@ -2282,6 +2283,12 @@ void SwHTMLWriter::OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt )
if( SFX_ITEM_SET==rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) ) if( SFX_ITEM_SET==rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
OutCSS1_SvxBrush( *this, *pItem, CSS1_BACKGROUND_SECTION, 0 ); OutCSS1_SvxBrush( *this, *pItem, CSS1_BACKGROUND_SECTION, 0 );
if (pCol)
{
OString sColumnCount(OString::number(static_cast<sal_Int32>(pCol->GetNumCols())));
OutCSS1_PropertyAscii(sCSS1_P_column_count, sColumnCount);
}
if( !bFirstCSS1Property ) if( !bFirstCSS1Property )
Strm() << '\"'; Strm() << '\"';
} }
......
...@@ -219,6 +219,7 @@ sal_Char CSS1_CONSTASCII_DEF( sCSS1_P_height, "height" ); ...@@ -219,6 +219,7 @@ sal_Char CSS1_CONSTASCII_DEF( sCSS1_P_height, "height" );
sal_Char CSS1_CONSTASCII_DEF( sCSS1_P_float, "float" ); sal_Char CSS1_CONSTASCII_DEF( sCSS1_P_float, "float" );
sal_Char CSS1_CONSTASCII_DEF( sCSS1_P_column_count, "column-count" );
// Strings fuer Positioning // Strings fuer Positioning
......
...@@ -229,6 +229,7 @@ extern sal_Char CSS1_CONSTASCII_DECL( sCSS1_P_height, "height" ); ...@@ -229,6 +229,7 @@ extern sal_Char CSS1_CONSTASCII_DECL( sCSS1_P_height, "height" );
extern sal_Char CSS1_CONSTASCII_DECL( sCSS1_P_float, "float" ); extern sal_Char CSS1_CONSTASCII_DECL( sCSS1_P_float, "float" );
extern sal_Char CSS1_CONSTASCII_DECL( sCSS1_P_column_count, "column-count" );
// Strings fuer Positioning // Strings fuer Positioning
......
...@@ -469,15 +469,13 @@ sal_uLong SwHTMLWriter::WriteStream() ...@@ -469,15 +469,13 @@ sal_uLong SwHTMLWriter::WriteStream()
return nWarn; return nWarn;
} }
static const SwFmtCol *lcl_html_GetFmtCol( const SwHTMLWriter& rHTMLWrt, static const SwFmtCol *lcl_html_GetFmtCol( const SwSection& rSection,
const SwSection& rSection,
const SwSectionFmt& rFmt ) const SwSectionFmt& rFmt )
{ {
const SwFmtCol *pCol = 0; const SwFmtCol *pCol = 0;
const SfxPoolItem* pItem; const SfxPoolItem* pItem;
if( rHTMLWrt.IsHTMLMode( HTMLMODE_FRM_COLUMNS ) && if( FILE_LINK_SECTION != rSection.GetType() &&
FILE_LINK_SECTION != rSection.GetType() &&
SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState(RES_COL,sal_False,&pItem) && SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState(RES_COL,sal_False,&pItem) &&
((const SwFmtCol *)pItem)->GetNumCols() > 1 ) ((const SwFmtCol *)pItem)->GetNumCols() > 1 )
{ {
...@@ -496,7 +494,7 @@ static bool lcl_html_IsMultiColStart( const SwHTMLWriter& rHTMLWrt, sal_uLong nI ...@@ -496,7 +494,7 @@ static bool lcl_html_IsMultiColStart( const SwHTMLWriter& rHTMLWrt, sal_uLong nI
{ {
const SwSection& rSection = pSectNd->GetSection(); const SwSection& rSection = pSectNd->GetSection();
const SwSectionFmt *pFmt = rSection.GetFmt(); const SwSectionFmt *pFmt = rSection.GetFmt();
if( pFmt && lcl_html_GetFmtCol( rHTMLWrt, rSection, *pFmt ) ) if( pFmt && lcl_html_GetFmtCol( rSection, *pFmt ) )
bRet = true; bRet = true;
} }
...@@ -615,7 +613,7 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt, ...@@ -615,7 +613,7 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt,
rHTMLWrt.Strm() << sOut.makeStringAndClear().getStr(); rHTMLWrt.Strm() << sOut.makeStringAndClear().getStr();
if( rHTMLWrt.IsHTMLMode( rHTMLWrt.bCfgOutStyles ) ) if( rHTMLWrt.IsHTMLMode( rHTMLWrt.bCfgOutStyles ) )
rHTMLWrt.OutCSS1_SectionFmtOptions( rFmt ); rHTMLWrt.OutCSS1_SectionFmtOptions( rFmt, pCol );
rHTMLWrt.Strm() << '>'; rHTMLWrt.Strm() << '>';
...@@ -660,7 +658,7 @@ static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd ) ...@@ -660,7 +658,7 @@ static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
sal_uInt32 nSectSttIdx = rSectNd.GetIndex(); sal_uInt32 nSectSttIdx = rSectNd.GetIndex();
sal_uInt32 nSectEndIdx = rSectNd.EndOfSectionIndex(); sal_uInt32 nSectEndIdx = rSectNd.EndOfSectionIndex();
const SwFmtCol *pCol = lcl_html_GetFmtCol( rHTMLWrt, rSection, *pFmt ); const SwFmtCol *pCol = lcl_html_GetFmtCol( rSection, *pFmt );
if( pCol ) if( pCol )
{ {
// If the next node is a columned section node, too, don't export // If the next node is a columned section node, too, don't export
...@@ -686,7 +684,7 @@ static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd ) ...@@ -686,7 +684,7 @@ static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
pSurrSection = &pSurrSectNd->GetSection(); pSurrSection = &pSurrSectNd->GetSection();
pSurrFmt = pSurrSection->GetFmt(); pSurrFmt = pSurrSection->GetFmt();
if( pSurrFmt ) if( pSurrFmt )
pSurrCol = lcl_html_GetFmtCol( rHTMLWrt, *pSurrSection, pSurrCol = lcl_html_GetFmtCol( *pSurrSection,
*pSurrFmt ); *pSurrFmt );
} }
} }
......
...@@ -473,7 +473,7 @@ public: ...@@ -473,7 +473,7 @@ public:
sal_uInt32 nFrmOpts, const rtl::OString& rEndTags = rtl::OString() ); sal_uInt32 nFrmOpts, const rtl::OString& rEndTags = rtl::OString() );
void OutCSS1_TableFrmFmtOptions( const SwFrmFmt& rFrmFmt ); void OutCSS1_TableFrmFmtOptions( const SwFrmFmt& rFrmFmt );
void OutCSS1_TableCellBorderHack(const SwFrmFmt& rFrmFmt); void OutCSS1_TableCellBorderHack(const SwFrmFmt& rFrmFmt);
void OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt ); void OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt, const SwFmtCol *pCol );
void OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, sal_uInt32 nFrmOpts, void OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, sal_uInt32 nFrmOpts,
const SdrObject *pSdrObj=0, const SdrObject *pSdrObj=0,
const SfxItemSet *pItemSet=0 ); const SfxItemSet *pItemSet=0 );
......
...@@ -320,10 +320,10 @@ sal_uInt16 GetHtmlMode(const SwDocShell* pShell) ...@@ -320,10 +320,10 @@ sal_uInt16 GetHtmlMode(const SwDocShell* pShell)
nRet |= HTMLMODE_FULL_STYLES; nRet |= HTMLMODE_FULL_STYLES;
break; break;
case HTML_CFG_NS40: case HTML_CFG_NS40:
nRet |= HTMLMODE_FRM_COLUMNS; // no special features for this browser
break; break;
case HTML_CFG_WRITER: case HTML_CFG_WRITER:
nRet |= HTMLMODE_FRM_COLUMNS|HTMLMODE_FULL_STYLES; nRet |= HTMLMODE_FULL_STYLES;
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment