sc/inc/ViewSettingsSequenceDefines.hxx |   31 +++++++-------
 sc/inc/unonames.hxx                    |    1 
 sc/inc/viewopti.hxx                    |    1 
 sc/source/core/tool/viewopti.cxx       |   21 ++++++---
 sc/source/ui/inc/output.hxx            |    1 
 sc/source/ui/inc/tpview.hxx            |    1 
 sc/source/ui/optdlg/tpview.cxx         |    6 ++
 sc/source/ui/unoobj/confuno.cxx        |    5 ++
 sc/source/ui/unoobj/viewuno.cxx        |    4 +
 sc/source/ui/view/gridwin4.cxx         |    3 +
 sc/source/ui/view/gridwin5.cxx         |   25 +++++++++++
 sc/source/ui/view/output.cxx           |   72 +++++++++++++++++++++++++++++++++
 sc/source/ui/view/viewdata.cxx         |    4 +
 sc/uiconfig/scalc/ui/tpviewpage.ui     |   22 ++++++++--
 14 files changed, 172 insertions(+), 25 deletions(-)

New commits:
commit 3fcf9f864f9d12fdb0ade4741127c81cec74378a
Author:     Grigory A. Mozhaev <zcren...@gmail.com>
AuthorDate: Mon Feb 27 16:03:39 2023 +0300
Commit:     Heiko Tietze <heiko.tie...@documentfoundation.org>
CommitDate: Wed Mar 8 10:51:42 2023 +0000

    tdf#97551 Added marker and hint for formula to Calc
    
    Added option "Formula indicator and hint" to LibreOffice Calc > View 
section (near to "Comment indicator"). This option turned off by default to 
avoid interfere existing UX.
    
    Indicator displays in the bottom-left corner as blue triangle marker if 
cells contains formula (correctly reacts on cells merging and different sizing).
    
    Hint displays when user hover cursor over the cell that contains the 
formula (uses already built-in mechanics for help tooltip).
    
    More details about request and discussion of the feature in Bugzilla.
    
    Change-Id: I8f3e368d4fdad362b819b4ce2fd6b0c32b5c1c0f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147914
    Tested-by: Jenkins
    Tested-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>

diff --git a/sc/inc/ViewSettingsSequenceDefines.hxx 
b/sc/inc/ViewSettingsSequenceDefines.hxx
index f22c4df5e05b..501a87cc1854 100644
--- a/sc/inc/ViewSettingsSequenceDefines.hxx
+++ b/sc/inc/ViewSettingsSequenceDefines.hxx
@@ -36,21 +36,22 @@
 #define SC_PAGE_BREAK_PREVIEW               7
 #define SC_SHOWZERO                         8
 #define SC_SHOWNOTES                        9
-#define SC_SHOWGRID                         10
-#define SC_GRIDCOLOR                        11
-#define SC_SHOWPAGEBR                       12
-#define SC_COLROWHDR                        13
-#define SC_SHEETTABS                        14
-#define SC_OUTLSYMB                         15
-#define SC_VALUE_HIGHLIGHTING               16
-#define SC_SNAPTORASTER                     17
-#define SC_RASTERVIS                        18
-#define SC_RASTERRESX                       19
-#define SC_RASTERRESY                       20
-#define SC_RASTERSUBX                       21
-#define SC_RASTERSUBY                       22
-#define SC_RASTERSYNC                       23
-#define SC_FORMULA_BAR_HEIGHT               24
+#define SC_SHOWFORMULASMARKS                10
+#define SC_SHOWGRID                         11
+#define SC_GRIDCOLOR                        12
+#define SC_SHOWPAGEBR                       13
+#define SC_COLROWHDR                        14
+#define SC_SHEETTABS                        15
+#define SC_OUTLSYMB                         16
+#define SC_VALUE_HIGHLIGHTING               17
+#define SC_SNAPTORASTER                     18
+#define SC_RASTERVIS                        19
+#define SC_RASTERRESX                       20
+#define SC_RASTERRESY                       21
+#define SC_RASTERSUBX                       22
+#define SC_RASTERSUBY                       23
+#define SC_RASTERSYNC                       24
+#define SC_FORMULA_BAR_HEIGHT               25
 
 // this are the defines for the position of the settings in the
 // TableViewSettingsSequence
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index bdd37e666871..abb09c334c10 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -550,6 +550,7 @@ inline constexpr OUStringLiteral SC_UNO_SHOWFORM            
 = u"ShowFormulas";
 inline constexpr OUStringLiteral SC_UNO_SHOWGRID             = u"ShowGrid";
 inline constexpr OUStringLiteral SC_UNO_SHOWHELP             = 
