[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 2 commits - sw/source

Caolán McNamara caolan at kemper.freedesktop.org
Mon Apr 30 07:27:13 PDT 2012


 sw/source/filter/html/css1atr.cxx  |   12 ++++++++++++
 sw/source/filter/html/htmltab.cxx  |   30 ++++++++++++++++++++++++++----
 sw/source/filter/html/htmltabw.cxx |    6 +-----
 sw/source/filter/html/parcss1.cxx  |    6 ++++++
 sw/source/filter/html/wrthtml.hxx  |    1 +
 5 files changed, 46 insertions(+), 9 deletions(-)

New commits:
commit 920de2d0f5bfc79b2570595d95495759c009a825
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 30 14:31:06 2012 +0200

    fdo#41796: sw: HTML: spurious semicolons in STYLE:
    
    The STYLE attributes on TD elements (except for the first) start with a
    spurious semicolon, because the bFirstCSS1Prop variable is not reset.
    Apparently the semicolon is a separator in STYLE attributes, so it is
    probably invalid to write a spurious one, but Mozilla can still render
    the borders right, so add a workaround to CSS1Parser::ParseStyleOption
    to skip initial semicolons.
    Fix the export by using the SwCSS1OutMode to set the mode (also turning
    on encoding while at it), which is the only way to reset bFirstCSS1Prop.
    (regression from d18feffd49f4481626417daac7984b2a7e70c3bf)
    (cherry picked from commit 284b421f40078275e5e647a4f7e82e4ef7fec6a7)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 97414c2..1a62162 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -2301,6 +2301,18 @@ void SwHTMLWriter::OutCSS1_TableFrmFmtOptions( const SwFrmFmt& rFrmFmt )
         Strm() << '\"';
 }
 
+void SwHTMLWriter::OutCSS1_TableCellBorderHack(SwFrmFmt const& rFrmFmt)
+{
+    SwCSS1OutMode const aMode(*this,
+        CSS1_OUTMODE_STYLE_OPT_ON|CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_TABLEBOX,
+        true, 0);
+    OutCSS1_SvxBox(*this, rFrmFmt.GetBox());
+    if (!bFirstCSS1Property)
+    {
+        this->Strm() << cCSS1_style_opt_end;
+    }
+}
+
 void SwHTMLWriter::OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt )
 {
     SwCSS1OutMode aMode( *this, CSS1_OUTMODE_STYLE_OPT_ON |
diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx
index f33cf53..1f9cc92 100644
--- a/sw/source/filter/html/htmltabw.cxx
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -442,11 +442,7 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
             OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
     }
 
-    sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_style).
-        append(RTL_CONSTASCII_STRINGPARAM("=\""));
-    rWrt.Strm() << sOut.makeStringAndClear().getStr();
-    OutCSS1_SvxBox( rWrt, pBox->GetFrmFmt()->GetBox() );
-    sOut.append('"');
+    rWrt.OutCSS1_TableCellBorderHack(*pBox->GetFrmFmt());
 
     sal_uInt32 nNumFmt = 0;
     double nValue = 0.0;
diff --git a/sw/source/filter/html/parcss1.cxx b/sw/source/filter/html/parcss1.cxx
index ab13dfb..0623d07 100644
--- a/sw/source/filter/html/parcss1.cxx
+++ b/sw/source/filter/html/parcss1.cxx
@@ -1181,6 +1181,12 @@ sal_Bool CSS1Parser::ParseStyleOption( const String& rIn )
 
     InitRead( rIn );
 
+    // fdo#41796: skip over spurious semicolons
+    while (CSS1_SEMICOLON == nToken)
+    {
+        nToken = GetNextToken();
+    }
+
     String aProperty;
     CSS1Expression *pExpr = ParseDeclaration( aProperty );
     if( !pExpr )
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 5f9753e..506a88e 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -409,6 +409,7 @@ public:
     rtl::OString OutFrmFmtOptions( const SwFrmFmt& rFrmFmt, const String& rAltTxt,
         sal_uInt32 nFrmOpts, const rtl::OString& rEndTags = rtl::OString() );
     void OutCSS1_TableFrmFmtOptions( const SwFrmFmt& rFrmFmt );
+    void OutCSS1_TableCellBorderHack(const SwFrmFmt& rFrmFmt);
     void OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt );
     void OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, sal_uInt32 nFrmOpts,
                                 const SdrObject *pSdrObj=0,
