diff options
author | Cao Cuong Ngo <cao.cuong.ngo@gmail.com> | 2013-09-12 15:27:37 +0200 |
---|---|---|
committer | Bosdonnat Cedric <cedric.bosdonnat@free.fr> | 2013-09-23 12:56:09 +0000 |
commit | b61970cfbe12722efd6218db6489980381b8783d (patch) | |
tree | fec47f16c02a2b3732561466c783a7e96b7c4a4e /sfx2 | |
parent | 0618b35ebda29b911058254cd34620e8b24ab8f7 (diff) |
Cmis Versions dialog
Change-Id: Ie863282062a6932a55543143e841917c54223ac9
Reviewed-on: https://gerrit.libreoffice.org/5925
Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/UIConfig_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/source/dialog/versdlg.cxx | 111 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 15 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 23 | ||||
-rw-r--r-- | sfx2/source/inc/versdlg.hxx | 24 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/versionscmis.ui | 340 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/versionsofdialog.ui | 16 |
7 files changed, 528 insertions, 2 deletions
diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk index ff754473b7be..a2629d20ca31 100644 --- a/sfx2/UIConfig_sfx.mk +++ b/sfx2/UIConfig_sfx.mk @@ -27,6 +27,7 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\ sfx2/uiconfig/ui/singletabdialog \ sfx2/uiconfig/ui/versionsofdialog \ sfx2/uiconfig/ui/versioncommentdialog \ + sfx2/uiconfig/ui/versionscmis \ sfx2/uiconfig/ui/startcenter \ sfx2/uiconfig/ui/cmisinfopage \ sfx2/uiconfig/ui/cmisline \ diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx index abc4644a4b88..c36540cada09 100644 --- a/sfx2/source/dialog/versdlg.cxx +++ b/sfx2/source/dialog/versdlg.cxx @@ -81,7 +81,7 @@ public: { *this = rCpy; } SfxVersionTableDtor( const uno::Sequence < util::RevisionTag >& rInfo ); - + SfxVersionTableDtor( const uno::Sequence < document::CmisVersion > & rInfo ); ~SfxVersionTableDtor() { DelDtor(); } @@ -114,6 +114,23 @@ SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < util::RevisionTa } } +SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < document::CmisVersion >& rInfo ) +{ + for ( sal_Int32 n=0; n<(sal_Int32)rInfo.getLength(); n++ ) + { + SfxVersionInfo* pInfo = new SfxVersionInfo; + pInfo->aName = rInfo[n].Id; + pInfo->aComment = rInfo[n].Comment; + pInfo->aAuthor = rInfo[n].Author; + + Date aDate ( rInfo[n].TimeStamp.Day, rInfo[n].TimeStamp.Month, rInfo[n].TimeStamp.Year ); + Time aTime ( rInfo[n].TimeStamp.Hours, rInfo[n].TimeStamp.Minutes, rInfo[n].TimeStamp.Seconds, rInfo[n].TimeStamp.NanoSeconds ); + + pInfo->aCreationDate = DateTime( aDate, aTime ); + aTableList.push_back( pInfo ); + } +} + void SfxVersionTableDtor::DelDtor() { for ( size_t i = 0, n = aTableList.size(); i < n; ++i ) @@ -218,6 +235,7 @@ SfxVersionDialog::SfxVersionDialog ( SfxViewFrame* pVwFrame, sal_Bool bIsSaveVer get(m_pViewButton, "show"); get(m_pDeleteButton, "delete"); get(m_pCompareButton, "compare"); + get(m_pCmisButton, "cmis"); SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("versions"); Size aControlSize(260, 114); @@ -234,6 +252,7 @@ SfxVersionDialog::SfxVersionDialog ( SfxViewFrame* pVwFrame, sal_Bool bIsSaveVer m_pCompareButton->SetClickHdl ( aClickLink ); m_pOpenButton->SetClickHdl ( aClickLink ); m_pSaveCheckBox->SetClickHdl ( aClickLink ); + m_pCmisButton->SetClickHdl ( aClickLink ); m_pVersionBox->SetSelectHdl( LINK( this, SfxVersionDialog, SelectHdl_Impl ) ); m_pVersionBox->SetDoubleClickHdl( LINK( this, SfxVersionDialog, DClickHdl_Impl ) ); @@ -329,6 +348,7 @@ void SfxVersionDialog::Init_Impl() m_pViewButton->Disable(); m_pDeleteButton->Disable(); m_pCompareButton->Disable(); + m_pCmisButton->Enable(); SelectHdl_Impl(m_pVersionBox); } @@ -456,6 +476,12 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton ) pViewFrame->GetDispatcher()->Execute( SID_DOCUMENT_COMPARE, SFX_CALLMODE_ASYNCHRON, aSet ); Close(); } + else if (pButton == m_pCmisButton) + { + SfxCmisVersionsDialog* pDlg = new SfxCmisVersionsDialog(pViewFrame, false); + pDlg->Execute(); + delete pDlg; + } return 0L; } @@ -504,4 +530,87 @@ IMPL_LINK(SfxViewVersionDialog_Impl, ButtonHdl, Button*, pButton) return 0L; } +SfxCmisVersionsDialog::SfxCmisVersionsDialog ( SfxViewFrame* pVwFrame, sal_Bool bIsSaveVersionOnClose ) + : SfxModalDialog(NULL, "VersionsCmisDialog", "sfx/ui/versionscmis.ui") + , pViewFrame(pVwFrame) + , m_pTable(NULL) + , m_bIsSaveVersionOnClose(bIsSaveVersionOnClose) +{ + get(m_pSaveButton, "save"); + get(m_pSaveCheckBox, "always"); + get(m_pOpenButton, "open"); + get(m_pViewButton, "show"); + get(m_pDeleteButton, "delete"); + get(m_pCompareButton, "compare"); + + SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("versions"); + Size aControlSize(260, 114); + aControlSize = pContainer->LogicToPixel(aControlSize, MAP_APPFONT); + pContainer->set_width_request(aControlSize.Width()); + pContainer->set_height_request(aControlSize.Height()); + + m_pVersionBox = new SfxVersionsTabListBox_Impl(*pContainer, WB_TABSTOP); + + m_pVersionBox->GrabFocus(); + m_pVersionBox->SetStyle( m_pVersionBox->GetStyle() | WB_HSCROLL | WB_CLIPCHILDREN ); + m_pVersionBox->SetSelectionMode( SINGLE_SELECTION ); + + long nTabs_Impl[] = { 3, 0, 0, 0 }; + + m_pVersionBox->SvSimpleTable::SetTabs(&nTabs_Impl[0]); + OUString sHeader1(get<FixedText>("datetime")->GetText()); + OUString sHeader2(get<FixedText>("savedby")->GetText()); + OUString sHeader3(get<FixedText>("comments")->GetText()); + OUStringBuffer sHeader; + sHeader.append(sHeader1).append("\t").append(sHeader2) + .append("\t ").append(sHeader3); + m_pVersionBox->InsertHeaderEntry(sHeader.makeStringAndClear()); + + HeaderBar &rBar = m_pVersionBox->GetTheHeaderBar(); + HeaderBarItemBits nBits = rBar.GetItemBits(1) | HIB_FIXEDPOS | HIB_FIXED; + nBits &= ~HIB_CLICKABLE; + rBar.SetItemBits(1, nBits); + rBar.SetItemBits(2, nBits); + rBar.SetItemBits(3, nBits); + + m_pVersionBox->Resize(); + + OUString sText = GetText(); + sText = sText + " " + pViewFrame->GetObjectShell()->GetTitle(); + SetText( sText ); + + LoadVersions(); + + m_pVersionBox->setColSizes(); + +} + +SfxCmisVersionsDialog::~SfxCmisVersionsDialog() +{ + delete m_pTable; + delete m_pVersionBox; +} + +void SfxCmisVersionsDialog::LoadVersions() +{ + SfxObjectShell *pObjShell = pViewFrame->GetObjectShell(); + uno::Sequence < document::CmisVersion > aVersions = pObjShell->GetCmisVersions( ); + delete m_pTable; + m_pTable = new SfxVersionTableDtor( aVersions ); + { + for ( size_t n = 0; n < m_pTable->size(); ++n ) + { + SfxVersionInfo *pInfo = m_pTable->at( n ); + OUString aEntry = formatTime(pInfo->aCreationDate, Application::GetSettings().GetLocaleDataWrapper()); + aEntry += "\t"; + aEntry += pInfo->aAuthor; + aEntry += "\t"; + aEntry += ConvertWhiteSpaces_Impl( pInfo->aComment ); + SvTreeListEntry *pEntry = m_pVersionBox->InsertEntry( aEntry ); + pEntry->SetUserData( pInfo ); + } + } + +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index a06d519edf29..fc4076961672 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -405,6 +405,21 @@ void SfxObjectShell::CheckIn( ) } } +uno::Sequence< document::CmisVersion > SfxObjectShell::GetCmisVersions( ) +{ + try + { + uno::Reference< document::XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY_THROW ); + return xCmisDoc->getAllVersions( ); + } + catch ( const uno::RuntimeException& e ) + { + ErrorBox* pErrorBox = new ErrorBox( &GetFrame()->GetWindow(), WB_OK, e.Message ); + pErrorBox->Execute( ); + delete pErrorBox; + } + return uno::Sequence< document::CmisVersion > ( ); +} //-------------------------------------------------------------------- void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 4224e3ee3ce5..5eae505cec4b 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2604,6 +2604,29 @@ void SAL_CALL SfxBaseModel::checkIn( sal_Bool bIsMajor, const OUString& rMessage } } +uno::Sequence< document::CmisVersion > SAL_CALL SfxBaseModel::getAllVersions( ) throw ( RuntimeException ) +{ + uno::Sequence< document::CmisVersion > aVersions; + SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); + if ( pMedium ) + { + try + { + ::ucbhelper::Content aContent( pMedium->GetName(), + Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext() ); + + Any aResult = aContent.executeCommand( "getAllVersions", Any( ) ); + aResult >>= aVersions; + } + catch ( const Exception & e ) + { + throw RuntimeException( e.Message, e.Context ); + } + } + return aVersions; +} + sal_Bool SfxBaseModel::getBoolPropertyValue( const OUString& rName ) throw ( RuntimeException ) { sal_Bool bValue = sal_False; diff --git a/sfx2/source/inc/versdlg.hxx b/sfx2/source/inc/versdlg.hxx index bdb30c2c0170..ad96ef073f18 100644 --- a/sfx2/source/inc/versdlg.hxx +++ b/sfx2/source/inc/versdlg.hxx @@ -52,6 +52,7 @@ class SfxVersionDialog : public SfxModalDialog PushButton* m_pViewButton; PushButton* m_pDeleteButton; PushButton* m_pCompareButton; + PushButton* m_pCmisButton; SfxViewFrame* pViewFrame; SfxVersionTableDtor* m_pTable; bool m_bIsSaveVersionOnClose; @@ -84,6 +85,29 @@ public: SfxViewVersionDialog_Impl(Window *pParent, SfxVersionInfo& rInfo, bool bEdit); }; +class SfxCmisVersionsDialog : public SfxModalDialog +{ + PushButton* m_pSaveButton; + CheckBox* m_pSaveCheckBox; + SfxVersionsTabListBox_Impl* m_pVersionBox; + PushButton* m_pOpenButton; + PushButton* m_pViewButton; + PushButton* m_pDeleteButton; + PushButton* m_pCompareButton; + SfxViewFrame* pViewFrame; + SfxVersionTableDtor* m_pTable; + bool m_bIsSaveVersionOnClose; + + DECL_LINK(DClickHdl_Impl, void *); + DECL_LINK(SelectHdl_Impl, void *); + DECL_LINK( ButtonHdl_Impl, Button* ); + void LoadVersions(); + +public: + SfxCmisVersionsDialog ( SfxViewFrame* pFrame, sal_Bool ); + virtual ~SfxCmisVersionsDialog (); +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/uiconfig/ui/versionscmis.ui b/sfx2/uiconfig/ui/versionscmis.ui new file mode 100644 index 000000000000..f5b75ac143c3 --- /dev/null +++ b/sfx2/uiconfig/ui/versionscmis.ui @@ -0,0 +1,340 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.6 --> + <!-- interface-requires LibreOffice 1.0 --> + <object class="GtkDialog" id="VersionsCmisDialog"> + <property name="can_focus">False</property> + <property name="border_width">6</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="layout_style">start</property> + <child> + <object class="GtkButton" id="close"> + <property name="label">gtk-close</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="open"> + <property name="label">gtk-open</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="show"> + <property name="label" translatable="yes">_Show...</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="delete"> + <property name="label">gtk-delete</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkButton" id="compare"> + <property name="label" translatable="yes">_Compare</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <object class="GtkButton" id="help"> + <property name="label">gtk-help</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">6</property> + <property name="secondary">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="row_spacing">12</property> + <child> + <object class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkGrid" id="grid2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkButton" id="save"> + <property name="label" translatable="yes">Save _New Version</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="always"> + <property name="label" translatable="yes">_Always save a new version on closing</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">New versions</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkGrid" id="grid3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="spacing">12</property> + <property name="homogeneous">True</property> + <child> + <object class="GtkLabel" id="datetime"> + <property name="can_focus">False</property> + <property name="no_show_all">True</property> + <property name="label" translatable="yes">Date and time</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="savedby"> + <property name="can_focus">False</property> + <property name="no_show_all">True</property> + <property name="label" translatable="yes">Saved by</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="comments"> + <property name="can_focus">False</property> + <property name="no_show_all">True</property> + <property name="label" translatable="yes">Comments</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="svtlo-SvSimpleTableContainer" id="versions"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Simple Table Container-selection1"/> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Existing versions</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="0">close</action-widget> + <action-widget response="0">open</action-widget> + <action-widget response="0">show</action-widget> + <action-widget response="0">delete</action-widget> + <action-widget response="0">compare</action-widget> + <action-widget response="0">help</action-widget> + </action-widgets> + </object> +</interface> diff --git a/sfx2/uiconfig/ui/versionsofdialog.ui b/sfx2/uiconfig/ui/versionsofdialog.ui index 00d197f374af..45d62761f54e 100644 --- a/sfx2/uiconfig/ui/versionsofdialog.ui +++ b/sfx2/uiconfig/ui/versionsofdialog.ui @@ -87,6 +87,20 @@ </packing> </child> <child> + <object class="GtkButton" id="cmis"> + <property name="label" translatable="yes">CMIS</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">5</property> + </packing> + </child> + + <child> <object class="GtkButton" id="help"> <property name="label">gtk-help</property> <property name="visible">True</property> @@ -97,7 +111,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">5</property> + <property name="position">6</property> <property name="secondary">True</property> </packing> </child> |