u"ShowHelpLines";
 inline constexpr OUStringLiteral SC_UNO_SHOWNOTES            = u"ShowNotes";
+inline constexpr OUStringLiteral SC_UNO_SHOWFORMULASMARKS    = 
u"ShowFormulasMarks";
 inline constexpr OUStringLiteral SC_UNO_SHOWOBJ              = u"ShowObjects";
 inline constexpr OUStringLiteral SC_UNO_SHOWPAGEBR           = 
u"ShowPageBreaks";
 inline constexpr OUStringLiteral SC_UNO_SHOWZERO             = 
u"ShowZeroValues";
diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx
index 79819e7ca324..b5a15f016e1b 100644
--- a/sc/inc/viewopti.hxx
+++ b/sc/inc/viewopti.hxx
@@ -33,6 +33,7 @@ enum ScViewOption
     VOPT_NULLVALS,
     VOPT_SYNTAX,
     VOPT_NOTES,
+    VOPT_FORMULAS_MARKS,
     VOPT_VSCROLL,
     VOPT_HSCROLL,
     VOPT_TABCONTROLS,
diff --git a/sc/source/core/tool/viewopti.cxx b/sc/source/core/tool/viewopti.cxx
index 30e5e14c9b1b..6079323f13e7 100644
--- a/sc/source/core/tool/viewopti.cxx
+++ b/sc/source/core/tool/viewopti.cxx
@@ -93,6 +93,7 @@ void ScViewOptions::SetDefaults()
     aOptArr[ VOPT_HELPLINES    ] = false;
     aOptArr[ VOPT_GRID_ONTOP   ] = false;
     aOptArr[ VOPT_NOTES        ] = true;
+    aOptArr[ VOPT_FORMULAS_MARKS ] = false;
     aOptArr[ VOPT_NULLVALS     ] = true;
     aOptArr[ VOPT_VSCROLL      ] = true;
     aOptArr[ VOPT_HSCROLL      ] = true;
@@ -206,12 +207,13 @@ constexpr OUStringLiteral CFGPATH_DISPLAY = 
u"Office.Calc/Content/Display";
 #define SCDISPLAYOPT_FORMULA        0
 #define SCDISPLAYOPT_ZEROVALUE      1
 #define SCDISPLAYOPT_NOTETAG        2
-#define SCDISPLAYOPT_VALUEHI        3
-#define SCDISPLAYOPT_ANCHOR         4
-#define SCDISPLAYOPT_TEXTOVER       5
-#define SCDISPLAYOPT_OBJECTGRA      6
-#define SCDISPLAYOPT_CHART          7
-#define SCDISPLAYOPT_DRAWING        8
+#define SCDISPLAYOPT_FORMULAMARK    3
+#define SCDISPLAYOPT_VALUEHI        4
+#define SCDISPLAYOPT_ANCHOR         5
+#define SCDISPLAYOPT_TEXTOVER       6
+#define SCDISPLAYOPT_OBJECTGRA      7
+#define SCDISPLAYOPT_CHART          8
+#define SCDISPLAYOPT_DRAWING        9
 
 constexpr OUStringLiteral CFGPATH_GRID = u"Office.Calc/Grid";
 
@@ -247,6 +249,7 @@ Sequence<OUString> ScViewCfg::GetDisplayPropertyNames()
     return {"Formula",                  // SCDISPLAYOPT_FORMULA
             "ZeroValue",                // SCDISPLAYOPT_ZEROVALUE
             "NoteTag",                  // SCDISPLAYOPT_NOTETAG
+            "FormulaMark",              // SCDISPLAYOPT_FORMULAMARK
             "ValueHighlighting",        // SCDISPLAYOPT_VALUEHI
             "Anchor",                   // SCDISPLAYOPT_ANCHOR
             "TextOverflow",             // SCDISPLAYOPT_TEXTOVER
@@ -365,6 +368,9 @@ ScViewCfg::ScViewCfg() :
                     case SCDISPLAYOPT_NOTETAG:
                         SetOption( VOPT_NOTES, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
                         break;
+                    case SCDISPLAYOPT_FORMULAMARK:
+                        SetOption( VOPT_FORMULAS_MARKS, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
+                        break;
                     case SCDISPLAYOPT_VALUEHI:
                         SetOption( VOPT_SYNTAX, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
                         break;
@@ -530,6 +536,9 @@ IMPL_LINK_NOARG(ScViewCfg, DisplayCommitHdl, 
ScLinkConfigItem&, void)
             case SCDISPLAYOPT_NOTETAG:
                 pValues[nProp] <<= GetOption( VOPT_NOTES );
                 break;
+            case SCDISPLAYOPT_FORMULAMARK:
+                pValues[nProp] <<= GetOption( VOPT_FORMULAS_MARKS );
+                break;
             case SCDISPLAYOPT_VALUEHI:
                 pValues[nProp] <<= GetOption( VOPT_SYNTAX );
                 break;
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index d44f7052589b..f0ce65d19c6a 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -381,6 +381,7 @@ public:
     void    DrawClipMarks();
 
     void    DrawNoteMarks(vcl::RenderContext& rRenderContext);
+    void    DrawFormulaMarks(vcl::RenderContext& rRenderContext);
     void    AddPDFNotes();
     void    DrawSparklines(vcl::RenderContext& rRenderContext);
 };
diff --git a/sc/source/ui/inc/tpview.hxx b/sc/source/ui/inc/tpview.hxx
index e1aa9ea07400..7be90de5aceb 100644
--- a/sc/source/ui/inc/tpview.hxx
+++ b/sc/source/ui/inc/tpview.hxx
@@ -37,6 +37,7 @@ class ScTpContentOptions : public SfxTabPage
     std::unique_ptr<weld::CheckButton> m_xFormulaCB;
     std::unique_ptr<weld::CheckButton> m_xNilCB;
     std::unique_ptr<weld::CheckButton> m_xAnnotCB;
+    std::unique_ptr<weld::CheckButton> m_xFormulaMarkCB;
     std::unique_ptr<weld::CheckButton> m_xValueCB;
     std::unique_ptr<weld::CheckButton> m_xAnchorCB;
     std::unique_ptr<weld::CheckButton> m_xClipMarkCB;
diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx
index 90b99f4a34b0..926436864e79 100644
--- a/sc/source/ui/optdlg/tpview.cxx
+++ b/sc/source/ui/optdlg/tpview.cxx
@@ -44,6 +44,7 @@ ScTpContentOptions::ScTpContentOptions(weld::Container* 
pPage, weld::DialogContr
     , m_xFormulaCB(m_xBuilder->weld_check_button("formula"))
     , m_xNilCB(m_xBuilder->weld_check_button("nil"))
     , m_xAnnotCB(m_xBuilder->weld_check_button("annot"))
+    , m_xFormulaMarkCB(m_xBuilder->weld_check_button("formulamark"))
     , m_xValueCB(m_xBuilder->weld_check_button("value"))
     , m_xAnchorCB(m_xBuilder->weld_check_button("anchor"))
     , m_xClipMarkCB(m_xBuilder->weld_check_button("clipmark"))
@@ -73,6 +74,7 @@ ScTpContentOptions::ScTpContentOptions(weld::Container* 
pPage, weld::DialogContr
     m_xNilCB->connect_toggled(aCBHdl);
     m_xAnnotCB->connect_toggled(aCBHdl);
     m_xAnnotCB->set_accessible_description(ScResId(STR_A11Y_DESC_ANNOT));
+    m_xFormulaMarkCB->connect_toggled(aCBHdl);
     m_xValueCB->connect_toggled(aCBHdl);
     m_xAnchorCB->connect_toggled(aCBHdl);
     m_xClipMarkCB->connect_toggled(aCBHdl);
@@ -108,6 +110,7 @@ bool    ScTpContentOptions::FillItemSet( SfxItemSet* 
rCoreSet )
     if( m_xFormulaCB->get_state_changed_from_saved() ||
         m_xNilCB->get_state_changed_from_saved() ||
         m_xAnnotCB->get_state_changed_from_saved() ||
+        m_xFormulaMarkCB->get_state_changed_from_saved() ||
         m_xValueCB->get_state_changed_from_saved() ||
         m_xAnchorCB->get_state_changed_from_saved() ||
         m_xClipMarkCB->get_state_changed_from_saved() ||
@@ -159,6 +162,7 @@ void    ScTpContentOptions::Reset( const SfxItemSet* 
rCoreSet )
     m_xFormulaCB ->set_active(m_xLocalOptions->GetOption(VOPT_FORMULAS));
     m_xNilCB     ->set_active(m_xLocalOptions->GetOption(VOPT_NULLVALS));
     m_xAnnotCB   ->set_active(m_xLocalOptions->GetOption(VOPT_NOTES));
+    
m_xFormulaMarkCB->set_active(m_xLocalOptions->GetOption(VOPT_FORMULAS_MARKS));
     m_xValueCB   ->set_active(m_xLocalOptions->GetOption(VOPT_SYNTAX));
     m_xAnchorCB  ->set_active(m_xLocalOptions->GetOption(VOPT_ANCHOR));
     m_xClipMarkCB->set_active(m_xLocalOptions->GetOption(VOPT_CLIPMARKS));
@@ -194,6 +198,7 @@ void    ScTpContentOptions::Reset( const SfxItemSet* 
rCoreSet )
     m_xFormulaCB->save_state();
     m_xNilCB->save_state();
     m_xAnnotCB->save_state();
+    m_xFormulaMarkCB->save_state();
     m_xValueCB->save_state();
     m_xAnchorCB->save_state();
     m_xClipMarkCB->save_state();
@@ -248,6 +253,7 @@ IMPL_LINK( ScTpContentOptions, CBHdl, weld::Toggleable&, 
rBtn, void )
     if (m_xFormulaCB.get() == &rBtn )   eOption = VOPT_FORMULAS;
     else if ( m_xNilCB.get() == &rBtn )   eOption = VOPT_NULLVALS;
     else if ( m_xAnnotCB.get() == &rBtn )   eOption = VOPT_NOTES;
+    else if ( m_xFormulaMarkCB.get() == &rBtn )   eOption = 
VOPT_FORMULAS_MARKS;
     else if ( m_xValueCB.get() == &rBtn )   eOption = VOPT_SYNTAX;
     else if ( m_xAnchorCB.get() == &rBtn )   eOption = VOPT_ANCHOR;
     else if ( m_xClipMarkCB.get() == &rBtn )   eOption = VOPT_CLIPMARKS;
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index a8ea046962c2..87236a3fcc4d 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -53,6 +53,7 @@ static o3tl::span<const SfxItemPropertyMapEntry> 
lcl_GetConfigPropertyMap()
     {
         { SC_UNO_SHOWZERO,     0,  cppu::UnoType<bool>::get(),              0, 
0},
         { SC_UNO_SHOWNOTES,    0,  cppu::UnoType<bool>::get(),              0, 
0},
+        { SC_UNO_SHOWFORMULASMARKS,    0,  cppu::UnoType<bool>::get(),         
     0, 0},
         { SC_UNO_SHOWGRID,     0,  cppu::UnoType<bool>::get(),              0, 
0},
         { SC_UNO_GRIDCOLOR,    0,  cppu::UnoType<sal_Int32>::get(),        0, 
0},
         { SC_UNO_SHOWPAGEBR,   0,  cppu::UnoType<bool>::get(),              0, 
0},
@@ -152,6 +153,8 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
         aViewOpt.SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( 
aValue ) );
     else if ( aPropertyName == SC_UNO_SHOWNOTES )
         aViewOpt.SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( 
aValue ) );
+    else if ( aPropertyName == SC_UNO_SHOWFORMULASMARKS )
+        aViewOpt.SetOption(VOPT_FORMULAS_MARKS, 
ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     else if ( aPropertyName == SC_UNO_SHOWGRID )
         aViewOpt.SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( 
aValue ) );
     else if ( aPropertyName == SC_UNO_GRIDCOLOR )
@@ -458,6 +461,8 @@ uno::Any SAL_CALL 
ScDocumentConfiguration::getPropertyValue( const OUString& aPr
         aRet <<= aViewOpt.GetOption( VOPT_NULLVALS );
     else if ( aPropertyName == SC_UNO_SHOWNOTES )
         aRet <<= aViewOpt.GetOption( VOPT_NOTES );
+    else if ( aPropertyName == SC_UNO_SHOWFORMULASMARKS )
+        aRet <<= aViewOpt.GetOption( VOPT_FORMULAS_MARKS );
     else if ( aPropertyName == SC_UNO_SHOWGRID )
         aRet <<= aViewOpt.GetOption( VOPT_GRID );
     else if ( aPropertyName == SC_UNO_GRIDCOLOR )
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index ba292fb15814..96b055250c72 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -101,6 +101,7 @@ static o3tl::span<const SfxItemPropertyMapEntry> 
lcl_GetViewOptPropertyMap()
         { SC_UNO_SHOWGRID,     0,  cppu::UnoType<bool>::get(),          0, 0},
         { SC_UNO_SHOWHELP,     0,  cppu::UnoType<bool>::get(),          0, 0},
         { SC_UNO_SHOWNOTES,    0,  cppu::UnoType<bool>::get(),          0, 0},
+        { SC_UNO_SHOWFORMULASMARKS,    0,  cppu::UnoType<bool>::get(),         
 0, 0},
         { SC_UNO_SHOWOBJ,      0,  cppu::UnoType<sal_Int16>::get(),    0, 0},
         { SC_UNO_SHOWPAGEBR,   0,  cppu::UnoType<bool>::get(),          0, 0},
         { SC_UNO_SHOWZERO,     0,  cppu::UnoType<bool>::get(),          0, 0},
@@ -1741,6 +1742,8 @@ void SAL_CALL ScTabViewObj::setPropertyValue(
         aNewOpt.SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( 
aValue ) );
     else if ( aPropertyName == SC_UNO_SHOWNOTES )
         aNewOpt.SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( 
aValue ) );
+    else if ( aPropertyName == SC_UNO_SHOWFORMULASMARKS )
+        aNewOpt.SetOption( VOPT_FORMULAS_MARKS, 
ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     else if ( aPropertyName == SC_UNO_SHOWPAGEBR )
         aNewOpt.SetOption( VOPT_PAGEBREAKS, 
ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     else if ( aPropertyName == SC_UNO_SHOWZERO )
@@ -1871,6 +1874,7 @@ uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const 
OUString& aPropertyName
         else if ( aPropertyName == SC_UNO_SHOWGRID )   aRet <<= 
rOpt.GetOption( VOPT_GRID );
         else if ( aPropertyName == SC_UNO_SHOWHELP )   aRet <<= 
rOpt.GetOption( VOPT_HELPLINES );
         else if ( aPropertyName == SC_UNO_SHOWNOTES )  aRet <<= 
rOpt.GetOption( VOPT_NOTES );
+        else if ( aPropertyName == SC_UNO_SHOWFORMULASMARKS )  aRet <<= 
rOpt.GetOption( VOPT_FORMULAS_MARKS );
         else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) aRet <<= 
rOpt.GetOption( VOPT_PAGEBREAKS );
         else if ( aPropertyName == SC_UNO_SHOWZERO )   aRet <<= 
rOpt.GetOption( VOPT_NULLVALS );
         else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == 
OLD_UNO_VALUEHIGH )
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index c30052237646..d3d21f049e55 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -927,6 +927,9 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const 
ScTableInfo& rTableI
     if ( rOpts.GetOption( VOPT_NOTES ) )
         aOutputData.DrawNoteMarks(*pContentDev);
 
+    if ( rOpts.GetOption( VOPT_FORMULAS_MARKS ) )
+        aOutputData.DrawFormulaMarks(*pContentDev);
+
     if ( !bLogicText )
         aOutputData.DrawStrings();     // in pixel MapMode
 
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
index ff26f2e5709f..22ee3726b124 100644
--- a/sc/source/ui/view/gridwin5.cxx
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -204,6 +204,8 @@ bool ScGridWindow::ShowNoteMarker( SCCOL nPosX, SCROW 
nPosY, bool bKeyboard )
 void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
 {
     bool bDone = false;
+    OUString aFormulaText;
+    tools::Rectangle aFormulaPixRect;
     bool bHelpEnabled = bool(rHEvt.GetMode() & ( HelpEventMode::BALLOON | 
HelpEventMode::QUICK ));
     SdrView* pDrView = mrViewData.GetScDrawView();
     bool bDrawTextEdit = false;
@@ -215,6 +217,9 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
         Point       aPosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() 
);
         SCCOL nPosX;
         SCROW nPosY;
+        ScDocument& rDoc = mrViewData.GetDocument();
+        SCTAB       nTab = mrViewData.GetTabNo();
+        const ScViewOptions& rOpts = mrViewData.GetOptions();
         mrViewData.GetPosFromPixel( aPosPixel.X(), aPosPixel.Y(), eWhich, 
nPosX, nPosY );
 
         if ( ShowNoteMarker( nPosX, nPosY, false ) )
@@ -222,6 +227,15 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
             Window::RequestHelp( rHEvt );   // turn off old Tip/Balloon
             bDone = true;
         }
+
+        if ( rOpts.GetOption( VOPT_FORMULAS_MARKS ) )
+        {
+            aFormulaText = rDoc.GetFormula( nPosX, nPosY, nTab );
+            if ( !aFormulaText.isEmpty() ) {
+                const ScPatternAttr* pPattern = rDoc.GetPattern( nPosX, nPosY, 
nTab );
+                aFormulaPixRect = mrViewData.GetEditArea( eWhich, nPosX, 
nPosY, this, pPattern, true );
+            }
+        }
     }
 
     if (!bDone && mpNoteMarker)
@@ -236,6 +250,17 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
         }
     }
 
+    if ( !aFormulaText.isEmpty() )
+    {
+        tools::Rectangle 
aScreenRect(OutputToScreenPixel(aFormulaPixRect.TopLeft()),
+                                     
OutputToScreenPixel(aFormulaPixRect.BottomRight()));
+        if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
+            Help::ShowBalloon(this, rHEvt.GetMousePosPixel(), aScreenRect, 
aFormulaText);
+        else if ( rHEvt.GetMode() & HelpEventMode::QUICK )
+            Help::ShowQuickHelp(this, aScreenRect, aFormulaText);
+        bDone = true;
+    }
+
     //  Image-Map / Text-URL
 
     if ( bHelpEnabled && !bDone && !nButtonDown )       // only without 
pressed button
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 9b7ba7ea66ed..14227020e70f 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -2454,6 +2454,78 @@ void ScOutputData::DrawNoteMarks(vcl::RenderContext& 
rRenderContext)
     }
 }
 
+void ScOutputData::DrawFormulaMarks(vcl::RenderContext& rRenderContext)
+{
+    bool bFirst = true;
+
+    tools::Long nInitPosX = nScrX;
+    if ( bLayoutRTL )
+        nInitPosX += nMirrorW - 1;              // always in pixels
+    tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+    tools::Long nPosY = nScrY;
+    for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+    {
+        RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+        if ( pThisRowInfo->bChanged )
+        {
+            tools::Long nPosX = nInitPosX;
+            for (SCCOL nX=nX1; nX<=nX2; nX++)
+            {
+                ScCellInfo* pInfo = &pThisRowInfo->cellInfo(nX);
+                if (!mpDoc->ColHidden(nX, nTab) && !mpDoc->GetFormula(nX, 
pRowInfo[nArrY].nRowNo, nTab).isEmpty()
+                    && (!pInfo->bHOverlapped && !pInfo->bVOverlapped))
+                {
+                    if (bFirst)
+                    {
+                        rRenderContext.SetLineColor(COL_WHITE);
+
+                        const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
+                        if ( mbUseStyleColor && 
rStyleSettings.GetHighContrastMode() )
+                            rRenderContext.SetFillColor( 
SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+                        else
+                            rRenderContext.SetFillColor(COL_LIGHTBLUE);
+
+                        bFirst = false;
+                    }
+
+                    tools::Long nMarkX = nPosX;
+                    tools::Long nMarkY = nPosY + pThisRowInfo->nHeight - 2;
+                    if ( pInfo->bMerged )
+                    {
+                        for (SCSIZE nNextY=nArrY+1; nNextY+1<nArrCount; 
nNextY++)
+                        {
+                            bool bVOver;
+                            if (pRowInfo[nNextY + 1].nRowNo == 
(pRowInfo[nNextY].nRowNo + 1)) {
+                                bVOver = 
pRowInfo[nNextY].cellInfo(nX).bVOverlapped;
+                            } else {
+                                bVOver = 
mpDoc->GetAttr(nX,nNextY,nTab,ATTR_MERGE_FLAG)->IsVerOverlapped();
+                            }
+                            if (!bVOver) break;
+                            nMarkY += pRowInfo[nNextY].nHeight;
+                        }
+                    }
+                    // DPI/ZOOM 100/100 => 10, 100/50 => 7, 100/150 => 13
+                    // DPI/ZOOM 150/100 => 13, 150/50 => 8.5, 150/150 => 17.5
+                    const double nSize( rRenderContext.GetDPIScaleFactor() * 
aZoomX * 6 + 4);
+                    Point aPoints[3];
+                    aPoints[0] = Point(nMarkX, nMarkY);
+                    aPoints[0].setX( bLayoutRTL ? aPoints[0].X() - nSize : 
aPoints[0].X() + nSize );
+                    aPoints[1] = Point(nMarkX, nMarkY);
+                    aPoints[2] = Point(nMarkX, nMarkY - nSize);
+                    tools::Polygon aPoly(3, aPoints);
+
+                    if ( bLayoutRTL ? ( nMarkX >= 0 ) : ( nMarkX < nScrX+nScrW 
) )
+                        rRenderContext.DrawPolygon(aPoly);
+                }
+
+                nPosX += pRowInfo[0].basicCellInfo(nX).nWidth * nLayoutSign;
+            }
+        }
+        nPosY += pThisRowInfo->nHeight;
+    }
+}
+
 void ScOutputData::AddPDFNotes()
 {
     vcl::PDFExtOutDevData* pPDFData = dynamic_cast< vcl::PDFExtOutDevData* >( 
mpDev->GetExtOutDevData() );
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 61d62a8cccd8..e236256ce35d 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -3757,6 +3757,8 @@ void ScViewData::WriteUserDataSequence(uno::Sequence 
<beans::PropertyValue>& rSe
     pSettings[SC_SHOWZERO].Value <<= maOptions.GetOption(VOPT_NULLVALS);
     pSettings[SC_SHOWNOTES].Name = SC_UNO_SHOWNOTES;
     pSettings[SC_SHOWNOTES].Value <<= maOptions.GetOption(VOPT_NOTES);
+    pSettings[SC_SHOWFORMULASMARKS].Name = SC_UNO_SHOWFORMULASMARKS;
+    pSettings[SC_SHOWFORMULASMARKS].Value <<= 
maOptions.GetOption(VOPT_FORMULAS_MARKS);
     pSettings[SC_SHOWGRID].Name = SC_UNO_SHOWGRID;
     pSettings[SC_SHOWGRID].Value <<= maOptions.GetOption(VOPT_GRID);
     pSettings[SC_GRIDCOLOR].Name = SC_UNO_GRIDCOLOR;
@@ -3901,6 +3903,8 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence 
<beans::PropertyValue>
             maOptions.SetOption(VOPT_NULLVALS, 
ScUnoHelpFunctions::GetBoolFromAny(rSetting.Value));
         else if ( sName == SC_UNO_SHOWNOTES )
             maOptions.SetOption(VOPT_NOTES, 
ScUnoHelpFunctions::GetBoolFromAny(rSetting.Value));
+        else if ( sName == SC_UNO_SHOWFORMULASMARKS )
+            maOptions.SetOption(VOPT_FORMULAS_MARKS, 
ScUnoHelpFunctions::GetBoolFromAny(rSetting.Value));
         else if ( sName == SC_UNO_SHOWGRID )
             maOptions.SetOption(VOPT_GRID, 
ScUnoHelpFunctions::GetBoolFromAny(rSetting.Value));
         else if ( sName == SC_UNO_GRIDCOLOR )
diff --git a/sc/uiconfig/scalc/ui/tpviewpage.ui 
b/sc/uiconfig/scalc/ui/tpviewpage.ui
index 6bbbe4aa756e..8198a7ed5ec4 100644
--- a/sc/uiconfig/scalc/ui/tpviewpage.ui
+++ b/sc/uiconfig/scalc/ui/tpviewpage.ui
@@ -78,6 +78,20 @@
                     <property name="top-attach">2</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkCheckButton" id="formulamark">
+                    <property name="label" translatable="yes" 
context="tpviewpage|formulamark">_Formula indicator and hint</property>
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="receives-default">False</property>
+                    <property name="use-underline">True</property>
+                    <property name="draw-indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">3</property>
+                  </packing>
+                </child>
                 <child>
                   <object class="GtkCheckButton" id="value">
                     <property name="label" translatable="yes" 
context="tpviewpage|value">Value h_ighlighting</property>
@@ -94,7 +108,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">0</property>
-                    <property name="top-attach">3</property>
+                    <property name="top-attach">4</property>
                   </packing>
                 </child>
                 <child>
@@ -113,7 +127,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">0</property>
-                    <property name="top-attach">4</property>
+                    <property name="top-attach">5</property>
                   </packing>
                 </child>
                 <child>
@@ -132,7 +146,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">0</property>
-                    <property name="top-attach">5</property>
+                    <property name="top-attach">6</property>
                   </packing>
                 </child>
                 <child>
@@ -151,7 +165,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">0</property>
-                    <property name="top-attach">6</property>
+                    <property name="top-attach">7</property>
                   </packing>
                 </child>
               </object>

Reply via email to