summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2015-09-26 16:19:24 +0200
committerJan Holesovsky <kendy@collabora.com>2015-09-27 22:48:21 +0200
commitac6f8bc92b1abe995694602f43d8ad108b7030fb (patch)
treeae8ed9337704cd83ab10e4c9cce4b7e06aaa7e8e /sw/inc
parent5c26f79467e4c5f920b77a058aa079654c322c25 (diff)
sw table styles: Implement table styles in Writer.
This extends the table auto formats so that SwDoc keeps track of the auto formats used in the document. With this in mind, we can update the format of the table with every operation like adding/removing a line, splitting a table, etc. So far we only have the core functionality, and cover inserting a line in the table; more to come. Based on work of Alex Ivan <alexnivan@yahoo.com> during GSoC 2013 - thank you! Change-Id: I7839147e54c2f976988121a523331def9859f4c2
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/doc.hxx7
-rw-r--r--sw/inc/fesh.hxx7
-rw-r--r--sw/inc/swtable.hxx9
-rw-r--r--sw/inc/tblafmt.hxx7
4 files changed, 28 insertions, 2 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 2ddcc2d73ff9..51631a337a22 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -127,6 +127,7 @@ class SwSectionFormat;
class SwSectionFormats;
class SwSectionData;
class SwSelBoxes;
+class SwTableAutoFormatTable;
class SwTOXBaseSection;
class SwTOXTypes;
class SwTabCols;
@@ -343,6 +344,9 @@ class SW_DLLPUBLIC SwDoc :
com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > mxVbaEvents;
com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> m_xTemplateToProjectCache;
+ /// Table styles (autoformats that are applied with table changes).
+ std::unique_ptr<SwTableAutoFormatTable> mpTableStyles;
+
private:
::std::unique_ptr< ::sfx2::IXmlIdRegistry > m_pXmlIdRegistry;
@@ -1257,6 +1261,9 @@ public:
// Query attributes.
bool GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGet );
+ /// Return the available table styles.
+ SwTableAutoFormatTable& GetTableStyles() { return *mpTableStyles.get(); }
+
void AppendUndoForInsertFromDB( const SwPaM& rPam, bool bIsTable );
bool SetColRowWidthHeight( SwTableBox& rAktBox, sal_uInt16 eType,
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index a219ac1f6997..a41e119eef2f 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -720,8 +720,11 @@ public:
/// Not allowed if only empty cells are selected.
bool IsAdjustCellWidthAllowed( bool bBalance = false ) const;
- /// AutoFormat for table/ table selection.
- bool SetTableAutoFormat( const SwTableAutoFormat& rNew );
+ /// Set table style of the current table.
+ bool SetTableStyle(const SwTableAutoFormat& rNew);
+
+ /// Update the direct formatting according to the current table style.
+ bool UpdateTableStyleFormatting();
bool GetTableAutoFormat( SwTableAutoFormat& rGet );
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 8b42d9dfafbe..5f645e31311b 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -114,6 +114,9 @@ protected:
// at HTML-import.
sal_uInt16 nRowsToRepeat; // Number of rows to repeat on every page.
+ /// Name of the table style to be applied on this table.
+ OUString maTableStyleName;
+
bool bModifyLocked :1;
bool bNewModel :1; // false: old SubTableModel; true: new RowSpanModel
#ifdef DBG_UTIL
@@ -175,6 +178,12 @@ public:
void SetTableModel( bool bNew ){ bNewModel = bNew; }
bool IsNewModel() const { return bNewModel; }
+ /// Return the table style name of this table.
+ OUString GetTableStyleName() const { return maTableStyleName; }
+
+ /// Set the new table style name for this table.
+ void SetTableStyleName(const OUString& rName) { maTableStyleName = rName; }
+
sal_uInt16 GetRowsToRepeat() const { return std::min( (sal_uInt16)GetTabLines().size(), nRowsToRepeat ); }
sal_uInt16 _GetRowsToRepeat() const { return nRowsToRepeat; }
void SetRowsToRepeat( sal_uInt16 nNumOfRows ) { nRowsToRepeat = nNumOfRows; }
diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index 3503bb72eb51..500e2cad9cd7 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -310,10 +310,17 @@ public:
size_t size() const;
SwTableAutoFormat const& operator[](size_t i) const;
SwTableAutoFormat & operator[](size_t i);
+
+ /// Append table style to the existing styles.
+ void AddAutoFormat(const SwTableAutoFormat& rFormat);
+
void InsertAutoFormat(size_t i, std::unique_ptr<SwTableAutoFormat> pFormat);
void EraseAutoFormat(size_t i);
std::unique_ptr<SwTableAutoFormat> ReleaseAutoFormat(size_t i);
+ /// Find table style with the provided name, return nullptr when not found.
+ SwTableAutoFormat* FindAutoFormat(const OUString& rName) const;
+
bool Load();
bool Save() const;
};