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@collabora.co.uk>
This commit is contained in:
Noel Grandin 2021-06-29 09:45:51 +02:00
parent 67b157e994
commit beaf6001c0
10 changed files with 39 additions and 19 deletions

View file

@ -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;
}

View file

@ -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 );

View file

@ -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: */

View file

@ -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 );

View file

@ -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;

View file

@ -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()));

View file

@ -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

View file

@ -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:

View file

@ -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:

View file

@ -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");