sc/source/filter/oox/workbookhelper.cxx | 4 + sc/source/filter/xml/xmlimprt.cxx | 73 -------------------------------- sc/source/filter/xml/xmlimprt.hxx | 1 sc/source/ui/docshell/docsh.cxx | 56 ++++++++++++++++++++++++ sc/source/ui/inc/docsh.hxx | 2 vcl/qt5/QtInstance.cxx | 5 ++ 6 files changed, 68 insertions(+), 73 deletions(-)
New commits: commit 86abb6fd8a8f680f9fc5ff1db775845c9f4e254b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Mar 13 12:27:12 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Mar 13 14:31:35 2024 +0100 tdf#159915 qt: Force Qt::HighDpiScaleFactorRoundingPolicy::Round For now, force `Qt::HighDpiScaleFactorRoundingPolicy::Round` for the HighDPI-scale factor rounding policy [1], which is the default for Qt 5, while Qt 6 defaults to `Qt::HighDpiScaleFactorRoundingPolicy::PassThrough` (see [2]), which resulted in broken rendering (e.g. "Help" -> "About" dialog not showing the whole content) when fractional display scaling like 150 % is configured in the KDE Plasma display settings (in contrast to manually setting the `QT_SCALE_FACTOR=1.5` env variable to apply scaling, which was working fine). Quoting from [3]: > The two principal options are whether fractional scale factors should be > rounded to an integer or not. Keeping the scale factor as-is will make > the user interface size match the OS setting exactly, but may cause > painting errors, for example with the Windows style. Manually setting the env variable `QT_SCALE_FACTOR_ROUNDING_POLICY="Round"` has the same effect (and can be used with LO versions not yet containing this fix). (There might be a way to adjust the way that scaling happens to make other policies work, but for now, just hard-code to the policy that is known to work.) [1] https://doc.qt.io/qt-6/qt.html#HighDpiScaleFactorRoundingPolicy-enum [2] https://doc.qt.io/qt-6/highdpi.html#environment-variable-reference [3] https://doc.qt.io/qt-6/qguiapplication.html#setHighDpiScaleFactorRoundingPolicy Change-Id: I8eb6911d4dd5faf00912b8f15a58e0bdace1995a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164768 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx index 6b3bd0cc301a..2801601115ec 100644 --- a/vcl/qt5/QtInstance.cxx +++ b/vcl/qt5/QtInstance.cxx @@ -740,6 +740,11 @@ std::unique_ptr<QApplication> QtInstance::CreateQApplication(int& nArgc, char** // for scaled icons in the native menus QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif + // force Qt::HighDpiScaleFactorRoundingPolicy::Round, which is the Qt 5 default + // policy and prevents incorrect rendering with the Qt 6 default policy + // Qt::HighDpiScaleFactorRoundingPolicy::PassThrough (tdf#159915) + QGuiApplication::setHighDpiScaleFactorRoundingPolicy( + Qt::HighDpiScaleFactorRoundingPolicy::Round); FreeableCStr session_manager; if (getenv("SESSION_MANAGER") != nullptr) commit 09d20ef6bd90d33a71b581d22d1312c5d26eb32b Author: Justin Luth <jl...@mail.com> AuthorDate: Tue Mar 12 13:16:52 2024 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Wed Mar 13 14:31:22 2024 +0100 tdf#123026: also use global config "RecalcOptimalRowHeightMode" for xlsx 24.8 commit 2d2974f22ab59ea7dab1aee778308c4f50ff5464 for tdf#124098 added a setting that prompts before recalculating optimal row height on file open. I can't think of any reason why that shouldn't apply to all formats. It defaults to "always - without asking". XLSX started optimal row height on file open for tdf#123026 with 24.2 commit d15c4caabaa21e0efe3a08ffbe145390e802bab9. So this patch just moves the code to a more accessible location, and then uses it for the XLSX case too. Change-Id: Ia0c672c3aec788857dea09ac88e4395dcf6c2242 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164721 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de> Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx index 2361122e0bfe..270e5aca1dc6 100644 --- a/sc/source/filter/oox/workbookhelper.cxx +++ b/sc/source/filter/oox/workbookhelper.cxx @@ -639,7 +639,9 @@ void WorkbookGlobals::finalize() mpDoc->EnableExecuteLink(true); // #i79826# enable updating automatic row height after loading the document mpDoc->UnlockAdjustHeight(); - mpDocShell->UpdateAllRowHeights(/*bOnlyUsedRows=*/true); + // check settings (potentially asking the user if optimal row height should be run now) + if (mpDocShell->GetRecalcRowHeightsMode()) // default is to always update + mpDocShell->UpdateAllRowHeights(/*bOnlyUsedRows=*/true); // #i76026# enable Undo after loading the document mpDoc->EnableUndo(true); diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 986aa69ebb7a..b59b644b5c4d 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -1206,76 +1206,6 @@ sal_Int32 ScXMLImport::GetRangeType(std::u16string_view sRangeType) return nRangeType; } -namespace { - -class MessageWithCheck : public weld::MessageDialogController -{ -private: - std::unique_ptr<weld::CheckButton> m_xWarningOnBox; -public: - MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OUString& rDialogId) - : MessageDialogController(pParent, rUIFile, rDialogId, "ask") - , m_xWarningOnBox(m_xBuilder->weld_check_button("ask")) - { - } - bool get_active() const { return m_xWarningOnBox->get_active(); } - void hide_ask() const { m_xWarningOnBox->set_visible(false); }; -}; - -} - -bool ScXMLImport::GetRecalcRowHeightsMode() -{ - ScRecalcOptions nRecalcMode = - static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::RecalcOptimalRowHeightMode::get()); - - bool bHardRecalc = false; - switch (nRecalcMode) - { - case RECALC_ASK: - { - if (pDoc->IsUserInteractionEnabled()) - { - // Ask if the user wants to perform full re-calculation. - MessageWithCheck aQueryBox(ScDocShell::GetActiveDialogParent(), - "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog"); - aQueryBox.set_primary_text(ScResId(STR_QUERY_OPT_ROW_HEIGHT_RECALC_ONLOAD)); - aQueryBox.set_default_response(RET_YES); - - if (officecfg::Office::Calc::Formula::Load::RecalcOptimalRowHeightMode::isReadOnly()) - aQueryBox.hide_ask(); - - bHardRecalc = aQueryBox.run() == RET_YES; - - if (aQueryBox.get_active()) - { - // Always perform selected action in the future. - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); - officecfg::Office::Calc::Formula::Load::RecalcOptimalRowHeightMode::set( - bHardRecalc ? static_cast<sal_Int32>(RECALC_ALWAYS) : static_cast<sal_Int32>(RECALC_NEVER), batch); - - ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions(); - aOpt.SetReCalcOptiRowHeights(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER); - SC_MOD()->SetFormulaOptions(aOpt); - - batch->commit(); - } - } - } - break; - case RECALC_ALWAYS: - bHardRecalc = true; - break; - case RECALC_NEVER: - bHardRecalc = false; - break; - default: - SAL_WARN("sc", "unknown optimal row height recalc option!"); - } - - return bHardRecalc; -} - void ScXMLImport::SetLabelRanges() { if (maMyLabelRanges.empty()) @@ -1495,7 +1425,8 @@ void SAL_CALL ScXMLImport::endDocument() } // There are rows with optimal height which need to be updated - if (pDoc && !maRecalcRowRanges.empty() && GetRecalcRowHeightsMode()) + if (pDoc && !maRecalcRowRanges.empty() && pDoc->GetDocumentShell() + && pDoc->GetDocumentShell()->GetRecalcRowHeightsMode()) { bool bLockHeight = pDoc->IsAdjustHeightLocked(); if (bLockHeight) diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index 546ccb97faf2..843e86536088 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -305,7 +305,6 @@ public: void SetRangeOverflowType(ErrCode nType); static sal_Int32 GetRangeType(std::u16string_view sRangeType); - bool GetRecalcRowHeightsMode(); void SetNamedRanges(); void SetSheetNamedRanges(); void SetLabelRanges(); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 5f0cf927cd1d..857313f587b9 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -505,6 +505,62 @@ public: } +bool ScDocShell::GetRecalcRowHeightsMode() +{ + const ScRecalcOptions nRecalcMode = static_cast<ScRecalcOptions>( + officecfg::Office::Calc::Formula::Load::RecalcOptimalRowHeightMode::get()); + + bool bHardRecalc = false; + switch (nRecalcMode) + { + case RECALC_ASK: + { + if (m_pDocument->IsUserInteractionEnabled()) + { + // Ask if the user wants to perform full re-calculation. + MessageWithCheck aQueryBox(ScDocShell::GetActiveDialogParent(), + "modules/scalc/ui/recalcquerydialog.ui", + "RecalcQueryDialog"); + aQueryBox.set_primary_text(ScResId(STR_QUERY_OPT_ROW_HEIGHT_RECALC_ONLOAD)); + aQueryBox.set_default_response(RET_YES); + + if (officecfg::Office::Calc::Formula::Load::RecalcOptimalRowHeightMode::isReadOnly()) + aQueryBox.hide_ask(); + + bHardRecalc = aQueryBox.run() == RET_YES; + + if (aQueryBox.get_active()) + { + // Always perform selected action in the future. + std::shared_ptr<comphelper::ConfigurationChanges> batch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Calc::Formula::Load::RecalcOptimalRowHeightMode::set( + bHardRecalc ? static_cast<sal_Int32>(RECALC_ALWAYS) + : static_cast<sal_Int32>(RECALC_NEVER), + batch); + + ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions(); + aOpt.SetReCalcOptiRowHeights(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER); + SC_MOD()->SetFormulaOptions(aOpt); + + batch->commit(); + } + } + } + break; + case RECALC_ALWAYS: + bHardRecalc = true; + break; + case RECALC_NEVER: + bHardRecalc = false; + break; + default: + SAL_WARN("sc", "unknown optimal row height recalc option!"); + } + + return bHardRecalc; +} + bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css::embed::XStorage >& xStor ) { LoadMediumGuard aLoadGuard(m_pDocument.get()); diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 2f78bd16ef18..4cc4ceacfb11 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -266,6 +266,8 @@ public: void ErrorMessage(TranslateId pGlobStrId); bool IsEditable() const; + /// check config if on file-open optimal row heights should run, or if the user should be asked + SC_DLLPUBLIC bool GetRecalcRowHeightsMode(); bool AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ); SC_DLLPUBLIC void UpdateAllRowHeights( const ScMarkData* pTabMark = nullptr ); SC_DLLPUBLIC void UpdateAllRowHeights(const bool bOnlyUsedRows);