1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SFX2_SOURCE_APPL_NEWHELP_HXX
20 #define INCLUDED_SFX2_SOURCE_APPL_NEWHELP_HXX
22 #include <com/sun/star/uno/Reference.h>
23 #include <com/sun/star/frame/XFrame2.hpp>
25 #include <rtl/ustrbuf.hxx>
26 #include <vcl/builderpage.hxx>
27 #include <vcl/dockwin.hxx>
28 #include <vcl/idle.hxx>
29 #include <vcl/keycod.hxx>
30 #include <vcl/weld.hxx>
31 #include <vcl/window.hxx>
33 #include <srchdlg.hxx>
40 namespace com::sun::star::awt
{ class XWindow
; }
41 namespace com::sun::star::i18n
{ class XBreakIterator
; }
42 namespace com::sun::star::text
{ class XTextRange
; }
44 // class HelpTabPage_Impl ------------------------------------------------
46 class SfxHelpIndexWindow_Impl
;
48 class HelpTabPage_Impl
: public BuilderPage
51 SfxHelpIndexWindow_Impl
* m_pIdxWin
;
54 HelpTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
,
55 const OUString
& rID
, const OUString
& rUIXMLDescription
);
56 virtual ~HelpTabPage_Impl() override
;
59 // class ContentTabPage_Impl ---------------------------------------------
61 class ContentTabPage_Impl
: public HelpTabPage_Impl
64 std::unique_ptr
<weld::TreeView
> m_xContentBox
;
65 std::unique_ptr
<weld::TreeIter
> m_xScratchIter
;
66 OUString aOpenBookImage
;
67 OUString aClosedBookImage
;
68 OUString aDocumentImage
;
70 Link
<LinkParamNone
*, void> aDoubleClickHdl
;
72 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
73 DECL_LINK(ExpandingHdl
, const weld::TreeIter
&, bool);
74 DECL_LINK(CollapsingHdl
, const weld::TreeIter
&, bool);
76 void ClearChildren(const weld::TreeIter
* pParent
);
79 ContentTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
80 virtual ~ContentTabPage_Impl() override
;
82 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
83 OUString
GetSelectedEntry() const;
84 void SetFocusOnBox() { m_xContentBox
->grab_focus(); }
87 class IndexTabPage_Impl
: public HelpTabPage_Impl
90 std::unique_ptr
<weld::Entry
> m_xIndexEntry
;
91 std::unique_ptr
<weld::TreeView
> m_xIndexList
;
92 std::unique_ptr
<weld::Button
> m_xOpenBtn
;
95 Idle aAutoCompleteIdle
;
97 Link
<IndexTabPage_Impl
&,void> aKeywordLink
;
105 sal_uInt16 nLastCharCode
;
107 void InitializeIndex();
110 Link
<LinkParamNone
*, void> aDoubleClickHdl
;
112 DECL_LINK(OpenHdl
, weld::Button
&, void);
113 DECL_LINK(IdleHdl
, Timer
*, void);
114 DECL_LINK(AutoCompleteHdl
, Timer
*, void);
115 DECL_LINK(TimeoutHdl
, Timer
*, void);
116 DECL_LINK(TreeChangeHdl
, weld::TreeView
&, void);
117 DECL_LINK(EntryChangeHdl
, weld::Entry
&, void);
118 DECL_LINK(ActivateHdl
, weld::Entry
&, bool);
119 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
120 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
121 DECL_LINK(CustomGetSizeHdl
, weld::TreeView::get_size_args
, Size
);
122 DECL_LINK(CustomRenderHdl
, weld::TreeView::render_args
, void);
123 DECL_LINK(ResizeHdl
, const Size
&, void);
125 int starts_with(const OUString
& rStr
, int nStartRow
, bool bCaseSensitive
);
128 IndexTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* pIdxWin
);
129 virtual ~IndexTabPage_Impl() override
;
131 virtual void Activate() override
;
133 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
134 void SetFactory( const OUString
& rFactory
);
135 const OUString
& GetFactory() const { return sFactory
; }
136 OUString
GetSelectedEntry() const;
137 void SetFocusOnBox() { m_xIndexEntry
->grab_focus(); }
138 bool HasFocusOnEdit() const { return m_xIndexEntry
->has_focus(); }
140 void SetKeywordHdl( const Link
<IndexTabPage_Impl
&,void>& rLink
) { aKeywordLink
= rLink
; }
141 void SetKeyword( const OUString
& rKeyword
);
142 bool HasKeyword() const;
143 bool HasKeywordIgnoreCase();
146 void SelectExecutableEntry();
149 class SearchTabPage_Impl
: public HelpTabPage_Impl
152 std::unique_ptr
<weld::ComboBox
> m_xSearchED
;
153 std::unique_ptr
<weld::Button
> m_xSearchBtn
;
154 std::unique_ptr
<weld::CheckButton
> m_xFullWordsCB
;
155 std::unique_ptr
<weld::CheckButton
> m_xScopeCB
;
156 std::unique_ptr
<weld::TreeView
> m_xResultsLB
;
157 std::unique_ptr
<weld::Button
> m_xOpenBtn
;
159 Link
<LinkParamNone
*, void> aDoubleClickHdl
;
163 css::uno::Reference
< css::i18n::XBreakIterator
>
166 void ClearSearchResults();
167 void RememberSearchText( const OUString
& rSearchText
);
170 DECL_LINK(ClickHdl
, weld::Button
&, void);
171 DECL_LINK(OpenHdl
, weld::Button
&, void);
172 DECL_LINK(ModifyHdl
, weld::ComboBox
&, void);
173 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
174 DECL_LINK(ActivateHdl
, weld::ComboBox
&, bool);
177 SearchTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* pIdxWin
);
178 virtual ~SearchTabPage_Impl() override
;
180 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
181 void SetFactory( const OUString
& rFactory
) { aFactory
= rFactory
; }
182 OUString
GetSelectedEntry() const;
184 void SetFocusOnBox() { m_xResultsLB
->grab_focus(); }
185 bool HasFocusOnEdit() const { return m_xSearchED
->has_focus(); }
186 OUString
GetSearchText() const { return m_xSearchED
->get_active_text(); }
187 bool IsFullWordSearch() const { return m_xFullWordsCB
->get_active(); }
188 bool OpenKeyword( const OUString
& rKeyword
);
191 class BookmarksTabPage_Impl
: public HelpTabPage_Impl
194 std::unique_ptr
<weld::TreeView
> m_xBookmarksBox
;
195 std::unique_ptr
<weld::Button
> m_xBookmarksPB
;
197 Link
<LinkParamNone
*, void> aDoubleClickHdl
;
199 DECL_LINK(OpenHdl
, weld::Button
&, void);
200 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
201 DECL_LINK(CommandHdl
, const CommandEvent
&, bool);
202 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
204 void DoAction(std::u16string_view rAction
);
207 BookmarksTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* pIdxWin
);
208 virtual ~BookmarksTabPage_Impl() override
;
210 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
211 OUString
GetSelectedEntry() const;
212 void AddBookmarks( const OUString
& rTitle
, const OUString
& rURL
);
213 void SetFocusOnBox() { m_xBookmarksBox
->grab_focus(); }
216 // class SfxHelpIndexWindow_Impl -----------------------------------------
218 class SfxHelpWindow_Impl
;
220 class SfxHelpIndexWindow_Impl
223 std::unique_ptr
<weld::Builder
> m_xBuilder
;
224 std::unique_ptr
<weld::Container
> m_xContainer
;
225 std::unique_ptr
<weld::ComboBox
> m_xActiveLB
;
226 std::unique_ptr
<weld::Notebook
> m_xTabCtrl
;
230 Link
<SfxHelpIndexWindow_Impl
*,void> aSelectFactoryLink
;
231 Link
<LinkParamNone
*,void> aPageDoubleClickLink
;
232 Link
<IndexTabPage_Impl
&,void> aIndexKeywordLink
;
235 VclPtr
<SfxHelpWindow_Impl
> pParentWin
;
237 std::unique_ptr
<ContentTabPage_Impl
> xCPage
;
238 std::unique_ptr
<IndexTabPage_Impl
> xIPage
;
239 std::unique_ptr
<SearchTabPage_Impl
> xSPage
;
240 std::unique_ptr
<BookmarksTabPage_Impl
> xBPage
;
245 void SetActiveFactory();
246 HelpTabPage_Impl
* GetPage(std::u16string_view
);
248 inline ContentTabPage_Impl
* GetContentPage();
249 inline IndexTabPage_Impl
* GetIndexPage();
250 inline SearchTabPage_Impl
* GetSearchPage();
251 inline BookmarksTabPage_Impl
* GetBookmarksPage();
253 DECL_LINK(ActivatePageHdl
, const OUString
&, void);
254 DECL_LINK(SelectHdl
, weld::ComboBox
&, void);
255 DECL_LINK(InitHdl
, Timer
*, void);
256 DECL_LINK(SelectFactoryHdl
, Timer
*, void);
257 DECL_LINK(KeywordHdl
, IndexTabPage_Impl
&, void);
258 DECL_LINK(ContentTabPageDoubleClickHdl
, LinkParamNone
*, void);
259 DECL_LINK(TabPageDoubleClickHdl
, LinkParamNone
*, void);
260 DECL_LINK(IndexTabPageDoubleClickHdl
, LinkParamNone
*, void);
263 explicit SfxHelpIndexWindow_Impl(SfxHelpWindow_Impl
* pParent
, weld::Container
* pContainer
);
264 ~SfxHelpIndexWindow_Impl();
266 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
267 void SetSelectFactoryHdl( const Link
<SfxHelpIndexWindow_Impl
*,void>& rLink
) { aSelectFactoryLink
= rLink
; }
268 void SetFactory( const OUString
& rFactory
, bool bActive
);
269 OUString
const & GetFactory() const { return xIPage
->GetFactory(); }
270 OUString
GetSelectedEntry() const;
271 void AddBookmarks( const OUString
& rTitle
, const OUString
& rURL
);
272 bool IsValidFactory( std::u16string_view _rFactory
);
273 OUString
GetActiveFactoryTitle() const { return m_xActiveLB
->get_active_text(); }
274 void ClearSearchPage();
275 void GrabFocusBack();
276 bool HasFocusOnEdit() const;
277 OUString
GetSearchText() const;
278 bool IsFullWordSearch() const;
279 void OpenKeyword( const OUString
& rKeyword
);
280 void SelectExecutableEntry();
282 weld::Window
* GetFrameWeld() const;
285 // inlines ---------------------------------------------------------------
287 ContentTabPage_Impl
* SfxHelpIndexWindow_Impl::GetContentPage()
291 xCPage
.reset(new ContentTabPage_Impl(m_xTabCtrl
->get_page(u
"contents"_ustr
), this));
292 xCPage
->SetDoubleClickHdl(LINK(this, SfxHelpIndexWindow_Impl
, ContentTabPageDoubleClickHdl
));
297 IndexTabPage_Impl
* SfxHelpIndexWindow_Impl::GetIndexPage()
301 xIPage
.reset(new IndexTabPage_Impl(m_xTabCtrl
->get_page(u
"index"_ustr
), this));
302 xIPage
->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl
, IndexTabPageDoubleClickHdl
) );
303 xIPage
->SetKeywordHdl( aIndexKeywordLink
);
308 SearchTabPage_Impl
* SfxHelpIndexWindow_Impl::GetSearchPage()
312 xSPage
.reset(new SearchTabPage_Impl(m_xTabCtrl
->get_page(u
"find"_ustr
), this));
313 xSPage
->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl
, TabPageDoubleClickHdl
) );
318 BookmarksTabPage_Impl
* SfxHelpIndexWindow_Impl::GetBookmarksPage()
322 xBPage
.reset(new BookmarksTabPage_Impl(m_xTabCtrl
->get_page(u
"bookmarks"_ustr
), this));
323 xBPage
->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl
, TabPageDoubleClickHdl
) );
328 // class TextWin_Impl ----------------------------------------------------
329 class TextWin_Impl
: public DockingWindow
332 explicit TextWin_Impl( vcl::Window
* pParent
);
334 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
337 // class SfxHelpTextWindow_Impl ------------------------------------------
339 class SvtMiscOptions
;
340 class SfxHelpWindow_Impl
;
342 class SfxHelpTextWindow_Impl
: public vcl::Window
345 std::unique_ptr
<weld::Toolbar
> xToolBox
;
346 std::unique_ptr
<weld::CheckButton
> xOnStartupCB
;
347 std::unique_ptr
<weld::Menu
> xMenu
;
349 OUString aIndexOnImage
;
350 OUString aIndexOffImage
;
351 OUString aIndexOnText
;
352 OUString aIndexOffText
;
353 OUString aSearchText
;
354 OUString aOnStartupText
;
355 OUString sCurrentFactory
;
357 VclPtr
<SfxHelpWindow_Impl
> xHelpWin
;
358 VclPtr
<vcl::Window
> pTextWin
;
359 std::shared_ptr
<sfx2::SearchDialog
> m_xSrchDlg
;
360 css::uno::Reference
< css::frame::XFrame2
>
362 css::uno::Reference
< css::i18n::XBreakIterator
>
364 css::uno::Reference
< css::uno::XInterface
>
369 bool bIsFullWordSearch
;
371 bool HasSelection() const;
372 void InitToolBoxImages();
373 void InitOnStartupBox();
375 css::uno::Reference
< css::i18n::XBreakIterator
> const &
377 css::uno::Reference
< css::text::XTextRange
>
379 bool isHandledKey( const vcl::KeyCode
& _rKeyCode
);
381 DECL_LINK( SelectHdl
, Timer
*, void);
382 DECL_LINK( NotifyHdl
, LinkParamNone
*, void );
383 DECL_LINK( FindHdl
, sfx2::SearchDialog
&, void );
384 DECL_LINK( CloseHdl
, LinkParamNone
*, void );
385 DECL_LINK( CheckHdl
, weld::Toggleable
&, void );
386 void FindHdl(sfx2::SearchDialog
*);
389 explicit SfxHelpTextWindow_Impl(SfxHelpWindow_Impl
* pHelpWin
, weld::Builder
& rBuilder
, vcl::Window
* pParent
);
390 virtual ~SfxHelpTextWindow_Impl() override
;
391 virtual void dispose() override
;
393 virtual void Resize() override
;
394 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
395 virtual void GetFocus() override
;
396 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
398 const css::uno::Reference
< css::frame::XFrame2
>&
399 getFrame() const { return xFrame
; }
401 void SetSelectHdl(const Link
<const OUString
&, void>& rLink
) { xToolBox
->connect_clicked(rLink
); }
402 void ToggleIndex( bool bOn
);
403 void SelectSearchText( const OUString
& rSearchText
, bool _bIsFullWordSearch
);
404 void SetPageStyleHeaderOff() const;
405 weld::Toolbar
& GetToolBox() { return *xToolBox
; }
410 // class SfxHelpWindow_Impl ----------------------------------------------
412 class HelpInterceptor_Impl
;
413 class HelpListener_Impl
;
414 class SfxHelpWindow_Impl
: public ResizableDockingWindow
417 friend class SfxHelpIndexWindow_Impl
;
419 std::unique_ptr
<weld::Builder
> m_xBuilder
;
420 std::unique_ptr
<weld::Paned
> m_xContainer
;
421 std::unique_ptr
<weld::Container
> m_xHelpPaneWindow
;
422 std::unique_ptr
<weld::Container
> m_xHelpTextWindow
;
423 css::uno::Reference
<css::awt::XWindow
> m_xHelpTextXWindow
;
425 css::uno::Reference
< css::awt::XWindow
>
427 css::uno::Reference
< css::frame::XFrame2
>
430 std::unique_ptr
<SfxHelpIndexWindow_Impl
> xIndexWin
;
431 VclPtr
<SfxHelpTextWindow_Impl
> pTextWin
;
432 HelpInterceptor_Impl
* pHelpInterceptor
;
433 rtl::Reference
<HelpListener_Impl
> pHelpListener
;
436 bool bGrabFocusToToolBox
;
440 AbsoluteScreenPixelPoint aWinPos
;
444 virtual void GetFocus() override
;
449 void ShowStartPage();
452 DECL_LINK(SelectHdl
, const OUString
&, void);
453 DECL_LINK(OpenHdl
, LinkParamNone
*, void);
454 DECL_LINK(SelectFactoryHdl
, SfxHelpIndexWindow_Impl
*, void);
455 DECL_LINK(ChangeHdl
, HelpListener_Impl
&, void);
456 DECL_LINK(ResizeHdl
, const Size
&, void);
459 SfxHelpWindow_Impl( const css::uno::Reference
< css::frame::XFrame2
>& rFrame
,
460 vcl::Window
* pParent
);
461 virtual ~SfxHelpWindow_Impl() override
;
462 virtual void dispose() override
;
464 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
466 void setContainerWindow( const css::uno::Reference
< css::awt::XWindow
>& xWin
);
467 css::uno::Reference
< css::frame::XFrame2
> const &
468 getTextFrame() const { return pTextWin
->getFrame(); }
470 void SetFactory( const OUString
& rFactory
);
471 void SetHelpURL( std::u16string_view rURL
);
472 void DoAction(std::u16string_view rAction
);
475 weld::Container
* GetContainer() { return m_xHelpTextWindow
.get(); }
477 void UpdateToolbox();
478 void OpenKeyword( const OUString
& rKeyword
) { xIndexWin
->OpenKeyword( rKeyword
); }
480 bool HasHistoryPredecessor() const; // forward to interceptor
481 bool HasHistorySuccessor() const; // forward to interceptor
483 void openDone(std::u16string_view sURL
,
486 static OUString
buildHelpURL(std::u16string_view sFactory
,
487 std::u16string_view sContent
,
488 std::u16string_view sAnchor
);
490 void loadHelpContent(const OUString
& sHelpURL
,
491 bool bAddToHistory
= true);
494 class SfxAddHelpBookmarkDialog_Impl
: public weld::GenericDialogController
497 std::unique_ptr
<weld::Entry
> m_xTitleED
;
498 std::unique_ptr
<weld::Label
> m_xAltTitle
;
500 SfxAddHelpBookmarkDialog_Impl(weld::Widget
* pParent
, bool bRename
);
502 void SetTitle( const OUString
& rTitle
);
503 OUString
GetTitle() const { return m_xTitleED
->get_text(); }
506 /// Appends ?Language=xy&System=abc to the help URL in rURL
507 void AppendConfigToken(OUStringBuffer
& rURL
, bool bQuestionMark
);
509 #endif // INCLUDED_SFX2_SOURCE_APPL_NEWHELP_HXX
511 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */