Kaydet (Commit) 57f358f1 authored tarafından Michael Stahl's avatar Michael Stahl

sw_redlinehide_3: add second result to SwGetExpField, SwSetExpField

This is quite tricky & somewhat ugly due to the SwValueField base class
& we need to duplicate its member too :(

It would be possible to filter the deleted fields in
SwDocUpdateField::MakeFieldList(), but the problem with that is that
the instance is long-lived & might be used with different layout
settings, so it's probably better to filter in the 5 or so client
functions that iterate over the GetSortList().

Note that this will also filter other fields including database fields,
hopefully that shouldn't cause problems.

Change-Id: I0cdbc7757fa529598b5dbceec0bd2c4a619be05a
üst 5e622d1b
......@@ -38,6 +38,7 @@ class SwNode;
enum class SwFieldIds : sal_uInt16;
template <class T> class SwHashTable;
struct HashStr;
class SwRootFrame;
namespace rtl { class OUString; }
using rtl::OUString;
......@@ -122,9 +123,9 @@ namespace com { namespace sun { namespace star { namespace uno { class Any; } }
// (if the address != 0 and the pointer == 0 a new list will be returned).
virtual void FieldsToCalc(SwCalc& rCalc, sal_uLong nLastNd, sal_uInt16 nLastCnt) = 0;
virtual void FieldsToCalc(SwCalc& rCalc, const SetGetExpField& rToThisField) = 0;
virtual void FieldsToCalc(SwCalc& rCalc, const SetGetExpField& rToThisField, SwRootFrame const* pLayout) = 0;
virtual void FieldsToExpand(SwHashTable<HashStr> & rTable, const SetGetExpField& rToThisField) = 0;
virtual void FieldsToExpand(SwHashTable<HashStr> & rTable, const SetGetExpField& rToThisField, SwRootFrame const& rLayout) = 0;
virtual bool IsNewFieldLst() const = 0;
......
......@@ -31,6 +31,7 @@ class SwCalc;
class SwTableBox;
class SwTableFormulaUpdate;
class SwDoc;
class SwRootFrame;
class SwTableCalcPara
{
......@@ -38,11 +39,12 @@ class SwTableCalcPara
sal_uInt16 m_nStackCount, m_nMaxSize;
public:
SwRootFrame const*const m_pLayout; ///< layout to access text field results
std::unique_ptr<SwTableSortBoxes> m_pBoxStack; ///< stack for recognizing recursion
SwCalc& m_rCalc; ///< current Calculator
const SwTable* m_pTable; ///< current table
SwTableCalcPara( SwCalc& rCalculator, const SwTable& rTable );
SwTableCalcPara(SwCalc& rCalculator, const SwTable& rTable, SwRootFrame const* pLayout);
~SwTableCalcPara();
bool CalcWithStackOverflow();
......
......@@ -79,7 +79,9 @@ protected:
class SW_DLLPUBLIC SwGetExpField : public SwFormulaField
{
double m_fValueRLHidden; ///< SwValueField; hidden redlines
OUString m_sExpand;
OUString m_sExpandRLHidden; ///< hidden redlines
bool m_bIsInBodyText;
sal_uInt16 m_nSubType;
......@@ -87,15 +89,19 @@ class SW_DLLPUBLIC SwGetExpField : public SwFormulaField
virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
virtual std::unique_ptr<SwField> Copy() const override;
using SwFormulaField::GetValue; // hide it, don't use
virtual void SetValue(const double& rVal) override; // hide it
public:
SwGetExpField( SwGetExpFieldType*, const OUString& rFormel,
sal_uInt16 nSubType, sal_uLong nFormat);
virtual void SetValue( const double& rVal ) override;
double GetValue(SwRootFrame const* pLayout) const;
void SetValue(const double& rVal, SwRootFrame const* pLayout);
virtual void SetLanguage(LanguageType nLng) override;
inline void ChgExpStr(const OUString& rExpand);
void ChgExpStr(const OUString& rExpand, SwRootFrame const* pLayout);
/// Called by formatting.
inline bool IsInBodyText() const;
......@@ -123,9 +129,6 @@ public:
void SetLateInitialization() { m_bLateInitialization = true;}
};
inline void SwGetExpField::ChgExpStr(const OUString& rExpand)
{ m_sExpand = rExpand;}
/// Called by formatting.
inline bool SwGetExpField::IsInBodyText() const
{ return m_bIsInBodyText; }
......@@ -174,7 +177,7 @@ public:
void SetDelimiter( const OUString& s ) { m_sDelim = s; }
sal_uInt8 GetOutlineLvl() const { return m_nLevel; }
void SetOutlineLvl( sal_uInt8 n ) { m_nLevel = n; }
void SetChapter( SwSetExpField& rField, const SwNode& rNd );
void SetChapter(SwSetExpField& rField, const SwNode& rNd, SwRootFrame const* pLayout);
virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
......@@ -194,7 +197,9 @@ inline const OUString& SwSetExpFieldType::GetSetRefName() const
class SW_DLLPUBLIC SwSetExpField : public SwFormulaField
{
double m_fValueRLHidden; ///< SwValueField; hidden redlines
OUString msExpand;
OUString msExpandRLHidden; ///< hidden redlines
OUString maPText;
bool mbInput;
sal_uInt16 mnSeqNo;
......@@ -203,6 +208,8 @@ class SW_DLLPUBLIC SwSetExpField : public SwFormulaField
virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
virtual std::unique_ptr<SwField> Copy() const override;
using SwFormulaField::GetValue; // hide it, don't use
virtual void SetValue(const double& rVal) override; // hide it
public:
SwSetExpField(SwSetExpFieldType*, const OUString& rFormel, sal_uLong nFormat = 0);
......@@ -210,11 +217,12 @@ public:
void SetFormatField(SwFormatField & rFormatField);
SwFormatField* GetFormatField() { return mpFormatField;}
virtual void SetValue( const double& rVal ) override;
double GetValue(SwRootFrame const* pLayout) const;
void SetValue(const double& rVal, SwRootFrame const* pLayout);
inline const OUString& GetExpStr() const;
const OUString& GetExpStr(SwRootFrame const* pLayout) const;
inline void ChgExpStr( const OUString& rExpand );
void ChgExpStr(const OUString& rExpand, SwRootFrame const* pLayout);
inline void SetPromptText(const OUString& rStr);
inline const OUString& GetPromptText() const;
......@@ -243,12 +251,6 @@ public:
virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
};
inline const OUString& SwSetExpField::GetExpStr() const
{ return msExpand; }
inline void SwSetExpField::ChgExpStr( const OUString& rExpand )
{ msExpand = rExpand; }
inline void SwSetExpField::SetPromptText(const OUString& rStr)
{ maPText = rStr; }
......
......@@ -163,7 +163,7 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
switch ( pField->GetTyp()->Which() )
{
case SwFieldIds::SetExp:
nRet = static_cast<const SwSetExpField*>(pField)->GetValue();
nRet = static_cast<const SwSetExpField*>(pField)->GetValue(rCalcPara.m_pLayout);
break;
case SwFieldIds::User:
nRet = static_cast<const SwUserField*>(pField)->GetValue();
......@@ -251,10 +251,15 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
// structure needed for calculation of tables
SwTableCalcPara::SwTableCalcPara( SwCalc& rCalculator, const SwTable& rTable )
: m_pLastTableBox( nullptr ), m_nStackCount( 0 ), m_nMaxSize( cMAXSTACKSIZE ),
m_pBoxStack( new SwTableSortBoxes ),
m_rCalc( rCalculator ), m_pTable( &rTable )
SwTableCalcPara::SwTableCalcPara(SwCalc& rCalculator, const SwTable& rTable,
SwRootFrame const*const pLayout)
: m_pLastTableBox(nullptr)
, m_nStackCount( 0 )
, m_nMaxSize( cMAXSTACKSIZE )
, m_pLayout(pLayout)
, m_pBoxStack( new SwTableSortBoxes )
, m_rCalc( rCalculator )
, m_pTable( &rTable )
{
}
......
......@@ -56,8 +56,8 @@ public:
virtual bool SetFieldsDirty(bool b, const SwNode* pChk, sal_uLong nLen) override;
virtual void SetFixFields(const DateTime* pNewDateTime) override;
virtual void FieldsToCalc(SwCalc& rCalc, sal_uLong nLastNd, sal_uInt16 nLastCnt) override;
virtual void FieldsToCalc(SwCalc& rCalc, const SetGetExpField& rToThisField) override;
virtual void FieldsToExpand(SwHashTable<HashStr>& rTable, const SetGetExpField& rToThisField) override;
virtual void FieldsToCalc(SwCalc& rCalc, const SetGetExpField& rToThisField, SwRootFrame const* pLayout) override;
virtual void FieldsToExpand(SwHashTable<HashStr>& rTable, const SetGetExpField& rToThisField, SwRootFrame const& rLayout) override;
virtual bool IsNewFieldLst() const override;
virtual void SetNewFieldLst( bool bFlag) override;
virtual void InsDelFieldInFieldLst(bool bIns, const SwTextField& rField) override;
......@@ -95,6 +95,8 @@ private:
DocumentFieldsManager(DocumentFieldsManager const&) = delete;
DocumentFieldsManager& operator=(DocumentFieldsManager const&) = delete;
void UpdateExpFieldsImpl(SwTextField* pField, SwRootFrame const* pLayout);
SwDoc& m_rDoc;
bool mbNewFieldLst; //< TRUE: Rebuild field-list.
......
......@@ -1730,7 +1730,7 @@ void SAL_CALL SwXTextField::attach(
pSEField->SetInputFlag(m_pImpl->m_pProps->bBool1);
pSEField->SetPromptText(m_pImpl->m_pProps->sPar3);
if (!m_pImpl->m_pProps->sPar4.isEmpty())
pSEField->ChgExpStr(m_pImpl->m_pProps->sPar4);
pSEField->ChgExpStr(m_pImpl->m_pProps->sPar4, nullptr);
}
break;
......@@ -1772,7 +1772,7 @@ void SAL_CALL SwXTextField::attach(
xField.reset(pGEField);
//TODO: evaluate SubType!
if (!m_pImpl->m_pProps->sPar4.isEmpty())
pGEField->ChgExpStr(m_pImpl->m_pProps->sPar4);
pGEField->ChgExpStr(m_pImpl->m_pProps->sPar4, nullptr);
// #i82544#
if (bSetGetExpFieldUninitialized)
pGEField->SetLateInitialization();
......
......@@ -1393,7 +1393,7 @@ eF_ResT SwWW8ImplReader::Read_F_ANumber( WW8FieldDesc*, OUString& rStr )
}
SwSetExpField aField( static_cast<SwSetExpFieldType*>(m_pNumFieldType), OUString(),
GetNumberPara( rStr ) );
aField.SetValue( ++m_nFieldNum );
aField.SetValue( ++m_nFieldNum, nullptr );
m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) );
return eF_ResT::OK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment