Commits

Anonymous committed 11ab264

CWS-TOOLING: integrate CWS mav48_DEV300
2009-03-09 12:55:54 +0100 mav r269080 : #i99918# provide decoded version of the name
2009-03-09 10:14:59 +0100 mav r269064 : #99967# let readonly files be correctly recognized
2009-03-09 07:04:09 +0100 mav r269056 : #i99922# fix the typo
2009-03-06 14:10:29 +0100 mav r269005 : #i99922# convert system path correctly
2009-03-06 13:53:45 +0100 mav r269001 : #i99922# Prevent the problem for the case that the configuration contains wrong URL
2009-03-06 13:16:56 +0100 mav r268999 : #i99919# handle SID_OPENHYPERLINK correctly in slide-show

Comments (0)

Files changed (6)

 		StateMethod = GetState ;
 	]
 
+	SID_OPENHYPERLINK // ole() api()
+	[
+
+		ExecMethod = Execute ;
+		StateMethod = GetState ;
+	]
+
 	SID_AUTOSPELL_CHECK // ole() api()
 	[
 

sd/source/ui/app/sdmod1.cxx

 
 			break;
 
+		case SID_OPENHYPERLINK:
 		case SID_OPENDOC:
 		{
 			BOOL bIntercept = FALSE;
 			rItemSet.Put(*pItem);
 	}
 
+	// der Status von SID_OPENHYPERLINK wird von der Basisklasse bestimmt
+	if (rItemSet.GetItemState(SID_OPENHYPERLINK) != SFX_ITEM_UNKNOWN)
+	{
+        const SfxPoolItem* pItem = SFX_APP()->GetSlotState(SID_OPENHYPERLINK, SFX_APP()->GetInterface());
+		if (pItem)
+			rItemSet.Put(*pItem);
+	}
+
     if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_AUTOSPELL_CHECK ) )
 	{
 		::sd::DrawDocShell* pDocSh =

sd/source/ui/slideshow/slideshowimpl.cxx

 	SID_JUMPTOMARK							, //	 5598
 // 	SID_SHOWPOPUPS							, //	 5929
 //    SID_GALLERY                             , //     5960
+	SID_OPENHYPERLINK						, //	 6676
 //    SID_GALLERY_FORMATS                     , //    10280
     SID_NAVIGATOR							, //	10366
 //	SID_FM_DESIGN_MODE						, //	10629

sfx2/source/doc/docfile.cxx

     sal_Bool m_bSalvageMode: 1;
     sal_Bool m_bVersionsAlreadyLoaded: 1;
     sal_Bool m_bLocked: 1;
-    sal_Bool m_bHandleSysLocked: 1;
     sal_Bool m_bGotDateTime: 1;
 
     uno::Reference < embed::XStorage > xStorage;
     m_bSalvageMode( sal_False ),
     m_bVersionsAlreadyLoaded( sal_False ),
     m_bLocked( sal_False ),
-    m_bHandleSysLocked( sal_False ),
     m_bGotDateTime( sal_False ),
     pAntiImpl( pAntiImplP ),
     nFileVersion( 0 ),
 
     sal_Bool bResult = pImp->m_bLocked;
 
-    if ( ::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
+    if ( !bResult )
     {
-        // the special file locking should be used only for file URLs
-
-        // in case of storing the document should request the output before locking
+        // no read-write access is necessary on loading if the document is explicitly opened as copy
+        SFX_ITEMSET_ARG( GetItemSet(), pTemplateItem, SfxBoolItem, SID_TEMPLATE, sal_False);
+        bResult = ( bLoading && pTemplateItem && pTemplateItem->GetValue() );
+    }
+
+    if ( !bResult && !IsReadOnly() )
+    {
+        // check whether the file is readonly in fs
+        // do it only for loading, some contents still might have problems with this property, let them not affect the saving
+        sal_Bool bContentReadonly = sal_False;
         if ( bLoading )
         {
-            // let the stream be opened to check the system file locking
-            GetMedium_Impl();
-        }
-
-        // no locking is necessary on loading if the document is explicitly opened as copy
-        SFX_ITEMSET_ARG( GetItemSet(), pTemplateItem, SfxBoolItem, SID_TEMPLATE, sal_False);
-        bResult = ( bLoading && pTemplateItem && pTemplateItem->GetValue() );
-
-        if ( !bResult && ( !IsReadOnly() || pImp->m_bHandleSysLocked ) )
-        {
-            sal_Int8 bUIStatus = LOCK_UI_NOLOCK;
-
-            // check whether system file locking has been used, the default value is false
-            sal_Bool bUseSystemLock = sal_False;
             try
             {
-
-                uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig(
-                                    ::comphelper::getProcessServiceFactory(),
-                                    ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common" ) ),
-                                    ::comphelper::ConfigurationHelper::E_STANDARD );
-                if ( !xCommonConfig.is() )
-                    throw uno::RuntimeException();
-
-                ::comphelper::ConfigurationHelper::readRelativeKey(
-                        xCommonConfig,
-                        ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Misc/" ) ),
-                        ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseDocumentSystemFileLocking" ) ) ) >>= bUseSystemLock;
+                // MediaDescriptor does this check also, the duplication should be avoided in future
+                pImp->aContent.getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ) ) >>= bContentReadonly;
             }
-            catch( const uno::Exception& )
+            catch( uno::Exception )
+            {}
+        }
+
+        if ( !bContentReadonly )
+        {
+            if ( ::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
             {
-            }
-
-            // TODO/LATER: This implementation does not allow to detect the system lock on saving here, actually this is no big problem
-            if ( bLoading && bUseSystemLock && !pImp->xStream.is() && !pOutStream )
-                pImp->m_bHandleSysLocked = sal_True; // if system lock is used the writeable stream should be available
-
-            do
-            {
+                // the special file locking should be used only for file URLs
+
+                // in case of storing the document should request the output before locking
+                if ( bLoading )
+                {
+                    // let the stream be opened to check the system file locking
+                    GetMedium_Impl();
+                }
+
+                sal_Int8 bUIStatus = LOCK_UI_NOLOCK;
+
+                // check whether system file locking has been used, the default value is false
+                sal_Bool bUseSystemLock = sal_False;
                 try
-                {   
-                    ::svt::DocumentLockFile aLockFile( aLogicName );
-                    if ( !pImp->m_bHandleSysLocked )
-                    {
-                        try
+                {
+                    uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig(
+                                        ::comphelper::getProcessServiceFactory(),
+                                        ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common" ) ),
+                                        ::comphelper::ConfigurationHelper::E_STANDARD );
+                    if ( !xCommonConfig.is() )
+                        throw uno::RuntimeException();
+
+                    ::comphelper::ConfigurationHelper::readRelativeKey(
+                            xCommonConfig,
+                            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Misc/" ) ),
+                            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseDocumentSystemFileLocking" ) ) ) >>= bUseSystemLock;
+                }
+                catch( const uno::Exception& )
+                {
+                }
+
+                // TODO/LATER: This implementation does not allow to detect the system lock on saving here, actually this is no big problem
+                // if system lock is used the writeable stream should be available
+                sal_Bool bHandleSysLocked = ( bLoading && bUseSystemLock && !pImp->xStream.is() && !pOutStream );
+
+                do
+                {
+                    try
+                    {   
+                        ::svt::DocumentLockFile aLockFile( aLogicName );
+                        if ( !bHandleSysLocked )
                         {
-                            bResult = aLockFile.CreateOwnLockFile();
-                        }
-                        catch ( ucb::InteractiveIOException& e )
-                        {
-                            if ( e.Code == IOErrorCode_INVALID_PARAMETER )
+                            try
                             {
-                                // it looks like the lock file name is not accepted by the content
-                                if ( !bUseSystemLock )
+                                bResult = aLockFile.CreateOwnLockFile();
+                            }
+                            catch ( ucb::InteractiveIOException& e )
+                            {
+                                if ( e.Code == IOErrorCode_INVALID_PARAMETER )
                                 {
-                                    // system file locking is not active, ask user whether he wants to open the document without any locking
-                                    uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
-                                    
-                                    if ( xHandler.is() )
+                                    // it looks like the lock file name is not accepted by the content
+                                    if ( !bUseSystemLock )
                                     {
-                                        ::rtl::Reference< ::ucbhelper::InteractionRequest > xIgnoreRequestImpl
-                                            = new ::ucbhelper::InteractionRequest( uno::makeAny( document::LockFileIgnoreRequest() ) );
-
-                                        uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 2 );
-                                        aContinuations[0] = new ::ucbhelper::InteractionAbort( xIgnoreRequestImpl.get() );
-                                        aContinuations[1] = new ::ucbhelper::InteractionApprove( xIgnoreRequestImpl.get() );
-                                        xIgnoreRequestImpl->setContinuations( aContinuations );
-
-                                        xHandler->handle( xIgnoreRequestImpl.get() );
-
-                                        ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xIgnoreRequestImpl->getSelection();
-                                        bResult = (  uno::Reference< task::XInteractionApprove >( xSelected.get(), uno::UNO_QUERY ).is() );
+                                        // system file locking is not active, ask user whether he wants to open the document without any locking
+                                        uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
+                                        
+                                        if ( xHandler.is() )
+                                        {
+                                            ::rtl::Reference< ::ucbhelper::InteractionRequest > xIgnoreRequestImpl
+                                                = new ::ucbhelper::InteractionRequest( uno::makeAny( document::LockFileIgnoreRequest() ) );
+
+                                            uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 2 );
+                                            aContinuations[0] = new ::ucbhelper::InteractionAbort( xIgnoreRequestImpl.get() );
+                                            aContinuations[1] = new ::ucbhelper::InteractionApprove( xIgnoreRequestImpl.get() );
+                                            xIgnoreRequestImpl->setContinuations( aContinuations );
+
+                                            xHandler->handle( xIgnoreRequestImpl.get() );
+
+                                            ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xIgnoreRequestImpl->getSelection();
+                                            bResult = (  uno::Reference< task::XInteractionApprove >( xSelected.get(), uno::UNO_QUERY ).is() );
+                                        }
                                     }
+                                    else
+                                        bResult = sal_True;
                                 }
                                 else
+                                    throw;
+                            }
+                        }
+
+                       
+                        if ( !bResult )
+                        {
+                            uno::Sequence< ::rtl::OUString > aData;
+                            try
+                            {
+                                // impossibility to get data is no real problem
+                                aData = aLockFile.GetLockData();
+                            }
+                            catch( uno::Exception ) {}
+
+                            sal_Bool bOwnLock = sal_False;
+
+                            if ( !bHandleSysLocked )
+                            {
+                                uno::Sequence< ::rtl::OUString > aOwnData = aLockFile.GenerateOwnEntry();
+                                bOwnLock = ( aData.getLength() > LOCKFILE_USERURL_ID
+                                          && aOwnData.getLength() > LOCKFILE_USERURL_ID
+                                          && aOwnData[LOCKFILE_SYSUSERNAME_ID].equals( aData[LOCKFILE_SYSUSERNAME_ID] ) );
+                           
+                                if ( bOwnLock
+                                  && aOwnData[LOCKFILE_LOCALHOST_ID].equals( aData[LOCKFILE_LOCALHOST_ID] )
+                                  && aOwnData[LOCKFILE_USERURL_ID].equals( aData[LOCKFILE_USERURL_ID] ) )
+                                {
+                                    // this is own lock from the same installation, it could remain because of crash
                                     bResult = sal_True;
+                                }
                             }
-                            else
-                                throw;
+
+                            if ( !bResult && !bNoUI )
+                            {
+                                bUIStatus = ShowLockedDocumentDialog( aData, bLoading, bOwnLock );
+                                if ( bUIStatus == LOCK_UI_SUCCEEDED )
+                                {
+                                    // take the ownership over the lock file
+                                    bResult = aLockFile.OverwriteOwnLockFile();
+                                }
+                            }
+
+                            bHandleSysLocked = sal_False;
                         }
                     }
-
-                   
-                    if ( !bResult )
+                    catch( uno::Exception& )
                     {
-                        uno::Sequence< ::rtl::OUString > aData;
-                        try
-                        {
-                            // impossibility to get data is no real problem
-                            aData = aLockFile.GetLockData();
-                        }
-                        catch( uno::Exception ) {}
-
-                        sal_Bool bOwnLock = sal_False;
-
-                        if ( !pImp->m_bHandleSysLocked )
-                        {
-                            uno::Sequence< ::rtl::OUString > aOwnData = aLockFile.GenerateOwnEntry();
-                            bOwnLock = ( aData.getLength() > LOCKFILE_USERURL_ID
-                                      && aOwnData.getLength() > LOCKFILE_USERURL_ID
-                                      && aOwnData[LOCKFILE_SYSUSERNAME_ID].equals( aData[LOCKFILE_SYSUSERNAME_ID] ) );
-                       
-                            if ( bOwnLock
-                              && aOwnData[LOCKFILE_LOCALHOST_ID].equals( aData[LOCKFILE_LOCALHOST_ID] )
-                              && aOwnData[LOCKFILE_USERURL_ID].equals( aData[LOCKFILE_USERURL_ID] ) )
-                            {
-                                // this is own lock from the same installation, it could remain because of crash
-                                bResult = sal_True;
-                            }
-                        }
-
-                        if ( !bResult && !bNoUI )
-                        {
-                            bUIStatus = ShowLockedDocumentDialog( aData, bLoading, bOwnLock );
-                            if ( bUIStatus == LOCK_UI_SUCCEEDED )
-                            {
-                                // take the ownership over the lock file
-                                bResult = aLockFile.OverwriteOwnLockFile();
-                            }
-                        }
-
-                        pImp->m_bHandleSysLocked = sal_False;
                     }
-                }
-                catch( uno::Exception& )
-                {
-                }
-            } while( !bResult && bUIStatus == LOCK_UI_TRY );
-
-            pImp->m_bLocked = bResult;
-        }
-
-        if ( !bResult && GetError() == ERRCODE_NONE )
-        {
-            // the error should be set in case it is storing process
-            // or the document has been opened for editing explicitly
-
-            SFX_ITEMSET_ARG( pSet, pReadOnlyItem, SfxBoolItem, SID_DOC_READONLY, FALSE );
-            if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->GetValue()) )
-                SetError( ERRCODE_IO_ACCESSDENIED );
-            else 
-                GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
+                } while( !bResult && bUIStatus == LOCK_UI_TRY );
+
+                pImp->m_bLocked = bResult;
+            }
+            else
+            {
+                // this is no file URL, check whether the file is readonly
+                bResult = !bContentReadonly;
+            }
         }
     }
-    else
-        bResult = sal_True;
+
+    if ( !bResult && GetError() == ERRCODE_NONE )
+    {
+        // the error should be set in case it is storing process
+        // or the document has been opened for editing explicitly
+
+        SFX_ITEMSET_ARG( pSet, pReadOnlyItem, SfxBoolItem, SID_DOC_READONLY, FALSE );
+        if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->GetValue()) )
+            SetError( ERRCODE_IO_ACCESSDENIED );
+        else 
+            GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
+    }
 
     return bResult;
 }
             {
                 TransformItems( SID_OPENDOC, *GetItemSet(), xProps );
                 comphelper::MediaDescriptor aMedium( xProps );
-                sal_Bool bRequestedReadOnly = aMedium.getUnpackedValueOrDefault( ::comphelper::MediaDescriptor::PROP_READONLY(), sal_False );
 
                 if ( bFromTempFile )
                 {
                 else
                     aMedium.addInputStream();
 
-                // the warning is shown if the user wants to edit the document, but it is not possible
-                pImp->m_bHandleSysLocked = ( !bRequestedReadOnly && aMedium.getUnpackedValueOrDefault( ::comphelper::MediaDescriptor::PROP_READONLY(), sal_False ) );
-
-                sal_Bool bReadOnly = sal_False;
-                aMedium[comphelper::MediaDescriptor::PROP_READONLY()] >>= bReadOnly;
-                if ( bReadOnly )
-                {
-                    SFX_ITEMSET_ARG( GetItemSet(), pROItem, SfxBoolItem, SID_DOC_READONLY, sal_False);
-                    BOOL bForceWritable = ( pROItem && !pROItem->GetValue() );
-                    GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
-                    if( bForceWritable )
-                        SetError( ERRCODE_IO_ACCESSDENIED );
-                }
+                // the ReadOnly property set in aMedium is ignored
+                // the check is done in LockOrigFileOnDemand() for file and non-file URLs
 
                 //TODO/MBA: what happens if property is not there?!
                 GetContent();

sfx2/source/doc/guisaveas.cxx

 	// get the path from the dialog
 	INetURLObject aURL( pFileDlg->GetPath() );
 	// the path should be provided outside since it might be used for further calls to the dialog
-	aSuggestedName = aURL.GetMainURL( INetURLObject::NO_DECODE );
+	aSuggestedName = aURL.GetName( INetURLObject::DECODE_WITH_CHARSET );
 
 	// old filter options should be cleared in case different filter is used
 
 	else
 	{
         // pb: set graphic path if context == SD_EXPORT or SI_EXPORT else work path
-        aReccomendedDir = ( aCtxt != sfx2::FileDialogHelper::UNKNOWN_CONTEXT )
-            ? SvtPathOptions().GetGraphicPath() : SvtPathOptions().GetWorkPath();
+        ::rtl::OUString aConfigSuggestion( ( aCtxt != sfx2::FileDialogHelper::UNKNOWN_CONTEXT ) ? SvtPathOptions().GetGraphicPath() : SvtPathOptions().GetWorkPath() );
+        aReccomendedDir = INetURLObject( aConfigSuggestion ).GetMainURL( INetURLObject::NO_DECODE );
 	}
     
     return aReccomendedDir;
         aReccomendedName = aSuggestedName;
     else
     {
-        aReccomendedName = INetURLObject( GetStorable()->getLocation() ).GetName();
+        aReccomendedName = INetURLObject( GetStorable()->getLocation() ).GetName( INetURLObject::DECODE_WITH_CHARSET );
         if ( !aReccomendedName.getLength() )
         {
             try {
                         aObj.SetExtension( aExtensions[0] );
                 }
 
-				aReccomendedName = aObj.GetName();
+				aReccomendedName = aObj.GetName( INetURLObject::DECODE_WITH_CHARSET );
 			}
 		}
     }

shell/source/backends/kdebe/kdepathslayer.cxx

     uno::Sequence<backend::PropertyInfo> aPropInfoList(1);
     sal_Int32 nProperties = 0;
 
-    QString aDocumentsDir( "file:" );
-    ::rtl::OUString sDocumentsDir;
-
-    aDocumentsDir += KGlobalSettings::documentPath();
+    QString aDocumentsDir( KGlobalSettings::documentPath() );
+    rtl::OUString sDocumentsDir;
+    rtl::OUString sDocumentsURL;
     if ( aDocumentsDir.endsWith(QChar('/')) )
         aDocumentsDir.truncate ( aDocumentsDir.length() - 1 );
     sDocumentsDir = (const sal_Unicode *) aDocumentsDir.ucs2();
+    osl_getFileURLFromSystemPath( sDocumentsDir.pData, &sDocumentsURL.pData );
 
     aPropInfoList[nProperties].Name = rtl::OUString(
         RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Paths/Variables/Work") );
     aPropInfoList[nProperties].Type = rtl::OUString( 
         RTL_CONSTASCII_USTRINGPARAM( "string" ) );
     aPropInfoList[nProperties].Protected = sal_False;
-    aPropInfoList[nProperties++].Value = uno::makeAny( sDocumentsDir );
+    aPropInfoList[nProperties++].Value = uno::makeAny( sDocumentsURL );
 
     if( nProperties > 0 )
     {