sw/inc/doc.hxx | 3 +++ sw/source/core/doc/docnew.cxx | 5 +++++ sw/source/core/doc/swtblfmt.cxx | 3 +++ sw/source/core/doc/tblafmt.cxx | 9 +++------ sw/source/core/doc/tblrwcl.cxx | 8 +++++++- sw/source/core/docnode/ndcopy.cxx | 9 ++++++++- sw/source/core/docnode/ndtbl.cxx | 14 ++++++++++++++ sw/source/core/undo/untbl.cxx | 13 +++++++++++-- sw/source/ui/table/tautofmt.cxx | 4 +--- 9 files changed, 55 insertions(+), 13 deletions(-)
New commits: commit 452435c85c5fbe1e62ec81bc39deccb646a78bf6 Author: Alex Ivan <alexni...@yahoo.com> Date: Thu Aug 29 19:02:57 2013 +0300 Reapply table style after merging tables The undo part was inadvertedly already fixed since it used the same mechanics as some of the previously fixed undo actions. Change-Id: I75380513945a6b84fa8f18ab77c756b4e8c358c1 diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 8133065..d67ca3a 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -3390,6 +3390,9 @@ sal_Bool SwDoc::MergeTable( const SwPosition& rPos, sal_Bool bWithPrev, sal_uInt if( !pDelTblNd ) return sal_False; + SwTableFmt* pStyle = (SwTableFmt*)pTblNd->GetTable().GetTableFmt()->GetRegisteredIn(); + SwTable& rTable = (bWithPrev ? pDelTblNd : pTblNd)->GetTable(); + if( pTblNd->GetTable().ISA( SwDDETable ) || pDelTblNd->GetTable().ISA( SwDDETable )) return sal_False; @@ -3427,6 +3430,8 @@ sal_Bool SwDoc::MergeTable( const SwPosition& rPos, sal_Bool bWithPrev, sal_uInt } if( bRet ) { + SwTableFmt::AssignFormatParents( pStyle, rTable ); + SetModified(); SetFieldsDirty( true, NULL, 0 ); } commit 758c691d749b3e2770a4b7a14579e5bbfde5114a Author: Alex Ivan <alexni...@yahoo.com> Date: Thu Aug 29 18:15:44 2013 +0300 Reapply table style after spliting table and undo Change-Id: I32fea8b4679809070a47368de65d57ce5df7ed9d diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index e6d5821..8133065 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -3153,6 +3153,9 @@ sal_Bool SwDoc::SplitTable( const SwPosition& rPos, sal_uInt16 eHdlnMode, // TL_CHART2: need to inform chart of probably changed cell names UpdateCharts( rTbl.GetFrmFmt()->GetName() ); + SwTableFmt::AssignFormatParents( (SwTableFmt*)rTbl.GetTableFmt()->GetRegisteredIn(), rTbl ); + SwTableFmt::AssignFormatParents( (SwTableFmt*)rTbl.GetTableFmt()->GetRegisteredIn(), pNew->GetTable() ); + SetFieldsDirty( true, NULL, 0 ); return 0 != pNew; diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 661ed33..5fa3d2a 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -2927,6 +2927,12 @@ void SwUndoSplitTbl::UndoImpl(::sw::UndoRedoContext & rContext) pTblNd->GetTable().RestoreRowSpan( *mpSaveRowSpan ); } ClearFEShellTabCols(); + + pTblNd = rIdx.GetNode().FindTableNode(); + if( pTblNd ) + SwTableFmt::AssignFormatParents( (SwTableFmt*)pTblNd->GetTable(). + GetTableFmt()->GetRegisteredIn(), + pTblNd->GetTable() ); } void SwUndoSplitTbl::RedoImpl(::sw::UndoRedoContext & rContext) commit 49d18eb95929b4d0fadfaa5ba553049922bd4fb4 Author: Alex Ivan <alexni...@yahoo.com> Date: Thu Aug 29 15:26:02 2013 +0300 Reapply table styles after merging/spliting cells and corresponding undos Change-Id: I0a0f1cd1ec05487230af568ab3350de04d98bfb6 diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 0a09ccd..e6d5821 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2112,6 +2112,8 @@ sal_Bool SwDoc::SplitTbl( const SwSelBoxes& rBoxes, sal_Bool bVert, sal_uInt16 n delete pUndo; } + SwTableFmt::AssignFormatParents( (SwTableFmt*)rTbl.GetTableFmt()->GetRegisteredIn(), rTbl ); + return bRet; } @@ -2217,6 +2219,10 @@ sal_uInt16 SwDoc::MergeTbl( SwPaM& rPam ) ::ClearFEShellTabCols(); SetRedlineMode_intern( eOld ); } + + SwTableFmt::AssignFormatParents( (SwTableFmt*)rTable.GetTableFmt()->GetRegisteredIn(), + rTable ); + GetIDocumentUndoRedo().EndUndo( UNDO_TABLE_MERGE, NULL ); return nRet; } diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index afba0c2..661ed33 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -2076,6 +2076,9 @@ CHECKTABLE(pTblNd->GetTable()) CHECKTABLE(pTblNd->GetTable()) ClearFEShellTabCols(); + + SwTableFmt::AssignFormatParents( (SwTableFmt*)pTblNd->GetTable().GetTableFmt()->GetRegisteredIn(), + pTblNd->GetTable() ); } void SwUndoTblMerge::RedoImpl(::sw::UndoRedoContext & rContext) commit 453ddd7267b539e755cdc63eb8cbd6fa24ec4998 Author: Alex Ivan <alexni...@yahoo.com> Date: Wed Aug 28 18:52:39 2013 +0300 Fix copy-pasting table with no table style Change-Id: I11eee9b3a7762dd2500129994e4da61b5b149520 diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 692d23e..370807d 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -429,11 +429,11 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const } SwTableFmt* pStyle = (SwTableFmt*)GetTable().GetTableFmt()->GetRegisteredIn(); - SwTableFmt* pActualStyle = pDoc->FindTblFmtByName( pStyle->GetName(), sal_True ); + SwTableFmt* pActualStyle = pStyle ? pDoc->FindTblFmtByName( pStyle->GetName() , sal_True ) : 0; if( !pActualStyle ) pActualStyle = pStyle; - SwFrmFmt* pTblFmt = pDoc->MakeTblFrmFmt( sTblName, pStyle ? pStyle : pDoc->GetDfltFrmFmt() ); + SwFrmFmt* pTblFmt = pDoc->MakeTblFrmFmt( sTblName, pActualStyle ? pActualStyle : pDoc->GetDfltFrmFmt() ); pTblFmt->CopyAttrs( *GetTable().GetFrmFmt() ); SwTableNode* pTblNd = new SwTableNode( rIdx ); SwEndNode* pEndNd = new SwEndNode( rIdx, *pTblNd ); commit 5766905d06fbc4d280d7f5d94b5167b5d42324b2 Author: Alex Ivan <alexni...@yahoo.com> Date: Wed Aug 28 16:09:44 2013 +0300 Replace String with OUString in table style undo Change-Id: Ibc66d8ea44ac294832cf7c937d7e03fba4ad635b diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 8181640..afba0c2 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -116,7 +116,7 @@ class _SaveTable SfxItemSet aTblSet; _SaveLine* pLine; const SwTable* pSwTable; - String sSaveFmtName; + OUString sSaveFmtName; SfxItemSets aSets; SwFrmFmts aFrmFmts; sal_uInt16 nLineCount; @@ -978,7 +978,7 @@ void _SaveTable::RestoreAttr( SwTable& rTbl, bool bMdfyBox ) pLn->RestoreAttr( *rTbl.GetTabLines()[ n ], *this ); } - if( !sSaveFmtName.Len() ) + if( sSaveFmtName.isEmpty() ) SwTableFmt::RestoreTableProperties( NULL, rTbl ); else { commit 33d2dde3bf0f754ec07a093135fabf07ea7cac06 Author: Alex Ivan <alexni...@yahoo.com> Date: Wed Aug 28 15:40:28 2013 +0300 Apply table style copying from writer to writer After the table is copied to the new doc, we search for a style with the same name in this doc, and, if one exists, we apply that one, else, we apply the one from the clipboard. Change-Id: I8e3b6b15efa9d7a267cb48223a6f0d62dde46d6f diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 70560a7..53514b1 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -46,6 +46,7 @@ #include <cellatr.hxx> #include <mvsave.hxx> #include <swtblfmt.hxx> +#include <tblafmt.hxx> #include <swddetbl.hxx> #include <poolfmt.hxx> #include <tblrwcl.hxx> @@ -2152,10 +2153,15 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos, pInsDoc->CopyTxtColl( *pSrcDoc->GetTxtCollFromPool( RES_POOLCOLL_TABLE_HDLN ) ); } + SwTableFmt* pStyle = (SwTableFmt*)GetTableFmt()->GetRegisteredIn(); + SwTableAutoFmt* pAutoFmt = 0; + if( pStyle ) + pAutoFmt = new SwTableAutoFmt( pStyle->GetName(), pStyle ); + SwTable* pNewTbl = (SwTable*)pInsDoc->InsertTable( SwInsertTableOptions( tabopts::HEADLINE_NO_BORDER, 1 ), rPos, 1, 1, GetFrmFmt()->GetHoriOrient().GetHoriOrient(), - 0, 0, sal_False, IsNewModel() ); + pAutoFmt, 0, sal_False, IsNewModel() ); if( !pNewTbl ) return false; diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 7df0ae4..692d23e 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -428,7 +428,12 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const } } - SwFrmFmt* pTblFmt = pDoc->MakeTblFrmFmt( sTblName, pDoc->GetDfltFrmFmt() ); + SwTableFmt* pStyle = (SwTableFmt*)GetTable().GetTableFmt()->GetRegisteredIn(); + SwTableFmt* pActualStyle = pDoc->FindTblFmtByName( pStyle->GetName(), sal_True ); + if( !pActualStyle ) + pActualStyle = pStyle; + + SwFrmFmt* pTblFmt = pDoc->MakeTblFrmFmt( sTblName, pStyle ? pStyle : pDoc->GetDfltFrmFmt() ); pTblFmt->CopyAttrs( *GetTable().GetFrmFmt() ); SwTableNode* pTblNd = new SwTableNode( rIdx ); SwEndNode* pEndNd = new SwEndNode( rIdx, *pTblNd ); @@ -491,6 +496,8 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const if( pDDEType ) pDDEType->IncRefCnt(); + SwTableFmt::AssignFormatParents( pActualStyle, rTbl ); + CHECK_TABLE( GetTable() ); return pTblNd; } commit 574579ae5c940377ff5125cf7ca360fe3cf7d1e6 Author: Alex Ivan <alexni...@yahoo.com> Date: Tue Aug 27 15:12:23 2013 +0300 Load predifined table styles at document creation Until now, the styles were loaded and deleted every time the AutoFormat dialog was opened/closed. Now, they are loaded once at document creation, and unloaded when in the document dtor. Change-Id: I7cc8cfa38c7c8c196e303e542736e937ac0023a8 diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index e3eeb61..0ae40c8 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -163,6 +163,7 @@ class SwTOXTypes; class SwTabCols; class SwTable; class SwTableAutoFmt; +class SwTableAutoFmtTbl; class SwTableBox; class SwTableBoxFmt; class SwTableFmt; @@ -310,6 +311,7 @@ class SW_DLLPUBLIC SwDoc : SwFrmFmts *mpSpzFrmFmtTbl; SwSectionFmts *mpSectionFmtTbl; SwFrmFmts *mpTblFrmFmtTbl; ///< For tables + SwTableAutoFmtTbl *mpTblStyleTbl; ///< Table styles SwTxtFmtColls *mpTxtFmtCollTbl; ///< FormatCollections SwGrfFmtColls *mpGrfFmtCollTbl; @@ -1283,6 +1285,7 @@ public: SwTableFmt* MakeTblFrmFmt(const String &rFmtName, SwFrmFmt *pDerivedFrom); void DelTblFrmFmt( SwTableFmt* pFmt ); SwTableFmt* FindTblFmtByName( const String& rName, sal_Bool bAll = sal_False ) const; + SwTableAutoFmtTbl* GetTableStyles() { return mpTblStyleTbl; }; /** Access to frames. Iterate over Flys - forr Basic-Collections. */ diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 88707bb..9c699b3 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -89,6 +89,7 @@ #include <UndoManager.hxx> #include <unochart.hxx> #include <fldbas.hxx> +#include <tblafmt.hxx> #include <cmdid.h> // for the default printer in SetJob @@ -354,6 +355,9 @@ SwDoc::SwDoc() mpFrmFmtTbl->push_back(mpDfltFrmFmt); mpCharFmtTbl->push_back(mpDfltCharFmt); + mpTblStyleTbl = new SwTableAutoFmtTbl( this ); + mpTblStyleTbl->Load(); + /* FmtColls */ // TXT mpTxtFmtCollTbl->push_back(mpDfltTxtFmtColl); @@ -656,6 +660,7 @@ SwDoc::~SwDoc() delete mpCharFmtTbl; delete mpSectionFmtTbl; delete mpTblFrmFmtTbl; + delete mpTblStyleTbl; delete mpDfltTxtFmtColl; delete mpDfltGrfFmtColl; delete mpNumRuleTbl; diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 976aa0a..5ec240b 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -961,13 +961,10 @@ SwTableAutoFmtTbl::SwTableAutoFmtTbl(SwDoc* pDoc) : m_pImpl(new Impl) , m_pDoc( pDoc) { - String sNm; - // FIXME Yuk! we are creating the table styles ATM, but in the targetted - // ideal, the table styles are created with the document + OUString sNm; sNm = SwStyleNameMapper::GetUIName( RES_POOLCOLL_STANDARD, sNm ); - SwTableFmt* pStyle = pDoc->FindTblFmtByName(sNm); - if ( !pStyle ) - pStyle = pDoc->MakeTblFrmFmt( sNm, pDoc->GetDfltFrmFmt() ); + SwTableFmt* pStyle = pDoc->MakeTblFrmFmt( sNm, pDoc->GetDfltFrmFmt() ); + SwTableAutoFmt* pNewTableAutoFmt = new SwTableAutoFmt( sNm, pStyle ); SwTableBoxFmt* pNewBoxFmt = pDoc->MakeTableBoxFmt(); diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx index da75280..dc68eb2 100644 --- a/sw/source/ui/table/tautofmt.cxx +++ b/sw/source/ui/table/tautofmt.cxx @@ -170,15 +170,13 @@ SwAutoFormatDlg::SwAutoFormatDlg( Window* pParent, SwWrtShell* pWrtShell, m_pWndPreview->DetectRTL(pWrtShell); - pTableTbl = new SwTableAutoFmtTbl(pWrtShell->GetDoc()); - pTableTbl->Load(); + pTableTbl = pWrtShell->GetDoc()->GetTableStyles(); Init(pSelFmt); } SwAutoFormatDlg::~SwAutoFormatDlg() { - delete pTableTbl; } void SwAutoFormatDlg::Init( const SwTableAutoFmt* pSelFmt ) commit 03877216d708eaeb0fad205aacaec892fe4a3800 Author: Alex Ivan <alexni...@yahoo.com> Date: Fri Aug 23 16:33:36 2013 +0300 Add some more security to format parent assigning Change-Id: I3f250f88ae68d6604bb4da0e9ae78ccefabf96e9 diff --git a/sw/source/core/doc/swtblfmt.cxx b/sw/source/core/doc/swtblfmt.cxx index 823f073..ee5c3f0 100644 --- a/sw/source/core/doc/swtblfmt.cxx +++ b/sw/source/core/doc/swtblfmt.cxx @@ -276,6 +276,9 @@ void SwTableFmt::AssignFormatParents( SwTableFmt* pSrcFmt, SwTable &rTable ) if( !pHardFmt ) return; + if( pSrcFmt && pSrcFmt->IsDefault() ) + return; + if( pSrcFmt ) pHardFmt->GetAttrSet().SetParent( &pSrcFmt->GetAttrSet() ); else _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits