[Libreoffice-commits] core.git: Branch 'distro/suse/suse-3.6' - 3 commits - sw/source

Miklos Vajna vmiklos at suse.cz
Mon May 13 04:05:18 PDT 2013


 sw/source/filter/ww8/ww8par.hxx   |   58 +++++++++++++++++++++++++++++++++++++-
 sw/source/filter/ww8/ww8par2.cxx  |   58 --------------------------------------
 sw/source/filter/ww8/ww8par6.cxx  |   37 +++++++++++++++++++-----
 sw/source/filter/ww8/ww8struc.hxx |    1 
 4 files changed, 88 insertions(+), 66 deletions(-)

New commits:
commit e9485fb5c5453618a39c8b64f607346c77aabad6
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon May 13 11:24:58 2013 +0200

    bnc#816603, fdo#61594 SwWW8ImplReader::StartApo: don't always start a frame
    
    Word supports floating tables, Writer does not. We can map floating
    tables to fly frames, containing just a table, but then those can't span
    over multiple pages. We could avoid creating frames in case the table is
    of multiple pages, but that's hard to determine.
    
    One easy case is when the table width is >= the text area with, in that
    case we can be sure that no wrapping would be performed anyway, so we
    can avoid putting the table to a frame.
    
    Two more related problems:
    
    1) When we need to decide if a frame should be created or not, we
    typically don't know yet the table width. That's why TestApo() has to
    always succeed (in case the paragraphs are wrapped), and then we always
    enter StartApo(), where we can avoid creating the frame, if necessary.
    
    2) Even if we decide that we don't create a frame, floating and
    non-floating table rows are different, so a separate table should be
    created for such rows. By doing all the StartApo() / StopApo(), we are
    safe here.
    
    (cherry picked from commit c2cf03e02b1c942645aea6988112028e13dd0c89)
    
    Change-Id: Ifc0e0e2f7320c3784698d0ff278031b46864e2e5

diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index a74c4d0..220a7e5 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -75,6 +75,7 @@
 #include <editeng/pgrditem.hxx>
 #include <editeng/frmdiritem.hxx>
 #include <editeng/charhiddenitem.hxx>
+#include <writerfilter/doctok/sprmids.hxx>
 #include <fmtpdsc.hxx>
 #include <node.hxx>
 #include <ndtxt.hxx> // SwTxtNode, siehe unten: JoinNode()
@@ -2172,6 +2173,8 @@ SwTwips SwWW8ImplReader::MoveOutsideFly(SwFrmFmt *pFlyFmt,
     const SwPosition &rPos, bool bTableJoin)
 {
     SwTwips nRetWidth = 0;
+    if (!pFlyFmt)
+        return nRetWidth;
     // Alle Attribute schliessen, da sonst Attribute entstehen koennen,
     // die aus Flys rausragen
     WW8DupProperties aDup(rDoc,pCtrlStck);
@@ -2322,10 +2325,15 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
 
         WW8FlySet aFlySet(*this, pWFlyPara, pSFlyPara, false);
 
-        pSFlyPara->pFlyFmt = rDoc.MakeFlySection( pSFlyPara->eAnchor,
-            pPaM->GetPoint(), &aFlySet );
-        OSL_ENSURE(pSFlyPara->pFlyFmt->GetAnchor().GetAnchorId() ==
-            pSFlyPara->eAnchor, "Not the anchor type requested!");
+        if (pTabPos && pTabPos->bNoFly)
+            pSFlyPara->pFlyFmt = 0;
+        else
+        {
+            pSFlyPara->pFlyFmt = rDoc.MakeFlySection( pSFlyPara->eAnchor,
+                    pPaM->GetPoint(), &aFlySet );
+            OSL_ENSURE(pSFlyPara->pFlyFmt->GetAnchor().GetAnchorId() ==
+                    pSFlyPara->eAnchor, "Not the anchor type requested!");
+        }
 
         if (pSFlyPara->pFlyFmt)
         {
@@ -2336,7 +2344,7 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
             pWWZOrder->InsertTextLayerObject(pOurNewObject);
         }
 
-        if (FLY_AS_CHAR != pSFlyPara->eAnchor)
+        if (FLY_AS_CHAR != pSFlyPara->eAnchor && pSFlyPara->pFlyFmt)
         {
             pAnchorStck->AddAnchor(*pPaM->GetPoint(),pSFlyPara->pFlyFmt);
         }
@@ -2350,7 +2358,8 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
         pSFlyPara->pOldAnchorStck = pAnchorStck;
         pAnchorStck = new SwWW8FltAnchorStack(&rDoc, nFieldFlags);
 
-        MoveInsideFly(pSFlyPara->pFlyFmt);
+        if (pSFlyPara->pFlyFmt)
+            MoveInsideFly(pSFlyPara->pFlyFmt);
 
         // 1) ReadText() wird nicht wie beim W4W-Reader rekursiv aufgerufen,
         //    da die Laenge des Apo zu diesen Zeitpunkt noch nicht feststeht,
@@ -2453,7 +2462,8 @@ void SwWW8ImplReader::StopApo()
             pNd->JoinNext();
         }
 
-        pSFlyPara->pFlyFmt->SetFmtAttr(SvxBrushItem(aBg, RES_BACKGROUND));
+        if (pSFlyPara->pFlyFmt)
+            pSFlyPara->pFlyFmt->SetFmtAttr(SvxBrushItem(aBg, RES_BACKGROUND));
 
         DeleteAnchorStk();
         pAnchorStck = pSFlyPara->pOldAnchorStck;
@@ -2477,7 +2487,7 @@ void SwWW8ImplReader::StopApo()
         #i27204# Added AutoWidth setting. Left the old CalculateFlySize in place
         so that if the user unselects autowidth, the width doesn't max out
         */
-        else if( !pWFlyPara->nSp28 )
+        else if( !pWFlyPara->nSp28 && pSFlyPara->pFlyFmt)
         {
             using namespace sw::util;
             SfxItemSet aFlySet( pSFlyPara->pFlyFmt->GetAttrSet() );
@@ -4824,6 +4834,17 @@ bool SwWW8ImplReader::ParseTabPos(WW8_TablePos *pTabPos, WW8PLCFx_Cp_FKP* pPap)
             pTabPos->nLoMgn = SVBT16ToShort(pRes);
         bRet = true;
     }
+    if (0 != (pRes = pPap->HasSprm(NS_sprm::LN_TDefTable)))
+    {
+        WW8TabBandDesc aDesc;
+        aDesc.ReadDef(false, pRes);
+        int nTableWidth = aDesc.nCenter[aDesc.nWwCols] - aDesc.nCenter[0];
+        int nTextAreaWidth = maSectionManager.GetTextAreaWidth();
+        // If the table is wider than the text area, then don't create a fly
+        // for the table: no wrapping will be performed anyway, but multi-page
+        // tables will be broken.
+        pTabPos->bNoFly = nTableWidth >= nTextAreaWidth;
+    }
     return bRet;
 }
 
diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx
index 98dff63..5bda235 100644
--- a/sw/source/filter/ww8/ww8struc.hxx
+++ b/sw/source/filter/ww8/ww8struc.hxx
@@ -803,6 +803,7 @@ struct WW8_TablePos
     sal_Int16 nLoMgn;
     sal_uInt8 nSp29;
     sal_uInt8 nSp37;
+    bool bNoFly;
 };
 
 struct WW8_FSPA
commit a4422e1c976d4d3f030671da13b765175439acbd
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon May 13 11:08:48 2013 +0200

    bnc#816603 SwWW8ImplReader::ParseTabPos: make this non-static
    
    I'll need to access the non-static maSectionManager in this method soon.
    
    (cherry picked from commit 1fd1ecd3451a39c837b42dd100aa5f154e01816b)
    
    Change-Id: Ia056ec9c812020c4ac0f4a0f1460a0c9506b12fa

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 5655def..e259bf5 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1677,7 +1677,7 @@ public:     // eigentlich private, geht aber leider nur public
 
     void Read_TabRowEnd(        sal_uInt16, const sal_uInt8* pData, short nLen );
     void Read_TabCellEnd(        sal_uInt16, const sal_uInt8* pData, short nLen );
