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