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 <cppuhelper/implbase1.hxx>
23 #include <com/sun/star/uno/Reference.h>
24 #include <com/sun/star/frame/XDispatchResultListener.hpp>
25 #include <com/sun/star/frame/XDispatch.hpp>
26 #include <com/sun/star/frame/XFrame2.hpp>
28 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XWindow
; } } } }
29 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{ class XBreakIterator
; } } } }
30 namespace com
{ namespace sun
{ namespace star
{ namespace text
{ class XTextRange
; } } } }
32 #include <vcl/window.hxx>
33 #include <vcl/idle.hxx>
34 #include <vcl/toolbox.hxx>
35 #include <vcl/tabpage.hxx>
36 #include <vcl/splitwin.hxx>
37 #include <vcl/tabctrl.hxx>
38 #include <vcl/combobox.hxx>
39 #include <vcl/fixed.hxx>
40 #include <vcl/button.hxx>
41 #include <vcl/lstbox.hxx>
42 #include <vcl/dialog.hxx>
43 #include <svtools/treelistbox.hxx>
44 #include <unotools/moduleoptions.hxx>
46 #include "srchdlg.hxx"
48 // ContentListBox_Impl ---------------------------------------------------
50 class ContentListBox_Impl
: public SvTreeListBox
54 Image aClosedBookImage
;
58 void ClearChildren( SvTreeListEntry
* pParent
);
61 ContentListBox_Impl(vcl::Window
* pParent
, WinBits nStyle
);
62 virtual ~ContentListBox_Impl();
63 virtual void dispose() SAL_OVERRIDE
;
65 virtual void RequestingChildren( SvTreeListEntry
* pParent
) SAL_OVERRIDE
;
66 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
68 inline void SetOpenHdl( const Link
<>& rLink
) { SetDoubleClickHdl( rLink
); }
69 OUString
GetSelectEntry() const;
72 // class HelpTabPage_Impl ------------------------------------------------
74 class SfxHelpIndexWindow_Impl
;
76 class HelpTabPage_Impl
: public TabPage
79 VclPtr
<SfxHelpIndexWindow_Impl
> m_pIdxWin
;
82 HelpTabPage_Impl(vcl::Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
,
83 const OString
& rID
, const OUString
& rUIXMLDescription
);
84 virtual ~HelpTabPage_Impl();
85 virtual void dispose() SAL_OVERRIDE
;
87 virtual Control
* GetLastFocusControl() = 0;
90 // class ContentTabPage_Impl ---------------------------------------------
92 class ContentTabPage_Impl
: public HelpTabPage_Impl
95 VclPtr
<ContentListBox_Impl
> m_pContentBox
;
98 ContentTabPage_Impl(vcl::Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
99 virtual ~ContentTabPage_Impl();
100 virtual void dispose() SAL_OVERRIDE
;
102 virtual void ActivatePage() SAL_OVERRIDE
;
103 virtual Control
* GetLastFocusControl() SAL_OVERRIDE
;
105 void SetOpenHdl( const Link
<>& rLink
) { m_pContentBox
->SetOpenHdl( rLink
); }
106 OUString
GetSelectEntry() const { return m_pContentBox
->GetSelectEntry(); }
107 void SetFocusOnBox() { m_pContentBox
->GrabFocus(); }
110 // class IndexTabPage_Impl -----------------------------------------------
112 class IndexBox_Impl
: public ComboBox
115 IndexBox_Impl(vcl::Window
* pParent
, WinBits nStyle
);
117 virtual void UserDraw( const UserDrawEvent
& rUDEvt
) SAL_OVERRIDE
;
118 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
120 void SelectExecutableEntry();
123 class IndexTabPage_Impl
: public HelpTabPage_Impl
126 VclPtr
<IndexBox_Impl
> m_pIndexCB
;
127 VclPtr
<PushButton
> m_pOpenBtn
;
138 void InitializeIndex();
141 DECL_LINK(OpenHdl
, void *);
142 DECL_LINK_TYPED(IdleHdl
, Idle
*, void);
143 DECL_LINK_TYPED(TimeoutHdl
, Timer
*, void);
146 IndexTabPage_Impl( vcl::Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
147 virtual ~IndexTabPage_Impl();
148 virtual void dispose() SAL_OVERRIDE
;
150 virtual void ActivatePage() SAL_OVERRIDE
;
151 virtual Control
* GetLastFocusControl() SAL_OVERRIDE
;
153 void SetDoubleClickHdl( const Link
<>& rLink
);
154 void SetFactory( const OUString
& rFactory
);
155 inline OUString
GetFactory() const { return sFactory
; }
156 OUString
GetSelectEntry() const;
157 inline void SetFocusOnBox() { m_pIndexCB
->GrabFocus(); }
158 inline bool HasFocusOnEdit() const { return m_pIndexCB
->HasChildPathFocus(); }
160 inline void SetKeywordHdl( const Link
<>& rLink
) { aKeywordLink
= rLink
; }
161 void SetKeyword( const OUString
& rKeyword
);
162 bool HasKeyword() const;
163 bool HasKeywordIgnoreCase();
166 inline void SelectExecutableEntry() { m_pIndexCB
->SelectExecutableEntry(); }
169 // class SearchTabPage_Impl ----------------------------------------------
171 class SearchBox_Impl
: public ComboBox
177 SearchBox_Impl(vcl::Window
* pParent
, WinBits nStyle
)
178 : ComboBox(pParent
, nStyle
)
180 SetDropDownLineCount(5);
183 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
184 virtual void Select() SAL_OVERRIDE
;
186 inline void SetSearchLink( const Link
<>& rLink
) { aSearchLink
= rLink
; }
189 class SearchResultsBox_Impl
: public ListBox
192 SearchResultsBox_Impl(vcl::Window
* pParent
, WinBits nStyle
)
193 : ListBox(pParent
, nStyle
)
197 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
200 class SearchTabPage_Impl
: public HelpTabPage_Impl
203 VclPtr
<SearchBox_Impl
> m_pSearchED
;
204 VclPtr
<PushButton
> m_pSearchBtn
;
205 VclPtr
<CheckBox
> m_pFullWordsCB
;
206 VclPtr
<CheckBox
> m_pScopeCB
;
207 VclPtr
<SearchResultsBox_Impl
> m_pResultsLB
;
208 VclPtr
<PushButton
> m_pOpenBtn
;
212 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XBreakIterator
>
215 void ClearSearchResults();
216 void RememberSearchText( const OUString
& rSearchText
);
218 DECL_LINK(SearchHdl
, void *);
219 DECL_LINK(OpenHdl
, void *);
220 DECL_LINK(ModifyHdl
, void *);
223 SearchTabPage_Impl( vcl::Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
224 virtual ~SearchTabPage_Impl();
225 virtual void dispose() SAL_OVERRIDE
;
227 virtual void ActivatePage() SAL_OVERRIDE
;
228 virtual Control
* GetLastFocusControl() SAL_OVERRIDE
;
230 void SetDoubleClickHdl( const Link
<>& rLink
);
231 inline void SetFactory( const OUString
& rFactory
) { aFactory
= rFactory
; }
232 OUString
GetSelectEntry() const;
234 inline void SetFocusOnBox() { m_pResultsLB
->GrabFocus(); }
235 inline bool HasFocusOnEdit() const { return m_pSearchED
->HasChildPathFocus(); }
236 inline OUString
GetSearchText() const { return m_pSearchED
->GetText(); }
237 inline bool IsFullWordSearch() const { return m_pFullWordsCB
->IsChecked(); }
238 bool OpenKeyword( const OUString
& rKeyword
);
241 // class BookmarksTabPage_Impl -------------------------------------------
243 class BookmarksBox_Impl
: public ListBox
246 void DoAction( sal_uInt16 nAction
);
249 BookmarksBox_Impl(vcl::Window
* pParent
, WinBits nStyle
);
250 virtual ~BookmarksBox_Impl();
251 virtual void dispose() SAL_OVERRIDE
;
253 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
256 class BookmarksTabPage_Impl
: public HelpTabPage_Impl
259 VclPtr
<BookmarksBox_Impl
> m_pBookmarksBox
;
260 VclPtr
<PushButton
> m_pBookmarksPB
;
262 DECL_LINK(OpenHdl
, void *);
265 BookmarksTabPage_Impl( vcl::Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
266 virtual ~BookmarksTabPage_Impl();
267 virtual void dispose() SAL_OVERRIDE
;
269 virtual void ActivatePage() SAL_OVERRIDE
;
270 virtual Control
* GetLastFocusControl() SAL_OVERRIDE
;
272 void SetDoubleClickHdl( const Link
<>& rLink
);
273 OUString
GetSelectEntry() const;
274 void AddBookmarks( const OUString
& rTitle
, const OUString
& rURL
);
275 void SetFocusOnBox() { m_pBookmarksBox
->GrabFocus(); }
278 // class SfxHelpIndexWindow_Impl -----------------------------------------
280 class SfxHelpWindow_Impl
;
282 class SfxHelpIndexWindow_Impl
: public vcl::Window
, public VclBuilderContainer
285 VclPtr
<ListBox
> m_pActiveLB
;
286 VclPtr
<TabControl
> m_pTabCtrl
;
290 Link
<> aSelectFactoryLink
;
291 Link
<> aPageDoubleClickLink
;
292 Link
<> aIndexKeywordLink
;
295 VclPtr
<SfxHelpWindow_Impl
> pParentWin
;
297 VclPtr
<ContentTabPage_Impl
> pCPage
;
298 VclPtr
<IndexTabPage_Impl
> pIPage
;
299 VclPtr
<SearchTabPage_Impl
> pSPage
;
300 VclPtr
<BookmarksTabPage_Impl
> pBPage
;
303 bool bWasCursorLeftOrRight
;
307 void SetActiveFactory();
308 HelpTabPage_Impl
* GetCurrentPage( sal_uInt16
& rCurId
);
310 inline ContentTabPage_Impl
* GetContentPage();
311 inline IndexTabPage_Impl
* GetIndexPage();
312 inline SearchTabPage_Impl
* GetSearchPage();
313 inline BookmarksTabPage_Impl
* GetBookmarksPage();
315 DECL_LINK( ActivatePageHdl
, TabControl
* );
316 DECL_LINK(SelectHdl
, void *);
317 DECL_LINK_TYPED(InitHdl
, Idle
*, void);
318 DECL_LINK_TYPED(SelectFactoryHdl
, Idle
*, void);
319 DECL_LINK(KeywordHdl
, void *);
322 SfxHelpIndexWindow_Impl( SfxHelpWindow_Impl
* pParent
);
323 virtual ~SfxHelpIndexWindow_Impl();
324 virtual void dispose() SAL_OVERRIDE
;
326 virtual void Resize() SAL_OVERRIDE
;
327 virtual Size
GetOptimalSize() const SAL_OVERRIDE
;
328 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
329 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
331 void SetDoubleClickHdl( const Link
<>& rLink
);
332 inline void SetSelectFactoryHdl( const Link
<>& rLink
) { aSelectFactoryLink
= rLink
; }
333 void SetFactory( const OUString
& rFactory
, bool bActive
);
334 inline OUString
GetFactory() const { return pIPage
->GetFactory(); }
335 OUString
GetSelectEntry() const;
336 void AddBookmarks( const OUString
& rTitle
, const OUString
& rURL
);
337 bool IsValidFactory( const OUString
& _rFactory
);
338 inline OUString
GetActiveFactoryTitle() const { return m_pActiveLB
->GetSelectEntry(); }
339 inline void UpdateTabControl() { m_pTabCtrl
->Invalidate(); }
340 void ClearSearchPage();
341 void GrabFocusBack();
342 bool HasFocusOnEdit() const;
343 OUString
GetSearchText() const;
344 bool IsFullWordSearch() const;
345 void OpenKeyword( const OUString
& rKeyword
);
346 void SelectExecutableEntry();
347 inline bool WasCursorLeftOrRight();
350 // inlines ---------------------------------------------------------------
352 ContentTabPage_Impl
* SfxHelpIndexWindow_Impl::GetContentPage()
356 pCPage
= VclPtr
<ContentTabPage_Impl
>::Create( m_pTabCtrl
, this );
357 pCPage
->SetOpenHdl( aPageDoubleClickLink
);
361 IndexTabPage_Impl
* SfxHelpIndexWindow_Impl::GetIndexPage()
365 pIPage
= VclPtr
<IndexTabPage_Impl
>::Create( m_pTabCtrl
, this );
366 pIPage
->SetDoubleClickHdl( aPageDoubleClickLink
);
367 pIPage
->SetKeywordHdl( aIndexKeywordLink
);
372 SearchTabPage_Impl
* SfxHelpIndexWindow_Impl::GetSearchPage()
376 pSPage
= VclPtr
<SearchTabPage_Impl
>::Create( m_pTabCtrl
, this );
377 pSPage
->SetDoubleClickHdl( aPageDoubleClickLink
);
382 BookmarksTabPage_Impl
* SfxHelpIndexWindow_Impl::GetBookmarksPage()
386 pBPage
= VclPtr
<BookmarksTabPage_Impl
>::Create( m_pTabCtrl
, this );
387 pBPage
->SetDoubleClickHdl( aPageDoubleClickLink
);
392 bool SfxHelpIndexWindow_Impl::WasCursorLeftOrRight()
394 bool bRet
= bWasCursorLeftOrRight
;
395 bWasCursorLeftOrRight
= false;
399 // class TextWin_Impl ----------------------------------------------------
401 class TextWin_Impl
: public DockingWindow
404 TextWin_Impl( vcl::Window
* pParent
);
406 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
409 // class SfxHelpTextWindow_Impl ------------------------------------------
411 class SvtMiscOptions
;
412 class SfxHelpWindow_Impl
;
414 class SfxHelpTextWindow_Impl
: public vcl::Window
417 VclPtr
<ToolBox
> aToolBox
;
418 VclPtr
<CheckBox
> aOnStartupCB
;
421 Image aIndexOffImage
;
422 OUString aIndexOnText
;
423 OUString aIndexOffText
;
424 OUString aSearchText
;
425 OUString aOnStartupText
;
426 OUString sCurrentFactory
;
428 VclPtr
<SfxHelpWindow_Impl
> pHelpWin
;
429 VclPtr
<vcl::Window
> pTextWin
;
430 VclPtr
<sfx2::SearchDialog
> pSrchDlg
;
431 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>
433 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XBreakIterator
>
435 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
441 bool bIsFullWordSearch
;
443 bool HasSelection() const;
444 void InitToolBoxImages();
445 void InitOnStartupBox( bool bOnlyText
);
446 void SetOnStartupBoxPosition();
448 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XBreakIterator
>
450 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
>
452 bool isHandledKey( const vcl::KeyCode
& _rKeyCode
);
454 DECL_LINK_TYPED(SelectHdl
, Idle
*, void);
455 DECL_LINK( NotifyHdl
, SvtMiscOptions
* );
456 DECL_LINK( FindHdl
, sfx2::SearchDialog
* );
457 DECL_LINK( CloseHdl
, sfx2::SearchDialog
* );
458 DECL_LINK( CheckHdl
, CheckBox
* );
461 SfxHelpTextWindow_Impl( SfxHelpWindow_Impl
* pParent
);
462 virtual ~SfxHelpTextWindow_Impl();
463 virtual void dispose() SAL_OVERRIDE
;
465 virtual void Resize() SAL_OVERRIDE
;
466 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
467 virtual void GetFocus() SAL_OVERRIDE
;
468 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
470 inline ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>
471 getFrame() const { return xFrame
; }
473 inline void SetSelectHdl( const Link
<ToolBox
*, void>& rLink
) { aToolBox
->SetSelectHdl( rLink
); }
474 void ToggleIndex( bool bOn
);
475 void SelectSearchText( const OUString
& rSearchText
, bool _bIsFullWordSearch
);
476 void SetPageStyleHeaderOff() const;
477 inline ToolBox
& GetToolBox() { return *aToolBox
.get(); }
482 // class SfxHelpWindow_Impl ----------------------------------------------
484 class HelpInterceptor_Impl
;
485 class HelpListener_Impl
;
486 class SfxHelpWindow_Impl
: public SplitWindow
489 friend class SfxHelpIndexWindow_Impl
;
491 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>
493 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchResultListener
>
495 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>
498 VclPtr
<SfxHelpIndexWindow_Impl
> pIndexWin
;
499 VclPtr
<SfxHelpTextWindow_Impl
> pTextWin
;
500 HelpInterceptor_Impl
* pHelpInterceptor
;
501 HelpListener_Impl
* pHelpListener
;
503 sal_Int32 nExpandWidth
;
504 sal_Int32 nCollapseWidth
;
509 bool bGrabFocusToToolBox
;
513 virtual void Resize() SAL_OVERRIDE
;
514 virtual void Split() SAL_OVERRIDE
;
515 virtual void GetFocus() SAL_OVERRIDE
;
521 void ShowStartPage();
523 DECL_LINK_TYPED( SelectHdl
, ToolBox
*, void );
524 DECL_LINK(OpenHdl
, void *);
525 DECL_LINK( SelectFactoryHdl
, SfxHelpIndexWindow_Impl
* );
526 DECL_LINK( ChangeHdl
, HelpListener_Impl
* );
529 SfxHelpWindow_Impl( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>& rFrame
,
530 vcl::Window
* pParent
, WinBits nBits
);
531 virtual ~SfxHelpWindow_Impl();
532 virtual void dispose() SAL_OVERRIDE
;
534 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
536 void setContainerWindow(
537 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xWin
);
538 inline ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>
539 getTextFrame() const { return pTextWin
->getFrame(); }
540 inline ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchResultListener
>
541 getOpenListener() const { return xOpenListener
; }
543 void SetFactory( const OUString
& rFactory
);
544 void SetHelpURL( const OUString
& rURL
);
545 void DoAction( sal_uInt16 nActionId
);
548 void UpdateToolbox();
549 inline void OpenKeyword( const OUString
& rKeyword
) { pIndexWin
->OpenKeyword( rKeyword
); }
550 inline OUString
GetFactory() const { return pIndexWin
->GetFactory(); }
552 bool HasHistoryPredecessor() const; // forward to interceptor
553 bool HasHistorySuccessor() const; // forward to interceptor
555 void openDone(const OUString
& sURL
,
558 static OUString
buildHelpURL(const OUString
& sFactory
,
559 const OUString
& sContent
,
560 const OUString
& sAnchor
,
561 bool bUseQuestionMark
);
563 void loadHelpContent(const OUString
& sHelpURL
,
564 bool bAddToHistory
= true);
567 class SfxAddHelpBookmarkDialog_Impl
: public ModalDialog
570 VclPtr
<Edit
> m_pTitleED
;
572 SfxAddHelpBookmarkDialog_Impl( vcl::Window
* pParent
, bool bRename
= true );
573 virtual ~SfxAddHelpBookmarkDialog_Impl();
574 virtual void dispose() SAL_OVERRIDE
;
576 void SetTitle( const OUString
& rTitle
);
577 OUString
GetTitle() const { return m_pTitleED
->GetText(); }
580 /// Appends ?Language=xy&System=abc to the help URL in rURL
581 void AppendConfigToken(OUStringBuffer
& rURL
, bool bQuestionMark
, const OUString
&rLang
= OUString());
583 #endif // INCLUDED_SFX2_SOURCE_APPL_NEWHELP_HXX
585 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */