diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-09-26 17:55:31 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-09-27 22:48:21 +0200 |
commit | 73f4a06c0bce51c7c8b9ae9adfdc7ffac27d06b4 (patch) | |
tree | aec530a6ce7f784b113544ccc4cc794b167338b2 | |
parent | ac6f8bc92b1abe995694602f43d8ad108b7030fb (diff) |
sw table styles: Insert column, split table, delete row/column.
Make these operations applying the table style too.
Change-Id: Iee2808a5a5c5f84538474b8fbc6bf53d1fab19b7
-rw-r--r-- | sw/inc/fesh.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/tblrwcl.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/frmedt/fetab.cxx | 23 | ||||
-rw-r--r-- | sw/source/core/table/swtable.cxx | 1 |
5 files changed, 37 insertions, 11 deletions
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index a41e119eef2f..a4829e8ee136 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -724,7 +724,8 @@ public: bool SetTableStyle(const SwTableAutoFormat& rNew); /// Update the direct formatting according to the current table style. - bool UpdateTableStyleFormatting(); + /// @param pTableNode Table node to update. When nullptr, current cursor position is used. + bool UpdateTableStyleFormatting(SwTableNode *pTableNode = nullptr); bool GetTableAutoFormat( SwTableAutoFormat& rGet ); diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 9574e0ae88f8..acc2d8e70974 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -550,6 +550,8 @@ bool SwTable::InsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, pPCD->AddRowCols( *this, rBoxes, nCnt, bBehind ); pDoc->UpdateCharts( GetFrameFormat()->GetName() ); + pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + return bRes; } @@ -2095,6 +2097,8 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos, pTableNd->GetTable().SetRowsToRepeat( GetRowsToRepeat() ); + pNewTable->SetTableStyleName(pTableNd->GetTable().GetTableStyleName()); + if( IS_TYPE( SwDDETable, this )) { // A DDE-Table is being copied diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 5f50cc95a2c6..5d3499b4d998 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2104,8 +2104,12 @@ bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) pTableNd->DelFrms(); getIDocumentContentOperations().DeleteSection( pTableNd ); } + + GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 ); + return true; } @@ -2135,6 +2139,8 @@ bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) bRet = rTable.DeleteSel( this, aSelBoxes, 0, pUndo, true, true ); if (bRet) { + GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 ); } @@ -2203,6 +2209,8 @@ bool SwDoc::SplitTable( const SwSelBoxes& rBoxes, bool bVert, sal_uInt16 nCnt, if (bRet) { + GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 ); } @@ -2310,6 +2318,7 @@ sal_uInt16 SwDoc::MergeTable( SwPaM& rPam ) if( pTableNd->GetTable().Merge( this, aBoxes, aMerged, pMergeBox, pUndo )) { nRet = TBLMERGE_OK; + getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 ); if( pUndo ) @@ -3257,6 +3266,10 @@ bool SwDoc::SplitTable( const SwPosition& rPos, sal_uInt16 eHdlnMode, // TL_CHART2: need to inform chart of probably changed cell names UpdateCharts( rTable.GetFrameFormat()->GetName() ); + // update table style formatting of both the tables + GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTNd); + GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pNew); + getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 ); return 0 != pNew; @@ -3457,6 +3470,8 @@ SwTableNode* SwNodes::SplitTable( const SwNodeIndex& rPos, bool bAfter, *pNewTableFormat = *pOldTableFormat; pNewTableNd->GetTable().RegisterToFormat( *pNewTableFormat ); + pNewTableNd->GetTable().SetTableStyleName(rTable.GetTableStyleName()); + // Calculate a new Size? // lcl_ChgTableSize: Only execute the second call if the first call was // successful, thus has an absolute Size @@ -3527,6 +3542,8 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool bWithPrev, sal_uInt16 nMode } if( bRet ) { + GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 ); } diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 191ba23edca2..5d4551cf9982 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -1181,22 +1181,25 @@ bool SwFEShell::SetTableStyle(const SwTableAutoFormat& rStyle) // make sure SwDoc has the style GetDoc()->GetTableStyles().AddAutoFormat(rStyle); - SwTableNode *pTableNd = const_cast<SwTableNode*>(IsCrsrInTable()); - if (!pTableNd) + SwTableNode *pTableNode = const_cast<SwTableNode*>(IsCrsrInTable()); + if (!pTableNode) return false; // set the name & update - pTableNd->GetTable().SetTableStyleName(rStyle.GetName()); - return UpdateTableStyleFormatting(); + pTableNode->GetTable().SetTableStyleName(rStyle.GetName()); + return UpdateTableStyleFormatting(pTableNode); } -bool SwFEShell::UpdateTableStyleFormatting() +bool SwFEShell::UpdateTableStyleFormatting(SwTableNode *pTableNode) { - SwTableNode *pTableNd = const_cast<SwTableNode*>(IsCrsrInTable()); - if( !pTableNd || pTableNd->GetTable().IsTableComplex() ) - return false; + if (!pTableNode) + { + pTableNode = const_cast<SwTableNode*>(IsCrsrInTable()); + if (!pTableNode || pTableNode->GetTable().IsTableComplex()) + return false; + } - OUString aTableStyleName(pTableNd->GetTable().GetTableStyleName()); + OUString aTableStyleName(pTableNode->GetTable().GetTableStyleName()); SwTableAutoFormat* pTableStyle = GetDoc()->GetTableStyles().FindAutoFormat(aTableStyleName); if (!pTableStyle) return false; @@ -1211,7 +1214,7 @@ bool SwFEShell::UpdateTableStyleFormatting() ::GetTableSelCrs( *this, aBoxes ); else { - const SwTableSortBoxes& rTBoxes = pTableNd->GetTable().GetTabSortBoxes(); + const SwTableSortBoxes& rTBoxes = pTableNode->GetTable().GetTabSortBoxes(); for (size_t n = 0; n < rTBoxes.size(); ++n) { SwTableBox* pBox = rTBoxes[ n ]; diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index ca75280e3b8a..3a6abf1d84e8 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -264,6 +264,7 @@ SwTable::SwTable( const SwTable& rTable ) eTableChgMode( rTable.eTableChgMode ), nGrfsThatResize( 0 ), nRowsToRepeat( rTable.GetRowsToRepeat() ), + maTableStyleName(rTable.maTableStyleName), bModifyLocked( false ), bNewModel( rTable.bNewModel ) { |