[Libreoffice-commits] core.git: 3 commits - sw/source

Miklos Vajna vmiklos at suse.cz
Mon May 13 02:43:51 PDT 2013


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

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

    Related: 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.
    
    Change-Id: Ifc0e0e2f7320c3784698d0ff278031b46864e2e5

diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index a8ff78d..3927540 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2164,6 +2164,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);
@@ -2314,10 +2316,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)
         {
@@ -2328,7 +2335,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);
         }
@@ -2342,7 +2349,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,
@@ -2445,7 +2453,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;
@@ -2469,7 +2478,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() );
@@ -4812,6 +4821,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 56d39d9..06b3578 100644
--- a/sw/source/filter/ww8/ww8struc.hxx
+++ b/sw/source/filter/ww8/ww8struc.hxx
@@ -794,6 +794,7 @@ struct WW8_TablePos
     sal_Int16 nLoMgn;
     sal_uInt8 nSp29;
     sal_uInt8 nSp37;
+    bool bNoFly;
 };
 
 struct WW8_FSPA
commit 6618d0764d75a9524b2d634883047bdd888c6ee0
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon May 13 11:08:48 2013 +0200

    SwWW8ImplReader::ParseTabPos: make this non-static
    
    I'll need to access the non-static maSectionManager in this method soon.
    
    Change-Id: Ia056ec9c812020c4ac0f4a0f1460a0c9506b12fa

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index d6b9f05..97be94e 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1690,7 +1690,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 49951cf..6a8836b 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -1997,7 +1997,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 7d0dd9bd5b9fcd3b575c77e22c909bff15519a84
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon May 13 11:07:43 2013 +0200

    sw: move WW8TabBandDesc to ww8par.hxx
    
    I'll need this struct in ww8par6.cxx soon.
    
    Change-Id: I4cf546ff585c89c076e4fdad93dbbb9b8ea72eca

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index e6d706a..d6b9f05 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -913,6 +913,62 @@ struct WW8PostProcessAttrsInfo
     WW8PostProcessAttrsInfo(WW8_CP nCpStart, WW8_CP nCpEnd, SwPaM & rPaM);
 };
 
+#define MAX_COL 64  // WW6-description: 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-edge of all cells of this band
+    short nWidth[MAX_COL + 1];  // length of all cells of this band
+    short nWwCols;      // sal_uInt8 would be sufficient, alignment -> short
+    short nSwCols;      // SW: number of columns for the writer
+    bool bLEmptyCol;    // SW: an additional empty column at the left
+    bool bREmptyCol;    // SW: same at the right
+    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];           // does this cell exist ?
+    sal_uInt8 nTransCell[MAX_COL + 2];  // translation WW-Index -> SW-Index
+
+    sal_uInt8 transCell(sal_uInt8 nWwCol) const
+    {
+        return nWwCol < SAL_N_ELEMENTS(nTransCell) ? nTransCell[nWwCol] : 0xFF;
+    }
+
+    WW8TabBandDesc();
+    WW8TabBandDesc(WW8TabBandDesc& rBand);    // deep copy
+    ~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 7b6b649..49951cf 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -67,8 +67,6 @@
 
 #include <iostream>
 
-#define MAX_COL 64  // WW6-description: 32, WW6-UI: 31 & WW8-UI: 63!
-
 using namespace ::com::sun::star;
 
 
@@ -90,60 +88,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-edge of all cells of this band
-    short nWidth[MAX_COL + 1];  // length of all cells of this band
-    short nWwCols;      // sal_uInt8 would be sufficient, alignment -> short
-    short nSwCols;      // SW: number of columns for the writer
-    bool bLEmptyCol;    // SW: an additional empty column at the left
-    bool bREmptyCol;    // SW: same at the right
-    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];           // does this cell exist ?
-    sal_uInt8 nTransCell[MAX_COL + 2];  // translation WW-Index -> SW-Index
-
-    sal_uInt8 transCell(sal_uInt8 nWwCol) const
-    {
-        return nWwCol < SAL_N_ELEMENTS(nTransCell) ? nTransCell[nWwCol] : 0xFF;
-    }
-
-    WW8TabBandDesc();
-    WW8TabBandDesc(WW8TabBandDesc& rBand);    // deep copy
-    ~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