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

weld SvxThesaurusDialog

Change-Id: I09a7b4dcd43af061d0e4be42a7b6a2ebf2331d0d
Reviewed-on: https://gerrit.libreoffice.org/73282Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 2a1ebc88
......@@ -86,7 +86,6 @@
#define RID_SVXSTR_HYPERDLG_FROM_TEXT NC_("RID_SVXSTR_HYPERDLG_FROM_TEXT", "Text")
#define RID_SVXSTR_HYPERDLG_QUERYOVERWRITE NC_("RID_SVXSTR_HYPERDLG_QUERYOVERWRITE", "The file already exists. Overwrite?")
#define RID_SVXSTR_ERR_TEXTNOTFOUND NC_("RID_SVXSTR_ERR_TEXTNOTFOUND", "No alternatives found.")
#define RID_SVXSTR_SELECT_FILE_IFRAME NC_("RID_SVXSTR_SELECT_FILE_IFRAME", "Select File for Floating Frame")
#define RID_SVXSTR_ALLFUNCTIONS NC_("RID_SVXSTR_ALLFUNCTIONS", "All commands")
#define RID_SVXSTR_MACROS NC_("RID_SVXSTR_MACROS", "Macros")
......
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CUI_SOURCE_DIALOGS_THESDLG_IMPL_HXX
#define INCLUDED_CUI_SOURCE_DIALOGS_THESDLG_IMPL_HXX
#include <thesdlg.hxx>
#include <svtools/ehdl.hxx>
#include <vcl/svlbitm.hxx>
#include <svx/checklbx.hxx>
#include <vcl/button.hxx>
#include <vcl/combobox.hxx>
#include <vcl/edit.hxx>
#include <vcl/image.hxx>
#include <vcl/menubtn.hxx>
#include <vcl/svapp.hxx>
#include <vcl/timer.hxx>
#include <vcl/wrkwin.hxx>
#include <stack>
#include <map>
#include <algorithm>
class SvTreeListEntry;
class ThesaurusAlternativesCtrl;
class AlternativesString : public SvLBoxString
{
ThesaurusAlternativesCtrl& m_rControlImpl;
public:
AlternativesString( ThesaurusAlternativesCtrl &rControl, const OUString& rStr );
virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext,
const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -133,7 +133,15 @@ short AbstractHyphenWordDialog_Impl::Execute()
return m_xDlg->run();
}
IMPL_ABSTDLG_BASE(AbstractThesaurusDialog_Impl)
short AbstractThesaurusDialog_Impl::Execute()
{
return m_xDlg->run();
}
bool AbstractThesaurusDialog_Impl::StartExecuteAsync(AsyncContext &rCtx)
{
return SfxDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
}
short AbstractSvxZoomDialog_Impl::Execute()
{
......@@ -463,7 +471,7 @@ OUString AbstractHangulHanjaConversionDialog_Impl::GetCurrentSuggestion( ) const
OUString AbstractThesaurusDialog_Impl::GetWord()
{
return pDlg->GetWord();
return m_xDlg->GetWord();
};
Reference < css::embed::XEmbeddedObject > AbstractInsertObjectDialog_Impl::GetObject()
......@@ -1016,12 +1024,11 @@ VclPtr<AbstractHangulHanjaConversionDialog> AbstractDialogFactory_Impl::CreateHa
return VclPtr<AbstractHangulHanjaConversionDialog_Impl>::Create(std::make_unique<HangulHanjaConversionDialog>(pParent));
}
VclPtr<AbstractThesaurusDialog> AbstractDialogFactory_Impl::CreateThesaurusDialog( vcl::Window* pParent,
css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus,
const OUString &rWord, LanguageType nLanguage )
VclPtr<AbstractThesaurusDialog> AbstractDialogFactory_Impl::CreateThesaurusDialog(weld::Window* pParent,
css::uno::Reference<css::linguistic2::XThesaurus> xThesaurus,
const OUString &rWord, LanguageType nLanguage)
{
VclPtrInstance<SvxThesaurusDialog> pDlg( pParent, xThesaurus, rWord, nLanguage );
return VclPtr<AbstractThesaurusDialog_Impl>::Create( pDlg );
return VclPtr<AbstractThesaurusDialog_Impl>::Create(std::make_unique<SvxThesaurusDialog>(pParent, xThesaurus, rWord, nLanguage));
}
VclPtr<AbstractHyphenWordDialog> AbstractDialogFactory_Impl::CreateHyphenWordDialog(weld::Window* pParent,
......
......@@ -183,7 +183,14 @@ public:
class AbstractThesaurusDialog_Impl : public AbstractThesaurusDialog
{
DECL_ABSTDLG_BASE(AbstractThesaurusDialog_Impl,SvxThesaurusDialog)
std::shared_ptr<SvxThesaurusDialog> m_xDlg;
public:
explicit AbstractThesaurusDialog_Impl(std::unique_ptr<SvxThesaurusDialog> p)
: m_xDlg(std::move(p))
{
}
virtual short Execute() override;
virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
virtual OUString GetWord() override;
};
......@@ -715,8 +722,9 @@ public:
virtual VclPtr<SfxAbstractLinksDialog> CreateLinksDialog(weld::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML = false, sfx2::SvBaseLink* p=nullptr) override;
virtual VclPtr<AbstractHangulHanjaConversionDialog> CreateHangulHanjaConversionDialog(weld::Window* pParent) override;
virtual VclPtr<AbstractThesaurusDialog> CreateThesaurusDialog( vcl::Window*, css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus,
const OUString &rWord, LanguageType nLanguage ) override;
virtual VclPtr<AbstractThesaurusDialog> CreateThesaurusDialog(weld::Window*,
css::uno::Reference<css::linguistic2::XThesaurus> xThesaurus,
const OUString &rWord, LanguageType nLanguage) override;
virtual VclPtr<AbstractHyphenWordDialog> CreateHyphenWordDialog(weld::Window*,
const OUString &rWord, LanguageType nLang,
......
......@@ -26,108 +26,14 @@
#include <vcl/combobox.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/idle.hxx>
#include <svx/stddlg.hxx>
#include <sfx2/basedlgs.hxx>
#include <memory>
#include <stack>
class SvxThesaurusDialog;
class LookUpComboBox : public ComboBox
{
Idle m_aModifyIdle;
VclPtr<SvxThesaurusDialog> m_pDialog;
LookUpComboBox( const LookUpComboBox & ) = delete;
LookUpComboBox& operator = ( const LookUpComboBox & ) = delete;
public:
LookUpComboBox(vcl::Window *pParent);
virtual ~LookUpComboBox() override;
virtual void dispose() override;
DECL_LINK( ModifyTimer_Hdl, Timer *, void );
void init(SvxThesaurusDialog *pDialog);
// ComboBox
virtual void Modify() override;
};
class AlternativesExtraData
class SvxThesaurusDialog : public SfxDialogController
{
OUString sText;
bool bHeader;
public:
AlternativesExtraData() : bHeader( false ) {}
AlternativesExtraData( const OUString &rText, bool bIsHeader ) :
sText(rText),
bHeader(bIsHeader)
{
}
bool IsHeader() const { return bHeader; }
const OUString& GetText() const { return sText; }
};
class ThesaurusAlternativesCtrl
: public SvxCheckListBox
{
VclPtr<SvxThesaurusDialog> m_pDialog;
typedef std::map< const SvTreeListEntry *, AlternativesExtraData > UserDataMap_t;
UserDataMap_t m_aUserData;
ThesaurusAlternativesCtrl( const ThesaurusAlternativesCtrl & ) = delete;
ThesaurusAlternativesCtrl & operator = ( const ThesaurusAlternativesCtrl & ) = delete;
public:
ThesaurusAlternativesCtrl(vcl::Window* pParent);
void init(SvxThesaurusDialog *pDialog);
virtual ~ThesaurusAlternativesCtrl() override;
virtual void dispose() override;
SvTreeListEntry * AddEntry( sal_Int32 nVal, const OUString &rText, bool bIsHeader );
void ClearExtraData();
void SetExtraData( const SvTreeListEntry *pEntry, const AlternativesExtraData &rData );
AlternativesExtraData * GetExtraData( const SvTreeListEntry *pEntry );
virtual void KeyInput( const KeyEvent& rKEvt ) override;
virtual void Paint( vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect ) override;
};
class ReplaceEdit : public Edit
{
VclPtr<Button> m_pBtn;
ReplaceEdit( const ReplaceEdit & ) = delete;
ReplaceEdit & operator = ( const ReplaceEdit & ) = delete;
public:
ReplaceEdit(vcl::Window *pParent);
virtual ~ReplaceEdit() override;
virtual void dispose() override;
void init(Button *pBtn) { m_pBtn = pBtn; }
// Edit
virtual void Modify() override;
virtual void SetText( const OUString& rStr ) override;
virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override;
};
class SvxThesaurusDialog : public SvxStandardDialog
{
VclPtr<PushButton> m_pLeftBtn;
VclPtr<LookUpComboBox> m_pWordCB;
VclPtr<ThesaurusAlternativesCtrl> m_pAlternativesCT;
VclPtr<ReplaceEdit> m_pReplaceEdit;
VclPtr<ListBox> m_pLangLB;
OUString m_aErrStr;
Idle m_aModifyIdle;
css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus;
OUString aLookUpText;
......@@ -135,22 +41,30 @@ class SvxThesaurusDialog : public SvxStandardDialog
std::stack< OUString > aLookUpHistory;
bool m_bWordFound;
std::unique_ptr<weld::Button> m_xLeftBtn;
std::unique_ptr<weld::ComboBox> m_xWordCB;
std::unique_ptr<weld::TreeView> m_xAlternativesCT;
std::unique_ptr<weld::Label> m_xNotFound;
std::unique_ptr<weld::Entry> m_xReplaceEdit;
std::unique_ptr<weld::ComboBox> m_xLangLB;
std::unique_ptr<weld::Button> m_xReplaceBtn;
public:
virtual ~SvxThesaurusDialog() override;
virtual void dispose() override;
bool WordFound() const { return m_bWordFound; }
const OUString& getErrStr() const { return m_aErrStr; }
// Handler
DECL_LINK( ReplaceBtnHdl_Impl, Button *, void );
DECL_LINK( LeftBtnHdl_Impl, Button *, void );
DECL_LINK( LanguageHdl_Impl, ListBox&, void );
DECL_LINK( WordSelectHdl_Impl, ComboBox&, void );
DECL_LINK( AlternativesSelectHdl_Impl, SvTreeListBox*, void );
DECL_LINK( AlternativesDoubleClickHdl_Impl, SvTreeListBox*, bool );
DECL_STATIC_LINK( SvxThesaurusDialog, SelectFirstHdl_Impl, void*, void );
DECL_LINK( ReplaceBtnHdl_Impl, weld::Button&, void );
DECL_LINK( LeftBtnHdl_Impl, weld::Button&, void );
DECL_LINK( LanguageHdl_Impl, weld::ComboBox&, void );
DECL_LINK( WordSelectHdl_Impl, weld::ComboBox&, void );
DECL_LINK( AlternativesSelectHdl_Impl, weld::TreeView&, void );
DECL_LINK( AlternativesDoubleClickHdl_Impl, weld::TreeView&, void );
DECL_LINK( SelectFirstHdl_Impl, void*, void );
DECL_LINK( ReplaceEditHdl_Impl, weld::Entry&, void );
DECL_LINK( ModifyTimer_Hdl, Timer *, void );
DECL_LINK( KeyInputHdl, const KeyEvent&, bool );
/// @throws css::lang::IllegalArgumentException
/// @throws css::uno::RuntimeException
......@@ -160,13 +74,11 @@ public:
bool UpdateAlternativesBox_Impl();
void LookUp( const OUString &rText );
void LookUp_Impl();
virtual void Apply() override;
public:
SvxThesaurusDialog( vcl::Window* pParent,
css::uno::Reference< css::linguistic2::XThesaurus > const & xThesaurus,
const OUString &rWord, LanguageType nLanguage );
SvxThesaurusDialog(weld::Window* pParent,
css::uno::Reference< css::linguistic2::XThesaurus > const & xThesaurus,
const OUString &rWord, LanguageType nLanguage);
void SetWindowTitle( LanguageType nLanguage );
OUString GetWord();
};
......
......@@ -28,7 +28,7 @@
<column type="gchararray"/>
<!-- column-name weight1 -->
<column type="gint"/>
<!-- column-name weight1 -->
<!-- column-name weight2 -->
<column type="gint"/>
<!-- column-name sensitive1 -->
<column type="gboolean"/>
......
This diff is collapsed.
......@@ -2429,7 +2429,8 @@ EESpellState ImpEditEngine::StartThesaurus( EditView* pEditView )
return EESpellState::ErrorFound;
EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create();
ScopedVclPtr<AbstractThesaurusDialog> xDlg(pFact->CreateThesaurusDialog( pEditView->GetWindow(), xThes, aWord, GetLanguage( aCurSel.Max() ) ));
ScopedVclPtr<AbstractThesaurusDialog> xDlg(pFact->CreateThesaurusDialog(pEditView->GetWindow()->GetFrameWeld(), xThes,
aWord, GetLanguage( aCurSel.Max() ) ));
if (xDlg->Execute() == RET_OK)
{
// Replace Word...
......
......@@ -27,15 +27,9 @@
<glade-widget-class title="Search Results Box" name="sfxlo-SearchResultsBox"
generic-name="SearchResultsBox" parent="GtkComboBoxText"
icon-name="widget-gtk-comboboxtext"/>
<glade-widget-class title="Thesaurus View" name="cuilo-ThesaurusAlternativesCtrl"
generic-name="ThesaurusAlternativesCtrl" parent="GtkTextView"
icon-name="widget-gtk-textview"/>
<glade-widget-class title="Spelling View" name="cuilo-SentenceEditWindow"
generic-name="SentenceEditWindow" parent="GtkTextView"
icon-name="widget-gtk-textview"/>
<glade-widget-class title="Thesaurus Edit" name="cuilo-ReplaceEdit"
generic-name="ReplaceEdit" parent="GtkEntry"
icon-name="widget-gtk-textentry"/>
<glade-widget-class title="Condition Edit" name="rptuilo-ConditionField"
generic-name="ConditionEdit" parent="GtkEntry"
icon-name="widget-gtk-comboboxtext"/>
......
......@@ -93,8 +93,9 @@ class EDITENG_DLLPUBLIC EditAbstractDialogFactory : virtual public VclAbstractDi
public:
virtual ~EditAbstractDialogFactory() override; // needed for export of vtable
static EditAbstractDialogFactory* Create();
virtual VclPtr<AbstractThesaurusDialog> CreateThesaurusDialog( vcl::Window*, css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus,
const OUString &rWord, LanguageType nLanguage ) = 0;
virtual VclPtr<AbstractThesaurusDialog> CreateThesaurusDialog(weld::Window*,
css::uno::Reference<css::linguistic2::XThesaurus> xThesaurus,
const OUString &rWord, LanguageType nLanguage) = 0;
virtual VclPtr<AbstractHyphenWordDialog> CreateHyphenWordDialog(weld::Window*,
const OUString &rWord, LanguageType nLang,
......
......@@ -681,6 +681,8 @@ public:
virtual void set_image(int row, const css::uno::Reference<css::graphic::XGraphic>& rImage,
int col = -1)
= 0;
virtual void set_text_emphasis(int row, bool bOn, int col) = 0;
virtual bool get_text_emphasis(int row, int col) const = 0;
virtual void set_top_entry(int pos) = 0;
virtual void swap(int pos1, int pos2) = 0;
virtual std::vector<int> get_selected_rows() const = 0;
......
......@@ -459,7 +459,6 @@ custom_widgets = [
'IndexBox',
'IndexBox',
'LightButton',
'LookUpComboBox',
'ManagedMenuButton',
'MultiLineEditSyntaxHighlight',
'OFileURLControl',
......@@ -470,7 +469,6 @@ custom_widgets = [
'PriorityMergedHBox',
'PropertyControl',
'RecentDocsView',
'ReplaceEdit',
'RowEdit',
'SameContentListBox',
'ScCsvTableBox',
......@@ -512,7 +510,6 @@ custom_widgets = [
'SwNavHelpToolBox',
'TableValueSet',
'TemplateDefaultView',
'ThesaurusAlternativesCtrl',
'ValueSet',
]
......
......@@ -2739,7 +2739,6 @@ cui/source/dialogs/showcols.cxx
cui/source/dialogs/splitcelldlg.cxx
cui/source/dialogs/srchxtra.cxx
cui/source/dialogs/thesdlg.cxx
cui/source/dialogs/thesdlg_impl.hxx
cui/source/dialogs/zoom.cxx
cui/source/factory/cuiexp.cxx
cui/source/factory/cuiresmgr.cxx
......
......@@ -439,6 +439,7 @@ cui/uiconfig/ui/textanimtabpage.ui://GtkLabel[@id='FT_DELAY'] orphan-label
cui/uiconfig/ui/textflowpage.ui://GtkLabel[@id='labelOrphan'] orphan-label
cui/uiconfig/ui/textflowpage.ui://GtkLabel[@id='labelWidow'] orphan-label
cui/uiconfig/ui/thesaurus.ui://GtkButton[@id='left'] button-no-label
cui/uiconfig/ui/thesaurus.ui://GtkLabel[@id='notfound'] orphan-label
cui/uiconfig/ui/tsaurldialog.ui://GtkLabel[@id='label2'] orphan-label
cui/uiconfig/ui/tsaurldialog.ui://GtkTreeView[@id='urls:border'] no-labelled-by
cui/uiconfig/ui/tsaurldialog.ui://GtkLabel[@id='enteraurl'] orphan-label
......
......@@ -578,7 +578,7 @@ void SwView::StartThesaurus()
SwWait aWait( *GetDocShell(), true );
// load library with dialog only on demand ...
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
pDlg.reset(pFact->CreateThesaurusDialog(&GetEditWin(), xThes, aTmp, eLang));
pDlg.reset(pFact->CreateThesaurusDialog(GetEditWin().GetFrameWeld(), xThes, aTmp, eLang));
}
if (pDlg)
......@@ -590,6 +590,7 @@ void SwView::StartThesaurus()
InsertThesaurusSynonym(pDlg->GetWord(), aTmp, bSelection);
pVOpt->SetIdle(bOldIdle);
pDlg->disposeOnce();
});
}
}
......
......@@ -3141,12 +3141,24 @@ public:
set_text_emphasis(rVclIter.iter, bOn, col);
}
virtual void set_text_emphasis(int pos, bool bOn, int col) override
{
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
set_text_emphasis(pEntry, bOn, col);
}
virtual bool get_text_emphasis(const weld::TreeIter& rIter, int col) const override
{
const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
return ::get_text_emphasis(rVclIter.iter, col);
}
virtual bool get_text_emphasis(int pos, int col) const override
{
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
return ::get_text_emphasis(pEntry, col);
}
void set_image(SvTreeListEntry* pEntry, const Image& rImage, int col)
{
if (col == -1)
......
......@@ -6361,6 +6361,17 @@ private:
return nRet;
}
gint get_int(int pos, int col) const
{
gint nRet(-1);
GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
GtkTreeIter iter;
if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos))
nRet = get_int(iter, col);
gtk_tree_model_get(pModel, &iter, col, &nRet, -1);
return nRet;
}
bool get_bool(const GtkTreeIter& iter, int col) const
{
gboolean bRet(false);
......@@ -6411,6 +6422,14 @@ private:
gtk_tree_store_set(m_pTreeStore, const_cast<GtkTreeIter*>(&iter), col, bInt, -1);
}
void set(int pos, int col, gint bInt)
{
GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
GtkTreeIter iter;
if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos))
set(iter, col, bInt);
}
static gboolean signalTestExpandRow(GtkTreeView*, GtkTreeIter* iter, GtkTreePath*, gpointer widget)
{
GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget);
......@@ -7118,6 +7137,12 @@ public:
set(rGtkIter.iter, m_aWeightMap[col], bOn ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
}
virtual void set_text_emphasis(int pos, bool bOn, int col) override
{
col = get_model_col(col);
set(pos, m_aWeightMap[col], bOn ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
}
virtual bool get_text_emphasis(const weld::TreeIter& rIter, int col) const override
{
const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter);
......@@ -7125,6 +7150,12 @@ public:
return get_int(rGtkIter.iter, m_aWeightMap.find(col)->second) == PANGO_WEIGHT_BOLD;
}
virtual bool get_text_emphasis(int pos, int col) const override
{
col = get_model_col(col);
return get_int(pos, m_aWeightMap.find(col)->second) == PANGO_WEIGHT_BOLD;
}
using GtkInstanceWidget::set_sensitive;
virtual void set_sensitive(int pos, bool bSensitive, int col) override
......
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