merge the formfield patch from ooo-build
[ooovba.git] / sfx2 / source / appl / newhelp.hxx
blobc32dc800ad781bcb90de8c89062e4bf6eab91ead
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: newhelp.hxx,v $
10 * $Revision: 1.59 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef INCLUDED_SFX_NEWHELP_HXX
31 #define INCLUDED_SFX_NEWHELP_HXX
33 #include <cppuhelper/implbase1.hxx>
34 #include <com/sun/star/uno/Reference.h>
35 #include <com/sun/star/frame/XDispatchResultListener.hpp>
36 #include <com/sun/star/frame/XDispatch.hpp>
37 #include <com/sun/star/frame/XFrame.hpp>
39 namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
40 namespace com { namespace sun { namespace star { namespace frame { class XFrame; } } } }
41 namespace com { namespace sun { namespace star { namespace i18n { class XBreakIterator; } } } }
42 namespace com { namespace sun { namespace star { namespace text { class XTextRange; } } } }
44 #include <vcl/window.hxx>
45 #include <vcl/toolbox.hxx>
46 #include <vcl/tabpage.hxx>
47 #include <vcl/splitwin.hxx>
48 #include <vcl/tabctrl.hxx>
49 #include <vcl/combobox.hxx>
50 #include <vcl/fixed.hxx>
51 #include <vcl/button.hxx>
52 #include <vcl/lstbox.hxx>
53 #include <vcl/dialog.hxx>
54 #include <svtools/svtreebx.hxx>
55 #include <svtools/moduleoptions.hxx>
57 #include "srchdlg.hxx"
59 // class OpenStatusListener_Impl -----------------------------------------
61 class OpenStatusListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XDispatchResultListener >
63 private:
64 sal_Bool m_bFinished;
65 sal_Bool m_bSuccess;
66 Link m_aOpenLink;
67 String m_sURL;
69 public:
70 OpenStatusListener_Impl() : m_bFinished( FALSE ), m_bSuccess( FALSE ) {}
72 virtual void SAL_CALL dispatchFinished( const ::com::sun::star::frame::DispatchResultEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
73 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
75 inline sal_Bool IsFinished() const { return m_bFinished; }
76 inline sal_Bool IsSuccessful() const { return m_bSuccess; }
77 inline void SetURL( const String& rURL ) { m_sURL = rURL; }
78 inline String GetURL() const { return m_sURL; }
79 inline void SetOpenHdl( const Link& rLink ) { m_aOpenLink = rLink; }
82 // ContentListBox_Impl ---------------------------------------------------
84 class ContentListBox_Impl : public SvTreeListBox
86 private:
87 Image aOpenBookImage;
88 Image aClosedBookImage;
89 Image aDocumentImage;
91 void InitRoot();
92 void ClearChildren( SvLBoxEntry* pParent );
94 public:
95 ContentListBox_Impl( Window* pParent, const ResId& rResId );
96 ~ContentListBox_Impl();
99 virtual void RequestingChilds( SvLBoxEntry* pParent );
100 virtual long Notify( NotifyEvent& rNEvt );
102 inline void SetOpenHdl( const Link& rLink ) { SetDoubleClickHdl( rLink ); }
103 String GetSelectEntry() const;
106 // class HelpTabPage_Impl ------------------------------------------------
108 class SfxHelpIndexWindow_Impl;
110 class HelpTabPage_Impl : public TabPage
112 protected:
113 SfxHelpIndexWindow_Impl* m_pIdxWin;
115 public:
116 HelpTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin, const ResId& rResId );
118 virtual Control* GetLastFocusControl() = 0;
121 // class ContentTabPage_Impl ---------------------------------------------
123 class ContentTabPage_Impl : public HelpTabPage_Impl
125 private:
126 ContentListBox_Impl aContentBox;
128 public:
129 ContentTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin );
131 virtual void Resize();
132 virtual void ActivatePage();
133 virtual Control* GetLastFocusControl();
135 inline void SetOpenHdl( const Link& rLink ) { aContentBox.SetOpenHdl( rLink ); }
136 inline String GetSelectEntry() const { return aContentBox.GetSelectEntry(); }
137 inline void SetFocusOnBox() { aContentBox.GrabFocus(); }
140 // class IndexTabPage_Impl -----------------------------------------------
142 class IndexBox_Impl : public ComboBox
144 public:
145 IndexBox_Impl( Window* pParent, const ResId& rResId );
147 virtual void UserDraw( const UserDrawEvent& rUDEvt );
148 virtual long Notify( NotifyEvent& rNEvt );
150 void SelectExecutableEntry();
153 class IndexTabPage_Impl : public HelpTabPage_Impl
155 private:
156 FixedText aExpressionFT;
157 IndexBox_Impl aIndexCB;
158 PushButton aOpenBtn;
160 Timer aFactoryTimer;
161 Timer aKeywordTimer;
162 Link aKeywordLink;
164 String sFactory;
165 String sKeyword;
167 long nMinWidth;
168 sal_Bool bIsActivated;
170 void InitializeIndex();
171 void ClearIndex();
173 DECL_LINK( OpenHdl, PushButton* );
174 DECL_LINK( TimeoutHdl, Timer* );
176 public:
177 IndexTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin );
178 ~IndexTabPage_Impl();
180 virtual void Resize();
181 virtual void ActivatePage();
182 virtual Control* GetLastFocusControl();
184 void SetDoubleClickHdl( const Link& rLink );
185 void SetFactory( const String& rFactory );
186 inline String GetFactory() const { return sFactory; }
187 String GetSelectEntry() const;
188 inline void SetFocusOnBox() { aIndexCB.GrabFocus(); }
189 inline sal_Bool HasFocusOnEdit() const { return aIndexCB.HasChildPathFocus(); }
191 inline void SetKeywordHdl( const Link& rLink ) { aKeywordLink = rLink; }
192 void SetKeyword( const String& rKeyword );
193 sal_Bool HasKeyword() const;
194 sal_Bool HasKeywordIgnoreCase(); //added by BerryJia for fixing Bug98251, 2002-12-11
195 void OpenKeyword();
197 inline void SelectExecutableEntry() { aIndexCB.SelectExecutableEntry(); }
200 // class SearchTabPage_Impl ----------------------------------------------
202 class SearchBox_Impl : public ComboBox
204 private:
205 Link aSearchLink;
207 public:
208 SearchBox_Impl( Window* pParent, const ResId& rResId ) :
209 ComboBox( pParent, rResId ) { SetDropDownLineCount( 5 ); }
211 virtual long PreNotify( NotifyEvent& rNEvt );
212 virtual void Select();
214 inline void SetSearchLink( const Link& rLink ) { aSearchLink = rLink; }
217 class SearchResultsBox_Impl : public ListBox
219 public:
220 SearchResultsBox_Impl( Window* pParent, const ResId& rResId ) : ListBox( pParent, rResId ) {}
222 virtual long Notify( NotifyEvent& rNEvt );
225 class SearchTabPage_Impl : public HelpTabPage_Impl
227 private:
228 FixedText aSearchFT;
229 SearchBox_Impl aSearchED;
230 PushButton aSearchBtn;
231 CheckBox aFullWordsCB;
232 CheckBox aScopeCB;
233 SearchResultsBox_Impl aResultsLB;
234 PushButton aOpenBtn;
236 Size aMinSize;
237 String aFactory;
239 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >
240 xBreakIterator;
242 void ClearSearchResults();
243 void RememberSearchText( const String& rSearchText );
245 DECL_LINK( SearchHdl, PushButton* );
246 DECL_LINK( OpenHdl, PushButton* );
247 DECL_LINK( ModifyHdl, Edit* );
249 public:
250 SearchTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin );
251 ~SearchTabPage_Impl();
253 virtual void Resize();
254 virtual void ActivatePage();
255 virtual Control* GetLastFocusControl();
257 void SetDoubleClickHdl( const Link& rLink );
258 inline void SetFactory( const String& rFactory ) { aFactory = rFactory; }
259 String GetSelectEntry() const;
260 void ClearPage();
261 inline void SetFocusOnBox() { aResultsLB.GrabFocus(); }
262 inline sal_Bool HasFocusOnEdit() const { return aSearchED.HasChildPathFocus(); }
263 inline String GetSearchText() const { return aSearchED.GetText(); }
264 inline sal_Bool IsFullWordSearch() const { return aFullWordsCB.IsChecked(); }
265 sal_Bool OpenKeyword( const String& rKeyword );
268 // class BookmarksTabPage_Impl -------------------------------------------
270 class BookmarksBox_Impl : public ListBox
272 private:
273 void DoAction( USHORT nAction );
275 public:
276 BookmarksBox_Impl( Window* pParent, const ResId& rResId );
277 ~BookmarksBox_Impl();
279 virtual long Notify( NotifyEvent& rNEvt );
282 class BookmarksTabPage_Impl : public HelpTabPage_Impl
284 private:
285 FixedText aBookmarksFT;
286 BookmarksBox_Impl aBookmarksBox;
287 PushButton aBookmarksPB;
289 long nMinWidth;
291 DECL_LINK( OpenHdl, PushButton* );
293 public:
294 BookmarksTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin );
296 virtual void Resize();
297 virtual void ActivatePage();
298 virtual Control* GetLastFocusControl();
300 void SetDoubleClickHdl( const Link& rLink );
301 String GetSelectEntry() const;
302 void AddBookmarks( const String& rTitle, const String& rURL );
303 inline void SetFocusOnBox() { aBookmarksBox.GrabFocus(); }
306 // class SfxHelpIndexWindow_Impl -----------------------------------------
308 class SfxHelpWindow_Impl;
310 class SfxHelpIndexWindow_Impl : public Window
312 private:
313 ListBox aActiveLB;
314 FixedLine aActiveLine;
316 TabControl aTabCtrl;
317 Timer aTimer;
319 Link aSelectFactoryLink;
320 Link aPageDoubleClickLink;
321 Link aIndexKeywordLink;
322 String sKeyword;
324 SfxHelpWindow_Impl* pParentWin;
326 ContentTabPage_Impl* pCPage;
327 IndexTabPage_Impl* pIPage;
328 SearchTabPage_Impl* pSPage;
329 BookmarksTabPage_Impl* pBPage;
331 long nMinWidth;
332 bool bWasCursorLeftOrRight;
333 bool bIsInitDone;
335 void Initialize();
336 void SetActiveFactory();
337 HelpTabPage_Impl* GetCurrentPage( USHORT& rCurId );
339 inline ContentTabPage_Impl* GetContentPage();
340 inline IndexTabPage_Impl* GetIndexPage();
341 inline SearchTabPage_Impl* GetSearchPage();
342 inline BookmarksTabPage_Impl* GetBookmarksPage();
344 DECL_LINK( ActivatePageHdl, TabControl* );
345 DECL_LINK( SelectHdl, ListBox* );
346 DECL_LINK( InitHdl, Timer* );
347 DECL_LINK( SelectFactoryHdl, Timer* );
348 DECL_LINK( KeywordHdl, IndexTabPage_Impl* );
350 public:
351 SfxHelpIndexWindow_Impl( SfxHelpWindow_Impl* pParent );
352 ~SfxHelpIndexWindow_Impl();
354 virtual void Resize();
355 virtual long PreNotify( NotifyEvent& rNEvt );
356 virtual void DataChanged( const DataChangedEvent& rDCEvt );
358 void SetDoubleClickHdl( const Link& rLink );
359 inline void SetSelectFactoryHdl( const Link& rLink ) { aSelectFactoryLink = rLink; }
360 void SetFactory( const String& rFactory, sal_Bool bActive );
361 inline String GetFactory() const { return pIPage->GetFactory(); }
362 String GetSelectEntry() const;
363 void AddBookmarks( const String& rTitle, const String& rURL );
364 bool IsValidFactory( const String& _rFactory );
365 inline String GetActiveFactoryTitle() const { return aActiveLB.GetSelectEntry(); }
366 inline void UpdateTabControl() { aTabCtrl.Invalidate(); }
367 void ClearSearchPage();
368 void GrabFocusBack();
369 sal_Bool HasFocusOnEdit() const;
370 String GetSearchText() const;
371 sal_Bool IsFullWordSearch() const;
372 void OpenKeyword( const String& rKeyword );
373 void SelectExecutableEntry();
374 inline bool WasCursorLeftOrRight();
377 // inlines ---------------------------------------------------------------
379 ContentTabPage_Impl* SfxHelpIndexWindow_Impl::GetContentPage()
381 if ( !pCPage )
383 pCPage = new ContentTabPage_Impl( &aTabCtrl, this );
384 pCPage->SetOpenHdl( aPageDoubleClickLink );
386 return pCPage;
388 IndexTabPage_Impl* SfxHelpIndexWindow_Impl::GetIndexPage()
390 if ( !pIPage )
392 pIPage = new IndexTabPage_Impl( &aTabCtrl, this );
393 pIPage->SetDoubleClickHdl( aPageDoubleClickLink );
394 pIPage->SetKeywordHdl( aIndexKeywordLink );
396 return pIPage;
399 SearchTabPage_Impl* SfxHelpIndexWindow_Impl::GetSearchPage()
401 if ( !pSPage )
403 pSPage = new SearchTabPage_Impl( &aTabCtrl, this );
404 pSPage->SetDoubleClickHdl( aPageDoubleClickLink );
406 return pSPage;
409 BookmarksTabPage_Impl* SfxHelpIndexWindow_Impl::GetBookmarksPage()
411 if ( !pBPage )
413 pBPage = new BookmarksTabPage_Impl( &aTabCtrl, this );
414 pBPage->SetDoubleClickHdl( aPageDoubleClickLink );
416 return pBPage;
419 bool SfxHelpIndexWindow_Impl::WasCursorLeftOrRight()
421 bool bRet = bWasCursorLeftOrRight;
422 bWasCursorLeftOrRight = false;
423 return bRet;
426 // class TextWin_Impl ----------------------------------------------------
428 class TextWin_Impl : public DockingWindow
430 public:
431 TextWin_Impl( Window* pParent );
432 virtual ~TextWin_Impl();
434 virtual long Notify( NotifyEvent& rNEvt );
437 // class SfxHelpTextWindow_Impl ------------------------------------------
439 class SvtMiscOptions;
440 class SfxHelpWindow_Impl;
442 class SfxHelpTextWindow_Impl : public Window
444 private:
445 ToolBox aToolBox;
446 CheckBox aOnStartupCB;
447 Timer aSelectTimer;
448 Image aIndexOnImage;
449 Image aIndexOffImage;
450 String aIndexOnText;
451 String aIndexOffText;
452 String aSearchText;
453 String aOnStartupText;
454 ::rtl::OUString sCurrentFactory;
456 SfxHelpWindow_Impl* pHelpWin;
457 Window* pTextWin;
458 sfx2::SearchDialog* pSrchDlg;
459 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
460 xFrame;
461 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >
462 xBreakIterator;
463 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
464 xConfiguration;
465 long nMinPos;
466 sal_Bool bIsDebug;
467 sal_Bool bIsIndexOn;
468 sal_Bool bIsInClose;
469 sal_Bool bIsFullWordSearch;
471 sal_Bool HasSelection() const;
472 void InitToolBoxImages();
473 void InitOnStartupBox( bool bOnlyText );
474 void SetOnStartupBoxPosition();
476 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >
477 GetBreakIterator();
478 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >
479 getCursor() const;
480 bool isHandledKey( const KeyCode& _rKeyCode );
482 DECL_LINK( SelectHdl, Timer* );
483 DECL_LINK( NotifyHdl, SvtMiscOptions* );
484 DECL_LINK( FindHdl, sfx2::SearchDialog* );
485 DECL_LINK( CloseHdl, sfx2::SearchDialog* );
486 DECL_LINK( CheckHdl, CheckBox* );
488 public:
489 SfxHelpTextWindow_Impl( SfxHelpWindow_Impl* pParent );
490 ~SfxHelpTextWindow_Impl();
492 virtual void Resize();
493 virtual long PreNotify( NotifyEvent& rNEvt );
494 virtual void GetFocus();
495 virtual void DataChanged( const DataChangedEvent& rDCEvt );
497 inline ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
498 getFrame() const { return xFrame; }
500 inline void SetSelectHdl( const Link& rLink ) { aToolBox.SetSelectHdl( rLink ); }
501 void ToggleIndex( sal_Bool bOn );
502 void SelectSearchText( const String& rSearchText, sal_Bool _bIsFullWordSearch );
503 void SetPageStyleHeaderOff() const;
504 inline ToolBox& GetToolBox() { return aToolBox; }
505 void CloseFrame();
506 void DoSearch();
509 // class SfxHelpWindow_Impl ----------------------------------------------
511 class HelpInterceptor_Impl;
512 class HelpListener_Impl;
513 class SfxHelpWindow_Impl : public SplitWindow
515 private:
516 friend class SfxHelpIndexWindow_Impl;
518 ::com::sun::star::uno::Reference < ::com::sun::star::awt::XWindow >
519 xWindow;
520 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchResultListener >
521 xOpenListener;
522 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
523 xFrame;
525 SfxHelpIndexWindow_Impl* pIndexWin;
526 SfxHelpTextWindow_Impl* pTextWin;
527 HelpInterceptor_Impl* pHelpInterceptor;
528 HelpListener_Impl* pHelpListener;
530 sal_Int32 nExpandWidth;
531 sal_Int32 nCollapseWidth;
532 sal_Int32 nHeight;
533 long nIndexSize;
534 long nTextSize;
535 sal_Bool bIndex;
536 sal_Bool bGrabFocusToToolBox;
537 Point aWinPos;
538 String sTitle;
539 String sKeyword;
541 virtual void Resize();
542 virtual void Split();
543 virtual void GetFocus();
545 void MakeLayout();
546 void InitSizes();
547 void LoadConfig();
548 void SaveConfig();
549 void ShowStartPage();
551 DECL_LINK( SelectHdl, ToolBox* );
552 DECL_LINK( OpenHdl, SfxHelpIndexWindow_Impl* );
553 DECL_LINK( SelectFactoryHdl, SfxHelpIndexWindow_Impl* );
554 DECL_LINK( ChangeHdl, HelpListener_Impl* );
556 public:
557 SfxHelpWindow_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >& rFrame,
558 Window* pParent, WinBits nBits );
559 ~SfxHelpWindow_Impl();
561 virtual long PreNotify( NotifyEvent& rNEvt );
563 void setContainerWindow(
564 ::com::sun::star::uno::Reference < ::com::sun::star::awt::XWindow > xWin );
565 inline ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
566 getTextFrame() const { return pTextWin->getFrame(); }
567 inline ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchResultListener >
568 getOpenListener() const { return xOpenListener; }
570 void SetFactory( const String& rFactory );
571 void SetHelpURL( const String& rURL );
572 void DoAction( USHORT nActionId );
573 void CloseWindow();
575 void UpdateToolbox();
576 inline void OpenKeyword( const String& rKeyword ) { pIndexWin->OpenKeyword( rKeyword ); }
577 inline String GetFactory() const { return pIndexWin->GetFactory(); }
579 sal_Bool HasHistoryPredecessor() const; // forward to interceptor
580 sal_Bool HasHistorySuccessor() const; // forward to interceptor
582 void openDone(const ::rtl::OUString& sURL ,
583 sal_Bool bSuccess);
585 static sal_Bool splitHelpURL(const ::rtl::OUString& sHelpURL,
586 ::rtl::OUString& sFactory,
587 ::rtl::OUString& sContent,
588 ::rtl::OUString& sAnchor );
590 static ::rtl::OUString buildHelpURL(const ::rtl::OUString& sFactory ,
591 const ::rtl::OUString& sContent ,
592 const ::rtl::OUString& sAnchor ,
593 sal_Bool bUseQuestionMark);
595 void loadHelpContent(const ::rtl::OUString& sHelpURL ,
596 sal_Bool bAddToHistory = sal_True);
599 class SfxAddHelpBookmarkDialog_Impl : public ModalDialog
601 private:
602 FixedText aTitleFT;
603 Edit aTitleED;
604 OKButton aOKBtn;
605 CancelButton aEscBtn;
606 HelpButton aHelpBtn;
608 public:
609 SfxAddHelpBookmarkDialog_Impl( Window* pParent, sal_Bool bRename = sal_True );
610 ~SfxAddHelpBookmarkDialog_Impl();
612 void SetTitle( const String& rTitle );
613 inline String GetTitle() const { return aTitleED.GetText(); }
616 #endif // #ifndef INCLUDED_SFX_NEWHELP_HXX