[Libreoffice-commits] core.git: extras/source sfx2/inc sfx2/source sfx2/uiconfig sfx2/UIConfig_sfx.mk solenv/bin solenv/sanitizers
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 12 18:24:29 UTC 2020
extras/source/glade/libreoffice-catalog.xml.in | 16
sfx2/UIConfig_sfx.mk | 1
sfx2/inc/pch/precompiled_sfx.hxx | 12
sfx2/source/appl/newhelp.cxx | 2042 +++++++++----------------
sfx2/source/appl/newhelp.hxx | 398 ++--
sfx2/uiconfig/ui/helpbookmarkpage.ui | 78
sfx2/uiconfig/ui/helpcontentpage.ui | 57
sfx2/uiconfig/ui/helpcontrol.ui | 109 +
sfx2/uiconfig/ui/helpindexpage.ui | 116 +
sfx2/uiconfig/ui/helpsearchpage.ui | 60
sfx2/uiconfig/ui/helpwindow.ui | 207 ++
solenv/bin/native-code.py | 5
solenv/sanitizers/ui/sfx.suppr | 3
13 files changed, 1534 insertions(+), 1570 deletions(-)
New commits:
commit 859636d491960b797bd8cbfb81e6f08451175f12
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Apr 29 20:29:45 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 12 20:23:50 2020 +0200
weld help browser
Change-Id: Ibd8dcc10c4403731953e2e46db4ae8f89ebc7e4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93216
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index cb5b695f86da..9316bb275289 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -15,22 +15,6 @@
-->
<glade-catalog name="LibreOffice" domain="glade-3" depends="gtk+" version="1.0">
<glade-widget-classes>
- <glade-widget-class title="Bookmarks Box" name="sfxlo-BookmarksBox"
- generic-name="BookmarksBox" parent="GtkComboBoxText"
- icon-name="widget-gtk-comboboxtext"/>
- <glade-widget-class title="Index Box" name="sfxlo-IndexBox"
- generic-name="IndexBox" parent="GtkComboBoxText"
- icon-name="widget-gtk-comboboxtext"/>
- <glade-widget-class title="Search Box" name="sfxlo-SearchBox"
- generic-name="SearchBox" parent="GtkComboBoxText"
- icon-name="widget-gtk-comboboxtext"/>
- <glade-widget-class title="Search Results Box" name="sfxlo-SearchResultsBox"
- generic-name="SearchResultsBox" parent="GtkComboBoxText"
- icon-name="widget-gtk-comboboxtext"/>
-
- <glade-widget-class title="Content List Box" name="sfxlo-ContentListBox"
- generic-name="Content List Box" parent="GtkTreeView"
- icon-name="widget-gtk-treeview"/>
<glade-widget-class title="Sidebar ToolBox" name="sfxlo-SidebarToolBox"
generic-name="Sidebar ToolBox" parent="GtkToolbar"
diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk
index c682be2b214b..5e79a8399cbf 100644
--- a/sfx2/UIConfig_sfx.mk
+++ b/sfx2/UIConfig_sfx.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\
sfx2/uiconfig/ui/helpindexpage \
sfx2/uiconfig/ui/helpmanual \
sfx2/uiconfig/ui/helpsearchpage \
+ sfx2/uiconfig/ui/helpwindow \
sfx2/uiconfig/ui/inputdialog \
sfx2/uiconfig/ui/licensedialog \
sfx2/uiconfig/ui/linefragment \
diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx
index fd89965cc4c8..5120b4494745 100644
--- a/sfx2/inc/pch/precompiled_sfx.hxx
+++ b/sfx2/inc/pch/precompiled_sfx.hxx
@@ -13,7 +13,7 @@
manual changes will be rewritten by the next run of update_pch.sh (which presumably
also fixes all possible problems, so it's usually better to use it).
- Generated on 2020-04-25 20:55:30 using:
+ Generated on 2020-04-30 12:39:28 using:
./bin/update_pch sfx2 sfx --cutoff=3 --exclude:system --exclude:module --exclude:local
If after updating build fails, use the following command to locate conflicting headers:
@@ -94,6 +94,7 @@
#include <vcl/button.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/commandinfoprovider.hxx>
+#include <vcl/ctrl.hxx>
#include <vcl/dibtools.hxx>
#include <vcl/dllapi.h>
#include <vcl/errcode.hxx>
@@ -119,7 +120,6 @@
#include <vcl/taskpanelist.hxx>
#include <vcl/timer.hxx>
#include <vcl/toolbox.hxx>
-#include <vcl/treelistbox.hxx>
#include <vcl/vclenum.hxx>
#include <vcl/vclptr.hxx>
#include <vcl/virdev.hxx>
@@ -140,6 +140,7 @@
#include <basic/sbstar.hxx>
#include <basic/sbxdef.hxx>
#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/PropertyExistException.hpp>
@@ -153,6 +154,8 @@
#include <com/sun/star/container/XContainerQuery.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
#include <com/sun/star/document/DocumentProperties.hpp>
#include <com/sun/star/document/MacroExecMode.hpp>
#include <com/sun/star/document/UpdateDocMode.hpp>
@@ -165,6 +168,7 @@
#include <com/sun/star/document/XScriptInvocationContext.hpp>
#include <com/sun/star/document/XTypeDetection.hpp>
#include <com/sun/star/document/XViewDataSupplier.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/EmbedStates.hpp>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
@@ -189,6 +193,7 @@
#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
#include <com/sun/star/frame/XTitle.hpp>
#include <com/sun/star/frame/XToolbarController.hpp>
#include <com/sun/star/frame/status/ItemStatus.hpp>
@@ -233,12 +238,14 @@
#include <com/sun/star/ucb/XContent.hpp>
#include <com/sun/star/ucb/XContentAccess.hpp>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
+#include <com/sun/star/ui/XSidebarPanel.hpp>
#include <com/sun/star/ui/XUIElement.hpp>
#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/ControlActions.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#include <com/sun/star/uno/Any.h>
#include <com/sun/star/uno/Any.hxx>
@@ -444,6 +451,7 @@
#include <sfx2/sidebar/Context.hxx>
#include <sfx2/sidebar/Deck.hxx>
#include <sfx2/sidebar/Panel.hxx>
+#include <sfx2/sidebar/PanelLayout.hxx>
#include <sfx2/sidebar/ResourceManager.hxx>
#include <sfx2/sidebar/SidebarChildWindow.hxx>
#include <sfx2/sidebar/SidebarController.hxx>
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 4a9b5b8e73bc..e48522f87808 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -25,7 +25,6 @@
#include "panelist.hxx"
#include <srchdlg.hxx>
#include <sfx2/sfxhelp.hxx>
-#include <vcl/treelistentry.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
#include <tools/debug.hxx>
@@ -78,11 +77,14 @@
#include <tools/urlobj.hxx>
#include <svtools/imagemgr.hxx>
#include <svtools/miscopt.hxx>
-#include <vcl/unohelp.hxx>
+#include <vcl/commandevent.hxx>
+#include <vcl/event.hxx>
#include <vcl/i18nhelp.hxx>
#include <vcl/layout.hxx>
#include <vcl/taskpanelist.hxx>
#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/unohelp.hxx>
#include <vcl/weld.hxx>
#include <ucbhelper/content.hxx>
@@ -111,24 +113,6 @@ using namespace ::comphelper;
// defines ---------------------------------------------------------------
-#define SPLITSET_ID 0
-#define COLSET_ID 1
-#define INDEXWIN_ID 2
-#define TEXTWIN_ID 3
-
-#define TOOLBOX_OFFSET 3
-
-#define TBI_INDEX 1001
-#define TBI_BACKWARD 1002
-#define TBI_FORWARD 1003
-#define TBI_START 1004
-#define TBI_PRINT 1005
-#define TBI_COPY 1006
-#define TBI_BOOKMARKS 1007
-#define TBI_SEARCHDIALOG 1008
-#define TBI_SOURCEVIEW 1009
-#define TBI_SELECTIONMODE 1010
-
#define CONFIGNAME_HELPWIN "OfficeHelp"
#define CONFIGNAME_INDEXWIN "OfficeHelpIndex"
#define CONFIGNAME_SEARCHPAGE "OfficeHelpSearch"
@@ -250,98 +234,48 @@ struct ContentEntry_Impl
}
-// ContentListBox_Impl ---------------------------------------------------
-
-ContentListBox_Impl::ContentListBox_Impl(vcl::Window* pParent, WinBits nStyle)
- : SvTreeListBox(pParent, nStyle)
- , aOpenBookImage(StockImage::Yes, BMP_HELP_CONTENT_BOOK_OPEN)
- , aClosedBookImage(StockImage::Yes, BMP_HELP_CONTENT_BOOK_CLOSED)
- , aDocumentImage(StockImage::Yes, BMP_HELP_CONTENT_DOC)
-
-{
- SetStyle( GetStyle() | WB_HIDESELECTION | WB_HSCROLL );
-
- SetEntryHeight( 16 );
- SetSelectionMode( SelectionMode::Single );
- SetSpaceBetweenEntries( 2 );
- SetNodeBitmaps( aClosedBookImage, aOpenBookImage );
-
- SetSublistOpenWithReturn();
- SetSublistOpenWithLeftRight();
-
- InitRoot();
-}
-
-extern "C" SAL_DLLPUBLIC_EXPORT void makeContentListBox(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
-{
- static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>,
- decltype(makeContentListBox)>);
- WinBits nWinStyle = WB_TABSTOP;
- OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
- if (!sBorder.isEmpty())
- nWinStyle |= WB_BORDER;
- rRet = VclPtr<ContentListBox_Impl>::Create(pParent, nWinStyle);
-}
-
-ContentListBox_Impl::~ContentListBox_Impl()
-{
- disposeOnce();
-}
-
-void ContentListBox_Impl::dispose()
-{
- sal_uInt16 nPos = 0;
- SvTreeListEntry* pEntry = GetEntry( nPos++ );
- while ( pEntry )
- {
- ClearChildren( pEntry );
- delete static_cast<ContentEntry_Impl*>(pEntry->GetUserData());
- pEntry = GetEntry( nPos++ );
- }
- SvTreeListBox::dispose();
-}
-
-void ContentListBox_Impl::InitRoot()
+void ContentTabPage_Impl::InitRoot()
{
std::vector< OUString > aList =
SfxContentHelper::GetHelpTreeViewContents( "vnd.sun.star.hier://com.sun.star.help.TreeView/" );
- for(const OUString & aRow : aList)
+ for (const OUString & aRow : aList)
{
sal_Int32 nIdx = 0;
OUString aTitle = aRow.getToken( 0, '\t', nIdx );
OUString aURL = aRow.getToken( 0, '\t', nIdx );
sal_Unicode cFolder = aRow.getToken( 0, '\t', nIdx )[0];
bool bIsFolder = ( '1' == cFolder );
- SvTreeListEntry* pEntry = InsertEntry( aTitle, aOpenBookImage, aClosedBookImage, nullptr, true );
- if ( bIsFolder )
- pEntry->SetUserData( new ContentEntry_Impl( aURL, true ) );
+ OUString sId;
+ if (bIsFolder)
+ sId = OUString::number(reinterpret_cast<sal_Int64>(new ContentEntry_Impl(aURL, true)));
+ m_xContentBox->insert(nullptr, -1, &aTitle, &sId, nullptr, nullptr, &aClosedBookImage, true, nullptr);
}
}
-
-void ContentListBox_Impl::ClearChildren( SvTreeListEntry* pParent )
+void ContentTabPage_Impl::ClearChildren(weld::TreeIter* pParent)
{
- SvTreeListEntry* pEntry = FirstChild( pParent );
- while ( pEntry )
+ std::unique_ptr<weld::TreeIter> xEntry = m_xContentBox->make_iterator(pParent);
+ bool bEntry = m_xContentBox->iter_children(*xEntry);
+ while (bEntry)
{
- ClearChildren( pEntry );
- delete static_cast<ContentEntry_Impl*>(pEntry->GetUserData());
- pEntry = pEntry->NextSibling();
+ ClearChildren(xEntry.get());
+ delete reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_id(*xEntry).toInt64());
+ bEntry = m_xContentBox->iter_next_sibling(*xEntry);
}
-}
+}
-void ContentListBox_Impl::RequestingChildren( SvTreeListEntry* pParent )
+IMPL_LINK(ContentTabPage_Impl, ExpandingHdl, const weld::TreeIter&, rIter, bool)
{
- try
+ ContentEntry_Impl* pContentEntry = reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_id(rIter).toInt64());
+ if (!m_xContentBox->iter_has_child(rIter))
{
- if ( !pParent->HasChildren() )
+ try
{
- if ( pParent->GetUserData() )
+ if (pContentEntry)
{
- std::vector<OUString > aList =
- SfxContentHelper::GetHelpTreeViewContents( static_cast<ContentEntry_Impl*>(pParent->GetUserData())->aURL );
+ std::vector<OUString > aList = SfxContentHelper::GetHelpTreeViewContents(pContentEntry->aURL);
for (const OUString & aRow : aList)
{
@@ -350,213 +284,284 @@ void ContentListBox_Impl::RequestingChildren( SvTreeListEntry* pParent )
OUString aURL = aRow.getToken( 0, '\t', nIdx );
sal_Unicode cFolder = aRow.getToken( 0, '\t', nIdx )[0];
bool bIsFolder = ( '1' == cFolder );
- SvTreeListEntry* pEntry = nullptr;
if ( bIsFolder )
{
- pEntry = InsertEntry( aTitle, aOpenBookImage, aClosedBookImage, pParent, true );
- pEntry->SetUserData( new ContentEntry_Impl( aURL, true ) );
+ OUString sId = OUString::number(reinterpret_cast<sal_Int64>(new ContentEntry_Impl(aURL, true)));
+ m_xContentBox->insert(&rIter, -1, &aTitle, &sId, nullptr, nullptr, &aClosedBookImage, true, nullptr);
}
else
{
- pEntry = InsertEntry( aTitle, aDocumentImage, aDocumentImage, pParent );
Any aAny( ::utl::UCBContentHelper::GetProperty( aURL, "TargetURL" ) );
+ OUString sId;
OUString aTargetURL;
if ( aAny >>= aTargetURL )
- pEntry->SetUserData( new ContentEntry_Impl( aTargetURL, false ) );
+ sId = OUString::number(reinterpret_cast<sal_Int64>(new ContentEntry_Impl(aTargetURL, false)));
+ m_xContentBox->insert(&rIter, -1, &aTitle, &sId, nullptr, nullptr, &aDocumentImage, false, nullptr);
}
}
}
}
+ catch (const Exception&)
+ {
+ OSL_FAIL( "ContentListBox_Impl::RequestingChildren(): unexpected exception" );
+ }
}
- catch( Exception& )
- {
- OSL_FAIL( "ContentListBox_Impl::RequestingChildren(): unexpected exception" );
- }
-}
+ if (!pContentEntry || pContentEntry->bIsFolder)
+ m_xContentBox->set_image(rIter, aOpenBookImage);
+
+ return true;
+}
-bool ContentListBox_Impl::EventNotify( NotifyEvent& rNEvt )
+IMPL_LINK(ContentTabPage_Impl, CollapsingHdl, const weld::TreeIter&, rIter, bool)
{
- bool bHandled = false;
- if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT &&
- KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
- {
- GetDoubleClickHdl().Call( nullptr );
- bHandled = true;
- }
+ ContentEntry_Impl* pContentEntry = reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_id(rIter).toInt64());
+ if (!pContentEntry || pContentEntry->bIsFolder)
+ m_xContentBox->set_image(rIter, aClosedBookImage);
- return bHandled || SvTreeListBox::EventNotify( rNEvt );
+ return true;
}
-
-OUString ContentListBox_Impl::GetSelectedEntry() const
+OUString ContentTabPage_Impl::GetSelectedEntry() const
{
OUString aRet;
- SvTreeListEntry* pEntry = FirstSelected();
- if ( pEntry && !static_cast<ContentEntry_Impl*>(pEntry->GetUserData())->bIsFolder )
- aRet = static_cast<ContentEntry_Impl*>(pEntry->GetUserData())->aURL;
+ ContentEntry_Impl* pEntry = reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_selected_id().toInt64());
+ if (pEntry && !pEntry->bIsFolder)
+ aRet = pEntry->aURL;
return aRet;
}
// class HelpTabPage_Impl ------------------------------------------------
-HelpTabPage_Impl::HelpTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin,
+HelpTabPage_Impl::HelpTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* pIdxWin,
const OString& rID, const OUString& rUIXMLDescription)
- : TabPage( pParent, rID, rUIXMLDescription)
- , m_pIdxWin( _pIdxWin )
+ : BuilderPage(pParent, nullptr, rUIXMLDescription, rID)
+ , m_pIdxWin(pIdxWin)
{
}
HelpTabPage_Impl::~HelpTabPage_Impl()
{
- disposeOnce();
}
-void HelpTabPage_Impl::dispose()
+// class ContentTabPage_Impl ---------------------------------------------
+ContentTabPage_Impl::ContentTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* pIdxWin)
+ : HelpTabPage_Impl(pParent, pIdxWin, "HelpContentPage",
+ "sfx/ui/helpcontentpage.ui")
+ , m_xContentBox(m_xBuilder->weld_tree_view("content"))
+ , aOpenBookImage(BMP_HELP_CONTENT_BOOK_OPEN)
+ , aClosedBookImage(BMP_HELP_CONTENT_BOOK_CLOSED)
+ , aDocumentImage(BMP_HELP_CONTENT_DOC)
{
- m_pIdxWin.clear();
- TabPage::dispose();
+ m_xContentBox->set_size_request(m_xContentBox->get_approximate_digit_width() * 30,
+ m_xContentBox->get_height_rows(20));
+ m_xContentBox->connect_row_activated(LINK(this, ContentTabPage_Impl, DoubleClickHdl));
+ m_xContentBox->connect_expanding(LINK(this, ContentTabPage_Impl, ExpandingHdl));
+ m_xContentBox->connect_collapsing(LINK(this, ContentTabPage_Impl, CollapsingHdl));
+
+ InitRoot();
}
-// class ContentTabPage_Impl ---------------------------------------------
-ContentTabPage_Impl::ContentTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin)
- : HelpTabPage_Impl(pParent, _pIdxWin, "HelpContentPage",
- "sfx/ui/helpcontentpage.ui")
+IMPL_LINK_NOARG(ContentTabPage_Impl, DoubleClickHdl, weld::TreeView&, bool)
{
- get(m_pContentBox, "content");
- Size aSize(LogicToPixel(Size(108 , 188), MapMode(MapUnit::MapAppFont)));
- m_pContentBox->set_width_request(aSize.Width());
- m_pContentBox->set_height_request(aSize.Height());
+ aDoubleClickHdl.Call(nullptr);
+ return false;
}
-ContentTabPage_Impl::~ContentTabPage_Impl()
+void ContentTabPage_Impl::SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink)
{
- disposeOnce();
+ aDoubleClickHdl = rLink;
}
-void ContentTabPage_Impl::dispose()
+ContentTabPage_Impl::~ContentTabPage_Impl()
{
- m_pContentBox.clear();
- HelpTabPage_Impl::dispose();
+ std::unique_ptr<weld::TreeIter> xEntry = m_xContentBox->make_iterator();
+ bool bEntry = m_xContentBox->get_iter_first(*xEntry);
+ while (bEntry)
+ {
+ ClearChildren(xEntry.get());
+ delete reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_id(*xEntry).toInt64());
+ bEntry = m_xContentBox->iter_next_sibling(*xEntry);
+ }
}
-void ContentTabPage_Impl::ActivatePage()
+weld::Widget* ContentTabPage_Impl::GetLastFocusControl()
{
- if ( !m_pIdxWin->WasCursorLeftOrRight() )
- SetFocusOnBox();
+ return m_xContentBox.get();
}
-Control* ContentTabPage_Impl::GetLastFocusControl()
+void IndexTabPage_Impl::SelectExecutableEntry()
{
- return m_pContentBox;
+ sal_Int32 nPos = m_xIndexList->find_text(m_xIndexEntry->get_text());
+ if (nPos == -1)
+ return;
+
+ sal_Int32 nOldPos = nPos;
+ OUString aEntryText;
+ IndexEntry_Impl* pEntry = reinterpret_cast<IndexEntry_Impl*>(m_xIndexList->get_id(nPos).toInt64());
+ sal_Int32 nCount = m_xIndexList->n_children();
+ while ( nPos < nCount && ( !pEntry || pEntry->m_aURL.isEmpty() ) )
+ {
+ pEntry = reinterpret_cast<IndexEntry_Impl*>(m_xIndexList->get_id(++nPos).toInt64());
+ aEntryText = m_xIndexList->get_text(nPos);
+ }
+
+ if ( nOldPos != nPos )
+ m_xIndexEntry->set_text(aEntryText);
}
-// class IndexBox_Impl ---------------------------------------------------
+// class IndexTabPage_Impl -----------------------------------------------
+IndexTabPage_Impl::IndexTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* pIdxWin)
+ : HelpTabPage_Impl(pParent, pIdxWin, "HelpIndexPage", "sfx/ui/helpindexpage.ui")
+ , m_xIndexEntry(m_xBuilder->weld_entry("termentry"))
+ , m_xIndexList(m_xBuilder->weld_tree_view("termlist"))
+ , m_xOpenBtn(m_xBuilder->weld_button("display"))
+ , aFactoryIdle("sfx2 appl IndexTabPage_Impl Factory")
+ , aAutoCompleteIdle("sfx2 appl IndexTabPage_Impl AutoComplete")
+ , bIsActivated(false)
+ , nRowHeight(m_xIndexList->get_height_rows(1))
+ , nAllHeight(0)
+{
+ m_xIndexList->set_size_request(m_xIndexList->get_approximate_digit_width() * 30, -1);
+
+ m_xOpenBtn->connect_clicked(LINK(this, IndexTabPage_Impl, OpenHdl));
+ aFactoryIdle.SetInvokeHandler( LINK(this, IndexTabPage_Impl, IdleHdl ));
+ aAutoCompleteIdle.SetInvokeHandler( LINK(this, IndexTabPage_Impl, AutoCompleteHdl ));
+ aKeywordTimer.SetInvokeHandler( LINK( this, IndexTabPage_Impl, TimeoutHdl ) );
+ m_xIndexList->connect_row_activated(LINK(this, IndexTabPage_Impl, DoubleClickHdl));
+ m_xIndexList->connect_changed(LINK(this, IndexTabPage_Impl, TreeChangeHdl));
+ m_xIndexList->connect_custom_get_size(LINK(this, IndexTabPage_Impl, CustomGetSizeHdl));
+ m_xIndexList->connect_custom_render(LINK(this, IndexTabPage_Impl, CustomRenderHdl));
+ m_xIndexList->set_column_custom_renderer(0, true);
+ m_xIndexList->connect_size_allocate(LINK(this, IndexTabPage_Impl, ResizeHdl));
+ m_xIndexEntry->connect_key_press(LINK(this, IndexTabPage_Impl, KeyInputHdl));
+ m_xIndexEntry->connect_changed(LINK(this, IndexTabPage_Impl, EntryChangeHdl));
+ m_xIndexEntry->connect_activate(LINK(this, IndexTabPage_Impl, ActivateHdl));
+}
-IndexBox_Impl::IndexBox_Impl(vcl::Window* pParent, WinBits nStyle)
- : ComboBox(pParent, nStyle)
+IMPL_LINK(IndexTabPage_Impl, ResizeHdl, const Size&, rSize, void)
{
- EnableAutocomplete(true);
- EnableUserDraw(true);
+ nAllHeight = rSize.Height();
}
-extern "C" SAL_DLLPUBLIC_EXPORT void makeIndexBox(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
+IMPL_LINK_NOARG(IndexTabPage_Impl, CustomGetSizeHdl, weld::TreeView::get_size_args, Size)
{
- static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>,
- decltype(makeIndexBox)>);
- WinBits nWinBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK;
- OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
- if (!sBorder.isEmpty())
- nWinBits |= WB_BORDER;
- VclPtrInstance<IndexBox_Impl> pListBox(pParent, nWinBits);
- pListBox->EnableAutoSize(true);
- rRet = pListBox;
+ return Size(m_xIndexList->get_size_request().Width(), nRowHeight);
}
-void IndexBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
+IMPL_LINK(IndexTabPage_Impl, CustomRenderHdl, weld::TreeView::render_args, aPayload, void)
{
- IndexEntry_Impl* pEntry = static_cast<IndexEntry_Impl*>(GetEntryData( rUDEvt.GetItemId() ));
- if ( pEntry && pEntry->m_bSubEntry )
+ vcl::RenderContext& rRenderContext = std::get<0>(aPayload);
+ const ::tools::Rectangle& rRect = std::get<1>(aPayload);
+ bool bSelected = std::get<2>(aPayload);
+ const OUString& rId = std::get<3>(aPayload);
+
+ rRenderContext.Push(PushFlags::TEXTCOLOR);
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ if (bSelected)
+ rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
+ else
+ rRenderContext.SetTextColor(rStyleSettings.GetDialogTextColor());
+
+ Point aPos(rRect.TopLeft());
+ aPos.AdjustY((rRect.GetHeight() - rRenderContext.GetTextHeight()) / 2);
+
+ int nIndex = m_xIndexList->find_id(rId);
+ OUString aEntry(m_xIndexList->get_text(nIndex));
+
+ IndexEntry_Impl* pEntry = reinterpret_cast<IndexEntry_Impl*>(rId.toInt64());
+ if (pEntry && pEntry->m_bSubEntry)
{
// indent sub entries
- Point aPos( rUDEvt.GetRect().TopLeft() );
- aPos.AdjustX(8 );
- aPos.AdjustY((rUDEvt.GetRect().GetHeight() - rUDEvt.GetRenderContext()->GetTextHeight()) / 2 );
- OUString aEntry( GetEntry( rUDEvt.GetItemId() ) );
- sal_Int32 nPos = aEntry.indexOf( ';' );
- rUDEvt.GetRenderContext()->DrawText(aPos, (nPos !=-1) ? aEntry.copy(nPos + 1) : aEntry);
+ aPos.AdjustX(8);
+ sal_Int32 nPos = aEntry.indexOf(';');
+ rRenderContext.DrawText(aPos, (nPos !=-1) ? aEntry.copy(nPos + 1) : aEntry);
}
else
- DrawEntry( rUDEvt, true, true );
-}
+ rRenderContext.DrawText(aPos, aEntry);
+ rRenderContext.Pop();
+}
-bool IndexBox_Impl::EventNotify( NotifyEvent& rNEvt )
+IMPL_LINK_NOARG(IndexTabPage_Impl, TreeChangeHdl, weld::TreeView&, void)
{
- bool bHandled = false;
- if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT &&
- KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
- {
- GetDoubleClickHdl().Call( *this );
- bHandled = true;
- }
-
- return bHandled || ComboBox::EventNotify( rNEvt );
+ m_xIndexEntry->set_text(m_xIndexList->get_selected_text());
}
+IMPL_LINK_NOARG(IndexTabPage_Impl, EntryChangeHdl, weld::Entry&, void)
+{
+ aAutoCompleteIdle.Start();
+}
-void IndexBox_Impl::SelectExecutableEntry()
+IMPL_LINK(IndexTabPage_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
{
- sal_Int32 nPos = GetEntryPos( GetText() );
- if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
- return;
+ const vcl::KeyCode& rKCode = rKEvt.GetKeyCode();
+ if (rKCode.GetModifier()) // only with no modifiers held
+ return false;
- sal_Int32 nOldPos = nPos;
- OUString aEntryText;
- IndexEntry_Impl* pEntry = static_cast<IndexEntry_Impl*>(GetEntryData( nPos ));
- sal_Int32 nCount = GetEntryCount();
- while ( nPos < nCount && ( !pEntry || pEntry->m_aURL.isEmpty() ) )
- {
- pEntry = static_cast<IndexEntry_Impl*>(GetEntryData( ++nPos ));
- aEntryText = GetEntry( nPos );
- }
+ sal_uInt16 nCode = rKCode.GetCode();
- if ( nOldPos != nPos )
- SetText( aEntryText );
-}
+ if (nCode == KEY_UP || nCode == KEY_PAGEUP ||
+ nCode == KEY_DOWN || nCode == KEY_PAGEDOWN)
+ {
+// disable_notify_events();
+ sal_Int32 nIndex = m_xIndexList->get_selected_index();
+ sal_Int32 nOrigIndex = nIndex;
+ sal_Int32 nCount = m_xIndexList->n_children();
+ if (nIndex == -1)
+ {
+ m_xIndexList->set_cursor(0);
+ m_xIndexList->select(0);
+ m_xIndexEntry->set_text(m_xIndexList->get_selected_text());
+ }
+ else
+ {
+ if (nCode == KEY_UP)
+ --nIndex;
+ else if (nCode == KEY_DOWN)
+ ++nIndex;
+ else if (nCode == KEY_PAGEUP)
+ {
+ int nVisRows = nAllHeight / nRowHeight;
+ nIndex -= nVisRows;
+ }
+ else if (nCode == KEY_PAGEDOWN)
+ {
+ int nVisRows = nAllHeight / nRowHeight;
+ nIndex += nVisRows;
+ }
-// class IndexTabPage_Impl -----------------------------------------------
+ if (nIndex < 0)
+ nIndex = 0;
+ if (nIndex >= nCount)
+ nIndex = nCount - 1;
-IndexTabPage_Impl::IndexTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin)
- : HelpTabPage_Impl(pParent, _pIdxWin, "HelpIndexPage",
- "sfx/ui/helpindexpage.ui")
- , aFactoryIdle("sfx2 appl IndexTabPage_Impl Factory")
- , bIsActivated(false)
-{
- get(m_pIndexCB, "terms");
- Size aSize(LogicToPixel(Size(108, 97), MapMode(MapUnit::MapAppFont)));
- m_pIndexCB->set_width_request(aSize.Width());
- m_pIndexCB->set_height_request(aSize.Height());
- get(m_pOpenBtn, "display");
+ if (nIndex != nOrigIndex)
+ {
+ m_xIndexList->set_cursor(nIndex);
+ m_xIndexList->select(nIndex);
+ m_xIndexEntry->set_text(m_xIndexList->get_selected_text());
+ }
- m_pOpenBtn->SetClickHdl( LINK( this, IndexTabPage_Impl, OpenHdl ) );
- aFactoryIdle.SetInvokeHandler( LINK(this, IndexTabPage_Impl, IdleHdl ));
- aKeywordTimer.SetInvokeHandler( LINK( this, IndexTabPage_Impl, TimeoutHdl ) );
+// m_xIndexList->grab_focus();
+// g_signal_emit_by_name(pWidget, "key-press-event", pEvent, &ret);
+// m_xIndexEntry->set_text(m_xIndexList->get_selected_text());
+// m_xIndexEntry->grab_focus();
+ }
+ m_xIndexEntry->select_region(0, -1);
+// enable_notify_events();
+// m_bTreeChange = true;
+// m_pEntry->fire_signal_changed();
+// m_bTreeChange = false;
+ return true;
+ }
+ return false;
}
IndexTabPage_Impl::~IndexTabPage_Impl()
-{
- disposeOnce();
-}
-
-void IndexTabPage_Impl::dispose()
{
ClearIndex();
- m_pIndexCB.clear();
- m_pOpenBtn.clear();
- HelpTabPage_Impl::dispose();
}
-
namespace sfx2 {
typedef std::unordered_map< OUString, int > KeywordInfo;
@@ -564,7 +569,7 @@ namespace sfx2 {
void IndexTabPage_Impl::InitializeIndex()
{
- weld::WaitObject aWaitCursor(GetFrameWeld());
+ weld::WaitObject aWaitCursor(m_pIdxWin->GetFrameWeld());
// By now more than 256 equal entries are not allowed
sal_Unicode append[256];
@@ -572,7 +577,7 @@ void IndexTabPage_Impl::InitializeIndex()
k = ' ';
sfx2::KeywordInfo aInfo;
- m_pIndexCB->SetUpdateMode( false );
+ m_xIndexList->freeze();
try
{
@@ -602,7 +607,6 @@ void IndexTabPage_Impl::InitializeIndex()
if ( ( aAnySeq[0] >>= aKeywordList ) && ( aAnySeq[1] >>= aKeywordRefList ) &&
( aAnySeq[2] >>= aAnchorRefList ) && ( aAnySeq[3] >>= aTitleRefList ) )
{
- sal_Int32 nPos;
int ndx,tmp;
OUString aIndex, aTempString;
OUStringBuffer aData( 128 ); // Capacity of up to 128 characters
@@ -622,6 +626,8 @@ void IndexTabPage_Impl::InitializeIndex()
ndx = aKeywordPair.indexOf( ';' );
const bool insert = ndx != -1;
+ OUString sId;
+
if ( insert )
{
aTempString = aKeywordPair.copy( 0, ndx );
@@ -629,22 +635,16 @@ void IndexTabPage_Impl::InitializeIndex()
{
aIndex = aTempString;
it = aInfo.emplace(aTempString, 0).first;
+ sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(OUString(), false)));
if ( (tmp = it->second++) != 0)
- m_pIndexCB->InsertEntry(aTempString + OUString(append, tmp));
+ m_xIndexList->append(sId, aTempString + OUString(append, tmp));
else
- m_pIndexCB->InsertEntry(aTempString);
+ m_xIndexList->append(sId, aTempString);
}
}
else
aIndex.clear();
- // Assume the token is trimmed
- it = aInfo.emplace(aKeywordPair, 0).first;
- if ((tmp = it->second++) != 0)
- nPos = m_pIndexCB->InsertEntry(aKeywordPair + OUString(append, tmp));
- else
- nPos = m_pIndexCB->InsertEntry(aKeywordPair);
-
sal_uInt32 nRefListLen = aRefList.getLength();
DBG_ASSERT( aAnchorList.hasElements(), "*IndexTabPage_Impl::InitializeIndex(): AnchorList is empty!" );
@@ -655,12 +655,19 @@ void IndexTabPage_Impl::InitializeIndex()
if ( aAnchorList[0].getLength() > 0 )
{
aData.append( aRefList[0] ).append( '#' ).append( aAnchorList[0] );
- m_pIndexCB->SetEntryData( nPos, new IndexEntry_Impl( aData.makeStringAndClear(), insert ) );
+ sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(aData.makeStringAndClear(), insert)));
}
else
- m_pIndexCB->SetEntryData( nPos, new IndexEntry_Impl( aRefList[0], insert ) );
+ sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(aRefList[0], insert)));
}
+ // Assume the token is trimmed
+ it = aInfo.emplace(aKeywordPair, 0).first;
+ if ((tmp = it->second++) != 0)
+ m_xIndexList->append(sId, aKeywordPair + OUString(append, tmp));
+ else
+ m_xIndexList->append(sId, aKeywordPair);
+
for ( sal_uInt32 j = 1; j < nRefListLen ; ++j )
{
aData
@@ -671,19 +678,20 @@ void IndexTabPage_Impl::InitializeIndex()
.append( aTitleList[j] );
aTempString = aData.makeStringAndClear();
- it = aInfo.emplace(aTempString, 0).first;
- if ( (tmp = it->second++) != 0 )
- nPos = m_pIndexCB->InsertEntry(aTempString + OUString(append, tmp));
- else
- nPos = m_pIndexCB->InsertEntry(aTempString);
if ( aAnchorList[j].getLength() > 0 )
{
aData.append( aRefList[j] ).append( '#' ).append( aAnchorList[j] );
- m_pIndexCB->SetEntryData( nPos, new IndexEntry_Impl( aData.makeStringAndClear(), insert ) );
+ sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(aData.makeStringAndClear(), insert)));
}
else
- m_pIndexCB->SetEntryData( nPos, new IndexEntry_Impl( aRefList[j], insert ) );
+ sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(aRefList[j], insert)));
+
+ it = aInfo.emplace(aTempString, 0).first;
+ if ( (tmp = it->second++) != 0 )
+ m_xIndexList->append(sId, aTempString + OUString(append, tmp));
+ else
+ m_xIndexList->append(sId, aTempString);
}
}
}
@@ -694,7 +702,7 @@ void IndexTabPage_Impl::InitializeIndex()
OSL_FAIL( "IndexTabPage_Impl::InitializeIndex(): unexpected exception" );
}
- m_pIndexCB->SetUpdateMode( true );
+ m_xIndexList->thaw();
if ( !sKeyword.isEmpty() )
aKeywordLink.Call( *this );
@@ -702,21 +710,95 @@ void IndexTabPage_Impl::InitializeIndex()
void IndexTabPage_Impl::ClearIndex()
{
- const sal_Int32 nCount = m_pIndexCB->GetEntryCount();
+ const sal_Int32 nCount = m_xIndexList->n_children();
for ( sal_Int32 i = 0; i < nCount; ++i )
- delete static_cast<IndexEntry_Impl*>(m_pIndexCB->GetEntryData(i));
- m_pIndexCB->Clear();
+ delete reinterpret_cast<IndexEntry_Impl*>(m_xIndexList->get_id(i).toInt64());
+ m_xIndexList->clear();
+}
+
+IMPL_LINK_NOARG(IndexTabPage_Impl, OpenHdl, weld::Button&, void)
+{
+ aDoubleClickHdl.Call(nullptr);
+}
+
+IMPL_LINK_NOARG(IndexTabPage_Impl, ActivateHdl, weld::Entry&, bool)
+{
+ aDoubleClickHdl.Call(nullptr);
+ return true;
}
-IMPL_LINK_NOARG(IndexTabPage_Impl, OpenHdl, Button*, void)
+IMPL_LINK_NOARG(IndexTabPage_Impl, DoubleClickHdl, weld::TreeView&, bool)
{
- m_pIndexCB->GetDoubleClickHdl().Call(*m_pIndexCB);
+ aDoubleClickHdl.Call(nullptr);
+ return true;
}
-IMPL_LINK( IndexTabPage_Impl, IdleHdl, Timer*, pIdle, void )
+IMPL_LINK_NOARG(IndexTabPage_Impl, IdleHdl, Timer*, void)
{
- if ( &aFactoryIdle == pIdle )
- InitializeIndex();
+ InitializeIndex();
+}
+
+int IndexTabPage_Impl::starts_with(const OUString& rStr, int nStartRow, bool bCaseSensitive)
+{
+ const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
+
+ int nRet = nStartRow;
+ int nCount = m_xIndexList->n_children();
+ while (nRet < nCount)
+ {
+ OUString aStr(m_xIndexList->get_text(nRet));
+ const bool bMatch = !bCaseSensitive ? rI18nHelper.MatchString(rStr, aStr) : aStr.startsWith(rStr);
+ if (bMatch)
+ return nRet;
+ ++nRet;
+ }
+
+ return -1;
+}
+
+IMPL_LINK_NOARG(IndexTabPage_Impl, AutoCompleteHdl, Timer*, void)
+{
+ OUString aStartText = m_xIndexEntry->get_text();
+ int nStartPos, nEndPos;
+ m_xIndexEntry->get_selection_bounds(nStartPos, nEndPos);
+ int nMaxSelection = std::max(nStartPos, nEndPos);
+ if (nMaxSelection != aStartText.getLength())
+ return;
+
+ int nActive = m_xIndexList->get_selected_index();
+ int nStart = nActive;
+
+ if (nStart == -1)
+ nStart = 0;
+
+ // Try match case insensitive from current position
+ int nPos = starts_with(aStartText, nStart, false);
+ if (nPos == -1 && nStart != 0)
+ {
+ // Try match case insensitive, but from start
+ nPos = starts_with(aStartText, 0, false);
+ }
+
+ if (nPos == -1)
+ {
+ // Try match case sensitive from current position
+ nPos = starts_with(aStartText, nStart, true);
+ if (nPos == -1 && nStart != 0)
+ {
+ // Try match case sensitive, but from start
+ nPos = starts_with(aStartText, 0, true);
+ }
+ }
+
+ if (nPos != -1)
+ {
+ m_xIndexList->set_cursor(nPos);
+ m_xIndexList->select(nPos);
+ OUString aText = m_xIndexList->get_text(nPos);
+ if (aText != aStartText)
+ m_xIndexEntry->set_text(aText);
+ m_xIndexEntry->select_region(aText.getLength(), aStartText.getLength());
+ }
}
IMPL_LINK( IndexTabPage_Impl, TimeoutHdl, Timer*, pTimer, void)
@@ -725,26 +807,23 @@ IMPL_LINK( IndexTabPage_Impl, TimeoutHdl, Timer*, pTimer, void)
aKeywordLink.Call(*this);
}
-void IndexTabPage_Impl::ActivatePage()
+void IndexTabPage_Impl::Activate()
{
if ( !bIsActivated )
{
bIsActivated = true;
aFactoryIdle.Start();
}
-
- if ( !m_pIdxWin->WasCursorLeftOrRight() )
- SetFocusOnBox();
}
-Control* IndexTabPage_Impl::GetLastFocusControl()
+weld::Widget* IndexTabPage_Impl::GetLastFocusControl()
{
- return m_pOpenBtn;
+ return m_xOpenBtn.get();
}
-void IndexTabPage_Impl::SetDoubleClickHdl( const Link<ComboBox&,void>& rLink )
+void IndexTabPage_Impl::SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink)
{
- m_pIndexCB->SetDoubleClickHdl( rLink );
+ aDoubleClickHdl = rLink;
}
void IndexTabPage_Impl::SetFactory( const OUString& rFactory )
@@ -768,22 +847,20 @@ void IndexTabPage_Impl::SetFactory( const OUString& rFactory )
}
}
-
OUString IndexTabPage_Impl::GetSelectedEntry() const
{
OUString aRet;
- IndexEntry_Impl* pEntry = static_cast<IndexEntry_Impl*>(m_pIndexCB->GetEntryData( m_pIndexCB->GetEntryPos( m_pIndexCB->GetText() ) ));
- if ( pEntry )
+ IndexEntry_Impl* pEntry = reinterpret_cast<IndexEntry_Impl*>(m_xIndexList->get_id(m_xIndexList->find_text(m_xIndexEntry->get_text())).toInt64());
+ if (pEntry)
aRet = pEntry->m_aURL;
return aRet;
}
-
void IndexTabPage_Impl::SetKeyword( const OUString& rKeyword )
{
sKeyword = rKeyword;
- if ( m_pIndexCB->GetEntryCount() > 0 )
+ if (m_xIndexList->n_children() > 0)
aKeywordTimer.Start();
else if ( !bIsActivated )
aFactoryIdle.Start();
@@ -795,8 +872,8 @@ bool IndexTabPage_Impl::HasKeyword() const
bool bRet = false;
if ( !sKeyword.isEmpty() )
{
- sal_Int32 nPos = m_pIndexCB->GetEntryPos( sKeyword );
- bRet = ( nPos != LISTBOX_ENTRY_NOTFOUND );
+ sal_Int32 nPos = m_xIndexList->find_text( sKeyword );
+ bRet = nPos != -1;
}
return bRet;
@@ -808,11 +885,11 @@ bool IndexTabPage_Impl::HasKeywordIgnoreCase()
bool bRet = false;
if ( !sKeyword.isEmpty() )
{
- sal_Int32 nEntries = m_pIndexCB->GetEntryCount();
- const vcl::I18nHelper& rI18nHelper = GetSettings().GetLocaleI18nHelper();
+ sal_Int32 nEntries = m_xIndexList->n_children();
+ const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetLocaleI18nHelper();
for ( sal_Int32 n = 0; n < nEntries; n++)
{
- const OUString sIndexItem {m_pIndexCB->GetEntry( n )};
+ const OUString sIndexItem {m_xIndexList->get_text(n)};
if (rI18nHelper.MatchString( sIndexItem, sKeyword ))
{
sKeyword = sIndexItem;
@@ -824,99 +901,43 @@ bool IndexTabPage_Impl::HasKeywordIgnoreCase()
return bRet;
}
-
void IndexTabPage_Impl::OpenKeyword()
{
if ( !sKeyword.isEmpty() )
{
- m_pIndexCB->SetText( sKeyword );
- m_pIndexCB->GetDoubleClickHdl().Call( *m_pIndexCB );
+ m_xIndexEntry->set_text(sKeyword);
+ aDoubleClickHdl.Call(nullptr);
sKeyword.clear();
}
}
-// class SearchBox_Impl --------------------------------------------------
-
-extern "C" SAL_DLLPUBLIC_EXPORT void makeSearchBox(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap &)
-{
- static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>,
- decltype(makeSearchBox)>);
- WinBits nWinBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_DROPDOWN;
- VclPtrInstance<SearchBox_Impl> pComboBox(pParent, nWinBits);
- pComboBox->EnableAutoSize(true);
- rRet = pComboBox;
-}
-
-bool SearchBox_Impl::PreNotify( NotifyEvent& rNEvt )
-{
- bool bHandled = false;
- if ( !IsInDropDown() &&
- rNEvt.GetWindow() == GetSubEdit() &&
- rNEvt.GetType() == MouseNotifyEvent::KEYINPUT &&
- KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
- {
- aSearchLink.Call( nullptr );
- bHandled = true;
- }
- return bHandled || ComboBox::PreNotify( rNEvt );
-}
-
-
-void SearchBox_Impl::Select()
-{
- if ( !IsTravelSelect() )
- aSearchLink.Call( nullptr );
-}
-
-// class SearchResultsBox_Impl -------------------------------------------
-
-extern "C" SAL_DLLPUBLIC_EXPORT void makeSearchResultsBox(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
+IMPL_LINK_NOARG(SearchTabPage_Impl, ActivateHdl, weld::ComboBox&, bool)
{
- static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>,
- decltype(makeSearchResultsBox)>);
- WinBits nWinBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK;
- OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
- if (!sBorder.isEmpty())
- nWinBits |= WB_BORDER;
- VclPtrInstance<SearchResultsBox_Impl> pListBox(pParent, nWinBits);
- pListBox->EnableAutoSize(true);
- rRet = pListBox;
-}
-
-bool SearchResultsBox_Impl::EventNotify( NotifyEvent& rNEvt )
-{
- bool bHandled = false;
- if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT &&
- KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
- {
- GetDoubleClickHdl().Call( *this );
- bHandled = true;
- }
-
- return bHandled || ListBox::EventNotify( rNEvt );
+ Search();
+ return true;
}
// class SearchTabPage_Impl ----------------------------------------------
-SearchTabPage_Impl::SearchTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin)
- : HelpTabPage_Impl(pParent, _pIdxWin, "HelpSearchPage",
+SearchTabPage_Impl::SearchTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* pIdxWin)
+ : HelpTabPage_Impl(pParent, pIdxWin, "HelpSearchPage",
"sfx/ui/helpsearchpage.ui")
+ , m_xSearchED(m_xBuilder->weld_combo_box("search"))
+ , m_xSearchBtn(m_xBuilder->weld_button("find"))
+ , m_xFullWordsCB(m_xBuilder->weld_check_button("completewords"))
+ , m_xScopeCB(m_xBuilder->weld_check_button("headings"))
+ , m_xResultsLB(m_xBuilder->weld_tree_view("results"))
+ , m_xOpenBtn(m_xBuilder->weld_button("display"))
, xBreakIterator(vcl::unohelper::CreateBreakIterator())
{
- get(m_pSearchED, "search");
- get(m_pSearchBtn, "find");
- get(m_pFullWordsCB, "completewords");
- get(m_pScopeCB, "headings");
- get(m_pResultsLB, "results");
- Size aSize(LogicToPixel(Size(128 , 30), MapMode(MapUnit::MapAppFont)));
- m_pResultsLB->set_width_request(aSize.Width());
- m_pResultsLB->set_height_request(aSize.Height());
- get(m_pOpenBtn, "display");
-
- m_pSearchED->SetSearchLink( LINK( this, SearchTabPage_Impl, SearchHdl ) );
- m_pSearchBtn->SetClickHdl(LINK( this, SearchTabPage_Impl, ClickHdl ));
- m_pSearchED->SetModifyHdl( LINK( this, SearchTabPage_Impl, ModifyHdl ) );
- m_pOpenBtn->SetClickHdl( LINK( this, SearchTabPage_Impl, OpenHdl ) );
+ m_xResultsLB->set_size_request(m_xResultsLB->get_approximate_digit_width() * 30,
+ m_xResultsLB->get_height_rows(15));
+
+ m_xSearchBtn->connect_clicked(LINK(this, SearchTabPage_Impl, ClickHdl));
+ m_xSearchED->connect_changed(LINK(this, SearchTabPage_Impl, ModifyHdl));
+ m_xSearchED->connect_entry_activate(LINK(this, SearchTabPage_Impl, ActivateHdl));
+ m_xOpenBtn->connect_clicked(LINK(this, SearchTabPage_Impl, OpenHdl));
+ m_xResultsLB->connect_row_activated(LINK(this, SearchTabPage_Impl, DoubleClickHdl));
SvtViewOptions aViewOpt( EViewType::TabPage, CONFIGNAME_SEARCHPAGE );
if ( aViewOpt.Exists() )
@@ -927,40 +948,35 @@ SearchTabPage_Impl::SearchTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_
{
sal_Int32 nIdx {0};
bool bChecked = aUserData.getToken(0, ';', nIdx).toInt32() == 1;
- m_pFullWordsCB->Check( bChecked );
+ m_xFullWordsCB->set_active(bChecked);
bChecked = aUserData.getToken(0, ';', nIdx).toInt32() == 1;
- m_pScopeCB->Check( bChecked );
+ m_xScopeCB->set_active(bChecked);
while ( nIdx > 0 )
{
- m_pSearchED->InsertEntry( INetURLObject::decode(
+ m_xSearchED->append_text( INetURLObject::decode(
aUserData.getToken(0, ';', nIdx),
INetURLObject::DecodeMechanism::WithCharset ) );
}
}
}
- ModifyHdl(*m_pSearchED);
+ ModifyHdl(*m_xSearchED);
}
SearchTabPage_Impl::~SearchTabPage_Impl()
-{
- disposeOnce();
-}
-
-void SearchTabPage_Impl::dispose()
{
SvtViewOptions aViewOpt( EViewType::TabPage, CONFIGNAME_SEARCHPAGE );
OUStringBuffer aUserData;
- aUserData.append(OUString::number( m_pFullWordsCB->IsChecked() ? 1 : 0 ))
+ aUserData.append(OUString::number(m_xFullWordsCB->get_active() ? 1 : 0))
.append(";")
- .append(OUString::number( m_pScopeCB->IsChecked() ? 1 : 0 ));
- sal_Int32 nCount = std::min( m_pSearchED->GetEntryCount(), sal_Int32(10) ); // save only 10 entries
+ .append(OUString::number( m_xScopeCB->get_active() ? 1 : 0 ));
+ sal_Int32 nCount = std::min(m_xSearchED->get_count(), 10); // save only 10 entries
for ( sal_Int32 i = 0; i < nCount; ++i )
{
aUserData.append(";").append(INetURLObject::encode(
- m_pSearchED->GetEntry(i),
+ m_xSearchED->get_text(i),
INetURLObject::PART_UNO_PARAM_VALUE,
INetURLObject::EncodeMechanism::All ));
}
@@ -968,147 +984,132 @@ void SearchTabPage_Impl::dispose()
Any aUserItem = makeAny( aUserData.makeStringAndClear() );
aViewOpt.SetUserItem( USERITEM_NAME, aUserItem );
- m_pSearchED.clear();
- m_pSearchBtn.clear();
- m_pFullWordsCB.clear();
- m_pScopeCB.clear();
- m_pResultsLB.clear();
- m_pOpenBtn.clear();
- HelpTabPage_Impl::dispose();
+ m_xSearchED.reset();
+ m_xSearchBtn.reset();
+ m_xFullWordsCB.reset();
+ m_xScopeCB.reset();
+ m_xResultsLB.reset();
+ m_xOpenBtn.reset();
}
-
void SearchTabPage_Impl::ClearSearchResults()
{
- const sal_Int32 nCount = m_pResultsLB->GetEntryCount();
- for ( sal_Int32 i = 0; i < nCount; ++i )
- delete static_cast<OUString*>(m_pResultsLB->GetEntryData(i));
- m_pResultsLB->Clear();
- m_pResultsLB->PaintImmediately();
+ m_xResultsLB->clear();
}
-
void SearchTabPage_Impl::RememberSearchText( const OUString& rSearchText )
{
- for ( sal_Int32 i = 0; i < m_pSearchED->GetEntryCount(); ++i )
+ for (sal_Int32 i = 0, nEntryCount = m_xSearchED->get_count(); i < nEntryCount; ++i)
{
- if ( rSearchText == m_pSearchED->GetEntry(i) )
+ if (rSearchText == m_xSearchED->get_text(i))
{
- m_pSearchED->RemoveEntryAt(i);
+ m_xSearchED->remove(i);
break;
}
}
- m_pSearchED->InsertEntry( rSearchText, 0 );
+ m_xSearchED->insert_text(0, rSearchText);
}
-
-IMPL_LINK_NOARG(SearchTabPage_Impl, ClickHdl, Button*, void)
+IMPL_LINK_NOARG(SearchTabPage_Impl, ClickHdl, weld::Button&, void)
{
- SearchHdl(nullptr);
+ Search();
}
-IMPL_LINK_NOARG(SearchTabPage_Impl, SearchHdl, LinkParamNone*, void)
+void SearchTabPage_Impl::Search()
{
- OUString aSearchText = comphelper::string::strip(m_pSearchED->GetText(), ' ');
+ OUString aSearchText = comphelper::string::strip(m_xSearchED->get_active_text(), ' ');
if ( aSearchText.isEmpty() )
return;
- EnterWait();
+ std::unique_ptr<weld::WaitObject> xWaitCursor(new weld::WaitObject(m_pIdxWin->GetFrameWeld()));
ClearSearchResults();
RememberSearchText( aSearchText );
OUStringBuffer aSearchURL(HELP_URL);
aSearchURL.append(aFactory);
aSearchURL.append(HELP_SEARCH_TAG);
- if ( !m_pFullWordsCB->IsChecked() )
+ if (!m_xFullWordsCB->get_active())
aSearchText = sfx2::PrepareSearchString( aSearchText, xBreakIterator, true );
aSearchURL.append(aSearchText);
AppendConfigToken(aSearchURL, false);
- if ( m_pScopeCB->IsChecked() )
+ if (m_xScopeCB->get_active())
aSearchURL.append("&Scope=Heading");
std::vector< OUString > aFactories = SfxContentHelper::GetResultSet(aSearchURL.makeStringAndClear());
for (const OUString & rRow : aFactories)
{
sal_Int32 nIdx = 0;
- OUString aTitle = rRow.getToken( 0, '\t', nIdx );
- OUString* pURL = new OUString( rRow.getToken( 1, '\t', nIdx ) );
- const sal_Int32 nPos = m_pResultsLB->InsertEntry( aTitle );
- m_pResultsLB->SetEntryData( nPos, pURL );
+ OUString aTitle = rRow.getToken(0, '\t', nIdx);
+ OUString sURL(rRow.getToken(1, '\t', nIdx));
+ m_xResultsLB->append(sURL, aTitle);
}
- LeaveWait();
+ xWaitCursor.reset();
if ( aFactories.empty() )
{
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xContainer.get(),
VclMessageType::Info, VclButtonsType::Ok,
SfxResId(STR_INFO_NOSEARCHRESULTS)));
xBox->run();
}
}
-IMPL_LINK_NOARG(SearchTabPage_Impl, OpenHdl, Button*, void)
+IMPL_LINK_NOARG(SearchTabPage_Impl, OpenHdl, weld::Button&, void)
{
- m_pResultsLB->GetDoubleClickHdl().Call(*m_pResultsLB);
+ aDoubleClickHdl.Call(nullptr);
}
-IMPL_LINK_NOARG(SearchTabPage_Impl, ModifyHdl, Edit&, void)
+IMPL_LINK(SearchTabPage_Impl, ModifyHdl, weld::ComboBox&, rComboBox, void)
{
- OUString aSearchText = comphelper::string::strip(m_pSearchED->GetText(), ' ');
- m_pSearchBtn->Enable(!aSearchText.isEmpty());
+ OUString aSearchText = comphelper::string::strip(m_xSearchED->get_active_text(), ' ');
+ m_xSearchBtn->set_sensitive(!aSearchText.isEmpty());
+
+ if (rComboBox.changed_by_direct_pick())
+ Search();
}
-void SearchTabPage_Impl::ActivatePage()
+weld::Widget* SearchTabPage_Impl::GetLastFocusControl()
{
- if ( !m_pIdxWin->WasCursorLeftOrRight() )
- m_pSearchED->GrabFocus();
+ return m_xOpenBtn.get();
}
-Control* SearchTabPage_Impl::GetLastFocusControl()
+IMPL_LINK_NOARG(SearchTabPage_Impl, DoubleClickHdl, weld::TreeView&, bool)
{
- return m_pOpenBtn;
+ aDoubleClickHdl.Call(nullptr);
+ return true;
}
-void SearchTabPage_Impl::SetDoubleClickHdl( const Link<ListBox&,void>& rLink )
+void SearchTabPage_Impl::SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink)
{
- m_pResultsLB->SetDoubleClickHdl( rLink );
+ aDoubleClickHdl = rLink;
}
-
OUString SearchTabPage_Impl::GetSelectedEntry() const
{
- OUString aRet;
- OUString* pData = static_cast<OUString*>(m_pResultsLB->GetSelectedEntryData());
- if ( pData )
- aRet = *pData;
- return aRet;
+ return m_xResultsLB->get_selected_id();
}
-
void SearchTabPage_Impl::ClearPage()
{
ClearSearchResults();
- m_pSearchED->SetText( OUString() );
+ m_xSearchED->set_entry_text(OUString());
}
-
bool SearchTabPage_Impl::OpenKeyword( const OUString& rKeyword )
{
bool bRet = false;
- m_pSearchED->SetText( rKeyword );
- SearchHdl( nullptr );
- if ( m_pResultsLB->GetEntryCount() > 0 )
+ m_xSearchED->set_entry_text(rKeyword);
+ Search();
+ if (m_xResultsLB->n_children() > 0)
{
// found keyword -> open it
- m_pResultsLB->SelectEntryPos(0);
- OpenHdl( nullptr );
+ m_xResultsLB->select(0);
+ OpenHdl(*m_xOpenBtn);
bRet = true;
}
-
return bRet;
}
// class BookmarksTabPage_Impl -------------------------------------------
-
static void GetBookmarkEntry_Impl
(
const Sequence< PropertyValue >& aBookmarkEntry,
@@ -1125,149 +1126,83 @@ static void GetBookmarkEntry_Impl
}
}
-BookmarksBox_Impl::BookmarksBox_Impl(vcl::Window* pParent, WinBits nStyle)
- : ListBox(pParent, nStyle)
-{
-}
-
-extern "C" SAL_DLLPUBLIC_EXPORT void makeBookmarksBox(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
-{
- static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>,
- decltype(makeBookmarksBox)>);
- WinBits nWinBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
- OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
- if (!sBorder.isEmpty())
- nWinBits |= WB_BORDER;
- VclPtrInstance<BookmarksBox_Impl> pListBox(pParent, nWinBits);
- pListBox->EnableAutoSize(true);
- rRet = pListBox;
-}
-
-BookmarksBox_Impl::~BookmarksBox_Impl()
-{
- disposeOnce();
-}
-
-void BookmarksBox_Impl::dispose()
-{
- // save bookmarks to configuration
- SvtHistoryOptions aHistOpt;
- aHistOpt.Clear( eHELPBOOKMARKS );
- const sal_Int32 nCount = GetEntryCount();
- for ( sal_Int32 i = 0; i < nCount; ++i )
- {
- OUString* pURL = static_cast<OUString*>(GetEntryData(i));
- aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, "", GetEntry(i), std::nullopt);
- delete pURL;
- }
- ListBox::dispose();
-}
-
-
-void BookmarksBox_Impl::DoAction( sal_uInt16 nAction )
+void BookmarksTabPage_Impl::DoAction(const OString& rAction)
{
- switch ( nAction )
+ if (rAction == "display")
+ aDoubleClickHdl.Call(nullptr);
+ else if (rAction == "rename")
{
- case MID_OPEN :
- GetDoubleClickHdl().Call( *this );
- break;
-
- case MID_RENAME :
- {
- sal_Int32 nPos = GetSelectedEntryPos();
- if ( nPos != LISTBOX_ENTRY_NOTFOUND )
+ sal_Int32 nPos = m_xBookmarksBox->get_selected_index();
+ if (nPos != -1)
+ {
+ SfxAddHelpBookmarkDialog_Impl aDlg(m_xBookmarksBox.get(), true);
+ aDlg.SetTitle(m_xBookmarksBox->get_text(nPos));
+ if (aDlg.run() == RET_OK)
{
- SfxAddHelpBookmarkDialog_Impl aDlg(GetFrameWeld(), true);
- aDlg.SetTitle(GetEntry(nPos));
- if (aDlg.run() == RET_OK)
- {
- OUString* pURL = static_cast<OUString*>(GetEntryData( nPos ));
- RemoveEntry( nPos );
- nPos = InsertEntry( aDlg.GetTitle(), SvFileInformationManager::GetImage( INetURLObject(IMAGE_URL+INetURLObject( *pURL ).GetHost()) ) );
- SetEntryData( nPos, new OUString( *pURL ) );
- SelectEntryPos( nPos );
- delete pURL;
- }
+ OUString sURL = m_xBookmarksBox->get_id(nPos);
+ m_xBookmarksBox->remove(nPos);
+ m_xBookmarksBox->append(sURL, aDlg.GetTitle(), SvFileInformationManager::GetImageId(INetURLObject(IMAGE_URL+INetURLObject(sURL).GetHost())));
+ m_xBookmarksBox->select(m_xBookmarksBox->n_children() - 1);
}
- break;
}
-
- case MID_DELETE :
+ }
+ else if (rAction == "delete")
+ {
+ sal_Int32 nPos = m_xBookmarksBox->get_selected_index();
+ if (nPos != -1)
{
- sal_Int32 nPos = GetSelectedEntryPos();
- if ( nPos != LISTBOX_ENTRY_NOTFOUND )
+ m_xBookmarksBox->remove(nPos);
+ const sal_Int32 nCount = m_xBookmarksBox->n_children();
+ if (nCount)
{
- RemoveEntry( nPos );
- const sal_Int32 nCount = GetEntryCount();
- if ( nCount )
- {
- if ( nPos >= nCount )
- nPos = nCount - 1;
- SelectEntryPos( nPos );
- }
+ if (nPos >= nCount)
+ nPos = nCount - 1;
+ m_xBookmarksBox->select(nPos);
}
- break;
}
}
}
+IMPL_LINK(BookmarksTabPage_Impl, CommandHdl, const CommandEvent&, rCEvt, bool)
+{
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+ return false;
+
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xBookmarksBox.get(), "sfx/ui/bookmarkmenu.ui"));
+ std::unique_ptr<weld::Menu> xMenu = xBuilder->weld_menu("menu");
+
+ OString sIdent = xMenu->popup_at_rect(m_xBookmarksBox.get(), ::tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)));
+ if (!sIdent.isEmpty())
+ DoAction(sIdent);
+ return true;
+}
-bool BookmarksBox_Impl::EventNotify( NotifyEvent& rNEvt )
+IMPL_LINK(BookmarksTabPage_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
{
- bool bRet = false;
- MouseNotifyEvent nType = rNEvt.GetType();
- if ( MouseNotifyEvent::KEYINPUT == nType )
- {
- sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
- if ( KEY_DELETE == nCode && GetEntryCount() > 0 )
- {
- DoAction( MID_DELETE );
- bRet = true;
- }
- else if ( KEY_RETURN == nCode )
- {
- GetDoubleClickHdl().Call( *this );
- bRet = true;
- }
- }
- else if ( MouseNotifyEvent::COMMAND == nType )
- {
- const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
- if ( pCEvt->GetCommand() == CommandEventId::ContextMenu )
- {
- VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "sfx/ui/bookmarkmenu.ui", "");
- VclPtr<PopupMenu> aMenu(aBuilder.get_menu("menu"));
- sal_uInt16 nId = aMenu->Execute(this, pCEvt->GetMousePosPixel());
- if (nId != MENU_ITEM_NOTFOUND)
- {
- OString sIdent = aMenu->GetCurItemIdent();
- if (sIdent == "display")
- DoAction(MID_OPEN);
- else if (sIdent == "rename")
- DoAction(MID_RENAME);
- else if (sIdent == "delete")
- DoAction(MID_DELETE);
- }
- bRet = true;
- }
+ bool bHandled = false;
+ sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+ if (KEY_DELETE == nCode && m_xBookmarksBox->n_children() > 0)
+ {
+ DoAction("delete");
+ bHandled = true;
}
-
- return bRet || ListBox::EventNotify( rNEvt );
+ return bHandled;
}
// class BookmarksTabPage_Impl -------------------------------------------
-
-BookmarksTabPage_Impl::BookmarksTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin)
+BookmarksTabPage_Impl::BookmarksTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* _pIdxWin)
: HelpTabPage_Impl(pParent, _pIdxWin, "HelpBookmarkPage",
"sfx/ui/helpbookmarkpage.ui")
+ , m_xBookmarksBox(m_xBuilder->weld_tree_view("bookmarks"))
+ , m_xBookmarksPB(m_xBuilder->weld_button("display"))
{
- get(m_pBookmarksPB, "display");
- get(m_pBookmarksBox, "bookmarks");
- Size aSize(LogicToPixel(Size(120 , 200), MapMode(MapUnit::MapAppFont)));
- m_pBookmarksBox->set_width_request(aSize.Width());
- m_pBookmarksBox->set_height_request(aSize.Height());
+ m_xBookmarksBox->set_size_request(m_xBookmarksBox->get_approximate_digit_width() * 30,
+ m_xBookmarksBox->get_height_rows(20));
- m_pBookmarksPB->SetClickHdl( LINK( this, BookmarksTabPage_Impl, OpenHdl ) );
+ m_xBookmarksPB->connect_clicked( LINK(this, BookmarksTabPage_Impl, OpenHdl));
+ m_xBookmarksBox->connect_row_activated(LINK(this, BookmarksTabPage_Impl, DoubleClickHdl));
+ m_xBookmarksBox->connect_popup_menu(LINK(this, BookmarksTabPage_Impl, CommandHdl));
+ m_xBookmarksBox->connect_key_press(LINK(this, BookmarksTabPage_Impl, KeyInputHdl));
// load bookmarks from configuration
const Sequence< Sequence< PropertyValue > > aBookmarkSeq = SvtHistoryOptions().GetList( eHELPBOOKMARKS );
@@ -1284,53 +1219,47 @@ BookmarksTabPage_Impl::BookmarksTabPage_Impl(vcl::Window* pParent, SfxHelpIndexW
BookmarksTabPage_Impl::~BookmarksTabPage_Impl()
{
- disposeOnce();
-}
+ // save bookmarks to configuration
+ SvtHistoryOptions aHistOpt;
+ aHistOpt.Clear( eHELPBOOKMARKS );
+ const sal_Int32 nCount = m_xBookmarksBox->n_children();
+ for (sal_Int32 i = 0; i < nCount; ++i)
+ aHistOpt.AppendItem(eHELPBOOKMARKS, m_xBookmarksBox->get_id(i), "", m_xBookmarksBox->get_text(i), std::nullopt);
-void BookmarksTabPage_Impl::dispose()
-{
- m_pBookmarksBox.clear();
- m_pBookmarksPB.clear();
- HelpTabPage_Impl::dispose();
+ m_xBookmarksBox.reset();
+ m_xBookmarksPB.reset();
}
-
-IMPL_LINK_NOARG(BookmarksTabPage_Impl, OpenHdl, Button*, void)
+IMPL_LINK_NOARG(BookmarksTabPage_Impl, OpenHdl, weld::Button&, void)
{
- m_pBookmarksBox->GetDoubleClickHdl().Call(*m_pBookmarksBox);
+ aDoubleClickHdl.Call(nullptr);
}
-void BookmarksTabPage_Impl::ActivatePage()
+weld::Widget* BookmarksTabPage_Impl::GetLastFocusControl()
{
- if ( !m_pIdxWin->WasCursorLeftOrRight() )
- SetFocusOnBox();
+ return m_xBookmarksPB.get();
}
-Control* BookmarksTabPage_Impl::GetLastFocusControl()
+IMPL_LINK_NOARG(BookmarksTabPage_Impl, DoubleClickHdl, weld::TreeView&, bool)
{
- return m_pBookmarksPB;
+ aDoubleClickHdl.Call(nullptr);
+ return true;
}
-void BookmarksTabPage_Impl::SetDoubleClickHdl( const Link<ListBox&,void>& rLink )
+void BookmarksTabPage_Impl::SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink)
{
- m_pBookmarksBox->SetDoubleClickHdl(rLink);
+ aDoubleClickHdl = rLink;
}
OUString BookmarksTabPage_Impl::GetSelectedEntry() const
{
- OUString aRet;
- OUString* pData = static_cast<OUString*>(m_pBookmarksBox->GetSelectedEntryData());
- if ( pData )
- aRet = *pData;
- return aRet;
+ return m_xBookmarksBox->get_selected_id();
}
-
-void BookmarksTabPage_Impl::AddBookmarks( const OUString& rTitle, const OUString& rURL )
+void BookmarksTabPage_Impl::AddBookmarks(const OUString& rTitle, const OUString& rURL)
{
- const OUString aImageURL {IMAGE_URL + INetURLObject( rURL ).GetHost()};
- const sal_Int32 nPos = m_pBookmarksBox->InsertEntry( rTitle, SvFileInformationManager::GetImage( INetURLObject(aImageURL) ) );
- m_pBookmarksBox->SetEntryData( nPos, new OUString( rURL ) );
+ const OUString aImageURL {IMAGE_URL + INetURLObject(rURL).GetHost()};
+ m_xBookmarksBox->append(rURL, rTitle, SvFileInformationManager::GetImageId(INetURLObject(aImageURL)));
}
OUString SfxHelpWindow_Impl::buildHelpURL(const OUString& sFactory ,
@@ -1395,69 +1324,54 @@ void SfxHelpWindow_Impl::loadHelpContent(const OUString& sHelpURL, bool bAddToHi
LeaveWait();
}
-SfxHelpIndexWindow_Impl::SfxHelpIndexWindow_Impl(SfxHelpWindow_Impl* _pParent)
- : Window(_pParent, 0)
+IMPL_LINK(SfxHelpIndexWindow_Impl, ActivatePageHdl, const OString&, rPage, void)
+{
+ GetPage(rPage)->Activate();
+}
+
+SfxHelpIndexWindow_Impl::SfxHelpIndexWindow_Impl(SfxHelpWindow_Impl* _pParent, weld::Container* pContainer)
+ : m_xBuilder(Application::CreateBuilder(pContainer, "sfx/ui/helpcontrol.ui"))
+ , m_xContainer(m_xBuilder->weld_container("HelpControl"))
+ , m_xActiveLB(m_xBuilder->weld_combo_box("active"))
+ , m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
, aIdle("sfx2 appl SfxHelpIndexWindow_Impl")
, aIndexKeywordLink(LINK(this, SfxHelpIndexWindow_Impl, KeywordHdl))
, pParentWin(_pParent)
- , pCPage(nullptr)
- , pIPage(nullptr)
- , pSPage(nullptr)
- , pBPage(nullptr)
- , bWasCursorLeftOrRight(false)
, bIsInitDone(false)
{
- m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), "sfx/ui/helpcontrol.ui", "HelpControl"));
- get(m_pActiveLB, "active");
- get(m_pTabCtrl, "tabcontrol");
-
- sfx2::AddToTaskPaneList( this );
-
- m_pTabCtrl->SetActivatePageHdl( LINK( this, SfxHelpIndexWindow_Impl, ActivatePageHdl ) );
+ // create the pages
+ GetContentPage();
+ GetIndexPage();
+ GetSearchPage();
+ GetBookmarksPage();
OString sPageId("index");
SvtViewOptions aViewOpt( EViewType::TabDialog, CONFIGNAME_INDEXWIN );
if ( aViewOpt.Exists() )
sPageId = aViewOpt.GetPageID();
- m_pTabCtrl->SetCurPageId(m_pTabCtrl->GetPageId(sPageId));
- ActivatePageHdl( m_pTabCtrl );
- m_pActiveLB->SetSelectHdl( LINK( this, SfxHelpIndexWindow_Impl, SelectHdl ) );
+ m_xTabCtrl->set_current_page(sPageId);
+ ActivatePageHdl(sPageId);
+ m_xActiveLB->connect_changed(LINK(this, SfxHelpIndexWindow_Impl, SelectHdl));
+
+ m_xTabCtrl->connect_enter_page(LINK(this, SfxHelpIndexWindow_Impl, ActivatePageHdl));
aIdle.SetInvokeHandler( LINK( this, SfxHelpIndexWindow_Impl, InitHdl ) );
aIdle.Start();
- Show();
+ m_xContainer->show();
}
-
SfxHelpIndexWindow_Impl::~SfxHelpIndexWindow_Impl()
{
- disposeOnce();
-}
-
-void SfxHelpIndexWindow_Impl::dispose()
-{
- sfx2::RemoveFromTaskPaneList( this );
-
- pCPage.disposeAndClear();
- pIPage.disposeAndClear();
- pSPage.disposeAndClear();
- pBPage.disposeAndClear();
+ SvtViewOptions aViewOpt(EViewType::TabDialog, CONFIGNAME_INDEXWIN);
+ aViewOpt.SetPageID(m_xTabCtrl->get_current_page_ident());
- for ( sal_Int32 i = 0; i < m_pActiveLB->GetEntryCount(); ++i )
- delete static_cast<OUString*>(m_pActiveLB->GetEntryData(i));
-
- SvtViewOptions aViewOpt( EViewType::TabDialog, CONFIGNAME_INDEXWIN );
- aViewOpt.SetPageID(m_pTabCtrl->GetPageName(m_pTabCtrl->GetCurPageId()));
-
- disposeBuilder();
- m_pActiveLB.clear();
- m_pTabCtrl.clear();
- pParentWin.clear();
- vcl::Window::dispose();
+ xCPage.reset();
+ xIPage.reset();
+ xSPage.reset();
+ xBPage.reset();
}
-
void SfxHelpIndexWindow_Impl::Initialize()
{
OUStringBuffer aHelpURL(HELP_URL);
@@ -1468,79 +1382,64 @@ void SfxHelpIndexWindow_Impl::Initialize()
sal_Int32 nIdx = 0;
OUString aTitle = rRow.getToken( 0, '\t', nIdx ); // token 0
OUString aURL = rRow.getToken( 1, '\t', nIdx ); // token 2
- OUString* pFactory = new OUString( INetURLObject( aURL ).GetHost() );
- const sal_Int32 nPos = m_pActiveLB->InsertEntry( aTitle );
- m_pActiveLB->SetEntryData( nPos, pFactory );
+ OUString aFactory(INetURLObject(aURL).GetHost());
+ m_xActiveLB->append(aFactory, aTitle);
}
- m_pActiveLB->SetDropDownLineCount( static_cast<sal_uInt16>(aFactories.size()) );
- if ( m_pActiveLB->GetSelectedEntryPos() == LISTBOX_ENTRY_NOTFOUND )
+ if (m_xActiveLB->get_active() == -1)
SetActiveFactory();
}
-
void SfxHelpIndexWindow_Impl::SetActiveFactory()
{
- DBG_ASSERT( pIPage, "index page not initialized" );
- if ( !bIsInitDone && !m_pActiveLB->GetEntryCount() )
+ DBG_ASSERT( xIPage, "index page not initialized" );
+ if (!bIsInitDone && !m_xActiveLB->get_count())
{
aIdle.Stop();
InitHdl( nullptr );
}
- for ( sal_Int32 i = 0; i < m_pActiveLB->GetEntryCount(); ++i )
+ for (sal_Int32 i = 0, nEntryCount = m_xActiveLB->get_count(); i < nEntryCount; ++i)
{
- OUString* pFactory = static_cast<OUString*>(m_pActiveLB->GetEntryData(i));
- *pFactory = pFactory->toAsciiLowerCase();
- if ( *pFactory == pIPage->GetFactory() )
+ OUString aFactory = m_xActiveLB->get_id(i);
+ aFactory = aFactory.toAsciiLowerCase();
+ if (aFactory == xIPage->GetFactory())
{
- if ( m_pActiveLB->GetSelectedEntryPos() != i )
+ if (m_xActiveLB->get_active() != i)
{
- m_pActiveLB->SelectEntryPos(i);
- aSelectFactoryLink.Call( nullptr );
+ m_xActiveLB->set_active(i);
+ aSelectFactoryLink.Call(nullptr);
}
break;
}
}
}
-
-HelpTabPage_Impl* SfxHelpIndexWindow_Impl::GetCurrentPage( sal_uInt16& rCurId )
+HelpTabPage_Impl* SfxHelpIndexWindow_Impl::GetPage(const OString& rName)
{
- rCurId = m_pTabCtrl->GetCurPageId();
HelpTabPage_Impl* pPage = nullptr;
- OString sName(m_pTabCtrl->GetPageName(rCurId));
-
- if (sName == "contents")
- {
+ if (rName == "contents")
pPage = GetContentPage();
- }
- else if (sName == "index")
- {
+ else if (rName == "index")
pPage = GetIndexPage();
- }
- else if (sName == "find")
- {
+ else if (rName == "find")
pPage = GetSearchPage();
- }
- else if (sName == "bookmarks")
- {
+ else if (rName == "bookmarks")
pPage = GetBookmarksPage();
- }
- DBG_ASSERT( pPage, "SfxHelpIndexWindow_Impl::GetCurrentPage(): no current page" );
+ assert(pPage && "SfxHelpIndexWindow_Impl::GetCurrentPage(): no current page");
+
return pPage;
}
-IMPL_LINK( SfxHelpIndexWindow_Impl, ActivatePageHdl, TabControl *, pTabCtrl, void )
+HelpTabPage_Impl* SfxHelpIndexWindow_Impl::GetCurrentPage()
{
- sal_uInt16 nId = 0;
- TabPage* pPage = GetCurrentPage( nId );
- pTabCtrl->SetTabPage( nId, pPage );
+ OString sName(m_xTabCtrl->get_current_page_ident());
+ return GetPage(sName);
}
-IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, SelectHdl, ListBox&, void)
+IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, SelectHdl, weld::ComboBox&, void)
{
aIdle.Start();
}
@@ -1557,139 +1456,53 @@ IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, InitHdl, Timer *, void)
IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, SelectFactoryHdl, Timer *, void)
{
- OUString* pFactory = static_cast<OUString*>(m_pActiveLB->GetSelectedEntryData());
- if ( pFactory )
+ OUString aFactory = m_xActiveLB->get_active_id();
+ if (!aFactory.isEmpty())
{
- SetFactory( pFactory->toAsciiLowerCase(), false );
- aSelectFactoryLink.Call( this );
+ SetFactory(aFactory.toAsciiLowerCase(), false);
+ aSelectFactoryLink.Call(this);
}
}
IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, KeywordHdl, IndexTabPage_Impl&, void)
{
// keyword found on index?
- bool bIndex = pIPage->HasKeyword();
+ bool bIndex = xIPage->HasKeyword();
if( !bIndex)
- bIndex = pIPage->HasKeywordIgnoreCase();
+ bIndex = xIPage->HasKeywordIgnoreCase();
// then set index or search page as current.
- sal_uInt16 nPageId = bIndex ? m_pTabCtrl->GetPageId("index") : m_pTabCtrl->GetPageId("find");
- if ( nPageId != m_pTabCtrl->GetCurPageId() )
- {
- m_pTabCtrl->SetCurPageId( nPageId );
- ActivatePageHdl( m_pTabCtrl );
- }
+ OString sPageId = bIndex ? "index" : "find";
+ if (sPageId != m_xTabCtrl->get_current_page_ident())
+ m_xTabCtrl->set_current_page(sPageId);
// at last we open the keyword
if ( bIndex )
- pIPage->OpenKeyword();
- else if ( !pSPage->OpenKeyword( sKeyword ) )
+ xIPage->OpenKeyword();
+ else if ( !xSPage->OpenKeyword( sKeyword ) )
pParentWin->ShowStartPage();
}
-IMPL_LINK(SfxHelpIndexWindow_Impl, IndexTabPageDoubleClickHdl, ComboBox&, rBox, void)
-{
- aPageDoubleClickLink.Call(&rBox);
-}
-
-void SfxHelpIndexWindow_Impl::Resize()
-{
- vcl::Window *pChild = GetWindow(GetWindowType::FirstChild);
- if (!pChild)
- return;
- VclContainer::setLayoutAllocation(*pChild, Point(0,0), GetSizePixel());
-}
-
-Size SfxHelpIndexWindow_Impl::GetOptimalSize() const
-{
- const vcl::Window *pChild = GetWindow(GetWindowType::FirstChild);
- if (!pChild)
- return Window::GetOptimalSize();
- return VclContainer::getLayoutRequisition(*pChild);
-}
-
-bool SfxHelpIndexWindow_Impl::PreNotify(NotifyEvent& rNEvt)
-{
- bool bDone = false;
- MouseNotifyEvent nType = rNEvt.GetType();
- if ( MouseNotifyEvent::KEYINPUT == nType && rNEvt.GetKeyEvent() )
- {
- const vcl::KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
- sal_uInt16 nCode = rKeyCode.GetCode();
-
- if ( KEY_TAB == nCode )
- {
- // don't exit index pane with <TAB>
- sal_uInt16 nPageId = 0;
- HelpTabPage_Impl* pCurPage = GetCurrentPage( nPageId );
- Control* pControl = pCurPage->GetLastFocusControl();
- bool bShift = rKeyCode.IsShift();
- bool bCtrl = rKeyCode.IsMod1();
- if ( !bCtrl && bShift && m_pActiveLB->HasChildPathFocus() )
- {
- pControl->GrabFocus();
- bDone = true;
- }
- else if ( !bCtrl && !bShift && pControl->HasChildPathFocus() )
- {
- m_pActiveLB->GrabFocus();
- bDone = true;
- }
- else if ( bCtrl )
- {
- sal_uInt16 nPagePos = m_pTabCtrl->GetPagePos(nPageId);
- sal_uInt16 nPageCount = m_pTabCtrl->GetPageCount();
-
- ++nPageId;
- // <CTRL><TAB> moves through the pages
- if (nPagePos >= nPageCount)
- nPagePos = 0;
-
- m_pTabCtrl->SetCurPageId(m_pTabCtrl->GetPageId(nPagePos));
- ActivatePageHdl( m_pTabCtrl );
- bDone = true;
- }
- }
- else if ( m_pTabCtrl->HasFocus() && ( KEY_LEFT == nCode || KEY_RIGHT == nCode ) )
- {
- bWasCursorLeftOrRight = true;
- }
- }
-
- return bDone || Window::PreNotify( rNEvt );
-}
-
-
-void SfxHelpIndexWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
+IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, IndexTabPageDoubleClickHdl, LinkParamNone*, void)
{
- Window::DataChanged( rDCEvt );
-
- if ( ( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) ||
- ( rDCEvt.GetType() == DataChangedEventType::DISPLAY ) ) &&
- ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) )
- {
- SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFaceColor() ) );
- }
+ aPageDoubleClickLink.Call(nullptr);
}
-
-void SfxHelpIndexWindow_Impl::SetDoubleClickHdl( const Link<Control*,bool>& rLink )
+void SfxHelpIndexWindow_Impl::SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink)
{
aPageDoubleClickLink = rLink;
}
-IMPL_LINK(SfxHelpIndexWindow_Impl, ContentTabPageDoubleClickHdl, SvTreeListBox*, p, bool)
+IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, ContentTabPageDoubleClickHdl, LinkParamNone*, void)
{
- aPageDoubleClickLink.Call(p);
- return true;
+ aPageDoubleClickLink.Call(nullptr);
}
-IMPL_LINK(SfxHelpIndexWindow_Impl, TabPageDoubleClickHdl, ListBox&, r, void)
+IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, TabPageDoubleClickHdl, LinkParamNone*, void)
{
- aPageDoubleClickLink.Call(&r);
+ aPageDoubleClickLink.Call(nullptr);
}
-
void SfxHelpIndexWindow_Impl::SetFactory( const OUString& rFactory, bool bActive )
{
if ( !rFactory.isEmpty() )
@@ -1707,23 +1520,23 @@ OUString SfxHelpIndexWindow_Impl::GetSelectedEntry() const
{
OUString sRet;
- OString sName(m_pTabCtrl->GetPageName(m_pTabCtrl->GetCurPageId()));
+ OString sName(m_xTabCtrl->get_current_page_ident());
if (sName == "contents")
{
- sRet = pCPage->GetSelectedEntry();
+ sRet = xCPage->GetSelectedEntry();
}
else if (sName == "index")
{
- sRet = pIPage->GetSelectedEntry();
+ sRet = xIPage->GetSelectedEntry();
}
else if (sName == "find")
{
- sRet = pSPage->GetSelectedEntry();
+ sRet = xSPage->GetSelectedEntry();
}
else if (sName == "bookmarks")
{
- sRet = pBPage->GetSelectedEntry();
+ sRet = xBPage->GetSelectedEntry();
}
return sRet;
@@ -1734,14 +1547,13 @@ void SfxHelpIndexWindow_Impl::AddBookmarks( const OUString& rTitle, const OUStri
GetBookmarksPage()->AddBookmarks( rTitle, rURL );
}
-
bool SfxHelpIndexWindow_Impl::IsValidFactory( const OUString& _rFactory )
{
bool bValid = false;
- for ( sal_Int32 i = 0; i < m_pActiveLB->GetEntryCount(); ++i )
+ for (sal_Int32 i = 0, nEntryCount = m_xActiveLB->get_count(); i < nEntryCount; ++i)
{
- OUString* pFactory = static_cast<OUString*>(m_pActiveLB->GetEntryData(i));
- if ( *pFactory == _rFactory )
+ OUString aFactory = m_xActiveLB->get_id(i);
+ if (aFactory == _rFactory)
{
bValid = true;
break;
@@ -1750,73 +1562,75 @@ bool SfxHelpIndexWindow_Impl::IsValidFactory( const OUString& _rFactory )
return bValid;
}
-
void SfxHelpIndexWindow_Impl::ClearSearchPage()
{
- if ( pSPage )
- pSPage->ClearPage();
+ if ( xSPage )
+ xSPage->ClearPage();
}
void SfxHelpIndexWindow_Impl::GrabFocusBack()
{
- OString sName(m_pTabCtrl->GetPageName(m_pTabCtrl->GetCurPageId()));
+ OString sName(m_xTabCtrl->get_current_page_ident());
- if (sName == "contents" && pCPage)
- pCPage->SetFocusOnBox();
- else if (sName == "index" && pIPage)
- pIPage->SetFocusOnBox();
- else if (sName == "find" && pSPage)
- pSPage->SetFocusOnBox();
- else if (sName == "bookmarks" && pBPage)
- pBPage->SetFocusOnBox();
+ if (sName == "contents" && xCPage)
+ xCPage->SetFocusOnBox();
+ else if (sName == "index" && xIPage)
+ xIPage->SetFocusOnBox();
+ else if (sName == "find" && xSPage)
+ xSPage->SetFocusOnBox();
+ else if (sName == "bookmarks" && xBPage)
+ xBPage->SetFocusOnBox();
}
bool SfxHelpIndexWindow_Impl::HasFocusOnEdit() const
{
bool bRet = false;
- OString sName(m_pTabCtrl->GetPageName(m_pTabCtrl->GetCurPageId()));
- if (sName == "index" && pIPage)
- bRet = pIPage->HasFocusOnEdit();
- else if (sName == "find" && pSPage)
- bRet = pSPage->HasFocusOnEdit();
+ OString sName(m_xTabCtrl->get_current_page_ident());
+ if (sName == "index" && xIPage)
+ bRet = xIPage->HasFocusOnEdit();
+ else if (sName == "find" && xSPage)
+ bRet = xSPage->HasFocusOnEdit();
return bRet;
}
-
OUString SfxHelpIndexWindow_Impl::GetSearchText() const
{
OUString sRet;
- OString sName(m_pTabCtrl->GetPageName(m_pTabCtrl->GetCurPageId()));
- if (sName == "find" && pSPage)
- sRet = pSPage->GetSearchText();
+ OString sName(m_xTabCtrl->get_current_page_ident());
+ if (sName == "find" && xSPage)
+ sRet = xSPage->GetSearchText();
return sRet;
}
bool SfxHelpIndexWindow_Impl::IsFullWordSearch() const
{
bool bRet = false;
- OString sName(m_pTabCtrl->GetPageName(m_pTabCtrl->GetCurPageId()));
- if (sName == "find" && pSPage)
- bRet = pSPage->IsFullWordSearch();
+ OString sName(m_xTabCtrl->get_current_page_ident());
+ if (sName == "find" && xSPage)
+ bRet = xSPage->IsFullWordSearch();
return bRet;
}
void SfxHelpIndexWindow_Impl::OpenKeyword( const OUString& rKeyword )
{
sKeyword = rKeyword;
- DBG_ASSERT( pIPage, "invalid index page" );
- pIPage->SetKeyword( sKeyword );
+ DBG_ASSERT( xIPage, "invalid index page" );
+ xIPage->SetKeyword( sKeyword );
}
void SfxHelpIndexWindow_Impl::SelectExecutableEntry()
{
- OString sName(m_pTabCtrl->GetPageName(m_pTabCtrl->GetCurPageId()));
- if (sName == "index" && pIPage )
- pIPage->SelectExecutableEntry();
+ OString sName(m_xTabCtrl->get_current_page_ident());
+ if (sName == "index" && xIPage )
+ xIPage->SelectExecutableEntry();
}
-// class TextWin_Impl ----------------------------------------------------
+weld::Window* SfxHelpIndexWindow_Impl::GetFrameWeld() const
+{
+ return pParentWin->GetFrameWeld();
+}
+// class TextWin_Impl ----------------------------------------------------
TextWin_Impl::TextWin_Impl( vcl::Window* p ) : DockingWindow( p, 0 )
{
}
@@ -1838,58 +1652,45 @@ static void lcl_disableLayoutOfFrame(const Reference< XFrame2 >& xFrame)
// class SfxHelpTextWindow_Impl ------------------------------------------
-SfxHelpTextWindow_Impl::SfxHelpTextWindow_Impl( SfxHelpWindow_Impl* pParent ) :
+SfxHelpTextWindow_Impl::SfxHelpTextWindow_Impl(SfxHelpWindow_Impl* pHelpWin, weld::Builder& rBuilder, vcl::Window* pParent) :
Window( pParent, WB_CLIPCHILDREN | WB_TABSTOP | WB_DIALOGCONTROL ),
- aToolBox ( VclPtr<ToolBox>::Create(this, 0) ),
- aOnStartupCB ( VclPtr<CheckBox>::Create(this, WB_HIDE | WB_TABSTOP) ),
+ xToolBox ( rBuilder.weld_toolbar("toolbar") ),
+ xOnStartupCB ( rBuilder.weld_check_button("checkbutton") ),
+ xMenu ( rBuilder.weld_menu("menu") ),
aSelectIdle ( "sfx2 appl SfxHelpTextWindow_Impl Select" ),
- aIndexOnImage (StockImage::Yes, BMP_HELP_TOOLBOX_INDEX_ON),
- aIndexOffImage (StockImage::Yes, BMP_HELP_TOOLBOX_INDEX_OFF),
+ aIndexOnImage ( BMP_HELP_TOOLBOX_INDEX_ON ),
+ aIndexOffImage ( BMP_HELP_TOOLBOX_INDEX_OFF ),
aIndexOnText ( SfxResId( STR_HELP_BUTTON_INDEX_ON ) ),
aIndexOffText ( SfxResId( STR_HELP_BUTTON_INDEX_OFF ) ),
aOnStartupText ( SfxResId( RID_HELP_ONSTARTUP_TEXT ) ),
- pHelpWin ( pParent ),
+ xHelpWin ( pHelpWin ),
pTextWin ( VclPtr<TextWin_Impl>::Create( this ) ),
- nMinPos ( 0 ),
bIsDebug ( false ),
bIsIndexOn ( false ),
bIsInClose ( false ),
bIsFullWordSearch ( false )
{
- aOnStartupCB->SetSizePixel(aOnStartupCB->PixelToLogic(Size(200, 10), MapMode(MapUnit::MapAppFont)));
-
- sfx2::AddToTaskPaneList( aToolBox.get() );
-
xFrame = Frame::create( ::comphelper::getProcessComponentContext() );
xFrame->initialize( VCLUnoHelper::GetInterface ( pTextWin ) );
xFrame->setName( "OFFICE_HELP" );
lcl_disableLayoutOfFrame(xFrame);
- aToolBox->SetHelpId( HID_HELP_TOOLBOX );
-
- aToolBox->InsertItem( TBI_INDEX, aIndexOffText );
- aToolBox->SetHelpId( TBI_INDEX, HID_HELP_TOOLBOXITEM_INDEX );
- aToolBox->InsertSeparator();
- aToolBox->InsertItem( TBI_BACKWARD, SfxResId( STR_HELP_BUTTON_PREV ) );
- aToolBox->SetHelpId( TBI_BACKWARD, HID_HELP_TOOLBOXITEM_BACKWARD );
- aToolBox->InsertItem( TBI_FORWARD, SfxResId( STR_HELP_BUTTON_NEXT ) );
- aToolBox->SetHelpId( TBI_FORWARD, HID_HELP_TOOLBOXITEM_FORWARD );
- aToolBox->InsertItem( TBI_START, SfxResId( STR_HELP_BUTTON_START ) );
- aToolBox->SetHelpId( TBI_START, HID_HELP_TOOLBOXITEM_START );
- aToolBox->InsertSeparator();
- aToolBox->InsertItem( TBI_PRINT, SfxResId( STR_HELP_BUTTON_PRINT ) );
- aToolBox->SetHelpId( TBI_PRINT, HID_HELP_TOOLBOXITEM_PRINT );
- aToolBox->InsertItem( TBI_BOOKMARKS, SfxResId( STR_HELP_BUTTON_ADDBOOKMARK ) );
- aToolBox->SetHelpId( TBI_BOOKMARKS, HID_HELP_TOOLBOXITEM_BOOKMARKS );
- aToolBox->InsertItem( TBI_SEARCHDIALOG, SfxResId( STR_HELP_BUTTON_SEARCHDIALOG ) );
- aToolBox->SetHelpId( TBI_SEARCHDIALOG, HID_HELP_TOOLBOXITEM_SEARCHDIALOG );
+ xToolBox->set_help_id(HID_HELP_TOOLBOX);
+
+ xToolBox->set_item_tooltip_text("index", aIndexOffText );
+ xToolBox->set_item_help_id("index", HID_HELP_TOOLBOXITEM_INDEX);
+ xToolBox->set_item_help_id("backward", HID_HELP_TOOLBOXITEM_BACKWARD);
+ xToolBox->set_item_help_id("forward", HID_HELP_TOOLBOXITEM_FORWARD);
+ xToolBox->set_item_help_id("start", HID_HELP_TOOLBOXITEM_START);
+ xToolBox->set_item_help_id("print", HID_HELP_TOOLBOXITEM_PRINT);
+ xToolBox->set_item_help_id("bookmarks", HID_HELP_TOOLBOXITEM_BOOKMARKS );
+ xToolBox->set_item_help_id("searchdialog", HID_HELP_TOOLBOXITEM_SEARCHDIALOG);
InitToolBoxImages();
- aToolBox->Show();
InitOnStartupBox();
- aOnStartupCB->SetClickHdl( LINK( this, SfxHelpTextWindow_Impl, CheckHdl ) );
+ xOnStartupCB->connect_clicked(LINK(this, SfxHelpTextWindow_Impl, CheckHdl));
aSelectIdle.SetInvokeHandler( LINK( this, SfxHelpTextWindow_Impl, SelectHdl ) );
aSelectIdle.SetPriority( TaskPriority::LOWEST );
@@ -1908,19 +1709,16 @@ SfxHelpTextWindow_Impl::~SfxHelpTextWindow_Impl()
void SfxHelpTextWindow_Impl::dispose()
{
- sfx2::RemoveFromTaskPaneList( aToolBox.get() );
-
bIsInClose = true;
SvtMiscOptions().RemoveListenerLink( LINK( this, SfxHelpTextWindow_Impl, NotifyHdl ) );
m_xSrchDlg.reset();
- aToolBox.disposeAndClear();
- aOnStartupCB.disposeAndClear();
- pHelpWin.clear();
+ xToolBox.reset();
+ xOnStartupCB.reset();
+ xHelpWin.clear();
pTextWin.disposeAndClear();
vcl::Window::dispose();
}
-
bool SfxHelpTextWindow_Impl::HasSelection() const
{
// is there any selection in the text and not only a cursor?
@@ -1936,50 +1734,11 @@ bool SfxHelpTextWindow_Impl::HasSelection() const
return bRet;
}
-
void SfxHelpTextWindow_Impl::InitToolBoxImages()
{
- bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge();
-
- aIndexOnImage = Image(StockImage::Yes, bLarge ? OUString(BMP_HELP_TOOLBOX_L_INDEX_ON) : OUString(BMP_HELP_TOOLBOX_INDEX_ON));
- aIndexOffImage = Image(StockImage::Yes, bLarge ? OUString(BMP_HELP_TOOLBOX_L_INDEX_OFF) : OUString(BMP_HELP_TOOLBOX_INDEX_OFF));
-
- aToolBox->SetItemImage( TBI_INDEX, bIsIndexOn ? aIndexOffImage : aIndexOnImage );
-
- aToolBox->SetItemImage( TBI_BACKWARD,
- Image(StockImage::Yes, bLarge ? OUString(BMP_HELP_TOOLBOX_L_PREV) : OUString(BMP_HELP_TOOLBOX_PREV))
- );
-
- aToolBox->SetItemImage( TBI_FORWARD,
- Image(StockImage::Yes, bLarge ? OUString(BMP_HELP_TOOLBOX_L_NEXT) : OUString(BMP_HELP_TOOLBOX_NEXT))
- );
-
- aToolBox->SetItemImage( TBI_START,
- Image(StockImage::Yes, bLarge ? OUString(BMP_HELP_TOOLBOX_L_START) : OUString(BMP_HELP_TOOLBOX_START))
- );
-
- aToolBox->SetItemImage( TBI_PRINT,
- Image(StockImage::Yes, bLarge ? OUString(BMP_HELP_TOOLBOX_L_PRINT) : OUString(BMP_HELP_TOOLBOX_PRINT))
- );
-
- aToolBox->SetItemImage( TBI_BOOKMARKS,
- Image(StockImage::Yes, bLarge ? OUString(BMP_HELP_TOOLBOX_L_BOOKMARKS) : OUString(BMP_HELP_TOOLBOX_BOOKMARKS))
- );
-
- aToolBox->SetItemImage( TBI_SEARCHDIALOG,
- Image(StockImage::Yes, bLarge ? OUString(BMP_HELP_TOOLBOX_L_SEARCHDIALOG) : OUString(BMP_HELP_TOOLBOX_SEARCHDIALOG))
- );
-
- Size aSize = aToolBox->CalcWindowSizePixel();
- aSize.AdjustHeight(TOOLBOX_OFFSET );
- aToolBox->SetPosSizePixel( Point( 0, TOOLBOX_OFFSET ), aSize );
-
- SvtMiscOptions aMiscOptions;
- if ( aMiscOptions.GetToolboxStyle() != aToolBox->GetOutStyle() )
- aToolBox->SetOutStyle( aMiscOptions.GetToolboxStyle() );
+ xToolBox->set_item_icon_name("index", bIsIndexOn ? aIndexOffImage : aIndexOnImage);
}
-
void SfxHelpTextWindow_Impl::InitOnStartupBox()
{
sCurrentFactory = SfxHelp::GetCurrentModuleIdentifier();
@@ -2010,7 +1769,7 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox()
}
if ( bHideBox )
- aOnStartupCB->Hide();
+ xOnStartupCB->hide();
else
{
// detect module name
@@ -2034,43 +1793,16 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox()
if ( !sModuleName.isEmpty() )
{
// set module name in checkbox text
- aOnStartupCB->SetText( aOnStartupText.replaceFirst( "%MODULENAME", sModuleName ) );
+ xOnStartupCB->set_label(aOnStartupText.replaceFirst("%MODULENAME", sModuleName));
// and show it
- aOnStartupCB->Show();
+ xOnStartupCB->show();
// set check state
- aOnStartupCB->Check( bHelpAtStartup );
- aOnStartupCB->SaveValue();
-
- // calculate and set optimal width of the onstartup checkbox
- long nTextWidth = aOnStartupCB->GetTextWidth( "XXX" + aOnStartupCB->GetText() );
- Size aSize = aOnStartupCB->GetSizePixel();
- aSize.setWidth( nTextWidth );
- aOnStartupCB->SetSizePixel( aSize );
- SetOnStartupBoxPosition();
+ xOnStartupCB->set_active(bHelpAtStartup);
+ xOnStartupCB->save_state();
}
-
- // set position of the checkbox
- Size a3Size = LogicToPixel(Size(3, 3), MapMode(MapUnit::MapAppFont));
- Size aTBSize = aToolBox->GetSizePixel();
- Size aCBSize = aOnStartupCB->GetSizePixel();
- Point aPnt = aToolBox->GetPosPixel();
- aPnt.AdjustX(aTBSize.Width() + a3Size.Width() );
- aPnt.AdjustY( ( aTBSize.Height() - aCBSize.Height() ) / 2 );
- aOnStartupCB->SetPosPixel( aPnt );
- nMinPos = aPnt.X();
}
}
-
-void SfxHelpTextWindow_Impl::SetOnStartupBoxPosition()
-{
- long nX = std::max( GetOutputSizePixel().Width() - aOnStartupCB->GetSizePixel().Width(), nMinPos );
- Point aPos = aOnStartupCB->GetPosPixel();
- aPos.setX( nX );
- aOnStartupCB->SetPosPixel( aPos );
-}
-
-
Reference< XBreakIterator > const & SfxHelpTextWindow_Impl::GetBreakIterator()
{
if ( !xBreakIterator.is() )
@@ -2079,7 +1811,6 @@ Reference< XBreakIterator > const & SfxHelpTextWindow_Impl::GetBreakIterator()
return xBreakIterator;
}
-
Reference< XTextRange > SfxHelpTextWindow_Impl::getCursor() const
{
// return the current cursor
@@ -2173,10 +1904,8 @@ IMPL_LINK_NOARG( SfxHelpTextWindow_Impl, NotifyHdl, LinkParamNone*, void )
{
InitToolBoxImages();
Resize();
- aToolBox->Invalidate();
}
-
IMPL_LINK( SfxHelpTextWindow_Impl, FindHdl, sfx2::SearchDialog&, rDlg, void )
{
FindHdl(&rDlg);
@@ -2259,18 +1988,17 @@ void SfxHelpTextWindow_Impl::FindHdl(sfx2::SearchDialog* pDlg)
}
}
-IMPL_LINK_NOARG( SfxHelpTextWindow_Impl, CloseHdl, LinkParamNone*, void )
+IMPL_LINK_NOARG(SfxHelpTextWindow_Impl, CloseHdl, LinkParamNone*, void)
{
m_xSrchDlg.reset();
}
-IMPL_LINK( SfxHelpTextWindow_Impl, CheckHdl, Button*, pButton, void )
+IMPL_LINK_NOARG(SfxHelpTextWindow_Impl, CheckHdl, weld::Button&, void)
{
- CheckBox* pBox = static_cast<CheckBox*>(pButton);
if ( !xConfiguration.is() )
return;
- bool bChecked = pBox->IsChecked();
+ bool bChecked = xOnStartupCB->get_active();
try
{
ConfigurationHelper::writeRelativeKey(
@@ -2283,17 +2011,12 @@ IMPL_LINK( SfxHelpTextWindow_Impl, CheckHdl, Button*, pButton, void )
}
}
-
void SfxHelpTextWindow_Impl::Resize()
{
Size aSize = GetOutputSizePixel();
- long nToolBoxHeight = aToolBox->GetSizePixel().Height() + TOOLBOX_OFFSET;
- aSize.AdjustHeight( -nToolBoxHeight );
- pTextWin->SetPosSizePixel( Point( 0, nToolBoxHeight ), aSize );
- SetOnStartupBoxPosition();
+ pTextWin->SetPosSizePixel( Point(0, 0), aSize );
}
-
bool SfxHelpTextWindow_Impl::PreNotify( NotifyEvent& rNEvt )
{
bool bDone = false;
@@ -2303,58 +2026,33 @@ bool SfxHelpTextWindow_Impl::PreNotify( NotifyEvent& rNEvt )
const CommandEvent* pCmdEvt = rNEvt.GetCommandEvent();
vcl::Window* pCmdWin = rNEvt.GetWindow();
- if ( pCmdEvt->GetCommand() == CommandEventId::ContextMenu && pCmdWin != this && pCmdWin != aToolBox.get() )
+ if ( pCmdEvt->GetCommand() == CommandEventId::ContextMenu && pCmdWin != this )
{
Point aPos;
if ( pCmdEvt->IsMouseEvent() )
aPos = pCmdEvt->GetMousePosPixel();
else
aPos = Point( pTextWin->GetPosPixel().X() + 20, 20 );
- aPos.AdjustY(pTextWin->GetPosPixel().Y() );
- ScopedVclPtrInstance<PopupMenu> aMenu;
- if ( bIsIndexOn )
- aMenu->InsertItem(TBI_INDEX, aIndexOffText, Image(StockImage::Yes, BMP_HELP_TOOLBOX_INDEX_OFF));
+
+ xMenu->clear();
+
+ if (bIsIndexOn)
+ xMenu->append("index", aIndexOffText, BMP_HELP_TOOLBOX_INDEX_OFF);
else
- aMenu->InsertItem(TBI_INDEX, aIndexOnText, Image(StockImage::Yes, BMP_HELP_TOOLBOX_INDEX_ON));
-
- aMenu->SetHelpId( TBI_INDEX, HID_HELP_TOOLBOXITEM_INDEX );
- aMenu->InsertSeparator();
- aMenu->InsertItem( TBI_BACKWARD,
- SfxResId( STR_HELP_BUTTON_PREV ),
- Image(StockImage::Yes, BMP_HELP_TOOLBOX_PREV)
- );
- aMenu->SetHelpId( TBI_BACKWARD, HID_HELP_TOOLBOXITEM_BACKWARD );
- aMenu->EnableItem( TBI_BACKWARD, pHelpWin->HasHistoryPredecessor() );
- aMenu->InsertItem( TBI_FORWARD,
- SfxResId( STR_HELP_BUTTON_NEXT ),
- Image(StockImage::Yes, BMP_HELP_TOOLBOX_NEXT)
- );
- aMenu->SetHelpId( TBI_FORWARD, HID_HELP_TOOLBOXITEM_FORWARD );
- aMenu->EnableItem( TBI_FORWARD, pHelpWin->HasHistorySuccessor() );
- aMenu->InsertItem( TBI_START,
- SfxResId( STR_HELP_BUTTON_START ),
- Image(StockImage::Yes, BMP_HELP_TOOLBOX_START)
- );
- aMenu->SetHelpId( TBI_START, HID_HELP_TOOLBOXITEM_START );
- aMenu->InsertSeparator();
- aMenu->InsertItem( TBI_PRINT,
- SfxResId( STR_HELP_BUTTON_PRINT ),
- Image(StockImage::Yes, BMP_HELP_TOOLBOX_PRINT)
- );
- aMenu->SetHelpId( TBI_PRINT, HID_HELP_TOOLBOXITEM_PRINT );
- aMenu->InsertItem( TBI_BOOKMARKS,
- SfxResId( STR_HELP_BUTTON_ADDBOOKMARK ),
- Image(StockImage::Yes, BMP_HELP_TOOLBOX_BOOKMARKS)
- );
- aMenu->SetHelpId( TBI_BOOKMARKS, HID_HELP_TOOLBOXITEM_BOOKMARKS );
- aMenu->InsertItem( TBI_SEARCHDIALOG,
- SfxResId( STR_HELP_BUTTON_SEARCHDIALOG ),
- Image(StockImage::Yes, BMP_HELP_TOOLBOX_SEARCHDIALOG)
- );
- aMenu->SetHelpId( TBI_SEARCHDIALOG, HID_HELP_TOOLBOXITEM_SEARCHDIALOG );
- aMenu->InsertSeparator();
- aMenu->InsertItem( TBI_SELECTIONMODE, SfxResId( STR_HELP_MENU_TEXT_SELECTION_MODE ) );
- aMenu->SetHelpId( TBI_SELECTIONMODE, HID_HELP_TEXT_SELECTION_MODE );
+ xMenu->append("index", aIndexOnText, BMP_HELP_TOOLBOX_INDEX_ON);
+
+ xMenu->append_separator("separator1");
+ xMenu->append("backward", SfxResId(STR_HELP_BUTTON_PREV), BMP_HELP_TOOLBOX_PREV);
+ xMenu->set_sensitive("backward", xHelpWin->HasHistoryPredecessor());
+ xMenu->append("forward", SfxResId(STR_HELP_BUTTON_NEXT), BMP_HELP_TOOLBOX_NEXT);
+ xMenu->set_sensitive("forward", xHelpWin->HasHistorySuccessor());
+ xMenu->append("start", SfxResId(STR_HELP_BUTTON_START), BMP_HELP_TOOLBOX_START);
+ xMenu->append_separator("separator2");
+ xMenu->append("print", SfxResId(STR_HELP_BUTTON_PRINT), BMP_HELP_TOOLBOX_PRINT);
+ xMenu->append("bookmarks", SfxResId(STR_HELP_BUTTON_ADDBOOKMARK), BMP_HELP_TOOLBOX_BOOKMARKS);
+ xMenu->append("searchdialog", SfxResId(STR_HELP_BUTTON_SEARCHDIALOG), BMP_HELP_TOOLBOX_SEARCHDIALOG);
+ xMenu->append_separator("separator3");
+ xMenu->append_check("selectionmode", SfxResId(STR_HELP_MENU_TEXT_SELECTION_MODE));
URL aURL;
aURL.Complete = ".uno:SelectTextMode";
Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
@@ -2367,27 +2065,25 @@ bool SfxHelpTextWindow_Impl::PreNotify( NotifyEvent& rNEvt )
FeatureStateEvent rEvent = pStateListener->GetStateEvent();
bool bCheck = false;
rEvent.State >>= bCheck;
- aMenu->CheckItem(TBI_SELECTIONMODE, bCheck);
+ xMenu->set_active("selectionmode", bCheck);
}
- aMenu->InsertSeparator();
- aMenu->InsertItem( TBI_COPY,
- SfxResId(STR_HELP_MENU_TEXT_COPY),
- Image(StockImage::Yes, BMP_HELP_TOOLBOX_COPY)
- );
- aMenu->SetHelpId( TBI_COPY, ".uno:Copy" );
- aMenu->EnableItem( TBI_COPY, HasSelection() );
+ xMenu->append_separator("separator4");
+ xMenu->append("copy", SfxResId(STR_HELP_MENU_TEXT_COPY), BMP_HELP_TOOLBOX_COPY);
+ xMenu->set_sensitive("copy", HasSelection());
if ( bIsDebug )
{
- aMenu->InsertSeparator();
- aMenu->InsertItem( TBI_SOURCEVIEW, SfxResId(STR_HELP_BUTTON_SOURCEVIEW) );
+ xMenu->append_separator("separator5");
+ xMenu->append("sourceview", SfxResId(STR_HELP_BUTTON_SOURCEVIEW));
}
- if( ! SvtMenuOptions().IsEntryHidingEnabled() )
- aMenu->SetMenuFlags( aMenu->GetMenuFlags() | MenuFlags::HideDisabledEntries );
+ int x, y, width, height;
+ weld::Window* pTopLevel = GetFrameWeld();
+ xHelpWin->GetContainer()->get_extents_relative_to(*pTopLevel, x, y, width, height);
+ aPos.AdjustX(x);
+ aPos.AdjustY(y);
- sal_uInt16 nId = aMenu->Execute( this, aPos );
- pHelpWin->DoAction( nId );
+ xHelpWin->DoAction(xMenu->popup_at_rect(pTopLevel, tools::Rectangle(aPos, Size(1,1))));
bDone = true;
}
}
@@ -2405,12 +2101,12 @@ bool SfxHelpTextWindow_Impl::PreNotify( NotifyEvent& rNEvt )
else if ( rKeyCode.IsMod1() && ( KEY_F4 == nKey || KEY_W == nKey ) )
{
// <CTRL><F4> or <CTRL><W> -> close top frame
- pHelpWin->CloseWindow();
+ xHelpWin->CloseWindow();
bDone = true;
}
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list