[Libreoffice-commits] core.git: Branch 'feature/table-style' - 2 commits - sw/inc sw/source

Alex Ivan alexnivan at yahoo.com
Fri Jul 26 09:55:07 PDT 2013


 sw/inc/swtblfmt.hxx              |    6 +--
 sw/source/core/doc/swtblfmt.cxx  |   61 ++++++++++++++-------------------------
 sw/source/core/doc/tblafmt.cxx   |    6 +--
 sw/source/core/docnode/ndtbl.cxx |    2 -
 sw/source/core/undo/untbl.cxx    |    4 +-
 5 files changed, 31 insertions(+), 48 deletions(-)

New commits:
commit 5d8b4793247eedb5d02c52356d0dcc37d45290a1
Author: Alex Ivan <alexnivan at yahoo.com>
Date:   Fri Jul 26 19:51:15 2013 +0300

    Further changes on separating hard formatting from style
    
    Changes have been made to better distinguish table style from the
    table's hard format. These concern setting the table style on
    a certain table and the associated Undo/Redo operation.
    
    Some errors still need to be sorted out.
    
    Change-Id: Id7593616b89234301fb33352d46a83aca7c3ac90

diff --git a/sw/inc/swtblfmt.hxx b/sw/inc/swtblfmt.hxx
index d49396a..0443cbd 100644
--- a/sw/inc/swtblfmt.hxx
+++ b/sw/inc/swtblfmt.hxx
@@ -121,10 +121,8 @@ public:
     sal_Bool GetRowSplit() const;
     sal_uInt16 GetRepeatHeading() const;
 
-    void RestoreTableProperties( SwTable &table ) const;
-    void StoreTableProperties( const SwTable &table );
-
-    void CopyTableFormatInfo( const SwTableFmt* pTableFormat );
+    static void RestoreTableProperties( SwTableFmt* pSrcFmt, SwTable &table );
+    static SwTableFmt* StoreTableProperties( const SwTable &table );
 
     sal_Bool Load( SvStream& rStream, const SwAfVersions& rVersions, SwDoc* pDoc, sal_uInt16 nVal );
 
diff --git a/sw/source/core/doc/swtblfmt.cxx b/sw/source/core/doc/swtblfmt.cxx
index e4a3a89..15c63c7 100644
--- a/sw/source/core/doc/swtblfmt.cxx
+++ b/sw/source/core/doc/swtblfmt.cxx
@@ -241,57 +241,42 @@ sal_uInt16 SwTableFmt::GetRepeatHeading() const
     return (static_cast<const SfxUInt16Item&>( GetFmtAttr( FN_PARAM_TABLE_HEADLINE ) )).GetValue();
 }
 
-void SwTableFmt::RestoreTableProperties(SwTable &table) const
+void SwTableFmt::RestoreTableProperties( SwTableFmt* pSrcFmt, SwTable &table )
 {
-    SwTableFmt *pFormat = (SwTableFmt*)table.GetTableFmt()->GetRegisteredIn();
-    if (!pFormat)
+    SwTableFmt *pHardFmt = table.GetTableFmt();
+    if( !pHardFmt )
         return;
 
-    SwDoc *pDoc = pFormat->GetDoc();
-    if (!pDoc)
+    SwDoc *pDoc = pHardFmt->GetDoc();
+    if( !pDoc )
         return;
 
-    pFormat->CopyTableFormatInfo( this );
+    SwTableFmt *pTableStyle = (SwTableFmt*)pHardFmt->GetRegisteredIn();
+    sal_Bool bRowSplit = sal_True;
+    sal_uInt16 nRepeatHeading = 0;
 
-    SwEditShell *pShell = pDoc->GetEditShell();
-    pDoc->SetRowSplit( *pShell->getShellCrsr( false ), SwFmtRowSplit( GetRowSplit() ) );
-
-    table.SetRowsToRepeat( GetRepeatHeading() );
-}
-
-void SwTableFmt::StoreTableProperties(const SwTable &table)
-{
-    SwTableFmt *pFormat = (SwTableFmt*)table.GetTableFmt()->GetRegisteredIn();
-    if (!pFormat)
-        return;
-
-    SwDoc *pDoc = pFormat->GetDoc();
-    if (!pDoc)
-        return;
+    if( pSrcFmt )
+    {
+        pHardFmt->RegisterToFormat( *pSrcFmt );
+        bRowSplit = pSrcFmt->GetRowSplit();
+        nRepeatHeading = pSrcFmt->GetRepeatHeading();
+    }
+    else
+        pTableStyle->Remove( pHardFmt );
 
     SwEditShell *pShell = pDoc->GetEditShell();
-    SwFmtRowSplit *pRowSplit = 0;
-    pDoc->GetRowSplit( *pShell->getShellCrsr( false ), pRowSplit );
-    SetRowSplit( pRowSplit ? pRowSplit->GetValue() : sal_False );
-    delete pRowSplit;
-    pRowSplit = 0;
+    pDoc->SetRowSplit( *pShell->getShellCrsr( false ), SwFmtRowSplit( bRowSplit ) );
 
-    CopyTableFormatInfo( pFormat );
+    table.SetRowsToRepeat( nRepeatHeading );
 }
 
-void SwTableFmt::CopyTableFormatInfo( const SwTableFmt* pTableFormat )
+SwTableFmt* SwTableFmt::StoreTableProperties( const SwTable &table )
 {
-    SetFmtAttr( pTableFormat->GetAttrSet() );
-
-    m_pFstLineFmt.reset( new SwTableLineFmt ( *pTableFormat->GetFirstLineFmt() ) );
-    m_pLstLineFmt.reset( new SwTableLineFmt ( *pTableFormat->GetLastLineFmt() ) );
-    m_pOddLineFmt.reset( new SwTableLineFmt ( *pTableFormat->GetOddLineFmt() ) );
-    m_pEvnLineFmt.reset( new SwTableLineFmt ( *pTableFormat->GetEvenLineFmt() ) );
+    SwTableFmt *pHardFmt = table.GetTableFmt();
+    if( !pHardFmt )
+        return NULL;
 
-    m_pFstColFmt.reset( new SwTableLineFmt ( *pTableFormat->GetFirstColFmt() ) );
-    m_pLstColFmt.reset( new SwTableLineFmt ( *pTableFormat->GetLastColFmt() ) );
-    m_pOddColFmt.reset( new SwTableLineFmt ( *pTableFormat->GetOddColFmt() ) );
-    m_pEvnColFmt.reset( new SwTableLineFmt ( *pTableFormat->GetEvenColFmt() ) );
+    return (SwTableFmt*)pHardFmt->GetRegisteredIn();
 }
 
 SwTableLineFmt::SwTableLineFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index ef80167..8881553 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -751,12 +751,12 @@ void SwTableAutoFmt::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet,
 
 void SwTableAutoFmt::RestoreTableProperties(SwTable &table) const
 {
-    m_pTableStyle->RestoreTableProperties( table );
+    SwTableFmt::RestoreTableProperties( m_pTableStyle, table );
 }
 
 void SwTableAutoFmt::StoreTableProperties(const SwTable &table)
 {
-    m_pTableStyle->StoreTableProperties( table );
+    m_pTableStyle = SwTableFmt::StoreTableProperties( table );
 }
 
 sal_Bool SwTableFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, SwDoc* pDoc, sal_uInt16 nVal )
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 60254e5..a8635a3 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3564,7 +3564,7 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt&
         GetIDocumentUndoRedo().DoUndo(false);
     }
 
-    rNew.GetTableStyle()->RestoreTableProperties(table);
+    rNew.RestoreTableProperties(table);
 
     if( pUndo )
     {
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 4157e53..8c30a50 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1428,12 +1428,12 @@ SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext)
     OSL_ENSURE( pTblNd, "no TableNode" );
 
     SwTable& table = pTblNd->GetTable();
-    SwTableFmt* pOrig = new SwTableFmt( *(SwTableFmt*)table.GetTableFmt()->GetRegisteredIn() );
+    SwTableFmt* pOrig = (SwTableFmt*)table.GetTableFmt()->GetRegisteredIn();
 
     if( bUndo )
         table.SetRowsToRepeat( m_nRepeatHeading );
 
-    pSaveFmt->RestoreTableProperties( table );
+    SwTableFmt::RestoreTableProperties( pSaveFmt, table );
     delete pSaveFmt;
     pSaveFmt = pOrig;
 }
commit ae14aebb0cf0e536fd4b55bd74ddf5c43838b67f
Author: Alex Ivan <alexnivan at yahoo.com>
Date:   Thu Jul 25 15:50:24 2013 +0300

    Fix missing name for Default Style in AutoFormat dialog
    
    Fixed the missing name for the default style in the AutoFormat dialog.
    The String argument of SwStyleNameMapper::GetUIName is not modified
    in the method, so the actual return value needs to be used to get the
    desired result.
    
    Change-Id: I29b29c11343920dc69a5bc104f65536a26e17d67

diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index 3792f1b..ef80167 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -964,7 +964,7 @@ SwTableAutoFmtTbl::SwTableAutoFmtTbl(SwDoc* 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
-    SwStyleNameMapper::GetUIName( RES_POOLCOLL_STANDARD, sNm );
+    sNm = SwStyleNameMapper::GetUIName( RES_POOLCOLL_STANDARD, sNm );
     SwTableFmt* pStyle = pDoc->FindTblFmtByName(sNm);
     if ( !pStyle )
         pStyle = pDoc->MakeTblFrmFmt(sNm, NULL);


More information about the Libreoffice-commits mailing list