summaryrefslogtreecommitdiff
path: root/sfx2/source/doc/objserv.cxx
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-10-20 09:42:35 -0700
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-10-31 12:03:29 +0100
commit23722506efd84a9b7b447578de32c0eef9bf8b98 (patch)
treebb2fcf1bc1d6e6b190163acaa6e72a084b2dd7af /sfx2/source/doc/objserv.cxx
parent793ea6fe90209dbf2b659a44a302306a05888011 (diff)
CMIS: added CheckOut in the File menu
Change-Id: I5f003556065cff34cec38148bc3bb4da20692e54
Diffstat (limited to 'sfx2/source/doc/objserv.cxx')
-rw-r--r--sfx2/source/doc/objserv.cxx58
1 files changed, 58 insertions, 0 deletions
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 70a4f1dd6c48..13571881069c 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>
@@ -339,6 +342,25 @@ 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::ExecFile_Impl(SfxRequest &rReq)
@@ -884,6 +906,12 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
break;
}
+
+ case SID_CHECKOUT:
+ {
+ CheckOut( );
+ break;
+ }
}
// Prevent entry in the Pick-lists
@@ -918,6 +946,36 @@ 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_VERSION:
{
SfxObjectShell *pDoc = this;