-    static bool ParseTabPos(WW8_TablePos *aTabPos, WW8PLCFx_Cp_FKP* pPap);
+    bool ParseTabPos(WW8_TablePos *aTabPos, WW8PLCFx_Cp_FKP* pPap);
     void Read_Shade(            sal_uInt16, const sal_uInt8* pData, short nLen );
     void Read_ANLevelNo(        sal_uInt16, const sal_uInt8* pData, short nLen );
     void Read_ANLevelDesc(      sal_uInt16, const sal_uInt8* pData, short nLen );
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index fe0ee48..0cbbec2 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -1975,7 +1975,7 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
         //Get the end of row new table positioning data
         WW8_CP nMyStartCp=nStartCp;
         if (pIo->SearchRowEnd(pPap, nMyStartCp, pIo->nInTable))
-            if (SwWW8ImplReader::ParseTabPos(&aTabPos, pPap))
+            if (pIo->ParseTabPos(&aTabPos, pPap))
                 pTabPos = &aTabPos;
 
         //Move back to this cell
commit 3c922c203efb19e095c1687c0047e27d89c18c83
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon May 13 12:55:41 2013 +0200

    bnc#816603 sw: move WW8TabBandDesc to ww8par.hxx
    
    I'll need this struct in ww8par6.cxx soon.
    
    (cherry picked from commit 7d0dd9bd5b9fcd3b575c77e22c909bff15519a84)
    
    Change-Id: I4cf546ff585c89c076e4fdad93dbbb9b8ea72eca
    Conflicts:
            sw/source/filter/ww8/ww8par2.cxx

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index e2cc680..5655def 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -914,6 +914,62 @@ struct WW8PostProcessAttrsInfo
     WW8PostProcessAttrsInfo(WW8_CP nCpStart, WW8_CP nCpEnd, SwPaM & rPaM);
 };
 
+#define MAX_COL 64  // WW6-Beschreibung: 32, WW6-UI: 31 & WW8-UI: 63!
+
+struct WW8TabBandDesc
+{
+    WW8TabBandDesc* pNextBand;
+    short nGapHalf;
+    short mnDefaultLeft;
+    short mnDefaultTop;
+    short mnDefaultRight;
+    short mnDefaultBottom;
+    bool mbHasSpacing;
+    short nLineHeight;
+    short nRows;
+    sal_uInt16 maDirections[MAX_COL + 1];
+    short nCenter[MAX_COL + 1]; // X-Rand aller Zellen dieses Bandes
+    short nWidth[MAX_COL + 1];  // Laenge aller Zellen dieses Bandes
+    short nWwCols;      // sal_uInt8 wuerde reichen, alignment -> short
+    short nSwCols;      // SW: so viele Spalten fuer den Writer
+    bool bLEmptyCol;    // SW: Links eine leere Zusatz-Spalte
+    bool bREmptyCol;    // SW: dito rechts
+    bool bCantSplit;
+    bool bCantSplit90;
+    WW8_TCell* pTCs;
+    sal_uInt8 nOverrideSpacing[MAX_COL + 1];
+    short nOverrideValues[MAX_COL + 1][4];
+    WW8_SHD* pSHDs;
+    sal_uInt32* pNewSHDs;
+    WW8_BRC aDefBrcs[6];
+
+    bool bExist[MAX_COL];           // Existiert diese Zelle ?
+    sal_uInt8 nTransCell[MAX_COL + 2];  // UEbersetzung WW-Index -> SW-Index
+
+    sal_uInt8 transCell(sal_uInt8 nWwCol) const
+    {
+        return nWwCol < SAL_N_ELEMENTS(nTransCell) ? nTransCell[nWwCol] : 0xFF;
+    }
+
+    WW8TabBandDesc();
+    WW8TabBandDesc(WW8TabBandDesc& rBand);    // tief kopieren
+    ~WW8TabBandDesc();
+    static void setcelldefaults(WW8_TCell *pCells, short nCells);
+    void ReadDef(bool bVer67, const sal_uInt8* pS);
+    void ProcessDirection(const sal_uInt8* pParams);
+    void ProcessSprmTSetBRC(bool bVer67, const sal_uInt8* pParamsTSetBRC);
+    void ProcessSprmTTableBorders(bool bVer67, const sal_uInt8* pParams);
+    void ProcessSprmTDxaCol(const sal_uInt8* pParamsTDxaCol);
+    void ProcessSprmTDelete(const sal_uInt8* pParamsTDelete);
+    void ProcessSprmTInsert(const sal_uInt8* pParamsTInsert);
+    void ProcessSpacing(const sal_uInt8* pParamsTInsert);
+    void ProcessSpecificSpacing(const sal_uInt8* pParamsTInsert);
+    void ReadShd(const sal_uInt8* pS );
+    void ReadNewShd(const sal_uInt8* pS, bool bVer67);
+
+    enum wwDIR {wwTOP = 0, wwLEFT = 1, wwBOTTOM = 2, wwRIGHT = 3};
+};
+
 //-----------------------------------------
 //            Storage-Reader
 //-----------------------------------------
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 679f116..fe0ee48 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -75,8 +75,6 @@
 
 #include <iostream>
 
