Kaydet (Commit) 5c9ae702 authored tarafından Noel Grandin's avatar Noel Grandin

store Color using boost::optional in EditCharAttribField

Change-Id: If4af5991be51cdb035c0bc0fb7668844df703073
Reviewed-on: https://gerrit.libreoffice.org/54022Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst c5f8a296
......@@ -22,8 +22,9 @@
#include <editeng/eeitem.hxx>
#include <svl/poolitem.hxx>
#include <boost/optional.hpp>
#include <tools/color.hxx>
class Color;
class SvxFont;
class SvxFontItem;
class SvxWeightItem;
......@@ -363,8 +364,8 @@ public:
class EditCharAttribField: public EditCharAttrib
{
OUString aFieldValue;
Color* pTxtColor;
Color* pFldColor;
boost::optional<Color> mxTxtColor;
boost::optional<Color> mxFldColor;
EditCharAttribField& operator = ( const EditCharAttribField& rAttr ) = delete;
......@@ -378,8 +379,8 @@ public:
{ return !(operator == ( rAttr ) ); }
virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
Color*& GetTextColor() { return pTxtColor; }
Color*& GetFieldColor() { return pFldColor; }
boost::optional<Color>& GetTextColor() { return mxTxtColor; }
boost::optional<Color>& GetFieldColor() { return mxFldColor; }
const OUString& GetFieldValue() const { return aFieldValue;}
void SetFieldValue(const OUString& rVal);
......
......@@ -805,7 +805,7 @@ class UrlEditEngine : public EditEngine
public:
explicit UrlEditEngine(SfxItemPool *pPool) : EditEngine(pPool) {}
virtual OUString CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, Color*&, Color*& ) override
virtual OUString CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, boost::optional<Color>&, boost::optional<Color>& ) override
{
return OUString("jim@bob.com"); // a sophisticated view of value:
}
......
......@@ -345,19 +345,17 @@ EditCharAttribField::EditCharAttribField( const SvxFieldItem& rAttr, sal_Int32 n
: EditCharAttrib( rAttr, nPos, nPos+1 )
{
SetFeature( true ); // !!!
pTxtColor = nullptr;
pFldColor = nullptr;
}
void EditCharAttribField::SetFont( SvxFont& rFont, OutputDevice* )
{
if ( pFldColor )
if ( mxFldColor )
{
rFont.SetFillColor( *pFldColor );
rFont.SetFillColor( *mxFldColor );
rFont.SetTransparent( false );
}
if ( pTxtColor )
rFont.SetColor( *pTxtColor );
if ( mxTxtColor )
rFont.SetColor( *mxTxtColor );
}
......@@ -369,8 +367,8 @@ void EditCharAttribField::SetFieldValue(const OUString& rVal)
void EditCharAttribField::Reset()
{
aFieldValue.clear();
delete pTxtColor; pTxtColor = nullptr;
delete pFldColor; pFldColor = nullptr;
mxTxtColor.reset();
mxFldColor.reset();
}
EditCharAttribField::EditCharAttribField( const EditCharAttribField& rAttr )
......@@ -378,8 +376,8 @@ EditCharAttribField::EditCharAttribField( const EditCharAttribField& rAttr )
aFieldValue( rAttr.aFieldValue )
{
// Use this constructor only for temporary Objects, Item is not pooled.
pTxtColor = rAttr.pTxtColor ? new Color( *rAttr.pTxtColor ) : nullptr;
pFldColor = rAttr.pFldColor ? new Color( *rAttr.pFldColor ) : nullptr;
mxTxtColor = rAttr.mxTxtColor;
mxFldColor = rAttr.mxFldColor;
}
EditCharAttribField::~EditCharAttribField()
......@@ -392,14 +390,14 @@ bool EditCharAttribField::operator == ( const EditCharAttribField& rAttr ) const
if ( aFieldValue != rAttr.aFieldValue )
return false;
if ( ( pTxtColor && !rAttr.pTxtColor ) || ( !pTxtColor && rAttr.pTxtColor ) )
if ( ( mxTxtColor && !rAttr.mxTxtColor ) || ( !mxTxtColor && rAttr.mxTxtColor ) )
return false;
if ( ( pTxtColor && rAttr.pTxtColor ) && ( *pTxtColor != *rAttr.pTxtColor ) )
if ( ( mxTxtColor && rAttr.mxTxtColor ) && ( *mxTxtColor != *rAttr.mxTxtColor ) )
return false;
if ( ( pFldColor && !rAttr.pFldColor ) || ( !pFldColor && rAttr.pFldColor ) )
if ( ( mxFldColor && !rAttr.mxFldColor ) || ( !mxFldColor && rAttr.mxFldColor ) )
return false;
if ( ( pFldColor && rAttr.pFldColor ) && ( *pFldColor != *rAttr.pFldColor ) )
if ( ( mxFldColor && rAttr.mxFldColor ) && ( *mxFldColor != *rAttr.mxFldColor ) )
return false;
return true;
......
......@@ -2590,7 +2590,7 @@ tools::Rectangle EditEngine::GetBulletArea( sal_Int32 )
return tools::Rectangle( Point(), Point() );
}
OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, Color*&, Color*& )
OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, boost::optional<Color>&, boost::optional<Color>& )
{
return OUString(' ');
}
......
......@@ -2968,7 +2968,7 @@ bool ImpEditEngine::UpdateFields()
rField.Reset();
if ( aStatus.MarkFields() )
rField.GetFieldColor() = new Color( GetColorConfig().GetColorValue( svtools::WRITERFIELDSHADINGS ).nColor );
rField.GetFieldColor() = GetColorConfig().GetColorValue( svtools::WRITERFIELDSHADINGS ).nColor;
const OUString aFldValue =
GetEditEnginePtr()->CalcFieldValue(
......
......@@ -169,7 +169,7 @@ void OutlinerEditEng::DrawingTab( const Point& rStartPos, long nWidth, const OUS
bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor );
}
OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
{
return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}
......
......@@ -71,7 +71,7 @@ public:
// for text conversion
virtual bool ConvertNextDocument() override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) override;
virtual tools::Rectangle GetBulletArea( sal_Int32 nPara ) override;
......
......@@ -635,7 +635,7 @@ void Outliner::AddText( const OutlinerParaObject& rPObj )
pEditEngine->SetUpdateMode( bUpdate );
}
OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
{
if ( !aCalcFieldValueHdl.IsSet() )
return OUString( ' ' );
......@@ -648,12 +648,13 @@ OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara,
aCalcFieldValueHdl.Call( &aFldInfo );
if ( aFldInfo.GetTextColor() )
{
delete rpTxtColor;
rpTxtColor = new Color( *aFldInfo.GetTextColor() );
rpTxtColor = *aFldInfo.GetTextColor();
}
delete rpFldColor;
rpFldColor = aFldInfo.GetFieldColor() ? new Color( *aFldInfo.GetFieldColor() ) : nullptr;
if (aFldInfo.GetFieldColor())
rpFldColor = *aFldInfo.GetFieldColor();
else
rpFldColor.reset();
return aFldInfo.GetRepresentation();
}
......
......@@ -614,7 +614,7 @@ SfxItemPool* SvxAccessibleTextAdapter::GetPool() const
return mpTextForwarder->GetPool();
}
OUString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
{
assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder");
......
......@@ -151,7 +151,7 @@ bool SvxEditEngineForwarder::IsValid() const
return rEditEngine.GetUpdateMode();
}
OUString SvxEditEngineForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString SvxEditEngineForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
{
return rEditEngine.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}
......
......@@ -223,7 +223,7 @@ void SvxOutlinerForwarder::QuickSetAttribs( const SfxItemSet& rSet, const ESelec
rOutliner.QuickSetAttribs( rSet, rSel );
}
OUString SvxOutlinerForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString SvxOutlinerForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
{
return rOutliner.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}
......
......@@ -633,15 +633,12 @@ void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertySimpleEntry* pM
uno::Reference< text::XTextRange > xAnchor( this );
// get presentation string for field
Color* pTColor = nullptr;
Color* pFColor = nullptr;
boost::optional<Color> pTColor;
boost::optional<Color> pFColor;
SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
OUString aPresentation( pForwarder->CalcFieldValue( SvxFieldItem(*pData, EE_FEATURE_FIELD), maSelection.nStartPara, maSelection.nStartPos, pTColor, pFColor ) );
delete pTColor;
delete pFColor;
uno::Reference< text::XTextField > xField( new SvxUnoTextField( xAnchor, aPresentation, pData ) );
rAny <<= xField;
}
......@@ -2377,7 +2374,7 @@ void SvxDummyTextSource::QuickInsertLineBreak( const ESelection& )
{
};
OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, Color*&, Color*& )
OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, boost::optional<Color>&, boost::optional<Color>& )
{
return OUString();
}
......
......@@ -41,6 +41,7 @@
#include <o3tl/typed_flags_set.hxx>
#include <svl/languageoptions.hxx>
#include <vcl/errcode.hxx>
#include <boost/optional.hpp>
#include <functional>
namespace com { namespace sun { namespace star {
......@@ -508,7 +509,7 @@ public:
virtual OUString GetUndoComment( sal_uInt16 nUndoId ) const;
virtual bool SpellNextDocument();
virtual void FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor );
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor );
// override this if access to bullet information needs to be provided
virtual const SvxNumberFormat * GetNumberFormat( sal_Int32 nPara ) const;
......
......@@ -900,7 +900,7 @@ public:
bool UpdateFields();
void RemoveFields( const std::function<bool ( const SvxFieldData* )>& isFieldData = [] (const SvxFieldData* ){return true;} );
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor );
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor );
void SetSpeller( css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpeller );
css::uno::Reference< css::linguistic2::XSpellChecker1 > const &
......
......@@ -54,7 +54,7 @@ public:
virtual SfxItemPool* GetPool() const override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
virtual void FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos ) override;
virtual bool IsValid() const override;
......
......@@ -155,7 +155,7 @@ public:
virtual void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) = 0;
virtual void QuickInsertLineBreak( const ESelection& rSel ) = 0;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor ) = 0;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) = 0;
virtual void FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos ) = 0;
virtual SfxItemPool* GetPool() const = 0;
......
......@@ -54,7 +54,7 @@ public:
virtual SfxItemPool* GetPool() const override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
virtual void FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos ) override;
virtual bool IsValid() const override;
......
......@@ -72,7 +72,7 @@ public:
virtual SfxItemPool* GetPool() const override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
virtual void FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos ) override;
virtual bool IsValid() const override;
......
......@@ -196,7 +196,7 @@ public:
virtual void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) override;
virtual void QuickInsertLineBreak( const ESelection& rSel ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
virtual void FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos ) override;
virtual bool IsValid() const override;
......
......@@ -27,7 +27,7 @@ class ClassificationEditEngine : public EditEngine
public:
ClassificationEditEngine(SfxItemPool* pItemPool);
virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor) override;
virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor) override;
};
class SVX_DLLPUBLIC ClassificationEditView : public Control
......
......@@ -140,7 +140,7 @@ public:
virtual OutlinerParaObject* GetOutlinerParaObject() const override;
virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
bool bEdit, Color*& rpTxtColor, Color*& rpFldColor, OUString& rRet) const override;
bool bEdit, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor, OUString& rRet) const override;
// #i97878#
virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const override;
......
......@@ -496,7 +496,7 @@ public:
virtual void ReformatText() override;
virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
bool bEdit, Color*& rpTxtColor, Color*& rpFldColor, OUString& rRet) const;
bool bEdit, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor, OUString& rRet) const;
virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
......
......@@ -44,7 +44,7 @@ public:
void setVisualizedPage(const SdrPage* pPage) { if(pPage != mpVisualizedPage) mpVisualizedPage = pPage; }
const SdrPage* getVisualizedPage() const { return mpVisualizedPage; }
virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor) override;
virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor) override;
bool hasEditViewCallbacks() const;
};
......
......@@ -75,7 +75,7 @@ public:
static std::unique_ptr<EditTextObject> Clone( const EditTextObject& rSrc, ScDocument& rDestDoc );
static OUString GetCellFieldValue(
const SvxFieldData& rFieldData, const ScDocument* pDoc, Color** ppTextColor );
const SvxFieldData& rFieldData, const ScDocument* pDoc, boost::optional<Color>* ppTextColor );
public:
ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ,
......@@ -214,7 +214,7 @@ public:
void SetExecuteURL(bool bSet) { bExecuteURL = bSet; }
virtual void FieldClicked( const SvxFieldItem& rField, sal_Int32, sal_Int32 ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) override;
};
// for headers/footers with fields
......@@ -225,7 +225,7 @@ private:
public:
ScHeaderEditEngine( SfxItemPool* pEnginePool );
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) override;
void SetNumType(SvxNumType eNew) { aData.eNumType = eNew; }
void SetData(const ScHeaderFieldData& rNew) { aData = rNew; }
......
......@@ -191,7 +191,7 @@ std::unique_ptr<EditTextObject> ScEditUtil::Clone( const EditTextObject& rObj, S
}
OUString ScEditUtil::GetCellFieldValue(
const SvxFieldData& rFieldData, const ScDocument* pDoc, Color** ppTextColor )
const SvxFieldData& rFieldData, const ScDocument* pDoc, boost::optional<Color>* ppTextColor )
{
OUString aRet;
switch (rFieldData.GetClassId())
......@@ -218,7 +218,7 @@ OUString ScEditUtil::GetCellFieldValue(
INetURLHistory::GetOrCreate()->QueryUrl(aURL) ? svtools::LINKSVISITED : svtools::LINKS;
if (ppTextColor)
*ppTextColor = new Color( SC_MOD()->GetColorConfig().GetColorValue(eEntry).nColor );
*ppTextColor = SC_MOD()->GetColorConfig().GetColorValue(eEntry).nColor;
}
break;
case text::textfield::Type::EXTENDED_TIME:
......@@ -796,7 +796,7 @@ ScHeaderEditEngine::ScHeaderEditEngine( SfxItemPool* pEnginePoolP )
OUString ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem& rField,
sal_Int32 /* nPara */, sal_Int32 /* nPos */,
Color*& /* rTxtColor */, Color*& /* rFldColor */ )
boost::optional<Color>& /* rTxtColor */, boost::optional<Color>& /* rFldColor */ )
{
const SvxFieldData* pFieldData = rField.GetField();
if (!pFieldData)
......@@ -860,7 +860,7 @@ ScFieldEditEngine::ScFieldEditEngine(
OUString ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
sal_Int32 /* nPara */, sal_Int32 /* nPos */,
Color*& rTxtColor, Color*& /* rFldColor */ )
boost::optional<Color>& rTxtColor, boost::optional<Color>& /* rFldColor */ )
{
const SvxFieldData* pFieldData = rField.GetField();
......
......@@ -231,8 +231,8 @@ void ScHFEditPage::InitPreDefinedList()
{
SvtUserOptions aUserOpt;
Color* pTxtColour = nullptr;
Color* pFldColour = nullptr;
boost::optional<Color> pTxtColour;
boost::optional<Color> pFldColour;
// Get the all field values at the outset.
OUString aPageFieldValue(m_pWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
......
......@@ -177,7 +177,7 @@ public:
explicit ScUnoEditEngine(ScEditEngineDefaulter* pSource);
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
Color*& rTxtColor, Color*& rFldColor ) override;
boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) override;
sal_uInt16 CountFields();
SvxFieldData* FindByIndex(sal_uInt16 nIndex);
......@@ -202,7 +202,7 @@ ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter* pSource)
}
OUString ScUnoEditEngine::CalcFieldValue( const SvxFieldItem& rField,
sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor )
sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor )
{
OUString aRet(EditEngine::CalcFieldValue( rField, nPara, nPos, rTxtColor, rFldColor ));
if (eMode != SC_UNO_COLLECT_NONE)
......
......@@ -1023,7 +1023,7 @@ bool SmTextForwarder::IsValid() const
return pEditEngine && pEditEngine->GetUpdateMode();
}
OUString SmTextForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString SmTextForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor) : OUString();
......
......@@ -201,7 +201,7 @@ public:
virtual SfxItemPool* GetPool() const override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
virtual void FieldClicked(const SvxFieldItem&, sal_Int32, sal_Int32) override;
virtual bool IsValid() const override;
......
......@@ -120,7 +120,7 @@ namespace accessibility
//XTextCopy
void CopyText(const SvxTextForwarder& ) override {}
OUString CalcFieldValue( const SvxFieldItem& /*rField*/, sal_Int32 /*nPara*/, sal_Int32 /*nPos*/, Color*& /*rpTxtColor*/, Color*& /*rpFldColor*/ ) override
OUString CalcFieldValue( const SvxFieldItem& /*rField*/, sal_Int32 /*nPara*/, sal_Int32 /*nPos*/, boost::optional<Color>& /*rpTxtColor*/, boost::optional<Color>& /*rpFldColor*/ ) override
{
return OUString();
}
......
......@@ -29,7 +29,7 @@ ClassificationEditEngine::ClassificationEditEngine(SfxItemPool* pItemPool)
{}
OUString ClassificationEditEngine::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 /*nPara*/,
sal_Int32 /*nPos*/, Color*& /*rTxtColor*/, Color*& /*rFldColor*/)
sal_Int32 /*nPos*/, boost::optional<Color>& /*rTxtColor*/, boost::optional<Color>& /*rFldColor*/)
{
OUString aString;
const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(rField.GetField());
......
......@@ -975,17 +975,15 @@ IMPL_LINK(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI,void)
rStr.clear();
SdrTextObj* pTextObj = mxTextEditObj.get();
if (pTextObj!=nullptr) {
Color* pTxtCol=nullptr;
Color* pFldCol=nullptr;
boost::optional<Color> pTxtCol;
boost::optional<Color> pFldCol;
bOk=pTextObj->CalcFieldValue(pFI->GetField(),pFI->GetPara(),pFI->GetPos(),true,pTxtCol,pFldCol,rStr);
if (bOk) {
if (pTxtCol!=nullptr) {
if (pTxtCol) {
pFI->SetTextColor(*pTxtCol);
delete pTxtCol;
}
if (pFldCol!=nullptr) {
if (pFldCol) {
pFI->SetFieldColor(*pFldCol);
delete pFldCol;
} else {
pFI->SetFieldColor(COL_LIGHTGRAY); // TODO: remove this later on (357)
}
......
......@@ -549,18 +549,15 @@ basegfx::B2DPolyPolygon SdrMeasureObj::ImpCalcXPoly(const ImpMeasurePoly& rPol)
bool SdrMeasureObj::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
bool bEdit,
Color*& rpTxtColor, Color*& rpFldColor, OUString& rRet) const
boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor, OUString& rRet) const
{
const SvxFieldData* pField=rField.GetField();
const SdrMeasureField* pMeasureField=dynamic_cast<const SdrMeasureField*>( pField );
if (pMeasureField!=nullptr) {
rRet = TakeRepresentation(pMeasureField->GetMeasureFieldKind());
if (rpFldColor!=nullptr) {
if (!bEdit)
{
delete rpFldColor;
rpFldColor=nullptr;
}
if (rpFldColor && !bEdit)
{
rpFldColor.reset();
}
return true;
} else {
......
......@@ -22,7 +22,7 @@
#include <svx/svdotext.hxx>
bool SdrTextObj::CalcFieldValue(const SvxFieldItem& /*rField*/, sal_Int32 /*nPara*/, sal_uInt16 /*nPos*/,
bool /*bEdit*/, Color*& /*rpTxtColor*/, Color*& /*rpFldColor*/, OUString& /*rRet*/) const
bool /*bEdit*/, boost::optional<Color>& /*rpTxtColor*/, boost::optional<Color>& /*rpFldColor*/, OUString& /*rRet*/) const
{
return false;
}
......
......@@ -72,7 +72,7 @@ void SdrOutliner::SetTextObjNoInit( const SdrTextObj* pObj )
}
OUString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
Color*& rpTxtColor, Color*& rpFldColor)
boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor)
{
bool bOk = false;
OUString aRet;
......
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