summaryrefslogtreecommitdiffstats
path: root/sfx2
diff options
context:
space:
mode:
authorMikhail Voytenko <mav@openoffice.org>2010-04-22 12:51:04 +0200
committerMikhail Voytenko <mav@openoffice.org>2010-04-22 12:51:04 +0200
commite0986b3290e9c73116d86f9ae3b8e35f94aadc2b (patch)
treee522fa525e25d81dab19f873e793787c97e18a3c /sfx2
parenttl78: #i110383# fix typo (diff)
downloadcore-e0986b3290e9c73116d86f9ae3b8e35f94aadc2b.tar.gz
core-e0986b3290e9c73116d86f9ae3b8e35f94aadc2b.zip
tl78: #i110383# password to modify support
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/docfile.hxx2
-rw-r--r--sfx2/inc/sfx2/objsh.hxx3
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx63
-rw-r--r--sfx2/source/doc/docfile.cxx50
-rw-r--r--sfx2/source/doc/objcont.cxx10
-rw-r--r--sfx2/source/doc/objmisc.cxx29
-rw-r--r--sfx2/source/doc/objxtor.cxx1
-rw-r--r--sfx2/source/inc/objshimp.hxx2
-rw-r--r--sfx2/source/view/viewfrm.cxx286
9 files changed, 275 insertions, 171 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 <svtools/helpid.hrc>
#include <svl/pickerhelper.hxx>
#include <comphelper/docpasswordrequest.hxx>
-#include <comphelper/docpasswordhelper.hxx>
#include <ucbhelper/content.hxx>
#include <ucbhelper/commandenvironment.hxx>
#include <comphelper/storagehelper.hxx>
@@ -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 <comphelper/storagehelper.hxx>
#include <comphelper/mediadescriptor.hxx>
#include <comphelper/configurationhelper.hxx>
+#include <comphelper/docpasswordhelper.hxx>
#include <tools/urlobj.hxx>
#include <tools/inetmime.hxx>
#include <unotools/ucblockbytes.hxx>
@@ -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 <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/embed/EmbedStates.hpp>
+#include <com/sun/star/task/PasswordRequestMode.hpp>
#include <rtl/ustrbuf.hxx>
#include <unotools/localfilehelper.hxx>
@@ -86,6 +87,7 @@
#include <basic/sbmeth.hxx>
#include <basic/sbx.hxx>
#include <comphelper/storagehelper.hxx>
+#include <comphelper/docpasswordrequest.hxx>
#include <svtools/asynclink.hxx>
#include <svl/sharecontrolfile.hxx>
@@ -113,6 +115,7 @@ namespace css = ::com::sun::star;
#include "sfxtypes.hxx"
#include <sfx2/request.hxx>
#include <sfx2/docfac.hxx>
+#include <sfx2/docfilt.hxx>
#include <sfx2/ipclient.hxx>
#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 ));