summaryrefslogtreecommitdiff
path: root/sfx2/source/doc/objserv.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/doc/objserv.cxx')
-rw-r--r--sfx2/source/doc/objserv.cxx143
1 files changed, 143 insertions, 0 deletions
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 70a4f1dd6c48..2412dcc7b744 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -28,11 +28,13 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/document/XCmisDocument.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/task/InteractionHandler.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
#include <com/sun/star/frame/DocumentTemplates.hpp>
+#include <com/sun/star/frame/XController2.hpp>
#include <com/sun/star/frame/XDocumentTemplates.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <comphelper/processfactory.hxx>
@@ -46,6 +48,7 @@
#include <vcl/msgbox.hxx>
#include <svl/intitem.hxx>
#include <svl/eitem.hxx>
+#include <svl/visitem.hxx>
#include <vcl/wrkwin.hxx>
#include <svtools/sfxecode.hxx>
#include <svtools/ehdl.hxx>
@@ -84,6 +87,7 @@
#include "sfx2/sfxhelp.hxx"
#include <sfx2/msgpool.hxx>
#include <sfx2/objface.hxx>
+#include <sfx2/checkin.hxx>
#include "../appl/app.hrc"
#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
@@ -339,6 +343,65 @@ sal_Bool SfxObjectShell::APISaveAs_Impl
return bOk;
}
+void SfxObjectShell::CheckOut( )
+{
+ try
+ {
+ uno::Reference< document::XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY_THROW );
+ xCmisDoc->checkOut( );
+
+ // Remove the info bar
+ SfxViewFrame* pViewFrame = GetFrame();
+ pViewFrame->RemoveInfoBar( "checkout" );
+ }
+ catch ( const uno::RuntimeException& e )
+ {
+ ErrorBox* pErrorBox = new ErrorBox( &GetFrame()->GetWindow(), WB_OK, e.Message );
+ pErrorBox->Execute( );
+ delete pErrorBox;
+ }
+}
+
+void SfxObjectShell::CancelCheckOut( )
+{
+ try
+ {
+ uno::Reference< document::XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY_THROW );
+ 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 );
+ // Pop up dialog to ask for comment and major
+ SfxCheckinDialog checkinDlg( &GetFrame( )->GetWindow( ) );
+ if ( checkinDlg.Execute( ) == RET_OK )
+ {
+ rtl::OUString sComment = checkinDlg.GetComment( );
+ sal_Bool bMajor = checkinDlg.IsMajor( );
+ xCmisDoc->checkIn( bMajor, 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)
@@ -884,6 +947,25 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
break;
}
+
+ case SID_CHECKOUT:
+ {
+ CheckOut( );
+ break;
+ }
+ case SID_CANCELCHECKOUT:
+ {
+ if ( QueryBox( NULL, SfxResId( RID_QUERY_CANCELCHECKOUT ) ).Execute( ) == RET_YES )
+ {
+ CancelCheckOut( );
+ }
+ break;
+ }
+ case SID_CHECKIN:
+ {
+ CheckIn( );
+ break;
+ }
}
// Prevent entry in the Pick-lists
@@ -918,6 +1000,67 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
break;
}
+ case SID_CHECKOUT:
+ {
+ 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_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;