LCOV - code coverage report
Current view: top level - cui/source/options - optpath.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 409 0.0 %
Date: 2012-08-25 Functions: 0 30 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1048 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svx/svxdlg.hxx>
      30                 :            : #include <tools/shl.hxx>
      31                 :            : #include <vcl/msgbox.hxx>
      32                 :            : #include <sfx2/filedlghelper.hxx>
      33                 :            : #include <sfx2/app.hxx>
      34                 :            : #include <svl/aeitem.hxx>
      35                 :            : #include <svtools/svtabbx.hxx>
      36                 :            : #include <tools/urlobj.hxx>
      37                 :            : #include <vcl/svapp.hxx>
      38                 :            : #include <unotools/defaultoptions.hxx>
      39                 :            : #include <unotools/localfilehelper.hxx>
      40                 :            : #include <unotools/pathoptions.hxx>
      41                 :            : #include <unotools/moduleoptions.hxx>
      42                 :            : #include <unotools/viewoptions.hxx>
      43                 :            : 
      44                 :            : #define _SVX_OPTPATH_CXX
      45                 :            : 
      46                 :            : #include "optpath.hxx"
      47                 :            : #include <dialmgr.hxx>
      48                 :            : #include "optpath.hrc"
      49                 :            : #include <cuires.hrc>
      50                 :            : #include "helpid.hrc"
      51                 :            : #include <comphelper/configuration.hxx>
      52                 :            : #include <comphelper/processfactory.hxx>
      53                 :            : #include <comphelper/string.hxx>
      54                 :            : #include <com/sun/star/uno/Exception.hpp>
      55                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      56                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      57                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      58                 :            : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      59                 :            : #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
      60                 :            : #include <officecfg/Office/Common.hxx>
      61                 :            : #include "optHeaderTabListbox.hxx"
      62                 :            : #include <readonlyimage.hxx>
      63                 :            : #include <vcl/help.hxx>
      64                 :            : 
      65                 :            : using namespace ::com::sun::star::beans;
      66                 :            : using namespace ::com::sun::star::lang;
      67                 :            : using namespace ::com::sun::star::ui::dialogs;
      68                 :            : using namespace ::com::sun::star::uno;
      69                 :            : using namespace svx;
      70                 :            : 
      71                 :            : // define ----------------------------------------------------------------
      72                 :            : 
      73                 :            : #define TAB_WIDTH1      80
      74                 :            : #define TAB_WIDTH_MIN   10
      75                 :            : #define TAB_WIDTH2      1000
      76                 :            : #define ITEMID_TYPE       1
      77                 :            : #define ITEMID_PATH       2
      78                 :            : 
      79                 :            : #define POSTFIX_INTERNAL    rtl::OUString("_internal")
      80                 :            : #define POSTFIX_USER        rtl::OUString("_user")
      81                 :            : #define POSTFIX_WRITABLE    rtl::OUString("_writable")
      82                 :            : #define VAR_ONE             rtl::OUString("%1")
      83                 :            : #define IODLG_CONFIGNAME    rtl::OUString("FilePicker_Save")
      84                 :            : 
      85                 :            : // struct OptPath_Impl ---------------------------------------------------
      86                 :            : 
      87 [ #  # ][ #  # ]:          0 : struct OptPath_Impl
      88                 :            : {
      89                 :            :     SvtDefaultOptions           m_aDefOpt;
      90                 :            :     Image                       m_aLockImage;
      91                 :            :     String                      m_sMultiPathDlg;
      92                 :            :     Reference< XPropertySet >   m_xPathSettings;
      93                 :            : 
      94                 :          0 :     OptPath_Impl(const ResId& rLockRes)
      95 [ #  # ][ #  # ]:          0 :         : m_aLockImage(rLockRes)
      96                 :            :     {
      97                 :          0 :     }
      98                 :            : };
      99                 :            : 
     100                 :            : // struct PathUserData_Impl ----------------------------------------------
     101                 :            : 
     102         [ #  # ]:          0 : struct PathUserData_Impl
     103                 :            : {
     104                 :            :     sal_uInt16          nRealId;
     105                 :            :     SfxItemState    eState;
     106                 :            :     String          sUserPath;
     107                 :            :     String          sWritablePath;
     108                 :            : 
     109                 :          0 :     PathUserData_Impl( sal_uInt16 nId ) :
     110         [ #  # ]:          0 :         nRealId( nId ), eState( SFX_ITEM_UNKNOWN ) {}
     111                 :            : };
     112                 :            : 
     113                 :            : struct Handle2CfgNameMapping_Impl
     114                 :            : {
     115                 :            :     sal_uInt16      m_nHandle;
     116                 :            :     const char* m_pCfgName;
     117                 :            : };
     118                 :            : 
     119                 :            : static Handle2CfgNameMapping_Impl const Hdl2CfgMap_Impl[] =
     120                 :            : {
     121                 :            :     { SvtPathOptions::PATH_AUTOCORRECT, "AutoCorrect" },
     122                 :            :     { SvtPathOptions::PATH_AUTOTEXT,    "AutoText" },
     123                 :            :     { SvtPathOptions::PATH_BACKUP,      "Backup" },
     124                 :            :     { SvtPathOptions::PATH_GALLERY,     "Gallery" },
     125                 :            :     { SvtPathOptions::PATH_GRAPHIC,     "Graphic" },
     126                 :            :     { SvtPathOptions::PATH_TEMP,        "Temp" },
     127                 :            :     { SvtPathOptions::PATH_TEMPLATE,    "Template" },
     128                 :            :     { SvtPathOptions::PATH_WORK,        "Work" },
     129                 :            : #if OSL_DEBUG_LEVEL > 1
     130                 :            :     { SvtPathOptions::PATH_LINGUISTIC,        "Linguistic" },
     131                 :            :     { SvtPathOptions::PATH_DICTIONARY,        "Dictionary" },
     132                 :            : #endif
     133                 :            :     { USHRT_MAX, NULL }
     134                 :            : };
     135                 :            : 
     136                 :          0 : static String getCfgName_Impl( sal_uInt16 _nHandle )
     137                 :            : {
     138                 :          0 :     String sCfgName;
     139                 :          0 :     sal_uInt16 nIndex = 0;
     140         [ #  # ]:          0 :     while ( Hdl2CfgMap_Impl[ nIndex ].m_nHandle != USHRT_MAX )
     141                 :            :     {
     142         [ #  # ]:          0 :         if ( Hdl2CfgMap_Impl[ nIndex ].m_nHandle == _nHandle )
     143                 :            :         {
     144                 :            :             // config name found
     145         [ #  # ]:          0 :             sCfgName = rtl::OUString::createFromAscii( Hdl2CfgMap_Impl[ nIndex ].m_pCfgName );
     146                 :          0 :             break;
     147                 :            :         }
     148                 :          0 :         ++nIndex;
     149                 :            :     }
     150                 :            : 
     151                 :          0 :     return sCfgName;
     152                 :            : }
     153                 :            : 
     154                 :            : #define MULTIPATH_DELIMITER     ';'
     155                 :            : 
     156                 :          0 : String Convert_Impl( const String& rValue )
     157                 :            : {
     158                 :          0 :     char cDelim = MULTIPATH_DELIMITER;
     159         [ #  # ]:          0 :     sal_uInt16 nCount = comphelper::string::getTokenCount(rValue, cDelim);
     160                 :          0 :     String aReturn;
     161         [ #  # ]:          0 :     for ( sal_uInt16 i=0; i<nCount ; ++i )
     162                 :            :     {
     163         [ #  # ]:          0 :         String aValue = rValue.GetToken( i, cDelim );
     164 [ #  # ][ #  # ]:          0 :         INetURLObject aObj( aValue );
     165         [ #  # ]:          0 :         if ( aObj.GetProtocol() == INET_PROT_FILE )
     166 [ #  # ][ #  # ]:          0 :             aReturn += String(aObj.PathToFileName());
         [ #  # ][ #  # ]
     167 [ #  # ][ #  # ]:          0 :         else if ( ::utl::LocalFileHelper::IsFileContent( aValue ) )
                 [ #  # ]
     168 [ #  # ][ #  # ]:          0 :             aReturn += String(aObj.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ));
         [ #  # ][ #  # ]
     169         [ #  # ]:          0 :         if ( i+1 < nCount)
     170         [ #  # ]:          0 :             aReturn += MULTIPATH_DELIMITER;
     171 [ #  # ][ #  # ]:          0 :     }
     172                 :            : 
     173                 :          0 :     return aReturn;
     174                 :            : }
     175                 :            : 
     176                 :            : // class SvxControlFocusHelper ---------------------------------------------
     177                 :            : 
     178                 :          0 : long SvxControlFocusHelper::Notify( NotifyEvent& rNEvt )
     179                 :            : {
     180                 :          0 :     long nRet = Control::Notify( rNEvt );
     181                 :            : 
     182 [ #  # ][ #  # ]:          0 :     if ( m_pFocusCtrl && rNEvt.GetWindow() != m_pFocusCtrl && rNEvt.GetType() == EVENT_GETFOCUS )
         [ #  # ][ #  # ]
     183                 :          0 :         m_pFocusCtrl->GrabFocus();
     184                 :          0 :     return nRet;
     185                 :            : }
     186                 :            : 
     187                 :            : // functions -------------------------------------------------------------
     188                 :            : 
     189                 :          0 : sal_Bool IsMultiPath_Impl( const sal_uInt16 nIndex )
     190                 :            : {
     191                 :            : #if OSL_DEBUG_LEVEL > 1
     192                 :            :     return ( SvtPathOptions::PATH_AUTOCORRECT == nIndex ||
     193                 :            :              SvtPathOptions::PATH_AUTOTEXT == nIndex ||
     194                 :            :              SvtPathOptions::PATH_BASIC == nIndex ||
     195                 :            :              SvtPathOptions::PATH_GALLERY == nIndex ||
     196                 :            :              SvtPathOptions::PATH_TEMPLATE == nIndex );
     197                 :            : #else
     198                 :            :     return ( SvtPathOptions::PATH_AUTOCORRECT == nIndex ||
     199                 :            :              SvtPathOptions::PATH_AUTOTEXT == nIndex ||
     200                 :            :              SvtPathOptions::PATH_BASIC == nIndex ||
     201                 :            :              SvtPathOptions::PATH_GALLERY == nIndex ||
     202                 :            :              SvtPathOptions::PATH_TEMPLATE == nIndex ||
     203                 :            :              SvtPathOptions::PATH_LINGUISTIC == nIndex ||
     204 [ #  # ][ #  # ]:          0 :              SvtPathOptions::PATH_DICTIONARY == nIndex  );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     205                 :            : #endif
     206                 :            : }
     207                 :            : 
     208                 :            : // class SvxPathTabPage --------------------------------------------------
     209                 :            : 
     210                 :          0 : SvxPathTabPage::SvxPathTabPage( Window* pParent, const SfxItemSet& rSet ) :
     211                 :            : 
     212                 :          0 :     SfxTabPage( pParent, CUI_RES( RID_SFXPAGE_PATH ), rSet ),
     213                 :            : 
     214         [ #  # ]:          0 :     aStdBox         ( this, CUI_RES( GB_STD ) ),
     215         [ #  # ]:          0 :     aTypeText       ( this, CUI_RES( FT_TYPE ) ),
     216         [ #  # ]:          0 :     aPathText       ( this, CUI_RES( FT_PATH ) ),
     217         [ #  # ]:          0 :     aPathCtrl       ( this, CUI_RES( LB_PATH ) ),
     218         [ #  # ]:          0 :     aStandardBtn    ( this, CUI_RES( BTN_STANDARD ) ),
     219         [ #  # ]:          0 :     aPathBtn        ( this, CUI_RES( BTN_PATH ) ),
     220                 :            :     pHeaderBar      ( NULL ),
     221                 :            :     pPathBox        ( NULL ),
     222 [ #  # ][ #  # ]:          0 :     pImpl           ( new OptPath_Impl( CUI_RES(IMG_LOCK) ) ),
     223 [ #  # ][ #  # ]:          0 :     xDialogListener ( new ::svt::DialogClosedListener() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     224                 :            : 
     225                 :            : {
     226 [ #  # ][ #  # ]:          0 :     pImpl->m_sMultiPathDlg = String( CUI_RES( STR_MULTIPATHDLG ) );
         [ #  # ][ #  # ]
     227         [ #  # ]:          0 :     aStandardBtn.SetClickHdl( LINK( this, SvxPathTabPage, StandardHdl_Impl ) );
     228         [ #  # ]:          0 :     Link aLink = LINK( this, SvxPathTabPage, PathHdl_Impl );
     229                 :          0 :     aPathBtn.SetClickHdl( aLink );
     230                 :          0 :     Size aBoxSize = aPathCtrl.GetOutputSizePixel();
     231 [ #  # ][ #  # ]:          0 :     pHeaderBar = new HeaderBar( &aPathCtrl, WB_BUTTONSTYLE | WB_BOTTOMBORDER );
     232         [ #  # ]:          0 :     pHeaderBar->SetPosSizePixel( Point( 0, 0 ), Size( aBoxSize.Width(), 16 ) );
     233         [ #  # ]:          0 :     pHeaderBar->SetSelectHdl( LINK( this, SvxPathTabPage, HeaderSelect_Impl ) );
     234         [ #  # ]:          0 :     pHeaderBar->SetEndDragHdl( LINK( this, SvxPathTabPage, HeaderEndDrag_Impl ) );
     235                 :          0 :     Size aSz;
     236                 :          0 :     aSz.Width() = TAB_WIDTH1;
     237                 :            :     pHeaderBar->InsertItem( ITEMID_TYPE, aTypeText.GetText(),
     238 [ #  # ][ #  # ]:          0 :                             LogicToPixel( aSz, MapMode( MAP_APPFONT ) ).Width(),
                 [ #  # ]
     239 [ #  # ][ #  # ]:          0 :                             HIB_LEFT | HIB_VCENTER | HIB_CLICKABLE | HIB_UPARROW );
                 [ #  # ]
     240                 :          0 :     aSz.Width() = TAB_WIDTH2;
     241                 :            :     pHeaderBar->InsertItem( ITEMID_PATH, aPathText.GetText(),
     242 [ #  # ][ #  # ]:          0 :                             LogicToPixel( aSz, MapMode( MAP_APPFONT ) ).Width(),
                 [ #  # ]
     243 [ #  # ][ #  # ]:          0 :                             HIB_LEFT | HIB_VCENTER );
                 [ #  # ]
     244                 :            : 
     245                 :            :     static long nTabs[] = {3, 0, TAB_WIDTH1, TAB_WIDTH1 + TAB_WIDTH2 };
     246         [ #  # ]:          0 :     Size aHeadSize = pHeaderBar->GetSizePixel();
     247                 :            : 
     248                 :          0 :     WinBits nBits = WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP;
     249 [ #  # ][ #  # ]:          0 :     pPathBox = new svx::OptHeaderTabListBox( &aPathCtrl, nBits );
     250                 :          0 :     aPathCtrl.SetFocusControl( pPathBox );
     251                 :          0 :     pPathBox->SetDoubleClickHdl( aLink );
     252         [ #  # ]:          0 :     pPathBox->SetSelectHdl( LINK( this, SvxPathTabPage, PathSelect_Impl ) );
     253         [ #  # ]:          0 :     pPathBox->SetSelectionMode( MULTIPLE_SELECTION );
     254                 :          0 :     pPathBox->SetPosSizePixel( Point( 0, aHeadSize.Height() ),
     255         [ #  # ]:          0 :                                Size( aBoxSize.Width(), aBoxSize.Height() - aHeadSize.Height() ) );
     256         [ #  # ]:          0 :     pPathBox->SetTabs( &nTabs[0], MAP_APPFONT );
     257         [ #  # ]:          0 :     pPathBox->InitHeaderBar( pHeaderBar );
     258         [ #  # ]:          0 :     pPathBox->SetHighlightRange();
     259         [ #  # ]:          0 :     pPathBox->SetHelpId( HID_OPTPATH_CTL_PATH );
     260         [ #  # ]:          0 :     pHeaderBar->SetHelpId( HID_OPTPATH_HEADERBAR );
     261         [ #  # ]:          0 :     pPathBox->Show();
     262         [ #  # ]:          0 :     pHeaderBar->Show();
     263                 :            : 
     264         [ #  # ]:          0 :     FreeResource();
     265                 :            : 
     266 [ #  # ][ #  # ]:          0 :     xDialogListener->SetDialogClosedLink( LINK( this, SvxPathTabPage, DialogClosedHdl ) );
     267                 :          0 : }
     268                 :            : 
     269                 :            : // -----------------------------------------------------------------------
     270                 :            : 
     271 [ #  # ][ #  # ]:          0 : SvxPathTabPage::~SvxPathTabPage()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     272                 :            : {
     273                 :            :     // #110603# do not grab focus to a destroyed window !!!
     274                 :          0 :     aPathCtrl.SetFocusControl( NULL );
     275                 :            : 
     276         [ #  # ]:          0 :     pHeaderBar->Hide();
     277         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < pPathBox->GetEntryCount(); ++i )
     278 [ #  # ][ #  # ]:          0 :         delete (PathUserData_Impl*)pPathBox->GetEntry(i)->GetUserData();
                 [ #  # ]
     279 [ #  # ][ #  # ]:          0 :     delete pPathBox;
     280 [ #  # ][ #  # ]:          0 :     delete pHeaderBar;
     281 [ #  # ][ #  # ]:          0 :     delete pImpl;
     282         [ #  # ]:          0 : }
     283                 :            : 
     284                 :            : // -----------------------------------------------------------------------
     285                 :            : 
     286                 :          0 : SfxTabPage* SvxPathTabPage::Create( Window* pParent,
     287                 :            :                                     const SfxItemSet& rAttrSet )
     288                 :            : {
     289         [ #  # ]:          0 :     return ( new SvxPathTabPage( pParent, rAttrSet ) );
     290                 :            : }
     291                 :            : 
     292                 :            : // -----------------------------------------------------------------------
     293                 :            : 
     294                 :          0 : sal_Bool SvxPathTabPage::FillItemSet( SfxItemSet& )
     295                 :            : {
     296         [ #  # ]:          0 :     SvtPathOptions aPathOpt;
     297         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < pPathBox->GetEntryCount(); ++i )
     298                 :            :     {
     299         [ #  # ]:          0 :         PathUserData_Impl* pPathImpl = (PathUserData_Impl*)pPathBox->GetEntry(i)->GetUserData();
     300                 :          0 :         sal_uInt16 nRealId = pPathImpl->nRealId;
     301         [ #  # ]:          0 :         if ( pPathImpl->eState == SFX_ITEM_SET )
     302         [ #  # ]:          0 :             SetPathList( nRealId, pPathImpl->sUserPath, pPathImpl->sWritablePath );
     303                 :            :     }
     304         [ #  # ]:          0 :     return sal_True;
     305                 :            : }
     306                 :            : 
     307                 :            : // -----------------------------------------------------------------------
     308                 :            : 
     309                 :          0 : void SvxPathTabPage::Reset( const SfxItemSet& )
     310                 :            : {
     311         [ #  # ]:          0 :     pPathBox->Clear();
     312         [ #  # ]:          0 :     SvtPathOptions aPathOpt; //! deprecated
     313                 :            : 
     314         [ #  # ]:          0 :     for( sal_uInt16 i = 0; i <= (sal_uInt16)SvtPathOptions::PATH_WORK; ++i )
     315                 :            :     {
     316                 :            :         // only writer uses autotext
     317 [ #  # ][ #  # ]:          0 :         if ( i == SvtPathOptions::PATH_AUTOTEXT
                 [ #  # ]
     318 [ #  # ][ #  # ]:          0 :             && !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     319                 :          0 :             continue;
     320                 :            : 
     321         [ #  # ]:          0 :         switch (i)
     322                 :            :         {
     323                 :            :             case SvtPathOptions::PATH_AUTOCORRECT:
     324                 :            :             case SvtPathOptions::PATH_AUTOTEXT:
     325                 :            :             case SvtPathOptions::PATH_BACKUP:
     326                 :            :             case SvtPathOptions::PATH_GALLERY:
     327                 :            :             case SvtPathOptions::PATH_GRAPHIC:
     328                 :            :             case SvtPathOptions::PATH_TEMP:
     329                 :            :             case SvtPathOptions::PATH_TEMPLATE:
     330                 :            : #if OSL_DEBUG_LEVEL > 1
     331                 :            :             case SvtPathOptions::PATH_LINGUISTIC:
     332                 :            :             case SvtPathOptions::PATH_DICTIONARY:
     333                 :            : #endif
     334                 :            :             case SvtPathOptions::PATH_WORK:
     335                 :            :             {
     336 [ #  # ][ #  # ]:          0 :                 String aStr( CUI_RES( RID_SVXSTR_PATH_NAME_START + i ) );
     337 [ #  # ][ #  # ]:          0 :                 String sInternal, sUser, sWritable;
                 [ #  # ]
     338                 :          0 :                 sal_Bool bReadOnly = sal_False;
     339         [ #  # ]:          0 :                 GetPathList( i, sInternal, sUser, sWritable, bReadOnly );
     340         [ #  # ]:          0 :                 String sTmpPath = sUser;
     341 [ #  # ][ #  # ]:          0 :                 if ( sTmpPath.Len() > 0 && sWritable.Len() > 0 )
                 [ #  # ]
     342         [ #  # ]:          0 :                     sTmpPath += MULTIPATH_DELIMITER;
     343         [ #  # ]:          0 :                 sTmpPath += sWritable;
     344         [ #  # ]:          0 :                 String aValue( sTmpPath );
     345         [ #  # ]:          0 :                 aStr += '\t';
     346 [ #  # ][ #  # ]:          0 :                 aStr += Convert_Impl( aValue );
                 [ #  # ]
     347         [ #  # ]:          0 :                 SvLBoxEntry* pEntry = pPathBox->InsertEntry( aStr );
     348         [ #  # ]:          0 :                 if ( bReadOnly )
     349                 :            :                 {
     350         [ #  # ]:          0 :                     pPathBox->SetCollapsedEntryBmp( pEntry, pImpl->m_aLockImage );
     351                 :            :                 }
     352 [ #  # ][ #  # ]:          0 :                 PathUserData_Impl* pPathImpl = new PathUserData_Impl(i);
     353         [ #  # ]:          0 :                 pPathImpl->sUserPath = sUser;
     354         [ #  # ]:          0 :                 pPathImpl->sWritablePath = sWritable;
     355 [ #  # ][ #  # ]:          0 :                 pEntry->SetUserData( pPathImpl );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     356                 :            :             }
     357                 :            :         }
     358                 :            :     }
     359                 :            : 
     360         [ #  # ]:          0 :     String aUserData = GetUserData();
     361         [ #  # ]:          0 :     if ( aUserData.Len() )
     362                 :            :     {
     363                 :            :         // restore column width
     364 [ #  # ][ #  # ]:          0 :         pHeaderBar->SetItemSize( ITEMID_TYPE, aUserData.GetToken(0).ToInt32() );
         [ #  # ][ #  # ]
     365         [ #  # ]:          0 :         HeaderEndDrag_Impl( NULL );
     366                 :            :         // restore sort direction
     367 [ #  # ][ #  # ]:          0 :         sal_Bool bUp = (sal_Bool)(sal_uInt16)aUserData.GetToken(1).ToInt32();
                 [ #  # ]
     368         [ #  # ]:          0 :         HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE);
     369                 :            : 
     370         [ #  # ]:          0 :         if ( bUp )
     371                 :            :         {
     372                 :          0 :             nBits &= ~HIB_UPARROW;
     373                 :          0 :             nBits |= HIB_DOWNARROW;
     374                 :            :         }
     375                 :            :         else
     376                 :            :         {
     377                 :          0 :             nBits &= ~HIB_DOWNARROW;
     378                 :          0 :             nBits |= HIB_UPARROW;
     379                 :            :         }
     380         [ #  # ]:          0 :         pHeaderBar->SetItemBits( ITEMID_TYPE, nBits );
     381         [ #  # ]:          0 :         HeaderSelect_Impl( NULL );
     382                 :            :     }
     383 [ #  # ][ #  # ]:          0 :     PathSelect_Impl( NULL );
                 [ #  # ]
     384                 :          0 : }
     385                 :            : 
     386                 :            : // -----------------------------------------------------------------------
     387                 :            : 
     388                 :          0 : void SvxPathTabPage::FillUserData()
     389                 :            : {
     390 [ #  # ][ #  # ]:          0 :     String aUserData = String::CreateFromInt32( pHeaderBar->GetItemSize( ITEMID_TYPE ) );
     391         [ #  # ]:          0 :     aUserData += ';';
     392         [ #  # ]:          0 :     HeaderBarItemBits nBits = pHeaderBar->GetItemBits( ITEMID_TYPE );
     393                 :          0 :     sal_Bool bUp = ( ( nBits & HIB_UPARROW ) == HIB_UPARROW );
     394 [ #  # ][ #  # ]:          0 :     aUserData += bUp ? '1' : '0';
     395 [ #  # ][ #  # ]:          0 :     SetUserData( aUserData );
     396                 :          0 : }
     397                 :            : 
     398                 :            : // -----------------------------------------------------------------------
     399                 :            : 
     400                 :          0 : IMPL_LINK_NOARG(SvxPathTabPage, PathSelect_Impl)
     401                 :            : {
     402                 :          0 :     sal_uInt16 nSelCount = 0;
     403         [ #  # ]:          0 :     SvLBoxEntry* pEntry = pPathBox->FirstSelected();
     404                 :            : 
     405                 :            :     //the entry image indicates whether the path is write protected
     406         [ #  # ]:          0 :     Image aEntryImage;
     407         [ #  # ]:          0 :     if(pEntry)
     408 [ #  # ][ #  # ]:          0 :         aEntryImage = pPathBox->GetCollapsedEntryBmp( pEntry );
     409                 :          0 :     sal_Bool bEnable = !aEntryImage;
     410 [ #  # ][ #  # ]:          0 :     while ( pEntry && ( nSelCount < 2 ) )
                 [ #  # ]
     411                 :            :     {
     412                 :          0 :         nSelCount++;
     413         [ #  # ]:          0 :         pEntry = pPathBox->NextSelected( pEntry );
     414                 :            :     }
     415                 :            : 
     416 [ #  # ][ #  # ]:          0 :     aPathBtn.Enable( 1 == nSelCount && bEnable);
                 [ #  # ]
     417 [ #  # ][ #  # ]:          0 :     aStandardBtn.Enable( nSelCount > 0 && bEnable);
                 [ #  # ]
     418         [ #  # ]:          0 :     return 0;
     419                 :            : }
     420                 :            : 
     421                 :            : // -----------------------------------------------------------------------
     422                 :            : 
     423                 :          0 : IMPL_LINK_NOARG(SvxPathTabPage, StandardHdl_Impl)
     424                 :            : {
     425                 :          0 :     SvLBoxEntry* pEntry = pPathBox->FirstSelected();
     426         [ #  # ]:          0 :     while ( pEntry )
     427                 :            :     {
     428                 :          0 :         PathUserData_Impl* pPathImpl = (PathUserData_Impl*)pEntry->GetUserData();
     429         [ #  # ]:          0 :         String aOldPath = pImpl->m_aDefOpt.GetDefaultPath( pPathImpl->nRealId );
     430                 :            : 
     431         [ #  # ]:          0 :         if ( aOldPath.Len() )
     432                 :            :         {
     433 [ #  # ][ #  # ]:          0 :             String sInternal, sUser, sWritable, sTemp;
         [ #  # ][ #  # ]
     434                 :          0 :             sal_Bool bReadOnly = sal_False;
     435         [ #  # ]:          0 :             GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly );
     436                 :            : 
     437                 :            :             sal_uInt16 i;
     438 [ #  # ][ #  # ]:          0 :             sal_uInt16 nOldCount = comphelper::string::getTokenCount(aOldPath, MULTIPATH_DELIMITER);
     439 [ #  # ][ #  # ]:          0 :             sal_uInt16 nIntCount = comphelper::string::getTokenCount(sInternal, MULTIPATH_DELIMITER);
     440         [ #  # ]:          0 :             for ( i = 0; i < nOldCount; ++i )
     441                 :            :             {
     442                 :          0 :                 bool bFound = false;
     443         [ #  # ]:          0 :                 String sOnePath = aOldPath.GetToken( i, MULTIPATH_DELIMITER );
     444 [ #  # ][ #  # ]:          0 :                 for ( sal_uInt16 j = 0; !bFound && j < nIntCount; ++j )
                 [ #  # ]
     445                 :            :                 {
     446 [ #  # ][ #  # ]:          0 :                     if ( sInternal.GetToken( i, MULTIPATH_DELIMITER ) == sOnePath )
         [ #  # ][ #  # ]
     447                 :          0 :                         bFound = true;
     448                 :            :                 }
     449         [ #  # ]:          0 :                 if ( !bFound )
     450                 :            :                 {
     451         [ #  # ]:          0 :                     if ( sTemp.Len() > 0 )
     452         [ #  # ]:          0 :                         sTemp += MULTIPATH_DELIMITER;
     453         [ #  # ]:          0 :                     sTemp += sOnePath;
     454                 :            :                 }
     455         [ #  # ]:          0 :             }
     456                 :            : 
     457 [ #  # ][ #  # ]:          0 :             String sUserPath, sWritablePath;
     458 [ #  # ][ #  # ]:          0 :             nOldCount = comphelper::string::getTokenCount(sTemp, MULTIPATH_DELIMITER);
     459 [ #  # ][ #  # ]:          0 :             for ( i = 0; nOldCount > 0 && i < nOldCount - 1; ++i )
                 [ #  # ]
     460                 :            :             {
     461         [ #  # ]:          0 :                 if ( sUserPath.Len() > 0 )
     462         [ #  # ]:          0 :                     sUserPath += MULTIPATH_DELIMITER;
     463 [ #  # ][ #  # ]:          0 :                 sUserPath += sTemp.GetToken( i, MULTIPATH_DELIMITER );
                 [ #  # ]
     464                 :            :             }
     465 [ #  # ][ #  # ]:          0 :             sWritablePath = sTemp.GetToken( nOldCount - 1, MULTIPATH_DELIMITER );
                 [ #  # ]
     466                 :            : 
     467 [ #  # ][ #  # ]:          0 :             pPathBox->SetEntryText( Convert_Impl( sTemp ), pEntry, 1 );
                 [ #  # ]
     468                 :          0 :             pPathImpl->eState = SFX_ITEM_SET;
     469         [ #  # ]:          0 :             pPathImpl->sUserPath = sUserPath;
     470 [ #  # ][ #  # ]:          0 :             pPathImpl->sWritablePath = sWritablePath;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     471                 :            :         }
     472         [ #  # ]:          0 :         pEntry = pPathBox->NextSelected( pEntry );
     473         [ #  # ]:          0 :     }
     474                 :          0 :     return 0;
     475                 :            : }
     476                 :            : 
     477                 :            : // -----------------------------------------------------------------------
     478                 :            : 
     479                 :          0 : void SvxPathTabPage::ChangeCurrentEntry( const String& _rFolder )
     480                 :            : {
     481         [ #  # ]:          0 :     SvLBoxEntry* pEntry = pPathBox->GetCurEntry();
     482         [ #  # ]:          0 :     if ( !pEntry )
     483                 :            :     {
     484                 :            :         SAL_WARN( "cui.options", "SvxPathTabPage::ChangeCurrentEntry(): no entry" );
     485                 :          0 :         return;
     486                 :            :     }
     487                 :            : 
     488 [ #  # ][ #  # ]:          0 :     String sInternal, sUser, sWritable;
                 [ #  # ]
     489                 :          0 :     PathUserData_Impl* pPathImpl = (PathUserData_Impl*)pEntry->GetUserData();
     490                 :          0 :     sal_Bool bReadOnly = sal_False;
     491         [ #  # ]:          0 :     GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly );
     492         [ #  # ]:          0 :     sUser = pPathImpl->sUserPath;
     493         [ #  # ]:          0 :     sWritable = pPathImpl->sWritablePath;
     494                 :          0 :     sal_uInt16 nPos = pPathImpl->nRealId;
     495                 :            : 
     496                 :            :     // old path is an URL?
     497 [ #  # ][ #  # ]:          0 :     INetURLObject aObj( sWritable );
     498                 :          0 :     bool bURL = ( aObj.GetProtocol() != INET_PROT_NOT_VALID );
     499         [ #  # ]:          0 :     rtl::OUString aPathStr( _rFolder );
     500         [ #  # ]:          0 :     INetURLObject aNewObj( aPathStr );
     501         [ #  # ]:          0 :     aNewObj.removeFinalSlash();
     502                 :            : 
     503                 :            :     // then the new path also an URL else system path
     504 [ #  # ][ #  # ]:          0 :     String sNewPathStr = bURL ? aPathStr : aNewObj.getFSysPath( INetURLObject::FSYS_DETECT );
                 [ #  # ]
     505                 :            : 
     506                 :            :     bool bChanged =
     507                 :            : #ifdef UNX
     508                 :            : // Unix is case sensitive
     509         [ #  # ]:          0 :         ( sNewPathStr != sWritable );
     510                 :            : #else
     511                 :            :         ( sNewPathStr.CompareIgnoreCaseToAscii( sWritable ) != COMPARE_EQUAL );
     512                 :            : #endif
     513                 :            : 
     514         [ #  # ]:          0 :     if ( bChanged )
     515                 :            :     {
     516 [ #  # ][ #  # ]:          0 :         pPathBox->SetEntryText( Convert_Impl( sNewPathStr ), pEntry, 1 );
                 [ #  # ]
     517         [ #  # ]:          0 :         nPos = (sal_uInt16)pPathBox->GetModel()->GetAbsPos( pEntry );
     518         [ #  # ]:          0 :         pPathImpl = (PathUserData_Impl*)pPathBox->GetEntry(nPos)->GetUserData();
     519                 :          0 :         pPathImpl->eState = SFX_ITEM_SET;
     520         [ #  # ]:          0 :         pPathImpl->sWritablePath = sNewPathStr;
     521         [ #  # ]:          0 :         if ( SvtPathOptions::PATH_WORK == pPathImpl->nRealId )
     522                 :            :         {
     523                 :            :             // Remove view options entry so the new work path
     524                 :            :             // will be used for the next open dialog.
     525         [ #  # ]:          0 :             SvtViewOptions aDlgOpt( E_DIALOG, IODLG_CONFIGNAME );
     526         [ #  # ]:          0 :             aDlgOpt.Delete();
     527                 :            :             // Reset also last used dir in the sfx application instance
     528         [ #  # ]:          0 :             SfxApplication *pSfxApp = SFX_APP();
     529         [ #  # ]:          0 :             pSfxApp->ResetLastDir();
     530                 :            : 
     531                 :            :             // Set configuration flag to notify file picker that it's necessary
     532                 :            :             // to take over the path provided.
     533                 :            :             boost::shared_ptr< comphelper::ConfigurationChanges > batch(
     534 [ #  # ][ #  # ]:          0 :                 comphelper::ConfigurationChanges::create());
     535                 :            :             officecfg::Office::Common::Path::Info::WorkPathChanged::set(
     536         [ #  # ]:          0 :                 true, batch);
     537 [ #  # ][ #  # ]:          0 :             batch->commit();
                 [ #  # ]
     538                 :            :         }
     539 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     540                 :            : }
     541                 :            : 
     542                 :            : // -----------------------------------------------------------------------
     543                 :            : 
     544                 :          0 : IMPL_LINK_NOARG(SvxPathTabPage, PathHdl_Impl)
     545                 :            : {
     546         [ #  # ]:          0 :     SvLBoxEntry* pEntry = pPathBox->GetCurEntry();
     547         [ #  # ]:          0 :     sal_uInt16 nPos = ( pEntry != NULL ) ? ( (PathUserData_Impl*)pEntry->GetUserData() )->nRealId : 0;
     548 [ #  # ][ #  # ]:          0 :     String sInternal, sUser, sWritable;
                 [ #  # ]
     549         [ #  # ]:          0 :     if ( pEntry )
     550                 :            :     {
     551                 :          0 :         PathUserData_Impl* pPathImpl = (PathUserData_Impl*)pEntry->GetUserData();
     552                 :          0 :         sal_Bool bReadOnly = sal_False;
     553         [ #  # ]:          0 :         GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly );
     554         [ #  # ]:          0 :         sUser = pPathImpl->sUserPath;
     555         [ #  # ]:          0 :         sWritable = pPathImpl->sWritablePath;
     556                 :            :     }
     557                 :            : 
     558 [ #  # ][ #  # ]:          0 :     if(pEntry && !(!((OptHeaderTabListBox*)pPathBox)->GetCollapsedEntryBmp(pEntry)))
         [ #  # ][ #  # ]
     559                 :          0 :         return 0;
     560                 :            : 
     561         [ #  # ]:          0 :     if ( IsMultiPath_Impl( nPos ) )
     562                 :            :     {
     563         [ #  # ]:          0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     564         [ #  # ]:          0 :         if ( pFact )
     565                 :            :         {
     566                 :            :             AbstractSvxMultiPathDialog* pMultiDlg =
     567         [ #  # ]:          0 :                 pFact->CreateSvxMultiPathDialog( this );
     568                 :            :             DBG_ASSERT( pMultiDlg, "Dialogdiet fail!" );
     569         [ #  # ]:          0 :             pMultiDlg->EnableRadioButtonMode();
     570                 :            : 
     571         [ #  # ]:          0 :             String sPath( sUser );
     572         [ #  # ]:          0 :             if ( sPath.Len() > 0 )
     573         [ #  # ]:          0 :                 sPath += MULTIPATH_DELIMITER;
     574         [ #  # ]:          0 :             sPath += sWritable;
     575         [ #  # ]:          0 :             pMultiDlg->SetPath( sPath );
     576                 :            : 
     577         [ #  # ]:          0 :             String sPathName = pPathBox->GetEntryText( pEntry, 0 );
     578         [ #  # ]:          0 :             String sNewTitle( pImpl->m_sMultiPathDlg );
     579 [ #  # ][ #  # ]:          0 :             sNewTitle.SearchAndReplace( VAR_ONE, sPathName );
                 [ #  # ]
     580         [ #  # ]:          0 :             pMultiDlg->SetTitle( sNewTitle );
     581                 :            : 
     582 [ #  # ][ #  # ]:          0 :             if ( pMultiDlg->Execute() == RET_OK && pEntry )
         [ #  # ][ #  # ]
     583                 :            :             {
     584         [ #  # ]:          0 :                 sUser.Erase();
     585         [ #  # ]:          0 :                 sWritable.Erase();
     586         [ #  # ]:          0 :                 String sFullPath;
     587         [ #  # ]:          0 :                 String sNewPath = pMultiDlg->GetPath();
     588                 :          0 :                 char cDelim = MULTIPATH_DELIMITER;
     589 [ #  # ][ #  # ]:          0 :                 sal_uInt16 nCount = comphelper::string::getTokenCount(sNewPath, cDelim);
     590         [ #  # ]:          0 :                 if ( nCount > 0 )
     591                 :            :                 {
     592                 :          0 :                     sal_uInt16 i = 0;
     593         [ #  # ]:          0 :                     for ( ; i < nCount - 1; ++i )
     594                 :            :                     {
     595         [ #  # ]:          0 :                         if ( sUser.Len() > 0 )
     596         [ #  # ]:          0 :                             sUser += cDelim;
     597 [ #  # ][ #  # ]:          0 :                         sUser += sNewPath.GetToken( i, cDelim );
                 [ #  # ]
     598                 :            :                     }
     599         [ #  # ]:          0 :                     if ( sFullPath.Len() > 0 )
     600         [ #  # ]:          0 :                         sFullPath += cDelim;
     601         [ #  # ]:          0 :                     sFullPath += sUser;
     602 [ #  # ][ #  # ]:          0 :                     sWritable += sNewPath.GetToken( i, cDelim );
                 [ #  # ]
     603         [ #  # ]:          0 :                     if ( sFullPath.Len() > 0 )
     604         [ #  # ]:          0 :                         sFullPath += cDelim;
     605         [ #  # ]:          0 :                     sFullPath += sWritable;
     606                 :            :                 }
     607                 :            : 
     608 [ #  # ][ #  # ]:          0 :                 pPathBox->SetEntryText( Convert_Impl( sFullPath ), pEntry, 1 );
                 [ #  # ]
     609                 :            :                 // save modified flag
     610                 :          0 :                 PathUserData_Impl* pPathImpl = (PathUserData_Impl*)pEntry->GetUserData();
     611                 :          0 :                 pPathImpl->eState = SFX_ITEM_SET;
     612         [ #  # ]:          0 :                 pPathImpl->sUserPath = sUser;
     613 [ #  # ][ #  # ]:          0 :                 pPathImpl->sWritablePath = sWritable;
                 [ #  # ]
     614                 :            :             }
     615 [ #  # ][ #  # ]:          0 :             delete pMultiDlg;
         [ #  # ][ #  # ]
                 [ #  # ]
     616                 :            :         }
     617                 :            :     }
     618         [ #  # ]:          0 :     else if ( pEntry )
     619                 :            :     {
     620                 :            :         try
     621                 :            :         {
     622         [ #  # ]:          0 :             rtl::OUString aService( RTL_CONSTASCII_USTRINGPARAM( FOLDER_PICKER_SERVICE_NAME ) );
     623         [ #  # ]:          0 :             Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
     624                 :            :             xFolderPicker = ::com::sun::star::uno::Reference< XFolderPicker >(
     625 [ #  # ][ #  # ]:          0 :                 xFactory->createInstance( aService ), UNO_QUERY );
         [ #  # ][ #  # ]
     626                 :            : 
     627 [ #  # ][ #  # ]:          0 :             INetURLObject aURL( sWritable, INET_PROT_FILE );
     628 [ #  # ][ #  # ]:          0 :             xFolderPicker->setDisplayDirectory( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
                 [ #  # ]
     629                 :            : 
     630         [ #  # ]:          0 :             Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY );
     631         [ #  # ]:          0 :             if ( xAsyncDlg.is() )
     632 [ #  # ][ #  # ]:          0 :                 xAsyncDlg->startExecuteModal( xDialogListener.get() );
         [ #  # ][ #  # ]
                 [ #  # ]
     633                 :            :             else
     634                 :            :             {
     635 [ #  # ][ #  # ]:          0 :                 short nRet = xFolderPicker->execute();
     636         [ #  # ]:          0 :                 if ( ExecutableDialogResults::OK != nRet )
     637                 :          0 :                     return 0;
     638                 :            : 
     639 [ #  # ][ #  # ]:          0 :                 String sFolder( xFolderPicker->getDirectory() );
                 [ #  # ]
     640 [ #  # ][ #  # ]:          0 :                 ChangeCurrentEntry( sFolder );
     641 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     642                 :            :         }
     643         [ #  # ]:          0 :         catch( Exception& )
     644                 :            :         {
     645                 :            :             SAL_WARN( "cui.options", "SvxPathTabPage::PathHdl_Impl: exception from folder picker" );
     646                 :            :         }
     647                 :            :     }
     648 [ #  # ][ #  # ]:          0 :     return 0;
                 [ #  # ]
     649                 :            : }
     650                 :            : 
     651                 :            : // -----------------------------------------------------------------------
     652                 :            : 
     653                 :          0 : IMPL_LINK( SvxPathTabPage, HeaderSelect_Impl, HeaderBar*, pBar )
     654                 :            : {
     655 [ #  # ][ #  # ]:          0 :     if ( pBar && pBar->GetCurItemId() != ITEMID_TYPE )
                 [ #  # ]
     656                 :          0 :         return 0;
     657                 :            : 
     658                 :          0 :     HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE);
     659                 :          0 :     sal_Bool bUp = ( ( nBits & HIB_UPARROW ) == HIB_UPARROW );
     660                 :          0 :     SvSortMode eMode = SortAscending;
     661                 :            : 
     662         [ #  # ]:          0 :     if ( bUp )
     663                 :            :     {
     664                 :          0 :         nBits &= ~HIB_UPARROW;
     665                 :          0 :         nBits |= HIB_DOWNARROW;
     666                 :          0 :         eMode = SortDescending;
     667                 :            :     }
     668                 :            :     else
     669                 :            :     {
     670                 :          0 :         nBits &= ~HIB_DOWNARROW;
     671                 :          0 :         nBits |= HIB_UPARROW;
     672                 :            :     }
     673                 :          0 :     pHeaderBar->SetItemBits( ITEMID_TYPE, nBits );
     674                 :          0 :     SvTreeList* pModel = pPathBox->GetModel();
     675                 :          0 :     pModel->SetSortMode( eMode );
     676                 :          0 :     pModel->Resort();
     677                 :          0 :     return 1;
     678                 :            : }
     679                 :            : 
     680                 :            : // -----------------------------------------------------------------------
     681                 :            : 
     682                 :          0 : IMPL_LINK( SvxPathTabPage, HeaderEndDrag_Impl, HeaderBar*, pBar )
     683                 :            : {
     684 [ #  # ][ #  # ]:          0 :     if ( pBar && !pBar->GetCurItemId() )
                 [ #  # ]
     685                 :          0 :         return 0;
     686                 :            : 
     687         [ #  # ]:          0 :     if ( !pHeaderBar->IsItemMode() )
     688                 :            :     {
     689                 :          0 :         Size aSz;
     690         [ #  # ]:          0 :         sal_uInt16 nTabs = pHeaderBar->GetItemCount();
     691                 :          0 :         long nTmpSz = 0;
     692         [ #  # ]:          0 :         long nWidth = pHeaderBar->GetItemSize(ITEMID_TYPE);
     693         [ #  # ]:          0 :         long nBarWidth = pHeaderBar->GetSizePixel().Width();
     694                 :            : 
     695         [ #  # ]:          0 :         if(nWidth < TAB_WIDTH_MIN)
     696         [ #  # ]:          0 :             pHeaderBar->SetItemSize( ITEMID_TYPE, TAB_WIDTH_MIN);
     697         [ #  # ]:          0 :         else if ( ( nBarWidth - nWidth ) < TAB_WIDTH_MIN )
     698         [ #  # ]:          0 :             pHeaderBar->SetItemSize( ITEMID_TYPE, nBarWidth - TAB_WIDTH_MIN );
     699                 :            : 
     700         [ #  # ]:          0 :         for ( sal_uInt16 i = 1; i <= nTabs; ++i )
     701                 :            :         {
     702         [ #  # ]:          0 :             long _nWidth = pHeaderBar->GetItemSize(i);
     703                 :          0 :             aSz.Width() =  _nWidth + nTmpSz;
     704                 :          0 :             nTmpSz += _nWidth;
     705 [ #  # ][ #  # ]:          0 :             pPathBox->SetTab( i, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT );
         [ #  # ][ #  # ]
     706                 :            :         }
     707                 :            :     }
     708                 :          0 :     return 1;
     709                 :            : }
     710                 :            : 
     711                 :            : // -----------------------------------------------------------------------
     712                 :            : 
     713                 :          0 : IMPL_LINK( SvxPathTabPage, DialogClosedHdl, DialogClosedEvent*, pEvt )
     714                 :            : {
     715         [ #  # ]:          0 :     if ( RET_OK == pEvt->DialogResult )
     716                 :            :     {
     717                 :            :         DBG_ASSERT( xFolderPicker.is() == sal_True, "SvxPathTabPage::DialogClosedHdl(): no folder picker" );
     718                 :            : 
     719 [ #  # ][ #  # ]:          0 :         String sURL = String( xFolderPicker->getDirectory() );
                 [ #  # ]
     720 [ #  # ][ #  # ]:          0 :         ChangeCurrentEntry( sURL );
     721                 :            :     }
     722                 :          0 :     return 0L;
     723                 :            : }
     724                 :            : 
     725                 :            : // -----------------------------------------------------------------------
     726                 :            : 
     727                 :          0 : void SvxPathTabPage::GetPathList(
     728                 :            :     sal_uInt16 _nPathHandle, String& _rInternalPath,
     729                 :            :     String& _rUserPath, String& _rWritablePath, sal_Bool& _rReadOnly )
     730                 :            : {
     731         [ #  # ]:          0 :     String sCfgName = getCfgName_Impl( _nPathHandle );
     732                 :            : 
     733                 :            :     // load PathSettings service if necessary
     734         [ #  # ]:          0 :     if ( !pImpl->m_xPathSettings.is() )
     735                 :            :     {
     736         [ #  # ]:          0 :         Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory();
     737         [ #  # ]:          0 :         pImpl->m_xPathSettings = Reference< XPropertySet >( xSMgr->createInstance(
     738                 :            :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
     739 [ #  # ][ #  # ]:          0 :                 "com.sun.star.util.PathSettings") ) ), UNO_QUERY );
         [ #  # ][ #  # ]
     740                 :            :     }
     741                 :            : 
     742                 :            :     try
     743                 :            :     {
     744         [ #  # ]:          0 :         if ( pImpl->m_xPathSettings.is() )
     745                 :            :         {
     746                 :            :             // load internal paths
     747         [ #  # ]:          0 :             String sProp( sCfgName );
     748         [ #  # ]:          0 :             sProp = sCfgName;
     749         [ #  # ]:          0 :             sProp += POSTFIX_INTERNAL;
     750 [ #  # ][ #  # ]:          0 :             Any aAny = pImpl->m_xPathSettings->getPropertyValue( sProp );
                 [ #  # ]
     751         [ #  # ]:          0 :             Sequence< ::rtl::OUString > aPathSeq;
     752 [ #  # ][ #  # ]:          0 :             if ( aAny >>= aPathSeq )
     753                 :            :             {
     754                 :          0 :                 long i, nCount = aPathSeq.getLength();
     755                 :          0 :                 const ::rtl::OUString* pPaths = aPathSeq.getConstArray();
     756                 :            : 
     757         [ #  # ]:          0 :                 for ( i = 0; i < nCount; ++i )
     758                 :            :                 {
     759         [ #  # ]:          0 :                     if ( _rInternalPath.Len() > 0 )
     760         [ #  # ]:          0 :                         _rInternalPath += ';';
     761 [ #  # ][ #  # ]:          0 :                     _rInternalPath += String( pPaths[i] );
                 [ #  # ]
     762                 :            :                 }
     763                 :            :             }
     764                 :            :             // load user paths
     765         [ #  # ]:          0 :             sProp = sCfgName;
     766         [ #  # ]:          0 :             sProp += POSTFIX_USER;
     767 [ #  # ][ #  # ]:          0 :             aAny = pImpl->m_xPathSettings->getPropertyValue( sProp );
                 [ #  # ]
     768 [ #  # ][ #  # ]:          0 :             if ( aAny >>= aPathSeq )
     769                 :            :             {
     770                 :          0 :                 long i, nCount = aPathSeq.getLength();
     771                 :          0 :                 const ::rtl::OUString* pPaths = aPathSeq.getConstArray();
     772                 :            : 
     773         [ #  # ]:          0 :                 for ( i = 0; i < nCount; ++i )
     774                 :            :                 {
     775         [ #  # ]:          0 :                     if ( _rUserPath.Len() > 0 )
     776         [ #  # ]:          0 :                         _rUserPath += ';';
     777 [ #  # ][ #  # ]:          0 :                     _rUserPath += String( pPaths[i] );
                 [ #  # ]
     778                 :            :                 }
     779                 :            :             }
     780                 :            :             // then the writable path
     781         [ #  # ]:          0 :             sProp = sCfgName;
     782         [ #  # ]:          0 :             sProp += POSTFIX_WRITABLE;
     783 [ #  # ][ #  # ]:          0 :             aAny = pImpl->m_xPathSettings->getPropertyValue( sProp );
                 [ #  # ]
     784                 :          0 :             ::rtl::OUString sWritablePath;
     785         [ #  # ]:          0 :             if ( aAny >>= sWritablePath )
     786 [ #  # ][ #  # ]:          0 :                 _rWritablePath = String( sWritablePath );
                 [ #  # ]
     787                 :            : 
     788                 :            :             // and the readonly flag
     789         [ #  # ]:          0 :             sProp = sCfgName;
     790 [ #  # ][ #  # ]:          0 :             Reference< XPropertySetInfo > xInfo = pImpl->m_xPathSettings->getPropertySetInfo();
     791 [ #  # ][ #  # ]:          0 :             Property aProp = xInfo->getPropertyByName( sProp );
                 [ #  # ]
     792 [ #  # ][ #  # ]:          0 :             _rReadOnly = ( ( aProp.Attributes & PropertyAttribute::READONLY ) == PropertyAttribute::READONLY );
                 [ #  # ]
     793                 :            :         }
     794                 :            :     }
     795         [ #  # ]:          0 :     catch( const Exception& )
     796                 :            :     {
     797                 :            :         OSL_FAIL( "SvxPathTabPage::GetPathList(): caught an exception!" );
     798         [ #  # ]:          0 :     }
     799                 :          0 : }
     800                 :            : 
     801                 :            : // -----------------------------------------------------------------------
     802                 :            : 
     803                 :          0 : void SvxPathTabPage::SetPathList(
     804                 :            :     sal_uInt16 _nPathHandle, const String& _rUserPath, const String& _rWritablePath )
     805                 :            : {
     806         [ #  # ]:          0 :     String sCfgName = getCfgName_Impl( _nPathHandle );
     807                 :            : 
     808                 :            :     // load PathSettings service if necessary
     809         [ #  # ]:          0 :     if ( !pImpl->m_xPathSettings.is() )
     810                 :            :     {
     811         [ #  # ]:          0 :         Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory();
     812         [ #  # ]:          0 :         pImpl->m_xPathSettings = Reference< XPropertySet >( xSMgr->createInstance(
     813                 :            :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
     814 [ #  # ][ #  # ]:          0 :                 "com.sun.star.util.PathSettings") ) ), UNO_QUERY );
         [ #  # ][ #  # ]
     815                 :            :     }
     816                 :            : 
     817                 :            :     try
     818                 :            :     {
     819         [ #  # ]:          0 :         if ( pImpl->m_xPathSettings.is() )
     820                 :            :         {
     821                 :            :             // save user paths
     822                 :          0 :             char cDelim = MULTIPATH_DELIMITER;
     823 [ #  # ][ #  # ]:          0 :             sal_uInt16 nCount = comphelper::string::getTokenCount(_rUserPath, cDelim);
     824         [ #  # ]:          0 :             Sequence< ::rtl::OUString > aPathSeq( nCount );
     825         [ #  # ]:          0 :             ::rtl::OUString* pArray = aPathSeq.getArray();
     826         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < nCount; ++i )
     827 [ #  # ][ #  # ]:          0 :                 pArray[i] = ::rtl::OUString( _rUserPath.GetToken( i, cDelim ) );
                 [ #  # ]
     828         [ #  # ]:          0 :             String sProp( sCfgName );
     829         [ #  # ]:          0 :             sProp += POSTFIX_USER;
     830         [ #  # ]:          0 :             Any aValue = makeAny( aPathSeq );
     831 [ #  # ][ #  # ]:          0 :             pImpl->m_xPathSettings->setPropertyValue( sProp, aValue );
                 [ #  # ]
     832                 :            : 
     833                 :            :             // then the writable path
     834 [ #  # ][ #  # ]:          0 :             aValue = makeAny( ::rtl::OUString( _rWritablePath ) );
     835         [ #  # ]:          0 :             sProp = sCfgName;
     836         [ #  # ]:          0 :             sProp += POSTFIX_WRITABLE;
     837 [ #  # ][ #  # ]:          0 :             pImpl->m_xPathSettings->setPropertyValue( sProp, aValue );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     838                 :            :         }
     839                 :            :     }
     840         [ #  # ]:          0 :     catch( const Exception& e )
     841                 :            :     {
     842                 :            :         SAL_WARN("cui", "caught: " << e.Message);
     843         [ #  # ]:          0 :     }
     844                 :          0 : }
     845                 :            : 
     846                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10