-#define MAX_COL 64  // WW6-Beschreibung: 32, WW6-UI: 31 & WW8-UI: 63!
-
 using namespace ::com::sun::star;
 
 
@@ -97,60 +95,6 @@ public:
 
 typedef boost::ptr_vector<WW8SelBoxInfo> WW8MergeGroups;
 
-struct WW8TabBandDesc
-{
-    WW8TabBandDesc* pNextBand;
-    short nGapHalf;
-    short mnDefaultLeft;
-    short mnDefaultTop;
-    short mnDefaultRight;
-    short mnDefaultBottom;
-    bool mbHasSpacing;
-    short nLineHeight;
-    short nRows;
-    sal_uInt16 maDirections[MAX_COL + 1];
-    short nCenter[MAX_COL + 1]; // X-Rand aller Zellen dieses Bandes
-    short nWidth[MAX_COL + 1];  // Laenge aller Zellen dieses Bandes
-    short nWwCols;      // sal_uInt8 wuerde reichen, alignment -> short
-    short nSwCols;      // SW: so viele Spalten fuer den Writer
-    bool bLEmptyCol;    // SW: Links eine leere Zusatz-Spalte
-    bool bREmptyCol;    // SW: dito rechts
-    bool bCantSplit;
-    bool bCantSplit90;
-    WW8_TCell* pTCs;
-    sal_uInt8 nOverrideSpacing[MAX_COL + 1];
-    short nOverrideValues[MAX_COL + 1][4];
-    WW8_SHD* pSHDs;
-    sal_uInt32* pNewSHDs;
-    WW8_BRC aDefBrcs[6];
-
-    bool bExist[MAX_COL];           // Existiert diese Zelle ?
-    sal_uInt8 nTransCell[MAX_COL + 2];  // UEbersetzung WW-Index -> SW-Index
-
-    sal_uInt8 transCell(sal_uInt8 nWwCol) const
-    {
-        return nWwCol < SAL_N_ELEMENTS(nTransCell) ? nTransCell[nWwCol] : 0xFF;
-    }
-
-    WW8TabBandDesc();
-    WW8TabBandDesc(WW8TabBandDesc& rBand);    // tief kopieren
-    ~WW8TabBandDesc();
-    static void setcelldefaults(WW8_TCell *pCells, short nCells);
-    void ReadDef(bool bVer67, const sal_uInt8* pS);
-    void ProcessDirection(const sal_uInt8* pParams);
-    void ProcessSprmTSetBRC(bool bVer67, const sal_uInt8* pParamsTSetBRC);
-    void ProcessSprmTTableBorders(bool bVer67, const sal_uInt8* pParams);
-    void ProcessSprmTDxaCol(const sal_uInt8* pParamsTDxaCol);
-    void ProcessSprmTDelete(const sal_uInt8* pParamsTDelete);
-    void ProcessSprmTInsert(const sal_uInt8* pParamsTInsert);
-    void ProcessSpacing(const sal_uInt8* pParamsTInsert);
-    void ProcessSpecificSpacing(const sal_uInt8* pParamsTInsert);
-    void ReadShd(const sal_uInt8* pS );
-    void ReadNewShd(const sal_uInt8* pS, bool bVer67);
-
-    enum wwDIR {wwTOP = 0, wwLEFT = 1, wwBOTTOM = 2, wwRIGHT = 3};
-};
-
 WW8TabBandDesc::WW8TabBandDesc()
 {
     memset(this, 0, sizeof(*this));


More information about the Libreoffice-commits mailing list