bump product version to 4.1.6.2
[LibreOffice.git] / sfx2 / source / appl / newhelp.hxx
blobfe84268c9e643685c6cbd825db7caf008685ba85
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 >
51 private:
52 sal_Bool m_bFinished;
53 sal_Bool m_bSuccess;
54 Link m_aOpenLink;
55 String m_sURL;
57 public:
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
74 private:
75 Image aOpenBookImage;
76 Image aClosedBookImage;
77 Image aDocumentImage;
79 void InitRoot();
80 void ClearChildren( SvTreeListEntry* pParent );
82 public:
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
100 protected:
101 SfxHelpIndexWindow_Impl* m_pIdxWin;
103 public:
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
113 private:
114 ContentListBox_Impl aContentBox;
116 public:
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
132 public:
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
143 private:
144 FixedText aExpressionFT;
145 IndexBox_Impl aIndexCB;
146 PushButton aOpenBtn;
148 Timer aFactoryTimer;
149 Timer aKeywordTimer;
150 Link aKeywordLink;
152 String sFactory;
153 String sKeyword;
155 long nMinWidth;
156 sal_Bool bIsActivated;
158 void InitializeIndex();
159 void ClearIndex();
161 DECL_LINK(OpenHdl, void *);
162 DECL_LINK( TimeoutHdl, Timer* );
164 public:
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();
183 void OpenKeyword();
185 inline void SelectExecutableEntry() { aIndexCB.SelectExecutableEntry(); }
188 // class SearchTabPage_Impl ----------------------------------------------
190 class SearchBox_Impl : public ComboBox
192 private:
193 Link aSearchLink;
195 public:
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
207 public:
208 SearchResultsBox_Impl( Window* pParent, const ResId& rResId ) : ListBox( pParent, rResId ) {}
210 virtual long Notify( NotifyEvent& rNEvt );
213 class SearchTabPage_Impl : public HelpTabPage_Impl
215 private:
216 FixedText aSearchFT;
217 SearchBox_Impl aSearchED;
218 PushButton aSearchBtn;
219 CheckBox aFullWordsCB;
220 CheckBox aScopeCB;
221 SearchResultsBox_Impl aResultsLB;
222 PushButton aOpenBtn;
224 Size aMinSize;
225 String aFactory;
227 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >
228 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 *);
237 public:
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;
248 void ClearPage();
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
260 private:
261 void DoAction( sal_uInt16 nAction );
263 public:
264 BookmarksBox_Impl( Window* pParent, const ResId& rResId );
265 ~BookmarksBox_Impl();
267 virtual long Notify( NotifyEvent& rNEvt );
270 class BookmarksTabPage_Impl : public HelpTabPage_Impl
272 private:
273 FixedText aBookmarksFT;
274 BookmarksBox_Impl aBookmarksBox;
275 PushButton aBookmarksPB;
277 long nMinWidth;
279 DECL_LINK(OpenHdl, void *);
281 public:
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
300 private:
301 ListBox aActiveLB;
302 FixedLine aActiveLine;
304 TabControl aTabCtrl;
305 Timer aTimer;
307 Link aSelectFactoryLink;
308 Link aPageDoubleClickLink;
309 Link aIndexKeywordLink;
310 String sKeyword;
312 SfxHelpWindow_Impl* pParentWin;
314 ContentTabPage_Impl* pCPage;
315 IndexTabPage_Impl* pIPage;
316 SearchTabPage_Impl* pSPage;
317 BookmarksTabPage_Impl* pBPage;
319 long nMinWidth;
320 bool bWasCursorLeftOrRight;
321 bool bIsInitDone;
323 void Initialize();
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 *);
338 public:
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()
369 if ( !pCPage )
371 pCPage = new ContentTabPage_Impl( &aTabCtrl, this );
372 pCPage->SetOpenHdl( aPageDoubleClickLink );
374 return pCPage;
376 IndexTabPage_Impl* SfxHelpIndexWindow_Impl::GetIndexPage()
378 if ( !pIPage )
380 pIPage = new IndexTabPage_Impl( &aTabCtrl, this );
381 pIPage->SetDoubleClickHdl( aPageDoubleClickLink );
382 pIPage->SetKeywordHdl( aIndexKeywordLink );
384 return pIPage;
387 SearchTabPage_Impl* SfxHelpIndexWindow_Impl::GetSearchPage()
389 if ( !pSPage )
391 pSPage = new SearchTabPage_Impl( &aTabCtrl, this );
392 pSPage->SetDoubleClickHdl( aPageDoubleClickLink );
394 return pSPage;
397 BookmarksTabPage_Impl* SfxHelpIndexWindow_Impl::GetBookmarksPage()
399 if ( !pBPage )
401 pBPage = new BookmarksTabPage_Impl( &aTabCtrl, this );
402 pBPage->SetDoubleClickHdl( aPageDoubleClickLink );
404 return pBPage;
407 bool SfxHelpIndexWindow_Impl::WasCursorLeftOrRight()
409 bool bRet = bWasCursorLeftOrRight;
410 bWasCursorLeftOrRight = false;
411 return bRet;
414 // class TextWin_Impl ----------------------------------------------------
416 class TextWin_Impl : public DockingWindow
418 public:
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
432 private:
433 ToolBox aToolBox;
434 CheckBox aOnStartupCB;
435 Timer aSelectTimer;
436 Image aIndexOnImage;
437 Image aIndexOffImage;
438 String aIndexOnText;
439 String aIndexOffText;
440 String aSearchText;
441 String aOnStartupText;
442 OUString sCurrentFactory;
444 SfxHelpWindow_Impl* pHelpWin;
445 Window* pTextWin;
446 sfx2::SearchDialog* pSrchDlg;
447 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame2 >
448 xFrame;
449 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >
450 xBreakIterator;
451 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
452 xConfiguration;
453 long nMinPos;
454 sal_Bool bIsDebug;
455 sal_Bool bIsIndexOn;
456 sal_Bool bIsInClose;
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 >
465 GetBreakIterator();
466 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >
467 getCursor() const;
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* );
476 public:
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; }
493 void CloseFrame();
494 void DoSearch();
497 // class SfxHelpWindow_Impl ----------------------------------------------
499 class HelpInterceptor_Impl;
500 class HelpListener_Impl;
501 class SfxHelpWindow_Impl : public SplitWindow
503 private:
504 friend class SfxHelpIndexWindow_Impl;
506 ::com::sun::star::uno::Reference < ::com::sun::star::awt::XWindow >
507 xWindow;
508 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchResultListener >
509 xOpenListener;
510 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame2 >
511 xFrame;
513 SfxHelpIndexWindow_Impl* pIndexWin;
514 SfxHelpTextWindow_Impl* pTextWin;
515 HelpInterceptor_Impl* pHelpInterceptor;
516 HelpListener_Impl* pHelpListener;
518 sal_Int32 nExpandWidth;
519 sal_Int32 nCollapseWidth;
520 sal_Int32 nHeight;
521 long nIndexSize;
522 long nTextSize;
523 sal_Bool bIndex;
524 sal_Bool bGrabFocusToToolBox;
525 Point aWinPos;
526 OUString sTitle;
527 String sKeyword;
529 virtual void Resize();
530 virtual void Split();
531 virtual void GetFocus();
533 void MakeLayout();
534 void InitSizes();
535 void LoadConfig();
536 void SaveConfig();
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* );
544 public:
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 );
561 void CloseWindow();
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 ,
571 sal_Bool bSuccess);
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
584 private:
585 FixedText aTitleFT;
586 Edit aTitleED;
587 OKButton aOKBtn;
588 CancelButton aEscBtn;
589 HelpButton aHelpBtn;
591 public:
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: */