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