diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-10-30 11:06:18 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-10-31 12:03:30 +0100 |
commit | 1a9261124eed5baa04b069a1cb1b51f24423ec9b (patch) | |
tree | 1cb64575ef26bb2790e73b51371eff869f44cc13 /sfx2 | |
parent | 1eb7a921641107cdd802e8bbc6117d6f303f73f5 (diff) |
CMIS: added cancelCheckOut and checkIn implementations and menu items
Although the implementation is here, the dialogs to show when clicking
on the menu items aren't there yet.
Change-Id: I14886ec8ea8b97a35ca6c8474bc33e30da1a86d3
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/docfile.hxx | 2 | ||||
-rw-r--r-- | sfx2/inc/sfx2/objsh.hxx | 2 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxbasecontroller.hxx | 2 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxbasemodel.hxx | 8 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxcommands.h | 2 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxsids.hrc | 3 | ||||
-rw-r--r-- | sfx2/sdi/docslots.sdi | 10 | ||||
-rw-r--r-- | sfx2/sdi/sfx.sdi | 48 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 60 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 78 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 22 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 138 | ||||
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 2 |
14 files changed, 355 insertions, 25 deletions
diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index 9a134b651b8b..5ba00f65e830 100644 --- a/sfx2/inc/sfx2/docfile.hxx +++ b/sfx2/inc/sfx2/docfile.hxx @@ -194,6 +194,8 @@ public: sal_Bool SwitchDocumentToFile( const rtl::OUString& aURL ); ::rtl::OUString GetBaseURL( bool bForSaving=false ); + void SetInCheckIn( bool bInCheckIn ); + bool IsInCheckIn( ); #if _SOLAR__PRIVATE SAL_DLLPRIVATE sal_Bool HasStorage_Impl() const; diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 88a2abe87a4b..d2a3b3d76440 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -734,6 +734,8 @@ public: SAL_DLLPRIVATE sal_Bool QuerySaveSizeExceededModules_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); SAL_DLLPRIVATE void CheckOut( ); + SAL_DLLPRIVATE void CancelCheckOut( ); + SAL_DLLPRIVATE void CheckIn( ); }; #define SFX_GLOBAL_CLASSID \ diff --git a/sfx2/inc/sfx2/sfxbasecontroller.hxx b/sfx2/inc/sfx2/sfxbasecontroller.hxx index b8daf8b24e88..4db98d5634bb 100644 --- a/sfx2/inc/sfx2/sfxbasecontroller.hxx +++ b/sfx2/inc/sfx2/sfxbasecontroller.hxx @@ -387,7 +387,7 @@ private: SAL_DLLPRIVATE SfxViewFrame& GetViewFrame_Impl() const; SAL_DLLPRIVATE void ShowInfoBars( ); - DECL_LINK( CheckOutHandler, PushButton * ); + DECL_LINK( CheckOutHandler, void * ); //________________________________________________________________________________________________________ // private variables diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx index 3cabf59a7933..49e4dcae72be 100644 --- a/sfx2/inc/sfx2/sfxbasemodel.hxx +++ b/sfx2/inc/sfx2/sfxbasemodel.hxx @@ -1422,8 +1422,16 @@ public: throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL checkOut( ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL cancelCheckOut( ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL checkIn( sal_Bool bIsMajor, const rtl::OUString & rMessage ) + throw ( ::com::sun::star::uno::RuntimeException ); virtual sal_Bool SAL_CALL isVersionable( ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL canCheckOut( ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL canCancelCheckOut( ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL canCheckIn( ) throw ( ::com::sun::star::uno::RuntimeException ); + + sal_Bool getBoolPropertyValue( const rtl::OUString& rName ) throw ( ::com::sun::star::uno::RuntimeException ); //____________________________________________________________________________________________________ // SfxListener diff --git a/sfx2/inc/sfx2/sfxcommands.h b/sfx2/inc/sfx2/sfxcommands.h index 46c7ebcac274..f054ca959d90 100644 --- a/sfx2/inc/sfx2/sfxcommands.h +++ b/sfx2/inc/sfx2/sfxcommands.h @@ -45,6 +45,8 @@ #define CMD_SID_DOCINFO_TITLE ".uno:DocInfoTitle" #define CMD_SID_OPENTEMPLATE ".uno:OpenTemplate" #define CMD_SID_CHECKOUT ".uno:CheckOut" +#define CMD_SID_CANCELCHECKOUT ".uno:CancelCheckOut" +#define CMD_SID_CHECKIN ".uno:CheckIn" #define CMD_SID_OPENURL ".uno:OpenUrl" #define CMD_SID_OPTIONS ".uno:Options" #define CMD_SID_ORGANIZER ".uno:Organizer" diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 9586dde26c50..0998c65b53f4 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -144,6 +144,8 @@ #define SID_DIRECTEXPORTDOCASPDF (SID_SFX_START + 1674) #define SID_UPDATEDOCMODE (SID_SFX_START + 1668) #define SID_CHECKOUT (SID_SFX_START + 512) +#define SID_CANCELCHECKOUT (SID_SFX_START + 513) +#define SID_CHECKIN (SID_SFX_START + 514) #define SID_FORCERELOAD (SID_SFX_START + 1502) #define SID_FILE_DIALOG (SID_SFX_START + 304) @@ -310,6 +312,7 @@ #define SID_DOCINFO_KEYWORDS (SID_SFX_START + 591) #define SID_DOCINFO_COMMENTS (SID_SFX_START + 592) #define SID_DOCINFO_AUTHOR (SID_SFX_START + 593) +#define SID_DOCINFO_MAJOR (SID_SFX_START + 594) #define SID_NEWDOCDIRECT (SID_SFX_START + 537) #define SID_DOCFRAME (SID_SFX_START + 598) #define SID_TARGETNAME (SID_SFX_START + 560) diff --git a/sfx2/sdi/docslots.sdi b/sfx2/sdi/docslots.sdi index 6ba11a83f8e0..111ba6ddf690 100644 --- a/sfx2/sdi/docslots.sdi +++ b/sfx2/sdi/docslots.sdi @@ -182,6 +182,16 @@ interface OfficeDocument : Document ExecMethod = ExecFile_Impl; StateMethod = GetState_Impl; ] + SID_CANCELCHECKOUT + [ + ExecMethod = ExecFile_Impl; + StateMethod = GetState_Impl; + ] + SID_CHECKIN + [ + ExecMethod = ExecFile_Impl; + StateMethod = GetState_Impl; + ] } //========================================================================= diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 635342a40bcc..a7468cef6a2c 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -4468,6 +4468,54 @@ SfxVoidItem CheckOut SID_CHECKOUT GroupId = GID_DOCUMENT; ] +SfxVoidItem CancelCheckOut SID_CANCELCHECKOUT +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = TRUE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_DOCUMENT; +] + +SfxVoidItem CheckIn SID_CHECKIN +(SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxBoolItem VersionMajor SID_DOCINFO_MAJOR) +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = TRUE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_DOCUMENT; +] + //-------------------------------------------------------------------------- SfxStringItem OpenUrl SID_OPENURL diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 36be7f935710..fa308568b59d 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -131,7 +131,8 @@ SfxFormalArgument aFormalArgs[] = { SFX_ARGUMENT(SID_DEFAULTFILENAME,"SuggestedSaveAsName",SfxStringItem), SFX_ARGUMENT(SID_DEFAULTFILEPATH,"SuggestedSaveAsDir",SfxStringItem), SFX_ARGUMENT(SID_DOCINFO_AUTHOR,"VersionAuthor",SfxStringItem), - SFX_ARGUMENT(SID_DOCINFO_COMMENTS,"VersionComment",SfxStringItem), + SFX_ARGUMENT(SID_DOCINFO_COMMENTS,"VersionComment",SfxBoolItem), + SFX_ARGUMENT(SID_DOCINFO_MAJOR,"VersionMajor",SfxStringItem), SFX_ARGUMENT(SID_FILE_FILTEROPTIONS,"FilterOptions",SfxStringItem), SFX_ARGUMENT(SID_FILTER_NAME,"FilterName",SfxStringItem), // SFX_ARGUMENT(SID_FILE_NAME,"FileName",SfxStringItem), diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index e5380e73e4dd..b36a44155b79 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -262,6 +262,7 @@ public: bool m_bTriedStorage:1; bool m_bRemote:1; bool m_bInputStreamIsReadOnly:1; + bool m_bInCheckIn:1; OUString m_aName; OUString m_aLogicName; @@ -336,6 +337,7 @@ SfxMedium_Impl::SfxMedium_Impl( SfxMedium* pAntiImplP ) : m_bTriedStorage(false), m_bRemote(false), m_bInputStreamIsReadOnly(false), + m_bInCheckIn(false), m_pSet(NULL), m_pURLObj(NULL), m_pFilter(NULL), @@ -1924,23 +1926,31 @@ void SfxMedium::Transfer_Impl() ::ucbhelper::Content aSourceContent; ::ucbhelper::Content aTransferContent; - // Get the parent URL from the XChild if possible: why would the URL necessarily have - // a hierarchical path? It's not always the case for CMIS. ::ucbhelper::Content aDestContent; ::ucbhelper::Content::create( aDestURL, xComEnv, comphelper::getProcessComponentContext(), aDestContent ); - Reference< ::com::sun::star::container::XChild> xChild( aDestContent.get(), uno::UNO_QUERY ); - rtl::OUString sParentUrl; - if ( xChild.is( ) ) + if ( !IsInCheckIn( ) ) { - Reference< ::com::sun::star::ucb::XContent > xParent( xChild->getParent( ), uno::UNO_QUERY ); - if ( xParent.is( ) ) + // Get the parent URL from the XChild if possible: why would the URL necessarily have + // a hierarchical path? It's not always the case for CMIS. + Reference< ::com::sun::star::container::XChild> xChild( aDestContent.get(), uno::UNO_QUERY ); + rtl::OUString sParentUrl; + if ( xChild.is( ) ) { - sParentUrl = xParent->getIdentifier( )->getContentIdentifier(); + Reference< ::com::sun::star::ucb::XContent > xParent( xChild->getParent( ), uno::UNO_QUERY ); + if ( xParent.is( ) ) + { + sParentUrl = xParent->getIdentifier( )->getContentIdentifier(); + } } - } - if ( !sParentUrl.isEmpty() ) - aDest = INetURLObject( sParentUrl ); + if ( !sParentUrl.isEmpty() ) + aDest = INetURLObject( sParentUrl ); + } + else + { + // For checkin, we need the object URL, not the parent folder + aDest = INetURLObject( aDestURL ); + } // LongName wasn't defined anywhere, only used here... get the Title instead // as it's less probably empty @@ -1997,8 +2007,24 @@ void SfxMedium::Transfer_Impl() try { rtl::OUString aMimeType = GetFilter()->GetMimeType( ); - if (!aTransferContent.transferContent( aSourceContent, ::ucbhelper::InsertOperation_COPY, aFileName, nNameClash, aMimeType )) + ::ucbhelper::InsertOperation eOperation = ::ucbhelper::InsertOperation_COPY; + bool bMajor = false; + rtl::OUString sComment; + if ( IsInCheckIn( ) ) + { + eOperation = ::ucbhelper::InsertOperation_CHECKIN; + SFX_ITEMSET_ARG( GetItemSet(), pMajor, SfxBoolItem, SID_DOCINFO_MAJOR, false ); + bMajor = pMajor && pMajor->GetValue( ); + SFX_ITEMSET_ARG( GetItemSet(), pComments, SfxStringItem, SID_DOCINFO_COMMENTS, false ); + if ( pComments ) + sComment = pComments->GetValue( ); + } + rtl::OUString sResultURL; + if (!aTransferContent.transferContent( aSourceContent, eOperation, + aFileName, nNameClash, aMimeType, bMajor, sComment, &sResultURL )) pImp->m_eError = ERRCODE_IO_GENERAL; + else if ( !sResultURL.isEmpty( ) ) // Likely to happen only for checkin + SwitchDocumentToFile( sResultURL ); } catch ( const ::com::sun::star::ucb::CommandAbortedException& ) { @@ -3694,4 +3720,14 @@ sal_Bool SfxMedium::SwitchDocumentToFile( const rtl::OUString& aURL ) return bResult; } +void SfxMedium::SetInCheckIn( bool bInCheckIn ) +{ + pImp->m_bInCheckIn = bInCheckIn; +} + +bool SfxMedium::IsInCheckIn( ) +{ + return pImp->m_bInCheckIn; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 13571881069c..116f97608c5f 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -361,6 +361,43 @@ void SfxObjectShell::CheckOut( ) } } +void SfxObjectShell::CancelCheckOut( ) +{ + try + { + uno::Reference< document::XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY_THROW ); + // TODO Pop up dialog to ask whether to loose data or not + xCmisDoc->cancelCheckOut( ); + } + catch ( const uno::RuntimeException& e ) + { + ErrorBox* pErrorBox = new ErrorBox( &GetFrame()->GetWindow(), WB_OK, e.Message ); + pErrorBox->Execute( ); + delete pErrorBox; + } +} + +void SfxObjectShell::CheckIn( ) +{ + try + { + uno::Reference< document::XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY_THROW ); + sal_Bool bIsMajor = sal_False; + rtl::OUString sComment( "Some sample comment" ); + // TODO Pop up dialog to ask for comment and major + xCmisDoc->checkIn( bIsMajor, sComment ); + uno::Reference< util::XModifiable > xModifiable( GetModel( ), uno::UNO_QUERY ); + if ( xModifiable.is( ) ) + xModifiable->setModified( sal_False ); + } + catch ( const uno::RuntimeException& e ) + { + ErrorBox* pErrorBox = new ErrorBox( &GetFrame()->GetWindow(), WB_OK, e.Message ); + pErrorBox->Execute( ); + delete pErrorBox; + } +} + //-------------------------------------------------------------------- void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) @@ -912,6 +949,16 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) CheckOut( ); break; } + case SID_CANCELCHECKOUT: + { + CancelCheckOut( ); + break; + } + case SID_CHECKIN: + { + CheckIn( ); + break; + } } // Prevent entry in the Pick-lists @@ -976,6 +1023,37 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) } break; + case SID_CANCELCHECKOUT: + case SID_CHECKIN: + { + bool bShow = false; + Reference< XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY ); + beans::PropertyValues aCmisProperties = xCmisDoc->getCmisPropertiesValues( ); + + if ( xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( ) ) + { + // Loop over the CMIS Properties to find cmis:isVersionSeriesCheckedOut + bool bFoundCheckedout = false; + sal_Bool bCheckedOut = sal_False; + for ( sal_Int32 i = 0; i < aCmisProperties.getLength() && !bFoundCheckedout; ++i ) + { + if ( aCmisProperties[i].Name == "cmis:isVersionSeriesCheckedOut" ) + { + bFoundCheckedout = true; + aCmisProperties[i].Value >>= bCheckedOut; + } + } + bShow = bCheckedOut; + } + + if ( !bShow ) + { + rSet.DisableItem( nWhich ); + rSet.Put( SfxVisibilityItem( nWhich, sal_False ) ); + } + } + break; + case SID_VERSION: { SfxObjectShell *pDoc = this; diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 45b1cb28fa37..9fe53943155e 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1374,7 +1374,7 @@ sal_Bool SfxObjectShell::SaveTo_Impl pFilter = rMedium.GetFilter(); - const SfxStringItem *pVersionItem = pSet ? (const SfxStringItem*) + const SfxStringItem *pVersionItem = ( !rMedium.IsInCheckIn( ) && pSet ) ? (const SfxStringItem*) SfxRequest::GetItem( pSet, SID_DOCINFO_COMMENTS, sal_False, TYPE(SfxStringItem) ) : NULL; ::rtl::OUString aTmpVersionURL; @@ -1460,7 +1460,7 @@ sal_Bool SfxObjectShell::SaveTo_Impl } } - if ( bOk && pVersionItem ) + if ( bOk && pVersionItem && !rMedium.IsInCheckIn() ) { // store a version also const SfxStringItem *pAuthorItem = pSet ? (const SfxStringItem*) @@ -1624,7 +1624,12 @@ sal_Bool SfxObjectShell::SaveTo_Impl AddLog( ::rtl::OUString( OSL_LOG_PREFIX "Medium commit." ) ); + rtl::OUString sName( rMedium.GetName( ) ); bOk = rMedium.Commit(); + rtl::OUString sNewName( rMedium.GetName( ) ); + + if ( sName != sNewName ) + GetMedium( )->SwitchDocumentToFile( sNewName ); if ( bOk ) { @@ -2414,10 +2419,23 @@ sal_Bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) pSet->ClearItem( SID_VERSION ); pSet->ClearItem( SID_DOC_BASEURL ); + // copy the version comment and major items for the checkin only + if ( pRetrMedium->IsInCheckIn( ) ) + { + const SfxPoolItem* pMajor = pArgs->GetItem( SID_DOCINFO_MAJOR ); + if ( pMajor ) + pSet->Put( *pMajor ); + + const SfxPoolItem* pComments = pArgs->GetItem( SID_DOCINFO_COMMENTS ); + if ( pComments ) + pSet->Put( *pComments ); + } + // create a medium as a copy; this medium is only for writingm, because it // uses the same name as the original one writing is done through a copy, // that will be transferred to the target (of course after calling HandsOff) SfxMedium* pMediumTmp = new SfxMedium( pRetrMedium->GetName(), pRetrMedium->GetOpenMode(), pFilter, pSet ); + pMediumTmp->SetInCheckIn( pRetrMedium->IsInCheckIn( ) ); pMediumTmp->SetLongName( pRetrMedium->GetLongName() ); if ( pMediumTmp->GetErrorCode() != ERRCODE_NONE ) { diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index cc2abe9ec95d..46f0bee4debd 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1621,11 +1621,13 @@ void SAL_CALL SfxBaseModel::storeSelf( const uno::Sequence< beans::PropertyVa m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "storeSelf" ) ); SfxSaveGuard aSaveGuard(this, m_pData, sal_False); + sal_Bool bCheckIn = sal_False; for ( sal_Int32 nInd = 0; nInd < aSeqArgs.getLength(); nInd++ ) { // check that only acceptable parameters are provided here if ( aSeqArgs[nInd].Name != "VersionComment" && aSeqArgs[nInd].Name != "Author" - && aSeqArgs[nInd].Name != "InteractionHandler" && aSeqArgs[nInd].Name != "StatusIndicator" ) + && aSeqArgs[nInd].Name != "InteractionHandler" && aSeqArgs[nInd].Name != "StatusIndicator" + && aSeqArgs[nInd].Name != "VersionMajor" && aSeqArgs[nInd].Name != "CheckIn" ) { m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "unexpected parameter for storeSelf, might be no problem if SaveAs is executed." ) ); m_pData->m_pObjectShell->StoreLog(); @@ -1634,10 +1636,34 @@ void SAL_CALL SfxBaseModel::storeSelf( const uno::Sequence< beans::PropertyVa aMessage += aSeqArgs[nInd].Name; throw lang::IllegalArgumentException( aMessage, uno::Reference< uno::XInterface >(), 1 ); } + else if ( aSeqArgs[nInd].Name == "CheckIn" ) + { + aSeqArgs[nInd].Value >>= bCheckIn; + } + } + + // Remove CheckIn property if needed + sal_uInt16 nSlotId = SID_SAVEDOC; + uno::Sequence< beans::PropertyValue > aArgs = aSeqArgs; + if ( bCheckIn ) + { + nSlotId = SID_CHECKIN; + sal_Int32 nLength = aSeqArgs.getLength( ); + aArgs = uno::Sequence< beans::PropertyValue >( nLength - 1 ); + sal_Int32 nNewI = 0; + for ( sal_Int32 i = 0; i < nLength; ++i ) + { + beans::PropertyValue aProp = aSeqArgs[i]; + if ( aProp.Name != "CheckIn" ) + { + aArgs[nNewI] = aProp; + ++nNewI; + } + } } SfxAllItemSet *pParams = new SfxAllItemSet( SFX_APP()->GetPool() ); - TransformParameters( SID_SAVEDOC, aSeqArgs, *pParams ); + TransformParameters( nSlotId, aArgs, *pParams ); SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOC, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOC), m_pData->m_pObjectShell ) ); @@ -1662,7 +1688,12 @@ void SAL_CALL SfxBaseModel::storeSelf( const uno::Sequence< beans::PropertyVa } } else + { + // Tell the SfxMedium if we are in checkin instead of normal save + m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId == SID_CHECKIN ); bRet = m_pData->m_pObjectShell->Save_Impl( pParams ); + m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId != SID_CHECKIN ); + } DELETEZ( pParams ); @@ -2577,9 +2608,81 @@ void SAL_CALL SfxBaseModel::checkOut( ) throw ( uno::RuntimeException ) } } -sal_Bool SAL_CALL SfxBaseModel::isVersionable( ) throw ( uno::RuntimeException ) +void SAL_CALL SfxBaseModel::cancelCheckOut( ) throw ( uno::RuntimeException ) { - sal_Bool bVersionable = sal_False; + SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); + if ( pMedium ) + { + try + { + ::ucbhelper::Content aContent( pMedium->GetName(), + uno::Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext() ); + + uno::Any aResult = aContent.executeCommand( "cancelCheckout", uno::Any( ) ); + rtl::OUString sURL; + aResult >>= sURL; + + m_pData->m_pObjectShell->GetMedium( )->SwitchDocumentToFile( sURL ); + m_pData->m_xDocumentProperties->setTitle( getTitle( ) ); + uno::Sequence< beans::PropertyValue > aSequence ; + TransformItems( SID_OPENDOC, *pMedium->GetItemSet(), aSequence ); + attachResource( sURL, aSequence ); + + // Reload the CMIS properties + loadCmisProperties( ); + } + catch ( const uno::Exception & e ) + { + throw uno::RuntimeException( e.Message, e.Context ); + } + } +} + +void SAL_CALL SfxBaseModel::checkIn( sal_Bool bIsMajor, const rtl::OUString& rMessage ) throw ( uno::RuntimeException ) +{ + SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); + if ( pMedium ) + { + try + { + uno::Sequence< beans::PropertyValue > aProps( 3 ); + aProps[0].Name = "VersionMajor"; + aProps[0].Value = uno::makeAny( bIsMajor ); + aProps[1].Name = "VersionComment"; + aProps[1].Value = uno::makeAny( rMessage ); + aProps[2].Name = "CheckIn"; + aProps[2].Value = uno::makeAny( sal_True ); + + rtl::OUString sName( pMedium->GetName( ) ); + storeSelf( aProps ); + + // Refresh pMedium as it has probably changed during the storeSelf call + pMedium = m_pData->m_pObjectShell->GetMedium( ); + rtl::OUString sNewName( pMedium->GetName( ) ); + + // URL has changed, update the document + if ( sName != sNewName ) + { + m_pData->m_xDocumentProperties->setTitle( getTitle( ) ); + uno::Sequence< beans::PropertyValue > aSequence ; + TransformItems( SID_OPENDOC, *pMedium->GetItemSet(), aSequence ); + attachResource( sNewName, aSequence ); + + // Reload the CMIS properties + loadCmisProperties( ); + } + } + catch ( const uno::Exception & e ) + { + throw uno::RuntimeException( e.Message, e.Context ); + } + } +} + +sal_Bool SfxBaseModel::getBoolPropertyValue( const rtl::OUString& rName ) throw ( uno::RuntimeException ) +{ + sal_Bool bValue = sal_False; SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); if ( pMedium ) { @@ -2589,10 +2692,9 @@ sal_Bool SAL_CALL SfxBaseModel::isVersionable( ) throw ( uno::RuntimeException ) uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext() ); com::sun::star::uno::Reference < beans::XPropertySetInfo > xProps = aContent.getProperties(); - ::rtl::OUString aIsVersionableProp( "IsVersionable" ); - if ( xProps->hasPropertyByName( aIsVersionableProp ) ) + if ( xProps->hasPropertyByName( rName ) ) { - aContent.getPropertyValue( aIsVersionableProp ) >>= bVersionable; + aContent.getPropertyValue( rName ) >>= bValue; } } catch ( const uno::Exception & e ) @@ -2600,7 +2702,27 @@ sal_Bool SAL_CALL SfxBaseModel::isVersionable( ) throw ( uno::RuntimeException ) throw uno::RuntimeException( e.Message, e.Context ); } } - return bVersionable; + return bValue; +} + +sal_Bool SAL_CALL SfxBaseModel::isVersionable( ) throw ( uno::RuntimeException ) +{ + return getBoolPropertyValue( "IsVersionable" ); +} + +sal_Bool SAL_CALL SfxBaseModel::canCheckOut( ) throw ( uno::RuntimeException ) +{ + return getBoolPropertyValue( "CanCheckOut" ); +} + +sal_Bool SAL_CALL SfxBaseModel::canCancelCheckOut( ) throw ( uno::RuntimeException ) +{ + return getBoolPropertyValue( "CanCancelCheckOut" ); +} + +sal_Bool SAL_CALL SfxBaseModel::canCheckIn( ) throw ( uno::RuntimeException ) +{ + return getBoolPropertyValue( "CanCheckIn" ); } void SfxBaseModel::loadCmisProperties( ) diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 54827c5d7436..81638ff2076b 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -1470,7 +1470,7 @@ void SfxBaseController::ShowInfoBars( ) } } -IMPL_LINK( SfxBaseController, CheckOutHandler, PushButton*, pBtn ) +IMPL_LINK_NOARG ( SfxBaseController, CheckOutHandler ) { if ( m_pData->m_pViewShell ) m_pData->m_pViewShell->GetObjectShell()->CheckOut( ); |