summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-10-11 14:14:48 +0200
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-10-11 17:31:18 +0200
commitc767f82403635221af58998a3265e38e8d19e76d (patch)
treeafaa73f1815ec9b55dfec569e12d4b62f897e0c8 /sfx2/source
parent0c0e5c82c7d9fb790d0894c28af5cff99d71a910 (diff)
CMIS: Implemented the CheckOut button of the InfoBar
Implementing it needed: + Adding XCmisDocument::checkOut method and implement it in SfxBaseModel + Moving the CMIS properties loading into a SfxBaseModel private method to factorize code. + Adding the SfxInfoBarContainerChild registration in all modules Change-Id: I35bcb53cd2feff354aa5d9245897d0631cc924a0
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/doc/objstor.cxx18
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx71
-rw-r--r--sfx2/source/view/sfxbasecontroller.cxx25
-rw-r--r--sfx2/source/view/viewfrm.cxx25
4 files changed, 117 insertions, 22 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index fa4116b565c0..b9b5f0480551 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -29,7 +29,6 @@
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/document/XCmisDocument.hpp>
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExporter.hpp>
@@ -745,23 +744,6 @@ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed )
com::sun::star::uno::Reference < XPropertySetInfo > xProps = aContent.getProperties();
if ( xProps.is() )
{
- // Copy all the CMIS properties to the document (if there is any)
- ::rtl::OUString aCmisPropsValues( "CmisPropertiesValues" );
- ::rtl::OUString aCmisPropsNames( "CmisPropertiesDisplayNames" );
- uno::Reference< document::XCmisDocument > xCmisDoc( GetModel( ), uno::UNO_QUERY_THROW );
- if ( xProps->hasPropertyByName( aCmisPropsValues ) )
- {
- beans::PropertyValues aCmisValues;
- aContent.getPropertyValue( aCmisPropsValues ) >>= aCmisValues;
- xCmisDoc->setCmisPropertiesValues( aCmisValues );
- }
- if ( xProps->hasPropertyByName( aCmisPropsNames ) )
- {
- beans::PropertyValues aPropNames;
- aContent.getPropertyValue( aCmisPropsNames ) >>= aPropNames;
- xCmisDoc->setCmisPropertiesDisplayNames( aPropNames );
- }
-
::rtl::OUString aAuthor( "Author" );
::rtl::OUString aKeywords( "Keywords" );
::rtl::OUString aSubject( "Subject" );
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index ea8fdfabf8f7..872bdbca3b59 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -2001,6 +2001,8 @@ void SAL_CALL SfxBaseModel::load( const uno::Sequence< beans::PropertyValue >&
}
}
+ loadCmisProperties( );
+
sal_Bool bHidden = sal_False;
SFX_ITEMSET_ARG( pMedium->GetItemSet(), pHidItem, SfxBoolItem, SID_HIDDEN, sal_False);
if ( pHidItem )
@@ -2542,6 +2544,74 @@ void SAL_CALL SfxBaseModel::setCmisPropertiesDisplayNames( const uno::Sequence<
m_pData->m_cmisPropertiesDisplayNames = _cmispropertiesdisplaynames;
}
+void SAL_CALL SfxBaseModel::checkOut( ) throw ( uno::RuntimeException )
+{
+ 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( "checkout", 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 ucb::ContentCreationException &)
+ {
+ }
+ catch (const ucb::CommandAbortedException &)
+ {
+ }
+ }
+}
+
+void SfxBaseModel::loadCmisProperties( )
+{
+ SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
+ if ( pMedium )
+ {
+ try
+ {
+ ::ucbhelper::Content aContent( pMedium->GetName( ),
+ uno::Reference<ucb::XCommandEnvironment>(),
+ comphelper::getProcessComponentContext() );
+ com::sun::star::uno::Reference < beans::XPropertySetInfo > xProps = aContent.getProperties();
+ ::rtl::OUString aCmisPropsValues( "CmisPropertiesValues" );
+ ::rtl::OUString aCmisPropsNames( "CmisPropertiesDisplayNames" );
+ if ( xProps->hasPropertyByName( aCmisPropsValues ) )
+ {
+ beans::PropertyValues aCmisValues;
+ aContent.getPropertyValue( aCmisPropsValues ) >>= aCmisValues;
+ setCmisPropertiesValues( aCmisValues );
+ }
+ if ( xProps->hasPropertyByName( aCmisPropsNames ) )
+ {
+ beans::PropertyValues aPropNames;
+ aContent.getPropertyValue( aCmisPropsNames ) >>= aPropNames;
+ setCmisPropertiesDisplayNames( aPropNames );
+ }
+ }
+ catch (const ucb::ContentCreationException &)
+ {
+ }
+ catch (const ucb::CommandAbortedException &)
+ {
+ }
+ }
+}
+
//________________________________________________________________________________________________________
// SfxListener
//________________________________________________________________________________________________________
@@ -3587,6 +3657,7 @@ void SAL_CALL SfxBaseModel::loadFromStorage( const uno::Reference< XSTORAGE >& x
uno::Reference< uno::XInterface >(),
nError ? nError : ERRCODE_IO_CANTREAD );
}
+ loadCmisProperties( );
}
void SAL_CALL SfxBaseModel::storeToStorage( const uno::Reference< XSTORAGE >& xStorage,
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index 89ead633f11b..7b315a6b62ed 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -63,6 +63,7 @@
#include <sfx2/sfxresid.hxx>
#include <workwin.hxx>
#include <sfx2/objface.hxx>
+#include <sfx2/infobar.hxx>
#include <osl/mutex.hxx>
#include <tools/diagnose_ex.h>
@@ -1460,7 +1461,7 @@ void SfxBaseController::ShowInfoBars( )
SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame();
std::vector< PushButton* > aButtons;
PushButton* pBtn = new PushButton( &pViewFrame->GetWindow(), SfxResId( BT_CHECKOUT ) );
- // TODO Set the handler
+ pBtn->SetClickHdl( LINK( this, SfxBaseController, CheckOutHandler ) );
aButtons.push_back( pBtn );
pViewFrame->AppendInfoBar( SfxResId( STR_NONCHECKEDOUT_DOCUMENT ), aButtons );
}
@@ -1468,6 +1469,28 @@ 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& )
+ {
+ // TODO Handle the problem in some way?
+ }
+ }
+ return 0;
+}
+
//=============================================================================
css::uno::Reference< css::frame::XTitle > SfxBaseController::impl_getTitleHelper ()
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 9d459c6daedf..d9ed89314e47 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -3358,9 +3358,28 @@ void SfxViewFrame::AppendInfoBar( const rtl::OUString& sMessage, std::vector< Pu
if ( !HasChildWindow( nId ) )
ToggleChildWindow( nId );
SfxChildWindow* pChild = GetChildWindow( nId );
- SfxInfoBarContainerWindow* pInfoBars = ( SfxInfoBarContainerWindow* )pChild->GetWindow();
- pInfoBars->appendInfoBar( sMessage, aButtons );
- ShowChildWindow( nId );
+ if ( pChild )
+ {
+ SfxInfoBarContainerWindow* pInfoBars = ( SfxInfoBarContainerWindow* )pChild->GetWindow();
+ pInfoBars->appendInfoBar( sMessage, aButtons );
+ ShowChildWindow( nId );
+ }
+}
+
+void SfxViewFrame::RemoveInfoBar( SfxInfoBarWindow* pInfoBar )
+{
+ const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
+
+ // Make sure the InfoBar container is visible
+ if ( !HasChildWindow( nId ) )
+ ToggleChildWindow( nId );
+ SfxChildWindow* pChild = GetChildWindow( nId );
+ if ( pChild )
+ {
+ SfxInfoBarContainerWindow* pInfoBars = ( SfxInfoBarContainerWindow* )pChild->GetWindow();
+ pInfoBars->removeInfoBar( pInfoBar );
+ ShowChildWindow( nId );
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */