diff options
32 files changed, 600 insertions, 89 deletions
diff --git a/Repository.mk b/Repository.mk index b3c34f891038..9eb35ca82c68 100644 --- a/Repository.mk +++ b/Repository.mk @@ -64,6 +64,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \ xrmex \ $(if $(filter-out ANDROID IOS WNT,$(OS)), \ svdemo \ + fftester \ svptest \ svpclient \ pixelctl ) \ diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx index 3a798e5a480c..6f7f78ca371f 100644 --- a/framework/source/jobs/jobexecutor.cxx +++ b/framework/source/jobs/jobexecutor.cxx @@ -40,6 +40,7 @@ #include <cppuhelper/basemutex.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/supportsservice.hxx> +#include <unotools/configmgr.hxx> #include <unotools/configpaths.hxx> #include <rtl/ref.hxx> #include <rtl/ustrbuf.hxx> @@ -139,6 +140,9 @@ JobExecutor::JobExecutor( /*IN*/ const css::uno::Reference< css::uno::XComponent void JobExecutor::initListeners() { + if (utl::ConfigManager::IsAvoidConfig()) + return; + // read the list of all currently registered events inside configuration. // e.g. "/org.openoffice.Office.Jobs/Events/<event name>" // We need it later to check if an incoming event request can be executed successfully diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index 98958e9faab0..f77141fd1e8f 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -42,6 +42,7 @@ #include <svtools/ehdl.hxx> #include <svl/svdde.hxx> +#include <unotools/configmgr.hxx> #include <unotools/tempfile.hxx> #include <osl/file.hxx> #include <com/sun/star/uno/Sequence.hxx> @@ -165,11 +166,11 @@ SfxApplication* SfxApplication::GetOrCreate() ::framework::SetActivateToolPanel( &SfxViewFrame::ActivateToolPanel ); #if HAVE_FEATURE_DESKTOP Application::SetHelp( pSfxHelp ); - if ( SvtHelpOptions().IsHelpTips() ) + if (!utl::ConfigManager::IsAvoidConfig() && SvtHelpOptions().IsHelpTips()) Help::EnableQuickHelp(); else Help::DisableQuickHelp(); - if ( SvtHelpOptions().IsHelpTips() && SvtHelpOptions().IsExtendedHelp() ) + if (!utl::ConfigManager::IsAvoidConfig() && SvtHelpOptions().IsHelpTips() && SvtHelpOptions().IsExtendedHelp()) Help::EnableBalloonHelp(); else Help::DisableBalloonHelp(); @@ -182,7 +183,8 @@ SfxApplication::SfxApplication() : pAppData_Impl( 0 ) { SetName( OUString("StarOffice") ); - SvtViewOptions::AcquireOptions(); + if (!utl::ConfigManager::IsAvoidConfig()) + SvtViewOptions::AcquireOptions(); pAppData_Impl = new SfxAppData_Impl( this ); pAppData_Impl->m_xImeStatusWindow->init(); @@ -230,7 +232,8 @@ SfxApplication::~SfxApplication() #endif // delete global options - SvtViewOptions::ReleaseOptions(); + if (!utl::ConfigManager::IsAvoidConfig()) + SvtViewOptions::ReleaseOptions(); if ( !pAppData_Impl->bDowning ) Deinitialize(); diff --git a/sfx2/source/appl/appbas.cxx b/sfx2/source/appl/appbas.cxx index becd677efcaf..df23fcd9b4a6 100644 --- a/sfx2/source/appl/appbas.cxx +++ b/sfx2/source/appl/appbas.cxx @@ -69,6 +69,7 @@ #include <sfx2/sfxhelp.hxx> #include <basic/basmgr.hxx> #include <svtools/svtools.hrc> +#include <unotools/configmgr.hxx> #include "sorgitm.hxx" #include "appbaslib.hxx" #include <basic/basicmanagerrepository.hxx> @@ -99,17 +100,19 @@ BasicManager* SfxApplication::GetBasicManager() #if !HAVE_FEATURE_SCRIPTING return 0; #else + if (utl::ConfigManager::IsAvoidConfig()) + return 0; return BasicManagerRepository::getApplicationBasicManager( true ); #endif } - - XLibraryContainer * SfxApplication::GetDialogContainer() { #if !HAVE_FEATURE_SCRIPTING return NULL; #else + if (utl::ConfigManager::IsAvoidConfig()) + return NULL; if ( !pAppData_Impl->pBasicManager->isValid() ) GetBasicManager(); return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::DIALOGS ); @@ -123,6 +126,8 @@ XLibraryContainer * SfxApplication::GetBasicContainer() #if !HAVE_FEATURE_SCRIPTING return NULL; #else + if (utl::ConfigManager::IsAvoidConfig()) + return NULL; if ( !pAppData_Impl->pBasicManager->isValid() ) GetBasicManager(); return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::SCRIPTS ); @@ -134,6 +139,8 @@ StarBASIC* SfxApplication::GetBasic() #if !HAVE_FEATURE_SCRIPTING return 0; #else + if (utl::ConfigManager::IsAvoidConfig()) + return 0; return GetBasicManager()->GetLib(0); #endif } diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx index 89e11a37bc81..0c1b6d752929 100644 --- a/sfx2/source/appl/appinit.cxx +++ b/sfx2/source/appl/appinit.cxx @@ -28,6 +28,7 @@ #include <svtools/soerr.hxx> #include <svtools/svtools.hrc> +#include <unotools/configmgr.hxx> #include <unotools/saveopt.hxx> #include <unotools/localisationoptions.hxx> #include <svl/intitem.hxx> @@ -219,9 +220,12 @@ bool SfxApplication::Initialize_Impl() Help::EnableContextHelp(); Help::EnableExtHelp(); - SvtLocalisationOptions aLocalisation; - Application::EnableAutoMnemonic ( aLocalisation.IsAutoMnemonic() ); - Application::SetDialogScaleX ( (short)(aLocalisation.GetDialogScale()) ); + if (!utl::ConfigManager::IsAvoidConfig()) + { + SvtLocalisationOptions aLocalisation; + Application::EnableAutoMnemonic ( aLocalisation.IsAutoMnemonic() ); + Application::SetDialogScaleX ( (short)(aLocalisation.GetDialogScale()) ); + } pAppData_Impl->m_pToolsErrorHdl = new SfxErrorHandler( RID_ERRHDL, ERRCODE_AREA_TOOLS, ERRCODE_AREA_LIB1); @@ -237,9 +241,13 @@ bool SfxApplication::Initialize_Impl() pAppData_Impl->m_pSbxErrorHdl = new SfxErrorHandler( RID_BASIC_START, ERRCODE_AREA_SBX, ERRCODE_AREA_SBX_END, pAppData_Impl->pBasicResMgr ); #endif - //ensure instantiation of listener that manages the internal recently-used - //list - SfxPickList::ensure(); + + if (!utl::ConfigManager::IsAvoidConfig()) + { + //ensure instantiation of listener that manages the internal recently-used + //list + SfxPickList::ensure(); + } DBG_ASSERT( !pAppData_Impl->pAppDispat, "AppDispatcher already exists" ); pAppData_Impl->pAppDispat = new SfxDispatcher(static_cast<SfxDispatcher*>(nullptr)); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 73ab864526f8..d5bc6d00611e 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -73,6 +73,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/interaction.hxx> #include <svtools/sfxecode.hxx> +#include <unotools/configmgr.hxx> #include <unotools/securityoptions.hxx> #include <cppuhelper/weak.hxx> #include <unotools/streamwrap.hxx> @@ -368,8 +369,17 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, OUString( OSL_LOG_PREFIX ) ); } - SvtSaveOptions aSaveOpt; - SvtSaveOptions::ODFDefaultVersion nDefVersion = aSaveOpt.GetODFDefaultVersion(); + SvtSaveOptions::ODFDefaultVersion nDefVersion = SvtSaveOptions::ODFVER_012; + bool bUseSHA1InODF12 = false; + bool bUseBlowfishInODF12 = false; + + if (!utl::ConfigManager::IsAvoidConfig()) + { + SvtSaveOptions aSaveOpt; + nDefVersion = aSaveOpt.GetODFDefaultVersion(); + bUseSHA1InODF12 = aSaveOpt.IsUseSHA1InODF12(); + bUseBlowfishInODF12 = aSaveOpt.IsUseBlowfishInODF12(); + } uno::Sequence< beans::NamedValue > aEncryptionAlgs( 3 ); aEncryptionAlgs[0].Name = "StartKeyGenerationAlgorithm"; @@ -391,12 +401,12 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto { } - if ( !aSaveOpt.IsUseSHA1InODF12() && nDefVersion != SvtSaveOptions::ODFVER_012_EXT_COMPAT ) + if ( !bUseSHA1InODF12 && nDefVersion != SvtSaveOptions::ODFVER_012_EXT_COMPAT ) { aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; } - if ( !aSaveOpt.IsUseBlowfishInODF12() && nDefVersion != SvtSaveOptions::ODFVER_012_EXT_COMPAT ) + if ( !bUseBlowfishInODF12 && nDefVersion != SvtSaveOptions::ODFVER_012_EXT_COMPAT ) aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; } @@ -533,7 +543,8 @@ bool SfxObjectShell::DoInitNew( SfxMedium* pMed ) aArgs[nLength].Name = "Title"; aArgs[nLength].Value <<= OUString( GetTitle( SFX_TITLE_DETECT ) ); xModel->attachResource( OUString(), aArgs ); - impl_addToModelCollection(xModel); + if (!utl::ConfigManager::IsAvoidConfig()) + impl_addToModelCollection(xModel); } SetInitialized_Impl( true ); @@ -543,8 +554,6 @@ bool SfxObjectShell::DoInitNew( SfxMedium* pMed ) return false; } - - bool SfxObjectShell::ImportFromGeneratedStream_Impl( const uno::Reference< io::XStream >& xStream, const uno::Sequence< beans::PropertyValue >& rMediaDescr ) @@ -3115,7 +3124,8 @@ uno::Reference< embed::XStorage > SfxObjectShell::GetStorage() SetupStorage( pImp->m_xDocStorage, SOFFICE_FILEFORMAT_CURRENT, false ); pImp->m_bCreateTempStor = false; - SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, GlobalEventConfig::GetEventName(GlobalEventId::STORAGECHANGED), this ) ); + if (!utl::ConfigManager::IsAvoidConfig()) + SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, GlobalEventConfig::GetEventName(GlobalEventId::STORAGECHANGED), this ) ); } catch( uno::Exception& ) { diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 0a198b61c271..335b6f8e8f46 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -45,6 +45,7 @@ #include <basic/sbstar.hxx> #include <svl/stritem.hxx> #include <basic/sbx.hxx> +#include <unotools/configmgr.hxx> #include <unotools/eventcfg.hxx> #include <sfx2/objsh.hxx> @@ -798,18 +799,21 @@ Reference< XLibraryContainer > SfxObjectShell::GetDialogContainer() Reference< XLibraryContainer > SfxObjectShell::GetBasicContainer() { #if HAVE_FEATURE_SCRIPTING - try + if (!utl::ConfigManager::IsAvoidConfig()) { - if ( !pImp->m_bNoBasicCapabilities ) - return lcl_getOrCreateLibraryContainer( true, pImp->xBasicLibraries, GetModel() ); + try + { + if ( !pImp->m_bNoBasicCapabilities ) + return lcl_getOrCreateLibraryContainer( true, pImp->xBasicLibraries, GetModel() ); - BasicManager* pBasMgr = lcl_getBasicManagerForDocument( *this ); - if ( pBasMgr ) - return pBasMgr->GetScriptLibraryContainer().get(); - } - catch (const css::ucb::ContentCreationException& e) - { - SAL_WARN("sfx.doc", "caught exception " << e.Message); + BasicManager* pBasMgr = lcl_getBasicManagerForDocument( *this ); + if ( pBasMgr ) + return pBasMgr->GetScriptLibraryContainer().get(); + } + catch (const css::ucb::ContentCreationException& e) + { + SAL_WARN("sfx.doc", "caught exception " << e.Message); + } } SAL_WARN("sfx.doc", "SfxObjectShell::GetBasicContainer: falling back to the application - is this really expected here?"); #endif @@ -1152,6 +1156,8 @@ SfxObjectShell* SfxObjectShell::GetShellFromComponent( const Reference<lang::XCo void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew ) { pImp->bInitialized = true; + if (utl::ConfigManager::IsAvoidConfig()) + return; if ( i_fromInitNew ) { SetActivateEvent_Impl( SFX_EVENT_CREATEDOC ); diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index f4d7d35595d6..b02556293b1d 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -26,6 +26,7 @@ #include <comphelper/processfactory.hxx> #include <unotools/configitem.hxx> #include <unotools/confignode.hxx> +#include <unotools/configmgr.hxx> #include <unotools/configpaths.hxx> #include <com/sun/star/uno/Sequence.h> #include <svl/poolitem.hxx> @@ -199,7 +200,9 @@ ColorConfig_Impl::ColorConfig_Impl(bool bEditMode) : uno::Sequence < OUString > aNames(1); EnableNotification( aNames ); } - Load(OUString()); + + if (!utl::ConfigManager::IsAvoidConfig()) + Load(OUString()); ImplUpdateApplicationSettings(); diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 6db4171cf202..41c4d3ea2cb2 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -187,9 +187,12 @@ protected: #define SW_STREAM_READER 1 #define SW_STORAGE_READER 2 +extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportDOC(const OUString &rUrl); + class SW_DLLPUBLIC Reader { friend class SwReader; + friend bool TestImportDOC(const OUString &rUrl); SwDoc* pTemplate; OUString aTemplateNm; diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx b/sw/source/core/doc/DocumentDrawModelManager.cxx index a5b7163eb093..91c6bf9cbf72 100644 --- a/sw/source/core/doc/DocumentDrawModelManager.cxx +++ b/sw/source/core/doc/DocumentDrawModelManager.cxx @@ -46,6 +46,7 @@ #include <svl/smplhint.hxx> #include <svl/srchitem.hxx> #include <tools/link.hxx> +#include <unotools/configmgr.hxx> class SdrOutliner; class XSpellChecker1; @@ -136,13 +137,16 @@ void DocumentDrawModelManager::InitDrawModel() SdrPage* pMasterPage = mpDrawModel->AllocPage( false ); mpDrawModel->InsertPage( pMasterPage ); SAL_INFO( "sw.doc", "after create DrawDocument" ); - SAL_INFO( "sw.doc", "before create Spellchecker/Hyphenator" ); SdrOutliner& rOutliner = mpDrawModel->GetDrawOutliner(); - ::com::sun::star::uno::Reference< com::sun::star::linguistic2::XSpellChecker1 > xSpell = ::GetSpellChecker(); - rOutliner.SetSpeller( xSpell ); - ::com::sun::star::uno::Reference< com::sun::star::linguistic2::XHyphenator > xHyphenator( ::GetHyphenator() ); - rOutliner.SetHyphenator( xHyphenator ); - SAL_INFO( "sw.doc", "after create Spellchecker/Hyphenator" ); + if (!utl::ConfigManager::IsAvoidConfig()) + { + SAL_INFO( "sw.doc", "before create Spellchecker/Hyphenator" ); + ::com::sun::star::uno::Reference< com::sun::star::linguistic2::XSpellChecker1 > xSpell = ::GetSpellChecker(); + rOutliner.SetSpeller( xSpell ); + ::com::sun::star::uno::Reference< com::sun::star::linguistic2::XHyphenator > xHyphenator( ::GetHyphenator() ); + rOutliner.SetHyphenator( xHyphenator ); + SAL_INFO( "sw.doc", "after create Spellchecker/Hyphenator" ); + } m_rDoc.SetCalcFieldValueHdl(&rOutliner); m_rDoc.SetCalcFieldValueHdl(&mpDrawModel->GetHitTestOutliner()); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index fdf39db434f0..62e18943e9e8 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -655,6 +655,7 @@ static SwTextNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString& SwNumberTree::tNumberVector aLevelVal = rNdNum.GetNumberVector(); // now compare with the one searched for bool bEqual = true; + nLevel = std::min<int>(nLevel, MAXLEVEL); for( int n = 0; n < nLevel; ++n ) { if ( aLevelVal[n] != nLevelVal[n] ) diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 80e829d6ac03..695620d2de2e 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -26,6 +26,7 @@ #include <i18nlangtag/languagetag.hxx> +#include <unotools/configmgr.hxx> #include <unotools/ucbstreamhelper.hxx> #include <rtl/random.h> #include <rtl/ustring.hxx> @@ -124,9 +125,9 @@ #endif #include <svx/hlnkitem.hxx> +#include "swdll.hxx" #include "WW8Sttbf.hxx" #include "WW8FibData.hxx" - #include <unordered_set> #include <memory> @@ -4829,6 +4830,9 @@ bool WW8Customizations::Import( SwDocShell* pShell ) bool SwWW8ImplReader::ReadGlobalTemplateSettings( const OUString& sCreatedFrom, const uno::Reference< container::XNameContainer >& xPrjNameCache ) { + if (utl::ConfigManager::IsAvoidConfig()) + return true; + SvtPathOptions aPathOpt; OUString aAddinPath = aPathOpt.GetAddinPath(); uno::Sequence< OUString > sGlobalTemplates; @@ -5141,9 +5145,12 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos) } #if HAVE_FEATURE_SCRIPTING - BasicManager *pBasicMan = m_pDocShell->GetBasicManager(); - if (pBasicMan) - pBasicMan->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); + if (!utl::ConfigManager::IsAvoidConfig()) + { + BasicManager *pBasicMan = m_pDocShell->GetBasicManager(); + if (pBasicMan) + pBasicMan->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); + } #endif BasicProjImportHelper aBasicImporter( *m_pDocShell ); // Import vba via oox filter @@ -6041,6 +6048,35 @@ extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportDOC() return new WW8Reader(); } +extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportDOC(const OUString &rURL) +{ + Reader *pReader = ImportDOC(); + + SvFileStream aFileStream(rURL, StreamMode::READ); + tools::SvRef<SotStorage> xStorage = new SotStorage(aFileStream); + + pReader->pStrm = &aFileStream; + pReader->pStg = xStorage.get(); + + SwGlobals::ensure(); + + SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL)); + xDocSh->DoInitNew(0); + SwDoc *pD = static_cast<SwDocShell*>((&xDocSh))->GetDoc(); + + SwNodeIndex aIdx( + *pD->GetNodes().GetEndOfContent().StartOfSectionNode(), 1); + if( !aIdx.GetNode().IsTextNode() ) + { + pD->GetNodes().GoNext( &aIdx ); + } + SwPaM aPaM( aIdx ); + aPaM.GetPoint()->nContent.Assign(aIdx.GetNode().GetContentNode(), 0); + bool bRet = pReader->Read(*pD, OUString(), aPaM, OUString()) == 0; + delete pReader; + return bRet; +} + sal_uLong WW8Reader::OpenMainStream( tools::SvRef<SotStorageStream>& rRef, sal_uInt16& rBuffSize ) { sal_uLong nRet = ERR_SWG_READ_ERROR; diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx index f1799c99cdb4..ffedf522e941 100644 --- a/sw/source/uibase/app/docshini.cxx +++ b/sw/source/uibase/app/docshini.cxx @@ -25,6 +25,7 @@ #include <sot/storage.hxx> #include <svl/zforlist.hxx> #include <svtools/ctrltool.hxx> +#include <unotools/configmgr.hxx> #include <unotools/lingucfg.hxx> #include <sfx2/docfile.hxx> #include <sfx2/sfxmodelfactory.hxx> @@ -117,23 +118,26 @@ bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) SwTransferable::InitOle( this, *m_pDoc ); // set forbidden characters if necessary - SvxAsianConfig aAsian; - Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales(); - if(aLocales.getLength()) + if (!utl::ConfigManager::IsAvoidConfig()) { - const lang::Locale* pLocales = aLocales.getConstArray(); - for(sal_Int32 i = 0; i < aLocales.getLength(); i++) + SvxAsianConfig aAsian; + Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales(); + if (aLocales.getLength()) { - ForbiddenCharacters aForbidden; - aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine); - LanguageType eLang = LanguageTag::convertToLanguageType(pLocales[i]); - m_pDoc->getIDocumentSettingAccess().setForbiddenCharacters( eLang, aForbidden); + const lang::Locale* pLocales = aLocales.getConstArray(); + for(sal_Int32 i = 0; i < aLocales.getLength(); i++) + { + ForbiddenCharacters aForbidden; + aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine); + LanguageType eLang = LanguageTag::convertToLanguageType(pLocales[i]); + m_pDoc->getIDocumentSettingAccess().setForbiddenCharacters( eLang, aForbidden); + } } - } - m_pDoc->getIDocumentSettingAccess().set(DocumentSettingId::KERN_ASIAN_PUNCTUATION, + m_pDoc->getIDocumentSettingAccess().set(DocumentSettingId::KERN_ASIAN_PUNCTUATION, !aAsian.IsKerningWesternTextOnly()); - m_pDoc->getIDocumentSettingAccess().setCharacterCompressionType(static_cast<SwCharCompressType>(aAsian.GetCharDistanceCompression())); - m_pDoc->getIDocumentDeviceAccess().setPrintData(*SW_MOD()->GetPrtOptions(bWeb)); + m_pDoc->getIDocumentSettingAccess().setCharacterCompressionType(static_cast<SwCharCompressType>(aAsian.GetCharDistanceCompression())); + m_pDoc->getIDocumentDeviceAccess().setPrintData(*SW_MOD()->GetPrtOptions(bWeb)); + } SubInitNew(); @@ -651,7 +655,8 @@ void SwDocShell::SubInitNew() //! get lingu options without loading lingu DLL SvtLinguOptions aLinguOpt; - SvtLinguConfig().GetOptions( aLinguOpt ); + if (!utl::ConfigManager::IsAvoidConfig()) + SvtLinguConfig().GetOptions(aLinguOpt); sal_Int16 nVal = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), diff --git a/sw/source/uibase/app/swdll.cxx b/sw/source/uibase/app/swdll.cxx index 7a12f244e286..cff230ce9313 100644 --- a/sw/source/uibase/app/swdll.cxx +++ b/sw/source/uibase/app/swdll.cxx @@ -34,6 +34,7 @@ #include <cfgid.h> #include <com/sun/star/frame/Desktop.hpp> +#include <unotools/configmgr.hxx> #include <unotools/moduleoptions.hxx> #include <comphelper/unique_disposing_ptr.hxx> #include <comphelper/processfactory.hxx> @@ -85,10 +86,12 @@ SwDLL::SwDLL() if ( *ppShlPtr ) return; - SvtModuleOptions aOpt; + std::unique_ptr<SvtModuleOptions> xOpt; + if (!utl::ConfigManager::IsAvoidConfig()) + xOpt.reset(new SvtModuleOptions); SfxObjectFactory* pDocFact = 0; SfxObjectFactory* pGlobDocFact = 0; - if ( aOpt.IsWriter() ) + if (xOpt && xOpt->IsWriter()) { pDocFact = &SwDocShell::Factory(); pGlobDocFact = &SwGlobalDocShell::Factory(); @@ -101,7 +104,7 @@ SwDLL::SwDLL() pWDocFact->SetDocumentServiceName(OUString("com.sun.star.text.WebDocument")); - if ( aOpt.IsWriter() ) + if (xOpt && xOpt->IsWriter()) { pGlobDocFact->SetDocumentServiceName(OUString("com.sun.star.text.GlobalDocument")); pDocFact->SetDocumentServiceName(OUString("com.sun.star.text.TextDocument")); @@ -138,17 +141,23 @@ SwDLL::SwDLL() RegisterControls(); #endif - // replace SvxAutocorrect with SwAutocorrect - SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get(); - const SvxAutoCorrect* pOld = rACfg.GetAutoCorrect(); - rACfg.SetAutoCorrect(new SwAutoCorrect( *pOld )); + if (!utl::ConfigManager::IsAvoidConfig()) + { + // replace SvxAutocorrect with SwAutocorrect + SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get(); + const SvxAutoCorrect* pOld = rACfg.GetAutoCorrect(); + rACfg.SetAutoCorrect(new SwAutoCorrect( *pOld )); + } } SwDLL::~SwDLL() { - // fdo#86494 SwAutoCorrect must be deleted before _FinitCore - SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get(); - rACfg.SetAutoCorrect(0); // delete SwAutoCorrect before exit handlers + if (!utl::ConfigManager::IsAvoidConfig()) + { + // fdo#86494 SwAutoCorrect must be deleted before _FinitCore + SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get(); + rACfg.SetAutoCorrect(0); // delete SwAutoCorrect before exit handlers + } // Pool has to be deleted before statics are SW_MOD()->RemoveAttrPool(); diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 3f768c344608..b43373ad9c7b 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -113,6 +113,7 @@ #include <svx/rubydialog.hxx> #include <svtools/colorcfg.hxx> +#include <unotools/configmgr.hxx> #include <unotools/moduleoptions.hxx> #include <avmedia/mediaplayer.hxx> @@ -188,10 +189,13 @@ SwModule::SwModule( SfxObjectFactory* pWebFact, StartListening( *SfxGetpApp() ); - // OD 14.02.2003 #107424# - init color configuration - // member <pColorConfig> is created and the color configuration is applied - // at the view options. - GetColorConfig(); + if (!utl::ConfigManager::IsAvoidConfig()) + { + // init color configuration + // member <pColorConfig> is created and the color configuration is applied + // at the view options. + GetColorConfig(); + } } uno::Reference< scanner::XScannerManager2 > SwModule::GetScannerManager() @@ -228,13 +232,13 @@ void SwDLL::RegisterFactories() { // These Id's must not be changed. Through these Id's the View (resume Documentview) // is created by Sfx. - if ( SvtModuleOptions().IsWriter() ) + if (!utl::ConfigManager::IsAvoidConfig() && SvtModuleOptions().IsWriter()) SwView::RegisterFactory ( 2 ); #if HAVE_FEATURE_DESKTOP SwWebView::RegisterFactory ( 5 ); - if ( SvtModuleOptions().IsWriter() ) + if (!utl::ConfigManager::IsAvoidConfig() && SvtModuleOptions().IsWriter()) { SwSrcView::RegisterFactory ( 6 ); SwPagePreview::RegisterFactory ( 7 ); diff --git a/sw/source/uibase/config/fontcfg.cxx b/sw/source/uibase/config/fontcfg.cxx index 7511424b61c5..dbf7478a74db 100644 --- a/sw/source/uibase/config/fontcfg.cxx +++ b/sw/source/uibase/config/fontcfg.cxx @@ -20,6 +20,7 @@ #include <fontcfg.hxx> #include <i18nlangtag/mslangid.hxx> #include <vcl/outdev.hxx> +#include <unotools/configmgr.hxx> #include <unotools/lingucfg.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Sequence.hxx> @@ -92,7 +93,8 @@ SwStdFontConfig::SwStdFontConfig() : { SvtLinguOptions aLinguOpt; - SvtLinguConfig().GetOptions( aLinguOpt ); + if (!utl::ConfigManager::IsAvoidConfig()) + SvtLinguConfig().GetOptions( aLinguOpt ); sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), @@ -171,7 +173,8 @@ bool SwStdFontConfig::IsFontDefault(sal_uInt16 nFontType) const bool bSame = false; SvtLinguOptions aLinguOpt; - SvtLinguConfig().GetOptions( aLinguOpt ); + if (!utl::ConfigManager::IsAvoidConfig()) + SvtLinguConfig().GetOptions(aLinguOpt); sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), @@ -284,7 +287,8 @@ void SwStdFontConfig::ChangeInt( sal_uInt16 nFontType, sal_Int32 nHeight ) if( nFontType < DEF_FONT_COUNT && nDefaultFontHeight[nFontType] != nHeight) { SvtLinguOptions aLinguOpt; - SvtLinguConfig().GetOptions( aLinguOpt ); + if (!utl::ConfigManager::IsAvoidConfig()) + SvtLinguConfig().GetOptions( aLinguOpt ); sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), diff --git a/sw/source/uibase/config/modcfg.cxx b/sw/source/uibase/config/modcfg.cxx index fcefb8ff4a76..0121f723dd62 100644 --- a/sw/source/uibase/config/modcfg.cxx +++ b/sw/source/uibase/config/modcfg.cxx @@ -31,6 +31,7 @@ #include <itabenum.hxx> #include <modcfg.hxx> #include <fldupde.hxx> +#include <unotools/configmgr.hxx> #include <unotools/syslocaleoptions.hxx> #include <caption.hxx> #include <com/sun/star/uno/Any.hxx> @@ -1084,10 +1085,13 @@ void SwInsertConfig::Load() } else if (nProp == INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST) { - //#i61007# initialize caption order, right now only HUNGARIAN seems to need a different order - SvtSysLocaleOptions aSysLocaleOptions; - OUString sLang = aSysLocaleOptions.GetLocaleConfigString(); - bCaptionOrderNumberingFirst = sLang.startsWith( "hu" ); + if (!utl::ConfigManager::IsAvoidConfig()) + { + //#i61007# initialize caption order, right now only HUNGARIAN seems to need a different order + SvtSysLocaleOptions aSysLocaleOptions; + OUString sLang = aSysLocaleOptions.GetLocaleConfigString(); + bCaptionOrderNumberingFirst = sLang.startsWith( "hu" ); + } } } diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx index 7aec700cd7be..6ac62c6fc528 100644 --- a/sw/source/uibase/config/usrpref.cxx +++ b/sw/source/uibase/config/usrpref.cxx @@ -18,6 +18,7 @@ */ #include <tools/stream.hxx> +#include <unotools/configmgr.hxx> #include <unotools/syslocale.hxx> #include "swtypes.hxx" @@ -57,6 +58,11 @@ SwMasterUsrPref::SwMasterUsrPref(bool bWeb) : pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : 0), bApplyCharUnit(false) { + if (utl::ConfigManager::IsAvoidConfig()) + { + eHScrollMetric = eVScrollMetric = eUserMetric = FUNIT_CM; + return; + } MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH; eHScrollMetric = eVScrollMetric = eUserMetric; diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx index 1a105b89db6f..9bd36e8f0ebd 100644 --- a/sw/source/uibase/config/viewopt.cxx +++ b/sw/source/uibase/config/viewopt.cxx @@ -35,6 +35,7 @@ #include <crstate.hxx> #include <svtools/colorcfg.hxx> #include <svtools/accessibilityoptions.hxx> +#include <unotools/configmgr.hxx> #include <unotools/syslocale.hxx> #include <editeng/acorrcfg.hxx> @@ -193,13 +194,13 @@ SwViewOption::SwViewOption() : VIEWOPT_2_GRFKEEPZOOM | VIEWOPT_2_ANY_RULER; - if(MEASURE_METRIC != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()) + if (!utl::ConfigManager::IsAvoidConfig() && MEASURE_METRIC != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()) aSnapSize.Width() = aSnapSize.Height() = 720; // 1/2" else aSnapSize.Width() = aSnapSize.Height() = 567; // 1 cm nDivisionX = nDivisionY = 1; - bSelectionInReadonly = SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly(); + bSelectionInReadonly = !utl::ConfigManager::IsAvoidConfig() ? SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly() : false; bIdle = true; diff --git a/unotools/source/config/eventcfg.cxx b/unotools/source/config/eventcfg.cxx index fc862ac689b1..9b13364d253c 100644 --- a/unotools/source/config/eventcfg.cxx +++ b/unotools/source/config/eventcfg.cxx @@ -387,6 +387,8 @@ Mutex& GlobalEventConfig::GetOwnStaticMutex() OUString GlobalEventConfig::GetEventName( GlobalEventId nIndex ) { + if (utl::ConfigManager::IsAvoidConfig()) + return OUString(); return GlobalEventConfig().m_pImpl->GetEventName( nIndex ); } diff --git a/vcl/Executable_fftester.mk b/vcl/Executable_fftester.mk new file mode 100644 index 000000000000..0eaa4e39c3c2 --- /dev/null +++ b/vcl/Executable_fftester.mk @@ -0,0 +1,39 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Executable_Executable,fftester)) + +$(eval $(call gb_Executable_use_api,fftester,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_Executable_use_external,fftester,boost_headers)) + +$(eval $(call gb_Executable_set_include,fftester,\ + $$(INCLUDE) \ + -I$(SRCDIR)/vcl/inc \ +)) + +$(eval $(call gb_Executable_use_libraries,fftester,\ + tl \ + sal \ + utl \ + vcl \ + cppu \ + cppuhelper \ + comphelper \ +)) + +$(eval $(call gb_Executable_add_exception_objects,fftester,\ + vcl/workben/fftester \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index 4595375ba08c..c3e84e613521 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -36,6 +36,7 @@ $(eval $(call gb_Module_add_targets,vcl,\ Executable_mtfdemo ))) \ $(if $(filter-out ANDROID IOS WNT,$(OS)), \ Executable_svdemo \ + Executable_fftester \ Executable_svptest \ Executable_svpclient) \ )) diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx index 59ed6aee9bd8..4f81f3dfaaf7 100644 --- a/vcl/generic/fontmanager/fontconfig.cxx +++ b/vcl/generic/fontmanager/fontconfig.cxx @@ -44,7 +44,8 @@ using namespace psp; #include <cstdio> #include <cstdarg> -#include "unotools/atom.hxx" +#include <unotools/atom.hxx> +#include <unotools/configmgr.hxx> #include "osl/module.h" #include "osl/thread.h" @@ -475,6 +476,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int, OS FontCfgWrapper& rWrapper = FontCfgWrapper::get(); FcFontSet* pFSet = rWrapper.getFontSet(); + const bool bMinimalFontset = utl::ConfigManager::IsAvoidConfig(); if( pFSet ) { #if OSL_DEBUG_LEVEL > 1 @@ -495,6 +497,8 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int, OS FcResult eFileRes = FcPatternGetString(pFSet->fonts[i], FC_FILE, 0, &file); FcResult eFamilyRes = rWrapper.LocalizedElementFromPattern( pFSet->fonts[i], &family, FC_FAMILY, FC_FAMILYLANG ); + if (bMinimalFontset && strncmp((char*)family, "Liberation", strlen("Liberation"))) + continue; FcResult eStyleRes = rWrapper.LocalizedElementFromPattern( pFSet->fonts[i], &style, FC_STYLE, FC_STYLELANG ); FcResult eSlantRes = FcPatternGetInteger(pFSet->fonts[i], FC_SLANT, 0, &slant); FcResult eWeightRes = FcPatternGetInteger(pFSet->fonts[i], FC_WEIGHT, 0, &weight); diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index e24b2e1e3928..4032ebb6c5c0 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -802,7 +802,7 @@ ReadState GIFReader::ReadGIF( Graphic& rGraphic ) return eReadState; } -bool ImportGIF( SvStream & rStm, Graphic& rGraphic ) +VCL_DLLPUBLIC bool ImportGIF( SvStream & rStm, Graphic& rGraphic ) { GIFReader* pGIFReader = static_cast<GIFReader*>(rGraphic.GetContext()); SvStreamEndian nOldFormat = rStm.GetEndian(); diff --git a/vcl/source/filter/igif/gifread.hxx b/vcl/source/filter/igif/gifread.hxx index 52a4f1f11a73..3f1c18c928ac 100644 --- a/vcl/source/filter/igif/gifread.hxx +++ b/vcl/source/filter/igif/gifread.hxx @@ -112,7 +112,7 @@ public: #endif // _GIFPRIVATE -bool ImportGIF( SvStream& rStream, Graphic& rGraphic ); +VCL_DLLPUBLIC bool ImportGIF( SvStream& rStream, Graphic& rGraphic ); #endif // INCLUDED_VCL_SOURCE_FILTER_IGIF_GIFREAD_HXX diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx index 770eb3f25d82..92a1b39c76b5 100644 --- a/vcl/source/filter/ixbm/xbmread.cxx +++ b/vcl/source/filter/ixbm/xbmread.cxx @@ -336,7 +336,7 @@ ReadState XBMReader::ReadXBM( Graphic& rGraphic ) return eReadState; } -bool ImportXBM( SvStream& rStm, Graphic& rGraphic ) +VCL_DLLPUBLIC bool ImportXBM( SvStream& rStm, Graphic& rGraphic ) { XBMReader* pXBMReader = static_cast<XBMReader*>( rGraphic.GetContext() ); ReadState eReadState; diff --git a/vcl/source/filter/ixbm/xbmread.hxx b/vcl/source/filter/ixbm/xbmread.hxx index 55e1a9638e8e..94ada437b1a8 100644 --- a/vcl/source/filter/ixbm/xbmread.hxx +++ b/vcl/source/filter/ixbm/xbmread.hxx @@ -67,7 +67,7 @@ public: #endif // _XBMPRIVATE -bool ImportXBM( SvStream& rStream, Graphic& rGraphic ); +VCL_DLLPUBLIC bool ImportXBM( SvStream& rStream, Graphic& rGraphic ); #endif // INCLUDED_VCL_SOURCE_FILTER_IXBM_XBMREAD_HXX diff --git a/vcl/source/filter/ixpm/xpmread.cxx b/vcl/source/filter/ixpm/xpmread.cxx index a421b754248b..9491857001ee 100644 --- a/vcl/source/filter/ixpm/xpmread.cxx +++ b/vcl/source/filter/ixpm/xpmread.cxx @@ -635,7 +635,7 @@ bool XPMReader::ImplGetString() // - ImportXPM - -bool ImportXPM( SvStream& rStm, Graphic& rGraphic ) +VCL_DLLPUBLIC bool ImportXPM( SvStream& rStm, Graphic& rGraphic ) { XPMReader* pXPMReader = static_cast<XPMReader*>(rGraphic.GetContext()); ReadState eReadState; diff --git a/vcl/source/filter/ixpm/xpmread.hxx b/vcl/source/filter/ixpm/xpmread.hxx index 14543ca7d9fd..141f4b2b23f2 100644 --- a/vcl/source/filter/ixpm/xpmread.hxx +++ b/vcl/source/filter/ixpm/xpmread.hxx @@ -103,7 +103,7 @@ public: #endif // _XPMPRIVATE -bool ImportXPM( SvStream& rStream, Graphic& rGraphic ); +VCL_DLLPUBLIC bool ImportXPM( SvStream& rStream, Graphic& rGraphic ); #endif // INCLUDED_VCL_SOURCE_FILTER_IXPM_XPMREAD_HXX diff --git a/vcl/source/filter/jpeg/jpeg.cxx b/vcl/source/filter/jpeg/jpeg.cxx index 13c855258724..467c1b89b6bb 100644 --- a/vcl/source/filter/jpeg/jpeg.cxx +++ b/vcl/source/filter/jpeg/jpeg.cxx @@ -25,7 +25,7 @@ #include <vcl/FilterConfigItem.hxx> #include <vcl/graphicfilter.hxx> -bool ImportJPEG( SvStream& rInputStream, Graphic& rGraphic, void* pCallerData, GraphicFilterImportFlags nImportFlags ) +VCL_DLLPUBLIC bool ImportJPEG( SvStream& rInputStream, Graphic& rGraphic, void* pCallerData, GraphicFilterImportFlags nImportFlags ) { ReadState eReadState; bool bReturn = true; diff --git a/vcl/source/filter/jpeg/jpeg.hxx b/vcl/source/filter/jpeg/jpeg.hxx index 99cf499fddde..9076a4f85386 100644 --- a/vcl/source/filter/jpeg/jpeg.hxx +++ b/vcl/source/filter/jpeg/jpeg.hxx @@ -27,7 +27,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> -bool ImportJPEG( SvStream& rInputStream, Graphic& rGraphic, void* pCallerData, GraphicFilterImportFlags nImportFlags ); +VCL_DLLPUBLIC bool ImportJPEG( SvStream& rInputStream, Graphic& rGraphic, void* pCallerData, GraphicFilterImportFlags nImportFlags ); bool ExportJPEG(SvStream& rOutputStream, const Graphic& rGraphic, diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx new file mode 100644 index 000000000000..03e4c9f5c178 --- /dev/null +++ b/vcl/workben/fftester.cxx @@ -0,0 +1,346 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + /* e.g. + export CC=afl-clang-fast + export CXX=afl-clang-fast++ + make + cp workdir/LinkTarget/Executable/fftester instdir/program + LD_LIBRARY_PATH=`pwd`/instdir/program SAL_USE_VCLPLUGIN=svp AFL_PERSISTENT=1 afl-fuzz -t 50 -i ~/fuzz/in.png -o ~/fuzz/out.png -d -T png -m 50000000 instdir/program/fftester @@ png + + On slower file formats like .doc you can probably drop the -t and rely on the + estimations, on faster file formats ironically not specifing a timeout will + result in a hillarious dramatic falloff in performance from thousands per second + to teens per second as tiny variations from the initial calculated + timeout will trigger a shutdown of the fftester and a restart and the + startup time is woeful (hence the AFL_PERSISTENT mode in the first place) + */ + +#include <sal/main.h> +#include <tools/extendapplicationenvironment.hxx> + +#include <cppuhelper/bootstrap.hxx> +#include <comphelper/processfactory.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <unotools/configmgr.hxx> +#include <vcl/dibtools.hxx> +#include <vcl/event.hxx> +#include <vcl/graphicfilter.hxx> +#include <vcl/pngread.hxx> +#include <vcl/svapp.hxx> +#include <vcl/wmf.hxx> +#include <vcl/wrkwin.hxx> +#include <vcl/fltcall.hxx> +#include <osl/file.hxx> +#include <signal.h> + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace cppu; + +extern bool ImportJPEG( SvStream& rInputStream, Graphic& rGraphic, void* pCallerData, GraphicFilterImportFlags nImportFlags ); +extern bool ImportGIF( SvStream & rStm, Graphic& rGraphic ); +extern bool ImportXBM( SvStream& rStream, Graphic& rGraphic ); +extern bool ImportXPM( SvStream& rStm, Graphic& rGraphic ); + +extern "C" { static void SAL_CALL thisModule() {} } + +typedef bool (*WFilterCall)(const OUString &rUrl); + +/* This constant specifies the number of inputs to process before restarting. + * This is optional, but helps limit the impact of memory leaks and similar + * hiccups. */ + +#define PERSIST_MAX 1000 +unsigned int persist_cnt; + +SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) +{ + int ret = -1; + + if (argc < 3) + { + fprintf(stderr, "Usage: fftester <filename> <wmf|jpg>\n"); + return -1; + } + + OUString in(argv[1], strlen(argv[1]), RTL_TEXTENCODING_UTF8); + OUString out; + osl::File::getFileURLFromSystemPath(in, out); + + tools::extendApplicationEnvironment(); + + Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext(); + Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY ); + if( !xServiceManager.is() ) + Application::Abort( "Failed to bootstrap" ); + comphelper::setProcessServiceFactory( xServiceManager ); + utl::ConfigManager::EnableAvoidConfig(); + InitVCL(); + +try_again: + + { + if (strcmp(argv[2], "wmf") == 0 || strcmp(argv[2], "emf") == 0) + { + GDIMetaFile aGDIMetaFile; + SvFileStream aFileStream(out, StreamMode::READ); + ret = ReadWindowMetafile(aFileStream, aGDIMetaFile); + } + else if (strcmp(argv[2], "jpg") == 0) + { + Graphic aGraphic; + SvFileStream aFileStream(out, StreamMode::READ); + ret = ImportJPEG(aFileStream, aGraphic, NULL, GraphicFilterImportFlags::NONE); + } + else if (strcmp(argv[2], "gif") == 0) + { + SvFileStream aFileStream(out, StreamMode::READ); + Graphic aGraphic; + ret = ImportGIF(aFileStream, aGraphic); + } + else if (strcmp(argv[2], "xbm") == 0) + { + Graphic aGraphic; + SvFileStream aFileStream(out, StreamMode::READ); + ret = ImportXBM(aFileStream, aGraphic); + } + else if (strcmp(argv[2], "xpm") == 0) + { + Graphic aGraphic; + SvFileStream aFileStream(out, StreamMode::READ); + ret = ImportXPM(aFileStream, aGraphic); + } + else if (strcmp(argv[2], "png") == 0) + { + SvFileStream aFileStream(out, StreamMode::READ); + vcl::PNGReader aReader(aFileStream); + aReader.Read(); + } + else if (strcmp(argv[2], "bmp") == 0) + { + Bitmap aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = ReadDIB(aTarget, aFileStream, true); + } + else if (strcmp(argv[2], "svm") == 0) + { + GDIMetaFile aGDIMetaFile; + SvFileStream aFileStream(out, StreamMode::READ); + ReadGDIMetaFile(aFileStream, aGDIMetaFile); + } + else if (strcmp(argv[2], "pcd") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libicdlo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "dxf") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libidxlo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "met") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libimelo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if ((strcmp(argv[2], "pbm") == 0) || strcmp(argv[2], "ppm") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libipblo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "psd") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libipdlo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "eps") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libipslo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "pct") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libiptlo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "pcx") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libipxlo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "ras") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libiralo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "tga") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libitglo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "tif") == 0) + { + static PFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libitilo.so"); + pfnImport = reinterpret_cast<PFilterCall>( + aLibrary.getFunctionSymbol("GraphicImport")); + aLibrary.release(); + } + Graphic aTarget; + SvFileStream aFileStream(out, StreamMode::READ); + ret = (*pfnImport)(aFileStream, aTarget, NULL); + } + else if (strcmp(argv[2], "doc") == 0) + { + static WFilterCall pfnImport(0); + if (!pfnImport) + { + osl::Module aLibrary; + aLibrary.loadRelative(&thisModule, "libmswordlo.so", SAL_LOADMODULE_LAZY); + pfnImport = reinterpret_cast<WFilterCall>( + aLibrary.getFunctionSymbol("TestImportDOC")); + aLibrary.release(); + } + ret = (*pfnImport)(out); + } + } + + /* To signal successful completion of a run, we need to deliver + SIGSTOP to our own process, then loop to the very beginning + once we're resumed by the supervisor process. We do this only + if AFL_PERSISTENT is set to retain normal behavior when the + program is executed directly; and take note of PERSIST_MAX. */ + if (getenv("AFL_PERSISTENT") && persist_cnt++ < PERSIST_MAX) + { + raise(SIGSTOP); + goto try_again; + } + + /* If AFL_PERSISTENT not set or PERSIST_MAX exceeded, exit normally. */ + + _exit(ret); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |