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& 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 ReferencenScriptingSignatureState != 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 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 #include #include +#include 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");