[Libreoffice-commits] core.git: Branch 'feature/table-style' - 4 commits - sw/inc sw/source
Alex Ivan
alexnivan at yahoo.com
Fri Aug 9 10:50:40 PDT 2013
sw/inc/swtblfmt.hxx | 2 ++
sw/source/core/doc/swtblfmt.cxx | 8 ++++++++
sw/source/core/docnode/ndtbl.cxx | 29 +++++++++++++++--------------
sw/source/core/inc/UndoTable.hxx | 4 +---
sw/source/core/undo/untbl.cxx | 11 ++---------
5 files changed, 28 insertions(+), 26 deletions(-)
New commits:
commit 8d9905db69b2693cde5e80e53ccab521f4b8040f
Author: Alex Ivan <alexnivan at yahoo.com>
Date: Fri Aug 9 17:10:10 2013 +0300
Fix undo for applying table style
Undo now works for applying a new table style. There is an issue
where other undo commands i.e. resizing a cell will undo the
table style, probably due to not setting the parents correctly.
Change-Id: Ia7955e6303be57ec9ea10bd61a355a888818c420
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 4dd25c0..1a7ff43 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3556,7 +3556,7 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt&
bool const bUndo(GetIDocumentUndoRedo().DoesUndo());
if (bUndo)
{
- pUndo = new SwUndoTblAutoFmt( *pTblNd, rNew );
+ pUndo = new SwUndoTblAutoFmt( *pTblNd );
GetIDocumentUndoRedo().AppendUndo(pUndo);
GetIDocumentUndoRedo().DoUndo(false);
}
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 37f5c41..09bed01 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -153,9 +153,7 @@ class SwUndoTblAutoFmt : public SwUndo
void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext);
public:
- SwUndoTblAutoFmt( const SwTableNode& rTblNd, const SwTableAutoFmt& );
-
- virtual ~SwUndoTblAutoFmt();
+ SwUndoTblAutoFmt( const SwTableNode& rTblNd );
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 8c30a50..5ddb001 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1406,18 +1406,12 @@ void SwUndoAttrTbl::RedoImpl(::sw::UndoRedoContext & rContext)
}
// UndoObject for AutoFormat on Table
-SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd,
- const SwTableAutoFmt& rAFmt )
+SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd )
: SwUndo( UNDO_TABLE_AUTOFMT ),
nSttNode( rTblNd.GetIndex() ),
m_nRepeatHeading(rTblNd.GetTable().GetRowsToRepeat())
{
- pSaveFmt = new SwTableFmt( *rAFmt.GetTableStyle() );
-}
-
-SwUndoTblAutoFmt::~SwUndoTblAutoFmt()
-{
- delete pSaveFmt;
+ pSaveFmt = (SwTableFmt*)rTblNd.GetTable().GetTableFmt()->GetRegisteredIn();
}
void
@@ -1434,7 +1428,6 @@ SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext)
table.SetRowsToRepeat( m_nRepeatHeading );
SwTableFmt::RestoreTableProperties( pSaveFmt, table );
- delete pSaveFmt;
pSaveFmt = pOrig;
}
commit 085921a92a9255b1419687c2c0efb08145729cf3
Author: Alex Ivan <alexnivan at yahoo.com>
Date: Fri Aug 9 17:05:19 2013 +0300
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
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index c6adade..4dd25c0 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 );
}
commit 4fb2c9d396726af35ee22a5417708679710e0dbe
Author: Alex Ivan <alexnivan at yahoo.com>
Date: Wed Aug 7 14:23:21 2013 +0300
Correct previously skipped function in parent assigning cleanup
Change-Id: I12edb436caabd1f74943e77da69b03e17f56f196
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 614800d..c6adade 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -743,7 +743,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts,
}
}
- SwTableFmt::AssignLineParents( pTableStyle, *pNdTbl );
+ SwTableFmt::AssignFormatParents( pTableStyle, *pNdTbl );
// Check the Boxes' for Numbers
if( IsInsTblFormatNum() )
commit bbe418154e75377e9f5a2c41eaf63906913e7346
Author: Alex Ivan <alexnivan at yahoo.com>
Date: Wed Aug 7 12:23:05 2013 +0300
Partially fix properties update
Invalidating and setting complete paint for the SwTabFrms of the
table causes immediate update of the properties, with the
exception of the borders.
Font properties yet to be fixed.
Change-Id: Ie28a2f802ed9a2ad7f7d04ed283ea308b82e5b02
diff --git a/sw/inc/swtblfmt.hxx b/sw/inc/swtblfmt.hxx
index 51c279a..b4e709d 100644
--- a/sw/inc/swtblfmt.hxx
+++ b/sw/inc/swtblfmt.hxx
@@ -51,6 +51,8 @@
#include <frmfmt.hxx>
#include <paratr.hxx>
#include <swtable.hxx>
+#include <switerator.hxx>
+#include <tabfrm.hxx>
struct SwAfVersions;
diff --git a/sw/source/core/doc/swtblfmt.cxx b/sw/source/core/doc/swtblfmt.cxx
index 8a798f0..276c37a 100644
--- a/sw/source/core/doc/swtblfmt.cxx
+++ b/sw/source/core/doc/swtblfmt.cxx
@@ -282,6 +282,14 @@ void SwTableFmt::AssignFormatParents( SwTableFmt* pSrcFmt, SwTable &rTable )
pHardFmt->GetAttrSet().SetParent( NULL );
AssignLineParents( pSrcFmt, rTable );
+
+ SwIterator<SwTabFrm,SwFmt> aIter( *rTable.GetFrmFmt() );
+ for( SwTabFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
+ if( pLast->GetTable() == &rTable )
+ {
+ pLast->InvalidateAll();
+ pLast->SetCompletePaint();
+ }
}
void SwTableFmt::AssignLineParents( SwTableFmt* pSrcFmt, SwTable &rTable )
More information about the Libreoffice-commits
mailing list