LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sfx2/source/appl - newhelp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1686 0.1 %
Date: 2013-07-09 Functions: 2 182 1.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "newhelp.hxx"
      22             : #include <sfx2/sfxuno.hxx>
      23             : #include "sfx2/sfxresid.hxx"
      24             : #include "helpinterceptor.hxx"
      25             : #include "helper.hxx"
      26             : #include <sfx2/msgpool.hxx>
      27             : #include <sfx2/app.hxx>
      28             : #include "sfxtypes.hxx"
      29             : #include "panelist.hxx"
      30             : #include "sfx2/imgmgr.hxx"
      31             : #include "srchdlg.hxx"
      32             : #include "sfx2/sfxhelp.hxx"
      33             : #include "svtools/treelistentry.hxx"
      34             : 
      35             : #include "app.hrc"
      36             : #include "newhelp.hrc"
      37             : #include "helpid.hrc"
      38             : 
      39             : #include <boost/unordered_map.hpp>
      40             : #include <rtl/ustrbuf.hxx>
      41             : #include <comphelper/configurationhelper.hxx>
      42             : #include <comphelper/processfactory.hxx>
      43             : #include <comphelper/string.hxx>
      44             : #include <toolkit/helper/vclunohelper.hxx>
      45             : #include <com/sun/star/awt/PosSize.hpp>
      46             : #include <com/sun/star/awt/XWindow.hpp>
      47             : #include <com/sun/star/beans/Property.hpp>
      48             : #include <com/sun/star/beans/PropertyValue.hpp>
      49             : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      50             : #include <com/sun/star/container/XIndexAccess.hpp>
      51             : #include <com/sun/star/frame/XComponentLoader.hpp>
      52             : #include <com/sun/star/frame/XTitle.hpp>
      53             : #include <com/sun/star/frame/XLayoutManager.hpp>
      54             : #include <com/sun/star/frame/DispatchResultState.hpp>
      55             : #include <com/sun/star/frame/XController.hpp>
      56             : #include <com/sun/star/frame/XDispatch.hpp>
      57             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      58             : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
      59             : #include <com/sun/star/frame/Frame.hpp>
      60             : #include <com/sun/star/i18n/XBreakIterator.hpp>
      61             : #include <com/sun/star/i18n/WordType.hpp>
      62             : #include <com/sun/star/lang/XComponent.hpp>
      63             : #include <com/sun/star/lang/DisposedException.hpp>
      64             : #include <com/sun/star/style/XStyle.hpp>
      65             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      66             : #include <com/sun/star/text/XText.hpp>
      67             : #include <com/sun/star/text/XTextCursor.hpp>
      68             : #include <com/sun/star/text/XTextDocument.hpp>
      69             : #include <com/sun/star/text/XTextRange.hpp>
      70             : #include <com/sun/star/text/XTextViewCursor.hpp>
      71             : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
      72             : #include <com/sun/star/ucb/CommandAbortedException.hpp>
      73             : #include <com/sun/star/util/URL.hpp>
      74             : #include <com/sun/star/util/XSearchable.hpp>
      75             : #include <com/sun/star/util/XSearchDescriptor.hpp>
      76             : #include <com/sun/star/util/URLTransformer.hpp>
      77             : #include <com/sun/star/util/XURLTransformer.hpp>
      78             : #include <com/sun/star/util/XModifiable.hpp>
      79             : #include <com/sun/star/util/XCloseable.hpp>
      80             : #include <com/sun/star/util/CloseVetoException.hpp>
      81             : #include <com/sun/star/ui/XDockingAreaAcceptor.hpp>
      82             : #include <com/sun/star/view/XSelectionSupplier.hpp>
      83             : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
      84             : #include <svtools/helpopt.hxx>
      85             : #include <unotools/historyoptions.hxx>
      86             : #include <svtools/menuoptions.hxx>
      87             : #include <unotools/pathoptions.hxx>
      88             : #include <unotools/viewoptions.hxx>
      89             : #include <svtools/svtresid.hxx>
      90             : #include <tools/urlobj.hxx>
      91             : #include <unotools/streamhelper.hxx>
      92             : #include <svtools/imagemgr.hxx>
      93             : #include <svtools/miscopt.hxx>
      94             : #include <svtools/imgdef.hxx>
      95             : #include <vcl/unohelp.hxx>
      96             : #include <vcl/i18nhelp.hxx>
      97             : 
      98             : #include <ucbhelper/content.hxx>
      99             : #include <vcl/msgbox.hxx>
     100             : #include <vcl/waitobj.hxx>
     101             : #include <unotools/ucbhelper.hxx>
     102             : 
     103             : #include <sfx2/viewfrm.hxx>
     104             : #include <sfx2/objsh.hxx>
     105             : #include <sfx2/docfac.hxx>
     106             : 
     107             : #include <vector>
     108             : 
     109             : using namespace ::ucbhelper;
     110             : using namespace ::com::sun::star::ucb;
     111             : 
     112             : using namespace ::com::sun::star;
     113             : using namespace ::com::sun::star::beans;
     114             : using namespace ::com::sun::star::container;
     115             : using namespace ::com::sun::star::frame;
     116             : using namespace ::com::sun::star::i18n;
     117             : using namespace ::com::sun::star::lang;
     118             : using namespace ::com::sun::star::style;
     119             : using namespace ::com::sun::star::text;
     120             : using namespace ::com::sun::star::uno;
     121             : using namespace ::com::sun::star::util;
     122             : using namespace ::com::sun::star::view;
     123             : using namespace ::com::sun::star::ui;
     124             : 
     125             : using namespace ::comphelper;
     126             : 
     127             : // defines ---------------------------------------------------------------
     128             : 
     129             : #define SPLITSET_ID         0
     130             : #define COLSET_ID           1
     131             : #define INDEXWIN_ID         2
     132             : #define TEXTWIN_ID          3
     133             : 
     134             : #define TOOLBOX_OFFSET      3
     135             : 
     136             : #define TBI_INDEX           1001
     137             : #define TBI_BACKWARD        1002
     138             : #define TBI_FORWARD         1003
     139             : #define TBI_START           1004
     140             : #define TBI_PRINT           1005
     141             : #define TBI_COPY            1006
     142             : #define TBI_BOOKMARKS       1007
     143             : #define TBI_SEARCHDIALOG    1008
     144             : #define TBI_SOURCEVIEW      1009
     145             : #define TBI_SELECTIONMODE   1010
     146             : 
     147             : #define CONFIGNAME_HELPWIN      "OfficeHelp"
     148             : #define CONFIGNAME_INDEXWIN     "OfficeHelpIndex"
     149             : #define CONFIGNAME_SEARCHPAGE   "OfficeHelpSearch"
     150             : #define IMAGE_URL               "private:factory/"
     151             : 
     152             : #define PROPERTY_KEYWORDLIST    "KeywordList"
     153             : #define PROPERTY_KEYWORDREF     "KeywordRef"
     154             : #define PROPERTY_ANCHORREF      "KeywordAnchorForRef"
     155             : #define PROPERTY_TITLEREF       "KeywordTitleForRef"
     156             : #define PROPERTY_TITLE          "Title"
     157             : #define HELP_URL                "vnd.sun.star.help://"
     158             : #define HELP_SEARCH_TAG         "/?Query="
     159             : #define USERITEM_NAME           "UserItem"
     160             : 
     161             : #define PACKAGE_SETUP           "/org.openoffice.Setup"
     162             : #define PATH_OFFICE_FACTORIES   "Office/Factories/"
     163             : #define KEY_HELP_ON_OPEN        "ooSetupFactoryHelpOnOpen"
     164             : #define KEY_UI_NAME             "ooSetupFactoryUIName"
     165             : 
     166             : #define PARSE_URL( aURL ) \
     167             :     Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); \
     168             :     xTrans->parseStrict( aURL )
     169             : 
     170             : //.........................................................................
     171             : namespace sfx2
     172             : {
     173             : //.........................................................................
     174             : 
     175           0 :     void HandleTaskPaneList( Window* pWindow, sal_Bool bAddToList )
     176             :     {
     177           0 :         Window* pParent = pWindow->GetParent();
     178             :         DBG_ASSERT( pParent, "HandleTaskPaneList(): every window here should have a parent" );
     179             : 
     180           0 :         SystemWindow* pSysWin = pParent->GetSystemWindow();
     181           0 :         if( pSysWin )
     182             :         {
     183           0 :             TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList();
     184           0 :             if( pTaskPaneList )
     185             :             {
     186           0 :                 if( bAddToList )
     187           0 :                     pTaskPaneList->AddWindow( pWindow );
     188             :                 else
     189           0 :                     pTaskPaneList->RemoveWindow( pWindow );
     190             :             }
     191             :         }
     192           0 :     }
     193             : 
     194             :     /** Prepare a search string for searching or selecting.
     195             :         For searching every search word needs the postfix '*' and the delimiter ' ' if necessary.
     196             :         For selecting the delimiter '|' is required to search with regular expressions.
     197             :         Samples:
     198             :         search string | output for searching | output for selecting
     199             :         -----------------------------------------------------------
     200             :         "text"        | "text*"              | "text"
     201             :         "text*"       | "text*"              | "text"
     202             :         "text menu"   | "text* menu*"        | "text|menu"
     203             :     */
     204           0 :     String PrepareSearchString( const String& rSearchString,
     205             :                                 Reference< XBreakIterator > xBreak, bool bForSearch )
     206             :     {
     207           0 :         String sSearchStr;
     208           0 :         sal_Int32 nStartPos = 0;
     209           0 :         const Locale aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
     210           0 :         Boundary aBoundary = xBreak->getWordBoundary(
     211           0 :             rSearchString, nStartPos, aLocale, WordType::ANYWORD_IGNOREWHITESPACES, sal_True );
     212             : 
     213           0 :         while ( aBoundary.startPos != aBoundary.endPos )
     214             :         {
     215           0 :             nStartPos = aBoundary.endPos;
     216             :             String sSearchToken( rSearchString.Copy(
     217           0 :                 (sal_uInt16)aBoundary.startPos, (sal_uInt16)aBoundary.endPos - (sal_uInt16)aBoundary.startPos ) );
     218           0 :             if ( sSearchToken.Len() > 0 && ( sSearchToken.Len() > 1 || sSearchToken.GetChar(0) != '.' ) )
     219             :             {
     220           0 :                 if ( bForSearch && sSearchToken.GetChar( sSearchToken.Len() - 1 ) != '*' )
     221           0 :                     sSearchToken += '*';
     222             : 
     223           0 :                 if ( sSearchToken.Len() > 1 ||
     224           0 :                      ( sSearchToken.Len() > 0 && sSearchToken.GetChar( 0 ) != '*' ) )
     225             :                 {
     226           0 :                     if ( sSearchStr.Len() > 0 )
     227             :                     {
     228           0 :                         if ( bForSearch )
     229           0 :                             sSearchStr += ' ';
     230             :                         else
     231           0 :                             sSearchStr += '|';
     232             :                     }
     233           0 :                     sSearchStr += sSearchToken;
     234             :                 }
     235             :             }
     236           0 :             aBoundary = xBreak->nextWord( rSearchString, nStartPos,
     237           0 :                                           aLocale, WordType::ANYWORD_IGNOREWHITESPACES );
     238           0 :         }
     239             : 
     240           0 :         return sSearchStr;
     241             :     }
     242             : //.........................................................................
     243             : // namespace sfx2
     244             : }
     245             : //.........................................................................
     246             : 
     247             : // struct IndexEntry_Impl ------------------------------------------------
     248             : 
     249           0 : struct IndexEntry_Impl
     250             : {
     251             :     sal_Bool        m_bSubEntry;
     252             :     String          m_aURL;
     253             : 
     254           0 :     IndexEntry_Impl( const String& rURL, sal_Bool bSubEntry ) :
     255           0 :         m_bSubEntry( bSubEntry ), m_aURL( rURL ) {}
     256             : };
     257             : 
     258             : #define NEW_ENTRY( url, bool ) \
     259             :     (void*)(sal_uIntPtr)( new IndexEntry_Impl( url, bool ) )
     260             : 
     261             : // struct ContentEntry_Impl ----------------------------------------------
     262             : 
     263           0 : struct ContentEntry_Impl
     264             : {
     265             :     String      aURL;
     266             :     sal_Bool    bIsFolder;
     267             : 
     268           0 :     ContentEntry_Impl( const String& rURL, sal_Bool bFolder ) :
     269           0 :         aURL( rURL ), bIsFolder( bFolder ) {}
     270             : };
     271             : 
     272             : // ContentListBox_Impl ---------------------------------------------------
     273             : 
     274           0 : ContentListBox_Impl::ContentListBox_Impl( Window* pParent, const ResId& rResId ) :
     275             : 
     276             :     SvTreeListBox( pParent, rResId ),
     277             : 
     278             :     aOpenBookImage      ( SfxResId( IMG_HELP_CONTENT_BOOK_OPEN ) ),
     279             :     aClosedBookImage    ( SfxResId( IMG_HELP_CONTENT_BOOK_CLOSED ) ),
     280           0 :     aDocumentImage      ( SfxResId( IMG_HELP_CONTENT_DOC ) )
     281             : 
     282             : {
     283           0 :     SetStyle( GetStyle() | WB_HIDESELECTION | WB_HSCROLL );
     284             : 
     285           0 :     SetEntryHeight( 16 );
     286           0 :     SetSelectionMode( SINGLE_SELECTION );
     287           0 :     SetSpaceBetweenEntries( 2 );
     288           0 :     SetNodeBitmaps( aClosedBookImage, aOpenBookImage );
     289             : 
     290           0 :     SetSublistOpenWithReturn();
     291           0 :     SetSublistOpenWithLeftRight();
     292             : 
     293           0 :     InitRoot();
     294           0 : }
     295             : 
     296             : // -----------------------------------------------------------------------
     297             : 
     298           0 : ContentListBox_Impl::~ContentListBox_Impl()
     299             : {
     300           0 :     sal_uInt16 nPos = 0;
     301           0 :     SvTreeListEntry* pEntry = GetEntry( nPos++ );
     302           0 :     while ( pEntry )
     303             :     {
     304           0 :         ClearChildren( pEntry );
     305           0 :         delete (ContentEntry_Impl*)pEntry->GetUserData();
     306           0 :         pEntry = GetEntry( nPos++ );
     307             :     }
     308           0 : }
     309             : 
     310             : // -----------------------------------------------------------------------
     311             : 
     312           0 : void ContentListBox_Impl::InitRoot()
     313             : {
     314           0 :     OUString aHelpTreeviewURL( "vnd.sun.star.hier://com.sun.star.help.TreeView/" );
     315             :     std::vector< OUString > aList =
     316           0 :         SfxContentHelper::GetHelpTreeViewContents( aHelpTreeviewURL );
     317             : 
     318           0 :     for(size_t i = 0, n = aList.size(); i < n; ++i )
     319             :     {
     320           0 :         const OUString& aRow = aList[i];
     321           0 :         sal_Int32 nIdx = 0;
     322           0 :         OUString aTitle = aRow.getToken( 0, '\t', nIdx );
     323           0 :         OUString aURL = aRow.getToken( 0, '\t', nIdx );
     324           0 :         sal_Unicode cFolder = aRow.getToken( 0, '\t', nIdx )[0];
     325           0 :         bool bIsFolder = ( '1' == cFolder );
     326           0 :         SvTreeListEntry* pEntry = InsertEntry( aTitle, aOpenBookImage, aClosedBookImage, NULL, sal_True );
     327           0 :         if ( bIsFolder )
     328           0 :             pEntry->SetUserData( new ContentEntry_Impl( aURL, sal_True ) );
     329           0 :     }
     330           0 : }
     331             : 
     332             : // -----------------------------------------------------------------------
     333             : 
     334           0 : void ContentListBox_Impl::ClearChildren( SvTreeListEntry* pParent )
     335             : {
     336           0 :     SvTreeListEntry* pEntry = FirstChild( pParent );
     337           0 :     while ( pEntry )
     338             :     {
     339           0 :         ClearChildren( pEntry );
     340           0 :         delete (ContentEntry_Impl*)pEntry->GetUserData();
     341           0 :         pEntry = NextSibling( pEntry );
     342             :     }
     343           0 : }
     344             : 
     345             : // -----------------------------------------------------------------------
     346             : 
     347           0 : void ContentListBox_Impl::RequestingChildren( SvTreeListEntry* pParent )
     348             : {
     349             :     try
     350             :     {
     351           0 :         if ( !pParent->HasChildren() )
     352             :         {
     353           0 :             if ( pParent->GetUserData() )
     354             :             {
     355           0 :                 String aTmpURL( ( (ContentEntry_Impl*)pParent->GetUserData()  )->aURL );
     356             :                 std::vector<OUString > aList =
     357           0 :                     SfxContentHelper::GetHelpTreeViewContents( aTmpURL );
     358             : 
     359           0 :                 for (size_t i = 0,n = aList.size(); i < n; ++i )
     360             :                 {
     361           0 :                     const OUString& aRow = aList[i];
     362           0 :                     sal_Int32 nIdx = 0;
     363           0 :                     OUString aTitle = aRow.getToken( 0, '\t', nIdx );
     364           0 :                     OUString aURL = aRow.getToken( 0, '\t', nIdx );
     365           0 :                     sal_Unicode cFolder = aRow.getToken( 0, '\t', nIdx )[0];
     366           0 :                     bool bIsFolder = ( '1' == cFolder );
     367           0 :                     SvTreeListEntry* pEntry = NULL;
     368           0 :                     if ( bIsFolder )
     369             :                     {
     370           0 :                         pEntry = InsertEntry( aTitle, aOpenBookImage, aClosedBookImage, pParent, sal_True );
     371           0 :                         pEntry->SetUserData( new ContentEntry_Impl( aURL, sal_True ) );
     372             :                     }
     373             :                     else
     374             :                     {
     375           0 :                         pEntry = InsertEntry( aTitle, aDocumentImage, aDocumentImage, pParent );
     376           0 :                         Any aAny( ::utl::UCBContentHelper::GetProperty( aURL, String("TargetURL"  ) ) );
     377           0 :                         OUString aTargetURL;
     378           0 :                         if ( aAny >>= aTargetURL )
     379           0 :                             pEntry->SetUserData( new ContentEntry_Impl( aTargetURL, sal_False ) );
     380             :                     }
     381           0 :                 }
     382             :             }
     383             :         }
     384             :     }
     385           0 :     catch( Exception& )
     386             :     {
     387             :         OSL_FAIL( "ContentListBox_Impl::RequestingChildren(): unexpected exception" );
     388             :     }
     389           0 : }
     390             : 
     391             : // -----------------------------------------------------------------------
     392             : 
     393           0 : long ContentListBox_Impl::Notify( NotifyEvent& rNEvt )
     394             : {
     395           0 :     sal_Bool bHandled = sal_False;
     396           0 :     if ( rNEvt.GetType() == EVENT_KEYINPUT &&
     397           0 :          KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
     398             :     {
     399           0 :         GetDoubleClickHdl().Call( NULL );
     400           0 :         bHandled = sal_True;
     401             :     }
     402             : 
     403           0 :     return bHandled ? 1 : SvTreeListBox::Notify( rNEvt );
     404             : }
     405             : 
     406             : // -----------------------------------------------------------------------
     407             : 
     408           0 : String ContentListBox_Impl::GetSelectEntry() const
     409             : {
     410           0 :     String aRet;
     411           0 :     SvTreeListEntry* pEntry = FirstSelected();
     412           0 :     if ( pEntry && !( (ContentEntry_Impl*)pEntry->GetUserData()  )->bIsFolder )
     413           0 :         aRet = ( (ContentEntry_Impl*)pEntry->GetUserData() )->aURL;
     414           0 :     return aRet;
     415             : }
     416             : 
     417             : // class HelpTabPage_Impl ------------------------------------------------
     418             : 
     419           0 : HelpTabPage_Impl::HelpTabPage_Impl(
     420             :     Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin, const ResId& rResId ) :
     421             : 
     422             :     TabPage( pParent, rResId ),
     423             : 
     424           0 :     m_pIdxWin( _pIdxWin )
     425             : 
     426             : {
     427           0 : }
     428             : 
     429             : // class ContentTabPage_Impl ---------------------------------------------
     430             : 
     431           0 : ContentTabPage_Impl::ContentTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ) :
     432             : 
     433             :     HelpTabPage_Impl( pParent, _pIdxWin, SfxResId( TP_HELP_CONTENT ) ),
     434             : 
     435           0 :     aContentBox( this, SfxResId( LB_CONTENTS ) )
     436             : 
     437             : {
     438           0 :     FreeResource();
     439             : 
     440           0 :     aContentBox.Show();
     441           0 : }
     442             : 
     443             : // -----------------------------------------------------------------------
     444             : 
     445           0 : void ContentTabPage_Impl::Resize()
     446             : {
     447           0 :     Size aSize = GetOutputSizePixel();
     448           0 :     aSize.Width() -= 8;
     449           0 :     aSize.Height() -= 8;
     450           0 :     aContentBox.SetPosSizePixel( Point( 4, 4 ), aSize );
     451           0 : }
     452             : 
     453             : // -----------------------------------------------------------------------
     454             : 
     455           0 : void ContentTabPage_Impl::ActivatePage()
     456             : {
     457           0 :     if ( !m_pIdxWin->WasCursorLeftOrRight() )
     458           0 :         SetFocusOnBox();
     459           0 : }
     460             : 
     461             : // -----------------------------------------------------------------------
     462             : 
     463           0 : Control* ContentTabPage_Impl::GetLastFocusControl()
     464             : {
     465           0 :     return &aContentBox;
     466             : }
     467             : 
     468             : // class IndexBox_Impl ---------------------------------------------------
     469             : 
     470           0 : IndexBox_Impl::IndexBox_Impl( Window* pParent, const ResId& rResId ) :
     471             : 
     472           0 :     ComboBox( pParent, rResId )
     473             : 
     474             : {
     475           0 :     EnableAutocomplete( sal_True );
     476           0 :     EnableUserDraw( sal_True );
     477           0 : }
     478             : 
     479             : // -----------------------------------------------------------------------
     480             : 
     481           0 : void IndexBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
     482             : {
     483           0 :     IndexEntry_Impl* pEntry = (IndexEntry_Impl*)(sal_uIntPtr)GetEntryData( rUDEvt.GetItemId() );
     484           0 :     if ( pEntry && pEntry->m_bSubEntry )
     485             :     {
     486             :         // indent sub entries
     487           0 :         Point aPos( rUDEvt.GetRect().TopLeft() );
     488           0 :         aPos.X() += 8;
     489           0 :         aPos.Y() += ( rUDEvt.GetRect().GetHeight() - rUDEvt.GetDevice()->GetTextHeight() ) / 2;
     490           0 :         String aEntry( GetEntry( rUDEvt.GetItemId() ) );
     491           0 :         sal_uInt16 nPos = aEntry.Search( ';' );
     492           0 :         rUDEvt.GetDevice()->DrawText( aPos, ( nPos != STRING_NOTFOUND ) ? aEntry.Copy( nPos + 1 ) : aEntry );
     493             :     }
     494             :     else
     495           0 :         DrawEntry( rUDEvt, sal_False, sal_True, sal_True );
     496           0 : }
     497             : 
     498             : // -----------------------------------------------------------------------
     499             : 
     500           0 : long IndexBox_Impl::Notify( NotifyEvent& rNEvt )
     501             : {
     502           0 :     sal_Bool bHandled = sal_False;
     503           0 :     if ( rNEvt.GetType() == EVENT_KEYINPUT &&
     504           0 :          KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
     505             :     {
     506           0 :         GetDoubleClickHdl().Call( NULL );
     507           0 :         bHandled = sal_True;
     508             :     }
     509             : 
     510           0 :     return bHandled ? 1 : ComboBox::Notify( rNEvt );
     511             : }
     512             : 
     513             : // -----------------------------------------------------------------------
     514             : 
     515           0 : void IndexBox_Impl::SelectExecutableEntry()
     516             : {
     517           0 :     sal_uInt16 nPos = GetEntryPos( GetText() );
     518           0 :     if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
     519             :     {
     520           0 :         sal_uInt16 nOldPos = nPos;
     521           0 :         String aEntryText;
     522           0 :         IndexEntry_Impl* pEntry = (IndexEntry_Impl*)(sal_uIntPtr)GetEntryData( nPos );
     523           0 :         sal_uInt16 nCount = GetEntryCount();
     524           0 :         while ( nPos < nCount && ( !pEntry || pEntry->m_aURL.Len() == 0 ) )
     525             :         {
     526           0 :             pEntry = (IndexEntry_Impl*)(sal_uIntPtr)GetEntryData( ++nPos );
     527           0 :             aEntryText = GetEntry( nPos );
     528             :         }
     529             : 
     530           0 :         if ( nOldPos != nPos )
     531           0 :             SetText( aEntryText );
     532             :     }
     533           0 : }
     534             : 
     535             : // class IndexTabPage_Impl -----------------------------------------------
     536             : 
     537           0 : IndexTabPage_Impl::IndexTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ) :
     538             : 
     539             :     HelpTabPage_Impl( pParent, _pIdxWin, SfxResId( TP_HELP_INDEX ) ),
     540             : 
     541             :     aExpressionFT   ( this, SfxResId( FT_EXPRESSION ) ),
     542             :     aIndexCB        ( this, SfxResId( CB_INDEX ) ),
     543             :     aOpenBtn        ( this, SfxResId( PB_OPEN_INDEX ) ),
     544             : 
     545           0 :     bIsActivated    ( sal_False )
     546             : 
     547             : {
     548           0 :     FreeResource();
     549             : 
     550           0 :     aOpenBtn.SetClickHdl( LINK( this, IndexTabPage_Impl, OpenHdl ) );
     551           0 :     Link aTimeoutLink = LINK( this, IndexTabPage_Impl, TimeoutHdl );
     552           0 :     aFactoryTimer.SetTimeoutHdl( aTimeoutLink );
     553           0 :     aFactoryTimer.SetTimeout( 300 );
     554           0 :     aKeywordTimer.SetTimeoutHdl( aTimeoutLink );
     555           0 :     aFactoryTimer.SetTimeout( 300 );
     556             : 
     557           0 :     nMinWidth = aOpenBtn.GetSizePixel().Width();
     558           0 : }
     559             : 
     560             : // -----------------------------------------------------------------------
     561             : 
     562           0 : IndexTabPage_Impl::~IndexTabPage_Impl()
     563             : {
     564           0 :     ClearIndex();
     565           0 : }
     566             : 
     567             : // -----------------------------------------------------------------------
     568             : 
     569             : namespace sfx2 {
     570             : 
     571             :     struct equalOUString
     572             :     {
     573           0 :         bool operator()( const OUString& rKey1, const OUString& rKey2 ) const
     574             :         {
     575           0 :             return !!( rKey1 == rKey2 );
     576             :         }
     577             :     };
     578             : 
     579             : 
     580             :     struct hashOUString
     581             :     {
     582           0 :         size_t operator()( const OUString& rName ) const
     583             :         {
     584           0 :             return rName.hashCode();
     585             :         }
     586             :     };
     587             : 
     588             :     typedef ::boost::unordered_map< OUString, int, hashOUString, equalOUString > KeywordInfo;
     589             : }
     590             : 
     591             : #define UNIFY_AND_INSERT_TOKEN( aToken )                                                            \
     592             :     it =                                                                                            \
     593             :     aInfo.insert( sfx2::KeywordInfo::value_type( aToken, 0 ) ).first;                               \
     594             :     if ( ( tmp = it->second++ ) != 0 )                                                              \
     595             :        nPos = aIndexCB.InsertEntry( aToken + OUString( append, tmp ) );                        \
     596             :     else                                                                                            \
     597             :        nPos = aIndexCB.InsertEntry( aToken )
     598             : 
     599             : #define INSERT_DATA( j )                                                                            \
     600             :     if ( aAnchorList[j].getLength() > 0 )                                                           \
     601             :     {                                                                                               \
     602             :         aData.append( aRefList[j] ).append( sal_Unicode('#') ).append( aAnchorList[j] );            \
     603             :         aIndexCB.SetEntryData( nPos, NEW_ENTRY( aData.makeStringAndClear(), insert ) );             \
     604             :     }                                                                                               \
     605             :     else                                                                                            \
     606             :         aIndexCB.SetEntryData( nPos, NEW_ENTRY( aRefList[j], insert ) );
     607             : 
     608             : // -----------------------------------------------------------------------
     609             : 
     610           0 : void IndexTabPage_Impl::InitializeIndex()
     611             : {
     612           0 :     WaitObject aWaitCursor( this );
     613             : 
     614             :     // By now more than 256 equal entries are not allowed
     615             :     sal_Unicode append[256];
     616           0 :     for( int k = 0; k < 256; ++k )
     617           0 :         append[k] = sal_Unicode( ' ' );
     618             : 
     619           0 :     sfx2::KeywordInfo aInfo;
     620           0 :     aIndexCB.SetUpdateMode( sal_False );
     621             : 
     622             :     try
     623             :     {
     624           0 :         OUStringBuffer aURL = HELP_URL;
     625           0 :         aURL.append(sFactory);
     626           0 :         AppendConfigToken(aURL, sal_True);
     627             : 
     628           0 :         Content aCnt( aURL.makeStringAndClear(), Reference< ::com::sun::star::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
     629           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo = aCnt.getProperties();
     630           0 :         if ( xInfo->hasPropertyByName( PROPERTY_ANCHORREF ) )
     631             :         {
     632           0 :             ::com::sun::star::uno::Sequence< OUString > aPropSeq( 4 );
     633           0 :             aPropSeq[0] = PROPERTY_KEYWORDLIST;
     634           0 :             aPropSeq[1] = PROPERTY_KEYWORDREF;
     635           0 :             aPropSeq[2] = PROPERTY_ANCHORREF;
     636           0 :             aPropSeq[3] = PROPERTY_TITLEREF;
     637             : 
     638             :             // abi: use one possibly remote call only
     639             :             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aAnySeq =
     640           0 :                   aCnt.getPropertyValues( aPropSeq );
     641             : 
     642           0 :             ::com::sun::star::uno::Sequence< OUString > aKeywordList;
     643           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > aKeywordRefList;
     644           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > aAnchorRefList;
     645           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > aTitleRefList;
     646             : 
     647           0 :             if ( ( aAnySeq[0] >>= aKeywordList ) && ( aAnySeq[1] >>= aKeywordRefList ) &&
     648           0 :                  ( aAnySeq[2] >>= aAnchorRefList ) && ( aAnySeq[3] >>= aTitleRefList ) )
     649             :             {
     650             :                 sal_Bool insert;
     651             :                 sal_uInt16 nPos;
     652             :                 int ndx,tmp;
     653           0 :                 OUString aIndex, aTempString;
     654           0 :                 OUStringBuffer aData( 128 );            // Capacity of up to 128 characters
     655           0 :                 sfx2::KeywordInfo::iterator it;
     656             : 
     657           0 :                 for ( int i = 0; i < aKeywordList.getLength(); ++i )
     658             :                 {
     659             :                     // abi: Do not copy, but use references
     660           0 :                     const OUString& aKeywordPair = aKeywordList[i];
     661             :                     DBG_ASSERT( !aKeywordPair.isEmpty(), "invalid help index" );
     662           0 :                     const ::com::sun::star::uno::Sequence< OUString >& aRefList = aKeywordRefList[i];
     663           0 :                     const ::com::sun::star::uno::Sequence< OUString >& aAnchorList = aAnchorRefList[i];
     664           0 :                     const ::com::sun::star::uno::Sequence< OUString >& aTitleList = aTitleRefList[i];
     665             : 
     666             :                     DBG_ASSERT( aRefList.getLength() == aAnchorList.getLength(),"reference list and title list of different length" );
     667             : 
     668           0 :                     insert = ( ( ndx = aKeywordPair.indexOf( sal_Unicode( ';' ) ) ) == -1 ? sal_False : sal_True );
     669             : 
     670           0 :                     if ( insert )
     671             :                     {
     672           0 :                         aTempString = aKeywordPair.copy( 0, ndx );
     673           0 :                         if ( aIndex != aTempString )
     674             :                         {
     675           0 :                             aIndex = aTempString;
     676           0 :                             UNIFY_AND_INSERT_TOKEN( aTempString );
     677             :                         }
     678             :                     }
     679             :                     else
     680           0 :                         aIndex = OUString();
     681             : 
     682             :                     // Assume the token is trimed
     683           0 :                     UNIFY_AND_INSERT_TOKEN( aKeywordPair );
     684             : 
     685           0 :                     sal_uInt32 nRefListLen = aRefList.getLength();
     686             : 
     687             :                     DBG_ASSERT( aAnchorList.getLength(), "*IndexTabPage_Impl::InitializeIndex(): AnchorList is empty!" );           \
     688             :                     DBG_ASSERT( nRefListLen, "*IndexTabPage_Impl::InitializeIndex(): RefList is empty!" );          \
     689             : 
     690           0 :                     if ( aAnchorList.getLength() && nRefListLen )
     691             :                     {
     692           0 :                         INSERT_DATA( 0 );
     693             :                     }
     694             : 
     695           0 :                     for ( sal_uInt32 j = 1; j < nRefListLen ; ++j )
     696             :                     {
     697             :                         aData
     698           0 :                             .append( aKeywordPair )
     699           0 :                             .append( sal_Unicode(' ') )
     700           0 :                             .append( sal_Unicode('-') )
     701           0 :                             .append( sal_Unicode(' ') )
     702           0 :                             .append( aTitleList[j] );
     703             : 
     704           0 :                         aTempString = aData.makeStringAndClear();
     705           0 :                         UNIFY_AND_INSERT_TOKEN( aTempString );
     706           0 :                         INSERT_DATA( j );
     707             :                     }
     708           0 :                 }
     709           0 :             }
     710           0 :         }
     711             :     }
     712           0 :     catch( Exception& )
     713             :     {
     714             :         OSL_FAIL( "IndexTabPage_Impl::InitializeIndex(): unexpected exception" );
     715             :     }
     716             : 
     717           0 :     aIndexCB.SetUpdateMode( sal_True );
     718             : 
     719           0 :     if ( sKeyword.Len() > 0 )
     720           0 :         aKeywordLink.Call( this );
     721           0 : }
     722             : 
     723             : #undef INSERT_DATA
     724             : #undef UNIFY_AND_INSERT_TOKEN
     725             : 
     726             : // -----------------------------------------------------------------------
     727             : 
     728           0 : void IndexTabPage_Impl::ClearIndex()
     729             : {
     730           0 :     sal_uInt16 nCount = aIndexCB.GetEntryCount();
     731           0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
     732           0 :         delete (IndexEntry_Impl*)(sal_uIntPtr)aIndexCB.GetEntryData(i);
     733           0 :     aIndexCB.Clear();
     734           0 : }
     735             : 
     736             : // -----------------------------------------------------------------------
     737             : 
     738           0 : IMPL_LINK_NOARG(IndexTabPage_Impl, OpenHdl)
     739             : {
     740           0 :     aIndexCB.GetDoubleClickHdl().Call( &aIndexCB );
     741           0 :     return 0;
     742             : }
     743             : 
     744             : // -----------------------------------------------------------------------
     745             : 
     746           0 : IMPL_LINK( IndexTabPage_Impl, TimeoutHdl, Timer*, pTimer )
     747             : {
     748           0 :     if ( &aFactoryTimer == pTimer )
     749           0 :         InitializeIndex();
     750           0 :     else if ( &aKeywordTimer == pTimer && sKeyword.Len() > 0 )
     751           0 :         aKeywordLink.Call( this );
     752           0 :     return 0;
     753             : }
     754             : 
     755             : // -----------------------------------------------------------------------
     756             : 
     757           0 : void IndexTabPage_Impl::Resize()
     758             : {
     759           0 :     Size aSize = GetSizePixel();
     760           0 :     if ( aSize.Width() < nMinWidth )
     761           0 :         aSize.Width() = nMinWidth;
     762           0 :     Point aPnt = aExpressionFT.GetPosPixel();
     763           0 :     Size aNewSize = aExpressionFT.GetSizePixel();
     764           0 :     aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
     765           0 :     aExpressionFT.SetSizePixel( aNewSize );
     766             : 
     767           0 :     Size a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
     768           0 :     Size aBtnSize = aOpenBtn.GetSizePixel();
     769             : 
     770           0 :     aPnt = aIndexCB.GetPosPixel();
     771           0 :     aNewSize = aIndexCB.GetSizePixel();
     772           0 :     aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
     773           0 :     aNewSize.Height() = aSize.Height() - aPnt.Y();
     774           0 :     aNewSize.Height() -= ( aBtnSize.Height() + ( a6Size.Height() * 3 / 2 ) );
     775           0 :     aIndexCB.SetSizePixel( aNewSize );
     776             : 
     777           0 :     aPnt.X() += ( aNewSize.Width() - aBtnSize.Width() );
     778           0 :     aPnt.Y() += aNewSize.Height() + ( a6Size.Height() / 2 );
     779           0 :     long nMinX = aIndexCB.GetPosPixel().X();
     780           0 :     if ( aPnt.X() < nMinX )
     781           0 :         aPnt.X() = nMinX;
     782           0 :     aOpenBtn.SetPosPixel( aPnt );
     783           0 : }
     784             : 
     785             : // -----------------------------------------------------------------------
     786             : 
     787           0 : void IndexTabPage_Impl::ActivatePage()
     788             : {
     789           0 :     if ( !bIsActivated )
     790             :     {
     791           0 :         bIsActivated = sal_True;
     792           0 :         aFactoryTimer.Start();
     793             :     }
     794             : 
     795           0 :     if ( !m_pIdxWin->WasCursorLeftOrRight() )
     796           0 :         SetFocusOnBox();
     797           0 : }
     798             : 
     799             : // -----------------------------------------------------------------------
     800             : 
     801           0 : Control* IndexTabPage_Impl::GetLastFocusControl()
     802             : {
     803           0 :     return &aOpenBtn;
     804             : }
     805             : 
     806             : // -----------------------------------------------------------------------
     807             : 
     808           0 : void IndexTabPage_Impl::SetDoubleClickHdl( const Link& rLink )
     809             : {
     810           0 :     aIndexCB.SetDoubleClickHdl( rLink );
     811           0 : }
     812             : 
     813             : // -----------------------------------------------------------------------
     814             : 
     815           0 : void IndexTabPage_Impl::SetFactory( const String& rFactory )
     816             : {
     817           0 :     String sNewFactory( rFactory );
     818             :     DBG_ASSERT( sNewFactory.Len() > 0, "empty factory" );
     819           0 :     bool bValid = m_pIdxWin->IsValidFactory( rFactory );
     820             : 
     821           0 :     if ( sFactory.Len() == 0 && !bValid )
     822             :     {
     823           0 :         sNewFactory = SfxHelp::GetDefaultHelpModule();
     824           0 :         bValid = true;
     825             :     }
     826             : 
     827           0 :     if ( sNewFactory != sFactory && bValid )
     828             :     {
     829           0 :         sFactory = sNewFactory;
     830           0 :         ClearIndex();
     831           0 :         if ( bIsActivated )
     832           0 :             aFactoryTimer.Start();
     833           0 :     }
     834           0 : }
     835             : 
     836             : // -----------------------------------------------------------------------
     837             : 
     838           0 : String IndexTabPage_Impl::GetSelectEntry() const
     839             : {
     840           0 :     String aRet;
     841           0 :     IndexEntry_Impl* pEntry = (IndexEntry_Impl*)(sal_uIntPtr)aIndexCB.GetEntryData( aIndexCB.GetEntryPos( aIndexCB.GetText() ) );
     842           0 :     if ( pEntry )
     843           0 :         aRet = pEntry->m_aURL;
     844           0 :     return aRet;
     845             : }
     846             : 
     847             : // -----------------------------------------------------------------------
     848             : 
     849           0 : void IndexTabPage_Impl::SetKeyword( const String& rKeyword )
     850             : {
     851           0 :     sKeyword = rKeyword;
     852             : 
     853           0 :     if ( aIndexCB.GetEntryCount() > 0 )
     854           0 :         aKeywordTimer.Start();
     855           0 :     else if ( !bIsActivated )
     856           0 :         aFactoryTimer.Start();
     857           0 : }
     858             : 
     859             : // -----------------------------------------------------------------------
     860             : 
     861           0 : sal_Bool IndexTabPage_Impl::HasKeyword() const
     862             : {
     863           0 :     sal_Bool bRet = sal_False;
     864           0 :     if ( sKeyword.Len() > 0 )
     865             :     {
     866           0 :         sal_uInt16 nPos = aIndexCB.GetEntryPos( sKeyword );
     867           0 :         bRet = ( nPos != LISTBOX_ENTRY_NOTFOUND );
     868             :     }
     869             : 
     870           0 :     return bRet;
     871             : }
     872             : 
     873             : // -----------------------------------------------------------------------
     874             : 
     875           0 : sal_Bool IndexTabPage_Impl::HasKeywordIgnoreCase()
     876             : {
     877           0 :     sal_Bool bRet = sal_False;
     878           0 :     if ( sKeyword.Len() > 0 )
     879             :     {
     880           0 :         sal_uInt16 nEntries = aIndexCB.GetEntryCount();
     881           0 :         String sIndexItem;
     882           0 :         const vcl::I18nHelper& rI18nHelper = GetSettings().GetLocaleI18nHelper();
     883           0 :         for ( sal_uInt16 n = 0; n < nEntries; n++)
     884             :         {
     885           0 :             sIndexItem = aIndexCB.GetEntry( n );
     886           0 :             if (rI18nHelper.MatchString( sIndexItem, sKeyword ))
     887             :             {
     888           0 :                 sKeyword = sIndexItem;
     889           0 :                 bRet = sal_True;
     890             :             }
     891           0 :         }
     892             :     }
     893             : 
     894           0 :     return bRet;
     895             : }
     896             : 
     897             : // -----------------------------------------------------------------------
     898             : 
     899           0 : void IndexTabPage_Impl::OpenKeyword()
     900             : {
     901           0 :     if ( sKeyword.Len() > 0 )
     902             :     {
     903           0 :         aIndexCB.SetText( sKeyword );
     904           0 :         aIndexCB.GetDoubleClickHdl().Call( NULL );
     905           0 :         sKeyword.Erase();
     906             :     }
     907           0 : }
     908             : 
     909             : // class SearchBox_Impl --------------------------------------------------
     910             : 
     911           0 : long SearchBox_Impl::PreNotify( NotifyEvent& rNEvt )
     912             : {
     913           0 :     sal_Bool bHandled = sal_False;
     914           0 :     if ( !IsInDropDown() &&
     915           0 :          rNEvt.GetWindow() == GetSubEdit() &&
     916           0 :          rNEvt.GetType() == EVENT_KEYINPUT &&
     917           0 :          KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
     918             :     {
     919           0 :         aSearchLink.Call( NULL );
     920           0 :         bHandled = sal_True;
     921             :     }
     922           0 :     return bHandled ? 1 : ComboBox::PreNotify( rNEvt );
     923             : }
     924             : 
     925             : // -----------------------------------------------------------------------
     926             : 
     927           0 : void SearchBox_Impl::Select()
     928             : {
     929           0 :     if ( !IsTravelSelect() )
     930           0 :         aSearchLink.Call( NULL );
     931           0 : }
     932             : 
     933             : // class SearchResultsBox_Impl -------------------------------------------
     934             : 
     935           0 : long SearchResultsBox_Impl::Notify( NotifyEvent& rNEvt )
     936             : {
     937           0 :     sal_Bool bHandled = sal_False;
     938           0 :     if ( rNEvt.GetType() == EVENT_KEYINPUT &&
     939           0 :          KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
     940             :     {
     941           0 :         GetDoubleClickHdl().Call( NULL );
     942           0 :         bHandled = sal_True;
     943             :     }
     944             : 
     945           0 :     return bHandled ? 1 : ListBox::Notify( rNEvt );
     946             : }
     947             : 
     948             : // class SearchTabPage_Impl ----------------------------------------------
     949             : 
     950           0 : SearchTabPage_Impl::SearchTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ) :
     951             : 
     952             :     HelpTabPage_Impl( pParent, _pIdxWin, SfxResId( TP_HELP_SEARCH ) ),
     953             : 
     954             :     aSearchFT       ( this, SfxResId( FT_SEARCH ) ),
     955             :     aSearchED       ( this, SfxResId( ED_SEARCH ) ),
     956             :     aSearchBtn      ( this, SfxResId( PB_SEARCH ) ),
     957             :     aFullWordsCB    ( this, SfxResId( CB_FULLWORDS ) ),
     958             :     aScopeCB        ( this, SfxResId( CB_SCOPE ) ),
     959             :     aResultsLB      ( this, SfxResId( LB_RESULT ) ),
     960             :     aOpenBtn        ( this, SfxResId( PB_OPEN_SEARCH ) ),
     961           0 :     xBreakIterator  ( vcl::unohelper::CreateBreakIterator() )
     962             : 
     963             : {
     964           0 :     FreeResource();
     965             : 
     966           0 :     Link aLink = LINK( this, SearchTabPage_Impl, SearchHdl );
     967           0 :     aSearchED.SetSearchLink( aLink );
     968           0 :     aSearchBtn.SetClickHdl( aLink );
     969           0 :     aSearchED.SetModifyHdl( LINK( this, SearchTabPage_Impl, ModifyHdl ) );
     970           0 :     aOpenBtn.SetClickHdl( LINK( this, SearchTabPage_Impl, OpenHdl ) );
     971             : 
     972           0 :     aMinSize = GetSizePixel();
     973             : 
     974           0 :     SvtViewOptions aViewOpt( E_TABPAGE, CONFIGNAME_SEARCHPAGE );
     975           0 :     if ( aViewOpt.Exists() )
     976             :     {
     977           0 :         String aUserData;
     978           0 :         Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
     979           0 :         OUString aTemp;
     980           0 :         if ( aUserItem >>= aTemp )
     981             :         {
     982           0 :             aUserData = String( aTemp );
     983           0 :             sal_Bool bChecked = ( 1 == aUserData.GetToken(0).ToInt32() ) ? sal_True : sal_False;
     984           0 :             aFullWordsCB.Check( bChecked );
     985           0 :             bChecked = ( 1 == aUserData.GetToken(1).ToInt32() ) ? sal_True : sal_False;
     986           0 :             aScopeCB.Check( bChecked );
     987             : 
     988           0 :             for ( sal_uInt16 i = 2; i < comphelper::string::getTokenCount(aUserData, ';'); ++i )
     989             :             {
     990           0 :                 String aToken = aUserData.GetToken(i, ';');
     991             :                 aSearchED.InsertEntry( INetURLObject::decode(
     992           0 :                     aToken, '%', INetURLObject::DECODE_WITH_CHARSET ) );
     993           0 :             }
     994           0 :         }
     995             :     }
     996             : 
     997           0 :     ModifyHdl( &aSearchED );
     998           0 : }
     999             : 
    1000             : // -----------------------------------------------------------------------
    1001             : 
    1002           0 : SearchTabPage_Impl::~SearchTabPage_Impl()
    1003             : {
    1004           0 :     SvtViewOptions aViewOpt( E_TABPAGE, CONFIGNAME_SEARCHPAGE );
    1005           0 :     sal_Int32 nChecked = aFullWordsCB.IsChecked() ? 1 : 0;
    1006           0 :     String aUserData = OUString::number( nChecked );
    1007           0 :     aUserData += ';';
    1008           0 :     nChecked = aScopeCB.IsChecked() ? 1 : 0;
    1009           0 :     aUserData += OUString::number( nChecked );
    1010           0 :     aUserData += ';';
    1011           0 :     sal_uInt16 nCount = std::min( aSearchED.GetEntryCount(), (sal_uInt16)10 );  // save only 10 entries
    1012             : 
    1013           0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
    1014             :     {
    1015           0 :         OUString aText = aSearchED.GetEntry(i);
    1016           0 :         aUserData += String(INetURLObject::encode(
    1017             :             aText, INetURLObject::PART_UNO_PARAM_VALUE, '%',
    1018           0 :             INetURLObject::ENCODE_ALL ));
    1019           0 :         aUserData += ';';
    1020           0 :     }
    1021             : 
    1022           0 :     aUserData = comphelper::string::stripEnd(aUserData, ';');
    1023           0 :     Any aUserItem = makeAny( OUString( aUserData ) );
    1024           0 :     aViewOpt.SetUserItem( USERITEM_NAME, aUserItem );
    1025           0 : }
    1026             : 
    1027             : // -----------------------------------------------------------------------
    1028             : 
    1029           0 : void SearchTabPage_Impl::ClearSearchResults()
    1030             : {
    1031           0 :     sal_uInt16 nCount = aResultsLB.GetEntryCount();
    1032           0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
    1033           0 :         delete (String*)(sal_uIntPtr)aResultsLB.GetEntryData(i);
    1034           0 :     aResultsLB.Clear();
    1035           0 :     aResultsLB.Update();
    1036           0 : }
    1037             : 
    1038             : // -----------------------------------------------------------------------
    1039             : 
    1040           0 : void SearchTabPage_Impl::RememberSearchText( const String& rSearchText )
    1041             : {
    1042           0 :     for ( sal_uInt16 i = 0; i < aSearchED.GetEntryCount(); ++i )
    1043             :     {
    1044           0 :         if ( rSearchText == aSearchED.GetEntry(i) )
    1045             :         {
    1046           0 :             aSearchED.RemoveEntry(i);
    1047           0 :             break;
    1048             :         }
    1049             :     }
    1050             : 
    1051           0 :     aSearchED.InsertEntry( rSearchText, 0 );
    1052           0 : }
    1053             : 
    1054             : // -----------------------------------------------------------------------
    1055             : 
    1056           0 : IMPL_LINK_NOARG(SearchTabPage_Impl, SearchHdl)
    1057             : {
    1058           0 :     String aSearchText = comphelper::string::strip(aSearchED.GetText(), ' ');
    1059           0 :     if ( aSearchText.Len() > 0 )
    1060             :     {
    1061           0 :         EnterWait();
    1062           0 :         ClearSearchResults();
    1063           0 :         RememberSearchText( aSearchText );
    1064           0 :         OUStringBuffer aSearchURL(HELP_URL);
    1065           0 :         aSearchURL.append(aFactory);
    1066           0 :         aSearchURL.append(HELP_SEARCH_TAG);
    1067           0 :         if ( !aFullWordsCB.IsChecked() )
    1068           0 :             aSearchText = sfx2::PrepareSearchString( aSearchText, xBreakIterator, true );
    1069           0 :         aSearchURL.append(aSearchText);
    1070           0 :         AppendConfigToken(aSearchURL, sal_False);
    1071           0 :         if ( aScopeCB.IsChecked() )
    1072           0 :             aSearchURL.append("&Scope=Heading");
    1073           0 :         std::vector< OUString > aFactories = SfxContentHelper::GetResultSet(aSearchURL.makeStringAndClear());
    1074           0 :         for (size_t i = 0, n = aFactories.size(); i < n; ++i )
    1075             :         {
    1076           0 :             const OUString& rRow = aFactories[i];
    1077           0 :             sal_Int32 nIdx = 0;
    1078           0 :             OUString aTitle = rRow.getToken( 0, '\t', nIdx );
    1079           0 :             nIdx = 0;
    1080           0 :             String* pURL = new String( rRow.getToken( 2, '\t', nIdx ) );
    1081           0 :             sal_uInt16 nPos = aResultsLB.InsertEntry( aTitle );
    1082           0 :             aResultsLB.SetEntryData( nPos, (void*)(sal_uIntPtr)pURL );
    1083           0 :         }
    1084           0 :         LeaveWait();
    1085             : 
    1086           0 :         if ( aFactories.empty() )
    1087             :         {
    1088           0 :             InfoBox aBox( this, SfxResId( RID_INFO_NOSEARCHRESULTS ) );
    1089           0 :             aBox.SetText( SfxResId( STR_HELP_WINDOW_TITLE ).toString() );
    1090           0 :             aBox.Execute();
    1091           0 :         }
    1092             :     }
    1093           0 :     return 0;
    1094             : }
    1095             : 
    1096             : // -----------------------------------------------------------------------
    1097             : 
    1098           0 : IMPL_LINK_NOARG(SearchTabPage_Impl, OpenHdl)
    1099             : {
    1100           0 :     aResultsLB.GetDoubleClickHdl().Call( &aResultsLB );
    1101           0 :     return 0;
    1102             : }
    1103             : 
    1104             : // -----------------------------------------------------------------------
    1105             : 
    1106           0 : IMPL_LINK_NOARG(SearchTabPage_Impl, ModifyHdl)
    1107             : {
    1108           0 :     String aSearchText = comphelper::string::strip(aSearchED.GetText(), ' ');
    1109           0 :     aSearchBtn.Enable( aSearchText.Len() > 0 );
    1110           0 :     return 0;
    1111             : }
    1112             : 
    1113             : // -----------------------------------------------------------------------
    1114             : 
    1115           0 : void SearchTabPage_Impl::Resize()
    1116             : {
    1117           0 :     Size a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
    1118           0 :     Size aSize = GetSizePixel();
    1119           0 :     if ( aSize.Width() < aMinSize.Width() )
    1120           0 :         aSize.Width() = aMinSize.Width();
    1121           0 :     Point aPnt = aSearchFT.GetPosPixel();
    1122           0 :     Size aNewSize = aSearchFT.GetSizePixel();
    1123           0 :     aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
    1124           0 :     aSearchFT.SetSizePixel( aNewSize );
    1125           0 :     aNewSize.Height() = aResultsLB.GetSizePixel().Height();
    1126           0 :     aResultsLB.SetSizePixel( aNewSize );
    1127           0 :     aNewSize.Height() = aFullWordsCB.GetSizePixel().Height();
    1128           0 :     aFullWordsCB.SetSizePixel( aNewSize );
    1129           0 :     aScopeCB.SetSizePixel( aNewSize );
    1130           0 :     aNewSize = aSearchED.GetSizePixel();
    1131           0 :     aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 ) -
    1132           0 :                        ( aSearchBtn.GetSizePixel().Width() + ( aPnt.X() / 2 ) );
    1133           0 :     aSearchED.SetSizePixel( aNewSize );
    1134           0 :     Point aNewPnt = aSearchBtn.GetPosPixel();
    1135           0 :     aNewPnt.X() = aPnt.X() + aNewSize.Width() + ( aPnt.X() / 2 );
    1136           0 :     aSearchBtn.SetPosPixel( aNewPnt );
    1137             : 
    1138           0 :     if ( aSize.Height() > aMinSize.Height() )
    1139             :     {
    1140           0 :         long n3Height = a6Size.Height() / 2;
    1141           0 :         Size aBtnSize = aOpenBtn.GetSizePixel();
    1142           0 :         long nExtraHeight = aBtnSize.Height() + n3Height;
    1143             : 
    1144           0 :         aPnt = aResultsLB.GetPosPixel();
    1145           0 :         aNewSize = aResultsLB.GetSizePixel();
    1146           0 :         aNewSize.Height() = aSize.Height() - aPnt.Y();
    1147           0 :         aNewSize.Height() -= ( nExtraHeight + ( a6Size.Height() * 3 / 2 ) );
    1148           0 :         aResultsLB.SetSizePixel( aNewSize );
    1149             : 
    1150           0 :         aPnt.X() += ( aNewSize.Width() - aBtnSize.Width() );
    1151           0 :         aPnt.Y() += aNewSize.Height() + a6Size.Height();
    1152           0 :         aOpenBtn.SetPosPixel( aPnt );
    1153             :     }
    1154           0 : }
    1155             : 
    1156             : // -----------------------------------------------------------------------
    1157             : 
    1158           0 : void SearchTabPage_Impl::ActivatePage()
    1159             : {
    1160           0 :     if ( !m_pIdxWin->WasCursorLeftOrRight() )
    1161           0 :         aSearchED.GrabFocus();
    1162           0 : }
    1163             : 
    1164             : // -----------------------------------------------------------------------
    1165             : 
    1166           0 : Control* SearchTabPage_Impl::GetLastFocusControl()
    1167             : {
    1168           0 :     return &aOpenBtn;
    1169             : }
    1170             : 
    1171             : // -----------------------------------------------------------------------
    1172             : 
    1173           0 : void SearchTabPage_Impl::SetDoubleClickHdl( const Link& rLink )
    1174             : {
    1175           0 :     aResultsLB.SetDoubleClickHdl( rLink );
    1176           0 : }
    1177             : 
    1178             : // -----------------------------------------------------------------------
    1179             : 
    1180           0 : String SearchTabPage_Impl::GetSelectEntry() const
    1181             : {
    1182           0 :     String aRet;
    1183           0 :     String* pData = (String*)(sal_uIntPtr)aResultsLB.GetEntryData( aResultsLB.GetSelectEntryPos() );
    1184           0 :     if ( pData )
    1185           0 :         aRet = String( *pData );
    1186           0 :     return aRet;
    1187             : }
    1188             : 
    1189             : // -----------------------------------------------------------------------
    1190             : 
    1191           0 : void SearchTabPage_Impl::ClearPage()
    1192             : {
    1193           0 :     ClearSearchResults();
    1194           0 :     aSearchED.SetText( OUString() );
    1195           0 : }
    1196             : 
    1197             : // -----------------------------------------------------------------------
    1198             : 
    1199           0 : sal_Bool SearchTabPage_Impl::OpenKeyword( const String& rKeyword )
    1200             : {
    1201           0 :     sal_Bool bRet = sal_False;
    1202           0 :     aSearchED.SetText( rKeyword );
    1203           0 :     SearchHdl( NULL );
    1204           0 :     if ( aResultsLB.GetEntryCount() > 0 )
    1205             :     {
    1206             :         // found keyword -> open it
    1207           0 :         aResultsLB.SelectEntryPos(0);
    1208           0 :         OpenHdl( NULL );
    1209           0 :         bRet = sal_True;
    1210             :     }
    1211             : 
    1212           0 :     return bRet;
    1213             : }
    1214             : 
    1215             : // class BookmarksTabPage_Impl -------------------------------------------
    1216             : 
    1217           0 : void GetBookmarkEntry_Impl
    1218             : (
    1219             :     Sequence< PropertyValue >& aBookmarkEntry,
    1220             :     OUString& rTitle,
    1221             :     OUString& rURL
    1222             : )
    1223             : {
    1224           0 :     for ( int i = 0; i < aBookmarkEntry.getLength(); i++ )
    1225             :     {
    1226           0 :         PropertyValue aValue = aBookmarkEntry[i];
    1227           0 :         if ( aValue.Name == HISTORY_PROPERTYNAME_URL )
    1228           0 :             aValue.Value >>= rURL;
    1229           0 :         else if ( aValue.Name == HISTORY_PROPERTYNAME_TITLE )
    1230           0 :             aValue.Value >>= rTitle;
    1231           0 :     }
    1232           0 : }
    1233             : 
    1234             : // -----------------------------------------------------------------------
    1235             : 
    1236           0 : BookmarksBox_Impl::BookmarksBox_Impl( Window* pParent, const ResId& rResId ) :
    1237             : 
    1238           0 :     ListBox( pParent, rResId )
    1239             : 
    1240             : {
    1241           0 : }
    1242             : 
    1243             : // -----------------------------------------------------------------------
    1244             : 
    1245           0 : BookmarksBox_Impl::~BookmarksBox_Impl()
    1246             : {
    1247             :     // save bookmarks to configuration
    1248           0 :     SvtHistoryOptions aHistOpt;
    1249           0 :     aHistOpt.Clear( eHELPBOOKMARKS );
    1250           0 :     OUString sEmpty;
    1251           0 :     sal_uInt16 nCount = GetEntryCount();
    1252           0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
    1253             :     {
    1254           0 :         String aTitle = GetEntry(i);
    1255           0 :         String* pURL = (String*)(sal_uIntPtr)GetEntryData(i);
    1256           0 :         aHistOpt.AppendItem( eHELPBOOKMARKS, OUString( *pURL ), sEmpty, OUString( aTitle ), sEmpty );
    1257           0 :         delete pURL;
    1258           0 :     }
    1259           0 : }
    1260             : 
    1261             : // -----------------------------------------------------------------------
    1262             : 
    1263           0 : void BookmarksBox_Impl::DoAction( sal_uInt16 nAction )
    1264             : {
    1265           0 :     switch ( nAction )
    1266             :     {
    1267             :         case MID_OPEN :
    1268           0 :             GetDoubleClickHdl().Call( NULL );
    1269           0 :             break;
    1270             : 
    1271             :         case MID_RENAME :
    1272             :            {
    1273           0 :             sal_uInt16 nPos = GetSelectEntryPos();
    1274           0 :             if ( nPos != LISTBOX_ENTRY_NOTFOUND )
    1275             :             {
    1276           0 :                 SfxAddHelpBookmarkDialog_Impl aDlg( this, sal_True );
    1277           0 :                 aDlg.SetTitle( GetEntry( nPos ) );
    1278           0 :                 if ( aDlg.Execute() == RET_OK )
    1279             :                 {
    1280           0 :                     String* pURL = (String*)(sal_uIntPtr)GetEntryData( nPos );
    1281           0 :                     RemoveEntry( nPos );
    1282           0 :                     OUString aImageURL = IMAGE_URL;
    1283           0 :                     aImageURL += INetURLObject( *pURL ).GetHost();
    1284           0 :                     nPos = InsertEntry( aDlg.GetTitle(), SvFileInformationManager::GetImage( aImageURL, false ) );
    1285           0 :                     SetEntryData( nPos, (void*)(sal_uIntPtr)( new String( *pURL ) ) );
    1286           0 :                     SelectEntryPos( nPos );
    1287           0 :                     delete pURL;
    1288           0 :                 }
    1289             :             }
    1290           0 :             break;
    1291             :         }
    1292             : 
    1293             :         case MID_DELETE :
    1294             :         {
    1295           0 :             sal_uInt16 nPos = GetSelectEntryPos();
    1296           0 :             if ( nPos != LISTBOX_ENTRY_NOTFOUND )
    1297             :             {
    1298           0 :                 RemoveEntry( nPos );
    1299           0 :                 sal_uInt16 nCount = GetEntryCount();
    1300           0 :                 if ( nCount )
    1301             :                 {
    1302           0 :                     if ( nPos >= nCount )
    1303           0 :                         nPos = nCount - 1;
    1304           0 :                     SelectEntryPos( nPos );
    1305             :                 }
    1306             :             }
    1307           0 :             break;
    1308             :         }
    1309             :     }
    1310           0 : }
    1311             : 
    1312             : // -----------------------------------------------------------------------
    1313             : 
    1314           0 : long BookmarksBox_Impl::Notify( NotifyEvent& rNEvt )
    1315             : {
    1316           0 :     long nRet = 0;
    1317           0 :     sal_uInt16 nType = rNEvt.GetType();
    1318           0 :     if ( EVENT_KEYINPUT == nType )
    1319             :     {
    1320           0 :         sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
    1321           0 :         if ( KEY_DELETE == nCode && GetEntryCount() > 0 )
    1322             :         {
    1323           0 :             DoAction( MID_DELETE );
    1324           0 :             nRet = 1;
    1325             :         }
    1326           0 :         else if ( KEY_RETURN == nCode )
    1327             :         {
    1328           0 :             GetDoubleClickHdl().Call( NULL );
    1329           0 :             nRet = 1;
    1330             :         }
    1331             :     }
    1332           0 :     else if ( EVENT_COMMAND == nType )
    1333             :     {
    1334           0 :         const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
    1335           0 :         if ( pCEvt->GetCommand() == COMMAND_CONTEXTMENU )
    1336             :         {
    1337           0 :             PopupMenu aMenu( SfxResId( MENU_HELP_BOOKMARKS ) );
    1338           0 :             sal_uInt16 nId = aMenu.Execute( this, pCEvt->GetMousePosPixel() );
    1339           0 :             if ( nId != MENU_ITEM_NOTFOUND )
    1340           0 :                 DoAction( nId );
    1341           0 :             nRet = 1;
    1342             :         }
    1343             :     }
    1344             : 
    1345           0 :     return nRet ? nRet : ListBox::Notify( rNEvt );
    1346             : }
    1347             : 
    1348             : // class BookmarksTabPage_Impl -------------------------------------------
    1349             : 
    1350           0 : BookmarksTabPage_Impl::BookmarksTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ) :
    1351             : 
    1352             :     HelpTabPage_Impl( pParent, _pIdxWin, SfxResId( TP_HELP_BOOKMARKS ) ),
    1353             : 
    1354             :     aBookmarksFT    ( this, SfxResId( FT_BOOKMARKS ) ),
    1355             :     aBookmarksBox   ( this, SfxResId( LB_BOOKMARKS ) ),
    1356           0 :     aBookmarksPB    ( this, SfxResId( PB_BOOKMARKS ) )
    1357             : 
    1358             : {
    1359           0 :     FreeResource();
    1360             : 
    1361           0 :     nMinWidth = aBookmarksPB.GetSizePixel().Width();
    1362             : 
    1363           0 :     aBookmarksPB.SetClickHdl( LINK( this, BookmarksTabPage_Impl, OpenHdl ) );
    1364             : 
    1365             :     // load bookmarks from configuration
    1366           0 :     Sequence< Sequence< PropertyValue > > aBookmarkSeq;
    1367           0 :     aBookmarkSeq = SvtHistoryOptions().GetList( eHELPBOOKMARKS );
    1368             : 
    1369           0 :     OUString aTitle;
    1370           0 :     OUString aURL;
    1371             : 
    1372           0 :     sal_uInt32 i, nCount = aBookmarkSeq.getLength();
    1373           0 :     for ( i = 0; i < nCount; ++i )
    1374             :     {
    1375           0 :         GetBookmarkEntry_Impl( aBookmarkSeq[i], aTitle, aURL );
    1376           0 :         AddBookmarks( aTitle, aURL );
    1377           0 :     }
    1378           0 : }
    1379             : 
    1380             : // -----------------------------------------------------------------------
    1381             : 
    1382           0 : IMPL_LINK_NOARG(BookmarksTabPage_Impl, OpenHdl)
    1383             : {
    1384           0 :     aBookmarksBox.GetDoubleClickHdl().Call( &aBookmarksBox );
    1385           0 :     return 0;
    1386             : }
    1387             : 
    1388             : // -----------------------------------------------------------------------
    1389             : 
    1390           0 : void BookmarksTabPage_Impl::Resize()
    1391             : {
    1392           0 :     Size aSize = GetSizePixel();
    1393           0 :     if ( aSize.Width() < nMinWidth )
    1394           0 :         aSize.Width() = nMinWidth;
    1395           0 :     Point aPnt = aBookmarksFT.GetPosPixel();
    1396           0 :     Size aNewSize = aBookmarksFT.GetSizePixel();
    1397           0 :     aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
    1398           0 :     aBookmarksFT.SetSizePixel( aNewSize );
    1399             : 
    1400           0 :     Size a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
    1401           0 :     Size aBtnSize = aBookmarksPB.GetSizePixel();
    1402             : 
    1403           0 :     aPnt = aBookmarksBox.GetPosPixel();
    1404           0 :     aNewSize = aBookmarksBox.GetSizePixel();
    1405           0 :     aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
    1406           0 :     aNewSize.Height() = aSize.Height() - aPnt.Y();
    1407           0 :     aNewSize.Height() -= ( aBtnSize.Height() + ( a6Size.Height() * 3 / 2 ) );
    1408           0 :     aBookmarksBox.SetSizePixel( aNewSize );
    1409             : 
    1410           0 :     aPnt.X() += ( aNewSize.Width() - aBtnSize.Width() );
    1411           0 :     aPnt.Y() += aNewSize.Height() + ( a6Size.Height() / 2 );
    1412           0 :     long nMinX = aBookmarksBox.GetPosPixel().X();
    1413           0 :     if ( aPnt.X() < nMinX )
    1414           0 :         aPnt.X() = nMinX;
    1415           0 :     aBookmarksPB.SetPosPixel( aPnt );
    1416           0 : }
    1417             : 
    1418             : // -----------------------------------------------------------------------
    1419             : 
    1420           0 : void BookmarksTabPage_Impl::ActivatePage()
    1421             : {
    1422           0 :     if ( !m_pIdxWin->WasCursorLeftOrRight() )
    1423           0 :         SetFocusOnBox();
    1424           0 : }
    1425             : 
    1426             : // -----------------------------------------------------------------------
    1427             : 
    1428           0 : Control* BookmarksTabPage_Impl::GetLastFocusControl()
    1429             : {
    1430           0 :     return &aBookmarksPB;
    1431             : }
    1432             : 
    1433             : // -----------------------------------------------------------------------
    1434             : 
    1435           0 : void BookmarksTabPage_Impl::SetDoubleClickHdl( const Link& rLink )
    1436             : {
    1437           0 :     aBookmarksBox.SetDoubleClickHdl( rLink );
    1438           0 : }
    1439             : 
    1440             : // -----------------------------------------------------------------------
    1441             : 
    1442           0 : String BookmarksTabPage_Impl::GetSelectEntry() const
    1443             : {
    1444           0 :     String aRet;
    1445           0 :     String* pData = (String*)(sal_uIntPtr)aBookmarksBox.GetEntryData( aBookmarksBox.GetSelectEntryPos() );
    1446           0 :     if ( pData )
    1447           0 :         aRet = String( *pData );
    1448           0 :     return aRet;
    1449             : }
    1450             : 
    1451             : // -----------------------------------------------------------------------
    1452             : 
    1453           0 : void BookmarksTabPage_Impl::AddBookmarks( const String& rTitle, const String& rURL )
    1454             : {
    1455           0 :     OUString aImageURL = IMAGE_URL;
    1456           0 :     aImageURL += INetURLObject( rURL ).GetHost();
    1457           0 :     sal_uInt16 nPos = aBookmarksBox.InsertEntry( rTitle, SvFileInformationManager::GetImage( aImageURL, false ) );
    1458           0 :     aBookmarksBox.SetEntryData( nPos, (void*)(sal_uIntPtr)( new String( rURL ) ) );
    1459           0 : }
    1460             : 
    1461           0 : OUString SfxHelpWindow_Impl::buildHelpURL(const OUString& sFactory        ,
    1462             :                                                  const OUString& sContent        ,
    1463             :                                                  const OUString& sAnchor         ,
    1464             :                                                        sal_Bool         bUseQuestionMark)
    1465             : {
    1466           0 :     OUStringBuffer sHelpURL(256);
    1467           0 :     sHelpURL.append(HELP_URL);
    1468           0 :     sHelpURL.append(sFactory);
    1469           0 :     sHelpURL.append(sContent);
    1470           0 :     AppendConfigToken(sHelpURL, bUseQuestionMark);
    1471           0 :     if (!sAnchor.isEmpty())
    1472           0 :         sHelpURL.append(sAnchor);
    1473           0 :     return sHelpURL.makeStringAndClear();
    1474             : }
    1475             : 
    1476           0 : void SfxHelpWindow_Impl::loadHelpContent(const OUString& sHelpURL, sal_Bool bAddToHistory)
    1477             : {
    1478           0 :     Reference< XComponentLoader > xLoader(getTextFrame(), UNO_QUERY);
    1479           0 :     if (!xLoader.is())
    1480           0 :         return;
    1481             : 
    1482             :     // If a print job runs do not open a new page
    1483           0 :     Reference< XFrame2 >     xTextFrame      = pTextWin->getFrame();
    1484           0 :     Reference< XController > xTextController ;
    1485           0 :     if (xTextFrame.is())
    1486           0 :         xTextController = xTextFrame->getController ();
    1487           0 :     if ( xTextController.is() && !xTextController->suspend( sal_True ) )
    1488             :     {
    1489           0 :         xTextController->suspend( sal_False );
    1490           0 :         return;
    1491             :     }
    1492             : 
    1493             :     // save url to history
    1494           0 :     if (bAddToHistory)
    1495           0 :         pHelpInterceptor->addURL(sHelpURL);
    1496             : 
    1497           0 :     if ( !IsWait() )
    1498           0 :         EnterWait();
    1499           0 :     sal_Bool bSuccess = sal_False;
    1500             : // TODO implement locale fallback ... see below    while(true)
    1501             :     {
    1502             :         try
    1503             :         {
    1504           0 :             Reference< XComponent > xContent = xLoader->loadComponentFromURL(sHelpURL, "_self", 0, Sequence< PropertyValue >());
    1505           0 :             if (xContent.is())
    1506             :             {
    1507           0 :                 bSuccess = sal_True;
    1508           0 :             }
    1509             :         }
    1510           0 :         catch(const RuntimeException&)
    1511           0 :             { throw; }
    1512           0 :         catch(const Exception&)
    1513             :             { /*break;*/ }
    1514             : 
    1515             :         /* TODO try next locale ...
    1516             :                 no further locale available? => break loop and show error page
    1517             :         */
    1518             :     }
    1519           0 :     openDone(sHelpURL, bSuccess);
    1520           0 :     if ( IsWait() )
    1521           0 :         LeaveWait();
    1522             : }
    1523             : 
    1524           0 : SfxHelpIndexWindow_Impl::SfxHelpIndexWindow_Impl( SfxHelpWindow_Impl* _pParent ) :
    1525             : 
    1526             :     Window( _pParent, SfxResId( WIN_HELPINDEX ) ),
    1527             : 
    1528             :     aActiveLB           ( this, SfxResId( LB_ACTIVE ) ),
    1529             :     aActiveLine         ( this, SfxResId( FL_ACTIVE ) ),
    1530             :     aTabCtrl            ( this, SfxResId( TC_INDEX ) ),
    1531             : 
    1532             :     aIndexKeywordLink   ( LINK( this, SfxHelpIndexWindow_Impl, KeywordHdl ) ),
    1533             :     pParentWin          ( _pParent ),
    1534             : 
    1535             :     pCPage              ( NULL ),
    1536             :     pIPage              ( NULL ),
    1537             :     pSPage              ( NULL ),
    1538             :     pBPage              ( NULL ),
    1539             : 
    1540             :     bWasCursorLeftOrRight( false ),
    1541           0 :     bIsInitDone          ( false )
    1542             : 
    1543             : {
    1544           0 :     FreeResource();
    1545             : 
    1546           0 :     sfx2::AddToTaskPaneList( this );
    1547             : 
    1548           0 :     aTabCtrl.SetActivatePageHdl( LINK( this, SfxHelpIndexWindow_Impl, ActivatePageHdl ) );
    1549           0 :     aTabCtrl.Show();
    1550             : 
    1551           0 :     sal_Int32 nPageId = HELP_INDEX_PAGE_INDEX;
    1552           0 :     SvtViewOptions aViewOpt( E_TABDIALOG, CONFIGNAME_INDEXWIN );
    1553           0 :     if ( aViewOpt.Exists() )
    1554           0 :         nPageId = aViewOpt.GetPageID();
    1555           0 :     aTabCtrl.SetCurPageId( (sal_uInt16)nPageId );
    1556           0 :     ActivatePageHdl( &aTabCtrl );
    1557           0 :     aActiveLB.SetSelectHdl( LINK( this, SfxHelpIndexWindow_Impl, SelectHdl ) );
    1558           0 :     nMinWidth = ( aActiveLB.GetSizePixel().Width() / 2 );
    1559             : 
    1560           0 :     aTimer.SetTimeoutHdl( LINK( this, SfxHelpIndexWindow_Impl, InitHdl ) );
    1561           0 :     aTimer.SetTimeout( 200 );
    1562           0 :     aTimer.Start();
    1563           0 : }
    1564             : 
    1565             : // -----------------------------------------------------------------------
    1566             : 
    1567           0 : SfxHelpIndexWindow_Impl::~SfxHelpIndexWindow_Impl()
    1568             : {
    1569           0 :     sfx2::RemoveFromTaskPaneList( this );
    1570             : 
    1571           0 :     DELETEZ( pCPage );
    1572           0 :     DELETEZ( pIPage );
    1573           0 :     DELETEZ( pSPage );
    1574           0 :     DELETEZ( pBPage );
    1575             : 
    1576           0 :     for ( sal_uInt16 i = 0; i < aActiveLB.GetEntryCount(); ++i )
    1577           0 :         delete (String*)(sal_uIntPtr)aActiveLB.GetEntryData(i);
    1578             : 
    1579           0 :     SvtViewOptions aViewOpt( E_TABDIALOG, CONFIGNAME_INDEXWIN );
    1580           0 :     aViewOpt.SetPageID( (sal_Int32)aTabCtrl.GetCurPageId() );
    1581           0 : }
    1582             : 
    1583             : // -----------------------------------------------------------------------
    1584             : 
    1585           0 : void SfxHelpIndexWindow_Impl::Initialize()
    1586             : {
    1587           0 :     OUStringBuffer aHelpURL(HELP_URL);
    1588           0 :     AppendConfigToken(aHelpURL, sal_True);
    1589           0 :     std::vector<OUString> aFactories = SfxContentHelper::GetResultSet(aHelpURL.makeStringAndClear());
    1590           0 :     for (size_t i = 0, n = aFactories.size(); i < n; ++i )
    1591             :     {
    1592           0 :         const OUString& rRow = aFactories[i];
    1593           0 :         sal_Int32 nIdx = 0;
    1594           0 :         OUString aTitle = rRow.getToken( 0, '\t', nIdx );
    1595           0 :         nIdx = 0;
    1596           0 :         OUString aURL = rRow.getToken( 2, '\t', nIdx );
    1597           0 :         String* pFactory = new String( INetURLObject( aURL ).GetHost() );
    1598           0 :         sal_uInt16 nPos = aActiveLB.InsertEntry( aTitle );
    1599           0 :         aActiveLB.SetEntryData( nPos, (void*)(sal_uIntPtr)pFactory );
    1600           0 :     }
    1601             : 
    1602           0 :     aActiveLB.SetDropDownLineCount( (sal_uInt16)aFactories.size() );
    1603           0 :     if ( aActiveLB.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
    1604           0 :         SetActiveFactory();
    1605           0 : }
    1606             : 
    1607             : // -----------------------------------------------------------------------
    1608             : 
    1609           0 : void SfxHelpIndexWindow_Impl::SetActiveFactory()
    1610             : {
    1611             :     DBG_ASSERT( pIPage, "index page not initialized" );
    1612           0 :     if ( !bIsInitDone && !aActiveLB.GetEntryCount() )
    1613             :     {
    1614           0 :         aTimer.Stop();
    1615           0 :         InitHdl( NULL );
    1616             :     }
    1617             : 
    1618           0 :     for ( sal_uInt16 i = 0; i < aActiveLB.GetEntryCount(); ++i )
    1619             :     {
    1620           0 :         String* pFactory = (String*)(sal_uIntPtr)aActiveLB.GetEntryData(i);
    1621           0 :         pFactory->ToLowerAscii();
    1622           0 :         if ( *pFactory == pIPage->GetFactory() )
    1623             :         {
    1624           0 :             if ( aActiveLB.GetSelectEntryPos() != i )
    1625             :             {
    1626           0 :                 aActiveLB.SelectEntryPos(i);
    1627           0 :                 aSelectFactoryLink.Call( NULL );
    1628             :             }
    1629           0 :             break;
    1630             :         }
    1631             :     }
    1632           0 : }
    1633             : 
    1634             : // -----------------------------------------------------------------------
    1635             : 
    1636           0 : HelpTabPage_Impl* SfxHelpIndexWindow_Impl::GetCurrentPage( sal_uInt16& rCurId )
    1637             : {
    1638           0 :     rCurId = aTabCtrl.GetCurPageId();
    1639           0 :     HelpTabPage_Impl* pPage = NULL;
    1640             : 
    1641           0 :     switch ( rCurId )
    1642             :     {
    1643             :         case HELP_INDEX_PAGE_CONTENTS:
    1644             :         {
    1645           0 :             pPage = GetContentPage();
    1646           0 :             break;
    1647             :         }
    1648             : 
    1649             :         case HELP_INDEX_PAGE_INDEX:
    1650             :         {
    1651           0 :             pPage = GetIndexPage();
    1652           0 :             break;
    1653             :         }
    1654             : 
    1655             :         case HELP_INDEX_PAGE_SEARCH:
    1656             :         {
    1657           0 :             pPage = GetSearchPage();
    1658           0 :             break;
    1659             :         }
    1660             : 
    1661             :         case HELP_INDEX_PAGE_BOOKMARKS:
    1662             :         {
    1663           0 :             pPage = GetBookmarksPage();
    1664           0 :             break;
    1665             :         }
    1666             :     }
    1667             : 
    1668             :     DBG_ASSERT( pPage, "SfxHelpIndexWindow_Impl::GetCurrentPage(): no current page" );
    1669           0 :     return pPage;
    1670             : }
    1671             : 
    1672             : // -----------------------------------------------------------------------
    1673             : 
    1674           0 : IMPL_LINK( SfxHelpIndexWindow_Impl, ActivatePageHdl, TabControl *, pTabCtrl )
    1675             : {
    1676           0 :     sal_uInt16 nId = 0;
    1677           0 :     TabPage* pPage = GetCurrentPage( nId );
    1678           0 :     pTabCtrl->SetTabPage( nId, pPage );
    1679           0 :     return 0;
    1680             : }
    1681             : 
    1682             : // -----------------------------------------------------------------------
    1683             : 
    1684           0 : IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, SelectHdl)
    1685             : {
    1686           0 :     aTimer.Start();
    1687             : 
    1688           0 :     return 0;
    1689             : }
    1690             : 
    1691             : // -----------------------------------------------------------------------
    1692             : 
    1693           0 : IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, InitHdl)
    1694             : {
    1695           0 :     bIsInitDone = true;
    1696           0 :     Initialize();
    1697             : 
    1698             :     // now use the timer for selection
    1699           0 :     aTimer.SetTimeoutHdl( LINK( this, SfxHelpIndexWindow_Impl, SelectFactoryHdl ) );
    1700           0 :     aTimer.SetTimeout( 1000 );
    1701             : 
    1702           0 :     return 0;
    1703             : }
    1704             : 
    1705             : // -----------------------------------------------------------------------
    1706             : 
    1707           0 : IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, SelectFactoryHdl)
    1708             : {
    1709           0 :     String* pFactory = (String*)(sal_uIntPtr)aActiveLB.GetEntryData( aActiveLB.GetSelectEntryPos() );
    1710           0 :     if ( pFactory )
    1711             :     {
    1712           0 :         String aFactory( *pFactory );
    1713           0 :         aFactory.ToLowerAscii();
    1714           0 :         SetFactory( aFactory, sal_False );
    1715           0 :         aSelectFactoryLink.Call( this );
    1716             :     }
    1717             : 
    1718           0 :     return 0;
    1719             : }
    1720             : 
    1721             : // -----------------------------------------------------------------------
    1722             : 
    1723           0 : IMPL_LINK_NOARG(SfxHelpIndexWindow_Impl, KeywordHdl)
    1724             : {
    1725             :     // keyword found on index?
    1726           0 :     sal_Bool bIndex = pIPage->HasKeyword();
    1727             : 
    1728           0 :     if( !bIndex)
    1729           0 :         bIndex = pIPage->HasKeywordIgnoreCase();
    1730             :     // then set index or search page as current.
    1731           0 :     sal_uInt16 nPageId = ( bIndex ) ? HELP_INDEX_PAGE_INDEX :  HELP_INDEX_PAGE_SEARCH;
    1732           0 :     if ( nPageId != aTabCtrl.GetCurPageId() )
    1733             :     {
    1734           0 :         aTabCtrl.SetCurPageId( nPageId );
    1735           0 :         ActivatePageHdl( &aTabCtrl );
    1736             :     }
    1737             : 
    1738             :     // at last we open the keyword
    1739           0 :     if ( bIndex )
    1740           0 :         pIPage->OpenKeyword();
    1741           0 :     else if ( !pSPage->OpenKeyword( sKeyword ) )
    1742           0 :         pParentWin->ShowStartPage();
    1743             : 
    1744           0 :     return 0;
    1745             : }
    1746             : 
    1747             : // -----------------------------------------------------------------------
    1748             : 
    1749           0 : void SfxHelpIndexWindow_Impl::Resize()
    1750             : {
    1751           0 :     Size aSize = GetOutputSizePixel();
    1752           0 :     if ( aSize.Width() < nMinWidth )
    1753           0 :         aSize.Width() = nMinWidth;
    1754             : 
    1755           0 :     Point aPnt = aActiveLB.GetPosPixel();
    1756           0 :     Size aNewSize = aActiveLB.GetSizePixel();
    1757           0 :     aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
    1758           0 :     aActiveLB.SetSizePixel( aNewSize );
    1759           0 :     aPnt = aActiveLine.GetPosPixel();
    1760           0 :     aNewSize = aActiveLine.GetSizePixel();
    1761           0 :     aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
    1762           0 :     aActiveLine.SetSizePixel( aNewSize );
    1763           0 :     aPnt = aTabCtrl.GetPosPixel();
    1764           0 :     aNewSize = aSize;
    1765           0 :     aSize.Width() -= aPnt.X();
    1766           0 :     aSize.Height() -= aPnt.Y();
    1767           0 :     aTabCtrl.SetSizePixel( aSize );
    1768           0 : }
    1769             : 
    1770             : // -----------------------------------------------------------------------
    1771             : 
    1772           0 : long SfxHelpIndexWindow_Impl::PreNotify( NotifyEvent& rNEvt )
    1773             : {
    1774           0 :     long nDone = 0;
    1775           0 :     sal_uInt16 nType = rNEvt.GetType();
    1776           0 :     if ( EVENT_KEYINPUT == nType && rNEvt.GetKeyEvent() )
    1777             :     {
    1778           0 :          const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
    1779           0 :         sal_uInt16 nCode = rKeyCode.GetCode();
    1780             : 
    1781           0 :         if (  KEY_TAB == nCode )
    1782             :         {
    1783             :             // don't exit index pane with <TAB>
    1784           0 :             sal_uInt16 nPageId = 0;
    1785           0 :             HelpTabPage_Impl* pCurPage = GetCurrentPage( nPageId );
    1786           0 :             Control* pControl = pCurPage->GetLastFocusControl();
    1787           0 :             sal_Bool bShift = rKeyCode.IsShift();
    1788           0 :             sal_Bool bCtrl = rKeyCode.IsMod1();
    1789           0 :             if ( !bCtrl && bShift && aActiveLB.HasChildPathFocus() )
    1790             :             {
    1791           0 :                 pControl->GrabFocus();
    1792           0 :                 nDone = 1;
    1793             :             }
    1794           0 :             else if ( !bCtrl && !bShift && pControl->HasChildPathFocus() )
    1795             :             {
    1796           0 :                 aActiveLB.GrabFocus();
    1797           0 :                 nDone = 1;
    1798             :             }
    1799           0 :             else if ( bCtrl )
    1800             :             {
    1801             :                 // <CTRL><TAB> moves through the pages
    1802           0 :                 if ( nPageId < HELP_INDEX_PAGE_LAST )
    1803           0 :                     nPageId++;
    1804             :                 else
    1805           0 :                     nPageId = HELP_INDEX_PAGE_FIRST;
    1806           0 :                 aTabCtrl.SetCurPageId( (sal_uInt16)nPageId );
    1807           0 :                 ActivatePageHdl( &aTabCtrl );
    1808           0 :                 nDone = 1;
    1809             :             }
    1810             :          }
    1811           0 :         else if ( aTabCtrl.HasFocus() && ( KEY_LEFT == nCode || KEY_RIGHT == nCode ) )
    1812             :         {
    1813           0 :             bWasCursorLeftOrRight = true;
    1814             :         }
    1815             :     }
    1816             : 
    1817           0 :     return nDone ? nDone : Window::PreNotify( rNEvt );
    1818             : }
    1819             : 
    1820             : // -----------------------------------------------------------------------
    1821             : 
    1822           0 : void SfxHelpIndexWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
    1823             : {
    1824           0 :     Window::DataChanged( rDCEvt );
    1825             : 
    1826           0 :     if ( ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) ||
    1827           0 :            ( rDCEvt.GetType() == DATACHANGED_DISPLAY ) ) &&
    1828           0 :          ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
    1829             :     {
    1830           0 :         SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFaceColor() ) );
    1831             :     }
    1832           0 : }
    1833             : 
    1834             : // -----------------------------------------------------------------------
    1835             : 
    1836           0 : void SfxHelpIndexWindow_Impl::SetDoubleClickHdl( const Link& rLink )
    1837             : {
    1838           0 :     aPageDoubleClickLink = rLink;
    1839           0 :     if ( pCPage )
    1840           0 :         pCPage->SetOpenHdl( aPageDoubleClickLink );
    1841           0 :     if ( pIPage )
    1842           0 :         pIPage->SetDoubleClickHdl( aPageDoubleClickLink );
    1843           0 :     if ( pSPage )
    1844           0 :         pSPage->SetDoubleClickHdl( aPageDoubleClickLink );
    1845           0 :     if ( pBPage )
    1846           0 :         pBPage->SetDoubleClickHdl( aPageDoubleClickLink );
    1847           0 : }
    1848             : 
    1849             : // -----------------------------------------------------------------------
    1850             : 
    1851           0 : void SfxHelpIndexWindow_Impl::SetFactory( const String& rFactory, sal_Bool bActive )
    1852             : {
    1853           0 :     if ( rFactory.Len() > 0 )
    1854             :     {
    1855           0 :         GetIndexPage()->SetFactory( rFactory );
    1856             :         // the index page did a check if rFactory is valid,
    1857             :         // so the index page always returns a valid factory
    1858           0 :         GetSearchPage()->SetFactory( GetIndexPage()->GetFactory() );
    1859           0 :         if ( bActive )
    1860           0 :             SetActiveFactory();
    1861             :     }
    1862           0 : }
    1863             : 
    1864             : // -----------------------------------------------------------------------
    1865             : 
    1866           0 : String SfxHelpIndexWindow_Impl::GetSelectEntry() const
    1867             : {
    1868           0 :     String sRet;
    1869             : 
    1870           0 :     switch ( aTabCtrl.GetCurPageId() )
    1871             :     {
    1872             :         case HELP_INDEX_PAGE_CONTENTS:
    1873           0 :             sRet = pCPage->GetSelectEntry();
    1874           0 :             break;
    1875             : 
    1876             :         case HELP_INDEX_PAGE_INDEX:
    1877           0 :             sRet = pIPage->GetSelectEntry();
    1878           0 :             break;
    1879             : 
    1880             :         case HELP_INDEX_PAGE_SEARCH:
    1881           0 :             sRet = pSPage->GetSelectEntry();
    1882           0 :             break;
    1883             : 
    1884             :         case HELP_INDEX_PAGE_BOOKMARKS:
    1885           0 :             sRet = pBPage->GetSelectEntry();
    1886           0 :             break;
    1887             :     }
    1888             : 
    1889           0 :     return sRet;
    1890             : }
    1891             : 
    1892             : // -----------------------------------------------------------------------
    1893             : 
    1894           0 : void SfxHelpIndexWindow_Impl::AddBookmarks( const String& rTitle, const String& rURL )
    1895             : {
    1896           0 :     GetBookmarksPage()->AddBookmarks( rTitle, rURL );
    1897           0 : }
    1898             : 
    1899             : // -----------------------------------------------------------------------
    1900             : 
    1901           0 : bool SfxHelpIndexWindow_Impl::IsValidFactory( const String& _rFactory )
    1902             : {
    1903           0 :     bool bValid = false;
    1904           0 :     for ( sal_uInt16 i = 0; i < aActiveLB.GetEntryCount(); ++i )
    1905             :     {
    1906           0 :         String* pFactory = (String*)(sal_uIntPtr)aActiveLB.GetEntryData(i);
    1907           0 :         if ( *pFactory == _rFactory )
    1908             :         {
    1909           0 :             bValid = true;
    1910           0 :             break;
    1911             :         }
    1912             :     }
    1913           0 :     return bValid;
    1914             : }
    1915             : 
    1916             : // -----------------------------------------------------------------------
    1917             : 
    1918           0 : void SfxHelpIndexWindow_Impl::ClearSearchPage()
    1919             : {
    1920           0 :     if ( pSPage )
    1921           0 :         pSPage->ClearPage();
    1922           0 : }
    1923             : 
    1924             : // -----------------------------------------------------------------------
    1925             : 
    1926           0 : void SfxHelpIndexWindow_Impl::GrabFocusBack()
    1927             : {
    1928           0 :     if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_CONTENTS && pCPage )
    1929           0 :         pCPage->SetFocusOnBox();
    1930           0 :     else if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_INDEX && pIPage )
    1931           0 :         pIPage->SetFocusOnBox();
    1932           0 :     else if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_SEARCH && pSPage )
    1933           0 :         pSPage->SetFocusOnBox();
    1934           0 :     else if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_BOOKMARKS && pBPage )
    1935           0 :         pBPage->SetFocusOnBox();
    1936           0 : }
    1937             : 
    1938             : // -----------------------------------------------------------------------
    1939             : 
    1940           0 : sal_Bool SfxHelpIndexWindow_Impl::HasFocusOnEdit() const
    1941             : {
    1942           0 :     sal_Bool bRet = sal_False;
    1943           0 :     if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_INDEX && pIPage )
    1944           0 :         bRet = pIPage->HasFocusOnEdit();
    1945           0 :     else if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_SEARCH && pSPage )
    1946           0 :         bRet = pSPage->HasFocusOnEdit();
    1947           0 :     return bRet;
    1948             : }
    1949             : 
    1950             : // -----------------------------------------------------------------------
    1951             : 
    1952           0 : String SfxHelpIndexWindow_Impl::GetSearchText() const
    1953             : {
    1954           0 :     String sRet;
    1955           0 :     if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_SEARCH && pSPage )
    1956           0 :         sRet = pSPage->GetSearchText();
    1957           0 :     return sRet;
    1958             : }
    1959             : 
    1960             : // -----------------------------------------------------------------------
    1961             : 
    1962           0 : sal_Bool SfxHelpIndexWindow_Impl::IsFullWordSearch() const
    1963             : {
    1964           0 :     sal_Bool bRet = sal_False;
    1965           0 :     if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_SEARCH && pSPage )
    1966           0 :         bRet = pSPage->IsFullWordSearch();
    1967           0 :     return bRet;
    1968             : }
    1969             : 
    1970             : // -----------------------------------------------------------------------
    1971             : 
    1972           0 : void SfxHelpIndexWindow_Impl::OpenKeyword( const String& rKeyword )
    1973             : {
    1974           0 :     sKeyword = rKeyword;
    1975             :     DBG_ASSERT( pIPage, "invalid index page" );
    1976           0 :     pIPage->SetKeyword( sKeyword );
    1977           0 : }
    1978             : 
    1979             : // -----------------------------------------------------------------------
    1980             : 
    1981           0 : void SfxHelpIndexWindow_Impl::SelectExecutableEntry()
    1982             : {
    1983           0 :     if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_INDEX && pIPage )
    1984           0 :         pIPage->SelectExecutableEntry();
    1985           0 : }
    1986             : 
    1987             : // class TextWin_Impl ----------------------------------------------------
    1988             : 
    1989           0 : TextWin_Impl::TextWin_Impl( Window* p ) : DockingWindow( p, 0 )
    1990             : {
    1991           0 : }
    1992             : 
    1993           0 : TextWin_Impl::~TextWin_Impl()
    1994             : {
    1995           0 : }
    1996             : 
    1997           0 : long TextWin_Impl::Notify( NotifyEvent& rNEvt )
    1998             : {
    1999           0 :     if( ( rNEvt.GetType() == EVENT_KEYINPUT ) && rNEvt.GetKeyEvent()->GetKeyCode().GetCode() == KEY_TAB )
    2000           0 :         return GetParent()->Notify( rNEvt );
    2001             :     else
    2002           0 :         return DockingWindow::Notify( rNEvt );
    2003             : }
    2004             : 
    2005             : // -----------------------------------------------------------------------
    2006             : // remove docking area acceptor from layoutmanager, so it will not layout anything further .-)
    2007           0 : static void lcl_disableLayoutOfFrame(const Reference< XFrame2 >& xFrame)
    2008             : {
    2009           0 :     xFrame->setLayoutManager( Reference< XLayoutManager >() );
    2010           0 : }
    2011             : 
    2012             : // class SfxHelpTextWindow_Impl ------------------------------------------
    2013             : 
    2014           0 : SfxHelpTextWindow_Impl::SfxHelpTextWindow_Impl( SfxHelpWindow_Impl* pParent ) :
    2015             : 
    2016             :     Window( pParent, WB_CLIPCHILDREN | WB_TABSTOP | WB_DIALOGCONTROL ),
    2017             : 
    2018             :     aToolBox            ( this, 0 ),
    2019             :     aOnStartupCB        ( this, SfxResId( RID_HELP_ONSTARTUP_BOX ) ),
    2020             :     aIndexOnImage       ( SfxResId( IMG_HELP_TOOLBOX_INDEX_ON ) ),
    2021             :     aIndexOffImage      ( SfxResId( IMG_HELP_TOOLBOX_INDEX_OFF ) ),
    2022             :     aIndexOnText        ( SfxResId( STR_HELP_BUTTON_INDEX_ON ).toString() ),
    2023             :     aIndexOffText       ( SfxResId( STR_HELP_BUTTON_INDEX_OFF ).toString() ),
    2024             :     aOnStartupText      ( SfxResId( RID_HELP_ONSTARTUP_TEXT ).toString() ),
    2025             :     pHelpWin            ( pParent ),
    2026           0 :     pTextWin            ( new TextWin_Impl( this ) ),
    2027             :     pSrchDlg            ( NULL ),
    2028             :     nMinPos             ( 0 ),
    2029             :     bIsDebug            ( sal_False ),
    2030             :     bIsIndexOn          ( sal_False ),
    2031             :     bIsInClose          ( sal_False ),
    2032           0 :     bIsFullWordSearch   ( sal_False )
    2033             : 
    2034             : {
    2035           0 :     sfx2::AddToTaskPaneList( &aToolBox );
    2036             : 
    2037           0 :     xFrame = Frame::create( ::comphelper::getProcessComponentContext() );
    2038           0 :     xFrame->initialize( VCLUnoHelper::GetInterface ( pTextWin ) );
    2039           0 :     xFrame->setName( "OFFICE_HELP" );
    2040           0 :     lcl_disableLayoutOfFrame(xFrame);
    2041             : 
    2042           0 :     aToolBox.SetHelpId( HID_HELP_TOOLBOX );
    2043             : 
    2044           0 :     aToolBox.InsertItem( TBI_INDEX, aIndexOffText );
    2045           0 :     aToolBox.SetHelpId( TBI_INDEX, HID_HELP_TOOLBOXITEM_INDEX );
    2046           0 :     aToolBox.InsertSeparator();
    2047           0 :     aToolBox.InsertItem( TBI_BACKWARD, SfxResId( STR_HELP_BUTTON_PREV ).toString() );
    2048           0 :     aToolBox.SetHelpId( TBI_BACKWARD, HID_HELP_TOOLBOXITEM_BACKWARD );
    2049           0 :     aToolBox.InsertItem( TBI_FORWARD, SfxResId( STR_HELP_BUTTON_NEXT ).toString() );
    2050           0 :     aToolBox.SetHelpId( TBI_FORWARD, HID_HELP_TOOLBOXITEM_FORWARD );
    2051           0 :     aToolBox.InsertItem( TBI_START, SfxResId( STR_HELP_BUTTON_START ).toString() );
    2052           0 :     aToolBox.SetHelpId( TBI_START, HID_HELP_TOOLBOXITEM_START );
    2053           0 :     aToolBox.InsertSeparator();
    2054           0 :     aToolBox.InsertItem( TBI_PRINT, SfxResId( STR_HELP_BUTTON_PRINT ).toString() );
    2055           0 :     aToolBox.SetHelpId( TBI_PRINT, HID_HELP_TOOLBOXITEM_PRINT );
    2056           0 :     aToolBox.InsertItem( TBI_BOOKMARKS, SfxResId( STR_HELP_BUTTON_ADDBOOKMARK ).toString() );
    2057           0 :     aToolBox.SetHelpId( TBI_BOOKMARKS, HID_HELP_TOOLBOXITEM_BOOKMARKS );
    2058           0 :     aToolBox.InsertItem( TBI_SEARCHDIALOG, SfxResId( STR_HELP_BUTTON_SEARCHDIALOG ).toString() );
    2059           0 :     aToolBox.SetHelpId( TBI_SEARCHDIALOG, HID_HELP_TOOLBOXITEM_SEARCHDIALOG );
    2060             : 
    2061           0 :     InitToolBoxImages();
    2062           0 :     aToolBox.Show();
    2063           0 :     InitOnStartupBox( false );
    2064           0 :     aOnStartupCB.SetClickHdl( LINK( this, SfxHelpTextWindow_Impl, CheckHdl ) );
    2065             : 
    2066           0 :     aSelectTimer.SetTimeoutHdl( LINK( this, SfxHelpTextWindow_Impl, SelectHdl ) );
    2067           0 :     aSelectTimer.SetTimeout( 1000 );
    2068             : 
    2069           0 :     char* pEnv = getenv( "help_debug" );
    2070           0 :     if ( pEnv )
    2071           0 :         bIsDebug = sal_True;
    2072             : 
    2073           0 :     SvtMiscOptions().AddListenerLink( LINK( this, SfxHelpTextWindow_Impl, NotifyHdl ) );
    2074             : 
    2075           0 :     if ( !aOnStartupCB.GetHelpId().getLength() )
    2076           0 :         aOnStartupCB.SetHelpId( HID_HELP_ONSTARTUP_BOX );
    2077           0 : }
    2078             : 
    2079             : // -----------------------------------------------------------------------
    2080             : 
    2081           0 : SfxHelpTextWindow_Impl::~SfxHelpTextWindow_Impl()
    2082             : {
    2083           0 :     sfx2::RemoveFromTaskPaneList( &aToolBox );
    2084             : 
    2085           0 :     bIsInClose = sal_True;
    2086           0 :     SvtMiscOptions().RemoveListenerLink( LINK( this, SfxHelpTextWindow_Impl, NotifyHdl ) );
    2087           0 :     delete pSrchDlg;
    2088           0 : }
    2089             : 
    2090             : // -----------------------------------------------------------------------
    2091             : 
    2092           0 : sal_Bool SfxHelpTextWindow_Impl::HasSelection() const
    2093             : {
    2094             :     // is there any selection in the text and not only a cursor?
    2095           0 :     sal_Bool bRet = sal_False;
    2096           0 :     Reference < XTextRange > xRange = getCursor();
    2097           0 :     if ( xRange.is() )
    2098             :     {
    2099           0 :         Reference < XText > xText = xRange->getText();
    2100           0 :         Reference < XTextCursor > xCursor = xText->createTextCursorByRange( xRange );
    2101           0 :         bRet = !xCursor->isCollapsed();
    2102             :     }
    2103             : 
    2104           0 :     return bRet;
    2105             : }
    2106             : 
    2107             : // -----------------------------------------------------------------------
    2108             : 
    2109           0 : void SfxHelpTextWindow_Impl::InitToolBoxImages()
    2110             : {
    2111           0 :     sal_Bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge();
    2112             : 
    2113           0 :     aIndexOnImage  = Image( SfxResId( bLarge ? IMG_HELP_TOOLBOX_L_INDEX_ON  : IMG_HELP_TOOLBOX_INDEX_ON  ) );
    2114           0 :     aIndexOffImage = Image( SfxResId( bLarge ? IMG_HELP_TOOLBOX_L_INDEX_OFF : IMG_HELP_TOOLBOX_INDEX_OFF ) );
    2115             : 
    2116           0 :     aToolBox.SetItemImage( TBI_INDEX, bIsIndexOn ? aIndexOffImage : aIndexOnImage );
    2117             : 
    2118             :     aToolBox.SetItemImage( TBI_BACKWARD,
    2119             :                            Image( SfxResId( bLarge ? IMG_HELP_TOOLBOX_L_PREV : IMG_HELP_TOOLBOX_PREV ) )
    2120           0 :     );
    2121             : 
    2122             :     aToolBox.SetItemImage( TBI_FORWARD,
    2123             :                            Image( SfxResId( bLarge ? IMG_HELP_TOOLBOX_L_NEXT : IMG_HELP_TOOLBOX_NEXT ) )
    2124           0 :     );
    2125             : 
    2126             :     aToolBox.SetItemImage( TBI_START,
    2127             :                            Image( SfxResId( bLarge ? IMG_HELP_TOOLBOX_L_START : IMG_HELP_TOOLBOX_START ) )
    2128           0 :     );
    2129             : 
    2130             :     aToolBox.SetItemImage( TBI_PRINT,
    2131             :                            Image( SfxResId( bLarge ? IMG_HELP_TOOLBOX_L_PRINT : IMG_HELP_TOOLBOX_PRINT ) )
    2132           0 :     );
    2133             : 
    2134             :     aToolBox.SetItemImage( TBI_BOOKMARKS,
    2135             :                            Image( SfxResId( bLarge ? IMG_HELP_TOOLBOX_L_BOOKMARKS : IMG_HELP_TOOLBOX_BOOKMARKS ) )
    2136           0 :     );
    2137             : 
    2138             :     aToolBox.SetItemImage( TBI_SEARCHDIALOG,
    2139             :                            Image( SfxResId( bLarge ? IMG_HELP_TOOLBOX_L_SEARCHDIALOG : IMG_HELP_TOOLBOX_SEARCHDIALOG ) )
    2140           0 :     );
    2141             : 
    2142           0 :     Size aSize = aToolBox.CalcWindowSizePixel();
    2143           0 :     aSize.Height() += TOOLBOX_OFFSET;
    2144           0 :     aToolBox.SetPosSizePixel( Point( 0, TOOLBOX_OFFSET ), aSize );
    2145             : 
    2146           0 :     SvtMiscOptions aMiscOptions;
    2147           0 :     if ( aMiscOptions.GetToolboxStyle() != aToolBox.GetOutStyle() )
    2148           0 :         aToolBox.SetOutStyle( aMiscOptions.GetToolboxStyle() );
    2149           0 : }
    2150             : 
    2151             : // -----------------------------------------------------------------------
    2152             : 
    2153           0 : void SfxHelpTextWindow_Impl::InitOnStartupBox( bool bOnlyText )
    2154             : {
    2155           0 :     sCurrentFactory = SfxHelp::GetCurrentModuleIdentifier();
    2156             : 
    2157           0 :     Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
    2158           0 :     Reference< XInterface > xConfig;
    2159           0 :     OUString sPath( PATH_OFFICE_FACTORIES );
    2160           0 :     sPath += sCurrentFactory;
    2161           0 :     OUString sKey( KEY_HELP_ON_OPEN );
    2162             : 
    2163             :     // Attention: This check boy knows two states:
    2164             :     // 1) Reading of the config key fails with an exception or by getting an empty Any (!) => check box must be hidden
    2165             :     // 2) We read sal_True/sal_False => check box must be shown and enabled/disabled
    2166             : 
    2167           0 :     bool bHideBox = true;
    2168           0 :     sal_Bool bHelpAtStartup = sal_False;
    2169             :     try
    2170             :     {
    2171           0 :         xConfiguration = ConfigurationHelper::openConfig(
    2172           0 :             xContext, PACKAGE_SETUP, ConfigurationHelper::E_STANDARD );
    2173           0 :         if ( xConfiguration.is() )
    2174             :         {
    2175           0 :             Any aAny = ConfigurationHelper::readRelativeKey( xConfiguration, sPath, sKey );
    2176           0 :             if (aAny >>= bHelpAtStartup)
    2177           0 :                 bHideBox = false;
    2178             :         }
    2179             :     }
    2180           0 :     catch( Exception& )
    2181             :     {
    2182           0 :         bHideBox = true;
    2183             :     }
    2184             : 
    2185           0 :     if ( bHideBox )
    2186           0 :         aOnStartupCB.Hide();
    2187             :     else
    2188             :     {
    2189             :         // detect module name
    2190           0 :         String sModuleName;
    2191             : 
    2192           0 :         if ( xConfiguration.is() )
    2193             :         {
    2194           0 :             OUString sTemp;
    2195           0 :             sKey = KEY_UI_NAME;
    2196             :             try
    2197             :             {
    2198           0 :                 Any aAny = ConfigurationHelper::readRelativeKey( xConfiguration, sPath, sKey );
    2199           0 :                 aAny >>= sTemp;
    2200             :             }
    2201           0 :             catch( Exception& )
    2202             :             {
    2203             :                 SAL_WARN( "sfx2.appl", "SfxHelpTextWindow_Impl::InitOnStartupBox(): unexpected exception" );
    2204             :             }
    2205           0 :             sModuleName = String( sTemp );
    2206             :         }
    2207             : 
    2208           0 :         if ( sModuleName.Len() > 0 )
    2209             :         {
    2210             :             // set module name in checkbox text
    2211           0 :             String sText( aOnStartupText );
    2212           0 :             sText.SearchAndReplace( OUString("%MODULENAME"), sModuleName );
    2213           0 :             aOnStartupCB.SetText( sText );
    2214             :             // and show it
    2215           0 :             aOnStartupCB.Show();
    2216             :             // set check state
    2217           0 :             aOnStartupCB.Check( bHelpAtStartup );
    2218           0 :             aOnStartupCB.SaveValue();
    2219             : 
    2220             :             // calculate and set optimal width of the onstartup checkbox
    2221           0 :             String sCBText( "XXX" );
    2222           0 :             sCBText += aOnStartupCB.GetText();
    2223           0 :             long nTextWidth = aOnStartupCB.GetTextWidth( sCBText );
    2224           0 :             Size aSize = aOnStartupCB.GetSizePixel();
    2225           0 :             aSize.Width() = nTextWidth;
    2226           0 :             aOnStartupCB.SetSizePixel( aSize );
    2227           0 :             SetOnStartupBoxPosition();
    2228             :         }
    2229             : 
    2230           0 :         if ( !bOnlyText )
    2231             :         {
    2232             :             // set position of the checkbox
    2233           0 :             Size a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
    2234           0 :             Size aTBSize = aToolBox.GetSizePixel();
    2235           0 :             Size aCBSize = aOnStartupCB.GetSizePixel();
    2236           0 :             Point aPnt = aToolBox.GetPosPixel();
    2237           0 :             aPnt.X() += aTBSize.Width() + a3Size.Width();
    2238           0 :             aPnt.Y() += ( ( aTBSize.Height() - aCBSize.Height() ) / 2 );
    2239           0 :             aOnStartupCB.SetPosPixel( aPnt );
    2240           0 :             nMinPos = aPnt.X();
    2241           0 :         }
    2242           0 :     }
    2243           0 : }
    2244             : 
    2245             : // -----------------------------------------------------------------------
    2246             : 
    2247           0 : void SfxHelpTextWindow_Impl::SetOnStartupBoxPosition()
    2248             : {
    2249           0 :     long nX = std::max( GetOutputSizePixel().Width() - aOnStartupCB.GetSizePixel().Width(), nMinPos );
    2250           0 :     Point aPos = aOnStartupCB.GetPosPixel();
    2251           0 :     aPos.X() = nX;
    2252           0 :     aOnStartupCB.SetPosPixel( aPos );
    2253           0 : }
    2254             : 
    2255             : // -----------------------------------------------------------------------
    2256             : 
    2257           0 : Reference< XBreakIterator > SfxHelpTextWindow_Impl::GetBreakIterator()
    2258             : {
    2259           0 :     if ( !xBreakIterator.is() )
    2260           0 :         xBreakIterator = vcl::unohelper::CreateBreakIterator();
    2261             :     DBG_ASSERT( xBreakIterator.is(), "Could not create BreakIterator" );
    2262           0 :     return xBreakIterator;
    2263             : }
    2264             : 
    2265             : // -----------------------------------------------------------------------
    2266             : 
    2267           0 : Reference< XTextRange > SfxHelpTextWindow_Impl::getCursor() const
    2268             : {
    2269             :     // return the current cursor
    2270           0 :     Reference< XTextRange > xCursor;
    2271             : 
    2272             :     try
    2273             :     {
    2274           0 :         Reference < XSelectionSupplier > xSelSup( xFrame->getController(), UNO_QUERY );
    2275           0 :         if ( xSelSup.is() )
    2276             :         {
    2277           0 :             Any aAny = xSelSup->getSelection();
    2278           0 :             Reference < XIndexAccess > xSelection;
    2279           0 :             if ( aAny >>= xSelection )
    2280             :             {
    2281           0 :                 if ( xSelection->getCount() == 1 )
    2282             :                 {
    2283           0 :                     aAny = xSelection->getByIndex(0);
    2284           0 :                     aAny >>= xCursor;
    2285             :                 }
    2286           0 :             }
    2287           0 :         }
    2288             :     }
    2289           0 :     catch( Exception& )
    2290             :     {
    2291             :         OSL_FAIL( "SfxHelpTextWindow_Impl::getCursor(): unexpected exception" );
    2292             :     }
    2293             : 
    2294           0 :     return xCursor;
    2295             : }
    2296             : 
    2297             : // -----------------------------------------------------------------------
    2298             : 
    2299           0 : bool SfxHelpTextWindow_Impl::isHandledKey( const KeyCode& _rKeyCode )
    2300             : {
    2301           0 :     bool bRet = false;
    2302           0 :     sal_uInt16 nCode = _rKeyCode.GetCode();
    2303             : 
    2304             :     // the keys <CTRL><A> (select all), <CTRL><C> (copy),
    2305             :     //          <CTRL><F> (find), <CTRL><P> (print) and <CTRL><W> (close window)
    2306             :     // were handled in help
    2307           0 :     if ( _rKeyCode.IsMod1() &&
    2308           0 :          ( KEY_A == nCode || KEY_C == nCode || KEY_F == nCode || KEY_P == nCode || KEY_W == nCode ) )
    2309             :     {
    2310           0 :         if ( KEY_F == nCode )
    2311           0 :             DoSearch();
    2312             :         else
    2313           0 :             bRet = true;
    2314             :     }
    2315             : 
    2316           0 :     return bRet;
    2317             : }
    2318             : 
    2319             : // -----------------------------------------------------------------------
    2320             : 
    2321           0 : IMPL_LINK_NOARG(SfxHelpTextWindow_Impl, SelectHdl)
    2322             : {
    2323             :     try
    2324             :     {
    2325             :         // select the words, which are equal to the search text of the search page
    2326           0 :         Reference < XController > xController = xFrame->getController();
    2327           0 :         if ( xController.is() )
    2328             :         {
    2329             :             // get document
    2330           0 :             Reference < XSearchable > xSearchable( xController->getModel(), UNO_QUERY );
    2331           0 :             if ( xSearchable.is() )
    2332             :             {
    2333             :                 // create descriptor, set string and find all words
    2334           0 :                 Reference < XSearchDescriptor > xSrchDesc = xSearchable->createSearchDescriptor();
    2335           0 :                 xSrchDesc->setPropertyValue( "SearchRegularExpression",
    2336           0 :                                             makeAny( sal_Bool( sal_True ) ) );
    2337           0 :                 if ( bIsFullWordSearch )
    2338           0 :                     xSrchDesc->setPropertyValue( "SearchWords",
    2339           0 :                                                 makeAny( sal_Bool( sal_True ) ) );
    2340             : 
    2341           0 :                 String sSearchString = sfx2::PrepareSearchString( aSearchText, GetBreakIterator(), false );
    2342           0 :                 xSrchDesc->setSearchString( sSearchString );
    2343           0 :                 Reference< XIndexAccess > xSelection = xSearchable->findAll( xSrchDesc );
    2344             : 
    2345             :                 // then select all found words
    2346           0 :                 Reference < XSelectionSupplier > xSelectionSup( xController, UNO_QUERY );
    2347           0 :                 if ( xSelectionSup.is() )
    2348             :                 {
    2349           0 :                     Any aAny;
    2350           0 :                     aAny <<= xSelection;
    2351           0 :                     xSelectionSup->select( aAny );
    2352           0 :                 }
    2353           0 :             }
    2354           0 :         }
    2355             :     }
    2356           0 :     catch( Exception& )
    2357             :     {
    2358             :         OSL_FAIL( "SfxHelpTextWindow_Impl::SelectHdl(): unexpected exception" );
    2359             :     }
    2360             : 
    2361           0 :     return 1;
    2362             : }
    2363             : 
    2364             : // -----------------------------------------------------------------------
    2365             : 
    2366           0 : IMPL_LINK( SfxHelpTextWindow_Impl, NotifyHdl, SvtMiscOptions*, pOptions )
    2367             : {
    2368             :     (void)pOptions; // unused variable
    2369           0 :     InitToolBoxImages();
    2370           0 :     Resize();
    2371           0 :     aToolBox.Invalidate();
    2372           0 :     return 0;
    2373             : }
    2374             : 
    2375             : // -----------------------------------------------------------------------
    2376             : 
    2377           0 : IMPL_LINK( SfxHelpTextWindow_Impl, FindHdl, sfx2::SearchDialog*, pDlg )
    2378             : {
    2379           0 :     bool bWrapAround = ( NULL == pDlg );
    2380           0 :     if ( bWrapAround )
    2381           0 :         pDlg = pSrchDlg;
    2382             :     DBG_ASSERT( pDlg, "invalid search dialog" );
    2383           0 :     String sSearchText = pDlg->GetSearchText();
    2384             :     try
    2385             :     {
    2386             :         // select the words, which are equal to the search text of the search page
    2387           0 :         Reference < XController > xController = xFrame->getController();
    2388           0 :         if ( xController.is() )
    2389             :         {
    2390             :             // get document
    2391           0 :             Reference < XSearchable > xSearchable( xController->getModel(), UNO_QUERY );
    2392           0 :             if ( xSearchable.is() )
    2393             :             {
    2394             :                 // create descriptor, set string and find all words
    2395           0 :                 Reference < XSearchDescriptor > xSrchDesc = xSearchable->createSearchDescriptor();
    2396           0 :                 xSrchDesc->setPropertyValue( "SearchWords", makeAny( sal_Bool( pDlg->IsOnlyWholeWords() != false ) ) );
    2397           0 :                 xSrchDesc->setPropertyValue( "SearchCaseSensitive", makeAny( sal_Bool( pDlg->IsMarchCase() != false ) ) );
    2398           0 :                 xSrchDesc->setPropertyValue( "SearchBackwards", makeAny( sal_Bool( pDlg->IsSearchBackwards() != false ) ) );
    2399           0 :                 xSrchDesc->setSearchString( sSearchText );
    2400           0 :                 Reference< XInterface > xSelection;
    2401           0 :                 Reference< XTextRange > xCursor = getCursor();
    2402             : 
    2403           0 :                 if ( xCursor.is() )
    2404             :                 {
    2405           0 :                     if ( pDlg->IsSearchBackwards() )
    2406           0 :                         xCursor = xCursor->getStart();
    2407           0 :                     xSelection = xSearchable->findNext( xCursor, xSrchDesc );
    2408             :                 }
    2409             :                 else
    2410           0 :                     xSelection = xSearchable->findFirst( xSrchDesc );
    2411             : 
    2412             :                 // then select the found word
    2413           0 :                 if ( xSelection.is() )
    2414             :                 {
    2415           0 :                     Reference < XSelectionSupplier > xSelectionSup( xController, UNO_QUERY );
    2416           0 :                     if ( xSelectionSup.is() )
    2417             :                     {
    2418           0 :                         Any aAny;
    2419           0 :                         aAny <<= xSelection;
    2420           0 :                         xSelectionSup->select( aAny );
    2421           0 :                     }
    2422             :                 }
    2423           0 :                 else if ( pDlg->IsWrapAround() && !bWrapAround )
    2424             :                 {
    2425           0 :                     Reference < text::XTextViewCursorSupplier > xCrsrSupp( xController, uno::UNO_QUERY );
    2426           0 :                     Reference < text::XTextViewCursor > xTVCrsr( xCrsrSupp->getViewCursor(), uno::UNO_QUERY );
    2427           0 :                     if ( xTVCrsr.is() )
    2428             :                     {
    2429           0 :                         Reference < text::XTextDocument > xDoc( xController->getModel(), uno::UNO_QUERY );
    2430           0 :                         Reference < text::XText > xText = xDoc->getText();
    2431           0 :                         if ( xText.is() )
    2432             :                         {
    2433           0 :                             if ( pDlg->IsSearchBackwards() )
    2434           0 :                                 xTVCrsr->gotoRange( xText->getEnd(), sal_False );
    2435             :                             else
    2436           0 :                                 xTVCrsr->gotoRange( xText->getStart(), sal_False );
    2437           0 :                             FindHdl( NULL );
    2438           0 :                         }
    2439           0 :                     }
    2440             :                 }
    2441             :                 else
    2442             :                 {
    2443             :                     DBG_ASSERT( pSrchDlg, "no search dialog" );
    2444           0 :                     InfoBox aBox( pSrchDlg, SfxResId( RID_INFO_NOSEARCHTEXTFOUND ) );
    2445           0 :                     aBox.Execute();
    2446           0 :                     pSrchDlg->SetFocusOnEdit();
    2447           0 :                 }
    2448           0 :             }
    2449           0 :         }
    2450             :     }
    2451           0 :     catch( Exception& )
    2452             :     {
    2453             :         OSL_FAIL( "SfxHelpTextWindow_Impl::SelectHdl(): unexpected exception" );
    2454             :     }
    2455             : 
    2456           0 :     return 0;
    2457             : }
    2458             : 
    2459             : // -----------------------------------------------------------------------
    2460             : 
    2461           0 : IMPL_LINK( SfxHelpTextWindow_Impl, CloseHdl, sfx2::SearchDialog*, pDlg )
    2462             : {
    2463           0 :     if ( pDlg )
    2464           0 :         delete pSrchDlg;
    2465           0 :     pSrchDlg = NULL;
    2466           0 :     return 0;
    2467             : }
    2468             : 
    2469             : // -----------------------------------------------------------------------
    2470             : 
    2471           0 : IMPL_LINK( SfxHelpTextWindow_Impl, CheckHdl, CheckBox*, pBox )
    2472             : {
    2473           0 :     if ( xConfiguration.is() )
    2474             :     {
    2475           0 :         sal_Bool bChecked = pBox->IsChecked();
    2476           0 :         OUString sPath( PATH_OFFICE_FACTORIES );
    2477           0 :         sPath += sCurrentFactory;
    2478             :         try
    2479             :         {
    2480             :             ConfigurationHelper::writeRelativeKey(
    2481           0 :                 xConfiguration, sPath, KEY_HELP_ON_OPEN, makeAny( bChecked ) );
    2482           0 :             ConfigurationHelper::flush( xConfiguration );
    2483             :         }
    2484           0 :         catch( Exception& )
    2485             :         {
    2486             :             SAL_WARN( "sfx2.appl", "SfxHelpTextWindow_Impl::CheckHdl(): unexpected exception" );
    2487           0 :         }
    2488             :     }
    2489             : 
    2490           0 :     return 0;
    2491             : }
    2492             : 
    2493             : // -----------------------------------------------------------------------
    2494             : 
    2495           0 : void SfxHelpTextWindow_Impl::Resize()
    2496             : {
    2497           0 :     Size aSize = GetOutputSizePixel();
    2498           0 :     long nToolBoxHeight = aToolBox.GetSizePixel().Height() + TOOLBOX_OFFSET;
    2499           0 :     aSize.Height() -= nToolBoxHeight;
    2500           0 :     pTextWin->SetPosSizePixel( Point( 0, nToolBoxHeight  ), aSize );
    2501           0 :     SetOnStartupBoxPosition();
    2502           0 : }
    2503             : 
    2504             : // -----------------------------------------------------------------------
    2505             : 
    2506           0 : long SfxHelpTextWindow_Impl::PreNotify( NotifyEvent& rNEvt )
    2507             : {
    2508           0 :     long nDone = 0;
    2509           0 :     sal_uInt16 nType = rNEvt.GetType();
    2510           0 :     if ( EVENT_COMMAND == nType && rNEvt.GetCommandEvent() )
    2511             :     {
    2512           0 :         const CommandEvent* pCmdEvt = rNEvt.GetCommandEvent();
    2513           0 :         Window* pCmdWin = rNEvt.GetWindow();
    2514             : 
    2515           0 :         if ( pCmdEvt->GetCommand() == COMMAND_CONTEXTMENU && pCmdWin != this && pCmdWin != &aToolBox )
    2516             :         {
    2517           0 :             Point aPos;
    2518           0 :             if ( pCmdEvt->IsMouseEvent() )
    2519           0 :                 aPos = pCmdEvt->GetMousePosPixel();
    2520             :             else
    2521           0 :                 aPos = Point( pTextWin->GetPosPixel().X() + 20, 20 );
    2522           0 :             aPos.Y() += pTextWin->GetPosPixel().Y();
    2523           0 :             PopupMenu aMenu;
    2524           0 :             if ( bIsIndexOn )
    2525           0 :                 aMenu.InsertItem( TBI_INDEX, aIndexOffText, Image( SfxResId( IMG_HELP_TOOLBOX_INDEX_OFF ) ) );
    2526             :             else
    2527           0 :                 aMenu.InsertItem( TBI_INDEX, aIndexOnText,  Image( SfxResId( IMG_HELP_TOOLBOX_INDEX_ON  ) ) );
    2528             : 
    2529           0 :             aMenu.SetHelpId( TBI_INDEX, HID_HELP_TOOLBOXITEM_INDEX );
    2530           0 :             aMenu.InsertSeparator();
    2531             :             aMenu.InsertItem( TBI_BACKWARD,
    2532             :                               SfxResId( STR_HELP_BUTTON_PREV  ).toString(),
    2533             :                               Image(  SfxResId( IMG_HELP_TOOLBOX_PREV ) )
    2534           0 :             );
    2535           0 :             aMenu.SetHelpId( TBI_BACKWARD, HID_HELP_TOOLBOXITEM_BACKWARD );
    2536           0 :             aMenu.EnableItem( TBI_BACKWARD, pHelpWin->HasHistoryPredecessor() );
    2537             :             aMenu.InsertItem( TBI_FORWARD,
    2538             :                               SfxResId( STR_HELP_BUTTON_NEXT ).toString(),
    2539             :                               Image(  SfxResId( IMG_HELP_TOOLBOX_NEXT ) )
    2540           0 :             );
    2541           0 :             aMenu.SetHelpId( TBI_FORWARD, HID_HELP_TOOLBOXITEM_FORWARD );
    2542           0 :             aMenu.EnableItem( TBI_FORWARD, pHelpWin->HasHistorySuccessor() );
    2543             :             aMenu.InsertItem( TBI_START,
    2544             :                               SfxResId( STR_HELP_BUTTON_START ).toString(),
    2545             :                               Image(  SfxResId( IMG_HELP_TOOLBOX_START ) )
    2546           0 :             );
    2547           0 :             aMenu.SetHelpId( TBI_START, HID_HELP_TOOLBOXITEM_START );
    2548           0 :             aMenu.InsertSeparator();
    2549             :             aMenu.InsertItem( TBI_PRINT,
    2550             :                               SfxResId( STR_HELP_BUTTON_PRINT ).toString(),
    2551             :                               Image(  SfxResId( IMG_HELP_TOOLBOX_PRINT ) )
    2552           0 :             );
    2553           0 :             aMenu.SetHelpId( TBI_PRINT, HID_HELP_TOOLBOXITEM_PRINT );
    2554             :             aMenu.InsertItem( TBI_BOOKMARKS,
    2555             :                               SfxResId( STR_HELP_BUTTON_ADDBOOKMARK ).toString(),
    2556             :                               Image(  SfxResId( IMG_HELP_TOOLBOX_BOOKMARKS  ) )
    2557           0 :              );
    2558           0 :             aMenu.SetHelpId( TBI_BOOKMARKS, HID_HELP_TOOLBOXITEM_BOOKMARKS );
    2559             :             aMenu.InsertItem( TBI_SEARCHDIALOG,
    2560             :                               SfxResId( STR_HELP_BUTTON_SEARCHDIALOG ).toString(),
    2561             :                               Image(  SfxResId( IMG_HELP_TOOLBOX_SEARCHDIALOG ) )
    2562           0 :             );
    2563           0 :             aMenu.SetHelpId( TBI_SEARCHDIALOG, HID_HELP_TOOLBOXITEM_SEARCHDIALOG );
    2564           0 :             aMenu.InsertSeparator();
    2565           0 :             aMenu.InsertItem( TBI_SELECTIONMODE, SfxResId( STR_HELP_MENU_TEXT_SELECTION_MODE ).toString() );
    2566           0 :             aMenu.SetHelpId( TBI_SELECTIONMODE, HID_HELP_TEXT_SELECTION_MODE );
    2567           0 :             URL aURL;
    2568           0 :             aURL.Complete = ".uno:SelectTextMode";
    2569           0 :             PARSE_URL( aURL );
    2570           0 :             Reference < XDispatch > xDisp = xFrame->queryDispatch( aURL, OUString(), 0 );
    2571           0 :             if(xDisp.is())
    2572             :             {
    2573             :                 HelpStatusListener_Impl* pStateListener;
    2574             :                 Reference<XStatusListener>xStateListener = pStateListener =
    2575           0 :                                         new HelpStatusListener_Impl(xDisp, aURL );
    2576           0 :                 FeatureStateEvent rEvent = pStateListener->GetStateEvent();
    2577           0 :                 sal_Bool bCheck = sal_False;
    2578           0 :                 rEvent.State >>= bCheck;
    2579           0 :                 aMenu.CheckItem(TBI_SELECTIONMODE, bCheck);
    2580             :             }
    2581           0 :             aMenu.InsertSeparator();
    2582             :             aMenu.InsertItem( TBI_COPY,
    2583             :                               SfxResId(STR_HELP_MENU_TEXT_COPY).toString(),
    2584             :                               Image(  SfxResId( IMG_HELP_TOOLBOX_COPY   ) )
    2585           0 :                 );
    2586           0 :             aMenu.SetHelpId( TBI_COPY, ".uno:Copy" );
    2587           0 :             aMenu.EnableItem( TBI_COPY, HasSelection() );
    2588             : 
    2589           0 :             if ( bIsDebug )
    2590             :             {
    2591           0 :                 aMenu.InsertSeparator();
    2592           0 :                 aMenu.InsertItem( TBI_SOURCEVIEW, SfxResId(STR_HELP_BUTTON_SOURCEVIEW).toString() );
    2593             :             }
    2594             : 
    2595           0 :             if( SvtMenuOptions().IsEntryHidingEnabled() == sal_False )
    2596           0 :                 aMenu.SetMenuFlags( aMenu.GetMenuFlags() | MENU_FLAG_HIDEDISABLEDENTRIES );
    2597             : 
    2598           0 :             sal_uInt16 nId = aMenu.Execute( this, aPos );
    2599           0 :             pHelpWin->DoAction( nId );
    2600           0 :             nDone = 1;
    2601             :         }
    2602             :     }
    2603           0 :     else if ( EVENT_KEYINPUT == nType && rNEvt.GetKeyEvent() )
    2604             :     {
    2605           0 :          const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
    2606           0 :          const KeyCode& rKeyCode = pKEvt->GetKeyCode();
    2607           0 :         sal_uInt16 nKeyGroup = rKeyCode.GetGroup();
    2608           0 :         sal_uInt16 nKey = rKeyCode.GetCode();
    2609           0 :         if ( KEYGROUP_ALPHA == nKeyGroup &&  !isHandledKey( rKeyCode ) )
    2610             :         {
    2611             :             // do nothing disables the writer accelerators
    2612           0 :             nDone = 1;
    2613             :          }
    2614           0 :         else if ( rKeyCode.IsMod1() && ( KEY_F4 == nKey || KEY_W == nKey ) )
    2615             :         {
    2616             :             // <CTRL><F4> or <CTRL><W> -> close top frame
    2617           0 :             pHelpWin->CloseWindow();
    2618           0 :             nDone = 1;
    2619             :         }
    2620           0 :         else if ( KEY_TAB == nKey && aOnStartupCB.HasChildPathFocus() )
    2621             :         {
    2622           0 :             aToolBox.GrabFocus();
    2623           0 :             nDone = 1;
    2624             :         }
    2625             :     }
    2626             : 
    2627           0 :     return nDone ? nDone : Window::PreNotify( rNEvt );
    2628             : }
    2629             : 
    2630             : // -----------------------------------------------------------------------
    2631             : 
    2632           0 : void SfxHelpTextWindow_Impl::GetFocus()
    2633             : {
    2634           0 :     if ( !bIsInClose )
    2635             :     {
    2636             :         try
    2637             :         {
    2638           0 :             if( xFrame.is() )
    2639             :             {
    2640           0 :                 Reference< ::com::sun::star::awt::XWindow > xWindow = xFrame->getComponentWindow();
    2641           0 :                 if( xWindow.is() )
    2642           0 :                     xWindow->setFocus();
    2643             :             }
    2644             :         }
    2645           0 :         catch( Exception& )
    2646             :         {
    2647             :             SAL_WARN( "sfx2.appl", "SfxHelpTextWindow_Impl::GetFocus(): unexpected exception" );
    2648             :         }
    2649             :     }
    2650           0 : }
    2651             : 
    2652             : // -----------------------------------------------------------------------
    2653             : 
    2654           0 : void SfxHelpTextWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
    2655             : {
    2656           0 :     Window::DataChanged( rDCEvt );
    2657             : 
    2658           0 :     if ( ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) ||
    2659           0 :            ( rDCEvt.GetType() == DATACHANGED_DISPLAY ) ) &&
    2660           0 :          ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
    2661             :     {
    2662           0 :         SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFaceColor() ) );
    2663           0 :         InitToolBoxImages();
    2664             :     }
    2665           0 : }
    2666             : 
    2667             : // -----------------------------------------------------------------------
    2668             : 
    2669           0 : void SfxHelpTextWindow_Impl::ToggleIndex( sal_Bool bOn )
    2670             : {
    2671           0 :     bIsIndexOn = bOn;
    2672           0 :     if ( bIsIndexOn )
    2673             :     {
    2674           0 :         aToolBox.SetItemImage( TBI_INDEX, aIndexOffImage );
    2675           0 :         aToolBox.SetItemText( TBI_INDEX, aIndexOffText );
    2676             :     }
    2677             :     else
    2678             :     {
    2679           0 :         aToolBox.SetItemImage( TBI_INDEX, aIndexOnImage );
    2680           0 :         aToolBox.SetItemText( TBI_INDEX, aIndexOnText );
    2681             :     }
    2682           0 : }
    2683             : 
    2684             : // -----------------------------------------------------------------------
    2685             : 
    2686           0 : void SfxHelpTextWindow_Impl::SelectSearchText( const String& rSearchText, sal_Bool _bIsFullWordSearch )
    2687             : {
    2688           0 :     aSearchText = rSearchText;
    2689           0 :     bIsFullWordSearch = _bIsFullWordSearch;
    2690           0 :     aSelectTimer.Start();
    2691           0 : }
    2692             : 
    2693             : // -----------------------------------------------------------------------
    2694             : 
    2695           0 : void SfxHelpTextWindow_Impl::SetPageStyleHeaderOff() const
    2696             : {
    2697             : #ifdef DBG_UTIL
    2698             :     sal_Bool bSetOff = sal_False;
    2699             : #endif
    2700             :     // set off the pagestyle header to prevent print output of the help URL
    2701             :     try
    2702             :     {
    2703           0 :         Reference < XController > xController = xFrame->getController();
    2704           0 :         Reference < XSelectionSupplier > xSelSup( xController, UNO_QUERY );
    2705           0 :         if ( xSelSup.is() )
    2706             :         {
    2707           0 :             Reference < XIndexAccess > xSelection;
    2708           0 :             if ( xSelSup->getSelection() >>= xSelection )
    2709             :             {
    2710           0 :                 Reference < XTextRange > xRange;
    2711           0 :                 if ( xSelection->getByIndex(0) >>= xRange )
    2712             :                 {
    2713           0 :                     Reference < XText > xText = xRange->getText();
    2714           0 :                     Reference < XPropertySet > xProps( xText->createTextCursorByRange( xRange ), UNO_QUERY );
    2715           0 :                     OUString sStyleName;
    2716           0 :                     if ( xProps->getPropertyValue( "PageStyleName" ) >>= sStyleName )
    2717             :                     {
    2718           0 :                         Reference < XStyleFamiliesSupplier > xStyles( xController->getModel(), UNO_QUERY );
    2719           0 :                         Reference < XNameContainer > xContainer;
    2720           0 :                         if ( xStyles->getStyleFamilies()->getByName( "PageStyles" )
    2721           0 :                              >>= xContainer )
    2722             :                         {
    2723           0 :                             Reference < XStyle > xStyle;
    2724           0 :                             if ( xContainer->getByName( sStyleName ) >>= xStyle )
    2725             :                             {
    2726           0 :                                 Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
    2727           0 :                                 xPropSet->setPropertyValue( "HeaderIsOn",
    2728           0 :                                                             makeAny( sal_Bool( sal_False ) ) );
    2729             : 
    2730           0 :                                 Reference< XModifiable > xReset(xStyles, UNO_QUERY);
    2731           0 :                                 xReset->setModified(sal_False);
    2732             : #ifdef DBG_UTIL
    2733             :                                 bSetOff = sal_True;
    2734             : #endif
    2735           0 :                             }
    2736           0 :                         }
    2737           0 :                     }
    2738           0 :                 }
    2739           0 :             }
    2740           0 :         }
    2741             :     }
    2742           0 :     catch( Exception& )
    2743             :     {
    2744             :         SAL_WARN( "sfx2.appl", "SfxHelpTextWindow_Impl::SetPageStyleHeaderOff(): unexpected exception" );
    2745             :     }
    2746             : 
    2747             : #ifdef DBG_UTIL
    2748             :     if ( !bSetOff )
    2749             :     {
    2750             :         SAL_WARN( "sfx2.appl", "SfxHelpTextWindow_Impl::SetPageStyleHeaderOff(): set off failed" );
    2751             :     }
    2752             : #endif
    2753           0 : }
    2754             : 
    2755             : // -----------------------------------------------------------------------
    2756             : 
    2757           0 : void SfxHelpTextWindow_Impl::CloseFrame()
    2758             : {
    2759           0 :     bIsInClose = sal_True;
    2760             :     try
    2761             :     {
    2762           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > xCloseable  ( xFrame, ::com::sun::star::uno::UNO_QUERY );
    2763           0 :         if (xCloseable.is())
    2764           0 :             xCloseable->close(sal_True);
    2765             :     }
    2766           0 :     catch( ::com::sun::star::util::CloseVetoException& )
    2767             :     {
    2768             :     }
    2769           0 : }
    2770             : 
    2771             : // -----------------------------------------------------------------------
    2772             : 
    2773           0 : void SfxHelpTextWindow_Impl::DoSearch()
    2774             : {
    2775           0 :     if ( !pSrchDlg )
    2776             :     {
    2777             :         // create the search dialog
    2778           0 :         pSrchDlg = new sfx2::SearchDialog( pTextWin, "HelpSearchDialog" );
    2779             :         // set handler
    2780           0 :         pSrchDlg->SetFindHdl( LINK( this, SfxHelpTextWindow_Impl, FindHdl ) );
    2781           0 :         pSrchDlg->SetCloseHdl( LINK( this, SfxHelpTextWindow_Impl, CloseHdl ) );
    2782             :         // get selected text of the help page to set it as the search text
    2783           0 :         Reference< XTextRange > xCursor = getCursor();
    2784           0 :         if ( xCursor.is() )
    2785             :         {
    2786           0 :             String sText = xCursor->getString();
    2787           0 :             if ( sText.Len() > 0 )
    2788           0 :                 pSrchDlg->SetSearchText( sText );
    2789             :         }
    2790           0 :         pSrchDlg->Show();
    2791             :     }
    2792           0 : }
    2793             : 
    2794             : // class SfxHelpWindow_Impl ----------------------------------------------
    2795             : 
    2796           0 : void SfxHelpWindow_Impl::Resize()
    2797             : {
    2798           0 :     SplitWindow::Resize();
    2799           0 :     InitSizes();
    2800           0 : }
    2801             : 
    2802             : // -----------------------------------------------------------------------
    2803             : 
    2804           0 : void SfxHelpWindow_Impl::Split()
    2805             : {
    2806             :     static long nMinSplitSize = 5;
    2807           0 :     static long nMaxSplitSize = 99 - nMinSplitSize;
    2808             : 
    2809           0 :     SplitWindow::Split();
    2810             : 
    2811           0 :     nIndexSize = GetItemSize( INDEXWIN_ID );
    2812           0 :     nTextSize = GetItemSize( TEXTWIN_ID );
    2813             : 
    2814           0 :     sal_Bool        bMod = sal_False;
    2815           0 :     if( nIndexSize < nMinSplitSize )
    2816             :     {
    2817           0 :         nIndexSize = nMinSplitSize;
    2818           0 :         nTextSize = nMaxSplitSize;
    2819             : 
    2820           0 :         bMod = sal_True;
    2821             :     }
    2822           0 :     else if( nTextSize < nMinSplitSize )
    2823             :     {
    2824           0 :         nTextSize = nMinSplitSize;
    2825           0 :         nIndexSize = nMaxSplitSize;
    2826             : 
    2827           0 :         bMod = sal_True;
    2828             :     }
    2829             :     else
    2830           0 :         bMod = sal_False;
    2831             : 
    2832           0 :     if( bMod )
    2833             :     {
    2834           0 :         SetItemSize( INDEXWIN_ID, nIndexSize );
    2835           0 :         SetItemSize( TEXTWIN_ID, nTextSize );
    2836             :     }
    2837             : 
    2838           0 :     InitSizes();
    2839           0 : }
    2840             : 
    2841             : // -----------------------------------------------------------------------
    2842             : 
    2843           0 : void SfxHelpWindow_Impl::GetFocus()
    2844             : {
    2845           0 :     pTextWin->GrabFocus();
    2846           0 : }
    2847             : 
    2848             : // -----------------------------------------------------------------------
    2849             : 
    2850           0 : void SfxHelpWindow_Impl::MakeLayout()
    2851             : {
    2852           0 :     if ( nHeight > 0 && xWindow.is() )
    2853             :     {
    2854           0 :            Window* pScreenWin = VCLUnoHelper::GetWindow( xWindow );
    2855             : 
    2856             :         /* #i55528#
    2857             :             Hide() / Show() will produce starnge effects.
    2858             :             The returned size (used later to be written back into the configuration)
    2859             :             isnt the right after a resize during the window is hidden.
    2860             :             If this resize is done if the window is visible evyrthing works as aspected.
    2861             :             Some VCL-patches could not solve this problem so I've established the
    2862             :             workaround: resize the help window if it's visible .-)
    2863             :         */
    2864             : 
    2865           0 :         ::com::sun::star::awt::Rectangle aRect = xWindow->getPosSize();
    2866           0 :         sal_Int32 nOldWidth = bIndex ? nCollapseWidth : nExpandWidth;
    2867           0 :         sal_Int32 nWidth = bIndex ? nExpandWidth : nCollapseWidth;
    2868           0 :         xWindow->setPosSize( aRect.X, aRect.Y, nWidth, nHeight, ::com::sun::star::awt::PosSize::SIZE );
    2869             : 
    2870           0 :         if ( aRect.Width > 0 && aRect.Height > 0 )
    2871             :         {
    2872           0 :             Rectangle aScreenRect = pScreenWin->GetClientWindowExtentsRelative( NULL );
    2873           0 :             Point aNewPos = aScreenRect.TopLeft();
    2874           0 :             sal_Int32 nDiffWidth = nOldWidth - nWidth;
    2875           0 :             aNewPos.X() += nDiffWidth;
    2876           0 :             pScreenWin->SetPosPixel( aNewPos );
    2877             :         }
    2878           0 :         else if ( aWinPos.X() > 0 && aWinPos.Y() > 0 )
    2879           0 :             pScreenWin->SetPosPixel( aWinPos );
    2880             :     }
    2881             : 
    2882           0 :     Clear();
    2883             : 
    2884           0 :     if ( bIndex )
    2885             :     {
    2886           0 :         pIndexWin->Show();
    2887           0 :         InsertItem( COLSET_ID, 100, SPLITWINDOW_APPEND, SPLITSET_ID, SWIB_PERCENTSIZE | SWIB_COLSET );
    2888           0 :         InsertItem( INDEXWIN_ID, pIndexWin, nIndexSize, SPLITWINDOW_APPEND, COLSET_ID, SWIB_PERCENTSIZE );
    2889           0 :         InsertItem( TEXTWIN_ID, pTextWin, nTextSize, SPLITWINDOW_APPEND, COLSET_ID, SWIB_PERCENTSIZE );
    2890             :     }
    2891             :     else
    2892             :     {
    2893           0 :         pIndexWin->Hide();
    2894           0 :         InsertItem( COLSET_ID, 100, SPLITWINDOW_APPEND, SPLITSET_ID, SWIB_PERCENTSIZE | SWIB_COLSET );
    2895           0 :         InsertItem( TEXTWIN_ID, pTextWin, 100, SPLITWINDOW_APPEND, 1, SWIB_PERCENTSIZE );
    2896             :     }
    2897           0 : }
    2898             : 
    2899             : // -----------------------------------------------------------------------
    2900             : 
    2901           0 : void SfxHelpWindow_Impl::InitSizes()
    2902             : {
    2903           0 :     if ( xWindow.is() )
    2904             :     {
    2905           0 :         ::com::sun::star::awt::Rectangle aRect = xWindow->getPosSize();
    2906           0 :         nHeight = aRect.Height;
    2907             : 
    2908           0 :         if ( bIndex )
    2909             :         {
    2910           0 :             nExpandWidth = aRect.Width;
    2911           0 :             nCollapseWidth = nExpandWidth * nTextSize / 100;
    2912             :         }
    2913             :         else
    2914             :         {
    2915           0 :             nCollapseWidth = aRect.Width;
    2916           0 :             nExpandWidth = nCollapseWidth * 100 / nTextSize;
    2917             :         }
    2918             :     }
    2919           0 : }
    2920             : 
    2921             : // -----------------------------------------------------------------------
    2922             : 
    2923           0 : void SfxHelpWindow_Impl::LoadConfig()
    2924             : {
    2925           0 :      SvtViewOptions aViewOpt( E_WINDOW, CONFIGNAME_HELPWIN );
    2926           0 :     if ( aViewOpt.Exists() )
    2927             :     {
    2928           0 :         bIndex = aViewOpt.IsVisible();
    2929           0 :         String aUserData;
    2930           0 :         Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
    2931           0 :         OUString aTemp;
    2932           0 :         if ( aUserItem >>= aTemp )
    2933             :         {
    2934           0 :             aUserData = String( aTemp );
    2935             :             DBG_ASSERT( comphelper::string::getTokenCount(aUserData, ';') == 6, "invalid user data" );
    2936           0 :             sal_Int32 nIdx = 0;
    2937           0 :             nIndexSize = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
    2938           0 :             nTextSize = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
    2939           0 :             sal_Int32 nWidth = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
    2940           0 :             nHeight = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
    2941           0 :             aWinPos.X() = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
    2942           0 :             aWinPos.Y() = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
    2943           0 :             if ( bIndex )
    2944             :             {
    2945           0 :                 nExpandWidth = nWidth;
    2946           0 :                 nCollapseWidth = nExpandWidth * nTextSize / 100;
    2947             :             }
    2948             :             else
    2949             :             {
    2950           0 :                 nCollapseWidth = nWidth;
    2951           0 :                 nExpandWidth = nCollapseWidth * 100 / nTextSize;
    2952             :             }
    2953             :         }
    2954             : 
    2955           0 :         pTextWin->ToggleIndex( bIndex );
    2956           0 :     }
    2957           0 : }
    2958             : 
    2959             : // -----------------------------------------------------------------------
    2960             : 
    2961           0 : void SfxHelpWindow_Impl::SaveConfig()
    2962             : {
    2963           0 :     SvtViewOptions aViewOpt( E_WINDOW, CONFIGNAME_HELPWIN );
    2964           0 :     sal_Int32 nW = 0, nH = 0;
    2965             : 
    2966           0 :     if ( xWindow.is() )
    2967             :     {
    2968           0 :         ::com::sun::star::awt::Rectangle aRect = xWindow->getPosSize();
    2969           0 :         nW = aRect.Width;
    2970           0 :         nH = aRect.Height;
    2971             :     }
    2972             : 
    2973           0 :     aViewOpt.SetVisible( bIndex );
    2974           0 :     String aUserData = OUString::number( nIndexSize );
    2975           0 :     aUserData += ';';
    2976           0 :     aUserData += OUString::number( nTextSize );
    2977           0 :     aUserData += ';';
    2978           0 :     aUserData += OUString::number( nW );
    2979           0 :     aUserData += ';';
    2980           0 :     aUserData += OUString::number( nH );
    2981             : 
    2982           0 :        Window* pScreenWin = VCLUnoHelper::GetWindow( xWindow );
    2983           0 :     aWinPos = pScreenWin->GetWindowExtentsRelative( NULL ).TopLeft();
    2984           0 :     aUserData += ';';
    2985           0 :     aUserData += OUString::number( aWinPos.X() );
    2986           0 :     aUserData += ';';
    2987           0 :     aUserData += OUString::number( aWinPos.Y() );
    2988             : 
    2989           0 :     aViewOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aUserData ) ) );
    2990           0 : }
    2991             : 
    2992             : // -----------------------------------------------------------------------
    2993             : 
    2994           0 : void SfxHelpWindow_Impl::ShowStartPage()
    2995             : {
    2996             :     OUString sHelpURL = SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(),
    2997             :                                                                 "/start",
    2998             :                                                                 OUString(),
    2999           0 :                                                                 sal_True);
    3000           0 :     loadHelpContent(sHelpURL);
    3001           0 : }
    3002             : 
    3003             : // -----------------------------------------------------------------------
    3004             : 
    3005           0 : IMPL_LINK( SfxHelpWindow_Impl, SelectHdl, ToolBox* , pToolBox )
    3006             : {
    3007           0 :     if ( pToolBox )
    3008             :     {
    3009           0 :         bGrabFocusToToolBox = pToolBox->HasChildPathFocus();
    3010           0 :         DoAction( pToolBox->GetCurItemId() );
    3011             :     }
    3012             : 
    3013           0 :     return 1;
    3014             : }
    3015             : 
    3016             : //-------------------------------------------------------------------------
    3017             : 
    3018           0 : IMPL_LINK_NOARG(SfxHelpWindow_Impl, OpenHdl)
    3019             : {
    3020           0 :     pIndexWin->SelectExecutableEntry();
    3021           0 :     String aEntry = pIndexWin->GetSelectEntry();
    3022             : 
    3023           0 :     if ( aEntry.Len() < 1 )
    3024           0 :         return 0;
    3025             : 
    3026           0 :     OUString sHelpURL;
    3027             : 
    3028           0 :     bool bComplete = OUString(aEntry).toAsciiLowerCase().match(OUString("vnd.sun.star.help"),0);
    3029             : 
    3030           0 :     if (bComplete)
    3031           0 :         sHelpURL = OUString(aEntry);
    3032             :     else
    3033             :     {
    3034           0 :         String aId;
    3035           0 :         String aAnchor = OUString('#');
    3036           0 :         if ( comphelper::string::getTokenCount(aEntry, '#') == 2 )
    3037             :         {
    3038           0 :             aId = aEntry.GetToken( 0, '#' );
    3039           0 :             aAnchor += aEntry.GetToken( 1, '#' );
    3040             :         }
    3041             :         else
    3042           0 :             aId = aEntry;
    3043             : 
    3044           0 :         aEntry  = '/';
    3045           0 :         aEntry += aId;
    3046             : 
    3047           0 :         sHelpURL = SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(),
    3048             :                                                     aEntry,
    3049             :                                                     aAnchor,
    3050           0 :                                                     sal_True);
    3051             :     }
    3052             : 
    3053           0 :     loadHelpContent(sHelpURL);
    3054             : 
    3055           0 :     return 0;
    3056             : }
    3057             : 
    3058             : //-------------------------------------------------------------------------
    3059             : 
    3060           0 : IMPL_LINK( SfxHelpWindow_Impl, SelectFactoryHdl, SfxHelpIndexWindow_Impl* , pWin )
    3061             : {
    3062           0 :     if ( sTitle.isEmpty() )
    3063           0 :         sTitle = GetParent()->GetText();
    3064             : 
    3065           0 :     OUString aNewTitle = sTitle + " - " + pIndexWin->GetActiveFactoryTitle();
    3066             : 
    3067           0 :     Reference< XTitle > xTitle(xFrame, UNO_QUERY);
    3068           0 :     if (xTitle.is ())
    3069           0 :         xTitle->setTitle (aNewTitle);
    3070             : 
    3071           0 :     if ( pWin )
    3072           0 :         ShowStartPage();
    3073           0 :     pIndexWin->ClearSearchPage();
    3074             : 
    3075           0 :     return 0;
    3076             : }
    3077             : 
    3078             : // -----------------------------------------------------------------------
    3079             : 
    3080           0 : IMPL_LINK( SfxHelpWindow_Impl, ChangeHdl, HelpListener_Impl*, pListener )
    3081             : {
    3082           0 :     SetFactory( pListener->GetFactory() );
    3083           0 :     return 0;
    3084             : }
    3085             : 
    3086             : // -----------------------------------------------------------------------
    3087             : 
    3088           0 : void SfxHelpWindow_Impl::openDone(const OUString& sURL    ,
    3089             :                                         sal_Bool         bSuccess)
    3090             : {
    3091           0 :     INetURLObject aObj( sURL );
    3092           0 :     if ( aObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP )
    3093           0 :         SetFactory( aObj.GetHost() );
    3094           0 :     if ( IsWait() )
    3095           0 :         LeaveWait();
    3096           0 :     if ( bGrabFocusToToolBox )
    3097             :     {
    3098           0 :         pTextWin->GetToolBox().GrabFocus();
    3099           0 :         bGrabFocusToToolBox = sal_False;
    3100             :     }
    3101             :     else
    3102           0 :         pIndexWin->GrabFocusBack();
    3103           0 :     if ( bSuccess )
    3104             :     {
    3105             :         // set some view settings: "prevent help tips" and "helpid == 68245"
    3106             :         try
    3107             :         {
    3108           0 :             Reference < XController > xController = pTextWin->getFrame()->getController();
    3109           0 :             if ( xController.is() )
    3110             :             {
    3111           0 :                 Reference < XViewSettingsSupplier > xSettings( xController, UNO_QUERY );
    3112           0 :                 Reference < XPropertySet > xViewProps = xSettings->getViewSettings();
    3113           0 :                 Reference< XPropertySetInfo > xInfo = xViewProps->getPropertySetInfo();
    3114           0 :                 Any aBoolAny = makeAny( sal_Bool( sal_True ) );
    3115           0 :                 xViewProps->setPropertyValue( "ShowContentTips", makeAny( sal_Bool( sal_False ) ) );
    3116           0 :                 xViewProps->setPropertyValue( "ShowGraphics", aBoolAny );
    3117           0 :                 xViewProps->setPropertyValue( "ShowTables", aBoolAny );
    3118           0 :                 xViewProps->setPropertyValue( "HelpURL", makeAny( OUString("HID:SFX2_HID_HELP_ONHELP") ) );
    3119           0 :                 OUString sProperty( "IsExecuteHyperlinks" );
    3120           0 :                 if ( xInfo->hasPropertyByName( sProperty ) )
    3121           0 :                     xViewProps->setPropertyValue( sProperty, aBoolAny );
    3122           0 :                 xController->restoreViewData(pHelpInterceptor->GetViewData());
    3123           0 :             }
    3124             :         }
    3125           0 :         catch( Exception& )
    3126             :         {
    3127             :             OSL_FAIL( "SfxHelpWindow_Impl::OpenDoneHdl(): unexpected exception" );
    3128             :         }
    3129             : 
    3130             :         // When the SearchPage opens the help doc, then select all words, which are equal to its text
    3131           0 :         String sSearchText = comphelper::string::strip(pIndexWin->GetSearchText(), ' ');
    3132           0 :         if ( sSearchText.Len() > 0 )
    3133           0 :             pTextWin->SelectSearchText( sSearchText, pIndexWin->IsFullWordSearch() );
    3134             : 
    3135             :         // no page style header -> this prevents a print output of the URL
    3136           0 :         pTextWin->SetPageStyleHeaderOff();
    3137           0 :     }
    3138           0 : }
    3139             : 
    3140             : // -----------------------------------------------------------------------
    3141             : 
    3142           0 : SfxHelpWindow_Impl::SfxHelpWindow_Impl(
    3143             :     const ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame2 >& rFrame,
    3144             :     Window* pParent, WinBits ) :
    3145             : 
    3146             :     SplitWindow( pParent, WB_3DLOOK | WB_NOSPLITDRAW ),
    3147             : 
    3148             :     xFrame              ( rFrame ),
    3149             :     pIndexWin           ( NULL ),
    3150             :     pTextWin            ( NULL ),
    3151           0 :     pHelpInterceptor    ( new HelpInterceptor_Impl() ),
    3152           0 :     pHelpListener       ( new HelpListener_Impl( pHelpInterceptor ) ),
    3153             :     nExpandWidth        ( 0 ),
    3154             :     nCollapseWidth      ( 0 ),
    3155             :     nHeight             ( 0 ),
    3156             :     nIndexSize          ( 40 ),
    3157             :     nTextSize           ( 60 ),
    3158             :     bIndex              ( sal_True ),
    3159             :     bGrabFocusToToolBox ( sal_False ),
    3160             :     aWinPos             ( 0, 0 ),
    3161           0 :     sTitle              ( pParent->GetText() )
    3162             : {
    3163           0 :     SetHelpId( HID_HELP_WINDOW );
    3164           0 :     SetStyle( GetStyle() | WB_DIALOGCONTROL );
    3165             : 
    3166           0 :     pHelpInterceptor->InitWaiter( this );
    3167           0 :     pIndexWin = new SfxHelpIndexWindow_Impl( this );
    3168           0 :     pIndexWin->SetDoubleClickHdl( LINK( this, SfxHelpWindow_Impl, OpenHdl ) );
    3169           0 :     pIndexWin->SetSelectFactoryHdl( LINK( this, SfxHelpWindow_Impl, SelectFactoryHdl ) );
    3170           0 :     pIndexWin->Show();
    3171           0 :     pTextWin = new SfxHelpTextWindow_Impl( this );
    3172           0 :     Reference < XFrames > xFrames = rFrame->getFrames();
    3173           0 :     xFrames->append( Reference<XFrame>(pTextWin->getFrame(), UNO_QUERY_THROW) );
    3174           0 :     pTextWin->SetSelectHdl( LINK( this, SfxHelpWindow_Impl, SelectHdl ) );
    3175           0 :     pTextWin->Show();
    3176           0 :     pHelpInterceptor->setInterception( Reference<XFrame>(pTextWin->getFrame(), UNO_QUERY_THROW) );
    3177           0 :     pHelpListener->SetChangeHdl( LINK( this, SfxHelpWindow_Impl, ChangeHdl ) );
    3178           0 :     LoadConfig();
    3179           0 : }
    3180             : 
    3181             : // -----------------------------------------------------------------------
    3182             : 
    3183           0 : SfxHelpWindow_Impl::~SfxHelpWindow_Impl()
    3184             : {
    3185           0 :     SaveConfig();
    3186           0 :     Window* pDel = pIndexWin;
    3187           0 :     pIndexWin = NULL;
    3188           0 :     delete pDel;
    3189             : 
    3190           0 :     pTextWin->CloseFrame();
    3191           0 :     delete pTextWin;
    3192           0 : }
    3193             : 
    3194             : // -----------------------------------------------------------------------
    3195             : 
    3196           0 : long SfxHelpWindow_Impl::PreNotify( NotifyEvent& rNEvt )
    3197             : {
    3198           0 :     sal_Bool bHandled = sal_False;
    3199           0 :     if ( rNEvt.GetType() == EVENT_KEYINPUT )
    3200             :     {
    3201             :         // Backward == <ALT><LEFT> or <BACKSPACE> Forward == <ALT><RIGHT>
    3202           0 :          const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
    3203           0 :         sal_uInt16 nKey = rKeyCode.GetCode();
    3204           0 :         if ( ( rKeyCode.IsMod2() && ( KEY_LEFT == nKey || KEY_RIGHT == nKey ) ) ||
    3205           0 :              ( !rKeyCode.GetModifier() && KEY_BACKSPACE == nKey && !pIndexWin->HasFocusOnEdit() ) )
    3206             :         {
    3207           0 :             DoAction( rKeyCode.GetCode() == KEY_RIGHT ? TBI_FORWARD : TBI_BACKWARD );
    3208           0 :             bHandled = sal_True;
    3209             :         }
    3210           0 :         else if ( rKeyCode.IsMod1() && ( KEY_F4 == nKey || KEY_W == nKey ) )
    3211             :         {
    3212             :             // <CTRL><F4> or <CTRL><W> -> close top frame
    3213           0 :             CloseWindow();
    3214           0 :             bHandled = sal_True;
    3215             :         }
    3216             :     }
    3217           0 :     return bHandled ? 1 : Window::PreNotify( rNEvt );
    3218             : }
    3219             : 
    3220             : // -----------------------------------------------------------------------
    3221             : 
    3222           0 : void SfxHelpWindow_Impl::setContainerWindow( Reference < ::com::sun::star::awt::XWindow > xWin )
    3223             : {
    3224           0 :     xWindow = xWin;
    3225           0 :     MakeLayout();
    3226           0 : }
    3227             : 
    3228             : // -----------------------------------------------------------------------
    3229             : 
    3230           0 : void SfxHelpWindow_Impl::SetFactory( const String& rFactory )
    3231             : {
    3232           0 :     pIndexWin->SetFactory( rFactory, sal_True );
    3233           0 : }
    3234             : 
    3235             : // -----------------------------------------------------------------------
    3236             : 
    3237           0 : void SfxHelpWindow_Impl::SetHelpURL( const String& rURL )
    3238             : {
    3239           0 :     INetURLObject aObj( rURL );
    3240           0 :     if ( aObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP )
    3241           0 :         SetFactory( aObj.GetHost() );
    3242           0 : }
    3243             : 
    3244             : // -----------------------------------------------------------------------
    3245             : 
    3246           0 : void SfxHelpWindow_Impl::DoAction( sal_uInt16 nActionId )
    3247             : {
    3248           0 :     switch ( nActionId )
    3249             :     {
    3250             :         case TBI_INDEX :
    3251             :         {
    3252           0 :             bIndex = !bIndex;
    3253           0 :             MakeLayout();
    3254           0 :             pTextWin->ToggleIndex( bIndex );
    3255           0 :             break;
    3256             :         }
    3257             : 
    3258             :         case TBI_START :
    3259             :         {
    3260           0 :             ShowStartPage();
    3261           0 :             break;
    3262             :         }
    3263             : 
    3264             :         case TBI_BACKWARD :
    3265             :         case TBI_FORWARD :
    3266             :         {
    3267           0 :             URL aURL;
    3268           0 :             aURL.Complete = ".uno:Backward";
    3269           0 :             if ( TBI_FORWARD == nActionId )
    3270           0 :                 aURL.Complete = ".uno:Forward";
    3271           0 :             PARSE_URL( aURL );
    3272           0 :             pHelpInterceptor->dispatch( aURL, Sequence < PropertyValue >() );
    3273           0 :             break;
    3274             :         }
    3275             : 
    3276             :         case TBI_SEARCHDIALOG :
    3277             :         {
    3278           0 :             pTextWin->DoSearch();
    3279           0 :             break;
    3280             :         }
    3281             : 
    3282             :         case TBI_PRINT :
    3283             :         case TBI_SOURCEVIEW :
    3284             :         case TBI_COPY :
    3285             :         case TBI_SELECTIONMODE:
    3286             :         {
    3287           0 :             Reference < XDispatchProvider > xProv( pTextWin->getFrame(), UNO_QUERY );
    3288           0 :             if ( xProv.is() )
    3289             :             {
    3290           0 :                 URL aURL;
    3291           0 :                 if ( TBI_PRINT == nActionId )
    3292           0 :                     aURL.Complete = ".uno:Print";
    3293           0 :                 else if ( TBI_SOURCEVIEW == nActionId )
    3294           0 :                     aURL.Complete = ".uno:SourceView";
    3295           0 :                 else if ( TBI_COPY == nActionId )
    3296           0 :                     aURL.Complete = ".uno:Copy";
    3297           0 :                 else if ( TBI_SELECTIONMODE == nActionId )
    3298           0 :                     aURL.Complete = ".uno:SelectTextMode";
    3299             :                 else
    3300           0 :                     aURL.Complete = ".uno:SearchDialog";
    3301           0 :                 PARSE_URL( aURL );
    3302           0 :                 Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, String(), 0 );
    3303           0 :                 if ( xDisp.is() )
    3304           0 :                     xDisp->dispatch( aURL, Sequence < PropertyValue >() );
    3305             :             }
    3306           0 :             break;
    3307             :         }
    3308             : 
    3309             :         case TBI_BOOKMARKS :
    3310             :         {
    3311           0 :             String aURL = pHelpInterceptor->GetCurrentURL();
    3312           0 :             if ( aURL.Len() > 0 )
    3313             :             {
    3314             :                 try
    3315             :                 {
    3316           0 :                     Content aCnt( aURL, Reference< ::com::sun::star::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
    3317           0 :                     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo = aCnt.getProperties();
    3318           0 :                     if ( xInfo->hasPropertyByName( PROPERTY_TITLE ) )
    3319             :                     {
    3320           0 :                         ::com::sun::star::uno::Any aAny = aCnt.getPropertyValue( PROPERTY_TITLE );
    3321           0 :                         OUString aValue;
    3322           0 :                         if ( aAny >>= aValue )
    3323             :                         {
    3324           0 :                             String aTitle( aValue );
    3325           0 :                             SfxAddHelpBookmarkDialog_Impl aDlg( this, sal_False );
    3326           0 :                             aDlg.SetTitle( aTitle );
    3327           0 :                             if ( aDlg.Execute() == RET_OK )
    3328             :                             {
    3329           0 :                                 aTitle = aDlg.GetTitle();
    3330           0 :                                 pIndexWin->AddBookmarks( aTitle, aURL );
    3331           0 :                             }
    3332           0 :                         }
    3333           0 :                     }
    3334             :                 }
    3335           0 :                 catch( Exception& )
    3336             :                 {
    3337             :                     OSL_FAIL( "SfxHelpWindow_Impl::DoAction(): unexpected exception" );
    3338             :                 }
    3339             :             }
    3340           0 :             break;
    3341             :         }
    3342             :     }
    3343           0 : }
    3344             : 
    3345             : // -----------------------------------------------------------------------
    3346             : 
    3347           0 : void SfxHelpWindow_Impl::CloseWindow()
    3348             : {
    3349             :     try
    3350             :     {
    3351             :         // search for top frame
    3352           0 :         Reference< XFramesSupplier > xCreator = getTextFrame()->getCreator();
    3353           0 :         while ( xCreator.is() && !xCreator->isTop() )
    3354             :         {
    3355           0 :             xCreator = xCreator->getCreator();
    3356             :         }
    3357             : 
    3358             :         // when found, close it
    3359           0 :         if ( xCreator.is() && xCreator->isTop() )
    3360             :         {
    3361           0 :             Reference < XCloseable > xCloser( xCreator, UNO_QUERY );
    3362           0 :             if ( xCloser.is() )
    3363           0 :                 xCloser->close( sal_False );
    3364           0 :         }
    3365             :     }
    3366           0 :     catch( Exception& )
    3367             :     {
    3368             :         SAL_WARN( "sfx2.appl", "SfxHelpWindow_Impl::CloseWindow(): caught an exception" );
    3369             :     }
    3370           0 : }
    3371             : 
    3372             : // -----------------------------------------------------------------------
    3373             : 
    3374           0 : void SfxHelpWindow_Impl::UpdateToolbox()
    3375             : {
    3376           0 :     pTextWin->GetToolBox().EnableItem( TBI_BACKWARD, pHelpInterceptor->HasHistoryPred() );
    3377           0 :     pTextWin->GetToolBox().EnableItem( TBI_FORWARD, pHelpInterceptor->HasHistorySucc() );
    3378           0 : }
    3379             : 
    3380             : // -----------------------------------------------------------------------
    3381             : 
    3382           0 : sal_Bool SfxHelpWindow_Impl::HasHistoryPredecessor() const
    3383             : {
    3384           0 :     return pHelpInterceptor->HasHistoryPred();
    3385             : }
    3386             : 
    3387             : // -----------------------------------------------------------------------
    3388             : 
    3389           0 : sal_Bool SfxHelpWindow_Impl::HasHistorySuccessor() const
    3390             : {
    3391           0 :     return pHelpInterceptor->HasHistorySucc();
    3392             : }
    3393             : 
    3394             : // class SfxAddHelpBookmarkDialog_Impl -----------------------------------
    3395             : 
    3396           0 : SfxAddHelpBookmarkDialog_Impl::SfxAddHelpBookmarkDialog_Impl( Window* pParent, sal_Bool bRename ) :
    3397             : 
    3398             :     ModalDialog( pParent, SfxResId( DLG_HELP_ADDBOOKMARK ) ),
    3399             : 
    3400             :     aTitleFT    ( this, SfxResId( FT_BOOKMARK_TITLE ) ),
    3401             :     aTitleED    ( this, SfxResId( ED_BOOKMARK_TITLE ) ),
    3402             :     aOKBtn      ( this, SfxResId( PB_BOOKMARK_OK ) ),
    3403             :     aEscBtn     ( this, SfxResId( PB_BOOKMARK_CANCEL ) ),
    3404           0 :     aHelpBtn    ( this, SfxResId( PB_BOOKMARK_HELP ) )
    3405             : 
    3406             : {
    3407           0 :     if ( bRename )
    3408           0 :         SetText( SfxResId(STR_BOOKMARK_RENAME).toString() );
    3409             : 
    3410           0 :     FreeResource();
    3411           0 : }
    3412             : 
    3413             : // -----------------------------------------------------------------------
    3414             : 
    3415           0 : SfxAddHelpBookmarkDialog_Impl::~SfxAddHelpBookmarkDialog_Impl()
    3416             : {
    3417           0 : }
    3418             : 
    3419             : // -----------------------------------------------------------------------
    3420             : 
    3421           0 : void SfxAddHelpBookmarkDialog_Impl::SetTitle( const String& rTitle )
    3422             : {
    3423           0 :     aTitleED.SetText( rTitle );
    3424           0 :     aTitleED.SetSelection( Selection( 0, rTitle.Len() ) );
    3425         408 : }
    3426             : 
    3427             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10