summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-04-03 16:27:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-04-03 21:02:02 +0200
commitc5dac92053f053f302ac404afe0816b4d0654158 (patch)
treea4933f10a3e528618a551e81ba91fe77e0f37f64 /cui
parent4329d9d8cf83f3642c068a1493c979a894328e26 (diff)
weld SvPasteObjectDialog
Change-Id: I5248950fd3650df309015fbaf4302d2541a6374a Reviewed-on: https://gerrit.libreoffice.org/52337 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/pastedlg.cxx67
-rw-r--r--cui/source/factory/dlgfact.cxx22
-rw-r--r--cui/source/factory/dlgfact.hxx11
-rw-r--r--cui/source/inc/pastedlg.hxx29
-rw-r--r--cui/uiconfig/ui/pastespecial.ui44
5 files changed, 96 insertions, 77 deletions
diff --git a/cui/source/dialogs/pastedlg.cxx b/cui/source/dialogs/pastedlg.cxx
index 30205888f936..6c3a2ecaf176 100644
--- a/cui/source/dialogs/pastedlg.cxx
+++ b/cui/source/dialogs/pastedlg.cxx
@@ -37,52 +37,38 @@
#include <dialmgr.hxx>
-SvPasteObjectDialog::SvPasteObjectDialog( vcl::Window* pParent )
- : ModalDialog(pParent, "PasteSpecialDialog", "cui/ui/pastespecial.ui")
+SvPasteObjectDialog::SvPasteObjectDialog(weld::Window* pParent)
+ : GenericDialogController(pParent, "cui/ui/pastespecial.ui", "PasteSpecialDialog")
+ , m_xFtObjectSource(m_xBuilder->weld_label("source"))
+ , m_xLbInsertList(m_xBuilder->weld_tree_view("list"))
+ , m_xOKButton(m_xBuilder->weld_button("ok"))
{
- get(m_pFtObjectSource, "source");
- get(m_pLbInsertList, "list");
- get(m_pOKButton, "ok");
+ m_xLbInsertList->set_size_request(m_xLbInsertList->get_approximate_digit_width() * 40,
+ m_xLbInsertList->get_height_rows(6));
+ m_xOKButton->set_sensitive(false);
- m_pLbInsertList->SetDropDownLineCount(8);
- m_pLbInsertList->set_width_request(m_pLbInsertList->approximate_char_width() * 32);
- m_pOKButton->Disable();
-
- ObjectLB().SetSelectHdl( LINK( this, SvPasteObjectDialog, SelectHdl ) );
- ObjectLB().SetDoubleClickHdl( LINK( this, SvPasteObjectDialog, DoubleClickHdl ) );
-}
-
-SvPasteObjectDialog::~SvPasteObjectDialog()
-{
- disposeOnce();
-}
-
-void SvPasteObjectDialog::dispose()
-{
- m_pFtObjectSource.clear();
- m_pLbInsertList.clear();
- m_pOKButton.clear();
- ModalDialog::dispose();
+ ObjectLB().connect_changed(LINK(this, SvPasteObjectDialog, SelectHdl));
+ ObjectLB().connect_row_activated(LINK( this, SvPasteObjectDialog, DoubleClickHdl));
}
void SvPasteObjectDialog::SelectObject()
{
- if (m_pLbInsertList->GetEntryCount())
+ if (m_xLbInsertList->n_children())
{
- m_pLbInsertList->SelectEntryPos(0);
- SelectHdl(*m_pLbInsertList);
+ m_xLbInsertList->select(0);
+ SelectHdl(*m_xLbInsertList);
}
}
-IMPL_LINK_NOARG( SvPasteObjectDialog, SelectHdl, ListBox&, void )
+IMPL_LINK_NOARG(SvPasteObjectDialog, SelectHdl, weld::TreeView&, void)
{
- if ( !m_pOKButton->IsEnabled() )
- m_pOKButton->Enable();
+ if (!m_xOKButton->get_sensitive())
+ m_xOKButton->set_sensitive(true);
}
-IMPL_LINK_NOARG( SvPasteObjectDialog, DoubleClickHdl, ListBox&, void )
+IMPL_LINK_NOARG(SvPasteObjectDialog, DoubleClickHdl, weld::TreeView&, void)
{
- EndDialog( RET_OK );
+ m_xDialog->response(RET_OK);
}
/*************************************************************************
@@ -109,7 +95,7 @@ SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelpe
SotClipboardFormatId nSelFormat = SotClipboardFormatId::NONE;
SvGlobalName aEmptyNm;
- ObjectLB().SetUpdateMode( false );
+ ObjectLB().freeze();
for (auto const& format : *pFormats)
{
@@ -169,9 +155,10 @@ SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelpe
continue;
}
- if( LISTBOX_ENTRY_NOTFOUND == ObjectLB().GetEntryPos( aName ) )
- ObjectLB().SetEntryData(
- ObjectLB().InsertEntry( aName ), reinterpret_cast<void*>(nFormat) );
+ if (ObjectLB().find(aName) == -1)
+ {
+ ObjectLB().append(OUString::number(static_cast<sal_uInt32>(nFormat)), aName, "");
+ }
}
}
@@ -190,7 +177,7 @@ SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelpe
}
}
- ObjectLB().SetUpdateMode( true );
+ ObjectLB().thaw();
SelectObject();
if( !aSourceName.isEmpty() )
@@ -202,11 +189,11 @@ SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelpe
aTypeName = convertLineEnd(aTypeName, GetSystemLineEnd());
}
- m_pFtObjectSource->SetText( aTypeName );
+ m_xFtObjectSource->set_label(aTypeName);
- if( Dialog::Execute() == RET_OK )
+ if (run() == RET_OK)
{
- nSelFormat = static_cast<SotClipboardFormatId>(reinterpret_cast<sal_uLong>(ObjectLB().GetSelectedEntryData()));
+ nSelFormat = static_cast<SotClipboardFormatId>(ObjectLB().get_selected_id().toUInt32());
}
return nSelFormat;
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index a3b1ced56c74..bf07b49fc5d5 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -147,7 +147,12 @@ IMPL_ABSTDLG_BASE(AbstractSvxHpLinkDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractFmSearchDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractGraphicFilterDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractSvxAreaTabDialog_Impl);
-IMPL_ABSTDLG_BASE(AbstractPasteDialog_Impl);
+
+short AbstractPasteDialog_Impl::Execute()
+{
+ return m_xDlg->run();
+}
+
IMPL_ABSTDLG_BASE(AbstractInsertObjectDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractLinksDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractSpellDialog_Impl);
@@ -393,19 +398,19 @@ bool AbstractInsertObjectDialog_Impl::IsCreateNew()
return pDlg->GetIconIfIconified( pGraphicMediaType );
}
-void AbstractPasteDialog_Impl::Insert( SotClipboardFormatId nFormat, const OUString & rFormatName )
+void AbstractPasteDialog_Impl::Insert(SotClipboardFormatId nFormat, const OUString& rFormatName)
{
- pDlg->Insert( nFormat, rFormatName );
+ m_xDlg->Insert(nFormat, rFormatName);
}
-void AbstractPasteDialog_Impl::SetObjName( const SvGlobalName & rClass, const OUString & rObjName )
+void AbstractPasteDialog_Impl::SetObjName(const SvGlobalName & rClass, const OUString& rObjName)
{
- pDlg->SetObjName( rClass, rObjName );
+ m_xDlg->SetObjName(rClass, rObjName);
}
SotClipboardFormatId AbstractPasteDialog_Impl::GetFormat( const TransferableDataHelper& aHelper )
{
- return pDlg->GetFormat( aHelper );
+ return m_xDlg->GetFormat(aHelper);
}
void AbstractFmShowColsDialog_Impl::SetColumns(const ::Reference< css::container::XIndexContainer>& xCols)
@@ -1499,10 +1504,9 @@ VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateEditObjectDialog( co
return nullptr;
}
-
-VclPtr<SfxAbstractPasteDialog> AbstractDialogFactory_Impl::CreatePasteDialog( vcl::Window* pParent )
+VclPtr<SfxAbstractPasteDialog> AbstractDialogFactory_Impl::CreatePasteDialog(weld::Window* pParent)
{
- return VclPtr<AbstractPasteDialog_Impl>::Create( VclPtr<SvPasteObjectDialog>::Create( pParent ) );
+ return VclPtr<AbstractPasteDialog_Impl>::Create(new SvPasteObjectDialog(pParent));
}
VclPtr<SfxAbstractLinksDialog> AbstractDialogFactory_Impl::CreateLinksDialog( vcl::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML, sfx2::SvBaseLink* p)
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 2b36adee6204..ddea72e2c206 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -433,8 +433,15 @@ class AbstractInsertObjectDialog_Impl : public SfxAbstractInsertObjectDialog
class AbstractPasteDialog_Impl : public SfxAbstractPasteDialog
{
+protected:
+ std::unique_ptr<SvPasteObjectDialog> m_xDlg;
+public:
+ explicit AbstractPasteDialog_Impl(SvPasteObjectDialog* p)
+ : m_xDlg(p)
+ {
+ }
+ virtual short Execute() override;
public:
- DECL_ABSTDLG_BASE(AbstractPasteDialog_Impl, SvPasteObjectDialog )
virtual void Insert( SotClipboardFormatId nFormat, const OUString & rFormatName ) override;
virtual void SetObjName( const SvGlobalName & rClass, const OUString & rObjName ) override;
virtual SotClipboardFormatId GetFormat( const TransferableDataHelper& aHelper ) override;
@@ -546,7 +553,7 @@ public:
const SvObjectServerList* pList ) override;
virtual VclPtr<VclAbstractDialog> CreateEditObjectDialog( const OUString& rCommmand,
const css::uno::Reference < css::embed::XEmbeddedObject >& xObj ) override;
- virtual VclPtr<SfxAbstractPasteDialog> CreatePasteDialog( vcl::Window* pParent ) override;
+ virtual VclPtr<SfxAbstractPasteDialog> CreatePasteDialog(weld::Window* pParent) override;
virtual VclPtr<SfxAbstractLinksDialog> CreateLinksDialog( vcl::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML = false, sfx2::SvBaseLink* p=nullptr ) override;
virtual VclPtr<AbstractHangulHanjaConversionDialog> CreateHangulHanjaConversionDialog( vcl::Window* _pParent,
diff --git a/cui/source/inc/pastedlg.hxx b/cui/source/inc/pastedlg.hxx
index 6ef2572d839b..55f2c43dd83e 100644
--- a/cui/source/inc/pastedlg.hxx
+++ b/cui/source/inc/pastedlg.hxx
@@ -24,38 +24,29 @@
#include <sot/formats.hxx>
#include <tools/globname.hxx>
#include <svtools/transfer.hxx>
-
-#include <vcl/dialog.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/button.hxx>
-#include <vcl/edit.hxx>
-#include <vcl/lstbox.hxx>
-
-/********************** SvPasteObjectDialog ******************************
-*************************************************************************/
+#include <vcl/weld.hxx>
struct TransferableObjectDescriptor;
class TransferableDataHelper;
-class SvPasteObjectDialog : public ModalDialog
+class SvPasteObjectDialog : public weld::GenericDialogController
{
- VclPtr<FixedText> m_pFtObjectSource;
- VclPtr<ListBox> m_pLbInsertList;
- VclPtr<OKButton> m_pOKButton;
std::map< SotClipboardFormatId, OUString > aSupplementMap;
SvGlobalName aObjClassName;
OUString aObjName;
- ListBox& ObjectLB() { return *m_pLbInsertList; }
+ std::unique_ptr<weld::Label> m_xFtObjectSource;
+ std::unique_ptr<weld::TreeView> m_xLbInsertList;
+ std::unique_ptr<weld::Button> m_xOKButton;
+
+ weld::TreeView& ObjectLB() { return *m_xLbInsertList; }
void SelectObject();
- DECL_LINK( SelectHdl, ListBox&, void );
- DECL_LINK( DoubleClickHdl, ListBox&, void );
+ DECL_LINK(SelectHdl, weld::TreeView&, void);
+ DECL_LINK(DoubleClickHdl, weld::TreeView&, void);
public:
- SvPasteObjectDialog( vcl::Window* pParent );
- virtual ~SvPasteObjectDialog() override;
- virtual void dispose() override;
+ SvPasteObjectDialog(weld::Window* pParent);
void Insert( SotClipboardFormatId nFormat, const OUString & rFormatName );
void SetObjName( const SvGlobalName & rClass, const OUString & rObjName );
diff --git a/cui/uiconfig/ui/pastespecial.ui b/cui/uiconfig/ui/pastespecial.ui
index 0a9684cd5b67..8931e42e2944 100644
--- a/cui/uiconfig/ui/pastespecial.ui
+++ b/cui/uiconfig/ui/pastespecial.ui
@@ -1,20 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.4 -->
<interface domain="cui">
- <!-- interface-requires gtk+ 3.0 -->
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="PasteSpecialDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="pastespecial|PasteSpecialDialog">Paste Special</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox3">
<property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area3">
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="layout_style">start</property>
+ <property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
@@ -57,6 +69,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
+ <property name="secondary">True</property>
</packing>
</child>
</object>
@@ -129,20 +142,34 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTreeView" id="list:border">
+ <object class="GtkTreeView" id="list">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
<child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection"/>
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
</child>
</object>
</child>
@@ -181,5 +208,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>