commit b363a1aac10fad09d62d3c4aece5b2de5589947a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 30 14:24:12 2012 +0200

    fdo#41796: sw: HTML: import CSS STYLE border on TD:
    
    For TD elements, the SYLE attribute containing "border" properties is
    read, but the borders end up not at the table cell, but on some span or
    paragraph inside the cell.  So insert a special case that re-routes
    the SvxBoxItems containing the borders to FixFrameFmt, where the
    properties set at the TD element directly now override the SvxBoxItem
    that is derived from BORDER etc. attributes of the table.
    (regression from d18feffd49f4481626417daac7984b2a7e70c3bf,
     which changed the way the border attributes are written)
    (cherry picked from commit 9a482b4ea49c3ce964de4c0f81d8d3206ac75dc8)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 06aa3bf..c6a3c09 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -220,6 +220,7 @@ class HTMLTableCell
     HTMLTableCnts *pContents;       // cell content
     SvxBrushItem *pBGBrush;         // cell background
     // !!!ATTENTION!!!!!
+    ::boost::shared_ptr<SvxBoxItem> m_pBoxItem;
 
     sal_uInt32 nNumFmt;
     sal_uInt16 nRowSpan;                // cell ROWSPAN
@@ -243,6 +244,7 @@ public:
     // Fill a not empty cell
     void Set( HTMLTableCnts *pCnts, sal_uInt16 nRSpan, sal_uInt16 nCSpan,
               sal_Int16 eVertOri, SvxBrushItem *pBGBrush,
+              ::boost::shared_ptr<SvxBoxItem> const pBoxItem,
               sal_Bool bHasNumFmt, sal_uInt32 nNumFmt,
               sal_Bool bHasValue, double nValue, sal_Bool bNoWrap, sal_Bool bCovered );
 
@@ -264,6 +266,7 @@ public:
     inline void SetWidth( sal_uInt16 nWidth, sal_Bool bRelWidth );
 
     const SvxBrushItem *GetBGBrush() const { return pBGBrush; }
+    ::boost::shared_ptr<SvxBoxItem> GetBoxItem() const { return m_pBoxItem; }
 
     inline sal_Bool GetNumFmt( sal_uInt32& rNumFmt ) const;
     inline sal_Bool GetValue( double& rValue ) const;
@@ -592,6 +595,7 @@ public:
     void InsertCell( HTMLTableCnts *pCnts, sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
                      sal_uInt16 nWidth, sal_Bool bRelWidth, sal_uInt16 nHeight,
                      sal_Int16 eVertOri, SvxBrushItem *pBGBrush,
+                     boost::shared_ptr<SvxBoxItem> const pBoxItem,
                      sal_Bool bHasNumFmt, sal_uInt32 nNumFmt,
                      sal_Bool bHasValue, double nValue, sal_Bool bNoWrap );
 
