diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-05-18 18:48:38 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-05-20 13:16:28 +0200 |
commit | db04be037b611e296ef9f2542322c52ed82d7a2b (patch) | |
tree | 8892aa251d751037c592b3aeb4e521d067944837 /sw/inc | |
parent | d3122433616d4da2c6ee82f73bd8f591ea498fc0 (diff) |
tdf#35798: Hide empty Database fields' paragraphs (+ compat option)
With this change, Database fields that expand to empty values behave
as if they are "Hidden Paragraph" fields.
A compatibility option to enable this behaviour is added. The option is
enabled by default, and for any non-native documents (for compatibility
with other office suites). For existing (F)ODT documents, the option is
disabled for those documents that don't have this setting set, to keep
the layout of legacy documents.
Change-Id: Ic5e8cb15a3a7d1a765a984eef4b0d97666df7dfd
Reviewed-on: https://gerrit.libreoffice.org/54552
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/IDocumentSettingAccess.hxx | 1 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 3 | ||||
-rw-r--r-- | sw/inc/ndhints.hxx | 26 | ||||
-rw-r--r-- | sw/inc/ndtxt.hxx | 12 | ||||
-rw-r--r-- | sw/inc/viewsh.hxx | 2 |
5 files changed, 30 insertions, 14 deletions
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index e3ac10797b89..a66f2367c22f 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -83,6 +83,7 @@ enum class DocumentSettingId SUBTRACT_FLYS, // tdf#112443 disable off-page content positioning DISABLE_OFF_PAGE_POSITIONING, + EMPTY_DB_FIELD_HIDES_PARA, // COMPATIBILITY FLAGS END BROWSE_MODE, HTML_MODE, diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index d588428b8890..ab3acf7d9070 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -466,6 +466,9 @@ public: ::sw::DocumentFieldsManager & GetDocumentFieldsManager(); + bool FieldCanHidePara(SwFieldIds eFieldId) const; + bool FieldHidesPara(const SwField& rField) const; + // IDocumentContentOperations IDocumentContentOperations const & getIDocumentContentOperations() const; IDocumentContentOperations & getIDocumentContentOperations(); diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx index 77aebc67d2be..0d66f9c3ead2 100644 --- a/sw/inc/ndhints.hxx +++ b/sw/inc/ndhints.hxx @@ -77,6 +77,8 @@ class SwpHtEnd : public o3tl::sorted_vector<SwTextAttr*, CompareSwpHtEnd, class SwpHints { private: + const SwTextNode& m_rParent; + // SAL_MAX_SIZE is used by GetStartOf to return // failure, so just allow SAL_MAX_SIZE-1 hints static const size_t MAX_HINTS = SAL_MAX_SIZE-1; @@ -88,9 +90,11 @@ private: /// true: the Node is in Split and Frames are moved bool m_bInSplitNode : 1; - /// m_bHasHiddenParaField is invalid, call CalcHiddenParaField() - bool m_bCalcHiddenParaField : 1; - bool m_bHasHiddenParaField : 1; ///< HiddenParaField + // m_bHiddenByParaField is invalid, call CalcHiddenParaField() + mutable bool m_bCalcHiddenParaField : 1; + // if all fields controlling visibility of the paragraph require to hide it + // (if there's no such fields, or if any field requires to show, then this is false) + mutable bool m_bHiddenByParaField : 1; bool m_bFootnote : 1; ///< footnotes bool m_bDDEFields : 1; ///< the TextNode has DDE fields @@ -108,15 +112,15 @@ private: void Delete( SwTextAttr const * pTextHt ); void SetInSplitNode(bool bInSplit) { m_bInSplitNode = bInSplit; } - void SetCalcHiddenParaField() { m_bCalcHiddenParaField = true; } - void SetHiddenParaField( const bool bNew ) { m_bHasHiddenParaField = bNew; } - bool HasHiddenParaField() const + void SetCalcHiddenParaField() const { m_bCalcHiddenParaField = true; } + void SetHiddenByParaField( const bool bNew ) const { m_bHiddenByParaField = bNew; } + bool IsHiddenByParaField() const { if ( m_bCalcHiddenParaField ) { - const_cast<SwpHints*>(this)->CalcHiddenParaField(); + CalcHiddenParaField(); } - return m_bHasHiddenParaField; + return m_bHiddenByParaField; } void InsertNesting(SwTextAttrNesting & rNewHint); @@ -144,7 +148,7 @@ private: #endif public: - SwpHints(); + SwpHints(const SwTextNode& rParent); size_t Count() const { return m_HintsByStart.size(); } bool Contains( const SwTextAttr *pHt ) const; @@ -179,8 +183,8 @@ public: bool HasFootnote() const { return m_bFootnote; } bool IsInSplitNode() const { return m_bInSplitNode; } - /// calc current value of m_bHasHiddenParaField, returns true iff changed - bool CalcHiddenParaField(); + // calc current value of m_bHiddenByParaField, returns true iff changed + bool CalcHiddenParaField() const; // changes mutable state DECL_FIXEDMEMPOOL_NEWDEL(SwpHints) }; diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 50cc3a75172f..894f8c078635 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -21,6 +21,7 @@ #include <cppuhelper/weakref.hxx> +#include "doc.hxx" #include "swdllapi.h" #include "node.hxx" #include "hintids.hxx" @@ -701,8 +702,13 @@ public: { if (m_pSwpHints) m_pSwpHints->SetCalcHiddenParaField(); } /// is the paragraph visible? - bool HasHiddenParaField() const - { return m_pSwpHints && m_pSwpHints->HasHiddenParaField(); } + bool IsHiddenByParaField() const + { return m_pSwpHints && m_pSwpHints->IsHiddenByParaField(); } + + bool FieldCanHidePara(SwFieldIds eFieldId) const + { return GetDoc()->FieldCanHidePara(eFieldId); } + bool FieldHidesPara(const SwField& rField) const + { return GetDoc()->FieldHidesPara(rField); } /// Hidden Paragraph Field: @@ -811,7 +817,7 @@ inline SwpHints& SwTextNode::GetOrCreateSwpHints() { if ( !m_pSwpHints ) { - m_pSwpHints.reset(new SwpHints); + m_pSwpHints.reset(new SwpHints(*this)); } return *m_pSwpHints; } diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 30f5911da9bd..832f4f9dd878 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -410,6 +410,8 @@ public: void SetSubtractFlysAnchoredAtFlys(bool bSubtractFlysAnchoredAtFlys); + void SetEmptyDbFieldHidesPara(bool bEmptyDbFieldHidesPara); + // DOCUMENT COMPATIBILITY FLAGS END // Calls Idle-formatter of Layout. |