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/weld.hxx>
30 #include <vcl/window.hxx>
32 #include <srchdlg.hxx>
39 namespace com::sun::star::awt
{ class XWindow
; }
40 namespace com::sun::star::i18n
{ class XBreakIterator
; }
41 namespace com::sun::star::text
{ class XTextRange
; }
43 // class HelpTabPage_Impl ------------------------------------------------
45 class SfxHelpIndexWindow_Impl
;
47 class HelpTabPage_Impl
: public BuilderPage
50 SfxHelpIndexWindow_Impl
* m_pIdxWin
;
53 HelpTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
,
54 const OString
& rID
, const OUString
& rUIXMLDescription
);
55 virtual ~HelpTabPage_Impl() override
;
58 // class ContentTabPage_Impl ---------------------------------------------
60 class ContentTabPage_Impl
: public HelpTabPage_Impl
63 std::unique_ptr
<weld::TreeView
> m_xContentBox
;
64 std::unique_ptr
<weld::TreeIter
> m_xScratchIter
;
65 OUString aOpenBookImage
;
66 OUString aClosedBookImage
;
67 OUString aDocumentImage
;
69 Link
<LinkParamNone
*, void> aDoubleClickHdl
;
71 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
72 DECL_LINK(ExpandingHdl
, const weld::TreeIter
&, bool);
73 DECL_LINK(CollapsingHdl
, const weld::TreeIter
&, bool);
75 void ClearChildren(const weld::TreeIter
* pParent
);
78 ContentTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
79 virtual ~ContentTabPage_Impl() override
;
81 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
82 OUString
GetSelectedEntry() const;
83 void SetFocusOnBox() { m_xContentBox
->grab_focus(); }
86 class IndexTabPage_Impl
: public HelpTabPage_Impl
89 std::unique_ptr
<weld::Entry
> m_xIndexEntry
;
90 std::unique_ptr
<weld::TreeView
> m_xIndexList
;
91 std::unique_ptr
<weld::Button
> m_xOpenBtn
;
94 Idle aAutoCompleteIdle
;
96 Link
<IndexTabPage_Impl
&,void> aKeywordLink
;
105 void InitializeIndex();
108 Link
<LinkParamNone
*, void> aDoubleClickHdl
;
110 DECL_LINK(OpenHdl
, weld::Button
&, void);
111 DECL_LINK(IdleHdl
, Timer
*, void);
112 DECL_LINK(AutoCompleteHdl
, Timer
*, void);
113 DECL_LINK(TimeoutHdl
, Timer
*, void);
114 DECL_LINK(TreeChangeHdl
, weld::TreeView
&, void);
115 DECL_LINK(EntryChangeHdl
, weld::Entry
&, void);
116 DECL_LINK(ActivateHdl
, weld::Entry
&, bool);
117 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
118 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
119 DECL_LINK(CustomGetSizeHdl
, weld::TreeView::get_size_args
, Size
);
120 DECL_LINK(CustomRenderHdl
, weld::TreeView::render_args
, void);
121 DECL_LINK(ResizeHdl
, const Size
&, void);
123 int starts_with(const OUString
& rStr
, int nStartRow
, bool bCaseSensitive
);
126 IndexTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* pIdxWin
);
127 virtual ~IndexTabPage_Impl() override
;
129 virtual void Activate() override
;
131 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
132 void SetFactory( const OUString
& rFactory
);
133 const OUString
& GetFactory() const { return sFactory
; }
134 OUString
GetSelectedEntry() const;
135 void SetFocusOnBox() { m_xIndexEntry
->grab_focus(); }
136 bool HasFocusOnEdit() const { return m_xIndexEntry
->has_focus(); }
138 void SetKeywordHdl( const Link
<IndexTabPage_Impl
&,void>& rLink
) { aKeywordLink
= rLink
; }
139 void SetKeyword( const OUString
& rKeyword
);
140 bool HasKeyword() const;
141 bool HasKeywordIgnoreCase();
144 void SelectExecutableEntry();
147 class SearchTabPage_Impl
: public HelpTabPage_Impl
150 std::unique_ptr
<weld::ComboBox
> m_xSearchED
;
151 std::unique_ptr
<weld::Button
> m_xSearchBtn
;
152 std::unique_ptr
<weld::CheckButton
> m_xFullWordsCB
;
153 std::unique_ptr
<weld::CheckButton
> m_xScopeCB
;
154 std::unique_ptr
<weld::TreeView
> m_xResultsLB
;
155 std::unique_ptr
<weld::Button
> m_xOpenBtn
;
157 Link
<LinkParamNone
*, void> aDoubleClickHdl
;
161 css::uno::Reference
< css::i18n::XBreakIterator
>
164 void ClearSearchResults();
165 void RememberSearchText( const OUString
& rSearchText
);
168 DECL_LINK(ClickHdl
, weld::Button
&, void);
169 DECL_LINK(OpenHdl
, weld::Button
&, void);
170 DECL_LINK(ModifyHdl
, weld::ComboBox
&, void);
171 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
172 DECL_LINK(ActivateHdl
, weld::ComboBox
&, bool);
175 SearchTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* pIdxWin
);
176 virtual ~SearchTabPage_Impl() override
;
178 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
179 void SetFactory( const OUString
& rFactory
) { aFactory
= rFactory
; }
180 OUString
GetSelectedEntry() const;
182 void SetFocusOnBox() { m_xResultsLB
->grab_focus(); }
183 bool HasFocusOnEdit() const { return m_xSearchED
->has_focus(); }
184 OUString
GetSearchText() const { return m_xSearchED
->get_active_text(); }
185 bool IsFullWordSearch() const { return m_xFullWordsCB
->get_active(); }
186 bool OpenKeyword( const OUString
& rKeyword
);
189 class BookmarksTabPage_Impl
: public HelpTabPage_Impl
192 std::unique_ptr
<weld::TreeView
> m_xBookmarksBox
;
193 std::unique_ptr
<weld::Button
> m_xBookmarksPB
;
195 Link
<LinkParamNone
*, void> aDoubleClickHdl
;
197 DECL_LINK(OpenHdl
, weld::Button
&, void);
198 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
199 DECL_LINK(CommandHdl
, const CommandEvent
&, bool);
200 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
202 void DoAction(const OString
& rAction
);
205 BookmarksTabPage_Impl(weld::Widget
* pParent
, SfxHelpIndexWindow_Impl
* pIdxWin
);
206 virtual ~BookmarksTabPage_Impl() override
;
208 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
209 OUString
GetSelectedEntry() const;
210 void AddBookmarks( const OUString
& rTitle
, const OUString
& rURL
);
211 void SetFocusOnBox() { m_xBookmarksBox
->grab_focus(); }
214 // class SfxHelpIndexWindow_Impl -----------------------------------------
216 class SfxHelpWindow_Impl
;
218 class SfxHelpIndexWindow_Impl
221 std::unique_ptr
<weld::Builder
> m_xBuilder
;
222 std::unique_ptr
<weld::Container
> m_xContainer
;
223 std::unique_ptr
<weld::ComboBox
> m_xActiveLB
;
224 std::unique_ptr
<weld::Notebook
> m_xTabCtrl
;
228 Link
<SfxHelpIndexWindow_Impl
*,void> aSelectFactoryLink
;
229 Link
<LinkParamNone
*,void> aPageDoubleClickLink
;
230 Link
<IndexTabPage_Impl
&,void> aIndexKeywordLink
;
233 VclPtr
<SfxHelpWindow_Impl
> pParentWin
;
235 std::unique_ptr
<ContentTabPage_Impl
> xCPage
;
236 std::unique_ptr
<IndexTabPage_Impl
> xIPage
;
237 std::unique_ptr
<SearchTabPage_Impl
> xSPage
;
238 std::unique_ptr
<BookmarksTabPage_Impl
> xBPage
;
243 void SetActiveFactory();
244 HelpTabPage_Impl
* GetPage(const OString
&);
246 inline ContentTabPage_Impl
* GetContentPage();
247 inline IndexTabPage_Impl
* GetIndexPage();
248 inline SearchTabPage_Impl
* GetSearchPage();
249 inline BookmarksTabPage_Impl
* GetBookmarksPage();
251 DECL_LINK(ActivatePageHdl
, const OString
&, void);
252 DECL_LINK(SelectHdl
, weld::ComboBox
&, void);
253 DECL_LINK(InitHdl
, Timer
*, void);
254 DECL_LINK(SelectFactoryHdl
, Timer
*, void);
255 DECL_LINK(KeywordHdl
, IndexTabPage_Impl
&, void);
256 DECL_LINK(ContentTabPageDoubleClickHdl
, LinkParamNone
*, void);
257 DECL_LINK(TabPageDoubleClickHdl
, LinkParamNone
*, void);
258 DECL_LINK(IndexTabPageDoubleClickHdl
, LinkParamNone
*, void);
261 explicit SfxHelpIndexWindow_Impl(SfxHelpWindow_Impl
* pParent
, weld::Container
* pContainer
);
262 ~SfxHelpIndexWindow_Impl();
264 void SetDoubleClickHdl(const Link
<LinkParamNone
*, void>& rLink
);
265 void SetSelectFactoryHdl( const Link
<SfxHelpIndexWindow_Impl
*,void>& rLink
) { aSelectFactoryLink
= rLink
; }
266 void SetFactory( const OUString
& rFactory
, bool bActive
);
267 OUString
const & GetFactory() const { return xIPage
->GetFactory(); }
268 OUString
GetSelectedEntry() const;
269 void AddBookmarks( const OUString
& rTitle
, const OUString
& rURL
);
270 bool IsValidFactory( const OUString
& _rFactory
);
271 OUString
GetActiveFactoryTitle() const { return m_xActiveLB
->get_active_text(); }
272 void ClearSearchPage();
273 void GrabFocusBack();
274 bool HasFocusOnEdit() const;
275 OUString
GetSearchText() const;
276 bool IsFullWordSearch() const;
277 void OpenKeyword( const OUString
& rKeyword
);
278 void SelectExecutableEntry();
280 weld::Window
* GetFrameWeld() const;
283 // inlines ---------------------------------------------------------------
285 ContentTabPage_Impl
* SfxHelpIndexWindow_Impl::GetContentPage()
289 xCPage
.reset(new ContentTabPage_Impl(m_xTabCtrl
->get_page("contents"), this));
290 xCPage
->SetDoubleClickHdl(LINK(this, SfxHelpIndexWindow_Impl
, ContentTabPageDoubleClickHdl
));
295 IndexTabPage_Impl
* SfxHelpIndexWindow_Impl::GetIndexPage()
299 xIPage
.reset(new IndexTabPage_Impl(m_xTabCtrl
->get_page("index"), this));
300 xIPage
->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl
, IndexTabPageDoubleClickHdl
) );
301 xIPage
->SetKeywordHdl( aIndexKeywordLink
);
306 SearchTabPage_Impl
* SfxHelpIndexWindow_Impl::GetSearchPage()
310 xSPage
.reset(new SearchTabPage_Impl(m_xTabCtrl
->get_page("find"), this));
311 xSPage
->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl
, TabPageDoubleClickHdl
) );
316 BookmarksTabPage_Impl
* SfxHelpIndexWindow_Impl::GetBookmarksPage()
320 xBPage
.reset(new BookmarksTabPage_Impl(m_xTabCtrl
->get_page("bookmarks"), this));
321 xBPage
->SetDoubleClickHdl( LINK(this, SfxHelpIndexWindow_Impl
, TabPageDoubleClickHdl
) );
326 // class TextWin_Impl ----------------------------------------------------
327 class TextWin_Impl
: public DockingWindow
330 explicit TextWin_Impl( vcl::Window
* pParent
);
332 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
335 // class SfxHelpTextWindow_Impl ------------------------------------------
337 class SvtMiscOptions
;
338 class SfxHelpWindow_Impl
;
340 class SfxHelpTextWindow_Impl
: public vcl::Window
343 std::unique_ptr
<weld::Toolbar
> xToolBox
;
344 std::unique_ptr
<weld::CheckButton
> xOnStartupCB
;
345 std::unique_ptr
<weld::Menu
> xMenu
;
347 OUString aIndexOnImage
;
348 OUString aIndexOffImage
;
349 OUString aIndexOnText
;
350 OUString aIndexOffText
;
351 OUString aSearchText
;
352 OUString aOnStartupText
;
353 OUString sCurrentFactory
;
355 VclPtr
<SfxHelpWindow_Impl
> xHelpWin
;
356 VclPtr
<vcl::Window
> pTextWin
;
357 std::shared_ptr
<sfx2::SearchDialog
> m_xSrchDlg
;
358 css::uno::Reference
< css::frame::XFrame2
>
360 css::uno::Reference
< css::i18n::XBreakIterator
>
362 css::uno::Reference
< css::uno::XInterface
>
367 bool bIsFullWordSearch
;
369 bool HasSelection() const;
370 void InitToolBoxImages();
371 void InitOnStartupBox();
373 css::uno::Reference
< css::i18n::XBreakIterator
> const &
375 css::uno::Reference
< css::text::XTextRange
>
377 bool isHandledKey( const vcl::KeyCode
& _rKeyCode
);
379 DECL_LINK( SelectHdl
, Timer
*, void);
380 DECL_LINK( NotifyHdl
, LinkParamNone
*, void );
381 DECL_LINK( FindHdl
, sfx2::SearchDialog
&, void );
382 DECL_LINK( CloseHdl
, LinkParamNone
*, void );
383 DECL_LINK( CheckHdl
, weld::Button
&, void );
384 void FindHdl(sfx2::SearchDialog
*);
387 explicit SfxHelpTextWindow_Impl(SfxHelpWindow_Impl
* pHelpWin
, weld::Builder
& rBuilder
, vcl::Window
* pParent
);
388 virtual ~SfxHelpTextWindow_Impl() override
;
389 virtual void dispose() override
;
391 virtual void Resize() override
;
392 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
393 virtual void GetFocus() override
;
394 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
396 const css::uno::Reference
< css::frame::XFrame2
>&
397 getFrame() const { return xFrame
; }
399 void SetSelectHdl(const Link
<const OString
&, void>& rLink
) { xToolBox
->connect_clicked(rLink
); }
400 void ToggleIndex( bool bOn
);
401 void SelectSearchText( const OUString
& rSearchText
, bool _bIsFullWordSearch
);
402 void SetPageStyleHeaderOff() const;
403 weld::Toolbar
& GetToolBox() { return *xToolBox
; }
408 // class SfxHelpWindow_Impl ----------------------------------------------
410 class HelpInterceptor_Impl
;
411 class HelpListener_Impl
;
412 class SfxHelpWindow_Impl
: public DockingWindow
415 friend class SfxHelpIndexWindow_Impl
;
417 std::unique_ptr
<weld::Builder
> m_xBuilder
;
418 VclPtr
<vcl::Window
> m_xVclContentArea
;
419 std::unique_ptr
<weld::Paned
> m_xContainer
;
420 std::unique_ptr
<weld::Container
> m_xHelpPaneWindow
;
421 std::unique_ptr
<weld::Container
> m_xHelpTextWindow
;
422 css::uno::Reference
<css::awt::XWindow
> m_xHelpTextXWindow
;
424 css::uno::Reference
< css::awt::XWindow
>
426 css::uno::Reference
< css::frame::XFrame2
>
429 std::unique_ptr
<SfxHelpIndexWindow_Impl
> xIndexWin
;
430 VclPtr
<SfxHelpTextWindow_Impl
> pTextWin
;
431 HelpInterceptor_Impl
* pHelpInterceptor
;
432 rtl::Reference
<HelpListener_Impl
> pHelpListener
;
435 bool bGrabFocusToToolBox
;
443 virtual void GetFocus() override
;
448 void ShowStartPage();
451 DECL_LINK(SelectHdl
, const OString
&, void);
452 DECL_LINK(OpenHdl
, LinkParamNone
*, void);
453 DECL_LINK(SelectFactoryHdl
, SfxHelpIndexWindow_Impl
*, void);
454 DECL_LINK(ChangeHdl
, HelpListener_Impl
&, void);
455 DECL_LINK(ResizeHdl
, const Size
&, void);
458 SfxHelpWindow_Impl( const css::uno::Reference
< css::frame::XFrame2
>& rFrame
,
459 vcl::Window
* pParent
);
460 virtual ~SfxHelpWindow_Impl() override
;
461 virtual void dispose() override
;
463 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
465 void setContainerWindow( const css::uno::Reference
< css::awt::XWindow
>& xWin
);
466 css::uno::Reference
< css::frame::XFrame2
> const &
467 getTextFrame() const { return pTextWin
->getFrame(); }
469 void SetFactory( const OUString
& rFactory
);
470 void SetHelpURL( const OUString
& rURL
);
471 void DoAction(const OString
& rAction
);
474 weld::Container
* GetContainer() { return m_xHelpTextWindow
.get(); }
476 void UpdateToolbox();
477 void OpenKeyword( const OUString
& rKeyword
) { xIndexWin
->OpenKeyword( rKeyword
); }
479 bool HasHistoryPredecessor() const; // forward to interceptor
480 bool HasHistorySuccessor() const; // forward to interceptor
482 void openDone(const OUString
& sURL
,
485 static OUString
buildHelpURL(const OUString
& sFactory
,
486 const OUString
& sContent
,
487 const OUString
& sAnchor
);
489 void loadHelpContent(const OUString
& sHelpURL
,
490 bool bAddToHistory
= true);
493 class SfxAddHelpBookmarkDialog_Impl
: public weld::GenericDialogController
496 std::unique_ptr
<weld::Entry
> m_xTitleED
;
497 std::unique_ptr
<weld::Label
> m_xAltTitle
;
499 SfxAddHelpBookmarkDialog_Impl(weld::Widget
* pParent
, bool bRename
);
501 void SetTitle( const OUString
& rTitle
);
502 OUString
GetTitle() const { return m_xTitleED
->get_text(); }
505 /// Appends ?Language=xy&System=abc to the help URL in rURL
506 void AppendConfigToken(OUStringBuffer
& rURL
, bool bQuestionMark
);
508 #endif // INCLUDED_SFX2_SOURCE_APPL_NEWHELP_HXX
510 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */