diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-04-29 20:29:45 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-05-12 20:23:50 +0200 |
commit | 859636d491960b797bd8cbfb81e6f08451175f12 (patch) | |
tree | d3d384cd7650a276eedb79e03759107b45faabe7 /sfx2/source | |
parent | 9d573bca549861ecdbce6826804e5db0471307e6 (diff) |
weld help browser
Change-Id: Ibd8dcc10c4403731953e2e46db4ae8f89ebc7e4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93216
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/appl/newhelp.cxx | 2040 | ||||
-rw-r--r-- | sfx2/source/appl/newhelp.hxx | 398 |
2 files changed, 983 insertions, 1455 deletions
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); -bool ContentListBox_Impl::EventNotify( NotifyEvent& rNEvt ) + return true; +} + +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, Button*, void) +IMPL_LINK_NOARG(IndexTabPage_Impl, OpenHdl, weld::Button&, void) { - m_pIndexCB->GetDoubleClickHdl().Call(*m_pIndexCB); + aDoubleClickHdl.Call(nullptr); +} + +IMPL_LINK_NOARG(IndexTabPage_Impl, ActivateHdl, weld::Entry&, bool) +{ + aDoubleClickHdl.Call(nullptr); + return true; +} + +IMPL_LINK_NOARG(IndexTabPage_Impl, DoubleClickHdl, weld::TreeView&, bool) +{ + 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 ) +IMPL_LINK_NOARG(SearchTabPage_Impl, ActivateHdl, weld::ComboBox&, bool) { - 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) -{ - 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 ) + bool bHandled = false; + sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); + if (KEY_DELETE == nCode && m_xBookmarksBox->n_children() > 0) { - 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; - } + 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 +IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, IndexTabPageDoubleClickHdl, LinkParamNone*, void) { - const vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); - if (!pChild) - return Window::GetOptimalSize(); - return VclContainer::getLayoutRequisition(*pChild); + aPageDoubleClickLink.Call(nullptr); } -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 ) -{ - Window::DataChanged( rDCEvt ); - - if ( ( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) || - ( rDCEvt.GetType() == DataChangedEventType::DISPLAY ) ) && - ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) ) - { - SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFaceColor() ) ); - } -} - - -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; } - else if ( KEY_TAB == nKey && aOnStartupCB->HasChildPathFocus() ) + else if ( KEY_TAB == nKey && xOnStartupCB->has_focus() ) { - aToolBox->GrabFocus(); + xToolBox->grab_focus(); bDone = true; } } @@ -2453,23 +2149,21 @@ void SfxHelpTextWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt ) } } - void SfxHelpTextWindow_Impl::ToggleIndex( bool bOn ) { bIsIndexOn = bOn; if ( bIsIndexOn ) { - aToolBox->SetItemImage( TBI_INDEX, aIndexOffImage ); - aToolBox->SetItemText( TBI_INDEX, aIndexOffText ); + xToolBox->set_item_icon_name("index", aIndexOffImage); + xToolBox->set_item_tooltip_text("index", aIndexOffText); } else { - aToolBox->SetItemImage( TBI_INDEX, aIndexOnImage ); - aToolBox->SetItemText( TBI_INDEX, aIndexOnText ); + xToolBox->set_item_icon_name("index", aIndexOnImage); + xToolBox->set_item_tooltip_text("index", aIndexOnText); } } - void SfxHelpTextWindow_Impl::SelectSearchText( const OUString& rSearchText, bool _bIsFullWordSearch ) { aSearchText = rSearchText; @@ -2565,137 +2259,48 @@ void SfxHelpTextWindow_Impl::DoSearch() sfx2::SearchDialog::runAsync(m_xSrchDlg); } -// class SfxHelpWindow_Impl ---------------------------------------------- - -void SfxHelpWindow_Impl::Resize() -{ - SplitWindow::Resize(); - InitSizes(); -} - - -void SfxHelpWindow_Impl::Split() -{ - static const long nMinSplitSize = 5; - static const long nMaxSplitSize = 99 - nMinSplitSize; - - SplitWindow::Split(); - - nIndexSize = GetItemSize( INDEXWIN_ID ); - nTextSize = GetItemSize( TEXTWIN_ID ); - - bool bMod = false; - if( nIndexSize < nMinSplitSize ) - { - nIndexSize = nMinSplitSize; - nTextSize = nMaxSplitSize; - - bMod = true; - } - else if( nTextSize < nMinSplitSize ) - { - nTextSize = nMinSplitSize; - nIndexSize = nMaxSplitSize; - - bMod = true; - } - else - bMod = false; - - if( bMod ) - { - SetItemSize( INDEXWIN_ID, nIndexSize ); - SetItemSize( TEXTWIN_ID, nTextSize ); - } - - InitSizes(); -} - void SfxHelpWindow_Impl::GetFocus() { - if( pTextWin ) + if (pTextWin) pTextWin->GrabFocus(); else - vcl::Window::GetFocus(); + DockingWindow::GetFocus(); } void SfxHelpWindow_Impl::MakeLayout() { - if ( nHeight > 0 && xWindow.is() ) - { - VclPtr<vcl::Window> pScreenWin = VCLUnoHelper::GetWindow(xWindow); - - /* #i55528# - Hide() / Show() will produce strange effects. - The returned size (used later to be written back into the configuration) - is not the right after a resize during the window is hidden. - If this resize is done if the window is visible everything works as expected. - Some VCL-patches could not solve this problem so I've established the - workaround: resize the help window if it's visible .-) - */ - css::awt::Rectangle aRect = xWindow->getPosSize(); - sal_Int32 nOldWidth = bIndex ? nCollapseWidth : nExpandWidth; - sal_Int32 nWidth = bIndex ? nExpandWidth : nCollapseWidth; - xWindow->setPosSize( aRect.X, aRect.Y, nWidth, nHeight, css::awt::PosSize::SIZE ); - - if ( aRect.Width > 0 && aRect.Height > 0 ) - { - tools::Rectangle aScreenRect = pScreenWin->GetClientWindowExtentsRelative(); - Point aNewPos = aScreenRect.TopLeft(); - sal_Int32 nDiffWidth = nOldWidth - nWidth; - aNewPos.AdjustX(nDiffWidth ); - pScreenWin->SetPosPixel( aNewPos ); - } - else if ( aWinPos.X() > 0 && aWinPos.Y() > 0 ) - pScreenWin->SetPosPixel( aWinPos ); - } + Split(); - Clear(); - - if ( bIndex ) - { - pIndexWin->Show(); - InsertItem( COLSET_ID, 100, SPLITWINDOW_APPEND, SPLITSET_ID, SplitWindowItemFlags::PercentSize | SplitWindowItemFlags::ColSet ); - InsertItem( INDEXWIN_ID, pIndexWin, nIndexSize, SPLITWINDOW_APPEND, COLSET_ID, SplitWindowItemFlags::PercentSize ); - InsertItem( TEXTWIN_ID, pTextWin, nTextSize, SPLITWINDOW_APPEND, COLSET_ID, SplitWindowItemFlags::PercentSize ); - } - else - { - pIndexWin->Hide(); - InsertItem( COLSET_ID, 100, SPLITWINDOW_APPEND, SPLITSET_ID, SplitWindowItemFlags::PercentSize | SplitWindowItemFlags::ColSet ); - InsertItem( TEXTWIN_ID, pTextWin, 100, SPLITWINDOW_APPEND, 1, SplitWindowItemFlags::PercentSize ); - } + m_xHelpPaneWindow->set_visible(bIndex); } - -void SfxHelpWindow_Impl::InitSizes() +IMPL_LINK(SfxHelpWindow_Impl, ResizeHdl, const Size&, rSize, void) { - if ( !xWindow.is() ) + int nNewWidth = rSize.Width(); + if (!nNewWidth) return; - - css::awt::Rectangle aRect = xWindow->getPosSize(); - nHeight = aRect.Height; - - if ( bIndex ) - { - nExpandWidth = aRect.Width; - nCollapseWidth = nExpandWidth * nTextSize / 100; - } - else - { - nCollapseWidth = aRect.Width; - nExpandWidth = nTextSize ? nCollapseWidth * 100 / nTextSize : 0; - } + if (bSplit) + nIndexSize = round(m_xContainer->get_position() * 100.0 / nNewWidth); + nWidth = nNewWidth; + Split(); + nIndexSize = round(m_xContainer->get_position() * 100.0 / nWidth); } +void SfxHelpWindow_Impl::Split() +{ + if (!nWidth) + return; + m_xContainer->set_position(nWidth * nIndexSize / 100); + bSplit = true; +} void SfxHelpWindow_Impl::LoadConfig() { SvtViewOptions aViewOpt( EViewType::Window, CONFIGNAME_HELPWIN ); if ( !aViewOpt.Exists() ) return; - bIndex = aViewOpt.IsVisible(); + Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME ); OUString aUserData; if ( aUserItem >>= aUserData ) @@ -2703,27 +2308,17 @@ void SfxHelpWindow_Impl::LoadConfig() DBG_ASSERT( comphelper::string::getTokenCount(aUserData, ';') == 6, "invalid user data" ); sal_Int32 nIdx = 0; nIndexSize = aUserData.getToken( 0, ';', nIdx ).toInt32(); - nTextSize = aUserData.getToken( 0, ';', nIdx ).toInt32(); - sal_Int32 nWidth = aUserData.getToken( 0, ';', nIdx ).toInt32(); - nHeight = aUserData.getToken( 0, ';', nIdx ).toInt32(); + aUserData.getToken(0, ';', nIdx); // ignore nTextSize + sal_Int32 nOldWidth = aUserData.getToken( 0, ';', nIdx ).toInt32(); + sal_Int32 nOldHeight = aUserData.getToken( 0, ';', nIdx ).toInt32(); + aWinSize = Size(nOldWidth, nOldHeight); aWinPos.setX( aUserData.getToken( 0, ';', nIdx ).toInt32() ); aWinPos.setY( aUserData.getToken( 0, ';', nIdx ).toInt32() ); - if ( bIndex ) - { - nExpandWidth = nWidth; - nCollapseWidth = nExpandWidth * nTextSize / 100; - } - else if (nTextSize != 0) - { - nCollapseWidth = nWidth; - nExpandWidth = nCollapseWidth * 100 / nTextSize; - } } pTextWin->ToggleIndex( bIndex ); } - void SfxHelpWindow_Impl::SaveConfig() { SvtViewOptions aViewOpt( EViewType::Window, CONFIGNAME_HELPWIN ); @@ -2737,11 +2332,12 @@ void SfxHelpWindow_Impl::SaveConfig() } aViewOpt.SetVisible( bIndex ); - VclPtr<vcl::Window> pScreenWin = VCLUnoHelper::GetWindow( xWindow ); aWinPos = pScreenWin->GetWindowExtentsRelative( nullptr ).TopLeft(); + if (bSplit) + nIndexSize = round(m_xContainer->get_position() * 100.0 / nWidth); const OUString aUserData = OUString::number( nIndexSize ) - + ";" + OUString::number( nTextSize ) + + ";" + OUString::number( 100 - nIndexSize ) + ";" + OUString::number( nW ) + ";" + OUString::number( nH ) + ";" + OUString::number( aWinPos.X() ) @@ -2750,30 +2346,24 @@ void SfxHelpWindow_Impl::SaveConfig() aViewOpt.SetUserItem( USERITEM_NAME, makeAny( aUserData ) ); } - void SfxHelpWindow_Impl::ShowStartPage() { - loadHelpContent(SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(), "/start", OUString())); + loadHelpContent(SfxHelpWindow_Impl::buildHelpURL(xIndexWin->GetFactory(), "/start", OUString())); } - -IMPL_LINK( SfxHelpWindow_Impl, SelectHdl, ToolBox* , pToolBox, void ) +IMPL_LINK(SfxHelpWindow_Impl, SelectHdl, const OString&, rCurItem, void) { - if ( pToolBox ) - { - bGrabFocusToToolBox = pToolBox->HasChildPathFocus(); - DoAction( pToolBox->GetCurItemId() ); - } + bGrabFocusToToolBox = pTextWin->GetToolBox().has_focus(); + DoAction(rCurItem); } - -IMPL_LINK_NOARG(SfxHelpWindow_Impl, OpenHdl, Control*, bool) +IMPL_LINK_NOARG(SfxHelpWindow_Impl, OpenHdl, LinkParamNone*, void) { - pIndexWin->SelectExecutableEntry(); - OUString aEntry = pIndexWin->GetSelectedEntry(); + xIndexWin->SelectExecutableEntry(); + OUString aEntry = xIndexWin->GetSelectedEntry(); if ( aEntry.isEmpty() ) - return false; + return; OUString sHelpURL; @@ -2794,15 +2384,12 @@ IMPL_LINK_NOARG(SfxHelpWindow_Impl, OpenHdl, Control*, bool) else aId = aEntry; - sHelpURL = SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(), "/" + aId, aAnchor); + sHelpURL = SfxHelpWindow_Impl::buildHelpURL(xIndexWin->GetFactory(), "/" + aId, aAnchor); } loadHelpContent(sHelpURL); - - return false; } - IMPL_LINK( SfxHelpWindow_Impl, SelectFactoryHdl, SfxHelpIndexWindow_Impl* , pWin, void ) { if ( sTitle.isEmpty() ) @@ -2810,11 +2397,11 @@ IMPL_LINK( SfxHelpWindow_Impl, SelectFactoryHdl, SfxHelpIndexWindow_Impl* , pWin Reference< XTitle > xTitle(xFrame, UNO_QUERY); if (xTitle.is ()) - xTitle->setTitle(sTitle + " - " + pIndexWin->GetActiveFactoryTitle()); + xTitle->setTitle(sTitle + " - " + xIndexWin->GetActiveFactoryTitle()); if ( pWin ) ShowStartPage(); - pIndexWin->ClearSearchPage(); + xIndexWin->ClearSearchPage(); } @@ -2834,11 +2421,11 @@ void SfxHelpWindow_Impl::openDone(const OUString& sURL , LeaveWait(); if ( bGrabFocusToToolBox ) { - pTextWin->GetToolBox().GrabFocus(); + pTextWin->GetToolBox().grab_focus(); bGrabFocusToToolBox = false; } else - pIndexWin->GrabFocusBack(); + xIndexWin->GrabFocusBack(); if ( !bSuccess ) return; @@ -2867,9 +2454,9 @@ void SfxHelpWindow_Impl::openDone(const OUString& sURL , } // When the SearchPage opens the help doc, then select all words, which are equal to its text - OUString sSearchText = comphelper::string::strip(pIndexWin->GetSearchText(), ' '); + OUString sSearchText = comphelper::string::strip(xIndexWin->GetSearchText(), ' '); if ( !sSearchText.isEmpty() ) - pTextWin->SelectSearchText( sSearchText, pIndexWin->IsFullWordSearch() ); + pTextWin->SelectSearchText( sSearchText, xIndexWin->IsFullWordSearch() ); // no page style header -> this prevents a print output of the URL pTextWin->SetPageStyleHeaderOff(); @@ -2880,33 +2467,41 @@ SfxHelpWindow_Impl::SfxHelpWindow_Impl( const css::uno::Reference < css::frame::XFrame2 >& rFrame, vcl::Window* pParent ) : - SplitWindow( pParent, WB_3DLOOK | WB_NOSPLITDRAW ), + DockingWindow(pParent, "DockingWindow", "sfx/ui/dockingwindow.ui"), xFrame ( rFrame ), - pIndexWin ( nullptr ), pTextWin ( nullptr ), pHelpInterceptor ( new HelpInterceptor_Impl() ), pHelpListener ( new HelpListener_Impl( pHelpInterceptor ) ), - nExpandWidth ( 0 ), - nCollapseWidth ( 0 ), - nHeight ( 0 ), - nIndexSize ( 40 ), - nTextSize ( 60 ), bIndex ( true ), bGrabFocusToToolBox ( false ), + bSplit ( false ), + nWidth ( 0 ), + nIndexSize ( 40 ), // % of width aWinPos ( 0, 0 ), + aWinSize ( 0, 0 ), sTitle ( pParent->GetText() ) { + SetStyle(GetStyle() & ~WB_DOCKABLE); + SetHelpId( HID_HELP_WINDOW ); - SetStyle( GetStyle() | WB_DIALOGCONTROL ); + + m_xVclContentArea = VclPtr<VclVBox>::Create(this); + m_xVclContentArea->Show(); + m_xBuilder.reset(Application::CreateInterimBuilder(m_xVclContentArea, "sfx/ui/helpwindow.ui")); + m_xContainer = m_xBuilder->weld_paned("HelpWindow"); + m_xContainer->connect_size_allocate(LINK(this, SfxHelpWindow_Impl, ResizeHdl)); + m_xHelpPaneWindow = m_xBuilder->weld_container("helppanewindow"); + m_xHelpTextWindow = m_xBuilder->weld_container("helptextwindow"); + m_xHelpTextWindow->set_size_request(m_xHelpTextWindow->get_approximate_digit_width() * 120, -1); + m_xHelpTextXWindow = m_xHelpTextWindow->CreateChildFrame(); pHelpInterceptor->InitWaiter( this ); - pIndexWin = VclPtr<SfxHelpIndexWindow_Impl>::Create( this ); - pIndexWin->SetDoubleClickHdl( LINK( this, SfxHelpWindow_Impl, OpenHdl ) ); - pIndexWin->SetSelectFactoryHdl( LINK( this, SfxHelpWindow_Impl, SelectFactoryHdl ) ); - pIndexWin->SetSizePixel(LogicToPixel(Size(120, 200), MapMode(MapUnit::MapAppFont))); - pIndexWin->Show(); - pTextWin = VclPtr<SfxHelpTextWindow_Impl>::Create( this ); + xIndexWin.reset(new SfxHelpIndexWindow_Impl(this, m_xHelpPaneWindow.get())); + xIndexWin->SetDoubleClickHdl( LINK( this, SfxHelpWindow_Impl, OpenHdl ) ); + xIndexWin->SetSelectFactoryHdl( LINK( this, SfxHelpWindow_Impl, SelectFactoryHdl ) ); + + pTextWin = VclPtr<SfxHelpTextWindow_Impl>::Create(this, *m_xBuilder, VCLUnoHelper::GetWindow(m_xHelpTextXWindow)); Reference < XFrames > xFrames = rFrame->getFrames(); xFrames->append( Reference<XFrame>(pTextWin->getFrame(), UNO_QUERY_THROW) ); pTextWin->SetSelectHdl( LINK( this, SfxHelpWindow_Impl, SelectHdl ) ); @@ -2916,7 +2511,6 @@ SfxHelpWindow_Impl::SfxHelpWindow_Impl( LoadConfig(); } - SfxHelpWindow_Impl::~SfxHelpWindow_Impl() { disposeOnce(); @@ -2925,10 +2519,19 @@ SfxHelpWindow_Impl::~SfxHelpWindow_Impl() void SfxHelpWindow_Impl::dispose() { SaveConfig(); - pIndexWin.disposeAndClear(); + xIndexWin.reset(); pTextWin->CloseFrame(); pTextWin.disposeAndClear(); - SplitWindow::dispose(); + + m_xHelpTextXWindow->dispose(); + m_xHelpTextXWindow.clear(); + m_xHelpTextWindow.reset(); + m_xHelpPaneWindow.reset(); + m_xContainer.reset(); + m_xBuilder.reset(); + m_xVclContentArea.disposeAndClear(); + + DockingWindow::dispose(); } bool SfxHelpWindow_Impl::PreNotify( NotifyEvent& rNEvt ) @@ -2940,9 +2543,9 @@ bool SfxHelpWindow_Impl::PreNotify( NotifyEvent& rNEvt ) const vcl::KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode(); sal_uInt16 nKey = rKeyCode.GetCode(); if ( ( rKeyCode.IsMod2() && ( KEY_LEFT == nKey || KEY_RIGHT == nKey ) ) || - ( !rKeyCode.GetModifier() && KEY_BACKSPACE == nKey && !pIndexWin->HasFocusOnEdit() ) ) + ( !rKeyCode.GetModifier() && KEY_BACKSPACE == nKey && !xIndexWin->HasFocusOnEdit() ) ) { - DoAction( rKeyCode.GetCode() == KEY_RIGHT ? TBI_FORWARD : TBI_BACKWARD ); + DoAction( rKeyCode.GetCode() == KEY_RIGHT ? "forward" : "backward" ); bHandled = true; } else if ( rKeyCode.IsMod1() && ( KEY_F4 == nKey || KEY_W == nKey ) ) @@ -2959,14 +2562,21 @@ void SfxHelpWindow_Impl::setContainerWindow( const Reference < css::awt::XWindow { xWindow = xWin; MakeLayout(); + if (xWindow.is()) + { + VclPtr<vcl::Window> pScreenWin = VCLUnoHelper::GetWindow(xWindow); + if (aWinSize.Width() && aWinSize.Height()) + pScreenWin->SetPosSizePixel(aWinPos, aWinSize); + else + pScreenWin->SetPosPixel(aWinPos); + } } void SfxHelpWindow_Impl::SetFactory( const OUString& rFactory ) { - pIndexWin->SetFactory( rFactory, true ); + xIndexWin->SetFactory( rFactory, true ); } - void SfxHelpWindow_Impl::SetHelpURL( const OUString& rURL ) { INetURLObject aObj( rURL ); @@ -2974,105 +2584,85 @@ void SfxHelpWindow_Impl::SetHelpURL( const OUString& rURL ) SetFactory( aObj.GetHost() ); } - -void SfxHelpWindow_Impl::DoAction( sal_uInt16 nActionId ) +void SfxHelpWindow_Impl::DoAction(const OString& rActionId) { - switch ( nActionId ) + if (rActionId == "index") { - case TBI_INDEX : - { - bIndex = !bIndex; - MakeLayout(); - pTextWin->ToggleIndex( bIndex ); - break; - } - - case TBI_START : - { - ShowStartPage(); - break; - } - - case TBI_BACKWARD : - case TBI_FORWARD : + bIndex = !bIndex; + MakeLayout(); + pTextWin->ToggleIndex( bIndex ); + } + else if (rActionId == "start") + { + ShowStartPage(); + } + else if (rActionId == "backward" || rActionId == "forward") + { + URL aURL; + aURL.Complete = ".uno:Backward"; + if (rActionId == "forward") + aURL.Complete = ".uno:Forward"; + Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); + xTrans->parseStrict(aURL); + pHelpInterceptor->dispatch( aURL, Sequence < PropertyValue >() ); + } + else if (rActionId == "searchdialog") + { + pTextWin->DoSearch(); + } + else if (rActionId == "print" || rActionId == "sourceview" || rActionId == "copy" || rActionId == "selectionmode") + { + Reference < XDispatchProvider > xProv = pTextWin->getFrame(); + if ( xProv.is() ) { URL aURL; - aURL.Complete = ".uno:Backward"; - if ( TBI_FORWARD == nActionId ) - aURL.Complete = ".uno:Forward"; + if (rActionId == "print") + aURL.Complete = ".uno:Print"; + else if (rActionId == "sourceview") + aURL.Complete = ".uno:SourceView"; + else if (rActionId == "copy") + aURL.Complete = ".uno:Copy"; + else // rActionId == "selectionmode" + aURL.Complete = ".uno:SelectTextMode"; Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); xTrans->parseStrict(aURL); - pHelpInterceptor->dispatch( aURL, Sequence < PropertyValue >() ); - break; - } - - case TBI_SEARCHDIALOG : - { - pTextWin->DoSearch(); - break; + Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, OUString(), 0 ); + if ( xDisp.is() ) + xDisp->dispatch( aURL, Sequence < PropertyValue >() ); } - - case TBI_PRINT : - case TBI_SOURCEVIEW : - case TBI_COPY : - case TBI_SELECTIONMODE: - { - Reference < XDispatchProvider > xProv = pTextWin->getFrame(); - if ( xProv.is() ) - { - URL aURL; - if ( TBI_PRINT == nActionId ) - aURL.Complete = ".uno:Print"; - else if ( TBI_SOURCEVIEW == nActionId ) - aURL.Complete = ".uno:SourceView"; - else if ( TBI_COPY == nActionId ) - aURL.Complete = ".uno:Copy"; - else // TBI_SELECTIONMODE == nActionId - aURL.Complete = ".uno:SelectTextMode"; - Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); - xTrans->parseStrict(aURL); - Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, OUString(), 0 ); - if ( xDisp.is() ) - xDisp->dispatch( aURL, Sequence < PropertyValue >() ); - } - break; - } - - case TBI_BOOKMARKS : + } + else if (rActionId == "bookmarks") + { + OUString aURL = pHelpInterceptor->GetCurrentURL(); + if ( !aURL.isEmpty() ) { - OUString aURL = pHelpInterceptor->GetCurrentURL(); - if ( !aURL.isEmpty() ) + try { - try + Content aCnt( aURL, Reference< css::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() ); + css::uno::Reference< css::beans::XPropertySetInfo > xInfo = aCnt.getProperties(); + if ( xInfo->hasPropertyByName( PROPERTY_TITLE ) ) { - Content aCnt( aURL, Reference< css::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() ); - css::uno::Reference< css::beans::XPropertySetInfo > xInfo = aCnt.getProperties(); - if ( xInfo->hasPropertyByName( PROPERTY_TITLE ) ) + css::uno::Any aAny = aCnt.getPropertyValue( PROPERTY_TITLE ); + OUString aValue; + if ( aAny >>= aValue ) { - css::uno::Any aAny = aCnt.getPropertyValue( PROPERTY_TITLE ); - OUString aValue; - if ( aAny >>= aValue ) + SfxAddHelpBookmarkDialog_Impl aDlg(GetFrameWeld(), false); + aDlg.SetTitle(aValue); + if (aDlg.run() == RET_OK ) { - SfxAddHelpBookmarkDialog_Impl aDlg(GetFrameWeld(), false); - aDlg.SetTitle(aValue); - if (aDlg.run() == RET_OK ) - { - pIndexWin->AddBookmarks( aDlg.GetTitle(), aURL ); - } + xIndexWin->AddBookmarks( aDlg.GetTitle(), aURL ); } } } - catch( Exception& ) - { - OSL_FAIL( "SfxHelpWindow_Impl::DoAction(): unexpected exception" ); - } } - break; + catch( Exception& ) + { + OSL_FAIL( "SfxHelpWindow_Impl::DoAction(): unexpected exception" ); + } } } } - void SfxHelpWindow_Impl::CloseWindow() { try @@ -3101,8 +2691,8 @@ void SfxHelpWindow_Impl::CloseWindow() void SfxHelpWindow_Impl::UpdateToolbox() { - pTextWin->GetToolBox().EnableItem( TBI_BACKWARD, pHelpInterceptor->HasHistoryPred() ); - pTextWin->GetToolBox().EnableItem( TBI_FORWARD, pHelpInterceptor->HasHistorySucc() ); + pTextWin->GetToolBox().set_item_sensitive("backward", pHelpInterceptor->HasHistoryPred()); + pTextWin->GetToolBox().set_item_sensitive("forward", pHelpInterceptor->HasHistorySucc()); } @@ -3119,7 +2709,7 @@ bool SfxHelpWindow_Impl::HasHistorySuccessor() const // class SfxAddHelpBookmarkDialog_Impl ----------------------------------- -SfxAddHelpBookmarkDialog_Impl::SfxAddHelpBookmarkDialog_Impl(weld::Window* pParent, bool bRename) +SfxAddHelpBookmarkDialog_Impl::SfxAddHelpBookmarkDialog_Impl(weld::Widget* pParent, bool bRename) : GenericDialogController(pParent, "sfx/ui/bookmarkdialog.ui", "BookmarkDialog") , m_xTitleED(m_xBuilder->weld_entry("entry")) , m_xAltTitle(m_xBuilder->weld_label("alttitle")) diff --git a/sfx2/source/appl/newhelp.hxx b/sfx2/source/appl/newhelp.hxx index 66a39b5e17c1..83b356eee551 100644 --- a/sfx2/source/appl/newhelp.hxx +++ b/sfx2/source/appl/newhelp.hxx @@ -22,17 +22,12 @@ #include <com/sun/star/uno/Reference.h> #include <com/sun/star/frame/XFrame2.hpp> -#include <vcl/window.hxx> +#include <rtl/ustrbuf.hxx> +#include <vcl/builderpage.hxx> +#include <vcl/dockwin.hxx> #include <vcl/idle.hxx> -#include <vcl/toolbox.hxx> -#include <vcl/tabpage.hxx> -#include <vcl/splitwin.hxx> -#include <vcl/tabctrl.hxx> -#include <vcl/combobox.hxx> -#include <vcl/button.hxx> -#include <vcl/lstbox.hxx> #include <vcl/weld.hxx> -#include <vcl/treelistbox.hxx> +#include <vcl/window.hxx> #include <srchdlg.hxx> @@ -45,47 +40,21 @@ namespace com::sun::star::awt { class XWindow; } namespace com::sun::star::i18n { class XBreakIterator; } namespace com::sun::star::text { class XTextRange; } - -// ContentListBox_Impl --------------------------------------------------- - -class ContentListBox_Impl : public SvTreeListBox -{ -private: - Image aOpenBookImage; - Image aClosedBookImage; - Image aDocumentImage; - - void InitRoot(); - void ClearChildren( SvTreeListEntry* pParent ); - -public: - ContentListBox_Impl(vcl::Window* pParent, WinBits nStyle); - virtual ~ContentListBox_Impl() override; - virtual void dispose() override; - - virtual void RequestingChildren( SvTreeListEntry* pParent ) override; - virtual bool EventNotify( NotifyEvent& rNEvt ) override; - - void SetOpenHdl( const Link<SvTreeListBox*,bool>& rLink ) { SetDoubleClickHdl( rLink ); } - OUString GetSelectedEntry() const; -}; - // class HelpTabPage_Impl ------------------------------------------------ class SfxHelpIndexWindow_Impl; -class HelpTabPage_Impl : public TabPage +class HelpTabPage_Impl : public BuilderPage { protected: - VclPtr<SfxHelpIndexWindow_Impl> m_pIdxWin; + SfxHelpIndexWindow_Impl* m_pIdxWin; public: - HelpTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin, + HelpTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* _pIdxWin, const OString& rID, const OUString& rUIXMLDescription); virtual ~HelpTabPage_Impl() override; - virtual void dispose() override; - virtual Control* GetLastFocusControl() = 0; + virtual weld::Widget* GetLastFocusControl() = 0; }; // class ContentTabPage_Impl --------------------------------------------- @@ -93,41 +62,39 @@ public: class ContentTabPage_Impl : public HelpTabPage_Impl { private: - VclPtr<ContentListBox_Impl> m_pContentBox; - -public: - ContentTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin); - virtual ~ContentTabPage_Impl() override; - virtual void dispose() override; + std::unique_ptr<weld::TreeView> m_xContentBox; + OUString aOpenBookImage; + OUString aClosedBookImage; + OUString aDocumentImage; - virtual void ActivatePage() override; - virtual Control* GetLastFocusControl() override; + Link<LinkParamNone*, void> aDoubleClickHdl; - void SetOpenHdl( const Link<SvTreeListBox*,bool>& rLink ) { m_pContentBox->SetOpenHdl( rLink ); } - OUString GetSelectedEntry() const { return m_pContentBox->GetSelectedEntry(); } - void SetFocusOnBox() { m_pContentBox->GrabFocus(); } -}; + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); + DECL_LINK(ExpandingHdl, const weld::TreeIter&, bool); + DECL_LINK(CollapsingHdl, const weld::TreeIter&, bool); -// class IndexTabPage_Impl ----------------------------------------------- - -class IndexBox_Impl : public ComboBox -{ + void ClearChildren(weld::TreeIter* pParent); + void InitRoot(); public: - IndexBox_Impl(vcl::Window* pParent, WinBits nStyle); + ContentTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* _pIdxWin); + virtual ~ContentTabPage_Impl() override; - virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; - virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual weld::Widget* GetLastFocusControl() override; - void SelectExecutableEntry(); + void SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink); + OUString GetSelectedEntry() const; + void SetFocusOnBox() { m_xContentBox->grab_focus(); } }; class IndexTabPage_Impl : public HelpTabPage_Impl { private: - VclPtr<IndexBox_Impl> m_pIndexCB; - VclPtr<PushButton> m_pOpenBtn; + std::unique_ptr<weld::Entry> m_xIndexEntry; + std::unique_ptr<weld::TreeView> m_xIndexList; + std::unique_ptr<weld::Button> m_xOpenBtn; Idle aFactoryIdle; + Idle aAutoCompleteIdle; Timer aKeywordTimer; Link<IndexTabPage_Impl&,void> aKeywordLink; @@ -135,211 +102,182 @@ private: OUString sKeyword; bool bIsActivated; + int nRowHeight; + int nAllHeight; void InitializeIndex(); void ClearIndex(); - DECL_LINK(OpenHdl, Button*, void); + Link<LinkParamNone*, void> aDoubleClickHdl; + + DECL_LINK(OpenHdl, weld::Button&, void); DECL_LINK(IdleHdl, Timer*, void); + DECL_LINK(AutoCompleteHdl, Timer*, void); DECL_LINK(TimeoutHdl, Timer*, void); + DECL_LINK(TreeChangeHdl, weld::TreeView&, void); + DECL_LINK(EntryChangeHdl, weld::Entry&, void); + DECL_LINK(ActivateHdl, weld::Entry&, bool); + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(CustomGetSizeHdl, weld::TreeView::get_size_args, Size); + DECL_LINK(CustomRenderHdl, weld::TreeView::render_args, void); + DECL_LINK(ResizeHdl, const Size&, void); + + int starts_with(const OUString& rStr, int nStartRow, bool bCaseSensitive); public: - IndexTabPage_Impl( vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ); + IndexTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* pIdxWin); virtual ~IndexTabPage_Impl() override; - virtual void dispose() override; - virtual void ActivatePage() override; - virtual Control* GetLastFocusControl() override; + virtual void Activate() override; + virtual weld::Widget* GetLastFocusControl() override; - void SetDoubleClickHdl( const Link<ComboBox&,void>& rLink ); + void SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink); void SetFactory( const OUString& rFactory ); const OUString& GetFactory() const { return sFactory; } OUString GetSelectedEntry() const; - void SetFocusOnBox() { m_pIndexCB->GrabFocus(); } - bool HasFocusOnEdit() const { return m_pIndexCB->HasChildPathFocus(); } + void SetFocusOnBox() { m_xIndexEntry->grab_focus(); } + bool HasFocusOnEdit() const { return m_xIndexEntry->has_focus(); } - void SetKeywordHdl( const Link<IndexTabPage_Impl&,void>& rLink ) { aKeywordLink = rLink; } + void SetKeywordHdl( const Link<IndexTabPage_Impl&,void>& rLink ) { aKeywordLink = rLink; } void SetKeyword( const OUString& rKeyword ); bool HasKeyword() const; bool HasKeywordIgnoreCase(); void OpenKeyword(); - void SelectExecutableEntry() { m_pIndexCB->SelectExecutableEntry(); } -}; - -// class SearchTabPage_Impl ---------------------------------------------- - -class SearchBox_Impl : public ComboBox -{ -private: - Link<LinkParamNone*,void> aSearchLink; - -public: - SearchBox_Impl(vcl::Window* pParent, WinBits nStyle) - : ComboBox(pParent, nStyle) - { - SetDropDownLineCount(5); - } - - virtual bool PreNotify( NotifyEvent& rNEvt ) override; - virtual void Select() override; - - void SetSearchLink( const Link<LinkParamNone*,void>& rLink ) { aSearchLink = rLink; } -}; - -class SearchResultsBox_Impl : public ListBox -{ -public: - SearchResultsBox_Impl(vcl::Window* pParent, WinBits nStyle) - : ListBox(pParent, nStyle) - { - } - - virtual bool EventNotify( NotifyEvent& rNEvt ) override; + void SelectExecutableEntry(); }; class SearchTabPage_Impl : public HelpTabPage_Impl { private: - VclPtr<SearchBox_Impl> m_pSearchED; - VclPtr<PushButton> m_pSearchBtn; - VclPtr<CheckBox> m_pFullWordsCB; - VclPtr<CheckBox> m_pScopeCB; - VclPtr<SearchResultsBox_Impl> m_pResultsLB; - VclPtr<PushButton> m_pOpenBtn; + std::unique_ptr<weld::ComboBox> m_xSearchED; + std::unique_ptr<weld::Button> m_xSearchBtn; + std::unique_ptr<weld::CheckButton> m_xFullWordsCB; + std::unique_ptr<weld::CheckButton> m_xScopeCB; + std::unique_ptr<weld::TreeView> m_xResultsLB; + std::unique_ptr<weld::Button> m_xOpenBtn; + + Link<LinkParamNone*, void> aDoubleClickHdl; OUString aFactory; css::uno::Reference< css::i18n::XBreakIterator > xBreakIterator; - void ClearSearchResults(); - void RememberSearchText( const OUString& rSearchText ); + void ClearSearchResults(); + void RememberSearchText( const OUString& rSearchText ); + void Search(); - DECL_LINK(SearchHdl, LinkParamNone*, void); - DECL_LINK(ClickHdl, Button*, void); - DECL_LINK(OpenHdl, Button*, void); - DECL_LINK(ModifyHdl, Edit&, void); + DECL_LINK(ClickHdl, weld::Button&, void); + DECL_LINK(OpenHdl, weld::Button&, void); + DECL_LINK(ModifyHdl, weld::ComboBox&, void); + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); + DECL_LINK(ActivateHdl, weld::ComboBox&, bool); public: - SearchTabPage_Impl( vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ); + SearchTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* pIdxWin); virtual ~SearchTabPage_Impl() override; - virtual void dispose() override; - virtual void ActivatePage() override; - virtual Control* GetLastFocusControl() override; + virtual weld::Widget* GetLastFocusControl() override; - void SetDoubleClickHdl( const Link<ListBox&,void>& rLink ); + void SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink); void SetFactory( const OUString& rFactory ) { aFactory = rFactory; } - OUString GetSelectedEntry() const; - void ClearPage(); - void SetFocusOnBox() { m_pResultsLB->GrabFocus(); } - bool HasFocusOnEdit() const { return m_pSearchED->HasChildPathFocus(); } - OUString GetSearchText() const { return m_pSearchED->GetText(); } - bool IsFullWordSearch() const { return m_pFullWordsCB->IsChecked(); } - bool OpenKeyword( const OUString& rKeyword ); + OUString GetSelectedEntry() const; + void ClearPage(); + void SetFocusOnBox() { m_xResultsLB->grab_focus(); } + bool HasFocusOnEdit() const { return m_xSearchED->has_focus(); } + OUString GetSearchText() const { return m_xSearchED->get_active_text(); } + bool IsFullWordSearch() const { return m_xFullWordsCB->get_active(); } + bool OpenKeyword( const OUString& rKeyword ); }; -// class BookmarksTabPage_Impl ------------------------------------------- - -class BookmarksBox_Impl : public ListBox +class BookmarksTabPage_Impl : public HelpTabPage_Impl { private: - void DoAction( sal_uInt16 nAction ); - -public: - BookmarksBox_Impl(vcl::Window* pParent, WinBits nStyle); - virtual ~BookmarksBox_Impl() override; - virtual void dispose() override; + std::unique_ptr<weld::TreeView> m_xBookmarksBox; + std::unique_ptr<weld::Button> m_xBookmarksPB; - virtual bool EventNotify( NotifyEvent& rNEvt ) override; -}; + Link<LinkParamNone*, void> aDoubleClickHdl; -class BookmarksTabPage_Impl : public HelpTabPage_Impl -{ -private: - VclPtr<BookmarksBox_Impl> m_pBookmarksBox; - VclPtr<PushButton> m_pBookmarksPB; + DECL_LINK(OpenHdl, weld::Button&, void); + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); + DECL_LINK(CommandHdl, const CommandEvent&, bool); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); - DECL_LINK(OpenHdl, Button*, void); + void DoAction(const OString& rAction); public: - BookmarksTabPage_Impl( vcl::Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ); + BookmarksTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow_Impl* pIdxWin); virtual ~BookmarksTabPage_Impl() override; - virtual void dispose() override; - virtual void ActivatePage() override; - virtual Control* GetLastFocusControl() override; + virtual weld::Widget* GetLastFocusControl() override; - void SetDoubleClickHdl( const Link<ListBox&,void>& rLink ); + void SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink); OUString GetSelectedEntry() const; void AddBookmarks( const OUString& rTitle, const OUString& rURL ); - void SetFocusOnBox() { m_pBookmarksBox->GrabFocus(); } + void SetFocusOnBox() { m_xBookmarksBox->grab_focus(); } }; // class SfxHelpIndexWindow_Impl ----------------------------------------- class SfxHelpWindow_Impl; -class SfxHelpIndexWindow_Impl : public vcl::Window, public VclBuilderContainer +class SfxHelpIndexWindow_Impl { private: - VclPtr<ListBox> m_pActiveLB; - VclPtr<TabControl> m_pTabCtrl; + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::ComboBox> m_xActiveLB; + std::unique_ptr<weld::Notebook> m_xTabCtrl; Idle aIdle; Link<SfxHelpIndexWindow_Impl*,void> aSelectFactoryLink; - Link<Control*,bool> aPageDoubleClickLink; + Link<LinkParamNone*,void> aPageDoubleClickLink; Link<IndexTabPage_Impl&,void> aIndexKeywordLink; OUString sKeyword; VclPtr<SfxHelpWindow_Impl> pParentWin; - VclPtr<ContentTabPage_Impl> pCPage; - VclPtr<IndexTabPage_Impl> pIPage; - VclPtr<SearchTabPage_Impl> pSPage; - VclPtr<BookmarksTabPage_Impl> pBPage; + std::unique_ptr<ContentTabPage_Impl> xCPage; + std::unique_ptr<IndexTabPage_Impl> xIPage; + std::unique_ptr<SearchTabPage_Impl> xSPage; + std::unique_ptr<BookmarksTabPage_Impl> xBPage; - bool bWasCursorLeftOrRight; bool bIsInitDone; void Initialize(); void SetActiveFactory(); - HelpTabPage_Impl* GetCurrentPage( sal_uInt16& rCurId ); + HelpTabPage_Impl* GetPage(const OString&); + HelpTabPage_Impl* GetCurrentPage(); inline ContentTabPage_Impl* GetContentPage(); inline IndexTabPage_Impl* GetIndexPage(); inline SearchTabPage_Impl* GetSearchPage(); inline BookmarksTabPage_Impl* GetBookmarksPage(); - DECL_LINK(ActivatePageHdl, TabControl*, void ); - DECL_LINK(SelectHdl, ListBox&, void); + DECL_LINK(ActivatePageHdl, const OString&, void); + DECL_LINK(SelectHdl, weld::ComboBox&, void); DECL_LINK(InitHdl, Timer *, void); DECL_LINK(SelectFactoryHdl, Timer *, void); DECL_LINK(KeywordHdl, IndexTabPage_Impl&, void); - DECL_LINK(ContentTabPageDoubleClickHdl, SvTreeListBox*, bool); - DECL_LINK(TabPageDoubleClickHdl, ListBox&, void); - DECL_LINK(IndexTabPageDoubleClickHdl, ComboBox&, void); + DECL_LINK(ContentTabPageDoubleClickHdl, LinkParamNone*, void); + DECL_LINK(TabPageDoubleClickHdl, LinkParamNone*, void); + DECL_LINK(IndexTabPageDoubleClickHdl, LinkParamNone*, void); public: - explicit SfxHelpIndexWindow_Impl( SfxHelpWindow_Impl* pParent ); - virtual ~SfxHelpIndexWindow_Impl() override; - virtual void dispose() override; - - virtual void Resize() override; - virtual Size GetOptimalSize() const override; - virtual bool PreNotify( NotifyEvent& rNEvt ) override; - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + explicit SfxHelpIndexWindow_Impl(SfxHelpWindow_Impl* pParent, weld::Container* pContainer); + ~SfxHelpIndexWindow_Impl(); - void SetDoubleClickHdl( const Link<Control*,bool>& rLink ); - void SetSelectFactoryHdl( const Link<SfxHelpIndexWindow_Impl*,void>& rLink ) { aSelectFactoryLink = rLink; } + void SetDoubleClickHdl(const Link<LinkParamNone*, void>& rLink); + void SetSelectFactoryHdl( const Link<SfxHelpIndexWindow_Impl*,void>& rLink ) { aSelectFactoryLink = rLink; } void SetFactory( const OUString& rFactory, bool bActive ); - OUString const & GetFactory() const { return pIPage->GetFactory(); } + OUString const & GetFactory() const { return xIPage->GetFactory(); } OUString GetSelectedEntry() const; void AddBookmarks( const OUString& rTitle, const OUString& rURL ); bool IsValidFactory( const OUString& _rFactory ); - OUString GetActiveFactoryTitle() const { return m_pActiveLB->GetSelectedEntry(); } + OUString GetActiveFactoryTitle() const { return m_xActiveLB->get_active_text(); } void ClearSearchPage(); void GrabFocusBack(); bool HasFocusOnEdit() const; @@ -347,60 +285,54 @@ public: bool IsFullWordSearch() const; void OpenKeyword( const OUString& rKeyword ); void SelectExecutableEntry(); - inline bool WasCursorLeftOrRight(); + + weld::Window* GetFrameWeld() const; }; // inlines --------------------------------------------------------------- ContentTabPage_Impl* SfxHelpIndexWindow_Impl::GetContentPage() { - if ( !pCPage ) + if (!xCPage) { - pCPage = VclPtr<ContentTabPage_Impl>::Create( m_pTabCtrl, this ); - pCPage->SetOpenHdl( LINK(this, SfxHelpIndexWindow_Impl, ContentTabPageDoubleClickHdl) ); + xCPage.reset(new ContentTabPage_Impl(m_xTabCtrl->get_page("contents"), this)); + xCPage->SetDoubleClickHdl(LINK(this, SfxHelpIndexWindow_Impl, ContentTabPageDoubleClickHdl)); } - return pCPage; + return xCPage.get(); } + IndexTabPage_Impl* SfxHelpIndexWindow_Impl::GetIndexPage() { - if ( !pIPage ) + if (!xIPage) { - pIPage = VclPtr<IndexTabPage_Impl>::Create( m_pTabCtrl, this ); - pIPage->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl, IndexTabPageDoubleClickHdl) ); - pIPage->SetKeywordHdl( aIndexKeywordLink ); + xIPage.reset(new IndexTabPage_Impl(m_xTabCtrl->get_page("index"), this)); + xIPage->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl, IndexTabPageDoubleClickHdl) ); + xIPage->SetKeywordHdl( aIndexKeywordLink ); } - return pIPage; + return xIPage.get(); } SearchTabPage_Impl* SfxHelpIndexWindow_Impl::GetSearchPage() { - if ( !pSPage ) + if (!xSPage) { - pSPage = VclPtr<SearchTabPage_Impl>::Create( m_pTabCtrl, this ); - pSPage->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl, TabPageDoubleClickHdl) ); + xSPage.reset(new SearchTabPage_Impl(m_xTabCtrl->get_page("find"), this)); + xSPage->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl, TabPageDoubleClickHdl) ); } - return pSPage; + return xSPage.get(); } BookmarksTabPage_Impl* SfxHelpIndexWindow_Impl::GetBookmarksPage() { - if ( !pBPage ) + if (!xBPage) { - pBPage = VclPtr<BookmarksTabPage_Impl>::Create( m_pTabCtrl, this ); - pBPage->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl, TabPageDoubleClickHdl) ); + xBPage.reset(new BookmarksTabPage_Impl(m_xTabCtrl->get_page("bookmarks"), this)); + xBPage->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl, TabPageDoubleClickHdl) ); } - return pBPage; -} - -bool SfxHelpIndexWindow_Impl::WasCursorLeftOrRight() -{ - bool bRet = bWasCursorLeftOrRight; - bWasCursorLeftOrRight = false; - return bRet; + return xBPage.get(); } // class TextWin_Impl ---------------------------------------------------- - class TextWin_Impl : public DockingWindow { public: @@ -417,18 +349,19 @@ class SfxHelpWindow_Impl; class SfxHelpTextWindow_Impl : public vcl::Window { private: - VclPtr<ToolBox> aToolBox; - VclPtr<CheckBox> aOnStartupCB; + std::unique_ptr<weld::Toolbar> xToolBox; + std::unique_ptr<weld::CheckButton> xOnStartupCB; + std::unique_ptr<weld::Menu> xMenu; Idle aSelectIdle; - Image aIndexOnImage; - Image aIndexOffImage; + OUString aIndexOnImage; + OUString aIndexOffImage; OUString aIndexOnText; OUString aIndexOffText; OUString aSearchText; OUString aOnStartupText; OUString sCurrentFactory; - VclPtr<SfxHelpWindow_Impl> pHelpWin; + VclPtr<SfxHelpWindow_Impl> xHelpWin; VclPtr<vcl::Window> pTextWin; std::shared_ptr<sfx2::SearchDialog> m_xSrchDlg; css::uno::Reference < css::frame::XFrame2 > @@ -437,7 +370,6 @@ private: xBreakIterator; css::uno::Reference< css::uno::XInterface > xConfiguration; - long nMinPos; bool bIsDebug; bool bIsIndexOn; bool bIsInClose; @@ -446,7 +378,6 @@ private: bool HasSelection() const; void InitToolBoxImages(); void InitOnStartupBox(); - void SetOnStartupBoxPosition(); css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIterator(); @@ -458,11 +389,11 @@ private: DECL_LINK( NotifyHdl, LinkParamNone*, void ); DECL_LINK( FindHdl, sfx2::SearchDialog&, void ); DECL_LINK( CloseHdl, LinkParamNone*, void ); - DECL_LINK( CheckHdl, Button*, void ); + DECL_LINK( CheckHdl, weld::Button&, void ); void FindHdl(sfx2::SearchDialog*); public: - explicit SfxHelpTextWindow_Impl( SfxHelpWindow_Impl* pParent ); + explicit SfxHelpTextWindow_Impl(SfxHelpWindow_Impl* pHelpWin, weld::Builder& rBuilder, vcl::Window* pParent); virtual ~SfxHelpTextWindow_Impl() override; virtual void dispose() override; @@ -474,11 +405,11 @@ public: const css::uno::Reference < css::frame::XFrame2 >& getFrame() const { return xFrame; } - void SetSelectHdl( const Link<ToolBox *, void>& rLink ) { aToolBox->SetSelectHdl( rLink ); } + void SetSelectHdl(const Link<const OString&, void>& rLink) { xToolBox->connect_clicked(rLink); } void ToggleIndex( bool bOn ); void SelectSearchText( const OUString& rSearchText, bool _bIsFullWordSearch ); void SetPageStyleHeaderOff() const; - ToolBox& GetToolBox() { return *aToolBox; } + weld::Toolbar& GetToolBox() { return *xToolBox; } void CloseFrame(); void DoSearch(); }; @@ -487,45 +418,50 @@ public: class HelpInterceptor_Impl; class HelpListener_Impl; -class SfxHelpWindow_Impl : public SplitWindow +class SfxHelpWindow_Impl : public DockingWindow { private: friend class SfxHelpIndexWindow_Impl; + std::unique_ptr<weld::Builder> m_xBuilder; + VclPtr<vcl::Window> m_xVclContentArea; + std::unique_ptr<weld::Paned> m_xContainer; + std::unique_ptr<weld::Container> m_xHelpPaneWindow; + std::unique_ptr<weld::Container> m_xHelpTextWindow; + css::uno::Reference<css::awt::XWindow> m_xHelpTextXWindow; + css::uno::Reference < css::awt::XWindow > xWindow; css::uno::Reference < css::frame::XFrame2 > xFrame; - VclPtr<SfxHelpIndexWindow_Impl> pIndexWin; + std::unique_ptr<SfxHelpIndexWindow_Impl> xIndexWin; VclPtr<SfxHelpTextWindow_Impl> pTextWin; HelpInterceptor_Impl* pHelpInterceptor; rtl::Reference<HelpListener_Impl> pHelpListener; - sal_Int32 nExpandWidth; - sal_Int32 nCollapseWidth; - sal_Int32 nHeight; - long nIndexSize; - long nTextSize; bool bIndex; bool bGrabFocusToToolBox; + bool bSplit; + int nWidth; + int nIndexSize; Point aWinPos; + Size aWinSize; OUString sTitle; - virtual void Resize() override; - virtual void Split() override; virtual void GetFocus() override; void MakeLayout(); - void InitSizes(); void LoadConfig(); void SaveConfig(); void ShowStartPage(); + void Split(); - DECL_LINK( SelectHdl, ToolBox*, void ); - DECL_LINK( OpenHdl, Control*, bool ); - DECL_LINK( SelectFactoryHdl, SfxHelpIndexWindow_Impl*, void ); - DECL_LINK( ChangeHdl, HelpListener_Impl&, void ); + DECL_LINK(SelectHdl, const OString&, void); + DECL_LINK(OpenHdl, LinkParamNone*, void); + DECL_LINK(SelectFactoryHdl, SfxHelpIndexWindow_Impl*, void); + DECL_LINK(ChangeHdl, HelpListener_Impl&, void); + DECL_LINK(ResizeHdl, const Size&, void); public: SfxHelpWindow_Impl( const css::uno::Reference < css::frame::XFrame2 >& rFrame, @@ -541,11 +477,13 @@ public: void SetFactory( const OUString& rFactory ); void SetHelpURL( const OUString& rURL ); - void DoAction( sal_uInt16 nActionId ); + void DoAction(const OString& rAction); void CloseWindow(); + weld::Container* GetContainer() { return m_xHelpTextWindow.get(); } + void UpdateToolbox(); - void OpenKeyword( const OUString& rKeyword ) { pIndexWin->OpenKeyword( rKeyword ); } + void OpenKeyword( const OUString& rKeyword ) { xIndexWin->OpenKeyword( rKeyword ); } bool HasHistoryPredecessor() const; // forward to interceptor bool HasHistorySuccessor() const; // forward to interceptor @@ -567,7 +505,7 @@ private: std::unique_ptr<weld::Entry> m_xTitleED; std::unique_ptr<weld::Label> m_xAltTitle; public: - SfxAddHelpBookmarkDialog_Impl(weld::Window* pParent, bool bRename); + SfxAddHelpBookmarkDialog_Impl(weld::Widget* pParent, bool bRename); void SetTitle( const OUString& rTitle ); OUString GetTitle() const { return m_xTitleED->get_text(); } |