[Libreoffice-commits] core.git: Branch 'feature/table-style' - 5 commits - sw/source
Alex Ivan
alexnivan at yahoo.com
Sun Jul 21 09:54:23 PDT 2013
sw/source/core/doc/swtblfmt.cxx | 4
sw/source/core/docnode/ndtbl.cxx | 184 ---------------------------------------
sw/source/core/inc/UndoTable.hxx | 7 -
sw/source/core/undo/untbl.cxx | 44 +--------
4 files changed, 17 insertions(+), 222 deletions(-)
New commits:
commit 74fe564c6772707be3b978d12473ff69ae66843e
Author: Alex Ivan <alexnivan at yahoo.com>
Date: Sun Jul 21 19:19:43 2013 +0300
Separated hardformatting/styles in table insertion
Had previously overlooked where the table style information was
stored when inserting a new table into the document.
Change-Id: I8b285951c76fabe9b3b24006bba8592a3a6e5364
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 6e38a77..eaa15ac 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -404,7 +404,7 @@ const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTblOpts,
::lcl_SetDfltBorders( pTableFmt );
SwTable * pNdTbl = &pTblNd->GetTable();
- pNdTbl->RegisterToFormat( *pTableFmt );
+ pNdTbl->GetTableFmt()->RegisterToFormat( *pTableFmt );
pNdTbl->SetRowsToRepeat( nRowsToRepeat );
pNdTbl->SetTableModel( bNewModel );
@@ -658,7 +658,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts,
// Set Orientation in the Table's Fmt
pTableFmt->SetFmtAttr( SwFmtHoriOrient( 0, eAdjust ) );
- pNdTbl->RegisterToFormat( *pTableFmt );
+ pNdTbl->GetTableFmt()->RegisterToFormat( *pTableFmt );
if( rInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER )
{
commit 248c76291562f2fe95c2f246be06cbd7338fcb3e
Author: Alex Ivan <alexnivan at yahoo.com>
Date: Thu Jul 18 18:45:14 2013 +0300
Modify undo mechanism for applying table format
Undo object no longer reconstructs table, but changes the table
style back to the original. The actual modification _should_
become visible once the proper modifications to the rendering of
the table are done.
Change-Id: Ife10f52077c9b13d5cf4f44fa1194fe414661cd1
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index cd79f20..37f5c41 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -43,6 +43,7 @@ class SwTable;
class SwTableBox;
class SwStartNode;
class SwTableNode;
+class SwTableFmt;
class SwTableAutoFmt;
class SwTableSortBoxes;
@@ -146,9 +147,7 @@ class SwUndoTblNumFmt;
class SwUndoTblAutoFmt : public SwUndo
{
sal_uLong nSttNode;
- _SaveTable* pSaveTbl;
- ::std::vector< ::boost::shared_ptr<SwUndoTblNumFmt> > m_Undos;
- sal_Bool bSaveCntntAttr;
+ SwTableFmt* pSaveFmt;
sal_uInt16 m_nRepeatHeading;
void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext);
@@ -160,8 +159,6 @@ public:
virtual void UndoImpl( ::sw::UndoRedoContext & );
virtual void RedoImpl( ::sw::UndoRedoContext & );
-
- void SaveBoxCntnt( const SwTableBox& rBox );
};
class SwUndoTblNdsChg : public SwUndo, private boost::noncopyable
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index a3793d2..4157e53 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1410,29 +1410,14 @@ SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd,
const SwTableAutoFmt& rAFmt )
: SwUndo( UNDO_TABLE_AUTOFMT ),
nSttNode( rTblNd.GetIndex() ),
- bSaveCntntAttr( sal_False )
- , m_nRepeatHeading(rTblNd.GetTable().GetRowsToRepeat())
+ m_nRepeatHeading(rTblNd.GetTable().GetRowsToRepeat())
{
- pSaveTbl = new _SaveTable( rTblNd.GetTable() );
-
- if( rAFmt.IsFont() || rAFmt.IsJustify() )
- {
- // than also go over the ContentNodes of the EndBoxes and collect
- // all paragraph attributes
- pSaveTbl->SaveCntntAttrs( (SwDoc*)rTblNd.GetDoc() );
- bSaveCntntAttr = sal_True;
- }
+ pSaveFmt = new SwTableFmt( *rAFmt.GetTableStyle() );
}
SwUndoTblAutoFmt::~SwUndoTblAutoFmt()
{
- delete pSaveTbl;
-}
-
-void SwUndoTblAutoFmt::SaveBoxCntnt( const SwTableBox& rBox )
-{
- ::boost::shared_ptr<SwUndoTblNumFmt> const p(new SwUndoTblNumFmt(rBox));
- m_Undos.push_back(p);
+ delete pSaveFmt;
}
void
@@ -1443,25 +1428,14 @@ SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext)
OSL_ENSURE( pTblNd, "no TableNode" );
SwTable& table = pTblNd->GetTable();
- _SaveTable* pOrig = new _SaveTable( table );
- // than go also over the ContentNodes of the EndBoxes and collect
- // all paragraph attributes
- if( bSaveCntntAttr )
- pOrig->SaveCntntAttrs( &rDoc );
+ SwTableFmt* pOrig = new SwTableFmt( *(SwTableFmt*)table.GetTableFmt()->GetRegisteredIn() );
- if (bUndo)
- {
- for (size_t n = m_Undos.size(); 0 < n; --n)
- {
- m_Undos.at(n-1)->UndoImpl(rContext);
- }
+ if( bUndo )
+ table.SetRowsToRepeat( m_nRepeatHeading );
- table.SetRowsToRepeat(m_nRepeatHeading);
- }
-
- pSaveTbl->RestoreAttr( pTblNd->GetTable(), !bUndo );
- delete pSaveTbl;
- pSaveTbl = pOrig;
+ pSaveFmt->RestoreTableProperties( table );
+ delete pSaveFmt;
+ pSaveFmt = pOrig;
}
void SwUndoTblAutoFmt::UndoImpl(::sw::UndoRedoContext & rContext)
commit 13d870054e1b9f9b52519eef5eaf769d5cf4337e
Author: Alex Ivan <alexnivan at yahoo.com>
Date: Thu Jul 18 14:15:58 2013 +0300
Table style stored separately from hard format
Store/RestoreTableProperties methods used in Set/GetTableAutoFmt now
save/apply properties to/from the table's GetRegisteredIn's
GetRegisteredIn, thus separating the table style from the actual
hard format of the current table.
Change-Id: Iac3b73ad4388a9d73446c24d2fb50d96b7d1c380
diff --git a/sw/source/core/doc/swtblfmt.cxx b/sw/source/core/doc/swtblfmt.cxx
index 67bc68c..e4a3a89 100644
--- a/sw/source/core/doc/swtblfmt.cxx
+++ b/sw/source/core/doc/swtblfmt.cxx
@@ -243,7 +243,7 @@ sal_uInt16 SwTableFmt::GetRepeatHeading() const
void SwTableFmt::RestoreTableProperties(SwTable &table) const
{
- SwTableFmt *pFormat = table.GetTableFmt();
+ SwTableFmt *pFormat = (SwTableFmt*)table.GetTableFmt()->GetRegisteredIn();
if (!pFormat)
return;
@@ -261,7 +261,7 @@ void SwTableFmt::RestoreTableProperties(SwTable &table) const
void SwTableFmt::StoreTableProperties(const SwTable &table)
{
- SwTableFmt *pFormat = table.GetTableFmt();
+ SwTableFmt *pFormat = (SwTableFmt*)table.GetTableFmt()->GetRegisteredIn();
if (!pFormat)
return;
commit a52ce17f99cabca41d55404e63cd7717bc2bd8ab
Author: Alex Ivan <alexnivan at yahoo.com>
Date: Mon Jul 15 19:13:14 2013 +0300
Removed no longer used helper functions
lcl_SetAFmtBox/Line helper functions and structure _SetAFmtTabPara
have been removed since they are no longer used because table styles
are now stored in order to get the relevant properties at render time.
Change-Id: I8a6824d30f9cfd997ac29b94638cdc37400f7976
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index d6a16fd..6e38a77 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3468,89 +3468,6 @@ sal_Bool SwNodes::MergeTable( const SwNodeIndex& rPos, sal_Bool bWithPrev,
}
-// Use the PtrArray's ForEach method
-struct _SetAFmtTabPara
-{
- SwTableAutoFmt& rTblFmt;
- SwUndoTblAutoFmt* pUndo;
- sal_uInt16 nEndBox, nCurBox;
- sal_uInt8 nAFmtLine, nAFmtBox;
-
- _SetAFmtTabPara( const SwTableAutoFmt& rNew )
- : rTblFmt( (SwTableAutoFmt&)rNew ), pUndo( 0 ),
- nEndBox( 0 ), nCurBox( 0 ), nAFmtLine( 0 ), nAFmtBox( 0 )
- {}
-};
-
-// Forward declare so that the Lines and Boxes can use recursion
-static bool lcl_SetAFmtBox(_FndBox &, _SetAFmtTabPara *pSetPara);
-static bool lcl_SetAFmtLine(_FndLine &, _SetAFmtTabPara *pPara);
-
-static bool lcl_SetAFmtLine(_FndLine & rLine, _SetAFmtTabPara *pPara)
-{
- for (_FndBoxes::iterator it = rLine.GetBoxes().begin();
- it != rLine.GetBoxes().end(); ++it)
- {
- lcl_SetAFmtBox(*it, pPara);
- }
- return true;
-}
-
-static bool lcl_SetAFmtBox( _FndBox & rBox, _SetAFmtTabPara *pSetPara )
-{
- if (!rBox.GetUpper()->GetUpper()) // Box on first level?
- {
- if( !pSetPara->nCurBox )
- pSetPara->nAFmtBox = 0;
- else if( pSetPara->nCurBox == pSetPara->nEndBox )
- pSetPara->nAFmtBox = 3;
- else
- pSetPara->nAFmtBox = (sal_uInt8)(1 + ((pSetPara->nCurBox-1) & 1));
- }
-
- if (rBox.GetBox()->GetSttNd())
- {
- SwTableBox* pSetBox = static_cast<SwTableBox*>(rBox.GetBox());
- SwDoc* pDoc = pSetBox->GetFrmFmt()->GetDoc();
- SfxItemSet aCharSet( pDoc->GetAttrPool(), RES_CHRATR_BEGIN, RES_PARATR_LIST_END-1 );
- SfxItemSet aBoxSet( pDoc->GetAttrPool(), aTableBoxSetRange );
- sal_uInt8 nPos = pSetPara->nAFmtLine * 4 + pSetPara->nAFmtBox;
- pSetPara->rTblFmt.UpdateToSet( nPos, aCharSet,
- SwTableAutoFmt::UPDATE_CHAR, 0 );
- pSetPara->rTblFmt.UpdateToSet( nPos, aBoxSet,
- SwTableAutoFmt::UPDATE_BOX,
- pDoc->GetNumberFormatter( sal_True ) );
- if( aCharSet.Count() )
- {
- sal_uLong nSttNd = pSetBox->GetSttIdx()+1;
- sal_uLong nEndNd = pSetBox->GetSttNd()->EndOfSectionIndex();
- for( ; nSttNd < nEndNd; ++nSttNd )
- {
- SwCntntNode* pNd = pDoc->GetNodes()[ nSttNd ]->GetCntntNode();
- if( pNd )
- pNd->SetAttr( aCharSet );
- }
- }
-
- if( aBoxSet.Count() )
- {
- if( pSetPara->pUndo &&
- SFX_ITEM_SET == aBoxSet.GetItemState( RES_BOXATR_FORMAT ))
- pSetPara->pUndo->SaveBoxCntnt( *pSetBox );
-
- pSetBox->ClaimFrmFmt()->SetFmtAttr( aBoxSet );
- }
- }
- else
- BOOST_FOREACH( _FndLine& rFndLine, rBox.GetLines() )
- lcl_SetAFmtLine( rFndLine, pSetPara );
-
- if (!rBox.GetUpper()->GetUpper()) // a BaseLine
- ++pSetPara->nCurBox;
- return true;
-}
-
-
/**
* AutoFormat for the Table/TableSelection
*/
commit 391b96732815ca6eafca698b5a4f03bac5677c81
Author: Alex Ivan <alexnivan at yahoo.com>
Date: Mon Jul 15 19:05:31 2013 +0300
Table style applied at table level
SetTableAutoFmt method has been modified to store the style at table
level rather than apply it to the range of selected cells.
Similarly, the GetTableAutoFmt does not create a set of properties
from the selected range, but uses the info stored at table level.
Change-Id: Iacfc6bd38d4f952255358d540edc696f47449baa
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index a243333..d6a16fd 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3573,17 +3573,6 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt&
SwTable &table = pTblNd->GetTable();
table.SetHTMLTableLayout( 0 );
- _FndBox* pFndBox = &aFndBox;
- while( 1 == pFndBox->GetLines().size() &&
- 1 == pFndBox->GetLines().front().GetBoxes().size() )
- {
- pFndBox = &pFndBox->GetLines().front().GetBoxes()[0];
- }
-
- if( pFndBox->GetLines().empty() ) // One too far? (only one sel. Box)
- pFndBox = pFndBox->GetUpper()->GetUpper();
-
-
// Disable Undo, but first store parameters
SwUndoTblAutoFmt* pUndo = 0;
bool const bUndo(GetIDocumentUndoRedo().DoesUndo());
@@ -3594,39 +3583,7 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt&
GetIDocumentUndoRedo().DoUndo(false);
}
- rNew.RestoreTableProperties(table);
-
- _SetAFmtTabPara aPara( rNew );
- _FndLines& rFLns = pFndBox->GetLines();
- _FndLine* pLine;
-
- for( sal_uInt16 n = 0; n < rFLns.size(); ++n )
- {
- pLine = &rFLns[n];
-
- // Set Upper to 0 (thus simulate BaseLine)
- _FndBox* pSaveBox = pLine->GetUpper();
- pLine->SetUpper( 0 );
-
- if( !n )
- aPara.nAFmtLine = 0;
- else if (static_cast<size_t>(n+1) == rFLns.size())
- aPara.nAFmtLine = 3;
- else
- aPara.nAFmtLine = (sal_uInt8)(1 + ((n-1) & 1 ));
-
- aPara.nAFmtBox = 0;
- aPara.nCurBox = 0;
- aPara.nEndBox = pLine->GetBoxes().size()-1;
- aPara.pUndo = pUndo;
- for (_FndBoxes::iterator it = pLine->GetBoxes().begin();
- it != pLine->GetBoxes().end(); ++it)
- {
- lcl_SetAFmtBox(*it, &aPara);
- }
-
- pLine->SetUpper( pSaveBox );
- }
+ rNew.GetTableStyle()->RestoreTableProperties(table);
if( pUndo )
{
@@ -3661,57 +3618,7 @@ sal_Bool SwDoc::GetTableAutoFmt( const SwSelBoxes& rBoxes, SwTableAutoFmt& rGet
// Store table properties
SwTable &table = pTblNd->GetTable();
- rGet.StoreTableProperties(table);
-
- _FndBox* pFndBox = &aFndBox;
- while( 1 == pFndBox->GetLines().size() &&
- 1 == pFndBox->GetLines().front().GetBoxes().size() )
- {
- pFndBox = &pFndBox->GetLines().front().GetBoxes()[0];
- }
-
- if( pFndBox->GetLines().empty() ) // One too far? (only one sel. Box)
- pFndBox = pFndBox->GetUpper()->GetUpper();
-
- _FndLines& rFLns = pFndBox->GetLines();
-
- sal_uInt16 aLnArr[4];
- aLnArr[0] = 0;
- aLnArr[1] = 1 < rFLns.size() ? 1 : 0;
- aLnArr[2] = 2 < rFLns.size() ? 2 : aLnArr[1];
- aLnArr[3] = rFLns.size() - 1;
-
- for( sal_uInt8 nLine = 0; nLine < 4; ++nLine )
- {
- _FndLine& rLine = rFLns[ aLnArr[ nLine ] ];
-
- sal_uInt16 aBoxArr[4];
- aBoxArr[0] = 0;
- aBoxArr[1] = 1 < rLine.GetBoxes().size() ? 1 : 0;
- aBoxArr[2] = 2 < rLine.GetBoxes().size() ? 2 : aBoxArr[1];
- aBoxArr[3] = rLine.GetBoxes().size() - 1;
-
- for( sal_uInt8 nBox = 0; nBox < 4; ++nBox )
- {
- SwTableBox* pFBox = rLine.GetBoxes()[ aBoxArr[ nBox ] ].GetBox();
- // Always apply to the first ones
- while( !pFBox->GetSttNd() )
- pFBox = pFBox->GetTabLines()[0]->GetTabBoxes()[0];
-
- sal_uInt8 nPos = nLine * 4 + nBox;
- SwNodeIndex aIdx( *pFBox->GetSttNd(), 1 );
- SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
- if( !pCNd )
- pCNd = GetNodes().GoNext( &aIdx );
-
- if( pCNd )
- rGet.UpdateFromSet( nPos, pCNd->GetSwAttrSet(),
- SwTableAutoFmt::UPDATE_CHAR, 0 );
- rGet.UpdateFromSet( nPos, pFBox->GetFrmFmt()->GetAttrSet(),
- SwTableAutoFmt::UPDATE_BOX,
- GetNumberFormatter( sal_True ) );
- }
- }
+ rGet.GetTableStyle()->StoreTableProperties(table);
return sal_True;
}
More information about the Libreoffice-commits
mailing list