From 603d5e9c0ed374c5acc477208133dc29f8d97d5c Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 17 Sep 2009 15:48:04 -0400 Subject: #i5560# Applied & adjusted for the latest codebase the patches from go-oo. The original patches were contributed by Daniel Watson. --- .../registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index 991ea9a64d10..4368520f6371 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -1246,6 +1246,19 @@ Rename Sheet + + + ~Tab Color... + + + ~Tab Color... + + + + + Tab Color + + ~Move/Copy Sheet... -- cgit From 2db393ea0b24fd230d3437d664a25d1cf7e5fb91 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Wed, 10 Feb 2010 10:27:57 +0100 Subject: jl152 copy changeset 263364:4815fbf0d446 from native0: #161641# XPackageManager.addPackage can install a folder, which is an uncompressed extension. --- desktop/source/deployment/manager/dp_manager.cxx | 18 +++++++--- desktop/source/deployment/registry/dp_registry.cxx | 18 +++++++--- .../deployment/registry/package/dp_package.cxx | 41 +++++++++++++++------- 3 files changed, 55 insertions(+), 22 deletions(-) diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 165efbaeca5a..3f13cb021aae 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -542,11 +542,19 @@ OUString PackageManagerImpl::insertToActivationLayer( { // inflate content: ::rtl::OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.zip://") ); - buf.append( ::rtl::Uri::encode( sourceContent.getURL(), - rtl_UriCharClassRegName, - rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8 ) ); + if (!sourceContent.isFolder()) + { + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.zip://") ); + buf.append( ::rtl::Uri::encode( sourceContent.getURL(), + rtl_UriCharClassRegName, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ); + } + else + { + //Folder. No need to unzip, just copy + buf.append(sourceContent.getURL()); + } buf.append( static_cast('/') ); sourceContent = ::ucbhelper::Content( buf.makeStringAndClear(), xCmdEnv ); diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index c6572364aac0..c56131a1015c 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -181,6 +181,7 @@ OUString normalizeMediaType( OUString const & mediaType ) } //______________________________________________________________________________ + void PackageRegistryImpl::insertBackend( Reference const & xBackend ) { @@ -201,7 +202,8 @@ void PackageRegistryImpl::insertBackend( ::std::pair mb_insertion( m_mediaType2backend.insert( t_string2registry::value_type( mediaType, xBackend ) ) ); - if (mb_insertion.second) { + if (mb_insertion.second) + { // add parameterless media-type, too: sal_Int32 semi = mediaType.indexOf( ';' ); if (semi >= 0) { @@ -210,9 +212,13 @@ void PackageRegistryImpl::insertBackend( mediaType.copy( 0, semi ), xBackend ) ); } const OUString fileFilter( xPackageType->getFileFilter() ); + //The package backend shall also be called to determine the mediatype + //(XPackageRegistry.bindPackage) when the URL points to a directory. + const bool bExtension = mediaType.equals(OUSTR("application/vnd.sun.star.package-bundle")); if (fileFilter.getLength() == 0 || fileFilter.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("*.*") ) || - fileFilter.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("*") )) + fileFilter.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("*") ) || + bExtension) { m_ambiguousBackends.insert( xBackend ); } @@ -351,7 +357,10 @@ Reference PackageRegistryImpl::create( } } - // insert bundle be: + // Insert bundle back-end. + // Always register as last, because we want to add extensions also as folders + // and as a default we accept every folder, which was not recognized by the other + // backends. that->insertBackend( ::dp_registry::backend::bundle::create( that, context, cachePath, readOnly, xComponentContext ) ); @@ -445,7 +454,8 @@ Reference PackageRegistryImpl::bindPackage( { ::ucbhelper::Content ucbContent; if (create_ucb_content( - &ucbContent, url, xCmdEnv, false /* no throw */ )) + &ucbContent, url, xCmdEnv, false /* no throw */ ) + && !ucbContent.isFolder()) { OUString title( ucbContent.getPropertyValue( StrTitle::get() ).get() ); diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index e45f7fb7ef73..b0b4a918c7a3 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -287,7 +287,7 @@ BackendImpl::BackendImpl( m_xBundleTypeInfo->getShortDescription(), RID_IMG_DEF_PACKAGE_BUNDLE, RID_IMG_DEF_PACKAGE_BUNDLE_HC ) ), - m_typeInfos( 2 ) + m_typeInfos(2) { m_typeInfos[ 0 ] = m_xBundleTypeInfo; m_typeInfos[ 1 ] = m_xLegacyBundleTypeInfo; @@ -342,17 +342,32 @@ Reference BackendImpl::bindPackage_( ::ucbhelper::Content ucbContent; if (create_ucb_content( &ucbContent, url, xCmdEnv )) { - const OUString title( ucbContent.getPropertyValue( - StrTitle::get() ).get() ); - if (title.endsWithIgnoreAsciiCaseAsciiL( - RTL_CONSTASCII_STRINGPARAM(".oxt") ) || - title.endsWithIgnoreAsciiCaseAsciiL( - RTL_CONSTASCII_STRINGPARAM(".uno.pkg") )) - mediaType = OUSTR("application/vnd.sun.star.package-bundle"); - else if (title.endsWithIgnoreAsciiCaseAsciiL( - RTL_CONSTASCII_STRINGPARAM(".zip") )) - mediaType = - OUSTR("application/vnd.sun.star.legacy-package-bundle"); + if (ucbContent.isFolder()) + { + //Every .oxt, uno.pkg file must contain a META-INF folder + ::ucbhelper::Content metaInfContent; + if (create_ucb_content( + &metaInfContent, makeURL( url, OUSTR("META-INF/manifest.xml") ), + xCmdEnv, false /* no throw */ )) + { + mediaType = OUSTR("application/vnd.sun.star.package-bundle"); + } + //No support of legacy bundles, because every folder could be one. + } + else + { + const OUString title( ucbContent.getPropertyValue( + StrTitle::get() ).get() ); + if (title.endsWithIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM(".oxt") ) || + title.endsWithIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM(".uno.pkg") )) + mediaType = OUSTR("application/vnd.sun.star.package-bundle"); + else if (title.endsWithIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM(".zip") )) + mediaType = + OUSTR("application/vnd.sun.star.legacy-package-bundle"); + } } if (mediaType.getLength() == 0) throw lang::IllegalArgumentException( @@ -1303,7 +1318,7 @@ void BackendImpl::PackageImpl::scanBundle( { OSL_ENSURE( 0, "### missing META-INF/manifest.xml file!" ); return; -} + } const lang::Locale officeLocale = getOfficeLocale(); -- cgit From 115be1e754c02ba61dcaaa8be29988d0ccafc5db Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 22 Feb 2010 10:13:55 -0500 Subject: calctabcolor: #i5560# Added new token for storing the tab color with ods, as a table document property. --- xmloff/inc/xmloff/xmltoken.hxx | 1 + xmloff/source/core/xmltoken.cxx | 1 + 2 files changed, 2 insertions(+) diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index 4a96de28b480..224b9e41a19f 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -1708,6 +1708,7 @@ namespace xmloff { namespace token { XML_SYMBOL_IMAGE_NAME, XML_SYMBOL_WIDTH, XML_SYSTEM, + XML_TAB_COLOR, XML_TAB_STOP, XML_TAB_STOP_DISTANCE, XML_TAB_STOPS, diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 3073ead17646..1dfbbacf8790 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -1716,6 +1716,7 @@ namespace xmloff { namespace token { TOKEN( "symbol-image-name", XML_SYMBOL_IMAGE_NAME ), TOKEN( "symbol-width", XML_SYMBOL_WIDTH ), TOKEN( "system", XML_SYSTEM ), + TOKEN( "tab-color", XML_TAB_COLOR ), TOKEN( "tab-stop", XML_TAB_STOP ), TOKEN( "tab-stop-distance", XML_TAB_STOP_DISTANCE ), TOKEN( "tab-stops", XML_TAB_STOPS ), -- cgit From 5f4789aa21fb16982d4e744d6eb1f2198f36154e Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 3 Mar 2010 16:36:43 +0100 Subject: #109634# password to modify dialog --- uui/source/cookiedg.cxx | 0 uui/source/cookiedg.hxx | 0 uui/source/iahndl-authentication.cxx | 46 +++++-- uui/source/ids.hrc | 257 ++++++++++++++++++----------------- uui/source/passworddlg.cxx | 30 ++-- uui/source/passworddlg.hxx | 2 +- uui/source/passworddlg.src | 12 +- uui/source/passworderrs.src | 9 +- 8 files changed, 199 insertions(+), 157 deletions(-) mode change 100644 => 100755 uui/source/cookiedg.cxx mode change 100644 => 100755 uui/source/cookiedg.hxx mode change 100644 => 100755 uui/source/iahndl-authentication.cxx mode change 100644 => 100755 uui/source/ids.hrc mode change 100644 => 100755 uui/source/passworddlg.cxx mode change 100644 => 100755 uui/source/passworddlg.hxx mode change 100644 => 100755 uui/source/passworddlg.src mode change 100644 => 100755 uui/source/passworderrs.src diff --git a/uui/source/cookiedg.cxx b/uui/source/cookiedg.cxx old mode 100644 new mode 100755 diff --git a/uui/source/cookiedg.hxx b/uui/source/cookiedg.hxx old mode 100644 new mode 100755 diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx old mode 100644 new mode 100755 index 9154122187ea..18c8d94b573a --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -29,6 +29,7 @@ ************************************************************************/ #include "com/sun/star/task/DocumentPasswordRequest.hpp" +#include "com/sun/star/task/DocumentPasswordRequest2.hpp" #include "com/sun/star/task/DocumentMSPasswordRequest.hpp" #include "com/sun/star/task/MasterPasswordRequest.hpp" #include "com/sun/star/task/XInteractionAbort.hpp" @@ -37,6 +38,7 @@ #include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp" #include "com/sun/star/ucb/URLAuthenticationRequest.hpp" +#include "osl/diagnose.h" #include "rtl/digest.h" #include "vos/mutex.hxx" #include "tools/errcode.hxx" @@ -561,28 +563,46 @@ UUIInteractionHelper::handlePasswordRequest( uno::Reference< task::XInteractionRequest > const & rRequest) SAL_THROW((uno::RuntimeException)) { + // parameters to be filled for the call to handlePasswordRequest_ + Window * pParent = getParentProperty(); + task::PasswordRequestMode nMode = task::PasswordRequestMode_PASSWORD_ENTER; + uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations = rRequest->getContinuations(); + ::rtl::OUString aDocumentName; + bool bMSCryptoMode = false; + bool bIsPasswordToModify = false; + + bool bDoHandleRequest = false; + uno::Any aAnyRequest(rRequest->getRequest()); task::DocumentPasswordRequest aDocumentPasswordRequest; - if (aAnyRequest >>= aDocumentPasswordRequest) + if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest)) { - handlePasswordRequest_(getParentProperty(), - aDocumentPasswordRequest.Mode, - rRequest->getContinuations(), - aDocumentPasswordRequest.Name, - false /* bool bMSCryptoMode */); - return true; + nMode = aDocumentPasswordRequest.Mode; + aDocumentName = aDocumentPasswordRequest.Name; + OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" ); + OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" ); + + bDoHandleRequest = true; } task::DocumentMSPasswordRequest aDocumentMSPasswordRequest; - if (aAnyRequest >>= aDocumentMSPasswordRequest) + if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest)) + { + nMode = aDocumentMSPasswordRequest.Mode; + aDocumentName = aDocumentMSPasswordRequest.Name; + bMSCryptoMode = true; + OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" ); + + bDoHandleRequest = true; + } + + if (bDoHandleRequest) { - handlePasswordRequest_(getParentProperty(), - aDocumentMSPasswordRequest.Mode, - rRequest->getContinuations(), - aDocumentMSPasswordRequest.Name, - true /* bool bMSCryptoMode */); + handlePasswordRequest_( pParent, nMode, rContinuations, aDocumentName, bMSCryptoMode ); return true; } + return false; } + diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc old mode 100644 new mode 100755 index 28de301fe775..c02d9d6e419f --- a/uui/source/ids.hrc +++ b/uui/source/ids.hrc @@ -38,126 +38,129 @@ #include "tools/errcode.hxx" #endif -#define RID_KEEP_PASSWORD (RID_UUI_START + 0) -#define RID_SAVE_PASSWORD (RID_UUI_START + 1) -#define DLG_UUI_LOGIN (RID_UUI_START + 2) -#define DLG_COOKIES (RID_UUI_START + 3) -#define STR_COOKIES_RECV_START (RID_UUI_START + 4) -#define STR_COOKIES_RECV_COOKIES (RID_UUI_START + 5) -#define STR_COOKIES_RECV_TITLE (RID_UUI_START + 6) -#define STR_COOKIES_SEND_START (RID_UUI_START + 7) -#define STR_COOKIES_SEND_COOKIES (RID_UUI_START + 8) -#define STR_COOKIES_SEND_TITLE (RID_UUI_START + 9) -#define DLG_FILTER_SELECT (RID_UUI_START + 10) +#define RID_KEEP_PASSWORD (RID_UUI_START + 0) +#define RID_SAVE_PASSWORD (RID_UUI_START + 1) +#define DLG_UUI_LOGIN (RID_UUI_START + 2) +#define DLG_COOKIES (RID_UUI_START + 3) +#define STR_COOKIES_RECV_START (RID_UUI_START + 4) +#define STR_COOKIES_RECV_COOKIES (RID_UUI_START + 5) +#define STR_COOKIES_RECV_TITLE (RID_UUI_START + 6) +#define STR_COOKIES_SEND_START (RID_UUI_START + 7) +#define STR_COOKIES_SEND_COOKIES (RID_UUI_START + 8) +#define STR_COOKIES_SEND_TITLE (RID_UUI_START + 9) +#define DLG_FILTER_SELECT (RID_UUI_START + 10) // RID_UUI_START + 11 moved to ERRCODE_UUI_WRONGMEDIUM -#define DLG_UUI_MASTERPASSWORD (RID_UUI_START + 12) -#define STR_ERROR_PASSWORDS_NOT_IDENTICAL (RID_UUI_START + 13) -#define STR_ERROR_MASTERPASSWORD_WRONG (RID_UUI_START + 14) +#define DLG_UUI_MASTERPASSWORD (RID_UUI_START + 12) +#define STR_ERROR_PASSWORDS_NOT_IDENTICAL (RID_UUI_START + 13) +#define STR_ERROR_MASTERPASSWORD_WRONG (RID_UUI_START + 14) // RID_UUI_START + 15, 16, 17 are misused by syncaccess/source/ui/resids.hrc -#define RID_UUI_ERRHDL (RID_UUI_START + 20) -#define DLG_UUI_MASTERPASSWORD_CRT (RID_UUI_START + 21) -#define DLG_UUI_PASSWORD (RID_UUI_START + 22) -#define DLG_UUI_PASSWORD_CRT (RID_UUI_START + 23) -#define STR_ERROR_PASSWORD_WRONG (RID_UUI_START + 24) -#define STR_WARNING_BROKENSIGNATURE_TITLE (RID_UUI_START + 25) -#define DLG_UUI_UNKNOWNAUTH (RID_UUI_START + 26) -#define DLG_UUI_UNKNOWNAUTH_CRT (RID_UUI_START + 27) -#define DLG_UUI_SSLWARN (RID_UUI_START + 28) -#define DLG_UUI_SSLWARN_CRT (RID_UUI_START + 29) -#define RID_XMLSECDLG_MACROWARN (RID_UUI_START + 30) -#define STR_UNKNOWNUSER (RID_UUI_START + 31) -#define STR_OPENLOCKED_TITLE (RID_UUI_START + 32) -#define STR_OPENLOCKED_MSG (RID_UUI_START + 33) -#define STR_OPENLOCKED_OPENREADONLY_BTN (RID_UUI_START + 34) -#define STR_OPENLOCKED_OPENCOPY_BTN (RID_UUI_START + 35) -#define STR_FILECHANGED_TITLE (RID_UUI_START + 36) -#define STR_FILECHANGED_MSG (RID_UUI_START + 37) -#define STR_FILECHANGED_SAVEANYWAY_BTN (RID_UUI_START + 38) -#define STR_ALREADYOPEN_TITLE (RID_UUI_START + 39) -#define STR_ALREADYOPEN_MSG (RID_UUI_START + 40) -#define STR_ALREADYOPEN_READONLY_BTN (RID_UUI_START + 41) -#define STR_ALREADYOPEN_OPEN_BTN (RID_UUI_START + 42) -#define STR_LOCKFAILED_TITLE (RID_UUI_START + 43) -#define STR_LOCKFAILED_MSG (RID_UUI_START + 44) -#define STR_LOCKFAILED_DONTSHOWAGAIN (RID_UUI_START + 45) -#define STR_TRYLATER_TITLE (RID_UUI_START + 46) -#define STR_TRYLATER_MSG (RID_UUI_START + 47) -#define STR_TRYLATER_RETRYSAVING_BTN (RID_UUI_START + 48) -#define STR_TRYLATER_SAVEAS_BTN (RID_UUI_START + 49) -#define STR_ALREADYOPEN_SAVE_MSG (RID_UUI_START + 50) -#define STR_ALREADYOPEN_RETRY_SAVE_BTN (RID_UUI_START + 51) -#define STR_ALREADYOPEN_SAVE_BTN (RID_UUI_START + 52) -#define RID_DLG_NEWER_VERSION_WARNING (RID_UUI_START + 53) -#define STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE (RID_UUI_START + 54) +#define RID_UUI_ERRHDL (RID_UUI_START + 20) +#define DLG_UUI_MASTERPASSWORD_CRT (RID_UUI_START + 21) +#define DLG_UUI_PASSWORD (RID_UUI_START + 22) +#define DLG_UUI_PASSWORD_CRT (RID_UUI_START + 23) +#define STR_ERROR_PASSWORD_TO_OPEN_WRONG (RID_UUI_START + 24) +#define STR_ERROR_PASSWORD_TO_MODIFY_WRONG (RID_UUI_START + 25) +#define DLG_UUI_UNKNOWNAUTH (RID_UUI_START + 26) +#define DLG_UUI_UNKNOWNAUTH_CRT (RID_UUI_START + 27) +#define DLG_UUI_SSLWARN (RID_UUI_START + 28) +#define DLG_UUI_SSLWARN_CRT (RID_UUI_START + 29) +#define RID_XMLSECDLG_MACROWARN (RID_UUI_START + 30) +#define STR_UNKNOWNUSER (RID_UUI_START + 31) +#define STR_OPENLOCKED_TITLE (RID_UUI_START + 32) +#define STR_OPENLOCKED_MSG (RID_UUI_START + 33) +#define STR_OPENLOCKED_OPENREADONLY_BTN (RID_UUI_START + 34) +#define STR_OPENLOCKED_OPENCOPY_BTN (RID_UUI_START + 35) +#define STR_FILECHANGED_TITLE (RID_UUI_START + 36) +#define STR_FILECHANGED_MSG (RID_UUI_START + 37) +#define STR_FILECHANGED_SAVEANYWAY_BTN (RID_UUI_START + 38) +#define STR_ALREADYOPEN_TITLE (RID_UUI_START + 39) +#define STR_ALREADYOPEN_MSG (RID_UUI_START + 40) +#define STR_ALREADYOPEN_READONLY_BTN (RID_UUI_START + 41) +#define STR_ALREADYOPEN_OPEN_BTN (RID_UUI_START + 42) +#define STR_LOCKFAILED_TITLE (RID_UUI_START + 43) +#define STR_LOCKFAILED_MSG (RID_UUI_START + 44) +#define STR_LOCKFAILED_DONTSHOWAGAIN (RID_UUI_START + 45) +#define STR_TRYLATER_TITLE (RID_UUI_START + 46) +#define STR_TRYLATER_MSG (RID_UUI_START + 47) +#define STR_TRYLATER_RETRYSAVING_BTN (RID_UUI_START + 48) +#define STR_TRYLATER_SAVEAS_BTN (RID_UUI_START + 49) +#define STR_ALREADYOPEN_SAVE_MSG (RID_UUI_START + 50) +#define STR_ALREADYOPEN_RETRY_SAVE_BTN (RID_UUI_START + 51) +#define STR_ALREADYOPEN_SAVE_BTN (RID_UUI_START + 52) +#define RID_DLG_NEWER_VERSION_WARNING (RID_UUI_START + 53) +#define STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE (RID_UUI_START + 54) +#define STR_WARNING_BROKENSIGNATURE_TITLE (RID_UUI_START + 55) +#define STR_ENTER_PASSWORD_TO_OPEN (RID_UUI_START + 56) +#define STR_ENTER_PASSWORD_TO_MODIFY (RID_UUI_START + 57) -#define ERRCODE_UUI_IO_ABORT (ERRCODE_AREA_UUI + 0) -#define ERRCODE_UUI_IO_ACCESSDENIED (ERRCODE_AREA_UUI + 1) -#define ERRCODE_UUI_IO_ALREADYEXISTS (ERRCODE_AREA_UUI + 2) -#define ERRCODE_UUI_IO_BADCRC (ERRCODE_AREA_UUI + 3) -#define ERRCODE_UUI_IO_CANTCREATE (ERRCODE_AREA_UUI + 4) -#define ERRCODE_UUI_IO_CANTREAD (ERRCODE_AREA_UUI + 5) -#define ERRCODE_UUI_IO_CANTSEEK (ERRCODE_AREA_UUI + 6) -#define ERRCODE_UUI_IO_CANTTELL (ERRCODE_AREA_UUI + 7) -#define ERRCODE_UUI_IO_CANTWRITE (ERRCODE_AREA_UUI + 8) -#define ERRCODE_UUI_IO_CURRENTDIR (ERRCODE_AREA_UUI + 9) -#define ERRCODE_UUI_IO_NOTREADY (ERRCODE_AREA_UUI + 10) -#define ERRCODE_UUI_IO_NOTSAMEDEVICE (ERRCODE_AREA_UUI + 11) -#define ERRCODE_UUI_IO_GENERAL (ERRCODE_AREA_UUI + 12) -#define ERRCODE_UUI_IO_INVALIDACCESS (ERRCODE_AREA_UUI + 13) -#define ERRCODE_UUI_IO_INVALIDCHAR (ERRCODE_AREA_UUI + 14) -#define ERRCODE_UUI_IO_INVALIDDEVICE (ERRCODE_AREA_UUI + 15) -#define ERRCODE_UUI_IO_INVALIDLENGTH (ERRCODE_AREA_UUI + 16) -#define ERRCODE_UUI_IO_INVALIDPARAMETER (ERRCODE_AREA_UUI + 17) -#define ERRCODE_UUI_IO_ISWILDCARD (ERRCODE_AREA_UUI + 18) -#define ERRCODE_UUI_IO_LOCKVIOLATION (ERRCODE_AREA_UUI + 19) -#define ERRCODE_UUI_IO_MISPLACEDCHAR (ERRCODE_AREA_UUI + 20) -#define ERRCODE_UUI_IO_NAMETOOLONG (ERRCODE_AREA_UUI + 21) -#define ERRCODE_UUI_IO_NOTEXISTS (ERRCODE_AREA_UUI + 22) -#define ERRCODE_UUI_IO_NOTEXISTSPATH (ERRCODE_AREA_UUI + 23) -#define ERRCODE_UUI_IO_NOTSUPPORTED (ERRCODE_AREA_UUI + 24) -#define ERRCODE_UUI_IO_NOTADIRECTORY (ERRCODE_AREA_UUI + 25) -#define ERRCODE_UUI_IO_NOTAFILE (ERRCODE_AREA_UUI + 26) -#define ERRCODE_UUI_IO_OUTOFSPACE (ERRCODE_AREA_UUI + 27) -#define ERRCODE_UUI_IO_TOOMANYOPENFILES (ERRCODE_AREA_UUI + 28) -#define ERRCODE_UUI_IO_OUTOFMEMORY (ERRCODE_AREA_UUI + 29) -#define ERRCODE_UUI_IO_PENDING (ERRCODE_AREA_UUI + 30) -#define ERRCODE_UUI_IO_RECURSIVE (ERRCODE_AREA_UUI + 31) -#define ERRCODE_UUI_IO_UNKNOWN (ERRCODE_AREA_UUI + 32) -#define ERRCODE_UUI_IO_WRITEPROTECTED (ERRCODE_AREA_UUI + 33) -#define ERRCODE_UUI_IO_WRONGFORMAT (ERRCODE_AREA_UUI + 34) -#define ERRCODE_UUI_IO_WRONGVERSION (ERRCODE_AREA_UUI + 35) -#define ERRCODE_UUI_IO_NOTEXISTS_VOLUME (ERRCODE_AREA_UUI + 36) -#define ERRCODE_UUI_IO_NOTEXISTS_FOLDER (ERRCODE_AREA_UUI + 37) -#define ERRCODE_UUI_WRONGJAVA (ERRCODE_AREA_UUI + 38) -#define ERRCODE_UUI_WRONGJAVA_VERSION (ERRCODE_AREA_UUI + 39) -#define ERRCODE_UUI_WRONGJAVA_MIN (ERRCODE_AREA_UUI + 40) -#define ERRCODE_UUI_WRONGJAVA_VERSION_MIN (ERRCODE_AREA_UUI + 41) -#define ERRCODE_UUI_BADPARTNERSHIP (ERRCODE_AREA_UUI + 42) -#define ERRCODE_UUI_BADPARTNERSHIP_NAME (ERRCODE_AREA_UUI + 43) -#define ERRCODE_UUI_IO_NOTREADY_VOLUME (ERRCODE_AREA_UUI + 44) -#define ERRCODE_UUI_IO_NOTREADY_REMOVABLE (ERRCODE_AREA_UUI + 45) -#define ERRCODE_UUI_IO_NOTREADY_VOLUME_REMOVABLE (ERRCODE_AREA_UUI + 46) -#define ERRCODE_UUI_WRONGMEDIUM (ERRCODE_AREA_UUI + 47) -#define ERRCODE_UUI_IO_CANTCREATE_NONAME (ERRCODE_AREA_UUI + 48) -#define ERRCODE_UUI_IO_TARGETALREADYEXISTS (ERRCODE_AREA_UUI + 49) -#define ERRCODE_UUI_IO_UNSUPPORTEDOVERWRITE (ERRCODE_AREA_UUI + 50) -#define ERRCODE_UUI_IO_BROKENPACKAGE (ERRCODE_AREA_UUI + 51) -#define ERRCODE_UUI_IO_BROKENPACKAGE_CANTREPAIR (ERRCODE_AREA_UUI + 52) -#define ERRCODE_UUI_CONFIGURATION_BROKENDATA_NOREMOVE (ERRCODE_AREA_UUI + 53) -#define ERRCODE_UUI_CONFIGURATION_BROKENDATA_WITHREMOVE (ERRCODE_AREA_UUI + 54) -#define ERRCODE_UUI_CONFIGURATION_BACKENDMISSING (ERRCODE_AREA_UUI + 55) -#define ERRCODE_UUI_CONFIGURATION_BACKENDMISSING_WITHRECOVER (ERRCODE_AREA_UUI + 56) -#define ERRCODE_UUI_INVALID_XFORMS_SUBMISSION_DATA (ERRCODE_AREA_UUI + 57) -#define ERRCODE_UUI_IO_MODULESIZEEXCEEDED (ERRCODE_AREA_UUI + 58) -#define ERRCODE_UUI_LOCKING_LOCKED (ERRCODE_AREA_UUI + 59) -#define ERRCODE_UUI_LOCKING_LOCKED_SELF (ERRCODE_AREA_UUI + 60) -#define ERRCODE_UUI_LOCKING_NOT_LOCKED (ERRCODE_AREA_UUI + 61) -#define ERRCODE_UUI_LOCKING_LOCK_EXPIRED (ERRCODE_AREA_UUI + 62) +#define ERRCODE_UUI_IO_ABORT (ERRCODE_AREA_UUI + 0) +#define ERRCODE_UUI_IO_ACCESSDENIED (ERRCODE_AREA_UUI + 1) +#define ERRCODE_UUI_IO_ALREADYEXISTS (ERRCODE_AREA_UUI + 2) +#define ERRCODE_UUI_IO_BADCRC (ERRCODE_AREA_UUI + 3) +#define ERRCODE_UUI_IO_CANTCREATE (ERRCODE_AREA_UUI + 4) +#define ERRCODE_UUI_IO_CANTREAD (ERRCODE_AREA_UUI + 5) +#define ERRCODE_UUI_IO_CANTSEEK (ERRCODE_AREA_UUI + 6) +#define ERRCODE_UUI_IO_CANTTELL (ERRCODE_AREA_UUI + 7) +#define ERRCODE_UUI_IO_CANTWRITE (ERRCODE_AREA_UUI + 8) +#define ERRCODE_UUI_IO_CURRENTDIR (ERRCODE_AREA_UUI + 9) +#define ERRCODE_UUI_IO_NOTREADY (ERRCODE_AREA_UUI + 10) +#define ERRCODE_UUI_IO_NOTSAMEDEVICE (ERRCODE_AREA_UUI + 11) +#define ERRCODE_UUI_IO_GENERAL (ERRCODE_AREA_UUI + 12) +#define ERRCODE_UUI_IO_INVALIDACCESS (ERRCODE_AREA_UUI + 13) +#define ERRCODE_UUI_IO_INVALIDCHAR (ERRCODE_AREA_UUI + 14) +#define ERRCODE_UUI_IO_INVALIDDEVICE (ERRCODE_AREA_UUI + 15) +#define ERRCODE_UUI_IO_INVALIDLENGTH (ERRCODE_AREA_UUI + 16) +#define ERRCODE_UUI_IO_INVALIDPARAMETER (ERRCODE_AREA_UUI + 17) +#define ERRCODE_UUI_IO_ISWILDCARD (ERRCODE_AREA_UUI + 18) +#define ERRCODE_UUI_IO_LOCKVIOLATION (ERRCODE_AREA_UUI + 19) +#define ERRCODE_UUI_IO_MISPLACEDCHAR (ERRCODE_AREA_UUI + 20) +#define ERRCODE_UUI_IO_NAMETOOLONG (ERRCODE_AREA_UUI + 21) +#define ERRCODE_UUI_IO_NOTEXISTS (ERRCODE_AREA_UUI + 22) +#define ERRCODE_UUI_IO_NOTEXISTSPATH (ERRCODE_AREA_UUI + 23) +#define ERRCODE_UUI_IO_NOTSUPPORTED (ERRCODE_AREA_UUI + 24) +#define ERRCODE_UUI_IO_NOTADIRECTORY (ERRCODE_AREA_UUI + 25) +#define ERRCODE_UUI_IO_NOTAFILE (ERRCODE_AREA_UUI + 26) +#define ERRCODE_UUI_IO_OUTOFSPACE (ERRCODE_AREA_UUI + 27) +#define ERRCODE_UUI_IO_TOOMANYOPENFILES (ERRCODE_AREA_UUI + 28) +#define ERRCODE_UUI_IO_OUTOFMEMORY (ERRCODE_AREA_UUI + 29) +#define ERRCODE_UUI_IO_PENDING (ERRCODE_AREA_UUI + 30) +#define ERRCODE_UUI_IO_RECURSIVE (ERRCODE_AREA_UUI + 31) +#define ERRCODE_UUI_IO_UNKNOWN (ERRCODE_AREA_UUI + 32) +#define ERRCODE_UUI_IO_WRITEPROTECTED (ERRCODE_AREA_UUI + 33) +#define ERRCODE_UUI_IO_WRONGFORMAT (ERRCODE_AREA_UUI + 34) +#define ERRCODE_UUI_IO_WRONGVERSION (ERRCODE_AREA_UUI + 35) +#define ERRCODE_UUI_IO_NOTEXISTS_VOLUME (ERRCODE_AREA_UUI + 36) +#define ERRCODE_UUI_IO_NOTEXISTS_FOLDER (ERRCODE_AREA_UUI + 37) +#define ERRCODE_UUI_WRONGJAVA (ERRCODE_AREA_UUI + 38) +#define ERRCODE_UUI_WRONGJAVA_VERSION (ERRCODE_AREA_UUI + 39) +#define ERRCODE_UUI_WRONGJAVA_MIN (ERRCODE_AREA_UUI + 40) +#define ERRCODE_UUI_WRONGJAVA_VERSION_MIN (ERRCODE_AREA_UUI + 41) +#define ERRCODE_UUI_BADPARTNERSHIP (ERRCODE_AREA_UUI + 42) +#define ERRCODE_UUI_BADPARTNERSHIP_NAME (ERRCODE_AREA_UUI + 43) +#define ERRCODE_UUI_IO_NOTREADY_VOLUME (ERRCODE_AREA_UUI + 44) +#define ERRCODE_UUI_IO_NOTREADY_REMOVABLE (ERRCODE_AREA_UUI + 45) +#define ERRCODE_UUI_IO_NOTREADY_VOLUME_REMOVABLE (ERRCODE_AREA_UUI + 46) +#define ERRCODE_UUI_WRONGMEDIUM (ERRCODE_AREA_UUI + 47) +#define ERRCODE_UUI_IO_CANTCREATE_NONAME (ERRCODE_AREA_UUI + 48) +#define ERRCODE_UUI_IO_TARGETALREADYEXISTS (ERRCODE_AREA_UUI + 49) +#define ERRCODE_UUI_IO_UNSUPPORTEDOVERWRITE (ERRCODE_AREA_UUI + 50) +#define ERRCODE_UUI_IO_BROKENPACKAGE (ERRCODE_AREA_UUI + 51) +#define ERRCODE_UUI_IO_BROKENPACKAGE_CANTREPAIR (ERRCODE_AREA_UUI + 52) +#define ERRCODE_UUI_CONFIGURATION_BROKENDATA_NOREMOVE (ERRCODE_AREA_UUI + 53) +#define ERRCODE_UUI_CONFIGURATION_BROKENDATA_WITHREMOVE (ERRCODE_AREA_UUI + 54) +#define ERRCODE_UUI_CONFIGURATION_BACKENDMISSING (ERRCODE_AREA_UUI + 55) +#define ERRCODE_UUI_CONFIGURATION_BACKENDMISSING_WITHRECOVER (ERRCODE_AREA_UUI + 56) +#define ERRCODE_UUI_INVALID_XFORMS_SUBMISSION_DATA (ERRCODE_AREA_UUI + 57) +#define ERRCODE_UUI_IO_MODULESIZEEXCEEDED (ERRCODE_AREA_UUI + 58) +#define ERRCODE_UUI_LOCKING_LOCKED (ERRCODE_AREA_UUI + 59) +#define ERRCODE_UUI_LOCKING_LOCKED_SELF (ERRCODE_AREA_UUI + 60) +#define ERRCODE_UUI_LOCKING_NOT_LOCKED (ERRCODE_AREA_UUI + 61) +#define ERRCODE_UUI_LOCKING_LOCK_EXPIRED (ERRCODE_AREA_UUI + 62) -#define ERRCODE_AREA_UUI_UNKNOWNAUTH 25000 -#define SSLWARN_TYPE_DOMAINMISMATCH 10 -#define SSLWARN_TYPE_EXPIRED 20 -#define SSLWARN_TYPE_INVALID 30 +#define ERRCODE_AREA_UUI_UNKNOWNAUTH 25000 +#define SSLWARN_TYPE_DOMAINMISMATCH 10 +#define SSLWARN_TYPE_EXPIRED 20 +#define SSLWARN_TYPE_INVALID 30 #define ERRCODE_UUI_UNKNOWNAUTH_UNTRUSTED (ERRCODE_AREA_UUI_UNKNOWNAUTH + 1) @@ -170,17 +173,17 @@ #define ERRCODE_UUI_SSLWARN_INVALID_1 (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 1) #define TITLE_UUI_SSLWARN_INVALID (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 3) -#define HID_DLG_LOGIN (HID_UUI_START + 0) -#define HID_DLG_COOKIES (HID_UUI_START + 1) -#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START+2) -#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START+3) -#define HID_DLG_FILTER_SELECT (HID_UUI_START+4) -#define HID_DLG_PASSWORD_UUI (HID_UUI_START+5) -#define HID_DLG_PASSWORD_CRT (HID_UUI_START+6) -#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START+7) -#define HID_DLG_SSLWARN_UUI (HID_UUI_START+8) -#define HID_XMLSECDLG_MACROWARN (HID_UUI_START+9) -#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START+10) +#define HID_DLG_LOGIN (HID_UUI_START + 0) +#define HID_DLG_COOKIES (HID_UUI_START + 1) +#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START + 2) +#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START + 3) +#define HID_DLG_FILTER_SELECT (HID_UUI_START + 4) +#define HID_DLG_PASSWORD_UUI (HID_UUI_START + 5) +#define HID_DLG_PASSWORD_CRT (HID_UUI_START + 6) +#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START + 7) +#define HID_DLG_SSLWARN_UUI (HID_UUI_START + 8) +#define HID_XMLSECDLG_MACROWARN (HID_UUI_START + 9) +#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START +10) // HID_UUI_END (aka HID_CHAOS_NEW_DATABASE) is reserved in // sfx2/util/hidother.src diff --git a/uui/source/passworddlg.cxx b/uui/source/passworddlg.cxx old mode 100644 new mode 100755 index 4a2c584cf123..eaba330c85ec --- a/uui/source/passworddlg.cxx +++ b/uui/source/passworddlg.cxx @@ -51,30 +51,34 @@ IMPL_LINK( PasswordDialog, OKHdl_Impl, OKButton *, EMPTYARG ) // ----------------------------------------------------------------------- -PasswordDialog::PasswordDialog -( +PasswordDialog::PasswordDialog( Window* _pParent, ::com::sun::star::task::PasswordRequestMode nDlgMode, ResMgr * pResMgr, - rtl::OUString& aDocURL - ) + rtl::OUString& aDocURL, + bool bOpenToModify ) + :ModalDialog( _pParent, ResId( DLG_UUI_PASSWORD, *pResMgr ) ) - ,aFTPassword ( this, ResId( FT_PASSWORD, *pResMgr ) ) - ,aEDPassword ( this, ResId( ED_PASSWORD, *pResMgr ) ) - ,aOKBtn ( this, ResId( BTN_PASSWORD_OK, *pResMgr ) ) - ,aCancelBtn ( this, ResId( BTN_PASSWORD_CANCEL, *pResMgr ) ) - ,aHelpBtn ( this, ResId( BTN_PASSWORD_HELP, *pResMgr ) ) - ,aFixedLine1 ( this, ResId( FL_FIXED_LINE_1, *pResMgr ) ) - ,nDialogMode ( nDlgMode ) - ,pResourceMgr ( pResMgr ) + ,aFTPassword( this, ResId( FT_PASSWORD, *pResMgr )) + ,aEDPassword( this, ResId( ED_PASSWORD, *pResMgr )) + ,aOKBtn ( this, ResId( BTN_PASSWORD_OK, *pResMgr )) + ,aCancelBtn ( this, ResId( BTN_PASSWORD_CANCEL, *pResMgr )) + ,aHelpBtn ( this, ResId( BTN_PASSWORD_HELP, *pResMgr )) + ,aFixedLine1( this, ResId( FL_FIXED_LINE_1, *pResMgr )) + ,nDialogMode( nDlgMode ) + ,pResourceMgr ( pResMgr ) { if( nDialogMode == ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER ) { - String aErrorMsg( ResId( STR_ERROR_PASSWORD_WRONG, *pResourceMgr )); + USHORT nErrStrId = bOpenToModify ? STR_ERROR_PASSWORD_TO_MODIFY_WRONG : STR_ERROR_PASSWORD_TO_OPEN_WRONG; + String aErrorMsg( ResId( nErrStrId, *pResourceMgr )); ErrorBox aErrorBox( _pParent, WB_OK, aErrorMsg ); aErrorBox.Execute(); } + USHORT nStrId = bOpenToModify ? STR_ENTER_PASSWORD_TO_MODIFY : STR_ENTER_PASSWORD_TO_OPEN; + aFTPassword.SetText( String( ResId( nStrId, *pResourceMgr ) ) ); + FreeResource(); aFTPassword.SetText( aFTPassword.GetText() + aDocURL ); diff --git a/uui/source/passworddlg.hxx b/uui/source/passworddlg.hxx old mode 100644 new mode 100755 index 75f65b456ac7..c5cb136022da --- a/uui/source/passworddlg.hxx +++ b/uui/source/passworddlg.hxx @@ -53,7 +53,7 @@ class PasswordDialog : public ModalDialog DECL_LINK( OKHdl_Impl, OKButton * ); public: - PasswordDialog( Window* pParent, ::com::sun::star::task::PasswordRequestMode nDlgMode, ResMgr * pResMgr, ::rtl::OUString& aDocURL ); + PasswordDialog( Window* pParent, ::com::sun::star::task::PasswordRequestMode nDlgMode, ResMgr * pResMgr, ::rtl::OUString& aDocURL, bool bOpenToModify = false ); String GetPassword() const { return aEDPassword.GetText(); } diff --git a/uui/source/passworddlg.src b/uui/source/passworddlg.src old mode 100644 new mode 100755 index c9b8dfe0847e..682d8921cf5b --- a/uui/source/passworddlg.src +++ b/uui/source/passworddlg.src @@ -46,11 +46,11 @@ ModalDialog DLG_UUI_PASSWORD SVLook = TRUE ; Size = MAP_APPFONT( 145, 75 ); Text [ en-US ] = "Enter password"; + FixedText FT_PASSWORD { Pos = MAP_APPFONT( 3, 4 ); Size = MAP_APPFONT( 139, 28 ); - Text [ en-US ] = "Enter password to open file: \n"; WordBreak = TRUE; }; @@ -87,5 +87,15 @@ ModalDialog DLG_UUI_PASSWORD Pos = MAP_APPFONT( 0, 50 ); Size = MAP_APPFONT( 145, 6 ); }; + + String STR_ENTER_PASSWORD_TO_OPEN + { + Text [ en-US ] = "Enter password to open file: \n"; + }; + + String STR_ENTER_PASSWORD_TO_MODIFY + { + Text [ en-US ] = "Enter password to modify file: \n"; + }; }; diff --git a/uui/source/passworderrs.src b/uui/source/passworderrs.src old mode 100644 new mode 100755 index 90aa5688610e..1573cfbc8bb3 --- a/uui/source/passworderrs.src +++ b/uui/source/passworderrs.src @@ -34,9 +34,14 @@ #include #endif -String STR_ERROR_PASSWORD_WRONG +String STR_ERROR_PASSWORD_TO_OPEN_WRONG { - Text [ en-US ] = "The password is incorrect. The document cannot be opened."; + Text [ en-US ] = "The password is incorrect. The file cannot be opened."; +}; + +String STR_ERROR_PASSWORD_TO_MODIFY_WRONG +{ + Text [ en-US ] = "The password is incorrect. The file cannot be modified."; }; String STR_ERROR_MASTERPASSWORD_WRONG -- cgit From 8e594b080d8d542b1cdd9a2b90bd79215fb72ff8 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 4 Mar 2010 13:39:59 +0100 Subject: tl78: #i109779# add SID_MODIFYPASSWORDHASH --- sfx2/inc/sfx2/sfxsids.hrc | 3 ++- sfx2/sdi/sfx.sdi | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index bcbb39c96638..8ec890d3f2c4 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -575,7 +575,8 @@ #define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) #define SID_FONT_NAME (SID_SFX_START + 1716) #define SID_DEFAULTFILENAME (SID_SFX_START + 1717) -#define SID_SFX_free_START (SID_SFX_START + 1718) +#define SID_MODIFYPASSWORDHASH (SID_SFX_START + 1718) +#define SID_SFX_free_START (SID_SFX_START + 1719) #define SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 26f55ccdd178..29797a258ea2 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3993,6 +3993,33 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER GroupId = GID_MACRO; ] +//-------------------------------------------------------------------------- +SfxInt32Item ModifyPasswordHash SID_MODIFYPASSWORDHASH + +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = TRUE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + Readonly = TRUE, + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = ; +] + //-------------------------------------------------------------------------- SfxVoidItem RunMacro SID_RUNMACRO () -- cgit From 8a44a90d32ee4dd2e9b3813e485ed4c0fe30cb12 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 4 Mar 2010 16:14:56 +0100 Subject: #i109634# password to open/modify dialog --- uui/source/iahndl-authentication.cxx | 92 +++++++++++++++++++++--------------- uui/source/loginerr.hxx | 12 +++++ 2 files changed, 66 insertions(+), 38 deletions(-) mode change 100644 => 100755 uui/source/loginerr.hxx diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index 18c8d94b573a..e910d27d1132 100755 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -31,6 +31,7 @@ #include "com/sun/star/task/DocumentPasswordRequest.hpp" #include "com/sun/star/task/DocumentPasswordRequest2.hpp" #include "com/sun/star/task/DocumentMSPasswordRequest.hpp" +#include "com/sun/star/task/DocumentMSPasswordRequest2.hpp" #include "com/sun/star/task/MasterPasswordRequest.hpp" #include "com/sun/star/task/XInteractionAbort.hpp" #include "com/sun/star/task/XInteractionPassword.hpp" @@ -43,6 +44,7 @@ #include "vos/mutex.hxx" #include "tools/errcode.hxx" #include "vcl/msgbox.hxx" +#include "vcl/abstdlg.hxx" #include "vcl/svapp.hxx" #include "ids.hrc" @@ -72,10 +74,8 @@ executeLoginDialog( { vos::OGuard aGuard(Application::GetSolarMutex()); - bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) - != 0; - bool bSavePassword = rInfo.GetIsPersistentPassword() - || rInfo.GetIsSavePassword(); + bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0; + bool bSavePassword = rInfo.GetIsPersistentPassword() || rInfo.GetIsSavePassword(); bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials(); sal_uInt16 nFlags = 0; @@ -94,15 +94,10 @@ executeLoginDialog( if (!bCanUseSysCreds) nFlags |= LF_NO_USESYSCREDS; - std::auto_ptr< ResMgr > xManager( - ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); + std::auto_ptr< ResMgr > xManager( ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); UniString aRealm(rRealm); std::auto_ptr< LoginDialog > xDialog( - new LoginDialog(pParent, - nFlags, - rInfo.GetServer(), - &aRealm, - xManager.get())); + new LoginDialog( pParent, nFlags, rInfo.GetServer(), &aRealm, xManager.get())); if (rInfo.GetErrorText().Len() != 0) xDialog->SetErrorText(rInfo.GetErrorText()); xDialog->SetName(rInfo.GetUserName()); @@ -114,17 +109,14 @@ executeLoginDialog( if (bSavePassword) { - xDialog-> - SetSavePasswordText(ResId(rInfo.GetIsPersistentPassword() ? - RID_SAVE_PASSWORD : - RID_KEEP_PASSWORD, - *xManager.get())); + sal_uInt32 nResId = rInfo.GetIsPersistentPassword() ? + RID_SAVE_PASSWORD : RID_KEEP_PASSWORD; + xDialog->SetSavePasswordText( ResId( nResId, *xManager.get()) ); xDialog->SetSavePassword(rInfo.GetIsSavePassword()); } if ( bCanUseSysCreds ) - xDialog->SetUseSystemCredentials( - rInfo.GetIsUseSystemCredentials() ); + xDialog->SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() ); rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); @@ -423,7 +415,8 @@ executePasswordDialog( LoginErrorInfo & rInfo, task::PasswordRequestMode nMode, ::rtl::OUString aDocName, - bool bMSCryptoMode) + bool bMSCryptoMode, + bool bIsPasswordToModify ) SAL_THROW((uno::RuntimeException)) { try @@ -434,23 +427,25 @@ executePasswordDialog( ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); if( nMode == task::PasswordRequestMode_PASSWORD_CREATE ) { - std::auto_ptr< PasswordCreateDialog > xDialog( - new PasswordCreateDialog(pParent, - xManager.get(), - bMSCryptoMode)); + const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length - rInfo.SetResult(xDialog->Execute() - == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); - rInfo.SetPassword( xDialog->GetPassword() ); + VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create(); + std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog( + pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen ) ); + + rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); + rInfo.SetPasswordToOpen( pDialog->GetPasswordToOpen() ); + rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() ); + rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() ); } else { - std::auto_ptr< PasswordDialog > xDialog( - new PasswordDialog(pParent, nMode, xManager.get(), aDocName)); + std::auto_ptr< PasswordDialog > pDialog( + new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) ); - rInfo.SetResult(xDialog->Execute() - == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); - rInfo.SetPassword( xDialog->GetPassword() ); + rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); + rInfo.SetPasswordToOpen( bIsPasswordToModify ? String() : pDialog->GetPassword() ); + rInfo.SetPasswordToModify( bIsPasswordToModify ? pDialog->GetPassword() : String() ); } } catch (std::bad_alloc const &) @@ -468,7 +463,8 @@ handlePasswordRequest_( uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations, ::rtl::OUString aDocumentName, - bool bMSCryptoMode ) + bool bMSCryptoMode, + bool bIsPasswordToModify ) SAL_THROW((uno::RuntimeException)) { uno::Reference< task::XInteractionRetry > xRetry; @@ -477,11 +473,8 @@ handlePasswordRequest_( getContinuations(rContinuations, &xRetry, &xAbort, &xPassword); LoginErrorInfo aInfo; - executePasswordDialog(pParent, - aInfo, - nMode, - aDocumentName, - bMSCryptoMode); + executePasswordDialog( pParent, aInfo, nMode, + aDocumentName, bMSCryptoMode, bIsPasswordToModify ); switch (aInfo.GetResult()) { @@ -575,6 +568,17 @@ UUIInteractionHelper::handlePasswordRequest( uno::Any aAnyRequest(rRequest->getRequest()); + task::DocumentPasswordRequest2 aDocumentPasswordRequest2; + if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest2)) + { + nMode = aDocumentPasswordRequest2.Mode; + aDocumentName = aDocumentPasswordRequest2.Name; + OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" ); + bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify; + + bDoHandleRequest = true; + } + task::DocumentPasswordRequest aDocumentPasswordRequest; if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest)) { @@ -586,6 +590,17 @@ UUIInteractionHelper::handlePasswordRequest( bDoHandleRequest = true; } + task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2; + if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest2)) + { + nMode = aDocumentMSPasswordRequest2.Mode; + aDocumentName = aDocumentMSPasswordRequest2.Name; + bMSCryptoMode = true; + bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify; + + bDoHandleRequest = true; + } + task::DocumentMSPasswordRequest aDocumentMSPasswordRequest; if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest)) { @@ -599,7 +614,8 @@ UUIInteractionHelper::handlePasswordRequest( if (bDoHandleRequest) { - handlePasswordRequest_( pParent, nMode, rContinuations, aDocumentName, bMSCryptoMode ); + handlePasswordRequest_( pParent, nMode, rContinuations, + aDocumentName, bMSCryptoMode, bIsPasswordToModify ); return true; } diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx old mode 100644 new mode 100755 index 6fc00c3b1eac..c09917ae04fe --- a/uui/source/loginerr.hxx +++ b/uui/source/loginerr.hxx @@ -50,10 +50,13 @@ private: String _aAccount; String _aUserName; String _aPassword; + String _aPasswordToOpen; + String _aPasswordToModify; String _aPath; String _aErrorText; BYTE _nFlags; USHORT _nRet; + bool _bRecommendToOpenReadonly; public: LoginErrorInfo() @@ -67,6 +70,9 @@ public: const String& GetAccount() const { return _aAccount; } const String& GetUserName() const { return _aUserName; } const String& GetPassword() const { return _aPassword; } + const String& GetPasswordToOpen() const { return _aPasswordToOpen; } + const String& GetPasswordToModify() const { return _aPasswordToModify; } + const bool IsRecommendToOpenReadonly() const { return _bRecommendToOpenReadonly; } const String& GetPath() const { return _aPath; } const String& GetErrorText() const { return _aErrorText; } BOOL GetIsPersistentPassword() const @@ -91,6 +97,12 @@ public: { _aUserName = aUserName; } void SetPassword( const String& aPassword ) { _aPassword = aPassword; } + void SetPasswordToOpen( const String& aPassword ) + { _aPasswordToOpen = aPassword; } + void SetPasswordToModify( const String& aPassword ) + { _aPasswordToModify = aPassword; } + void SetRecommendToOpenReadonly( bool bVal ) + { _bRecommendToOpenReadonly = bVal; } void SetPath( const String& aPath ) { _aPath = aPath; } void SetErrorText( const String& aErrorText ) -- cgit From 790814ab03bed7d1a05f36ce560292c5f25896a1 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 11 Mar 2010 15:22:09 +0100 Subject: #i110048# rearranging controls of the password dialog --- uui/source/logindlg.cxx | 153 +++++++++++++++++++--------------------- uui/source/logindlg.hrc | 16 +++-- uui/source/logindlg.hxx | 43 +++++------- uui/source/logindlg.src | 181 +++++++++++++++++++++++------------------------- 4 files changed, 188 insertions(+), 205 deletions(-) mode change 100644 => 100755 uui/source/logindlg.cxx mode change 100644 => 100755 uui/source/logindlg.hrc mode change 100644 => 100755 uui/source/logindlg.hxx mode change 100644 => 100755 uui/source/logindlg.src diff --git a/uui/source/logindlg.cxx b/uui/source/logindlg.cxx old mode 100644 new mode 100755 index 53ea243c9577..941c6c2558c8 --- a/uui/source/logindlg.cxx +++ b/uui/source/logindlg.cxx @@ -47,6 +47,14 @@ //............................................................................ //............................................................................ +static void lcl_Move( Window &rWin, long nOffset ) +{ + Point aTmp( rWin.GetPosPixel() ); + aTmp.Y() -= nOffset; + rWin.SetPosPixel( aTmp ); +} + + void LoginDialog::HideControls_Impl( USHORT nFlags ) { FASTBOOL bPathHide = FALSE; @@ -91,7 +99,8 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) if ( ( nFlags & LF_NO_ERRORTEXT ) == LF_NO_ERRORTEXT ) { aErrorInfo.Hide(); - aErrorGB.Hide(); + aErrorFT.Hide(); + aLogin1FL.Hide(); bErrorHide = TRUE; } @@ -110,53 +119,28 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) if ( bErrorHide ) { - long nOffset = aLoginGB.GetPosPixel().Y() - - aErrorGB.GetPosPixel().Y(); - Point aNewPnt = aRequestInfo.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aRequestInfo.SetPosPixel( aNewPnt ); - aNewPnt = aPathFT.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPathFT.SetPosPixel( aNewPnt ); - aNewPnt = aPathED.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPathED.SetPosPixel( aNewPnt ); - aNewPnt = aPathInfo.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPathInfo.SetPosPixel( aNewPnt ); - aNewPnt = aPathBtn.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPathBtn.SetPosPixel( aNewPnt ); - aNewPnt = aNameFT.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aNameFT.SetPosPixel( aNewPnt ); - aNewPnt = aNameED.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aNameED.SetPosPixel( aNewPnt ); - aNewPnt = aNameInfo.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aNameInfo.SetPosPixel( aNewPnt ); - aNewPnt = aPasswordFT.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPasswordFT.SetPosPixel( aNewPnt ); - aNewPnt = aPasswordED.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aPasswordED.SetPosPixel( aNewPnt ); - aNewPnt = aAccountFT.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aAccountFT.SetPosPixel( aNewPnt ); - aNewPnt = aAccountED.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aAccountED.SetPosPixel( aNewPnt ); - aNewPnt = aSavePasswdBtn.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aSavePasswdBtn.SetPosPixel( aNewPnt ); - aNewPnt = aUseSysCredsCB.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aUseSysCredsCB.SetPosPixel( aNewPnt ); - aNewPnt = aLoginGB.GetPosPixel(); - aNewPnt.Y() -= nOffset; - aLoginGB.SetPosPixel( aNewPnt ); + long nOffset = aRequestInfo.GetPosPixel().Y() - + aErrorFT.GetPosPixel().Y(); + lcl_Move( aRequestInfo, nOffset ); + lcl_Move( aLogin2FL, nOffset ); + lcl_Move( aPathFT, nOffset ); + lcl_Move( aPathED, nOffset ); + lcl_Move( aPathInfo, nOffset ); + lcl_Move( aPathBtn, nOffset ); + lcl_Move( aNameFT, nOffset ); + lcl_Move( aNameED, nOffset ); + lcl_Move( aNameInfo, nOffset ); + lcl_Move( aPasswordFT, nOffset ); + lcl_Move( aPasswordED, nOffset ); + lcl_Move( aAccountFT, nOffset ); + lcl_Move( aAccountED, nOffset ); + lcl_Move( aSavePasswdBtn, nOffset ); + lcl_Move( aUseSysCredsCB, nOffset ); + lcl_Move( aButtonsFL, nOffset ); + lcl_Move( aOKBtn, nOffset ); + lcl_Move( aCancelBtn, nOffset ); + lcl_Move( aHelpBtn, nOffset ); + Size aNewSiz = GetSizePixel(); aNewSiz.Height() -= nOffset; SetSizePixel( aNewSiz ); @@ -166,24 +150,20 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) { long nOffset = aNameED.GetPosPixel().Y() - aPathED.GetPosPixel().Y(); + lcl_Move( aNameFT, nOffset ); + lcl_Move( aNameED, nOffset ); + lcl_Move( aNameInfo, nOffset ); + lcl_Move( aPasswordFT, nOffset ); + lcl_Move( aPasswordED, nOffset ); + lcl_Move( aAccountFT, nOffset ); + lcl_Move( aAccountED, nOffset ); + lcl_Move( aSavePasswdBtn, nOffset ); + lcl_Move( aUseSysCredsCB, nOffset ); + lcl_Move( aButtonsFL, nOffset ); + lcl_Move( aOKBtn, nOffset ); + lcl_Move( aCancelBtn, nOffset ); + lcl_Move( aHelpBtn, nOffset ); - Point aTmpPnt1 = aNameFT.GetPosPixel(); - Point aTmpPnt2 = aPasswordFT.GetPosPixel(); - aNameFT.SetPosPixel( aPathFT.GetPosPixel() ); - aPasswordFT.SetPosPixel( aTmpPnt1 ); - aAccountFT.SetPosPixel( aTmpPnt2 ); - aTmpPnt1 = aNameED.GetPosPixel(); - aTmpPnt2 = aPasswordED.GetPosPixel(); - aNameED.SetPosPixel( aPathED.GetPosPixel() ); - aPasswordED.SetPosPixel( aTmpPnt1 ); - aAccountED.SetPosPixel( aTmpPnt2 ); - aNameInfo.SetPosPixel( aPathInfo.GetPosPixel() ); - aTmpPnt1 = aSavePasswdBtn.GetPosPixel(); - aTmpPnt1.Y() -= nOffset; - aSavePasswdBtn.SetPosPixel( aTmpPnt1 ); - aTmpPnt1 = aUseSysCredsCB.GetPosPixel(); - aTmpPnt1.Y() -= nOffset; - aUseSysCredsCB.SetPosPixel( aTmpPnt1 ); Size aNewSz = GetSizePixel(); aNewSz.Height() -= nOffset; SetSizePixel( aNewSz ); @@ -191,14 +171,15 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) if ( bAccountHide ) { - long nOffset = aAccountED.GetPosPixel().Y() - aPasswordED.GetPosPixel().Y(); - - Point aTmpPnt = aSavePasswdBtn.GetPosPixel(); - aTmpPnt.Y() -= nOffset; - aSavePasswdBtn.SetPosPixel( aTmpPnt ); - aTmpPnt = aUseSysCredsCB.GetPosPixel(); - aTmpPnt.Y() -= nOffset; - aUseSysCredsCB.SetPosPixel( aTmpPnt ); + long nOffset = aAccountED.GetPosPixel().Y() - + aPasswordED.GetPosPixel().Y(); + lcl_Move( aSavePasswdBtn, nOffset ); + lcl_Move( aUseSysCredsCB, nOffset ); + lcl_Move( aButtonsFL, nOffset ); + lcl_Move( aOKBtn, nOffset ); + lcl_Move( aCancelBtn, nOffset ); + lcl_Move( aHelpBtn, nOffset ); + Size aNewSz = GetSizePixel(); aNewSz.Height() -= nOffset; SetSizePixel( aNewSz ); @@ -208,6 +189,10 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) { long nOffset = aUseSysCredsCB.GetPosPixel().Y() - aSavePasswdBtn.GetPosPixel().Y(); + lcl_Move( aButtonsFL, nOffset ); + lcl_Move( aOKBtn, nOffset ); + lcl_Move( aCancelBtn, nOffset ); + lcl_Move( aHelpBtn, nOffset ); Size aNewSz = GetSizePixel(); aNewSz.Height() -= nOffset; @@ -219,7 +204,7 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) void LoginDialog::EnableUseSysCredsControls_Impl( BOOL bUseSysCredsEnabled ) { aErrorInfo.Enable( !bUseSysCredsEnabled ); - aErrorGB.Enable( !bUseSysCredsEnabled ); + aErrorFT.Enable( !bUseSysCredsEnabled ); aRequestInfo.Enable( !bUseSysCredsEnabled ); aPathFT.Enable( !bUseSysCredsEnabled ); aPathED.Enable( !bUseSysCredsEnabled ); @@ -282,23 +267,25 @@ LoginDialog::LoginDialog ModalDialog( pParent, ResId( DLG_UUI_LOGIN, *pResMgr ) ), - aErrorInfo ( this, ResId( INFO_LOGIN_ERROR, *pResMgr ) ), - aErrorGB ( this, ResId( GB_LOGIN_ERROR, *pResMgr ) ), - aRequestInfo ( this, ResId( INFO_LOGIN_REQUEST, *pResMgr ) ), + aErrorFT ( this, ResId( FT_LOGIN_ERROR, *pResMgr ) ), + aErrorInfo ( this, ResId( FT_INFO_LOGIN_ERROR, *pResMgr ) ), + aLogin1FL ( this, ResId( FL_LOGIN_1, *pResMgr ) ), + aRequestInfo ( this, ResId( FT_INFO_LOGIN_REQUEST, *pResMgr ) ), + aLogin2FL ( this, ResId( FL_LOGIN_2, *pResMgr ) ), aPathFT ( this, ResId( FT_LOGIN_PATH, *pResMgr ) ), aPathED ( this, ResId( ED_LOGIN_PATH, *pResMgr ) ), - aPathInfo ( this, ResId( INFO_LOGIN_PATH, *pResMgr ) ), + aPathInfo ( this, ResId( FT_INFO_LOGIN_PATH, *pResMgr ) ), aPathBtn ( this, ResId( BTN_LOGIN_PATH, *pResMgr ) ), aNameFT ( this, ResId( FT_LOGIN_USERNAME, *pResMgr ) ), aNameED ( this, ResId( ED_LOGIN_USERNAME, *pResMgr ) ), - aNameInfo ( this, ResId( INFO_LOGIN_USERNAME, *pResMgr ) ), + aNameInfo ( this, ResId( FT_INFO_LOGIN_USERNAME, *pResMgr ) ), aPasswordFT ( this, ResId( FT_LOGIN_PASSWORD, *pResMgr ) ), aPasswordED ( this, ResId( ED_LOGIN_PASSWORD, *pResMgr ) ), aAccountFT ( this, ResId( FT_LOGIN_ACCOUNT, *pResMgr ) ), aAccountED ( this, ResId( ED_LOGIN_ACCOUNT, *pResMgr ) ), aSavePasswdBtn ( this, ResId( CB_LOGIN_SAVEPASSWORD, *pResMgr ) ), aUseSysCredsCB ( this, ResId( CB_LOGIN_USESYSCREDS, *pResMgr ) ), - aLoginGB ( this, ResId( GB_LOGIN_LOGIN, *pResMgr ) ), + aButtonsFL ( this, ResId( FL_BUTTONS, *pResMgr ) ), aOKBtn ( this, ResId( BTN_LOGIN_OK, *pResMgr ) ), aCancelBtn ( this, ResId( BTN_LOGIN_CANCEL, *pResMgr ) ), aHelpBtn ( this, ResId( BTN_LOGIN_HELP, *pResMgr ) ) @@ -333,6 +320,12 @@ LoginDialog::LoginDialog // ----------------------------------------------------------------------- +LoginDialog::~LoginDialog() +{ +} + +// ----------------------------------------------------------------------- + void LoginDialog::SetName( const String& rNewName ) { aNameED.SetText( rNewName ); diff --git a/uui/source/logindlg.hrc b/uui/source/logindlg.hrc old mode 100644 new mode 100755 index 68162fb620cd..b6e1f52444fd --- a/uui/source/logindlg.hrc +++ b/uui/source/logindlg.hrc @@ -30,24 +30,26 @@ //============================================================================ -#define INFO_LOGIN_ERROR 10 -#define GB_LOGIN_ERROR 11 +#define FT_INFO_LOGIN_ERROR 10 +#define FT_LOGIN_ERROR 11 -#define INFO_LOGIN_REQUEST 20 +#define FT_INFO_LOGIN_REQUEST 20 #define FT_LOGIN_PATH 21 #define ED_LOGIN_PATH 22 -#define INFO_LOGIN_PATH 23 +#define FT_INFO_LOGIN_PATH 23 #define BTN_LOGIN_PATH 24 #define FT_LOGIN_USERNAME 25 #define ED_LOGIN_USERNAME 26 -#define INFO_LOGIN_USERNAME 27 +#define FT_INFO_LOGIN_USERNAME 27 #define FT_LOGIN_PASSWORD 28 #define ED_LOGIN_PASSWORD 29 #define FT_LOGIN_ACCOUNT 30 #define ED_LOGIN_ACCOUNT 31 #define CB_LOGIN_SAVEPASSWORD 32 -#define GB_LOGIN_LOGIN 33 -#define CB_LOGIN_USESYSCREDS 34 +#define CB_LOGIN_USESYSCREDS 33 +#define FL_LOGIN_1 34 +#define FL_LOGIN_2 35 +#define FL_BUTTONS 36 #define BTN_LOGIN_OK 50 #define BTN_LOGIN_CANCEL 51 diff --git a/uui/source/logindlg.hxx b/uui/source/logindlg.hxx old mode 100644 new mode 100755 index 0a4637d89251..04ea8eb7523d --- a/uui/source/logindlg.hxx +++ b/uui/source/logindlg.hxx @@ -53,9 +53,11 @@ //============================================================================ class LoginDialog : public ModalDialog { + FixedText aErrorFT; FixedInfo aErrorInfo; - FixedLine aErrorGB; + FixedLine aLogin1FL; FixedInfo aRequestInfo; + FixedLine aLogin2FL; FixedText aPathFT; Edit aPathED; FixedInfo aPathInfo; @@ -69,7 +71,7 @@ class LoginDialog : public ModalDialog Edit aAccountED; CheckBox aSavePasswdBtn; CheckBox aUseSysCredsCB; - FixedLine aLoginGB; + FixedLine aButtonsFL; OKButton aOKBtn; CancelButton aCancelBtn; HelpButton aHelpBtn; @@ -85,32 +87,23 @@ public: LoginDialog( Window* pParent, USHORT nFlags, const String& rServer, const String* pRealm, ResMgr * pResMgr ); + virtual ~LoginDialog(); - String GetPath() const { return aPathED.GetText(); } - void SetPath( const String& rNewPath ) - { aPathED.SetText( rNewPath ); - aPathInfo.SetText( rNewPath );} - String GetName() const { return aNameED.GetText(); } + String GetPath() const { return aPathED.GetText(); } + void SetPath( const String& rNewPath ) { aPathED.SetText( rNewPath ); aPathInfo.SetText( rNewPath ); } + String GetName() const { return aNameED.GetText(); } void SetName( const String& rNewName ); - String GetPassword() const { return aPasswordED.GetText(); } - void SetPassword( const String& rNew ) - { aPasswordED.SetText( rNew ); } - String GetAccount() const { return aAccountED.GetText(); } - void SetAccount( const String& rNew ) - { aAccountED.SetText( rNew ); } - BOOL IsSavePassword() const - { return aSavePasswdBtn.IsChecked(); } - void SetSavePassword( BOOL bSave ) - { aSavePasswdBtn.Check( bSave ); } - void SetSavePasswordText( const String& rTxt ) - { aSavePasswdBtn.SetText( rTxt ); } - BOOL IsUseSystemCredentials() const - { return aUseSysCredsCB.IsChecked(); } + String GetPassword() const { return aPasswordED.GetText(); } + void SetPassword( const String& rNew ) { aPasswordED.SetText( rNew ); } + String GetAccount() const { return aAccountED.GetText(); } + void SetAccount( const String& rNew ) { aAccountED.SetText( rNew ); } + BOOL IsSavePassword() const { return aSavePasswdBtn.IsChecked(); } + void SetSavePassword( BOOL bSave ) { aSavePasswdBtn.Check( bSave ); } + void SetSavePasswordText( const String& rTxt ) { aSavePasswdBtn.SetText( rTxt ); } + BOOL IsUseSystemCredentials() const { return aUseSysCredsCB.IsChecked(); } void SetUseSystemCredentials( BOOL bUse ); - void SetErrorText( const String& rTxt ) - { aErrorInfo.SetText( rTxt ); } - void SetLoginRequestText( const String& rTxt ) - { aRequestInfo.SetText( rTxt ); } + void SetErrorText( const String& rTxt ) { aErrorInfo.SetText( rTxt ); } + void SetLoginRequestText( const String& rTxt ) { aRequestInfo.SetText( rTxt ); } void ClearPassword(); void ClearAccount(); }; diff --git a/uui/source/logindlg.src b/uui/source/logindlg.src old mode 100644 new mode 100755 index ce998f4945be..f997fb7b7f34 --- a/uui/source/logindlg.src +++ b/uui/source/logindlg.src @@ -16,7 +16,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). + *(a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see @@ -42,166 +42,161 @@ ModalDialog DLG_UUI_LOGIN Moveable = TRUE ; OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT ( 265 , 170 ) ; - FixedText INFO_LOGIN_ERROR + Size = MAP_APPFONT( 177 , 247 ) ; + Text [ en-US ] = "Authentication Required" ; + + FixedText FT_LOGIN_ERROR + { + Pos = MAP_APPFONT( 6 , 6 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; + Text [ en-US ] = "Message from server:" ; + }; + + FixedText FT_INFO_LOGIN_ERROR { - Pos = MAP_APPFONT ( 12 , 14 ) ; - Size = MAP_APPFONT ( 185 , 18 ) ; + Pos = MAP_APPFONT( 6 , 14 ) ; + Size = MAP_APPFONT( 185 , 3*8 ) ; WordBreak = TRUE ; }; - FixedLine GB_LOGIN_ERROR + + FixedLine FL_LOGIN_1 { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 197 , 8 ) ; - Text [ en-US ] = "Message from server" ; + Pos = MAP_APPFONT( 6 , 41 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; }; - FixedText INFO_LOGIN_REQUEST + + FixedText FT_INFO_LOGIN_REQUEST { - Pos = MAP_APPFONT ( 12 , 55 ) ; - Size = MAP_APPFONT ( 185 , 18 ) ; + Pos = MAP_APPFONT( 6 , 52 ) ; + Size = MAP_APPFONT( 185 , 2*8 ) ; WordBreak = TRUE ; - Text [ en-US ] = "Enter the user name and password for %1 here." ; + Text [ en-US ] = "Enter user name and password for: \n%1" ; + }; + + String STR_LOGIN_REALM + { + Text [ en-US ] = "Enter user name and password for: \n\"%2\" on %1" ; + }; + + FixedLine FL_LOGIN_2 + { + Pos = MAP_APPFONT( 6 , 71 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; }; + FixedText FT_LOGIN_PATH { - Pos = MAP_APPFONT ( 12 , 77 ) ; - Size = MAP_APPFONT ( 57 , 10 ) ; + Pos = MAP_APPFONT( 6 , 84 ) ; + Size = MAP_APPFONT( 112 , 8 ) ; Text [ en-US ] = "~Path" ; }; + Edit ED_LOGIN_PATH { Border = TRUE ; - Pos = MAP_APPFONT ( 72 , 76 ) ; - Size = MAP_APPFONT ( 108 , 12 ) ; + Pos = MAP_APPFONT( 6 , 95 ) ; + Size = MAP_APPFONT( 112 , 12 ) ; }; - FixedText INFO_LOGIN_PATH + FixedText FT_INFO_LOGIN_PATH // used instead of ED_LOGIN_PATH when LF_PATH_READONLY is set { Hide = TRUE ; - Pos = MAP_APPFONT ( 72 , 77 ) ; - Size = MAP_APPFONT ( 125 , 10 ) ; + Pos = MAP_APPFONT( 6 , 97 ) ; + Size = MAP_APPFONT( 112 , 8 ) ; }; PushButton BTN_LOGIN_PATH { - Pos = MAP_APPFONT ( 183 , 75 ) ; - Size = MAP_APPFONT ( 14 , 14 ) ; - Text = "~..." ; + Pos = MAP_APPFONT( 121 , 94 ) ; + Size = MAP_APPFONT( 50 , 14 ) ; + Text = "~Browse..." ; }; + FixedText FT_LOGIN_USERNAME { - Pos = MAP_APPFONT ( 12 , 92 ) ; - Size = MAP_APPFONT ( 57 , 10 ) ; + Pos = MAP_APPFONT( 6 , 110 ) ; + Size = MAP_APPFONT( 106 , 8 ) ; Text [ en-US ] = "~User name" ; }; + Edit ED_LOGIN_USERNAME { Border = TRUE ; - Pos = MAP_APPFONT ( 72 , 91 ) ; - Size = MAP_APPFONT ( 125 , 12 ) ; + Pos = MAP_APPFONT( 6 , 121 ) ; + Size = MAP_APPFONT( 165 , 12 ) ; }; - FixedText INFO_LOGIN_USERNAME + FixedText FT_INFO_LOGIN_USERNAME // used instead of ED_LOGIN_USERNAME when LF_USERNAME_READONLY is set { Hide = TRUE ; - Pos = MAP_APPFONT ( 72 , 92 ) ; - Size = MAP_APPFONT ( 125 , 10 ) ; + Pos = MAP_APPFONT( 6 , 123 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; }; + FixedText FT_LOGIN_PASSWORD { - Pos = MAP_APPFONT ( 12 , 107 ) ; - Size = MAP_APPFONT ( 57 , 10 ) ; + Pos = MAP_APPFONT( 6 , 136 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; Text [ en-US ] = "Pass~word" ; }; + Edit ED_LOGIN_PASSWORD { Border = TRUE ; - Pos = MAP_APPFONT ( 72 , 106 ) ; - Size = MAP_APPFONT ( 125 , 12 ) ; + Pos = MAP_APPFONT( 6 , 147 ) ; + Size = MAP_APPFONT( 165 , 12 ) ; PassWord = TRUE ; }; + FixedText FT_LOGIN_ACCOUNT { - Pos = MAP_APPFONT ( 12 , 122 ) ; - Size = MAP_APPFONT ( 57 , 10 ) ; + Pos = MAP_APPFONT( 6 , 162 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; Text [ en-US ] = "A~ccount"; }; + Edit ED_LOGIN_ACCOUNT { Border = TRUE ; - Pos = MAP_APPFONT ( 72 , 121 ) ; - Size = MAP_APPFONT ( 125 , 12 ) ; + Pos = MAP_APPFONT( 6 , 173 ) ; + Size = MAP_APPFONT( 165 , 12 ) ; PassWord = TRUE ; }; + CheckBox CB_LOGIN_SAVEPASSWORD { - Pos = MAP_APPFONT ( 12 , 136 ) ; - Size = MAP_APPFONT ( 185 , 10 ) ; - Text [ en-US ] = "~Save password" ; + Pos = MAP_APPFONT( 6 , 190 ) ; + Size = MAP_APPFONT( 165 , 10 ) ; + Text [ en-US ] = "~Remember password" ; }; + CheckBox CB_LOGIN_USESYSCREDS { - Pos = MAP_APPFONT ( 12 , 148 ) ; - Size = MAP_APPFONT ( 185 , 10 ) ; - Text [ en-US ] = "~Use System Credentials" ; + Pos = MAP_APPFONT( 6 , 203 ) ; + Size = MAP_APPFONT( 165 , 10 ) ; + Text [ en-US ] = "~Use system credentials" ; }; - FixedLine GB_LOGIN_LOGIN + + FixedLine FL_BUTTONS { - Pos = MAP_APPFONT ( 7 , 44 ) ; - Size = MAP_APPFONT ( 197 , 8 ) ; - Text [ en-US ] = "Log in" ; + Pos = MAP_APPFONT( 0 , 216 ) ; + Size = MAP_APPFONT( 177 , 8 ) ; }; + OKButton BTN_LOGIN_OK { - Pos = MAP_APPFONT ( 209 , 6 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + Pos = MAP_APPFONT( 6 , 227 ) ; + Size = MAP_APPFONT( 50 , 14 ) ; DefButton = TRUE ; }; + CancelButton BTN_LOGIN_CANCEL { - Pos = MAP_APPFONT ( 209 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + Pos = MAP_APPFONT( 66 , 227 ) ; + Size = MAP_APPFONT( 50 , 14 ) ; }; + HelpButton BTN_LOGIN_HELP { - Pos = MAP_APPFONT ( 209 , 43 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - }; - String STR_LOGIN_REALM - { - Text [ en-US ] = "Please enter user name and password for \"%2\" on %1 here." ; + Pos = MAP_APPFONT( 121 , 227 ) ; + Size = MAP_APPFONT( 50 , 14 ) ; }; - Text [ en-US ] = "User Name and Password Required" ; }; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit From 3fa4688994df161df3742fcb75a54cc059276259 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 16 Mar 2010 11:35:19 +0100 Subject: cws tl79: #i110048# further changes to the LoginDialog --- uui/source/logindlg.cxx | 31 +++++++------------------------ uui/source/logindlg.hrc | 26 ++++++++++++-------------- uui/source/logindlg.hxx | 9 +++++---- uui/source/logindlg.src | 18 +++--------------- 4 files changed, 27 insertions(+), 57 deletions(-) diff --git a/uui/source/logindlg.cxx b/uui/source/logindlg.cxx index 941c6c2558c8..d7ded58b5dde 100755 --- a/uui/source/logindlg.cxx +++ b/uui/source/logindlg.cxx @@ -57,10 +57,10 @@ static void lcl_Move( Window &rWin, long nOffset ) void LoginDialog::HideControls_Impl( USHORT nFlags ) { - FASTBOOL bPathHide = FALSE; - FASTBOOL bErrorHide = FALSE; - FASTBOOL bAccountHide = FALSE; - FASTBOOL bUseSysCredsHide = FALSE; + bool bPathHide = FALSE; + bool bErrorHide = FALSE; + bool bAccountHide = FALSE; + bool bUseSysCredsHide = FALSE; if ( ( nFlags & LF_NO_PATH ) == LF_NO_PATH ) { @@ -71,9 +71,8 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) } else if ( ( nFlags & LF_PATH_READONLY ) == LF_PATH_READONLY ) { - aPathED.Hide(); - aPathInfo.Show(); - aPathBtn.Hide(); + aPathED.Enable( FALSE ); + aPathBtn.Enable( FALSE ); } if ( ( nFlags & LF_NO_USERNAME ) == LF_NO_USERNAME ) @@ -83,8 +82,7 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) } else if ( ( nFlags & LF_USERNAME_READONLY ) == LF_USERNAME_READONLY ) { - aNameED.Hide(); - aNameInfo.Show(); + aNameED.Enable( FALSE ); } if ( ( nFlags & LF_NO_PASSWORD ) == LF_NO_PASSWORD ) @@ -125,11 +123,9 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) lcl_Move( aLogin2FL, nOffset ); lcl_Move( aPathFT, nOffset ); lcl_Move( aPathED, nOffset ); - lcl_Move( aPathInfo, nOffset ); lcl_Move( aPathBtn, nOffset ); lcl_Move( aNameFT, nOffset ); lcl_Move( aNameED, nOffset ); - lcl_Move( aNameInfo, nOffset ); lcl_Move( aPasswordFT, nOffset ); lcl_Move( aPasswordED, nOffset ); lcl_Move( aAccountFT, nOffset ); @@ -152,7 +148,6 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) aPathED.GetPosPixel().Y(); lcl_Move( aNameFT, nOffset ); lcl_Move( aNameED, nOffset ); - lcl_Move( aNameInfo, nOffset ); lcl_Move( aPasswordFT, nOffset ); lcl_Move( aPasswordED, nOffset ); lcl_Move( aAccountFT, nOffset ); @@ -208,11 +203,9 @@ void LoginDialog::EnableUseSysCredsControls_Impl( BOOL bUseSysCredsEnabled ) aRequestInfo.Enable( !bUseSysCredsEnabled ); aPathFT.Enable( !bUseSysCredsEnabled ); aPathED.Enable( !bUseSysCredsEnabled ); - aPathInfo.Enable( !bUseSysCredsEnabled ); aPathBtn.Enable( !bUseSysCredsEnabled ); aNameFT.Enable( !bUseSysCredsEnabled ); aNameED.Enable( !bUseSysCredsEnabled ); - aNameInfo.Enable( !bUseSysCredsEnabled ); aPasswordFT.Enable( !bUseSysCredsEnabled ); aPasswordED.Enable( !bUseSysCredsEnabled ); aAccountFT.Enable( !bUseSysCredsEnabled ); @@ -274,11 +267,9 @@ LoginDialog::LoginDialog aLogin2FL ( this, ResId( FL_LOGIN_2, *pResMgr ) ), aPathFT ( this, ResId( FT_LOGIN_PATH, *pResMgr ) ), aPathED ( this, ResId( ED_LOGIN_PATH, *pResMgr ) ), - aPathInfo ( this, ResId( FT_INFO_LOGIN_PATH, *pResMgr ) ), aPathBtn ( this, ResId( BTN_LOGIN_PATH, *pResMgr ) ), aNameFT ( this, ResId( FT_LOGIN_USERNAME, *pResMgr ) ), aNameED ( this, ResId( ED_LOGIN_USERNAME, *pResMgr ) ), - aNameInfo ( this, ResId( FT_INFO_LOGIN_USERNAME, *pResMgr ) ), aPasswordFT ( this, ResId( FT_LOGIN_PASSWORD, *pResMgr ) ), aPasswordED ( this, ResId( ED_LOGIN_PASSWORD, *pResMgr ) ), aAccountFT ( this, ResId( FT_LOGIN_ACCOUNT, *pResMgr ) ), @@ -326,14 +317,6 @@ LoginDialog::~LoginDialog() // ----------------------------------------------------------------------- -void LoginDialog::SetName( const String& rNewName ) -{ - aNameED.SetText( rNewName ); - aNameInfo.SetText( rNewName ); -} - -// ----------------------------------------------------------------------- - void LoginDialog::SetUseSystemCredentials( BOOL bUse ) { if ( aUseSysCredsCB.IsVisible() ) diff --git a/uui/source/logindlg.hrc b/uui/source/logindlg.hrc index b6e1f52444fd..b541740bd768 100755 --- a/uui/source/logindlg.hrc +++ b/uui/source/logindlg.hrc @@ -36,20 +36,18 @@ #define FT_INFO_LOGIN_REQUEST 20 #define FT_LOGIN_PATH 21 #define ED_LOGIN_PATH 22 -#define FT_INFO_LOGIN_PATH 23 -#define BTN_LOGIN_PATH 24 -#define FT_LOGIN_USERNAME 25 -#define ED_LOGIN_USERNAME 26 -#define FT_INFO_LOGIN_USERNAME 27 -#define FT_LOGIN_PASSWORD 28 -#define ED_LOGIN_PASSWORD 29 -#define FT_LOGIN_ACCOUNT 30 -#define ED_LOGIN_ACCOUNT 31 -#define CB_LOGIN_SAVEPASSWORD 32 -#define CB_LOGIN_USESYSCREDS 33 -#define FL_LOGIN_1 34 -#define FL_LOGIN_2 35 -#define FL_BUTTONS 36 +#define BTN_LOGIN_PATH 23 +#define FT_LOGIN_USERNAME 24 +#define ED_LOGIN_USERNAME 25 +#define FT_LOGIN_PASSWORD 26 +#define ED_LOGIN_PASSWORD 27 +#define FT_LOGIN_ACCOUNT 28 +#define ED_LOGIN_ACCOUNT 29 +#define CB_LOGIN_SAVEPASSWORD 30 +#define CB_LOGIN_USESYSCREDS 31 +#define FL_LOGIN_1 32 +#define FL_LOGIN_2 33 +#define FL_BUTTONS 34 #define BTN_LOGIN_OK 50 #define BTN_LOGIN_CANCEL 51 diff --git a/uui/source/logindlg.hxx b/uui/source/logindlg.hxx index 04ea8eb7523d..05ba8e8d55d4 100755 --- a/uui/source/logindlg.hxx +++ b/uui/source/logindlg.hxx @@ -60,11 +60,9 @@ class LoginDialog : public ModalDialog FixedLine aLogin2FL; FixedText aPathFT; Edit aPathED; - FixedInfo aPathInfo; PushButton aPathBtn; FixedText aNameFT; Edit aNameED; - FixedInfo aNameInfo; FixedText aPasswordFT; Edit aPasswordED; FixedText aAccountFT; @@ -90,9 +88,9 @@ public: virtual ~LoginDialog(); String GetPath() const { return aPathED.GetText(); } - void SetPath( const String& rNewPath ) { aPathED.SetText( rNewPath ); aPathInfo.SetText( rNewPath ); } + void SetPath( const String& rNewPath ) { aPathED.SetText( rNewPath ); } String GetName() const { return aNameED.GetText(); } - void SetName( const String& rNewName ); + void SetName( const String& rNewName ) { aNameED.SetText( rNewName ); } String GetPassword() const { return aPasswordED.GetText(); } void SetPassword( const String& rNew ) { aPasswordED.SetText( rNew ); } String GetAccount() const { return aAccountED.GetText(); } @@ -108,6 +106,9 @@ public: void ClearAccount(); }; +// ----------------------------------------------------------------------- + + //............................................................................ //............................................................................ diff --git a/uui/source/logindlg.src b/uui/source/logindlg.src index f997fb7b7f34..c2683ea3d94c 100755 --- a/uui/source/logindlg.src +++ b/uui/source/logindlg.src @@ -55,7 +55,7 @@ ModalDialog DLG_UUI_LOGIN FixedText FT_INFO_LOGIN_ERROR { Pos = MAP_APPFONT( 6 , 14 ) ; - Size = MAP_APPFONT( 185 , 3*8 ) ; + Size = MAP_APPFONT( 165 , 3*8 ) ; WordBreak = TRUE ; }; @@ -68,7 +68,7 @@ ModalDialog DLG_UUI_LOGIN FixedText FT_INFO_LOGIN_REQUEST { Pos = MAP_APPFONT( 6 , 52 ) ; - Size = MAP_APPFONT( 185 , 2*8 ) ; + Size = MAP_APPFONT( 165 , 2*8 ) ; WordBreak = TRUE ; Text [ en-US ] = "Enter user name and password for: \n%1" ; }; @@ -97,12 +97,6 @@ ModalDialog DLG_UUI_LOGIN Pos = MAP_APPFONT( 6 , 95 ) ; Size = MAP_APPFONT( 112 , 12 ) ; }; - FixedText FT_INFO_LOGIN_PATH // used instead of ED_LOGIN_PATH when LF_PATH_READONLY is set - { - Hide = TRUE ; - Pos = MAP_APPFONT( 6 , 97 ) ; - Size = MAP_APPFONT( 112 , 8 ) ; - }; PushButton BTN_LOGIN_PATH { Pos = MAP_APPFONT( 121 , 94 ) ; @@ -113,7 +107,7 @@ ModalDialog DLG_UUI_LOGIN FixedText FT_LOGIN_USERNAME { Pos = MAP_APPFONT( 6 , 110 ) ; - Size = MAP_APPFONT( 106 , 8 ) ; + Size = MAP_APPFONT( 165 , 8 ) ; Text [ en-US ] = "~User name" ; }; @@ -123,12 +117,6 @@ ModalDialog DLG_UUI_LOGIN Pos = MAP_APPFONT( 6 , 121 ) ; Size = MAP_APPFONT( 165 , 12 ) ; }; - FixedText FT_INFO_LOGIN_USERNAME // used instead of ED_LOGIN_USERNAME when LF_USERNAME_READONLY is set - { - Hide = TRUE ; - Pos = MAP_APPFONT( 6 , 123 ) ; - Size = MAP_APPFONT( 165 , 8 ) ; - }; FixedText FT_LOGIN_PASSWORD { -- cgit From a84618d8076b877ca77c217d33aa7457ee95fc1b Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Wed, 17 Mar 2010 08:53:20 +0100 Subject: whitespace cleanup. --- uui/source/loginerr.hxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx index c8cbba96564b..14cce88e0534 100644 --- a/uui/source/loginerr.hxx +++ b/uui/source/loginerr.hxx @@ -32,10 +32,10 @@ //========================================================================= -#define LOGINERROR_FLAG_SET_SAVE_PASSWORD 1 -#define LOGINERROR_FLAG_MODIFY_ACCOUNT 2 -#define LOGINERROR_FLAG_MODIFY_USER_NAME 4 -#define LOGINERROR_FLAG_PERSISTENT_PASSWORD 8 +#define LOGINERROR_FLAG_SET_SAVE_PASSWORD 1 +#define LOGINERROR_FLAG_MODIFY_ACCOUNT 2 +#define LOGINERROR_FLAG_MODIFY_USER_NAME 4 +#define LOGINERROR_FLAG_PERSISTENT_PASSWORD 8 #define LOGINERROR_FLAG_CAN_USE_SYSCREDS 16 #define LOGINERROR_FLAG_IS_USE_SYSCREDS 32 -- cgit From 52a1c736c09537fdf0de42c13100f2616c8305f1 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Thu, 18 Mar 2010 11:11:15 +0100 Subject: #i110213# - credentials handling improvements. --- ucb/source/ucp/webdav/DAVAuthListener.hxx | 3 - ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx | 1 - ucb/source/ucp/webdav/DAVResourceAccess.cxx | 4 +- ucb/source/ucp/webdav/NeonSession.cxx | 21 --- uui/source/iahndl-authentication.cxx | 194 ++++++++++++++++++-------- uui/source/loginerr.hxx | 55 +++++--- uui/source/passwordcontainer.cxx | 13 +- 7 files changed, 186 insertions(+), 105 deletions(-) diff --git a/ucb/source/ucp/webdav/DAVAuthListener.hxx b/ucb/source/ucp/webdav/DAVAuthListener.hxx index c092f9fd311f..71bed1c0a14d 100644 --- a/ucb/source/ucp/webdav/DAVAuthListener.hxx +++ b/ucb/source/ucp/webdav/DAVAuthListener.hxx @@ -30,9 +30,7 @@ #include #include -#ifndef _COM_SUN_STAR_UCB_XREFERENCE_HPP_ #include -#endif #include namespace webdav_ucp @@ -46,7 +44,6 @@ class DAVAuthListener : public salhelper::SimpleReferenceObject const ::rtl::OUString & inHostName, ::rtl::OUString & inoutUserName, ::rtl::OUString & outPassWord, - sal_Bool bAllowPersistentStoring, sal_Bool bCanUseSystemCredentials ) = 0; }; diff --git a/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx b/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx index 3d03cc63952b..c0c9968613af 100644 --- a/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx +++ b/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx @@ -61,7 +61,6 @@ namespace webdav_ucp const ::rtl::OUString & inHostName, ::rtl::OUString & inoutUserName, ::rtl::OUString & outPassWord, - sal_Bool bAllowPersistentStoring, sal_Bool bCanUseSystemCredentials ); private: diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx index ea1c09efaa3f..1f1aa68c29c0 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx @@ -57,7 +57,6 @@ int DAVAuthListener_Impl::authenticate( const ::rtl::OUString & inHostName, ::rtl::OUString & inoutUserName, ::rtl::OUString & outPassWord, - sal_Bool bAllowPersistentStoring, sal_Bool bCanUseSystemCredentials ) { if ( m_xEnv.is() ) @@ -79,7 +78,8 @@ int DAVAuthListener_Impl::authenticate( = new ucbhelper::SimpleAuthenticationRequest( m_aURL, inHostName, inRealm, inoutUserName, outPassWord, ::rtl::OUString(), - bAllowPersistentStoring, bCanUseSystemCredentials ); + true /*bAllowPersistentStoring*/, + bCanUseSystemCredentials ); xIH->handle( xRequest.get() ); rtl::Reference< ucbhelper::InteractionContinuation > xSelection diff --git a/ucb/source/ucp/webdav/NeonSession.cxx b/ucb/source/ucp/webdav/NeonSession.cxx index 0d979ae72ada..1558a8ff6734 100644 --- a/ucb/source/ucp/webdav/NeonSession.cxx +++ b/ucb/source/ucp/webdav/NeonSession.cxx @@ -60,7 +60,6 @@ #include #include #include -#include #include #include @@ -330,31 +329,11 @@ extern "C" int NeonSession_NeonAuth( void * inUserData, ( ne_strcasecmp( inAuthProtocol, "Negotiate" ) == 0 ) ); #endif - // #i97003# (tkr): Ask XMasterPasswordHandling if we should store the - // credentials persistently and give this information to the auth listener - uno::Reference< task::XMasterPasswordHandling > xMasterPasswordHandling; - try - { - xMasterPasswordHandling = - uno::Reference< task::XMasterPasswordHandling >( - theSession->getMSF()->createInstance( - rtl::OUString::createFromAscii( - "com.sun.star.task.PasswordContainer" ) ), - uno::UNO_QUERY ); - } - catch ( uno::Exception const & ) - { - } - int theRetVal = pListener->authenticate( rtl::OUString::createFromAscii( inRealm ), theSession->getHostName(), theUserName, thePassWord, - xMasterPasswordHandling.is() - ? xMasterPasswordHandling-> - isPersistentStoringAllowed() - : sal_False, bCanUseSystemCreds); rtl::OString aUser( diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index f31397f1ef92..81f79c1b75e4 100644 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -67,10 +67,9 @@ executeLoginDialog( { vos::OGuard aGuard(Application::GetSolarMutex()); - bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) - != 0; - bool bSavePassword = rInfo.GetIsPersistentPassword() - || rInfo.GetIsSavePassword(); + bool bAccount + = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0; + bool bSavePassword = rInfo.GetCanRememberPassword(); bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials(); sal_uInt16 nFlags = 0; @@ -82,10 +81,8 @@ executeLoginDialog( nFlags |= LF_NO_ACCOUNT; if (!(rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME)) nFlags |= LF_USERNAME_READONLY; - if (!bSavePassword) nFlags |= LF_NO_SAVEPASSWORD; - if (!bCanUseSysCreds) nFlags |= LF_NO_USESYSCREDS; @@ -109,12 +106,13 @@ executeLoginDialog( if (bSavePassword) { - xDialog-> - SetSavePasswordText(ResId(rInfo.GetIsPersistentPassword() ? - RID_SAVE_PASSWORD : - RID_KEEP_PASSWORD, - *xManager.get())); - xDialog->SetSavePassword(rInfo.GetIsSavePassword()); + xDialog->SetSavePasswordText( + ResId(rInfo.GetIsRememberPersistent() + ? RID_SAVE_PASSWORD + : RID_KEEP_PASSWORD, + *xManager.get())); + + xDialog->SetSavePassword(rInfo.GetIsRememberPassword()); } if ( bCanUseSysCreds ) @@ -126,7 +124,7 @@ executeLoginDialog( rInfo.SetUserName(xDialog->GetName()); rInfo.SetPassword(xDialog->GetPassword()); rInfo.SetAccount(xDialog->GetAccount()); - rInfo.SetSavePassword(xDialog->IsSavePassword()); + rInfo.SetIsRememberPassword(xDialog->IsSavePassword()); if ( bCanUseSysCreds ) rInfo.SetIsUseSystemCredentials( xDialog->IsUseSystemCredentials() ); @@ -139,6 +137,61 @@ executeLoginDialog( } } +void +getRememberModes( + uno::Sequence< ucb::RememberAuthentication > const & rRememberModes, + ucb::RememberAuthentication & rPreferredMode, + ucb::RememberAuthentication & rAlternateMode ) +{ + sal_Int32 nCount = rRememberModes.getLength(); + OSL_ENSURE( (nCount > 0) && (nCount < 4), + "ucb::RememberAuthentication sequence size mismatch!" ); + if ( nCount == 1 ) + { + rPreferredMode = rAlternateMode = rRememberModes[ 0 ]; + return; + } + else + { + //bool bHasRememberModeNo = false; + bool bHasRememberModeSession = false; + bool bHasRememberModePersistent = false; + + for (sal_Int32 i = 0; i < nCount; ++i) + { + switch ( rRememberModes[i] ) + { + case ucb::RememberAuthentication_NO: + //bHasRememberModeNo = true; + break; + case ucb::RememberAuthentication_SESSION: + bHasRememberModeSession = true; + break; + case ucb::RememberAuthentication_PERSISTENT: + bHasRememberModePersistent = true; + break; + default: + OSL_TRACE( "Unsupported RememberAuthentication value" ); + break; + } + } + + if (bHasRememberModePersistent) + { + rPreferredMode = ucb::RememberAuthentication_PERSISTENT; + if (bHasRememberModeSession) + rAlternateMode = ucb::RememberAuthentication_SESSION; + else + rAlternateMode = ucb::RememberAuthentication_NO; + } + else + { + rPreferredMode = ucb::RememberAuthentication_SESSION; + rAlternateMode = ucb::RememberAuthentication_NO; + } + } +} + void handleAuthenticationRequest_( Window * pParent, @@ -161,7 +214,7 @@ handleAuthenticationRequest_( xSupplyAuthentication2.set(xSupplyAuthentication, uno::UNO_QUERY); ////////////////////////// - // First, try to obatin credentials from password container service. + // First, try to obtain credentials from password container service. uui::PasswordContainerHelper aPwContainerHelper(xServiceFactory); if (aPwContainerHelper.handleAuthenticationRequest(rRequest, xSupplyAuthentication, @@ -174,26 +227,20 @@ handleAuthenticationRequest_( ////////////////////////// // Second, try to obtain credentials from user via password dialog. - bool bRemember; - bool bRememberPersistent; + ucb::RememberAuthentication eDefaultRememberMode + = ucb::RememberAuthentication_SESSION; + ucb::RememberAuthentication ePreferredRememberMode + = eDefaultRememberMode; + ucb::RememberAuthentication eAlternateRememberMode + = ucb::RememberAuthentication_NO; + if (xSupplyAuthentication.is()) { - ucb::RememberAuthentication eDefault; - uno::Sequence< ucb::RememberAuthentication > - aModes(xSupplyAuthentication->getRememberPasswordModes(eDefault)); - bRemember = eDefault != ucb::RememberAuthentication_NO; - bRememberPersistent = false; - for (sal_Int32 i = 0; i < aModes.getLength(); ++i) - if (aModes[i] == ucb::RememberAuthentication_PERSISTENT) - { - bRememberPersistent = true; - break; - } - } - else - { - bRemember = false; - bRememberPersistent = false; + getRememberModes( + xSupplyAuthentication->getRememberPasswordModes( + eDefaultRememberMode), + ePreferredRememberMode, + eAlternateRememberMode); } sal_Bool bCanUseSystemCredentials; @@ -220,10 +267,16 @@ handleAuthenticationRequest_( if (rRequest.HasPassword) aInfo.SetPassword(rRequest.Password); aInfo.SetErrorText(rRequest.Diagnostic); - aInfo.SetPersistentPassword(bRememberPersistent); - aInfo.SetSavePassword(bRemember); + + aInfo.SetCanRememberPassword( + ePreferredRememberMode != eAlternateRememberMode); + aInfo.SetIsRememberPassword( + eDefaultRememberMode != ucb::RememberAuthentication_NO); + aInfo.SetIsRememberPersistent( + ePreferredRememberMode == ucb::RememberAuthentication_PERSISTENT); + aInfo.SetCanUseSystemCredentials(bCanUseSystemCredentials); - aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials ); + aInfo.SetIsUseSystemCredentials(bDefaultUseSystemCredentials); aInfo.SetModifyAccount(rRequest.HasAccount && xSupplyAuthentication.is() && xSupplyAuthentication->canSetAccount()); @@ -242,13 +295,24 @@ handleAuthenticationRequest_( xSupplyAuthentication->setUserName(aInfo.GetUserName()); if (xSupplyAuthentication->canSetPassword()) xSupplyAuthentication->setPassword(aInfo.GetPassword()); - xSupplyAuthentication-> - setRememberPassword( - aInfo.GetIsSavePassword() ? - bRememberPersistent ? - ucb::RememberAuthentication_PERSISTENT : - ucb::RememberAuthentication_SESSION : - ucb::RememberAuthentication_NO); + + if (ePreferredRememberMode != eAlternateRememberMode) + { + // user had te choice. + if (aInfo.GetIsRememberPassword()) + xSupplyAuthentication->setRememberPassword( + ePreferredRememberMode); + else + xSupplyAuthentication->setRememberPassword( + eAlternateRememberMode); + } + else + { + // user had no choice. + xSupplyAuthentication->setRememberPassword( + ePreferredRememberMode); + } + if (rRequest.HasRealm) { if (xSupplyAuthentication->canSetRealm()) @@ -267,22 +331,31 @@ handleAuthenticationRequest_( ////////////////////////// // Third, store credentials in password container. - if ( aInfo.GetIsUseSystemCredentials() ) + if (aInfo.GetIsUseSystemCredentials()) { - if (aInfo.GetIsSavePassword()) + if (aInfo.GetIsRememberPassword() || + (eAlternateRememberMode == ucb::RememberAuthentication_SESSION)) { - aPwContainerHelper.addRecord( - rURL.getLength() ? rURL : rRequest.ServerName, - rtl::OUString(), // empty u/p -> sys creds - uno::Sequence< rtl::OUString >(), - xIH, - bRememberPersistent); + if (!aPwContainerHelper.addRecord( + rURL.getLength() ? rURL : rRequest.ServerName, + rtl::OUString(), // empty u/p -> sys creds + uno::Sequence< rtl::OUString >(), + xIH, + !aInfo.GetIsRememberPassword() + ? false /* SESSION */ + : ePreferredRememberMode + == ucb::RememberAuthentication_PERSISTENT)) + { + xSupplyAuthentication->setRememberPassword( + ucb::RememberAuthentication_NO); + } } } // Empty user name can not be valid: else if (aInfo.GetUserName().Len() != 0) { - if (aInfo.GetIsSavePassword()) + if (aInfo.GetIsRememberPassword() || + (eAlternateRememberMode == ucb::RememberAuthentication_SESSION)) { uno::Sequence< rtl::OUString > aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2); @@ -290,12 +363,19 @@ handleAuthenticationRequest_( if (aInfo.GetAccount().Len() != 0) aPassList[1] = aInfo.GetAccount(); - aPwContainerHelper.addRecord( - rURL.getLength() ? rURL : rRequest.ServerName, - aInfo.GetUserName(), - aPassList, - xIH, - bRememberPersistent); + if (!aPwContainerHelper.addRecord( + rURL.getLength() ? rURL : rRequest.ServerName, + aInfo.GetUserName(), + aPassList, + xIH, + !aInfo.GetIsRememberPassword() + ? false /* SESSION */ + : ePreferredRememberMode + == ucb::RememberAuthentication_PERSISTENT)) + { + xSupplyAuthentication->setRememberPassword( + ucb::RememberAuthentication_NO); + } } } break; diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx index 14cce88e0534..d713fbafa053 100644 --- a/uui/source/loginerr.hxx +++ b/uui/source/loginerr.hxx @@ -32,12 +32,13 @@ //========================================================================= -#define LOGINERROR_FLAG_SET_SAVE_PASSWORD 1 -#define LOGINERROR_FLAG_MODIFY_ACCOUNT 2 -#define LOGINERROR_FLAG_MODIFY_USER_NAME 4 -#define LOGINERROR_FLAG_PERSISTENT_PASSWORD 8 -#define LOGINERROR_FLAG_CAN_USE_SYSCREDS 16 -#define LOGINERROR_FLAG_IS_USE_SYSCREDS 32 +#define LOGINERROR_FLAG_MODIFY_ACCOUNT 1 +#define LOGINERROR_FLAG_MODIFY_USER_NAME 2 +#define LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD 4 +#define LOGINERROR_FLAG_IS_REMEMBER_PASSWORD 8 +#define LOGINERROR_FLAG_CAN_USE_SYSCREDS 16 +#define LOGINERROR_FLAG_IS_USE_SYSCREDS 32 +#define LOGINERROR_FLAG_REMEMBER_PERSISTENT 64 class LoginErrorInfo { @@ -56,8 +57,7 @@ public: LoginErrorInfo() : _nFlags( LOGINERROR_FLAG_MODIFY_USER_NAME ), _nRet( ERRCODE_BUTTON_CANCEL ) - { - } + {} const String& GetTitle() const { return _aTitle; } const String& GetServer() const { return _aServer; } @@ -66,10 +66,14 @@ public: const String& GetPassword() const { return _aPassword; } const String& GetPath() const { return _aPath; } const String& GetErrorText() const { return _aErrorText; } - BOOL GetIsPersistentPassword() const - { return ( _nFlags & LOGINERROR_FLAG_PERSISTENT_PASSWORD ); } - BOOL GetIsSavePassword() const - { return ( _nFlags & LOGINERROR_FLAG_SET_SAVE_PASSWORD ); } + + BOOL GetCanRememberPassword() const + { return ( _nFlags & LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD ); } + BOOL GetIsRememberPersistent() const + { return ( _nFlags & LOGINERROR_FLAG_REMEMBER_PERSISTENT ); } + BOOL GetIsRememberPassword() const + { return ( _nFlags & LOGINERROR_FLAG_IS_REMEMBER_PASSWORD ); } + BOOL GetCanUseSystemCredentials() const { return ( _nFlags & LOGINERROR_FLAG_CAN_USE_SYSCREDS ); } BOOL GetIsUseSystemCredentials() const @@ -94,8 +98,11 @@ public: { _aErrorText = aErrorText; } void SetFlags( BYTE nFlags ) { _nFlags = nFlags; } - inline void SetSavePassword( BOOL bSet ); - inline void SetPersistentPassword( BOOL bSet ); + + inline void SetCanRememberPassword( BOOL bSet ); + inline void SetIsRememberPassword( BOOL bSet ); + inline void SetIsRememberPersistent( BOOL bSet ); + inline void SetCanUseSystemCredentials( BOOL bSet ); inline void SetIsUseSystemCredentials( BOOL bSet ); inline void SetModifyAccount( BOOL bSet ); @@ -104,20 +111,28 @@ public: { _nRet = nRet; } }; -inline void LoginErrorInfo::SetSavePassword( BOOL bSet ) +inline void LoginErrorInfo::SetCanRememberPassword( BOOL bSet ) +{ + if ( bSet ) + _nFlags |= LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD; + else + _nFlags &= ~LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD; +} + +inline void LoginErrorInfo::SetIsRememberPassword( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_SET_SAVE_PASSWORD; + _nFlags |= LOGINERROR_FLAG_IS_REMEMBER_PASSWORD; else - _nFlags &= ~LOGINERROR_FLAG_SET_SAVE_PASSWORD; + _nFlags &= ~LOGINERROR_FLAG_IS_REMEMBER_PASSWORD; } -inline void LoginErrorInfo::SetPersistentPassword( BOOL bSet ) +inline void LoginErrorInfo::SetIsRememberPersistent( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_PERSISTENT_PASSWORD; + _nFlags |= LOGINERROR_FLAG_REMEMBER_PERSISTENT; else - _nFlags &= ~LOGINERROR_FLAG_PERSISTENT_PASSWORD; + _nFlags &= ~LOGINERROR_FLAG_REMEMBER_PERSISTENT; } inline void LoginErrorInfo::SetCanUseSystemCredentials( BOOL bSet ) diff --git a/uui/source/passwordcontainer.cxx b/uui/source/passwordcontainer.cxx index 26d22b320d8a..0a056289c29d 100644 --- a/uui/source/passwordcontainer.cxx +++ b/uui/source/passwordcontainer.cxx @@ -30,6 +30,7 @@ #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/task/NoMasterException.hpp" #include "com/sun/star/task/XInteractionHandler.hpp" +#include "com/sun/star/task/XMasterPasswordHandling.hpp" #include "com/sun/star/task/XPasswordContainer.hpp" #include "com/sun/star/task/XUrlContainer.hpp" #include "com/sun/star/ucb/AuthenticationRequest.hpp" @@ -271,10 +272,20 @@ bool PasswordContainerHelper::addRecord( return false; if ( bPersist ) + { + uno::Reference< task::XMasterPasswordHandling > xMPH( + m_xPasswordContainer, uno::UNO_QUERY_THROW ); + + // If persistent storing of passwords is not yet + // allowed, enable it. + if ( !xMPH->isPersistentStoringAllowed() ) + xMPH->allowPersistentStoring( sal_True ); + m_xPasswordContainer->addPersistent( rURL, rUsername, rPasswords, xIH ); + } else m_xPasswordContainer->add( rURL, rUsername, @@ -429,7 +440,7 @@ PasswordContainerInteractionHandler::handle( // @@@ FIXME: this not able to // handle master pw request! // master pw request is never - // solvabe without UI! + // solvable without UI! this ) ) { // successfully handled -- cgit From 54499ed54bd760755e4d172417f0cc849fc47d1e Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 19 Mar 2010 11:13:29 +0100 Subject: cws tl79: #i110254# new 'Security' tab page --- sfx2/inc/sfx2/securitypage.hxx | 57 ++++++ sfx2/inc/sfx2/sfx.hrc | 1 + sfx2/source/dialog/dinfdlg.cxx | 4 +- sfx2/source/dialog/dinfdlg.src | 11 +- sfx2/source/dialog/makefile.mk | 6 +- sfx2/source/dialog/securitypage.cxx | 379 ++++++++++++++++++++++++++++++++++++ sfx2/source/dialog/securitypage.hrc | 52 +++++ sfx2/source/dialog/securitypage.src | 156 +++++++++++++++ sfx2/source/inc/helpid.hrc | 1 + svx/inc/svx/svxids.hrc | 1 + 10 files changed, 661 insertions(+), 7 deletions(-) create mode 100755 sfx2/inc/sfx2/securitypage.hxx mode change 100644 => 100755 sfx2/inc/sfx2/sfx.hrc mode change 100644 => 100755 sfx2/source/dialog/dinfdlg.cxx mode change 100644 => 100755 sfx2/source/dialog/dinfdlg.src mode change 100644 => 100755 sfx2/source/dialog/makefile.mk create mode 100755 sfx2/source/dialog/securitypage.cxx create mode 100755 sfx2/source/dialog/securitypage.hrc create mode 100755 sfx2/source/dialog/securitypage.src mode change 100644 => 100755 sfx2/source/inc/helpid.hrc mode change 100644 => 100755 svx/inc/svx/svxids.hrc diff --git a/sfx2/inc/sfx2/securitypage.hxx b/sfx2/inc/sfx2/securitypage.hxx new file mode 100755 index 000000000000..616f11d3b6d1 --- /dev/null +++ b/sfx2/inc/sfx2/securitypage.hxx @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SECURITYPAGE_HXX_ +#define _SECURITYPAGE_HXX_ + +#include "sfx2/tabdlg.hxx " + +#include + + +////////////////////////////////////////////////////////////////////// + +struct SfxSecurityPage_Impl; + +class SfxSecurityPage : public SfxTabPage +{ + std::auto_ptr< SfxSecurityPage_Impl > m_pImpl; + +protected: + SfxSecurityPage( Window* pParent, const SfxItemSet& ); + virtual ~SfxSecurityPage(); + + virtual BOOL FillItemSet( SfxItemSet& ); + virtual void Reset( const SfxItemSet& ); + +public: + static SfxTabPage* Create( Window* pParent, const SfxItemSet& ); +}; + +////////////////////////////////////////////////////////////////////// + +#endif // #ifndef _SECURITYPAGE_HXX_ + diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc old mode 100644 new mode 100755 index 83f20874c324..5e64bdf4ca7b --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -228,6 +228,7 @@ #define TP_DOCINFOUSER (RID_SFX_START+5) #define TP_DOCINFORELOAD (RID_SFX_START+13) #define TP_CUSTOMPROPERTIES (RID_SFX_START+14) +#define TP_DOCINFOSECURITY (RID_SFX_START+215) #define DLG_DOCINFO_EDT (RID_SFX_START+6) #define TP_MANAGE_STYLES (RID_SFX_START+7) #define DLG_STYLE_DESIGNER (RID_SFX_START+8) diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx old mode 100644 new mode 100755 index 0f778a94f091..e592eae82b08 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -58,7 +58,8 @@ #include #include -#include +#include "sfx2/dinfdlg.hxx" +#include "sfx2/securitypage.hxx" #include "sfxresid.hxx" #include "dinfedt.hxx" #include @@ -1554,6 +1555,7 @@ SfxDocumentInfoDialog::SfxDocumentInfoDialog( Window* pParent, AddTabPage(TP_DOCINFODOC, SfxDocumentPage::Create, 0); AddTabPage(TP_CUSTOMPROPERTIES, SfxCustomPropertiesPage::Create, 0); AddTabPage(TP_DOCINFORELOAD, SfxInternetPage::Create, 0); + AddTabPage(TP_DOCINFOSECURITY, SfxSecurityPage::Create, 0); } // ----------------------------------------------------------------------- diff --git a/sfx2/source/dialog/dinfdlg.src b/sfx2/source/dialog/dinfdlg.src old mode 100644 new mode 100755 index eaa691fe3eff..f32bc768e846 --- a/sfx2/source/dialog/dinfdlg.src +++ b/sfx2/source/dialog/dinfdlg.src @@ -27,11 +27,11 @@ // include --------------------------------------------------------------- -#include +#include "sfx2/sfx.hrc" #include "helpid.hrc" #include "sfxlocal.hrc" #include "dinfdlg.hrc" -#include +#include "dialog.hrc" // TP_DOCINFODESC -------------------------------------------------------- String STR_SFX_NEWOFFICEDOC @@ -685,8 +685,6 @@ QueryBox SFX_QB_WRONG_TYPE Message [ en-US ] = "The value entered does not match the specified type.\nThe value will be stored as text." ; }; - // SID_DOCINFO ----------------------------------------------------------- - TabDialog SID_DOCINFO { OutputSize = TRUE ; @@ -718,6 +716,11 @@ TabDialog SID_DOCINFO Identifier = TP_DOCINFORELOAD ; Text [ en-US ] = "Internet" ; }; + PageItem + { + Identifier = TP_DOCINFOSECURITY ; + Text [ en-US ] = "Security" ; + }; }; }; }; diff --git a/sfx2/source/dialog/makefile.mk b/sfx2/source/dialog/makefile.mk old mode 100644 new mode 100755 index 87ef0f1a7af1..b344170fd39c --- a/sfx2/source/dialog/makefile.mk +++ b/sfx2/source/dialog/makefile.mk @@ -68,7 +68,8 @@ SLOFILES =\ $(SLO)$/tabdlg.obj \ $(SLO)$/tplcitem.obj \ $(SLO)$/tplpitem.obj \ - $(SLO)$/versdlg.obj + $(SLO)$/versdlg.obj \ + $(SLO)$/securitypage.obj SRS1NAME=$(TARGET) SRC1FILES =\ @@ -85,7 +86,8 @@ SRC1FILES =\ templdlg.src \ versdlg.src \ printopt.src \ - srchdlg.src + srchdlg.src \ + securitypage.src .IF "$(BUILD_VER_STRING)"!="" .IF "$(GUI)"=="UNX" diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx new file mode 100755 index 000000000000..affebc8615cb --- /dev/null +++ b/sfx2/source/dialog/securitypage.cxx @@ -0,0 +1,379 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sfx2.hxx" + +#include "sfx2/securitypage.hxx" +#include "sfx2/sfx.hrc" +#include "securitypage.hrc" +#include "sfxresid.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +////////////////////////////////////////////////////////////////////// + +namespace +{ + enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; + + enum RedlineFunc { RF_ON, RF_PROTECT }; + + const SfxBoolItem* ExecuteRecordChangesFunc( RedliningMode _eMode, RedlineFunc _eFunc, BOOL _bVal, Window* _pParent = NULL ) + { + const SfxBoolItem* pRet = NULL; + + if (_eMode != RL_NONE) + { + USHORT nSlot; + if (_eMode == RL_WRITER) + nSlot = _eFunc == RF_ON ? FN_REDLINE_ON : FN_REDLINE_PROTECT; + else + nSlot = _eFunc == RF_ON ? FID_CHG_RECORD : SID_CHG_PROTECT; + + // execute + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + bool bNeedItem = _eMode == RL_WRITER || _eFunc != RF_ON; + SfxBoolItem* pItem = bNeedItem ? new SfxBoolItem( nSlot, _bVal ) : NULL; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + if (_pParent) + { + XWindowItem aParentItem( SID_ATTR_XWINDOW, _pParent ); + pRet = static_cast< const SfxBoolItem* >( + pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, &aParentItem, pItem, 0L ) ); + } + else + pRet = static_cast< const SfxBoolItem* >( + pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, pItem, 0L ) ); + delete pItem; + } + } + + return pRet; + } + + bool QueryState( USHORT _nSlot, bool& _rValue ) + { + bool bRet = false; + + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + const SfxPoolItem* pItem; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + bRet = SFX_ITEM_AVAILABLE <= pDisp->QueryState( _nSlot, pItem ); + if (bRet) + _rValue = ( static_cast< const SfxBoolItem* >( pItem ) )->GetValue(); + } + + return bRet; + } + + bool QueryRecordChangesProtectionState( RedliningMode _eMode, bool& _rValue ) + { + bool bRet = false; + + if (_eMode != RL_NONE) + { + USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_PROTECT : SID_CHG_PROTECT; + bRet = QueryState( nSlot, _rValue ); + } + + return bRet; + } + + bool QueryRecordChangesState( RedliningMode _eMode, bool& _rValue ) + { + bool bRet = false; + + if (_eMode != RL_NONE) + { + USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_ON : FID_CHG_RECORD; + bRet = QueryState( nSlot, _rValue ); + } + + return bRet; + } +} + + +////////////////////////////////////////////////////////////////////// + + +struct SfxSecurityPage_Impl +{ + SfxSecurityPage & m_rDialog; + + FixedLine m_aPasswordToOpenFL; + FixedText m_aPasswordToOpenFT; + Edit m_aPasswordToOpenED; + FixedText m_aConfirmPasswordToOpenFT; + Edit m_aConfirmPasswordToOpenED; + FixedText m_aPasswordInfoFT; + + FixedLine m_aPasswordToModifyFL; + FixedText m_aPasswordToModifyFT; + Edit m_aPasswordToModifyED; + FixedText m_aConfirmPasswordToModifyFT; + Edit m_aConfirmPasswordToModifyED; + + FixedLine m_aOptionsFL; + CheckBox m_aOpenReadonlyCB; + CheckBox m_aRemoveInfoOnSavingCB; + CheckBox m_aRecordChangesCB; // for record changes + PushButton m_aChangeProtectionPB; // for record changes + String m_aProtectSTR; // for record changes + String m_aUnProtectSTR; // for record changes + RedliningMode m_eRedlingMode; // for record changes + + DECL_LINK( RecordChangesCBHdl, void* ); + DECL_LINK( ChangeProtectionPBHdl, void* ); + + SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet &rItemSet ); + ~SfxSecurityPage_Impl(); + + void CheckRecordChangesState( void ); + + BOOL FillItemSet_Impl( SfxItemSet & ); + void Reset_Impl( const SfxItemSet & ); +}; + + +SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet & ) : + m_rDialog (rDlg), + m_aPasswordToOpenFL (&rDlg, SfxResId( PASSWORD_TO_OPEN_FL ) ), + m_aPasswordToOpenFT (&rDlg, SfxResId( PASSWORD_TO_OPEN_FT ) ), + m_aPasswordToOpenED (&rDlg, SfxResId( PASSWORD_TO_OPEN_ED ) ), + m_aConfirmPasswordToOpenFT (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_OPEN_FT ) ), + m_aConfirmPasswordToOpenED (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_OPEN_ED ) ), + m_aPasswordInfoFT (&rDlg, SfxResId( PASSWORD_INFO_FT ) ), + m_aPasswordToModifyFL (&rDlg, SfxResId( PASSWORD_TO_MODIFY_FL ) ), + m_aPasswordToModifyFT (&rDlg, SfxResId( PASSWORD_TO_MODIFY_FT ) ), + m_aPasswordToModifyED (&rDlg, SfxResId( PASSWORD_TO_MODIFY_ED ) ), + m_aConfirmPasswordToModifyFT (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_FT ) ), + m_aConfirmPasswordToModifyED (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_ED ) ), + m_aOptionsFL (&rDlg, SfxResId( OPTIONS_FL ) ), + m_aOpenReadonlyCB (&rDlg, SfxResId( OPEN_READONLY_CB ) ), + m_aRemoveInfoOnSavingCB (&rDlg, SfxResId( REMOVE_INFO_ON_SAVING_CB ) ), + m_aRecordChangesCB (&rDlg, SfxResId( RECORD_CHANGES_CB ) ), + m_aChangeProtectionPB (&rDlg, SfxResId( CHANGE_PROTECTION_PB ) ), + m_aProtectSTR ( SfxResId( STR_PROTECT ) ), + m_aUnProtectSTR ( SfxResId( STR_UNPROTECT ) ), + m_eRedlingMode ( RL_NONE ) +{ + m_aChangeProtectionPB.SetText( m_aProtectSTR ); + // adjust button width if necessary + long nBtnTextWidth = 0; + long nTemp = m_aChangeProtectionPB.GetCtrlTextWidth( m_aChangeProtectionPB.GetText() ); + if (nTemp > nBtnTextWidth) + nBtnTextWidth = nTemp; + + m_aRecordChangesCB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, RecordChangesCBHdl ) ); + m_aChangeProtectionPB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, ChangeProtectionPBHdl ) ); +} + + +SfxSecurityPage_Impl::~SfxSecurityPage_Impl() +{ +} + + +void SfxSecurityPage_Impl::CheckRecordChangesState( void ) +{ + bool bVal; + if (QueryRecordChangesState( m_eRedlingMode, bVal )) + { + m_aRecordChangesCB.Enable(); + m_aRecordChangesCB.Check( bVal ); + } + else + m_aRecordChangesCB.Disable(); // because now we don't know the state! + + m_aChangeProtectionPB.Enable( QueryRecordChangesProtectionState( m_eRedlingMode, bVal ) ); +} + + +BOOL SfxSecurityPage_Impl::FillItemSet_Impl( SfxItemSet & ) +{ + BOOL bModified = FALSE; + + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + if (pCurDocShell) + { + if (pCurDocShell->HasSecurityOptOpenReadOnly()) + pCurDocShell->SetSecurityOptOpenReadOnly( m_aOpenReadonlyCB.IsChecked() ); + } + + return bModified; +} + + +void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) +{ + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + + String sNewText = m_aProtectSTR; + if (!pCurDocShell) + { + // no doc -> hide document settings + m_aOpenReadonlyCB.Disable(); + m_aRecordChangesCB.Disable(); + m_aChangeProtectionPB.Disable(); + } + else + { + bool bIsHTMLDoc = false; + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + const SfxPoolItem* pItem; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + if (SFX_ITEM_AVAILABLE <= pDisp->QueryState( SID_HTML_MODE, pItem )) + { + USHORT nMode = static_cast< const SfxUInt16Item* >( pItem )->GetValue(); + bIsHTMLDoc = ( ( nMode & HTMLMODE_ON ) != 0 ); + } + } + + sal_Bool bIsReadonly = pCurDocShell->IsReadOnly(); + if (pCurDocShell->HasSecurityOptOpenReadOnly() && !bIsHTMLDoc) + { + m_aOpenReadonlyCB.Check( pCurDocShell->IsSecurityOptOpenReadOnly() ); + m_aOpenReadonlyCB.Enable( !bIsReadonly ); + } + else + m_aOpenReadonlyCB.Disable(); + + bool bVal; + if (QueryRecordChangesState( RL_WRITER, bVal ) && !bIsHTMLDoc) + m_eRedlingMode = RL_WRITER; + else if (QueryRecordChangesState( RL_CALC, bVal )) + m_eRedlingMode = RL_CALC; + else + m_eRedlingMode = RL_NONE; + + if (m_eRedlingMode != RL_NONE) + { + m_aRecordChangesCB.Check( bVal ); + m_aRecordChangesCB.Enable( !bVal && !bIsReadonly ); + m_aChangeProtectionPB.Enable( + QueryRecordChangesProtectionState( m_eRedlingMode, bVal ) && !bIsReadonly ); + // set the right text + if (bVal) + sNewText = m_aUnProtectSTR; + } + } + + m_aChangeProtectionPB.SetText( sNewText ); +} + + +IMPL_LINK( SfxSecurityPage_Impl, RecordChangesCBHdl, void*, EMPTYARG ) +{ + ExecuteRecordChangesFunc( m_eRedlingMode, RF_ON, m_aRecordChangesCB.IsChecked(), &m_rDialog ); + CheckRecordChangesState(); + return 0; +} + + +IMPL_LINK( SfxSecurityPage_Impl, ChangeProtectionPBHdl, void*, EMPTYARG ) +{ + bool bProt; + QueryRecordChangesProtectionState( m_eRedlingMode, bProt ); + ExecuteRecordChangesFunc( m_eRedlingMode, RF_PROTECT, !bProt, &m_rDialog ); + CheckRecordChangesState(); + + if (QueryRecordChangesProtectionState( m_eRedlingMode, bProt )) + { + // RecordChangesCB is enabled if protection is off + m_aRecordChangesCB.Enable( !bProt ); + // toggle text of button "Protect" <-> "Unprotect" + String sNewText = bProt ? m_aUnProtectSTR : m_aProtectSTR; + m_aChangeProtectionPB.SetText( sNewText ); + } + return 0; +} + + +////////////////////////////////////////////////////////////////////// + + +SfxTabPage* SfxSecurityPage::Create( Window * pParent, const SfxItemSet & rItemSet ) +{ + return new SfxSecurityPage( pParent, rItemSet ); +} + + +SfxSecurityPage::SfxSecurityPage( Window* pParent, const SfxItemSet& rItemSet ) : + SfxTabPage( pParent, SfxResId( TP_DOCINFOSECURITY ), rItemSet ) +{ + m_pImpl = std::auto_ptr< SfxSecurityPage_Impl >(new SfxSecurityPage_Impl( *this, rItemSet )); + + FreeResource(); +} + + +SfxSecurityPage::~SfxSecurityPage() +{ +} + + +BOOL SfxSecurityPage::FillItemSet( SfxItemSet & rItemSet ) +{ + bool bModified = false; + DBG_ASSERT( m_pImpl.get(), "implementation pointer is 0. Still in c-tor?" ); + if (m_pImpl.get() != 0) + bModified = m_pImpl->FillItemSet_Impl( rItemSet ); + return bModified; +} + + +void SfxSecurityPage::Reset( const SfxItemSet & rItemSet ) +{ + DBG_ASSERT( m_pImpl.get(), "implementation pointer is 0. Still in c-tor?" ); + if (m_pImpl.get() != 0) + m_pImpl->Reset_Impl( rItemSet ); +} + + +////////////////////////////////////////////////////////////////////// + diff --git a/sfx2/source/dialog/securitypage.hrc b/sfx2/source/dialog/securitypage.hrc new file mode 100755 index 000000000000..820dab538b9f --- /dev/null +++ b/sfx2/source/dialog/securitypage.hrc @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SECURITYPAGE_HRC_ +#define _SECURITYPAGE_HRC_ + + +#define PASSWORD_TO_OPEN_FL 1 +#define PASSWORD_TO_OPEN_FT 2 +#define PASSWORD_TO_OPEN_ED 3 +#define CONFIRM_PASSWORD_TO_OPEN_FT 4 +#define CONFIRM_PASSWORD_TO_OPEN_ED 5 +#define PASSWORD_INFO_FT 6 +#define PASSWORD_TO_MODIFY_FL 7 +#define PASSWORD_TO_MODIFY_FT 8 +#define PASSWORD_TO_MODIFY_ED 9 +#define CONFIRM_PASSWORD_TO_MODIFY_FT 10 +#define CONFIRM_PASSWORD_TO_MODIFY_ED 11 +#define OPTIONS_FL 12 +#define OPEN_READONLY_CB 13 +#define REMOVE_INFO_ON_SAVING_CB 14 +#define RECORD_CHANGES_CB 15 +#define CHANGE_PROTECTION_PB 16 + +#define STR_PROTECT 101 +#define STR_UNPROTECT 102 + +#endif + diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src new file mode 100755 index 000000000000..32f5fac704a4 --- /dev/null +++ b/sfx2/source/dialog/securitypage.src @@ -0,0 +1,156 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "sfx2/sfx.hrc" +#include "securitypage.hrc" +#include "helpid.hrc" +#include "dialog.hrc" +#include "sfxlocal.hrc" + +#include + + +TabPage TP_DOCINFOSECURITY +{ + HelpId = HID_DOCINFOSECURITY ; + Hide = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + + FixedLine PASSWORD_TO_OPEN_FL + { + Pos = MAP_APPFONT( 6, 6 ); + Size = MAP_APPFONT( 248, RSC_CD_FIXEDLINE_HEIGHT ); + Text [ en-US ] = "File encryption password"; + }; + FixedText PASSWORD_TO_OPEN_FT + { + Pos = MAP_APPFONT( 12, 20 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "~Enter password to open"; + }; + Edit PASSWORD_TO_OPEN_ED + { + Pos = MAP_APPFONT( 100, 18 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedText CONFIRM_PASSWORD_TO_OPEN_FT + { + Pos = MAP_APPFONT( 12, 34 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "~Reenter password to open"; + }; + Edit CONFIRM_PASSWORD_TO_OPEN_ED + { + Pos = MAP_APPFONT( 100, 32 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedText PASSWORD_INFO_FT + { + Pos = MAP_APPFONT( 12, 48 ); + Size = MAP_APPFONT( 236, 3 * RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "Note: If you lose or forget the password, it cannot be recovered."\ + "It is advisable to keep passwords in a safe place."\ + "Passwords are case-sensitive."; + WordBreak = TRUE; + }; + FixedLine PASSWORD_TO_MODIFY_FL + { + Pos = MAP_APPFONT( 6, 78 ); + Size = MAP_APPFONT( 248, RSC_CD_FIXEDLINE_HEIGHT ); + Text [ en-US ] = "File sharing password"; + }; + FixedText PASSWORD_TO_MODIFY_FT + { + Pos = MAP_APPFONT( 12, 92 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "Enter password to modify"; + }; + Edit PASSWORD_TO_MODIFY_ED + { + Pos = MAP_APPFONT( 100, 90 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedText CONFIRM_PASSWORD_TO_MODIFY_FT + { + Pos = MAP_APPFONT( 12, 106 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "Reenter password to modify"; + }; + Edit CONFIRM_PASSWORD_TO_MODIFY_ED + { + Pos = MAP_APPFONT( 100, 104 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedLine OPTIONS_FL + { + Pos = MAP_APPFONT( 6, 120 ); + Size = MAP_APPFONT( 248, RSC_CD_FIXEDLINE_HEIGHT ); + Text [ en-US ] = "File sharing options"; + }; + CheckBox OPEN_READONLY_CB + { + Pos = MAP_APPFONT( 12, 133 ); + Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); + Text [ en-US ] = "~Open file read-only"; + }; + CheckBox REMOVE_INFO_ON_SAVING_CB + { + Pos = MAP_APPFONT( 12, 147 ); + Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); + Text [ en-US ] = "Remove personal ~information on saving"; + }; + CheckBox RECORD_CHANGES_CB + { + Pos = MAP_APPFONT( 12, 162 ); + Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); + Text [ en-US ] = "Record ~changes"; + }; + PushButton CHANGE_PROTECTION_PB + { + Pos = MAP_APPFONT( 194, 160 ); + Size = MAP_APPFONT( 60, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + String STR_PROTECT + { + Text [ en-US ] = "~Protect..."; + }; + String STR_UNPROTECT + { + Text [ en-US ] = "~Unprotect..."; + }; + +}; + + diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc old mode 100644 new mode 100755 index 29ad461d18da..f09ac7e94ecc --- a/sfx2/source/inc/helpid.hrc +++ b/sfx2/source/inc/helpid.hrc @@ -46,6 +46,7 @@ #define HID_DOCINFODESC (HID_SFX_START + 8) #define HID_DOCINFODOC (HID_SFX_START + 9) #define HID_DOCINFOUSER (HID_SFX_START + 10) +#define HID_DOCINFOSECURITY (HID_SFX_START + 11) #define HID_BOOKMARKPROPS (HID_SFX_START + 14) #define HID_BOOKGROUPPROPS (HID_SFX_START + 15) #define HID_BOOKFILEPROPS (HID_SFX_START + 16) diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc old mode 100644 new mode 100755 index b53b5f6dac26..ee31d4ee3964 --- a/svx/inc/svx/svxids.hrc +++ b/svx/inc/svx/svxids.hrc @@ -182,6 +182,7 @@ #define RID_OFA_TP_INTERNATIONAL_IMPR (RID_OFA_START + 254) // 4 impress */ +#define SID_ATTR_XWINDOW (RID_OFA_START + 250) #define SID_ATTR_PARENTWINDOW (RID_OFA_START + 255) // -------------------------------------------------------------------------- -- cgit From dc3c40a13388625726db26c953910d347cf4a9fc Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 4 May 2010 12:37:01 +0200 Subject: jl152 bundled extensions, import of changeset 263438:8b253e76e957 from native0jl --- desktop/inc/app.hxx | 1 + desktop/source/app/app.cxx | 3 + desktop/source/app/check_ext_deps.cxx | 235 +++- desktop/source/deployment/dp_services.cxx | 13 +- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 20 +- .../deployment/inc/dp_descriptioninfoset.hxx | 15 + desktop/source/deployment/inc/dp_misc.h | 21 + desktop/source/deployment/inc/dp_version.hxx | 7 - .../deployment/manager/dp_activepackages.cxx | 22 +- .../deployment/manager/dp_activepackages.hxx | 10 + .../deployment/manager/dp_extensionmanager.cxx | 1301 ++++++++++++++++++++ .../deployment/manager/dp_extensionmanager.hxx | 287 +++++ desktop/source/deployment/manager/dp_manager.cxx | 696 +++++++---- desktop/source/deployment/manager/dp_manager.h | 53 +- .../source/deployment/manager/dp_managerfac.cxx | 4 + .../source/deployment/manager/dp_tmprepocmdenv.cxx | 166 +++ .../source/deployment/manager/dp_tmprepocmdenv.hxx | 84 ++ desktop/source/deployment/manager/makefile.mk | 4 +- .../deployment/misc/dp_descriptioninfoset.cxx | 250 +++- desktop/source/deployment/misc/dp_misc.cxx | 31 + desktop/source/deployment/misc/dp_version.cxx | 6 - desktop/source/deployment/misc/makefile.mk | 3 +- .../registry/component/dp_compbackenddb.cxx | 142 +++ .../registry/component/dp_compbackenddb.hxx | 116 ++ .../deployment/registry/component/dp_component.cxx | 171 ++- .../deployment/registry/component/makefile.mk | 3 +- .../registry/configuration/dp_configuration.cxx | 13 +- desktop/source/deployment/registry/dp_backend.cxx | 81 +- .../source/deployment/registry/dp_backenddb.cxx | 332 +++++ desktop/source/deployment/registry/dp_registry.cxx | 27 +- .../registry/executable/dp_executable.cxx | 10 +- .../source/deployment/registry/help/dp_help.cxx | 13 +- .../source/deployment/registry/inc/dp_backend.h | 16 +- .../deployment/registry/inc/dp_backenddb.hxx | 121 ++ desktop/source/deployment/registry/makefile.mk | 3 +- .../deployment/registry/package/dp_description.cxx | 205 --- .../deployment/registry/package/dp_description.hxx | 125 -- .../registry/package/dp_extbackenddb.cxx | 177 +++ .../registry/package/dp_extbackenddb.hxx | 94 ++ .../deployment/registry/package/dp_package.cxx | 282 +++-- .../source/deployment/registry/package/makefile.mk | 2 +- .../deployment/registry/script/dp_script.cxx | 19 +- .../source/deployment/registry/sfwk/dp_sfwk.cxx | 18 +- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 80 +- desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx | 2 +- 45 files changed, 4396 insertions(+), 888 deletions(-) create mode 100644 desktop/source/deployment/manager/dp_extensionmanager.cxx create mode 100644 desktop/source/deployment/manager/dp_extensionmanager.hxx create mode 100644 desktop/source/deployment/manager/dp_tmprepocmdenv.cxx create mode 100644 desktop/source/deployment/manager/dp_tmprepocmdenv.hxx create mode 100644 desktop/source/deployment/registry/component/dp_compbackenddb.cxx create mode 100644 desktop/source/deployment/registry/component/dp_compbackenddb.hxx create mode 100644 desktop/source/deployment/registry/dp_backenddb.cxx create mode 100644 desktop/source/deployment/registry/inc/dp_backenddb.hxx delete mode 100644 desktop/source/deployment/registry/package/dp_description.cxx delete mode 100644 desktop/source/deployment/registry/package/dp_description.hxx create mode 100644 desktop/source/deployment/registry/package/dp_extbackenddb.cxx create mode 100644 desktop/source/deployment/registry/package/dp_extbackenddb.hxx diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 0ae632a6e968..4f5a3b176be3 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -132,6 +132,7 @@ class Desktop : public Application static sal_Bool LicenseNeedsAcceptance(); static sal_Bool IsFirstStartWizardNeeded(); static sal_Bool CheckExtensionDependencies(); + static void SynchronizeExtensionRepositories(); private: // Bootstrap methods diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index efba60ca75b9..b82915871566 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1395,6 +1395,9 @@ void Desktop::Main() bool bAbort = CheckExtensionDependencies(); if ( bAbort ) return; + //Check if bundled or shared extensions were added /removed + //and process those extensions + SynchronizeExtensionRepositories(); // First Start Wizard allowed ? if ( ! pCmdLineArgs->IsNoFirstStartWizard()) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 8b73e0c2c525..17dc20e1a129 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -27,21 +27,27 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" +#include #include #include +#include +#include "cppuhelper/compbase3.hxx" + #include #include #include #include - +#include #include #include #include "com/sun/star/deployment/XPackage.hpp" #include "com/sun/star/deployment/XPackageManager.hpp" #include "com/sun/star/deployment/thePackageManagerFactory.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include #include +#include #include #include @@ -53,9 +59,91 @@ using namespace com::sun::star; #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) +namespace +{ +//For use with XExtensionManager.synchronize +class SilentCommandEnv + : public ::cppu::WeakImplHelper3< ucb::XCommandEnvironment, + task::XInteractionHandler, + ucb::XProgressHandler > +{ +public: + virtual ~SilentCommandEnv(){}; + SilentCommandEnv(){}; + + // XCommandEnvironment + virtual uno::Reference SAL_CALL + getInteractionHandler() throw (uno::RuntimeException); + virtual uno::Reference + SAL_CALL getProgressHandler() throw (uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( + uno::Reference const & xRequest ) + throw (uno::RuntimeException); + + // XProgressHandler + virtual void SAL_CALL push( uno::Any const & Status ) + throw (uno::RuntimeException); + virtual void SAL_CALL update( uno::Any const & Status ) + throw (uno::RuntimeException); + virtual void SAL_CALL pop() throw (uno::RuntimeException); +}; +Reference SilentCommandEnv::getInteractionHandler() +throw (uno::RuntimeException) +{ + return this; +} + +Reference SilentCommandEnv::getProgressHandler() +throw (uno::RuntimeException) +{ + return this; +} + +// XInteractionHandler +void SilentCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + + // We approve everything here + uno::Sequence< Reference< task::XInteractionContinuation > > conts( + xRequest->getContinuations() ); + Reference< task::XInteractionContinuation > const * pConts = + conts.getConstArray(); + sal_Int32 len = conts.getLength(); + for ( sal_Int32 pos = 0; pos < len; ++pos ) + { + + Reference< task::XInteractionApprove > xInteractionApprove( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionApprove.is()) { + xInteractionApprove->select(); + } + } +} + +// XProgressHandler +void SilentCommandEnv::push( uno::Any const & /*Status*/ ) +throw (uno::RuntimeException) +{ +} + + +void SilentCommandEnv::update( uno::Any const & /*Status */) +throw (uno::RuntimeException) +{ +} + +void SilentCommandEnv::pop() throw (uno::RuntimeException) +{ +} + +} // end namespace static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); - //------------------------------------------------------------------------------ static sal_Int16 impl_showExtensionDialog( uno::Reference< uno::XComponentContext > &xContext ) { @@ -254,3 +342,146 @@ sal_Bool Desktop::CheckExtensionDependencies() return bAbort; } +//Returns true if the Folder was more recently modified then +//the lastsynchronized file. That is the repository needs to +//be synchronized. +static bool compareExtensionFolderWithLastSynchronizedFile( + OUString const & folderURL, OUString const & fileURL) +{ + bool bNeedsSync = false; + ::osl::DirectoryItem itemExtFolder; + ::osl::File::RC err1 = + ::osl::DirectoryItem::get(folderURL, itemExtFolder); + //If it does not exist, then there is nothing to be done + if (err1 == ::osl::File::E_NOENT) + { + return false; + } + else if (err1 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access extension folder"); + return true; //sync just in case + } + + //If last synchronized does not exist, then OOo is started for the first time + ::osl::DirectoryItem itemFile; + ::osl::File::RC err2 = ::osl::DirectoryItem::get(fileURL, itemFile); + if (err2 == ::osl::File::E_NOENT) + { + return true; + + } + else if (err2 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access file lastsynchronized"); + return true; //sync just in case + } + + //compare the modification time of the extension folder and the last + //modified file + ::osl::FileStatus statFolder(FileStatusMask_ModifyTime); + ::osl::FileStatus statFile(FileStatusMask_ModifyTime); + if (itemExtFolder.getFileStatus(statFolder) == ::osl::File::E_None) + { + if (itemFile.getFileStatus(statFile) == ::osl::File::E_None) + { + TimeValue timeFolder = statFolder.getModifyTime(); + TimeValue timeFile = statFile.getModifyTime(); + + if (timeFile.Seconds < timeFolder.Seconds) + bNeedsSync = true; + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + return bNeedsSync; +} + +static bool needToSyncRepostitory(OUString const & name) +{ + OUString folder; + OUString file; + if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")))) + { + folder = OUString( + RTL_CONSTASCII_USTRINGPARAM("$BUNDLED_EXTENSIONS")); + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); + } + else if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("shared")))) + { + folder = OUString( + RTL_CONSTASCII_USTRINGPARAM( + "$UNO_SHARED_PACKAGES_CACHE/uno_packages")); + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$SHARED_EXTENSIONS_USER/lastsynchronized")); + } + else + { + OSL_ASSERT(0); + return true; + } + ::rtl::Bootstrap::expandMacros(folder); + ::rtl::Bootstrap::expandMacros(file); + return compareExtensionFolderWithLastSynchronizedFile( + folder, file); +} + +void Desktop::SynchronizeExtensionRepositories() +{ + RTL_LOGFILE_CONTEXT(aLog,"desktop (jl97489) ::Desktop::SynchronizeExtensionRepositories"); + OUString sDisable; + ::rtl::Bootstrap::get( + OUString(RTL_CONSTASCII_USTRINGPARAM("DISABLE_SYNC_EXTENSIONS")), + sDisable, + OUString(RTL_CONSTASCII_USTRINGPARAM(""))); + if (sDisable.getLength() > 0) + return; + Reference xExtensionManager; + //synchronize shared before bundled otherewise there are + //more revoke and registration calls. + OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); + if (needToSyncRepostitory(sShared)) + { + xExtensionManager = + deployment::ExtensionManager::get( + comphelper_getProcessComponentContext()); + if (xExtensionManager.is()) + { + Reference cmdEnv( + new SilentCommandEnv()); + xExtensionManager->synchronize( + sShared, Reference(), cmdEnv); + } + + } + + OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); + if (needToSyncRepostitory( sBundled)) + { + if (!xExtensionManager.is()) + { + xExtensionManager = + deployment::ExtensionManager::get( + comphelper_getProcessComponentContext()); + } + if (xExtensionManager.is()) + { + Reference cmdEnv( + new SilentCommandEnv()); + xExtensionManager->synchronize( + sBundled, Reference(), cmdEnv); + + } + } +} diff --git a/desktop/source/deployment/dp_services.cxx b/desktop/source/deployment/dp_services.cxx index c83a62bfd17e..05b9a2a1971a 100644 --- a/desktop/source/deployment/dp_services.cxx +++ b/desktop/source/deployment/dp_services.cxx @@ -28,7 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" -#define COMPHELPER_SERVICEDECL_COMPONENT_HELPER_MAX_ARGS 11 +#define COMPHELPER_SERVICEDECL_COMPONENT_HELPER_MAX_ARGS 12 #include "comphelper/servicedecl.hxx" using namespace com::sun::star; @@ -69,6 +69,8 @@ namespace factory { extern sdecl::ServiceDecl const serviceDecl; bool singleton_entries( uno::Reference const& ); } +extern sdecl::ServiceDecl const serviceDecl; +bool singleton_entries( uno::Reference const& ); } namespace dp_log { @@ -109,9 +111,11 @@ sal_Bool SAL_CALL component_writeInfo( dp_manager::factory::serviceDecl, dp_log::serviceDecl, dp_migration::serviceDecl, - dp_info::serviceDecl ) && + dp_info::serviceDecl, + dp_manager::serviceDecl) && dp_manager::factory::singleton_entries( pRegistryKey ) && - dp_info::singleton_entries( pRegistryKey ); + dp_info::singleton_entries( pRegistryKey ) && + dp_manager::singleton_entries( pRegistryKey); } void * SAL_CALL component_getFactory( @@ -130,7 +134,8 @@ void * SAL_CALL component_getFactory( dp_manager::factory::serviceDecl, dp_log::serviceDecl, dp_migration::serviceDecl, - dp_info::serviceDecl ); + dp_info::serviceDecl, + dp_manager::serviceDecl); } } // extern "C" diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 58a5ab1c19ea..89a5ae1e22c8 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -110,12 +110,15 @@ using ::rtl::OUString; namespace { -OUString getVersion( const uno::Reference< deployment::XPackage > &rPackage ) +OUString getVersion( OUString const & sVersion ) { - OUString sVersion( rPackage->getVersion()); return ( sVersion.getLength() == 0 ) ? OUString( RTL_CONSTASCII_USTRINGPARAM( "0" ) ) : sVersion; } +OUString getVersion( const uno::Reference< deployment::XPackage > &rPackage ) +{ + return getVersion( rPackage->getVersion()); +} } @@ -468,7 +471,8 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & else if (request >>= verExc) { sal_uInt32 id; - switch (dp_misc::comparePackageVersions( verExc.New, verExc.Deployed )) + switch (dp_misc::compareVersions( + verExc.NewVersion, verExc.Deployed->getVersion() )) { case dp_misc::LESS: id = RID_WARNINGBOX_VERSION_LESS; @@ -480,8 +484,8 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & id = RID_WARNINGBOX_VERSION_GREATER; break; } - OSL_ASSERT( verExc.New.is() && verExc.Deployed.is() ); - bool bEqualNames = verExc.New->getDisplayName().equals( + OSL_ASSERT( verExc.Deployed.is() ); + bool bEqualNames = verExc.NewDisplayName.equals( verExc.Deployed->getDisplayName()); { vos::OGuard guard(Application::GetSolarMutex()); @@ -506,9 +510,9 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & { s = String(ResId(RID_STR_WARNINGBOX_VERSION_GREATER_DIFFERENT_NAMES, *DeploymentGuiResMgr::get())); } - s.SearchAndReplaceAllAscii( "$NAME", verExc.New->getDisplayName()); + s.SearchAndReplaceAllAscii( "$NAME", verExc.NewDisplayName); s.SearchAndReplaceAllAscii( "$OLDNAME", verExc.Deployed->getDisplayName()); - s.SearchAndReplaceAllAscii( "$NEW", getVersion(verExc.New) ); + s.SearchAndReplaceAllAscii( "$NEW", getVersion(verExc.NewVersion) ); s.SearchAndReplaceAllAscii( "$DEPLOYED", getVersion(verExc.Deployed) ); box.SetMessText(s); approve = box.Execute() == RET_OK; @@ -527,7 +531,7 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & { vos::OGuard guard(Application::GetSolarMutex()); - approve = m_pDialogHelper->installExtensionWarn( instExc.New->getDisplayName() ); + approve = m_pDialogHelper->installExtensionWarn( instExc.displayName ); } else approve = false; diff --git a/desktop/source/deployment/inc/dp_descriptioninfoset.hxx b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx index 38a1870782ed..3d2d56cad00a 100644 --- a/desktop/source/deployment/inc/dp_descriptioninfoset.hxx +++ b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx @@ -62,6 +62,7 @@ struct DESKTOP_DEPLOYMENTMISC_DLLPUBLIC SimpleLicenseAttributes bool suppressIfRequired; }; + /** Access to the content of an XML description element. @@ -226,6 +227,8 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::xml::xpath::XXPathAPI > getXpath() const; + bool hasDescription() const; + private: SAL_DLLPRIVATE ::boost::optional< ::rtl::OUString > getOptionalValue( ::rtl::OUString const & expression) const; @@ -289,6 +292,18 @@ private: ::com::sun::star::xml::xpath::XXPathAPI > m_xpath; }; +inline bool DescriptionInfoset::hasDescription() const +{ + return m_element.is(); +} + +/** creates a DescriptionInfoset object. + + The argument sExtensionFolderURL is a file URL to extension folder containing + the description.xml. + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +DescriptionInfoset getDescriptionInfoset(::rtl::OUString const & sExtensionFolderURL); } #endif diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index a717e7797c8a..ee5867a655d3 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -74,9 +74,25 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString expandUnoRcUrl( ::rtl::OUString const & url ); //============================================================================== + +/** appends a relative path to a url. + + The relative path must already be correctly encoded for use in an URL. + If the URL starts with vnd.sun.star.expand then the relative path will + be again encoded for use in an "expand" URL. + */ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString makeURL( ::rtl::OUString const & baseURL, ::rtl::OUString const & relPath ); + +/** appends a relative path to a url. + + This is the same as makeURL, but the relative Path must me a segment + of an system path. + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString makeURLAppendSysPathSegment( + ::rtl::OUString const & baseURL, ::rtl::OUString const & relPath ); + //============================================================================== DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString generateRandomPipeId(); @@ -151,6 +167,11 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void TRACE(::rtl::OUString const & sText); DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void TRACE(::rtl::OString const & sText); + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +bool hasExtensionRepositoryChanged(::rtl::OUString const & repository); + + } #endif diff --git a/desktop/source/deployment/inc/dp_version.hxx b/desktop/source/deployment/inc/dp_version.hxx index 9808ebaab388..c459333f97a9 100644 --- a/desktop/source/deployment/inc/dp_version.hxx +++ b/desktop/source/deployment/inc/dp_version.hxx @@ -43,13 +43,6 @@ enum Order { LESS, EQUAL, GREATER }; DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order compareVersions( ::rtl::OUString const & version1, ::rtl::OUString const & version2); - -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order comparePackageVersions( - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > - const & package1, - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > - const & package2); - } #endif diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx index 04dc22b77a77..bf9071682b2e 100644 --- a/desktop/source/deployment/manager/dp_activepackages.cxx +++ b/desktop/source/deployment/manager/dp_activepackages.cxx @@ -96,9 +96,23 @@ static char const legacyPrefix[] = "org.openoffice.legacy."; OSL_ASSERT(i2 >= 0); d.fileName = ::rtl::OUString( value.getStr() + i1 + 1, i2 - i1 - 1, RTL_TEXTENCODING_UTF8); - d.mediaType = ::rtl::OUString( - value.getStr() + i2 + 1, value.getLength() - i2 - 1, - RTL_TEXTENCODING_UTF8); + sal_Int32 i3 = value.indexOf(separator, i2 + 1); + + if (i3 < 0) + { + //Before ActivePackages::Data::version was added + d.mediaType = ::rtl::OUString( + value.getStr() + i2 + 1, value.getLength() - i2 - 1, + RTL_TEXTENCODING_UTF8); + } + else + { + d.mediaType = ::rtl::OUString( + value.getStr() + i2 + 1, i3 - i2 -1, RTL_TEXTENCODING_UTF8); + d.version = ::rtl::OUString( + value.getStr() + i3 + 1, value.getLength() - i3 - 1, + RTL_TEXTENCODING_UTF8); + } return d; } @@ -172,6 +186,8 @@ void ActivePackages::put(::rtl::OUString const & id, Data const & data) { b.append(::rtl::OUStringToOString(data.fileName, RTL_TEXTENCODING_UTF8)); b.append(separator); b.append(::rtl::OUStringToOString(data.mediaType, RTL_TEXTENCODING_UTF8)); + b.append(separator); + b.append(::rtl::OUStringToOString(data.version, RTL_TEXTENCODING_UTF8)); m_map.put(newKey(id), b.makeStringAndClear()); } diff --git a/desktop/source/deployment/manager/dp_activepackages.hxx b/desktop/source/deployment/manager/dp_activepackages.hxx index 1c58f76be245..36060d26bd02 100644 --- a/desktop/source/deployment/manager/dp_activepackages.hxx +++ b/desktop/source/deployment/manager/dp_activepackages.hxx @@ -42,9 +42,19 @@ namespace dp_manager { class ActivePackages { public: struct Data { + /* name of the temporary file (shared, user extension) or the name of + the folder of the bundled extension. + It does not contain the trailing '_' of the folder. + UTF-8 encoded + */ ::rtl::OUString temporaryName; + /* The file name (shared, user) or the folder name (bundled) + If the key is the file name, then file name is not encoded. + If the key is the idendifier then the file name is UTF-8 encoded. + */ ::rtl::OUString fileName; ::rtl::OUString mediaType; + ::rtl::OUString version; }; typedef ::std::vector< ::std::pair< ::rtl::OUString, Data > > Entries; diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx new file mode 100644 index 000000000000..469245bef340 --- /dev/null +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -0,0 +1,1301 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include + +#include "comphelper/servicedecl.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "rtl/bootstrap.hxx" +#include "com/sun/star/deployment/ExtensionManager.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/thePackageManagerFactory.hpp" +#include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/XPackageManagerFactory.hpp" +#include "com/sun/star/deployment/XPackage.hpp" +#include "com/sun/star/deployment/InstallException.hpp" +#include "com/sun/star/deployment/VersionException.hpp" +#include "com/sun/star/deployment/LicenseException.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/registry/XRegistryKey.hpp" +#include "com/sun/star/beans/Optional.hpp" +#include "com/sun/star/task/XInteractionApprove.hpp" +#include "com/sun/star/beans/Ambiguous.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/io/XInputStream.hpp" +#include "comphelper/sequence.hxx" +#include "xmlscript/xml_helper.hxx" +#include "osl/diagnose.h" +#include "dp_interact.h" +#include "dp_resource.h" +#include "dp_ucb.h" +#include "dp_identifier.hxx" + +#include "dp_extensionmanager.hxx" +#include "dp_tmprepocmdenv.hxx" +#include +#include +#include + +namespace deploy = com::sun::star::deployment; +namespace lang = com::sun::star::lang; +namespace registry = com::sun::star::registry; +namespace task = com::sun::star::task; +namespace ucb = com::sun::star::ucb; +namespace uno = com::sun::star::uno; +namespace beans = com::sun::star::beans; +namespace css = com::sun::star; + +//#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) + +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +namespace { + +struct CompIdentifiers +{ + bool operator() (::std::vector > const & a, + ::std::vector > const & b) + { + + if (getName(a).compareTo(getName(b)) < 0) + return true; + return false; + } + + OUString getName(::std::vector > const & a); +}; + +OUString CompIdentifiers::getName(::std::vector > const & a) +{ + OSL_ASSERT(a.size() == 3); + //get the first non-null reference + Reference extension; + ::std::vector >::const_iterator it = a.begin(); + for (; it != a.end(); it++) + { + if (it->is()) + { + extension = *it; + break; + } + } + OSL_ASSERT(extension.is()); + return extension->getDisplayName(); +} +} //end namespace + +namespace dp_manager { + + + +//------------------------------------------------------------------------------ + +//ToDo: bundled extension +ExtensionManager::ExtensionManager( Reference< uno::XComponentContext > const& xContext) : + m_xContext( xContext ) +{ + Reference xPackageManagerFactory( + deploy::thePackageManagerFactory::get(m_xContext)); + m_userRepository = xPackageManagerFactory->getPackageManager(OUSTR("user")); + m_sharedRepository = xPackageManagerFactory->getPackageManager(OUSTR("shared")); + m_bundledRepository = xPackageManagerFactory->getPackageManager(OUSTR("bundled")); + m_tmpRepository = xPackageManagerFactory->getPackageManager(OUSTR("tmp")); + + m_repositoryNames.push_back(OUSTR("user")); + m_repositoryNames.push_back(OUSTR("shared")); + m_repositoryNames.push_back(OUSTR("bundled")); +} + +//------------------------------------------------------------------------------ + +ExtensionManager::~ExtensionManager() +{ +} + +Reference ExtensionManager::createAbortChannel() + throw (uno::RuntimeException) +{ + return new dp_misc::AbortChannel; +} + +/* + Enters the XPackage objects into a map. They must be all from the + same repository. The value type of the map is a vector, where each vector + represents an extension with a particular identifier. The first member + is represents the user extension, the second the shared extension and the + third the bundled extension. + */ +void ExtensionManager::addExtensionsToMap( + id2extensions & mapExt, + uno::Sequence > const & seqExt, + OUString const & repository) +{ + //Determine the index in the vector where these extensions are to be + //added. + ::std::list::const_iterator citNames = + m_repositoryNames.begin(); + int index = 0; + for (;citNames != m_repositoryNames.end(); citNames++, index++) + { + if (citNames->equals(repository)) + break; + } + + for (int i = 0; i < seqExt.getLength(); i++) + { + Reference const & xExtension = seqExt[i]; + OUString id = dp_misc::getIdentifier(xExtension); + id2extensions::iterator ivec = mapExt.find(id); + if (ivec == mapExt.end()) + { + ::std::vector > vec(3); + vec[index] = xExtension; + mapExt[id] = vec; + } + else + { + ivec->second[index] = xExtension; + } + } +} + +/* + returns a list containing extensions with the same identifier from + all repositories (user, shared, bundled) If one repository does not + have this extension, then the list contains an empty Referenc. The list + is ordered according to the priority of the repostories: + 1. user + 2. shared + 3. bundled + + The number of elements is always three, unless the number of repository + changes. + */ +::std::list > + ExtensionManager::getExtensionsWithSameId( + OUString const & identifier, OUString const & fileName) + +{ + ::std::list > extensionList; + try + { //will throw an exception if the extension does not exist + extensionList.push_back(m_userRepository->getDeployedPackage( + identifier, fileName, Reference())); + } catch(lang::IllegalArgumentException &) + { + extensionList.push_back(Reference()); + } + try + { + extensionList.push_back(m_sharedRepository->getDeployedPackage( + identifier, fileName, Reference())); + } catch (lang::IllegalArgumentException &) + { + extensionList.push_back(Reference()); + } + try + { + extensionList.push_back(m_bundledRepository->getDeployedPackage( + identifier, fileName, Reference())); + } catch (lang::IllegalArgumentException &) + { + extensionList.push_back(Reference()); + } + OSL_ASSERT(extensionList.size() == 3); + return extensionList; +} + + +/* + +*/ +Reference ExtensionManager::getExtensionAndStatus( + ::rtl::OUString const & identifier, + ::rtl::OUString const & fileName, + ::rtl::OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv, + bool & out_bWasRegistered) +{ + Reference theExtension; + ::std::list > listExtensions = + getExtensionsWithSameId(identifier, fileName); + OSL_ASSERT(listExtensions.size() == m_repositoryNames.size()); + Reference xActiveExtension; + ::std::list::const_iterator + inames = m_repositoryNames.begin(); + ::std::list >::const_iterator + iext = listExtensions.begin(); + for (; inames != m_repositoryNames.end(); inames++, iext++) + { + if (repository.equals(*inames)) + { + theExtension = *iext; + if (iext->is()) + { + beans::Optional > optRegistered = + (*iext)->isRegistered(xAbortChannel, xCmdEnv); + OSL_ENSURE(! optRegistered.Value.IsAmbiguous, + "Extension is not properly registered"); + //IsAmbiguous = true: only partly registered, but we assume + //that this is the active extension, and something went wrong when registering it + //previously. + if (optRegistered.IsPresent + && (optRegistered.Value.Value || optRegistered.Value.IsAmbiguous)) + out_bWasRegistered = true; + } + break; + } + } + return theExtension; +} + +/* + Determines if the user extension was disabled by the user. Currently a user + cannot disable extensions from other repositories. If an extension does not + contain any items which need to be registered then the extension cannot + actually be disabled (because it cannot be registered). In this case false is + returned. If there is no user extension then also false is returned. + + A user extension is regarded as disabled if there is an extension in a + repository with a lower priority that is registered. + */ +bool ExtensionManager::isUserExtensionDisabled( + OUString const & identifier, OUString const & fileName, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + +{ + bool bDisabled = false; + ::std::list > listExtensions = + getExtensionsWithSameId(identifier, fileName); + ::std::list >::const_iterator + iext = listExtensions.begin(); + bool bCheckOptional = false; + Reference xActive; + for (; iext != listExtensions.end(); iext++) + { + if (iext->is()) + { + if (!(*iext)->isRegistered(xAbortChannel, xCmdEnv).IsPresent) + { + // IsPresent must be the same for all extnesions + OSL_ASSERT(!bCheckOptional); + break; + } + else + { + bCheckOptional = true; + if ((*iext)->isRegistered(xAbortChannel, xCmdEnv).Value.Value) + { + xActive = *iext; + break; + } + } + } + Reference const & xUser = listExtensions.front(); + if (xUser.is() + && xActive.is() + && xUser != xActive) + bDisabled = true; + } + return bDisabled; +} +/* + This method determines the active extension (XPackage.registerPackage) with a + particular identifier. + + The parameter bUserDisabled determines if the user extension is disabled. + + When the user repository contains an extension with the given identifier and + it is not disabled by the user, then it is always registered. Otherwise an + extension is only registered when there is no registered extension in one of + the repositories with a higher priority. That is, if the extension is from + the shared repository and an active extension with the same identifer is in + the user repository, then the extension is not registered. Similarly a + bundled extension is not registered if there is an active extension with the + same identifier in the shared or user repository. +*/ +void ExtensionManager::activateExtension( + OUString const & identifier, OUString const & fileName, + bool bUserDisabled, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) +{ + ::std::list > listExtensions = + getExtensionsWithSameId(identifier, fileName); + OSL_ASSERT(listExtensions.size() == 3); + ::std::list >::const_iterator + iext = listExtensions.begin(); + //skip disabled user extension + if (listExtensions.front().is() && bUserDisabled) + iext++; + bool bActive = false; + for (; iext != listExtensions.end(); iext++) + { + if (iext->is()) + { + //get the registration value of the current iteration + beans::Optional > optReg = + (*iext)->isRegistered(xAbortChannel, xCmdEnv); + //If nothing can be registered then break + if (!optReg.IsPresent) + break; + + //If we have already determined an active extension then we must + //make sure to unregister all extensions with the same id in + //repositories with a lower priority + if (bActive) + { + (*iext)->revokePackage(xAbortChannel, xCmdEnv); + } + else + { + //This is the first extension in the ordered list, which becomes + //the active extension + bActive = true; + //Register if not already done. + //reregister if the value is ambiguous, which indicates that + //something went wrong during last registration. + (*iext)->registerPackage(xAbortChannel, xCmdEnv); + } + } + } +} + +Reference ExtensionManager::backupExtension( + OUString const & identifier, OUString const & fileName, + Reference const & xPackageManager, + Reference const & xCmdEnv ) +{ + Reference xBackup; + Reference tmpCmdEnv( + new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler())); + Reference xOldExtension; + xOldExtension = xPackageManager->getDeployedPackage( + identifier, fileName, tmpCmdEnv); + + if (xOldExtension.is()) + { + xBackup = m_tmpRepository->addPackage( + xOldExtension->getURL(), OUString(), + Reference(), tmpCmdEnv); + + OSL_ENSURE(xBackup.is(), "Failed to backup extension"); + } + return xBackup; +} + +uno::Sequence< Reference > +ExtensionManager::getSupportedPackageTypes(OUString const & repository) + throw (uno::RuntimeException) +{ + if (repository.equals(OUSTR("user"))) + return m_userRepository->getSupportedPackageTypes(); + else if (repository.equals(OUSTR("shared"))) + return m_sharedRepository->getSupportedPackageTypes(); + else + return uno::Sequence< Reference >(); +} + +// Only add to shared and user repository +Reference ExtensionManager::addExtension( + OUString const & url, OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + Reference xNewExtension; + //Determine the repository to use + Reference xPackageManager; + if (repository.equals(OUSTR("user"))) + xPackageManager = m_userRepository; + else if (repository.equals(OUSTR("shared"))) + xPackageManager = m_sharedRepository; + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + ::osl::MutexGuard guard(m_mutex); + Reference xTmpExtension = + getTempExtension(url, xAbortChannel, xCmdEnv); + const OUString sIdentifier = dp_misc::getIdentifier(xTmpExtension); + const OUString sFileName = xTmpExtension->getName(); + const OUString sDisplayName = xTmpExtension->getDisplayName(); + const OUString sVersion = xTmpExtension->getVersion(); + + Reference xOldExtension; + bool bUserDisabled = false; + Reference xExtensionBackup; + + uno::Any excOccurred1; + uno::Any excOccurred2; + + try + { + //If we add a user extension and there is already one which was + //disabled by a user, then the newly installed one is enabled. If we + //add to another repository then the user extension remains + //disabled. + if (! repository.equals(OUSTR("user"))) + bUserDisabled = isUserExtensionDisabled( + sIdentifier, sFileName, xAbortChannel, xCmdEnv); + + bool bWasRegistered = false; + xOldExtension = getExtensionAndStatus( + sIdentifier, sFileName, repository, xAbortChannel, + xCmdEnv, bWasRegistered); + bool bCanInstall = false; + try + { + if (xOldExtension.is()) + { + //throws a CommandFailedException if the user cancels + //the action. + checkUpdate(sVersion, sDisplayName,xOldExtension, xCmdEnv); + } + else + { + //throws a CommandFailedException if the user cancels + //the action. + checkInstall(sDisplayName, xCmdEnv); + } + + bCanInstall = xTmpExtension->checkPrerequisites( + xAbortChannel, xCmdEnv, xOldExtension.is(), repository); + } + catch (deploy::DeploymentException& ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (...) { + excOccurred1 = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during addExtension, url: ") + + url, static_cast(this), excOccurred1); + excOccurred1 <<= exc; + } + + if (bCanInstall) + { + if (xOldExtension.is()) + { + if (bWasRegistered) + xOldExtension->revokePackage(xAbortChannel, xCmdEnv); + //save the old user extension in case the user aborts + //store the extension in the tmp repository, this will overwrite + //xTmpPackage (same identifier). Do not let the user abort or + //interact + Reference tmpCmdEnv( + new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler())); + //importing the old extension in the tmp repository will remove + //the xTmpExtension + xTmpExtension = 0; + xExtensionBackup = m_tmpRepository->importExtension( + xOldExtension, Reference(), + tmpCmdEnv); + } + + xNewExtension = xPackageManager->addPackage( + url, OUString(), xAbortChannel, xCmdEnv); + activateExtension( + dp_misc::getIdentifier(xNewExtension), + xNewExtension->getName(), bUserDisabled, + xAbortChannel, xCmdEnv); + } + } + catch (deploy::DeploymentException& ) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (...) { + excOccurred2 = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during addExtension, url: ") + + url, static_cast(this), excOccurred2); + excOccurred2 <<= exc; + } + + if (excOccurred2.hasValue()) + { + //It does not matter what exception is thrown. We try to + //recover the original status. + //If the user aborted installation then a ucb::CommandAbortedException + //is thrown. + //Use a private AbortChannel so the user cannot interrupt. + try + { + Reference tmpCmdEnv( + new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler())); + if (xExtensionBackup.is()) + { + Reference xRestored = + xPackageManager->importExtension( + xExtensionBackup, Reference(), + tmpCmdEnv); + } + activateExtension( + sIdentifier, sFileName, bUserDisabled, + Reference(), tmpCmdEnv); + if (xTmpExtension.is() || xExtensionBackup.is()) + m_tmpRepository->removePackage( + sIdentifier, OUString(), xAbortChannel, xCmdEnv); + } + catch (...) + { + } + ::cppu::throwException(excOccurred2); + } + if (xTmpExtension.is() || xExtensionBackup.is()) + m_tmpRepository->removePackage( + sIdentifier,OUString(), xAbortChannel, xCmdEnv); + + if (excOccurred1.hasValue()) + ::cppu::throwException(excOccurred1); + + return xNewExtension; +} + +void ExtensionManager::removeExtension( + OUString const & identifier, OUString const & fileName, + OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + uno::Any excOccurred1; + Reference xExtensionBackup; + Reference xPackageManager; + bool bUserDisabled = false; + try + { +//Determine the repository to use + if (repository.equals(OUSTR("user"))) + xPackageManager = m_userRepository; + else if (repository.equals(OUSTR("shared"))) + xPackageManager = m_sharedRepository; + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + ::osl::MutexGuard guard(m_mutex); + //Backup the extension, in case the user cancels the action + + bUserDisabled = isUserExtensionDisabled( + identifier, fileName, xAbortChannel, xCmdEnv); + //Backup the extension, in case the user cancels the action + xExtensionBackup = backupExtension( + identifier, fileName, xPackageManager, xCmdEnv); + + //revoke the extension if it is active + Reference xOldExtension = + xPackageManager->getDeployedPackage( + identifier, fileName, xCmdEnv); + xOldExtension->revokePackage(xAbortChannel, xCmdEnv); + + xPackageManager->removePackage( + identifier, fileName, xAbortChannel, xCmdEnv); + activateExtension(identifier, fileName, bUserDisabled, + xAbortChannel, xCmdEnv); + } + catch (deploy::DeploymentException& ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (...) { + excOccurred1 = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during removeEtension"), + static_cast(this), excOccurred1); + excOccurred1 <<= exc; + } + + if (excOccurred1.hasValue()) + { + //User aborted installation, restore the previous situation. + //Use a private AbortChannel so the user cannot interrupt. + try + { + Reference tmpCmdEnv( + new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler())); + if (xExtensionBackup.is()) + { + Reference xRestored = + xPackageManager->importExtension( + xExtensionBackup, Reference(), + tmpCmdEnv); + activateExtension( + identifier, fileName, bUserDisabled, Reference(), + tmpCmdEnv); + + m_tmpRepository->removePackage( + dp_misc::getIdentifier(xExtensionBackup), + xExtensionBackup->getName(), xAbortChannel, xCmdEnv); + } + } + catch (...) + { + } + ::cppu::throwException(excOccurred1); + } + + if (xExtensionBackup.is()) + m_tmpRepository->removePackage( + dp_misc::getIdentifier(xExtensionBackup), + xExtensionBackup->getName(), xAbortChannel, xCmdEnv); +} + +// Only enable extensions from shared and user repository +void ExtensionManager::enableExtension( + Reference const & extension, + Reference const & xAbortChannel, + Reference const & xCmdEnv) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + try + { + if (!extension.is()) + return; + + OUString repository = extension->getRepositoryName(); + if (!repository.equals(OUSTR("user"))) + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + ::osl::MutexGuard guard(m_mutex); + + //if it is already registered or if it cannot be registered + //because it does not contain any files which need to be processed + //then there is nothing to do here + beans::Optional > reg = + extension->isRegistered(xAbortChannel, xCmdEnv); + if (!reg.IsPresent + || (!reg.Value.IsAmbiguous && reg.Value.Value)) + return; + } + catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), exc); + } + + uno::Any excOccurred; + try + { + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), + false, xAbortChannel, xCmdEnv); + } + catch (deploy::DeploymentException& ) { + excOccurred = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred = ::cppu::getCaughtException(); + } catch (...) { + excOccurred = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), excOccurred); + excOccurred <<= exc; + } + + if (excOccurred.hasValue()) + { + try + { + extension->revokePackage(Reference(), xCmdEnv); + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), + true, xAbortChannel, xCmdEnv); + } + catch (...) + { + } + ::cppu::throwException(excOccurred); + } +} + +void ExtensionManager::disableExtension( + Reference const & extension, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + uno::Any excOccurred; + try + { + if (!extension.is()) + return; + + ::osl::MutexGuard guard(m_mutex); + OUString repository = extension->getRepositoryName(); + if (!repository.equals(OUSTR("user"))) + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + //if it is already registered or if it cannot be registered + //because it does not contain any files which need to be processed + //then there is nothing to do here + beans::Optional > reg = + extension->isRegistered(xAbortChannel, xCmdEnv); + if (!reg.IsPresent + || (!reg.Value.IsAmbiguous && !reg.Value.Value)) + return; + + extension->revokePackage(xAbortChannel, xCmdEnv); + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), + true, xAbortChannel, xCmdEnv); + } + catch (deploy::DeploymentException& ) { + excOccurred = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred = ::cppu::getCaughtException(); + } catch (...) { + excOccurred = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during disableExtension"), + static_cast(this), excOccurred); + excOccurred <<= exc; + } + + if (excOccurred.hasValue()) + { + try + { + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), + false, xAbortChannel, xCmdEnv); + } + catch (...) + { + } + ::cppu::throwException(excOccurred); + } +} + +uno::Sequence< Reference > + ExtensionManager::getDeployedExtensions( + OUString const & repository, + Reference const &xAbort, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + if (repository.equals(OUSTR("user"))) + { + return m_userRepository->getDeployedPackages( + xAbort, xCmdEnv); + } + else if (repository.equals(OUSTR("shared"))) + { + return m_sharedRepository->getDeployedPackages( + xAbort, xCmdEnv); + } + else if (repository.equals(OUSTR("bundled"))) + { + return m_bundledRepository->getDeployedPackages( + xAbort, xCmdEnv); + } + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + +} + +Reference + ExtensionManager::getDeployedExtension( + OUString const & repository, + OUString const & identifier, + OUString const & filename, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + if (repository.equals(OUSTR("user"))) + { + return m_userRepository->getDeployedPackage( + identifier, filename, xCmdEnv); + } + else if (repository.equals(OUSTR("shared"))) + { + return m_sharedRepository->getDeployedPackage( + identifier, filename, xCmdEnv); + } + else if (repository.equals(OUSTR("bundled"))) + { + return m_bundledRepository->getDeployedPackage( + identifier, filename, xCmdEnv); + } + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); +} + +uno::Sequence< uno::Sequence > > + ExtensionManager::getAllExtensions( + Reference const & xAbort, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + uno::Sequence< uno::Sequence > > seqSeq; + try + { + id2extensions mapExt; + + uno::Sequence > userExt = + m_userRepository->getDeployedPackages(xAbort, xCmdEnv); + addExtensionsToMap(mapExt, userExt, OUSTR("user")); + uno::Sequence > sharedExt = + m_sharedRepository->getDeployedPackages(xAbort, xCmdEnv); + addExtensionsToMap(mapExt, sharedExt, OUSTR("shared")); + uno::Sequence > bundledExt = + m_bundledRepository->getDeployedPackages(xAbort, xCmdEnv); + addExtensionsToMap(mapExt, bundledExt, OUSTR("bundled")); + + //copy the values of the map to a vector for sorting + ::std::vector< ::std::vector > > + vecExtensions; + id2extensions::const_iterator mapIt = mapExt.begin(); + for (;mapIt != mapExt.end(); mapIt++) + vecExtensions.push_back(mapIt->second); + + //sort the element according to the identifier + ::std::sort(vecExtensions.begin(), vecExtensions.end(), CompIdentifiers()); + + ::std::vector< ::std::vector > >::const_iterator + citVecVec = vecExtensions.begin(); + sal_Int32 j = 0; + for (;citVecVec != vecExtensions.end(); citVecVec++, j++) + { + seqSeq[j] = comphelper::containerToSequence(*citVecVec); + } + } catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), exc); + } + + return seqSeq; +} + +void ExtensionManager::reinstallDeployedExtensions( + OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, ucb::CommandAbortedException, + lang::IllegalArgumentException, uno::RuntimeException) +{ + try + { + Reference xPackageManager; + if (repository.equals(OUSTR("user"))) + xPackageManager = m_userRepository; + else if (repository.equals(OUSTR("shared"))) + xPackageManager = m_sharedRepository; + else if (repository.equals(OUSTR("bundled"))) + xPackageManager = m_bundledRepository; + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + ::osl::MutexGuard guard(m_mutex); + xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv); + const uno::Sequence< Reference > extensions( + xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv)); + + for ( sal_Int32 pos = 0; pos < extensions.getLength(); ++pos ) + { + try + { + const OUString id = dp_misc::getIdentifier(extensions[ pos ]); + const OUString fileName = extensions[ pos ]->getName(); + OSL_ASSERT(id.getLength()); + activateExtension( + id, fileName, + isUserExtensionDisabled(id, fileName, xAbortChannel, xCmdEnv), + xAbortChannel, xCmdEnv ); + } + catch (lang::DisposedException &) + { + } + } + } catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), exc); + } +} + +void ExtensionManager::synchronize( + OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + try + { + Reference xPackageManager; + OUString file; + if (repository.equals(OUSTR("user"))) + { + xPackageManager = m_userRepository; + } + else if (repository.equals(OUSTR("shared"))) + { + xPackageManager = m_sharedRepository; + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$SHARED_EXTENSIONS_USER/lastsynchronized")); + } + else if (repository.equals(OUSTR("bundled"))) + { + xPackageManager = m_bundledRepository; + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); + } + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + ::osl::MutexGuard guard(m_mutex); + uno::Sequence > seqAddedExtensions; + uno::Sequence > seqRemovedExtensions; + xPackageManager->synchronize(seqAddedExtensions, seqRemovedExtensions, + xAbortChannel, xCmdEnv); + + //ToDo: optimize, only call activateExtension once per id. + //Determine which of the extensions was disabled by the user + //iterate of both sequences and add the ids of the user disabled + //to a map + for (sal_Int32 i = 0; i < seqRemovedExtensions.getLength(); i++) + { + try + { + Reference const & xExtension = seqRemovedExtensions[i]; + OSL_ASSERT(xExtension.is()); + const OUString id = dp_misc::getIdentifier(xExtension); + const OUString fileName = xExtension->getName(); + + bool bUserDisabled = isUserExtensionDisabled( + id, xExtension->getName(), xAbortChannel, xCmdEnv); + xExtension->revokePackage(xAbortChannel, xCmdEnv); + xPackageManager->removePackage( + id, fileName, xAbortChannel, xCmdEnv); + activateExtension( + id, fileName, bUserDisabled, xAbortChannel, xCmdEnv); + } + catch (...) + { + OSL_ENSURE(0, "Extensions Manager: synchronize"); + } + } + + for (sal_Int32 i = 0; i < seqAddedExtensions.getLength(); i++) + { + try + { + Reference const & xExtension = seqAddedExtensions[i]; + OSL_ASSERT(xExtension.is()); + const OUString id = dp_misc::getIdentifier(xExtension); + const OUString fileName = xExtension->getName(); + bool bUserDisabled = isUserExtensionDisabled( + id, fileName, xAbortChannel, xCmdEnv); + activateExtension( + id, fileName, bUserDisabled, xAbortChannel, xCmdEnv); + } + catch (...) + { + OSL_ENSURE(0, "Extensions Manager: synchronize"); + } + } + + //Write the lastmodified file + try { + ::rtl::Bootstrap::expandMacros(file); + ::ucbhelper::Content ucbStamp(file, xCmdEnv ); + dp_misc::erase_path( file, xCmdEnv ); + ::rtl::OString stamp("1" ); + Reference xData( + ::xmlscript::createInputStream( + ::rtl::ByteSequence( + reinterpret_cast(stamp.getStr()), + stamp.getLength() ) ) ); + ucbStamp.writeStream( xData, true /* replace existing */ ); + } + catch(...) + { + uno::Any exc(::cppu::getCaughtException()); + throw deploy::DeploymentException( + OUSTR("Failed to update") + file, + static_cast(this), exc); + + } + } catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), exc); + } +} + +// Notify the user when a new extension is to be installed. This is only the +// case when one uses the system integration to install an extension (double +// clicking on .oxt file etc.)). The function must only be called if there is no +// extension with the same identifier already deployed. Then the checkUpdate +// function will inform the user that the extension is about to be installed In +// case the user cancels the installation a CommandFailed exception is +// thrown. +void ExtensionManager::checkInstall( + OUString const & displayName, + Reference const & cmdEnv) +{ + uno::Any request( + deploy::InstallException( + OUSTR("Extension ") + displayName + + OUSTR(" is about to be installed."), + static_cast(this), displayName)); + bool approve = false, abort = false; + if (! dp_misc::interactContinuation( + request, task::XInteractionApprove::static_type(), + cmdEnv, &approve, &abort )) + { + OSL_ASSERT( !approve && !abort ); + throw deploy::DeploymentException( + dp_misc::getResourceString(RID_STR_ERROR_WHILE_ADDING) + displayName, + static_cast(this), request ); + } + if (abort || !approve) + throw ucb::CommandFailedException( + dp_misc::getResourceString(RID_STR_ERROR_WHILE_ADDING) + displayName, + static_cast(this), request ); +} + +/* The function will make the user interaction in case there is an extension +installed with the same id. This function may only be called if there is already +an extension. +*/ +void ExtensionManager::checkUpdate( + OUString const & newVersion, + OUString const & newDisplayName, + Reference const & oldExtension, + Reference const & xCmdEnv ) +{ + // package already deployed, interact --force: + uno::Any request( + (deploy::VersionException( + dp_misc::getResourceString( + RID_STR_PACKAGE_ALREADY_ADDED ) + newDisplayName, + static_cast(this), newVersion, newDisplayName, + oldExtension ) ) ); + bool replace = false, abort = false; + if (! dp_misc::interactContinuation( + request, task::XInteractionApprove::static_type(), + xCmdEnv, &replace, &abort )) { + OSL_ASSERT( !replace && !abort ); + throw deploy::DeploymentException( + dp_misc::getResourceString( + RID_STR_ERROR_WHILE_ADDING) + newDisplayName, + static_cast(this), request ); + } + if (abort || !replace) + throw ucb::CommandFailedException( + dp_misc::getResourceString( + RID_STR_PACKAGE_ALREADY_ADDED) + newDisplayName, + static_cast(this), request ); +} + +Reference ExtensionManager::getTempExtension( + OUString const & url, + Reference const & xAbortChannel, + Reference const & /*xCmdEnv*/) + +{ + Reference tmpCmdEnvA(new TmpRepositoryCommandEnv()); + Reference xTmpPackage = m_tmpRepository->addPackage( + url, OUString(), xAbortChannel, tmpCmdEnvA); + + if (!xTmpPackage.is()) + { + throw deploy::DeploymentException( + OUSTR("Extension Manager: Failed to create temporary XPackage for url: ") + url, + static_cast(this), uno::Any()); + + } + return xTmpPackage; +} +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ + +namespace sdecl = comphelper::service_decl; +sdecl::class_ servicePIP; +extern sdecl::ServiceDecl const serviceDecl( + servicePIP, + // a private one: + "com.sun.star.comp.deployment.ExtensionManager", + "com.sun.star.comp.deployment.ExtensionManager"); + +//------------------------------------------------------------------------------ +bool singleton_entries( + uno::Reference< registry::XRegistryKey > const & xRegistryKey ) +{ + try { + uno::Reference< registry::XRegistryKey > xKey( + xRegistryKey->createKey( + serviceDecl.getImplementationName() + + // xxx todo: use future generated function to get singleton name + OUSTR("/UNO/SINGLETONS/" + "com.sun.star.deployment.ExtensionManager") ) ); + xKey->setStringValue( serviceDecl.getSupportedServiceNames()[0] ); + return true; + } + catch (registry::InvalidRegistryException & exc) { + (void) exc; // avoid warnings + OSL_ENSURE( 0, ::rtl::OUStringToOString( + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + return false; + } +} + +} // namespace dp_manager + + diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx new file mode 100644 index 000000000000..386e2a7ceffd --- /dev/null +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -0,0 +1,287 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#if ! defined INCLUDED_DP_EXTENSIONMANAGER_H +#define INCLUDED_DP_EXTENSIONMANAGER_H + +#include "dp_manager.hrc" +#include "dp_misc.h" +#include "dp_interact.h" +#include "dp_activepackages.hxx" +#include "rtl/ref.hxx" +#include "cppuhelper/compbase1.hxx" +//#include "cppuhelper/implbase2.hxx" +#include "ucbhelper/content.hxx" +#include "com/sun/star/deployment/XPackageRegistry.hpp" +#include "com/sun/star/deployment/XPackageManager.hpp" +//#include +#include "osl/mutex.hxx" +#include + + +namespace css = ::com::sun::star; + +namespace dp_manager { + +typedef ::std::hash_map< + ::rtl::OUString, + ::std::vector >, + ::rtl::OUStringHash > id2extensions; + +class ExtensionManager : + public ::cppu::WeakImplHelper1< css::deployment::XExtensionManager > + +{ +private: + ::osl::Mutex m_mutex; + + public: + ExtensionManager( css::uno::Reference< css::uno::XComponentContext >const& xContext); + virtual ~ExtensionManager(); + + static css::uno::Sequence< ::rtl::OUString > getServiceNames(); + static ::rtl::OUString getImplName(); + +// // XInteractionHandler +// virtual void SAL_CALL handle( const uno::Reference< task::XInteractionRequest >& Request ) +// throw( uno::RuntimeException ); +// // XCommandEnvironment +// virtual uno::Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler() +// throw ( uno::RuntimeException ) { return static_cast(this); }; + +// virtual uno::Reference< css_ucb::XProgressHandler > SAL_CALL getProgressHandler() +// throw ( uno::RuntimeException ) { return uno::Reference< css_ucb::XProgressHandler >(); }; +public: + // XComponent + //virtual void SAL_CALL dispose() throw (css::uno::RuntimeException); + //virtual void SAL_CALL addEventListener( + // css::uno::Reference const & xListener ) + // throw (css::uno::RuntimeException); + //virtual void SAL_CALL removeEventListener( + // css::uno::Reference const & xListener ) + // throw (css::uno::RuntimeException); + // + //// XModifyBroadcaster + //virtual void SAL_CALL addModifyListener( + // css::uno::Reference const & xListener ) + // throw (css::uno::RuntimeException); + //virtual void SAL_CALL removeModifyListener( + // css::uno::Reference const & xListener ) + // throw (css::uno::RuntimeException); + + // XPackageManager +// virtual ::rtl::OUString SAL_CALL getContext() +// throw (css::uno::RuntimeException); + virtual css::uno::Sequence< + css::uno::Reference > SAL_CALL + getSupportedPackageTypes(::rtl::OUString const & repository) + throw (css::uno::RuntimeException); + + virtual css::uno::Reference SAL_CALL + createAbortChannel() throw (css::uno::RuntimeException); + + virtual css::uno::Reference SAL_CALL addExtension( + ::rtl::OUString const & url, ::rtl::OUString const & repository, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual void SAL_CALL removeExtension( + ::rtl::OUString const & identifier, + ::rtl::OUString const & filename, + ::rtl::OUString const & repository, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual void SAL_CALL enableExtension( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual void SAL_CALL disableExtension( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual css::uno::Sequence< css::uno::Reference > + SAL_CALL getDeployedExtensions( + ::rtl::OUString const & repository, + css::uno::Reference const &, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual css::uno::Reference< css::deployment::XPackage> + SAL_CALL getDeployedExtension( + ::rtl::OUString const & repository, + ::rtl::OUString const & identifier, + ::rtl::OUString const & filename, + css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) + throw ( + css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual css::uno::Sequence< css::uno::Sequence > > + SAL_CALL getAllExtensions( + css::uno::Reference const &, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + + virtual void SAL_CALL reinstallDeployedExtensions( + ::rtl::OUString const & repository, + css::uno::Reference< css::task::XAbortChannel> const & xAbortChannel, + css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) + throw ( + css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual void SAL_CALL synchronize( + ::rtl::OUString const & repository, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + +private: + + struct ExtensionInfos + { + ::rtl::OUString identifier; + ::rtl::OUString fileName; + ::rtl::OUString displayName; + ::rtl::OUString version; + }; + + css::uno::Reference< css::uno::XComponentContext> m_xContext; + + css::uno::Reference m_userRepository; + css::uno::Reference m_sharedRepository; + css::uno::Reference m_bundledRepository; + css::uno::Reference m_tmpRepository; + + /* contains the names of all repositories (except tmp) in order of there + priority. That is, the first element is "user" follod by "shared" and + then "bundled" + */ + ::std::list< ::rtl::OUString > m_repositoryNames; + + css::uno::Reference getExtensionAndStatus( + ::rtl::OUString const & identifier, + ::rtl::OUString const & fileName, + ::rtl::OUString const & repository, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv, + bool & out_bWasRegistered); + + bool isUserExtensionDisabled( + ::rtl::OUString const & identifier, + ::rtl::OUString const & fileName, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + + void activateExtension( + ::rtl::OUString const & identifier, + ::rtl::OUString const & fileName, + bool bUserDisabled, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + + + ::std::list > + getExtensionsWithSameId(::rtl::OUString const & identifier, + ::rtl::OUString const & fileName); + + css::uno::Reference backupExtension( + ::rtl::OUString const & identifier, ::rtl::OUString const & fileName, + css::uno::Reference const & xPackageManager, + css::uno::Reference const & xCmdEnv); + + void checkInstall( + ::rtl::OUString const & displayName, + css::uno::Reference const & cmdEnv); + + void checkUpdate( + ::rtl::OUString const & newVersion, + ::rtl::OUString const & newDisplayName, + css::uno::Reference const & oldExtension, + css::uno::Reference const & xCmdEnv); + + css::uno::Reference getTempExtension( + ::rtl::OUString const & url, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + + + void addExtensionsToMap( + id2extensions & mapExt, + css::uno::Sequence > const & seqExt, + ::rtl::OUString const & repository); +}; + +} + + + + +#endif + diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 3f13cb021aae..59e9f2049722 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -60,7 +60,12 @@ #include "com/sun/star/task/XInteractionApprove.hpp" #include "com/sun/star/ucb/UnsupportedCommandException.hpp" #include "boost/bind.hpp" +#include "tools/urlobj.hxx" + +#include "osl/file.hxx" #include +#include +#include "dp_descriptioninfoset.hxx" using namespace ::dp_misc; @@ -91,6 +96,58 @@ struct MatchTempDir } }; +struct MatchExtension +{ + const ActivePackages::Data m_data; + MatchExtension(ActivePackages::Data const & data ) : m_data(data) {} + bool operator () ( OUString const & temporaryName ) const; +}; + +bool MatchExtension::operator () (OUString const & temporaryName) const +{ + //case 1: The temporary file and thus the extension folder are already + //removed. + return m_data.temporaryName.equals(temporaryName); +} + +namespace { +OUString getExtensionFolder(OUString const & parentFolder, + Reference const & xCmdEnv) +{ + ::ucbhelper::Content tempFolder( + parentFolder, xCmdEnv ); + Reference xResultSet( + tempFolder.createCursor( + Sequence( &StrTitle::get(), 1 ), + ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); + + OUString title; + while (xResultSet->next()) + { + title = Reference( + xResultSet, UNO_QUERY_THROW )->getString(1 /* Title */ ) ; + break; + } + return title; +} +/* adds an unencoded segment to the URL. + + Throws an com.sun.star.uno.Exception if this failed. +*/ +OUString appendURLSegement(OUString const & baseURL, OUString const & segment) +{ + OUString url; + INetURLObject inet(baseURL); + if (inet.insertName( + segment, false, INetURLObject::LAST_SEGMENT, true, + INetURLObject::ENCODE_ALL)) + url = inet.GetMainURL(INetURLObject::NO_DECODE); + else + throw Exception( + OUSTR("ExtensionManager: failed to add segment to URL"), 0); + return url; +} +} //______________________________________________________________________________ void PackageManagerImpl::initActivationLayer( Reference const & xCmdEnv ) @@ -151,12 +208,23 @@ void PackageManagerImpl::initActivationLayer( // user|share: OSL_ASSERT( m_activePackages.getLength() > 0 ); m_activePackages_expanded = expandUnoRcUrl( m_activePackages ); - create_folder( 0, m_activePackages_expanded, xCmdEnv, !m_readOnly ); + m_registrationData_expanded = expandUnoRcUrl(m_registrationData); + create_folder( 0, m_activePackages_expanded, xCmdEnv, true); + + OUString dbName; + if (m_context.equals(OUSTR("user"))) + dbName = m_activePackages_expanded + OUSTR(".db"); + else + { + //Create the extension data base in the user installation + create_folder( 0, m_registrationData_expanded, xCmdEnv, true); + dbName = m_registrationData_expanded + OUSTR("/extensions.db"); + } + //The data base can always be written because it it always in the user installation m_activePackagesDB.reset( - new ActivePackages( - m_activePackages_expanded + OUSTR(".db"), m_readOnly ) ); + new ActivePackages( dbName, false ) ); - if (! m_readOnly) + if (! m_readOnly && ! m_context.equals(OUSTR("bundled"))) { // clean up activation layer, scan for zombie temp dirs: ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); @@ -169,11 +237,17 @@ void PackageManagerImpl::initActivationLayer( ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); // get all temp directories: ::std::vector tempEntries; - while (xResultSet->next()) { + while (xResultSet->next()) + { OUString title( Reference( xResultSet, UNO_QUERY_THROW )->getString( 1 /* Title */ ) ); + const char extensionRemoved[] = ".tmpremoved"; + if (title.endsWithAsciiL( + extensionRemoved, sizeof(extensionRemoved) - 1)) + continue; + tempEntries.push_back( ::rtl::Uri::encode( title, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, @@ -195,6 +269,9 @@ void PackageManagerImpl::initActivationLayer( false /* no throw: ignore errors */ ); erase_path( url, Reference(), false /* no throw: ignore errors */ ); + //delete the xxx.tmpremoved file + erase_path(url + OUSTR("removed"), + Reference(), false); } } } @@ -206,9 +283,9 @@ void PackageManagerImpl::initRegistryBackends() { if (m_registryCache.getLength() > 0) create_folder( 0, m_registryCache, - Reference(), !m_readOnly ); + Reference(), false); m_xRegistry.set( ::dp_registry::create( - m_context, m_registryCache, m_readOnly, + m_context, m_registryCache, false, m_xComponentContext ) ); } @@ -223,12 +300,14 @@ Reference PackageManagerImpl::create( OUString packages, logFile, stampURL; if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("user") )) { - that->m_activePackages = OUSTR("vnd.sun.star.expand:$UNO_" - "USER_PACKAGES_CACHE/uno_packages"); - that->m_registryCache = OUSTR("vnd.sun.star.expand:$UNO_" - "USER_PACKAGES_CACHE/registry"); - logFile = OUSTR("vnd.sun.star.expand:$UNO_" - "USER_PACKAGES_CACHE/log.txt"); + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/registry"); + logFile = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/log.txt"); //We use the extension .sys for the file because on Windows Vista a sys //(as well as exe and dll) file //will not be written in the VirtualStore. For example if the process has no @@ -240,25 +319,42 @@ Reference PackageManagerImpl::create( //using virtualization it appears that he/she can. Then a shared extension can //be installed but is only visible for the user (because the extension is in //the virtual store). - stampURL = OUSTR("vnd.sun.star.expand:$UNO_" - "USER_PACKAGES_CACHE/stamp.sys"); + stampURL = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/stamp.sys"); } else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) { - that->m_activePackages = OUSTR("vnd.sun.star.expand:$UNO_" - "SHARED_PACKAGES_CACHE/uno_packages"); - that->m_registryCache = OUSTR("vnd.sun.star.expand:$UNO_" - "SHARED_PACKAGES_CACHE/registry"); -// The current logging implementation does not work for shared, because it requires -// write access to the logfile. When two users run OOo at the same time on the same machine -// then the -// second will fail because it does not get write access. One cannot write into the -// user's home, because then people may complain that when installing shared extension -// stuff is written in their home. -// logFile = OUSTR("vnd.sun.star.expand:$UNO_" -// "SHARED_PACKAGES_CACHE/log.txt"); - //See description for stampURL for user packages. - stampURL = OUSTR("vnd.sun.star.expand:$UNO_" - "SHARED_PACKAGES_CACHE/stamp.sys"); + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/registry"); + logFile = OUSTR( + "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/log.txt"); + stampURL = OUSTR( + "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/stamp.sys"); + } + else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") )) { + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/registry"); + logFile = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/log.txt"); + //No stamp file. We assume that bundled is always readonly. It must not be + //modified from ExtensionManager but only by the installer + } + else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) { + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$TMP_EXTENSIONS/extensions"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$TMP_EXTENSIONS"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$TMP_EXTENSIONS/registry"); + stampURL = OUSTR( + "vnd.sun.star.expand:$TMP_EXTENSIONS/stamp.sys"); } else if (! context.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") )) { @@ -270,29 +366,15 @@ Reference PackageManagerImpl::create( Reference xCmdEnv; try { - bool renewal = false; - + //There is no stampURL for the bundled folder if (stampURL.getLength() > 0) { - // currently no automatic renewal possible, because quickstarter - // already hinders from deleting registry directory... - #define CURRENT_STAMP "1" -// renewal = true; -// { -// ::ucbhelper::Content ucbStamp; -// if (create_ucb_content( -// &ucbStamp, stampURL, xCmdEnv, false /* no throw */ )) -// { -// OUString line; -// renewal = !readLine( &line, OUSTR(CURRENT_STAMP), ucbStamp, -// RTL_TEXTENCODING_ASCII_US ); -// } -// } - try { + //The osl file API does not allow to find out if one can write + //into a folder. Therefore we try to write a file. Then we delete + //it, so that it does not hinder uninstallation of OOo // probe writing: - erase_path( stampURL, xCmdEnv ); ::ucbhelper::Content ucbStamp( stampURL, xCmdEnv ); ::rtl::OString stamp( RTL_CONSTASCII_STRINGPARAM(CURRENT_STAMP) ); @@ -302,8 +384,15 @@ Reference PackageManagerImpl::create( reinterpret_cast(stamp.getStr()), stamp.getLength() ) ) ); ucbStamp.writeStream( xData, true /* replace existing */ ); + that->m_readOnly = false; + erase_path( stampURL, xCmdEnv ); } catch (RuntimeException &) { + try { + erase_path( stampURL, xCmdEnv ); + } catch (...) + { + } throw; } catch (Exception &) { @@ -324,12 +413,6 @@ Reference PackageManagerImpl::create( xCmdEnv.set( new CmdEnvWrapperImpl( xCmdEnv, that->m_xLogFile ) ); } - OSL_ENSURE( !that->m_readOnly || !renewal, - "### ought to reinstall all packages, but cannot write!" ); - if (!that->m_readOnly && renewal) // try to reinstall - that->reinstallDeployedPackages( - Reference(), xCmdEnv ); - that->initRegistryBackends(); that->initActivationLayer( xCmdEnv ); @@ -484,7 +567,7 @@ OUString PackageManagerImpl::detectMediaType( try { Reference xPackage( m_xRegistry->bindPackage( - url, OUString(), ucbContent.getCommandEnvironment() ) ); + url, OUString(), false, ucbContent.getCommandEnvironment() ) ); const Reference xPackageType( xPackage->getPackageType() ); OSL_ASSERT( xPackageType.is() ); @@ -564,10 +647,18 @@ OUString PackageManagerImpl::insertToActivationLayer( title, NameClash::OVERWRITE )) throw RuntimeException( OUSTR("UCB transferContent() failed!"), 0 ); + // write to DB: + //bundled extensions should only be added by the synchronizeAddedExtensions + //functions. Moreover, there is no "temporary folder" for bundled extensions. + OSL_ASSERT(!m_context.equals(OUSTR("bundled"))); + DescriptionInfoset info = + dp_misc::getDescriptionInfoset( + appendURLSegement(destFolderContent.getURL(), title)); dbData->temporaryName = tempEntry; dbData->fileName = title; dbData->mediaType = mediaType; + dbData->version = info.getVersion(); return destFolder; } @@ -582,79 +673,35 @@ void PackageManagerImpl::insertToActivationLayerDB( /* The function returns true if there is an extension with the same id already installed which needs to be uninstalled, before the new extension can be installed. */ -bool PackageManagerImpl::checkUpdate( - Reference const & package, - Reference const & origCmdEnv, - Reference const & wrappedCmdEnv ) +bool PackageManagerImpl::isInstalled( + Reference const & package) { OUString id(dp_misc::getIdentifier(package)); OUString fn(package->getName()); - bool removeExisting = false; + bool bInstalled = false; if (m_activePackagesDB->has( id, fn )) { - // package already deployed, interact --force: - Any request( - (deployment::VersionException( - getResourceString( RID_STR_PACKAGE_ALREADY_ADDED ) + id, - static_cast(this), package, - getDeployedPackage_( id, fn, origCmdEnv ) ) ) ); - bool replace = false, abort = false; - if (! interactContinuation( - request, task::XInteractionApprove::static_type(), - wrappedCmdEnv, &replace, &abort )) { - OSL_ASSERT( !replace && !abort ); - throw deployment::DeploymentException( - getResourceString(RID_STR_ERROR_WHILE_ADDING) + id, - static_cast(this), request ); - } - if (abort || !replace) - throw CommandFailedException( - getResourceString(RID_STR_PACKAGE_ALREADY_ADDED) + id, - static_cast(this), request ); - - // remove clashing package before registering new version: - removeExisting = true; + bInstalled = true; } - return removeExisting; + return bInstalled; } + +// XPackageManager //______________________________________________________________________________ -// Notify the user when a new extension is to be installed. This is only the case -//when unopkg gui extension1 is used (used by system integration (double click on .oxt -// file etc.)). In case there is already this extension then the function returns -//true. -//ToDo: Function always returns true or throws an exception -bool PackageManagerImpl::checkInstall( - Reference const & package, - Reference const & cmdEnv) +Reference PackageManagerImpl::importExtension( + Reference const & extension, + Reference const & xAbortChannel, + Reference const & xCmdEnv_ ) + throw (deployment::DeploymentException, CommandFailedException, + CommandAbortedException, lang::IllegalArgumentException, + RuntimeException) { - OUString id(dp_misc::getIdentifier(package)); - if ( ! m_activePackagesDB->has( id, package->getName() )) - { - Any request( - deployment::InstallException( - OUSTR("Extension ") + id + OUSTR(" is about to be installed."), - static_cast(this), package)); - bool approve = false, abort = false; - if (! interactContinuation( - request, task::XInteractionApprove::static_type(), - cmdEnv, &approve, &abort )) - { - OSL_ASSERT( !approve && !abort ); - throw deployment::DeploymentException( - getResourceString(RID_STR_ERROR_WHILE_ADDING) + id, - static_cast(this), request ); - } - if (abort || !approve) - throw CommandFailedException( - getResourceString(RID_STR_ERROR_WHILE_ADDING) + id, - static_cast(this), request ); - - } - return true; + return addPackage(extension->getURL(), OUString(), xAbortChannel, xCmdEnv_); } -// XPackageManager -//______________________________________________________________________________ +/* The function adds an extension but does not register it!!! + It may not do any user interaction. This is done in XExtensionManager::addExtension +*/ Reference PackageManagerImpl::addPackage( OUString const & url, OUString const & mediaType_, Reference const & xAbortChannel, @@ -733,80 +780,39 @@ Reference PackageManagerImpl::addPackage( // bind activation package: - //Because every extension will be unpacked in a folder, which was created with a unique name - //we will always have two different XPackage objects, even if the second extension is the same. + //Because every shared/user extension will be unpacked in a folder, + //which was created with a unique name we will always have two different + //XPackage objects, even if the second extension is the same. //Therefore bindPackage does not need a guard here. xPackage = m_xRegistry->bindPackage( - makeURL( destFolder, title_enc ), mediaType, xCmdEnv ); + makeURL( destFolder, title_enc ), mediaType, false, xCmdEnv ); OSL_ASSERT( xPackage.is() ); if (xPackage.is()) { bool install = false; - OUString id; - try { - id = dp_misc::getIdentifier( xPackage ); - //checkInstall throws an exception if the user denies the installation - checkInstall(xPackage, xCmdEnv); - //checkUpdate throws an exception if the user cancels the interaction. - //For example, he may be asked if he wants to replace the older version - //with the new version. - //checkUpdates must be called before checkPrerequisites - bool bAlreadyInstalled = checkUpdate( - xPackage, xCmdEnv_, xCmdEnv ); - - if (xPackage->checkPrerequisites(xAbortChannel, xCmdEnv, bAlreadyInstalled, m_context)) + OUString const id = dp_misc::getIdentifier( xPackage ); + //This guard is used to prevent that an extension is + //installed twice. Do not use it in other functions. + //Imagine addPackage is called two times by different + //threads for the same extension quickly after each other. + //The second call would calculate "bAlreadyInstalled = + //false" if the first thread has not yet reached + //insertToActivationLayerDB. + ::osl::MutexGuard g(m_addMutex); + if (isInstalled(xPackage)) { - //This guard is used to prevent that an extension is installed twice. Do not use it in other - //functions. - //Imagine addPackage is called two times by different threads for the same extension quickly - //after each other. - //The second call would calculate "bAlreadyInstalled = false" if the first thread has not yet reached - //insertToActivationLayerDB. - ::osl::MutexGuard g(m_addMutex); - - //Holds the database data of the old extension, in case we need to roll back. - ActivePackages::Data oldDbData; - if (bAlreadyInstalled) - { - // Remove extension which is already installed. It is not removed from disk, only - // the different contents are being unregisterd. We remember the databas information - // in case we need to roll back this operation. - // When the user canceled the operation (CommandAbortedException) than the package is still - // fully functional. - // Do not guard the complete function with the getMutex - removePackage_(id, xPackage->getName(), xAbortChannel, - xCmdEnv, & oldDbData); - } - install = true; - const ::osl::MutexGuard guard( getMutex() ); - try - { - //throws CommandAbortedException if the user cancelled the installation. - xPackage->registerPackage(xAbortChannel, xCmdEnv); - } - catch(CommandAbortedException & ) - { //ToDo: Interaction so that the gui can display an appropriate string. - //See also removePackage_ - //User aborted installation, restore the previous situation. - //Use a private AbortChannel so the user cannot interrupt. - xPackage->revokePackage(new AbortChannel(), xCmdEnv); - if (bAlreadyInstalled) - { - OUString instFolder = makeURL( m_activePackages, oldDbData.temporaryName) - + OUSTR("_"); - Reference xOldPgk = m_xRegistry->bindPackage( - makeURL( instFolder, oldDbData.fileName ), oldDbData.mediaType, xCmdEnv ); - xOldPgk->registerPackage(new AbortChannel(), xCmdEnv); - insertToActivationLayerDB(dp_misc::getIdentifier( xOldPgk ), oldDbData); - } - throw; - } - //access to the database must be guarded. See removePackage_ - insertToActivationLayerDB(id, dbData); + //Do not guard the complete function with the getMutex + removePackage(id, xPackage->getName(), xAbortChannel, + xCmdEnv); } + install = true; + const ::osl::MutexGuard guard( getMutex() ); + //access to the database must be guarded. See removePackage_ + insertToActivationLayerDB(id, dbData); + } catch (...) { @@ -817,6 +823,7 @@ Reference PackageManagerImpl::addPackage( { deletePackageFromCache( xPackage, destFolder ); } + //ToDo: We should notify only if the extension is registered fireModified(); } return xPackage; @@ -860,42 +867,10 @@ void PackageManagerImpl::deletePackageFromCache( false /* no throw: ignore errors */ ); } -//______________________________________________________________________________ -void PackageManagerImpl::removePackage_( - OUString const & id, OUString const & fileName, - Reference const & xAbortChannel, - Reference const & xCmdEnv, - ActivePackages::Data * out_dbData) -{ - Reference xPackage; - { - try { - const ::osl::MutexGuard guard(getMutex()); - xPackage = getDeployedPackage_(id, fileName, xCmdEnv ); - m_activePackagesDB->get(out_dbData, id, fileName); - beans::Optional< beans::Ambiguous > option( - xPackage->isRegistered( Reference(), - xCmdEnv ) ); - if (!option.IsPresent || option.Value.IsAmbiguous || option.Value.Value) - xPackage->revokePackage( xAbortChannel, xCmdEnv ); - m_activePackagesDB->erase( id, fileName ); // to be removed upon next start - } - catch (CommandAbortedException &) - { - //ToDo: interaction, so that gui can show an appropriate string - //reregister the package - //Create our own XAbortChannel, so the user cannot interrupt the registration. - xPackage->registerPackage(new AbortChannel(), xCmdEnv); - throw; - } - } - try_dispose( xPackage ); -} - //______________________________________________________________________________ void PackageManagerImpl::removePackage( OUString const & id, ::rtl::OUString const & fileName, - Reference const & xAbortChannel, + Reference const & /*xAbortChannel*/, Reference const & xCmdEnv_ ) throw (deployment::DeploymentException, CommandFailedException, CommandAbortedException, lang::IllegalArgumentException, @@ -920,7 +895,39 @@ void PackageManagerImpl::removePackage( xCmdEnv.set( xCmdEnv_ ); try { - removePackage_( id, fileName, xAbortChannel, xCmdEnv, NULL); + Reference xPackage; + { + const ::osl::MutexGuard guard(getMutex()); + //Check if this extension exist and throw an IllegalArgumentException + //if it does not + xPackage = getDeployedPackage_(id, fileName, xCmdEnv ); + //Because the extension is only removed the next time the extension + //manager runs after restarting OOo, we need to indicate that a + //shared extension was "deleted". When a user starts OOo, then it + //will check if something changed in the shared repository. Based on + //the flag file it will then recognize, that the extension was + //deleted and can then update the extnesion database of the shared + //extensions in the user installation. + if (m_context.equals(OUSTR("shared"))) + { + ActivePackages::Data val; + m_activePackagesDB->get( & val, id, fileName); + OSL_ASSERT(val.temporaryName.getLength()); + OUString url(makeURL(m_activePackages_expanded, + val.temporaryName + OUSTR("removed"))); + ::ucbhelper::Content contentRemoved(url, xCmdEnv ); + ::rtl::OString stamp("1"); + Reference xData( + ::xmlscript::createInputStream( + ::rtl::ByteSequence( + reinterpret_cast(stamp.getStr()), + stamp.getLength() ) ) ); + contentRemoved.writeStream( xData, true /* replace existing */ ); + } + m_activePackagesDB->erase( id, fileName ); // to be removed upon next start + } + try_dispose( xPackage ); + fireModified(); } catch (RuntimeException &) { @@ -955,10 +962,16 @@ OUString PackageManagerImpl::getDeployPath( ActivePackages::Data const & data ) { ::rtl::OUStringBuffer buf; buf.append( data.temporaryName ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") ); - buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar, + //The bundled extensions are not contained in an additional folder + //with a unique name. data.temporaryName contains already the + //UTF8 encoded folder name. See PackageManagerImpl::synchronize + if (!m_context.equals(OUSTR("bundled"))) + { + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") ); + buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ) ); + } return makeURL( m_activePackages, buf.makeStringAndClear() ); } @@ -998,7 +1011,7 @@ Reference PackageManagerImpl::getDeployedPackage_( } } return m_xRegistry->bindPackage( - getDeployPath( data ), data.mediaType, xCmdEnv ); + getDeployPath( data ), data.mediaType, false, xCmdEnv ); } //______________________________________________________________________________ @@ -1124,8 +1137,12 @@ PackageManagerImpl::getDeployedPackages( } //______________________________________________________________________________ + + +//ToDo: the function must not call registerPackage, do this in +//XExtensionManager.reinstallDeployedExtensions void PackageManagerImpl::reinstallDeployedPackages( - Reference const & xAbortChannel, + Reference const & /*xAbortChannel*/, Reference const & xCmdEnv_ ) throw (deployment::DeploymentException, CommandFailedException, CommandAbortedException, @@ -1167,12 +1184,7 @@ void PackageManagerImpl::reinstallDeployedPackages( if (xUpdatable.is()) xUpdatable->update(); - // reregister all: - const ::osl::MutexGuard guard( getMutex() ); - const Sequence< Reference > packages( - getDeployedPackages_( xCmdEnv ) ); - for ( sal_Int32 pos = 0; pos < packages.getLength(); ++pos ) - packages[ pos ]->registerPackage( xAbortChannel, xCmdEnv ); + //registering is done by the ExtensionManager service. } catch (RuntimeException &) { throw; @@ -1205,6 +1217,242 @@ void PackageManagerImpl::reinstallDeployedPackages( { return m_readOnly; } +void PackageManagerImpl::synchronizeRemovedExtensions( + Sequence > & out_removedExtensions, + Reference const & /*xAbortChannel*/, + Reference const & xCmdEnv) +{ + + //find all which are in the extension data base but which + //are removed already. + OSL_ASSERT(!m_context.equals(OUSTR("user"))); + ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); + + //Iterate over the contents of the extension folder and gather the + //temp file names (shared) or the folder names of the bundled extension. + ::ucbhelper::ResultSetInclude includeType = ::ucbhelper::INCLUDE_DOCUMENTS_ONLY; + if (m_context.equals(OUSTR("bundled"))) + includeType = ::ucbhelper::INCLUDE_FOLDERS_ONLY; + ::ucbhelper::Content tempFolder( + m_activePackages_expanded, xCmdEnv ); + Reference xResultSet( + tempFolder.createCursor( + Sequence( &StrTitle::get(), 1 ), includeType) ); + // get all temp directories: + ::std::vector tempEntries; + while (xResultSet->next()) { + OUString title( + Reference( + xResultSet, UNO_QUERY_THROW )->getString( + 1 /* Title */ ) ); + //also add the xxx.tmpremoved files for remove shared extensions + //this does not matter + tempEntries.push_back( ::rtl::Uri::encode( + title, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ); + } + + typedef ActivePackages::Entries::const_iterator ITActive; + bool bShared = m_context.equals(OUSTR("shared")); + ::std::vector > removedExtensions; + for (ITActive i = id2temp.begin(); i != id2temp.end(); i++) + { + //Get the URL to the extensions folder, first make the url for the + //shared repository including the temporary name +// OUString url(m_activePackages_expanded + OUSTR("/") +// + i->second.temporaryName); +// if (bShared) +// url = appendURLSegement(m_activePackages_expanded + OUSTR("/") +// + i->second.temporaryName + OUSTR("_"), +// i->second.fileName); + OUString url = makeURL(m_activePackages, i->second.temporaryName); + if (bShared) + url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName); + + const MatchExtension match(i->second); + bool bRemoved = false; + if (::std::find_if(tempEntries.begin(), tempEntries.end(), match) == + tempEntries.end()) + { + //The the URL from the data base entry does not exist anymore. That is the + //folder was removed. + bRemoved = true; + } + else + { + //The folder is in the extension database, but it can still be deleted. + //look for the xxx.tmpremoved file + if (bShared) + { + ::ucbhelper::Content contentRemoved; + if (create_ucb_content( + &contentRemoved, + m_activePackages_expanded + OUSTR("/") + + i->second.temporaryName + OUSTR("removed"), + Reference(), false)) + { + bRemoved = true; + } + } + if (!bRemoved) + { + //There may be another extensions at the same place + dp_misc::DescriptionInfoset infoset = + dp_misc::getDescriptionInfoset(url); + OSL_ENSURE(infoset.hasDescription(), + "Extension Manager: bundled and shared extensions " + "must have an identifer and a version"); + if ( ! i->first.equals(*(infoset.getIdentifier())) + || ! i->second.version.equals(infoset.getVersion())) + { + bRemoved = true; + } + } + } + if (bRemoved) + { + Reference xPackage = m_xRegistry->bindPackage( + url, i->second.mediaType, true, xCmdEnv ); + OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object. + removedExtensions.push_back(xPackage); + } + } + out_removedExtensions = ::comphelper::containerToSequence(removedExtensions); +} + +void PackageManagerImpl::synchronizeAddedExtensions( + Sequence > & out_addedExtensions, + Reference const & xAbortChannel, + Reference const & xCmdEnv) +{ + // clean up activation layer, scan for zombie temp dirs: + ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); + + ::ucbhelper::Content tempFolder( + m_activePackages_expanded, xCmdEnv ); + Reference xResultSet( + tempFolder.createCursor( + Sequence( &StrTitle::get(), 1 ), + ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); + + + ::std::vector > addedExtensions; + while (xResultSet->next()) + { + OUString title( + Reference( + xResultSet, UNO_QUERY_THROW )->getString( + 1 /* Title */ ) ); + //The temporary folders of user and shared have an '_' at then end. + //But the name in ActivePackages.temporaryName is saved without. + OUString title2 = title; + bool bNotBundled = !m_context.equals(OUSTR("bundled")); + if (bNotBundled) + { + OSL_ASSERT(title2[title2.getLength() -1] == '_'); + title2 = title2.copy(0, title2.getLength() -1); + } + OUString titleEncoded = ::rtl::Uri::encode( + title2, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8); + + const MatchTempDir match(titleEncoded); + if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == + id2temp.end()) + { + + // The folder was not found in the data base, so it must be + // an added extension + OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded); + OUString sExtFolder; + if (bNotBundled) //that is, shared + { + //Check if the extension was not "deleted" already which is indicated + //by a xxx.tmpremoved file + ::ucbhelper::Content contentRemoved; + if (create_ucb_content(&contentRemoved, url + OUSTR("removed"), + Reference(), false)) + continue; + sExtFolder = getExtensionFolder( + m_activePackages_expanded + + OUString(OUSTR("/")) + titleEncoded + OUSTR("_"), xCmdEnv); + url = appendURLSegement(m_activePackages_expanded, title); + url = appendURLSegement(url, sExtFolder); + } + Reference xPackage = m_xRegistry->bindPackage( + url, OUString(), false, xCmdEnv ); + if (xPackage.is()) + { + try + { + //ToDo: We need to prevent that removed shared extensions are + //added again. This can happen if there is still the folder of the + //extension. However, there is the "removed" flag file which indicates + //that the extension was removed. + //Prepare the database entry + ActivePackages::Data dbData; + //There is no temporary folder for bundled extensions. It is therefore + //an empty string. + dbData.temporaryName = titleEncoded; + if (bNotBundled) + dbData.fileName = sExtFolder; + else + dbData.fileName = title; + dbData.mediaType = xPackage->getPackageType()->getMediaType(); + dbData.version = xPackage->getVersion(); + OSL_ENSURE(dbData.version.getLength() > 0, + "Extension Manager: bundled and shared extensions must have " + "an identifier and a version"); + + OUString id = dp_misc::getIdentifier( xPackage ); + sal_Bool bAlreadyInstalled = sal_False; + if (xPackage->checkPrerequisites( + xAbortChannel, xCmdEnv, bAlreadyInstalled, m_context)) + { + const ::osl::MutexGuard guard( getMutex() ); + //access to the database must be guarded. See removePackage_ + insertToActivationLayerDB(id, dbData); + } + else + { + //ToDo: Remember that this failed. For example, the user + //could have declined the license. Then the next time the + //extension folder is investigated we do not want to + //try to install the extension again. + } + addedExtensions.push_back(xPackage); + } + catch (...) + { + } + } + } + } + out_addedExtensions = ::comphelper::containerToSequence(addedExtensions); +} + +void PackageManagerImpl::synchronize( + Sequence > & out_addedExtensions, + Sequence > & out_removedExtensions, + Reference const & xAbortChannel, + Reference const & xCmdEnv) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException) +{ + + check(); + if (m_context.equals(OUSTR("user"))) + return; + synchronizeRemovedExtensions( + out_removedExtensions, xAbortChannel, xCmdEnv); + synchronizeAddedExtensions( + out_addedExtensions, xAbortChannel, xCmdEnv); +} + //############################################################################## diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h index ffa7252d7883..1249fe7e29d4 100644 --- a/desktop/source/deployment/manager/dp_manager.h +++ b/desktop/source/deployment/manager/dp_manager.h @@ -53,6 +53,8 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper { css::uno::Reference m_xComponentContext; ::rtl::OUString m_context; + ::rtl::OUString m_registrationData; + ::rtl::OUString m_registrationData_expanded; ::rtl::OUString m_registryCache; bool m_readOnly; @@ -83,16 +85,20 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper css::uno::Reference const & xPackage, ::rtl::OUString const & destFolder ); - bool checkUpdate( - css::uno::Reference const & package, - css::uno::Reference const & origCmdEnv, - css::uno::Reference const & - wrappedCmdEnv ); + bool isInstalled( + css::uno::Reference const & package); - bool checkInstall( - css::uno::Reference const & package, - css::uno::Reference const & cmdEnv); + void synchronizeRemovedExtensions( + css::uno::Sequence > & + out_removedExtensions, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + void synchronizeAddedExtensions( + css::uno::Sequence > & + out_AddedExtensions, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); class CmdEnvWrapperImpl : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment, @@ -135,7 +141,7 @@ protected: : t_pm_helper( getMutex() ), m_xComponentContext( xComponentContext ), m_context( context ), - m_readOnly( false ) + m_readOnly( true ) {} public: @@ -180,17 +186,15 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); - /* Unregisters the package but does not remove it from disk. - When the operation is canceled by the user, a CommandAbortedException - is thrown. Then the package is still fully functional. - @param out_oldData - can be NULL - */ - void removePackage_( - ::rtl::OUString const & id, ::rtl::OUString const & fileName, + virtual css::uno::Reference SAL_CALL importExtension( + css::uno::Reference const & extension, css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv, - ActivePackages::Data * out_oldData); + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); virtual void SAL_CALL removePackage( ::rtl::OUString const & id, ::rtl::OUString const & fileName, @@ -242,6 +246,17 @@ public: virtual ::sal_Bool SAL_CALL isReadOnly( ) throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL synchronize( + css::uno::Sequence > & out_xAddedExtensions, + css::uno::Sequence > & out_xRemovedExtensions, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException); + }; //______________________________________________________________________________ diff --git a/desktop/source/deployment/manager/dp_managerfac.cxx b/desktop/source/deployment/manager/dp_managerfac.cxx index d4c9df1d57af..f6fde6b07d60 100644 --- a/desktop/source/deployment/manager/dp_managerfac.cxx +++ b/desktop/source/deployment/manager/dp_managerfac.cxx @@ -53,6 +53,7 @@ class PackageManagerFactoryImpl : private MutexHolder, public t_pmfac_helper Reference m_xUserMgr; Reference m_xSharedMgr; + Reference m_xBundledMgr; typedef ::std::hash_map< OUString, WeakReference, ::rtl::OUStringHash > t_string2weakref; @@ -141,6 +142,7 @@ void PackageManagerFactoryImpl::disposing() // the below are already disposed: m_xUserMgr.clear(); m_xSharedMgr.clear(); + m_xBundledMgr.clear(); } // XPackageManagerFactory @@ -172,6 +174,8 @@ PackageManagerFactoryImpl::getPackageManager( OUString const & context ) m_xUserMgr = xRet; else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) m_xSharedMgr = xRet; + else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") )) + m_xBundledMgr = xRet; } else { diff --git a/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx b/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx new file mode 100644 index 000000000000..3a4a6f1d2b72 --- /dev/null +++ b/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "com/sun/star/deployment/VersionException.hpp" +#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" +#include "com/sun/star/deployment/LicenseException.hpp" +#include "com/sun/star/deployment/InstallException.hpp" +#include "com/sun/star/task/XInteractionApprove.hpp" +#include "com/sun/star/task/XInteractionAbort.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "dp_tmprepocmdenv.hxx" + +namespace deployment = com::sun::star::deployment; +namespace lang = com::sun::star::lang; +namespace task = com::sun::star::task; +namespace ucb = com::sun::star::ucb; +namespace uno = com::sun::star::uno; +namespace css = com::sun::star; + +#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) + +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +namespace dp_manager { + +TmpRepositoryCommandEnv::TmpRepositoryCommandEnv() +{ +} + +TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( + Reference< css::task::XInteractionHandler> const & handler) + : m_forwardHandler(handler) +{ +} + +TmpRepositoryCommandEnv::~TmpRepositoryCommandEnv() +{ +} +// XCommandEnvironment +//______________________________________________________________________________ +Reference TmpRepositoryCommandEnv::getInteractionHandler() +throw (uno::RuntimeException) +{ + return this; +} + +//______________________________________________________________________________ +Reference TmpRepositoryCommandEnv::getProgressHandler() +throw (uno::RuntimeException) +{ + return this; +} + +// XInteractionHandler +void TmpRepositoryCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + deployment::VersionException verExc; + deployment::LicenseException licExc; + deployment::InstallException instExc; + deployment::LicenseIndividualAgreementException licAgreementExc; + + + bool approve = false; + bool abort = false; + + if ((request >>= verExc) + || (request >>= licExc) + || (request >>= instExc) + || (request >>= licAgreementExc)) + { + approve = true; + } + + if (approve == false && abort == false) + { + if (m_forwardHandler.is()) + m_forwardHandler->handle(xRequest); + else + approve = true; + } + else + { + // select: + uno::Sequence< Reference< task::XInteractionContinuation > > conts( + xRequest->getContinuations() ); + Reference< task::XInteractionContinuation > const * pConts = + conts.getConstArray(); + sal_Int32 len = conts.getLength(); + for ( sal_Int32 pos = 0; pos < len; ++pos ) + { + if (approve) { + Reference< task::XInteractionApprove > xInteractionApprove( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionApprove.is()) { + xInteractionApprove->select(); + // don't query again for ongoing continuations: + approve = false; + } + } + else if (abort) { + Reference< task::XInteractionAbort > xInteractionAbort( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionAbort.is()) { + xInteractionAbort->select(); + // don't query again for ongoing continuations: + abort = false; + } + } + } + } +} + +// XProgressHandler +void TmpRepositoryCommandEnv::push( uno::Any const & /*Status*/ ) +throw (uno::RuntimeException) +{ +} + + +void TmpRepositoryCommandEnv::update( uno::Any const & /*Status */) +throw (uno::RuntimeException) +{ +} + +void TmpRepositoryCommandEnv::pop() throw (uno::RuntimeException) +{ +} + + +} // namespace dp_manager + + diff --git a/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx b/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx new file mode 100644 index 000000000000..22111bc1e081 --- /dev/null +++ b/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_TMPREPOSITORYCOMMANDENVIRONMENT_HXX +#define INCLUDED_DP_TMPREPOSITORYCOMMANDENVIRONMENT_HXX + + +#include "cppuhelper/compbase3.hxx" +//#include "cppuhelper/implbase2.hxx" +#include "ucbhelper/content.hxx" + + + +namespace css = ::com::sun::star; + +namespace dp_manager { + +/** + This command environment is to be used when an extension is temporarily + stored in the "tmp" repository. It prevents all kind of user interaction. + */ +class TmpRepositoryCommandEnv + : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment, + css::task::XInteractionHandler, + css::ucb::XProgressHandler > +{ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler; +public: + virtual ~TmpRepositoryCommandEnv(); + TmpRepositoryCommandEnv(); + TmpRepositoryCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler); + + // XCommandEnvironment + virtual css::uno::Reference SAL_CALL + getInteractionHandler() throw (css::uno::RuntimeException); + virtual css::uno::Reference + SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + + // XProgressHandler + virtual void SAL_CALL push( css::uno::Any const & Status ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL update( css::uno::Any const & Status ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL pop() throw (css::uno::RuntimeException); +}; + +} + + + + +#endif + diff --git a/desktop/source/deployment/manager/makefile.mk b/desktop/source/deployment/manager/makefile.mk index a9ff47881fc3..cb99325bde52 100644 --- a/desktop/source/deployment/manager/makefile.mk +++ b/desktop/source/deployment/manager/makefile.mk @@ -45,7 +45,9 @@ SLOFILES = \ $(SLO)$/dp_activepackages.obj \ $(SLO)$/dp_manager.obj \ $(SLO)$/dp_managerfac.obj \ - $(SLO)$/dp_informationprovider.obj + $(SLO)$/dp_informationprovider.obj \ + $(SLO)$/dp_extensionmanager.obj \ + $(SLO)$/dp_tmprepocmdenv.obj .INCLUDE : ..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx index 28f45918e9e2..d97b400f4609 100644 --- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx +++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx @@ -35,6 +35,7 @@ #include "comphelper/sequence.hxx" #include "comphelper/makesequence.hxx" +#include "comphelper/processfactory.hxx" #include "boost/optional.hpp" #include "com/sun/star/beans/Optional.hpp" #include "com/sun/star/lang/XMultiComponentFactory.hpp" @@ -47,17 +48,23 @@ #include "com/sun/star/xml/dom/DOMException.hpp" #include "com/sun/star/xml/dom/XNode.hpp" #include "com/sun/star/xml/dom/XNodeList.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" #include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp" #include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implbase2.hxx" #include "cppuhelper/weak.hxx" +#include "cppuhelper/exc_hlp.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" - +#include "ucbhelper/content.hxx" namespace { namespace css = ::com::sun::star; +using css::uno::Reference; +using ::rtl::OUString; class EmptyNodeList: public ::cppu::WeakImplHelper1< css::xml::dom::XNodeList > { @@ -110,10 +117,251 @@ css::uno::Reference< css::xml::dom::XNode > EmptyNodeList::item(::sal_Int32) } } +/**The class uses the UCB to access the description.xml file in an + extension. The UCB must have been initialized already. It also + requires that the extension has already be unzipped to a particular + location. + */ +class ExtensionDescription +{ +public: + /**throws an exception if the description.xml is not + available, cannot be read, does not contain the expected data, + or any other error occured. Therefore it shoult only be used with + new extensions. + + Throws com::sun::star::uno::RuntimeException, + com::sun::star::deployment::DeploymentException, + dp_registry::backend::bundle::NoDescriptionException. + */ + ExtensionDescription( + const css::uno::Reference& xContext, + const ::rtl::OUString& installDir, + const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv); + + ~ExtensionDescription(); + + css::uno::Reference getRootElement() const + { + return m_xRoot; + } + + ::rtl::OUString getExtensionRootUrl() const + { + return m_sExtensionRootUrl; + } + + +private: + css::uno::Reference m_xRoot; + ::rtl::OUString m_sExtensionRootUrl; +}; + +class NoDescriptionException +{ +}; + +class FileDoesNotExistFilter + : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment, + css::task::XInteractionHandler > + +{ + //css::uno::Reference m_xHandler; + bool m_bExist; + css::uno::Reference< css::ucb::XCommandEnvironment > m_xCommandEnv; + +public: + virtual ~FileDoesNotExistFilter(); + FileDoesNotExistFilter( + const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv); + + bool exist(); + // XCommandEnvironment + virtual css::uno::Reference SAL_CALL + getInteractionHandler() throw (css::uno::RuntimeException); + virtual css::uno::Reference + SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); +}; + +ExtensionDescription::ExtensionDescription( + const Reference& xContext, + const OUString& installDir, + const Reference< css::ucb::XCommandEnvironment >& xCmdEnv) +{ + try { + m_sExtensionRootUrl = installDir; + //may throw ::com::sun::star::ucb::ContentCreationException + //If there is no description.xml then ucb will start an interaction which + //brings up a dialog.We want to prevent this. Therefore we wrap the xCmdEnv + //and filter the respective exception out. + OUString sDescriptionUri(installDir + OUSTR("/description.xml")); + Reference xFilter = + static_cast( + new FileDoesNotExistFilter(xCmdEnv)); + ::ucbhelper::Content descContent(sDescriptionUri, xFilter); + + //throws an com::sun::star::uno::Exception if the file is not available + Reference xIn; + try + { //throws com.sun.star.ucb.InteractiveAugmentedIOException + xIn = descContent.openStream(); + } + catch (css::uno::Exception& ) + { + if ( ! static_cast(xFilter.get())->exist()) + throw NoDescriptionException(); + throw; + } + if (!xIn.is()) + { + throw css::uno::Exception( + OUSTR("Could not get XInputStream for description.xml of extension ") + + sDescriptionUri, 0); + } + + //get root node of description.xml + Reference xDocBuilder( + xContext->getServiceManager()->createInstanceWithContext( + OUSTR("com.sun.star.xml.dom.DocumentBuilder"), + xContext ), css::uno::UNO_QUERY); + if (!xDocBuilder.is()) + throw css::uno::Exception(OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0); + + if (xDocBuilder->isNamespaceAware() == sal_False) + { + throw css::uno::Exception( + OUSTR("Service com.sun.star.xml.dom.DocumentBuilder is not namespace aware."), 0); + } + + Reference xDoc = xDocBuilder->parse(xIn); + if (!xDoc.is()) + { + throw css::uno::Exception(sDescriptionUri + OUSTR(" contains data which cannot be parsed. "), 0); + } + + //check for proper root element and namespace + Reference xRoot = xDoc->getDocumentElement(); + if (!xRoot.is()) + { + throw css::uno::Exception( + sDescriptionUri + OUSTR(" contains no root element."), 0); + } + + if ( ! xRoot->getTagName().equals(OUSTR("description"))) + { + throw css::uno::Exception( + sDescriptionUri + OUSTR(" does not contain the root element ."), 0); + } + + m_xRoot = Reference( + xRoot, css::uno::UNO_QUERY_THROW); + OUString nsDescription = xRoot->getNamespaceURI(); + + //check if this namespace is supported + if ( ! nsDescription.equals(OUSTR("http://openoffice.org/extensions/description/2006"))) + { + throw css::uno::Exception(sDescriptionUri + OUSTR(" contains a root element with an unsupported namespace. "), 0); + } + } catch (css::uno::RuntimeException &) { + throw; + } catch (css::deployment::DeploymentException &) { + throw; + } catch (css::uno::Exception & e) { + css::uno::Any a(cppu::getCaughtException()); + throw css::deployment::DeploymentException( + e.Message, Reference< css::uno::XInterface >(), a); + } +} + +ExtensionDescription::~ExtensionDescription() +{ +} + +//====================================================================== +FileDoesNotExistFilter::FileDoesNotExistFilter( + const Reference< css::ucb::XCommandEnvironment >& xCmdEnv): + m_bExist(true), m_xCommandEnv(xCmdEnv) +{} + +FileDoesNotExistFilter::~FileDoesNotExistFilter() +{ +}; + +bool FileDoesNotExistFilter::exist() +{ + return m_bExist; +} + // XCommandEnvironment +Reference + FileDoesNotExistFilter::getInteractionHandler() throw (css::uno::RuntimeException) +{ + return static_cast(this); +} + +Reference + FileDoesNotExistFilter::getProgressHandler() throw (css::uno::RuntimeException) +{ + return m_xCommandEnv.is() + ? m_xCommandEnv->getProgressHandler() + : Reference(); +} + +// XInteractionHandler +//If the interaction was caused by a non-existing file which is specified in the ctor +//of FileDoesNotExistFilter, then we do nothing +void FileDoesNotExistFilter::handle( + Reference const & xRequest ) + throw (css::uno::RuntimeException) +{ + css::uno::Any request( xRequest->getRequest() ); + + css::ucb::InteractiveAugmentedIOException ioexc; + if ((request>>= ioexc) && ioexc.Code == css::ucb::IOErrorCode_NOT_EXISTING ) + { + m_bExist = false; + return; + } + Reference xInteraction; + if (m_xCommandEnv.is()) { + xInteraction = m_xCommandEnv->getInteractionHandler(); + } + if (xInteraction.is()) { + xInteraction->handle(xRequest); + } +} + } namespace dp_misc { +DescriptionInfoset getDescriptionInfoset(OUString const & sExtensionFolderURL) +{ + Reference< css::xml::dom::XNode > root; + Reference context = + comphelper_getProcessComponentContext(); + OSL_ASSERT(context.is()); + try { + root = + ExtensionDescription( + context, sExtensionFolderURL, + Reference< css::ucb::XCommandEnvironment >()). + getRootElement(); + } catch (NoDescriptionException &) { + } catch (css::deployment::DeploymentException & e) { + throw css::uno::RuntimeException( + (OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.deployment.DeploymentException: ")) + + e.Message), 0); + } + return DescriptionInfoset(context, root); +} + DescriptionInfoset::DescriptionInfoset( css::uno::Reference< css::uno::XComponentContext > const & context, css::uno::Reference< css::xml::dom::XNode > const & element): diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 3ed2d554b59f..1f1fde7ca7bf 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -197,6 +197,19 @@ OUString makeURL( OUString const & baseURL, OUString const & relPath_ ) return buf.makeStringAndClear(); } +OUString makeURLAppendSysPathSegment( OUString const & baseURL, OUString const & relPath_ ) +{ + OUString segment = relPath_; + OSL_ASSERT(segment.indexOf(static_cast('/')) == -1); + + ::rtl::Uri::encode( + segment, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8); + return makeURL(baseURL, segment); +} + + + //============================================================================== OUString expandUnoRcTerm( OUString const & term_ ) { @@ -467,4 +480,22 @@ void TRACE(::rtl::OString const & sText) #endif } +bool hasExtensionRepositoryChanged(::rtl::OUString const & repository) +{ + if (repository.equals(OUSTR("shared"))) + { + //get the extensions folder + OUString folder(RTL_CONSTASCII_USTRINGPARAM("BUNDLED_EXTENSIONS")); + ::rtl::Bootstrap::expandMacros(folder); + } + else if (repository.equals(OUSTR("bundled"))) + { + } + else + throw lang::IllegalArgumentException( + OUSTR("Invalid repository name."), 0, 0); + + return false; +} + } diff --git a/desktop/source/deployment/misc/dp_version.cxx b/desktop/source/deployment/misc/dp_version.cxx index 1668ebe4a0b7..c0da0533b54c 100644 --- a/desktop/source/deployment/misc/dp_version.cxx +++ b/desktop/source/deployment/misc/dp_version.cxx @@ -70,11 +70,5 @@ namespace dp_misc { return ::dp_misc::EQUAL; } -::dp_misc::Order comparePackageVersions( - css::uno::Reference< css::deployment::XPackage > const & package1, - css::uno::Reference< css::deployment::XPackage > const & package2) -{ - return compareVersions(package1->getVersion(), package2->getVersion()); -} } diff --git a/desktop/source/deployment/misc/makefile.mk b/desktop/source/deployment/misc/makefile.mk index e191169202fd..9a7f1d62e001 100644 --- a/desktop/source/deployment/misc/makefile.mk +++ b/desktop/source/deployment/misc/makefile.mk @@ -75,7 +75,8 @@ SHL1STDLIBS = \ $(TOOLSLIB) \ $(UCBHELPERLIB) \ $(UNOTOOLSLIB) \ - $(XMLSCRIPTLIB) + $(XMLSCRIPTLIB) \ + $(COMPHELPERLIB) .IF "$(GUI)"=="OS2" SHL1IMPLIB = ideploymentmisc$(DLLPOSTFIX) LIB1TARGET = $(SLB)$/_deplmisc.lib diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx new file mode 100644 index 000000000000..edaf642a2ab1 --- /dev/null +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -0,0 +1,142 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_compbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010" +#define ROOT_ELEMENT_NAME "component-backend-db" + +namespace dp_registry { +namespace backend { +namespace component { + +ComponentBackendDb::ComponentBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString ComponentBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ComponentBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + Reference componentElement( + doc->createElement(OUSTR("component"))); + + componentElement->setAttribute(OUSTR("url"), url); + + Reference componentNode( + componentElement, UNO_QUERY_THROW); + + root->appendChild(componentNode); + + Reference javaTypeLibNode( + doc->createElement(OUSTR("java-type-library")), UNO_QUERY_THROW); + + componentNode->appendChild(javaTypeLibNode); + + Reference javaTypeLibValueNode( + doc->createTextNode(OUString::valueOf((sal_Bool) data.javaTypeLibrary)), + UNO_QUERY_THROW); + javaTypeLibNode->appendChild(javaTypeLibValueNode); + + writeSimpleList( + data.implementationNames, + OUSTR("implementation-names"), + OUSTR("name"), + componentNode); + + writeVectorOfPair( + data.singletons, + OUSTR("singletons"), + OUSTR("item"), + OUSTR("key"), + OUSTR("value"), + componentNode); + + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +void ComponentBackendDb::removeEntry(::rtl::OUString const & url) +{ + OUString sExpression( + OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + removeElement(sExpression); +} + + + +} // namespace bundle +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx new file mode 100644 index 000000000000..0dde24beed3f --- /dev/null +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_COMPBACKENDDB_HXX +#define INCLUDED_DP_COMPBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { +namespace component { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + The format looks like this: + + + + + true + + com.sun.star.comp.extensionoptions.OptionsEventHandler$_OptionsEventHandler + ... + + + + com.sun.star.java.theJavaVirtualMachine + com.sun.star.java.JavaVirtualMachine + + ... + + + + + ... + + */ +class ComponentBackendDb: public dp_registry::backend::BackendDb +{ +public: + struct Data + { + Data(): javaTypeLibrary(false) {}; + + ::std::list< ::rtl::OUString> implementationNames; + /* every singleton has a key and a value + */ + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString> >singletons; + bool javaTypeLibrary; + }; + +public: + + ComponentBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url, Data const & data); + void removeEntry(::rtl::OUString const & url); + + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getRootElementName(); + + +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index e6781e2a1746..e4e5efff9e81 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -58,7 +58,7 @@ #include #include #include - +#include "dp_compbackenddb.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -74,6 +74,9 @@ namespace { typedef ::std::list t_stringlist; typedef ::std::vector< ::std::pair > t_stringpairvec; +#define IMPLEMENTATION_NAME "com.sun.star.comp.deployment.component.PackageRegistryBackend" +inline OUString makeRcTerm( OUString const & url ); + /** return a vector of bootstrap variables which have been provided as command arguments. */ @@ -153,9 +156,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - OUString const & loader ) + OUString const & loader, bool bUseDb ) : Package( myBackend, url, name, name /* display-name */, - xPackageType ), + xPackageType, bUseDb ), m_loader( loader ), m_registered( REG_UNINIT ) {} @@ -187,9 +190,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool jarFile ) + bool jarFile, bool bUseDb ) : Package( myBackend, url, name, name /* display-name */, - xPackageType ), + xPackageType, bUseDb), m_jarFile( jarFile ) {} }; @@ -212,6 +215,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -230,6 +234,12 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend OUString m_commonRDB_RO; OUString m_nativeRDB_RO; + std::auto_ptr m_backendDb; + + void addDataToDb(OUString const & url, ComponentBackendDb::Data const & data); + void deleteDataFromDb(OUString const & url); + + //These rdbs are for writing new service entries. The rdb files are copies //which are created when services are added or removed. Reference m_xCommonRDB; @@ -371,59 +381,59 @@ void BackendImpl::disposing() } } + void BackendImpl::initServiceRdbFiles() { const Reference xCmdEnv; - if (! m_readOnly) + + ::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv ); + ::ucbhelper::Content oldRDB; + // switch common rdb: + if (m_commonRDB_RO.getLength() > 0) { - ::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv ); - ::ucbhelper::Content oldRDB; - // switch common rdb: - if (m_commonRDB_RO.getLength() > 0) - { - create_ucb_content( - &oldRDB, makeURL( getCachePath(), m_commonRDB_RO), - xCmdEnv, false /* no throw */ ); - } - m_commonRDB = m_commonRDB_RO.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM("common.rdb") ) - ? OUSTR("common_.rdb") : OUSTR("common.rdb"); - if (oldRDB.get().is()) - { - if (! cacheDir.transferContent( + create_ucb_content( + &oldRDB, makeURL( getCachePath(), m_commonRDB_RO), + xCmdEnv, false /* no throw */ ); + } + m_commonRDB = m_commonRDB_RO.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("common.rdb") ) + ? OUSTR("common_.rdb") : OUSTR("common.rdb"); + if (oldRDB.get().is()) + { + if (! cacheDir.transferContent( oldRDB, ::ucbhelper::InsertOperation_COPY, m_commonRDB, NameClash::OVERWRITE )) - { - - throw RuntimeException( - OUSTR("UCB transferContent() failed!"), 0 ); - } - oldRDB = ::ucbhelper::Content(); - } - // switch native rdb: - if (m_nativeRDB_RO.getLength() > 0) { - create_ucb_content( - &oldRDB, makeURL(getCachePath(), m_nativeRDB_RO), - xCmdEnv, false /* no throw */ ); + + throw RuntimeException( + OUSTR("UCB transferContent() failed!"), 0 ); } - const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") ); - const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") ); - m_nativeRDB = m_nativeRDB_RO.equals( plt_rdb ) ? plt_rdb_ : plt_rdb; - if (oldRDB.get().is()) - { - if (! cacheDir.transferContent( + oldRDB = ::ucbhelper::Content(); + } + // switch native rdb: + if (m_nativeRDB_RO.getLength() > 0) + { + create_ucb_content( + &oldRDB, makeURL(getCachePath(), m_nativeRDB_RO), + xCmdEnv, false /* no throw */ ); + } + const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") ); + const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") ); + m_nativeRDB = m_nativeRDB_RO.equals( plt_rdb ) ? plt_rdb_ : plt_rdb; + if (oldRDB.get().is()) + { + if (! cacheDir.transferContent( oldRDB, ::ucbhelper::InsertOperation_COPY, m_nativeRDB, NameClash::OVERWRITE )) - throw RuntimeException( + throw RuntimeException( OUSTR("UCB transferContent() failed!"), 0 ); - } - - // UNO is bootstrapped, flush for next process start: - m_unorc_modified = true; - unorc_flush( Reference() ); } + // UNO is bootstrapped, flush for next process start: + m_unorc_modified = true; + unorc_flush( Reference() ); + + // common rdb for java, native rdb for shared lib components if (m_commonRDB.getLength() > 0) { m_xCommonRDB.set( @@ -433,7 +443,8 @@ void BackendImpl::initServiceRdbFiles() m_xComponentContext ), UNO_QUERY_THROW ); m_xCommonRDB->open( makeURL( expandUnoRcUrl(getCachePath()), m_commonRDB ), - m_readOnly, !m_readOnly ); +// m_readOnly, !m_readOnly ); + false, true); } if (m_nativeRDB.getLength() > 0) { m_xNativeRDB.set( @@ -443,7 +454,8 @@ void BackendImpl::initServiceRdbFiles() m_xComponentContext ), UNO_QUERY_THROW ); m_xNativeRDB->open( makeURL( expandUnoRcUrl(getCachePath()), m_nativeRDB ), - m_readOnly, !m_readOnly ); +// m_readOnly, !m_readOnly ); + false, true); } } @@ -562,9 +574,25 @@ BackendImpl::BackendImpl( initServiceRdbFiles_RO(); + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new ComponentBackendDb(getComponentContext(), dbFile)); } } +void BackendImpl::addDataToDb( + OUString const & url, ComponentBackendDb::Data const & data) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url, data); +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference > @@ -577,6 +605,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType(mediaType_); @@ -649,17 +678,20 @@ Reference BackendImpl::bindPackage_( if (value.EqualsIgnoreCaseAscii("native")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xDynComponentTypeInfo, - OUSTR("com.sun.star.loader.SharedLibrary") ); + OUSTR("com.sun.star.loader.SharedLibrary"), + bNoFileAccess ); } if (value.EqualsIgnoreCaseAscii("Java")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xJavaComponentTypeInfo, - OUSTR("com.sun.star.loader.Java2") ); + OUSTR("com.sun.star.loader.Java2"), + bNoFileAccess ); } if (value.EqualsIgnoreCaseAscii("Python")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xPythonComponentTypeInfo, - OUSTR("com.sun.star.loader.Python") ); + OUSTR("com.sun.star.loader.Python"), + bNoFileAccess); } } } @@ -675,12 +707,12 @@ Reference BackendImpl::bindPackage_( { return new BackendImpl::TypelibraryPackageImpl( this, url, name, m_xRDBTypelibTypeInfo, - false /* rdb */ ); + false /* rdb */, bNoFileAccess); } if (value.EqualsIgnoreCaseAscii("Java")) { return new BackendImpl::TypelibraryPackageImpl( this, url, name, m_xJavaTypelibTypeInfo, - true /* jar */ ); + true /* jar */, bNoFileAccess); } } } @@ -785,18 +817,11 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) return; ::rtl::OStringBuffer buf; - // UNO_USER_PACKAGES_CACHE, UNO_SHARED_PACKAGES_CACHE have to be resolved - // locally: - if (m_eContext == CONTEXT_USER) { - buf.append( RTL_CONSTASCII_STRINGPARAM( - "UNO_USER_PACKAGES_CACHE=$ORIGIN/../..") ); - } - else if (m_eContext == CONTEXT_SHARED) { - buf.append( RTL_CONSTASCII_STRINGPARAM( - "UNO_SHARED_PACKAGES_CACHE=$ORIGIN/../..") ); - } - else - OSL_ASSERT(0); + + buf.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN=")); + OUString sOrigin = makeRcTerm(m_cachePath); + ::rtl::OString osOrigin = ::rtl::OUStringToOString(sOrigin, RTL_TEXTENCODING_UTF8); + buf.append(osOrigin); buf.append(LF); if (! m_jar_typelibs.empty()) @@ -852,6 +877,9 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) // write native rc: ::rtl::OStringBuffer buf2; + buf2.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN=")); + buf2.append(osOrigin); + buf2.append(LF); buf2.append( RTL_CONSTASCII_STRINGPARAM("UNO_SERVICES=?$ORIGIN/") ); buf2.append( ::rtl::OUStringToOString( sNativeRDB, RTL_TEXTENCODING_ASCII_US ) ); @@ -886,7 +914,7 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) inline OUString makeRcTerm( OUString const & url ) { OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( - "vnd.sun.star.expand:") ) ); + "vnd.sun.star.expand:") ) ); if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) { // cut protocol: OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); @@ -1186,6 +1214,8 @@ void BackendImpl::ComponentPackageImpl::processPackage_( bool isJavaTypelib = java && !jarManifestHeaderPresent( url, OUSTR("UNO-Type-Path"), xCmdEnv ); + ComponentBackendDb::Data data; + data.javaTypeLibrary = isJavaTypelib; if (doRegisterPackage) { if (! m_xRemoteContext.is()) { @@ -1210,12 +1240,17 @@ void BackendImpl::ComponentPackageImpl::processPackage_( //only write to unorc if registration was successful. //It may fail if there is no suitable java. if (isJavaTypelib) + { that->addToUnoRc( java, url, xCmdEnv ); + data.javaTypeLibrary = true; + } t_stringlist implNames; t_stringpairvec singletons; - const Reference xLoader( + const Reference xLoader( getComponentInfo( &implNames, &singletons, m_xRemoteContext ) ); + data.implementationNames = implNames; + data.singletons = singletons; // factories live insertion: const Reference xSet( @@ -1280,6 +1315,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_( } m_registered = REG_REGISTERED; + getMyBackend()->addDataToDb(url, data); } else // revokePackage() { @@ -1364,6 +1400,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_( } m_registered = REG_NOT_REGISTERED; + getMyBackend()->deleteDataFromDb(url); } } @@ -1490,7 +1527,7 @@ namespace sdecl = comphelper::service_decl; sdecl::class_ > serviceBI; extern sdecl::ServiceDecl const serviceDecl( serviceBI, - "com.sun.star.comp.deployment.component.PackageRegistryBackend", + IMPLEMENTATION_NAME, BACKEND_SERVICE_NAME ); } // namespace component diff --git a/desktop/source/deployment/registry/component/makefile.mk b/desktop/source/deployment/registry/component/makefile.mk index 4c4016f9bf6c..b7ee5c203cd5 100644 --- a/desktop/source/deployment/registry/component/makefile.mk +++ b/desktop/source/deployment/registry/component/makefile.mk @@ -40,7 +40,8 @@ SRC1FILES = \ INCPRE += ..$/..$/inc SLOFILES = \ - $(SLO)$/dp_component.obj + $(SLO)$/dp_component.obj \ + $(SLO)$/dp_compbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 460ba5e9fed0..7118e6d1b2d5 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -94,9 +94,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool isSchema ) + bool isSchema, bool bUseDb) : Package( myBackend, url, name, name /* display-name */, - xPackageType ), + xPackageType, bUseDb), m_isSchema( isSchema ) {} }; @@ -113,7 +113,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, Reference const & xCmdEnv ); ::std::auto_ptr m_registeredPackages; @@ -199,7 +199,7 @@ BackendImpl::BackendImpl( m_registeredPackages.reset( new PersistentMap( makeURL( getCachePath(), OUSTR("registered_packages.db") ), - m_readOnly ) ); + false ) ); } } @@ -215,6 +215,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -255,14 +256,14 @@ Reference BackendImpl::bindPackage_( return new PackageImpl( this, url, ucbContent.getPropertyValue( StrTitle::get() ).get(), - m_xConfDataTypeInfo, false /* data file */ ); + m_xConfDataTypeInfo, false /* data file */, bNoFileAccess); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.configuration-schema")) { return new PackageImpl( this, url, ucbContent.getPropertyValue( StrTitle::get() ).get(), - m_xConfSchemaTypeInfo, true /* schema file */ ); + m_xConfSchemaTypeInfo, true /* schema file */, bNoFileAccess); } } } diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index c06b30be1669..31bb30de7315 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -88,6 +88,10 @@ PackageRegistryBackend::PackageRegistryBackend( m_eContext = CONTEXT_USER; else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) m_eContext = CONTEXT_SHARED; + else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") )) + m_eContext = CONTEXT_BUNDLED; + else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) + m_eContext = CONTEXT_TMP; else if (m_context.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") )) m_eContext = CONTEXT_DOCUMENT; @@ -127,24 +131,29 @@ void PackageRegistryBackend::disposing() // XPackageRegistry //______________________________________________________________________________ Reference PackageRegistryBackend::bindPackage( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess , Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException) { ::osl::ResettableMutexGuard guard( getMutex() ); check(); - t_string2ref::const_iterator const iFind( m_bound.find( url ) ); - if (iFind != m_bound.end()) { - Reference xPackage( iFind->second ); - if (xPackage.is()) - return xPackage; + if (!bNoFileAccess) + { + //We only save those object which were created with bNoFileAccess = false + t_string2ref::const_iterator const iFind( m_bound.find( url ) ); + if (iFind != m_bound.end()) + { + Reference xPackage( iFind->second ); + if (xPackage.is()) + return xPackage; + } } guard.clear(); Reference xNewPackage; try { - xNewPackage = bindPackage_( url, mediaType, xCmdEnv ); + xNewPackage = bindPackage_( url, mediaType, bNoFileAccess, xCmdEnv ); } catch (RuntimeException &) { throw; @@ -166,19 +175,23 @@ Reference PackageRegistryBackend::bindPackage( } guard.reset(); - ::std::pair< t_string2ref::iterator, bool > insertion( - m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) ); - if (insertion.second) - { // first insertion - OSL_ASSERT( Reference(insertion.first->second) - == xNewPackage ); - } - else - { // found existing entry - Reference xPackage( insertion.first->second ); - if (xPackage.is()) - return xPackage; - insertion.first->second = xNewPackage; + if (!bNoFileAccess) + { + //We only save those object which were created with bNoFileAccess = false + ::std::pair< t_string2ref::iterator, bool > insertion( + m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) ); + if (insertion.second) + { // first insertion + OSL_ASSERT( Reference(insertion.first->second) + == xNewPackage ); + } + else + { // found existing entry + Reference xPackage( insertion.first->second ); + if (xPackage.is()) + return xPackage; + insertion.first->second = xNewPackage; + } } guard.clear(); xNewPackage->addEventListener( this ); // listen for disposing events @@ -197,13 +210,15 @@ Package::Package( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, OUString const & displayName, - Reference const & xPackageType ) + Reference const & xPackageType, + bool bUseDb) : t_PackageBase( getMutex() ), m_myBackend( myBackend ), m_url( url ), m_name( name ), m_displayName( displayName ), - m_xPackageType( xPackageType ) + m_xPackageType( xPackageType ), + m_bUseDb(bUseDb) { } @@ -542,7 +557,29 @@ void Package::revokePackage( lang::IllegalArgumentException, RuntimeException) { processPackage_impl( false /* revoke */, xAbortChannel, xCmdEnv ); + +} + +PackageRegistryBackend * Package::getMyBackend() const +{ + PackageRegistryBackend * pBackend = m_myBackend.get(); + if (NULL == pBackend) + { + //May throw a DisposedException + check(); + //We should never get here... + throw RuntimeException( + OUSTR("Failed to get the BackendImpl"), + static_cast(const_cast(this))); + } + return pBackend; } +OUString Package::getRepositoryName() + throw (RuntimeException) +{ + PackageRegistryBackend * backEnd = getMyBackend(); + return backEnd->getContext(); + } //############################################################################## diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx new file mode 100644 index 000000000000..fb0b99c3363c --- /dev/null +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -0,0 +1,332 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/strbuf.hxx" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "osl/file.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "com/sun/star/io/XActiveDataSource.hpp" +#include "com/sun/star/io/XActiveDataControl.hpp" +#include "dp_ucb.h" +#include "dp_misc.h" +#include "ucbhelper/content.hxx" +#include "xmlscript/xml_helper.hxx" +#include "dp_backenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + + +namespace dp_registry { +namespace backend { + +BackendDb::BackendDb( + Reference const & xContext, + ::rtl::OUString const & url): + m_xContext(xContext) +{ + m_urlDb = dp_misc::expandUnoRcUrl(url); +} + +void BackendDb::save() +{ + Reference xDataSource(m_doc,css::uno::UNO_QUERY_THROW); + ::rtl::ByteSequence bytes; + xDataSource->setOutputStream(::xmlscript::createOutputStream(&bytes)); + Reference xDataControl(m_doc,css::uno::UNO_QUERY_THROW); + xDataControl->start(); + + Reference xData( + ::xmlscript::createInputStream(bytes)); + ::ucbhelper::Content ucbDb(m_urlDb, 0); + ucbDb.writeStream(xData, true /*replace existing*/); +} + +css::uno::Reference BackendDb::getDocument() +{ + if (!m_doc.is()) + { + Reference xDocBuilder( + m_xContext->getServiceManager()->createInstanceWithContext( + OUSTR("com.sun.star.xml.dom.DocumentBuilder"), + m_xContext ), css::uno::UNO_QUERY); + if (!xDocBuilder.is()) + throw css::uno::RuntimeException( + OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0); + + ::osl::DirectoryItem item; + ::osl::File::RC err = ::osl::DirectoryItem::get(m_urlDb, item); + if (err == ::osl::File::E_None) + { + m_doc = xDocBuilder->parseURI(m_urlDb); + } + else if (err == ::osl::File::E_NOENT) + { + //Create a new document and insert some basic stuff + m_doc = xDocBuilder->newDocument(); + Reference rootNode = + m_doc->createElement(getRootElementName()); + rootNode->setAttribute( + OUSTR("xmlns"), getDbNSName()); + m_doc->appendChild(Reference( + rootNode, UNO_QUERY_THROW)); + save(); + } + else + throw css::uno::RuntimeException( + OUSTR("Extension manager could not access database file:" ) + + m_urlDb, 0); + + if (!m_doc.is()) + throw css::uno::RuntimeException( + OUSTR("Extension manager could not get root node of data base file: ") + + m_urlDb, 0); + } + + return m_doc; +} + +Reference BackendDb::getXPathAPI() +{ + if (!m_xpathApi.is()) + { + m_xpathApi = Reference< css::xml::xpath::XXPathAPI >( + m_xContext->getServiceManager()->createInstanceWithContext( + OUSTR("com.sun.star.xml.xpath.XPathAPI"), + m_xContext), css::uno::UNO_QUERY); + + if (!m_xpathApi.is()) + throw css::uno::RuntimeException( + OUSTR(" Could not create service com.sun.star.xml.xpath.XPathAPI"), 0); + + m_xpathApi->registerNS( + OUSTR("reg"), getDbNSName()); + } + + return m_xpathApi; +} + +// OUString BackendDb::getDbNSName() +// { +// return OUString(); +// } + + +// OUString BackendDb::getRootElementName() +// { +// return OUString(); +// } + +void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) +{ + try + { + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sXPathExpression); + OSL_ASSERT(aNode.is()); + if (aNode.is()) + { + root->removeChild(aNode); + save(); + } + +#if OSL_DEBUG_LEVEL > 0 + //There must not be any other entry with the same url + Reference nextNode = + xpathApi->selectSingleNode(root, sXPathExpression); + OSL_ASSERT(! nextNode.is()); +#endif + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } + +} + +void BackendDb::writeVectorOfPair( + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > const & vecPairs, + OUString const & sVectorTagName, + OUString const & sPairTagName, + OUString const & sFirstTagName, + OUString const & sSecondTagName, + css::uno::Reference const & xParent) +{ + try{ + + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference vectorNode( + doc->createElement(sVectorTagName)); + + xParent->appendChild( + Reference( + vectorNode, css::uno::UNO_QUERY_THROW)); + typedef ::std::vector< ::std::pair< OUString, OUString > >::const_iterator CIT; + for (CIT i = vecPairs.begin(); i != vecPairs.end(); i++) + { + Reference pairNode( + doc->createElement(sPairTagName)); + + vectorNode->appendChild( + Reference( + pairNode, css::uno::UNO_QUERY_THROW)); + + Reference firstNode( + doc->createElement(sFirstTagName)); + + pairNode->appendChild( + Reference( + firstNode, css::uno::UNO_QUERY_THROW)); + + Reference firstTextNode( + doc->createTextNode( i->first)); + + firstNode->appendChild( + Reference( + firstTextNode, css::uno::UNO_QUERY_THROW)); + + Reference secondNode( + doc->createElement(sSecondTagName)); + + pairNode->appendChild( + Reference( + secondNode, css::uno::UNO_QUERY_THROW)); + + Reference secondTextNode( + doc->createTextNode( i->second)); + + secondNode->appendChild( + Reference( + secondTextNode, css::uno::UNO_QUERY_THROW)); + } + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +::std::vector< ::std::pair< OUString, OUString > > +BackendDb::readVectorOfPair( + Reference const & parent, + OUString const & sListTagName, + OUString const & sPairTagName, + OUString const & sFirstTagName, + OUString const & sSecondTagName) +{ + OSL_ASSERT(parent.is()); + Reference xpathApi = getXPathAPI(); + OUString sExprPairs( + sListTagName + OUSTR("/") + sPairTagName); + Reference listPairs = + xpathApi->selectNodeList(parent, sExprPairs); + + ::std::vector< ::std::pair< OUString, OUString > > retVector; + sal_Int32 length = listPairs->getLength(); + for (sal_Int32 i = 0; i < length; i++) + { + Reference aPair = listPairs->item(i); + OUString sExprFirst(sFirstTagName + OUSTR("/text()")); + Reference first = + xpathApi->selectSingleNode(aPair, sExprFirst); + + OUString sExprSecond(sSecondTagName + OUSTR("/text()")); + Reference second = + xpathApi->selectSingleNode(aPair, sExprSecond); + OSL_ASSERT(first.is() && second.is()); + + retVector.push_back(::std::make_pair( + first->getNodeValue(), second->getNodeValue())); + } + return retVector; +} + +void BackendDb::writeSimpleList( + ::std::list< ::rtl::OUString> const & list, + OUString const & sListTagName, + OUString const & sMemberTagName, + Reference const & xParent) +{ + try + { + Reference doc = getDocument(); + + Reference listNode( + doc->createElement(sListTagName)); + + xParent->appendChild( + Reference( + listNode, css::uno::UNO_QUERY_THROW)); + + typedef ::std::list::const_iterator ITC_ITEMS; + for (ITC_ITEMS i = list.begin(); i != list.end(); i++) + { + Reference memberNode( + doc->createElement(sMemberTagName), css::uno::UNO_QUERY_THROW); + + listNode->appendChild(memberNode); + + Reference textNode( + doc->createTextNode( *i), css::uno::UNO_QUERY_THROW); + + memberNode->appendChild(textNode); + } + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } + +} + +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index c56131a1015c..9ea13ad2c91f 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -126,7 +126,7 @@ public: // XPackageRegistry virtual Reference SAL_CALL bindPackage( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException); @@ -361,9 +361,24 @@ Reference PackageRegistryImpl::create( // Always register as last, because we want to add extensions also as folders // and as a default we accept every folder, which was not recognized by the other // backends. - that->insertBackend( + Reference extensionBackend = ::dp_registry::backend::bundle::create( - that, context, cachePath, readOnly, xComponentContext ) ); + that, context, cachePath, readOnly, xComponentContext); + that->insertBackend(extensionBackend); + + Reference xServiceInfo( + extensionBackend, UNO_QUERY_THROW ); + + OSL_ASSERT(xServiceInfo.is()); + OUString registryCachePath( + makeURL( cachePath, + ::rtl::Uri::encode( + xServiceInfo->getImplementationName(), + rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ) ); + create_folder( 0, registryCachePath, Reference()); + #if OSL_DEBUG_LEVEL > 1 // dump tables: @@ -443,7 +458,7 @@ void PackageRegistryImpl::update() throw (RuntimeException) // XPackageRegistry //______________________________________________________________________________ Reference PackageRegistryImpl::bindPackage( - OUString const & url, OUString const & mediaType_, + OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException) @@ -482,7 +497,7 @@ Reference PackageRegistryImpl::bindPackage( for ( ; iPos != iEnd; ++iPos ) { try { - return (*iPos)->bindPackage( url, mediaType, xCmdEnv ); + return (*iPos)->bindPackage( url, mediaType, bNoFileAccess, xCmdEnv ); } catch (lang::IllegalArgumentException &) { } @@ -511,7 +526,7 @@ Reference PackageRegistryImpl::bindPackage( getResourceString(RID_STR_UNSUPPORTED_MEDIA_TYPE) + mediaType, static_cast(this), static_cast(-1) ); } - return iFind->second->bindPackage( url, mediaType, xCmdEnv ); + return iFind->second->bindPackage( url, mediaType, bNoFileAccess, xCmdEnv ); } } diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index 8c95d5874b4c..a5fe1b99746f 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -72,9 +72,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend inline ExecutablePackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, - Reference const & xPackageType) + Reference const & xPackageType, bool bUseDb) : Package( myBackend, url, name, name /* display-name */, - xPackageType ) //, + xPackageType, bUseDb) //, {} }; friend class ExecutablePackageImpl; @@ -84,7 +84,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, Reference const & xCmdEnv ); Reference m_xExecutableTypeInfo; @@ -125,7 +125,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) // PackageRegistryBackend Reference BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { if (mediaType.getLength() == 0) @@ -147,7 +147,7 @@ Reference BackendImpl::bindPackage_( if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.executable")) { return new BackendImpl::ExecutablePackageImpl( - this, url, name, m_xExecutableTypeInfo); + this, url, name, m_xExecutableTypeInfo, bNoFileAccess); } } } diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 2b0d91250e4a..05ff8dda0e01 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -78,8 +78,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend inline PackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, - Reference const & xPackageType ) - : Package( myBackend, url, name, name, xPackageType ) + Reference const & xPackageType, + bool bUseDb) + : Package( myBackend, url, name, name, xPackageType, bUseDb) {} }; friend class PackageImpl; @@ -87,6 +88,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage ); @@ -138,6 +140,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { // we don't support auto detection: @@ -156,8 +159,10 @@ Reference BackendImpl::bindPackage_( if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.help")) { - return new PackageImpl( this, url, - ucbContent.getPropertyValue( StrTitle::get() ).get(), m_xHelpTypeInfo ); + return new PackageImpl( + this, url, + ucbContent.getPropertyValue( StrTitle::get() ).get(), + m_xHelpTypeInfo, bNoFileAccess); } } } diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index fe52c8ffc7e3..09b25caedc2b 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -62,6 +62,7 @@ typedef ::cppu::WeakComponentImplHelper1< //============================================================================== class Package : protected ::dp_misc::MutexHolder, public t_PackageBase { + PackageRegistryBackend * getMyBackend() const; void processPackage_impl( bool registerPackage, css::uno::Reference const & xAbortChannel, @@ -73,6 +74,7 @@ protected: ::rtl::OUString m_name; ::rtl::OUString m_displayName; const css::uno::Reference m_xPackageType; + const bool m_bUseDb; void check() const; void fireModified(); @@ -101,7 +103,8 @@ protected: ::rtl::OUString const & name, ::rtl::OUString const & displayName, css::uno::Reference const & - xPackageType ); + xPackageType, + bool bUseDb); public: @@ -233,6 +236,9 @@ public: css::uno::Reference const & xCmdEnv ) throw (css::ucb::CommandFailedException, css::ucb::CommandAbortedException, css::uno::RuntimeException); + + virtual ::rtl::OUString SAL_CALL getRepositoryName() + throw (css::uno::RuntimeException); }; typedef ::cppu::WeakComponentImplHelper2< @@ -243,7 +249,6 @@ typedef ::cppu::WeakComponentImplHelper2< class PackageRegistryBackend : protected ::dp_misc::MutexHolder, public t_BackendBase { - ::rtl::OUString m_cachePath; //The map held originally WeakReferences. The map entries are removed in the disposing //function, which is called when the XPackages are destructed or they are //explicitely disposed. The latter happens, for example, when a extension is @@ -257,13 +262,14 @@ class PackageRegistryBackend t_string2ref m_bound; protected: + ::rtl::OUString m_cachePath; css::uno::Reference m_xComponentContext; ::rtl::OUString m_context; // currently only for library containers: enum context { CONTEXT_UNKNOWN, - CONTEXT_USER, CONTEXT_SHARED, + CONTEXT_USER, CONTEXT_SHARED,CONTEXT_BUNDLED, CONTEXT_TMP, CONTEXT_DOCUMENT } m_eContext; bool m_readOnly; @@ -276,6 +282,7 @@ protected: // @@@ to be implemented by specific backend: virtual css::uno::Reference bindPackage_( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, + sal_Bool bNoFileAccess, css::uno::Reference const & xCmdEnv ) = 0; @@ -299,6 +306,8 @@ public: inline ::rtl::OUString const & getCachePath() const { return m_cachePath; } inline bool transientMode() const { return m_cachePath.getLength() == 0; } + inline ::rtl::OUString getContext() const {return m_context; } + // XEventListener virtual void SAL_CALL disposing( css::lang::EventObject const & evt ) throw (css::uno::RuntimeException); @@ -306,6 +315,7 @@ public: // XPackageRegistry virtual css::uno::Reference SAL_CALL bindPackage( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, + sal_Bool bNoFileAccess, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, css::ucb::CommandFailedException, diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx new file mode 100644 index 000000000000..3005ffcafb5b --- /dev/null +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_BACKENDDB_HXX +#define INCLUDED_DP_BACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { + +class BackendDb +{ +private: + + css::uno::Reference m_doc; + css::uno::Reference m_xpathApi; + + BackendDb(BackendDb const &); + BackendDb & operator = (BackendDb const &); + +protected: + const css::uno::Reference m_xContext; + ::rtl::OUString m_urlDb; + +protected: + + /* caller must make sure that only one thread accesses the function + */ + css::uno::Reference getDocument(); + + /* the namespace prefix is "reg" (without quotes) + */ + css::uno::Reference getXPathAPI(); + void save(); + void removeElement(::rtl::OUString const & sXPathExpression); + + void writeSimpleList( + ::std::list< ::rtl::OUString> const & list, + ::rtl::OUString const & sListTagName, + ::rtl::OUString const & sMemberTagName, + css::uno::Reference const & xParent); + + void writeVectorOfPair( + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > const & vecPairs, + ::rtl::OUString const & sVectorTagName, + ::rtl::OUString const & sPairTagName, + ::rtl::OUString const & sFirstTagName, + ::rtl::OUString const & sSecondTagName, + css::uno::Reference const & xParent); + + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > + readVectorOfPair( + css::uno::Reference const & parent, + ::rtl::OUString const & sListTagName, + ::rtl::OUString const & sPairTagName, + ::rtl::OUString const & sFirstTagName, + ::rtl::OUString const & sSecondTagName); + + + + /* returns the namespace which is to be written as xmlns attribute + into the root element. + */ + virtual ::rtl::OUString getDbNSName()=0; + /* returns the name of the root element without any namespace prefix. + */ + virtual ::rtl::OUString getRootElementName()=0; + + +public: + BackendDb(css::uno::Reference const & xContext, + ::rtl::OUString const & url); + virtual ~BackendDb() {}; + +}; + +} +} +#endif + diff --git a/desktop/source/deployment/registry/makefile.mk b/desktop/source/deployment/registry/makefile.mk index de0e943654d9..e45cec272ca7 100644 --- a/desktop/source/deployment/registry/makefile.mk +++ b/desktop/source/deployment/registry/makefile.mk @@ -41,7 +41,8 @@ INCPRE += inc SLOFILES = \ $(SLO)$/dp_backend.obj \ - $(SLO)$/dp_registry.obj + $(SLO)$/dp_registry.obj \ + $(SLO)$/dp_backenddb.obj .INCLUDE : ..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/package/dp_description.cxx b/desktop/source/deployment/registry/package/dp_description.cxx deleted file mode 100644 index 7c05bfd90a5b..000000000000 --- a/desktop/source/deployment/registry/package/dp_description.cxx +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_desktop.hxx" - -#include "dp_description.hxx" - -#include "cppuhelper/exc_hlp.hxx" -#include "ucbhelper/content.hxx" -#include "com/sun/star/deployment/DeploymentException.hpp" -#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/ucb/CommandFailedException.hpp" -#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp" -#include "com/sun/star/ucb/IOErrorCode.hpp" - -#include "com/sun/star/beans/PropertyValue.hpp" - - -#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) - -namespace css = com::sun::star; -namespace cssu = com::sun::star::uno; - -namespace dp_registry { -namespace backend { -namespace bundle { - -ExtensionDescription::ExtensionDescription( - const cssu::Reference& xContext, - const ::rtl::OUString& installDir, - const cssu::Reference< css::ucb::XCommandEnvironment >& xCmdEnv) -{ - try { - m_sExtensionRootUrl = installDir; - //may throw ::com::sun::star::ucb::ContentCreationException - //If there is no description.xml then ucb will start an interaction which - //brings up a dialog.We want to prevent this. Therefore we wrap the xCmdEnv - //and filter the respective exception out. - ::rtl::OUString sDescriptionUri(installDir + OUSTR("/description.xml")); - cssu::Reference xFilter = - static_cast( - new FileDoesNotExistFilter(xCmdEnv)); - ::ucbhelper::Content descContent(sDescriptionUri, xFilter); - - //throws an com::sun::star::uno::Exception if the file is not available - cssu::Reference xIn; - try - { //throws com.sun.star.ucb.InteractiveAugmentedIOException - xIn = descContent.openStream(); - } - catch (cssu::Exception& ) - { - if ( ! static_cast(xFilter.get())->exist()) - throw NoDescriptionException(); - throw; - } - if (!xIn.is()) - { - throw cssu::Exception( - OUSTR("Could not get XInputStream for description.xml of extension ") + - sDescriptionUri, 0); - } - - //get root node of description.xml - cssu::Reference xDocBuilder( - xContext->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.xml.dom.DocumentBuilder"), - xContext ), cssu::UNO_QUERY); - if (!xDocBuilder.is()) - throw css::uno::Exception(OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0); - - if (xDocBuilder->isNamespaceAware() == sal_False) - { - throw cssu::Exception( - OUSTR("Service com.sun.star.xml.dom.DocumentBuilder is not namespace aware."), 0); - } - - cssu::Reference xDoc = xDocBuilder->parse(xIn); - if (!xDoc.is()) - { - throw cssu::Exception(sDescriptionUri + OUSTR(" contains data which cannot be parsed. "), 0); - } - - //check for proper root element and namespace - cssu::Reference xRoot = xDoc->getDocumentElement(); - if (!xRoot.is()) - { - throw cssu::Exception( - sDescriptionUri + OUSTR(" contains no root element."), 0); - } - - if ( ! xRoot->getTagName().equals(OUSTR("description"))) - { - throw cssu::Exception( - sDescriptionUri + OUSTR(" does not contain the root element ."), 0); - } - - m_xRoot = cssu::Reference( - xRoot, cssu::UNO_QUERY_THROW); - ::rtl::OUString nsDescription = xRoot->getNamespaceURI(); - - //check if this namespace is supported - if ( ! nsDescription.equals(OUSTR("http://openoffice.org/extensions/description/2006"))) - { - throw cssu::Exception(sDescriptionUri + OUSTR(" contains a root element with an unsupported namespace. "), 0); - } - } catch (css::uno::RuntimeException &) { - throw; - } catch (css::deployment::DeploymentException &) { - throw; - } catch (css::uno::Exception & e) { - css::uno::Any a(cppu::getCaughtException()); - throw css::deployment::DeploymentException( - e.Message, css::uno::Reference< css::uno::XInterface >(), a); - } -} - -ExtensionDescription::~ExtensionDescription() -{ -} - -//====================================================================== -FileDoesNotExistFilter::FileDoesNotExistFilter( - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv): - m_bExist(true), m_xCommandEnv(xCmdEnv) -{} - -FileDoesNotExistFilter::~FileDoesNotExistFilter() -{ -}; - -bool FileDoesNotExistFilter::exist() -{ - return m_bExist; -} - // XCommandEnvironment -cssu::Reference - FileDoesNotExistFilter::getInteractionHandler() throw (css::uno::RuntimeException) -{ - return static_cast(this); -} - -cssu::Reference - FileDoesNotExistFilter::getProgressHandler() throw (css::uno::RuntimeException) -{ - return m_xCommandEnv.is() - ? m_xCommandEnv->getProgressHandler() - : cssu::Reference(); -} - -// XInteractionHandler -//If the interaction was caused by a non-existing file which is specified in the ctor -//of FileDoesNotExistFilter, then we do nothing -void FileDoesNotExistFilter::handle( - cssu::Reference const & xRequest ) - throw (css::uno::RuntimeException) -{ - cssu::Any request( xRequest->getRequest() ); - - css::ucb::InteractiveAugmentedIOException ioexc; - if ((request>>= ioexc) && ioexc.Code == css::ucb::IOErrorCode_NOT_EXISTING ) - { - m_bExist = false; - return; - } - css::uno::Reference xInteraction; - if (m_xCommandEnv.is()) { - xInteraction = m_xCommandEnv->getInteractionHandler(); - } - if (xInteraction.is()) { - xInteraction->handle(xRequest); - } -} - - -} // namespace bundle -} // namespace backend -} // namespace dp_registry - diff --git a/desktop/source/deployment/registry/package/dp_description.hxx b/desktop/source/deployment/registry/package/dp_description.hxx deleted file mode 100644 index eb74c454af75..000000000000 --- a/desktop/source/deployment/registry/package/dp_description.hxx +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#if !defined INCLUDED_DESKTOP_EXTENSION_DESCRIPTION_HXX -#define INCLUDED_DESKTOP_EXTENSION_DESCRIPTION_HXX - - - -#include "com/sun/star/uno/Reference.hxx" - -#include "com/sun/star/ucb/XCommandEnvironment.hpp" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/xml/dom/XNode.hpp" -#include "com/sun/star/task/XInteractionHandler.hpp" -#include "cppuhelper/implbase2.hxx" - - -namespace css = ::com::sun::star; - -namespace dp_registry { -namespace backend { -namespace bundle { - -/**The class uses the UCB to access the description.xml file in an - extension. The UCB must have been initialized already. It also - requires that the extension has already be unzipped to a particular - location. - */ -class ExtensionDescription -{ -public: - /**throws an exception if the description.xml is not - available, cannot be read, does not contain the expected data, - or any other error occured. Therefore it shoult only be used with - new extensions. - - Throws com::sun::star::uno::RuntimeException, - com::sun::star::deployment::DeploymentException, - dp_registry::backend::bundle::NoDescriptionException. - */ - ExtensionDescription( - const css::uno::Reference& xContext, - const ::rtl::OUString& installDir, - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv); - - ~ExtensionDescription(); - - css::uno::Reference getRootElement() const - { - return m_xRoot; - } - - ::rtl::OUString getExtensionRootUrl() const - { - return m_sExtensionRootUrl; - } - - -private: - css::uno::Reference m_xRoot; - ::rtl::OUString m_sExtensionRootUrl; -}; - -class NoDescriptionException -{ -}; - -class FileDoesNotExistFilter - : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment, - css::task::XInteractionHandler > - -{ - //css::uno::Reference m_xHandler; - bool m_bExist; - css::uno::Reference< css::ucb::XCommandEnvironment > m_xCommandEnv; - -public: - virtual ~FileDoesNotExistFilter(); - FileDoesNotExistFilter( - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv); - - bool exist(); - // XCommandEnvironment - virtual css::uno::Reference SAL_CALL - getInteractionHandler() throw (css::uno::RuntimeException); - virtual css::uno::Reference - SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); - - // XInteractionHandler - virtual void SAL_CALL handle( - css::uno::Reference const & xRequest ) - throw (css::uno::RuntimeException); -}; - - -} // namespace bundle -} // namespace backend -} // namespace dp_registry - - -#endif // INCLUDED_DESKTOP_LICENSE_INTERACT_HXX diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx new file mode 100644 index 000000000000..97cfc136049c --- /dev/null +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_extbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010" +#define ROOT_ELEMENT_NAME "extension-backend-db" + +// /extension-backend-db/extension +#define EXTENSION_ELEMENT "extension" + +// /extension-backend-db/extension/extension-items +#define EXTENSION_ITEMS "extension-items" + +// /extension-backend-db/extension/extension-items/item +#define EXTENSION_ITEMS_ITEM "item" + +// /extension-backend-db/extension/extension-items/item/url +#define ITEM_URL "url" + +// /extension-backend-db/extension/extension-items/item/media-type +#define ITEM_MEDIA_TYP "media-type" + + +namespace dp_registry { +namespace backend { +namespace bundle { + +ExtensionBackendDb::ExtensionBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString ExtensionBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ExtensionBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + // + Reference extensionNode( + doc->createElement(OUSTR("extension"))); + + extensionNode->setAttribute(OUSTR("url"), url); + + Reference extensionNodeNode( + extensionNode, css::uno::UNO_QUERY_THROW); + root->appendChild(extensionNodeNode); + + // ... + Reference identifierNode( + doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); + extensionNodeNode->appendChild(identifierNode); + + Reference identifierValue( + doc->createTextNode(data.identifier), UNO_QUERY_THROW); + identifierNode->appendChild(identifierValue); + + + writeVectorOfPair( + data.items, + OUSTR("extension-items"), + OUSTR("item"), + OUSTR("url"), + OUSTR("media-type"), + extensionNodeNode); + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +void ExtensionBackendDb::removeEntry(::rtl::OUString const & url) +{ + OUString sExpression( + OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + removeElement(sExpression); +} + +ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & url) +{ + ExtensionBackendDb::Data retData; + const OUString sExpression( + OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + OSL_ASSERT(aNode.is()); + + const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); + + Reference idValueNode = + xpathApi->selectSingleNode(aNode, sExprIdentifier); + retData.identifier = idValueNode->getNodeValue(); + + retData.items = + readVectorOfPair( + aNode, + OUSTR("reg:extension-items"), + OUSTR("reg:item"), OUSTR("reg:url"), OUSTR("reg:media-type")); + return retData; +} + +} // namespace bundle +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx new file mode 100644 index 000000000000..156e34155040 --- /dev/null +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#if ! defined INCLUDED_DP_EXTBACKENDDB_HXX +#define INCLUDED_DP_EXTBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { +namespace bundle { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + */ +class ExtensionBackendDb: public dp_registry::backend::BackendDb +{ +public: + struct Data + { + ::rtl::OUString identifier; + /* every element consists of a pair of the url to the item (jar,rdb, etc) + and the media type + */ + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString> > items; + typedef ::std::vector< + ::std::pair< ::rtl::OUString, ::rtl::OUString> >::const_iterator ITC_ITEMS; + + }; + +public: + + ExtensionBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url, Data const & data); + void removeEntry(::rtl::OUString const & url); + Data getEntry(::rtl::OUString const & url); + + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getRootElementName(); +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index b0b4a918c7a3..8fe7874f247f 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -34,7 +34,6 @@ #include "dp_interact.h" #include "dp_dependencies.hxx" #include "dp_platform.hxx" -#include "dp_description.hxx" #include "dp_descriptioninfoset.hxx" #include "dp_identifier.hxx" #include "rtl/uri.hxx" @@ -74,7 +73,7 @@ #include #include - +#include "dp_extbackenddb.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -106,6 +105,8 @@ class BackendImpl : public ImplBaseT Sequence< Reference > m_bundle; Sequence< Reference > * m_pBundle; + ExtensionBackendDb::Data m_data; + Reference bindBundleItem( OUString const & url, OUString const & mediaType, Reference const & xCmdEnv, @@ -122,20 +123,20 @@ class BackendImpl : public ImplBaseT ::rtl::Reference const & abortChannel, Reference const & xCmdEnv, bool skip_registration = false ); - + ::std::vector > getPackagesFromDb(); bool checkPlatform( css::uno::Reference< css::ucb::XCommandEnvironment > const & environment); bool checkDependencies( css::uno::Reference< css::ucb::XCommandEnvironment > const & environment, - ExtensionDescription const & description); + DescriptionInfoset const & description); // throws css::uno::RuntimeException, // css::deployment::DeploymentException ::sal_Bool checkLicense( css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, - ExtensionDescription const& description, bool bInstalled, + DescriptionInfoset const & description, bool bInstalled, OUString const & aContextName ) throw (css::deployment::DeploymentException, css::ucb::CommandFailedException, @@ -169,13 +170,8 @@ class BackendImpl : public ImplBaseT OUString const & url, OUString const & name, Reference const & xPackageType, - bool legacyBundle ) - : Package( myBackend, url, name, name /* display-name */, - xPackageType ), - m_url_expanded( expandUnoRcUrl( url ) ), - m_legacyBundle( legacyBundle ), - m_pBundle( 0 ) - {} + bool legacyBundle, + bool useDb); // XPackage virtual sal_Bool SAL_CALL isBundle() throw (RuntimeException); @@ -228,9 +224,16 @@ class BackendImpl : public ImplBaseT const Reference m_xLegacyBundleTypeInfo; Sequence< Reference > m_typeInfos; + std::auto_ptr m_backendDb; + + void addDataToDb(OUString const & url, ExtensionBackendDb::Data const & data); + ExtensionBackendDb::Data readDataFromDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -291,6 +294,14 @@ BackendImpl::BackendImpl( { m_typeInfos[ 0 ] = m_xBundleTypeInfo; m_typeInfos[ 1 ] = m_xLegacyBundleTypeInfo; + + if (!transientMode()) + { + OUString dbFile = makeURL(getCachePath(), getImplementationName()); + dbFile = makeURL(dbFile, OUSTR("backenddb.xml")); + m_backendDb.reset( + new ExtensionBackendDb(getComponentContext(), dbFile)); + } } //______________________________________________________________________________ @@ -333,6 +344,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -381,19 +393,21 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + ::ucbhelper::Content ucbContent; + OUString name; + //In case a XPackage is created for a removed extension, we cannot + //obtain the name + if (create_ucb_content(&ucbContent, url, xCmdEnv, false )) + name = ucbContent.getPropertyValue( + StrTitle::get() ).get(); if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.package-bundle")) { return new PackageImpl( - this, url, ucbContent.getPropertyValue( - StrTitle::get() ).get(), - m_xBundleTypeInfo, false ); + this, url, name, m_xBundleTypeInfo, false, bNoFileAccess); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.legacy-package-bundle")) { return new PackageImpl( - this, url, ucbContent.getPropertyValue( - StrTitle::get() ).get(), - m_xLegacyBundleTypeInfo, true ); + this, url, name, m_xLegacyBundleTypeInfo, true, bNoFileAccess); } } } @@ -403,8 +417,48 @@ Reference BackendImpl::bindPackage_( static_cast(-1) ); } +void BackendImpl::addDataToDb( + OUString const & url, ExtensionBackendDb::Data const & data) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url, data); +} + +ExtensionBackendDb::Data BackendImpl::readDataFromDb( + OUString const & url) +{ + ExtensionBackendDb::Data data; + if (m_backendDb.get()) + data = m_backendDb->getEntry(url); + return data; +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + + //############################################################################## +BackendImpl::PackageImpl::PackageImpl( + ::rtl::Reference const & myBackend, + OUString const & url, + OUString const & name, + Reference const & xPackageType, + bool legacyBundle, + bool useDb) + : Package( myBackend, url, name, name /* display-name */, + xPackageType, useDb ), + m_url_expanded( expandUnoRcUrl( url ) ), + m_legacyBundle( legacyBundle ), + m_pBundle( 0 ) +{ + if (useDb) + m_data = getMyBackend()->readDataFromDb(url); +} + BackendImpl * BackendImpl::PackageImpl::getMyBackend() const { BackendImpl * pBackend = static_cast(m_myBackend.get()); @@ -510,23 +564,7 @@ OUString BackendImpl::PackageImpl::getTextFromURL( DescriptionInfoset BackendImpl::PackageImpl::getDescriptionInfoset() { - css::uno::Reference< css::xml::dom::XNode > root; - try { - root = - ExtensionDescription( - getMyBackend()->getComponentContext(), m_url_expanded, - css::uno::Reference< css::ucb::XCommandEnvironment >()). - getRootElement(); - } catch (NoDescriptionException &) { - } catch (css::deployment::DeploymentException & e) { - throw RuntimeException( - (OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.deployment.DeploymentException: ")) + - e.Message), - static_cast< OWeakObject * >(this)); - } - return DescriptionInfoset(getMyBackend()->getComponentContext(), root); + return dp_misc::getDescriptionInfoset(m_url_expanded); } bool BackendImpl::PackageImpl::checkPlatform( @@ -561,14 +599,11 @@ bool BackendImpl::PackageImpl::checkPlatform( bool BackendImpl::PackageImpl::checkDependencies( css::uno::Reference< css::ucb::XCommandEnvironment > const & environment, - ExtensionDescription const & description) + DescriptionInfoset const & description) { css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > - unsatisfied( - dp_misc::Dependencies::check( - DescriptionInfoset( - getMyBackend()->getComponentContext(), - description.getRootElement()))); + unsatisfied(dp_misc::Dependencies::check(description)); + if (unsatisfied.getLength() == 0) { return true; } else { @@ -590,7 +625,7 @@ bool BackendImpl::PackageImpl::checkDependencies( ::sal_Bool BackendImpl::PackageImpl::checkLicense( css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, - ExtensionDescription const & desc, bool bInstalled, OUString const & aContextName) + DescriptionInfoset const & info, bool bInstalled, OUString const & aContextName) throw (css::deployment::DeploymentException, css::ucb::CommandFailedException, css::ucb::CommandAbortedException, @@ -598,7 +633,6 @@ bool BackendImpl::PackageImpl::checkDependencies( { try { - DescriptionInfoset info = getDescriptionInfoset(); ::boost::optional simplLicAttr = info.getSimpleLicenseAttributes(); if (! simplLicAttr) @@ -610,7 +644,7 @@ bool BackendImpl::PackageImpl::checkDependencies( if (sLic.getLength() == 0) throw css::deployment::DeploymentException( OUSTR("Could not obtain path to license. Possible error in description.xml"), 0, Any()); - OUString sHref = desc.getExtensionRootUrl() + OUSTR("/") + sLic; + OUString sHref = m_url_expanded + OUSTR("/") + sLic; OUString sLicense = getTextFromURL(xCmdEnv, sHref); ////determine who has to agree to the license //check correct value for attribute @@ -693,19 +727,13 @@ bool BackendImpl::PackageImpl::checkDependencies( css::ucb::CommandAbortedException, css::uno::RuntimeException) { - std::auto_ptr spDescription; - try { - spDescription.reset( - new ExtensionDescription( - getMyBackend()->getComponentContext(), - m_url_expanded, - xCmdEnv)); - } catch (NoDescriptionException& ) { + DescriptionInfoset info = getDescriptionInfoset(); + if (!info.hasDescription()) return sal_True; - } + return checkPlatform(xCmdEnv) - && checkDependencies(xCmdEnv, *spDescription) - && checkLicense(xCmdEnv, *spDescription, bInstalled, aContextName); + && checkDependencies(xCmdEnv, info) + && checkLicense(xCmdEnv, info, bInstalled, aContextName); } ::sal_Bool BackendImpl::PackageImpl::checkDependencies( @@ -714,23 +742,25 @@ bool BackendImpl::PackageImpl::checkDependencies( css::ucb::CommandFailedException, css::uno::RuntimeException) { - std::auto_ptr spDescription; - try { - spDescription.reset( - new ExtensionDescription( getMyBackend()->getComponentContext(), m_url_expanded, xCmdEnv )); - } catch (NoDescriptionException& ) { + DescriptionInfoset info = getDescriptionInfoset(); + if (!info.hasDescription()) return sal_True; - } - return checkDependencies(xCmdEnv, *spDescription); + + return checkDependencies(xCmdEnv, info); } beans::Optional BackendImpl::PackageImpl::getIdentifier() throw (RuntimeException) { + OUString identifier; + if (m_bUseDb) + identifier = m_data.identifier; + else + identifier = dp_misc::generateIdentifier( + getDescriptionInfoset().getIdentifier(), m_name); + return beans::Optional( - true, - dp_misc::generateIdentifier( - getDescriptionInfoset().getIdentifier(), m_name)); + true, identifier); } OUString BackendImpl::PackageImpl::getVersion() throw (RuntimeException) @@ -793,6 +823,7 @@ void BackendImpl::PackageImpl::processPackage_( if (doRegisterPackage) { + ExtensionBackendDb::Data data; const sal_Int32 len = bundle.getLength(); for ( sal_Int32 pos = 0; pos < len; ++pos ) { @@ -870,7 +901,12 @@ void BackendImpl::PackageImpl::processPackage_( ::cppu::throwException(exc); } } + data.items.push_back( + ::std::make_pair(xPackage->getURL(), + xPackage->getPackageType()->getMediaType())); } + data.identifier = getIdentifier().Value; + getMyBackend()->addDataToDb(getURL(), data); } else { @@ -914,6 +950,7 @@ void BackendImpl::PackageImpl::processPackage_( // selected } } + getMyBackend()->deleteDataFromDb(getURL()); } } @@ -1139,58 +1176,66 @@ Sequence< Reference > BackendImpl::PackageImpl::getBundle( if (pBundle == 0) { t_packagevec bundle; - try { - if (m_legacyBundle) - { - // .zip legacy packages allow script.xlb, dialog.xlb in bundle - // root folder: - OUString mediaType; - // probe for script.xlb: - if (create_ucb_content( - 0, makeURL( m_url_expanded, OUSTR("script.xlb") ), - xCmdEnv, false /* no throw */ )) { - mediaType = OUSTR("application/vnd.sun.star.basic-library"); + if (m_bUseDb) + { + bundle = getPackagesFromDb(); + } + else + { + try { + if (m_legacyBundle) + { + // .zip legacy packages allow script.xlb, dialog.xlb in bundle + // root folder: + OUString mediaType; + // probe for script.xlb: + if (create_ucb_content( + 0, makeURL( m_url_expanded, OUSTR("script.xlb") ), + xCmdEnv, false /* no throw */ )) { + mediaType = OUSTR("application/vnd.sun.star.basic-library"); + } + // probe for dialog.xlb: + else if (create_ucb_content( + 0, makeURL( m_url_expanded, OUSTR("dialog.xlb") ), + xCmdEnv, false /* no throw */ )) + mediaType = OUSTR("application/vnd.sun.star." + "dialog-library"); + + if (mediaType.getLength() > 0) { + const Reference xPackage( + bindBundleItem( getURL(), mediaType, xCmdEnv ) ); + if (xPackage.is()) + bundle.push_back( xPackage ); + // continue scanning: + } + scanLegacyBundle( bundle, getURL(), + AbortChannel::get(xAbortChannel), xCmdEnv ); } - // probe for dialog.xlb: - else if (create_ucb_content( - 0, makeURL( m_url_expanded, OUSTR("dialog.xlb") ), - xCmdEnv, false /* no throw */ )) - mediaType = OUSTR("application/vnd.sun.star." - "dialog-library"); - - if (mediaType.getLength() > 0) { - const Reference xPackage( - bindBundleItem( getURL(), mediaType, xCmdEnv ) ); - if (xPackage.is()) - bundle.push_back( xPackage ); - // continue scanning: + else + { + // .oxt: + scanBundle( bundle, AbortChannel::get(xAbortChannel), xCmdEnv ); } - scanLegacyBundle( bundle, getURL(), - AbortChannel::get(xAbortChannel), xCmdEnv ); + } - else - { - // .oxt: - scanBundle( bundle, AbortChannel::get(xAbortChannel), xCmdEnv ); + catch (RuntimeException &) { + throw; + } + catch (CommandFailedException &) { + throw; + } + catch (CommandAbortedException &) { + throw; + } + catch (deployment::DeploymentException &) { + throw; + } + catch (Exception &) { + Any exc( ::cppu::getCaughtException() ); + throw deployment::DeploymentException( + OUSTR("error scanning bundle: ") + getURL(), + static_cast(this), exc ); } - } - catch (RuntimeException &) { - throw; - } - catch (CommandFailedException &) { - throw; - } - catch (CommandAbortedException &) { - throw; - } - catch (deployment::DeploymentException &) { - throw; - } - catch (Exception &) { - Any exc( ::cppu::getCaughtException() ); - throw deployment::DeploymentException( - OUSTR("error scanning bundle: ") + getURL(), - static_cast(this), exc ); } // sort: schema before config data, typelibs before components: @@ -1267,7 +1312,7 @@ Reference BackendImpl::PackageImpl::bindBundleItem( ReferencexPackage; try { xPackage.set( getMyBackend()->m_xRootRegistry->bindPackage( - url, mediaType, xCmdEnv ) ); + url, mediaType, false, xCmdEnv ) ); OSL_ASSERT( xPackage.is() ); } catch (RuntimeException &) { @@ -1523,6 +1568,13 @@ OUString BackendImpl::PackageImpl::getDisplayName() throw (RuntimeException) return sName; } +::std::vector > BackendImpl::PackageImpl::getPackagesFromDb() +{ + //get the data base entry for this extension + + return ::std::vector >(); +} + } // anon namespace //============================================================================== diff --git a/desktop/source/deployment/registry/package/makefile.mk b/desktop/source/deployment/registry/package/makefile.mk index ccadc2070301..203ce176d289 100644 --- a/desktop/source/deployment/registry/package/makefile.mk +++ b/desktop/source/deployment/registry/package/makefile.mk @@ -41,7 +41,7 @@ INCPRE += ..$/..$/inc SLOFILES = \ $(SLO)$/dp_package.obj \ - $(SLO)$/dp_description.obj + $(SLO)$/dp_extbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 4af0cbb84130..6d503d33d51d 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -88,13 +88,15 @@ class BackendImpl : public t_helper ::rtl::Reference const & myBackend, OUString const & url, Reference const &xCmdEnv, - OUString const & scriptURL, OUString const & dialogURL ); + OUString const & scriptURL, OUString const & dialogURL, + bool bUseDb); }; friend class PackageImpl; // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); @@ -123,11 +125,11 @@ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference const & myBackend, OUString const & url, Reference const &xCmdEnv, - OUString const & scriptURL, OUString const & dialogURL ) + OUString const & scriptURL, OUString const & dialogURL, bool bUseDb ) : Package( myBackend.get(), url, OUString(), OUString(), // will be late-initialized scriptURL.getLength() > 0 ? myBackend->m_xBasicLibTypeInfo - : myBackend->m_xDialogLibTypeInfo ), + : myBackend->m_xDialogLibTypeInfo, bUseDb), m_scriptURL( scriptURL ), m_dialogURL( dialogURL ) { @@ -189,6 +191,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -231,13 +234,15 @@ Reference BackendImpl::bindPackage_( } return new PackageImpl( this, url, xCmdEnv, makeURL( url, OUSTR("script.xlb") ), - dialogURL ); + dialogURL, bNoFileAccess); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.dialog-library")) { - return new PackageImpl( this, url, xCmdEnv, - OUString() /* no script lib */, - makeURL( url, OUSTR("dialog.xlb") ) ); + return new PackageImpl( + this, url, xCmdEnv, + OUString() /* no script lib */, + makeURL( url, OUSTR("dialog.xlb") ), + bNoFileAccess); } } } diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index 52ced6908bd8..47b6430f1a1e 100644 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -81,8 +81,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv ); public: - PackageImpl( ::rtl::Reference const & myBackend, - OUString const & url, OUString const & libType ); + PackageImpl( + ::rtl::Reference const & myBackend, + OUString const & url, OUString const & libType, bool bUseDb); // XPackage virtual OUString SAL_CALL getDescription() throw (RuntimeException); }; @@ -91,6 +92,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); const Reference m_xTypeInfo; @@ -131,9 +133,9 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) //______________________________________________________________________________ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference const & myBackend, - OUString const & url, OUString const & libType ) + OUString const & url, OUString const & libType, bool bUseDb) : Package( myBackend.get(), url, OUString(), OUString(), - myBackend->m_xTypeInfo ), + myBackend->m_xTypeInfo, bUseDb ), m_descr(libType) { initPackageHandler(); @@ -217,7 +219,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) // PackageRegistryBackend //______________________________________________________________________________ Reference BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType_, + OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -294,7 +296,7 @@ Reference BackendImpl::bindPackage_( dp_misc::TRACE(OUSTR(" BackEnd detected lang = ") + lang + OUSTR("\n")); dp_misc::TRACE(OUSTR(" for url ") + sParcelDescURL + OUSTR("\n") ); dp_misc::TRACE("******************************\n"); - return new PackageImpl( this, url, sfwkLibType ); + return new PackageImpl( this, url, sfwkLibType, bNoFileAccess); } } } @@ -322,6 +324,10 @@ void BackendImpl::PackageImpl:: initPackageHandler() { aContext <<= OUSTR("share"); } + else if ( that->m_eContext == CONTEXT_BUNDLED ) + { + aContext <<= OUSTR("bundled"); + } else { OSL_ASSERT( 0 ); diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 2acd4f79a781..807260fe4663 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -41,7 +41,8 @@ #include "cppuhelper/implbase1.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/anytostring.hxx" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" + #include "com/sun/star/deployment/ui/PackageManagerDialog.hpp" #include "com/sun/star/ui/dialogs/XExecutableDialog.hpp" #include "com/sun/star/lang/DisposedException.hpp" @@ -149,12 +150,13 @@ void DialogClosedListenerImpl::dialogClosed( // installed with OOo 2.2 or later could not normally be found via its file // name. Reference findPackage( - Reference const & manager, + OUString const & repository, + Reference const & manager, Reference const & environment, OUString const & idOrFileName ) { Sequence< Reference > ps( - manager->getDeployedPackages( + manager->getDeployedExtensions(repository, Reference(), environment ) ); for ( sal_Int32 i = 0; i < ps.getLength(); ++i ) if ( dp_misc::getIdentifier( ps[i] ) == idOrFileName ) @@ -214,7 +216,7 @@ extern "C" int unopkg_main() bool subcmd_add = false; bool subcmd_gui = false; OUString logFile; - OUString deploymentContext; + OUString repository; OUString cmdArg; ::std::vector cmdPackages; @@ -279,7 +281,7 @@ extern "C" int unopkg_main() !readOption( &option_force, info_force, &nPos ) && !readOption( &option_bundled, info_bundled, &nPos ) && !readOption( &option_suppressLicense, info_suppressLicense, &nPos ) && - !readArgument( &deploymentContext, info_context, &nPos ) && + !readArgument( &repository, info_context, &nPos ) && !isBootstrapVariable(&nPos)) { osl_getCommandArg( nPos, &cmdArg.pData ); @@ -313,24 +315,30 @@ extern "C" int unopkg_main() } //make sure the bundled option was provided together with shared - if (option_bundled && !option_shared) - { - dp_misc::writeConsoleError( - "\nERROR: option --bundled can only be used together with --shared!"); - return 1; - } +// if (option_bundled && !option_shared) +// { +// dp_misc::writeConsoleError( +// "\nERROR: option --bundled can only be used together with --shared!"); +// return 1; +// } xComponentContext = getUNO( disposeGuard, option_verbose, option_shared, subcmd_gui, xLocalComponentContext ); - if (deploymentContext.getLength() == 0) { - deploymentContext = option_shared ? OUSTR("shared") : OUSTR("user"); + if (repository.getLength() == 0) + { + if (option_shared) + repository = OUSTR("shared"); + else if (option_bundled) + repository = OUSTR("bundled"); + else + repository = OUSTR("user"); } else { - if (deploymentContext.equalsAsciiL( + if (repository.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) { option_shared = true; } @@ -343,10 +351,9 @@ extern "C" int unopkg_main() } } - Reference xPackageManagerFactory( - deployment::thePackageManagerFactory::get( xComponentContext ) ); - Reference xPackageManager( - xPackageManagerFactory->getPackageManager( deploymentContext ) ); + + Reference xExtensionManager( + deployment::ExtensionManager::get( xComponentContext ) ); Reference< ::com::sun::star::ucb::XCommandEnvironment > xCmdEnv( createCmdEnv( xComponentContext, logFile, @@ -362,25 +369,23 @@ extern "C" int unopkg_main() OUString const & cmdPackage = cmdPackages[ pos ]; if (subcmd_add) { - Reference xPackage( - xPackageManager->addPackage( - cmdPackage, OUString() /* to be detected */, - Reference(), xCmdEnv ) ); - OSL_ASSERT( xPackage.is() ); + xExtensionManager->addExtension( + cmdPackage, repository, + Reference(), xCmdEnv); } else { try { - xPackageManager->removePackage( - cmdPackage, cmdPackage, + xExtensionManager->removeExtension( + cmdPackage, cmdPackage, repository, Reference(), xCmdEnv ); } catch (lang::IllegalArgumentException &) { Reference p( - findPackage( - xPackageManager, xCmdEnv, cmdPackage ) ); + findPackage(repository, + xExtensionManager, xCmdEnv, cmdPackage ) ); //Todo. temporary preventing exception in bundled case. //In case of a bundled extension, remove would be called as a result of //uninstalling a rpm. Then we do not want to show an error when the @@ -389,8 +394,9 @@ extern "C" int unopkg_main() if ( !p.is() && !option_bundled) throw; else if (p.is()) - xPackageManager->removePackage( + xExtensionManager->removeExtension( ::dp_misc::getIdentifier(p), p->getName(), + repository, Reference(), xCmdEnv ); } } @@ -399,18 +405,18 @@ extern "C" int unopkg_main() else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reinstall") )) { - xPackageManager->reinstallDeployedPackages( - Reference(), xCmdEnv ); + xExtensionManager->reinstallDeployedExtensions( + repository, Reference(), xCmdEnv); } else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("list") )) { Sequence< Reference > packages; if (cmdPackages.empty()) { - packages = xPackageManager->getDeployedPackages( - Reference(), xCmdEnv ); + packages = xExtensionManager->getDeployedExtensions( + repository, Reference(), xCmdEnv ); dp_misc::writeConsole( - OUSTR("all deployed ") + deploymentContext + OUSTR(" packages:\n")); + OUSTR("all deployed ") + repository + OUSTR(" packages:\n")); } else { @@ -418,13 +424,13 @@ extern "C" int unopkg_main() for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos ) try { - packages[ pos ] = xPackageManager->getDeployedPackage( - cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv ); + packages[ pos ] = xExtensionManager->getDeployedExtension( + repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv ); } catch (lang::IllegalArgumentException &) { - packages[ pos ] = findPackage( - xPackageManager, xCmdEnv, cmdPackages[ pos ] ); + packages[ pos ] = findPackage(repository, + xExtensionManager, xCmdEnv, cmdPackages[ pos ] ); if ( !packages[ pos ].is() ) throw; } diff --git a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx index e4a503d98732..d23dcbf9577d 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx @@ -320,7 +320,7 @@ void CommandEnvironmentImpl::handle( deployment::VersionException nc_exc; if (request >>= nc_exc) { approve = m_option_force_overwrite || - (::dp_misc::comparePackageVersions(nc_exc.New, nc_exc.Deployed) + (::dp_misc::compareVersions(nc_exc.NewVersion, nc_exc.Deployed->getVersion()) == ::dp_misc::GREATER); abort = !approve; } -- cgit From d8411c3281b10eeea679e84697adfcd7c51b1657 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 19 Mar 2010 15:12:00 +0100 Subject: jl152 import 263439 from native0jl: #i77196# fix for XExtensionManager.getAllExtensions --- desktop/source/deployment/manager/dp_extensionmanager.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 469245bef340..1519e1f40596 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -936,7 +936,6 @@ uno::Sequence< uno::Sequence > > lang::IllegalArgumentException, uno::RuntimeException) { - uno::Sequence< uno::Sequence > > seqSeq; try { id2extensions mapExt; @@ -964,10 +963,13 @@ uno::Sequence< uno::Sequence > > ::std::vector< ::std::vector > >::const_iterator citVecVec = vecExtensions.begin(); sal_Int32 j = 0; + uno::Sequence< uno::Sequence > > seqSeq(vecExtensions.size()); for (;citVecVec != vecExtensions.end(); citVecVec++, j++) { seqSeq[j] = comphelper::containerToSequence(*citVecVec); } + return seqSeq; + } catch (deploy::DeploymentException& ) { throw; } catch (ucb::CommandFailedException & ) { @@ -983,9 +985,7 @@ uno::Sequence< uno::Sequence > > throw deploy::DeploymentException( OUSTR("Extension Manager: exception during enableExtension"), static_cast(this), exc); - } - - return seqSeq; + } } void ExtensionManager::reinstallDeployedExtensions( -- cgit From 67c12270ab84ac474cebe3ec4169688fa3120844 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 22 Mar 2010 12:35:33 +0100 Subject: jl152 import 263440 from native0jl: #i77196# removing of bundled/shared extension (except python, script) works now --- .../deployment/manager/dp_extensionmanager.cxx | 50 ++-- desktop/source/deployment/manager/dp_manager.cxx | 55 ++--- .../registry/component/dp_compbackenddb.cxx | 58 +++++ .../registry/component/dp_compbackenddb.hxx | 11 +- .../deployment/registry/component/dp_component.cxx | 132 +++++++---- .../registry/configuration/dp_configuration.cxx | 31 ++- desktop/source/deployment/registry/dp_backend.cxx | 149 ++++++++---- .../source/deployment/registry/dp_backenddb.cxx | 90 ++++++-- desktop/source/deployment/registry/dp_registry.cxx | 10 +- .../registry/executable/dp_executable.cxx | 25 +- .../source/deployment/registry/help/dp_help.cxx | 21 +- .../source/deployment/registry/inc/dp_backend.h | 68 ++++-- .../deployment/registry/inc/dp_backenddb.hxx | 6 + .../registry/package/dp_extbackenddb.cxx | 87 ++++--- .../registry/package/dp_extbackenddb.hxx | 11 +- .../deployment/registry/package/dp_package.cxx | 257 +++++++++++++-------- .../deployment/registry/script/dp_script.cxx | 15 +- .../source/deployment/registry/sfwk/dp_sfwk.cxx | 16 +- .../framework/container/UnoPkgContainer.java | 11 +- 19 files changed, 697 insertions(+), 406 deletions(-) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 1519e1f40596..6e76cfb574bd 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -284,9 +284,6 @@ Reference ExtensionManager::getExtensionAndStatus( contain any items which need to be registered then the extension cannot actually be disabled (because it cannot be registered). In this case false is returned. If there is no user extension then also false is returned. - - A user extension is regarded as disabled if there is an extension in a - repository with a lower priority that is registered. */ bool ExtensionManager::isUserExtensionDisabled( OUString const & identifier, OUString const & fileName, @@ -295,36 +292,19 @@ bool ExtensionManager::isUserExtensionDisabled( { bool bDisabled = false; - ::std::list > listExtensions = - getExtensionsWithSameId(identifier, fileName); - ::std::list >::const_iterator - iext = listExtensions.begin(); - bool bCheckOptional = false; - Reference xActive; - for (; iext != listExtensions.end(); iext++) + Reference xExtension; + try + { //will throw an exception if the extension does not exist + xExtension = m_userRepository->getDeployedPackage( + identifier, fileName, Reference()); + } catch(lang::IllegalArgumentException &) { - if (iext->is()) - { - if (!(*iext)->isRegistered(xAbortChannel, xCmdEnv).IsPresent) - { - // IsPresent must be the same for all extnesions - OSL_ASSERT(!bCheckOptional); - break; - } - else - { - bCheckOptional = true; - if ((*iext)->isRegistered(xAbortChannel, xCmdEnv).Value.Value) - { - xActive = *iext; - break; - } - } - } - Reference const & xUser = listExtensions.front(); - if (xUser.is() - && xActive.is() - && xUser != xActive) + } + if (xExtension.is()) + { + beans::Optional > reg = + xExtension->isRegistered(xAbortChannel, xCmdEnv); + if (reg.IsPresent && ! reg.Value.Value) bDisabled = true; } return bDisabled; @@ -1105,13 +1085,13 @@ void ExtensionManager::synchronize( const OUString id = dp_misc::getIdentifier(xExtension); const OUString fileName = xExtension->getName(); - bool bUserDisabled = isUserExtensionDisabled( - id, xExtension->getName(), xAbortChannel, xCmdEnv); + bool bUserDisabled = isUserExtensionDisabled( + id, xExtension->getName(), xAbortChannel, xCmdEnv); xExtension->revokePackage(xAbortChannel, xCmdEnv); xPackageManager->removePackage( id, fileName, xAbortChannel, xCmdEnv); activateExtension( - id, fileName, bUserDisabled, xAbortChannel, xCmdEnv); + id, fileName, /*bUserDisabled*/ false, xAbortChannel, xCmdEnv); } catch (...) { diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 59e9f2049722..9b4f51ea89dd 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -567,7 +567,7 @@ OUString PackageManagerImpl::detectMediaType( try { Reference xPackage( m_xRegistry->bindPackage( - url, OUString(), false, ucbContent.getCommandEnvironment() ) ); + url, OUString(), false, OUString(), ucbContent.getCommandEnvironment() ) ); const Reference xPackageType( xPackage->getPackageType() ); OSL_ASSERT( xPackageType.is() ); @@ -785,7 +785,7 @@ Reference PackageManagerImpl::addPackage( //XPackage objects, even if the second extension is the same. //Therefore bindPackage does not need a guard here. xPackage = m_xRegistry->bindPackage( - makeURL( destFolder, title_enc ), mediaType, false, xCmdEnv ); + makeURL( destFolder, title_enc ), mediaType, false, OUString(), xCmdEnv ); OSL_ASSERT( xPackage.is() ); if (xPackage.is()) @@ -877,16 +877,6 @@ void PackageManagerImpl::removePackage( RuntimeException) { check(); - if (m_readOnly) - { - OUString message; - if (m_context == OUSTR("shared")) - message = OUSTR("You need write permissions in order to remove a shared extension!"); - else - message = OUSTR("You need write permissions in order to remove this extension!"); - throw deployment::DeploymentException( - message, static_cast(this), Any() ); - } Reference xCmdEnv; if (m_xLogFile.is()) @@ -900,7 +890,12 @@ void PackageManagerImpl::removePackage( const ::osl::MutexGuard guard(getMutex()); //Check if this extension exist and throw an IllegalArgumentException //if it does not + //If the files of the extension are already removed, or there is a + //different extension at the same place, for example after updating the + //extension, then the returned object is that which uses the database data. xPackage = getDeployedPackage_(id, fileName, xCmdEnv ); + + //Because the extension is only removed the next time the extension //manager runs after restarting OOo, we need to indicate that a //shared extension was "deleted". When a user starts OOo, then it @@ -908,7 +903,7 @@ void PackageManagerImpl::removePackage( //the flag file it will then recognize, that the extension was //deleted and can then update the extnesion database of the shared //extensions in the user installation. - if (m_context.equals(OUSTR("shared"))) + if (! m_readOnly && !xPackage->isRemoved() && m_context.equals(OUSTR("shared"))) { ActivePackages::Data val; m_activePackagesDB->get( & val, id, fileName); @@ -1010,8 +1005,17 @@ Reference PackageManagerImpl::getDeployedPackage_( static_cast(-1) ); } } - return m_xRegistry->bindPackage( - getDeployPath( data ), data.mediaType, false, xCmdEnv ); + Reference xExtension; + try + { + xExtension = m_xRegistry->bindPackage( + getDeployPath( data ), data.mediaType, false, OUString(), xCmdEnv ); + } + catch (deployment::InvalidRemovedParameterException& e) + { + xExtension = e.Extension; + } + return xExtension; } //______________________________________________________________________________ @@ -1149,17 +1153,6 @@ void PackageManagerImpl::reinstallDeployedPackages( lang::IllegalArgumentException, RuntimeException) { check(); - if (m_readOnly) - { - OUString message; - if (m_context == OUSTR("shared")) - message = OUSTR("You need write permissions in order to install shared extensions!"); - else - message = OUSTR("You need write permissions in order to install extensions!"); - throw deployment::DeploymentException( - message, static_cast(this), Any() ); - } - if (office_is_running()) throw RuntimeException( OUSTR("You must close any running Office process before " @@ -1303,8 +1296,10 @@ void PackageManagerImpl::synchronizeRemovedExtensions( OSL_ENSURE(infoset.hasDescription(), "Extension Manager: bundled and shared extensions " "must have an identifer and a version"); - if ( ! i->first.equals(*(infoset.getIdentifier())) - || ! i->second.version.equals(infoset.getVersion())) + if (infoset.hasDescription() && + infoset.getIdentifier() && + (! i->first.equals(*(infoset.getIdentifier())) + || ! i->second.version.equals(infoset.getVersion()))) { bRemoved = true; } @@ -1313,7 +1308,7 @@ void PackageManagerImpl::synchronizeRemovedExtensions( if (bRemoved) { Reference xPackage = m_xRegistry->bindPackage( - url, i->second.mediaType, true, xCmdEnv ); + url, i->second.mediaType, true, i->first, xCmdEnv ); OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object. removedExtensions.push_back(xPackage); } @@ -1382,7 +1377,7 @@ void PackageManagerImpl::synchronizeAddedExtensions( url = appendURLSegement(url, sExtFolder); } Reference xPackage = m_xRegistry->bindPackage( - url, OUString(), false, xCmdEnv ); + url, OUString(), false, OUString(), xCmdEnv ); if (xPackage.is()) { try diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx index edaf642a2ab1..a942b81a7e32 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -92,6 +92,16 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data root->appendChild(componentNode); +// Reference name( +// doc->createElement(OUSTR("name")), UNO_QUERY_THROW); + +// componentNode->appendChild(name); + +// Reference nameValue( +// doc->createTextNode(data.name), +// UNO_QUERY_THROW); +// name->appendChild(nameValue); + Reference javaTypeLibNode( doc->createElement(OUSTR("java-type-library")), UNO_QUERY_THROW); @@ -134,6 +144,54 @@ void ComponentBackendDb::removeEntry(::rtl::OUString const & url) removeElement(sExpression); } +ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & url) +{ + try + { + ComponentBackendDb::Data retData; + const OUString sExpression( + OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (aNode.is()) + { +// const OUString sExprName(OUSTR("reg:name/text()")); + +// Reference nameValue = +// xpathApi->selectSingleNode(aNode, sExprName); +// retData.name = nameValue->getNodeValue(); + + const OUString sExprJavaTypeLib(OUSTR("reg:java-type-library/text()")); + + Reference idValueNode = + xpathApi->selectSingleNode(aNode, sExprJavaTypeLib); + retData.javaTypeLibrary = + idValueNode->getNodeValue().equals(OUSTR("true")) ? true : false; + + retData.implementationNames = + readList( + aNode, OUSTR("reg:implementation-names"), OUSTR("reg:name")); + + retData.singletons = + readVectorOfPair( + aNode, OUSTR("reg:singletons"), OUSTR("item"), OUSTR("key"), + OUSTR("value")); + } + return retData; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } +} } // namespace bundle diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx index 0dde24beed3f..29ac4e50fe88 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx @@ -60,6 +60,7 @@ namespace component { + FileName true com.sun.star.comp.extensionoptions.OptionsEventHandler$_OptionsEventHandler @@ -80,6 +81,11 @@ namespace component { */ class ComponentBackendDb: public dp_registry::backend::BackendDb { +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getRootElementName(); + public: struct Data { @@ -99,10 +105,7 @@ public: void addEntry(::rtl::OUString const & url, Data const & data); void removeEntry(::rtl::OUString const & url); - - virtual ::rtl::OUString getDbNSName(); - - virtual ::rtl::OUString getRootElementName(); + Data getEntry(::rtl::OUString const & url); }; diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index e4e5efff9e81..667f1588e247 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -123,6 +123,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend const OUString m_loader; Reference m_xRemoteContext; + ComponentBackendDb::Data m_registeredComponentsDb; enum reg { REG_UNINIT, REG_VOID, REG_REGISTERED, REG_NOT_REGISTERED, REG_MAYBE_REGISTERED @@ -152,16 +153,11 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend const Reference getRDB_RO() const; public: - inline ComponentPackageImpl( + ComponentPackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - OUString const & loader, bool bUseDb ) - : Package( myBackend, url, name, name /* display-name */, - xPackageType, bUseDb ), - m_loader( loader ), - m_registered( REG_UNINIT ) - {} + OUString const & loader, bool bRemoved, OUString const & identifier); }; friend class ComponentPackageImpl; @@ -186,15 +182,11 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv ); public: - inline TypelibraryPackageImpl( + TypelibraryPackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool jarFile, bool bUseDb ) - : Package( myBackend, url, name, name /* display-name */, - xPackageType, bUseDb), - m_jarFile( jarFile ) - {} + bool jarFile, bool bRemoved, OUString const & identifier); }; friend class TypelibraryPackageImpl; @@ -215,7 +207,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bNoFileAccess, OUString const & identifier, Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -238,6 +230,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend void addDataToDb(OUString const & url, ComponentBackendDb::Data const & data); void deleteDataFromDb(OUString const & url); + ComponentBackendDb::Data readDataFromDb(OUString const & url); //These rdbs are for writing new service entries. The rdb files are copies @@ -285,6 +278,24 @@ public: }; //______________________________________________________________________________ + +BackendImpl::ComponentPackageImpl::ComponentPackageImpl( + ::rtl::Reference const & myBackend, + OUString const & url, OUString const & name, + Reference const & xPackageType, + OUString const & loader, bool bRemoved, OUString const & identifier) + : Package( myBackend, url, name, name /* display-name */, + xPackageType, bRemoved, identifier), + m_loader( loader ), + m_registered( REG_UNINIT ) +{ + if (bRemoved) + { + m_registeredComponentsDb = getMyBackend()->readDataFromDb(url); + } +} + + const Reference BackendImpl::ComponentPackageImpl::getRDB() const { @@ -593,6 +604,14 @@ void BackendImpl::deleteDataFromDb(OUString const & url) m_backendDb->removeEntry(url); } +ComponentBackendDb::Data BackendImpl::readDataFromDb(OUString const & url) +{ + ComponentBackendDb::Data data; + if (m_backendDb.get()) + data = m_backendDb->getEntry(url); + return data; +} + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference > @@ -605,7 +624,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) { OUString mediaType(mediaType_); @@ -661,9 +680,14 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); - const OUString name( ucbContent.getPropertyValue( - StrTitle::get() ).get() ); + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + StrTitle::get() ).get(); + } + if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.uno-component")) { // xxx todo: probe and evaluate component xml description @@ -679,19 +703,19 @@ Reference BackendImpl::bindPackage_( return new BackendImpl::ComponentPackageImpl( this, url, name, m_xDynComponentTypeInfo, OUSTR("com.sun.star.loader.SharedLibrary"), - bNoFileAccess ); + bRemoved, identifier); } if (value.EqualsIgnoreCaseAscii("Java")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xJavaComponentTypeInfo, OUSTR("com.sun.star.loader.Java2"), - bNoFileAccess ); + bRemoved, identifier); } if (value.EqualsIgnoreCaseAscii("Python")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xPythonComponentTypeInfo, OUSTR("com.sun.star.loader.Python"), - bNoFileAccess); + bRemoved, identifier); } } } @@ -707,12 +731,12 @@ Reference BackendImpl::bindPackage_( { return new BackendImpl::TypelibraryPackageImpl( this, url, name, m_xRDBTypelibTypeInfo, - false /* rdb */, bNoFileAccess); + false /* rdb */, bRemoved, identifier); } if (value.EqualsIgnoreCaseAscii("Java")) { return new BackendImpl::TypelibraryPackageImpl( this, url, name, m_xJavaTypelibTypeInfo, - true /* jar */, bNoFileAccess); + true /* jar */, bRemoved, identifier); } } } @@ -749,16 +773,13 @@ void BackendImpl::unorc_verify_init( sal_Int32 index = sizeof ("UNO_JAVA_CLASSPATH=") - 1; do { OUString token( line.getToken( 0, ' ', index ).trim() ); - if (token.getLength() > 0) { - // cleanup, check if existing: - if (create_ucb_content( - 0, expandUnoRcTerm(token), xCmdEnv, - false /* no throw */ )) { - m_jar_typelibs.push_back( token ); - } - else - OSL_ENSURE( - 0, "### invalid UNO_JAVA_CLASSPATH entry!" ); + if (token.getLength() > 0) + { + //The jar file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the unorc + //After running XExtensionManager::synchronize, the unorc is + //cleaned up + m_jar_typelibs.push_back( token ); } } while (index >= 0); @@ -768,17 +789,15 @@ void BackendImpl::unorc_verify_init( sal_Int32 index = sizeof ("UNO_TYPES=") - 1; do { OUString token( line.getToken( 0, ' ', index ).trim() ); - if (token.getLength() > 0) { + if (token.getLength() > 0) + { if (token[ 0 ] == '?') token = token.copy( 1 ); - // cleanup, check if existing: - if (create_ucb_content( - 0, expandUnoRcTerm(token), - xCmdEnv, false /* no throw */ )) { - m_rdb_typelibs.push_back( token ); - } - else - OSL_ENSURE( 0, "### invalid UNO_TYPES entry!" ); + //The RDB file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the unorc. + //After running XExtensionManager::synchronize, the unorc is + //cleaned up + m_rdb_typelibs.push_back( token ); } } while (index >= 0); @@ -1211,8 +1230,12 @@ void BackendImpl::ComponentPackageImpl::processPackage_( const bool java = m_loader.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.Java2") ); const OUString url( getURL() ); - bool isJavaTypelib = java && - !jarManifestHeaderPresent( url, OUSTR("UNO-Type-Path"), xCmdEnv ); + 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; @@ -1330,8 +1353,15 @@ void BackendImpl::ComponentPackageImpl::processPackage_( t_stringlist implNames; t_stringpairvec singletons; - getComponentInfo( &implNames, &singletons, xContext ); - + if (m_bRemoved) + { + implNames = m_registeredComponentsDb.implementationNames; + singletons = m_registeredComponentsDb.singletons; + } + else + { + getComponentInfo( &implNames, &singletons, xContext ); + } // factories live removal: const Reference xSet( that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); @@ -1405,6 +1435,16 @@ void BackendImpl::ComponentPackageImpl::processPackage_( } //############################################################################## +BackendImpl::TypelibraryPackageImpl::TypelibraryPackageImpl( + ::rtl::Reference const & myBackend, + OUString const & url, OUString const & name, + Reference const & xPackageType, + bool jarFile, bool bRemoved, OUString const & identifier) + : Package( myBackend, url, name, name /* display-name */, + xPackageType, bRemoved, identifier), + m_jarFile( jarFile ) +{ +} // Package BackendImpl * BackendImpl::TypelibraryPackageImpl::getMyBackend() const diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 7118e6d1b2d5..354676fd56ff 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -94,9 +94,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool isSchema, bool bUseDb) + bool isSchema, bool bRemoved, OUString const & identifier) : Package( myBackend, url, name, name /* display-name */, - xPackageType, bUseDb), + xPackageType, bRemoved, identifier), m_isSchema( isSchema ) {} }; @@ -113,8 +113,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ); + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ); ::std::auto_ptr m_registeredPackages; // for backwards compatibility @@ -215,7 +215,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -250,20 +250,27 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + StrTitle::get() ).get(); + } + ::ucbhelper::Content ucbContent( url, xCmdEnv ); if (subType.EqualsIgnoreCaseAscii( - "vnd.sun.star.configuration-data")) { + "vnd.sun.star.configuration-data")) + { return new PackageImpl( - this, url, ucbContent.getPropertyValue( - StrTitle::get() ).get(), - m_xConfDataTypeInfo, false /* data file */, bNoFileAccess); + this, url, name, m_xConfDataTypeInfo, false /* data file */, + bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.configuration-schema")) { return new PackageImpl( - this, url, ucbContent.getPropertyValue( - StrTitle::get() ).get(), - m_xConfSchemaTypeInfo, true /* schema file */, bNoFileAccess); + this, url, name, m_xConfSchemaTypeInfo, true /* schema file */, + bRemoved, identifier); } } } diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 31bb30de7315..7ee49fc46734 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -36,6 +36,7 @@ #include "comphelper/unwrapargs.hxx" #include "ucbhelper/content.hxx" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" +#include "com/sun/star/deployment/InvalidRemovedParameterException.hpp" #include "com/sun/star/beans/StringPair.hpp" @@ -131,29 +132,40 @@ void PackageRegistryBackend::disposing() // XPackageRegistry //______________________________________________________________________________ Reference PackageRegistryBackend::bindPackage( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess , - Reference const & xCmdEnv ) - throw (deployment::DeploymentException, CommandFailedException, + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ) + throw (deployment::DeploymentException, + deployment::InvalidRemovedParameterException, + ucb::CommandFailedException, lang::IllegalArgumentException, RuntimeException) { ::osl::ResettableMutexGuard guard( getMutex() ); check(); - if (!bNoFileAccess) + + t_string2ref::const_iterator const iFind( m_bound.find( url ) ); + if (iFind != m_bound.end()) { - //We only save those object which were created with bNoFileAccess = false - t_string2ref::const_iterator const iFind( m_bound.find( url ) ); - if (iFind != m_bound.end()) + Reference xPackage( iFind->second ); + if (xPackage.is()) { - Reference xPackage( iFind->second ); - if (xPackage.is()) - return xPackage; + if (mediaType.getLength() && + mediaType != xPackage->getPackageType()->getMediaType()) + throw lang::IllegalArgumentException + (OUSTR("XPackageRegistry::bindPackage: media type does not match"), + static_cast(this), 1); + if (xPackage->isRemoved() != bRemoved) + throw deployment::InvalidRemovedParameterException( + OUSTR("XPackageRegistry::bindPackage: bRemoved parameter does not match"), + static_cast(this), xPackage->isRemoved(), xPackage); + return xPackage; } } + guard.clear(); Reference xNewPackage; try { - xNewPackage = bindPackage_( url, mediaType, bNoFileAccess, xCmdEnv ); + xNewPackage = bindPackage_( url, mediaType, bRemoved, identifier, xCmdEnv ); } catch (RuntimeException &) { throw; @@ -175,24 +187,22 @@ Reference PackageRegistryBackend::bindPackage( } guard.reset(); - if (!bNoFileAccess) - { - //We only save those object which were created with bNoFileAccess = false - ::std::pair< t_string2ref::iterator, bool > insertion( - m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) ); - if (insertion.second) - { // first insertion - OSL_ASSERT( Reference(insertion.first->second) - == xNewPackage ); - } - else - { // found existing entry - Reference xPackage( insertion.first->second ); - if (xPackage.is()) - return xPackage; - insertion.first->second = xNewPackage; - } + + ::std::pair< t_string2ref::iterator, bool > insertion( + m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) ); + if (insertion.second) + { // first insertion + OSL_ASSERT( Reference(insertion.first->second) + == xNewPackage ); } + else + { // found existing entry + Reference xPackage( insertion.first->second ); + if (xPackage.is()) + return xPackage; + insertion.first->second = xNewPackage; + } + guard.clear(); xNewPackage->addEventListener( this ); // listen for disposing events return xNewPackage; @@ -211,14 +221,16 @@ Package::Package( ::rtl::Reference const & myBackend, OUString const & name, OUString const & displayName, Reference const & xPackageType, - bool bUseDb) + bool bRemoved, + OUString const & identifier) : t_PackageBase( getMutex() ), m_myBackend( myBackend ), m_url( url ), m_name( name ), m_displayName( displayName ), m_xPackageType( xPackageType ), - m_bUseDb(bUseDb) + m_bRemoved(bRemoved), + m_identifier(identifier) { } @@ -314,10 +326,13 @@ sal_Bool Package::isBundle() throw (RuntimeException) const css::uno::Reference< css::ucb::XCommandEnvironment >&, sal_Bool, ::rtl::OUString const &) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException) + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return true; } @@ -325,9 +340,12 @@ sal_Bool Package::isBundle() throw (RuntimeException) ::sal_Bool Package::checkDependencies( const css::uno::Reference< css::ucb::XCommandEnvironment >& ) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::uno::RuntimeException) + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::uno::RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return true; } @@ -351,12 +369,19 @@ OUString Package::getName() throw (RuntimeException) beans::Optional Package::getIdentifier() throw (RuntimeException) { + if (m_bRemoved) + return beans::Optional(true, m_identifier); + return beans::Optional(); } //______________________________________________________________________________ -OUString Package::getVersion() throw (RuntimeException) +OUString Package::getVersion() throw ( + deployment::ExtensionRemovedException, + RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return OUString(); } @@ -367,33 +392,49 @@ OUString Package::getURL() throw (RuntimeException) } //______________________________________________________________________________ -OUString Package::getDisplayName() throw (RuntimeException) +OUString Package::getDisplayName() throw ( + deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return m_displayName; } //______________________________________________________________________________ -OUString Package::getDescription() throw (RuntimeException) +OUString Package::getDescription() throw ( + deployment::ExtensionRemovedException,RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return OUString(); } //______________________________________________________________________________ -Sequence Package::getUpdateInformationURLs() throw (RuntimeException) +Sequence Package::getUpdateInformationURLs() throw ( + deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return Sequence(); } //______________________________________________________________________________ -css::beans::StringPair Package::getPublisherInfo() throw (RuntimeException) +css::beans::StringPair Package::getPublisherInfo() throw ( + deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); css::beans::StringPair aEmptyPair; return aEmptyPair; } //______________________________________________________________________________ -uno::Reference< css::graphic::XGraphic > Package::getIcon( sal_Bool /*bHighContrast*/ ) throw ( RuntimeException ) +uno::Reference< css::graphic::XGraphic > Package::getIcon( sal_Bool /*bHighContrast*/ ) + throw (deployment::ExtensionRemovedException, RuntimeException ) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + uno::Reference< css::graphic::XGraphic > aEmpty; return aEmpty; } @@ -409,8 +450,12 @@ Reference Package::getPackageType() void Package::exportTo( OUString const & destFolderURL, OUString const & newTitle, sal_Int32 nameClashAction, Reference const & xCmdEnv ) - throw (CommandFailedException, CommandAbortedException, RuntimeException) + throw (deployment::ExtensionRemovedException, + CommandFailedException, CommandAbortedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + ::ucbhelper::Content destFolder( destFolderURL, xCmdEnv ); ::ucbhelper::Content sourceContent( getURL(), xCmdEnv ); if (! destFolder.transferContent( @@ -493,7 +538,8 @@ void Package::processPackage_impl( (doRegisterPackage ? !option.Value.Value : option.Value.Value))); if (action) { - OUString displayName( getDisplayName() ); + + OUString displayName = isRemoved() ? getName() : getDisplayName(); ProgressLevel progress( xCmdEnv, (doRegisterPackage @@ -542,9 +588,12 @@ void Package::registerPackage( Reference const & xAbortChannel, Reference const & xCmdEnv ) throw (deployment::DeploymentException, + deployment::ExtensionRemovedException, CommandFailedException, CommandAbortedException, lang::IllegalArgumentException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); processPackage_impl( true /* register */, xAbortChannel, xCmdEnv ); } @@ -579,7 +628,13 @@ OUString Package::getRepositoryName() { PackageRegistryBackend * backEnd = getMyBackend(); return backEnd->getContext(); - } +} + +sal_Bool Package::isRemoved() + throw (RuntimeException) +{ + return m_bRemoved; +} //############################################################################## @@ -596,13 +651,15 @@ OUString Package::TypeInfo::getMediaType() throw (RuntimeException) } //______________________________________________________________________________ -OUString Package::TypeInfo::getDescription() throw (RuntimeException) +OUString Package::TypeInfo::getDescription() + throw (deployment::ExtensionRemovedException, RuntimeException) { return getShortDescription(); } //______________________________________________________________________________ -OUString Package::TypeInfo::getShortDescription() throw (RuntimeException) +OUString Package::TypeInfo::getShortDescription() + throw (deployment::ExtensionRemovedException, RuntimeException) { return m_shortDescr; } diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index fb0b99c3363c..339236126796 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -259,31 +259,41 @@ BackendDb::readVectorOfPair( OUString const & sFirstTagName, OUString const & sSecondTagName) { - OSL_ASSERT(parent.is()); - Reference xpathApi = getXPathAPI(); - OUString sExprPairs( - sListTagName + OUSTR("/") + sPairTagName); - Reference listPairs = - xpathApi->selectNodeList(parent, sExprPairs); - - ::std::vector< ::std::pair< OUString, OUString > > retVector; - sal_Int32 length = listPairs->getLength(); - for (sal_Int32 i = 0; i < length; i++) + try { - Reference aPair = listPairs->item(i); - OUString sExprFirst(sFirstTagName + OUSTR("/text()")); - Reference first = - xpathApi->selectSingleNode(aPair, sExprFirst); - - OUString sExprSecond(sSecondTagName + OUSTR("/text()")); - Reference second = - xpathApi->selectSingleNode(aPair, sExprSecond); - OSL_ASSERT(first.is() && second.is()); - - retVector.push_back(::std::make_pair( - first->getNodeValue(), second->getNodeValue())); + OSL_ASSERT(parent.is()); + Reference xpathApi = getXPathAPI(); + OUString sExprPairs( + sListTagName + OUSTR("/") + sPairTagName); + Reference listPairs = + xpathApi->selectNodeList(parent, sExprPairs); + + ::std::vector< ::std::pair< OUString, OUString > > retVector; + sal_Int32 length = listPairs->getLength(); + for (sal_Int32 i = 0; i < length; i++) + { + Reference aPair = listPairs->item(i); + OUString sExprFirst(sFirstTagName + OUSTR("/text()")); + Reference first = + xpathApi->selectSingleNode(aPair, sExprFirst); + + OUString sExprSecond(sSecondTagName + OUSTR("/text()")); + Reference second = + xpathApi->selectSingleNode(aPair, sExprSecond); + OSL_ASSERT(first.is() && second.is()); + + retVector.push_back(::std::make_pair( + first->getNodeValue(), second->getNodeValue())); + } + return retVector; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); } - return retVector; } void BackendDb::writeSimpleList( @@ -327,6 +337,40 @@ void BackendDb::writeSimpleList( } +::std::list< OUString> BackendDb::readList( + Reference const & parent, + OUString const & sListTagName, + OUString const & sMemberTagName) +{ + try + { + OSL_ASSERT(parent.is()); + Reference xpathApi = getXPathAPI(); + OUString sExprList( + sListTagName + OUSTR("/") + sMemberTagName + OUSTR("/text()")); + Reference list = + xpathApi->selectNodeList(parent, sExprList); + + ::std::list retList; + sal_Int32 length = list->getLength(); + for (sal_Int32 i = 0; i < length; i++) + { + Reference member = list->item(i); + retList.push_back(member->getNodeValue()); + } + return retList; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + + + } // namespace backend } // namespace dp_registry diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 9ea13ad2c91f..0b3b9e80a7d7 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -127,7 +127,7 @@ public: // XPackageRegistry virtual Reference SAL_CALL bindPackage( OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + OUString const & identifier, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException); virtual Sequence< Reference > SAL_CALL @@ -458,8 +458,8 @@ void PackageRegistryImpl::update() throw (RuntimeException) // XPackageRegistry //______________________________________________________________________________ Reference PackageRegistryImpl::bindPackage( - OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + OUString const & url, OUString const & mediaType_, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException) { @@ -497,7 +497,7 @@ Reference PackageRegistryImpl::bindPackage( for ( ; iPos != iEnd; ++iPos ) { try { - return (*iPos)->bindPackage( url, mediaType, bNoFileAccess, xCmdEnv ); + return (*iPos)->bindPackage( url, mediaType, bRemoved, identifier, xCmdEnv ); } catch (lang::IllegalArgumentException &) { } @@ -526,7 +526,7 @@ Reference PackageRegistryImpl::bindPackage( getResourceString(RID_STR_UNSUPPORTED_MEDIA_TYPE) + mediaType, static_cast(this), static_cast(-1) ); } - return iFind->second->bindPackage( url, mediaType, bNoFileAccess, xCmdEnv ); + return iFind->second->bindPackage( url, mediaType, bRemoved, identifier, xCmdEnv ); } } diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index a5fe1b99746f..39fd3cdc892e 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -72,9 +72,10 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend inline ExecutablePackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, - Reference const & xPackageType, bool bUseDb) + Reference const & xPackageType, + bool bRemoved, OUString const & identifier) : Package( myBackend, url, name, name /* display-name */, - xPackageType, bUseDb) //, + xPackageType, bRemoved, identifier) {} }; friend class ExecutablePackageImpl; @@ -84,8 +85,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ); + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ); Reference m_xExecutableTypeInfo; @@ -125,8 +126,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) // PackageRegistryBackend Reference BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ) { if (mediaType.getLength() == 0) { @@ -141,13 +142,17 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); - const OUString name( ucbContent.getPropertyValue( - dp_misc::StrTitle::get() ).get() ); + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + dp_misc::StrTitle::get() ).get(); + } if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.executable")) { return new BackendImpl::ExecutablePackageImpl( - this, url, name, m_xExecutableTypeInfo, bNoFileAccess); + this, url, name, m_xExecutableTypeInfo, bRemoved, identifier); } } } diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 05ff8dda0e01..9fd9e7ae79fc 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -79,8 +79,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool bUseDb) - : Package( myBackend, url, name, name, xPackageType, bUseDb) + bool bRemoved, OUString const & identifier) + : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) {} }; friend class PackageImpl; @@ -88,7 +88,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage ); @@ -140,7 +140,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) { // we don't support auto detection: @@ -155,14 +155,19 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + StrTitle::get() ).get(); + } + if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.help")) { return new PackageImpl( - this, url, - ucbContent.getPropertyValue( StrTitle::get() ).get(), - m_xHelpTypeInfo, bNoFileAccess); + this, url, name, m_xHelpTypeInfo, bRemoved, identifier); } } } diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 09b25caedc2b..371faf579caf 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -40,6 +40,7 @@ #include "com/sun/star/lang/XEventListener.hpp" #include "com/sun/star/deployment/XPackageRegistry.hpp" #include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/InvalidRemovedParameterException.hpp" #include #include #include "dp_registry.hrc" @@ -74,7 +75,9 @@ protected: ::rtl::OUString m_name; ::rtl::OUString m_displayName; const css::uno::Reference m_xPackageType; - const bool m_bUseDb; + const bool m_bRemoved; + //Only set if m_bRemoved = true; + const ::rtl::OUString m_identifier; void check() const; void fireModified(); @@ -104,7 +107,8 @@ protected: ::rtl::OUString const & displayName, css::uno::Reference const & xPackageType, - bool bUseDb); + bool bRemoved, + ::rtl::OUString const & identifier); public: @@ -129,9 +133,11 @@ public: virtual ::rtl::OUString SAL_CALL getMediaType() throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getDescription() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getShortDescription() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getFileFilter() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getIcon( sal_Bool highContrast, @@ -173,20 +179,23 @@ public: const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, sal_Bool bInstalled, ::rtl::OUString const & aContextName) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException); + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL checkDependencies( const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv ) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::uno::RuntimeException); + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::uno::RuntimeException); virtual void SAL_CALL registerPackage( css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, + css::deployment::ExtensionRemovedException, css::ucb::CommandFailedException, css::ucb::CommandAbortedException, css::lang::IllegalArgumentException, css::uno::RuntimeException); @@ -214,19 +223,27 @@ public: virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getIdentifier() throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getVersion() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getDisplayName() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getDescription() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL - getUpdateInformationURLs() throw (css::uno::RuntimeException); - - virtual css::beans::StringPair SAL_CALL getPublisherInfo() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getIcon( sal_Bool bHighContrast ) throw (css::uno::RuntimeException); - + getUpdateInformationURLs() + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); + virtual css::beans::StringPair SAL_CALL getPublisherInfo() + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); + virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL + getIcon( sal_Bool bHighContrast ) + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual css::uno::Reference SAL_CALL getPackageType() throw (css::uno::RuntimeException); virtual void SAL_CALL exportTo( @@ -234,11 +251,14 @@ public: ::rtl::OUString const & newTitle, sal_Int32 nameClashAction, css::uno::Reference const & xCmdEnv ) - throw (css::ucb::CommandFailedException, + throw (css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, css::ucb::CommandAbortedException, css::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getRepositoryName() + throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL isRemoved() + throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getRepositoryName() - throw (css::uno::RuntimeException); }; typedef ::cppu::WeakComponentImplHelper2< @@ -282,7 +302,7 @@ protected: // @@@ to be implemented by specific backend: virtual css::uno::Reference bindPackage_( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, ::rtl::OUString const & identifier, css::uno::Reference const & xCmdEnv ) = 0; @@ -315,14 +335,12 @@ public: // XPackageRegistry virtual css::uno::Reference SAL_CALL bindPackage( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, ::rtl::OUString const & identifier, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, + css::deployment::InvalidRemovedParameterException, css::ucb::CommandFailedException, css::lang::IllegalArgumentException, css::uno::RuntimeException); -// virtual css::uno::Sequence< -// css::uno::Reference > SAL_CALL -// getSupportedPackageTypes() throw (css::uno::RuntimeException); }; } diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index 3005ffcafb5b..dbac54e10c6d 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -97,6 +97,12 @@ protected: ::rtl::OUString const & sFirstTagName, ::rtl::OUString const & sSecondTagName); + ::std::list< ::rtl::OUString> readList( + css::uno::Reference const & parent, + ::rtl::OUString const & sListTagName, + ::rtl::OUString const & sMemberTagName); + + /* returns the namespace which is to be written as xmlns attribute diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx index 97cfc136049c..93aa62174e0f 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -46,22 +46,6 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010" #define ROOT_ELEMENT_NAME "extension-backend-db" -// /extension-backend-db/extension -#define EXTENSION_ELEMENT "extension" - -// /extension-backend-db/extension/extension-items -#define EXTENSION_ITEMS "extension-items" - -// /extension-backend-db/extension/extension-items/item -#define EXTENSION_ITEMS_ITEM "item" - -// /extension-backend-db/extension/extension-items/item/url -#define ITEM_URL "url" - -// /extension-backend-db/extension/extension-items/item/media-type -#define ITEM_MEDIA_TYP "media-type" - - namespace dp_registry { namespace backend { namespace bundle { @@ -109,13 +93,13 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data root->appendChild(extensionNodeNode); // ... - Reference identifierNode( - doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); - extensionNodeNode->appendChild(identifierNode); +// Reference identifierNode( +// doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); +// extensionNodeNode->appendChild(identifierNode); - Reference identifierValue( - doc->createTextNode(data.identifier), UNO_QUERY_THROW); - identifierNode->appendChild(identifierValue); +// Reference identifierValue( +// doc->createTextNode(data.identifier), UNO_QUERY_THROW); +// identifierNode->appendChild(identifierValue); writeVectorOfPair( @@ -145,30 +129,41 @@ void ExtensionBackendDb::removeEntry(::rtl::OUString const & url) ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & url) { - ExtensionBackendDb::Data retData; - const OUString sExpression( - OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); - //find the extension element that is to be removed - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); - OSL_ASSERT(aNode.is()); - - const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); - - Reference idValueNode = - xpathApi->selectSingleNode(aNode, sExprIdentifier); - retData.identifier = idValueNode->getNodeValue(); - - retData.items = - readVectorOfPair( - aNode, - OUSTR("reg:extension-items"), - OUSTR("reg:item"), OUSTR("reg:url"), OUSTR("reg:media-type")); - return retData; + try + { + ExtensionBackendDb::Data retData; + const OUString sExpression( + OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (aNode.is()) + { +// const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); + +// Reference idValueNode = +// xpathApi->selectSingleNode(aNode, sExprIdentifier); +// retData.identifier = idValueNode->getNodeValue(); + + retData.items = + readVectorOfPair( + aNode, + OUSTR("reg:extension-items"), + OUSTR("reg:item"), OUSTR("reg:url"), OUSTR("reg:media-type")); + } + return retData; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } } } // namespace bundle diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx index 156e34155040..4afe6f1a5577 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx @@ -58,11 +58,15 @@ namespace bundle { */ class ExtensionBackendDb: public dp_registry::backend::BackendDb { +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getRootElementName(); + public: struct Data { - ::rtl::OUString identifier; - /* every element consists of a pair of the url to the item (jar,rdb, etc) + /* every element consists of a pair of the url to the item (jar,rdb, etc) and the media type */ ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString> > items; @@ -80,9 +84,6 @@ public: void removeEntry(::rtl::OUString const & url); Data getEntry(::rtl::OUString const & url); - virtual ::rtl::OUString getDbNSName(); - - virtual ::rtl::OUString getRootElementName(); }; diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 8fe7874f247f..467ff5ca89fa 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -77,9 +77,9 @@ using namespace ::dp_misc; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::ucb; + namespace css = ::com::sun::star; -namespace cssu = ::com::sun::star::uno; + using ::rtl::OUString; namespace dp_registry { @@ -105,46 +105,49 @@ class BackendImpl : public ImplBaseT Sequence< Reference > m_bundle; Sequence< Reference > * m_pBundle; - ExtensionBackendDb::Data m_data; + ExtensionBackendDb::Data m_dbData; Reference bindBundleItem( OUString const & url, OUString const & mediaType, - Reference const & xCmdEnv, + sal_Bool bRemoved, //that is, useing data base information + OUString const & identifier, + Reference const & xCmdEnv, bool notifyDetectionError = true ); typedef ::std::vector< Reference > t_packagevec; void scanBundle( t_packagevec & bundle, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ); + Reference const & xCmdEnv ); void scanLegacyBundle( t_packagevec & bundle, OUString const & url, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv, + Reference const & xCmdEnv, bool skip_registration = false ); - ::std::vector > getPackagesFromDb(); + ::std::vector > getPackagesFromDb( + Reference const & xCmdEnv); bool checkPlatform( - css::uno::Reference< css::ucb::XCommandEnvironment > const & environment); + Reference const & environment); bool checkDependencies( - css::uno::Reference< css::ucb::XCommandEnvironment > const & + Reference const & environment, DescriptionInfoset const & description); // throws css::uno::RuntimeException, // css::deployment::DeploymentException ::sal_Bool checkLicense( - css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, + Reference< ucb::XCommandEnvironment > const & xCmdEnv, DescriptionInfoset const & description, bool bInstalled, OUString const & aContextName ) - throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException); + throw (deployment::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + RuntimeException); // @throws DeploymentException OUString getTextFromURL( - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, + const Reference< ucb::XCommandEnvironment >& xCmdEnv, const OUString& licenseUrl); DescriptionInfoset getDescriptionInfoset(); @@ -153,12 +156,12 @@ class BackendImpl : public ImplBaseT virtual beans::Optional< beans::Ambiguous > isRegistered_( ::osl::ResettableMutexGuard & guard, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ); + Reference const & xCmdEnv ); virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ); + Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -171,51 +174,66 @@ class BackendImpl : public ImplBaseT OUString const & name, Reference const & xPackageType, bool legacyBundle, - bool useDb); + bool bRemoved, + OUString const & identifier); // XPackage virtual sal_Bool SAL_CALL isBundle() throw (RuntimeException); + virtual Sequence< Reference > SAL_CALL getBundle( Reference const & xAbortChannel, - Reference const & xCmdEnv ) + Reference const & xCmdEnv ) throw (deployment::DeploymentException, - CommandFailedException, CommandAbortedException, + ucb::CommandFailedException, + ucb::CommandAbortedException, lang::IllegalArgumentException, RuntimeException); - virtual OUString SAL_CALL getDescription() throw (RuntimeException); + virtual OUString SAL_CALL getDescription() + throw (deployment::ExtensionRemovedException, RuntimeException); + virtual void SAL_CALL exportTo( OUString const & destFolderURL, OUString const & newTitle, sal_Int32 nameClashAction, - Reference const & xCmdEnv ) - throw (CommandFailedException, CommandAbortedException, + Reference const & xCmdEnv ) + throw (deployment::ExtensionRemovedException, + ucb::CommandFailedException, + ucb::CommandAbortedException, RuntimeException); virtual ::sal_Bool SAL_CALL checkPrerequisites( - const css::uno::Reference< css::task::XAbortChannel >& xAbortChannel, - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, + const Reference< task::XAbortChannel >& xAbortChannel, + const Reference< ucb::XCommandEnvironment >& xCmdEnv, ::sal_Bool bInstalled, OUString const & aContextName) - throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException); + throw (deployment::ExtensionRemovedException, + deployment::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + RuntimeException); virtual ::sal_Bool SAL_CALL checkDependencies( - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv ) - throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::uno::RuntimeException); + const Reference< ucb::XCommandEnvironment >& xCmdEnv ) + throw (deployment::DeploymentException, + deployment::ExtensionRemovedException, + ucb::CommandFailedException, + RuntimeException); virtual beans::Optional SAL_CALL getIdentifier() throw (RuntimeException); - virtual OUString SAL_CALL getVersion() throw (RuntimeException); + virtual OUString SAL_CALL getVersion() + throw (deployment::ExtensionRemovedException, RuntimeException); virtual Sequence SAL_CALL getUpdateInformationURLs() - throw (RuntimeException); + throw (deployment::ExtensionRemovedException, RuntimeException); - virtual css::beans::StringPair SAL_CALL getPublisherInfo() throw (css::uno::RuntimeException); + virtual beans::StringPair SAL_CALL getPublisherInfo() + throw (deployment::ExtensionRemovedException, RuntimeException); virtual OUString SAL_CALL getDisplayName() throw (RuntimeException); - virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getIcon( ::sal_Bool bHighContrast ) throw (css::uno::RuntimeException); + + virtual Reference< graphic::XGraphic > SAL_CALL + getIcon( ::sal_Bool bHighContrast ) + throw (deployment::ExtensionRemovedException, + RuntimeException); }; friend class PackageImpl; @@ -233,8 +251,8 @@ class BackendImpl : public ImplBaseT // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, - Reference const & xCmdEnv ); + sal_Bool bRemoved, OUString const & identifier, + Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -344,8 +362,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + sal_Bool bRemoved, OUString const & identifier, + Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); if (mediaType.getLength() == 0) @@ -393,21 +411,24 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent; - OUString name; + //In case a XPackage is created for a removed extension, we cannot //obtain the name - if (create_ucb_content(&ucbContent, url, xCmdEnv, false )) + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); name = ucbContent.getPropertyValue( StrTitle::get() ).get(); + } if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.package-bundle")) { return new PackageImpl( - this, url, name, m_xBundleTypeInfo, false, bNoFileAccess); + this, url, name, m_xBundleTypeInfo, false, bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.legacy-package-bundle")) { return new PackageImpl( - this, url, name, m_xLegacyBundleTypeInfo, true, bNoFileAccess); + this, url, name, m_xLegacyBundleTypeInfo, true, bRemoved, identifier); } } } @@ -447,16 +468,15 @@ BackendImpl::PackageImpl::PackageImpl( OUString const & url, OUString const & name, Reference const & xPackageType, - bool legacyBundle, - bool useDb) + bool legacyBundle, bool bRemoved, OUString const & identifier) : Package( myBackend, url, name, name /* display-name */, - xPackageType, useDb ), + xPackageType, bRemoved, identifier), m_url_expanded( expandUnoRcUrl( url ) ), m_legacyBundle( legacyBundle ), m_pBundle( 0 ) { - if (useDb) - m_data = getMyBackend()->readDataFromDb(url); + if (bRemoved) + m_dbData = getMyBackend()->readDataFromDb(url); } BackendImpl * BackendImpl::PackageImpl::getMyBackend() const @@ -491,10 +511,17 @@ beans::Optional< beans::Ambiguous > BackendImpl::PackageImpl::isRegistered_( ::osl::ResettableMutexGuard &, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ) + Reference const & xCmdEnv ) { + //In case the object was created for a removed extension (m_bRemoved = true) + //but the extension is not registered, then bundle will be empty. Then + //the return value will be Optional<...>.IsPresent= false. Althoug this is + //not true, this does not matter. Then registerPackage or revokePackage + //would never be called for the items. But since the extension is removed + //and not registered anyway, this does not matter. const Sequence< Reference > bundle( getBundle( abortChannel.get(), xCmdEnv ) ); + bool reg = false; bool present = false; bool ambig = false; @@ -723,10 +750,13 @@ bool BackendImpl::PackageImpl::checkDependencies( const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, sal_Bool bInstalled, OUString const & aContextName) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException) + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); DescriptionInfoset info = getDescriptionInfoset(); if (!info.hasDescription()) return sal_True; @@ -742,6 +772,8 @@ bool BackendImpl::PackageImpl::checkDependencies( css::ucb::CommandFailedException, css::uno::RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); DescriptionInfoset info = getDescriptionInfoset(); if (!info.hasDescription()) return sal_True; @@ -753,8 +785,8 @@ beans::Optional BackendImpl::PackageImpl::getIdentifier() throw (RuntimeException) { OUString identifier; - if (m_bUseDb) - identifier = m_data.identifier; + if (m_bRemoved) + identifier = m_identifier; else identifier = dp_misc::generateIdentifier( getDescriptionInfoset().getIdentifier(), m_name); @@ -765,18 +797,24 @@ beans::Optional BackendImpl::PackageImpl::getIdentifier() OUString BackendImpl::PackageImpl::getVersion() throw (RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return getDescriptionInfoset().getVersion(); } Sequence BackendImpl::PackageImpl::getUpdateInformationURLs() - throw (RuntimeException) + throw (deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return getDescriptionInfoset().getUpdateInformationUrls(); } beans::StringPair BackendImpl::PackageImpl::getPublisherInfo() - throw (RuntimeException) + throw (deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); ::std::pair< OUString, OUString > aInfo = getDescriptionInfoset().getLocalizedPublisherNameAndURL(); beans::StringPair aStrPair( aInfo.first, aInfo.second ); return aStrPair; @@ -784,8 +822,11 @@ beans::StringPair BackendImpl::PackageImpl::getPublisherInfo() //______________________________________________________________________________ uno::Reference< graphic::XGraphic > BackendImpl::PackageImpl::getIcon( sal_Bool bHighContrast ) - throw ( RuntimeException ) + throw (deployment::ExtensionRemovedException, RuntimeException ) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + uno::Reference< graphic::XGraphic > xGraphic; OUString aIconURL = getDescriptionInfoset().getIconURL( bHighContrast ); @@ -816,7 +857,7 @@ void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ) + Reference const & xCmdEnv ) { const Sequence< Reference > bundle( getBundle( abortChannel.get(), xCmdEnv ) ); @@ -838,7 +879,7 @@ void BackendImpl::PackageImpl::processPackage_( catch (RuntimeException &) { throw; } - catch (CommandAbortedException &) { + catch (ucb::CommandAbortedException &) { throw; } catch (Exception &) { @@ -876,7 +917,7 @@ void BackendImpl::PackageImpl::processPackage_( catch (RuntimeException &) { throw; } - catch (CommandAbortedException &) { + catch (ucb::CommandAbortedException &) { throw; } catch (Exception &) { @@ -893,7 +934,7 @@ void BackendImpl::PackageImpl::processPackage_( deployment::DeploymentException dpExc; if (exc >>= dpExc) { - throw CommandFailedException( + throw ucb::CommandFailedException( dpExc.Message, dpExc.Context, dpExc.Cause ); } else { @@ -905,7 +946,6 @@ void BackendImpl::PackageImpl::processPackage_( ::std::make_pair(xPackage->getURL(), xPackage->getPackageType()->getMediaType())); } - data.identifier = getIdentifier().Value; getMyBackend()->addDataToDb(getURL(), data); } else @@ -924,7 +964,7 @@ void BackendImpl::PackageImpl::processPackage_( catch (RuntimeException &) { throw; } - catch (CommandAbortedException &) { + catch (ucb::CommandAbortedException &) { throw; } catch (Exception &) { @@ -957,6 +997,9 @@ void BackendImpl::PackageImpl::processPackage_( //______________________________________________________________________________ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + const OUString sRelativeURL(getDescriptionInfoset().getLocalizedDescriptionURL()); OUString sDescription; if (sRelativeURL.getLength()) @@ -977,9 +1020,14 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) //______________________________________________________________________________ void BackendImpl::PackageImpl::exportTo( OUString const & destFolderURL, OUString const & newTitle, - sal_Int32 nameClashAction, Reference const & xCmdEnv ) - throw (CommandFailedException, CommandAbortedException, RuntimeException) + sal_Int32 nameClashAction, Reference const & xCmdEnv ) + throw (ucb::CommandFailedException, + deployment::ExtensionRemovedException, + ucb::CommandAbortedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + ::ucbhelper::Content sourceContent( m_url_expanded, xCmdEnv ); OUString title(newTitle); if (title.getLength() == 0) @@ -989,25 +1037,25 @@ void BackendImpl::PackageImpl::exportTo( rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ) ) ); - if (nameClashAction == NameClash::ASK) + if (nameClashAction == ucb::NameClash::ASK) { if (create_ucb_content( 0, destURL, xCmdEnv, false /* no throw */ )) { bool replace = false, abort = false; if (! interactContinuation( - Any( NameClashResolveRequest( + Any( ucb::NameClashResolveRequest( OUSTR("file already exists: ") + title, static_cast(this), task::InteractionClassification_QUERY, destFolderURL, title, OUString() ) ), - XInteractionReplaceExistingData::static_type(), xCmdEnv, + ucb::XInteractionReplaceExistingData::static_type(), xCmdEnv, &replace, &abort ) || !replace) { return; } } } - else if (nameClashAction != NameClash::OVERWRITE) { - throw CommandFailedException( + else if (nameClashAction != ucb::NameClash::OVERWRITE) { + throw ucb::CommandFailedException( OUSTR("unsupported nameClashAction!"), static_cast(this), Any() ); } @@ -1033,11 +1081,11 @@ void BackendImpl::PackageImpl::exportTo( while (xResultSet->next()) { ::ucbhelper::Content subContent( - Reference( + Reference( xResultSet, UNO_QUERY_THROW )->queryContent(), xCmdEnv ); if (! destFolderContent.transferContent( subContent, ::ucbhelper::InsertOperation_COPY, - OUString(), NameClash::OVERWRITE )) + OUString(), ucb::NameClash::OVERWRITE )) throw RuntimeException( OUSTR("UCB transferContent() failed!"), static_cast(this) ); progress.update( Any() ); // animating progress bar @@ -1145,7 +1193,7 @@ void BackendImpl::PackageImpl::exportTo( if (! metainfFolderContent.transferContent( manifestContent, ::ucbhelper::InsertOperation_COPY, - OUString(), NameClash::OVERWRITE )) + OUString(), ucb::NameClash::OVERWRITE )) throw RuntimeException( OUSTR("UCB transferContent() failed!"), static_cast(this) ); } @@ -1154,7 +1202,7 @@ void BackendImpl::PackageImpl::exportTo( try { destFolderContent.executeCommand( OUSTR("flush"), Any() ); } - catch (UnsupportedCommandException &) { + catch (ucb::UnsupportedCommandException &) { } } @@ -1167,18 +1215,18 @@ sal_Bool BackendImpl::PackageImpl::isBundle() throw (RuntimeException) //______________________________________________________________________________ Sequence< Reference > BackendImpl::PackageImpl::getBundle( Reference const & xAbortChannel, - Reference const & xCmdEnv ) + Reference const & xCmdEnv ) throw (deployment::DeploymentException, - CommandFailedException, CommandAbortedException, + ucb::CommandFailedException, ucb::CommandAbortedException, lang::IllegalArgumentException, RuntimeException) { Sequence< Reference > * pBundle = m_pBundle; if (pBundle == 0) { t_packagevec bundle; - if (m_bUseDb) + if (m_bRemoved) { - bundle = getPackagesFromDb(); + bundle = getPackagesFromDb(xCmdEnv); } else { @@ -1203,7 +1251,8 @@ Sequence< Reference > BackendImpl::PackageImpl::getBundle( if (mediaType.getLength() > 0) { const Reference xPackage( - bindBundleItem( getURL(), mediaType, xCmdEnv ) ); + bindBundleItem( getURL(), mediaType, false, OUString(), + xCmdEnv ) ); if (xPackage.is()) bundle.push_back( xPackage ); // continue scanning: @@ -1221,10 +1270,10 @@ Sequence< Reference > BackendImpl::PackageImpl::getBundle( catch (RuntimeException &) { throw; } - catch (CommandFailedException &) { + catch (ucb::CommandFailedException &) { throw; } - catch (CommandAbortedException &) { + catch (ucb::CommandAbortedException &) { throw; } catch (deployment::DeploymentException &) { @@ -1302,7 +1351,8 @@ inline bool isBundle_( OUString const & mediaType ) //______________________________________________________________________________ Reference BackendImpl::PackageImpl::bindBundleItem( OUString const & url, OUString const & mediaType, - Reference const & xCmdEnv, + sal_Bool bRemoved, OUString const & identifier, + Reference const & xCmdEnv, bool notifyDetectionError ) { // ignore any nested bundles: @@ -1312,13 +1362,13 @@ Reference BackendImpl::PackageImpl::bindBundleItem( ReferencexPackage; try { xPackage.set( getMyBackend()->m_xRootRegistry->bindPackage( - url, mediaType, false, xCmdEnv ) ); + url, mediaType, bRemoved, identifier, xCmdEnv ) ); OSL_ASSERT( xPackage.is() ); } catch (RuntimeException &) { throw; } - catch (CommandFailedException &) { + catch (ucb::CommandFailedException &) { // ignore already handled error } catch (Exception &) { @@ -1351,7 +1401,7 @@ Reference BackendImpl::PackageImpl::bindBundleItem( void BackendImpl::PackageImpl::scanBundle( t_packagevec & bundle, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ) + Reference const & xCmdEnv ) { OSL_ASSERT( !m_legacyBundle ); @@ -1448,7 +1498,7 @@ void BackendImpl::PackageImpl::scanBundle( if (bundle.end() == std::find_if(bundle.begin(), bundle.end(), XPackage_eq(url))) { const Reference xPackage( - bindBundleItem( url, mediaType, xCmdEnv ) ); + bindBundleItem( url, mediaType, false, OUString(), xCmdEnv ) ); if (xPackage.is()) bundle.push_back( xPackage ); } @@ -1487,7 +1537,7 @@ void BackendImpl::PackageImpl::scanLegacyBundle( t_packagevec & bundle, OUString const & url, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv, + Reference const & xCmdEnv, bool skip_registration ) { ::ucbhelper::Content ucbContent( url, xCmdEnv ); @@ -1523,8 +1573,8 @@ void BackendImpl::PackageImpl::scanLegacyBundle( OUString mediaType; const Reference xPackage( - bindBundleItem( path, OUString() /* detect */, xCmdEnv, - false /* ignore detection errors */ ) ); + bindBundleItem( path, OUString() /* detect */, false, OUString(), + xCmdEnv, false /* ignore detection errors */ ) ); if (xPackage.is()) { const Reference xPackageType( xPackage->getPackageType() ); @@ -1559,8 +1609,12 @@ void BackendImpl::PackageImpl::scanLegacyBundle( } } -OUString BackendImpl::PackageImpl::getDisplayName() throw (RuntimeException) +OUString BackendImpl::PackageImpl::getDisplayName() + throw (deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + OUString sName = getDescriptionInfoset().getLocalizedDisplayName(); if (sName.getLength() == 0) return m_displayName; @@ -1568,11 +1622,22 @@ OUString BackendImpl::PackageImpl::getDisplayName() throw (RuntimeException) return sName; } -::std::vector > BackendImpl::PackageImpl::getPackagesFromDb() +::std::vector > +BackendImpl::PackageImpl::getPackagesFromDb( + Reference const & xCmdEnv) { - //get the data base entry for this extension + ::std::vector > retVector; + + typedef ::std::vector< ::std::pair >::const_iterator ITC; + for (ITC i = m_dbData.items.begin(); i != m_dbData.items.end(); i++) + { + Reference xExtension = + bindBundleItem(i->first, i->second, true, m_identifier, xCmdEnv); + OSL_ASSERT(xExtension.is()); + retVector.push_back(xExtension); + } - return ::std::vector >(); + return retVector; } } // anon namespace diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 6d503d33d51d..b645c9b2af7a 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -89,14 +89,14 @@ class BackendImpl : public t_helper OUString const & url, Reference const &xCmdEnv, OUString const & scriptURL, OUString const & dialogURL, - bool bUseDb); + bool bRemoved, OUString const & identifier); }; friend class PackageImpl; // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); @@ -125,11 +125,12 @@ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference const & myBackend, OUString const & url, Reference const &xCmdEnv, - OUString const & scriptURL, OUString const & dialogURL, bool bUseDb ) + OUString const & scriptURL, OUString const & dialogURL, bool bRemoved, + OUString const & identifier) : Package( myBackend.get(), url, OUString(), OUString(), // will be late-initialized scriptURL.getLength() > 0 ? myBackend->m_xBasicLibTypeInfo - : myBackend->m_xDialogLibTypeInfo, bUseDb), + : myBackend->m_xDialogLibTypeInfo, bRemoved, identifier), m_scriptURL( scriptURL ), m_dialogURL( dialogURL ) { @@ -191,7 +192,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -234,7 +235,7 @@ Reference BackendImpl::bindPackage_( } return new PackageImpl( this, url, xCmdEnv, makeURL( url, OUSTR("script.xlb") ), - dialogURL, bNoFileAccess); + dialogURL, bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.dialog-library")) { @@ -242,7 +243,7 @@ Reference BackendImpl::bindPackage_( this, url, xCmdEnv, OUString() /* no script lib */, makeURL( url, OUSTR("dialog.xlb") ), - bNoFileAccess); + bRemoved, identifier); } } } diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index 47b6430f1a1e..704f4f810928 100644 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -83,7 +83,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend public: PackageImpl( ::rtl::Reference const & myBackend, - OUString const & url, OUString const & libType, bool bUseDb); + OUString const & url, OUString const & libType, bool bRemoved, + OUString const & identifier); // XPackage virtual OUString SAL_CALL getDescription() throw (RuntimeException); }; @@ -92,7 +93,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); const Reference m_xTypeInfo; @@ -133,9 +134,10 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) //______________________________________________________________________________ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference const & myBackend, - OUString const & url, OUString const & libType, bool bUseDb) + OUString const & url, OUString const & libType, bool bRemoved, + OUString const & identifier) : Package( myBackend.get(), url, OUString(), OUString(), - myBackend->m_xTypeInfo, bUseDb ), + myBackend->m_xTypeInfo, bRemoved, identifier), m_descr(libType) { initPackageHandler(); @@ -219,8 +221,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) // PackageRegistryBackend //______________________________________________________________________________ Reference BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + OUString const & url, OUString const & mediaType_, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); if (mediaType.getLength() == 0) @@ -296,7 +298,7 @@ Reference BackendImpl::bindPackage_( dp_misc::TRACE(OUSTR(" BackEnd detected lang = ") + lang + OUSTR("\n")); dp_misc::TRACE(OUSTR(" for url ") + sParcelDescURL + OUSTR("\n") ); dp_misc::TRACE("******************************\n"); - return new PackageImpl( this, url, sfwkLibType, bNoFileAccess); + return new PackageImpl( this, url, sfwkLibType, bRemoved, identifier); } } } diff --git a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java index 3b9e04a27210..4c6a4f1eda2b 100644 --- a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java +++ b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java @@ -44,6 +44,7 @@ import com.sun.star.io.XOutputStream; import com.sun.star.io.XTruncate; import com.sun.star.deployment.XPackage; +import com.sun.star.deployment.ExtensionRemovedException; public class UnoPkgContainer extends ParcelContainer { @@ -336,7 +337,15 @@ public class UnoPkgContainer extends ParcelContainer LogUtils.DEBUG("** processUnoPackage getURL() -> " + uri ); LogUtils.DEBUG("** processUnoPackage getName() -> " + dPackage.getName() ); LogUtils.DEBUG("** processUnoPackage getMediaType() -> " + dPackage.getPackageType().getMediaType() ); - LogUtils.DEBUG("** processUnoPackage getDisplayName() -> " + dPackage.getDisplayName() ); + try + { + LogUtils.DEBUG("** processUnoPackage getDisplayName() -> " + dPackage.getDisplayName() ); + } + catch (com.sun.star.deployment.ExtensionRemovedException e) + { + throw new com.sun.star.lang.WrappedTargetException(e.toString(), this, e); + } + processUnoPackage( uri, language ); db = getUnoPackagesDB(); -- cgit From a13b1c857a8bc6657a14eb46e7e9663ff2bc9fa4 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 25 Mar 2010 10:32:07 +0100 Subject: jl152 import 263441 from native0jl:#i77196# add and remove in the same process now works, help backend creates a unique folder for every extension --- desktop/source/deployment/manager/dp_manager.cxx | 74 +++- .../registry/component/dp_compbackenddb.cxx | 61 ++- .../registry/component/dp_compbackenddb.hxx | 2 +- desktop/source/deployment/registry/dp_backend.cxx | 86 ++++ .../source/deployment/registry/dp_backenddb.cxx | 36 +- desktop/source/deployment/registry/dp_registry.cxx | 2 +- .../source/deployment/registry/help/dp_help.cxx | 463 ++++++++++++--------- .../deployment/registry/help/dp_helpbackenddb.cxx | 224 ++++++++++ .../deployment/registry/help/dp_helpbackenddb.hxx | 101 +++++ .../source/deployment/registry/help/makefile.mk | 3 +- .../source/deployment/registry/inc/dp_backend.h | 18 + .../deployment/registry/inc/dp_backenddb.hxx | 5 + .../registry/package/dp_extbackenddb.cxx | 48 +-- .../registry/package/dp_extbackenddb.hxx | 2 +- 14 files changed, 836 insertions(+), 289 deletions(-) create mode 100644 desktop/source/deployment/registry/help/dp_helpbackenddb.cxx create mode 100644 desktop/source/deployment/registry/help/dp_helpbackenddb.hxx diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 9b4f51ea89dd..e2580e7b955b 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -39,6 +39,7 @@ #include "rtl/bootstrap.hxx" #include "osl/diagnose.h" #include "osl/file.hxx" +#include "osl/security.hxx" #include "cppuhelper/weakref.hxx" #include "cppuhelper/exc_hlp.hxx" #include "cppuhelper/implbase1.hxx" @@ -237,23 +238,37 @@ void PackageManagerImpl::initActivationLayer( ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); // get all temp directories: ::std::vector tempEntries; + ::std::vector removedEntries; while (xResultSet->next()) { OUString title( Reference( xResultSet, UNO_QUERY_THROW )->getString( 1 /* Title */ ) ); - const char extensionRemoved[] = ".tmpremoved"; + + const char extensionRemoved[] = "removed"; if (title.endsWithAsciiL( extensionRemoved, sizeof(extensionRemoved) - 1)) - continue; - - tempEntries.push_back( ::rtl::Uri::encode( - title, rtl_UriCharClassPchar, - rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8 ) ); + { + //save the file name withouth the "removed" part + sal_Int32 index = title.lastIndexOfAsciiL( + extensionRemoved, sizeof(extensionRemoved) - 1); + OUString remFile = title.copy(0, index); + removedEntries.push_back(::rtl::Uri::encode( + remFile, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ); + } + else + { + tempEntries.push_back( ::rtl::Uri::encode( + title, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ); + } } + bool bShared = m_context.equals(OUSTR("shared")) ? true : false; for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos ) { OUString const & tempEntry = tempEntries[ pos ]; @@ -261,9 +276,44 @@ void PackageManagerImpl::initActivationLayer( if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == id2temp.end()) { + const OUString url( + makeURL(m_activePackages_expanded, tempEntry ) ); + + //In case of shared extensions, new entries are regarded as + //added extensions if there is no xxx.tmpremoved file. + if (bShared) + { + if (::std::find(removedEntries.begin(), removedEntries.end(), tempEntry) == + removedEntries.end()) + { + continue; + } + else + { + //Make sure only the same user removes the extension, who + //previously unregistered it. This is avoid races if multiple instances + //of OOo are running which all have write access to the shared installation. + //For example, user a uses extension a, removes the extension, but keeps OOo + //running. Parts of the extension may still be loaded and used by OOo. + //Therefore the extension is only deleted the next time the extension manager is + //run after restarting OOo. While OOo is still running, another user starts OOo + //which would deleted the extension files. If the same user starts another + //instance of OOo then the lock file will prevent this. + OUString aUserName; + ::osl::Security aSecurity; + aSecurity.getUserName( aUserName ); + ucbhelper::Content remFileContent( + url + OUSTR("removed"), Reference()); + ::rtl::ByteSequence data = dp_misc::readFile(remFileContent); + ::rtl::OString osData(reinterpret_cast(data.getConstArray()), + data.getLength()); + OUString sData = ::rtl::OStringToOUString( + osData, RTL_TEXTENCODING_UTF8); + if (!sData.equals(aUserName)) + continue; + } + } // temp entry not needed anymore: - const OUString url( makeURL( m_activePackages_expanded, - tempEntry ) ); erase_path( url + OUSTR("_"), Reference(), false /* no throw: ignore errors */ ); @@ -911,7 +961,11 @@ void PackageManagerImpl::removePackage( OUString url(makeURL(m_activePackages_expanded, val.temporaryName + OUSTR("removed"))); ::ucbhelper::Content contentRemoved(url, xCmdEnv ); - ::rtl::OString stamp("1"); + OUString aUserName; + ::osl::Security aSecurity; + aSecurity.getUserName( aUserName ); + + ::rtl::OString stamp = ::rtl::OUStringToOString(aUserName, RTL_TEXTENCODING_UTF8); Reference xData( ::xmlscript::createInputStream( ::rtl::ByteSequence( diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx index a942b81a7e32..568ecca08138 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -44,6 +44,7 @@ using namespace ::com::sun::star::uno; using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010" +#define NS_PREFIX "comp" #define ROOT_ELEMENT_NAME "component-backend-db" namespace dp_registry { @@ -62,6 +63,11 @@ OUString ComponentBackendDb::getDbNSName() return OUSTR(EXTENSION_REG_NS); } +OUString ComponentBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + OUString ComponentBackendDb::getRootElementName() { return OUSTR(ROOT_ELEMENT_NAME); @@ -70,20 +76,21 @@ OUString ComponentBackendDb::getRootElementName() void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); Reference doc = getDocument(); Reference root = doc->getFirstChild(); #if OSL_DEBUG_LEVEL > 0 //There must not be yet an entry with the same url OUString sExpression( - OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); Reference _extensionNode = getXPathAPI()->selectSingleNode(root, sExpression); OSL_ASSERT(! _extensionNode.is()); #endif Reference componentElement( - doc->createElement(OUSTR("component"))); + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":component"))); componentElement->setAttribute(OUSTR("url"), url); @@ -92,18 +99,8 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data root->appendChild(componentNode); -// Reference name( -// doc->createElement(OUSTR("name")), UNO_QUERY_THROW); - -// componentNode->appendChild(name); - -// Reference nameValue( -// doc->createTextNode(data.name), -// UNO_QUERY_THROW); -// name->appendChild(nameValue); - Reference javaTypeLibNode( - doc->createElement(OUSTR("java-type-library")), UNO_QUERY_THROW); + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":java-type-library")), UNO_QUERY_THROW); componentNode->appendChild(javaTypeLibNode); @@ -114,16 +111,16 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data writeSimpleList( data.implementationNames, - OUSTR("implementation-names"), - OUSTR("name"), + sPrefix + OUSTR(":implementation-names"), + sPrefix + OUSTR(":name"), componentNode); writeVectorOfPair( data.singletons, - OUSTR("singletons"), - OUSTR("item"), - OUSTR("key"), - OUSTR("value"), + sPrefix + OUSTR(":singletons"), + sPrefix + OUSTR(":item"), + sPrefix + OUSTR(":key"), + sPrefix + OUSTR(":value"), componentNode); save(); @@ -140,7 +137,7 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data void ComponentBackendDb::removeEntry(::rtl::OUString const & url) { OUString sExpression( - OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + OUSTR(NS_PREFIX) + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); removeElement(sExpression); } @@ -148,9 +145,10 @@ ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & ur { try { + const OUString sPrefix = getNSPrefix(); ComponentBackendDb::Data retData; const OUString sExpression( - OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); Reference doc = getDocument(); Reference root = doc->getFirstChild(); @@ -160,13 +158,7 @@ ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & ur xpathApi->selectSingleNode(root, sExpression); if (aNode.is()) { -// const OUString sExprName(OUSTR("reg:name/text()")); - -// Reference nameValue = -// xpathApi->selectSingleNode(aNode, sExprName); -// retData.name = nameValue->getNodeValue(); - - const OUString sExprJavaTypeLib(OUSTR("reg:java-type-library/text()")); + const OUString sExprJavaTypeLib(sPrefix + OUSTR(":java-type-library/text()")); Reference idValueNode = xpathApi->selectSingleNode(aNode, sExprJavaTypeLib); @@ -175,12 +167,17 @@ ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & ur retData.implementationNames = readList( - aNode, OUSTR("reg:implementation-names"), OUSTR("reg:name")); + aNode, + sPrefix + OUSTR(":implementation-names"), + sPrefix + OUSTR(":name")); retData.singletons = readVectorOfPair( - aNode, OUSTR("reg:singletons"), OUSTR("item"), OUSTR("key"), - OUSTR("value")); + aNode, + sPrefix + OUSTR(":singletons"), + sPrefix + OUSTR(":item"), + sPrefix + OUSTR(":key"), + sPrefix + OUSTR(":value")); } return retData; } diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx index 29ac4e50fe88..90ff41f2a4b8 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx @@ -83,7 +83,7 @@ class ComponentBackendDb: public dp_registry::backend::BackendDb { protected: virtual ::rtl::OUString getDbNSName(); - + virtual ::rtl::OUString getNSPrefix(); virtual ::rtl::OUString getRootElementName(); public: diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 7ee49fc46734..dcfc2c6b3d2f 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -31,13 +31,18 @@ #include "dp_backend.h" #include "dp_ucb.h" #include "rtl/uri.hxx" +#include "osl/file.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/servicedecl.hxx" #include "comphelper/unwrapargs.hxx" #include "ucbhelper/content.hxx" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" #include "com/sun/star/deployment/InvalidRemovedParameterException.hpp" +#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp" +#include "com/sun/star/ucb/IOErrorCode.hpp" #include "com/sun/star/beans/StringPair.hpp" +#include "com/sun/star/sdbc/XResultSet.hpp" +#include "com/sun/star/sdbc/XRow.hpp" using namespace ::dp_misc; @@ -208,6 +213,87 @@ Reference PackageRegistryBackend::bindPackage( return xNewPackage; } +OUString PackageRegistryBackend::createFolder( + OUString const & relUrl, + Reference const & xCmdEnv) +{ + OUString sDataFolder = makeURL(getCachePath(), relUrl); + //make sure the folder exist + ucbhelper::Content dataContent; + ::dp_misc::create_folder(&dataContent, sDataFolder, xCmdEnv); + + OUString sDataFolderURL = dp_misc::expandUnoRcUrl(sDataFolder); + + OUString tempEntry; + if (::osl::File::createTempFile( + &sDataFolderURL, 0, &tempEntry ) != ::osl::File::E_None) + throw RuntimeException( + OUSTR("::osl::File::createTempFile() failed!"), 0 ); + tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 ); + OUString destFolder= makeURL(sDataFolder, tempEntry) + OUSTR("_"); + ::ucbhelper::Content destFolderContent; + dp_misc::create_folder( &destFolderContent, destFolder, xCmdEnv ); + + return destFolder; +} + +void PackageRegistryBackend::deleteUnusedFolders( + OUString const & relUrl, + ::std::list< OUString> const & usedFolders) +{ + try + { + const OUString sDataFolder = makeURL(getCachePath(), relUrl); + ::ucbhelper::Content tempFolder( + sDataFolder, Reference()); + Reference xResultSet( + tempFolder.createCursor( + Sequence( &StrTitle::get(), 1 ), + ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); + // get all temp directories: + ::std::vector tempEntries; + + char tmp[] = ".tmp"; + + while (xResultSet->next()) + { + OUString title( + Reference( + xResultSet, UNO_QUERY_THROW )->getString( + 1 /* Title */ ) ); + + if (title.endsWithAsciiL(tmp, sizeof(tmp) - 1)) + tempEntries.push_back( + makeURLAppendSysPathSegment(sDataFolder, title)); + } + + for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos ) + { + //usedFolders contains the urls to the folders which have + //a trailing underscore + const OUString tempFile = tempEntries[ pos ]; + const OUString tempFolder = tempFile + OUSTR("_"); + + if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolder ) == + usedFolders.end()) + { + erase_path( tempFolder, Reference(), + false /* no throw: ignore errors */ ); + erase_path( tempFile, Reference(), + false /* no throw: ignore errors */ ); + } + } + } + catch (ucb::InteractiveAugmentedIOException& e) + { + //In case the folder containing all the data folder does not + //exist yet, we ignore the exception + if (e.Code != ucb::IOErrorCode_NOT_EXISTING) + throw e; + } + +} + //############################################################################## //______________________________________________________________________________ diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 339236126796..1c0451c77cd6 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -98,9 +98,10 @@ css::uno::Reference BackendDb::getDocument() //Create a new document and insert some basic stuff m_doc = xDocBuilder->newDocument(); Reference rootNode = - m_doc->createElement(getRootElementName()); - rootNode->setAttribute( - OUSTR("xmlns"), getDbNSName()); + m_doc->createElementNS(getDbNSName(), getNSPrefix() + + OUSTR(":") + getRootElementName()); +// rootNode->setAttribute( +// OUSTR("xmlns"), getDbNSName()); m_doc->appendChild(Reference( rootNode, UNO_QUERY_THROW)); save(); @@ -133,23 +134,12 @@ Reference BackendDb::getXPathAPI() OUSTR(" Could not create service com.sun.star.xml.xpath.XPathAPI"), 0); m_xpathApi->registerNS( - OUSTR("reg"), getDbNSName()); + getNSPrefix(), getDbNSName()); } return m_xpathApi; } -// OUString BackendDb::getDbNSName() -// { -// return OUString(); -// } - - -// OUString BackendDb::getRootElementName() -// { -// return OUString(); -// } - void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) { try @@ -193,12 +183,13 @@ void BackendDb::writeVectorOfPair( css::uno::Reference const & xParent) { try{ - + const OUString sNameSpace = getDbNSName(); + OSL_ASSERT(sNameSpace.getLength()); Reference doc = getDocument(); Reference root = doc->getFirstChild(); Reference vectorNode( - doc->createElement(sVectorTagName)); + doc->createElementNS(sNameSpace, sVectorTagName)); xParent->appendChild( Reference( @@ -207,14 +198,14 @@ void BackendDb::writeVectorOfPair( for (CIT i = vecPairs.begin(); i != vecPairs.end(); i++) { Reference pairNode( - doc->createElement(sPairTagName)); + doc->createElementNS(sNameSpace, sPairTagName)); vectorNode->appendChild( Reference( pairNode, css::uno::UNO_QUERY_THROW)); Reference firstNode( - doc->createElement(sFirstTagName)); + doc->createElementNS(sNameSpace, sFirstTagName)); pairNode->appendChild( Reference( @@ -228,7 +219,7 @@ void BackendDb::writeVectorOfPair( firstTextNode, css::uno::UNO_QUERY_THROW)); Reference secondNode( - doc->createElement(sSecondTagName)); + doc->createElementNS(sNameSpace, sSecondTagName)); pairNode->appendChild( Reference( @@ -304,10 +295,11 @@ void BackendDb::writeSimpleList( { try { + const OUString sNameSpace = getDbNSName(); Reference doc = getDocument(); Reference listNode( - doc->createElement(sListTagName)); + doc->createElementNS(sNameSpace, sListTagName)); xParent->appendChild( Reference( @@ -317,7 +309,7 @@ void BackendDb::writeSimpleList( for (ITC_ITEMS i = list.begin(); i != list.end(); i++) { Reference memberNode( - doc->createElement(sMemberTagName), css::uno::UNO_QUERY_THROW); + doc->createElementNS(sNameSpace, sMemberTagName), css::uno::UNO_QUERY_THROW); listNode->appendChild(memberNode); diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 0b3b9e80a7d7..e35b37bdeb07 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -115,6 +115,7 @@ protected: virtual ~PackageRegistryImpl(); PackageRegistryImpl() : t_helper( getMutex() ) {} + public: static Reference create( OUString const & context, @@ -536,7 +537,6 @@ PackageRegistryImpl::getSupportedPackageTypes() throw (RuntimeException) { return comphelper::containerToSequence(m_typesInfos); } - } // anon namespace //============================================================================== diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 9fd9e7ae79fc..b594f9395ceb 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -30,9 +30,11 @@ #include "dp_help.hrc" #include "dp_backend.h" +#include "dp_helpbackenddb.hxx" #include "dp_ucb.h" #include "rtl/uri.hxx" #include "osl/file.hxx" +#include "rtl/bootstrap.hxx" #include "ucbhelper/content.hxx" #include "comphelper/servicedecl.hxx" #include "svl/inettype.hxx" @@ -45,6 +47,7 @@ #include #include + using namespace ::dp_misc; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -63,6 +66,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend { BackendImpl * getMyBackend() const; + HelpBackendDb::Data m_dbData; + // Package virtual beans::Optional< beans::Ambiguous > isRegistered_( ::osl::ResettableMutexGuard & guard, @@ -79,9 +84,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool bRemoved, OUString const & identifier) - : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) - {} + bool bRemoved, OUString const & identifier); }; friend class PackageImpl; @@ -91,18 +94,25 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); - void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage ); + void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage, + Reference const & xCmdEnv); void implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ); rtl::OUString getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ); rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); rtl::OUString getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ); rtl::OUString expandURL( const rtl::OUString& aURL ); + + void addDataToDb(OUString const & url, HelpBackendDb::Data const & data); + HelpBackendDb::Data readDataFromDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + Reference< ucb::XSimpleFileAccess > getFileAccess( void ); Reference< ucb::XSimpleFileAccess > m_xSFA; const Reference m_xHelpTypeInfo; Sequence< Reference > m_typeInfos; + std::auto_ptr m_backendDb; public: BackendImpl( Sequence const & args, @@ -126,6 +136,20 @@ BackendImpl::BackendImpl( m_typeInfos( 1 ) { m_typeInfos[ 0 ] = m_xHelpTypeInfo; + if (!transientMode()) + { + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new HelpBackendDb(getComponentContext(), dbFile)); + + //clean up data folders which are no longer used. + //This must not be done in the same process where the help files + //are still registers. Only after revoking and restarting OOo the folders + //can be removed. This works now, because the extension manager is a singleton + //and the backends are only create once per process. + ::std::list folders = m_backendDb->getAllDataUrls(); + deleteUnusedFolders(OUString(), folders); + } } // XPackageRegistry @@ -177,8 +201,39 @@ Reference BackendImpl::bindPackage_( static_cast(-1) ); } +void BackendImpl::addDataToDb( + OUString const & url, HelpBackendDb::Data const & data) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url, data); +} + +HelpBackendDb::Data BackendImpl::readDataFromDb( + OUString const & url) +{ + HelpBackendDb::Data data; + if (m_backendDb.get()) + data = m_backendDb->getEntry(url); + return data; +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} //############################################################################## +BackendImpl::PackageImpl::PackageImpl( + ::rtl::Reference const & myBackend, + OUString const & url, OUString const & name, + Reference const & xPackageType, + bool bRemoved, OUString const & identifier) + : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) +{ + if (bRemoved) + m_dbData = getMyBackend()->readDataFromDb(url); +} // Package BackendImpl * BackendImpl::PackageImpl::getMyBackend() const @@ -226,7 +281,14 @@ void BackendImpl::PackageImpl::processPackage_( BackendImpl* that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - that->implProcessHelp( xThisPackage, doRegisterPackage ); + that->implProcessHelp( xThisPackage, doRegisterPackage, xCmdEnv); + +// HelpBackendDb::Data data; +// getMyBackend()->addDataToDb(getURL(), data); + +// } +// else +// getMyBackend()->deleteDataFromDb(getURL()); } //############################################################################## @@ -234,235 +296,246 @@ void BackendImpl::PackageImpl::processPackage_( static rtl::OUString aSlash( rtl::OUString::createFromAscii( "/" ) ); static rtl::OUString aHelpStr( rtl::OUString::createFromAscii( "help" ) ); + void BackendImpl::implProcessHelp - ( Reference< deployment::XPackage > xPackage, bool doRegisterPackage ) +( Reference< deployment::XPackage > xPackage, bool doRegisterPackage, + Reference const & xCmdEnv) { - if( !xPackage.is() ) - return; - - Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); - - rtl::OUString aRegisteredFlagFile = getRegisteredFlagFileURL( xPackage ); - if( !doRegisterPackage ) + OSL_ASSERT(xPackage.is()); + if (doRegisterPackage) { - if( xSFA->exists( aRegisteredFlagFile ) ) - xSFA->kill( aRegisteredFlagFile ); - return; - } + HelpBackendDb::Data data; + Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); - bool bCompile = true; - rtl::OUString aCompiledFlagFile = getCompiledFlagFileURL( xPackage ); - if( xSFA->exists( aCompiledFlagFile ) ) - bCompile = false; - - if( bCompile ) - { - rtl::OUString aHelpURL = xPackage->getURL(); - rtl::OUString aExpandedHelpURL = expandURL( aHelpURL ); - rtl::OUString aName = xPackage->getName(); - if( !xSFA->isFolder( aExpandedHelpURL ) ) + rtl::OUString aRegisteredFlagFile = getRegisteredFlagFileURL( xPackage ); + if( !doRegisterPackage ) { - rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); - aErrStr += rtl::OUString::createFromAscii( "No help folder" ); - OWeakObject* oWeakThis = static_cast(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + if( xSFA->exists( aRegisteredFlagFile ) ) + xSFA->kill( aRegisteredFlagFile ); + return; } - Reference const & xContext = getComponentContext(); - Reference< script::XInvocation > xInvocation; - if( xContext.is() ) + bool bCompile = true; + rtl::OUString aCompiledFlagFile = getCompiledFlagFileURL( xPackage ); + if( xSFA->exists( aCompiledFlagFile ) ) + bCompile = false; + + if( bCompile ) { - try + OUString sHelpFolder = createFolder(OUString(), xCmdEnv); + data.dataUrl = sHelpFolder; + rtl::OUString aHelpURL = xPackage->getURL(); + rtl::OUString aExpandedHelpURL = expandURL( aHelpURL ); + rtl::OUString aName = xPackage->getName(); + if( !xSFA->isFolder( aExpandedHelpURL ) ) { - xInvocation = Reference< script::XInvocation >( - xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); + rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); + aErrStr += rtl::OUString::createFromAscii( "No help folder" ); + OWeakObject* oWeakThis = static_cast(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } - catch (Exception &) + + Reference const & xContext = getComponentContext(); + Reference< script::XInvocation > xInvocation; + if( xContext.is() ) { - // i98680: Survive missing lucene + try + { + xInvocation = Reference< script::XInvocation >( + xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( + "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); + } + catch (Exception &) + { + // i98680: Survive missing lucene + } } - } - // Scan languages - Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); - sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); - const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); - for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) - { - rtl::OUString aLangURL = pSeq[iLang]; - if( xSFA->isFolder( aLangURL ) ) + // Scan languages + Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); + sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); + const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); + for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) { - std::vector< rtl::OUString > aXhpFileVector; - - // Delete (old) files in any case to allow compiler to be started every time - rtl::OUString aLangWithPureNameURL( aLangURL ); - aLangWithPureNameURL += aSlash; - aLangWithPureNameURL += aHelpStr; - rtl::OUString aDbFile( aLangWithPureNameURL ); - aDbFile += rtl::OUString::createFromAscii( ".db" ); - if( xSFA->exists( aDbFile ) ) - xSFA->kill( aDbFile ); - rtl::OUString aHtFile( aLangWithPureNameURL ); - aHtFile += rtl::OUString::createFromAscii( ".ht" ); - if( xSFA->exists( aHtFile ) ) - xSFA->kill( aHtFile ); - rtl::OUString aKeyFile( aLangWithPureNameURL ); - aKeyFile += rtl::OUString::createFromAscii( ".key" ); - if( xSFA->exists( aKeyFile ) ) - xSFA->kill( aKeyFile ); - - // calculate jar file URL - rtl::OUString aJarFile( aLangURL ); - aJarFile += aSlash; - aJarFile += aHelpStr; - aJarFile += rtl::OUString::createFromAscii( ".jar" ); - // remove in any case to clean up - if( xSFA->exists( aJarFile ) ) - xSFA->kill( aJarFile ); - - rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( aJarFile, - rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ); - rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" ); - aDestBasePath += aEncodedJarFilePath; - aDestBasePath += rtl::OUString::createFromAscii( "/" ); - - sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; - - Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); - sal_Int32 nSubLangCount = aSubLangSeq.getLength(); - const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); - for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) + rtl::OUString aLangURL = pSeq[iLang]; + if( xSFA->isFolder( aLangURL ) ) { - rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; - if( !xSFA->isFolder( aSubFolderURL ) ) - continue; + std::vector< rtl::OUString > aXhpFileVector; + + // Delete (old) files in any case to allow compiler to be started every time + rtl::OUString aLangWithPureNameURL( aLangURL ); + aLangWithPureNameURL += aSlash; + aLangWithPureNameURL += aHelpStr; + rtl::OUString aDbFile( aLangWithPureNameURL ); + aDbFile += rtl::OUString::createFromAscii( ".db" ); + if( xSFA->exists( aDbFile ) ) + xSFA->kill( aDbFile ); + rtl::OUString aHtFile( aLangWithPureNameURL ); + aHtFile += rtl::OUString::createFromAscii( ".ht" ); + if( xSFA->exists( aHtFile ) ) + xSFA->kill( aHtFile ); + rtl::OUString aKeyFile( aLangWithPureNameURL ); + aKeyFile += rtl::OUString::createFromAscii( ".key" ); + if( xSFA->exists( aKeyFile ) ) + xSFA->kill( aKeyFile ); + + // calculate jar file URL + rtl::OUString aJarFile( aLangURL ); + aJarFile += aSlash; + aJarFile += aHelpStr; + aJarFile += rtl::OUString::createFromAscii( ".jar" ); + // remove in any case to clean up + if( xSFA->exists( aJarFile ) ) + xSFA->kill( aJarFile ); + + rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( aJarFile, + rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ); + rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" ); + aDestBasePath += aEncodedJarFilePath; + aDestBasePath += rtl::OUString::createFromAscii( "/" ); + + sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; + + Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); + sal_Int32 nSubLangCount = aSubLangSeq.getLength(); + const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); + for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) + { + rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; + if( !xSFA->isFolder( aSubFolderURL ) ) + continue; - implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); + implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); - // Copy to package (later: move?) - rtl::OUString aDestPath = aDestBasePath; - rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); - aDestPath += aPureFolderName; - xSFA->copy( aSubFolderURL, aDestPath ); - } + // Copy to package (later: move?) + rtl::OUString aDestPath = aDestBasePath; + rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); + aDestPath += aPureFolderName; + xSFA->copy( aSubFolderURL, aDestPath ); + } - // Call compiler - sal_Int32 nXhpFileCount = aXhpFileVector.size(); - rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; - for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) - { - rtl::OUString aXhpFile = aXhpFileVector[iXhp]; - rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); - pXhpFiles[iXhp] = aXhpRelFile; - } + // Call compiler + sal_Int32 nXhpFileCount = aXhpFileVector.size(); + rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; + for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) + { + rtl::OUString aXhpFile = aXhpFileVector[iXhp]; + rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); + pXhpFiles[iXhp] = aXhpRelFile; + } - rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); - rtl::OUString aOfficeHelpPathFileURL; - ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); + rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); + rtl::OUString aOfficeHelpPathFileURL; + ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); - HelpProcessingErrorInfo aErrorInfo; - bool bSuccess = compileExtensionHelp( aOfficeHelpPathFileURL, aHelpStr, aLangURL, - nXhpFileCount, pXhpFiles, aErrorInfo ); + HelpProcessingErrorInfo aErrorInfo; + bool bSuccess = compileExtensionHelp( aOfficeHelpPathFileURL, aHelpStr, aLangURL, + nXhpFileCount, pXhpFiles, aErrorInfo ); - if( bSuccess && xInvocation.is() ) - { - Sequence aParamsSeq( 6 ); - - aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); - - rtl::OUString aLang; - sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); - if( nLastSlash != -1 ) - aLang = aLangURL.copy( nLastSlash + 1 ); - else - aLang = rtl::OUString::createFromAscii( "en" ); - aParamsSeq[1] = uno::makeAny( aLang ); - - aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); - aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); - - aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); - rtl::OUString aSystemPath; - osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); - aParamsSeq[5] = uno::makeAny( aSystemPath ); - - Sequence< sal_Int16 > aOutParamIndex; - Sequence< uno::Any > aOutParam; - uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), - aParamsSeq, aOutParamIndex, aOutParam ); - } + if( bSuccess && xInvocation.is() ) + { + Sequence aParamsSeq( 6 ); + + aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); + + rtl::OUString aLang; + sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); + if( nLastSlash != -1 ) + aLang = aLangURL.copy( nLastSlash + 1 ); + else + aLang = rtl::OUString::createFromAscii( "en" ); + aParamsSeq[1] = uno::makeAny( aLang ); + + aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); + aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); + + aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); + rtl::OUString aSystemPath; + osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); + aParamsSeq[5] = uno::makeAny( aSystemPath ); + + Sequence< sal_Int16 > aOutParamIndex; + Sequence< uno::Any > aOutParam; + uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), + aParamsSeq, aOutParamIndex, aOutParam ); + } - if( !bSuccess ) - { - USHORT nErrStrId = 0; - switch( aErrorInfo.m_eErrorClass ) + if( !bSuccess ) { + USHORT nErrStrId = 0; + switch( aErrorInfo.m_eErrorClass ) + { case HELPPROCESSING_GENERAL_ERROR: case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break; case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break; default: ; - }; + }; - rtl::OUString aErrStr; - if( nErrStrId != 0 ) - { - aErrStr = getResourceString( nErrStrId ); - - // Remoce CR/LF - rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); - sal_Unicode nCR = 13, nLF = 10; - sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); - sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); - sal_Int32 nCopy; - if( nSearchCR != -1 || nSearchLF != -1 ) + rtl::OUString aErrStr; + if( nErrStrId != 0 ) { - if( nSearchCR == -1 ) - nCopy = nSearchLF; - else if( nSearchLF == -1 ) - nCopy = nSearchCR; - else - nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; - - aErrMsg = aErrMsg.copy( 0, nCopy ); - } - aErrStr += aErrMsg; - if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) - { - aErrStr += rtl::OUString::createFromAscii( " in " ); - - rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - aErrStr += aDecodedFile; - if( aErrorInfo.m_nXMLParsingLine != -1 ) + aErrStr = getResourceString( nErrStrId ); + + // Remoce CR/LF + rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); + sal_Unicode nCR = 13, nLF = 10; + sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); + sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); + sal_Int32 nCopy; + if( nSearchCR != -1 || nSearchLF != -1 ) { - aErrStr += rtl::OUString::createFromAscii( ", line " ); - aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); + if( nSearchCR == -1 ) + nCopy = nSearchLF; + else if( nSearchLF == -1 ) + nCopy = nSearchCR; + else + nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; + + aErrMsg = aErrMsg.copy( 0, nCopy ); + } + aErrStr += aErrMsg; + if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) + { + aErrStr += rtl::OUString::createFromAscii( " in " ); + + rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); + aErrStr += aDecodedFile; + if( aErrorInfo.m_nXMLParsingLine != -1 ) + { + aErrStr += rtl::OUString::createFromAscii( ", line " ); + aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); + } } } - } - OWeakObject* oWeakThis = static_cast(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + OWeakObject* oWeakThis = static_cast(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + } } } - } - // Write compiled flag file (this code is only reached in case of success) - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aCompiledFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); + // Write compiled flag file (this code is only reached in case of success) + Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aCompiledFlagFile ); + if( xOutputStream.is() ) + xOutputStream->closeOutput(); - } // if( bCompile ) + } // if( bCompile ) - // Write registered flag file (this code is only reached in case of success) - if( !xSFA->exists( aRegisteredFlagFile ) ) + // Write registered flag file (this code is only reached in case of success) + if( !xSFA->exists( aRegisteredFlagFile ) ) + { + Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile ); + if( xOutputStream.is() ) + xOutputStream->closeOutput(); + } + addDataToDb(xPackage->getURL(), data); + } + else { - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); + deleteDataFromDb(xPackage->getURL()); } } diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx new file mode 100644 index 000000000000..6f7e1d2844ac --- /dev/null +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -0,0 +1,224 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_package.cxx,v $ + * $Revision: 1.34.16.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_helpbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/help-registry/2010" +#define NS_PREFIX "help" +#define ROOT_ELEMENT_NAME "help-backend-db" + +namespace dp_registry { +namespace backend { +namespace help { + +HelpBackendDb::HelpBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString HelpBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString HelpBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + +OUString HelpBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + Reference helpElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":help"))); + + helpElement->setAttribute(OUSTR("url"), url); + + Reference helpNode( + helpElement, UNO_QUERY_THROW); + root->appendChild(helpNode); + + Reference dataNode( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")), + UNO_QUERY_THROW); + helpNode->appendChild(dataNode); + + Reference dataValue( + doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); + dataNode->appendChild(dataValue); + +// writeSimpleList( +// data.implementationNames, +// OUSTR("implementation-names"), +// OUSTR("name"), +// componentNode); + +// writeVectorOfPair( +// data.singletons, +// OUSTR("singletons"), +// OUSTR("item"), +// OUSTR("key"), +// OUSTR("value"), +// componentNode); + + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +void HelpBackendDb::removeEntry(::rtl::OUString const & url) +{ + OUString sExpression( + OUSTR(NS_PREFIX) + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); + removeElement(sExpression); +} + +HelpBackendDb::Data HelpBackendDb::getEntry(::rtl::OUString const & url) +{ + try + { + const OUString sPrefix = getNSPrefix(); + HelpBackendDb::Data retData; + const OUString sExpression( + sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (aNode.is()) + { + const OUString sExprDataUrl(sPrefix + OUSTR(":data-url/text()")); + + Reference dataUrlVal = + xpathApi->selectSingleNode(aNode, sExprDataUrl); + retData.dataUrl = dataUrlVal->getNodeValue(); + +// retData.implementationNames = +// readList( +// aNode, OUSTR("reg:implementation-names"), OUSTR("reg:name")); + +// retData.singletons = +// readVectorOfPair( +// aNode, OUSTR("reg:singletons"), OUSTR("item"), OUSTR("key"), +// OUSTR("value")); + } + return retData; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +::std::list HelpBackendDb::getAllDataUrls() +{ + try + { + ::std::list listRet; + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + const OUString sPrefix = getNSPrefix(); + OUString sExpression( + sPrefix + OUSTR(":help/") + sPrefix + OUSTR(":data-url/text()")); + Reference nodes = + xpathApi->selectNodeList(root, sExpression); + if (nodes.is()) + { + sal_Int32 length = nodes->getLength(); + for (sal_Int32 i = 0; i < length; i++) + listRet.push_back(nodes->item(i)->getNodeValue()); + } + return listRet; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + + +} // namespace help +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx new file mode 100644 index 000000000000..e80a24f85ab1 --- /dev/null +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_backend.h,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_HELPBACKENDDB_HXX +#define INCLUDED_DP_HELPBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { +namespace help { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + The format looks like this: + + + */ +class HelpBackendDb: public dp_registry::backend::BackendDb +{ +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getNSPrefix(); + + virtual ::rtl::OUString getRootElementName(); + +public: + struct Data + { + /* the URL to the folder containing the compiled help files, etc. + */ + ::rtl::OUString dataUrl; + + }; + +public: + + HelpBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url, Data const & data); + void removeEntry(::rtl::OUString const & url); + Data getEntry(::rtl::OUString const & url); + ::std::list< ::rtl::OUString> getAllDataUrls(); + +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/help/makefile.mk b/desktop/source/deployment/registry/help/makefile.mk index ba904bb7f28a..d4934f71a46f 100644 --- a/desktop/source/deployment/registry/help/makefile.mk +++ b/desktop/source/deployment/registry/help/makefile.mk @@ -44,7 +44,8 @@ SRC1FILES = \ dp_help.src SLOFILES = \ - $(SLO)$/dp_help.obj + $(SLO)$/dp_help.obj \ + $(SLO)$/dp_helpbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 371faf579caf..24c6e4914fe1 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -43,6 +43,7 @@ #include "com/sun/star/deployment/InvalidRemovedParameterException.hpp" #include #include +#include #include "dp_registry.hrc" namespace dp_registry @@ -314,6 +315,23 @@ protected: css::uno::Sequence const & args, css::uno::Reference const & xContext ); + /* creates a folder with a unique name. + If url is empty then it is created in the the backend folder, otherwise + at a location relative to that folder specified by url. + */ + ::rtl::OUString createFolder( + ::rtl::OUString const & relUrl, + css::uno::Reference const & xCmdEnv); + /* deletes folders and files. + + All folder all files which end with ".tmp" or ".tmp_" and which are + not used are deleted. + */ + void deleteUnusedFolders( + ::rtl::OUString const & relUrl, + ::std::list< ::rtl::OUString> const & usedFolders); + + public: struct StrRegisteringPackage : public ::dp_misc::StaticResourceString< StrRegisteringPackage, RID_STR_REGISTERING_PACKAGE> {}; diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index dbac54e10c6d..ca28f28ac390 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -109,6 +109,11 @@ protected: into the root element. */ virtual ::rtl::OUString getDbNSName()=0; + /* return the namespace prefix which is to be registered with the XPath API. + + The prefix can then be used in XPath expressions. + */ + virtual ::rtl::OUString getNSPrefix()=0; /* returns the name of the root element without any namespace prefix. */ virtual ::rtl::OUString getRootElementName()=0; diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx index 93aa62174e0f..99aa2178b421 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -44,6 +44,7 @@ using namespace ::com::sun::star::uno; using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010" +#define NS_PREFIX "ext" #define ROOT_ELEMENT_NAME "extension-backend-db" namespace dp_registry { @@ -62,6 +63,11 @@ OUString ExtensionBackendDb::getDbNSName() return OUSTR(EXTENSION_REG_NS); } +OUString ExtensionBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + OUString ExtensionBackendDb::getRootElementName() { return OUSTR(ROOT_ELEMENT_NAME); @@ -71,20 +77,23 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data { try{ + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); Reference doc = getDocument(); Reference root = doc->getFirstChild(); #if OSL_DEBUG_LEVEL > 0 //There must not be yet an entry with the same url OUString sExpression( - OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); Reference _extensionNode = getXPathAPI()->selectSingleNode(root, sExpression); OSL_ASSERT(! _extensionNode.is()); #endif // Reference extensionNode( - doc->createElement(OUSTR("extension"))); + doc->createElementNS(sNameSpace, + sPrefix + OUSTR(":extension"))); extensionNode->setAttribute(OUSTR("url"), url); @@ -92,22 +101,12 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data extensionNode, css::uno::UNO_QUERY_THROW); root->appendChild(extensionNodeNode); - // ... -// Reference identifierNode( -// doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); -// extensionNodeNode->appendChild(identifierNode); - -// Reference identifierValue( -// doc->createTextNode(data.identifier), UNO_QUERY_THROW); -// identifierNode->appendChild(identifierValue); - - writeVectorOfPair( data.items, - OUSTR("extension-items"), - OUSTR("item"), - OUSTR("url"), - OUSTR("media-type"), + sPrefix + OUSTR(":extension-items"), + sPrefix + OUSTR(":item"), + sPrefix + OUSTR(":url"), + sPrefix + OUSTR(":media-type"), extensionNodeNode); save(); } @@ -123,7 +122,7 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data void ExtensionBackendDb::removeEntry(::rtl::OUString const & url) { OUString sExpression( - OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + OUSTR(NS_PREFIX) + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); removeElement(sExpression); } @@ -131,9 +130,10 @@ ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & ur { try { + const OUString sPrefix = getNSPrefix(); ExtensionBackendDb::Data retData; const OUString sExpression( - OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); Reference doc = getDocument(); Reference root = doc->getFirstChild(); @@ -143,17 +143,13 @@ ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & ur xpathApi->selectSingleNode(root, sExpression); if (aNode.is()) { -// const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); - -// Reference idValueNode = -// xpathApi->selectSingleNode(aNode, sExprIdentifier); -// retData.identifier = idValueNode->getNodeValue(); - retData.items = readVectorOfPair( aNode, - OUSTR("reg:extension-items"), - OUSTR("reg:item"), OUSTR("reg:url"), OUSTR("reg:media-type")); + sPrefix + OUSTR(":extension-items"), + sPrefix + OUSTR(":item"), + sPrefix + OUSTR(":url"), + sPrefix + OUSTR(":media-type")); } return retData; } diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx index 4afe6f1a5577..e46c67b166de 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx @@ -60,7 +60,7 @@ class ExtensionBackendDb: public dp_registry::backend::BackendDb { protected: virtual ::rtl::OUString getDbNSName(); - + virtual ::rtl::OUString getNSPrefix(); virtual ::rtl::OUString getRootElementName(); public: -- cgit From e955e6941dcf5784f44d64ec753041a4dc6cf37e Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 24 Mar 2010 08:27:52 +0100 Subject: jl152 import 263442 from native0jl:#i77196# new add, remove and update are now supported from extension manager --- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 17 +++-- .../source/deployment/gui/dp_gui_extlistbox.cxx | 4 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 85 ++++++++++++++++------ desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 4 + 4 files changed, 82 insertions(+), 28 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 89a5ae1e22c8..a617e07758c7 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -946,11 +946,12 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv try { - uno::Reference< deployment::XPackage > xPackage( xPackageManager->addPackage( - rPackageURL, OUString() /* detect media-type */, - xAbortChannel, rCmdEnv.get() ) ); + OUString sPackageManager = xPackageManager->getContext(); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< deployment::XPackage > xPackage( xExtMgr->addExtension( rPackageURL, sPackageManager, + xAbortChannel, rCmdEnv.get() ) ); OSL_ASSERT( xPackage.is() ); - } + } catch ( ucb::CommandFailedException & ) { // When the extension is already installed we'll get a dialog asking if we want to overwrite. If we then press @@ -976,8 +977,14 @@ void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdE OUString id( dp_misc::getIdentifier( xPackage ) ); try { - xPackageManager->removePackage( id, xPackage->getName(), xAbortChannel, rCmdEnv.get() ); + OUString sPackageManager = xPackageManager->getContext(); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + xExtMgr->removeExtension( id, xPackage->getName(), sPackageManager, xAbortChannel, rCmdEnv.get() ); } + catch ( deployment::DeploymentException & ) + {} + catch ( ucb::CommandFailedException & ) + {} catch ( ucb::CommandAbortedException & ) {} diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 2e02a90f59fd..6793b6e1e0ab 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -951,7 +951,7 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & if ( m_vEntries.empty() ) { pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bShared = ( m_pManager->getSharedPkgMgr() == xPackageManager ); + pEntry->m_bShared = ( m_pManager->getUserPkgMgr() != xPackageManager ); pEntry->m_bNew = m_bInCheckMode; m_vEntries.push_back( pEntry ); } @@ -960,7 +960,7 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & if ( !FindEntryPos( pEntry, 0, m_vEntries.size()-1, nPos ) ) { pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bShared = ( m_pManager->getSharedPkgMgr() == xPackageManager ); + pEntry->m_bShared = ( m_pManager->getUserPkgMgr() != xPackageManager ); pEntry->m_bNew = m_bInCheckMode; m_vEntries.insert( m_vEntries.begin()+nPos, pEntry ); } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 796918202a52..7519ab8a1dc8 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -47,6 +47,10 @@ #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) +#define USER_PACKAGE_MANAGER OUSTR("user") +#define SHARED_PACKAGE_MANAGER OUSTR("shared") +#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") + using namespace ::com::sun::star; using ::rtl::OUString; @@ -67,15 +71,18 @@ TheExtensionManager::TheExtensionManager( Window *pParent, m_pExtMgrDialog( NULL ), m_pUpdReqDialog( NULL ) { - m_sPackageManagers.realloc(2); - m_sPackageManagers[0] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( OUSTR("user") ); - m_sPackageManagers[1] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( OUSTR("shared") );; + m_sPackageManagers.realloc(3); + m_sPackageManagers[0] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( USER_PACKAGE_MANAGER ); + m_sPackageManagers[1] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( SHARED_PACKAGE_MANAGER ); + m_sPackageManagers[2] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( BUNDLED_PACKAGE_MANAGER ); for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i ) { m_sPackageManagers[i]->addModifyListener( this ); } + m_xExtensionManager = deployment::ExtensionManager::get( xContext ); + uno::Reference< lang::XMultiServiceFactory > xConfig( xContext->getServiceManager()->createInstanceWithContext( OUSTR("com.sun.star.configuration.ConfigurationProvider"), xContext ), uno::UNO_QUERY_THROW); @@ -206,26 +213,34 @@ bool TheExtensionManager::isVisible() bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bParentVisible*/ ) { std::vector< TUpdateListEntry > vEntries; + uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; - for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i ) + try { + xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ); + } catch ( deployment::DeploymentException & ) { + return false; + } catch ( ucb::CommandFailedException & ) { + return false; + } catch ( ucb::CommandAbortedException & ) { + return false; + } catch ( lang::IllegalArgumentException & e ) { + throw uno::RuntimeException( e.Message, e.Context ); + } + + for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - uno::Sequence< uno::Reference< deployment::XPackage > > xPackages; - try { - xPackages = m_sPackageManagers[i]->getDeployedPackages( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ); - for ( sal_Int32 k = 0; k < xPackages.getLength(); ++k ) + uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; + + for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) + { + uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; + if ( xPackage.is() ) { - TUpdateListEntry pEntry( new UpdateListEntry( xPackages[k], m_sPackageManagers[i] ) ); + TUpdateListEntry pEntry( new UpdateListEntry( xPackage, m_sPackageManagers[j] ) ); vEntries.push_back( pEntry ); + break; } - } catch ( deployment::DeploymentException & ) { - continue; - } catch ( ucb::CommandFailedException & ) { - continue; - } catch ( ucb::CommandAbortedException & ) { - return true; - } catch ( lang::IllegalArgumentException & e ) { - throw uno::RuntimeException( e.Message, e.Context ); } } @@ -342,10 +357,38 @@ bool TheExtensionManager::createPackageList( const uno::Reference< deployment::X //------------------------------------------------------------------------------ void TheExtensionManager::createPackageList() { - for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i ) + uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; + + try { + xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ); + } catch ( deployment::DeploymentException & ) { + return; + } catch ( ucb::CommandFailedException & ) { + return; + } catch ( ucb::CommandAbortedException & ) { + return; + } catch ( lang::IllegalArgumentException & e ) { + throw uno::RuntimeException( e.Message, e.Context ); + } + + for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - if ( ! createPackageList( m_sPackageManagers[i] ) ) - break; + uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; + + for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) + { + uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; + if ( xPackage.is() ) + { + PackageState eState = getPackageState( xPackage ); + getDialogHelper()->addPackageToList( xPackage, m_sPackageManagers[j] ); + // When the package is enabled, we can stop here, otherwise we have to look for + // another version of this package + if ( ( eState == REGISTERED ) || ( eState == NOT_AVAILABLE ) ) + break; + } + } } } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index 1cdd1851d59e..f794f8aa432d 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -34,6 +34,8 @@ #include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/frame/XDesktop.hpp" #include "com/sun/star/frame/XTerminateListener.hpp" #include "com/sun/star/uno/XComponentContext.hpp" @@ -57,6 +59,7 @@ class TheExtensionManager : private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > m_xDesktop; + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> > m_sPackageManagers; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xNameAccessNodes; @@ -111,6 +114,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext; } ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getUserPkgMgr() const { return m_sPackageManagers[0]; } ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getSharedPkgMgr() const { return m_sPackageManagers[1]; } + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const { return m_xExtensionManager; } //----------------- static ::rtl::Reference get( -- cgit From 72506215f8419786691277f2936b9298ddadd925 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 25 Mar 2010 10:45:08 +0100 Subject: jl152 import 263443 from native0jl:#i77196# merging --- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 32 ++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 7519ab8a1dc8..a45affcb2c08 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -34,7 +34,6 @@ #include "vos/mutex.hxx" #include "toolkit/helper/vclunohelper.hxx" - #include "com/sun/star/beans/XPropertySet.hpp" #include "com/sun/star/deployment/XPackageManagerFactory.hpp" #include "com/sun/star/deployment/thePackageManagerFactory.hpp" @@ -51,6 +50,10 @@ #define SHARED_PACKAGE_MANAGER OUSTR("shared") #define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") +#define USER_PACKAGE_MANAGER OUSTR("user") +#define SHARED_PACKAGE_MANAGER OUSTR("shared") +#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") + using namespace ::com::sun::star; using ::rtl::OUString; @@ -329,16 +332,14 @@ void TheExtensionManager::terminateDialog() //------------------------------------------------------------------------------ bool TheExtensionManager::createPackageList( const uno::Reference< deployment::XPackageManager > &xPackageManager ) { - uno::Sequence< uno::Reference< deployment::XPackage > > packages; + uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; try { - packages = xPackageManager->getDeployedPackages( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ); + xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ); } catch ( deployment::DeploymentException & ) { - //handleGeneralError(e.Cause); return true; } catch ( ucb::CommandFailedException & ) { - //handleGeneralError(e.Reason); return true; } catch ( ucb::CommandAbortedException & ) { return false; @@ -346,9 +347,24 @@ bool TheExtensionManager::createPackageList( const uno::Reference< deployment::X throw uno::RuntimeException( e.Message, e.Context ); } - for ( sal_Int32 j = 0; j < packages.getLength(); ++j ) + for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - getDialogHelper()->addPackageToList( packages[j], xPackageManager ); + uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; + + for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) + { + uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; + if ( xPackage.is() ) + { + PackageState eState = getPackageState( xPackage ); + getDialogHelper()->addPackageToList( xPackage, m_sPackageManagers[j] ); + // When the package is enabled, we can stop here, otherwise we have to look for + // another version of this package + if ( ( eState == REGISTERED ) || ( eState == NOT_AVAILABLE ) ) + break; + } + } + } return true; -- cgit From ada29520025252056fc0b9a156103b17bc770b0f Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Thu, 25 Mar 2010 11:57:04 +0100 Subject: jl152 import 263444 from native0jl:#i77196# disable now supported new from extension manager --- desktop/source/deployment/gui/dp_gui.hrc | 2 + desktop/source/deployment/gui/dp_gui_dialog2.cxx | 25 +++++++---- desktop/source/deployment/gui/dp_gui_dialog2.hxx | 6 +-- desktop/source/deployment/gui/dp_gui_dialog2.src | 12 +++++- .../source/deployment/gui/dp_gui_extlistbox.cxx | 46 +++++++++++++-------- .../source/deployment/gui/dp_gui_extlistbox.hxx | 20 +++++---- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 48 ++-------------------- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 1 - 8 files changed, 78 insertions(+), 82 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui.hrc b/desktop/source/deployment/gui/dp_gui.hrc index 8da4db5ca74f..1d2f4869cc7f 100644 --- a/desktop/source/deployment/gui/dp_gui.hrc +++ b/desktop/source/deployment/gui/dp_gui.hrc @@ -138,6 +138,8 @@ #define RID_IMG_LOCKED_HC (RID_DEPLOYMENT_GUI_START+59) #define RID_IMG_EXTENSION (RID_DEPLOYMENT_GUI_START+60) #define RID_IMG_EXTENSION_HC (RID_DEPLOYMENT_GUI_START+61) +#define RID_IMG_SHARED (RID_DEPLOYMENT_GUI_START+62) +#define RID_IMG_SHARED_HC (RID_DEPLOYMENT_GUI_START+63) #define RID_STR_ADD_PACKAGES (RID_DEPLOYMENT_GUI_START+70) diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 2d0733dfbae3..5f0cf3d91012 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -291,6 +291,7 @@ void ExtBoxWithBtns_Impl::SetButtonPos( const Rectangle& rRect ) // ----------------------------------------------------------------------- void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) { + pEntry->m_bHasButtons = false; if ( ( pEntry->m_eState == REGISTERED ) || ( pEntry->m_eState == NOT_AVAILABLE ) ) { m_pEnableBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) ); @@ -302,24 +303,32 @@ void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_ENABLE ); } - if ( ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) + if ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) m_pEnableBtn->Hide(); else { m_pEnableBtn->Enable( !pEntry->m_bLocked ); m_pEnableBtn->Show(); + pEntry->m_bHasButtons = true; } if ( pEntry->m_bHasOptions ) { m_pOptionsBtn->Enable( pEntry->m_bHasOptions ); m_pOptionsBtn->Show(); + pEntry->m_bHasButtons = true; } else m_pOptionsBtn->Hide(); - m_pRemoveBtn->Show(); - m_pRemoveBtn->Enable( !pEntry->m_bLocked ); + if ( pEntry->m_bUser || pEntry->m_bShared ) + { + m_pRemoveBtn->Enable( !pEntry->m_bLocked ); + m_pRemoveBtn->Show(); + pEntry->m_bHasButtons = true; + } + else + m_pRemoveBtn->Hide(); } // ----------------------------------------------------------------------- @@ -778,10 +787,9 @@ long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage } //------------------------------------------------------------------------------ -void ExtMgrDialog::prepareChecking( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +void ExtMgrDialog::prepareChecking() { - if ( xPackageManager.is() ) - m_pExtensionBox->prepareChecking( xPackageManager ); + m_pExtensionBox->prepareChecking(); } //------------------------------------------------------------------------------ @@ -1323,10 +1331,9 @@ long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::X } //------------------------------------------------------------------------------ -void UpdateRequiredDialog::prepareChecking( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +void UpdateRequiredDialog::prepareChecking() { - if ( xPackageManager.is() ) - m_pExtensionBox->prepareChecking( xPackageManager ); + m_pExtensionBox->prepareChecking(); } //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index d5e939ace8a9..cadc127446ea 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -85,7 +85,7 @@ public: virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & ) = 0; - virtual void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ) = 0; + virtual void prepareChecking() = 0; virtual void checkEntries() = 0; static ResId getResId( USHORT nId ); @@ -169,7 +169,7 @@ public: bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - virtual void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + virtual void prepareChecking(); virtual void checkEntries(); ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); @@ -242,7 +242,7 @@ public: bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - virtual void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + virtual void prepareChecking(); virtual void checkEntries(); ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.src b/desktop/source/deployment/gui/dp_gui_dialog2.src index d55421d50d75..7c47365999a0 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.src +++ b/desktop/source/deployment/gui/dp_gui_dialog2.src @@ -165,10 +165,20 @@ Image RID_IMG_WARNING_HC Image RID_IMG_LOCKED { - ImageBitmap = Bitmap { File = "shared_16.png"; }; + ImageBitmap = Bitmap { File = "lock_16.png"; }; }; Image RID_IMG_LOCKED_HC +{ + ImageBitmap = Bitmap { File = "lock_16_h.png"; }; +}; + +Image RID_IMG_SHARED +{ + ImageBitmap = Bitmap { File = "shared_16.png"; }; +}; + +Image RID_IMG_SHARED_HC { ImageBitmap = Bitmap { File = "shared_16_h.png"; }; }; diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 6793b6e1e0ab..7d616b103c21 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -58,9 +58,11 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_bLocked( false ), m_bHasOptions( false ), m_bShared( false ), + m_bUser( false ), m_bNew( false ), m_bChecked( false ), m_bMissingDeps( false ), + m_bHasButtons( false ), m_eState( eState ), m_pPublisher( NULL ), m_xPackage( xPackage ), @@ -177,6 +179,8 @@ ExtensionBox_Impl::ExtensionBox_Impl( Dialog* pParent, TheExtensionManager *pMan m_nTopIndex( 0 ), m_nActiveHeight( 0 ), m_nExtraHeight( 2 ), + m_aSharedImage( DialogHelper::getResId( RID_IMG_SHARED ) ), + m_aSharedImageHC( DialogHelper::getResId( RID_IMG_SHARED_HC ) ), m_aLockedImage( DialogHelper::getResId( RID_IMG_LOCKED ) ), m_aLockedImageHC( DialogHelper::getResId( RID_IMG_LOCKED_HC ) ), m_aWarningImage( DialogHelper::getResId( RID_IMG_WARNING ) ), @@ -380,7 +384,10 @@ void ExtensionBox_Impl::CalcActiveHeight( const long nPos ) if ( aTextHeight < m_nStdHeight ) aTextHeight = m_nStdHeight; - m_nActiveHeight = aTextHeight + m_nExtraHeight; + if ( m_vEntries[ nPos ]->m_bHasButtons ) + m_nActiveHeight = aTextHeight + m_nExtraHeight; + else + m_nActiveHeight = aTextHeight + 2; } //------------------------------------------------------------------------------ @@ -469,13 +476,15 @@ void ExtensionBox_Impl::selectEntry( const long nPos ) if ( IsReallyVisible() ) { - m_bNeedsRecalc = true; m_bAdjustActive = true; } } if ( IsReallyVisible() ) + { + m_bNeedsRecalc = true; Invalidate(); + } guard.clear(); } @@ -595,7 +604,12 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr aPos.Y() += aTextHeight; if ( pEntry->m_bActive ) { - DrawText( Rectangle( aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - m_nExtraHeight ), + long nExtraHeight = 0; + + if ( pEntry->m_bHasButtons ) + nExtraHeight = m_nExtraHeight; + + DrawText( Rectangle( aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - nExtraHeight ), sDescription, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK ); } else @@ -615,10 +629,13 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr } // Draw status icons - if ( pEntry->m_bShared ) + if ( !pEntry->m_bUser ) { aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SMALL_ICON_SIZE), TOP_OFFSET ); - DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aLockedImageHC : m_aLockedImage ); + if ( pEntry->m_bLocked ) + DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aLockedImageHC : m_aLockedImage ); + else + DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aSharedImageHC : m_aSharedImage ); } if ( ( pEntry->m_eState == AMBIGUOUS ) || pEntry->m_bMissingDeps ) { @@ -950,18 +967,12 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & ::osl::ClearableMutexGuard guard(m_entriesMutex); if ( m_vEntries.empty() ) { - pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bShared = ( m_pManager->getUserPkgMgr() != xPackageManager ); - pEntry->m_bNew = m_bInCheckMode; m_vEntries.push_back( pEntry ); } else { if ( !FindEntryPos( pEntry, 0, m_vEntries.size()-1, nPos ) ) { - pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bShared = ( m_pManager->getUserPkgMgr() != xPackageManager ); - pEntry->m_bNew = m_bInCheckMode; m_vEntries.insert( m_vEntries.begin()+nPos, pEntry ); } else if ( !m_bInCheckMode ) @@ -969,6 +980,12 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & OSL_ENSURE( 0, "ExtensionBox_Impl::addEntry(): Will not add duplicate entries" ); } } + + pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); + pEntry->m_bUser = ( m_pManager->getUserPkgMgr() == xPackageManager ); + pEntry->m_bShared = !pEntry->m_bUser && ( m_pManager->getSharedPkgMgr() == xPackageManager ); + pEntry->m_bNew = m_bInCheckMode; + //access to m_nActive must be guarded if ( !m_bInCheckMode && m_bHasActive && ( m_nActive >= nPos ) ) m_nActive += 1; @@ -1084,16 +1101,13 @@ void ExtensionBox_Impl::RemoveUnlocked() } //------------------------------------------------------------------------------ -void ExtensionBox_Impl::prepareChecking( const uno::Reference< deployment::XPackageManager > &xPackageMgr ) +void ExtensionBox_Impl::prepareChecking() { m_bInCheckMode = true; typedef std::vector< TEntry_Impl >::iterator ITER; for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex ) { - if ( (*iIndex)->m_xPackageManager == xPackageMgr ) - (*iIndex)->m_bChecked = false; - else - (*iIndex)->m_bChecked = true; + (*iIndex)->m_bChecked = false; (*iIndex)->m_bNew = false; } } diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx index ad62bfd1a2d8..1ea3d0d72fcc 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -65,13 +65,15 @@ typedef ::boost::shared_ptr< Entry_Impl > TEntry_Impl; struct Entry_Impl { - bool m_bActive; - bool m_bLocked; - bool m_bHasOptions; - bool m_bShared; - bool m_bNew; - bool m_bChecked; - bool m_bMissingDeps; + bool m_bActive :1; + bool m_bLocked :1; + bool m_bHasOptions :1; + bool m_bUser :1; + bool m_bShared :1; + bool m_bNew :1; + bool m_bChecked :1; + bool m_bMissingDeps :1; + bool m_bHasButtons :1; PackageState m_eState; String m_sTitle; String m_sVersion; @@ -135,6 +137,8 @@ class ExtensionBox_Impl : public ::svt::IExtensionListBox long m_nActiveHeight; long m_nExtraHeight; Size m_aOutputSize; + Image m_aSharedImage; + Image m_aSharedImageHC; Image m_aLockedImage; Image m_aLockedImageHC; Image m_aWarningImage; @@ -209,7 +213,7 @@ public: void updateEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void removeEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageMgr ); + void prepareChecking(); void checkEntries(); TheExtensionManager* getExtensionManager() const { return m_pManager; } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index a45affcb2c08..fef6d36c7165 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -235,7 +235,8 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare { uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) + // we don't want update notifications for bundled packages + for ( sal_Int32 j = 0; ( j < 2 ) && ( j < xPackageList.getLength() ); ++j ) { uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; if ( xPackage.is() ) @@ -329,47 +330,6 @@ void TheExtensionManager::terminateDialog() } } -//------------------------------------------------------------------------------ -bool TheExtensionManager::createPackageList( const uno::Reference< deployment::XPackageManager > &xPackageManager ) -{ - uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; - - try { - xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ); - } catch ( deployment::DeploymentException & ) { - return true; - } catch ( ucb::CommandFailedException & ) { - return true; - } catch ( ucb::CommandAbortedException & ) { - return false; - } catch ( lang::IllegalArgumentException & e ) { - throw uno::RuntimeException( e.Message, e.Context ); - } - - for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) - { - uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - - for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) - { - uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; - if ( xPackage.is() ) - { - PackageState eState = getPackageState( xPackage ); - getDialogHelper()->addPackageToList( xPackage, m_sPackageManagers[j] ); - // When the package is enabled, we can stop here, otherwise we have to look for - // another version of this package - if ( ( eState == REGISTERED ) || ( eState == NOT_AVAILABLE ) ) - break; - } - } - - } - - return true; -} - //------------------------------------------------------------------------------ void TheExtensionManager::createPackageList() { @@ -553,8 +513,8 @@ void TheExtensionManager::modified( ::lang::EventObject const & rEvt ) uno::Reference< deployment::XPackageManager > xPackageManager( rEvt.Source, uno::UNO_QUERY ); if ( xPackageManager.is() ) { - getDialogHelper()->prepareChecking( xPackageManager ); - createPackageList( xPackageManager ); + getDialogHelper()->prepareChecking(); + createPackageList(); getDialogHelper()->checkEntries(); } } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index f794f8aa432d..2b8f86de9955 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -74,7 +74,6 @@ private: // liste der packages ( xpackage?, mit parent manager, ... ) void createPackageList(); - bool createPackageList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); public: static ::rtl::Reference s_ExtMgr; -- cgit From 6b08288aa173d0717b15a1cb970fdb0614a88d6a Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 30 Mar 2010 16:45:08 +0200 Subject: tl78: #i105076# the filter related constants are no more in framework module --- framework/inc/filterflags.h | 172 ------------------------------- framework/inc/queries.h | 1 - framework/source/constant/filter.cxx | 119 --------------------- framework/source/constant/makefile.mk | 3 +- framework/source/inc/constant/filter.hxx | 126 ---------------------- framework/source/loadenv/loadenv.cxx | 3 - framework/util/makefile.mk | 1 - 7 files changed, 1 insertion(+), 424 deletions(-) delete mode 100644 framework/inc/filterflags.h delete mode 100644 framework/source/constant/filter.cxx delete mode 100644 framework/source/inc/constant/filter.hxx diff --git a/framework/inc/filterflags.h b/framework/inc/filterflags.h deleted file mode 100644 index 227834bc41dd..000000000000 --- a/framework/inc/filterflags.h +++ /dev/null @@ -1,172 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __FRAMEWORK_FILTERFLAGS_H_ -#define __FRAMEWORK_FILTERFLAGS_H_ - -namespace framework{ - -/*-************************************************************************************************************//** - @short These values describe our supported filter flags. - @attention Don't change flag values without reason - we must support old functionality and position - in flag combined values! -*//*-*************************************************************************************************************/ - -#define FILTERFLAGNAME_IMPORT DECLARE_ASCII("Import" ) // x -#define FILTERFLAGNAME_EXPORT DECLARE_ASCII("Export" ) // x -#define FILTERFLAGNAME_TEMPLATE DECLARE_ASCII("Template" ) // x -#define FILTERFLAGNAME_INTERNAL DECLARE_ASCII("Internal" ) // x -#define FILTERFLAGNAME_TEMPLATEPATH DECLARE_ASCII("TemplatePath" ) // x -#define FILTERFLAGNAME_OWN DECLARE_ASCII("Own" ) // x -#define FILTERFLAGNAME_ALIEN DECLARE_ASCII("Alien" ) // x -#define FILTERFLAGNAME_USESOPTIONS DECLARE_ASCII("UsesOptions" ) // x -#define FILTERFLAGNAME_DEFAULT DECLARE_ASCII("Default" ) // x -#define FILTERFLAGNAME_EXECUTABLE DECLARE_ASCII("Executable" ) // deprecated -#define FILTERFLAGNAME_SUPPORTSSELECTION DECLARE_ASCII("SupportsSelection") // x -#define FILTERFLAGNAME_MAPTOAPPPLUG DECLARE_ASCII("MapToAppPlug" ) // deprecated -#define FILTERFLAGNAME_NOTINFILEDIALOG DECLARE_ASCII("NotInFileDialog" ) // x -#define FILTERFLAGNAME_NOTINCHOOSER DECLARE_ASCII("NotInChooser" ) // x -#define FILTERFLAGNAME_ASYNCHRON DECLARE_ASCII("Asynchron" ) // x -#define FILTERFLAGNAME_CREATOR DECLARE_ASCII("Creator" ) // deprecated -#define FILTERFLAGNAME_READONLY DECLARE_ASCII("Readonly" ) // x -#define FILTERFLAGNAME_NOTINSTALLED DECLARE_ASCII("NotInstalled" ) // deprecated -#define FILTERFLAGNAME_CONSULTSERVICE DECLARE_ASCII("ConsultService" ) // deprecated -#define FILTERFLAGNAME_3RDPARTYFILTER DECLARE_ASCII("3rdPartyFilter" ) // x -#define FILTERFLAGNAME_PACKED DECLARE_ASCII("Packed" ) // x -#define FILTERFLAGNAME_SILENTEXPORT DECLARE_ASCII("SilentExport" ) // x -#define FILTERFLAGNAME_BROWSERPREFERED DECLARE_ASCII("BrowserPrefered" ) // deprecated -#define FILTERFLAGNAME_PREFERED DECLARE_ASCII("Prefered" ) // x - -#define FILTERFLAG_IMPORT 0x00000001L // 1 -#define FILTERFLAG_EXPORT 0x00000002L // 2 -#define FILTERFLAG_TEMPLATE 0x00000004L // 4 -#define FILTERFLAG_INTERNAL 0x00000008L // 8 -#define FILTERFLAG_TEMPLATEPATH 0x00000010L // 16 -#define FILTERFLAG_OWN 0x00000020L // 32 -#define FILTERFLAG_ALIEN 0x00000040L // 64 -#define FILTERFLAG_USESOPTIONS 0x00000080L // 128 -#define FILTERFLAG_DEFAULT 0x00000100L // 256 -#define FILTERFLAG_EXECUTABLE 0x00000200L // 512 -#define FILTERFLAG_SUPPORTSSELECTION 0x00000400L // 1024 -#define FILTERFLAG_MAPTOAPPPLUG 0x00000800L // 2048 -#define FILTERFLAG_NOTINFILEDIALOG 0x00001000L // 4096 -#define FILTERFLAG_NOTINCHOOSER 0x00002000L // 8192 -#define FILTERFLAG_ASYNCHRON 0x00004000L // 16384 -#define FILTERFLAG_CREATOR 0x00008000L // 32768 -#define FILTERFLAG_READONLY 0x00010000L // 65536 -#define FILTERFLAG_NOTINSTALLED 0x00020000L // 131072 -#define FILTERFLAG_CONSULTSERVICE 0x00040000L // 262144 -#define FILTERFLAG_3RDPARTYFILTER 0x00080000L // 524288 -#define FILTERFLAG_PACKED 0x00100000L // 1048576 -#define FILTERFLAG_SILENTEXPORT 0x00200000L // 2097152 -#define FILTERFLAG_BROWSERPREFERED 0x00400000L // 4194304 -//FREE! ... 0x00800000L -#define FILTERFLAG_PREFERED 0x10000000L // 268435456 - -class FlagCheck -{ - public: - - //___________________________________________ - - /** @short checks if the given flag mask is set. - - @param nFlags the flag field, which should be checked. - @param nMask this mask field is searched inside parameter nFlags. - - @return TRUE if mask match to the given flag field. - */ - static sal_Bool isMaskSet( sal_Int32 nFlags, sal_Int32 nMask ) - { - return((nFlags & nMask) == nMask); - } - - //___________________________________________ - - /** @short checks if the given flag field contains unknown flags. - - @descr Of course it can work only, if not the whole range of an int32 - is used! - - @param nFlags the flag field, which should be checked. - - @return TRUE if only well known flags are set. - */ - static sal_Bool isValid( sal_Int32 nFlags ) - { - sal_Int32 nCheck = nFlags; - nCheck &= ~FILTERFLAG_IMPORT; - nCheck &= ~FILTERFLAG_EXPORT; - nCheck &= ~FILTERFLAG_TEMPLATE; - nCheck &= ~FILTERFLAG_INTERNAL; - nCheck &= ~FILTERFLAG_TEMPLATEPATH; - nCheck &= ~FILTERFLAG_OWN; - nCheck &= ~FILTERFLAG_ALIEN; - nCheck &= ~FILTERFLAG_USESOPTIONS; - nCheck &= ~FILTERFLAG_DEFAULT; - nCheck &= ~FILTERFLAG_EXECUTABLE; - nCheck &= ~FILTERFLAG_SUPPORTSSELECTION; - nCheck &= ~FILTERFLAG_MAPTOAPPPLUG; - nCheck &= ~FILTERFLAG_NOTINFILEDIALOG; - nCheck &= ~FILTERFLAG_NOTINCHOOSER; - nCheck &= ~FILTERFLAG_ASYNCHRON; - nCheck &= ~FILTERFLAG_CREATOR; - nCheck &= ~FILTERFLAG_READONLY; - nCheck &= ~FILTERFLAG_NOTINSTALLED; - nCheck &= ~FILTERFLAG_CONSULTSERVICE; - nCheck &= ~FILTERFLAG_3RDPARTYFILTER; - nCheck &= ~FILTERFLAG_PACKED; - nCheck &= ~FILTERFLAG_SILENTEXPORT; - nCheck &= ~FILTERFLAG_BROWSERPREFERED; - nCheck &= ~FILTERFLAG_PREFERED; - return(nCheck == 0); - } - - //___________________________________________ - - /** @short checks if the given flag field uses deprecated flag values. - - @param nFlags the flag field, which should be checked. - - @return TRUE if one deprecated flag item could be found. - */ - static sal_Bool useDeprecated( sal_Int32 nFlags ) - { - return( - isMaskSet(nFlags, FILTERFLAG_EXECUTABLE ) || - isMaskSet(nFlags, FILTERFLAG_MAPTOAPPPLUG ) || - isMaskSet(nFlags, FILTERFLAG_CREATOR ) || - isMaskSet(nFlags, FILTERFLAG_NOTINSTALLED ) || - isMaskSet(nFlags, FILTERFLAG_CONSULTSERVICE ) || - isMaskSet(nFlags, FILTERFLAG_BROWSERPREFERED ) - ); - } -}; - -} // namespace framework - -#endif // #ifndef __FRAMEWORK_FILTERFLAGS_H_ diff --git a/framework/inc/queries.h b/framework/inc/queries.h index ce190a796dcb..b8d122118abf 100644 --- a/framework/inc/queries.h +++ b/framework/inc/queries.h @@ -32,7 +32,6 @@ // own includes //_________________________________________________________________________________________________________________ -#include #include //_________________________________________________________________________________________________________________ diff --git a/framework/source/constant/filter.cxx b/framework/source/constant/filter.cxx deleted file mode 100644 index 57d94d772e6d..000000000000 --- a/framework/source/constant/filter.cxx +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" - -#ifndef __FRAMEWORK_CONSTANT_FILTER_HXX_ -#include -#endif - -namespace framework{ - namespace constant{ - -const ::rtl::OUString Filter::PROP_NAME = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name" )); -const ::rtl::OUString Filter::PROP_TYPE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type" )); -const ::rtl::OUString Filter::PROP_DOCUMENTSERVICE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentService")); -const ::rtl::OUString Filter::PROP_FILTERSERVICE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FilterService" )); -const ::rtl::OUString Filter::PROP_UICOMPONENT = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIComponent" )); -const ::rtl::OUString Filter::PROP_FLAGS = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Flags" )); -const ::rtl::OUString Filter::PROP_USERDATA = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UserData" )); -const ::rtl::OUString Filter::PROP_TEMPLATENAME = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TemplateName" )); - -const ::rtl::OUString Filter::QUERY_GET_DEFAULT_FILTER_FOR_TYPE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("getDefaultFilterForType")); -const ::rtl::OUString Filter::QUERY_ALL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_query_all" )); -const ::rtl::OUString Filter::QUERY_WRITER = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_query_writer" )); -const ::rtl::OUString Filter::QUERY_WEB = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_query_web" )); -const ::rtl::OUString Filter::QUERY_GLOBAL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_query_global" )); -const ::rtl::OUString Filter::QUERY_CHART = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_query_chart" )); -const ::rtl::OUString Filter::QUERY_CALC = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_query_calc" )); -const ::rtl::OUString Filter::QUERY_IMPRESS = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_query_impress" )); -const ::rtl::OUString Filter::QUERY_DRAW = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_query_draw" )); -const ::rtl::OUString Filter::QUERY_MATH = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_query_math" )); - -const ::rtl::OUString Filter::QUERYPARAM_IFLAGS = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("iflags" )); -const ::rtl::OUString Filter::QUERYPARAM_EFLAGS = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("eflags" )); -const ::rtl::OUString Filter::QUERYPARAM_SORT_PROP = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sort_prop" )); -const ::rtl::OUString Filter::QUERYPARAM_DESCENDING = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("descending" )); -const ::rtl::OUString Filter::QUERYPARAM_USE_ORDER = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("use_order" )); -const ::rtl::OUString Filter::QUERYPARAM_DEFAULT_FIRST = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("default_first" )); -const ::rtl::OUString Filter::QUERYPARAM_CASE_SENSITIVE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("case_sensitive")); -const ::rtl::OUString Filter::QUERYPARAMVALUE_SORT_PROP_NAME = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("name" )); -const ::rtl::OUString Filter::QUERYPARAMVALUE_SORT_PROP_UINAME = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uiname" )); - -const ::rtl::OUString Filter::FLAGNAME_IMPORT = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Import" )); -const ::rtl::OUString Filter::FLAGNAME_EXPORT = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Export" )); -const ::rtl::OUString Filter::FLAGNAME_TEMPLATE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Template" )); -const ::rtl::OUString Filter::FLAGNAME_INTERNAL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Internal" )); -const ::rtl::OUString Filter::FLAGNAME_TEMPLATEPATH = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TemplatePath" )); -const ::rtl::OUString Filter::FLAGNAME_OWN = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Own" )); -const ::rtl::OUString Filter::FLAGNAME_ALIEN = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Alien" )); -const ::rtl::OUString Filter::FLAGNAME_USESOPTIONS = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UsesOptions" )); -const ::rtl::OUString Filter::FLAGNAME_DEFAULT = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Default" )); -const ::rtl::OUString Filter::FLAGNAME_EXECUTABLE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Executable" )); -const ::rtl::OUString Filter::FLAGNAME_SUPPORTSSELECTION = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SupportsSelection")); -const ::rtl::OUString Filter::FLAGNAME_MAPTOAPPPLUG = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MapToAppPlug" )); -const ::rtl::OUString Filter::FLAGNAME_NOTINFILEDIALOG = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NotInFileDialog" )); -const ::rtl::OUString Filter::FLAGNAME_NOTINCHOOSER = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NotInChooser" )); -const ::rtl::OUString Filter::FLAGNAME_ASYNCHRON = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Asynchron" )); -const ::rtl::OUString Filter::FLAGNAME_CREATOR = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Creator" )); -const ::rtl::OUString Filter::FLAGNAME_READONLY = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Readonly" )); -const ::rtl::OUString Filter::FLAGNAME_NOTINSTALLED = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NotInstalled" )); -const ::rtl::OUString Filter::FLAGNAME_CONSULTSERVICE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConsultService" )); -const ::rtl::OUString Filter::FLAGNAME_3RDPARTYFILTER = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("3rdPartyFilter" )); -const ::rtl::OUString Filter::FLAGNAME_PACKED = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Packed" )); -const ::rtl::OUString Filter::FLAGNAME_SILENTEXPORT = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SilentExport" )); -const ::rtl::OUString Filter::FLAGNAME_BROWSERPREFERED = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BrowserPrefered" )); -const ::rtl::OUString Filter::FLAGNAME_PREFERED = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Prefered" )); - -const sal_Int32 Filter::FLAGVALUE_IMPORT = 0x00000001L; // 1 -const sal_Int32 Filter::FLAGVALUE_EXPORT = 0x00000002L; // 2 -const sal_Int32 Filter::FLAGVALUE_TEMPLATE = 0x00000004L; // 4 -const sal_Int32 Filter::FLAGVALUE_INTERNAL = 0x00000008L; // 8 -const sal_Int32 Filter::FLAGVALUE_TEMPLATEPATH = 0x00000010L; // 16 -const sal_Int32 Filter::FLAGVALUE_OWN = 0x00000020L; // 32 -const sal_Int32 Filter::FLAGVALUE_ALIEN = 0x00000040L; // 64 -const sal_Int32 Filter::FLAGVALUE_USESOPTIONS = 0x00000080L; // 128 -const sal_Int32 Filter::FLAGVALUE_DEFAULT = 0x00000100L; // 256 -const sal_Int32 Filter::FLAGVALUE_EXECUTABLE = 0x00000200L; // 512 -const sal_Int32 Filter::FLAGVALUE_SUPPORTSSELECTION = 0x00000400L; // 1024 -const sal_Int32 Filter::FLAGVALUE_MAPTOAPPPLUG = 0x00000800L; // 2048 -const sal_Int32 Filter::FLAGVALUE_NOTINFILEDIALOG = 0x00001000L; // 4096 -const sal_Int32 Filter::FLAGVALUE_NOTINCHOOSER = 0x00002000L; // 8192 -const sal_Int32 Filter::FLAGVALUE_ASYNCHRON = 0x00004000L; // 16384 -const sal_Int32 Filter::FLAGVALUE_CREATOR = 0x00008000L; // 32768 -const sal_Int32 Filter::FLAGVALUE_READONLY = 0x00010000L; // 65536 -const sal_Int32 Filter::FLAGVALUE_NOTINSTALLED = 0x00020000L; // 131072 -const sal_Int32 Filter::FLAGVALUE_CONSULTSERVICE = 0x00040000L; // 262144 -const sal_Int32 Filter::FLAGVALUE_3RDPARTYFILTER = 0x00080000L; // 524288 -const sal_Int32 Filter::FLAGVALUE_PACKED = 0x00100000L; // 1048576 -const sal_Int32 Filter::FLAGVALUE_SILENTEXPORT = 0x00200000L; // 2097152 -const sal_Int32 Filter::FLAGVALUE_BROWSERPREFERED = 0x00400000L; // 4194304 -const sal_Int32 Filter::FLAGVALUE_PREFERED = 0x10000000L; // 268435456 - - } // namespace constant -} // namespace framework diff --git a/framework/source/constant/makefile.mk b/framework/source/constant/makefile.mk index 1c050db57dca..05fc28870d0a 100644 --- a/framework/source/constant/makefile.mk +++ b/framework/source/constant/makefile.mk @@ -35,8 +35,7 @@ ENABLE_EXCEPTIONS= TRUE # --- Generate ----------------------------------------------------- -SLOFILES= $(SLO)$/filter.obj \ - $(SLO)$/frameloader.obj \ +SLOFILES= $(SLO)$/frameloader.obj \ $(SLO)$/contenthandler.obj \ $(SLO)$/containerquery.obj diff --git a/framework/source/inc/constant/filter.hxx b/framework/source/inc/constant/filter.hxx deleted file mode 100644 index 141440a77716..000000000000 --- a/framework/source/inc/constant/filter.hxx +++ /dev/null @@ -1,126 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __FRAMEWORK_CONSTANT_FILTER_H_ -#define __FRAMEWORK_CONSTANT_FILTER_H_ - -#include - -namespace framework{ - namespace constant{ - -struct Filter -{ - public: - - static const ::rtl::OUString PROP_NAME; // string - static const ::rtl::OUString PROP_TYPE; // string - static const ::rtl::OUString PROP_DOCUMENTSERVICE; // string - static const ::rtl::OUString PROP_FILTERSERVICE; // string - static const ::rtl::OUString PROP_UICOMPONENT; // string - static const ::rtl::OUString PROP_FLAGS; // int32 - static const ::rtl::OUString PROP_USERDATA; // seq< string > - static const ::rtl::OUString PROP_TEMPLATENAME; // string - - static const ::rtl::OUString QUERY_GET_DEFAULT_FILTER_FOR_TYPE; - static const ::rtl::OUString QUERY_ALL; - static const ::rtl::OUString QUERY_WRITER; - static const ::rtl::OUString QUERY_WEB; - static const ::rtl::OUString QUERY_GLOBAL; - static const ::rtl::OUString QUERY_CHART; - static const ::rtl::OUString QUERY_CALC; - static const ::rtl::OUString QUERY_IMPRESS; - static const ::rtl::OUString QUERY_DRAW; - static const ::rtl::OUString QUERY_MATH; - - static const ::rtl::OUString QUERYPARAM_IFLAGS; - static const ::rtl::OUString QUERYPARAM_EFLAGS; - static const ::rtl::OUString QUERYPARAM_SORT_PROP; - static const ::rtl::OUString QUERYPARAM_DESCENDING; - static const ::rtl::OUString QUERYPARAM_USE_ORDER; - static const ::rtl::OUString QUERYPARAM_DEFAULT_FIRST; - static const ::rtl::OUString QUERYPARAM_CASE_SENSITIVE; - static const ::rtl::OUString QUERYPARAMVALUE_SORT_PROP_NAME; - static const ::rtl::OUString QUERYPARAMVALUE_SORT_PROP_UINAME; - - static const ::rtl::OUString FLAGNAME_IMPORT; - static const ::rtl::OUString FLAGNAME_EXPORT; - static const ::rtl::OUString FLAGNAME_TEMPLATE; - static const ::rtl::OUString FLAGNAME_INTERNAL; - static const ::rtl::OUString FLAGNAME_TEMPLATEPATH; - static const ::rtl::OUString FLAGNAME_OWN; - static const ::rtl::OUString FLAGNAME_ALIEN; - static const ::rtl::OUString FLAGNAME_USESOPTIONS; - static const ::rtl::OUString FLAGNAME_DEFAULT; - static const ::rtl::OUString FLAGNAME_EXECUTABLE; - static const ::rtl::OUString FLAGNAME_SUPPORTSSELECTION; - static const ::rtl::OUString FLAGNAME_MAPTOAPPPLUG; - static const ::rtl::OUString FLAGNAME_NOTINFILEDIALOG; - static const ::rtl::OUString FLAGNAME_NOTINCHOOSER; - static const ::rtl::OUString FLAGNAME_ASYNCHRON; - static const ::rtl::OUString FLAGNAME_CREATOR; - static const ::rtl::OUString FLAGNAME_READONLY; - static const ::rtl::OUString FLAGNAME_NOTINSTALLED; - static const ::rtl::OUString FLAGNAME_CONSULTSERVICE; - static const ::rtl::OUString FLAGNAME_3RDPARTYFILTER; - static const ::rtl::OUString FLAGNAME_PACKED; - static const ::rtl::OUString FLAGNAME_SILENTEXPORT; - static const ::rtl::OUString FLAGNAME_BROWSERPREFERED; - static const ::rtl::OUString FLAGNAME_PREFERED; - - static const sal_Int32 FLAGVALUE_IMPORT; - static const sal_Int32 FLAGVALUE_EXPORT; - static const sal_Int32 FLAGVALUE_TEMPLATE; - static const sal_Int32 FLAGVALUE_INTERNAL; - static const sal_Int32 FLAGVALUE_TEMPLATEPATH; - static const sal_Int32 FLAGVALUE_OWN; - static const sal_Int32 FLAGVALUE_ALIEN; - static const sal_Int32 FLAGVALUE_USESOPTIONS; - static const sal_Int32 FLAGVALUE_DEFAULT; - static const sal_Int32 FLAGVALUE_EXECUTABLE; - static const sal_Int32 FLAGVALUE_SUPPORTSSELECTION; - static const sal_Int32 FLAGVALUE_MAPTOAPPPLUG; - static const sal_Int32 FLAGVALUE_NOTINFILEDIALOG; - static const sal_Int32 FLAGVALUE_NOTINCHOOSER; - static const sal_Int32 FLAGVALUE_ASYNCHRON; - static const sal_Int32 FLAGVALUE_CREATOR; - static const sal_Int32 FLAGVALUE_READONLY; - static const sal_Int32 FLAGVALUE_NOTINSTALLED; - static const sal_Int32 FLAGVALUE_CONSULTSERVICE; - static const sal_Int32 FLAGVALUE_3RDPARTYFILTER; - static const sal_Int32 FLAGVALUE_PACKED; - static const sal_Int32 FLAGVALUE_SILENTEXPORT; - static const sal_Int32 FLAGVALUE_BROWSERPREFERED; - //FREE! ... 0x00800000L - static const sal_Int32 FLAGVALUE_PREFERED; - -}; - - } // namespace constant -} // namespace framework - -#endif // #ifndef __FRAMEWORK_CONSTANT_FILTER_H_ diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index c1d76d6f8985..79f42eba8e69 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -36,9 +36,6 @@ #endif #include -#ifndef __FRAMEWORK_CONSTANT_FILTER_HXX_ -#include -#endif #include #ifndef __FRAMEWORK_CONSTANT_FRAMELOADER_HXX_ diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk index ed7e2e131550..4a94edae92b0 100644 --- a/framework/util/makefile.mk +++ b/framework/util/makefile.mk @@ -255,7 +255,6 @@ SHL4OBJS= \ $(SLO)$/droptargetlistener.obj \ $(SLO)$/edittoolbarcontroller.obj \ $(SLO)$/factoryconfiguration.obj \ - $(SLO)$/filter.obj \ $(SLO)$/framecontainer.obj \ $(SLO)$/frameloader.obj \ $(SLO)$/frame.obj \ -- cgit From 9ed2bd2cd955daefa3eed53466dc63e8ded60d17 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Fri, 26 Mar 2010 09:35:04 +0100 Subject: tl78: #i105076# add ENCRYPTION and PASSWORDTOMODIFY filter flags --- sfx2/source/dialog/filedlghelper.cxx | 46 ++++++++++++++++++++---------------- sfx2/source/doc/docfilt.cxx | 14 ----------- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 5270eb5d4207..5e4e7d88258c 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -466,23 +466,14 @@ sal_Bool FileDialogHelper_Impl::isInOpenMode() const namespace { -bool lclCheckODFPasswordCapability( const SfxFilter* pFilter ) +sal_Bool lclCheckPasswordCapability( const SfxFilter* pFilter ) { - return pFilter && pFilter->IsOwnFormat() && pFilter->UsesStorage() && (pFilter->GetVersion() >= SOFFICE_FILEFORMAT_60); + return pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_ENCRYPTION ); } -bool lclCheckMSPasswordCapability( const SfxFilter* pFilter ) +sal_Bool lclCheckPasswordToModifyCapability( const SfxFilter* pFilter ) { - // TODO #i105076# this should be in the filter configuration!!! - return pFilter && CheckMSPasswordCapabilityForExport( pFilter->GetFilterName() ); -} - -bool lclCheckPasswordCapability( const SfxFilter* pFilter ) -{ - return - lclCheckODFPasswordCapability( pFilter ) || - // TODO #i105076# this should be in the filter configuration!!! - lclCheckMSPasswordCapability( pFilter ); + return pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ); } } @@ -546,7 +537,7 @@ void FileDialogHelper_Impl::updateSelectionBox() return; // Does the selection box exist? - bool bSelectionBoxFound = false; + sal_Bool bSelectionBoxFound = sal_False; uno::Reference< XControlInformation > xCtrlInfo( mxFileDlg, UNO_QUERY ); if ( xCtrlInfo.is() ) { @@ -555,7 +546,7 @@ void FileDialogHelper_Impl::updateSelectionBox() for ( sal_uInt32 nCtrl = 0; nCtrl < nCount; ++nCtrl ) if ( aCtrlList[ nCtrl ].equalsAscii("SelectionBox") ) { - bSelectionBoxFound = true; + bSelectionBoxFound = sal_False; break; } } @@ -1550,6 +1541,10 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, { SFX_ITEMSET_ARG( rpSet, pPassItem, SfxStringItem, SID_PASSWORD, FALSE ); mbPwdCheckBoxState = ( pPassItem != NULL ); + + // in case the document has password to modify, the dialog should be shown + SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxStringItem, SID_PASSWORDTOMODIFY, FALSE ); + mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); } SFX_ITEMSET_ARG( rpSet, pSelectItem, SfxBoolItem, SID_SELECTION, FALSE ); @@ -1560,6 +1555,9 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // the password will be set in case user decide so rpSet->ClearItem( SID_PASSWORD ); + rpSet->ClearItem( SID_RECOMMENDREADONLY ); + rpSet->ClearItem( SID_PASSWORDTOMODIFY ); + } if ( mbHasPassword && !mbPwdCheckBoxState ) @@ -1656,18 +1654,26 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if( xInteractionHandler.is() ) { // TODO: need a save way to distinguish MS filters from other filters - bool bMSType = CheckMSPasswordCapabilityForExport( rFilter ); + sal_Bool bMSType = CheckMSPasswordCapabilityForExport( rFilter ); ::comphelper::DocPasswordRequestType eType = bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; - ::comphelper::DocPasswordRequest* pPasswordRequest = new ::comphelper::DocPasswordRequest( - eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)) ); + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( getCurentSfxFilter() ) ) ); uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest ); xInteractionHandler->handle( rRequest ); - if ( pPasswordRequest->isPassword() ) - rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); + if ( pPasswordRequest->isSelected() ) + { + if ( pPasswordRequest->isPassword() ) + rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); + + if ( pPasswordRequest->isRecommendReadOnly() ) + rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); + + if ( pPasswordRequest->getPasswordToModify().getLength() ) + rpSet->Put( SfxStringItem( SID_PASSWORDTOMODIFY, pPasswordRequest->getPasswordToModify() ) ); + } else return ERRCODE_ABORT; } diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx index e955c43af705..1219d30d7b27 100644 --- a/sfx2/source/doc/docfilt.cxx +++ b/sfx2/source/doc/docfilt.cxx @@ -49,20 +49,6 @@ using namespace ::com::sun::star; -namespace sfx2 { - -// TODO #i105076# this should be in the filter configuration!!! -bool CheckMSPasswordCapabilityForExport( const String& rFilterName ) -{ - return - rFilterName.EqualsAscii( "MS Word 97" ) || - rFilterName.EqualsAscii( "MS Word 97 Vorlage" ) || - rFilterName.EqualsAscii( "MS Excel 97" ) || - rFilterName.EqualsAscii( "MS Excel 97 Vorlage/Template" ); -} - -} // namespace sfx2 - // STATIC DATA ----------------------------------------------------------- DBG_NAME(SfxFilter) -- cgit From a6c29b00be50f9b48c56903d5764518b7b3aced9 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Fri, 26 Mar 2010 09:35:40 +0100 Subject: tl78: #i105076# add ENCRYPTION and PASSWORDTOMODIFY filter flags --- sfx2/inc/sfx2/docfilt.hxx | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/sfx2/inc/sfx2/docfilt.hxx b/sfx2/inc/sfx2/docfilt.hxx index b4118272bb88..f024fdb07c06 100644 --- a/sfx2/inc/sfx2/docfilt.hxx +++ b/sfx2/inc/sfx2/docfilt.hxx @@ -37,6 +37,7 @@ #include #include +// TODO/LATER: The flags should be part of the UNO specification #define SFX_FILTER_IMPORT 0x00000001L #define SFX_FILTER_EXPORT 0x00000002L #define SFX_FILTER_TEMPLATE 0x00000004L @@ -45,13 +46,13 @@ #define SFX_FILTER_OWN 0x00000020L #define SFX_FILTER_ALIEN 0x00000040L #define SFX_FILTER_USESOPTIONS 0x00000080L -#define SFX_FILTER_NOTINFILEDLG 0x00001000L -#define SFX_FILTER_NOTINCHOOSER 0x00002000L #define SFX_FILTER_DEFAULT 0x00000100L #define SFX_FILTER_EXECUTABLE 0x00000200L #define SFX_FILTER_SUPPORTSSELECTION 0x00000400L #define SFX_FILTER_MAPTOAPPPLUG 0x00000800L +#define SFX_FILTER_NOTINFILEDLG 0x00001000L +#define SFX_FILTER_NOTINCHOOSER 0x00002000L #define SFX_FILTER_ASYNC 0x00004000L // Legt Objekt nur an, kein Laden #define SFX_FILTER_CREATOR 0x00008000L @@ -64,6 +65,10 @@ #define SFX_FILTER_SILENTEXPORT 0x00200000L #define SFX_FILTER_BROWSERPREFERED 0x00400000L + +#define SFX_FILTER_ENCRYPTION 0x01000000L +#define SFX_FILTER_PASSWORDTOMODIFY 0x02000000L + #define SFX_FILTER_PREFERED 0x10000000L #define SFX_FILTER_VERSION_NONE 0 @@ -71,20 +76,6 @@ #include -//======================================================================== - -namespace sfx2 { - -/** Returns true if the passed string is the name of a Microsoft Office file - format filter supporting export of password protected documents. - - This function is just a hack for #i105076# is fixed and needs to be removed - then. - */ -SFX2_DLLPUBLIC bool CheckMSPasswordCapabilityForExport( const String& rFilterName ); - -} // namespace sfx2 - //======================================================================== class SfxFilterContainer; class SotStorage; -- cgit From d160fd054bc4e8c02152d7ce55f7eddbd611e01f Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 30 Mar 2010 16:47:18 +0200 Subject: tl78: #i110383# support password to modify --- sfx2/inc/sfx2/sfxsids.hrc | 5 +- sfx2/sdi/sfx.sdi | 30 +++++++++- sfx2/source/dialog/filedlghelper.cxx | 51 ++++++++++++++-- sfx2/source/doc/guisaveas.cxx | 109 +++++++++++++++++++++++++++++++++++ sfx2/source/doc/objstor.cxx | 51 +--------------- 5 files changed, 188 insertions(+), 58 deletions(-) diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index a7c73d3e14d8..64bb5692cf09 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -505,8 +505,9 @@ #define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) #define SID_FONT_NAME (SID_SFX_START + 1716) #define SID_DEFAULTFILENAME (SID_SFX_START + 1717) -#define SID_MODIFYPASSWORDHASH (SID_SFX_START + 1718) -#define SID_SFX_free_START (SID_SFX_START + 1719) +#define SID_PASSWORDTOMODIFYHASH (SID_SFX_START + 1718) +#define SID_RECOMMENDREADONLY (SID_SFX_START + 1719) +#define SID_SFX_free_START (SID_SFX_START + 1720) #define SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 1b59c639a17d..9df71c085b25 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3990,7 +3990,7 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER ] //-------------------------------------------------------------------------- -SfxInt32Item ModifyPasswordHash SID_MODIFYPASSWORDHASH +SfxUInt16Item PasswordToModifyHash SID_PASSWORDTOMODIFYHASH [ /* flags: */ @@ -4016,6 +4016,34 @@ SfxInt32Item ModifyPasswordHash SID_MODIFYPASSWORDHASH GroupId = ; ] +//-------------------------------------------------------------------------- +SfxBoolItem ReccomendReadonly SID_RECOMMENDREADONLY + +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = TRUE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + Readonly = TRUE, + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = ; +] + + //-------------------------------------------------------------------------- SfxVoidItem RunMacro SID_RUNMACRO () diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 5e4e7d88258c..adca8cdb7922 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include @@ -1543,7 +1544,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, mbPwdCheckBoxState = ( pPassItem != NULL ); // in case the document has password to modify, the dialog should be shown - SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxStringItem, SID_PASSWORDTOMODIFY, FALSE ); + SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUInt16Item, SID_PASSWORDTOMODIFYHASH, FALSE ); mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); } @@ -1556,7 +1557,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // the password will be set in case user decide so rpSet->ClearItem( SID_PASSWORD ); rpSet->ClearItem( SID_RECOMMENDREADONLY ); - rpSet->ClearItem( SID_PASSWORDTOMODIFY ); + rpSet->ClearItem( SID_PASSWORDTOMODIFYHASH ); } @@ -1634,8 +1635,10 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // set the filter getRealFilter( rFilter ); + SfxFilter* pCurrentFilter = getCurentSfxFilter(); + // fill the rpURLList - implGetAndCacheFiles(mxFileDlg, rpURLList, getCurentSfxFilter()); + implGetAndCacheFiles( mxFileDlg, rpURLList, pCurrentFilter ); if ( rpURLList == NULL || rpURLList->GetObject(0) == NULL ) return ERRCODE_ABORT; @@ -1654,12 +1657,13 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if( xInteractionHandler.is() ) { // TODO: need a save way to distinguish MS filters from other filters - sal_Bool bMSType = CheckMSPasswordCapabilityForExport( rFilter ); + // for now MS-filters are the only alien filters that support encryption + sal_Bool bMSType = !pCurrentFilter->isOwn(); ::comphelper::DocPasswordRequestType eType = bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; - ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( getCurentSfxFilter() ) ) ); + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( pCurrentFilter ) ) ); uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest ); xInteractionHandler->handle( rRequest ); @@ -1672,7 +1676,42 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); if ( pPasswordRequest->getPasswordToModify().getLength() ) - rpSet->Put( SfxStringItem( SID_PASSWORDTOMODIFY, pPasswordRequest->getPasswordToModify() ) ); + { + rtl_TextEncoding nEncoding = RTL_TEXTENCOFING_UTF8; + if ( bMSType ) + { + // if the MS-filter should be used + // use the inconsistent algorithm to find the encoding specified by MS + nEncoding = rtl_getThreadTextEncoding(); + switch( nEncoding ) + { + case RTL_TEXTENCODING_ISO_8859_15: + case RTL_TEXTENCODING_MS_874: + case RTL_TEXTENCODING_MS_1250: + case RTL_TEXTENCODING_MS_1251: + case RTL_TEXTENCODING_MS_1252: + case RTL_TEXTENCODING_MS_1253: + case RTL_TEXTENCODING_MS_1254: + case RTL_TEXTENCODING_MS_1255: + case RTL_TEXTENCODING_MS_1256: + case RTL_TEXTENCODING_MS_1257: + case RTL_TEXTENCODING_MS_1258: + case RTL_TEXTENCODING_SHIFT_JIS: + case RTL_TEXTENCODING_GB_2312: + case RTL_TEXTENCODING_BIG5: + // in case the system uses an encoding from the list above, it should be used + break; + + default: + // in case other encoding is used, use one of the encodings from the list + nEncoding = RTL_TEXTENCODING_MS_1250; + break; + } + } + + sal_uInt16 nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( pPasswordRequest->getPasswordToModify(), nEncoding ); + rpSet->Put( SfxUInt16Item( SID_PASSWORDTOMODIFYHASH, nHash ) ); + } } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index cbd269b41516..4993e96b40bb 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -62,6 +62,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -80,6 +83,7 @@ #include #include #include +#include #include #include "alienwarn.hxx" @@ -108,6 +112,7 @@ const ::rtl::OUString aFilterFlagsString = ::rtl::OUString::createFromAscii( " using namespace ::com::sun::star; +namespace { //------------------------------------------------------------------------- static sal_uInt16 getSlotIDFromMode( sal_Int8 nStoreMode ) { @@ -167,6 +172,88 @@ static sal_Int32 getDontFlags( sal_Int8 nStoreMode ) | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) ? SFX_FILTER_IMPORT : 0 ) ); } +//========================================================================= +// class DocumentSettingsGuard +//========================================================================= + +class DocumentSettingsGuard +{ + uno::Reference< beans::XPropertySet > m_xDocumentSettings; + sal_Bool m_bPreserveReadOnly; + sal_uInt16 m_nPreserveHash; + + sal_Bool m_bReadOnlySupported; + sal_Bool m_bModifyPasswordHashSupported; + + sal_Bool m_bRestoreSettings; +public: + DocumentSettingsGuard( const uno::Reference< frame::XModel >& xModel, sal_Bool bReadOnly, sal_uInt16 nHash, sal_Bool bRestore ) + : m_bPreserveReadOnly( sal_False ) + , m_nPreserveHash( 0 ) + , m_bReadOnlySupported( sal_False ) + , m_bModifyPasswordHashSupported( sal_False ) + , m_bRestoreSettings( bRestore ) + { + try + { + uno::Reference< lang::XMultiServiceFactory > xDocSettingsSupplier( xModel, uno::UNO_QUERY_THROW ); + m_xDocumentSettings.set( + xDocSettingsSupplier->createInstance( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), + uno::UNO_QUERY_THROW ); + + ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) ); + ::rtl::OUString aModifyPasswordHashString( RTL_CONSTASCII_USTRINGPARAM( "ModifyPasswordHash" ) ); + + try + { + m_xDocumentSettings->getPropertyValue( aLoadReadonlyString ) >>= m_bPreserveReadOnly; + m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::makeAny( bReadOnly ) ); + m_bReadOnlySupported = sal_True; + } + catch( uno::Exception& ) + {} + + try + { + m_xDocumentSettings->getPropertyValue( aModifyPasswordHashString ) >>= m_nPreserveHash; + m_xDocumentSettings->setPropertyValue( aModifyPasswordHashString, uno::makeAny( nHash ) ); + m_bModifyPasswordHashSupported = sal_True; + } + catch( uno::Exception& ) + {} + } + catch( uno::Exception& ) + {} + + if ( ( bReadOnly && !m_bReadOnlySupported ) || ( nHash && !m_bModifyPasswordHashSupported ) ) + throw uno::RuntimeException(); // the user could provide the data, so it must be stored + } + + ~DocumentSettingsGuard() + { + if ( m_bRestoreSettings ) + { + ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) ); + ::rtl::OUString aModifyPasswordHashString( RTL_CONSTASCII_USTRINGPARAM( "ModifyPasswordHash" ) ); + + try + { + if ( m_bReadOnlySupported ) + m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::makeAny( m_bPreserveReadOnly ) ); + + if ( m_bModifyPasswordHashSupported ) + m_xDocumentSettings->setPropertyValue( aModifyPasswordHashString, uno::makeAny( m_nPreserveHash ) ); + } + catch( uno::Exception& ) + { + OSL_ASSERT( "Unexpected exception!" ); + } + } + } +}; +} // anonymous namespace + //========================================================================= // class ModelData_Impl //========================================================================= @@ -184,6 +271,9 @@ class ModelData_Impl ::comphelper::SequenceAsHashMap m_aMediaDescrHM; + sal_Bool m_bRecommendReadOnly; + sal_uInt16 m_nPasswordToModifyHash; + public: ModelData_Impl( SfxStoringHelper& aOwner, const uno::Reference< frame::XModel >& xModel, @@ -200,6 +290,9 @@ public: ::comphelper::SequenceAsHashMap& GetMediaDescr() { return m_aMediaDescrHM; } + sal_Bool IsRecommendReadOnly() { return m_bRecommendReadOnly; } + sal_uInt16 GetPasswordToModifyHash() { return m_nPasswordToModifyHash; } + const ::comphelper::SequenceAsHashMap& GetDocProps(); ::rtl::OUString GetModuleName(); @@ -252,6 +345,9 @@ ModelData_Impl::ModelData_Impl( SfxStoringHelper& aOwner, , m_pDocumentPropsHM( NULL ) , m_pModulePropsHM( NULL ) , m_aMediaDescrHM( aMediaDescr ) +, m_bRecommendReadOnly( sal_False ) +, m_nPasswordToModifyHash( 0 ) + { CheckInteractionHandler(); } @@ -916,6 +1012,17 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode, ::rtl::OUString aFilterName = aStringTypeFN; + // the following two arguments can not be converted in MediaDescriptor, + // so they should be removed from the ItemSet after retrieving + SFX_ITEMSET_ARG( pDialogParams, pRecommendReadOnly, SfxBoolItem, SID_RECOMMENDREADONLY, sal_False ); + m_bRecommendReadOnly = ( pRecommendReadOnly && pRecommendReadOnly->GetValue() ); + pDialogParams->ClearItem( SID_RECOMMENDREADONLY ); + + SFX_ITEMSET_ARG( pDialogParams, pPassToModifyItem, SfxUInt16Item, SID_PASSWORDTOMODIFYHASH, sal_False ); + if ( pPassToModifyItem ) + m_nPasswordToModifyHash = pPassToModifyItem->GetValue(); + pDialogParams->ClearItem( SID_PASSWORDTOMODIFYHASH ); + uno::Sequence< beans::PropertyValue > aPropsFromDialog; TransformItems( nSlotID, *pDialogParams, aPropsFromDialog, NULL ); GetMediaDescr() << aPropsFromDialog; @@ -1500,6 +1607,8 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& // store the document and handle it's docinfo SvtSaveOptions aOptions; + DocumentSettingsGuard aSettingsGuard( aModelData.GetModel(), aModelData.IsRecommendReadOnly(), aModelData.GetPasswordToModifyHash(), nStoreMode & EXPORT_REQUESTED ); + if ( aOptions.IsDocInfoSave() && ( !aModelData.GetStorable()->hasLocation() || INetURLObject( aModelData.GetStorable()->getLocation() ) != aURL ) ) diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 593de3d181f1..b710a4b0fbfe 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1376,7 +1376,6 @@ sal_Bool SfxObjectShell::SaveTo_Impl { if ( pFilt->GetServiceName() != rMedium.GetFilter()->GetServiceName() ) { -//REMOVE rMedium.GetStorage()->SetClass( SvFactory::GetServerName( nFormat ), nFormat, pFilt->GetTypeName() ); datatransfer::DataFlavor aDataFlavor; SotExchange::GetFormatDataFlavor( nFormat, aDataFlavor ); @@ -2093,9 +2092,6 @@ sal_Bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed ) } else { -//REMOVE if( pFilter->UsesStorage() ) -//REMOVE pMedium->GetStorage(); -//REMOVE else if( pMedium->GetOpenMode() & STREAM_WRITE ) if( pMedium->GetOpenMode() & STREAM_WRITE ) pMedium->GetInStream(); xStorage = GetStorage(); @@ -2632,9 +2628,6 @@ sal_Bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) SetError(pMediumTmp->GetErrorCode(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); -//REMOVE if ( !IsHandsOff() ) -//REMOVE pMediumTmp->Close(); - sal_Bool bOpen( sal_False ); bOpen = DoSaveCompleted( pMediumTmp ); DBG_ASSERT(bOpen,"Fehlerbehandlung fuer DoSaveCompleted nicht implementiert"); @@ -2645,13 +2638,7 @@ sal_Bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) SetError( pMediumTmp->GetError(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); // reconnect to object storage -//REMOVE if ( IsHandsOff() ) -//REMOVE { -//REMOVE if ( !DoSaveCompleted( pRetrMedium ) ) -//REMOVE DBG_ERROR("Case not handled - no way to get a storage!"); -//REMOVE } -//REMOVE else - DoSaveCompleted( 0 ); + DoSaveCompleted( 0 ); if( pRetrMedium->GetItemSet() ) { @@ -2910,8 +2897,6 @@ sal_Bool SfxObjectShell::PreDoSaveAs_Impl else pNewFile->SetFilter( GetFactory().GetFilterContainer()->GetAnyFilter( SFX_FILTER_IMPORT | SFX_FILTER_EXPORT ) ); -//REMOVE // saving is alway done using a temporary file -//REMOVE pNewFile->CreateTempFileNoCopy(); if ( pNewFile->GetErrorCode() != ERRCODE_NONE ) { // creating temporary file failed ( f.e. floppy disk not inserted! ) @@ -2948,18 +2933,8 @@ sal_Bool SfxObjectShell::PreDoSaveAs_Impl SetError( pNewFile->GetErrorCode(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); // notify the document that saving was done successfully -//REMOVE if ( bCopyTo ) -//REMOVE { -//REMOVE if ( IsHandsOff() ) -//REMOVE bOk = DoSaveCompleted( pMedium ); -//REMOVE } -//REMOVE else if ( !bCopyTo ) { - // Muss !!! -//REMOVE if ( bToOwnFormat ) -//REMOVE SetFileName( pNewFile->GetPhysicalName() ); - bOk = DoSaveCompleted( pNewFile ); } else @@ -2991,31 +2966,12 @@ sal_Bool SfxObjectShell::PreDoSaveAs_Impl // by the storage DELETEZ( pNewFile ); } - - // TODO/LATER: there is no need in the following code in case HandsOff is not used, - // hope we will not have to introduce it back -//REMOVE String aPasswd; -//REMOVE if ( IsOwnStorageFormat_Impl( *GetMedium() ) && GetPasswd_Impl( GetMedium()->GetItemSet(), aPasswd ) ) -//REMOVE { -//REMOVE try -//REMOVE { -//REMOVE // the following code must throw an exception in case of failure -//REMOVE ::comphelper::OStorageHelper::SetCommonStoragePassword( GetMedium->GetStorage(), aPasswd ); -//REMOVE } -//REMOVE catch( uno::Exception& ) -//REMOVE { -//REMOVE // TODO: handle the error -//REMOVE } -//REMOVE } } else { SetError( pNewFile->GetErrorCode(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); -//REMOVE // reconnect to the old storage -//REMOVE if ( IsHandsOff() ) -//REMOVE DoSaveCompleted( pMedium ); -//REMOVE else + // reconnect to the old storage DoSaveCompleted( 0 ); DELETEZ( pNewFile ); @@ -3196,9 +3152,6 @@ sal_Bool SfxObjectShell::LoadOwnFormat( SfxMedium& rMedium ) uno::Reference< embed::XStorage > xStorage = rMedium.GetStorage(); if ( xStorage.is() ) { -//REMOVE if ( rMedium.GetFileVersion() ) -//REMOVE xStor->SetVersion( rMedium.GetFileVersion() ); - // Password SFX_ITEMSET_ARG( rMedium.GetItemSet(), pPasswdItem, SfxStringItem, SID_PASSWORD, sal_False ); if ( pPasswdItem || ERRCODE_IO_ABORT != CheckPasswd_Impl( this, SFX_APP()->GetPool(), pMedium ) ) -- cgit From 0e95d8378a6f670993a3d408d3bfe313385379e8 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 30 Mar 2010 16:34:51 +0200 Subject: tl78: #i110383# support password to modify --- sfx2/inc/sfx2/objsh.hxx | 3 +++ sfx2/source/dialog/filedlghelper.cxx | 16 ++++++++-------- sfx2/source/doc/objcont.cxx | 17 +++++++++++++++++ sfx2/source/doc/objxtor.cxx | 1 + sfx2/source/inc/objshimp.hxx | 2 ++ 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index e0142e9ba140..99161cb5b36c 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -444,6 +444,9 @@ public: void SetSaveVersionOnClose( sal_Bool bSet ); void ResetFromTemplate( const String& rTemplateName, const String& rFileName ); + sal_uInt16 GetModifyPasswordHash() const; + sal_Bool SetModifyPasswordHash( sal_uInt16 nHash ); + static sal_uInt32 HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc ); virtual void ViewAssigned(); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index adca8cdb7922..c1b9aaf7838d 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1635,7 +1635,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // set the filter getRealFilter( rFilter ); - SfxFilter* pCurrentFilter = getCurentSfxFilter(); + const SfxFilter* pCurrentFilter = getCurentSfxFilter(); // fill the rpURLList implGetAndCacheFiles( mxFileDlg, rpURLList, pCurrentFilter ); @@ -1658,31 +1658,31 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, { // TODO: need a save way to distinguish MS filters from other filters // for now MS-filters are the only alien filters that support encryption - sal_Bool bMSType = !pCurrentFilter->isOwn(); + sal_Bool bMSType = !pCurrentFilter->IsOwnFormat(); ::comphelper::DocPasswordRequestType eType = bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( pCurrentFilter ) ) ); - uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest ); + uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); xInteractionHandler->handle( rRequest ); - if ( pPasswordRequest->isSelected() ) + if ( pPasswordRequest->isPassword() ) { - if ( pPasswordRequest->isPassword() ) + if ( pPasswordRequest->getPassword().getLength() ) rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); - if ( pPasswordRequest->isRecommendReadOnly() ) + if ( pPasswordRequest->getRecommendReadOnly() ) rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); if ( pPasswordRequest->getPasswordToModify().getLength() ) { - rtl_TextEncoding nEncoding = RTL_TEXTENCOFING_UTF8; + rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; if ( bMSType ) { // if the MS-filter should be used // use the inconsistent algorithm to find the encoding specified by MS - nEncoding = rtl_getThreadTextEncoding(); + nEncoding = osl_getThreadTextEncoding(); switch( nEncoding ) { case RTL_TEXTENCODING_ISO_8859_15: diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 207a5096a89a..b1a5968b2b5a 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1479,3 +1479,20 @@ void SfxObjectShell::SetSaveVersionOnClose( sal_Bool bNew ) pImp->bSaveVersionOnClose = bNew; } +sal_uInt16 SfxObjectShell::GetModifyPasswordHash() const +{ + return pImp->m_nModifyPasswordHash; +} + +sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt16 nHash ) +{ + if ( !IsReadOnly() && !IsReadOnlyUI() ) + { + // the hash can be changed only in editable documents, + pImp->m_nModifyPasswordHash = nHash; + return sal_True; + } + + return sal_False; +} + diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index e3e3a36505a5..0ed230dd9dd9 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -262,6 +262,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_xDocInfoListener() ,m_bIsInit( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) + ,m_nModifyPasswordHash( 0 ) { } diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index e015058ae280..a97018e4b3f6 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -170,6 +170,8 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_Bool m_bIncomplEncrWarnShown; + sal_uInt16 m_nModifyPasswordHash; + SfxObjectShell_Impl( SfxObjectShell& _rDocShell ); virtual ~SfxObjectShell_Impl(); -- cgit From 9ace57ec709cd618b5401da6f1ebacba5a07c1c0 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 1 Apr 2010 15:31:41 +0200 Subject: tl78: #i110383# allow to change the hash always for now --- sfx2/source/doc/objcont.cxx | 15 +++++++++------ sfx2/source/doc/objxtor.cxx | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index b1a5968b2b5a..5d14007ec169 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1486,13 +1486,16 @@ sal_uInt16 SfxObjectShell::GetModifyPasswordHash() const sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt16 nHash ) { - if ( !IsReadOnly() && !IsReadOnlyUI() ) - { - // the hash can be changed only in editable documents, +// Commented out before the solution for Saving process is found +// if ( ( !IsReadOnly() && !IsReadOnlyUI() ) +// || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) ) +// { +// // the hash can be changed only in editable documents, +// // or during loading of document pImp->m_nModifyPasswordHash = nHash; return sal_True; - } - - return sal_False; +// } +// +// return sal_False; } diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 0ed230dd9dd9..0b0c356b65ed 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -261,6 +261,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bCreateTempStor( sal_False ) ,m_xDocInfoListener() ,m_bIsInit( sal_False ) + ,m_bUIStoring( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) ,m_nModifyPasswordHash( 0 ) { -- cgit From 62eee956dbb05c25600030ab47310bf39db0c7ee Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 1 Apr 2010 15:37:38 +0200 Subject: tl78: #i110383# fix typo --- sfx2/source/doc/objxtor.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 0b0c356b65ed..0ed230dd9dd9 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -261,7 +261,6 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bCreateTempStor( sal_False ) ,m_xDocInfoListener() ,m_bIsInit( sal_False ) - ,m_bUIStoring( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) ,m_nModifyPasswordHash( 0 ) { -- cgit From fb70a4cd3b77e0ea6bb5820b47bfd7ea39fa3228 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 6 Apr 2010 17:15:01 +0200 Subject: jl152 import 263445 from native0jl:#i77196# supporting extension help --- desktop/source/deployment/registry/dp_backend.cxx | 9 + .../source/deployment/registry/help/dp_help.cxx | 583 +++++++++++---------- .../deployment/registry/help/dp_helpbackenddb.cxx | 10 +- .../deployment/registry/help/dp_helpbackenddb.hxx | 3 +- .../source/deployment/registry/inc/dp_backend.h | 3 + xmlhelp/source/cxxhelp/provider/databases.cxx | 178 +++++-- xmlhelp/source/cxxhelp/provider/databases.hxx | 19 +- xmlhelp/source/cxxhelp/provider/urlparameter.cxx | 10 +- xmlhelp/source/cxxhelp/provider/urlparameter.hxx | 3 + 9 files changed, 492 insertions(+), 326 deletions(-) diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index dcfc2c6b3d2f..be752bcf0733 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -716,6 +716,15 @@ OUString Package::getRepositoryName() return backEnd->getContext(); } +beans::Optional< OUString > Package::getRegistrationDataURL() + throw (deployment::ExtensionRemovedException, + css::uno::RuntimeException) +{ + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + return beans::Optional(); +} + sal_Bool Package::isRemoved() throw (RuntimeException) { diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index b594f9395ceb..aeeec94981e6 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -46,7 +46,7 @@ #include #include #include - +#include "boost/optional.hpp" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -80,11 +80,15 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv ); public: - inline PackageImpl( + PackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, bool bRemoved, OUString const & identifier); + + //XPackage + virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getRegistrationDataURL() + throw (deployment::ExtensionRemovedException, css::uno::RuntimeException); }; friend class PackageImpl; @@ -98,13 +102,13 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv); void implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ); - rtl::OUString getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ); - rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); - rtl::OUString getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ); - rtl::OUString expandURL( const rtl::OUString& aURL ); +// rtl::OUString getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ); +// rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); +// rtl::OUString getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ); +// rtl::OUString expandURL( const rtl::OUString& aURL ); void addDataToDb(OUString const & url, HelpBackendDb::Data const & data); - HelpBackendDb::Data readDataFromDb(OUString const & url); + ::boost::optional readDataFromDb(OUString const & url); void deleteDataFromDb(OUString const & url); Reference< ucb::XSimpleFileAccess > getFileAccess( void ); @@ -208,10 +212,10 @@ void BackendImpl::addDataToDb( m_backendDb->addEntry(url, data); } -HelpBackendDb::Data BackendImpl::readDataFromDb( +::boost::optional BackendImpl::readDataFromDb( OUString const & url) { - HelpBackendDb::Data data; + ::boost::optional data; if (m_backendDb.get()) data = m_backendDb->getEntry(url); return data; @@ -232,7 +236,12 @@ BackendImpl::PackageImpl::PackageImpl( : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) { if (bRemoved) - m_dbData = getMyBackend()->readDataFromDb(url); + { + ::boost::optional opt = + getMyBackend()->readDataFromDb(url); + if (opt) + m_dbData = *opt; + } } // Package @@ -259,11 +268,10 @@ BackendImpl::PackageImpl::isRegistered_( Reference const & ) { BackendImpl * that = getMyBackend(); - Reference< deployment::XPackage > xThisPackage( this ); - rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage ); - Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess(); - bool bReg = xSFA->exists( aRegisteredFlagFile ); + bool bReg = false; + if (that->readDataFromDb(getURL())) + bReg = true; return beans::Optional< beans::Ambiguous >( true, beans::Ambiguous( bReg, false ) ); } @@ -291,6 +299,23 @@ void BackendImpl::PackageImpl::processPackage_( // getMyBackend()->deleteDataFromDb(getURL()); } +beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL() + throw (deployment::ExtensionRemovedException, + css::uno::RuntimeException) +{ + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + + ::boost::optional data = + getMyBackend()->readDataFromDb(getURL()); + + if (data) + return beans::Optional(true, data->dataUrl); + + return beans::Optional(true, OUString()); +} + + //############################################################################## static rtl::OUString aSlash( rtl::OUString::createFromAscii( "/" ) ); @@ -305,232 +330,230 @@ void BackendImpl::implProcessHelp if (doRegisterPackage) { HelpBackendDb::Data data; - Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); + const OUString sHelpFolder = createFolder(OUString(), xCmdEnv); + data.dataUrl = sHelpFolder; - rtl::OUString aRegisteredFlagFile = getRegisteredFlagFileURL( xPackage ); - if( !doRegisterPackage ) + Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); + rtl::OUString aHelpURL = xPackage->getURL(); + rtl::OUString aExpandedHelpURL = dp_misc::expandUnoRcUrl( aHelpURL ); + rtl::OUString aName = xPackage->getName(); + if( !xSFA->isFolder( aExpandedHelpURL ) ) { - if( xSFA->exists( aRegisteredFlagFile ) ) - xSFA->kill( aRegisteredFlagFile ); - return; + rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); + aErrStr += rtl::OUString::createFromAscii( "No help folder" ); + OWeakObject* oWeakThis = static_cast(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } - bool bCompile = true; - rtl::OUString aCompiledFlagFile = getCompiledFlagFileURL( xPackage ); - if( xSFA->exists( aCompiledFlagFile ) ) - bCompile = false; - - if( bCompile ) + Reference const & xContext = getComponentContext(); + Reference< script::XInvocation > xInvocation; + if( xContext.is() ) { - OUString sHelpFolder = createFolder(OUString(), xCmdEnv); - data.dataUrl = sHelpFolder; - rtl::OUString aHelpURL = xPackage->getURL(); - rtl::OUString aExpandedHelpURL = expandURL( aHelpURL ); - rtl::OUString aName = xPackage->getName(); - if( !xSFA->isFolder( aExpandedHelpURL ) ) + try { - rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); - aErrStr += rtl::OUString::createFromAscii( "No help folder" ); - OWeakObject* oWeakThis = static_cast(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + xInvocation = Reference< script::XInvocation >( + xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( + "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); } - - Reference const & xContext = getComponentContext(); - Reference< script::XInvocation > xInvocation; - if( xContext.is() ) + catch (Exception &) { - try - { - xInvocation = Reference< script::XInvocation >( - xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); - } - catch (Exception &) - { - // i98680: Survive missing lucene - } + // i98680: Survive missing lucene } + } - // Scan languages - Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); - sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); - const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); - for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) + // Scan languages + Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); + sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); + const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); + for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) + { + rtl::OUString aLangURL = pSeq[iLang]; + if( xSFA->isFolder( aLangURL ) ) { - rtl::OUString aLangURL = pSeq[iLang]; - if( xSFA->isFolder( aLangURL ) ) + std::vector< rtl::OUString > aXhpFileVector; + + // Delete (old) files in any case to allow compiler to be started every time +// rtl::OUString aLangWithPureNameURL( aLangURL ); +// aLangWithPureNameURL += aSlash; +// aLangWithPureNameURL += aHelpStr; +// rtl::OUString aDbFile( aLangWithPureNameURL ); +// aDbFile += rtl::OUString::createFromAscii( ".db" ); +// if( xSFA->exists( aDbFile ) ) +// xSFA->kill( aDbFile ); +// rtl::OUString aHtFile( aLangWithPureNameURL ); +// aHtFile += rtl::OUString::createFromAscii( ".ht" ); +// if( xSFA->exists( aHtFile ) ) +// xSFA->kill( aHtFile ); +// rtl::OUString aKeyFile( aLangWithPureNameURL ); +// aKeyFile += rtl::OUString::createFromAscii( ".key" ); +// if( xSFA->exists( aKeyFile ) ) +// xSFA->kill( aKeyFile ); + + // calculate jar file URL + sal_Int32 indexStartSegment = aLangURL.lastIndexOf('/'); + // for example "/en" + OUString langFolderURLSegment( + aLangURL.copy( + indexStartSegment + 1, aLangURL.getLength() - indexStartSegment - 1)); + + //create the folder in the "temporary folder" + ::ucbhelper::Content langFolderContent; + const OUString langFolderDest = makeURL(sHelpFolder, langFolderURLSegment); + const OUString langFolderDestExpanded = ::dp_misc::expandUnoRcUrl(langFolderDest); + ::dp_misc::create_folder( + &langFolderContent, + langFolderDest, xCmdEnv); + + rtl::OUString aJarFile( + makeURL(sHelpFolder, langFolderURLSegment + aSlash + aHelpStr + + OUSTR(".jar"))); +// aJarFile += aSlash; +// aJarFile += aHelpStr; +// aJarFile += rtl::OUString::createFromAscii( ".jar" ); + // remove in any case to clean up +// if( xSFA->exists( aJarFile ) ) +// xSFA->kill( aJarFile ); + aJarFile = ::dp_misc::expandUnoRcUrl(aJarFile); + + rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( + aJarFile, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ); + rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" ); + aDestBasePath += aEncodedJarFilePath; + aDestBasePath += rtl::OUString::createFromAscii( "/" ); + + sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; + + Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); + sal_Int32 nSubLangCount = aSubLangSeq.getLength(); + const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); + for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) { - std::vector< rtl::OUString > aXhpFileVector; - - // Delete (old) files in any case to allow compiler to be started every time - rtl::OUString aLangWithPureNameURL( aLangURL ); - aLangWithPureNameURL += aSlash; - aLangWithPureNameURL += aHelpStr; - rtl::OUString aDbFile( aLangWithPureNameURL ); - aDbFile += rtl::OUString::createFromAscii( ".db" ); - if( xSFA->exists( aDbFile ) ) - xSFA->kill( aDbFile ); - rtl::OUString aHtFile( aLangWithPureNameURL ); - aHtFile += rtl::OUString::createFromAscii( ".ht" ); - if( xSFA->exists( aHtFile ) ) - xSFA->kill( aHtFile ); - rtl::OUString aKeyFile( aLangWithPureNameURL ); - aKeyFile += rtl::OUString::createFromAscii( ".key" ); - if( xSFA->exists( aKeyFile ) ) - xSFA->kill( aKeyFile ); - - // calculate jar file URL - rtl::OUString aJarFile( aLangURL ); - aJarFile += aSlash; - aJarFile += aHelpStr; - aJarFile += rtl::OUString::createFromAscii( ".jar" ); - // remove in any case to clean up - if( xSFA->exists( aJarFile ) ) - xSFA->kill( aJarFile ); - - rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( aJarFile, - rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ); - rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" ); - aDestBasePath += aEncodedJarFilePath; - aDestBasePath += rtl::OUString::createFromAscii( "/" ); - - sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; - - Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); - sal_Int32 nSubLangCount = aSubLangSeq.getLength(); - const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); - for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) - { - rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; - if( !xSFA->isFolder( aSubFolderURL ) ) - continue; + rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; + if( !xSFA->isFolder( aSubFolderURL ) ) + continue; - implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); + implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); - // Copy to package (later: move?) - rtl::OUString aDestPath = aDestBasePath; - rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); - aDestPath += aPureFolderName; - xSFA->copy( aSubFolderURL, aDestPath ); - } + // Copy to package (later: move?) + rtl::OUString aDestPath = aDestBasePath; + rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); + aDestPath += aPureFolderName; + xSFA->copy( aSubFolderURL, aDestPath ); + } + //Copy help.tree to the temp folder in the help backend folder +// xSFA->copy(aLangURL + OUSTR("/help.tree"), langFolderDestExpanded + OUSTR("/help.tree")); - // Call compiler - sal_Int32 nXhpFileCount = aXhpFileVector.size(); - rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; - for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) - { - rtl::OUString aXhpFile = aXhpFileVector[iXhp]; - rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); - pXhpFiles[iXhp] = aXhpRelFile; - } + // Call compiler + sal_Int32 nXhpFileCount = aXhpFileVector.size(); + rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; + for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) + { + rtl::OUString aXhpFile = aXhpFileVector[iXhp]; + rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); + pXhpFiles[iXhp] = aXhpRelFile; + } - rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); - rtl::OUString aOfficeHelpPathFileURL; - ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); + rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); + rtl::OUString aOfficeHelpPathFileURL; + ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); - HelpProcessingErrorInfo aErrorInfo; - bool bSuccess = compileExtensionHelp( aOfficeHelpPathFileURL, aHelpStr, aLangURL, - nXhpFileCount, pXhpFiles, aErrorInfo ); + HelpProcessingErrorInfo aErrorInfo; + bool bSuccess = compileExtensionHelp( + aOfficeHelpPathFileURL, aHelpStr, aLangURL, + nXhpFileCount, pXhpFiles, + langFolderDestExpanded, aErrorInfo ); - if( bSuccess && xInvocation.is() ) - { - Sequence aParamsSeq( 6 ); - - aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); - - rtl::OUString aLang; - sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); - if( nLastSlash != -1 ) - aLang = aLangURL.copy( nLastSlash + 1 ); - else - aLang = rtl::OUString::createFromAscii( "en" ); - aParamsSeq[1] = uno::makeAny( aLang ); - - aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); - aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); - - aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); - rtl::OUString aSystemPath; - osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); - aParamsSeq[5] = uno::makeAny( aSystemPath ); - - Sequence< sal_Int16 > aOutParamIndex; - Sequence< uno::Any > aOutParam; - uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), - aParamsSeq, aOutParamIndex, aOutParam ); - } + if( bSuccess && xInvocation.is() ) + { + Sequence aParamsSeq( 6 ); + + aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); + + rtl::OUString aLang; + sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); + if( nLastSlash != -1 ) + aLang = aLangURL.copy( nLastSlash + 1 ); + else + aLang = rtl::OUString::createFromAscii( "en" ); + aParamsSeq[1] = uno::makeAny( aLang ); + + aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); + aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); + + aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); + rtl::OUString aSystemPath; +// osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); + osl::FileBase::getSystemPathFromFileURL( + langFolderDestExpanded, aSystemPath ); + aParamsSeq[5] = uno::makeAny( aSystemPath ); + + Sequence< sal_Int16 > aOutParamIndex; + Sequence< uno::Any > aOutParam; + uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), + aParamsSeq, aOutParamIndex, aOutParam ); + } - if( !bSuccess ) + if( !bSuccess ) + { + USHORT nErrStrId = 0; + switch( aErrorInfo.m_eErrorClass ) + { + case HELPPROCESSING_GENERAL_ERROR: + case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break; + case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break; + default: ; + }; + + rtl::OUString aErrStr; + if( nErrStrId != 0 ) { - USHORT nErrStrId = 0; - switch( aErrorInfo.m_eErrorClass ) + aErrStr = getResourceString( nErrStrId ); + + // Remoce CR/LF + rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); + sal_Unicode nCR = 13, nLF = 10; + sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); + sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); + sal_Int32 nCopy; + if( nSearchCR != -1 || nSearchLF != -1 ) { - case HELPPROCESSING_GENERAL_ERROR: - case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break; - case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break; - default: ; - }; - - rtl::OUString aErrStr; - if( nErrStrId != 0 ) + if( nSearchCR == -1 ) + nCopy = nSearchLF; + else if( nSearchLF == -1 ) + nCopy = nSearchCR; + else + nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; + + aErrMsg = aErrMsg.copy( 0, nCopy ); + } + aErrStr += aErrMsg; + if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) { - aErrStr = getResourceString( nErrStrId ); - - // Remoce CR/LF - rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); - sal_Unicode nCR = 13, nLF = 10; - sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); - sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); - sal_Int32 nCopy; - if( nSearchCR != -1 || nSearchLF != -1 ) - { - if( nSearchCR == -1 ) - nCopy = nSearchLF; - else if( nSearchLF == -1 ) - nCopy = nSearchCR; - else - nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; - - aErrMsg = aErrMsg.copy( 0, nCopy ); - } - aErrStr += aErrMsg; - if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) + aErrStr += rtl::OUString::createFromAscii( " in " ); + + rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); + aErrStr += aDecodedFile; + if( aErrorInfo.m_nXMLParsingLine != -1 ) { - aErrStr += rtl::OUString::createFromAscii( " in " ); - - rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - aErrStr += aDecodedFile; - if( aErrorInfo.m_nXMLParsingLine != -1 ) - { - aErrStr += rtl::OUString::createFromAscii( ", line " ); - aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); - } + aErrStr += rtl::OUString::createFromAscii( ", line " ); + aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); } } - - OWeakObject* oWeakThis = static_cast(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } + + OWeakObject* oWeakThis = static_cast(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } } - - // Write compiled flag file (this code is only reached in case of success) - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aCompiledFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); - - } // if( bCompile ) - - // Write registered flag file (this code is only reached in case of success) - if( !xSFA->exists( aRegisteredFlagFile ) ) - { - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); } + + //Writing the data entry replaces writing the flag file. If we got to this + //point the registration was successful. addDataToDb(xPackage->getURL(), data); } else @@ -539,75 +562,75 @@ void BackendImpl::implProcessHelp } } -rtl::OUString BackendImpl::getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ) -{ - rtl::OUString aRetURL; - if( !xPackage.is() ) - return aRetURL; - rtl::OUString aHelpURL = xPackage->getURL(); - aRetURL = expandURL( aHelpURL ); - aRetURL += rtl::OUString::createFromAscii( pFlagStr ); - return aRetURL; -} - -rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ) -{ - return getFlagFileURL( xPackage, "/RegisteredFlag" ); -} - -rtl::OUString BackendImpl::getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ) -{ - return getFlagFileURL( xPackage, "/CompiledFlag" ); -} - -rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL ) -{ - static Reference< util::XMacroExpander > xMacroExpander; - static Reference< uri::XUriReferenceFactory > xFac; - - if( !xMacroExpander.is() || !xFac.is() ) - { - Reference const & xContext = getComponentContext(); - if( xContext.is() ) - { - xFac = Reference< uri::XUriReferenceFactory >( - xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY ); - } - if( !xFac.is() ) - { - throw RuntimeException( - ::rtl::OUString::createFromAscii( - "dp_registry::backend::help::BackendImpl::expandURL(), " - "could not instatiate UriReferenceFactory." ), - Reference< XInterface >() ); - } - - xMacroExpander = Reference< util::XMacroExpander >( - xContext->getValueByName( - ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), - UNO_QUERY_THROW ); - } - - rtl::OUString aRetURL = aURL; - if( xMacroExpander.is() ) - { - Reference< uri::XUriReference > uriRef; - for (;;) - { - uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY ); - if ( uriRef.is() ) - { - Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY ); - if( !sxUri.is() ) - break; - - aRetURL = sxUri->expand( xMacroExpander ); - } - } - } - return aRetURL; -} +// rtl::OUString BackendImpl::getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ) +// { +// rtl::OUString aRetURL; +// if( !xPackage.is() ) +// return aRetURL; +// rtl::OUString aHelpURL = xPackage->getURL(); +// aRetURL = expandURL( aHelpURL ); +// aRetURL += rtl::OUString::createFromAscii( pFlagStr ); +// return aRetURL; +// } + +// rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ) +// { +// return getFlagFileURL( xPackage, "/RegisteredFlag" ); +// } + +// rtl::OUString BackendImpl::getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ) +// { +// return getFlagFileURL( xPackage, "/CompiledFlag" ); +// } + +// rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL ) +// { +// static Reference< util::XMacroExpander > xMacroExpander; +// static Reference< uri::XUriReferenceFactory > xFac; + +// if( !xMacroExpander.is() || !xFac.is() ) +// { +// Reference const & xContext = getComponentContext(); +// if( xContext.is() ) +// { +// xFac = Reference< uri::XUriReferenceFactory >( +// xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( +// "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY ); +// } +// if( !xFac.is() ) +// { +// throw RuntimeException( +// ::rtl::OUString::createFromAscii( +// "dp_registry::backend::help::BackendImpl::expandURL(), " +// "could not instatiate UriReferenceFactory." ), +// Reference< XInterface >() ); +// } + +// xMacroExpander = Reference< util::XMacroExpander >( +// xContext->getValueByName( +// ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), +// UNO_QUERY_THROW ); +// } + +// rtl::OUString aRetURL = aURL; +// if( xMacroExpander.is() ) +// { +// Reference< uri::XUriReference > uriRef; +// for (;;) +// { +// uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY ); +// if ( uriRef.is() ) +// { +// Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY ); +// if( !sxUri.is() ) +// break; + +// aRetURL = sxUri->expand( xMacroExpander ); +// } +// } +// } +// return aRetURL; +// } void BackendImpl::implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ) diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index 6f7e1d2844ac..f36eb6d7b8cb 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -143,7 +143,8 @@ void HelpBackendDb::removeEntry(::rtl::OUString const & url) removeElement(sExpression); } -HelpBackendDb::Data HelpBackendDb::getEntry(::rtl::OUString const & url) +::boost::optional +HelpBackendDb::getEntry(::rtl::OUString const & url) { try { @@ -174,8 +175,13 @@ HelpBackendDb::Data HelpBackendDb::getEntry(::rtl::OUString const & url) // readVectorOfPair( // aNode, OUSTR("reg:singletons"), OUSTR("item"), OUSTR("key"), // OUSTR("value")); + + } + else + { + return ::boost::optional(); } - return retData; + return ::boost::optional(retData); } catch(css::uno::Exception &) { diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx index e80a24f85ab1..bf812ad96511 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -35,6 +35,7 @@ #include "rtl/string.hxx" #include #include +#include "boost/optional.hpp" #include "dp_backenddb.hxx" namespace css = ::com::sun::star; @@ -87,7 +88,7 @@ public: void addEntry(::rtl::OUString const & url, Data const & data); void removeEntry(::rtl::OUString const & url); - Data getEntry(::rtl::OUString const & url); + ::boost::optional getEntry(::rtl::OUString const & url); ::std::list< ::rtl::OUString> getAllDataUrls(); }; diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 24c6e4914fe1..179420b16ef6 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -257,6 +257,9 @@ public: css::ucb::CommandAbortedException, css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getRepositoryName() throw (css::uno::RuntimeException); + virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getRegistrationDataURL() + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual sal_Bool SAL_CALL isRemoved() throw (css::uno::RuntimeException); diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index c5e2582b3905..5c164e08c100 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -1162,7 +1162,8 @@ Reference< XHierarchicalNameAccess > Databases::jarFile( const rtl::OUString& ja Reference< XHierarchicalNameAccess > Databases::findJarFileForPath ( const rtl::OUString& jar, const rtl::OUString& Language, - const rtl::OUString& path, rtl::OUString* o_pExtensionPath ) + const rtl::OUString& path, rtl::OUString* o_pExtensionPath, + rtl::OUString* o_pExtensionRegistryPath ) { Reference< XHierarchicalNameAccess > xNA; if( ! jar.getLength() || @@ -1174,7 +1175,7 @@ Reference< XHierarchicalNameAccess > Databases::findJarFileForPath JarFileIterator aJarFileIt( m_xContext, *this, jar, Language ); Reference< XHierarchicalNameAccess > xTestNA; Reference< deployment::XPackage > xParentPackageBundle; - while( (xTestNA = aJarFileIt.nextJarFile( xParentPackageBundle, o_pExtensionPath )).is() ) + while( (xTestNA = aJarFileIt.nextJarFile( xParentPackageBundle, o_pExtensionPath, o_pExtensionRegistryPath )).is() ) { if( xTestNA.is() && xTestNA->hasByHierarchicalName( path ) ) { @@ -1512,6 +1513,7 @@ void ExtensionIteratorBase::init() m_bSharedPackagesLoaded = false; m_iUserPackage = 0; m_iSharedPackage = 0; + m_iBundledPackage = 0; } Reference< deployment::XPackage > ExtensionIteratorBase::implGetHelpPackageFromPackage @@ -1635,6 +1637,36 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextSharedHelpPa return xHelpPackage; } +Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextBundledHelpPackage + ( Reference< deployment::XPackage >& o_xParentPackageBundle ) +{ + Reference< deployment::XPackage > xHelpPackage; + + if( !m_bBundledPackagesLoaded ) + { + Reference< XPackageManager > xBundledManager = + thePackageManagerFactory::get( m_xContext )->getPackageManager( rtl::OUString::createFromAscii("bundled") ); + m_aBundledPackagesSeq = xBundledManager->getDeployedPackages + ( Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); + m_bBundledPackagesLoaded = true; + } + + if( m_iBundledPackage == m_aBundledPackagesSeq.getLength() ) + { + m_eState = END_REACHED; + } + else + { + const Reference< deployment::XPackage >* pBundledPackages = + m_aBundledPackagesSeq.getConstArray(); + Reference< deployment::XPackage > xPackage = pBundledPackages[ m_iBundledPackage++ ]; + VOS_ENSURE( xPackage.is(), "ExtensionIteratorBase::implGetNextBundledHelpPackage(): Invalid package" ); + xHelpPackage = implGetHelpPackageFromPackage( xPackage, o_xParentPackageBundle ); + } + + return xHelpPackage; +} + rtl::OUString ExtensionIteratorBase::implGetFileFromPackage( const rtl::OUString& rFileExtension, Reference< deployment::XPackage > xPackage ) { @@ -1646,7 +1678,7 @@ rtl::OUString ExtensionIteratorBase::implGetFileFromPackage( for( sal_Int32 iPass = 0 ; iPass < 2 ; ++iPass ) { rtl::OUStringBuffer aStrBuf; - aStrBuf.append( xPackage->getURL() ); + aStrBuf.append( xPackage->getRegistrationDataURL().Value); aStrBuf.append( aSlash ); aStrBuf.append( aLanguage ); if( !bLangFolderOnly ) @@ -1720,7 +1752,7 @@ void ExtensionIteratorBase::implGetLanguageVectorFromPackage( ::std::vector< ::r //=================================================================== // class DataBaseIterator -Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath ) +Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ) { Db* pRetDb = NULL; @@ -1743,7 +1775,7 @@ Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath ) Reference< deployment::XPackage > xHelpPackage = implGetNextUserHelpPackage( xParentPackageBundle ); if( !xHelpPackage.is() ) break; - pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath ); + pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); break; } @@ -1754,9 +1786,21 @@ Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath ) if( !xHelpPackage.is() ) break; - pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath ); + pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); break; } + + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xParentPackageBundle; + Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( xParentPackageBundle ); + if( !xHelpPackage.is() ) + break; + + pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); + break; + } + case END_REACHED: VOS_ENSURE( false, "DataBaseIterator::nextDb(): Invalid case END_REACHED" ); break; @@ -1767,38 +1811,55 @@ Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath ) } Db* DataBaseIterator::implGetDbFromPackage( Reference< deployment::XPackage > xPackage, - rtl::OUString* o_pExtensionPath ) + rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ) { - rtl::OUString aExtensionPath = xPackage->getURL(); - //if( o_pExtensionPath ) - //*o_pExtensionPath = aExtensionPath; - aExtensionPath += aSlash; - rtl::OUString aUsedLanguage = m_aLanguage; - Db* pRetDb = m_rDatabases.getBerkeley( aHelpFilesBaseName, aUsedLanguage, - m_bHelpText, &aExtensionPath ); + beans::Optional< ::rtl::OUString> optRegData; + try + { + optRegData = xPackage->getRegistrationDataURL(); + } + catch ( deployment::ExtensionRemovedException&) + { + return NULL; + } - // Language fallback - if( !pRetDb ) + Db* pRetDb = NULL; + if (optRegData.IsPresent && optRegData.Value.getLength() > 0) { - ::std::vector< ::rtl::OUString > av; - implGetLanguageVectorFromPackage( av, xPackage ); - ::std::vector< ::rtl::OUString >::const_iterator pFound = av.end(); - try - { - pFound = ::comphelper::Locale::getFallback( av, m_aLanguage ); - } - catch( ::comphelper::Locale::MalFormedLocaleException& ) - {} - if( pFound != av.end() ) + rtl::OUString aRegDataUrl(optRegData.Value); + aRegDataUrl += aSlash; + + rtl::OUString aUsedLanguage = m_aLanguage; + pRetDb = m_rDatabases.getBerkeley( + aHelpFilesBaseName, aUsedLanguage, m_bHelpText, &aRegDataUrl); + + // Language fallback + if( !pRetDb ) { - aUsedLanguage = *pFound; - pRetDb = m_rDatabases.getBerkeley( aHelpFilesBaseName, aUsedLanguage, m_bHelpText, &aExtensionPath ); + ::std::vector< ::rtl::OUString > av; + implGetLanguageVectorFromPackage( av, xPackage ); + ::std::vector< ::rtl::OUString >::const_iterator pFound = av.end(); + try + { + pFound = ::comphelper::Locale::getFallback( av, m_aLanguage ); + } + catch( ::comphelper::Locale::MalFormedLocaleException& ) + {} + if( pFound != av.end() ) + { + aUsedLanguage = *pFound; + pRetDb = m_rDatabases.getBerkeley( + aHelpFilesBaseName, aUsedLanguage, m_bHelpText, &aRegDataUrl); + } } - } - if( o_pExtensionPath ) - *o_pExtensionPath = aExtensionPath + aUsedLanguage; + if( o_pExtensionPath ) + *o_pExtensionPath = aRegDataUrl + aUsedLanguage; + + if( o_pExtensionRegistryPath ) + *o_pExtensionRegistryPath = xPackage->getURL() + aSlash + aUsedLanguage; + } return pRetDb; } @@ -1853,6 +1914,19 @@ rtl::OUString KeyDataBaseFileIterator::nextDbFile( bool& o_rbExtension ) o_rbExtension = true; break; } + + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xParentPackageBundle; + Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( xParentPackageBundle ); + if( !xHelpPackage.is() ) + break; + + aRetFile = implGetDbFileFromPackage( xHelpPackage ); + o_rbExtension = true; + break; + } + case END_REACHED: VOS_ENSURE( false, "DataBaseIterator::nextDbFile(): Invalid case END_REACHED" ); break; @@ -1879,7 +1953,8 @@ rtl::OUString KeyDataBaseFileIterator::implGetDbFileFromPackage // class JarFileIterator Reference< XHierarchicalNameAccess > JarFileIterator::nextJarFile - ( Reference< deployment::XPackage >& o_xParentPackageBundle, rtl::OUString* o_pExtensionPath ) + ( Reference< deployment::XPackage >& o_xParentPackageBundle, + rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ) { Reference< XHierarchicalNameAccess > xNA; @@ -1902,7 +1977,7 @@ Reference< XHierarchicalNameAccess > JarFileIterator::nextJarFile if( !xHelpPackage.is() ) break; - xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath ); + xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); break; } @@ -1912,9 +1987,20 @@ Reference< XHierarchicalNameAccess > JarFileIterator::nextJarFile if( !xHelpPackage.is() ) break; - xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath ); + xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); break; } + + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( o_xParentPackageBundle ); + if( !xHelpPackage.is() ) + break; + + xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); + break; + } + case END_REACHED: VOS_ENSURE( false, "JarFileIterator::nextJarFile(): Invalid case END_REACHED" ); break; @@ -1925,7 +2011,7 @@ Reference< XHierarchicalNameAccess > JarFileIterator::nextJarFile } Reference< XHierarchicalNameAccess > JarFileIterator::implGetJarFromPackage - ( Reference< deployment::XPackage > xPackage, rtl::OUString* o_pExtensionPath ) +( Reference< deployment::XPackage > xPackage, rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ) { Reference< XHierarchicalNameAccess > xNA; @@ -1970,6 +2056,15 @@ Reference< XHierarchicalNameAccess > JarFileIterator::implGetJarFromPackage sal_Int32 nLastSlash = zipFile.lastIndexOf( '/' ); if( nLastSlash != -1 ) *o_pExtensionPath = zipFile.copy( 0, nLastSlash ); + + if( o_pExtensionRegistryPath != NULL ) + { + rtl::OUString& rPath = *o_pExtensionPath; + sal_Int32 nLastSlashInPath = rPath.lastIndexOf( '/', rPath.getLength() - 1 ); + + *o_pExtensionRegistryPath = xPackage->getURL(); + *o_pExtensionRegistryPath += rPath.copy( nLastSlashInPath); + } } return xNA; @@ -2026,6 +2121,19 @@ rtl::OUString IndexFolderIterator::nextIndexFolder( bool& o_rbExtension, bool& o o_rbExtension = true; break; } + + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xParentPackageBundle; + Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( xParentPackageBundle ); + if( !xHelpPackage.is() ) + break; + + aIndexFolder = implGetIndexFolderFromPackage( o_rbTemporary, xHelpPackage ); + o_rbExtension = true; + break; + } + case END_REACHED: VOS_ENSURE( false, "IndexFolderIterator::nextIndexFolder(): Invalid case END_REACHED" ); break; diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx index 6468c5732c6b..aa80bf27405b 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.hxx +++ b/xmlhelp/source/cxxhelp/provider/databases.hxx @@ -267,7 +267,8 @@ namespace chelp { com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess > findJarFileForPath( const rtl::OUString& jar, const rtl::OUString& Language, - const rtl::OUString& path, rtl::OUString* o_pExtensionPath = NULL ); + const rtl::OUString& path, rtl::OUString* o_pExtensionPath = NULL, + rtl::OUString* o_pExtensionRegistryPath = NULL ); /** * Maps a given language-locale combination to language. @@ -398,6 +399,7 @@ namespace chelp { //SHARED_MODULE, // Later, avoids redundancies in help compiling USER_EXTENSIONS, SHARED_EXTENSIONS, + BUNDLED_EXTENSIONS, END_REACHED }; @@ -433,6 +435,8 @@ namespace chelp { ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle ); com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextSharedHelpPackage ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle ); + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledHelpPackage + ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle ); rtl::OUString implGetFileFromPackage( const rtl::OUString& rFileExtension, com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage ); void implGetLanguageVectorFromPackage( ::std::vector< ::rtl::OUString > &rv, @@ -456,8 +460,13 @@ namespace chelp { < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; bool m_bSharedPackagesLoaded; + com::sun::star::uno::Sequence< com::sun::star::uno::Reference + < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; + bool m_bBundledPackagesLoaded; + int m_iUserPackage; int m_iSharedPackage; + int m_iBundledPackage; }; // end class ExtensionIteratorBase @@ -477,13 +486,13 @@ namespace chelp { , m_bHelpText( bHelpText ) {} - berkeleydbproxy::Db* nextDb( rtl::OUString* o_pExtensionPath = NULL ); + berkeleydbproxy::Db* nextDb( rtl::OUString* o_pExtensionPath = NULL, rtl::OUString* o_pExtensionRegistryPath = NULL ); private: berkeleydbproxy::Db* implGetDbFromPackage( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage, - rtl::OUString* o_pExtensionPath ); + rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ); bool m_bHelpText; @@ -517,12 +526,12 @@ namespace chelp { com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess > nextJarFile( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle, - rtl::OUString* o_pExtensionPath = NULL ); + rtl::OUString* o_pExtensionPath = NULL, rtl::OUString* o_pExtensionRegistryPath = NULL ); private: com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess > implGetJarFromPackage(com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage, - rtl::OUString* o_pExtensionPath = NULL ); + rtl::OUString* o_pExtensionPath = NULL, rtl::OUString* o_pExtensionRegistryPath = NULL ); }; // end class JarFileIterator diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx index 9268ec19cd7f..67735c4e0a6a 100644 --- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx +++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx @@ -306,9 +306,10 @@ void URLParameter::readBerkeley() Dbt data; DBData aDBData; rtl::OUString aExtensionPath; + rtl::OUString aExtensionRegistryPath; while( true ) { - Db* db = aDbIt.nextDb( &aExtensionPath ); + Db* db = aDbIt.nextDb( &aExtensionPath, &aExtensionRegistryPath ); if( !db ) break; @@ -355,6 +356,7 @@ void URLParameter::readBerkeley() aExtendedJarStrBuf.append( aQuestionMark ); aExtendedJarStrBuf.append( m_aJar ); m_aJar = aExtendedJarStrBuf.makeStringAndClear(); + m_aExtensionRegistryPath = aExtensionRegistryPath; } m_aTag = converter.getHash(); } @@ -1004,18 +1006,20 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, rtl::OUString aJar = urlParam->get_jar(); bool bAddExtensionPath = false; + rtl::OUString aExtensionRegistryPath; sal_Int32 nQuestionMark1 = aJar.indexOf( sal_Unicode('?') ); sal_Int32 nQuestionMark2 = aJar.lastIndexOf( sal_Unicode('?') ); if( nQuestionMark1 != -1 && nQuestionMark2 != -1 && nQuestionMark1 != nQuestionMark2 ) { aExtensionPath = aJar.copy( nQuestionMark1 + 1, nQuestionMark2 - nQuestionMark1 - 1 ); + aExtensionRegistryPath = urlParam->get_ExtensionRegistryPath(); bAddExtensionPath = true; } else { // Path not yet specified, search directly Reference< XHierarchicalNameAccess > xNA = pDatabases->findJarFileForPath - ( aJar, urlParam->get_language(), urlParam->get_path(), &aExtensionPath ); + ( aJar, urlParam->get_language(), urlParam->get_path(), &aExtensionPath, &aExtensionRegistryPath ); if( xNA.is() && aExtensionPath.getLength() ) bAddExtensionPath = true; } @@ -1038,7 +1042,7 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, Reference< XInterface >() ); } - rtl::OUString aOUExpandedExtensionPath = Databases::expandURL( aExtensionPath, xContext ); + rtl::OUString aOUExpandedExtensionPath = Databases::expandURL( aExtensionRegistryPath, xContext ); rtl::OString aExpandedExtensionPath = rtl::OUStringToOString( aOUExpandedExtensionPath, osl_getThreadTextEncoding() ); parString[last++] = "ExtensionPath"; diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.hxx b/xmlhelp/source/cxxhelp/provider/urlparameter.hxx index d1dbf48132a7..5f73c930dcdb 100644 --- a/xmlhelp/source/cxxhelp/provider/urlparameter.hxx +++ b/xmlhelp/source/cxxhelp/provider/urlparameter.hxx @@ -150,6 +150,8 @@ namespace chelp { rtl::OUString get_jar() { return get_the_jar(); } // BerkeleyDb + rtl::OUString get_ExtensionRegistryPath() { return m_aExtensionRegistryPath; } + rtl::OUString get_module() { return m_aModule; } rtl::OUString get_dbpar() { @@ -203,6 +205,7 @@ namespace chelp { rtl::OUString m_aModule; rtl::OUString m_aTitle; rtl::OUString m_aJar; + rtl::OUString m_aExtensionRegistryPath; rtl::OUString m_aEid; rtl::OUString m_aDbPar; -- cgit From 3c289e248a4f7c6940bb7429ee70d17a6196016c Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 19 Apr 2010 11:33:33 +0200 Subject: jl152 import 263446 from native0jl:#i77196# supporting licenses, suppress license switch, subsequent accepting of licenses for bundled/shared extensions --- desktop/inc/deployment.hrc | 1 - desktop/source/app/check_ext_deps.cxx | 135 +------ desktop/source/app/makefile.mk | 14 + desktop/source/deployment/gui/dp_gui.hrc | 1 - desktop/source/deployment/gui/dp_gui_dialog.src | 10 +- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 23 +- .../deployment/gui/dp_gui_updateinstalldialog.cxx | 4 +- desktop/source/deployment/gui/license_dialog.cxx | 11 +- desktop/source/deployment/gui/license_dialog.hxx | 1 + desktop/source/deployment/inc/dp_misc.h | 7 +- desktop/source/deployment/inc/dp_ucb.h | 7 + .../deployment/manager/dp_activepackages.cxx | 8 +- .../deployment/manager/dp_activepackages.hxx | 9 + .../deployment/manager/dp_commandenvironments.cxx | 255 ++++++++++++ .../deployment/manager/dp_commandenvironments.hxx | 146 +++++++ .../deployment/manager/dp_extensionmanager.cxx | 333 ++++++++-------- .../deployment/manager/dp_extensionmanager.hxx | 37 +- desktop/source/deployment/manager/dp_manager.cxx | 439 ++++++++++++--------- desktop/source/deployment/manager/dp_manager.h | 28 +- .../source/deployment/manager/dp_properties.cxx | 147 +++++++ .../source/deployment/manager/dp_properties.hxx | 76 ++++ .../source/deployment/manager/dp_tmprepocmdenv.cxx | 166 -------- .../source/deployment/manager/dp_tmprepocmdenv.hxx | 84 ---- desktop/source/deployment/manager/makefile.mk | 3 +- .../source/deployment/migration/dp_migration.cxx | 2 +- desktop/source/deployment/misc/dp_misc.cxx | 142 ++++++- desktop/source/deployment/misc/dp_ucb.cxx | 46 +++ .../deployment/registry/component/dp_component.cxx | 11 +- .../registry/configuration/dp_configuration.cxx | 3 +- desktop/source/deployment/registry/dp_backend.cxx | 20 +- desktop/source/deployment/registry/dp_registry.cxx | 8 +- .../registry/executable/dp_executable.cxx | 3 +- .../source/deployment/registry/help/dp_help.cxx | 112 +----- .../source/deployment/registry/inc/dp_backend.h | 4 +- .../deployment/registry/package/dp_package.cxx | 69 ++-- .../deployment/registry/script/dp_script.cxx | 6 +- desktop/source/deployment/unopkg/unopkg.src | 7 +- .../migration/services/oo3extensionmigration.cxx | 4 +- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 161 ++++++-- desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx | 55 +-- desktop/source/pkgchk/unopkg/unopkg_misc.cxx | 42 +- desktop/source/pkgchk/unopkg/unopkg_shared.h | 10 +- 42 files changed, 1612 insertions(+), 1038 deletions(-) create mode 100644 desktop/source/deployment/manager/dp_commandenvironments.cxx create mode 100644 desktop/source/deployment/manager/dp_commandenvironments.hxx create mode 100644 desktop/source/deployment/manager/dp_properties.cxx create mode 100644 desktop/source/deployment/manager/dp_properties.hxx delete mode 100644 desktop/source/deployment/manager/dp_tmprepocmdenv.cxx delete mode 100644 desktop/source/deployment/manager/dp_tmprepocmdenv.hxx diff --git a/desktop/inc/deployment.hrc b/desktop/inc/deployment.hrc index 7e4c21d3c5a4..370996c710ae 100644 --- a/desktop/inc/deployment.hrc +++ b/desktop/inc/deployment.hrc @@ -63,7 +63,6 @@ #define RID_IMG_JAVA_TYPELIB_HC (RID_DEPLOYMENT_COMPONENT_START+7) #define RID_DEPLOYMENT_UNOPKG_START (RID_DEPLOYMENT_START+4000) -#define RID_STR_UNOPKG_NO_SHARED_ALLOWED RID_DEPLOYMENT_UNOPKG_START #define RID_STR_UNOPKG_ACCEPT_LIC_1 (RID_DEPLOYMENT_UNOPKG_START+1) #define RID_STR_UNOPKG_ACCEPT_LIC_2 (RID_DEPLOYMENT_UNOPKG_START+2) #define RID_STR_UNOPKG_ACCEPT_LIC_3 (RID_DEPLOYMENT_UNOPKG_START+3) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 17dc20e1a129..f487e0dfc96f 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -53,6 +53,8 @@ #include "app.hxx" +#include "../deployment/inc/dp_misc.h" + using rtl::OUString; using namespace desktop; using namespace com::sun::star; @@ -342,101 +344,6 @@ sal_Bool Desktop::CheckExtensionDependencies() return bAbort; } -//Returns true if the Folder was more recently modified then -//the lastsynchronized file. That is the repository needs to -//be synchronized. -static bool compareExtensionFolderWithLastSynchronizedFile( - OUString const & folderURL, OUString const & fileURL) -{ - bool bNeedsSync = false; - ::osl::DirectoryItem itemExtFolder; - ::osl::File::RC err1 = - ::osl::DirectoryItem::get(folderURL, itemExtFolder); - //If it does not exist, then there is nothing to be done - if (err1 == ::osl::File::E_NOENT) - { - return false; - } - else if (err1 != ::osl::File::E_None) - { - OSL_ENSURE(0, "Cannot access extension folder"); - return true; //sync just in case - } - - //If last synchronized does not exist, then OOo is started for the first time - ::osl::DirectoryItem itemFile; - ::osl::File::RC err2 = ::osl::DirectoryItem::get(fileURL, itemFile); - if (err2 == ::osl::File::E_NOENT) - { - return true; - - } - else if (err2 != ::osl::File::E_None) - { - OSL_ENSURE(0, "Cannot access file lastsynchronized"); - return true; //sync just in case - } - - //compare the modification time of the extension folder and the last - //modified file - ::osl::FileStatus statFolder(FileStatusMask_ModifyTime); - ::osl::FileStatus statFile(FileStatusMask_ModifyTime); - if (itemExtFolder.getFileStatus(statFolder) == ::osl::File::E_None) - { - if (itemFile.getFileStatus(statFile) == ::osl::File::E_None) - { - TimeValue timeFolder = statFolder.getModifyTime(); - TimeValue timeFile = statFile.getModifyTime(); - - if (timeFile.Seconds < timeFolder.Seconds) - bNeedsSync = true; - } - else - { - OSL_ASSERT(0); - bNeedsSync = true; - } - } - else - { - OSL_ASSERT(0); - bNeedsSync = true; - } - return bNeedsSync; -} - -static bool needToSyncRepostitory(OUString const & name) -{ - OUString folder; - OUString file; - if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")))) - { - folder = OUString( - RTL_CONSTASCII_USTRINGPARAM("$BUNDLED_EXTENSIONS")); - file = OUString ( - RTL_CONSTASCII_USTRINGPARAM( - "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); - } - else if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("shared")))) - { - folder = OUString( - RTL_CONSTASCII_USTRINGPARAM( - "$UNO_SHARED_PACKAGES_CACHE/uno_packages")); - file = OUString ( - RTL_CONSTASCII_USTRINGPARAM( - "$SHARED_EXTENSIONS_USER/lastsynchronized")); - } - else - { - OSL_ASSERT(0); - return true; - } - ::rtl::Bootstrap::expandMacros(folder); - ::rtl::Bootstrap::expandMacros(file); - return compareExtensionFolderWithLastSynchronizedFile( - folder, file); -} - void Desktop::SynchronizeExtensionRepositories() { RTL_LOGFILE_CONTEXT(aLog,"desktop (jl97489) ::Desktop::SynchronizeExtensionRepositories"); @@ -447,41 +354,5 @@ void Desktop::SynchronizeExtensionRepositories() OUString(RTL_CONSTASCII_USTRINGPARAM(""))); if (sDisable.getLength() > 0) return; - Reference xExtensionManager; - //synchronize shared before bundled otherewise there are - //more revoke and registration calls. - OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); - if (needToSyncRepostitory(sShared)) - { - xExtensionManager = - deployment::ExtensionManager::get( - comphelper_getProcessComponentContext()); - if (xExtensionManager.is()) - { - Reference cmdEnv( - new SilentCommandEnv()); - xExtensionManager->synchronize( - sShared, Reference(), cmdEnv); - } - - } - - OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); - if (needToSyncRepostitory( sBundled)) - { - if (!xExtensionManager.is()) - { - xExtensionManager = - deployment::ExtensionManager::get( - comphelper_getProcessComponentContext()); - } - if (xExtensionManager.is()) - { - Reference cmdEnv( - new SilentCommandEnv()); - xExtensionManager->synchronize( - sBundled, Reference(), cmdEnv); - - } - } + dp_misc::syncRepositories(new SilentCommandEnv()); } diff --git a/desktop/source/app/makefile.mk b/desktop/source/app/makefile.mk index d9db7c163481..085d8520e7ad 100644 --- a/desktop/source/app/makefile.mk +++ b/desktop/source/app/makefile.mk @@ -35,11 +35,24 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.INCLUDE : ../deployment/inc/dp_misc.mk .IF "$(ENABLE_GNOMEVFS)"=="TRUE" CFLAGS+=-DGNOME_VFS_ENABLED .ENDIF +# .IF "$(OS)" == "WNT" +# .IF "$(COM)" == "GCC" +# DEPLOYMENTMISCLIB = -ldeploymentmisc$(DLLPOSTFIX) +# .ELSE +# DEPLOYMENTMISCLIB = ideploymentmisc$(DLLPOSTFIX).lib +# .ENDIF +# .ELIF "$(OS)" == "OS2" +# DEPLOYMENTMISCLIB = ideploymentmisc$(DLLPOSTFIX).lib +# .ELSE +# DEPLOYMENTMISCLIB = -ldeploymentmisc$(DLLPOSTFIX) +# .ENDIF + SHL1TARGET = sofficeapp SHL1OBJS = \ $(SLO)$/app.obj \ @@ -67,6 +80,7 @@ SHL1STDLIBS = \ $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ + $(DEPLOYMENTMISCLIB) \ $(I18NISOLANGLIB) \ $(SALLIB) \ $(SFXLIB) \ diff --git a/desktop/source/deployment/gui/dp_gui.hrc b/desktop/source/deployment/gui/dp_gui.hrc index 1d2f4869cc7f..022141976f55 100644 --- a/desktop/source/deployment/gui/dp_gui.hrc +++ b/desktop/source/deployment/gui/dp_gui.hrc @@ -172,7 +172,6 @@ #define RID_WARNINGBOX_DISABLE_SHARED_EXTENSION (RID_DEPLOYMENT_GUI_START+106) #define RID_DLG_LICENSE RID_DEPLOYMENT_LICENSE_START -#define WARNINGBOX_NOSHAREDALLOWED (RID_DEPLOYMENT_LICENSE_START+1) diff --git a/desktop/source/deployment/gui/dp_gui_dialog.src b/desktop/source/deployment/gui/dp_gui_dialog.src index 79c0c5172030..f9d9c0e011c6 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog.src +++ b/desktop/source/deployment/gui/dp_gui_dialog.src @@ -131,7 +131,7 @@ String RID_STR_ERROR_MISSING_DEPENDENCIES #define ROW1_Y RSC_SP_DLG_INNERBORDER_TOP #define ROW1_HEIGHT 16*RSC_CD_FIXEDTEXT_HEIGHT #define ROW2_Y ROW1_Y+ROW1_HEIGHT+RSC_SP_CTRL_GROUP_Y -#define ROW2_HEIGHT 2*RSC_CD_FIXEDTEXT_HEIGHT +#define ROW2_HEIGHT 3*RSC_CD_FIXEDTEXT_HEIGHT #define ROW3_Y ROW2_Y+ROW2_HEIGHT+RSC_SP_CTRL_GROUP_Y #define ROW3_HEIGHT 3*RSC_CD_FIXEDTEXT_HEIGHT #define ROW4_Y ROW3_Y+ROW3_HEIGHT+RSC_SP_CTRL_GROUP_Y @@ -282,14 +282,6 @@ ModalDialog RID_DLG_LICENSE -WarningBox WARNINGBOX_NOSHAREDALLOWED -{ - Buttons = WB_OK ; - DefButton = WB_DEF_OK; - Message[ en-US ] ="The extension \'%NAME\' cannot be installed under \"%PRODUCTNAME Extensions\", because " - "every user has to agree to the license agreement of the extension. The extension will not be installed."; -}; - WarningBox RID_WARNINGBOX_INSTALL_EXTENSION { Buttons = WB_OK_CANCEL; DefButton = WB_DEF_OK; diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index a617e07758c7..4b55a93d3f84 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -36,10 +36,10 @@ #include #include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/beans/NamedValue.hpp" #include "com/sun/star/deployment/DependencyException.hpp" #include "com/sun/star/deployment/LicenseException.hpp" -#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" #include "com/sun/star/deployment/VersionException.hpp" #include "com/sun/star/deployment/InstallException.hpp" #include "com/sun/star/deployment/PlatformException.hpp" @@ -379,7 +379,6 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & lang::WrappedTargetException wtExc; deployment::DependencyException depExc; deployment::LicenseException licExc; - deployment::LicenseIndividualAgreementException licAgreementExc; deployment::VersionException verExc; deployment::InstallException instExc; deployment::PlatformException platExc; @@ -441,23 +440,12 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & || (n == RET_CANCEL && !Application::IsDialogCancelEnabled()); } } - else if (request >>= licAgreementExc) - { - vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - ResId warnId(WARNINGBOX_NOSHAREDALLOWED, *DeploymentGuiResMgr::get()); - WarningBox warn( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL, warnId); - String msgText = warn.GetMessText(); - msgText.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() ); - msgText.SearchAndReplaceAllAscii("%NAME", licAgreementExc.ExtensionName); - warn.SetMessText(msgText); - warn.Execute(); - abort = true; - } else if (request >>= licExc) { uno::Reference< ui::dialogs::XExecutableDialog > xDialog( deployment::ui::LicenseDialog::create( - m_xContext, VCLUnoHelper::GetInterface( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL ), licExc.Text ) ); + m_xContext, VCLUnoHelper::GetInterface( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL ), + licExc.ExtensionName, licExc.Text ) ); sal_Int16 res = xDialog->execute(); if ( res == ui::dialogs::ExecutableDialogResults::CANCEL ) abort = true; @@ -948,8 +936,9 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv { OUString sPackageManager = xPackageManager->getContext(); uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); - uno::Reference< deployment::XPackage > xPackage( xExtMgr->addExtension( rPackageURL, sPackageManager, - xAbortChannel, rCmdEnv.get() ) ); + uno::Reference< deployment::XPackage > xPackage( + xExtMgr->addExtension(rPackageURL, uno::Sequence(), + sPackageManager, xAbortChannel, rCmdEnv.get() ) ); OSL_ASSERT( xPackage.is() ); } catch ( ucb::CommandFailedException & ) diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index 113e6d2069ac..f607713118f0 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -46,6 +46,7 @@ #include "cppuhelper/implbase3.hxx" #include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/beans/NamedValue.hpp" #include "com/sun/star/xml/dom/XElement.hpp" #include "com/sun/star/xml/dom/XNode.hpp" #include "com/sun/star/xml/dom/XNodeList.hpp" @@ -504,7 +505,8 @@ void UpdateInstallDialog::Thread::installExtensions() m_abort = xAbortChannel; } xPackage = curData.aPackageManager->addPackage( - curData.sLocalURL, OUString(), xAbortChannel, m_updateCmdEnv.get()); + curData.sLocalURL, css::uno::Sequence(), + OUString(), xAbortChannel, m_updateCmdEnv.get()); } catch (css::deployment::DeploymentException & de) { diff --git a/desktop/source/deployment/gui/license_dialog.cxx b/desktop/source/deployment/gui/license_dialog.cxx index 50992eb07a97..9698e257b953 100644 --- a/desktop/source/deployment/gui/license_dialog.cxx +++ b/desktop/source/deployment/gui/license_dialog.cxx @@ -116,6 +116,7 @@ struct LicenseDialogImpl : public ModalDialog LicenseDialogImpl( Window * pParent, css::uno::Reference< css::uno::XComponentContext > const & xContext, + const ::rtl::OUString & sExtensionName, const ::rtl::OUString & sLicenseText); virtual void Activate(); @@ -193,6 +194,7 @@ void LicenseView::Notify( SfxBroadcaster&, const SfxHint& rHint ) LicenseDialogImpl::LicenseDialogImpl( Window * pParent, cssu::Reference< cssu::XComponentContext > const & xContext, + const ::rtl::OUString & sExtensionName, const ::rtl::OUString & sLicenseText): ModalDialog(pParent, DpGuiResId(RID_DLG_LICENSE)) ,m_xComponentContext(xContext) @@ -225,6 +227,7 @@ LicenseDialogImpl::LicenseDialogImpl( m_fiArrow1.Show(true); m_fiArrow2.Show(false); m_mlLicense.SetText(sLicenseText); + m_ftHead.SetText(m_ftHead.GetText() + OUString('\n') + sExtensionName); m_mlLicense.SetEndReachedHdl( LINK(this, LicenseDialogImpl, EndReachedHdl) ); m_mlLicense.SetScrolledHdl( LINK(this, LicenseDialogImpl, ScrolledHdl) ); @@ -296,7 +299,7 @@ LicenseDialog::LicenseDialog( Sequence const& args, Reference const& xComponentContext) : m_xComponentContext(xComponentContext) { - comphelper::unwrapArgs( args, m_parent, m_sLicenseText ); + comphelper::unwrapArgs( args, m_parent, m_sExtensionName, m_sLicenseText ); } // XExecutableDialog @@ -315,8 +318,10 @@ sal_Int16 LicenseDialog::execute() throw (RuntimeException) sal_Int16 LicenseDialog::solar_execute() { - std::auto_ptr dlg(new LicenseDialogImpl( - VCLUnoHelper::GetWindow(m_parent), m_xComponentContext, m_sLicenseText)); + std::auto_ptr dlg( + new LicenseDialogImpl( + VCLUnoHelper::GetWindow(m_parent), + m_xComponentContext, m_sExtensionName, m_sLicenseText)); return dlg->Execute(); } diff --git a/desktop/source/deployment/gui/license_dialog.hxx b/desktop/source/deployment/gui/license_dialog.hxx index 4733922dc607..bb4a6b6646c8 100644 --- a/desktop/source/deployment/gui/license_dialog.hxx +++ b/desktop/source/deployment/gui/license_dialog.hxx @@ -48,6 +48,7 @@ class LicenseDialog { Reference const m_xComponentContext; Reference /* const */ m_parent; + OUString m_sExtensionName; OUString /* const */ m_sLicenseText; OUString m_initialTitle; diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index ee5867a655d3..3283d20718be 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -36,6 +36,7 @@ #include "com/sun/star/lang/XComponent.hpp" #include "com/sun/star/lang/DisposedException.hpp" #include "com/sun/star/deployment/XPackageRegistry.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" #include "com/sun/star/awt/XWindow.hpp" #include "dp_misc_api.hxx" @@ -168,8 +169,12 @@ void TRACE(::rtl::OUString const & sText); DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void TRACE(::rtl::OString const & sText); +/** registers or revokes shared or bundled extensions which have been + recently added or removed. +*/ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -bool hasExtensionRepositoryChanged(::rtl::OUString const & repository); +void syncRepositories(::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv); } diff --git a/desktop/source/deployment/inc/dp_ucb.h b/desktop/source/deployment/inc/dp_ucb.h index 6f9127504860..03144388e8a8 100644 --- a/desktop/source/deployment/inc/dp_ucb.h +++ b/desktop/source/deployment/inc/dp_ucb.h @@ -28,6 +28,7 @@ #if ! defined INCLUDED_DP_UCB_H #define INCLUDED_DP_UCB_H +#include #include "rtl/byteseq.hxx" #include "rtl/instance.hxx" #include "com/sun/star/ucb/XCommandEnvironment.hpp" @@ -79,6 +80,12 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool readLine( ::rtl::OUString * res, ::rtl::OUString const & startingWith, ::ucbhelper::Content & ucb_content, rtl_TextEncoding textenc ); +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +bool readProperties( ::std::list< ::std::pair< ::rtl::OUString, ::rtl::OUString> > & out_result, + ::ucbhelper::Content & ucb_content); + + + } #endif diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx index bf9071682b2e..8f6b6b82c0b7 100644 --- a/desktop/source/deployment/manager/dp_activepackages.cxx +++ b/desktop/source/deployment/manager/dp_activepackages.cxx @@ -107,10 +107,14 @@ static char const legacyPrefix[] = "org.openoffice.legacy."; } else { + sal_Int32 i4 = value.indexOf(separator, i3 + 1); d.mediaType = ::rtl::OUString( value.getStr() + i2 + 1, i3 - i2 -1, RTL_TEXTENCODING_UTF8); d.version = ::rtl::OUString( - value.getStr() + i3 + 1, value.getLength() - i3 - 1, + value.getStr() + i3 + 1, i4 - i3 - 1, + RTL_TEXTENCODING_UTF8); + d.failedPrerequisites = ::rtl::OUString( + value.getStr() + i4 + 1, value.getLength() - i4 - 1, RTL_TEXTENCODING_UTF8); } return d; @@ -188,6 +192,8 @@ void ActivePackages::put(::rtl::OUString const & id, Data const & data) { b.append(::rtl::OUStringToOString(data.mediaType, RTL_TEXTENCODING_UTF8)); b.append(separator); b.append(::rtl::OUStringToOString(data.version, RTL_TEXTENCODING_UTF8)); + b.append(separator); + b.append(::rtl::OUStringToOString(data.failedPrerequisites, RTL_TEXTENCODING_UTF8)); m_map.put(newKey(id), b.makeStringAndClear()); } diff --git a/desktop/source/deployment/manager/dp_activepackages.hxx b/desktop/source/deployment/manager/dp_activepackages.hxx index 36060d26bd02..7d9c7e32cfb4 100644 --- a/desktop/source/deployment/manager/dp_activepackages.hxx +++ b/desktop/source/deployment/manager/dp_activepackages.hxx @@ -42,6 +42,8 @@ namespace dp_manager { class ActivePackages { public: struct Data { + Data(): failedPrerequisites(::rtl::OUString::valueOf((sal_Int32)0)) + {} /* name of the temporary file (shared, user extension) or the name of the folder of the bundled extension. It does not contain the trailing '_' of the folder. @@ -55,6 +57,13 @@ public: ::rtl::OUString fileName; ::rtl::OUString mediaType; ::rtl::OUString version; + /* If this string contains the value according to + com::sun::star::deployment::Prerequisites or "0". That is, if + the value is > 0 then + the call to XPackage::checkPrerequisites failed. + In this case the extension must not be registered. + */ + ::rtl::OUString failedPrerequisites; }; typedef ::std::vector< ::std::pair< ::rtl::OUString, Data > > Entries; diff --git a/desktop/source/deployment/manager/dp_commandenvironments.cxx b/desktop/source/deployment/manager/dp_commandenvironments.cxx new file mode 100644 index 000000000000..814dc818b2a6 --- /dev/null +++ b/desktop/source/deployment/manager/dp_commandenvironments.cxx @@ -0,0 +1,255 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "com/sun/star/deployment/VersionException.hpp" +#include "com/sun/star/deployment/LicenseException.hpp" +#include "com/sun/star/deployment/InstallException.hpp" +#include "com/sun/star/task/XInteractionApprove.hpp" +#include "com/sun/star/task/XInteractionAbort.hpp" +#include "com/sun/star/task/XInteractionHandler.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "dp_commandenvironments.hxx" + +namespace deployment = com::sun::star::deployment; +namespace lang = com::sun::star::lang; +namespace task = com::sun::star::task; +namespace ucb = com::sun::star::ucb; +namespace uno = com::sun::star::uno; +namespace css = com::sun::star; + +#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) + +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +namespace dp_manager { + +BaseCommandEnv::BaseCommandEnv() +{ +} + +BaseCommandEnv::BaseCommandEnv( + Reference< task::XInteractionHandler> const & handler) + : m_forwardHandler(handler) +{ +} + +BaseCommandEnv::~BaseCommandEnv() +{ +} +// XCommandEnvironment +//______________________________________________________________________________ +Reference BaseCommandEnv::getInteractionHandler() +throw (uno::RuntimeException) +{ + return this; +} + +//______________________________________________________________________________ +Reference BaseCommandEnv::getProgressHandler() +throw (uno::RuntimeException) +{ + return this; +} + +void BaseCommandEnv::handle( + Reference< task::XInteractionRequest> const & /*xRequest*/ ) + throw (uno::RuntimeException) +{ +} + +void BaseCommandEnv::handle_(bool approve, bool abort, + Reference< task::XInteractionRequest> const & xRequest ) +{ + if (approve == false && abort == false) + { + //not handled so far -> forwarding + if (m_forwardHandler.is()) + m_forwardHandler->handle(xRequest); + else + return; //cannot handle + } + else + { + // select: + uno::Sequence< Reference< task::XInteractionContinuation > > conts( + xRequest->getContinuations() ); + Reference< task::XInteractionContinuation > const * pConts = + conts.getConstArray(); + sal_Int32 len = conts.getLength(); + for ( sal_Int32 pos = 0; pos < len; ++pos ) + { + if (approve) { + Reference< task::XInteractionApprove > xInteractionApprove( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionApprove.is()) { + xInteractionApprove->select(); + // don't query again for ongoing continuations: + approve = false; + } + } + else if (abort) { + Reference< task::XInteractionAbort > xInteractionAbort( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionAbort.is()) { + xInteractionAbort->select(); + // don't query again for ongoing continuations: + abort = false; + } + } + } + } + +} + +// XProgressHandler +void BaseCommandEnv::push( uno::Any const & /*Status*/ ) +throw (uno::RuntimeException) +{ +} + + +void BaseCommandEnv::update( uno::Any const & /*Status */) +throw (uno::RuntimeException) +{ +} + +void BaseCommandEnv::pop() throw (uno::RuntimeException) +{ +} +//============================================================================== + +TmpRepositoryCommandEnv::TmpRepositoryCommandEnv() +{ +} + +TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler): + BaseCommandEnv(handler) +{ +} +// XInteractionHandler +void TmpRepositoryCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + deployment::VersionException verExc; + deployment::LicenseException licExc; + deployment::InstallException instExc; + + bool approve = false; + bool abort = false; + + if ((request >>= verExc) + || (request >>= licExc) + || (request >>= instExc)) + { + approve = true; + } + + handle_(approve, abort, xRequest); +} +//================================================================================ + +LicenseCommandEnv::LicenseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler, + bool bSuppressLicense, + OUString const & repository): + BaseCommandEnv(handler), m_repository(repository), + m_bSuppressLicense(bSuppressLicense) +{ +} +// XInteractionHandler +void LicenseCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + + deployment::LicenseException licExc; + + bool approve = false; + bool abort = false; + + if (request >>= licExc) + { + if (m_bSuppressLicense + || m_repository.equals(OUSTR("bundled")) + || licExc.AcceptBy.equals(OUSTR("admin"))) + { + //always approve in bundled case, because we do not support + //showing licenses anyway. + //The "admin" already accepted the license when installing the + // shared extension + approve = true; + } + } + + handle_(approve, abort, xRequest); +} + +//================================================================================ +//================================================================================ + +NoLicenseCommandEnv::NoLicenseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler): + BaseCommandEnv(handler) +{ +} +// XInteractionHandler +void NoLicenseCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + + deployment::LicenseException licExc; + + bool approve = false; + bool abort = false; + + if (request >>= licExc) + { + approve = true; + } + handle_(approve, abort, xRequest); +} + +} // namespace dp_manager + + diff --git a/desktop/source/deployment/manager/dp_commandenvironments.hxx b/desktop/source/deployment/manager/dp_commandenvironments.hxx new file mode 100644 index 000000000000..ad47fd2af549 --- /dev/null +++ b/desktop/source/deployment/manager/dp_commandenvironments.hxx @@ -0,0 +1,146 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_COMMANDENVIRONMENTS_HXX +#define INCLUDED_DP_COMMANDENVIRONMENTS_HXX + + +#include "cppuhelper/compbase3.hxx" +//#include "cppuhelper/implbase2.hxx" +#include "ucbhelper/content.hxx" + + + +namespace css = ::com::sun::star; + +namespace dp_manager { + + + +/** + This command environment is to be used when an extension is temporarily + stored in the "tmp" repository. It prevents all kind of user interaction. + */ +class BaseCommandEnv + : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment, + css::task::XInteractionHandler, + css::ucb::XProgressHandler > +{ +protected: + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler; + + void handle_(bool approve, bool abort, + css::uno::Reference< css::task::XInteractionRequest> const & xRequest ); +public: + virtual ~BaseCommandEnv(); + BaseCommandEnv(); + BaseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler); + + // XCommandEnvironment + virtual css::uno::Reference SAL_CALL + getInteractionHandler() throw (css::uno::RuntimeException); + virtual css::uno::Reference + SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + + // XProgressHandler + virtual void SAL_CALL push( css::uno::Any const & Status ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL update( css::uno::Any const & Status ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL pop() throw (css::uno::RuntimeException); +}; + +class TmpRepositoryCommandEnv : public BaseCommandEnv +{ +public: + TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(); + TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler); + +// XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + +}; + +/** this class is for use in XPackageManager::synchronize. + + It handles particular license cases. + */ +class LicenseCommandEnv : public BaseCommandEnv +{ +private: + ::rtl::OUString m_repository; + bool m_bSuppressLicense; +public: + LicenseCommandEnv::LicenseCommandEnv(){}; + LicenseCommandEnv::LicenseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler, + bool bSuppressLicense, + ::rtl::OUString const & repository); + +// XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + +}; + +/** this class is for use in XPackageManager::checkPrerequisites + + It always prohibits a license interaction + */ +class NoLicenseCommandEnv : public BaseCommandEnv +{ + +public: + NoLicenseCommandEnv::NoLicenseCommandEnv(){}; + NoLicenseCommandEnv::NoLicenseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler); + +// XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + +}; + +} + + + + +#endif + diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 6e76cfb574bd..15bd9a581611 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -56,9 +56,10 @@ #include "dp_resource.h" #include "dp_ucb.h" #include "dp_identifier.hxx" - +#include "dp_descriptioninfoset.hxx" #include "dp_extensionmanager.hxx" -#include "dp_tmprepocmdenv.hxx" +#include "dp_commandenvironments.hxx" +#include "dp_properties.hxx" #include #include #include @@ -146,6 +147,25 @@ Reference ExtensionManager::createAbortChannel() return new dp_misc::AbortChannel; } +css::uno::Reference +ExtensionManager::getPackageManager(::rtl::OUString const & repository) + throw (css::lang::IllegalArgumentException) +{ + Reference xPackageManager; + if (repository.equals(OUSTR("user"))) + xPackageManager = m_userRepository; + else if (repository.equals(OUSTR("shared"))) + xPackageManager = m_sharedRepository; + else if (repository.equals(OUSTR("bundled"))) + xPackageManager = m_bundledRepository; + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + return xPackageManager; +} + + /* Enters the XPackage objects into a map. They must be all from the same repository. The value type of the map is a vector, where each vector @@ -278,37 +298,6 @@ Reference ExtensionManager::getExtensionAndStatus( return theExtension; } -/* - Determines if the user extension was disabled by the user. Currently a user - cannot disable extensions from other repositories. If an extension does not - contain any items which need to be registered then the extension cannot - actually be disabled (because it cannot be registered). In this case false is - returned. If there is no user extension then also false is returned. - */ -bool ExtensionManager::isUserExtensionDisabled( - OUString const & identifier, OUString const & fileName, - css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv ) - -{ - bool bDisabled = false; - Reference xExtension; - try - { //will throw an exception if the extension does not exist - xExtension = m_userRepository->getDeployedPackage( - identifier, fileName, Reference()); - } catch(lang::IllegalArgumentException &) - { - } - if (xExtension.is()) - { - beans::Optional > reg = - xExtension->isRegistered(xAbortChannel, xCmdEnv); - if (reg.IsPresent && ! reg.Value.Value) - bDisabled = true; - } - return bDisabled; -} /* This method determines the active extension (XPackage.registerPackage) with a particular identifier. @@ -326,36 +315,50 @@ bool ExtensionManager::isUserExtensionDisabled( */ void ExtensionManager::activateExtension( OUString const & identifier, OUString const & fileName, - bool bUserDisabled, Reference const & xAbortChannel, Reference const & xCmdEnv ) { ::std::list > listExtensions = getExtensionsWithSameId(identifier, fileName); OSL_ASSERT(listExtensions.size() == 3); - ::std::list >::const_iterator - iext = listExtensions.begin(); - //skip disabled user extension - if (listExtensions.front().is() && bUserDisabled) - iext++; + + activateExtension( + ::comphelper::containerToSequence< + Reference, + ::std::list > + > (listExtensions), + xAbortChannel, xCmdEnv); +} + +void ExtensionManager::activateExtension( + uno::Sequence > const & seqExt, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) +{ bool bActive = false; - for (; iext != listExtensions.end(); iext++) + sal_Int32 len = seqExt.getLength(); + for (sal_Int32 i = 0; i < len; i++) { - if (iext->is()) + Reference const & aExt = seqExt[i]; + if (aExt.is()) { //get the registration value of the current iteration beans::Optional > optReg = - (*iext)->isRegistered(xAbortChannel, xCmdEnv); + aExt->isRegistered(xAbortChannel, xCmdEnv); //If nothing can be registered then break if (!optReg.IsPresent) break; + //Check if this is a disabled user extension, if so then skip + if (!optReg.Value.Value && i == 0) //e.g. not registered + continue; + //If we have already determined an active extension then we must //make sure to unregister all extensions with the same id in //repositories with a lower priority if (bActive) { - (*iext)->revokePackage(xAbortChannel, xCmdEnv); + aExt->revokePackage(xAbortChannel, xCmdEnv); } else { @@ -365,7 +368,7 @@ void ExtensionManager::activateExtension( //Register if not already done. //reregister if the value is ambiguous, which indicates that //something went wrong during last registration. - (*iext)->registerPackage(xAbortChannel, xCmdEnv); + aExt->registerPackage(xAbortChannel, xCmdEnv); } } } @@ -386,8 +389,8 @@ Reference ExtensionManager::backupExtension( if (xOldExtension.is()) { xBackup = m_tmpRepository->addPackage( - xOldExtension->getURL(), OUString(), - Reference(), tmpCmdEnv); + xOldExtension->getURL(), uno::Sequence(), + OUString(), Reference(), tmpCmdEnv); OSL_ENSURE(xBackup.is(), "Failed to backup extension"); } @@ -408,7 +411,8 @@ ExtensionManager::getSupportedPackageTypes(OUString const & repository) // Only add to shared and user repository Reference ExtensionManager::addExtension( - OUString const & url, OUString const & repository, + OUString const & url, uno::Sequence const & properties, + OUString const & repository, Reference const & xAbortChannel, Reference const & xCmdEnv ) throw (deploy::DeploymentException, @@ -436,9 +440,11 @@ Reference ExtensionManager::addExtension( const OUString sFileName = xTmpExtension->getName(); const OUString sDisplayName = xTmpExtension->getDisplayName(); const OUString sVersion = xTmpExtension->getVersion(); + dp_misc::DescriptionInfoset info(dp_misc::getDescriptionInfoset(xTmpExtension->getURL())); + const ::boost::optional licenseAttributes = + info.getSimpleLicenseAttributes(); Reference xOldExtension; - bool bUserDisabled = false; Reference xExtensionBackup; uno::Any excOccurred1; @@ -450,10 +456,6 @@ Reference ExtensionManager::addExtension( //disabled by a user, then the newly installed one is enabled. If we //add to another repository then the user extension remains //disabled. - if (! repository.equals(OUSTR("user"))) - bUserDisabled = isUserExtensionDisabled( - sIdentifier, sFileName, xAbortChannel, xCmdEnv); - bool bWasRegistered = false; xOldExtension = getExtensionAndStatus( sIdentifier, sFileName, repository, xAbortChannel, @@ -474,8 +476,15 @@ Reference ExtensionManager::addExtension( checkInstall(sDisplayName, xCmdEnv); } + //Prevent showing the license if requested. + Reference _xCmdEnv(xCmdEnv); + ExtensionProperties props(OUString(), properties, Reference()); + if (licenseAttributes && licenseAttributes->suppressIfRequired + && props.isSuppressedLicense()) + _xCmdEnv = Reference(new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler())); + bCanInstall = xTmpExtension->checkPrerequisites( - xAbortChannel, xCmdEnv, xOldExtension.is(), repository); + xAbortChannel, _xCmdEnv, xOldExtension.is()) == 0 ? true : false; } catch (deploy::DeploymentException& ) { excOccurred1 = ::cppu::getCaughtException(); @@ -516,11 +525,10 @@ Reference ExtensionManager::addExtension( } xNewExtension = xPackageManager->addPackage( - url, OUString(), xAbortChannel, xCmdEnv); + url, properties, OUString(), xAbortChannel, xCmdEnv); activateExtension( dp_misc::getIdentifier(xNewExtension), - xNewExtension->getName(), bUserDisabled, - xAbortChannel, xCmdEnv); + xNewExtension->getName(), xAbortChannel, xCmdEnv); } } catch (deploy::DeploymentException& ) { @@ -560,7 +568,7 @@ Reference ExtensionManager::addExtension( tmpCmdEnv); } activateExtension( - sIdentifier, sFileName, bUserDisabled, + sIdentifier, sFileName, Reference(), tmpCmdEnv); if (xTmpExtension.is() || xExtensionBackup.is()) m_tmpRepository->removePackage( @@ -595,7 +603,7 @@ void ExtensionManager::removeExtension( uno::Any excOccurred1; Reference xExtensionBackup; Reference xPackageManager; - bool bUserDisabled = false; + try { //Determine the repository to use @@ -610,10 +618,6 @@ void ExtensionManager::removeExtension( ::osl::MutexGuard guard(m_mutex); //Backup the extension, in case the user cancels the action - - bUserDisabled = isUserExtensionDisabled( - identifier, fileName, xAbortChannel, xCmdEnv); - //Backup the extension, in case the user cancels the action xExtensionBackup = backupExtension( identifier, fileName, xPackageManager, xCmdEnv); @@ -625,8 +629,7 @@ void ExtensionManager::removeExtension( xPackageManager->removePackage( identifier, fileName, xAbortChannel, xCmdEnv); - activateExtension(identifier, fileName, bUserDisabled, - xAbortChannel, xCmdEnv); + activateExtension(identifier, fileName, xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { excOccurred1 = ::cppu::getCaughtException(); @@ -661,7 +664,7 @@ void ExtensionManager::removeExtension( xExtensionBackup, Reference(), tmpCmdEnv); activateExtension( - identifier, fileName, bUserDisabled, Reference(), + identifier, fileName, Reference(), tmpCmdEnv); m_tmpRepository->removePackage( @@ -735,7 +738,7 @@ void ExtensionManager::enableExtension( { activateExtension(dp_misc::getIdentifier(extension), extension->getName(), - false, xAbortChannel, xCmdEnv); + xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { excOccurred = ::cppu::getCaughtException(); @@ -762,7 +765,7 @@ void ExtensionManager::enableExtension( extension->revokePackage(Reference(), xCmdEnv); activateExtension(dp_misc::getIdentifier(extension), extension->getName(), - true, xAbortChannel, xCmdEnv); + xAbortChannel, xCmdEnv); } catch (...) { @@ -771,6 +774,56 @@ void ExtensionManager::enableExtension( } } +/** + */ +long ExtensionManager::checkPrerequisitesAndEnable( + Reference const & extension, + Reference const & xAbortChannel, + Reference const & xCmdEnv) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + try + { + if (!extension.is()) + return 0; + ::osl::MutexGuard guard(m_mutex); + sal_Int32 ret = 0; + Reference mgr = + getPackageManager(extension->getRepositoryName()); + ret = mgr->checkPrerequisites(extension, xAbortChannel, xCmdEnv); + if (ret) + { + //There are some unfulfilled prerequisites, try to revoke + extension->revokePackage(xAbortChannel, xCmdEnv); + } + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), xAbortChannel, xCmdEnv); + return ret; + } + catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any excOccurred = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during disableExtension"), + static_cast(this), excOccurred); + throw exc; + } +} + + void ExtensionManager::disableExtension( Reference const & extension, Reference const & xAbortChannel, @@ -806,7 +859,7 @@ void ExtensionManager::disableExtension( extension->revokePackage(xAbortChannel, xCmdEnv); activateExtension(dp_misc::getIdentifier(extension), extension->getName(), - true, xAbortChannel, xCmdEnv); + xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { excOccurred = ::cppu::getCaughtException(); @@ -832,7 +885,7 @@ void ExtensionManager::disableExtension( { activateExtension(dp_misc::getIdentifier(extension), extension->getName(), - false, xAbortChannel, xCmdEnv); + xAbortChannel, xCmdEnv); } catch (...) { @@ -852,26 +905,8 @@ uno::Sequence< Reference > lang::IllegalArgumentException, uno::RuntimeException) { - if (repository.equals(OUSTR("user"))) - { - return m_userRepository->getDeployedPackages( - xAbort, xCmdEnv); - } - else if (repository.equals(OUSTR("shared"))) - { - return m_sharedRepository->getDeployedPackages( - xAbort, xCmdEnv); - } - else if (repository.equals(OUSTR("bundled"))) - { - return m_bundledRepository->getDeployedPackages( - xAbort, xCmdEnv); - } - else - throw lang::IllegalArgumentException( - OUSTR("No valid repository name provided."), - static_cast(this), 0); - + return getPackageManager(repository)->getDeployedPackages( + xAbort, xCmdEnv); } Reference @@ -885,25 +920,8 @@ Reference lang::IllegalArgumentException, uno::RuntimeException) { - if (repository.equals(OUSTR("user"))) - { - return m_userRepository->getDeployedPackage( - identifier, filename, xCmdEnv); - } - else if (repository.equals(OUSTR("shared"))) - { - return m_sharedRepository->getDeployedPackage( - identifier, filename, xCmdEnv); - } - else if (repository.equals(OUSTR("bundled"))) - { - return m_bundledRepository->getDeployedPackage( - identifier, filename, xCmdEnv); - } - else - throw lang::IllegalArgumentException( - OUSTR("No valid repository name provided."), - static_cast(this), 0); + return getPackageManager(repository)->getDeployedPackage( + identifier, filename, xCmdEnv); } uno::Sequence< uno::Sequence > > @@ -978,17 +996,8 @@ void ExtensionManager::reinstallDeployedExtensions( { try { - Reference xPackageManager; - if (repository.equals(OUSTR("user"))) - xPackageManager = m_userRepository; - else if (repository.equals(OUSTR("shared"))) - xPackageManager = m_sharedRepository; - else if (repository.equals(OUSTR("bundled"))) - xPackageManager = m_bundledRepository; - else - throw lang::IllegalArgumentException( - OUSTR("No valid repository name provided."), - static_cast(this), 0); + Reference + xPackageManager = getPackageManager(repository); ::osl::MutexGuard guard(m_mutex); xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv); @@ -1002,10 +1011,7 @@ void ExtensionManager::reinstallDeployedExtensions( const OUString id = dp_misc::getIdentifier(extensions[ pos ]); const OUString fileName = extensions[ pos ]->getName(); OSL_ASSERT(id.getLength()); - activateExtension( - id, fileName, - isUserExtensionDisabled(id, fileName, xAbortChannel, xCmdEnv), - xAbortChannel, xCmdEnv ); + activateExtension(id, fileName, xAbortChannel, xCmdEnv ); } catch (lang::DisposedException &) { @@ -1067,57 +1073,34 @@ void ExtensionManager::synchronize( static_cast(this), 0); ::osl::MutexGuard guard(m_mutex); - uno::Sequence > seqAddedExtensions; - uno::Sequence > seqRemovedExtensions; - xPackageManager->synchronize(seqAddedExtensions, seqRemovedExtensions, - xAbortChannel, xCmdEnv); - - //ToDo: optimize, only call activateExtension once per id. - //Determine which of the extensions was disabled by the user - //iterate of both sequences and add the ids of the user disabled - //to a map - for (sal_Int32 i = 0; i < seqRemovedExtensions.getLength(); i++) + + dp_misc::ProgressLevel progress( + xCmdEnv, OUSTR("Synchronizing ") + repository + OUSTR(" repository\n")); + xPackageManager->synchronize(xAbortChannel, xCmdEnv); + + + try { - try - { - Reference const & xExtension = seqRemovedExtensions[i]; - OSL_ASSERT(xExtension.is()); - const OUString id = dp_misc::getIdentifier(xExtension); - const OUString fileName = xExtension->getName(); - - bool bUserDisabled = isUserExtensionDisabled( - id, xExtension->getName(), xAbortChannel, xCmdEnv); - xExtension->revokePackage(xAbortChannel, xCmdEnv); - xPackageManager->removePackage( - id, fileName, xAbortChannel, xCmdEnv); - activateExtension( - id, fileName, /*bUserDisabled*/ false, xAbortChannel, xCmdEnv); - } - catch (...) + const uno::Sequence > > + seqSeqExt = getAllExtensions(xAbortChannel, xCmdEnv); + for (sal_Int32 i = 0; i < seqSeqExt.getLength(); i++) { - OSL_ENSURE(0, "Extensions Manager: synchronize"); + uno::Sequence > const & seqExt = + seqSeqExt[i]; + + activateExtension(seqExt, xAbortChannel, xCmdEnv); } } - - for (sal_Int32 i = 0; i < seqAddedExtensions.getLength(); i++) + catch (...) { - try - { - Reference const & xExtension = seqAddedExtensions[i]; - OSL_ASSERT(xExtension.is()); - const OUString id = dp_misc::getIdentifier(xExtension); - const OUString fileName = xExtension->getName(); - bool bUserDisabled = isUserExtensionDisabled( - id, fileName, xAbortChannel, xCmdEnv); - activateExtension( - id, fileName, bUserDisabled, xAbortChannel, xCmdEnv); - } - catch (...) - { - OSL_ENSURE(0, "Extensions Manager: synchronize"); - } + //We catch the exception, so we can write the lastmodified file + //so we will no repeat this everytime OOo starts. + OSL_ENSURE(0, "Extensions Manager: synchronize"); } + + progress.update(OUSTR("\n\n")); + //Write the lastmodified file try { ::rtl::Bootstrap::expandMacros(file); @@ -1231,7 +1214,7 @@ Reference ExtensionManager::getTempExtension( { Reference tmpCmdEnvA(new TmpRepositoryCommandEnv()); Reference xTmpPackage = m_tmpRepository->addPackage( - url, OUString(), xAbortChannel, tmpCmdEnvA); + url, uno::Sequence(),OUString(), xAbortChannel, tmpCmdEnvA); if (!xTmpPackage.is()) { @@ -1242,6 +1225,20 @@ Reference ExtensionManager::getTempExtension( } return xTmpPackage; } + +uno::Sequence > SAL_CALL +ExtensionManager::getExtensionsWithUnacceptedLicenses( + OUString const & repository, + Reference const & xCmdEnv) + throw (deploy::DeploymentException, + uno::RuntimeException) +{ + Reference + xPackageManager = getPackageManager(repository); + ::osl::MutexGuard guard(m_mutex); + return xPackageManager->getExtensionsWithUnacceptedLicenses(xCmdEnv); +} + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 386e2a7ceffd..bafa97c24944 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -106,7 +106,9 @@ public: createAbortChannel() throw (css::uno::RuntimeException); virtual css::uno::Reference SAL_CALL addExtension( - ::rtl::OUString const & url, ::rtl::OUString const & repository, + ::rtl::OUString const & url, + css::uno::Sequence const & properties, + ::rtl::OUString const & repository, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, @@ -147,6 +149,18 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); + + virtual long SAL_CALL checkPrerequisitesAndEnable( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual css::uno::Sequence< css::uno::Reference > SAL_CALL getDeployedExtensions( ::rtl::OUString const & repository, @@ -202,6 +216,13 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual css::uno::Sequence > SAL_CALL + getExtensionsWithUnacceptedLicenses( + ::rtl::OUString const & repository, + css::uno::Reference const & xCmdEnv) + throw (css::deployment::DeploymentException, + css::uno::RuntimeException); + private: struct ExtensionInfos @@ -233,18 +254,16 @@ private: css::uno::Reference const & xCmdEnv, bool & out_bWasRegistered); - bool isUserExtensionDisabled( + void activateExtension( ::rtl::OUString const & identifier, ::rtl::OUString const & fileName, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); void activateExtension( - ::rtl::OUString const & identifier, - ::rtl::OUString const & fileName, - bool bUserDisabled, - css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv); + css::uno::Sequence > const & seqExt, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ); ::std::list > @@ -276,6 +295,10 @@ private: id2extensions & mapExt, css::uno::Sequence > const & seqExt, ::rtl::OUString const & repository); + + css::uno::Reference + getPackageManager(::rtl::OUString const & repository) + throw (css::lang::IllegalArgumentException); }; } diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index e2580e7b955b..0464d0de62d5 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -58,6 +58,7 @@ #include "com/sun/star/ucb/NameClash.hpp" #include "com/sun/star/deployment/VersionException.hpp" #include "com/sun/star/deployment/InstallException.hpp" +#include "com/sun/star/deployment/Prerequisites.hpp" #include "com/sun/star/task/XInteractionApprove.hpp" #include "com/sun/star/ucb/UnsupportedCommandException.hpp" #include "boost/bind.hpp" @@ -67,7 +68,8 @@ #include #include #include "dp_descriptioninfoset.hxx" - +#include "dp_commandenvironments.hxx" +#include "dp_properties.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -97,19 +99,6 @@ struct MatchTempDir } }; -struct MatchExtension -{ - const ActivePackages::Data m_data; - MatchExtension(ActivePackages::Data const & data ) : m_data(data) {} - bool operator () ( OUString const & temporaryName ) const; -}; - -bool MatchExtension::operator () (OUString const & temporaryName) const -{ - //case 1: The temporary file and thus the extension folder are already - //removed. - return m_data.temporaryName.equals(temporaryName); -} namespace { OUString getExtensionFolder(OUString const & parentFolder, @@ -131,23 +120,6 @@ OUString getExtensionFolder(OUString const & parentFolder, } return title; } -/* adds an unencoded segment to the URL. - - Throws an com.sun.star.uno.Exception if this failed. -*/ -OUString appendURLSegement(OUString const & baseURL, OUString const & segment) -{ - OUString url; - INetURLObject inet(baseURL); - if (inet.insertName( - segment, false, INetURLObject::LAST_SEGMENT, true, - INetURLObject::ENCODE_ALL)) - url = inet.GetMainURL(INetURLObject::NO_DECODE); - else - throw Exception( - OUSTR("ExtensionManager: failed to add segment to URL"), 0); - return url; -} } //______________________________________________________________________________ void PackageManagerImpl::initActivationLayer( @@ -193,7 +165,8 @@ void PackageManagerImpl::initActivationLayer( { ActivePackages::Data dbData; insertToActivationLayer( - mediaType, sourceContent, title, &dbData ); + Sequence(),mediaType, sourceContent, + title, &dbData ); insertToActivationLayerDB( title, dbData ); //TODO #i73136#: insertToActivationLayerDB needs id not @@ -293,7 +266,7 @@ void PackageManagerImpl::initActivationLayer( //Make sure only the same user removes the extension, who //previously unregistered it. This is avoid races if multiple instances //of OOo are running which all have write access to the shared installation. - //For example, user a uses extension a, removes the extension, but keeps OOo + //For example, a user removes the extension, but keeps OOo //running. Parts of the extension may still be loaded and used by OOo. //Therefore the extension is only deleted the next time the extension manager is //run after restarting OOo. While OOo is still running, another user starts OOo @@ -637,6 +610,7 @@ OUString PackageManagerImpl::detectMediaType( //______________________________________________________________________________ OUString PackageManagerImpl::insertToActivationLayer( + Sequence const & properties, OUString const & mediaType, ::ucbhelper::Content const & sourceContent_, OUString const & title, ActivePackages::Data * dbData ) { @@ -702,13 +676,17 @@ OUString PackageManagerImpl::insertToActivationLayer( //bundled extensions should only be added by the synchronizeAddedExtensions //functions. Moreover, there is no "temporary folder" for bundled extensions. OSL_ASSERT(!m_context.equals(OUSTR("bundled"))); + OUString sFolderUrl = makeURLAppendSysPathSegment(destFolderContent.getURL(), title); DescriptionInfoset info = - dp_misc::getDescriptionInfoset( - appendURLSegement(destFolderContent.getURL(), title)); + dp_misc::getDescriptionInfoset(sFolderUrl); dbData->temporaryName = tempEntry; dbData->fileName = title; dbData->mediaType = mediaType; dbData->version = info.getVersion(); + + //No write the properties file next to the extension + ExtensionProperties props(sFolderUrl, properties, xCmdEnv); + props.write(); return destFolder; } @@ -716,6 +694,8 @@ OUString PackageManagerImpl::insertToActivationLayer( void PackageManagerImpl::insertToActivationLayerDB( OUString const & id, ActivePackages::Data const & dbData ) { + //access to the database must be guarded. See removePackage + const ::osl::MutexGuard guard( getMutex() ); m_activePackagesDB->put( id, dbData ); } @@ -746,14 +726,17 @@ Reference PackageManagerImpl::importExtension( CommandAbortedException, lang::IllegalArgumentException, RuntimeException) { - return addPackage(extension->getURL(), OUString(), xAbortChannel, xCmdEnv_); + return addPackage(extension->getURL(), Sequence(), + OUString(), xAbortChannel, xCmdEnv_); } /* The function adds an extension but does not register it!!! It may not do any user interaction. This is done in XExtensionManager::addExtension */ Reference PackageManagerImpl::addPackage( - OUString const & url, OUString const & mediaType_, + OUString const & url, + css::uno::Sequence const & properties, + OUString const & mediaType_, Reference const & xAbortChannel, Reference const & xCmdEnv_ ) throw (deployment::DeploymentException, CommandFailedException, @@ -826,7 +809,7 @@ Reference PackageManagerImpl::addPackage( } ActivePackages::Data dbData; destFolder = insertToActivationLayer( - mediaType, sourceContent, title, &dbData ); + properties, mediaType, sourceContent, title, &dbData ); // bind activation package: @@ -859,10 +842,7 @@ Reference PackageManagerImpl::addPackage( xCmdEnv); } install = true; - const ::osl::MutexGuard guard( getMutex() ); - //access to the database must be guarded. See removePackage_ insertToActivationLayerDB(id, dbData); - } catch (...) { @@ -1062,8 +1042,13 @@ Reference PackageManagerImpl::getDeployedPackage_( Reference xExtension; try { - xExtension = m_xRegistry->bindPackage( - getDeployPath( data ), data.mediaType, false, OUString(), xCmdEnv ); + //Ignore extensions where XPackage::checkPrerequisites failed. + //They must not be usable for this user. + if (data.failedPrerequisites.equals(OUSTR("0"))) + { + xExtension = m_xRegistry->bindPackage( + getDeployPath( data ), data.mediaType, false, OUString(), xCmdEnv ); + } } catch (deployment::InvalidRemovedParameterException& e) { @@ -1083,6 +1068,8 @@ PackageManagerImpl::getDeployedPackages_( ActivePackages::Entries::const_iterator const iEnd( id2temp.end() ); for ( ; iPos != iEnd; ++iPos ) { + if (! iPos->second.failedPrerequisites.equals(OUSTR("0"))) + continue; try { packages.push_back( getDeployedPackage_( @@ -1265,8 +1252,7 @@ void PackageManagerImpl::reinstallDeployedPackages( return m_readOnly; } void PackageManagerImpl::synchronizeRemovedExtensions( - Sequence > & out_removedExtensions, - Reference const & /*xAbortChannel*/, + Reference const & xAbortChannel, Reference const & xCmdEnv) { @@ -1275,64 +1261,38 @@ void PackageManagerImpl::synchronizeRemovedExtensions( OSL_ASSERT(!m_context.equals(OUSTR("user"))); ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); - //Iterate over the contents of the extension folder and gather the - //temp file names (shared) or the folder names of the bundled extension. - ::ucbhelper::ResultSetInclude includeType = ::ucbhelper::INCLUDE_DOCUMENTS_ONLY; - if (m_context.equals(OUSTR("bundled"))) - includeType = ::ucbhelper::INCLUDE_FOLDERS_ONLY; - ::ucbhelper::Content tempFolder( - m_activePackages_expanded, xCmdEnv ); - Reference xResultSet( - tempFolder.createCursor( - Sequence( &StrTitle::get(), 1 ), includeType) ); - // get all temp directories: - ::std::vector tempEntries; - while (xResultSet->next()) { - OUString title( - Reference( - xResultSet, UNO_QUERY_THROW )->getString( - 1 /* Title */ ) ); - //also add the xxx.tmpremoved files for remove shared extensions - //this does not matter - tempEntries.push_back( ::rtl::Uri::encode( - title, rtl_UriCharClassPchar, - rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8 ) ); - } - typedef ActivePackages::Entries::const_iterator ITActive; bool bShared = m_context.equals(OUSTR("shared")); - ::std::vector > removedExtensions; + for (ITActive i = id2temp.begin(); i != id2temp.end(); i++) { - //Get the URL to the extensions folder, first make the url for the - //shared repository including the temporary name -// OUString url(m_activePackages_expanded + OUSTR("/") -// + i->second.temporaryName); -// if (bShared) -// url = appendURLSegement(m_activePackages_expanded + OUSTR("/") -// + i->second.temporaryName + OUSTR("_"), -// i->second.fileName); - OUString url = makeURL(m_activePackages, i->second.temporaryName); - if (bShared) - url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName); - - const MatchExtension match(i->second); - bool bRemoved = false; - if (::std::find_if(tempEntries.begin(), tempEntries.end(), match) == - tempEntries.end()) - { - //The the URL from the data base entry does not exist anymore. That is the - //folder was removed. - bRemoved = true; - } - else + try { + //Get the URL to the extensions folder, first make the url for the + //shared repository including the temporary name + OUString url = makeURL(m_activePackages, i->second.temporaryName); + if (bShared) + url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName); + + bool bRemoved = false; + //Check if the URL to the extension is still the same + ::ucbhelper::Content contentExtension; + + if (!create_ucb_content( + &contentExtension, url, + Reference(), false)) + { + bRemoved = true; + } + //The folder is in the extension database, but it can still be deleted. //look for the xxx.tmpremoved file - if (bShared) + //There can also be the case that a different extension was installed + //in a "temp" folder with name that is already used. + if (!bRemoved && bShared) { ::ucbhelper::Content contentRemoved; + if (create_ucb_content( &contentRemoved, m_activePackages_expanded + OUSTR("/") + @@ -1342,6 +1302,7 @@ void PackageManagerImpl::synchronizeRemovedExtensions( bRemoved = true; } } + if (!bRemoved) { //There may be another extensions at the same place @@ -1353,26 +1314,32 @@ void PackageManagerImpl::synchronizeRemovedExtensions( if (infoset.hasDescription() && infoset.getIdentifier() && (! i->first.equals(*(infoset.getIdentifier())) - || ! i->second.version.equals(infoset.getVersion()))) + || ! i->second.version.equals(infoset.getVersion()))) { bRemoved = true; } + + } + if (bRemoved) + { + Reference xPackage = m_xRegistry->bindPackage( + url, i->second.mediaType, true, i->first, xCmdEnv ); + OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object. + xPackage->revokePackage(xAbortChannel, xCmdEnv); + removePackage(xPackage->getIdentifier().Value, xPackage->getName(), + xAbortChannel, xCmdEnv); } } - if (bRemoved) + catch( uno::Exception & ) { - Reference xPackage = m_xRegistry->bindPackage( - url, i->second.mediaType, true, i->first, xCmdEnv ); - OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object. - removedExtensions.push_back(xPackage); + OSL_ASSERT(0); } } - out_removedExtensions = ::comphelper::containerToSequence(removedExtensions); } + void PackageManagerImpl::synchronizeAddedExtensions( - Sequence > & out_addedExtensions, - Reference const & xAbortChannel, + Reference const & xAbortChannel, Reference const & xCmdEnv) { // clean up activation layer, scan for zombie temp dirs: @@ -1385,65 +1352,58 @@ void PackageManagerImpl::synchronizeAddedExtensions( Sequence( &StrTitle::get(), 1 ), ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); - - ::std::vector > addedExtensions; while (xResultSet->next()) { - OUString title( - Reference( - xResultSet, UNO_QUERY_THROW )->getString( - 1 /* Title */ ) ); - //The temporary folders of user and shared have an '_' at then end. - //But the name in ActivePackages.temporaryName is saved without. - OUString title2 = title; - bool bNotBundled = !m_context.equals(OUSTR("bundled")); - if (bNotBundled) + try { - OSL_ASSERT(title2[title2.getLength() -1] == '_'); - title2 = title2.copy(0, title2.getLength() -1); - } - OUString titleEncoded = ::rtl::Uri::encode( + OUString title( + Reference( + xResultSet, UNO_QUERY_THROW )->getString( + 1 /* Title */ ) ); + //The temporary folders of user and shared have an '_' at then end. + //But the name in ActivePackages.temporaryName is saved without. + OUString title2 = title; + bool bNotBundled = !m_context.equals(OUSTR("bundled")); + if (bNotBundled) + { + OSL_ASSERT(title2[title2.getLength() -1] == '_'); + title2 = title2.copy(0, title2.getLength() -1); + } + OUString titleEncoded = ::rtl::Uri::encode( title2, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8); - const MatchTempDir match(titleEncoded); - if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == - id2temp.end()) - { - - // The folder was not found in the data base, so it must be - // an added extension - OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded); - OUString sExtFolder; - if (bNotBundled) //that is, shared + const MatchTempDir match(titleEncoded); + if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == + id2temp.end()) { - //Check if the extension was not "deleted" already which is indicated - //by a xxx.tmpremoved file - ::ucbhelper::Content contentRemoved; - if (create_ucb_content(&contentRemoved, url + OUSTR("removed"), - Reference(), false)) - continue; - sExtFolder = getExtensionFolder( - m_activePackages_expanded + + + // The folder was not found in the data base, so it must be + // an added extension + OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded); + OUString sExtFolder; + if (bNotBundled) //that is, shared + { + //Check if the extension was not "deleted" already which is indicated + //by a xxx.tmpremoved file + ::ucbhelper::Content contentRemoved; + if (create_ucb_content(&contentRemoved, url + OUSTR("removed"), + Reference(), false)) + continue; + sExtFolder = getExtensionFolder( + m_activePackages_expanded + OUString(OUSTR("/")) + titleEncoded + OUSTR("_"), xCmdEnv); - url = appendURLSegement(m_activePackages_expanded, title); - url = appendURLSegement(url, sExtFolder); - } - Reference xPackage = m_xRegistry->bindPackage( - url, OUString(), false, OUString(), xCmdEnv ); - if (xPackage.is()) - { - try + url = makeURLAppendSysPathSegment(m_activePackages_expanded, title); + url = makeURLAppendSysPathSegment(url, sExtFolder); + } + Reference xPackage = m_xRegistry->bindPackage( + url, OUString(), false, OUString(), xCmdEnv ); + if (xPackage.is()) { - //ToDo: We need to prevent that removed shared extensions are - //added again. This can happen if there is still the folder of the - //extension. However, there is the "removed" flag file which indicates - //that the extension was removed. //Prepare the database entry ActivePackages::Data dbData; - //There is no temporary folder for bundled extensions. It is therefore - //an empty string. + dbData.temporaryName = titleEncoded; if (bNotBundled) dbData.fileName = sExtFolder; @@ -1456,35 +1416,45 @@ void PackageManagerImpl::synchronizeAddedExtensions( "an identifier and a version"); OUString id = dp_misc::getIdentifier( xPackage ); - sal_Bool bAlreadyInstalled = sal_False; - if (xPackage->checkPrerequisites( - xAbortChannel, xCmdEnv, bAlreadyInstalled, m_context)) - { - const ::osl::MutexGuard guard( getMutex() ); - //access to the database must be guarded. See removePackage_ - insertToActivationLayerDB(id, dbData); - } - else - { - //ToDo: Remember that this failed. For example, the user - //could have declined the license. Then the next time the - //extension folder is investigated we do not want to - //try to install the extension again. - } - addedExtensions.push_back(xPackage); - } - catch (...) - { + + //We provide a special command environment that will prevent + //showing a license if simple-licens/@accept-by = "admin" + //It will also prevent showing the license for bundled extensions + //which is not supported. + OSL_ASSERT(!m_context.equals(OUSTR("user"))); + + // shall the license be suppressed? + DescriptionInfoset info = + dp_misc::getDescriptionInfoset(url); + ::boost::optional + attr = info.getSimpleLicenseAttributes(); + ExtensionProperties props(url,xCmdEnv); + bool bNoLicense = false; + if (attr && attr->suppressIfRequired && props.isSuppressedLicense()) + bNoLicense = true; + + Reference licCmdEnv( + new LicenseCommandEnv(xCmdEnv->getInteractionHandler(), + bNoLicense, m_context)); + sal_Int32 failedPrereq = xPackage->checkPrerequisites( + xAbortChannel, licCmdEnv, false); + //Remember that this failed. For example, the user + //could have declined the license. Then the next time the + //extension folder is investigated we do not want to + //try to install the extension again. + dbData.failedPrerequisites = OUString::valueOf(failedPrereq); + insertToActivationLayerDB(id, dbData); } } } + catch (uno::Exception &) + { + OSL_ASSERT(0); + } } - out_addedExtensions = ::comphelper::containerToSequence(addedExtensions); } void PackageManagerImpl::synchronize( - Sequence > & out_addedExtensions, - Sequence > & out_removedExtensions, Reference const & xAbortChannel, Reference const & xCmdEnv) throw (css::deployment::DeploymentException, @@ -1496,12 +1466,129 @@ void PackageManagerImpl::synchronize( check(); if (m_context.equals(OUSTR("user"))) return; - synchronizeRemovedExtensions( - out_removedExtensions, xAbortChannel, xCmdEnv); - synchronizeAddedExtensions( - out_addedExtensions, xAbortChannel, xCmdEnv); + synchronizeRemovedExtensions(xAbortChannel, xCmdEnv); + synchronizeAddedExtensions(xAbortChannel, xCmdEnv); +} + +Sequence< Reference > PackageManagerImpl::getExtensionsWithUnacceptedLicenses( + Reference const & xCmdEnv) + throw (deployment::DeploymentException, RuntimeException) +{ + try + { + const ::osl::MutexGuard guard( getMutex() ); + // clean up activation layer, scan for zombie temp dirs: + ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); + + ActivePackages::Entries::const_iterator i = id2temp.begin(); + bool bShared = m_context.equals(OUSTR("shared")); + ::std::vector > vec; + + + for (; i != id2temp.end(); i++ ) + { + //Get the database entry + ActivePackages::Data const & dbData = i->second; + sal_Int32 failedPrereq = dbData.failedPrerequisites.toInt32(); + //If the installation failed for other reason then the license then we + //ignore it. + if (failedPrereq ^= deployment::Prerequisites::LICENSE) + continue; + + //Prepare the URL to the extension + OUString url = makeURL(m_activePackages, i->second.temporaryName); + if (bShared) + url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName); + + Reference p = m_xRegistry->bindPackage( + url, OUString(), false, OUString(), xCmdEnv ); + + if (p.is()) + vec.push_back(p); + + } + return ::comphelper::containerToSequence(vec); + } + catch (deployment::DeploymentException &) + { + throw; + } + catch (RuntimeException&) + { + throw; + } + catch (...) + { + Any exc = ::cppu::getCaughtException(); + deployment::DeploymentException de( + OUSTR("PackageManagerImpl::getExtensionsWithUnacceptedLicenses"), + static_cast(this), exc); + exc <<= de; + ::cppu::throwException(exc); + } } +sal_Int32 PackageManagerImpl::checkPrerequisites( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException) +{ + try + { + if (!extension.is()) + return 0; + if (!m_context.equals(extension->getRepositoryName())) + throw lang::IllegalArgumentException( + OUSTR("PackageManagerImpl::checkPrerequisites: extension is not" + " from this repository."), 0, 0); + + ActivePackages::Data dbData; + OUString id = dp_misc::getIdentifier(extension); + if (m_activePackagesDB->get( &dbData, id, OUString())) + { + //If the license was already displayed, then do not show it again + Reference _xCmdEnv = xCmdEnv; + sal_Int32 prereq = dbData.failedPrerequisites.toInt32(); + if ( !(prereq & deployment::Prerequisites::LICENSE)) + _xCmdEnv = new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler()); + + sal_Int32 failedPrereq = extension->checkPrerequisites( + xAbortChannel, _xCmdEnv, false); + dbData.failedPrerequisites = OUString::valueOf(failedPrereq); + insertToActivationLayerDB(id, dbData); + } + else + { + throw lang::IllegalArgumentException( + OUSTR("PackageManagerImpl::checkPrerequisites: unknown extension"), + 0, 0); + + } + return 0; + } + catch (deployment::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any excOccurred = ::cppu::getCaughtException(); + deployment::DeploymentException exc( + OUSTR("PackageManagerImpl::checkPrerequisites: exception "), + static_cast(this), excOccurred); + throw exc; + } +} //############################################################################## diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h index 1249fe7e29d4..2e13c56ae968 100644 --- a/desktop/source/deployment/manager/dp_manager.h +++ b/desktop/source/deployment/manager/dp_manager.h @@ -75,6 +75,7 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper ::rtl::OUString detectMediaType( ::ucbhelper::Content const & ucbContent, bool throw_exc = true ); ::rtl::OUString insertToActivationLayer( + css::uno::Sequence const & properties, ::rtl::OUString const & mediaType, ::ucbhelper::Content const & sourceContent, ::rtl::OUString const & title, ActivePackages::Data * dbData ); @@ -89,14 +90,10 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper css::uno::Reference const & package); void synchronizeRemovedExtensions( - css::uno::Sequence > & - out_removedExtensions, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); void synchronizeAddedExtensions( - css::uno::Sequence > & - out_AddedExtensions, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); @@ -177,7 +174,9 @@ public: createAbortChannel() throw (css::uno::RuntimeException); virtual css::uno::Reference SAL_CALL addPackage( - ::rtl::OUString const & url, ::rtl::OUString const & mediaType, + ::rtl::OUString const & url, + css::uno::Sequence const & properties, + ::rtl::OUString const & mediaType, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, @@ -248,8 +247,6 @@ public: throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL synchronize( - css::uno::Sequence > & out_xAddedExtensions, - css::uno::Sequence > & out_xRemovedExtensions, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, @@ -257,7 +254,22 @@ public: css::ucb::CommandAbortedException, css::uno::RuntimeException); -}; + virtual css::uno::Sequence > SAL_CALL + getExtensionsWithUnacceptedLicenses( + css::uno::Reference const & xCmdEnv) + throw (css::deployment::DeploymentException, + css::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL checkPrerequisites( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + }; //______________________________________________________________________________ inline void PackageManagerImpl::check() diff --git a/desktop/source/deployment/manager/dp_properties.cxx b/desktop/source/deployment/manager/dp_properties.cxx new file mode 100644 index 000000000000..b04e8131ee15 --- /dev/null +++ b/desktop/source/deployment/manager/dp_properties.cxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "com/sun/star/ucb/XCommandEnvironment.hpp" +#include "com/sun/star/lang/IllegalArgumentException.hpp" +#include "xmlscript/xml_helper.hxx" +#include "ucbhelper/content.hxx" +#include + +#include "dp_ucb.h" +#include "rtl/ustrbuf.hxx" +#include "dp_properties.hxx" + +namespace lang = com::sun::star::lang; +namespace task = com::sun::star::task; +namespace ucb = com::sun::star::ucb; +namespace uno = com::sun::star::uno; +namespace css = com::sun::star; + +#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) + +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +#define PROP_SUPPRESS_LICENSE "SUPPRESS_LICENSE" +namespace dp_manager { + +//Reading the file +ExtensionProperties::ExtensionProperties( + OUString const & urlExtension, + Reference const & xCmdEnv) : + m_xCmdEnv(xCmdEnv) +{ + m_propFileUrl = urlExtension + OUSTR("properties"); + + ::std::list< ::std::pair< OUString, OUString> > props; + if (! dp_misc::create_ucb_content(NULL, m_propFileUrl, 0, false)) + return; + + ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv); + dp_misc::readProperties(props, contentProps); + + typedef ::std::list< ::std::pair< OUString, OUString> >::const_iterator CI; + for (CI i = props.begin(); i != props.end(); i++) + { + if (i->first.equals(OUSTR(PROP_SUPPRESS_LICENSE))) + m_prop_suppress_license = i->second; + } +} + +//Writing the file +ExtensionProperties::ExtensionProperties( + OUString const & urlExtension, + uno::Sequence const & properties, + Reference const & xCmdEnv) : + m_xCmdEnv(xCmdEnv) +{ + m_propFileUrl = urlExtension + OUSTR("properties"); + + for (sal_Int32 i = 0; i < properties.getLength(); i++) + { + css::beans::NamedValue const & v = properties[i]; + if (v.Name.equals(OUSTR(PROP_SUPPRESS_LICENSE))) + { + OUString value; + if (v.Value >>= value) + { + if (value.equals(OUSTR("1"))) + m_prop_suppress_license = OUSTR("1"); + } + else + { + throw lang::IllegalArgumentException( + OUSTR("Extension Manager: wrong property value"), 0, -1); + } + } + else + { + throw lang::IllegalArgumentException( + OUSTR("Extension Manager: unknown property"), 0, -1); + } + } +} + +void ExtensionProperties::write() +{ + ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv); + ::rtl::OUStringBuffer buf; + + if (m_prop_suppress_license) + { + buf.append(OUSTR(PROP_SUPPRESS_LICENSE)); + buf.append(OUSTR("=")); + buf.append(*m_prop_suppress_license); + } + + ::rtl::OString stamp = ::rtl::OUStringToOString( + buf.makeStringAndClear(), RTL_TEXTENCODING_UTF8); + Reference xData( + ::xmlscript::createInputStream( + ::rtl::ByteSequence( + reinterpret_cast(stamp.getStr()), + stamp.getLength() ) ) ); + contentProps.writeStream( xData, true /* replace existing */ ); +} + +bool ExtensionProperties::isSuppressedLicense() +{ + bool ret = false; + if (m_prop_suppress_license) + { + if (m_prop_suppress_license->equals(OUSTR("1"))) + ret = true; + } + return ret; +} + +} // namespace dp_manager + + diff --git a/desktop/source/deployment/manager/dp_properties.hxx b/desktop/source/deployment/manager/dp_properties.hxx new file mode 100644 index 000000000000..197155653de1 --- /dev/null +++ b/desktop/source/deployment/manager/dp_properties.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_manager.h,v $ + * $Revision: 1.17 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_PROPERTIES_HXX +#define INCLUDED_DP_PROPERTIES_HXX + + + +#include "com/sun/star/beans/NamedValue.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" +#include "boost/optional.hpp" + + +namespace css = ::com::sun::star; + +namespace dp_manager { + + + +/** + + */ +class ExtensionProperties +{ +protected: + ::rtl::OUString m_propFileUrl; + const css::uno::Reference m_xCmdEnv; + ::boost::optional< ::rtl::OUString> m_prop_suppress_license; +public: + + virtual ~ExtensionProperties() {}; + ExtensionProperties(::rtl::OUString const & urlExtension, + css::uno::Reference const & xCmdEnv); + + ExtensionProperties(::rtl::OUString const & urlExtension, + css::uno::Sequence const & properties, + css::uno::Reference const & xCmdEnv); + + void write(); + + bool isSuppressedLicense(); +}; +} + + + + +#endif + diff --git a/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx b/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx deleted file mode 100644 index 3a4a6f1d2b72..000000000000 --- a/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx +++ /dev/null @@ -1,166 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_desktop.hxx" - -#include "com/sun/star/deployment/VersionException.hpp" -#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" -#include "com/sun/star/deployment/LicenseException.hpp" -#include "com/sun/star/deployment/InstallException.hpp" -#include "com/sun/star/task/XInteractionApprove.hpp" -#include "com/sun/star/task/XInteractionAbort.hpp" -#include "com/sun/star/ucb/XCommandEnvironment.hpp" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "dp_tmprepocmdenv.hxx" - -namespace deployment = com::sun::star::deployment; -namespace lang = com::sun::star::lang; -namespace task = com::sun::star::task; -namespace ucb = com::sun::star::ucb; -namespace uno = com::sun::star::uno; -namespace css = com::sun::star; - -#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) - -using ::com::sun::star::uno::Reference; -using ::rtl::OUString; - -namespace dp_manager { - -TmpRepositoryCommandEnv::TmpRepositoryCommandEnv() -{ -} - -TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( - Reference< css::task::XInteractionHandler> const & handler) - : m_forwardHandler(handler) -{ -} - -TmpRepositoryCommandEnv::~TmpRepositoryCommandEnv() -{ -} -// XCommandEnvironment -//______________________________________________________________________________ -Reference TmpRepositoryCommandEnv::getInteractionHandler() -throw (uno::RuntimeException) -{ - return this; -} - -//______________________________________________________________________________ -Reference TmpRepositoryCommandEnv::getProgressHandler() -throw (uno::RuntimeException) -{ - return this; -} - -// XInteractionHandler -void TmpRepositoryCommandEnv::handle( - Reference< task::XInteractionRequest> const & xRequest ) - throw (uno::RuntimeException) -{ - uno::Any request( xRequest->getRequest() ); - OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); - - deployment::VersionException verExc; - deployment::LicenseException licExc; - deployment::InstallException instExc; - deployment::LicenseIndividualAgreementException licAgreementExc; - - - bool approve = false; - bool abort = false; - - if ((request >>= verExc) - || (request >>= licExc) - || (request >>= instExc) - || (request >>= licAgreementExc)) - { - approve = true; - } - - if (approve == false && abort == false) - { - if (m_forwardHandler.is()) - m_forwardHandler->handle(xRequest); - else - approve = true; - } - else - { - // select: - uno::Sequence< Reference< task::XInteractionContinuation > > conts( - xRequest->getContinuations() ); - Reference< task::XInteractionContinuation > const * pConts = - conts.getConstArray(); - sal_Int32 len = conts.getLength(); - for ( sal_Int32 pos = 0; pos < len; ++pos ) - { - if (approve) { - Reference< task::XInteractionApprove > xInteractionApprove( - pConts[ pos ], uno::UNO_QUERY ); - if (xInteractionApprove.is()) { - xInteractionApprove->select(); - // don't query again for ongoing continuations: - approve = false; - } - } - else if (abort) { - Reference< task::XInteractionAbort > xInteractionAbort( - pConts[ pos ], uno::UNO_QUERY ); - if (xInteractionAbort.is()) { - xInteractionAbort->select(); - // don't query again for ongoing continuations: - abort = false; - } - } - } - } -} - -// XProgressHandler -void TmpRepositoryCommandEnv::push( uno::Any const & /*Status*/ ) -throw (uno::RuntimeException) -{ -} - - -void TmpRepositoryCommandEnv::update( uno::Any const & /*Status */) -throw (uno::RuntimeException) -{ -} - -void TmpRepositoryCommandEnv::pop() throw (uno::RuntimeException) -{ -} - - -} // namespace dp_manager - - diff --git a/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx b/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx deleted file mode 100644 index 22111bc1e081..000000000000 --- a/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#if ! defined INCLUDED_DP_TMPREPOSITORYCOMMANDENVIRONMENT_HXX -#define INCLUDED_DP_TMPREPOSITORYCOMMANDENVIRONMENT_HXX - - -#include "cppuhelper/compbase3.hxx" -//#include "cppuhelper/implbase2.hxx" -#include "ucbhelper/content.hxx" - - - -namespace css = ::com::sun::star; - -namespace dp_manager { - -/** - This command environment is to be used when an extension is temporarily - stored in the "tmp" repository. It prevents all kind of user interaction. - */ -class TmpRepositoryCommandEnv - : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment, - css::task::XInteractionHandler, - css::ucb::XProgressHandler > -{ - css::uno::Reference< css::uno::XComponentContext > m_xContext; - css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler; -public: - virtual ~TmpRepositoryCommandEnv(); - TmpRepositoryCommandEnv(); - TmpRepositoryCommandEnv( - css::uno::Reference< css::task::XInteractionHandler> const & handler); - - // XCommandEnvironment - virtual css::uno::Reference SAL_CALL - getInteractionHandler() throw (css::uno::RuntimeException); - virtual css::uno::Reference - SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); - - // XInteractionHandler - virtual void SAL_CALL handle( - css::uno::Reference const & xRequest ) - throw (css::uno::RuntimeException); - - // XProgressHandler - virtual void SAL_CALL push( css::uno::Any const & Status ) - throw (css::uno::RuntimeException); - virtual void SAL_CALL update( css::uno::Any const & Status ) - throw (css::uno::RuntimeException); - virtual void SAL_CALL pop() throw (css::uno::RuntimeException); -}; - -} - - - - -#endif - diff --git a/desktop/source/deployment/manager/makefile.mk b/desktop/source/deployment/manager/makefile.mk index cb99325bde52..4dc6405e34bf 100644 --- a/desktop/source/deployment/manager/makefile.mk +++ b/desktop/source/deployment/manager/makefile.mk @@ -47,7 +47,8 @@ SLOFILES = \ $(SLO)$/dp_managerfac.obj \ $(SLO)$/dp_informationprovider.obj \ $(SLO)$/dp_extensionmanager.obj \ - $(SLO)$/dp_tmprepocmdenv.obj + $(SLO)$/dp_commandenvironments.obj \ + $(SLO)$/dp_properties.obj .INCLUDE : ..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/migration/dp_migration.cxx b/desktop/source/deployment/migration/dp_migration.cxx index 49362f7e2f5f..c2d0b0dc6bb8 100644 --- a/desktop/source/deployment/migration/dp_migration.cxx +++ b/desktop/source/deployment/migration/dp_migration.cxx @@ -136,7 +136,7 @@ Any MigrationImpl::execute( Sequence const & ) ->queryContentIdentifierString() ); try { xManager->addPackage( - sourceURL, OUString() /* detect media-type */, + sourceURL, uno::Sequence(),OUString() /* detect media-type */, Reference(), xCmdEnv ); } catch (RuntimeException &) { diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 1f1fde7ca7bf..919f134b3fb9 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -44,8 +44,10 @@ #include "com/sun/star/ucb/CommandAbortedException.hpp" #include "com/sun/star/bridge/UnoUrlResolver.hpp" #include "com/sun/star/bridge/XUnoUrlResolver.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "boost/scoped_array.hpp" #include "boost/shared_ptr.hpp" +#include #ifdef WNT //#include "tools/prewin.h" @@ -138,6 +140,103 @@ bool existsOfficePipe() return pipe.is(); } + +//Returns true if the Folder was more recently modified then +//the lastsynchronized file. That is the repository needs to +//be synchronized. +bool compareExtensionFolderWithLastSynchronizedFile( + OUString const & folderURL, OUString const & fileURL) +{ + bool bNeedsSync = false; + ::osl::DirectoryItem itemExtFolder; + ::osl::File::RC err1 = + ::osl::DirectoryItem::get(folderURL, itemExtFolder); + //If it does not exist, then there is nothing to be done + if (err1 == ::osl::File::E_NOENT) + { + return false; + } + else if (err1 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access extension folder"); + return true; //sync just in case + } + + //If last synchronized does not exist, then OOo is started for the first time + ::osl::DirectoryItem itemFile; + ::osl::File::RC err2 = ::osl::DirectoryItem::get(fileURL, itemFile); + if (err2 == ::osl::File::E_NOENT) + { + return true; + + } + else if (err2 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access file lastsynchronized"); + return true; //sync just in case + } + + //compare the modification time of the extension folder and the last + //modified file + ::osl::FileStatus statFolder(FileStatusMask_ModifyTime); + ::osl::FileStatus statFile(FileStatusMask_ModifyTime); + if (itemExtFolder.getFileStatus(statFolder) == ::osl::File::E_None) + { + if (itemFile.getFileStatus(statFile) == ::osl::File::E_None) + { + TimeValue timeFolder = statFolder.getModifyTime(); + TimeValue timeFile = statFile.getModifyTime(); + + if (timeFile.Seconds < timeFolder.Seconds) + bNeedsSync = true; + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + return bNeedsSync; +} + +bool needToSyncRepostitory(OUString const & name) +{ + OUString folder; + OUString file; + if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")))) + { + folder = OUString( + RTL_CONSTASCII_USTRINGPARAM("$BUNDLED_EXTENSIONS")); + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); + } + else if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("shared")))) + { + folder = OUString( + RTL_CONSTASCII_USTRINGPARAM( + "$UNO_SHARED_PACKAGES_CACHE/uno_packages")); + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$SHARED_EXTENSIONS_USER/lastsynchronized")); + } + else + { + OSL_ASSERT(0); + return true; + } + ::rtl::Bootstrap::expandMacros(folder); + ::rtl::Bootstrap::expandMacros(file); + return compareExtensionFolderWithLastSynchronizedFile( + folder, file); +} + + } // anon namespace //============================================================================== @@ -480,22 +579,43 @@ void TRACE(::rtl::OString const & sText) #endif } -bool hasExtensionRepositoryChanged(::rtl::OUString const & repository) +void syncRepositories(Reference const & xCmdEnv) { - if (repository.equals(OUSTR("shared"))) + Reference xExtensionManager; + //synchronize shared before bundled otherewise there are + //more revoke and registration calls. + OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); + if (needToSyncRepostitory(sShared)) { - //get the extensions folder - OUString folder(RTL_CONSTASCII_USTRINGPARAM("BUNDLED_EXTENSIONS")); - ::rtl::Bootstrap::expandMacros(folder); + xExtensionManager = + deployment::ExtensionManager::get( + comphelper_getProcessComponentContext()); + + if (xExtensionManager.is()) + { + xExtensionManager->synchronize( + sShared, Reference(), xCmdEnv); + } } - else if (repository.equals(OUSTR("bundled"))) + + OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); + if (needToSyncRepostitory( sBundled)) { - } - else - throw lang::IllegalArgumentException( - OUSTR("Invalid repository name."), 0, 0); + if (!xExtensionManager.is()) + { + xExtensionManager = + deployment::ExtensionManager::get( + comphelper_getProcessComponentContext()); + } + if (xExtensionManager.is()) + { + xExtensionManager->synchronize( + sBundled, Reference(), xCmdEnv); - return false; + } + } } + + } diff --git a/desktop/source/deployment/misc/dp_ucb.cxx b/desktop/source/deployment/misc/dp_ucb.cxx index 571aef9c1b95..795a492aa0d5 100644 --- a/desktop/source/deployment/misc/dp_ucb.cxx +++ b/desktop/source/deployment/misc/dp_ucb.cxx @@ -271,4 +271,50 @@ bool readLine( OUString * res, OUString const & startingWith, return false; } +bool readProperties( ::std::list< ::std::pair< ::rtl::OUString, ::rtl::OUString> > & out_result, + ::ucbhelper::Content & ucb_content ) +{ + // read whole file: + ::rtl::ByteSequence bytes( readFile( ucb_content ) ); + OUString file( reinterpret_cast(bytes.getConstArray()), + bytes.getLength(), RTL_TEXTENCODING_UTF8); + sal_Int32 pos = 0; + + for (;;) + { + + ::rtl::OUStringBuffer buf; + sal_Int32 start = pos; + + bool bEOF = false; + pos = file.indexOf( LF, pos ); + if (pos < 0) { // EOF + buf.append( file.copy( start ) ); + bEOF = true; + } + else + { + if (pos > 0 && file[ pos - 1 ] == CR) + // consume extra CR + buf.append( file.copy( start, pos - start - 1 ) ); + else + buf.append( file.copy( start, pos - start ) ); + pos++; + } + OUString aLine = buf.makeStringAndClear(); + + sal_Int32 posEqual = aLine.indexOf('='); + if (posEqual > 0 && (posEqual + 1) < aLine.getLength()) + { + OUString name = aLine.copy(0, posEqual); + OUString value = aLine.copy(posEqual + 1); + out_result.push_back(::std::make_pair(name, value)); + } + + if (bEOF) + break; + } + return false; +} + } diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index 667f1588e247..17444eb0828e 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -157,7 +157,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - OUString const & loader, bool bRemoved, OUString const & identifier); + OUString const & loader, bool bRemoved, + OUString const & identifier); }; friend class ComponentPackageImpl; @@ -186,7 +187,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool jarFile, bool bRemoved, OUString const & identifier); + bool jarFile, bool bRemoved, + OUString const & identifier); }; friend class TypelibraryPackageImpl; @@ -207,7 +209,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, OUString const & identifier, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -283,7 +285,8 @@ BackendImpl::ComponentPackageImpl::ComponentPackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - OUString const & loader, bool bRemoved, OUString const & identifier) + OUString const & loader, bool bRemoved, + OUString const & identifier) : Package( myBackend, url, name, name /* display-name */, xPackageType, bRemoved, identifier), m_loader( loader ), diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 354676fd56ff..fefa6794342a 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -114,7 +114,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, sal_Bool bRemoved, - OUString const & identifier, Reference const & xCmdEnv ); + OUString const & identifier, + Reference const & xCmdEnv ); ::std::auto_ptr m_registeredPackages; // for backwards compatibility diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index be752bcf0733..1cebd20c297a 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -31,6 +31,7 @@ #include "dp_backend.h" #include "dp_ucb.h" #include "rtl/uri.hxx" +#include "rtl/bootstrap.hxx" #include "osl/file.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/servicedecl.hxx" @@ -170,7 +171,8 @@ Reference PackageRegistryBackend::bindPackage( Reference xNewPackage; try { - xNewPackage = bindPackage_( url, mediaType, bRemoved, identifier, xCmdEnv ); + xNewPackage = bindPackage_( url, mediaType, bRemoved, + identifier, xCmdEnv ); } catch (RuntimeException &) { throw; @@ -318,6 +320,16 @@ Package::Package( ::rtl::Reference const & myBackend, m_bRemoved(bRemoved), m_identifier(identifier) { + if (m_bRemoved) + { + //We use the last segment of the URL + OSL_ASSERT(m_name.getLength() == 0); + OUString name = m_url; + rtl::Bootstrap::expandMacros(name); + sal_Int32 index = name.lastIndexOf('/'); + if (index != -1 && index < name.getLength()) + m_name = name.copy(index + 1); + } } //______________________________________________________________________________ @@ -407,10 +419,10 @@ sal_Bool Package::isBundle() throw (RuntimeException) } //______________________________________________________________________________ -::sal_Bool Package::checkPrerequisites( +::sal_Int32 Package::checkPrerequisites( const css::uno::Reference< css::task::XAbortChannel >&, const css::uno::Reference< css::ucb::XCommandEnvironment >&, - sal_Bool, ::rtl::OUString const &) + sal_Bool) throw (css::deployment::DeploymentException, css::deployment::ExtensionRemovedException, css::ucb::CommandFailedException, @@ -419,7 +431,7 @@ sal_Bool Package::isBundle() throw (RuntimeException) { if (m_bRemoved) throw deployment::ExtensionRemovedException(); - return true; + return 0; } //______________________________________________________________________________ diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index e35b37bdeb07..c5e440a2a825 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -127,7 +127,7 @@ public: // XPackageRegistry virtual Reference SAL_CALL bindPackage( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException); @@ -498,7 +498,8 @@ Reference PackageRegistryImpl::bindPackage( for ( ; iPos != iEnd; ++iPos ) { try { - return (*iPos)->bindPackage( url, mediaType, bRemoved, identifier, xCmdEnv ); + return (*iPos)->bindPackage( url, mediaType, bRemoved, + identifier, xCmdEnv ); } catch (lang::IllegalArgumentException &) { } @@ -527,7 +528,8 @@ Reference PackageRegistryImpl::bindPackage( getResourceString(RID_STR_UNSUPPORTED_MEDIA_TYPE) + mediaType, static_cast(this), static_cast(-1) ); } - return iFind->second->bindPackage( url, mediaType, bRemoved, identifier, xCmdEnv ); + return iFind->second->bindPackage( url, mediaType, bRemoved, + identifier, xCmdEnv ); } } diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index 39fd3cdc892e..1dc4cdde64ea 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -152,7 +152,8 @@ Reference BackendImpl::bindPackage_( if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.executable")) { return new BackendImpl::ExecutablePackageImpl( - this, url, name, m_xExecutableTypeInfo, bRemoved, identifier); + this, url, name, m_xExecutableTypeInfo, bRemoved, + identifier); } } } diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index aeeec94981e6..a523a1aa20a5 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -102,10 +102,6 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv); void implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ); -// rtl::OUString getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ); -// rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); -// rtl::OUString getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ); -// rtl::OUString expandURL( const rtl::OUString& aURL ); void addDataToDb(OUString const & url, HelpBackendDb::Data const & data); ::boost::optional readDataFromDb(OUString const & url); @@ -195,7 +191,8 @@ Reference BackendImpl::bindPackage_( "vnd.sun.star.help")) { return new PackageImpl( - this, url, name, m_xHelpTypeInfo, bRemoved, identifier); + this, url, name, m_xHelpTypeInfo, bRemoved, + identifier); } } } @@ -233,7 +230,8 @@ BackendImpl::PackageImpl::PackageImpl( OUString const & url, OUString const & name, Reference const & xPackageType, bool bRemoved, OUString const & identifier) - : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) + : Package( myBackend, url, name, name, xPackageType, bRemoved, + identifier) { if (bRemoved) { @@ -290,13 +288,6 @@ void BackendImpl::PackageImpl::processPackage_( BackendImpl* that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); that->implProcessHelp( xThisPackage, doRegisterPackage, xCmdEnv); - -// HelpBackendDb::Data data; -// getMyBackend()->addDataToDb(getURL(), data); - -// } -// else -// getMyBackend()->deleteDataFromDb(getURL()); } beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL() @@ -373,23 +364,6 @@ void BackendImpl::implProcessHelp { std::vector< rtl::OUString > aXhpFileVector; - // Delete (old) files in any case to allow compiler to be started every time -// rtl::OUString aLangWithPureNameURL( aLangURL ); -// aLangWithPureNameURL += aSlash; -// aLangWithPureNameURL += aHelpStr; -// rtl::OUString aDbFile( aLangWithPureNameURL ); -// aDbFile += rtl::OUString::createFromAscii( ".db" ); -// if( xSFA->exists( aDbFile ) ) -// xSFA->kill( aDbFile ); -// rtl::OUString aHtFile( aLangWithPureNameURL ); -// aHtFile += rtl::OUString::createFromAscii( ".ht" ); -// if( xSFA->exists( aHtFile ) ) -// xSFA->kill( aHtFile ); -// rtl::OUString aKeyFile( aLangWithPureNameURL ); -// aKeyFile += rtl::OUString::createFromAscii( ".key" ); -// if( xSFA->exists( aKeyFile ) ) -// xSFA->kill( aKeyFile ); - // calculate jar file URL sal_Int32 indexStartSegment = aLangURL.lastIndexOf('/'); // for example "/en" @@ -408,12 +382,6 @@ void BackendImpl::implProcessHelp rtl::OUString aJarFile( makeURL(sHelpFolder, langFolderURLSegment + aSlash + aHelpStr + OUSTR(".jar"))); -// aJarFile += aSlash; -// aJarFile += aHelpStr; -// aJarFile += rtl::OUString::createFromAscii( ".jar" ); - // remove in any case to clean up -// if( xSFA->exists( aJarFile ) ) -// xSFA->kill( aJarFile ); aJarFile = ::dp_misc::expandUnoRcUrl(aJarFile); rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( @@ -443,8 +411,6 @@ void BackendImpl::implProcessHelp aDestPath += aPureFolderName; xSFA->copy( aSubFolderURL, aDestPath ); } - //Copy help.tree to the temp folder in the help backend folder -// xSFA->copy(aLangURL + OUSTR("/help.tree"), langFolderDestExpanded + OUSTR("/help.tree")); // Call compiler sal_Int32 nXhpFileCount = aXhpFileVector.size(); @@ -485,7 +451,6 @@ void BackendImpl::implProcessHelp aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); rtl::OUString aSystemPath; -// osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); osl::FileBase::getSystemPathFromFileURL( langFolderDestExpanded, aSystemPath ); aParamsSeq[5] = uno::makeAny( aSystemPath ); @@ -562,75 +527,6 @@ void BackendImpl::implProcessHelp } } -// rtl::OUString BackendImpl::getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ) -// { -// rtl::OUString aRetURL; -// if( !xPackage.is() ) -// return aRetURL; -// rtl::OUString aHelpURL = xPackage->getURL(); -// aRetURL = expandURL( aHelpURL ); -// aRetURL += rtl::OUString::createFromAscii( pFlagStr ); -// return aRetURL; -// } - -// rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ) -// { -// return getFlagFileURL( xPackage, "/RegisteredFlag" ); -// } - -// rtl::OUString BackendImpl::getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ) -// { -// return getFlagFileURL( xPackage, "/CompiledFlag" ); -// } - -// rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL ) -// { -// static Reference< util::XMacroExpander > xMacroExpander; -// static Reference< uri::XUriReferenceFactory > xFac; - -// if( !xMacroExpander.is() || !xFac.is() ) -// { -// Reference const & xContext = getComponentContext(); -// if( xContext.is() ) -// { -// xFac = Reference< uri::XUriReferenceFactory >( -// xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( -// "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY ); -// } -// if( !xFac.is() ) -// { -// throw RuntimeException( -// ::rtl::OUString::createFromAscii( -// "dp_registry::backend::help::BackendImpl::expandURL(), " -// "could not instatiate UriReferenceFactory." ), -// Reference< XInterface >() ); -// } - -// xMacroExpander = Reference< util::XMacroExpander >( -// xContext->getValueByName( -// ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), -// UNO_QUERY_THROW ); -// } - -// rtl::OUString aRetURL = aURL; -// if( xMacroExpander.is() ) -// { -// Reference< uri::XUriReference > uriRef; -// for (;;) -// { -// uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY ); -// if ( uriRef.is() ) -// { -// Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY ); -// if( !sxUri.is() ) -// break; - -// aRetURL = sxUri->expand( xMacroExpander ); -// } -// } -// } -// return aRetURL; -// } void BackendImpl::implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ) diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 179420b16ef6..7ad55d29ba2f 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -175,10 +175,10 @@ public: css::ucb::CommandAbortedException, css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL checkPrerequisites( + virtual ::sal_Int32 SAL_CALL checkPrerequisites( const css::uno::Reference< css::task::XAbortChannel >& xAbortChannel, const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, - sal_Bool bInstalled, ::rtl::OUString const & aContextName) + sal_Bool noLicenseChecking) throw (css::deployment::DeploymentException, css::deployment::ExtensionRemovedException, css::ucb::CommandFailedException, diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 467ff5ca89fa..822e744b8fc2 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -64,8 +64,8 @@ #include "com/sun/star/packages/manifest/XManifestWriter.hpp" #include "com/sun/star/deployment/DependencyException.hpp" #include "com/sun/star/deployment/LicenseException.hpp" -#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" #include "com/sun/star/deployment/PlatformException.hpp" +#include "com/sun/star/deployment/Prerequisites.hpp" #include "com/sun/star/xml/dom/XDocumentBuilder.hpp" #include "com/sun/star/xml/xpath/XXPathAPI.hpp" #include "com/sun/star/deployment/XPackageManager.hpp" @@ -139,8 +139,7 @@ class BackendImpl : public ImplBaseT ::sal_Bool checkLicense( Reference< ucb::XCommandEnvironment > const & xCmdEnv, - DescriptionInfoset const & description, bool bInstalled, - OUString const & aContextName ) + DescriptionInfoset const & description, bool bNoLicenseChecking) throw (deployment::DeploymentException, ucb::CommandFailedException, ucb::CommandAbortedException, @@ -199,10 +198,10 @@ class BackendImpl : public ImplBaseT ucb::CommandAbortedException, RuntimeException); - virtual ::sal_Bool SAL_CALL checkPrerequisites( + virtual ::sal_Int32 SAL_CALL checkPrerequisites( const Reference< task::XAbortChannel >& xAbortChannel, const Reference< ucb::XCommandEnvironment >& xCmdEnv, - ::sal_Bool bInstalled, OUString const & aContextName) + ::sal_Bool noLicenseChecking) throw (deployment::ExtensionRemovedException, deployment::DeploymentException, ucb::CommandFailedException, @@ -423,12 +422,14 @@ Reference BackendImpl::bindPackage_( } if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.package-bundle")) { return new PackageImpl( - this, url, name, m_xBundleTypeInfo, false, bRemoved, identifier); + this, url, name, m_xBundleTypeInfo, false, bRemoved, + identifier); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.legacy-package-bundle")) { return new PackageImpl( - this, url, name, m_xLegacyBundleTypeInfo, true, bRemoved, identifier); + this, url, name, m_xLegacyBundleTypeInfo, true, bRemoved, + identifier); } } } @@ -652,7 +653,7 @@ bool BackendImpl::PackageImpl::checkDependencies( ::sal_Bool BackendImpl::PackageImpl::checkLicense( css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, - DescriptionInfoset const & info, bool bInstalled, OUString const & aContextName) + DescriptionInfoset const & info, bool alreadyInstalled) throw (css::deployment::DeploymentException, css::ucb::CommandFailedException, css::ucb::CommandAbortedException, @@ -679,41 +680,21 @@ bool BackendImpl::PackageImpl::checkDependencies( throw css::deployment::DeploymentException( OUSTR("Could not obtain attribute simple-lincense@accept-by or it has no valid value"), 0, Any()); - //If if @accept-by="user" then every user needs to accept the license before it can be installed. - //Therefore we must prevent the installation as shared extension unless suppress-if-required="true" - OSL_ASSERT(aContextName.getLength()); - if (simplLicAttr->acceptBy.equals(OUSTR("user")) && aContextName.equals(OUSTR("shared"))) - { - css::deployment::LicenseIndividualAgreementException - exc = css::deployment::LicenseIndividualAgreementException( - OUString(), 0, m_name, simplLicAttr->suppressIfRequired); - - bool approve = false; - bool abort = false; - if (! interactContinuation( - Any(exc), task::XInteractionApprove::static_type(), xCmdEnv, &approve, &abort )) - throw css::deployment::DeploymentException( - OUSTR("Could not interact with user."), 0, Any()); - if (abort == true) - return false; - - //If the unopkg --suppress-license was used and simplLicAttr->suppressIfRequired == true, - //then the user implicitely accepts the license - } //Only use interaction if there is no version of this extension already installed //and the suppress-on-update flag is not set for the new extension - // bInstalled | bSuppressOnUpdate | show license + // alreadyInstalled | bSuppressOnUpdate | show license //---------------------------------------- // 0 | 0 | 1 // 0 | 1 | 1 // 1 | 0 | 1 // 1 | 1 | 0 - if ( !(bInstalled && simplLicAttr->suppressOnUpdate)) + if ( !(alreadyInstalled && simplLicAttr->suppressOnUpdate)) { css::deployment::LicenseException licExc( - OUString(), 0, m_name, sLicense, simplLicAttr->suppressIfRequired); + OUString(), 0, getDisplayName(), sLicense, + simplLicAttr->acceptBy); bool approve = false; bool abort = false; if (! interactContinuation( @@ -745,10 +726,10 @@ bool BackendImpl::PackageImpl::checkDependencies( } } -::sal_Bool BackendImpl::PackageImpl::checkPrerequisites( +::sal_Int32 BackendImpl::PackageImpl::checkPrerequisites( const css::uno::Reference< css::task::XAbortChannel >&, const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, - sal_Bool bInstalled, OUString const & aContextName) + sal_Bool alreadyInstalled) throw (css::deployment::DeploymentException, css::deployment::ExtensionRemovedException, css::ucb::CommandFailedException, @@ -759,11 +740,21 @@ bool BackendImpl::PackageImpl::checkDependencies( throw deployment::ExtensionRemovedException(); DescriptionInfoset info = getDescriptionInfoset(); if (!info.hasDescription()) - return sal_True; - - return checkPlatform(xCmdEnv) - && checkDependencies(xCmdEnv, info) - && checkLicense(xCmdEnv, info, bInstalled, aContextName); + return 0; + + //always return LICENSE as long as the user did not accept the license + //so that XExtensonManager::checkPrerequisitesAndEnable will again + //check the license + if (!checkPlatform(xCmdEnv)) + return deployment::Prerequisites::PLATFORM | + deployment::Prerequisites::LICENSE; + else if(!checkDependencies(xCmdEnv, info)) + return deployment::Prerequisites::DEPENDENCIES | + deployment::Prerequisites::LICENSE; + else if(!checkLicense(xCmdEnv, info, alreadyInstalled)) + return deployment::Prerequisites::LICENSE; + else + return 0; } ::sal_Bool BackendImpl::PackageImpl::checkDependencies( diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index b645c9b2af7a..5023a501c67e 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -233,9 +233,9 @@ Reference BackendImpl::bindPackage_( 0, dialogURL, xCmdEnv, false /* no throw */ )) { dialogURL = OUString(); } - return new PackageImpl( this, url, xCmdEnv, - makeURL( url, OUSTR("script.xlb") ), - dialogURL, bRemoved, identifier); + return new PackageImpl( + this, url, xCmdEnv, makeURL( url, OUSTR("script.xlb") ), + dialogURL, bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.dialog-library")) { diff --git a/desktop/source/deployment/unopkg/unopkg.src b/desktop/source/deployment/unopkg/unopkg.src index 79c578628676..dc204e265ec6 100644 --- a/desktop/source/deployment/unopkg/unopkg.src +++ b/desktop/source/deployment/unopkg/unopkg.src @@ -27,15 +27,10 @@ #include "deployment.hrc" -String RID_STR_UNOPKG_NO_SHARED_ALLOWED -{ - Text [ en-US ] = "The option \"--shared\" cannot be used to install the extension \'%NAME\', " - "because every user has to agree to the license agreement of the extension. The extension will not be installed."; -}; String RID_STR_UNOPKG_ACCEPT_LIC_1 { - Text [ en-US ] = "Extension License Agreement:"; + Text [ en-US ] = "Extension Software License Agreement of $NAME:"; }; String RID_STR_UNOPKG_ACCEPT_LIC_2 diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index 11bf8129cc04..a077eaddb911 100755 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -52,6 +52,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -363,7 +364,8 @@ bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir static_cast< cppu::OWeakObject* >( pCmdEnv ), uno::UNO_QUERY ); uno::Reference< task::XAbortChannel > xAbortChannel; uno::Reference< deployment::XPackage > xPackage = - m_xPackageManager->addPackage( sSourceDir, ::rtl::OUString(), xAbortChannel, xCmdEnv ); + m_xPackageManager->addPackage( + sSourceDir, uno::Sequence(),::rtl::OUString(), xAbortChannel, xCmdEnv ); if ( xPackage.is() ) return true; diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 807260fe4663..ba8cd56085f8 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -41,6 +41,7 @@ #include "cppuhelper/implbase1.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/anytostring.hxx" +#include "comphelper/sequence.hxx" #include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/ui/PackageManagerDialog.hpp" @@ -60,10 +61,24 @@ using ::rtl::OUString; namespace css = ::com::sun::star; namespace { +struct ExtensionName +{ + OUString m_str; + ExtensionName( OUString const & str ) : m_str( str ) {} + bool operator () ( Reference const & e ) const + { + if (m_str.equals(dp_misc::getIdentifier(e)) + || m_str.equals(e->getName())) + return true; + return false; + } +}; + //------------------------------------------------------------------------------ const char s_usingText [] = "\n" "using: " APP_NAME " add extension-path...\n" +" " APP_NAME " validate extension-identifier...\n" " " APP_NAME " remove extension-identifier...\n" " " APP_NAME " list extension-identifier...\n" " " APP_NAME " reinstall \n" @@ -73,6 +88,8 @@ const char s_usingText [] = "\n" "sub-commands:\n" " add add extension\n" +" validate checks the prerequisites of an installed extension and" +" registers it if possible\n" " remove remove extensions by identifier\n" " reinstall expert feature: reinstall all deployed extensions\n" " list list information about deployed extensions\n" @@ -252,7 +269,7 @@ extern "C" int unopkg_main() return 0; } else if (isOption( info_version, &nPos )) { - dp_misc::writeConsole("\n"APP_NAME" Version 3.0\n"); + dp_misc::writeConsole("\n"APP_NAME" Version 3.3\n"); return 0; } //consume all bootstrap variables which may occur before the subcommannd @@ -314,15 +331,6 @@ extern "C" int unopkg_main() } } - //make sure the bundled option was provided together with shared -// if (option_bundled && !option_shared) -// { -// dp_misc::writeConsoleError( -// "\nERROR: option --bundled can only be used together with --shared!"); -// return 1; -// } - - xComponentContext = getUNO( disposeGuard, option_verbose, option_shared, subcmd_gui, xLocalComponentContext ); @@ -357,8 +365,11 @@ extern "C" int unopkg_main() Reference< ::com::sun::star::ucb::XCommandEnvironment > xCmdEnv( createCmdEnv( xComponentContext, logFile, - option_force, option_verbose, option_bundled, - option_suppressLicense) ); + option_force, option_verbose) ); + + //synchronize bundled/shared extensions + if (!subcmd_gui && ! dp_misc::office_is_running()) + dp_misc::syncRepositories(xCmdEnv); if (subcmd_add || subCommand.equalsAsciiL( @@ -369,9 +380,12 @@ extern "C" int unopkg_main() OUString const & cmdPackage = cmdPackages[ pos ]; if (subcmd_add) { + beans::NamedValue nvSuppress( + OUSTR("SUPPRESS_LICENSE"), option_suppressLicense ? + makeAny(OUSTR("1")):makeAny(OUSTR("0"))); xExtensionManager->addExtension( - cmdPackage, repository, - Reference(), xCmdEnv); + cmdPackage, Sequence(&nvSuppress, 1), + repository, Reference(), xCmdEnv); } else { @@ -410,32 +424,131 @@ extern "C" int unopkg_main() } else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("list") )) { - Sequence< Reference > packages; + ::std::vector > vecExtUnaccepted; + ::comphelper::sequenceToContainer(vecExtUnaccepted, + xExtensionManager->getExtensionsWithUnacceptedLicenses( + repository, xCmdEnv)); + + //This vector tells what XPackage in allExtensions has an + //unaccepted license. + std::vector vecUnaccepted; + std::vector > allExtensions; if (cmdPackages.empty()) { - packages = xExtensionManager->getDeployedExtensions( - repository, Reference(), xCmdEnv ); + Sequence< Reference > + packages = xExtensionManager->getDeployedExtensions( + repository, Reference(), xCmdEnv ); + + ::std::vector > vec_packages; + ::comphelper::sequenceToContainer(vec_packages, packages); + + //First copy the extensions with the unaccepted license + //to vector allExtensions. + allExtensions.resize(vecExtUnaccepted.size() + vec_packages.size()); + + ::std::vector >::iterator i_all_ext = + ::std::copy(vecExtUnaccepted.begin(), vecExtUnaccepted.end(), + allExtensions.begin()); + //Now copy those we got from getDeployedExtensions + ::std::copy(vec_packages.begin(), vec_packages.end(), i_all_ext); + + //Now prepare the vector which tells what extension has an + //unaccepted license + vecUnaccepted.resize(vecExtUnaccepted.size() + vec_packages.size()); + ::std::vector::iterator i_unaccepted = + ::std::fill_n(vecUnaccepted.begin(), + vecExtUnaccepted.size(), true); + ::std::fill_n(i_unaccepted, vec_packages.size(), false); + dp_misc::writeConsole( - OUSTR("all deployed ") + repository + OUSTR(" packages:\n")); + OUSTR("All deployed ") + repository + OUSTR(" extensions:\n\n")); } else { - packages.realloc( cmdPackages.size() ); + //The user provided the names (ids or file names) of the extensions + //which shall be listed for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos ) + { + Reference extension; try { - packages[ pos ] = xExtensionManager->getDeployedExtension( + extension = xExtensionManager->getDeployedExtension( repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv ); } catch (lang::IllegalArgumentException &) { - packages[ pos ] = findPackage(repository, + extension = findPackage(repository, xExtensionManager, xCmdEnv, cmdPackages[ pos ] ); - if ( !packages[ pos ].is() ) - throw; } + + //Now look if the requested extension has an unaccepted license + bool bUnacceptedLic = false; + if (!extension.is()) + { + ::std::vector >::const_iterator + i = ::std::find_if( + vecExtUnaccepted.begin(), + vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos])); + if (i != vecExtUnaccepted.end()) + { + extension = *i; + bUnacceptedLic = true; + } + } + + if (extension.is()) + { + allExtensions.push_back(extension); + vecUnaccepted.push_back(bUnacceptedLic); + } + + else + throw lang::IllegalArgumentException( + OUSTR("There is no such extension deployed: ") + + cmdPackages[pos],0,-1); + } + + } + + printf_packages(allExtensions, vecUnaccepted, xCmdEnv ); + } + else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("validate") )) + { + ::std::vector > vecExtUnaccepted; + ::comphelper::sequenceToContainer( + vecExtUnaccepted, xExtensionManager->getExtensionsWithUnacceptedLicenses( + repository, xCmdEnv)); + + for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos ) + { + Reference extension; + try + { + extension = xExtensionManager->getDeployedExtension( + repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv ); + } + catch (lang::IllegalArgumentException &) + { + extension = findPackage( + repository, xExtensionManager, xCmdEnv, cmdPackages[ pos ] ); + } + + if (!extension.is()) + { + ::std::vector >::const_iterator + i = ::std::find_if( + vecExtUnaccepted.begin(), + vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos])); + if (i != vecExtUnaccepted.end()) + { + extension = *i; + } + } + + if (extension.is()) + xExtensionManager->checkPrerequisitesAndEnable( + extension, Reference(), xCmdEnv); } - printf_packages( packages, xCmdEnv ); } else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("gui") )) { diff --git a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx index d23dcbf9577d..69a973b90a42 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx @@ -49,7 +49,7 @@ #include "com/sun/star/deployment/PlatformException.hpp" #include "com/sun/star/i18n/XCollator.hpp" #include "com/sun/star/i18n/CollatorOptions.hpp" -#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" + #include #include "deployment.hrc" #include "dp_version.hxx" @@ -85,13 +85,12 @@ class CommandEnvironmentImpl sal_Int32 m_logLevel; bool m_option_force_overwrite; bool m_option_verbose; - bool m_option_bundled; - bool m_option_suppressLicense; Reference< XComponentContext > m_xComponentContext; Reference< XProgressHandler > m_xLogFile; void update_( Any const & Status ) throw (RuntimeException); - void printLicense(const OUString& sLicense, bool & accept, bool & decline); + void printLicense(const OUString & sName,const OUString& sLicense, + bool & accept, bool & decline); public: virtual ~CommandEnvironmentImpl(); @@ -99,9 +98,7 @@ public: Reference const & xComponentContext, OUString const & log_file, bool option_force_overwrite, - bool option_verbose, - bool option_bundled, - bool option_suppressLicense); + bool option_verbose); // XCommandEnvironment virtual Reference< task::XInteractionHandler > SAL_CALL @@ -120,19 +117,16 @@ public: virtual void SAL_CALL pop() throw (RuntimeException); }; + //______________________________________________________________________________ CommandEnvironmentImpl::CommandEnvironmentImpl( Reference const & xComponentContext, OUString const & log_file, bool option_force_overwrite, - bool option_verbose, - bool option_bundled, - bool option_suppressLicense) + bool option_verbose) : m_logLevel(0), m_option_force_overwrite( option_force_overwrite ), m_option_verbose( option_verbose ), - m_option_bundled( option_bundled), - m_option_suppressLicense( option_suppressLicense), m_xComponentContext(xComponentContext) { if (log_file.getLength() > 0) { @@ -162,10 +156,13 @@ CommandEnvironmentImpl::~CommandEnvironmentImpl() } //May throw exceptions -void CommandEnvironmentImpl::printLicense(const OUString& sLicense, bool & accept, bool &decline) +void CommandEnvironmentImpl::printLicense( + const OUString & sName, const OUString& sLicense, bool & accept, bool &decline) { ResMgr * pResMgr = DeploymentResMgr::get(); - OUString s1 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_1, *pResMgr)); + String s1tmp(ResId(RID_STR_UNOPKG_ACCEPT_LIC_1, *pResMgr)); + s1tmp.SearchAndReplaceAllAscii( "$NAME", sName ); + OUString s1(s1tmp); OUString s2 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_2, *pResMgr)); OUString s3 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_3, *pResMgr)); OUString s4 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_4, *pResMgr)); @@ -246,7 +243,6 @@ void CommandEnvironmentImpl::handle( lang::WrappedTargetException wtExc; deployment::LicenseException licExc; deployment::InstallException instExc; - deployment::LicenseIndividualAgreementException licAgreementExc; deployment::PlatformException platExc; deployment::VersionException verExc; @@ -281,27 +277,9 @@ void CommandEnvironmentImpl::handle( update_( wtExc.TargetException ); } } - else if (request >>= licAgreementExc) - { - if (m_option_suppressLicense && licAgreementExc.SuppressIfRequired) - { - approve = true; - } - else - { - String sResMsg( ResId( RID_STR_UNOPKG_NO_SHARED_ALLOWED, *DeploymentResMgr::get() ) ); - sResMsg.SearchAndReplaceAllAscii( "%NAME", licAgreementExc.ExtensionName ); - dp_misc::writeConsole(OUSTR("\n") + sResMsg + OUSTR("\n\n")); - abort = true; - } - } else if (request >>= licExc) { - bLicenseException = true; - if (m_option_suppressLicense && licExc.SuppressIfRequired) - approve = true; - else - printLicense(licExc.Text, approve, abort); + printLicense(licExc.ExtensionName, licExc.Text, approve, abort); } else if (request >>= instExc) { @@ -436,6 +414,7 @@ void CommandEnvironmentImpl::pop() throw (RuntimeException) m_xLogFile->pop(); } + } // anon namespace namespace unopkg { @@ -445,14 +424,10 @@ Reference< XCommandEnvironment > createCmdEnv( Reference< XComponentContext > const & xContext, OUString const & logFile, bool option_force_overwrite, - bool option_verbose, - bool option_bundled, - bool option_suppressLicense) + bool option_verbose) { return new CommandEnvironmentImpl( - xContext, logFile, option_force_overwrite, option_verbose, option_bundled, - option_suppressLicense); + xContext, logFile, option_force_overwrite, option_verbose); } - } // unopkg diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx index b25176e1dcee..3272810afee2 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx @@ -48,6 +48,7 @@ #include "unotools/configmgr.hxx" #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "cppuhelper/bootstrap.hxx" +#include "comphelper/sequence.hxx" #include using ::rtl::OUString; @@ -317,7 +318,10 @@ void printf_package( xPackage->getBundle( Reference(), xCmdEnv ) ); printf_space( level + 1 ); dp_misc::writeConsole("bundled Packages: {\n"); - printf_packages( seq, xCmdEnv, level + 2 ); + ::std::vector >vec_bundle; + ::comphelper::sequenceToContainer(vec_bundle, seq); + printf_packages( vec_bundle, ::std::vector(vec_bundle.size()), + xCmdEnv, level + 2 ); printf_space( level + 1 ); dp_misc::writeConsole("}\n"); } @@ -325,23 +329,45 @@ void printf_package( } // anon namespace +void printf_unaccepted_licenses( + Reference const & ext) +{ + OUString id( + dp_misc::getIdentifier(ext) ); + printf_line( OUSTR("Identifier"), id, 0 ); + printf_space(1); + dp_misc::writeConsole(OUSTR("License not accepted\n\n")); +} + //============================================================================== void printf_packages( - Sequence< Reference > const & seq, + ::std::vector< Reference > const & allExtensions, + ::std::vector const & vecUnaccepted, Reference const & xCmdEnv, sal_Int32 level ) { - sal_Int32 len = seq.getLength(); - Reference< deployment::XPackage > const * p = seq.getConstArray(); - if (len == 0) { + OSL_ASSERT(allExtensions.size() == vecUnaccepted.size()); + + if (allExtensions.size() == 0) + { printf_space( level ); dp_misc::writeConsole("\n"); } - else { - for ( sal_Int32 pos = 0; pos < len; ++pos ) - printf_package( p[ pos ], xCmdEnv, level ); + else + { + typedef ::std::vector< Reference >::const_iterator I_EXT; + int index = 0; + for (I_EXT i = allExtensions.begin(); i != allExtensions.end(); i++, index++) + { + if (vecUnaccepted[index]) + printf_unaccepted_licenses(*i); + else + printf_package( *i, xCmdEnv, level ); + dp_misc::writeConsole(OUSTR("\n")); + } } } + //############################################################################## namespace { diff --git a/desktop/source/pkgchk/unopkg/unopkg_shared.h b/desktop/source/pkgchk/unopkg/unopkg_shared.h index 6e9d30cf0d42..43f77513b10c 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_shared.h +++ b/desktop/source/pkgchk/unopkg/unopkg_shared.h @@ -162,14 +162,12 @@ css::uno::Reference createCmdEnv( css::uno::Reference const & xContext, ::rtl::OUString const & logFile, bool option_force_overwrite, - bool option_verbose, - bool option_bundled, - bool option_suppressLicense); - + bool option_verbose); //============================================================================== void printf_packages( - css::uno::Sequence< - css::uno::Reference > const & seq, + ::std::vector< + css::uno::Reference > const & allExtensions, + ::std::vector const & vecUnaccepted, css::uno::Reference const & xCmdEnv, sal_Int32 level = 0 ); -- cgit From 85c93f5779b0382769cf9dfb5a6306a018c17edd Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Tue, 20 Apr 2010 07:59:05 +0200 Subject: jl152 import 263447 from native0jl:#i77196# Show progress on startup --- desktop/inc/app.hxx | 6 +- desktop/source/app/app.cxx | 16 +- desktop/source/app/check_ext_deps.cxx | 205 +++++++++++++-------- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 1 - desktop/source/splash/splash.cxx | 27 +-- desktop/source/splash/splash.hxx | 1 + 6 files changed, 161 insertions(+), 95 deletions(-) diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 4f5a3b176be3..486d280311d9 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -132,7 +132,10 @@ class Desktop : public Application static sal_Bool LicenseNeedsAcceptance(); static sal_Bool IsFirstStartWizardNeeded(); static sal_Bool CheckExtensionDependencies(); - static void SynchronizeExtensionRepositories(); + + void SynchronizeExtensionRepositories(); + void SetSplashScreenText( const ::rtl::OUString& rText ); + void SetSplashScreenProgress( sal_Int32 ); private: // Bootstrap methods @@ -165,7 +168,6 @@ class Desktop : public Application Reference m_rSplashScreen; void OpenSplashScreen(); - void SetSplashScreenProgress(sal_Int32); void CloseSplashScreen(); void EnableOleAutomation(); diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index b82915871566..8e610fb0e141 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1392,12 +1392,14 @@ void Desktop::Main() tools::InitTestToolLib(); RTL_LOGFILE_CONTEXT_TRACE( aLog, "} tools::InitTestToolLib" ); + // Check if bundled or shared extensions were added /removed + // and process those extensions (has to be done before checking + // the extension dependencies! + SynchronizeExtensionRepositories(); + bool bAbort = CheckExtensionDependencies(); if ( bAbort ) return; - //Check if bundled or shared extensions were added /removed - //and process those extensions - SynchronizeExtensionRepositories(); // First Start Wizard allowed ? if ( ! pCmdLineArgs->IsNoFirstStartWizard()) @@ -2919,6 +2921,14 @@ void Desktop::SetSplashScreenProgress(sal_Int32 iProgress) } } +void Desktop::SetSplashScreenText( const ::rtl::OUString& rText ) +{ + if( m_rSplashScreen.is() ) + { + m_rSplashScreen->setText( rText ); + } +} + void Desktop::CloseSplashScreen() { if(m_rSplashScreen.is()) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index f487e0dfc96f..6a9beae58ccd 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -27,12 +27,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" -#include +#include "osl/file.hxx" +#include "osl/mutex.hxx" + #include #include #include #include "cppuhelper/compbase3.hxx" +#include "vcl/wrkwin.hxx" +#include "vcl/timer.hxx" + #include #include @@ -59,7 +64,7 @@ using rtl::OUString; using namespace desktop; using namespace com::sun::star; -#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) +#define UNISTRING(s) OUString(RTL_CONSTASCII_USTRINGPARAM(s)) namespace { @@ -69,9 +74,13 @@ class SilentCommandEnv task::XInteractionHandler, ucb::XProgressHandler > { + Desktop *mpDesktop; + sal_Int32 mnLevel; + sal_Int32 mnProgress; + public: - virtual ~SilentCommandEnv(){}; - SilentCommandEnv(){}; + SilentCommandEnv( Desktop* pDesktop ); + virtual ~SilentCommandEnv(); // XCommandEnvironment virtual uno::Reference SAL_CALL @@ -91,21 +100,38 @@ public: throw (uno::RuntimeException); virtual void SAL_CALL pop() throw (uno::RuntimeException); }; + +//----------------------------------------------------------------------------- +SilentCommandEnv::SilentCommandEnv( Desktop* pDesktop ) +{ + mpDesktop = pDesktop; + mnLevel = 0; + mnProgress = 25; +} + +//----------------------------------------------------------------------------- +SilentCommandEnv::~SilentCommandEnv() +{ + mpDesktop->SetSplashScreenText( OUString() ); +} + +//----------------------------------------------------------------------------- Reference SilentCommandEnv::getInteractionHandler() -throw (uno::RuntimeException) + throw (uno::RuntimeException) { return this; } +//----------------------------------------------------------------------------- Reference SilentCommandEnv::getProgressHandler() -throw (uno::RuntimeException) + throw (uno::RuntimeException) { return this; } +//----------------------------------------------------------------------------- // XInteractionHandler -void SilentCommandEnv::handle( - Reference< task::XInteractionRequest> const & xRequest ) +void SilentCommandEnv::handle( Reference< task::XInteractionRequest> const & xRequest ) throw (uno::RuntimeException) { uno::Any request( xRequest->getRequest() ); @@ -127,23 +153,45 @@ void SilentCommandEnv::handle( } } +//----------------------------------------------------------------------------- // XProgressHandler -void SilentCommandEnv::push( uno::Any const & /*Status*/ ) -throw (uno::RuntimeException) +void SilentCommandEnv::push( uno::Any const & rStatus ) + throw (uno::RuntimeException) { -} + OUString sText; + mnLevel += 1; + if ( rStatus.hasValue() && ( rStatus >>= sText) ) + { + if ( mnLevel == 1 ) + mpDesktop->SetSplashScreenText( sText ); + else + mpDesktop->SetSplashScreenProgress( ++mnProgress ); + } +} -void SilentCommandEnv::update( uno::Any const & /*Status */) -throw (uno::RuntimeException) +//----------------------------------------------------------------------------- +void SilentCommandEnv::update( uno::Any const & rStatus ) + throw (uno::RuntimeException) { + OUString sText; + if ( rStatus.hasValue() && ( rStatus >>= sText) ) + { + mpDesktop->SetSplashScreenText( sText ); + } } +//----------------------------------------------------------------------------- void SilentCommandEnv::pop() throw (uno::RuntimeException) { + mnLevel -= 1; } } // end namespace + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); //------------------------------------------------------------------------------ @@ -169,55 +217,75 @@ static sal_Int16 impl_showExtensionDialog( uno::Reference< uno::XComponentContex //------------------------------------------------------------------------------ // Check dependencies of all packages //------------------------------------------------------------------------------ -static bool impl_checkDependencies( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +static bool impl_checkDependencies( const uno::Reference< uno::XComponentContext > &xContext ) { - uno::Sequence< uno::Reference< deployment::XPackage > > packages; + uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; + uno::Reference< deployment::XExtensionManager > xExtensionManager = deployment::ExtensionManager::get( xContext ); + + if ( !xExtensionManager.is() ) + { + OSL_ENSURE( 0, "Could not get the Extension Manager!" ); + return true; + } try { - packages = xPackageManager->getDeployedPackages( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ); + xAllPackages = xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ); } - catch ( deployment::DeploymentException & ) { /* handleGeneralError(e.Cause);*/ } - catch ( ucb::CommandFailedException & ) { /* handleGeneralError(e.Reason);*/ } - catch ( ucb::CommandAbortedException & ) {} + catch ( deployment::DeploymentException & ) { return true; } + catch ( ucb::CommandFailedException & ) { return true; } + catch ( ucb::CommandAbortedException & ) { return true; } catch ( lang::IllegalArgumentException & e ) { throw uno::RuntimeException( e.Message, e.Context ); } - for ( sal_Int32 i = 0; i < packages.getLength(); ++i ) + sal_Int32 nMax = 2; +#ifdef DEBUG + nMax = 3; +#endif + + for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - bool bRegistered = false; - try { - beans::Optional< beans::Ambiguous< sal_Bool > > option( packages[i]->isRegistered( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ) ); - if ( option.IsPresent ) - { - ::beans::Ambiguous< sal_Bool > const & reg = option.Value; - if ( reg.IsAmbiguous ) - bRegistered = false; - else - bRegistered = reg.Value ? true : false; - } - else - bRegistered = false; - } - catch ( uno::RuntimeException & ) { throw; } - catch ( uno::Exception & exc) { - (void) exc; - OSL_ENSURE( 0, ::rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); - bRegistered = false; - } + uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - if ( bRegistered ) + for ( sal_Int32 j = 0; (jcheckDependencies( uno::Reference< ucb::XCommandEnvironment >() ); - } - catch ( deployment::DeploymentException & ) {} - if ( ! bDependenciesValid ) + uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; + if ( xPackage.is() ) { - return false; + bool bRegistered = false; + try { + beans::Optional< beans::Ambiguous< sal_Bool > > option( xPackage->isRegistered( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ) ); + if ( option.IsPresent ) + { + ::beans::Ambiguous< sal_Bool > const & reg = option.Value; + if ( reg.IsAmbiguous ) + bRegistered = false; + else + bRegistered = reg.Value ? true : false; + } + else + bRegistered = false; + } + catch ( uno::RuntimeException & ) { throw; } + catch ( uno::Exception & exc) { + (void) exc; + OSL_ENSURE( 0, ::rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + } + + if ( bRegistered ) + { + bool bDependenciesValid = false; + try { + bDependenciesValid = xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment >() ); + } + catch ( deployment::DeploymentException & ) {} + if ( ! bDependenciesValid ) + { + return false; + } + } } } } @@ -254,31 +322,11 @@ static void impl_setNeedsCompatCheck() static bool impl_check() { uno::Reference< uno::XComponentContext > xContext = comphelper_getProcessComponentContext(); - uno::Reference< deployment::XPackageManager > xManager; - bool bDependenciesValid = true; - try { - xManager = deployment::thePackageManagerFactory::get( xContext )->getPackageManager( UNISTRING("user") ); - } - catch ( ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - if ( xManager.is() ) - bDependenciesValid = impl_checkDependencies( xManager ); - - if ( bDependenciesValid ) - { - try { - xManager = deployment::thePackageManagerFactory::get( xContext )->getPackageManager( UNISTRING("shared") ); - } - catch ( ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - if ( xManager.is() ) - bDependenciesValid = impl_checkDependencies( xManager ); - } + bool bDependenciesValid = impl_checkDependencies( xContext ); short nRet = 0; + if ( !bDependenciesValid ) nRet = impl_showExtensionDialog( xContext ); @@ -292,7 +340,7 @@ static bool impl_check() } //------------------------------------------------------------------------------ -// to check, if we need checking the dependencies of the extensions again, we compare +// to check if we need checking the dependencies of the extensions again, we compare // the build id of the office with the one of the last check //------------------------------------------------------------------------------ static bool impl_needsCompatCheck() @@ -325,6 +373,9 @@ static bool impl_needsCompatCheck() pset->setPropertyValue( OUString::createFromAscii("LastCompatibilityCheckID"), result ); Reference< util::XChangesBatch >( pset, UNO_QUERY_THROW )->commitChanges(); } +#ifdef DEBUG + bNeedsCheck = true; +#endif } catch (const Exception&) {} @@ -348,11 +399,9 @@ void Desktop::SynchronizeExtensionRepositories() { RTL_LOGFILE_CONTEXT(aLog,"desktop (jl97489) ::Desktop::SynchronizeExtensionRepositories"); OUString sDisable; - ::rtl::Bootstrap::get( - OUString(RTL_CONSTASCII_USTRINGPARAM("DISABLE_SYNC_EXTENSIONS")), - sDisable, - OUString(RTL_CONSTASCII_USTRINGPARAM(""))); + ::rtl::Bootstrap::get( UNISTRING( "DISABLE_SYNC_EXTENSIONS" ), sDisable, OUString() ); if (sDisable.getLength() > 0) return; - dp_misc::syncRepositories(new SilentCommandEnv()); + + dp_misc::syncRepositories( new SilentCommandEnv( this ) ); } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index fef6d36c7165..cd37f07729bb 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -243,7 +243,6 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare { TUpdateListEntry pEntry( new UpdateListEntry( xPackage, m_sPackageManagers[j] ) ); vEntries.push_back( pEntry ); - break; } } } diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 5fee3028b4f6..381a98ce008f 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -135,14 +135,21 @@ void SAL_CALL SplashScreen::reset() } } -void SAL_CALL SplashScreen::setText(const OUString&) +void SAL_CALL SplashScreen::setText(const OUString& rText) throw (RuntimeException) { - if (_bVisible && !_bProgressEnd) { - if ( _eBitmapMode == BM_FULLSCREEN ) - ShowFullScreenMode( TRUE ); - Show(); - Flush(); + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + if ( _sProgressText != rText ) + { + _sProgressText = rText; + + if (_bVisible && !_bProgressEnd) + { + if ( _eBitmapMode == BM_FULLSCREEN ) + ShowFullScreenMode( TRUE ); + Show(); + updateStatus(); + } } } @@ -647,7 +654,7 @@ void SplashScreen::Paint( const Rectangle&) } if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aControlRegion, - CTRL_STATE_ENABLED, aValue, rtl::OUString() )) != FALSE ) + CTRL_STATE_ENABLED, aValue, _sProgressText )) != FALSE ) { return; } @@ -668,10 +675,8 @@ void SplashScreen::Paint( const Rectangle&) _vdev.DrawRect(Rectangle(_tlx, _tly, _tlx+_barwidth, _tly+_barheight)); _vdev.SetFillColor( _cProgressBarColor ); _vdev.SetLineColor(); - Rectangle aRect(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace); - _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, - _tlx+_barspace+length, _tly+_barheight-_barspace)); - + _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace)); + _vdev.DrawText( Rectangle(_tlx, _tly+_barheight+5, _tlx+_barwidth, _tly+_barheight+5+20), _sProgressText, TEXT_DRAW_CENTER ); } Size aSize = GetOutputSizePixel(); Size bSize = _vdev.GetOutputSizePixel(); diff --git a/desktop/source/splash/splash.hxx b/desktop/source/splash/splash.hxx index 99677aa107f1..8480ed3df9ae 100644 --- a/desktop/source/splash/splash.hxx +++ b/desktop/source/splash/splash.hxx @@ -91,6 +91,7 @@ private: Color _cProgressBarColor; bool _bNativeProgress; OUString _sAppName; + OUString _sProgressText; std::vector< FullScreenProgressRatioValue > _sFullScreenProgressRatioValues; sal_Int32 _iMax; -- cgit From e1703d7ac3e485fb7b94787ecdf04a7910bb20c5 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 20 Apr 2010 10:04:52 +0200 Subject: jl152 import 263448 from native0jl:#i77196# XExtensionManager supports XModifyBroadcaster --- .../deployment/manager/dp_extensionmanager.cxx | 66 +++++++++++++++++++--- .../deployment/manager/dp_extensionmanager.hxx | 51 +++++------------ desktop/source/deployment/manager/dp_manager.cxx | 8 +-- 3 files changed, 74 insertions(+), 51 deletions(-) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 15bd9a581611..c4581556749f 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -49,6 +49,7 @@ #include "com/sun/star/beans/Ambiguous.hpp" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/io/XInputStream.hpp" +#include "com/sun/star/util/XModifyBroadcaster.hpp" #include "comphelper/sequence.hxx" #include "xmlscript/xml_helper.hxx" #include "osl/diagnose.h" @@ -60,6 +61,8 @@ #include "dp_extensionmanager.hxx" #include "dp_commandenvironments.hxx" #include "dp_properties.hxx" +#include "boost/bind.hpp" + #include #include #include @@ -71,8 +74,10 @@ namespace task = com::sun::star::task; namespace ucb = com::sun::star::ucb; namespace uno = com::sun::star::uno; namespace beans = com::sun::star::beans; +namespace util = com::sun::star::util; namespace css = com::sun::star; + //#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) using ::com::sun::star::uno::Reference; @@ -121,6 +126,7 @@ namespace dp_manager { //ToDo: bundled extension ExtensionManager::ExtensionManager( Reference< uno::XComponentContext > const& xContext) : + ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager >(getMutex()), m_xContext( xContext ) { Reference xPackageManagerFactory( @@ -433,7 +439,7 @@ Reference ExtensionManager::addExtension( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); Reference xTmpExtension = getTempExtension(url, xAbortChannel, xCmdEnv); const OUString sIdentifier = dp_misc::getIdentifier(xTmpExtension); @@ -529,6 +535,7 @@ Reference ExtensionManager::addExtension( activateExtension( dp_misc::getIdentifier(xNewExtension), xNewExtension->getName(), xAbortChannel, xCmdEnv); + fireModified(); } } catch (deploy::DeploymentException& ) { @@ -573,6 +580,7 @@ Reference ExtensionManager::addExtension( if (xTmpExtension.is() || xExtensionBackup.is()) m_tmpRepository->removePackage( sIdentifier, OUString(), xAbortChannel, xCmdEnv); + fireModified(); } catch (...) { @@ -616,7 +624,7 @@ void ExtensionManager::removeExtension( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); //Backup the extension, in case the user cancels the action xExtensionBackup = backupExtension( identifier, fileName, xPackageManager, xCmdEnv); @@ -630,6 +638,7 @@ void ExtensionManager::removeExtension( xPackageManager->removePackage( identifier, fileName, xAbortChannel, xCmdEnv); activateExtension(identifier, fileName, xAbortChannel, xCmdEnv); + fireModified(); } catch (deploy::DeploymentException& ) { excOccurred1 = ::cppu::getCaughtException(); @@ -670,6 +679,7 @@ void ExtensionManager::removeExtension( m_tmpRepository->removePackage( dp_misc::getIdentifier(xExtensionBackup), xExtensionBackup->getName(), xAbortChannel, xCmdEnv); + fireModified(); } } catch (...) @@ -705,7 +715,7 @@ void ExtensionManager::enableExtension( throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); //if it is already registered or if it cannot be registered //because it does not contain any files which need to be processed @@ -790,7 +800,7 @@ long ExtensionManager::checkPrerequisitesAndEnable( { if (!extension.is()) return 0; - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); sal_Int32 ret = 0; Reference mgr = getPackageManager(extension->getRepositoryName()); @@ -840,7 +850,7 @@ void ExtensionManager::disableExtension( if (!extension.is()) return; - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); OUString repository = extension->getRepositoryName(); if (!repository.equals(OUSTR("user"))) throw lang::IllegalArgumentException( @@ -999,7 +1009,7 @@ void ExtensionManager::reinstallDeployedExtensions( Reference xPackageManager = getPackageManager(repository); - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv); const uno::Sequence< Reference > extensions( xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv)); @@ -1072,7 +1082,7 @@ void ExtensionManager::synchronize( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); dp_misc::ProgressLevel progress( xCmdEnv, OUSTR("Synchronizing ") + repository + OUSTR(" repository\n")); @@ -1235,7 +1245,7 @@ ExtensionManager::getExtensionsWithUnacceptedLicenses( { Reference xPackageManager = getPackageManager(repository); - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); return xPackageManager->getExtensionsWithUnacceptedLicenses(xCmdEnv); } @@ -1273,6 +1283,46 @@ bool singleton_entries( } } +// XModifyBroadcaster +//______________________________________________________________________________ +void ExtensionManager::addModifyListener( + Reference const & xListener ) + throw (uno::RuntimeException) +{ + check(); + rBHelper.addListener( ::getCppuType( &xListener ), xListener ); +} + +//______________________________________________________________________________ +void ExtensionManager::removeModifyListener( + Reference const & xListener ) + throw (uno::RuntimeException) +{ + check(); + rBHelper.removeListener( ::getCppuType( &xListener ), xListener ); +} + +void ExtensionManager::check() +{ + ::osl::MutexGuard guard( getMutex() ); + if (rBHelper.bInDispose || rBHelper.bDisposed) { + throw lang::DisposedException( + OUSTR("ExtensionManager instance has already been disposed!"), + static_cast(this) ); + } +} + +void ExtensionManager::fireModified() +{ + ::cppu::OInterfaceContainerHelper * pContainer = rBHelper.getContainer( + util::XModifyListener::static_type() ); + if (pContainer != 0) { + pContainer->forEach( + boost::bind(&util::XModifyListener::modified, _1, + lang::EventObject(static_cast(this))) ); + } +} + } // namespace dp_manager diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index bafa97c24944..b11a2c64f546 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -35,11 +35,9 @@ #include "dp_activepackages.hxx" #include "rtl/ref.hxx" #include "cppuhelper/compbase1.hxx" -//#include "cppuhelper/implbase2.hxx" #include "ucbhelper/content.hxx" #include "com/sun/star/deployment/XPackageRegistry.hpp" #include "com/sun/star/deployment/XPackageManager.hpp" -//#include #include "osl/mutex.hxx" #include @@ -53,50 +51,31 @@ typedef ::std::hash_map< ::std::vector >, ::rtl::OUStringHash > id2extensions; -class ExtensionManager : - public ::cppu::WeakImplHelper1< css::deployment::XExtensionManager > +class ExtensionManager : private ::dp_misc::MutexHolder, + public ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager > { -private: - ::osl::Mutex m_mutex; - - public: +public: ExtensionManager( css::uno::Reference< css::uno::XComponentContext >const& xContext); virtual ~ExtensionManager(); static css::uno::Sequence< ::rtl::OUString > getServiceNames(); static ::rtl::OUString getImplName(); -// // XInteractionHandler -// virtual void SAL_CALL handle( const uno::Reference< task::XInteractionRequest >& Request ) -// throw( uno::RuntimeException ); -// // XCommandEnvironment -// virtual uno::Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler() -// throw ( uno::RuntimeException ) { return static_cast(this); }; + void check(); + void fireModified(); -// virtual uno::Reference< css_ucb::XProgressHandler > SAL_CALL getProgressHandler() -// throw ( uno::RuntimeException ) { return uno::Reference< css_ucb::XProgressHandler >(); }; public: - // XComponent - //virtual void SAL_CALL dispose() throw (css::uno::RuntimeException); - //virtual void SAL_CALL addEventListener( - // css::uno::Reference const & xListener ) - // throw (css::uno::RuntimeException); - //virtual void SAL_CALL removeEventListener( - // css::uno::Reference const & xListener ) - // throw (css::uno::RuntimeException); - // - //// XModifyBroadcaster - //virtual void SAL_CALL addModifyListener( - // css::uno::Reference const & xListener ) - // throw (css::uno::RuntimeException); - //virtual void SAL_CALL removeModifyListener( - // css::uno::Reference const & xListener ) - // throw (css::uno::RuntimeException); - - // XPackageManager -// virtual ::rtl::OUString SAL_CALL getContext() -// throw (css::uno::RuntimeException); + +// XModifyBroadcaster + virtual void SAL_CALL addModifyListener( + css::uno::Reference const & xListener ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL removeModifyListener( + css::uno::Reference const & xListener ) + throw (css::uno::RuntimeException); + +//XExtensionManager virtual css::uno::Sequence< css::uno::Reference > SAL_CALL getSupportedPackageTypes(::rtl::OUString const & repository) diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 0464d0de62d5..8c55f2508680 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -827,13 +827,7 @@ Reference PackageManagerImpl::addPackage( try { OUString const id = dp_misc::getIdentifier( xPackage ); - //This guard is used to prevent that an extension is - //installed twice. Do not use it in other functions. - //Imagine addPackage is called two times by different - //threads for the same extension quickly after each other. - //The second call would calculate "bAlreadyInstalled = - //false" if the first thread has not yet reached - //insertToActivationLayerDB. + ::osl::MutexGuard g(m_addMutex); if (isInstalled(xPackage)) { -- cgit From c2d9d80b487dd0d7353b22eee44bee3b84fc7838 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Wed, 21 Apr 2010 16:04:34 +0200 Subject: jl152 import 263449 from native0jl:#i77196# no registration of components in uno.exe at startup, fixed extension activation, basic, etc. --- basic/source/inc/namecont.hxx | 11 ++ basic/source/uno/namecont.cxx | 90 ++++++++- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 2 +- .../deployment/manager/dp_extensionmanager.cxx | 207 +++++++++------------ .../deployment/manager/dp_extensionmanager.hxx | 21 ++- desktop/source/deployment/manager/dp_manager.hrc | 2 +- desktop/source/deployment/manager/dp_manager.src | 4 + .../deployment/registry/component/dp_component.cxx | 39 ++-- .../registry/configuration/dp_configuration.cxx | 2 + desktop/source/deployment/registry/dp_backend.cxx | 7 +- .../registry/executable/dp_executable.cxx | 2 + .../source/deployment/registry/help/dp_help.cxx | 2 + .../source/deployment/registry/inc/dp_backend.h | 3 + .../deployment/registry/package/dp_package.cxx | 4 +- .../deployment/registry/script/dp_script.cxx | 2 + .../source/deployment/registry/sfwk/dp_sfwk.cxx | 2 + .../migration/services/extensionmigration.cxx | 6 +- .../migration/services/oo3extensionmigration.cxx | 2 +- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 7 +- svx/source/smarttags/SmartTagMgr.cxx | 11 +- 20 files changed, 253 insertions(+), 173 deletions(-) diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 1f7e77170d44..2d24759d9b83 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -689,6 +689,7 @@ enum IteratorState { USER_EXTENSIONS, SHARED_EXTENSIONS, + BUNDLED_EXTENSIONS, END_REACHED }; @@ -708,6 +709,8 @@ protected: implGetNextUserScriptPackage( bool& rbPureDialogLib ); com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextSharedScriptPackage( bool& rbPureDialogLib ); + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > + implGetNextBundledScriptPackage( bool& rbPureDialogLib ); com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; @@ -721,8 +724,16 @@ protected: < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; bool m_bSharedPackagesLoaded; + com::sun::star::uno::Sequence< com::sun::star::uno::Reference + < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; + bool m_bBundledPackagesLoaded; + + int m_iUserPackage; int m_iSharedPackage; + int m_iBundledPackage; + + ScriptSubPackageIterator* m_pScriptSubPackageIterator; diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index 14c84420dad6..7a6a771f85cc 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -65,7 +65,7 @@ #include #include #include -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include #ifndef _RTL_USTRING_HXX_ #include @@ -1080,6 +1080,7 @@ sal_Bool SfxLibraryContainer::init_Impl( OUString aUserSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE" ); OUString aSharedSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE" ); + OUString aBundledSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$BUNDLED_EXTENSIONS" ); OUString aInstSearchStr = OUString::createFromAscii( "$(INST)" ); Sequence< OUString > aNames = pPrevCont->getElementNames(); @@ -1111,6 +1112,7 @@ sal_Bool SfxLibraryContainer::init_Impl( bool bCreateLink = true; if( aStorageURL.indexOf( aUserSearchStr ) != -1 || aStorageURL.indexOf( aSharedSearchStr ) != -1 || + aStorageURL.indexOf( aBundledSearchStr ) != -1 || aStorageURL.indexOf( aInstSearchStr ) != -1 ) { bCreateLink = false; @@ -2182,11 +2184,12 @@ Reference< XNameAccess > SAL_CALL SfxLibraryContainer::createLibraryLink OUString aUserSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE" ); OUString aSharedSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE" ); + OUString aBundledSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$BUNDLED_EXTENSIONS" ); if( StorageURL.indexOf( aUserSearchStr ) != -1 ) { pNewLib->mbExtension = sal_True; } - else if( StorageURL.indexOf( aSharedSearchStr ) != -1 ) + else if( StorageURL.indexOf( aSharedSearchStr ) != -1 || StorageURL.indexOf( aBundledSearchStr ) != -1 ) { pNewLib->mbExtension = sal_True; pNewLib->mbReadOnly = sal_True; @@ -3075,8 +3078,10 @@ ScriptExtensionIterator::ScriptExtensionIterator( void ) : m_eState( USER_EXTENSIONS ) , m_bUserPackagesLoaded( false ) , m_bSharedPackagesLoaded( false ) + , m_bBundledPackagesLoaded( false ) , m_iUserPackage( 0 ) , m_iSharedPackage( 0 ) + , m_iBundledPackage( 0 ) , m_pScriptSubPackageIterator( NULL ) { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); @@ -3125,6 +3130,16 @@ rtl::OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& rbPureDia aRetLib = xScriptPackage->getURL(); break; } + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xScriptPackage = + implGetNextBundledScriptPackage( rbPureDialogLib ); + if( !xScriptPackage.is() ) + break; + + aRetLib = xScriptPackage->getURL(); + break; + } case END_REACHED: VOS_ENSURE( false, "ScriptExtensionIterator::nextBasicOrDialogLibrary(): Invalid case END_REACHED" ); break; @@ -3295,10 +3310,11 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextUserScript { try { - Reference< XPackageManager > xUserManager = - thePackageManagerFactory::get( m_xContext )->getPackageManager( rtl::OUString::createFromAscii("user") ); - m_aUserPackagesSeq = xUserManager->getDeployedPackages - ( Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); + Reference< XExtensionManager > xManager = + ExtensionManager::get( m_xContext ); + m_aUserPackagesSeq = xManager->getDeployedExtensions + (rtl::OUString::createFromAscii("user"), + Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); } catch( com::sun::star::uno::DeploymentException& ) { @@ -3348,10 +3364,11 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScri { try { - Reference< XPackageManager > xSharedManager = - thePackageManagerFactory::get( m_xContext )->getPackageManager( rtl::OUString::createFromAscii("shared") ); - m_aSharedPackagesSeq = xSharedManager->getDeployedPackages - ( Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); + Reference< XExtensionManager > xSharedManager = + ExtensionManager::get( m_xContext ); + m_aSharedPackagesSeq = xSharedManager->getDeployedExtensions + (rtl::OUString::createFromAscii("shared"), + Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); } catch( com::sun::star::uno::DeploymentException& ) { @@ -3391,4 +3408,57 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScri return xScriptPackage; } +Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextBundledScriptPackage + ( bool& rbPureDialogLib ) +{ + Reference< deployment::XPackage > xScriptPackage; + + if( !m_bBundledPackagesLoaded ) + { + try + { + Reference< XExtensionManager > xManager = + ExtensionManager::get( m_xContext ); + m_aBundledPackagesSeq = xManager->getDeployedExtensions + (rtl::OUString::createFromAscii("bundled"), + Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); + } + catch( com::sun::star::uno::DeploymentException& ) + { + // Special Office installations may not contain deployment code + return xScriptPackage; + } + + m_bBundledPackagesLoaded = true; + } + + if( m_iBundledPackage == m_aBundledPackagesSeq.getLength() ) + { + m_eState = END_REACHED; + } + else + { + if( m_pScriptSubPackageIterator == NULL ) + { + const Reference< deployment::XPackage >* pBundledPackages = m_aBundledPackagesSeq.getConstArray(); + Reference< deployment::XPackage > xPackage = pBundledPackages[ m_iBundledPackage ]; + VOS_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextBundledScriptPackage(): Invalid package" ); + m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage ); + } + + if( m_pScriptSubPackageIterator != NULL ) + { + xScriptPackage = m_pScriptSubPackageIterator->getNextScriptSubPackage( rbPureDialogLib ); + if( !xScriptPackage.is() ) + { + delete m_pScriptSubPackageIterator; + m_pScriptSubPackageIterator = NULL; + m_iBundledPackage++; + } + } + } + + return xScriptPackage; +} + } // namespace basic diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 4b55a93d3f84..647c46b754c8 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -1048,7 +1048,7 @@ void ExtensionCmdQueue::Thread::_enableExtension( ::rtl::Reference< ProgressCmdE try { - xPackage->registerPackage( xAbortChannel, rCmdEnv.get() ); + xPackage->registerPackage(false, xAbortChannel, rCmdEnv.get() ); if ( m_pDialogHelper ) m_pDialogHelper->updatePackageInfo( xPackage ); } diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index c4581556749f..bbe476e57fba 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -260,48 +260,38 @@ void ExtensionManager::addExtensionsToMap( } -/* -*/ -Reference ExtensionManager::getExtensionAndStatus( - ::rtl::OUString const & identifier, - ::rtl::OUString const & fileName, - ::rtl::OUString const & repository, - Reference const & xAbortChannel, - Reference const & xCmdEnv, - bool & out_bWasRegistered) +bool ExtensionManager::isUserDisabled( + OUString const & identifier, OUString const & fileName) { - Reference theExtension; ::std::list > listExtensions = - getExtensionsWithSameId(identifier, fileName); - OSL_ASSERT(listExtensions.size() == m_repositoryNames.size()); - Reference xActiveExtension; - ::std::list::const_iterator - inames = m_repositoryNames.begin(); - ::std::list >::const_iterator - iext = listExtensions.begin(); - for (; inames != m_repositoryNames.end(); inames++, iext++) + getExtensionsWithSameId(identifier, fileName); + OSL_ASSERT(listExtensions.size() == 3); + + return isUserDisabled( ::comphelper::containerToSequence< + Reference, + ::std::list > + > (listExtensions)); +} + +bool ExtensionManager::isUserDisabled( + uno::Sequence > const & seqExtSameId) +{ + OSL_ASSERT(seqExtSameId.getLength() == 3); + Reference const & userExtension = seqExtSameId[0]; + if (userExtension.is()) { - if (repository.equals(*inames)) - { - theExtension = *iext; - if (iext->is()) - { - beans::Optional > optRegistered = - (*iext)->isRegistered(xAbortChannel, xCmdEnv); - OSL_ENSURE(! optRegistered.Value.IsAmbiguous, - "Extension is not properly registered"); - //IsAmbiguous = true: only partly registered, but we assume - //that this is the active extension, and something went wrong when registering it - //previously. - if (optRegistered.IsPresent - && (optRegistered.Value.Value || optRegistered.Value.IsAmbiguous)) - out_bWasRegistered = true; - } - break; - } + beans::Optional > reg = + userExtension->isRegistered(Reference(), + Reference()); + //If the value is ambiguous is than we assume that the extension + //is enabled, but something went wrong during enabling. We do not + //automatically disable user extensions. + if (reg.IsPresent && + ! reg.Value.IsAmbiguous && ! reg.Value.Value) + return true; } - return theExtension; + return false; } /* @@ -321,6 +311,8 @@ Reference ExtensionManager::getExtensionAndStatus( */ void ExtensionManager::activateExtension( OUString const & identifier, OUString const & fileName, + bool bUserDisabled, + bool bStartup, Reference const & xAbortChannel, Reference const & xCmdEnv ) { @@ -333,11 +325,13 @@ void ExtensionManager::activateExtension( Reference, ::std::list > > (listExtensions), - xAbortChannel, xCmdEnv); + bUserDisabled, bStartup, xAbortChannel, xCmdEnv); } void ExtensionManager::activateExtension( uno::Sequence > const & seqExt, + bool bUserDisabled, + bool bStartup, Reference const & xAbortChannel, Reference const & xCmdEnv ) { @@ -355,9 +349,12 @@ void ExtensionManager::activateExtension( if (!optReg.IsPresent) break; - //Check if this is a disabled user extension, if so then skip - if (!optReg.Value.Value && i == 0) //e.g. not registered - continue; + //Check if this is a disabled user extension, + if (i == 0 && bUserDisabled) + { + aExt->revokePackage(xAbortChannel, xCmdEnv); + continue; + } //If we have already determined an active extension then we must //make sure to unregister all extensions with the same id in @@ -374,7 +371,7 @@ void ExtensionManager::activateExtension( //Register if not already done. //reregister if the value is ambiguous, which indicates that //something went wrong during last registration. - aExt->registerPackage(xAbortChannel, xCmdEnv); + aExt->registerPackage(bStartup, xAbortChannel, xCmdEnv); } } } @@ -455,17 +452,18 @@ Reference ExtensionManager::addExtension( uno::Any excOccurred1; uno::Any excOccurred2; - + bool bUserDisabled = false; try { - //If we add a user extension and there is already one which was - //disabled by a user, then the newly installed one is enabled. If we - //add to another repository then the user extension remains - //disabled. - bool bWasRegistered = false; - xOldExtension = getExtensionAndStatus( - sIdentifier, sFileName, repository, xAbortChannel, - xCmdEnv, bWasRegistered); + bUserDisabled = isUserDisabled(sIdentifier, sFileName); + try + { + xOldExtension = xPackageManager->getDeployedPackage( + sIdentifier, sFileName, xCmdEnv); + } + catch (lang::IllegalArgumentException &) + { + } bool bCanInstall = false; try { @@ -514,8 +512,7 @@ Reference ExtensionManager::addExtension( { if (xOldExtension.is()) { - if (bWasRegistered) - xOldExtension->revokePackage(xAbortChannel, xCmdEnv); + xOldExtension->revokePackage(xAbortChannel, xCmdEnv); //save the old user extension in case the user aborts //store the extension in the tmp repository, this will overwrite //xTmpPackage (same identifier). Do not let the user abort or @@ -532,9 +529,17 @@ Reference ExtensionManager::addExtension( xNewExtension = xPackageManager->addPackage( url, properties, OUString(), xAbortChannel, xCmdEnv); + + //If we add a user extension and there is already one which was + //disabled by a user, then the newly installed one is enabled. If we + //add to another repository then the user extension remains + //disabled. + bool bUserDisabled2 = bUserDisabled; + if (repository.equals(OUSTR("user"))) + bUserDisabled2 = false; activateExtension( dp_misc::getIdentifier(xNewExtension), - xNewExtension->getName(), xAbortChannel, xCmdEnv); + xNewExtension->getName(), bUserDisabled2, false, xAbortChannel, xCmdEnv); fireModified(); } } @@ -575,7 +580,7 @@ Reference ExtensionManager::addExtension( tmpCmdEnv); } activateExtension( - sIdentifier, sFileName, + sIdentifier, sFileName, bUserDisabled, false, Reference(), tmpCmdEnv); if (xTmpExtension.is() || xExtensionBackup.is()) m_tmpRepository->removePackage( @@ -611,7 +616,8 @@ void ExtensionManager::removeExtension( uno::Any excOccurred1; Reference xExtensionBackup; Reference xPackageManager; - + bool bUserDisabled = false; + ::osl::MutexGuard guard(getMutex()); try { //Determine the repository to use @@ -624,7 +630,7 @@ void ExtensionManager::removeExtension( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(getMutex()); + bUserDisabled = isUserDisabled(identifier, fileName); //Backup the extension, in case the user cancels the action xExtensionBackup = backupExtension( identifier, fileName, xPackageManager, xCmdEnv); @@ -637,7 +643,8 @@ void ExtensionManager::removeExtension( xPackageManager->removePackage( identifier, fileName, xAbortChannel, xCmdEnv); - activateExtension(identifier, fileName, xAbortChannel, xCmdEnv); + activateExtension(identifier, fileName, bUserDisabled, false, + xAbortChannel, xCmdEnv); fireModified(); } catch (deploy::DeploymentException& ) { @@ -673,7 +680,8 @@ void ExtensionManager::removeExtension( xExtensionBackup, Reference(), tmpCmdEnv); activateExtension( - identifier, fileName, Reference(), + identifier, fileName, bUserDisabled, false, + Reference(), tmpCmdEnv); m_tmpRepository->removePackage( @@ -705,49 +713,24 @@ void ExtensionManager::enableExtension( lang::IllegalArgumentException, uno::RuntimeException) { + ::osl::MutexGuard guard(getMutex()); + bool bUserDisabled = false; + uno::Any excOccurred; try { if (!extension.is()) return; - OUString repository = extension->getRepositoryName(); if (!repository.equals(OUSTR("user"))) throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(getMutex()); - //if it is already registered or if it cannot be registered - //because it does not contain any files which need to be processed - //then there is nothing to do here - beans::Optional > reg = - extension->isRegistered(xAbortChannel, xCmdEnv); - if (!reg.IsPresent - || (!reg.Value.IsAmbiguous && reg.Value.Value)) - return; - } - catch (deploy::DeploymentException& ) { - throw; - } catch (ucb::CommandFailedException & ) { - throw; - } catch (ucb::CommandAbortedException & ) { - throw; - } catch (lang::IllegalArgumentException &) { - throw; - } catch (uno::RuntimeException &) { - throw; - } catch (...) { - uno::Any exc = ::cppu::getCaughtException(); - throw deploy::DeploymentException( - OUSTR("Extension Manager: exception during enableExtension"), - static_cast(this), exc); - } + bUserDisabled = isUserDisabled(dp_misc::getIdentifier(extension), + extension->getName()); - uno::Any excOccurred; - try - { activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), + extension->getName(), false, false, xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { @@ -772,9 +755,8 @@ void ExtensionManager::enableExtension( { try { - extension->revokePackage(Reference(), xCmdEnv); activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), + extension->getName(), bUserDisabled, false, xAbortChannel, xCmdEnv); } catch (...) @@ -810,8 +792,10 @@ long ExtensionManager::checkPrerequisitesAndEnable( //There are some unfulfilled prerequisites, try to revoke extension->revokePackage(xAbortChannel, xCmdEnv); } - activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), xAbortChannel, xCmdEnv); + const OUString id(dp_misc::getIdentifier(extension)); + activateExtension(id, extension->getName(), + isUserDisabled(id, extension->getName()), false, + xAbortChannel, xCmdEnv); return ret; } catch (deploy::DeploymentException& ) { @@ -844,31 +828,23 @@ void ExtensionManager::disableExtension( lang::IllegalArgumentException, uno::RuntimeException) { + ::osl::MutexGuard guard(getMutex()); uno::Any excOccurred; + bool bUserDisabled = false; try { if (!extension.is()) return; - - ::osl::MutexGuard guard(getMutex()); - OUString repository = extension->getRepositoryName(); + const OUString repository( extension->getRepositoryName()); if (!repository.equals(OUSTR("user"))) throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), static_cast(this), 0); - //if it is already registered or if it cannot be registered - //because it does not contain any files which need to be processed - //then there is nothing to do here - beans::Optional > reg = - extension->isRegistered(xAbortChannel, xCmdEnv); - if (!reg.IsPresent - || (!reg.Value.IsAmbiguous && !reg.Value.Value)) - return; + const OUString id(dp_misc::getIdentifier(extension)); + bUserDisabled = isUserDisabled(id, extension->getName()); - extension->revokePackage(xAbortChannel, xCmdEnv); - activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), + activateExtension(id, extension->getName(), true, false, xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { @@ -894,7 +870,7 @@ void ExtensionManager::disableExtension( try { activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), + extension->getName(), bUserDisabled, false, xAbortChannel, xCmdEnv); } catch (...) @@ -1021,7 +997,7 @@ void ExtensionManager::reinstallDeployedExtensions( const OUString id = dp_misc::getIdentifier(extensions[ pos ]); const OUString fileName = extensions[ pos ]->getName(); OSL_ASSERT(id.getLength()); - activateExtension(id, fileName, xAbortChannel, xCmdEnv ); + activateExtension(id, fileName, false, false, xAbortChannel, xCmdEnv ); } catch (lang::DisposedException &) { @@ -1083,12 +1059,11 @@ void ExtensionManager::synchronize( static_cast(this), 0); ::osl::MutexGuard guard(getMutex()); + String sSynchronizing(StrSyncRepository::get()); + sSynchronizing.SearchAndReplaceAllAscii( "%NAME", repository ); + dp_misc::ProgressLevel progress(xCmdEnv, sSynchronizing); - dp_misc::ProgressLevel progress( - xCmdEnv, OUSTR("Synchronizing ") + repository + OUSTR(" repository\n")); xPackageManager->synchronize(xAbortChannel, xCmdEnv); - - try { const uno::Sequence > > @@ -1097,8 +1072,8 @@ void ExtensionManager::synchronize( { uno::Sequence > const & seqExt = seqSeqExt[i]; - - activateExtension(seqExt, xAbortChannel, xCmdEnv); + activateExtension(seqExt, isUserDisabled(seqExt), true, + xAbortChannel, xCmdEnv); } } catch (...) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index b11a2c64f546..10bf3713c410 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -204,6 +204,9 @@ public: private: + struct StrSyncRepository : public ::dp_misc::StaticResourceString< + StrSyncRepository, RID_STR_SYNCHRONIZING_REPOSITORY> {}; + struct ExtensionInfos { ::rtl::OUString identifier; @@ -225,24 +228,24 @@ private: */ ::std::list< ::rtl::OUString > m_repositoryNames; - css::uno::Reference getExtensionAndStatus( - ::rtl::OUString const & identifier, - ::rtl::OUString const & fileName, - ::rtl::OUString const & repository, - css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv, - bool & out_bWasRegistered); + bool isUserDisabled(::rtl::OUString const & identifier, + ::rtl::OUString const & filename); + + bool ExtensionManager::isUserDisabled( + css::uno::Sequence > const & seqExtSameId); void activateExtension( ::rtl::OUString const & identifier, ::rtl::OUString const & fileName, + bool bUserDisabled, bool bStartup, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); void activateExtension( css::uno::Sequence > const & seqExt, - css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv ); + bool bUserDisabled, bool bStartup, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ); ::std::list > diff --git a/desktop/source/deployment/manager/dp_manager.hrc b/desktop/source/deployment/manager/dp_manager.hrc index bdbfc079cda6..6131cc381abf 100644 --- a/desktop/source/deployment/manager/dp_manager.hrc +++ b/desktop/source/deployment/manager/dp_manager.hrc @@ -35,5 +35,5 @@ #define RID_STR_PACKAGE_ALREADY_ADDED (RID_DEPLOYMENT_MANAGER_START+2) #define RID_STR_COPYING_PACKAGE (RID_DEPLOYMENT_MANAGER_START+3) #define RID_STR_NO_SUCH_PACKAGE (RID_DEPLOYMENT_MANAGER_START+4) - +#define RID_STR_SYNCHRONIZING_REPOSITORY (RID_DEPLOYMENT_MANAGER_START+5) #endif diff --git a/desktop/source/deployment/manager/dp_manager.src b/desktop/source/deployment/manager/dp_manager.src index 95ede4aa6227..7d38b880c37a 100644 --- a/desktop/source/deployment/manager/dp_manager.src +++ b/desktop/source/deployment/manager/dp_manager.src @@ -53,3 +53,7 @@ String RID_STR_NO_SUCH_PACKAGE Text [ en-US ] = "There is no such extension deployed: "; }; +String RID_STR_SYNCHRONIZING_REPOSITORY +{ + Text [ en-US ] = "Synchronizing repository for %NAME extensions"; +}; diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index 17444eb0828e..b3b8a8249994 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -122,7 +122,6 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend BackendImpl * getMyBackend() const; const OUString m_loader; - Reference m_xRemoteContext; ComponentBackendDb::Data m_registeredComponentsDb; enum reg { @@ -143,6 +142,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -179,6 +179,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -356,7 +357,7 @@ BackendImpl * BackendImpl::ComponentPackageImpl::getMyBackend() const //______________________________________________________________________________ void BackendImpl::ComponentPackageImpl::disposing() { - m_xRemoteContext.clear(); +// m_xRemoteContext.clear(); Package::disposing(); } @@ -1224,6 +1225,7 @@ BackendImpl::ComponentPackageImpl::isRegistered_( void BackendImpl::ComponentPackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ) { @@ -1244,11 +1246,14 @@ void BackendImpl::ComponentPackageImpl::processPackage_( data.javaTypeLibrary = isJavaTypelib; if (doRegisterPackage) { - if (! m_xRemoteContext.is()) { - m_xRemoteContext.set( + Reference context(that->getComponentContext()); + if (! startup) + { + context.set( that->getObject( url ), UNO_QUERY ); - if (! m_xRemoteContext.is()) { - m_xRemoteContext.set( + + if (! context.is()) { + context.set( that->insertObject( url, raise_uno_process( that->getComponentContext(), abortChannel ) ), @@ -1258,9 +1263,9 @@ void BackendImpl::ComponentPackageImpl::processPackage_( const Reference xServicesRDB( getRDB() ); const Reference xImplReg( - m_xRemoteContext->getServiceManager()->createInstanceWithContext( + context->getServiceManager()->createInstanceWithContext( OUSTR("com.sun.star.registry.ImplementationRegistration"), - m_xRemoteContext ), UNO_QUERY_THROW ); + context ), UNO_QUERY_THROW ); xImplReg->registerImplementation( m_loader, url, xServicesRDB ); //only write to unorc if registration was successful. @@ -1274,7 +1279,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_( t_stringlist implNames; t_stringpairvec singletons; const Reference xLoader( - getComponentInfo( &implNames, &singletons, m_xRemoteContext ) ); + getComponentInfo( &implNames, &singletons, context ) ); data.implementationNames = implNames; data.singletons = singletons; @@ -1348,11 +1353,14 @@ void BackendImpl::ComponentPackageImpl::processPackage_( // set to VOID during revocation process: m_registered = REG_VOID; - Reference xContext; - if (m_xRemoteContext.is()) // has been activated in this process - xContext = m_xRemoteContext; - else // has been deployed in former times + //get the remote context. If it does not exist then use the local one + Reference xContext( + that->getObject( url ), UNO_QUERY ); + bool bRemoteContext = false; + if (!xContext.is()) xContext = that->getComponentContext(); + else + bRemoteContext = true; t_stringlist implNames; t_stringpairvec singletons; @@ -1427,10 +1435,8 @@ void BackendImpl::ComponentPackageImpl::processPackage_( if (isJavaTypelib) that->removeFromUnoRc( java, url, xCmdEnv ); - if (m_xRemoteContext.is()) { + if (bRemoteContext) that->releaseObject( url ); - m_xRemoteContext.clear(); - } m_registered = REG_NOT_REGISTERED; getMyBackend()->deleteDataFromDb(url); @@ -1483,6 +1489,7 @@ BackendImpl::TypelibraryPackageImpl::isRegistered_( void BackendImpl::TypelibraryPackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool startup, ::rtl::Reference const &, Reference const & xCmdEnv ) { diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index fefa6794342a..941b9a35d7f5 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -86,6 +86,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -644,6 +645,7 @@ OUString replaceOrigin( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /*startup*/, ::rtl::Reference const &, Reference const & xCmdEnv ) { diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 1cebd20c297a..e822a66aa85f 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -619,6 +619,7 @@ beans::Optional< beans::Ambiguous > Package::isRegistered( //______________________________________________________________________________ void Package::processPackage_impl( bool doRegisterPackage, + bool startup, Reference const & xAbortChannel, Reference const & xCmdEnv ) { @@ -646,6 +647,7 @@ void Package::processPackage_impl( + displayName ); processPackage_( guard, doRegisterPackage, + startup, AbortChannel::get(xAbortChannel), xCmdEnv ); } @@ -683,6 +685,7 @@ void Package::processPackage_impl( //______________________________________________________________________________ void Package::registerPackage( + sal_Bool startup, Reference const & xAbortChannel, Reference const & xCmdEnv ) throw (deployment::DeploymentException, @@ -692,7 +695,7 @@ void Package::registerPackage( { if (m_bRemoved) throw deployment::ExtensionRemovedException(); - processPackage_impl( true /* register */, xAbortChannel, xCmdEnv ); + processPackage_impl( true /* register */, startup, xAbortChannel, xCmdEnv ); } //______________________________________________________________________________ @@ -703,7 +706,7 @@ void Package::revokePackage( CommandFailedException, CommandAbortedException, lang::IllegalArgumentException, RuntimeException) { - processPackage_impl( false /* revoke */, xAbortChannel, xCmdEnv ); + processPackage_impl( false /* revoke */, false, xAbortChannel, xCmdEnv ); } diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index 1dc4cdde64ea..ac83302f9fb4 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -62,6 +62,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -202,6 +203,7 @@ BackendImpl::ExecutablePackageImpl::isRegistered_( void BackendImpl::ExecutablePackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /*startup*/, ::rtl::Reference const & abortChannel, Reference const & /*xCmdEnv*/ ) { diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index a523a1aa20a5..7e8f128bbf12 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -76,6 +76,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -278,6 +279,7 @@ BackendImpl::PackageImpl::isRegistered_( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /* startup */, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ) { diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 7ad55d29ba2f..7b11ae456d5d 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -67,6 +67,7 @@ class Package : protected ::dp_misc::MutexHolder, public t_PackageBase PackageRegistryBackend * getMyBackend() const; void processPackage_impl( bool registerPackage, + bool startup, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ); @@ -97,6 +98,7 @@ protected: virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference< ::dp_misc::AbortChannel > const & abortChannel, css::uno::Reference const & xCmdEnv ) = 0; @@ -193,6 +195,7 @@ public: css::uno::RuntimeException); virtual void SAL_CALL registerPackage( + sal_Bool startup, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 822e744b8fc2..a5426bf26b54 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -159,6 +159,7 @@ class BackendImpl : public ImplBaseT virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -847,6 +848,7 @@ uno::Reference< graphic::XGraphic > BackendImpl::PackageImpl::getIcon( sal_Bool void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ) { @@ -865,7 +867,7 @@ void BackendImpl::PackageImpl::processPackage_( xPackage->createAbortChannel() ); AbortChannel::Chain chain( abortChannel, xSubAbortChannel ); try { - xPackage->registerPackage( xSubAbortChannel, xCmdEnv ); + xPackage->registerPackage( startup, xSubAbortChannel, xCmdEnv ); } catch (RuntimeException &) { throw; diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 5023a501c67e..b2eddfaf74e0 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -80,6 +80,7 @@ class BackendImpl : public t_helper virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -379,6 +380,7 @@ BackendImpl::PackageImpl::isRegistered_( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /* startup */, ::rtl::Reference const &, Reference const & xCmdEnv ) { diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index 704f4f810928..8a4ee1b45fbc 100644 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -77,6 +77,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -371,6 +372,7 @@ BackendImpl::PackageImpl::isRegistered_( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /* startup */, ::rtl::Reference const &, Reference const & ) { diff --git a/desktop/source/migration/services/extensionmigration.cxx b/desktop/source/migration/services/extensionmigration.cxx index a926f17c0c19..66f32744a782 100755 --- a/desktop/source/migration/services/extensionmigration.cxx +++ b/desktop/source/migration/services/extensionmigration.cxx @@ -236,7 +236,7 @@ namespace migration if ( (sMediaType.equals(sBasicType) || sMediaType.equals(sDialogType)) && isBasicPackageEnabled(xPkg)) { - xPkg->registerPackage(uno::Reference< task::XAbortChannel >(), + xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); } } @@ -288,7 +288,7 @@ namespace migration if ( bRegistered && !sMediaType.equals(sBasicType) && !sMediaType.equals(sDialogType) ) { seqPkg[l]->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - seqPkg[l]->registerPackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); + seqPkg[l]->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); } } } @@ -297,7 +297,7 @@ namespace migration registerBasicPackage(aPackage); { aPackage->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - aPackage->registerPackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); + aPackage->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); } } } diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index a077eaddb911..2d17a654b29b 100755 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -146,7 +146,7 @@ void OO3ExtensionMigration::registerConfigurationPackage( const uno::Reference< if ( (sMediaType.equals(sConfigurationDataType) || sMediaType.equals(sConfigurationSchemaType) ) ) { xPkg->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - xPkg->registerPackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); + xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); } } diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index ba8cd56085f8..2f4a7f1d7146 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -400,12 +400,7 @@ extern "C" int unopkg_main() Reference p( findPackage(repository, xExtensionManager, xCmdEnv, cmdPackage ) ); - //Todo. temporary preventing exception in bundled case. - //In case of a bundled extension, remove would be called as a result of - //uninstalling a rpm. Then we do not want to show an error when the - //extension does not exist, because the package will be uninstalled anyway - //and the error would only confuse people. - if ( !p.is() && !option_bundled) + if ( !p.is()) throw; else if (p.is()) xExtensionManager->removeExtension( diff --git a/svx/source/smarttags/SmartTagMgr.cxx b/svx/source/smarttags/SmartTagMgr.cxx index b3a19ecc65bd..0070646b3330 100644 --- a/svx/source/smarttags/SmartTagMgr.cxx +++ b/svx/source/smarttags/SmartTagMgr.cxx @@ -35,8 +35,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -472,11 +471,9 @@ void SmartTagMgr::RegisterListener() // register as listener at package manager try { - Reference xPackageManagerFactory( - deployment::thePackageManagerFactory::get( mxContext ) ); - Reference xPackageManager( - xPackageManagerFactory->getPackageManager( C2U("user" ) ) ); - Reference< util::XModifyBroadcaster > xMB ( xPackageManager, UNO_QUERY_THROW ); + Reference xExtensionManager( + deployment::ExtensionManager::get( mxContext ) ); + Reference< util::XModifyBroadcaster > xMB ( xExtensionManager, UNO_QUERY_THROW ); Reference< util::XModifyListener > xListener( this ); xMB->addModifyListener( xListener ); -- cgit From e0986b3290e9c73116d86f9ae3b8e35f94aadc2b Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 22 Apr 2010 12:51:04 +0200 Subject: tl78: #i110383# password to modify support --- sfx2/inc/sfx2/docfile.hxx | 2 + sfx2/inc/sfx2/objsh.hxx | 3 + sfx2/source/dialog/filedlghelper.cxx | 63 +------- sfx2/source/doc/docfile.cxx | 50 ++++++ sfx2/source/doc/objcont.cxx | 10 ++ sfx2/source/doc/objmisc.cxx | 29 ++++ sfx2/source/doc/objxtor.cxx | 1 + sfx2/source/inc/objshimp.hxx | 2 +- sfx2/source/view/viewfrm.cxx | 286 +++++++++++++++++++++-------------- uui/source/iahndl-authentication.cxx | 21 ++- uui/source/loginerr.hxx | 142 +++++++++-------- 11 files changed, 361 insertions(+), 248 deletions(-) diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index 03bcfec5818f..01494f751773 100644 --- a/sfx2/inc/sfx2/docfile.hxx +++ b/sfx2/inc/sfx2/docfile.hxx @@ -166,6 +166,7 @@ public: const SfxFilter * GetFilter() const { return pFilter; } const SfxFilter * GetOrigFilter( sal_Bool bNotCurrent = sal_False ) const; const String& GetOrigURL() const; + SfxItemSet * GetItemSet() const; void SetItemSet(SfxItemSet *pSet); void Close(); @@ -342,6 +343,7 @@ public: static sal_Bool CallApproveHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler, ::com::sun::star::uno::Any aRequest, sal_Bool bAllowAbort ); static sal_Bool SetWritableForUserOnly( const ::rtl::OUString& aURL ); + static sal_uInt16 CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bMSType ); }; SV_DECL_IMPL_REF( SfxMedium ) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 99161cb5b36c..e932f0f87477 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -294,6 +294,7 @@ public: sal_Bool HasName() const { return bHasName; } virtual String GetAPIName() const; void SetHasName( sal_Bool bSet = sal_True ) { bHasName = bSet; } + void SetReadOnly(); sal_Bool IsReadOnly() const; sal_Bool IsReadOnlyMedium() const; void SetReadOnlyUI( sal_Bool bReadOnly = sal_True ); @@ -736,6 +737,8 @@ public: SAL_DLLPRIVATE sal_uInt16 ImplCheckSignaturesInformation( const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >& aInfos ); SAL_DLLPRIVATE void CheckEncryption_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); + SAL_DLLPRIVATE void SetModifyPasswordEntered(); + SAL_DLLPRIVATE sal_Bool IsModifyPasswordEntered(); SAL_DLLPRIVATE SEQUENCE< OUSTRING > GetEventNames_Impl(); SAL_DLLPRIVATE void InitBasicManager_Impl(); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index c1b9aaf7838d..d7109496d670 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -80,7 +80,6 @@ #include #include #include -#include #include #include #include @@ -465,22 +464,6 @@ sal_Bool FileDialogHelper_Impl::isInOpenMode() const // ------------------------------------------------------------------------ -namespace { - -sal_Bool lclCheckPasswordCapability( const SfxFilter* pFilter ) -{ - return pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_ENCRYPTION ); -} - -sal_Bool lclCheckPasswordToModifyCapability( const SfxFilter* pFilter ) -{ - return pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ); -} - -} - -// ------------------------------------------------------------------------ - void FileDialogHelper_Impl::updateFilterOptionsBox() { if ( !m_bHaveFilterOptions ) @@ -571,9 +554,10 @@ void FileDialogHelper_Impl::enablePasswordBox( sal_Bool bInit ) sal_Bool bWasEnabled = mbIsPwdEnabled; + const SfxFilter* pCurrentFilter = getCurentSfxFilter(); mbIsPwdEnabled = updateExtendedControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, - lclCheckPasswordCapability( getCurentSfxFilter() ) + pCurrentFilter && ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_ENCRYPTION ) ); if( bInit ) @@ -1643,7 +1627,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, return ERRCODE_ABORT; // check, wether or not we have to display a password box - if ( mbHasPassword && mbIsPwdEnabled && xCtrlAccess.is() ) + if ( pCurrentFilter && mbHasPassword && mbIsPwdEnabled && xCtrlAccess.is() ) { try { @@ -1663,7 +1647,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; - ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( pCurrentFilter ) ) ); + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) ) ); uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); xInteractionHandler->handle( rRequest ); @@ -1675,43 +1659,10 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if ( pPasswordRequest->getRecommendReadOnly() ) rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); - if ( pPasswordRequest->getPasswordToModify().getLength() ) - { - rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; - if ( bMSType ) - { - // if the MS-filter should be used - // use the inconsistent algorithm to find the encoding specified by MS - nEncoding = osl_getThreadTextEncoding(); - switch( nEncoding ) - { - case RTL_TEXTENCODING_ISO_8859_15: - case RTL_TEXTENCODING_MS_874: - case RTL_TEXTENCODING_MS_1250: - case RTL_TEXTENCODING_MS_1251: - case RTL_TEXTENCODING_MS_1252: - case RTL_TEXTENCODING_MS_1253: - case RTL_TEXTENCODING_MS_1254: - case RTL_TEXTENCODING_MS_1255: - case RTL_TEXTENCODING_MS_1256: - case RTL_TEXTENCODING_MS_1257: - case RTL_TEXTENCODING_MS_1258: - case RTL_TEXTENCODING_SHIFT_JIS: - case RTL_TEXTENCODING_GB_2312: - case RTL_TEXTENCODING_BIG5: - // in case the system uses an encoding from the list above, it should be used - break; - - default: - // in case other encoding is used, use one of the encodings from the list - nEncoding = RTL_TEXTENCODING_MS_1250; - break; - } - } - - sal_uInt16 nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( pPasswordRequest->getPasswordToModify(), nEncoding ); + // the empty password has 0 as Hash + sal_uInt16 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), bMSType ); + if ( nHash ) rpSet->Put( SfxUInt16Item( SID_PASSWORDTOMODIFYHASH, nHash ) ); - } } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 0b535088b0bd..1740d2703ed1 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -115,6 +115,7 @@ using namespace ::com::sun::star::io; #include #include #include +#include #include #include #include @@ -2671,18 +2672,67 @@ void SfxMedium::SetFilter( const SfxFilter* pFilterP, sal_Bool /*bResetOrig*/ ) pFilter = pFilterP; pImp->nFileVersion = 0; } + //---------------------------------------------------------------- const SfxFilter* SfxMedium::GetOrigFilter( sal_Bool bNotCurrent ) const { return ( pImp->pOrigFilter || bNotCurrent ) ? pImp->pOrigFilter : pFilter; } + //---------------------------------------------------------------- void SfxMedium::SetOrigFilter_Impl( const SfxFilter* pOrigFilter ) { pImp->pOrigFilter = pOrigFilter; } + +//------------------------------------------------------------------ + +sal_uInt16 SfxMedium::CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bMSType ) +{ + sal_uInt16 nHash = 0; + + if ( aPasswd.getLength() ) + { + rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; + if ( bMSType ) + { + // if the MS-filter should be used + // use the inconsistent algorithm to find the encoding specified by MS + nEncoding = osl_getThreadTextEncoding(); + switch( nEncoding ) + { + case RTL_TEXTENCODING_ISO_8859_15: + case RTL_TEXTENCODING_MS_874: + case RTL_TEXTENCODING_MS_1250: + case RTL_TEXTENCODING_MS_1251: + case RTL_TEXTENCODING_MS_1252: + case RTL_TEXTENCODING_MS_1253: + case RTL_TEXTENCODING_MS_1254: + case RTL_TEXTENCODING_MS_1255: + case RTL_TEXTENCODING_MS_1256: + case RTL_TEXTENCODING_MS_1257: + case RTL_TEXTENCODING_MS_1258: + case RTL_TEXTENCODING_SHIFT_JIS: + case RTL_TEXTENCODING_GB_2312: + case RTL_TEXTENCODING_BIG5: + // in case the system uses an encoding from the list above, it should be used + break; + + default: + // in case other encoding is used, use one of the encodings from the list + nEncoding = RTL_TEXTENCODING_MS_1250; + break; + } + } + + nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( aPasswd, nEncoding ); + } + + return nHash; +} + //------------------------------------------------------------------ void SfxMedium::Close() diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 5d14007ec169..0a02a7f8df49 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1499,3 +1499,13 @@ sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt16 nHash ) // return sal_False; } +void SfxObjectShell::SetModifyPasswordEntered() +{ + pImp->m_bModifyPasswordEntered = sal_True; +} + +sal_Bool SfxObjectShell::IsModifyPasswordEntered() +{ + return pImp->m_bModifyPasswordEntered; +} + diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 1cb88e98f59f..a7adf530afc9 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -476,6 +476,32 @@ void SfxObjectShell::SetReadOnlyUI( sal_Bool bReadOnly ) //------------------------------------------------------------------------- +void SfxObjectShell::SetReadOnly() +{ + // Let the document be completely readonly, means that the + // medium open mode is adjusted accordingly, and the write lock + // on the file is removed. + + if ( pMedium && !IsReadOnlyMedium() ) + { + sal_Bool bWasROUI = IsReadOnly(); + + pMedium->UnlockFile( sal_False ); + + // the storage-based mediums are already based on the temporary file + // so UnlockFile has already closed the locking stream + if ( !pMedium->HasStorage_Impl() && IsLoadingFinished() ) + pMedium->CloseInStream(); + + pMedium->SetOpenMode( SFX_STREAM_READONLY, pMedium->IsDirect(), sal_True ); + pMedium->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) ); + + if ( !bWasROUI ) + Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) ); + } +} +//------------------------------------------------------------------------- + sal_Bool SfxObjectShell::IsReadOnly() const { return pImp->bReadOnlyUI || IsReadOnlyMedium(); @@ -1370,6 +1396,9 @@ void SfxObjectShell::FinishedLoading( sal_uInt16 nFlags ) if( !IsAbortingImport() ) PositionView_Impl(); + if ( GetModifyPasswordHash() ) + SetReadOnly(); + // Salvage if ( pSalvageItem ) bSetModifiedTRUE = sal_True; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 0ed230dd9dd9..cc983e5eb543 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -263,6 +263,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bIsInit( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) ,m_nModifyPasswordHash( 0 ) + ,m_bModifyPasswordEntered( sal_False ) { } diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index a97018e4b3f6..04df263a3de8 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -171,7 +171,7 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_Bool m_bIncomplEncrWarnShown; sal_uInt16 m_nModifyPasswordHash; - + sal_Bool m_bModifyPasswordEntered; SfxObjectShell_Impl( SfxObjectShell& _rDocShell ); virtual ~SfxObjectShell_Impl(); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 2291e8079b3a..1d61b09fdd63 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -71,6 +71,7 @@ #include #include #include +#include #include #include @@ -86,6 +87,7 @@ #include #include #include +#include #include #include @@ -113,6 +115,7 @@ namespace css = ::com::sun::star; #include "sfxtypes.hxx" #include #include +#include #include #include "sfxresid.hxx" #include "appbas.hxx" @@ -158,6 +161,48 @@ TYPEINIT1(SfxViewFrameItem, SfxPoolItem); //========================================================================= +static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt16 nPasswordHash ) +{ + sal_Bool bResult = !nPasswordHash; + + OSL_ENSURE( pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ), "PasswordToModify feature is active for a filter that does not support it!" ); + + if ( pFilter && xHandler.is() ) + { + sal_Bool bCancel = sal_False; + sal_Bool bFirstTime = sal_True; + + while ( !bResult && !bCancel ) + { + sal_Bool bMSType = !pFilter->IsOwnFormat(); + ::comphelper::DocPasswordRequestType nType = bMSType ? + ::comphelper::DocPasswordRequestType_MS : + ::comphelper::DocPasswordRequestType_STANDARD; + + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( + new ::comphelper::DocPasswordRequest( + bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD, + bFirstTime ? ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER : ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER, + aPath, + sal_True ) ); + + uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); + xHandler->handle( rRequest ); + + if ( pPasswordRequest->isPassword() ) + bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), bMSType ) == nPasswordHash ); + else + bCancel = sal_True; + + bFirstTime = sal_False; + } + } + + return bResult; +} + +//========================================================================= + struct SfxViewFrame_Impl { SvBorder aBorder; @@ -371,10 +416,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT )) break; + SfxMedium* pMed = pSh->GetMedium(); + SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_VIEWONLY, sal_False ); if ( pItem && pItem->GetValue() ) { - SfxMedium* pMed = pSh->GetMedium(); SfxApplication* pApp = SFX_APP(); SfxAllItemSet aSet( pApp->GetPool() ); aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetURLObject().GetMainURL(INetURLObject::NO_DECODE) ) ); @@ -417,6 +463,22 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } else { + if ( pSh->IsReadOnlyMedium() + && pSh->GetModifyPasswordHash() + && !pSh->IsModifyPasswordEntered() ) + { + ::rtl::OUString aDocumentName = INetURLObject( pMed->GetOrigURL() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); + if( !AskPasswordToModify_Impl( pMed->GetInteractionHandler(), aDocumentName, pMed->GetOrigFilter(), pSh->GetModifyPasswordHash() ) ) + { + // this is a read-only document, if it has "Password to modify" + // the user should enter password before he can edit the document + rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) ); + return; + } + + pSh->SetModifyPasswordEntered(); + } + nOpenMode = SFX_STREAM_READWRITE; pSh->SetReadOnlyUI( sal_False ); @@ -436,142 +498,138 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } // doing - if( pSh ) + String aTemp; + utl::LocalFileHelper::ConvertPhysicalNameToURL( pMed->GetPhysicalName(), aTemp ); + INetURLObject aPhysObj( aTemp ); + SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), + pVersionItem, SfxInt16Item, SID_VERSION, sal_False ); + + INetURLObject aMedObj( pMed->GetName() ); + + // the logic below is following, if the document seems not to need to be reloaded and the physical name is different + // to the logical one, then on file system it can be checked that the copy is still newer than the original and no document reload is required + if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE && + aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) && + !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) )) + || pMed->IsRemote() ) ) + || pVersionItem ) { - SfxMedium* pMed = pSh->GetMedium(); - String aTemp; - utl::LocalFileHelper::ConvertPhysicalNameToURL( pMed->GetPhysicalName(), aTemp ); - INetURLObject aPhysObj( aTemp ); - SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), - pVersionItem, SfxInt16Item, SID_VERSION, sal_False ); - - INetURLObject aMedObj( pMed->GetName() ); - - // the logic below is following, if the document seems not to need to be reloaded and the physical name is different - // to the logical one, then on file system it can be checked that the copy is still newer than the original and no document reload is required - if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE && - aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) && - !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) )) - || pMed->IsRemote() ) ) - || pVersionItem ) + sal_Bool bOK = sal_False; + if ( !pVersionItem ) { - sal_Bool bOK = sal_False; - if ( !pVersionItem ) + sal_Bool bHasStorage = pMed->HasStorage_Impl(); + // switching edit mode could be possible without reload + if ( bHasStorage && pMed->GetStorage() == pSh->GetStorage() ) { - sal_Bool bHasStorage = pMed->HasStorage_Impl(); - // switching edit mode could be possible without reload - if ( bHasStorage && pMed->GetStorage() == pSh->GetStorage() ) - { - // TODO/LATER: faster creation of copy - if ( !pSh->ConnectTmpStorage_Impl( pMed->GetStorage(), pMed ) ) - return; - } + // TODO/LATER: faster creation of copy + if ( !pSh->ConnectTmpStorage_Impl( pMed->GetStorage(), pMed ) ) + return; + } - pMed->CloseAndRelease(); - pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); - pMed->SetOpenMode( nOpenMode, pMed->IsDirect() ); + pMed->CloseAndRelease(); + pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); + pMed->SetOpenMode( nOpenMode, pMed->IsDirect() ); - pMed->CompleteReOpen(); - if ( nOpenMode & STREAM_WRITE ) - pMed->LockOrigFileOnDemand( sal_False, sal_True ); + pMed->CompleteReOpen(); + if ( nOpenMode & STREAM_WRITE ) + pMed->LockOrigFileOnDemand( sal_False, sal_True ); - // LockOrigFileOnDemand might set the readonly flag itself, it should be set back - pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); + // LockOrigFileOnDemand might set the readonly flag itself, it should be set back + pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); - if ( !pMed->GetErrorCode() ) - bOK = sal_True; - } + if ( !pMed->GetErrorCode() ) + bOK = sal_True; + } - if( !bOK ) + if( !bOK ) + { + ErrCode nErr = pMed->GetErrorCode(); + if ( pVersionItem ) + nErr = ERRCODE_IO_ACCESSDENIED; + else { - ErrCode nErr = pMed->GetErrorCode(); - if ( pVersionItem ) - nErr = ERRCODE_IO_ACCESSDENIED; - else - { - pMed->ResetError(); - pMed->SetOpenMode( SFX_STREAM_READONLY, pMed->IsDirect() ); - pMed->ReOpen(); - pSh->DoSaveCompleted( pMed ); - } + pMed->ResetError(); + pMed->SetOpenMode( SFX_STREAM_READONLY, pMed->IsDirect() ); + pMed->ReOpen(); + pSh->DoSaveCompleted( pMed ); + } - // r/o-Doc kann nicht in Editmode geschaltet werden? - rReq.Done( sal_False ); + // r/o-Doc kann nicht in Editmode geschaltet werden? + rReq.Done( sal_False ); - SFX_REQUEST_ARG( rReq, pFSetItem, SfxBoolItem, SID_EDIT_FRAMESET, sal_False); - if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() ) + SFX_REQUEST_ARG( rReq, pFSetItem, SfxBoolItem, SID_EDIT_FRAMESET, sal_False); + if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() ) + { + // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen + QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) ); + if ( !pFSetItem && RET_YES == aBox.Execute() ) { - // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen - QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) ); - if ( !pFSetItem && RET_YES == aBox.Execute() ) + SfxApplication* pApp = SFX_APP(); + SfxAllItemSet aSet( pApp->GetPool() ); + aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) ); + SFX_ITEMSET_ARG( pMed->GetItemSet(), pReferer, SfxStringItem, SID_REFERER, sal_False ); + if ( pReferer ) + aSet.Put( *pReferer ); + aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); + if ( pVersionItem ) + aSet.Put( *pVersionItem ); + + if( pMed->GetFilter() ) { - SfxApplication* pApp = SFX_APP(); - SfxAllItemSet aSet( pApp->GetPool() ); - aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) ); - SFX_ITEMSET_ARG( pMed->GetItemSet(), pReferer, SfxStringItem, SID_REFERER, sal_False ); - if ( pReferer ) - aSet.Put( *pReferer ); - aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); - if ( pVersionItem ) - aSet.Put( *pVersionItem ); - - if( pMed->GetFilter() ) - { - aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) ); - SFX_ITEMSET_ARG( pMed->GetItemSet(), pOptions, - SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False ); - if ( pOptions ) - aSet.Put( *pOptions ); - } - - GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet ); - return; + aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) ); + SFX_ITEMSET_ARG( pMed->GetItemSet(), pOptions, + SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False ); + if ( pOptions ) + aSet.Put( *pOptions ); } - else - nErr = 0; - } - ErrorHandler::HandleError( nErr ); - rReq.SetReturnValue( - SfxBoolItem( rReq.GetSlot(), sal_False ) ); - return; - } - else - { - pSh->DoSaveCompleted( pMed ); - pSh->Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) ); - rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_True ) ); - rReq.Done( sal_True ); - // if( nOpenMode == SFX_STREAM_READONLY ) - // pMed->Close(); - - // ReloadForEdit bei Framesets schaltet auch FramesetEditmode - sal_Bool bIsReadonly = GetObjectShell()->IsReadOnly(); - if ( bIsReadonly != bWasReadonly && !GetFrame()->GetParentFrame() ) - { - SfxBoolItem aItem( SID_EDIT_FRAMESET, !bIsReadonly ); - GetDispatcher()->Execute( SID_EDIT_FRAMESET, - SFX_CALLMODE_RECORD, &aItem, 0L ); - pSh->Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); + GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet ); + return; } - return; + else + nErr = 0; } - } - /* - if ( !bReload ) - { - // Es soll nicht reloaded werden - SfxErrorContext aEc( ERRCODE_SFX_NODOCRELOAD ); - ErrorHandler::HandleError( ERRCODE_SFX_NODOCRELOAD ); + ErrorHandler::HandleError( nErr ); rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) ); return; } - */ - // Ansonsten ( lokal und arbeiten auf Kopie ) muss gereloaded - // werden. + else + { + pSh->DoSaveCompleted( pMed ); + pSh->Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) ); + rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_True ) ); + rReq.Done( sal_True ); + // if( nOpenMode == SFX_STREAM_READONLY ) + // pMed->Close(); + + // ReloadForEdit bei Framesets schaltet auch FramesetEditmode + sal_Bool bIsReadonly = GetObjectShell()->IsReadOnly(); + if ( bIsReadonly != bWasReadonly && !GetFrame()->GetParentFrame() ) + { + SfxBoolItem aItem( SID_EDIT_FRAMESET, !bIsReadonly ); + GetDispatcher()->Execute( SID_EDIT_FRAMESET, + SFX_CALLMODE_RECORD, &aItem, 0L ); + pSh->Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); + } + return; + } + } + + /* + if ( !bReload ) + { + // Es soll nicht reloaded werden + SfxErrorContext aEc( ERRCODE_SFX_NODOCRELOAD ); + ErrorHandler::HandleError( ERRCODE_SFX_NODOCRELOAD ); + rReq.SetReturnValue( + SfxBoolItem( rReq.GetSlot(), sal_False ) ); + return; } + */ + // Ansonsten ( lokal und arbeiten auf Kopie ) muss gereloaded + // werden. rReq.AppendItem( SfxBoolItem( SID_FORCERELOAD, sal_True) ); rReq.AppendItem( SfxBoolItem( SID_SILENT, sal_True )); diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index 51556e88bb0f..7103fee29510 100755 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -32,6 +32,7 @@ #include "com/sun/star/task/MasterPasswordRequest.hpp" #include "com/sun/star/task/XInteractionAbort.hpp" #include "com/sun/star/task/XInteractionPassword.hpp" +#include "com/sun/star/task/XInteractionPassword2.hpp" #include "com/sun/star/task/XInteractionRetry.hpp" #include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp" #include "com/sun/star/ucb/URLAuthenticationRequest.hpp" @@ -431,7 +432,7 @@ executePasswordDialog( pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen ) ); rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); - rInfo.SetPasswordToOpen( pDialog->GetPasswordToOpen() ); + rInfo.SetPassword( pDialog->GetPasswordToOpen() ); rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() ); rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() ); } @@ -441,7 +442,7 @@ executePasswordDialog( new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) ); rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); - rInfo.SetPasswordToOpen( bIsPasswordToModify ? String() : pDialog->GetPassword() ); + rInfo.SetPassword( bIsPasswordToModify ? String() : pDialog->GetPassword() ); rInfo.SetPasswordToModify( bIsPasswordToModify ? pDialog->GetPassword() : String() ); } } @@ -467,7 +468,12 @@ handlePasswordRequest_( uno::Reference< task::XInteractionRetry > xRetry; uno::Reference< task::XInteractionAbort > xAbort; uno::Reference< task::XInteractionPassword > xPassword; - getContinuations(rContinuations, &xRetry, &xAbort, &xPassword); + uno::Reference< task::XInteractionPassword2 > xPassword2; + getContinuations(rContinuations, &xRetry, &xAbort, &xPassword2, &xPassword); + + if ( xPassword2.is() && !xPassword.is() ) + xPassword.set( xPassword2, uno::UNO_QUERY_THROW ); + LoginErrorInfo aInfo; executePasswordDialog( pParent, aInfo, nMode, @@ -476,8 +482,15 @@ handlePasswordRequest_( switch (aInfo.GetResult()) { case ERRCODE_BUTTON_OK: + OSL_ENSURE( !bIsPasswordToModify || xPassword2.is(), "PasswordToModify is requested, but there is no Interaction!" ); if (xPassword.is()) { + if (xPassword2.is()) + { + xPassword2->setPasswordToModify( aInfo.GetPasswordToModify() ); + xPassword2->setRecommendReadOnly( aInfo.IsRecommendToOpenReadonly() ); + } + xPassword->setPassword(aInfo.GetPassword()); xPassword->select(); } @@ -593,7 +606,7 @@ UUIInteractionHelper::handlePasswordRequest( nMode = aDocumentMSPasswordRequest2.Mode; aDocumentName = aDocumentMSPasswordRequest2.Name; bMSCryptoMode = true; - bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify; + bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify; bDoHandleRequest = true; } diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx index d16e1a541710..2e0009900d86 100755 --- a/uui/source/loginerr.hxx +++ b/uui/source/loginerr.hxx @@ -25,143 +25,139 @@ * ************************************************************************/ -#ifndef _LOGINERR_HXX -#define _LOGINERR_HXX +#ifndef m_LOGINERR_HXX +#define m_LOGINERR_HXX #include //========================================================================= -#define LOGINERROR_FLAG_SET_SAVE_PASSWORD 1 -#define LOGINERROR_FLAG_MODIFY_ACCOUNT 2 +#define LOGINERROR_FLAG_SET_SAVE_PASSWORD 1 +#define LOGINERROR_FLAG_MODIFY_ACCOUNT 2 #define LOGINERROR_FLAG_MODIFY_USER_NAME 4 -#define LOGINERROR_FLAG_PERSISTENT_PASSWORD 8 +#define LOGINERROR_FLAG_PERSISTENT_PASSWORD 8 #define LOGINERROR_FLAG_CAN_USE_SYSCREDS 16 -#define LOGINERROR_FLAG_IS_USE_SYSCREDS 32 +#define LOGINERROR_FLAG_IS_USE_SYSCREDS 32 class LoginErrorInfo { private: - String _aTitle; - String _aServer; - String _aAccount; - String _aUserName; - String _aPassword; - String _aPasswordToOpen; - String _aPasswordToModify; - String _aPath; - String _aErrorText; - BYTE _nFlags; - USHORT _nRet; - bool _bRecommendToOpenReadonly; + String m_aTitle; + String m_aServer; + String m_aAccount; + String m_aUserName; + String m_aPassword; + String m_aPasswordToModify; + String m_aPath; + String m_aErrorText; + BYTE m_nFlags; + USHORT m_nRet; + bool m_bRecommendToOpenReadonly; public: LoginErrorInfo() - : _nFlags( LOGINERROR_FLAG_MODIFY_USER_NAME ), - _nRet( ERRCODE_BUTTON_CANCEL ) + : m_nFlags( LOGINERROR_FLAG_MODIFY_USER_NAME ), + m_nRet( ERRCODE_BUTTON_CANCEL ) { } - const String& GetTitle() const { return _aTitle; } - const String& GetServer() const { return _aServer; } - const String& GetAccount() const { return _aAccount; } - const String& GetUserName() const { return _aUserName; } - const String& GetPassword() const { return _aPassword; } - const String& GetPasswordToOpen() const { return _aPasswordToOpen; } - const String& GetPasswordToModify() const { return _aPasswordToModify; } - const bool IsRecommendToOpenReadonly() const { return _bRecommendToOpenReadonly; } - const String& GetPath() const { return _aPath; } - const String& GetErrorText() const { return _aErrorText; } - BOOL GetIsPersistentPassword() const - { return ( _nFlags & LOGINERROR_FLAG_PERSISTENT_PASSWORD ); } - BOOL GetIsSavePassword() const - { return ( _nFlags & LOGINERROR_FLAG_SET_SAVE_PASSWORD ); } + const String& GetTitle() const { return m_aTitle; } + const String& GetServer() const { return m_aServer; } + const String& GetAccount() const { return m_aAccount; } + const String& GetUserName() const { return m_aUserName; } + const String& GetPassword() const { return m_aPassword; } + const String& GetPasswordToModify() const { return m_aPasswordToModify; } + const bool IsRecommendToOpenReadonly() const { return m_bRecommendToOpenReadonly; } + const String& GetPath() const { return m_aPath; } + const String& GetErrorText() const { return m_aErrorText; } + BOOL GetIsPersistentPassword() const + { return ( m_nFlags & LOGINERROR_FLAG_PERSISTENT_PASSWORD ); } + BOOL GetIsSavePassword() const + { return ( m_nFlags & LOGINERROR_FLAG_SET_SAVE_PASSWORD ); } BOOL GetCanUseSystemCredentials() const - { return ( _nFlags & LOGINERROR_FLAG_CAN_USE_SYSCREDS ); } + { return ( m_nFlags & LOGINERROR_FLAG_CAN_USE_SYSCREDS ); } BOOL GetIsUseSystemCredentials() const - { return ( _nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) == + { return ( m_nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) == LOGINERROR_FLAG_IS_USE_SYSCREDS; } - BYTE GetFlags() const { return _nFlags; } - USHORT GetResult() const { return _nRet; } + BYTE GetFlags() const { return m_nFlags; } + USHORT GetResult() const { return m_nRet; } - void SetTitle( const String& aTitle ) - { _aTitle = aTitle; } - void SetServer( const String& aServer ) - { _aServer = aServer; } - void SetAccount( const String& aAccount ) - { _aAccount = aAccount; } - void SetUserName( const String& aUserName ) - { _aUserName = aUserName; } + void SetTitle( const String& aTitle ) + { m_aTitle = aTitle; } + void SetServer( const String& aServer ) + { m_aServer = aServer; } + void SetAccount( const String& aAccount ) + { m_aAccount = aAccount; } + void SetUserName( const String& aUserName ) + { m_aUserName = aUserName; } void SetPassword( const String& aPassword ) - { _aPassword = aPassword; } - void SetPasswordToOpen( const String& aPassword ) - { _aPasswordToOpen = aPassword; } + { m_aPassword = aPassword; } void SetPasswordToModify( const String& aPassword ) - { _aPasswordToModify = aPassword; } + { m_aPasswordToModify = aPassword; } void SetRecommendToOpenReadonly( bool bVal ) - { _bRecommendToOpenReadonly = bVal; } - void SetPath( const String& aPath ) - { _aPath = aPath; } - void SetErrorText( const String& aErrorText ) - { _aErrorText = aErrorText; } + { m_bRecommendToOpenReadonly = bVal; } + void SetPath( const String& aPath ) + { m_aPath = aPath; } + void SetErrorText( const String& aErrorText ) + { m_aErrorText = aErrorText; } void SetFlags( BYTE nFlags ) - { _nFlags = nFlags; } - inline void SetSavePassword( BOOL bSet ); - inline void SetPersistentPassword( BOOL bSet ); + { m_nFlags = nFlags; } + inline void SetSavePassword( BOOL bSet ); + inline void SetPersistentPassword( BOOL bSet ); inline void SetCanUseSystemCredentials( BOOL bSet ); inline void SetIsUseSystemCredentials( BOOL bSet ); - inline void SetModifyAccount( BOOL bSet ); - inline void SetModifyUserName( BOOL bSet ); + inline void SetModifyAccount( BOOL bSet ); + inline void SetModifyUserName( BOOL bSet ); void SetResult( USHORT nRet ) - { _nRet = nRet; } + { m_nRet = nRet; } }; inline void LoginErrorInfo::SetSavePassword( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_SET_SAVE_PASSWORD; + m_nFlags |= LOGINERROR_FLAG_SET_SAVE_PASSWORD; else - _nFlags &= ~LOGINERROR_FLAG_SET_SAVE_PASSWORD; + m_nFlags &= ~LOGINERROR_FLAG_SET_SAVE_PASSWORD; } inline void LoginErrorInfo::SetPersistentPassword( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_PERSISTENT_PASSWORD; + m_nFlags |= LOGINERROR_FLAG_PERSISTENT_PASSWORD; else - _nFlags &= ~LOGINERROR_FLAG_PERSISTENT_PASSWORD; + m_nFlags &= ~LOGINERROR_FLAG_PERSISTENT_PASSWORD; } inline void LoginErrorInfo::SetCanUseSystemCredentials( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_CAN_USE_SYSCREDS; + m_nFlags |= LOGINERROR_FLAG_CAN_USE_SYSCREDS; else - _nFlags &= ~LOGINERROR_FLAG_CAN_USE_SYSCREDS; + m_nFlags &= ~LOGINERROR_FLAG_CAN_USE_SYSCREDS; } inline void LoginErrorInfo::SetIsUseSystemCredentials( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_IS_USE_SYSCREDS; + m_nFlags |= LOGINERROR_FLAG_IS_USE_SYSCREDS; else - _nFlags &= ~LOGINERROR_FLAG_IS_USE_SYSCREDS; + m_nFlags &= ~LOGINERROR_FLAG_IS_USE_SYSCREDS; } inline void LoginErrorInfo::SetModifyAccount( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_MODIFY_ACCOUNT; + m_nFlags |= LOGINERROR_FLAG_MODIFY_ACCOUNT; else - _nFlags &= ~LOGINERROR_FLAG_MODIFY_ACCOUNT; + m_nFlags &= ~LOGINERROR_FLAG_MODIFY_ACCOUNT; } inline void LoginErrorInfo::SetModifyUserName( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_MODIFY_USER_NAME; + m_nFlags |= LOGINERROR_FLAG_MODIFY_USER_NAME; else - _nFlags &= ~LOGINERROR_FLAG_MODIFY_USER_NAME; + m_nFlags &= ~LOGINERROR_FLAG_MODIFY_USER_NAME; } #endif -- cgit From 9bfe25036358e6befdb2e9ddcbc1084f6a3d8c7f Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 23 Apr 2010 11:43:48 +0200 Subject: jl152 import 263450 from native0jl:#i77196# XExtensionManager.isReadOnlyRepositor, fixed removing xcu exceptions, executable backend --- .../deployment/manager/dp_commandenvironments.cxx | 31 ++++ .../deployment/manager/dp_commandenvironments.hxx | 18 ++- .../deployment/manager/dp_extensionmanager.cxx | 4 + .../deployment/manager/dp_extensionmanager.hxx | 2 + desktop/source/deployment/manager/dp_manager.cxx | 3 + .../source/deployment/registry/dp_backenddb.cxx | 8 +- .../registry/executable/dp_executable.cxx | 61 ++++++-- .../registry/executable/dp_executablebackenddb.cxx | 165 +++++++++++++++++++++ .../registry/executable/dp_executablebackenddb.hxx | 91 ++++++++++++ .../deployment/registry/executable/makefile.mk | 3 +- .../deployment/registry/help/dp_helpbackenddb.cxx | 24 --- .../deployment/registry/package/dp_package.cxx | 6 - .../deployment/registry/script/dp_script.cxx | 17 ++- 13 files changed, 382 insertions(+), 51 deletions(-) create mode 100644 desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx create mode 100644 desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx diff --git a/desktop/source/deployment/manager/dp_commandenvironments.cxx b/desktop/source/deployment/manager/dp_commandenvironments.cxx index 814dc818b2a6..c2801ba1d965 100644 --- a/desktop/source/deployment/manager/dp_commandenvironments.cxx +++ b/desktop/source/deployment/manager/dp_commandenvironments.cxx @@ -250,6 +250,37 @@ void NoLicenseCommandEnv::handle( handle_(approve, abort, xRequest); } + +// NoExceptionCommandEnv::NoExceptionCommandEnv( +// css::uno::Reference< css::task::XInteractionHandler> const & handler, +// css::uno::Type const & type): +// BaseCommandEnv(handler), +// m_type(type) +// { +// } +// // XInteractionHandler +// void NoExceptionCommandEnv::handle( +// Reference< task::XInteractionRequest> const & xRequest ) +// throw (uno::RuntimeException) +// { +// uno::Any request( xRequest->getRequest() ); +// OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + +// deployment::LicenseException licExc; + +// bool approve = false; +// bool abort = false; + +// if (request.getValueType() == m_type) +// { +// approve = true; +// } +// handle_(approve, abort, xRequest); +// } + + + } // namespace dp_manager diff --git a/desktop/source/deployment/manager/dp_commandenvironments.hxx b/desktop/source/deployment/manager/dp_commandenvironments.hxx index ad47fd2af549..0bdad4fd09cc 100644 --- a/desktop/source/deployment/manager/dp_commandenvironments.hxx +++ b/desktop/source/deployment/manager/dp_commandenvironments.hxx @@ -32,7 +32,7 @@ #include "cppuhelper/compbase3.hxx" //#include "cppuhelper/implbase2.hxx" #include "ucbhelper/content.hxx" - +#include "com/sun/star/uno/Type.hxx" namespace css = ::com::sun::star; @@ -137,6 +137,22 @@ public: }; +// class NoExceptionCommandEnv : public BaseCommandEnv +// { +// css::uno::Type m_type; +// public: +// NoExceptionCommandEnv::NoExceptionCommandEnv(){}; +// NoExceptionCommandEnv::NoExceptionCommandEnv( +// css::uno::Reference< css::task::XInteractionHandler> const & handler, +// css::uno::Type const & type); + +// // XInteractionHandler +// virtual void SAL_CALL handle( +// css::uno::Reference const & xRequest ) +// throw (css::uno::RuntimeException); + +// }; + } diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index bbe476e57fba..44f34991889e 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -1224,6 +1224,10 @@ ExtensionManager::getExtensionsWithUnacceptedLicenses( return xPackageManager->getExtensionsWithUnacceptedLicenses(xCmdEnv); } +sal_Bool ExtensionManager::isReadOnlyRepository(::rtl::OUString const & repository) +{ + return getPackageManager(repository)->isReadOnly(); +} //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 10bf3713c410..158fd35e2fa0 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -202,6 +202,8 @@ public: throw (css::deployment::DeploymentException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnlyRepository(::rtl::OUString const & repository); + private: struct StrSyncRepository : public ::dp_misc::StaticResourceString< diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 8c55f2508680..83105406f253 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -1368,6 +1368,9 @@ void PackageManagerImpl::synchronizeAddedExtensions( rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8); + //It it sufficient to check for the folder name, because when the administor + //installed the extension it was already checked if there is one with the + //same identifier. const MatchTempDir match(titleEncoded); if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == id2temp.end()) diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 1c0451c77cd6..fe8b39b94d44 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -150,7 +150,7 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) //find the extension element that is to be removed Reference aNode = xpathApi->selectSingleNode(root, sXPathExpression); - OSL_ASSERT(aNode.is()); + if (aNode.is()) { root->removeChild(aNode); @@ -174,6 +174,7 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) } +//Only writes the data if there is at least one entry void BackendDb::writeVectorOfPair( ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > const & vecPairs, OUString const & sVectorTagName, @@ -183,6 +184,8 @@ void BackendDb::writeVectorOfPair( css::uno::Reference const & xParent) { try{ + if (vecPairs.size() == 0) + return; const OUString sNameSpace = getDbNSName(); OSL_ASSERT(sNameSpace.getLength()); Reference doc = getDocument(); @@ -287,6 +290,7 @@ BackendDb::readVectorOfPair( } } +//Only writes the data if there is at least one entry void BackendDb::writeSimpleList( ::std::list< ::rtl::OUString> const & list, OUString const & sListTagName, @@ -295,6 +299,8 @@ void BackendDb::writeSimpleList( { try { + if (list.size() == 0) + return; const OUString sNameSpace = getDbNSName(); Reference doc = getDocument(); diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index ac83302f9fb4..c72a97d88891 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" +#include "dp_misc.h" #include "dp_backend.h" #include "dp_ucb.h" #include "dp_interact.h" @@ -37,10 +38,12 @@ #include "comphelper/servicedecl.hxx" #include "svl/inettype.hxx" #include "cppuhelper/implbase1.hxx" +#include "dp_executablebackenddb.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; +using namespace dp_misc; using ::rtl::OUString; namespace dp_registry { @@ -68,7 +71,6 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend bool getFileAttributes(sal_uInt64& out_Attributes); bool isUrlTargetInExtension(); - public: inline ExecutablePackageImpl( ::rtl::Reference const & myBackend, @@ -89,8 +91,12 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend OUString const & url, OUString const & mediaType, sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); - Reference m_xExecutableTypeInfo; + void addDataToDb(OUString const & url); + bool isRegisteredInDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + Reference m_xExecutableTypeInfo; + std::auto_ptr m_backendDb; public: BackendImpl( Sequence const & args, Reference const & xComponentContext ); @@ -114,7 +120,32 @@ BackendImpl::BackendImpl( RID_IMG_COMPONENT, RID_IMG_COMPONENT_HC ) ) { + if (!transientMode()) + { + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new ExecutableBackendDb(getComponentContext(), dbFile)); + } +} +void BackendImpl::addDataToDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url); +} + +bool BackendImpl::isRegisteredInDb(OUString const & url) +{ + bool ret = false; + if (m_backendDb.get()) + ret = m_backendDb->getEntry(url); + return ret; +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); } // XPackageRegistry @@ -186,18 +217,11 @@ BackendImpl::ExecutablePackageImpl::isRegistered_( ::rtl::Reference const &, Reference const & ) { - //We must return Optional.isPresent = true, otherwise - //processPackage is not called. - //The user shall not be able to enable/disable the executable. This is not needed since - //the executable does not affect the office. The best thing is to show no - //status at all. See also BackendImpl::PackageImpl::isRegistered_ (dp_package.cxx) - //On Windows there is no executable file attribute. One has to use security API for this. - //However, on Windows we do not have the problem, that after unzipping the file cannot be - //executed. + bool registered = getMyBackend()->isRegisteredInDb(getURL()); return beans::Optional< beans::Ambiguous >( sal_True /* IsPresent */, beans::Ambiguous( - sal_True, sal_True /* IsAmbiguous */ ) ); + registered, sal_False /* IsAmbiguous */ ) ); } void BackendImpl::ExecutablePackageImpl::processPackage_( @@ -224,7 +248,9 @@ void BackendImpl::ExecutablePackageImpl::processPackage_( else if (getMyBackend()->m_context.equals(OUSTR("shared"))) attributes |= (osl_File_Attribute_OwnExe | osl_File_Attribute_GrpExe | osl_File_Attribute_OthExe); - else + else if (!getMyBackend()->m_context.equals(OUSTR("bundled"))) + //Bundled extension are required to be in the properly + //installed. That is an executable must have the right flags OSL_ASSERT(0); //This won't have affect on Windows @@ -232,11 +258,18 @@ void BackendImpl::ExecutablePackageImpl::processPackage_( dp_misc::expandUnoRcUrl(m_url), attributes)) OSL_ENSURE(0, "Extension Manager: Could not set executable file attribute."); } + getMyBackend()->addDataToDb(getURL()); + } + else + { + getMyBackend()->deleteDataFromDb(getURL()); } } -//We currently cannot check if this XPackage represents a content of a particular exension +//We currently cannot check if this XPackage represents a content of a particular extension //But we can check if we are within $UNO_USER_PACKAGES_CACHE etc. +//Done for security reasons. For example an extension manifest could contain a path to +//an executable outside the extension. bool BackendImpl::ExecutablePackageImpl::isUrlTargetInExtension() { bool bSuccess = false; @@ -245,6 +278,8 @@ bool BackendImpl::ExecutablePackageImpl::isUrlTargetInExtension() sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$UNO_USER_PACKAGES_CACHE")); else if (getMyBackend()->m_context.equals(OUSTR("shared"))) sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$UNO_SHARED_PACKAGES_CACHE")); + else if (getMyBackend()->m_context.equals(OUSTR("bundled"))) + sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$BUNDLED_EXTENSIONS")); else OSL_ASSERT(0); //remove file ellipses diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx new file mode 100644 index 000000000000..893a58ee8c64 --- /dev/null +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_package.cxx,v $ + * $Revision: 1.34.16.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_executablebackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/executable-registry/2010" +#define NS_PREFIX "exe" +#define ROOT_ELEMENT_NAME "executable-backend-db" + +namespace dp_registry { +namespace backend { +namespace executable { + +ExecutableBackendDb::ExecutableBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString ExecutableBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ExecutableBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + +OUString ExecutableBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +void ExecutableBackendDb::addEntry(::rtl::OUString const & url) +{ + try{ + + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + Reference helpElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":executable"))); + + helpElement->setAttribute(OUSTR("url"), url); + + Reference helpNode( + helpElement, UNO_QUERY_THROW); + root->appendChild(helpNode); + +// Reference dataNode( +// doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")), +// UNO_QUERY_THROW); +// helpNode->appendChild(dataNode); + +// Reference dataValue( +// doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); +// dataNode->appendChild(dataValue); + + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +void ExecutableBackendDb::removeEntry(::rtl::OUString const & url) +{ + OUString sExpression( + OUSTR(NS_PREFIX) + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); + removeElement(sExpression); +} + +bool ExecutableBackendDb::getEntry(::rtl::OUString const & url) +{ + try + { + const OUString sPrefix = getNSPrefix(); + const OUString sExpression( + sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (!aNode.is()) + { + return false; + } + return true; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + + +} // namespace executable +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx new file mode 100644 index 000000000000..2634d1d9d376 --- /dev/null +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_backend.h,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_EXECUTABLEBACKENDDB_HXX +#define INCLUDED_DP_EXECUTABLEBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include +#include "boost/optional.hpp" +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { +namespace executable { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + The format looks like this: + + + */ +class ExecutableBackendDb: public dp_registry::backend::BackendDb +{ +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getNSPrefix(); + + virtual ::rtl::OUString getRootElementName(); + +public: + + ExecutableBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url); + void removeEntry(::rtl::OUString const & url); + bool getEntry(::rtl::OUString const & url); +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/executable/makefile.mk b/desktop/source/deployment/registry/executable/makefile.mk index 1e57f5ecf3b1..81b2baa44e5d 100644 --- a/desktop/source/deployment/registry/executable/makefile.mk +++ b/desktop/source/deployment/registry/executable/makefile.mk @@ -36,7 +36,8 @@ ENABLE_EXCEPTIONS = TRUE INCPRE += ..$/..$/inc SLOFILES = \ - $(SLO)$/dp_executable.obj + $(SLO)$/dp_executable.obj \ + $(SLO)$/dp_executablebackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index f36eb6d7b8cb..cad6ddecf751 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -111,20 +111,6 @@ void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); dataNode->appendChild(dataValue); -// writeSimpleList( -// data.implementationNames, -// OUSTR("implementation-names"), -// OUSTR("name"), -// componentNode); - -// writeVectorOfPair( -// data.singletons, -// OUSTR("singletons"), -// OUSTR("item"), -// OUSTR("key"), -// OUSTR("value"), -// componentNode); - save(); } catch(css::uno::Exception &) @@ -166,16 +152,6 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) Reference dataUrlVal = xpathApi->selectSingleNode(aNode, sExprDataUrl); retData.dataUrl = dataUrlVal->getNodeValue(); - -// retData.implementationNames = -// readList( -// aNode, OUSTR("reg:implementation-names"), OUSTR("reg:name")); - -// retData.singletons = -// readVectorOfPair( -// aNode, OUSTR("reg:singletons"), OUSTR("item"), OUSTR("key"), -// OUSTR("value")); - } else { diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index a5426bf26b54..3d4842f62bfd 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -530,12 +530,6 @@ BackendImpl::PackageImpl::isRegistered_( for ( sal_Int32 pos = bundle.getLength(); pos--; ) { Reference const & xPackage = bundle[ pos ]; - //disregard executable (application/vnd.sun.star.executable) - //it will not be disabled/enabled. - OUString sType = xPackage->getPackageType()->getMediaType(); - if (sType.equals(OUSTR("application/vnd.sun.star.executable"))) - continue; - Reference xSubAbortChannel( xPackage->createAbortChannel() ); AbortChannel::Chain chain( abortChannel, xSubAbortChannel ); diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index b2eddfaf74e0..e808cd0f5e73 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -227,15 +227,22 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { + OUString dialogURL( makeURL( url, OUSTR("dialog.xlb") ) ); + if (! create_ucb_content( + 0, dialogURL, xCmdEnv, false /* no throw */ )) { + dialogURL = OUString(); + } + if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.basic-library")) { - OUString dialogURL( makeURL( url, OUSTR("dialog.xlb") ) ); + OUString scriptURL( makeURL( url, OUSTR("script.xlb"))); if (! create_ucb_content( - 0, dialogURL, xCmdEnv, false /* no throw */ )) { - dialogURL = OUString(); + 0, scriptURL, xCmdEnv, false /* no throw */ )) { + scriptURL = OUString(); } + return new PackageImpl( - this, url, xCmdEnv, makeURL( url, OUSTR("script.xlb") ), + this, url, xCmdEnv, scriptURL, dialogURL, bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( @@ -243,7 +250,7 @@ Reference BackendImpl::bindPackage_( return new PackageImpl( this, url, xCmdEnv, OUString() /* no script lib */, - makeURL( url, OUSTR("dialog.xlb") ), + dialogURL, bRemoved, identifier); } } -- cgit From 3807193d03962da3247a7b74bd58d2d511786fc2 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 28 Apr 2010 11:44:09 +0200 Subject: jl152 import 263451 from native0jl:#i77196# Use ExtensionManager instead of PackageManager --- desktop/source/app/check_ext_deps.cxx | 2 +- desktop/source/deployment/gui/dp_gui.h | 9 +-- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 91 +++++++++------------- desktop/source/deployment/gui/dp_gui_dialog2.hxx | 34 +++----- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 73 +++++++---------- .../deployment/gui/dp_gui_extensioncmdqueue.hxx | 8 +- .../source/deployment/gui/dp_gui_extlistbox.cxx | 39 +++++----- .../source/deployment/gui/dp_gui_extlistbox.hxx | 8 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 53 ++++++------- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 8 +- .../source/deployment/gui/dp_gui_updatedata.hxx | 7 +- .../source/deployment/gui/dp_gui_updatedialog.cxx | 53 ++++++------- .../source/deployment/gui/dp_gui_updatedialog.hxx | 5 +- .../deployment/gui/dp_gui_updateinstalldialog.cxx | 11 ++- .../deployment/gui/dp_gui_updateinstalldialog.hxx | 6 ++ .../deployment/registry/component/dp_component.cxx | 2 +- 16 files changed, 172 insertions(+), 237 deletions(-) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 6a9beae58ccd..c3eb81dfc3ec 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -163,7 +163,7 @@ void SilentCommandEnv::push( uno::Any const & rStatus ) if ( rStatus.hasValue() && ( rStatus >>= sText) ) { - if ( mnLevel == 1 ) + if ( mnLevel <= 2 ) mpDesktop->SetSplashScreenText( sText ); else mpDesktop->SetSplashScreenProgress( ++mnProgress ); diff --git a/desktop/source/deployment/gui/dp_gui.h b/desktop/source/deployment/gui/dp_gui.h index 85e6eaef3544..092b232ce96d 100644 --- a/desktop/source/deployment/gui/dp_gui.h +++ b/desktop/source/deployment/gui/dp_gui.h @@ -79,21 +79,18 @@ enum PackageState { REGISTERED, NOT_REGISTERED, AMBIGUOUS, NOT_AVAILABLE }; class SelectedPackage: public salhelper::SimpleReferenceObject { public: SelectedPackage() {} - SelectedPackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> &xPackage, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> &xPackageManager ) - : m_xPackage( xPackage ), - m_xPackageManager( xPackageManager ) + SelectedPackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> &xPackage) + : m_xPackage( xPackage ) {} virtual ~SelectedPackage(); ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> getPackage() const { return m_xPackage; } - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> getPackageManager() const { return m_xPackageManager; } + private: SelectedPackage(SelectedPackage &); // not defined void operator =(SelectedPackage &); // not defined ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage; - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> m_xPackageManager; }; } // namespace dp_gui diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 5f0cf3d91012..164bb833fd6d 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -74,8 +74,6 @@ #include "com/sun/star/uno/Any.hxx" #include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" - #include #include #include @@ -108,10 +106,8 @@ struct StrAllFiles : public rtl::StaticWithInit< const OUString, StrAllFiles > }; //------------------------------------------------------------------------------ -UpdateListEntry::UpdateListEntry( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager ) : - m_xPackage( xPackage ), - m_xPackageManager( xPackageManager ) +UpdateListEntry::UpdateListEntry( const uno::Reference< deployment::XPackage > &xPackage ) : + m_xPackage( xPackage ) {} //------------------------------------------------------------------------------ @@ -415,17 +411,13 @@ void ExtBoxWithBtns_Impl::MouseButtonDown( const MouseEvent& rMEvt ) switch( ShowPopupMenu( aMousePos, nPos ) ) { case CMD_NONE: break; - case CMD_ENABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackageManager, - GetEntryData( nPos )->m_xPackage, true ); + case CMD_ENABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, true ); break; - case CMD_DISABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackageManager, - GetEntryData( nPos )->m_xPackage, false ); + case CMD_DISABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, false ); break; - case CMD_UPDATE: m_pParent->updatePackage( GetEntryData( nPos )->m_xPackageManager, - GetEntryData( nPos )->m_xPackage ); + case CMD_UPDATE: m_pParent->updatePackage( GetEntryData( nPos )->m_xPackage ); break; - case CMD_REMOVE: m_pParent->removePackage( GetEntryData( nPos )->m_xPackageManager, - GetEntryData( nPos )->m_xPackage ); + case CMD_REMOVE: m_pParent->removePackage( GetEntryData( nPos )->m_xPackage ); break; } } @@ -529,9 +521,7 @@ IMPL_LINK( ExtBoxWithBtns_Impl, HandleEnableBtn, void*, EMPTYARG ) TEntry_Impl pEntry = GetEntryData( nActive ); const bool bEnable( pEntry->m_eState != REGISTERED ); - m_pParent->enablePackage( pEntry->m_xPackageManager, - pEntry->m_xPackage, - bEnable ); + m_pParent->enablePackage( pEntry->m_xPackage, bEnable ); } return 1; @@ -545,8 +535,7 @@ IMPL_LINK( ExtBoxWithBtns_Impl, HandleRemoveBtn, void*, EMPTYARG ) if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND ) { TEntry_Impl pEntry = GetEntryData( nActive ); - m_pParent->removePackage( pEntry->m_xPackageManager, - pEntry->m_xPackage ); + m_pParent->removePackage( pEntry->m_xPackage ); } return 1; @@ -592,21 +581,21 @@ String DialogHelper::getResourceString( USHORT id ) } //------------------------------------------------------------------------------ -bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackage > &xPackage ) { - if ( xPackageManager->getContext().equals( OUSTR("shared") ) ) + if ( xPackage->getRepositoryName().equals( OUSTR("shared") ) ) return true; else return false; } //------------------------------------------------------------------------------ -bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackageManager > &xPackageManager, +bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackage > &xPackage, Window *pParent, const USHORT nResID, bool &bHadWarning ) { - if ( !bHadWarning && IsSharedPkgMgr( xPackageManager ) ) + if ( !bHadWarning && IsSharedPkgMgr( xPackage ) ) { const ::vos::OGuard guard( Application::GetSolarMutex() ); WarningBox aInfoBox( pParent, getResId( nResID ) ); @@ -779,11 +768,10 @@ void ExtMgrDialog::setGetExtensionsURL( const ::rtl::OUString &rURL ) } //------------------------------------------------------------------------------ -long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager ) +long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage ) { m_aUpdateBtn.Enable( true ); - return m_pExtensionBox->addEntry( xPackage, xPackageManager ); + return m_pExtensionBox->addEntry( xPackage ); } //------------------------------------------------------------------------------ @@ -813,21 +801,20 @@ bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const } //------------------------------------------------------------------------------ -bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager, - const uno::Reference< deployment::XPackage > &xPackage, +bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, bool bEnable ) { - if ( !xPackageManager.is() || !xPackage.is() ) + if ( !xPackage.is() ) return false; if ( bEnable ) { - if ( ! continueOnSharedExtension( xPackageManager, this, RID_WARNINGBOX_ENABLE_SHARED_EXTENSION, m_bEnableWarning ) ) + if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_ENABLE_SHARED_EXTENSION, m_bEnableWarning ) ) return false; } else { - if ( ! continueOnSharedExtension( xPackageManager, this, RID_WARNINGBOX_DISABLE_SHARED_EXTENSION, m_bDisableWarning ) ) + if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_DISABLE_SHARED_EXTENSION, m_bDisableWarning ) ) return false; } @@ -837,35 +824,33 @@ bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackageMana } //------------------------------------------------------------------------------ -bool ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager, - const uno::Reference< deployment::XPackage > &xPackage ) +bool ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > &xPackage ) { - if ( !xPackageManager.is() || !xPackage.is() ) + if ( !xPackage.is() ) return false; - if ( !IsSharedPkgMgr( xPackageManager ) || m_bDeleteWarning ) + if ( !IsSharedPkgMgr( xPackage ) || m_bDeleteWarning ) { if ( ! removeExtensionWarn( xPackage->getDisplayName() ) ) return false; } - if ( ! continueOnSharedExtension( xPackageManager, this, RID_WARNINGBOX_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) ) + if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) ) return false; - m_pManager->removePackage( xPackageManager, xPackage ); + m_pManager->removePackage( xPackage ); return true; } //------------------------------------------------------------------------------ -bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager, - const uno::Reference< deployment::XPackage > &xPackage ) +bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > &xPackage ) { - if ( !xPackageManager.is() || !xPackage.is() ) + if ( !xPackage.is() ) return false; std::vector< TUpdateListEntry > vEntries; - TUpdateListEntry pEntry( new UpdateListEntry( xPackage, xPackageManager ) ); + TUpdateListEntry pEntry( new UpdateListEntry( xPackage ) ); vEntries.push_back( pEntry ); m_pManager->updatePackages( vEntries ); @@ -874,7 +859,7 @@ bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackageMana } //------------------------------------------------------------------------------ -uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker() { const uno::Any mode( static_cast< sal_Int16 >( ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE ) ); const uno::Reference< uno::XComponentContext > xContext( m_pManager->getContext() ); @@ -892,7 +877,7 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker( const uno::Reference< de t_string2string title2filter; OUString sDefaultFilter( StrAllFiles::get() ); - const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( xPackageManager->getSupportedPackageTypes() ); + const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( m_pManager->getExtensionManager()->getSupportedPackageTypes( OUSTR("user") ) ); for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos ) { @@ -1046,8 +1031,7 @@ IMPL_LINK( ExtMgrDialog, HandleAddBtn, void*, EMPTYARG ) { setBusy( true ); - uno::Reference< deployment::XPackageManager > xUserPkgMgr = m_pManager->getUserPkgMgr(); - uno::Sequence< OUString > aFileList = raiseAddPicker( xUserPkgMgr ); + uno::Sequence< OUString > aFileList = raiseAddPicker(); if ( aFileList.getLength() ) { @@ -1317,15 +1301,14 @@ UpdateRequiredDialog::~UpdateRequiredDialog() } //------------------------------------------------------------------------------ -long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager ) +long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage ) { // We will only add entries to the list with unsatisfied dependencies if ( !checkDependencies( xPackage ) ) { - m_bHasLockedEntries |= (bool) xPackageManager->isReadOnly(); + m_bHasLockedEntries |= m_pManager->isReadOnly( xPackage ); m_aUpdateBtn.Enable( true ); - return m_pExtensionBox->addEntry( xPackage, xPackageManager ); + return m_pExtensionBox->addEntry( xPackage ); } return 0; } @@ -1350,9 +1333,8 @@ void UpdateRequiredDialog::checkEntries() } //------------------------------------------------------------------------------ -bool UpdateRequiredDialog::enablePackage( const uno::Reference< deployment::XPackageManager > &, - const uno::Reference< deployment::XPackage > &xPackage, - bool bEnable ) +bool UpdateRequiredDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, + bool bEnable ) { m_pManager->enablePackage( xPackage, bEnable ); @@ -1476,8 +1458,7 @@ IMPL_LINK( UpdateRequiredDialog, HandleUpdateBtn, void*, EMPTYARG ) for ( sal_Int32 i = 0; i < nCount; ++i ) { TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( i ); - TUpdateListEntry pUpdateEntry( new UpdateListEntry( pEntry->m_xPackage, - pEntry->m_xPackageManager ) ); + TUpdateListEntry pUpdateEntry( new UpdateListEntry( pEntry->m_xPackage ) ); vUpdateEntries.push_back( pUpdateEntry ); } @@ -1738,7 +1719,7 @@ void UpdateRequiredDialog::disableAllEntries() for ( long nIndex = 0; nIndex < nCount; nIndex++ ) { TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( nIndex ); - enablePackage( pEntry->m_xPackageManager, pEntry->m_xPackage, false ); + enablePackage( pEntry->m_xPackage, false ); } setBusy( false ); diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index cadc127446ea..4c99d64740db 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -46,7 +46,6 @@ #include "com/sun/star/awt/XWindow.hpp" #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/ui/dialogs/XExecutableDialog.hpp" #include "com/sun/star/util/XModifyListener.hpp" @@ -82,16 +81,15 @@ public: virtual void updateProgress( const long nProgress ) = 0; virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0; - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & ) = 0; + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0; virtual void prepareChecking() = 0; virtual void checkEntries() = 0; static ResId getResId( USHORT nId ); static String getResourceString( USHORT id ); - static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &); - static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &, + static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &); + static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, Window *pParent, const USHORT nResID, bool &bHadWarning ); @@ -159,20 +157,16 @@ public: virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void setGetExtensionsURL( const ::rtl::OUString &rURL ); - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & ); - bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &); + bool enablePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); - bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + bool removePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + bool updatePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); virtual void prepareChecking(); virtual void checkEntries(); - ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker(); }; //============================================================================== @@ -234,18 +228,14 @@ public: virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void selectEntry( long nPos ); - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & ); - bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - bool bEnable ); - bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & ); + bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); + bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); virtual void prepareChecking(); virtual void checkEntries(); - ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker(); bool installForAllUsers( bool &bInstallForAll ) const; bool installExtensionWarn( const ::rtl::OUString &rExtensionURL ) const; diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 647c46b754c8..4c9357e03e9f 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -48,7 +48,6 @@ #include "com/sun/star/deployment/DeploymentException.hpp" #include "com/sun/star/deployment/UpdateInformationProvider.hpp" #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" #include "com/sun/star/task/XAbortChannel.hpp" #include "com/sun/star/task/XInteractionAbort.hpp" @@ -201,25 +200,18 @@ struct ExtensionCmd E_CMD_TYPE m_eCmdType; bool m_bWarnUser; OUString m_sExtensionURL; - uno::Reference< deployment::XPackageManager > m_xPackageManager; - uno::Reference< deployment::XPackage > m_xPackage; - std::vector< TUpdateListEntry > m_vExtensionList; + OUString m_sRepository; + uno::Reference< deployment::XPackage > m_xPackage; + std::vector< TUpdateListEntry > m_vExtensionList; ExtensionCmd( const E_CMD_TYPE eCommand, - const uno::Reference< deployment::XPackageManager > &rPackageManager, const OUString &rExtensionURL, + const OUString &rRepository, const bool bWarnUser ) : m_eCmdType( eCommand ), m_bWarnUser( bWarnUser ), m_sExtensionURL( rExtensionURL ), - m_xPackageManager( rPackageManager ) {}; - ExtensionCmd( const E_CMD_TYPE eCommand, - const uno::Reference< deployment::XPackageManager > &rPackageManager, - const uno::Reference< deployment::XPackage > &rPackage ) - : m_eCmdType( eCommand ), - m_bWarnUser( false ), - m_xPackageManager( rPackageManager ), - m_xPackage( rPackage ) {}; + m_sRepository( rRepository ) {}; ExtensionCmd( const E_CMD_TYPE eCommand, const uno::Reference< deployment::XPackage > &rPackage ) : m_eCmdType( eCommand ), @@ -242,11 +234,10 @@ public: TheExtensionManager *pManager, const uno::Reference< uno::XComponentContext > & rContext ); - void addExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const OUString &rExtensionURL, + void addExtension( const OUString &rExtensionURL, + const OUString &rRepository, const bool bWarnUser ); - void removeExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const uno::Reference< deployment::XPackage > &rPackage ); + void removeExtension( const uno::Reference< deployment::XPackage > &rPackage ); void enableExtension( const uno::Reference< deployment::XPackage > &rPackage, const bool bEnable ); void checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ); @@ -266,11 +257,10 @@ private: virtual void SAL_CALL onTerminated(); void _addExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, - const uno::Reference< deployment::XPackageManager > &xPackageManager, const OUString &rPackageURL, + const OUString &rRepository, const bool bWarnUser ); void _removeExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, - const uno::Reference< deployment::XPackageManager > &xPackageManager, const uno::Reference< deployment::XPackage > &xPackage ); void _enableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, const uno::Reference< deployment::XPackage > &xPackage ); @@ -645,8 +635,8 @@ ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper, } //------------------------------------------------------------------------------ -void ExtensionCmdQueue::Thread::addExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const ::rtl::OUString &rExtensionURL, +void ExtensionCmdQueue::Thread::addExtension( const ::rtl::OUString &rExtensionURL, + const ::rtl::OUString &rRepository, const bool bWarnUser ) { ::osl::MutexGuard aGuard( m_mutex ); @@ -657,7 +647,7 @@ void ExtensionCmdQueue::Thread::addExtension( const uno::Reference< deployment:: if ( rExtensionURL.getLength() ) { - TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ADD, rPackageManager, rExtensionURL, bWarnUser ) ); + TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ADD, rExtensionURL, rRepository, bWarnUser ) ); m_queue.push( pEntry ); m_eInput = START; @@ -666,8 +656,7 @@ void ExtensionCmdQueue::Thread::addExtension( const uno::Reference< deployment:: } //------------------------------------------------------------------------------ -void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const uno::Reference< deployment::XPackage > &rPackage ) +void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deployment::XPackage > &rPackage ) { ::osl::MutexGuard aGuard( m_mutex ); @@ -675,9 +664,9 @@ void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deploymen if ( m_bStopped ) return; - if ( rPackageManager.is() && rPackage.is() ) + if ( rPackage.is() ) { - TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::REMOVE, rPackageManager, rPackage ) ); + TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::REMOVE, rPackage ) ); m_queue.push( pEntry ); m_eInput = START; @@ -811,10 +800,10 @@ void ExtensionCmdQueue::Thread::execute() switch ( pEntry->m_eCmdType ) { case ExtensionCmd::ADD : - _addExtension( currentCmdEnv, pEntry->m_xPackageManager, pEntry->m_sExtensionURL, pEntry->m_bWarnUser ); + _addExtension( currentCmdEnv, pEntry->m_sExtensionURL, pEntry->m_sRepository, pEntry->m_bWarnUser ); break; case ExtensionCmd::REMOVE : - _removeExtension( currentCmdEnv, pEntry->m_xPackageManager, pEntry->m_xPackage ); + _removeExtension( currentCmdEnv, pEntry->m_xPackage ); break; case ExtensionCmd::ENABLE : _enableExtension( currentCmdEnv, pEntry->m_xPackage ); @@ -904,8 +893,8 @@ void ExtensionCmdQueue::Thread::execute() //------------------------------------------------------------------------------ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, - const uno::Reference< deployment::XPackageManager > &xPackageManager, const OUString &rPackageURL, + const OUString &rRepository, const bool bWarnUser ) { //check if we have a string in anyTitle. For example "unopkg gui \" caused anyTitle to be void @@ -928,17 +917,16 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv } rCmdEnv->setWarnUser( bWarnUser ); - uno::Reference< task::XAbortChannel > xAbortChannel( xPackageManager->createAbortChannel() ); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); OUString sTitle = searchAndReplaceAll( m_sAddingPackages, OUSTR("%EXTENSION_NAME"), sName ); rCmdEnv->progressSection( sTitle, xAbortChannel ); try { - OUString sPackageManager = xPackageManager->getContext(); - uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); uno::Reference< deployment::XPackage > xPackage( xExtMgr->addExtension(rPackageURL, uno::Sequence(), - sPackageManager, xAbortChannel, rCmdEnv.get() ) ); + rRepository, xAbortChannel, rCmdEnv.get() ) ); OSL_ASSERT( xPackage.is() ); } catch ( ucb::CommandFailedException & ) @@ -956,19 +944,17 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv //------------------------------------------------------------------------------ void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, - const uno::Reference< deployment::XPackageManager > &xPackageManager, const uno::Reference< deployment::XPackage > &xPackage ) { - uno::Reference< task::XAbortChannel > xAbortChannel( xPackageManager->createAbortChannel() ); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); OUString sTitle = searchAndReplaceAll( m_sRemovingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); rCmdEnv->progressSection( sTitle, xAbortChannel ); OUString id( dp_misc::getIdentifier( xPackage ) ); try { - OUString sPackageManager = xPackageManager->getContext(); - uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); - xExtMgr->removeExtension( id, xPackage->getName(), sPackageManager, xAbortChannel, rCmdEnv.get() ); + xExtMgr->removeExtension( id, xPackage->getName(), xPackage->getRepositoryName(), xAbortChannel, rCmdEnv.get() ); } catch ( deployment::DeploymentException & ) {} @@ -1120,17 +1106,16 @@ ExtensionCmdQueue::~ExtensionCmdQueue() { stop(); } -void ExtensionCmdQueue::addExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const ::rtl::OUString & extensionURL, +void ExtensionCmdQueue::addExtension( const ::rtl::OUString & extensionURL, + const ::rtl::OUString & repository, const bool bWarnUser ) { - m_thread->addExtension( rPackageManager, extensionURL, bWarnUser ); + m_thread->addExtension( extensionURL, repository, bWarnUser ); } -void ExtensionCmdQueue::removeExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const uno::Reference< deployment::XPackage > &rPackage ) +void ExtensionCmdQueue::removeExtension( const uno::Reference< deployment::XPackage > &rPackage ) { - m_thread->removeExtension( rPackageManager, rPackage ); + m_thread->removeExtension( rPackage ); } void ExtensionCmdQueue::enableExtension( const uno::Reference< deployment::XPackage > &rPackage, diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx index f984c71c6c1c..69ad7da24769 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx @@ -40,7 +40,6 @@ /// @HTML namespace com { namespace sun { namespace star { - namespace deployment { class XPackageManager; } namespace task { class XInteractionRequest; } namespace uno { class XComponentContext; } } } } @@ -78,11 +77,10 @@ public: /** */ - void addExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &rPackageManager, - const ::rtl::OUString &rExtensionURL, + void addExtension( const ::rtl::OUString &rExtensionURL, + const ::rtl::OUString &rRepository, const bool bWarnUser ); - void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &rPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); + void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); void enableExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage, const bool bEnable ); void checkForUpdates( const std::vector< TUpdateListEntry > &vList ); diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 7d616b103c21..18911ce63ea2 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -44,6 +44,10 @@ #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) +#define USER_PACKAGE_MANAGER OUSTR("user") +#define SHARED_PACKAGE_MANAGER OUSTR("shared") +#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") + using namespace ::com::sun::star; namespace dp_gui { @@ -52,10 +56,9 @@ namespace dp_gui { // struct Entry_Impl //------------------------------------------------------------------------------ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager, - PackageState eState ) : + const PackageState eState, const bool bReadOnly ) : m_bActive( false ), - m_bLocked( false ), + m_bLocked( bReadOnly ), m_bHasOptions( false ), m_bShared( false ), m_bUser( false ), @@ -65,8 +68,7 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_bHasButtons( false ), m_eState( eState ), m_pPublisher( NULL ), - m_xPackage( xPackage ), - m_xPackageManager( xPackageManager ) + m_xPackage( xPackage ) { m_sTitle = xPackage->getDisplayName(); m_sVersion = xPackage->getVersion(); @@ -87,8 +89,6 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, else m_aIconHC = m_aIcon; - m_bLocked = m_xPackageManager->isReadOnly(); - if ( eState == AMBIGUOUS ) m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS ); else if ( eState == NOT_REGISTERED ) @@ -108,14 +108,11 @@ StringCompare Entry_Impl::CompareTo( const CollatorWrapper *pCollator, const TEn eCompare = m_sVersion.CompareTo( pEntry->m_sVersion ); if ( eCompare == COMPARE_EQUAL ) { - if ( m_xPackageManager != pEntry->m_xPackageManager ) - { - sal_Int32 nCompare = m_xPackageManager->getContext().compareTo( pEntry->m_xPackageManager->getContext() ); - if ( nCompare < 0 ) - eCompare = COMPARE_LESS; - else if ( nCompare > 0 ) - eCompare = COMPARE_GREATER; - } + sal_Int32 nCompare = m_xPackage->getRepositoryName().compareTo( pEntry->m_xPackage->getRepositoryName() ); + if ( nCompare < 0 ) + eCompare = COMPARE_LESS; + else if ( nCompare > 0 ) + eCompare = COMPARE_GREATER; } } return eCompare; @@ -955,13 +952,13 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl pEntry, const long nStar } //------------------------------------------------------------------------------ -long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager ) +long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage ) { - long nPos = 0; + long nPos = 0; PackageState eState = m_pManager->getPackageState( xPackage ); + bool bLocked = m_pManager->isReadOnly( xPackage ); - TEntry_Impl pEntry( new Entry_Impl( xPackage, xPackageManager, eState ) ); + TEntry_Impl pEntry( new Entry_Impl( xPackage, eState, bLocked ) ); xPackage->addEventListener( uno::Reference< lang::XEventListener > ( m_xRemoveListener, uno::UNO_QUERY ) ); ::osl::ClearableMutexGuard guard(m_entriesMutex); @@ -982,8 +979,8 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & } pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bUser = ( m_pManager->getUserPkgMgr() == xPackageManager ); - pEntry->m_bShared = !pEntry->m_bUser && ( m_pManager->getSharedPkgMgr() == xPackageManager ); + pEntry->m_bUser = xPackage->getRepositoryName().equals( USER_PACKAGE_MANAGER ); + pEntry->m_bShared = xPackage->getRepositoryName().equals( SHARED_PACKAGE_MANAGER ); pEntry->m_bNew = m_bInCheckMode; //access to m_nActive must be guarded diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx index 1ea3d0d72fcc..0f56d022492b 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -38,7 +38,6 @@ #include "com/sun/star/lang/Locale.hpp" #include "com/sun/star/lang/XEventListener.hpp" #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" #include @@ -86,11 +85,9 @@ struct Entry_Impl svt::FixedHyperlink *m_pPublisher; ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage; - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> m_xPackageManager; Entry_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - PackageState eState ); + const PackageState eState, const bool bReadOnly ); ~Entry_Impl(); StringCompare CompareTo( const CollatorWrapper *pCollator, const TEntry_Impl pEntry ) const; @@ -208,8 +205,7 @@ public: //----------------- virtual void selectEntry( const long nPos ); - long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void updateEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void removeEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index cd37f07729bb..65a1bf021d29 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -35,8 +35,6 @@ #include "toolkit/helper/vclunohelper.hxx" #include "com/sun/star/beans/XPropertySet.hpp" -#include "com/sun/star/deployment/XPackageManagerFactory.hpp" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" #include "dp_gui_dialog2.hxx" #include "dp_gui_extensioncmdqueue.hxx" @@ -74,17 +72,8 @@ TheExtensionManager::TheExtensionManager( Window *pParent, m_pExtMgrDialog( NULL ), m_pUpdReqDialog( NULL ) { - m_sPackageManagers.realloc(3); - m_sPackageManagers[0] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( USER_PACKAGE_MANAGER ); - m_sPackageManagers[1] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( SHARED_PACKAGE_MANAGER ); - m_sPackageManagers[2] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( BUNDLED_PACKAGE_MANAGER ); - - for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i ) - { - m_sPackageManagers[i]->addModifyListener( this ); - } - m_xExtensionManager = deployment::ExtensionManager::get( xContext ); + m_xExtensionManager->addModifyListener( this ); uno::Reference< lang::XMultiServiceFactory > xConfig( xContext->getServiceManager()->createInstanceWithContext( @@ -241,7 +230,7 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; if ( xPackage.is() ) { - TUpdateListEntry pEntry( new UpdateListEntry( xPackage, m_sPackageManagers[j] ) ); + TUpdateListEntry pEntry( new UpdateListEntry( xPackage ) ); vEntries.push_back( pEntry ); } } @@ -261,10 +250,9 @@ bool TheExtensionManager::enablePackage( const uno::Reference< deployment::XPack } //------------------------------------------------------------------------------ -bool TheExtensionManager::removePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager, - const uno::Reference< deployment::XPackage > &xPackage ) +bool TheExtensionManager::removePackage( const uno::Reference< deployment::XPackage > &xPackage ) { - m_pExecuteCmdQueue->removeExtension( xPackageManager, xPackage ); + m_pExecuteCmdQueue->removeExtension( xPackage ); return true; } @@ -285,22 +273,20 @@ bool TheExtensionManager::installPackage( const OUString &rPackageURL, bool bWar createDialog( false ); - uno::Reference< deployment::XPackageManager > xUserPkgMgr = getUserPkgMgr(); - uno::Reference< deployment::XPackageManager > xSharedPkgMgr = getSharedPkgMgr(); - bool bInstall = true; bool bInstallForAll = false; - if ( !bWarnUser && ! xSharedPkgMgr->isReadOnly() ) + // DV! missing function is read only repository from extension manager + if ( !bWarnUser && ! m_xExtensionManager->isReadOnlyRepository( SHARED_PACKAGE_MANAGER ) ) bInstall = getDialogHelper()->installForAllUsers( bInstallForAll ); if ( !bInstall ) return false; if ( bInstallForAll ) - m_pExecuteCmdQueue->addExtension( xSharedPkgMgr, rPackageURL, false ); + m_pExecuteCmdQueue->addExtension( rPackageURL, SHARED_PACKAGE_MANAGER, false ); else - m_pExecuteCmdQueue->addExtension( xUserPkgMgr, rPackageURL, bWarnUser ); + m_pExecuteCmdQueue->addExtension( rPackageURL, USER_PACKAGE_MANAGER, bWarnUser ); return true; } @@ -357,7 +343,7 @@ void TheExtensionManager::createPackageList() if ( xPackage.is() ) { PackageState eState = getPackageState( xPackage ); - getDialogHelper()->addPackageToList( xPackage, m_sPackageManagers[j] ); + getDialogHelper()->addPackageToList( xPackage ); // When the package is enabled, we can stop here, otherwise we have to look for // another version of this package if ( ( eState == REGISTERED ) || ( eState == NOT_AVAILABLE ) ) @@ -395,6 +381,17 @@ PackageState TheExtensionManager::getPackageState( const uno::Reference< deploym } } +//------------------------------------------------------------------------------ +bool TheExtensionManager::isReadOnly( const uno::Reference< deployment::XPackage > &xPackage ) const +{ + if ( m_xExtensionManager.is() && xPackage.is() ) + { + return m_xExtensionManager->isReadOnlyRepository( xPackage->getRepositoryName() ); + } + else + return true; +} + //------------------------------------------------------------------------------ // The function investigates if the extension supports options. bool TheExtensionManager::supportsOptions( const uno::Reference< deployment::XPackage > &xPackage ) const @@ -509,13 +506,9 @@ void TheExtensionManager::notifyTermination( ::lang::EventObject const & rEvt ) void TheExtensionManager::modified( ::lang::EventObject const & rEvt ) throw ( uno::RuntimeException ) { - uno::Reference< deployment::XPackageManager > xPackageManager( rEvt.Source, uno::UNO_QUERY ); - if ( xPackageManager.is() ) - { - getDialogHelper()->prepareChecking(); - createPackageList(); - getDialogHelper()->checkEntries(); - } + getDialogHelper()->prepareChecking(); + createPackageList(); + getDialogHelper()->checkEntries(); } //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index 2b8f86de9955..6605b5907dab 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -33,7 +33,6 @@ #include "cppuhelper/implbase2.hxx" #include "com/sun/star/container/XNameAccess.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" #include "com/sun/star/deployment/XExtensionManager.hpp" #include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/frame/XDesktop.hpp" @@ -60,7 +59,6 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > m_xDesktop; ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> > m_sPackageManagers; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xNameAccessNodes; ::std::auto_ptr< ExtensionCmdQueue > m_pExecuteCmdQueue; @@ -100,8 +98,7 @@ public: bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); - bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); bool installPackage( const ::rtl::OUString &rPackageURL, bool bWarnUser = false ); bool queryTermination(); @@ -111,9 +108,8 @@ public: bool supportsOptions( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; PackageState getPackageState( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext; } - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getUserPkgMgr() const { return m_sPackageManagers[0]; } - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getSharedPkgMgr() const { return m_sPackageManagers[1]; } ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const { return m_xExtensionManager; } + bool isReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; //----------------- static ::rtl::Reference get( diff --git a/desktop/source/deployment/gui/dp_gui_updatedata.hxx b/desktop/source/deployment/gui/dp_gui_updatedata.hxx index dda6126f70d0..2082b92e923a 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedata.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedata.hxx @@ -35,7 +35,6 @@ namespace com { namespace sun { namespace star { namespace deployment { - class XPackageManager; class XPackage; }}}} namespace com { namespace sun { namespace star { namespace xml { namespace dom { @@ -48,10 +47,8 @@ namespace dp_gui { struct UpdateListEntry { ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage; - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> m_xPackageManager; - UpdateListEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + UpdateListEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); ~UpdateListEntry(); }; @@ -61,8 +58,6 @@ typedef ::boost::shared_ptr< UpdateListEntry > TUpdateListEntry; struct UpdateData { ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > aInstalledPackage; - - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > aPackageManager; // The content of the update information ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo; //The URL of the locally downloaded extension. It will only be set if there were no errors diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index 61479f799e6f..fca7d97c798a 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -54,7 +54,8 @@ #include "com/sun/star/deployment/DeploymentException.hpp" #include "com/sun/star/deployment/UpdateInformationProvider.hpp" #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/XUpdateInformationProvider.hpp" #include "com/sun/star/frame/XDesktop.hpp" #include "com/sun/star/frame/XDispatch.hpp" @@ -240,12 +241,9 @@ private: struct Entry { explicit Entry( css::uno::Reference< css::deployment::XPackage > const & thePackage, - css::uno::Reference< css::deployment::XPackageManager > const & - thePackageManager, rtl::OUString const & theVersion); css::uno::Reference< css::deployment::XPackage > package; - css::uno::Reference< css::deployment::XPackageManager > packageManager; rtl::OUString version; css::uno::Reference< css::xml::dom::XNode > info; }; @@ -271,14 +269,10 @@ private: void handle( css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::deployment::XPackageManager > const & - packageManager, Map * map); bool update( css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::deployment::XPackageManager > const & - packageManager, css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const; css::uno::Reference< css::uno::XComponentContext > m_context; @@ -333,11 +327,8 @@ void UpdateDialog::Thread::stop() { UpdateDialog::Thread::Entry::Entry( css::uno::Reference< css::deployment::XPackage > const & thePackage, - css::uno::Reference< css::deployment::XPackageManager > const & - thePackageManager, rtl::OUString const & theVersion): package(thePackage), - packageManager(thePackageManager), version(theVersion) {} @@ -356,7 +347,6 @@ void UpdateDialog::Thread::execute() for ( ITER iIndex = m_vExtensionList.begin(); iIndex < m_vExtensionList.end(); ++iIndex ) { css::uno::Reference< css::deployment::XPackage > p = (*iIndex)->m_xPackage; - css::uno::Reference< css::deployment::XPackageManager > m = (*iIndex)->m_xPackageManager; if ( p.is() ) { { @@ -365,7 +355,7 @@ void UpdateDialog::Thread::execute() return; } } - handle( p, m, &map ); + handle( p, &map ); } } @@ -399,9 +389,7 @@ void UpdateDialog::Thread::execute() } for (Map::const_iterator i(map.begin()); i != map.end(); ++i) { if (i->second.info.is() && - !update( - i->second.package, i->second.packageManager, - i->second.info)) + !update( i->second.package, i->second.info )) { break; } @@ -468,8 +456,6 @@ UpdateDialog::Thread::getUpdateInformation( void UpdateDialog::Thread::handle( css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::deployment::XPackageManager > const & - packageManager, Map * map) { rtl::OUString id(dp_misc::getIdentifier(package)); @@ -478,7 +464,7 @@ void UpdateDialog::Thread::handle( if (urls.getLength() == 0) { map->insert( Map::value_type( - id, Entry(package, packageManager, package->getVersion()))); + id, Entry(package, package->getVersion()))); } else { css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > infos(getUpdateInformation(package, urls, id)); @@ -504,18 +490,15 @@ void UpdateDialog::Thread::handle( } } if (latestIndex != -1) { - update( - package, packageManager, - css::uno::Reference< css::xml::dom::XNode >( - infos[latestIndex], css::uno::UNO_QUERY_THROW)); + update( package, + css::uno::Reference< css::xml::dom::XNode >( + infos[latestIndex], css::uno::UNO_QUERY_THROW)); } } } bool UpdateDialog::Thread::update( css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::deployment::XPackageManager > const & - packageManager, css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const { dp_misc::DescriptionInfoset infoset(m_context, updateInfo); @@ -529,7 +512,7 @@ bool UpdateDialog::Thread::update( for (sal_Int32 i = 0; i < ds.getLength(); ++i) { du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]); } - du.permission = ! packageManager->isReadOnly(); + du.permission = ! m_dialog.isReadOnly( package ); const ::boost::optional< ::rtl::OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL()); rtl::OUStringBuffer b(package->getDisplayName()); b.append(static_cast< sal_Unicode >(' ')); @@ -559,7 +542,6 @@ bool UpdateDialog::Thread::update( { dp_gui::UpdateData data; data.aInstalledPackage = package; - data.aPackageManager = packageManager; data.aUpdateInfo = updateInfo; if (updateWebsiteURL) data.sWebsiteURL = *updateWebsiteURL; @@ -626,6 +608,9 @@ UpdateDialog::UpdateDialog( // m_extensionManagerDialog(extensionManagerDialog) { OSL_ASSERT(updateData != NULL); + + m_xExtensionManager = css::deployment::ExtensionManager::get( context ); + css::uno::Reference< css::awt::XToolkit > toolkit; try { toolkit = css::uno::Reference< css::awt::XToolkit >( @@ -1055,6 +1040,16 @@ bool UpdateDialog::showDescription( const String& rDescription, bool bWithPublis return true; } +bool UpdateDialog::isReadOnly( const css::uno::Reference< css::deployment::XPackage > &xPackage ) const +{ + if ( m_xExtensionManager.is() && xPackage.is() ) + { + return m_xExtensionManager->isReadOnlyRepository( xPackage->getRepositoryName() ); + } + else + return true; +} + IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) { rtl::OUStringBuffer b; @@ -1233,10 +1228,10 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) typedef ::std::vector::const_iterator CIT; for (CIT i = m_enabledUpdates.begin(); i < m_enabledUpdates.end(); i++) { - OSL_ASSERT(i->aPackageManager.is()); + OSL_ASSERT(i->aInstalledPackage.is()); //If the user has no write access to the shared folder then the update //for a shared extension is disable, that is it cannot be in m_enabledUpdates - OSL_ASSERT(i->aPackageManager->isReadOnly() == sal_False); + OSL_ASSERT(isReadOnly(i->aInstalledPackage) == sal_False); #if 0 // TODO: check! OSL_ASSERT(m_extensionManagerDialog.get()); diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx index 1a8484e2c20f..1e72b22a68c7 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx @@ -60,7 +60,8 @@ class Window; namespace com { namespace sun { namespace star { namespace awt { class XThrobber; } - namespace deployment { class XPackageManager; } + namespace deployment { class XExtensionManager; + class XPackage; } namespace uno { class XComponentContext; } } } } @@ -171,6 +172,7 @@ private: bool showDescription( ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & aUpdateInfo); bool showDescription( const String& rDescription, bool bWithPublisher ); + bool isReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; DECL_LINK(selectionHandler, void *); DECL_LINK(allHandler, void *); @@ -214,6 +216,7 @@ private: std::vector< UpdateDialog::SpecificError > m_specificErrors; 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; diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index f607713118f0..f2f8b8b0d6e2 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -54,7 +54,8 @@ #include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp" #include "com/sun/star/ucb/XCommandEnvironment.hpp" #include "com/sun/star/ucb/XProgressHandler.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/XUpdateInformationProvider.hpp" #include "com/sun/star/deployment/DependencyException.hpp" #include "com/sun/star/deployment/LicenseException.hpp" @@ -257,6 +258,8 @@ UpdateInstallDialog::UpdateInstallDialog( { FreeResource(); + m_xExtensionManager = css::deployment::ExtensionManager::get( xCtx ); + m_cancel.SetClickHdl(LINK(this, UpdateInstallDialog, cancelHandler)); m_mle_info.EnableCursor(FALSE); if ( ! dp_misc::office_is_running()) @@ -496,7 +499,7 @@ void UpdateInstallDialog::Thread::installExtensions() if (curData.sLocalURL.getLength() == 0) continue; cssu::Reference< css::task::XAbortChannel > xAbortChannel( - curData.aPackageManager->createAbortChannel() ); + curData.aInstalledPackage->createAbortChannel() ); { vos::OGuard g(Application::GetSolarMutex()); if (m_stop) { @@ -504,9 +507,9 @@ void UpdateInstallDialog::Thread::installExtensions() } m_abort = xAbortChannel; } - xPackage = curData.aPackageManager->addPackage( + xPackage = m_dialog.getExtensionManager()->addExtension( curData.sLocalURL, css::uno::Sequence(), - OUString(), xAbortChannel, m_updateCmdEnv.get()); + curData.aInstalledPackage->getRepositoryName(), xAbortChannel, m_updateCmdEnv.get()); } catch (css::deployment::DeploymentException & de) { diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx index c3d01c8ee6d9..c0e64a8028e8 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx @@ -41,6 +41,9 @@ #include "dp_gui_autoscrolledit.hxx" /// @HTML +namespace com { namespace sun { namespace star { namespace deployment { + class XExtensionManager; +}}}} namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; }}}} @@ -102,9 +105,12 @@ private: }; void setError(INSTALL_ERROR err, ::rtl::OUString const & sExtension, ::rtl::OUString const & exceptionMessage); void setError(::rtl::OUString const & exceptionMessage); + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const + { return m_xExtensionManager; } rtl::Reference< Thread > m_thread; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xComponentContext; + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; //Signals that an error occurred during download and installation bool m_bError; bool m_bNoEntry; diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index b3b8a8249994..edb53d134c8b 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -1489,7 +1489,7 @@ BackendImpl::TypelibraryPackageImpl::isRegistered_( void BackendImpl::TypelibraryPackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, - bool startup, + bool /*startup*/, ::rtl::Reference const &, Reference const & xCmdEnv ) { -- cgit From b74d54d62a0162c490c5fe833f937120c8795680 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 28 Apr 2010 16:47:08 +0200 Subject: cws tl79: include fixed --- sfx2/inc/sfx2/securitypage.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfx2/inc/sfx2/securitypage.hxx b/sfx2/inc/sfx2/securitypage.hxx index 616f11d3b6d1..8b2ca43fc945 100755 --- a/sfx2/inc/sfx2/securitypage.hxx +++ b/sfx2/inc/sfx2/securitypage.hxx @@ -27,7 +27,7 @@ #ifndef _SECURITYPAGE_HXX_ #define _SECURITYPAGE_HXX_ -#include "sfx2/tabdlg.hxx " +#include "sfx2/tabdlg.hxx" #include -- cgit From 65cf934efc6f8958d9c024ee965685cfd6cac704 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 29 Apr 2010 13:02:24 +0200 Subject: cws tl79: fixed problems after merging with DEV300_m77 --- sfx2/inc/sfx2/htmlmode.hxx | 68 +++++++++++++++++++++++++++++++++++++ sfx2/inc/sfx2/securitypage.hxx | 1 + sfx2/inc/sfx2/sfxsids.hrc | 26 ++++++++++++++ sfx2/source/dialog/dinfdlg.cxx | 1 + sfx2/source/dialog/securitypage.cxx | 15 ++++---- svx/inc/htmlmode.hxx | 23 +------------ svx/inc/svx/svxids.hrc | 43 ++++++++++++----------- 7 files changed, 129 insertions(+), 48 deletions(-) create mode 100644 sfx2/inc/sfx2/htmlmode.hxx diff --git a/sfx2/inc/sfx2/htmlmode.hxx b/sfx2/inc/sfx2/htmlmode.hxx new file mode 100644 index 000000000000..51f341c5c3c0 --- /dev/null +++ b/sfx2/inc/sfx2/htmlmode.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SFX_HTMLMODE_HXX_ +#define _SFX_HTMLMODE_HXX_ + + +#define HTMLMODE_ON 0x0001 +#define HTMLMODE_PARA_BORDER 0x0002 /* Absatzumrandungen */ +#define HTMLMODE_PARA_DISTANCE 0x0004 /* bestimmte Absatzabstaende */ +#define HTMLMODE_SMALL_CAPS 0x0008 /* Kapitaelchen */ +#define HTMLMODE_FRM_COLUMNS 0x0010 /* spaltige Rahmen */ +#define HTMLMODE_SOME_STYLES 0x0020 /* mind. MS IE */ +#define HTMLMODE_FULL_STYLES 0x0040 /* == SW */ +#define HTMLMODE_BLINK 0x0080 /* blinkende Zeichen*/ +#define HTMLMODE_PARA_BLOCK 0x0100 /* Blocksatz */ +#define HTMLMODE_DROPCAPS 0x0200 /* Initialen*/ +#define HTMLMODE_FIRSTLINE 0x0400 /* Erstzeileneinzug mit Spacer == NS 3.0 */ +#define HTMLMODE_GRAPH_POS 0x0800 /* Grafikpositionen Hintergrund */ +#define HTMLMODE_FULL_ABS_POS 0x1000 /* abs. Rahmenpositionierung */ +#define HTMLMODE_SOME_ABS_POS 0x2000 /* abs. Rahmenpositionierung vollst.*/ +#define HTMLMODE_RESERVED1 0x4000 +#define HTMLMODE_RESERVED0 0x8000 + + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/sfx2/inc/sfx2/securitypage.hxx b/sfx2/inc/sfx2/securitypage.hxx index 8b2ca43fc945..d25f0ee0b967 100755 --- a/sfx2/inc/sfx2/securitypage.hxx +++ b/sfx2/inc/sfx2/securitypage.hxx @@ -28,6 +28,7 @@ #define _SECURITYPAGE_HXX_ #include "sfx2/tabdlg.hxx" +#include "sfx2/htmlmode.hxx" #include diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index bc4c11b53184..74210ba680ef 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -155,6 +155,7 @@ #define SID_RELOAD (SID_SFX_START + 508) #define SID_PRINTDOCDIRECT (SID_SFX_START + 509) #define SID_PICKLIST (SID_SFX_START + 510) +#define SID_ATTR_XWINDOW (SID_SFX_START + 777) #define SID_PLUGIN_MODE (SID_SFX_START + 827) #define SID_EXPORTDOC (SID_SFX_START + 829) #define SID_EXPORTDOCASPDF (SID_SFX_START + 1673) @@ -998,5 +999,30 @@ #endif // #ifndef _SFXSIDS_HRC +//----------------------------------------------------------------------- +// SfxSecurityPage related stuff + +#define FN_EDIT2 (SID_SW_START + 1800) +#define FN_REDLINE_PROTECT (FN_EDIT2 + 23) +#define FN_REDLINE_ON (FN_EDIT2 + 25) + +#define SID_HTML_MODE (SID_SVX_START + 414) + +// Calc-Id's used for SfxSecurityPage +#ifndef SC_FUNCTION_START +#define SC_FUNCTION_START (SID_SC_START + 200) +#endif +#ifndef FILE_MENU_END +#define FILE_MENU_END (SC_FUNCTION_START + 20) +#endif +#ifndef EDIT_MENU_START +#define EDIT_MENU_START (FILE_MENU_END) +#endif +#ifndef SC_VIEW_START +#define SC_VIEW_START (SID_SC_START) +#endif +#define FID_CHG_RECORD (EDIT_MENU_START + 18) +#define SID_CHG_PROTECT (SC_VIEW_START + 84) + // eof ------------------------------------------------------------------------ diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 1495a560965b..f8da760bc12d 100755 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sfx2.hxx" + #include #include #include diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index affebc8615cb..d6351143c51e 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -29,22 +29,23 @@ #include "precompiled_sfx2.hxx" #include "sfx2/securitypage.hxx" -#include "sfx2/sfx.hrc" + #include "securitypage.hrc" #include "sfxresid.hxx" +#include +#include +#include +#include +#include + #include #include #include #include -#include -#include -#include #include -#include -#include #include -#include +#include diff --git a/svx/inc/htmlmode.hxx b/svx/inc/htmlmode.hxx index a1c5bf0cdf11..dab1b5b1db70 100644 --- a/svx/inc/htmlmode.hxx +++ b/svx/inc/htmlmode.hxx @@ -27,28 +27,7 @@ #ifndef _SVX_HTMLMODE_HXX #define _SVX_HTMLMODE_HXX -// include --------------------------------------------------------------- - -// define ---------------------------------------------------------------- - -#define HTMLMODE_ON 0x0001 -#define HTMLMODE_PARA_BORDER 0x0002 /* Absatzumrandungen */ -#define HTMLMODE_PARA_DISTANCE 0x0004 /* bestimmte Absatzabstaende */ -#define HTMLMODE_SMALL_CAPS 0x0008 /* Kapitaelchen */ -#define HTMLMODE_FRM_COLUMNS 0x0010 /* spaltige Rahmen */ -#define HTMLMODE_SOME_STYLES 0x0020 /* mind. MS IE */ -#define HTMLMODE_FULL_STYLES 0x0040 /* == SW */ -#define HTMLMODE_BLINK 0x0080 /* blinkende Zeichen*/ -#define HTMLMODE_PARA_BLOCK 0x0100 /* Blocksatz */ -#define HTMLMODE_DROPCAPS 0x0200 /* Initialen*/ -#define HTMLMODE_FIRSTLINE 0x0400 /* Erstzeileneinzug mit Spacer == NS 3.0 */ -#define HTMLMODE_GRAPH_POS 0x0800 /* Grafikpositionen Hintergrund */ -#define HTMLMODE_FULL_ABS_POS 0x1000 /* abs. Rahmenpositionierung */ -#define HTMLMODE_SOME_ABS_POS 0x2000 /* abs. Rahmenpositionierung vollst.*/ -#define HTMLMODE_RESERVED1 0x4000 -#define HTMLMODE_RESERVED0 0x8000 - - +#include #endif diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc index ee31d4ee3964..780da532ddb0 100755 --- a/svx/inc/svx/svxids.hrc +++ b/svx/inc/svx/svxids.hrc @@ -182,7 +182,6 @@ #define RID_OFA_TP_INTERNATIONAL_IMPR (RID_OFA_START + 254) // 4 impress */ -#define SID_ATTR_XWINDOW (RID_OFA_START + 250) #define SID_ATTR_PARENTWINDOW (RID_OFA_START + 255) // -------------------------------------------------------------------------- @@ -343,18 +342,19 @@ // Calc-Id's // -------------------------------------------------------------------------- -#ifndef SC_FUNCTION_START -#define SC_FUNCTION_START (SID_SC_START + 200) -#endif -#ifndef FILE_MENU_END -#define FILE_MENU_END (SC_FUNCTION_START + 20) -#endif -#ifndef EDIT_MENU_START -#define EDIT_MENU_START (FILE_MENU_END) -#endif -#ifndef SC_VIEW_START -#define SC_VIEW_START (SID_SC_START) -#endif +//! moved to sfx2, still in use: +//#ifndef SC_FUNCTION_START +//#define SC_FUNCTION_START (SID_SC_START + 200) +//#endif +//#ifndef FILE_MENU_END +//#define FILE_MENU_END (SC_FUNCTION_START + 20) +//#endif +//#ifndef EDIT_MENU_START +//#define EDIT_MENU_START (FILE_MENU_END) +//#endif +//#ifndef SC_VIEW_START +//#define SC_VIEW_START (SID_SC_START) +//#endif #define SID_OUTLINE_HIDE (SID_SC_START + 329) #define SID_OUTLINE_SHOW (SID_SC_START + 330) @@ -366,8 +366,9 @@ #define SID_ATTR_SECIALCHAR (SID_SC_START + 581) #define SID_ATTR_SPECIALCHAR (SID_SC_START + 581) -#define FID_CHG_RECORD (EDIT_MENU_START + 18) -#define SID_CHG_PROTECT (SC_VIEW_START + 84) +//! moved to sfx2, still in use: +//#define FID_CHG_RECORD (EDIT_MENU_START + 18) +//#define SID_CHG_PROTECT (SC_VIEW_START + 84) // -------------------------------------------------------------------------- // Writer-Id's @@ -402,9 +403,10 @@ #define FN_PGPREVIEW (SID_SW_START + 1250) #define FN_SHOW_MULTIPLE_PAGES (FN_PGPREVIEW + 2) -#define FN_EDIT2 (SID_SW_START + 1800) -#define FN_REDLINE_PROTECT (FN_EDIT2 + 23) -#define FN_REDLINE_ON (FN_EDIT2 + 25) +//! moved to sfx2, still in use: +//#define FN_EDIT2 (SID_SW_START + 1800) +//#define FN_REDLINE_PROTECT (FN_EDIT2 + 23) +//#define FN_REDLINE_ON (FN_EDIT2 + 25) // -------------------------------------------------------------------------- // Svx-Id's @@ -748,7 +750,10 @@ #define SID_ATTR_3D_AMBIENTINTENSITY ( SID_SVX_START + 410 ) /* --> Slots mit --> koennen demnaechst entfallen ( heute 12.03.1998 ) */ #define SID_ATTR_3D_AMBIENTCOLOR ( SID_SVX_START + 411 ) #define SID_IMPORT_GRAPH_LINK ( SID_SVX_START + 412 ) -#define SID_HTML_MODE ( SID_SVX_START + 414 ) + +//! moved to sfx2, still in use: +//#define SID_HTML_MODE ( SID_SVX_START + 414 ) + #define SID_RULER_PROTECT ( SID_SVX_START + 415 ) //#define SID_INET_DLG ( SID_SVX_START + 416 ) -> sfxsids.hrc #define SID_COLOR_CONTROL ( SID_SVX_START + 417 ) -- cgit From 2005bc7b8b04f6eaa3d4636a3a1df1d6ff02f550 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 3 May 2010 09:08:38 +0200 Subject: cws tl78: build issues after merging with DEV300_m77 --- sfx2/source/view/viewfrm.cxx | 4 +--- uui/prj/build.lst | 2 +- uui/source/iahndl-authentication.cxx | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index aedd383b042a..c8cf7bd8c6c8 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -82,6 +82,7 @@ #include #include #include +#include #include #include @@ -183,9 +184,6 @@ static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteracti while ( !bResult && !bCancel ) { sal_Bool bMSType = !pFilter->IsOwnFormat(); - ::comphelper::DocPasswordRequestType nType = bMSType ? - ::comphelper::DocPasswordRequestType_MS : - ::comphelper::DocPasswordRequestType_STANDARD; ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( diff --git a/uui/prj/build.lst b/uui/prj/build.lst index 0ebacfcb814f..dbe31cb1b57e 100644 --- a/uui/prj/build.lst +++ b/uui/prj/build.lst @@ -1,4 +1,4 @@ -uu uui : l10n svtools NULL +uu uui : l10n vcl svtools NULL uu uui usr1 - all uu_mkout NULL uu uui\source nmake - all uu_source NULL uu uui\util nmake - all uu_util uu_source NULL diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index 7103fee29510..a84b1442a4ce 100755 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -428,8 +428,8 @@ executePasswordDialog( const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create(); - std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog( - pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen ) ); + AbstractPasswordToOpenModifyDialog *pTmp = pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen ); + std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog( pTmp ); rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); rInfo.SetPassword( pDialog->GetPasswordToOpen() ); -- cgit From 86e2dc0dcb9d79f1267dbd88d68bba6da3de871e Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 3 May 2010 11:51:05 +0200 Subject: jl152 import 263452 from native0jl:#i77196# fixed bundled extension help tree view, scripts in shared extensions... --- basic/source/inc/namecont.hxx | 14 +- basic/source/uno/namecont.cxx | 16 +- .../registry/component/dp_compbackenddb.cxx | 93 ++----- .../registry/component/dp_compbackenddb.hxx | 3 +- .../source/deployment/registry/dp_backenddb.cxx | 308 ++++++++++++++++++--- .../registry/executable/dp_executablebackenddb.cxx | 89 +----- .../registry/executable/dp_executablebackenddb.hxx | 18 +- .../deployment/registry/help/dp_helpbackenddb.cxx | 76 ++--- .../deployment/registry/help/dp_helpbackenddb.hxx | 7 +- .../deployment/registry/inc/dp_backenddb.hxx | 35 +++ .../registry/package/dp_extbackenddb.cxx | 65 ++--- .../registry/package/dp_extbackenddb.hxx | 3 +- .../deployment/registry/script/dp_script.cxx | 254 ++++++++--------- .../registry/script/dp_scriptbackenddb.cxx | 88 ++++++ .../registry/script/dp_scriptbackenddb.hxx | 76 +++++ .../source/deployment/registry/script/makefile.mk | 3 +- .../framework/container/UnoPkgContainer.java | 20 +- .../script/framework/provider/ScriptProvider.java | 18 +- scripting/source/provider/ActiveMSPList.cxx | 7 + scripting/source/provider/ActiveMSPList.hxx | 1 + xmlhelp/source/cxxhelp/provider/databases.cxx | 3 +- xmlhelp/source/treeview/tvread.cxx | 47 +++- xmlhelp/source/treeview/tvread.hxx | 9 + 23 files changed, 796 insertions(+), 457 deletions(-) create mode 100644 desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx create mode 100644 desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 2d24759d9b83..7cd2de701634 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,7 @@ #include #include -#include +#include #include class BasicManager; @@ -65,11 +66,12 @@ class BasicManager; namespace basic { -typedef ::cppu::WeakComponentImplHelper6< +typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::lang::XInitialization, ::com::sun::star::script::XStorageBasedLibraryContainer, ::com::sun::star::script::XLibraryContainerPassword, ::com::sun::star::script::XLibraryContainerExport, + ::com::sun::star::script::XLibraryContainer3, ::com::sun::star::container::XContainer, ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper; @@ -405,6 +407,12 @@ public: virtual ::rtl::OUString SAL_CALL getContainerLocationName() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL storeLibraries( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + //Methods XLibraryContainer3 + virtual ::rtl::OUString SAL_CALL getOriginalLibraryLinkURL( const ::rtl::OUString& Name ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + // Methods XLibraryContainer2 (base of XPersistentLibraryContainer) virtual sal_Bool SAL_CALL isLibraryLink( const ::rtl::OUString& Name ) throw (::com::sun::star::container::NoSuchElementException, @@ -541,6 +549,8 @@ private: ::rtl::OUString maLibInfoFileURL; ::rtl::OUString maStorageURL; ::rtl::OUString maUnexpandedStorageURL; + ::rtl::OUString maOrignialStorageURL; + sal_Bool mbLink; sal_Bool mbReadOnly; sal_Bool mbReadOnlyLink; diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index 7a6a771f85cc..e357b0e85f91 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -2169,6 +2169,7 @@ Reference< XNameAccess > SAL_CALL SfxLibraryContainer::createLibraryLink SfxLibrary* pNewLib = implCreateLibraryLink( Name, aLibInfoFileURL, aLibDirURL, ReadOnly ); pNewLib->maLibElementFileExtension = maLibElementFileExtension; pNewLib->maUnexpandedStorageURL = aUnexpandedStorageURL; + pNewLib->maOrignialStorageURL = StorageURL; OUString aInitFileName; uno::Reference< embed::XStorage > xDummyStor; @@ -2788,6 +2789,19 @@ OUString SfxLibraryContainer::expand_url( const OUString& url ) } } +//XLibraryContainer3 +OUString SAL_CALL SfxLibraryContainer::getOriginalLibraryLinkURL( const OUString& Name ) + throw (IllegalArgumentException, NoSuchElementException, RuntimeException) +{ + LibraryContainerMethodGuard aGuard( *this ); + SfxLibrary* pImplLib = getImplLib( Name ); + sal_Bool bLink = pImplLib->mbLink; + if( !bLink ) + throw IllegalArgumentException(); + OUString aRetStr = pImplLib->maOrignialStorageURL; + return aRetStr; +} + // Methods XServiceInfo ::sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) @@ -3381,7 +3395,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScri if( m_iSharedPackage == m_aSharedPackagesSeq.getLength() ) { - m_eState = END_REACHED; + m_eState = BUNDLED_EXTENSIONS; } else { diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx index 568ecca08138..898e7c931f6d 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -46,6 +46,7 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010" #define NS_PREFIX "comp" #define ROOT_ELEMENT_NAME "component-backend-db" +#define KEY_ELEMENT_NAME "component" namespace dp_registry { namespace backend { @@ -73,54 +74,31 @@ OUString ComponentBackendDb::getRootElementName() return OUSTR(ROOT_ELEMENT_NAME); } +OUString ComponentBackendDb::getKeyElementName() +{ + return OUSTR(KEY_ELEMENT_NAME); +} + void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url - OUString sExpression( - sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); - Reference _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif - Reference componentElement( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":component"))); - - componentElement->setAttribute(OUSTR("url"), url); - - Reference componentNode( - componentElement, UNO_QUERY_THROW); - - root->appendChild(componentNode); - - Reference javaTypeLibNode( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":java-type-library")), UNO_QUERY_THROW); - - componentNode->appendChild(javaTypeLibNode); - - Reference javaTypeLibValueNode( - doc->createTextNode(OUString::valueOf((sal_Bool) data.javaTypeLibrary)), - UNO_QUERY_THROW); - javaTypeLibNode->appendChild(javaTypeLibValueNode); + Reference componentNode = writeKeyElement(url); + writeSimpleElement(OUSTR("java-type-library"), + OUString::valueOf((sal_Bool) data.javaTypeLibrary), + componentNode); writeSimpleList( data.implementationNames, - sPrefix + OUSTR(":implementation-names"), - sPrefix + OUSTR(":name"), + OUSTR("implementation-names"), + OUSTR("name"), componentNode); writeVectorOfPair( data.singletons, - sPrefix + OUSTR(":singletons"), - sPrefix + OUSTR(":item"), - sPrefix + OUSTR(":key"), - sPrefix + OUSTR(":value"), + OUSTR("singletons"), + OUSTR("item"), + OUSTR("key"), + OUSTR("value"), componentNode); save(); @@ -134,50 +112,31 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data } } -void ComponentBackendDb::removeEntry(::rtl::OUString const & url) -{ - OUString sExpression( - OUSTR(NS_PREFIX) + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); - removeElement(sExpression); -} - ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & url) { try { - const OUString sPrefix = getNSPrefix(); ComponentBackendDb::Data retData; - const OUString sExpression( - sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); - //find the extension element that is to be removed - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); + Reference aNode = getKeyElement(url); if (aNode.is()) { - const OUString sExprJavaTypeLib(sPrefix + OUSTR(":java-type-library/text()")); - - Reference idValueNode = - xpathApi->selectSingleNode(aNode, sExprJavaTypeLib); - retData.javaTypeLibrary = - idValueNode->getNodeValue().equals(OUSTR("true")) ? true : false; + bool bJava = readSimpleElement(OUSTR("java-type-library"), aNode) + .equals(OUSTR("true")) ? true : false; + retData.javaTypeLibrary = bJava; retData.implementationNames = readList( aNode, - sPrefix + OUSTR(":implementation-names"), - sPrefix + OUSTR(":name")); + OUSTR("implementation-names"), + OUSTR("name")); retData.singletons = readVectorOfPair( aNode, - sPrefix + OUSTR(":singletons"), - sPrefix + OUSTR(":item"), - sPrefix + OUSTR(":key"), - sPrefix + OUSTR(":value")); + OUSTR("singletons"), + OUSTR("item"), + OUSTR("key"), + OUSTR("value")); } return retData; } diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx index 90ff41f2a4b8..b9a5ed737b7c 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx @@ -85,6 +85,7 @@ protected: virtual ::rtl::OUString getDbNSName(); virtual ::rtl::OUString getNSPrefix(); virtual ::rtl::OUString getRootElementName(); + virtual ::rtl::OUString getKeyElementName(); public: struct Data @@ -104,7 +105,7 @@ public: ::rtl::OUString const & url); void addEntry(::rtl::OUString const & url, Data const & data); - void removeEntry(::rtl::OUString const & url); + Data getEntry(::rtl::OUString const & url); diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index fe8b39b94d44..660c5ad80bf1 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -63,13 +63,13 @@ BackendDb::BackendDb( void BackendDb::save() { - Reference xDataSource(m_doc,css::uno::UNO_QUERY_THROW); + const Reference xDataSource(m_doc,css::uno::UNO_QUERY_THROW); ::rtl::ByteSequence bytes; xDataSource->setOutputStream(::xmlscript::createOutputStream(&bytes)); - Reference xDataControl(m_doc,css::uno::UNO_QUERY_THROW); + const Reference xDataControl(m_doc,css::uno::UNO_QUERY_THROW); xDataControl->start(); - Reference xData( + const Reference xData( ::xmlscript::createInputStream(bytes)); ::ucbhelper::Content ucbDb(m_urlDb, 0); ucbDb.writeStream(xData, true /*replace existing*/); @@ -79,7 +79,7 @@ css::uno::Reference BackendDb::getDocument() { if (!m_doc.is()) { - Reference xDocBuilder( + const Reference xDocBuilder( m_xContext->getServiceManager()->createInstanceWithContext( OUSTR("com.sun.star.xml.dom.DocumentBuilder"), m_xContext ), css::uno::UNO_QUERY); @@ -97,11 +97,10 @@ css::uno::Reference BackendDb::getDocument() { //Create a new document and insert some basic stuff m_doc = xDocBuilder->newDocument(); - Reference rootNode = + const Reference rootNode = m_doc->createElementNS(getDbNSName(), getNSPrefix() + OUSTR(":") + getRootElementName()); -// rootNode->setAttribute( -// OUSTR("xmlns"), getDbNSName()); + m_doc->appendChild(Reference( rootNode, UNO_QUERY_THROW)); save(); @@ -144,11 +143,11 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) { try { - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - Reference xpathApi = getXPathAPI(); + const Reference doc = getDocument(); + const Reference root = doc->getFirstChild(); + const Reference xpathApi = getXPathAPI(); //find the extension element that is to be removed - Reference aNode = + const Reference aNode = xpathApi->selectSingleNode(root, sXPathExpression); if (aNode.is()) @@ -159,7 +158,7 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) #if OSL_DEBUG_LEVEL > 0 //There must not be any other entry with the same url - Reference nextNode = + const Reference nextNode = xpathApi->selectSingleNode(root, sXPathExpression); OSL_ASSERT(! nextNode.is()); #endif @@ -171,7 +170,50 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) OUSTR("Extension Manager: failed to write data entry in backend db: ") + m_urlDb, 0, exc); } +} +void BackendDb::removeEntry(::rtl::OUString const & url) +{ + const OUString sKeyElement = getKeyElementName(); + const OUString sPrefix = getNSPrefix(); + ::rtl::OUStringBuffer sExpression(500); + sExpression.append(sPrefix); + sExpression.appendAscii(":"); + sExpression.append(sKeyElement); + sExpression.append(OUSTR("[@url = \"")); + sExpression.append(url); + sExpression.appendAscii("\"]"); + + removeElement(sExpression.makeStringAndClear()); +} + +Reference BackendDb::getKeyElement( + ::rtl::OUString const & url) +{ + try + { + const OUString sPrefix = getNSPrefix(); + const OUString sKeyElement = getKeyElementName(); + ::rtl::OUStringBuffer sExpression(500); + sExpression.append(sPrefix); + sExpression.appendAscii(":"); + sExpression.append(sKeyElement); + sExpression.append(OUSTR("[@url = \"")); + sExpression.append(url); + sExpression.appendAscii("\"]"); + + const Reference doc = getDocument(); + const Reference root = doc->getFirstChild(); + const Reference xpathApi = getXPathAPI(); + return xpathApi->selectSingleNode(root, sExpression.makeStringAndClear()); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read key element in backend db: ") + + m_urlDb, 0, exc); + } } //Only writes the data if there is at least one entry @@ -188,11 +230,12 @@ void BackendDb::writeVectorOfPair( return; const OUString sNameSpace = getDbNSName(); OSL_ASSERT(sNameSpace.getLength()); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); + const OUString sPrefix(getNSPrefix() + OUSTR(":")); + const Reference doc = getDocument(); + const Reference root = doc->getFirstChild(); - Reference vectorNode( - doc->createElementNS(sNameSpace, sVectorTagName)); + const Reference vectorNode( + doc->createElementNS(sNameSpace, sPrefix + sVectorTagName)); xParent->appendChild( Reference( @@ -200,35 +243,35 @@ void BackendDb::writeVectorOfPair( typedef ::std::vector< ::std::pair< OUString, OUString > >::const_iterator CIT; for (CIT i = vecPairs.begin(); i != vecPairs.end(); i++) { - Reference pairNode( - doc->createElementNS(sNameSpace, sPairTagName)); + const Reference pairNode( + doc->createElementNS(sNameSpace, sPrefix + sPairTagName)); vectorNode->appendChild( Reference( pairNode, css::uno::UNO_QUERY_THROW)); - Reference firstNode( - doc->createElementNS(sNameSpace, sFirstTagName)); + const Reference firstNode( + doc->createElementNS(sNameSpace, sPrefix + sFirstTagName)); pairNode->appendChild( Reference( firstNode, css::uno::UNO_QUERY_THROW)); - Reference firstTextNode( + const Reference firstTextNode( doc->createTextNode( i->first)); firstNode->appendChild( Reference( firstTextNode, css::uno::UNO_QUERY_THROW)); - Reference secondNode( - doc->createElementNS(sNameSpace, sSecondTagName)); + const Reference secondNode( + doc->createElementNS(sNameSpace, sPrefix + sSecondTagName)); pairNode->appendChild( Reference( secondNode, css::uno::UNO_QUERY_THROW)); - Reference secondTextNode( + const Reference secondTextNode( doc->createTextNode( i->second)); secondNode->appendChild( @@ -256,23 +299,24 @@ BackendDb::readVectorOfPair( try { OSL_ASSERT(parent.is()); - Reference xpathApi = getXPathAPI(); - OUString sExprPairs( - sListTagName + OUSTR("/") + sPairTagName); - Reference listPairs = + const OUString sPrefix(getNSPrefix() + OUSTR(":")); + const Reference xpathApi = getXPathAPI(); + const OUString sExprPairs( + sPrefix + sListTagName + OUSTR("/") + sPrefix + sPairTagName); + const Reference listPairs = xpathApi->selectNodeList(parent, sExprPairs); ::std::vector< ::std::pair< OUString, OUString > > retVector; sal_Int32 length = listPairs->getLength(); for (sal_Int32 i = 0; i < length; i++) { - Reference aPair = listPairs->item(i); - OUString sExprFirst(sFirstTagName + OUSTR("/text()")); - Reference first = + const Reference aPair = listPairs->item(i); + const OUString sExprFirst(sPrefix + sFirstTagName + OUSTR("/text()")); + const Reference first = xpathApi->selectSingleNode(aPair, sExprFirst); - OUString sExprSecond(sSecondTagName + OUSTR("/text()")); - Reference second = + const OUString sExprSecond(sPrefix + sSecondTagName + OUSTR("/text()")); + const Reference second = xpathApi->selectSingleNode(aPair, sExprSecond); OSL_ASSERT(first.is() && second.is()); @@ -302,10 +346,11 @@ void BackendDb::writeSimpleList( if (list.size() == 0) return; const OUString sNameSpace = getDbNSName(); - Reference doc = getDocument(); + const OUString sPrefix(getNSPrefix() + OUSTR(":")); + const Reference doc = getDocument(); - Reference listNode( - doc->createElementNS(sNameSpace, sListTagName)); + const Reference listNode( + doc->createElementNS(sNameSpace, sPrefix + sListTagName)); xParent->appendChild( Reference( @@ -314,12 +359,12 @@ void BackendDb::writeSimpleList( typedef ::std::list::const_iterator ITC_ITEMS; for (ITC_ITEMS i = list.begin(); i != list.end(); i++) { - Reference memberNode( - doc->createElementNS(sNameSpace, sMemberTagName), css::uno::UNO_QUERY_THROW); + const Reference memberNode( + doc->createElementNS(sNameSpace, sPrefix + sMemberTagName), css::uno::UNO_QUERY_THROW); listNode->appendChild(memberNode); - Reference textNode( + const Reference textNode( doc->createTextNode( *i), css::uno::UNO_QUERY_THROW); memberNode->appendChild(textNode); @@ -332,9 +377,105 @@ void BackendDb::writeSimpleList( OUSTR("Extension Manager: failed to write data entry in backend db: ") + m_urlDb, 0, exc); } +} + +//Writes only the element if is has a value. +//The prefix is automatically added to the element name +void BackendDb::writeSimpleElement( + OUString const & sElementName, OUString const & value, + Reference const & xParent) +{ + try + { + if (value.getLength() == 0) + return; + const OUString sPrefix = getNSPrefix(); + const Reference doc = getDocument(); + const OUString sNameSpace = getDbNSName(); + const Reference dataNode( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName), + UNO_QUERY_THROW); + xParent->appendChild(dataNode); + + const Reference dataValue( + doc->createTextNode(value), UNO_QUERY_THROW); + dataNode->appendChild(dataValue); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry(writeSimpleElement) in backend db: ") + + m_urlDb, 0, exc); + } + +} + +/** The key elements have an url attribute and are always children of the root + element. +*/ +Reference BackendDb::writeKeyElement( + ::rtl::OUString const & url) +{ + try + { + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + const OUString sElementName = getKeyElementName(); + const Reference doc = getDocument(); + const Reference root = doc->getFirstChild(); +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + const OUString sExpression( + sPrefix + OUSTR(":") + sElementName + OUSTR("[@url = \"") + url + OUSTR("\"]")); + const Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + const Reference keyElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName)); + + keyElement->setAttribute(OUSTR("url"), url); + + const Reference keyNode( + keyElement, UNO_QUERY_THROW); + root->appendChild(keyNode); + return keyNode; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write key element in backend db: ") + + m_urlDb, 0, exc); + } } +OUString BackendDb::readSimpleElement( + OUString const & sElementName, Reference const & xParent) +{ + try + { + const OUString sPrefix = getNSPrefix(); + const OUString sExpr(sPrefix + OUSTR(":") + sElementName + OUSTR("/text()")); + const Reference xpathApi = getXPathAPI(); + const Reference val = + xpathApi->selectSingleNode(xParent, sExpr); + if (val.is()) + return val->getNodeValue(); + return OUString(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data (readSimpleElement) in backend db: ") + + m_urlDb, 0, exc); + } +} + + ::std::list< OUString> BackendDb::readList( Reference const & parent, OUString const & sListTagName, @@ -343,17 +484,18 @@ void BackendDb::writeSimpleList( try { OSL_ASSERT(parent.is()); - Reference xpathApi = getXPathAPI(); - OUString sExprList( - sListTagName + OUSTR("/") + sMemberTagName + OUSTR("/text()")); - Reference list = + const OUString sPrefix(getNSPrefix() + OUSTR(":")); + const Reference xpathApi = getXPathAPI(); + const OUString sExprList( + sPrefix + sListTagName + OUSTR("/") + sPrefix + sMemberTagName + OUSTR("/text()")); + const Reference list = xpathApi->selectNodeList(parent, sExprList); ::std::list retList; sal_Int32 length = list->getLength(); for (sal_Int32 i = 0; i < length; i++) { - Reference member = list->item(i); + const Reference member = list->item(i); retList.push_back(member->getNodeValue()); } return retList; @@ -369,6 +511,84 @@ void BackendDb::writeSimpleList( +//================================================================================ +RegisteredDb::RegisteredDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +void RegisteredDb::addEntry(::rtl::OUString const & url) +{ + try{ + + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + const OUString sEntry = getKeyElementName(); + + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + Reference helpElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sEntry)); + + helpElement->setAttribute(OUSTR("url"), url); + + Reference helpNode( + helpElement, UNO_QUERY_THROW); + root->appendChild(helpNode); + + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +bool RegisteredDb::getEntry(::rtl::OUString const & url) +{ + try + { + const OUString sPrefix = getNSPrefix(); + const OUString sEntry = getKeyElementName(); + const OUString sExpression( + sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (!aNode.is()) + { + return false; + } + return true; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + + } // namespace backend } // namespace dp_registry diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx index 893a58ee8c64..976a6281a2bd 100644 --- a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx @@ -32,13 +32,8 @@ #include "precompiled_desktop.hxx" #include "rtl/string.h" -#include "rtl/bootstrap.hxx" -#include "cppuhelper/exc_hlp.hxx" #include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" -#include "com/sun/star/xml/xpath/XXPathAPI.hpp" #include "dp_misc.h" - #include "dp_executablebackenddb.hxx" @@ -49,6 +44,7 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/executable-registry/2010" #define NS_PREFIX "exe" #define ROOT_ELEMENT_NAME "executable-backend-db" +#define ENTRY_NAME "executable" namespace dp_registry { namespace backend { @@ -56,7 +52,7 @@ namespace executable { ExecutableBackendDb::ExecutableBackendDb( Reference const & xContext, - ::rtl::OUString const & url):BackendDb(xContext, url) + ::rtl::OUString const & url):RegisteredDb(xContext, url) { } @@ -76,86 +72,9 @@ OUString ExecutableBackendDb::getRootElementName() return OUSTR(ROOT_ELEMENT_NAME); } -void ExecutableBackendDb::addEntry(::rtl::OUString const & url) +OUString ExecutableBackendDb::getKeyElementName() { - try{ - - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url - OUString sExpression( - sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); - Reference _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif - Reference helpElement( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":executable"))); - - helpElement->setAttribute(OUSTR("url"), url); - - Reference helpNode( - helpElement, UNO_QUERY_THROW); - root->appendChild(helpNode); - -// Reference dataNode( -// doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")), -// UNO_QUERY_THROW); -// helpNode->appendChild(dataNode); - -// Reference dataValue( -// doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); -// dataNode->appendChild(dataValue); - - save(); - } - catch(css::uno::Exception &) - { - Any exc( ::cppu::getCaughtException() ); - throw css::deployment::DeploymentException( - OUSTR("Extension Manager: failed to write data entry in backend db: ") + - m_urlDb, 0, exc); - } -} - -void ExecutableBackendDb::removeEntry(::rtl::OUString const & url) -{ - OUString sExpression( - OUSTR(NS_PREFIX) + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); - removeElement(sExpression); -} - -bool ExecutableBackendDb::getEntry(::rtl::OUString const & url) -{ - try - { - const OUString sPrefix = getNSPrefix(); - const OUString sExpression( - sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); - //find the extension element that is to be removed - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); - if (!aNode.is()) - { - return false; - } - return true; - } - catch(css::uno::Exception &) - { - Any exc( ::cppu::getCaughtException() ); - throw css::deployment::DeploymentException( - OUSTR("Extension Manager: failed to read data entry in backend db: ") + - m_urlDb, 0, exc); - } + return OUSTR(ENTRY_NAME); } diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx index 2634d1d9d376..4f17eeda24a6 100644 --- a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx @@ -32,10 +32,6 @@ #define INCLUDED_DP_EXECUTABLEBACKENDDB_HXX #include "rtl/ustring.hxx" -#include "rtl/string.hxx" -#include -#include -#include "boost/optional.hpp" #include "dp_backenddb.hxx" namespace css = ::com::sun::star; @@ -44,13 +40,6 @@ namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } - namespace xml { namespace dom { - class XDocument; - class XNode; - }} - namespace xml { namespace xpath { - class XXPathAPI; - }} }}} namespace dp_registry { @@ -63,7 +52,7 @@ namespace executable { */ -class ExecutableBackendDb: public dp_registry::backend::BackendDb +class ExecutableBackendDb: public dp_registry::backend::RegisteredDb { protected: virtual ::rtl::OUString getDbNSName(); @@ -72,14 +61,13 @@ protected: virtual ::rtl::OUString getRootElementName(); + virtual ::rtl::OUString getKeyElementName(); + public: ExecutableBackendDb( css::uno::Reference const & xContext, ::rtl::OUString const & url); - void addEntry(::rtl::OUString const & url); - void removeEntry(::rtl::OUString const & url); - bool getEntry(::rtl::OUString const & url); }; diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index cad6ddecf751..4a8fa71e0618 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -49,6 +49,7 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/help-registry/2010" #define NS_PREFIX "help" #define ROOT_ELEMENT_NAME "help-backend-db" +#define KEY_ELEMENT_NAME "help" namespace dp_registry { namespace backend { @@ -76,43 +77,25 @@ OUString HelpBackendDb::getRootElementName() return OUSTR(ROOT_ELEMENT_NAME); } -void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +OUString HelpBackendDb::getKeyElementName() { - try{ - - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url - OUString sExpression( - sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); - Reference _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif - Reference helpElement( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":help"))); - - helpElement->setAttribute(OUSTR("url"), url); - - Reference helpNode( - helpElement, UNO_QUERY_THROW); - root->appendChild(helpNode); + return OUSTR(KEY_ELEMENT_NAME); +} - Reference dataNode( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")), - UNO_QUERY_THROW); - helpNode->appendChild(dataNode); - Reference dataValue( - doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); - dataNode->appendChild(dataValue); +void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + Reference helpNode + = writeKeyElement(url); + writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); save(); } + catch (css::deployment::DeploymentException& ) + { + throw; + } catch(css::uno::Exception &) { Any exc( ::cppu::getCaughtException() ); @@ -122,36 +105,17 @@ void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) } } -void HelpBackendDb::removeEntry(::rtl::OUString const & url) -{ - OUString sExpression( - OUSTR(NS_PREFIX) + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); - removeElement(sExpression); -} ::boost::optional HelpBackendDb::getEntry(::rtl::OUString const & url) { try { - const OUString sPrefix = getNSPrefix(); HelpBackendDb::Data retData; - const OUString sExpression( - sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); - //find the extension element that is to be removed - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); + Reference aNode = getKeyElement(url); if (aNode.is()) { - const OUString sExprDataUrl(sPrefix + OUSTR(":data-url/text()")); - - Reference dataUrlVal = - xpathApi->selectSingleNode(aNode, sExprDataUrl); - retData.dataUrl = dataUrlVal->getNodeValue(); + retData.dataUrl = readSimpleElement(OUSTR("data-url"), aNode); } else { @@ -159,6 +123,10 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) } return ::boost::optional(retData); } + catch (css::deployment::DeploymentException& ) + { + throw; + } catch(css::uno::Exception &) { Any exc( ::cppu::getCaughtException() ); @@ -190,6 +158,10 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) } return listRet; } + catch (css::deployment::DeploymentException& ) + { + throw; + } catch(css::uno::Exception &) { Any exc( ::cppu::getCaughtException() ); diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx index bf812ad96511..baecf0da48e6 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -59,9 +59,6 @@ namespace help { /* The XML file stores the extensions which are currently registered. They will be removed when they are revoked. - The format looks like this: - - */ class HelpBackendDb: public dp_registry::backend::BackendDb { @@ -72,6 +69,8 @@ protected: virtual ::rtl::OUString getRootElementName(); + virtual ::rtl::OUString getKeyElementName(); + public: struct Data { @@ -87,7 +86,7 @@ public: ::rtl::OUString const & url); void addEntry(::rtl::OUString const & url, Data const & data); - void removeEntry(::rtl::OUString const & url); + ::boost::optional getEntry(::rtl::OUString const & url); ::std::list< ::rtl::OUString> getAllDataUrls(); diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index ca28f28ac390..b8ba5facd492 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -30,6 +30,7 @@ #include "rtl/ustring.hxx" #include +#include namespace css = ::com::sun::star; @@ -75,6 +76,9 @@ protected: void save(); void removeElement(::rtl::OUString const & sXPathExpression); + css::uno::Reference getKeyElement( + ::rtl::OUString const & url); + void writeSimpleList( ::std::list< ::rtl::OUString> const & list, ::rtl::OUString const & sListTagName, @@ -89,6 +93,17 @@ protected: ::rtl::OUString const & sSecondTagName, css::uno::Reference const & xParent); + void writeSimpleElement( + ::rtl::OUString const & sElementName, ::rtl::OUString const & value, + css::uno::Reference const & xParent); + + css::uno::Reference writeKeyElement( + ::rtl::OUString const & url); + + ::rtl::OUString readSimpleElement( + ::rtl::OUString const & sElementName, + css::uno::Reference const & xParent); + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > readVectorOfPair( css::uno::Reference const & parent, @@ -117,6 +132,10 @@ protected: /* returns the name of the root element without any namespace prefix. */ virtual ::rtl::OUString getRootElementName()=0; + /* returns the name of xml element for each entry + */ + virtual ::rtl::OUString getKeyElementName()=0; + public: @@ -124,8 +143,24 @@ public: ::rtl::OUString const & url); virtual ~BackendDb() {}; + void removeEntry(::rtl::OUString const & url); }; +class RegisteredDb: public BackendDb +{ + +public: + RegisteredDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + virtual ~RegisteredDb() {}; + + + virtual void addEntry(::rtl::OUString const & url); + virtual bool getEntry(::rtl::OUString const & url); + +}; + + } } #endif diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx index 99aa2178b421..2e92a907f8fb 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -46,6 +46,7 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010" #define NS_PREFIX "ext" #define ROOT_ELEMENT_NAME "extension-backend-db" +#define KEY_ELEMENT_NAME "extension" namespace dp_registry { namespace backend { @@ -73,40 +74,21 @@ OUString ExtensionBackendDb::getRootElementName() return OUSTR(ROOT_ELEMENT_NAME); } +OUString ExtensionBackendDb::getKeyElementName() +{ + return OUSTR(KEY_ELEMENT_NAME); +} + void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url - OUString sExpression( - sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); - Reference _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif - // - Reference extensionNode( - doc->createElementNS(sNameSpace, - sPrefix + OUSTR(":extension"))); - - extensionNode->setAttribute(OUSTR("url"), url); - - Reference extensionNodeNode( - extensionNode, css::uno::UNO_QUERY_THROW); - root->appendChild(extensionNodeNode); - + Reference extensionNodeNode = writeKeyElement(url); writeVectorOfPair( data.items, - sPrefix + OUSTR(":extension-items"), - sPrefix + OUSTR(":item"), - sPrefix + OUSTR(":url"), - sPrefix + OUSTR(":media-type"), + OUSTR("extension-items"), + OUSTR("item"), + OUSTR("url"), + OUSTR("media-type"), extensionNodeNode); save(); } @@ -119,37 +101,22 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data } } -void ExtensionBackendDb::removeEntry(::rtl::OUString const & url) -{ - OUString sExpression( - OUSTR(NS_PREFIX) + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); - removeElement(sExpression); -} - ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & url) { try { - const OUString sPrefix = getNSPrefix(); ExtensionBackendDb::Data retData; - const OUString sExpression( - sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); + Reference aNode = getKeyElement(url); - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); if (aNode.is()) { retData.items = readVectorOfPair( aNode, - sPrefix + OUSTR(":extension-items"), - sPrefix + OUSTR(":item"), - sPrefix + OUSTR(":url"), - sPrefix + OUSTR(":media-type")); + OUSTR("extension-items"), + OUSTR("item"), + OUSTR("url"), + OUSTR("media-type")); } return retData; } diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx index e46c67b166de..d09fd0891a32 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx @@ -62,6 +62,7 @@ protected: virtual ::rtl::OUString getDbNSName(); virtual ::rtl::OUString getNSPrefix(); virtual ::rtl::OUString getRootElementName(); + virtual ::rtl::OUString getKeyElementName(); public: struct Data @@ -81,7 +82,7 @@ public: ::rtl::OUString const & url); void addEntry(::rtl::OUString const & url, Data const & data); - void removeEntry(::rtl::OUString const & url); + Data getEntry(::rtl::OUString const & url); }; diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index e808cd0f5e73..f0c4c9b42c6e 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -39,12 +39,12 @@ #include "comphelper/servicedecl.hxx" #include "svl/inettype.hxx" #include "com/sun/star/util/XUpdatable.hpp" -#include "com/sun/star/script/XLibraryContainer.hpp" +#include "com/sun/star/script/XLibraryContainer3.hpp" #include #include #include -#include #include +#include "dp_scriptbackenddb.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -100,15 +100,19 @@ class BackendImpl : public t_helper sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); - rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); - rtl::OUString expandURL( const rtl::OUString& aURL ); - Reference< ucb::XSimpleFileAccess > getFileAccess( void ); - Reference< ucb::XSimpleFileAccess > m_xSFA; + void addDataToDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + bool isRegisteredInDb(OUString const & url); + + + +// Reference< ucb::XSimpleFileAccess > getFileAccess( void ); +// Reference< ucb::XSimpleFileAccess > m_xSFA; const Reference m_xBasicLibTypeInfo; const Reference m_xDialogLibTypeInfo; Sequence< Reference > m_typeInfos; - + std::auto_ptr m_backendDb; public: BackendImpl( Sequence const & args, Reference const & xComponentContext ); @@ -172,6 +176,33 @@ BackendImpl::BackendImpl( m_typeInfos[ 1 ] = m_xDialogLibTypeInfo; OSL_ASSERT( ! transientMode() ); + + if (!transientMode()) + { + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new ScriptBackendDb(getComponentContext(), dbFile)); + } + +} +void BackendImpl::addDataToDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url); +} + +bool BackendImpl::isRegisteredInDb(OUString const & url) +{ + bool registered = false; + if (m_backendDb.get()) + registered = m_backendDb->getEntry(url); + return registered; +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); } // XUpdatable @@ -261,90 +292,6 @@ Reference BackendImpl::bindPackage_( static_cast(-1) ); } -rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ) -{ - rtl::OUString aRetURL; - if( !xPackage.is() ) - return aRetURL; - rtl::OUString aHelpURL = xPackage->getURL(); - aRetURL = expandURL( aHelpURL ); - aRetURL += rtl::OUString::createFromAscii( "/RegisteredFlag" ); - return aRetURL; -} - -rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL ) -{ - static Reference< util::XMacroExpander > xMacroExpander; - static Reference< uri::XUriReferenceFactory > xFac; - - if( !xMacroExpander.is() || !xFac.is() ) - { - Reference const & xContext = getComponentContext(); - if( xContext.is() ) - { - xFac = Reference< uri::XUriReferenceFactory >( - xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY ); - } - if( !xFac.is() ) - { - throw RuntimeException( - ::rtl::OUString::createFromAscii( - "dp_registry::backend::help::BackendImpl::expandURL(), " - "could not instatiate UriReferenceFactory." ), - Reference< XInterface >() ); - } - - xMacroExpander = Reference< util::XMacroExpander >( - xContext->getValueByName( - ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), - UNO_QUERY_THROW ); - } - - rtl::OUString aRetURL = aURL; - if( xMacroExpander.is() ) - { - Reference< uri::XUriReference > uriRef; - for (;;) - { - uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY ); - if ( uriRef.is() ) - { - Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY ); - if( !sxUri.is() ) - break; - - aRetURL = sxUri->expand( xMacroExpander ); - } - } - } - return aRetURL; -} - -Reference< ucb::XSimpleFileAccess > BackendImpl::getFileAccess( void ) -{ - if( !m_xSFA.is() ) - { - Reference const & xContext = getComponentContext(); - if( xContext.is() ) - { - m_xSFA = Reference< ucb::XSimpleFileAccess >( - xContext->getServiceManager()->createInstanceWithContext( - rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), - xContext ), UNO_QUERY ); - } - if( !m_xSFA.is() ) - { - throw RuntimeException( - ::rtl::OUString::createFromAscii( - "dp_registry::backend::help::BackendImpl::getFileAccess(), " - "could not instatiate SimpleFileAccess." ), - Reference< XInterface >() ); - } - } - return m_xSFA; -} - //############################################################################## // Package @@ -373,14 +320,11 @@ BackendImpl::PackageImpl::isRegistered_( BackendImpl * that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage ); - - Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess(); - bool bReg = xSFA->exists( aRegisteredFlagFile ); + bool registered = getMyBackend()->isRegisteredInDb(getURL()); return beans::Optional< beans::Ambiguous >( true /* IsPresent */, - beans::Ambiguous( bReg, false /* IsAmbiguous */ ) ); + beans::Ambiguous( registered, false /* IsAmbiguous */ ) ); } //______________________________________________________________________________ @@ -396,15 +340,13 @@ void BackendImpl::PackageImpl::processPackage_( BackendImpl * that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage ); - Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess(); Reference const & xComponentContext = that->getComponentContext(); bool bScript = (m_scriptURL.getLength() > 0); - Reference xScriptLibs; + Reference xScriptLibs; bool bDialog = (m_dialogURL.getLength() > 0); - Reference xDialogLibs; + Reference xDialogLibs; bool bRunning = office_is_running(); if( bRunning ) @@ -425,52 +367,116 @@ void BackendImpl::PackageImpl::processPackage_( xComponentContext ), UNO_QUERY_THROW ); } } - + bool bRegistered = getMyBackend()->isRegisteredInDb(getURL()); if( !doRegisterPackage ) { - if( xSFA->exists( aRegisteredFlagFile ) ) + //We cannot just call removeLibrary(name) because this could remove a + //script which was added by an extension in a different repository. For + //example, extension foo is contained in the bundled repository and then + //the user adds it it to the user repository. The extension manager will + //then register the new script and revoke the script from the bundled + //extension. removeLibrary(name) would now remove the script from the + //user repository. That is, the script of the newly added user extension does + //not work anymore. Therefore we must check if the currently active + //script comes in fact from the currently processed extension. + + if (bRegistered) { - xSFA->kill( aRegisteredFlagFile ); - - if( bScript && xScriptLibs.is() && xScriptLibs->hasByName( m_name ) ) - xScriptLibs->removeLibrary( m_name ); + if (!isRemoved()) + { + if (bScript && xScriptLibs.is() && xScriptLibs->hasByName(m_name)) + { + const OUString sScriptUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name); + if (sScriptUrl.equals(m_scriptURL)) + xScriptLibs->removeLibrary(m_name); + } - if( bDialog && xDialogLibs.is() && xDialogLibs->hasByName( m_dialogName ) ) - xDialogLibs->removeLibrary( m_dialogName ); + if (bDialog && xDialogLibs.is() && xDialogLibs->hasByName(m_dialogName)) + { + const OUString sDialogUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName); + if (sDialogUrl.equals(m_dialogURL)) + xDialogLibs->removeLibrary(m_dialogName); + } + } + getMyBackend()->deleteDataFromDb(getURL()); + return; } - return; } - - if( xSFA->exists( aRegisteredFlagFile ) ) + if (bRegistered) return; // Already registered // Update LibraryContainer bool bScriptSuccess = false; const bool bReadOnly = false; - if( bScript && xScriptLibs.is() && !xScriptLibs->hasByName( m_name ) ) + + //If there is a bundled extension, and the user installes the same extension + //then the script from the bundled extension must be removed. If this does not work + //then live deployment does not work for scripts. + if (bScript && xScriptLibs.is()) { - xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly ); - bScriptSuccess = xScriptLibs->hasByName( m_name ); + bool bCanAdd = true; + if (xScriptLibs->hasByName(m_name)) + { + const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + { + xScriptLibs->removeLibrary(m_name); + bCanAdd = true; + } + else + { + bCanAdd = false; + } + } + + if (bCanAdd) + { + xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly ); + bScriptSuccess = xScriptLibs->hasByName( m_name ); + } } bool bDialogSuccess = false; - if( bDialog && xDialogLibs.is() && !xDialogLibs->hasByName( m_dialogName ) ) + if (bDialog && xDialogLibs.is()) { - xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly ); - bDialogSuccess = xDialogLibs->hasByName( m_dialogName ); - } + bool bCanAdd = true; + if (xDialogLibs->hasByName(m_dialogName)) + { + const OUString sOriginalUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + { + xDialogLibs->removeLibrary(m_dialogName); + bCanAdd = true; + } + else + { + bCanAdd = false; + } + } + if (bCanAdd) + { + xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly ); + bDialogSuccess = xDialogLibs->hasByName(m_dialogName); + } + } bool bSuccess = bScript || bDialog; // Something must have happened if( bRunning ) if( (bScript && !bScriptSuccess) || (bDialog && !bDialogSuccess) ) bSuccess = false; - if( bSuccess && !xSFA->exists( aRegisteredFlagFile ) ) - { - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); - } + if (bSuccess) + getMyBackend()->addDataToDb(getURL()); } } // anon namespace diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx new file mode 100644 index 000000000000..ce0d3029084d --- /dev/null +++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_package.cxx,v $ + * $Revision: 1.34.16.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocument.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" +#include "dp_scriptbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/script-registry/2010" +#define NS_PREFIX "script" +#define ROOT_ELEMENT_NAME "script-backend-db" +#define KEY_ELEMENT_NAME "script" + +namespace dp_registry { +namespace backend { +namespace script { + +ScriptBackendDb::ScriptBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):RegisteredDb(xContext, url) +{ + +} + +OUString ScriptBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ScriptBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + +OUString ScriptBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +OUString ScriptBackendDb::getKeyElementName() +{ + return OUSTR(KEY_ELEMENT_NAME); +} + + + +} // namespace executable +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx new file mode 100644 index 000000000000..9d227f8b64b8 --- /dev/null +++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_backend.h,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_SCRIPTBACKENDDB_HXX +#define INCLUDED_DP_SCRIPTBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "dp_backenddb.hxx" +#include "boost/optional.hpp" +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + +namespace dp_registry { +namespace backend { +namespace script { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + */ +class ScriptBackendDb: public dp_registry::backend::RegisteredDb +{ +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getNSPrefix(); + + virtual ::rtl::OUString getRootElementName(); + + virtual ::rtl::OUString getKeyElementName(); + + +public: + + ScriptBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/script/makefile.mk b/desktop/source/deployment/registry/script/makefile.mk index ae159914a548..708def358021 100644 --- a/desktop/source/deployment/registry/script/makefile.mk +++ b/desktop/source/deployment/registry/script/makefile.mk @@ -41,7 +41,8 @@ INCPRE += ..$/..$/inc SLOFILES = \ $(SLO)$/dp_script.obj \ - $(SLO)$/dp_lib_container.obj + $(SLO)$/dp_lib_container.obj \ + $(SLO)$/dp_scriptbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java index 4c6a4f1eda2b..edf6a2d806b7 100644 --- a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java +++ b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java @@ -50,10 +50,15 @@ public class UnoPkgContainer extends ParcelContainer { private Map registeredPackages = new HashMap(); + protected String extensionDb; + protected String extensionRepository; - public UnoPkgContainer( XComponentContext xCtx, String locationURL, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException + public UnoPkgContainer( XComponentContext xCtx, String locationURL, + String _extensionDb, String _extensionRepository, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException { super( xCtx, locationURL, language, false ); + extensionDb = _extensionDb; + extensionRepository = _extensionRepository; init(); } @@ -218,8 +223,8 @@ public class UnoPkgContainer extends ParcelContainer DeployedUnoPackagesDB dp = null; try { - String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") ); - String packagesUrl = PathUtils.make_url( path, "Scripts/unopkg-desc.xml" ); +// String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") ); + String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" ); LogUtils.DEBUG("getUnoPackagesDB() looking for existing db in " + packagesUrl ); if ( m_xSFA.exists( packagesUrl ) ) { @@ -277,8 +282,8 @@ public class UnoPkgContainer extends ParcelContainer OutputStream os = null; try { - String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") ); - String packagesUrl = PathUtils.make_url( path, "Scripts/unopkg-desc.xml" ); +// String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") ); + String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" ); xos = m_xSFA.openFileWrite( packagesUrl ); XTruncate xTrc = (XTruncate) UnoRuntime.queryInterface( XTruncate.class, xos ); if ( xTrc != null ) @@ -375,7 +380,10 @@ public class UnoPkgContainer extends ParcelContainer String parentUrl = uri; if ( uri.indexOf( "%2Funo_packages%2F" ) > -1 || - uri.indexOf( "/uno_packages/" ) > -1 ) + uri.indexOf( "/uno_packages/" ) > -1 || + uri.indexOf("$UNO_USER_PACKAGES_CACHE/") > -1 || + uri.indexOf("$UNO_SHARED_PACKAGES_CACHE/") > -1 || + uri.indexOf("$BUNDLED_EXTENSIONS/") > -1 ) { //its in a bundle need to determine the uno-package file its in LogUtils.DEBUG("processUnoPackage - is part of a uno bundle"); diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java index c43756072ba3..e83410f3f35c 100755 --- a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java +++ b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java @@ -213,26 +213,40 @@ public abstract class ScriptProvider } else { + String extensionDb = null; + String extensionRepository = null; + if ( originalContextURL.startsWith( "bundled" ) ) + { + contextUrl = "vnd.sun.star.expand:$BUNDLED_EXTENSIONS"; + extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; + extensionRepository = "bundled"; + } + if ( originalContextURL.startsWith( "share" ) ) { contextUrl = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::BaseInstallation}/share"; + extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; + extensionRepository = "shared"; } else if ( originalContextURL.startsWith( "user" ) ) { contextUrl = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; + extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; + extensionRepository = "user"; } if ( originalContextURL.endsWith( "uno_packages") ) { isPkgProvider = true; } - if ( originalContextURL.endsWith( "uno_packages") && !originalContextURL.equals( contextUrl ) ) + if ( originalContextURL.endsWith( "uno_packages") && !originalContextURL.equals( contextUrl ) + && !extensionRepository.equals("bundled")) { contextUrl = PathUtils.make_url( contextUrl, "uno_packages" ); } if ( isPkgProvider ) { - m_container = new UnoPkgContainer( m_xContext, contextUrl, language ); + m_container = new UnoPkgContainer( m_xContext, contextUrl, extensionDb, extensionRepository, language ); } else { diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx index f8400ed77950..3c6206d8d051 100644 --- a/scripting/source/provider/ActiveMSPList.cxx +++ b/scripting/source/provider/ActiveMSPList.cxx @@ -59,6 +59,7 @@ ActiveMSPList::ActiveMSPList( const Reference< XComponentContext > & xContext ) { userDirString = ::rtl::OUString::createFromAscii("user"); shareDirString = ::rtl::OUString::createFromAscii("share"); + bundledDirString = ::rtl::OUString::createFromAscii("bundled"); } ActiveMSPList::~ActiveMSPList() @@ -307,6 +308,12 @@ ActiveMSPList::createNonDocMSPs() Reference< provider::XScriptProvider > shareMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY ); // should check if provider reference is valid m_hMsps[ shareDirString ] = shareMsp; + + args[ 0 ] <<= bundledDirString; + Reference< provider::XScriptProvider > bundledMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY ); + // should check if provider reference is valid + m_hMsps[ bundledDirString ] = bundledMsp; + created = true; } diff --git a/scripting/source/provider/ActiveMSPList.hxx b/scripting/source/provider/ActiveMSPList.hxx index 5adf2fc5a961..b127f3c41b16 100644 --- a/scripting/source/provider/ActiveMSPList.hxx +++ b/scripting/source/provider/ActiveMSPList.hxx @@ -107,6 +107,7 @@ private: osl::Mutex m_mutex; ::rtl::OUString userDirString; ::rtl::OUString shareDirString; + ::rtl::OUString bundledDirString; css::uno::Reference< css::uno::XComponentContext > m_xContext; }; } // func_provider diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index 5c164e08c100..f1113c1e114f 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -1511,6 +1511,7 @@ void ExtensionIteratorBase::init() m_bUserPackagesLoaded = false; m_bSharedPackagesLoaded = false; + m_bBundledPackagesLoaded = false; m_iUserPackage = 0; m_iSharedPackage = 0; m_iBundledPackage = 0; @@ -1624,7 +1625,7 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextSharedHelpPa if( m_iSharedPackage == m_aSharedPackagesSeq.getLength() ) { - m_eState = END_REACHED; + m_eState = BUNDLED_EXTENSIONS; } else { diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx index 478562fca7b7..73c413394763 100644 --- a/xmlhelp/source/treeview/tvread.cxx +++ b/xmlhelp/source/treeview/tvread.cxx @@ -986,8 +986,10 @@ void ExtensionIteratorBase::init() m_bUserPackagesLoaded = false; m_bSharedPackagesLoaded = false; + m_bBundledPackagesLoaded = false; m_iUserPackage = 0; m_iSharedPackage = 0; + m_iBundledPackage = 0; } Reference< deployment::XPackage > ExtensionIteratorBase::implGetHelpPackageFromPackage @@ -1089,7 +1091,7 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextSharedHelpPa if( m_iSharedPackage == m_aSharedPackagesSeq.getLength() ) { - m_eState = END_REACHED; + m_eState = BUNDLED_EXTENSIONS; } else { @@ -1102,6 +1104,36 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextSharedHelpPa return xHelpPackage; } +Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextBundledHelpPackage + ( Reference< deployment::XPackage >& o_xParentPackageBundle ) +{ + Reference< deployment::XPackage > xHelpPackage; + + if( !m_bBundledPackagesLoaded ) + { + Reference< XPackageManager > xBundledManager = + thePackageManagerFactory::get( m_xContext )->getPackageManager( rtl::OUString::createFromAscii("bundled") ); + m_aBundledPackagesSeq = xBundledManager->getDeployedPackages + ( Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); + + m_bBundledPackagesLoaded = true; + } + + if( m_iBundledPackage == m_aBundledPackagesSeq.getLength() ) + { + m_eState = END_REACHED; + } + else + { + const Reference< deployment::XPackage >* pBundledPackages = m_aBundledPackagesSeq.getConstArray(); + Reference< deployment::XPackage > xPackage = pBundledPackages[ m_iBundledPackage++ ]; + VOS_ENSURE( xPackage.is(), "ExtensionIteratorBase::implGetNextBundledHelpPackage(): Invalid package" ); + xHelpPackage = implGetHelpPackageFromPackage( xPackage, o_xParentPackageBundle ); + } + + return xHelpPackage; +} + inline bool isLetter( sal_Unicode c ) { bool bLetter = ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); @@ -1173,7 +1205,18 @@ rtl::OUString TreeFileIterator::nextTreeFile( sal_Int32& rnFileSize ) aRetFile = implGetTreeFileFromPackage( rnFileSize, xHelpPackage ); break; } - case END_REACHED: + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xParentPackageBundle; + Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( xParentPackageBundle ); + if( !xHelpPackage.is() ) + break; + + aRetFile = implGetTreeFileFromPackage( rnFileSize, xHelpPackage ); + break; + } + + case END_REACHED: VOS_ENSURE( false, "DataBaseIterator::nextTreeFile(): Invalid case END_REACHED" ); break; } diff --git a/xmlhelp/source/treeview/tvread.hxx b/xmlhelp/source/treeview/tvread.hxx index 907568815568..7cc3887448be 100644 --- a/xmlhelp/source/treeview/tvread.hxx +++ b/xmlhelp/source/treeview/tvread.hxx @@ -328,6 +328,7 @@ namespace treeview { { USER_EXTENSIONS, SHARED_EXTENSIONS, + BUNDLED_EXTENSIONS, END_REACHED }; @@ -347,6 +348,9 @@ namespace treeview { ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle ); com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextSharedHelpPackage ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle ); + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledHelpPackage + ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle ); + void implGetLanguageVectorFromPackage( ::std::vector< ::rtl::OUString > &rv, com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage ); @@ -365,8 +369,13 @@ namespace treeview { < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; bool m_bSharedPackagesLoaded; + com::sun::star::uno::Sequence< com::sun::star::uno::Reference + < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; + bool m_bBundledPackagesLoaded; + int m_iUserPackage; int m_iSharedPackage; + int m_iBundledPackage; }; // end class ExtensionIteratorBase -- cgit From 6241367966bca60d2ee49a693d23c59acfac3349 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Mon, 3 May 2010 14:22:23 +0200 Subject: jl152 import 263453 from native0jl:#i77196# Use ExtensionManager instead of PackageManager --- desktop/source/app/check_ext_deps.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index c3eb81dfc3ec..7629a5c5cf83 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -47,8 +47,6 @@ #include #include #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" #include "com/sun/star/deployment/ExtensionManager.hpp" #include #include -- cgit -- cgit From a9dbaec3087911f20e5781d98586bd1ec9b0937b Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 6 May 2010 17:19:12 +0200 Subject: jl152 i111434 ucb failes when copying folders, which contain files containing percent signs --- ucb/source/ucp/file/shell.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ucb/source/ucp/file/shell.cxx b/ucb/source/ucp/file/shell.cxx index 769e58c08819..f324c93b878f 100644 --- a/ucb/source/ucp/file/shell.cxx +++ b/ucb/source/ucp/file/shell.cxx @@ -33,6 +33,7 @@ #endif #include "osl/diagnose.h" +#include #include #include #include @@ -2054,9 +2055,14 @@ shell::copy_recursive( const rtl::OUString& srcUnqPath, rtl::OUString newDstUnqPath = dstUnqPath; rtl::OUString tit; if( aFileStatus.isValid( FileStatusMask_FileName ) ) - tit = aFileStatus.getFileName(); + tit = rtl::Uri::encode( aFileStatus.getFileName(), + rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ); + if( newDstUnqPath.lastIndexOf( sal_Unicode('/') ) != newDstUnqPath.getLength()-1 ) newDstUnqPath += rtl::OUString::createFromAscii( "/" ); + newDstUnqPath += tit; if ( newSrcUnqPath != dstUnqPath ) -- cgit From e8f78faa415a94dda55b8cd3249d3586d36dc119 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 7 May 2010 10:40:12 +0200 Subject: cws tl78: fixing windows specific build problems after merging with DEV300_m77 --- desktop/source/migration/migration.cxx | 1 + sfx2/inc/brokenpackageint.hxx | 18 +++++++++++++-- sfx2/source/appl/appuno.cxx | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) mode change 100644 => 100755 desktop/source/migration/migration.cxx mode change 100644 => 100755 sfx2/inc/brokenpackageint.hxx mode change 100644 => 100755 sfx2/source/appl/appuno.cxx diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx old mode 100644 new mode 100755 index 2181daab7454..b9be788ebd4b --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -232,6 +232,7 @@ static void insertSorted(migrations_available& rAvailableMigrations, supported_m { rAvailableMigrations.insert(pIter, aSupportedMigration ); bInserted = true; + break; } ++pIter; } diff --git a/sfx2/inc/brokenpackageint.hxx b/sfx2/inc/brokenpackageint.hxx old mode 100644 new mode 100755 index e39c92c599ae..16f332480cf6 --- a/sfx2/inc/brokenpackageint.hxx +++ b/sfx2/inc/brokenpackageint.hxx @@ -36,7 +36,9 @@ using namespace ::framework; typedef ContinuationBase< ::com::sun::star::task::XInteractionApprove > SfxContinuationApprove; typedef ContinuationBase< ::com::sun::star::task::XInteractionDisapprove > SfxContinuationDisapprove; -class SFX2_DLLPUBLIC RequestPackageReparation : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest > +class SFX2_DLLPUBLIC RequestPackageReparation : + public ::com::sun::star::task::XInteractionRequest, + public ::cppu::OWeakObject { ::com::sun::star::uno::Any m_aRequest; @@ -50,6 +52,11 @@ class SFX2_DLLPUBLIC RequestPackageReparation : public ::cppu::WeakImplHelper1< public: RequestPackageReparation( ::rtl::OUString aName ); + // XInterface / OWeakObject + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire( ) throw (); + virtual void SAL_CALL release( ) throw (); + sal_Bool isApproved() { return m_pApprove->isSelected(); } virtual ::com::sun::star::uno::Any SAL_CALL getRequest() @@ -61,7 +68,9 @@ public: throw( ::com::sun::star::uno::RuntimeException ); }; -class SFX2_DLLPUBLIC NotifyBrokenPackage : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest > +class SFX2_DLLPUBLIC NotifyBrokenPackage : + public ::com::sun::star::task::XInteractionRequest, + public ::cppu::OWeakObject { ::com::sun::star::uno::Any m_aRequest; @@ -74,6 +83,11 @@ class SFX2_DLLPUBLIC NotifyBrokenPackage : public ::cppu::WeakImplHelper1< ::com public: NotifyBrokenPackage( ::rtl::OUString aName ); + // XInterface / OWeakObject + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire( ) throw (); + virtual void SAL_CALL release( ) throw (); + sal_Bool isAborted() { return m_pAbort->isSelected(); } virtual ::com::sun::star::uno::Any SAL_CALL getRequest() diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx old mode 100644 new mode 100755 index fd33e21ea645..66452f10bbfb --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -2411,6 +2411,26 @@ RequestPackageReparation::RequestPackageReparation( ::rtl::OUString aName ) m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pDisapprove ); } +/*uno::*/Any SAL_CALL RequestPackageReparation::queryInterface( const /*uno::*/Type& rType ) throw (RuntimeException) +{ + return ::cppu::queryInterface ( rType, + // OWeakObject interfaces + dynamic_cast< XInterface* > ( (XInteractionRequest *) this ), + static_cast< XWeak* > ( this ), + // my own interfaces + static_cast< XInteractionRequest* > ( this ) ); +} + +void SAL_CALL RequestPackageReparation::acquire( ) throw () +{ + OWeakObject::acquire(); +} + +void SAL_CALL RequestPackageReparation::release( ) throw () +{ + OWeakObject::release(); +} + ::com::sun::star::uno::Any SAL_CALL RequestPackageReparation::getRequest() throw( ::com::sun::star::uno::RuntimeException ) { @@ -2442,6 +2462,26 @@ NotifyBrokenPackage::NotifyBrokenPackage( ::rtl::OUString aName ) m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort ); } +/*uno::*/Any SAL_CALL NotifyBrokenPackage::queryInterface( const /*uno::*/Type& rType ) throw (RuntimeException) +{ + return ::cppu::queryInterface ( rType, + // OWeakObject interfaces + dynamic_cast< XInterface* > ( (XInteractionRequest *) this ), + static_cast< XWeak* > ( this ), + // my own interfaces + static_cast< XInteractionRequest* > ( this ) ); +} + +void SAL_CALL NotifyBrokenPackage::acquire( ) throw () +{ + OWeakObject::acquire(); +} + +void SAL_CALL NotifyBrokenPackage::release( ) throw () +{ + OWeakObject::release(); +} + ::com::sun::star::uno::Any SAL_CALL NotifyBrokenPackage::getRequest() throw( ::com::sun::star::uno::RuntimeException ) { -- cgit From c6f3782d96f7a93889d742520496e9d27775048e Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Mon, 10 May 2010 11:06:01 +0200 Subject: jl152: Fixed compiling errors for gcc --- desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 2 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 2 +- .../source/deployment/manager/dp_commandenvironments.hxx | 14 ++++++-------- .../source/deployment/manager/dp_extensionmanager.cxx | 1 + .../source/deployment/manager/dp_extensionmanager.hxx | 5 +++-- desktop/source/deployment/manager/dp_manager.cxx | 6 ++++-- desktop/source/deployment/registry/dp_backend.cxx | 10 +++++----- .../source/deployment/registry/package/dp_package.cxx | 16 ++++++++++------ desktop/source/deployment/registry/script/dp_script.cxx | 2 +- 9 files changed, 32 insertions(+), 26 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 18911ce63ea2..5fd713239e68 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -60,8 +60,8 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_bActive( false ), m_bLocked( bReadOnly ), m_bHasOptions( false ), - m_bShared( false ), m_bUser( false ), + m_bShared( false ), m_bNew( false ), m_bChecked( false ), m_bMissingDeps( false ), diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 65a1bf021d29..20f47139599a 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -503,7 +503,7 @@ void TheExtensionManager::notifyTermination( ::lang::EventObject const & rEvt ) //------------------------------------------------------------------------------ // XModifyListener -void TheExtensionManager::modified( ::lang::EventObject const & rEvt ) +void TheExtensionManager::modified( ::lang::EventObject const & /*rEvt*/ ) throw ( uno::RuntimeException ) { getDialogHelper()->prepareChecking(); diff --git a/desktop/source/deployment/manager/dp_commandenvironments.hxx b/desktop/source/deployment/manager/dp_commandenvironments.hxx index 0bdad4fd09cc..aa21f8281c72 100644 --- a/desktop/source/deployment/manager/dp_commandenvironments.hxx +++ b/desktop/source/deployment/manager/dp_commandenvironments.hxx @@ -84,9 +84,8 @@ public: class TmpRepositoryCommandEnv : public BaseCommandEnv { public: - TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(); - TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( - css::uno::Reference< css::task::XInteractionHandler> const & handler); + TmpRepositoryCommandEnv(); + TmpRepositoryCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler); // XInteractionHandler virtual void SAL_CALL handle( @@ -105,8 +104,8 @@ private: ::rtl::OUString m_repository; bool m_bSuppressLicense; public: - LicenseCommandEnv::LicenseCommandEnv(){}; - LicenseCommandEnv::LicenseCommandEnv( + LicenseCommandEnv(){}; + LicenseCommandEnv( css::uno::Reference< css::task::XInteractionHandler> const & handler, bool bSuppressLicense, ::rtl::OUString const & repository); @@ -126,9 +125,8 @@ class NoLicenseCommandEnv : public BaseCommandEnv { public: - NoLicenseCommandEnv::NoLicenseCommandEnv(){}; - NoLicenseCommandEnv::NoLicenseCommandEnv( - css::uno::Reference< css::task::XInteractionHandler> const & handler); + NoLicenseCommandEnv(){}; + NoLicenseCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler); // XInteractionHandler virtual void SAL_CALL handle( diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 44f34991889e..844417d5ec85 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -1225,6 +1225,7 @@ ExtensionManager::getExtensionsWithUnacceptedLicenses( } sal_Bool ExtensionManager::isReadOnlyRepository(::rtl::OUString const & repository) + throw (uno::RuntimeException) { return getPackageManager(repository)->isReadOnly(); } diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 158fd35e2fa0..e6c9ca3aa915 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -202,7 +202,8 @@ public: throw (css::deployment::DeploymentException, css::uno::RuntimeException); - virtual sal_Bool SAL_CALL isReadOnlyRepository(::rtl::OUString const & repository); + virtual sal_Bool SAL_CALL isReadOnlyRepository(::rtl::OUString const & repository) + throw (css::uno::RuntimeException); private: @@ -233,7 +234,7 @@ private: bool isUserDisabled(::rtl::OUString const & identifier, ::rtl::OUString const & filename); - bool ExtensionManager::isUserDisabled( + bool isUserDisabled( css::uno::Sequence > const & seqExtSameId); void activateExtension( diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 83105406f253..69b2baab8878 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -1471,6 +1471,8 @@ Sequence< Reference > PackageManagerImpl::getExtensionsWit Reference const & xCmdEnv) throw (deployment::DeploymentException, RuntimeException) { + ::std::vector > vec; + try { const ::osl::MutexGuard guard( getMutex() ); @@ -1479,8 +1481,6 @@ Sequence< Reference > PackageManagerImpl::getExtensionsWit ActivePackages::Entries::const_iterator i = id2temp.begin(); bool bShared = m_context.equals(OUSTR("shared")); - ::std::vector > vec; - for (; i != id2temp.end(); i++ ) { @@ -1523,6 +1523,8 @@ Sequence< Reference > PackageManagerImpl::getExtensionsWit exc <<= de; ::cppu::throwException(exc); } + + return ::comphelper::containerToSequence(vec); } sal_Int32 PackageManagerImpl::checkPrerequisites( diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index e822a66aa85f..9a83ca63d36e 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -274,12 +274,12 @@ void PackageRegistryBackend::deleteUnusedFolders( //usedFolders contains the urls to the folders which have //a trailing underscore const OUString tempFile = tempEntries[ pos ]; - const OUString tempFolder = tempFile + OUSTR("_"); + const OUString tempFolderName = tempFile + OUSTR("_"); - if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolder ) == + if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolderName ) == usedFolders.end()) { - erase_path( tempFolder, Reference(), + erase_path( tempFolderName, Reference(), false /* no throw: ignore errors */ ); erase_path( tempFile, Reference(), false /* no throw: ignore errors */ ); @@ -306,7 +306,7 @@ Package::~Package() //______________________________________________________________________________ Package::Package( ::rtl::Reference const & myBackend, OUString const & url, - OUString const & name, + OUString const & rName, OUString const & displayName, Reference const & xPackageType, bool bRemoved, @@ -314,7 +314,7 @@ Package::Package( ::rtl::Reference const & myBackend, : t_PackageBase( getMutex() ), m_myBackend( myBackend ), m_url( url ), - m_name( name ), + m_name( rName ), m_displayName( displayName ), m_xPackageType( xPackageType ), m_bRemoved(bRemoved), diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 3d4842f62bfd..a2c68dd2341f 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -228,7 +228,8 @@ class BackendImpl : public ImplBaseT virtual beans::StringPair SAL_CALL getPublisherInfo() throw (deployment::ExtensionRemovedException, RuntimeException); - virtual OUString SAL_CALL getDisplayName() throw (RuntimeException); + virtual OUString SAL_CALL getDisplayName() + throw (deployment::ExtensionRemovedException, RuntimeException); virtual Reference< graphic::XGraphic > SAL_CALL getIcon( ::sal_Bool bHighContrast ) @@ -754,9 +755,10 @@ bool BackendImpl::PackageImpl::checkDependencies( ::sal_Bool BackendImpl::PackageImpl::checkDependencies( const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv ) - throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::uno::RuntimeException) + throw (deployment::DeploymentException, + deployment::ExtensionRemovedException, + ucb::CommandFailedException, + RuntimeException) { if (m_bRemoved) throw deployment::ExtensionRemovedException(); @@ -781,7 +783,8 @@ beans::Optional BackendImpl::PackageImpl::getIdentifier() true, identifier); } -OUString BackendImpl::PackageImpl::getVersion() throw (RuntimeException) +OUString BackendImpl::PackageImpl::getVersion() + throw (deployment::ExtensionRemovedException, RuntimeException) { if (m_bRemoved) throw deployment::ExtensionRemovedException(); @@ -982,7 +985,8 @@ void BackendImpl::PackageImpl::processPackage_( } //______________________________________________________________________________ -OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) +OUString BackendImpl::PackageImpl::getDescription() + throw (deployment::ExtensionRemovedException, RuntimeException) { if (m_bRemoved) throw deployment::ExtensionRemovedException(); diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index f0c4c9b42c6e..414d4c1c61cd 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -321,7 +321,7 @@ BackendImpl::PackageImpl::isRegistered_( BackendImpl * that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - bool registered = getMyBackend()->isRegisteredInDb(getURL()); + bool registered = that->isRegisteredInDb(getURL()); return beans::Optional< beans::Ambiguous >( true /* IsPresent */, beans::Ambiguous( registered, false /* IsAmbiguous */ ) ); -- cgit From 051f7b163fa4bf1917fb3db98fed2a6a932a827e Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Mon, 10 May 2010 12:00:49 +0200 Subject: jl152#i77196# Use ExtensionManager instead of PackageManager --- .../source/deployment/gui/dp_gui_extensioncmdqueue.cxx | 10 ++++++---- desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 17 +++++++++++++++-- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 5 +---- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 2 -- .../source/deployment/manager/dp_extensionmanager.cxx | 2 ++ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 4c9357e03e9f..8d82d969c4a0 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -1028,13 +1028,14 @@ void ExtensionCmdQueue::Thread::_enableExtension( ::rtl::Reference< ProgressCmdE if ( !xPackage.is() ) return; - uno::Reference< task::XAbortChannel > xAbortChannel( xPackage->createAbortChannel() ); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); OUString sTitle = searchAndReplaceAll( m_sEnablingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); rCmdEnv->progressSection( sTitle, xAbortChannel ); try { - xPackage->registerPackage(false, xAbortChannel, rCmdEnv.get() ); + xExtMgr->enableExtension( xPackage, xAbortChannel, rCmdEnv.get() ); if ( m_pDialogHelper ) m_pDialogHelper->updatePackageInfo( xPackage ); } @@ -1049,13 +1050,14 @@ void ExtensionCmdQueue::Thread::_disableExtension( ::rtl::Reference< ProgressCmd if ( !xPackage.is() ) return; - uno::Reference< task::XAbortChannel > xAbortChannel( xPackage->createAbortChannel() ); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); OUString sTitle = searchAndReplaceAll( m_sDisablingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); rCmdEnv->progressSection( sTitle, xAbortChannel ); try { - xPackage->revokePackage( xAbortChannel, rCmdEnv.get() ); + xExtMgr->disableExtension( xPackage, xAbortChannel, rCmdEnv.get() ); if ( m_pDialogHelper ) m_pDialogHelper->updatePackageInfo( xPackage ); } diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 5fd713239e68..c73d8dfba136 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -1123,17 +1123,30 @@ void ExtensionBox_Impl::checkEntries() { if ( (*iIndex)->m_bChecked == false ) { + (*iIndex)->m_bChecked = true; bNeedsUpdate = true; nPos = iIndex-m_vEntries.begin(); if ( (*iIndex)->m_bNew ) - { + { // add entry to list and correct active pos if ( nNewPos == - 1) nNewPos = nPos; if ( nPos <= m_nActive ) m_nActive += 1; + iIndex++; + } + else + { // remove entry from list + if ( nPos < m_nActive ) + m_nActive -= 1; + else if ( ( nPos == m_nActive ) && ( nPos == m_vEntries.size() - 1 ) ) + m_nActive -= 1; + m_vRemovedEntries.push_back( *iIndex ); + m_vEntries.erase( iIndex ); + iIndex = m_vEntries.begin() + nPos; } } - iIndex++; + else + iIndex++; } guard.clear(); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 20f47139599a..7c81517bbbfa 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -34,6 +34,7 @@ #include "vos/mutex.hxx" #include "toolkit/helper/vclunohelper.hxx" + #include "com/sun/star/beans/XPropertySet.hpp" #include "dp_gui_dialog2.hxx" @@ -48,10 +49,6 @@ #define SHARED_PACKAGE_MANAGER OUSTR("shared") #define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") -#define USER_PACKAGE_MANAGER OUSTR("user") -#define SHARED_PACKAGE_MANAGER OUSTR("shared") -#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") - using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index 6605b5907dab..02e3aad56915 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -69,8 +69,6 @@ private: ::rtl::OUString m_sGetExtensionsURL; - // liste der packages ( xpackage?, mit parent manager, ... ) - void createPackageList(); public: diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 844417d5ec85..83e68dff255e 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -326,6 +326,8 @@ void ExtensionManager::activateExtension( ::std::list > > (listExtensions), bUserDisabled, bStartup, xAbortChannel, xCmdEnv); + + fireModified(); } void ExtensionManager::activateExtension( -- cgit From cbe7eeb41f84acf01241189b67d17b8a4bb4954b Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Mon, 10 May 2010 12:18:08 +0200 Subject: jl152: Fixed compiling errors for gcc --- desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index c73d8dfba136..dbb5c93cd853 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -1138,7 +1138,7 @@ void ExtensionBox_Impl::checkEntries() { // remove entry from list if ( nPos < m_nActive ) m_nActive -= 1; - else if ( ( nPos == m_nActive ) && ( nPos == m_vEntries.size() - 1 ) ) + else if ( ( nPos == m_nActive ) && ( nPos == (long) m_vEntries.size() - 1 ) ) m_nActive -= 1; m_vRemovedEntries.push_back( *iIndex ); m_vEntries.erase( iIndex ); -- cgit From dc9d30e6e99da3e63f9255a0c5dd046015437665 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 7 May 2010 17:02:22 +0200 Subject: jl152 #i77196# adapting configuration backend to changes introduced by SB on DEV300 branch concering different handling of configuration files in extensions, also fixed writing of compiled help files into the user installation --- configmgr/source/components.cxx | 8 +- desktop/source/deployment/inc/dp_misc.h | 3 + desktop/source/deployment/misc/dp_misc.cxx | 16 ++ .../deployment/registry/component/dp_component.cxx | 56 +++-- .../registry/configuration/dp_configuration.cxx | 240 +++++++++++++-------- .../configuration/dp_configurationbackenddb.cxx | 186 ++++++++++++++++ .../configuration/dp_configurationbackenddb.hxx | 96 +++++++++ .../deployment/registry/configuration/makefile.mk | 3 +- desktop/source/deployment/registry/dp_backend.cxx | 24 ++- .../source/deployment/registry/dp_backenddb.cxx | 45 ++++ .../source/deployment/registry/help/dp_help.cxx | 16 +- .../deployment/registry/help/dp_helpbackenddb.cxx | 6 +- .../deployment/registry/help/dp_helpbackenddb.hxx | 9 - .../source/deployment/registry/inc/dp_backend.h | 5 + .../deployment/registry/inc/dp_backenddb.hxx | 5 +- 15 files changed, 568 insertions(+), 150 deletions(-) create mode 100644 desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx create mode 100644 desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 48f90fa8382e..7ef1bd3ee3e7 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -368,22 +368,22 @@ Components::Components( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/share/registry/modules")))); - parseXcsXcuLayer( //TODO: migrate + parseXcsXcuIniLayer( 7, expand( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("uno") - ":UNO_SHARED_PACKAGES_CACHE}/registry/" + ":BUNDLED_EXTENSIONS_USER}/registry/" "com.sun.star.comp.deployment.configuration." - "PackageRegistryBackend/registry")))); + "PackageRegistryBackend/configmgr.ini")))); parseXcsXcuIniLayer( 9, expand( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("uno") - ":UNO_SHARED_PACKAGES_CACHE}/registry/" + ":SHARED_EXTENSIONS_USER}/registry/" "com.sun.star.comp.deployment.configuration." "PackageRegistryBackend/configmgr.ini")))); parseXcsXcuLayer( //TODO: migrate diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index 3283d20718be..a0ca7f53be03 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -70,6 +70,9 @@ inline void try_dispose( ::com::sun::star::uno::Reference< ::com::sun::star::uno DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString expandUnoRcTerm( ::rtl::OUString const & term ); +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::rtl::OUString makeRcTerm( ::rtl::OUString const & url ); + //============================================================================== DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString expandUnoRcUrl( ::rtl::OUString const & url ); diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 919f134b3fb9..799542a4757f 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -317,6 +317,22 @@ OUString expandUnoRcTerm( OUString const & term_ ) return term; } +OUString makeRcTerm( OUString const & url ) +{ + OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( + "vnd.sun.star.expand:") ) ); + if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) { + // cut protocol: + OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); + // decode uric class chars: + rcterm = ::rtl::Uri::decode( + rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); + return rcterm; + } + else + return url; +} + //============================================================================== OUString expandUnoRcUrl( OUString const & url ) { diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index edb53d134c8b..fc9880438bac 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -75,7 +75,6 @@ typedef ::std::list t_stringlist; typedef ::std::vector< ::std::pair > t_stringpairvec; #define IMPLEMENTATION_NAME "com.sun.star.comp.deployment.component.PackageRegistryBackend" -inline OUString makeRcTerm( OUString const & url ); /** return a vector of bootstrap variables which have been provided as command arguments. @@ -779,11 +778,16 @@ void BackendImpl::unorc_verify_init( OUString token( line.getToken( 0, ' ', index ).trim() ); if (token.getLength() > 0) { - //The jar file may not exist anymore if a shared or bundled - //extension was removed, but it can still be in the unorc - //After running XExtensionManager::synchronize, the unorc is - //cleaned up - m_jar_typelibs.push_back( token ); + if (create_ucb_content( + 0, expandUnoRcTerm(token), xCmdEnv, + false /* no throw */ )) + { + //The jar file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the unorc + //After running XExtensionManager::synchronize, the unorc is + //cleaned up + m_jar_typelibs.push_back( token ); + } } } while (index >= 0); @@ -797,11 +801,16 @@ void BackendImpl::unorc_verify_init( { if (token[ 0 ] == '?') token = token.copy( 1 ); - //The RDB file may not exist anymore if a shared or bundled - //extension was removed, but it can still be in the unorc. - //After running XExtensionManager::synchronize, the unorc is - //cleaned up - m_rdb_typelibs.push_back( token ); + if (create_ucb_content( + 0, expandUnoRcTerm(token), xCmdEnv, + false /* no throw */ )) + { + //The RDB file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the unorc. + //After running XExtensionManager::synchronize, the unorc is + //cleaned up + m_rdb_typelibs.push_back( token ); + } } } while (index >= 0); @@ -842,7 +851,7 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) ::rtl::OStringBuffer buf; buf.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN=")); - OUString sOrigin = makeRcTerm(m_cachePath); + OUString sOrigin = dp_misc::makeRcTerm(m_cachePath); ::rtl::OString osOrigin = ::rtl::OUStringToOString(sOrigin, RTL_TEXTENCODING_UTF8); buf.append(osOrigin); buf.append(LF); @@ -933,28 +942,11 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) m_unorc_modified = false; } -//------------------------------------------------------------------------------ -inline OUString makeRcTerm( OUString const & url ) -{ - OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( - "vnd.sun.star.expand:") ) ); - if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) { - // cut protocol: - OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); - // decode uric class chars: - rcterm = ::rtl::Uri::decode( - rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - return rcterm; - } - else - return url; -} - //______________________________________________________________________________ bool BackendImpl::addToUnoRc( bool jarFile, OUString const & url_, Reference const & xCmdEnv ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); unorc_verify_init( xCmdEnv ); t_stringlist & rSet = getTypelibs(jarFile); @@ -974,7 +966,7 @@ bool BackendImpl::removeFromUnoRc( bool jarFile, OUString const & url_, Reference const & xCmdEnv ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); unorc_verify_init( xCmdEnv ); getTypelibs(jarFile).remove( rcterm ); @@ -988,7 +980,7 @@ bool BackendImpl::removeFromUnoRc( bool BackendImpl::hasInUnoRc( bool jarFile, OUString const & url_ ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); t_stringlist const & rSet = getTypelibs(jarFile); return ::std::find( rSet.begin(), rSet.end(), rcterm ) != rSet.end(); diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index a97736235656..1a6738b0270b 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -55,6 +55,7 @@ #include #include +#include "dp_configurationbackenddb.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -111,6 +112,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend bool m_configmgrini_inited; bool m_configmgrini_modified; + std::auto_ptr m_backendDb; // PackageRegistryBackend virtual Reference bindPackage_( @@ -135,7 +137,11 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv ); bool removeFromConfigmgrIni( bool isSchema, OUString const & url, Reference const & xCmdEnv ); - bool hasInConfigmgrIni( bool isSchema, OUString const & url ); + + void addDataToDb(OUString const & url, ConfigurationBackendDb::Data const & data); + ::boost::optional readDataFromDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + ::std::list getAllIniEntries(); public: BackendImpl( Sequence const & args, @@ -193,18 +199,64 @@ BackendImpl::BackendImpl( const Reference xCmdEnv; - if (transientMode()) { + if (transientMode()) + { //TODO } - else { + else + { + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new ConfigurationBackendDb(getComponentContext(), dbFile)); + //clean up data folders which are no longer used. + //This must not be done in the same process where the help files + //are still registers. Only after revoking and restarting OOo the folders + //can be removed. This works now, because the extension manager is a singleton + //and the backends are only create once per process. + ::std::list folders = m_backendDb->getAllDataUrls(); + deleteUnusedFolders(OUString(), folders); + + configmgrini_verify_init( xCmdEnv ); m_registeredPackages.reset( new PersistentMap( makeURL( getCachePath(), OUSTR("registered_packages.db") ), false ) ); - } + } +} + +void BackendImpl::addDataToDb( + OUString const & url, ConfigurationBackendDb::Data const & data) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url, data); +} + +::boost::optional BackendImpl::readDataFromDb( + OUString const & url) +{ + ::boost::optional data; + if (m_backendDb.get()) + data = m_backendDb->getEntry(url); + return data; } +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + +::std::list BackendImpl::getAllIniEntries() +{ + if (m_backendDb.get()) + return m_backendDb->getAllIniEntries(); + else + return ::std::list(); +} + + + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference > @@ -312,11 +364,12 @@ void BackendImpl::configmgrini_verify_init( if (create_ucb_content( 0, expandUnoRcTerm(token), xCmdEnv, false /* no throw */ )) { + //The file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the configmgrini. + //After running XExtensionManager::synchronize, the configmgrini is + //cleaned up m_xcs_files.push_back( token ); } - else - OSL_ENSURE( - 0, "### invalid SCHEMA entry!" ); } } while (index >= 0); @@ -333,10 +386,24 @@ void BackendImpl::configmgrini_verify_init( if (create_ucb_content( 0, expandUnoRcTerm(token), xCmdEnv, false /* no throw */ )) { + //The file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the configmgrini. + //After running XExtensionManager::synchronize, the configmgrini is + //cleaned up m_xcu_files.push_back( token ); } else - OSL_ENSURE( 0, "### invalid DATA entry!" ); + { + //Check if it was removed. Only when the file contained %origin, so that + //a new file was writen in the user installation (e.g. $BUNDLED_EXTENSIONS_USER) + //See also ConfigurationBackendDb.iniEntry + ::std::list iniEntries = getAllIniEntries(); + if (::std::find(iniEntries.begin(), iniEntries.end(), token) + != iniEntries.end()) + m_xcu_files.push_back( token ); + else + OSL_ENSURE(0, "Extension manager: Invalid configmgr.ini entry."); + } } } while (index >= 0); @@ -357,20 +424,6 @@ void BackendImpl::configmgrini_flush( return; ::rtl::OStringBuffer buf; - // UNO_USER_PACKAGES_CACHE, UNO_SHARED_PACKAGES_CACHE have to be resolved - // locally: - if (m_eContext == CONTEXT_USER) { - buf.append( RTL_CONSTASCII_STRINGPARAM( - "UNO_USER_PACKAGES_CACHE=$ORIGIN/../..") ); - } - else if (m_eContext == CONTEXT_SHARED) { - buf.append( RTL_CONSTASCII_STRINGPARAM( - "UNO_SHARED_PACKAGES_CACHE=$ORIGIN/../..") ); - } - else - OSL_ASSERT(0); - buf.append(LF); - if (! m_xcs_files.empty()) { t_stringlist::const_iterator iPos( m_xcs_files.begin() ); @@ -417,28 +470,11 @@ void BackendImpl::configmgrini_flush( m_configmgrini_modified = false; } -//------------------------------------------------------------------------------ -inline OUString makeRcTerm( OUString const & url ) -{ - OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( - "vnd.sun.star.expand:") ) ); - if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) { - // cut protocol: - OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); - // decode uric class chars: - rcterm = ::rtl::Uri::decode( - rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - return rcterm; - } - else - return url; -} - //______________________________________________________________________________ bool BackendImpl::addToConfigmgrIni( bool isSchema, OUString const & url_, Reference const & xCmdEnv ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); configmgrini_verify_init( xCmdEnv ); t_stringlist & rSet = getFiles(isSchema); @@ -458,15 +494,18 @@ bool BackendImpl::removeFromConfigmgrIni( bool isSchema, OUString const & url_, Reference const & xCmdEnv ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); configmgrini_verify_init( xCmdEnv ); t_stringlist & rSet = getFiles(isSchema); t_stringlist::iterator i(std::find(rSet.begin(), rSet.end(), rcterm)); - if (i == rSet.end() && !isSchema) { //TODO: see replaceOrigin() - i = std::find( - rSet.begin(), rSet.end(), - rcterm + OUString(RTL_CONSTASCII_USTRINGPARAM(".mod"))); + if (i == rSet.end() && !isSchema) + { + //in case the xcu contained %origin% then the configmr.ini contains the + //url to the file in the user installation (e.g. $BUNDLED_EXTENSIONS_USER) + ::boost::optional data = readDataFromDb(url_); + if (data) + i = std::find(rSet.begin(), rSet.end(), data->iniEntry); } if (i == rSet.end()) { return false; @@ -478,21 +517,6 @@ bool BackendImpl::removeFromConfigmgrIni( return true; } -//______________________________________________________________________________ -bool BackendImpl::hasInConfigmgrIni( - bool isSchema, OUString const & url_ ) -{ - const OUString rcterm( makeRcTerm(url_) ); - const ::osl::MutexGuard guard( getMutex() ); - t_stringlist const & rSet = getFiles(isSchema); - return ::std::find( rSet.begin(), rSet.end(), rcterm ) != rSet.end() - || (!isSchema && //TODO: see replaceOrigin() - ::std::find( - rSet.begin(), rSet.end(), - rcterm + OUString(RTL_CONSTASCII_USTRINGPARAM(".mod"))) != - rSet.end()); -} - //############################################################################## // Package @@ -519,14 +543,18 @@ BackendImpl::PackageImpl::isRegistered_( Reference const & ) { BackendImpl * that = getMyBackend(); - rtl::OUString url(getURL()); + const rtl::OUString url(getURL()); + + bool bReg = false; + if (that->readDataFromDb(getURL())) + bReg = true; + if (!bReg) + //fallback for user extension registered in berkeley DB + bReg = that->m_registeredPackages->has( + rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 )); + return beans::Optional< beans::Ambiguous >( - true /* IsPresent */, - beans::Ambiguous( - that->hasInConfigmgrIni( m_isSchema, url ) || - that->m_registeredPackages->has( - rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 ) ), - false /* IsAmbiguous */ ) ); + true, beans::Ambiguous( bReg, false ) ); } //------------------------------------------------------------------------------ @@ -564,7 +592,7 @@ OUString encodeForXml( OUString const & text ) //______________________________________________________________________________ OUString replaceOrigin( - OUString const & url, Reference< XCommandEnvironment > const & xCmdEnv ) + OUString const & url, OUString const & destFolder, Reference< XCommandEnvironment > const & xCmdEnv, bool & out_replaced) { // looking for %origin%: ::ucbhelper::Content ucb_content( url, xCmdEnv ); @@ -634,10 +662,17 @@ OUString replaceOrigin( return url; if (write_pos < filtered.getLength()) filtered.realloc( write_pos ); - rtl::OUString newUrl(url + OUString(RTL_CONSTASCII_USTRINGPARAM(".mod"))); - //TODO: unique name + rtl::OUString newUrl(url); + if (destFolder.getLength()) + { + //get the file name of the xcu and add it to the url of the temporary folder + sal_Int32 i = url.lastIndexOf('/'); + newUrl = destFolder + url.copy(i); + } + ucbhelper::Content(newUrl, xCmdEnv).writeStream( xmlscript::createInputStream(filtered), true); + out_replaced = true; return newUrl; } @@ -654,21 +689,37 @@ void BackendImpl::PackageImpl::processPackage_( if (doRegisterPackage) { - if (m_isSchema) + ConfigurationBackendDb::Data data; + if (!m_isSchema) { - com::sun::star::configuration::Update::get( - that->m_xComponentContext)->insertExtensionXcsFile( - that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); + bool out_replaced = false; + url = replaceOrigin(url, sModFolder, xCmdEnv, out_replaced); + if (out_replaced) + data.dataUrl = sModFolder; + else + deleteTempFolder(sModFolder); } - else + //No need for live-deployment for bundled extension, because OOo + //restarts after installation + if (that->m_eContext != CONTEXT_BUNDLED) { - url = replaceOrigin(url, xCmdEnv); - com::sun::star::configuration::Update::get( - that->m_xComponentContext)->insertExtensionXcuFile( - that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + if (m_isSchema) + { + com::sun::star::configuration::Update::get( + that->m_xComponentContext)->insertExtensionXcsFile( + that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + } + else + { + com::sun::star::configuration::Update::get( + that->m_xComponentContext)->insertExtensionXcuFile( + that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + } } - that->addToConfigmgrIni( m_isSchema, url, xCmdEnv ); + data.iniEntry = dp_misc::makeRcTerm(url); + that->addDataToDb(getURL(), data); } else // revoke { @@ -678,15 +729,31 @@ void BackendImpl::PackageImpl::processPackage_( for (t_string2string_map::iterator i(entries.begin()); i != entries.end(); ++i) { + //If the xcu file was installed before the configmgr was chaned + //to use the configmgr.ini, one needed to rebuild to whole directory + //structur containing the xcu, xcs files from all extensions. Now, + //we just add all other xcu/xcs files to the configmgr.ini instead of + //rebuilding the directory structure. rtl::OUString url2( rtl::OStringToOUString(i->first, RTL_TEXTENCODING_UTF8)); + ConfigurationBackendDb::Data data; if (url2 != url) { - bool schema = i->second.equalsIgnoreAsciiCase( - "vnd.sun.star.configuration-schema"); - if (!schema) { - url2 = replaceOrigin(url2, xCmdEnv); - } - that->addToConfigmgrIni(schema, url2, xCmdEnv); + bool schema = i->second.equalsIgnoreAsciiCase( + "vnd.sun.star.configuration-schema"); + OUString url_replaced(url2); + if (!schema) + { + const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); + bool out_replaced = false; + url_replaced = replaceOrigin( + url2, sModFolder, xCmdEnv, out_replaced); + if (out_replaced) + data.dataUrl = sModFolder; + else + deleteTempFolder(sModFolder); + } + that->addToConfigmgrIni(schema, url_replaced, xCmdEnv); + that->addDataToDb(url2, data); } that->m_registeredPackages->erase(i->first); } @@ -695,6 +762,7 @@ void BackendImpl::PackageImpl::processPackage_( xCmdEnv ).executeCommand( OUSTR("delete"), Any( true /* delete physically */ ) ); } + that->deleteDataFromDb(getURL()); //TODO: revoking at runtime, possible, sensible? } diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx new file mode 100644 index 000000000000..845ba88cb813 --- /dev/null +++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx @@ -0,0 +1,186 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_package.cxx,v $ + * $Revision: 1.34.16.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_configurationbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/configuration-registry/2010" +#define NS_PREFIX "conf" +#define ROOT_ELEMENT_NAME "configuration-backend-db" +#define KEY_ELEMENT_NAME "configuration" + +namespace dp_registry { +namespace backend { +namespace configuration { + +ConfigurationBackendDb::ConfigurationBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString ConfigurationBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ConfigurationBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + +OUString ConfigurationBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +OUString ConfigurationBackendDb::getKeyElementName() +{ + return OUSTR(KEY_ELEMENT_NAME); +} + + +void ConfigurationBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + Reference helpNode + = writeKeyElement(url); + + writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); + writeSimpleElement(OUSTR("ini-entry"), data.iniEntry, helpNode); + save(); + } + catch (css::deployment::DeploymentException& ) + { + throw; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in configuration backend db: ") + + m_urlDb, 0, exc); + } +} + + +::boost::optional +ConfigurationBackendDb::getEntry(::rtl::OUString const & url) +{ + try + { + ConfigurationBackendDb::Data retData; + Reference aNode = getKeyElement(url); + if (aNode.is()) + { + retData.dataUrl = readSimpleElement(OUSTR("data-url"), aNode); + retData.iniEntry = readSimpleElement(OUSTR("ini-entry"), aNode); + } + else + { + return ::boost::optional(); + } + return ::boost::optional(retData); + } + catch (css::deployment::DeploymentException& ) + { + throw; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in configuration backend db: ") + + m_urlDb, 0, exc); + } +} + +::std::list ConfigurationBackendDb::getAllDataUrls() +{ + try + { + ::std::list listRet; + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + const OUString sPrefix = getNSPrefix(); + OUString sExpression( + sPrefix + OUSTR(":configuration/") + sPrefix + OUSTR(":data-url/text()")); + Reference nodes = + xpathApi->selectNodeList(root, sExpression); + if (nodes.is()) + { + sal_Int32 length = nodes->getLength(); + for (sal_Int32 i = 0; i < length; i++) + listRet.push_back(nodes->item(i)->getNodeValue()); + } + return listRet; + } + catch (css::deployment::DeploymentException& ) + { + throw; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in configuration backend db: ") + + m_urlDb, 0, exc); + } +} + +::std::list ConfigurationBackendDb::getAllIniEntries() +{ + return getOneChildFromAllEntries(OUSTR("ini-entry")); +} + + + +} // namespace configuration +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx new file mode 100644 index 000000000000..1b6c4f8973a4 --- /dev/null +++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_backend.h,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_CONFIGURATIONBACKENDDB_HXX +#define INCLUDED_DP_CONFIGURATIONBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include "boost/optional.hpp" +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + +namespace dp_registry { +namespace backend { +namespace configuration { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + */ +class ConfigurationBackendDb: public dp_registry::backend::BackendDb +{ +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getNSPrefix(); + + virtual ::rtl::OUString getRootElementName(); + + virtual ::rtl::OUString getKeyElementName(); + +public: + struct Data + { + /* the URL to the folder containing the xcu or xcs files which contained + %origin% + */ + ::rtl::OUString dataUrl; + /* the URL of the xcu or xcs file which is written in to the configmgr.ini + */ + ::rtl::OUString iniEntry; + }; + +public: + + ConfigurationBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url, Data const & data); + + ::boost::optional getEntry(::rtl::OUString const & url); + ::std::list< ::rtl::OUString> getAllDataUrls(); + ::std::list< ::rtl::OUString> getAllIniEntries(); +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/configuration/makefile.mk b/desktop/source/deployment/registry/configuration/makefile.mk index f549b0e7b0f8..9bcbd50d4230 100644 --- a/desktop/source/deployment/registry/configuration/makefile.mk +++ b/desktop/source/deployment/registry/configuration/makefile.mk @@ -44,7 +44,8 @@ SRC1FILES = \ dp_configuration.src SLOFILES = \ - $(SLO)$/dp_configuration.obj + $(SLO)$/dp_configuration.obj \ + $(SLO)$/dp_configurationbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 9a83ca63d36e..ea31f75c6b6b 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -239,6 +239,22 @@ OUString PackageRegistryBackend::createFolder( return destFolder; } +void PackageRegistryBackend::deleteTempFolder( + OUString const & folderUrl) +{ + OSL_ASSERT(folderUrl.getLength() + && folderUrl[folderUrl.getLength() - 1] == '_'); + if (folderUrl.getLength() + && folderUrl[folderUrl.getLength() - 1] == '_') + { + const OUString tempFile = folderUrl.copy(0, folderUrl.getLength() - 1); + erase_path( folderUrl, Reference(), + false /* no throw: ignore errors */ ); + erase_path( tempFile, Reference(), + false /* no throw: ignore errors */ ); + } +} + void PackageRegistryBackend::deleteUnusedFolders( OUString const & relUrl, ::std::list< OUString> const & usedFolders) @@ -273,16 +289,12 @@ void PackageRegistryBackend::deleteUnusedFolders( { //usedFolders contains the urls to the folders which have //a trailing underscore - const OUString tempFile = tempEntries[ pos ]; - const OUString tempFolderName = tempFile + OUSTR("_"); + const OUString tempFolderName = tempEntries[ pos ] + OUSTR("_"); if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolderName ) == usedFolders.end()) { - erase_path( tempFolderName, Reference(), - false /* no throw: ignore errors */ ); - erase_path( tempFile, Reference(), - false /* no throw: ignore errors */ ); + deleteTempFolder(tempFolder); } } } diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 660c5ad80bf1..1f4a62e696d7 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -509,6 +509,51 @@ OUString BackendDb::readSimpleElement( } } +::std::list BackendDb::getOneChildFromAllEntries( + OUString const & name) +{ + try + { + ::std::list listRet; + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + const OUString sPrefix = getNSPrefix(); + const OUString sKeyElement = getKeyElementName(); + ::rtl::OUStringBuffer buf(512); + buf.append(sPrefix); + buf.appendAscii(":"); + buf.append(sKeyElement); + buf.appendAscii("/"); + buf.append(sPrefix); + buf.appendAscii(":"); + buf.append(name); + buf.append(OUSTR("/text()")); + + Reference nodes = + xpathApi->selectNodeList(root, buf.makeStringAndClear()); + if (nodes.is()) + { + sal_Int32 length = nodes->getLength(); + for (sal_Int32 i = 0; i < length; i++) + listRet.push_back(nodes->item(i)->getNodeValue()); + } + return listRet; + } + catch (css::deployment::DeploymentException& ) + { + throw; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + //================================================================================ diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 7e8f128bbf12..bc17a1f7163d 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -66,7 +66,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend { BackendImpl * getMyBackend() const; - HelpBackendDb::Data m_dbData; +// HelpBackendDb::Data m_dbData; // Package virtual beans::Optional< beans::Ambiguous > isRegistered_( @@ -234,13 +234,13 @@ BackendImpl::PackageImpl::PackageImpl( : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) { - if (bRemoved) - { - ::boost::optional opt = - getMyBackend()->readDataFromDb(url); - if (opt) - m_dbData = *opt; - } +// if (bRemoved) +// { +// ::boost::optional opt = +// getMyBackend()->readDataFromDb(url); +// if (opt) +// m_dbData = *opt; +// } } // Package diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index 4a8fa71e0618..3bf67e0c050b 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -100,7 +100,7 @@ void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { Any exc( ::cppu::getCaughtException() ); throw css::deployment::DeploymentException( - OUSTR("Extension Manager: failed to write data entry in backend db: ") + + OUSTR("Extension Manager: failed to write data entry in help backend db: ") + m_urlDb, 0, exc); } } @@ -131,7 +131,7 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) { Any exc( ::cppu::getCaughtException() ); throw css::deployment::DeploymentException( - OUSTR("Extension Manager: failed to read data entry in backend db: ") + + OUSTR("Extension Manager: failed to read data entry in help backend db: ") + m_urlDb, 0, exc); } } @@ -166,7 +166,7 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) { Any exc( ::cppu::getCaughtException() ); throw css::deployment::DeploymentException( - OUSTR("Extension Manager: failed to read data entry in backend db: ") + + OUSTR("Extension Manager: failed to read data entry in help backend db: ") + m_urlDb, 0, exc); } } diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx index baecf0da48e6..edf7dfdfc284 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -32,8 +32,6 @@ #define INCLUDED_DP_HELPBACKENDDB_HXX #include "rtl/ustring.hxx" -#include "rtl/string.hxx" -#include #include #include "boost/optional.hpp" #include "dp_backenddb.hxx" @@ -44,13 +42,6 @@ namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } - namespace xml { namespace dom { - class XDocument; - class XNode; - }} - namespace xml { namespace xpath { - class XXPathAPI; - }} }}} namespace dp_registry { diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 7b11ae456d5d..3d3bf7cf912c 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -336,6 +336,11 @@ protected: void deleteUnusedFolders( ::rtl::OUString const & relUrl, ::std::list< ::rtl::OUString> const & usedFolders); + /* deletes one folder with a "temporary" name and the corresponding + tmp file, which was used to derive the folder name. + */ + static void deleteTempFolder( + ::rtl::OUString const & folderUrl); public: diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index b8ba5facd492..cf0bb5129292 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -117,7 +117,10 @@ protected: ::rtl::OUString const & sListTagName, ::rtl::OUString const & sMemberTagName); - + /* returns the values of one particulary child element of all key elements. + */ + ::std::list< ::rtl::OUString> BackendDb::getOneChildFromAllEntries( + ::rtl::OUString const & sElementName); /* returns the namespace which is to be written as xmlns attribute -- cgit From 1711ca5365d607f09507b3d1420403b11cd49064 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 10 May 2010 11:20:35 +0100 Subject: cmcfixes75: #i111508# implement a com.sun.star.mail.Mailserver in mailmerge.py --- scripting/source/pyprov/mailmerge.py | 120 ++++++++++++++++++++++++++++++----- 1 file changed, 104 insertions(+), 16 deletions(-) diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py index f9c2f0f70b09..55c204f87dbf 100644 --- a/scripting/source/pyprov/mailmerge.py +++ b/scripting/source/pyprov/mailmerge.py @@ -16,6 +16,8 @@ import uno import re #to implement com::sun::star::mail::XMailServiceProvider +#and +#to implement com.sun.star.mail.XMailMessage from com.sun.star.mail import XMailServiceProvider from com.sun.star.mail import XMailService @@ -37,7 +39,7 @@ from email import Encoders from email.Header import Header from email.MIMEMultipart import MIMEMultipart from email.Utils import formatdate -from email.Utils import formataddr +from email.Utils import parseaddr import sys, smtplib, imaplib, poplib @@ -118,30 +120,46 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): print >> sys.stderr, "PyMailSMPTService sendMailMessage" recipients = xMailMessage.getRecipients() sendermail = xMailMessage.SenderAddress - sendername = xMailMessage.SenderName + sendername = xMailMessage.SenderName subject = xMailMessage.Subject ccrecipients = xMailMessage.getCcRecipients() bccrecipients = xMailMessage.getBccRecipients() if dbg: print >> sys.stderr, "PyMailSMPTService subject", subject - print >> sys.stderr, "PyMailSMPTService from", sendername.encode('utf-8'), sendermail - print >> sys.stderr, "PyMailSMTPService from", formataddr((sendername.encode('utf-8'), sendermail)) + print >> sys.stderr, "PyMailSMPTService from", sendername.encode('utf-8') + print >> sys.stderr, "PyMailSMTPService from", sendermail print >> sys.stderr, "PyMailSMPTService send to", recipients attachments = xMailMessage.getAttachments() + textmsg = Message() + content = xMailMessage.Body flavors = content.getTransferDataFlavors() - flavor = flavors[0] if dbg: - print >> sys.stderr, "PyMailSMPTService mimetype is", flavor.MimeType - textbody = content.getTransferData(flavor) + print >> sys.stderr, "PyMailSMPTService flavors len", len(flavors) - textmsg = Message() - mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType) - textmsg['Content-Type'] = mimeEncoding - textmsg['MIME-Version'] = '1.0' - textmsg.set_payload(textbody.encode('utf-8')) + #Use first flavor that's sane for an email body + for flavor in flavors: + if flavor.MimeType.find('text/html') != -1 or flavor.MimeType.find('text/plain') != -1: + if dbg: + print >> sys.stderr, "PyMailSMPTService mimetype is", flavor.MimeType + textbody = content.getTransferData(flavor) + try: + textbody = textbody.value + except: + pass + textbody = textbody.encode('utf-8') + + if len(textbody): + mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType) + if mimeEncoding.find('charset=UTF-8') == -1: + mimeEncoding = mimeEncoding + "; charset=UTF-8" + textmsg['Content-Type'] = mimeEncoding + textmsg['MIME-Version'] = '1.0' + textmsg.set_payload(textbody) + + break if (len(attachments)): msg = MIMEMultipart() @@ -150,15 +168,31 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): else: msg = textmsg - msg['Subject'] = subject - msg['From'] = formataddr((sendername.encode('utf-8'), sendermail)) + hdr = Header(sendername, 'utf-8') + hdr.append('<'+sendermail+'>','us-ascii') + msg['Subject'] = subject + msg['From'] = hdr msg['To'] = COMMASPACE.join(recipients) if len(ccrecipients): msg['Cc'] = COMMASPACE.join(ccrecipients) if xMailMessage.ReplyToAddress != '': msg['Reply-To'] = xMailMessage.ReplyToAddress - msg['X-Mailer'] = "OpenOffice.org 2.0 via Caolan's mailmerge component" + mailerstring = "OpenOffice.org 2.0 via Caolan's mailmerge component" + try: + ctx = uno.getComponentContext() + aConfigProvider = ctx.ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider") + prop = uno.createUnoStruct('com.sun.star.beans.PropertyValue') + prop.Name = "nodepath" + prop.Value = "/org.openoffice.Setup/Product" + aSettings = aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", + (prop,)) + mailerstring = aSettings.getByName("ooName") + " " + \ + aSettings.getByName("ooSetupVersion") + " via Caolan's mailmerge component" + except: + pass + + msg['X-Mailer'] = mailerstring msg['Date'] = formatdate(localtime=True) for attachment in attachments: @@ -344,9 +378,63 @@ class PyMailServiceProvider(unohelper.Base, XMailServiceProvider): else: print >> sys.stderr, "PyMailServiceProvider, unknown TYPE", aType +class PyMailMessage(unohelper.Base, XMailMessage): + def __init__( self, ctx, sTo='', sFrom='', Subject='', Body=None, aMailAttachment=None ): + if dbg: + print >> sys.stderr, "PyMailMessage init" + self.ctx = ctx + + self.recipients = sTo, + self.ccrecipients = () + self.bccrecipients = () + self.aMailAttachments = () + if aMailAttachment != None: + self.aMailAttachments = aMailAttachment, + + self.SenderName, self.SenderAddress = parseaddr(sFrom) + self.ReplyToAddress = sFrom + self.Subject = Subject + self.Body = Body + if dbg: + print >> sys.stderr, "post PyMailMessage init" + def addRecipient( self, recipient ): + if dbg: + print >> sys.stderr, "PyMailMessage.addRecipient", recipient + self.recipients = self.recipients, recipient + def addCcRecipient( self, ccrecipient ): + if dbg: + print >> sys.stderr, "PyMailMessage.addCcRecipient", ccrecipient + self.ccrecipients = self.ccrecipients, ccrecipient + def addBccRecipient( self, bccrecipient ): + if dbg: + print >> sys.stderr, "PyMailMessage.addBccRecipient", bccrecipient + self.bccrecipients = self.bccrecipients, bccrecipient + def getRecipients( self ): + if dbg: + print >> sys.stderr, "PyMailMessage.getRecipients", self.recipients + return self.recipients + def getCcRecipients( self ): + if dbg: + print >> sys.stderr, "PyMailMessage.getCcRecipients", self.ccrecipients + return self.ccrecipients + def getBccRecipients( self ): + if dbg: + print >> sys.stderr, "PyMailMessage.getBccRecipients", self.bccrecipients + return self.bccrecipients + def addAttachment( self, aMailAttachment ): + if dbg: + print >> sys.stderr, "PyMailMessage.addAttachment" + self.aMailAttachments = self.aMailAttachments, aMailAttachment + def getAttachments( self ): + if dbg: + print >> sys.stderr, "PyMailMessage.getAttachments" + return self.aMailAttachments + # pythonloader looks for a static g_ImplementationHelper variable g_ImplementationHelper = unohelper.ImplementationHelper() g_ImplementationHelper.addImplementation( \ PyMailServiceProvider, "org.openoffice.pyuno.MailServiceProvider", ("com.sun.star.mail.MailServiceProvider",),) - +g_ImplementationHelper.addImplementation( \ + PyMailMessage, "org.openoffice.pyuno.MailMessage", + ("com.sun.star.mail.MailMessage",),) -- cgit From 0e1079119202c55866d01479e913a30bf7513ce6 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Mon, 10 May 2010 13:58:03 +0200 Subject: CWS mba33issues01: #i109842#: delete global resources in pro version also --- sfx2/source/appl/appquit.cxx | 50 -------------------------------------------- 1 file changed, 50 deletions(-) diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx index 4da32cf9f566..d615d90ff37a 100644 --- a/sfx2/source/appl/appquit.cxx +++ b/sfx2/source/appl/appquit.cxx @@ -74,57 +74,11 @@ using ::basic::BasicManagerRepository; -#ifdef DBG_UTIL -DECLARE_LIST( SfxFrameWindowFactoryArray_Impl, SfxFrameWindowFactory* ) -SV_DECL_PTRARR(SfxInitLinkList, Link*, 2, 2) -#endif - //=================================================================== BOOL SfxApplication::QueryExit_Impl() { BOOL bQuit = TRUE; -/* - BOOL bPrinting = FALSE; - for ( SfxViewShell *pViewSh = SfxViewShell::GetFirst(); - !bPrinting && pViewSh; - pViewSh = SfxViewShell::GetNext(*pViewSh) ) - { - SfxPrinter *pPrinter = pViewSh->GetPrinter(); - bPrinting = pPrinter && pPrinter->IsPrinting(); - } - - if ( bPrinting ) - { - // Benutzer fragen, ob abgebrochen werden soll - if ( RET_OK == QueryBox( 0, SfxResId( MSG_ISPRINTING_QUERYABORT ) ).Execute() ) - { - // alle Jobs canceln - for ( SfxViewShell *pViewSh = SfxViewShell::GetFirst(); - !bPrinting && pViewSh; - pViewSh = SfxViewShell::GetNext(*pViewSh) ) - { - SfxPrinter *pPrinter = pViewSh->GetPrinter(); - if ( pPrinter && pPrinter->IsPrinting() ) - pPrinter->AbortJob(); - } - - // da das Canceln asynchron ist, Quit erstmal wieder verlassen - GetDispatcher_Impl()->Execute( SID_QUITAPP, SFX_CALLMODE_ASYNCHRON ); - DBG_TRACE( "QueryExit => FALSE (printing)" ); - return FALSE; - } - } -*/ -/* - SfxObjectShell *pLastDocSh = SfxObjectShell::GetFirst(); - if ( bQuit ) - { - // Jetzt zur Sicherheit auch hidden Frames abr"aumen - SfxViewFrame::CloseHiddenFrames_Impl(); - pLastDocSh = SfxObjectShell::GetFirst(); - } -*/ // will trotzdem noch jemand, den man nicht abschiessen kann, die App haben? if ( !bQuit ) { @@ -197,22 +151,18 @@ void SfxApplication::Deinitialize() delete pAppData_Impl->pLabelResMgr; -#ifdef DBG_UTIL DELETEX(pAppData_Impl->pSlotPool); DELETEX(pAppData_Impl->pEventConfig); SfxMacroConfig::Release_Impl(); DELETEX(pAppData_Impl->pFactArr); DELETEX(pAppData_Impl->pInitLinkList); -#endif -#ifdef DBG_UTIL DELETEX(pAppData_Impl->pTbxCtrlFac); DELETEX(pAppData_Impl->pStbCtrlFac); DELETEX(pAppData_Impl->pMenuCtrlFac); DELETEX(pAppData_Impl->pViewFrames); DELETEX(pAppData_Impl->pViewShells); DELETEX(pAppData_Impl->pObjShells); -#endif //TODO/CLEANTUP //ReleaseArgs could be used instead! -- cgit From 311a2cbcf6532e47027abfef191b94fb60aaab7c Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Mon, 10 May 2010 13:58:53 +0200 Subject: CWS mba33issues01: #i108607#: resolve operator ambiguity --- svx/source/svdraw/svdoole2.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 88d9aba87673..15c2ecb9c564 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -1714,8 +1714,8 @@ void SdrOle2Obj::ImpSetVisAreaSize() if ( pClient || bHasOwnClient ) { // TODO/LATER: IMHO we need to do similar things when object is UIActive or OutplaceActive?! (MBA) - if ( (nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) && - svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() ) + if ( ((nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) && + svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() )) || xObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE ) { -- cgit From b8dc3e6f63c57c92f877d392ef013127f41c5d44 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 10 May 2010 15:19:49 +0200 Subject: jl152 fixing merge conflict --- desktop/source/deployment/registry/dp_backend.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index ea31f75c6b6b..d781ba9e40ef 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -294,7 +294,7 @@ void PackageRegistryBackend::deleteUnusedFolders( if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolderName ) == usedFolders.end()) { - deleteTempFolder(tempFolder); + deleteTempFolder(tempFolderName); } } } -- cgit From be45f3f14b9f103e12ddc343f483086eff10011e Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 10 May 2010 15:53:56 +0200 Subject: jl152: #i77196# typo --- desktop/source/deployment/registry/inc/dp_backenddb.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index cf0bb5129292..a0e477979f8c 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -119,7 +119,7 @@ protected: /* returns the values of one particulary child element of all key elements. */ - ::std::list< ::rtl::OUString> BackendDb::getOneChildFromAllEntries( + ::std::list< ::rtl::OUString> getOneChildFromAllEntries( ::rtl::OUString const & sElementName); -- cgit From c288dd322747e11a5c779f155ba39e799a9920c2 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 10 May 2010 17:35:24 +0200 Subject: jl152: #i108704# allow to restart the office --- desktop/scripts/soffice.sh | 9 +++++++-- desktop/source/app/app.cxx | 21 ++++++++++++++++++++- desktop/source/inc/exithelper.hxx | 2 ++ desktop/unx/source/officeloader/officeloader.cxx | 2 +- desktop/win32/source/officeloader/officeloader.cxx | 3 ++- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh index ebbdeb9eabdb..fae9dbe4d695 100644 --- a/desktop/scripts/soffice.sh +++ b/desktop/scripts/soffice.sh @@ -120,9 +120,14 @@ trap 'kill -9 $!' TERM wait $! sd_ret=$? -while [ $sd_ret -eq 79 ] +while [ $sd_ret -eq 79 -o $sd_ret -eq 81 ] do - "$sd_prog/$sd_binary" ""$BOOTSTRAPVARS"" & + if [ $sd_ret -eq 79 ]; then + "$sd_prog/$sd_binary" ""$BOOTSTRAPVARS"" & + elif if [ $sd_ret -eq 81 ]; then + "$sd_prog/$sd_binary" "$@" & + fi + wait $! sd_ret=$? done diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 8e610fb0e141..3b0a1ea0dcf8 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -84,6 +84,7 @@ #include #include #include +#include #ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_ #include #endif @@ -103,6 +104,7 @@ #include #include #include +#include #include #ifndef _UTL__HXX_ #include @@ -140,6 +142,7 @@ #include #include #include +#include #include "vos/process.hxx" @@ -1615,6 +1618,7 @@ void Desktop::Main() // call Application::Execute to process messages in vcl message loop RTL_LOGFILE_PRODUCT_TRACE( "PERFORMANCE - enter Application::Execute()" ); + Reference< ::com::sun::star::task::XRestartManager > xRestartManager; try { // The JavaContext contains an interaction handler which is used when @@ -1622,7 +1626,11 @@ void Desktop::Main() com::sun::star::uno::ContextLayer layer2( new svt::JavaContext( com::sun::star::uno::getCurrentContext() ) ); - Execute(); + ::comphelper::ComponentContext aContext( xSMgr ); + xRestartManager.set( aContext.getSingleton( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.OfficeRestartManager" ) ) ), UNO_QUERY ); + + if ( !xRestartManager.is() || !xRestartManager->isRestartRequested( sal_True ) ) + Execute(); } catch(const com::sun::star::document::CorruptedFilterConfigurationException& exFilterCfg) { @@ -1635,6 +1643,9 @@ void Desktop::Main() FatalError( MakeStartupErrorMessage(exAnyCfg.Message) ); } + // check whether the shutdown is caused by restart + sal_Bool bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); + if (xGlobalBroadcaster.is()) { css::document::EventObject aEvent; @@ -1671,6 +1682,14 @@ void Desktop::Main() RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- deinit ucb" ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "FINISHED WITH Destop::Main" ); + if ( bRestartRequested ) + { +#ifdef MACOSX + DoRestart(); +#endif + // wouldn't the solution be more clean if SalMain returns the exit code to the system? + _exit( ExitHelper::E_NORMAL_RESTART ); + } } IMPL_LINK( Desktop, ImplInitFilterHdl, ConvertData*, pData ) diff --git a/desktop/source/inc/exithelper.hxx b/desktop/source/inc/exithelper.hxx index 2e6d7e774d98..e2604ce49b68 100644 --- a/desktop/source/inc/exithelper.hxx +++ b/desktop/source/inc/exithelper.hxx @@ -58,6 +58,8 @@ class ExitHelper E_FATAL_ERROR = 333, // Only the low 8 bits are significant 333 % 256 = 77 /// user force automatic restart after crash E_CRASH_WITH_RESTART = 79, + /// the office restarts itself + E_NORMAL_RESTART = 81 }; }; diff --git a/desktop/unx/source/officeloader/officeloader.cxx b/desktop/unx/source/officeloader/officeloader.cxx index de84985cdea6..87621960c61a 100755 --- a/desktop/unx/source/officeloader/officeloader.cxx +++ b/desktop/unx/source/officeloader/officeloader.cxx @@ -93,7 +93,7 @@ SAL_IMPLEMENT_MAIN() if ( info.Fields & osl_Process_EXITCODE ) { exitcode = info.Code; - bRestart = (ExitHelper::E_CRASH_WITH_RESTART == exitcode); + bRestart = (ExitHelper::E_CRASH_WITH_RESTART == exitcode || ExitHelper::E_NORMAL_RESTART == exitcode); } else break; diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx index f36bfc134ded..2d602a6d6507 100644 --- a/desktop/win32/source/officeloader/officeloader.cxx +++ b/desktop/win32/source/officeloader/officeloader.cxx @@ -416,7 +416,8 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) CloseHandle( aProcessInfo.hProcess ); CloseHandle( aProcessInfo.hThread ); } - } while ( fSuccess && ::desktop::ExitHelper::E_CRASH_WITH_RESTART == dwExitCode ); + } while ( fSuccess + && ( ::desktop::ExitHelper::E_CRASH_WITH_RESTART == dwExitCode || ::desktop::ExitHelper::E_NORMAL_RESTART == dwExitCode ); delete[] lpCommandLine; return fSuccess ? dwExitCode : -1; -- cgit From d3fa4e4b471979d44494079aafa2a1018cc91fa0 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 10 May 2010 17:55:28 +0200 Subject: jl152: #i108704# fix typo --- desktop/scripts/soffice.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh index fae9dbe4d695..0215f88d1ff0 100644 --- a/desktop/scripts/soffice.sh +++ b/desktop/scripts/soffice.sh @@ -124,7 +124,7 @@ while [ $sd_ret -eq 79 -o $sd_ret -eq 81 ] do if [ $sd_ret -eq 79 ]; then "$sd_prog/$sd_binary" ""$BOOTSTRAPVARS"" & - elif if [ $sd_ret -eq 81 ]; then + elif [ $sd_ret -eq 81 ]; then "$sd_prog/$sd_binary" "$@" & fi -- cgit From ddd3ac4abb2054e30440198bc9ab54ae227d1f82 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 11 May 2010 14:48:15 +0200 Subject: CWS mba33issues01: #i111452#: allow to call getController() at disposed frames without assertion --- framework/source/services/frame.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index 18d5a1c31bef..08a7c522831b 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -1551,8 +1551,9 @@ css::uno::Reference< css::awt::XWindow > SAL_CALL Frame::getComponentWindow() th css::uno::Reference< css::frame::XController > SAL_CALL Frame::getController() throw( css::uno::RuntimeException ) { /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ + // It seems to be unavoidable that disposed frames allow to ask for a Controller (#111452) // Register transaction and reject wrong calls. - TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); + // TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ ReadGuard aReadLock( m_aLock ); -- cgit From cd50d383f645aa1d188331039d334faebfa1add0 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Wed, 12 May 2010 08:38:13 +0200 Subject: CWS mba33issues01: #i105239#: safe way to access SfxApplication in IMEStatusWindow --- sfx2/inc/sfx2/app.hxx | 2 +- sfx2/source/appl/appdata.cxx | 5 ++--- sfx2/source/appl/imestatuswindow.cxx | 6 +++--- sfx2/source/appl/imestatuswindow.hxx | 7 +------ sfx2/source/bastyp/progress.cxx | 2 +- sfx2/source/control/unoctitm.cxx | 2 +- sfx2/source/view/viewfrm.cxx | 2 +- 7 files changed, 10 insertions(+), 16 deletions(-) diff --git a/sfx2/inc/sfx2/app.hxx b/sfx2/inc/sfx2/app.hxx index 17b2dee417cd..e38a2e9dbe7f 100644 --- a/sfx2/inc/sfx2/app.hxx +++ b/sfx2/inc/sfx2/app.hxx @@ -258,7 +258,7 @@ public: void ResetLastDir(); //#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE static SfxApplication* Is_Impl() { return pApp;} + SAL_DLLPRIVATE static SfxApplication* Get() { return pApp;} SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl(); SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl(); diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index a07623df46b1..38ea69280c49 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -89,7 +89,7 @@ void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XM m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager ); } -SfxAppData_Impl::SfxAppData_Impl( SfxApplication* pApp ) : +SfxAppData_Impl::SfxAppData_Impl( SfxApplication* ) : pDdeService( 0 ), pDocTopics( 0 ), pTriggerTopic(0), @@ -116,8 +116,7 @@ SfxAppData_Impl::SfxAppData_Impl( SfxApplication* pApp ) : nRescheduleLocks(0), nInReschedule(0), nAsynchronCalls(0), - m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow( - *pApp, comphelper::getProcessServiceFactory())) + m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessServiceFactory())) , pTbxCtrlFac(0) , pStbCtrlFac(0) , pViewFrames(0) diff --git a/sfx2/source/appl/imestatuswindow.cxx b/sfx2/source/appl/imestatuswindow.cxx index 3cdc3064fb81..07eb47bd92ad 100644 --- a/sfx2/source/appl/imestatuswindow.cxx +++ b/sfx2/source/appl/imestatuswindow.cxx @@ -57,10 +57,8 @@ namespace css = com::sun::star; using sfx2::appl::ImeStatusWindow; ImeStatusWindow::ImeStatusWindow( - SfxApplication & rApplication, css::uno::Reference< css::lang::XMultiServiceFactory > const & rServiceFactory): - m_rApplication(rApplication), m_xServiceFactory(rServiceFactory), m_bDisposed(false) {} @@ -161,7 +159,9 @@ ImeStatusWindow::propertyChange(css::beans::PropertyChangeEvent const & ) throw (css::uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - m_rApplication.Invalidate(SID_SHOW_IME_STATUS_WINDOW); + SfxApplication* pApp = SfxApplication::Get(); + if (pApp) + pApp->Invalidate(SID_SHOW_IME_STATUS_WINDOW); } css::uno::Reference< css::beans::XPropertySet > ImeStatusWindow::getConfig() diff --git a/sfx2/source/appl/imestatuswindow.hxx b/sfx2/source/appl/imestatuswindow.hxx index 71c0b371f796..4edba523ed30 100644 --- a/sfx2/source/appl/imestatuswindow.hxx +++ b/sfx2/source/appl/imestatuswindow.hxx @@ -37,7 +37,6 @@ namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } namespace lang { class XMultiServiceFactory; } } } } -class SfxApplication; namespace sfx2 { namespace appl { @@ -56,10 +55,7 @@ ImeStatusWindow_Impl; class ImeStatusWindow: private ImeStatusWindow_Impl { public: - ImeStatusWindow(SfxApplication & rApplication, - com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > const & - rServiceFactory); + ImeStatusWindow( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > const& rServiceFactory ); /** Set up VCL according to the configuration. @@ -115,7 +111,6 @@ private: com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > getConfig(); - SfxApplication & m_rApplication; com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory; diff --git a/sfx2/source/bastyp/progress.cxx b/sfx2/source/bastyp/progress.cxx index 649ae121c274..3af0ba2b0a6f 100644 --- a/sfx2/source/bastyp/progress.cxx +++ b/sfx2/source/bastyp/progress.cxx @@ -706,7 +706,7 @@ SfxProgress* SfxProgress::GetActiveProgress */ { - if ( !SfxApplication::Is_Impl() ) + if ( !SfxApplication::Get() ) return 0; SfxProgress *pProgress = 0; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index d2ad8c645eb7..e53f1766b7b9 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -823,7 +823,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const ::com::sun::star::util pItem = pDispatcher->Execute( GetId(), nCall, 0, &aInternalSet, nModifier ); // no bindings, no invalidate ( usually done in SfxDispatcher::Call_Impl()! ) - if ( SfxApplication::Is_Impl() ) + if ( SfxApplication::Get() ) { SfxDispatcher* pAppDispat = SFX_APP()->GetAppDispatcher_Impl(); if ( pAppDispat ) diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 66af0d7ac8ba..0d3c1f727e5b 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1510,7 +1510,7 @@ void SfxViewFrame::KillDispatcher_Impl() //------------------------------------------------------------------------ SfxViewFrame* SfxViewFrame::Current() { - return SfxApplication::Is_Impl() ? SFX_APP()->Get_Impl()->pViewFrame : NULL; + return SfxApplication::Get() ? SFX_APP()->Get_Impl()->pViewFrame : NULL; } //-------------------------------------------------------------------- -- cgit From defd78c476f1dc496bfa98c1701740a957803270 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 12 May 2010 08:55:24 +0100 Subject: cmcfixes75: #i111551# remove unused getGlobalTransactionManager --- framework/inc/threadhelp/transactionmanager.hxx | 1 - framework/source/threadhelp/transactionmanager.cxx | 36 ---------------------- 2 files changed, 37 deletions(-) diff --git a/framework/inc/threadhelp/transactionmanager.hxx b/framework/inc/threadhelp/transactionmanager.hxx index a3ce7e67ea8a..eca13d63103c 100644 --- a/framework/inc/threadhelp/transactionmanager.hxx +++ b/framework/inc/threadhelp/transactionmanager.hxx @@ -93,7 +93,6 @@ class TransactionManager : public ITransactionManager virtual sal_Bool isCallRejected ( ERejectReason& eReason ) const; virtual void registerTransaction ( EExceptionMode eMode, ERejectReason& eReason ) throw( css::uno::RuntimeException, css::lang::DisposedException ); virtual void unregisterTransaction ( ) throw( css::uno::RuntimeException, css::lang::DisposedException ); - static TransactionManager& getGlobalTransactionManager ( ); //------------------------------------------------------------------------------------------------------------- // private methods diff --git a/framework/source/threadhelp/transactionmanager.cxx b/framework/source/threadhelp/transactionmanager.cxx index 34b4892ccebe..a42c871c176e 100644 --- a/framework/source/threadhelp/transactionmanager.cxx +++ b/framework/source/threadhelp/transactionmanager.cxx @@ -318,42 +318,6 @@ sal_Bool TransactionManager::isCallRejected( ERejectReason& eReason ) const return( eReason!=E_NOREASON ); } -/*-****************************************************************************************************//** - @short return a reference to a static manager - @descr Sometimes we need the global member! (e.g. in our own static methods) - We create our own "class global static" member threadsafe. - It will be created at first call only! - All other requests use these created one then directly. - - @seealso - - - @param - - @return A reference to a static member. - - @onerror No error should occure. -*//*-*****************************************************************************************************/ -TransactionManager& TransactionManager::getGlobalTransactionManager() -{ - // Initialize static member only for one time! - static TransactionManager* pManager = NULL; - // If these method first called (member not already exist!) ... - if( pManager == NULL ) - { - // ... we must create a new one. Protect follow code with the global mutex - - // It must be - we create a static variable! - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - // We must check our pointer again - because ... another instance of ouer class could be faster then these one! - if( pManager == NULL ) - { - // Create the new manager and set it for return on static variable. - static TransactionManager aManager; - pManager = &aManager; - } - } - // Return new created or already existing object. - return *pManager; -} - /*-****************************************************************************************************//** @short throw any exceptions for rejected calls @descr If user whish to use our automaticly exception mode we use this impl-method. -- cgit From 2af4a389327fbf8640fdb5f69eb8d1637f0e86bf Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Wed, 12 May 2010 16:11:41 +0200 Subject: jl152 #i77196# restarting at startup when shared/bundled extensions were changed, fixed typo in win32/source/officeloader/officeloader.cxx --- desktop/source/app/check_ext_deps.cxx | 2 +- desktop/source/deployment/misc/dp_misc.cxx | 23 ++- .../deployment/registry/component/dp_component.cxx | 195 +++++++++++---------- .../registry/configuration/dp_configuration.cxx | 5 +- .../deployment/registry/script/dp_script.cxx | 99 ++++++----- desktop/win32/source/officeloader/officeloader.cxx | 2 +- 6 files changed, 178 insertions(+), 148 deletions(-) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 7629a5c5cf83..757135a7e2d3 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -395,7 +395,7 @@ sal_Bool Desktop::CheckExtensionDependencies() void Desktop::SynchronizeExtensionRepositories() { - RTL_LOGFILE_CONTEXT(aLog,"desktop (jl97489) ::Desktop::SynchronizeExtensionRepositories"); + RTL_LOGFILE_CONTEXT(aLog,"desktop (jl) ::Desktop::SynchronizeExtensionRepositories"); OUString sDisable; ::rtl::Bootstrap::get( UNISTRING( "DISABLE_SYNC_EXTENSIONS" ), sDisable, OUString() ); if (sDisable.getLength() > 0) diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 799542a4757f..b68593c7f174 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -42,9 +42,11 @@ #include "osl/thread.hxx" #include "osl/mutex.hxx" #include "com/sun/star/ucb/CommandAbortedException.hpp" +#include "com/sun/star/task/XInteractionHandler.hpp" #include "com/sun/star/bridge/UnoUrlResolver.hpp" #include "com/sun/star/bridge/XUnoUrlResolver.hpp" #include "com/sun/star/deployment/ExtensionManager.hpp" +#include "com/sun/star/task/XRestartManager.hpp" #include "boost/scoped_array.hpp" #include "boost/shared_ptr.hpp" #include @@ -600,7 +602,8 @@ void syncRepositories(Reference const & xCmdEnv) Reference xExtensionManager; //synchronize shared before bundled otherewise there are //more revoke and registration calls. - OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); + bool bSynced = false; + const OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); if (needToSyncRepostitory(sShared)) { xExtensionManager = @@ -611,10 +614,11 @@ void syncRepositories(Reference const & xCmdEnv) { xExtensionManager->synchronize( sShared, Reference(), xCmdEnv); + bSynced = true; } } - OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); + const OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); if (needToSyncRepostitory( sBundled)) { if (!xExtensionManager.is()) @@ -627,9 +631,22 @@ void syncRepositories(Reference const & xCmdEnv) { xExtensionManager->synchronize( sBundled, Reference(), xCmdEnv); - + bSynced = true; } } + + if (bSynced) + { + Reference restarter( + comphelper_getProcessComponentContext()->getValueByName( + OUSTR( "/singletons/com.sun.star.task.OfficeRestartManager") ), UNO_QUERY ); + if (restarter.is()) + { + fprintf(stdout, "\nrestarting\n"); + restarter->requestRestart(xCmdEnv.is() == sal_True ? xCmdEnv->getInteractionHandler() : + Reference()); + } + } } diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index fc9880438bac..e0844c227669 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -1275,63 +1275,66 @@ void BackendImpl::ComponentPackageImpl::processPackage_( data.implementationNames = implNames; data.singletons = singletons; - // factories live insertion: - const Reference xSet( - that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); - for ( t_stringlist::const_iterator iPos( implNames.begin() ); - iPos != implNames.end(); ++iPos ) + if (!startup) { - checkAborted( abortChannel ); - OUString const & implName = *iPos; - // activate factory: - const Reference 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?" ); + // factories live insertion: + const Reference 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 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 xRootContext( - that->getComponentContext()->getValueByName( - OUSTR("_root") ), UNO_QUERY ); - if (xRootContext.is()) + if (! singletons.empty()) { - for ( t_stringpairvec::const_iterator iPos( - singletons.begin() ); - iPos != singletons.end(); ++iPos ) + // singletons live insertion: + const Reference xRootContext( + that->getComponentContext()->getValueByName( + OUSTR("_root") ), UNO_QUERY ); + if (xRootContext.is()) { - ::std::pair 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() ); + for ( t_stringpairvec::const_iterator iPos( + singletons.begin() ); + iPos != singletons.end(); ++iPos ) + { + ::std::pair 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() ); + } } } } @@ -1365,53 +1368,57 @@ void BackendImpl::ComponentPackageImpl::processPackage_( { getComponentInfo( &implNames, &singletons, xContext ); } - // factories live removal: - const Reference xSet( - that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); - for ( t_stringlist::const_iterator iPos( implNames.begin() ); - iPos != implNames.end(); ++iPos ) + + if (!startup) { - OUString const & implName = *iPos; - try { - xSet->remove( Any(implName) ); - } // ignore if factory has not been live deployed: - catch (container::NoSuchElementException &) { + // factories live removal: + const Reference 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 xRootContext( - that->getComponentContext()->getValueByName( - OUSTR("_root") ), UNO_QUERY ); - if (xRootContext.is()) + if (! singletons.empty()) { - for ( t_stringpairvec::const_iterator iPos( - singletons.begin() ); - iPos != singletons.end(); ++iPos ) + // singletons live removal: + const Reference xRootContext( + that->getComponentContext()->getValueByName( + OUSTR("_root") ), UNO_QUERY ); + if (xRootContext.is()) { - ::std::pair 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() ); + for ( t_stringpairvec::const_iterator iPos( + singletons.begin() ); + iPos != singletons.end(); ++iPos ) + { + ::std::pair 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() ); + } } } } diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 1a6738b0270b..f892c21a6a6b 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -680,7 +680,7 @@ OUString replaceOrigin( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, - bool /*startup*/, + bool startup, ::rtl::Reference const &, Reference const & xCmdEnv ) { @@ -702,7 +702,8 @@ void BackendImpl::PackageImpl::processPackage_( } //No need for live-deployment for bundled extension, because OOo //restarts after installation - if (that->m_eContext != CONTEXT_BUNDLED) + if (that->m_eContext != CONTEXT_BUNDLED + && !startup) { if (m_isSchema) { diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 414d4c1c61cd..3a43e916e39e 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -331,7 +331,7 @@ BackendImpl::PackageImpl::isRegistered_( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, - bool /* startup */, + bool startup, ::rtl::Reference const &, Reference const & xCmdEnv ) { @@ -382,7 +382,8 @@ void BackendImpl::PackageImpl::processPackage_( if (bRegistered) { - if (!isRemoved()) + //we also prevent and live deployment at startup + if (!isRemoved() && !startup) { if (bScript && xScriptLibs.is() && xScriptLibs->hasByName(m_name)) { @@ -409,66 +410,70 @@ void BackendImpl::PackageImpl::processPackage_( bool bScriptSuccess = false; const bool bReadOnly = false; - //If there is a bundled extension, and the user installes the same extension - //then the script from the bundled extension must be removed. If this does not work - //then live deployment does not work for scripts. - if (bScript && xScriptLibs.is()) + bool bDialogSuccess = false; + if (!startup) { - bool bCanAdd = true; - if (xScriptLibs->hasByName(m_name)) + //If there is a bundled extension, and the user installes the same extension + //then the script from the bundled extension must be removed. If this does not work + //then live deployment does not work for scripts. + if (bScript && xScriptLibs.is()) { - const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name); - //We assume here that library names in extensions are unique, which may not be the case - //ToDo: If the script exist in another extension, then both extensions must have the - //same id - if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) - || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) - || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + bool bCanAdd = true; + if (xScriptLibs->hasByName(m_name)) { - xScriptLibs->removeLibrary(m_name); - bCanAdd = true; + const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + { + xScriptLibs->removeLibrary(m_name); + bCanAdd = true; + } + else + { + bCanAdd = false; + } } - else + + if (bCanAdd) { - bCanAdd = false; + xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly ); + bScriptSuccess = xScriptLibs->hasByName( m_name ); } } - if (bCanAdd) - { - xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly ); - bScriptSuccess = xScriptLibs->hasByName( m_name ); - } - } - bool bDialogSuccess = false; - if (bDialog && xDialogLibs.is()) - { - bool bCanAdd = true; - if (xDialogLibs->hasByName(m_dialogName)) + if (bDialog && xDialogLibs.is()) { - const OUString sOriginalUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName); - //We assume here that library names in extensions are unique, which may not be the case - //ToDo: If the script exist in another extension, then both extensions must have the - //same id - if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) - || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) - || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + bool bCanAdd = true; + if (xDialogLibs->hasByName(m_dialogName)) { - xDialogLibs->removeLibrary(m_dialogName); - bCanAdd = true; + const OUString sOriginalUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + { + xDialogLibs->removeLibrary(m_dialogName); + bCanAdd = true; + } + else + { + bCanAdd = false; + } } - else + + if (bCanAdd) { - bCanAdd = false; + xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly ); + bDialogSuccess = xDialogLibs->hasByName(m_dialogName); } } - - if (bCanAdd) - { - xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly ); - bDialogSuccess = xDialogLibs->hasByName(m_dialogName); - } } bool bSuccess = bScript || bDialog; // Something must have happened if( bRunning ) diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx index 2d602a6d6507..ef980e1e994e 100644 --- a/desktop/win32/source/officeloader/officeloader.cxx +++ b/desktop/win32/source/officeloader/officeloader.cxx @@ -417,7 +417,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) CloseHandle( aProcessInfo.hThread ); } } while ( fSuccess - && ( ::desktop::ExitHelper::E_CRASH_WITH_RESTART == dwExitCode || ::desktop::ExitHelper::E_NORMAL_RESTART == dwExitCode ); + && ( ::desktop::ExitHelper::E_CRASH_WITH_RESTART == dwExitCode || ::desktop::ExitHelper::E_NORMAL_RESTART == dwExitCode )); delete[] lpCommandLine; return fSuccess ? dwExitCode : -1; -- cgit From d0a3afc82beed2c1d2e0035a0cc5d43bb6acf774 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 17 May 2010 10:40:52 +0200 Subject: jl152 #i77196# only restarting if a extension was added/removed, XextensionManager.getSupportedArguments: removed repository argument --- desktop/source/app/app.cxx | 10 ++------ desktop/source/deployment/gui/dp_gui_dialog2.cxx | 3 ++- .../deployment/manager/dp_extensionmanager.cxx | 30 ++++++++++------------ .../deployment/manager/dp_extensionmanager.hxx | 4 +-- desktop/source/deployment/manager/dp_manager.cxx | 24 +++++++++++------ desktop/source/deployment/manager/dp_manager.h | 6 ++--- desktop/source/deployment/misc/dp_misc.cxx | 15 +++++------ 7 files changed, 45 insertions(+), 47 deletions(-) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 3b0a1ea0dcf8..ebc0ab743125 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1399,11 +1399,9 @@ void Desktop::Main() // and process those extensions (has to be done before checking // the extension dependencies! SynchronizeExtensionRepositories(); - bool bAbort = CheckExtensionDependencies(); if ( bAbort ) return; - // First Start Wizard allowed ? if ( ! pCmdLineArgs->IsNoFirstStartWizard()) { @@ -1447,7 +1445,6 @@ void Desktop::Main() } SetSplashScreenProgress(50); - // Backing Component sal_Bool bCrashed = sal_False; sal_Bool bExistsRecoveryData = sal_False; @@ -1628,7 +1625,6 @@ void Desktop::Main() ::comphelper::ComponentContext aContext( xSMgr ); xRestartManager.set( aContext.getSingleton( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.OfficeRestartManager" ) ) ), UNO_QUERY ); - if ( !xRestartManager.is() || !xRestartManager->isRestartRequested( sal_True ) ) Execute(); } @@ -1654,22 +1650,20 @@ void Desktop::Main() } delete pResMgr; - // Restore old value if ( pCmdLineArgs->IsHeadless() ) SvtMiscOptions().SetUseSystemFileDialog( bUseSystemFileDialog ); // remove temp directory RemoveTemporaryDirectory(); - // The acceptors in the AcceptorMap must be released (in DeregisterServices) // with the solar mutex unlocked, to avoid deadlock: nAcquireCount = Application::ReleaseSolarMutex(); + printf("###1\n"); DeregisterServices(); + printf("###2\n"); Application::AcquireSolarMutex(nAcquireCount); - tools::DeInitTestToolLib(); - // be sure that path/language options gets destroyed before // UCB is deinitialized RTL_LOGFILE_CONTEXT_TRACE( aLog, "-> dispose path/language options" ); diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 164bb833fd6d..086e39e5f18c 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -877,7 +877,8 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker() t_string2string title2filter; OUString sDefaultFilter( StrAllFiles::get() ); - const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( m_pManager->getExtensionManager()->getSupportedPackageTypes( OUSTR("user") ) ); + const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( + m_pManager->getExtensionManager()->getSupportedPackageTypes() ); for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos ) { diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 83e68dff255e..edc414dc6f5d 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -402,16 +402,19 @@ Reference ExtensionManager::backupExtension( return xBackup; } +//The supported package types are actually determined by the registry. However +//creating a registry +//(desktop/source/deployment/registry/dp_registry.cxx:PackageRegistryImpl) will +//create all the backends, so that the registry can obtain from them the package +//types. Creating the registry will also set up the registry folder containing +//all the subfolders for the respective backends. +//Because all repositories support the same backends, we can just delegate this +//call to one of the repositories. uno::Sequence< Reference > -ExtensionManager::getSupportedPackageTypes(OUString const & repository) +ExtensionManager::getSupportedPackageTypes() throw (uno::RuntimeException) { - if (repository.equals(OUSTR("user"))) - return m_userRepository->getSupportedPackageTypes(); - else if (repository.equals(OUSTR("shared"))) - return m_sharedRepository->getSupportedPackageTypes(); - else - return uno::Sequence< Reference >(); + return m_userRepository->getSupportedPackageTypes(); } // Only add to shared and user repository @@ -437,7 +440,6 @@ Reference ExtensionManager::addExtension( throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(getMutex()); Reference xTmpExtension = getTempExtension(url, xAbortChannel, xCmdEnv); @@ -448,7 +450,6 @@ Reference ExtensionManager::addExtension( dp_misc::DescriptionInfoset info(dp_misc::getDescriptionInfoset(xTmpExtension->getURL())); const ::boost::optional licenseAttributes = info.getSimpleLicenseAttributes(); - Reference xOldExtension; Reference xExtensionBackup; @@ -481,14 +482,12 @@ Reference ExtensionManager::addExtension( //the action. checkInstall(sDisplayName, xCmdEnv); } - //Prevent showing the license if requested. Reference _xCmdEnv(xCmdEnv); ExtensionProperties props(OUString(), properties, Reference()); if (licenseAttributes && licenseAttributes->suppressIfRequired && props.isSuppressedLicense()) _xCmdEnv = Reference(new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler())); - bCanInstall = xTmpExtension->checkPrerequisites( xAbortChannel, _xCmdEnv, xOldExtension.is()) == 0 ? true : false; } @@ -528,10 +527,8 @@ Reference ExtensionManager::addExtension( xOldExtension, Reference(), tmpCmdEnv); } - xNewExtension = xPackageManager->addPackage( url, properties, OUString(), xAbortChannel, xCmdEnv); - //If we add a user extension and there is already one which was //disabled by a user, then the newly installed one is enabled. If we //add to another repository then the user extension remains @@ -1023,7 +1020,7 @@ void ExtensionManager::reinstallDeployedExtensions( } } -void ExtensionManager::synchronize( +sal_Bool ExtensionManager::synchronize( OUString const & repository, Reference const & xAbortChannel, Reference const & xCmdEnv ) @@ -1035,6 +1032,7 @@ void ExtensionManager::synchronize( { try { + sal_Bool bModified = sal_False; Reference xPackageManager; OUString file; if (repository.equals(OUSTR("user"))) @@ -1065,7 +1063,7 @@ void ExtensionManager::synchronize( sSynchronizing.SearchAndReplaceAllAscii( "%NAME", repository ); dp_misc::ProgressLevel progress(xCmdEnv, sSynchronizing); - xPackageManager->synchronize(xAbortChannel, xCmdEnv); + bModified = xPackageManager->synchronize(xAbortChannel, xCmdEnv); try { const uno::Sequence > > @@ -1109,6 +1107,7 @@ void ExtensionManager::synchronize( static_cast(this), exc); } + return bModified; } catch (deploy::DeploymentException& ) { throw; } catch (ucb::CommandFailedException & ) { @@ -1202,7 +1201,6 @@ Reference ExtensionManager::getTempExtension( Reference tmpCmdEnvA(new TmpRepositoryCommandEnv()); Reference xTmpPackage = m_tmpRepository->addPackage( url, uno::Sequence(),OUString(), xAbortChannel, tmpCmdEnvA); - if (!xTmpPackage.is()) { throw deploy::DeploymentException( diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index e6c9ca3aa915..4367770945aa 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -78,7 +78,7 @@ public: //XExtensionManager virtual css::uno::Sequence< css::uno::Reference > SAL_CALL - getSupportedPackageTypes(::rtl::OUString const & repository) + getSupportedPackageTypes() throw (css::uno::RuntimeException); virtual css::uno::Reference SAL_CALL @@ -185,7 +185,7 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); - virtual void SAL_CALL synchronize( + virtual sal_Bool SAL_CALL synchronize( ::rtl::OUString const & repository, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 69b2baab8878..7844e11b0651 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -1245,7 +1245,7 @@ void PackageManagerImpl::reinstallDeployedPackages( { return m_readOnly; } -void PackageManagerImpl::synchronizeRemovedExtensions( +bool PackageManagerImpl::synchronizeRemovedExtensions( Reference const & xAbortChannel, Reference const & xCmdEnv) { @@ -1253,6 +1253,7 @@ void PackageManagerImpl::synchronizeRemovedExtensions( //find all which are in the extension data base but which //are removed already. OSL_ASSERT(!m_context.equals(OUSTR("user"))); + bool bModified = false; ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); typedef ActivePackages::Entries::const_iterator ITActive; @@ -1322,6 +1323,7 @@ void PackageManagerImpl::synchronizeRemovedExtensions( xPackage->revokePackage(xAbortChannel, xCmdEnv); removePackage(xPackage->getIdentifier().Value, xPackage->getName(), xAbortChannel, xCmdEnv); + bModified |= true; } } catch( uno::Exception & ) @@ -1329,14 +1331,15 @@ void PackageManagerImpl::synchronizeRemovedExtensions( OSL_ASSERT(0); } } + return bModified; } -void PackageManagerImpl::synchronizeAddedExtensions( +bool PackageManagerImpl::synchronizeAddedExtensions( Reference const & xAbortChannel, Reference const & xCmdEnv) { - // clean up activation layer, scan for zombie temp dirs: + bool bModified = false; ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); ::ucbhelper::Content tempFolder( @@ -1441,6 +1444,7 @@ void PackageManagerImpl::synchronizeAddedExtensions( //try to install the extension again. dbData.failedPrerequisites = OUString::valueOf(failedPrereq); insertToActivationLayerDB(id, dbData); + bModified |= true; } } } @@ -1449,9 +1453,10 @@ void PackageManagerImpl::synchronizeAddedExtensions( OSL_ASSERT(0); } } + return bModified; } -void PackageManagerImpl::synchronize( +sal_Bool PackageManagerImpl::synchronize( Reference const & xAbortChannel, Reference const & xCmdEnv) throw (css::deployment::DeploymentException, @@ -1459,12 +1464,15 @@ void PackageManagerImpl::synchronize( css::ucb::CommandAbortedException, css::uno::RuntimeException) { - check(); + bool bModified = false; if (m_context.equals(OUSTR("user"))) - return; - synchronizeRemovedExtensions(xAbortChannel, xCmdEnv); - synchronizeAddedExtensions(xAbortChannel, xCmdEnv); + return bModified; + bModified |= + synchronizeRemovedExtensions(xAbortChannel, xCmdEnv); + bModified |= synchronizeAddedExtensions(xAbortChannel, xCmdEnv); + + return bModified; } Sequence< Reference > PackageManagerImpl::getExtensionsWithUnacceptedLicenses( diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h index 2e13c56ae968..8fe0f662011b 100644 --- a/desktop/source/deployment/manager/dp_manager.h +++ b/desktop/source/deployment/manager/dp_manager.h @@ -89,11 +89,11 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper bool isInstalled( css::uno::Reference const & package); - void synchronizeRemovedExtensions( + bool synchronizeRemovedExtensions( css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); - void synchronizeAddedExtensions( + bool synchronizeAddedExtensions( css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); @@ -246,7 +246,7 @@ public: virtual ::sal_Bool SAL_CALL isReadOnly( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL synchronize( + virtual ::sal_Bool SAL_CALL synchronize( css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index b68593c7f174..5ccc3d7225d4 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -602,7 +602,7 @@ void syncRepositories(Reference const & xCmdEnv) Reference xExtensionManager; //synchronize shared before bundled otherewise there are //more revoke and registration calls. - bool bSynced = false; + bool bModified = false; const OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); if (needToSyncRepostitory(sShared)) { @@ -612,9 +612,8 @@ void syncRepositories(Reference const & xCmdEnv) if (xExtensionManager.is()) { - xExtensionManager->synchronize( + bModified = xExtensionManager->synchronize( sShared, Reference(), xCmdEnv); - bSynced = true; } } @@ -629,24 +628,22 @@ void syncRepositories(Reference const & xCmdEnv) } if (xExtensionManager.is()) { - xExtensionManager->synchronize( + bModified |= xExtensionManager->synchronize( sBundled, Reference(), xCmdEnv); - bSynced = true; } } - if (bSynced) + if (bModified) { Reference restarter( comphelper_getProcessComponentContext()->getValueByName( OUSTR( "/singletons/com.sun.star.task.OfficeRestartManager") ), UNO_QUERY ); if (restarter.is()) { - fprintf(stdout, "\nrestarting\n"); restarter->requestRestart(xCmdEnv.is() == sal_True ? xCmdEnv->getInteractionHandler() : Reference()); - } - } + } + } } -- cgit From 885511f9be6f9e437687216affc1fb5c7d99054b Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 17 May 2010 16:42:05 +0200 Subject: jl152 #i77196# office hangs in smoketest when it is about to restart itself --- desktop/source/deployment/misc/dp_misc.cxx | 2 +- desktop/source/offacc/acceptor.cxx | 6 ++++++ desktop/source/offacc/acceptor.hxx | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 5ccc3d7225d4..3867f741f982 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -602,7 +602,7 @@ void syncRepositories(Reference const & xCmdEnv) Reference xExtensionManager; //synchronize shared before bundled otherewise there are //more revoke and registration calls. - bool bModified = false; + sal_Bool bModified = false; const OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); if (needToSyncRepostitory(sShared)) { diff --git a/desktop/source/offacc/acceptor.cxx b/desktop/source/offacc/acceptor.cxx index 4eee12f5949a..4e100fd99665 100644 --- a/desktop/source/offacc/acceptor.cxx +++ b/desktop/source/offacc/acceptor.cxx @@ -67,6 +67,7 @@ Acceptor::Acceptor( const Reference< XMultiServiceFactory >& rFactory ) , m_aConnectString() , m_aProtocol() , m_bInit(sal_False) + , m_bDying(false) { m_rSMgr = rFactory; m_rAcceptor = Reference< XAcceptor > (m_rSMgr->createInstance( @@ -88,6 +89,9 @@ Acceptor::~Acceptor() osl::MutexGuard g(m_aMutex); t = m_thread; } + //prevent locking if the thread is still waiting + m_bDying = true; + m_cEnable.set(); osl_joinWithThread(t); { // Make the final state of m_bridges visible to this thread (since @@ -117,6 +121,8 @@ void SAL_CALL Acceptor::run() RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109)"\ "Acceptor::run waiting for office to come up"); m_cEnable.wait(); + if (m_bDying) //see destructor + break; RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109)"\ "Acceptor::run now enabled and continuing"); diff --git a/desktop/source/offacc/acceptor.hxx b/desktop/source/offacc/acceptor.hxx index 1693dd8b75d0..87f50db032dd 100644 --- a/desktop/source/offacc/acceptor.hxx +++ b/desktop/source/offacc/acceptor.hxx @@ -83,6 +83,7 @@ private: OUString m_aProtocol; sal_Bool m_bInit; + bool m_bDying; public: Acceptor( const Reference< XMultiServiceFactory >& aFactory ); -- cgit From eef1fd8ab2966ee3b2934d9050b0a14c4478e1f6 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 18 May 2010 14:59:37 +0200 Subject: jl152 #i77196# smoketest now uses new extension manager service --- desktop/source/app/app.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index ebc0ab743125..5e0460891c30 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1659,9 +1659,7 @@ void Desktop::Main() // The acceptors in the AcceptorMap must be released (in DeregisterServices) // with the solar mutex unlocked, to avoid deadlock: nAcquireCount = Application::ReleaseSolarMutex(); - printf("###1\n"); DeregisterServices(); - printf("###2\n"); Application::AcquireSolarMutex(nAcquireCount); tools::DeInitTestToolLib(); // be sure that path/language options gets destroyed before -- cgit From e6d9970ba08599dfaf13998b9cc0908554f00176 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 18 May 2010 15:50:04 +0200 Subject: jl152 #i77196# adapted migration code to use new extension manager, removed old unused migration code, adapted ooo improvement dialog to appear after third start, taking into account the restarting after extension installation --- desktop/prj/build.lst | 3 +- desktop/source/deployment/dp_services.cxx | 6 - desktop/source/deployment/makefile.mk | 1 - .../source/deployment/migration/dp_migration.cxx | 251 ---------- desktop/source/deployment/migration/makefile.mk | 41 -- desktop/source/migration/services/cexports.cxx | 12 +- .../migration/services/extensionmigration.cxx | 540 --------------------- .../migration/services/extensionmigration.hxx | 130 ----- desktop/source/migration/services/makefile.mk | 2 - .../migration/services/oo3extensionmigration.cxx | 33 +- .../migration/services/oo3extensionmigration.hxx | 8 +- .../openoffice/Office/OOoImprovement/Settings.xcs | 2 +- 12 files changed, 28 insertions(+), 1001 deletions(-) delete mode 100644 desktop/source/deployment/migration/dp_migration.cxx delete mode 100644 desktop/source/deployment/migration/makefile.mk delete mode 100755 desktop/source/migration/services/extensionmigration.cxx delete mode 100755 desktop/source/migration/services/extensionmigration.hxx diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst index 6f611926a0df..8029b6ecc9f7 100644 --- a/desktop/prj/build.lst +++ b/desktop/prj/build.lst @@ -21,10 +21,9 @@ dt desktop\os2\source\applauncher nmake - p dt_applauncher dt_inc NULL dt desktop\unx\source\officeloader nmake - u dt_officeloader_unx dt_inc NULL dt desktop\source\pagein nmake - u dt_pagein dt_inc NULL dt desktop\source\pkgchk\unopkg nmake - all dt_unopkg dt_dp_misc dt_app dt_inc dt_guiloader.w NULL -dt desktop\source\deployment nmake - all dt_deployment dt_dp_manager dt_dp_registry dt_dp_registry_package dt_dp_registry_executable dt_dp_registry_help dt_dp_registry_script dt_dp_registry_sfwk dt_dp_registry_component dt_dp_registry_configuration dt_dp_migration dt_dp_unopkg dt_inc dt_dp_misc NULL +dt desktop\source\deployment nmake - all dt_deployment dt_dp_manager dt_dp_registry dt_dp_registry_package dt_dp_registry_executable dt_dp_registry_help dt_dp_registry_script dt_dp_registry_sfwk dt_dp_registry_component dt_dp_registry_configuration dt_dp_unopkg dt_inc dt_dp_misc NULL dt desktop\source\deployment\misc nmake - all dt_dp_misc dt_inc NULL dt desktop\source\deployment\unopkg nmake - all dt_dp_unopkg dt_inc NULL -dt desktop\source\deployment\migration nmake - all dt_dp_migration dt_inc NULL dt desktop\source\deployment\gui nmake - all dt_dp_gui dt_dp_misc dt_inc NULL dt desktop\source\deployment\manager nmake - all dt_dp_manager dt_inc NULL dt desktop\source\deployment\registry nmake - all dt_dp_registry dt_inc NULL diff --git a/desktop/source/deployment/dp_services.cxx b/desktop/source/deployment/dp_services.cxx index 05b9a2a1971a..f7ebf66355ba 100644 --- a/desktop/source/deployment/dp_services.cxx +++ b/desktop/source/deployment/dp_services.cxx @@ -77,10 +77,6 @@ namespace dp_log { extern sdecl::ServiceDecl const serviceDecl; } -namespace dp_migration { -extern sdecl::ServiceDecl const serviceDecl; -} - namespace dp_info { extern sdecl::ServiceDecl const serviceDecl; bool singleton_entries( uno::Reference const& ); @@ -110,7 +106,6 @@ sal_Bool SAL_CALL component_writeInfo( dp_registry::backend::executable::serviceDecl, dp_manager::factory::serviceDecl, dp_log::serviceDecl, - dp_migration::serviceDecl, dp_info::serviceDecl, dp_manager::serviceDecl) && dp_manager::factory::singleton_entries( pRegistryKey ) && @@ -133,7 +128,6 @@ void * SAL_CALL component_getFactory( dp_registry::backend::executable::serviceDecl, dp_manager::factory::serviceDecl, dp_log::serviceDecl, - dp_migration::serviceDecl, dp_info::serviceDecl, dp_manager::serviceDecl); } diff --git a/desktop/source/deployment/makefile.mk b/desktop/source/deployment/makefile.mk index 173ff35bec1d..6d83a5c1004b 100644 --- a/desktop/source/deployment/makefile.mk +++ b/desktop/source/deployment/makefile.mk @@ -53,7 +53,6 @@ SHL1VERSIONMAP = $(SOLARENV)/src/component.map SHL1LIBS = \ $(SLB)$/deployment_manager.lib \ - $(SLB)$/deployment_migration.lib \ $(SLB)$/deployment_registry.lib \ $(SLB)$/deployment_registry_executable.lib \ $(SLB)$/deployment_registry_component.lib \ diff --git a/desktop/source/deployment/migration/dp_migration.cxx b/desktop/source/deployment/migration/dp_migration.cxx deleted file mode 100644 index c2d0b0dc6bb8..000000000000 --- a/desktop/source/deployment/migration/dp_migration.cxx +++ /dev/null @@ -1,251 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_desktop.hxx" - -#include "dp_misc.h" -#include "dp_ucb.h" -#include "cppuhelper/implbase1.hxx" -#include "cppuhelper/implbase2.hxx" -#include "cppuhelper/exc_hlp.hxx" -#include "ucbhelper/content.hxx" -#include "comphelper/anytostring.hxx" -#include "comphelper/servicedecl.hxx" -#include "com/sun/star/lang/WrappedTargetException.hpp" -#include "com/sun/star/task/XJob.hpp" -#include "com/sun/star/task/XInteractionAbort.hpp" -#include "com/sun/star/task/XInteractionApprove.hpp" -#include "com/sun/star/sdbc/XResultSet.hpp" -#include "com/sun/star/sdbc/XRow.hpp" -#include "com/sun/star/ucb/XContentAccess.hpp" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" - - -using namespace ::com::sun::star; -using namespace ::com::sun::star::ucb; -using namespace ::com::sun::star::uno; -using namespace ::dp_misc; -using ::rtl::OUString; - -namespace dp_migration { - -class MigrationImpl : public ::cppu::WeakImplHelper1 -{ - struct CommandEnvironmentImpl - : public ::cppu::WeakImplHelper2< XCommandEnvironment, - task::XInteractionHandler > - { - // XCommandEnvironment - virtual Reference SAL_CALL - getInteractionHandler() throw (RuntimeException); - virtual Reference SAL_CALL getProgressHandler() - throw (RuntimeException); - // XInteractionHandler - virtual void SAL_CALL handle( - Reference const & xRequest ) - throw (RuntimeException); - }; - - const Reference m_xContext; - OUString m_userData; - -protected: - virtual ~MigrationImpl(); -public: - MigrationImpl( Sequence const & args, - Reference const & xComponentContext ); - - // XJob - virtual Any SAL_CALL execute( Sequence const & args ) - throw (lang::IllegalArgumentException, Exception, RuntimeException); -}; - -MigrationImpl::~MigrationImpl() -{ -} - -MigrationImpl::MigrationImpl( - Sequence const & args, Reference const & xContext ) - : m_xContext(xContext) -{ - for ( sal_Int32 pos = args.getLength(); pos--; ) - { - const beans::NamedValue nv(args[pos].get()); - if (nv.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UserData") )) - m_userData = nv.Value.get(); - } - if (m_userData.getLength() == 0) - throw lang::IllegalArgumentException( OUSTR("missing UserData!"), 0, - static_cast(-1) ); -} - -// XJob -Any MigrationImpl::execute( Sequence const & ) - throw (lang::IllegalArgumentException, Exception, RuntimeException) -{ - const Reference xManager( - deployment::thePackageManagerFactory::get( - m_xContext )->getPackageManager( OUSTR("user") ) ); - ::ucbhelper::Content packagesDir; - if (create_ucb_content( &packagesDir, - makeURL( m_userData, OUSTR("user/uno_packages") ), - Reference(), - false /* no throw */ )) - { - const Reference xCmdEnv( - new CommandEnvironmentImpl ); - OUString const & strTitle = StrTitle::get(); - const Reference xResultSet( - packagesDir.createCursor( Sequence( &strTitle, 1 ), - ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); - while (xResultSet->next()) - { - Reference xRow( xResultSet, UNO_QUERY_THROW ); - const OUString title( xRow->getString( 1 /* Title */ ) ); - // exclude stampIt, not migratable to OOo 2.0: - if (title.matchIgnoreAsciiCaseAsciiL( - RTL_CONSTASCII_STRINGPARAM("SSICONCT.") )) - continue; - const OUString sourceURL( Reference( - xResultSet, UNO_QUERY_THROW ) - ->queryContentIdentifierString() ); - try { - xManager->addPackage( - sourceURL, uno::Sequence(),OUString() /* detect media-type */, - Reference(), xCmdEnv ); - } - catch (RuntimeException &) { - throw; - } - catch (Exception &) { - OSL_ENSURE( 0, ::rtl::OUStringToOString( - ::comphelper::anyToString( - ::cppu::getCaughtException() ), - RTL_TEXTENCODING_UTF8 ).getStr() ); - } - } - } - return Any(); -} - -// XCommandEnvironment -Reference -MigrationImpl::CommandEnvironmentImpl::getInteractionHandler() - throw (RuntimeException) -{ - return this; -} - -Reference -MigrationImpl::CommandEnvironmentImpl::getProgressHandler() - throw (RuntimeException) -{ - return Reference(); -} - -// XInteractionHandler -void MigrationImpl::CommandEnvironmentImpl::handle( - Reference const & xRequest ) - throw (RuntimeException) -{ - Any request( xRequest->getRequest() ); - OSL_ASSERT( request.getValueTypeClass() == TypeClass_EXCEPTION ); -#if OSL_DEBUG_LEVEL > 1 - OSL_TRACE( "[dp_migration.cxx] incoming request:\n%s\n", - ::rtl::OUStringToOString( ::comphelper::anyToString(request), - RTL_TEXTENCODING_UTF8 ).getStr() ); -#endif - - // selections: - bool approve = false; - bool abort = false; - - lang::WrappedTargetException wtExc; - if (request >>= wtExc) { - OSL_ENSURE( 0, ::rtl::OUStringToOString( - ::comphelper::anyToString(wtExc.TargetException), - RTL_TEXTENCODING_UTF8 ).getStr() ); - - // ignore intermediate errors of legacy packages, i.e. - // former pkgchk behaviour: - const Reference xPackage( - wtExc.Context, UNO_QUERY ); - OSL_ASSERT( xPackage.is() ); - if (xPackage.is()) { - const Reference xPackageType( - xPackage->getPackageType() ); - OSL_ASSERT( xPackageType.is() ); - if (xPackageType.is()) { - approve = (xPackage->isBundle() && - xPackageType->getMediaType().matchAsciiL( - RTL_CONSTASCII_STRINGPARAM( - "application/" - "vnd.sun.star.legacy-package-bundle") )); - } - } - abort = !approve; - } - else - return; // unknown request => no selection at all - - // select: - const Sequence< Reference > conts( - xRequest->getContinuations() ); - for ( sal_Int32 pos = 0; pos < conts.getLength(); ++pos ) - { - if (approve) { - const Reference xInteractionApprove( - conts[ pos ], UNO_QUERY ); - if (xInteractionApprove.is()) { - xInteractionApprove->select(); - // don't query again for ongoing continuations: - approve = false; - } - } - else if (abort) { - const Reference xInteractionAbort( - conts[ pos ], UNO_QUERY ); - if (xInteractionAbort.is()) { - xInteractionAbort->select(); - // don't query again for ongoing continuations: - abort = false; - } - } - } -} - -namespace sdecl = comphelper::service_decl; -sdecl::class_ > serviceMI; -extern sdecl::ServiceDecl const serviceDecl( - serviceMI, - // a private one (config entry): - "com.sun.star.comp.deployment.migration.Migration_2_0", - "com.sun.star.comp.deployment.migration.Migration_2_0" ); - -} // namespace dp_migration - diff --git a/desktop/source/deployment/migration/makefile.mk b/desktop/source/deployment/migration/makefile.mk deleted file mode 100644 index a37b7e5bebf8..000000000000 --- a/desktop/source/deployment/migration/makefile.mk +++ /dev/null @@ -1,41 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ = ..$/..$/.. - -PRJNAME = desktop -TARGET = deployment_migration -ENABLE_EXCEPTIONS = TRUE - -.INCLUDE : settings.mk - -SLOFILES = \ - $(SLO)$/dp_migration.obj - -.INCLUDE : ..$/target.pmk -.INCLUDE : target.mk - diff --git a/desktop/source/migration/services/cexports.cxx b/desktop/source/migration/services/cexports.cxx index c1971e9d4d00..cf9a9ab30b0c 100644 --- a/desktop/source/migration/services/cexports.cxx +++ b/desktop/source/migration/services/cexports.cxx @@ -31,7 +31,7 @@ #include "cppuhelper/implementationentry.hxx" #include "basicmigration.hxx" #include "wordbookmigration.hxx" -#include "extensionmigration.hxx" +//#include "extensionmigration.hxx" extern "C" { @@ -48,11 +48,11 @@ extern "C" migration::WordbookMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory, 0, 0 }, - { - migration::ExtensionMigration_create, migration::ExtensionMigration_getImplementationName, - migration::ExtensionMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory, - 0, 0 - }, +// { +// migration::ExtensionMigration_create, migration::ExtensionMigration_getImplementationName, +// migration::ExtensionMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory, +// 0, 0 +// }, { 0, 0, 0, 0, 0, 0 } }; diff --git a/desktop/source/migration/services/extensionmigration.cxx b/desktop/source/migration/services/extensionmigration.cxx deleted file mode 100755 index 66f32744a782..000000000000 --- a/desktop/source/migration/services/extensionmigration.cxx +++ /dev/null @@ -1,540 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_desktop.hxx" -#include "extensionmigration.hxx" -#include -#include -#include -#include -#include -#include -#include -#include "comphelper/processfactory.hxx" -#include "com/sun/star/deployment/XPackageManagerFactory.hpp" -#include "com/sun/star/ucb/XCommandEnvironment.hpp" -#include "com/sun/star/xml/sax/XParser.hpp" -#include "rtl/instance.hxx" -#include "osl/file.hxx" -#include "osl/thread.h" - -#include "xmlscript/xmllib_imexp.hxx" -#include "../../deployment/inc/dp_ucb.h" - -#ifdef SYSTEM_DB -#include -#else -#include -#endif - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - -namespace { - - struct LibDescriptor : - public rtl::StaticWithInit { - const ::xmlscript::LibDescriptorArray operator () () { - - - return ::xmlscript::LibDescriptorArray(); - } -}; -} -//......................................................................... -namespace migration -{ -//......................................................................... - - - static ::rtl::OUString sExtensionSubDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/uno_packages/" ) ); - static ::rtl::OUString sSubDirName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cache" ) ); - static ::rtl::OUString sConfigDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data" ) ); - static ::rtl::OUString sOrgDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data/org" ) ); - static ::rtl::OUString sExcludeDir1 = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data/org" ) ); - static ::rtl::OUString sExcludeDir2 = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data/org/openoffice" ) ); - - static ::rtl::OUString sBasicType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.basic-library")); - static ::rtl::OUString sDialogType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.dialog-library")); - - static ::rtl::OUString sConfigurationDataType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.configuration-data")); - static ::rtl::OUString sConfigurationSchemaType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.configuration-schema")); - - // ============================================================================= - // component operations - // ============================================================================= - - ::rtl::OUString ExtensionMigration_getImplementationName() - { - static ::rtl::OUString* pImplName = 0; - if ( !pImplName ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pImplName ) - { - static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.desktop.migration.Extensions" ) ); - pImplName = &aImplName; - } - } - return *pImplName; - } - - // ----------------------------------------------------------------------------- - - Sequence< ::rtl::OUString > ExtensionMigration_getSupportedServiceNames() - { - static Sequence< ::rtl::OUString >* pNames = 0; - if ( !pNames ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pNames ) - { - static Sequence< ::rtl::OUString > aNames(1); - aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.migration.Extensions" ) ); - pNames = &aNames; - } - } - return *pNames; - } - - // ============================================================================= - // ExtensionMigration - // ============================================================================= - - ExtensionMigration::ExtensionMigration(Reference< XComponentContext > const & ctx) : - m_ctx(ctx) - { - } - - // ----------------------------------------------------------------------------- - - ExtensionMigration::~ExtensionMigration() - { - } - - ::osl::FileBase::RC ExtensionMigration::checkAndCreateDirectory( INetURLObject& rDirURL ) - { - ::osl::FileBase::RC aResult = ::osl::Directory::create( rDirURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) ); - if ( aResult == ::osl::FileBase::E_NOENT ) - { - INetURLObject aBaseURL( rDirURL ); - aBaseURL.removeSegment(); - checkAndCreateDirectory( aBaseURL ); - return ::osl::Directory::create( rDirURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) ); - } - else - { - return aResult; - } - } - - void ExtensionMigration::prepareBasicLibs() - { - prepareBasicLibs(m_sSourceDir + ::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("/user/basic/script.xlc")), m_scriptElements); - prepareBasicLibs(m_sSourceDir + ::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("/user/basic/dialog.xlc")), m_dialogElements); - } - - void ExtensionMigration::prepareBasicLibs(const ::rtl::OUString & sURL, - ::xmlscript::LibDescriptorArray & out_elements) - { - - ::ucbhelper::Content ucb_content; - if (dp_misc::create_ucb_content( &ucb_content, sURL, - uno::Reference< ucb::XCommandEnvironment>(), false /* no throw */ )) - { - uno::Reference xParser( - m_ctx->getServiceManager()->createInstanceWithContext( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser")), - m_ctx ), UNO_QUERY_THROW ); - - xParser->setDocumentHandler( ::xmlscript::importLibraryContainer( &out_elements ) ); - xml::sax::InputSource source; - source.aInputStream = ucb_content.openStream(); - source.sSystemId = ucb_content.getURL(); - xParser->parseStream( source ); - } - //else - //The file need not exists - } - /* Checks if basic package is enabled in StarOffice 8. This is the case when the dialog.xlc or - the script.xlc in the user installation contains an entry for this package. - The passed package MUST be a basic package. - */ - bool ExtensionMigration::isBasicPackageEnabled( const uno::Reference< deployment::XPackage > & xPkg) - { - ::rtl::OUString sScriptURL = xPkg->getURL(); - if ( sScriptURL[ sScriptURL.getLength()-1 ] != '/' ) - sScriptURL += ::rtl::OUString::createFromAscii("/"); - sScriptURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("script.xlb") ); - - bool bEntryFound = false; - for ( sal_Int32 nPos = m_scriptElements.mnLibCount; nPos--; ) - { - ::xmlscript::LibDescriptor const & descr = - m_scriptElements.mpLibs[ nPos ]; - - if (descr.aStorageURL.equals(sScriptURL)) - { - bEntryFound = true; - break; - } - } - - ::rtl::OUString sDialogURL = xPkg->getURL(); - if ( sDialogURL[ sDialogURL.getLength()-1 ] != '/' ) - sDialogURL += ::rtl::OUString::createFromAscii("/"); - sScriptURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("dialog.xlb") ); - - if (!bEntryFound) - { - for ( sal_Int32 nPos = m_dialogElements.mnLibCount; nPos--; ) - { - ::xmlscript::LibDescriptor const & descr = - m_dialogElements.mpLibs[ nPos ]; - - if (descr.aStorageURL.equals(sDialogURL)) - { - bEntryFound = true; - break; - } - } - } - return bEntryFound; - } - /* This function only registers basic and dialog packages. - */ - void ExtensionMigration::registerBasicPackage( const uno::Reference< deployment::XPackage > & xPkg) - { - const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType(); - if ( (sMediaType.equals(sBasicType) || sMediaType.equals(sDialogType)) - && isBasicPackageEnabled(xPkg)) - { - xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment> ()); - } - } - - bool ExtensionMigration::processExtensions( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ) - { - if (!copy(sSourceDir, sTargetDir)) - return false; - - // Find all basic and script packages and reregister them - uno::Reference< deployment::XPackageManagerFactory > xPMF; - if (! ( m_ctx->getValueByName( ::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.deployment.thePackageManagerFactory"))) - >>= xPMF)) - throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "ExtensionsMigration: could not get thePackageManagerFactory")), 0); - - const uno::Reference< deployment::XPackageManager > xPackageMgr = - xPMF->getPackageManager(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user"))); - - if (!xPackageMgr.is()) - throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "ExtensionsMigration: could not get XPackageManager")), 0); - - const uno::Sequence< uno::Reference< deployment::XPackage > > allPackages = - xPackageMgr->getDeployedPackages( - uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - - for (int i = 0; i < allPackages.getLength(); i ++) - { - const uno::Reference< deployment::XPackage > aPackage = allPackages[i]; - if ( aPackage->isBundle() ) - { - const uno::Sequence< uno::Reference < deployment::XPackage > > seqPkg = - aPackage->getBundle( - uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment> ()); - - for ( int k = 0; k < seqPkg.getLength(); k++ ) - registerBasicPackage(seqPkg[k]); - - for (int l = 0; l < seqPkg.getLength(); l++) - { - const ::rtl::OUString sMediaType = seqPkg[l]->getPackageType()->getMediaType(); - beans::Optional > opt = - seqPkg[l]->isRegistered(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - bool bRegistered = opt.IsPresent && opt.Value.IsAmbiguous == sal_False && opt.Value.Value == sal_True ? true : false; - - if ( bRegistered && !sMediaType.equals(sBasicType) && !sMediaType.equals(sDialogType) ) - { - seqPkg[l]->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - seqPkg[l]->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - } - } - } - else - { - registerBasicPackage(aPackage); - { - aPackage->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - aPackage->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - } - } - } - - - return true; - - } - -bool ExtensionMigration::isCompatibleBerkleyDb(const ::rtl::OUString& sSourceDir) -{ - try - { - ::rtl::OUString sDb(sSourceDir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "/uno_packages.db"))); - //check if the db exist at all. If not then the call to db_create would create - //the file. - ::osl::File f(sDb); - if (::osl::File::E_None != f.open(OpenFlag_Read)) - { - f.close(); - return false; - } - f.close(); - - //create a system path - ::rtl::OUString sSysPath; - if (::osl::File::getSystemPathFromFileURL(sDb, sSysPath ) != ::osl::File::E_None) - return false; - - ::rtl::OString cstr_sysPath( - ::rtl::OUStringToOString( sSysPath, osl_getThreadTextEncoding() ) ); - char const * pcstr_sysPath = cstr_sysPath.getStr(); - - //Open the db. If it works then we assume that the file was written with a - //compatible version of Berkeley Db - DB* pDB = NULL; - //using DB_RDONLY will return an "Invalid argument" error. - //DB_CREATE: only creates the file if it does not exist. - //An existing db is not modified. - if (0 != db_create(& pDB, 0, DB_CREATE)) - return false; - - if (0 != pDB->open(pDB, 0, pcstr_sysPath , 0, DB_HASH, DB_RDONLY, 0664 /* fs mode */)) - return false; - - pDB->close(pDB, 0); - } - catch (uno::Exception& ) - { - return false; - } - - return true; -} - -bool ExtensionMigration::copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ) -{ - bool bRet = false; - if (! isCompatibleBerkleyDb(sSourceDir)) - return false; - - INetURLObject aSourceObj( sSourceDir ); - INetURLObject aDestObj( sTargetDir ); - String aName = aDestObj.getName(); - aDestObj.removeSegment(); - aDestObj.setFinalSlash(); - - try - { - ::ucbhelper::Content aDestPath( aDestObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () ); - uno::Reference< ucb::XCommandInfo > xInfo = aDestPath.getCommands(); - ::rtl::OUString aTransferName = ::rtl::OUString::createFromAscii( "transfer" ); - if ( xInfo->hasCommandByName( aTransferName ) ) - { - aDestPath.executeCommand( aTransferName, uno::makeAny( - ucb::TransferInfo( sal_False, aSourceObj.GetMainURL( INetURLObject::NO_DECODE ), aName, ucb::NameClash::OVERWRITE ) ) ); - bRet = true; - } - } - catch( uno::Exception& ) - { - } - - return bRet; -} - - - // ----------------------------------------------------------------------------- - // XServiceInfo - // ----------------------------------------------------------------------------- - - ::rtl::OUString ExtensionMigration::getImplementationName() throw (RuntimeException) - { - return ExtensionMigration_getImplementationName(); - } - - // ----------------------------------------------------------------------------- - - sal_Bool ExtensionMigration::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException) - { - Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() ); - const ::rtl::OUString* pNames = aNames.getConstArray(); - const ::rtl::OUString* pEnd = pNames + aNames.getLength(); - for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames ) - ; - - return pNames != pEnd; - } - - // ----------------------------------------------------------------------------- - - Sequence< ::rtl::OUString > ExtensionMigration::getSupportedServiceNames() throw (RuntimeException) - { - return ExtensionMigration_getSupportedServiceNames(); - } - - // ----------------------------------------------------------------------------- - // XInitialization - // ----------------------------------------------------------------------------- - - void ExtensionMigration::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException) - { - ::osl::MutexGuard aGuard( m_aMutex ); - - const Any* pIter = aArguments.getConstArray(); - const Any* pEnd = pIter + aArguments.getLength(); - for ( ; pIter != pEnd ; ++pIter ) - { - beans::NamedValue aValue; - *pIter >>= aValue; - if ( aValue.Name.equalsAscii( "UserData" ) ) - { - if ( !(aValue.Value >>= m_sSourceDir) ) - { - OSL_ENSURE( false, "ExtensionMigration::initialize: argument UserData has wrong type!" ); - } - break; - } - } - prepareBasicLibs(); - } - - TStringVectorPtr getContent( const ::rtl::OUString& rBaseURL ) - { - TStringVectorPtr aResult( new TStringVector ); - ::osl::Directory aDir( rBaseURL); - if ( aDir.open() == ::osl::FileBase::E_None ) - { - // iterate over directory content - TStringVector aSubDirs; - ::osl::DirectoryItem aItem; - while ( aDir.getNextItem( aItem ) == ::osl::FileBase::E_None ) - { - ::osl::FileStatus aFileStatus( FileStatusMask_Type | FileStatusMask_FileURL ); - if ( aItem.getFileStatus( aFileStatus ) == ::osl::FileBase::E_None ) - aResult->push_back( aFileStatus.getFileURL() ); - } - } - - return aResult; - } - - // ----------------------------------------------------------------------------- - // XJob - // ----------------------------------------------------------------------------- - -void ExtensionMigration::copyConfig( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ) -{ - ::rtl::OUString sEx1( m_sSourceDir ); - sEx1 += sExcludeDir1; - ::rtl::OUString sEx2( m_sSourceDir ); - sEx2 += sExcludeDir2; - - TStringVectorPtr aList = getContent( sSourceDir ); - TStringVector::const_iterator aI = aList->begin(); - while ( aI != aList->end() ) - { - ::rtl::OUString sSourceLocalName = aI->copy( sSourceDir.getLength() ); - ::rtl::OUString aTemp = aI->copy( m_sSourceDir.getLength() ); - if ( aTemp != sExcludeDir1 && aTemp != sExcludeDir2 ) - { - ::rtl::OUString sTargetName = sTargetDir + sSourceLocalName; - copy( (*aI), sTargetName ); - } - ++aI; - } -} - - Any ExtensionMigration::execute( const Sequence< beans::NamedValue >& ) - throw (lang::IllegalArgumentException, Exception, RuntimeException) - { - ::osl::MutexGuard aGuard( m_aMutex ); - - ::utl::Bootstrap::PathStatus aStatus = ::utl::Bootstrap::locateUserInstallation( m_sTargetDir ); - if ( aStatus == ::utl::Bootstrap::PATH_EXISTS ) - { - // copy all extensions - ::rtl::OUString sTargetDir(m_sTargetDir), sSourceDir( m_sSourceDir ); - sTargetDir += sExtensionSubDir; - sSourceDir += sExtensionSubDir; - sSourceDir += sSubDirName; - sTargetDir += sSubDirName; - processExtensions( sSourceDir, sTargetDir ); - - // copy all user config settings in user/registry/data (except user/registry/data/org) - sSourceDir = m_sSourceDir; - sSourceDir += sConfigDir; - sTargetDir = m_sTargetDir; - sTargetDir += sConfigDir; - copyConfig( sSourceDir, sTargetDir ); - - // copy all user config settings in user/registry/data/org (except user/registry/data/org/openoffice) - sSourceDir = m_sSourceDir; - sSourceDir += sOrgDir; - sTargetDir = m_sTargetDir; - sTargetDir += sOrgDir; - copyConfig( sSourceDir, sTargetDir ); - } - - return Any(); - } - - // ============================================================================= - // component operations - // ============================================================================= - - Reference< XInterface > SAL_CALL ExtensionMigration_create( - Reference< XComponentContext > const & ctx ) - SAL_THROW( () ) - { - return static_cast< lang::XTypeProvider * >( new ExtensionMigration( - ctx) ); - } - - // ----------------------------------------------------------------------------- - -//......................................................................... -} // namespace migration -//......................................................................... diff --git a/desktop/source/migration/services/extensionmigration.hxx b/desktop/source/migration/services/extensionmigration.hxx deleted file mode 100755 index 70f6a4c44c9b..000000000000 --- a/desktop/source/migration/services/extensionmigration.hxx +++ /dev/null @@ -1,130 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _DESKTOP_EXTENSIONMIGRATION_HXX_ -#define _DESKTOP_EXTENSIONMIGRATION_HXX_ - -#include "misc.hxx" -#include -#include -#include -#include -#include -#include -#include "xmlscript/xmllib_imexp.hxx" - -namespace com { namespace sun { namespace star { - namespace uno { - class XComponentContext; - } - namespace deployment { - class XPackage; - } -}}} - - - -class INetURLObject; - - -//......................................................................... -namespace migration -{ -//......................................................................... - - ::rtl::OUString SAL_CALL ExtensionMigration_getImplementationName(); - ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ExtensionMigration_getSupportedServiceNames(); - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ExtensionMigration_create( - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext ) - SAL_THROW( (::com::sun::star::uno::Exception) ); - - - // ============================================================================= - // class ExtensionMigration - // ============================================================================= - - typedef ::cppu::WeakImplHelper3< - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::lang::XInitialization, - ::com::sun::star::task::XJob > ExtensionMigration_BASE; - - class ExtensionMigration : public ExtensionMigration_BASE - { - private: - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx; - ::osl::Mutex m_aMutex; - ::rtl::OUString m_sSourceDir; - ::rtl::OUString m_sTargetDir; - - ::xmlscript::LibDescriptorArray m_scriptElements; - ::xmlscript::LibDescriptorArray m_dialogElements; - - ::osl::FileBase::RC checkAndCreateDirectory( INetURLObject& rDirURL ); - void copyConfig( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ); - bool isCompatibleBerkleyDb(const ::rtl::OUString& sSourceDir); - bool copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ); - bool processExtensions( const ::rtl::OUString& sSourceDir, - const ::rtl::OUString& sTargetDir ); - /* fills m_scriptElements and m_dialogElements - */ - void prepareBasicLibs(); - void prepareBasicLibs(const ::rtl::OUString & sURL, - ::xmlscript::LibDescriptorArray & out_elements); - bool isBasicPackageEnabled( const ::com::sun::star::uno::Reference< - ::com::sun::star::deployment::XPackage > & xPkg); - void registerBasicPackage( - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg); - - public: - ExtensionMigration(::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext > const & ctx); - virtual ~ExtensionMigration(); - - // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName() - throw (::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() - throw (::com::sun::star::uno::RuntimeException); - - // XInitialization - virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) - throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - - // XJob - virtual ::com::sun::star::uno::Any SAL_CALL execute( - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ) - throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, - ::com::sun::star::uno::RuntimeException); - }; - -//......................................................................... -} // namespace migration -//......................................................................... - -#endif // _DESKTOP_AUTOCORRMIGRATION_HXX_ diff --git a/desktop/source/migration/services/makefile.mk b/desktop/source/migration/services/makefile.mk index 55ecff6bc06f..2f3eb9308ebd 100644 --- a/desktop/source/migration/services/makefile.mk +++ b/desktop/source/migration/services/makefile.mk @@ -51,7 +51,6 @@ SLOFILES= \ $(SLO)$/cexports.obj \ $(SLO)$/basicmigration.obj \ $(SLO)$/wordbookmigration.obj \ - $(SLO)$/extensionmigration.obj \ $(SLO)$/autocorrmigration.obj \ $(SLO)$/oo3extensionmigration.obj \ $(SLO)$/cexportsoo3.obj @@ -61,7 +60,6 @@ SHL1OBJS= \ $(SLO)$/cexports.obj \ $(SLO)$/basicmigration.obj \ $(SLO)$/wordbookmigration.obj \ - $(SLO)$/extensionmigration.obj \ $(SLO)$/autocorrmigration.obj SHL1TARGET=$(TARGET) diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index 2d17a654b29b..37608a7b1276 100755 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -43,8 +43,6 @@ #include #include -#include -#include #include #include #include @@ -53,6 +51,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -140,15 +139,15 @@ OO3ExtensionMigration::~OO3ExtensionMigration() } } -void OO3ExtensionMigration::registerConfigurationPackage( const uno::Reference< deployment::XPackage > & xPkg) -{ - const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType(); - if ( (sMediaType.equals(sConfigurationDataType) || sMediaType.equals(sConfigurationSchemaType) ) ) - { - xPkg->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - } -} +//void OO3ExtensionMigration::registerConfigurationPackage( const uno::Reference< deployment::XPackage > & xPkg) +//{ +// const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType(); +// if ( (sMediaType.equals(sConfigurationDataType) || sMediaType.equals(sConfigurationSchemaType) ) ) +// { +// xPkg->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); +// xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); +// } +//} void OO3ExtensionMigration::scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ) { @@ -343,18 +342,17 @@ bool OO3ExtensionMigration::scanDescriptionXml( const ::rtl::OUString& sDescript bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir ) { - if ( !m_xPackageManager.is() ) + if ( !m_xExtensionManager.is() ) { try { - m_xPackageManager = deployment::thePackageManagerFactory::get( m_ctx )->getPackageManager( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "user" )) ); + m_xExtensionManager = deployment::ExtensionManager::get( m_ctx ); } catch ( ucb::CommandFailedException & ){} catch ( uno::RuntimeException & ) {} } - if ( m_xPackageManager.is() ) + if ( m_xExtensionManager.is() ) { try { @@ -364,8 +362,9 @@ bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir static_cast< cppu::OWeakObject* >( pCmdEnv ), uno::UNO_QUERY ); uno::Reference< task::XAbortChannel > xAbortChannel; uno::Reference< deployment::XPackage > xPackage = - m_xPackageManager->addPackage( - sSourceDir, uno::Sequence(),::rtl::OUString(), xAbortChannel, xCmdEnv ); + m_xExtensionManager->addExtension( + sSourceDir, uno::Sequence(), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), xAbortChannel, xCmdEnv ); if ( xPackage.is() ) return true; diff --git a/desktop/source/migration/services/oo3extensionmigration.hxx b/desktop/source/migration/services/oo3extensionmigration.hxx index a001f41d92c5..7890eb86a75c 100755 --- a/desktop/source/migration/services/oo3extensionmigration.hxx +++ b/desktop/source/migration/services/oo3extensionmigration.hxx @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -83,7 +83,7 @@ namespace migration ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx; ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XDocumentBuilder > m_xDocBuilder; ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xSimpleFileAccess; - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > m_xPackageManager; + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; ::osl::Mutex m_aMutex; ::rtl::OUString m_sSourceDir; ::rtl::OUString m_sTargetDir; @@ -105,8 +105,8 @@ namespace migration bool migrateExtension( const ::rtl::OUString& sSourceDir ); /* fills m_scriptElements and m_dialogElements */ - void registerConfigurationPackage( - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg); + //void registerConfigurationPackage( + // const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg); public: OO3ExtensionMigration(::com::sun::star::uno::Reference< diff --git a/officecfg/registry/schema/org/openoffice/Office/OOoImprovement/Settings.xcs b/officecfg/registry/schema/org/openoffice/Office/OOoImprovement/Settings.xcs index 7ff91464727d..7b0b221f15a9 100755 --- a/officecfg/registry/schema/org/openoffice/Office/OOoImprovement/Settings.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/OOoImprovement/Settings.xcs @@ -15,7 +15,7 @@ OpenOffice.org Improvement Program. If this is zero the user will get asked. - 1 + 2 -- cgit From d310e6479f4db1c86629ca98f6e0f7480a0fa5e4 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 18 May 2010 17:10:29 +0200 Subject: CWS mba33issues01: #i109842#: missing typedef --- sfx2/source/appl/appmain.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/sfx2/source/appl/appmain.cxx b/sfx2/source/appl/appmain.cxx index 020f68d01e8d..cf097b900b52 100644 --- a/sfx2/source/appl/appmain.cxx +++ b/sfx2/source/appl/appmain.cxx @@ -93,9 +93,6 @@ static SfxItemInfo __READONLY_DATA aItemInfos[] = //=================================================================== -typedef Link* LinkPtr; -SV_DECL_PTRARR(SfxInitLinkList, LinkPtr, 4, 4) - TYPEINIT2(SfxApplication,SfxShell,SfxBroadcaster); //-------------------------------------------------------------------- -- cgit From 74efe21718537220ec16adab9964a00fc13cd9fd Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 18 May 2010 17:10:57 +0200 Subject: CWS mba33issues01: #i109842#: missing typedef --- sfx2/source/inc/appdata.hxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index 91305eb95cce..bd12f3db80dc 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -82,6 +82,9 @@ class SfxBasicManagerCreationListener; namespace sfx2 { namespace appl { class ImeStatusWindow; } } +typedef Link* LinkPtr; +SV_DECL_PTRARR(SfxInitLinkList, LinkPtr, 4, 4) + //========================================================================= // SfxAppData_Impl //========================================================================= -- cgit From 9a4d07cc52534a40cf1cd68efdef1464475e694b Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 18 May 2010 17:19:21 +0200 Subject: CWS mba33issues01: #i107576#: make code safe against releasing of external references to client site --- sfx2/source/view/ipclient.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 6d61f4182bbb..328d88d8b2b9 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -131,6 +131,8 @@ public: , m_bResizeNoScale( sal_False ) {} + ~SfxInPlaceClient_Impl(); + void SizeHasChanged(); DECL_LINK (TimerHdl, Timer*); uno::Reference < frame::XFrame > GetFrame() const; @@ -168,6 +170,10 @@ public: virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); }; +SfxInPlaceClient_Impl::~SfxInPlaceClient_Impl() +{ +} + void SAL_CALL SfxInPlaceClient_Impl::changingState( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 /*nOldState*/, @@ -645,6 +651,7 @@ SfxInPlaceClient::SfxInPlaceClient( SfxViewShell* pViewShell, Window *pDraw, sal m_pViewSh( pViewShell ), m_pEditWin( pDraw ) { + m_pImp->acquire(); m_pImp->m_pClient = this; m_pImp->m_nAspect = nAspect; m_pImp->m_aScaleWidth = m_pImp->m_aScaleHeight = Fraction(1,1); @@ -668,6 +675,7 @@ SfxInPlaceClient::~SfxInPlaceClient() // the next call will destroy m_pImp if no other reference to it exists m_pImp->m_xClient = uno::Reference < embed::XEmbeddedClient >(); + m_pImp->release(); // TODO/LATER: // the class is not intended to be used in multithreaded environment; -- cgit From fc05fb607569bf4eff1b37c7eba1fc4369702744 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 19 May 2010 11:00:36 +0200 Subject: jl152: #i108704# use all the arguments when restarting on Windows --- desktop/win32/source/officeloader/officeloader.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx index ef980e1e994e..7c2dafc79bbb 100644 --- a/desktop/win32/source/officeloader/officeloader.cxx +++ b/desktop/win32/source/officeloader/officeloader.cxx @@ -212,7 +212,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) LPTSTR lpCommandLine = NULL; int argc = 0; LPTSTR * argv = NULL; - bool first = true; + bool bFirst = true; WCHAR cwd[MAX_PATH]; DWORD cwdLen = GetCurrentDirectoryW(MAX_PATH, cwd); if (cwdLen >= MAX_PATH) { @@ -318,7 +318,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) } } - if (first) { + if ( bFirst ) { argv = GetCommandArgs(&argc); std::size_t n = wcslen(argv[0]) + 2; for (int i = 1; i < argc; ++i) { @@ -334,7 +334,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) lpCommandLine, MY_STRING(L"\"")); p = desktop_win32::commandLineAppend(p, argv[0]); for (int i = 1; i < argc; ++i) { - if (first || wcsncmp(argv[i], MY_STRING(L"-env:")) == 0) { + if (bFirst || ::desktop::ExitHelper::E_NORMAL_RESTART == dwExitCode || wcsncmp(argv[i], MY_STRING(L"-env:")) == 0) { p = desktop_win32::commandLineAppend(p, MY_STRING(L"\" \"")); p = desktop_win32::commandLineAppend(p, argv[i]); } @@ -348,7 +348,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) p = desktop_win32::commandLineAppendEncoded(p, cwd); } desktop_win32::commandLineAppend(p, MY_STRING(L"\"")); - first = false; + bFirst = false; TCHAR szParentProcessId[64]; // This is more than large enough for a 128 bit decimal value BOOL bHeadlessMode( FALSE ); -- cgit From 4659d84eb4e0e8038ac21044ddd3c390e2585581 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 19 May 2010 14:28:33 +0200 Subject: cws tl79: #i110254# new security tap page in 'File/Properties' --- desktop/source/migration/migration.cxx | 1 + sfx2/inc/sfx2/objsh.hxx | 7 + sfx2/inc/sfx2/sfx.hrc | 2 + sfx2/sdi/sfx.sdi | 2 +- sfx2/source/dialog/securitypage.cxx | 320 ++++++++++++++++++++++----------- sfx2/source/dialog/securitypage.hrc | 6 +- sfx2/source/dialog/securitypage.src | 19 +- sfx2/source/doc/objxtor.cxx | 24 +++ 8 files changed, 262 insertions(+), 119 deletions(-) mode change 100644 => 100755 desktop/source/migration/migration.cxx mode change 100644 => 100755 sfx2/inc/sfx2/objsh.hxx mode change 100644 => 100755 sfx2/sdi/sfx.sdi mode change 100644 => 100755 sfx2/source/doc/objxtor.cxx diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx old mode 100644 new mode 100755 index 2181daab7454..b9be788ebd4b --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -232,6 +232,7 @@ static void insertSorted(migrations_available& rAvailableMigrations, supported_m { rAvailableMigrations.insert(pIter, aSupportedMigration ); bInserted = true; + break; } ++pIter; } diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx old mode 100644 new mode 100755 index 5fc5a641fd44..7984fae956cb --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -683,6 +683,13 @@ public: sal_Int32 nVersion, sal_Bool bTemplate = sal_False) const = 0; + // change recording and respective passwword protection for Writer and Calc + // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON + // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT + virtual void SetChangeRecording( bool bActivate ); + virtual bool SetProtectionPassword( const String &rPassword ); + virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); + // ================================= //#if 0 // _SOLAR__PRIVATE diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc index 137218e3c117..3ed7f34ee3b8 100755 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -234,6 +234,8 @@ #define TP_MANAGE_STYLES (RID_SFX_START+7) #define DLG_STYLE_DESIGNER (RID_SFX_START+8) +#define RID_SFX_INCORRECT_PASSWORD (RID_SFX_START+216) + #define STR_STYLE_FILTER_AUTO (RID_SFX_START+9) #define STR_STYLE_FILTER_USED (RID_SFX_START+10) #define STR_STYLE_FILTER_USERDEF (RID_SFX_START+11) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi old mode 100644 new mode 100755 index 10a920852848..e4ff0dc8d2b5 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -31,7 +31,7 @@ SfxBoolItem _SwitchViewShell0 SID_VIEWSHELL0 [ /* flags: */ AutoUpdate = FALSE, - Cachable = Cachable, + Cachable = Cachable,  FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index d6351143c51e..d4f217671d6e 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -38,64 +38,70 @@ #include #include #include +#include #include #include #include +#include #include #include #include +#include #include +using namespace ::com::sun::star; ////////////////////////////////////////////////////////////////////// -namespace +static short lcl_GetPassword( Window *pParent, bool bShowConfirm, /*out*/String &rPassword ) { - enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; + bool bRes = false; + SfxPasswordDialog aPasswdDlg( pParent ); + if (bShowConfirm) + aPasswdDlg.ShowExtras( SHOWEXTRAS_CONFIRM ); + if (RET_OK == aPasswdDlg.Execute() && aPasswdDlg.GetPassword().Len() > 0) + { + rPassword = aPasswdDlg.GetPassword(); + bRes = true; + } + return bRes; +} - enum RedlineFunc { RF_ON, RF_PROTECT }; - const SfxBoolItem* ExecuteRecordChangesFunc( RedliningMode _eMode, RedlineFunc _eFunc, BOOL _bVal, Window* _pParent = NULL ) - { - const SfxBoolItem* pRet = NULL; +static bool lcl_IsPasswordCorrect( const String &rPassword ) +{ + bool bRes = false; - if (_eMode != RL_NONE) - { - USHORT nSlot; - if (_eMode == RL_WRITER) - nSlot = _eFunc == RF_ON ? FN_REDLINE_ON : FN_REDLINE_PROTECT; - else - nSlot = _eFunc == RF_ON ? FID_CHG_RECORD : SID_CHG_PROTECT; + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + uno::Sequence< sal_Int8 > aPasswordHash; + bool bHasPassword = pCurDocShell->GetProtectionHash( aPasswordHash ); + + // check if supplied password was correct + uno::Sequence< sal_Int8 > aNewPasswd( aPasswordHash ); + SvPasswordHelper::GetHashPassword( aNewPasswd, rPassword ); + if (SvPasswordHelper::CompareHashPassword( aPasswordHash, rPassword )) + bRes = true; // password was correct + else + InfoBox( NULL, String( SfxResId( RID_SFX_INCORRECT_PASSWORD ) ) ).Execute(); - // execute - SfxViewShell* pViewSh = SfxViewShell::Current(); - if (pViewSh) - { - bool bNeedItem = _eMode == RL_WRITER || _eFunc != RF_ON; - SfxBoolItem* pItem = bNeedItem ? new SfxBoolItem( nSlot, _bVal ) : NULL; - SfxDispatcher* pDisp = pViewSh->GetDispatcher(); - if (_pParent) - { - XWindowItem aParentItem( SID_ATTR_XWINDOW, _pParent ); - pRet = static_cast< const SfxBoolItem* >( - pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, &aParentItem, pItem, 0L ) ); - } - else - pRet = static_cast< const SfxBoolItem* >( - pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, pItem, 0L ) ); - delete pItem; - } - } + return bRes; +} + + +////////////////////////////////////////////////////////////////////// + + +namespace +{ + enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; + enum RedlineFunc { RF_ON, RF_PROTECT }; - return pRet; - } bool QueryState( USHORT _nSlot, bool& _rValue ) { bool bRet = false; - SfxViewShell* pViewSh = SfxViewShell::Current(); if (pViewSh) { @@ -105,33 +111,30 @@ namespace if (bRet) _rValue = ( static_cast< const SfxBoolItem* >( pItem ) )->GetValue(); } - return bRet; } + bool QueryRecordChangesProtectionState( RedliningMode _eMode, bool& _rValue ) { bool bRet = false; - if (_eMode != RL_NONE) { USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_PROTECT : SID_CHG_PROTECT; bRet = QueryState( nSlot, _rValue ); } - return bRet; } + bool QueryRecordChangesState( RedliningMode _eMode, bool& _rValue ) { bool bRet = false; - if (_eMode != RL_NONE) { USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_ON : FID_CHG_RECORD; bRet = QueryState( nSlot, _rValue ); } - return bRet; } } @@ -142,64 +145,71 @@ namespace struct SfxSecurityPage_Impl { - SfxSecurityPage & m_rDialog; + SfxSecurityPage & m_rMyTabPage; - FixedLine m_aPasswordToOpenFL; - FixedText m_aPasswordToOpenFT; - Edit m_aPasswordToOpenED; + FixedLine m_aNewPasswordToOpenFL; + FixedText m_aNewPasswordToOpenFT; + Edit m_aNewPasswordToOpenED; FixedText m_aConfirmPasswordToOpenFT; Edit m_aConfirmPasswordToOpenED; - FixedText m_aPasswordInfoFT; + FixedText m_aNewPasswordInfoFT; - FixedLine m_aPasswordToModifyFL; - FixedText m_aPasswordToModifyFT; - Edit m_aPasswordToModifyED; + FixedLine m_aNewPasswordToModifyFL; + FixedText m_aNewPasswordToModifyFT; + Edit m_aNewPasswordToModifyED; FixedText m_aConfirmPasswordToModifyFT; Edit m_aConfirmPasswordToModifyED; FixedLine m_aOptionsFL; CheckBox m_aOpenReadonlyCB; - CheckBox m_aRemoveInfoOnSavingCB; CheckBox m_aRecordChangesCB; // for record changes PushButton m_aChangeProtectionPB; // for record changes String m_aProtectSTR; // for record changes String m_aUnProtectSTR; // for record changes RedliningMode m_eRedlingMode; // for record changes + bool m_bOrigPasswordIsConfirmed; + bool m_bNewPasswordIsValid; + String m_aNewPassword; + + String m_aEndRedliningWarning; + bool m_bEndRedliningWarningDone; + DECL_LINK( RecordChangesCBHdl, void* ); DECL_LINK( ChangeProtectionPBHdl, void* ); SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet &rItemSet ); ~SfxSecurityPage_Impl(); - void CheckRecordChangesState( void ); - BOOL FillItemSet_Impl( SfxItemSet & ); void Reset_Impl( const SfxItemSet & ); }; -SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet & ) : - m_rDialog (rDlg), - m_aPasswordToOpenFL (&rDlg, SfxResId( PASSWORD_TO_OPEN_FL ) ), - m_aPasswordToOpenFT (&rDlg, SfxResId( PASSWORD_TO_OPEN_FT ) ), - m_aPasswordToOpenED (&rDlg, SfxResId( PASSWORD_TO_OPEN_ED ) ), - m_aConfirmPasswordToOpenFT (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_OPEN_FT ) ), - m_aConfirmPasswordToOpenED (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_OPEN_ED ) ), - m_aPasswordInfoFT (&rDlg, SfxResId( PASSWORD_INFO_FT ) ), - m_aPasswordToModifyFL (&rDlg, SfxResId( PASSWORD_TO_MODIFY_FL ) ), - m_aPasswordToModifyFT (&rDlg, SfxResId( PASSWORD_TO_MODIFY_FT ) ), - m_aPasswordToModifyED (&rDlg, SfxResId( PASSWORD_TO_MODIFY_ED ) ), - m_aConfirmPasswordToModifyFT (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_FT ) ), - m_aConfirmPasswordToModifyED (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_ED ) ), - m_aOptionsFL (&rDlg, SfxResId( OPTIONS_FL ) ), - m_aOpenReadonlyCB (&rDlg, SfxResId( OPEN_READONLY_CB ) ), - m_aRemoveInfoOnSavingCB (&rDlg, SfxResId( REMOVE_INFO_ON_SAVING_CB ) ), - m_aRecordChangesCB (&rDlg, SfxResId( RECORD_CHANGES_CB ) ), - m_aChangeProtectionPB (&rDlg, SfxResId( CHANGE_PROTECTION_PB ) ), +SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rTabPage, const SfxItemSet & ) : + m_rMyTabPage (rTabPage), + m_aNewPasswordToOpenFL (&rTabPage, SfxResId( PASSWORD_TO_OPEN_FL ) ), + m_aNewPasswordToOpenFT (&rTabPage, SfxResId( PASSWORD_TO_OPEN_FT ) ), + m_aNewPasswordToOpenED (&rTabPage, SfxResId( PASSWORD_TO_OPEN_ED ) ), + m_aConfirmPasswordToOpenFT (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_OPEN_FT ) ), + m_aConfirmPasswordToOpenED (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_OPEN_ED ) ), + m_aNewPasswordInfoFT (&rTabPage, SfxResId( PASSWORD_INFO_FT ) ), + m_aNewPasswordToModifyFL (&rTabPage, SfxResId( PASSWORD_TO_MODIFY_FL ) ), + m_aNewPasswordToModifyFT (&rTabPage, SfxResId( PASSWORD_TO_MODIFY_FT ) ), + m_aNewPasswordToModifyED (&rTabPage, SfxResId( PASSWORD_TO_MODIFY_ED ) ), + m_aConfirmPasswordToModifyFT (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_FT ) ), + m_aConfirmPasswordToModifyED (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_ED ) ), + m_aOptionsFL (&rTabPage, SfxResId( OPTIONS_FL ) ), + m_aOpenReadonlyCB (&rTabPage, SfxResId( OPEN_READONLY_CB ) ), + m_aRecordChangesCB (&rTabPage, SfxResId( RECORD_CHANGES_CB ) ), + m_aChangeProtectionPB (&rTabPage, SfxResId( CHANGE_PROTECTION_PB ) ), m_aProtectSTR ( SfxResId( STR_PROTECT ) ), m_aUnProtectSTR ( SfxResId( STR_UNPROTECT ) ), - m_eRedlingMode ( RL_NONE ) + m_eRedlingMode ( RL_NONE ), + m_bOrigPasswordIsConfirmed ( false ), + m_bNewPasswordIsValid ( false ), + m_aEndRedliningWarning ( SfxResId( STR_END_REDLINING_WARNING ) ), + m_bEndRedliningWarningDone ( false ) { m_aChangeProtectionPB.SetText( m_aProtectSTR ); // adjust button width if necessary @@ -218,30 +228,46 @@ SfxSecurityPage_Impl::~SfxSecurityPage_Impl() } -void SfxSecurityPage_Impl::CheckRecordChangesState( void ) -{ - bool bVal; - if (QueryRecordChangesState( m_eRedlingMode, bVal )) - { - m_aRecordChangesCB.Enable(); - m_aRecordChangesCB.Check( bVal ); - } - else - m_aRecordChangesCB.Disable(); // because now we don't know the state! - - m_aChangeProtectionPB.Enable( QueryRecordChangesProtectionState( m_eRedlingMode, bVal ) ); -} - - BOOL SfxSecurityPage_Impl::FillItemSet_Impl( SfxItemSet & ) { - BOOL bModified = FALSE; + bool bModified = false; SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); if (pCurDocShell) { + if (m_eRedlingMode != RL_NONE && !pCurDocShell->IsReadOnly()) + { + // change recording + const bool bDoRecordChanges = m_aRecordChangesCB.IsChecked(); + pCurDocShell->SetChangeRecording( bDoRecordChanges ); + + // no change recording should imply no password protection + if (!bDoRecordChanges && (!m_bNewPasswordIsValid || m_aNewPassword.Len() != 0)) + { + // actually this should not be possible. Thus just as 'coded comment': + DBG_ASSERT( 0, "unexpected state of UI" ); + m_bNewPasswordIsValid = true; + m_aNewPassword = String(); + } + + // change record protection + if (m_bNewPasswordIsValid) + { + const bool bDoChangeProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; + DBG_ASSERT( !bDoChangeProtection || bDoRecordChanges, + "change protection requires record changes to be active!" ); + pCurDocShell->SetProtectionPassword( m_aNewPassword ); + } + + bModified = true; + } + + // open read-only? if (pCurDocShell->HasSecurityOptOpenReadOnly()) + { pCurDocShell->SetSecurityOptOpenReadOnly( m_aOpenReadonlyCB.IsChecked() ); + bModified = true; + } } return bModified; @@ -284,23 +310,37 @@ void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) else m_aOpenReadonlyCB.Disable(); - bool bVal; - if (QueryRecordChangesState( RL_WRITER, bVal ) && !bIsHTMLDoc) + bool bRecordChanges; + if (QueryRecordChangesState( RL_WRITER, bRecordChanges ) && !bIsHTMLDoc) m_eRedlingMode = RL_WRITER; - else if (QueryRecordChangesState( RL_CALC, bVal )) + else if (QueryRecordChangesState( RL_CALC, bRecordChanges )) m_eRedlingMode = RL_CALC; else m_eRedlingMode = RL_NONE; if (m_eRedlingMode != RL_NONE) { - m_aRecordChangesCB.Check( bVal ); - m_aRecordChangesCB.Enable( !bVal && !bIsReadonly ); - m_aChangeProtectionPB.Enable( - QueryRecordChangesProtectionState( m_eRedlingMode, bVal ) && !bIsReadonly ); + bool bProtection; + QueryRecordChangesProtectionState( m_eRedlingMode, bProtection ); + + m_aChangeProtectionPB.Enable( !bIsReadonly ); // set the right text - if (bVal) + if (bProtection) sNewText = m_aUnProtectSTR; + + m_aRecordChangesCB.Check( bRecordChanges ); + m_aRecordChangesCB.Enable( /*!bProtection && */!bIsReadonly ); + + DBG_ASSERT( pCurDocShell, "doc shell missing" ); + if (pCurDocShell) + { + m_bOrigPasswordIsConfirmed = true; // default case if no password is set + uno::Sequence< sal_Int8 > aPasswordHash; + // check if password is available + if (pCurDocShell->GetProtectionHash( aPasswordHash ) && + aPasswordHash.getLength() > 0) + m_bOrigPasswordIsConfirmed = false; // password found, needs to be confirmed later on + } } } @@ -310,27 +350,94 @@ void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) IMPL_LINK( SfxSecurityPage_Impl, RecordChangesCBHdl, void*, EMPTYARG ) { - ExecuteRecordChangesFunc( m_eRedlingMode, RF_ON, m_aRecordChangesCB.IsChecked(), &m_rDialog ); - CheckRecordChangesState(); + // when change recording gets disabled protection must be disabled as well + if (!m_aRecordChangesCB.IsChecked()) // the new check state is already present, thus the '!' + { + bool bAlreadyDone = false; + if (!m_bEndRedliningWarningDone) + { + WarningBox aBox( m_rMyTabPage.GetParent(), WinBits(WB_YES_NO | WB_DEF_NO), + m_aEndRedliningWarning ); + if (aBox.Execute() != RET_YES) + bAlreadyDone = true; + else + m_bEndRedliningWarningDone = true; + } + + const bool bNeedPasssword = !m_bOrigPasswordIsConfirmed + && m_aChangeProtectionPB.GetText() != m_aProtectSTR; + if (!bAlreadyDone && bNeedPasssword) + { + String aPasswordText; + + // dialog canceled or no password provided + if (!lcl_GetPassword( m_rMyTabPage.GetParent(), false, aPasswordText )) + bAlreadyDone = true; + + // ask for password and if dialog is canceled or no password provided return + if (lcl_IsPasswordCorrect( aPasswordText )) + m_bOrigPasswordIsConfirmed = true; + else + bAlreadyDone = true; + } + + if (bAlreadyDone) + m_aRecordChangesCB.Check( true ); // restore original state + else + { + // remember required values to change protection and change recording in + // FillItemSet_Impl later on if password was correct. + m_bNewPasswordIsValid = true; + m_aNewPassword = String(); + + m_aChangeProtectionPB.SetText( m_aProtectSTR ); + } + } + return 0; } IMPL_LINK( SfxSecurityPage_Impl, ChangeProtectionPBHdl, void*, EMPTYARG ) { - bool bProt; - QueryRecordChangesProtectionState( m_eRedlingMode, bProt ); - ExecuteRecordChangesFunc( m_eRedlingMode, RF_PROTECT, !bProt, &m_rDialog ); - CheckRecordChangesState(); + if (m_eRedlingMode == RL_NONE) + return 0; + + // the push button text is always the opposite of the current state. Thus: + const bool bCurrentProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; - if (QueryRecordChangesProtectionState( m_eRedlingMode, bProt )) + // ask user for password (if still necessary) + String aPasswordText; + bool bNewProtection = !bCurrentProtection; + const bool bNeedPassword = bNewProtection || !m_bOrigPasswordIsConfirmed; + if (bNeedPassword) { - // RecordChangesCB is enabled if protection is off - m_aRecordChangesCB.Enable( !bProt ); - // toggle text of button "Protect" <-> "Unprotect" - String sNewText = bProt ? m_aUnProtectSTR : m_aProtectSTR; - m_aChangeProtectionPB.SetText( sNewText ); + // ask for password and if dialog is canceled or no password provided return + if (!lcl_GetPassword( m_rMyTabPage.GetParent(), bNewProtection, aPasswordText )) + return 0; + + // provided password still needs to be checked? + if (!bNewProtection && !m_bOrigPasswordIsConfirmed) + { + if (lcl_IsPasswordCorrect( aPasswordText )) + m_bOrigPasswordIsConfirmed = true; + else + return 0; + } } + DBG_ASSERT( m_bOrigPasswordIsConfirmed, "ooops... this should not have happened!" ); + + // remember required values to change protection and change recording in + // FillItemSet_Impl later on if password was correct. + m_bNewPasswordIsValid = true; + m_aNewPassword = bNewProtection? aPasswordText : String(); + +// // RecordChangesCB is enabled if protection is off +// m_aRecordChangesCB.Enable( !bNewProtection ); + m_aRecordChangesCB.Check( bNewProtection ); + // toggle text of button "Protect" <-> "Unprotect" + m_aChangeProtectionPB.SetText( bNewProtection ? m_aUnProtectSTR : m_aProtectSTR ); + return 0; } @@ -378,3 +485,4 @@ void SfxSecurityPage::Reset( const SfxItemSet & rItemSet ) ////////////////////////////////////////////////////////////////////// + diff --git a/sfx2/source/dialog/securitypage.hrc b/sfx2/source/dialog/securitypage.hrc index 820dab538b9f..d425131b4772 100755 --- a/sfx2/source/dialog/securitypage.hrc +++ b/sfx2/source/dialog/securitypage.hrc @@ -41,12 +41,12 @@ #define CONFIRM_PASSWORD_TO_MODIFY_ED 11 #define OPTIONS_FL 12 #define OPEN_READONLY_CB 13 -#define REMOVE_INFO_ON_SAVING_CB 14 -#define RECORD_CHANGES_CB 15 -#define CHANGE_PROTECTION_PB 16 +#define RECORD_CHANGES_CB 14 +#define CHANGE_PROTECTION_PB 15 #define STR_PROTECT 101 #define STR_UNPROTECT 102 +#define STR_END_REDLINING_WARNING 103 #endif diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src index 32f5fac704a4..4bf8cdaf58a9 100755 --- a/sfx2/source/dialog/securitypage.src +++ b/sfx2/source/dialog/securitypage.src @@ -125,21 +125,15 @@ TabPage TP_DOCINFOSECURITY Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); Text [ en-US ] = "~Open file read-only"; }; - CheckBox REMOVE_INFO_ON_SAVING_CB - { - Pos = MAP_APPFONT( 12, 147 ); - Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); - Text [ en-US ] = "Remove personal ~information on saving"; - }; CheckBox RECORD_CHANGES_CB { - Pos = MAP_APPFONT( 12, 162 ); + Pos = MAP_APPFONT( 12, 147 ); Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); Text [ en-US ] = "Record ~changes"; }; PushButton CHANGE_PROTECTION_PB { - Pos = MAP_APPFONT( 194, 160 ); + Pos = MAP_APPFONT( 194, 145 ); Size = MAP_APPFONT( 60, RSC_CD_PUSHBUTTON_HEIGHT ); }; String STR_PROTECT @@ -150,7 +144,14 @@ TabPage TP_DOCINFOSECURITY { Text [ en-US ] = "~Unprotect..."; }; - + String STR_END_REDLINING_WARNING + { + Text [ en-US ] = "This action will exit the change recording mode.\nAny information about changes will be lost.\n\nExit change recording mode?\n\n" ; + }; }; +String RID_SFX_INCORRECT_PASSWORD +{ + Text [ en-US ] = "Incorrect password" ; +}; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx old mode 100644 new mode 100755 index 6502eeaeb78c..751525910958 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -1074,3 +1074,27 @@ void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew ) SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) ); } } + + +void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ ) +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); +} + + +bool SfxObjectShell::SetProtectionPassword( const String &rPassword ) +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + + +bool SfxObjectShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > & /*rPasswordHash*/ ) +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + -- cgit From 1778298eb695174aad2f6a981f560f0e4e2b229a Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 19 May 2010 14:59:46 +0200 Subject: cws tl79 : random typo in sfx.sdi fixed --- sfx2/sdi/sfx.sdi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index e4ff0dc8d2b5..10a920852848 100755 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -31,7 +31,7 @@ SfxBoolItem _SwitchViewShell0 SID_VIEWSHELL0 [ /* flags: */ AutoUpdate = FALSE, - Cachable = Cachable,  + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, -- cgit From 3ff45fd2d5b0bbf8318a5559fa66aba45b5c4040 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 20 May 2010 11:04:13 +0200 Subject: cws tl79: #i111422# pre-notify for 'Toggle' of check box --- sfx2/source/dialog/securitypage.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index d4f217671d6e..f88525107f1c 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -175,7 +175,7 @@ struct SfxSecurityPage_Impl String m_aEndRedliningWarning; bool m_bEndRedliningWarningDone; - DECL_LINK( RecordChangesCBHdl, void* ); + DECL_LINK( RecordChangesCBToggleHdl, void* ); DECL_LINK( ChangeProtectionPBHdl, void* ); SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet &rItemSet ); @@ -218,7 +218,9 @@ SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rTabPage, const Sfx if (nTemp > nBtnTextWidth) nBtnTextWidth = nTemp; - m_aRecordChangesCB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, RecordChangesCBHdl ) ); + // force toggle hdl called before visual change of checkbox + m_aRecordChangesCB.SetStyle( m_aRecordChangesCB.GetStyle() | WB_EARLYTOGGLE ); + m_aRecordChangesCB.SetToggleHdl( LINK( this, SfxSecurityPage_Impl, RecordChangesCBToggleHdl ) ); m_aChangeProtectionPB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, ChangeProtectionPBHdl ) ); } @@ -348,7 +350,7 @@ void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) } -IMPL_LINK( SfxSecurityPage_Impl, RecordChangesCBHdl, void*, EMPTYARG ) +IMPL_LINK( SfxSecurityPage_Impl, RecordChangesCBToggleHdl, void*, EMPTYARG ) { // when change recording gets disabled protection must be disabled as well if (!m_aRecordChangesCB.IsChecked()) // the new check state is already present, thus the '!' -- cgit From 7df75b6fe4c992f61c593dc33bb84ba537f05f99 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 20 May 2010 11:27:05 +0200 Subject: jl152 #i77196# registering basic item at startup did not work --- .../deployment/registry/configuration/dp_configuration.cxx | 1 - desktop/source/deployment/registry/script/dp_script.cxx | 2 +- desktop/source/migration/services/oo3extensionmigration.cxx | 12 +----------- desktop/source/migration/services/oo3extensionmigration.hxx | 4 ---- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index f892c21a6a6b..9ea6e8227340 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -35,7 +35,6 @@ #include "dp_backend.h" #include "dp_persmap.h" #include "dp_ucb.h" -#include "dp_xml.h" #include "rtl/string.hxx" #include "rtl/ustrbuf.hxx" #include "rtl/uri.hxx" diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 3a43e916e39e..edeae256cbaf 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -476,7 +476,7 @@ void BackendImpl::PackageImpl::processPackage_( } } bool bSuccess = bScript || bDialog; // Something must have happened - if( bRunning ) + if( bRunning && !startup) if( (bScript && !bScriptSuccess) || (bDialog && !bDialogSuccess) ) bSuccess = false; diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index 37608a7b1276..0b757212eaa6 100755 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -139,17 +139,7 @@ OO3ExtensionMigration::~OO3ExtensionMigration() } } -//void OO3ExtensionMigration::registerConfigurationPackage( const uno::Reference< deployment::XPackage > & xPkg) -//{ -// const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType(); -// if ( (sMediaType.equals(sConfigurationDataType) || sMediaType.equals(sConfigurationSchemaType) ) ) -// { -// xPkg->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); -// xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); -// } -//} - - void OO3ExtensionMigration::scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ) +void OO3ExtensionMigration::scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ) { osl::Directory aScanRootDir( sSourceDir ); osl::FileStatus fs(FileStatusMask_Type | FileStatusMask_FileURL); diff --git a/desktop/source/migration/services/oo3extensionmigration.hxx b/desktop/source/migration/services/oo3extensionmigration.hxx index 7890eb86a75c..7962da177217 100755 --- a/desktop/source/migration/services/oo3extensionmigration.hxx +++ b/desktop/source/migration/services/oo3extensionmigration.hxx @@ -103,10 +103,6 @@ namespace migration void scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ); bool scanDescriptionXml( const ::rtl::OUString& sDescriptionXmlFilePath ); bool migrateExtension( const ::rtl::OUString& sSourceDir ); - /* fills m_scriptElements and m_dialogElements - */ - //void registerConfigurationPackage( - // const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg); public: OO3ExtensionMigration(::com::sun::star::uno::Reference< -- cgit From d8b873beb717df820251dc68e869a97ab3998fe2 Mon Sep 17 00:00:00 2001 From: Frank Peters Date: Thu, 20 May 2010 15:23:05 +0200 Subject: #i111721# --- readlicense_oo/docs/readme.xsl | 334 +++++--------- readlicense_oo/docs/readme/readme.xrm | 819 +++++++++++++--------------------- 2 files changed, 419 insertions(+), 734 deletions(-) mode change 100755 => 100644 readlicense_oo/docs/readme.xsl diff --git a/readlicense_oo/docs/readme.xsl b/readlicense_oo/docs/readme.xsl old mode 100755 new mode 100644 index 2c98b011c315..cb13fb08ff83 --- a/readlicense_oo/docs/readme.xsl +++ b/readlicense_oo/docs/readme.xsl @@ -1,232 +1,128 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + - - - - - - ------------------------------------------------------------ - - - ------------------------------------------------------------ - - - - - - - - - - - - - - - - - - - ------------------------------------------------------------ - - - ------------------------------------------------------------ - - - + + + + - - - - - - - - - - -
    - -
-
- -
    - -
-
-
-
- - - - - -
  • -
    -
    - - - - - - - - - - - - - - - -
    - - - - - - - - - + + + + + + + + + + + + + + + + + + + +---------------------------------------------------------------------------------------------------------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + +* + + + + + + + - - - - - - - - - - - - file://localhost/ - - - http:// - - - - - - - - - - - - - - - - - - - - - - - - + + + + + +====================================================================== + +====================================================================== + + + +---------------------------------------------------------------------- + +---------------------------------------------------------------------- + + + + + +---------------------------------------------------------------------- + + + + + + +
    diff --git a/readlicense_oo/docs/readme/readme.xrm b/readlicense_oo/docs/readme/readme.xrm index 2a8a409b4eff..43603ed2159b 100755 --- a/readlicense_oo/docs/readme/readme.xrm +++ b/readlicense_oo/docs/readme/readme.xrm @@ -1,524 +1,313 @@ - - - - -
    - - - Welcome - - - - ${PRODUCTNAME} ${PRODUCTVERSION} ReadMe - - - - For latest updates to this readme file, see - http://www.openoffice.org/welcome/readme.html - - - - Dear User - - - - This file contains important information about this program. Please read this information very carefully before starting work. - - - - The OpenOffice.org Community, responsible for the development of this product, would like to invite you to participate as a community member. As a new user, you can check out the ${PRODUCTNAME} site with helpful user information at - - - - - http://www.openoffice.org/about_us/introduction.html - - - - - Also read the sections below about getting involved in the OpenOffice.org project. - - - - Is ${PRODUCTNAME} really free for any user? - - - - - ${PRODUCTNAME} is free for use by everybody. You may take this copy of ${PRODUCTNAME} and install it on as many computers as you like, and use it for any purpose you like (including commercial, government, public administration and educational use). For further details see the license text delivered together with ${PRODUCTNAME} or - http://www.openoffice.org/license.html - - - - - Why is ${PRODUCTNAME} free for any user? - - - - - - You can use this copy of ${PRODUCTNAME} today free of charge because individual contributors and corporate sponsors have designed, developed, tested, translated, documented, supported, marketed, and helped in many other ways to make ${PRODUCTNAME} what it is today - the world's leading open-source office software. - If you appreciate their efforts, and would like to ensure OpenOffice.org continues into the future, please consider contributing to the project - see - http://contributing.openoffice.org - for details. Everyone has a contribution to make. - - -
    - -
    - - - Notes on Installation - - - - System Requirements: - - - - - MacOSX 10.4 (Tiger) or higher - Intel processor - 512 MB RAM - 500 MB available hard disk space - Chinese, Japanese and Korean versions: 600 MB (multi-language version: 800 MB) available hard disk space) - 1024 x 768 graphic device with 256 colors (higher resolution recommended) - - - - - - Microsoft Windows 2000 (Service Pack 4 or higher), XP, or Vista - Pentium compatible PC (Pentium III or Athlon recommended) - 256 MB RAM (512 MB RAM recommended) - 370 MB available hard disk space - Chinese, Japanese and Korean versions: 650 MB available hard disk space - 1024x768 resolution (higher resolution recommended), at least 256 colors - - - - - - Solaris 10 operating system (SPARC platform) or higher - 256 MB RAM (512 MB RAM recommended) - 480 MB available hard disk space - Chinese, Japanese and Korean versions: 480 MB available hard disk space - X Server with 1024x768 resolution (higher resolution recommended), with at least 256 colors - Window Manager - Gnome 2.6 or higher, with the gail 1.8.6 and the at-spi 1.7 packages, required for support of assistive technology tools (AT tools) - - - - - - Solaris 10 operating system (x86 platform) or higher - 256 MB RAM (512 MB RAM recommended) - 480 MB available hard disk space - Chinese, Japanese and Korean versions: 480 MB available hard disk space - X Server with 1024x768 resolution (higher resolution recommended), with at least 256 colors - Window Manager - Gnome 2.6 or higher, with the gail 1.8.6 and the at-spi 1.7 packages, required for support of assistive technology tools (AT tools) - - - - - - Linux Kernel version 2.4 or higher - glibc2 version 2.3.2 or higher - gtk version 2.2.0 or higher - Pentium compatible PC (Pentium III or Athlon recommended) - 256 MB RAM (512 MB RAM recommended) - 440 MB available hard disk space - Chinese, Japanese and Korean versions: 440 MB available hard disk space - X Server with 1024x768 resolution (higher resolution recommended), with at least 256 colors - Window Manager - Gnome 2.6 or higher, with the gail 1.8.6 and the at-spi 1.7 packages, required for support of assistive technology tools (AT tools) - - - - - There is a wide variety of Linux distributions, and even within the same distribution there may be different installation options (KDE vs Gnome, etc.). Some distributions ship with their own ‘native’ version of ${PRODUCTNAME}, which may have different features from this Community ${PRODUCTNAME}. Sometimes you can install the Community ${PRODUCTNAME} alongside the ‘native’ version. However, it’s usually safer to remove the ‘native’ version before installing this Community version. Consult the documentation for your distribution for details of how to do this. - - - - It is recommended that you always backup your system before you remove or install software. - - - - Registration of ${PRODUCTNAME} as default application for Microsoft Office formats can be forced or suppressed by using the following command line switches with the installer: - - /msoreg=1 will force registration of ${PRODUCTNAME} as default application for Microsoft Office formats. - /msoreg=0 will suppress registration of ${PRODUCTNAME} as default application for Microsoft Office formats. - - - - - If you perform an administrative installation using setup /a, you need to make sure that the file msvc90.dll is installed on the system. This file is required for ${PRODUCTNAME} to start after an administrative installation. You can get the file from - http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF - - + + + + + ${PRODUCTNAME} Readme File + + + +
    -
    - - Extension Database Incompatibility - -
    - - - The Berkeley database engine has been upgraded in this version of ${PRODUCTNAME}. The database engine upgrade introduces an incompatibility with user data for installed extensions for ${PRODUCTNAME} versions prior to 3.2 that may require your action if you downgrade your version of ${PRODUCTNAME}. - - - - This version of ${PRODUCTNAME} will convert your extension database to the new Berkeley database format when extensions are installed or removed. After this conversion, the database can no longer be read by earlier versions of ${PRODUCTNAME}. Downgrading to an earlier version may result in a dysfunctional installation. - - - - If you downgrade to an earlier version of ${PRODUCTNAME}, you must remove the user data directory {user data}/uno_packages, for example ~/.openoffice.org/3/user/uno_packages, and reinstall all extensions. - - - - - Problems During Program Startup - - - - If you experience ${PRODUCTNAME} startup problems (most notably while using Gnome) please 'unset' the SESSION_MANAGER environment variable inside the shell you use to start ${PRODUCTNAME}. This can be done by adding the line "unset SESSION_MANAGER" to the beginning of the soffice shell script found in the "[office folder]/program" directory. - - - - Difficulties starting ${PRODUCTNAME} (e.g. applications hang) as well as problems with the screen display are often caused by the graphics card driver. If these problems occur, please update your graphics card driver or try using the graphics driver delivered with your operating system. Difficulties displaying 3D objects can often be solved by deactivating the option "Use OpenGL" under 'Tools - Options - ${PRODUCTNAME} - View - 3D view'. - - - - Difficulties starting ${PRODUCTNAME} (e.g. applications hang) as well as problems with the screen display are often caused by the graphics card driver. If these problems occur, please update your graphics card driver or try using the graphics driver delivered with your operating system. Difficulties displaying 3D objects can often be solved by deactivating the option "Use OpenGL" under 'Tools - Options - ${PRODUCTNAME} - View - 3D view'. - - - +

    ${PRODUCTNAME} ${PRODUCTVERSION} ReadMe

    +

    For latest updates to this readme file, see http://www.openoffice.org/welcome/readme.html

    +

    This file contains important information about this program. Please read this information very carefully before starting work.

    +

    The OpenOffice.org Community, responsible for the development of this product, would like to invite you to participate as a community member. As a new user, you can check out the ${PRODUCTNAME} site with helpful user information at http://www.openoffice.org/about_us/introduction.html

    +

    Also read the sections below about getting involved in the OpenOffice.org project.

    + +

    Is ${PRODUCTNAME} really free for any user?

    +

    ${PRODUCTNAME} is free for use by everybody. You may take this copy of ${PRODUCTNAME} and install it on as many computers as you like, and use it for any purpose you like (including commercial, government, public administration and educational use). For further details see the license text delivered together with ${PRODUCTNAME} or http://www.openoffice.org/license.html

    + +

    Why is ${PRODUCTNAME} free for any user?

    +

    You can use this copy of ${PRODUCTNAME} today free of charge because individual contributors and corporate sponsors have designed, developed, tested, translated, documented, supported, marketed, and helped in many other ways to make ${PRODUCTNAME} what it is today - the world's leading open-source office software.

    +

    If you appreciate their efforts, and would like to ensure OpenOffice.org continues into the future, please consider contributing to the project - see http://contributing.openoffice.org for details. Everyone has a contribution to make.

    + +
    + +
    - - - - Please note that copy and paste via clipboard between ${PRODUCTNAME} 1.x and ${PRODUCTNAME} ${PRODUCTVERSION} might not work in OpenOffice.org format. If that happens, choose 'Edit - Paste Special' and choose a format other than ${PRODUCTNAME}, or open the document in ${PRODUCTNAME} ${PRODUCTVERSION} directly. - - - - Please make sure you have enough free memory in the temporary directory on your system and that read, write and run access rights have been granted. Close all other programs before starting the installation. - - - - Note: Please be aware that administrator rights are needed for the installation process. - +

    Notes on Installation

    + +

    System Requirements

    +
    +
      +
    • +

      MacOSX 10.4 (Tiger) or higher

      +
    • +
    • +

      Intel processor

      +
    • +
    • +

      512 MB RAM

      +
    • +
    • +

      Up to 1.5 GB available hard disk space

      +
    • +
    • +

      1024 x 768 graphic device with 256 colors (higher resolution recommended)

      +
    • +
    +
    +
    +
      +
    • +

      Microsoft Windows 2000 (Service Pack 4 or higher), XP, Vista, or Windows 7

      +
    • +
    • +

      Pentium compatible PC (Pentium III or Athlon recommended)

      +
    • +
    • +

      256 MB RAM (512 MB RAM recommended)

      +
    • +
    • +

      Up to 1.5 GB available hard disk space

      +
    • +
    • +

      1024x768 resolution (higher resolution recommended), at least 256 colors

      +
    • +
    +

    Please be aware that administrator rights are needed for the installation process.

    + +

    Registration of ${PRODUCTNAME} as default application for Microsoft Office formats can be forced or suppressed by using the following command line switches with the installer:

    +
      +
    • +

      /msoreg=1 will force registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

      +
    • +
    • +

      /msoreg=0 will suppress registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

      +
    • +
    +

    If you perform an administrative installation using setup /a, you need to make sure that the file msvc90.dll is installed on the system. This file is required for ${PRODUCTNAME} to start after an administrative installation. You can get the file from http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF

    +

    Please be aware that administrator rights are needed for the installation process.

    +
    +
    +
      +
    • +

      Solaris 10 operating system (SPARC platform) or higher

      +
    • +
    • +

      256 MB RAM (512 MB RAM recommended)

      +
    • +
    • +

      Up to 1.55 GB available hard disk space

      +
    • +
    • +

      X Server with 1024x768 resolution (higher resolution recommended), with at least 256 colors

      +
    • +
    • +

      Window Manager

      +
    • +
    • +

      Gnome 2.6 or higher, with the gail 1.8.6 and the at-spi 1.7 packages, required for support of assistive technology tools (AT tools)

      +
    • +
    +
    +
    +
      +
    • +

      Solaris 10 operating system (x86 platform) or higher

      +
    • +
    • +

      256 MB RAM (512 MB RAM recommended)

      +
    • +
    • +

      Up to 1.55 GB available hard disk space

      +
    • +
    • +

      X Server with 1024x768 resolution (higher resolution recommended), with at least 256 colors

      +
    • +
    • +

      Window Manager

      +
    • +
    • +

      Gnome 2.6 or higher, with the gail 1.8.6 and the at-spi 1.7 packages, required for support of assistive technology tools (AT tools)

      +
    • +
    +
    +
    +
      +
    • +

      Linux Kernel version 2.6.18 or higher

      +
    • +
    • +

      glibc2 version 2.5 or higher

      +
    • +
    • +

      gtk version 2.10.4 or higher

      +
    • +
    • +

      Pentium compatible PC (Pentium III or Athlon recommended)

      +
    • +
    • +

      256 MB RAM (512 MB RAM recommended)

      +
    • +
    • +

      Up to 1.55 GB available hard disk space

      +
    • +
    • +

      X Server with 1024x768 resolution (higher resolution recommended), with at least 256 colors

      +
    • +
    • +

      Window Manager

      +
    • +
    • +

      Gnome 2.16 or higher, with the gail 1.8.6 and the at-spi 1.7 packages, required for support of assistive technology tools (AT tools)

      +
    • +
    +

    There is a wide variety of Linux distributions, and even within the same distribution there may be different installation options (KDE vs Gnome, etc.). Some distributions ship with their own ‘native’ version of ${PRODUCTNAME}, which may have different features from this Community ${PRODUCTNAME}. Sometimes you can install the Community ${PRODUCTNAME} alongside the ‘native’ version. However, it’s usually safer to remove the ‘native’ version before installing this Community version. Consult the documentation for your distribution for details of how to do this.

    +

    It is recommended that you always backup your system before you remove or install software.

    +
    + +

    Please make sure you have enough free memory in the temporary directory on your system and that read, write and run access rights have been granted. Close all other programs before starting the installation.

    +
    -
    - -
    - - - ALPS/Synaptics notebook touchpads in Windows - - - - Due to a Windows driver issue, you cannot scroll through ${PRODUCTNAME} documents when you slide your finger across an ALPS/Synaptics touchpad. - - - - To enable touchpad scrolling, add the following lines to the "C:\Program Files\Synaptics\SynTP\SynTPEnh.ini" configuration file, and restart your computer: - - - - [${PRODUCTNAME}] - FC = "SALFRAME" - SF = 0x10000000 - SF |= 0x00004000 - - - - Note: The location of the configuration file might vary on different versions of Windows. - -
    - -
    - - - Mozilla Address Book Driver - - - - The Mozilla address book driver requires the SUNWzlib package. This package is not part of the minimum Solaris operating system installation. If you require access to the Mozilla address book, then add this package to your Solaris operating system using the command "pkgadd" from the installation CD. - -
    - -
    - - - Shortcut Keys - - - - Only shortcut keys (key combinations) not used by the operating system can be used in ${PRODUCTNAME}. If a key combination in ${PRODUCTNAME} does not work as described in the ${PRODUCTNAME} Help, check if that shortcut is already used by the operating system. To rectify such conflicts, you can change the keys assigned by your operating system. Alternatively, you can change almost any key assignment in ${PRODUCTNAME}. For more information on this topic, refer to the ${PRODUCTNAME} Help or the Help documentation of your operating system. - - - - The application help of ${PRODUCTNAME} may use shortcut combinations for PC keyboards only. - - - - Due to a conflict with input method switching on multiple platforms, the following shortcut keys required to be changed at last minute: - - - - - Cmd-Space is now Cmd-Shift-Space - Cmd-Shift-Space is now Cmd-M - - - - - - Ctrl-Space is now Ctrl-Shift-Space - Ctrl-Shift-Space is now Ctrl-M - - - - - - Ctrl-Space is now Ctrl-Shift-Space - Ctrl-Shift-Space is now Ctrl-M - - +
    +

    Extension Database Incompatibility

    +

    The Berkeley database engine has been upgraded in this version of ${PRODUCTNAME}. The database engine upgrade introduces an incompatibility with user data for installed extensions for ${PRODUCTNAME} versions prior to 3.2 that may require your action if you downgrade your version of ${PRODUCTNAME}.

    +

    This version of ${PRODUCTNAME} will convert your extension database to the new Berkeley database format when extensions are installed or removed. After this conversion, the database can no longer be read by earlier versions of ${PRODUCTNAME}. Downgrading to an earlier version may result in a dysfunctional installation.

    +

    If you downgrade to an earlier version of ${PRODUCTNAME}, you must remove the user data directory {user data}/uno_packages, for example ~/.openoffice.org/3/user/uno_packages, and reinstall all extensions.

    +
    - - - Ctrl-Space is now Ctrl-Shift-Space - Ctrl-Shift-Space is now Ctrl-M - - - -
    - -
    - - - File Locking - - - - In the default setting, file locking is turned on in ${PRODUCTNAME}. To deactivate it, you have to set the appropriate environment variables SAL_ENABLE_FILE_LOCKING=0 and export SAL_ENABLE_FILE_LOCKING. These entries are already in enabled form in the soffice script file. - - - - Warning: The activated file locking feature can cause problems with Solaris 2.5.1 and 2.7 used in conjunction with Linux NFS 2.0. If your system environment has these parameters, we strongly recommend that you avoid using the file locking feature. Otherwise, ${PRODUCTNAME} will hang when you try to open a file from a NFS mounted directory from a Linux computer. - -
    - -
    - - - Problems When Sending Documents as E-mails From ${PRODUCTNAME} - - - - When sending a document via 'File - Send - Document as E-mail' or 'Document as PDF Attachment' problems might occur (program crashes or hangs). This is due to the Windows system file "Mapi" (Messaging Application Programming Interface) which causes problems in some file versions. Unfortunately, the problem cannot be narrowed down to a certain version number. For more information visit http://www.microsoft.com to search the Microsoft Knowledge Base for "mapi dll". - -
    - -
    - - Important Accessibility Notes - - - - For information on the accessibility features in ${PRODUCTNAME}, see - http://www.openoffice.org/access/ - . - +
    +

    Problems During Program Startup

    + +
    +

    If you experience ${PRODUCTNAME} startup problems (most notably while using Gnome) please 'unset' the SESSION_MANAGER environment variable inside the shell you use to start ${PRODUCTNAME}. This can be done by adding the line "unset SESSION_MANAGER" to the beginning of the soffice shell script found in the "[office folder]/program" directory.

    +
    + +

    Difficulties starting ${PRODUCTNAME} (e.g. applications hang) as well as problems with the screen display are often caused by the graphics card driver. If these problems occur, please update your graphics card driver or try using the graphics driver delivered with your operating system. Difficulties displaying 3D objects can often be solved by deactivating the option "Use OpenGL" under 'Tools - Options - ${PRODUCTNAME} - View - 3D view'.

    +
    -
    - -
    - - - Registration - - - - Please take a little time to complete the minimal Product Registration process when you install the software. While registration is optional, we encourage you to register, since the information enables the community to make an even better software suite and address user needs directly. Through its Privacy Policy, the ${PRODUCTNAME} Community takes every precaution to safeguard your personal data. If you missed the registration at installation, you can return and register at any time at by choosing "Help > Registration" from the main menu. - -
    - -
    - - - User Survey - - - - There is also a User Survey located online which we encourage you to fill out. The User Survey results will help ${PRODUCTNAME} move more rapidly in setting new standards for the creation of the next-generation office suite. Through its Privacy Policy, the ${PRODUCTNAME} Community takes every precaution to safeguard your personal data. - -
    - -
    - - - User Support - - - - The main support page - http://support.openoffice.org/ - offers various possibilities for help with ${PRODUCTNAME}. Your question may have already been answered - check the Community Forum. - http://user.services.openoffice.org - or search the archives of the 'users@openoffice.org' mailing list at - http://www.openoffice.org/mail_list.html - . Alternatively, you can send in your questions to - users@openoffice.org - . How to subscribe to the list (to get an email response) is explained on this page: - http://wiki.services.openoffice.org/wiki/Website/Content/help/mailinglists - . - - - - Also check the FAQ section at - http://wiki.services.openoffice.org/wiki/Documentation/FAQ - . - -
    +
    +

    ALPS/Synaptics notebook touchpads in Windows

    +

    Due to a Windows driver issue, you cannot scroll through ${PRODUCTNAME} documents when you slide your finger across an ALPS/Synaptics touchpad.

    +

    To enable touchpad scrolling, add the following lines to the "C:\Program Files\Synaptics\SynTP\SynTPEnh.ini" configuration file, and restart your computer:

    +

    [${PRODUCTNAME}]

    +

    FC = "SALFRAME"

    +

    SF = 0x10000000

    +

    SF |= 0x00004000

    +

    The location of the configuration file might vary on different versions of Windows.

    +
    + +
    +

    Mozilla Address Book Driver

    +

    The Mozilla address book driver requires the SUNWzlib package. This package is not part of the minimum Solaris operating system installation. If you require access to the Mozilla address book, then add this package to your Solaris operating system using the command "pkgadd" from the installation CD.

    +
    + +
    +

    Shortcut Keys

    +

    Only shortcut keys (key combinations) not used by the operating system can be used in ${PRODUCTNAME}. If a key combination in ${PRODUCTNAME} does not work as described in the ${PRODUCTNAME} Help, check if that shortcut is already used by the operating system. To rectify such conflicts, you can change the keys assigned by your operating system. Alternatively, you can change almost any key assignment in ${PRODUCTNAME}. For more information on this topic, refer to the ${PRODUCTNAME} Help or the Help documention of your operating system.

    + +
    +

    The application help of ${PRODUCTNAME} may use shortcut combinations for PC keyboards only.

    +
    + +

    Due to a conflict with input method switching on multiple platforms, the following shortcut keys required to be changed at last minute:

    + +
    +
      +
    • +

      Cmd-Space is now Cmd-Shift-Space

      +
    • +
    • +

      Cmd-Shift-Space is now Cmd-M

      +
    • +
    +
    + +
    +
      +
    • +

      Ctrl-Space is now Ctrl-Shift-Space

      +
    • +
    • +

      Ctrl-Shift-Space is now Ctrl-M

      +
    • +
    +
    +
    + +
    +

    File Locking

    +

    File locking is enabled by default in ${PRODUCTNAME}. On a network that uses the Network File System protocol (NFS), the locking daemon for NFS clients must be active. To disable file locking, edit the soffice script and change the line "export SAL_ENABLE_FILE_LOCKING" to "# export SAL_ENABLE_FILE_LOCKING". If you disable file locking, the write access of a document is not restricted to the user who first opens the document.

    +

    Warning: The activated file locking feature can cause problems with Solaris 2.5.1 and 2.7 used in conjunction with Linux NFS 2.0. If your system environment has these parameters, we strongly recommend that you avoid using the file locking feature. Otherwise, ${PRODUCTNAME} will hang when you try to open a file from a NFS mounted directory from a Linux computer.

    +
    + +
    +

    Problems When Sending Documents as E-mails From ${PRODUCTNAME}

    +

    When sending a document via 'File - Send - Document as E-mail' or 'Document as PDF Attachment' problems might occur (program crashes or hangs). This is due to the Windows system file "Mapi" (Messaging Application Programming Interface) which causes problems in some file versions. Unfortunately, the problem cannot be narrowed down to a certain version number. For more information visit http://www.microsoft.com to search the Microsoft Knowledge Base for "mapi dll".

    +
    + +
    +

    Important Accessibility Notes

    +

    For more information on the accessibility features in ${PRODUCTNAME}, see http://www.openoffice.org/access/

    +
    -
    - - - Report Bugs & Issues - - - - The ${PRODUCTNAME} Web site hosts IssueZilla, our mechanism for reporting, tracking and solving bugs and issues. We encourage all users to feel entitled and welcome to report issues that may arise on your particular platform. Energetic reporting of issues is one of the most important contributions that the user community can make to the ongoing development and improvement of the suite. - -
    - -
    - - - Getting Involved - - - - The ${PRODUCTNAME} Community would very much benefit from your active participation in the development of this important open source project. - - - - As a user, you are already a valuable part of the suite's development process and we would like to encourage you to take an even more active role with a view to being a long-term contributor to the community. Please join and check out the user page at: - http://www.openoffice.org - - - - - - Way to Start - - - - The best way to start contributing is to subscribe to one or more of the mailing lists, lurk for a while, and gradually use the mail archives to familiarize yourself with many of the topics covered since the ${PRODUCTNAME} source code was released back in October 2000. When you're comfortable, all you need to do is send an email self-introduction and jump right in. If you are familiar with Open Source Projects, check out our To-Dos list and see if there is anything you would like to help with at - http://development.openoffice.org/todo.html - . - - +
    +

    Registration

    +

    Please take a little time to complete the minimal Product Registration process when you install the software. While registration is optional, we encourage you to register, since the information enables the community to make an even better software suite and address user needs directly. Through its Privacy Policy, the ${PRODUCTNAME} Community takes every precaution to safeguard your personal data. If you missed the registration at installation, you can return and register at any time at by choosing "Help - Registration" from the main menu.

    +
    + +
    +

    User Survey

    +

    There is also a User Survey located online which we encourage you to fill out. The User Survey results will help ${PRODUCTNAME} move more rapidly in setting new standards for the creation of the next-generation office suite. Through its Privacy Policy, the ${PRODUCTNAME} Community takes every precaution to safeguard your personal data.

    +
    + +
    +

    User Support

    +

    The main support page http://support.openoffice.org/ offers various possibilities for help with ${PRODUCTNAME}. Your question may have already been answered - check the Community Forum at http://user.services.openoffice.org or search the archives of the 'users@openoffice.org' mailing list at http://www.openoffice.org/mail_list.html. Alternatively, you can send in your questions to users@openoffice.org. How to subscribe to the list (to get an email response) is explained on this page: http://wiki.services.openoffice.org/wiki/Website/Content/help/mailinglists.

    +

    Also check the FAQ section at http://wiki.services.openoffice.org/wiki/Documentation/FAQ.

    +
    - - Subscribe - - - - Here are a few of the Project mailing lists to which you can subscribe at - http://www.openoffice.org/mail_list.html - - - - - News: announce@openoffice.org *recommended to all users* (light traffic) - Main user forum: user@openoffice.org *easy way to lurk on discussions* (heavy traffic) - Marketing project: dev@marketing.openoffice.org *beyond development* (getting heavy) - General code contributor list: dev@openoffice.org (moderate/heavy) - - - +
    +

    Reporting Bugs & Issues

    +

    The ${PRODUCTNAME} Web site hosts IssueZilla, our mechanism for reporting, tracking and solving bugs and issues. We encourage all users to feel entitled and welcome to report issues that may arise on your particular platform. Energetic reporting of issues is one of the most important contributions that the user community can make to the ongoing development and improvement of the suite.

    +
    + +
    +

    Getting Involved

    +

    The ${PRODUCTNAME} Community would very much benefit from your active participation in the development of this important open source project.

    +

    As a user, you are already a valuable part of the suite's development process and we would like to encourage you to take an even more active role with a view to being a long-term contributor to the community. Please join and check out the user page at http://www.openoffice.org

    + +

    How to Start

    +

    The best way to start contributing is to subscribe to one or more of the mailing lists, lurk for a while, and gradually use the mail archives to familiarize yourself with many of the topics covered since the ${PRODUCTNAME} source code was released back in October 2000. When you're comfortable, all you need to do is send an email self-introduction and jump right in. If you are familiar with Open Source Projects, check out our To-Dos list and see if there is anything you would like to help with at http://development.openoffice.org/todo.html.

    + +

    Subscribe

    +

    Here are a few of the Project mailing lists to which you can subscribe at http://www.openoffice.org/mail_list.html

    +
      +
    • +

      News: announce@openoffice.org *recommended to all users* (light traffic)

      +
    • +
    • +

      Main user forum: user@openoffice.org *easy way to lurk on discussions* (heavy traffic)

      +
    • +
    • +

      Marketing project: dev@marketing.openoffice.org *beyond development* (getting heavy)

      +
    • +
    • +

      General code contributor list: dev@openoffice.org (moderate/heavy)

      +
    • +
    + +

    Joining one or more Projects

    +

    You can make major contributions to this important open source project even if you have limited software design or coding experience. Yes, you!

    +

    At http://projects.openoffice.org/index.html you will find projects ranging from Localization, Porting and Groupware to some real core coding projects. If you are not a developer, try the Documentation or the Marketing Project. The OpenOffice.org Marketing Project is applying both guerilla and traditional commercial techniques to marketing open source software, and we are doing it across language and cultural barriers, so you can help just by spreading the word and telling a friend about this office suite.

    +

    You can help by joining the Marketing Communications & Information Network on http://marketing.openoffice.org/contacts.html where you can provide point communication contact with press, media, government agencies, consultants, schools, Linux Users Groups and developers in your country and local community.

    +
    - - Join one or more Projects - - - - You can make major contributions to this important open source project even if you have limited software design or coding experience. Yes, you! - - - - At - http://projects.openoffice.org/index.html - you will find projects ranging from Localization, Porting and Groupware to some real core coding projects. If you are not a developer, try the Documentation or the Marketing Project. The OpenOffice.org Marketing Project is applying both guerrilla and traditional commercial techniques to marketing open source software, and we are doing it across language and cultural barriers, so you can help just by spreading the word and telling a friend about this office suite. - - - - You can help by joining the Marketing Communications & Information Network here: - http://marketing.openoffice.org/contacts.html - where you can provide point communication contact with press, media, government agencies, consultants, schools, Linux Users Groups and developers in your country and local community. - -
    +
    +

    We hope you enjoy working with the new ${PRODUCTNAME} ${PRODUCTVERSION} and will join us online.

    +

    The OpenOffice.org Community

    +
    + +
    +

    Used / Modified Source Code

    +

    Portions Copyright 1998, 1999 James Clark. Portions Copyright 1996, 1998 Netscape Communications Corporation.

    +
    - -
    - - - - - We hope you enjoy working with the new ${PRODUCTNAME} ${PRODUCTVERSION} and will join us online. - - - - The OpenOffice.org Community - - - - - - -
    - -
    - - - Used / Modified Source Code - - - - Portions Copyright 1998, 1999 James Clark. Portions Copyright 1996, 1998 Netscape Communications Corporation. - -
    -
    + + -- cgit From 89b704f9db9ebbff43f6a423d2a1f17314de7a5c Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 21 May 2010 09:42:27 +0200 Subject: jl152 #i77196# XExtensionManager::synchronize now has no repository argument; adapted PackageInformationProvider to use bundled extensions --- .../deployment/manager/dp_extensionmanager.cxx | 90 +++++------ .../deployment/manager/dp_extensionmanager.hxx | 1 - .../deployment/manager/dp_informationprovider.cxx | 174 +++++++++------------ desktop/source/deployment/misc/dp_misc.cxx | 22 +-- 4 files changed, 109 insertions(+), 178 deletions(-) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index edc414dc6f5d..2781231b8f5e 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -116,6 +116,29 @@ OUString CompIdentifiers::getName(::std::vector > co OSL_ASSERT(extension.is()); return extension->getDisplayName(); } + +void writeLastModified(OUString & url, Reference const & xCmdEnv) +{ + //Write the lastmodified file + try { + ::rtl::Bootstrap::expandMacros(url); + ::ucbhelper::Content ucbStamp(url, xCmdEnv ); + dp_misc::erase_path( url, xCmdEnv ); + ::rtl::OString stamp("1" ); + Reference xData( + ::xmlscript::createInputStream( + ::rtl::ByteSequence( + reinterpret_cast(stamp.getStr()), + stamp.getLength() ) ) ); + ucbStamp.writeStream( xData, true /* replace existing */ ); + } + catch(...) + { + uno::Any exc(::cppu::getCaughtException()); + throw deploy::DeploymentException( + OUSTR("Failed to update") + url, 0, exc); + } +} } //end namespace namespace dp_manager { @@ -1021,7 +1044,6 @@ void ExtensionManager::reinstallDeployedExtensions( } sal_Bool ExtensionManager::synchronize( - OUString const & repository, Reference const & xAbortChannel, Reference const & xCmdEnv ) throw (deploy::DeploymentException, @@ -1033,37 +1055,20 @@ sal_Bool ExtensionManager::synchronize( try { sal_Bool bModified = sal_False; - Reference xPackageManager; - OUString file; - if (repository.equals(OUSTR("user"))) - { - xPackageManager = m_userRepository; - } - else if (repository.equals(OUSTR("shared"))) - { - xPackageManager = m_sharedRepository; - file = OUString ( - RTL_CONSTASCII_USTRINGPARAM( - "$SHARED_EXTENSIONS_USER/lastsynchronized")); - } - else if (repository.equals(OUSTR("bundled"))) - { - xPackageManager = m_bundledRepository; - file = OUString ( - RTL_CONSTASCII_USTRINGPARAM( - "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); - } - else - throw lang::IllegalArgumentException( - OUSTR("No valid repository name provided."), - static_cast(this), 0); ::osl::MutexGuard guard(getMutex()); - String sSynchronizing(StrSyncRepository::get()); - sSynchronizing.SearchAndReplaceAllAscii( "%NAME", repository ); - dp_misc::ProgressLevel progress(xCmdEnv, sSynchronizing); + String sSynchronizingShared(StrSyncRepository::get()); + sSynchronizingShared.SearchAndReplaceAllAscii( "%NAME", OUSTR("shared")); + dp_misc::ProgressLevel progressShared(xCmdEnv, sSynchronizingShared); + bModified = m_sharedRepository->synchronize(xAbortChannel, xCmdEnv); + progressShared.update(OUSTR("\n\n")); + + String sSynchronizingBundled(StrSyncRepository::get()); + sSynchronizingBundled.SearchAndReplaceAllAscii( "%NAME", OUSTR("bundled")); + dp_misc::ProgressLevel progressBundled(xCmdEnv, sSynchronizingBundled); + bModified |= m_bundledRepository->synchronize(xAbortChannel, xCmdEnv); + progressBundled.update(OUSTR("\n\n")); - bModified = xPackageManager->synchronize(xAbortChannel, xCmdEnv); try { const uno::Sequence > > @@ -1082,31 +1087,8 @@ sal_Bool ExtensionManager::synchronize( //so we will no repeat this everytime OOo starts. OSL_ENSURE(0, "Extensions Manager: synchronize"); } - - - progress.update(OUSTR("\n\n")); - - //Write the lastmodified file - try { - ::rtl::Bootstrap::expandMacros(file); - ::ucbhelper::Content ucbStamp(file, xCmdEnv ); - dp_misc::erase_path( file, xCmdEnv ); - ::rtl::OString stamp("1" ); - Reference xData( - ::xmlscript::createInputStream( - ::rtl::ByteSequence( - reinterpret_cast(stamp.getStr()), - stamp.getLength() ) ) ); - ucbStamp.writeStream( xData, true /* replace existing */ ); - } - catch(...) - { - uno::Any exc(::cppu::getCaughtException()); - throw deploy::DeploymentException( - OUSTR("Failed to update") + file, - static_cast(this), exc); - - } + writeLastModified(OUSTR("$BUNDLED_EXTENSIONS_USER/lastsynchronized"), xCmdEnv); + writeLastModified(OUSTR("$SHARED_EXTENSIONS_USER/lastsynchronized"), xCmdEnv); return bModified; } catch (deploy::DeploymentException& ) { throw; diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 4367770945aa..ad0e7d95df7e 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -186,7 +186,6 @@ public: css::uno::RuntimeException); virtual sal_Bool SAL_CALL synchronize( - ::rtl::OUString const & repository, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index 9f2e0c9e1177..537b7233ef77 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -32,11 +32,10 @@ #include "comphelper/servicedecl.hxx" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" #include "com/sun/star/deployment/UpdateInformationProvider.hpp" #include "com/sun/star/deployment/XPackage.hpp" #include "com/sun/star/deployment/XPackageInformationProvider.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/XUpdateInformationProvider.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/registry/XRegistryKey.hpp" @@ -104,7 +103,7 @@ private: uno::Reference< uno::XComponentContext> mxContext; - rtl::OUString getPackageLocation( const uno::Reference< deployment::XPackageManager > _xManager, + rtl::OUString getPackageLocation( const rtl::OUString& repository, const rtl::OUString& _sExtensionId ); uno::Reference< deployment::XUpdateInformationProvider > mxUpdateInformation; @@ -113,10 +112,9 @@ private: getUpdateInformation( uno::Sequence< rtl::OUString > const & urls, rtl::OUString const & identifier ) const; uno::Sequence< uno::Reference< deployment::XPackage > > - getPackages( const uno::Reference< deployment::XPackageManager > _xManager ); - uno::Sequence< uno::Sequence< rtl::OUString > > isUpdateAvailable( const uno::Reference< deployment::XPackageManager > _xManager, - const rtl::OUString& _sExtensionId ); - uno::Sequence< uno::Sequence< rtl::OUString > > getExtensionList( const uno::Reference< deployment::XPackageManager > _xManager ); + getPackages(rtl::OUString const & repository); + uno::Sequence< uno::Sequence< rtl::OUString > > isUpdateAvailable( + rtl::OUString const & repository, const rtl::OUString& _sExtensionId ); uno::Sequence< uno::Sequence< rtl::OUString > > concatLists( uno::Sequence< uno::Sequence< rtl::OUString > > aFirst, uno::Sequence< uno::Sequence< rtl::OUString > > aSecond ); }; @@ -148,15 +146,18 @@ void SAL_CALL PackageInformationProvider::handle( uno::Reference< task::XInterac //------------------------------------------------------------------------------ rtl::OUString PackageInformationProvider::getPackageLocation( - const uno::Reference< deployment::XPackageManager > _xManager, - const rtl::OUString& _rExtensionId ) + const rtl::OUString & repository, + const rtl::OUString& _rExtensionId ) { rtl::OUString aLocationURL; + uno::Reference xManager = + deployment::ExtensionManager::get(mxContext); - if ( _xManager.is() ) + if ( xManager.is() ) { const uno::Sequence< uno::Reference< deployment::XPackage > > packages( - _xManager->getDeployedPackages( + xManager->getDeployedExtensions( + repository, uno::Reference< task::XAbortChannel >(), static_cast < XCommandEnvironment *> (this) ) ); @@ -187,32 +188,21 @@ rtl::OUString SAL_CALL PackageInformationProvider::getPackageLocation( const rtl::OUString& _sExtensionId ) throw ( uno::RuntimeException ) { - uno::Reference< deployment::XPackageManager > xManager; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - rtl::OUString aLocationURL = getPackageLocation( xManager, _sExtensionId ); + rtl::OUString aLocationURL = getPackageLocation( UNISTRING("user"), _sExtensionId ); if ( aLocationURL.getLength() == 0 ) { - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - aLocationURL = getPackageLocation( xManager, _sExtensionId ); + aLocationURL = getPackageLocation( UNISTRING("shared"), _sExtensionId ); + } + if ( aLocationURL.getLength() == 0 ) + { + aLocationURL = getPackageLocation( UNISTRING("bundled"), _sExtensionId ); } - if ( aLocationURL.getLength() ) { ::ucbhelper::Content aContent( aLocationURL, NULL ); aLocationURL = aContent.getURL(); } - return aLocationURL; } @@ -222,75 +212,76 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionId ) throw ( uno::RuntimeException ) { - uno::Sequence< uno::Sequence< rtl::OUString > > aUpdateListUser; + uno::Sequence< uno::Sequence< rtl::OUString > > + aUpdateListUser = isUpdateAvailable( UNISTRING("user"), _sExtensionId ); - uno::Reference< deployment::XPackageManager > xManager; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} + uno::Sequence< uno::Sequence< rtl::OUString > > + aUpdateListShared = isUpdateAvailable( UNISTRING("shared"), _sExtensionId ); - aUpdateListUser = isUpdateAvailable( xManager, _sExtensionId ); + uno::Sequence< uno::Sequence< rtl::OUString > > + aUpdateListBundled = isUpdateAvailable( UNISTRING("bundled"), _sExtensionId ); - uno::Sequence< uno::Sequence< rtl::OUString > > aUpdateListShared; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - aUpdateListShared = isUpdateAvailable( xManager, _sExtensionId ); - - if ( !aUpdateListUser.hasElements() ) - return aUpdateListShared; - else if ( !aUpdateListShared.hasElements() ) - return aUpdateListUser; - else - return concatLists( aUpdateListUser, aUpdateListShared ); + uno::Sequence< uno::Sequence< rtl::OUString > > user_shared = + concatLists( aUpdateListUser, aUpdateListShared ); + return concatLists(user_shared, aUpdateListBundled); } //------------------------------------------------------------------------------ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::getExtensionList() throw ( uno::RuntimeException ) { - uno::Sequence< uno::Sequence< rtl::OUString > > aListUser; + const uno::Reference mgr = + deployment::ExtensionManager::get(mxContext); - uno::Reference< deployment::XPackageManager > xManager; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} + if (!mgr.is()) + return uno::Sequence< uno::Sequence< rtl::OUString > >(); - aListUser = getExtensionList( xManager ); + const uno::Sequence< uno::Sequence< uno::Reference > > + allExt = mgr->getAllExtensions( + uno::Reference< task::XAbortChannel >(), + static_cast < XCommandEnvironment *> (this) ); - uno::Sequence< uno::Sequence< rtl::OUString > > aListShared; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} + uno::Sequence< uno::Sequence< rtl::OUString > > retList; - aListShared = getExtensionList( xManager ); + sal_Int32 cAllIds = allExt.getLength(); + retList.realloc(cAllIds); - if ( !aListUser.hasElements() ) - return aListShared; - else if ( !aListShared.hasElements() ) - return aListUser; - else - return concatLists( aListUser, aListShared ); + for (sal_Int32 i = 0; i < cAllIds; i++) + { + //The inner sequence contains extensions with the same identifier from + //all the different repositories, that is user, share, bundled. + const uno::Sequence< uno::Reference< deployment::XPackage > > & + seqExtension = allExt[i]; + sal_Int32 cExt = seqExtension.getLength(); + OSL_ASSERT(cExt == 3); + for (sal_Int32 j = 0; j < cExt; j++) + { + //ToDo according to the old code the first found extenions is used + //even if another one with the same id has a better version. Design flaw? + uno::Reference< deployment::XPackage > const & xExtension( seqExtension[j] ); + if (xExtension.is()) + { + rtl::OUString aNewEntry[2]; + aNewEntry[0] = dp_misc::getIdentifier(xExtension); + aNewEntry[1] = xExtension->getVersion(); + retList[i] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 ); + break; + } + } + } + return retList; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ uno::Sequence< uno::Reference< deployment::XPackage > > - PackageInformationProvider::getPackages( const uno::Reference< deployment::XPackageManager > _xMgr ) +PackageInformationProvider::getPackages( const rtl::OUString & repository ) { uno::Sequence< uno::Reference< deployment::XPackage > > packages; try { - packages = _xMgr->getDeployedPackages( uno::Reference< task::XAbortChannel >(), + uno::Reference xMgr = deployment::ExtensionManager::get(mxContext); + packages = xMgr->getDeployedExtensions(repository, uno::Reference< task::XAbortChannel >(), static_cast < XCommandEnvironment *> (this) ); } catch ( deployment::DeploymentException & ) @@ -329,18 +320,19 @@ uno::Sequence< uno::Reference< xml::dom::XElement > > //------------------------------------------------------------------------------ uno::Sequence< uno::Sequence< rtl::OUString > > PackageInformationProvider::isUpdateAvailable( - const uno::Reference< deployment::XPackageManager > _xManager, - const rtl::OUString& _sExtensionId ) + const rtl::OUString& repository, + const rtl::OUString& _sExtensionId ) { uno::Sequence< uno::Sequence< rtl::OUString > > aList; sal_Int32 nCount = 0; bool bPackageFound = false; + uno::Reference xManager = deployment::ExtensionManager::get(mxContext); // If the package manager is readonly then the user cannot modify anything anyway // so we can abort the search here - if ( _xManager.is() && ! _xManager->isReadOnly() ) + if ( xManager.is() && ! xManager->isReadOnlyRepository(repository) ) { - uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( _xManager ) ); + uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( repository ) ); uno::Sequence< uno::Reference< xml::dom::XElement > > defaultInfos; for ( int pos = packages.getLength(); pos-- && !bPackageFound; ) @@ -412,32 +404,6 @@ uno::Sequence< uno::Sequence< rtl::OUString > > return aList; } -//------------------------------------------------------------------------------ -uno::Sequence< uno::Sequence< rtl::OUString > > - PackageInformationProvider::getExtensionList( - const uno::Reference< deployment::XPackageManager > _xManager ) -{ - uno::Sequence< uno::Sequence< rtl::OUString > > aList; - - if ( _xManager.is() ) - { - uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( _xManager ) ); - - aList.realloc( packages.getLength() ); - - for ( int pos = packages.getLength(); pos--; ) - { - uno::Reference< deployment::XPackage > package( packages[ pos ] ); - rtl::OUString aNewEntry[2]; - - aNewEntry[0] = dp_misc::getIdentifier( package ); - aNewEntry[1] = package->getVersion(); - aList[ pos ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 ); - } - } - return aList; -} - //------------------------------------------------------------------------------ uno::Sequence< uno::Sequence< rtl::OUString > > PackageInformationProvider::concatLists( uno::Sequence< uno::Sequence< rtl::OUString > > aFirst, diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 3867f741f982..5269e3d8aac5 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -603,8 +603,8 @@ void syncRepositories(Reference const & xCmdEnv) //synchronize shared before bundled otherewise there are //more revoke and registration calls. sal_Bool bModified = false; - const OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); - if (needToSyncRepostitory(sShared)) + if (needToSyncRepostitory(OUString(RTL_CONSTASCII_USTRINGPARAM("shared"))) + || needToSyncRepostitory(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")))) { xExtensionManager = deployment::ExtensionManager::get( @@ -613,23 +613,7 @@ void syncRepositories(Reference const & xCmdEnv) if (xExtensionManager.is()) { bModified = xExtensionManager->synchronize( - sShared, Reference(), xCmdEnv); - } - } - - const OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); - if (needToSyncRepostitory( sBundled)) - { - if (!xExtensionManager.is()) - { - xExtensionManager = - deployment::ExtensionManager::get( - comphelper_getProcessComponentContext()); - } - if (xExtensionManager.is()) - { - bModified |= xExtensionManager->synchronize( - sBundled, Reference(), xCmdEnv); + Reference(), xCmdEnv); } } -- cgit From 7668f1f0a853091d9e24d8dcce104e6081789a55 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 21 May 2010 15:13:26 +0200 Subject: jl152 #i77196# unopkg reinstall works now --- .../deployment/manager/dp_extensionmanager.cxx | 12 ++++++-- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 34 ++++++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 2781231b8f5e..fddefb5ad277 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -994,6 +994,7 @@ uno::Sequence< uno::Sequence > > } } +//only to be called from unopkg!!! void ExtensionManager::reinstallDeployedExtensions( OUString const & repository, Reference const & xAbortChannel, @@ -1009,6 +1010,9 @@ void ExtensionManager::reinstallDeployedExtensions( ::osl::MutexGuard guard(getMutex()); xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv); + //We must sync here, otherwise we will get exceptions when extensions + //are removed. + dp_misc::syncRepositories(xCmdEnv); const uno::Sequence< Reference > extensions( xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv)); @@ -1087,8 +1091,12 @@ sal_Bool ExtensionManager::synchronize( //so we will no repeat this everytime OOo starts. OSL_ENSURE(0, "Extensions Manager: synchronize"); } - writeLastModified(OUSTR("$BUNDLED_EXTENSIONS_USER/lastsynchronized"), xCmdEnv); - writeLastModified(OUSTR("$SHARED_EXTENSIONS_USER/lastsynchronized"), xCmdEnv); + OUString lastSyncBundled(RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); + writeLastModified(lastSyncBundled, xCmdEnv); + OUString lastSyncShared(RTL_CONSTASCII_USTRINGPARAM( + "$SHARED_EXTENSIONS_USER/lastsynchronized")); + writeLastModified(lastSyncShared, xCmdEnv); return bModified; } catch (deploy::DeploymentException& ) { throw; diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 2f4a7f1d7146..621b8b0bac7c 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -35,6 +35,7 @@ #include "tools/extendapplicationenvironment.hxx" #include "rtl/ustrbuf.hxx" #include "rtl/uri.hxx" +#include "rtl/bootstrap.hxx" #include "osl/thread.h" #include "osl/process.h" #include "osl/conditn.hxx" @@ -331,10 +332,6 @@ extern "C" int unopkg_main() } } - xComponentContext = getUNO( - disposeGuard, option_verbose, option_shared, subcmd_gui, - xLocalComponentContext ); - if (repository.getLength() == 0) { if (option_shared) @@ -359,6 +356,29 @@ extern "C" int unopkg_main() } } + if (subCommand.equals(OUSTR("reinstall"))) + { + //We must prevent that services and types are loaded by UNO, + //otherwise we cannot delete the registry data folder. + OUString extensionUnorc; + if (repository.equals(OUSTR("user"))) + extensionUnorc = OUSTR("$UNO_USER_PACKAGES_CACHE/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc"); + else if (repository.equals(OUSTR("shared"))) + extensionUnorc = OUSTR("$SHARED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc"); + else if (repository.equals(OUSTR("bundled"))) + extensionUnorc = OUSTR("$BUNDLED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc"); + else + OSL_ASSERT(0); + + ::rtl::Bootstrap::expandMacros(extensionUnorc); + oslFileError e = osl_removeFile(extensionUnorc.pData); + if (e != osl_File_E_None && e != osl_File_E_NOENT) + throw Exception(OUSTR("Could not delete ") + extensionUnorc, 0); + } + + xComponentContext = getUNO( + disposeGuard, option_verbose, option_shared, subcmd_gui, + xLocalComponentContext ); Reference xExtensionManager( deployment::ExtensionManager::get( xComponentContext ) ); @@ -368,7 +388,11 @@ extern "C" int unopkg_main() option_force, option_verbose) ); //synchronize bundled/shared extensions - if (!subcmd_gui && ! dp_misc::office_is_running()) + //Do not synchronize when command is "reinstall". This could add types and services to UNO and + //prevent the deletion of the registry data folder + //synching is done in XExtensionManager.reinstall + if (!subcmd_gui && ! subCommand.equals(OUSTR("reinstall")) + && ! dp_misc::office_is_running()) dp_misc::syncRepositories(xCmdEnv); if (subcmd_add || -- cgit From 3d3b46bb623c859265d2b95068845b18a1b64716 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 21 May 2010 16:17:24 +0200 Subject: jl152 #i77196# dp_misc::sycnRepositories cannot be switched off with bootstrap variable, because it is not necessary fro the perfomance test --- desktop/source/app/check_ext_deps.cxx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 757135a7e2d3..e9c71bc1ea36 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -396,10 +396,5 @@ sal_Bool Desktop::CheckExtensionDependencies() void Desktop::SynchronizeExtensionRepositories() { RTL_LOGFILE_CONTEXT(aLog,"desktop (jl) ::Desktop::SynchronizeExtensionRepositories"); - OUString sDisable; - ::rtl::Bootstrap::get( UNISTRING( "DISABLE_SYNC_EXTENSIONS" ), sDisable, OUString() ); - if (sDisable.getLength() > 0) - return; - dp_misc::syncRepositories( new SilentCommandEnv( this ) ); } -- cgit From 8d8f9bc029e9dec0bcc74846095661e9090a8789 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 21 May 2010 16:46:32 +0200 Subject: dr76: #i103453# import visual area for embedded documents --- desktop/source/migration/migration.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index 2181daab7454..b9be788ebd4b 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -232,6 +232,7 @@ static void insertSorted(migrations_available& rAvailableMigrations, supported_m { rAvailableMigrations.insert(pIter, aSupportedMigration ); bInserted = true; + break; } ++pIter; } -- cgit From 5186da3ad7783a49efb08064f9cf380754c3f4bd Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 24 May 2010 11:28:33 +0100 Subject: cmcfixes75: #i111796# check ftruncate return value --- shell/source/unix/sysshell/recently_used_file.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/source/unix/sysshell/recently_used_file.cxx b/shell/source/unix/sysshell/recently_used_file.cxx index cc4fbf75adcc..8a9de90c8b16 100644 --- a/shell/source/unix/sysshell/recently_used_file.cxx +++ b/shell/source/unix/sysshell/recently_used_file.cxx @@ -114,7 +114,8 @@ void recently_used_file::reset() const //------------------------------------------------ void recently_used_file::truncate(off_t length) { - ftruncate(fileno(file_), length); + if (ftruncate(fileno(file_), length) == -1) + throw "I/O error: ftruncate failed"; } //------------------------------------------------ -- cgit From de8796345a26ebc4607cfd0fd10b303c20b866e9 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 25 May 2010 11:45:06 +0200 Subject: cws tl79: #i110254# security tab page in 'File/Properties' --- sfx2/inc/sfx2/objsh.hxx | 2 + sfx2/inc/sfx2/sfx.hrc | 4 +- sfx2/source/dialog/securitypage.cxx | 163 ++++++++++++++++++++++-------------- sfx2/source/dialog/securitypage.src | 8 ++ sfx2/source/doc/objxtor.cxx | 16 ++++ 5 files changed, 127 insertions(+), 66 deletions(-) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 7984fae956cb..3e3448de4753 100755 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -686,6 +686,8 @@ public: // change recording and respective passwword protection for Writer and Calc // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT + virtual bool IsChangeRecording() const; + virtual bool HasChangeRecordProtection() const; virtual void SetChangeRecording( bool bActivate ); virtual bool SetProtectionPassword( const String &rPassword ); virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc index 3ed7f34ee3b8..a49b003b5b49 100755 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -234,7 +234,9 @@ #define TP_MANAGE_STYLES (RID_SFX_START+7) #define DLG_STYLE_DESIGNER (RID_SFX_START+8) -#define RID_SFX_INCORRECT_PASSWORD (RID_SFX_START+216) +#define RID_SFX_PROTECT_RECORDS (RID_SFX_START+216) +#define RID_SFX_UNPROTECT_RECORDS (RID_SFX_START+217) +#define RID_SFX_INCORRECT_PASSWORD (RID_SFX_START+218) #define STR_STYLE_FILTER_AUTO (RID_SFX_START+9) #define STR_STYLE_FILTER_USED (RID_SFX_START+10) diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index f88525107f1c..0c6688ab1229 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -53,43 +53,6 @@ using namespace ::com::sun::star; -////////////////////////////////////////////////////////////////////// - -static short lcl_GetPassword( Window *pParent, bool bShowConfirm, /*out*/String &rPassword ) -{ - bool bRes = false; - SfxPasswordDialog aPasswdDlg( pParent ); - if (bShowConfirm) - aPasswdDlg.ShowExtras( SHOWEXTRAS_CONFIRM ); - if (RET_OK == aPasswdDlg.Execute() && aPasswdDlg.GetPassword().Len() > 0) - { - rPassword = aPasswdDlg.GetPassword(); - bRes = true; - } - return bRes; -} - - -static bool lcl_IsPasswordCorrect( const String &rPassword ) -{ - bool bRes = false; - - SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); - uno::Sequence< sal_Int8 > aPasswordHash; - bool bHasPassword = pCurDocShell->GetProtectionHash( aPasswordHash ); - - // check if supplied password was correct - uno::Sequence< sal_Int8 > aNewPasswd( aPasswordHash ); - SvPasswordHelper::GetHashPassword( aNewPasswd, rPassword ); - if (SvPasswordHelper::CompareHashPassword( aPasswordHash, rPassword )) - bRes = true; // password was correct - else - InfoBox( NULL, String( SfxResId( RID_SFX_INCORRECT_PASSWORD ) ) ).Execute(); - - return bRes; -} - - ////////////////////////////////////////////////////////////////////// @@ -98,6 +61,21 @@ namespace enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; enum RedlineFunc { RF_ON, RF_PROTECT }; +/* + bool QueryIsEnabled( USHORT _nSlot ) + { + bool bRes = false; + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + const SfxPoolItem* pItem; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + SfxItemState eState = pDisp->QueryState( _nSlot, pItem ); + bRes = (eState & SFX_ITEM_DISABLED) == 0; + } + return bRes; + } +*/ bool QueryState( USHORT _nSlot, bool& _rValue ) { @@ -107,7 +85,8 @@ namespace { const SfxPoolItem* pItem; SfxDispatcher* pDisp = pViewSh->GetDispatcher(); - bRet = SFX_ITEM_AVAILABLE <= pDisp->QueryState( _nSlot, pItem ); + SfxItemState nState = pDisp->QueryState( _nSlot, pItem ); + bRet = SFX_ITEM_AVAILABLE <= nState; if (bRet) _rValue = ( static_cast< const SfxBoolItem* >( pItem ) )->GetValue(); } @@ -143,6 +122,50 @@ namespace ////////////////////////////////////////////////////////////////////// +static short lcl_GetPassword( + Window *pParent, + bool bProtect, + /*out*/String &rPassword ) +{ + bool bRes = false; + SfxPasswordDialog aPasswdDlg( pParent ); + const String aTitle( SfxResId( bProtect ? RID_SFX_PROTECT_RECORDS : RID_SFX_UNPROTECT_RECORDS ) ); + aPasswdDlg.SetText( aTitle ); + aPasswdDlg.SetMinLen( 1 ); + if (bProtect) + aPasswdDlg.ShowExtras( SHOWEXTRAS_CONFIRM ); + if (RET_OK == aPasswdDlg.Execute() && aPasswdDlg.GetPassword().Len() > 0) + { + rPassword = aPasswdDlg.GetPassword(); + bRes = true; + } + return bRes; +} + + +static bool lcl_IsPasswordCorrect( const String &rPassword ) +{ + bool bRes = false; + + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + uno::Sequence< sal_Int8 > aPasswordHash; + bool bHasPassword = pCurDocShell->GetProtectionHash( aPasswordHash ); + + // check if supplied password was correct + uno::Sequence< sal_Int8 > aNewPasswd( aPasswordHash ); + SvPasswordHelper::GetHashPassword( aNewPasswd, rPassword ); + if (SvPasswordHelper::CompareHashPassword( aPasswordHash, rPassword )) + bRes = true; // password was correct + else + InfoBox( NULL, String( SfxResId( RID_SFX_INCORRECT_PASSWORD ) ) ).Execute(); + + return bRes; +} + + +////////////////////////////////////////////////////////////////////// + + struct SfxSecurityPage_Impl { SfxSecurityPage & m_rMyTabPage; @@ -235,39 +258,43 @@ BOOL SfxSecurityPage_Impl::FillItemSet_Impl( SfxItemSet & ) bool bModified = false; SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); - if (pCurDocShell) + if (pCurDocShell&& !pCurDocShell->IsReadOnly()) { - if (m_eRedlingMode != RL_NONE && !pCurDocShell->IsReadOnly()) + if (m_eRedlingMode != RL_NONE ) { - // change recording - const bool bDoRecordChanges = m_aRecordChangesCB.IsChecked(); - pCurDocShell->SetChangeRecording( bDoRecordChanges ); + const bool bDoRecordChanges = m_aRecordChangesCB.IsChecked(); + const bool bDoChangeProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; + + // sanity checks + DBG_ASSERT( bDoRecordChanges || !bDoChangeProtection, "no change recording should imply no change protection" ); + DBG_ASSERT( bDoChangeProtection || !bDoRecordChanges, "no change protection should imply no change recording" ); + DBG_ASSERT( !bDoChangeProtection || m_aNewPassword.Len() > 0, "change protection should imply password length is > 0" ); + DBG_ASSERT( bDoChangeProtection || m_aNewPassword.Len() == 0, "no change protection should imply password length is 0" ); - // no change recording should imply no password protection - if (!bDoRecordChanges && (!m_bNewPasswordIsValid || m_aNewPassword.Len() != 0)) + // change recording + if (bDoRecordChanges != pCurDocShell->IsChangeRecording()) { - // actually this should not be possible. Thus just as 'coded comment': - DBG_ASSERT( 0, "unexpected state of UI" ); - m_bNewPasswordIsValid = true; - m_aNewPassword = String(); + pCurDocShell->SetChangeRecording( bDoRecordChanges ); + bModified = true; } // change record protection - if (m_bNewPasswordIsValid) + if (m_bNewPasswordIsValid && + bDoChangeProtection != pCurDocShell->HasChangeRecordProtection()) { - const bool bDoChangeProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; DBG_ASSERT( !bDoChangeProtection || bDoRecordChanges, "change protection requires record changes to be active!" ); pCurDocShell->SetProtectionPassword( m_aNewPassword ); + bModified = true; } - - bModified = true; } // open read-only? - if (pCurDocShell->HasSecurityOptOpenReadOnly()) + const sal_Bool bDoOpenReadonly = m_aOpenReadonlyCB.IsChecked(); + if (pCurDocShell->HasSecurityOptOpenReadOnly() && + bDoOpenReadonly != pCurDocShell->IsSecurityOptOpenReadOnly()) { - pCurDocShell->SetSecurityOptOpenReadOnly( m_aOpenReadonlyCB.IsChecked() ); + pCurDocShell->SetSecurityOptOpenReadOnly( bDoOpenReadonly ); bModified = true; } } @@ -333,16 +360,22 @@ void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) m_aRecordChangesCB.Check( bRecordChanges ); m_aRecordChangesCB.Enable( /*!bProtection && */!bIsReadonly ); - DBG_ASSERT( pCurDocShell, "doc shell missing" ); - if (pCurDocShell) - { - m_bOrigPasswordIsConfirmed = true; // default case if no password is set - uno::Sequence< sal_Int8 > aPasswordHash; - // check if password is available - if (pCurDocShell->GetProtectionHash( aPasswordHash ) && - aPasswordHash.getLength() > 0) - m_bOrigPasswordIsConfirmed = false; // password found, needs to be confirmed later on - } + m_bOrigPasswordIsConfirmed = true; // default case if no password is set + uno::Sequence< sal_Int8 > aPasswordHash; + // check if password is available + if (pCurDocShell->GetProtectionHash( aPasswordHash ) && + aPasswordHash.getLength() > 0) + m_bOrigPasswordIsConfirmed = false; // password found, needs to be confirmed later on + } + else + { + // A Calc document that is shared will have 'm_eRedlingMode == RL_NONE' + // In shared documents change recording and protection must be disabled, + // similar to documents that do not support change recording at all. + m_aRecordChangesCB.Check( FALSE ); + m_aRecordChangesCB.Disable(); + m_aChangeProtectionPB.Check( FALSE ); + m_aChangeProtectionPB.Disable(); } } diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src index 4bf8cdaf58a9..7c0fffd96057 100755 --- a/sfx2/source/dialog/securitypage.src +++ b/sfx2/source/dialog/securitypage.src @@ -150,6 +150,14 @@ TabPage TP_DOCINFOSECURITY }; }; +String RID_SFX_PROTECT_RECORDS +{ + Text [ en-US ] = "Protect Records" ; +}; +String RID_SFX_UNPROTECT_RECORDS +{ + Text [ en-US ] = "Unprotect Records" ; +}; String RID_SFX_INCORRECT_PASSWORD { Text [ en-US ] = "Incorrect password" ; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 751525910958..fdbd2b6a5cf0 100755 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -1076,6 +1076,22 @@ void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew ) } +bool SfxObjectShell::IsChangeRecording() const +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + + +bool SfxObjectShell::HasChangeRecordProtection() const +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + + void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ ) { // currently this function needs to be overwritten by Writer and Calc only -- cgit From 6b4917460417793350ed406aa0742ec31ef6ca3c Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 26 May 2010 08:13:07 +0200 Subject: cws tl79: warning-free code --- sfx2/source/dialog/securitypage.cxx | 2 +- sfx2/source/doc/objxtor.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index 0c6688ab1229..d32ee843cbf2 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -149,7 +149,7 @@ static bool lcl_IsPasswordCorrect( const String &rPassword ) SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); uno::Sequence< sal_Int8 > aPasswordHash; - bool bHasPassword = pCurDocShell->GetProtectionHash( aPasswordHash ); + pCurDocShell->GetProtectionHash( aPasswordHash ); // check if supplied password was correct uno::Sequence< sal_Int8 > aNewPasswd( aPasswordHash ); diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index fdbd2b6a5cf0..217faeca2e55 100755 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -1099,7 +1099,7 @@ void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ ) } -bool SfxObjectShell::SetProtectionPassword( const String &rPassword ) +bool SfxObjectShell::SetProtectionPassword( const String & /*rPassword*/ ) { // currently this function needs to be overwritten by Writer and Calc only DBG_ASSERT( 0, "function not implemented" ); -- cgit From 16d2852d25a1c2c90ac5a2f90f7753564b082afc Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 26 May 2010 10:22:48 +0200 Subject: vcl112: #i111819# resolve aliases --- fpicker/source/aqua/FilterHelper.cxx | 11 +++++++++++ fpicker/source/aqua/NSURL_OOoAdditions.hxx | 13 +++++++++---- fpicker/source/aqua/NSURL_OOoAdditions.mm | 30 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/fpicker/source/aqua/FilterHelper.cxx b/fpicker/source/aqua/FilterHelper.cxx index 10e429f201c5..9c644326005e 100644 --- a/fpicker/source/aqua/FilterHelper.cxx +++ b/fpicker/source/aqua/FilterHelper.cxx @@ -35,6 +35,7 @@ // #endif #include "CFStringUtilities.hxx" #include "NSString_OOoAdditions.hxx" +#include "NSURL_OOoAdditions.hxx" #include "FilterHelper.hxx" @@ -428,6 +429,16 @@ sal_Bool FilterHelper::filenameMatchesFilter(NSString* sFilename) } } + // might be an alias + NSString* pResolved = resolveAlias( sFilename ); + if( pResolved ) + { + sal_Bool bResult = filenameMatchesFilter( pResolved ); + [pResolved autorelease]; + if( bResult ) + return sal_True; + } + DBG_PRINT_EXIT(CLASS_NAME, __func__); return sal_False; diff --git a/fpicker/source/aqua/NSURL_OOoAdditions.hxx b/fpicker/source/aqua/NSURL_OOoAdditions.hxx index 8be2c0362096..31b55385e155 100644 --- a/fpicker/source/aqua/NSURL_OOoAdditions.hxx +++ b/fpicker/source/aqua/NSURL_OOoAdditions.hxx @@ -29,15 +29,20 @@ #define _NSURL_OOOADDITIONS_HXX_ #include -#include +#include #include #include "CFStringUtilities.hxx" #include -// #include - @interface NSURL (OOoAdditions) - (rtl::OUString) OUStringForInfo:(InfoType)info; @end -#endif \ No newline at end of file +/* + returns the resolved string if there was an alias + if there was no alias, nil is returned +*/ + +NSString* resolveAlias( NSString* i_pSystemPath ); + +#endif diff --git a/fpicker/source/aqua/NSURL_OOoAdditions.mm b/fpicker/source/aqua/NSURL_OOoAdditions.mm index 56fc198650c8..ecc38b7e232b 100644 --- a/fpicker/source/aqua/NSURL_OOoAdditions.mm +++ b/fpicker/source/aqua/NSURL_OOoAdditions.mm @@ -80,3 +80,33 @@ return sResult; } @end + +NSString* resolveAlias( NSString* i_pSystemPath ) +{ + NSString* pResolvedPath = nil; + CFURLRef rUrl = CFURLCreateWithFileSystemPath( kCFAllocatorDefault, + (CFStringRef)i_pSystemPath, + kCFURLPOSIXPathStyle, false); + if( rUrl != NULL ) + { + FSRef rFS; + if( CFURLGetFSRef( rUrl, &rFS ) ) + { + MacOSBoolean bIsFolder = false; + MacOSBoolean bAlias = false; + OSErr err = FSResolveAliasFile( &rFS, true, &bIsFolder, &bAlias); + if( (err == noErr) && bAlias ) + { + CFURLRef rResolvedUrl = CFURLCreateFromFSRef( kCFAllocatorDefault, &rFS ); + if( rResolvedUrl != NULL ) + { + pResolvedPath = (NSString*)CFURLCopyFileSystemPath( rResolvedUrl, kCFURLPOSIXPathStyle ); + CFRelease( rResolvedUrl ); + } + } + } + CFRelease( rUrl ); + } + + return pResolvedPath; +} -- cgit From 776d5631f5089f94cbe87b6f869f7887aeff2092 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 28 May 2010 17:50:38 +0200 Subject: jl152 #i77196# new update behavior for extensions --- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 27 +- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 22 +- .../deployment/gui/dp_gui_extensioncmdqueue.hxx | 3 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 19 +- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 3 +- .../source/deployment/gui/dp_gui_updatedata.hxx | 35 ++- .../source/deployment/gui/dp_gui_updatedialog.cxx | 331 ++++++++++++++------- .../source/deployment/gui/dp_gui_updatedialog.hxx | 20 +- .../source/deployment/gui/dp_gui_updatedialog.src | 12 - .../deployment/gui/dp_gui_updateinstalldialog.cxx | 43 ++- desktop/source/deployment/inc/dp_misc.h | 46 +++ .../deployment/manager/dp_extensionmanager.cxx | 77 ++++- .../deployment/manager/dp_extensionmanager.hxx | 15 +- .../source/deployment/manager/dp_properties.cxx | 44 ++- .../source/deployment/manager/dp_properties.hxx | 5 + desktop/source/deployment/misc/dp_misc.cxx | 142 +++++++++ 16 files changed, 635 insertions(+), 209 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 086e39e5f18c..35634d5ef851 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -38,6 +38,7 @@ #include "dp_gui_shared.hxx" #include "dp_gui_theextmgr.hxx" #include "dp_misc.h" +#include "dp_identifier.hxx" #include "vcl/ctrl.hxx" #include "vcl/menu.hxx" @@ -105,15 +106,6 @@ struct StrAllFiles : public rtl::StaticWithInit< const OUString, StrAllFiles > } }; -//------------------------------------------------------------------------------ -UpdateListEntry::UpdateListEntry( const uno::Reference< deployment::XPackage > &xPackage ) : - m_xPackage( xPackage ) -{} - -//------------------------------------------------------------------------------ -UpdateListEntry::~UpdateListEntry() -{} - //------------------------------------------------------------------------------ // ExtBoxWithBtns_Impl //------------------------------------------------------------------------------ @@ -849,9 +841,15 @@ bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > & if ( !xPackage.is() ) return false; - std::vector< TUpdateListEntry > vEntries; - TUpdateListEntry pEntry( new UpdateListEntry( xPackage ) ); - vEntries.push_back( pEntry ); + // get the extension with highest version + uno::Sequence > seqExtensions = + m_pManager->getExtensionManager()->getExtensionsWithSameIdentifier( + dp_misc::getIdentifier(xPackage), xPackage->getName(), uno::Reference()); + uno::Reference extension = + dp_misc::getExtensionWithHighestVersion(seqExtensions); + OSL_ASSERT(extension.is()); + std::vector< css::uno::Reference< css::deployment::XPackage > > vEntries; + vEntries.push_back(extension); m_pManager->updatePackages( vEntries ); @@ -1453,14 +1451,13 @@ IMPL_LINK( UpdateRequiredDialog, HandleUpdateBtn, void*, EMPTYARG ) { ::osl::ClearableMutexGuard aGuard( m_aMutex ); - std::vector< TUpdateListEntry > vUpdateEntries; + std::vector< uno::Reference< deployment::XPackage > > vUpdateEntries; sal_Int32 nCount = m_pExtensionBox->GetEntryCount(); for ( sal_Int32 i = 0; i < nCount; ++i ) { TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( i ); - TUpdateListEntry pUpdateEntry( new UpdateListEntry( pEntry->m_xPackage ) ); - vUpdateEntries.push_back( pUpdateEntry ); + vUpdateEntries.push_back( pEntry->m_xPackage ); } aGuard.clear(); diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 8d82d969c4a0..954f32f4c9c6 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -202,7 +202,7 @@ struct ExtensionCmd OUString m_sExtensionURL; OUString m_sRepository; uno::Reference< deployment::XPackage > m_xPackage; - std::vector< TUpdateListEntry > m_vExtensionList; + std::vector< uno::Reference< deployment::XPackage > > m_vExtensionList; ExtensionCmd( const E_CMD_TYPE eCommand, const OUString &rExtensionURL, @@ -218,7 +218,7 @@ struct ExtensionCmd m_bWarnUser( false ), m_xPackage( rPackage ) {}; ExtensionCmd( const E_CMD_TYPE eCommand, - const std::vector< TUpdateListEntry > &vExtensionList ) + const std::vector > &vExtensionList ) : m_eCmdType( eCommand ), m_bWarnUser( false ), m_vExtensionList( vExtensionList ) {}; @@ -240,7 +240,7 @@ public: void removeExtension( const uno::Reference< deployment::XPackage > &rPackage ); void enableExtension( const uno::Reference< deployment::XPackage > &rPackage, const bool bEnable ); - void checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ); + void checkForUpdates( const std::vector > &vExtensionList ); void stop(); bool isBusy(); @@ -266,7 +266,7 @@ private: const uno::Reference< deployment::XPackage > &xPackage ); void _disableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, const uno::Reference< deployment::XPackage > &xPackage ); - void _checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ); + void _checkForUpdates( const std::vector > &vExtensionList ); enum Input { NONE, START, STOP }; @@ -696,7 +696,8 @@ void ExtensionCmdQueue::Thread::enableExtension( const uno::Reference< deploymen } //------------------------------------------------------------------------------ -void ExtensionCmdQueue::Thread::checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ) +void ExtensionCmdQueue::Thread::checkForUpdates( + const std::vector > &vExtensionList ) { ::osl::MutexGuard aGuard( m_mutex ); @@ -924,10 +925,8 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv try { - uno::Reference< deployment::XPackage > xPackage( - xExtMgr->addExtension(rPackageURL, uno::Sequence(), - rRepository, xAbortChannel, rCmdEnv.get() ) ); - OSL_ASSERT( xPackage.is() ); + xExtMgr->addExtension(rPackageURL, uno::Sequence(), + rRepository, xAbortChannel, rCmdEnv.get() ); } catch ( ucb::CommandFailedException & ) { @@ -969,7 +968,8 @@ void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdE } //------------------------------------------------------------------------------ -void ExtensionCmdQueue::Thread::_checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ) +void ExtensionCmdQueue::Thread::_checkForUpdates( + const std::vector > &vExtensionList ) { UpdateDialog* pUpdateDialog; std::vector< UpdateData > vData; @@ -1126,7 +1126,7 @@ void ExtensionCmdQueue::enableExtension( const uno::Reference< deployment::XPack m_thread->enableExtension( rPackage, bEnable ); } -void ExtensionCmdQueue::checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ) +void ExtensionCmdQueue::checkForUpdates( const std::vector > &vExtensionList ) { m_thread->checkForUpdates( vExtensionList ); } diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx index 69ad7da24769..cfadad84cedc 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx @@ -83,7 +83,8 @@ public: void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); void enableExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage, const bool bEnable ); - void checkForUpdates( const std::vector< TUpdateListEntry > &vList ); + void checkForUpdates(const std::vector< ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage > > &vList ); /** This call does not block. It signals the internal thread that it should install the remaining extensions and then terminate. diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 7c81517bbbfa..fdbc1974f61c 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -201,7 +201,7 @@ bool TheExtensionManager::isVisible() //------------------------------------------------------------------------------ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bParentVisible*/ ) { - std::vector< TUpdateListEntry > vEntries; + std::vector< uno::Reference< deployment::XPackage > > vEntries; uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; try { @@ -219,17 +219,11 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - - // we don't want update notifications for bundled packages - for ( sal_Int32 j = 0; ( j < 2 ) && ( j < xPackageList.getLength() ); ++j ) + uno::Reference< deployment::XPackage > xPackage = dp_misc::getExtensionWithHighestVersion(xAllPackages[i]); + OSL_ASSERT(xPackage.is()); + if ( xPackage.is() ) { - uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; - if ( xPackage.is() ) - { - TUpdateListEntry pEntry( new UpdateListEntry( xPackage ) ); - vEntries.push_back( pEntry ); - } + vEntries.push_back( xPackage ); } } @@ -255,7 +249,8 @@ bool TheExtensionManager::removePackage( const uno::Reference< deployment::XPack } //------------------------------------------------------------------------------ -bool TheExtensionManager::updatePackages( const std::vector< TUpdateListEntry > &vList ) +bool TheExtensionManager::updatePackages( + const std::vector< uno::Reference< deployment::XPackage > > &vList ) { m_pExecuteCmdQueue->checkForUpdates( vList ); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index 02e3aad56915..da8d3c083f42 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -92,7 +92,8 @@ public: //----------------- bool checkUpdates( bool showUpdateOnly, bool parentVisible ); - bool updatePackages( const std::vector< TUpdateListEntry > &vList ); + bool updatePackages( const std::vector< ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage > > &vList ); bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); diff --git a/desktop/source/deployment/gui/dp_gui_updatedata.hxx b/desktop/source/deployment/gui/dp_gui_updatedata.hxx index 2082b92e923a..7228982da518 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedata.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedata.hxx @@ -44,27 +44,42 @@ namespace com { namespace sun { namespace star { namespace xml { namespace dom { namespace dp_gui { -struct UpdateListEntry +struct UpdateData { - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage; + UpdateData( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > const & aExt): + aInstalledPackage(aExt), bIsShared(false) {}; - UpdateListEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - ~UpdateListEntry(); -}; + //When entries added to the listbox then there can be one for the user update and one + //for the shared update. However, both list entries will contain the same UpdateData. + //isShared is used to indicate which one is used for the shared entry. + bool bIsShared; -typedef ::boost::shared_ptr< UpdateListEntry > TUpdateListEntry; + //The currently installed extension which is going to be updated. If the extension exist in + //multiple repositories then it is the one with the highest version. + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > aInstalledPackage; + //The version of the update + ::rtl::OUString updateVersion; -struct UpdateData -{ - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > aInstalledPackage; - // The content of the update information + //For online update + // ====================== + // The content of the update information. + //Only if aUpdateInfo is set then there is an online update available with a better version + //than any of the currently installed extensions with the same identifier. ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo; //The URL of the locally downloaded extension. It will only be set if there were no errors //during the download ::rtl::OUString sLocalURL; //The URL of the website wher the download can be obtained. ::rtl::OUString sWebsiteURL; + + //For local update + //===================== + //The locale extension which is used as update for the user or shared repository. + //If set then the data for the online update (aUpdateInfo, sLocalURL, sWebsiteURL) + //are to be ignored. + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > + aUpdateSource; }; } diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index fca7d97c798a..d121ad976a06 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -151,7 +151,6 @@ rtl::OUString confineToParagraph(rtl::OUString const & text) { struct UpdateDialog::DisabledUpdate { rtl::OUString name; css::uno::Sequence< rtl::OUString > unsatisfiedDependencies; - bool permission; // We also want to show release notes and publisher for disabled updates ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo; }; @@ -230,7 +229,7 @@ public: Thread( css::uno::Reference< css::uno::XComponentContext > const & context, UpdateDialog & dialog, - const std::vector< TUpdateListEntry > &vExtensionList); + const std::vector< css::uno::Reference< css::deployment::XPackage > > & vExtensionList); void stop(); @@ -245,10 +244,16 @@ private: css::uno::Reference< css::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; + UpdateDialog::DisabledUpdate disableUpdate; + dp_gui::UpdateData updateData; }; - // A multimap in case an extension is installed in both "user" and "shared": + // A multimap in case an extension is installed in "user", "shared" or "bundled" typedef std::multimap< rtl::OUString, Entry > Map; virtual ~Thread(); @@ -267,17 +272,26 @@ private: css::uno::Sequence< rtl::OUString > const & urls, rtl::OUString const & identifier) const; - void handle( + void getOwnUpdateInformation( css::uno::Reference< css::deployment::XPackage > const & package, Map * map); + ::rtl::OUString getUpdateDisplayString( + dp_gui::UpdateData const & data, ::rtl::OUString const & version = ::rtl::OUString()) const; + + void prepareUpdateData( + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > const & package, + ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & updateInfo, + UpdateDialog::DisabledUpdate & out_du, + dp_gui::UpdateData & out_data) const; + bool update( - css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const; + UpdateDialog::DisabledUpdate const & du, + dp_gui::UpdateData const & data) const; css::uno::Reference< css::uno::XComponentContext > m_context; UpdateDialog & m_dialog; - std::vector< dp_gui::TUpdateListEntry > m_vExtensionList; + 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; @@ -289,7 +303,7 @@ private: UpdateDialog::Thread::Thread( css::uno::Reference< css::uno::XComponentContext > const & context, UpdateDialog & dialog, - const std::vector< dp_gui::TUpdateListEntry > &vExtensionList): + const std::vector< css::uno::Reference< css::deployment::XPackage > > &vExtensionList): m_context(context), m_dialog(dialog), m_vExtensionList(vExtensionList), @@ -328,9 +342,13 @@ void UpdateDialog::Thread::stop() { UpdateDialog::Thread::Entry::Entry( css::uno::Reference< css::deployment::XPackage > const & thePackage, rtl::OUString const & theVersion): + package(thePackage), - version(theVersion) -{} + version(theVersion), + bProvidesOwnUpdate(false), + updateData(thePackage) +{ +} UpdateDialog::Thread::~Thread() { @@ -343,10 +361,10 @@ void UpdateDialog::Thread::execute() OSL_ASSERT( ! m_vExtensionList.empty() ); Map map; - typedef std::vector< TUpdateListEntry >::const_iterator ITER; + typedef std::vector< css::uno::Reference< css::deployment::XPackage > >::const_iterator ITER; for ( ITER iIndex = m_vExtensionList.begin(); iIndex < m_vExtensionList.end(); ++iIndex ) { - css::uno::Reference< css::deployment::XPackage > p = (*iIndex)->m_xPackage; + css::uno::Reference< css::deployment::XPackage > p = *iIndex; if ( p.is() ) { { @@ -355,47 +373,113 @@ void UpdateDialog::Thread::execute() return; } } - handle( p, &map ); + getOwnUpdateInformation( p, &map ); } } - if (!map.empty()) { - const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL()); - if (sDefaultURL.getLength()) - { - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > - infos( - getUpdateInformation( - css::uno::Reference< css::deployment::XPackage >(), - css::uno::Sequence< rtl::OUString >(&sDefaultURL, 1), rtl::OUString())); - for (sal_Int32 i = 0; i < infos.getLength(); ++i) { - css::uno::Reference< css::xml::dom::XNode > node( - infos[i], css::uno::UNO_QUERY_THROW); - dp_misc::DescriptionInfoset infoset(m_context, node); - boost::optional< rtl::OUString > id(infoset.getIdentifier()); - if (!id) { - continue; - } - Map::iterator end(map.upper_bound(*id)); - for (Map::iterator j(map.lower_bound(*id)); j != end; ++j) { - rtl::OUString v(infoset.getVersion()); - if (dp_misc::compareVersions(v, j->second.version) == - dp_misc::GREATER) - { - j->second.version = v; - j->second.info = node; - } - } + const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL()); + if (sDefaultURL.getLength()) + { + css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > + infos( + getUpdateInformation( + css::uno::Reference< css::deployment::XPackage >(), + css::uno::Sequence< rtl::OUString >(&sDefaultURL, 1), rtl::OUString())); + for (sal_Int32 i = 0; i < infos.getLength(); ++i) { + css::uno::Reference< css::xml::dom::XNode > node( + infos[i], css::uno::UNO_QUERY_THROW); + dp_misc::DescriptionInfoset infoset(m_context, node); + boost::optional< rtl::OUString > id(infoset.getIdentifier()); + if (!id) { + continue; } - for (Map::const_iterator i(map.begin()); i != map.end(); ++i) { - if (i->second.info.is() && - !update( i->second.package, i->second.info )) + Map::iterator end(map.upper_bound(*id)); + for (Map::iterator j(map.lower_bound(*id)); j != end; ++j) { + //skip those extension which provide its own update urls + if (j->second.bProvidesOwnUpdate) + continue; + rtl::OUString v(infoset.getVersion()); + //look for the highest version in the online repository + if (dp_misc::compareVersions(v, j->second.version) == + dp_misc::GREATER) { - break; + j->second.version = v; + j->second.info = node; } } } } + + css::uno::Reference extMgr = + css::deployment::ExtensionManager::get(m_context); + for (Map::iterator i(map.begin()); i != map.end(); ++i) + { + //determine if online updates meet the requirements + prepareUpdateData(i->second.package, i->second.info, + i->second.disableUpdate, i->second.updateData); + + //determine if the update is installed in the user or shared repository + rtl::OUString sOnlineVersion; + if (i->second.updateData.aUpdateInfo.is()) + sOnlineVersion = i->second.version; + + rtl::OUString sVersionUser; + rtl::OUString sVersionShared; + rtl::OUString sVersionBundled; + css::uno::Sequence< css::uno::Reference< css::deployment::XPackage> > extensions; + try { + extensions = extMgr->getExtensionsWithSameIdentifier( + dp_misc::getIdentifier(i->second.package), i->second.package->getName(), + css::uno::Reference()); + } catch (css::lang::IllegalArgumentException& ) { + OSL_ASSERT(0); + } + OSL_ASSERT(extensions.getLength() == 3); + if (extensions[0].is() ) + sVersionUser = extensions[0]->getVersion(); + if (extensions[1].is() ) + sVersionShared = extensions[1]->getVersion(); + if (extensions[2].is() ) + sVersionBundled = extensions[2]->getVersion(); + + bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared")); + + dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension( + bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion); + dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension( + bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion); + + css::uno::Reference updateSource; + if (sourceUser != dp_misc::UPDATE_SOURCE_NONE) + { + if (sourceUser == dp_misc::UPDATE_SOURCE_SHARED) + { + i->second.updateData.aUpdateSource = extensions[1]; + i->second.updateData.updateVersion = extensions[1]->getVersion(); + } + else if (sourceUser == dp_misc::UPDATE_SOURCE_BUNDLED) + { + i->second.updateData.aUpdateSource = extensions[2]; + i->second.updateData.updateVersion = extensions[2]->getVersion(); + } + if (!update(i->second.disableUpdate, i->second.updateData)) + return; + } + + if (sourceShared != dp_misc::UPDATE_SOURCE_NONE) + { + if (sourceShared == dp_misc::UPDATE_SOURCE_BUNDLED) + { + i->second.updateData.aUpdateSource = extensions[2]; + i->second.updateData.updateVersion = extensions[2]->getVersion(); + } + i->second.updateData.bIsShared = true; + if (!update(i->second.disableUpdate, i->second.updateData)) + return; + } + } + + vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { m_dialog.checkingDone(); @@ -454,7 +538,7 @@ UpdateDialog::Thread::getUpdateInformation( css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >(); } -void UpdateDialog::Thread::handle( +void UpdateDialog::Thread::getOwnUpdateInformation( css::uno::Reference< css::deployment::XPackage > const & package, Map * map) { @@ -464,11 +548,11 @@ void UpdateDialog::Thread::handle( if (urls.getLength() == 0) { map->insert( Map::value_type( - id, Entry(package, package->getVersion()))); + id, Entry(package, OUSTR("")))); } else { css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > infos(getUpdateInformation(package, urls, id)); - rtl::OUString latestVersion(package->getVersion()); + rtl::OUString latestVersion; sal_Int32 latestIndex = -1; for (sal_Int32 i = 0; i < infos.getLength(); ++i) { dp_misc::DescriptionInfoset infoset( @@ -490,80 +574,102 @@ void UpdateDialog::Thread::handle( } } if (latestIndex != -1) { - update( package, - css::uno::Reference< css::xml::dom::XNode >( - infos[latestIndex], css::uno::UNO_QUERY_THROW)); + Entry e(package, latestVersion); + e.info = css::uno::Reference< css::xml::dom::XNode >( + infos[latestIndex], css::uno::UNO_QUERY_THROW); + e.bProvidesOwnUpdate = true; + map->insert(Map::value_type(id, e)); } } } -bool UpdateDialog::Thread::update( - css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const +::rtl::OUString UpdateDialog::Thread::getUpdateDisplayString( + dp_gui::UpdateData const & data, ::rtl::OUString const & version) const { - dp_misc::DescriptionInfoset infoset(m_context, updateInfo); - OSL_ASSERT(infoset.getVersion().getLength() != 0); - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > ds( - dp_misc::Dependencies::check(infoset)); - - UpdateDialog::DisabledUpdate du; - du.aUpdateInfo = updateInfo; - du.unsatisfiedDependencies.realloc(ds.getLength()); - for (sal_Int32 i = 0; i < ds.getLength(); ++i) { - du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]); - } - du.permission = ! m_dialog.isReadOnly( package ); - const ::boost::optional< ::rtl::OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL()); - rtl::OUStringBuffer b(package->getDisplayName()); + OSL_ASSERT(data.aInstalledPackage.is()); + rtl::OUStringBuffer b(data.aInstalledPackage->getDisplayName()); b.append(static_cast< sal_Unicode >(' ')); { vos::OGuard g( Application::GetSolarMutex() ); - if ( m_stop ) - return !m_stop; - else - b.append(m_dialog.m_version); + b.append(m_dialog.m_version); } b.append(static_cast< sal_Unicode >(' ')); - b.append(infoset.getVersion()); - if (updateWebsiteURL) + if (version.getLength()) + b.append(version); + else + b.append(data.updateVersion); + + if (data.sWebsiteURL.getLength()) { b.append(static_cast< sal_Unicode >(' ')); { vos::OGuard g( Application::GetSolarMutex() ); - if ( m_stop ) - return !m_stop; - else - b.append(m_dialog.m_browserbased); + b.append(m_dialog.m_browserbased); } } - du.name = b.makeStringAndClear(); + return b.makeStringAndClear(); +} + +/** out_data will only be filled if all dependencies are ok. + */ +void UpdateDialog::Thread::prepareUpdateData( + css::uno::Reference< css::deployment::XPackage > const & package, + css::uno::Reference< css::xml::dom::XNode > const & updateInfo, + UpdateDialog::DisabledUpdate & out_du, + dp_gui::UpdateData & out_data) const +{ + if (!updateInfo.is()) + 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( + dp_misc::Dependencies::check(infoset)); + + out_du.aUpdateInfo = updateInfo; + out_du.unsatisfiedDependencies.realloc(ds.getLength()); + for (sal_Int32 i = 0; i < ds.getLength(); ++i) { + out_du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]); + } + + const ::boost::optional< ::rtl::OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL()); + + out_du.name = getUpdateDisplayString(out_data, infoset.getVersion()); - if (du.unsatisfiedDependencies.getLength() == 0 && du.permission) + if (out_du.unsatisfiedDependencies.getLength() == 0) { - dp_gui::UpdateData data; - data.aInstalledPackage = package; - data.aUpdateInfo = updateInfo; + out_data.aUpdateInfo = updateInfo; + out_data.updateVersion = infoset.getVersion(); if (updateWebsiteURL) - data.sWebsiteURL = *updateWebsiteURL; + out_data.sWebsiteURL = *updateWebsiteURL; + } +} + +bool UpdateDialog::Thread::update( + UpdateDialog::DisabledUpdate const & du, + dp_gui::UpdateData const & data) const +{ + if (du.unsatisfiedDependencies.getLength() == 0) + { vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { - m_dialog.addEnabledUpdate(du.name, data); + m_dialog.addEnabledUpdate(getUpdateDisplayString(data), data); } return !m_stop; } else { vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { - m_dialog.addDisabledUpdate(du); + m_dialog.addDisabledUpdate(du); } return !m_stop; } + return true; } // UpdateDialog ---------------------------------------------------------- UpdateDialog::UpdateDialog( css::uno::Reference< css::uno::XComponentContext > const & context, Window * parent, - const std::vector< dp_gui::TUpdateListEntry > &vExtensionList, + const std::vector > &vExtensionList, std::vector< dp_gui::UpdateData > * updateData): ModalDialog(parent,DpGuiResId(RID_DLG_UPDATE)), m_context(context), @@ -593,8 +699,6 @@ UpdateDialog::UpdateDialog( m_noInstall(String(DpGuiResId(RID_DLG_UPDATE_NOINSTALL))), m_noDependency(String(DpGuiResId(RID_DLG_UPDATE_NODEPENDENCY))), m_noDependencyCurVer(String(DpGuiResId(RID_DLG_UPDATE_NODEPENDENCY_CUR_VER))), - m_noPermission(String(DpGuiResId(RID_DLG_UPDATE_NOPERMISSION))), - m_noPermissionVista(String(DpGuiResId(RID_DLG_UPDATE_NOPERMISSION_VISTA))), m_browserbased(String(DpGuiResId(RID_DLG_UPDATE_BROWSERBASED))), m_version(String(DpGuiResId(RID_DLG_UPDATE_VERSION))), m_updateData(*updateData), @@ -651,9 +755,6 @@ UpdateDialog::UpdateDialog( if ( ! dp_misc::office_is_running()) m_help.Disable(); FreeResource(); - String sTemp(m_noPermissionVista); - sTemp.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() ); - m_noPermissionVista = sTemp; initDescription(); } @@ -983,12 +1084,25 @@ void UpdateDialog::clearDescription() bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > const & aUpdateInfo) { dp_misc::DescriptionInfoset infoset(m_context, aUpdateInfo); - std::pair< rtl::OUString, rtl::OUString > pairPub = infoset.getLocalizedPublisherNameAndURL(); - rtl::OUString sPub = pairPub.first; - rtl::OUString sURL = pairPub.second; - rtl::OUString sRel = infoset.getLocalizedReleaseNotesURL(); + return showDescription(infoset.getLocalizedPublisherNameAndURL(), + infoset.getLocalizedReleaseNotesURL()); +} + +bool UpdateDialog::showDescription(css::uno::Reference< css::deployment::XPackage > const & aExtension) +{ + OSL_ASSERT(aExtension.is()); + css::beans::StringPair pubInfo = aExtension->getPublisherInfo(); + return showDescription(std::make_pair(pubInfo.First, pubInfo.Second), + OUSTR("")); +} - if ( sPub.getLength() == 0 && sURL.getLength() == 0 && sRel.getLength() == 0 ) +bool UpdateDialog::showDescription(std::pair< rtl::OUString, rtl::OUString > const & pairPublisher, + rtl::OUString const & sReleaseNotes) +{ + rtl::OUString sPub = pairPublisher.first; + rtl::OUString sURL = pairPublisher.second; + + if ( sPub.getLength() == 0 && sURL.getLength() == 0 && sReleaseNotes.getLength() == 0 ) // nothing to show return false; @@ -1002,7 +1116,7 @@ bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > c bPublisher = true; } - if ( sRel.getLength() > 0 ) + if ( sReleaseNotes.getLength() > 0 ) { if ( !bPublisher ) { @@ -1011,7 +1125,7 @@ bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > c } m_ReleaseNotesLabel.Show(); m_ReleaseNotesLink.Show(); - m_ReleaseNotesLink.SetURL( sRel ); + m_ReleaseNotesLink.SetURL( sReleaseNotes ); } return true; } @@ -1069,7 +1183,12 @@ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) const std::vector< UpdateDialog::DisabledUpdate >::size_type sizeDisabled = m_disabledUpdates.size(); if (pos < sizeEnabled) - bInserted = showDescription(m_enabledUpdates[pos].aUpdateInfo); + { + 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); @@ -1115,16 +1234,6 @@ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) b.appendAscii(RTL_CONSTASCII_STRINGPARAM(" ")); b.append(m_noDependencyCurVer); } - if (!data.permission) { - if (b.getLength() == 0) { - b.append(m_noInstall); - } - b.append(LF); - if (isVista()) - b.append(m_noPermissionVista); - else - b.append(m_noPermission); - } break; } case GENERAL_ERROR: @@ -1231,7 +1340,7 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) OSL_ASSERT(i->aInstalledPackage.is()); //If the user has no write access to the shared folder then the update //for a shared extension is disable, that is it cannot be in m_enabledUpdates - OSL_ASSERT(isReadOnly(i->aInstalledPackage) == sal_False); +// OSL_ASSERT(isReadOnly(i->aInstalledPackage) == sal_False); #if 0 // TODO: check! OSL_ASSERT(m_extensionManagerDialog.get()); @@ -1243,6 +1352,7 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) #endif } + for (USHORT i = 0; i < m_updates.getItemCount(); ++i) { UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >( @@ -1251,6 +1361,7 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) m_updateData.push_back(m_enabledUpdates[p->index.enabledUpdate]); } } + EndDialog(RET_OK); return 0; } diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx index 1e72b22a68c7..32c317cb8735 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx @@ -83,16 +83,17 @@ public: @param parent the parent window, may be null - @param selectedPackages - if non-null, only check for updates for the selected packages - - @param packageManagers - if non-null, check for updates for all managed packages + @param vExtensionList + check for updates for the contained extensions. There must only be one extension with + a particular identifier. If one extension is installed in several repositories, then the + one with the highest version must be used, because it contains the latest known update + information. */ UpdateDialog( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context, Window * parent, - const std::vector< dp_gui::TUpdateListEntry > &vExtensionList, + const std::vector< com::sun::star::uno::Reference< + com::sun::star::deployment::XPackage > > & vExtensionList, std::vector< dp_gui::UpdateData > * updateData); ~UpdateDialog(); @@ -142,6 +143,7 @@ private: UpdateDialog & m_dialog; }; + friend class CheckListBox; void insertItem( @@ -169,6 +171,10 @@ private: void initDescription(); void clearDescription(); + bool showDescription(::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage > const & aExtension); + bool showDescription(std::pair< rtl::OUString, rtl::OUString > const & pairPublisher, + rtl::OUString const & sReleaseNotes); bool showDescription( ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & aUpdateInfo); bool showDescription( const String& rDescription, bool bWithPublisher ); @@ -206,8 +212,6 @@ private: rtl::OUString m_noInstall; rtl::OUString m_noDependency; rtl::OUString m_noDependencyCurVer; - rtl::OUString m_noPermission; - rtl::OUString m_noPermissionVista; rtl::OUString m_browserbased; rtl::OUString m_version; std::vector< dp_gui::UpdateData > m_enabledUpdates; diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.src b/desktop/source/deployment/gui/dp_gui_updatedialog.src index b86a8ad66f08..325d98c88d48 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.src +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.src @@ -244,18 +244,6 @@ ModalDialog RID_DLG_UPDATE { String RID_DLG_UPDATE_NODEPENDENCY_CUR_VER { Text[en-US] = "You have OpenOffice.org %VERSION"; }; - String RID_DLG_UPDATE_NOPERMISSION { - Text[en-US] = "No write permission (shared extension)."; - }; - String RID_DLG_UPDATE_NOPERMISSION_VISTA { - Text[en-US] = "No write permission. %PRODUCTNAME needs to run as administrator.\n" - "Please follow these steps to update this shared extension:\n" - "1. Close Extension Manager dialog.\n" - "2. Exit %PRODUCTNAME.\n" - "3. Exit %PRODUCTNAME Quickstarter located in the tray area of Windows.\n" - "4. Run %PRODUCTNAME as administrator. In order to do this call the context menu of the %PRODUCTNAME program icon and choose \'Run as administrator\'.\n" - "5. Call the Extension Manager dialog and update this shared extension.\n"; - }; String RID_DLG_UPDATE_BROWSERBASED { Text[en-US] = "browser based update"; }; diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index f2f8b8b0d6e2..067a703ec413 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -380,13 +380,12 @@ void UpdateInstallDialog::Thread::downloadExtensions() { UpdateData & curData = *i; - OSL_ASSERT(curData.aUpdateInfo.is()); + if (!curData.aUpdateInfo.is() || curData.aUpdateSource.is()) + continue; //We assume that m_aVecUpdateData contains only information about extensions which //can be downloaded directly. OSL_ASSERT(curData.sWebsiteURL.getLength() == 0); - if (!curData.aUpdateInfo.is()) - continue; //update the name of the extension which is to be downloaded { ::vos::OGuard g(Application::GetSolarMutex()); @@ -491,13 +490,11 @@ void UpdateInstallDialog::Thread::installExtensions() // osl::Thread::wait(v); bool bError = false; bool bLicenseDeclined = false; - cssu::Reference xPackage; + cssu::Reference xExtension; UpdateData & curData = *i; cssu::Exception exc; try { - if (curData.sLocalURL.getLength() == 0) - continue; cssu::Reference< css::task::XAbortChannel > xAbortChannel( curData.aInstalledPackage->createAbortChannel() ); { @@ -507,9 +504,35 @@ void UpdateInstallDialog::Thread::installExtensions() } m_abort = xAbortChannel; } - xPackage = m_dialog.getExtensionManager()->addExtension( - curData.sLocalURL, css::uno::Sequence(), - curData.aInstalledPackage->getRepositoryName(), xAbortChannel, m_updateCmdEnv.get()); + if (!curData.aUpdateSource.is() && curData.sLocalURL.getLength()) + { + css::beans::NamedValue prop(OUSTR("EXTENSION_UPDATE"), css::uno::makeAny(OUSTR("1"))); + if (!curData.bIsShared) + xExtension = m_dialog.getExtensionManager()->addExtension( + curData.sLocalURL, css::uno::Sequence(&prop, 1), + OUSTR("user"), xAbortChannel, m_updateCmdEnv.get()); + else + xExtension = m_dialog.getExtensionManager()->addExtension( + curData.sLocalURL, css::uno::Sequence(&prop, 1), + OUSTR("shared"), xAbortChannel, m_updateCmdEnv.get()); + } + else if (curData.aUpdateSource.is()) + { + OSL_ASSERT(curData.aUpdateSource.is()); + //I am not sure if we should obtain the install properties and pass them into + //add extension. Currently it contains only "SUPPRESS_LICENSE". So it it could happen + //that a license is displayed when updating from the shared repository, although the + //shared extension was installed using "SUPPRESS_LICENSE". + css::beans::NamedValue prop(OUSTR("EXTENSION_UPDATE"), css::uno::makeAny(OUSTR("1"))); + if (!curData.bIsShared) + xExtension = m_dialog.getExtensionManager()->addExtension( + curData.aUpdateSource->getURL(), css::uno::Sequence(&prop, 1), + OUSTR("user"), xAbortChannel, m_updateCmdEnv.get()); + else + xExtension = m_dialog.getExtensionManager()->addExtension( + curData.aUpdateSource->getURL(), css::uno::Sequence(&prop, 1), + OUSTR("shared"), xAbortChannel, m_updateCmdEnv.get()); + } } catch (css::deployment::DeploymentException & de) { @@ -538,7 +561,7 @@ void UpdateInstallDialog::Thread::installExtensions() m_dialog.setError(UpdateInstallDialog::ERROR_LICENSE_DECLINED, curData.aInstalledPackage->getDisplayName(), OUString()); } - else if (!xPackage.is() || bError) + else if (!xExtension.is() || bError) { ::vos::OGuard g(Application::GetSolarMutex()); if (m_stop) { diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index a0ca7f53be03..161b91a6bcde 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -179,6 +179,52 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void syncRepositories(::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv); +enum UPDATE_SOURCE +{ + UPDATE_SOURCE_NONE, + UPDATE_SOURCE_SHARED, + UPDATE_SOURCE_BUNDLED, + UPDATE_SOURCE_ONLINE +}; + +/* determine if an update is available which is installed in the + user repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateUserExtension( + bool bReadOnlyShared, + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +/* determine if an update is available which is installed in the + shared repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateSharedExtension( + bool bReadOnlyShared, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +/* determines the extension with the highest identifier and returns it + + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> +getExtensionWithHighestVersion( + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId); } diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index fddefb5ad277..251e70a19ce6 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -250,7 +250,8 @@ void ExtensionManager::addExtensionsToMap( */ ::std::list > ExtensionManager::getExtensionsWithSameId( - OUString const & identifier, OUString const & fileName) + OUString const & identifier, OUString const & fileName, + Reference< ucb::XCommandEnvironment> const & xCmdEnv) { ::std::list > extensionList; @@ -282,13 +283,70 @@ void ExtensionManager::addExtensionsToMap( return extensionList; } +uno::Sequence > +ExtensionManager::getExtensionsWithSameIdentifier( + OUString const & identifier, + OUString const & fileName, + Reference< ucb::XCommandEnvironment> const & xCmdEnv ) + throw ( + deploy::DeploymentException, + ucb::CommandFailedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + try + { + ::std::list > listExtensions = + getExtensionsWithSameId( + identifier, fileName, xCmdEnv); + sal_Bool bHasExtension = false; + + //throw an IllegalArgumentException if there is no extension at all. + typedef ::std::list >::const_iterator CIT; + for (CIT i = listExtensions.begin(); i != listExtensions.end(); i++) + bHasExtension |= i->is(); + if (!bHasExtension) + throw lang::IllegalArgumentException( + OUSTR("Could not find extension: ") + identifier + OUSTR(", ") + fileName, + static_cast(this), -1); + + return comphelper::containerToSequence< + Reference, + ::std::list > + > (listExtensions); + } + catch (deploy::DeploymentException & ) + { + throw; + } + catch ( ucb::CommandFailedException & ) + { + throw; + } + catch (lang::IllegalArgumentException &) + { + throw; + } + catch (...) + { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception during getExtensionsWithSameIdentifier"), + static_cast(this), exc); + } +} + bool ExtensionManager::isUserDisabled( OUString const & identifier, OUString const & fileName) { - ::std::list > listExtensions = - getExtensionsWithSameId(identifier, fileName); + ::std::list > listExtensions; + + try { + listExtensions = getExtensionsWithSameId(identifier, fileName); + } catch (lang::IllegalArgumentException & ) { + } OSL_ASSERT(listExtensions.size() == 3); return isUserDisabled( ::comphelper::containerToSequence< @@ -339,8 +397,11 @@ void ExtensionManager::activateExtension( Reference const & xAbortChannel, Reference const & xCmdEnv ) { - ::std::list > listExtensions = - getExtensionsWithSameId(identifier, fileName); + ::std::list > listExtensions; + try { + listExtensions = getExtensionsWithSameId(identifier, fileName); + } catch (lang::IllegalArgumentException &) { + } OSL_ASSERT(listExtensions.size() == 3); activateExtension( @@ -510,9 +571,11 @@ Reference ExtensionManager::addExtension( ExtensionProperties props(OUString(), properties, Reference()); if (licenseAttributes && licenseAttributes->suppressIfRequired && props.isSuppressedLicense()) - _xCmdEnv = Reference(new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler())); + _xCmdEnv = Reference( + new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler())); + bCanInstall = xTmpExtension->checkPrerequisites( - xAbortChannel, _xCmdEnv, xOldExtension.is()) == 0 ? true : false; + xAbortChannel, _xCmdEnv, xOldExtension.is() || props.isExtensionUpdate()) == 0 ? true : false; } catch (deploy::DeploymentException& ) { excOccurred1 = ::cppu::getCaughtException(); diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index ad0e7d95df7e..54624514adce 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -163,6 +163,17 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual css::uno::Sequence > + SAL_CALL getExtensionsWithSameIdentifier( + ::rtl::OUString const & identifier, + ::rtl::OUString const & filename, + css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) + throw ( + css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + virtual css::uno::Sequence< css::uno::Sequence > > SAL_CALL getAllExtensions( css::uno::Reference const &, @@ -252,7 +263,9 @@ private: ::std::list > getExtensionsWithSameId(::rtl::OUString const & identifier, - ::rtl::OUString const & fileName); + ::rtl::OUString const & fileName, + css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv = + css::uno::Reference< css::ucb::XCommandEnvironment>()); css::uno::Reference backupExtension( ::rtl::OUString const & identifier, ::rtl::OUString const & fileName, diff --git a/desktop/source/deployment/manager/dp_properties.cxx b/desktop/source/deployment/manager/dp_properties.cxx index b04e8131ee15..df579944c6e4 100644 --- a/desktop/source/deployment/manager/dp_properties.cxx +++ b/desktop/source/deployment/manager/dp_properties.cxx @@ -50,6 +50,8 @@ using ::com::sun::star::uno::Reference; using ::rtl::OUString; #define PROP_SUPPRESS_LICENSE "SUPPRESS_LICENSE" +#define PROP_EXTENSION_UPDATE "EXTENSION_UPDATE" + namespace dp_manager { //Reading the file @@ -89,17 +91,11 @@ ExtensionProperties::ExtensionProperties( css::beans::NamedValue const & v = properties[i]; if (v.Name.equals(OUSTR(PROP_SUPPRESS_LICENSE))) { - OUString value; - if (v.Value >>= value) - { - if (value.equals(OUSTR("1"))) - m_prop_suppress_license = OUSTR("1"); - } - else - { - throw lang::IllegalArgumentException( - OUSTR("Extension Manager: wrong property value"), 0, -1); - } + m_prop_suppress_license = getPropertyValue(v); + } + else if (v.Name.equals(OUSTR(PROP_EXTENSION_UPDATE))) + { + m_prop_extension_update = getPropertyValue(v); } else { @@ -109,6 +105,21 @@ ExtensionProperties::ExtensionProperties( } } +OUString ExtensionProperties::getPropertyValue(css::beans::NamedValue const & v) +{ + OUString value(OUSTR("0")); + if (v.Value >>= value) + { + if (value.equals(OUSTR("1"))) + value = OUSTR("1"); + } + else + { + throw lang::IllegalArgumentException( + OUSTR("Extension Manager: wrong property value"), 0, -1); + } + return value; +} void ExtensionProperties::write() { ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv); @@ -142,6 +153,17 @@ bool ExtensionProperties::isSuppressedLicense() return ret; } +bool ExtensionProperties::isExtensionUpdate() +{ + bool ret = false; + if (m_prop_extension_update) + { + if (m_prop_extension_update->equals(OUSTR("1"))) + ret = true; + } + return ret; +} + } // namespace dp_manager diff --git a/desktop/source/deployment/manager/dp_properties.hxx b/desktop/source/deployment/manager/dp_properties.hxx index 197155653de1..97fc8b8c5394 100644 --- a/desktop/source/deployment/manager/dp_properties.hxx +++ b/desktop/source/deployment/manager/dp_properties.hxx @@ -53,6 +53,9 @@ protected: ::rtl::OUString m_propFileUrl; const css::uno::Reference m_xCmdEnv; ::boost::optional< ::rtl::OUString> m_prop_suppress_license; + ::boost::optional< ::rtl::OUString> m_prop_extension_update; + + ::rtl::OUString getPropertyValue(css::beans::NamedValue const & v); public: virtual ~ExtensionProperties() {}; @@ -66,6 +69,8 @@ public: void write(); bool isSuppressedLicense(); + + bool isExtensionUpdate(); }; } diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 5269e3d8aac5..53d488095ecd 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -30,6 +30,7 @@ #include "dp_misc.h" +#include "dp_version.hxx" #include "dp_interact.h" #include "rtl/uri.hxx" #include "rtl/digest.h" @@ -630,6 +631,147 @@ void syncRepositories(Reference const & xCmdEnv) } } +/* returns the index of the greatest version, starting with 0 + + */ +int determineHighestVersion( + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + int index = 0; + OUString greatest = userVersion; + if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER) + { + index = 1; + greatest = sharedVersion; + } + if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER) + { + index = 2; + greatest = bundledVersion; + } + if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER) + { + index = 3; + } + return index; +} + +UPDATE_SOURCE isUpdateUserExtension( + bool bReadOnlyShared, + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; + if (bReadOnlyShared) + { + if (userVersion.getLength()) + { + int index = determineHighestVersion( + userVersion, sharedVersion, bundledVersion, onlineVersion); + if (index == 1) + retVal = UPDATE_SOURCE_SHARED; + else if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + else if (sharedVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), sharedVersion, bundledVersion, onlineVersion); + if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + + } + else if (bundledVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), OUString(), bundledVersion, onlineVersion); + if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + } + else + { + if (userVersion.getLength()) + { + int index = determineHighestVersion( + userVersion, sharedVersion, bundledVersion, onlineVersion); + if (index == 1) + retVal = UPDATE_SOURCE_SHARED; + else if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + } + + return retVal; +} + +UPDATE_SOURCE isUpdateSharedExtension( + bool bReadOnlyShared, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + if (bReadOnlyShared) + return UPDATE_SOURCE_NONE; + UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; + + if (sharedVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), sharedVersion, bundledVersion, onlineVersion); + if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + else if (bundledVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), OUString(), bundledVersion, onlineVersion); + if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + return retVal; +} + +Reference +getExtensionWithHighestVersion( + Sequence > const & seqExt) +{ + if (seqExt.getLength() == 0) + return Reference(); + + Reference greatest; + sal_Int32 len = seqExt.getLength(); + + for (sal_Int32 i = 0; i < len; i++) + { + if (!greatest.is()) + { + greatest = seqExt[i]; + continue; + } + Reference const & current = seqExt[i]; + //greatest has a value + if (! current.is()) + continue; + + if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER) + greatest = current; + } + return greatest; +} } -- cgit From 720cb002b90767f097bed1ee63f61337632b731d Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Mon, 31 May 2010 12:59:01 +0200 Subject: fwk143: #i111516# Support language argument and configuration item for dictionary repository URL. --- .../registry/data/org/openoffice/Office/Common.xcu | 5 ++ .../schema/org/openoffice/Office/Common.xcs | 13 +++++ sfx2/source/appl/appserv.cxx | 63 +++++++++++++++++++--- 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu index 03e37b72f9ad..b7c019f24c28 100644 --- a/officecfg/registry/data/org/openoffice/Office/Common.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu @@ -157,6 +157,11 @@ WIN
    + + + ${DICT_REPO_URL} + + true diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index cb19bb01e1ba..02e05a932952 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -974,6 +974,19 @@ false + + + CD + Contains settings related to dictionaries. + + + + CD + Specifies a repository URL where users can download additional dictionaries. + + + + AW diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 14789100bb24..bd9efc9bca1e 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -51,20 +51,15 @@ #include #include -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX #include -#endif #include +#include "comphelper/configurationhelper.hxx" -#ifndef _SVT_DOC_ADDRESSTEMPLATE_HXX_ #include -#endif #include #include -#ifndef _UNOTOOLS_CONFIGMGR_HXX_ #include -#endif #include #include #include @@ -90,6 +85,7 @@ #include #include #include +#include #include #include @@ -879,6 +875,31 @@ namespace } } +static ::rtl::OUString getConfigurationStringValue( + const ::rtl::OUString& rPackage, + const ::rtl::OUString& rRelPath, + const ::rtl::OUString& rKey, + const ::rtl::OUString& rDefaultValue ) +{ + ::rtl::OUString aDefVal( rDefaultValue ); + + try + { + ::comphelper::ConfigurationHelper::readDirectKey( + comphelper::getProcessServiceFactory(), + rPackage, + rRelPath, + rKey, + ::comphelper::ConfigurationHelper::E_READONLY) >>= aDefVal; + } + catch(const com::sun::star::uno::RuntimeException& exRun) + { throw exRun; } + catch(const com::sun::star::uno::Exception&) + {} + + return aDefVal; +} + void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) { DBG_MEMTEST(); @@ -924,8 +945,34 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) uno::Reference< css::system::XSystemShellExecute > xSystemShell( xSMGR->createInstance( DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute" ) ), uno::UNO_QUERY_THROW ); - if ( xSystemShell.is() ) - xSystemShell->execute( DEFINE_CONST_UNICODE("http://extensions.services.openoffice.org/dictionary?cid=926385"), ::rtl::OUString(), css::system::SystemShellExecuteFlags::DEFAULTS ); + + // read repository URL from configuration + ::rtl::OUString sTemplRepoURL = + getConfigurationStringValue( + ::rtl::OUString::createFromAscii("org.openoffice.Office.Common"), + ::rtl::OUString::createFromAscii("Dictionaries"), + ::rtl::OUString::createFromAscii("RepositoryURL"), + ::rtl::OUString()); + + if ( xSystemShell.is() && sTemplRepoURL.getLength() > 0 ) + { + ::rtl::OUStringBuffer aURLBuf( sTemplRepoURL ); + aURLBuf.appendAscii( "?" ); + aURLBuf.appendAscii( "lang=" ); + + // read locale from configuration + ::rtl::OUString sLocale = getConfigurationStringValue( + ::rtl::OUString::createFromAscii("org.openoffice.Setup"), + ::rtl::OUString::createFromAscii("L10N"), + ::rtl::OUString::createFromAscii("ooLocale"), + ::rtl::OUString::createFromAscii("en-US")); + + aURLBuf.append( sLocale ); + xSystemShell->execute( + aURLBuf.makeStringAndClear(), + ::rtl::OUString(), + css::system::SystemShellExecuteFlags::DEFAULTS ); + } } catch( const ::com::sun::star::uno::Exception& ) { -- cgit From 08c5dbe4de29dfbdba96ce9a269d203154472bba Mon Sep 17 00:00:00 2001 From: tono Date: Mon, 31 May 2010 21:51:32 +0900 Subject: i#111956: MinGW port fix: dependency to shared library --- desktop/source/pkgchk/unopkg/makefile.mk | 8 ++++++++ framework/util/makefile.mk | 24 ++++++++++++++++++++---- svx/util/makefile.mk | 4 ++++ vbahelper/util/makefile.mk | 4 ++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/desktop/source/pkgchk/unopkg/makefile.mk b/desktop/source/pkgchk/unopkg/makefile.mk index 8384f1b24372..729548cbadd1 100644 --- a/desktop/source/pkgchk/unopkg/makefile.mk +++ b/desktop/source/pkgchk/unopkg/makefile.mk @@ -49,7 +49,11 @@ CFLAGS+=-DSYSTEM_DB -I$(DB_INCLUDES) APP1TARGET = so$/unopkg APP1OBJS = $(OBJFILES) APP1STDLIBS = $(SALLIB) $(UNOPKGAPPLIB) +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" APP1DEPN = $(SHL1TARGETN) +.ELSE +APP1DEPN = $(SHL1IMPLIBN) +.ENDIF APP1NOSAL = TRUE APP1RPATH = BRAND .IF "$(OS)" == "WNT" @@ -61,7 +65,11 @@ APP1LINKRES = $(MISC)$/$(TARGET)1.res APP2TARGET = unopkg APP2OBJS = $(OBJFILES) APP2STDLIBS = $(SALLIB) $(UNOPKGAPPLIB) +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" APP2DEPN = $(SHL1TARGETN) +.ELSE +APP2DEPN = $(SHL1IMPLIBN) +.ENDIF APP2NOSAL = TRUE APP2RPATH = BRAND .IF "$(OS)" == "WNT" diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk index b1b7c691d29f..08218b6267b3 100644 --- a/framework/util/makefile.mk +++ b/framework/util/makefile.mk @@ -158,7 +158,11 @@ SHL2STDLIBS= \ $(SALLIB) SHL2DEF= $(MISC)$/$(SHL2TARGET).def -SHL2DEPN= $(SHL1IMPLIBN) $(SHL1TARGETN) +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +SHL2DEPN= $(SHL1TARGETN) +.ELSE +SHL2DEPN= $(SHL1IMPLIBN) +.ENDIF DEF2NAME= $(SHL2TARGET) @@ -214,7 +218,11 @@ SHL3STDLIBS= \ $(SALLIB) SHL3DEF= $(MISC)$/$(SHL3TARGET).def -SHL3DEPN= $(SHL1IMPLIBN) $(SHL1TARGETN) $(SHL2TARGETN) +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +SHL3DEPN= $(SHL1TARGETN) $(SHL2TARGETN) +.ELSE +SHL3DEPN= $(SHL1IMPLIBN) $(SHL2IMPLIBN) +.ENDIF DEF3NAME= $(SHL3TARGET) @@ -355,7 +363,11 @@ SHL4STDLIBS= \ $(I18NISOLANGLIB) SHL4DEF= $(MISC)$/$(SHL4TARGET).def -SHL4DEPN= $(SHL1IMPLIBN) $(SHL1TARGETN) $(SHL2IMPLIBN) $(SHL2TARGETN) +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +SHL4DEPN= $(SHL1TARGETN) $(SHL2TARGETN) +.ELSE +SHL4DEPN= $(SHL1IMPLIBN) $(SHL2IMPLIBN) +.ENDIF DEF4NAME= $(SHL4TARGET) @@ -386,7 +398,11 @@ SHL5STDLIBS= \ $(SALLIB) SHL5DEF= $(MISC)$/$(SHL5TARGET).def -SHL5DEPN= $(SHL1IMPLIBN) $(SHL1TARGETN) +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +SHL5DEPN= $(SHL1TARGETN) +.ELSE +SHL5DEPN= $(SHL1IMPLIBN) +.ENDIF DEF5NAME= $(SHL5TARGET) diff --git a/svx/util/makefile.mk b/svx/util/makefile.mk index 0006fa2ff5fe..5ee482e6ac82 100644 --- a/svx/util/makefile.mk +++ b/svx/util/makefile.mk @@ -104,7 +104,11 @@ DEFLIB1NAME=$(SHL1LIBS:b) SHL2TARGET= svx$(DLLPOSTFIX) SHL2IMPLIB= i$(TARGET) SHL2USE_EXPORTS=name +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL2DEPN=$(SHL1TARGETN) +.ELSE +SHL2DEPN=$(SHL1IMPLIBN) +.ENDIF SHL2LIBS= \ $(SLB)$/svdraw.lib \ diff --git a/vbahelper/util/makefile.mk b/vbahelper/util/makefile.mk index dda4be0cbc81..54a17873cf94 100644 --- a/vbahelper/util/makefile.mk +++ b/vbahelper/util/makefile.mk @@ -96,7 +96,11 @@ SHL2STDLIBS= \ $(TKLIB) \ $(BASICLIB) \ +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL2DEPN=$(SHL1TARGETN) +.ELSE +SHL2DEPN=$(SHL1IMPLIBN) +.ENDIF SHL2LIBS=$(SLB)$/$(TARGET_MSFORMS).lib # --- Targets ----------------------------------------------------------- -- cgit From 3655eab4df54f47e8821db8aed9b90fa7fab33bd Mon Sep 17 00:00:00 2001 From: tono Date: Mon, 31 May 2010 21:53:32 +0900 Subject: i#111958: MinGW port enhancement: runtime-pseude-reloc-v2 --- sfx2/source/bastyp/sfxhtml.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx index 6132e958b900..8a4b434f460b 100644 --- a/sfx2/source/bastyp/sfxhtml.cxx +++ b/sfx2/source/bastyp/sfxhtml.cxx @@ -62,11 +62,7 @@ sal_Char __FAR_DATA sHTML_MIME_application[] = "application/"; sal_Char __FAR_DATA sHTML_MIME_experimental[] = "x-"; // -#ifdef __MINGW32__ // for runtime pseudo reloc -static HTMLOptionEnum aAreaShapeOptEnums[] = -#else static HTMLOptionEnum __READONLY_DATA aAreaShapeOptEnums[] = -#endif { { OOO_STRING_SVTOOLS_HTML_SH_rect, IMAP_OBJ_RECTANGLE }, { OOO_STRING_SVTOOLS_HTML_SH_rectangle, IMAP_OBJ_RECTANGLE }, -- cgit From ac7fee6151fadda39e02a42486baeff2fb1bc95a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 31 May 2010 14:19:35 +0100 Subject: cmcfixes74: #i111960 use xdg-open when available --- shell/source/unix/misc/gnome-open-url.sh | 4 +-- shell/source/unix/misc/open-url.sh | 54 +++++++++++++++++++------------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/shell/source/unix/misc/gnome-open-url.sh b/shell/source/unix/misc/gnome-open-url.sh index 1a52fc763783..ab730d169a49 100644 --- a/shell/source/unix/misc/gnome-open-url.sh +++ b/shell/source/unix/misc/gnome-open-url.sh @@ -1,6 +1,6 @@ #!/bin/sh -# use gnome-open utility coming with libgnome if available -gnome-open "$1" 2>/dev/null || "$0.bin" $1 +# use xdg-open or gnome-open if available +xdg-open "$1" 2>/dev/null || gnome-open "$1" 2>/dev/null || "$0.bin" $1 exit 0 diff --git a/shell/source/unix/misc/open-url.sh b/shell/source/unix/misc/open-url.sh index 5a70785f89d3..449af5915ce8 100755 --- a/shell/source/unix/misc/open-url.sh +++ b/shell/source/unix/misc/open-url.sh @@ -46,38 +46,48 @@ run_browser() { # special handling for mailto: uris if echo $1 | grep '^mailto:' > /dev/null; then + # check for xdg-email + mailer=`which xdg-email` + if [ ! -z "$mailer" ]; then + $mailer "$1" & + exit 0 + fi # check $MAILER variable if [ ! -z "$MAILER" ]; then $MAILER "$1" & exit 0 - else - # mozilla derivates may need -remote semantics - for i in thunderbird mozilla netscape; do - mailer=`which $i` - if [ ! -z "$mailer" ]; then - run_mozilla "$mailer" "$1" - exit 0 - fi - done - # handle all non mozilla mail clients below - # .. fi + # mozilla derivates may need -remote semantics + for i in thunderbird mozilla netscape; do + mailer=`which $i` + if [ ! -z "$mailer" ]; then + run_mozilla "$mailer" "$1" + exit 0 + fi + done + # handle all non mozilla mail clients below + # .. else + # check for xdg-open + browser=`which xdg-open` + if [ ! -z "$browser" ]; then + $browser "$1" & + exit 0 + fi # check $BROWSER variable if [ ! -z "$BROWSER" ]; then $BROWSER "$1" & exit 0 - else - # mozilla derivates may need -remote semantics - for i in firefox mozilla netscape; do - browser=`which $i` - if [ ! -z "$browser" ]; then - run_mozilla "$browser" "$1" - exit 0 - fi - done - # handle all non mozilla browers below - # .. fi + # mozilla derivates may need -remote semantics + for i in firefox mozilla netscape; do + browser=`which $i` + if [ ! -z "$browser" ]; then + run_mozilla "$browser" "$1" + exit 0 + fi + done + # handle all non mozilla browers below + # .. fi exit 1 -- cgit From f228a0e3a37c155947580f78b433f1ba2da5d16b Mon Sep 17 00:00:00 2001 From: "Herbert Duerr [hdu]" Date: Tue, 1 Jun 2010 12:54:48 +0200 Subject: #i100925# added msyahei as default font for CJK locales --- officecfg/registry/data/org/openoffice/VCL.xcu | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/officecfg/registry/data/org/openoffice/VCL.xcu b/officecfg/registry/data/org/openoffice/VCL.xcu index 36fd48ebf753..231d9bc1ccc2 100644 --- a/officecfg/registry/data/org/openoffice/VCL.xcu +++ b/officecfg/registry/data/org/openoffice/VCL.xcu @@ -547,22 +547,22 @@ - 方正宋体;MSung Light SC;SimSun;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正宋体;MSung Light SC;SimSun;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma 方正宋体;新宋体;NSimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced - 方正黑体;方正宋体;宋体;SimSun;黑体;文鼎PL中楷Uni;AR PL ZenKai Uni;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正黑体;方正宋体;宋体;SimSun;黑体;文鼎PL中楷Uni;AR PL ZenKai Uni;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 方正宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Song;FZSongYi;FZShuSong;NSimSun;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma 方正宋体;新宋体;NSimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced @@ -571,7 +571,7 @@ 方正宋体;新宋体;NSimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light SC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced - 方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Andale Sans UI;ZYSong18030;AR PL SungtiL GB;AR PL KaitiM GB;SimSun;Arial Unicode MS;Fangsong;Hei;Song;Kai;Ming;gnu-unifont;Interface User;WarpSans;Geneva;Tahoma;MS Sans Serif;Helv;Dialog;Albany AMT;Albany;Lucida;Arial;Nimbus Sans L;Helvetica;Charcoal;Chicago;Arial;Helmet;Interface System;Sans Serif + 方正宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Andale Sans UI;ZYSong18030;AR PL SungtiL GB;AR PL KaitiM GB;SimSun;Arial Unicode MS;Fangsong;Hei;Song;Kai;Ming;gnu-unifont;Interface User;WarpSans;Geneva;Tahoma;MS Sans Serif;Helv;Dialog;Albany AMT;Albany;Lucida;Arial;Nimbus Sans L;Helvetica;Charcoal;Chicago;Arial;Helmet;Interface System;Sans Serif @@ -579,19 +579,19 @@ 方正明體;細明體;MingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced - 方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma 方正黑体;新細明體;PMingLiU;文鼎PL中楷Uni;AR PL ZenKai Uni;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正明體;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正明體;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma 方正明體;細明體;MingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced @@ -600,7 +600,7 @@ 方正明體;細明體;MingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced - 方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Andale Sans UI;AR PL Mingti2L Big5;AR PL KaitiM Big5;Kai;Arial Unicode MS;Ming;gnu-unifont;Interface User;WarpSans;Geneva;Tahoma;MS Sans Serif;Helv;Dialog;Albany AMT;Albany;Lucida;Arial;Nimbus Sans L;Helvetica;Charcoal;Chicago;Arial;Helmet;Interface System;Sans Serif + 微软雅黑;方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Andale Sans UI;AR PL Mingti2L Big5;AR PL KaitiM Big5;Kai;Arial Unicode MS;Ming;gnu-unifont;Interface User;WarpSans;Geneva;Tahoma;MS Sans Serif;Helv;Dialog;Albany AMT;Albany;Lucida;Arial;Nimbus Sans L;Helvetica;Charcoal;Chicago;Arial;Helmet;Interface System;Sans Serif @@ -608,16 +608,16 @@ 方正明體;細明體;MingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced - 方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - FZHeiTi;方正明體;新細明體;PMingLiU;文鼎PL中楷Uni;AR PL ZenKai Uni;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;FZHeiTi;方正明體;新細明體;PMingLiU;文鼎PL中楷Uni;AR PL ZenKai Uni;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正明體;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正明體;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma 方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;MingLiU;Ming;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma @@ -629,7 +629,7 @@ 方正明體;細明體;MingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced - 方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Andale Sans UI;AR PL Mingti2L Big5;AR PL KaitiM Big5;Kai;Arial Unicode MS;Ming;gnu-unifont;Interface User;WarpSans;Geneva;Tahoma;MS Sans Serif;Helv;Dialog;Albany AMT;Albany;Lucida;Arial;Nimbus Sans L;Helvetica;Charcoal;Chicago;Arial;Helmet;Interface System;Sans Serif + 微软雅黑;方正明體;新細明體;PMingLiU;文鼎PL細上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Andale Sans UI;AR PL Mingti2L Big5;AR PL KaitiM Big5;Kai;Arial Unicode MS;Ming;gnu-unifont;Interface User;WarpSans;Geneva;Tahoma;MS Sans Serif;Helv;Dialog;Albany AMT;Albany;Lucida;Arial;Nimbus Sans L;Helvetica;Charcoal;Chicago;Arial;Helmet;Interface System;Sans Serif @@ -637,19 +637,19 @@ 方正宋体;新宋体;NSimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced - 方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正黑体;方正宋体;宋体;SimSun;文鼎PL中楷Uni;AR PL ZenKai Uni;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正黑体;方正宋体;宋体;SimSun;文鼎PL中楷Uni;AR PL ZenKai Uni;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma - 方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma + 微软雅黑;方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Song;FZSongYi;FZShuSong;MSung Light TC;MingLiU;Ming;PMingLiU;Andale Sans UI;Arial Unicode MS;Lucida Sans Unicode;Tahoma 方正宋体;新宋体;NSimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced @@ -658,7 +658,7 @@ 方正宋体;新宋体;NSimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;MSung Light TC;Cumberland AMT;Cumberland;Courier New;Nimbus Mono L;Courier;Lucida Sans Typewriter;Lucida Typewriter;Monaco;Monospaced - 方正宋体;宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Andale Sans UI;ZYSong18030;AR PL SungtiL GB;AR PL KaitiM GB;SimSun;Arial Unicode MS;Fangsong;Hei;Song;Kai;Ming;gnu-unifont;Interface User;WarpSans;Geneva;Tahoma;MS Sans Serif;Helv;Dialog;Albany AMT;Albany;Lucida;Arial;Nimbus Sans L;Helvetica;Charcoal;Chicago;Arial;Helmet;Interface System;Sans Serif + 方正宋体;SimSun;文鼎PL细上海宋Uni;AR PL ShanHeiSun Uni;文鼎PL新宋;AR PL New Sung;Andale Sans UI;ZYSong18030;AR PL SungtiL GB;AR PL KaitiM GB;SimSun;Arial Unicode MS;Fangsong;Hei;Song;Kai;Ming;gnu-unifont;Interface User;WarpSans;Geneva;Tahoma;MS Sans Serif;Helv;Dialog;Albany AMT;Albany;Lucida;Arial;Nimbus Sans L;Helvetica;Charcoal;Chicago;Arial;Helmet;Interface System;Sans Serif -- cgit From ea38408294e1a781bc31238e8c0b87714f7214d3 Mon Sep 17 00:00:00 2001 From: Frank Peters Date: Tue, 1 Jun 2010 14:35:19 +0200 Subject: #i111721# --- readlicense_oo/util/makefile.pmk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readlicense_oo/util/makefile.pmk b/readlicense_oo/util/makefile.pmk index 8aee1ce3b69a..30e07779457b 100755 --- a/readlicense_oo/util/makefile.pmk +++ b/readlicense_oo/util/makefile.pmk @@ -53,7 +53,7 @@ $(COMMONMISC)$/readme.dtd : ..$/readme.dtd virtual : $(MERGEDXRM) $(COMMONMISC)$/readme.dtd $(PRJ)$/docs/readme.xsl $(MISC)$/readme_text.xsl : virtual - $(SED) 's#method="html".*>#method="text"/>#' < ..$/readme.xsl > $@ + $(SED) '' < ..$/readme.xsl > $@ $(MISC)$/$(GUI)$/$(eq,$(GUI),WNT readme README)_%.html : 'virtual' @@-$(MKDIRHIER) $(@:d) @@ -79,6 +79,7 @@ $(SYSTEXTDOCS) : $(MISC)$/readme_text.xsl --stringparam os1 $(OS) --stringparam gui1 $(GUI) --stringparam com1 $(COM) \ --stringparam cp1 $(CPUNAME) --stringparam type text --stringparam lang1 $(@:b:s/readme_//:s/README_//) \ $< $(MERGEDXRM) + .IF "$(GUI)"=="UNX" chmod g+w $(MISC)$/$(GUI) .ENDIF # "$(GUI)"=="UNX" -- cgit From 7ef48b304fe975501f32f8261ee620ebbedc90e5 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 1 Jun 2010 16:20:28 +0200 Subject: jl152 #i77196# fix compiler warnings --- desktop/source/deployment/gui/dp_gui_updatedata.hxx | 2 +- desktop/source/deployment/gui/dp_gui_updatedialog.cxx | 11 +++++------ desktop/source/deployment/manager/dp_extensionmanager.cxx | 2 +- desktop/util/makefile.mk | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui_updatedata.hxx b/desktop/source/deployment/gui/dp_gui_updatedata.hxx index 7228982da518..76eb8af31e8e 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedata.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedata.hxx @@ -47,7 +47,7 @@ namespace dp_gui { struct UpdateData { UpdateData( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > const & aExt): - aInstalledPackage(aExt), bIsShared(false) {}; + bIsShared(false), aInstalledPackage(aExt){}; //When entries added to the listbox then there can be one for the user update and one //for the shared update. However, both list entries will contain the same UpdateData. diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index d121ad976a06..a27f04326b25 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -280,7 +280,6 @@ private: dp_gui::UpdateData const & data, ::rtl::OUString const & version = ::rtl::OUString()) const; void prepareUpdateData( - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > const & package, ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & updateInfo, UpdateDialog::DisabledUpdate & out_du, dp_gui::UpdateData & out_data) const; @@ -415,7 +414,7 @@ void UpdateDialog::Thread::execute() for (Map::iterator i(map.begin()); i != map.end(); ++i) { //determine if online updates meet the requirements - prepareUpdateData(i->second.package, i->second.info, + prepareUpdateData(i->second.info, i->second.disableUpdate, i->second.updateData); //determine if the update is installed in the user or shared repository @@ -613,7 +612,6 @@ void UpdateDialog::Thread::getOwnUpdateInformation( /** out_data will only be filled if all dependencies are ok. */ void UpdateDialog::Thread::prepareUpdateData( - css::uno::Reference< css::deployment::XPackage > const & package, css::uno::Reference< css::xml::dom::XNode > const & updateInfo, UpdateDialog::DisabledUpdate & out_du, dp_gui::UpdateData & out_data) const @@ -648,21 +646,22 @@ bool UpdateDialog::Thread::update( UpdateDialog::DisabledUpdate const & du, dp_gui::UpdateData const & data) const { + bool ret = false; if (du.unsatisfiedDependencies.getLength() == 0) { vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { m_dialog.addEnabledUpdate(getUpdateDisplayString(data), data); } - return !m_stop; + ret = !m_stop; } else { vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { m_dialog.addDisabledUpdate(du); } - return !m_stop; + ret = !m_stop; } - return true; + return ret; } // UpdateDialog ---------------------------------------------------------- diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 251e70a19ce6..24b5712ebd30 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -251,7 +251,7 @@ void ExtensionManager::addExtensionsToMap( ::std::list > ExtensionManager::getExtensionsWithSameId( OUString const & identifier, OUString const & fileName, - Reference< ucb::XCommandEnvironment> const & xCmdEnv) + Reference< ucb::XCommandEnvironment> const & /*xCmdEnv*/) { ::std::list > extensionList; diff --git a/desktop/util/makefile.mk b/desktop/util/makefile.mk index 47885dfd6b73..8cf03f157254 100644 --- a/desktop/util/makefile.mk +++ b/desktop/util/makefile.mk @@ -108,7 +108,7 @@ APP5RPATH=BRAND APP5OBJS=$(OBJ)$/copyright_ascii_ooo.obj $(OBJ)$/main.obj APP5STDLIBS = $(SALLIB) $(SOFFICELIB) .IF "$(OS)" == "LINUX" -APP5STDLIBS+= -lXext +APP5STDLIBS+= -lXext -lX11 #APP5STDLIBS+= -lXext -lSM -lICE .ENDIF # LINUX -- cgit From ce6749f139440c79b207e26a522a177f4c2594d0 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 1 Jun 2010 17:15:33 +0200 Subject: CWS mba33issues01: #i107576#: create OwnLightClient only if there isn't a client already --- svx/source/svdraw/svdoole2.cxx | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 15c2ecb9c564..483c247c064f 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -1832,11 +1832,7 @@ void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract // if the object needs recompose on resize // the client site should be created before the resize will take place // check whether there is no client site and create it if necessary - if ( !SfxInPlaceClient::GetClient( dynamic_cast(pModel->GetPersist()), xObjRef.GetObject() ) - && !( mpImpl->pLightClient && xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) ) ) - { - AddOwnLightClient(); - } + AddOwnLightClient(); } } @@ -2197,26 +2193,32 @@ sal_Bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScal sal_Bool SdrOle2Obj::AddOwnLightClient() { // The Own Light Client must be registered in object only using this method! - Connect(); - - if ( xObjRef.is() && mpImpl->pLightClient ) + if ( !SfxInPlaceClient::GetClient( dynamic_cast(pModel->GetPersist()), xObjRef.GetObject() ) + && !( mpImpl->pLightClient && xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) ) ) { - Fraction aScaleWidth; - Fraction aScaleHeight; - Size aObjAreaSize; - if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) + Connect(); + + if ( xObjRef.is() && mpImpl->pLightClient ) { - mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight ); - try { - xObjRef->setClientSite( mpImpl->pLightClient ); - return sal_True; - } catch( uno::Exception& ) - {} + Fraction aScaleWidth; + Fraction aScaleHeight; + Size aObjAreaSize; + if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) + { + mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight ); + try { + xObjRef->setClientSite( mpImpl->pLightClient ); + return sal_True; + } catch( uno::Exception& ) + {} + } + } + return sal_False; } - return sal_False; + return sal_True; } ////////////////////////////////////////////////////////////////////////////// -- cgit From a340fb93fa310e0eb82c3bd5ac7d5b9a3b22ce70 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 2 Jun 2010 08:50:04 +0200 Subject: jl152#i77196# Enable showing license during startup check, better handling of extensions with unaccepted license --- desktop/source/app/check_ext_deps.cxx | 49 +++++++++++++++---- desktop/source/deployment/gui/dp_gui.hrc | 2 + desktop/source/deployment/gui/dp_gui_dialog.src | 10 ++++ desktop/source/deployment/gui/dp_gui_dialog2.cxx | 44 ++++++++++++----- desktop/source/deployment/gui/dp_gui_dialog2.hxx | 10 ++-- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 56 +++++++++++++++++++++- .../deployment/gui/dp_gui_extensioncmdqueue.hxx | 1 + .../source/deployment/gui/dp_gui_extlistbox.cxx | 15 +++++- .../source/deployment/gui/dp_gui_extlistbox.hxx | 4 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 49 ++++++++----------- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 10 +--- desktop/source/deployment/manager/dp_manager.cxx | 2 +- 12 files changed, 186 insertions(+), 66 deletions(-) mode change 100644 => 100755 desktop/source/app/check_ext_deps.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui.hrc mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_dialog.src mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_dialog2.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_dialog2.hxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_extlistbox.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_extlistbox.hxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_theextmgr.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_theextmgr.hxx diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx old mode 100644 new mode 100755 index e9c71bc1ea36..ebdc9ccdf51e --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -39,6 +39,7 @@ #include "vcl/timer.hxx" #include +#include "toolkit/helper/vclunohelper.hxx" #include #include @@ -48,10 +49,14 @@ #include #include "com/sun/star/deployment/XPackage.hpp" #include "com/sun/star/deployment/ExtensionManager.hpp" +#include "com/sun/star/deployment/LicenseException.hpp" +#include "com/sun/star/deployment/ui/LicenseDialog.hpp" #include #include #include +#include #include +#include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp" #include #include "app.hxx" @@ -132,21 +137,47 @@ Reference SilentCommandEnv::getProgressHandler() void SilentCommandEnv::handle( Reference< task::XInteractionRequest> const & xRequest ) throw (uno::RuntimeException) { + deployment::LicenseException licExc; + uno::Any request( xRequest->getRequest() ); + bool bApprove = true; + + if ( request >>= licExc ) + { + uno::Reference< uno::XComponentContext > xContext = comphelper_getProcessComponentContext(); + uno::Reference< ui::dialogs::XExecutableDialog > xDialog( + deployment::ui::LicenseDialog::create( + xContext, VCLUnoHelper::GetInterface( NULL ), + licExc.ExtensionName, licExc.Text ) ); + sal_Int16 res = xDialog->execute(); + if ( res == ui::dialogs::ExecutableDialogResults::CANCEL ) + bApprove = false; + else if ( res == ui::dialogs::ExecutableDialogResults::OK ) + bApprove = true; + else + { + OSL_ASSERT(0); + } + } // We approve everything here - uno::Sequence< Reference< task::XInteractionContinuation > > conts( - xRequest->getContinuations() ); - Reference< task::XInteractionContinuation > const * pConts = - conts.getConstArray(); + uno::Sequence< Reference< task::XInteractionContinuation > > conts( xRequest->getContinuations() ); + Reference< task::XInteractionContinuation > const * pConts = conts.getConstArray(); sal_Int32 len = conts.getLength(); + for ( sal_Int32 pos = 0; pos < len; ++pos ) { - - Reference< task::XInteractionApprove > xInteractionApprove( - pConts[ pos ], uno::UNO_QUERY ); - if (xInteractionApprove.is()) { - xInteractionApprove->select(); + if ( bApprove ) + { + uno::Reference< task::XInteractionApprove > xInteractionApprove( pConts[ pos ], uno::UNO_QUERY ); + if ( xInteractionApprove.is() ) + xInteractionApprove->select(); + } + else + { + uno::Reference< task::XInteractionAbort > xInteractionAbort( pConts[ pos ], uno::UNO_QUERY ); + if ( xInteractionAbort.is() ) + xInteractionAbort->select(); } } } diff --git a/desktop/source/deployment/gui/dp_gui.hrc b/desktop/source/deployment/gui/dp_gui.hrc old mode 100644 new mode 100755 index 022141976f55..5f52b042edf3 --- a/desktop/source/deployment/gui/dp_gui.hrc +++ b/desktop/source/deployment/gui/dp_gui.hrc @@ -153,6 +153,7 @@ #define RID_STR_REMOVING_PACKAGES (RID_DEPLOYMENT_GUI_START+86) #define RID_STR_ENABLING_PACKAGES (RID_DEPLOYMENT_GUI_START+87) #define RID_STR_DISABLING_PACKAGES (RID_DEPLOYMENT_GUI_START+88) +#define RID_STR_ACCEPT_LICENSE (RID_DEPLOYMENT_GUI_START+89) #define RID_STR_INSTALL_FOR_ALL (RID_DEPLOYMENT_GUI_START+90) #define RID_STR_INSTALL_FOR_ME (RID_DEPLOYMENT_GUI_START+91) @@ -161,6 +162,7 @@ #define RID_STR_EXIT_BTN (RID_DEPLOYMENT_GUI_START+94) #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 WARNINGBOX_CONCURRENTINSTANCE (RID_DEPLOYMENT_GUI_START+100) diff --git a/desktop/source/deployment/gui/dp_gui_dialog.src b/desktop/source/deployment/gui/dp_gui_dialog.src old mode 100644 new mode 100755 index f9d9c0e011c6..15823288ee20 --- a/desktop/source/deployment/gui/dp_gui_dialog.src +++ b/desktop/source/deployment/gui/dp_gui_dialog.src @@ -72,6 +72,11 @@ String RID_STR_DISABLING_PACKAGES Text [ en-US ] = "Disabling %EXTENSION_NAME"; }; +String RID_STR_ACCEPT_LICENSE +{ + Text [ en-US ] = "Accept license for %EXTENSION_NAME"; +}; + String RID_STR_INSTALL_FOR_ALL { Text [ en-US ] = "~For all users"; @@ -109,6 +114,11 @@ String RID_STR_ERROR_MISSING_DEPENDENCIES Text [ en-US ] = "The extension cannot be enabled as the following system dependencies are not fulfilled:"; }; +String RID_STR_ERROR_MISSING_LICENSE +{ + Text [ en-US ] = "This extension is disabled because you haven't accepted the license yet.\n"; +}; + // Dialog layout // --------------------------------------------------- // row 1 | multi line edit diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx old mode 100644 new mode 100755 index 35634d5ef851..d34001393ba7 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -37,6 +37,7 @@ #include "dp_gui_extlistbox.hxx" #include "dp_gui_shared.hxx" #include "dp_gui_theextmgr.hxx" +#include "dp_gui_extensioncmdqueue.hxx" #include "dp_misc.h" #include "dp_identifier.hxx" @@ -291,7 +292,8 @@ void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_ENABLE ); } - if ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) + if ( ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) + && !pEntry->m_bMissingLic ) m_pEnableBtn->Hide(); else { @@ -511,9 +513,14 @@ IMPL_LINK( ExtBoxWithBtns_Impl, HandleEnableBtn, void*, EMPTYARG ) if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND ) { TEntry_Impl pEntry = GetEntryData( nActive ); - const bool bEnable( pEntry->m_eState != REGISTERED ); - m_pParent->enablePackage( pEntry->m_xPackage, bEnable ); + if ( pEntry->m_bMissingLic ) + m_pParent->acceptLicense( pEntry->m_xPackage ); + else + { + const bool bEnable( pEntry->m_eState != REGISTERED ); + m_pParent->enablePackage( pEntry->m_xPackage, bEnable ); + } } return 1; @@ -760,10 +767,11 @@ void ExtMgrDialog::setGetExtensionsURL( const ::rtl::OUString &rURL ) } //------------------------------------------------------------------------------ -long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage ) +long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage, + bool bLicenseMissing ) { m_aUpdateBtn.Enable( true ); - return m_pExtensionBox->addEntry( xPackage ); + return m_pExtensionBox->addEntry( xPackage, bLicenseMissing ); } //------------------------------------------------------------------------------ @@ -810,7 +818,7 @@ bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > & return false; } - m_pManager->enablePackage( xPackage, bEnable ); + m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable ); return true; } @@ -830,7 +838,7 @@ bool ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > & if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) ) return false; - m_pManager->removePackage( xPackage ); + m_pManager->getCmdQueue()->removeExtension( xPackage ); return true; } @@ -851,7 +859,18 @@ bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > & std::vector< css::uno::Reference< css::deployment::XPackage > > vEntries; vEntries.push_back(extension); - m_pManager->updatePackages( vEntries ); + m_pManager->getCmdQueue()->checkForUpdates( vEntries ); + + return true; +} + +//------------------------------------------------------------------------------ +bool ExtMgrDialog::acceptLicense( const uno::Reference< deployment::XPackage > &xPackage ) +{ + if ( !xPackage.is() ) + return false; + + m_pManager->getCmdQueue()->acceptLicense( xPackage ); return true; } @@ -1300,10 +1319,11 @@ UpdateRequiredDialog::~UpdateRequiredDialog() } //------------------------------------------------------------------------------ -long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage ) +long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage, + bool bLicenseMissing ) { // We will only add entries to the list with unsatisfied dependencies - if ( !checkDependencies( xPackage ) ) + if ( !bLicenseMissing && !checkDependencies( xPackage ) ) { m_bHasLockedEntries |= m_pManager->isReadOnly( xPackage ); m_aUpdateBtn.Enable( true ); @@ -1335,7 +1355,7 @@ void UpdateRequiredDialog::checkEntries() bool UpdateRequiredDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, bool bEnable ) { - m_pManager->enablePackage( xPackage, bEnable ); + m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable ); return true; } @@ -1462,7 +1482,7 @@ IMPL_LINK( UpdateRequiredDialog, HandleUpdateBtn, void*, EMPTYARG ) aGuard.clear(); - m_pManager->updatePackages( vUpdateEntries ); + m_pManager->getCmdQueue()->checkForUpdates( vUpdateEntries ); return 1; } diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx old mode 100644 new mode 100755 index 4c99d64740db..f0a85cce98c0 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -81,7 +81,8 @@ public: virtual void updateProgress( const long nProgress ) = 0; virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0; - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0; + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, + bool bLicenseMissing = false ) = 0; virtual void prepareChecking() = 0; virtual void checkEntries() = 0; @@ -157,11 +158,13 @@ public: virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void setGetExtensionsURL( const ::rtl::OUString &rURL ); - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &); + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, + bool bLicenseMissing = false ); bool enablePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); bool removePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); bool updatePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + bool acceptLicense(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); virtual void prepareChecking(); virtual void checkEntries(); @@ -228,7 +231,8 @@ public: virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void selectEntry( long nPos ); - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & ); + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, + bool bLicenseMissing = false ); bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx old mode 100644 new mode 100755 index 954f32f4c9c6..e3c8b2bfb46b --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -195,7 +195,7 @@ public: //------------------------------------------------------------------------------ struct ExtensionCmd { - enum E_CMD_TYPE { ADD, ENABLE, DISABLE, REMOVE, CHECK_FOR_UPDATES }; + enum E_CMD_TYPE { ADD, ENABLE, DISABLE, REMOVE, CHECK_FOR_UPDATES, ACCEPT_LICENSE }; E_CMD_TYPE m_eCmdType; bool m_bWarnUser; @@ -241,6 +241,7 @@ public: void enableExtension( const uno::Reference< deployment::XPackage > &rPackage, const bool bEnable ); void checkForUpdates( const std::vector > &vExtensionList ); + void acceptLicense( const uno::Reference< deployment::XPackage > &rPackage ); void stop(); bool isBusy(); @@ -267,6 +268,8 @@ private: void _disableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, const uno::Reference< deployment::XPackage > &xPackage ); void _checkForUpdates( const std::vector > &vExtensionList ); + void _acceptLicense( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, + const uno::Reference< deployment::XPackage > &xPackage ); enum Input { NONE, START, STOP }; @@ -281,6 +284,7 @@ private: const OUString m_sAddingPackages; const OUString m_sRemovingPackages; const OUString m_sDefaultCmd; + const OUString m_sAcceptLicense; osl::Condition m_wakeup; osl::Mutex m_mutex; Input m_eInput; @@ -626,6 +630,7 @@ ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper, m_sAddingPackages( DialogHelper::getResourceString( RID_STR_ADDING_PACKAGES ) ), m_sRemovingPackages( DialogHelper::getResourceString( RID_STR_REMOVING_PACKAGES ) ), m_sDefaultCmd( DialogHelper::getResourceString( RID_STR_ADD_PACKAGES ) ), + m_sAcceptLicense( DialogHelper::getResourceString( RID_STR_ACCEPT_LICENSE ) ), m_eInput( NONE ), m_bTerminated( false ), m_bStopped( false ), @@ -674,6 +679,25 @@ void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deploymen } } +//------------------------------------------------------------------------------ +void ExtensionCmdQueue::Thread::acceptLicense( const uno::Reference< deployment::XPackage > &rPackage ) +{ + ::osl::MutexGuard aGuard( m_mutex ); + + //If someone called stop then we do not remove the extension -> game over! + if ( m_bStopped ) + return; + + if ( rPackage.is() ) + { + TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ACCEPT_LICENSE, rPackage ) ); + + m_queue.push( pEntry ); + m_eInput = START; + m_wakeup.set(); + } +} + //------------------------------------------------------------------------------ void ExtensionCmdQueue::Thread::enableExtension( const uno::Reference< deployment::XPackage > &rPackage, const bool bEnable ) @@ -815,6 +839,9 @@ void ExtensionCmdQueue::Thread::execute() case ExtensionCmd::CHECK_FOR_UPDATES : _checkForUpdates( pEntry->m_vExtensionList ); break; + case ExtensionCmd::ACCEPT_LICENSE : + _acceptLicense( currentCmdEnv, pEntry->m_xPackage ); + break; } } //catch ( deployment::DeploymentException &) @@ -1065,6 +1092,28 @@ void ExtensionCmdQueue::Thread::_disableExtension( ::rtl::Reference< ProgressCmd {} } +//------------------------------------------------------------------------------ +void ExtensionCmdQueue::Thread::_acceptLicense( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, + const uno::Reference< deployment::XPackage > &xPackage ) +{ + if ( !xPackage.is() ) + return; + + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); + OUString sTitle = searchAndReplaceAll( m_sAcceptLicense, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); + rCmdEnv->progressSection( sTitle, xAbortChannel ); + + try + { + xExtMgr->checkPrerequisitesAndEnable( xPackage, xAbortChannel, rCmdEnv.get() ); + if ( m_pDialogHelper ) + m_pDialogHelper->updatePackageInfo( xPackage ); + } + catch ( ::ucb::CommandAbortedException & ) + {} +} + //------------------------------------------------------------------------------ void ExtensionCmdQueue::Thread::onTerminated() { @@ -1131,6 +1180,11 @@ void ExtensionCmdQueue::checkForUpdates( const std::vectorcheckForUpdates( vExtensionList ); } +void ExtensionCmdQueue::acceptLicense( const uno::Reference< deployment::XPackage > &rPackage ) +{ + m_thread->acceptLicense( rPackage ); +} + void ExtensionCmdQueue::stop() { m_thread->stop(); diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx old mode 100644 new mode 100755 index cfadad84cedc..29cee4292102 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx @@ -85,6 +85,7 @@ public: const bool bEnable ); void checkForUpdates(const std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > &vList ); + void acceptLicense( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); /** This call does not block. It signals the internal thread that it should install the remaining extensions and then terminate. diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx old mode 100644 new mode 100755 index dbb5c93cd853..d76764fa1e53 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -66,6 +66,7 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_bChecked( false ), m_bMissingDeps( false ), m_bHasButtons( false ), + m_bMissingLic( false ), m_eState( eState ), m_pPublisher( NULL ), m_xPackage( xPackage ) @@ -372,6 +373,8 @@ void ExtensionBox_Impl::CalcActiveHeight( const long nPos ) aSize.Height() = 10000; rtl::OUString aText( m_vEntries[ nPos ]->m_sErrorText ); + if ( aText.getLength() ) + aText += OUSTR("\n"); aText += m_vEntries[ nPos ]->m_sDescription; Rectangle aRect = GetTextRect( Rectangle( Point(), aSize ), aText, @@ -634,7 +637,7 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr else DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aSharedImageHC : m_aSharedImage ); } - if ( ( pEntry->m_eState == AMBIGUOUS ) || pEntry->m_bMissingDeps ) + if ( ( pEntry->m_eState == AMBIGUOUS ) || pEntry->m_bMissingDeps || pEntry->m_bMissingLic ) { aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SPACE_BETWEEN + 2*SMALL_ICON_SIZE), TOP_OFFSET ); DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aWarningImageHC : m_aWarningImage ); @@ -952,7 +955,8 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl pEntry, const long nStar } //------------------------------------------------------------------------------ -long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage ) +long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage, + bool bLicenseMissing ) { long nPos = 0; PackageState eState = m_pManager->getPackageState( xPackage ); @@ -982,6 +986,10 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & pEntry->m_bUser = xPackage->getRepositoryName().equals( USER_PACKAGE_MANAGER ); pEntry->m_bShared = xPackage->getRepositoryName().equals( SHARED_PACKAGE_MANAGER ); pEntry->m_bNew = m_bInCheckMode; + pEntry->m_bMissingLic = bLicenseMissing; + + if ( bLicenseMissing ) + pEntry->m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_MISSING_LICENSE ); //access to m_nActive must be guarded if ( !m_bInCheckMode && m_bHasActive && ( m_nActive >= nPos ) ) @@ -1017,6 +1025,9 @@ void ExtensionBox_Impl::updateEntry( const uno::Reference< deployment::XPackage else (*iIndex)->m_sErrorText = String(); + if ( eState == REGISTERED ) + (*iIndex)->m_bMissingLic = false; + if ( IsReallyVisible() ) Invalidate(); break; diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx old mode 100644 new mode 100755 index 0f56d022492b..762f50296690 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -73,6 +73,7 @@ struct Entry_Impl bool m_bChecked :1; bool m_bMissingDeps :1; bool m_bHasButtons :1; + bool m_bMissingLic :1; PackageState m_eState; String m_sTitle; String m_sVersion; @@ -205,7 +206,8 @@ public: //----------------- virtual void selectEntry( const long nPos ); - long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, + bool bLicenseMissing = false ); void updateEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void removeEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx old mode 100644 new mode 100755 index fdbc1974f61c..7bfcc79480b3 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -67,7 +67,8 @@ TheExtensionManager::TheExtensionManager( Window *pParent, m_xContext( xContext ), m_pParent( pParent ), m_pExtMgrDialog( NULL ), - m_pUpdReqDialog( NULL ) + m_pUpdReqDialog( NULL ), + m_pExecuteCmdQueue( NULL ) { m_xExtensionManager = deployment::ExtensionManager::get( xContext ); m_xExtensionManager->addModifyListener( this ); @@ -117,6 +118,8 @@ TheExtensionManager::~TheExtensionManager() delete m_pUpdReqDialog; if ( m_pExtMgrDialog ) delete m_pExtMgrDialog; + if ( m_pExecuteCmdQueue ) + delete m_pExecuteCmdQueue; } //------------------------------------------------------------------------------ @@ -129,14 +132,16 @@ void TheExtensionManager::createDialog( const bool bCreateUpdDlg ) if ( !m_pUpdReqDialog ) { m_pUpdReqDialog = new UpdateRequiredDialog( NULL, this ); - m_pExecuteCmdQueue.reset( new ExtensionCmdQueue( (DialogHelper*) m_pUpdReqDialog, this, m_xContext ) ); + delete m_pExecuteCmdQueue; + m_pExecuteCmdQueue = new ExtensionCmdQueue( (DialogHelper*) m_pUpdReqDialog, this, m_xContext ); createPackageList(); } } else if ( !m_pExtMgrDialog ) { m_pExtMgrDialog = new ExtMgrDialog( m_pParent, this ); - m_pExecuteCmdQueue.reset( new ExtensionCmdQueue( (DialogHelper*) m_pExtMgrDialog, this, m_xContext ) ); + delete m_pExecuteCmdQueue; + m_pExecuteCmdQueue = new ExtensionCmdQueue( (DialogHelper*) m_pExtMgrDialog, this, m_xContext ); m_pExtMgrDialog->setGetExtensionsURL( m_sGetExtensionsURL ); createPackageList(); } @@ -231,32 +236,6 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare return true; } -//------------------------------------------------------------------------------ -bool TheExtensionManager::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, - bool bEnable ) -{ - m_pExecuteCmdQueue->enableExtension( xPackage, bEnable ); - - return true; -} - -//------------------------------------------------------------------------------ -bool TheExtensionManager::removePackage( const uno::Reference< deployment::XPackage > &xPackage ) -{ - m_pExecuteCmdQueue->removeExtension( xPackage ); - - return true; -} - -//------------------------------------------------------------------------------ -bool TheExtensionManager::updatePackages( - const std::vector< uno::Reference< deployment::XPackage > > &vList ) -{ - m_pExecuteCmdQueue->checkForUpdates( vList ); - - return true; -} - //------------------------------------------------------------------------------ bool TheExtensionManager::installPackage( const OUString &rPackageURL, bool bWarnUser ) { @@ -343,6 +322,18 @@ void TheExtensionManager::createPackageList() } } } + + uno::Sequence< uno::Reference< deployment::XPackage > > xNoLicPackages; + xNoLicPackages = m_xExtensionManager->getExtensionsWithUnacceptedLicenses( SHARED_PACKAGE_MANAGER, + uno::Reference< ucb::XCommandEnvironment >() ); + for ( sal_Int32 i = 0; i < xNoLicPackages.getLength(); ++i ) + { + uno::Reference< deployment::XPackage > xPackage = xNoLicPackages[i]; + if ( xPackage.is() ) + { + getDialogHelper()->addPackageToList( xPackage, true ); + } + } } //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx old mode 100644 new mode 100755 index da8d3c083f42..094e25e249b7 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -61,11 +61,10 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xNameAccessNodes; - ::std::auto_ptr< ExtensionCmdQueue > m_pExecuteCmdQueue; - Window *m_pParent; ExtMgrDialog *m_pExtMgrDialog; UpdateRequiredDialog *m_pUpdReqDialog; + ExtensionCmdQueue *m_pExecuteCmdQueue; ::rtl::OUString m_sGetExtensionsURL; @@ -83,6 +82,7 @@ public: Dialog* getDialog() { return m_pExtMgrDialog ? (Dialog*) m_pExtMgrDialog : (Dialog*) m_pUpdReqDialog; } DialogHelper* getDialogHelper() { return m_pExtMgrDialog ? (DialogHelper*) m_pExtMgrDialog : (DialogHelper*) m_pUpdReqDialog; } + ExtensionCmdQueue* getCmdQueue() const { return m_pExecuteCmdQueue; } void SetText( const ::rtl::OUString &rTitle ); void Show(); @@ -92,12 +92,6 @@ public: //----------------- bool checkUpdates( bool showUpdateOnly, bool parentVisible ); - bool updatePackages( const std::vector< ::com::sun::star::uno::Reference< - ::com::sun::star::deployment::XPackage > > &vList ); - - bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - bool bEnable ); - bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); bool installPackage( const ::rtl::OUString &rPackageURL, bool bWarnUser = false ); bool queryTermination(); diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 7844e11b0651..409cf2674184 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -927,7 +927,7 @@ void PackageManagerImpl::removePackage( //the flag file it will then recognize, that the extension was //deleted and can then update the extnesion database of the shared //extensions in the user installation. - if (! m_readOnly && !xPackage->isRemoved() && m_context.equals(OUSTR("shared"))) + if ( xPackage.is() && !m_readOnly && !xPackage->isRemoved() && m_context.equals(OUSTR("shared"))) { ActivePackages::Data val; m_activePackagesDB->get( & val, id, fileName); -- cgit From 057d47a436bab4ba71a101f7d2ad21cabae0cd20 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 2 Jun 2010 09:31:52 +0200 Subject: jl152#i77196# better handling of extensions with unaccepted license --- desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index d76764fa1e53..24b47aa223e3 100755 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -1020,14 +1020,14 @@ void ExtensionBox_Impl::updateEntry( const uno::Reference< deployment::XPackage (*iIndex)->m_sVersion = xPackage->getVersion(); (*iIndex)->m_sDescription = xPackage->getDescription(); + if ( eState == REGISTERED ) + (*iIndex)->m_bMissingLic = false; + if ( eState == AMBIGUOUS ) (*iIndex)->m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS ); - else + else if ( ! (*iIndex)->m_bMissingLic ) (*iIndex)->m_sErrorText = String(); - if ( eState == REGISTERED ) - (*iIndex)->m_bMissingLic = false; - if ( IsReallyVisible() ) Invalidate(); break; -- cgit From d90913a6131cd829292e7f13cc6c9b28120a5e43 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Wed, 2 Jun 2010 10:16:03 +0200 Subject: CWS mba33issues01: #i112021#: remove obsolete code --- sfx2/source/dialog/about.cxx | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/sfx2/source/dialog/about.cxx b/sfx2/source/dialog/about.cxx index 66d4146d9e62..02f05c773f73 100644 --- a/sfx2/source/dialog/about.cxx +++ b/sfx2/source/dialog/about.cxx @@ -130,20 +130,6 @@ AboutDialog::AboutDialog( Window* pParent, const ResId& rId, const String& rVerS rtl::OUString sProduct; utl::ConfigManager::GetDirectConfigProperty(utl::ConfigManager::PRODUCTNAME) >>= sProduct; - if ( sProduct.equals( rtl::OUString::createFromAscii("StarOffice") ) || - sProduct.equals( rtl::OUString::createFromAscii("StarSuite") ) ) - { - // --> PB 2004-11-18 #118455# new copyright text (only in french version show a french text) - ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); - ::rtl::OUString sFrenchLang( DEFINE_CONST_OUSTRING( "fr" ) ); - if ( aLocale.Language.equals( sFrenchLang ) ) - { - String sNewCopyrightText( ResId( ABOUT_STR_FRENCH_COPYRIGHT, *rId.GetResMgr() ) ); - aCopyrightText.SetText( sNewCopyrightText ); - } - // <-- - } - // load image from module path rtl::OUString aAbouts( RTL_CONSTASCII_USTRINGPARAM( ABOUT_BITMAP_STRINGLIST ) ); bool bLoaded = false; @@ -289,22 +275,6 @@ AboutDialog::AboutDialog( Window* pParent, const ResId& rId, const String& rVerS // explizite Help-Id SetHelpId( SID_ABOUT ); - - //#112429# replace occurences of "StarOffice" in the "StarSuite" version - String sCopyright( aCopyrightText.GetText() ); - if(sProduct.equals(rtl::OUString::createFromAscii("StarSuite"))) - { - String sSO(String::CreateFromAscii("StarOffice")); - sCopyright.SearchAndReplaceAll(sSO, sProduct); - } - - String sNewYear( DEFINE_CONST_UNICODE("2005") ); - xub_StrLen nIdx = sCopyright.SearchAndReplace( DEFINE_CONST_UNICODE("2002"), sNewYear ); - if ( STRING_NOTFOUND == nIdx ) - nIdx = sCopyright.SearchAndReplace( DEFINE_CONST_UNICODE("2003"), sNewYear ); - if ( STRING_NOTFOUND == nIdx ) - nIdx = sCopyright.SearchAndReplace( DEFINE_CONST_UNICODE("2004"), sNewYear ); - aCopyrightText.SetText( sCopyright ); } // ----------------------------------------------------------------------- -- cgit From 04615ba86017896e0fb4bf951004ba2e4e22e6c9 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Thu, 3 Jun 2010 09:35:22 +0200 Subject: jl152#i77196# unopkg gui should sync repositories, too --- desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx | 6 ++++++ desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx | 1 + desktop/source/deployment/gui/dp_gui_service.cxx | 2 ++ 3 files changed, 9 insertions(+) mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_service.cxx diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index e3c8b2bfb46b..8bd8a6191201 100755 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -76,6 +76,7 @@ #include "comphelper/anytostring.hxx" #include "vcl/msgbox.hxx" #include "toolkit/helper/vclunohelper.hxx" +#include "comphelper/processfactory.hxx" #include "dp_gui.h" #include "dp_gui_thread.hxx" @@ -1185,6 +1186,11 @@ void ExtensionCmdQueue::acceptLicense( const uno::Reference< deployment::XPackag m_thread->acceptLicense( rPackage ); } +void ExtensionCmdQueue::syncRepositories( const uno::Reference< uno::XComponentContext > &xContext ) +{ + dp_misc::syncRepositories( new ProgressCmdEnv( xContext, NULL, OUSTR("Extension Manager") ) ); +} + void ExtensionCmdQueue::stop() { m_thread->stop(); diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx index 29cee4292102..7ac00e2740d4 100755 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx @@ -86,6 +86,7 @@ public: void checkForUpdates(const std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > &vList ); void acceptLicense( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); + static void syncRepositories( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext ); /** This call does not block. It signals the internal thread that it should install the remaining extensions and then terminate. diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx old mode 100644 new mode 100755 index 061988d5b04d..c4269e6ac137 --- a/desktop/source/deployment/gui/dp_gui_service.cxx +++ b/desktop/source/deployment/gui/dp_gui_service.cxx @@ -46,6 +46,7 @@ #include "boost/bind.hpp" #include "license_dialog.hxx" #include "dp_gui_dialog2.hxx" +#include "dp_gui_extensioncmdqueue.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -256,6 +257,7 @@ void ServiceImpl::startExecuteModal( + ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTVERSION).get(); app->SetDisplayName(sTitle); + ExtensionCmdQueue::syncRepositories( m_xComponentContext ); } } else -- cgit From a82d6ff3b4aa2453120cd1bcb3fb69c1d3e2aed2 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Wed, 2 Jun 2010 17:05:21 +0200 Subject: jl152 #i77196# bubble update notification now supports the new update behavior --- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 1 + desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 1 + .../source/deployment/gui/dp_gui_updatedialog.cxx | 170 ++------- desktop/source/deployment/inc/dp_misc.h | 52 --- desktop/source/deployment/inc/dp_update.hxx | 147 ++++++++ .../deployment/manager/dp_informationprovider.cxx | 275 +++++--------- desktop/source/deployment/misc/dp_misc.cxx | 152 -------- desktop/source/deployment/misc/dp_update.cxx | 397 +++++++++++++++++++++ desktop/source/deployment/misc/makefile.mk | 3 +- 9 files changed, 679 insertions(+), 519 deletions(-) create mode 100755 desktop/source/deployment/inc/dp_update.hxx create mode 100755 desktop/source/deployment/misc/dp_update.cxx diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index d34001393ba7..4ba747198c09 100755 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -39,6 +39,7 @@ #include "dp_gui_theextmgr.hxx" #include "dp_gui_extensioncmdqueue.hxx" #include "dp_misc.h" +#include "dp_update.hxx" #include "dp_identifier.hxx" #include "vcl/ctrl.hxx" diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 7bfcc79480b3..d0347c7cbf4e 100755 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -42,6 +42,7 @@ #include "dp_gui_theextmgr.hxx" #include "dp_gui_theextmgr.hxx" #include "dp_identifier.hxx" +#include "dp_update.hxx" #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index a27f04326b25..b27cd8da81fe 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -112,6 +112,7 @@ #include "dp_identifier.hxx" #include "dp_version.hxx" #include "dp_misc.h" +#include "dp_update.hxx" #include "dp_gui.h" #include "dp_gui.hrc" @@ -254,7 +255,7 @@ private: }; // A multimap in case an extension is installed in "user", "shared" or "bundled" - typedef std::multimap< rtl::OUString, Entry > Map; + typedef std::map< rtl::OUString, Entry > Map; virtual ~Thread(); @@ -357,78 +358,44 @@ UpdateDialog::Thread::~Thread() void UpdateDialog::Thread::execute() { - OSL_ASSERT( ! m_vExtensionList.empty() ); - Map map; - - typedef std::vector< css::uno::Reference< css::deployment::XPackage > >::const_iterator ITER; - for ( ITER iIndex = m_vExtensionList.begin(); iIndex < m_vExtensionList.end(); ++iIndex ) { - css::uno::Reference< css::deployment::XPackage > p = *iIndex; - if ( p.is() ) - { - { - vos::OGuard g( Application::GetSolarMutex() ); - if ( m_stop ) { - return; - } - } - getOwnUpdateInformation( p, &map ); - } - } - - const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL()); - if (sDefaultURL.getLength()) - { - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > - infos( - getUpdateInformation( - css::uno::Reference< css::deployment::XPackage >(), - css::uno::Sequence< rtl::OUString >(&sDefaultURL, 1), rtl::OUString())); - for (sal_Int32 i = 0; i < infos.getLength(); ++i) { - css::uno::Reference< css::xml::dom::XNode > node( - infos[i], css::uno::UNO_QUERY_THROW); - dp_misc::DescriptionInfoset infoset(m_context, node); - boost::optional< rtl::OUString > id(infoset.getIdentifier()); - if (!id) { - continue; - } - Map::iterator end(map.upper_bound(*id)); - for (Map::iterator j(map.lower_bound(*id)); j != end; ++j) { - //skip those extension which provide its own update urls - if (j->second.bProvidesOwnUpdate) - continue; - rtl::OUString v(infoset.getVersion()); - //look for the highest version in the online repository - if (dp_misc::compareVersions(v, j->second.version) == - dp_misc::GREATER) - { - j->second.version = v; - j->second.info = node; - } - } + vos::OGuard g( Application::GetSolarMutex() ); + if ( m_stop ) { + return; } } - css::uno::Reference extMgr = css::deployment::ExtensionManager::get(m_context); - for (Map::iterator i(map.begin()); i != map.end(); ++i) + + std::vector, css::uno::Any > > errors; + + dp_misc::UpdateInfoMap updateInfoMap = dp_misc::getOnlineUpdateInfos( + m_context, extMgr, m_updateInformation, &m_vExtensionList, errors); + + typedef std::vector, + css::uno::Any> >::const_iterator ITERROR; + for (ITERROR ite = errors.begin(); ite != errors.end(); ite ++) + handleSpecificError(ite->first, ite->second); + + for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++) { + dp_misc::UpdateInfo const & info = i->second; + UpdateData updateData(info.extension); + DisabledUpdate disableUpdate; //determine if online updates meet the requirements - prepareUpdateData(i->second.info, - i->second.disableUpdate, i->second.updateData); + prepareUpdateData(info.info, disableUpdate, updateData); //determine if the update is installed in the user or shared repository rtl::OUString sOnlineVersion; - if (i->second.updateData.aUpdateInfo.is()) - sOnlineVersion = i->second.version; - + if (info.info.is()) + sOnlineVersion = info.version; rtl::OUString sVersionUser; rtl::OUString sVersionShared; rtl::OUString sVersionBundled; css::uno::Sequence< css::uno::Reference< css::deployment::XPackage> > extensions; try { extensions = extMgr->getExtensionsWithSameIdentifier( - dp_misc::getIdentifier(i->second.package), i->second.package->getName(), + dp_misc::getIdentifier(info.extension), info.extension->getName(), css::uno::Reference()); } catch (css::lang::IllegalArgumentException& ) { OSL_ASSERT(0); @@ -453,15 +420,15 @@ void UpdateDialog::Thread::execute() { if (sourceUser == dp_misc::UPDATE_SOURCE_SHARED) { - i->second.updateData.aUpdateSource = extensions[1]; - i->second.updateData.updateVersion = extensions[1]->getVersion(); + updateData.aUpdateSource = extensions[1]; + updateData.updateVersion = extensions[1]->getVersion(); } else if (sourceUser == dp_misc::UPDATE_SOURCE_BUNDLED) { - i->second.updateData.aUpdateSource = extensions[2]; - i->second.updateData.updateVersion = extensions[2]->getVersion(); + updateData.aUpdateSource = extensions[2]; + updateData.updateVersion = extensions[2]->getVersion(); } - if (!update(i->second.disableUpdate, i->second.updateData)) + if (!update(disableUpdate, updateData)) return; } @@ -469,11 +436,11 @@ void UpdateDialog::Thread::execute() { if (sourceShared == dp_misc::UPDATE_SOURCE_BUNDLED) { - i->second.updateData.aUpdateSource = extensions[2]; - i->second.updateData.updateVersion = extensions[2]->getVersion(); + updateData.aUpdateSource = extensions[2]; + updateData.updateVersion = extensions[2]->getVersion(); } - i->second.updateData.bIsShared = true; - if (!update(i->second.disableUpdate, i->second.updateData)) + updateData.bIsShared = true; + if (!update(disableUpdate, updateData)) return; } } @@ -517,71 +484,6 @@ void UpdateDialog::Thread::handleSpecificError( } } -css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > -UpdateDialog::Thread::getUpdateInformation( - css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Sequence< rtl::OUString > const & urls, - rtl::OUString const & identifier) const -{ - try { - return m_updateInformation->getUpdateInformation(urls, identifier); - } catch (css::uno::RuntimeException &) { - throw; - } catch (css::ucb::CommandFailedException & e) { - handleSpecificError(package, e.Reason); - } catch (css::ucb::CommandAbortedException &) { - } catch (css::uno::Exception & e) { - handleSpecificError(package, css::uno::makeAny(e)); - } - return - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >(); -} - -void UpdateDialog::Thread::getOwnUpdateInformation( - css::uno::Reference< css::deployment::XPackage > const & package, - Map * map) -{ - rtl::OUString id(dp_misc::getIdentifier(package)); - css::uno::Sequence< rtl::OUString > urls( - package->getUpdateInformationURLs()); - if (urls.getLength() == 0) { - map->insert( - Map::value_type( - id, Entry(package, OUSTR("")))); - } else { - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > - infos(getUpdateInformation(package, urls, id)); - rtl::OUString latestVersion; - sal_Int32 latestIndex = -1; - for (sal_Int32 i = 0; i < infos.getLength(); ++i) { - dp_misc::DescriptionInfoset infoset( - m_context, - css::uno::Reference< css::xml::dom::XNode >( - infos[i], css::uno::UNO_QUERY_THROW)); - boost::optional< rtl::OUString > id2(infoset.getIdentifier()); - if (!id2) { - continue; - } - if (*id2 == id) { - rtl::OUString v(infoset.getVersion()); - if (dp_misc::compareVersions(v, latestVersion) == - dp_misc::GREATER) - { - latestVersion = v; - latestIndex = i; - } - } - } - if (latestIndex != -1) { - Entry e(package, latestVersion); - e.info = css::uno::Reference< css::xml::dom::XNode >( - infos[latestIndex], css::uno::UNO_QUERY_THROW); - e.bProvidesOwnUpdate = true; - map->insert(Map::value_type(id, e)); - } - } -} - ::rtl::OUString UpdateDialog::Thread::getUpdateDisplayString( dp_gui::UpdateData const & data, ::rtl::OUString const & version) const { @@ -590,7 +492,8 @@ void UpdateDialog::Thread::getOwnUpdateInformation( b.append(static_cast< sal_Unicode >(' ')); { vos::OGuard g( Application::GetSolarMutex() ); - b.append(m_dialog.m_version); + if(!m_stop) + b.append(m_dialog.m_version); } b.append(static_cast< sal_Unicode >(' ')); if (version.getLength()) @@ -603,7 +506,8 @@ void UpdateDialog::Thread::getOwnUpdateInformation( b.append(static_cast< sal_Unicode >(' ')); { vos::OGuard g( Application::GetSolarMutex() ); - b.append(m_dialog.m_browserbased); + if(!m_stop) + b.append(m_dialog.m_browserbased); } } return b.makeStringAndClear(); diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index 161b91a6bcde..61e3fcc45418 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -117,11 +117,6 @@ oslProcess raiseProcess( ::rtl::OUString const & appURL, ::com::sun::star::uno::Sequence< ::rtl::OUString > const & args ); //============================================================================== -/** returns the default update URL (for the update information) which - is used when an extension does not provide its own URL. -*/ -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -::rtl::OUString getExtensionDefaultUpdateURL(); /** writes the argument string to the console. On Linux/Unix/etc. it converts the UTF16 string to an ANSI string using @@ -179,53 +174,6 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void syncRepositories(::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv); -enum UPDATE_SOURCE -{ - UPDATE_SOURCE_NONE, - UPDATE_SOURCE_SHARED, - UPDATE_SOURCE_BUNDLED, - UPDATE_SOURCE_ONLINE -}; - -/* determine if an update is available which is installed in the - user repository. - - If the return value is UPDATE_SOURCE_NONE, then no update is - available, otherwise the return value determine from which the - repository the update is used. -*/ -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -UPDATE_SOURCE isUpdateUserExtension( - bool bReadOnlyShared, - ::rtl::OUString const & userVersion, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion); - -/* determine if an update is available which is installed in the - shared repository. - - If the return value is UPDATE_SOURCE_NONE, then no update is - available, otherwise the return value determine from which the - repository the update is used. -*/ -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -UPDATE_SOURCE isUpdateSharedExtension( - bool bReadOnlyShared, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion); - -/* determines the extension with the highest identifier and returns it - - */ -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> -getExtensionWithHighestVersion( - ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Reference< - ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId); - } #endif diff --git a/desktop/source/deployment/inc/dp_update.hxx b/desktop/source/deployment/inc/dp_update.hxx new file mode 100755 index 000000000000..01511b1f2d21 --- /dev/null +++ b/desktop/source/deployment/inc/dp_update.hxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_UPDATE_HXX +#define INCLUDED_DP_UPDATE_HXX + + +#include "com/sun/star/deployment/XPackage.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/XUpdateInformationProvider.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XNode.hpp" + +#include "rtl/ustrbuf.hxx" +#include "dp_misc_api.hxx" + +#include +#include + +namespace dp_misc { + +/** returns the default update URL (for the update information) which + is used when an extension does not provide its own URL. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::rtl::OUString getExtensionDefaultUpdateURL(); + +enum UPDATE_SOURCE +{ + UPDATE_SOURCE_NONE, + UPDATE_SOURCE_SHARED, + UPDATE_SOURCE_BUNDLED, + UPDATE_SOURCE_ONLINE +}; + +/* determine if an update is available which is installed in the + user repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateUserExtension( + bool bReadOnlyShared, + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +/* determine if an update is available which is installed in the + shared repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateSharedExtension( + bool bReadOnlyShared, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +/* determines the extension with the highest identifier and returns it + + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> +getExtensionWithHighestVersion( + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId); + + +struct UpdateInfo +{ + UpdateInfo( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & ext); + ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage> extension; +//version of the update + ::rtl::OUString version; + ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > info; +}; + +typedef std::map< ::rtl::OUString, UpdateInfo > UpdateInfoMap; + +/* + @param extensionList + List of extension for which online update information are to be obtained. If NULL, then + for update information are obtained for all installed extension. There may be only one extension + with a particular identifier contained in the list. If one extension is installed + in several repositories, then the one with the highest version must be used, because it contains + the more recent URLs for getting the update information (if at all). + @param out_errors + the first member of the pair is the extension and the second the exception that was produced + when processing the extension. + + @return + A map of UpdateInfo instances. If the parameter extensionList was given, then the map contains + at only information for those extensions. + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UpdateInfoMap getOnlineUpdateInfos( + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const &xContext, + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager> const & xExtMgr, + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XUpdateInformationProvider > const & updateInformation, + std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > const * extensionList, + ::std::vector< ::std::pair< ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage>, ::com::sun::star::uno::Any> > & out_errors); + +/* retunrs the highest version from the provided arguments. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::rtl::OUString getHighestVersion( + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +} + +#endif diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index 537b7233ef77..ca2c7b5438cf 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -55,6 +55,7 @@ #include "dp_identifier.hxx" #include "dp_version.hxx" #include "dp_misc.h" +#include "dp_update.hxx" namespace beans = com::sun::star::beans ; namespace deployment = com::sun::star::deployment ; @@ -107,16 +108,6 @@ private: const rtl::OUString& _sExtensionId ); uno::Reference< deployment::XUpdateInformationProvider > mxUpdateInformation; - - uno::Sequence< uno::Reference< xml::dom::XElement > > - getUpdateInformation( uno::Sequence< rtl::OUString > const & urls, - rtl::OUString const & identifier ) const; - uno::Sequence< uno::Reference< deployment::XPackage > > - getPackages(rtl::OUString const & repository); - uno::Sequence< uno::Sequence< rtl::OUString > > isUpdateAvailable( - rtl::OUString const & repository, const rtl::OUString& _sExtensionId ); - uno::Sequence< uno::Sequence< rtl::OUString > > concatLists( uno::Sequence< uno::Sequence< rtl::OUString > > aFirst, - uno::Sequence< uno::Sequence< rtl::OUString > > aSecond ); }; //------------------------------------------------------------------------------ @@ -212,18 +203,101 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionId ) throw ( uno::RuntimeException ) { - uno::Sequence< uno::Sequence< rtl::OUString > > - aUpdateListUser = isUpdateAvailable( UNISTRING("user"), _sExtensionId ); + uno::Sequence< uno::Sequence< rtl::OUString > > aList; - uno::Sequence< uno::Sequence< rtl::OUString > > - aUpdateListShared = isUpdateAvailable( UNISTRING("shared"), _sExtensionId ); + uno::Reference extMgr = + deployment::ExtensionManager::get(mxContext); - uno::Sequence< uno::Sequence< rtl::OUString > > - aUpdateListBundled = isUpdateAvailable( UNISTRING("bundled"), _sExtensionId ); + if (!extMgr.is()) + { + OSL_ASSERT(0); + return aList; + } + std::vector, uno::Any > > errors; + dp_misc::UpdateInfoMap updateInfoMap; + if (_sExtensionId.getLength()) + { + std::vector > vecExtensions; + uno::Reference extension; + try + { + extension = dp_misc::getExtensionWithHighestVersion( + extMgr->getExtensionsWithSameIdentifier( + _sExtensionId, _sExtensionId, uno::Reference())); + vecExtensions.push_back(extension); + } + catch (lang::IllegalArgumentException &) + { + OSL_ASSERT(0); + } + updateInfoMap = dp_misc::getOnlineUpdateInfos( + mxContext, extMgr, mxUpdateInformation, &vecExtensions, errors); + } + else + { + updateInfoMap = dp_misc::getOnlineUpdateInfos( + mxContext, extMgr, mxUpdateInformation, NULL, errors); + } + + int nCount = 0; + for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++) + { + dp_misc::UpdateInfo const & info = i->second; + + rtl::OUString sOnlineVersion; + if (info.info.is()) + sOnlineVersion = info.version; + + rtl::OUString sVersionUser; + rtl::OUString sVersionShared; + rtl::OUString sVersionBundled; + uno::Sequence< uno::Reference< deployment::XPackage> > extensions; + try { + extensions = extMgr->getExtensionsWithSameIdentifier( + dp_misc::getIdentifier(info.extension), info.extension->getName(), + uno::Reference()); + } catch (lang::IllegalArgumentException& ) { + OSL_ASSERT(0); + } + OSL_ASSERT(extensions.getLength() == 3); + if (extensions[0].is() ) + sVersionUser = extensions[0]->getVersion(); + if (extensions[1].is() ) + sVersionShared = extensions[1]->getVersion(); + if (extensions[2].is() ) + sVersionBundled = extensions[2]->getVersion(); + + bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared")); + + dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension( + bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion); + dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension( + bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion); + + rtl::OUString updateVersionUser; + rtl::OUString updateVersionShared; + if (sourceUser != dp_misc::UPDATE_SOURCE_NONE) + updateVersionUser = dp_misc::getHighestVersion( + rtl::OUString(), sVersionShared, sVersionBundled, sOnlineVersion); + if (sourceShared != dp_misc::UPDATE_SOURCE_NONE) + updateVersionShared = dp_misc::getHighestVersion( + rtl::OUString(), rtl::OUString(), sVersionBundled, sOnlineVersion); + rtl::OUString updateVersion; + if (dp_misc::compareVersions(updateVersionUser, updateVersionShared) == dp_misc::GREATER) + updateVersion = updateVersionUser; + else + updateVersion = updateVersionShared; + if (updateVersion.getLength()) + { - uno::Sequence< uno::Sequence< rtl::OUString > > user_shared = - concatLists( aUpdateListUser, aUpdateListShared ); - return concatLists(user_shared, aUpdateListBundled); + rtl::OUString aNewEntry[2]; + aNewEntry[0] = i->first; + aNewEntry[1] = updateVersion; + aList.realloc( ++nCount ); + aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 ); + } + } + return aList; } //------------------------------------------------------------------------------ @@ -257,7 +331,7 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvi for (sal_Int32 j = 0; j < cExt; j++) { //ToDo according to the old code the first found extenions is used - //even if another one with the same id has a better version. Design flaw? + //even if another one with the same id has a better version. uno::Reference< deployment::XPackage > const & xExtension( seqExtension[j] ); if (xExtension.is()) { @@ -272,167 +346,6 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvi return retList; } -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -uno::Sequence< uno::Reference< deployment::XPackage > > -PackageInformationProvider::getPackages( const rtl::OUString & repository ) -{ - uno::Sequence< uno::Reference< deployment::XPackage > > packages; - try { - uno::Reference xMgr = deployment::ExtensionManager::get(mxContext); - packages = xMgr->getDeployedExtensions(repository, uno::Reference< task::XAbortChannel >(), - static_cast < XCommandEnvironment *> (this) ); - } - catch ( deployment::DeploymentException & ) - {} - catch ( css_ucb::CommandFailedException & ) - {} - catch ( css_ucb::CommandAbortedException & ) - {} - catch ( lang::IllegalArgumentException & e ) - { - throw uno::RuntimeException(e.Message, e.Context); - } - - return packages; -} - -//------------------------------------------------------------------------------ -uno::Sequence< uno::Reference< xml::dom::XElement > > - PackageInformationProvider::getUpdateInformation( uno::Sequence< rtl::OUString > const & urls, - rtl::OUString const & identifier ) const -{ - try - { - return mxUpdateInformation->getUpdateInformation( urls, identifier ); - } - catch ( uno::RuntimeException & ) { - throw; - } - catch ( css_ucb::CommandFailedException & ) {} - catch ( css_ucb::CommandAbortedException & ) {} - catch ( uno::Exception & ) {} - - return uno::Sequence< uno::Reference< xml::dom::XElement > >(); -} - -//------------------------------------------------------------------------------ -uno::Sequence< uno::Sequence< rtl::OUString > > - PackageInformationProvider::isUpdateAvailable( - const rtl::OUString& repository, - const rtl::OUString& _sExtensionId ) -{ - uno::Sequence< uno::Sequence< rtl::OUString > > aList; - sal_Int32 nCount = 0; - bool bPackageFound = false; - - uno::Reference xManager = deployment::ExtensionManager::get(mxContext); - // If the package manager is readonly then the user cannot modify anything anyway - // so we can abort the search here - if ( xManager.is() && ! xManager->isReadOnlyRepository(repository) ) - { - uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( repository ) ); - uno::Sequence< uno::Reference< xml::dom::XElement > > defaultInfos; - - for ( int pos = packages.getLength(); pos-- && !bPackageFound; ) - { - uno::Reference< deployment::XPackage > package( packages[ pos ] ); - uno::Sequence< rtl::OUString > urls( package->getUpdateInformationURLs()); - uno::Sequence< uno::Reference< xml::dom::XElement > > infos; - rtl::OUString id( dp_misc::getIdentifier( package ) ); - - if ( _sExtensionId.getLength() ) - { - if ( _sExtensionId == id ) - bPackageFound = true; - else /* we have an ID and the IDs don't match, continue with next package */ - continue; - } - - if ( urls.getLength() != 0) - { - infos = getUpdateInformation( urls, id ); - } - else - { - if ( defaultInfos.getLength() == 0 ) - { - const rtl::OUString defaultURL( dp_misc::getExtensionDefaultUpdateURL() ); - if ( defaultURL.getLength() ) - defaultInfos = getUpdateInformation( uno::Sequence< rtl::OUString >( &defaultURL, 1 ), - rtl::OUString() ); - } - infos = defaultInfos; - } - rtl::OUString latestVersion( package->getVersion() ); - sal_Int32 latestIndex = -1; - for ( sal_Int32 i = 0; i < infos.getLength(); ++i ) - { - dp_misc::DescriptionInfoset infoset( mxContext, - uno::Reference< xml::dom::XNode >( infos[i], uno::UNO_QUERY_THROW)); - boost::optional< rtl::OUString > id2( infoset.getIdentifier() ); - - if (!id2) - continue; - - if (*id2 == id) - { - // check, if there are unsatisfied dependencies and ignore those updates - uno::Sequence< uno::Reference< xml::dom::XElement > > ds( dp_misc::Dependencies::check( infoset ) ); - if ( ds.getLength() ) - continue; - - rtl::OUString v( infoset.getVersion() ); - if ( dp_misc::compareVersions( v, latestVersion ) == dp_misc::GREATER ) - { - latestVersion = v; - latestIndex = i; - } - } - } - if ( latestIndex != -1 ) - { - rtl::OUString aNewEntry[2]; - aNewEntry[0] = id; - aNewEntry[1] = latestVersion; - aList.realloc( ++nCount ); - aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 ); - } - } - } - return aList; -} - -//------------------------------------------------------------------------------ -uno::Sequence< uno::Sequence< rtl::OUString > > PackageInformationProvider::concatLists( - uno::Sequence< uno::Sequence< rtl::OUString > > aFirst, - uno::Sequence< uno::Sequence< rtl::OUString > > aSecond ) -{ - sal_Int32 nFirstCount = aFirst.getLength(); - sal_Int32 nSecondCount = aSecond.getLength(); - sal_Int32 nIndex = nFirstCount; - - for ( sal_Int32 i=0; i < nSecondCount; i++ ) - { - bool bDuplicateEntry = false; - for ( sal_Int32 j=0; j < nFirstCount; j++ ) - { - if ( aFirst[ j ][0] == aSecond[ i ][0] ) - { - bDuplicateEntry = true; - break; - } - } - if ( !bDuplicateEntry ) - { - nIndex += 1; - aFirst.realloc( nIndex ); - aFirst[ nIndex - 1 ] = aSecond[ i ]; - } - } - return aFirst; -} //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 53d488095ecd..fe3490903043 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -477,17 +477,6 @@ Reference resolveUnoURL( } } -OUString getExtensionDefaultUpdateURL() -{ - ::rtl::OUString sUrl( - RTL_CONSTASCII_USTRINGPARAM( - "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") - ":Version:ExtensionUpdateURL}")); - ::rtl::Bootstrap::expandMacros(sUrl); - return sUrl; -} - - #ifdef WNT void writeConsoleWithStream(::rtl::OUString const & sText, HANDLE stream) { @@ -631,147 +620,6 @@ void syncRepositories(Reference const & xCmdEnv) } } -/* returns the index of the greatest version, starting with 0 - - */ -int determineHighestVersion( - ::rtl::OUString const & userVersion, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion) -{ - int index = 0; - OUString greatest = userVersion; - if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER) - { - index = 1; - greatest = sharedVersion; - } - if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER) - { - index = 2; - greatest = bundledVersion; - } - if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER) - { - index = 3; - } - return index; -} - -UPDATE_SOURCE isUpdateUserExtension( - bool bReadOnlyShared, - ::rtl::OUString const & userVersion, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion) -{ - UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; - if (bReadOnlyShared) - { - if (userVersion.getLength()) - { - int index = determineHighestVersion( - userVersion, sharedVersion, bundledVersion, onlineVersion); - if (index == 1) - retVal = UPDATE_SOURCE_SHARED; - else if (index == 2) - retVal = UPDATE_SOURCE_BUNDLED; - else if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - else if (sharedVersion.getLength()) - { - int index = determineHighestVersion( - OUString(), sharedVersion, bundledVersion, onlineVersion); - if (index == 2) - retVal = UPDATE_SOURCE_BUNDLED; - else if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - - } - else if (bundledVersion.getLength()) - { - int index = determineHighestVersion( - OUString(), OUString(), bundledVersion, onlineVersion); - if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - } - else - { - if (userVersion.getLength()) - { - int index = determineHighestVersion( - userVersion, sharedVersion, bundledVersion, onlineVersion); - if (index == 1) - retVal = UPDATE_SOURCE_SHARED; - else if (index == 2) - retVal = UPDATE_SOURCE_BUNDLED; - else if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - } - - return retVal; -} - -UPDATE_SOURCE isUpdateSharedExtension( - bool bReadOnlyShared, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion) -{ - if (bReadOnlyShared) - return UPDATE_SOURCE_NONE; - UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; - - if (sharedVersion.getLength()) - { - int index = determineHighestVersion( - OUString(), sharedVersion, bundledVersion, onlineVersion); - if (index == 2) - retVal = UPDATE_SOURCE_BUNDLED; - else if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - else if (bundledVersion.getLength()) - { - int index = determineHighestVersion( - OUString(), OUString(), bundledVersion, onlineVersion); - if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - return retVal; -} - -Reference -getExtensionWithHighestVersion( - Sequence > const & seqExt) -{ - if (seqExt.getLength() == 0) - return Reference(); - - Reference greatest; - sal_Int32 len = seqExt.getLength(); - - for (sal_Int32 i = 0; i < len; i++) - { - if (!greatest.is()) - { - greatest = seqExt[i]; - continue; - } - Reference const & current = seqExt[i]; - //greatest has a value - if (! current.is()) - continue; - - if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER) - greatest = current; - } - return greatest; -} } diff --git a/desktop/source/deployment/misc/dp_update.cxx b/desktop/source/deployment/misc/dp_update.cxx new file mode 100755 index 000000000000..52011f1f0ca0 --- /dev/null +++ b/desktop/source/deployment/misc/dp_update.cxx @@ -0,0 +1,397 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + + +#include "dp_update.hxx" +#include "dp_version.hxx" +#include "dp_identifier.hxx" +#include "dp_descriptioninfoset.hxx" + +#include "rtl/bootstrap.hxx" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; +using ::rtl::OString; + + +namespace dp_misc { +namespace { + +int determineHighestVersion( + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + int index = 0; + OUString greatest = userVersion; + if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER) + { + index = 1; + greatest = sharedVersion; + } + if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER) + { + index = 2; + greatest = bundledVersion; + } + if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER) + { + index = 3; + } + return index; +} + +Sequence< Reference< xml::dom::XElement > > +getUpdateInformation( Reference const & updateInformation, + Sequence< OUString > const & urls, + OUString const & identifier, + uno::Any & out_error) +{ + try { + return updateInformation->getUpdateInformation(urls, identifier); + } catch (uno::RuntimeException &) { + throw; + } catch (ucb::CommandFailedException & e) { + out_error = e.Reason; + } catch (ucb::CommandAbortedException &) { + } catch (uno::Exception & e) { + out_error = uno::makeAny(e); + } + return + Sequence >(); +} + +//Put in anonymous namespace + +void getOwnUpdateInfos( + Reference const & xContext, + Reference const & updateInformation, + UpdateInfoMap& inout_map, std::vector, uno::Any> > & out_errors, + bool & out_allFound) +{ + bool allHaveOwnUpdateInformation = true; + for (UpdateInfoMap::iterator i = inout_map.begin(); i != inout_map.end(); i++) + { + OSL_ASSERT(i->second.extension.is()); + Sequence urls(i->second.extension->getUpdateInformationURLs()); + if (urls.getLength()) + { + const OUString id = dp_misc::getIdentifier(i->second.extension); + uno::Any anyError; + //It is unclear from the idl if there can be a null reference returned. + //However all valid information should be the same + Sequence > + infos(getUpdateInformation(updateInformation, urls, id, anyError)); + if (anyError.hasValue()) + out_errors.push_back(std::make_pair(i->second.extension, anyError)); + + for (sal_Int32 j = 0; j < infos.getLength(); ++j) + { + dp_misc::DescriptionInfoset infoset( + xContext, + Reference< xml::dom::XNode >(infos[j], UNO_QUERY_THROW)); + if (!infoset.hasDescription()) + continue; + boost::optional< OUString > id2(infoset.getIdentifier()); + if (!id2) + continue; + OSL_ASSERT(*id2 == id); + if (*id2 == id) + { + i->second.version = infoset.getVersion(); + i->second.info = Reference< xml::dom::XNode >( + infos[j], UNO_QUERY_THROW); + } + break; + } + } + else + { + allHaveOwnUpdateInformation &= false; + } + } + out_allFound = allHaveOwnUpdateInformation; +} + +void getDefaultUpdateInfos( + Reference const & xContext, + Reference const & updateInformation, + UpdateInfoMap& inout_map, + std::vector, uno::Any> > & out_errors) +{ + const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL()); + OSL_ASSERT(sDefaultURL.getLength()); + + Any anyError; + Sequence< Reference< xml::dom::XElement > > + infos( + getUpdateInformation( + updateInformation, + Sequence< OUString >(&sDefaultURL, 1), OUString(), anyError)); + if (anyError.hasValue()) + out_errors.push_back(std::make_pair(Reference(), anyError)); + for (sal_Int32 i = 0; i < infos.getLength(); ++i) + { + Reference< xml::dom::XNode > node(infos[i], UNO_QUERY_THROW); + dp_misc::DescriptionInfoset infoset(xContext, node); + boost::optional< OUString > id(infoset.getIdentifier()); + if (!id) { + continue; + } + UpdateInfoMap::iterator j = inout_map.find(*id); + if (j != inout_map.end()) + { + //skip those extension which provide its own update urls + if (j->second.extension->getUpdateInformationURLs().getLength()) + continue; + OUString v(infoset.getVersion()); + //look for the highest version in the online repository + if (dp_misc::compareVersions(v, j->second.version) == + dp_misc::GREATER) + { + j->second.version = v; + j->second.info = node; + } + } + } +} + + +} // anon namespace + + +OUString getExtensionDefaultUpdateURL() +{ + ::rtl::OUString sUrl( + RTL_CONSTASCII_USTRINGPARAM( + "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") + ":Version:ExtensionUpdateURL}")); + ::rtl::Bootstrap::expandMacros(sUrl); + return sUrl; +} + +/* returns the index of the greatest version, starting with 0 + + */ +UPDATE_SOURCE isUpdateUserExtension( + bool bReadOnlyShared, + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; + if (bReadOnlyShared) + { + if (userVersion.getLength()) + { + int index = determineHighestVersion( + userVersion, sharedVersion, bundledVersion, onlineVersion); + if (index == 1) + retVal = UPDATE_SOURCE_SHARED; + else if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + else if (sharedVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), sharedVersion, bundledVersion, onlineVersion); + if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + + } + else if (bundledVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), OUString(), bundledVersion, onlineVersion); + if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + } + else + { + if (userVersion.getLength()) + { + int index = determineHighestVersion( + userVersion, sharedVersion, bundledVersion, onlineVersion); + if (index == 1) + retVal = UPDATE_SOURCE_SHARED; + else if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + } + + return retVal; +} + +UPDATE_SOURCE isUpdateSharedExtension( + bool bReadOnlyShared, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + if (bReadOnlyShared) + return UPDATE_SOURCE_NONE; + UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; + + if (sharedVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), sharedVersion, bundledVersion, onlineVersion); + if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + else if (bundledVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), OUString(), bundledVersion, onlineVersion); + if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + return retVal; +} + +Reference +getExtensionWithHighestVersion( + Sequence > const & seqExt) +{ + if (seqExt.getLength() == 0) + return Reference(); + + Reference greatest; + sal_Int32 len = seqExt.getLength(); + + for (sal_Int32 i = 0; i < len; i++) + { + if (!greatest.is()) + { + greatest = seqExt[i]; + continue; + } + Reference const & current = seqExt[i]; + //greatest has a value + if (! current.is()) + continue; + + if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER) + greatest = current; + } + return greatest; +} + +UpdateInfo::UpdateInfo( Reference< deployment::XPackage> const & ext): +extension(ext) +{ +} + + + +UpdateInfoMap getOnlineUpdateInfos( + Reference const &xContext, + Reference const & xExtMgr, + Reference const & updateInformation, + std::vector > const * extensionList, + std::vector, uno::Any> > & out_errors) +{ + OSL_ASSERT(xExtMgr.is()); + UpdateInfoMap infoMap; + if (!xExtMgr.is()) + return infoMap; + + if (!extensionList) + { + const uno::Sequence< uno::Sequence< Reference > > seqAllExt = xExtMgr->getAllExtensions( + Reference(), Reference()); + + //fill the UpdateInfoMap. key = extension identifier, value = UpdateInfo + for (int pos = seqAllExt.getLength(); pos --; ) + { + uno::Sequence > const & seqExt = seqAllExt[pos]; + + Reference extension = getExtensionWithHighestVersion(seqExt); + OSL_ASSERT(extension.is()); + + std::pair insertRet = infoMap.insert( + UpdateInfoMap::value_type( + dp_misc::getIdentifier(extension), UpdateInfo(extension))); + OSL_ASSERT(insertRet.second == true); + } + } + else + { + typedef std::vector >::const_iterator CIT; + for (CIT i = extensionList->begin(); i != extensionList->end(); i++) + { + OSL_ASSERT(i->is()); + std::pair insertRet = infoMap.insert( + UpdateInfoMap::value_type( + dp_misc::getIdentifier(*i), UpdateInfo(*i))); + OSL_ASSERT(insertRet.second == true); + } + } + + //Now find the update information for the extensions which provide their own + //URLs to update information. + bool allInfosObtained = false; + getOwnUpdateInfos(xContext, updateInformation, infoMap, out_errors, allInfosObtained); + + if (!allInfosObtained) + getDefaultUpdateInfos(xContext, updateInformation, infoMap, out_errors); + return infoMap; +} +OUString getHighestVersion( + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + int index = determineHighestVersion(userVersion, sharedVersion, bundledVersion, onlineVersion); + switch (index) + { + case 0: return userVersion; + case 1: return sharedVersion; + case 2: return bundledVersion; + case 3: return onlineVersion; + default: OSL_ASSERT(0); + } + + return OUString(); +} +} //namespace dp_misc diff --git a/desktop/source/deployment/misc/makefile.mk b/desktop/source/deployment/misc/makefile.mk index 9a7f1d62e001..3e4bd68cb4c0 100644 --- a/desktop/source/deployment/misc/makefile.mk +++ b/desktop/source/deployment/misc/makefile.mk @@ -65,7 +65,8 @@ SHL1OBJS = \ $(SLO)$/dp_version.obj \ $(SLO)$/dp_descriptioninfoset.obj \ $(SLO)$/dp_dependencies.obj \ - $(SLO)$/dp_platform.obj + $(SLO)$/dp_platform.obj \ + $(SLO)$/dp_update.obj SHL1STDLIBS = \ $(BERKELEYLIB) \ -- cgit From b1ec4b2cd5a9e6ece0e2a928cc0a11fef6bbe818 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 3 Jun 2010 00:10:45 +0200 Subject: tl78: #i110383# password to modify support for binary types only --- sfx2/inc/sfx2/docfile.hxx | 2 +- sfx2/inc/sfx2/objsh.hxx | 4 ++-- sfx2/inc/sfx2/sfxsids.hrc | 2 +- sfx2/sdi/sfx.sdi | 4 ++-- sfx2/source/dialog/filedlghelper.cxx | 8 ++++---- sfx2/source/doc/docfile.cxx | 17 +++++++++++------ sfx2/source/doc/guisaveas.cxx | 34 +++------------------------------- sfx2/source/doc/objcont.cxx | 4 ++-- sfx2/source/doc/sfxbasemodel.cxx | 14 ++++++++++++++ sfx2/source/inc/objshimp.hxx | 2 +- sfx2/source/view/viewfrm.cxx | 4 ++-- 11 files changed, 43 insertions(+), 52 deletions(-) diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index 7c702c838629..e4d3ff023b3b 100644 --- a/sfx2/inc/sfx2/docfile.hxx +++ b/sfx2/inc/sfx2/docfile.hxx @@ -328,7 +328,7 @@ public: static sal_Bool CallApproveHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler, ::com::sun::star::uno::Any aRequest, sal_Bool bAllowAbort ); static sal_Bool SetWritableForUserOnly( const ::rtl::OUString& aURL ); - static sal_uInt16 CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bMSType ); + static sal_uInt32 CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bWriter ); }; SV_DECL_IMPL_REF( SfxMedium ) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index a769fce4d26e..3b35886bc45d 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -437,8 +437,8 @@ public: void SetSaveVersionOnClose( sal_Bool bSet ); void ResetFromTemplate( const String& rTemplateName, const String& rFileName ); - sal_uInt16 GetModifyPasswordHash() const; - sal_Bool SetModifyPasswordHash( sal_uInt16 nHash ); + sal_uInt32 GetModifyPasswordHash() const; + sal_Bool SetModifyPasswordHash( sal_uInt32 nHash ); static sal_uInt32 HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc ); diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index a24c91e60060..5492c76a7e7e 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -306,7 +306,7 @@ #define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) #define SID_FONT_NAME (SID_SFX_START + 1716) #define SID_DEFAULTFILENAME (SID_SFX_START + 1717) -#define SID_PASSWORDTOMODIFYHASH (SID_SFX_START + 1718) +#define SID_MODIFYPASSWORDHASH (SID_SFX_START + 1718) #define SID_RECOMMENDREADONLY (SID_SFX_START + 1719) #define SID_SFX_free_START (SID_SFX_START + 1720) #define SID_SFX_free_END (SID_SFX_START + 3999) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 98c89663a9ae..1fc2cc16962d 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3594,7 +3594,7 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER ] //-------------------------------------------------------------------------- -SfxUInt16Item PasswordToModifyHash SID_PASSWORDTOMODIFYHASH +SfxUInt16Item PasswordToModifyHash SID_MODIFYPASSWORDHASH [ /* flags: */ @@ -5317,7 +5317,7 @@ SfxBoolItem SaveAll SID_SAVEDOCS //-------------------------------------------------------------------------- SfxBoolItem SaveAs SID_SAVEASDOC -(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO) +(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO,SfxInt32Item ModifyPasswordHash SID_MODIFYPASSWORDHASH) [ /* flags: */ AutoUpdate = FALSE, diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index d7109496d670..759c47598f9f 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1528,7 +1528,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, mbPwdCheckBoxState = ( pPassItem != NULL ); // in case the document has password to modify, the dialog should be shown - SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUInt16Item, SID_PASSWORDTOMODIFYHASH, FALSE ); + SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUInt32Item, SID_MODIFYPASSWORDHASH, FALSE ); mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); } @@ -1541,7 +1541,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // the password will be set in case user decide so rpSet->ClearItem( SID_PASSWORD ); rpSet->ClearItem( SID_RECOMMENDREADONLY ); - rpSet->ClearItem( SID_PASSWORDTOMODIFYHASH ); + rpSet->ClearItem( SID_MODIFYPASSWORDHASH ); } @@ -1660,9 +1660,9 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); // the empty password has 0 as Hash - sal_uInt16 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), bMSType ); + sal_uInt16 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); if ( nHash ) - rpSet->Put( SfxUInt16Item( SID_PASSWORDTOMODIFYHASH, nHash ) ); + rpSet->Put( SfxInt32Item( SID_MODIFYPASSWORDHASH, (sal_Int32)nHash ) ); } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index bb30670162fd..1dea202e0d0e 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -2576,15 +2576,20 @@ void SfxMedium::SetOrigFilter_Impl( const SfxFilter* pOrigFilter ) //------------------------------------------------------------------ -sal_uInt16 SfxMedium::CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bMSType ) +sal_uInt32 SfxMedium::CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bWriter ) { - sal_uInt16 nHash = 0; + sal_uInt32 nHash = 0; if ( aPasswd.getLength() ) { - rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; - if ( bMSType ) + if ( bWriter ) { + nHash = ::comphelper::DocPasswordHelper::GetWordHashAsUINT32( aPasswd ); + } + else + { + rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; + // if the MS-filter should be used // use the inconsistent algorithm to find the encoding specified by MS nEncoding = osl_getThreadTextEncoding(); @@ -2612,9 +2617,9 @@ sal_uInt16 SfxMedium::CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd nEncoding = RTL_TEXTENCODING_MS_1250; break; } - } - nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( aPasswd, nEncoding ); + nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( aPasswd, nEncoding ); + } } return nHash; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 4993e96b40bb..d68fd9dd2bad 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -180,18 +180,13 @@ class DocumentSettingsGuard { uno::Reference< beans::XPropertySet > m_xDocumentSettings; sal_Bool m_bPreserveReadOnly; - sal_uInt16 m_nPreserveHash; - sal_Bool m_bReadOnlySupported; - sal_Bool m_bModifyPasswordHashSupported; sal_Bool m_bRestoreSettings; public: - DocumentSettingsGuard( const uno::Reference< frame::XModel >& xModel, sal_Bool bReadOnly, sal_uInt16 nHash, sal_Bool bRestore ) + DocumentSettingsGuard( const uno::Reference< frame::XModel >& xModel, sal_Bool bReadOnly, sal_Bool bRestore ) : m_bPreserveReadOnly( sal_False ) - , m_nPreserveHash( 0 ) , m_bReadOnlySupported( sal_False ) - , m_bModifyPasswordHashSupported( sal_False ) , m_bRestoreSettings( bRestore ) { try @@ -203,7 +198,6 @@ public: uno::UNO_QUERY_THROW ); ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) ); - ::rtl::OUString aModifyPasswordHashString( RTL_CONSTASCII_USTRINGPARAM( "ModifyPasswordHash" ) ); try { @@ -213,20 +207,11 @@ public: } catch( uno::Exception& ) {} - - try - { - m_xDocumentSettings->getPropertyValue( aModifyPasswordHashString ) >>= m_nPreserveHash; - m_xDocumentSettings->setPropertyValue( aModifyPasswordHashString, uno::makeAny( nHash ) ); - m_bModifyPasswordHashSupported = sal_True; - } - catch( uno::Exception& ) - {} } catch( uno::Exception& ) {} - if ( ( bReadOnly && !m_bReadOnlySupported ) || ( nHash && !m_bModifyPasswordHashSupported ) ) + if ( ( bReadOnly && !m_bReadOnlySupported ) ) throw uno::RuntimeException(); // the user could provide the data, so it must be stored } @@ -235,15 +220,11 @@ public: if ( m_bRestoreSettings ) { ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) ); - ::rtl::OUString aModifyPasswordHashString( RTL_CONSTASCII_USTRINGPARAM( "ModifyPasswordHash" ) ); try { if ( m_bReadOnlySupported ) m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::makeAny( m_bPreserveReadOnly ) ); - - if ( m_bModifyPasswordHashSupported ) - m_xDocumentSettings->setPropertyValue( aModifyPasswordHashString, uno::makeAny( m_nPreserveHash ) ); } catch( uno::Exception& ) { @@ -272,7 +253,6 @@ class ModelData_Impl ::comphelper::SequenceAsHashMap m_aMediaDescrHM; sal_Bool m_bRecommendReadOnly; - sal_uInt16 m_nPasswordToModifyHash; public: ModelData_Impl( SfxStoringHelper& aOwner, @@ -291,7 +271,6 @@ public: ::comphelper::SequenceAsHashMap& GetMediaDescr() { return m_aMediaDescrHM; } sal_Bool IsRecommendReadOnly() { return m_bRecommendReadOnly; } - sal_uInt16 GetPasswordToModifyHash() { return m_nPasswordToModifyHash; } const ::comphelper::SequenceAsHashMap& GetDocProps(); @@ -346,8 +325,6 @@ ModelData_Impl::ModelData_Impl( SfxStoringHelper& aOwner, , m_pModulePropsHM( NULL ) , m_aMediaDescrHM( aMediaDescr ) , m_bRecommendReadOnly( sal_False ) -, m_nPasswordToModifyHash( 0 ) - { CheckInteractionHandler(); } @@ -1018,11 +995,6 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode, m_bRecommendReadOnly = ( pRecommendReadOnly && pRecommendReadOnly->GetValue() ); pDialogParams->ClearItem( SID_RECOMMENDREADONLY ); - SFX_ITEMSET_ARG( pDialogParams, pPassToModifyItem, SfxUInt16Item, SID_PASSWORDTOMODIFYHASH, sal_False ); - if ( pPassToModifyItem ) - m_nPasswordToModifyHash = pPassToModifyItem->GetValue(); - pDialogParams->ClearItem( SID_PASSWORDTOMODIFYHASH ); - uno::Sequence< beans::PropertyValue > aPropsFromDialog; TransformItems( nSlotID, *pDialogParams, aPropsFromDialog, NULL ); GetMediaDescr() << aPropsFromDialog; @@ -1607,7 +1579,7 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& // store the document and handle it's docinfo SvtSaveOptions aOptions; - DocumentSettingsGuard aSettingsGuard( aModelData.GetModel(), aModelData.IsRecommendReadOnly(), aModelData.GetPasswordToModifyHash(), nStoreMode & EXPORT_REQUESTED ); + DocumentSettingsGuard aSettingsGuard( aModelData.GetModel(), aModelData.IsRecommendReadOnly(), nStoreMode & EXPORT_REQUESTED ); if ( aOptions.IsDocInfoSave() && ( !aModelData.GetStorable()->hasLocation() diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 4cf5a5e7ad51..dc834debd533 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1242,12 +1242,12 @@ void SfxObjectShell::SetSaveVersionOnClose( sal_Bool bNew ) pImp->bSaveVersionOnClose = bNew; } -sal_uInt16 SfxObjectShell::GetModifyPasswordHash() const +sal_uInt32 SfxObjectShell::GetModifyPasswordHash() const { return pImp->m_nModifyPasswordHash; } -sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt16 nHash ) +sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt32 nHash ) { // Commented out before the solution for Saving process is found // if ( ( !IsReadOnly() && !IsReadOnlyUI() ) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index e1b37c119f1a..d3707636d5ea 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -74,6 +74,7 @@ #include #include #include +#include #include #include #include @@ -2731,6 +2732,12 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL uno::Reference< uno::XInterface >() ); } + SFX_ITEMSET_ARG( aParams, pModifyPasswordHashItem, SfxInt32Item, SID_MODIFYPASSWORDHASH, sal_False ); + sal_uInt32 nModifyPasswordHash = pModifyPasswordHashItem ? pModifyPasswordHashItem->GetValue() : 0; + aParams->ClearItem( SID_MODIFYPASSWORDHASH ); + sal_uInt32 nOldModifyPasswordHash = m_pData->m_pObjectShell->GetModifyPasswordHash(); + m_pData->m_pObjectShell->SetModifyPasswordHash( nModifyPasswordHash ); + // since saving a document modifies its DocumentInfo, the current // DocumentInfo must be saved on "SaveTo", so it can be restored // after saving @@ -2809,10 +2816,14 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL if ( !bSaveTo ) { m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl(); + m_pData->m_pObjectShell->SetModifyPasswordEntered(); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEASDOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVEASDOCDONE), m_pData->m_pObjectShell ) ); } else { + m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVETODOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVETODOCDONE), m_pData->m_pObjectShell ) ); } } @@ -2822,6 +2833,9 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL m_pData->m_pObjectShell->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Storing failed!" ) ) ); m_pData->m_pObjectShell->StoreLog(); + m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); + + SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOCFAILED : STR_EVENT_SAVEASDOCFAILED), m_pData->m_pObjectShell ) ); diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index 5aa0c793e12b..e170a7c27240 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -149,7 +149,7 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_Bool m_bIncomplEncrWarnShown; - sal_uInt16 m_nModifyPasswordHash; + sal_uInt32 m_nModifyPasswordHash; sal_Bool m_bModifyPasswordEntered; SfxObjectShell_Impl( SfxObjectShell& _rDocShell ); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index c8cf7bd8c6c8..ca95475cabe6 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -170,7 +170,7 @@ TYPEINIT1(SfxViewFrameItem, SfxPoolItem); //========================================================================= //------------------------------------------------------------------------- -static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt16 nPasswordHash ) +static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt32 nPasswordHash ) { sal_Bool bResult = !nPasswordHash; @@ -196,7 +196,7 @@ static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteracti xHandler->handle( rRequest ); if ( pPasswordRequest->isPassword() ) - bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), bMSType ) == nPasswordHash ); + bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pFilter->GetServiceName() ) ) == nPasswordHash ); else bCancel = sal_True; -- cgit From 928c651b68ccb995482edf00d27e825b880132bd Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 3 Jun 2010 10:47:56 +0200 Subject: cws tl79: missing includes added --- svx/source/dialog/hdft.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx index 729d4f748921..551f682abda0 100644 --- a/svx/source/dialog/hdft.cxx +++ b/svx/source/dialog/hdft.cxx @@ -37,6 +37,8 @@ #include #include +#include +#include #include #include "hdft.hrc" #include -- cgit From 1ad6bfaa61736ffd37b67c35506a7e68f0c63396 Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Thu, 3 Jun 2010 15:20:47 +0200 Subject: #i58213# get date styles from automatic styles in impress --- xmloff/source/draw/ximppage.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx index becfd05b1963..6c715b5ad77a 100644 --- a/xmloff/source/draw/ximppage.cxx +++ b/xmloff/source/draw/ximppage.cxx @@ -339,6 +339,9 @@ void SdXMLGenericPageContext::EndElement() else if( aDateTimeFormat.getLength() ) { const SdXMLStylesContext* pStyles = dynamic_cast< const SdXMLStylesContext* >( GetSdImport().GetShapeImport()->GetStylesContext() ); + if( !pStyles ) + pStyles = dynamic_cast< const SdXMLStylesContext* >( GetSdImport().GetShapeImport()->GetAutoStylesContext() ); + if( pStyles ) { const SdXMLNumberFormatImportContext* pSdNumStyle = -- cgit From 227d80375c8c851fe74a035d882ae316922ba6f0 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Fri, 4 Jun 2010 08:25:27 +0200 Subject: jl152#i77196# Improved progress handling on startup --- desktop/source/app/check_ext_deps.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index ebdc9ccdf51e..664e63c7f6ca 100755 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -192,7 +192,7 @@ void SilentCommandEnv::push( uno::Any const & rStatus ) if ( rStatus.hasValue() && ( rStatus >>= sText) ) { - if ( mnLevel <= 2 ) + if ( mnLevel <= 3 ) mpDesktop->SetSplashScreenText( sText ); else mpDesktop->SetSplashScreenProgress( ++mnProgress ); -- cgit From bd4822e3ac4d89de9d70af10a7afe22f0c7a5ebb Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 4 Jun 2010 13:49:01 +0200 Subject: vcl112: #i109307# add InitialPreference (thanks rene!) --- sysui/desktop/menus/base.desktop | 1 + sysui/desktop/menus/calc.desktop | 1 + sysui/desktop/menus/draw.desktop | 1 + sysui/desktop/menus/impress.desktop | 1 + sysui/desktop/menus/math.desktop | 1 + sysui/desktop/menus/writer.desktop | 1 + 6 files changed, 6 insertions(+) diff --git a/sysui/desktop/menus/base.desktop b/sysui/desktop/menus/base.desktop index 89d0a20adb00..9497666691fe 100644 --- a/sysui/desktop/menus/base.desktop +++ b/sysui/desktop/menus/base.desktop @@ -9,3 +9,4 @@ MimeType=application/vnd.oasis.opendocument.database;application/vnd.sun.xml.bas Name=%PRODUCTNAME Base GenericName=Database Development Comment=Manage databases, create queries and reports to track and manage your information by using Base. +InitialPreference=5 diff --git a/sysui/desktop/menus/calc.desktop b/sysui/desktop/menus/calc.desktop index e49b114b0954..bc0c9ee8b618 100644 --- a/sysui/desktop/menus/calc.desktop +++ b/sysui/desktop/menus/calc.desktop @@ -9,3 +9,4 @@ MimeType=application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.op Name=%PRODUCTNAME Calc GenericName=Spreadsheet Comment=Perform calculation, analyze information and manage lists in spreadsheets by using Calc. +InitialPreference=5 diff --git a/sysui/desktop/menus/draw.desktop b/sysui/desktop/menus/draw.desktop index 438d603e06a2..42db7c6f84a0 100644 --- a/sysui/desktop/menus/draw.desktop +++ b/sysui/desktop/menus/draw.desktop @@ -9,3 +9,4 @@ MimeType=application/vnd.oasis.opendocument.graphics;application/vnd.oasis.opend Name=%PRODUCTNAME Draw GenericName=Drawing Program Comment=Create and edit drawings, flow charts, and logos by using Draw. +InitialPreference=5 diff --git a/sysui/desktop/menus/impress.desktop b/sysui/desktop/menus/impress.desktop index 0aa3cdecdc04..90df11ac54f1 100644 --- a/sysui/desktop/menus/impress.desktop +++ b/sysui/desktop/menus/impress.desktop @@ -9,3 +9,4 @@ MimeType=application/vnd.oasis.opendocument.presentation;application/vnd.oasis.o Name=%PRODUCTNAME Impress GenericName=Presentation Comment=Create and edit presentations for slideshows, meeting and Web pages by using Impress. +InitialPreference=5 diff --git a/sysui/desktop/menus/math.desktop b/sysui/desktop/menus/math.desktop index 15a6d42efc2c..f97536d6ef04 100644 --- a/sysui/desktop/menus/math.desktop +++ b/sysui/desktop/menus/math.desktop @@ -9,3 +9,4 @@ MimeType=application/vnd.oasis.opendocument.formula;application/vnd.sun.xml.math Name=%PRODUCTNAME Math GenericName=Formula Editor Comment=Create and edit scientific formulas and equations by using Math. +InitialPreference=5 diff --git a/sysui/desktop/menus/writer.desktop b/sysui/desktop/menus/writer.desktop index 0184d916e2ab..1509de0fb402 100644 --- a/sysui/desktop/menus/writer.desktop +++ b/sysui/desktop/menus/writer.desktop @@ -9,3 +9,4 @@ MimeType=application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocum Name=%PRODUCTNAME Writer GenericName=Word Processor Comment=Create and edit text and graphics in letters, reports, documents and Web pages by using Writer. +InitialPreference=5 -- cgit From 88581862df4e46ee0f6515267ffeb46a53d1ba53 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 4 Jun 2010 16:19:25 +0200 Subject: jl152 #i77196# information upate provider now excludes online updates with unfulfilled dependencies --- desktop/source/deployment/manager/dp_informationprovider.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index ca2c7b5438cf..4cc43a8386d8 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -246,7 +246,14 @@ PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionI rtl::OUString sOnlineVersion; if (info.info.is()) - sOnlineVersion = info.version; + { + // check, if there are unsatisfied dependencies and ignore this online update + dp_misc::DescriptionInfoset infoset(mxContext, info.info); + uno::Sequence< uno::Reference< xml::dom::XElement > > + ds( dp_misc::Dependencies::check( infoset ) ); + if ( ! ds.getLength() ) + sOnlineVersion = info.version; + } rtl::OUString sVersionUser; rtl::OUString sVersionShared; -- cgit From 11eab80d847a072e49f6e13b022bb0d4a7cadd51 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Fri, 4 Jun 2010 18:22:13 +0200 Subject: calc55: #i112035# loading some old chart document fails --- xmloff/source/chart/SchXMLPlotAreaContext.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index ec5c4b2130c1..cea7bf40b299 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -1249,18 +1249,23 @@ void SchXMLAxisContext::CreateAxis() case SCH_XML_AXIS_Z: { + bool bSettingZAxisSuccedded = false; try { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasZAxis" ), aTrueBool ); + rtl::OUString sHasZAxis( rtl::OUString::createFromAscii( "HasZAxis" ) ); + xDiaProp->setPropertyValue( sHasZAxis, aTrueBool ); + xDiaProp->getPropertyValue( sHasZAxis ) >>= bSettingZAxisSuccedded; } catch( beans::UnknownPropertyException & ) { DBG_ERROR( "Couldn't turn on z axis" ); } - uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getZAxis(); + if( bSettingZAxisSuccedded ) + { + uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); + if( xSuppl.is()) + xProp = xSuppl->getZAxis(); + } } break; case SCH_XML_AXIS_UNDEF: -- cgit From 213132eb58be3236f379d0b3d13b415bf10d4bd1 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 4 Jun 2010 18:53:06 +0200 Subject: vcl112: #i111992# fill recent file list of menu button on demand --- framework/source/services/backingwindow.cxx | 9 ++++++++- framework/source/services/backingwindow.hxx | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index 19afbc29d843..962dbe2686c3 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -460,7 +460,7 @@ void BackingWindow::initBackground() maOpenButton.SetMenuMode( MENUBUTTON_MENUMODE_TIMED ); maOpenButton.SetSelectHdl( LINK( this, BackingWindow, SelectHdl ) ); - prepareRecentFileMenu(); + maOpenButton.SetActivateHdl( LINK( this, BackingWindow, ActivateHdl ) ); } void BackingWindow::initControls() @@ -1056,6 +1056,13 @@ IMPL_LINK( BackingWindow, SelectHdl, Button*, pButton ) return 0; } +IMPL_LINK( BackingWindow, ActivateHdl, Button*, pButton ) +{ + if( pButton == &maOpenButton ) + prepareRecentFileMenu(); + return 0; +} + struct ImplDelayedDispatch { Reference< XDispatch > xDispatch; diff --git a/framework/source/services/backingwindow.hxx b/framework/source/services/backingwindow.hxx index eaf5e9ec5a23..958ebfbb243e 100644 --- a/framework/source/services/backingwindow.hxx +++ b/framework/source/services/backingwindow.hxx @@ -159,6 +159,7 @@ namespace framework DECL_LINK( ClickHdl, Button* ); DECL_LINK( SelectHdl, Button* ); + DECL_LINK( ActivateHdl, Button* ); DECL_LINK( ToolboxHdl, void* ); void initControls(); -- cgit From 7b0105f0bfff2dde2398f7e8e910384898d65154 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Fri, 4 Jun 2010 20:08:33 +0200 Subject: calc55: #i112084# All charts in a Calc document are loaded when saving the document --- svx/inc/svx/unoshprp.hxx | 2 +- svx/source/unodraw/unoprov.cxx | 1 + svx/source/unodraw/unoshap4.cxx | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) mode change 100755 => 100644 svx/inc/svx/unoshprp.hxx diff --git a/svx/inc/svx/unoshprp.hxx b/svx/inc/svx/unoshprp.hxx old mode 100755 new mode 100644 index 27196079db07..ec8ecd485280 --- a/svx/inc/svx/unoshprp.hxx +++ b/svx/inc/svx/unoshprp.hxx @@ -160,7 +160,7 @@ #define OWN_ATTR_PAGE_NUMBER (OWN_ATTR_VALUE_START+65) #define OWN_ATTR_THUMBNAIL (OWN_ATTR_VALUE_START+66) #define OWN_ATTR_PERSISTNAME (OWN_ATTR_VALUE_START+67) -//#define OWN_ATTR_HASLEVELS (OWN_ATTR_VALUE_START+68) +#define OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT (OWN_ATTR_VALUE_START+68) #define OWN_ATTR_MEDIA_URL (OWN_ATTR_VALUE_START+69) #define OWN_ATTR_MEDIA_PREFERREDSIZE (OWN_ATTR_VALUE_START+70) #define OWN_ATTR_MEDIA_LOOP (OWN_ATTR_VALUE_START+71) diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx index 9a9717b34495..ea875d8d9427 100644 --- a/svx/source/unodraw/unoprov.cxx +++ b/svx/source/unodraw/unoprov.cxx @@ -478,6 +478,7 @@ SfxItemPropertyMapEntry* ImplGetSvxOle2PropertyMap() { MAP_CHAR_LEN("ThumbnailGraphicURL"), OWN_ATTR_THUMBNAIL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, { MAP_CHAR_LEN("Model"), OWN_ATTR_OLEMODEL , &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, { MAP_CHAR_LEN("EmbeddedObject"), OWN_ATTR_OLE_EMBEDDED_OBJECT , &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("EmbeddedObjectNoNewClient"),OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, { MAP_CHAR_LEN("OriginalSize"), OWN_ATTR_OLESIZE , &::getCppuType(( const ::com::sun::star::awt::Size*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, { MAP_CHAR_LEN("CLSID"), OWN_ATTR_CLSID , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, { MAP_CHAR_LEN("IsInternal"), OWN_ATTR_INTERNAL_OLE , &::getBooleanCppuType() , ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index cf3bdc6621f0..96804103f610 100644 --- a/svx/source/unodraw/unoshap4.cxx +++ b/svx/source/unodraw/unoshap4.cxx @@ -355,22 +355,26 @@ bool SvxOle2Shape::getPropertyValueImpl( const ::rtl::OUString& rName, const Sfx case OWN_ATTR_OLEMODEL: case OWN_ATTR_OLE_EMBEDDED_OBJECT: + case OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT: { SdrOle2Obj* pObj = dynamic_cast( mpObj.get() ); if( pObj ) { uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() ); if ( xObj.is() - && ( pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT || svt::EmbeddedObjectRef::TryRunningState( xObj ) ) ) + && ( pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT || pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT || svt::EmbeddedObjectRef::TryRunningState( xObj ) ) ) { // Discussed with CL fue to the before GetPaintingPageView // usage. Removed it, former fallback is used now + if ( pProperty->nWID == OWN_ATTR_OLEMODEL || pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT ) + { #ifdef DBG_UTIL - const sal_Bool bSuccess(pObj->AddOwnLightClient()); - OSL_ENSURE( bSuccess, "An object without client is provided!" ); + const sal_Bool bSuccess(pObj->AddOwnLightClient()); + OSL_ENSURE( bSuccess, "An object without client is provided!" ); #else - pObj->AddOwnLightClient(); + pObj->AddOwnLightClient(); #endif + } if ( pProperty->nWID == OWN_ATTR_OLEMODEL ) rValue <<= pObj->GetObjRef()->getComponent(); -- cgit From cfdbe09c28e21212d4223c13daf43688adca8c5d Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 7 Jun 2010 13:31:53 +0200 Subject: vcl112: #b6956353# add ToTop call in case document is already visible --- framework/source/loadenv/loadenv.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index b9f1d2c8a09a..2d6b7ceea668 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -1774,7 +1774,10 @@ void LoadEnv::impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::X ::comphelper::ConfigurationHelper::E_READONLY); a >>= bForceFrontAndFocus; - pWindow->Show(sal_True, (bForceFrontAndFocus || bForceToFront) ? SHOW_FOREGROUNDTASK : 0 ); + if( pWindow->IsVisible() && (bForceFrontAndFocus || bForceToFront) ) + pWindow->ToTop(); + else + pWindow->Show(sal_True, (bForceFrontAndFocus || bForceToFront) ? SHOW_FOREGROUNDTASK : 0 ); } /* #i19976# -- cgit From 77d761f74d1147b013325487753255846aa56b96 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 7 Jun 2010 17:08:48 +0200 Subject: jl152 #i77196# fixing merge conflicts --- basic/source/inc/namecont.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 4d31483ab513..c475535143d2 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -58,7 +58,7 @@ #include #include -#include +#include #include #include @@ -67,7 +67,7 @@ class BasicManager; namespace basic { -typedef ::cppu::WeakComponentImplHelper7< +typedef ::cppu::WeakComponentImplHelper8< ::com::sun::star::lang::XInitialization, ::com::sun::star::script::XStorageBasedLibraryContainer, ::com::sun::star::script::XLibraryContainerPassword, -- cgit From ba8229cc9d9a4c48a9e0a01611354f64ab5fd069 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 8 Jun 2010 12:35:50 +0200 Subject: tl78: #i105076# fix typo --- sfx2/sdi/sfx.sdi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 1fc2cc16962d..a19ea0fb8dfc 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3594,7 +3594,7 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER ] //-------------------------------------------------------------------------- -SfxUInt16Item PasswordToModifyHash SID_MODIFYPASSWORDHASH +SfxInt32Item PasswordToModifyHash SID_MODIFYPASSWORDHASH [ /* flags: */ -- cgit From ab46983bad9dfb4f6af22487e55904938638fc21 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Tue, 8 Jun 2010 13:15:18 +0200 Subject: vcl112:#i111580# startcenter supports opening (installing) of extensions --- sysui/desktop/menus/startcenter.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysui/desktop/menus/startcenter.desktop b/sysui/desktop/menus/startcenter.desktop index b6067494a68c..6302a5b16289 100644 --- a/sysui/desktop/menus/startcenter.desktop +++ b/sysui/desktop/menus/startcenter.desktop @@ -5,7 +5,7 @@ Icon=startcenter Type=Application Categories=Office;X-Red-Hat-Base;X-SuSE-Core-Office;X-MandrivaLinux-Office-Other; Exec=openoffice %U -MimeType= +MimeType=application/vnd.openofficeorg.extension; Name=%PRODUCTNAME GenericName=Office Comment=The office productivity suite compatible to the open and standardized ODF document format. Supported by Sun Microsystems. -- cgit From d0d67b203b9f306f3ac10fcb5019e82127a18610 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 8 Jun 2010 16:29:32 +0200 Subject: cws tl78: more space for filename added to password dialog --- uui/source/passworddlg.src | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/uui/source/passworddlg.src b/uui/source/passworddlg.src index 5eba2fdb2c5b..33767057e1bd 100755 --- a/uui/source/passworddlg.src +++ b/uui/source/passworddlg.src @@ -41,7 +41,7 @@ ModalDialog DLG_UUI_PASSWORD Moveable = TRUE ; OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT( 145, 75 ); + Size = MAP_APPFONT( 145, 91 ); Text [ en-US ] = "Enter password"; FixedText FT_PASSWORD @@ -53,15 +53,21 @@ ModalDialog DLG_UUI_PASSWORD Edit ED_PASSWORD { - Pos = MAP_APPFONT( 3, 35 ); + Pos = MAP_APPFONT( 3, 51 ); Size = MAP_APPFONT( 139, 13 ); Border = TRUE ; PassWord = TRUE ; }; + FixedLine FL_FIXED_LINE_1 + { + Pos = MAP_APPFONT( 0, 66 ); + Size = MAP_APPFONT( 145, 6 ); + }; + OKButton BTN_PASSWORD_OK { - Pos = MAP_APPFONT( 27, 56 ); + Pos = MAP_APPFONT( 27, 72 ); Size = MAP_APPFONT( 37, 15 ); DefButton = TRUE ; DefButton = TRUE; @@ -69,22 +75,16 @@ ModalDialog DLG_UUI_PASSWORD CancelButton BTN_PASSWORD_CANCEL { - Pos = MAP_APPFONT( 66, 56 ); + Pos = MAP_APPFONT( 66, 72 ); Size = MAP_APPFONT( 37, 15 ); }; HelpButton BTN_PASSWORD_HELP { - Pos = MAP_APPFONT( 105, 56 ); + Pos = MAP_APPFONT( 105, 72 ); Size = MAP_APPFONT( 37, 15 ); }; - FixedLine FL_FIXED_LINE_1 - { - Pos = MAP_APPFONT( 0, 50 ); - Size = MAP_APPFONT( 145, 6 ); - }; - String STR_ENTER_PASSWORD_TO_OPEN { Text [ en-US ] = "Enter password to open file: \n"; -- cgit From db2236600ffc64b188d23f43fb88ee0bf13a680a Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 8 Jun 2010 17:01:41 +0200 Subject: tl78: #i110383# fix reload functionality --- sfx2/inc/sfx2/objsh.hxx | 2 +- sfx2/source/dialog/filedlghelper.cxx | 6 +++--- sfx2/source/doc/objcont.cxx | 4 ++-- sfx2/source/doc/objmisc.cxx | 2 +- sfx2/source/view/viewfrm.cxx | 13 ++++++++++--- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index d8a8ea2f678a..95e8f21c8d86 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -717,7 +717,7 @@ public: SAL_DLLPRIVATE sal_uInt16 ImplCheckSignaturesInformation( const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >& aInfos ); SAL_DLLPRIVATE void CheckEncryption_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); - SAL_DLLPRIVATE void SetModifyPasswordEntered(); + SAL_DLLPRIVATE void SetModifyPasswordEntered( sal_Bool bEntered = sal_True ); SAL_DLLPRIVATE sal_Bool IsModifyPasswordEntered(); SAL_DLLPRIVATE void InitBasicManager_Impl(); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 759c47598f9f..072729648628 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1528,7 +1528,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, mbPwdCheckBoxState = ( pPassItem != NULL ); // in case the document has password to modify, the dialog should be shown - SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUInt32Item, SID_MODIFYPASSWORDHASH, FALSE ); + SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxInt32Item, SID_MODIFYPASSWORDHASH, FALSE ); mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); } @@ -1660,9 +1660,9 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); // the empty password has 0 as Hash - sal_uInt16 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); + sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); if ( nHash ) - rpSet->Put( SfxInt32Item( SID_MODIFYPASSWORDHASH, (sal_Int32)nHash ) ); + rpSet->Put( SfxInt32Item( SID_MODIFYPASSWORDHASH, nHash ) ); } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index dc834debd533..547198f60ace 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1262,9 +1262,9 @@ sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt32 nHash ) // return sal_False; } -void SfxObjectShell::SetModifyPasswordEntered() +void SfxObjectShell::SetModifyPasswordEntered( sal_Bool bEntered ) { - pImp->m_bModifyPasswordEntered = sal_True; + pImp->m_bModifyPasswordEntered = bEntered; } sal_Bool SfxObjectShell::IsModifyPasswordEntered() diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 76aed9d11ed1..afcaa1614f2c 100755 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1389,7 +1389,7 @@ void SfxObjectShell::FinishedLoading( sal_uInt16 nFlags ) if( !IsAbortingImport() ) PositionView_Impl(); - if ( GetModifyPasswordHash() ) + if ( GetModifyPasswordHash() && !IsModifyPasswordEntered() ) SetReadOnly(); // Salvage diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index ca95475cabe6..a80741df13a6 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -714,6 +714,10 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } xNewObj = SfxObjectShell::CreateObject( pFilter->GetServiceName(), SFX_CREATE_MODE_STANDARD ); + + if ( xOldObj->IsModifyPasswordEntered() ) + xNewObj->SetModifyPasswordEntered(); + uno::Sequence < beans::PropertyValue > aLoadArgs; TransformItems( SID_OPENDOC, *pNewSet, aLoadArgs ); try @@ -769,6 +773,12 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } else { + if ( xNewObj->GetModifyPasswordHash() && xNewObj->GetModifyPasswordHash() != xOldObj->GetModifyPasswordHash() ) + { + xNewObj->SetModifyPasswordEntered( sal_False ); + xNewObj->SetReadOnly(); + } + if ( xNewObj->IsDocShared() ) { // the file is shared but the closing can change the sharing control file @@ -781,10 +791,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) TransformItems( SID_OPENDOC, *xNewObj->GetMedium()->GetItemSet(), aLoadArgs ); UpdateDocument_Impl(); - } - if ( xNewObj.Is() ) - { try { while ( !aViewFrames.empty() ) -- cgit From b5774ca9c4b802578b24120a0f8eb6625d2173ef Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 8 Jun 2010 19:15:36 +0200 Subject: cws tl78: #i109634# additional dialog parameter --- uui/source/iahndl-authentication.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index 027a5cced169..008acadea0ae 100755 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -534,7 +534,7 @@ executePasswordDialog( const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create(); - AbstractPasswordToOpenModifyDialog *pTmp = pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen ); + AbstractPasswordToOpenModifyDialog *pTmp = pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen, bIsPasswordToModify ); std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog( pTmp ); rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); -- cgit From 6fd692c5e9d61acb3613ef0f783fc232ecef67ef Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 8 Jun 2010 18:02:35 +0200 Subject: cws tl79: #i110048# help ids added --- uui/source/ids.hrc | 30 +++++++++++++++++++----------- uui/source/logindlg.src | 7 +++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc index 9bf5856bc270..808033ec9d4c 100644 --- a/uui/source/ids.hrc +++ b/uui/source/ids.hrc @@ -167,17 +167,25 @@ #define ERRCODE_UUI_SSLWARN_INVALID_1 (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 1) #define TITLE_UUI_SSLWARN_INVALID (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 3) -#define HID_DLG_LOGIN (HID_UUI_START + 0) -#define HID_DLG_COOKIES (HID_UUI_START + 1) -#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START+2) -#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START+3) -#define HID_DLG_FILTER_SELECT (HID_UUI_START+4) -#define HID_DLG_PASSWORD_UUI (HID_UUI_START+5) -#define HID_DLG_PASSWORD_CRT (HID_UUI_START+6) -#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START+7) -#define HID_DLG_SSLWARN_UUI (HID_UUI_START+8) -#define HID_XMLSECDLG_MACROWARN (HID_UUI_START+9) -#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START+10) +#define HID_DLG_LOGIN (HID_UUI_START + 0) +#define HID_DLG_COOKIES (HID_UUI_START + 1) +#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START + 2) +#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START + 3) +#define HID_DLG_FILTER_SELECT (HID_UUI_START + 4) +#define HID_DLG_PASSWORD_UUI (HID_UUI_START + 5) +#define HID_DLG_PASSWORD_CRT (HID_UUI_START + 6) +#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START + 7) +#define HID_DLG_SSLWARN_UUI (HID_UUI_START + 8) +#define HID_XMLSECDLG_MACROWARN (HID_UUI_START + 9) +#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START +10) + +#define HID_LOGIN_DLG_PATH (HID_UUI_START +11) +#define HID_LOGIN_DLG_BROWSE (HID_UUI_START +12) +#define HID_LOGIN_DLG_USER_NAME (HID_UUI_START +13) +#define HID_LOGIN_DLG_PASSWORD (HID_UUI_START +14) +#define HID_LOGIN_DLG_ACCOUNT (HID_UUI_START +15) +#define HID_LOGIN_DLG_REMEMBER_PASSWORD (HID_UUI_START +16) +#define HID_LOGIN_DLG_USE_SYSTEM_CREDENTIALS (HID_UUI_START +17) // HID_UUI_END (aka HID_CHAOS_NEW_DATABASE) is reserved in // sfx2/util/hidother.src diff --git a/uui/source/logindlg.src b/uui/source/logindlg.src index c2683ea3d94c..bf6a97c3b0ff 100755 --- a/uui/source/logindlg.src +++ b/uui/source/logindlg.src @@ -93,12 +93,14 @@ ModalDialog DLG_UUI_LOGIN Edit ED_LOGIN_PATH { + HelpId = HID_LOGIN_DLG_PATH; Border = TRUE ; Pos = MAP_APPFONT( 6 , 95 ) ; Size = MAP_APPFONT( 112 , 12 ) ; }; PushButton BTN_LOGIN_PATH { + HelpId = HID_LOGIN_DLG_BROWSE; Pos = MAP_APPFONT( 121 , 94 ) ; Size = MAP_APPFONT( 50 , 14 ) ; Text = "~Browse..." ; @@ -113,6 +115,7 @@ ModalDialog DLG_UUI_LOGIN Edit ED_LOGIN_USERNAME { + HelpId = HID_LOGIN_DLG_USER_NAME; Border = TRUE ; Pos = MAP_APPFONT( 6 , 121 ) ; Size = MAP_APPFONT( 165 , 12 ) ; @@ -127,6 +130,7 @@ ModalDialog DLG_UUI_LOGIN Edit ED_LOGIN_PASSWORD { + HelpId = HID_LOGIN_DLG_PASSWORD; Border = TRUE ; Pos = MAP_APPFONT( 6 , 147 ) ; Size = MAP_APPFONT( 165 , 12 ) ; @@ -142,6 +146,7 @@ ModalDialog DLG_UUI_LOGIN Edit ED_LOGIN_ACCOUNT { + HelpId = HID_LOGIN_DLG_ACCOUNT; Border = TRUE ; Pos = MAP_APPFONT( 6 , 173 ) ; Size = MAP_APPFONT( 165 , 12 ) ; @@ -150,6 +155,7 @@ ModalDialog DLG_UUI_LOGIN CheckBox CB_LOGIN_SAVEPASSWORD { + HelpId = HID_LOGIN_DLG_REMEMBER_PASSWORD; Pos = MAP_APPFONT( 6 , 190 ) ; Size = MAP_APPFONT( 165 , 10 ) ; Text [ en-US ] = "~Remember password" ; @@ -157,6 +163,7 @@ ModalDialog DLG_UUI_LOGIN CheckBox CB_LOGIN_USESYSCREDS { + HelpId = HID_LOGIN_DLG_USE_SYSTEM_CREDENTIALS; Pos = MAP_APPFONT( 6 , 203 ) ; Size = MAP_APPFONT( 165 , 10 ) ; Text [ en-US ] = "~Use system credentials" ; -- cgit From d148b9b253a4dc439d7572877afd7b43aa943ca8 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 8 Jun 2010 18:04:16 +0200 Subject: cws tl79: #i110254# help ids added --- sfx2/source/dialog/securitypage.src | 15 ++++++++++++--- sfx2/source/inc/helpid.hrc | 10 +++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src index 7c0fffd96057..fee60404d01c 100755 --- a/sfx2/source/dialog/securitypage.src +++ b/sfx2/source/dialog/securitypage.src @@ -54,6 +54,7 @@ TabPage TP_DOCINFOSECURITY }; Edit PASSWORD_TO_OPEN_ED { + HelpId = HID_SECURITYTAB_PASSWORD_TO_OPEN; Pos = MAP_APPFONT( 100, 18 ); Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); Border = TRUE; @@ -67,6 +68,7 @@ TabPage TP_DOCINFOSECURITY }; Edit CONFIRM_PASSWORD_TO_OPEN_ED { + HelpId = HID_SECURITYTAB_CONFIRM_PASSWORD_TO_OPEN; Pos = MAP_APPFONT( 100, 32 ); Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); Border = TRUE; @@ -76,9 +78,11 @@ TabPage TP_DOCINFOSECURITY { Pos = MAP_APPFONT( 12, 48 ); Size = MAP_APPFONT( 236, 3 * RSC_CD_FIXEDTEXT_HEIGHT ); - Text [ en-US ] = "Note: If you lose or forget the password, it cannot be recovered."\ - "It is advisable to keep passwords in a safe place."\ - "Passwords are case-sensitive."; + Text [ en-US ] = + "Note: After a password has been set, the document will only open "\ + "with the password. Should you lose the password, there will be "\ + "no way to recover the document. Please also note that this password "\ + "is case-sensitive."; WordBreak = TRUE; }; FixedLine PASSWORD_TO_MODIFY_FL @@ -95,6 +99,7 @@ TabPage TP_DOCINFOSECURITY }; Edit PASSWORD_TO_MODIFY_ED { + HelpId = HID_SECURITYTAB_PASSWORD_TO_MODIFY; Pos = MAP_APPFONT( 100, 90 ); Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); Border = TRUE; @@ -108,6 +113,7 @@ TabPage TP_DOCINFOSECURITY }; Edit CONFIRM_PASSWORD_TO_MODIFY_ED { + HelpId = HID_SECURITYTAB_CONFIRM_PASSWORD_TO_MODIFY; Pos = MAP_APPFONT( 100, 104 ); Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); Border = TRUE; @@ -121,18 +127,21 @@ TabPage TP_DOCINFOSECURITY }; CheckBox OPEN_READONLY_CB { + HelpId = HID_SECURITYTAB_OPEN_FILE_READONLY; Pos = MAP_APPFONT( 12, 133 ); Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); Text [ en-US ] = "~Open file read-only"; }; CheckBox RECORD_CHANGES_CB { + HelpId = HID_SECURITYTAB_RECORD_CHANGES; Pos = MAP_APPFONT( 12, 147 ); Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); Text [ en-US ] = "Record ~changes"; }; PushButton CHANGE_PROTECTION_PB { + HelpId = HID_SECURITYTAB_PROTECTION; Pos = MAP_APPFONT( 194, 145 ); Size = MAP_APPFONT( 60, RSC_CD_PUSHBUTTON_HEIGHT ); }; diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc index f09ac7e94ecc..4c9aa3fd7f63 100755 --- a/sfx2/source/inc/helpid.hrc +++ b/sfx2/source/inc/helpid.hrc @@ -346,7 +346,15 @@ #define HID_CTRL_CUSTOMPROPS_YES_NO (HID_SFX_START + 326) #define HID_DLG_CUSTOMPROPS_DURATION (HID_SFX_START + 327) -#define ACT_SFX_HID_END HID_DLG_CUSTOMPROPS_DURATION +#define HID_SECURITYTAB_PASSWORD_TO_OPEN (HID_SFX_START + 328) +#define HID_SECURITYTAB_CONFIRM_PASSWORD_TO_OPEN (HID_SFX_START + 329) +#define HID_SECURITYTAB_PASSWORD_TO_MODIFY (HID_SFX_START + 330) +#define HID_SECURITYTAB_CONFIRM_PASSWORD_TO_MODIFY (HID_SFX_START + 331) +#define HID_SECURITYTAB_OPEN_FILE_READONLY (HID_SFX_START + 332) +#define HID_SECURITYTAB_RECORD_CHANGES (HID_SFX_START + 333) +#define HID_SECURITYTAB_PROTECTION (HID_SFX_START + 334) + +#define ACT_SFX_HID_END HID_SECURITYTAB_PROTECTION // "Uberlaufpr"ufung -------------------------------------------------------- -- cgit From dad227c459a2329bf6da8eec4847ce8fca228575 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 9 Jun 2010 14:04:54 +0200 Subject: tl78: #i110383# fix condition --- sfx2/source/dialog/filedlghelper.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 072729648628..569c0ddb163e 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1647,7 +1647,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; - ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) ) ); + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) != 0 ) ); uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); xInteractionHandler->handle( rRequest ); -- cgit From 6fa6c701a54c78715c7df2cc771875313c4d71d6 Mon Sep 17 00:00:00 2001 From: Frank Peters Date: Wed, 9 Jun 2010 18:24:55 +0200 Subject: #i111721# --- readlicense_oo/docs/readme.xsl | 149 ++++++++++++------- readlicense_oo/docs/readme/readme.xrm | 270 +++++++++++++++++----------------- 2 files changed, 235 insertions(+), 184 deletions(-) diff --git a/readlicense_oo/docs/readme.xsl b/readlicense_oo/docs/readme.xsl index cb13fb08ff83..4e77fa522c3d 100644 --- a/readlicense_oo/docs/readme.xsl +++ b/readlicense_oo/docs/readme.xsl @@ -5,8 +5,8 @@ - - + + @@ -15,30 +15,40 @@ - - + + + + + + - - + + + + + + + + + - - + - - - + + + - + - - + + @@ -46,83 +56,118 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - + - + + - - - + + + + + + + + ---------------------------------------------------------------------------------------------------------- - + - - - -* - - - - + + + + + + + + +* + + + + + + + + + + - + + - + + - + + ====================================================================== - + + + ====================================================================== - + + ---------------------------------------------------------------------- - + + + ---------------------------------------------------------------------- - + + - + + + ---------------------------------------------------------------------- - + - + diff --git a/readlicense_oo/docs/readme/readme.xrm b/readlicense_oo/docs/readme/readme.xrm index 43603ed2159b..ac9ba071362e 100755 --- a/readlicense_oo/docs/readme/readme.xrm +++ b/readlicense_oo/docs/readme/readme.xrm @@ -1,8 +1,12 @@ - + + - + + ${PRODUCTNAME} Readme File + +
    -

    ${PRODUCTNAME} ${PRODUCTVERSION} ReadMe

    -

    For latest updates to this readme file, see http://www.openoffice.org/welcome/readme.html

    +

    For latest updates to this readme file, see http://www.openoffice.org/welcome/readme.html +

    This file contains important information about this program. Please read this information very carefully before starting work.

    -

    The OpenOffice.org Community, responsible for the development of this product, would like to invite you to participate as a community member. As a new user, you can check out the ${PRODUCTNAME} site with helpful user information at http://www.openoffice.org/about_us/introduction.html

    +

    The OpenOffice.org Community, responsible for the development of this product, would like to invite you to participate as a community member. As a new user, you can check out the ${PRODUCTNAME} site with helpful user information at http://www.openoffice.org/about_us/introduction.html +

    Also read the sections below about getting involved in the OpenOffice.org project.

    -

    Is ${PRODUCTNAME} really free for any user?

    -

    ${PRODUCTNAME} is free for use by everybody. You may take this copy of ${PRODUCTNAME} and install it on as many computers as you like, and use it for any purpose you like (including commercial, government, public administration and educational use). For further details see the license text delivered together with ${PRODUCTNAME} or http://www.openoffice.org/license.html

    - +

    ${PRODUCTNAME} is free for use by everybody. You may take this copy of ${PRODUCTNAME} and install it on as many computers as you like, and use it for any purpose you like (including commercial, government, public administration and educational use). For further details see the license text delivered together with ${PRODUCTNAME} or http://www.openoffice.org/license.html +

    Why is ${PRODUCTNAME} free for any user?

    You can use this copy of ${PRODUCTNAME} today free of charge because individual contributors and corporate sponsors have designed, developed, tested, translated, documented, supported, marketed, and helped in many other ways to make ${PRODUCTNAME} what it is today - the world's leading open-source office software.

    If you appreciate their efforts, and would like to ensure OpenOffice.org continues into the future, please consider contributing to the project - see http://contributing.openoffice.org for details. Everyone has a contribution to make.

    -
    -

    Notes on Installation

    -

    System Requirements

    -
    +
    • MacOSX 10.4 (Tiger) or higher

    • +
    • Intel processor

    • +
    • 512 MB RAM

    • +
    • Up to 1.5 GB available hard disk space

    • +
    • 1024 x 768 graphic device with 256 colors (higher resolution recommended)

    -
    +
    • Microsoft Windows 2000 (Service Pack 4 or higher), XP, Vista, or Windows 7

    • +
    • Pentium compatible PC (Pentium III or Athlon recommended)

    • +
    • 256 MB RAM (512 MB RAM recommended)

    • +
    • Up to 1.5 GB available hard disk space

    • +
    • 1024x768 resolution (higher resolution recommended), at least 256 colors

    -

    Please be aware that administrator rights are needed for the installation process.

    - +

    Please be aware that administrator rights are needed for the installation process.

    Registration of ${PRODUCTNAME} as default application for Microsoft Office formats can be forced or suppressed by using the following command line switches with the installer:

    • -

      /msoreg=1 will force registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

      +

      + /msoreg=1 will force registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

    • +
    • -

      /msoreg=0 will suppress registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

      +

      + /msoreg=0 will suppress registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

    -

    If you perform an administrative installation using setup /a, you need to make sure that the file msvc90.dll is installed on the system. This file is required for ${PRODUCTNAME} to start after an administrative installation. You can get the file from http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF

    -

    Please be aware that administrator rights are needed for the installation process.

    +

    If you perform an administrative installation using setup /a, you need to make sure that the file msvc90.dll is installed on the system. This file is required for ${PRODUCTNAME} to start after an administrative installation. You can get the file from http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF +

    +

    Please be aware that administrator rights are needed for the installation process.

    -
    +
    • Solaris 10 operating system (SPARC platform) or higher

    • +
    • 256 MB RAM (512 MB RAM recommended)

    • +
    • Up to 1.55 GB available hard disk space

    • +
    • X Server with 1024x768 resolution (higher resolution recommended), with at least 256 colors

    • +
    • Window Manager

    • +
    • Gnome 2.6 or higher, with the gail 1.8.6 and the at-spi 1.7 packages, required for support of assistive technology tools (AT tools)

    -
    +
    • Solaris 10 operating system (x86 platform) or higher

    • +
    • 256 MB RAM (512 MB RAM recommended)

    • +
    • Up to 1.55 GB available hard disk space

    • +
    • X Server with 1024x768 resolution (higher resolution recommended), with at least 256 colors

    • +
    • Window Manager

    • +
    • Gnome 2.6 or higher, with the gail 1.8.6 and the at-spi 1.7 packages, required for support of assistive technology tools (AT tools)

    -
    -
    +
    +
    • Linux Kernel version 2.6.18 or higher

    • +
    • glibc2 version 2.5 or higher

    • +
    • gtk version 2.10.4 or higher

    • +
    • Pentium compatible PC (Pentium III or Athlon recommended)

    • +
    • 256 MB RAM (512 MB RAM recommended)

    • +
    • Up to 1.55 GB available hard disk space

    • +
    • X Server with 1024x768 resolution (higher resolution recommended), with at least 256 colors

    • +
    • Window Manager

    • +
    • Gnome 2.16 or higher, with the gail 1.8.6 and the at-spi 1.7 packages, required for support of assistive technology tools (AT tools)

    There is a wide variety of Linux distributions, and even within the same distribution there may be different installation options (KDE vs Gnome, etc.). Some distributions ship with their own ‘native’ version of ${PRODUCTNAME}, which may have different features from this Community ${PRODUCTNAME}. Sometimes you can install the Community ${PRODUCTNAME} alongside the ‘native’ version. However, it’s usually safer to remove the ‘native’ version before installing this Community version. Consult the documentation for your distribution for details of how to do this.

    -

    It is recommended that you always backup your system before you remove or install software.

    -
    - -

    Please make sure you have enough free memory in the temporary directory on your system and that read, write and run access rights have been granted. Close all other programs before starting the installation.

    -
    - -
    -

    Extension Database Incompatibility

    -

    The Berkeley database engine has been upgraded in this version of ${PRODUCTNAME}. The database engine upgrade introduces an incompatibility with user data for installed extensions for ${PRODUCTNAME} versions prior to 3.2 that may require your action if you downgrade your version of ${PRODUCTNAME}.

    -

    This version of ${PRODUCTNAME} will convert your extension database to the new Berkeley database format when extensions are installed or removed. After this conversion, the database can no longer be read by earlier versions of ${PRODUCTNAME}. Downgrading to an earlier version may result in a dysfunctional installation.

    -

    If you downgrade to an earlier version of ${PRODUCTNAME}, you must remove the user data directory {user data}/uno_packages, for example ~/.openoffice.org/3/user/uno_packages, and reinstall all extensions.

    -
    - -
    -

    Problems During Program Startup

    - -
    -

    If you experience ${PRODUCTNAME} startup problems (most notably while using Gnome) please 'unset' the SESSION_MANAGER environment variable inside the shell you use to start ${PRODUCTNAME}. This can be done by adding the line "unset SESSION_MANAGER" to the beginning of the soffice shell script found in the "[office folder]/program" directory.

    -
    - -

    Difficulties starting ${PRODUCTNAME} (e.g. applications hang) as well as problems with the screen display are often caused by the graphics card driver. If these problems occur, please update your graphics card driver or try using the graphics driver delivered with your operating system. Difficulties displaying 3D objects can often be solved by deactivating the option "Use OpenGL" under 'Tools - Options - ${PRODUCTNAME} - View - 3D view'.

    -
    - -
    -

    ALPS/Synaptics notebook touchpads in Windows

    -

    Due to a Windows driver issue, you cannot scroll through ${PRODUCTNAME} documents when you slide your finger across an ALPS/Synaptics touchpad.

    -

    To enable touchpad scrolling, add the following lines to the "C:\Program Files\Synaptics\SynTP\SynTPEnh.ini" configuration file, and restart your computer:

    -

    [${PRODUCTNAME}]

    -

    FC = "SALFRAME"

    -

    SF = 0x10000000

    -

    SF |= 0x00004000

    -

    The location of the configuration file might vary on different versions of Windows.

    +

    It is recommended that you always backup your system before you remove or install software.

    +

    Please make sure you have enough free memory in the temporary directory on your system and that read, write and run access rights have been granted. Close all other programs before starting the installation.

    +
    -
    -

    Mozilla Address Book Driver

    -

    The Mozilla address book driver requires the SUNWzlib package. This package is not part of the minimum Solaris operating system installation. If you require access to the Mozilla address book, then add this package to your Solaris operating system using the command "pkgadd" from the installation CD.

    -
    +
    +

    Extension Database Incompatibility

    +

    The Berkeley database engine has been upgraded in this version of ${PRODUCTNAME}. The database engine upgrade introduces an incompatibility with user data for installed extensions for ${PRODUCTNAME} versions prior to 3.2 that may require your action if you downgrade your version of ${PRODUCTNAME}.

    +

    This version of ${PRODUCTNAME} will convert your extension database to the new Berkeley database format when extensions are installed or removed. After this conversion, the database can no longer be read by earlier versions of ${PRODUCTNAME}. Downgrading to an earlier version may result in a dysfunctional installation.

    +

    If you downgrade to an earlier version of ${PRODUCTNAME}, you must remove the user data directory {user data}/uno_packages, for example ~/.openoffice.org/3/user/uno_packages, and reinstall all extensions.

    +
    -
    -

    Shortcut Keys

    -

    Only shortcut keys (key combinations) not used by the operating system can be used in ${PRODUCTNAME}. If a key combination in ${PRODUCTNAME} does not work as described in the ${PRODUCTNAME} Help, check if that shortcut is already used by the operating system. To rectify such conflicts, you can change the keys assigned by your operating system. Alternatively, you can change almost any key assignment in ${PRODUCTNAME}. For more information on this topic, refer to the ${PRODUCTNAME} Help or the Help documention of your operating system.

    - -
    -

    The application help of ${PRODUCTNAME} may use shortcut combinations for PC keyboards only.

    -
    - -

    Due to a conflict with input method switching on multiple platforms, the following shortcut keys required to be changed at last minute:

    - -
    -
      -
    • -

      Cmd-Space is now Cmd-Shift-Space

      -
    • -
    • -

      Cmd-Shift-Space is now Cmd-M

      -
    • -
    -
    - -
    -
      -
    • -

      Ctrl-Space is now Ctrl-Shift-Space

      -
    • -
    • -

      Ctrl-Shift-Space is now Ctrl-M

      -
    • -
    -
    +
    +

    Problems During Program Startup

    +
    +

    If you experience ${PRODUCTNAME} startup problems (most notably while using Gnome) please 'unset' the SESSION_MANAGER environment variable inside the shell you use to start ${PRODUCTNAME}. This can be done by adding the line "unset SESSION_MANAGER" to the beginning of the soffice shell script found in the "[office folder]/program" directory.

    +

    Difficulties starting ${PRODUCTNAME} (e.g. applications hang) as well as problems with the screen display are often caused by the graphics card driver. If these problems occur, please update your graphics card driver or try using the graphics driver delivered with your operating system. Difficulties displaying 3D objects can often be solved by deactivating the option "Use OpenGL" under 'Tools - Options - ${PRODUCTNAME} - View - 3D view'.

    +
    -
    -

    File Locking

    -

    File locking is enabled by default in ${PRODUCTNAME}. On a network that uses the Network File System protocol (NFS), the locking daemon for NFS clients must be active. To disable file locking, edit the soffice script and change the line "export SAL_ENABLE_FILE_LOCKING" to "# export SAL_ENABLE_FILE_LOCKING". If you disable file locking, the write access of a document is not restricted to the user who first opens the document.

    -

    Warning: The activated file locking feature can cause problems with Solaris 2.5.1 and 2.7 used in conjunction with Linux NFS 2.0. If your system environment has these parameters, we strongly recommend that you avoid using the file locking feature. Otherwise, ${PRODUCTNAME} will hang when you try to open a file from a NFS mounted directory from a Linux computer.

    -
    +
    +

    ALPS/Synaptics notebook touchpads in Windows

    +

    Due to a Windows driver issue, you cannot scroll through ${PRODUCTNAME} documents when you slide your finger across an ALPS/Synaptics touchpad.

    +

    To enable touchpad scrolling, add the following lines to the "C:\Program Files\Synaptics\SynTP\SynTPEnh.ini" configuration file, and restart your computer:

    +

    [${PRODUCTNAME}]

    +

    FC = "SALFRAME"

    +

    SF = 0x10000000

    +

    SF |= 0x00004000

    +

    The location of the configuration file might vary on different versions of Windows.

    +
    -
    -

    Problems When Sending Documents as E-mails From ${PRODUCTNAME}

    -

    When sending a document via 'File - Send - Document as E-mail' or 'Document as PDF Attachment' problems might occur (program crashes or hangs). This is due to the Windows system file "Mapi" (Messaging Application Programming Interface) which causes problems in some file versions. Unfortunately, the problem cannot be narrowed down to a certain version number. For more information visit http://www.microsoft.com to search the Microsoft Knowledge Base for "mapi dll".

    -
    +
    +

    Mozilla Address Book Driver

    +

    The Mozilla address book driver requires the SUNWzlib package. This package is not part of the minimum Solaris operating system installation. If you require access to the Mozilla address book, then add this package to your Solaris operating system using the command "pkgadd" from the installation CD.

    +
    -
    -

    Important Accessibility Notes

    -

    For more information on the accessibility features in ${PRODUCTNAME}, see http://www.openoffice.org/access/

    -
    - -
    -

    Registration

    -

    Please take a little time to complete the minimal Product Registration process when you install the software. While registration is optional, we encourage you to register, since the information enables the community to make an even better software suite and address user needs directly. Through its Privacy Policy, the ${PRODUCTNAME} Community takes every precaution to safeguard your personal data. If you missed the registration at installation, you can return and register at any time at by choosing "Help - Registration" from the main menu.

    +
    +

    Shortcut Keys

    +

    Only shortcut keys (key combinations) not used by the operating system can be used in ${PRODUCTNAME}. If a key combination in ${PRODUCTNAME} does not work as described in the ${PRODUCTNAME} Help, check if that shortcut is already used by the operating system. To rectify such conflicts, you can change the keys assigned by your operating system. Alternatively, you can change almost any key assignment in ${PRODUCTNAME}. For more information on this topic, refer to the ${PRODUCTNAME} Help or the Help documention of your operating system.

    +
    +

    The application help of ${PRODUCTNAME} may use shortcut combinations for PC keyboards only.

    +
    -
    -

    User Survey

    -

    There is also a User Survey located online which we encourage you to fill out. The User Survey results will help ${PRODUCTNAME} move more rapidly in setting new standards for the creation of the next-generation office suite. Through its Privacy Policy, the ${PRODUCTNAME} Community takes every precaution to safeguard your personal data.

    -
    +
    +

    File Locking

    +

    File locking is enabled by default in ${PRODUCTNAME}. On a network that uses the Network File System protocol (NFS), the locking daemon for NFS clients must be active. To disable file locking, edit the soffice script and change the line "export SAL_ENABLE_FILE_LOCKING" to "# export SAL_ENABLE_FILE_LOCKING". If you disable file locking, the write access of a document is not restricted to the user who first opens the document.

    +

    Warning: The activated file locking feature can cause problems with Solaris 2.5.1 and 2.7 used in conjunction with Linux NFS 2.0. If your system environment has these parameters, we strongly recommend that you avoid using the file locking feature. Otherwise, ${PRODUCTNAME} will hang when you try to open a file from a NFS mounted directory from a Linux computer.

    +
    -
    -

    User Support

    -

    The main support page http://support.openoffice.org/ offers various possibilities for help with ${PRODUCTNAME}. Your question may have already been answered - check the Community Forum at http://user.services.openoffice.org or search the archives of the 'users@openoffice.org' mailing list at http://www.openoffice.org/mail_list.html. Alternatively, you can send in your questions to users@openoffice.org. How to subscribe to the list (to get an email response) is explained on this page: http://wiki.services.openoffice.org/wiki/Website/Content/help/mailinglists.

    -

    Also check the FAQ section at http://wiki.services.openoffice.org/wiki/Documentation/FAQ.

    -
    - -
    -

    Reporting Bugs & Issues

    -

    The ${PRODUCTNAME} Web site hosts IssueZilla, our mechanism for reporting, tracking and solving bugs and issues. We encourage all users to feel entitled and welcome to report issues that may arise on your particular platform. Energetic reporting of issues is one of the most important contributions that the user community can make to the ongoing development and improvement of the suite.

    -
    +
    +

    Problems When Sending Documents as E-mails From ${PRODUCTNAME}

    +

    When sending a document via 'File - Send - Document as E-mail' or 'Document as PDF Attachment' problems might occur (program crashes or hangs). This is due to the Windows system file "Mapi" (Messaging Application Programming Interface) which causes problems in some file versions. Unfortunately, the problem cannot be narrowed down to a certain version number. For more information visit http://www.microsoft.com to search the Microsoft Knowledge Base for "mapi dll".

    +
    -
    +
    +

    Important Accessibility Notes

    +

    For more information on the accessibility features in ${PRODUCTNAME}, see http://www.openoffice.org/access/ +

    +
    + +
    +

    Registration

    +

    Please take a little time to complete the minimal Product Registration process when you install the software. While registration is optional, we encourage you to register, since the information enables the community to make an even better software suite and address user needs directly. Through its Privacy Policy, the ${PRODUCTNAME} Community takes every precaution to safeguard your personal data. If you missed the registration at installation, you can return and register at any time at by choosing "Help - Registration" from the main menu.

    +
    + +
    +

    User Survey

    +

    There is also a User Survey located online which we encourage you to fill out. The User Survey results will help ${PRODUCTNAME} move more rapidly in setting new standards for the creation of the next-generation office suite. Through its Privacy Policy, the ${PRODUCTNAME} Community takes every precaution to safeguard your personal data.

    +
    + +
    +

    User Support

    +

    The main support page http://support.openoffice.org/ offers various possibilities for help with ${PRODUCTNAME}. Your question may have already been answered - check the Community Forum at http://user.services.openoffice.org or search the archives of the 'users@openoffice.org' mailing list at http://www.openoffice.org/mail_list.html. Alternatively, you can send in your questions to users@openoffice.org. How to subscribe to the list (to get an email response) is explained on this page: http://wiki.services.openoffice.org/wiki/Website/Content/help/mailinglists.

    +

    Also check the FAQ section at http://wiki.services.openoffice.org/wiki/Documentation/FAQ. +

    +
    + +
    +

    Reporting Bugs & Issues

    +

    The ${PRODUCTNAME} Web site hosts IssueZilla, our mechanism for reporting, tracking and solving bugs and issues. We encourage all users to feel entitled and welcome to report issues that may arise on your particular platform. Energetic reporting of issues is one of the most important contributions that the user community can make to the ongoing development and improvement of the suite.

    +
    + +

    Getting Involved

    The ${PRODUCTNAME} Community would very much benefit from your active participation in the development of this important open source project.

    -

    As a user, you are already a valuable part of the suite's development process and we would like to encourage you to take an even more active role with a view to being a long-term contributor to the community. Please join and check out the user page at http://www.openoffice.org

    - +

    As a user, you are already a valuable part of the suite's development process and we would like to encourage you to take an even more active role with a view to being a long-term contributor to the community. Please join and check out the user page at http://www.openoffice.org +

    How to Start

    -

    The best way to start contributing is to subscribe to one or more of the mailing lists, lurk for a while, and gradually use the mail archives to familiarize yourself with many of the topics covered since the ${PRODUCTNAME} source code was released back in October 2000. When you're comfortable, all you need to do is send an email self-introduction and jump right in. If you are familiar with Open Source Projects, check out our To-Dos list and see if there is anything you would like to help with at http://development.openoffice.org/todo.html.

    - +

    The best way to start contributing is to subscribe to one or more of the mailing lists, lurk for a while, and gradually use the mail archives to familiarize yourself with many of the topics covered since the ${PRODUCTNAME} source code was released back in October 2000. When you're comfortable, all you need to do is send an email self-introduction and jump right in. If you are familiar with Open Source Projects, check out our To-Dos list and see if there is anything you would like to help with at http://development.openoffice.org/todo.html.

    Subscribe

    -

    Here are a few of the Project mailing lists to which you can subscribe at http://www.openoffice.org/mail_list.html

    +

    Here are a few of the Project mailing lists to which you can subscribe at http://www.openoffice.org/mail_list.html +

    • News: announce@openoffice.org *recommended to all users* (light traffic)

    • +
    • Main user forum: user@openoffice.org *easy way to lurk on discussions* (heavy traffic)

    • +
    • Marketing project: dev@marketing.openoffice.org *beyond development* (getting heavy)

    • +
    • General code contributor list: dev@openoffice.org (moderate/heavy)

    -

    Joining one or more Projects

    You can make major contributions to this important open source project even if you have limited software design or coding experience. Yes, you!

    -

    At http://projects.openoffice.org/index.html you will find projects ranging from Localization, Porting and Groupware to some real core coding projects. If you are not a developer, try the Documentation or the Marketing Project. The OpenOffice.org Marketing Project is applying both guerilla and traditional commercial techniques to marketing open source software, and we are doing it across language and cultural barriers, so you can help just by spreading the word and telling a friend about this office suite.

    +

    At http://projects.openoffice.org/index.html you will find projects ranging from Localization, Porting and Groupware to some real core coding projects. If you are not a developer, try the Documentation or the Marketing Project. The OpenOffice.org Marketing Project is applying both guerilla and traditional commercial techniques to marketing open source software, and we are doing it across language and cultural barriers, so you can help just by spreading the word and telling a friend about this office suite.

    You can help by joining the Marketing Communications & Information Network on http://marketing.openoffice.org/contacts.html where you can provide point communication contact with press, media, government agencies, consultants, schools, Linux Users Groups and developers in your country and local community.

    - +

    We hope you enjoy working with the new ${PRODUCTNAME} ${PRODUCTVERSION} and will join us online.

    The OpenOffice.org Community

    @@ -306,8 +313,7 @@

    Used / Modified Source Code

    -

    Portions Copyright 1998, 1999 James Clark. Portions Copyright 1996, 1998 Netscape Communications Corporation.

    +

    Portions Copyright 1998, 1999 James Clark. Portions Copyright 1996, 1998 Netscape Communications Corporation.

    - -- cgit From 421512f0dc8985da05ff9654be8a3344aae0d513 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 14:04:48 +0200 Subject: jl152 #i77196# fixed failed start up for user without write access to share --- desktop/source/deployment/manager/dp_extensionmanager.cxx | 2 +- desktop/source/deployment/manager/dp_manager.cxx | 10 ++++++++-- .../source/deployment/registry/executable/dp_executable.cxx | 5 ++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 24b5712ebd30..13c43e41decf 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -1174,7 +1174,7 @@ sal_Bool ExtensionManager::synchronize( } catch (...) { uno::Any exc = ::cppu::getCaughtException(); throw deploy::DeploymentException( - OUSTR("Extension Manager: exception during enableExtension"), + OUSTR("Extension Manager: exception in synchronize"), static_cast(this), exc); } } diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 409cf2674184..44bc4d469f2f 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -183,7 +183,8 @@ void PackageManagerImpl::initActivationLayer( OSL_ASSERT( m_activePackages.getLength() > 0 ); m_activePackages_expanded = expandUnoRcUrl( m_activePackages ); m_registrationData_expanded = expandUnoRcUrl(m_registrationData); - create_folder( 0, m_activePackages_expanded, xCmdEnv, true); + if (!m_readOnly) + create_folder( 0, m_activePackages_expanded, xCmdEnv, true); OUString dbName; if (m_context.equals(OUSTR("user"))) @@ -1341,9 +1342,14 @@ bool PackageManagerImpl::synchronizeAddedExtensions( { bool bModified = false; ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); - + //check if the folder exist at all. The shared extension folder + //may not exist for a normal user. + if (!create_ucb_content( + NULL, m_activePackages_expanded, Reference(), false)) + return bModified; ::ucbhelper::Content tempFolder( m_activePackages_expanded, xCmdEnv ); + Reference xResultSet( tempFolder.createCursor( Sequence( &StrTitle::get(), 1 ), diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index c72a97d88891..968ee7297b0f 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -254,9 +254,8 @@ void BackendImpl::ExecutablePackageImpl::processPackage_( OSL_ASSERT(0); //This won't have affect on Windows - if (osl::File::E_None != osl::File::setAttributes( - dp_misc::expandUnoRcUrl(m_url), attributes)) - OSL_ENSURE(0, "Extension Manager: Could not set executable file attribute."); + osl::File::setAttributes( + dp_misc::expandUnoRcUrl(m_url), attributes); } getMyBackend()->addDataToDb(getURL()); } -- cgit From 699df1265794647c54e63c13d2e7dc819728677f Mon Sep 17 00:00:00 2001 From: Frank Peters Date: Thu, 10 Jun 2010 14:23:42 +0200 Subject: consolidatereadme #i111721# --- readlicense_oo/docs/readme/readme.xrm | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/readlicense_oo/docs/readme/readme.xrm b/readlicense_oo/docs/readme/readme.xrm index ac9ba071362e..78716869e822 100755 --- a/readlicense_oo/docs/readme/readme.xrm +++ b/readlicense_oo/docs/readme/readme.xrm @@ -18,15 +18,12 @@

    ${PRODUCTNAME} ${PRODUCTVERSION} ReadMe

    -

    For latest updates to this readme file, see http://www.openoffice.org/welcome/readme.html -

    +

    For latest updates to this readme file, see http://www.openoffice.org/welcome/readme.html

    This file contains important information about this program. Please read this information very carefully before starting work.

    -

    The OpenOffice.org Community, responsible for the development of this product, would like to invite you to participate as a community member. As a new user, you can check out the ${PRODUCTNAME} site with helpful user information at http://www.openoffice.org/about_us/introduction.html -

    +

    The OpenOffice.org Community, responsible for the development of this product, would like to invite you to participate as a community member. As a new user, you can check out the ${PRODUCTNAME} site with helpful user information at http://www.openoffice.org/about_us/introduction.html

    Also read the sections below about getting involved in the OpenOffice.org project.

    Is ${PRODUCTNAME} really free for any user?

    -

    ${PRODUCTNAME} is free for use by everybody. You may take this copy of ${PRODUCTNAME} and install it on as many computers as you like, and use it for any purpose you like (including commercial, government, public administration and educational use). For further details see the license text delivered together with ${PRODUCTNAME} or http://www.openoffice.org/license.html -

    +

    ${PRODUCTNAME} is free for use by everybody. You may take this copy of ${PRODUCTNAME} and install it on as many computers as you like, and use it for any purpose you like (including commercial, government, public administration and educational use). For further details see the license text delivered together with ${PRODUCTNAME} or http://www.openoffice.org/license.html

    Why is ${PRODUCTNAME} free for any user?

    You can use this copy of ${PRODUCTNAME} today free of charge because individual contributors and corporate sponsors have designed, developed, tested, translated, documented, supported, marketed, and helped in many other ways to make ${PRODUCTNAME} what it is today - the world's leading open-source office software.

    If you appreciate their efforts, and would like to ensure OpenOffice.org continues into the future, please consider contributing to the project - see http://contributing.openoffice.org for details. Everyone has a contribution to make.

    @@ -84,17 +81,14 @@

    Registration of ${PRODUCTNAME} as default application for Microsoft Office formats can be forced or suppressed by using the following command line switches with the installer:

    • -

      - /msoreg=1 will force registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

      +

      /msoreg=1 will force registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

    • -

      - /msoreg=0 will suppress registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

      +

      /msoreg=0 will suppress registration of ${PRODUCTNAME} as default application for Microsoft Office formats.

    -

    If you perform an administrative installation using setup /a, you need to make sure that the file msvc90.dll is installed on the system. This file is required for ${PRODUCTNAME} to start after an administrative installation. You can get the file from http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF -

    +

    If you perform an administrative installation using setup /a, you need to make sure that the file msvc90.dll is installed on the system. This file is required for ${PRODUCTNAME} to start after an administrative installation. You can get the file from http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF

    Please be aware that administrator rights are needed for the installation process.

    @@ -247,8 +241,7 @@

    Important Accessibility Notes

    -

    For more information on the accessibility features in ${PRODUCTNAME}, see http://www.openoffice.org/access/ -

    +

    For more information on the accessibility features in ${PRODUCTNAME}, see http://www.openoffice.org/access/

    @@ -264,8 +257,7 @@

    User Support

    The main support page http://support.openoffice.org/ offers various possibilities for help with ${PRODUCTNAME}. Your question may have already been answered - check the Community Forum at http://user.services.openoffice.org or search the archives of the 'users@openoffice.org' mailing list at http://www.openoffice.org/mail_list.html. Alternatively, you can send in your questions to users@openoffice.org. How to subscribe to the list (to get an email response) is explained on this page: http://wiki.services.openoffice.org/wiki/Website/Content/help/mailinglists.

    -

    Also check the FAQ section at http://wiki.services.openoffice.org/wiki/Documentation/FAQ. -

    +

    Also check the FAQ section at http://wiki.services.openoffice.org/wiki/Documentation/FAQ.

    @@ -276,13 +268,11 @@

    Getting Involved

    The ${PRODUCTNAME} Community would very much benefit from your active participation in the development of this important open source project.

    -

    As a user, you are already a valuable part of the suite's development process and we would like to encourage you to take an even more active role with a view to being a long-term contributor to the community. Please join and check out the user page at http://www.openoffice.org -

    +

    As a user, you are already a valuable part of the suite's development process and we would like to encourage you to take an even more active role with a view to being a long-term contributor to the community. Please join and check out the user page at http://www.openoffice.org

    How to Start

    The best way to start contributing is to subscribe to one or more of the mailing lists, lurk for a while, and gradually use the mail archives to familiarize yourself with many of the topics covered since the ${PRODUCTNAME} source code was released back in October 2000. When you're comfortable, all you need to do is send an email self-introduction and jump right in. If you are familiar with Open Source Projects, check out our To-Dos list and see if there is anything you would like to help with at http://development.openoffice.org/todo.html.

    Subscribe

    -

    Here are a few of the Project mailing lists to which you can subscribe at http://www.openoffice.org/mail_list.html -

    +

    Here are a few of the Project mailing lists to which you can subscribe at http://www.openoffice.org/mail_list.html

    • News: announce@openoffice.org *recommended to all users* (light traffic)

      -- cgit From 3bdbb3f6717d8690bc5b08cf241ac6cf44518f71 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 14:41:57 +0200 Subject: jl152 #i77196# unopkg --help prints out infos about --bundled --- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 621b8b0bac7c..a9a0c8271373 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -108,6 +108,8 @@ const char s_usingText [] = " deployment context;\n" " run only when no concurrent Office\n" " process(es) are running!\n" +" --bundled expert feature: operate on bundled extensions. Only\n" +" works with list, validate, reinstall;\n" " --deployment-context expert feature: explicit deployment context\n" " \n" "\n" -- cgit From 4393f0c2551af853c8b6e26c891829442100abbf Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 10 Jun 2010 15:17:05 +0200 Subject: #i112280# added missing minus in translation --- svx/source/svdraw/svdopath.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 2b495725c006..9d136ef82eae 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -2927,7 +2927,8 @@ sal_Bool SdrPathObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx:: aScale = aCorrectedRangeNoCurve.getRange(); // define matrix for move polygon to zero point - aMoveToZeroMatrix.translate(-aCorrectedRangeNoCurve.getMinX(), aCorrectedRangeNoCurve.getMinY()); + // #i112280# Added missing minus for Y-Translation + aMoveToZeroMatrix.translate(-aCorrectedRangeNoCurve.getMinX(), -aCorrectedRangeNoCurve.getMinY()); } else { -- cgit From 2d03198027d5422eb374696b827268033338e73e Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 15:20:30 +0200 Subject: jl152 #i77196# unopkg checkPrerequisitesAndEnable must return sal_Int32 --- desktop/source/deployment/manager/dp_extensionmanager.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 54624514adce..64cada7da3ac 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -129,7 +129,7 @@ public: css::uno::RuntimeException); - virtual long SAL_CALL checkPrerequisitesAndEnable( + virtual sal_Int32 SAL_CALL checkPrerequisitesAndEnable( css::uno::Reference const & extension, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) -- cgit From 463d6da2397ff113907eaa710fe711ee444ed3da Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 16:55:56 +0200 Subject: jl152 #i77196# backend db wrote double entries if there was an ambiguous extension, and XExtensionManager::synchronize was run --- desktop/source/deployment/registry/dp_backenddb.cxx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 1f4a62e696d7..14b4f2374c5b 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -425,14 +425,24 @@ Reference BackendDb::writeKeyElement( const Reference doc = getDocument(); const Reference root = doc->getFirstChild(); -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url + //Check if there are an entry with the same url. This can be the case if the + //the status of an XPackage is ambiguous. In this case a call to activateExtension + //(dp_extensionmanager.cxx), will register the package again. See also + //Package::processPackage_impl in dp_backend.cxx. + //A package can become + //invalid after its successful registration, for example if a second extension with + //the same service is installed. const OUString sExpression( sPrefix + OUSTR(":") + sElementName + OUSTR("[@url = \"") + url + OUSTR("\"]")); - const Reference _extensionNode = + const Reference existingNode = getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif + if (existingNode.is()) + { + OSL_ASSERT(0); + //replace the existing entry. + removeEntry(url); + } + const Reference keyElement( doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName)); -- cgit From 88f93ac2d640f99b46767caed96afdcd5d0cb688 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 17:19:42 +0200 Subject: jl152 #i77196# unopkg checkPrerequisitesAndEnable must return sal_Int32 (also in cxx) --- desktop/source/deployment/manager/dp_extensionmanager.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 13c43e41decf..de9d97db2b48 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -853,7 +853,7 @@ void ExtensionManager::enableExtension( /** */ -long ExtensionManager::checkPrerequisitesAndEnable( +sal_Int32 ExtensionManager::checkPrerequisitesAndEnable( Reference const & extension, Reference const & xAbortChannel, Reference const & xCmdEnv) -- cgit From df2bc9a970d890d417c97810d41cc9686c30b975 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Thu, 10 Jun 2010 18:09:39 +0200 Subject: impressaccessibility7: #i111668# Added guards against empty mpEditSource in SvxUnoTextRangeBase. --- editeng/source/uno/unotext.cxx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 45ef23c2be8f..ec7e76b144c0 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -260,12 +260,14 @@ SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxEditSource* pSource, const Sv DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!"); mpEditSource = pSource->Clone(); - ESelection aSelection; - ::GetSelection( aSelection, mpEditSource->GetTextForwarder() ); - SetSelection( aSelection ); + if (mpEditSource != NULL) + { + ESelection aSelection; + ::GetSelection( aSelection, mpEditSource->GetTextForwarder() ); + SetSelection( aSelection ); - if( mpEditSource ) mpEditSource->addRange( this ); + } #ifdef DEBUG gNumRanges.add(this); #endif @@ -348,7 +350,8 @@ void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw() OGuard aGuard( Application::GetSolarMutex() ); maSelection = rSelection; - CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); + if (mpEditSource != NULL) + CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); } // Interface XTextRange ( XText ) -- cgit From 09733434899d23c04e60d4caa18765b4bed87f3a Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 10 Jun 2010 19:17:08 +0200 Subject: tl78: #i110383# fix reload functionality --- sfx2/source/view/viewfrm.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index a80741df13a6..47f0926d00b6 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -382,12 +382,17 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // Speichern und Readonly Reloaden if( pSh->IsModified() ) { - if ( !pSh->PrepareClose() ) + if ( pSh->PrepareClose() ) + { + // the storing could let the medium be changed + pMed = pSh->GetMedium(); + bNeedsReload = sal_True; + } + else { rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) ); return; } - else bNeedsReload = sal_True; } nOpenMode = SFX_STREAM_READONLY; } -- cgit From cd24cd260c8112aa71f657b2de8381cc8f1e8c8e Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Sat, 12 Jun 2010 20:29:06 +0200 Subject: CWS mba33issues01: put code to load libraries on demand into class SvLibrary --- officecfg/registry/data/org/openoffice/Office/Paths.xcu | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/officecfg/registry/data/org/openoffice/Office/Paths.xcu b/officecfg/registry/data/org/openoffice/Office/Paths.xcu index a7ecd0e224e8..91a26137b24d 100644 --- a/officecfg/registry/data/org/openoffice/Office/Paths.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Paths.xcu @@ -98,7 +98,13 @@ - + + + + + + + -- cgit From 27908970ce3c92d8be0a01f1d522500a0a1b7100 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Mon, 14 Jun 2010 11:44:03 +0200 Subject: #i112361# - Fixed DAVResourceAccess::handleException() to suggest retry on status code 0 --- ucb/source/ucp/webdav/DAVResourceAccess.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx index 4ffc8dd88cf5..61eebe907608 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx @@ -1201,8 +1201,7 @@ sal_Bool DAVResourceAccess::handleException( DAVException & e, int errorCount ) // if we have a bad connection try again. Up to three times. case DAVException::DAV_HTTP_ERROR: // retry up to three times, if not a client-side error. - if ( e.getStatus() > 0 && - ( e.getStatus() < 400 || e.getStatus() > 499 ) && + if ( ( e.getStatus() < 400 || e.getStatus() >= 500 ) && errorCount < 3 ) { return sal_True; -- cgit From cac00f06770da2c1217fab5b58c1426833c6a03d Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 14 Jun 2010 11:53:06 +0200 Subject: jl152 bindPackage for extensions checks only for META-INF in folders and not META-INF/manifest.xml --- desktop/source/deployment/registry/package/dp_package.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index a2c68dd2341f..2ad6478b665c 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -378,7 +378,7 @@ Reference BackendImpl::bindPackage_( //Every .oxt, uno.pkg file must contain a META-INF folder ::ucbhelper::Content metaInfContent; if (create_ucb_content( - &metaInfContent, makeURL( url, OUSTR("META-INF/manifest.xml") ), + &metaInfContent, makeURL( url, OUSTR("META-INF") ), xCmdEnv, false /* no throw */ )) { mediaType = OUSTR("application/vnd.sun.star.package-bundle"); -- cgit From 6d073c4d67c86fcdde53e9e12da3c73e3b6e536a Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Mon, 14 Jun 2010 12:49:53 +0200 Subject: jl152:#i112371# Replaced old startcenter icon --- .../icons/hicolor/128x128/apps/startcenter.png | Bin 11073 -> 15601 bytes .../icons/hicolor/16x16/apps/startcenter.png | Bin 1043 -> 893 bytes .../icons/hicolor/32x32/apps/startcenter.png | Bin 2375 -> 2429 bytes .../icons/hicolor/48x48/apps/startcenter.png | Bin 3615 -> 4184 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/sysui/desktop/icons/hicolor/128x128/apps/startcenter.png b/sysui/desktop/icons/hicolor/128x128/apps/startcenter.png index b009ee2b9277..1b51a60bddea 100644 Binary files a/sysui/desktop/icons/hicolor/128x128/apps/startcenter.png and b/sysui/desktop/icons/hicolor/128x128/apps/startcenter.png differ diff --git a/sysui/desktop/icons/hicolor/16x16/apps/startcenter.png b/sysui/desktop/icons/hicolor/16x16/apps/startcenter.png index c81fc95d4770..3aa8f08a8c5d 100644 Binary files a/sysui/desktop/icons/hicolor/16x16/apps/startcenter.png and b/sysui/desktop/icons/hicolor/16x16/apps/startcenter.png differ diff --git a/sysui/desktop/icons/hicolor/32x32/apps/startcenter.png b/sysui/desktop/icons/hicolor/32x32/apps/startcenter.png index 22bdd4a7fef9..296c6f4c58b1 100644 Binary files a/sysui/desktop/icons/hicolor/32x32/apps/startcenter.png and b/sysui/desktop/icons/hicolor/32x32/apps/startcenter.png differ diff --git a/sysui/desktop/icons/hicolor/48x48/apps/startcenter.png b/sysui/desktop/icons/hicolor/48x48/apps/startcenter.png index f67dc976750b..86bcf599553f 100644 Binary files a/sysui/desktop/icons/hicolor/48x48/apps/startcenter.png and b/sysui/desktop/icons/hicolor/48x48/apps/startcenter.png differ -- cgit From 59e28862922d58883e74c6a87670a085b4a1df76 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 14 Jun 2010 15:03:53 +0100 Subject: gtkfpicker9: #i112386# make gtk fpicker gdk sections thread safe --- fpicker/source/unx/gnome/SalGtkFilePicker.cxx | 83 ++++++++++++++++--------- fpicker/source/unx/gnome/SalGtkFolderPicker.cxx | 16 +++-- fpicker/source/unx/gnome/SalGtkPicker.cxx | 23 +++++-- fpicker/source/unx/gnome/SalGtkPicker.hxx | 7 +++ fpicker/source/unx/gnome/resourceprovider.cxx | 2 - 5 files changed, 87 insertions(+), 44 deletions(-) diff --git a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx index 4fe6f6f11b20..c6b0acd6a33f 100644 --- a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx @@ -96,6 +96,8 @@ namespace static void expandexpanders(GtkContainer *pWidget) { + GdkThreadLock aLock; + GList *pChildren = gtk_container_get_children(pWidget); for( GList *p = pChildren; p; p = p->next ) { @@ -114,6 +116,8 @@ void SalGtkFilePicker::dialog_mapped_cb(GtkWidget *, SalGtkFilePicker *pobjFP) void SalGtkFilePicker::InitialMapping() { + GdkThreadLock aLock; + if (!mbPreviewState ) { gtk_widget_hide( m_pPreview ); @@ -208,6 +212,8 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference& xListener ) throw( uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); m_xListener = xListener; } void SAL_CALL SalGtkFilePicker::removeFilePickerListener( const uno::Reference& ) throw( uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); m_xListener.clear(); } @@ -591,6 +595,8 @@ shrinkFilterName( const rtl::OUString &rFilterName, bool bAllowNoStar = false ) static void dialog_remove_buttons( GtkDialog *pDialog ) { + GdkThreadLock aLock; + g_return_if_fail( GTK_IS_DIALOG( pDialog ) ); GList *pChildren = @@ -700,7 +706,6 @@ void SAL_CALL SalGtkFilePicker::appendFilter( const rtl::OUString& aTitle, const throw( lang::IllegalArgumentException, uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); if( FilterNameExists( aTitle ) ) throw IllegalArgumentException(); @@ -721,7 +726,6 @@ void SAL_CALL SalGtkFilePicker::setCurrentFilter( const rtl::OUString& aTitle ) throw( lang::IllegalArgumentException, uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); OSL_TRACE( "Setting current filter to %s\n", OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 ).getStr() ); @@ -763,6 +767,9 @@ void SalGtkFilePicker::UpdateFilterfromUI() // from the filter of the files glob on which he is currently searching if (!mnHID_FolderChange || !mnHID_SelectionChange) return; + + GdkThreadLock aLock; + GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_pFilterView)); GtkTreeIter iter; GtkTreeModel *model; @@ -782,7 +789,6 @@ void SalGtkFilePicker::UpdateFilterfromUI() rtl::OUString SAL_CALL SalGtkFilePicker::getCurrentFilter() throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); OSL_TRACE( "GetCURRENTfilter\n" ); @@ -802,7 +808,6 @@ void SAL_CALL SalGtkFilePicker::appendFilterGroup( const rtl::OUString& /*sGroup throw( lang::IllegalArgumentException, uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); // TODO m_pImpl->appendFilterGroup( sGroupTitle, aFilters ); // check the names @@ -832,7 +837,8 @@ void SAL_CALL SalGtkFilePicker::appendFilterGroup( const rtl::OUString& /*sGroup void SAL_CALL SalGtkFilePicker::setMultiSelectionMode( sal_Bool bMode ) throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + GdkThreadLock aLock; gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER(m_pDialog), bMode ); } @@ -841,7 +847,8 @@ void SAL_CALL SalGtkFilePicker::setDefaultName( const rtl::OUString& aName ) throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + GdkThreadLock aLock; OString aStr = OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ); GtkFileChooserAction eAction = gtk_file_chooser_get_action( GTK_FILE_CHOOSER( m_pDialog ) ); @@ -877,7 +884,8 @@ uno::Sequence SAL_CALL SalGtkFilePicker::getFiles() throw( uno::R uno::Sequence SAL_CALL SalGtkFilePicker::getSelectedFiles() throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + GdkThreadLock aLock; GSList* pPathList = gtk_file_chooser_get_uris( GTK_FILE_CHOOSER(m_pDialog) ); @@ -1014,7 +1022,8 @@ sal_Int16 SAL_CALL SalGtkFilePicker::execute() throw( uno::RuntimeException ) { OSL_TRACE( "1: HERE WE ARE\n"); OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + GdkThreadLock aLock; sal_Int16 retVal = 0; @@ -1171,6 +1180,8 @@ namespace { void HackWidthToFirst(GtkComboBox *pWidget) { + GdkThreadLock aLock; + GtkRequisition requisition; gtk_widget_size_request(GTK_WIDGET(pWidget), &requisition); gtk_widget_set_size_request(GTK_WIDGET(pWidget), requisition.width, -1); @@ -1179,6 +1190,8 @@ namespace void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nControlAction, const uno::Any& rValue) { + GdkThreadLock aLock; + switch (nControlAction) { case ControlActions::ADD_ITEM: @@ -1253,6 +1266,8 @@ void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nContr uno::Any SalGtkFilePicker::HandleGetListValue(GtkComboBox *pWidget, sal_Int16 nControlAction) const { + GdkThreadLock aLock; + uno::Any aAny; switch (nControlAction) { @@ -1312,15 +1327,15 @@ void SAL_CALL SalGtkFilePicker::setValue( sal_Int16 nControlId, sal_Int16 nContr throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); OSL_TRACE( "SETTING VALUE %d\n", nControlAction ); GType tType; GtkWidget *pWidget; + GdkThreadLock aLock; + if( !( pWidget = getWidget( nControlId, &tType ) ) ) OSL_TRACE("enable unknown control %d\n", nControlId); - else if( tType == GTK_TYPE_TOGGLE_BUTTON ) { sal_Bool bChecked = false; @@ -1340,15 +1355,16 @@ uno::Any SAL_CALL SalGtkFilePicker::getValue( sal_Int16 nControlId, sal_Int16 nC throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + uno::Any aRetval; GType tType; GtkWidget *pWidget; + GdkThreadLock aLock; + if( !( pWidget = getWidget( nControlId, &tType ) ) ) OSL_TRACE("enable unknown control %d\n", nControlId); - else if( tType == GTK_TYPE_TOGGLE_BUTTON ) aRetval <<= (sal_Bool) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( pWidget ) ); else if( tType == GTK_TYPE_COMBO_BOX ) @@ -1364,13 +1380,13 @@ void SAL_CALL SalGtkFilePicker::enableControl( sal_Int16 nControlId, sal_Bool bE throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); GtkWidget *pWidget; + GdkThreadLock aLock; + if ( nControlId == ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR ) gtk_expander_set_expanded( GTK_EXPANDER( m_pFilterExpander ), bEnable ); - else if( ( pWidget = getWidget( nControlId ) ) ) { if( bEnable ) @@ -1392,11 +1408,12 @@ void SAL_CALL SalGtkFilePicker::setLabel( sal_Int16 nControlId, const ::rtl::OUS throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); GType tType; GtkWidget *pWidget; + GdkThreadLock aLock; + if( !( pWidget = getWidget( nControlId, &tType ) ) ) { OSL_TRACE("Set label on unknown control %d\n", nControlId); @@ -1428,18 +1445,17 @@ rtl::OUString SAL_CALL SalGtkFilePicker::getLabel( sal_Int16 nControlId ) throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); GType tType; OString aTxt; GtkWidget *pWidget; + GdkThreadLock aLock; + if( !( pWidget = getWidget( nControlId, &tType ) ) ) OSL_TRACE("Get label on unknown control %d\n", nControlId); - else if( tType == GTK_TYPE_TOGGLE_BUTTON || tType == GTK_TYPE_BUTTON || tType == GTK_TYPE_LABEL ) aTxt = gtk_button_get_label( GTK_BUTTON( pWidget ) ); - else OSL_TRACE("Can't get label on list\n"); @@ -1453,7 +1469,6 @@ rtl::OUString SAL_CALL SalGtkFilePicker::getLabel( sal_Int16 nControlId ) uno::Sequence SAL_CALL SalGtkFilePicker::getSupportedImageFormats() throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); // TODO return m_pImpl->getSupportedImageFormats(); return 0; @@ -1462,7 +1477,6 @@ uno::Sequence SAL_CALL SalGtkFilePicker::getSupportedImageFormats() t sal_Int32 SAL_CALL SalGtkFilePicker::getTargetColorDepth() throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); // TODO return m_pImpl->getTargetColorDepth(); return 0; @@ -1471,18 +1485,14 @@ sal_Int32 SAL_CALL SalGtkFilePicker::getTargetColorDepth() throw( uno::RuntimeEx sal_Int32 SAL_CALL SalGtkFilePicker::getAvailableWidth() throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - // TODO return m_pImpl->getAvailableWidth(); return m_PreviewImageWidth; } sal_Int32 SAL_CALL SalGtkFilePicker::getAvailableHeight() throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - // TODO return m_pImpl->getAvailableHeight(); return m_PreviewImageHeight; } @@ -1490,7 +1500,6 @@ void SAL_CALL SalGtkFilePicker::setImage( sal_Int16 /*aImageFormat*/, const uno: throw( lang::IllegalArgumentException, uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); // TODO m_pImpl->setImage( aImageFormat, aImage ); } @@ -1499,6 +1508,9 @@ void SalGtkFilePicker::implChangeType( GtkTreeSelection *selection ) { CResourceProvider aResProvider; OUString aLabel = aResProvider.getResString( FILE_PICKER_FILE_TYPE ); + + GdkThreadLock aLock; + GtkTreeIter iter; GtkTreeModel *model; if (gtk_tree_selection_get_selected (selection, &model, &iter)) @@ -1523,6 +1535,8 @@ void SalGtkFilePicker::type_changed_cb( GtkTreeSelection *selection, SalGtkFileP void SalGtkFilePicker::unselect_type() { + GdkThreadLock aLock; + gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(m_pFilterView))); } @@ -1589,11 +1603,12 @@ void SalGtkFilePicker::update_preview_cb( GtkFileChooser *file_chooser, SalGtkFi sal_Bool SAL_CALL SalGtkFilePicker::setShowState( sal_Bool bShowState ) throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); // TODO return m_pImpl->setShowState( bShowState ); if( bShowState != mbPreviewState ) { + GdkThreadLock aLock; + if( bShowState ) { // Show @@ -1622,9 +1637,7 @@ sal_Bool SAL_CALL SalGtkFilePicker::setShowState( sal_Bool bShowState ) throw( u sal_Bool SAL_CALL SalGtkFilePicker::getShowState() throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - // TODO return m_pImpl->getShowState(); return mbPreviewState; } @@ -1740,6 +1753,8 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence& aArgu 1 ); } + GdkThreadLock aLock; + if( GTK_FILE_CHOOSER_ACTION_SAVE == eAction ) { CResourceProvider aResProvider; @@ -1801,7 +1816,6 @@ void SalGtkFilePicker::preview_toggled_cb( GtkObject *cb, SalGtkFilePicker* pobj void SAL_CALL SalGtkFilePicker::cancel() throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); // TODO m_pImpl->cancel(); } @@ -1848,6 +1862,8 @@ uno::Sequence SAL_CALL SalGtkFilePicker::getSupportedServiceNames //------------------------------------------------- void SalGtkFilePicker::SetCurFilter( const OUString& rFilter ) { + GdkThreadLock aLock; + // Get all the filters already added GSList *filters = gtk_file_chooser_list_filters ( GTK_FILE_CHOOSER( m_pDialog ) ); bool bFound = false; @@ -1903,6 +1919,8 @@ case_insensitive_filter (const GtkFileFilterInfo *filter_info, gpointer data) int SalGtkFilePicker::implAddFilter( const OUString& rFilter, const OUString& rType ) { + GdkThreadLock aLock; + GtkFileFilter *filter = gtk_file_filter_new(); OUString aShrunkName = shrinkFilterName( rFilter ); @@ -1981,6 +1999,9 @@ int SalGtkFilePicker::implAddFilterGroup( const OUString& /*_rFilter*/, const Se void SalGtkFilePicker::SetFilters() { OSL_TRACE( "start setting filters\n"); + + GdkThreadLock aLock; + int nAdded = 0; if( m_pFilterList && !m_pFilterList->empty() ) { diff --git a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx index 6b843d8b79f4..f9c78d76639c 100644 --- a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx @@ -87,6 +87,9 @@ SalGtkFolderPicker::SalGtkFolderPicker( const uno::Referencecancel(); } diff --git a/fpicker/source/unx/gnome/SalGtkPicker.cxx b/fpicker/source/unx/gnome/SalGtkPicker.cxx index 2d2e086ba2ca..8bd28bb22d29 100644 --- a/fpicker/source/unx/gnome/SalGtkPicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkPicker.cxx @@ -148,6 +148,8 @@ RunDialog::RunDialog( GtkWidget *pDialog, uno::Reference< awt::XExtendedToolkit } } + GdkThreadLock aLock; + GdkDisplay *pDisplay = aWindowHandle.DisplayPointer ? gdk_x11_lookup_xdisplay(reinterpret_cast(static_cast(aWindowHandle.DisplayPointer))) : NULL; GdkWindow* pParent = pDisplay ? gdk_window_lookup_for_display(pDisplay, aWindowHandle.WindowHandle) : NULL; if (!pParent && pDisplay) @@ -163,17 +165,22 @@ RunDialog::RunDialog( GtkWidget *pDialog, uno::Reference< awt::XExtendedToolkit RunDialog::~RunDialog() { if (mpCreatedParent) + { + GdkThreadLock aLock; gdk_window_destroy (mpCreatedParent); + } } void SAL_CALL RunDialog::windowOpened( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException) { - g_timeout_add_full(G_PRIORITY_HIGH_IDLE, 0, (GSourceFunc)canceldialog, this, NULL); + GdkThreadLock aLock; + gdk_threads_add_timeout_full(G_PRIORITY_HIGH_IDLE, 0, (GSourceFunc)canceldialog, this, NULL); } void RunDialog::cancel() { + GdkThreadLock aLock; gtk_dialog_response( GTK_DIALOG( mpDialog ), GTK_RESPONSE_CANCEL ); gtk_widget_hide( mpDialog ); } @@ -183,6 +190,7 @@ gint RunDialog::run() if (mxToolkit.is()) mxToolkit->addTopWindowListener(this); + GdkThreadLock aLock; gint nStatus = gtk_dialog_run( GTK_DIALOG( mpDialog ) ); if (mxToolkit.is()) @@ -197,14 +205,16 @@ gint RunDialog::run() SalGtkPicker::~SalGtkPicker() { if (m_pDialog) + { + GdkThreadLock aLock; gtk_widget_destroy(m_pDialog); + } } void SAL_CALL SalGtkPicker::implsetDisplayDirectory( const rtl::OUString& aDirectory ) throw( lang::IllegalArgumentException, uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); OString aTxt = unicodetouri(aDirectory); @@ -213,14 +223,16 @@ void SAL_CALL SalGtkPicker::implsetDisplayDirectory( const rtl::OUString& aDirec OSL_TRACE( "setting path to %s\n", aTxt.getStr() ); + GdkThreadLock aLock; gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ), - aTxt.getStr() ); + aTxt.getStr() ); } rtl::OUString SAL_CALL SalGtkPicker::implgetDisplayDirectory() throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + GdkThreadLock aLock; gchar* pCurrentFolder = gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ) ); @@ -233,8 +245,9 @@ rtl::OUString SAL_CALL SalGtkPicker::implgetDisplayDirectory() throw( uno::Runti void SAL_CALL SalGtkPicker::implsetTitle( const rtl::OUString& aTitle ) throw( uno::RuntimeException ) { OSL_ASSERT( m_pDialog != NULL ); - ::vos::OGuard aGuard( Application::GetSolarMutex() ); ::rtl::OString aWindowTitle = OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 ); + + GdkThreadLock aLock; gtk_window_set_title( GTK_WINDOW( m_pDialog ), aWindowTitle.getStr() ); } diff --git a/fpicker/source/unx/gnome/SalGtkPicker.hxx b/fpicker/source/unx/gnome/SalGtkPicker.hxx index 5baa5bdb56e8..6349d3ed4988 100644 --- a/fpicker/source/unx/gnome/SalGtkPicker.hxx +++ b/fpicker/source/unx/gnome/SalGtkPicker.hxx @@ -71,6 +71,13 @@ class SalGtkPicker static rtl::OString unicodetouri(const rtl::OUString &rURL); }; +class GdkThreadLock +{ +public: + GdkThreadLock() { gdk_threads_enter(); } + ~GdkThreadLock() { gdk_threads_leave(); } +}; + //Run the Gtk Dialog. Watch for any "new windows" created while we're //executing and consider that a CANCEL event to avoid e.g. "file cannot be opened" //modal dialogs and this one getting locked if some other API call causes this diff --git a/fpicker/source/unx/gnome/resourceprovider.cxx b/fpicker/source/unx/gnome/resourceprovider.cxx index 393ea7585d5a..8df810060ee5 100644 --- a/fpicker/source/unx/gnome/resourceprovider.cxx +++ b/fpicker/source/unx/gnome/resourceprovider.cxx @@ -168,8 +168,6 @@ public: String aResString; OUString aResOUString; - const ::vos::OGuard aGuard( Application::GetSolarMutex() ); - try { OSL_ASSERT( m_ResMgr && m_OtherResMgr ); -- cgit From 5456f4e6acb5b5a3528cdf18d2e230684ffe3eb9 Mon Sep 17 00:00:00 2001 From: va Date: Mon, 14 Jun 2010 17:59:06 +0200 Subject: #i112366# Replaced sun.dic with oracle.dic --- officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs b/officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs index 220d94c89da6..79a509de06f8 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs @@ -227,7 +227,7 @@ Specifies the custom dictionaries to be used. The Ignore list (IgnoreAllList (All)) is administered in the RAM only for the current spellcheck. - IgnoreAllList;soffice.dic;standard.dic;sun.dic + IgnoreAllList;soffice.dic;standard.dic;oracle.dic -- cgit From 6232a745c835aba638fbde151f27de070e5a5c56 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 14 Jun 2010 18:26:43 +0200 Subject: ooo30gsl01: #i112083# fix return value in PreNotfiy --- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index f4f03170a90f..284b96a9e933 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -135,7 +135,10 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode(); if ( (bCtrl && bAlt && KEY_F == nCode) || KEY_ESCAPE == nCode ) + { + nRet = 1; GrabFocusToDocument(); + } if ( KEY_RETURN == nCode ) { @@ -154,6 +157,7 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) lArgs[1].Value <<= sal_False; impl_executeSearch(m_xServiceManager, m_xFrame, lArgs); + nRet = 1; } break; } -- cgit From c44ba0727fecc1a1a70f525e72b0854527ab3e22 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 14 Jun 2010 20:07:33 +0200 Subject: tl78: #i111065# let the model be correctly loaded into a frame --- sfx2/source/view/viewfrm.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 47f0926d00b6..08c4980881f7 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -2113,9 +2113,7 @@ SfxViewShell* SfxViewFrame::LoadViewIntoFrame_Impl( const SfxObjectShell& i_rDoc else aTransformLoadArgs.remove( "Hidden" ); - ::rtl::OUString sURL( xDocument->getURL() ); - if ( !sURL.getLength() ) - sURL = i_rDoc.GetFactory().GetFactoryURL(); + ::rtl::OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "private:object" ) ); Reference< XComponentLoader > xLoader( i_rFrame, UNO_QUERY_THROW ); xLoader->loadComponentFromURL( sURL, ::rtl::OUString::createFromAscii( "_self" ), 0, -- cgit From 9d31e5d3ca564c719f94810fd93825131a14699c Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 15 Jun 2010 13:02:12 +0200 Subject: cws tl79: #i110254# security tab hid added to hidother.src --- sfx2/util/hidother.src | 1 + 1 file changed, 1 insertion(+) diff --git a/sfx2/util/hidother.src b/sfx2/util/hidother.src index 72b178b2d629..3ef31046bb00 100644 --- a/sfx2/util/hidother.src +++ b/sfx2/util/hidother.src @@ -165,3 +165,4 @@ hidspecial HID_DID_SAVE_PACKED_XML { HelpID = HID_DID_SAVE_PACKED_X hidspecial HID_HELP_ONHELP { HelpID = HID_HELP_ONHELP; }; hidspecial HID_HELP_TEXT_SELECTION_MODE { HelpID = HID_HELP_TEXT_SELECTION_MODE; }; hidspecial HID_DLG_CHECKFORONLINEUPDATE { HelpID = HID_DLG_CHECKFORONLINEUPDATE; }; +hidspecial HID_DOCINFOSECURITY { HelpID = HID_DOCINFOSECURITY; }; -- cgit From d2fc0f17b593f580b7c66521873fe4bfe4a9ab38 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 15 Jun 2010 15:21:45 +0200 Subject: #i112300# extended interpretation of MetaGradientAction in metafile primitive decomposition --- .../source/primitive2d/metafileprimitive2d.cxx | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index 238c47419eb9..480fa99e07fe 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -2291,35 +2291,48 @@ namespace { const Gradient& rGradient = pA->GetGradient(); const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + basegfx::B2DPolyPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); if(aAttribute.getStartColor() == aAttribute.getEndColor()) { // not really a gradient. Create filled rectangle - const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); - createFillPrimitive(basegfx::B2DPolyPolygon(aOutline), rTargetHolders.Current(), rPropertyHolders.Current()); + createFillPrimitive( + aOutline, + rTargetHolders.Current(), + rPropertyHolders.Current()); } else { // really a gradient aRange.transform(rPropertyHolders.Current().getTransformation()); + drawinglayer::primitive2d::Primitive2DSequence xGradient(1); if(rPropertyHolders.Current().isRasterOpInvert()) { // use a special version of FillGradientPrimitive2D which creates // non-overlapping geometry on decomposition to makethe old XOR // paint 'trick' work. - rTargetHolders.Current().append( + xGradient[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::NonOverlappingFillGradientPrimitive2D( aRange, aAttribute)); } else { - rTargetHolders.Current().append( + xGradient[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::FillGradientPrimitive2D( aRange, aAttribute)); } + + // #i112300# clip against polygon representing the rectangle from + // the action. This is implicitely done using a temp Clipping in VCL + // when a MetaGradientAction is executed + aOutline.transform(rPropertyHolders.Current().getTransformation()); + rTargetHolders.Current().append( + new drawinglayer::primitive2d::MaskPrimitive2D( + aOutline, + xGradient)); } } } -- cgit From e447c6b6ea98f01ee8f048134e700d05cf265392 Mon Sep 17 00:00:00 2001 From: tono Date: Tue, 15 Jun 2010 22:35:25 +0900 Subject: i#111956: MinGW port fix: dependency to shared library: pure porting fix --- desktop/source/pkgchk/unopkg/makefile.mk | 4 ++-- framework/util/makefile.mk | 8 ++++---- svx/util/makefile.mk | 2 +- vbahelper/util/makefile.mk | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/desktop/source/pkgchk/unopkg/makefile.mk b/desktop/source/pkgchk/unopkg/makefile.mk index 729548cbadd1..0cefee98634e 100644 --- a/desktop/source/pkgchk/unopkg/makefile.mk +++ b/desktop/source/pkgchk/unopkg/makefile.mk @@ -49,7 +49,7 @@ CFLAGS+=-DSYSTEM_DB -I$(DB_INCLUDES) APP1TARGET = so$/unopkg APP1OBJS = $(OBJFILES) APP1STDLIBS = $(SALLIB) $(UNOPKGAPPLIB) -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") APP1DEPN = $(SHL1TARGETN) .ELSE APP1DEPN = $(SHL1IMPLIBN) @@ -65,7 +65,7 @@ APP1LINKRES = $(MISC)$/$(TARGET)1.res APP2TARGET = unopkg APP2OBJS = $(OBJFILES) APP2STDLIBS = $(SALLIB) $(UNOPKGAPPLIB) -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") APP2DEPN = $(SHL1TARGETN) .ELSE APP2DEPN = $(SHL1IMPLIBN) diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk index 08218b6267b3..ab0513fccece 100644 --- a/framework/util/makefile.mk +++ b/framework/util/makefile.mk @@ -158,7 +158,7 @@ SHL2STDLIBS= \ $(SALLIB) SHL2DEF= $(MISC)$/$(SHL2TARGET).def -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") SHL2DEPN= $(SHL1TARGETN) .ELSE SHL2DEPN= $(SHL1IMPLIBN) @@ -218,7 +218,7 @@ SHL3STDLIBS= \ $(SALLIB) SHL3DEF= $(MISC)$/$(SHL3TARGET).def -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") SHL3DEPN= $(SHL1TARGETN) $(SHL2TARGETN) .ELSE SHL3DEPN= $(SHL1IMPLIBN) $(SHL2IMPLIBN) @@ -363,7 +363,7 @@ SHL4STDLIBS= \ $(I18NISOLANGLIB) SHL4DEF= $(MISC)$/$(SHL4TARGET).def -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") SHL4DEPN= $(SHL1TARGETN) $(SHL2TARGETN) .ELSE SHL4DEPN= $(SHL1IMPLIBN) $(SHL2IMPLIBN) @@ -398,7 +398,7 @@ SHL5STDLIBS= \ $(SALLIB) SHL5DEF= $(MISC)$/$(SHL5TARGET).def -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") SHL5DEPN= $(SHL1TARGETN) .ELSE SHL5DEPN= $(SHL1IMPLIBN) diff --git a/svx/util/makefile.mk b/svx/util/makefile.mk index 5ee482e6ac82..eeb1ee3dbcec 100644 --- a/svx/util/makefile.mk +++ b/svx/util/makefile.mk @@ -104,7 +104,7 @@ DEFLIB1NAME=$(SHL1LIBS:b) SHL2TARGET= svx$(DLLPOSTFIX) SHL2IMPLIB= i$(TARGET) SHL2USE_EXPORTS=name -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") SHL2DEPN=$(SHL1TARGETN) .ELSE SHL2DEPN=$(SHL1IMPLIBN) diff --git a/vbahelper/util/makefile.mk b/vbahelper/util/makefile.mk index 54a17873cf94..5f6bfa4967f9 100644 --- a/vbahelper/util/makefile.mk +++ b/vbahelper/util/makefile.mk @@ -96,7 +96,7 @@ SHL2STDLIBS= \ $(TKLIB) \ $(BASICLIB) \ -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" +.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") SHL2DEPN=$(SHL1TARGETN) .ELSE SHL2DEPN=$(SHL1IMPLIBN) -- cgit From 77b41d4ecd48f2dbc578ab1f320fdb69302547a8 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Tue, 15 Jun 2010 17:36:43 +0200 Subject: ooo30gsl01: #i112249# add missing URL conversion --- fpicker/source/unx/kde4/KDE4FilePicker.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fpicker/source/unx/kde4/KDE4FilePicker.cxx b/fpicker/source/unx/kde4/KDE4FilePicker.cxx index a7fa01a5ece6..eadc255f0ec0 100644 --- a/fpicker/source/unx/kde4/KDE4FilePicker.cxx +++ b/fpicker/source/unx/kde4/KDE4FilePicker.cxx @@ -46,6 +46,8 @@ #include #include +#include "osl/file.h" + #include "KDE4FilePicker.hxx" #include "FPServiceInfo.hxx" @@ -246,7 +248,7 @@ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles() // kde file picker returns the file and directories for selectedFiles() // when a file is double clicked // make a true list of files - const QString dir = "file://" + KUrl(rawFiles[0]).directory(); + const QString dir = KUrl(rawFiles[0]).directory(); bool singleFile = true; if (rawFiles.size() > 1) @@ -262,7 +264,7 @@ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles() { // if the raw file is not the base directory (see above kde bug) // we add the file to list of avail files - if ((dir + "/") != ("file://" + rawFiles[i])) + if ((dir + "/") != ( rawFiles[i])) { QString filename = KUrl(rawFiles[i]).fileName(); @@ -280,7 +282,11 @@ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles() // add all files and leading directory to outgoing OO sequence uno::Sequence< ::rtl::OUString > seq(files.size()); for (int i = 0; i < files.size(); ++i) - seq[i] = toOUString(files[i]); + { + rtl::OUString aFile(toOUString(files[i])), aURL; + osl_getFileURLFromSystemPath(aFile.pData, &aURL.pData ); + seq[i] = aURL; + } return seq; } -- cgit From 5ed103d2dd5f8ee2f13183263c0930f84437bdc7 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 15 Jun 2010 20:02:53 +0200 Subject: mib16: contributed bugfixes and various new symbols in VBA compatibility implementation --- basic/inc/basic/sbmod.hxx | 10 +- basic/inc/basic/sbobjmod.hxx | 18 +- basic/inc/basic/sbx.hxx | 2 +- basic/inc/basic/sbxdef.hxx | 4 + basic/inc/basic/sbxvar.hxx | 11 +- basic/prj/build.lst | 2 +- basic/source/basmgr/basmgr.cxx | 2 +- basic/source/classes/disas.cxx | 3 +- basic/source/classes/sb.cxx | 81 +- basic/source/classes/sbunoobj.cxx | 288 ++++- basic/source/classes/sbxmod.cxx | 64 +- basic/source/comp/dim.cxx | 75 +- basic/source/comp/exprgen.cxx | 6 + basic/source/comp/exprnode.cxx | 14 +- basic/source/comp/exprtree.cxx | 72 +- basic/source/comp/io.cxx | 37 + basic/source/comp/parser.cxx | 62 +- basic/source/comp/symtbl.cxx | 2 + basic/source/comp/token.cxx | 58 +- basic/source/inc/codegen.hxx | 2 +- basic/source/inc/dlgcont.hxx | 9 +- basic/source/inc/expr.hxx | 20 +- basic/source/inc/namecont.hxx | 9 +- basic/source/inc/opcodes.hxx | 1 + basic/source/inc/parser.hxx | 3 +- basic/source/inc/runtime.hxx | 5 +- basic/source/inc/sbintern.hxx | 3 + basic/source/inc/scriptcont.hxx | 9 +- basic/source/inc/symtbl.hxx | 6 + basic/source/inc/token.hxx | 20 +- basic/source/runtime/dllmgr.cxx | 1157 +++++++++++--------- basic/source/runtime/dllmgr.hxx | 71 +- basic/source/runtime/makefile.mk | 21 +- basic/source/runtime/methods1.cxx | 15 +- basic/source/runtime/rtlproto.hxx | 1 + basic/source/runtime/runtime.cxx | 5 +- basic/source/runtime/stdobj.cxx | 7 + basic/source/runtime/step0.cxx | 37 + basic/source/runtime/step1.cxx | 9 +- basic/source/runtime/step2.cxx | 32 +- basic/source/runtime/wnt-mingw.s | 98 +- basic/source/runtime/wnt.asm | 100 +- basic/source/sbx/sbxvar.cxx | 57 + basic/source/uno/dlgcont.cxx | 11 +- basic/source/uno/namecont.cxx | 18 +- basic/source/uno/scriptcont.cxx | 142 ++- basic/util/makefile.mk | 1 + formula/source/core/api/FormulaCompiler.cxx | 2 +- oovbaapi/ooo/vba/XApplicationBase.idl | 8 + oovbaapi/ooo/vba/XCollection.idl | 1 + oovbaapi/ooo/vba/XCommandBarControl.idl | 1 + oovbaapi/ooo/vba/XDocumentBase.idl | 3 + oovbaapi/ooo/vba/excel/XApplication.idl | 19 +- oovbaapi/ooo/vba/excel/XComment.idl | 13 +- oovbaapi/ooo/vba/excel/XHyperlink.idl | 27 +- oovbaapi/ooo/vba/excel/XPane.idl | 7 +- oovbaapi/ooo/vba/excel/XRange.idl | 3 +- oovbaapi/ooo/vba/excel/XWindow.idl | 10 +- oovbaapi/ooo/vba/excel/XWorksheet.idl | 21 +- oovbaapi/ooo/vba/excel/makefile.mk | 3 + oovbaapi/ooo/vba/makefile.mk | 5 +- oovbaapi/ooo/vba/msforms/XControl.idl | 6 +- oovbaapi/ooo/vba/msforms/XControls.idl | 7 + oovbaapi/prj/d.lst | 14 + vbahelper/inc/vbahelper/vbaapplicationbase.hxx | 11 + vbahelper/inc/vbahelper/vbacollectionimpl.hxx | 92 ++ vbahelper/inc/vbahelper/vbadocumentbase.hxx | 3 + vbahelper/inc/vbahelper/vbafontbase.hxx | 9 +- vbahelper/inc/vbahelper/vbahelper.hxx | 20 +- vbahelper/inc/vbahelper/vbahelperinterface.hxx | 53 + vbahelper/source/msforms/makefile.mk | 1 + vbahelper/source/msforms/vbacontrol.cxx | 34 +- vbahelper/source/msforms/vbacontrol.hxx | 7 + vbahelper/source/msforms/vbacontrols.cxx | 182 ++- vbahelper/source/msforms/vbacontrols.hxx | 7 +- vbahelper/source/vbahelper/makefile.mk | 1 - vbahelper/source/vbahelper/vbaapplicationbase.cxx | 293 ++++- vbahelper/source/vbahelper/vbacommandbar.cxx | 82 ++ vbahelper/source/vbahelper/vbacommandbar.hxx | 34 + .../source/vbahelper/vbacommandbarcontrol.cxx | 16 + .../source/vbahelper/vbacommandbarcontrol.hxx | 2 + .../source/vbahelper/vbacommandbarcontrols.cxx | 78 +- .../source/vbahelper/vbacommandbarcontrols.hxx | 20 + vbahelper/source/vbahelper/vbacommandbarhelper.cxx | 25 +- vbahelper/source/vbahelper/vbacommandbarhelper.hxx | 4 +- vbahelper/source/vbahelper/vbacommandbars.cxx | 72 +- vbahelper/source/vbahelper/vbacommandbars.hxx | 2 +- vbahelper/source/vbahelper/vbadocumentbase.cxx | 40 +- vbahelper/source/vbahelper/vbafontbase.cxx | 85 +- vbahelper/source/vbahelper/vbahelper.cxx | 350 +++++- xmloff/inc/xmloff/XMLEventExport.hxx | 8 + xmloff/source/script/XMLEventExport.cxx | 25 +- xmlscript/inc/xmlscript/xmlmod_imexp.hxx | 1 + xmlscript/source/xmlmod_imexp/xmlmod_export.cxx | 3 + xmlscript/source/xmlmod_imexp/xmlmod_import.cxx | 7 +- 95 files changed, 3279 insertions(+), 1118 deletions(-) diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index 63ffef6cdd61..cf888adf9dcf 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -40,6 +40,7 @@ class SbiBreakpoints; class SbiImage; class SbProcedureProperty; class SbIfaceMapperMethod; +class SbClassModuleObject; struct SbClassData; class SbModuleImpl; @@ -125,11 +126,12 @@ public: BOOL LoadBinaryData( SvStream& ); BOOL ExceedsLegacyModuleSize(); void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const; - BOOL IsVBACompat(); - void SetVBACompat( BOOL bCompat ); - INT32 GetModuleType() { return mnType; } - void SetModuleType( INT32 nType ) { mnType = nType; } + BOOL IsVBACompat() const; + void SetVBACompat( BOOL bCompat ); + INT32 GetModuleType() { return mnType; } + void SetModuleType( INT32 nType ) { mnType = nType; } bool GetIsProxyModule() { return bIsProxyModule; } + bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); }; #ifndef __SB_SBMODULEREF_HXX diff --git a/basic/inc/basic/sbobjmod.hxx b/basic/inc/basic/sbobjmod.hxx index ad804dcfab38..3d638a475f9a 100644 --- a/basic/inc/basic/sbobjmod.hxx +++ b/basic/inc/basic/sbobjmod.hxx @@ -62,6 +62,7 @@ public: class SbUserFormModule : public SbObjModule { + com::sun::star::script::ModuleInfo m_mInfo; css::uno::Reference m_DialogListener; css::uno::Reference m_xDialog; css::uno::Reference m_xModel; @@ -70,7 +71,7 @@ class SbUserFormModule : public SbObjModule SbUserFormModule( const SbUserFormModule& ); SbUserFormModule(); -protected: +//protected: virtual void InitObject(); public: TYPEINFO(); @@ -85,8 +86,23 @@ public: void triggerDeActivateEvent(); void triggerInitializeEvent(); void triggerTerminateEvent(); + + class SbUserFormModuleInstance* CreateInstance(); }; +class SbUserFormModuleInstance : public SbUserFormModule +{ + SbUserFormModule* m_pParentModule; + +public: + SbUserFormModuleInstance( SbUserFormModule* pParentModule, const String& rName, + const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat ); + + virtual BOOL IsClass( const String& ) const; + virtual SbxVariable* Find( const XubString& rName, SbxClassType t ); +}; + + #ifndef __SB_SBOBJMODULEREF_HXX #define __SB_SBOBJMODULEREF_HXX diff --git a/basic/inc/basic/sbx.hxx b/basic/inc/basic/sbx.hxx index 1254716c84e6..2eb194708739 100644 --- a/basic/inc/basic/sbx.hxx +++ b/basic/inc/basic/sbx.hxx @@ -171,8 +171,8 @@ class SbxArray : public SbxBase { // #100883 Method to set method directly to parameter array friend class SbMethod; - friend class SbTypeFactory; friend class SbClassModuleObject; + friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj ); void PutDirect( SbxVariable* pVar, UINT32 nIdx ); SbxArrayImpl* mpSbxArrayImpl; // Impl data diff --git a/basic/inc/basic/sbxdef.hxx b/basic/inc/basic/sbxdef.hxx index 8206fa2b1667..89322be776f9 100644 --- a/basic/inc/basic/sbxdef.hxx +++ b/basic/inc/basic/sbxdef.hxx @@ -105,6 +105,9 @@ enum SbxDataType { SbxUSERn = 2047 // last user defined data type }; +const UINT32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000; +const UINT32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible + #endif #ifndef _SBX_OPERATOR @@ -313,6 +316,7 @@ enum SbxError { // Ergebnis einer Rechenoperation/Konversion #define SBX_NO_BROADCAST 0x2000 // No broadcast on Get/Put #define SBX_REFERENCE 0x4000 // Parameter is Reference (DLL-call) #define SBX_NO_MODIFY 0x8000 // SetModified is suppressed +#define SBX_WITH_EVENTS 0x0080 // Same value as unused SBX_HIDDEN // Broadcaster-IDs: #define SBX_HINT_DYING SFX_HINT_DYING diff --git a/basic/inc/basic/sbxvar.hxx b/basic/inc/basic/sbxvar.hxx index 715d8c46f0f3..4d9d19b52a59 100644 --- a/basic/inc/basic/sbxvar.hxx +++ b/basic/inc/basic/sbxvar.hxx @@ -230,8 +230,6 @@ class SbxValueImpl; class SbxValue : public SbxBase { - friend class SbiDllMgr; // BASIC-Runtime must access aData - SbxValueImpl* mpSbxValueImplImpl; // Impl data // #55226 Transport additional infos @@ -289,6 +287,8 @@ public: const SbxValues& GetValues_Impl() const { return aData; } virtual BOOL Put( const SbxValues& ); + inline SbxValues * data() { return &aData; } + SbxINT64 GetCurrency() const; SbxINT64 GetLong64() const; SbxUINT64 GetULong64() const; @@ -447,6 +447,9 @@ class SbxVariable : public SbxValue String maName; // Name, if available SbxArrayRef mpPar; // Parameter-Array, if set USHORT nHash; // Hash-ID for search + + SbxVariableImpl* getImpl( void ); + protected: SbxInfoRef pInfo; // Probably called information sal_uIntPtr nUserData; // User data for Call() @@ -492,6 +495,10 @@ public: inline SbxObject* GetParent() { return pParent; } virtual void SetParent( SbxObject* ); + const String& GetDeclareClassName( void ); + void SetDeclareClassName( const String& ); + void SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener ); + static USHORT MakeHashCode( const String& rName ); }; diff --git a/basic/prj/build.lst b/basic/prj/build.lst index 2cd1d3dc0466..a41428a1ca20 100755 --- a/basic/prj/build.lst +++ b/basic/prj/build.lst @@ -1,4 +1,4 @@ -sb basic : l10n offuh oovbaapi svtools xmlscript framework NULL +sb basic : l10n offuh oovbaapi svtools xmlscript framework salhelper NULL sb basic usr1 - all sb_mkout NULL sb basic\inc nmake - all sb_inc NULL sb basic\source\app nmake - all sb_app sb_class sb_inc NULL diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index c242165df825..b76a2b5e249e 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -1789,7 +1789,7 @@ bool BasicManager::GetGlobalUNOConstant( const sal_Char* _pAsciiName, ::com::sun { bool bRes = false; StarBASIC* pStandardLib = GetStdLib(); - OSL_PRECOND( pStandardLib, "BasicManager::SetGlobalUNOConstant: no lib to insert into!" ); + OSL_PRECOND( pStandardLib, "BasicManager::GetGlobalUNOConstant: no lib to read from!" ); if ( pStandardLib ) bRes = pStandardLib->GetUNOConstant( _pAsciiName, aOut ); return bRes; diff --git a/basic/source/classes/disas.cxx b/basic/source/classes/disas.cxx index 36e88b6353e8..7317005d74fe 100644 --- a/basic/source/classes/disas.cxx +++ b/basic/source/classes/disas.cxx @@ -89,7 +89,8 @@ static const char* pOp1[] = { "INITFOREACH", "VBASET", "ERASE_CLEAR", - "ARRAYACCESS" + "ARRAYACCESS", + "BYVAL" }; static const char* pOp2[] = { diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 4f2f90d5da1f..79c5f78601ea 100755 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -321,23 +321,52 @@ SbxObject* SbOLEFactory::CreateObject( const String& rClassName ) } -// Factory class to create user defined objects (type command) -class SbTypeFactory : public SbxFactory -{ - SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj ); +//======================================================================== +// SbFormFactory, show user forms by: dim as new +class SbFormFactory : public SbxFactory +{ public: virtual SbxBase* Create( UINT16 nSbxId, UINT32 = SBXCR_SBX ); virtual SbxObject* CreateObject( const String& ); }; -SbxBase* SbTypeFactory::Create( UINT16, UINT32 ) +SbxBase* SbFormFactory::Create( UINT16, UINT32 ) { // Not supported return NULL; } -SbxObject* SbTypeFactory::cloneTypeObjectImpl( const SbxObject& rTypeObj ) +SbxObject* SbFormFactory::CreateObject( const String& rClassName ) +{ + static String aLoadMethodName( RTL_CONSTASCII_USTRINGPARAM("load") ); + + SbxObject* pRet = NULL; + SbModule* pMod = pMOD; + if( pMod ) + { + SbxVariable* pVar = pMod->Find( rClassName, SbxCLASS_OBJECT ); + if( pVar ) + { + SbxBase* pObj = pVar->GetObject(); + SbUserFormModule* pFormModule = PTR_CAST( SbUserFormModule, pObj ); + + if( pFormModule != NULL ) + { + pFormModule->load(); + SbUserFormModuleInstance* pFormInstance = pFormModule->CreateInstance(); + pRet = pFormInstance; + } + } + } + return pRet; +} + + +//======================================================================== +// SbTypeFactory + +SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj ) { SbxObject* pRet = new SbxObject( rTypeObj ); pRet->PutObject( pRet ); @@ -352,7 +381,8 @@ SbxObject* SbTypeFactory::cloneTypeObjectImpl( const SbxObject& rTypeObj ) if( pProp ) { SbxProperty* pNewProp = new SbxProperty( *pProp ); - if( pVar->GetType() & SbxARRAY ) + SbxDataType eVarType = pVar->GetType(); + if( eVarType & SbxARRAY ) { SbxBase* pParObj = pVar->GetObject(); SbxDimArray* pSource = PTR_CAST(SbxDimArray,pParObj); @@ -379,12 +409,35 @@ SbxObject* SbTypeFactory::cloneTypeObjectImpl( const SbxObject& rTypeObj ) pNewProp->PutObject( pDest ); pNewProp->SetFlags( nSavFlags ); } + if( eVarType == SbxOBJECT ) + { + SbxBase* pObjBase = pVar->GetObject(); + SbxObject* pSrcObj = PTR_CAST(SbxObject,pObjBase); + SbxObject* pDestObj = NULL; + if( pSrcObj != NULL ) + pDestObj = cloneTypeObjectImpl( *pSrcObj ); + pNewProp->PutObject( pDestObj ); + } pProps->PutDirect( pNewProp, i ); } } return pRet; } +// Factory class to create user defined objects (type command) +class SbTypeFactory : public SbxFactory +{ +public: + virtual SbxBase* Create( UINT16 nSbxId, UINT32 = SBXCR_SBX ); + virtual SbxObject* CreateObject( const String& ); +}; + +SbxBase* SbTypeFactory::Create( UINT16, UINT32 ) +{ + // Not supported + return NULL; +} + SbxObject* SbTypeFactory::CreateObject( const String& rClassName ) { SbxObject* pRet = NULL; @@ -728,6 +781,8 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic ) AddFactory( pCLASSFAC ); pOLEFAC = new SbOLEFactory; AddFactory( pOLEFAC ); + pFORMFAC = new SbFormFactory; + AddFactory( pFORMFAC ); } pRtl = new SbiStdObject( String( RTL_CONSTASCII_USTRINGPARAM(RTLNAME) ), this ); // Search via StarBasic is always global @@ -748,15 +803,17 @@ StarBASIC::~StarBASIC() if( !--GetSbData()->nInst ) { RemoveFactory( pSBFAC ); - pSBFAC = NULL; + delete pSBFAC; pSBFAC = NULL; RemoveFactory( pUNOFAC ); - pUNOFAC = NULL; + delete pUNOFAC; pUNOFAC = NULL; RemoveFactory( pTYPEFAC ); - pTYPEFAC = NULL; + delete pTYPEFAC; pTYPEFAC = NULL; RemoveFactory( pCLASSFAC ); - pCLASSFAC = NULL; + delete pCLASSFAC; pCLASSFAC = NULL; RemoveFactory( pOLEFAC ); - pOLEFAC = NULL; + delete pOLEFAC; pOLEFAC = NULL; + RemoveFactory( pFORMFAC ); + delete pFORMFAC; pFORMFAC = NULL; #ifdef DBG_UTIL // There is no need to clean SbiData at program end, diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 849fd839bfd1..e51a0c09270b 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -1074,8 +1075,19 @@ Any sbxToUnoValueImpl( SbxVariable* pVar, bool bBlockConversionToSmallestType = if( eBaseType == SbxOBJECT ) { SbxBaseRef xObj = (SbxBase*)pVar->GetObject(); - if( xObj.Is() && xObj->ISA(SbUnoAnyObject) ) - return ((SbUnoAnyObject*)(SbxBase*)xObj)->getValue(); + if( xObj.Is() ) + { + if( xObj->ISA(SbUnoAnyObject) ) + return ((SbUnoAnyObject*)(SbxBase*)xObj)->getValue(); + if( xObj->ISA(SbClassModuleObject) ) + { + Any aRetAny; + SbClassModuleObject* pClassModuleObj = (SbClassModuleObject*)(SbxBase*)xObj; + SbModule* pClassModule = pClassModuleObj->getClassModule(); + if( pClassModule->createCOMWrapperForIface( aRetAny, pClassModuleObj ) ) + return aRetAny; + } + } } Type aType = getUnoTypeForSbxValue( pVar ); @@ -1581,12 +1593,18 @@ String getBasicObjectTypeName( SbxObject* pObj ) bool checkUnoObjectType( SbUnoObject* pUnoObj, const String& aClass ) { - bool result = false; Any aToInspectObj = pUnoObj->getUnoAny(); TypeClass eType = aToInspectObj.getValueType().getTypeClass(); if( eType != TypeClass_INTERFACE ) return false; const Reference< XInterface > x = *(Reference< XInterface >*)aToInspectObj.getValue(); + + // Return true for XInvocation based objects as interface type names don't count then + Reference< XInvocation > xInvocation( x, UNO_QUERY ); + if( xInvocation.is() ) + return true; + + bool result = false; Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY ); if( xTypeProvider.is() ) { @@ -4135,3 +4153,267 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite ) refVar->PutObject( xUnoAnyObject ); } +//========================================================================== + +typedef WeakImplHelper1< XInvocation > ModuleInvocationProxyHelper; + +class ModuleInvocationProxy : public ModuleInvocationProxyHelper +{ + ::rtl::OUString m_aPrefix; + SbxObjectRef m_xScopeObj; + bool m_bProxyIsClassModuleObject; + +public: + ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj ); + ~ModuleInvocationProxy() + {} + + // XInvocation + virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() throw(); + virtual void SAL_CALL setValue( const ::rtl::OUString& rProperty, const Any& rValue ) + throw( UnknownPropertyException ); + virtual Any SAL_CALL getValue( const ::rtl::OUString& rProperty ) + throw( UnknownPropertyException ); + virtual sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& rName ) throw(); + virtual sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& rProp ) throw(); + + virtual Any SAL_CALL invoke( const ::rtl::OUString& rFunction, + const Sequence< Any >& rParams, + Sequence< sal_Int16 >& rOutParamIndex, + Sequence< Any >& rOutParam ) + throw( CannotConvertException, InvocationTargetException ); +}; + +ModuleInvocationProxy::ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj ) + : m_aPrefix( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_") ) ) + , m_xScopeObj( xScopeObj ) +{ + m_bProxyIsClassModuleObject = xScopeObj.Is() ? xScopeObj->ISA(SbClassModuleObject) : false; +} + +Reference< XIntrospectionAccess > SAL_CALL ModuleInvocationProxy::getIntrospection() throw() +{ + return Reference< XIntrospectionAccess >(); +} + +void SAL_CALL ModuleInvocationProxy::setValue( const ::rtl::OUString& rProperty, const Any& rValue ) throw( UnknownPropertyException ) +{ + if( !m_bProxyIsClassModuleObject ) + throw UnknownPropertyException(); + + NAMESPACE_VOS(OGuard) guard( Application::GetSolarMutex() ); + + ::rtl::OUString aPropertyFunctionName( RTL_CONSTASCII_USTRINGPARAM( "Property Set ") ); + aPropertyFunctionName += m_aPrefix; + aPropertyFunctionName += rProperty; + + SbxVariable* p = m_xScopeObj->Find( aPropertyFunctionName, SbxCLASS_METHOD ); + SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL; + if( pMeth == NULL ) + { + // TODO: Check vba behavior concernig missing function + //StarBASIC::Error( SbERR_NO_METHOD, aFunctionName ); + throw UnknownPropertyException(); + } + + // Setup parameter + SbxArrayRef xArray = new SbxArray; + SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); + unoToSbxValue( (SbxVariable*)xVar, rValue ); + xArray->Put( xVar, 1 ); + + // Call property method + SbxVariableRef xValue = new SbxVariable; + pMeth->SetParameters( xArray ); + pMeth->Call( xValue ); + //aRet = sbxToUnoValue( xValue ); + pMeth->SetParameters( NULL ); + + // TODO: OutParameter? + + // throw InvocationTargetException(); + + //return aRet; + +} + +Any SAL_CALL ModuleInvocationProxy::getValue( const ::rtl::OUString& rProperty ) throw( UnknownPropertyException ) +{ + if( !m_bProxyIsClassModuleObject ) + throw UnknownPropertyException(); + + NAMESPACE_VOS(OGuard) guard( Application::GetSolarMutex() ); + + ::rtl::OUString aPropertyFunctionName( RTL_CONSTASCII_USTRINGPARAM( "Property Get ") ); + aPropertyFunctionName += m_aPrefix; + aPropertyFunctionName += rProperty; + + SbxVariable* p = m_xScopeObj->Find( aPropertyFunctionName, SbxCLASS_METHOD ); + SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL; + if( pMeth == NULL ) + { + // TODO: Check vba behavior concernig missing function + //StarBASIC::Error( SbERR_NO_METHOD, aFunctionName ); + throw UnknownPropertyException(); + } + + // Call method + SbxVariableRef xValue = new SbxVariable; + pMeth->Call( xValue ); + Any aRet = sbxToUnoValue( xValue ); + return aRet; +} + +sal_Bool SAL_CALL ModuleInvocationProxy::hasMethod( const ::rtl::OUString& ) throw() +{ + return sal_False; +} + +sal_Bool SAL_CALL ModuleInvocationProxy::hasProperty( const ::rtl::OUString& ) throw() +{ + return sal_False; +} + +Any SAL_CALL ModuleInvocationProxy::invoke( const ::rtl::OUString& rFunction, + const Sequence< Any >& rParams, + Sequence< sal_Int16 >&, + Sequence< Any >& ) + throw( CannotConvertException, InvocationTargetException ) +{ + NAMESPACE_VOS(OGuard) guard( Application::GetSolarMutex() ); + + Any aRet; + if( !m_xScopeObj.Is() ) + return aRet; + + ::rtl::OUString aFunctionName = m_aPrefix; + aFunctionName += rFunction; + + SbxVariable* p = m_xScopeObj->Find( aFunctionName, SbxCLASS_METHOD ); + SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL; + if( pMeth == NULL ) + { + // TODO: Check vba behavior concernig missing function + //StarBASIC::Error( SbERR_NO_METHOD, aFunctionName ); + return aRet; + } + + // Setup parameters + SbxArrayRef xArray; + sal_Int32 nParamCount = rParams.getLength(); + if( nParamCount ) + { + xArray = new SbxArray; + const Any *pArgs = rParams.getConstArray(); + for( sal_Int32 i = 0 ; i < nParamCount ; i++ ) + { + SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); + unoToSbxValue( (SbxVariable*)xVar, pArgs[i] ); + xArray->Put( xVar, sal::static_int_cast< USHORT >(i+1) ); + } + } + + // Call method + SbxVariableRef xValue = new SbxVariable; + if( xArray.Is() ) + pMeth->SetParameters( xArray ); + pMeth->Call( xValue ); + aRet = sbxToUnoValue( xValue ); + pMeth->SetParameters( NULL ); + + // TODO: OutParameter? + + return aRet; +} + +Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::OUString& aVBAType, + const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj ) +{ + Reference< XInterface > xRet; + + Reference< XComponentContext > xContext = getComponentContext_Impl(); + Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() ); + + Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPrefix, xScopeObj ); + + Sequence args( 3 ); + args[0] <<= aControlAny; + args[1] <<= aVBAType; + args[2] <<= xProxy; + + try + { + xRet = xServiceMgr->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.UnoComListener")), + args, xContext ); + } + catch( const Exception& ) + { + implHandleAnyException( ::cppu::getCaughtException() ); + } + + return xRet; +} + +// Handle module implements mechanism for OLE types +bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ) +{ + // For now: Take first interface that allows to instantiate COM wrapper + // TODO: Check if support for multiple interfaces is needed + + Reference< XComponentContext > xContext = getComponentContext_Impl(); + Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() ); + Reference< XSingleServiceFactory > xComImplementsFactory + ( + xServiceMgr->createInstanceWithContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.ComImplementsFactory")), xContext ), + UNO_QUERY + ); + if( !xComImplementsFactory.is() ) + return false; + + bool bSuccess = false; + + SbxArray* pModIfaces = pClassData->mxIfaces; + USHORT nCount = pModIfaces->Count(); + for( USHORT i = 0 ; i < nCount ; ++i ) + { + SbxVariable* pVar = pModIfaces->Get( i ); + ::rtl::OUString aIfaceName = pVar->GetName(); + + if( aIfaceName.getLength() != 0 ) + { + ::rtl::OUString aPureIfaceName = aIfaceName; + sal_Int32 indexLastDot = aIfaceName.lastIndexOf('.'); + if ( indexLastDot > -1 ) + aPureIfaceName = aIfaceName.copy( indexLastDot + 1 ); + + Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPureIfaceName, pProxyClassModuleObject ); + + Sequence args( 2 ); + args[0] <<= aIfaceName; + args[1] <<= xProxy; + + Reference< XInterface > xRet; + bSuccess = false; + try + { + xRet = xComImplementsFactory->createInstanceWithArguments( args ); + bSuccess = true; + } + catch( const Exception& ) + { + implHandleAnyException( ::cppu::getCaughtException() ); + } + + if( bSuccess ) + { + o_rRetAny <<= xRet; + break; + } + } + } + + return bSuccess; +} + diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 83c0ae9e65f4..6a00e5b6649b 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -190,6 +190,11 @@ SbModule::SbModule( const String& rName, BOOL bVBACompat ) SetName( rName ); SetFlag( SBX_EXTSEARCH | SBX_GBLSEARCH ); SetModuleType( script::ModuleType::NORMAL ); + + // #i92642: Set name property to intitial name + SbxVariable* pNameProp = pProps->Find( String( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_PROPERTY ); + if( pNameProp != NULL ) + pNameProp->PutString( GetName() ); } SbModule::~SbModule() @@ -366,7 +371,7 @@ SbxVariable* SbModule::Find( const XubString& rName, SbxClassType t ) { // make sure a search in an uninstatiated class module will fail SbxVariable* pRes = SbxObject::Find( rName, t ); - if ( bIsProxyModule ) + if ( bIsProxyModule && !GetSbData()->bRunInit ) return NULL; if( !pRes && pImage ) { @@ -452,7 +457,19 @@ void SbModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, } } else - SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType ); + { + // #i92642: Special handling for name property to avoid + // side effects when using name as variable implicitely + bool bForwardToSbxObject = true; + + ULONG nId = pHint->GetId(); + if( (nId == SBX_HINT_DATAWANTED || nId == SBX_HINT_DATACHANGED) && + pVar->GetName().EqualsIgnoreCaseAscii( "name" ) ) + bForwardToSbxObject = false; + + if( bForwardToSbxObject ) + SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType ); + } } } @@ -646,7 +663,7 @@ void ClearUnoObjectsInRTL_Impl( StarBASIC* pBasic ) if( ((StarBASIC*)p) != pBasic ) ClearUnoObjectsInRTL_Impl_Rek( (StarBASIC*)p ); } -BOOL SbModule::IsVBACompat() +BOOL SbModule::IsVBACompat() const { return mbVBACompat; } @@ -1710,18 +1727,20 @@ public: }; SbUserFormModule::SbUserFormModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsCompat ) - :SbObjModule( rName, mInfo, bIsCompat ), mbInit( false ) + : SbObjModule( rName, mInfo, bIsCompat ) + , m_mInfo( mInfo ) + , mbInit( false ) { - m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW ); + m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW ); } void SbUserFormModule::ResetApiObj() { - if ( m_xDialog.is() ) // probably someone close the dialog window + if ( m_xDialog.is() ) // probably someone close the dialog window { - triggerTerminateEvent(); - } - pDocObject = NULL; + triggerTerminateEvent(); + } + pDocObject = NULL; m_xDialog = NULL; } @@ -1807,6 +1826,33 @@ void SbUserFormModule::triggerTerminateEvent( void ) mbInit=false; } +SbUserFormModuleInstance* SbUserFormModule::CreateInstance() +{ + SbUserFormModuleInstance* pInstance = new SbUserFormModuleInstance( this, GetName(), m_mInfo, IsVBACompat() ); + return pInstance; +} + +SbUserFormModuleInstance::SbUserFormModuleInstance( SbUserFormModule* pParentModule, + const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat ) + : SbUserFormModule( rName, mInfo, bIsVBACompat ) + , m_pParentModule( pParentModule ) +{ +} + +BOOL SbUserFormModuleInstance::IsClass( const XubString& rName ) const +{ + BOOL bParentNameMatches = m_pParentModule->GetName().EqualsIgnoreCaseAscii( rName ); + BOOL bRet = bParentNameMatches || SbxObject::IsClass( rName ); + return bRet; +} + +SbxVariable* SbUserFormModuleInstance::Find( const XubString& rName, SbxClassType t ) +{ + SbxVariable* pVar = m_pParentModule->Find( rName, t ); + return pVar; +} + + void SbUserFormModule::load() { OSL_TRACE("** load() "); diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index fb4071bcc2a2..bff3d22dd9b0 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -1,4 +1,4 @@ - /************************************************************************* +/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -30,6 +30,8 @@ #include #include "sbcomp.hxx" +SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj ); + // Deklaration einer Variablen // Bei Fehlern wird bis zum Komma oder Newline geparst. // Returnwert: eine neue Instanz, die eingefuegt und dann geloescht wird. @@ -37,6 +39,12 @@ SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, BOOL bStatic, BOOL bConst ) { + bool bWithEvents = false; + if( Peek() == WITHEVENTS ) + { + Next(); + bWithEvents = true; + } if( !TestSymbol() ) return NULL; SbxDataType t = eScanType; SbiSymDef* pDef = bConst ? new SbiConstDef( aSym ) : new SbiSymDef( aSym ); @@ -47,6 +55,8 @@ SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, BOOL bStatic, BOOL bConst ) pDef->SetType( t ); if( bStatic ) pDef->SetStatic(); + if( bWithEvents ) + pDef->SetWithEvents(); TypeDecl( *pDef ); if( !ppDim && pDim ) { @@ -107,8 +117,10 @@ void SbiParser::TypeDecl( SbiSymDef& rDef, BOOL bAsNewAlreadyParsed ) Next(); SbiConstExpression aSize( this ); nSize = aSize.GetShortValue(); - if( nSize < 0 ) + if( nSize < 0 || (bVBASupportOn && nSize <= 0) ) Error( SbERR_OUT_OF_RANGE ); + else + rDef.SetFixedStringLength( nSize ); } } break; @@ -209,7 +221,7 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic ) // #110004 It can also be a sub/function if( !bConst && (eCurTok == SUB || eCurTok == FUNCTION || eCurTok == PROPERTY || - eCurTok == STATIC || eCurTok == ENUM || eCurTok == DECLARE) ) + eCurTok == STATIC || eCurTok == ENUM || eCurTok == DECLARE || eCurTok == TYPE) ) { // Next token is read here, because !bConst bool bPrivate = ( eFirstTok == PRIVATE ); @@ -244,6 +256,13 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic ) DefDeclare( bPrivate ); return; } + // #i109049 + else if( eCurTok == TYPE ) + { + Next(); + DefType( bPrivate ); + return; + } } #ifdef SHARED @@ -349,9 +368,15 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic ) break; default: eOp2 = _LOCAL; } - aGen.Gen( - eOp2, pDef->GetId(), - sal::static_int_cast< UINT16 >( pDef->GetType() ) ); + UINT32 nOpnd2 = sal::static_int_cast< UINT16 >( pDef->GetType() ); + if( pDef->IsWithEvents() ) + nOpnd2 |= SBX_TYPE_WITH_EVENTS_FLAG; + + short nFixedStringLength = pDef->GetFixedStringLength(); + if( nFixedStringLength >= 0 ) + nOpnd2 |= (SBX_FIXED_LEN_STRING_FLAG + (UINT32(nFixedStringLength) << 17)); // len = all bits above 0x10000 + + aGen.Gen( eOp2, pDef->GetId(), nOpnd2 ); } // Initialisierung fuer selbstdefinierte Datentypen @@ -473,7 +498,7 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic ) // d.h. pPool muss immer am Schleifen-Ende zurueckgesetzt werden. // auch bei break pPool = pOldPool; - continue; // MyBreak überspingen + continue; // MyBreak überspingen MyBreak: pPool = pOldPool; break; @@ -506,18 +531,7 @@ void SbiParser::Erase() { while( !bAbort ) { - if( !TestSymbol() ) return; - String aName( aSym ); - SbxDataType eType = eScanType; - SbiSymDef* pDef = pPool->Find( aName ); - if( !pDef ) - { - if( bExplicit ) - Error( SbERR_UNDEF_VAR, aName ); - pDef = pPool->AddSym( aName ); - pDef->SetType( eType ); - } - SbiExpression aExpr( this, *pDef ); + SbiExpression aExpr( this, SbLVALUE ); aExpr.Gen(); aGen.Gen( _ERASE ); if( !TestComma() ) break; @@ -576,12 +590,14 @@ void SbiParser::DefType( BOOL bPrivate ) } if( pElem ) { - SbxArray *pTypeMembers = pType -> GetProperties(); - if (pTypeMembers -> Find (pElem->GetName(),SbxCLASS_DONTCARE)) + SbxArray *pTypeMembers = pType->GetProperties(); + String aElemName = pElem->GetName(); + if( pTypeMembers->Find( aElemName, SbxCLASS_DONTCARE) ) Error (SbERR_VAR_DEFINED); else { - SbxProperty *pTypeElem = new SbxProperty (pElem->GetName(),pElem->GetType()); + SbxDataType eElemType = pElem->GetType(); + SbxProperty *pTypeElem = new SbxProperty( aElemName, eElemType ); if( pDim ) { SbxDimArray* pArray = new SbxDimArray( pElem->GetType() ); @@ -618,6 +634,21 @@ void SbiParser::DefType( BOOL bPrivate ) pTypeElem->PutObject( pArray ); pTypeElem->SetFlags( nSavFlags ); } + // Nested user type? + if( eElemType == SbxOBJECT ) + { + USHORT nElemTypeId = pElem->GetTypeId(); + if( nElemTypeId != 0 ) + { + String aTypeName( aGblStrings.Find( nElemTypeId ) ); + SbxObject* pTypeObj = static_cast< SbxObject* >( rTypeArray->Find( aTypeName, SbxCLASS_OBJECT ) ); + if( pTypeObj != NULL ) + { + SbxObject* pCloneObj = cloneTypeObjectImpl( *pTypeObj ); + pTypeElem->PutObject( pCloneObj ); + } + } + } delete pDim; pTypeMembers->Insert( pTypeElem, pTypeMembers->Count() ); } diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx index 89520832ff67..60869307aecf 100644 --- a/basic/source/comp/exprgen.cxx +++ b/basic/source/comp/exprgen.cxx @@ -148,6 +148,10 @@ void SbiExprNode::Gen( RecursiveMode eRecMode ) pLeft->Gen(); pGen->Gen( _TESTCLASS, nTypeStrId ); } + else if( IsNew() ) + { + pGen->Gen( _CREATE, 0, nTypeStrId ); + } else { pLeft->Gen(); @@ -285,6 +289,8 @@ void SbiExpression::Gen( RecursiveMode eRecMode ) // AB: 17.12.1995, Spezialbehandlung fuer WITH // Wenn pExpr == .-Ausdruck in With, zunaechst Gen fuer Basis-Objekt pExpr->Gen( eRecMode ); + if( bByVal ) + pParser->aGen.Gen( _BYVAL ); if( bBased ) { USHORT uBase = pParser->nBase; diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx index a77cf32abbaa..d47c86f86ea8 100644 --- a/basic/source/comp/exprnode.cxx +++ b/basic/source/comp/exprnode.cxx @@ -100,6 +100,15 @@ SbiExprNode::SbiExprNode( SbiParser* p, SbiExprNode* l, USHORT nId ) nTypeStrId = nId; } +// new +SbiExprNode::SbiExprNode( SbiParser* p, USHORT nId ) +{ + BaseInit( p ); + + eType = SbxOBJECT; + eNodeType = SbxNEW; + nTypeStrId = nId; +} // AB: 17.12.95, Hilfsfunktion fuer Ctor fuer einheitliche Initialisierung void SbiExprNode::BaseInit( SbiParser* p ) @@ -253,7 +262,8 @@ void SbiExprNode::CollectBits() void SbiExprNode::FoldConstants() { if( IsOperand() || eTok == LIKE ) return; - pLeft->FoldConstants(); + if( pLeft ) + pLeft->FoldConstants(); if( pRight ) { pRight->FoldConstants(); @@ -431,7 +441,7 @@ void SbiExprNode::FoldConstants() } } } - else if( pLeft->IsNumber() ) + else if( pLeft && pLeft->IsNumber() ) { nVal = pLeft->nVal; delete pLeft; diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index 2f5c0b967a2e..0cf0d9870378 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -38,7 +38,8 @@ |* ***************************************************************************/ -SbiExpression::SbiExpression( SbiParser* p, SbiExprType t, SbiExprMode eMode ) +SbiExpression::SbiExpression( SbiParser* p, SbiExprType t, + SbiExprMode eMode, const KeywordSymbolInfo* pKeywordSymbolInfo ) { pParser = p; bError = bByVal = bBased = bBracket = FALSE; @@ -46,7 +47,7 @@ SbiExpression::SbiExpression( SbiParser* p, SbiExprType t, SbiExprMode eMode ) eCurExpr = t; m_eMode = eMode; pNext = NULL; - pExpr = (t != SbSTDEXPR ) ? Term() : Boolean(); + pExpr = (t != SbSTDEXPR ) ? Term( pKeywordSymbolInfo ) : Boolean(); if( t != SbSYMBOL ) pExpr->Optimize(); if( t == SbLVALUE && !pExpr->IsLvalue() ) @@ -114,7 +115,7 @@ static BOOL DoParametersFollow( SbiParser* p, SbiExprType eCurExpr, SbiToken eTo if( !p->WhiteSpace() || eCurExpr != SbSYMBOL ) return FALSE; if ( eTok == NUMBER || eTok == MINUS || eTok == FIXSTRING - || eTok == SYMBOL || eTok == COMMA || eTok == DOT || eTok == NOT ) + || eTok == SYMBOL || eTok == COMMA || eTok == DOT || eTok == NOT || eTok == BYVAL ) { return TRUE; } @@ -177,7 +178,7 @@ static SbiSymDef* AddSym // Zur Zeit sind sogar Keywords zugelassen (wg. gleichnamiger Dflt-Properties) -SbiExprNode* SbiExpression::Term( void ) +SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo ) { if( pParser->Peek() == DOT ) { @@ -204,11 +205,11 @@ SbiExprNode* SbiExpression::Term( void ) return pNd; } - SbiToken eTok = pParser->Next(); + SbiToken eTok = (pKeywordSymbolInfo == NULL) ? pParser->Next() : pKeywordSymbolInfo->m_eTok; // Anfang des Parsings merken pParser->LockColumn(); - String aSym( pParser->GetSym() ); - SbxDataType eType = pParser->GetType(); + String aSym( (pKeywordSymbolInfo == NULL) ? pParser->GetSym() : pKeywordSymbolInfo->m_aKeywordSymbol ); + SbxDataType eType = (pKeywordSymbolInfo == NULL) ? pParser->GetType() : pKeywordSymbolInfo->m_eSbxDataType; SbiParameters* pPar = NULL; SbiExprListVector* pvMoreParLcl = NULL; // Folgen Parameter? @@ -280,6 +281,12 @@ SbiExprNode* SbiExpression::Term( void ) // AB 31.3.1996: In Parser-Methode ausgelagert // (wird auch in SbiParser::DefVar() in DIM.CXX benoetigt) pDef = pParser->CheckRTLForSym( aSym, eType ); + + // #i109184: Check if symbol is or later will be defined inside module + SbModule& rMod = pParser->aGen.GetModule(); + SbxArray* pModMethods = rMod.GetMethods(); + if( pModMethods->Find( aSym, SbxCLASS_DONTCARE ) ) + pDef = NULL; } if( !pDef ) { @@ -417,13 +424,27 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj ) String aSym( pParser->GetSym() ); SbxDataType eType = pParser->GetType(); SbiParameters* pPar = NULL; + SbiExprListVector* pvMoreParLcl = NULL; eTok = pParser->Peek(); // Parameter? if( DoParametersFollow( pParser, eCurExpr, eTok ) ) { - pPar = new SbiParameters( pParser ); + bool bStandaloneExpression = false; + pPar = new SbiParameters( pParser, bStandaloneExpression ); bError |= !pPar->IsValid(); eTok = pParser->Peek(); + + // i109624 check for additional sets of parameters + while( eTok == LPAREN ) + { + if( pvMoreParLcl == NULL ) + pvMoreParLcl = new SbiExprListVector(); + SbiParameters* pAddPar = new SbiParameters( pParser ); + pvMoreParLcl->push_back( pAddPar ); + bError |= !pPar->IsValid(); + eTok = pParser->Peek(); + } + } BOOL bObj = BOOL( ( eTok == DOT || eTok == EXCLAM ) && !pParser->WhiteSpace() ); if( bObj ) @@ -450,6 +471,7 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj ) SbiExprNode* pNd = new SbiExprNode( pParser, *pDef, eType ); pNd->aVar.pPar = pPar; + pNd->aVar.pvMorePar = pvMoreParLcl; if( bObj ) { // Falls wir etwas mit Punkt einscannen, muss der @@ -483,7 +505,7 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj ) // Funktionen // geklammerte Ausdruecke -SbiExprNode* SbiExpression::Operand() +SbiExprNode* SbiExpression::Operand( bool bUsedForTypeOf ) { SbiExprNode *pRes; SbiToken eTok; @@ -494,7 +516,7 @@ SbiExprNode* SbiExpression::Operand() case SYMBOL: pRes = Term(); // process something like "IF Not r Is Nothing Then .." - if( pParser->IsVBASupportOn() && pParser->Peek() == IS ) + if( !bUsedForTypeOf && pParser->IsVBASupportOn() && pParser->Peek() == IS ) { eTok = pParser->Next(); pRes = new SbiExprNode( pParser, pRes, eTok, Like() ); @@ -576,7 +598,8 @@ SbiExprNode* SbiExpression::Unary() case TYPEOF: { pParser->Next(); - SbiExprNode* pObjNode = Operand(); + bool bUsedForTypeOf = true; + SbiExprNode* pObjNode = Operand( bUsedForTypeOf ); pParser->TestToken( IS ); String aDummy; SbiSymDef* pTypeDef = new SbiSymDef( aDummy ); @@ -584,6 +607,15 @@ SbiExprNode* SbiExpression::Unary() pNd = new SbiExprNode( pParser, pObjNode, pTypeDef->GetTypeId() ); break; } + case NEW: + { + pParser->Next(); + String aStr; + SbiSymDef* pTypeDef = new SbiSymDef( aStr ); + pParser->TypeDecl( *pTypeDef, TRUE ); + pNd = new SbiExprNode( pParser, pTypeDef->GetTypeId() ); + break; + } default: pNd = Operand(); } @@ -938,6 +970,14 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa // Benannte Argumente: entweder .name= oder name:= else { + bool bByVal = false; + if( eTok == BYVAL ) + { + bByVal = true; + pParser->Next(); + eTok = pParser->Peek(); + } + if( bAssumeExprLParenMode ) { pExpr = new SbiExpression( pParser, SbSTDEXPR, EXPRMODE_LPAREN_PENDING ); @@ -961,12 +1001,22 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa { bBracket = TRUE; delete pExpr; + if( bByVal ) + pParser->Error( SbERR_LVALUE_EXPECTED ); return; } } else pExpr = new SbiExpression( pParser ); + if( bByVal ) + { + if( !pExpr->IsLvalue() ) + pParser->Error( SbERR_LVALUE_EXPECTED ); + else + pExpr->SetByVal(); + } + //pExpr = bConst ? new SbiConstExpression( pParser ) // : new SbiExpression( pParser ); if( !bAssumeArrayMode ) diff --git a/basic/source/comp/io.cxx b/basic/source/comp/io.cxx index 1ed551994c92..b211ea0b7b08 100644 --- a/basic/source/comp/io.cxx +++ b/basic/source/comp/io.cxx @@ -115,6 +115,30 @@ void SbiParser::Write() aGen.Gen( _CHAN0 ); } + +// #i92642 Handle LINE keyword outside ::Next() +void SbiParser::Line() +{ + // #i92642: Special handling to allow name as symbol + if( Peek() == INPUT ) + { + Next(); + LineInput(); + } + else + { + aGen.Statement(); + + KeywordSymbolInfo aInfo; + aInfo.m_aKeywordSymbol = String( RTL_CONSTASCII_USTRINGPARAM( "line" ) ); + aInfo.m_eSbxDataType = GetType(); + aInfo.m_eTok = SYMBOL; + + Symbol( &aInfo ); + } +} + + // LINE INPUT [prompt], var$ void SbiParser::LineInput() @@ -288,6 +312,19 @@ void SbiParser::Open() void SbiParser::Name() { + // #i92642: Special handling to allow name as symbol + if( Peek() == EQ ) + { + aGen.Statement(); + + KeywordSymbolInfo aInfo; + aInfo.m_aKeywordSymbol = String( RTL_CONSTASCII_USTRINGPARAM( "name" ) ); + aInfo.m_eSbxDataType = GetType(); + aInfo.m_eTok = SYMBOL; + + Symbol( &aInfo ); + return; + } SbiExpression aExpr1( this ); TestToken( AS ); SbiExpression aExpr2( this ); diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx index 8770dc8539f0..3d7178ae7688 100644 --- a/basic/source/comp/parser.cxx +++ b/basic/source/comp/parser.cxx @@ -83,6 +83,7 @@ static SbiStatement StmntTable [] = { { IMPLEMENTS, &SbiParser::Implements, Y, N, }, // IMPLEMENTS { INPUT, &SbiParser::Input, N, Y, }, // INPUT { LET, &SbiParser::Assign, N, Y, }, // LET +{ LINE, &SbiParser::Line, N, Y, }, // LINE, -> LINE INPUT (#i92642) { LINEINPUT,&SbiParser::LineInput, N, Y, }, // LINE INPUT { LOOP, &SbiParser::BadBlock, N, Y, }, // LOOP { LSET, &SbiParser::LSet, N, Y, }, // LSET @@ -237,7 +238,9 @@ void SbiParser::Exit() SbiToken eTok = Next(); for( SbiParseStack* p = pStack; p; p = p->pNext ) { - if( eTok == p->eExitTok ) + SbiToken eExitTok = p->eExitTok; + if( eTok == eExitTok || + (eTok == PROPERTY && (eExitTok == GET || eExitTok == LET) ) ) // #i109051 { p->nChain = aGen.Gen( _JUMP, p->nChain ); return; @@ -367,7 +370,10 @@ BOOL SbiParser::Parse() } // Ende des Parsings? - if( eCurTok == eEndTok ) + if( eCurTok == eEndTok || + ( bVBASupportOn && // #i109075 + (eCurTok == ENDFUNC || eCurTok == ENDPROPERTY || eCurTok == ENDSUB) && + (eEndTok == ENDFUNC || eEndTok == ENDPROPERTY || eEndTok == ENDSUB) ) ) { Next(); if( eCurTok != NIL ) @@ -477,10 +483,10 @@ SbiExprNode* SbiParser::GetWithVar() // Zuweisung oder Subroutine Call -void SbiParser::Symbol() +void SbiParser::Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo ) { SbiExprMode eMode = bVBASupportOn ? EXPRMODE_STANDALONE : EXPRMODE_STANDARD; - SbiExpression aVar( this, SbSYMBOL, eMode ); + SbiExpression aVar( this, SbSYMBOL, eMode, pKeywordSymbolInfo ); bool bEQ = ( Peek() == EQ ); if( !bEQ && bVBASupportOn && aVar.IsBracket() ) @@ -704,11 +710,37 @@ void SbiParser::Implements() return; } - if( TestSymbol() ) + Peek(); + if( eCurTok != SYMBOL ) + { + Error( SbERR_SYMBOL_EXPECTED ); + return; + } + + String aImplementedIface = aSym; + Next(); + if( Peek() == DOT ) { - String aImplementedIface = GetSym(); - aIfaceVector.push_back( aImplementedIface ); + String aDotStr( '.' ); + while( Peek() == DOT ) + { + aImplementedIface += aDotStr; + Next(); + SbiToken ePeekTok = Peek(); + if( ePeekTok == SYMBOL || IsKwd( ePeekTok ) ) + { + Next(); + aImplementedIface += aSym; + } + else + { + Next(); + Error( SbERR_SYMBOL_EXPECTED ); + break; + } + } } + aIfaceVector.push_back( aImplementedIface ); } void SbiParser::EnableCompatibility() @@ -745,12 +777,16 @@ void SbiParser::Option() break; } case COMPARE: - switch( Next() ) - { - case TEXT: bText = TRUE; return; - case BINARY: bText = FALSE; return; - default:; - } // Fall thru! + { + SbiToken eTok = Next(); + if( eTok == BINARY ) + bText = FALSE; + else if( eTok == SYMBOL && GetSym().EqualsIgnoreCaseAscii("text") ) + bText = TRUE; + else + Error( SbERR_EXPECTED, "Text/Binary" ); + break; + } case COMPATIBLE: EnableCompatibility(); break; diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx index 24f0f890eebb..d6b3dbb878fc 100644 --- a/basic/source/comp/symtbl.cxx +++ b/basic/source/comp/symtbl.cxx @@ -300,12 +300,14 @@ SbiSymDef::SbiSymDef( const String& rName ) : aName( rName ) bStatic = bOpt = bParamArray = + bWithEvents = bByVal = bChained = bGlobal = FALSE; pIn = pPool = NULL; nDefaultId = 0; + nFixedStringLength = -1; } SbiSymDef::~SbiSymDef() diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx index 9fdfef0490b1..8cb3126f03f1 100644 --- a/basic/source/comp/token.cxx +++ b/basic/source/comp/token.cxx @@ -185,6 +185,7 @@ static TokenTable aTokTable_Basic [] = { // Token-Tabelle: { WEND, "Wend" }, { WHILE, "While" }, { WITH, "With" }, + { WITHEVENTS, "WithEvents" }, { WRITE, "Write" }, // auch WRITE # { XOR, "Xor" }, { NIL, "" } @@ -353,6 +354,29 @@ TokenTable aTokTable_Java [] = { // Token-Tabelle: }; */ +// #i109076 +TokenLabelInfo::TokenLabelInfo( void ) +{ + m_pTokenCanBeLabelTab = new bool[VBASUPPORT+1]; + for( int i = 0 ; i <= VBASUPPORT ; ++i ) + m_pTokenCanBeLabelTab[i] = false; + + // Token accepted as label by VBA + SbiToken eLabelToken[] = { ACCESS, ALIAS, APPEND, BASE, BINARY, CLASSMODULE, + COMPARE, COMPATIBLE, DEFERR, _ERROR_, EXPLICIT, LIB, LINE, LPRINT, NAME, + TOBJECT, OUTPUT, PROPERTY, RANDOM, READ, STEP, STOP, TEXT, VBASUPPORT, NIL }; + SbiToken* pTok = eLabelToken; + SbiToken eTok; + for( pTok = eLabelToken ; (eTok = *pTok) != NIL ; ++pTok ) + m_pTokenCanBeLabelTab[eTok] = true; +} + +TokenLabelInfo::~TokenLabelInfo() +{ + delete[] m_pTokenCanBeLabelTab; +} + + // Der Konstruktor ermittelt die Laenge der Token-Tabelle. SbiTokenizer::SbiTokenizer( const ::rtl::OUString& rSrc, StarBASIC* pb ) @@ -371,7 +395,8 @@ SbiTokenizer::SbiTokenizer( const ::rtl::OUString& rSrc, StarBASIC* pb ) } SbiTokenizer::~SbiTokenizer() -{} +{ +} // Wiederablage (Pushback) eines Tokens. (Bis zu 2 Tokens) @@ -513,7 +538,8 @@ SbiToken SbiTokenizer::Next() tp = &pTokTable[ lb + delta ]; StringCompare res = aSym.CompareIgnoreCaseToAscii( tp->s ); // Gefunden? - if( res == COMPARE_EQUAL ) goto special; + if( res == COMPARE_EQUAL ) + goto special; // Groesser? Dann untere Haelfte if( res == COMPARE_LESS ) { @@ -534,24 +560,14 @@ SbiToken SbiTokenizer::Next() return eCurTok = SYMBOL; } special: - // LINE INPUT - if( tp->t == LINE ) - { - short nC1 = nCol1; - String aOldSym = aSym; - eCurTok = Peek(); - if( eCurTok == INPUT ) - { - Next(); - nCol1 = nC1; - return eCurTok = LINEINPUT; - } - else - { - aSym = aOldSym; - return eCurTok = LINE; - } - } + // #i92642 + if( eCurTok != NIL && eCurTok != REM && eCurTok != EOLN && (tp->t == NAME || tp->t == LINE) ) + return eCurTok = SYMBOL; + else if( tp->t == TEXT ) + return eCurTok = SYMBOL; + + // #i92642: Special LINE token handling -> SbiParser::Line() + // END IF, CASE, SUB, DEF, FUNCTION, TYPE, CLASS, WITH if( tp->t == END ) { @@ -639,7 +655,7 @@ special: BOOL SbiTokenizer::MayBeLabel( BOOL bNeedsColon ) { - if( eCurTok == SYMBOL ) + if( eCurTok == SYMBOL || m_aTokenLabelInfo.canTokenBeLabel( eCurTok ) ) return bNeedsColon ? DoesColonFollow() : TRUE; else return BOOL( eCurTok == NUMBER diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx index 3d90d16bdcbe..a3fe02227cfd 100644 --- a/basic/source/inc/codegen.hxx +++ b/basic/source/inc/codegen.hxx @@ -44,6 +44,7 @@ class SbiCodeGen { // Code-Erzeugung: public: SbiCodeGen( SbModule&, SbiParser*, short ); SbiParser* GetParser() { return pParser; } + SbModule& GetModule() { return rMod; } UINT32 Gen( SbiOpcode ); UINT32 Gen( SbiOpcode, UINT32 ); UINT32 Gen( SbiOpcode, UINT32, UINT32 ); @@ -53,7 +54,6 @@ public: void GenStmnt(); // evtl. Statement-Opcode erzeugen UINT32 GetPC(); UINT32 GetOffset() { return GetPC() + 1; } - SbModule& GetModule() { return rMod; } void Save(); // #29955 for-Schleifen-Ebene pflegen diff --git a/basic/source/inc/dlgcont.hxx b/basic/source/inc/dlgcont.hxx index b0b3334b5031..2c927a8286f4 100644 --- a/basic/source/inc/dlgcont.hxx +++ b/basic/source/inc/dlgcont.hxx @@ -54,14 +54,17 @@ class SfxDialogLibraryContainer : public SfxLibraryContainer virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; virtual void SAL_CALL writeLibraryElement ( - ::com::sun::star::uno::Any aElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, const ::rtl::OUString& aElementName, - ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOutput + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput ) throw(::com::sun::star::uno::Exception); virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement - ( const ::rtl::OUString& aFile, + ( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, + const ::rtl::OUString& aElementName, + const ::rtl::OUString& aFile, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ); virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ); diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx index 8ccbcebe4309..9b8f51d09dea 100644 --- a/basic/source/inc/expr.hxx +++ b/basic/source/inc/expr.hxx @@ -52,6 +52,13 @@ struct SbVar { // Variablen-Element: SbiExprListVector* pvMorePar; // Array of arrays foo(pPar)(avMorePar[0])(avMorePar[1])... }; +struct KeywordSymbolInfo +{ + String m_aKeywordSymbol; + SbxDataType m_eSbxDataType; + SbiToken m_eTok; +}; + enum SbiExprType { // Expression-Typen: SbSTDEXPR, // normaler Ausdruck SbLVALUE, // beliebiger lValue @@ -76,6 +83,7 @@ enum SbiNodeType { SbxVARVAL, // aVar = Wert SbxTYPEOF, // TypeOf ObjExpr Is Type SbxNODE, // Node + SbxNEW, // new expression SbxDUMMY }; @@ -107,9 +115,11 @@ class SbiExprNode { // Operatoren (und Operanden) void FoldConstants(); // Constant Folding durchfuehren void CollectBits(); // Umwandeln von Zahlen in Strings BOOL IsOperand() // TRUE, wenn Operand - { return BOOL( eNodeType != SbxNODE && eNodeType != SbxTYPEOF ); } + { return BOOL( eNodeType != SbxNODE && eNodeType != SbxTYPEOF && eNodeType != SbxNEW ); } BOOL IsTypeOf() { return BOOL( eNodeType == SbxTYPEOF ); } + BOOL IsNew() + { return BOOL( eNodeType == SbxNEW ); } BOOL IsNumber(); // TRUE bei Zahlen BOOL IsString(); // TRUE bei Strings BOOL IsLvalue(); // TRUE, falls als Lvalue verwendbar @@ -122,6 +132,7 @@ public: SbiExprNode( SbiParser*, const SbiSymDef&, SbxDataType, SbiExprList* = NULL ); SbiExprNode( SbiParser*, SbiExprNode*, SbiToken, SbiExprNode* ); SbiExprNode( SbiParser*, SbiExprNode*, USHORT ); // #120061 TypeOf + SbiExprNode( SbiParser*, USHORT ); // new virtual ~SbiExprNode(); BOOL IsValid() { return BOOL( !bError ); } @@ -166,9 +177,9 @@ protected: BOOL bByVal; // TRUE: ByVal-Parameter BOOL bBracket; // TRUE: Parameter list with brackets USHORT nParenLevel; - SbiExprNode* Term(); + SbiExprNode* Term( const KeywordSymbolInfo* pKeywordSymbolInfo = NULL ); SbiExprNode* ObjTerm( SbiSymDef& ); - SbiExprNode* Operand(); + SbiExprNode* Operand( bool bUsedForTypeOf = false ); SbiExprNode* Unary(); SbiExprNode* Exp(); SbiExprNode* MulDiv(); @@ -180,7 +191,8 @@ protected: SbiExprNode* Comp(); SbiExprNode* Boolean(); public: - SbiExpression( SbiParser*, SbiExprType = SbSTDEXPR, SbiExprMode eMode = EXPRMODE_STANDARD ); // Parsender Ctor + SbiExpression( SbiParser*, SbiExprType = SbSTDEXPR, + SbiExprMode eMode = EXPRMODE_STANDARD, const KeywordSymbolInfo* pKeywordSymbolInfo = NULL ); // Parsender Ctor SbiExpression( SbiParser*, const String& ); SbiExpression( SbiParser*, double, SbxDataType = SbxDOUBLE ); SbiExpression( SbiParser*, const SbiSymDef&, SbiExprList* = NULL ); diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 1f4084db1d0d..4df1c48557d2 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -284,14 +284,17 @@ protected: virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0; virtual void SAL_CALL writeLibraryElement ( - ::com::sun::star::uno::Any aElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, const ::rtl::OUString& aElementName, - ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOutput + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput ) throw(::com::sun::star::uno::Exception) = 0; virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement - ( const ::rtl::OUString& aFile, + ( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, + const ::rtl::OUString& aElementName, + const ::rtl::OUString& aFile, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ) = 0; virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ) = 0; diff --git a/basic/source/inc/opcodes.hxx b/basic/source/inc/opcodes.hxx index 9d909c03c436..ff7eff027f83 100644 --- a/basic/source/inc/opcodes.hxx +++ b/basic/source/inc/opcodes.hxx @@ -93,6 +93,7 @@ enum SbiOpcode { _VBASET, // VBA-like Set _ERASE_CLEAR, // Erase array and clear variable _ARRAYACCESS, // Assign parameters to TOS and get value, used for array of arrays + _BYVAL, // byref -> byval for lvalue parameter passed in call SbOP0_END, // Alle Opcodes mit einem Operanden diff --git a/basic/source/inc/parser.hxx b/basic/source/inc/parser.hxx index 3dc8525377a2..1161c4ed259d 100644 --- a/basic/source/inc/parser.hxx +++ b/basic/source/inc/parser.hxx @@ -99,7 +99,7 @@ public: BOOL TestComma(); // Komma oder EOLN? void TestEoln(); // EOLN? - void Symbol(); // Let oder Call + void Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo = NULL ); // Let oder Call void ErrorStmnt(); // ERROR n void NotImp(); // nicht implementiert void BadBlock(); // LOOP/WEND/NEXT @@ -119,6 +119,7 @@ public: void If(); // IF void Implements(); // IMPLEMENTS void Input(); // INPUT, INPUT # + void Line(); // LINE -> LINE INPUT [#] (#i92642) void LineInput(); // LINE INPUT, LINE INPUT # void LSet(); // LSET void Name(); // NAME .. AS .. diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index c9a41110ad46..6ca69209a752 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -407,7 +407,7 @@ class SbiRuntime void StepPRINTF(), StepWRITE(), StepRENAME(), StepPROMPT(); void StepRESTART(), StepEMPTY(), StepLEAVE(); void StepLSET(), StepRSET(), StepREDIMP_ERASE(), StepERASE_CLEAR(); - void StepARRAYACCESS(); + void StepARRAYACCESS(), StepBYVAL(); // Alle Opcodes mit einem Operanden void StepLOADNC( UINT32 ), StepLOADSC( UINT32 ), StepLOADI( UINT32 ); void StepARGN( UINT32 ), StepBASED( UINT32 ), StepPAD( UINT32 ); @@ -416,7 +416,7 @@ class SbiRuntime void StepGOSUB( UINT32 ), StepRETURN( UINT32 ); void StepTESTFOR( UINT32 ), StepCASETO( UINT32 ), StepERRHDL( UINT32 ); void StepRESUME( UINT32 ), StepSETCLASS( UINT32 ), StepVBASETCLASS( UINT32 ), StepTESTCLASS( UINT32 ), StepLIB( UINT32 ); - bool checkClass_Impl( const SbxVariableRef& refVal, const String& aClass, bool bRaiseErrors ); + bool checkClass_Impl( const SbxVariableRef& refVal, const String& aClass, bool bRaiseErrors, bool bDefault = true ); void StepCLOSE( UINT32 ), StepPRCHAR( UINT32 ), StepARGTYP( UINT32 ); // Alle Opcodes mit zwei Operanden void StepRTL( UINT32, UINT32 ), StepPUBLIC( UINT32, UINT32 ), StepPUBLIC_P( UINT32, UINT32 ); @@ -434,6 +434,7 @@ class SbiRuntime void StepDCREATE_REDIMP(UINT32,UINT32), StepDCREATE_IMPL(UINT32,UINT32); void StepFIND_CM( UINT32, UINT32 ); void StepFIND_STATIC( UINT32, UINT32 ); + void implCreateFixedString( SbxVariable* pStrVar, UINT32 nOp2 ); public: void SetVBAEnabled( bool bEnabled ); USHORT GetImageFlag( USHORT n ) const; diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx index 5896db78ea40..59cfe21d25a8 100644 --- a/basic/source/inc/sbintern.hxx +++ b/basic/source/inc/sbintern.hxx @@ -39,6 +39,7 @@ namespace utl class SbUnoFactory; class SbTypeFactory; class SbOLEFactory; +class SbFormFactory; class SbiInstance; class SbModule; @@ -101,6 +102,7 @@ struct SbiGlobals SbTypeFactory* pTypeFac; // Factory for user defined types SbClassFactory* pClassFac; // Factory for user defined classes (based on class modules) SbOLEFactory* pOLEFac; // Factory for OLE types + SbFormFactory* pFormFac; // Factory for user forms SbModule* pMod; // aktuell aktives Modul SbModule* pCompMod; // aktuell compiliertes Modul short nInst; // Anzahl BASICs @@ -136,6 +138,7 @@ SbiGlobals* GetSbData(); #define pTYPEFAC GetSbData()->pTypeFac #define pCLASSFAC GetSbData()->pClassFac #define pOLEFAC GetSbData()->pOLEFac +#define pFORMFAC GetSbData()->pFormFac #endif diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx index 31025c48c4a4..d184a2d558e2 100644 --- a/basic/source/inc/scriptcont.hxx +++ b/basic/source/inc/scriptcont.hxx @@ -53,14 +53,17 @@ class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPas virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const; virtual void SAL_CALL writeLibraryElement ( - ::com::sun::star::uno::Any aElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, const ::rtl::OUString& aElementName, - ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOutput + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput ) throw(::com::sun::star::uno::Exception); virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement - ( const ::rtl::OUString& aFile, + ( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary, + const ::rtl::OUString& aElementName, + const ::rtl::OUString& aFile, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ); virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ); diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx index 03202edba910..9bd8cfd49754 100644 --- a/basic/source/inc/symtbl.hxx +++ b/basic/source/inc/symtbl.hxx @@ -132,7 +132,9 @@ protected: BOOL bAs : 1; // TRUE: Datentyp per AS XXX definiert BOOL bGlobal : 1; // TRUE: Global-Variable BOOL bParamArray : 1; // TRUE: ParamArray parameter + BOOL bWithEvents : 1; // TRUE: Declared WithEvents USHORT nDefaultId; // Symbol number of default value + short nFixedStringLength; // String length in: Dim foo As String*Length public: SbiSymDef( const String& ); virtual ~SbiSymDef(); @@ -156,6 +158,7 @@ public: BOOL IsDefined() const{ return bChained; } void SetOptional() { bOpt = TRUE; } void SetParamArray() { bParamArray = TRUE; } + void SetWithEvents() { bWithEvents = TRUE; } void SetByVal() { bByVal = TRUE; } void SetStatic( BOOL bAsStatic = TRUE ) { bStatic = bAsStatic; } void SetNew() { bNew = TRUE; } @@ -165,11 +168,14 @@ public: USHORT GetDefaultId( void ) { return nDefaultId; } BOOL IsOptional() const{ return bOpt; } BOOL IsParamArray() const{ return bParamArray; } + BOOL IsWithEvents() const{ return bWithEvents; } BOOL IsByVal() const { return bByVal; } BOOL IsStatic() const { return bStatic; } BOOL IsNew() const { return bNew; } BOOL IsDefinedAs() const { return bAs; } BOOL IsGlobal() const { return bGlobal; } + short GetFixedStringLength( void ) const { return nFixedStringLength; } + void SetFixedStringLength( short n ) { nFixedStringLength = n; } SbiSymPool& GetPool(); UINT32 Define(); // Symbol in Code definieren diff --git a/basic/source/inc/token.hxx b/basic/source/inc/token.hxx index 3dc1113b57d1..930f68910b78 100644 --- a/basic/source/inc/token.hxx +++ b/basic/source/inc/token.hxx @@ -95,7 +95,7 @@ enum SbiToken { NUMBER=FIRSTEXTRA, FIXSTRING, SYMBOL, _CDECL_, BYVAL, BYREF, OUTPUT, RANDOM, APPEND, BINARY, ACCESS, LOCK, READ, PRESERVE, BASE, ANY, LIB, _OPTIONAL_, - EXPLICIT, COMPATIBLE, CLASSMODULE, PARAMARRAY, + EXPLICIT, COMPATIBLE, CLASSMODULE, PARAMARRAY, WITHEVENTS, // Ab hier kommen JavaScript-Tokens (gleiches enum, damit gleicher Typ) FIRSTJAVA, @@ -120,7 +120,25 @@ enum SbiToken { #undef SbiTokenSHAREDTMPUNDEF #endif +// #i109076 +class TokenLabelInfo +{ + bool* m_pTokenCanBeLabelTab; + +public: + TokenLabelInfo( void ); + TokenLabelInfo( const TokenLabelInfo& rInfo ) + : m_pTokenCanBeLabelTab( NULL ) + { (void)rInfo; } + ~TokenLabelInfo(); + + bool canTokenBeLabel( SbiToken eTok ) + { return m_pTokenCanBeLabelTab[eTok]; } +}; + class SbiTokenizer : public SbiScanner { + TokenLabelInfo m_aTokenLabelInfo; + protected: SbiToken eCurTok; // aktuelles Token SbiToken ePush; // Pushback-Token diff --git a/basic/source/runtime/dllmgr.cxx b/basic/source/runtime/dllmgr.cxx index 22014763bb29..bc08a8cb64bc 100644 --- a/basic/source/runtime/dllmgr.cxx +++ b/basic/source/runtime/dllmgr.cxx @@ -25,647 +25,714 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" +#include "sal/config.h" -#include -#ifdef OS2 -#define INCL_DOSMODULEMGR -#include -#endif - -#if defined( WIN ) || defined( WNT ) -#ifndef _SVWIN_H -#undef WB_LEFT -#undef WB_RIGHT -#include -#endif -#endif -#include -#include -#include -#include -#include - -#if defined(WIN) -typedef HINSTANCE SbiDllHandle; -typedef FARPROC SbiDllProc; -#elif defined(WNT) -typedef HMODULE SbiDllHandle; -typedef int(*SbiDllProc)(); -#elif defined(OS2) -typedef HMODULE SbiDllHandle; -typedef PFN SbiDllProc; -#else -typedef void* SbiDllHandle; -typedef void* SbiDllProc; -#endif +#include +#include +#include +#include +#include -#define _DLLMGR_CXX -#include "dllmgr.hxx" -#include +#include "basic/sbx.hxx" +#include "basic/sbxvar.hxx" +#include "osl/thread.h" +#include "rtl/ref.hxx" +#include "rtl/string.hxx" +#include "rtl/ustring.hxx" +#include "salhelper/simplereferenceobject.hxx" +#include "tools/svwin.h" -#ifndef WINAPI -#ifdef WNT -#define WINAPI __far __pascal -#endif -#endif +#undef max -extern "C" { -#if defined(INTEL) && (defined(WIN) || defined(WNT)) +#include "dllmgr.hxx" -extern INT16 WINAPI CallINT( SbiDllProc, char *stack, short nstack); -extern INT32 WINAPI CallLNG( SbiDllProc, char *stack, short nstack); -#ifndef WNT -extern float WINAPI CallSNG( SbiDllProc, char *stack, short nstack); -#endif -extern double WINAPI CallDBL( SbiDllProc, char *stack, short nstack); -extern char* WINAPI CallSTR( SbiDllProc, char *stack, short nstack); -// extern CallFIX( SbiDllProc, char *stack, short nstack); +/* Open issues: -#else + Only 32-bit Windows for now. -INT16 CallINT( SbiDllProc, char *, short ) { return 0; } -INT32 CallLNG( SbiDllProc, char *, short ) { return 0; } -float CallSNG( SbiDllProc, char *, short ) { return 0; } -double CallDBL( SbiDllProc, char *, short) { return 0; } -char* CallSTR( SbiDllProc, char *, short ) { return 0; } -#endif -} + Missing support for functions returning structs (see TODO in call()). -SV_IMPL_OP_PTRARR_SORT(ImplDllArr,ByteStringPtr) + Missing support for additional data types (64 bit integers, Any, ...; would + trigger OSL_ASSERT(false) in various switches). -/* mit Optimierung An stuerzt unter Win95 folgendes Makro ab: -declare Sub MessageBeep Lib "user32" (ByVal long) -sub main - MessageBeep( 1 ) -end sub + It is assumed that the variables passed into SbiDllMgr::Call to represent + the arguments and return value have types that exactly match the Declare + statement; it would be better if this code had access to the function + signature from the Declare statement, so that it could convert the passed + variables accordingly. */ -#if defined (WNT) && defined (MSC) -//#pragma optimize ("", off) -#endif -// -// *********************************************************************** -// +#if defined WNT // only 32-bit Windows, actually -class ImplSbiProc : public ByteString -{ - SbiDllProc pProc; - ImplSbiProc(); - ImplSbiProc( const ImplSbiProc& ); - -public: - ImplSbiProc( const ByteString& rName, SbiDllProc pFunc ) - : ByteString( rName ) { pProc = pFunc; } - SbiDllProc GetProc() const { return pProc; } -}; +extern "C" { -// -// *********************************************************************** -// +int __stdcall DllMgr_call32(FARPROC, void const * stack, std::size_t size); +double __stdcall DllMgr_callFp(FARPROC, void const * stack, std::size_t size); -class ImplSbiDll : public ByteString -{ - ImplDllArr aProcArr; - SbiDllHandle hDLL; +} - ImplSbiDll( const ImplSbiDll& ); -public: - ImplSbiDll( const ByteString& rName, SbiDllHandle hHandle ) - : ByteString( rName ) { hDLL = hHandle; } - ~ImplSbiDll(); - SbiDllHandle GetHandle() const { return hDLL; } - SbiDllProc GetProc( const ByteString& rName ) const; - void InsertProc( const ByteString& rName, SbiDllProc pProc ); -}; +namespace { -ImplSbiDll::~ImplSbiDll() -{ - USHORT nCount = aProcArr.Count(); - for( USHORT nCur = 0; nCur < nCount; nCur++ ) - { - ImplSbiProc* pProc = (ImplSbiProc*)aProcArr.GetObject( nCur ); - delete pProc; - } +char * address(std::vector< char > & blob) { + return blob.empty() ? 0 : &blob[0]; } -SbiDllProc ImplSbiDll::GetProc( const ByteString& rName ) const -{ - USHORT nPos; - BOOL bRet = aProcArr.Seek_Entry( (ByteStringPtr)&rName, &nPos ); - if( bRet ) - { - ImplSbiProc* pImplProc = (ImplSbiProc*)aProcArr.GetObject(nPos); - return pImplProc->GetProc(); - } - return (SbiDllProc)0; +SbError convert(rtl::OUString const & source, rtl::OString * target) { + return + source.convertToString( + target, osl_getThreadTextEncoding(), + (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | + RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)) + ? ERRCODE_NONE : ERRCODE_BASIC_BAD_ARGUMENT; + //TODO: more specific errcode? } -void ImplSbiDll::InsertProc( const ByteString& rName, SbiDllProc pProc ) -{ - DBG_ASSERT(aProcArr.Seek_Entry((ByteStringPtr)&rName,0)==0,"InsertProc: Already in table"); - ImplSbiProc* pImplProc = new ImplSbiProc( rName, pProc ); - aProcArr.Insert( (ByteStringPtr)pImplProc ); +SbError convert(char const * source, sal_Int32 length, rtl::OUString * target) { + return + rtl_convertStringToUString( + &target->pData, source, length, osl_getThreadTextEncoding(), + (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)) + ? ERRCODE_NONE : ERRCODE_BASIC_BAD_ARGUMENT; + //TODO: more specific errcode? } +struct UnmarshalData { + UnmarshalData(SbxVariable * theVariable, void * theBuffer): + variable(theVariable), buffer(theBuffer) {} -// -// *********************************************************************** -// + SbxVariable * variable; + void * buffer; +}; -SbiDllMgr::SbiDllMgr( const SbiDllMgr& ) -{ -} +struct StringData: public UnmarshalData { + StringData(SbxVariable * theVariable, void * theBuffer, bool theSpecial): + UnmarshalData(theVariable, theBuffer), special(theSpecial) {} -SbiDllMgr::SbiDllMgr() -{ -} + bool special; +}; -SbiDllMgr::~SbiDllMgr() -{ - USHORT nCount = aDllArr.Count(); - for( USHORT nCur = 0; nCur < nCount; nCur++ ) - { - ImplSbiDll* pDll = (ImplSbiDll*)aDllArr.GetObject( nCur ); - FreeDllHandle( pDll->GetHandle() ); - delete pDll; +class MarshalData: private boost::noncopyable { +public: + std::vector< char > * newBlob() { + blobs_.push_front(std::vector< char >()); + return &blobs_.front(); } -} -void SbiDllMgr::FreeDll( const ByteString& rDllName ) -{ - USHORT nPos; - BOOL bRet = aDllArr.Seek_Entry( (ByteStringPtr)&rDllName, &nPos ); - if( bRet ) - { - ImplSbiDll* pDll = (ImplSbiDll*)aDllArr.GetObject(nPos); - FreeDllHandle( pDll->GetHandle() ); - delete pDll; - aDllArr.Remove( nPos, 1 ); - } -} + std::vector< UnmarshalData > unmarshal; + std::vector< StringData > unmarshalStrings; -ImplSbiDll* SbiDllMgr::GetDll( const ByteString& rDllName ) -{ - USHORT nPos; - ImplSbiDll* pDll = 0; - BOOL bRet = aDllArr.Seek_Entry( (ByteStringPtr)&rDllName, &nPos ); - if( bRet ) - pDll = (ImplSbiDll*)aDllArr.GetObject(nPos); - else - { - SbiDllHandle hDll = CreateDllHandle( rDllName ); - if( hDll ) - { - pDll = new ImplSbiDll( rDllName, hDll ); - aDllArr.Insert( (ByteStringPtr)pDll ); - } - } - return pDll; +private: + std::list< std::vector< char > > blobs_; +}; + +std::size_t align(std::size_t address, std::size_t alignment) { + // alignment = 2^k for some k >= 0 + return (address + (alignment - 1)) & ~(alignment - 1); } -SbiDllProc SbiDllMgr::GetProc( ImplSbiDll* pDll, const ByteString& rProcName ) +char * align( + std::vector< char > & blob, std::size_t alignment, std::size_t offset, + std::size_t add) { - DBG_ASSERT(pDll,"GetProc: No dll-ptr"); - SbiDllProc pProc; - pProc = pDll->GetProc( rProcName ); - if( !pProc ) - { - pProc = GetProcAddr( pDll->GetHandle(), rProcName ); - if( pProc ) - pDll->InsertProc( rProcName, pProc ); - } - return pProc; + std::vector< char >::size_type n = blob.size(); + n = align(n - offset, alignment) + offset; //TODO: overflow in align() + blob.resize(n + add); //TODO: overflow + return address(blob) + n; } - -SbError SbiDllMgr::Call( const char* pProcName, const char* pDllName, - SbxArray* pArgs, SbxVariable& rResult, BOOL bCDecl ) +template< typename T > void add( + std::vector< char > & blob, T const & data, std::size_t alignment, + std::size_t offset) { - DBG_ASSERT(pProcName&&pDllName,"Call: Bad parms"); - SbError nSbErr = 0; - ByteString aDllName( pDllName ); - CheckDllName( aDllName ); - ImplSbiDll* pDll = GetDll( aDllName ); - if( pDll ) - { - SbiDllProc pProc = GetProc( pDll, pProcName ); - if( pProc ) - { - if( bCDecl ) - nSbErr = CallProcC( pProc, pArgs, rResult ); - else - nSbErr = CallProc( pProc, pArgs, rResult ); + *reinterpret_cast< T * >(align(blob, alignment, offset, sizeof (T))) = data; +} + +std::size_t alignment(SbxVariable * variable) { + OSL_ASSERT(variable != 0); + if ((variable->GetType() & SbxARRAY) == 0) { + switch (variable->GetType()) { + case SbxINTEGER: + return 2; + case SbxLONG: + case SbxSINGLE: + case SbxSTRING: + return 4; + case SbxDOUBLE: + return 8; + case SbxOBJECT: + { + std::size_t n = 1; + SbxArray * props = PTR_CAST(SbxObject, variable->GetObject())-> + GetProperties(); + for (USHORT i = 0; i < props->Count(); ++i) { + n = std::max(n, alignment(props->Get(i))); + } + return n; + } + case SbxBOOL: + case SbxBYTE: + return 1; + default: + OSL_ASSERT(false); + return 1; + } + } else { + SbxDimArray * arr = PTR_CAST(SbxDimArray, variable->GetObject()); + int dims = arr->GetDims(); + std::vector< INT32 > low(dims); + for (int i = 0; i < dims; ++i) { + INT32 up; + arr->GetDim32(i + 1, low[i], up); } - else - nSbErr = SbERR_PROC_UNDEFINED; + return alignment(arr->Get32(&low[0])); } - else - nSbErr = SbERR_BAD_DLL_LOAD; - return nSbErr; } -// *********************************************************************** -// ******************* abhaengige Implementationen *********************** -// *********************************************************************** +SbError marshal( + bool outer, SbxVariable * variable, bool special, + std::vector< char > & blob, std::size_t offset, MarshalData & data); -void SbiDllMgr::CheckDllName( ByteString& rDllName ) +SbError marshalString( + SbxVariable * variable, bool special, MarshalData & data, void ** buffer) { -#if defined(WIN) || defined(WNT) || defined(OS2) - if( rDllName.Search('.') == STRING_NOTFOUND ) - rDllName += ".DLL"; -#else - (void)rDllName; -#endif + OSL_ASSERT(variable != 0 && buffer != 0); + rtl::OString str; + SbError e = convert(variable->GetString(), &str); + if (e != ERRCODE_NONE) { + return e; + } + std::vector< char > * blob = data.newBlob(); + blob->insert(blob->begin(), str.getStr(), str.getStr() + str.getLength()); + *buffer = address(*blob); + data.unmarshalStrings.push_back(StringData(variable, *buffer, special)); + return ERRCODE_NONE; } - -SbiDllHandle SbiDllMgr::CreateDllHandle( const ByteString& rDllName ) +SbError marshalStruct( + SbxVariable * variable, std::vector< char > & blob, std::size_t offset, + MarshalData & data) { - (void)rDllName; - -#if defined(UNX) - SbiDllHandle hLib=0; -#else - SbiDllHandle hLib; -#endif - -#if defined(WIN) - hLib = LoadLibrary( (const char*)rDllName ); - if( (ULONG)hLib < 32 ) - hLib = 0; - -#elif defined(WNT) - hLib = LoadLibrary( rDllName.GetBuffer() ); - if( !(ULONG)hLib ) - { -#ifdef DBG_UTIL - ULONG nLastErr; - nLastErr = GetLastError(); -#endif - hLib = 0; + OSL_ASSERT(variable != 0); + SbxArray * props = PTR_CAST(SbxObject, variable->GetObject())-> + GetProperties(); + for (USHORT i = 0; i < props->Count(); ++i) { + SbError e = marshal(false, props->Get(i), false, blob, offset, data); + if (e != ERRCODE_NONE) { + return e; + } } - -#elif defined(OS2) - char cErr[ 100 ]; - if( DosLoadModule( (PSZ) cErr, 100, (const char*)rDllName.GetBuffer(), &hLib ) ) - hLib = 0; -#endif - return hLib; + return ERRCODE_NONE; } -void SbiDllMgr::FreeDllHandle( SbiDllHandle hLib ) +SbError marshalArray( + SbxVariable * variable, std::vector< char > & blob, std::size_t offset, + MarshalData & data) { -#if defined(WIN) || defined(WNT) - if( hLib ) - FreeLibrary ((HINSTANCE) hLib); -#elif defined(OS2) - if( hLib ) - DosFreeModule( (HMODULE) hLib ); -#else - (void)hLib; -#endif + OSL_ASSERT(variable != 0); + SbxDimArray * arr = PTR_CAST(SbxDimArray, variable->GetObject()); + int dims = arr->GetDims(); + std::vector< INT32 > low(dims); + std::vector< INT32 > up(dims); + for (int i = 0; i < dims; ++i) { + arr->GetDim32(i + 1, low[i], up[i]); + } + for (std::vector< INT32 > idx = low;;) { + SbError e = marshal( + false, arr->Get32(&idx[0]), false, blob, offset, data); + if (e != ERRCODE_NONE) { + return e; + } + int i = dims - 1; + while (idx[i] == up[i]) { + idx[i] = low[i]; + if (i == 0) { + return ERRCODE_NONE; + } + --i; + } + ++idx[i]; + } } -SbiDllProc SbiDllMgr::GetProcAddr(SbiDllHandle hLib, const ByteString& rProcName) +// 8-aligned structs are only 4-aligned on stack, so alignment of members in +// such structs must take that into account via "offset" +SbError marshal( + bool outer, SbxVariable * variable, bool special, + std::vector< char > & blob, std::size_t offset, MarshalData & data) { - char buf1 [128] = ""; - char buf2 [128] = ""; - - SbiDllProc pProc = 0; - int nOrd = 0; - - // Ordinal? - if( rProcName.GetBuffer()[0] == '@' ) - nOrd = atoi( rProcName.GetBuffer()+1 ); - - // Moegliche Parameter weg: - DBG_ASSERT( sizeof(buf1) > rProcName.Len(), - "SbiDllMgr::GetProcAddr: buffer to small!" ); - strncpy( buf1, rProcName.GetBuffer(), sizeof(buf1)-1 ); - char *p = strchr( buf1, '#' ); - if( p ) - *p = 0; - - DBG_ASSERT( sizeof(buf2) > strlen(buf1) + 1, - "SbiDllMgr::GetProcAddr: buffer to small!" ); - strncpy( buf2, "_", sizeof(buf2)-1 ); - strncat( buf2, buf1, sizeof(buf2)-1-strlen(buf2) ); - -#if defined(WIN) || defined(WNT) - if( nOrd > 0 ) - pProc = (SbiDllProc)GetProcAddress( hLib, (char*)(long) nOrd ); - else - { - // 2. mit Parametern: - pProc = (SbiDllProc)GetProcAddress ( hLib, rProcName.GetBuffer() ); - // 3. nur der Name: - if (!pProc) - pProc = (SbiDllProc)GetProcAddress( hLib, buf1 ); - // 4. der Name mit Underline vorweg: - if( !pProc ) - pProc = (SbiDllProc)GetProcAddress( hLib, buf2 ); + OSL_ASSERT(variable != 0); + if ((variable->GetFlags() & SBX_REFERENCE) == 0) { + if ((variable->GetType() & SbxARRAY) == 0) { + switch (variable->GetType()) { + case SbxINTEGER: + add(blob, variable->GetInteger(), outer ? 4 : 2, offset); + break; + case SbxLONG: + add(blob, variable->GetLong(), 4, offset); + break; + case SbxSINGLE: + add(blob, variable->GetSingle(), 4, offset); + break; + case SbxDOUBLE: + add(blob, variable->GetDouble(), outer ? 4 : 8, offset); + break; + case SbxSTRING: + { + void * p; + SbError e = marshalString(variable, special, data, &p); + if (e != ERRCODE_NONE) { + return e; + } + add(blob, p, 4, offset); + break; + } + case SbxOBJECT: + { + align(blob, outer ? 4 : alignment(variable), offset, 0); + SbError e = marshalStruct(variable, blob, offset, data); + if (e != ERRCODE_NONE) { + return e; + } + break; + } + case SbxBOOL: + add(blob, variable->GetBool(), outer ? 4 : 1, offset); + break; + case SbxBYTE: + add(blob, variable->GetByte(), outer ? 4 : 1, offset); + break; + default: + OSL_ASSERT(false); + break; + } + } else { + SbError e = marshalArray(variable, blob, offset, data); + if (e != ERRCODE_NONE) { + return e; + } + } + } else { + if ((variable->GetType() & SbxARRAY) == 0) { + switch (variable->GetType()) { + case SbxINTEGER: + case SbxLONG: + case SbxSINGLE: + case SbxDOUBLE: + case SbxBOOL: + case SbxBYTE: + add(blob, variable->data(), 4, offset); + break; + case SbxSTRING: + { + std::vector< char > * blob2 = data.newBlob(); + void * p; + SbError e = marshalString(variable, special, data, &p); + if (e != ERRCODE_NONE) { + return e; + } + add(*blob2, p, 4, 0); + add(blob, address(*blob2), 4, offset); + break; + } + case SbxOBJECT: + { + std::vector< char > * blob2 = data.newBlob(); + SbError e = marshalStruct(variable, *blob2, 0, data); + if (e != ERRCODE_NONE) { + return e; + } + void * p = address(*blob2); + if (outer) { + data.unmarshal.push_back(UnmarshalData(variable, p)); + } + add(blob, p, 4, offset); + break; + } + default: + OSL_ASSERT(false); + break; + } + } else { + std::vector< char > * blob2 = data.newBlob(); + SbError e = marshalArray(variable, *blob2, 0, data); + if (e != ERRCODE_NONE) { + return e; + } + void * p = address(*blob2); + if (outer) { + data.unmarshal.push_back(UnmarshalData(variable, p)); + } + add(blob, p, 4, offset); + } } + return ERRCODE_NONE; +} -#elif defined(OS2) - PSZ pp; - APIRET rc; - // 1. Ordinal oder mit Parametern: - rc = DosQueryProcAddr( hLib, nOrd, pp = (char*)rProcName.GetBuffer(), &pProc ); - // 2. nur der Name: - if( rc ) - rc = DosQueryProcAddr( hLib, 0, pp = (PSZ)buf1, &pProc ); - // 3. der Name mit Underline vorweg: - if( rc ) - rc = DosQueryProcAddr( hLib, 0, pp = (PSZ)buf2, &pProc ); - if( rc ) - pProc = NULL; - else - { - // 16-bit oder 32-bit? - ULONG nInfo = 0; - if( DosQueryProcType( hLib, nOrd, pp, &nInfo ) ) - nInfo = 0;; - } -#else - (void)hLib; -#endif - return pProc; +template< typename T > T read(void const ** pointer) { + T const * p = static_cast< T const * >(*pointer); + *pointer = static_cast< void const * >(p + 1); + return *p; } -SbError SbiDllMgr::CallProc( SbiDllProc pProc, SbxArray* pArgs, - SbxVariable& rResult ) -{ -// ByteString aStr("Calling DLL at "); -// aStr += (ULONG)pProc; -// InfoBox( 0, aStr ).Execute(); - INT16 nInt16; int nInt; INT32 nInt32; double nDouble; - char* pStr; - - USHORT nSize; - char* pStack = (char*)CreateStack( pArgs, nSize ); - switch( rResult.GetType() ) - { +void const * unmarshal(SbxVariable * variable, void const * data) { + OSL_ASSERT(variable != 0); + if ((variable->GetType() & SbxARRAY) == 0) { + switch (variable->GetType()) { case SbxINTEGER: - nInt16 = CallINT(pProc, pStack, (short)nSize ); - rResult.PutInteger( nInt16 ); - break; - - case SbxUINT: - case SbxUSHORT: - nInt16 = (INT16)CallINT(pProc, pStack, (short)nSize ); - rResult.PutUShort( (USHORT)nInt16 ); - break; - - case SbxERROR: - nInt16 = (INT16)CallINT(pProc, pStack, (short)nSize ); - rResult.PutErr( (USHORT)nInt16 ); - break; - - case SbxINT: - nInt = CallINT(pProc, pStack, (short)nSize ); - rResult.PutInt( nInt ); + variable->PutInteger(read< sal_Int16 >(&data)); break; - case SbxLONG: - nInt32 = CallLNG(pProc, pStack, (short)nSize ); - rResult.PutLong( nInt32 ); + variable->PutLong(read< sal_Int32 >(&data)); break; - - case SbxULONG: - nInt32 = CallINT(pProc, pStack, (short)nSize ); - rResult.PutULong( (ULONG)nInt32 ); - break; - -#ifndef WNT case SbxSINGLE: - { - float nSingle = CallSNG(pProc, pStack, (short)nSize ); - rResult.PutSingle( nSingle ); + variable->PutSingle(read< float >(&data)); break; - } -#endif - case SbxDOUBLE: -#ifdef WNT - case SbxSINGLE: -#endif - nDouble = CallDBL(pProc, pStack, (short)nSize ); - rResult.PutDouble( nDouble ); + variable->PutDouble(read< double >(&data)); break; - - case SbxDATE: - nDouble = CallDBL(pProc, pStack, (short)nSize ); - rResult.PutDate( nDouble ); + case SbxSTRING: + read< char * >(&data); // handled by unmarshalString break; - - case SbxCHAR: - case SbxBYTE: + case SbxOBJECT: + { + data = reinterpret_cast< void const * >( + align( + reinterpret_cast< sal_uIntPtr >(data), + alignment(variable))); + SbxArray * props = PTR_CAST(SbxObject, variable->GetObject())-> + GetProperties(); + for (USHORT i = 0; i < props->Count(); ++i) { + data = unmarshal(props->Get(i), data); + } + break; + } case SbxBOOL: - nInt16 = CallINT(pProc, pStack, (short)nSize ); - rResult.PutByte( (BYTE)nInt16 ); - break; - - case SbxSTRING: - case SbxLPSTR: - pStr = CallSTR(pProc, pStack, (short)nSize ); - rResult.PutString( String::CreateFromAscii( pStr ) ); + variable->PutBool(read< sal_Bool >(&data)); break; - - case SbxNULL: - case SbxEMPTY: - nInt16 = CallINT(pProc, pStack, (short)nSize ); - // Rueckgabe nur zulaessig, wenn variant! - if( !rResult.IsFixed() ) - rResult.PutInteger( nInt16 ); + case SbxBYTE: + variable->PutByte(read< sal_uInt8 >(&data)); break; - - case SbxCURRENCY: - case SbxOBJECT: - case SbxDATAOBJECT: default: - CallINT(pProc, pStack, (short)nSize ); + OSL_ASSERT(false); break; - } - delete [] pStack; - - if( pArgs ) - { - // die Laengen aller uebergebenen Strings anpassen - USHORT nCount = pArgs->Count(); - for( USHORT nCur = 1; nCur < nCount; nCur++ ) - { - SbxVariable* pVar = pArgs->Get( nCur ); - BOOL bIsString = ( pVar->GetType() == SbxSTRING ) || - ( pVar->GetType() == SbxLPSTR ); - - if( pVar->GetFlags() & SBX_REFERENCE ) - { - pVar->ResetFlag( SBX_REFERENCE ); // Sbx moechte es so - if( bIsString ) - { - ByteString aByteStr( (char*)pVar->GetUserData() ); - String aStr( aByteStr, gsl_getSystemTextEncoding() ); - pVar->PutString( aStr ); + } + } else { + SbxDimArray * arr = PTR_CAST(SbxDimArray, variable->GetObject()); + int dims = arr->GetDims(); + std::vector< INT32 > low(dims); + std::vector< INT32 > up(dims); + for (int i = 0; i < dims; ++i) { + arr->GetDim32(i + 1, low[i], up[i]); + } + for (std::vector< INT32 > idx = low;;) { + data = unmarshal(arr->Get32(&idx[0]), data); + int i = dims - 1; + while (idx[i] == up[i]) { + idx[i] = low[i]; + if (i == 0) { + goto done; } + --i; } - if( bIsString ) - { - delete (char*)(pVar->GetUserData()); - pVar->SetUserData( 0 ); - } + ++idx[i]; } + done:; } - return 0; + return data; } -SbError SbiDllMgr::CallProcC( SbiDllProc pProc, SbxArray* pArgs, - SbxVariable& rResult ) -{ - (void)pProc; - (void)pArgs; - (void)rResult; - - DBG_ERROR("C calling convention not supported"); - return SbERR_BAD_ARGUMENT; +SbError unmarshalString(StringData const & data, SbxVariable & result) { + rtl::OUString str; + if (data.buffer != 0) { + char const * p = static_cast< char const * >(data.buffer); + sal_Int32 len; + if (data.special) { + len = static_cast< sal_Int32 >(result.GetULong()); + if (len < 0) { // i.e., DWORD result >= 2^31 + return ERRCODE_BASIC_BAD_ARGUMENT; + //TODO: more specific errcode? + } + } else { + len = rtl_str_getLength(p); + } + SbError e = convert(p, len, &str); + if (e != ERRCODE_NONE) { + return e; + } + } + data.variable->PutString(String(str)); + return ERRCODE_NONE; } -void* SbiDllMgr::CreateStack( SbxArray* pArgs, USHORT& rSize ) +struct ProcData { + rtl::OString name; + FARPROC proc; +}; + +SbError call( + rtl::OUString const & dll, ProcData const & proc, SbxArray * arguments, + SbxVariable & result) { - if( !pArgs ) + std::vector< char > stack; + MarshalData data; + // For DWORD GetLogicalDriveStringsA(DWORD nBufferLength, LPSTR lpBuffer) + // from kernel32, upon return, filled lpBuffer length is result DWORD, which + // requires special handling in unmarshalString; other functions might + // require similar treatment, too: + bool special = + dll.equalsIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM("KERNEL32.DLL")) && + (proc.name == + rtl::OString(RTL_CONSTASCII_STRINGPARAM("GetLogicalDriveStringsA"))); + for (USHORT i = 1; i < (arguments == 0 ? 0 : arguments->Count()); ++i) { + SbError e = marshal( + true, arguments->Get(i), special && i == 2, stack, stack.size(), + data); + if (e != ERRCODE_NONE) { + return e; + } + align(stack, 4, 0, 0); + } + switch (result.GetType()) { + case SbxEMPTY: + DllMgr_call32(proc.proc, address(stack), stack.size()); + break; + case SbxINTEGER: + result.PutInteger( + static_cast< sal_Int16 >( + DllMgr_call32(proc.proc, address(stack), stack.size()))); + break; + case SbxLONG: + result.PutLong( + static_cast< sal_Int32 >( + DllMgr_call32(proc.proc, address(stack), stack.size()))); + break; + case SbxSINGLE: + result.PutSingle( + static_cast< float >( + DllMgr_callFp(proc.proc, address(stack), stack.size()))); + break; + case SbxDOUBLE: + result.PutDouble( + DllMgr_callFp(proc.proc, address(stack), stack.size())); + break; + case SbxSTRING: + { + char const * s1 = reinterpret_cast< char const * >( + DllMgr_call32(proc.proc, address(stack), stack.size())); + rtl::OUString s2; + SbError e = convert(s1, rtl_str_getLength(s1), &s2); + if (e != ERRCODE_NONE) { + return e; + } + result.PutString(String(s2)); + break; + } + case SbxOBJECT: + //TODO + DllMgr_call32(proc.proc, address(stack), stack.size()); + break; + case SbxBOOL: + result.PutBool( + static_cast< sal_Bool >( + DllMgr_call32(proc.proc, address(stack), stack.size()))); + break; + case SbxBYTE: + result.PutByte( + static_cast< sal_uInt8 >( + DllMgr_call32(proc.proc, address(stack), stack.size()))); + break; + default: + OSL_ASSERT(false); + break; + } + for (USHORT i = 1; i < (arguments == 0 ? 0 : arguments->Count()); ++i) { + arguments->Get(i)->ResetFlag(SBX_REFERENCE); + //TODO: skipped for errors?!? + } + for (std::vector< UnmarshalData >::iterator i(data.unmarshal.begin()); + i != data.unmarshal.end(); ++i) { - rSize = 0; - return 0; + unmarshal(i->variable, i->buffer); } - char* pStack = new char[ 2048 ]; - char* pTop = pStack; - USHORT nCount = pArgs->Count(); - // erstes Element ueberspringen -#ifndef WIN - for( USHORT nCur = 1; nCur < nCount; nCur++ ) -#else - // unter 16-Bit Windows anders rum (OS/2 ?????) - for( USHORT nCur = nCount-1; nCur >= 1; nCur-- ) -#endif + for (std::vector< StringData >::iterator i(data.unmarshalStrings.begin()); + i != data.unmarshalStrings.end(); ++i) { - SbxVariable* pVar = pArgs->Get( nCur ); - // AB 22.1.1996, Referenz - if( pVar->GetFlags() & SBX_REFERENCE ) // Es ist eine Referenz - { - switch( pVar->GetType() ) - { - case SbxINTEGER: - case SbxUINT: - case SbxINT: - case SbxUSHORT: - case SbxLONG: - case SbxULONG: - case SbxSINGLE: - case SbxDOUBLE: - case SbxCHAR: - case SbxBYTE: - case SbxBOOL: - *((void**)pTop) = (void*)&(pVar->aData); - pTop += sizeof( void* ); - break; - - case SbxSTRING: - case SbxLPSTR: - { - USHORT nLen = 256; - ByteString rStr( pVar->GetString(), gsl_getSystemTextEncoding() ); - if( rStr.Len() > 255 ) - nLen = rStr.Len() + 1; - - char* pStr = new char[ nLen ]; - strcpy( pStr, rStr.GetBuffer() ); // #100211# - checked - // ist nicht so sauber, aber wir sparen ein Pointerarray - DBG_ASSERT(sizeof(UINT32)>=sizeof(char*),"Gleich krachts im Basic"); - pVar->SetUserData( (sal_uIntPtr)pStr ); - *((const char**)pTop) = pStr; - pTop += sizeof( char* ); - } - break; + SbError e = unmarshalString(*i, result); + if (e != ERRCODE_NONE) { + return e; + } + } + return ERRCODE_NONE; +} - case SbxNULL: - case SbxEMPTY: - case SbxERROR: - case SbxDATE: - case SbxCURRENCY: - case SbxOBJECT: - case SbxDATAOBJECT: - default: - break; +SbError getProcData(HMODULE handle, rtl::OUString const & name, ProcData * proc) +{ + OSL_ASSERT(proc != 0); + if (name.getLength() != 0 && name[0] == '@') { //TODO: "@" vs. "#"??? + sal_Int32 n = name.copy(1).toInt32(); //TODO: handle bad input + if (n <= 0 || n > 0xFFFF) { + return ERRCODE_BASIC_BAD_ARGUMENT; //TODO: more specific errcode? + } + FARPROC p = GetProcAddress(handle, reinterpret_cast< LPCSTR >(n)); + if (p != 0) { + proc->name = rtl::OString(RTL_CONSTASCII_STRINGPARAM("#")) + + rtl::OString::valueOf(n); + proc->proc = p; + return ERRCODE_NONE; + } + } else { + rtl::OString name8; + SbError e = convert(name, &name8); + if (e != ERRCODE_NONE) { + return e; + } + FARPROC p = GetProcAddress(handle, name8.getStr()); + if (p != 0) { + proc->name = name8; + proc->proc = p; + return ERRCODE_NONE; + } + sal_Int32 i = name8.indexOf('#'); + if (i != -1) { + name8 = name8.copy(0, i); + p = GetProcAddress(handle, name8.getStr()); + if (p != 0) { + proc->name = name8; + proc->proc = p; + return ERRCODE_NONE; } } - else - { - // ByVal - switch( pVar->GetType() ) - { - case SbxINTEGER: - case SbxUINT: - case SbxINT: - case SbxUSHORT: - *((INT16*)pTop) = pVar->GetInteger(); - pTop += sizeof( INT16 ); - break; + rtl::OString real( + rtl::OString(RTL_CONSTASCII_STRINGPARAM("_")) + name8); + p = GetProcAddress(handle, real.getStr()); + if (p != 0) { + proc->name = real; + proc->proc = p; + return ERRCODE_NONE; + } + real = name8 + rtl::OString(RTL_CONSTASCII_STRINGPARAM("A")); + p = GetProcAddress(handle, real.getStr()); + if (p != 0) { + proc->name = real; + proc->proc = p; + return ERRCODE_NONE; + } + } + return ERRCODE_BASIC_PROC_UNDEFINED; +} - case SbxLONG: - case SbxULONG: - *((INT32*)pTop) = pVar->GetLong(); - pTop += sizeof( INT32 ); - break; +struct Dll: public salhelper::SimpleReferenceObject { +private: + typedef std::map< rtl::OUString, ProcData > Procs; - case SbxSINGLE: - *((float*)pTop) = pVar->GetSingle(); - pTop += sizeof( float ); - break; + virtual ~Dll(); - case SbxDOUBLE: - *((double*)pTop) = pVar->GetDouble(); - pTop += sizeof( double ); - break; +public: + Dll(): handle(0) {} - case SbxSTRING: - case SbxLPSTR: - { - char* pStr = new char[ pVar->GetString().Len() + 1 ]; - ByteString aByteStr( pVar->GetString(), gsl_getSystemTextEncoding() ); - strcpy( pStr, aByteStr.GetBuffer() ); // #100211# - checked - // ist nicht so sauber, aber wir sparen ein Pointerarray - DBG_ASSERT(sizeof(UINT32)>=sizeof(char*),"Gleich krachts im Basic"); - pVar->SetUserData( (sal_uIntPtr)pStr ); - *((const char**)pTop) = pStr; - pTop += sizeof( char* ); - } - break; + SbError getProc(rtl::OUString const & name, ProcData * proc); - case SbxCHAR: - case SbxBYTE: - case SbxBOOL: - *((BYTE*)pTop) = pVar->GetByte(); - pTop += sizeof( BYTE ); - break; + HMODULE handle; + Procs procs; +}; - case SbxNULL: - case SbxEMPTY: - case SbxERROR: - case SbxDATE: - case SbxCURRENCY: - case SbxOBJECT: - case SbxDATAOBJECT: - default: - break; - } +Dll::~Dll() { + if (handle != 0 && !FreeLibrary(handle)) { + OSL_TRACE("FreeLibrary(%p) failed with %u", handle, GetLastError()); + } +} + +SbError Dll::getProc(rtl::OUString const & name, ProcData * proc) { + Procs::iterator i(procs.find(name)); + if (i != procs.end()) { + *proc = i->second; + return ERRCODE_NONE; + } + SbError e = getProcData(handle, name, proc); + if (e == ERRCODE_NONE) { + procs.insert(Procs::value_type(name, *proc)); + } + return e; +} + +rtl::OUString fullDllName(rtl::OUString const & name) { + rtl::OUString full(name); + if (full.indexOf('.') == -1) { + full += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".DLL")); + } + return full; +} + +} + +struct SbiDllMgr::Impl: private boost::noncopyable { +private: + typedef std::map< rtl::OUString, rtl::Reference< Dll > > Dlls; + +public: + Dll * getDll(rtl::OUString const & name); + + Dlls dlls; +}; + +Dll * SbiDllMgr::Impl::getDll(rtl::OUString const & name) { + Dlls::iterator i(dlls.find(name)); + if (i == dlls.end()) { + i = dlls.insert(Dlls::value_type(name, new Dll)).first; + HMODULE h = LoadLibraryW(name); + if (h == 0) { + dlls.erase(i); + return 0; } + i->second->handle = h; } - rSize = (USHORT)((ULONG)pTop - (ULONG)pStack); - return pStack; + return i->second.get(); } +SbError SbiDllMgr::Call( + rtl::OUString const & function, rtl::OUString const & library, + SbxArray * arguments, SbxVariable & result, bool cdeclConvention) +{ + if (cdeclConvention) { + return ERRCODE_BASIC_NOT_IMPLEMENTED; + } + rtl::OUString dllName(fullDllName(library)); + Dll * dll = impl_->getDll(dllName); + if (dll == 0) { + return ERRCODE_BASIC_BAD_DLL_LOAD; + } + ProcData proc; + SbError e = dll->getProc(function, &proc); + if (e != ERRCODE_NONE) { + return e; + } + return call(dllName, proc, arguments, result); +} + +void SbiDllMgr::FreeDll(rtl::OUString const & library) { + impl_->dlls.erase(library); +} +#else + +struct SbiDllMgr::Impl {}; + +SbError SbiDllMgr::Call( + rtl::OUString const &, rtl::OUString const &, SbxArray *, SbxVariable &, + bool) +{ + return ERRCODE_BASIC_NOT_IMPLEMENTED; +} + +void SbiDllMgr::FreeDll(rtl::OUString const &) {} + +#endif +SbiDllMgr::SbiDllMgr(): impl_(new Impl) {} +SbiDllMgr::~SbiDllMgr() {} diff --git a/basic/source/runtime/dllmgr.hxx b/basic/source/runtime/dllmgr.hxx index 2c71a2843c37..fdff8c2849be 100644 --- a/basic/source/runtime/dllmgr.hxx +++ b/basic/source/runtime/dllmgr.hxx @@ -25,71 +25,36 @@ * ************************************************************************/ -#ifndef _DLLMGR_HXX -#define _DLLMGR_HXX +#ifndef INCLUDED_BASIC_SOURCE_RUNTIME_DLLMGR_HXX +#define INCLUDED_BASIC_SOURCE_RUNTIME_DLLMGR_HXX -#define _SVSTDARR_BYTESTRINGSSORT -#include -#ifndef _SVSTDARR_HXX //autogen -#include -#endif +#include "sal/config.h" -// !!! nur zum debuggen fuer infoboxes !!! -//#ifndef _SV_HXX -//#include -//#endif +#include -//#ifndef _TOOLS_HXX -//#include -//#endif -#define _SVSTDARR_STRINGS -//#ifndef _SVSTDARR_HXX -//#include -//#endif -#ifndef _SBERRORS_HXX -#include -#endif +#include "basic/sberrors.hxx" +#include "boost/noncopyable.hpp" +namespace rtl { class OUString; } class SbxArray; class SbxVariable; -class ImplSbiDll; -class ImplSbiProc; - -SV_DECL_PTRARR_SORT(ImplDllArr,ByteStringPtr,5,5) - -class SbiDllMgr -{ - ImplDllArr aDllArr; - - SbiDllMgr( const SbiDllMgr& ); +class SbiDllMgr: private boost::noncopyable { +public: + SbiDllMgr(); -#ifdef _DLLMGR_CXX - ImplSbiDll* GetDll( const ByteString& rDllName ); - SbiDllProc GetProc( ImplSbiDll*, const ByteString& rProcName ); + ~SbiDllMgr(); - SbiDllHandle CreateDllHandle( const ByteString& rDllName ); - void FreeDllHandle( SbiDllHandle ); - SbiDllProc GetProcAddr( SbiDllHandle, const ByteString& pProcName ); - SbError CallProc( SbiDllProc pProc, SbxArray* pArgs, - SbxVariable& rResult ); - SbError CallProcC( SbiDllProc pProc, SbxArray* pArgs, - SbxVariable& rResult ); - void* CreateStack( SbxArray* pArgs, USHORT& rSize ); - void CheckDllName( ByteString& rName ); -#endif + SbError Call( + rtl::OUString const & function, rtl::OUString const & library, + SbxArray * arguments, SbxVariable & result, bool cdeclConvention); -public: - SbiDllMgr(); - ~SbiDllMgr(); + void FreeDll(rtl::OUString const & library); - SbError Call( const char* pFunc, const char* pDll, - SbxArray* pArgs, SbxVariable& rResult, - BOOL bCDecl ); +private: + struct Impl; - void FreeDll( const ByteString& rDllName ); + std::auto_ptr< Impl > impl_; }; - - #endif diff --git a/basic/source/runtime/makefile.mk b/basic/source/runtime/makefile.mk index 9bd197975ee6..f2ed11196b28 100644 --- a/basic/source/runtime/makefile.mk +++ b/basic/source/runtime/makefile.mk @@ -30,6 +30,8 @@ PRJ=..$/.. PRJNAME=basic TARGET=runtime +ENABLE_EXCEPTIONS = TRUE + # --- Settings ----------------------------------------------------------- .INCLUDE : settings.mk @@ -53,29 +55,12 @@ SLOFILES= \ $(SLO)$/ddectrl.obj \ $(SLO)$/dllmgr.obj -.IF "$(GUI)$(CPU)" == "WINI" -SLOFILES+= $(SLO)$/win.obj -.ENDIF - .IF "$(GUI)$(COM)$(CPU)" == "WNTMSCI" SLOFILES+= $(SLO)$/wnt.obj -.ENDIF - -.IF "$(GUI)$(COM)$(CPU)" == "WNTGCCI" +.ELIF "$(GUI)$(COM)$(CPU)" == "WNTGCCI" SLOFILES+= $(SLO)$/wnt-mingw.obj .ENDIF -.IF "$(GUI)$(CPU)" == "OS2I" -#FIXME SLOFILES+= $(SLO)$/os2.obj -.ENDIF - -EXCEPTIONSFILES=$(SLO)$/step0.obj \ - $(SLO)$/step2.obj \ - $(SLO)$/methods.obj \ - $(SLO)$/methods1.obj \ - $(SLO)$/iosys.obj \ - $(SLO)$/runtime.obj - # --- Targets ------------------------------------------------------------- .INCLUDE : target.mk diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index b25c213a493d..8c7da2403705 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -523,6 +523,18 @@ RTLFUNC(WaitUntil) Wait_Impl( true, rPar ); } +RTLFUNC(DoEvents) +{ + (void)pBasic; + (void)bWrite; + (void)rPar; + Timer aTimer; + aTimer.SetTimeout( 1 ); + aTimer.Start(); + while ( aTimer.IsActive() ) + Application::Yield(); +} + RTLFUNC(GetGUIVersion) { (void)pBasic; @@ -622,8 +634,7 @@ RTLFUNC(FreeLibrary) if ( rPar.Count() != 2 ) StarBASIC::Error( SbERR_BAD_ARGUMENT ); - ByteString aByteDLLName( rPar.Get(1)->GetString(), gsl_getSystemTextEncoding() ); - pINST->GetDllMgr()->FreeDll( aByteDLLName ); + pINST->GetDllMgr()->FreeDll( rPar.Get(1)->GetString() ); } bool IsBaseIndexOne() { diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx index 6c90c408cd93..1a1ae4f32283 100644 --- a/basic/source/runtime/rtlproto.hxx +++ b/basic/source/runtime/rtlproto.hxx @@ -166,6 +166,7 @@ extern RTLFUNC(RmDir); // JSM extern RTLFUNC(SendKeys); // JSM extern RTLFUNC(DimArray); extern RTLFUNC(Dir); +extern RTLFUNC(DoEvents); extern RTLFUNC(Exp); extern RTLFUNC(FileLen); extern RTLFUNC(Fix); diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 29e49b0ffde8..1ace790f8aee 100755 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -155,6 +155,7 @@ SbiRuntime::pStep0 SbiRuntime::aStep0[] = { // Alle Opcodes ohne Operanden &SbiRuntime::StepVBASET,// vba-like set statement &SbiRuntime::StepERASE_CLEAR,// vba-like set statement &SbiRuntime::StepARRAYACCESS,// access TOS as array + &SbiRuntime::StepBYVAL, // access TOS as array }; SbiRuntime::pStep1 SbiRuntime::aStep1[] = { // Alle Opcodes mit einem Operanden @@ -1231,9 +1232,7 @@ void SbiRuntime::DllCall SbxVariable* pRes = new SbxVariable( eResType ); SbiDllMgr* pDllMgr = pInst->GetDllMgr(); - ByteString aByteFuncName( aFuncName, gsl_getSystemTextEncoding() ); - ByteString aByteDLLName( aDLLName, gsl_getSystemTextEncoding() ); - SbError nErr = pDllMgr->Call( aByteFuncName.GetBuffer(), aByteDLLName.GetBuffer(), pArgs, *pRes, bCDecl ); + SbError nErr = pDllMgr->Call( aFuncName, aDLLName, pArgs, *pRes, bCDecl ); if( nErr ) Error( nErr ); PushVar( pRes ); diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 13bc8810144a..60d2e9cf448d 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -216,6 +216,7 @@ static Methods aMethods[] = { { "Dir", SbxSTRING, 2 | _FUNCTION, RTLNAME(Dir),0 }, { "FileSpec", SbxSTRING, _OPT, NULL,0 }, { "attrmask", SbxINTEGER, _OPT, NULL,0 }, +{ "DoEvents", SbxEMPTY, _FUNCTION, RTLNAME(DoEvents),0 }, { "DumpAllObjects", SbxEMPTY, 2 | _SUB, RTLNAME(DumpAllObjects),0 }, { "FileSpec", SbxSTRING, 0,NULL,0 }, { "DumpAll", SbxINTEGER, _OPT, NULL,0 }, @@ -361,6 +362,8 @@ static Methods aMethods[] = { { "Count", SbxLONG, 0,NULL,0 }, { "Len", SbxLONG, 1 | _FUNCTION, RTLNAME(Len),0 }, { "StringOrVariant", SbxVARIANT, 0,NULL,0 }, +{ "LenB", SbxLONG, 1 | _FUNCTION, RTLNAME(Len),0 }, + { "StringOrVariant", SbxVARIANT, 0,NULL,0 }, { "Load", SbxNULL, 1 | _FUNCTION, RTLNAME(Load),0 }, { "object", SbxOBJECT, 0,NULL,0 }, { "LoadPicture", SbxOBJECT, 1 | _FUNCTION, RTLNAME(LoadPicture),0 }, @@ -628,6 +631,10 @@ SbiStdObject::SbiStdObject( const String& r, StarBASIC* pb ) : SbxObject( r ) p += ( p->nArgs & _ARGSMASK ) + 1; } + // #i92642: Remove default properties + Remove( XubString( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_DONTCARE ); + Remove( XubString( RTL_CONSTASCII_USTRINGPARAM("Parent") ), SbxCLASS_DONTCARE ); + SetParent( pb ); pStdFactory = new SbStdFactory; diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 39af5ea4adc3..1d9333ff7555 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -43,6 +43,9 @@ #include #include +Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::OUString& aVBAType, + const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj ); + #include SbxVariable* getDefaultProp( SbxVariable* pRef ); @@ -515,8 +518,29 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b } } + // Handle withevents + BOOL bWithEvents = refVar->IsSet( SBX_WITH_EVENTS ); + Reference< XInterface > xComListener; + if( bWithEvents ) + { + SbxBase* pObj = refVal->GetObject(); + SbUnoObject* pUnoObj = (pObj != NULL) ? PTR_CAST(SbUnoObject,pObj) : NULL; + if( pUnoObj != NULL ) + { + Any aControlAny = pUnoObj->getUnoAny(); + String aDeclareClassName = refVar->GetDeclareClassName(); + ::rtl::OUString aVBAType = aDeclareClassName; + ::rtl::OUString aPrefix = refVar->GetName(); + SbxObjectRef xScopeObj = refVar->GetParent(); + xComListener = createComListener( aControlAny, aVBAType, aPrefix, xScopeObj ); + } + } + *refVar = *refVal; + if( bWithEvents ) + refVar->SetComListener( xComListener ); // Hold reference + // lhs is a property who's value is currently (Empty e.g. no broadcast yet) // in this case if there is a default prop involved the value of the // default property may infact be void so the type will also be SbxEMPTY @@ -908,6 +932,19 @@ void SbiRuntime::StepARRAYACCESS() PushVar( CheckArray( refVar ) ); } +void SbiRuntime::StepBYVAL() +{ + // Copy variable on stack to break call by reference + SbxVariableRef pVar = PopVar(); + SbxDataType t = pVar->GetType(); + + SbxVariable* pCopyVar = new SbxVariable( t ); + pCopyVar->SetFlag( SBX_READWRITE ); + *pCopyVar = *pVar; + + PushVar( pCopyVar ); +} + // Einrichten eines Argvs // nOp1 bleibt so -> 1. Element ist Returnwert diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx index c6f090048bf2..e23ef864218e 100644 --- a/basic/source/runtime/step1.cxx +++ b/basic/source/runtime/step1.cxx @@ -453,9 +453,9 @@ bool SbiRuntime::implIsClass( SbxObject* pObj, const String& aClass ) } bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal, - const String& aClass, bool bRaiseErrors ) + const String& aClass, bool bRaiseErrors, bool bDefault ) { - bool bOk = true; + bool bOk = bDefault; SbxDataType t = refVal->GetType(); if( t == SbxOBJECT ) @@ -489,6 +489,8 @@ bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal, } else { + bOk = true; + SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pObj); if( pClassModuleObject != NULL ) pClassModuleObject->triggerInitializeEvent(); @@ -532,7 +534,8 @@ void SbiRuntime::StepTESTCLASS( UINT32 nOp1 ) { SbxVariableRef xObjVal = PopVar(); String aClass( pImg->GetString( static_cast( nOp1 ) ) ); - bool bOk = checkClass_Impl( xObjVal, aClass, false ); + bool bDefault = !bVBAEnabled; + bool bOk = checkClass_Impl( xObjVal, aClass, false, bDefault ); SbxVariable* pRet = new SbxVariable; pRet->PutBool( bOk ); diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index 3a260ad203a3..72ea67dd8db4 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -1068,9 +1068,17 @@ void SbiRuntime::StepTCREATE( UINT32 nOp1, UINT32 nOp2 ) pCopyObj->SetName( aName ); SbxVariable* pNew = new SbxVariable; pNew->PutObject( pCopyObj ); + pNew->SetDeclareClassName( aClass ); PushVar( pNew ); } +void SbiRuntime::implCreateFixedString( SbxVariable* pStrVar, UINT32 nOp2 ) +{ + USHORT nCount = static_cast( nOp2 >> 17 ); // len = all bits above 0x10000 + String aStr; + aStr.Fill( nCount, 0 ); + pStrVar->PutString( aStr ); +} // Einrichten einer lokalen Variablen (+StringID+Typ) @@ -1081,9 +1089,15 @@ void SbiRuntime::StepLOCAL( UINT32 nOp1, UINT32 nOp2 ) String aName( pImg->GetString( static_cast( nOp1 ) ) ); if( refLocals->Find( aName, SbxCLASS_DONTCARE ) == NULL ) { - SbxDataType t = (SbxDataType) nOp2; + SbxDataType t = (SbxDataType)(nOp2 & 0xffff); SbxVariable* p = new SbxVariable( t ); p->SetName( aName ); + bool bWithEvents = ((t & 0xff) == SbxOBJECT && (nOp2 & SBX_TYPE_WITH_EVENTS_FLAG) != 0); + if( bWithEvents ) + p->SetFlag( SBX_WITH_EVENTS ); + bool bFixedString = ((t & 0xff) == SbxSTRING && (nOp2 & SBX_FIXED_LEN_STRING_FLAG) != 0); + if( bFixedString ) + implCreateFixedString( p, nOp2 ); refLocals->Put( p, refLocals->Count() ); } } @@ -1093,7 +1107,7 @@ void SbiRuntime::StepLOCAL( UINT32 nOp1, UINT32 nOp2 ) void SbiRuntime::StepPUBLIC_Impl( UINT32 nOp1, UINT32 nOp2, bool bUsedForClassModule ) { String aName( pImg->GetString( static_cast( nOp1 ) ) ); - SbxDataType t = (SbxDataType) nOp2; + SbxDataType t = (SbxDataType)(SbxDataType)(nOp2 & 0xffff);; BOOL bFlag = pMod->IsSet( SBX_NO_MODIFY ); pMod->SetFlag( SBX_NO_MODIFY ); SbxVariableRef p = pMod->Find( aName, SbxCLASS_PROPERTY ); @@ -1109,6 +1123,13 @@ void SbiRuntime::StepPUBLIC_Impl( UINT32 nOp1, UINT32 nOp2, bool bUsedForClassMo pProp->SetFlag( SBX_DONTSTORE ); // AB: 2.7.1996: HACK wegen 'Referenz kann nicht gesichert werden' pProp->SetFlag( SBX_NO_MODIFY); + + bool bWithEvents = ((t & 0xff) == SbxOBJECT && (nOp2 & SBX_TYPE_WITH_EVENTS_FLAG) != 0); + if( bWithEvents ) + pProp->SetFlag( SBX_WITH_EVENTS ); + bool bFixedString = ((t & 0xff) == SbxSTRING && (nOp2 & SBX_FIXED_LEN_STRING_FLAG) != 0); + if( bFixedString ) + implCreateFixedString( p, nOp2 ); } } @@ -1122,7 +1143,10 @@ void SbiRuntime::StepPUBLIC_P( UINT32 nOp1, UINT32 nOp2 ) // Creates module variable that isn't reinitialised when // between invocations ( for VBASupport & document basic only ) if( pMod->pImage->bFirstInit ) - StepPUBLIC( nOp1, nOp2 ); + { + bool bUsedForClassModule = pImg->GetFlag( SBIMG_CLASSMODULE ); + StepPUBLIC_Impl( nOp1, nOp2, bUsedForClassModule ); + } } // Einrichten einer globalen Variablen (+StringID+Typ) @@ -1133,7 +1157,7 @@ void SbiRuntime::StepGLOBAL( UINT32 nOp1, UINT32 nOp2 ) StepPUBLIC_Impl( nOp1, nOp2, true ); String aName( pImg->GetString( static_cast( nOp1 ) ) ); - SbxDataType t = (SbxDataType) nOp2; + SbxDataType t = (SbxDataType)(SbxDataType)(nOp2 & 0xffff);; BOOL bFlag = rBasic.IsSet( SBX_NO_MODIFY ); rBasic.SetFlag( SBX_NO_MODIFY ); SbxVariableRef p = rBasic.Find( aName, SbxCLASS_PROPERTY ); diff --git a/basic/source/runtime/wnt-mingw.s b/basic/source/runtime/wnt-mingw.s index 1168804102d0..7868ddd386f0 100644 --- a/basic/source/runtime/wnt-mingw.s +++ b/basic/source/runtime/wnt-mingw.s @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -23,71 +23,31 @@ # # for a copy of the LGPLv3 License. # -#************************************************************************* - -# Anmerkungen -# Direktaufruf von C- und PASCAL-Routinen, Windows und OS/2 -# -# Inhalt: -# type = CallXXX (far *pProc, char *pStack, short nStack) -# -# Kopie des Basic-Stacks (nStack Bytes) auf den C-Stack -# und Aufruf der Prozedur. - - .intel_syntax - #.386 - -#_TEXT SEGMENT DWORD PUBLIC 'CODE' USE32 - - #ASSUME CS:_TEXT - -.globl _CallINT -.globl _CallLNG -.globl _CallDBL -.globl _CallSTR -.globl _CallFIX - -_CallINT: -_CallLNG: -_CallDBL: -_CallSTR: - -_CallFIX: PUSH EBP - MOV EBP,ESP - PUSH ESI - PUSH EDI - - PUSH ECX - PUSH EDX - - MOV DX,DS - MOVZX EAX,WORD PTR [EBP+16] # EAX == nStack - SUB ESP,EAX # Stack um nStack Bytes vergroessern - MOV EDI,ESP - MOV AX,SS - MOV ES,AX # ES:EDI = Startadresse des fuer - # Parameter reservierten Stackbereichs - MOV ESI,[EBP+12] # DS:ESI == pStack - - MOVZX ECX,WORD PTR [EBP+16] # ECX == nStack - SHR ECX,1 - CLD - JCXZ $1 - REP MOVSW # Stack uebernehmen -$1: MOV DS,DX - CALL DWORD PTR [EBP+8] # Aufruf der Prozedur - # CLI # unter NT nicht erlaubt (privileged instruction) - MOV ESP,EBP - SUB ESP,16 # wegen gepushter Register - # (ESI, EDI) - # STI - POP EDX - POP ECX - POP EDI - POP ESI - POP EBP - RET 12 - -#_TEXT ENDS - - #END +#***********************************************************************/ + +.intel_syntax + +.globl _DllMgr_call32 +.globl _DllMgr_callFp + +_DllMgr_call32: +_DllMgr_callFp: + push ebp + mov ebp, esp + push esi + push edi + mov ecx, [ebp+16] + jecxz $1 + sub esp, ecx + mov edi, esp + mov esi, [ebp+12] + shr ecx, 2 + rep movsd +$1: call DWORD PTR [ebp+8] + ; for extra safety, do not trust esp after call (in case the Basic Declare + ; signature is wrong): + mov edi, [ebp-8] + mov esi, [ebp-4] + mov esp, ebp + pop ebp + ret 12 diff --git a/basic/source/runtime/wnt.asm b/basic/source/runtime/wnt.asm index 3824daae964b..2a8710e34243 100644 --- a/basic/source/runtime/wnt.asm +++ b/basic/source/runtime/wnt.asm @@ -1,7 +1,7 @@ ;************************************************************************* ; ; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -; +; ; Copyright 2000, 2010 Oracle and/or its affiliates. ; ; OpenOffice.org - a multi-platform office productivity suite @@ -23,70 +23,34 @@ ; ; for a copy of the LGPLv3 License. ; -;************************************************************************* - -; Anmerkungen -; Direktaufruf von C- und PASCAL-Routinen, Windows und OS/2 -; -; Inhalt: -; type = CallXXX (far *pProc, char *pStack, short nStack) -; -; Kopie des Basic-Stacks (nStack Bytes) auf den C-Stack -; und Aufruf der Prozedur. - - .386 - -_TEXT SEGMENT DWORD PUBLIC 'CODE' USE32 - - ASSUME CS:_TEXT - - PUBLIC _CallINT@12 - PUBLIC _CallLNG@12 - PUBLIC _CallDBL@12 - PUBLIC _CallSTR@12 - PUBLIC _CallFIX@12 - -_CallINT@12 LABEL byte -_CallLNG@12 LABEL byte -_CallDBL@12 LABEL byte -_CallSTR@12 LABEL byte - -_CallFIX@12: PUSH EBP - MOV EBP,ESP - PUSH ESI - PUSH EDI - - PUSH ECX - PUSH EDX - - MOV DX,DS - MOVZX EAX,WORD PTR [EBP+16] ; EAX == nStack - SUB ESP,EAX ; Stack um nStack Bytes vergroessern - MOV EDI,ESP - MOV AX,SS - MOV ES,AX ; ES:EDI = Startadresse des fuer - ; Parameter reservierten Stackbereichs - MOV ESI,[EBP+12] ; DS:ESI == pStack - - MOVZX ECX,WORD PTR [EBP+16] ; ECX == nStack - SHR ECX,1 - CLD - JCXZ $1 - REP MOVSW ; Stack uebernehmen -$1: MOV DS,DX - CALL DWORD PTR [EBP+8] ; Aufruf der Prozedur - ; CLI ; unter NT nicht erlaubt (privileged instruction) - MOV ESP,EBP - SUB ESP,16 ; wegen gepushter Register - ; (ESI, EDI) - ; STI - POP EDX - POP ECX - POP EDI - POP ESI - POP EBP - RET 12 - -_TEXT ENDS - - END +;***********************************************************************/ + +.386 + +PUBLIC _DllMgr_call32@12 +PUBLIC _DllMgr_callFp@12 + +_TEXT SEGMENT +_DllMgr_call32@12: +_DllMgr_callFp@12: + push ebp + mov ebp, esp + push esi + push edi + mov ecx, [ebp+16] + jecxz $1 + sub esp, ecx + mov edi, esp + mov esi, [ebp+12] + shr ecx, 2 + rep movsd +$1: call DWORD PTR [ebp+8] + ; for extra safety, do not trust esp after call (in case the Basic Declare + ; signature is wrong): + mov edi, [ebp-8] + mov esi, [ebp-4] + mov esp, ebp + pop ebp + ret 12 +_TEXT ENDS +END diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index 9a83fb7ba578..20060f1f7493 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -39,6 +39,9 @@ #include #include +#include "com/sun/star/uno/XInterface.hpp" +using namespace com::sun::star::uno; + ///////////////////////////// SbxVariable ////////////////////////////// TYPEINIT1(SbxVariable,SbxValue) @@ -49,10 +52,28 @@ extern UINT32 nVarCreator; // in SBXBASE.CXX, fuer LoadData() static ULONG nVar = 0; #endif +///////////////////////////// SbxVariableImpl //////////////////////////// + +class SbxVariableImpl +{ + friend class SbxVariable; + String m_aDeclareClassName; + Reference< XInterface > m_xComListener; + + SbxVariableImpl( void ) + {} + SbxVariableImpl( const SbxVariableImpl& r ) + : m_aDeclareClassName( r.m_aDeclareClassName ) + , m_xComListener( r.m_xComListener ) + {} +}; + + ///////////////////////////// Konstruktoren ////////////////////////////// SbxVariable::SbxVariable() : SbxValue() { + mpSbxVariableImpl = NULL; pCst = NULL; pParent = NULL; nUserData = 0; @@ -66,6 +87,9 @@ SbxVariable::SbxVariable() : SbxValue() SbxVariable::SbxVariable( const SbxVariable& r ) : SvRefBase( r ), SbxValue( r ), mpPar( r.mpPar ), pInfo( r.pInfo ) { + mpSbxVariableImpl = NULL; + if( r.mpSbxVariableImpl != NULL ) + mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl ); pCst = NULL; if( r.CanRead() ) { @@ -91,6 +115,7 @@ SbxVariable::SbxVariable( const SbxVariable& r ) SbxVariable::SbxVariable( SbxDataType t, void* p ) : SbxValue( t, p ) { + mpSbxVariableImpl = NULL; pCst = NULL; pParent = NULL; nUserData = 0; @@ -111,6 +136,7 @@ SbxVariable::~SbxVariable() maName.AssignAscii( aCellsStr, sizeof( aCellsStr )-1 ); GetSbxData_Impl()->aVars.Remove( this ); #endif + delete mpSbxVariableImpl; delete pCst; } @@ -287,6 +313,11 @@ USHORT SbxVariable::MakeHashCode( const XubString& rName ) SbxVariable& SbxVariable::operator=( const SbxVariable& r ) { SbxValue::operator=( r ); + delete mpSbxVariableImpl; + if( r.mpSbxVariableImpl != NULL ) + mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl ); + else + mpSbxVariableImpl = NULL; return *this; } @@ -346,6 +377,32 @@ void SbxVariable::SetParent( SbxObject* p ) pParent = p; } +SbxVariableImpl* SbxVariable::getImpl( void ) +{ + if( mpSbxVariableImpl == NULL ) + mpSbxVariableImpl = new SbxVariableImpl(); + return mpSbxVariableImpl; +} + +const String& SbxVariable::GetDeclareClassName( void ) +{ + SbxVariableImpl* pImpl = getImpl(); + return pImpl->m_aDeclareClassName; +} + +void SbxVariable::SetDeclareClassName( const String& rDeclareClassName ) +{ + SbxVariableImpl* pImpl = getImpl(); + pImpl->m_aDeclareClassName = rDeclareClassName; +} + +void SbxVariable::SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener ) +{ + SbxVariableImpl* pImpl = getImpl(); + pImpl->m_xComListener = xComListener; +} + + ////////////////////////////// Laden/Speichern ///////////////////////////// BOOL SbxVariable::LoadData( SvStream& rStrm, USHORT nVer ) diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx index 051b4fa9f077..004b61fbf198 100644 --- a/basic/source/uno/dlgcont.cxx +++ b/basic/source/uno/dlgcont.cxx @@ -187,12 +187,13 @@ bool writeOasis2OOoLibraryElement( void SAL_CALL SfxDialogLibraryContainer::writeLibraryElement ( - Any aElement, - const OUString& /*aElementName*/, - Reference< XOutputStream > xOutput + const Reference < XNameContainer >& xLib, + const OUString& aElementName, + const Reference< XOutputStream >& xOutput ) throw(Exception) { + Any aElement = xLib->getByName( aElementName ); Reference< XInputStreamProvider > xISP; aElement >>= xISP; if( !xISP.is() ) @@ -256,7 +257,9 @@ void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< e Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement - ( const OUString& aFile, const uno::Reference< io::XInputStream >& xElementStream ) + ( const Reference < XNameContainer >& /*xLib*/, + const OUString& /*aElementName */, const OUString& aFile, + const uno::Reference< io::XInputStream >& xElementStream ) { Any aRetAny; diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index 90e7cb4cb4d5..f692277fc5ba 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -1369,8 +1369,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, OUString aStreamName = aElementName; aStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".xml") ); - Any aElement = pLib->getByName( aElementName ); - if( !isLibraryElementValid( aElement ) ) + /*Any aElement = pLib->getByName( aElementName );*/ + if( !isLibraryElementValid( pLib->getByName( aElementName ) ) ) { #if OSL_DEBUG_LEVEL > 0 ::rtl::OStringBuffer aMessage; @@ -1406,7 +1406,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, xProps->setPropertyValue( aPropName, uno::makeAny( sal_True ) ); Reference< XOutputStream > xOutput = xElementStream->getOutputStream(); - writeLibraryElement( aElement, aElementName, xOutput ); + Reference< XNameContainer > xLib( pLib ); + writeLibraryElement( xLib, aElementName, xOutput ); // writeLibraryElement closes the stream // xOutput->closeOutput(); } @@ -1458,8 +1459,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, aElementInetObj.setExtension( maLibElementFileExtension ); String aElementPath( aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ) ); - Any aElement = pLib->getByName( aElementName ); - if( !isLibraryElementValid( aElement ) ) + /*Any aElement = pLib->getByName( aElementName );*/ + if( !isLibraryElementValid( pLib->getByName( aElementName ) ) ) { #if OSL_DEBUG_LEVEL > 0 ::rtl::OStringBuffer aMessage; @@ -1477,7 +1478,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, if( xSFI->exists( aElementPath ) ) xSFI->kill( aElementPath ); Reference< XOutputStream > xOutput = xSFI->openFileWrite( aElementPath ); - writeLibraryElement( aElement, aElementName, xOutput ); + Reference< XNameContainer > xLib( pLib ); + writeLibraryElement( xLib, aElementName, xOutput ); xOutput->closeOutput(); } catch( Exception& ) @@ -2380,7 +2382,9 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name ) aFile = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ); } - Any aAny = importLibraryElement( aFile, xInStream ); + Reference< XNameContainer > xLib( pImplLib ); + Any aAny = importLibraryElement( xLib, aElementName, + aFile, xInStream ); if( pImplLib->hasByName( aElementName ) ) { if( aAny.hasValue() ) diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index 4185b6f9579c..5622adc19af1 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #ifndef _COMPHELPER_STORAGEHELPER_HXX_ #include @@ -60,6 +61,7 @@ #include #include #include +#include #include "modsizeexceeded.hxx" #include #include @@ -184,9 +186,9 @@ bool SAL_CALL SfxScriptLibraryContainer::isLibraryElementValid( Any aElement ) c void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement ( - Any aElement, + const Reference < XNameContainer >& xLib, const OUString& aElementName, - Reference< XOutputStream > xOutput + const Reference< XOutputStream >& xOutput ) throw(Exception) { @@ -211,13 +213,42 @@ void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement xmlscript::ModuleDescriptor aMod; aMod.aName = aElementName; aMod.aLanguage = maScriptLanguage; + Any aElement = xLib->getByName( aElementName ); aElement >>= aMod.aCode; + + Reference < script::XVBAModuleInfo > xModInfo( xLib, UNO_QUERY ); + + if( xModInfo.is() && xModInfo->hasModuleInfo( aElementName ) ) + { + script::ModuleInfo aModInfo = xModInfo->getModuleInfo( aElementName ); + switch( aModInfo.ModuleType ) + { + case ModuleType::NORMAL: + aMod.aModuleType = OUString( RTL_CONSTASCII_USTRINGPARAM("normal") ); + break; + case ModuleType::CLASS: + aMod.aModuleType = OUString( RTL_CONSTASCII_USTRINGPARAM("class") ); + break; + case ModuleType::FORM: + aMod.aModuleType = OUString( RTL_CONSTASCII_USTRINGPARAM("form") ); + break; + case ModuleType::DOCUMENT: + aMod.aModuleType = OUString( RTL_CONSTASCII_USTRINGPARAM("document") ); + break; + case ModuleType::UNKNOWN: + // nothing + break; + } + } + xmlscript::exportScriptModule( xHandler, aMod ); } Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement - ( const OUString& aFile, const uno::Reference< io::XInputStream >& xInStream ) + ( const Reference < XNameContainer >& xLib, + const OUString& aElementName, const OUString& aFile, + const uno::Reference< io::XInputStream >& xInStream ) { Any aRetAny; @@ -279,6 +310,86 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement // TODO: Check language // aMod.aLanguage // aMod.aName ignored + if( aMod.aModuleType.getLength() > 0 ) + { + if( !getVBACompatModeOn() ) + { + setVBACompatModeOn( sal_True ); + + Any aGlobs; + Sequence< Any > aArgs(1); + Reference xModel( mxOwnerDocument ); + aArgs[ 0 ] <<= xModel; + + BasicManager* pBasicMgr = getBasicManager(); + if( pBasicMgr ) + { + aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs ); + pBasicMgr->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); + } + pBasicMgr = BasicManagerRepository::getApplicationBasicManager( sal_False ); + if( pBasicMgr ) + pBasicMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[0] ); + } + + script::ModuleInfo aModInfo; + aModInfo.ModuleType = ModuleType::UNKNOWN; + if( aMod.aModuleType.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("normal") )) + { + aModInfo.ModuleType = ModuleType::NORMAL; + } + else if( aMod.aModuleType.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("class") )) + { + aModInfo.ModuleType = ModuleType::CLASS; + } + else if( aMod.aModuleType.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("form") )) + { + aModInfo.ModuleType = ModuleType::FORM; + aModInfo.ModuleObject = mxOwnerDocument; + } + else if( aMod.aModuleType.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("document") )) + { + aModInfo.ModuleType = ModuleType::DOCUMENT; + Reference xModel( mxOwnerDocument ); + Reference< XMultiServiceFactory> xSF( xModel, UNO_QUERY); + Reference< container::XNameAccess > xVBACodeNameAccess; + if( xSF.is() ) + { + try + { + xVBACodeNameAccess.set( xSF->createInstance( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "ooo.vba.VBAObjectModuleObjectProvider"))), + UNO_QUERY ); + } + catch(uno::Exception&) {} + } + if( xVBACodeNameAccess.is() ) + { + try + { + aModInfo.ModuleObject.set( xVBACodeNameAccess->getByName( aElementName), uno::UNO_QUERY ); + } + catch(uno::Exception&) + { + OSL_TRACE("Failed to get documument object for %s", rtl::OUStringToOString( aElementName, RTL_TEXTENCODING_UTF8 ).getStr() ); + } + } + } + + Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, + UNO_QUERY ); + if( xVBAModuleInfo.is() ) + { + if( xVBAModuleInfo->hasModuleInfo( aElementName ) ) + xVBAModuleInfo->removeModuleInfo( aElementName ); + xVBAModuleInfo->insertModuleInfo( aElementName, aModInfo ); + } + } return aRetAny; } @@ -574,8 +685,8 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, if( pLib->mbPasswordVerified || pLib->mbDoc50Password ) { - Any aElement = pLib->getByName( aElementName ); - if( !isLibraryElementValid( aElement ) ) + /*Any aElement = pLib->getByName( aElementName );*/ + if( !isLibraryElementValid( pLib->getByName( aElementName ) ) ) { #if OSL_DEBUG_LEVEL > 0 ::rtl::OStringBuffer aMessage; @@ -606,7 +717,8 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, setStreamKey( xSourceStream, pLib->maPassword ); Reference< XOutputStream > xOutput = xSourceStream->getOutputStream(); - writeLibraryElement( aElement, aElementName, xOutput ); + Reference< XNameContainer > xLib( pLib ); + writeLibraryElement( xLib, aElementName, xOutput ); // writeLibraryElement should have the stream already closed // xOutput->closeOutput(); } @@ -659,8 +771,8 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, aElementInetObj.setExtension( OUString( RTL_CONSTASCII_USTRINGPARAM("pba") ) ); String aElementPath = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ); - Any aElement = pLib->getByName( aElementName ); - if( !isLibraryElementValid( aElement ) ) + /*Any aElement = pLib->getByName( aElementName );*/ + if( !isLibraryElementValid( pLib->getByName( aElementName ) ) ) { #if OSL_DEBUG_LEVEL > 0 ::rtl::OStringBuffer aMessage; @@ -741,7 +853,8 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, xProps->setPropertyValue( aPropName, uno::makeAny( aMime ) ); Reference< XOutputStream > xOut = xSourceStream->getOutputStream(); - writeLibraryElement( aElement, aElementName, xOut ); + Reference< XNameContainer > xLib( pLib ); + writeLibraryElement( xLib, aElementName, xOut ); // i50568: sax writer already closes stream // xOut->closeOutput(); @@ -903,7 +1016,10 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary if ( !xInStream.is() ) throw io::IOException(); // read access denied, seems to be impossible - Any aAny = importLibraryElement( aSourceStreamName, xInStream ); + Reference< XNameContainer > xLib( pLib ); + Any aAny = importLibraryElement( xLib, + aElementName, aSourceStreamName, + xInStream ); if( pLib->hasByName( aElementName ) ) { if( aAny.hasValue() ) @@ -1006,7 +1122,11 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary if ( !xInStream.is() ) throw io::IOException(); // read access denied, seems to be impossible - Any aAny = importLibraryElement( aSourceStreamName, xInStream ); + Reference< XNameContainer > xLib( pLib ); + Any aAny = importLibraryElement( xLib, + aElementName, + aSourceStreamName, + xInStream ); if( pLib->hasByName( aElementName ) ) { if( aAny.hasValue() ) diff --git a/basic/util/makefile.mk b/basic/util/makefile.mk index 645c9b6a3ce8..629586f0441c 100644 --- a/basic/util/makefile.mk +++ b/basic/util/makefile.mk @@ -59,6 +59,7 @@ SHL1STDLIBS= \ $(VCLLIB) \ $(VOSLIB) \ $(SALLIB) \ + $(SALHELPERLIB) \ $(COMPHELPERLIB) \ $(UNOTOOLSLIB) \ $(SOTLIB) \ diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 4cc5306fec9f..d4e43363676f 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -493,7 +493,7 @@ void FormulaCompiler::OpCodeMap::putOpCode( const String & rStr, const OpCode eO DBG_ASSERT( 0 < eOp && USHORT(eOp) < mnSymbols, "OpCodeMap::putOpCode: OpCode out of range"); if (0 < eOp && USHORT(eOp) < mnSymbols) { - DBG_ASSERT( (mpTable[eOp].Len() == 0) || (mpTable[eOp] == rStr), + DBG_ASSERT( (mpTable[eOp].Len() == 0) || (mpTable[eOp] == rStr) || (eOp == ocCurrency), ByteString( "OpCodeMap::putOpCode: reusing OpCode "). Append( ByteString::CreateFromInt32( sal_Int32( eOp))).Append( " ("). Append( ByteString( rStr, RTL_TEXTENCODING_ASCII_US)).Append( ')').GetBuffer()); diff --git a/oovbaapi/ooo/vba/XApplicationBase.idl b/oovbaapi/ooo/vba/XApplicationBase.idl index b42e456bd7eb..7f59ddb75247 100644 --- a/oovbaapi/ooo/vba/XApplicationBase.idl +++ b/oovbaapi/ooo/vba/XApplicationBase.idl @@ -38,19 +38,27 @@ module ooo { module vba { //============================================================================= + + interface XApplicationBase { interface ::ooo::vba::XHelperInterface; [attribute] boolean ScreenUpdating; [attribute] boolean DisplayStatusBar; + [attribute] boolean Interactive; [attribute, readonly] string Version; + //mbn + [attribute, readonly] any VBE; + [attribute, readonly] any VBProjects; void Quit(); any CommandBars( [in] any aIndex ); void Run([in] string MacroName, [in] /*Optional*/ any varg1, [in] /*Optional*/ any varg2, [in] /*Optional*/ any varg3, [in] /*Optional*/ any varg4, [in] /*Optional*/ any varg5, [in] /*Optional*/ any varg6, [in] /*Optional*/ any varg7, [in] /*Optional*/ any varg8, [in] /*Optional*/ any varg9, [in] /*Optional*/ any varg10, [in] /*Optional*/ any varg11, [in] /*Optional*/ any varg12, [in] /*Optional*/ any varg13, [in] /*Optional*/ any varg14, [in] /*Optional*/ any varg15, [in] /*Optional*/ any varg16, [in] /*Optional*/ any varg17, [in] /*Optional*/ any varg18, [in] /*Optional*/ any varg19, [in] /*Optional*/ any varg20, [in] /*Optional*/ any varg21, [in] /*Optional*/ any varg22, [in] /*Optional*/ any varg23, [in] /*Optional*/ any varg24, [in] /*Optional*/ any varg25, [in] /*Optional*/ any varg26, [in] /*Optional*/ any varg27, [in] /*Optional*/ any varg28, [in] /*Optional*/ any varg29, [in] /*Optional*/ any varg30); + void OnTime( [in] any aEarliestTime, [in] string aFunction, [in] any aLatestTime, [in] any aSchedule ); float CentimetersToPoints([in] float Centimeters ); + void Undo(); }; }; }; diff --git a/oovbaapi/ooo/vba/XCollection.idl b/oovbaapi/ooo/vba/XCollection.idl index 60971034bb5d..63982aab36d6 100644 --- a/oovbaapi/ooo/vba/XCollection.idl +++ b/oovbaapi/ooo/vba/XCollection.idl @@ -52,6 +52,7 @@ interface XCollection interface ::com::sun::star::container::XEnumerationAccess; [attribute, readonly] long Count; + any Item( [in] any Index1, [in] any Index2 ); }; diff --git a/oovbaapi/ooo/vba/XCommandBarControl.idl b/oovbaapi/ooo/vba/XCommandBarControl.idl index 2f89959cdaa0..7f20a6bf2c3f 100644 --- a/oovbaapi/ooo/vba/XCommandBarControl.idl +++ b/oovbaapi/ooo/vba/XCommandBarControl.idl @@ -48,6 +48,7 @@ interface XCommandBarControl [attribute] boolean Visible; [attribute, readonly] long Type; [attribute] boolean Enabled; + [attribute] boolean BeginGroup; void Delete() raises ( com::sun::star::script::BasicErrorException ); any Controls( [in] any Index ) raises ( com::sun::star::script::BasicErrorException ); diff --git a/oovbaapi/ooo/vba/XDocumentBase.idl b/oovbaapi/ooo/vba/XDocumentBase.idl index 12cb931987d6..a4ee8b4366c6 100644 --- a/oovbaapi/ooo/vba/XDocumentBase.idl +++ b/oovbaapi/ooo/vba/XDocumentBase.idl @@ -38,6 +38,8 @@ module ooo { module vba { //============================================================================= + + interface XDocumentBase { interface ::ooo::vba::XHelperInterface; @@ -46,6 +48,7 @@ interface XDocumentBase [attribute, readonly] string Path; [attribute, readonly] string FullName; [attribute] boolean Saved; + [attribute, readonly] any VBProject; // Michael E. Bohn void Close([in] any SaveChanges, [in] any FileName, [in] any RouteWorkBook); void Save(); diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl index e4c063d161cf..39693a37511c 100644 --- a/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/oovbaapi/ooo/vba/excel/XApplication.idl @@ -27,17 +27,10 @@ #ifndef __ooo_vba_excel_XApplication_idl__ #define __ooo_vba_excel_XApplication_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -#ifndef __ooo_vba_XHelperInterface_idl__ +#include +#include #include -#endif - -#ifndef __ooo_vba_XAssistant_idl__ #include -#endif module ooo { module vba { module excel { @@ -49,8 +42,11 @@ interface XWorksheetFunction; interface XWindow; interface XWorksheet; -interface XApplication : com::sun::star::uno::XInterface +interface XApplication { + // Application serves as WorksheetFunction object with little differences + interface ::com::sun::star::beans::XExactName; + interface ::com::sun::star::script::XInvocation; // interface ::ooo::vba::XHelperInterface; @@ -86,8 +82,7 @@ interface XApplication : com::sun::star::uno::XInterface any Range( [in] any Cell1, [in] any Cell2 ); any Names( [in] any Index ); void GoTo( [in] any Reference, [in] any Scroll ); - // #FIXME #TODO up to 30 args needed - double CountA( [in] any arg1 ); + void wait( [in] double time ); void Calculate() raises(com::sun::star::script::BasicErrorException); XRange Intersect([in] XRange Arg1, [in] XRange Arg2, [in] /*Optional*/ any Arg3, [in] /*Optional*/ any Arg4, [in] /*Optional*/ any Arg5, [in] /*Optional*/ any Arg6, [in] /*Optional*/ any Arg7, [in] /*Optional*/ any Arg8, [in] /*Optional*/ any Arg9, [in] /*Optional*/ any Arg10, [in] /*Optional*/ any Arg11, [in] /*Optional*/ any Arg12, [in] /*Optional*/ any Arg13, [in] /*Optional*/ any Arg14, [in] /*Optional*/ any Arg15, [in] /*Optional*/ any Arg16, [in] /*Optional*/ any Arg17, [in] /*Optional*/ any Arg18, [in] /*Optional*/ any Arg19, [in] /*Optional*/ any Arg20, [in] /*Optional*/ any Arg21, [in] /*Optional*/ any Arg22, [in] /*Optional*/ any Arg23, [in] /*Optional*/ any Arg24, [in] /*Optional*/ any Arg25, [in] /*Optional*/ any Arg26, [in] /*Optional*/ any Arg27, [in] /*Optional*/ any Arg28, [in] /*Optional*/ any Arg29, [in] /*Optional*/ any Arg30) diff --git a/oovbaapi/ooo/vba/excel/XComment.idl b/oovbaapi/ooo/vba/excel/XComment.idl index 9f333cfd9542..8b811f31cc41 100644 --- a/oovbaapi/ooo/vba/excel/XComment.idl +++ b/oovbaapi/ooo/vba/excel/XComment.idl @@ -27,15 +27,8 @@ #ifndef __ooo_vba_excel_XComment_idl__ #define __ooo_vba_excel_XComment_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif -#ifndef __com_sun_star_lang_IllegalArgumentException_idl__ -#include -#endif -#ifndef __ooo_vba_XHelperInterface_idl__ -#include -#endif +#include + //============================================================================= module ooo { module vba { module excel { @@ -48,7 +41,7 @@ interface XComment interface ::ooo::vba::XHelperInterface; [attribute] string Author; -// [attribute, readonly] Shape Shape; + [attribute, readonly] ooo::vba::msforms::XShape Shape; [attribute] boolean Visible; void Delete(); diff --git a/oovbaapi/ooo/vba/excel/XHyperlink.idl b/oovbaapi/ooo/vba/excel/XHyperlink.idl index 32fd985a4a37..1f6f9d23bfa6 100644 --- a/oovbaapi/ooo/vba/excel/XHyperlink.idl +++ b/oovbaapi/ooo/vba/excel/XHyperlink.idl @@ -27,31 +27,38 @@ #ifndef __ooo_vba_excel_XHyperlink_idl__ #define __ooo_vba_excel_XHyperlink_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -#ifndef __ooo_vba_XHelperInterface_idl__ #include -#endif //============================================================================= +module ooo { module vba { module msforms { + interface XShape; +}; }; }; + module ooo { module vba { module excel { -//============================================================================= interface XRange; + +//============================================================================= + interface XHyperlink { interface ::ooo::vba::XHelperInterface; - [attribute] string Address; [attribute] string Name; + [attribute] string Address; + [attribute] string SubAddress; + [attribute] string ScreenTip; [attribute] string TextToDisplay; - - XRange Range(); + [attribute, readonly] long Type; + [attribute, readonly] XRange Range; + [attribute, readonly] ooo::vba::msforms::XShape Shape; }; +//============================================================================= + }; }; }; +//============================================================================= + #endif diff --git a/oovbaapi/ooo/vba/excel/XPane.idl b/oovbaapi/ooo/vba/excel/XPane.idl index acc5520bb9ea..ac9ec2e3ca08 100644 --- a/oovbaapi/ooo/vba/excel/XPane.idl +++ b/oovbaapi/ooo/vba/excel/XPane.idl @@ -27,9 +27,7 @@ #ifndef __com_sun_star_helper_XPane_idl__ #define __com_sun_star_helper_XPane_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ #include -#endif //============================================================================ @@ -37,10 +35,13 @@ module ooo { module vba { module excel { //============================================================================ -interface XPane: com::sun::star::uno::XInterface +interface XRange; + +interface XPane : com::sun::star::uno::XInterface { [attribute] long ScrollColumn; [attribute] long ScrollRow; + [attribute, readonly] XRange VisibleRange; void SmallScroll([in] /*Optional*/ any Down, [in] /*Optional*/ any Up, [in] /*Optional*/ any ToRight, [in] /*Optional*/ any ToLeft); void LargeScroll([in] /*Optional*/ any Down, [in] /*Optional*/ any Up, [in] /*Optional*/ any ToRight, [in] /*Optional*/ any ToLeft); diff --git a/oovbaapi/ooo/vba/excel/XRange.idl b/oovbaapi/ooo/vba/excel/XRange.idl index 5eb1913fc40a..3820911f2c96 100644 --- a/oovbaapi/ooo/vba/excel/XRange.idl +++ b/oovbaapi/ooo/vba/excel/XRange.idl @@ -98,6 +98,7 @@ interface XRange [attribute, readonly ] any Left; [attribute] any PageBreak; [attribute, readonly] XValidation Validation; + [attribute, readonly] any PrefixCharacter; [attribute] any Style; [attribute] any AddIndent; [attribute] any ShowDetail; @@ -164,7 +165,7 @@ interface XRange void RemoveSubtotal() raises ( com::sun::star::script::BasicErrorException ); void Subtotal( [in] long GroupBy, [in] long Function, [in] /*Optional*/ sequence TotalList, [in] /*Optional*/ any Replace, [in] /*Optional*/ any PageBreaks, [in] any SummaryBelowData ) raises ( com::sun::star::script::BasicErrorException ); XRange MergeArea( ) raises ( com::sun::star::script::BasicErrorException ); - + any Hyperlinks( [in] any aIndex ); }; //============================================================================= diff --git a/oovbaapi/ooo/vba/excel/XWindow.idl b/oovbaapi/ooo/vba/excel/XWindow.idl index 0ac2271a32d6..dde7818ebda7 100644 --- a/oovbaapi/ooo/vba/excel/XWindow.idl +++ b/oovbaapi/ooo/vba/excel/XWindow.idl @@ -27,22 +27,18 @@ #ifndef __ooo_vba_excel_XWindow_idl__ #define __ooo_vba_excel_XWindow_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -#ifndef __ooo_vba_XHelperInterface_idl__ #include -#endif //============================================================================= module ooo { module vba { module excel { //============================================================================= + interface XRange; interface XWorksheet; interface XPane; + interface XWindow : com::sun::star::uno::XInterface { [attribute] any Caption; @@ -61,6 +57,7 @@ interface XWindow : com::sun::star::uno::XInterface [attribute] any ScrollColumn; [attribute] any ScrollRow; [attribute] any View; + [attribute, readonly] XRange VisibleRange; [attribute] any WindowState; [attribute] any Zoom; any SelectedSheets( [in] any aIndex ); @@ -71,6 +68,7 @@ interface XWindow : com::sun::star::uno::XInterface void Close([in] any SaveChanges, [in] any FileName, [in] any RouteWorkBook); XRange ActiveCell() raises(com::sun::star::script::BasicErrorException); any Selection() raises(com::sun::star::script::BasicErrorException); + XRange RangeSelection() raises(com::sun::star::script::BasicErrorException); long PointsToScreenPixelsX([in] long Points) raises(com::sun::star::script::BasicErrorException); long PointsToScreenPixelsY([in] long Points) raises(com::sun::star::script::BasicErrorException); void PrintOut([in] /*optional short*/ any From, diff --git a/oovbaapi/ooo/vba/excel/XWorksheet.idl b/oovbaapi/ooo/vba/excel/XWorksheet.idl index 3620c899de83..271cd81d4d0e 100644 --- a/oovbaapi/ooo/vba/excel/XWorksheet.idl +++ b/oovbaapi/ooo/vba/excel/XWorksheet.idl @@ -83,6 +83,8 @@ interface XWorksheet void Protect([in] any Password,[in] any DrawingObjects ,[in] any Contents,[in] any Scenarios,[in] any UserInterfaceOnly); void Unprotect([in] any Password ); void CheckSpelling([in] any CustomDictionary,[in] any IgnoreUppercase, [in] any AlwaysSuggest,[in] any SpellingLang ); + void ShowDataForm(); + XRange Range([in] any Cell1, [in] any Cell2 ); any ChartObjects([in] any Index); any PivotTables([in] any Index); @@ -92,23 +94,32 @@ interface XWorksheet any HPageBreaks([in] any Index); any VPageBreaks([in] any Index); any OLEObjects([in] any Index); - void ShowDataForm(); any Shapes([in] any Index); + /* The following form control related symbols do not refer to ActiveX form + controls embedded in the sheet, but to the old-style drawing controls + of Excel. This is an Excel-only feature. */ + any Buttons( [in] any aIndex ); + any CheckBoxes( [in] any aIndex ); + any DropDowns( [in] any aIndex ); + any GroupBoxes( [in] any aIndex ); + any Labels( [in] any aIndex ); + any ListBoxes( [in] any aIndex ); + any OptionButtons( [in] any aIndex ); + any ScrollBars( [in] any aIndex ); + any Spinners( [in] any aIndex ); // FIXME: should prolly inherit from Range somehow... XRange Cells([in] any RowIndex, [in] any ColumnIndex); XRange Rows([in] any aIndex); XRange Columns([in] any aIndex); + any Hyperlinks( [in] any aIndex ); any Evaluate( [in] string Name); - void setEnableCalculation([in] boolean EnableCalculation) raises(com::sun::star::script::BasicErrorException); boolean getEnableCalculation() raises(com::sun::star::script::BasicErrorException); void PrintOut( [in] any From, [in] any To, [in] any Copies, [in] any Preview, [in] any ActivePrinter, [in] any PrintToFile, [in] any Collate, [in] any PrToFileName, [in] any IgnorePrintAreas ); - - }; //============================================================================= @@ -116,5 +127,3 @@ interface XWorksheet }; }; }; #endif - - diff --git a/oovbaapi/ooo/vba/excel/makefile.mk b/oovbaapi/ooo/vba/excel/makefile.mk index 01e26d4cb19b..12dcf025e489 100644 --- a/oovbaapi/ooo/vba/excel/makefile.mk +++ b/oovbaapi/ooo/vba/excel/makefile.mk @@ -39,6 +39,8 @@ PACKAGE=ooo$/vba$/Excel IDLFILES= XGlobals.idl\ Globals.idl\ + SheetObject.idl\ + SheetObjects.idl\ XApplication.idl\ XComment.idl\ XComments.idl\ @@ -92,6 +94,7 @@ IDLFILES= XGlobals.idl\ Window.idl \ XHyperlink.idl \ Hyperlink.idl \ + XHyperlinks.idl \ XPageSetup.idl \ XPageBreak.idl \ XHPageBreak.idl \ diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk index 7fc70303d942..75f6465bf4c0 100644 --- a/oovbaapi/ooo/vba/makefile.mk +++ b/oovbaapi/ooo/vba/makefile.mk @@ -1,4 +1,4 @@ -#************************************************************************* + #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # @@ -62,7 +62,8 @@ IDLFILES=\ XDialogsBase.idl\ XDialogBase.idl\ XPageSetupBase.idl \ - + XVBAAppService.idl\ + XVBADocService.idl\ # ------------------------------------------------------------------ .ENDIF .INCLUDE : target.mk diff --git a/oovbaapi/ooo/vba/msforms/XControl.idl b/oovbaapi/ooo/vba/msforms/XControl.idl index 867fd564c9af..97ca9d152716 100644 --- a/oovbaapi/ooo/vba/msforms/XControl.idl +++ b/oovbaapi/ooo/vba/msforms/XControl.idl @@ -45,13 +45,16 @@ interface XControl { interface ::ooo::vba::XHelperInterface; void SetFocus(); + void Move( [in] double Left, [in] double Top, [in] any Width, [in] any Height ); + [attribute, readonly ] com::sun::star::uno::XInterface Object; [attribute] string ControlSource; [attribute] string RowSource; [attribute] boolean Enabled; [attribute] boolean Visible; //Size. there are some defferent between Mso and OOo. - //Mso use double but OOo use long. OOo 1 = 1/100mm but Mso use pt + //Mso use double but OOo use long. OOo 1 = 1/100mm but Mso use pt. + //in Dialogs Mso uses pixels [attribute] double Height; [attribute] double Width; //Postion @@ -59,6 +62,7 @@ interface XControl [attribute] double Top; [attribute] string Name; [attribute] string ControlTipText; + [attribute] string Tag; }; //============================================================================= diff --git a/oovbaapi/ooo/vba/msforms/XControls.idl b/oovbaapi/ooo/vba/msforms/XControls.idl index 00d8f16f9dd9..11325303d56c 100644 --- a/oovbaapi/ooo/vba/msforms/XControls.idl +++ b/oovbaapi/ooo/vba/msforms/XControls.idl @@ -41,6 +41,13 @@ interface XControls { interface ooo::vba::XCollection; void Move( [in] double cx, [in] double cy ); + + // the following two methods should be actually part of XCollection, but at least Add conflicts with + // methods in the derived from XCollection interfaces + // thus the methods are declared in the top-level interface + any Add( [in] any Object, [in] any StringKey, [in] any Before, [in] any After ); + void Remove( [in] any StringKeyOrIndex ); + }; }; }; }; diff --git a/oovbaapi/prj/d.lst b/oovbaapi/prj/d.lst index 1acd2acd5b4b..ac5924e2d684 100644 --- a/oovbaapi/prj/d.lst +++ b/oovbaapi/prj/d.lst @@ -1 +1,15 @@ +mkdir: %COMMON_DEST%\idl%_EXT%\ooo + +mkdir: %COMMON_DEST%\idl%_EXT%\ooo\vba +mkdir: %COMMON_DEST%\idl%_EXT%\ooo\vba\constants +mkdir: %COMMON_DEST%\idl%_EXT%\ooo\vba\excel +mkdir: %COMMON_DEST%\idl%_EXT%\ooo\vba\msforms +mkdir: %COMMON_DEST%\idl%_EXT%\ooo\vba\word + ..\%__SRC%\ucr\oovbaapi.db %_DEST%\bin%_EXT%\oovbaapi.rdb + +..\ooo\vba\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\ +..\ooo\vba\constants\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\constants +..\ooo\vba\excel\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\excel +..\ooo\vba\msforms\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\msforms +..\ooo\vba\word\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\word diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx index e72015413192..e2a5a3bff5da 100644 --- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx +++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx @@ -34,8 +34,12 @@ typedef InheritedHelperInterfaceImpl1< ov::XApplicationBase > ApplicationBase_BASE; +struct VbaApplicationBase_Impl; + class VBAHELPER_DLLPUBLIC VbaApplicationBase : public ApplicationBase_BASE { + VbaApplicationBase_Impl* m_pImpl; + protected: VbaApplicationBase( const css::uno::Reference< css::uno::XComponentContext >& xContext ); virtual ~VbaApplicationBase(); @@ -49,11 +53,18 @@ public: virtual void SAL_CALL setScreenUpdating(sal_Bool bUpdate) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getDisplayStatusBar() throw (css::uno::RuntimeException); virtual void SAL_CALL setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getInteractive() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw (::com::sun::star::uno::RuntimeException); virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException); virtual void SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException); + virtual void SAL_CALL OnTime( const ::com::sun::star::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const ::com::sun::star::uno::Any& aLatestTime, const ::com::sun::star::uno::Any& aSchedule ) throw (::com::sun::star::uno::RuntimeException); virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Undo( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL Quit( ) throw (::com::sun::star::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL SAL_CALL getVBProjects() throw (css::uno::RuntimeException); + // XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); diff --git a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx index 6d596c31ba53..36102116c7b3 100644 --- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx +++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx @@ -24,6 +24,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef OOVBAAPI_VBA_COLLECTION_IMPL_HXX #define OOVBAAPI_VBA_COLLECTION_IMPL_HXX @@ -44,8 +45,91 @@ #include +// ============================================================================ + typedef ::cppu::WeakImplHelper1< css::container::XEnumeration > EnumerationHelper_BASE; +// ============================================================================ + +/** A wrapper that holds a com.sun.star.container.XIndexAccess and provides a + com.sun.star.container.XEnumeration. + + Can be used to provide an enumeration from an index container that contains + completely constructed/initialized VBA implementation objects. CANNOT be + used to provide an enumeration from an index container with other objects + (e.g. UNO objects) where construction of the VBA objects is needed first. + */ +class VBAHELPER_DLLPUBLIC SimpleIndexAccessToEnumeration : public EnumerationHelper_BASE +{ +public: + explicit SimpleIndexAccessToEnumeration( + const css::uno::Reference< css::container::XIndexAccess >& rxIndexAccess ) throw (css::uno::RuntimeException) : + mxIndexAccess( rxIndexAccess ), mnIndex( 0 ) {} + + virtual sal_Bool SAL_CALL hasMoreElements() throw (css::uno::RuntimeException) + { + return mnIndex < mxIndexAccess->getCount(); + } + + virtual css::uno::Any SAL_CALL nextElement() throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException) + { + if( !hasMoreElements() ) + throw css::container::NoSuchElementException(); + return mxIndexAccess->getByIndex( mnIndex++ ); + } + +private: + css::uno::Reference< css::container::XIndexAccess > mxIndexAccess; + sal_Int32 mnIndex; +}; + +// ============================================================================ + +/** A wrapper that holds a com.sun.star.container.XEnumeration or a + com.sun.star.container.XIndexAccess and provides an enumeration of VBA objects. + + The method nextElement() needs to be implemented by the derived class. This + class can be used to convert an enumeration or an index container + containing UNO objects to an enumeration providing the related VBA objects. + */ +class VBAHELPER_DLLPUBLIC SimpleEnumerationBase : public EnumerationHelper_BASE +{ +public: + explicit SimpleEnumerationBase( + const css::uno::Reference< ov::XHelperInterface >& rxParent, + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::container::XEnumeration >& rxEnumeration ) throw (css::uno::RuntimeException) : + mxParent( rxParent ), mxContext( rxContext ), mxEnumeration( rxEnumeration ) {} + + explicit SimpleEnumerationBase( + const css::uno::Reference< ov::XHelperInterface >& rxParent, + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::container::XIndexAccess >& rxIndexAccess ) throw (css::uno::RuntimeException) : + mxParent( rxParent ), mxContext( rxContext ), mxEnumeration( new SimpleIndexAccessToEnumeration( rxIndexAccess ) ) {} + + virtual sal_Bool SAL_CALL hasMoreElements() throw (css::uno::RuntimeException) + { + return mxEnumeration->hasMoreElements(); + } + + virtual css::uno::Any SAL_CALL nextElement() throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException) + { + return createCollectionObject( mxEnumeration->nextElement() ); + } + + /** Derived classes implement creation of a VBA implementation object from + the passed container element. */ + virtual css::uno::Any createCollectionObject( const css::uno::Any& rSource ) = 0; + +protected: + css::uno::Reference< ov::XHelperInterface > mxParent; + css::uno::Reference< css::uno::XComponentContext > mxContext; + css::uno::Reference< css::container::XEnumeration > mxEnumeration; +}; + +// ============================================================================ + +// deprecated, use SimpleEnumerationBase instead! class VBAHELPER_DLLPUBLIC EnumerationHelperImpl : public EnumerationHelper_BASE { protected: @@ -181,6 +265,14 @@ protected: // need to adjust for vba index ( for which first element is 1 ) return createCollectionObject( m_xIndexAccess->getByIndex( nIndex - 1 ) ); } + + virtual void UpdateCollectionIndex( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) + { + css::uno::Reference< css::container::XNameAccess > xNameAccess( xIndexAccess, css::uno::UNO_QUERY_THROW ); + m_xIndexAccess = xIndexAccess; + m_xNameAccess = xNameAccess; + } + public: ScVbaCollectionBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) : BaseColBase( xParent, xContext ), m_xIndexAccess( xIndexAccess ){ m_xNameAccess.set(m_xIndexAccess, css::uno::UNO_QUERY); } //XCollection diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx index 36648ff6849b..7131e1963b26 100644 --- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx +++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx @@ -53,6 +53,9 @@ public: virtual sal_Bool SAL_CALL getSaved() throw (css::uno::RuntimeException); virtual void SAL_CALL setSaved( sal_Bool bSave ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); // Michhael E. Bohn + + // Methods virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges, const css::uno::Any &aFileName, diff --git a/vbahelper/inc/vbahelper/vbafontbase.hxx b/vbahelper/inc/vbahelper/vbafontbase.hxx index b820804f1fe2..d1272c9dcf48 100644 --- a/vbahelper/inc/vbahelper/vbafontbase.hxx +++ b/vbahelper/inc/vbahelper/vbafontbase.hxx @@ -63,8 +63,15 @@ class VBAHELPER_DLLPUBLIC VbaFontBase : public VbaFontBase_BASE protected: css::uno::Reference< css::beans::XPropertySet > mxFont; css::uno::Reference< css::container::XIndexAccess > mxPalette; + bool mbFormControl; + public: - VbaFontBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xPalette, css::uno::Reference< css::beans::XPropertySet > xPropertySet ) throw ( css::uno::RuntimeException ); + VbaFontBase( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::container::XIndexAccess >& xPalette, + const css::uno::Reference< css::beans::XPropertySet >& xPropertySet, + bool bFormControl = false ) throw ( css::uno::RuntimeException ); virtual ~VbaFontBase();// {} // Attributes diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index 166ad76475d8..33613bb76091 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -74,8 +75,8 @@ namespace ooo VBAHELPER_DLLPUBLIC css::uno::Reference< css::beans::XIntrospectionAccess > getIntrospectionAccess( const css::uno::Any& aObject ) throw (css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::script::XTypeConverter > getTypeConverter( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); - VBAHELPER_DLLPUBLIC void dispatchRequests (css::uno::Reference< css::frame::XModel>& xModel,rtl::OUString & aUrl) ; - VBAHELPER_DLLPUBLIC void dispatchRequests (css::uno::Reference< css::frame::XModel>& xModel,rtl::OUString & aUrl, css::uno::Sequence< css::beans::PropertyValue >& sProps ) ; + VBAHELPER_DLLPUBLIC void dispatchRequests( const css::uno::Reference< css::frame::XModel>& xModel, const rtl::OUString& aUrl ); + VBAHELPER_DLLPUBLIC void dispatchRequests( const css::uno::Reference< css::frame::XModel>& xModel, const rtl::OUString& aUrl, const css::uno::Sequence< css::beans::PropertyValue >& sProps ); VBAHELPER_DLLPUBLIC void dispatchExecute(SfxViewShell* pView, USHORT nSlot, SfxCallMode nCall = SFX_CALLMODE_SYNCHRON ); VBAHELPER_DLLPUBLIC sal_Int32 OORGBToXLRGB( sal_Int32 ); VBAHELPER_DLLPUBLIC sal_Int32 XLRGBToOORGB( sal_Int32 ); @@ -92,7 +93,9 @@ namespace ooo VBAHELPER_DLLPUBLIC rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike = false); // needs to be in an uno service ( already this code is duplicated in basic ) VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical); VBAHELPER_DLLPUBLIC double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical); - VBAHELPER_DLLPUBLIC double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC sal_Int32 PointsToHmm( double fPoints ); + VBAHELPER_DLLPUBLIC double HmmToPoints( sal_Int32 nHmm ); VBAHELPER_DLLPUBLIC sal_Int32 getPointerStyle( const css::uno::Reference< css::frame::XModel >& ); VBAHELPER_DLLPUBLIC void setCursorHelper( const css::uno::Reference< css::frame::XModel >& xModel, const Pointer& rPointer, sal_Bool bOverWrite ); VBAHELPER_DLLPUBLIC void setDefaultPropByIntrospection( const css::uno::Any& aObj, const css::uno::Any& aValue ) throw ( css::uno::RuntimeException ); @@ -103,8 +106,6 @@ class VBAHELPER_DLLPUBLIC Millimeter { //Factor to translate between points and hundredths of millimeters: private: - static const double factor; - double m_nMillimeter; public: @@ -178,12 +179,19 @@ public: virtual double getWidth(); virtual void setWidth( double nWidth); }; + #define VBA_LEFT "PositionX" #define VBA_TOP "PositionY" +#define VBA_HEIGHT "Height" +#define VBA_WIDTH "Width" class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes { - + css::uno::Reference< css::awt::XUnitConversion > mxControlUnits; css::uno::Reference< css::beans::XPropertySet > mxModel; + + sal_Int32 ConvertLogicToPixel( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nSourceUnit ); + sal_Int32 ConvertPixelToLogic( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nTargetUnit ); + public: UserFormGeometryHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::awt::XControl >& xControl ); virtual double getLeft(); diff --git a/vbahelper/inc/vbahelper/vbahelperinterface.hxx b/vbahelper/inc/vbahelper/vbahelperinterface.hxx index 5695ab36b4fa..21339631e1ed 100644 --- a/vbahelper/inc/vbahelper/vbahelperinterface.hxx +++ b/vbahelper/inc/vbahelper/vbahelperinterface.hxx @@ -115,4 +115,57 @@ public: InheritedHelperInterfaceImpl1< Ifc1 > ( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} }; + +// ============================================================================ + +/** Helper macro to implement the method 'getServiceImplName()' of the + 'ooo.vba.XHelperInterface' interface. Will return the class name as service + implementation name. + */ +#define VBAHELPER_IMPL_GETSERVICEIMPLNAME( classname ) \ +::rtl::OUString& classname::getServiceImplName() \ +{ \ + static ::rtl::OUString saImplName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( #classname ) ); \ + return saImplName; \ +} + +// ---------------------------------------------------------------------------- + +/** Helper macro to implement the method 'getServiceNames()' for a single + service name. + */ +#define VBAHELPER_IMPL_GETSERVICENAMES( classname, servicename ) \ +css::uno::Sequence< ::rtl::OUString > classname::getServiceNames() \ +{ \ + static css::uno::Sequence< ::rtl::OUString > saServiceNames; \ + if( saServiceNames.getLength() == 0 ) \ + { \ + saServiceNames.realloc( 1 ); \ + saServiceNames[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( servicename ) ); \ + } \ + return saServiceNames; \ +} + +// ---------------------------------------------------------------------------- + +/** Helper macro to declare the methods 'getServiceImplName()' and + 'getServiceNames()' of the 'ooo.vba.XHelperInterface' interface in a class + declaration. + */ +#define VBAHELPER_DECL_XHELPERINTERFACE \ + virtual ::rtl::OUString& getServiceImplName(); \ + virtual css::uno::Sequence< ::rtl::OUString > getServiceNames(); + +// ---------------------------------------------------------------------------- + +/** Helper macro to implement the methods 'getServiceImplName()' and + 'getServiceNames()' of the 'ooo.vba.XHelperInterface' interface. Will + return the class name as service implementation name. + */ +#define VBAHELPER_IMPL_XHELPERINTERFACE( classname, servicename ) \ +VBAHELPER_IMPL_GETSERVICEIMPLNAME( classname ) \ +VBAHELPER_IMPL_GETSERVICENAMES( classname, servicename ) + +// ============================================================================ + #endif diff --git a/vbahelper/source/msforms/makefile.mk b/vbahelper/source/msforms/makefile.mk index 7c61e4302b7f..5fce64649dcb 100644 --- a/vbahelper/source/msforms/makefile.mk +++ b/vbahelper/source/msforms/makefile.mk @@ -58,6 +58,7 @@ SLOFILES=\ $(SLO)$/vbamultipage.obj \ $(SLO)$/vbalistcontrolhelper.obj \ $(SLO)$/vbaspinbutton.obj \ + $(SLO)$/vbasystemaxcontrol.obj \ $(SLO)$/vbaimage.obj \ $(SLO)$/vbapages.obj \ $(SLO)$/vbauserform.obj \ diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index 2ff12b145824..4222e3d299d0 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -57,6 +57,7 @@ #include "vbaprogressbar.hxx" #include "vbamultipage.hxx" #include "vbaspinbutton.hxx" +#include "vbasystemaxcontrol.hxx" #include "vbaimage.hxx" #include @@ -254,6 +255,22 @@ void SAL_CALL ScVbaControl::SetFocus() throw (uno::RuntimeException) xWin->setFocus(); } +void SAL_CALL ScVbaControl::Move( double Left, double Top, const uno::Any& Width, const uno::Any& Height ) + throw ( uno::RuntimeException ) +{ + double nWidth; + double nHeight; + + setLeft( Left ); + setTop( Top ); + + if ( Width >>= nWidth ) + setWidth( nWidth ); + + if ( Height >>= nHeight ) + setHeight( nHeight ); +} + rtl::OUString SAL_CALL ScVbaControl::getControlSource() throw (uno::RuntimeException) { @@ -368,6 +385,20 @@ ScVbaControl::setControlTipText( const rtl::OUString& rsToolTip ) throw (css::un m_xProps->setPropertyValue (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) ), uno::makeAny( rsToolTip ) ); } + +::rtl::OUString SAL_CALL ScVbaControl::getTag() + throw (css::uno::RuntimeException) +{ + return m_aControlTag; +} + +void SAL_CALL ScVbaControl::setTag( const ::rtl::OUString& aTag ) + throw (css::uno::RuntimeException) +{ + m_aControlTag = aTag; +} + + //ScVbaControlFactory ScVbaControlFactory::ScVbaControlFactory( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel ): m_xContext( xContext ), m_xControl( xControl ), m_xModel( xModel ) @@ -383,7 +414,6 @@ ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XIn if ( !xControl.is() ) throw uno::RuntimeException(); // really we should be more informative return createControl( xControl, xParent ); - } ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< uno::XInterface >& /*xParent*/ ) throw (uno::RuntimeException) @@ -456,6 +486,8 @@ ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XCo pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) ) pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) ) + pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() ); return pControl; diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx index 1a8ed063548b..992fbd94a8c5 100644 --- a/vbahelper/source/msforms/vbacontrol.hxx +++ b/vbahelper/source/msforms/vbacontrol.hxx @@ -48,6 +48,10 @@ class ScVbaControl : public ControlImpl_BASE private: com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener; protected: + // awt control has nothing similar to Tag property of Mso controls, + // whether it is necessary is another question + ::rtl::OUString m_aControlTag; + std::auto_ptr< ov::AbstractGeometryAttributes > mpGeometryHelper; css::uno::Reference< css::beans::XPropertySet > m_xProps; css::uno::Reference< css::uno::XInterface > m_xControl; @@ -75,6 +79,7 @@ public: virtual double SAL_CALL getTop() throw (css::uno::RuntimeException); virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException); virtual void SAL_CALL SetFocus( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Move( double Left, double Top, const ::com::sun::star::uno::Any& Width, const ::com::sun::star::uno::Any& Height ) throw (::com::sun::star::uno::RuntimeException); virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException); virtual rtl::OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException); @@ -85,6 +90,8 @@ public: virtual void SAL_CALL setName( const rtl::OUString& _name ) throw (css::uno::RuntimeException); virtual rtl::OUString SAL_CALL getControlTipText() throw (css::uno::RuntimeException); virtual void SAL_CALL setControlTipText( const rtl::OUString& ) throw (css::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTag() throw (css::uno::RuntimeException); + virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException); //remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape virtual void removeResouce() throw( css::uno::RuntimeException ); //XHelperInterface diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 48ef83d60aa6..1284b36be463 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -25,9 +25,14 @@ * ************************************************************************/ +#include +#include +#include +#include +#include + #include "vbacontrols.hxx" #include -#include #include #include @@ -48,16 +53,25 @@ class ControlArrayWrapper : public ArrayWrapImpl ControlVec mControls; ControlIndexMap mIndices; - rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl ) +private: + void SetArrayElementTo( const uno::Reference< awt::XControl >& xCtrl, sal_Int32 nIndex = -1 ) { - uno::Reference< beans::XPropertySet > xProp( xCtrl->getModel(), uno::UNO_QUERY ); - rtl::OUString sName; - xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName; - return sName; + // initialize the element with specified index to the control + if ( xCtrl.is() ) + { + if ( nIndex == -1 ) + nIndex = msNames.getLength(); + + if ( nIndex >= msNames.getLength() ) + msNames.realloc( nIndex ); + + msNames[ nIndex ] = getControlName( xCtrl ); + mControls.push_back( xCtrl ); + mIndices[ msNames[ nIndex ] ] = nIndex; + } } public: - ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog ) { mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); @@ -65,14 +79,21 @@ public: msNames.realloc( sXControls.getLength() ); for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i ) - { - uno::Reference< awt::XControl > xCtrl = sXControls[ i ]; - msNames[ i ] = getControlName( xCtrl ); - mControls.push_back( xCtrl ); - mIndices[ msNames[ i ] ] = i; - } + SetArrayElementTo( sXControls[ i ], i ); + } + + static rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl ) + { + if ( !xCtrl.is() ) + throw uno::RuntimeException(); + + uno::Reference< beans::XPropertySet > xProp( xCtrl->getModel(), uno::UNO_QUERY_THROW ); + rtl::OUString sName; + xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName; + return sName; } + // XElementAccess virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { @@ -204,6 +225,141 @@ ScVbaControls::Move( double cx, double cy ) throw (uno::RuntimeException) } } +uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& StringKey, const uno::Any& /*Before*/, const uno::Any& /*After*/ ) + throw (uno::RuntimeException) +{ + uno::Any aResult; + ::rtl::OUString aComServiceName; + + try + { + if ( !mxDialog.is() ) + throw uno::RuntimeException(); + + uno::Reference< awt::XControl > xNewControl; + uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW ); + + uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW ); + + Object >>= aComServiceName; + + // TODO: Support Before and After? + ::rtl::OUString aNewName; + StringKey >>= aNewName; + if ( !aNewName.getLength() ) + { + aNewName = aComServiceName; + if ( !aNewName.getLength() ) + aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) ); + + sal_Int32 nInd = 0; + while( xDialogContainer->hasByName( aNewName ) && nInd < SAL_MAX_INT32 ) + { + aNewName = aComServiceName; + aNewName += ::rtl::OUString::valueOf( nInd ); + } + } + + if ( aComServiceName.getLength() ) + { + uno::Reference< awt::XControlModel > xNewModel( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW ); + + + xDialogContainer->insertByName( aNewName, uno::makeAny( xNewModel ) ); + uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW ); + xNewControl = xControlContainer->getControl( aNewName ); + + try + { + uno::Reference< script::XInvocation > xControlInvoke( xNewControl, uno::UNO_QUERY_THROW ); + + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] <<= aComServiceName; + uno::Sequence< sal_Int16 > aOutIDDummy; + uno::Sequence< uno::Any > aOutDummy; + xControlInvoke->invoke( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SOAddAXControl" ) ), aArgs, aOutIDDummy, aOutDummy ); + } + catch( uno::Exception& ) + { + xDialogContainer->removeByName( aNewName ); + throw; + } + } + + if ( xNewControl.is() ) + { + UpdateCollectionIndex( lcl_controlsWrapper( mxDialog ) ); + aResult <<= xNewControl; + aResult = createCollectionObject( aResult ); + } + else + throw uno::RuntimeException(); + } + catch( uno::RuntimeException& ) + { + throw; + } + catch( uno::Exception& e ) + { + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); + } + + return aResult; +} + +void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex ) + throw (uno::RuntimeException) +{ + ::rtl::OUString aControlName; + sal_Int32 nIndex = -1; + + try + { + if ( !mxDialog.is() ) + throw uno::RuntimeException(); + + uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW ); + uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW ); + + if ( !( ( StringKeyOrIndex >>= aControlName ) && aControlName.getLength() ) + && !( ( StringKeyOrIndex >>= nIndex ) && nIndex >= 0 && nIndex < m_xIndexAccess->getCount() ) ) + throw uno::RuntimeException(); + + uno::Reference< awt::XControl > xControl; + if ( aControlName.getLength() ) + { + uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW ); + xControl = xControlContainer->getControl( aControlName ); + } + else + { + m_xIndexAccess->getByIndex( nIndex ) >>= xControl; + } + + if ( !xControl.is() ) + throw uno::RuntimeException(); + + if ( !aControlName.getLength() ) + aControlName = ControlArrayWrapper::getControlName( xControl ); + + xDialogContainer->removeByName( aControlName ); + xControl->dispose(); + } + catch( uno::RuntimeException& ) + { + throw; + } + catch( uno::Exception& e ) + { + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); + } +} + + uno::Type ScVbaControls::getElementType() throw (uno::RuntimeException) { diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx index 804133dbddfa..a72506609531 100644 --- a/vbahelper/source/msforms/vbacontrols.hxx +++ b/vbahelper/source/msforms/vbacontrols.hxx @@ -39,14 +39,19 @@ typedef CollTestImplHelper< ov::msforms::XControls > ControlsImpl_BASE; class ScVbaControls : public ControlsImpl_BASE { css::uno::Reference< css::awt::XControl > mxDialog; + protected: virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); + public: ScVbaControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::awt::XControl >& xDialog ); // XControls - virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL Add( const ::com::sun::star::uno::Any& Object, const ::com::sun::star::uno::Any& StringKey, const ::com::sun::star::uno::Any& Before, const ::com::sun::star::uno::Any& After ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL Remove( const ::com::sun::star::uno::Any& StringKeyOrIndex ) throw (::com::sun::star::uno::RuntimeException); + // XEnumerationAccess virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); diff --git a/vbahelper/source/vbahelper/makefile.mk b/vbahelper/source/vbahelper/makefile.mk index b11b4ffa0a4f..47ad44b3d0ed 100644 --- a/vbahelper/source/vbahelper/makefile.mk +++ b/vbahelper/source/vbahelper/makefile.mk @@ -65,7 +65,6 @@ SLOFILES=\ $(SLO)$/vbashaperange.obj \ $(SLO)$/vbatextframe.obj \ $(SLO)$/vbapagesetupbase.obj \ - # --- Targets ------------------------------------------------------- .INCLUDE : target.mk diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 54b635d2f08d..6d2c51066ca2 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -26,15 +26,24 @@ ************************************************************************/ #include "vbahelper/vbaapplicationbase.hxx" #include +#include //Michael E. Bohn +#include //Michael E. Bohn +#include //Michael E. Bohn +#include //Michael E. Bohn #include #include #include #include #include #include +#include //Michael E. Bohn +#include //Michael E. Bohn +#include + #include "vbacommandbars.hxx" #include +#include // start basic includes #include @@ -43,18 +52,141 @@ #include #include // end basic includes + +#include + using namespace com::sun::star; using namespace ooo::vba; #define OFFICEVERSION "11.0" +// ====VbaTimerInfo================================== +typedef ::std::pair< ::rtl::OUString, ::std::pair< double, double > > VbaTimerInfo; + +// ====VbaTimer================================== +class VbaTimer +{ + Timer m_aTimer; + VbaTimerInfo m_aTimerInfo; + ::rtl::Reference< VbaApplicationBase > m_xBase; + + // the following declarations are here to prevent the usage of them + VbaTimer( const VbaTimer& ); + VbaTimer& operator=( const VbaTimer& ); + +public: + VbaTimer() + {} + + virtual ~VbaTimer() + { + m_aTimer.Stop(); + } + + static double GetNow() + { + Date aDateNow; + Time aTimeNow; + Date aRefDate( 1,1,1900 ); + long nDiffDays = (long)(aDateNow - aRefDate); + nDiffDays += 2; // Anpassung VisualBasic: 1.Jan.1900 == 2 + + long nDiffSeconds = aTimeNow.GetHour() * 3600 + aTimeNow.GetMin() * 60 + aTimeNow.GetSec(); + return (double)nDiffDays + ((double)nDiffSeconds)/(double)(24*3600); + } + + static sal_Int32 GetTimerMiliseconds( double nFrom, double nTo ) + { + double nResult = nTo - nFrom; + if ( nResult > 0 ) + nResult *= 24*3600*1000; + else + nResult = 50; + + return (sal_Int32) nResult; + } + + void Start( const ::rtl::Reference< VbaApplicationBase > xBase, const ::rtl::OUString& aFunction, double nFrom, double nTo ) + { + if ( !xBase.is() || !aFunction.getLength() ) + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unexpected arguments!" ) ), uno::Reference< uno::XInterface >() ); + + m_xBase = xBase; + m_aTimerInfo = VbaTimerInfo( aFunction, ::std::pair< double, double >( nFrom, nTo ) ); + m_aTimer.SetTimeoutHdl( LINK( this, VbaTimer, MacroCallHdl ) ); + m_aTimer.SetTimeout( GetTimerMiliseconds( GetNow(), nFrom ) ); + m_aTimer.Start(); + } + + DECL_LINK( MacroCallHdl, void* ); +}; + +IMPL_LINK( VbaTimer, MacroCallHdl, void*, EMPTYARG ) +{ + if ( m_aTimerInfo.second.second == 0 || GetNow() < m_aTimerInfo.second.second ) + { + uno::Any aDummyArg; + try + { + m_xBase->Run( m_aTimerInfo.first, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg, aDummyArg ); + } + catch( uno::Exception& ) + {} + } + + // mast be the last call in the method since it deletes the timer + try + { + m_xBase->OnTime( uno::makeAny( m_aTimerInfo.second.first ), m_aTimerInfo.first, uno::makeAny( m_aTimerInfo.second.second ), uno::makeAny( sal_False ) ); + } catch( uno::Exception& ) + {} + + return 0; +} + +// ====VbaTimerInfoHash================================== +struct VbaTimerInfoHash +{ + size_t operator()( const VbaTimerInfo& rTimerInfo ) const + { + return (size_t)rTimerInfo.first.hashCode() + + (size_t)rtl_str_hashCode_WithLength( (char*)&rTimerInfo.second.first, sizeof( double ) ) + + (size_t)rtl_str_hashCode_WithLength( (char*)&rTimerInfo.second.second, sizeof( double ) ); + } +}; + +// ====VbaTimerHashMap================================== +typedef ::std::hash_map< VbaTimerInfo, VbaTimer*, VbaTimerInfoHash, ::std::equal_to< VbaTimerInfo > > VbaTimerHashMap; + +// ====VbaApplicationBase_Impl================================== +struct VbaApplicationBase_Impl +{ + VbaTimerHashMap m_aTimerHash; + + virtual ~VbaApplicationBase_Impl() + { + // remove the remaining timers + for ( VbaTimerHashMap::iterator aIter = m_aTimerHash.begin(); + aIter != m_aTimerHash.end(); + aIter++ ) + { + delete aIter->second; + aIter->second = NULL; + } + } +}; + +// ====VbaApplicationBase================================== VbaApplicationBase::VbaApplicationBase( const uno::Reference< uno::XComponentContext >& xContext ) : ApplicationBase_BASE( uno::Reference< XHelperInterface >(), xContext ) + , m_pImpl( new VbaApplicationBase_Impl ) { } VbaApplicationBase::~VbaApplicationBase() { + m_pImpl = 0; + delete m_pImpl; } sal_Bool SAL_CALL @@ -116,6 +248,26 @@ VbaApplicationBase::setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (uno:: return; } +::sal_Bool SAL_CALL VbaApplicationBase::getInteractive() + throw (uno::RuntimeException) +{ + uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); + uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); + uno::Reference< awt::XWindow2 > xWindow( xFrame->getContainerWindow(), uno::UNO_QUERY_THROW ); + + return xWindow->isEnabled(); +} + +void SAL_CALL VbaApplicationBase::setInteractive( ::sal_Bool bInteractive ) + throw (uno::RuntimeException) +{ + uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); + uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); + uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); + + xWindow->setEnable( bInteractive ); +} + uno::Any SAL_CALL VbaApplicationBase::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException) { @@ -133,7 +285,54 @@ VbaApplicationBase::getVersion() throw (uno::RuntimeException) void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const uno::Any& varg1, const uno::Any& varg2, const uno::Any& varg3, const uno::Any& varg4, const uno::Any& varg5, const uno::Any& varg6, const uno::Any& varg7, const uno::Any& varg8, const uno::Any& varg9, const uno::Any& varg10, const uno::Any& varg11, const uno::Any& varg12, const uno::Any& varg13, const uno::Any& varg14, const uno::Any& varg15, const uno::Any& varg16, const uno::Any& varg17, const uno::Any& varg18, const uno::Any& varg19, const uno::Any& varg20, const uno::Any& varg21, const uno::Any& varg22, const uno::Any& varg23, const uno::Any& varg24, const uno::Any& varg25, const uno::Any& varg26, const uno::Any& varg27, const uno::Any& varg28, const uno::Any& varg29, const uno::Any& varg30 ) throw (uno::RuntimeException) { - VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( getCurrentDocument() ), MacroName ); + ::rtl::OUString sSeparator = ::rtl::OUString::createFromAscii("/"); + ::rtl::OUString sMacroSeparator = ::rtl::OUString::createFromAscii("!"); + ::rtl::OUString sMacro_only_Name; + sal_Int32 Position_MacroSeparator = MacroName.indexOf(sMacroSeparator); + + uno::Reference< frame::XModel > aMacroDocumentModel; + if (-1 != Position_MacroSeparator) + { + uno::Reference< container::XEnumerationAccess > xComponentEnumAccess; + uno::Reference< lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); + try + { + uno::Reference< frame::XDesktop > xDesktop (xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" )),mxContext ), uno::UNO_QUERY_THROW ); + xComponentEnumAccess = xDesktop->getComponents(); + } + catch(uno::Exception&) + { + } + + //rem look for the name of the document in the cmpoonents collection + uno::Reference < container::XEnumeration > xEnum = xComponentEnumAccess->createEnumeration(); + + // iterate through the collection by name + while (xEnum->hasMoreElements()) + { + // get the next element as a UNO Any + uno::Any aComponentHelper = xEnum->nextElement(); + uno::Reference xDocModel( aComponentHelper, uno::UNO_QUERY_THROW ); + + // get the name of the sheet from its XNamed interface + ::rtl::OUString aName = xDocModel->getURL(); + + + if (aName.match(MacroName.copy(0,Position_MacroSeparator-1),aName.lastIndexOf(sSeparator)+1)) + { + aMacroDocumentModel = xDocModel; + sMacro_only_Name = MacroName.copy(Position_MacroSeparator+1); + } + } + } + else + { + aMacroDocumentModel = getCurrentDocument(); + sMacro_only_Name = MacroName.copy(0); + } + + + VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( aMacroDocumentModel ), sMacro_only_Name ); if( aMacroInfo.IsResolved() ) { // handle the arguments @@ -168,6 +367,39 @@ void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const u } } +void SAL_CALL VbaApplicationBase::OnTime( const uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const uno::Any& aLatestTime, const uno::Any& aSchedule ) + throw ( uno::RuntimeException ) +{ + if ( !aFunction.getLength() ) + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unexpected function name!" ) ), uno::Reference< uno::XInterface >() ); + + double nEarliestTime = 0; + double nLatestTime = 0; + if ( !( aEarliestTime >>= nEarliestTime ) + || ( aLatestTime.hasValue() && !( aLatestTime >>= nLatestTime ) ) ) + throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Only double is supported as time for now!" ) ), uno::Reference< uno::XInterface >() ); + + sal_Bool bSetTimer = sal_True; + aSchedule >>= bSetTimer; + + VbaTimerInfo aTimerIndex( aFunction, ::std::pair< double, double >( nEarliestTime, nLatestTime ) ); + + VbaTimerHashMap::iterator aIter = m_pImpl->m_aTimerHash.find( aTimerIndex ); + if ( aIter != m_pImpl->m_aTimerHash.end() ) + { + delete aIter->second; + aIter->second = NULL; + m_pImpl->m_aTimerHash.erase( aIter ); + } + + if ( bSetTimer ) + { + VbaTimer* pTimer = new VbaTimer; + m_pImpl->m_aTimerHash[ aTimerIndex ] = pTimer; + pTimer->Start( this, aFunction, nEarliestTime, nLatestTime ); + } +} + float SAL_CALL VbaApplicationBase::CentimetersToPoints( float _Centimeters ) throw (uno::RuntimeException) { // i cm = 28.35 points @@ -175,6 +407,57 @@ float SAL_CALL VbaApplicationBase::CentimetersToPoints( float _Centimeters ) thr return ( _Centimeters * rate ); } +// inserted by Michael E. Bohn +uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException) +{ + uno::Any aAny; + uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); + try + { + uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAAppService" )),mxContext); + uno::Reference < ::ooo::vba::XVBAAppService > xVBAAppService (xInterface, ::uno::UNO_QUERY_THROW ); + if (xVBAAppService.is()){ + uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); + return xVBAAppService->getVBE( this, mxContext, xModel); + } + + }catch(uno::Exception* e) + { + } + return aAny; +} + +uno::Any SAL_CALL +VbaApplicationBase::getVBProjects() throw (uno::RuntimeException) +{ + uno::Any aAny; + uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); + try + { + uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAAppService" )),mxContext); + uno::Reference < ::ooo::vba::XVBAAppService > xVBAAppService (xInterface, ::uno::UNO_QUERY_THROW ); + if (xVBAAppService.is()){ + uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XEmbeddedScripts > xEnbeddedScripts ( xModel, uno::UNO_QUERY_THROW ); + uno::Reference< script::XStorageBasedLibraryContainer > xMacroStorageBasedLibraryContainer = xEnbeddedScripts->getBasicLibraries(); + uno::Reference< script::XStorageBasedLibraryContainer > xDialogStorageBasedLibraryContainer = xEnbeddedScripts->getDialogLibraries(); + uno::Reference< script::XLibraryContainer > xMacroLibraryContainer ( xMacroStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); + uno::Reference< script::XLibraryContainer > xDialogLibraryContainer( xDialogStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); + return xVBAAppService->getVBProjects(this, mxContext, xModel, xMacroLibraryContainer, xDialogLibraryContainer); + } + + }catch(uno::Exception* e) + { + } + return aAny; + + + +} + + + + rtl::OUString& VbaApplicationBase::getServiceImplName() { @@ -193,6 +476,13 @@ VbaApplicationBase::getServiceNames() return aServiceNames; } +void SAL_CALL VbaApplicationBase::Undo() + throw (uno::RuntimeException) +{ + uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); + dispatchRequests( xModel, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Undo" ) ) ); +} + void VbaApplicationBase::Quit() throw (uno::RuntimeException) { // need to stop basic @@ -208,3 +498,4 @@ void VbaApplicationBase::Quit() throw (uno::RuntimeException) } } } + diff --git a/vbahelper/source/vbahelper/vbacommandbar.cxx b/vbahelper/source/vbahelper/vbacommandbar.cxx index 1e2911ad4f52..1e8d21d53583 100644 --- a/vbahelper/source/vbahelper/vbacommandbar.cxx +++ b/vbahelper/source/vbahelper/vbacommandbar.cxx @@ -202,3 +202,85 @@ ScVbaCommandBar::getServiceNames() } return aServiceNames; } + + +VbaDummyCommandBar::VbaDummyCommandBar( + const uno::Reference< ov::XHelperInterface > xParent, + const uno::Reference< uno::XComponentContext > xContext, + const ::rtl::OUString& rName, sal_Int32 nType ) throw( uno::RuntimeException ) : + CommandBar_BASE( xParent, xContext ), + maName( rName ), + mnType( nType ) +{ +} + +::rtl::OUString SAL_CALL VbaDummyCommandBar::getName() throw ( uno::RuntimeException ) +{ + return maName; +} + +void SAL_CALL VbaDummyCommandBar::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeException) +{ + maName = _name; +} + +::sal_Bool SAL_CALL VbaDummyCommandBar::getVisible() throw (uno::RuntimeException) +{ + return sal_True; +} + +void SAL_CALL VbaDummyCommandBar::setVisible( ::sal_Bool /*_visible*/ ) throw (uno::RuntimeException) +{ +} + +::sal_Bool SAL_CALL VbaDummyCommandBar::getEnabled() throw (uno::RuntimeException) +{ + // emulated with Visible + return getVisible(); +} + +void SAL_CALL VbaDummyCommandBar::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException) +{ + // emulated with Visible + setVisible( _enabled ); +} + +void SAL_CALL VbaDummyCommandBar::Delete( ) throw (script::BasicErrorException, uno::RuntimeException) +{ + // no-op +} + +uno::Any SAL_CALL VbaDummyCommandBar::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException) +{ + uno::Reference< XCommandBarControls > xCommandBarControls( new VbaDummyCommandBarControls( this, mxContext ) ); + if( aIndex.hasValue() ) + return xCommandBarControls->Item( aIndex, uno::Any() ); + return uno::Any( xCommandBarControls ); +} + +sal_Int32 SAL_CALL VbaDummyCommandBar::Type() throw (script::BasicErrorException, uno::RuntimeException) +{ + return mnType; +} + +uno::Any SAL_CALL VbaDummyCommandBar::FindControl( const uno::Any& /*aType*/, const uno::Any& /*aId*/, const uno::Any& /*aTag*/, const uno::Any& /*aVisible*/, const uno::Any& /*aRecursive*/ ) throw (script::BasicErrorException, uno::RuntimeException) +{ + return uno::Any( uno::Reference< XCommandBarControl >() ); +} + +rtl::OUString& VbaDummyCommandBar::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaDummyCommandBar") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > VbaDummyCommandBar::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBar" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/vbahelper/vbacommandbar.hxx b/vbahelper/source/vbahelper/vbacommandbar.hxx index 4f488fab6cd2..bcb5a11e9691 100644 --- a/vbahelper/source/vbahelper/vbacommandbar.hxx +++ b/vbahelper/source/vbahelper/vbacommandbar.hxx @@ -72,4 +72,38 @@ public: virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); }; + +/** Dummy command bar implementation. Does nothing but provide its name. */ +class VbaDummyCommandBar : public CommandBar_BASE +{ +public: + VbaDummyCommandBar( + const css::uno::Reference< ov::XHelperInterface > xParent, + const css::uno::Reference< css::uno::XComponentContext > xContext, + const ::rtl::OUString& rName, + sal_Int32 nType ) throw( css::uno::RuntimeException ); + + // Attributes + virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); + virtual void SAL_CALL setName( const ::rtl::OUString& _name ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException); + virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (css::uno::RuntimeException); + + // Methods + virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL Type( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL FindControl( const css::uno::Any& aType, const css::uno::Any& aId, const css::uno::Any& aTag, const css::uno::Any& aVisible, const css::uno::Any& aRecursive ) throw (css::script::BasicErrorException, css::uno::RuntimeException); + + // XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); + +private: + ::rtl::OUString maName; + sal_Int32 mnType; +}; + #endif//SC_VBA_COMMANDBAR_HXX diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx index a4bb3adc7dbf..3f9c7ddeae89 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx @@ -141,6 +141,22 @@ ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeExcep } } +::sal_Bool SAL_CALL +ScVbaCommandBarControl::getBeginGroup() throw (css::uno::RuntimeException) +{ + // TODO: need to check if the item before this item is of type 'separator' + return sal_False; +} + +void SAL_CALL +ScVbaCommandBarControl::setBeginGroup( ::sal_Bool _begin ) throw (css::uno::RuntimeException) +{ + if( getBeginGroup() != _begin ) + { + // TODO: need to insert or remove an item of type 'separator' before this item + } +} + void SAL_CALL ScVbaCommandBarControl::Delete( ) throw (script::BasicErrorException, uno::RuntimeException) { diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx index 6411430bacb1..a165f8e1cccd 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx @@ -67,6 +67,8 @@ public: virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException); virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getBeginGroup() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBeginGroup( ::sal_Bool _begin ) throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException) { return ov::office::MsoControlType::msoControlButton; diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx index 21e2dfb4b368..634b4a0e9395 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx @@ -34,10 +34,10 @@ typedef ::cppu::WeakImplHelper1< container::XEnumeration > CommandBarControlEnum class CommandBarControlEnumeration : public CommandBarControlEnumeration_BASE { //uno::Reference< uno::XComponentContext > m_xContext; - ScVbaCommandBarControls* m_pCommandBarControls; + CommandBarControls_BASE* m_pCommandBarControls; sal_Int32 m_nCurrentPosition; public: - CommandBarControlEnumeration( ScVbaCommandBarControls* pCommandBarControls ) : m_pCommandBarControls( pCommandBarControls ), m_nCurrentPosition( 0 ) {} + CommandBarControlEnumeration( CommandBarControls_BASE* pCommandBarControls ) : m_pCommandBarControls( pCommandBarControls ), m_nCurrentPosition( 0 ) {} virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException ) { if( m_nCurrentPosition < m_pCommandBarControls->getCount() ) @@ -140,7 +140,7 @@ ScVbaCommandBarControls::Item( const uno::Any& aIndex, const uno::Any& /*aIndex* { rtl::OUString sName; aIndex >>= sName; - nPosition = VbaCommandBarHelper::findControlByName( m_xIndexAccess, sName ); + nPosition = VbaCommandBarHelper::findControlByName( m_xIndexAccess, sName, m_bIsMenu ); } else { @@ -246,3 +246,75 @@ ScVbaCommandBarControls::getServiceNames() return aServiceNames; } +// ============================================================================ + +class VbaDummyIndexAccess : public ::cppu::WeakImplHelper1< container::XIndexAccess > +{ +public: + inline VbaDummyIndexAccess() {} + // XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) + { return 0; } + virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 /*Index*/ ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) + { throw lang::IndexOutOfBoundsException(); } + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) + { return XCommandBarControl::static_type( 0 ); } + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException) + { return false; } +}; + +// ---------------------------------------------------------------------------- + +VbaDummyCommandBarControls::VbaDummyCommandBarControls( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException) : + CommandBarControls_BASE( xParent, xContext, new VbaDummyIndexAccess ) +{ +} + +// XEnumerationAccess +uno::Type SAL_CALL VbaDummyCommandBarControls::getElementType() throw ( uno::RuntimeException ) +{ + return XCommandBarControl::static_type( 0 ); +} + +uno::Reference< container::XEnumeration > VbaDummyCommandBarControls::createEnumeration() throw ( uno::RuntimeException ) +{ + return uno::Reference< container::XEnumeration >( new CommandBarControlEnumeration( this ) ); +} + +uno::Any VbaDummyCommandBarControls::createCollectionObject( const uno::Any& /*aSource*/ ) +{ + return uno::Any( uno::Reference< XCommandBarControl >() ); +} + +// Methods +uno::Any SAL_CALL VbaDummyCommandBarControls::Item( const uno::Any& /*aIndex*/, const uno::Any& /*aIndex*/ ) throw (uno::RuntimeException) +{ + return uno::Any( uno::Reference< XCommandBarControl >() ); +} + +uno::Reference< XCommandBarControl > SAL_CALL VbaDummyCommandBarControls::Add( + const uno::Any& /*Type*/, const uno::Any& /*Id*/, const uno::Any& /*Parameter*/, const uno::Any& /*Before*/, const uno::Any& /*Temporary*/ ) throw (script::BasicErrorException, uno::RuntimeException) +{ + return uno::Reference< XCommandBarControl >(); +} + +// XHelperInterface +rtl::OUString& VbaDummyCommandBarControls::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaDummyCommandBarControls") ); + return sImplName; +} + +uno::Sequence VbaDummyCommandBarControls::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarControls" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx index 534ba5a10966..0b35773660d1 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx @@ -64,4 +64,24 @@ public: virtual css::uno::Sequence getServiceNames(); }; +class VbaDummyCommandBarControls : public CommandBarControls_BASE +{ +public: + VbaDummyCommandBarControls( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw( css::uno::RuntimeException ); + + // XEnumerationAccess + virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); + virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); + + // Methods + virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::XCommandBarControl > SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& Id, const css::uno::Any& Parameter, const css::uno::Any& Before, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException); + // XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); +}; + #endif//SC_VBA_COMMANDBARCONTROLS_HXX diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx index 06b997186169..385b220d201c 100644 --- a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx @@ -30,11 +30,10 @@ #include #include #include -#ifndef _COM_SUN_STAR_UI_UIElementType_HPP_ #include -#endif #include #include +#include #include #include @@ -233,7 +232,7 @@ rtl::OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference< } // if found, return the position of the control. if not found, return -1 -sal_Int32 VbaCommandBarHelper::findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException) +sal_Int32 VbaCommandBarHelper::findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName, bool bMenu ) throw (css::uno::RuntimeException) { sal_Int32 nCount = xIndexAccess->getCount(); css::uno::Sequence< css::beans::PropertyValue > aProps; @@ -242,17 +241,21 @@ sal_Int32 VbaCommandBarHelper::findControlByName( const css::uno::Reference< css rtl::OUString sLabel; xIndexAccess->getByIndex( i ) >>= aProps; getPropertyValue( aProps, rtl::OUString::createFromAscii(ITEM_DESCRIPTOR_LABEL) ) >>= sLabel; - // handle the hotkey character '~' - rtl::OUString sNewLabel; + // handle the hotkey marker '~' (remove in toolbars (?), replace by '&' in menus) + ::rtl::OUStringBuffer aBuffer; sal_Int32 index = sLabel.indexOf( sal_Unicode('~') ); if( index < 0 ) - sNewLabel = sLabel; - else if( index == 0 ) - sNewLabel = sLabel.copy( index + 1); - else if( index == sNewLabel.getLength() - 1 ) - sNewLabel = sLabel.copy(0, index ); + { + aBuffer = sLabel; + } else - sNewLabel = sLabel.copy( 0, index ) + sLabel.copy( index + 1 ); + { + aBuffer.append( sLabel.copy( 0, index ) ); + if( bMenu ) + aBuffer.append( sal_Unicode( '&' ) ); + aBuffer.append( sLabel.copy( index + 1 ) ); + } + rtl::OUString sNewLabel = aBuffer.makeStringAndClear(); OSL_TRACE("VbaCommandBarHelper::findControlByName, control name: %s", rtl::OUStringToOString( sNewLabel, RTL_TEXTENCODING_UTF8 ).getStr() ); if( sName.equalsIgnoreAsciiCase( sNewLabel ) ) return i; diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx index 1c18af07b3df..1fa41d7141b3 100644 --- a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx +++ b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx @@ -95,8 +95,8 @@ public: const rtl::OUString getModuleId(){ return maModuleId; } rtl::OUString findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException); - static sal_Int32 findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException); + static sal_Int32 findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName, bool bMenu = false ) throw (css::uno::RuntimeException); static rtl::OUString generateCustomURL(); }; -#endif//VBA_COMMANDBARHELPER_HXX +#endif //VBA_COMMANDBARHELPER_HXX diff --git a/vbahelper/source/vbahelper/vbacommandbars.cxx b/vbahelper/source/vbahelper/vbacommandbars.cxx index 3e7bdc6d53e8..9d6cd9e2eea7 100644 --- a/vbahelper/source/vbahelper/vbacommandbars.cxx +++ b/vbahelper/source/vbahelper/vbacommandbars.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include "vbacommandbars.hxx" #include "vbacommandbar.hxx" @@ -45,13 +46,13 @@ class CommandBarEnumeration : public CommandBarEnumeration_BASE { uno::Reference< XHelperInterface > m_xParent; uno::Reference< uno::XComponentContext > m_xContext; - VbaCommandBarHelperRef pCBarHelper; + VbaCommandBarHelperRef m_pCBarHelper; uno::Sequence< rtl::OUString > m_sNames; sal_Int32 m_nCurrentPosition; public: - CommandBarEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, VbaCommandBarHelperRef pHelper) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), pCBarHelper( pHelper ) , m_nCurrentPosition( 0 ) + CommandBarEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, VbaCommandBarHelperRef pHelper) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_pCBarHelper( pHelper ) , m_nCurrentPosition( 0 ) { - uno::Reference< container::XNameAccess > xNameAccess = pCBarHelper->getPersistentWindowState(); + uno::Reference< container::XNameAccess > xNameAccess = m_pCBarHelper->getPersistentWindowState(); m_sNames = xNameAccess->getElementNames(); } virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException ) @@ -68,8 +69,8 @@ public: rtl::OUString sResourceUrl( m_sNames[ m_nCurrentPosition++ ] ); if( sResourceUrl.indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 ) { - uno::Reference< container::XIndexAccess > xCBarSetting = pCBarHelper->getSettings( sResourceUrl ); - uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( m_xParent, m_xContext, pCBarHelper, xCBarSetting, sResourceUrl, sal_False, sal_False ) ); + uno::Reference< container::XIndexAccess > xCBarSetting = m_pCBarHelper->getSettings( sResourceUrl ); + uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( m_xParent, m_xContext, m_pCBarHelper, xCBarSetting, sResourceUrl, sal_False, sal_False ) ); } else return nextElement(); @@ -82,8 +83,8 @@ public: ScVbaCommandBars::ScVbaCommandBars( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : CommandBars_BASE( xParent, xContext, xIndexAccess ) { - pCBarHelper.reset( new VbaCommandBarHelper( mxContext, xModel ) ); - m_xNameAccess = pCBarHelper->getPersistentWindowState(); + m_pCBarHelper.reset( new VbaCommandBarHelper( mxContext, xModel ) ); + m_xNameAccess = m_pCBarHelper->getPersistentWindowState(); } ScVbaCommandBars::~ScVbaCommandBars() @@ -100,7 +101,7 @@ ScVbaCommandBars::getElementType() throw ( uno::RuntimeException ) uno::Reference< container::XEnumeration > ScVbaCommandBars::createEnumeration() throw ( uno::RuntimeException ) { - return uno::Reference< container::XEnumeration >( new CommandBarEnumeration( this, mxContext, pCBarHelper ) ); + return uno::Reference< container::XEnumeration >( new CommandBarEnumeration( this, mxContext, m_pCBarHelper ) ); } uno::Any @@ -111,28 +112,53 @@ ScVbaCommandBars::createCollectionObject( const uno::Any& aSource ) uno::Reference< container::XIndexAccess > xBarSettings; rtl::OUString sBarName; sal_Bool bMenu = sal_False; + uno::Any aRet; + if( aSource >>= sBarName ) { - if( sBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Worksheet Menu Bar") ) - || sBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Menu Bar") ) ) + // some built-in command bars + if( m_pCBarHelper->getModuleId().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.sheet.SpreadsheetDocument") ) ) { - // menu bar - sResourceUrl = rtl::OUString::createFromAscii( ITEM_MENUBAR_URL ); - bMenu = sal_True; + if( sBarName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("Worksheet Menu Bar") ) ) + { + // spreadsheet menu bar + sResourceUrl = rtl::OUString::createFromAscii( ITEM_MENUBAR_URL ); + bMenu = sal_True; + } + else if( sBarName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("Cell") ) ) + { + // EVIL HACK (tm): spreadsheet cell context menu as dummy object without functionality + aRet <<= uno::Reference< XCommandBar >( new VbaDummyCommandBar( this, mxContext, sBarName, office::MsoBarType::msoBarTypePopup ) ); + } } - else + else if( m_pCBarHelper->getModuleId().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextDocument") ) ) + { + if( sBarName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("Menu Bar") ) ) + { + // text processor menu bar + sResourceUrl = rtl::OUString::createFromAscii( ITEM_MENUBAR_URL ); + bMenu = sal_True; + } + } + + // nothing found - try to resolve from name + if( !aRet.hasValue() && (sResourceUrl.getLength() == 0) ) { - sResourceUrl = pCBarHelper->findToolbarByName( m_xNameAccess, sBarName ); + sResourceUrl = m_pCBarHelper->findToolbarByName( m_xNameAccess, sBarName ); bMenu = sal_False; } } if( sResourceUrl.getLength() ) - xBarSettings = pCBarHelper->getSettings( sResourceUrl ); - else + { + xBarSettings = m_pCBarHelper->getSettings( sResourceUrl ); + aRet <<= uno::Reference< XCommandBar >( new ScVbaCommandBar( this, mxContext, m_pCBarHelper, xBarSettings, sResourceUrl, bMenu, sal_False ) ); + } + + if( !aRet.hasValue() ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toolbar do not exist") ), uno::Reference< uno::XInterface >() ); - return uno::Any( uno::Reference< XCommandBar >( new ScVbaCommandBar( this, mxContext, pCBarHelper, xBarSettings, sResourceUrl, bMenu, sal_False ) ) ); + return aRet; } // XCommandBars @@ -149,7 +175,7 @@ ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Positio rtl::OUString sResourceUrl; if( sName.getLength() ) { - sResourceUrl = pCBarHelper->findToolbarByName( m_xNameAccess, sName ); + sResourceUrl = m_pCBarHelper->findToolbarByName( m_xNameAccess, sName ); if( sResourceUrl.getLength() ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toolbar exists") ), uno::Reference< uno::XInterface >() ); } @@ -163,8 +189,8 @@ ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Positio Temporary >>= bTemporary; sResourceUrl = VbaCommandBarHelper::generateCustomURL(); - uno::Reference< container::XIndexAccess > xBarSettings( pCBarHelper->getSettings( sResourceUrl ), uno::UNO_QUERY_THROW ); - uno::Reference< XCommandBar > xCBar( new ScVbaCommandBar( this, mxContext, pCBarHelper, xBarSettings, sResourceUrl, sal_False, bTemporary ) ); + uno::Reference< container::XIndexAccess > xBarSettings( m_pCBarHelper->getSettings( sResourceUrl ), uno::UNO_QUERY_THROW ); + uno::Reference< XCommandBar > xCBar( new ScVbaCommandBar( this, mxContext, m_pCBarHelper, xBarSettings, sResourceUrl, sal_False, bTemporary ) ); xCBar->setName( sName ); return xCBar; } @@ -199,9 +225,9 @@ ScVbaCommandBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) th if( nIndex == 1 ) { uno::Any aSource; - if( pCBarHelper->getModuleId().equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ) ) + if( m_pCBarHelper->getModuleId().equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ) ) aSource <<= rtl::OUString::createFromAscii( "Worksheet Menu Bar" ); - else if( pCBarHelper->getModuleId().equalsAscii("com.sun.star.text.TextDocument") ) + else if( m_pCBarHelper->getModuleId().equalsAscii("com.sun.star.text.TextDocument") ) aSource <<= rtl::OUString::createFromAscii( "Menu Bar" ); if( aSource.hasValue() ) return createCollectionObject( aSource ); diff --git a/vbahelper/source/vbahelper/vbacommandbars.hxx b/vbahelper/source/vbahelper/vbacommandbars.hxx index 698d718f7cdf..92ed1438d269 100644 --- a/vbahelper/source/vbahelper/vbacommandbars.hxx +++ b/vbahelper/source/vbahelper/vbacommandbars.hxx @@ -40,7 +40,7 @@ typedef CollTestImplHelper< ov::XCommandBars > CommandBars_BASE; class ScVbaCommandBars : public CommandBars_BASE { private: - VbaCommandBarHelperRef pCBarHelper; + VbaCommandBarHelperRef m_pCBarHelper; public: ScVbaCommandBars( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index fb2af0687d11..f27f2de53c8a 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -33,7 +33,9 @@ #include #include #include +#include //Michael E. Bohn #include +#include #include #include @@ -179,14 +181,14 @@ void VbaDocumentBase::setSaved( sal_Bool bSave ) throw (uno::RuntimeException) { uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW ); - xModifiable->setModified( bSave ); + xModifiable->setModified( !bSave ); } sal_Bool VbaDocumentBase::getSaved() throw (uno::RuntimeException) { uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW ); - return xModifiable->isModified(); + return !xModifiable->isModified(); } void @@ -204,6 +206,40 @@ VbaDocumentBase::Activate() throw (uno::RuntimeException) xFrame->activate(); } +// ---- Michael E.Bohn Start----- + +uno::Any SAL_CALL +VbaDocumentBase::getVBProject() throw (uno::RuntimeException) + +{ + uno::Any aAny; + uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); + try + { + uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBADocService" )),mxContext); + uno::Reference < ::ooo::vba::XVBADocService > xVBADocService (xInterface, ::uno::UNO_QUERY_THROW ); + if (xVBADocService.is()){ + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XEmbeddedScripts > xEnbeddedScripts ( xModel, uno::UNO_QUERY_THROW ); + uno::Reference< script::XStorageBasedLibraryContainer > xMacroStorageBasedLibraryContainer = xEnbeddedScripts->getBasicLibraries(); + uno::Reference< script::XStorageBasedLibraryContainer > xDialogStorageBasedLibraryContainer = xEnbeddedScripts->getDialogLibraries(); + uno::Reference< script::XLibraryContainer > xMacroLibraryContainer ( xMacroStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); + uno::Reference< script::XLibraryContainer > xDialogLibraryContainer( xDialogStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); + + return xVBADocService->getVBProject( this, mxContext, xModel, xMacroLibraryContainer, xDialogLibraryContainer ); + } + + }catch(uno::Exception* e) + { + } + return aAny; + +} + + +// ---- Michael E.Bohn End ----- + + rtl::OUString& VbaDocumentBase::getServiceImplName() { diff --git a/vbahelper/source/vbahelper/vbafontbase.cxx b/vbahelper/source/vbahelper/vbafontbase.cxx index 76e5de7761e1..3e84f55ef11a 100644 --- a/vbahelper/source/vbahelper/vbafontbase.cxx +++ b/vbahelper/source/vbahelper/vbafontbase.cxx @@ -35,7 +35,20 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; -VbaFontBase::VbaFontBase( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< css::container::XIndexAccess >& xPalette, uno::Reference< beans::XPropertySet > xPropertySet ) throw ( uno::RuntimeException ) : VbaFontBase_BASE( xParent, xContext ), mxFont( xPropertySet, css::uno::UNO_QUERY_THROW ), mxPalette( xPalette ) +// form controls use other property name as the remaining OOo API +#define VBAFONTBASE_PROPNAME( ascii_normal, ascii_control ) \ + mbFormControl ? rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ascii_control ) ) : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ascii_normal ) ) + +VbaFontBase::VbaFontBase( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< css::container::XIndexAccess >& xPalette, + const uno::Reference< beans::XPropertySet >& xPropertySet, + bool bFormControl ) throw ( uno::RuntimeException ) : + VbaFontBase_BASE( xParent, xContext ), + mxFont( xPropertySet, uno::UNO_SET_THROW ), + mxPalette( xPalette, uno::UNO_SET_THROW ), + mbFormControl( bFormControl ) { } @@ -43,19 +56,22 @@ VbaFontBase::~VbaFontBase() { } - void SAL_CALL VbaFontBase::setSuperscript( const uno::Any& aValue ) throw ( uno::RuntimeException ) { + // not supported in form controls + if( mbFormControl ) + return; + sal_Bool bValue = sal_False; aValue >>= bValue; sal_Int16 nValue = NORMAL; sal_Int8 nValue2 = NORMALHEIGHT; - if( bValue ) + if( bValue ) { nValue = SUPERSCRIPT; - nValue2 = SUPERSCRIPTHEIGHT; + nValue2 = SUPERSCRIPTHEIGHT; } mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ), ( uno::Any )nValue ); mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapementHeight" ) ), ( uno::Any )nValue2 ); @@ -64,23 +80,29 @@ VbaFontBase::setSuperscript( const uno::Any& aValue ) throw ( uno::RuntimeExcept uno::Any SAL_CALL VbaFontBase::getSuperscript() throw ( uno::RuntimeException ) { - short nValue = 0; - mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ) ) >>= nValue; + short nValue = NORMAL; + // not supported in form controls + if( !mbFormControl ) + mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ) ) >>= nValue; return uno::makeAny( ( nValue == SUPERSCRIPT ) ); } void SAL_CALL VbaFontBase::setSubscript( const uno::Any& aValue ) throw ( uno::RuntimeException ) { + // not supported in form controls + if( mbFormControl ) + return; + sal_Bool bValue = sal_False; aValue >>= bValue; sal_Int16 nValue = NORMAL; sal_Int8 nValue2 = NORMALHEIGHT; - if( bValue ) + if( bValue ) { nValue= SUBSCRIPT; - nValue2 = SUBSCRIPTHEIGHT; + nValue2 = SUBSCRIPTHEIGHT; } mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapementHeight" ) ), ( uno::Any )nValue2 ); @@ -92,20 +114,30 @@ uno::Any SAL_CALL VbaFontBase::getSubscript() throw ( uno::RuntimeException ) { short nValue = NORMAL; - mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ) ) >>= nValue; + // not supported in form controls + if( !mbFormControl ) + mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ) ) >>= nValue; return uno::makeAny( ( nValue == SUBSCRIPT ) ); } void SAL_CALL VbaFontBase::setSize( const uno::Any& aValue ) throw( uno::RuntimeException ) { - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ) ), aValue ); + // form controls need a sal_Int16 containing points, other APIs need a float + uno::Any aVal( aValue ); + if( mbFormControl ) + { + float fVal; + aVal >>= fVal; + aVal <<= static_cast< sal_Int16 >( fVal ); + } + mxFont->setPropertyValue( VBAFONTBASE_PROPNAME( "CharHeight", "FontHeight" ), aVal ); } uno::Any SAL_CALL VbaFontBase::getSize() throw ( uno::RuntimeException ) { - return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ) ) ); + return mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharHeight", "FontHeight" ) ); } void SAL_CALL @@ -152,7 +184,7 @@ VbaFontBase::setBold( const uno::Any& aValue ) throw( uno::RuntimeException ) double fBoldValue = awt::FontWeight::NORMAL; if( bValue ) fBoldValue = awt::FontWeight::BOLD; - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" ) ), ( uno::Any )fBoldValue ); + mxFont->setPropertyValue( VBAFONTBASE_PROPNAME( "CharWeight", "FontWeight" ), uno::Any( fBoldValue ) ); } @@ -160,7 +192,7 @@ uno::Any SAL_CALL VbaFontBase::getBold() throw ( uno::RuntimeException ) { double fValue = 0.0; - mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" ) ) ) >>= fValue; + mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharWeight", "FontWeight" ) ) >>= fValue; return uno::makeAny( fValue == awt::FontWeight::BOLD ); } @@ -172,27 +204,28 @@ VbaFontBase::setStrikethrough( const uno::Any& aValue ) throw ( uno::RuntimeExce short nValue = awt::FontStrikeout::NONE; if( bValue ) nValue = awt::FontStrikeout::SINGLE; - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharStrikeout" ) ), ( uno::Any )nValue ); + mxFont->setPropertyValue( VBAFONTBASE_PROPNAME( "CharStrikeout", "FontStrikeout" ), uno::Any( nValue ) ); } uno::Any SAL_CALL VbaFontBase::getStrikethrough() throw ( uno::RuntimeException ) { short nValue = 0; - mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharStrikeout" ) ) ) >>= nValue; + mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharStrikeout", "FontStrikeout" ) ) >>= nValue; return uno::Any( nValue == awt::FontStrikeout::SINGLE ); } void SAL_CALL VbaFontBase::setShadow( const uno::Any& aValue ) throw ( uno::RuntimeException ) { - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharShadowed" ) ), aValue ); + if( !mbFormControl ) + mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharShadowed" ) ), aValue ); } uno::Any SAL_CALL VbaFontBase::getShadow() throw (uno::RuntimeException) { - return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharShadowed" ) ) ); + return mbFormControl ? uno::Any( false ) : mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharShadowed" ) ) ); } void SAL_CALL @@ -203,15 +236,14 @@ VbaFontBase::setItalic( const uno::Any& aValue ) throw ( uno::RuntimeException ) short nValue = awt::FontSlant_NONE; if( bValue ) nValue = awt::FontSlant_ITALIC; - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharPosture" ) ), ( uno::Any )nValue ); + mxFont->setPropertyValue( VBAFONTBASE_PROPNAME( "CharPosture", "FontSlant" ), uno::Any( nValue ) ); } uno::Any SAL_CALL VbaFontBase::getItalic() throw ( uno::RuntimeException ) { - awt::FontSlant aFS; - mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharPosture" ) ) ) >>= aFS; + mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharPosture", "FontSlant" ) ) >>= aFS; return uno::makeAny( aFS == awt::FontSlant_ITALIC ); } @@ -220,26 +252,27 @@ VbaFontBase::setName( const uno::Any& aValue ) throw ( uno::RuntimeException ) { rtl::OUString sString; aValue >>= sString; - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ) ), aValue); + mxFont->setPropertyValue( VBAFONTBASE_PROPNAME( "CharFontName", "FontName" ), aValue ); } uno::Any SAL_CALL VbaFontBase::getName() throw ( uno::RuntimeException ) { - return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ) ) ); + return mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharFontName", "FontName" ) ); } + uno::Any VbaFontBase::getColor() throw (uno::RuntimeException) { uno::Any aAny; - aAny = OORGBToXLRGB( mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) ) ) ); + aAny = OORGBToXLRGB( mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharColor", "TextColor" ) ) ); return aAny; } void VbaFontBase::setColor( const uno::Any& _color ) throw (uno::RuntimeException) { - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) ) , XLRGBToOORGB(_color)); + mxFont->setPropertyValue( VBAFONTBASE_PROPNAME( "CharColor", "TextColor" ), XLRGBToOORGB(_color) ); } void SAL_CALL @@ -273,7 +306,7 @@ VbaFontBase::setUnderline( const uno::Any& /*aValue*/ ) throw ( uno::RuntimeExce throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown value for Underline")), uno::Reference< uno::XInterface >() ); } - mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" ) ), ( uno::Any )nValue ); + mxFont->setPropertyValue( VBAFONTBASE_PROPNAME( "CharUnderline", "FontUnderline" ), uno::Any( nValue ) ); */ } @@ -282,7 +315,7 @@ uno::Any SAL_CALL VbaFontBase::getUnderline() throw ( uno::RuntimeException ) { sal_Int32 nValue = awt::FontUnderline::NONE; - mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" ) ) ) >>= nValue; + mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharUnderline", "FontUnderline" ) ) >>= nValue; /* switch ( nValue ) { diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index a9e72318536d..1953d0772f3c 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -31,11 +31,15 @@ #include #include #include +#include #include #include #include +#include #include #include +#include + #include #include @@ -63,8 +67,6 @@ #include #include #include -#include -#include #include #include #include @@ -82,12 +84,6 @@ using namespace ::com::sun::star; using namespace ::ooo::vba; -#define NAME_HEIGHT "Height" -#define NAME_WIDTH "Width" - -#define POINTTO100THMILLIMETERFACTOR 35.27778 - - void unoToSbxValue( SbxVariable* pVar, const uno::Any& aValue ); uno::Any sbxToUnoValue( SbxVariable* pVar ); @@ -98,6 +94,8 @@ namespace ooo namespace vba { +namespace { const double factor = 2540.0 / 72.0; } + css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException) { OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" ); @@ -271,7 +269,6 @@ getCurrentViewFrame() }; #endif -const double Millimeter::factor = 35.27778; uno::Reference< beans::XIntrospectionAccess > getIntrospectionAccess( const uno::Any& aObject ) throw (uno::RuntimeException) @@ -314,10 +311,9 @@ void dispatchExecute(SfxViewShell* pViewShell, USHORT nSlot, SfxCallMode nCall) } void -dispatchRequests (uno::Reference< frame::XModel>& xModel,rtl::OUString & aUrl, uno::Sequence< beans::PropertyValue >& sProps ) +dispatchRequests( const uno::Reference< frame::XModel>& xModel, const rtl::OUString& aUrl, const uno::Sequence< beans::PropertyValue >& sProps ) { - - util::URL url ; + util::URL url; url.Complete = aUrl; rtl::OUString emptyString = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" )); uno::Reference xController = xModel->getCurrentController(); @@ -328,25 +324,22 @@ dispatchRequests (uno::Reference< frame::XModel>& xModel,rtl::OUString & aUrl, u uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); uno::Reference xContext( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW ); if ( !xContext.is() ) - { - return ; - } + return; - uno::Reference xServiceManager( - xContext->getServiceManager() ); + uno::Reference xServiceManager = xContext->getServiceManager(); if ( !xServiceManager.is() ) - { - return ; - } - uno::Reference xParser( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ) - ,xContext), uno::UNO_QUERY_THROW ); + return; + + uno::Reference xParser( xServiceManager->createInstanceWithContext( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ), xContext), + uno::UNO_QUERY_THROW ); if (!xParser.is()) return; xParser->parseStrict (url); } catch ( uno::Exception & /*e*/ ) { - return ; + return; } uno::Reference xDispatcher = xDispatchProvider->queryDispatch(url,emptyString,0); @@ -360,7 +353,7 @@ dispatchRequests (uno::Reference< frame::XModel>& xModel,rtl::OUString & aUrl, u dispatchProps.realloc( nProps + 1 ); // need to reaccquire pDest after realloc pDest = dispatchProps.getArray(); - beans::PropertyValue* pSrc = sProps.getArray(); + const beans::PropertyValue* pSrc = sProps.getConstArray(); for ( sal_Int32 index=0; index& xModel,rtl::OUString & aUrl, u } void -dispatchRequests (uno::Reference< frame::XModel>& xModel,rtl::OUString & aUrl) +dispatchRequests( const uno::Reference< frame::XModel>& xModel, const rtl::OUString& aUrl ) { uno::Sequence dispatchProps; dispatchRequests( xModel, aUrl, dispatchProps ); } - - - - uno::Reference< frame::XModel > +uno::Reference< frame::XModel > getCurrentDoc( const rtl::OUString& sKey ) throw (uno::RuntimeException) { uno::Reference< frame::XModel > xModel; @@ -840,12 +830,22 @@ double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt: double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical) { double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); - return fPoints * POINTTO100THMILLIMETERFACTOR * fConvertFactor; + return PointsToHmm( fPoints ) * fConvertFactor; } double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical) { double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical ); - return (fPixels/fConvertFactor)/POINTTO100THMILLIMETERFACTOR; + return HmmToPoints( fPixels/fConvertFactor ); +} + +sal_Int32 PointsToHmm( double fPoints ) +{ + return static_cast( fPoints * factor + 0.5 ); +} + +double HmmToPoints( sal_Int32 nHmm ) +{ + return nHmm / factor; } ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& /*xContext*/, const css::uno::Reference< css::drawing::XShape >& xShape ) @@ -962,53 +962,284 @@ sal_Bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const r return sal_False; } -#define VBA_LEFT "PositionX" -#define VBA_TOP "PositionY" +// ====UserFormGeomentryHelper==== +//--------------------------------------------- UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl ) { + if ( !xControl.is() ) + throw uno::RuntimeException(); + + mxControlUnits.set( xControl->getPeer(), uno::UNO_QUERY_THROW ); mxModel.set( xControl->getModel(), uno::UNO_QUERY_THROW ); } - double UserFormGeometryHelper::getLeft() + +//--------------------------------------------- +sal_Int32 UserFormGeometryHelper::ConvertPixelToLogic( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nTargetUnit ) +{ + sal_Int32 nResult = 0; + if ( bIsPoint ) + { + // conversion for a point + awt::Point aPixelPoint( 0, 0 ); + ( bIsX ? aPixelPoint.X : aPixelPoint.Y ) = nValue; + awt::Point aTargetPoint( 0, 0 ); + aTargetPoint = mxControlUnits->convertPointToLogic( aPixelPoint, nTargetUnit ); + + nResult = bIsX ? aTargetPoint.X : aTargetPoint.Y; + } + else + { + // conversion for a size + awt::Size aPixelSize( 0, 0 ); + ( bIsX ? aPixelSize.Width : aPixelSize.Height ) = nValue; + awt::Size aTargetSize( 0, 0 ); + aTargetSize = mxControlUnits->convertSizeToLogic( aPixelSize, nTargetUnit ); + + nResult = bIsX ? aTargetSize.Width : aTargetSize.Height; + } + + return nResult; +} + +//--------------------------------------------- +sal_Int32 UserFormGeometryHelper::ConvertLogicToPixel( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nSourceUnit ) +{ + sal_Int32 nResult = 0; + if ( bIsPoint ) + { + // conversion for a point + awt::Point aSourcePoint( 0, 0 ); + ( bIsX ? aSourcePoint.X : aSourcePoint.Y ) = nValue; + + awt::Point aPixelPoint( 0, 0 ); + aPixelPoint = mxControlUnits->convertPointToPixel( aSourcePoint, nSourceUnit ); + + nResult = bIsX ? aPixelPoint.X : aPixelPoint.Y; + } + else + { + // conversion for a size + awt::Size aSourceSize( 0, 0 ); + ( bIsX ? aSourceSize.Width : aSourceSize.Height ) = nValue; + + awt::Size aPixelSize( 0, 0 ); + aPixelSize = mxControlUnits->convertSizeToPixel( aSourceSize, nSourceUnit ); + + nResult = bIsX ? aPixelSize.Width : aPixelSize.Height; + } + + return nResult; +} +//--------------------------------------------- +double UserFormGeometryHelper::getLeft() +{ + double nResult = 0; + + try + { + sal_Int32 nLeft = 0; + mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft; + nResult = ConvertLogicToPixel( nLeft, + sal_True, // Point + sal_True, // X + util::MeasureUnit::APPFONT ); + } + catch ( uno::RuntimeException& ) + { + throw; + } + catch ( uno::Exception& e ) + { + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not get position X!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); + } + + return nResult; +} + +//--------------------------------------------- +void UserFormGeometryHelper::setLeft( double nLeft ) +{ + try + { + mxModel->setPropertyValue( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ), + uno::makeAny( ConvertPixelToLogic( nLeft, + sal_True, // Point + sal_True, // X + util::MeasureUnit::APPFONT ) ) ); + } + catch ( uno::RuntimeException& ) + { + throw; + } + catch ( uno::Exception& e ) + { + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not set position X!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); + } +} + +//--------------------------------------------- +double UserFormGeometryHelper::getTop() +{ + double nResult = 0; + + try { - sal_Int32 nLeft = 0; - mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft; - return Millimeter::getInPoints( nLeft ); + sal_Int32 nTop = 0; + mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop; + nResult = ConvertLogicToPixel( nTop, + sal_True, // Point + sal_False, // Y + util::MeasureUnit::APPFONT ); } - void UserFormGeometryHelper::setLeft( double nLeft ) + catch ( uno::RuntimeException& ) { - mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nLeft ) ) ); + throw; } - double UserFormGeometryHelper::getTop() + catch ( uno::Exception& e ) { - sal_Int32 nTop = 0; - mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop; - return Millimeter::getInPoints( nTop ); + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not get position Y!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); } - void UserFormGeometryHelper::setTop( double nTop ) + + return nResult; +} + +//--------------------------------------------- +void UserFormGeometryHelper::setTop( double nTop ) +{ + try + { + mxModel->setPropertyValue( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ), + uno::makeAny( ConvertPixelToLogic( nTop, + sal_True, // Point + sal_False, // Y + util::MeasureUnit::APPFONT ) ) ); + } + catch ( uno::RuntimeException& ) { - mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nTop ) ) ); + throw; } - double UserFormGeometryHelper::getHeight() + catch ( uno::Exception& e ) { - sal_Int32 nHeight = 0; - mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( NAME_HEIGHT ) ) ) >>= nHeight; - return Millimeter::getInPoints( nHeight ); + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not set position X!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); } - void UserFormGeometryHelper::setHeight( double nHeight ) +} + +//--------------------------------------------- +double UserFormGeometryHelper::getWidth() +{ + double nResult = 0; + + try { - mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( NAME_HEIGHT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nHeight ) ) ); + sal_Int32 nWidth = 0; + mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_WIDTH ) ) ) >>= nWidth; + nResult = ConvertLogicToPixel( nWidth, + sal_False, // Size + sal_True, // X + util::MeasureUnit::APPFONT ); } - double UserFormGeometryHelper::getWidth() + catch ( uno::RuntimeException& ) { - sal_Int32 nWidth = 0; - mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( NAME_WIDTH ) ) ) >>= nWidth; - return Millimeter::getInPoints( nWidth ); + throw; } - void UserFormGeometryHelper::setWidth( double nWidth) + catch ( uno::Exception& e ) { - mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( NAME_WIDTH ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nWidth ) ) ); + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not get width!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); } + return nResult; +} + +//--------------------------------------------- +void UserFormGeometryHelper::setWidth( double nWidth) +{ + try + { + mxModel->setPropertyValue( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_WIDTH ) ), + uno::makeAny( ConvertPixelToLogic( nWidth, + sal_False, // Size + sal_True, // X + util::MeasureUnit::APPFONT ) ) ); + } + catch ( uno::RuntimeException& ) + { + throw; + } + catch ( uno::Exception& e ) + { + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not set width!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); + } +} + +//--------------------------------------------- +double UserFormGeometryHelper::getHeight() +{ + double nResult = 0; + + try + { + sal_Int32 nHeight = 0; + mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_HEIGHT ) ) ) >>= nHeight; + nResult = ConvertLogicToPixel( nHeight, + sal_False, // Size + sal_False, // Y + util::MeasureUnit::APPFONT ); + } + catch ( uno::RuntimeException& ) + { + throw; + } + catch ( uno::Exception& e ) + { + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not get height!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); + } + + return nResult; +} + +//--------------------------------------------- +void UserFormGeometryHelper::setHeight( double nHeight ) +{ + try + { + mxModel->setPropertyValue( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_HEIGHT ) ), + uno::makeAny( ConvertPixelToLogic( nHeight, + sal_False, // Size + sal_False, // Y + util::MeasureUnit::APPFONT ) ) ); + } + catch ( uno::RuntimeException& ) + { + throw; + } + catch ( uno::Exception& e ) + { + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not set height!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); + } +} + +// ============ + double ConcreteXShapeGeometryAttributes::getLeft() { return m_pShapeHelper->getLeft(); @@ -1140,8 +1371,7 @@ UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComp void Millimeter::set(double mm) { m_nMillimeter = mm; } void Millimeter::setInPoints(double points) { - m_nMillimeter = points * 0.352777778; - // 25.4mm / 72 + m_nMillimeter = points * factor / 100.0; } void Millimeter::setInHundredthsOfOneMillimeter(double hmm) @@ -1159,7 +1389,7 @@ UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComp } double Millimeter::getInPoints() { - return m_nMillimeter * 2.834645669; // 72 / 25.4mm + return m_nMillimeter / factor * 100.0; } sal_Int32 Millimeter::getInHundredthsOfOneMillimeter(double points) diff --git a/xmloff/inc/xmloff/XMLEventExport.hxx b/xmloff/inc/xmloff/XMLEventExport.hxx index 4a8a8b8d45b5..b0ec63b45b35 100644 --- a/xmloff/inc/xmloff/XMLEventExport.hxx +++ b/xmloff/inc/xmloff/XMLEventExport.hxx @@ -73,6 +73,8 @@ class XMLOFF_DLLPUBLIC XMLEventExport HandlerMap aHandlerMap; NameMap aNameTranslationMap; + bool bExtNamespace; + public: XMLEventExport(SvXMLExport& rExport, const XMLEventNameTranslation* pTranslationTable = NULL); @@ -104,6 +106,12 @@ public: ::com::sun::star::container::XNameAccess> & xAccess, sal_Bool bUseWhitespace = sal_True); + /// export the events, but write element + /// (for new file format additions) + void ExportExt( ::com::sun::star::uno::Reference< + ::com::sun::star::container::XNameAccess> & xAccess, + sal_Bool bUseWhitespace = sal_True); + /// export a single event (writes element) void ExportSingleEvent( ::com::sun::star::uno::Sequence< diff --git a/xmloff/source/script/XMLEventExport.cxx b/xmloff/source/script/XMLEventExport.cxx index e7c716a39372..f126fd566e94 100644 --- a/xmloff/source/script/XMLEventExport.cxx +++ b/xmloff/source/script/XMLEventExport.cxx @@ -62,7 +62,8 @@ using ::xmloff::token::XML_EVENT_LISTENERS; XMLEventExport::XMLEventExport(SvXMLExport& rExp, const XMLEventNameTranslation* pTranslationTable) : sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")), - rExport(rExp) + rExport(rExp), + bExtNamespace(false) { AddTranslationTable(pTranslationTable); } @@ -175,6 +176,16 @@ void XMLEventExport::Export( Reference & rAccess, } } +void XMLEventExport::ExportExt( Reference & rAccess, + sal_Bool bWhitespace ) +{ + // set bExtNamespace flag to use XML_NAMESPACE_OFFICE_EXT namespace + // for events element (not for child elements) + bExtNamespace = true; + Export(rAccess, bWhitespace); + bExtNamespace = false; // reset for future Export calls +} + /// export a singular event and wirte container void XMLEventExport::ExportSingleEvent( Sequence& rEventValues, @@ -270,13 +281,17 @@ void XMLEventExport::StartElement(sal_Bool bWhitespace) { rExport.IgnorableWhitespace(); } - rExport.StartElement( XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, + sal_uInt16 nNamespace = bExtNamespace ? XML_NAMESPACE_OFFICE_EXT + : XML_NAMESPACE_OFFICE; + rExport.StartElement( nNamespace, XML_EVENT_LISTENERS, bWhitespace); } void XMLEventExport::EndElement(sal_Bool bWhitespace) { - rExport.EndElement(XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, bWhitespace); + sal_uInt16 nNamespace = bExtNamespace ? XML_NAMESPACE_OFFICE_EXT + : XML_NAMESPACE_OFFICE; + rExport.EndElement(nNamespace, XML_EVENT_LISTENERS, bWhitespace); if (bWhitespace) { rExport.IgnorableWhitespace(); @@ -343,6 +358,10 @@ const XMLEventNameTranslation aStandardEventTable[] = { "OnFieldMerge", XML_NAMESPACE_OFFICE, "field-merge" }, { "OnFieldMergeFinished", XML_NAMESPACE_OFFICE, "field-merge-finished" }, { "OnLayoutFinished", XML_NAMESPACE_OFFICE, "layout-finished" }, + { "OnDoubleClick", XML_NAMESPACE_OFFICE, "dblclick" }, + { "OnRightClick", XML_NAMESPACE_OFFICE, "contextmenu" }, + { "OnChange", XML_NAMESPACE_OFFICE, "content-changed" }, + { "OnCalculate", XML_NAMESPACE_OFFICE, "calculated" }, { NULL, 0, 0 } }; diff --git a/xmlscript/inc/xmlscript/xmlmod_imexp.hxx b/xmlscript/inc/xmlscript/xmlmod_imexp.hxx index c7c1d6d1acdc..a2873542d10c 100644 --- a/xmlscript/inc/xmlscript/xmlmod_imexp.hxx +++ b/xmlscript/inc/xmlscript/xmlmod_imexp.hxx @@ -45,6 +45,7 @@ struct ModuleDescriptor ::rtl::OUString aName; ::rtl::OUString aLanguage; ::rtl::OUString aCode; + ::rtl::OUString aModuleType; // VBA }; void diff --git a/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx b/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx index ba23ad031f91..781d2d779dda 100644 --- a/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx +++ b/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx @@ -65,6 +65,9 @@ SAL_CALL exportScriptModule( rMod.aName ); pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ), rMod.aLanguage ); + if( rMod.aModuleType.getLength()>0 ) + pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":moduleType") ), + rMod.aModuleType ); xOut->ignorableWhitespace( OUString() ); xOut->startElement( aModuleName, xAttributes ); diff --git a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx index b995817c1eb9..7f38f915aa62 100644 --- a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx +++ b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx @@ -188,11 +188,14 @@ Reference< xml::input::XElement > ModuleImport::startRootElement( else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("module") )) { mrModuleDesc.aName = xAttributes->getValueByUidName( - XMLNS_LIBRARY_UID, + XMLNS_SCRIPT_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("name") ) ); mrModuleDesc.aLanguage = xAttributes->getValueByUidName( - XMLNS_XLINK_UID, + XMLNS_SCRIPT_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("language") ) ); + mrModuleDesc.aModuleType = xAttributes->getValueByUidName( + XMLNS_SCRIPT_UID, + OUString( RTL_CONSTASCII_USTRINGPARAM("moduleType") ) ); return new ModuleElement( rLocalName, xAttributes, 0, this ); } -- cgit From 02799da3b58265a3051b2b4f7626daf0feee2b78 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 15 Jun 2010 20:19:01 +0200 Subject: mib16: contributed bugfixes and various new symbols in VBA compatibility implementation --- basic/source/runtime/os2.asm | 103 ---------------- basic/source/runtime/win.asm | 80 ------------- oovbaapi/ooo/vba/XVBAAppService.idl | 72 ++++++++++++ oovbaapi/ooo/vba/XVBADocService.idl | 72 ++++++++++++ oovbaapi/ooo/vba/excel/SheetObject.idl | 131 +++++++++++++++++++++ oovbaapi/ooo/vba/excel/SheetObjects.idl | 150 ++++++++++++++++++++++++ oovbaapi/ooo/vba/excel/XHyperlinks.idl | 70 +++++++++++ vbahelper/source/msforms/vbasystemaxcontrol.cxx | 101 ++++++++++++++++ vbahelper/source/msforms/vbasystemaxcontrol.hxx | 58 +++++++++ 9 files changed, 654 insertions(+), 183 deletions(-) delete mode 100644 basic/source/runtime/os2.asm delete mode 100644 basic/source/runtime/win.asm create mode 100755 oovbaapi/ooo/vba/XVBAAppService.idl create mode 100755 oovbaapi/ooo/vba/XVBADocService.idl create mode 100755 oovbaapi/ooo/vba/excel/SheetObject.idl create mode 100755 oovbaapi/ooo/vba/excel/SheetObjects.idl create mode 100755 oovbaapi/ooo/vba/excel/XHyperlinks.idl create mode 100755 vbahelper/source/msforms/vbasystemaxcontrol.cxx create mode 100755 vbahelper/source/msforms/vbasystemaxcontrol.hxx diff --git a/basic/source/runtime/os2.asm b/basic/source/runtime/os2.asm deleted file mode 100644 index a56f0b74b89e..000000000000 --- a/basic/source/runtime/os2.asm +++ /dev/null @@ -1,103 +0,0 @@ -;************************************************************************* -; -; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -; -; Copyright 2000, 2010 Oracle and/or its affiliates. -; -; OpenOffice.org - a multi-platform office productivity suite -; -; This file is part of OpenOffice.org. -; -; OpenOffice.org is free software: you can redistribute it and/or modify -; it under the terms of the GNU Lesser General Public License version 3 -; only, as published by the Free Software Foundation. -; -; OpenOffice.org is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU Lesser General Public License version 3 for more details -; (a copy is included in the LICENSE file that accompanied this code). -; -; You should have received a copy of the GNU Lesser General Public License -; version 3 along with OpenOffice.org. If not, see -; -; for a copy of the LGPLv3 License. -; -;************************************************************************* - -; Anmerkungen -; Direktaufruf von C- und PASCAL-Routinen, OS/2 -; -; Inhalt: -; type = CallXXX (far *proc, char *stack, short nstack) -; -; Kopie des Basic-Stacks (nstack Bytes) auf den C-Stack -; und Aufruf der Prozedur. - - .386 - .MODEL FLAT - - .CODE - - PUBLIC CallINT - PUBLIC CallLNG - PUBLIC CallSNG - PUBLIC CallDBL - PUBLIC CallSTR - PUBLIC CallFIX - - PUBLIC _CallINT - PUBLIC _CallLNG - PUBLIC _CallSNG - PUBLIC _CallDBL - PUBLIC _CallSTR - PUBLIC _CallFIX - -_CallINT LABEL byte -_CallLNG LABEL byte -_CallSNG LABEL byte -_CallDBL LABEL byte -_CallSTR LABEL byte -_CallFIX LABEL byte - -CallINT LABEL byte -CallLNG LABEL byte -CallSNG LABEL byte -CallDBL LABEL byte -CallSTR LABEL byte -CallFIX PROC - -p EQU [EBP+8] -stk EQU [EBP+12] -n EQU [EBP+16] - - PUSH EBP - MOV EBP,ESP - PUSH ESI - PUSH EDI - MOV DX,DS - MOVZX ECX,word ptr [n] - SUB ESP,ECX - MOV EDI,ESP - MOV AX,SS - MOV ES,AX - MOV ESI,[stk] - SHR ECX,1 - CLD - JCXZ $1 - REP MOVSW ; Stack uebernehmen -$1: MOV DS,DX - CALL LARGE [p] ; 32-bit - MOV ECX,EBP - SUB ECX,8 ; wegen gepushter Register - MOV ESP,ECX - POP EDI - POP ESI - POP EBP -; Bei Borland C++ Calling Convention: -; RET 12 -; CSet System-Calling Convention - RET -CallFIX ENDP - - END diff --git a/basic/source/runtime/win.asm b/basic/source/runtime/win.asm deleted file mode 100644 index dea597a4ce51..000000000000 --- a/basic/source/runtime/win.asm +++ /dev/null @@ -1,80 +0,0 @@ -;************************************************************************* -; -; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -; -; Copyright 2000, 2010 Oracle and/or its affiliates. -; -; OpenOffice.org - a multi-platform office productivity suite -; -; This file is part of OpenOffice.org. -; -; OpenOffice.org is free software: you can redistribute it and/or modify -; it under the terms of the GNU Lesser General Public License version 3 -; only, as published by the Free Software Foundation. -; -; OpenOffice.org is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU Lesser General Public License version 3 for more details -; (a copy is included in the LICENSE file that accompanied this code). -; -; You should have received a copy of the GNU Lesser General Public License -; version 3 along with OpenOffice.org. If not, see -; -; for a copy of the LGPLv3 License. -; -;************************************************************************* - -; Anmerkungen -; Direktaufruf von C- und PASCAL-Routinen, Windows und OS/2 -; -; Inhalt: -; type = CallXXX (far *proc, char *stack, short nstack) -; -; Kopie des Basic-Stacks (nstack Bytes) auf den C-Stack -; und Aufruf der Prozedur. - - .MODEL LARGE,C - - .CODE - - PUBLIC CallINT - PUBLIC CallLNG - PUBLIC CallSNG - PUBLIC CallDBL - PUBLIC CallSTR - PUBLIC CallFIX - -CallINT LABEL byte -CallLNG LABEL byte -CallSNG LABEL byte -CallDBL LABEL byte -CallSTR LABEL byte -CallFIX PROC p:PTR,stk:PTR,n:WORD - - PUSH SI - PUSH DI - MOV DX,DS - SUB SP,[n] - MOV DI,SP - MOV AX,SS - MOV ES,AX - LDS SI,[stk] - MOV CX,[n] - SHR CX,1 - CLD - JCXZ $1 - REP MOVSW ; Stack uebernehmen -$1: MOV DS,DX - CALL [p] ; Aufruf der Prozedur - CLI - MOV SP,BP - SUB SP,4 ; wegen gepushter Register - STI - POP DI - POP SI - RET - -CallFIX ENDP - - END diff --git a/oovbaapi/ooo/vba/XVBAAppService.idl b/oovbaapi/ooo/vba/XVBAAppService.idl new file mode 100755 index 000000000000..1c4a0920fbf8 --- /dev/null +++ b/oovbaapi/ooo/vba/XVBAAppService.idl @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: XWorkbook.idl,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __ooo_vba_appservice_idl__ +#define __ooo_vba_appservice_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +#ifndef __com_sun_star_uno_XComponentContext_idl__ +#include +#endif + +#ifndef __com_sun_star_frame_XModel_idl__ +#include +#endif + +#ifndef __com_sun_star_script_XLibraryContainer_idl__ +#include +#endif + +//============================================================================= + +module ooo { module vba { + +//============================================================================= + + +interface XHelperInterface; +interface XComponentContext; +interface XModel; + +interface XVBAAppService +{ + interface ::com::sun::star::uno::XInterface; + + any getVBE([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel); + any getVBProjects([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel, [in] ::com::sun::star::script::XLibraryContainer xMacroLibraryContainer, [in] com::sun::star::script::XLibraryContainer xDialogLibraryContainer); + + +}; + + }; }; + +#endif diff --git a/oovbaapi/ooo/vba/XVBADocService.idl b/oovbaapi/ooo/vba/XVBADocService.idl new file mode 100755 index 000000000000..6500f028934b --- /dev/null +++ b/oovbaapi/ooo/vba/XVBADocService.idl @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: XVBADocService.idl,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __ooo_vba_socservice_idl__ +#define __ooo_vba_appservice_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +#ifndef __com_sun_star_uno_XComponentContext_idl__ +#include +#endif + +#ifndef __com_sun_star_frame_XModel_idl__ +#include +#endif + +#ifndef __com_sun_star_script_XLibraryContainer_idl__ +#include +#endif + +//============================================================================= + +module ooo { module vba { + +//============================================================================= + + +interface XHelperInterface; +interface XComponentContext; +interface XModel; + +interface XVBADocService +{ + interface ::com::sun::star::uno::XInterface; + + + any getVBProject([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel, [in] ::com::sun::star::script::XLibraryContainer xMacroLibraryContainer, [in] com::sun::star::script::XLibraryContainer xDialogLibraryContainer); + + +}; + + }; }; + +#endif diff --git a/oovbaapi/ooo/vba/excel/SheetObject.idl b/oovbaapi/ooo/vba/excel/SheetObject.idl new file mode 100755 index 000000000000..e4037e69b84d --- /dev/null +++ b/oovbaapi/ooo/vba/excel/SheetObject.idl @@ -0,0 +1,131 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_excel_SheetObject_idl__ +#define __ooo_vba_excel_SheetObject_idl__ + +#include + +//============================================================================= + +/* Note: This file collects all compatibility interfaces for drawing objects + and drawing controls embedded in sheets. All these symbols are deprecated + in VBA and kept for compatibility with old VBA scripts. */ + +//============================================================================= + +module ooo { module vba { module excel { + +//============================================================================= + +/** Base interface for graphic objects and drawing controls in a single sheet. + +

      The objects supporting this interface are now deprecated in VBA in + favour of the Shapes and OLEObjects collections, but are kept for + compatibility with old VBA scripts. All form control objects do NOT belong + to ActiveX form controls but to the old-style drawing controls.

      + */ +interface XSheetObject : ooo::vba::XHelperInterface +{ + /** Left coordinate of the drawing object, in points. */ + [attribute] double Left; + + /** Top coordinate of the drawing object, in points. */ + [attribute] double Top; + + /** Width of the drawing object, in points. */ + [attribute] double Width; + + /** Height of the drawing object, in points. */ + [attribute] double Height; + + /** The name of the drawing object, used as collection key. */ + [attribute] string Name; + + /** Name of a macro that will be executed when the drawing object is clicked. */ + [attribute] string OnAction; + + /** Anchor mode of the object (fixed or variable position and size). Must + be a value from ooo::vba::excel::XlPlacement. */ + [attribute] long Placement; + + /** True = print object, false = skip object on printing. */ + [attribute] boolean PrintObject; +}; + +//============================================================================= + +/** Additional attributes for all drawing controls (this interface does not + belong to ActiveX form controls). + */ +interface XControlObject : com::sun::star::uno::XInterface +{ + [attribute] boolean AutoSize; +}; + +//============================================================================= + +/** Additional attributes for a push button drawing control (this interface + does not belong to ActiveX form controls). + */ +interface XButton : com::sun::star::uno::XInterface +{ + /** Visible caption of the button. */ + [attribute] string Caption; + + /** Font settings for the entire caption text. */ + [attribute] XFont Font; + + /** Horizontal alignment of the caption. */ + [attribute] long HorizontalAlignment; + + /** Vertical alignment of the caption. */ + [attribute] long VerticalAlignment; + + /** Orientation (rotation) of the text. Must be a value from + ooo::vba::excel::XlOrientation. */ + [attribute] long Orientation; + + /** Access to text and text formatting of the button caption. */ + XCharacters Characters( [in] any aStart, [in] any aLength ); +}; + +//============================================================================= + +/** Represents a drawing button control in a spreadsheet. */ +service Button +{ + interface XSheetObject; + interface XControlObject; + interface XButton; +}; + +//============================================================================= + +}; }; }; + +#endif diff --git a/oovbaapi/ooo/vba/excel/SheetObjects.idl b/oovbaapi/ooo/vba/excel/SheetObjects.idl new file mode 100755 index 000000000000..0339059e1231 --- /dev/null +++ b/oovbaapi/ooo/vba/excel/SheetObjects.idl @@ -0,0 +1,150 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_excel_SheetObjects_idl__ +#define __ooo_vba_excel_SheetObjects_idl__ + +#include + +//============================================================================= + +/* Note: This file collects all compatibility interfaces for collections of + drawing objects and drawing controls embedded in sheets. All these symbols + are deprecated in VBA and kept for compatibility with old VBA scripts. */ + +//============================================================================= + +module ooo { module vba { module excel { + +//============================================================================= + +/** Collections that implement this interface provide access to a specific type + of drawing objects in a single sheet. + +

      The following sheet symbols represent collections of graphic objects, + and therefore implement this interface:

      +
      • Buttons: push button (command button) controls,
      • +
      • ChartObjects: chart objects embedded in the sheet,
      • +
      • CheckBoxes: check box controls,
      • +
      • DropDowns: drop-down listbox controls,
      • +
      • EditBoxes: text edit controls (dialog sheets only),
      • +
      • GroupBoxes: group frame controls,
      • +
      • GroupObjects: group objects containing other child objects,
      • +
      • Labels: fixed text controls,
      • +
      • ListBoxes: plain listbox controls,
      • +
      • OptionButtons: option button (radio button) controls,
      • +
      • Ovals: simple ovals and circles,
      • +
      • Pictures: picture objects,
      • +
      • Rectangles: simple rectangle objects,
      • +
      • ScrollBars: scrollbar controls,
      • +
      • Spinners: spinner (spin button) controls,
      • +
      • TextBoxes: rectangle objects with embedded text.
      + +

      These symbols are now deprecated in VBA but kept for compatibility with + old VBA scripts. All symbols representing collections of form controls do + NOT belong to ActiveX form controls but to the old-style drawing controls. +

      + */ +interface XGraphicObjects : com::sun::star::uno::XInterface +{ + /** Adds a new graphic object to the sheet this collection belongs to. The + type of the object is determined by the type of the collection. + + @param fLeft Position of the left border in points (1/72 inch). + @param fTop Position of the top border in points (1/72 inch). + @param fWidth Width of the object in points (1/72 inch). + @param fHeight Height of the object in points (1/72 inch). + + @return The created graphic object. + */ + any Add( [in] any fLeft, [in] any fTop, [in] any fWidth, [in] any fHeight ); +}; + +//============================================================================= + +/** Collections that implement this interface provide access to a specific type + of drawing objects in a single sheet. + +

      The following sheet symbols represent collections of line objects, and + therefore implement this interface:

      +
      • Arcs: arc objects, and
      • +
      • Lines: straight line ojects.
      + +

      These symbols are now deprecated in VBA but kept for compatibility with + old VBA scripts.

      + */ +interface XLineObjects : com::sun::star::uno::XInterface +{ + /** Adds a new line object to the sheet this collection belongs to. The + type of the object is determined by the type of the collection. + + @param fX1 Position of the first X coordinate in points (1/72 inch). + @param fY1 Position of the first Y coordinate in points (1/72 inch). + @param fX2 Position of the last X coordinate in points (1/72 inch). + @param fY2 Position of the last Y coordinate in points (1/72 inch). + + @return The created line object. + */ + any Add( [in] any fX1, [in] any fY1, [in] any fX2, [in] any fY2 ); +}; + +//============================================================================= + +/** A collection providing access to all polygon objects in a single sheet. + +

      This symbol is now deprecated in VBA but kept for compatibility with old + VBA scripts.

      + */ +interface XDrawings : com::sun::star::uno::XInterface +{ + /** Adds a new polygon object to the sheet this collection belongs to. + + @param fX1 Position of the first X coordinate in points (1/72 inch). + @param fY1 Position of the first Y coordinate in points (1/72 inch). + @param fX2 Position of the last X coordinate in points (1/72 inch). + @param fY2 Position of the last Y coordinate in points (1/72 inch). + @param bClosed True = outline closed (last and first point connected). + + @return The created polygon object. + */ + any Add( [in] any fX1, [in] any fY1, [in] any fX2, [in] any fY2, [in] any bClosed ); +}; + +//============================================================================= + +/** Represents the collection of drawing button controls in a spreadsheet. */ +service Buttons +{ + interface ooo::vba::XCollection; + interface XGraphicObjects; +}; + +//============================================================================= + +}; }; }; + +#endif diff --git a/oovbaapi/ooo/vba/excel/XHyperlinks.idl b/oovbaapi/ooo/vba/excel/XHyperlinks.idl new file mode 100755 index 000000000000..dbaab84568e8 --- /dev/null +++ b/oovbaapi/ooo/vba/excel/XHyperlinks.idl @@ -0,0 +1,70 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __ooo_vba_excel_XHyperlinks_idl__ +#define __ooo_vba_excel_XHyperlinks_idl__ + +#include + +//============================================================================= + +module ooo { module vba { module excel { + +//============================================================================= + +interface XHyperlink; + +interface XHyperlinks +{ + // ------------------------------------------------------------------------ + + interface ::ooo::vba::XCollection; + + // ------------------------------------------------------------------------ + + XHyperlink Add( + [in] any aAnchor, + [in] any aAddress, + [in] any aSubAddress, + [in] any aScreenTip, + [in] any aTextToDisplay ); + + // ------------------------------------------------------------------------ + + void Delete(); + + // ------------------------------------------------------------------------ + +}; + +//============================================================================= + +}; }; }; + +//============================================================================= + +#endif diff --git a/vbahelper/source/msforms/vbasystemaxcontrol.cxx b/vbahelper/source/msforms/vbasystemaxcontrol.cxx new file mode 100755 index 000000000000..ed2fc70164ac --- /dev/null +++ b/vbahelper/source/msforms/vbasystemaxcontrol.cxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * ( a copy is included in the LICENSE file that accompanied this code ). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "vbasystemaxcontrol.hxx" + +using namespace com::sun::star; +using namespace ooo::vba; + +//---------------------------------------------------------- +VbaSystemAXControl::VbaSystemAXControl( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) +: SystemAXControlImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +, m_xControlInvocation( xControl, uno::UNO_QUERY_THROW ) +{ +} + +//---------------------------------------------------------- +uno::Reference< beans::XIntrospectionAccess > SAL_CALL VbaSystemAXControl::getIntrospection() + throw ( uno::RuntimeException ) +{ + return m_xControlInvocation->getIntrospection(); +} + +//---------------------------------------------------------- +uno::Any SAL_CALL VbaSystemAXControl::invoke( const ::rtl::OUString& aFunctionName, const uno::Sequence< uno::Any >& aParams, uno::Sequence< ::sal_Int16 >& aOutParamIndex, uno::Sequence< uno::Any >& aOutParam ) + throw ( lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException ) +{ + return m_xControlInvocation->invoke( aFunctionName, aParams, aOutParamIndex, aOutParam ); +} + +//---------------------------------------------------------- +void SAL_CALL VbaSystemAXControl::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) + throw ( beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException ) +{ + m_xControlInvocation->setValue( aPropertyName, aValue ); +} + +//---------------------------------------------------------- +uno::Any SAL_CALL VbaSystemAXControl::getValue( const ::rtl::OUString& aPropertyName ) + throw ( beans::UnknownPropertyException, uno::RuntimeException ) +{ + return m_xControlInvocation->getValue( aPropertyName ); +} + +//---------------------------------------------------------- +::sal_Bool SAL_CALL VbaSystemAXControl::hasMethod( const ::rtl::OUString& aName ) + throw ( uno::RuntimeException ) +{ + return m_xControlInvocation->hasMethod( aName ); +} + +//---------------------------------------------------------- +::sal_Bool SAL_CALL VbaSystemAXControl::hasProperty( const ::rtl::OUString& aName ) + throw ( uno::RuntimeException ) +{ + return m_xControlInvocation->hasProperty( aName ); +} + +//---------------------------------------------------------- +rtl::OUString& +VbaSystemAXControl::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM( "VbaSystemAXControl" ) ); + return sImplName; +} + +//---------------------------------------------------------- +uno::Sequence< rtl::OUString > +VbaSystemAXControl::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.msforms.Frame" ) ); + } + return aServiceNames; +} + diff --git a/vbahelper/source/msforms/vbasystemaxcontrol.hxx b/vbahelper/source/msforms/vbasystemaxcontrol.hxx new file mode 100755 index 000000000000..bffe5b99c4f1 --- /dev/null +++ b/vbahelper/source/msforms/vbasystemaxcontrol.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * ( a copy is included in the LICENSE file that accompanied this code ). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef VBA_SYSTEMAXCONTROL_HXX +#define VBA_SYSTEMAXCONTROL_HXX + +#include +#include + +#include "vbacontrol.hxx" +#include + +typedef cppu::ImplInheritanceHelper1< ScVbaControl, css::script::XInvocation > SystemAXControlImpl_BASE; + +class VbaSystemAXControl : public SystemAXControlImpl_BASE +{ + css::uno::Reference< css::script::XInvocation > m_xControlInvocation; + +public: + VbaSystemAXControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ); + + // XInvocation + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< ::sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException ); + virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw ( ::com::sun::star::uno::RuntimeException ); + + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); +}; + +#endif -- cgit From 7b4fd03cc280edac58705d047566e30d0b41bae0 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 15 Jun 2010 21:01:57 +0200 Subject: tl78v2: #i112427# Support password to modify in calc and writer ODF documents --- sfx2/inc/sfx2/objsh.hxx | 4 ++++ sfx2/inc/sfx2/sfxsids.hrc | 2 +- sfx2/sdi/sfx.sdi | 29 +---------------------------- sfx2/source/appl/appuno.cxx | 17 +++++++++++++++-- sfx2/source/dialog/filedlghelper.cxx | 25 ++++++++++++++++++------- sfx2/source/doc/objcont.cxx | 36 +++++++++++++++++++++++++++--------- sfx2/source/doc/sfxbasemodel.cxx | 18 +++++++++++++++--- sfx2/source/inc/objshimp.hxx | 2 ++ 8 files changed, 83 insertions(+), 50 deletions(-) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 95e8f21c8d86..6d2b6611991e 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -439,9 +439,13 @@ public: void SetSaveVersionOnClose( sal_Bool bSet ); void ResetFromTemplate( const String& rTemplateName, const String& rFileName ); + // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future sal_uInt32 GetModifyPasswordHash() const; sal_Bool SetModifyPasswordHash( sal_uInt32 nHash ); + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetModifyPasswordInfo() const; + sal_Bool SetModifyPasswordInfo( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aInfo ); + static sal_uInt32 HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc ); virtual void ViewAssigned(); diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 5492c76a7e7e..b7a3ddf8347d 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -306,7 +306,7 @@ #define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) #define SID_FONT_NAME (SID_SFX_START + 1716) #define SID_DEFAULTFILENAME (SID_SFX_START + 1717) -#define SID_MODIFYPASSWORDHASH (SID_SFX_START + 1718) +#define SID_MODIFYPASSWORDINFO (SID_SFX_START + 1718) #define SID_RECOMMENDREADONLY (SID_SFX_START + 1719) #define SID_SFX_free_START (SID_SFX_START + 1720) #define SID_SFX_free_END (SID_SFX_START + 3999) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index a19ea0fb8dfc..241f3900c09b 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3593,33 +3593,6 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER GroupId = GID_MACRO; ] -//-------------------------------------------------------------------------- -SfxInt32Item PasswordToModifyHash SID_MODIFYPASSWORDHASH - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = TRUE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = ; -] - //-------------------------------------------------------------------------- SfxBoolItem ReccomendReadonly SID_RECOMMENDREADONLY @@ -5317,7 +5290,7 @@ SfxBoolItem SaveAll SID_SAVEDOCS //-------------------------------------------------------------------------- SfxBoolItem SaveAs SID_SAVEASDOC -(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO,SfxInt32Item ModifyPasswordHash SID_MODIFYPASSWORDHASH) +(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO) [ /* flags: */ AutoUpdate = FALSE, diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 66452f10bbfb..6f9d3b258745 100755 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -191,6 +191,7 @@ static char const sFolderName[] = "FolderName"; static char const sUseSystemDialog[] = "UseSystemDialog"; static char const sStandardDir[] = "StandardDir"; static char const sBlackList[] = "BlackList"; +static char const sModifyPasswordInfo[] = "ModifyPasswordInfo"; void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot ) { @@ -846,6 +847,10 @@ void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Seque if (bOK) rSet.Put( SfxBoolItem( SID_NOAUTOSAVE, bVal ) ); } + else if ( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sModifyPasswordInfo)) ) + { + rSet.Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, rProp.Value ) ); + } #ifdef DBG_UTIL else --nFoundArgs; @@ -1058,6 +1063,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta nAdditional++; if ( rSet.GetItemState( SID_NOAUTOSAVE ) == SFX_ITEM_SET ) nAdditional++; + if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO ) == SFX_ITEM_SET ) + nAdditional++; // consider additional arguments nProps += nAdditional; @@ -1197,7 +1204,9 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta // used only internally if ( nId == SID_SAVETO ) continue; - } + if ( nId == SID_MODIFYPASSWORDINFO ) + continue; + } ByteString aDbg( "Unknown item detected: "); aDbg += ByteString::CreateFromInt32( nId ); @@ -1555,7 +1564,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sNoAutoSave)); pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() ); } - + if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO, sal_False, &pItem ) == SFX_ITEM_SET ) + { + pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sModifyPasswordInfo)); + pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() ); + } } } diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 569c0ddb163e..dba0da93208d 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -80,11 +80,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include "openflag.hxx" @@ -1528,8 +1530,8 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, mbPwdCheckBoxState = ( pPassItem != NULL ); // in case the document has password to modify, the dialog should be shown - SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxInt32Item, SID_MODIFYPASSWORDHASH, FALSE ); - mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); + SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUnoAnyItem, SID_MODIFYPASSWORDINFO, FALSE ); + mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue().hasValue() ); } SFX_ITEMSET_ARG( rpSet, pSelectItem, SfxBoolItem, SID_SELECTION, FALSE ); @@ -1541,7 +1543,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // the password will be set in case user decide so rpSet->ClearItem( SID_PASSWORD ); rpSet->ClearItem( SID_RECOMMENDREADONLY ); - rpSet->ClearItem( SID_MODIFYPASSWORDHASH ); + rpSet->ClearItem( SID_MODIFYPASSWORDINFO ); } @@ -1659,10 +1661,19 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if ( pPasswordRequest->getRecommendReadOnly() ) rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); - // the empty password has 0 as Hash - sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); - if ( nHash ) - rpSet->Put( SfxInt32Item( SID_MODIFYPASSWORDHASH, nHash ) ); + if ( bMSType ) + { + // the empty password has 0 as Hash + sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); + if ( nHash ) + rpSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( nHash ) ) ); + } + else + { + uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = ::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( pPasswordRequest->getPasswordToModify() ); + if ( aModifyPasswordInfo.getLength() ) + rpSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( aModifyPasswordInfo ) ) ); + } } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 547198f60ace..451e33084c07 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1249,17 +1249,35 @@ sal_uInt32 SfxObjectShell::GetModifyPasswordHash() const sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt32 nHash ) { -// Commented out before the solution for Saving process is found -// if ( ( !IsReadOnly() && !IsReadOnlyUI() ) -// || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) ) -// { -// // the hash can be changed only in editable documents, -// // or during loading of document + if ( ( !IsReadOnly() && !IsReadOnlyUI() ) + || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) ) + { + // the hash can be changed only in editable documents, + // or during loading of document pImp->m_nModifyPasswordHash = nHash; return sal_True; -// } -// -// return sal_False; + } + + return sal_False; +} + +uno::Sequence< beans::PropertyValue > SfxObjectShell::GetModifyPasswordInfo() const +{ + return pImp->m_aModifyPasswordInfo; +} + +sal_Bool SfxObjectShell::SetModifyPasswordInfo( const uno::Sequence< beans::PropertyValue >& aInfo ) +{ + if ( ( !IsReadOnly() && !IsReadOnlyUI() ) + || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) ) + { + // the hash can be changed only in editable documents, + // or during loading of document + pImp->m_aModifyPasswordInfo = aInfo; + return sal_True; + } + + return sal_False; } void SfxObjectShell::SetModifyPasswordEntered( sal_Bool bEntered ) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index d3707636d5ea..96f44169bfd0 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2732,11 +2732,21 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL uno::Reference< uno::XInterface >() ); } - SFX_ITEMSET_ARG( aParams, pModifyPasswordHashItem, SfxInt32Item, SID_MODIFYPASSWORDHASH, sal_False ); - sal_uInt32 nModifyPasswordHash = pModifyPasswordHashItem ? pModifyPasswordHashItem->GetValue() : 0; - aParams->ClearItem( SID_MODIFYPASSWORDHASH ); + sal_uInt32 nModifyPasswordHash = 0; + uno::Sequence< beans::PropertyValue > aModifyPasswordInfo; + SFX_ITEMSET_ARG( aParams, pModifyPasswordInfoItem, SfxUnoAnyItem, SID_MODIFYPASSWORDINFO, sal_False ); + if ( pModifyPasswordInfoItem ) + { + // it contains either a simple hash or a set of PropertyValues + // TODO/LATER: the sequence of PropertyValue should replace the hash completely in future + pModifyPasswordInfoItem->GetValue() >>= nModifyPasswordHash; + pModifyPasswordInfoItem->GetValue() >>= aModifyPasswordInfo; + } + aParams->ClearItem( SID_MODIFYPASSWORDINFO ); sal_uInt32 nOldModifyPasswordHash = m_pData->m_pObjectShell->GetModifyPasswordHash(); m_pData->m_pObjectShell->SetModifyPasswordHash( nModifyPasswordHash ); + uno::Sequence< beans::PropertyValue > aOldModifyPasswordInfo = m_pData->m_pObjectShell->GetModifyPasswordInfo(); + m_pData->m_pObjectShell->SetModifyPasswordInfo( aModifyPasswordInfo ); // since saving a document modifies its DocumentInfo, the current // DocumentInfo must be saved on "SaveTo", so it can be restored @@ -2823,6 +2833,7 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL else { m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); + m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo ); SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVETODOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVETODOCDONE), m_pData->m_pObjectShell ) ); } @@ -2834,6 +2845,7 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL m_pData->m_pObjectShell->StoreLog(); m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); + m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo ); SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOCFAILED : STR_EVENT_SAVEASDOCFAILED), diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index e170a7c27240..b5087fb46294 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -149,7 +149,9 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_Bool m_bIncomplEncrWarnShown; + // TODO/LATER: m_aModifyPasswordInfo should completely replace m_nModifyPasswordHash in future sal_uInt32 m_nModifyPasswordHash; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aModifyPasswordInfo; sal_Bool m_bModifyPasswordEntered; SfxObjectShell_Impl( SfxObjectShell& _rDocShell ); -- cgit From 3d2a51111ac8e45f6eae9d1fd9e52ee8c4cb35d0 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 16 Jun 2010 10:36:38 +0200 Subject: tl78v2: #i112427# Support password to modify in calc and writer ODF documents --- sfx2/source/doc/objmisc.cxx | 2 +- sfx2/source/doc/sfxbasemodel.cxx | 4 +++- sfx2/source/view/viewfrm.cxx | 22 +++++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index afcaa1614f2c..addb648ef2e9 100755 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1389,7 +1389,7 @@ void SfxObjectShell::FinishedLoading( sal_uInt16 nFlags ) if( !IsAbortingImport() ) PositionView_Impl(); - if ( GetModifyPasswordHash() && !IsModifyPasswordEntered() ) + if ( ( GetModifyPasswordHash() || GetModifyPasswordInfo().getLength() ) && !IsModifyPasswordEntered() ) SetReadOnly(); // Salvage diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 96f44169bfd0..b5a9536b12c5 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2739,7 +2739,9 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL { // it contains either a simple hash or a set of PropertyValues // TODO/LATER: the sequence of PropertyValue should replace the hash completely in future - pModifyPasswordInfoItem->GetValue() >>= nModifyPasswordHash; + sal_Int32 nMPHTmp = 0; + pModifyPasswordInfoItem->GetValue() >>= nMPHTmp; + nModifyPasswordHash = (sal_uInt32)nMPHTmp; pModifyPasswordInfoItem->GetValue() >>= aModifyPasswordInfo; } aParams->ClearItem( SID_MODIFYPASSWORDINFO ); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 08c4980881f7..1dbd3aed623f 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -83,6 +83,7 @@ #include #include #include +#include #include #include @@ -170,9 +171,10 @@ TYPEINIT1(SfxViewFrameItem, SfxPoolItem); //========================================================================= //------------------------------------------------------------------------- -static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt32 nPasswordHash ) +static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt32 nPasswordHash, const uno::Sequence< beans::PropertyValue > aInfo ) { - sal_Bool bResult = !nPasswordHash; + // TODO/LATER: In future the info should replace the direct hash completely + sal_Bool bResult = ( !nPasswordHash && !aInfo.getLength() ); OSL_ENSURE( pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ), "PasswordToModify feature is active for a filter that does not support it!" ); @@ -196,7 +198,17 @@ static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteracti xHandler->handle( rRequest ); if ( pPasswordRequest->isPassword() ) - bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pFilter->GetServiceName() ) ) == nPasswordHash ); + { + if ( aInfo.getLength() ) + { + bResult = ::comphelper::DocPasswordHelper::IsModifyPasswordCorrect( pPasswordRequest->getPasswordToModify(), aInfo ); + } + else + { + // the binary format + bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pFilter->GetServiceName() ) ) == nPasswordHash ); + } + } else bCancel = sal_True; @@ -399,11 +411,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) else { if ( pSh->IsReadOnlyMedium() - && pSh->GetModifyPasswordHash() + && ( pSh->GetModifyPasswordHash() || pSh->GetModifyPasswordInfo().getLength() ) && !pSh->IsModifyPasswordEntered() ) { ::rtl::OUString aDocumentName = INetURLObject( pMed->GetOrigURL() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); - if( !AskPasswordToModify_Impl( pMed->GetInteractionHandler(), aDocumentName, pMed->GetOrigFilter(), pSh->GetModifyPasswordHash() ) ) + if( !AskPasswordToModify_Impl( pMed->GetInteractionHandler(), aDocumentName, pMed->GetOrigFilter(), pSh->GetModifyPasswordHash(), pSh->GetModifyPasswordInfo() ) ) { // this is a read-only document, if it has "Password to modify" // the user should enter password before he can edit the document -- cgit From e7db1c97285463eb51ac171dfce38ec0c4e034d0 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 16 Jun 2010 12:31:59 +0200 Subject: mib16: #i111971# missing internal build dependencies --- basic/prj/build.lst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/basic/prj/build.lst b/basic/prj/build.lst index a41428a1ca20..b49a8ce2bcc0 100755 --- a/basic/prj/build.lst +++ b/basic/prj/build.lst @@ -2,12 +2,12 @@ sb basic : l10n offuh oovbaapi svtools xmlscript framework salhelper NULL sb basic usr1 - all sb_mkout NULL sb basic\inc nmake - all sb_inc NULL sb basic\source\app nmake - all sb_app sb_class sb_inc NULL -sb basic\source\basmgr nmake - all sb_mgr sb_inc NULL +sb basic\source\basmgr nmake - all sb_mgr sb_inc sb_class NULL sb basic\source\classes nmake - all sb_class sb_inc NULL -sb basic\source\comp nmake - all sb_comp sb_inc NULL -sb basic\source\runtime nmake - all sb_rt sb_inc NULL -sb basic\source\sample nmake - all sb_samp sb_inc NULL -sb basic\source\sbx nmake - all sb_sbx sb_inc NULL -sb basic\source\uno nmake - all sb_uno sb_inc NULL +sb basic\source\comp nmake - all sb_comp sb_inc sb_class NULL +sb basic\source\runtime nmake - all sb_rt sb_inc sb_class NULL +sb basic\source\sample nmake - all sb_samp sb_inc sb_class NULL +sb basic\source\sbx nmake - all sb_sbx sb_inc sb_class NULL +sb basic\source\uno nmake - all sb_uno sb_inc sb_class NULL sb basic\util nmake - all sb_util sb_app sb_class sb_comp sb_mgr sb_rt sb_samp sb_sbx sb_uno NULL -- cgit From 6ba182c5728c491af5a136c6b7ac1ca170e95066 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 16 Jun 2010 12:44:11 +0200 Subject: mib16: #i111971# missing internal build dependencies --- basic/prj/build.lst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/basic/prj/build.lst b/basic/prj/build.lst index b49a8ce2bcc0..c00a3d8412d3 100755 --- a/basic/prj/build.lst +++ b/basic/prj/build.lst @@ -2,12 +2,12 @@ sb basic : l10n offuh oovbaapi svtools xmlscript framework salhelper NULL sb basic usr1 - all sb_mkout NULL sb basic\inc nmake - all sb_inc NULL sb basic\source\app nmake - all sb_app sb_class sb_inc NULL -sb basic\source\basmgr nmake - all sb_mgr sb_inc sb_class NULL +sb basic\source\basmgr nmake - all sb_mgr sb_inc NULL sb basic\source\classes nmake - all sb_class sb_inc NULL -sb basic\source\comp nmake - all sb_comp sb_inc sb_class NULL +sb basic\source\comp nmake - all sb_comp sb_inc NULL sb basic\source\runtime nmake - all sb_rt sb_inc sb_class NULL -sb basic\source\sample nmake - all sb_samp sb_inc sb_class NULL -sb basic\source\sbx nmake - all sb_sbx sb_inc sb_class NULL -sb basic\source\uno nmake - all sb_uno sb_inc sb_class NULL +sb basic\source\sample nmake - all sb_samp sb_inc NULL +sb basic\source\sbx nmake - all sb_sbx sb_inc NULL +sb basic\source\uno nmake - all sb_uno sb_inc NULL sb basic\util nmake - all sb_util sb_app sb_class sb_comp sb_mgr sb_rt sb_samp sb_sbx sb_uno NULL -- cgit From 00cb4072a3052e4dca32a39fb692f34a1d7e4d35 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 16 Jun 2010 14:12:43 +0200 Subject: mib16: unxmacxi compiler warnings --- vbahelper/source/msforms/vbacontrol.cxx | 4 ++-- vbahelper/source/vbahelper/vbafontbase.cxx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index 4222e3d299d0..82b68bbd5be7 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -258,8 +258,8 @@ void SAL_CALL ScVbaControl::SetFocus() throw (uno::RuntimeException) void SAL_CALL ScVbaControl::Move( double Left, double Top, const uno::Any& Width, const uno::Any& Height ) throw ( uno::RuntimeException ) { - double nWidth; - double nHeight; + double nWidth = 0.0; + double nHeight = 0.0; setLeft( Left ); setTop( Top ); diff --git a/vbahelper/source/vbahelper/vbafontbase.cxx b/vbahelper/source/vbahelper/vbafontbase.cxx index 3e84f55ef11a..065414343bd1 100644 --- a/vbahelper/source/vbahelper/vbafontbase.cxx +++ b/vbahelper/source/vbahelper/vbafontbase.cxx @@ -127,7 +127,7 @@ VbaFontBase::setSize( const uno::Any& aValue ) throw( uno::RuntimeException ) uno::Any aVal( aValue ); if( mbFormControl ) { - float fVal; + float fVal = 0.0; aVal >>= fVal; aVal <<= static_cast< sal_Int16 >( fVal ); } -- cgit From 22dedfaadf4a53093a9ccbccbf3a70f78b1dbb06 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 16 Jun 2010 14:23:17 +0200 Subject: jl152#i112437# Disabled extensions should not show an options button --- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 4ba747198c09..d57fbdb9f4ed 100755 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -281,6 +281,8 @@ void ExtBoxWithBtns_Impl::SetButtonPos( const Rectangle& rRect ) // ----------------------------------------------------------------------- void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) { + bool bShowOptionBtn = true; + pEntry->m_bHasButtons = false; if ( ( pEntry->m_eState == REGISTERED ) || ( pEntry->m_eState == NOT_AVAILABLE ) ) { @@ -291,6 +293,7 @@ void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) { m_pEnableBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) ); m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_ENABLE ); + bShowOptionBtn = false; } if ( ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) @@ -303,7 +306,7 @@ void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) pEntry->m_bHasButtons = true; } - if ( pEntry->m_bHasOptions ) + if ( pEntry->m_bHasOptions && bShowOptionBtn ) { m_pOptionsBtn->Enable( pEntry->m_bHasOptions ); m_pOptionsBtn->Show(); -- cgit From a70f8ac0962410f6c2b5b0775bc1b410452dadad Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 16 Jun 2010 14:30:12 +0200 Subject: jpropenable: #i112445# exclude this file from l10n process --- connectivity/qa/drivers/dbase/test.properties | 1 + officecfg/registry/schema/oo-ldap-attr-map.properties | 1 + officecfg/registry/schema/oo-org-map.properties | 1 + .../org/openoffice/netbeans/modules/office/filesystem/Bundle.properties | 1 + .../java/org/openoffice/netbeans/modules/office/loader/Bundle.properties | 1 + .../org/openoffice/netbeans/modules/office/options/Bundle.properties | 1 + .../org/openoffice/netbeans/modules/office/resources/Bundle.properties | 1 + .../java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties | 1 + 8 files changed, 8 insertions(+) diff --git a/connectivity/qa/drivers/dbase/test.properties b/connectivity/qa/drivers/dbase/test.properties index 6f301f972d40..c26879f480f3 100644 --- a/connectivity/qa/drivers/dbase/test.properties +++ b/connectivity/qa/drivers/dbase/test.properties @@ -1,3 +1,4 @@ +# x-no-translate Driver=org.openoffice.comp.drivers.MySQL.Driver user=testuser password= diff --git a/officecfg/registry/schema/oo-ldap-attr-map.properties b/officecfg/registry/schema/oo-ldap-attr-map.properties index c67cd5262fd4..684dfbdebfa3 100644 --- a/officecfg/registry/schema/oo-ldap-attr-map.properties +++ b/officecfg/registry/schema/oo-ldap-attr-map.properties @@ -1,4 +1,5 @@ # inetOrgPerson.givenName +# x-no-translate org.openoffice.UserProfile/Data/givenname = givenname # person.sn diff --git a/officecfg/registry/schema/oo-org-map.properties b/officecfg/registry/schema/oo-org-map.properties index 1f4b4377677c..dc87a4346ce9 100644 --- a/officecfg/registry/schema/oo-org-map.properties +++ b/officecfg/registry/schema/oo-org-map.properties @@ -1,5 +1,6 @@ # attribute and objectclass identifying a user # multi values are supported, separated by comma +# x-no-translate User/ObjectClass=inetorgperson User/NamingAttribute=uid User/Container=ou=People diff --git a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties index 3137b89dde94..f776ff9e7933 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties @@ -1,5 +1,6 @@ # Filesystems API # {0} - root path +# x-no-translate LAB_invalid_file_system=invalid OpenOffice.org document {0} # {0} - root path LAB_valid_file_system={0} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties index a3bf47447607..eab2fa1f3fbc 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties @@ -3,6 +3,7 @@ #HINT_myProp= #LBL_DataNode_exec_sheet=Execution #HINT_DataNode_exec_sheet=Properties pertaining to compiling, running, and debugging. +# x-no-translate LBL_loaderName= # Datasystems API #PROP_myProp= diff --git a/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties index b823204cb227..6a9112e8c768 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties @@ -1,4 +1,5 @@ # Options API +# x-no-translate LBL_settings=Office Settings PROP_OfficeDirectory=Path to Office installation HINT_OfficeDirectory=Path to the Office installation diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties index 58989c2506b7..22aea6525f3d 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties @@ -1,3 +1,4 @@ +# x-no-translate Templates/OfficeScripting=Office Scripting Templates/OfficeScripting/parcel.xml=Script Parcel Descriptor Services/MIMEResolver/org-netbeans-modules-office-mime-resolver.xml=Script Parcel Descriptor File diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties index 0e4f2bd100c7..a40b4b373959 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties @@ -1,4 +1,5 @@ # Window System API +# x-no-translate # TopComponent LBL_component_name= -- cgit From ea0e9744690e2c3e75ab6b1eee1f57d94ceca5aa Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Thu, 17 Jun 2010 16:33:20 +0800 Subject: findbarfixes01: #112235# [A11Y] Text in Find toolbar text field has wrong colour in High Contrast mode --- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index f4f03170a90f..889bf63459bd 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -92,7 +92,7 @@ FindTextFieldControl::~FindTextFieldControl() void FindTextFieldControl::InitControls_Impl() { SetText( String( ::rtl::OUString::createFromAscii("Find") ) ); - SetControlForeground(COL_GRAY); + SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor()); EnableAutocomplete(TRUE, TRUE); } @@ -117,7 +117,7 @@ void FindTextFieldControl::Modify() { ComboBox::Modify(); - SetControlForeground( Color( COL_BLACK ) ); + SetControlForeground( GetSettings().GetStyleSettings().GetWindowTextColor() ); } long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) @@ -171,7 +171,7 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) if ( GetText().Len() == 0 ) { SetText( String( ::rtl::OUString::createFromAscii("Find") ) ); - SetControlForeground(COL_GRAY); + SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor()); m_bToClearTextField = sal_True; } break; -- cgit From f288b50cef4d2a13cfb100af3a71f14b171d066a Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 17 Jun 2010 14:26:43 +0200 Subject: #i112245# 1st part for SvtGraphicStroke --- .../drawinglayer/primitive2d/chartprimitive2d.hxx | 2 +- .../primitive2d/drawinglayer_primitivetypes2d.hxx | 2 +- .../primitive2d/embedded3dprimitive2d.hxx | 2 +- .../primitive2d/helplineprimitive2d.hxx | 4 +- .../primitive2d/polygonprimitive2d.hxx | 2 +- .../primitive2d/polypolygonprimitive2d.hxx | 6 +- .../drawinglayer/primitive2d/sceneprimitive2d.hxx | 2 +- .../primitive2d/textdecoratedprimitive2d.hxx | 4 +- .../source/primitive2d/structuretagprimitive2d.cxx | 2 +- .../source/processor2d/vclmetafileprocessor2d.cxx | 192 +++++++++++---------- 10 files changed, 111 insertions(+), 107 deletions(-) diff --git a/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx index bd8c3be1fbbd..71c4cc6ffe1e 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx @@ -56,7 +56,7 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rTransformation, const Primitive2DSequence& rChildren); - // get data + /// data read access const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& getChartModel() const { return mxChartModel; } const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 7872ad825496..c60257551c28 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -90,7 +90,7 @@ #define PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 47) #define PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 48) #define PRIMITIVE2D_ID_CHARTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 49) -#define PRIMITIVE2D_ID_STRUCTURETAGRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 50) +#define PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 50) #define PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 51) #define PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 52) #define PRIMITIVE2D_ID_INVERTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 53) diff --git a/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx index ce49995c999d..d651af24047d 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx @@ -101,7 +101,7 @@ namespace drawinglayer double fShadowSlant, const basegfx::B3DRange& rScene3DRange); - /// get data + /// data read access const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; } const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx index 237ae00a4642..e2323765b2e5 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx @@ -94,8 +94,8 @@ namespace drawinglayer double fDiscreteDashLength); /// data read access - const basegfx::B2DPoint getPosition() const { return maPosition; } - const basegfx::B2DVector getDirection() const { return maDirection; } + const basegfx::B2DPoint& getPosition() const { return maPosition; } + const basegfx::B2DVector& getDirection() const { return maDirection; } HelplineStyle2D getStyle() const { return meStyle; } const basegfx::BColor& getRGBColA() const { return maRGBColA; } const basegfx::BColor& getRGBColB() const { return maRGBColB; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx index 80e281ede05c..ee5de781be86 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx @@ -189,7 +189,7 @@ namespace drawinglayer const attribute::LineAttribute& rLineAttribute); /// data read access - basegfx::B2DPolygon getB2DPolygon() const { return maPolygon; } + const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; } const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx index 18743937b6bc..4a48ae0d3e59 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx @@ -69,7 +69,7 @@ namespace drawinglayer PolyPolygonHairlinePrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBColor); /// data read access - basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const basegfx::BColor& getBColor() const { return maBColor; } /// compare operator @@ -123,7 +123,7 @@ namespace drawinglayer double fDiscreteDashLength); // data read access - basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const basegfx::BColor& getRGBColorA() const { return maRGBColorA; } const basegfx::BColor& getRGBColorB() const { return maRGBColorB; } double getDiscreteDashLength() const { return mfDiscreteDashLength; } @@ -182,7 +182,7 @@ namespace drawinglayer const attribute::LineAttribute& rLineAttribute); /// data read access - basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx index 4c95972ca67d..278a1b0bfff2 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx @@ -136,7 +136,7 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rObjectTransformation, const geometry::ViewInformation3D& rViewInformation3D); - /// data ead access + /// data read access const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; } const attribute::SdrSceneAttribute& getSdrSceneAttribute() const { return maSdrSceneAttribute; } const attribute::SdrLightingAttribute& getSdrLightingAttribute() const { return maSdrLightingAttribute; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx index 6ae691cbcff9..5c1093bc333a 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx @@ -129,8 +129,8 @@ namespace drawinglayer TextStrikeout getTextStrikeout() const { return meTextStrikeout; } TextEmphasisMark getTextEmphasisMark() const { return meTextEmphasisMark; } TextRelief getTextRelief() const { return meTextRelief; } - basegfx::BColor getOverlineColor() const { return maOverlineColor; } - basegfx::BColor getTextlineColor() const { return maTextlineColor; } + const basegfx::BColor& getOverlineColor() const { return maOverlineColor; } + const basegfx::BColor& getTextlineColor() const { return maTextlineColor; } bool getUnderlineAbove() const { return mbUnderlineAbove; } bool getWordLineMode() const { return mbWordLineMode; } bool getEmphasisMarkAbove() const { return mbEmphasisMarkAbove; } diff --git a/drawinglayer/source/primitive2d/structuretagprimitive2d.cxx b/drawinglayer/source/primitive2d/structuretagprimitive2d.cxx index 0ead7302ba38..8adcb6a10b82 100644 --- a/drawinglayer/source/primitive2d/structuretagprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/structuretagprimitive2d.cxx @@ -50,7 +50,7 @@ namespace drawinglayer } // provide unique ID - ImplPrimitrive2DIDBlock(StructureTagPrimitive2D, PRIMITIVE2D_ID_STRUCTURETAGRIMITIVE2D) + ImplPrimitrive2DIDBlock(StructureTagPrimitive2D, PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D) } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 0bc1b57113b8..68ca424cca78 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -982,26 +982,69 @@ namespace drawinglayer } case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D : { - // direct draw of hairline; use default processing - // also support SvtGraphicStroke MetaCommentAction const primitive2d::PolygonHairlinePrimitive2D& rHairlinePrimitive = static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate); - const basegfx::BColor aLineColor(maBColorModifierStack.getModifiedColor(rHairlinePrimitive.getBColor())); - SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke(rHairlinePrimitive.getB2DPolygon(), &aLineColor, 0, 0, 0, 0); + const basegfx::B2DPolygon& rBasePolygon = rHairlinePrimitive.getB2DPolygon(); - impStartSvtGraphicStroke(pSvtGraphicStroke); - RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate), false); - impEndSvtGraphicStroke(pSvtGraphicStroke); + if(rBasePolygon.count() > (0x0000ffff - 1)) + { + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. If there are more, split the polygon in half and call recursively + const sal_uInt32 nCount(rBasePolygon.count()); + const sal_uInt32 nHalfCount((nCount - 1) >> 1); + const basegfx::B2DPolygon aLeft(rBasePolygon, 0, nHalfCount + 1); + const basegfx::B2DPolygon aRight(rBasePolygon, nHalfCount, nCount - nHalfCount); + const primitive2d::PolygonHairlinePrimitive2D aPLeft(aLeft, rHairlinePrimitive.getBColor()); + const primitive2d::PolygonHairlinePrimitive2D aPRight(aRight, rHairlinePrimitive.getBColor()); + + processBasePrimitive2D(aPLeft); + processBasePrimitive2D(aPRight); + } + else + { + // direct draw of hairline; use default processing + // support SvtGraphicStroke MetaCommentAction + const basegfx::BColor aLineColor(maBColorModifierStack.getModifiedColor(rHairlinePrimitive.getBColor())); + SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke( + rHairlinePrimitive.getB2DPolygon(), + &aLineColor, + 0, 0, 0, 0); + + impStartSvtGraphicStroke(pSvtGraphicStroke); + RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate), false); + impEndSvtGraphicStroke(pSvtGraphicStroke); + } break; } case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D : { - // support SvtGraphicStroke MetaCommentAction const primitive2d::PolygonStrokePrimitive2D& rStrokePrimitive = static_cast< const primitive2d::PolygonStrokePrimitive2D& >(rCandidate); - SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke(rStrokePrimitive.getB2DPolygon(), 0, &rStrokePrimitive.getLineAttribute(), - &rStrokePrimitive.getStrokeAttribute(), 0, 0); + const basegfx::B2DPolygon& rBasePolygon = rStrokePrimitive.getB2DPolygon(); - if(true) + if(rBasePolygon.count() > (0x0000ffff - 1)) { + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. If there are more, split the polygon in half and call recursively + const sal_uInt32 nCount(rBasePolygon.count()); + const sal_uInt32 nHalfCount((nCount - 1) >> 1); + const basegfx::B2DPolygon aLeft(rBasePolygon, 0, nHalfCount + 1); + const basegfx::B2DPolygon aRight(rBasePolygon, nHalfCount, nCount - nHalfCount); + const primitive2d::PolygonStrokePrimitive2D aPLeft( + aLeft, rStrokePrimitive.getLineAttribute(), rStrokePrimitive.getStrokeAttribute()); + const primitive2d::PolygonStrokePrimitive2D aPRight( + aRight, rStrokePrimitive.getLineAttribute(), rStrokePrimitive.getStrokeAttribute()); + + processBasePrimitive2D(aPLeft); + processBasePrimitive2D(aPRight); + } + else + { + // support SvtGraphicStroke MetaCommentAction + SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke( + rBasePolygon, 0, + &rStrokePrimitive.getLineAttribute(), + &rStrokePrimitive.getStrokeAttribute(), + 0, 0); + impStartSvtGraphicStroke(pSvtGraphicStroke); const attribute::LineAttribute& rLine = rStrokePrimitive.getLineAttribute(); @@ -1013,12 +1056,12 @@ namespace drawinglayer if(0.0 == rStroke.getFullDotDashLen()) { - aHairLinePolyPolygon.append(rStrokePrimitive.getB2DPolygon()); + aHairLinePolyPolygon.append(rBasePolygon); } else { basegfx::tools::applyLineDashing( - rStrokePrimitive.getB2DPolygon(), rStroke.getDotDashArray(), + rBasePolygon, rStroke.getDotDashArray(), &aHairLinePolyPolygon, 0, rStroke.getFullDotDashLen()); } @@ -1048,93 +1091,54 @@ namespace drawinglayer impEndSvtGraphicStroke(pSvtGraphicStroke); } - else - { - // Adapt OutDev's DrawMode if special ones were used - const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); - adaptLineToFillDrawMode(); - - impStartSvtGraphicStroke(pSvtGraphicStroke); - - // #i101491# - // Change default of fat line generation for MetaFiles: Create MetaPolyLineAction - // instead of decomposing all geometries when the polygon has more than given amount of - // points; else the decomposition will get too expensive quiclky. OTOH - // the decomposition provides the better quality e.g. taking edge roundings - // into account which will NOT be taken into account with LineInfo-based actions - const sal_uInt32 nSubPolygonCount(rStrokePrimitive.getB2DPolygon().count()); - bool bDone(0 == nSubPolygonCount); - - if(!bDone && nSubPolygonCount > 1000) - { - // create MetaPolyLineActions, but without LINE_DASH - const attribute::LineAttribute& rLine = rStrokePrimitive.getLineAttribute(); - - if(basegfx::fTools::more(rLine.getWidth(), 0.0)) - { - const attribute::StrokeAttribute& rStroke = rStrokePrimitive.getStrokeAttribute(); - basegfx::B2DPolyPolygon aHairLinePolyPolygon; - - if(0.0 == rStroke.getFullDotDashLen()) - { - aHairLinePolyPolygon.append(rStrokePrimitive.getB2DPolygon()); - } - else - { - basegfx::tools::applyLineDashing( - rStrokePrimitive.getB2DPolygon(), rStroke.getDotDashArray(), - &aHairLinePolyPolygon, 0, rStroke.getFullDotDashLen()); - } - - const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLine.getColor())); - mpOutputDevice->SetLineColor(Color(aHairlineColor)); - mpOutputDevice->SetFillColor(); - - aHairLinePolyPolygon.transform(maCurrentTransformation); - - const LineInfo aLineInfo(LINE_SOLID, basegfx::fround(rLine.getWidth())); - - for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++) - { - const basegfx::B2DPolygon aCandidate(aHairLinePolyPolygon.getB2DPolygon(a)); - - if(aCandidate.count() > 1) - { - const Polygon aToolsPolygon(aCandidate); - - mpMetaFile->AddAction(new MetaPolyLineAction(aToolsPolygon, aLineInfo)); - } - } - - bDone = true; - } - } - - if(!bDone) - { - // use decomposition (creates line geometry as filled polygon - // geometry) - process(rCandidate.get2DDecomposition(getViewInformation2D())); - } - - impEndSvtGraphicStroke(pSvtGraphicStroke); - - // restore DrawMode - mpOutputDevice->SetDrawMode(nOriginalDrawMode); - } break; } case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D : { - // support SvtGraphicStroke MetaCommentAction const primitive2d::PolygonStrokeArrowPrimitive2D& rStrokeArrowPrimitive = static_cast< const primitive2d::PolygonStrokeArrowPrimitive2D& >(rCandidate); - SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke(rStrokeArrowPrimitive.getB2DPolygon(), 0, &rStrokeArrowPrimitive.getLineAttribute(), - &rStrokeArrowPrimitive.getStrokeAttribute(), &rStrokeArrowPrimitive.getStart(), &rStrokeArrowPrimitive.getEnd()); + const basegfx::B2DPolygon& rBasePolygon = rStrokeArrowPrimitive.getB2DPolygon(); + + if(rBasePolygon.count() > (0x0000ffff - 1)) + { + // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points + // per polygon. If there are more, split the polygon in half and call recursively + const sal_uInt32 nCount(rBasePolygon.count()); + const sal_uInt32 nHalfCount((nCount - 1) >> 1); + const basegfx::B2DPolygon aLeft(rBasePolygon, 0, nHalfCount + 1); + const basegfx::B2DPolygon aRight(rBasePolygon, nHalfCount, nCount - nHalfCount); + const attribute::LineStartEndAttribute aEmpty; + const primitive2d::PolygonStrokeArrowPrimitive2D aPLeft( + aLeft, + rStrokeArrowPrimitive.getLineAttribute(), + rStrokeArrowPrimitive.getStrokeAttribute(), + rStrokeArrowPrimitive.getStart(), + aEmpty); + const primitive2d::PolygonStrokeArrowPrimitive2D aPRight( + aRight, + rStrokeArrowPrimitive.getLineAttribute(), + rStrokeArrowPrimitive.getStrokeAttribute(), + aEmpty, + rStrokeArrowPrimitive.getEnd()); + + processBasePrimitive2D(aPLeft); + processBasePrimitive2D(aPRight); + } + else + { + // support SvtGraphicStroke MetaCommentAction + SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke( + rBasePolygon, 0, + &rStrokeArrowPrimitive.getLineAttribute(), + &rStrokeArrowPrimitive.getStrokeAttribute(), + &rStrokeArrowPrimitive.getStart(), + &rStrokeArrowPrimitive.getEnd()); + + impStartSvtGraphicStroke(pSvtGraphicStroke); + process(rCandidate.get2DDecomposition(getViewInformation2D())); + impEndSvtGraphicStroke(pSvtGraphicStroke); + } - impStartSvtGraphicStroke(pSvtGraphicStroke); - process(rCandidate.get2DDecomposition(getViewInformation2D())); - impEndSvtGraphicStroke(pSvtGraphicStroke); break; } case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : @@ -1780,7 +1784,7 @@ namespace drawinglayer } break; } - case PRIMITIVE2D_ID_STRUCTURETAGRIMITIVE2D : + case PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D : { // structured tag primitive const primitive2d::StructureTagPrimitive2D& rStructureTagCandidate = static_cast< const primitive2d::StructureTagPrimitive2D& >(rCandidate); -- cgit From 1a639c734cec2dfce0a4efe2fecdeeddbbc9b441 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 17 Jun 2010 16:09:17 +0200 Subject: mib16: compiler warning (debug only) --- basic/source/runtime/runtime.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 1ace790f8aee..c3419adbfdb3 100755 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -907,7 +907,7 @@ sal_Int32 SbiRuntime::translateErrorToVba( SbError nError, String& rMsg ) { // TEST, has to be vb here always #ifdef DBG_UTIL - SbError nTmp = StarBASIC::GetSfxFromVBError( nError ); + SbError nTmp = StarBASIC::GetSfxFromVBError( (USHORT)nError ); DBG_ASSERT( nTmp, "No VB error!" ); #endif -- cgit From cc7090d4a96f70b56920302a48895100a0d7c671 Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Thu, 17 Jun 2010 16:10:42 +0200 Subject: #i97336# check if text shape actually has text --- svx/source/sdr/properties/textproperties.cxx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx index 348c319e256e..091656e1f261 100644 --- a/svx/source/sdr/properties/textproperties.cxx +++ b/svx/source/sdr/properties/textproperties.cxx @@ -185,18 +185,21 @@ namespace sdr { SdrText* pText = rObj.getText( nCount ); OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject(); - rOutliner.SetText(*pParaObj); - sal_uInt32 nParaCount(rOutliner.GetParagraphCount()); - - if(nParaCount) + if( pParaObj ) { - ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL); - rOutliner.RemoveAttribs(aSelection, sal_True, 0); + rOutliner.SetText(*pParaObj); + sal_uInt32 nParaCount(rOutliner.GetParagraphCount()); - OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount); - rOutliner.Clear(); + if(nParaCount) + { + ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL); + rOutliner.RemoveAttribs(aSelection, sal_True, 0); - rObj.NbcSetOutlinerParaObjectForText( pTemp, pText ); + OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount); + rOutliner.Clear(); + + rObj.NbcSetOutlinerParaObjectForText( pTemp, pText ); + } } } } -- cgit From 7d9bce7ca0408786d0ad448dee0f2bf480870d3e Mon Sep 17 00:00:00 2001 From: sb Date: Thu, 17 Jun 2010 16:30:50 +0200 Subject: jl153: #i110720# ignore spurious elements in .xcu set nodes --- configmgr/source/xcuparser.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx index eda478b18b70..cd1e6e55d085 100644 --- a/configmgr/source/xcuparser.cxx +++ b/configmgr/source/xcuparser.cxx @@ -196,6 +196,14 @@ bool XcuParser::startElement( { handleSetNode( reader, dynamic_cast< SetNode * >(state_.top().node.get())); + } else if (ns == XmlReader::NAMESPACE_NONE && + name.equals(RTL_CONSTASCII_STRINGPARAM("prop"))) + { + OSL_TRACE( + "configmgr bad set node member in %s", + rtl::OUStringToOString( + reader.getUrl(), RTL_TEXTENCODING_UTF8).getStr()); + state_.push(State(true)); // ignored } else { throw css::uno::RuntimeException( (rtl::OUString( -- cgit From a03b1ebebf434ff1fe71cd83b8ac31a7b699296b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 18 Jun 2010 08:50:11 +0100 Subject: gtkfpicker9: #i112386# gdk_threads_add_timeout_full unavailable on older glibs --- fpicker/source/unx/gnome/SalGtkPicker.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpicker/source/unx/gnome/SalGtkPicker.cxx b/fpicker/source/unx/gnome/SalGtkPicker.cxx index 8bd28bb22d29..1a685e0981e6 100644 --- a/fpicker/source/unx/gnome/SalGtkPicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkPicker.cxx @@ -175,7 +175,7 @@ void SAL_CALL RunDialog::windowOpened( const ::com::sun::star::lang::EventObject throw (::com::sun::star::uno::RuntimeException) { GdkThreadLock aLock; - gdk_threads_add_timeout_full(G_PRIORITY_HIGH_IDLE, 0, (GSourceFunc)canceldialog, this, NULL); + g_timeout_add_full(G_PRIORITY_HIGH_IDLE, 0, (GSourceFunc)canceldialog, this, NULL); } void RunDialog::cancel() -- cgit From f5dca43c9a814b8955edf6968443737e521162dc Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Fri, 18 Jun 2010 15:27:12 +0200 Subject: #i102353# correct page number and page count field when printing handouts --- svx/inc/svx/svdmodel.hxx | 6 +++++- svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx | 12 ++++++++++-- svx/source/svdraw/svdmodel.cxx | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx index fc8d401f94e7..328efedd98f0 100644 --- a/svx/inc/svx/svdmodel.hxx +++ b/svx/inc/svx/svdmodel.hxx @@ -276,7 +276,7 @@ public: SdrOutlinerCache* mpOutlinerCache; SdrModelImpl* mpImpl; UINT16 mnCharCompressType; - UINT16 nReserveUInt5; + UINT16 mnHandoutPageCount; UINT16 nReserveUInt6; UINT16 nReserveUInt7; FASTBOOL mbModelLocked; @@ -298,6 +298,10 @@ public: SvNumberFormatter* mpNumberFormatter; public: const SvNumberFormatter& GetNumberFormatter() const; + + UINT16 getHandoutPageCount() const { return mnHandoutPageCount; } + void setHandoutPageCount( UINT16 nHandoutPageCount ) { mnHandoutPageCount = nHandoutPageCount; } + protected: virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel(); diff --git a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx index 2320944afd03..089f75aa8ade 100644 --- a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx @@ -77,8 +77,16 @@ namespace if(pPage && pPage->GetModel()) { - const sal_uInt16 nPageCount(pPage->GetModel()->GetPageCount()); - nRetval = ((sal_Int16)nPageCount - 1) / 2; + if( (pPage->GetPageNum() == 0) && !pPage->IsMasterPage() ) + { + // handout page! + return pPage->GetModel()->getHandoutPageCount(); + } + else + { + const sal_uInt16 nPageCount(pPage->GetModel()->GetPageCount()); + nRetval = ((sal_Int16)nPageCount - 1) / 2; + } } return nRetval; diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 2fcdfdffbb8a..8ab385fa329c 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -178,6 +178,7 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe mpOutlinerCache = NULL; mbKernAsianPunctuation = sal_False; mbAddExtLeading = sal_False; + mnHandoutPageCount = 0; SvxAsianConfig aAsian; mnCharCompressType = aAsian.GetCharDistanceCompression(); -- cgit From da6b240a3fdc74b2811c229a7f8eff8307c6c256 Mon Sep 17 00:00:00 2001 From: tono Date: Fri, 18 Jun 2010 22:43:04 +0900 Subject: Backed out changeset: d80a58fd55d9 --- desktop/source/pkgchk/unopkg/makefile.mk | 4 ++-- framework/util/makefile.mk | 8 ++++---- svx/util/makefile.mk | 2 +- vbahelper/util/makefile.mk | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/desktop/source/pkgchk/unopkg/makefile.mk b/desktop/source/pkgchk/unopkg/makefile.mk index 0cefee98634e..729548cbadd1 100644 --- a/desktop/source/pkgchk/unopkg/makefile.mk +++ b/desktop/source/pkgchk/unopkg/makefile.mk @@ -49,7 +49,7 @@ CFLAGS+=-DSYSTEM_DB -I$(DB_INCLUDES) APP1TARGET = so$/unopkg APP1OBJS = $(OBJFILES) APP1STDLIBS = $(SALLIB) $(UNOPKGAPPLIB) -.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" APP1DEPN = $(SHL1TARGETN) .ELSE APP1DEPN = $(SHL1IMPLIBN) @@ -65,7 +65,7 @@ APP1LINKRES = $(MISC)$/$(TARGET)1.res APP2TARGET = unopkg APP2OBJS = $(OBJFILES) APP2STDLIBS = $(SALLIB) $(UNOPKGAPPLIB) -.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" APP2DEPN = $(SHL1TARGETN) .ELSE APP2DEPN = $(SHL1IMPLIBN) diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk index ab0513fccece..08218b6267b3 100644 --- a/framework/util/makefile.mk +++ b/framework/util/makefile.mk @@ -158,7 +158,7 @@ SHL2STDLIBS= \ $(SALLIB) SHL2DEF= $(MISC)$/$(SHL2TARGET).def -.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL2DEPN= $(SHL1TARGETN) .ELSE SHL2DEPN= $(SHL1IMPLIBN) @@ -218,7 +218,7 @@ SHL3STDLIBS= \ $(SALLIB) SHL3DEF= $(MISC)$/$(SHL3TARGET).def -.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL3DEPN= $(SHL1TARGETN) $(SHL2TARGETN) .ELSE SHL3DEPN= $(SHL1IMPLIBN) $(SHL2IMPLIBN) @@ -363,7 +363,7 @@ SHL4STDLIBS= \ $(I18NISOLANGLIB) SHL4DEF= $(MISC)$/$(SHL4TARGET).def -.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL4DEPN= $(SHL1TARGETN) $(SHL2TARGETN) .ELSE SHL4DEPN= $(SHL1IMPLIBN) $(SHL2IMPLIBN) @@ -398,7 +398,7 @@ SHL5STDLIBS= \ $(SALLIB) SHL5DEF= $(MISC)$/$(SHL5TARGET).def -.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL5DEPN= $(SHL1TARGETN) .ELSE SHL5DEPN= $(SHL1IMPLIBN) diff --git a/svx/util/makefile.mk b/svx/util/makefile.mk index eeb1ee3dbcec..5ee482e6ac82 100644 --- a/svx/util/makefile.mk +++ b/svx/util/makefile.mk @@ -104,7 +104,7 @@ DEFLIB1NAME=$(SHL1LIBS:b) SHL2TARGET= svx$(DLLPOSTFIX) SHL2IMPLIB= i$(TARGET) SHL2USE_EXPORTS=name -.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL2DEPN=$(SHL1TARGETN) .ELSE SHL2DEPN=$(SHL1IMPLIBN) diff --git a/vbahelper/util/makefile.mk b/vbahelper/util/makefile.mk index 5f6bfa4967f9..54a17873cf94 100644 --- a/vbahelper/util/makefile.mk +++ b/vbahelper/util/makefile.mk @@ -96,7 +96,7 @@ SHL2STDLIBS= \ $(TKLIB) \ $(BASICLIB) \ -.IF "$(GUI)"=="UNX" || ("$(COM)"=="GCC" && "$(GUI)"=="WNT") +.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL2DEPN=$(SHL1TARGETN) .ELSE SHL2DEPN=$(SHL1IMPLIBN) -- cgit From 6517b485af245f10d821c6823204bb67b66f5ef9 Mon Sep 17 00:00:00 2001 From: tono Date: Fri, 18 Jun 2010 22:49:15 +0900 Subject: Backed out changeset: f63af3433bcb --- desktop/source/pkgchk/unopkg/makefile.mk | 8 -------- framework/util/makefile.mk | 24 ++++-------------------- svx/util/makefile.mk | 4 ---- vbahelper/util/makefile.mk | 4 ---- 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/desktop/source/pkgchk/unopkg/makefile.mk b/desktop/source/pkgchk/unopkg/makefile.mk index 729548cbadd1..8384f1b24372 100644 --- a/desktop/source/pkgchk/unopkg/makefile.mk +++ b/desktop/source/pkgchk/unopkg/makefile.mk @@ -49,11 +49,7 @@ CFLAGS+=-DSYSTEM_DB -I$(DB_INCLUDES) APP1TARGET = so$/unopkg APP1OBJS = $(OBJFILES) APP1STDLIBS = $(SALLIB) $(UNOPKGAPPLIB) -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" APP1DEPN = $(SHL1TARGETN) -.ELSE -APP1DEPN = $(SHL1IMPLIBN) -.ENDIF APP1NOSAL = TRUE APP1RPATH = BRAND .IF "$(OS)" == "WNT" @@ -65,11 +61,7 @@ APP1LINKRES = $(MISC)$/$(TARGET)1.res APP2TARGET = unopkg APP2OBJS = $(OBJFILES) APP2STDLIBS = $(SALLIB) $(UNOPKGAPPLIB) -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" APP2DEPN = $(SHL1TARGETN) -.ELSE -APP2DEPN = $(SHL1IMPLIBN) -.ENDIF APP2NOSAL = TRUE APP2RPATH = BRAND .IF "$(OS)" == "WNT" diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk index 08218b6267b3..b1b7c691d29f 100644 --- a/framework/util/makefile.mk +++ b/framework/util/makefile.mk @@ -158,11 +158,7 @@ SHL2STDLIBS= \ $(SALLIB) SHL2DEF= $(MISC)$/$(SHL2TARGET).def -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" -SHL2DEPN= $(SHL1TARGETN) -.ELSE -SHL2DEPN= $(SHL1IMPLIBN) -.ENDIF +SHL2DEPN= $(SHL1IMPLIBN) $(SHL1TARGETN) DEF2NAME= $(SHL2TARGET) @@ -218,11 +214,7 @@ SHL3STDLIBS= \ $(SALLIB) SHL3DEF= $(MISC)$/$(SHL3TARGET).def -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" -SHL3DEPN= $(SHL1TARGETN) $(SHL2TARGETN) -.ELSE -SHL3DEPN= $(SHL1IMPLIBN) $(SHL2IMPLIBN) -.ENDIF +SHL3DEPN= $(SHL1IMPLIBN) $(SHL1TARGETN) $(SHL2TARGETN) DEF3NAME= $(SHL3TARGET) @@ -363,11 +355,7 @@ SHL4STDLIBS= \ $(I18NISOLANGLIB) SHL4DEF= $(MISC)$/$(SHL4TARGET).def -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" -SHL4DEPN= $(SHL1TARGETN) $(SHL2TARGETN) -.ELSE -SHL4DEPN= $(SHL1IMPLIBN) $(SHL2IMPLIBN) -.ENDIF +SHL4DEPN= $(SHL1IMPLIBN) $(SHL1TARGETN) $(SHL2IMPLIBN) $(SHL2TARGETN) DEF4NAME= $(SHL4TARGET) @@ -398,11 +386,7 @@ SHL5STDLIBS= \ $(SALLIB) SHL5DEF= $(MISC)$/$(SHL5TARGET).def -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" -SHL5DEPN= $(SHL1TARGETN) -.ELSE -SHL5DEPN= $(SHL1IMPLIBN) -.ENDIF +SHL5DEPN= $(SHL1IMPLIBN) $(SHL1TARGETN) DEF5NAME= $(SHL5TARGET) diff --git a/svx/util/makefile.mk b/svx/util/makefile.mk index 5ee482e6ac82..0006fa2ff5fe 100644 --- a/svx/util/makefile.mk +++ b/svx/util/makefile.mk @@ -104,11 +104,7 @@ DEFLIB1NAME=$(SHL1LIBS:b) SHL2TARGET= svx$(DLLPOSTFIX) SHL2IMPLIB= i$(TARGET) SHL2USE_EXPORTS=name -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL2DEPN=$(SHL1TARGETN) -.ELSE -SHL2DEPN=$(SHL1IMPLIBN) -.ENDIF SHL2LIBS= \ $(SLB)$/svdraw.lib \ diff --git a/vbahelper/util/makefile.mk b/vbahelper/util/makefile.mk index 54a17873cf94..dda4be0cbc81 100644 --- a/vbahelper/util/makefile.mk +++ b/vbahelper/util/makefile.mk @@ -96,11 +96,7 @@ SHL2STDLIBS= \ $(TKLIB) \ $(BASICLIB) \ -.IF ("$(GUI)"=="UNX" || "$(COM)"=="GCC") && "$(GUI)"!="OS2" SHL2DEPN=$(SHL1TARGETN) -.ELSE -SHL2DEPN=$(SHL1IMPLIBN) -.ENDIF SHL2LIBS=$(SLB)$/$(TARGET_MSFORMS).lib # --- Targets ----------------------------------------------------------- -- cgit From 94b9ce9272f17c7c2412eaba99771e782a463d1e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 18 Jun 2010 16:36:34 +0200 Subject: sb123: #i112473# RDFaExportHelper: don't use SvXMLExport::GetRelativeReference() --- xmloff/source/core/RDFaExportHelper.cxx | 37 ++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/xmloff/source/core/RDFaExportHelper.cxx b/xmloff/source/core/RDFaExportHelper.cxx index 593e2d1f29e6..f603d21258fd 100644 --- a/xmloff/source/core/RDFaExportHelper.cxx +++ b/xmloff/source/core/RDFaExportHelper.cxx @@ -37,6 +37,8 @@ #include #include +#include +#include #include #include #include @@ -85,6 +87,39 @@ makeCURIE(SvXMLExport * i_pExport, return buf.makeStringAndClear(); } +// #i112473# SvXMLExport::GetRelativeReference() not right for RDF on SaveAs +// because the URIs in the repository are not rewritten on SaveAs, the +// URI of the loaded document has to be used, not the URI of the target doc. +static ::rtl::OUString +getRelativeReference(SvXMLExport const& rExport, ::rtl::OUString const& rURI) +{ + uno::Reference< rdf::XURI > const xModelURI( + rExport.GetModel(), uno::UNO_QUERY_THROW ); + ::rtl::OUString const baseURI( xModelURI->getStringValue() ); + + uno::Reference const xContext( + rExport.GetComponentContext()); + uno::Reference const xServiceFactory( + xContext->getServiceManager(), uno::UNO_SET_THROW); + uno::Reference const xUriFactory( + xServiceFactory->createInstanceWithContext( + ::rtl::OUString::createFromAscii( + "com.sun.star.uri.UriReferenceFactory"), xContext), + uno::UNO_QUERY_THROW); + + uno::Reference< uri::XUriReference > const xBaseURI( + xUriFactory->parse(baseURI), uno::UNO_SET_THROW ); + uno::Reference< uri::XUriReference > const xAbsoluteURI( + xUriFactory->parse(rURI), uno::UNO_SET_THROW ); + uno::Reference< uri::XUriReference > const xRelativeURI( + xUriFactory->makeRelative(xBaseURI, xAbsoluteURI, true, true, false), + uno::UNO_SET_THROW ); + ::rtl::OUString const relativeURI(xRelativeURI->getUriReference()); + + return relativeURI; +} + + //////////////////////////////////////////////////////////////////////////// RDFaExportHelper::RDFaExportHelper(SvXMLExport & i_rExport) @@ -145,7 +180,7 @@ RDFaExportHelper::AddRDFa( static const sal_Unicode s_OpenBracket ('['); static const sal_Unicode s_CloseBracket(']'); const ::rtl::OUString about( xSubjectURI.is() - ? m_rExport.GetRelativeReference(xSubjectURI->getStringValue()) + ? getRelativeReference(m_rExport, xSubjectURI->getStringValue()) : ::rtl::OUStringBuffer().append(s_OpenBracket).append( LookupBlankNode(xSubjectBNode)).append(s_CloseBracket) .makeStringAndClear() -- cgit From 1601a33ae631de893be783ce005b318590561827 Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Tue, 22 Jun 2010 15:28:35 +0800 Subject: findbarfixes01: #i112572# [vcl] assertion in ImageAryData::Load --- .../registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 6 ------ 1 file changed, 6 deletions(-) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index ebed194fcffc..70448e5bbf89 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -1463,9 +1463,6 @@ Find Text - - 1 -
      @@ -1487,9 +1484,6 @@ Focus to Findbar - - 1 - -- cgit From 122581b430e564bcde272a0753f36d64f3aaefb1 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Tue, 22 Jun 2010 17:08:07 +0200 Subject: fwk147: Provide better error message if there is no configuration access on startup --- desktop/inc/app.hxx | 3 ++- desktop/source/app/app.cxx | 20 +++++++++++++++++++- desktop/source/app/langselect.cxx | 23 ++++++++++++++++++++--- desktop/source/app/langselect.hxx | 19 ++++++++++++++----- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 0ae632a6e968..df39d0142787 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -75,7 +75,8 @@ class Desktop : public Application BE_USERINSTALL_FAILED, BE_LANGUAGE_MISSING, BE_USERINSTALL_NOTENOUGHDISKSPACE, - BE_USERINSTALL_NOWRITEACCESS + BE_USERINSTALL_NOWRITEACCESS, + BE_OFFICECONFIG_BROKEN }; enum BootstrapStatus { diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 6f00d47332ac..05311010f455 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -474,6 +474,8 @@ void Desktop::Init() RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Init" ); SetBootstrapStatus(BS_OK); + Sleep(10000); + // create service factory... Reference < XMultiServiceFactory > rSMgr = CreateApplicationServiceManager(); if( rSMgr.is() ) @@ -489,7 +491,12 @@ void Desktop::Init() { // prepare language if ( !LanguageSelection::prepareLanguage() ) - SetBootstrapError( BE_LANGUAGE_MISSING ); + { + if ( LanguageSelection::getStatus() == LanguageSelection::LS_STATUS_CANNOT_DETERMINE_LANGUAGE ) + SetBootstrapError( BE_LANGUAGE_MISSING ); + else + SetBootstrapError( BE_OFFICECONFIG_BROKEN ); + } } if ( GetBootstrapError() == BE_OK ) @@ -870,6 +877,17 @@ void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError ) FatalError( aMessage); } + else if ( aBootstrapError == BE_OFFICECONFIG_BROKEN ) + { + OUString aMessage; + OUStringBuffer aDiagnosticMessage( 100 ); + OUString aErrorMsg; + aErrorMsg = GetMsgString( STR_CONFIG_ERR_ACCESS_GENERAL, + OUString( RTL_CONSTASCII_USTRINGPARAM( "A general error occurred while accessing your central configuration." )) ); + aDiagnosticMessage.append( aErrorMsg ); + aMessage = MakeStartupErrorMessage( aDiagnosticMessage.makeStringAndClear() ); + FatalError(aMessage); + } else if ( aBootstrapError == BE_USERINSTALL_FAILED ) { OUString aMessage; diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index 5e2145b03729..9df8d82a37ff 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -64,10 +64,12 @@ namespace desktop { static char const SOFFICE_BOOTSTRAP[] = "Bootstrap"; static char const SOFFICE_STARTLANG[] = "STARTLANG"; + sal_Bool LanguageSelection::bFoundLanguage = sal_False; OUString LanguageSelection::aFoundLanguage; -const OUString LanguageSelection::usFallbackLanguage = OUString::createFromAscii("en-US"); +LanguageSelection::LanguageSelectionStatus LanguageSelection::m_eStatus = LS_STATUS_OK; +const OUString LanguageSelection::usFallbackLanguage = OUString::createFromAscii("en-US"); static sal_Bool existsURL( OUString const& sURL ) { @@ -122,6 +124,7 @@ Locale LanguageSelection::IsoStringToLocale(const OUString& str) bool LanguageSelection::prepareLanguage() { + m_eStatus = LS_STATUS_OK; OUString sConfigSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"); Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); Reference< XLocalizable > theConfigProvider; @@ -131,7 +134,9 @@ bool LanguageSelection::prepareLanguage() } catch(const Exception&) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } + if(!theConfigProvider.is()) return false; @@ -149,6 +154,7 @@ bool LanguageSelection::prepareLanguage() } catch(const Exception&) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } // #i32939# use system locale to set document default locale @@ -162,6 +168,7 @@ bool LanguageSelection::prepareLanguage() } catch (Exception&) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } // get the selected UI language as string @@ -350,8 +357,10 @@ OUString LanguageSelection::getLanguageString() aFoundLanguage = usFallbackLanguage; return aFoundLanguage; } + // fallback didn't work use first installed language aUserLanguage = getFirstInstalledLanguage(); + bFoundLanguage = sal_True; aFoundLanguage = aUserLanguage; return aFoundLanguage; @@ -455,7 +464,7 @@ sal_Bool LanguageSelection::isInstalledLanguage(OUString& usLocale, sal_Bool bEx // requested locale starts with the installed locale // (i.e. installed locale has index 0 in requested locale) bInstalled = sal_True; - usLocale = seqLanguages[i]; + usLocale = seqLanguages[i]; break; } } @@ -484,10 +493,12 @@ OUString LanguageSelection::getUserLanguage() } catch ( NoSuchElementException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } catch ( WrappedTargetException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } } @@ -506,10 +517,12 @@ OUString LanguageSelection::getSystemLanguage() } catch ( NoSuchElementException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } catch ( WrappedTargetException const & ) { + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; return OUString(); } } @@ -533,9 +546,13 @@ void LanguageSelection::resetUserLanguage() { OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); OSL_ENSURE(sal_False, aMsg.getStr()); + m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; } - } +LanguageSelection::LanguageSelectionStatus LanguageSelection::getStatus() +{ + return m_eStatus; +} } // namespace desktop diff --git a/desktop/source/app/langselect.hxx b/desktop/source/app/langselect.hxx index 60308164690f..bdf3cd6364de 100644 --- a/desktop/source/app/langselect.hxx +++ b/desktop/source/app/langselect.hxx @@ -40,10 +40,24 @@ namespace desktop class LanguageSelection { +public: + enum LanguageSelectionStatus + { + LS_STATUS_OK, + LS_STATUS_CANNOT_DETERMINE_LANGUAGE, + LS_STATUS_CONFIGURATIONACCESS_BROKEN + }; + + static com::sun::star::lang::Locale IsoStringToLocale(const rtl::OUString& str); + static rtl::OUString getLanguageString(); + static bool prepareLanguage(); + static LanguageSelectionStatus getStatus(); + private: static const rtl::OUString usFallbackLanguage; static rtl::OUString aFoundLanguage; static sal_Bool bFoundLanguage; + static LanguageSelectionStatus m_eStatus; static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getConfigAccess(const sal_Char* pPath, sal_Bool bUpdate=sal_False); @@ -55,11 +69,6 @@ private: static rtl::OUString getSystemLanguage(); static void resetUserLanguage(); static void setDefaultLanguage(const rtl::OUString&); - -public: - static com::sun::star::lang::Locale IsoStringToLocale(const rtl::OUString& str); - static rtl::OUString getLanguageString(); - static bool prepareLanguage(); }; } //namespace desktop -- cgit From 98b532d57687b171a4770ac9d738a9e6ef4b85dd Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 22 Jun 2010 18:16:32 +0200 Subject: mib17: remove unused/needless code --- oovbaapi/ooo/vba/XVBAAppService.idl | 72 ----------------- oovbaapi/ooo/vba/XVBADocService.idl | 72 ----------------- oovbaapi/ooo/vba/makefile.mk | 5 +- vbahelper/inc/vbahelper/vbaapplicationbase.hxx | 5 +- vbahelper/inc/vbahelper/vbadocumentbase.hxx | 4 +- vbahelper/inc/vbahelper/vbahelperinterface.hxx | 30 ++++++- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 95 ++++++++++------------- vbahelper/source/vbahelper/vbadocumentbase.cxx | 51 +++++------- 8 files changed, 89 insertions(+), 245 deletions(-) delete mode 100755 oovbaapi/ooo/vba/XVBAAppService.idl delete mode 100755 oovbaapi/ooo/vba/XVBADocService.idl diff --git a/oovbaapi/ooo/vba/XVBAAppService.idl b/oovbaapi/ooo/vba/XVBAAppService.idl deleted file mode 100755 index 1c4a0920fbf8..000000000000 --- a/oovbaapi/ooo/vba/XVBAAppService.idl +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: XWorkbook.idl,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef __ooo_vba_appservice_idl__ -#define __ooo_vba_appservice_idl__ - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -#ifndef __com_sun_star_uno_XComponentContext_idl__ -#include -#endif - -#ifndef __com_sun_star_frame_XModel_idl__ -#include -#endif - -#ifndef __com_sun_star_script_XLibraryContainer_idl__ -#include -#endif - -//============================================================================= - -module ooo { module vba { - -//============================================================================= - - -interface XHelperInterface; -interface XComponentContext; -interface XModel; - -interface XVBAAppService -{ - interface ::com::sun::star::uno::XInterface; - - any getVBE([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel); - any getVBProjects([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel, [in] ::com::sun::star::script::XLibraryContainer xMacroLibraryContainer, [in] com::sun::star::script::XLibraryContainer xDialogLibraryContainer); - - -}; - - }; }; - -#endif diff --git a/oovbaapi/ooo/vba/XVBADocService.idl b/oovbaapi/ooo/vba/XVBADocService.idl deleted file mode 100755 index 6500f028934b..000000000000 --- a/oovbaapi/ooo/vba/XVBADocService.idl +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: XVBADocService.idl,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef __ooo_vba_socservice_idl__ -#define __ooo_vba_appservice_idl__ - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -#ifndef __com_sun_star_uno_XComponentContext_idl__ -#include -#endif - -#ifndef __com_sun_star_frame_XModel_idl__ -#include -#endif - -#ifndef __com_sun_star_script_XLibraryContainer_idl__ -#include -#endif - -//============================================================================= - -module ooo { module vba { - -//============================================================================= - - -interface XHelperInterface; -interface XComponentContext; -interface XModel; - -interface XVBADocService -{ - interface ::com::sun::star::uno::XInterface; - - - any getVBProject([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel, [in] ::com::sun::star::script::XLibraryContainer xMacroLibraryContainer, [in] com::sun::star::script::XLibraryContainer xDialogLibraryContainer); - - -}; - - }; }; - -#endif diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk index 75f6465bf4c0..4f6d378cfe3f 100644 --- a/oovbaapi/ooo/vba/makefile.mk +++ b/oovbaapi/ooo/vba/makefile.mk @@ -61,9 +61,8 @@ IDLFILES=\ XFontBase.idl\ XDialogsBase.idl\ XDialogBase.idl\ - XPageSetupBase.idl \ - XVBAAppService.idl\ - XVBADocService.idl\ + XPageSetupBase.idl + # ------------------------------------------------------------------ .ENDIF .INCLUDE : target.mk diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx index e2a5a3bff5da..73c1aa0d94e7 100644 --- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx +++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx @@ -57,13 +57,14 @@ public: virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw (::com::sun::star::uno::RuntimeException); virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getVBProjects() throw (css::uno::RuntimeException); + virtual void SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException); virtual void SAL_CALL OnTime( const ::com::sun::star::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const ::com::sun::star::uno::Any& aLatestTime, const ::com::sun::star::uno::Any& aSchedule ) throw (::com::sun::star::uno::RuntimeException); virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException); virtual void SAL_CALL Undo( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL Quit( ) throw (::com::sun::star::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL SAL_CALL getVBProjects() throw (css::uno::RuntimeException); // XHelperInterface virtual rtl::OUString& getServiceImplName(); diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx index 7131e1963b26..2588b7da1720 100644 --- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx +++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx @@ -52,9 +52,7 @@ public: virtual ::rtl::OUString SAL_CALL getFullName() throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getSaved() throw (css::uno::RuntimeException); virtual void SAL_CALL setSaved( sal_Bool bSave ) throw (css::uno::RuntimeException); - - virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); // Michhael E. Bohn - + virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); // Methods virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges, diff --git a/vbahelper/inc/vbahelper/vbahelperinterface.hxx b/vbahelper/inc/vbahelper/vbahelperinterface.hxx index 21339631e1ed..b095b5cd2823 100644 --- a/vbahelper/inc/vbahelper/vbahelperinterface.hxx +++ b/vbahelper/inc/vbahelper/vbahelperinterface.hxx @@ -28,6 +28,8 @@ #define OOVBAAPI_VBA_HELPERINTERFACE_HXX #include +#include +#include #include #include #include @@ -68,6 +70,7 @@ protected: css::uno::Reference< css::uno::XComponentContext > mxContext; public: InheritedHelperInterfaceImpl() {} + InheritedHelperInterfaceImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxContext( xContext ) {} InheritedHelperInterfaceImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxParent( xParent ), mxContext( xContext ) {} virtual rtl::OUString& getServiceImplName() = 0; virtual css::uno::Sequence getServiceNames() = 0; @@ -86,7 +89,6 @@ public: return xNameAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Application" ) ) ); } - // XServiceInfo Methods virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (css::uno::RuntimeException) { return getServiceImplName(); } virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (css::uno::RuntimeException) @@ -101,19 +103,39 @@ public: } virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (css::uno::RuntimeException) { - css::uno::Sequence< rtl::OUString > aNames = getServiceNames();; + css::uno::Sequence< rtl::OUString > aNames = getServiceNames(); return aNames; } }; template< typename Ifc1 > class VBAHELPER_DLLPUBLIC InheritedHelperInterfaceImpl1 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > +{ + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > Base; +public: + InheritedHelperInterfaceImpl1< Ifc1 >() {} + InheritedHelperInterfaceImpl1< Ifc1 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl1< Ifc1 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} +}; +template< typename Ifc1, typename Ifc2 > +class VBAHELPER_DLLPUBLIC InheritedHelperInterfaceImpl2 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper2< Ifc1, Ifc2 > > { -typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > Base; + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper2< Ifc1, Ifc2 > > Base; public: - InheritedHelperInterfaceImpl1< Ifc1 > ( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >() {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} +}; +template< typename Ifc1, typename Ifc2, typename Ifc3 > +class VBAHELPER_DLLPUBLIC InheritedHelperInterfaceImpl3 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper3< Ifc1, Ifc2, Ifc3 > > +{ + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper3< Ifc1, Ifc2, Ifc3 > > Base; +public: + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >() {} + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} }; // ============================================================================ diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 6d2c51066ca2..213133998def 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -24,39 +24,36 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbahelper/vbaapplicationbase.hxx" + #include -#include //Michael E. Bohn -#include //Michael E. Bohn -#include //Michael E. Bohn -#include //Michael E. Bohn +#include +#include +#include +#include #include #include #include #include #include #include -#include //Michael E. Bohn -#include //Michael E. Bohn +#include #include - -#include "vbacommandbars.hxx" +#include #include #include - -// start basic includes #include #include #include #include #include -// end basic includes -#include +#include "vbacommandbars.hxx" -using namespace com::sun::star; -using namespace ooo::vba; +using namespace ::com::sun::star; +using namespace ::ooo::vba; #define OFFICEVERSION "11.0" @@ -407,57 +404,43 @@ float SAL_CALL VbaApplicationBase::CentimetersToPoints( float _Centimeters ) thr return ( _Centimeters * rate ); } -// inserted by Michael E. Bohn uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException) { - uno::Any aAny; - uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); - try - { - uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAAppService" )),mxContext); - uno::Reference < ::ooo::vba::XVBAAppService > xVBAAppService (xInterface, ::uno::UNO_QUERY_THROW ); - if (xVBAAppService.is()){ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - return xVBAAppService->getVBE( this, mxContext, xModel); - } - - }catch(uno::Exception* e) - { - } - return aAny; + try // return empty object on error + { + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); + aArgs[ 1 ] <<= getCurrentDocument(); + uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); + uno::Reference< uno::XInterface > xVBE = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBE" ) ), aArgs, mxContext ); + return uno::Any( xVBE ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); } uno::Any SAL_CALL VbaApplicationBase::getVBProjects() throw (uno::RuntimeException) { - uno::Any aAny; - uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); - try - { - uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAAppService" )),mxContext); - uno::Reference < ::ooo::vba::XVBAAppService > xVBAAppService (xInterface, ::uno::UNO_QUERY_THROW ); - if (xVBAAppService.is()){ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XEmbeddedScripts > xEnbeddedScripts ( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< script::XStorageBasedLibraryContainer > xMacroStorageBasedLibraryContainer = xEnbeddedScripts->getBasicLibraries(); - uno::Reference< script::XStorageBasedLibraryContainer > xDialogStorageBasedLibraryContainer = xEnbeddedScripts->getDialogLibraries(); - uno::Reference< script::XLibraryContainer > xMacroLibraryContainer ( xMacroStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - uno::Reference< script::XLibraryContainer > xDialogLibraryContainer( xDialogStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - return xVBAAppService->getVBProjects(this, mxContext, xModel, xMacroLibraryContainer, xDialogLibraryContainer); - } - - }catch(uno::Exception* e) - { - } - return aAny; - - - + try // return empty object on error + { + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); + aArgs[ 1 ] <<= getCurrentDocument(); + uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); + uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProjects" ) ), aArgs, mxContext ); + return uno::Any( xVBProjects ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); } - - - rtl::OUString& VbaApplicationBase::getServiceImplName() { diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index f27f2de53c8a..65f7f4bcfbeb 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -24,9 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include -#include -#include + +#include "vbahelper/vbadocumentbase.hxx" +#include "vbahelper/helperdecl.hxx" #include #include @@ -35,8 +35,8 @@ #include #include //Michael E. Bohn #include -#include +#include #include #include @@ -206,40 +206,25 @@ VbaDocumentBase::Activate() throw (uno::RuntimeException) xFrame->activate(); } -// ---- Michael E.Bohn Start----- - uno::Any SAL_CALL VbaDocumentBase::getVBProject() throw (uno::RuntimeException) - { - uno::Any aAny; - uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); - try - { - uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBADocService" )),mxContext); - uno::Reference < ::ooo::vba::XVBADocService > xVBADocService (xInterface, ::uno::UNO_QUERY_THROW ); - if (xVBADocService.is()){ - uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XEmbeddedScripts > xEnbeddedScripts ( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< script::XStorageBasedLibraryContainer > xMacroStorageBasedLibraryContainer = xEnbeddedScripts->getBasicLibraries(); - uno::Reference< script::XStorageBasedLibraryContainer > xDialogStorageBasedLibraryContainer = xEnbeddedScripts->getDialogLibraries(); - uno::Reference< script::XLibraryContainer > xMacroLibraryContainer ( xMacroStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - uno::Reference< script::XLibraryContainer > xDialogLibraryContainer( xDialogStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - - return xVBADocService->getVBProject( this, mxContext, xModel, xMacroLibraryContainer, xDialogLibraryContainer ); - } - - }catch(uno::Exception* e) - { - } - return aAny; - + try // return empty object on error + { + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); + aArgs[ 1 ] <<= mxModel; + uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); + uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProject" ) ), aArgs, mxContext ); + return uno::Any( xVBProjects ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); } - -// ---- Michael E.Bohn End ----- - - rtl::OUString& VbaDocumentBase::getServiceImplName() { -- cgit From 3878d8a7a5279d5b24e91b438084a82d91fd9ee4 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Wed, 23 Jun 2010 12:00:04 +0200 Subject: aw083 #i105548# Added using the VOCRedirector inside pageobject content creation --- svx/source/sdr/contact/viewobjectcontactofpageobj.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx index 5ef26193d4b3..34731f100b5d 100644 --- a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx @@ -273,9 +273,16 @@ namespace sdr // init extractor, guarantee existance, set page there mpExtractor->SetStartPage(pPage); + // #i105548# also need to copy the VOCRedirector for sub-content creation + mpExtractor->SetViewObjectContactRedirector(GetObjectContact().GetViewObjectContactRedirector()); + // create page content xPageContent = mpExtractor->createPrimitive2DSequenceForPage(rDisplayInfo); + // #i105548# reset VOCRedirector to not accidentially have a pointer to a + // temporary class, so calls to it are avoided safely + mpExtractor->SetViewObjectContactRedirector(0); + // reset recursion flag bInCreatePrimitive2D = false; } -- cgit From b68a479f8fe93e9ab4bbb6d7c05d3c9e0532aa1a Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 23 Jun 2010 17:19:22 +0200 Subject: fwk147: #159152# Use a more robust exception handling to avoid crashes due to unexpected exceptions --- sfx2/source/view/userinputinterception.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sfx2/source/view/userinputinterception.cxx b/sfx2/source/view/userinputinterception.cxx index e716e604b649..ad910a944e0f 100644 --- a/sfx2/source/view/userinputinterception.cxx +++ b/sfx2/source/view/userinputinterception.cxx @@ -216,6 +216,13 @@ namespace sfx2 if ( e.Context == xHandler ) aIterator.remove(); } + catch( const RuntimeException& ) + { + throw; + } + catch( const Exception& ) + { + } } } break; @@ -247,6 +254,13 @@ namespace sfx2 if ( e.Context == xHandler ) aIterator.remove(); } + catch( const RuntimeException& ) + { + throw; + } + catch( const Exception& ) + { + } } } break; -- cgit From 64994694589f6706b6d48356859555381ab7b76a Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 23 Jun 2010 19:44:37 +0200 Subject: mib17: #i109119 add Events menu entry --- .../registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index d3db05206a6a..2d887c084317 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -1,4 +1,4 @@ - + @@ -160,6 +160,14 @@ ~Select... + + + Sheet ~Events... + + + ~Events... + + DataPilot Filter -- cgit From 271727322f844a8b56d5f3054f0eb61a7e1484a9 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 24 Jun 2010 09:08:52 +0200 Subject: cws tl81: #i112179# dictionary issue with context menus fixed --- editeng/source/editeng/editview.cxx | 11 +++++++++-- editeng/source/misc/unolingu.cxx | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) mode change 100644 => 100755 editeng/source/misc/unolingu.cxx diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 642b5e0d9f17..c07b84d0d0f2 100755 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -1044,7 +1044,8 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack ) { PopupMenu aPopupMenu( EditResId( RID_MENU_SPELL ) ); PopupMenu *pAutoMenu = aPopupMenu.GetPopupMenu( MN_AUTOCORR ); - PopupMenu *pInsertMenu = aPopupMenu.GetPopupMenu( MN_INSERT ); + PopupMenu *pInsertMenu = aPopupMenu.GetPopupMenu( MN_INSERT ); // add word to user-dictionaries + pInsertMenu->SetMenuFlags( MENU_FLAG_NOAUTOMNEMONICS ); //! necessary to retrieve the correct dictionary names later EditPaM aPaM2( aPaM ); aPaM2.GetIndex()++; @@ -1261,7 +1262,13 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack ) } else if ( nId >= MN_DICTSTART ) { - Reference< XDictionary > xDic( pDic[nId - MN_DICTSTART], UNO_QUERY ); + String aDicName ( pInsertMenu->GetItemText(nId) ); + + uno::Reference< linguistic2::XDictionary > xDic; + uno::Reference< linguistic2::XDictionaryList > xDicList( SvxGetDictionaryList() ); + if (xDicList.is()) + xDic = xDicList->getDictionaryByName( aDicName ); + if (xDic.is()) xDic->add( aSelected, sal_False, String() ); // save modified user-dictionary if it is persistent diff --git a/editeng/source/misc/unolingu.cxx b/editeng/source/misc/unolingu.cxx old mode 100644 new mode 100755 index e95ce560023b..ae92fd1a01b8 --- a/editeng/source/misc/unolingu.cxx +++ b/editeng/source/misc/unolingu.cxx @@ -1197,7 +1197,10 @@ uno::Reference< XDictionary > LinguMgr::GetStandard() // add new dictionary to list if (xTmp.is()) + { xTmpDicList->addDictionary( xTmp ); + xTmp->setActive( sal_True ); + } xDic = uno::Reference< XDictionary > ( xTmp, UNO_QUERY ); } #if OSL_DEBUG_LEVEL > 1 -- cgit From a2e7c2e0d002d75a6b77a629a4e904ab54bf8375 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 24 Jun 2010 10:44:42 +0200 Subject: #i10000# add bIsPasswordToModify --- uui/source/iahndl-authentication.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index 91aa3fed73a6..73fa61f31ff4 100755 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -742,7 +742,8 @@ UUIInteractionHelper::handlePasswordRequest( aPasswordRequest.Mode, rRequest->getContinuations(), rtl::OUString(), - false /* bool bMSCryptoMode */); + false /* bool bMSCryptoMode */, + false /* bool bIsPasswordToModify */); return true; } -- cgit From 5db01bbf8f1ef192cbd7c35695f517e3622e3913 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Fri, 25 Jun 2010 08:57:06 +0200 Subject: mib17: #i110821# COM default member support --- basic/source/classes/sb.cxx | 4 +++- basic/source/runtime/step2.cxx | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 79c5f78601ea..924a3ef2807f 100755 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -569,11 +569,13 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) } } SetModuleType( ModuleType::CLASS ); + mbVBACompat = pClassModule->mbVBACompat; } SbClassModuleObject::~SbClassModuleObject() { - triggerTerminateEvent(); + if( StarBASIC::IsRunning() ) + triggerTerminateEvent(); // Must be deleted by base class dtor because this data // is not owned by the SbClassModuleObject object diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index 72ea67dd8db4..8e72fd2ac3c6 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -263,8 +263,10 @@ SbxVariable* SbiRuntime::FindElement pElem = pNew; } // Index-Access bei UnoObjekten beruecksichtigen - /* - else if( pElem->ISA(SbUnoProperty) ) + // definitely we want this for VBA where properties are often + // collections ( which need index access ), but lets only do + // this if we actually have params following + else if( bVBAEnabled && pElem->ISA(SbUnoProperty) && pElem->GetParameters() ) { // pElem auf eine Ref zuweisen, um ggf. eine Temp-Var zu loeschen SbxVariableRef refTemp = pElem; @@ -274,7 +276,6 @@ SbxVariable* SbiRuntime::FindElement pElem->SetParameters( NULL ); // sonst bleibt Ref auf sich selbst pElem = pNew; } - */ } return CheckArray( pElem ); } -- cgit From 32b60d0777e2420f9779af1771ac32ce8a7f9761 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Fri, 25 Jun 2010 09:56:19 +0200 Subject: #i110653# - use ooo base version supplied by build env. --- desktop/test/deployment/boxt/makefile.mk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/desktop/test/deployment/boxt/makefile.mk b/desktop/test/deployment/boxt/makefile.mk index 63f123fcc608..11d736448d44 100644 --- a/desktop/test/deployment/boxt/makefile.mk +++ b/desktop/test/deployment/boxt/makefile.mk @@ -33,11 +33,9 @@ ENABLE_EXCEPTIONS = TRUE .INCLUDE: settings.mk .INCLUDE: rtlbootstrap.mk +.INCLUDE: versionlist.mk -#TODO: The underlying OOo base version needed here is currently only available -# as instsetoo_native/util/openoffice.lst OOOBASEVERSION, so hard-coding it here -# for now (see issue 110653): -my_version = 3.3 +my_version = $(OOOBASEVERSIONMAJOR).$(OOOBASEVERSIONMINOR) DLLPRE = -- cgit From 2ee058b62a083ad6dd208f79fefdd014f67678da Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Fri, 25 Jun 2010 11:04:30 +0200 Subject: #i112664# - service must not be 'one instance'. --- ucb/source/core/cmdenv.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ucb/source/core/cmdenv.cxx b/ucb/source/core/cmdenv.cxx index 0f425e814400..5c0136fab063 100644 --- a/ucb/source/core/cmdenv.cxx +++ b/ucb/source/core/cmdenv.cxx @@ -183,7 +183,7 @@ UcbCommandEnvironment::createServiceFactory( const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr ) { return uno::Reference< lang::XSingleServiceFactory >( - cppu::createOneInstanceFactory( + cppu::createSingleFactory( rxServiceMgr, UcbCommandEnvironment::getImplementationName_Static(), UcbCommandEnvironment_CreateInstance, -- cgit From 7359de66a265a67863bab7e2ee424b40dcf7343c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 25 Jun 2010 17:42:50 +0200 Subject: sw33bf06: #i110070#: fix regression: member initialization removed by accident --- xmloff/source/text/XMLTextMarkImportContext.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index af51f5f56d98..00cdce37f4d5 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -116,6 +116,7 @@ XMLTextMarkImportContext::XMLTextMarkImportContext( const OUString& rLocalName ) : SvXMLImportContext(rImport, nPrefix, rLocalName) , m_rHelper(rHlp) + , m_bHaveAbout(false) { } -- cgit From 07a000e572751457da400f615c085e6916c2aa28 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Mon, 28 Jun 2010 09:26:14 +0200 Subject: fwk147: #i112578# Remove Sleep command used for debugging --- desktop/source/app/app.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 05311010f455..04574b4c57b8 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -474,8 +474,6 @@ void Desktop::Init() RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Init" ); SetBootstrapStatus(BS_OK); - Sleep(10000); - // create service factory... Reference < XMultiServiceFactory > rSMgr = CreateApplicationServiceManager(); if( rSMgr.is() ) -- cgit From 7cf95e512b371281073de2422aa30c5d3c35a3c0 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 28 Jun 2010 13:58:27 +0200 Subject: cws tl81: #i112695# crash in synonym sub-menu fixed --- sfx2/source/menu/mnumgr.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sfx2/source/menu/mnumgr.cxx b/sfx2/source/menu/mnumgr.cxx index b264a5b47861..bc765b95340c 100755 --- a/sfx2/source/menu/mnumgr.cxx +++ b/sfx2/source/menu/mnumgr.cxx @@ -578,6 +578,7 @@ SfxPopupMenuManager* SfxPopupMenuManager::Popup( const ResId& rResId, SfxViewFra return 0; } + void SfxPopupMenuManager::ExecutePopup( const ResId& rResId, SfxViewFrame* pFrame, const Point& rPoint, Window* pWindow ) { PopupMenu *pSVMenu = new PopupMenu( rResId ); @@ -622,6 +623,12 @@ void SfxPopupMenuManager::ExecutePopup( const ResId& rResId, SfxViewFrame* pFram SfxPopupMenuManager aPop( pSVMenu, pFrame->GetBindings() ); aPop.RemoveDisabledEntries(); aPop.Execute( rPoint, pWindow ); + + // #i112646 avoid crash when context menu is closed. + // the (manually inserted) sub-menu needs to be destroyed before + // aPop gets destroyed. + delete pThesSubMenu; + pThesSubMenu = 0; } delete pThesSubMenu; @@ -631,3 +638,4 @@ Menu* SfxPopupMenuManager::GetSVMenu() { return (Menu*) GetMenu()->GetSVMenu(); } + -- cgit From 748cc4c7f3e05ef8d2cb90e33d311084a4d425dd Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 28 Jun 2010 15:25:14 +0200 Subject: cws tl81: #i112695# crash in synonym sub-menu fixed --- .../registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 9 --------- 1 file changed, 9 deletions(-) mode change 100644 => 100755 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu old mode 100644 new mode 100755 index ebed194fcffc..85bc336ddec0 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -2139,9 +2139,6 @@ ~Sentence case - - 1 - @@ -2163,17 +2160,11 @@ ~Capitalize Every Word - - 1 - ~tOGGLE cASE - - 1 - -- cgit From b6e30719dde5f67290a1b77891d3435ee7da2f9e Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Tue, 29 Jun 2010 16:13:34 +0200 Subject: impress193: #i112647# Integrated diff from MAV. --- sfx2/source/view/frame2.cxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sfx2/source/view/frame2.cxx b/sfx2/source/view/frame2.cxx index d99ad8733e03..d43512ac791d 100644 --- a/sfx2/source/view/frame2.cxx +++ b/sfx2/source/view/frame2.cxx @@ -280,10 +280,7 @@ SfxFrame* SfxFrame::Create( SfxObjectShell& rDoc, Window& rWindow, USHORT nViewI aLoadArgs = aArgs.getPropertyValues(); // load the doc into that frame - ::rtl::OUString sLoaderURL( rDoc.GetModel()->getURL() ); - if ( sLoaderURL.getLength() == 0 ) - sLoaderURL = rDoc.GetFactory().GetFactoryURL(); - + ::rtl::OUString sLoaderURL( RTL_CONSTASCII_USTRINGPARAM( "private:object" ) ); Reference< XComponentLoader > xLoader( xFrame, UNO_QUERY_THROW ); xLoader->loadComponentFromURL( sLoaderURL, -- cgit From 1cad7ac9a61f02d6eeb4053c93f7a8d01a7eff52 Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Tue, 29 Jun 2010 17:52:44 +0200 Subject: #i112601# paint the correct page background --- svx/inc/svx/sdrmasterpagedescriptor.hxx | 3 +++ svx/inc/svx/svdpage.hxx | 1 + .../contact/viewcontactofmasterpagedescriptor.cxx | 18 +---------------- svx/source/svdraw/sdrmasterpagedescriptor.cxx | 23 ++++++++++++++++++++++ svx/source/svdraw/svdpage.cxx | 12 +++++++++++ svx/source/unodraw/UnoGraphicExporter.cxx | 14 +++++++++---- 6 files changed, 50 insertions(+), 21 deletions(-) diff --git a/svx/inc/svx/sdrmasterpagedescriptor.hxx b/svx/inc/svx/sdrmasterpagedescriptor.hxx index 612f2ab927ec..3a31c3d11206 100644 --- a/svx/inc/svx/sdrmasterpagedescriptor.hxx +++ b/svx/inc/svx/sdrmasterpagedescriptor.hxx @@ -35,6 +35,7 @@ // predeclarations class SdrObject; class SfxItemSet; +class SdrPageProperties; namespace sdr { @@ -89,6 +90,8 @@ namespace sdr // operators sal_Bool operator==(const MasterPageDescriptor& rCandidate) const; sal_Bool operator!=(const MasterPageDescriptor& rCandidate) const; + + const SdrPageProperties* getCorrectSdrPageProperties() const; }; } // end of namespace sdr diff --git a/svx/inc/svx/svdpage.hxx b/svx/inc/svx/svdpage.hxx index c601fddef181..784598d7d544 100644 --- a/svx/inc/svx/svdpage.hxx +++ b/svx/inc/svx/svdpage.hxx @@ -448,6 +448,7 @@ private: public: SdrPageProperties& getSdrPageProperties() { return *mpSdrPageProperties; } const SdrPageProperties& getSdrPageProperties() const { return *mpSdrPageProperties; } + const SdrPageProperties* getCorrectSdrPageProperties() const; protected: // new MasterPageDescriptorVector diff --git a/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx b/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx index cbe9c4a9c615..6ca5f1c4d172 100644 --- a/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx +++ b/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx @@ -62,23 +62,7 @@ namespace sdr { drawinglayer::primitive2d::Primitive2DSequence xRetval; drawinglayer::attribute::SdrFillAttribute aFill; - const SdrPage* pCorrectPage = &GetMasterPageDescriptor().GetOwnerPage(); - const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties(); - - if(XFILL_NONE == ((const XFillStyleItem&)pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue()) - { - pCorrectPage = &GetMasterPageDescriptor().GetUsedPage(); - pCorrectProperties = &pCorrectPage->getSdrPageProperties(); - } - - if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet()) - { - // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets, - // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all - // MasterPages should have a StyleSheet excactly for this reason, but historically - // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others). - pCorrectProperties = 0; - } + const SdrPageProperties* pCorrectProperties = GetMasterPageDescriptor().getCorrectSdrPageProperties(); if(pCorrectProperties) { diff --git a/svx/source/svdraw/sdrmasterpagedescriptor.cxx b/svx/source/svdraw/sdrmasterpagedescriptor.cxx index 67b2de8b693c..eb757a8ee41c 100644 --- a/svx/source/svdraw/sdrmasterpagedescriptor.cxx +++ b/svx/source/svdraw/sdrmasterpagedescriptor.cxx @@ -113,6 +113,29 @@ namespace sdr || &maUsedPage != &rCandidate.maUsedPage || maVisibleLayers != rCandidate.maVisibleLayers); } + + const SdrPageProperties* MasterPageDescriptor::getCorrectSdrPageProperties() const + { + const SdrPage* pCorrectPage = &GetOwnerPage(); + const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties(); + + if(XFILL_NONE == ((const XFillStyleItem&)pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue()) + { + pCorrectPage = &GetUsedPage(); + pCorrectProperties = &pCorrectPage->getSdrPageProperties(); + } + + if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet()) + { + // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets, + // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all + // MasterPages should have a StyleSheet excactly for this reason, but historically + // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others). + pCorrectProperties = 0; + } + + return pCorrectProperties; + } } // end of namespace sdr ////////////////////////////////////////////////////////////////////////////// diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 8da0b248f38b..592f41543132 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -1979,6 +1979,18 @@ void SdrPage::ReplaceCommentByIndex(sal_uInt32 nIndex, const sdr::Comment& rNew) } } +const SdrPageProperties* SdrPage::getCorrectSdrPageProperties() const +{ + if(mpMasterPageDescriptor) + { + return mpMasterPageDescriptor->getCorrectSdrPageProperties(); + } + else + { + return &getSdrPageProperties(); + } +} + ////////////////////////////////////////////////////////////////////////////// // use new redirector instead of pPaintProc diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index b80be1076b7e..c58e86f77fc3 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -634,10 +634,16 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, { if( rSettings.mbExportOnlyBackground ) { - pTempBackgroundShape = new SdrRectObj(Rectangle(Point(0,0), pPage->GetSize())); - pTempBackgroundShape->SetMergedItemSet(pPage->getSdrPageProperties().GetItemSet()); - pTempBackgroundShape->SetMergedItem(XLineStyleItem(XLINE_NONE)); - aShapes.push_back(pTempBackgroundShape); + const SdrPageProperties* pCorrectProperties = pPage->getCorrectSdrPageProperties(); + + if(pCorrectProperties) + { + pTempBackgroundShape = new SdrRectObj(Rectangle(Point(0,0), pPage->GetSize())); + pTempBackgroundShape->SetMergedItemSet(pCorrectProperties->GetItemSet()); + pTempBackgroundShape->SetMergedItem(XLineStyleItem(XLINE_NONE)); + pTempBackgroundShape->NbcSetStyleSheet(pCorrectProperties->GetStyleSheet(), true); + aShapes.push_back(pTempBackgroundShape); + } } else { -- cgit From 6e819dc904924498d55857ec7d585bf7055a6953 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 1 Jul 2010 15:19:53 +0200 Subject: cws tl81: #i112788# patch was broken, old code restored --- editeng/source/editeng/impedit2.cxx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 778942730e71..148ca08816ae 100755 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -4209,18 +4209,8 @@ long ImpEditEngine::GetXPos( ParaPortion* pParaPortion, EditLine* pLine, USHORT DBG_ERROR("svx::ImpEditEngine::GetXPos(), index out of range!"); } -#if 0 + // old code restored see #i112788 (which leaves #i74188 unfixed again) long nPosInPortion = pLine->GetCharPosArray().GetObject( nPos ); -#else - // #i74188# (positioning the cursor after deleting components of combined indic characters) - SvxFont aTmpFont( pParaPortion->GetNode()->GetCharAttribs().GetDefFont() ); - SeekCursor( pParaPortion->GetNode(), nPos+1, aTmpFont ); - aTmpFont.SetPhysFont( GetRefDevice() ); - ImplInitDigitMode( GetRefDevice(), 0, 0, 0, aTmpFont.GetLanguage() ); - String sSegment(*pParaPortion->GetNode(), pLine->GetStart(), nPos+1); - long nPosInPortion = aTmpFont.QuickGetTextSize( GetRefDevice(), - sSegment, 0, nPos+1, NULL ).Width(); -#endif if ( !pPortion->IsRightToLeft() ) { -- cgit From 7e018ced84bd8a4400bf8c7ede4e1cb33e90aec9 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Thu, 1 Jul 2010 16:23:26 +0200 Subject: mib17: #111144# Enable calls to module function via Sheet object --- basic/inc/basic/sbmod.hxx | 3 + basic/source/classes/sbxmod.cxx | 359 ++++++++++++++++++++++++++ vbahelper/inc/vbahelper/vbacollectionimpl.hxx | 3 +- vbahelper/inc/vbahelper/vbahelper.hxx | 1 + vbahelper/source/vbahelper/vbaglobalbase.cxx | 24 +- vbahelper/source/vbahelper/vbahelper.cxx | 20 ++ 6 files changed, 404 insertions(+), 6 deletions(-) diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index cf888adf9dcf..aeed4c2b6347 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -28,6 +28,7 @@ #ifndef _SB_SBMOD_HXX #define _SB_SBMOD_HXX +#include #include #include #include @@ -57,6 +58,7 @@ class SbModule : public SbxObject SbModuleImpl* mpSbModuleImpl; // Impl data protected: + com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper; ::rtl::OUString aOUSource; String aComment; SbiImage* pImage; // the Image @@ -131,6 +133,7 @@ public: INT32 GetModuleType() { return mnType; } void SetModuleType( INT32 nType ) { mnType = nType; } bool GetIsProxyModule() { return bIsProxyModule; } + ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); }; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 1b49a376c9bd..254e99c69da9 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -76,7 +76,20 @@ using namespace com::sun::star; #include #include #include +#include +#include +#include +#include +#include +#include +#include + using namespace ::com::sun::star; +using namespace com::sun::star::lang; +using namespace com::sun::star::reflection; +using namespace com::sun::star::beans; +using namespace com::sun::star::script; + #include #include @@ -85,6 +98,340 @@ using namespace com::sun::star; #include #include #include +#include + +typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE; +typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap; +::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar ); +void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue ); + +class DocObjectWrapper : public DocObjectWrapper_BASE +{ + Reference< XAggregation > m_xAggProxy; + Reference< XInvocation > m_xAggInv; + Reference< XTypeProvider > m_xAggregateTypeProv; + Sequence< Type > m_Types; + SbModule* m_pMod; + SbMethodRef getMethod( const rtl::OUString& aName ) throw (RuntimeException); + SbPropertyRef getProperty( const rtl::OUString& aName ) throw (RuntimeException); + String mName; // for debugging + +public: + DocObjectWrapper( SbModule* pMod ); + ~DocObjectWrapper(); + + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() + throw ( com::sun::star::uno::RuntimeException ) + { + return m_xAggregateTypeProv->getImplementationId(); + + } + + virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (RuntimeException); + + virtual Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const Sequence< Any >& aParams, Sequence< ::sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException); + virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException); + virtual Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (UnknownPropertyException, RuntimeException); + virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (RuntimeException); + virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (RuntimeException); + virtual Any SAL_CALL queryInterface( const Type& aType ) throw ( RuntimeException ); + + virtual Sequence< Type > SAL_CALL getTypes() throw ( RuntimeException ); +}; + +DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pVar->GetName() ) +{ + SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); + if ( pMod ) + { + sal_Int16 nType = pMod->GetModuleType(); + if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) + { + Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); + // Use proxy factory service to create aggregatable proxy. + SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pMod->GetObject() ); + Reference< XInterface > xIf; + if ( pUnoObj ) + { + Any aObj = pUnoObj->getUnoAny(); + aObj >>= xIf; + if ( xIf.is() ) + { + m_xAggregateTypeProv.set( xIf, UNO_QUERY ); + m_xAggInv.set( xIf, UNO_QUERY ); + } + } + if ( xIf.is() ) + { + try + { + Reference< XMultiComponentFactory > xMFac( xFactory, UNO_QUERY_THROW ); + Reference< XPropertySet> xPSMPropertySet( xMFac, UNO_QUERY_THROW ); + Reference< XComponentContext > xCtx; + xPSMPropertySet->getPropertyValue( + String( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xCtx; + Reference< XProxyFactory > xProxyFac( xMFac->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.reflection.ProxyFactory" ) ), xCtx ), UNO_QUERY_THROW ); + m_xAggProxy = xProxyFac->createProxy( xIf ); + } + catch( Exception& ) + { + OSL_ENSURE( false, "DocObjectWrapper::DocObjectWrapper: Caught exception!" ); + } + } + + if ( m_xAggProxy.is() ) + { + osl_incrementInterlockedCount( &m_refCount ); + + /* i35609 - Fix crash on Solaris. The setDelegator call needs + to be in its own block to ensure that all temporary Reference + instances that are acquired during the call are released + before m_refCount is decremented again */ + { + m_xAggProxy->setDelegator( static_cast< cppu::OWeakObject * >( this ) ); + } + + osl_decrementInterlockedCount( &m_refCount ); + } + } + } +} + +void SAL_CALL +DocObjectWrapper::acquire() throw () +{ + osl_incrementInterlockedCount( &m_refCount ); + OSL_TRACE("DocObjectWrapper::acquire(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount ); +} +void SAL_CALL +DocObjectWrapper::release() throw () +{ + if ( osl_decrementInterlockedCount( &m_refCount ) == 0 ) + { + OSL_TRACE("DocObjectWrapper::release(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount ); + delete this; + } + else + OSL_TRACE("DocObjectWrapper::release(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount ); +} + +DocObjectWrapper::~DocObjectWrapper() +{ +} + +Sequence< Type > SAL_CALL DocObjectWrapper::getTypes() + throw ( RuntimeException ) +{ + if ( m_Types.getLength() == 0 ) + { + Sequence< Type > sTypes; + if ( m_xAggregateTypeProv.is() ) + sTypes = m_xAggregateTypeProv->getTypes(); + m_Types.realloc( sTypes.getLength() + 1 ); + Type* pPtr = m_Types.getArray(); + for ( int i=0; i SAL_CALL +DocObjectWrapper::getIntrospection( ) throw (RuntimeException) +{ + return NULL; +} + +Any SAL_CALL +DocObjectWrapper::invoke( const ::rtl::OUString& aFunctionName, const Sequence< Any >& aParams, Sequence< ::sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasMethod( aFunctionName ) ) + return m_xAggInv->invoke( aFunctionName, aParams, aOutParamIndex, aOutParam ); + SbMethodRef pMethod = getMethod( aFunctionName ); + if ( !pMethod ) + throw RuntimeException(); + // check number of parameters + sal_Int32 nParamsCount = aParams.getLength(); + SbxInfo* pInfo = pMethod->GetInfo(); + if ( pInfo ) + { + sal_Int32 nSbxOptional = 0; + USHORT n = 1; + for ( const SbxParamInfo* pParamInfo = pInfo->GetParam( n ); pParamInfo; pParamInfo = pInfo->GetParam( ++n ) ) + { + if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != 0 ) + ++nSbxOptional; + else + nSbxOptional = 0; + } + sal_Int32 nSbxCount = n - 1; + if ( nParamsCount < nSbxCount - nSbxOptional ) + { + throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "wrong number of parameters!" ) ), Reference< XInterface >() ); + } + } + // set parameters + SbxArrayRef xSbxParams; + if ( nParamsCount > 0 ) + { + xSbxParams = new SbxArray; + const Any* pParams = aParams.getConstArray(); + for ( sal_Int32 i = 0; i < nParamsCount; ++i ) + { + SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT ); + unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), pParams[i] ); + xSbxParams->Put( xSbxVar, static_cast< USHORT >( i ) + 1 ); + + // Enable passing by ref + if ( xSbxVar->GetType() != SbxVARIANT ) + xSbxVar->SetFlag( SBX_FIXED ); + } + } + if ( xSbxParams.Is() ) + pMethod->SetParameters( xSbxParams ); + + // call method + SbxVariableRef xReturn = new SbxVariable; + ErrCode nErr = SbxERR_OK; + + nErr = pMethod->Call( xReturn ); + Any aReturn; + // get output parameters + if ( xSbxParams.Is() ) + { + SbxInfo* pInfo_ = pMethod->GetInfo(); + if ( pInfo_ ) + { + OutParamMap aOutParamMap; + for ( USHORT n = 1, nCount = xSbxParams->Count(); n < nCount; ++n ) + { + const SbxParamInfo* pParamInfo = pInfo_->GetParam( n ); + if ( pParamInfo && ( pParamInfo->eType & SbxBYREF ) != 0 ) + { + SbxVariable* pVar = xSbxParams->Get( n ); + if ( pVar ) + { + SbxVariableRef xVar = pVar; + aOutParamMap.insert( OutParamMap::value_type( n - 1, sbxToUnoValue( xVar ) ) ); + } + } + } + sal_Int32 nOutParamCount = aOutParamMap.size(); + aOutParamIndex.realloc( nOutParamCount ); + aOutParam.realloc( nOutParamCount ); + sal_Int16* pOutParamIndex = aOutParamIndex.getArray(); + Any* pOutParam = aOutParam.getArray(); + for ( OutParamMap::iterator aIt = aOutParamMap.begin(); aIt != aOutParamMap.end(); ++aIt, ++pOutParamIndex, ++pOutParam ) + { + *pOutParamIndex = aIt->first; + *pOutParam = aIt->second; + } + } + } + + // get return value + aReturn = sbxToUnoValue( xReturn ); + + pMethod->SetParameters( NULL ); + + return aReturn; +} + +void SAL_CALL +DocObjectWrapper::setValue( const ::rtl::OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasProperty( aPropertyName ) ) + return m_xAggInv->setValue( aPropertyName, aValue ); + + SbPropertyRef pProperty = getProperty( aPropertyName ); + if ( !pProperty.Is() ) + throw UnknownPropertyException(); + unoToSbxValue( (SbxVariable*) pProperty, aValue ); +} + +Any SAL_CALL +DocObjectWrapper::getValue( const ::rtl::OUString& aPropertyName ) throw (UnknownPropertyException, RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasProperty( aPropertyName ) ) + return m_xAggInv->getValue( aPropertyName ); + + SbPropertyRef pProperty = getProperty( aPropertyName ); + if ( !pProperty.Is() ) + throw UnknownPropertyException(); + + SbxVariable* pProp = ( SbxVariable* ) pProperty; + if ( pProp->GetType() == SbxEMPTY ) + pProperty->Broadcast( SBX_HINT_DATAWANTED ); + + Any aRet = sbxToUnoValue( pProp ); + return aRet; +} + +::sal_Bool SAL_CALL +DocObjectWrapper::hasMethod( const ::rtl::OUString& aName ) throw (RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasMethod( aName ) ) + return sal_True; + return getMethod( aName ).Is(); +} + +::sal_Bool SAL_CALL +DocObjectWrapper::hasProperty( const ::rtl::OUString& aName ) throw (RuntimeException) +{ + sal_Bool bRes = sal_False; + if ( m_xAggInv.is() && m_xAggInv->hasProperty( aName ) ) + bRes = sal_True; + else bRes = getProperty( aName ).Is(); + return bRes; +} + +Any SAL_CALL DocObjectWrapper::queryInterface( const Type& aType ) + throw ( RuntimeException ) +{ + Any aRet = DocObjectWrapper_BASE::queryInterface( aType ); + if ( aRet.hasValue() ) + return aRet; + else if ( m_xAggProxy.is() ) + aRet = m_xAggProxy->queryAggregation( aType ); + return aRet; +} + +SbMethodRef DocObjectWrapper::getMethod( const rtl::OUString& aName ) throw (RuntimeException) +{ + SbMethodRef pMethod = NULL; + if ( m_pMod ) + { + USHORT nSaveFlgs = m_pMod->GetFlags(); + // Limit search to this module + m_pMod->ResetFlag( SBX_GBLSEARCH ); + pMethod = (SbMethod*) m_pMod->SbModule::Find( aName, SbxCLASS_METHOD ); + m_pMod->SetFlags( nSaveFlgs ); + } + + return pMethod; +} + +SbPropertyRef DocObjectWrapper::getProperty( const rtl::OUString& aName ) throw (RuntimeException) +{ + SbPropertyRef pProperty = NULL; + if ( m_pMod ) + { + USHORT nSaveFlgs = m_pMod->GetFlags(); + // Limit search to this module. + m_pMod->ResetFlag( SBX_GBLSEARCH ); + pProperty = (SbProperty*)m_pMod->SbModule::Find( aName, SbxCLASS_PROPERTY ); + m_pMod->SetFlag( nSaveFlgs ); + } + + return pProperty; +} TYPEINIT1(SbModule,SbxObject) TYPEINIT1(SbMethod,SbxMethod) @@ -199,12 +546,24 @@ SbModule::SbModule( const String& rName, BOOL bVBACompat ) SbModule::~SbModule() { + OSL_TRACE("Module named %s is destructing", rtl::OUStringToOString( GetName(), RTL_TEXTENCODING_UTF8 ).getStr() ); if( pImage ) delete pImage; if( pBreaks ) delete pBreaks; if( pClassData ) delete pClassData; + mxWrapper = NULL; +} + +uno::Reference< script::XInvocation > +SbModule::GetUnoModule() +{ + if ( !mxWrapper.is() ) + mxWrapper = new DocObjectWrapper( this ); + + OSL_TRACE("Module named %s returning wrapper mxWrapper (0x%x)", rtl::OUStringToOString( GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), mxWrapper.get() ); + return mxWrapper; } BOOL SbModule::IsCompiled() const diff --git a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx index 36102116c7b3..5bd58b44adaf 100644 --- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx +++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx @@ -133,11 +133,12 @@ protected: class VBAHELPER_DLLPUBLIC EnumerationHelperImpl : public EnumerationHelper_BASE { protected: + css::uno::WeakReference< ov::XHelperInterface > m_xParent; css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::container::XEnumeration > m_xEnumeration; public: - EnumerationHelperImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xContext( xContext ), m_xEnumeration( xEnumeration ) { } + EnumerationHelperImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration ) { } virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (css::uno::RuntimeException) { return m_xEnumeration->hasMoreElements(); } }; diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index 33613bb76091..a1eca84bbdf8 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -63,6 +63,7 @@ namespace ooo throw css::lang::IllegalArgumentException(); return aSomething; } + VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ); VBAHELPER_DLLPUBLIC SfxObjectShell* getSfxObjShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/vbahelper/vbaglobalbase.cxx b/vbahelper/source/vbahelper/vbaglobalbase.cxx index c7c33b93b1a3..b4b39344fd61 100644 --- a/vbahelper/source/vbahelper/vbaglobalbase.cxx +++ b/vbahelper/source/vbahelper/vbaglobalbase.cxx @@ -35,6 +35,9 @@ using namespace ooo::vba; rtl::OUString sApplication( RTL_CONSTASCII_USTRINGPARAM("Application") ); +// special key to return the Application +rtl::OUString sAppService( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.Application") ); + VbaGlobalsBase::VbaGlobalsBase( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sDocCtxName ) @@ -74,19 +77,30 @@ uno::Reference< uno::XInterface > SAL_CALL VbaGlobalsBase::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (uno::Exception, uno::RuntimeException) { uno::Reference< uno::XInterface > xReturn; - - if ( hasServiceName( aServiceSpecifier ) ) + if ( aServiceSpecifier.equals( sAppService ) ) + { + // try to extract the Application from the context + uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY ); + xNameContainer->getByName( sApplication ) >>= xReturn; + } + else if ( hasServiceName( aServiceSpecifier ) ) xReturn = mxContext->getServiceManager()->createInstanceWithContext( aServiceSpecifier, mxContext ); return xReturn; } uno::Reference< uno::XInterface > SAL_CALL -VbaGlobalsBase::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) throw (uno::Exception, uno::RuntimeException) +VbaGlobalsBase::createInstanceWithArguments( const ::rtl::OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) throw (uno::Exception, uno::RuntimeException) { uno::Reference< uno::XInterface > xReturn; - if ( hasServiceName( ServiceSpecifier ) ) - xReturn = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( ServiceSpecifier, Arguments, mxContext ); + if ( aServiceSpecifier.equals( sAppService ) ) + { + // try to extract the Application from the context + uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY ); + xNameContainer->getByName( sApplication ) >>= xReturn; + } + else if ( hasServiceName( aServiceSpecifier ) ) + xReturn = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( aServiceSpecifier, Arguments, mxContext ); return xReturn; } diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 1953d0772f3c..7cd82dff9536 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -1404,6 +1404,26 @@ void UserFormGeometryHelper::setHeight( double nHeight ) return points; } + uno::Reference< uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ) + { + uno::Reference< uno::XInterface > xIf; + if ( pShell ) + { + rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") ); + BasicManager* pBasMgr = pShell->GetBasicManager(); + if ( pBasMgr && pBasMgr->GetName().Len() ) + sProj = pShell->GetBasicManager()->GetName(); + StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ); + if ( pBasic ) + { + SbModule* pMod = pBasic->FindModule( aModName ); + if ( pMod ) + xIf = pMod->GetUnoModule(); + } + } + return xIf; + } + SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { SfxObjectShell* pFoundShell = NULL; -- cgit From d73100a4f9999f144ce5d9a8b64428fd9830da5e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 1 Jul 2010 18:24:05 +0200 Subject: sw33bf06: #i112566#: SfxViewShell_Impl::pPrinterController -> boost::shared_ptr --- sfx2/source/view/viewimp.hxx | 2 +- sfx2/source/view/viewprn.cxx | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx index 1c9e219cf180..be20cd2f2a47 100644 --- a/sfx2/source/view/viewimp.hxx +++ b/sfx2/source/view/viewimp.hxx @@ -75,7 +75,7 @@ struct SfxViewShell_Impl ::svt::AcceleratorExecute* pAccExec; com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aPrintOpts; ::rtl::Reference< SfxClipboardChangeListener > xClipboardListener; - vcl::PrinterController* pPrinterController; + ::boost::shared_ptr< vcl::PrinterController > m_pPrinterController; SfxViewShell_Impl(); }; diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index f62ae4c1ddc7..5b317e4b770b 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -332,7 +332,9 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt mpObjectShell->EnableSetModified( m_bOrigStatus ); if ( mpViewShell ) - mpViewShell->pImp->pPrinterController = 0; + { + mpViewShell->pImp->m_pPrinterController.reset(); + } } } @@ -643,7 +645,7 @@ void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro this, rProps ) ); - pImp->pPrinterController = pController.get(); + pImp->m_pPrinterController = pController; SfxObjectShell *pObjShell = GetObjectShell(); pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobName" ) ), @@ -661,7 +663,8 @@ void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro Printer* SfxViewShell::GetActivePrinter() const { - return pImp->pPrinterController ? pImp->pPrinterController->getPrinter().get() : 0; + return (pImp->m_pPrinterController) + ? pImp->m_pPrinterController->getPrinter().get() : 0; } void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) -- cgit From 1f3d1cba85b041abc7a0211effa099b68747b66f Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Fri, 2 Jul 2010 08:26:18 +0200 Subject: mib17: #111144# Fixed warning --- basic/source/classes/sbxmod.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 254e99c69da9..52076be8eece 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -147,7 +147,6 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); if ( pMod ) { - sal_Int16 nType = pMod->GetModuleType(); if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); -- cgit From 444742b5201b4036245348f6232a677038b6f057 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 2 Jul 2010 13:02:21 +0200 Subject: #i10000# internal dependency missing --- desktop/prj/build.lst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst index 8029b6ecc9f7..dc5d7a99b2d6 100644 --- a/desktop/prj/build.lst +++ b/desktop/prj/build.lst @@ -3,7 +3,7 @@ dt desktop usr1 - all dt_mkout NULL dt desktop\inc nmake - all dt_inc NULL dt desktop\prj get - all dt_prj NULL dt desktop\res get - all dt_res NULL -dt desktop\source\app nmake - all dt_app dt_migr dt_inc NULL +dt desktop\source\app nmake - all dt_app dt_migr dt_inc dt_dp_misc NULL dt desktop\source\migration nmake - all dt_migr dt_inc NULL dt desktop\source\migration\services nmake - all dt_services dt_inc dt_dp_misc NULL dt desktop\source\so_comp nmake - all dt_so_comp dt_inc NULL @@ -35,7 +35,7 @@ dt desktop\source\deployment\registry\configuration nmake - all dt_dp_registry_c dt desktop\source\deployment\registry\help nmake - all dt_dp_registry_help dt_inc NULL dt desktop\source\deployment\registry\executable nmake - all dt_dp_registry_executable dt_inc NULL dt desktop\scripts nmake - u dt_scripts dt_inc NULL -dt desktop\util nmake - all dt_util dt_app dt_so_comp dt_spl dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr dt_rebase.w NULL +dt desktop\util nmake - all dt_util dt_app dt_pagein.u dt_so_comp dt_spl dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr dt_rebase.w NULL dt desktop\zipintro nmake - all dt_zipintro NULL dt desktop\registry\data\org\openoffice\Office nmake - all sn_regconfig NULL dt desktop\source\registration\com\sun\star\servicetag\resources get - all sn_svctagres NULL -- cgit From de432231c123abae12659a4776047f11205f23db Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 2 Jul 2010 14:45:29 +0200 Subject: cws tl81: warning-free code --- editeng/source/editeng/editview.cxx | 1 - 1 file changed, 1 deletion(-) mode change 100755 => 100644 editeng/source/editeng/editview.cxx diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx old mode 100755 new mode 100644 index c07b84d0d0f2..664512df414e --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -1265,7 +1265,6 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack ) String aDicName ( pInsertMenu->GetItemText(nId) ); uno::Reference< linguistic2::XDictionary > xDic; - uno::Reference< linguistic2::XDictionaryList > xDicList( SvxGetDictionaryList() ); if (xDicList.is()) xDic = xDicList->getDictionaryByName( aDicName ); -- cgit From 0d4968c436f15c385ac454adc0f642e13434d78a Mon Sep 17 00:00:00 2001 From: tono Date: Sat, 3 Jul 2010 00:04:42 +0900 Subject: i#112734: MinGW port fix: sfx2 --- sfx2/source/doc/syspathw32.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfx2/source/doc/syspathw32.cxx b/sfx2/source/doc/syspathw32.cxx index 73bd84f5249a..c0a163bed39c 100644 --- a/sfx2/source/doc/syspathw32.cxx +++ b/sfx2/source/doc/syspathw32.cxx @@ -74,7 +74,7 @@ typedef unsigned short sal_uInt16; extern "C" bool GetUserTemplateLocation(sal_Unicode* pFolder, int nSize) { #ifdef WNT - return _SHGetSpecialFolderW32( CSIDL_TEMPLATES, pFolder, nSize ); + return _SHGetSpecialFolderW32( CSIDL_TEMPLATES, reinterpret_cast(pFolder), nSize ); #else (void)pFolder; (void)nSize; -- cgit From 2d0afbadabf572c04eab99876b71d99d0b7a59be Mon Sep 17 00:00:00 2001 From: tono Date: Sat, 3 Jul 2010 00:12:58 +0900 Subject: i#112777: DEV300_m84 MinGW basic/source/runtime build fail --- basic/source/runtime/dllmgr.cxx | 2 +- basic/source/runtime/wnt-mingw.s | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basic/source/runtime/dllmgr.cxx b/basic/source/runtime/dllmgr.cxx index bc08a8cb64bc..04f1ee0a8acc 100644 --- a/basic/source/runtime/dllmgr.cxx +++ b/basic/source/runtime/dllmgr.cxx @@ -684,7 +684,7 @@ Dll * SbiDllMgr::Impl::getDll(rtl::OUString const & name) { Dlls::iterator i(dlls.find(name)); if (i == dlls.end()) { i = dlls.insert(Dlls::value_type(name, new Dll)).first; - HMODULE h = LoadLibraryW(name); + HMODULE h = LoadLibraryW(reinterpret_cast(name.getStr())); if (h == 0) { dlls.erase(i); return 0; diff --git a/basic/source/runtime/wnt-mingw.s b/basic/source/runtime/wnt-mingw.s index 7868ddd386f0..8c332c1a8ce8 100644 --- a/basic/source/runtime/wnt-mingw.s +++ b/basic/source/runtime/wnt-mingw.s @@ -44,8 +44,8 @@ _DllMgr_callFp: shr ecx, 2 rep movsd $1: call DWORD PTR [ebp+8] - ; for extra safety, do not trust esp after call (in case the Basic Declare - ; signature is wrong): + # for extra safety, do not trust esp after call (in case the Basic Declare + # signature is wrong): mov edi, [ebp-8] mov esi, [ebp-4] mov esp, ebp -- cgit From d66c407d55c485552a47ce0a4951e64083460773 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Sun, 4 Jul 2010 11:38:02 +0200 Subject: #i110653# - bumped minor version to 3 --- desktop/util/ooverinfo2.rc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/desktop/util/ooverinfo2.rc b/desktop/util/ooverinfo2.rc index f149ec6474e7..8bc39767f04a 100644 --- a/desktop/util/ooverinfo2.rc +++ b/desktop/util/ooverinfo2.rc @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -25,26 +25,26 @@ * *************************************************************************/ -#define VERSION 3 -#define SUBVERSION 2 -//#define VERVARIANT 0 +#define VERSION 3 +#define SUBVERSION 3 +//#define VERVARIANT 0 // .0 + VER_CONCEPT // .100 + VER_ALPHA // .200 + VER_BETA // .300 + VER_GAMMA // .500 + VER_FINAL -//#define VER_CONCEPT 0 -//#define VER_BETA 6 -#define VER_FINAL 0 +//#define VER_CONCEPT 0 +//#define VER_BETA 6 +#define VER_FINAL 0 -#define VER_DAY 1 -#define VER_MONTH 9 -#define VER_YEAR 2009 +#define VER_DAY 1 +#define VER_MONTH 1 +#define VER_YEAR 2010 // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// language/character set specification table +// language/character set specification table // ----------------------------------------------------------------------- -- cgit From 985a3c7cc96f260024c8fbdb64c988fc5660e9a7 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 5 Jul 2010 11:20:24 +0200 Subject: ooo33gsl02: #i112873# change NativeWidget methods to be prepared for mapmodes --- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 12 ++++++------ desktop/source/splash/splash.cxx | 10 ++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 1a66ff38e4a4..87f70e449b9d 100755 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -1147,13 +1147,13 @@ void ExtMgrDialog::Resize() { ImplControlValue aValue; bool bNativeOK; - Region aControlRegion( Rectangle( (const Point&)Point(), m_aProgressBar.GetSizePixel() ) ); - Region aNativeControlRegion, aNativeContentRegion; + Rectangle aControlRegion( Point( 0, 0 ), m_aProgressBar.GetSizePixel() ); + Rectangle aNativeControlRegion, aNativeContentRegion; if( (bNativeOK = GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) != FALSE ) { - nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + nProgressHeight = aNativeControlRegion.GetHeight(); } } @@ -1590,13 +1590,13 @@ void UpdateRequiredDialog::Resize() { ImplControlValue aValue; bool bNativeOK; - Region aControlRegion( Rectangle( (const Point&)Point(), m_aProgressBar.GetSizePixel() ) ); - Region aNativeControlRegion, aNativeContentRegion; + Rectangle aControlRegion( Point( 0, 0 ), m_aProgressBar.GetSizePixel() ); + Rectangle aNativeControlRegion, aNativeContentRegion; if( (bNativeOK = GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) != FALSE ) { - nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + nProgressHeight = aNativeControlRegion.GetHeight(); } } diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 381a98ce008f..c6a185b8e54d 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -640,20 +640,18 @@ void SplashScreen::Paint( const Rectangle&) ImplControlValue aValue( _iProgress * _barwidth / _iMax); Rectangle aDrawRect( Point(_tlx, _tly), Size( _barwidth, _barheight ) ); - Region aControlRegion( aDrawRect ); - Region aNativeControlRegion, aNativeContentRegion; + Rectangle aNativeControlRegion, aNativeContentRegion; - if( GetNativeControlRegion( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aControlRegion, + if( GetNativeControlRegion( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) { - long nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + long nProgressHeight = aNativeControlRegion.GetHeight(); aDrawRect.Top() -= (nProgressHeight - _barheight)/2; aDrawRect.Bottom() += (nProgressHeight - _barheight)/2; - aControlRegion = Region( aDrawRect ); } - if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aControlRegion, + if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect, CTRL_STATE_ENABLED, aValue, _sProgressText )) != FALSE ) { return; -- cgit From ba994212ea43ea8f0e93a038646ca960221ad16d Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Mon, 5 Jul 2010 13:58:36 +0200 Subject: mib17: #i100659# Changed module variable handling --- basic/inc/basic/sbmod.hxx | 5 ++++- basic/source/classes/sbxmod.cxx | 28 ++++++++++++++++++++++++++++ basic/source/comp/sbcomp.cxx | 1 + basic/source/runtime/step2.cxx | 23 +++++++++++++++++------ 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index aeed4c2b6347..932a828ac753 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -33,6 +33,7 @@ #include #include #include +#include class SbMethod; class SbProperty; @@ -56,6 +57,7 @@ class SbModule : public SbxObject friend class SbClassModuleObject; SbModuleImpl* mpSbModuleImpl; // Impl data + std::vector< String > mModuleVariableNames; protected: com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper; @@ -133,7 +135,8 @@ public: INT32 GetModuleType() { return mnType; } void SetModuleType( INT32 nType ) { mnType = nType; } bool GetIsProxyModule() { return bIsProxyModule; } - ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); + void AddVarName( const String& aName ); + void RemoveVars(); ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); }; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 52076be8eece..de8071dacfa7 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -147,6 +147,7 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); if ( pMod ) { + sal_Int16 nType = pMod->GetModuleType(); if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); @@ -1242,6 +1243,33 @@ void SbModule::RunInit() } // Mit private/dim deklarierte Variablen loeschen + +void SbModule::AddVarName( const String& aName ) +{ + // see if the name is added allready + std::vector< String >::iterator it_end = mModuleVariableNames.end(); + for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it ) + { + if ( aName == *it ) + return; + } + mModuleVariableNames.push_back( aName ); +} + +void SbModule::RemoveVars() +{ + std::vector< String >::iterator it_end = mModuleVariableNames.end(); + for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it ) + { + // We don't want a Find being called in a derived class ( e.g. + // SbUserform because it could trigger say an initialise event + // which would cause basic to be re-run in the middle of the init ( and remember RemoveVars is called from compile and we don't want code to run as part of the compile ) + SbxVariableRef p = SbModule::Find( *it, SbxCLASS_PROPERTY ); + if( p.Is() ) + Remove (p); + } +} + void SbModule::ClearPrivateVars() { for( USHORT i = 0 ; i < pProps->Count() ; i++ ) diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 6e4f7ddf126e..50dc6f847076 100644 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -131,6 +131,7 @@ BOOL SbModule::Compile() if( bRet ) { pBasic->ClearAllModuleVars(); + RemoveVars(); // remove 'this' Modules variables // clear all method statics for( USHORT i = 0; i < pMethods->Count(); i++ ) { diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index 8e72fd2ac3c6..c9f344c57d32 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -1158,15 +1158,26 @@ void SbiRuntime::StepGLOBAL( UINT32 nOp1, UINT32 nOp2 ) StepPUBLIC_Impl( nOp1, nOp2, true ); String aName( pImg->GetString( static_cast( nOp1 ) ) ); - SbxDataType t = (SbxDataType)(SbxDataType)(nOp2 & 0xffff);; - BOOL bFlag = rBasic.IsSet( SBX_NO_MODIFY ); + SbxDataType t = (SbxDataType)(nOp2 & 0xffff);; + + // Store module scope variables at module scope + // in non vba mode these are stored at the library level :/ + // not sure if this really should not be enabled for ALL basic + SbxObject* pStorage = &rBasic; + if ( SbiRuntime::isVBAEnabled() ) + { + pStorage = pMod; + pMod->AddVarName( aName ); + } + + BOOL bFlag = pStorage->IsSet( SBX_NO_MODIFY ); rBasic.SetFlag( SBX_NO_MODIFY ); - SbxVariableRef p = rBasic.Find( aName, SbxCLASS_PROPERTY ); + SbxVariableRef p = pStorage->Find( aName, SbxCLASS_PROPERTY ); if( p.Is() ) - rBasic.Remove (p); - p = rBasic.Make( aName, SbxCLASS_PROPERTY, t ); + pStorage->Remove (p); + p = pStorage->Make( aName, SbxCLASS_PROPERTY, t ); if( !bFlag ) - rBasic.ResetFlag( SBX_NO_MODIFY ); + pStorage->ResetFlag( SBX_NO_MODIFY ); if( p ) { p->SetFlag( SBX_DONTSTORE ); -- cgit From bb09a0aa845e46c538bd62d0c7d95a57e4d1a7d9 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 6 Jul 2010 08:08:39 +0200 Subject: mib17: #i100659# Removed warning --- basic/source/classes/sbxmod.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index de8071dacfa7..51af5685d888 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -147,7 +147,6 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); if ( pMod ) { - sal_Int16 nType = pMod->GetModuleType(); if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); -- cgit From dba973219b95c52db4fd632ab642628d36084bdd Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 6 Jul 2010 15:59:41 +0200 Subject: mib17: #162898# Special handling for ByVal followed by StrPtr --- basic/source/comp/exprtree.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index 0cf0d9870378..9b6f419e15ce 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -971,11 +971,16 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa else { bool bByVal = false; + bool bByValBlockLValueError = false; if( eTok == BYVAL ) { bByVal = true; pParser->Next(); eTok = pParser->Peek(); + + // Special handling for VBA function "StrPtr" that's accepted as lvalue + if( eTok == SYMBOL && pParser->GetSym().EqualsIgnoreCaseAscii( "StrPtr" ) ) + bByValBlockLValueError = true; } if( bAssumeExprLParenMode ) @@ -1011,7 +1016,7 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa if( bByVal ) { - if( !pExpr->IsLvalue() ) + if( !pExpr->IsLvalue() && !bByValBlockLValueError ) pParser->Error( SbERR_LVALUE_EXPECTED ); else pExpr->SetByVal(); -- cgit From b687b636115b17970db28c389a8d28040ace86d1 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 6 Jul 2010 18:07:29 +0200 Subject: mib17: #162576# handle VBA UserForm_Resize and UserForm_Layout events --- basic/inc/basic/sbobjmod.hxx | 12 ++- basic/source/classes/sb.cxx | 21 ++---- basic/source/classes/sbxmod.cxx | 158 +++++++++++++++++++++++++++------------ basic/source/runtime/methods.cxx | 3 +- 4 files changed, 127 insertions(+), 67 deletions(-) diff --git a/basic/inc/basic/sbobjmod.hxx b/basic/inc/basic/sbobjmod.hxx index 3d638a475f9a..9ff46d1931f3 100644 --- a/basic/inc/basic/sbobjmod.hxx +++ b/basic/inc/basic/sbobjmod.hxx @@ -36,6 +36,7 @@ #ifndef _SB_OBJMOD_HXX #define _SB_OBJMOD_HXX +#include #include #include #include @@ -60,10 +61,12 @@ public: void SetUnoObject( const com::sun::star::uno::Any& aObj )throw ( com::sun::star::uno::RuntimeException ) ; }; +class FormObjEventListenerImpl; + class SbUserFormModule : public SbObjModule { com::sun::star::script::ModuleInfo m_mInfo; - css::uno::Reference m_DialogListener; + ::rtl::Reference< FormObjEventListenerImpl > m_DialogListener; css::uno::Reference m_xDialog; css::uno::Reference m_xModel; String sFormName; @@ -76,16 +79,19 @@ class SbUserFormModule : public SbObjModule public: TYPEINFO(); SbUserFormModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat ); + virtual ~SbUserFormModule(); virtual SbxVariable* Find( const XubString& rName, SbxClassType t ); void ResetApiObj(); void Unload(); - void load(); + void Load(); void triggerMethod( const String& ); void triggerMethod( const String&, css::uno::Sequence< css::uno::Any >& ); void triggerActivateEvent(); - void triggerDeActivateEvent(); + void triggerDeactivateEvent(); void triggerInitializeEvent(); void triggerTerminateEvent(); + void triggerLayoutEvent(); + void triggerResizeEvent(); class SbUserFormModuleInstance* CreateInstance(); }; diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 924a3ef2807f..9012471cac0a 100755 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -339,27 +339,18 @@ SbxBase* SbFormFactory::Create( UINT16, UINT32 ) SbxObject* SbFormFactory::CreateObject( const String& rClassName ) { - static String aLoadMethodName( RTL_CONSTASCII_USTRINGPARAM("load") ); - - SbxObject* pRet = NULL; - SbModule* pMod = pMOD; - if( pMod ) + if( SbModule* pMod = pMOD ) { - SbxVariable* pVar = pMod->Find( rClassName, SbxCLASS_OBJECT ); - if( pVar ) + if( SbxVariable* pVar = pMod->Find( rClassName, SbxCLASS_OBJECT ) ) { - SbxBase* pObj = pVar->GetObject(); - SbUserFormModule* pFormModule = PTR_CAST( SbUserFormModule, pObj ); - - if( pFormModule != NULL ) + if( SbUserFormModule* pFormModule = PTR_CAST( SbUserFormModule, pVar->GetObject() ) ) { - pFormModule->load(); - SbUserFormModuleInstance* pFormInstance = pFormModule->CreateInstance(); - pRet = pFormInstance; + pFormModule->Load(); + return pFormModule->CreateInstance(); } } } - return pRet; + return 0; } diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 51af5685d888..30d856fda40e 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,7 @@ using namespace com::sun::star::script; #include #include #include +#include #include #include #include @@ -1985,9 +1987,9 @@ SbObjModule::Find( const XubString& rName, SbxClassType t ) return pVar; } -typedef ::cppu::WeakImplHelper1< awt::XTopWindowListener > EventListener_BASE; +typedef ::cppu::WeakImplHelper2< awt::XTopWindowListener, awt::XWindowListener > FormObjEventListener_BASE; -class FormObjEventListenerImpl : public EventListener_BASE +class FormObjEventListenerImpl : public FormObjEventListener_BASE { SbUserFormModule* mpUserForm; uno::Reference< lang::XComponent > mxComponent; @@ -1997,39 +1999,57 @@ class FormObjEventListenerImpl : public EventListener_BASE sal_Bool mbShowing; FormObjEventListenerImpl(); // not defined FormObjEventListenerImpl(const FormObjEventListenerImpl&); // not defined + public: - FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : mpUserForm( pUserForm ), mxComponent( xComponent) , mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False ), mbShowing( sal_False ) + FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : + mpUserForm( pUserForm ), mxComponent( xComponent) , + mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False ), mbShowing( sal_False ) { if ( mxComponent.is() ) { - uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; - OSL_TRACE("*********** Registering the listener"); - xList->addTopWindowListener( this ); + OSL_TRACE("*********** Registering the listeners"); + try + { + uno::Reference< awt::XTopWindow >( mxComponent, uno::UNO_QUERY_THROW )->addTopWindowListener( this ); + } + catch( uno::Exception& ) {} + try + { + uno::Reference< awt::XWindow >( mxComponent, uno::UNO_QUERY_THROW )->addWindowListener( this ); + } + catch( uno::Exception& ) {} } } - ~FormObjEventListenerImpl() + virtual ~FormObjEventListenerImpl() { removeListener(); } - sal_Bool isShowing() { return mbShowing; } + + sal_Bool isShowing() const { return mbShowing; } + void removeListener() { - try + if ( mxComponent.is() && !mbDisposed ) { - if ( mxComponent.is() && !mbDisposed ) + OSL_TRACE("*********** Removing the listeners"); + try { - uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; - OSL_TRACE("*********** Removing the listener"); - xList->removeTopWindowListener( this ); - mxComponent = NULL; + uno::Reference< awt::XTopWindow >( mxComponent, uno::UNO_QUERY_THROW )->removeTopWindowListener( this ); } + catch( uno::Exception& ) {} + try + { + uno::Reference< awt::XWindow >( mxComponent, uno::UNO_QUERY_THROW )->removeWindowListener( this ); + } + catch( uno::Exception& ) {} } - catch( uno::Exception& ) {} + mxComponent.clear(); } + virtual void SAL_CALL windowOpened( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { - if ( mpUserForm ) + if ( mpUserForm ) { mbOpened = sal_True; mbShowing = sal_True; @@ -2076,12 +2096,23 @@ public: } //liuchen 2009-7-21 - virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { mbOpened = sal_False; mbShowing = sal_False; } - virtual void SAL_CALL windowMinimized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) {} - virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException){} + virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + mbOpened = sal_False; + mbShowing = sal_False; + } + + virtual void SAL_CALL windowMinimized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } + + virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } + virtual void SAL_CALL windowActivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { - if ( mpUserForm ) + if ( mpUserForm ) { mbActivated = sal_True; if ( mbOpened ) @@ -2094,18 +2125,38 @@ public: virtual void SAL_CALL windowDeactivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { - if ( mpUserForm ) - mpUserForm->triggerDeActivateEvent(); + if ( mpUserForm ) + mpUserForm->triggerDeactivateEvent(); } + virtual void SAL_CALL windowResized( const awt::WindowEvent& /*e*/ ) throw (uno::RuntimeException) + { + if ( mpUserForm ) + { + mpUserForm->triggerResizeEvent(); + mpUserForm->triggerLayoutEvent(); + } + } + + virtual void SAL_CALL windowMoved( const awt::WindowEvent& /*e*/ ) throw (uno::RuntimeException) + { + if ( mpUserForm ) + mpUserForm->triggerLayoutEvent(); + } + + virtual void SAL_CALL windowShown( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } + + virtual void SAL_CALL windowHidden( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } - virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (uno::RuntimeException) + virtual void SAL_CALL disposing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException) { OSL_TRACE("** Userform/Dialog disposing"); mbDisposed = true; - uno::Any aSource; - aSource <<= Source; - mxComponent = NULL; + mxComponent.clear(); if ( mpUserForm ) mpUserForm->ResetApiObj(); } @@ -2119,6 +2170,10 @@ SbUserFormModule::SbUserFormModule( const String& rName, const com::sun::star::s m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW ); } +SbUserFormModule::~SbUserFormModule() +{ +} + void SbUserFormModule::ResetApiObj() { if ( m_xDialog.is() ) // probably someone close the dialog window @@ -2181,23 +2236,22 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any void SbUserFormModule::triggerActivateEvent( void ) { - OSL_TRACE("**** entering SbUserFormModule::triggerActivate"); - triggerMethod( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserForm_activate") ) ); - OSL_TRACE("**** leaving SbUserFormModule::triggerActivate"); + OSL_TRACE("**** entering SbUserFormModule::triggerActivate"); + triggerMethod( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserForm_Activate") ) ); + OSL_TRACE("**** leaving SbUserFormModule::triggerActivate"); } -void SbUserFormModule::triggerDeActivateEvent( void ) +void SbUserFormModule::triggerDeactivateEvent( void ) { - OSL_TRACE("**** SbUserFormModule::triggerDeActivate"); - triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_DeActivate") ) ); + OSL_TRACE("**** SbUserFormModule::triggerDeactivate"); + triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_Deactivate") ) ); } void SbUserFormModule::triggerInitializeEvent( void ) - { if ( mbInit ) return; - OSL_TRACE("**** SbUserFormModule::triggerInitializeEvent"); + OSL_TRACE("**** SbUserFormModule::triggerInitializeEvent"); static String aInitMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Initialize") ); triggerMethod( aInitMethodName ); mbInit = true; @@ -2205,12 +2259,24 @@ void SbUserFormModule::triggerInitializeEvent( void ) void SbUserFormModule::triggerTerminateEvent( void ) { - OSL_TRACE("**** SbUserFormModule::triggerTerminateEvent"); + OSL_TRACE("**** SbUserFormModule::triggerTerminateEvent"); static String aTermMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Terminate") ); triggerMethod( aTermMethodName ); mbInit=false; } +void SbUserFormModule::triggerLayoutEvent( void ) +{ + static String aMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Layout") ); + triggerMethod( aMethodName ); +} + +void SbUserFormModule::triggerResizeEvent( void ) +{ + static String aMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Resize") ); + triggerMethod( aMethodName ); +} + SbUserFormModuleInstance* SbUserFormModule::CreateInstance() { SbUserFormModuleInstance* pInstance = new SbUserFormModuleInstance( this, GetName(), m_mInfo, IsVBACompat() ); @@ -2238,7 +2304,7 @@ SbxVariable* SbUserFormModuleInstance::Find( const XubString& rName, SbxClassTyp } -void SbUserFormModule::load() +void SbUserFormModule::Load() { OSL_TRACE("** load() "); // forces a load @@ -2276,21 +2342,20 @@ void SbUserFormModule::Unload() if( pMeth ) { OSL_TRACE("Attempting too run the UnloadObjectMethod"); - m_xDialog = NULL; //release ref to the uno object + m_xDialog.clear(); //release ref to the uno object SbxValues aVals; - FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() ); bool bWaitForDispose = true; // assume dialog is showing - if ( pFormListener ) + if ( m_DialogListener.get() ) { - bWaitForDispose = pFormListener->isShowing(); + bWaitForDispose = m_DialogListener->isShowing(); OSL_TRACE("Showing %d", bWaitForDispose ); } pMeth->Get( aVals); - if ( !bWaitForDispose ) - { - // we've either already got a dispose or we'er never going to get one + if ( !bWaitForDispose ) + { + // we've either already got a dispose or we'er never going to get one ResetApiObj(); - } // else wait for dispose + } // else wait for dispose OSL_TRACE("UnloadObject completed ( we hope )"); } } @@ -2328,9 +2393,8 @@ void SbUserFormModule::InitObject() pDocObject = new SbUnoObject( GetName(), uno::makeAny( xVBAFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.UserForm")), aArgs ) ) ); uno::Reference< lang::XComponent > xComponent( aArgs[ 1 ], uno::UNO_QUERY_THROW ); // remove old listener if it exists - FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() ); - if ( pFormListener ) - pFormListener->removeListener(); + if ( m_DialogListener.get() ) + m_DialogListener->removeListener(); m_DialogListener = new FormObjEventListenerImpl( this, xComponent ); triggerInitializeEvent(); diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 36fbda5c9097..1a60a5d79a45 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -4134,8 +4134,7 @@ RTLFUNC(Load) { if( pObj->IsA( TYPE( SbUserFormModule ) ) ) { - SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj; - pFormModule->load(); + ((SbUserFormModule*)pObj)->Load(); } else if( pObj->IsA( TYPE( SbxObject ) ) ) { -- cgit From c449069c0608be9f263392589cb2c91e44bc9e8b Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 6 Jul 2010 19:34:53 +0200 Subject: mib17: #i112634# add VBA sheet event handling, based on a patch from Noel Power --- oovbaapi/ooo/vba/excel/XApplication.idl | 1 + oovbaapi/ooo/vba/excel/makefile.mk | 2 +- oovbaapi/ooo/vba/word/makefile.mk | 2 +- sfx2/inc/sfx2/objsh.hxx | 1 + sfx2/source/doc/objserv.cxx | 24 +++ sfx2/source/view/viewprn.cxx | 18 ++ vbahelper/inc/vbahelper/vbaeventshelperbase.hxx | 165 +++++++++++++++ vbahelper/prj/d.lst | 1 + vbahelper/source/vbahelper/makefile.mk | 2 + vbahelper/source/vbahelper/vbaeventshelperbase.cxx | 229 +++++++++++++++++++++ 10 files changed, 443 insertions(+), 2 deletions(-) create mode 100755 vbahelper/inc/vbahelper/vbaeventshelperbase.hxx create mode 100755 vbahelper/source/vbahelper/vbaeventshelperbase.cxx diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl index 39693a37511c..6f513ae64577 100644 --- a/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/oovbaapi/ooo/vba/excel/XApplication.idl @@ -64,6 +64,7 @@ interface XApplication [attribute] any CutCopyMode; [attribute] any StatusBar; [attribute] long Cursor; + [attribute] boolean EnableEvents; void setDefaultFilePath([in] string DefaultFilePath) raises(com::sun::star::script::BasicErrorException); diff --git a/oovbaapi/ooo/vba/excel/makefile.mk b/oovbaapi/ooo/vba/excel/makefile.mk index 12dcf025e489..251588086701 100644 --- a/oovbaapi/ooo/vba/excel/makefile.mk +++ b/oovbaapi/ooo/vba/excel/makefile.mk @@ -29,7 +29,7 @@ PRJ=..$/..$/.. PRJNAME=oovapi TARGET=excel -PACKAGE=ooo$/vba$/Excel +PACKAGE=ooo$/vba$/excel # --- Settings ----------------------------------------------------- .INCLUDE : $(PRJ)$/util$/makefile.pmk diff --git a/oovbaapi/ooo/vba/word/makefile.mk b/oovbaapi/ooo/vba/word/makefile.mk index e3a19e678414..543e99f7c538 100644 --- a/oovbaapi/ooo/vba/word/makefile.mk +++ b/oovbaapi/ooo/vba/word/makefile.mk @@ -29,7 +29,7 @@ PRJ=..$/..$/.. PRJNAME=oovapi TARGET=word -PACKAGE=ooo$/vba$/Word +PACKAGE=ooo$/vba$/word # --- Settings ----------------------------------------------------- .INCLUDE : $(PRJ)$/util$/makefile.pmk diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index d514235cbfa2..49223c23de75 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -292,6 +292,7 @@ public: sal_Bool IsReadOnlyUI() const; void SetNoName(); sal_Bool IsInModalMode() const; + sal_Bool IsInPrepareClose() const; //Added by PengYunQuan for Validity Cell Range Picker diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index c063546da1c7..ae3b527ff7a6 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -100,6 +100,7 @@ #include #include #include +#include #include "helpid.hrc" @@ -489,6 +490,22 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) case SID_SAVEASDOC: case SID_SAVEDOC: { + // ask VBA emulation at document model whether to save the document + if( nId == SID_SAVEDOC || nId == SID_SAVEASDOC ) try + { + Reference< script::vba::XCoreEventProcessor > xEventProcessor( GetModel(), UNO_QUERY_THROW ); + xEventProcessor->processCoreVbaEvent( nId ); + } + catch( util::VetoException& ) + { + // VBA event handler indicates to cancel saving the document + rReq.SetReturnValue( SfxBoolItem( 0, TRUE ) ); + return; + } + catch( Exception& ) + { + } + //!! detaillierte Auswertung eines Fehlercodes SfxObjectShellRef xLock( this ); @@ -895,6 +912,13 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) rReq.Done(); } +//------------------------------------------------------------------------- + +sal_Bool SfxObjectShell::IsInPrepareClose() const +{ + return pImp->bInPrepareClose; +} + //-------------------------------------------------------------------- void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index f62ae4c1ddc7..faf392c90f32 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -29,6 +29,7 @@ #include "precompiled_sfx2.hxx" #include +#include #include #include "com/sun/star/view/XRenderable.hpp" @@ -697,6 +698,23 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) case SID_PRINTDOCDIRECT: { SfxObjectShell* pDoc = GetObjectShell(); + + // ask VBA emulation at document model whether to print the document + try + { + uno::Reference< script::vba::XCoreEventProcessor > xEventProcessor( pDoc->GetModel(), uno::UNO_QUERY_THROW ); + xEventProcessor->processCoreVbaEvent( nId ); + } + catch( util::VetoException& ) + { + // VBA event handler indicates to cancel printing the document + rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) ); + return; + } + catch( uno::Exception& ) + { + } + bool bDetectHidden = ( !bSilent && pDoc ); if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES ) break; diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx new file mode 100755 index 000000000000..a84b0e28f9db --- /dev/null +++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VBAHELPER_VBAEVENTSHELPERBASE_HXX +#define VBAHELPER_VBAEVENTSHELPERBASE_HXX + +#include +#include +#include +#include +#include +#include "vbahelper/vbahelper.hxx" + +namespace com { namespace sun { namespace star { + namespace uno { class XComponentContext; } +} } } + +// ============================================================================ + +typedef ::cppu::WeakImplHelper2< css::script::vba::XEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE; + +class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE +{ +public: + VbaEventsHelperBase( + const css::uno::Sequence< css::uno::Any >& rArgs, + const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~VbaEventsHelperBase(); + + // XEventProcessor + virtual void SAL_CALL setIgnoreEvents( sal_Bool bIgnoreEvents ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getIgnoreEvents() throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual void SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::script::provider::ScriptFrameworkErrorException, css::util::VetoException, css::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& aSource ) throw (css::uno::RuntimeException); + +protected: + // ------------------------------------------------------------------------ + + enum EventHandlerType { EVENTHANDLER_GLOBAL, EVENTHANDLER_DOCUMENT }; + struct EventHandlerInfo + { + sal_Int32 mnEventId; + ::rtl::OUString maMacroName; + EventHandlerType meType; + sal_Int32 mnCancelIndex; + css::uno::Any maUserData; + }; + + /** Registers a supported event handler. + + @param nEventId Event identifier from com.sun.star.script.vba.EventIdentifier. + @param pcMacroName Name of the associated VBA event handler macro. + @param eType Document event or global event. + @param nCancelIndex 0-based index of Cancel parameter, or -1. + @param rUserData User data for free usage in derived implementations. */ + void registerEventHandler( + sal_Int32 nEventId, + const sal_Char* pcMacroName, + EventHandlerType eType = EVENTHANDLER_DOCUMENT, + sal_Int32 nCancelIndex = -1, + const css::uno::Any& rUserData = css::uno::Any() ); + + /** Throws, if the passed sequence does not contain a value at the specified index. */ + static inline void checkArgument( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException) + { if( rArgs.getLength() <= nIndex ) throw css::lang::IllegalArgumentException(); } + + /** Throws, if the passed sequence does not contain a value of a specific at the specified index. */ + template< typename Type > + static inline void checkArgumentType( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException) + { if( (rArgs.getLength() <= nIndex) || !rArgs[ nIndex ].has< Type >() ) throw css::lang::IllegalArgumentException(); } + + // ------------------------------------------------------------------------ + + struct EventQueueEntry + { + sal_Int32 mnEventId; + css::uno::Sequence< css::uno::Any > maArgs; + inline /*implicit*/ EventQueueEntry( sal_Int32 nEventId ) : mnEventId( nEventId ) {} + inline EventQueueEntry( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) : mnEventId( nEventId ), maArgs( rArgs ) {} + }; + typedef ::std::deque< EventQueueEntry > EventQueue; + + /** Derived classes return whether event processing is enabled. Throws if + the instance is in an invalid state. */ + virtual bool implEventsEnabled() throw (css::uno::RuntimeException) = 0; + + /** Derived classes do additional prpeparations and return whether the + event handler has to be called. */ + virtual bool implPrepareEvent( + EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException) = 0; + + /** Derived classes have to return the argument list for the specified VBA event handler. */ + virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException) = 0; + + /** Derived classes may do additional postprocessing. Called even if the + event handler does not exist, or if an error occured during execution. */ + virtual void implPostProcessEvent( + EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, + bool bSuccess, + bool bCancel ) throw (css::uno::RuntimeException) = 0; + + /** Derived classes have to return the name of the Basic document module. */ + virtual ::rtl::OUString implGetDocumentModuleName( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException) = 0; + +private: + /** Returns the event handler info struct for the specified event, or throws. */ + const EventHandlerInfo& getEventHandlerInfo( sal_Int32 nEventId ) const throw (css::lang::IllegalArgumentException); + + /** Searches the event handler in the document and returns its full script path. */ + ::rtl::OUString getEventHandlerPath( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); + + /** Removes this instance from all broadcasters. */ + void stopListening(); + +protected: + css::uno::Reference< css::frame::XModel > mxModel; + SfxObjectShell* mpShell; + +private: + typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerMap; + + EventHandlerMap maEvents; + bool mbIgnoreEvents; + bool mbDisposed; +}; + +// ============================================================================ + +#endif diff --git a/vbahelper/prj/d.lst b/vbahelper/prj/d.lst index d683e97c8b90..2d20ab1f982d 100644 --- a/vbahelper/prj/d.lst +++ b/vbahelper/prj/d.lst @@ -26,3 +26,4 @@ mkdir: %_DEST%\inc%_EXT%\basic ..\inc\vbahelper\vbatextframe.hxx %_DEST%\inc%_EXT%\vbahelper\vbatextframe.hxx ..\inc\vbahelper\vbashaperange.hxx %_DEST%\inc%_EXT%\vbahelper\vbashaperange.hxx ..\inc\vbahelper\vbapagesetupbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbapagesetupbase.hxx +..\inc\vbahelper\vbaeventshelperbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbaeventshelperbase.hxx diff --git a/vbahelper/source/vbahelper/makefile.mk b/vbahelper/source/vbahelper/makefile.mk index 47ad44b3d0ed..22ed40a3adfa 100644 --- a/vbahelper/source/vbahelper/makefile.mk +++ b/vbahelper/source/vbahelper/makefile.mk @@ -65,6 +65,8 @@ SLOFILES=\ $(SLO)$/vbashaperange.obj \ $(SLO)$/vbatextframe.obj \ $(SLO)$/vbapagesetupbase.obj \ + $(SLO)$/vbaeventshelperbase.obj + # --- Targets ------------------------------------------------------- .INCLUDE : target.mk diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx new file mode 100755 index 000000000000..ea5448482a89 --- /dev/null +++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx @@ -0,0 +1,229 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vbahelper/vbaeventshelperbase.hxx" +#include + +using namespace ::com::sun::star; +using namespace ::ooo::vba; + +// ============================================================================ + +VbaEventsHelperBase::VbaEventsHelperBase( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& /*xContext*/ ) : + mpShell( 0 ), + mbIgnoreEvents( false ), + mbDisposed( false ) +{ + try + { + mxModel = getXSomethingFromArgs< frame::XModel >( rArgs, 0, false ); + mpShell = getSfxObjShell( mxModel ); + + // add dispose listener + uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW ); + xComponent->addEventListener( this ); + } + catch( uno::Exception& ) + { + } +} + +VbaEventsHelperBase::~VbaEventsHelperBase() +{ + stopListening(); +} + +void SAL_CALL VbaEventsHelperBase::setIgnoreEvents( sal_Bool bIgnoreEvents ) throw (uno::RuntimeException) +{ + mbIgnoreEvents = bIgnoreEvents; +} + +sal_Bool SAL_CALL VbaEventsHelperBase::getIgnoreEvents() throw (uno::RuntimeException) +{ + return mbIgnoreEvents; +} + +sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + // getEventHandlerInfo() throws, if unknown event dentifier has been passed + const EventHandlerInfo& rInfo = getEventHandlerInfo( nEventId ); + // getEventHandlerPath() searches for the macro in the document + return getEventHandlerPath( rInfo, rArgs ).getLength() > 0; +} + +void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) + throw (lang::IllegalArgumentException, script::provider::ScriptFrameworkErrorException, util::VetoException, uno::RuntimeException) +{ + /* Derived classes may add new event identifiers to be processed while + processing the original event. All unprocessed events are collected in + a queue. First element in the queue is the next event to be processed. */ + EventQueue aEventQueue; + aEventQueue.push_back( EventQueueEntry( nEventId, rArgs ) ); + + /* bEnabled will track if event processing is enabled. Every event handler + may disable handling of other events. */ + bool bEnabled = !mbIgnoreEvents; + + /* bCancel will contain the current Cancel value. It is possible that + multiple events will try to modify the Cancel value. Every event + handler receives the Cancel value of the previous event handler. */ + bool bCancel = false; + + /* bSuccess will change to true if at least one event handler has been + executed successfully. */ + bool bSuccess = false; + + /* Loop as long as there are more events to be processed, and as event + handling is still enabled. Derived classes may add new events to be + processed in the virtual implPrepareEvent() function. */ + while( bEnabled && !aEventQueue.empty() ) + { + /* Check that all class members are available, and that we are not + disposed (this may have happened at any time during execution of + the last event handler). */ + if( mbDisposed || !mxModel.is() || !mpShell ) + throw uno::RuntimeException(); + + // get info for next event + const EventHandlerInfo& rInfo = getEventHandlerInfo( aEventQueue.front().mnEventId ); + uno::Sequence< uno::Any > aEventArgs = aEventQueue.front().maArgs; + aEventQueue.pop_front(); + + // let derived classes decide whether event processing is still enabled + bEnabled = implEventsEnabled(); + // let derived classes prepare the event, they may add new events for next iteration + if( bEnabled && implPrepareEvent( aEventQueue, rInfo, aEventArgs ) ) + { + // search the event handler macro in the document + ::rtl::OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs ); + bool bEventSuccess = false; + if( aMacroPath.getLength() > 0 ) + { + // build the argument list + uno::Sequence< uno::Any > aVbaArgs = implBuildArgumentList( rInfo, aEventArgs ); + // insert current cancel value + if( rInfo.mnCancelIndex >= 0 ) + { + if( rInfo.mnCancelIndex >= aVbaArgs.getLength() ) + throw lang::IllegalArgumentException(); + aVbaArgs[ rInfo.mnCancelIndex ] <<= bCancel; + } + // execute the event handler + uno::Any aRet, aCaller; + bEventSuccess = executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller ); + // extract new cancel value + if( rInfo.mnCancelIndex >= 0 ) + { + if( rInfo.mnCancelIndex >= aVbaArgs.getLength() ) + throw lang::IllegalArgumentException(); + // cancel value may be boolean or any integer type, Any(bool) does not extract to sal_Int32 + bool bNewCancel = false; + sal_Int32 nNewCancel = 0; + if( aVbaArgs[ rInfo.mnCancelIndex ] >>= bNewCancel ) + bCancel = bNewCancel; + else if( aVbaArgs[ rInfo.mnCancelIndex ] >>= nNewCancel ) + bCancel = nNewCancel != 0; + } + } + // post processing (also, if event handler does not exist, or on error + implPostProcessEvent( aEventQueue, rInfo, bEventSuccess, bCancel ); + // global success, if at least one event handler succeeded + bSuccess |= bEventSuccess; + } + } + + // if event handlers want to cancel the event, do so regardless of any errors + if( bCancel ) + throw util::VetoException(); + + // if no event handler finished successfully, throw + if( !bSuccess ) + throw script::provider::ScriptFrameworkErrorException(); +} + +void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& /*aSource*/ ) throw (uno::RuntimeException) +{ + OSL_TRACE( "VbaEventsHelperBase::disposing" ); + stopListening(); + mbDisposed = true; +} + +// protected ------------------------------------------------------------------ + +void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId, + const sal_Char* pcMacroName, EventHandlerType eType, sal_Int32 nCancelIndex, const uno::Any& rUserData ) +{ + EventHandlerInfo& rInfo = maEvents[ nEventId ]; + rInfo.mnEventId = nEventId; + rInfo.maMacroName = ::rtl::OUString::createFromAscii( pcMacroName ); + rInfo.meType = eType; + rInfo.mnCancelIndex = nCancelIndex; + rInfo.maUserData = rUserData; +} + +// private -------------------------------------------------------------------- + +const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandlerInfo( + sal_Int32 nEventId ) const throw (lang::IllegalArgumentException) +{ + EventHandlerMap::const_iterator aIt = maEvents.find( nEventId ); + if( aIt == maEvents.end() ) + throw lang::IllegalArgumentException(); + return aIt->second; +} + +::rtl::OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo, + const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException) +{ + ::rtl::OUString aMacroName; + switch( rInfo.meType ) + { + case EVENTHANDLER_GLOBAL: + aMacroName = rInfo.maMacroName; + break; + case EVENTHANDLER_DOCUMENT: + aMacroName = ::rtl::OUStringBuffer( implGetDocumentModuleName( rInfo, rArgs ) ). + append( sal_Unicode( '.' ) ).append( rInfo.maMacroName ).makeStringAndClear(); + break; + } + return resolveVBAMacro( mpShell, aMacroName ).ResolvedMacro(); +} + +void VbaEventsHelperBase::stopListening() +{ + if( !mbDisposed ) try + { + uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW ); + xComponent->removeEventListener( this ); + } + catch( uno::Exception& ) + { + } +} + +// ============================================================================ -- cgit From 9b3ed7aa9162094b99fd3341c0432c94e659420b Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 7 Jul 2010 09:07:34 +0200 Subject: dba33g: handle of next and prior for count function corrected --- connectivity/source/drivers/file/FResultSet.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 265084be697f..421225b34935 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -1200,7 +1200,9 @@ BOOL OResultSet::Move(IResultSetHelper::Movement eCursorPosition, INT32 nOffset, break; } - if (m_nRowPos == 0) + if ( m_nRowPos < 0 ) + goto Error; + else if (m_nRowPos == 0) { // COUNT(*) in Ergebnisrow packen // (muss die erste und einzige Variable in der Row sein) -- cgit From b8d18edc25262dcd77c160d2910ac77e2d683a18 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 7 Jul 2010 09:32:11 +0200 Subject: mib17: #162901# fix Remove --- vbahelper/source/msforms/vbacontrols.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 1284b36be463..b7fad7d9372d 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -349,13 +349,16 @@ void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex ) } catch( uno::RuntimeException& ) { - throw; + // the exceptions are not rethrown, impossibility to find or remove the control is currently not reported + // since in most cases it means just that the controls is already not there, the VBA seems to do it in the same way + + // throw; } catch( uno::Exception& e ) { - throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), - uno::Reference< uno::XInterface >(), - uno::makeAny( e ) ); + // throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), + // uno::Reference< uno::XInterface >(), + // uno::makeAny( e ) ); } } -- cgit From cbd90787ccc28ff36fb439ae3e012d28688b2ecd Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Wed, 7 Jul 2010 14:58:53 +0200 Subject: mib17: #162916# No error if byval in calls isn't followed by lvalue --- basic/source/classes/disas.cxx | 2 ++ basic/source/comp/exprtree.cxx | 14 ++------------ basic/source/comp/sbcomp.cxx | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/basic/source/classes/disas.cxx b/basic/source/classes/disas.cxx index 7317005d74fe..87b4cad4e94b 100644 --- a/basic/source/classes/disas.cxx +++ b/basic/source/classes/disas.cxx @@ -153,6 +153,7 @@ static const char* pOp3[] = { "DCREATE_REDIMP", // Change dimensions of a user defined Object-Array (+StringId+StringId) "FIND_CM", // Search inside a class module (CM) to enable global search in time "PUBLIC_P", // Module global Variable (persisted between calls)(+StringID+Typ) + "FIND_STATIC", // local static var lookup (+StringID+Typ) }; static const char** pOps[3] = { pOp1, pOp2, pOp3 }; @@ -220,6 +221,7 @@ static const Func pOperand3[] = { &SbiDisas::Str2Op, // Redimensionate User defined Object-Array (+StringId+StringId) &SbiDisas::VarOp, // FIND_CM &SbiDisas::VarDefOp, // PUBLIC_P + &SbiDisas::VarOp, // FIND_STATIC }; // TODO: Why as method? Isn't a simple define sufficient? diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index 9b6f419e15ce..42969b98d0d8 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -971,16 +971,11 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa else { bool bByVal = false; - bool bByValBlockLValueError = false; if( eTok == BYVAL ) { bByVal = true; pParser->Next(); eTok = pParser->Peek(); - - // Special handling for VBA function "StrPtr" that's accepted as lvalue - if( eTok == SYMBOL && pParser->GetSym().EqualsIgnoreCaseAscii( "StrPtr" ) ) - bByValBlockLValueError = true; } if( bAssumeExprLParenMode ) @@ -1014,13 +1009,8 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa else pExpr = new SbiExpression( pParser ); - if( bByVal ) - { - if( !pExpr->IsLvalue() && !bByValBlockLValueError ) - pParser->Error( SbERR_LVALUE_EXPECTED ); - else - pExpr->SetByVal(); - } + if( bByVal && pExpr->IsLvalue() ) + pExpr->SetByVal(); //pExpr = bConst ? new SbiConstExpression( pParser ) // : new SbiExpression( pParser ); diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 50dc6f847076..faabba046c99 100644 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -67,7 +67,7 @@ void dbg_SaveDisassembly( SbModule* pModule ) ( OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY ); if( xSFI.is() ) { - String aFile( RTL_CONSTASCII_USTRINGPARAM("file:///d:/BasicAsm_") ); + String aFile( RTL_CONSTASCII_USTRINGPARAM("file:///d:/zBasic.Asm/Asm_") ); StarBASIC* pBasic = (StarBASIC*)pModule->GetParent(); if( pBasic ) { -- cgit From bf97aef60b98b7c72ebd494845d0bdfa0c54ef84 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 8 Jul 2010 12:45:25 +0200 Subject: dba33g: assertion when closing stream, only close either the input stream or output stream --- connectivity/source/commontools/FValue.cxx | 100 ++++++++++++++++----- .../source/drivers/hsqldb/HStorageAccess.cxx | 10 +-- connectivity/source/drivers/hsqldb/HStorageMap.cxx | 13 +-- 3 files changed, 89 insertions(+), 34 deletions(-) diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 2884e6179aaa..bb3ce9dbb13b 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -258,6 +258,7 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType) (*this) = getAny(); break; default: + (*this) = getAny(); OSL_ENSURE(0,"ORowSetValue:operator==(): UNSPUPPORTED TYPE!"); } } @@ -344,6 +345,12 @@ void ORowSetValue::free() TRACE_FREE( Any ) m_aValue.m_pValue = NULL; break; + default: + OSL_ENSURE(m_aValue.m_pString,"String pointer is null!"); + delete (Any*)m_aValue.m_pValue; + TRACE_FREE( Any ) + m_aValue.m_pValue = NULL; + break; } m_bNull = sal_True; @@ -849,7 +856,9 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const bRet = false; break; default: + bRet = false; OSL_ENSURE(0,"ORowSetValue::operator==(): UNSPUPPORTED TYPE!"); + break; } return bRet; } @@ -942,6 +951,8 @@ Any ORowSetValue::makeAny() const break; default: OSL_ENSURE(0,"ORowSetValue::makeAny(): UNSPUPPORTED TYPE!"); + rValue = getAny(); + break; } } return rValue; @@ -1032,6 +1043,12 @@ Any ORowSetValue::makeAny() const } } break; + default: + { + Any aValue = getAny(); + aValue >>= aRet; + break; + } } } return aRet; @@ -1104,8 +1121,11 @@ sal_Bool ORowSetValue::getBool() const bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (*static_cast(m_aValue.m_pValue) != sal_Int64(0)); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= bRet; + break; + } } } return bRet; @@ -1174,8 +1194,11 @@ sal_Int8 ORowSetValue::getInt8() const nRet = static_cast(*static_cast(m_aValue.m_pValue)); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1244,8 +1267,11 @@ sal_Int16 ORowSetValue::getInt16() const nRet = static_cast(*static_cast(m_aValue.m_pValue)); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1314,8 +1340,11 @@ sal_Int32 ORowSetValue::getInt32() const nRet = static_cast(*static_cast(m_aValue.m_pValue)); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1384,8 +1413,11 @@ sal_Int64 ORowSetValue::getLong() const nRet = *(sal_Int64*)m_aValue.m_pValue; break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1458,8 +1490,11 @@ float ORowSetValue::getFloat() const nRet = float(*(sal_Int64*)m_aValue.m_pValue); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1534,8 +1569,11 @@ double ORowSetValue::getDouble() const nRet = double(*(sal_Int64*)m_aValue.m_pValue); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aValue = getAny(); + aValue >>= nRet; + break; + } } } return nRet; @@ -1626,6 +1664,11 @@ void ORowSetValue::setFromDouble(const double& _rVal,sal_Int32 _nDatatype) TRACE_ALLOC( sal_Int64 ) } break; + default: + { + m_aValue.m_pValue = new Any(_rVal); + break; + } } m_eTypeKind = _nDatatype; } @@ -1692,7 +1735,11 @@ Sequence ORowSetValue::getSequence() const aSeq = *static_cast< Sequence*>(m_aValue.m_pValue); break; default: - ; + { + Any aValue = getAny(); + aValue >>= aSeq; + break; + } } } return aSeq; @@ -1734,8 +1781,11 @@ Sequence ORowSetValue::getSequence() const } break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aAnyValue = getAny(); + aAnyValue >>= aValue; + break; + } } } return aValue; @@ -1776,8 +1826,11 @@ Sequence ORowSetValue::getSequence() const aValue = *static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aAnyValue = getAny(); + aAnyValue >>= aValue; + break; + } } } return aValue; @@ -1826,8 +1879,11 @@ Sequence ORowSetValue::getSequence() const aValue = *static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue); break; default: - OSL_ENSURE(0,"Illegal conversion!"); - break; + { + Any aAnyValue = getAny(); + aAnyValue >>= aValue; + break; + } } } return aValue; @@ -2094,7 +2150,7 @@ void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const break; default: OSL_ENSURE( false, "ORowSetValue::fill: unsupported type!" ); - bReadData = false; + (*this) = _rValueSource.getObject(); break; } if ( bReadData && _bNullable && _rValueSource.wasNull() ) diff --git a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx index 1452df992a74..e7fab6acb6c0 100644 --- a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx @@ -234,7 +234,7 @@ jint read_from_storage_stream_into_buffer( JNIEnv * env, jobject /*obj_this*/,js if ( xIn.is() ) { jsize nLen = env->GetArrayLength(buffer); - if ( nLen < len ) + if ( nLen < len || len <= 0 ) { ThrowException( env, "java/io/IOException", @@ -439,21 +439,17 @@ void write_to_storage_stream_from_buffer( JNIEnv* env, jobject /*obj_this*/, jst if ( xOut.is() ) { jbyte *buf = env->GetByteArrayElements(buffer,NULL); -#ifdef HSQLDB_DBG - OSL_ENSURE(len <= env->GetArrayLength(buffer),"Length is greater than the buffer!"); -#endif - if (JNI_FALSE != env->ExceptionCheck()) { env->ExceptionClear(); OSL_ENSURE(0,"ExceptionClear"); } OSL_ENSURE(buf,"buf is NULL"); - if ( buf ) + if ( buf && len > 0 && len <= env->GetArrayLength(buffer)) { Sequence< ::sal_Int8 > aData(buf + off,len); - xOut->writeBytes(aData); env->ReleaseByteArrayElements(buffer, buf, JNI_ABORT); + xOut->writeBytes(aData); #ifdef HSQLDB_DBG if ( logger ) logger->write( aData.getConstArray(), len ); diff --git a/connectivity/source/drivers/hsqldb/HStorageMap.cxx b/connectivity/source/drivers/hsqldb/HStorageMap.cxx index afb4d0da2640..fe4e5d9ca12e 100644 --- a/connectivity/source/drivers/hsqldb/HStorageMap.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx @@ -61,13 +61,14 @@ namespace connectivity { try { - m_xStream.clear(); - m_xSeek.clear(); + m_xStream.clear(); + m_xSeek.clear(); if ( m_xInputStream.is() ) { m_xInputStream->closeInput(); - m_xInputStream.clear(); + m_xInputStream.clear(); } + /* this is done implicity by the closing of the input stream if ( m_xOutputStream.is() ) { m_xOutputStream->closeOutput(); @@ -83,11 +84,13 @@ namespace connectivity OSL_UNUSED( e ); OSL_ENSURE(0,"Could not dispose OutputStream"); } - m_xOutputStream.clear(); + m_xOutputStream.clear(); } + */ } - catch(Exception& ) + catch(Exception& ex) { + OSL_UNUSED( ex ); OSL_ENSURE(0,"Exception catched!"); } } -- cgit From 8300ef8db57da4dbf65a5b10323e1c909c41490b Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 8 Jul 2010 12:46:25 +0200 Subject: dba33g: assertion when closing stream, only close either the input stream or output stream --- connectivity/source/drivers/hsqldb/HStorageMap.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/connectivity/source/drivers/hsqldb/HStorageMap.cxx b/connectivity/source/drivers/hsqldb/HStorageMap.cxx index fe4e5d9ca12e..57ed88b1dda8 100644 --- a/connectivity/source/drivers/hsqldb/HStorageMap.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx @@ -68,8 +68,8 @@ namespace connectivity m_xInputStream->closeInput(); m_xInputStream.clear(); } - /* this is done implicity by the closing of the input stream - if ( m_xOutputStream.is() ) + // this is done implicity by the closing of the input stream + else if ( m_xOutputStream.is() ) { m_xOutputStream->closeOutput(); try @@ -86,7 +86,6 @@ namespace connectivity } m_xOutputStream.clear(); } - */ } catch(Exception& ex) { -- cgit From dd6ba6b64aec20d37a402bee233e742e29285e88 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 8 Jul 2010 21:33:48 +0200 Subject: mib17: #162917# let basic byte use one byte, let olebridge convert sequence to safearray correctly --- basic/source/classes/sbunoobj.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 basic/source/classes/sbunoobj.cxx diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx old mode 100644 new mode 100755 index e51a0c09270b..df13bc7ec571 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -911,7 +911,7 @@ Type getUnoTypeForSbxBaseType( SbxDataType eType ) case SbxVARIANT: aRetType = ::getCppuType( (Any*)0 ); break; //case SbxDATAOBJECT: break; case SbxCHAR: aRetType = ::getCppuType( (sal_Unicode*)0 ); break; - case SbxBYTE: aRetType = ::getCppuType( (sal_Int16*)0 ); break; + case SbxBYTE: aRetType = ::getCppuType( (sal_Int8*)0 ); break; case SbxUSHORT: aRetType = ::getCppuType( (sal_uInt16*)0 ); break; case SbxULONG: aRetType = ::getCppuType( (sal_uInt32*)0 ); break; //case SbxLONG64: break; -- cgit From 47ad9825590f931c574f83602b0745a122a79485 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 8 Jul 2010 22:10:20 +0200 Subject: hg commig -mmib17: --- vbahelper/source/msforms/vbacontrols.cxx | 20 ++++++++++++++------ vbahelper/source/msforms/vbauserform.cxx | 4 +++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index b7fad7d9372d..8d01687ef905 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -74,12 +74,20 @@ private: public: ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog ) { - mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); - uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls(); + try + { + mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls(); - msNames.realloc( sXControls.getLength() ); - for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i ) - SetArrayElementTo( sXControls[ i ], i ); + msNames.realloc( sXControls.getLength() ); + for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i ) + SetArrayElementTo( sXControls[ i ], i ); + } + catch( uno::Exception& ) + { + // accept the case when the dialog already does not exist + // in this case the wrapper should work in dummy mode + } } static rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl ) @@ -186,7 +194,7 @@ ScVbaControls::ScVbaControls( const uno::Reference< XHelperInterface >& xParent, const css::uno::Reference< awt::XControl >& xDialog ) : ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ) { - mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); + mxDialog.set( xDialog, uno::UNO_QUERY ); } uno::Reference< container::XEnumeration > diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index 1ce403fc19c3..2a4cecfc2338 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -185,7 +185,9 @@ ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::Runtime uno::Any SAL_CALL ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException) { - uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW ); + // if the dialog already closed we should do nothing, but the VBA will call methods of the Controls objects + // thus we have to provide a dummy object in this case + uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY ); uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) ); if ( index.hasValue() ) return uno::makeAny( xControls->Item( index, uno::Any() ) ); -- cgit From cfc1d8bdffb17985e35d8ae5b987acc1de664354 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 9 Jul 2010 07:19:45 +0200 Subject: dba33g: #i110825# applay patch to removed unused code --- connectivity/source/commontools/FValue.cxx | 15 +++++++++++---- connectivity/source/drivers/jdbc/Boolean.cxx | 17 ----------------- connectivity/source/drivers/jdbc/Object.cxx | 8 -------- connectivity/source/drivers/jdbc/String.cxx | 20 -------------------- connectivity/source/inc/java/lang/Boolean.hxx | 1 - connectivity/source/inc/java/lang/Object.hxx | 2 -- connectivity/source/inc/java/lang/String.hxx | 1 - 7 files changed, 11 insertions(+), 53 deletions(-) diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index bb3ce9dbb13b..aca181916b47 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -345,11 +345,18 @@ void ORowSetValue::free() TRACE_FREE( Any ) m_aValue.m_pValue = NULL; break; + case DataType::BIT: + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::BOOLEAN: + break; default: - OSL_ENSURE(m_aValue.m_pString,"String pointer is null!"); - delete (Any*)m_aValue.m_pValue; - TRACE_FREE( Any ) - m_aValue.m_pValue = NULL; + if ( m_aValue.m_pValue ) + { + delete (Any*)m_aValue.m_pValue; + TRACE_FREE( Any ) + m_aValue.m_pValue = NULL; + } break; } diff --git a/connectivity/source/drivers/jdbc/Boolean.cxx b/connectivity/source/drivers/jdbc/Boolean.cxx index 2df75283a14b..fd52f3092c0e 100644 --- a/connectivity/source/drivers/jdbc/Boolean.cxx +++ b/connectivity/source/drivers/jdbc/Boolean.cxx @@ -49,20 +49,3 @@ jclass java_lang_Boolean::getMyClass() const { return st_getMyClass(); } - -java_lang_Boolean::java_lang_Boolean( sal_Bool _par0 ): java_lang_Object( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - // Java-Call fuer den Konstruktor absetzen - // temporaere Variable initialisieren - static const char * cSignature = "(Z)V"; - jobject tempObj; - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, "",cSignature, mID); - tempObj = t.pEnv->NewObject( getMyClass(), mID, _par0 ); - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); - // und aufraeumen -} - - diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx index 4866781d23dd..4f5670ace8aa 100644 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -166,14 +166,6 @@ void java_lang_Object::saveRef( JNIEnv * pXEnv, jobject myObj ) } -java_lang_Class * java_lang_Object::getClass() -{ - SDBThreadAttach t; - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getClass","()Ljava/lang/Class;", mID); - return out ? new java_lang_Class( t.pEnv, out ) : NULL; -} - ::rtl::OUString java_lang_Object::toString() const { static jmethodID mID(NULL); diff --git a/connectivity/source/drivers/jdbc/String.cxx b/connectivity/source/drivers/jdbc/String.cxx index e6102fc3a471..f32b0cce4325 100644 --- a/connectivity/source/drivers/jdbc/String.cxx +++ b/connectivity/source/drivers/jdbc/String.cxx @@ -51,26 +51,6 @@ jclass java_lang_String::st_getMyClass() return theClass; } -//-------------------------------------------------------------------------- -java_lang_String::java_lang_String( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - if( !t.pEnv ) - return; - jvalue args[1]; - // Parameter konvertieren - args[0].l = convertwchar_tToJavaString(t.pEnv,_par0); - // Java-Call fuer den Konstruktor absetzen - // temporaere Variable initialisieren - static const char * cSignature = "(Ljava/lang/String;)V"; - jobject tempObj; - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, "",cSignature, mID); - tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args ); - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); - t.pEnv->DeleteLocalRef((jstring)args[0].l); -} //-------------------------------------------------------------------------- java_lang_String::operator ::rtl::OUString() { diff --git a/connectivity/source/inc/java/lang/Boolean.hxx b/connectivity/source/inc/java/lang/Boolean.hxx index f1f8081d9780..35655f8c1934 100644 --- a/connectivity/source/inc/java/lang/Boolean.hxx +++ b/connectivity/source/inc/java/lang/Boolean.hxx @@ -44,7 +44,6 @@ namespace connectivity // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: java_lang_Boolean( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} - java_lang_Boolean( sal_Bool _par0 ); static jclass st_getMyClass(); }; } diff --git a/connectivity/source/inc/java/lang/Object.hxx b/connectivity/source/inc/java/lang/Object.hxx index f0bacc2ee840..c00c5e67e06d 100644 --- a/connectivity/source/inc/java/lang/Object.hxx +++ b/connectivity/source/inc/java/lang/Object.hxx @@ -118,8 +118,6 @@ namespace connectivity void clearObject(JNIEnv& rEnv); void clearObject(); - java_lang_Class * getClass(); - virtual ::rtl::OUString toString() const; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() { return m_xFactory; } diff --git a/connectivity/source/inc/java/lang/String.hxx b/connectivity/source/inc/java/lang/String.hxx index 64584dab5e76..3e4bfd6c1399 100644 --- a/connectivity/source/inc/java/lang/String.hxx +++ b/connectivity/source/inc/java/lang/String.hxx @@ -42,7 +42,6 @@ namespace connectivity // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: java_lang_String( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} - java_lang_String( const ::rtl::OUString& _par0 ); operator ::rtl::OUString(); static jclass st_getMyClass(); -- cgit From 084fbb9e5e3c5cba2f00b7eaf9dad5b61ff62b6f Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 9 Jul 2010 14:49:18 +0200 Subject: dba33g: #i112213# handle chart import for columns --- connectivity/source/drivers/ado/AResultSet.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index c71d620d527c..0c5db12c3355 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -692,6 +692,10 @@ void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeExcept void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException) { + // ::osl::MutexGuard aGuard( m_aMutex ); + //checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + // if ( getResultSetConcurrency() == ResultSetConcurrency::READ_ONLY ) + // throw SQLException(); } // ------------------------------------------------------------------------- @@ -977,7 +981,7 @@ Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& ro sal_Int32 OResultSet::getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { - sal_Int32 nValue=0; + sal_Int32 nValue=ResultSetConcurrency::READ_ONLY; LockTypeEnum eRet; if(!SUCCEEDED(m_pRecordSet->get_LockType(&eRet))) { -- cgit From bb51dc29f50476471308159c97c25fa059dcd17a Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Sat, 10 Jul 2010 17:13:52 +0200 Subject: mib17: #i110746# fixed memory leaks --- vbahelper/inc/vbahelper/vbaglobalbase.hxx | 4 +-- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 1 - vbahelper/source/vbahelper/vbaglobalbase.cxx | 33 ++++++++++++++++++++--- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/vbahelper/inc/vbahelper/vbaglobalbase.hxx b/vbahelper/inc/vbahelper/vbaglobalbase.hxx index e75cbb7e7af8..61aaa1d65657 100644 --- a/vbahelper/inc/vbahelper/vbaglobalbase.hxx +++ b/vbahelper/inc/vbahelper/vbaglobalbase.hxx @@ -32,16 +32,16 @@ typedef InheritedHelperInterfaceImpl1< ov::XGlobalsBase > Globals_BASE; class VBAHELPER_DLLPUBLIC VbaGlobalsBase : public Globals_BASE - { protected: + rtl::OUString msDocCtxName; bool hasServiceName( const rtl::OUString& serviceName ); void init( const css::uno::Sequence< css::beans::PropertyValue >& aInitArgs ); public: VbaGlobalsBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sDocCtxName ); - virtual ~VbaGlobalsBase(){}; + virtual ~VbaGlobalsBase(); // XMultiServiceFactory virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (css::uno::Exception, css::uno::RuntimeException); virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) throw (css::uno::Exception, css::uno::RuntimeException); diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 213133998def..8af75a6bd043 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -182,7 +182,6 @@ VbaApplicationBase::VbaApplicationBase( const uno::Reference< uno::XComponentCon VbaApplicationBase::~VbaApplicationBase() { - m_pImpl = 0; delete m_pImpl; } diff --git a/vbahelper/source/vbahelper/vbaglobalbase.cxx b/vbahelper/source/vbahelper/vbaglobalbase.cxx index b4b39344fd61..e0df37583df5 100644 --- a/vbahelper/source/vbahelper/vbaglobalbase.cxx +++ b/vbahelper/source/vbahelper/vbaglobalbase.cxx @@ -41,19 +41,44 @@ rtl::OUString sAppService( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.Application") ); VbaGlobalsBase::VbaGlobalsBase( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sDocCtxName ) -: Globals_BASE( xParent, xContext ) +: Globals_BASE( xParent, xContext ), msDocCtxName( sDocCtxName ) { // overwrite context with custom one ( that contains the application ) + // wrap the service manager as we don't want the disposing context to tear down the 'normal' ServiceManager ( or at least thats what the code appears like it wants to do ) + uno::Any aSrvMgr; + if ( xContext.is() && xContext->getServiceManager().is() ) + { + aSrvMgr = uno::makeAny( xContext->getServiceManager()->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.OServiceManagerWrapper") ), xContext ) ); + } + ::cppu::ContextEntry_Init aHandlerContextInfo[] = { ::cppu::ContextEntry_Init( sApplication, uno::Any() ), ::cppu::ContextEntry_Init( sDocCtxName, uno::Any() ), + ::cppu::ContextEntry_Init( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.lang.theServiceManager" ) ), aSrvMgr ) }; - - mxContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), xContext ); - + // don't pass a delegate, this seems to introduce yet another cyclic dependency ( and + // some strange behavior + mxContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), NULL ); } +VbaGlobalsBase::~VbaGlobalsBase() +{ + try + { + uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY ); + if ( xNameContainer.is() ) + { + // release document reference ( we don't wan't the component context trying to dispose that ) + xNameContainer->removeByName( msDocCtxName ); + // release application reference, as it is holding onto the context + xNameContainer->removeByName( sApplication ); + } + } + catch ( const uno::Exception& ) + { + } +} void VbaGlobalsBase::init( const uno::Sequence< beans::PropertyValue >& aInitArgs ) -- cgit From 7aa177e87e43d6db6134cd08282181f905a4dcf1 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 12 Jul 2010 09:09:07 +0200 Subject: mib17: #162973# implementation of 'Empty' symbol from AB --- basic/source/runtime/props.cxx | 7 +++++++ basic/source/runtime/rtlproto.hxx | 1 + basic/source/runtime/stdobj.cxx | 1 + 3 files changed, 9 insertions(+) diff --git a/basic/source/runtime/props.cxx b/basic/source/runtime/props.cxx index cec74444e7a2..663d12fbcd72 100644 --- a/basic/source/runtime/props.cxx +++ b/basic/source/runtime/props.cxx @@ -76,6 +76,13 @@ RTLFUNC(False) rPar.Get(0)->PutBool( FALSE ); } +RTLFUNC(Empty) +{ + (void)pBasic; + (void)bWrite; + (void)rPar; +} + RTLFUNC(Nothing) { (void)pBasic; diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx index 1a1ae4f32283..5437654f69a0 100644 --- a/basic/source/runtime/rtlproto.hxx +++ b/basic/source/runtime/rtlproto.hxx @@ -38,6 +38,7 @@ extern RTLFUNC(Date); extern RTLFUNC(Err); extern RTLFUNC(Erl); extern RTLFUNC(False); +extern RTLFUNC(Empty); extern RTLFUNC(Nothing); extern RTLFUNC(Null); extern RTLFUNC(True); diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 60d2e9cf448d..4455901bfeba 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -221,6 +221,7 @@ static Methods aMethods[] = { { "FileSpec", SbxSTRING, 0,NULL,0 }, { "DumpAll", SbxINTEGER, _OPT, NULL,0 }, +{ "Empty", SbxVARIANT, _CPROP, RTLNAME(Empty),0 }, { "EqualUnoObjects",SbxBOOL, 2 | _FUNCTION, RTLNAME(EqualUnoObjects),0 }, { "Variant", SbxVARIANT, 0,NULL,0 }, { "Variant", SbxVARIANT, 0,NULL,0 }, -- cgit From adf3c10549e3a755f8705e3b97939f4488ee7381 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 12 Jul 2010 11:17:00 +0200 Subject: mib17: #i112634# API changes --- vbahelper/inc/vbahelper/vbaeventshelperbase.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx index a84b0e28f9db..b7216746c81d 100755 --- a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx +++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx @@ -29,7 +29,7 @@ #define VBAHELPER_VBAEVENTSHELPERBASE_HXX #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ namespace com { namespace sun { namespace star { // ============================================================================ -typedef ::cppu::WeakImplHelper2< css::script::vba::XEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE; +typedef ::cppu::WeakImplHelper2< css::script::vba::XVBAEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE; class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE { @@ -51,7 +51,7 @@ public: const css::uno::Reference< css::uno::XComponentContext >& xContext ); virtual ~VbaEventsHelperBase(); - // XEventProcessor + // XVBAEventProcessor virtual void SAL_CALL setIgnoreEvents( sal_Bool bIgnoreEvents ) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getIgnoreEvents() throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); -- cgit From 59e208d9037efc74525de69c2a892a30e61648c5 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Mon, 12 Jul 2010 19:32:20 +0200 Subject: calc56: #i102690# correct attribute names diagonal-bl-tr-widths and diagonal-tl-br-widths --- xmloff/inc/xmloff/xmltoken.hxx | 3 +++ xmloff/source/core/xmltoken.cxx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index d892c10f4f5d..f4843d54ace1 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -3107,6 +3107,9 @@ namespace xmloff { namespace token { XML_N_CHART_EXT, XML_COORDINATE_REGION, + XML_DIAGONAL_BL_TR_WIDTHS, + XML_DIAGONAL_TL_BR_WIDTHS, + XML_TOKEN_END }; diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 2e92c4a6a97d..a3d4a0c48d02 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3107,6 +3107,9 @@ namespace xmloff { namespace token { TOKEN( "http://openoffice.org/2010/chart", XML_N_CHART_EXT ), TOKEN( "coordinate-region", XML_COORDINATE_REGION ), + TOKEN( "diagonal-bl-tr-widths", XML_DIAGONAL_BL_TR_WIDTHS ), + TOKEN( "diagonal-tl-br-widths", XML_DIAGONAL_TL_BR_WIDTHS ), + #if OSL_DEBUG_LEVEL > 0 { 0, NULL, NULL, XML_TOKEN_END } #else -- cgit From 3ff5cbc45f24f6edead8957dd889817d1f4f23b0 Mon Sep 17 00:00:00 2001 From: sj Date: Wed, 14 Jul 2010 13:47:44 +0200 Subject: impress194: #i109282# applied patch (reading negative enhanced-path parameter) --- xmloff/source/draw/ximpcustomshape.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index 9d7856348516..98255edf68d0 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -708,6 +708,7 @@ void GetEnhancedPath( std::vector< com::sun::star::beans::PropertyValue >& rDest case '8' : case '9' : case '.' : + case '-' : { com::sun::star::drawing::EnhancedCustomShapeParameterPair aPair; if ( GetNextParameter( aPair.First, nIndex, rValue ) && -- cgit From 10bd37c4ce83606833f4addb1832600380e175a6 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 14 Jul 2010 14:35:59 +0200 Subject: dba33g: #i110067# correct word occurred --- connectivity/source/resource/conn_shared_res.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src index 87f69a4aabd0..3c384cbaa232 100644 --- a/connectivity/source/resource/conn_shared_res.src +++ b/connectivity/source/resource/conn_shared_res.src @@ -131,7 +131,7 @@ String STR_STMT_TYPE_NOT_SUPPORTED String STR_UNSPECIFIED_ERROR { - Text [ en-US ] = "An unknown error occured."; + Text [ en-US ] = "An unknown error occurred."; }; String STR_COULD_NOT_CREATE_ADDRESSBOOK -- cgit From aa183d45c83d5465ad77e8902e2314f2477ba2c5 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 14 Jul 2010 14:17:11 +0100 Subject: emailmerge33fix: #i113134# --- scripting/source/pyprov/mailmerge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py index 55c204f87dbf..6592a59d1843 100644 --- a/scripting/source/pyprov/mailmerge.py +++ b/scripting/source/pyprov/mailmerge.py @@ -153,8 +153,8 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): if len(textbody): mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType) - if mimeEncoding.find('charset=UTF-8') == -1: - mimeEncoding = mimeEncoding + "; charset=UTF-8" + if mimeEncoding.find('charset=UTF-8') == -1: + mimeEncoding = mimeEncoding + "; charset=UTF-8" textmsg['Content-Type'] = mimeEncoding textmsg['MIME-Version'] = '1.0' textmsg.set_payload(textbody) -- cgit From a95d6a3fb831f13fefd316e5147fb183e8ed3b0d Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 14 Jul 2010 15:25:10 +0200 Subject: dba33g: #i111345# handle string sep corrected --- connectivity/source/drivers/flat/ETable.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index eff2464ce533..70be592405eb 100644 --- a/connectivity/source/drivers/flat/ETable.cxx +++ b/connectivity/source/drivers/flat/ETable.cxx @@ -159,7 +159,10 @@ void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) (m_cStringDelimiter && m_cStringDelimiter == aField.GetChar(0))) { bNumeric = FALSE; - nStartPosFirstLine2 = nStartPosFirstLine; + if ( m_cStringDelimiter != '\0' ) + aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine2,m_cFieldDelimiter,m_cStringDelimiter); + else + nStartPosFirstLine2 = nStartPosFirstLine; } else { -- cgit From 0348b3a8bcec9ec8a6b06be61bdd997b835efd16 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Wed, 14 Jul 2010 15:34:49 +0200 Subject: dba33g: #i110067# reverting --- connectivity/source/resource/conn_shared_res.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src index 3c384cbaa232..87f69a4aabd0 100644 --- a/connectivity/source/resource/conn_shared_res.src +++ b/connectivity/source/resource/conn_shared_res.src @@ -131,7 +131,7 @@ String STR_STMT_TYPE_NOT_SUPPORTED String STR_UNSPECIFIED_ERROR { - Text [ en-US ] = "An unknown error occurred."; + Text [ en-US ] = "An unknown error occured."; }; String STR_COULD_NOT_CREATE_ADDRESSBOOK -- cgit From 07daaab0760e97b8449ec7f123b005d7b4e4a94a Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 15 Jul 2010 07:46:31 +0200 Subject: dba33g: #i111345# wrong error message used when opening invalid table format --- connectivity/source/drivers/dbase/DTable.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 8544e4affda7..157d1f7b68fa 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -2607,7 +2607,7 @@ void ODbaseTable::throwInvalidDbaseFormat() // no dbase file const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution( - STR_SQL_NAME_ERROR, + STR_INVALID_DBASE_FILE, "$filename$", getEntry(m_pConnection,m_Name) ) ); ::dbtools::throwGenericSQLException( sError, *this ); -- cgit From dfb885a53b8e92b766f13b8f67660f0b58882761 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 15 Jul 2010 14:30:44 +0200 Subject: mib17: #i112634# do not use an UNO interface to handle VBA BeforeSave and BeforePrint events --- sfx2/inc/sfx2/objsh.hxx | 3 +++ sfx2/source/doc/objserv.cxx | 23 +++-------------------- sfx2/source/doc/objstor.cxx | 7 +++++++ sfx2/source/doc/objxtor.cxx | 7 +++++++ sfx2/source/view/viewprn.cxx | 14 ++------------ 5 files changed, 22 insertions(+), 32 deletions(-) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 49223c23de75..abe6a8068513 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -346,6 +346,9 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); virtual void UpdateLinks(); + // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action + virtual sal_Bool QuerySlotExecutable( USHORT nSlotId ); + sal_Bool SaveChildren(BOOL bObjectsOnly=FALSE); sal_Bool SaveAsChildren( SfxMedium &rMedium ); sal_Bool SwitchChildrenPersistance( diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index ae3b527ff7a6..066f366b09bd 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -100,7 +100,6 @@ #include #include #include -#include #include "helpid.hrc" @@ -490,21 +489,12 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) case SID_SAVEASDOC: case SID_SAVEDOC: { - // ask VBA emulation at document model whether to save the document - if( nId == SID_SAVEDOC || nId == SID_SAVEASDOC ) try + // derived class may decide to abort this + if( !QuerySlotExecutable( nId ) ) { - Reference< script::vba::XCoreEventProcessor > xEventProcessor( GetModel(), UNO_QUERY_THROW ); - xEventProcessor->processCoreVbaEvent( nId ); - } - catch( util::VetoException& ) - { - // VBA event handler indicates to cancel saving the document - rReq.SetReturnValue( SfxBoolItem( 0, TRUE ) ); + rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) ); return; } - catch( Exception& ) - { - } //!! detaillierte Auswertung eines Fehlercodes SfxObjectShellRef xLock( this ); @@ -914,13 +904,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) //------------------------------------------------------------------------- -sal_Bool SfxObjectShell::IsInPrepareClose() const -{ - return pImp->bInPrepareClose; -} - -//-------------------------------------------------------------------- - void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) { DBG_CHKTHIS(SfxObjectShell, 0); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 6e1d89f2a8cd..e1b22ca26a22 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -195,6 +195,13 @@ sal_Bool SfxObjectShell::SaveAs( SfxMedium& rMedium ) //------------------------------------------------------------------------- +sal_Bool SfxObjectShell::QuerySlotExecutable( USHORT /*nSlotId*/ ) +{ + return sal_True; +} + +//------------------------------------------------------------------------- + sal_Bool GetPasswd_Impl( const SfxItemSet* pSet, ::rtl::OUString& rPasswd ) { const SfxPoolItem* pItem = NULL; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 6502eeaeb78c..f8b6cfe44407 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -524,6 +524,13 @@ SfxObjectShell* SfxObjectShell::Current() return pFrame ? pFrame->GetObjectShell() : 0; } +//------------------------------------------------------------------------- + +sal_Bool SfxObjectShell::IsInPrepareClose() const +{ + return pImp->bInPrepareClose; +} + //------------------------------------------------------------------------ struct BoolEnv_Impl diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index faf392c90f32..227099e7d783 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -29,7 +29,6 @@ #include "precompiled_sfx2.hxx" #include -#include #include #include "com/sun/star/view/XRenderable.hpp" @@ -699,21 +698,12 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { SfxObjectShell* pDoc = GetObjectShell(); - // ask VBA emulation at document model whether to print the document - try + // derived class may decide to abort this + if( !pDoc->QuerySlotExecutable( nId ) ) { - uno::Reference< script::vba::XCoreEventProcessor > xEventProcessor( pDoc->GetModel(), uno::UNO_QUERY_THROW ); - xEventProcessor->processCoreVbaEvent( nId ); - } - catch( util::VetoException& ) - { - // VBA event handler indicates to cancel printing the document rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) ); return; } - catch( uno::Exception& ) - { - } bool bDetectHidden = ( !bSilent && pDoc ); if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES ) -- cgit From 3ceb8dd77e9750449f20e01966b1b466741a922f Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Fri, 16 Jul 2010 11:06:18 +0200 Subject: mib17: #162980# Force Broadcast in StepIS for SbxEmpty --- basic/source/runtime/step0.cxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 1d9333ff7555..bdbb22678bf3 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -312,9 +312,21 @@ void SbiRuntime::StepIS() { SbxVariableRef refVar1 = PopVar(); SbxVariableRef refVar2 = PopVar(); - BOOL bRes = BOOL( - refVar1->GetType() == SbxOBJECT - && refVar2->GetType() == SbxOBJECT ); + + SbxDataType eType1 = refVar1->GetType(); + SbxDataType eType2 = refVar2->GetType(); + if ( eType1 == SbxEMPTY ) + { + refVar1->Broadcast( SBX_HINT_DATAWANTED ); + eType1 = refVar1->GetType(); + } + if ( eType2 == SbxEMPTY ) + { + refVar2->Broadcast( SBX_HINT_DATAWANTED ); + eType2 = refVar2->GetType(); + } + + BOOL bRes = BOOL( eType1 == SbxOBJECT && eType2 == SbxOBJECT ); if ( bVBAEnabled && !bRes ) Error( SbERR_INVALID_USAGE_OBJECT ); bRes = ( bRes && refVar1->GetObject() == refVar2->GetObject() ); -- cgit From f4fb9d6add29f3904f48928e3b1b25f0f226ce41 Mon Sep 17 00:00:00 2001 From: "Eike Rathke [er]" Date: Fri, 16 Jul 2010 20:13:45 +0200 Subject: calc56: #i108385# make TEXT return text if text was passed, handling text formats that include a @ code --- formula/inc/formula/errorcodes.hxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/formula/inc/formula/errorcodes.hxx b/formula/inc/formula/errorcodes.hxx index f9b04e012fab..f08af17e095e 100644 --- a/formula/inc/formula/errorcodes.hxx +++ b/formula/inc/formula/errorcodes.hxx @@ -64,7 +64,8 @@ const USHORT errInterpOverflow = 527; // Not displayed, temporary for TrackFormulas, // Cell depends on another cell that has errCircularReference const USHORT errTrackFromCircRef = 528; -// Interpreter internal: existing cell has no value but value queried +// ScInterpreter internal: no numeric value but numeric queried. If this is +// set as mnStringNoValueError no error is generated but 0 returned. const USHORT errCellNoValue = 529; // Interpreter: needed AddIn not found const USHORT errNoAddin = 530; @@ -74,6 +75,11 @@ const USHORT errNoMacro = 531; const USHORT errDivisionByZero = 532; // #DIV/0! // Compiler: a non-simple (str,err,val) value was put in an array const USHORT errNestedArray = 533; +// ScInterpreter internal: no numeric value but numeric queried. If this is +// temporarily (!) set as mnStringNoValueError, the error is generated and can +// be used to distinguish that condition from all other (inherited) errors. Do +// not use for anything else! Never push or inherit the error otherwise! +const USHORT errNotNumericString = 534; // Interpreter: NA() not available condition, not a real error const USHORT NOTAVAILABLE = 0x7fff; -- cgit From cf2e818a242c1d84e313a054625905883ecf583e Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 19 Jul 2010 23:54:06 +0200 Subject: mib17: add Application.Visible --- oovbaapi/ooo/vba/XApplicationBase.idl | 15 ++++++--------- vbahelper/inc/vbahelper/vbaapplicationbase.hxx | 12 +++++++----- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 13 +++++++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/oovbaapi/ooo/vba/XApplicationBase.idl b/oovbaapi/ooo/vba/XApplicationBase.idl index 7f59ddb75247..d9d32e02f2ce 100644 --- a/oovbaapi/ooo/vba/XApplicationBase.idl +++ b/oovbaapi/ooo/vba/XApplicationBase.idl @@ -24,21 +24,15 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef __ooo_vba_XApplicationBase_idl__ #define __ooo_vba_XApplicationBase_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -#ifndef __ooo_vba_XHelperInterface_idl__ #include -#endif module ooo { module vba { -//============================================================================= - +//============================================================================= interface XApplicationBase { @@ -47,8 +41,9 @@ interface XApplicationBase [attribute] boolean ScreenUpdating; [attribute] boolean DisplayStatusBar; [attribute] boolean Interactive; + [attribute] boolean Visible; + [attribute, readonly] string Version; - //mbn [attribute, readonly] any VBE; [attribute, readonly] any VBProjects; @@ -61,6 +56,8 @@ interface XApplicationBase void Undo(); }; +//============================================================================= + }; }; #endif diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx index 73c1aa0d94e7..6902bc7b5042 100644 --- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx +++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx @@ -53,18 +53,20 @@ public: virtual void SAL_CALL setScreenUpdating(sal_Bool bUpdate) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getDisplayStatusBar() throw (css::uno::RuntimeException); virtual void SAL_CALL setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getInteractive() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getInteractive() throw (css::uno::RuntimeException); + virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( ::sal_Bool bVisible ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getVBProjects() throw (css::uno::RuntimeException); virtual void SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException); - virtual void SAL_CALL OnTime( const ::com::sun::star::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const ::com::sun::star::uno::Any& aLatestTime, const ::com::sun::star::uno::Any& aSchedule ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL OnTime( const css::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const css::uno::Any& aLatestTime, const css::uno::Any& aSchedule ) throw (css::uno::RuntimeException); virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Undo( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL Quit( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL Undo() throw (css::uno::RuntimeException); + virtual void SAL_CALL Quit() throw (css::uno::RuntimeException); // XHelperInterface virtual rtl::OUString& getServiceImplName(); diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 8af75a6bd043..fc59b9478f5b 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -159,6 +159,9 @@ typedef ::std::hash_map< VbaTimerInfo, VbaTimer*, VbaTimerInfoHash, ::std::equal struct VbaApplicationBase_Impl { VbaTimerHashMap m_aTimerHash; + sal_Bool mbVisible; + + inline VbaApplicationBase_Impl() : mbVisible( sal_True ) {} virtual ~VbaApplicationBase_Impl() { @@ -264,6 +267,16 @@ void SAL_CALL VbaApplicationBase::setInteractive( ::sal_Bool bInteractive ) xWindow->setEnable( bInteractive ); } +sal_Bool SAL_CALL VbaApplicationBase::getVisible() throw (uno::RuntimeException) +{ + return m_pImpl->mbVisible; // dummy implementation +} + +void SAL_CALL VbaApplicationBase::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException) +{ + m_pImpl->mbVisible = bVisible; // dummy implementation +} + uno::Any SAL_CALL VbaApplicationBase::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException) { -- cgit From b57b872f1b0252da4d1622edfaca32ef0c51cbd8 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 20 Jul 2010 11:49:49 +0200 Subject: mib17: #162887# #162899# Changed handling of missing parameters --- basic/source/runtime/step2.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index c9f344c57d32..47f4967eab99 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -678,7 +678,18 @@ void SbiRuntime::StepPARAM( UINT32 nOp1, UINT32 nOp2 ) while( iLoop >= nParamCount ) { p = new SbxVariable(); - p->PutErr( 448 ); // Wie in VB: Error-Code 448 (SbERR_NAMED_NOT_FOUND) + + if( SbiRuntime::isVBAEnabled() && + (t == SbxOBJECT || t == SbxSTRING) ) + { + if( t == SbxOBJECT ) + p->PutObject( NULL ); + else + p->PutString( String() ); + } + else + p->PutErr( 448 ); // Wie in VB: Error-Code 448 (SbERR_NAMED_NOT_FOUND) + refParams->Put( p, iLoop ); iLoop--; } -- cgit From 42893428c4396619359aaaa7bdbad521ccb553a1 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 20 Jul 2010 12:50:30 +0200 Subject: mib17: #162900# Support parameters for Property Get calls --- basic/source/classes/sb.cxx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 9012471cac0a..e28b0a304f28 100755 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -599,7 +599,28 @@ void SbClassModuleObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType { SbxValues aVals; aVals.eType = SbxVARIANT; - pMeth->Get( aVals ); + + SbxArray* pArg = pVar->GetParameters(); + USHORT nVarParCount = (pArg != NULL) ? pArg->Count() : 0; + if( nVarParCount > 1 ) + { + SbxArrayRef xMethParameters = new SbxArray; + xMethParameters->Put( pMeth, 0 ); // Method as parameter 0 + for( USHORT i = 1 ; i < nVarParCount ; ++i ) + { + SbxVariable* pPar = pArg->Get( i ); + xMethParameters->Put( pPar, i ); + } + + pMeth->SetParameters( xMethParameters ); + pMeth->Get( aVals ); + pMeth->SetParameters( NULL ); + } + else + { + pMeth->Get( aVals ); + } + pVar->Put( aVals ); } } -- cgit From 2986fe6067949eb4aae3cc5ec195783f55033c2b Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 21 Jul 2010 11:54:48 +0200 Subject: fwk150: Make find bar string localizable --- svx/inc/svx/dialogs.hrc | 4 +++- svx/source/tbxctrls/makefile.mk | 1 + svx/source/tbxctrls/tbunosearchcontrollers.cxx | 6 +++-- svx/source/tbxctrls/tbunosearchcontrollers.src | 33 ++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) mode change 100755 => 100644 svx/inc/svx/dialogs.hrc create mode 100644 svx/source/tbxctrls/tbunosearchcontrollers.src diff --git a/svx/inc/svx/dialogs.hrc b/svx/inc/svx/dialogs.hrc old mode 100755 new mode 100644 index d193652b57fc..fd7561bb7192 --- a/svx/inc/svx/dialogs.hrc +++ b/svx/inc/svx/dialogs.hrc @@ -956,7 +956,9 @@ #define RID_SVXSTR_OUTLINENUM_DESCRIPTION_6 (RID_SVXSTR_OUTLINENUM_DESCRIPTIONS + 6)//? #define RID_SVXSTR_OUTLINENUM_DESCRIPTION_7 (RID_SVXSTR_OUTLINENUM_DESCRIPTIONS + 7)//? -#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1190) +#define RID_SVXSTR_FINDBAR_FIND (RID_SVX_START + 1190) + +#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1191) // ---------------------------------------------------------------------------- // if we have _a_lot_ time, we should group the resource ids by type, instead diff --git a/svx/source/tbxctrls/makefile.mk b/svx/source/tbxctrls/makefile.mk index 73a178d97594..a9ea745f3cc0 100644 --- a/svx/source/tbxctrls/makefile.mk +++ b/svx/source/tbxctrls/makefile.mk @@ -74,6 +74,7 @@ SRC1FILES = \ lboxctrl.src \ linectrl.src \ tbcontrl.src \ + tbunosearchcontrollers.src \ tbxdraw.src \ grafctrl.src diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 5dcaf6fd5e72..e446d3d3b9d5 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -29,6 +29,8 @@ #include "precompiled_svx.hxx" #include "tbunosearchcontrollers.hxx" +#include +#include #include #include @@ -91,7 +93,7 @@ FindTextFieldControl::~FindTextFieldControl() void FindTextFieldControl::InitControls_Impl() { - SetText( String( ::rtl::OUString::createFromAscii("Find") ) ); + SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) ); SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor()); EnableAutocomplete(TRUE, TRUE); @@ -174,7 +176,7 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) case EVENT_LOSEFOCUS: if ( GetText().Len() == 0 ) { - SetText( String( ::rtl::OUString::createFromAscii("Find") ) ); + SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) ); SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor()); m_bToClearTextField = sal_True; } diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.src b/svx/source/tbxctrls/tbunosearchcontrollers.src new file mode 100644 index 000000000000..9a256ae0cabb --- /dev/null +++ b/svx/source/tbxctrls/tbunosearchcontrollers.src @@ -0,0 +1,33 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include + +String RID_SVXSTR_FINDBAR_FIND +{ + Text [ en-US ] = "Find" ; +}; -- cgit From c6431e762cd7fedb380160db13dbbe2a9a7e7f9d Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Mon, 26 Jul 2010 14:20:03 +0200 Subject: mib17: #163025# Basic Trace functionality for debugging (inactive by default) --- basic/source/classes/disas.cxx | 32 +++- basic/source/classes/sbxmod.cxx | 29 +++- basic/source/comp/sbcomp.cxx | 307 ++++++++++++++++++++++++++++++++++++++- basic/source/inc/sbtrace.hxx | 42 ++++++ basic/source/runtime/runtime.cxx | 19 +++ 5 files changed, 420 insertions(+), 9 deletions(-) mode change 100644 => 100755 basic/source/comp/sbcomp.cxx create mode 100755 basic/source/inc/sbtrace.hxx diff --git a/basic/source/classes/disas.cxx b/basic/source/classes/disas.cxx index 87b4cad4e94b..a837a3dc4f24 100644 --- a/basic/source/classes/disas.cxx +++ b/basic/source/classes/disas.cxx @@ -35,6 +35,7 @@ #include "sb.hxx" #include "iosys.hxx" #include "disas.hxx" +#include "sbtrace.hxx" static const char* pOp1[] = { @@ -361,6 +362,11 @@ BOOL SbiDisas::DisasLine( String& rText ) rText.Erase(); if( !Fetch() ) return FALSE; + +#ifdef DBG_TRACE_BASIC + String aTraceStr_STMNT; +#endif + // New line? if( eOp == _STMNT && nOp1 != nLine ) { @@ -393,8 +399,13 @@ BOOL SbiDisas::DisasLine( String& rText ) rText.AppendAscii( "; " ); rText += s; rText.AppendAscii( _crlf() ); + +#ifdef DBG_TRACE_BASIC + aTraceStr_STMNT = s; +#endif } } + // Label? const char* p = ""; if( cLabels[ nPC >> 3 ] & ( 1 << ( nPC & 7 ) ) ) @@ -432,20 +443,29 @@ BOOL SbiDisas::DisasLine( String& rText ) rText.AppendAscii( _crlf() ); } snprintf( cBuf, sizeof(cBuf), pMask[ nParts ], nPC, (USHORT) eOp, nOp1, nOp2 ); - rText.AppendAscii( cBuf ); + + String aPCodeStr; + aPCodeStr.AppendAscii( cBuf ); int n = eOp; if( eOp >= SbOP2_START ) n -= SbOP2_START; else if( eOp >= SbOP1_START ) n -= SbOP1_START; - rText += '\t'; - rText.AppendAscii( pOps[ nParts-1 ][ n ] ); - rText += '\t'; + aPCodeStr += '\t'; + aPCodeStr.AppendAscii( pOps[ nParts-1 ][ n ] ); + aPCodeStr += '\t'; switch( nParts ) { - case 2: (this->*( pOperand2[ n ] ) )( rText ); break; - case 3: (this->*( pOperand3[ n ] ) )( rText ); break; + case 2: (this->*( pOperand2[ n ] ) )( aPCodeStr ); break; + case 3: (this->*( pOperand3[ n ] ) )( aPCodeStr ); break; } + + rText += aPCodeStr; + +#ifdef DBG_TRACE_BASIC + dbg_RegisterTraceTextForPC( pMod, nPC, aTraceStr_STMNT, aPCodeStr ); +#endif + return TRUE; } diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 30d856fda40e..0f52eef2d825 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -45,6 +45,7 @@ #include "runtime.hxx" #include "token.hxx" #include "sbunoobj.hxx" +#include "sbtrace.hxx" //#include @@ -1044,6 +1045,9 @@ USHORT SbModule::Run( SbMethod* pMeth ) StarBASICRef xBasic; if( bDelInst ) { +#ifdef DBG_TRACE_BASIC + dbg_InitTrace(); +#endif // #32779: Basic waehrend der Ausfuehrung festhalten xBasic = (StarBASIC*) GetParent(); @@ -1122,18 +1126,28 @@ USHORT SbModule::Run( SbMethod* pMeth ) SbModule* pOldMod = pMOD; pMOD = this; SbiRuntime* pRt = new SbiRuntime( this, pMeth, pMeth->nStart ); + +#ifdef DBG_TRACE_BASIC + dbg_traceNotifyCall( this, pMeth, pINST->nCallLvl ); +#endif + pRt->pNext = pINST->pRun; if( pRt->pNext ) pRt->pNext->block(); pINST->pRun = pRt; if ( mbVBACompat ) - { + { pINST->EnableCompatibility( TRUE ); - } + } while( pRt->Step() ) {} if( pRt->pNext ) pRt->pNext->unblock(); +#ifdef DBG_TRACE_BASIC + bool bLeave = true; + dbg_traceNotifyCall( this, pMeth, pINST->nCallLvl, bLeave ); +#endif + // #63710 Durch ein anderes Thread-Handling bei Events kann es passieren, // dass show-Aufruf an einem Dialog zurueckkehrt (durch schliessen des // Dialogs per UI), BEVOR ein per Event ausgeloester weitergehender Call, @@ -1227,9 +1241,20 @@ void SbModule::RunInit() pMOD = this; // Der Init-Code beginnt immer hier SbiRuntime* pRt = new SbiRuntime( this, NULL, 0 ); + +#ifdef DBG_TRACE_BASIC + dbg_traceNotifyCall( this, NULL, 0 ); +#endif + pRt->pNext = pINST->pRun; pINST->pRun = pRt; while( pRt->Step() ) {} + +#ifdef DBG_TRACE_BASIC + bool bLeave = true; + dbg_traceNotifyCall( this, NULL, 0, bLeave ); +#endif + pINST->pRun = pRt->pNext; delete pRt; pMOD = pOldMod; diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx old mode 100644 new mode 100755 index faabba046c99..e6fe73177dd2 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -31,10 +31,310 @@ #include #include "sbcomp.hxx" #include "image.hxx" +#include "sbtrace.hxx" +//========================================================================== +// Tracing, for debugging only + +// To activate tracing enable in sbtrace.hxx +#ifdef DBG_TRACE_BASIC + +#include + +// Trace Settings +static const char* GpTraceFileName = "d:\\zBasic.Asm\\BasicTrace.txt"; +static const bool GbIncludePCodes = false; +static const int GnIndentPerCallLevel = 4; +static const int GnIndentForPCode = 2; + +struct TraceTextData +{ + rtl::OString m_aTraceStr_STMNT; + rtl::OString m_aTraceStr_PCode; +}; +typedef std::hash_map< sal_Int32, TraceTextData > PCToTextDataMap; +typedef std::hash_map< ::rtl::OUString, PCToTextDataMap*, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleTraceMap; + +ModuleTraceMap GaModuleTraceMap; +ModuleTraceMap& rModuleTraceMap = GaModuleTraceMap; + +static void lcl_PrepareTraceForModule( SbModule* pModule ) +{ + String aModuleName = pModule->GetName(); + ModuleTraceMap::iterator it = rModuleTraceMap.find( aModuleName ); + if( it != rModuleTraceMap.end() ) + { + PCToTextDataMap* pInnerMap = it->second; + delete pInnerMap; + rModuleTraceMap.erase( it ); + } + + String aDisassemblyStr; + pModule->Disassemble( aDisassemblyStr ); +} + +static void lcl_lineOut( const char* pFileName, const char* pStr, const char* pPreStr = NULL ) +{ + const char* pPrintFirst = (pPreStr != NULL) ? pPreStr : ""; + FILE* pFile = fopen( pFileName, "a+" ); + if( pFile != NULL ) + { + fprintf( pFile, "%s%s\n", pPrintFirst, pStr ); + fclose( pFile ); + } +} + +const char* lcl_getSpaces( int nSpaceCount ) +{ + static sal_Char Spaces[] = " " + " " + " "; + static int nAvailableSpaceCount = strlen( Spaces ); + static sal_Char* pSpacesEnd = Spaces + nAvailableSpaceCount; + + if( nSpaceCount > nAvailableSpaceCount ) + nSpaceCount = nAvailableSpaceCount; + + return pSpacesEnd - nSpaceCount; +} + +static rtl::OString lcl_toOStringSkipLeadingWhites( const String& aStr ) +{ + static sal_Char Buffer[1000]; + + rtl::OString aOStr = OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ); + const sal_Char* pStr = aOStr.getStr(); + + // Skip whitespace + sal_Char c = *pStr; + while( c == ' ' || c == '\t' ) + { + pStr++; + c = *pStr; + } + + int nLen = strlen( pStr ); + strncpy( Buffer, pStr, nLen ); + Buffer[nLen] = 0; + + rtl::OString aORetStr( Buffer ); + return aORetStr; +} + +String dumpMethodParameters( SbMethod* pMethod ) +{ + String aStr; + if( pMethod == NULL ) + return aStr; + + SbxError eOld = SbxBase::GetError(); + + SbxArray* pParams = pMethod->GetParameters(); + SbxInfo* pInfo = pMethod->GetInfo(); + if ( pParams ) + { + aStr += '('; + // 0 is sub itself + for ( USHORT nParam = 1; nParam < pParams->Count(); nParam++ ) + { + SbxVariable* pVar = pParams->Get( nParam ); + DBG_ASSERT( pVar, "Parameter?!" ); + if ( pVar->GetName().Len() ) + aStr += pVar->GetName(); + else if ( pInfo ) + { + const SbxParamInfo* pParam = pInfo->GetParam( nParam ); + if ( pParam ) + aStr += pParam->aName; + } + aStr += '='; + if( pVar->GetType() & SbxARRAY ) + aStr += String( RTL_CONSTASCII_USTRINGPARAM( "..." ) ); + else + aStr += pVar->GetString(); + if ( nParam < ( pParams->Count() - 1 ) ) + aStr += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) ); + } + aStr += ')'; + } + + SbxBase::ResetError(); + if( eOld != SbxERR_OK ) + SbxBase::SetError( eOld ); + + return aStr; +} + +// Public functions +void dbg_InitTrace( void ) +{ + FILE* pFile = fopen( GpTraceFileName, "w" ); + if( pFile != NULL ) + fclose( pFile ); +} + +void dbg_traceStep( SbModule* pModule, UINT32 nPC, INT32 nCallLvl ) +{ + SbModule* pTraceMod = pModule; + if( pTraceMod->ISA(SbClassModuleObject) ) + { + SbClassModuleObject* pClassModuleObj = (SbClassModuleObject*)(SbxBase*)pTraceMod; + pTraceMod = pClassModuleObj->getClassModule(); + } + + String aModuleName = pTraceMod->GetName(); + ModuleTraceMap::iterator it = rModuleTraceMap.find( aModuleName ); + if( it == rModuleTraceMap.end() ) + { + const char* pModuleNameStr = OUStringToOString( rtl::OUString( aModuleName ), RTL_TEXTENCODING_ASCII_US ).getStr(); + char Buffer[200]; + sprintf( Buffer, "TRACE ERROR: Unknown module \"%s\"", pModuleNameStr ); + lcl_lineOut( GpTraceFileName, Buffer ); + return; + } + + PCToTextDataMap* pInnerMap = it->second; + if( pInnerMap == NULL ) + { + lcl_lineOut( GpTraceFileName, "TRACE INTERNAL ERROR: No inner map" ); + return; + } + + PCToTextDataMap::iterator itInner = pInnerMap->find( nPC ); + if( itInner == pInnerMap->end() ) + { + const char* pModuleNameStr = OUStringToOString( rtl::OUString( aModuleName ), RTL_TEXTENCODING_ASCII_US ).getStr(); + char Buffer[200]; + sprintf( Buffer, "TRACE ERROR: No info for PC = %d in module \"%s\"", nPC, pModuleNameStr ); + lcl_lineOut( GpTraceFileName, Buffer ); + return; + } + + //nCallLvl--; + //if( nCallLvl < 0 ) + // nCallLvl = 0; + int nIndent = nCallLvl * GnIndentPerCallLevel; + + const TraceTextData& rTraceTextData = itInner->second; + const rtl::OString& rStr_STMNT = rTraceTextData.m_aTraceStr_STMNT; + if( rStr_STMNT.getLength() ) + lcl_lineOut( GpTraceFileName, rStr_STMNT.getStr(), lcl_getSpaces( nIndent ) ); + + if( !GbIncludePCodes ) + return; + + nIndent += GnIndentForPCode; + const rtl::OString& rStr_PCode = rTraceTextData.m_aTraceStr_PCode; + if( rStr_PCode.getLength() ) + lcl_lineOut( GpTraceFileName, rStr_PCode.getStr(), lcl_getSpaces( nIndent ) ); +} + +void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl, bool bLeave ) +{ + static const char* pSeparator = "' ================================================================================"; + + SbModule* pTraceMod = pModule; + SbClassModuleObject* pClassModuleObj = NULL; + if( pTraceMod->ISA(SbClassModuleObject) ) + { + pClassModuleObj = (SbClassModuleObject*)(SbxBase*)pTraceMod; + pTraceMod = pClassModuleObj->getClassModule(); + } + + if( nCallLvl > 0 ) + nCallLvl--; + int nIndent = nCallLvl * GnIndentPerCallLevel; + if( !bLeave ) + { + lcl_lineOut( GpTraceFileName, "" ); + lcl_lineOut( GpTraceFileName, pSeparator, lcl_getSpaces( nIndent ) ); + } + + String aStr; + if( bLeave ) + { + lcl_lineOut( GpTraceFileName, "}", lcl_getSpaces( nIndent ) ); + aStr.AppendAscii( "' Leaving " ); + } + else + { + aStr.AppendAscii( "Entering " ); + } + String aModuleName = pModule->GetName(); + aStr += aModuleName; + if( pMethod != NULL ) + { + aStr.AppendAscii( "::" ); + String aMethodName = pMethod->GetName(); + aStr += aMethodName; + } + else + { + aStr.AppendAscii( "/RunInit" ); + } + + if( pClassModuleObj != NULL ) + { + aStr.AppendAscii( "[this=" ); + aStr += pClassModuleObj->GetName(); + aStr.AppendAscii( "]" ); + } + if( !bLeave ) + aStr += dumpMethodParameters( pMethod ); + + lcl_lineOut( GpTraceFileName, OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) ); + if( !bLeave ) + lcl_lineOut( GpTraceFileName, "{", lcl_getSpaces( nIndent ) ); + + if( bLeave ) + lcl_lineOut( GpTraceFileName, "" ); +} + +void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, INT32 nCallLvl ) +{ + rtl::OString aOTraceErrMsg = OUStringToOString( rtl::OUString( aTraceErrMsg ), RTL_TEXTENCODING_ASCII_US ); + + char Buffer[200]; + const char* pHandledStr = bTraceErrHandled ? " / HANDLED" : ""; + sprintf( Buffer, "*** ERROR%s, Id = %d, Msg = \"%s\" ***", pHandledStr, (int)nTraceErr, aOTraceErrMsg.getStr() ); + int nIndent = nCallLvl * GnIndentPerCallLevel; + lcl_lineOut( GpTraceFileName, Buffer, lcl_getSpaces( nIndent ) ); +} + +void dbg_RegisterTraceTextForPC( SbModule* pModule, UINT32 nPC, + const String& aTraceStr_STMNT, const String& aTraceStr_PCode ) +{ + String aModuleName = pModule->GetName(); + ModuleTraceMap::iterator it = rModuleTraceMap.find( aModuleName ); + PCToTextDataMap* pInnerMap; + if( it == rModuleTraceMap.end() ) + { + pInnerMap = new PCToTextDataMap(); + rModuleTraceMap[ aModuleName ] = pInnerMap; + } + else + { + pInnerMap = it->second; + } + + TraceTextData aData; + + rtl::OString aOTraceStr_STMNT = lcl_toOStringSkipLeadingWhites( aTraceStr_STMNT ); + aData.m_aTraceStr_STMNT = aOTraceStr_STMNT; + + rtl::OString aOTraceStr_PCode = lcl_toOStringSkipLeadingWhites( aTraceStr_PCode ); + aData.m_aTraceStr_PCode = aOTraceStr_PCode; + + (*pInnerMap)[nPC] = aData; +} + +#endif + + +//========================================================================== // For debugging only -// #define DBG_SAVE_DISASSEMBLY +//#define DBG_SAVE_DISASSEMBLY #ifdef DBG_SAVE_DISASSEMBLY static bool dbg_bDisassemble = true; @@ -99,6 +399,7 @@ void dbg_SaveDisassembly( SbModule* pModule ) } #endif + // Diese Routine ist hier definiert, damit der Compiler als eigenes Segment // geladen werden kann. @@ -155,6 +456,10 @@ BOOL SbModule::Compile() dbg_SaveDisassembly( this ); #endif +#ifdef DBG_TRACE_BASIC + lcl_PrepareTraceForModule( this ); +#endif + return bRet; } diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx new file mode 100755 index 000000000000..e8a482c2f6e9 --- /dev/null +++ b/basic/source/inc/sbtrace.hxx @@ -0,0 +1,42 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SBTRACE_HXX +#define _SBTRACE_HXX + +// #define DBG_TRACE_BASIC + +#ifdef DBG_TRACE_BASIC +void dbg_InitTrace( void ); +void dbg_traceStep( SbModule* pModule, UINT32 nPC, INT32 nCallLvl ); +void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl, bool bLeave = false ); +void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, INT32 nCallLvl ); +void dbg_RegisterTraceTextForPC( SbModule* pModule, UINT32 nPC, + const String& aTraceStr_STMNT, const String& aTraceStr_PCode ); +#endif + +#endif diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index c3419adbfdb3..1bb6fb82e113 100755 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -44,6 +44,7 @@ #include #include "sbunoobj.hxx" #include "errobject.hxx" +#include "sbtrace.hxx" using namespace ::com::sun::star; @@ -720,6 +721,12 @@ BOOL SbiRuntime::Step() if( pInst->IsReschedule() && bStaticGlobalEnableReschedule ) Application::Reschedule(); } + +#ifdef DBG_TRACE_BASIC + UINT32 nPC = ( pCode - (const BYTE* )pImg->GetCode() ); + dbg_traceStep( pMod, nPC, pINST->nCallLvl ); +#endif + SbiOpcode eOp = (SbiOpcode ) ( *pCode++ ); UINT32 nOp1, nOp2; if( eOp <= SbOP0_END ) @@ -756,6 +763,11 @@ BOOL SbiRuntime::Step() // (insbesondere nicht nach Compiler-Fehlern zur Laufzeit) if( nError && bRun ) { +#ifdef DBG_TRACE_BASIC + SbError nTraceErr = nError; + String aTraceErrMsg = GetSbData()->aErrMsg; + bool bTraceErrHandled = true; +#endif SbError err = nError; ClearExprStack(); nError = 0; @@ -836,12 +848,19 @@ BOOL SbiRuntime::Step() // Kein Error-Hdl gefunden -> altes Vorgehen else { +#ifdef DBG_TRACE_BASIC + bTraceErrHandled = false; +#endif pInst->Abort(); } // ALT: Nur // pInst->Abort(); } + +#ifdef DBG_TRACE_BASIC + dbg_traceNotifyError( nTraceErr, aTraceErrMsg, bTraceErrHandled, pINST->nCallLvl ); +#endif } } return bRun; -- cgit From 85a4e97dc97a88c59ab0cf8a4d89d9f9413adf9f Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Mon, 26 Jul 2010 15:06:38 +0200 Subject: OOO330 masterix: #113247#: disable checking against network based DTD, build must not depend on network resources --- readlicense_oo/util/makefile.pmk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readlicense_oo/util/makefile.pmk b/readlicense_oo/util/makefile.pmk index 30e07779457b..0efd9712f11d 100755 --- a/readlicense_oo/util/makefile.pmk +++ b/readlicense_oo/util/makefile.pmk @@ -57,7 +57,7 @@ $(MISC)$/readme_text.xsl : virtual $(MISC)$/$(GUI)$/$(eq,$(GUI),WNT readme README)_%.html : 'virtual' @@-$(MKDIRHIER) $(@:d) - $(XSLTPROC) --nonet -o $@ \ + $(XSLTPROC) --nonet --novalid -o $@ \ --stringparam os1 $(OS) --stringparam gui1 $(GUI) --stringparam com1 $(COM) \ --stringparam cp1 $(CPUNAME) --stringparam type html --stringparam lang1 $* \ ..$/readme.xsl $(MERGEDXRM) @@ -67,7 +67,7 @@ $(MISC)$/$(GUI)$/$(eq,$(GUI),WNT readme README)_%.html : 'virtual' $(MISC)$/$(GUI)$/$(eq,$(GUI),OS2 readme README)_%.html : 'virtual' @@-$(MKDIRHIER) $(@:d) - $(XSLTPROC) --nonet -o $@ \ + $(XSLTPROC) --nonet --novalid -o $@ \ --stringparam os1 $(OS) --stringparam gui1 $(GUI) --stringparam com1 $(COM) \ --stringparam cp1 $(CPUNAME) --stringparam type html --stringparam lang1 $* \ ..$/readme.xsl $(MERGEDXRM) @@ -75,7 +75,7 @@ $(MISC)$/$(GUI)$/$(eq,$(GUI),OS2 readme README)_%.html : 'virtual' # no percent-rule to avoid ambiguous inference chains for README_.html $(SYSTEXTDOCS) : $(MISC)$/readme_text.xsl @@-$(MKDIRHIER) $(@:d) - $(XSLTPROC) --nonet -o $@ \ + $(XSLTPROC) --nonet --novalid -o $@ \ --stringparam os1 $(OS) --stringparam gui1 $(GUI) --stringparam com1 $(COM) \ --stringparam cp1 $(CPUNAME) --stringparam type text --stringparam lang1 $(@:b:s/readme_//:s/README_//) \ $< $(MERGEDXRM) -- cgit From a11c345f88392632016ca0d4dd1e21188dae9e6c Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 26 Jul 2010 19:13:47 +0200 Subject: mib17: prevent crash when VBAGlobals object is missing (this causes that document modules do not have an associated UNO object thus the DocObjectWrapper does not have a type provider) --- basic/source/classes/sbxmod.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 0f52eef2d825..e42193ac2696 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -121,16 +121,16 @@ class DocObjectWrapper : public DocObjectWrapper_BASE public: DocObjectWrapper( SbModule* pMod ); - ~DocObjectWrapper(); + virtual ~DocObjectWrapper(); virtual void SAL_CALL acquire() throw(); virtual void SAL_CALL release() throw(); - virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() - throw ( com::sun::star::uno::RuntimeException ) + virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (RuntimeException) { + if( !m_xAggregateTypeProv.is() ) + throw RuntimeException(); return m_xAggregateTypeProv->getImplementationId(); - } virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (RuntimeException); -- cgit From 521b922314728107ea4c63dde76a1f5afe0b0855 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 27 Jul 2010 11:46:28 +0200 Subject: mib17: #163102# transport declaration class name for WithEvents --- basic/source/runtime/step0.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index bdbb22678bf3..29965c7e9da5 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -532,9 +532,10 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b // Handle withevents BOOL bWithEvents = refVar->IsSet( SBX_WITH_EVENTS ); - Reference< XInterface > xComListener; - if( bWithEvents ) + if ( bWithEvents ) { + Reference< XInterface > xComListener; + SbxBase* pObj = refVal->GetObject(); SbUnoObject* pUnoObj = (pObj != NULL) ? PTR_CAST(SbUnoObject,pObj) : NULL; if( pUnoObj != NULL ) @@ -545,13 +546,17 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b ::rtl::OUString aPrefix = refVar->GetName(); SbxObjectRef xScopeObj = refVar->GetParent(); xComListener = createComListener( aControlAny, aVBAType, aPrefix, xScopeObj ); - } - } - *refVar = *refVal; + refVal->SetDeclareClassName( aDeclareClassName ); + refVal->SetComListener( xComListener ); // Hold reference + } - if( bWithEvents ) - refVar->SetComListener( xComListener ); // Hold reference + *refVar = *refVal; + } + else + { + *refVar = *refVal; + } // lhs is a property who's value is currently (Empty e.g. no broadcast yet) // in this case if there is a default prop involved the value of the -- cgit From 4cc4f719538888c7f97048e9a7c1693ef9e6f344 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 27 Jul 2010 11:53:35 +0200 Subject: mib17: #i112634# prepare loading VBA with document events from ODF and XLSM --- vbahelper/inc/vbahelper/vbaeventshelperbase.hxx | 3 --- vbahelper/source/vbahelper/vbaeventshelperbase.cxx | 13 +------------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx index b7216746c81d..89d355db71f9 100755 --- a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx +++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx @@ -52,8 +52,6 @@ public: virtual ~VbaEventsHelperBase(); // XVBAEventProcessor - virtual void SAL_CALL setIgnoreEvents( sal_Bool bIgnoreEvents ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getIgnoreEvents() throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); virtual void SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::script::provider::ScriptFrameworkErrorException, css::util::VetoException, css::uno::RuntimeException); @@ -156,7 +154,6 @@ private: typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerMap; EventHandlerMap maEvents; - bool mbIgnoreEvents; bool mbDisposed; }; diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx index ea5448482a89..16a8671df601 100755 --- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx +++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx @@ -35,7 +35,6 @@ using namespace ::ooo::vba; VbaEventsHelperBase::VbaEventsHelperBase( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& /*xContext*/ ) : mpShell( 0 ), - mbIgnoreEvents( false ), mbDisposed( false ) { try @@ -57,16 +56,6 @@ VbaEventsHelperBase::~VbaEventsHelperBase() stopListening(); } -void SAL_CALL VbaEventsHelperBase::setIgnoreEvents( sal_Bool bIgnoreEvents ) throw (uno::RuntimeException) -{ - mbIgnoreEvents = bIgnoreEvents; -} - -sal_Bool SAL_CALL VbaEventsHelperBase::getIgnoreEvents() throw (uno::RuntimeException) -{ - return mbIgnoreEvents; -} - sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) throw (lang::IllegalArgumentException, uno::RuntimeException) { @@ -87,7 +76,7 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un /* bEnabled will track if event processing is enabled. Every event handler may disable handling of other events. */ - bool bEnabled = !mbIgnoreEvents; + bool bEnabled = true; /* bCancel will contain the current Cancel value. It is possible that multiple events will try to modify the Cancel value. Every event -- cgit From b7d6f018da399d350d778acf0d76b210242b3939 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 27 Jul 2010 12:16:05 +0200 Subject: mib17: #i110822# Fixed named parameter handling in automation bridge --- basic/source/runtime/step2.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 basic/source/runtime/step2.cxx diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx old mode 100644 new mode 100755 index 47f4967eab99..0e95bf66631d --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -378,7 +378,8 @@ void SbiRuntime::SetupArgs( SbxVariable* p, UINT32 nOp1 ) bool bError_ = true; SbUnoMethod* pUnoMethod = PTR_CAST(SbUnoMethod,p); - if( pUnoMethod ) + SbUnoProperty* pUnoProperty = PTR_CAST(SbUnoProperty,p); + if( pUnoMethod || pUnoProperty ) { SbUnoObject* pParentUnoObj = PTR_CAST( SbUnoObject,p->GetParent() ); if( pParentUnoObj ) -- cgit From e1461c4204ffc1c099fb8b877c3b7a58c35437dd Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 27 Jul 2010 14:43:33 +0200 Subject: mib17: move VBA specific interfaces into vba subdir --- basic/source/basmgr/basmgr.cxx | 12 ++++++------ basic/source/classes/sbxmod.cxx | 6 +++--- basic/source/inc/namecont.hxx | 10 +++++----- basic/source/inc/scriptcont.hxx | 4 ++-- basic/source/uno/namecont.cxx | 4 ++-- basic/source/uno/scriptcont.cxx | 8 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index b76a2b5e249e..84763468e64c 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -67,8 +67,8 @@ #include #include #include -#include -#include +#include +#include #include @@ -240,7 +240,7 @@ void BasMgrContainerListenerImpl::addLibraryModulesImpl( BasicManager* pMgr, Any aElement = xLibNameAccess->getByName( aModuleName ); ::rtl::OUString aMod; aElement >>= aMod; - Reference< XVBAModuleInfo > xVBAModuleInfo( xLibNameAccess, UNO_QUERY ); + Reference< vba::XVBAModuleInfo > xVBAModuleInfo( xLibNameAccess, UNO_QUERY ); if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( aModuleName ) ) { ModuleInfo mInfo = xVBAModuleInfo->getModuleInfo( aModuleName ); @@ -285,9 +285,9 @@ void SAL_CALL BasMgrContainerListenerImpl::elementInserted( const ContainerEvent StarBASIC* pLib = mpMgr->GetLib( aName ); if ( pLib ) { - Reference xVBACompat( xScriptCont, UNO_QUERY ); + Reference< vba::XVBACompatibility > xVBACompat( xScriptCont, UNO_QUERY ); if ( xVBACompat.is() ) - pLib->SetVBAEnabled( xVBACompat->getVBACompatModeOn() ); + pLib->SetVBAEnabled( xVBACompat->getVBACompatibilityMode() ); } } else @@ -302,7 +302,7 @@ void SAL_CALL BasMgrContainerListenerImpl::elementInserted( const ContainerEvent { ::rtl::OUString aMod; Event.Element >>= aMod; - Reference< XVBAModuleInfo > xVBAModuleInfo( Event.Source, UNO_QUERY ); + Reference< vba::XVBAModuleInfo > xVBAModuleInfo( Event.Source, UNO_QUERY ); if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( aName ) ) { ModuleInfo mInfo = xVBAModuleInfo->getModuleInfo( aName ); diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index e42193ac2696..8b1069bbeab3 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -57,7 +57,7 @@ #include #include #include -#include +#include #include using namespace com::sun::star; @@ -461,9 +461,9 @@ bool getDefaultVBAMode( StarBASIC* pb ) uno::Reference< beans::XPropertySet > xProp( aDoc, uno::UNO_QUERY ); if ( xProp.is() ) { - uno::Reference< script::XVBACompat > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY ); + uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY ); if ( xVBAMode.is() ) - bResult = ( xVBAMode->getVBACompatModeOn() == sal_True ); + bResult = xVBAMode->getVBACompatibilityMode() == sal_True; } } } diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 4df1c48557d2..10150daf96b8 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -60,7 +60,7 @@ #include #include #include -#include +#include class BasicManager; @@ -73,7 +73,7 @@ typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::script::XLibraryContainerPassword, ::com::sun::star::script::XLibraryContainerExport, ::com::sun::star::container::XContainer, - ::com::sun::star::script::XVBACompat, + ::com::sun::star::script::vba::XVBACompatibility, ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper; typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer, @@ -500,9 +500,9 @@ public: throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0; - // Methods XVBACompat - virtual ::sal_Bool SAL_CALL getVBACompatModeOn() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setVBACompatModeOn( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); + // Methods XVBACompatibility + virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); }; class LibraryContainerMethodGuard diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx index d184a2d558e2..091fbc24cdbe 100644 --- a/basic/source/inc/scriptcont.hxx +++ b/basic/source/inc/scriptcont.hxx @@ -30,7 +30,7 @@ #include "namecont.hxx" #include -#include +#include #include class BasicManager; @@ -141,7 +141,7 @@ public: //============================================================================ typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInfoMap; -typedef ::cppu::ImplHelper1 < ::com::sun::star::script::XVBAModuleInfo +typedef ::cppu::ImplHelper1 < ::com::sun::star::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE; class SfxScriptLibrary : public SfxLibrary diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index f692277fc5ba..b4cd118533fd 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -2789,12 +2789,12 @@ OUString SfxLibraryContainer::expand_url( const OUString& url ) } } -::sal_Bool SAL_CALL SfxLibraryContainer::getVBACompatModeOn() throw (RuntimeException) +::sal_Bool SAL_CALL SfxLibraryContainer::getVBACompatibilityMode() throw (RuntimeException) { return mbVBACompat; } -void SAL_CALL SfxLibraryContainer::setVBACompatModeOn( ::sal_Bool _vbacompatmodeon ) throw (RuntimeException) +void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (RuntimeException) { BasicManager* pBasMgr = getBasicManager(); if( pBasMgr ) diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index 5622adc19af1..ef8e1f459472 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -216,7 +216,7 @@ void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement Any aElement = xLib->getByName( aElementName ); aElement >>= aMod.aCode; - Reference < script::XVBAModuleInfo > xModInfo( xLib, UNO_QUERY ); + Reference < script::vba::XVBAModuleInfo > xModInfo( xLib, UNO_QUERY ); if( xModInfo.is() && xModInfo->hasModuleInfo( aElementName ) ) { @@ -312,9 +312,9 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement // aMod.aName ignored if( aMod.aModuleType.getLength() > 0 ) { - if( !getVBACompatModeOn() ) + if( !getVBACompatibilityMode() ) { - setVBACompatModeOn( sal_True ); + setVBACompatibilityMode( sal_True ); Any aGlobs; Sequence< Any > aArgs(1); @@ -381,7 +381,7 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement } } - Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, + Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); if( xVBAModuleInfo.is() ) { -- cgit From 69d41381ba6e808153508ccd09ea73b8d77dbe76 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 28 Jul 2010 11:53:03 +0200 Subject: mib17: resolved conflict after rebase corrected --- basic/source/runtime/step0.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 1051a0b514f5..29965c7e9da5 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -558,9 +558,6 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b *refVar = *refVal; } - if( bWithEvents ) - refVar->SetComListener( xComListener ); // Hold reference - // lhs is a property who's value is currently (Empty e.g. no broadcast yet) // in this case if there is a default prop involved the value of the // default property may infact be void so the type will also be SbxEMPTY -- cgit From c34ae9ba3c48c793a78ae86729d112ea1a282236 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 28 Jul 2010 13:27:00 +0200 Subject: mib17: resolved conflict after rebase corrected --- vbahelper/inc/vbahelper/vbaapplicationbase.hxx | 3 --- vbahelper/inc/vbahelper/vbadocumentbase.hxx | 3 --- vbahelper/source/vbahelper/vbadocumentbase.cxx | 1 - 3 files changed, 7 deletions(-) diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx index 8611a46a6bfc..6902bc7b5042 100644 --- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx +++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx @@ -68,9 +68,6 @@ public: virtual void SAL_CALL Undo() throw (css::uno::RuntimeException); virtual void SAL_CALL Quit() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL SAL_CALL getVBProjects() throw (css::uno::RuntimeException); - // XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence getServiceNames(); diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx index 8e14a0a8662e..2588b7da1720 100644 --- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx +++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx @@ -54,9 +54,6 @@ public: virtual void SAL_CALL setSaved( sal_Bool bSave ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); // Michhael E. Bohn - - // Methods virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges, const css::uno::Any &aFileName, diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index 01cd63cde7ac..65f7f4bcfbeb 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -35,7 +35,6 @@ #include #include //Michael E. Bohn #include -#include #include #include -- cgit From ad7fbe5ff52f49fca835d7100e1b892b5a362c40 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 30 Jul 2010 17:28:42 +0200 Subject: mib17: #163146# XLS import: do not skip hidden names, do not rename sheet-local names, add Worksheet.Names VBA symbol -- #i112849# fix crash when closing Calc document --- oovbaapi/ooo/vba/excel/XWorksheet.idl | 1 + 1 file changed, 1 insertion(+) diff --git a/oovbaapi/ooo/vba/excel/XWorksheet.idl b/oovbaapi/ooo/vba/excel/XWorksheet.idl index 271cd81d4d0e..fb6261bc06c0 100644 --- a/oovbaapi/ooo/vba/excel/XWorksheet.idl +++ b/oovbaapi/ooo/vba/excel/XWorksheet.idl @@ -114,6 +114,7 @@ interface XWorksheet XRange Rows([in] any aIndex); XRange Columns([in] any aIndex); any Hyperlinks( [in] any aIndex ); + any Names( [in] any Index ); any Evaluate( [in] string Name); -- cgit From 63be9a19153d112ecfbc01f40522f1a388c5bb56 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 4 Aug 2010 13:26:33 +0200 Subject: #i10000# fixed d.lst --- oovbaapi/prj/d.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oovbaapi/prj/d.lst b/oovbaapi/prj/d.lst index ac5924e2d684..86e801a15d93 100644 --- a/oovbaapi/prj/d.lst +++ b/oovbaapi/prj/d.lst @@ -8,7 +8,7 @@ mkdir: %COMMON_DEST%\idl%_EXT%\ooo\vba\word ..\%__SRC%\ucr\oovbaapi.db %_DEST%\bin%_EXT%\oovbaapi.rdb -..\ooo\vba\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\ +..\ooo\vba\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba ..\ooo\vba\constants\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\constants ..\ooo\vba\excel\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\excel ..\ooo\vba\msforms\*.idl %COMMON_DEST%\idl%_EXT%\ooo\vba\msforms -- cgit