summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ivan <alexnivan@yahoo.com>2013-08-27 15:12:23 +0300
committerAlex Ivan <alexnivan@yahoo.com>2013-08-27 15:52:06 +0300
commit574579ae5c940377ff5125cf7ca360fe3cf7d1e6 (patch)
tree8661f80f9d42b66e7e8e05d03e7a11920bdd8427
parent03877216d708eaeb0fad205aacaec892fe4a3800 (diff)
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
-rw-r--r--sw/inc/doc.hxx3
-rw-r--r--sw/source/core/doc/docnew.cxx5
-rw-r--r--sw/source/core/doc/tblafmt.cxx9
-rw-r--r--sw/source/ui/table/tautofmt.cxx4
4 files changed, 12 insertions, 9 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index e3eeb61f9f5a..0ae40c861493 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 88707bb9d6ae..9c699b3fa041 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 976aa0a0144e..5ec240bc2bc0 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 da752805d13c..dc68eb2b65e0 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 )