@@ -756,6 +760,7 @@ HTMLTableCell::~HTMLTableCell()
 
 void HTMLTableCell::Set( HTMLTableCnts *pCnts, sal_uInt16 nRSpan, sal_uInt16 nCSpan,
                          sal_Int16 eVert, SvxBrushItem *pBrush,
+                         ::boost::shared_ptr<SvxBoxItem> const pBoxItem,
                          sal_Bool bHasNF, sal_uInt32 nNF, sal_Bool bHasV, double nVal,
                          sal_Bool bNWrap, sal_Bool bCovered )
 {
@@ -765,6 +770,7 @@ void HTMLTableCell::Set( HTMLTableCnts *pCnts, sal_uInt16 nRSpan, sal_uInt16 nCS
     bProtected = sal_False;
     eVertOri = eVert;
     pBGBrush = pBrush;
+    m_pBoxItem = pBoxItem;
 
     bHasNumFmt = bHasNF;
     bHasValue = bHasV;
@@ -1388,6 +1394,7 @@ void HTMLTable::FixFrameFmt( SwTableBox *pBox,
     SwFrmFmt *pFrmFmt = 0;      // frame::Frame-Format
     sal_Int16 eVOri = text::VertOrientation::NONE;
     const SvxBrushItem *pBGBrushItem = 0;   // Hintergrund
+    boost::shared_ptr<SvxBoxItem> pBoxItem;
     sal_Bool bTopLine = sal_False, bBottomLine = sal_False, bLastBottomLine = sal_False;
     sal_Bool bReUsable = sal_False;     // Format nochmals verwendbar?
     sal_uInt16 nEmptyRows = 0;
@@ -1402,6 +1409,7 @@ void HTMLTable::FixFrameFmt( SwTableBox *pBox,
     {
         // die Hintergrundfarbe/-grafik bestimmen
         const HTMLTableCell *pCell = GetCell( nRow, nCol );
+        pBoxItem = pCell->GetBoxItem();
         pBGBrushItem = pCell->GetBGBrush();
         if( !pBGBrushItem )
         {
@@ -1444,7 +1452,7 @@ void HTMLTable::FixFrameFmt( SwTableBox *pBox,
             bHasValue = pCell->GetValue( nValue );
 
         if( nColSpan==1 && !bTopLine && !bLastBottomLine && !nEmptyRows &&
-            !pBGBrushItem && !bHasNumFmt )
+            !pBGBrushItem && !bHasNumFmt && !pBoxItem)
         {
             pFrmFmt = pColumn->GetFrmFmt( bBottomLine, eVOri );
             bReUsable = !pFrmFmt;
@@ -1518,7 +1526,11 @@ void HTMLTable::FixFrameFmt( SwTableBox *pBox,
                 bSet = sal_True;
             }
 
-            if( bSet )
+            if (pBoxItem)
+            {
+                pFrmFmt->SetFmtAttr( *pBoxItem );
+            }
+            else if (bSet)
             {
                 // BorderDist nicht mehr Bestandteil einer Zelle mit fixer Breite
                 sal_uInt16 nBDist = static_cast< sal_uInt16 >(
@@ -2124,6 +2136,7 @@ void HTMLTable::InsertCell( HTMLTableCnts *pCnts,
                             sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
                             sal_uInt16 nCellWidth, sal_Bool bRelWidth, sal_uInt16 nCellHeight,
                             sal_Int16 eVertOrient, SvxBrushItem *pBGBrushItem,
+                            boost::shared_ptr<SvxBoxItem> const pBoxItem,
                             sal_Bool bHasNumFmt, sal_uInt32 nNumFmt,
                             sal_Bool bHasValue, double nValue, sal_Bool bNoWrap )
 {
@@ -2202,7 +2215,7 @@ void HTMLTable::InsertCell( HTMLTableCnts *pCnts,
         {
             const bool bCovered = i != nColSpan || j != nRowSpan;
             GetCell( nRowsReq-j, nColsReq-i )
-                ->Set( pCnts, j, i, eVertOrient, pBGBrushItem,
+                ->Set( pCnts, j, i, eVertOrient, pBGBrushItem, pBoxItem,
                        bHasNumFmt, nNumFmt, bHasValue, nValue, bNoWrap, bCovered );
         }
     }
@@ -3135,6 +3148,7 @@ class _CellSaveStruct : public _SectionSaveStruct
     String aStyle, aId, aClass, aLang, aDir;
     String aBGImage;
     Color aBGColor;
+    boost::shared_ptr<SvxBoxItem> m_pBoxItem;
 
     HTMLTableCnts* pCnts;           // Liste aller Inhalte
     HTMLTableCnts* pCurrCnts;   // der aktuelle Inhalt oder 0
@@ -3320,7 +3334,15 @@ _CellSaveStruct::_CellSaveStruct( SwHTMLParser& rParser, HTMLTable *pCurTable,
 
         if( rParser.ParseStyleOptions( aStyle, aId, aClass, aItemSet,
                                        aPropInfo, &aLang, &aDir ) )
+        {
+            SfxPoolItem const* pItem;
+            if (SFX_ITEM_SET == aItemSet.GetItemState(RES_BOX, false, &pItem))
+            {   // fdo#41796: steal box item to set it in FixFrameFmt later!
+                m_pBoxItem.reset(dynamic_cast<SvxBoxItem *>(pItem->Clone()));
+                aItemSet.ClearItem(RES_BOX);
+            }
             rParser.InsertAttrs( aItemSet, aPropInfo, pCntxt );
+        }
     }
 
     rParser.SplitPREListingXMP( pCntxt );
@@ -3379,7 +3401,7 @@ void _CellSaveStruct::InsertCell( SwHTMLParser& rParser,
         rParser.CreateBrushItem( bBGColor ? &aBGColor : 0, aBGImage,
                                  aStyle, aId, aClass );
     pCurTable->InsertCell( pCnts, nRowSpan, nColSpan, nWidth,
-                           bPrcWidth, nHeight, eVertOri, pBrushItem,
+                           bPrcWidth, nHeight, eVertOri, pBrushItem, m_pBoxItem,
                            bHasNumFmt, nNumFmt, bHasValue, nValue,
                            bNoWrap );
     Restore( rParser );


More information about the Libreoffice-commits mailing list