diff options
author | Alex Ivan <alexnivan@yahoo.com> | 2013-08-09 17:05:19 +0300 |
---|---|---|
committer | Alex Ivan <alexnivan@yahoo.com> | 2013-08-09 17:05:19 +0300 |
commit | 085921a92a9255b1419687c2c0efb08145729cf3 (patch) | |
tree | 2eb2eba48a92a072278ec9bce35faf6e177ec5c6 | |
parent | 4fb2c9d396726af35ee22a5417708679710e0dbe (diff) |
Fix borders on Text to table method
Default borders no longer mask the ones from the table style if
borders checkbox is checked in Text to Table dialog and an
autoformat is selected. In other words, it bypasses the state of
said checkbox. May instead want to default its state to unchecked
in order to be clearer to the user.
Also, there is a strange crash on the undo operation. (Somehow,
a pointer ends up pointing to 0x99..9)
Change-Id: I4fe5ebec5ea2470d6b27869f043b5110d5fc0c3a
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index c6adade07366..4dd25c0c62a0 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -103,7 +103,7 @@ extern void ClearFEShellTabCols(); // Located in gctable.cxx extern sal_Bool sw_GC_Line_Border( const SwTableLine*& , void* pPara ); -static void lcl_SetDfltBoxAttr( SwFrmFmt& rFmt, sal_uInt8 nId ) +static void lcl_SetDfltBoxAttr( SwFrmFmt& rFmt, sal_uInt8 nId, sal_Bool bSetBorders ) { sal_Bool bTop = false, bBottom = false, bLeft = false, bRight = false; switch ( nId ) @@ -131,7 +131,8 @@ static void lcl_SetDfltBoxAttr( SwFrmFmt& rFmt, sal_uInt8 nId ) aBox.SetLine( &aLine, BOX_LINE_LEFT ); if ( bRight ) aBox.SetLine( &aLine, BOX_LINE_RIGHT ); - rFmt.SetFmtAttr( aBox ); + if ( bSetBorders ) + rFmt.SetFmtAttr( aBox ); } typedef std::map<SwFrmFmt *, SwTableBoxFmt *> DfltBoxAttrMap_t; @@ -139,7 +140,7 @@ typedef std::vector<DfltBoxAttrMap_t *> DfltBoxAttrList_t; static void lcl_SetDfltBoxAttr(SwTableBox& rBox, DfltBoxAttrList_t & rBoxFmtArr, - sal_uInt8 const nId, SwTableAutoFmt const*const pAutoFmt = 0) + sal_uInt8 const nId, sal_Bool bSetBorders ) { DfltBoxAttrMap_t * pMap = rBoxFmtArr[ nId ]; if (!pMap) @@ -162,7 +163,7 @@ lcl_SetDfltBoxAttr(SwTableBox& rBox, DfltBoxAttrList_t & rBoxFmtArr, pNewTableBoxFmt = pDoc->MakeTableBoxFmt(); pNewTableBoxFmt->SetFmtAttr( pBoxFrmFmt->GetAttrSet().Get( RES_FRM_SIZE ) ); - ::lcl_SetDfltBoxAttr( *pNewTableBoxFmt, nId ); + ::lcl_SetDfltBoxAttr( *pNewTableBoxFmt, nId, bSetBorders ); (*pMap)[pBoxFrmFmt] = pNewTableBoxFmt; } @@ -170,7 +171,7 @@ lcl_SetDfltBoxAttr(SwTableBox& rBox, DfltBoxAttrList_t & rBoxFmtArr, } static SwTableBoxFmt *lcl_CreateDfltBoxFmt( SwDoc &rDoc, std::vector<SwTableBoxFmt*> &rBoxFmtArr, - sal_uInt16 nCols, sal_uInt8 nId ) + sal_uInt16 nCols, sal_uInt8 nId, sal_Bool bSetBorders ) { if ( !rBoxFmtArr[nId] ) { @@ -178,7 +179,7 @@ static SwTableBoxFmt *lcl_CreateDfltBoxFmt( SwDoc &rDoc, std::vector<SwTableBoxF if( USHRT_MAX != nCols ) pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX / nCols, 0 )); - ::lcl_SetDfltBoxAttr( *pBoxFmt, nId ); + ::lcl_SetDfltBoxAttr( *pBoxFmt, nId, bSetBorders ); rBoxFmtArr[ nId ] = pBoxFmt; } return rBoxFmtArr[nId]; @@ -442,7 +443,7 @@ const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTblOpts, std::vector<SwTableBoxFmt*> aBoxFmtArr; SwTableBoxFmt* pBoxFmt = 0; - if( !bDfltBorders || pTAFmt ) + if( !bDfltBorders ) { pBoxFmt = MakeTableBoxFmt(); pBoxFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX / nCols, 0 )); @@ -460,10 +461,10 @@ const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTblOpts, for( sal_uInt16 i = 0; i < nCols; ++i ) { SwTableBoxFmt *pBoxF; - if( !pTAFmt && bDfltBorders ) + if( bDfltBorders ) { sal_uInt8 nBoxId = (i < nCols - 1 ? 0 : 1) + (n ? 2 : 0 ); - pBoxF = new SwTableBoxFmt( *::lcl_CreateDfltBoxFmt( *this, aBoxFmtArr, nCols, nBoxId) ); + pBoxF = new SwTableBoxFmt( *::lcl_CreateDfltBoxFmt( *this, aBoxFmtArr, nCols, nBoxId, pTAFmt == 0) ); } else pBoxF = new SwTableBoxFmt( *pBoxFmt ); @@ -705,7 +706,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts, pNdTbl->RegisterToFormat( *pTableFmt ); - if( rInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER ) + if( pTAFmt || rInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER ) { sal_uInt8 nBoxArrLen = 4; boost::scoped_ptr< DfltBoxAttrList_t > aBoxFmtArr1; @@ -732,10 +733,10 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts, sal_uInt8 nId = (i < nCols - 1 ? 0 : 1) + (n ? 2 : 0 ); if( bUseBoxFmt ) - ::lcl_SetDfltBoxAttr( *pBox, *aBoxFmtArr1, nId ); + ::lcl_SetDfltBoxAttr( *pBox, *aBoxFmtArr1, nId, pTAFmt == 0 ); else { - pBoxF = new SwTableBoxFmt ( *::lcl_CreateDfltBoxFmt( *this, *aBoxFmtArr2, USHRT_MAX, nId ) ); + pBoxF = new SwTableBoxFmt ( *::lcl_CreateDfltBoxFmt( *this, *aBoxFmtArr2, USHRT_MAX, nId, pTAFmt == 0 ) ); pBoxF->SetFmtAttr( pBox->GetFrmFmt()->GetFrmSize() ); pBox->ChgFrmFmt( pBoxF ); } |