Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / appl / newhelp.hxx
blob2b07f86f62b92c07d95c750e41a6bbf52268898d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef INCLUDED_SFX_NEWHELP_HXX
29 #define INCLUDED_SFX_NEWHELP_HXX
31 #include <cppuhelper/implbase1.hxx>
32 #include <com/sun/star/uno/Reference.h>
33 #include <com/sun/star/frame/XDispatchResultListener.hpp>
34 #include <com/sun/star/frame/XDispatch.hpp>
35 #include <com/sun/star/frame/XFrame.hpp>
37 namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
38 namespace com { namespace sun { namespace star { namespace frame { class XFrame; } } } }
39 namespace com { namespace sun { namespace star { namespace i18n { class XBreakIterator; } } } }
40 namespace com { namespace sun { namespace star { namespace text { class XTextRange; } } } }
42 #include <vcl/window.hxx>
43 #include <vcl/toolbox.hxx>
44 #include <vcl/tabpage.hxx>
45 #include <vcl/splitwin.hxx>
46 #include <vcl/tabctrl.hxx>
47 #include <vcl/combobox.hxx>
48 #include <vcl/fixed.hxx>
49 #include <vcl/button.hxx>
50 #include <vcl/lstbox.hxx>
51 #include <vcl/dialog.hxx>
52 #include <svtools/svtreebx.hxx>
53 #include <unotools/moduleoptions.hxx>
55 #include "srchdlg.hxx"
57 // class OpenStatusListener_Impl -----------------------------------------
59 class OpenStatusListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XDispatchResultListener >
61 private:
62 sal_Bool m_bFinished;
63 sal_Bool m_bSuccess;
64 Link m_aOpenLink;
65 String m_sURL;
67 public:
68 OpenStatusListener_Impl() : m_bFinished( sal_False ), m_bSuccess( sal_False ) {}
70 virtual void SAL_CALL dispatchFinished( const ::com::sun::star::frame::DispatchResultEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
71 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
73 inline sal_Bool IsFinished() const { return m_bFinished; }
74 inline sal_Bool IsSuccessful() const { return m_bSuccess; }
75 inline void SetURL( const String& rURL ) { m_sURL = rURL; }
76 inline String GetURL() const { return m_sURL; }
77 inline void SetOpenHdl( const Link& rLink ) { m_aOpenLink = rLink; }
80 // ContentListBox_Impl ---------------------------------------------------
82 class ContentListBox_Impl : public SvTreeListBox
84 private:
85 Image aOpenBookImage;
86 Image aClosedBookImage;
87 Image aDocumentImage;
89 void InitRoot();
90 void ClearChildren( SvLBoxEntry* pParent );
92 public:
93 ContentListBox_Impl( Window* pParent, const ResId& rResId );
94 ~ContentListBox_Impl();
97 virtual void RequestingChildren( SvLBoxEntry* pParent );
98 virtual long Notify( NotifyEvent& rNEvt );
100 inline void SetOpenHdl( const Link& rLink ) { SetDoubleClickHdl( rLink ); }
101 String GetSelectEntry() const;
104 // class HelpTabPage_Impl ------------------------------------------------
106 class SfxHelpIndexWindow_Impl;
108 class HelpTabPage_Impl : public TabPage
110 protected:
111 SfxHelpIndexWindow_Impl* m_pIdxWin;
113 public:
114 HelpTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin, const ResId& rResId );
116 virtual Control* GetLastFocusControl() = 0;
119 // class ContentTabPage_Impl ---------------------------------------------
121 class ContentTabPage_Impl : public HelpTabPage_Impl
123 private:
124 ContentListBox_Impl aContentBox;
126 public:
127 ContentTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin );
129 virtual void Resize();
130 virtual void ActivatePage();
131 virtual Control* GetLastFocusControl();
133 inline void SetOpenHdl( const Link& rLink ) { aContentBox.SetOpenHdl( rLink ); }
134 inline String GetSelectEntry() const { return aContentBox.GetSelectEntry(); }
135 inline void SetFocusOnBox() { aContentBox.GrabFocus(); }
138 // class IndexTabPage_Impl -----------------------------------------------
140 class IndexBox_Impl : public ComboBox
142 public:
143 IndexBox_Impl( Window* pParent, const ResId& rResId );
145 virtual void UserDraw( const UserDrawEvent& rUDEvt );
146 virtual long Notify( NotifyEvent& rNEvt );
148 void SelectExecutableEntry();
151 class IndexTabPage_Impl : public HelpTabPage_Impl
153 private:
154 FixedText aExpressionFT;
155 IndexBox_Impl aIndexCB;
156 PushButton aOpenBtn;
158 Timer aFactoryTimer;
159 Timer aKeywordTimer;
160 Link aKeywordLink;
162 String sFactory;
163 String sKeyword;
165 long nMinWidth;
166 sal_Bool bIsActivated;
168 void InitializeIndex();
169 void ClearIndex();
171 DECL_LINK(OpenHdl, void *);
172 DECL_LINK( TimeoutHdl, Timer* );
174 public:
175 IndexTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin );
176 ~IndexTabPage_Impl();
178 virtual void Resize();
179 virtual void ActivatePage();
180 virtual Control* GetLastFocusControl();
182 void SetDoubleClickHdl( const Link& rLink );
183 void SetFactory( const String& rFactory );
184 inline String GetFactory() const { return sFactory; }
185 String GetSelectEntry() const;
186 inline void SetFocusOnBox() { aIndexCB.GrabFocus(); }
187 inline sal_Bool HasFocusOnEdit() const { return aIndexCB.HasChildPathFocus(); }
189 inline void SetKeywordHdl( const Link& rLink ) { aKeywordLink = rLink; }
190 void SetKeyword( const String& rKeyword );
191 sal_Bool HasKeyword() const;
192 sal_Bool HasKeywordIgnoreCase();
193 void OpenKeyword();
195 inline void SelectExecutableEntry() { aIndexCB.SelectExecutableEntry(); }
198 // class SearchTabPage_Impl ----------------------------------------------
200 class SearchBox_Impl : public ComboBox
202 private:
203 Link aSearchLink;
205 public:
206 SearchBox_Impl( Window* pParent, const ResId& rResId ) :
207 ComboBox( pParent, rResId ) { SetDropDownLineCount( 5 ); }
209 virtual long PreNotify( NotifyEvent& rNEvt );
210 virtual void Select();
212 inline void SetSearchLink( const Link& rLink ) { aSearchLink = rLink; }
215 class SearchResultsBox_Impl : public ListBox
217 public:
218 SearchResultsBox_Impl( Window* pParent, const ResId& rResId ) : ListBox( pParent, rResId ) {}
220 virtual long Notify( NotifyEvent& rNEvt );
223 class SearchTabPage_Impl : public HelpTabPage_Impl
225 private:
226 FixedText aSearchFT;
227 SearchBox_Impl aSearchED;
228 PushButton aSearchBtn;
229 CheckBox aFullWordsCB;
230 CheckBox aScopeCB;
231 SearchResultsBox_Impl aResultsLB;
232 PushButton aOpenBtn;
234 Size aMinSize;
235 String aFactory;
237 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >
238 xBreakIterator;
240 void ClearSearchResults();
241 void RememberSearchText( const String& rSearchText );
243 DECL_LINK(SearchHdl, void *);
244 DECL_LINK(OpenHdl, void *);
245 DECL_LINK(ModifyHdl, void *);
247 public:
248 SearchTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin );
249 ~SearchTabPage_Impl();
251 virtual void Resize();
252 virtual void ActivatePage();
253 virtual Control* GetLastFocusControl();
255 void SetDoubleClickHdl( const Link& rLink );
256 inline void SetFactory( const String& rFactory ) { aFactory = rFactory; }
257 String GetSelectEntry() const;
258 void ClearPage();
259 inline void SetFocusOnBox() { aResultsLB.GrabFocus(); }
260 inline sal_Bool HasFocusOnEdit() const { return aSearchED.HasChildPathFocus(); }
261 inline String GetSearchText() const { return aSearchED.GetText(); }
262 inline sal_Bool IsFullWordSearch() const { return aFullWordsCB.IsChecked(); }
263 sal_Bool OpenKeyword( const String& rKeyword );
266 // class BookmarksTabPage_Impl -------------------------------------------
268 class BookmarksBox_Impl : public ListBox
270 private:
271 void DoAction( sal_uInt16 nAction );
273 public:
274 BookmarksBox_Impl( Window* pParent, const ResId& rResId );
275 ~BookmarksBox_Impl();
277 virtual long Notify( NotifyEvent& rNEvt );
280 class BookmarksTabPage_Impl : public HelpTabPage_Impl
282 private:
283 FixedText aBookmarksFT;
284 BookmarksBox_Impl aBookmarksBox;
285 PushButton aBookmarksPB;
287 long nMinWidth;
289 DECL_LINK(OpenHdl, void *);
291 public:
292 BookmarksTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin );
294 virtual void Resize();
295 virtual void ActivatePage();
296 virtual Control* GetLastFocusControl();
298 void SetDoubleClickHdl( const Link& rLink );
299 String GetSelectEntry() const;
300 void AddBookmarks( const String& rTitle, const String& rURL );
301 inline void SetFocusOnBox() { aBookmarksBox.GrabFocus(); }
304 // class SfxHelpIndexWindow_Impl -----------------------------------------
306 class SfxHelpWindow_Impl;
308 class SfxHelpIndexWindow_Impl : public Window
310 private:
311 ListBox aActiveLB;
312 FixedLine aActiveLine;
314 TabControl aTabCtrl;
315 Timer aTimer;
317 Link aSelectFactoryLink;
318 Link aPageDoubleClickLink;
319 Link aIndexKeywordLink;
320 String sKeyword;
322 SfxHelpWindow_Impl* pParentWin;
324 ContentTabPage_Impl* pCPage;
325 IndexTabPage_Impl* pIPage;
326 SearchTabPage_Impl* pSPage;
327 BookmarksTabPage_Impl* pBPage;
329 long nMinWidth;
330 bool bWasCursorLeftOrRight;
331 bool bIsInitDone;
333 void Initialize();
334 void SetActiveFactory();
335 HelpTabPage_Impl* GetCurrentPage( sal_uInt16& rCurId );
337 inline ContentTabPage_Impl* GetContentPage();
338 inline IndexTabPage_Impl* GetIndexPage();
339 inline SearchTabPage_Impl* GetSearchPage();
340 inline BookmarksTabPage_Impl* GetBookmarksPage();
342 DECL_LINK( ActivatePageHdl, TabControl* );
343 DECL_LINK(SelectHdl, void *);
344 DECL_LINK(InitHdl, void *);
345 DECL_LINK(SelectFactoryHdl, void *);
346 DECL_LINK(KeywordHdl, void *);
348 public:
349 SfxHelpIndexWindow_Impl( SfxHelpWindow_Impl* pParent );
350 ~SfxHelpIndexWindow_Impl();
352 virtual void Resize();
353 virtual long PreNotify( NotifyEvent& rNEvt );
354 virtual void DataChanged( const DataChangedEvent& rDCEvt );
356 void SetDoubleClickHdl( const Link& rLink );
357 inline void SetSelectFactoryHdl( const Link& rLink ) { aSelectFactoryLink = rLink; }
358 void SetFactory( const String& rFactory, sal_Bool bActive );
359 inline String GetFactory() const { return pIPage->GetFactory(); }
360 String GetSelectEntry() const;
361 void AddBookmarks( const String& rTitle, const String& rURL );
362 bool IsValidFactory( const String& _rFactory );
363 inline String GetActiveFactoryTitle() const { return aActiveLB.GetSelectEntry(); }
364 inline void UpdateTabControl() { aTabCtrl.Invalidate(); }
365 void ClearSearchPage();
366 void GrabFocusBack();
367 sal_Bool HasFocusOnEdit() const;
368 String GetSearchText() const;
369 sal_Bool IsFullWordSearch() const;
370 void OpenKeyword( const String& rKeyword );
371 void SelectExecutableEntry();
372 inline bool WasCursorLeftOrRight();
375 // inlines ---------------------------------------------------------------
377 ContentTabPage_Impl* SfxHelpIndexWindow_Impl::GetContentPage()
379 if ( !pCPage )
381 pCPage = new ContentTabPage_Impl( &aTabCtrl, this );
382 pCPage->SetOpenHdl( aPageDoubleClickLink );
384 return pCPage;
386 IndexTabPage_Impl* SfxHelpIndexWindow_Impl::GetIndexPage()
388 if ( !pIPage )
390 pIPage = new IndexTabPage_Impl( &aTabCtrl, this );
391 pIPage->SetDoubleClickHdl( aPageDoubleClickLink );
392 pIPage->SetKeywordHdl( aIndexKeywordLink );
394 return pIPage;
397 SearchTabPage_Impl* SfxHelpIndexWindow_Impl::GetSearchPage()
399 if ( !pSPage )
401 pSPage = new SearchTabPage_Impl( &aTabCtrl, this );
402 pSPage->SetDoubleClickHdl( aPageDoubleClickLink );
404 return pSPage;
407 BookmarksTabPage_Impl* SfxHelpIndexWindow_Impl::GetBookmarksPage()
409 if ( !pBPage )
411 pBPage = new BookmarksTabPage_Impl( &aTabCtrl, this );
412 pBPage->SetDoubleClickHdl( aPageDoubleClickLink );
414 return pBPage;
417 bool SfxHelpIndexWindow_Impl::WasCursorLeftOrRight()
419 bool bRet = bWasCursorLeftOrRight;
420 bWasCursorLeftOrRight = false;
421 return bRet;
424 // class TextWin_Impl ----------------------------------------------------
426 class TextWin_Impl : public DockingWindow
428 public:
429 TextWin_Impl( Window* pParent );
430 virtual ~TextWin_Impl();
432 virtual long Notify( NotifyEvent& rNEvt );
435 // class SfxHelpTextWindow_Impl ------------------------------------------
437 class SvtMiscOptions;
438 class SfxHelpWindow_Impl;
440 class SfxHelpTextWindow_Impl : public Window
442 private:
443 ToolBox aToolBox;
444 CheckBox aOnStartupCB;
445 Timer aSelectTimer;
446 Image aIndexOnImage;
447 Image aIndexOffImage;
448 String aIndexOnText;
449 String aIndexOffText;
450 String aSearchText;
451 String aOnStartupText;
452 ::rtl::OUString sCurrentFactory;
454 SfxHelpWindow_Impl* pHelpWin;
455 Window* pTextWin;
456 sfx2::SearchDialog* pSrchDlg;
457 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
458 xFrame;
459 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >
460 xBreakIterator;
461 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
462 xConfiguration;
463 long nMinPos;
464 sal_Bool bIsDebug;
465 sal_Bool bIsIndexOn;
466 sal_Bool bIsInClose;
467 sal_Bool bIsFullWordSearch;
469 sal_Bool HasSelection() const;
470 void InitToolBoxImages();
471 void InitOnStartupBox( bool bOnlyText );
472 void SetOnStartupBoxPosition();
474 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >
475 GetBreakIterator();
476 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >
477 getCursor() const;
478 bool isHandledKey( const KeyCode& _rKeyCode );
480 DECL_LINK(SelectHdl, void *);
481 DECL_LINK( NotifyHdl, SvtMiscOptions* );
482 DECL_LINK( FindHdl, sfx2::SearchDialog* );
483 DECL_LINK( CloseHdl, sfx2::SearchDialog* );
484 DECL_LINK( CheckHdl, CheckBox* );
486 public:
487 SfxHelpTextWindow_Impl( SfxHelpWindow_Impl* pParent );
488 ~SfxHelpTextWindow_Impl();
490 virtual void Resize();
491 virtual long PreNotify( NotifyEvent& rNEvt );
492 virtual void GetFocus();
493 virtual void DataChanged( const DataChangedEvent& rDCEvt );
495 inline ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
496 getFrame() const { return xFrame; }
498 inline void SetSelectHdl( const Link& rLink ) { aToolBox.SetSelectHdl( rLink ); }
499 void ToggleIndex( sal_Bool bOn );
500 void SelectSearchText( const String& rSearchText, sal_Bool _bIsFullWordSearch );
501 void SetPageStyleHeaderOff() const;
502 inline ToolBox& GetToolBox() { return aToolBox; }
503 void CloseFrame();
504 void DoSearch();
507 // class SfxHelpWindow_Impl ----------------------------------------------
509 class HelpInterceptor_Impl;
510 class HelpListener_Impl;
511 class SfxHelpWindow_Impl : public SplitWindow
513 private:
514 friend class SfxHelpIndexWindow_Impl;
516 ::com::sun::star::uno::Reference < ::com::sun::star::awt::XWindow >
517 xWindow;
518 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchResultListener >
519 xOpenListener;
520 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
521 xFrame;
523 SfxHelpIndexWindow_Impl* pIndexWin;
524 SfxHelpTextWindow_Impl* pTextWin;
525 HelpInterceptor_Impl* pHelpInterceptor;
526 HelpListener_Impl* pHelpListener;
528 sal_Int32 nExpandWidth;
529 sal_Int32 nCollapseWidth;
530 sal_Int32 nHeight;
531 long nIndexSize;
532 long nTextSize;
533 sal_Bool bIndex;
534 sal_Bool bGrabFocusToToolBox;
535 Point aWinPos;
536 String sTitle;
537 String sKeyword;
539 virtual void Resize();
540 virtual void Split();
541 virtual void GetFocus();
543 void MakeLayout();
544 void InitSizes();
545 void LoadConfig();
546 void SaveConfig();
547 void ShowStartPage();
549 DECL_LINK( SelectHdl, ToolBox* );
550 DECL_LINK(OpenHdl, void *);
551 DECL_LINK( SelectFactoryHdl, SfxHelpIndexWindow_Impl* );
552 DECL_LINK( ChangeHdl, HelpListener_Impl* );
554 public:
555 SfxHelpWindow_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >& rFrame,
556 Window* pParent, WinBits nBits );
557 ~SfxHelpWindow_Impl();
559 virtual long PreNotify( NotifyEvent& rNEvt );
561 void setContainerWindow(
562 ::com::sun::star::uno::Reference < ::com::sun::star::awt::XWindow > xWin );
563 inline ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
564 getTextFrame() const { return pTextWin->getFrame(); }
565 inline ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchResultListener >
566 getOpenListener() const { return xOpenListener; }
568 void SetFactory( const String& rFactory );
569 void SetHelpURL( const String& rURL );
570 void DoAction( sal_uInt16 nActionId );
571 void CloseWindow();
573 void UpdateToolbox();
574 inline void OpenKeyword( const String& rKeyword ) { pIndexWin->OpenKeyword( rKeyword ); }
575 inline String GetFactory() const { return pIndexWin->GetFactory(); }
577 sal_Bool HasHistoryPredecessor() const; // forward to interceptor
578 sal_Bool HasHistorySuccessor() const; // forward to interceptor
580 void openDone(const ::rtl::OUString& sURL ,
581 sal_Bool bSuccess);
583 static ::rtl::OUString buildHelpURL(const ::rtl::OUString& sFactory ,
584 const ::rtl::OUString& sContent ,
585 const ::rtl::OUString& sAnchor ,
586 sal_Bool bUseQuestionMark);
588 void loadHelpContent(const ::rtl::OUString& sHelpURL ,
589 sal_Bool bAddToHistory = sal_True);
592 class SfxAddHelpBookmarkDialog_Impl : public ModalDialog
594 private:
595 FixedText aTitleFT;
596 Edit aTitleED;
597 OKButton aOKBtn;
598 CancelButton aEscBtn;
599 HelpButton aHelpBtn;
601 public:
602 SfxAddHelpBookmarkDialog_Impl( Window* pParent, sal_Bool bRename = sal_True );
603 ~SfxAddHelpBookmarkDialog_Impl();
605 void SetTitle( const String& rTitle );
606 inline String GetTitle() const { return aTitleED.GetText(); }
609 /// Appends ?Language=xy&System=abc to the help URL in rURL
610 void AppendConfigToken( String& rURL, sal_Bool bQuestionMark, const rtl::OUString &rLang = rtl::OUString() );
612 #endif // #ifndef INCLUDED_SFX_NEWHELP_HXX
614 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */