sc/inc/strings.hrc | 4 ++++ sc/source/core/data/documen2.cxx | 12 ++++++++++++ sc/source/ui/docshell/docsh.cxx | 18 ++++++++++++++++-- sc/source/ui/inc/docsh.hxx | 6 ++++++ 4 files changed, 38 insertions(+), 2 deletions(-)
New commits: commit 6727fd079a6cb1a7ca6b4521e57357e6ec496fe1 Author: Mike Kaganski <[email protected]> AuthorDate: Wed Nov 5 21:39:36 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Nov 8 19:58:20 2025 +0100 tdf#169253: show infobar when changes are tracked in Calc There are several differences in Calc compared to Writer with regards to change tracking. First, there is no Track Changes toolbar there. Second, it's impossible to have changes without tracking. And third, it has more detailed control over which changes are shown, e.g. by date, author, etc., which makes it possible to have the changes "shown", and still have all existing changes hidden. Because of the last detail, I decided to show the infobar regardless of the "show" flag. The HiddenTrackChanges registry configuration allows to disable it, if needed. Change-Id: I3dcfeb68d13791e383665b5b769a1375ba3386f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193624 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc index 50549907ade0..c824785a830d 100644 --- a/sc/inc/strings.hrc +++ b/sc/inc/strings.hrc @@ -448,6 +448,10 @@ #define STR_CONTENT_WITH_UNKNOWN_ENCRYPTION NC_("STR_CONTENT_WITH_UNKNOWN_ENCRYPTION", "Document contains DRM content that is encrypted with an unknown encryption method. Only the un-encrypted content will be shown.") +#define STR_TRACK_CHANGES_INFOBAR_TITLE NC_("STR_TRACK_CHANGES_INFOBAR_TITLE", "Track Changes") +#define STR_DOCUMENT_HAS_CHANGES NC_("STR_DOCUMENT_HAS_CHANGES", "Document contains tracked changes and recording is enabled.") +#define STR_DOCUMENT_TRACKS_CHANGES NC_("STR_DOCUMENT_TRACKS_CHANGES", "Recording of changes is enabled.") + #define STR_AUTOCALC_OFF NC_("STR_AUTOCALC_OFF", "AutoCalculate: Off Click to enable.") /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index dba7aaa821a7..903800e29f47 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -24,6 +24,7 @@ #include <osl/thread.h> #include <svx/xtable.hxx> #include <sfx2/bindings.hxx> +#include <sfx2/infobar.hxx> #include <sfx2/objsh.hxx> #include <sfx2/docfile.hxx> #include <sfx2/printer.hxx> @@ -39,6 +40,8 @@ #include <comphelper/configuration.hxx> #include <scmod.hxx> +#include <scresid.hxx> +#include <strings.hrc> #include <document.hxx> #include <table.hxx> #include <patattr.hxx> @@ -314,6 +317,15 @@ void ScDocument::SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack ) return ; EndChangeTracking(); pChangeTrack = std::move(pTrack); + + if (bLoadingMedium && mpShell) + { + mpShell->AddDelayedInfobarEntry( + "hiddentrackchanges", ScResId(STR_TRACK_CHANGES_INFOBAR_TITLE), + ScResId(pChangeTrack->GetActionMax() > 0 ? STR_DOCUMENT_HAS_CHANGES + : STR_DOCUMENT_TRACKS_CHANGES), + InfobarType::INFO, true); + } } IMPL_LINK_NOARG(ScDocument, TrackTimeHdl, Timer *, void) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index caaed30794b3..8af4475f5151 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -563,6 +563,13 @@ bool ScDocShell::GetRecalcRowHeightsMode() return bHardRecalc; } +bool ScDocShell::ImportFrom(SfxMedium& rMedium, + const css::uno::Reference<css::text::XTextRange>& xInsertPosition) +{ + LoadMediumGuard aLoadGuard(m_pDocument.get()); + return SfxObjectShell::ImportFrom(rMedium, xInsertPosition); +} + bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css::embed::XStorage >& xStor ) { LoadMediumGuard aLoadGuard(m_pDocument.get()); @@ -1239,6 +1246,14 @@ static void lcl_parseHtmlFilterOption(const OUString& rOption, LanguageType& rLa rScientificConvert = static_cast<bool>(aTokens[2].toInt32()); } +void ScDocShell::AddDelayedInfobarEntry(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType aInfobarType, + bool bShowCloseButton) +{ + m_pImpl->mpDelayedInfobarEntry.push_back( + { sId, sPrimaryMessage, sSecondaryMessage, aInfobarType, bShowCloseButton }); +} + bool ScDocShell::ConvertFrom( SfxMedium& rMedium ) { LoadMediumGuard aLoadGuard(m_pDocument.get()); @@ -1334,8 +1349,7 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium ) if (eError == SCWARN_IMPORT_UNKNOWN_ENCRYPTION) { - - m_pImpl->mpDelayedInfobarEntry.push_back({ u"UnknownEncryption"_ustr, ScResId(STR_CONTENT_WITH_UNKNOWN_ENCRYPTION), u""_ustr, InfobarType::INFO, true }); + AddDelayedInfobarEntry(u"UnknownEncryption"_ustr, ScResId(STR_CONTENT_WITH_UNKNOWN_ENCRYPTION), u""_ustr, InfobarType::INFO, true); eError = ERRCODE_NONE; } diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 01bfcefa4514..88174b4312ef 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -128,6 +128,8 @@ class SAL_DLLPUBLIC_RTTI ScDocShell final: public SfxObjectShell, public SfxList ScDocShell & mrDocShell; }; + bool ImportFrom(SfxMedium&, const css::uno::Reference<css::text::XTextRange>&) override; + bool LoadXML( SfxMedium* pMedium, const css::uno::Reference< css::embed::XStorage >& ); bool SaveXML( SfxMedium* pMedium, const css::uno::Reference< css::embed::XStorage >& ); SCTAB GetSaveTab(); @@ -436,6 +438,10 @@ public: ScModelObj* GetModel() const { return static_cast<ScModelObj*>(SfxObjectShell::GetModel().get()); } + void AddDelayedInfobarEntry(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType aInfobarType, + bool bShowCloseButton); + private: void ExecuteChartSource(SfxRequest& rReq); void ExecuteChartSourcePost( bool bUndo, bool bMultiRange,
