LCOV - code coverage report
Current view: top level - sfx2/source/appl - newhelp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1709 0.0 %
Date: 2012-08-25 Functions: 0 180 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 4082 0.0 %

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

Generated by: LCOV version 1.10