From 89e65e6afdfc942cf8232886d6703947167eaec3 Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Sat, 1 Apr 2023 20:44:43 +0200 Subject: tdf#153880 sc: Make Calc text hyperlinks stand out more Add underlining for links in Calc. TODO: unit test Change-Id: Idd5a7de7464d8ce443cdec756ac803491e73b0ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149913 Tested-by: Jenkins Tested-by: Gabor Kelemen Reviewed-by: Balazs Varga --- sc/inc/editutil.hxx | 6 +++--- sc/source/core/tool/editutil.cxx | 13 +++++++++---- sc/source/filter/xml/xmlexprt.cxx | 2 +- sc/source/ui/pagedlg/scuitphfedit.cxx | 11 ++++++----- sc/source/ui/unoobj/fielduno.cxx | 6 +++--- 5 files changed, 22 insertions(+), 16 deletions(-) (limited to 'sc') diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx index 04975b05ccc0..ce102885ae4f 100644 --- a/sc/inc/editutil.hxx +++ b/sc/inc/editutil.hxx @@ -74,7 +74,7 @@ public: static std::unique_ptr Clone( const EditTextObject& rSrc, ScDocument& rDestDoc ); static OUString GetCellFieldValue( - const SvxFieldData& rFieldData, const ScDocument* pDoc, std::optional* ppTextColor ); + const SvxFieldData& rFieldData, const ScDocument* pDoc, std::optional* ppTextColor, std::optional* ppFldLineStyle ); public: ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ, @@ -181,7 +181,7 @@ public: void SetExecuteURL(bool bSet) { bExecuteURL = bSet; } virtual bool FieldClicked( const SvxFieldItem& rField ) override; - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional& rTxtColor, std::optional& rFldColor ) override; + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional& rTxtColor, std::optional& rFldColor, std::optional& rFldLineStyle ) override; }; // 1/100 mm @@ -218,7 +218,7 @@ private: public: ScHeaderEditEngine( SfxItemPool* pEnginePool ); - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional& rTxtColor, std::optional& rFldColor ) override; + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional& rTxtColor, std::optional& rFldColor, std::optional& rFldLineStyle ) override; void SetNumType(SvxNumType eNew) { aData.eNumType = eNew; } void SetData(const ScHeaderFieldData& rNew) { aData = rNew; } diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx index c7e0c0cb6830..43d903f60529 100644 --- a/sc/source/core/tool/editutil.cxx +++ b/sc/source/core/tool/editutil.cxx @@ -213,7 +213,7 @@ std::unique_ptr ScEditUtil::Clone( const EditTextObject& rObj, S } OUString ScEditUtil::GetCellFieldValue( - const SvxFieldData& rFieldData, const ScDocument* pDoc, std::optional* ppTextColor ) + const SvxFieldData& rFieldData, const ScDocument* pDoc, std::optional* ppTextColor, std::optional* ppFldLineStyle ) { OUString aRet; switch (rFieldData.GetClassId()) @@ -241,6 +241,9 @@ OUString ScEditUtil::GetCellFieldValue( if (ppTextColor) *ppTextColor = SC_MOD()->GetColorConfig().GetColorValue(eEntry).nColor; + + if (ppFldLineStyle) + *ppFldLineStyle = FontLineStyle::LINESTYLE_SINGLE; } break; case text::textfield::Type::EXTENDED_TIME: @@ -836,7 +839,8 @@ ScHeaderEditEngine::ScHeaderEditEngine( SfxItemPool* pEnginePoolP ) OUString ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 /* nPara */, sal_Int32 /* nPos */, - std::optional& /* rTxtColor */, std::optional& /* rFldColor */ ) + std::optional& /* rTxtColor */, std::optional& /* rFldColor */, + std::optional& /*rFldLineStyle*/ ) { const SvxFieldData* pFieldData = rField.GetField(); if (!pFieldData) @@ -900,14 +904,15 @@ ScFieldEditEngine::ScFieldEditEngine( OUString ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 /* nPara */, sal_Int32 /* nPos */, - std::optional& rTxtColor, std::optional& /* rFldColor */ ) + std::optional& rTxtColor, std::optional& /* rFldColor */, + std::optional& rFldLineStyle ) { const SvxFieldData* pFieldData = rField.GetField(); if (!pFieldData) return " "; - return ScEditUtil::GetCellFieldValue(*pFieldData, mpDoc, &rTxtColor); + return ScEditUtil::GetCellFieldValue(*pFieldData, mpDoc, &rTxtColor, &rFldLineStyle); } bool ScFieldEditEngine::FieldClicked( const SvxFieldItem& rField ) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 4c306de2c907..9aa4b7b5ad36 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3020,7 +3020,7 @@ void writeContent( if (pField) { // Write a field item. - OUString aFieldVal = ScEditUtil::GetCellFieldValue(*pField, rExport.GetDocument(), nullptr); + OUString aFieldVal = ScEditUtil::GetCellFieldValue(*pField, rExport.GetDocument(), nullptr, nullptr); switch (pField->GetClassId()) { case text::textfield::Type::URL: diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx index 46687884e376..d82c923e56c4 100644 --- a/sc/source/ui/pagedlg/scuitphfedit.cxx +++ b/sc/source/ui/pagedlg/scuitphfedit.cxx @@ -182,13 +182,14 @@ void ScHFEditPage::InitPreDefinedList() std::optional pTxtColour; std::optional pFldColour; + std::optional pFldLineStyle; // Get the all field values at the outset. - OUString aPageFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour)); - OUString aSheetFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour)); - OUString aFileFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour)); - OUString aExtFileFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxExtFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour)); - OUString aDateFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxDateField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour)); + OUString aPageFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour, pFldLineStyle)); + OUString aSheetFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour, pFldLineStyle)); + OUString aFileFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour, pFldLineStyle)); + OUString aExtFileFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxExtFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour, pFldLineStyle)); + OUString aDateFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxDateField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour, pFldLineStyle)); m_xLbDefined->clear(); diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx index aacb4e2e3815..4f179d782f94 100644 --- a/sc/source/ui/unoobj/fielduno.cxx +++ b/sc/source/ui/unoobj/fielduno.cxx @@ -170,7 +170,7 @@ public: explicit ScUnoEditEngine(ScEditEngineDefaulter* pSource); virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, - std::optional& rTxtColor, std::optional& rFldColor ) override; + std::optional& rTxtColor, std::optional& rFldColor, std::optional& rFldLineStyle ) override; sal_uInt16 CountFields(); SvxFieldData* FindByIndex(sal_uInt16 nIndex); @@ -196,9 +196,9 @@ ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter* pSource) } OUString ScUnoEditEngine::CalcFieldValue( const SvxFieldItem& rField, - sal_Int32 nPara, sal_Int32 nPos, std::optional& rTxtColor, std::optional& rFldColor ) + sal_Int32 nPara, sal_Int32 nPos, std::optional& rTxtColor, std::optional& rFldColor, std::optional& rFldLineStyle ) { - OUString aRet(EditEngine::CalcFieldValue( rField, nPara, nPos, rTxtColor, rFldColor )); + OUString aRet(EditEngine::CalcFieldValue( rField, nPara, nPos, rTxtColor, rFldColor, rFldLineStyle )); if (eMode != SC_UNO_COLLECT_NONE) { const SvxFieldData* pFieldData = rField.GetField(); -- cgit