diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-10-20 09:42:35 -0700 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-10-31 12:03:29 +0100 |
commit | 23722506efd84a9b7b447578de32c0eef9bf8b98 (patch) | |
tree | bb2fcf1bc1d6e6b190163acaa6e72a084b2dd7af /sfx2 | |
parent | 793ea6fe90209dbf2b659a44a302306a05888011 (diff) |
CMIS: added CheckOut in the File menu
Change-Id: I5f003556065cff34cec38148bc3bb4da20692e54
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/infobar.hxx | 7 | ||||
-rw-r--r-- | sfx2/inc/sfx2/objsh.hxx | 2 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxcommands.h | 1 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxsids.hrc | 1 | ||||
-rw-r--r-- | sfx2/inc/sfx2/viewfrm.hxx | 5 | ||||
-rw-r--r-- | sfx2/sdi/docslots.sdi | 5 | ||||
-rw-r--r-- | sfx2/sdi/sfx.sdi | 24 | ||||
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 23 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 58 | ||||
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 21 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 7 |
11 files changed, 122 insertions, 32 deletions
diff --git a/sfx2/inc/sfx2/infobar.hxx b/sfx2/inc/sfx2/infobar.hxx index 876764a8a896..b72dbbdb85f5 100644 --- a/sfx2/inc/sfx2/infobar.hxx +++ b/sfx2/inc/sfx2/infobar.hxx @@ -41,16 +41,18 @@ class SFX2_DLLPUBLIC SfxInfoBarContainerChild : public SfxChildWindow class SfxInfoBarWindow : public Window { private: + rtl::OUString m_sId; FixedText* m_pMessage; Button* m_pCloseBtn; std::vector< PushButton* > m_aActionBtns; public: - SfxInfoBarWindow( Window* parent, + SfxInfoBarWindow( Window* parent, const rtl::OUString& sId, const rtl::OUString& sMessage, std::vector< PushButton* > aButtons ); ~SfxInfoBarWindow( ); + virtual const rtl::OUString& getId() const { return m_sId; } virtual void Paint( const Rectangle& ); virtual void Resize( ); @@ -68,7 +70,8 @@ class SfxInfoBarContainerWindow : public Window SfxInfoBarContainerWindow( SfxInfoBarContainerChild* pChildWin ); ~SfxInfoBarContainerWindow( ); - void appendInfoBar( const rtl::OUString& sMessage, std::vector< PushButton* > aButtons ); + void appendInfoBar( const rtl::OUString& sId, const rtl::OUString& sMessage, std::vector< PushButton* > aButtons ); + SfxInfoBarWindow* getInfoBar( const rtl::OUString& sId ); void removeInfoBar( SfxInfoBarWindow* pInfoBar ); virtual void Resize( ); diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 331553db46a4..88a2abe87a4b 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -732,6 +732,8 @@ public: SAL_DLLPRIVATE void ImplSign( sal_Bool bScriptingContent = sal_False ); SAL_DLLPRIVATE sal_Bool QuerySaveSizeExceededModules_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); + + SAL_DLLPRIVATE void CheckOut( ); }; #define SFX_GLOBAL_CLASSID \ diff --git a/sfx2/inc/sfx2/sfxcommands.h b/sfx2/inc/sfx2/sfxcommands.h index fc075b299c64..46c7ebcac274 100644 --- a/sfx2/inc/sfx2/sfxcommands.h +++ b/sfx2/inc/sfx2/sfxcommands.h @@ -44,6 +44,7 @@ #define CMD_SID_OPENHYPERLINK ".uno:OpenHyperlink" #define CMD_SID_DOCINFO_TITLE ".uno:DocInfoTitle" #define CMD_SID_OPENTEMPLATE ".uno:OpenTemplate" +#define CMD_SID_CHECKOUT ".uno:CheckOut" #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 0d3522bd7b14..9586dde26c50 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -143,6 +143,7 @@ #define SID_EXPORTDOCASPDF (SID_SFX_START + 1673) #define SID_DIRECTEXPORTDOCASPDF (SID_SFX_START + 1674) #define SID_UPDATEDOCMODE (SID_SFX_START + 1668) +#define SID_CHECKOUT (SID_SFX_START + 512) #define SID_FORCERELOAD (SID_SFX_START + 1502) #define SID_FILE_DIALOG (SID_SFX_START + 304) diff --git a/sfx2/inc/sfx2/viewfrm.hxx b/sfx2/inc/sfx2/viewfrm.hxx index c3d889364522..4373a52ae6c1 100644 --- a/sfx2/inc/sfx2/viewfrm.hxx +++ b/sfx2/inc/sfx2/viewfrm.hxx @@ -23,7 +23,6 @@ #include "sfx2/dllapi.h" #include "sal/types.h" #include <svl/lstner.hxx> -#include <sfx2/infobar.hxx> #include <sfx2/module.hxx> #include <sfx2/frame.hxx> #include <sfx2/shell.hxx> @@ -191,8 +190,8 @@ public: The buttons will be added from Right to Left at the right of the info bar. The parent, size and position of each button will be changed: only the width will remain unchanged. */ - void AppendInfoBar( const rtl::OUString& sMessage, std::vector< PushButton* > aButtons ); - void RemoveInfoBar( SfxInfoBarWindow* pInfoBar ); + void AppendInfoBar( const rtl::OUString& sId, const rtl::OUString& sMessage, std::vector< PushButton* > aButtons ); + void RemoveInfoBar( const rtl::OUString& sId ); SAL_DLLPRIVATE void SetDowning_Impl(); SAL_DLLPRIVATE void GetDocNumber_Impl(); diff --git a/sfx2/sdi/docslots.sdi b/sfx2/sdi/docslots.sdi index 291eb58dddad..6ba11a83f8e0 100644 --- a/sfx2/sdi/docslots.sdi +++ b/sfx2/sdi/docslots.sdi @@ -177,6 +177,11 @@ interface OfficeDocument : Document ExecMethod = ExecFile_Impl; StateMethod = GetState_Impl; ] + SID_CHECKOUT + [ + ExecMethod = ExecFile_Impl; + StateMethod = GetState_Impl; + ] } //========================================================================= diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 92af180aedf3..635342a40bcc 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -4444,6 +4444,30 @@ SfxObjectItem OpenTemplate SID_OPENTEMPLATE GroupId = GID_TEMPLATE; ] +SfxVoidItem CheckOut SID_CHECKOUT +() +[ + /* 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/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index 1f979e871514..f92e836abe1d 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -94,9 +94,10 @@ namespace } } -SfxInfoBarWindow::SfxInfoBarWindow( Window* pParent, const rtl::OUString& sMessage, - vector< PushButton* > aButtons ) : +SfxInfoBarWindow::SfxInfoBarWindow( Window* pParent, const rtl::OUString& sId, + const rtl::OUString& sMessage, vector< PushButton* > aButtons ) : Window( pParent, 0 ), + m_sId( sId ), m_pMessage( NULL ), m_pCloseBtn( NULL ), m_aActionBtns( aButtons ) @@ -243,13 +244,12 @@ SfxInfoBarContainerWindow::~SfxInfoBarContainerWindow( ) m_pInfoBars.clear( ); } -void SfxInfoBarContainerWindow::appendInfoBar( const rtl::OUString& sMessage, vector< PushButton* > aButtons ) +void SfxInfoBarContainerWindow::appendInfoBar( const rtl::OUString& sId, const rtl::OUString& sMessage, vector< PushButton* > aButtons ) { Size aSize = GetSizePixel( ); - SfxInfoBarWindow* pInfoBar = new SfxInfoBarWindow( this, sMessage, aButtons ); + SfxInfoBarWindow* pInfoBar = new SfxInfoBarWindow( this, sId, sMessage, aButtons ); pInfoBar->SetPosPixel( Point( 0, aSize.getHeight( ) ) ); - m_pInfoBars.push_back( pInfoBar ); pInfoBar->Show( ); long nHeight = pInfoBar->GetSizePixel( ).getHeight( ); @@ -257,6 +257,19 @@ void SfxInfoBarContainerWindow::appendInfoBar( const rtl::OUString& sMessage, ve SetSizePixel( aSize ); } +SfxInfoBarWindow* SfxInfoBarContainerWindow::getInfoBar( const rtl::OUString& sId ) +{ + SfxInfoBarWindow* pRet = NULL; + for ( vector< SfxInfoBarWindow* >::iterator it = m_pInfoBars.begin( ); + it != m_pInfoBars.end( ) && pRet == NULL; ++it ) + { + SfxInfoBarWindow* pBar = *it; + if ( pBar->getId( ) == sId ) + pRet = pBar; + } + return pRet; +} + void SfxInfoBarContainerWindow::removeInfoBar( SfxInfoBarWindow* pInfoBar ) { for ( vector< SfxInfoBarWindow* >::iterator it = m_pInfoBars.begin( ); 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; diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 26e5ee54481b..54827c5d7436 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -1464,7 +1464,7 @@ void SfxBaseController::ShowInfoBars( ) PushButton* pBtn = new PushButton( &pViewFrame->GetWindow(), SfxResId( BT_CHECKOUT ) ); pBtn->SetClickHdl( LINK( this, SfxBaseController, CheckOutHandler ) ); aButtons.push_back( pBtn ); - pViewFrame->AppendInfoBar( SfxResId( STR_NONCHECKEDOUT_DOCUMENT ), aButtons ); + pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ), aButtons ); } } } @@ -1473,24 +1473,7 @@ void SfxBaseController::ShowInfoBars( ) IMPL_LINK( SfxBaseController, CheckOutHandler, PushButton*, pBtn ) { if ( m_pData->m_pViewShell ) - { - try - { - REFERENCE< document::XCmisDocument > xCmisDoc( m_pData->m_pViewShell->GetObjectShell()->GetModel(), uno::UNO_QUERY_THROW ); - xCmisDoc->checkOut( ); - - // Remove the info bar - SfxInfoBarWindow* pInfoBar = ( SfxInfoBarWindow* )pBtn->GetParent( ); - SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame(); - pViewFrame->RemoveInfoBar( pInfoBar ); - } - catch ( const uno::RuntimeException& e ) - { - ErrorBox* pErrorBox = new ErrorBox( &m_pData->m_pViewShell->GetFrame()->GetWindow(), WB_OK, e.Message ); - pErrorBox->Execute( ); - delete pErrorBox; - } - } + m_pData->m_pViewShell->GetObjectShell()->CheckOut( ); return 0; } diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index f039d3e2c39c..60bd2a758673 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -3348,7 +3348,7 @@ void SfxViewFrame::ActivateToolPanel_Impl( const ::rtl::OUString& i_rPanelURL ) pPanelAccess->ActivateToolPanel( i_rPanelURL ); } -void SfxViewFrame::AppendInfoBar( const rtl::OUString& sMessage, std::vector< PushButton* > aButtons ) +void SfxViewFrame::AppendInfoBar( const rtl::OUString& sId, const rtl::OUString& sMessage, std::vector< PushButton* > aButtons ) { const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId(); @@ -3359,12 +3359,12 @@ void SfxViewFrame::AppendInfoBar( const rtl::OUString& sMessage, std::vector< Pu if ( pChild ) { SfxInfoBarContainerWindow* pInfoBars = ( SfxInfoBarContainerWindow* )pChild->GetWindow(); - pInfoBars->appendInfoBar( sMessage, aButtons ); + pInfoBars->appendInfoBar( sId, sMessage, aButtons ); ShowChildWindow( nId ); } } -void SfxViewFrame::RemoveInfoBar( SfxInfoBarWindow* pInfoBar ) +void SfxViewFrame::RemoveInfoBar( const rtl::OUString& sId ) { const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId(); @@ -3375,6 +3375,7 @@ void SfxViewFrame::RemoveInfoBar( SfxInfoBarWindow* pInfoBar ) if ( pChild ) { SfxInfoBarContainerWindow* pInfoBars = ( SfxInfoBarContainerWindow* )pChild->GetWindow(); + SfxInfoBarWindow* pInfoBar = pInfoBars->getInfoBar( sId ); pInfoBars->removeInfoBar( pInfoBar ); ShowChildWindow( nId ); } |