diff options
author | Mikhail Voytenko <mav@openoffice.org> | 2011-01-06 14:57:12 +0100 |
---|---|---|
committer | Mikhail Voytenko <mav@openoffice.org> | 2011-01-06 14:57:12 +0100 |
commit | 8ff51afa0dcd4e5e644e923131ee72435c80b57b (patch) | |
tree | d63f6b6e298485b5f29f60c7af25baca46f59375 /desktop/source | |
parent | fa1f3c352c6126b24ab5af87ea4ebea742c546c2 (diff) | |
parent | 794c821e4d48c34aa376cdc7b6ab2cb029d9574d (diff) |
removetooltypes01: rebase to DEV300_m96
Diffstat (limited to 'desktop/source')
23 files changed, 1580 insertions, 962 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index d80aa37fdece..a49cabc90bed 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -121,6 +121,7 @@ #include <osl/module.h> #include <osl/file.hxx> #include <osl/signal.h> +#include <osl/thread.hxx> #include <rtl/uuid.h> #include <rtl/uri.hxx> #include <unotools/pathoptions.hxx> @@ -347,10 +348,8 @@ CommandLineArgs* Desktop::GetCommandLineArgs() { ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); if ( !pArgs ) - { pArgs = new CommandLineArgs; } - } return pArgs; } @@ -1552,7 +1551,7 @@ void Desktop::Main() Reference< ::com::sun::star::task::XRestartManager > xRestartManager; sal_Bool bRestartRequested( sal_False ); sal_Bool bUseSystemFileDialog(sal_True); - int nAcquireCount( 0 ); + int nAcquireCount( 0 ); Reference < css::document::XEventListener > xGlobalBroadcaster; try { @@ -1619,25 +1618,6 @@ void Desktop::Main() } String aTitle = pLabelResMgr ? String( ResId( RID_APPTITLE, *pLabelResMgr ) ) : String(); delete pLabelResMgr; -/* - // locale and UI locale in AppSettings are now retrieved from configuration or system directly via SvtSysLocale - // no reason to set while starting - // set UI language and locale - RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ set locale settings" ); - //LanguageSelection langselect; - OUString aUILocaleString = LanguageSelection::getLanguageString(); - Locale aUILocale = LanguageSelection::IsoStringToLocale(aUILocaleString); - LanguageType eLanguage = SvtSysLocale().GetLanguage(); - - // #i39040#, do not call anything between GetSettings and SetSettings that might have - // a side effect on the settings (like, eg, SvtSysLocaleOptions().GetLocaleLanguageType(), - // which changes the MiscSettings !!! ) - AllSettings aSettings( Application::GetSettings() ); - aSettings.SetUILocale( aUILocale ); - aSettings.SetLanguage( eLanguage ); - Application::SetSettings( aSettings ); - RTL_LOGFILE_CONTEXT_TRACE( aLog, "} set locale settings" ); -*/ // Check for StarOffice/Suite specific extensions runs also with OpenOffice installation sets OUString aTitleString( aTitle ); @@ -1657,12 +1637,9 @@ void Desktop::Main() #endif SetDisplayName( aTitle ); -// SetSplashScreenProgress(30); RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create SvtPathOptions and SvtLanguageOptions" ); pPathOptions.reset( new SvtPathOptions); -// SetSplashScreenProgress(40); -// pLanguageOptions = new SvtLanguageOptions(sal_True); -// SetSplashScreenProgress(45); + SetSplashScreenProgress(40); RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create SvtPathOptions and SvtLanguageOptions" ); // Check special env variable #111015# @@ -1744,6 +1721,7 @@ void Desktop::Main() } SetSplashScreenProgress(50); + // Backing Component sal_Bool bCrashed = sal_False; sal_Bool bExistsRecoveryData = sal_False; @@ -1773,43 +1751,37 @@ void Desktop::Main() if ( !bRestartRequested ) { - if ( - (pCmdLineArgs->IsEmptyOrAcceptOnly() ) && + if ((!pCmdLineArgs->WantsToLoadDocument() ) && (SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SSTARTMODULE)) && (!bExistsRecoveryData ) && (!bExistsSessionData ) && - (!Application::AnyInput( INPUT_APPEVENT ) ) - ) + (!Application::AnyInput( INPUT_APPEVENT ) )) { - RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create BackingComponent" ); - Reference< XFrame > xDesktopFrame( xSMgr->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY ); - if (xDesktopFrame.is()) - { - // SetSplashScreenProgress(60); - Reference< XFrame > xBackingFrame; - Reference< ::com::sun::star::awt::XWindow > xContainerWindow; - - xBackingFrame = xDesktopFrame->findFrame(OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" )), 0); - if (xBackingFrame.is()) - xContainerWindow = xBackingFrame->getContainerWindow(); - if (xContainerWindow.is()) - { - // set the WB_EXT_DOCUMENT style. Normally, this is done by the TaskCreator service when a "_blank" - // frame/window is created. Since we do not use the TaskCreator here, we need to mimic its behavior, - // otherwise documents loaded into this frame will later on miss functionality depending on the style. - Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); - OSL_ENSURE( pContainerWindow, "Desktop::Main: no implementation access to the frame's container window!" ); - pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT ); - - SetSplashScreenProgress(75); - Sequence< Any > lArgs(1); - lArgs[0] <<= xContainerWindow; - - Reference< XController > xBackingComp( - xSMgr->createInstanceWithArguments(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule") ), lArgs), - UNO_QUERY); - // SetSplashScreenProgress(80); + RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create BackingComponent" ); + Reference< XFrame > xDesktopFrame( xSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY ); + if (xDesktopFrame.is()) + { + Reference< XFrame > xBackingFrame; + Reference< ::com::sun::star::awt::XWindow > xContainerWindow; + + xBackingFrame = xDesktopFrame->findFrame(OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" )), 0); + if (xBackingFrame.is()) + xContainerWindow = xBackingFrame->getContainerWindow(); + if (xContainerWindow.is()) + { + // set the WB_EXT_DOCUMENT style. Normally, this is done by the TaskCreator service when a "_blank" + // frame/window is created. Since we do not use the TaskCreator here, we need to mimic its behavior, + // otherwise documents loaded into this frame will later on miss functionality depending on the style. + Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); + OSL_ENSURE( pContainerWindow, "Desktop::Main: no implementation access to the frame's container window!" ); + pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT ); + + SetSplashScreenProgress(75); + Sequence< Any > lArgs(1); + lArgs[0] <<= xContainerWindow; + + Reference< XController > xBackingComp( + xSMgr->createInstanceWithArguments(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule") ), lArgs), UNO_QUERY); if (xBackingComp.is()) { Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY); @@ -1840,16 +1812,6 @@ void Desktop::Main() FatalError( MakeStartupErrorMessage(e.Message) ); return; } - /* - catch ( ... ) - { - FatalError( MakeStartupErrorMessage( - OUString::createFromAscii( - "Unknown error during startup (Office wrapper service).\nInstallation could be damaged."))); - return; - } - */ -// SetSplashScreenProgress(55); SvtFontSubstConfig().Apply(); @@ -1858,7 +1820,6 @@ void Desktop::Main() aAppearanceCfg.SetApplicationDefaults( this ); SvtAccessibilityOptions aOptions; aOptions.SetVCLSettings(); -// SetSplashScreenProgress(60); if ( !bRestartRequested ) { @@ -1892,15 +1853,6 @@ void Desktop::Main() FatalError( MakeStartupErrorMessage(e.Message) ); return; } - /* - catch ( ... ) - { - FatalError( MakeStartupErrorMessage( - OUString::createFromAscii( - "Unknown error during startup (TD/Desktop service).\nInstallation could be damaged."))); - return; - } - */ // Post user event to startup first application component window // We have to send this OpenClients message short before execute() to @@ -2219,12 +2171,7 @@ IMPL_LINK( Desktop, OpenClients_Impl, void*, EMPTYARG ) // CloseStartupScreen(); CloseSplashScreen(); - CheckFirstRun( ); - - // allow ipc interaction -// OfficeIPCThread::SetReady(); - EnableOleAutomation(); if (getenv ("OOO_EXIT_POST_STARTUP")) @@ -2721,16 +2668,6 @@ void Desktop::OpenClients() if ( ! bAllowRecoveryAndSessionManagement ) { - /* - ::comphelper::ConfigurationHelper::writeDirectKey( - ::comphelper::getProcessServiceFactory(), - ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery"), - ::rtl::OUString::createFromAscii("AutoSave"), - ::rtl::OUString::createFromAscii("Enabled"), - ::com::sun::star::uno::makeAny(sal_False), - ::comphelper::ConfigurationHelper::E_STANDARD); - - */ try { Reference< XDispatch > xRecovery( diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 0625191ee2ea..14b4fd1d6ddc 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -142,15 +142,16 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) UNO_QUERY); // parse command line arguments - sal_Bool bPrintEvent = sal_False; - sal_Bool bOpenEvent = sal_True; - sal_Bool bViewEvent = sal_False; - sal_Bool bStartEvent = sal_False; - sal_Bool bPrintToEvent = sal_False; - sal_Bool bPrinterName = sal_False; - sal_Bool bForceOpenEvent = sal_False; - sal_Bool bForceNewEvent = sal_False; - sal_Bool bDisplaySpec = sal_False; + bool bOpenEvent(true); + bool bPrintEvent(false); + bool bViewEvent(false); + bool bStartEvent(false); + bool bPrintToEvent(false); + bool bPrinterName(false); + bool bForceOpenEvent(false); + bool bForceNewEvent(false); + bool bDisplaySpec(false); + bool bOpenDoc(false); m_eArgumentCount = NONE; @@ -169,8 +170,8 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) if (tmp.getLength() > 0) aArg = tmp; } - String aArgStr = aArg; + String aArgStr = aArg; if ( aArg.getLength() > 0 ) { m_eArgumentCount = m_eArgumentCount == NONE ? ONE : MANY; @@ -182,98 +183,98 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) if ( aArgStr.EqualsIgnoreCaseAscii( "-n" )) { // force new documents based on the following documents - bForceNewEvent = sal_True; - bOpenEvent = sal_False; - bForceOpenEvent = sal_False; - bPrintToEvent = sal_False; - bPrintEvent = sal_False; - bViewEvent = sal_False; - bStartEvent = sal_False; - bDisplaySpec = sal_False; - } + bForceNewEvent = true; + bOpenEvent = false; + bForceOpenEvent = false; + bPrintToEvent = false; + bPrintEvent = false; + bViewEvent = false; + bStartEvent = false; + bDisplaySpec = false; + } else if ( aArgStr.EqualsIgnoreCaseAscii( "-o" )) { - // force open documents regards if they are templates or not - bForceOpenEvent = sal_True; - bOpenEvent = sal_False; - bForceNewEvent = sal_False; - bPrintToEvent = sal_False; - bPrintEvent = sal_False; - bViewEvent = sal_False; - bStartEvent = sal_False; - bDisplaySpec = sal_False; - } + // force open documents regardless if they are templates or not + bForceOpenEvent = true; + bOpenEvent = false; + bForceNewEvent = false; + bPrintToEvent = false; + bPrintEvent = false; + bViewEvent = false; + bStartEvent = false; + bDisplaySpec = false; + } else if ( aArgStr.EqualsIgnoreCaseAscii( "-pt" )) { // Print to special printer - bPrintToEvent = sal_True; - bPrinterName = sal_True; - bPrintEvent = sal_False; - bOpenEvent = sal_False; - bForceNewEvent = sal_False; - bViewEvent = sal_False; - bStartEvent = sal_False; - bDisplaySpec = sal_False; - bForceOpenEvent = sal_False; - } - else if ( aArgStr.EqualsIgnoreCaseAscii( "-p" )) - { + bPrintToEvent = true; + bPrinterName = true; + bPrintEvent = false; + bOpenEvent = false; + bForceNewEvent = false; + bViewEvent = false; + bStartEvent = false; + bDisplaySpec = false; + bForceOpenEvent = false; + } + else if ( aArgStr.EqualsIgnoreCaseAscii( "-p" )) + { // Print to default printer - bPrintEvent = sal_True; - bPrintToEvent = sal_False; - bOpenEvent = sal_False; - bForceNewEvent = sal_False; - bForceOpenEvent = sal_False; - bViewEvent = sal_False; - bStartEvent = sal_False; - bDisplaySpec = sal_False; - } - else if ( aArgStr.EqualsIgnoreCaseAscii( "-view" )) - { + bPrintEvent = true; + bPrintToEvent = false; + bOpenEvent = false; + bForceNewEvent = false; + bForceOpenEvent = false; + bViewEvent = false; + bStartEvent = false; + bDisplaySpec = false; + } + else if ( aArgStr.EqualsIgnoreCaseAscii( "-view" )) + { // open in viewmode - bOpenEvent = sal_False; - bPrintEvent = sal_False; - bPrintToEvent = sal_False; - bForceNewEvent = sal_False; - bForceOpenEvent = sal_False; - bViewEvent = sal_True; - bStartEvent = sal_False; - bDisplaySpec = sal_False; - } + bOpenEvent = false; + bPrintEvent = false; + bPrintToEvent = false; + bForceNewEvent = false; + bForceOpenEvent = false; + bViewEvent = true; + bStartEvent = false; + bDisplaySpec = false; + } else if ( aArgStr.EqualsIgnoreCaseAscii( "-show" )) { // open in viewmode - bOpenEvent = sal_False; - bViewEvent = sal_False; - bStartEvent = sal_True; - bPrintEvent = sal_False; - bPrintToEvent = sal_False; - bForceNewEvent = sal_False; - bForceOpenEvent = sal_False; - bDisplaySpec = sal_False; + bOpenEvent = false; + bViewEvent = false; + bStartEvent = true; + bPrintEvent = false; + bPrintToEvent = false; + bForceNewEvent = false; + bForceOpenEvent = false; + bDisplaySpec = false; } else if ( aArgStr.EqualsIgnoreCaseAscii( "-display" )) { // set display - bOpenEvent = sal_False; - bPrintEvent = sal_False; - bForceOpenEvent = sal_False; - bPrintToEvent = sal_False; - bForceNewEvent = sal_False; - bViewEvent = sal_False; - bStartEvent = sal_False; - bDisplaySpec = sal_True; + bOpenEvent = false; + bPrintEvent = false; + bForceOpenEvent = false; + bPrintToEvent = false; + bForceNewEvent = false; + bViewEvent = false; + bStartEvent = false; + bDisplaySpec = true; } else if ( aArgStr.EqualsIgnoreCaseAscii( "-language" )) { - bOpenEvent = sal_False; - bPrintEvent = sal_False; - bForceOpenEvent = sal_False; - bPrintToEvent = sal_False; - bForceNewEvent = sal_False; - bViewEvent = sal_False; - bStartEvent = sal_False; - bDisplaySpec = sal_False; + bOpenEvent = false; + bPrintEvent = false; + bForceOpenEvent = false; + bPrintToEvent = false; + bForceNewEvent = false; + bViewEvent = false; + bStartEvent = false; + bDisplaySpec = false; } #ifdef MACOSX @@ -285,14 +286,14 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) else if ( aArgStr.CompareToAscii( "-psn", 4 ) == COMPARE_EQUAL ) { // finder argument from MacOSX - bOpenEvent = sal_False; - bPrintEvent = sal_False; - bForceOpenEvent = sal_False; - bPrintToEvent = sal_False; - bForceNewEvent = sal_False; - bViewEvent = sal_False; - bStartEvent = sal_False; - bDisplaySpec = sal_False; + bOpenEvent = false; + bPrintEvent = false; + bForceOpenEvent = false; + bPrintToEvent = false; + bForceNewEvent = false; + bViewEvent = false; + bStartEvent = false; + bDisplaySpec = false; } #endif } @@ -308,29 +309,54 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) { // handle this argument as a filename if ( bOpenEvent ) + { AddStringListParam_Impl( CMD_STRINGPARAM_OPENLIST, aArgStr ); + bOpenDoc = true; + } else if ( bViewEvent ) + { AddStringListParam_Impl( CMD_STRINGPARAM_VIEWLIST, aArgStr ); + bOpenDoc = true; + } else if ( bStartEvent ) + { AddStringListParam_Impl( CMD_STRINGPARAM_STARTLIST, aArgStr ); + bOpenDoc = true; + } else if ( bPrintEvent ) + { AddStringListParam_Impl( CMD_STRINGPARAM_PRINTLIST, aArgStr ); + bOpenDoc = true; + } else if ( bPrintToEvent ) + { AddStringListParam_Impl( CMD_STRINGPARAM_PRINTTOLIST, aArgStr ); + bOpenDoc = true; + } else if ( bForceNewEvent ) + { AddStringListParam_Impl( CMD_STRINGPARAM_FORCENEWLIST, aArgStr ); + bOpenDoc = true; + } else if ( bForceOpenEvent ) + { AddStringListParam_Impl( CMD_STRINGPARAM_FORCEOPENLIST, aArgStr ); - else if ( bDisplaySpec ){ + bOpenDoc = true; + } + else if ( bDisplaySpec ) + { AddStringListParam_Impl( CMD_STRINGPARAM_DISPLAY, aArgStr ); - bDisplaySpec = sal_False; // only one display, not a lsit - bOpenEvent = sal_True; // set back to standard + bDisplaySpec = false; // only one display, not a lsit + bOpenEvent = true; // set back to standard } } } } } } + + if ( bOpenDoc ) + m_bDocumentArgs = true; } void CommandLineArgs::AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam ) @@ -432,8 +458,8 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& return sal_True; } else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-help" )) - || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-h" )) - || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-?" ))) + || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-h" )) + || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-?" ))) { SetBoolParam_Impl( CMD_BOOLPARAM_HELP, sal_True ); return sal_True; @@ -473,18 +499,18 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& SetBoolParam_Impl( CMD_BOOLPARAM_HELPMATH, sal_True ); return sal_True; } - #ifdef MACOSX - /* #i84053# ignore -psn on Mac - Platform dependent #ifdef here is ugly, however this is currently - the only platform dependent parameter. Should more appear - we should find a better solution - */ +#ifdef MACOSX + /* #i84053# ignore -psn on Mac + Platform dependent #ifdef here is ugly, however this is currently + the only platform dependent parameter. Should more appear + we should find a better solution + */ else if ( aArg.compareToAscii( "-psn", 4 ) == 0 ) { SetBoolParam_Impl( CMD_BOOLPARAM_PSN, sal_True ); return sal_True; } - #endif +#endif else if ( aArgStr.Copy(0, 8).EqualsIgnoreCaseAscii( "-accept=" )) { AddStringListParam_Impl( CMD_STRINGPARAM_ACCEPT, aArgStr.Copy( 8 ) ); @@ -496,7 +522,7 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& return sal_True; } else if ( aArgStr.CompareIgnoreCaseToAscii( "-portal," , - RTL_CONSTASCII_LENGTH( "-portal," )) == COMPARE_EQUAL ) + RTL_CONSTASCII_LENGTH( "-portal," )) == COMPARE_EQUAL ) { AddStringListParam_Impl( CMD_STRINGPARAM_PORTAL, aArgStr.Copy( RTL_CONSTASCII_LENGTH( "-portal," )) ); return sal_True; @@ -504,13 +530,10 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& else if ( aArgStr.Copy( 0, 7 ).EqualsIgnoreCaseAscii( "-userid" )) { if ( aArgStr.Len() > 8 ) - { - rtl::OUString aUserDir = aArgStr; - AddStringListParam_Impl( - CMD_STRINGPARAM_USERDIR, - ::rtl::Uri::decode( aUserDir.copy( 8 ), - rtl_UriDecodeWithCharset, - RTL_TEXTENCODING_UTF8 ) ); + { + rtl::OUString aUserDir = aArgStr; + AddStringListParam_Impl( CMD_STRINGPARAM_USERDIR, + ::rtl::Uri::decode( aUserDir.copy( 8 ), rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ) ); } return sal_True; } @@ -533,56 +556,64 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& { sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_WRITER ); if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_WRITER, sal_True ); + SetBoolParam_Impl( CMD_BOOLPARAM_WRITER, sal_True ); + m_bDocumentArgs = true; return sal_True; } else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-calc" )) == sal_True ) { sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_CALC ); if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_CALC, sal_True ); + SetBoolParam_Impl( CMD_BOOLPARAM_CALC, sal_True ); + m_bDocumentArgs = true; return sal_True; } else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-draw" )) == sal_True ) { sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_DRAW ); if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_DRAW, sal_True ); + SetBoolParam_Impl( CMD_BOOLPARAM_DRAW, sal_True ); + m_bDocumentArgs = true; return sal_True; } else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-impress" )) == sal_True ) { sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_IMPRESS ); if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_IMPRESS, sal_True ); + SetBoolParam_Impl( CMD_BOOLPARAM_IMPRESS, sal_True ); + m_bDocumentArgs = true; return sal_True; } else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-base" )) == sal_True ) { sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_BASE ); if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_BASE, sal_True ); + SetBoolParam_Impl( CMD_BOOLPARAM_BASE, sal_True ); + m_bDocumentArgs = true; return sal_True; } else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-global" )) == sal_True ) { sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_GLOBAL ); if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_GLOBAL, sal_True ); + SetBoolParam_Impl( CMD_BOOLPARAM_GLOBAL, sal_True ); + m_bDocumentArgs = true; return sal_True; } else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-math" )) == sal_True ) { sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_MATH ); if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_MATH, sal_True ); + SetBoolParam_Impl( CMD_BOOLPARAM_MATH, sal_True ); + m_bDocumentArgs = true; return sal_True; } else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-web" )) == sal_True ) { sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_WEB ); if ( !bAlreadySet ) - SetBoolParam_Impl( CMD_BOOLPARAM_WEB, sal_True ); + SetBoolParam_Impl( CMD_BOOLPARAM_WEB, sal_True ); + m_bDocumentArgs = true; return sal_True; } @@ -605,12 +636,12 @@ sal_Bool CommandLineArgs::CheckGroupMembers( GroupParamId nGroupId, BoolParam nE void CommandLineArgs::ResetParamValues() { int i; - for ( i = 0; i < CMD_BOOLPARAM_COUNT; i++ ) m_aBoolParams[i] = sal_False; for ( i = 0; i < CMD_STRINGPARAM_COUNT; i++ ) m_aStrSetParams[i] = sal_False; m_eArgumentCount = NONE; + m_bDocumentArgs = false; } void CommandLineArgs::SetBoolParam( BoolParam eParam, sal_Bool bNewValue ) @@ -897,4 +928,10 @@ sal_Bool CommandLineArgs::IsEmptyOrAcceptOnly() const ( ( m_eArgumentCount == ONE ) && m_aBoolParams[ CMD_BOOLPARAM_PSN ] ); } +sal_Bool CommandLineArgs::WantsToLoadDocument() const +{ + osl::MutexGuard aMutexGuard( m_aMutex ); + return m_bDocumentArgs; +} + } // namespace desktop diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx index 615577098c2d..a1c70bf5df72 100644 --- a/desktop/source/app/cmdlineargs.hxx +++ b/desktop/source/app/cmdlineargs.hxx @@ -38,7 +38,7 @@ namespace desktop class CommandLineArgs { public: - enum BoolParam // must be zero based! + enum BoolParam // must be zero based! { CMD_BOOLPARAM_MINIMIZED, CMD_BOOLPARAM_INVISIBLE, @@ -71,7 +71,7 @@ class CommandLineArgs CMD_BOOLPARAM_HELPIMPRESS, CMD_BOOLPARAM_HELPBASE, CMD_BOOLPARAM_PSN, - CMD_BOOLPARAM_COUNT // must be last element! + CMD_BOOLPARAM_COUNT // must be last element! }; enum StringParam // must be zero based! @@ -92,7 +92,7 @@ class CommandLineArgs CMD_STRINGPARAM_PRINTERNAME, CMD_STRINGPARAM_DISPLAY, CMD_STRINGPARAM_LANGUAGE, - CMD_STRINGPARAM_COUNT // must be last element! + CMD_STRINGPARAM_COUNT // must be last element! }; enum GroupParamId @@ -101,7 +101,8 @@ class CommandLineArgs CMD_GRPID_COUNT }; - struct Supplier { + struct Supplier + { // Thrown from constructors and next: class Exception { public: @@ -122,86 +123,88 @@ class CommandLineArgs boost::optional< rtl::OUString > getCwdUrl() const { return m_cwdUrl; } // generic methods to access parameter - void SetBoolParam( BoolParam eParam, sal_Bool bNewValue ); + void SetBoolParam( BoolParam eParam, sal_Bool bNewValue ); // Access to bool parameters - sal_Bool IsMinimized() const; - sal_Bool IsInvisible() const; - sal_Bool IsNoRestore() const; - sal_Bool IsNoDefault() const; - sal_Bool IsBean() const; - sal_Bool IsServer() const; - sal_Bool IsHeadless() const; - sal_Bool IsQuickstart() const; - sal_Bool IsNoQuickstart() const; - sal_Bool IsTerminateAfterInit() const; - sal_Bool IsNoFirstStartWizard() const; - sal_Bool IsNoLogo() const; - sal_Bool IsNoLockcheck() const; - sal_Bool IsHelp() const; - sal_Bool IsHelpWriter() const; - sal_Bool IsHelpCalc() const; - sal_Bool IsHelpDraw() const; - sal_Bool IsHelpImpress() const; - sal_Bool IsHelpBase() const; - sal_Bool IsHelpMath() const; - sal_Bool IsHelpBasic() const; - sal_Bool IsWriter() const; - sal_Bool IsCalc() const; - sal_Bool IsDraw() const; - sal_Bool IsImpress() const; - sal_Bool IsBase() const; - sal_Bool IsGlobal() const; - sal_Bool IsMath() const; - sal_Bool IsWeb() const; - sal_Bool HasModuleParam() const; + sal_Bool IsMinimized() const; + sal_Bool IsInvisible() const; + sal_Bool IsNoRestore() const; + sal_Bool IsNoDefault() const; + sal_Bool IsBean() const; + sal_Bool IsServer() const; + sal_Bool IsHeadless() const; + sal_Bool IsQuickstart() const; + sal_Bool IsNoQuickstart() const; + sal_Bool IsTerminateAfterInit() const; + sal_Bool IsNoFirstStartWizard() const; + sal_Bool IsNoLogo() const; + sal_Bool IsNoLockcheck() const; + sal_Bool IsHelp() const; + sal_Bool IsHelpWriter() const; + sal_Bool IsHelpCalc() const; + sal_Bool IsHelpDraw() const; + sal_Bool IsHelpImpress() const; + sal_Bool IsHelpBase() const; + sal_Bool IsHelpMath() const; + sal_Bool IsHelpBasic() const; + sal_Bool IsWriter() const; + sal_Bool IsCalc() const; + sal_Bool IsDraw() const; + sal_Bool IsImpress() const; + sal_Bool IsBase() const; + sal_Bool IsGlobal() const; + sal_Bool IsMath() const; + sal_Bool IsWeb() const; + sal_Bool HasModuleParam() const; + sal_Bool WantsToLoadDocument() const; // Access to string parameters - sal_Bool GetPortalConnectString( ::rtl::OUString& rPara) const; - sal_Bool GetAcceptString( ::rtl::OUString& rPara) const; - sal_Bool GetUnAcceptString( ::rtl::OUString& rPara) const; - sal_Bool GetOpenList( ::rtl::OUString& rPara) const; - sal_Bool GetViewList( ::rtl::OUString& rPara) const; - sal_Bool GetStartList( ::rtl::OUString& rPara) const; - sal_Bool GetForceOpenList( ::rtl::OUString& rPara) const; - sal_Bool GetForceNewList( ::rtl::OUString& rPara) const; - sal_Bool GetPrintList( ::rtl::OUString& rPara) const; - sal_Bool GetPrintToList( ::rtl::OUString& rPara ) const; - sal_Bool GetPrinterName( ::rtl::OUString& rPara ) const; - sal_Bool GetLanguage( ::rtl::OUString& rPara ) const; + sal_Bool GetPortalConnectString( ::rtl::OUString& rPara) const; + sal_Bool GetAcceptString( ::rtl::OUString& rPara) const; + sal_Bool GetUnAcceptString( ::rtl::OUString& rPara) const; + sal_Bool GetOpenList( ::rtl::OUString& rPara) const; + sal_Bool GetViewList( ::rtl::OUString& rPara) const; + sal_Bool GetStartList( ::rtl::OUString& rPara) const; + sal_Bool GetForceOpenList( ::rtl::OUString& rPara) const; + sal_Bool GetForceNewList( ::rtl::OUString& rPara) const; + sal_Bool GetPrintList( ::rtl::OUString& rPara) const; + sal_Bool GetPrintToList( ::rtl::OUString& rPara ) const; + sal_Bool GetPrinterName( ::rtl::OUString& rPara ) const; + sal_Bool GetLanguage( ::rtl::OUString& rPara ) const; // Special analyzed states (does not match directly to a command line parameter!) - sal_Bool IsPrinting() const; - sal_Bool IsEmpty() const; - sal_Bool IsEmptyOrAcceptOnly() const; + sal_Bool IsPrinting() const; + sal_Bool IsEmpty() const; + sal_Bool IsEmptyOrAcceptOnly() const; private: enum Count { NONE, ONE, MANY }; struct GroupDefinition { - sal_Int32 nCount; - BoolParam* pGroupMembers; + sal_Int32 nCount; + BoolParam* pGroupMembers; }; // no copy and operator= CommandLineArgs( const CommandLineArgs& ); CommandLineArgs operator=( const CommandLineArgs& ); - sal_Bool InterpretCommandLineParameter( const ::rtl::OUString& ); - void ParseCommandLine_Impl( Supplier& supplier ); - void ResetParamValues(); - sal_Bool CheckGroupMembers( GroupParamId nGroup, BoolParam nExcludeMember ) const; + sal_Bool InterpretCommandLineParameter( const ::rtl::OUString& ); + void ParseCommandLine_Impl( Supplier& supplier ); + void ResetParamValues(); + sal_Bool CheckGroupMembers( GroupParamId nGroup, BoolParam nExcludeMember ) const; - void AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam ); - void SetBoolParam_Impl( BoolParam eParam, sal_Bool bValue ); + void AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam ); + void SetBoolParam_Impl( BoolParam eParam, sal_Bool bValue ); boost::optional< rtl::OUString > m_cwdUrl; - sal_Bool m_aBoolParams[ CMD_BOOLPARAM_COUNT ]; // Stores boolean parameters - rtl::OUString m_aStrParams[ CMD_STRINGPARAM_COUNT ]; // Stores string parameters - sal_Bool m_aStrSetParams[ CMD_STRINGPARAM_COUNT ]; // Stores if string parameters are provided on cmdline - Count m_eArgumentCount; // Number of Args - mutable ::osl::Mutex m_aMutex; + sal_Bool m_aBoolParams[ CMD_BOOLPARAM_COUNT ]; // Stores boolean parameters + rtl::OUString m_aStrParams[ CMD_STRINGPARAM_COUNT ]; // Stores string parameters + sal_Bool m_aStrSetParams[ CMD_STRINGPARAM_COUNT ]; // Stores if string parameters are provided on cmdline + Count m_eArgumentCount; // Number of Args + bool m_bDocumentArgs; // A document creation/open/load arg is used + mutable ::osl::Mutex m_aMutex; // static definition for groups where only one member can be true static GroupDefinition m_pGroupDefinitions[ CMD_GRPID_COUNT ]; diff --git a/desktop/source/deployment/gui/dp_gui.hrc b/desktop/source/deployment/gui/dp_gui.hrc index 5f52b042edf3..dcde55654a30 100644..100755 --- a/desktop/source/deployment/gui/dp_gui.hrc +++ b/desktop/source/deployment/gui/dp_gui.hrc @@ -106,7 +106,7 @@ #define RID_DLG_UPDATE_LINE 8 #define RID_DLG_UPDATE_HELP 9 #define RID_DLG_UPDATE_OK 10 -#define RID_DLG_UPDATE_CANCEL 11 +#define RID_DLG_UPDATE_CLOSE 11 #define RID_DLG_UPDATE_NORMALALERT 12 #define RID_DLG_UPDATE_HIGHCONTRASTALERT 13 #define RID_DLG_UPDATE_ERROR 14 @@ -127,6 +127,11 @@ #define RID_DLG_UPDATE_RELEASENOTES_LINK 29 #define RID_DLG_UPDATE_NOUPDATE 30 #define RID_DLG_UPDATE_VERSION 31 +#define RID_DLG_UPDATE_IGNORE 32 +#define RID_DLG_UPDATE_ENABLE 33 +#define RID_DLG_UPDATE_IGNORE_ALL 34 +#define RID_DLG_UPDATE_IGNORED_UPDATE 35 + #define RID_DLG_UPDATEINSTALL (RID_DEPLOYMENT_GUI_START + 20) @@ -163,6 +168,7 @@ #define RID_STR_NO_ADMIN_PRIVILEGE (RID_DEPLOYMENT_GUI_START+95) #define RID_STR_ERROR_MISSING_DEPENDENCIES (RID_DEPLOYMENT_GUI_START+96) #define RID_STR_ERROR_MISSING_LICENSE (RID_DEPLOYMENT_GUI_START+97) +#define RID_STR_SHOW_LICENSE_CMD (RID_DEPLOYMENT_GUI_START+98) #define WARNINGBOX_CONCURRENTINSTANCE (RID_DEPLOYMENT_GUI_START+100) @@ -172,6 +178,7 @@ #define RID_WARNINGBOX_REMOVE_SHARED_EXTENSION (RID_DEPLOYMENT_GUI_START+104) #define RID_WARNINGBOX_ENABLE_SHARED_EXTENSION (RID_DEPLOYMENT_GUI_START+105) #define RID_WARNINGBOX_DISABLE_SHARED_EXTENSION (RID_DEPLOYMENT_GUI_START+106) +#define RID_DLG_SHOW_LICENSE (RID_DEPLOYMENT_GUI_START+107) #define RID_DLG_LICENSE RID_DEPLOYMENT_LICENSE_START diff --git a/desktop/source/deployment/gui/dp_gui_dialog.src b/desktop/source/deployment/gui/dp_gui_dialog.src index 665dbe5934d7..c9fd19c25592 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog.src +++ b/desktop/source/deployment/gui/dp_gui_dialog.src @@ -119,6 +119,11 @@ String RID_STR_ERROR_MISSING_LICENSE Text [ en-US ] = "This extension is disabled because you haven't accepted the license yet.\n"; }; +String RID_STR_SHOW_LICENSE_CMD +{ + Text [ en-US ] = "Show license"; +}; + // Dialog layout // --------------------------------------------------- // row 1 | multi line edit @@ -293,6 +298,35 @@ ModalDialog RID_DLG_LICENSE }; +ModalDialog RID_DLG_SHOW_LICENSE +{ + Text [ en-US ] = "Extension Software License Agreement"; + Size = MAP_APPFONT( 300, 200 ); + OutputSize = TRUE; + SVLook = TRUE; + Moveable = TRUE; + Closeable = TRUE; + Sizeable = TRUE; + + MultiLineEdit ML_LICENSE + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 300 - 10, 200 - 15 - RSC_CD_PUSHBUTTON_HEIGHT ); + Border = TRUE; + VScroll = TRUE; + ReadOnly = TRUE; + }; + + OKButton RID_EM_BTN_CLOSE + { + TabStop = TRUE; + DefButton = TRUE; + Text [ en-US ] = "Close"; + Pos = MAP_APPFONT( (300-RSC_CD_PUSHBUTTON_WIDTH)/2, 200 - 5 - RSC_CD_PUSHBUTTON_HEIGHT ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; +}; + WarningBox RID_WARNINGBOX_INSTALL_EXTENSION { diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 44d1e30f74b6..8fd0f4c754d0 100644..100755 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -39,8 +39,10 @@ #include "dp_gui_theextmgr.hxx" #include "dp_gui_extensioncmdqueue.hxx" #include "dp_misc.h" +#include "dp_ucb.h" #include "dp_update.hxx" #include "dp_identifier.hxx" +#include "dp_descriptioninfoset.hxx" #include "vcl/ctrl.hxx" #include "vcl/menu.hxx" @@ -118,7 +120,8 @@ enum MENU_COMMAND CMD_REMOVE = 1, CMD_ENABLE, CMD_DISABLE, - CMD_UPDATE + CMD_UPDATE, + CMD_SHOW_LICENSE }; class ExtBoxWithBtns_Impl : public ExtensionBox_Impl @@ -224,13 +227,10 @@ const Size ExtBoxWithBtns_Impl::GetMinOutputSizePixel() const // ----------------------------------------------------------------------- void ExtBoxWithBtns_Impl::RecalcAll() { - ExtensionBox_Impl::RecalcAll(); - const sal_Int32 nActive = getSelIndex(); if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND ) { - SetButtonPos( GetEntryRect( nActive ) ); SetButtonStatus( GetEntryData( nActive) ); } else @@ -239,6 +239,11 @@ void ExtBoxWithBtns_Impl::RecalcAll() m_pEnableBtn->Hide(); m_pRemoveBtn->Hide(); } + + ExtensionBox_Impl::RecalcAll(); + + if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND ) + SetButtonPos( GetEntryRect( nActive ) ); } @@ -363,28 +368,29 @@ bool ExtBoxWithBtns_Impl::HandleTabKey( bool bReverse ) // ----------------------------------------------------------------------- MENU_COMMAND ExtBoxWithBtns_Impl::ShowPopupMenu( const Point & rPos, const long nPos ) { - if ( ( nPos >= 0 ) && ( nPos < (long) getItemCount() ) ) - { - if ( ! GetEntryData( nPos )->m_bLocked ) - { - PopupMenu aPopup; - - aPopup.InsertItem( CMD_UPDATE, DialogHelper::getResourceString( RID_CTX_ITEM_CHECK_UPDATE ) ); + if ( nPos >= (long) getItemCount() ) + return CMD_NONE; - if ( GetEntryData( nPos )->m_bUser ) - { - if ( GetEntryData( nPos )->m_eState == REGISTERED ) - aPopup.InsertItem( CMD_DISABLE, DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) ); - else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE ) - aPopup.InsertItem( CMD_ENABLE, DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) ); - } + PopupMenu aPopup; - aPopup.InsertItem( CMD_REMOVE, DialogHelper::getResourceString( RID_CTX_ITEM_REMOVE ) ); + aPopup.InsertItem( CMD_UPDATE, DialogHelper::getResourceString( RID_CTX_ITEM_CHECK_UPDATE ) ); - return (MENU_COMMAND) aPopup.Execute( this, rPos ); + if ( ! GetEntryData( nPos )->m_bLocked ) + { + if ( GetEntryData( nPos )->m_bUser ) + { + if ( GetEntryData( nPos )->m_eState == REGISTERED ) + aPopup.InsertItem( CMD_DISABLE, DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) ); + else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE ) + aPopup.InsertItem( CMD_ENABLE, DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) ); } + aPopup.InsertItem( CMD_REMOVE, DialogHelper::getResourceString( RID_CTX_ITEM_REMOVE ) ); } - return CMD_NONE; + + if ( GetEntryData( nPos )->m_sLicenseText.Len() ) + aPopup.InsertItem( CMD_SHOW_LICENSE, DialogHelper::getResourceString( RID_STR_SHOW_LICENSE_CMD ) ); + + return (MENU_COMMAND) aPopup.Execute( this, rPos ); } //------------------------------------------------------------------------------ @@ -409,6 +415,12 @@ void ExtBoxWithBtns_Impl::MouseButtonDown( const MouseEvent& rMEvt ) break; case CMD_REMOVE: m_pParent->removePackage( GetEntryData( nPos )->m_xPackage ); break; + case CMD_SHOW_LICENSE: + { + ShowLicenseDialog aLicenseDlg( m_pParent, GetEntryData( nPos )->m_xPackage ); + aLicenseDlg.Execute(); + break; + } } } else if ( rMEvt.IsLeft() ) @@ -1742,6 +1754,42 @@ void UpdateRequiredDialog::disableAllEntries() m_aCloseBtn.SetText( m_sCloseText ); } +//------------------------------------------------------------------------------ +// ShowLicenseDialog +//------------------------------------------------------------------------------ +ShowLicenseDialog::ShowLicenseDialog( Window * pParent, + const uno::Reference< deployment::XPackage > &xPackage ) : + ModalDialog( pParent, DialogHelper::getResId( RID_DLG_SHOW_LICENSE ) ), + m_aLicenseText( this, DialogHelper::getResId( ML_LICENSE ) ), + m_aCloseBtn( this, DialogHelper::getResId( RID_EM_BTN_CLOSE ) ) +{ + FreeResource(); + + OUString aText = xPackage->getLicenseText(); + m_aLicenseText.SetText( aText ); +} + +//------------------------------------------------------------------------------ +ShowLicenseDialog::~ShowLicenseDialog() +{} + +//------------------------------------------------------------------------------ +void ShowLicenseDialog::Resize() +{ + Size aTotalSize( GetOutputSizePixel() ); + Size aTextSize( aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_LEFT - RSC_SP_DLG_INNERBORDER_RIGHT, + aTotalSize.Height() - RSC_SP_DLG_INNERBORDER_TOP - 2*RSC_SP_DLG_INNERBORDER_BOTTOM + - m_aCloseBtn.GetSizePixel().Height() ); + + m_aLicenseText.SetPosSizePixel( Point( RSC_SP_DLG_INNERBORDER_LEFT, RSC_SP_DLG_INNERBORDER_TOP ), + aTextSize ); + + Point aBtnPos( (aTotalSize.Width() - m_aCloseBtn.GetSizePixel().Width())/2, + aTotalSize.Height() - RSC_SP_DLG_INNERBORDER_BOTTOM + - m_aCloseBtn.GetSizePixel().Height() ); + m_aCloseBtn.SetPosPixel( aBtnPos ); +} + //================================================================================= // UpdateRequiredDialogService //================================================================================= diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index f0a85cce98c0..755c3aadcbdf 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -35,6 +35,7 @@ #include "svtools/fixedhyper.hxx" #include "svtools/prgsbar.hxx" +#include "svtools/svmedit.hxx" #include "osl/conditn.hxx" #include "osl/mutex.hxx" @@ -246,6 +247,20 @@ public: }; //============================================================================== +class ShowLicenseDialog : public ModalDialog +{ + MultiLineEdit m_aLicenseText; + OKButton m_aCloseBtn; + +public: + ShowLicenseDialog( Window * pParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + virtual ~ShowLicenseDialog(); + + virtual void Resize(); +}; + +//============================================================================== class UpdateRequiredDialogService : public ::cppu::WeakImplHelper1< ::com::sun::star::ui::dialogs::XExecutableDialog > { ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const m_xComponentContext; diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 24b47aa223e3..54495de410dc 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -71,29 +71,35 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_pPublisher( NULL ), m_xPackage( xPackage ) { - m_sTitle = xPackage->getDisplayName(); - m_sVersion = xPackage->getVersion(); - m_sDescription = xPackage->getDescription(); - - beans::StringPair aInfo( m_xPackage->getPublisherInfo() ); - m_sPublisher = aInfo.First; - m_sPublisherURL = aInfo.Second; - - // get the icons for the package if there are any - uno::Reference< graphic::XGraphic > xGraphic = xPackage->getIcon( false ); - if ( xGraphic.is() ) - m_aIcon = Image( xGraphic ); - - xGraphic = xPackage->getIcon( true ); - if ( xGraphic.is() ) - m_aIconHC = Image( xGraphic ); - else - m_aIconHC = m_aIcon; + try + { + m_sTitle = xPackage->getDisplayName(); + m_sVersion = xPackage->getVersion(); + m_sDescription = xPackage->getDescription(); + m_sLicenseText = xPackage->getLicenseText(); + + beans::StringPair aInfo( m_xPackage->getPublisherInfo() ); + m_sPublisher = aInfo.First; + m_sPublisherURL = aInfo.Second; + + // get the icons for the package if there are any + uno::Reference< graphic::XGraphic > xGraphic = xPackage->getIcon( false ); + if ( xGraphic.is() ) + m_aIcon = Image( xGraphic ); + + xGraphic = xPackage->getIcon( true ); + if ( xGraphic.is() ) + m_aIconHC = Image( xGraphic ); + else + m_aIconHC = m_aIcon; - if ( eState == AMBIGUOUS ) - m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS ); - else if ( eState == NOT_REGISTERED ) - checkDependencies(); + if ( eState == AMBIGUOUS ) + m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS ); + else if ( eState == NOT_REGISTERED ) + checkDependencies(); + } + catch (deployment::ExtensionRemovedException &) {} + catch (uno::RuntimeException &) {} } //------------------------------------------------------------------------------ @@ -963,6 +969,11 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & bool bLocked = m_pManager->isReadOnly( xPackage ); TEntry_Impl pEntry( new Entry_Impl( xPackage, eState, bLocked ) ); + + // Don't add empty entries + if ( ! pEntry->m_sTitle.Len() ) + return 0; + xPackage->addEventListener( uno::Reference< lang::XEventListener > ( m_xRemoveListener, uno::UNO_QUERY ) ); ::osl::ClearableMutexGuard guard(m_entriesMutex); diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx index 762f50296690..cbf9e27a8da1 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -81,6 +81,7 @@ struct Entry_Impl String m_sPublisher; String m_sPublisherURL; String m_sErrorText; + String m_sLicenseText; Image m_aIcon; Image m_aIconHC; svt::FixedHyperlink *m_pPublisher; diff --git a/desktop/source/deployment/gui/dp_gui_updatedata.hxx b/desktop/source/deployment/gui/dp_gui_updatedata.hxx index 76eb8af31e8e..1112de0b34e8 100644..100755 --- a/desktop/source/deployment/gui/dp_gui_updatedata.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedata.hxx @@ -28,6 +28,7 @@ #define INCLUDED_DP_GUI_UPDATEDATA_HXX #include "sal/config.h" +#include "tools/solar.h" #include "rtl/ustring.hxx" #include "com/sun/star/uno/Reference.hxx" @@ -80,6 +81,10 @@ struct UpdateData //are to be ignored. ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > aUpdateSource; + + // ID to find this entry in the update listbox + USHORT m_nID; + bool m_bIgnored; }; } diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index b27cd8da81fe..44f335dd509d 100644..100755 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -50,7 +50,9 @@ #include "com/sun/star/beans/NamedValue.hpp" #include "com/sun/star/beans/Optional.hpp" #include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" #include "com/sun/star/container/XNameAccess.hpp" +#include "com/sun/star/container/XNameContainer.hpp" #include "com/sun/star/deployment/DeploymentException.hpp" #include "com/sun/star/deployment/UpdateInformationProvider.hpp" #include "com/sun/star/deployment/XPackage.hpp" @@ -62,6 +64,7 @@ #include "com/sun/star/frame/XDispatchProvider.hpp" #include "com/sun/star/lang/IllegalArgumentException.hpp" #include "com/sun/star/lang/XMultiComponentFactory.hpp" +#include "com/sun/star/lang/XSingleServiceFactory.hpp" #include "com/sun/star/system/SystemShellExecuteFlags.hpp" #include "com/sun/star/system/XSystemShellExecute.hpp" #include "com/sun/star/task/XAbortChannel.hpp" @@ -76,6 +79,7 @@ #include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/XInterface.hpp" #include "com/sun/star/util/URL.hpp" +#include "com/sun/star/util/XChangesBatch.hpp" #include "com/sun/star/util/XURLTransformer.hpp" #include "com/sun/star/xml/dom/XElement.hpp" #include "com/sun/star/xml/dom/XNode.hpp" @@ -129,16 +133,23 @@ namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } } -namespace css = ::com::sun::star; - +using namespace ::com::sun::star; using dp_gui::UpdateDialog; namespace { static sal_Unicode const LF = 0x000A; static sal_Unicode const CR = 0x000D; +static const USHORT CMD_ENABLE_UPDATE = 1; +static const USHORT CMD_IGNORE_UPDATE = 2; +static const USHORT CMD_IGNORE_ALL_UPDATES = 3; + +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) + +#define IGNORED_UPDATES OUSTR("/org.openoffice.Office.ExtensionManager/ExtensionUpdateData/IgnoredUpdates") +#define PROPERTY_VERSION OUSTR("Version") -enum Kind { ENABLED_UPDATE, DISABLED_UPDATE, GENERAL_ERROR, SPECIFIC_ERROR }; +enum Kind { ENABLED_UPDATE, DISABLED_UPDATE, SPECIFIC_ERROR }; rtl::OUString confineToParagraph(rtl::OUString const & text) { // Confine arbitrary text to a single paragraph in a dp_gui::AutoScrollEdit. @@ -151,86 +162,64 @@ rtl::OUString confineToParagraph(rtl::OUString const & text) { struct UpdateDialog::DisabledUpdate { rtl::OUString name; - css::uno::Sequence< rtl::OUString > unsatisfiedDependencies; + uno::Sequence< rtl::OUString > unsatisfiedDependencies; // We also want to show release notes and publisher for disabled updates ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo; + USHORT m_nID; }; struct UpdateDialog::SpecificError { rtl::OUString name; rtl::OUString message; + USHORT m_nID; }; -union UpdateDialog::IndexUnion{ - std::vector< dp_gui::UpdateData >::size_type enabledUpdate; - std::vector< UpdateDialog::DisabledUpdate >::size_type disabledUpdate; - std::vector< rtl::OUString >::size_type generalError; - std::vector< UpdateDialog::SpecificError >::size_type specificError; -}; - -struct UpdateDialog::Index { - static std::auto_ptr< UpdateDialog::Index const > newEnabledUpdate( - std::vector< dp_gui::UpdateData >::size_type n); - - static std::auto_ptr< UpdateDialog::Index const > newDisabledUpdate( - std::vector< UpdateDialog::DisabledUpdate >::size_type n); +//------------------------------------------------------------------------------ +struct UpdateDialog::IgnoredUpdate { + rtl::OUString sExtensionID; + rtl::OUString sVersion; + bool bRemoved; - static std::auto_ptr< UpdateDialog::Index const > newGeneralError( - std::vector< rtl::OUString >::size_type n); - - static std::auto_ptr< UpdateDialog::Index const > newSpecificError( - std::vector< UpdateDialog::SpecificError >::size_type n); - - Kind kind; - IndexUnion index; - -private: - explicit Index(Kind theKind); + IgnoredUpdate( const rtl::OUString &rExtensionID, const rtl::OUString &rVersion ); }; -std::auto_ptr< UpdateDialog::Index const > -UpdateDialog::Index::newEnabledUpdate( - std::vector< dp_gui::UpdateData >::size_type n) -{ - UpdateDialog::Index * p = new UpdateDialog::Index(ENABLED_UPDATE); - p->index.enabledUpdate = n; - return std::auto_ptr< UpdateDialog::Index const >(p); -} - -std::auto_ptr< UpdateDialog::Index const > -UpdateDialog::Index::newDisabledUpdate( - std::vector< UpdateDialog::DisabledUpdate >::size_type n) -{ - UpdateDialog::Index * p = new UpdateDialog::Index(DISABLED_UPDATE); - p->index.disabledUpdate = n; - return std::auto_ptr< UpdateDialog::Index const >(p); -} +//------------------------------------------------------------------------------ +UpdateDialog::IgnoredUpdate::IgnoredUpdate( const rtl::OUString &rExtensionID, const rtl::OUString &rVersion ): + sExtensionID( rExtensionID ), + sVersion( rVersion ), + bRemoved( false ) +{} -std::auto_ptr< UpdateDialog::Index const > UpdateDialog::Index::newGeneralError( - std::vector< rtl::OUString >::size_type n) +//------------------------------------------------------------------------------ +struct UpdateDialog::Index { - UpdateDialog::Index * p = new UpdateDialog::Index(GENERAL_ERROR); - p->index.generalError = n; - return std::auto_ptr< UpdateDialog::Index const >(p); -} + Kind m_eKind; + bool m_bIgnored; + USHORT m_nID; + USHORT m_nIndex; + rtl::OUString m_aName; -std::auto_ptr< UpdateDialog::Index const > -UpdateDialog::Index::newSpecificError( - std::vector< UpdateDialog::SpecificError >::size_type n) -{ - UpdateDialog::Index * p = new UpdateDialog::Index(SPECIFIC_ERROR); - p->index.specificError = n; - return std::auto_ptr< UpdateDialog::Index const >(p); -} + Index( Kind theKind, USHORT nID, USHORT nIndex, const rtl::OUString &rName ); +}; -UpdateDialog::Index::Index(Kind theKind): kind(theKind) {} +//------------------------------------------------------------------------------ +UpdateDialog::Index::Index( Kind theKind, USHORT nID, USHORT nIndex, const rtl::OUString &rName ): + m_eKind( theKind ), + m_bIgnored( false ), + m_nID( nID ), + m_nIndex( nIndex ), + m_aName( rName ) +{} +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ class UpdateDialog::Thread: public dp_gui::Thread { public: Thread( - css::uno::Reference< css::uno::XComponentContext > const & context, + uno::Reference< uno::XComponentContext > const & context, UpdateDialog & dialog, - const std::vector< css::uno::Reference< css::deployment::XPackage > > & vExtensionList); + const std::vector< uno::Reference< deployment::XPackage > > & vExtensionList); void stop(); @@ -240,16 +229,16 @@ private: struct Entry { explicit Entry( - css::uno::Reference< css::deployment::XPackage > const & thePackage, + uno::Reference< deployment::XPackage > const & thePackage, rtl::OUString const & theVersion); - css::uno::Reference< css::deployment::XPackage > package; + uno::Reference< deployment::XPackage > package; rtl::OUString version; //Indicates that the extension provides its own update URLs. //If this is true, then we must not use the default update //URL to find the update information. bool bProvidesOwnUpdate; - css::uno::Reference< css::xml::dom::XNode > info; + uno::Reference< xml::dom::XNode > info; UpdateDialog::DisabledUpdate disableUpdate; dp_gui::UpdateData updateData; }; @@ -261,20 +250,20 @@ private: virtual void execute(); #if 0 - void handleGeneralError(css::uno::Any const & exception) const; + void handleGeneralError(uno::Any const & exception) const; #endif void handleSpecificError( - css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Any const & exception) const; + uno::Reference< deployment::XPackage > const & package, + uno::Any const & exception) const; - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > + uno::Sequence< uno::Reference< xml::dom::XElement > > getUpdateInformation( - css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Sequence< rtl::OUString > const & urls, + uno::Reference< deployment::XPackage > const & package, + uno::Sequence< rtl::OUString > const & urls, rtl::OUString const & identifier) const; void getOwnUpdateInformation( - css::uno::Reference< css::deployment::XPackage > const & package, + uno::Reference< deployment::XPackage > const & package, Map * map); ::rtl::OUString getUpdateDisplayString( @@ -286,40 +275,40 @@ private: dp_gui::UpdateData & out_data) const; bool update( - UpdateDialog::DisabledUpdate const & du, - dp_gui::UpdateData const & data) const; + UpdateDialog::DisabledUpdate & du, + dp_gui::UpdateData & data) const; - css::uno::Reference< css::uno::XComponentContext > m_context; + uno::Reference< uno::XComponentContext > m_context; UpdateDialog & m_dialog; - std::vector< css::uno::Reference< css::deployment::XPackage > > m_vExtensionList; - css::uno::Reference< css::deployment::XUpdateInformationProvider > m_updateInformation; - css::uno::Reference< css::task::XInteractionHandler > m_xInteractionHdl; + std::vector< uno::Reference< deployment::XPackage > > m_vExtensionList; + uno::Reference< deployment::XUpdateInformationProvider > m_updateInformation; + uno::Reference< task::XInteractionHandler > m_xInteractionHdl; // guarded by Application::GetSolarMutex(): - css::uno::Reference< css::task::XAbortChannel > m_abort; + uno::Reference< task::XAbortChannel > m_abort; bool m_stop; }; UpdateDialog::Thread::Thread( - css::uno::Reference< css::uno::XComponentContext > const & context, + uno::Reference< uno::XComponentContext > const & context, UpdateDialog & dialog, - const std::vector< css::uno::Reference< css::deployment::XPackage > > &vExtensionList): + const std::vector< uno::Reference< deployment::XPackage > > &vExtensionList): m_context(context), m_dialog(dialog), m_vExtensionList(vExtensionList), m_updateInformation( - css::deployment::UpdateInformationProvider::create(context)), + deployment::UpdateInformationProvider::create(context)), m_stop(false) { if( m_context.is() ) { - css::uno::Reference< css::lang::XMultiComponentFactory > xServiceManager( m_context->getServiceManager() ); + uno::Reference< lang::XMultiComponentFactory > xServiceManager( m_context->getServiceManager() ); if( xServiceManager.is() ) { - m_xInteractionHdl = css::uno::Reference< css::task::XInteractionHandler > ( + m_xInteractionHdl = uno::Reference< task::XInteractionHandler > ( xServiceManager->createInstanceWithContext( OUSTR( "com.sun.star.task.InteractionHandler" ), m_context), - css::uno::UNO_QUERY ); + uno::UNO_QUERY ); if ( m_xInteractionHdl.is() ) m_updateInformation->setInteractionHandler( m_xInteractionHdl ); } @@ -327,7 +316,7 @@ UpdateDialog::Thread::Thread( } void UpdateDialog::Thread::stop() { - css::uno::Reference< css::task::XAbortChannel > abort; + uno::Reference< task::XAbortChannel > abort; { vos::OGuard g(Application::GetSolarMutex()); abort = m_abort; @@ -340,7 +329,7 @@ void UpdateDialog::Thread::stop() { } UpdateDialog::Thread::Entry::Entry( - css::uno::Reference< css::deployment::XPackage > const & thePackage, + uno::Reference< deployment::XPackage > const & thePackage, rtl::OUString const & theVersion): package(thePackage), @@ -353,7 +342,7 @@ UpdateDialog::Thread::Entry::Entry( UpdateDialog::Thread::~Thread() { if ( m_xInteractionHdl.is() ) - m_updateInformation->setInteractionHandler( css::uno::Reference< css::task::XInteractionHandler > () ); + m_updateInformation->setInteractionHandler( uno::Reference< task::XInteractionHandler > () ); } void UpdateDialog::Thread::execute() @@ -364,16 +353,16 @@ void UpdateDialog::Thread::execute() return; } } - css::uno::Reference<css::deployment::XExtensionManager> extMgr = - css::deployment::ExtensionManager::get(m_context); + uno::Reference<deployment::XExtensionManager> extMgr = + deployment::ExtensionManager::get(m_context); - std::vector<std::pair<css::uno::Reference<css::deployment::XPackage>, css::uno::Any > > errors; + std::vector<std::pair<uno::Reference<deployment::XPackage>, uno::Any > > errors; dp_misc::UpdateInfoMap updateInfoMap = dp_misc::getOnlineUpdateInfos( m_context, extMgr, m_updateInformation, &m_vExtensionList, errors); - typedef std::vector<std::pair<css::uno::Reference<css::deployment::XPackage>, - css::uno::Any> >::const_iterator ITERROR; + typedef std::vector<std::pair<uno::Reference<deployment::XPackage>, + uno::Any> >::const_iterator ITERROR; for (ITERROR ite = errors.begin(); ite != errors.end(); ite ++) handleSpecificError(ite->first, ite->second); @@ -392,12 +381,12 @@ void UpdateDialog::Thread::execute() rtl::OUString sVersionUser; rtl::OUString sVersionShared; rtl::OUString sVersionBundled; - css::uno::Sequence< css::uno::Reference< css::deployment::XPackage> > extensions; + uno::Sequence< uno::Reference< deployment::XPackage> > extensions; try { extensions = extMgr->getExtensionsWithSameIdentifier( dp_misc::getIdentifier(info.extension), info.extension->getName(), - css::uno::Reference<css::ucb::XCommandEnvironment>()); - } catch (css::lang::IllegalArgumentException& ) { + uno::Reference<ucb::XCommandEnvironment>()); + } catch (lang::IllegalArgumentException& ) { OSL_ASSERT(0); } OSL_ASSERT(extensions.getLength() == 3); @@ -415,7 +404,7 @@ void UpdateDialog::Thread::execute() dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension( bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion); - css::uno::Reference<css::deployment::XPackage> updateSource; + uno::Reference<deployment::XPackage> updateSource; if (sourceUser != dp_misc::UPDATE_SOURCE_NONE) { if (sourceUser == dp_misc::UPDATE_SOURCE_SHARED) @@ -452,11 +441,11 @@ void UpdateDialog::Thread::execute() } } #if 0 -void UpdateDialog::Thread::handleGeneralError(css::uno::Any const & exception) +void UpdateDialog::Thread::handleGeneralError(uno::Any const & exception) const { rtl::OUString message; - css::uno::Exception e; + uno::Exception e; if (exception >>= e) { message = e.Message; } @@ -468,13 +457,13 @@ void UpdateDialog::Thread::handleGeneralError(css::uno::Any const & exception) #endif //Parameter package can be null void UpdateDialog::Thread::handleSpecificError( - css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Any const & exception) const + uno::Reference< deployment::XPackage > const & package, + uno::Any const & exception) const { UpdateDialog::SpecificError data; if (package.is()) data.name = package->getDisplayName(); - css::uno::Exception e; + uno::Exception e; if (exception >>= e) { data.message = e.Message; } @@ -516,7 +505,7 @@ void UpdateDialog::Thread::handleSpecificError( /** out_data will only be filled if all dependencies are ok. */ void UpdateDialog::Thread::prepareUpdateData( - css::uno::Reference< css::xml::dom::XNode > const & updateInfo, + uno::Reference< xml::dom::XNode > const & updateInfo, UpdateDialog::DisabledUpdate & out_du, dp_gui::UpdateData & out_data) const { @@ -524,7 +513,7 @@ void UpdateDialog::Thread::prepareUpdateData( return; dp_misc::DescriptionInfoset infoset(m_context, updateInfo); OSL_ASSERT(infoset.getVersion().getLength() != 0); - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > ds( + uno::Sequence< uno::Reference< xml::dom::XElement > > ds( dp_misc::Dependencies::check(infoset)); out_du.aUpdateInfo = updateInfo; @@ -547,8 +536,8 @@ void UpdateDialog::Thread::prepareUpdateData( } bool UpdateDialog::Thread::update( - UpdateDialog::DisabledUpdate const & du, - dp_gui::UpdateData const & data) const + UpdateDialog::DisabledUpdate & du, + dp_gui::UpdateData & data) const { bool ret = false; if (du.unsatisfiedDependencies.getLength() == 0) @@ -570,9 +559,9 @@ bool UpdateDialog::Thread::update( // UpdateDialog ---------------------------------------------------------- UpdateDialog::UpdateDialog( - css::uno::Reference< css::uno::XComponentContext > const & context, + uno::Reference< uno::XComponentContext > const & context, Window * parent, - const std::vector<css::uno::Reference< css::deployment::XPackage > > &vExtensionList, + const std::vector<uno::Reference< deployment::XPackage > > &vExtensionList, std::vector< dp_gui::UpdateData > * updateData): ModalDialog(parent,DpGuiResId(RID_DLG_UPDATE)), m_context(context), @@ -592,7 +581,7 @@ UpdateDialog::UpdateDialog( m_line(this, DpGuiResId(RID_DLG_UPDATE_LINE)), m_help(this, DpGuiResId(RID_DLG_UPDATE_HELP)), m_ok(this, DpGuiResId(RID_DLG_UPDATE_OK)), - m_cancel(this, DpGuiResId(RID_DLG_UPDATE_CANCEL)), + m_close(this, DpGuiResId(RID_DLG_UPDATE_CLOSE)), m_error(String(DpGuiResId(RID_DLG_UPDATE_ERROR))), m_none(String(DpGuiResId(RID_DLG_UPDATE_NONE))), m_noInstallable(String(DpGuiResId(RID_DLG_UPDATE_NOINSTALLABLE))), @@ -604,71 +593,84 @@ UpdateDialog::UpdateDialog( m_noDependencyCurVer(String(DpGuiResId(RID_DLG_UPDATE_NODEPENDENCY_CUR_VER))), m_browserbased(String(DpGuiResId(RID_DLG_UPDATE_BROWSERBASED))), m_version(String(DpGuiResId(RID_DLG_UPDATE_VERSION))), + m_ignoredUpdate(String(DpGuiResId(RID_DLG_UPDATE_IGNORED_UPDATE))), m_updateData(*updateData), m_thread( new UpdateDialog::Thread( context, *this, vExtensionList)), m_nFirstLineDelta(0), - m_nOneLineMissing(0) + m_nOneLineMissing(0), + m_nLastID(1), + m_bModified( false ) // TODO: check! // , // m_extensionManagerDialog(extensionManagerDialog) { OSL_ASSERT(updateData != NULL); - m_xExtensionManager = css::deployment::ExtensionManager::get( context ); + m_xExtensionManager = deployment::ExtensionManager::get( context ); - css::uno::Reference< css::awt::XToolkit > toolkit; + uno::Reference< awt::XToolkit > toolkit; try { - toolkit = css::uno::Reference< css::awt::XToolkit >( - (css::uno::Reference< css::lang::XMultiComponentFactory >( + toolkit = uno::Reference< awt::XToolkit >( + (uno::Reference< lang::XMultiComponentFactory >( m_context->getServiceManager(), - css::uno::UNO_QUERY_THROW)-> + uno::UNO_QUERY_THROW)-> createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.Toolkit")), m_context)), - css::uno::UNO_QUERY_THROW); - } catch (css::uno::RuntimeException &) { + uno::UNO_QUERY_THROW); + } catch (uno::RuntimeException &) { throw; - } catch (css::uno::Exception & e) { - throw css::uno::RuntimeException(e.Message, e.Context); + } catch (uno::Exception & e) { + throw uno::RuntimeException(e.Message, e.Context); } Control c(this, DpGuiResId(RID_DLG_UPDATE_THROBBER)); Point pos(c.GetPosPixel()); Size size(c.GetSizePixel()); try { - m_throbber = css::uno::Reference< css::awt::XThrobber >( + m_throbber = uno::Reference< awt::XThrobber >( toolkit->createWindow( - css::awt::WindowDescriptor( - css::awt::WindowClass_SIMPLE, + awt::WindowDescriptor( + awt::WindowClass_SIMPLE, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Throbber")), GetComponentInterface(), 0, - css::awt::Rectangle( + awt::Rectangle( pos.X(), pos.Y(), size.Width(), size.Height()), - css::awt::WindowAttribute::SHOW)), - css::uno::UNO_QUERY_THROW); - } catch (css::lang::IllegalArgumentException & e) { - throw css::uno::RuntimeException(e.Message, e.Context); + awt::WindowAttribute::SHOW)), + uno::UNO_QUERY_THROW); + } catch (lang::IllegalArgumentException & e) { + throw uno::RuntimeException(e.Message, e.Context); } m_updates.SetSelectHdl(LINK(this, UpdateDialog, selectionHandler)); m_all.SetToggleHdl(LINK(this, UpdateDialog, allHandler)); m_ok.SetClickHdl(LINK(this, UpdateDialog, okHandler)); - m_cancel.SetClickHdl(LINK(this, UpdateDialog, cancelHandler)); + m_close.SetClickHdl(LINK(this, UpdateDialog, closeHandler)); if ( ! dp_misc::office_is_running()) m_help.Disable(); FreeResource(); initDescription(); + getIgnoredUpdates(); } -UpdateDialog::~UpdateDialog() { - for (USHORT i = 0; i < m_updates.getItemCount(); ++i) { - delete static_cast< UpdateDialog::Index const * >( - m_updates.GetEntryData(i)); +//------------------------------------------------------------------------------ +UpdateDialog::~UpdateDialog() +{ + storeIgnoredUpdates(); + + for ( std::vector< UpdateDialog::Index* >::iterator i( m_ListboxEntries.begin() ); i != m_ListboxEntries.end(); ++i ) + { + delete (*i); + } + for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i ) + { + delete (*i); } } +//------------------------------------------------------------------------------ BOOL UpdateDialog::Close() { m_thread->stop(); return ModalDialog::Close(); @@ -680,29 +682,45 @@ short UpdateDialog::Execute() { return ModalDialog::Execute(); } -UpdateDialog::CheckListBox::CheckListBox( - UpdateDialog & dialog, ResId const & resource, - Image const & normalStaticImage, Image const & highContrastStaticImage): - SvxCheckListBox( - &dialog, resource, normalStaticImage, highContrastStaticImage), +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +UpdateDialog::CheckListBox::CheckListBox( UpdateDialog & dialog, ResId const & resource, + Image const & normalStaticImage, + Image const & highContrastStaticImage ): + SvxCheckListBox( &dialog, resource, normalStaticImage, highContrastStaticImage ), + m_ignoreUpdate( String( DpGuiResId( RID_DLG_UPDATE_IGNORE ) ) ), + m_ignoreAllUpdates( String( DpGuiResId( RID_DLG_UPDATE_IGNORE_ALL ) ) ), + m_enableUpdate( String( DpGuiResId( RID_DLG_UPDATE_ENABLE ) ) ), m_dialog(dialog) {} +//------------------------------------------------------------------------------ UpdateDialog::CheckListBox::~CheckListBox() {} +//------------------------------------------------------------------------------ USHORT UpdateDialog::CheckListBox::getItemCount() const { ULONG i = GetEntryCount(); OSL_ASSERT(i <= std::numeric_limits< USHORT >::max()); return sal::static_int_cast< USHORT >(i); } -void UpdateDialog::CheckListBox::MouseButtonDown(MouseEvent const & event) { +//------------------------------------------------------------------------------ +void UpdateDialog::CheckListBox::MouseButtonDown( MouseEvent const & event ) +{ // When clicking on a selected entry in an SvxCheckListBox, the entry's // checkbox is toggled on mouse button down: - SvxCheckListBox::MouseButtonDown(event); + SvxCheckListBox::MouseButtonDown( event ); + + if ( event.IsRight() ) + { + handlePopupMenu( event.GetPosPixel() ); + } + m_dialog.enableOk(); } +//------------------------------------------------------------------------------ void UpdateDialog::CheckListBox::MouseButtonUp(MouseEvent const & event) { // When clicking on an entry's checkbox in an SvxCheckListBox, the entry's // checkbox is toggled on mouse button up: @@ -715,25 +733,82 @@ void UpdateDialog::CheckListBox::KeyInput(KeyEvent const & event) { m_dialog.enableOk(); } -void UpdateDialog::insertItem( - rtl::OUString const & name, USHORT position, - std::auto_ptr< UpdateDialog::Index const > index, SvLBoxButtonKind kind) +//------------------------------------------------------------------------------ +void UpdateDialog::CheckListBox::handlePopupMenu( const Point &rPos ) { - m_updates.InsertEntry( - name, position, - const_cast< void * >(static_cast< void const * >(index.release())), - kind); - //TODO #i72487#: UpdateDialog::Index potentially leaks as the exception - // behavior of SvxCheckListBox::InsertEntry is unspecified + SvListEntry *pData = GetEntry( rPos ); + + if ( pData ) + { + USHORT nEntryPos = GetSelectEntryPos(); + UpdateDialog::Index * p = static_cast< UpdateDialog::Index * >( GetEntryData( nEntryPos ) ); + + if ( ( p->m_eKind == ENABLED_UPDATE ) || ( p->m_eKind == DISABLED_UPDATE ) ) + { + PopupMenu aPopup; + + if ( p->m_bIgnored ) + aPopup.InsertItem( CMD_ENABLE_UPDATE, m_enableUpdate ); + else + { + aPopup.InsertItem( CMD_IGNORE_UPDATE, m_ignoreUpdate ); + aPopup.InsertItem( CMD_IGNORE_ALL_UPDATES, m_ignoreAllUpdates ); + } + + USHORT aCmd = aPopup.Execute( this, rPos ); + if ( ( aCmd == CMD_IGNORE_UPDATE ) || ( aCmd == CMD_IGNORE_ALL_UPDATES ) ) + { + p->m_bIgnored = true; + if ( p->m_eKind == ENABLED_UPDATE ) + { + RemoveEntry( nEntryPos ); + m_dialog.addAdditional( p, SvLBoxButtonKind_disabledCheckbox ); + } + if ( aCmd == CMD_IGNORE_UPDATE ) + m_dialog.setIgnoredUpdate( p, true, false ); + else + m_dialog.setIgnoredUpdate( p, true, true ); + // TODO: reselect entry to display new description! + } + else if ( aCmd == CMD_ENABLE_UPDATE ) + { + p->m_bIgnored = false; + if ( p->m_eKind == ENABLED_UPDATE ) + { + RemoveEntry( nEntryPos ); + m_dialog.insertItem( p, SvLBoxButtonKind_enabledCheckbox ); + } + m_dialog.setIgnoredUpdate( p, false, false ); + } + } + } } -void UpdateDialog::addAdditional( - rtl::OUString const & name, USHORT position, - std::auto_ptr< UpdateDialog::Index const > index, SvLBoxButtonKind kind) +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +USHORT UpdateDialog::insertItem( UpdateDialog::Index *pEntry, SvLBoxButtonKind kind ) +{ + m_updates.InsertEntry( pEntry->m_aName, LISTBOX_APPEND, static_cast< void * >( pEntry ), kind ); + + for ( USHORT i = m_updates.getItemCount(); i != 0 ; ) + { + i -= 1; + UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >( m_updates.GetEntryData( i ) ); + if ( p == pEntry ) + return i; + } + OSL_ASSERT(0); + return 0; +} + +//------------------------------------------------------------------------------ +void UpdateDialog::addAdditional( UpdateDialog::Index * index, SvLBoxButtonKind kind ) { m_all.Enable(); - if (m_all.IsChecked()) { - insertItem(name, position, index, kind); + if (m_all.IsChecked()) + { + insertItem( index, kind ); m_update.Enable(); m_updates.Enable(); m_description.Enable(); @@ -741,71 +816,81 @@ void UpdateDialog::addAdditional( } } -void UpdateDialog::addEnabledUpdate( - rtl::OUString const & name, dp_gui::UpdateData const & data) +//------------------------------------------------------------------------------ +void UpdateDialog::addEnabledUpdate( rtl::OUString const & name, + dp_gui::UpdateData & data ) { - std::vector< dp_gui::UpdateData >::size_type n = m_enabledUpdates.size(); - m_enabledUpdates.push_back(data); - insertItem( - name, sal::static_int_cast< USHORT >(n), - UpdateDialog::Index::newEnabledUpdate(n), - SvLBoxButtonKind_enabledCheckbox); - // position overflow is rather harmless - m_updates.CheckEntryPos(sal::static_int_cast< USHORT >(n)); - //TODO #i72487#: fragile computation; insertItem should instead return - // pos + USHORT nIndex = sal::static_int_cast< USHORT >( m_enabledUpdates.size() ); + UpdateDialog::Index *pEntry = new UpdateDialog::Index( ENABLED_UPDATE, m_nLastID, nIndex, name ); + + data.m_nID = m_nLastID; + m_nLastID += 1; + + m_enabledUpdates.push_back( data ); + m_ListboxEntries.push_back( pEntry ); + + if ( ! isIgnoredUpdate( pEntry ) ) + { + USHORT nPos = insertItem( pEntry, SvLBoxButtonKind_enabledCheckbox ); + m_updates.CheckEntryPos( nPos ); + } + else + addAdditional( pEntry, SvLBoxButtonKind_disabledCheckbox ); + m_update.Enable(); m_updates.Enable(); m_description.Enable(); m_descriptions.Enable(); } -void UpdateDialog::addDisabledUpdate(UpdateDialog::DisabledUpdate const & data) +//------------------------------------------------------------------------------ +void UpdateDialog::addDisabledUpdate( UpdateDialog::DisabledUpdate & data ) { - std::vector< UpdateDialog::DisabledUpdate >::size_type n = - m_disabledUpdates.size(); - m_disabledUpdates.push_back(data); - addAdditional( - data.name, sal::static_int_cast< USHORT >(m_enabledUpdates.size() + n), - UpdateDialog::Index::newDisabledUpdate(n), - SvLBoxButtonKind_disabledCheckbox); - // position overflow is rather harmless -} -#if 0 -void UpdateDialog::addGeneralError(rtl::OUString const & message) { - std::vector< rtl::OUString >::size_type n = m_generalErrors.size(); - m_generalErrors.push_back(message); - addAdditional( - m_error, - sal::static_int_cast< USHORT >( - m_enabledUpdates.size() + m_disabledUpdates.size() + n), - UpdateDialog::Index::newGeneralError(n), SvLBoxButtonKind_staticImage); - // position overflow is rather harmless + USHORT nIndex = sal::static_int_cast< USHORT >( m_disabledUpdates.size() ); + UpdateDialog::Index *pEntry = new UpdateDialog::Index( DISABLED_UPDATE, m_nLastID, nIndex, data.name ); + + data.m_nID = m_nLastID; + m_nLastID += 1; + + m_disabledUpdates.push_back( data ); + m_ListboxEntries.push_back( pEntry ); + + isIgnoredUpdate( pEntry ); + addAdditional( pEntry, SvLBoxButtonKind_disabledCheckbox ); } -#endif -void UpdateDialog::addSpecificError(UpdateDialog::SpecificError const & data) { - std::vector< UpdateDialog::SpecificError >::size_type n = - m_specificErrors.size(); - m_specificErrors.push_back(data); - addAdditional( - data.name, LISTBOX_APPEND, UpdateDialog::Index::newSpecificError(n), - SvLBoxButtonKind_staticImage); + +//------------------------------------------------------------------------------ +void UpdateDialog::addSpecificError( UpdateDialog::SpecificError & data ) +{ + USHORT nIndex = sal::static_int_cast< USHORT >( m_specificErrors.size() ); + UpdateDialog::Index *pEntry = new UpdateDialog::Index( DISABLED_UPDATE, m_nLastID, nIndex, data.name ); + + data.m_nID = m_nLastID; + m_nLastID += 1; + + m_specificErrors.push_back( data ); + m_ListboxEntries.push_back( pEntry ); + + addAdditional( pEntry, SvLBoxButtonKind_staticImage); } void UpdateDialog::checkingDone() { m_checking.Hide(); m_throbber->stop(); - css::uno::Reference< css::awt::XWindow >( - m_throbber, css::uno::UNO_QUERY_THROW)->setVisible(false); + uno::Reference< awt::XWindow >( + m_throbber, uno::UNO_QUERY_THROW)->setVisible(false); if (m_updates.getItemCount() == 0) { clearDescription(); m_description.Enable(); m_descriptions.Enable(); - showDescription( - ( m_disabledUpdates.empty() && m_generalErrors.empty() && m_specificErrors.empty() ) - ? m_none : m_noInstallable, false ); + + if ( m_disabledUpdates.empty() && m_specificErrors.empty() && m_ignoredUpdates.empty() ) + showDescription( m_none, false ); + else + showDescription( m_noInstallable, false ); } + enableOk(); } @@ -817,7 +902,7 @@ void UpdateDialog::enableOk() { // ********************************************************************************* void UpdateDialog::createNotifyJob( bool bPrepareOnly, - css::uno::Sequence< css::uno::Sequence< rtl::OUString > > &rItemList ) + uno::Sequence< uno::Sequence< rtl::OUString > > &rItemList ) { if ( !dp_misc::office_is_running() ) return; @@ -825,51 +910,51 @@ void UpdateDialog::createNotifyJob( bool bPrepareOnly, // notify update check job try { - css::uno::Reference< css::lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider( + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + uno::Reference< lang::XMultiServiceFactory > xConfigProvider( xFactory->createInstance( OUSTR( "com.sun.star.configuration.ConfigurationProvider" )), - css::uno::UNO_QUERY_THROW); + uno::UNO_QUERY_THROW); - css::beans::PropertyValue aProperty; + beans::PropertyValue aProperty; aProperty.Name = OUSTR( "nodepath" ); - aProperty.Value = css::uno::makeAny( OUSTR("org.openoffice.Office.Addons/AddonUI/OfficeHelp/UpdateCheckJob") ); + aProperty.Value = uno::makeAny( OUSTR("org.openoffice.Office.Addons/AddonUI/OfficeHelp/UpdateCheckJob") ); - css::uno::Sequence< css::uno::Any > aArgumentList( 1 ); - aArgumentList[0] = css::uno::makeAny( aProperty ); + uno::Sequence< uno::Any > aArgumentList( 1 ); + aArgumentList[0] = uno::makeAny( aProperty ); - css::uno::Reference< css::container::XNameAccess > xNameAccess( + uno::Reference< container::XNameAccess > xNameAccess( xConfigProvider->createInstanceWithArguments( OUSTR("com.sun.star.configuration.ConfigurationAccess"), aArgumentList ), - css::uno::UNO_QUERY_THROW ); + uno::UNO_QUERY_THROW ); - css::util::URL aURL; + util::URL aURL; xNameAccess->getByName(OUSTR("URL")) >>= aURL.Complete; - css::uno::Reference < css::util::XURLTransformer > xTransformer( xFactory->createInstance( OUSTR( "com.sun.star.util.URLTransformer" ) ), - css::uno::UNO_QUERY_THROW ); + uno::Reference < util::XURLTransformer > xTransformer( xFactory->createInstance( OUSTR( "com.sun.star.util.URLTransformer" ) ), + uno::UNO_QUERY_THROW ); xTransformer->parseStrict(aURL); - css::uno::Reference < css::frame::XDesktop > xDesktop( xFactory->createInstance( OUSTR( "com.sun.star.frame.Desktop" ) ), - css::uno::UNO_QUERY_THROW ); - css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( xDesktop->getCurrentFrame(), - css::uno::UNO_QUERY_THROW ); - css::uno::Reference< css::frame::XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL, rtl::OUString(), 0); + uno::Reference < frame::XDesktop > xDesktop( xFactory->createInstance( OUSTR( "com.sun.star.frame.Desktop" ) ), + uno::UNO_QUERY_THROW ); + uno::Reference< frame::XDispatchProvider > xDispatchProvider( xDesktop->getCurrentFrame(), + uno::UNO_QUERY_THROW ); + uno::Reference< frame::XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL, rtl::OUString(), 0); if( xDispatch.is() ) { - css::uno::Sequence< css::beans::PropertyValue > aPropList(2); + uno::Sequence< beans::PropertyValue > aPropList(2); aProperty.Name = OUSTR( "updateList" ); - aProperty.Value = css::uno::makeAny( rItemList ); + aProperty.Value = uno::makeAny( rItemList ); aPropList[0] = aProperty; aProperty.Name = OUSTR( "prepareOnly" ); - aProperty.Value = css::uno::makeAny( bPrepareOnly ); + aProperty.Value = uno::makeAny( bPrepareOnly ); aPropList[1] = aProperty; xDispatch->dispatch(aURL, aPropList ); } } - catch( const css::uno::Exception& e ) + catch( const uno::Exception& e ) { dp_misc::TRACE( OUSTR("Caught exception: ") + e.Message + OUSTR("\n thread terminated.\n\n")); @@ -882,26 +967,26 @@ void UpdateDialog::notifyMenubar( bool bPrepareOnly, bool bRecheckOnly ) if ( !dp_misc::office_is_running() ) return; - css::uno::Sequence< css::uno::Sequence< rtl::OUString > > aItemList; + uno::Sequence< uno::Sequence< rtl::OUString > > aItemList; sal_Int32 nCount = 0; if ( ! bRecheckOnly ) { for ( sal_Int16 i = 0; i < m_updates.getItemCount(); ++i ) { - css::uno::Sequence< rtl::OUString > aItem(2); + uno::Sequence< rtl::OUString > aItem(2); UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >(m_updates.GetEntryData(i)); - if ( p->kind == ENABLED_UPDATE ) + if ( p->m_eKind == ENABLED_UPDATE ) { - dp_gui::UpdateData aUpdData = m_enabledUpdates[ p->index.enabledUpdate ]; + dp_gui::UpdateData aUpdData = m_enabledUpdates[ p->m_nIndex ]; aItem[0] = dp_misc::getIdentifier( aUpdData.aInstalledPackage ); dp_misc::DescriptionInfoset aInfoset( m_context, aUpdData.aUpdateInfo ); aItem[1] = aInfoset.getVersion(); } - else if ( p->kind == DISABLED_UPDATE ) + else if ( p->m_eKind == DISABLED_UPDATE ) continue; else continue; @@ -911,6 +996,8 @@ void UpdateDialog::notifyMenubar( bool bPrepareOnly, bool bRecheckOnly ) nCount += 1; } } + + storeIgnoredUpdates(); createNotifyJob( bPrepareOnly, aItemList ); } @@ -984,17 +1071,17 @@ void UpdateDialog::clearDescription() m_descriptions.SetPosSizePixel( m_aFirstLinePos, m_aFirstLineSize ); } -bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > const & aUpdateInfo) +bool UpdateDialog::showDescription(uno::Reference< xml::dom::XNode > const & aUpdateInfo) { dp_misc::DescriptionInfoset infoset(m_context, aUpdateInfo); return showDescription(infoset.getLocalizedPublisherNameAndURL(), infoset.getLocalizedReleaseNotesURL()); } -bool UpdateDialog::showDescription(css::uno::Reference< css::deployment::XPackage > const & aExtension) +bool UpdateDialog::showDescription(uno::Reference< deployment::XPackage > const & aExtension) { OSL_ASSERT(aExtension.is()); - css::beans::StringPair pubInfo = aExtension->getPublisherInfo(); + beans::StringPair pubInfo = aExtension->getPublisherInfo(); return showDescription(std::make_pair(pubInfo.First, pubInfo.Second), OUSTR("")); } @@ -1057,7 +1144,7 @@ bool UpdateDialog::showDescription( const String& rDescription, bool bWithPublis return true; } -bool UpdateDialog::isReadOnly( const css::uno::Reference< css::deployment::XPackage > &xPackage ) const +bool UpdateDialog::isReadOnly( const uno::Reference< deployment::XPackage > &xPackage ) const { if ( m_xExtensionManager.is() && xPackage.is() ) { @@ -1067,6 +1154,162 @@ bool UpdateDialog::isReadOnly( const css::uno::Reference< css::deployment::XPack return true; } +//------------------------------------------------------------------------------ +void UpdateDialog::getIgnoredUpdates() +{ + uno::Reference< lang::XMultiServiceFactory > xConfig( m_context->getServiceManager()->createInstanceWithContext( + OUSTR("com.sun.star.configuration.ConfigurationProvider"), m_context ), uno::UNO_QUERY_THROW); + beans::NamedValue aValue( OUSTR("nodepath"), uno::Any( IGNORED_UPDATES ) ); + uno::Sequence< uno::Any > args(1); + args[0] <<= aValue; + + uno::Reference< container::XNameAccess > xNameAccess( xConfig->createInstanceWithArguments( OUSTR("com.sun.star.configuration.ConfigurationAccess"), args), uno::UNO_QUERY_THROW ); + uno::Sequence< rtl::OUString > aElementNames = xNameAccess->getElementNames(); + + for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ ) + { + ::rtl::OUString aIdentifier = aElementNames[i]; + ::rtl::OUString aVersion; + + uno::Any aPropValue( uno::Reference< beans::XPropertySet >( xNameAccess->getByName( aIdentifier ), uno::UNO_QUERY_THROW )->getPropertyValue( PROPERTY_VERSION ) ); + aPropValue >>= aVersion; + IgnoredUpdate *pData = new IgnoredUpdate( aIdentifier, aVersion ); + m_ignoredUpdates.push_back( pData ); + } +} + +//------------------------------------------------------------------------------ +void UpdateDialog::storeIgnoredUpdates() +{ + if ( m_bModified && ( m_ignoredUpdates.size() != 0 ) ) + { + uno::Reference< lang::XMultiServiceFactory > xConfig( m_context->getServiceManager()->createInstanceWithContext( + OUSTR("com.sun.star.configuration.ConfigurationProvider"), m_context ), uno::UNO_QUERY_THROW ); + beans::NamedValue aValue( OUSTR("nodepath"), uno::Any( IGNORED_UPDATES ) ); + uno::Sequence< uno::Any > args(1); + args[0] <<= aValue; + + uno::Reference< container::XNameContainer > xNameContainer( xConfig->createInstanceWithArguments( + OUSTR("com.sun.star.configuration.ConfigurationUpdateAccess"), args ), uno::UNO_QUERY_THROW ); + + for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i ) + { + if ( xNameContainer->hasByName( (*i)->sExtensionID ) ) + { + if ( (*i)->bRemoved ) + xNameContainer->removeByName( (*i)->sExtensionID ); + else + uno::Reference< beans::XPropertySet >( xNameContainer->getByName( (*i)->sExtensionID ), uno::UNO_QUERY_THROW )->setPropertyValue( PROPERTY_VERSION, uno::Any( (*i)->sVersion ) ); + } + else if ( ! (*i)->bRemoved ) + { + uno::Reference< beans::XPropertySet > elem( uno::Reference< lang::XSingleServiceFactory >( xNameContainer, uno::UNO_QUERY_THROW )->createInstance(), uno::UNO_QUERY_THROW ); + elem->setPropertyValue( PROPERTY_VERSION, uno::Any( (*i)->sVersion ) ); + xNameContainer->insertByName( (*i)->sExtensionID, uno::Any( elem ) ); + } + } + + uno::Reference< util::XChangesBatch > xChangesBatch( xNameContainer, uno::UNO_QUERY ); + if ( xChangesBatch.is() && xChangesBatch->hasPendingChanges() ) + xChangesBatch->commitChanges(); + } + + m_bModified = false; +} + +//------------------------------------------------------------------------------ +bool UpdateDialog::isIgnoredUpdate( UpdateDialog::Index * index ) +{ + bool bIsIgnored = false; + + if ( m_ignoredUpdates.size() != 0 ) + { + rtl::OUString aExtensionID; + rtl::OUString aVersion; + + if ( index->m_eKind == ENABLED_UPDATE ) + { + dp_gui::UpdateData aUpdData = m_enabledUpdates[ index->m_nIndex ]; + aExtensionID = dp_misc::getIdentifier( aUpdData.aInstalledPackage ); + aVersion = aUpdData.updateVersion; + } + else if ( index->m_eKind == DISABLED_UPDATE ) + { + DisabledUpdate &rData = m_disabledUpdates[ index->m_nIndex ]; + dp_misc::DescriptionInfoset aInfoset( m_context, rData.aUpdateInfo ); + ::boost::optional< ::rtl::OUString > aID( aInfoset.getIdentifier() ); + if ( aID ) + aExtensionID = *aID; + aVersion = aInfoset.getVersion(); + } + + for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i ) + { + if ( (*i)->sExtensionID == aExtensionID ) + { + if ( ( (*i)->sVersion.getLength() == 0 ) || ( (*i)->sVersion == aVersion ) ) + { + bIsIgnored = true; + index->m_bIgnored = true; + } + else // when we find another update of an ignored version, we will remove the old one to keep the ignored list small + (*i)->bRemoved = true; + break; + } + } + } + + return bIsIgnored; +} + +//------------------------------------------------------------------------------ +void UpdateDialog::setIgnoredUpdate( UpdateDialog::Index *pIndex, bool bIgnore, bool bIgnoreAll ) +{ + rtl::OUString aExtensionID; + rtl::OUString aVersion; + + m_bModified = true; + + if ( pIndex->m_eKind == ENABLED_UPDATE ) + { + dp_gui::UpdateData aUpdData = m_enabledUpdates[ pIndex->m_nIndex ]; + aExtensionID = dp_misc::getIdentifier( aUpdData.aInstalledPackage ); + if ( !bIgnoreAll ) + aVersion = aUpdData.updateVersion; + } + else if ( pIndex->m_eKind == DISABLED_UPDATE ) + { + DisabledUpdate &rData = m_disabledUpdates[ pIndex->m_nIndex ]; + dp_misc::DescriptionInfoset aInfoset( m_context, rData.aUpdateInfo ); + ::boost::optional< ::rtl::OUString > aID( aInfoset.getIdentifier() ); + if ( aID ) + aExtensionID = *aID; + if ( !bIgnoreAll ) + aVersion = aInfoset.getVersion(); + } + + if ( aExtensionID.getLength() ) + { + bool bFound = false; + for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i ) + { + if ( (*i)->sExtensionID == aExtensionID ) + { + (*i)->sVersion = aVersion; + (*i)->bRemoved = !bIgnore; + bFound = true; + break; + } + } + if ( bIgnore && !bFound ) + { + IgnoredUpdate *pData = new IgnoredUpdate( aExtensionID, aVersion ); + m_ignoredUpdates.push_back( pData ); + } + } +} + +//------------------------------------------------------------------------------ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) { rtl::OUStringBuffer b; @@ -1075,38 +1318,32 @@ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) m_updates.GetEntryData(m_updates.GetSelectEntryPos())); clearDescription(); - if (p != NULL) + if ( p != NULL ) { - //When the index is greater or equal than the amount of enabled updates then the "Show all" - //button is probably checked. Then we show first all enabled and then the disabled - //updates. - USHORT pos = m_updates.GetSelectEntryPos(); - const std::vector< dp_gui::UpdateData >::size_type sizeEnabled = - m_enabledUpdates.size(); - const std::vector< UpdateDialog::DisabledUpdate >::size_type sizeDisabled = - m_disabledUpdates.size(); - if (pos < sizeEnabled) - { - if (m_enabledUpdates[pos].aUpdateSource.is()) - bInserted = showDescription(m_enabledUpdates[pos].aUpdateSource); - else - bInserted = showDescription(m_enabledUpdates[pos].aUpdateInfo); - } - else if (pos >= sizeEnabled - && pos < (sizeEnabled + sizeDisabled)) - bInserted = showDescription(m_disabledUpdates[pos - sizeEnabled].aUpdateInfo); + USHORT pos = p->m_nIndex; - switch (p->kind) + switch (p->m_eKind) { case ENABLED_UPDATE: { - b.append(m_noDescription); + if ( m_enabledUpdates[ pos ].aUpdateSource.is() ) + bInserted = showDescription( m_enabledUpdates[ pos ].aUpdateSource ); + else + bInserted = showDescription( m_enabledUpdates[ pos ].aUpdateInfo ); + + if ( p->m_bIgnored ) + b.append( m_ignoredUpdate ); + break; } case DISABLED_UPDATE: { - UpdateDialog::DisabledUpdate & data = m_disabledUpdates[ - p->index.disabledUpdate]; + bInserted = showDescription( m_disabledUpdates[pos].aUpdateInfo ); + + if ( p->m_bIgnored ) + b.append( m_ignoredUpdate ); + + UpdateDialog::DisabledUpdate & data = m_disabledUpdates[ pos ]; if (data.unsatisfiedDependencies.getLength() != 0) { // create error string for version mismatch @@ -1139,23 +1376,12 @@ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) } break; } - case GENERAL_ERROR: - { - rtl::OUString & msg = m_generalErrors[p->index.generalError]; - b.append(m_failure); - b.append(LF); - b.append(msg.getLength() == 0 ? m_unknownError : msg); - break; - } case SPECIFIC_ERROR: { - UpdateDialog::SpecificError & data = m_specificErrors[ - p->index.specificError]; + UpdateDialog::SpecificError & data = m_specificErrors[ pos ]; b.append(m_failure); b.append(LF); - b.append( - data.message.getLength() == 0 - ? m_unknownError : data.message); + b.append( data.message.getLength() == 0 ? m_unknownError : data.message ); break; } default: @@ -1164,56 +1390,37 @@ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) } } + if ( b.getLength() == 0 ) + b.append( m_noDescription ); + showDescription( b.makeStringAndClear(), bInserted ); return 0; } -IMPL_LINK(UpdateDialog, allHandler, void *, EMPTYARG) { - if (m_all.IsChecked()) { +IMPL_LINK(UpdateDialog, allHandler, void *, EMPTYARG) +{ + if (m_all.IsChecked()) + { m_update.Enable(); m_updates.Enable(); m_description.Enable(); m_descriptions.Enable(); - std::vector< UpdateDialog::DisabledUpdate >::size_type n1 = 0; - for (std::vector< UpdateDialog::DisabledUpdate >::iterator i( - m_disabledUpdates.begin()); - i != m_disabledUpdates.end(); ++i) - { - insertItem( - i->name, LISTBOX_APPEND, - UpdateDialog::Index::newDisabledUpdate(n1++), - SvLBoxButtonKind_disabledCheckbox); - } - std::vector< rtl::OUString >::size_type n2 = 0; - for (std::vector< rtl::OUString >::iterator i(m_generalErrors.begin()); - i != m_generalErrors.end(); ++i) + + for (std::vector< UpdateDialog::Index* >::iterator i( m_ListboxEntries.begin() ); + i != m_ListboxEntries.end(); ++i ) { - insertItem( - m_error, LISTBOX_APPEND, - UpdateDialog::Index::newGeneralError(n2++), - SvLBoxButtonKind_staticImage); + if ( (*i)->m_bIgnored || ( (*i)->m_eKind != ENABLED_UPDATE ) ) + insertItem( (*i), SvLBoxButtonKind_disabledCheckbox ); } - std::vector< UpdateDialog::SpecificError >::size_type n3 = 0; - for (std::vector< UpdateDialog::SpecificError >::iterator i( - m_specificErrors.begin()); - i != m_specificErrors.end(); ++i) + } + else + { + for ( USHORT i = 0; i < m_updates.getItemCount(); ) { - insertItem( - i->name, LISTBOX_APPEND, - UpdateDialog::Index::newSpecificError(n3++), - SvLBoxButtonKind_staticImage); - } - } else { - for (USHORT i = 0; i < m_updates.getItemCount();) { - UpdateDialog::Index const * p = - static_cast< UpdateDialog::Index const * >( - m_updates.GetEntryData(i)); - if (p->kind != ENABLED_UPDATE) { + UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >( m_updates.GetEntryData(i) ); + if ( p->m_bIgnored || ( p->m_eKind != ENABLED_UPDATE ) ) + { m_updates.RemoveEntry(i); - //TODO #i72487#: UpdateDialog::Index potentially leaks as - // SvxCheckListBox::RemoveEntry's exception behavior is - // unspecified - delete p; } else { ++i; } @@ -1260,8 +1467,8 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >( m_updates.GetEntryData(i)); - if (p->kind == ENABLED_UPDATE && m_updates.IsChecked(i)) { - m_updateData.push_back(m_enabledUpdates[p->index.enabledUpdate]); + if (p->m_eKind == ENABLED_UPDATE && m_updates.IsChecked(i)) { + m_updateData.push_back( m_enabledUpdates[ p->m_nIndex ] ); } } @@ -1269,7 +1476,7 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) return 0; } -IMPL_LINK(UpdateDialog, cancelHandler, void *, EMPTYARG) { +IMPL_LINK(UpdateDialog, closeHandler, void *, EMPTYARG) { m_thread->stop(); EndDialog(RET_CANCEL); return 0; @@ -1285,15 +1492,15 @@ IMPL_LINK( UpdateDialog, hyperlink_clicked, svt::FixedHyperlink*, pHyperlink ) try { - css::uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute( + uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute( m_context->getServiceManager()->createInstanceWithContext( OUSTR( "com.sun.star.system.SystemShellExecute" ), - m_context), css::uno::UNO_QUERY_THROW); - //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException + m_context), uno::UNO_QUERY_THROW); + //throws lang::IllegalArgumentException, system::SystemShellExecuteException xSystemShellExecute->execute( - sURL, ::rtl::OUString(), css::system::SystemShellExecuteFlags::DEFAULTS); + sURL, ::rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS); } - catch (css::uno::Exception& ) + catch (uno::Exception& ) { } diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx index 32c317cb8735..54e645f195d8 100644..100755 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx @@ -112,8 +112,7 @@ private: struct DisabledUpdate; struct SpecificError; - union IndexUnion; - friend union IndexUnion; + struct IgnoredUpdate; struct Index; friend struct Index; class Thread; @@ -135,40 +134,36 @@ private: void operator =(UpdateDialog::CheckListBox &); // not defined virtual void MouseButtonDown(MouseEvent const & event); - virtual void MouseButtonUp(MouseEvent const & event); - virtual void KeyInput(KeyEvent const & event); + void handlePopupMenu( const Point &rPos ); + + rtl::OUString m_ignoreUpdate; + rtl::OUString m_ignoreAllUpdates; + rtl::OUString m_enableUpdate; UpdateDialog & m_dialog; }; friend class CheckListBox; - void insertItem( - rtl::OUString const & name, USHORT position, - std::auto_ptr< UpdateDialog::Index const > index, - SvLBoxButtonKind kind); - - void addAdditional( - rtl::OUString const & name, USHORT position, - std::auto_ptr< UpdateDialog::Index const > index, - SvLBoxButtonKind kind); + USHORT insertItem( UpdateDialog::Index *pIndex, SvLBoxButtonKind kind ); + void addAdditional( UpdateDialog::Index *pIndex, SvLBoxButtonKind kind ); + bool isIgnoredUpdate( UpdateDialog::Index *pIndex ); + void setIgnoredUpdate( UpdateDialog::Index *pIndex, bool bIgnore, bool bIgnoreAll ); - void addEnabledUpdate( - rtl::OUString const & name, dp_gui::UpdateData const & data); - - void addDisabledUpdate(UpdateDialog::DisabledUpdate const & data); -#if 0 - void addGeneralError(rtl::OUString const & message); -#endif - void addSpecificError(UpdateDialog::SpecificError const & data); + void addEnabledUpdate( rtl::OUString const & name, dp_gui::UpdateData & data ); + void addDisabledUpdate( UpdateDialog::DisabledUpdate & data ); + void addSpecificError( UpdateDialog::SpecificError & data ); void checkingDone(); void enableOk(); + void getIgnoredUpdates(); + void storeIgnoredUpdates(); + void initDescription(); void clearDescription(); bool showDescription(::com::sun::star::uno::Reference< @@ -183,7 +178,7 @@ private: DECL_LINK(selectionHandler, void *); DECL_LINK(allHandler, void *); DECL_LINK(okHandler, void *); - DECL_LINK(cancelHandler, void *); + DECL_LINK(closeHandler, void *); DECL_LINK(hyperlink_clicked, svt::FixedHyperlink *); com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > @@ -202,7 +197,7 @@ private: FixedLine m_line; HelpButton m_help; PushButton m_ok; - CancelButton m_cancel; + PushButton m_close; rtl::OUString m_error; rtl::OUString m_none; rtl::OUString m_noInstallable; @@ -214,18 +209,22 @@ private: rtl::OUString m_noDependencyCurVer; rtl::OUString m_browserbased; rtl::OUString m_version; + rtl::OUString m_ignoredUpdate; std::vector< dp_gui::UpdateData > m_enabledUpdates; std::vector< UpdateDialog::DisabledUpdate > m_disabledUpdates; - std::vector< rtl::OUString > m_generalErrors; std::vector< UpdateDialog::SpecificError > m_specificErrors; + std::vector< UpdateDialog::IgnoredUpdate* > m_ignoredUpdates; + std::vector< Index* > m_ListboxEntries; std::vector< dp_gui::UpdateData > & m_updateData; rtl::Reference< UpdateDialog::Thread > m_thread; ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; - Point m_aFirstLinePos; - Size m_aFirstLineSize; - long m_nFirstLineDelta; - long m_nOneLineMissing; + Point m_aFirstLinePos; + Size m_aFirstLineSize; + long m_nFirstLineDelta; + long m_nOneLineMissing; + USHORT m_nLastID; + bool m_bModified; }; } diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.src b/desktop/source/deployment/gui/dp_gui_updatedialog.src index 20b7d30988fd..4da431733e31 100644..100755 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.src +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.src @@ -199,7 +199,7 @@ ModalDialog RID_DLG_UPDATE { Text[en-US] = "~Install"; DefButton = TRUE; }; - CancelButton RID_DLG_UPDATE_CANCEL { + PushButton RID_DLG_UPDATE_CLOSE { Pos = MAP_APPFONT( RSC_SP_DLG_INNERBORDER_LEFT + LOCAL_WIDTH - RSC_CD_PUSHBUTTON_WIDTH, (RSC_SP_DLG_INNERBORDER_TOP + RSC_CD_FIXEDTEXT_HEIGHT + @@ -208,6 +208,7 @@ ModalDialog RID_DLG_UPDATE { RSC_SP_CTRL_DESC_Y + LOCAL_LIST_HEIGHT2 + RSC_SP_FLGR_SPACE_Y + RSC_CD_FIXEDLINE_HEIGHT + RSC_SP_FLGR_SPACE_Y)); Size = MAP_APPFONT(RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT); + Text[en-US] = "Close"; }; Image RID_DLG_UPDATE_NORMALALERT { @@ -227,7 +228,7 @@ ModalDialog RID_DLG_UPDATE { Text[en-US] = "No new updates are available."; }; String RID_DLG_UPDATE_NOINSTALLABLE { - Text[en-US] = "No installable updates are available. To see all updates, mark the check box 'Show all updates'."; + Text[en-US] = "No installable updates are available. To see ignored or disabled updates, mark the check box 'Show all updates'."; }; String RID_DLG_UPDATE_FAILURE { Text[en-US] = "An error occurred:"; @@ -236,7 +237,7 @@ ModalDialog RID_DLG_UPDATE { Text[en-US] = "Unknown error."; }; String RID_DLG_UPDATE_NODESCRIPTION { - Text[en-US] = "No descriptions available for this extension."; + Text[en-US] = "No more details are available for this update."; }; String RID_DLG_UPDATE_NOINSTALL { Text[en-US] = "The extension cannot be updated because:"; @@ -250,10 +251,21 @@ ModalDialog RID_DLG_UPDATE { String RID_DLG_UPDATE_BROWSERBASED { Text[en-US] = "browser based update"; }; - String RID_DLG_UPDATE_VERSION { Text[en-US] = "Version"; }; + String RID_DLG_UPDATE_IGNORE { + Text[en-US] = "Ignore this Update"; + }; + String RID_DLG_UPDATE_IGNORE_ALL { + Text[en-US] = "Ignore all Updates"; + }; + String RID_DLG_UPDATE_ENABLE { + Text[en-US] = "Enable Updates"; + }; + String RID_DLG_UPDATE_IGNORED_UPDATE { + Text[en-US] = "This update will be ignored.\n"; + }; }; WarningBox RID_WARNINGBOX_UPDATE_SHARED_EXTENSION diff --git a/desktop/source/deployment/misc/dp_misc.src b/desktop/source/deployment/misc/dp_misc.src index 0d341122af16..ae810d2c7851 100644..100755 --- a/desktop/source/deployment/misc/dp_misc.src +++ b/desktop/source/deployment/misc/dp_misc.src @@ -32,7 +32,7 @@ String RID_DEPLYOMENT_DEPENDENCIES_UNKNOWN { }; String RID_DEPLYOMENT_DEPENDENCIES_MIN { - Text[en-US] = "Extensions requires at least OpenOffice.org %VERSION"; + Text[en-US] = "Extension requires at least OpenOffice.org %VERSION"; }; String RID_DEPLYOMENT_DEPENDENCIES_MAX { diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index e0844c227669..d1511952a92a 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -65,6 +65,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; using ::rtl::OUString; +namespace css = com::sun::star; namespace dp_registry { namespace backend { @@ -121,14 +122,15 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend BackendImpl * getMyBackend() const; const OUString m_loader; - ComponentBackendDb::Data m_registeredComponentsDb; enum reg { REG_UNINIT, REG_VOID, REG_REGISTERED, REG_NOT_REGISTERED, REG_MAYBE_REGISTERED } m_registered; - Reference<loader::XImplementationLoader> getComponentInfo( - t_stringlist * pImplNames, t_stringpairvec * pSingletons, + void getComponentInfo( + ComponentBackendDb::Data * data, + std::vector< css::uno::Reference< css::uno::XInterface > > * + factories, Reference<XComponentContext> const & xContext ); virtual void SAL_CALL disposing(); @@ -161,6 +163,30 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend }; friend class ComponentPackageImpl; + class ComponentsPackageImpl : public ::dp_registry::backend::Package + { + BackendImpl * getMyBackend() const; + + // Package + virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_( + ::osl::ResettableMutexGuard & guard, + ::rtl::Reference<AbortChannel> const & abortChannel, + Reference<XCommandEnvironment> const & xCmdEnv ); + virtual void processPackage_( + ::osl::ResettableMutexGuard & guard, + bool registerPackage, + bool startup, + ::rtl::Reference<AbortChannel> const & abortChannel, + Reference<XCommandEnvironment> const & xCmdEnv ); + public: + ComponentsPackageImpl( + ::rtl::Reference<PackageRegistryBackend> const & myBackend, + OUString const & url, OUString const & name, + Reference<deployment::XPackageTypeInfo> const & xPackageType, + bool bRemoved, OUString const & identifier); + }; + friend class ComponentsPackageImpl; + class TypelibraryPackageImpl : public ::dp_registry::backend::Package { BackendImpl * getMyBackend() const; @@ -194,8 +220,20 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend t_stringlist m_jar_typelibs; t_stringlist m_rdb_typelibs; - t_stringlist & getTypelibs( bool jar ) { - return jar ? m_jar_typelibs : m_rdb_typelibs; + t_stringlist m_components; + + enum RcItem { RCITEM_JAR_TYPELIB, RCITEM_RDB_TYPELIB, RCITEM_COMPONENTS }; + + t_stringlist & getRcItemList( RcItem kind ) { + switch (kind) + { + case RCITEM_JAR_TYPELIB: + return m_jar_typelibs; + case RCITEM_RDB_TYPELIB: + return m_rdb_typelibs; + default: // case RCITEM_COMPONENTS + return m_components; + } } bool m_unorc_inited; @@ -217,6 +255,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend const Reference<deployment::XPackageTypeInfo> m_xDynComponentTypeInfo; const Reference<deployment::XPackageTypeInfo> m_xJavaComponentTypeInfo; const Reference<deployment::XPackageTypeInfo> m_xPythonComponentTypeInfo; + const Reference<deployment::XPackageTypeInfo> m_xComponentsTypeInfo; const Reference<deployment::XPackageTypeInfo> m_xRDBTypelibTypeInfo; const Reference<deployment::XPackageTypeInfo> m_xJavaTypelibTypeInfo; Sequence< Reference<deployment::XPackageTypeInfo> > m_typeInfos; @@ -254,13 +293,31 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend OUString const & id, Reference<XInterface> const & xObject ); void releaseObject( OUString const & id ); - bool addToUnoRc( bool jarFile, OUString const & url, + bool addToUnoRc( RcItem kind, OUString const & url, Reference<XCommandEnvironment> const & xCmdEnv ); - bool removeFromUnoRc( bool jarFile, OUString const & url, + bool removeFromUnoRc( RcItem kind, OUString const & url, Reference<XCommandEnvironment> const & xCmdEnv ); - bool hasInUnoRc( bool jarFile, OUString const & url ); + bool hasInUnoRc( RcItem kind, OUString const & url ); + + css::uno::Reference< css::registry::XRegistryKey > openRegistryKey( + css::uno::Reference< css::registry::XRegistryKey > const & base, + rtl::OUString const & path); + void extractComponentData( + css::uno::Reference< css::uno::XComponentContext > const & context, + css::uno::Reference< css::registry::XRegistryKey > const & registry, + ComponentBackendDb::Data * data, + std::vector< css::uno::Reference< css::uno::XInterface > > * factories, + css::uno::Reference< css::loader::XImplementationLoader > const * + componentLoader, + rtl::OUString const * componentUrl); + void componentLiveInsertion( + ComponentBackendDb::Data const & data, + std::vector< css::uno::Reference< css::uno::XInterface > > const & + factories); + + void componentLiveRemoval(ComponentBackendDb::Data const & data); public: BackendImpl( Sequence<Any> const & args, @@ -291,13 +348,7 @@ BackendImpl::ComponentPackageImpl::ComponentPackageImpl( xPackageType, bRemoved, identifier), m_loader( loader ), m_registered( REG_UNINIT ) -{ - if (bRemoved) - { - m_registeredComponentsDb = getMyBackend()->readDataFromDb(url); - } -} - +{} const Reference<registry::XSimpleRegistry> BackendImpl::ComponentPackageImpl::getRDB() const @@ -538,6 +589,13 @@ BackendImpl::BackendImpl( RID_STR_PYTHON_COMPONENT), RID_IMG_COMPONENT, RID_IMG_COMPONENT_HC ) ), + m_xComponentsTypeInfo( new Package::TypeInfo( + OUSTR("application/" + "vnd.sun.star.uno-components"), + OUSTR("*.components"), + getResourceString(RID_STR_COMPONENTS), + RID_IMG_COMPONENT, + RID_IMG_COMPONENT_HC ) ), m_xRDBTypelibTypeInfo( new Package::TypeInfo( OUSTR("application/" "vnd.sun.star.uno-typelibrary;" @@ -553,13 +611,14 @@ BackendImpl::BackendImpl( getResourceString(RID_STR_JAVA_TYPELIB), RID_IMG_JAVA_TYPELIB, RID_IMG_JAVA_TYPELIB_HC ) ), - m_typeInfos( 5 ) + m_typeInfos( 6 ) { m_typeInfos[ 0 ] = m_xDynComponentTypeInfo; m_typeInfos[ 1 ] = m_xJavaComponentTypeInfo; m_typeInfos[ 2 ] = m_xPythonComponentTypeInfo; - m_typeInfos[ 3 ] = m_xRDBTypelibTypeInfo; - m_typeInfos[ 4 ] = m_xJavaTypelibTypeInfo; + m_typeInfos[ 3 ] = m_xComponentsTypeInfo; + m_typeInfos[ 4 ] = m_xRDBTypelibTypeInfo; + m_typeInfos[ 5 ] = m_xJavaTypelibTypeInfo; const Reference<XCommandEnvironment> xCmdEnv; @@ -724,6 +783,17 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( } } else if (subType.EqualsIgnoreCaseAscii( + "vnd.sun.star.uno-components")) + { + INetContentTypeParameter const * param = params.find( + ByteString("platform") ); + if (param == 0 || platform_fits( param->m_sValue )) { + return new BackendImpl::ComponentsPackageImpl( + this, url, name, m_xComponentsTypeInfo, bRemoved, + identifier); + } + } + else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.uno-typelibrary")) { INetContentTypeParameter const * param = params.find( @@ -816,11 +886,50 @@ void BackendImpl::unorc_verify_init( while (index >= 0); } if (readLine( &line, OUSTR("UNO_SERVICES="), ucb_content, - RTL_TEXTENCODING_UTF8 )) { - sal_Int32 start = sizeof ("UNO_SERVICES=?$ORIGIN/") - 1; - sal_Int32 sep = line.indexOf( ' ', start ); - OSL_ASSERT( sep > 0 ); - m_commonRDB_RO = line.copy( start, sep - start ); + RTL_TEXTENCODING_UTF8 )) + { + // The UNO_SERVICES line always has the BNF form + // "UNO_SERVICES=" + // ("?$ORIGIN/" <common-rdb>)? -- first + // "${$ORIGIN/${_OS}_${_ARCH}rc:UNO_SERVICES}"? -- second + // ("?" ("BUNDLED_EXTENSIONS" | -- third + // "UNO_SHARED_PACKAGES_CACHE" | "UNO_USER_PACKAGES_CACHE") + // ...)* + // so can unambiguously be split into its thre parts: + int state = 1; + for (sal_Int32 i = RTL_CONSTASCII_LENGTH("UNO_SERVICES="); + i >= 0;) + { + rtl::OUString token(line.getToken(0, ' ', i)); + if (token.getLength() != 0) + { + if (state == 1 && + token.matchAsciiL( + RTL_CONSTASCII_STRINGPARAM("?$ORIGIN/"))) + { + m_commonRDB_RO = token.copy( + RTL_CONSTASCII_LENGTH("?$ORIGIN/")); + state = 2; + } + else if (state <= 2 && + token.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( + "${$ORIGIN/${_OS}_${_ARCH}rc:" + "UNO_SERVICES}"))) + { + state = 3; + } + else + { + if (token[0] == '?') + { + token = token.copy(1); + } + m_components.push_back(token); + state = 3; + } + } + } } // native rc: @@ -896,16 +1005,27 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv ) OUString sCommonRDB(m_commonRDB.getLength() > 0 ? m_commonRDB : m_commonRDB_RO); OUString sNativeRDB(m_nativeRDB.getLength() > 0 ? m_nativeRDB : m_nativeRDB_RO); - if (sCommonRDB.getLength() > 0 || sNativeRDB.getLength() > 0) + if (sCommonRDB.getLength() > 0 || sNativeRDB.getLength() > 0 || + !m_components.empty()) { - buf.append( RTL_CONSTASCII_STRINGPARAM("UNO_SERVICES=?$ORIGIN/") ); - buf.append( ::rtl::OUStringToOString( - sCommonRDB, RTL_TEXTENCODING_ASCII_US ) ); + buf.append( RTL_CONSTASCII_STRINGPARAM("UNO_SERVICES=") ); + bool space = false; + if (sCommonRDB.getLength() > 0) + { + buf.append( RTL_CONSTASCII_STRINGPARAM("?$ORIGIN/") ); + buf.append( ::rtl::OUStringToOString( + sCommonRDB, RTL_TEXTENCODING_ASCII_US ) ); + space = true; + } if (sNativeRDB.getLength() > 0) { + if (space) + { + buf.append(' '); + } buf.append( RTL_CONSTASCII_STRINGPARAM( - " ${$ORIGIN/${_OS}_${_ARCH}rc:UNO_SERVICES}") ); - buf.append(LF); + "${$ORIGIN/${_OS}_${_ARCH}rc:UNO_SERVICES}") ); + space = true; // write native rc: ::rtl::OStringBuffer buf2; @@ -927,6 +1047,18 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv ) xCmdEnv ); ucb_content.writeStream( xData, true /* replace existing */ ); } + for (t_stringlist::iterator i(m_components.begin()); + i != m_components.end(); ++i) + { + if (space) + { + buf.append(' '); + } + buf.append('?'); + buf.append(rtl::OUStringToOString(*i, RTL_TEXTENCODING_UTF8)); + space = true; + } + buf.append(LF); } // write unorc: @@ -943,13 +1075,13 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv ) } //______________________________________________________________________________ -bool BackendImpl::addToUnoRc( bool jarFile, OUString const & url_, +bool BackendImpl::addToUnoRc( RcItem kind, OUString const & url_, Reference<XCommandEnvironment> const & xCmdEnv ) { const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); unorc_verify_init( xCmdEnv ); - t_stringlist & rSet = getTypelibs(jarFile); + t_stringlist & rSet = getRcItemList(kind); if (::std::find( rSet.begin(), rSet.end(), rcterm ) == rSet.end()) { rSet.push_front( rcterm ); // prepend to list, thus overriding // write immediately: @@ -963,13 +1095,13 @@ bool BackendImpl::addToUnoRc( bool jarFile, OUString const & url_, //______________________________________________________________________________ bool BackendImpl::removeFromUnoRc( - bool jarFile, OUString const & url_, + RcItem kind, OUString const & url_, Reference<XCommandEnvironment> const & xCmdEnv ) { const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); unorc_verify_init( xCmdEnv ); - getTypelibs(jarFile).remove( rcterm ); + getRcItemList(kind).remove( rcterm ); // write immediately: m_unorc_modified = true; unorc_flush( xCmdEnv ); @@ -978,22 +1110,215 @@ bool BackendImpl::removeFromUnoRc( //______________________________________________________________________________ bool BackendImpl::hasInUnoRc( - bool jarFile, OUString const & url_ ) + RcItem kind, OUString const & url_ ) { const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); - t_stringlist const & rSet = getTypelibs(jarFile); + t_stringlist const & rSet = getRcItemList(kind); return ::std::find( rSet.begin(), rSet.end(), rcterm ) != rSet.end(); } +css::uno::Reference< css::registry::XRegistryKey > BackendImpl::openRegistryKey( + css::uno::Reference< css::registry::XRegistryKey > const & base, + rtl::OUString const & path) +{ + OSL_ASSERT(base.is()); + css::uno::Reference< css::registry::XRegistryKey > key(base->openKey(path)); + if (!key.is()) { + throw css::deployment::DeploymentException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("missing registry entry ")) + + path + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" under ")) + + base->getKeyName()), + static_cast< OWeakObject * >(this), Any()); + } + return key; +} + +void BackendImpl::extractComponentData( + css::uno::Reference< css::uno::XComponentContext > const & context, + css::uno::Reference< css::registry::XRegistryKey > const & registry, + ComponentBackendDb::Data * data, + std::vector< css::uno::Reference< css::uno::XInterface > > * factories, + css::uno::Reference< css::loader::XImplementationLoader > const * + componentLoader, + rtl::OUString const * componentUrl) +{ + OSL_ASSERT(context.is() && registry.is() && data != 0 && factories != 0); + rtl::OUString registryName(registry->getKeyName()); + sal_Int32 prefix = registryName.getLength(); + if (!registryName.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM("/"))) { + prefix += RTL_CONSTASCII_LENGTH("/"); + } + css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > + keys(registry->openKeys()); + css::uno::Reference< css::lang::XMultiComponentFactory > smgr( + context->getServiceManager(), css::uno::UNO_QUERY_THROW); + for (sal_Int32 i = 0; i < keys.getLength(); ++i) { + rtl::OUString name(keys[i]->getKeyName().copy(prefix)); + data->implementationNames.push_back(name); + css::uno::Reference< css::registry::XRegistryKey > singletons( + keys[i]->openKey( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UNO/SINGLETONS")))); + if (singletons.is()) { + sal_Int32 prefix2 = keys[i]->getKeyName().getLength() + + RTL_CONSTASCII_LENGTH("/UNO/SINGLETONS/"); + css::uno::Sequence< + css::uno::Reference< css::registry::XRegistryKey > > + singletonKeys(singletons->openKeys()); + for (sal_Int32 j = 0; j < singletonKeys.getLength(); ++j) { + data->singletons.push_back( + std::pair< rtl::OUString, rtl::OUString >( + singletonKeys[j]->getKeyName().copy(prefix2), name)); + } + } + css::uno::Reference< css::loader::XImplementationLoader > loader; + if (componentLoader == 0) { + rtl::OUString activator( + openRegistryKey( + keys[i], + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("UNO/ACTIVATOR")))-> + getAsciiValue()); + loader.set( + smgr->createInstanceWithContext(activator, context), + css::uno::UNO_QUERY); + if (!loader.is()) { + throw css::deployment::DeploymentException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "cannot instantiate loader ")) + + activator), + static_cast< OWeakObject * >(this), Any()); + } + } else { + OSL_ASSERT(componentLoader->is()); + loader = *componentLoader; + } + factories->push_back( + loader->activate( + name, rtl::OUString(), + (componentUrl == 0 + ? (openRegistryKey( + keys[i], + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("UNO/LOCATION")))-> + getAsciiValue()) + : *componentUrl), + keys[i])); + } +} + +void BackendImpl::componentLiveInsertion( + ComponentBackendDb::Data const & data, + std::vector< css::uno::Reference< css::uno::XInterface > > const & + factories) +{ + css::uno::Reference< css::container::XSet > set( + getComponentContext()->getServiceManager(), css::uno::UNO_QUERY_THROW); + std::vector< css::uno::Reference< css::uno::XInterface > >::const_iterator + factory(factories.begin()); + for (t_stringlist::const_iterator i(data.implementationNames.begin()); + i != data.implementationNames.end(); ++i) + { + try { + set->insert(css::uno::Any(*factory++)); + } catch (container::ElementExistException &) { + OSL_TRACE( + "implementation %s already registered", + rtl::OUStringToOString(*i, RTL_TEXTENCODING_UTF8).getStr()); + } + } + if (!data.singletons.empty()) { + css::uno::Reference< css::container::XNameContainer > + rootContext( + getComponentContext()->getValueByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_root"))), + css::uno::UNO_QUERY); + if (rootContext.is()) { + for (t_stringpairvec::const_iterator i(data.singletons.begin()); + i != data.singletons.end(); ++i) + { + rtl::OUString name( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) + + i->first); + try { + rootContext->removeByName( + name + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("/arguments"))); + } catch (container::NoSuchElementException &) {} + try { + rootContext->insertByName( + (name + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("/service"))), + css::uno::Any(i->second)); + } catch (container::ElementExistException &) { + rootContext->replaceByName( + (name + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("/service"))), + css::uno::Any(i->second)); + } + try { + rootContext->insertByName(name, css::uno::Any()); + } catch (container::ElementExistException &) { + OSL_TRACE( + "singleton %s already registered", + rtl::OUStringToOString( + i->first, RTL_TEXTENCODING_UTF8).getStr()); + rootContext->replaceByName(name, css::uno::Any()); + } + } + } + } +} + +void BackendImpl::componentLiveRemoval(ComponentBackendDb::Data const & data) { + css::uno::Reference< css::container::XSet > set( + getComponentContext()->getServiceManager(), css::uno::UNO_QUERY_THROW); + for (t_stringlist::const_iterator i(data.implementationNames.begin()); + i != data.implementationNames.end(); ++i) + { + try { + set->remove(css::uno::Any(*i)); + } catch (css::container::NoSuchElementException &) { + // ignore if factory has not been live deployed + } + } + if (!data.singletons.empty()) { + css::uno::Reference< css::container::XNameContainer > rootContext( + getComponentContext()->getValueByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_root"))), + css::uno::UNO_QUERY); + if (rootContext.is()) { + for (t_stringpairvec::const_iterator i(data.singletons.begin()); + i != data.singletons.end(); ++i) + { + rtl::OUString name( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) + + i->first); + try { + rootContext->removeByName( + name + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("/arguments"))); + rootContext->removeByName( + name + + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service"))); + rootContext->removeByName(name); + } catch (container::NoSuchElementException &) {} + } + } + } +} + //______________________________________________________________________________ void BackendImpl::releaseObject( OUString const & id ) { const ::osl::MutexGuard guard( getMutex() ); - if ( m_backendObjects.erase( id ) != 1 ) - { - OSL_ASSERT( false ); - } + m_backendObjects.erase( id ); } //______________________________________________________________________________ @@ -1076,62 +1401,38 @@ Reference<XComponentContext> raise_uno_process( } //------------------------------------------------------------------------------ -Reference<loader::XImplementationLoader> -BackendImpl::ComponentPackageImpl::getComponentInfo( - t_stringlist * pImplNames, t_stringpairvec * pSingletons, +void BackendImpl::ComponentPackageImpl::getComponentInfo( + ComponentBackendDb::Data * data, + std::vector< css::uno::Reference< css::uno::XInterface > > * factories, Reference<XComponentContext> const & xContext ) { const Reference<loader::XImplementationLoader> xLoader( xContext->getServiceManager()->createInstanceWithContext( m_loader, xContext ), UNO_QUERY ); if (! xLoader.is()) - return Reference<loader::XImplementationLoader>(); + { + throw css::deployment::DeploymentException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("cannot instantiate loader ")) + + m_loader), + static_cast< OWeakObject * >(this), Any()); + } // HACK: highly dependent on stoc/source/servicemanager // and stoc/source/implreg implementation which rely on the same // services.rdb format! - + // .../UNO/LOCATION and .../UNO/ACTIVATOR appear not to be written by + // writeRegistryInfo, however, but are knwon, fixed values here, so + // can be passed into extractComponentData + rtl::OUString url(getURL()); const Reference<registry::XSimpleRegistry> xMemReg( xContext->getServiceManager()->createInstanceWithContext( OUSTR("com.sun.star.registry.SimpleRegistry"), xContext ), UNO_QUERY_THROW ); xMemReg->open( OUString() /* in mem */, false, true ); - xLoader->writeRegistryInfo( xMemReg->getRootKey(), OUString(), getURL() ); - - const Sequence< Reference<registry::XRegistryKey> > keys( - xMemReg->getRootKey()->openKeys() ); - for ( sal_Int32 pos = keys.getLength(); pos--; ) - { - Reference<registry::XRegistryKey> const & xImplKey = keys[ pos ]; - const OUString implName( - xImplKey->getKeyName().copy( 1 /*leading slash*/ ) ); - - // check for singletons: - const Reference<registry::XRegistryKey> xSingletonKey( - xImplKey->openKey( OUSTR("UNO/SINGLETONS") ) ); - if (xSingletonKey.is() && xSingletonKey->isValid()) - { - const Sequence< Reference<registry::XRegistryKey> > singletonKeys( - xSingletonKey->openKeys() ); - for ( sal_Int32 i = singletonKeys.getLength(); i--; ) - { - Reference<registry::XRegistryKey> const & xSingleton = - singletonKeys[ i ]; - pSingletons->push_back( - ::std::pair<OUString, OUString>( - xSingleton->getKeyName().copy( - implName.getLength() + - sizeof ("//UNO/SINGLETONS/") - 1 ), - xSingleton->getStringValue() ) ); - } - } - else - { - pImplNames->push_back( implName ); - } - } - - return xLoader; + xLoader->writeRegistryInfo( xMemReg->getRootKey(), OUString(), url ); + getMyBackend()->extractComponentData( + xContext, xMemReg->getRootKey(), data, factories, &xLoader, &url); } // Package @@ -1222,223 +1523,74 @@ void BackendImpl::ComponentPackageImpl::processPackage_( Reference<XCommandEnvironment> const & xCmdEnv ) { BackendImpl * that = getMyBackend(); - - - const bool java = m_loader.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.Java2") ); - const OUString url( getURL() ); - bool isJavaTypelib; - if (m_bRemoved) - isJavaTypelib = m_registeredComponentsDb.javaTypeLibrary; - else - isJavaTypelib = java && - !jarManifestHeaderPresent( url, OUSTR("UNO-Type-Path"), xCmdEnv ); - - ComponentBackendDb::Data data; - data.javaTypeLibrary = isJavaTypelib; - if (doRegisterPackage) - { - Reference <uno::XComponentContext> context(that->getComponentContext()); - if (! startup) - { - context.set( - that->getObject( url ), UNO_QUERY ); - - if (! context.is()) { + rtl::OUString url(getURL()); + if (doRegisterPackage) { + ComponentBackendDb::Data data; + css::uno::Reference< css::uno::XComponentContext > context; + if (startup) { + context = that->getComponentContext(); + } else { + context.set(that->getObject(url), css::uno::UNO_QUERY); + if (!context.is()) { context.set( - that->insertObject( url, raise_uno_process( - that->getComponentContext(), - abortChannel ) ), - UNO_QUERY_THROW ); + that->insertObject( + url, + raise_uno_process( + that->getComponentContext(), abortChannel)), + css::uno::UNO_QUERY_THROW); } } - - const Reference<registry::XSimpleRegistry> xServicesRDB( getRDB() ); - const Reference<registry::XImplementationRegistration> xImplReg( + css::uno::Reference< css::registry::XImplementationRegistration>( context->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.registry.ImplementationRegistration"), - context ), UNO_QUERY_THROW ); - - xImplReg->registerImplementation( m_loader, url, xServicesRDB ); - //only write to unorc if registration was successful. - //It may fail if there is no suitable java. - if (isJavaTypelib) + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.ImplementationRegistration")), + context), + css::uno::UNO_QUERY_THROW)->registerImplementation( + m_loader, url, getRDB()); + // Only write to unorc after successful registration; it may fail if + // there is no suitable java + if (m_loader.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.Java2")) && + !jarManifestHeaderPresent(url, OUSTR("UNO-Type-Path"), xCmdEnv)) { - that->addToUnoRc( java, url, xCmdEnv ); + that->addToUnoRc(RCITEM_JAR_TYPELIB, url, xCmdEnv); data.javaTypeLibrary = true; } - - t_stringlist implNames; - t_stringpairvec singletons; - const Reference<loader::XImplementationLoader> xLoader( - getComponentInfo( &implNames, &singletons, context ) ); - data.implementationNames = implNames; - data.singletons = singletons; - - if (!startup) - { - // factories live insertion: - const Reference<container::XSet> xSet( - that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); - for ( t_stringlist::const_iterator iPos( implNames.begin() ); - iPos != implNames.end(); ++iPos ) - { - checkAborted( abortChannel ); - OUString const & implName = *iPos; - // activate factory: - const Reference<XInterface> xFactory( - xLoader->activate( - implName, OUString(), url, - xServicesRDB->getRootKey()->openKey( - OUSTR("/IMPLEMENTATIONS/") + implName ) ) ); - try { - xSet->insert( Any(xFactory) ); - } // ignore if factory has already been inserted: - catch (container::ElementExistException &) { - OSL_ENSURE( 0, "### factory already registered?" ); - } - } - - if (! singletons.empty()) - { - // singletons live insertion: - const Reference<container::XNameContainer> xRootContext( - that->getComponentContext()->getValueByName( - OUSTR("_root") ), UNO_QUERY ); - if (xRootContext.is()) - { - for ( t_stringpairvec::const_iterator iPos( - singletons.begin() ); - iPos != singletons.end(); ++iPos ) - { - ::std::pair<OUString, OUString> const & sp = *iPos; - const OUString name( OUSTR("/singletons/") + sp.first ); - // assure no arguments: - try { - xRootContext->removeByName( name + OUSTR("/arguments")); - } catch (container::NoSuchElementException &) {} - // used service: - try { - xRootContext->insertByName( - name + OUSTR("/service"), Any(sp.second) ); - } catch (container::ElementExistException &) { - xRootContext->replaceByName( - name + OUSTR("/service"), Any(sp.second) ); - } - // singleton entry: - try { - xRootContext->insertByName( name, Any() ); - } catch (container::ElementExistException & exc) { - (void) exc; // avoid warnings - OSL_ENSURE( - 0, OUStringToOString( - exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); - xRootContext->replaceByName( name, Any() ); - } - } - } - } + std::vector< css::uno::Reference< css::uno::XInterface > > factories; + getComponentInfo(&data, &factories, context); + if (!startup) { + that->componentLiveInsertion(data, factories); } - m_registered = REG_REGISTERED; - getMyBackend()->addDataToDb(url, data); - } - else // revokePackage() - { - // set to VOID during revocation process: + that->addDataToDb(url, data); + } else { // revoke m_registered = REG_VOID; - - //get the remote context. If it does not exist then use the local one - Reference<XComponentContext> xContext( - that->getObject( url ), UNO_QUERY ); - bool bRemoteContext = false; - if (!xContext.is()) - xContext = that->getComponentContext(); - else - bRemoteContext = true; - - t_stringlist implNames; - t_stringpairvec singletons; - if (m_bRemoved) - { - implNames = m_registeredComponentsDb.implementationNames; - singletons = m_registeredComponentsDb.singletons; + ComponentBackendDb::Data data(that->readDataFromDb(url)); + css::uno::Reference< css::uno::XComponentContext > context( + that->getObject(url), css::uno::UNO_QUERY); + bool remoteContext = context.is(); + if (!remoteContext) { + context = that->getComponentContext(); } - else - { - getComponentInfo( &implNames, &singletons, xContext ); + if (!startup) { + that->componentLiveRemoval(data); } - - if (!startup) - { - // factories live removal: - const Reference<container::XSet> xSet( - that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); - for ( t_stringlist::const_iterator iPos( implNames.begin() ); - iPos != implNames.end(); ++iPos ) - { - OUString const & implName = *iPos; - try { - xSet->remove( Any(implName) ); - } // ignore if factory has not been live deployed: - catch (container::NoSuchElementException &) { - } - } - - if (! singletons.empty()) - { - // singletons live removal: - const Reference<container::XNameContainer> xRootContext( - that->getComponentContext()->getValueByName( - OUSTR("_root") ), UNO_QUERY ); - if (xRootContext.is()) - { - for ( t_stringpairvec::const_iterator iPos( - singletons.begin() ); - iPos != singletons.end(); ++iPos ) - { - ::std::pair<OUString, OUString> const & sp = *iPos; - const OUString name( OUSTR("/singletons/") + sp.first ); - // arguments: - try { - xRootContext->removeByName( name + OUSTR("/arguments")); - } - catch (container::NoSuchElementException &) {} - // used service: - try { - xRootContext->removeByName( name + OUSTR("/service") ); - } - catch (container::NoSuchElementException &) {} - // singleton entry: - try { - xRootContext->removeByName( name ); - } - catch (container::NoSuchElementException & exc) { - (void) exc; // avoid warnings - OSL_ENSURE( - 0, OUStringToOString( - exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); - } - } - } - } + css::uno::Reference< css::registry::XImplementationRegistration >( + context->getServiceManager()->createInstanceWithContext( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.ImplementationRegistration")), + context), + css::uno::UNO_QUERY_THROW)->revokeImplementation(url, getRDB()); + if (data.javaTypeLibrary) { + that->removeFromUnoRc(RCITEM_JAR_TYPELIB, url, xCmdEnv); + } + if (remoteContext) { + that->releaseObject(url); } - - const Reference<registry::XSimpleRegistry> xServicesRDB( getRDB() ); - const Reference<registry::XImplementationRegistration> xImplReg( - xContext->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.registry.ImplementationRegistration"), - xContext ), UNO_QUERY_THROW ); - xImplReg->revokeImplementation( url, xServicesRDB ); - - if (isJavaTypelib) - that->removeFromUnoRc( java, url, xCmdEnv ); - - if (bRemoteContext) - that->releaseObject( url ); - m_registered = REG_NOT_REGISTERED; - getMyBackend()->deleteDataFromDb(url); + that->deleteDataFromDb(url); } } @@ -1480,7 +1632,8 @@ BackendImpl::TypelibraryPackageImpl::isRegistered_( return beans::Optional< beans::Ambiguous<sal_Bool> >( true /* IsPresent */, beans::Ambiguous<sal_Bool>( - that->hasInUnoRc( m_jarFile, getURL() ), + that->hasInUnoRc( + m_jarFile ? RCITEM_JAR_TYPELIB : RCITEM_RDB_TYPELIB, getURL() ), false /* IsAmbiguous */ ) ); } @@ -1546,11 +1699,13 @@ void BackendImpl::TypelibraryPackageImpl::processPackage_( } } - that->addToUnoRc( m_jarFile, url, xCmdEnv ); + that->addToUnoRc( m_jarFile ? RCITEM_JAR_TYPELIB : RCITEM_RDB_TYPELIB, + url, xCmdEnv ); } else // revokePackage() { - that->removeFromUnoRc( m_jarFile, url, xCmdEnv ); + that->removeFromUnoRc( + m_jarFile ? RCITEM_JAR_TYPELIB : RCITEM_RDB_TYPELIB, url, xCmdEnv ); // revoking types at runtime, possible, sensible? if (!m_xTDprov.is()) @@ -1570,6 +1725,97 @@ void BackendImpl::TypelibraryPackageImpl::processPackage_( } } +BackendImpl * BackendImpl::ComponentsPackageImpl::getMyBackend() const +{ + BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get()); + if (NULL == pBackend) + { + //Throws a DisposedException + check(); + //We should never get here... + throw RuntimeException( + OUSTR("Failed to get the BackendImpl"), + static_cast<OWeakObject*>(const_cast<ComponentsPackageImpl *>(this))); + } + return pBackend; +} + +beans::Optional< beans::Ambiguous<sal_Bool> > +BackendImpl::ComponentsPackageImpl::isRegistered_( + ::osl::ResettableMutexGuard &, + ::rtl::Reference<AbortChannel> const &, + Reference<XCommandEnvironment> const & ) +{ + return beans::Optional< beans::Ambiguous<sal_Bool> >( + true, + beans::Ambiguous<sal_Bool>( + getMyBackend()->hasInUnoRc(RCITEM_COMPONENTS, getURL()), false)); +} + +void BackendImpl::ComponentsPackageImpl::processPackage_( + ::osl::ResettableMutexGuard &, + bool doRegisterPackage, + bool startup, + ::rtl::Reference<AbortChannel> const & abortChannel, + Reference<XCommandEnvironment> const & xCmdEnv ) +{ + BackendImpl * that = getMyBackend(); + rtl::OUString url(getURL()); + if (doRegisterPackage) { + ComponentBackendDb::Data data; + data.javaTypeLibrary = false; + std::vector< css::uno::Reference< css::uno::XInterface > > factories; + css::uno::Reference< css::uno::XComponentContext > context( + that->getObject(url), css::uno::UNO_QUERY); + if (!context.is()) { + context.set( + that->insertObject( + url, + raise_uno_process( + that->getComponentContext(), abortChannel)), + css::uno::UNO_QUERY_THROW); + } + css::uno::Reference< css::registry::XSimpleRegistry > registry( + css::uno::Reference< css::lang::XMultiComponentFactory >( + that->getComponentContext()->getServiceManager(), + css::uno::UNO_SET_THROW)->createInstanceWithContext( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry")), + that->getComponentContext()), + css::uno::UNO_QUERY_THROW); + registry->open(expandUnoRcUrl(url), true, false); + getMyBackend()->extractComponentData( + context, + that->openRegistryKey( + registry->getRootKey(), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IMPLEMENTATIONS"))), + &data, &factories, 0, 0); + registry->close(); + if (!startup) { + that->componentLiveInsertion(data, factories); + } + that->addDataToDb(url, data); + that->addToUnoRc(RCITEM_COMPONENTS, url, xCmdEnv); + } else { // revoke + that->removeFromUnoRc(RCITEM_COMPONENTS, url, xCmdEnv); + if (!startup) { + that->componentLiveRemoval(that->readDataFromDb(url)); + } + that->releaseObject(url); + that->deleteDataFromDb(url); + } +} + +BackendImpl::ComponentsPackageImpl::ComponentsPackageImpl( + ::rtl::Reference<PackageRegistryBackend> const & myBackend, + OUString const & url, OUString const & name, + Reference<deployment::XPackageTypeInfo> const & xPackageType, + bool bRemoved, OUString const & identifier) + : Package( myBackend, url, name, name /* display-name */, + xPackageType, bRemoved, identifier) +{} + } // anon namespace namespace sdecl = comphelper::service_decl; diff --git a/desktop/source/deployment/registry/component/dp_component.hrc b/desktop/source/deployment/registry/component/dp_component.hrc index 53085a48d185..4a8c4184a994 100644 --- a/desktop/source/deployment/registry/component/dp_component.hrc +++ b/desktop/source/deployment/registry/component/dp_component.hrc @@ -33,6 +33,7 @@ #define RID_STR_DYN_COMPONENT (RID_DEPLOYMENT_COMPONENT_START+10) #define RID_STR_JAVA_COMPONENT (RID_DEPLOYMENT_COMPONENT_START+11) #define RID_STR_PYTHON_COMPONENT (RID_DEPLOYMENT_COMPONENT_START+12) +#define RID_STR_COMPONENTS (RID_DEPLOYMENT_COMPONENT_START+13) #define RID_STR_RDB_TYPELIB (RID_DEPLOYMENT_COMPONENT_START+20) #define RID_STR_JAVA_TYPELIB (RID_DEPLOYMENT_COMPONENT_START+21) diff --git a/desktop/source/deployment/registry/component/dp_component.src b/desktop/source/deployment/registry/component/dp_component.src index 36f2a1cc4a5c..9e9ab1a82bbf 100644 --- a/desktop/source/deployment/registry/component/dp_component.src +++ b/desktop/source/deployment/registry/component/dp_component.src @@ -42,6 +42,11 @@ String RID_STR_PYTHON_COMPONENT Text [ en-US ] = "UNO Python Component"; }; +String RID_STR_COMPONENTS +{ + Text [ en-US ] = "UNO Components"; +}; + String RID_STR_RDB_TYPELIB { Text [ en-US ] = "UNO RDB Type Library"; diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index d781ba9e40ef..fa53d4e78a15 100644..100755 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -520,6 +520,15 @@ OUString Package::getDescription() throw ( } //______________________________________________________________________________ +OUString Package::getLicenseText() throw ( + deployment::ExtensionRemovedException,RuntimeException) +{ + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + return OUString(); +} + +//______________________________________________________________________________ Sequence<OUString> Package::getUpdateInformationURLs() throw ( deployment::ExtensionRemovedException, RuntimeException) { diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 5a5efe825cfb..53a7ba1c316d 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -450,7 +450,7 @@ void BackendImpl::implProcessHelp aJarFile, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ); - rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" ); + rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.zip://" ); aDestBasePath += aEncodedJarFilePath; aDestBasePath += rtl::OUString::createFromAscii( "/" ); diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 3d3bf7cf912c..20fc2a8dc7e1 100644..100755 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -237,6 +237,9 @@ public: virtual ::rtl::OUString SAL_CALL getDescription() throw (css::deployment::ExtensionRemovedException, css::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getLicenseText() + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getUpdateInformationURLs() throw (css::deployment::ExtensionRemovedException, @@ -294,7 +297,7 @@ protected: ::rtl::OUString m_context; // currently only for library containers: - enum context { + enum { CONTEXT_UNKNOWN, CONTEXT_USER, CONTEXT_SHARED,CONTEXT_BUNDLED, CONTEXT_TMP, CONTEXT_DOCUMENT diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index feb55d0af3bf..262bbef420f2 100644..100755 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -190,6 +190,9 @@ class BackendImpl : public ImplBaseT virtual OUString SAL_CALL getDescription() throw (deployment::ExtensionRemovedException, RuntimeException); + virtual OUString SAL_CALL getLicenseText() + throw (deployment::ExtensionRemovedException, RuntimeException); + virtual void SAL_CALL exportTo( OUString const & destFolderURL, OUString const & newTitle, sal_Int32 nameClashAction, @@ -986,16 +989,45 @@ OUString BackendImpl::PackageImpl::getDescription() if (sRelativeURL.getLength()) { OUString sURL = m_url_expanded + OUSTR("/") + sRelativeURL; - sDescription = getTextFromURL( - css::uno::Reference< css::ucb::XCommandEnvironment >(), sURL); + try + { + sDescription = getTextFromURL( css::uno::Reference< css::ucb::XCommandEnvironment >(), sURL ); + } + catch ( css::deployment::DeploymentException& ) + { + OSL_ENSURE( 0, ::rtl::OUStringToOString( ::comphelper::anyToString( ::cppu::getCaughtException() ), RTL_TEXTENCODING_UTF8 ).getStr() ); + } } + if (sDescription.getLength()) return sDescription; - else if(m_oldDescription.getLength()) - return m_oldDescription; - else - return OUString(); + return m_oldDescription; +} + +//______________________________________________________________________________ +OUString BackendImpl::PackageImpl::getLicenseText() + throw (deployment::ExtensionRemovedException, RuntimeException) +{ + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + + OUString sLicense; + DescriptionInfoset aInfo = getDescriptionInfoset(); + + ::boost::optional< SimpleLicenseAttributes > aSimplLicAttr = aInfo.getSimpleLicenseAttributes(); + if ( aSimplLicAttr ) + { + OUString aLicenseURL = aInfo.getLocalizedLicenseURL(); + + if ( aLicenseURL.getLength() ) + { + OUString aFullURL = m_url_expanded + OUSTR("/") + aLicenseURL; + sLicense = getTextFromURL( Reference< ucb::XCommandEnvironment >(), aFullURL); + } + } + + return sLicense; } //______________________________________________________________________________ diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index 8a4ee1b45fbc..f3195701fc7c 100644..100755 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -88,6 +88,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend OUString const & identifier); // XPackage virtual OUString SAL_CALL getDescription() throw (RuntimeException); + virtual OUString SAL_CALL getLicenseText() throw (RuntimeException); }; friend class PackageImpl; @@ -133,6 +134,12 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) } //______________________________________________________________________________ +OUString BackendImpl::PackageImpl::getLicenseText() throw (RuntimeException) +{ + return Package::getDescription(); +} + +//______________________________________________________________________________ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference<BackendImpl> const & myBackend, OUString const & url, OUString const & libType, bool bRemoved, diff --git a/desktop/source/migration/wizard.cxx b/desktop/source/migration/wizard.cxx index 81a789a613b9..5cc90577aaff 100644 --- a/desktop/source/migration/wizard.cxx +++ b/desktop/source/migration/wizard.cxx @@ -209,7 +209,6 @@ FirstStartWizard::FirstStartWizard( Window* pParent, sal_Bool bLicenseNeedsAccep m_aDefaultPath = defineWizardPagesDependingFromContext(); activatePath(m_aDefaultPath, sal_True); - enterState(STATE_WELCOME); ActivatePage(); // set text of finish putton: |