[Libreoffice-commits] core.git: chart2/source include/unotools sd/source sfx2/source svx/source sw/source unotools/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jun 29 16:47:51 UTC 2021
chart2/source/tools/AxisHelper.cxx | 2 +-
chart2/source/tools/DiagramHelper.cxx | 2 +-
include/unotools/saveopt.hxx | 6 ++++++
sd/source/ui/annotations/annotationmanager.cxx | 2 +-
sfx2/source/dialog/filedlghelper.cxx | 2 +-
sfx2/source/doc/objserv.cxx | 6 ++----
sfx2/source/doc/objstor.cxx | 9 +++------
svx/source/xml/xmlgrhlp.cxx | 7 +++++--
sw/source/core/doc/number.cxx | 3 +--
unotools/source/config/saveopt.cxx | 19 ++++++++++++++++++-
10 files changed, 39 insertions(+), 19 deletions(-)
New commits:
commit beaf6001c0d020f525bb99dae4a0f6cdd16b4c99
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Jun 29 09:45:51 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jun 29 18:47:18 2021 +0200
constructing SaveOptions just to read default version
can be a little expensive sometimes, since it loads a bunch of other
stuff at the same time.
So create a custom method that just loads the version
Change-Id: Ic480d95c4d64c68e57faf1b52f1d102141b7e246
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118047
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index aefa18b248b2..563f734142b1 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -1148,7 +1148,7 @@ Reference< XChartType > AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisInd
bool AxisHelper::isAxisPositioningEnabled()
{
- const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(SvtSaveOptions().GetODFSaneDefaultVersion());
+ const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(GetODFSaneDefaultVersion());
return nCurrentVersion >= SvtSaveOptions::ODFSVER_012;
}
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 5805f929aebb..80a75f333d28 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -1660,7 +1660,7 @@ bool DiagramHelper::switchDiagramPositioningToExcludingPositioning(
ChartModel& rModel, bool bResetModifiedState, bool bConvertAlsoFromAutoPositioning )
{
//return true if something was changed
- const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion());
+ const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(GetODFSaneDefaultVersion());
if (SvtSaveOptions::ODFSVER_012 < nCurrentODFVersion)
{
uno::Reference< css::chart::XDiagramPositioning > xDiagramPositioning( rModel.getFirstDiagram(), uno::UNO_QUERY );
diff --git a/include/unotools/saveopt.hxx b/include/unotools/saveopt.hxx
index d1e8f32af12b..0e16b683e914 100644
--- a/include/unotools/saveopt.hxx
+++ b/include/unotools/saveopt.hxx
@@ -141,8 +141,14 @@ public:
ODFSaneDefaultVersion GetODFSaneDefaultVersion() const;
bool IsReadOnly( EOption eOption ) const;
+
+ /** gets a sane default from the currently configured default */
+ static ODFSaneDefaultVersion GetODFSaneDefaultVersion(ODFDefaultVersion eDefaultVersion);
};
+/** lighter-weight version of the same method in SvtSaveOptions */
+UNOTOOLS_DLLPUBLIC SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion();
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 95e7bfb4b901..6da902023f3c 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -703,7 +703,7 @@ void AnnotationManagerImpl::GetAnnotationState(SfxItemSet& rSet)
const bool bReadOnly = mrBase.GetDocShell()->IsReadOnly();
const bool bWrongPageKind = (pCurrentPage == nullptr) || (pCurrentPage->GetPageKind() != PageKind::Standard);
- const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFSaneDefaultVersion() );
+ const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( GetODFSaneDefaultVersion() );
if (bReadOnly || bWrongPageKind || (nCurrentODFVersion <= SvtSaveOptions::ODFSVER_012))
rSet.DisableItem( SID_INSERT_POSTIT );
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index b9750c142967..939863816142 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2699,7 +2699,7 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter,
OString const utf8Pwd(OUStringToOString(pPasswordRequest->getPassword(), RTL_TEXTENCODING_UTF8));
OString const utf8Ptm(OUStringToOString(pPasswordRequest->getPasswordToModify(), RTL_TEXTENCODING_UTF8));
if (!(52 <= utf8Pwd.getLength() && utf8Pwd.getLength() <= 55
- && SvtSaveOptions().GetODFSaneDefaultVersion() < SvtSaveOptions::ODFSVER_012)
+ && GetODFSaneDefaultVersion() < SvtSaveOptions::ODFSVER_012)
&& (52 > utf8Ptm.getLength() || utf8Ptm.getLength() > 55))
{
break;
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 4d8b13e324ef..cdbb281916a7 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1770,8 +1770,7 @@ bool SfxObjectShell::PrepareForSigning(weld::Window* pDialogParent)
bool bHasSign = ( pImpl->nScriptingSignatureState != SignatureState::NOSIGNATURES || pImpl->nDocumentSignatureState != SignatureState::NOSIGNATURES );
// the target ODF version on saving (only valid when signing ODF of course)
- SvtSaveOptions aSaveOpt;
- SvtSaveOptions::ODFSaneDefaultVersion nVersion = aSaveOpt.GetODFSaneDefaultVersion();
+ SvtSaveOptions::ODFSaneDefaultVersion nVersion = GetODFSaneDefaultVersion();
// the document is not new and is not modified
OUString aODFVersion(comphelper::OStorageHelper::GetODFVersionFromStorage(GetStorage()));
@@ -1952,8 +1951,7 @@ bool SfxObjectShell::SignDocumentContentUsingCertificate(const Reference<XCertif
bool bHasSign = ( pImpl->nScriptingSignatureState != SignatureState::NOSIGNATURES || pImpl->nDocumentSignatureState != SignatureState::NOSIGNATURES );
// the target ODF version on saving (only valid when signing ODF of course)
- SvtSaveOptions aSaveOpt;
- SvtSaveOptions::ODFSaneDefaultVersion nVersion = aSaveOpt.GetODFSaneDefaultVersion();
+ SvtSaveOptions::ODFSaneDefaultVersion nVersion = GetODFSaneDefaultVersion();
// the document is not new and is not modified
OUString aODFVersion(comphelper::OStorageHelper::GetODFVersionFromStorage(GetStorage()));
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index d30e52f25c03..4e3a66e51e20 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -319,8 +319,7 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto
SvtSaveOptions::ODFSaneDefaultVersion nDefVersion = SvtSaveOptions::ODFSVER_013;
if (!utl::ConfigManager::IsFuzzing())
{
- SvtSaveOptions aSaveOpt;
- nDefVersion = aSaveOpt.GetODFSaneDefaultVersion();
+ nDefVersion = GetODFSaneDefaultVersion();
}
// the default values, that should be used for ODF1.1 and older formats
@@ -977,8 +976,7 @@ bool SfxObjectShell::DoSave()
SvtSaveOptions::ODFSaneDefaultVersion nDefVersion = SvtSaveOptions::ODFSVER_013;
if (!utl::ConfigManager::IsFuzzing())
{
- SvtSaveOptions aSaveOpt;
- nDefVersion = aSaveOpt.GetODFSaneDefaultVersion();
+ nDefVersion = GetODFSaneDefaultVersion();
}
uno::Reference<beans::XPropertySet> const xProps(GetMedium()->GetStorage(), uno::UNO_QUERY);
assert(xProps.is());
@@ -1187,8 +1185,7 @@ bool SfxObjectShell::SaveTo_Impl
if ( bTryToPreserveScriptSignature )
{
// check that the storage format stays the same
- SvtSaveOptions aSaveOpt;
- SvtSaveOptions::ODFSaneDefaultVersion nVersion = aSaveOpt.GetODFSaneDefaultVersion();
+ SvtSaveOptions::ODFSaneDefaultVersion nVersion = GetODFSaneDefaultVersion();
OUString aODFVersion;
try
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 3a9279a96dcf..bdb453579224 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -653,13 +653,15 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
case GfxLinkType::NativeMet: aExtension = ".met"; break;
case GfxLinkType::NativePct: aExtension = ".pct"; break;
case GfxLinkType::NativeSvg:
+ {
// backward-compat kludge: since no released OOo
// version to date can handle svg properly, wrap it up
// into an svm. slight catch22 here, since strict ODF
// conformance _recommends_ svg - then again, most old
// ODF consumers are believed to be OOo
- if (SvtSaveOptions().GetODFSaneDefaultVersion() < SvtSaveOptions::ODFSVER_012
- || SvtSaveOptions().GetODFSaneDefaultVersion() == SvtSaveOptions::ODFSVER_012_EXT_COMPAT)
+ auto nSaneVersion = GetODFSaneDefaultVersion();
+ if ( nSaneVersion < SvtSaveOptions::ODFSVER_012
+ || nSaneVersion == SvtSaveOptions::ODFSVER_012_EXT_COMPAT)
{
bUseGfxLink = false;
aExtension = ".svm";
@@ -669,6 +671,7 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
aExtension = ".svg";
}
break;
+ }
case GfxLinkType::NativePdf: aExtension = ".pdf"; break;
default:
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 4522613f525c..9bd2f27283b9 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -1507,8 +1507,7 @@ namespace numfunc
return SvxNumberFormat::LABEL_ALIGNMENT;
SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode;
- SvtSaveOptions aSaveOptions;
- switch (aSaveOptions.GetODFSaneDefaultVersion())
+ switch (GetODFSaneDefaultVersion())
{
case SvtSaveOptions::ODFSVER_010:
case SvtSaveOptions::ODFSVER_011:
diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx
index 1fad334ddbca..58040c2eafae 100644
--- a/unotools/source/config/saveopt.cxx
+++ b/unotools/source/config/saveopt.cxx
@@ -31,6 +31,7 @@
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
#include <officecfg/Office/Recovery.hxx>
+#include <officecfg/Office/Common.hxx>
using namespace utl;
using namespace com::sun::star::uno;
@@ -937,9 +938,25 @@ SvtSaveOptions::ODFDefaultVersion SvtSaveOptions::GetODFDefaultVersion() const
return (nRet == ODFVER_UNKNOWN) ? ODFVER_LATEST : nRet;
}
+SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion()
+{
+ sal_Int16 nTmp = officecfg::Office::Common::Save::ODF::DefaultVersion::get();
+ SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion;
+ if( nTmp == 3 )
+ eODFDefaultVersion = SvtSaveOptions::ODFVER_LATEST;
+ else
+ eODFDefaultVersion = SvtSaveOptions::ODFDefaultVersion( nTmp );
+ return SvtSaveOptions::GetODFSaneDefaultVersion(eODFDefaultVersion);
+}
+
SvtSaveOptions::ODFSaneDefaultVersion SvtSaveOptions::GetODFSaneDefaultVersion() const
{
- switch (pImp->pSaveOpt->GetODFDefaultVersion())
+ return GetODFSaneDefaultVersion(pImp->pSaveOpt->GetODFDefaultVersion());
+}
+
+SvtSaveOptions::ODFSaneDefaultVersion SvtSaveOptions::GetODFSaneDefaultVersion(ODFDefaultVersion eODFDefaultVersion)
+{
+ switch (eODFDefaultVersion)
{
default:
assert(!"map new ODFDefaultVersion to ODFSaneDefaultVersion");
More information about the Libreoffice-commits
mailing list