Kaydet (Commit) 82925b57 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SfxNewFileDialog

Change-Id: I28b1aff90407bce7d04f10eed6a227c0970f9c0a
Reviewed-on: https://gerrit.libreoffice.org/50878Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 64117f70
...@@ -247,9 +247,6 @@ ...@@ -247,9 +247,6 @@
<glade-widget-class title="Token Window" name="swuilo-SwTokenWindow" <glade-widget-class title="Token Window" name="swuilo-SwTokenWindow"
generic-name="Token Window" parent="GtkDrawingArea" generic-name="Token Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/> icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Template Preview Window" name="sfxlo-SfxPreviewWin"
generic-name="Template Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Template Local View" name="sfxlo-TemplateLocalView" <glade-widget-class title="Template Local View" name="sfxlo-TemplateLocalView"
generic-name="Template Local View" parent="GtkDrawingArea" generic-name="Template Local View" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/> icon-name="widget-gtk-drawingarea"/>
......
...@@ -22,18 +22,17 @@ ...@@ -22,18 +22,17 @@
#include <memory> #include <memory>
#include <sal/config.h> #include <sal/config.h>
#include <sfx2/dllapi.h> #include <sfx2/dllapi.h>
#include <sfx2/objsh.hxx>
#include <vcl/button.hxx> #include <vcl/idle.hxx>
#include <vcl/lstbox.hxx> #include <vcl/weld.hxx>
#include <vcl/edit.hxx> #include <sfx2/doctempl.hxx>
#include <vcl/fixed.hxx>
#include <sfx2/basedlgs.hxx>
#include <o3tl/typed_flags_set.hxx> #include <o3tl/typed_flags_set.hxx>
class SfxObjectShellLock; class SfxObjectShellLock;
class SfxObjectShell; class SfxObjectShell;
class SfxPreviewWin_Impl;
enum class SfxNewFileDialogMode { enum class SfxNewFileDialogMode {
NONE, Preview, LoadTemplate NONE, Preview, LoadTemplate
...@@ -55,19 +54,42 @@ namespace o3tl ...@@ -55,19 +54,42 @@ namespace o3tl
#define RET_TEMPLATE_LOAD 100 #define RET_TEMPLATE_LOAD 100
class SfxNewFileDialog_Impl; class SFX2_DLLPUBLIC SfxNewFileDialog
class SFX2_DLLPUBLIC SfxNewFileDialog : public SfxModalDialog
{ {
friend class SfxNewFileDialog_Impl;
private: private:
std::unique_ptr< SfxNewFileDialog_Impl > pImpl; std::unique_ptr<weld::Builder> m_xBuilder;
std::unique_ptr<weld::Dialog> m_xDialog;
std::unique_ptr<weld::TreeView> m_xRegionLb;
std::unique_ptr<weld::TreeView> m_xTemplateLb;
std::unique_ptr<weld::CheckButton> m_xTextStyleCB;
std::unique_ptr<weld::CheckButton> m_xFrameStyleCB;
std::unique_ptr<weld::CheckButton> m_xPageStyleCB;
std::unique_ptr<weld::CheckButton> m_xNumStyleCB;
std::unique_ptr<weld::CheckButton> m_xMergeStyleCB;
std::unique_ptr<weld::Button> m_xLoadFilePB;
std::unique_ptr<weld::Expander> m_xMoreBt;
std::unique_ptr<SfxPreviewWin_Impl> m_xPreviewWin;
std::unique_ptr<weld::Label> m_xAltTitleFt;
Idle m_aPrevIdle;
OUString m_sLoadTemplate;
SfxNewFileDialogMode m_nFlags;
SfxDocumentTemplates m_aTemplates;
SfxObjectShellLock m_xDocShell;
DECL_LINK( Update, Timer *, void );
DECL_LINK(RegionSelect, weld::TreeView&, void);
DECL_LINK(TemplateSelect, weld::TreeView&, void);
DECL_LINK(DoubleClick, weld::TreeView&, void);
DECL_LINK(Expand, weld::Expander&, void);
sal_uInt16 GetSelectedTemplatePos() const;
public: public:
SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags);
SfxNewFileDialog(vcl::Window *pParent, SfxNewFileDialogMode nFlags); void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); }
virtual ~SfxNewFileDialog() override; short run() { return m_xDialog->run(); }
virtual void dispose() override; ~SfxNewFileDialog();
// Returns false, when '- No -' is set as Template // Returns false, when '- No -' is set as Template
// Template names can only be obtained when IsTemplate() returns true. // Template names can only be obtained when IsTemplate() returns true.
......
...@@ -99,10 +99,25 @@ protected: ...@@ -99,10 +99,25 @@ protected:
public: public:
virtual void set_title(const OUString& rTitle) = 0; virtual void set_title(const OUString& rTitle) = 0;
virtual OUString get_title() const = 0; virtual OUString get_title() const = 0;
virtual void set_busy_cursor(bool bBusy) = 0;
void connect_help(const Link<Widget&, bool>& rLink) { m_aHelpRequestHdl = rLink; } void connect_help(const Link<Widget&, bool>& rLink) { m_aHelpRequestHdl = rLink; }
}; };
class VCL_DLLPUBLIC WaitObject
{
private:
weld::Window* m_pWindow;
public:
WaitObject(weld::Window* pWindow)
: m_pWindow(pWindow)
{
m_pWindow->set_busy_cursor(true);
}
~WaitObject() { m_pWindow->set_busy_cursor(false); }
};
class VCL_DLLPUBLIC Dialog : virtual public Window class VCL_DLLPUBLIC Dialog : virtual public Window
{ {
public: public:
...@@ -455,6 +470,20 @@ public: ...@@ -455,6 +470,20 @@ public:
virtual void set_selection(const Selection&) = 0; virtual void set_selection(const Selection&) = 0;
}; };
class VCL_DLLPUBLIC Expander : virtual public Container
{
protected:
Link<Expander&, void> m_aExpandedHdl;
void signal_expanded() { m_aExpandedHdl.Call(*this); }
public:
virtual bool get_expanded() const = 0;
virtual void set_expanded(bool bExpand) = 0;
void connect_expanded(const Link<Expander&, void>& rLink) { m_aExpandedHdl = rLink; }
};
class VCL_DLLPUBLIC DrawingArea : virtual public Widget class VCL_DLLPUBLIC DrawingArea : virtual public Widget
{ {
protected: protected:
...@@ -500,6 +529,7 @@ public: ...@@ -500,6 +529,7 @@ public:
virtual TreeView* weld_tree_view(const OString& id, bool bTakeOwnership = false) = 0; virtual TreeView* weld_tree_view(const OString& id, bool bTakeOwnership = false) = 0;
virtual Label* weld_label(const OString& id, bool bTakeOwnership = false) = 0; virtual Label* weld_label(const OString& id, bool bTakeOwnership = false) = 0;
virtual TextView* weld_text_view(const OString& id, bool bTakeOwnership = false) = 0; virtual TextView* weld_text_view(const OString& id, bool bTakeOwnership = false) = 0;
virtual Expander* weld_expander(const OString& id, bool bTakeOwnership = false) = 0;
virtual Entry* weld_entry(const OString& id, bool bTakeOwnership = false) = 0; virtual Entry* weld_entry(const OString& id, bool bTakeOwnership = false) = 0;
virtual DrawingArea* weld_drawing_area(const OString& id, bool bTakeOwnership = false) = 0; virtual DrawingArea* weld_drawing_area(const OString& id, bool bTakeOwnership = false) = 0;
virtual ~Builder() {} virtual ~Builder() {}
......
...@@ -179,13 +179,13 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLayoutHdl, ValueSet*, void) ...@@ -179,13 +179,13 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLayoutHdl, ValueSet*, void)
*/ */
IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, Button*, void) IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, Button*, void)
{ {
VclPtrInstance< SfxNewFileDialog > pDlg(this, SfxNewFileDialogMode::Preview); SfxNewFileDialog aDlg(GetFrameWeld(), SfxNewFileDialogMode::Preview);
pDlg->SetText(SdResId(STR_LOAD_PRESENTATION_LAYOUT)); aDlg.set_title(SdResId(STR_LOAD_PRESENTATION_LAYOUT));
if(!IsReallyVisible()) if(!IsReallyVisible())
return; return;
sal_uInt16 nResult = pDlg->Execute(); sal_uInt16 nResult = aDlg.run();
// Inserted update to force repaint // Inserted update to force repaint
Update(); Update();
...@@ -195,9 +195,9 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, Button*, void) ...@@ -195,9 +195,9 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, Button*, void)
{ {
case RET_OK: case RET_OK:
{ {
if (pDlg->IsTemplate()) if (aDlg.IsTemplate())
{ {
maName = pDlg->GetTemplateFileName(); maName = aDlg.GetTemplateFileName();
} }
else else
{ {
...@@ -210,7 +210,6 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, Button*, void) ...@@ -210,7 +210,6 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, Button*, void)
default: default:
bCancel = true; bCancel = true;
} }
pDlg.reset();
if( !bCancel ) if( !bCancel )
{ {
......
This diff is collapsed.
...@@ -19,32 +19,24 @@ ...@@ -19,32 +19,24 @@
#ifndef INCLUDED_SFX2_SOURCE_INC_PREVIEW_HXX #ifndef INCLUDED_SFX2_SOURCE_INC_PREVIEW_HXX
#define INCLUDED_SFX2_SOURCE_INC_PREVIEW_HXX #define INCLUDED_SFX2_SOURCE_INC_PREVIEW_HXX
#include <sfx2/doctempl.hxx> #include <tools/link.hxx>
#include <sfx2/basedlgs.hxx>
class SfxObjectShell; class SfxObjectShell;
class GDIMetaFile; class GDIMetaFile;
class SfxPreviewBase_Impl : public vcl::Window class SfxPreviewWin_Impl
{ {
protected: protected:
std::shared_ptr<GDIMetaFile> xMetaFile; std::shared_ptr<GDIMetaFile> xMetaFile;
std::unique_ptr<weld::DrawingArea> m_xDrawingArea;
public: public:
SfxPreviewBase_Impl(vcl::Window* pParent, WinBits nStyle); SfxPreviewWin_Impl(weld::DrawingArea* pArea);
void SetObjectShell( SfxObjectShell const * pObj ); void SetObjectShell( SfxObjectShell const * pObj );
virtual void Resize() override; DECL_LINK(DoPaint, vcl::RenderContext&, void);
virtual Size GetOptimalSize() const override; DECL_LINK(DoResize, const Size& rSize, void);
}; void queue_draw() { m_xDrawingArea->queue_draw(); }
void show() { m_xDrawingArea->show(); }
class SfxPreviewWin_Impl: public SfxPreviewBase_Impl void set_size_request(int nWidth, int nHeight) { m_xDrawingArea->set_size_request(nWidth, nHeight); }
{
protected:
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
public:
SfxPreviewWin_Impl(vcl::Window* pParent, WinBits nStyle)
: SfxPreviewBase_Impl(pParent, nStyle)
{}
static void ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFile* pFile); static void ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFile* pFile);
}; };
......
...@@ -123,12 +123,12 @@ IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, Button*, pButton, void) ...@@ -123,12 +123,12 @@ IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, Button*, pButton, void)
if(bTemplate) if(bTemplate)
{ {
m_pLoadTemplateRB->Check(); m_pLoadTemplateRB->Check();
VclPtrInstance< SfxNewFileDialog > pNewFileDlg(this, SfxNewFileDialogMode::NONE); SfxNewFileDialog aNewFileDlg(GetFrameWeld(), SfxNewFileDialogMode::NONE);
sal_uInt16 nRet = pNewFileDlg->Execute(); sal_uInt16 nRet = aNewFileDlg.run();
if(RET_TEMPLATE_LOAD == nRet) if(RET_TEMPLATE_LOAD == nRet)
bTemplate = false; bTemplate = false;
else if(RET_CANCEL != nRet) else if(RET_CANCEL != nRet)
m_sLoadTemplateName = pNewFileDlg->GetTemplateFileName(); m_sLoadTemplateName = aNewFileDlg.GetTemplateFileName();
} }
else else
m_pLoadDocRB->Check(); m_pLoadDocRB->Check();
......
...@@ -500,11 +500,10 @@ void SwDocShell::Execute(SfxRequest& rReq) ...@@ -500,11 +500,10 @@ void SwDocShell::Execute(SfxRequest& rReq)
if ( aFileName.isEmpty() ) if ( aFileName.isEmpty() )
{ {
SvtPathOptions aPathOpt; SvtPathOptions aPathOpt;
ScopedVclPtr<SfxNewFileDialog> pNewFileDlg( SfxNewFileDialog aNewFileDlg(GetView()->GetViewFrame()->GetWindow().GetFrameWeld(), SfxNewFileDialogMode::LoadTemplate);
VclPtr<SfxNewFileDialog>::Create(&GetView()->GetViewFrame()->GetWindow(), SfxNewFileDialogMode::LoadTemplate)); aNewFileDlg.SetTemplateFlags(nFlags);
pNewFileDlg->SetTemplateFlags(nFlags);
nRet = pNewFileDlg->Execute(); nRet = aNewFileDlg.run();
if(RET_TEMPLATE_LOAD == nRet) if(RET_TEMPLATE_LOAD == nRet)
{ {
FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE, FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE,
...@@ -560,10 +559,10 @@ void SwDocShell::Execute(SfxRequest& rReq) ...@@ -560,10 +559,10 @@ void SwDocShell::Execute(SfxRequest& rReq)
} }
else if( RET_OK == nRet) else if( RET_OK == nRet)
{ {
aFileName = pNewFileDlg->GetTemplateFileName(); aFileName = aNewFileDlg.GetTemplateFileName();
} }
nFlags = pNewFileDlg->GetTemplateFlags(); nFlags = aNewFileDlg.GetTemplateFlags();
rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) ); rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) );
rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, static_cast<long>(nFlags) ) ); rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, static_cast<long>(nFlags) ) );
} }
......
...@@ -399,6 +399,14 @@ public: ...@@ -399,6 +399,14 @@ public:
return false; return false;
} }
virtual void set_busy_cursor(bool bBusy) override
{
if (bBusy)
m_xWindow->EnterWait();
else
m_xWindow->LeaveWait();
}
virtual ~SalInstanceWindow() override virtual ~SalInstanceWindow() override
{ {
clear_child_help(m_xWindow); clear_child_help(m_xWindow);
...@@ -861,12 +869,12 @@ public: ...@@ -861,12 +869,12 @@ public:
virtual void select(int pos) override virtual void select(int pos) override
{ {
assert(m_xTreeView->IsUpdateMode() && "don't select when frozen");
if (pos == -1) if (pos == -1)
{
m_xTreeView->SetNoSelection(); m_xTreeView->SetNoSelection();
return; else
} m_xTreeView->SelectEntryPos(pos);
m_xTreeView->SelectEntryPos(pos); m_xTreeView->Select();
} }
virtual OUString get_selected() override virtual OUString get_selected() override
...@@ -1063,6 +1071,42 @@ public: ...@@ -1063,6 +1071,42 @@ public:
} }
}; };
class SalInstanceExpander : public SalInstanceContainer, public virtual weld::Expander
{
private:
VclPtr<VclExpander> m_xExpander;
DECL_LINK(ExpandedHdl, VclExpander&, void);
public:
SalInstanceExpander(VclExpander* pExpander, bool bTakeOwnership)
: SalInstanceContainer(pExpander, bTakeOwnership)
, m_xExpander(pExpander)
{
m_xExpander->SetExpandedHdl(LINK(this, SalInstanceExpander, ExpandedHdl));
}
virtual bool get_expanded() const override
{
return m_xExpander->get_expanded();
}
virtual void set_expanded(bool bExpand) override
{
m_xExpander->set_expanded(bExpand);
}
virtual ~SalInstanceExpander() override
{
m_xExpander->SetExpandedHdl(Link<VclExpander&, void>());
}
};
IMPL_LINK_NOARG(SalInstanceExpander, ExpandedHdl, VclExpander&, void)
{
signal_expanded();
}
class SalInstanceDrawingArea : public SalInstanceWidget, public virtual weld::DrawingArea class SalInstanceDrawingArea : public SalInstanceWidget, public virtual weld::DrawingArea
{ {
private: private:
...@@ -1365,6 +1409,12 @@ public: ...@@ -1365,6 +1409,12 @@ public:
return pTextView ? new SalInstanceTextView(pTextView, bTakeOwnership) : nullptr; return pTextView ? new SalInstanceTextView(pTextView, bTakeOwnership) : nullptr;
} }
virtual weld::Expander* weld_expander(const OString &id, bool bTakeOwnership) override
{
VclExpander* pExpander = m_xBuilder->get<VclExpander>(id);
return pExpander ? new SalInstanceExpander(pExpander, bTakeOwnership) : nullptr;
}
virtual weld::DrawingArea* weld_drawing_area(const OString &id, bool bTakeOwnership) override virtual weld::DrawingArea* weld_drawing_area(const OString &id, bool bTakeOwnership) override
{ {
VclDrawingArea* pDrawingArea = m_xBuilder->get<VclDrawingArea>(id); VclDrawingArea* pDrawingArea = m_xBuilder->get<VclDrawingArea>(id);
......
...@@ -1404,6 +1404,17 @@ public: ...@@ -1404,6 +1404,17 @@ public:
const gchar* pStr = gtk_window_get_title(m_pWindow); const gchar* pStr = gtk_window_get_title(m_pWindow);
return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
} }
virtual void set_busy_cursor(bool bBusy) override
{
gtk_widget_realize(m_pWidget);
GdkDisplay *pDisplay = gtk_widget_get_display(m_pWidget);
GdkCursor *pCursor = bBusy ? gdk_cursor_new_from_name(pDisplay, "progress") : nullptr;
gdk_window_set_cursor(gtk_widget_get_window(m_pWidget), pCursor);
gdk_display_flush(pDisplay);
if (pCursor)
g_object_unref(pCursor);
}
}; };
namespace namespace
...@@ -2027,6 +2038,7 @@ public: ...@@ -2027,6 +2038,7 @@ public:
virtual void select(int pos) override virtual void select(int pos) override
{ {
assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen");
if (pos != -1) if (pos != -1)
{ {
GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1); GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
...@@ -2406,7 +2418,7 @@ public: ...@@ -2406,7 +2418,7 @@ public:
GtkInstanceComboBoxText(GtkComboBoxText* pComboBoxText, bool bTakeOwnership) GtkInstanceComboBoxText(GtkComboBoxText* pComboBoxText, bool bTakeOwnership)
: GtkInstanceContainer(GTK_CONTAINER(pComboBoxText), bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pComboBoxText), bTakeOwnership)
, m_pComboBoxText(pComboBoxText) , m_pComboBoxText(pComboBoxText)
, m_nSignalId(g_signal_connect(pComboBoxText, "changed", G_CALLBACK(signalChanged), this)) , m_nSignalId(g_signal_connect(m_pComboBoxText, "changed", G_CALLBACK(signalChanged), this))
{ {
} }
...@@ -2527,6 +2539,42 @@ public: ...@@ -2527,6 +2539,42 @@ public:
} }
}; };
class GtkInstanceExpander : public GtkInstanceContainer, public virtual weld::Expander
{
private:
GtkExpander* m_pExpander;
gulong m_nSignalId;
static void signalExpanded(GtkExpander*, GParamSpec *, gpointer widget)
{
GtkInstanceExpander* pThis = static_cast<GtkInstanceExpander*>(widget);
pThis->signal_expanded();
}
public:
GtkInstanceExpander(GtkExpander* pExpander, bool bTakeOwnership)
: GtkInstanceContainer(GTK_CONTAINER(pExpander), bTakeOwnership)
, m_pExpander(pExpander)
, m_nSignalId(g_signal_connect(m_pExpander, "notify::expanded", G_CALLBACK(signalExpanded), this))
{
}
virtual bool get_expanded() const override
{
return gtk_expander_get_expanded(m_pExpander);
}
virtual void set_expanded(bool bExpand) override
{
gtk_expander_set_expanded(m_pExpander, bExpand);
}
virtual ~GtkInstanceExpander() override
{
g_signal_handler_disconnect(m_pExpander, m_nSignalId);
}
};
namespace namespace
{ {
gboolean signalTooltipQuery(GtkWidget* pWidget, gint /*x*/, gint /*y*/, gboolean signalTooltipQuery(GtkWidget* pWidget, gint /*x*/, gint /*y*/,
...@@ -2810,6 +2858,15 @@ public: ...@@ -2810,6 +2858,15 @@ public:
return new GtkInstanceTextView(pTextView, bTakeOwnership); return new GtkInstanceTextView(pTextView, bTakeOwnership);
} }
virtual weld::Expander* weld_expander(const OString &id, bool bTakeOwnership) override
{
GtkExpander* pExpander = GTK_EXPANDER(gtk_builder_get_object(m_pBuilder, id.getStr()));
if (!pExpander)
return nullptr;
auto_add_parentless_widgets_to_container(GTK_WIDGET(pExpander));
return new GtkInstanceExpander(pExpander, bTakeOwnership);
}
virtual weld::DrawingArea* weld_drawing_area(const OString &id, bool bTakeOwnership) override virtual weld::DrawingArea* weld_drawing_area(const OString &id, bool bTakeOwnership) override
{ {
GtkDrawingArea* pDrawingArea = GTK_DRAWING_AREA(gtk_builder_get_object(m_pBuilder, id.getStr())); GtkDrawingArea* pDrawingArea = GTK_DRAWING_AREA(gtk_builder_get_object(m_pBuilder, id.getStr()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment