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_SFX_NEWHELP_HXX
20 #define INCLUDED_SFX_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/toolbox.hxx>
34 #include <vcl/tabpage.hxx>
35 #include <vcl/splitwin.hxx>
36 #include <vcl/tabctrl.hxx>
37 #include <vcl/combobox.hxx>
38 #include <vcl/fixed.hxx>
39 #include <vcl/button.hxx>
40 #include <vcl/lstbox.hxx>
41 #include <vcl/dialog.hxx>
42 #include <svtools/treelistbox.hxx>
43 #include <unotools/moduleoptions.hxx>
45 #include "srchdlg.hxx"
47 // class OpenStatusListener_Impl -----------------------------------------
49 class OpenStatusListener_Impl
: public ::cppu::WeakImplHelper1
< ::com::sun::star::frame::XDispatchResultListener
>
58 OpenStatusListener_Impl() : m_bFinished( sal_False
), m_bSuccess( sal_False
) {}
60 virtual void SAL_CALL
dispatchFinished( const ::com::sun::star::frame::DispatchResultEvent
& Event
) throw(::com::sun::star::uno::RuntimeException
);
61 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
);
63 inline sal_Bool
IsFinished() const { return m_bFinished
; }
64 inline sal_Bool
IsSuccessful() const { return m_bSuccess
; }
65 inline void SetURL( const String
& rURL
) { m_sURL
= rURL
; }
66 inline String
GetURL() const { return m_sURL
; }
67 inline void SetOpenHdl( const Link
& rLink
) { m_aOpenLink
= rLink
; }
70 // ContentListBox_Impl ---------------------------------------------------
72 class ContentListBox_Impl
: public SvTreeListBox
76 Image aClosedBookImage
;
80 void ClearChildren( SvTreeListEntry
* pParent
);
83 ContentListBox_Impl( Window
* pParent
, const ResId
& rResId
);
84 ~ContentListBox_Impl();
87 virtual void RequestingChildren( SvTreeListEntry
* pParent
);
88 virtual long Notify( NotifyEvent
& rNEvt
);
90 inline void SetOpenHdl( const Link
& rLink
) { SetDoubleClickHdl( rLink
); }
91 String
GetSelectEntry() const;
94 // class HelpTabPage_Impl ------------------------------------------------
96 class SfxHelpIndexWindow_Impl
;
98 class HelpTabPage_Impl
: public TabPage
101 SfxHelpIndexWindow_Impl
* m_pIdxWin
;
104 HelpTabPage_Impl( Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
, const ResId
& rResId
);
106 virtual Control
* GetLastFocusControl() = 0;
109 // class ContentTabPage_Impl ---------------------------------------------
111 class ContentTabPage_Impl
: public HelpTabPage_Impl
114 ContentListBox_Impl aContentBox
;
117 ContentTabPage_Impl( Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
119 virtual void Resize();
120 virtual void ActivatePage();
121 virtual Control
* GetLastFocusControl();
123 inline void SetOpenHdl( const Link
& rLink
) { aContentBox
.SetOpenHdl( rLink
); }
124 inline String
GetSelectEntry() const { return aContentBox
.GetSelectEntry(); }
125 inline void SetFocusOnBox() { aContentBox
.GrabFocus(); }
128 // class IndexTabPage_Impl -----------------------------------------------
130 class IndexBox_Impl
: public ComboBox
133 IndexBox_Impl( Window
* pParent
, const ResId
& rResId
);
135 virtual void UserDraw( const UserDrawEvent
& rUDEvt
);
136 virtual long Notify( NotifyEvent
& rNEvt
);
138 void SelectExecutableEntry();
141 class IndexTabPage_Impl
: public HelpTabPage_Impl
144 FixedText aExpressionFT
;
145 IndexBox_Impl aIndexCB
;
156 sal_Bool bIsActivated
;
158 void InitializeIndex();
161 DECL_LINK(OpenHdl
, void *);
162 DECL_LINK( TimeoutHdl
, Timer
* );
165 IndexTabPage_Impl( Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
166 ~IndexTabPage_Impl();
168 virtual void Resize();
169 virtual void ActivatePage();
170 virtual Control
* GetLastFocusControl();
172 void SetDoubleClickHdl( const Link
& rLink
);
173 void SetFactory( const String
& rFactory
);
174 inline String
GetFactory() const { return sFactory
; }
175 String
GetSelectEntry() const;
176 inline void SetFocusOnBox() { aIndexCB
.GrabFocus(); }
177 inline sal_Bool
HasFocusOnEdit() const { return aIndexCB
.HasChildPathFocus(); }
179 inline void SetKeywordHdl( const Link
& rLink
) { aKeywordLink
= rLink
; }
180 void SetKeyword( const String
& rKeyword
);
181 sal_Bool
HasKeyword() const;
182 sal_Bool
HasKeywordIgnoreCase();
185 inline void SelectExecutableEntry() { aIndexCB
.SelectExecutableEntry(); }
188 // class SearchTabPage_Impl ----------------------------------------------
190 class SearchBox_Impl
: public ComboBox
196 SearchBox_Impl( Window
* pParent
, const ResId
& rResId
) :
197 ComboBox( pParent
, rResId
) { SetDropDownLineCount( 5 ); }
199 virtual long PreNotify( NotifyEvent
& rNEvt
);
200 virtual void Select();
202 inline void SetSearchLink( const Link
& rLink
) { aSearchLink
= rLink
; }
205 class SearchResultsBox_Impl
: public ListBox
208 SearchResultsBox_Impl( Window
* pParent
, const ResId
& rResId
) : ListBox( pParent
, rResId
) {}
210 virtual long Notify( NotifyEvent
& rNEvt
);
213 class SearchTabPage_Impl
: public HelpTabPage_Impl
217 SearchBox_Impl aSearchED
;
218 PushButton aSearchBtn
;
219 CheckBox aFullWordsCB
;
221 SearchResultsBox_Impl aResultsLB
;
227 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XBreakIterator
>
230 void ClearSearchResults();
231 void RememberSearchText( const String
& rSearchText
);
233 DECL_LINK(SearchHdl
, void *);
234 DECL_LINK(OpenHdl
, void *);
235 DECL_LINK(ModifyHdl
, void *);
238 SearchTabPage_Impl( Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
239 ~SearchTabPage_Impl();
241 virtual void Resize();
242 virtual void ActivatePage();
243 virtual Control
* GetLastFocusControl();
245 void SetDoubleClickHdl( const Link
& rLink
);
246 inline void SetFactory( const String
& rFactory
) { aFactory
= rFactory
; }
247 String
GetSelectEntry() const;
249 inline void SetFocusOnBox() { aResultsLB
.GrabFocus(); }
250 inline sal_Bool
HasFocusOnEdit() const { return aSearchED
.HasChildPathFocus(); }
251 inline String
GetSearchText() const { return aSearchED
.GetText(); }
252 inline sal_Bool
IsFullWordSearch() const { return aFullWordsCB
.IsChecked(); }
253 sal_Bool
OpenKeyword( const String
& rKeyword
);
256 // class BookmarksTabPage_Impl -------------------------------------------
258 class BookmarksBox_Impl
: public ListBox
261 void DoAction( sal_uInt16 nAction
);
264 BookmarksBox_Impl( Window
* pParent
, const ResId
& rResId
);
265 ~BookmarksBox_Impl();
267 virtual long Notify( NotifyEvent
& rNEvt
);
270 class BookmarksTabPage_Impl
: public HelpTabPage_Impl
273 FixedText aBookmarksFT
;
274 BookmarksBox_Impl aBookmarksBox
;
275 PushButton aBookmarksPB
;
279 DECL_LINK(OpenHdl
, void *);
282 BookmarksTabPage_Impl( Window
* pParent
, SfxHelpIndexWindow_Impl
* _pIdxWin
);
284 virtual void Resize();
285 virtual void ActivatePage();
286 virtual Control
* GetLastFocusControl();
288 void SetDoubleClickHdl( const Link
& rLink
);
289 String
GetSelectEntry() const;
290 void AddBookmarks( const String
& rTitle
, const String
& rURL
);
291 inline void SetFocusOnBox() { aBookmarksBox
.GrabFocus(); }
294 // class SfxHelpIndexWindow_Impl -----------------------------------------
296 class SfxHelpWindow_Impl
;
298 class SfxHelpIndexWindow_Impl
: public Window
302 FixedLine aActiveLine
;
307 Link aSelectFactoryLink
;
308 Link aPageDoubleClickLink
;
309 Link aIndexKeywordLink
;
312 SfxHelpWindow_Impl
* pParentWin
;
314 ContentTabPage_Impl
* pCPage
;
315 IndexTabPage_Impl
* pIPage
;
316 SearchTabPage_Impl
* pSPage
;
317 BookmarksTabPage_Impl
* pBPage
;
320 bool bWasCursorLeftOrRight
;
324 void SetActiveFactory();
325 HelpTabPage_Impl
* GetCurrentPage( sal_uInt16
& rCurId
);
327 inline ContentTabPage_Impl
* GetContentPage();
328 inline IndexTabPage_Impl
* GetIndexPage();
329 inline SearchTabPage_Impl
* GetSearchPage();
330 inline BookmarksTabPage_Impl
* GetBookmarksPage();
332 DECL_LINK( ActivatePageHdl
, TabControl
* );
333 DECL_LINK(SelectHdl
, void *);
334 DECL_LINK(InitHdl
, void *);
335 DECL_LINK(SelectFactoryHdl
, void *);
336 DECL_LINK(KeywordHdl
, void *);
339 SfxHelpIndexWindow_Impl( SfxHelpWindow_Impl
* pParent
);
340 ~SfxHelpIndexWindow_Impl();
342 virtual void Resize();
343 virtual long PreNotify( NotifyEvent
& rNEvt
);
344 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
346 void SetDoubleClickHdl( const Link
& rLink
);
347 inline void SetSelectFactoryHdl( const Link
& rLink
) { aSelectFactoryLink
= rLink
; }
348 void SetFactory( const String
& rFactory
, sal_Bool bActive
);
349 inline String
GetFactory() const { return pIPage
->GetFactory(); }
350 String
GetSelectEntry() const;
351 void AddBookmarks( const String
& rTitle
, const String
& rURL
);
352 bool IsValidFactory( const String
& _rFactory
);
353 inline String
GetActiveFactoryTitle() const { return aActiveLB
.GetSelectEntry(); }
354 inline void UpdateTabControl() { aTabCtrl
.Invalidate(); }
355 void ClearSearchPage();
356 void GrabFocusBack();
357 sal_Bool
HasFocusOnEdit() const;
358 String
GetSearchText() const;
359 sal_Bool
IsFullWordSearch() const;
360 void OpenKeyword( const String
& rKeyword
);
361 void SelectExecutableEntry();
362 inline bool WasCursorLeftOrRight();
365 // inlines ---------------------------------------------------------------
367 ContentTabPage_Impl
* SfxHelpIndexWindow_Impl::GetContentPage()
371 pCPage
= new ContentTabPage_Impl( &aTabCtrl
, this );
372 pCPage
->SetOpenHdl( aPageDoubleClickLink
);
376 IndexTabPage_Impl
* SfxHelpIndexWindow_Impl::GetIndexPage()
380 pIPage
= new IndexTabPage_Impl( &aTabCtrl
, this );
381 pIPage
->SetDoubleClickHdl( aPageDoubleClickLink
);
382 pIPage
->SetKeywordHdl( aIndexKeywordLink
);
387 SearchTabPage_Impl
* SfxHelpIndexWindow_Impl::GetSearchPage()
391 pSPage
= new SearchTabPage_Impl( &aTabCtrl
, this );
392 pSPage
->SetDoubleClickHdl( aPageDoubleClickLink
);
397 BookmarksTabPage_Impl
* SfxHelpIndexWindow_Impl::GetBookmarksPage()
401 pBPage
= new BookmarksTabPage_Impl( &aTabCtrl
, this );
402 pBPage
->SetDoubleClickHdl( aPageDoubleClickLink
);
407 bool SfxHelpIndexWindow_Impl::WasCursorLeftOrRight()
409 bool bRet
= bWasCursorLeftOrRight
;
410 bWasCursorLeftOrRight
= false;
414 // class TextWin_Impl ----------------------------------------------------
416 class TextWin_Impl
: public DockingWindow
419 TextWin_Impl( Window
* pParent
);
420 virtual ~TextWin_Impl();
422 virtual long Notify( NotifyEvent
& rNEvt
);
425 // class SfxHelpTextWindow_Impl ------------------------------------------
427 class SvtMiscOptions
;
428 class SfxHelpWindow_Impl
;
430 class SfxHelpTextWindow_Impl
: public Window
434 CheckBox aOnStartupCB
;
437 Image aIndexOffImage
;
439 String aIndexOffText
;
441 String aOnStartupText
;
442 OUString sCurrentFactory
;
444 SfxHelpWindow_Impl
* pHelpWin
;
446 sfx2::SearchDialog
* pSrchDlg
;
447 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>
449 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XBreakIterator
>
451 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
457 sal_Bool bIsFullWordSearch
;
459 sal_Bool
HasSelection() const;
460 void InitToolBoxImages();
461 void InitOnStartupBox( bool bOnlyText
);
462 void SetOnStartupBoxPosition();
464 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XBreakIterator
>
466 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
>
468 bool isHandledKey( const KeyCode
& _rKeyCode
);
470 DECL_LINK(SelectHdl
, void *);
471 DECL_LINK( NotifyHdl
, SvtMiscOptions
* );
472 DECL_LINK( FindHdl
, sfx2::SearchDialog
* );
473 DECL_LINK( CloseHdl
, sfx2::SearchDialog
* );
474 DECL_LINK( CheckHdl
, CheckBox
* );
477 SfxHelpTextWindow_Impl( SfxHelpWindow_Impl
* pParent
);
478 ~SfxHelpTextWindow_Impl();
480 virtual void Resize();
481 virtual long PreNotify( NotifyEvent
& rNEvt
);
482 virtual void GetFocus();
483 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
485 inline ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>
486 getFrame() const { return xFrame
; }
488 inline void SetSelectHdl( const Link
& rLink
) { aToolBox
.SetSelectHdl( rLink
); }
489 void ToggleIndex( sal_Bool bOn
);
490 void SelectSearchText( const String
& rSearchText
, sal_Bool _bIsFullWordSearch
);
491 void SetPageStyleHeaderOff() const;
492 inline ToolBox
& GetToolBox() { return aToolBox
; }
497 // class SfxHelpWindow_Impl ----------------------------------------------
499 class HelpInterceptor_Impl
;
500 class HelpListener_Impl
;
501 class SfxHelpWindow_Impl
: public SplitWindow
504 friend class SfxHelpIndexWindow_Impl
;
506 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>
508 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchResultListener
>
510 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>
513 SfxHelpIndexWindow_Impl
* pIndexWin
;
514 SfxHelpTextWindow_Impl
* pTextWin
;
515 HelpInterceptor_Impl
* pHelpInterceptor
;
516 HelpListener_Impl
* pHelpListener
;
518 sal_Int32 nExpandWidth
;
519 sal_Int32 nCollapseWidth
;
524 sal_Bool bGrabFocusToToolBox
;
529 virtual void Resize();
530 virtual void Split();
531 virtual void GetFocus();
537 void ShowStartPage();
539 DECL_LINK( SelectHdl
, ToolBox
* );
540 DECL_LINK(OpenHdl
, void *);
541 DECL_LINK( SelectFactoryHdl
, SfxHelpIndexWindow_Impl
* );
542 DECL_LINK( ChangeHdl
, HelpListener_Impl
* );
545 SfxHelpWindow_Impl( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>& rFrame
,
546 Window
* pParent
, WinBits nBits
);
547 ~SfxHelpWindow_Impl();
549 virtual long PreNotify( NotifyEvent
& rNEvt
);
551 void setContainerWindow(
552 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xWin
);
553 inline ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame2
>
554 getTextFrame() const { return pTextWin
->getFrame(); }
555 inline ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchResultListener
>
556 getOpenListener() const { return xOpenListener
; }
558 void SetFactory( const String
& rFactory
);
559 void SetHelpURL( const String
& rURL
);
560 void DoAction( sal_uInt16 nActionId
);
563 void UpdateToolbox();
564 inline void OpenKeyword( const String
& rKeyword
) { pIndexWin
->OpenKeyword( rKeyword
); }
565 inline String
GetFactory() const { return pIndexWin
->GetFactory(); }
567 sal_Bool
HasHistoryPredecessor() const; // forward to interceptor
568 sal_Bool
HasHistorySuccessor() const; // forward to interceptor
570 void openDone(const OUString
& sURL
,
573 static OUString
buildHelpURL(const OUString
& sFactory
,
574 const OUString
& sContent
,
575 const OUString
& sAnchor
,
576 sal_Bool bUseQuestionMark
);
578 void loadHelpContent(const OUString
& sHelpURL
,
579 sal_Bool bAddToHistory
= sal_True
);
582 class SfxAddHelpBookmarkDialog_Impl
: public ModalDialog
588 CancelButton aEscBtn
;
592 SfxAddHelpBookmarkDialog_Impl( Window
* pParent
, sal_Bool bRename
= sal_True
);
593 ~SfxAddHelpBookmarkDialog_Impl();
595 void SetTitle( const String
& rTitle
);
596 inline String
GetTitle() const { return aTitleED
.GetText(); }
599 /// Appends ?Language=xy&System=abc to the help URL in rURL
600 void AppendConfigToken(OUStringBuffer
& rURL
, sal_Bool bQuestionMark
, const OUString
&rLang
= OUString());
602 #endif // #ifndef INCLUDED_SFX_NEWHELP_HXX
604 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */