diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-10-09 17:52:40 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-10-11 17:31:17 +0200 |
commit | 9d9eb583f56ed494a8574a2e7677fe66aabfd6c7 (patch) | |
tree | 48a7799551832dd783861988a89ab6b00ed00c46 /sfx2/source | |
parent | f5a84d8c1a44d82f2ca96a3d219a4cb05ab71a39 (diff) |
CMIS: Show an infobar when the document isn't checked out
Telling the user that the document isn't checked out is pretty important
as it may cause troubles for the Save operation later (depending on the
server policy)
Change-Id: Ia101d37cc6266170914ae2cbd90accea1f377f60
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 41 | ||||
-rw-r--r-- | sfx2/source/view/view.src | 12 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 5 |
4 files changed, 57 insertions, 4 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index ec6b25236f86..fa4116b565c0 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -754,9 +754,6 @@ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed ) beans::PropertyValues aCmisValues; aContent.getPropertyValue( aCmisPropsValues ) >>= aCmisValues; xCmisDoc->setCmisPropertiesValues( aCmisValues ); - - // TODO For CMIS case, try to look for cmis:isVersionSeriesCheckedOut - // If set to false, then show InfoBar to propose checkOut } if ( xProps->hasPropertyByName( aCmisPropsNames ) ) { diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 33cc346acab4..89ead633f11b 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/util/XCloseBroadcaster.hpp> #include <com/sun/star/util/XCloseListener.hpp> #include <com/sun/star/util/CloseVetoException.hpp> +#include <com/sun/star/document/XCmisDocument.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase2.hxx> @@ -58,6 +59,8 @@ #include <sfx2/unoctitm.hxx> #include <sfx2/childwin.hxx> #include <sfx2/sfxsids.hrc> +#include <sfx2/sfx.hrc> +#include <sfx2/sfxresid.hxx> #include <workwin.hxx> #include <sfx2/objface.hxx> @@ -581,6 +584,7 @@ void SAL_CALL SfxBaseController::attachFrame( const REFERENCE< XFRAME >& xFrame if ( m_pData->m_pViewShell ) { ConnectSfxFrame_Impl( E_CONNECT ); + ShowInfoBars( ); // attaching the frame to the controller is the last step in the creation of a new view, so notify this SfxViewEventHint aHint( SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ), m_pData->m_pViewShell->GetObjectShell(), uno::Reference< frame::XController2 >( this ) ); @@ -1428,6 +1432,43 @@ void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect ) pViewFrame->GetBindings().Invalidate( nViewNo + SID_VIEWSHELL0 ); } +void SfxBaseController::ShowInfoBars( ) +{ + if ( m_pData->m_pViewShell ) + { + // CMIS verifications + REFERENCE< document::XCmisDocument > xCmisDoc( m_pData->m_pViewShell->GetObjectShell()->GetModel(), uno::UNO_QUERY ); + beans::PropertyValues aCmisProperties = xCmisDoc->getCmisPropertiesValues( ); + + if ( 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; + } + } + + if ( !bCheckedOut ) + { + // Get the Frame and show the InfoBar if not checked out + SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame(); + std::vector< PushButton* > aButtons; + PushButton* pBtn = new PushButton( &pViewFrame->GetWindow(), SfxResId( BT_CHECKOUT ) ); + // TODO Set the handler + aButtons.push_back( pBtn ); + pViewFrame->AppendInfoBar( SfxResId( STR_NONCHECKEDOUT_DOCUMENT ), aButtons ); + } + } + } +} + + //============================================================================= css::uno::Reference< css::frame::XTitle > SfxBaseController::impl_getTitleHelper () { diff --git a/sfx2/source/view/view.src b/sfx2/source/view/view.src index a4fa3110ac72..cc2ebbb13143 100644 --- a/sfx2/source/view/view.src +++ b/sfx2/source/view/view.src @@ -161,3 +161,15 @@ String STR_REPAIREDDOCUMENT { Text [ en-US ] = " (repaired document)" ; }; + +String STR_NONCHECKEDOUT_DOCUMENT +{ + Text [ en-US ] = "Document is not checked out on server" ; +}; + +PushButton BT_CHECKOUT +{ + Pos = MAP_APPFONT( 0 , 0 ); + Size = MAP_APPFONT( 30 , 0 ); + Text[ en-US ] = "Check out"; +}; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index ad8dfc729128..9d459c6daedf 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -3353,7 +3353,10 @@ void SfxViewFrame::ActivateToolPanel_Impl( const ::rtl::OUString& i_rPanelURL ) void SfxViewFrame::AppendInfoBar( const rtl::OUString& sMessage, std::vector< PushButton* > aButtons ) { const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId(); - ShowChildWindow( nId ); + + // Make sure the InfoBar container is visible + if ( !HasChildWindow( nId ) ) + ToggleChildWindow( nId ); SfxChildWindow* pChild = GetChildWindow( nId ); SfxInfoBarContainerWindow* pInfoBars = ( SfxInfoBarContainerWindow* )pChild->GetWindow(); pInfoBars->appendInfoBar( sMessage, aButtons ); |