LCOV - code coverage report
Current view: top level - cui/source/options - dbregister.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 227 0.0 %
Date: 2012-08-25 Functions: 0 29 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 440 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 "dbregister.hxx"
      30                 :            : #include "dbregister.hrc"
      31                 :            : #include "dbregistersettings.hxx"
      32                 :            : #include "connpooloptions.hxx"
      33                 :            : #include <svl/filenotation.hxx>
      34                 :            : #include "helpid.hrc"
      35                 :            : #include <svtools/editbrowsebox.hxx>
      36                 :            : #include <cuires.hrc>
      37                 :            : #include <vcl/field.hxx>
      38                 :            : #include <svl/eitem.hxx>
      39                 :            : #include <comphelper/processfactory.hxx>
      40                 :            : #include <com/sun/star/uno/Exception.hpp>
      41                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      42                 :            : #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
      43                 :            : #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
      44                 :            : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      45                 :            : #include <vcl/msgbox.hxx>
      46                 :            : #include <svtools/svtabbx.hxx>
      47                 :            : #include <svl/itemset.hxx>
      48                 :            : #include "doclinkdialog.hxx"
      49                 :            : #include <unotools/localfilehelper.hxx>
      50                 :            : #include "optHeaderTabListbox.hxx"
      51                 :            : #include <sfx2/docfilt.hxx>
      52                 :            : #include <dialmgr.hxx>
      53                 :            : #include "dbregisterednamesconfig.hxx"
      54                 :            : #include <svx/dialogs.hrc>
      55                 :            : 
      56                 :            : #define TAB_WIDTH1      80
      57                 :            : #define TAB_WIDTH_MIN   10
      58                 :            : #define TAB_WIDTH2      1000
      59                 :            : #define ITEMID_TYPE       1
      60                 :            : #define ITEMID_PATH       2
      61                 :            : //........................................................................
      62                 :            : namespace svx
      63                 :            : {
      64                 :            : //........................................................................
      65                 :            : 
      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 ::svt;
      70                 :            : 
      71                 :            : // class RegistrationItemSetHolder  -------------------------------------------------
      72                 :            : 
      73                 :          0 : RegistrationItemSetHolder::RegistrationItemSetHolder( const SfxItemSet& _rMasterSet )
      74                 :          0 :     :m_aRegistrationItems( _rMasterSet )
      75                 :            : {
      76         [ #  # ]:          0 :     DbRegisteredNamesConfig::GetOptions( m_aRegistrationItems );
      77                 :          0 : }
      78                 :            : 
      79                 :          0 : RegistrationItemSetHolder::~RegistrationItemSetHolder()
      80                 :            : {
      81                 :          0 : }
      82                 :            : 
      83                 :            : // class DatabaseRegistrationDialog  ------------------------------------------------
      84                 :            : 
      85                 :          0 : DatabaseRegistrationDialog::DatabaseRegistrationDialog( Window* pParent, const SfxItemSet& rInAttrs )
      86                 :            :     :RegistrationItemSetHolder( rInAttrs )
      87         [ #  # ]:          0 :     ,SfxSingleTabDialog( pParent, getRegistrationItems(), RID_SFXPAGE_DBREGISTER )
      88                 :            : {
      89         [ #  # ]:          0 :     SfxTabPage* page = DbRegistrationOptionsPage::Create( this, getRegistrationItems() );
      90                 :            : 
      91         [ #  # ]:          0 :     SetTabPage( page );
      92 [ #  # ][ #  # ]:          0 :     SetText( page->GetText() );
                 [ #  # ]
      93                 :          0 : }
      94                 :            : 
      95         [ #  # ]:          0 : DatabaseRegistrationDialog::~DatabaseRegistrationDialog()
      96                 :            : {
      97         [ #  # ]:          0 : }
      98                 :            : 
      99                 :          0 : short DatabaseRegistrationDialog::Execute()
     100                 :            : {
     101                 :          0 :     short result = SfxSingleTabDialog::Execute();
     102         [ #  # ]:          0 :     if ( result == RET_OK )
     103                 :            :     {
     104                 :            :         DBG_ASSERT( GetOutputItemSet(), "DatabaseRegistrationDialog::Execute: no output items!" );
     105         [ #  # ]:          0 :         if ( GetOutputItemSet() )
     106                 :          0 :             DbRegisteredNamesConfig::SetOptions( *GetOutputItemSet() );
     107                 :            :     }
     108                 :          0 :     return result;
     109                 :            : }
     110                 :            : 
     111                 :            : // class DbRegistrationOptionsPage --------------------------------------------------
     112                 :            : 
     113                 :          0 : DbRegistrationOptionsPage::DbRegistrationOptionsPage( Window* pParent, const SfxItemSet& rSet ) :
     114                 :            : 
     115                 :          0 :     SfxTabPage( pParent, CUI_RES( RID_SFXPAGE_DBREGISTER), rSet ),
     116                 :            : 
     117         [ #  # ]:          0 :     aStdBox         ( this, CUI_RES( GB_STD ) ),
     118         [ #  # ]:          0 :     aTypeText       ( this, CUI_RES( FT_TYPE ) ),
     119         [ #  # ]:          0 :     aPathText       ( this, CUI_RES( FT_PATH ) ),
     120         [ #  # ]:          0 :     aPathCtrl       ( this, CUI_RES( LB_PATH ) ),
     121         [ #  # ]:          0 :     m_aNew          ( this, CUI_RES( BTN_NEW ) ),
     122         [ #  # ]:          0 :     m_aEdit         ( this, CUI_RES( BTN_EDIT ) ),
     123         [ #  # ]:          0 :     m_aDelete       ( this, CUI_RES( BTN_DELETE ) ),
     124                 :            :     pHeaderBar      ( NULL ),
     125                 :            :     pPathBox        ( NULL ),
     126                 :            :     m_pCurEntry     ( NULL ),
     127                 :            :     m_nOldCount     ( 0 ),
     128 [ #  # ][ #  # ]:          0 :     m_bModified     ( sal_False )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     129                 :            : {
     130         [ #  # ]:          0 :     m_aNew.SetClickHdl( LINK( this, DbRegistrationOptionsPage, NewHdl ) );
     131         [ #  # ]:          0 :     m_aEdit.SetClickHdl( LINK( this, DbRegistrationOptionsPage, EditHdl ) );
     132         [ #  # ]:          0 :     m_aDelete.SetClickHdl( LINK( this, DbRegistrationOptionsPage, DeleteHdl ) );
     133                 :            : 
     134                 :          0 :     Size aBoxSize = aPathCtrl.GetOutputSizePixel();
     135                 :            : 
     136                 :            : 
     137                 :          0 :     WinBits nBits = WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP;
     138 [ #  # ][ #  # ]:          0 :     pPathBox = new ::svx::OptHeaderTabListBox( &aPathCtrl, nBits );
     139                 :            : 
     140 [ #  # ][ #  # ]:          0 :     pHeaderBar = new HeaderBar( &aPathCtrl, WB_BUTTONSTYLE | WB_BOTTOMBORDER );
     141         [ #  # ]:          0 :     pHeaderBar->SetPosSizePixel( Point( 0, 0 ), Size( aBoxSize.Width(), 16 ) );
     142         [ #  # ]:          0 :     pHeaderBar->SetSelectHdl( LINK( this, DbRegistrationOptionsPage, HeaderSelect_Impl ) );
     143         [ #  # ]:          0 :     pHeaderBar->SetEndDragHdl( LINK( this, DbRegistrationOptionsPage, HeaderEndDrag_Impl ) );
     144                 :          0 :     Size aSz;
     145                 :          0 :     aSz.Width() = TAB_WIDTH1;
     146                 :            :     pHeaderBar->InsertItem( ITEMID_TYPE, aTypeText.GetText(),
     147 [ #  # ][ #  # ]:          0 :                             LogicToPixel( aSz, MapMode( MAP_APPFONT ) ).Width(),
                 [ #  # ]
     148 [ #  # ][ #  # ]:          0 :                             HIB_LEFT | HIB_VCENTER | HIB_CLICKABLE | HIB_UPARROW );
                 [ #  # ]
     149                 :          0 :     aSz.Width() = TAB_WIDTH2;
     150                 :            :     pHeaderBar->InsertItem( ITEMID_PATH, aPathText.GetText(),
     151 [ #  # ][ #  # ]:          0 :                             LogicToPixel( aSz, MapMode( MAP_APPFONT ) ).Width(),
                 [ #  # ]
     152 [ #  # ][ #  # ]:          0 :                             HIB_LEFT | HIB_VCENTER );
                 [ #  # ]
     153                 :            : 
     154                 :            :     static long nTabs[] = {3, 0, TAB_WIDTH1, TAB_WIDTH1 + TAB_WIDTH2 };
     155         [ #  # ]:          0 :     Size aHeadSize = pHeaderBar->GetSizePixel();
     156                 :            : 
     157                 :          0 :     aPathCtrl.SetFocusControl( pPathBox );
     158 [ #  # ][ #  # ]:          0 :     pPathBox->SetStyle( pPathBox->GetStyle()|nBits );
     159         [ #  # ]:          0 :     pPathBox->SetDoubleClickHdl( LINK( this, DbRegistrationOptionsPage, EditHdl ) );
     160         [ #  # ]:          0 :     pPathBox->SetSelectHdl( LINK( this, DbRegistrationOptionsPage, PathSelect_Impl ) );
     161         [ #  # ]:          0 :     pPathBox->SetSelectionMode( SINGLE_SELECTION );
     162                 :          0 :     pPathBox->SetPosSizePixel( Point( 0, aHeadSize.Height() ),
     163         [ #  # ]:          0 :                                Size( aBoxSize.Width(), aBoxSize.Height() - aHeadSize.Height() ) );
     164         [ #  # ]:          0 :     pPathBox->SetTabs( &nTabs[0], MAP_APPFONT );
     165         [ #  # ]:          0 :     pPathBox->InitHeaderBar( pHeaderBar );
     166         [ #  # ]:          0 :     pPathBox->SetHighlightRange();
     167                 :            : 
     168         [ #  # ]:          0 :     pPathBox->SetHelpId( HID_DBPATH_CTL_PATH );
     169         [ #  # ]:          0 :     pHeaderBar->SetHelpId( HID_DBPATH_HEADERBAR );
     170                 :            : 
     171         [ #  # ]:          0 :     pPathBox->Show();
     172         [ #  # ]:          0 :     pHeaderBar->Show();
     173                 :            : 
     174         [ #  # ]:          0 :     FreeResource();
     175                 :          0 : }
     176                 :            : 
     177                 :            : // -----------------------------------------------------------------------
     178                 :            : 
     179 [ #  # ][ #  # ]:          0 : DbRegistrationOptionsPage::~DbRegistrationOptionsPage()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     180                 :            : {
     181                 :            :     // #110603# do not grab focus to a destroyed window !!!
     182                 :          0 :     aPathCtrl.SetFocusControl( NULL );
     183                 :            : 
     184         [ #  # ]:          0 :     pHeaderBar->Hide();
     185         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < pPathBox->GetEntryCount(); ++i )
     186 [ #  # ][ #  # ]:          0 :         delete static_cast< DatabaseRegistration* >( pPathBox->GetEntry(i)->GetUserData() );
     187 [ #  # ][ #  # ]:          0 :     delete pPathBox;
     188 [ #  # ][ #  # ]:          0 :     delete pHeaderBar;
     189         [ #  # ]:          0 : }
     190                 :            : 
     191                 :            : // -----------------------------------------------------------------------
     192                 :            : 
     193                 :          0 : SfxTabPage* DbRegistrationOptionsPage::Create( Window* pParent,
     194                 :            :                                     const SfxItemSet& rAttrSet )
     195                 :            : {
     196         [ #  # ]:          0 :     return ( new DbRegistrationOptionsPage( pParent, rAttrSet ) );
     197                 :            : }
     198                 :            : 
     199                 :            : // -----------------------------------------------------------------------
     200                 :            : 
     201                 :          0 : sal_Bool DbRegistrationOptionsPage::FillItemSet( SfxItemSet& rCoreSet )
     202                 :            : {
     203                 :            :     // the settings for the single drivers
     204                 :          0 :     sal_Bool bModified = sal_False;
     205         [ #  # ]:          0 :     DatabaseRegistrations aRegistrations;
     206                 :          0 :     sal_uLong nCount = pPathBox->GetEntryCount();
     207         [ #  # ]:          0 :     for ( sal_uLong i = 0; i < nCount; ++i )
     208                 :            :     {
     209         [ #  # ]:          0 :         SvLBoxEntry* pEntry = pPathBox->GetEntry(i);
     210                 :          0 :         DatabaseRegistration* pRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() );
     211 [ #  # ][ #  # ]:          0 :         if ( pRegistration && !pRegistration->sLocation.isEmpty() )
                 [ #  # ]
     212                 :            :         {
     213 [ #  # ][ #  # ]:          0 :             ::rtl::OUString sName( pPathBox->GetEntryText( pEntry, 0 ) );
                 [ #  # ]
     214         [ #  # ]:          0 :             OFileNotation aTransformer( pRegistration->sLocation );
     215 [ #  # ][ #  # ]:          0 :             aRegistrations[ sName ] = DatabaseRegistration( aTransformer.get( OFileNotation::N_URL ), pRegistration->bReadOnly );
                 [ #  # ]
     216                 :            :         }
     217                 :            :     }
     218 [ #  # ][ #  # ]:          0 :     if ( m_nOldCount != aRegistrations.size() || m_bModified )
                 [ #  # ]
     219                 :            :     {
     220 [ #  # ][ #  # ]:          0 :         rCoreSet.Put(DatabaseMapItem( SID_SB_DB_REGISTER, aRegistrations ), SID_SB_DB_REGISTER);
                 [ #  # ]
     221                 :          0 :         bModified = sal_True;
     222                 :            :     }
     223                 :            : 
     224                 :          0 :     return bModified;
     225                 :            : }
     226                 :            : 
     227                 :            : // -----------------------------------------------------------------------
     228                 :            : 
     229                 :          0 : void DbRegistrationOptionsPage::Reset( const SfxItemSet& rSet )
     230                 :            : {
     231                 :            :     // the settings for the single drivers
     232 [ #  # ][ #  # ]:          0 :     SFX_ITEMSET_GET( rSet, pRegistrations, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True );
     233         [ #  # ]:          0 :     if ( !pRegistrations )
     234                 :          0 :         return;
     235                 :            : 
     236         [ #  # ]:          0 :     pPathBox->Clear();
     237                 :            : 
     238                 :          0 :     const DatabaseRegistrations& rRegistrations = pRegistrations->getRegistrations();
     239                 :          0 :     m_nOldCount = rRegistrations.size();
     240                 :          0 :     DatabaseRegistrations::const_iterator aIter = rRegistrations.begin();
     241                 :          0 :     DatabaseRegistrations::const_iterator aEnd = rRegistrations.end();
     242         [ #  # ]:          0 :     for ( ; aIter != aEnd; ++aIter )
     243                 :            :     {
     244         [ #  # ]:          0 :         OFileNotation aTransformer( aIter->second.sLocation );
     245 [ #  # ][ #  # ]:          0 :         insertNewEntry( aIter->first, aTransformer.get( OFileNotation::N_SYSTEM ), aIter->second.bReadOnly );
     246         [ #  # ]:          0 :     }
     247                 :            : 
     248         [ #  # ]:          0 :     String aUserData = GetUserData();
     249         [ #  # ]:          0 :     if ( aUserData.Len() )
     250                 :            :     {
     251                 :            :         // restore column width
     252 [ #  # ][ #  # ]:          0 :         pHeaderBar->SetItemSize( ITEMID_TYPE, aUserData.GetToken(0).ToInt32() );
         [ #  # ][ #  # ]
     253         [ #  # ]:          0 :         HeaderEndDrag_Impl( NULL );
     254                 :            :         // restore sort direction
     255 [ #  # ][ #  # ]:          0 :         sal_Bool bUp = (sal_Bool)(sal_uInt16)aUserData.GetToken(1).ToInt32();
                 [ #  # ]
     256         [ #  # ]:          0 :         HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE);
     257                 :            : 
     258         [ #  # ]:          0 :         if ( bUp )
     259                 :            :         {
     260                 :          0 :             nBits &= ~HIB_UPARROW;
     261                 :          0 :             nBits |= HIB_DOWNARROW;
     262                 :            :         }
     263                 :            :         else
     264                 :            :         {
     265                 :          0 :             nBits &= ~HIB_DOWNARROW;
     266                 :          0 :             nBits |= HIB_UPARROW;
     267                 :            :         }
     268         [ #  # ]:          0 :         pHeaderBar->SetItemBits( ITEMID_TYPE, nBits );
     269         [ #  # ]:          0 :         HeaderSelect_Impl( NULL );
     270         [ #  # ]:          0 :     }
     271                 :            : }
     272                 :            : 
     273                 :            : // -----------------------------------------------------------------------
     274                 :            : 
     275                 :          0 : void DbRegistrationOptionsPage::FillUserData()
     276                 :            : {
     277 [ #  # ][ #  # ]:          0 :     String aUserData = String::CreateFromInt32( pHeaderBar->GetItemSize( ITEMID_TYPE ) );
     278         [ #  # ]:          0 :     aUserData += ';';
     279         [ #  # ]:          0 :     HeaderBarItemBits nBits = pHeaderBar->GetItemBits( ITEMID_TYPE );
     280                 :          0 :     sal_Bool bUp = ( ( nBits & HIB_UPARROW ) == HIB_UPARROW );
     281 [ #  # ][ #  # ]:          0 :     aUserData += (bUp ? '1' : '0');
     282 [ #  # ][ #  # ]:          0 :     SetUserData( aUserData );
     283                 :          0 : }
     284                 :            : // -----------------------------------------------------------------------
     285                 :            : 
     286                 :          0 : IMPL_LINK_NOARG(DbRegistrationOptionsPage, DeleteHdl)
     287                 :            : {
     288                 :          0 :     SvLBoxEntry* pEntry = pPathBox->FirstSelected();
     289         [ #  # ]:          0 :     if ( pEntry )
     290                 :            :     {
     291 [ #  # ][ #  # ]:          0 :         QueryBox aQuery(this,CUI_RES(QUERY_DELETE_CONFIRM));
     292 [ #  # ][ #  # ]:          0 :         if ( aQuery.Execute() == RET_YES )
     293 [ #  # ][ #  # ]:          0 :             pPathBox->GetModel()->Remove(pEntry);
     294                 :            :     }
     295                 :          0 :     return 0;
     296                 :            : }
     297                 :            : // -----------------------------------------------------------------------
     298                 :          0 : IMPL_LINK_NOARG(DbRegistrationOptionsPage, NewHdl)
     299                 :            : {
     300 [ #  # ][ #  # ]:          0 :     String sNewName,sNewLocation;
     301         [ #  # ]:          0 :     openLinkDialog(sNewName,sNewLocation);
     302 [ #  # ][ #  # ]:          0 :     return 0;
     303                 :            : }
     304                 :            : 
     305                 :            : // -----------------------------------------------------------------------
     306                 :            : 
     307                 :          0 : IMPL_LINK_NOARG(DbRegistrationOptionsPage, EditHdl)
     308                 :            : {
     309         [ #  # ]:          0 :     SvLBoxEntry* pEntry = pPathBox->GetCurEntry();
     310         [ #  # ]:          0 :     if ( !pEntry )
     311                 :          0 :         return 0L;
     312                 :            : 
     313                 :          0 :     DatabaseRegistration* pOldRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() );
     314 [ #  # ][ #  # ]:          0 :     if ( !pOldRegistration || pOldRegistration->bReadOnly )
     315                 :          0 :         return 0L;
     316                 :            : 
     317         [ #  # ]:          0 :     String sOldName = pPathBox->GetEntryText(pEntry,0);
     318                 :          0 :     m_pCurEntry = pEntry;
     319 [ #  # ][ #  # ]:          0 :     openLinkDialog( sOldName, pOldRegistration->sLocation, pEntry );
                 [ #  # ]
     320                 :          0 :     m_pCurEntry = NULL;
     321                 :            : 
     322         [ #  # ]:          0 :     return 1L;
     323                 :            : }
     324                 :            : 
     325                 :            : // -----------------------------------------------------------------------
     326                 :            : 
     327                 :          0 : IMPL_LINK( DbRegistrationOptionsPage, HeaderSelect_Impl, HeaderBar*, pBar )
     328                 :            : {
     329 [ #  # ][ #  # ]:          0 :     if ( pBar && pBar->GetCurItemId() != ITEMID_TYPE )
                 [ #  # ]
     330                 :          0 :         return 0;
     331                 :            : 
     332                 :          0 :     HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE);
     333                 :          0 :     sal_Bool bUp = ( ( nBits & HIB_UPARROW ) == HIB_UPARROW );
     334                 :          0 :     SvSortMode eMode = SortAscending;
     335                 :            : 
     336         [ #  # ]:          0 :     if ( bUp )
     337                 :            :     {
     338                 :          0 :         nBits &= ~HIB_UPARROW;
     339                 :          0 :         nBits |= HIB_DOWNARROW;
     340                 :          0 :         eMode = SortDescending;
     341                 :            :     }
     342                 :            :     else
     343                 :            :     {
     344                 :          0 :         nBits &= ~HIB_DOWNARROW;
     345                 :          0 :         nBits |= HIB_UPARROW;
     346                 :            :     }
     347                 :          0 :     pHeaderBar->SetItemBits( ITEMID_TYPE, nBits );
     348                 :          0 :     SvTreeList* pModel = pPathBox->GetModel();
     349                 :          0 :     pModel->SetSortMode( eMode );
     350                 :          0 :     pModel->Resort();
     351                 :          0 :     return 1;
     352                 :            : }
     353                 :            : 
     354                 :            : // -----------------------------------------------------------------------
     355                 :            : 
     356                 :          0 : IMPL_LINK( DbRegistrationOptionsPage, HeaderEndDrag_Impl, HeaderBar*, pBar )
     357                 :            : {
     358 [ #  # ][ #  # ]:          0 :     if ( pBar && !pBar->GetCurItemId() )
                 [ #  # ]
     359                 :          0 :         return 0;
     360                 :            : 
     361         [ #  # ]:          0 :     if ( !pHeaderBar->IsItemMode() )
     362                 :            :     {
     363                 :          0 :         Size aSz;
     364         [ #  # ]:          0 :         sal_uInt16 nTabs = pHeaderBar->GetItemCount();
     365                 :          0 :         long nTmpSz = 0;
     366         [ #  # ]:          0 :         long nWidth = pHeaderBar->GetItemSize(ITEMID_TYPE);
     367         [ #  # ]:          0 :         long nBarWidth = pHeaderBar->GetSizePixel().Width();
     368                 :            : 
     369         [ #  # ]:          0 :         if(nWidth < TAB_WIDTH_MIN)
     370         [ #  # ]:          0 :             pHeaderBar->SetItemSize( ITEMID_TYPE, TAB_WIDTH_MIN);
     371         [ #  # ]:          0 :         else if ( ( nBarWidth - nWidth ) < TAB_WIDTH_MIN )
     372         [ #  # ]:          0 :             pHeaderBar->SetItemSize( ITEMID_TYPE, nBarWidth - TAB_WIDTH_MIN );
     373                 :            : 
     374         [ #  # ]:          0 :         for ( sal_uInt16 i = 1; i <= nTabs; ++i )
     375                 :            :         {
     376         [ #  # ]:          0 :             long _nWidth = pHeaderBar->GetItemSize(i);
     377                 :          0 :             aSz.Width() =  _nWidth + nTmpSz;
     378                 :          0 :             nTmpSz += _nWidth;
     379 [ #  # ][ #  # ]:          0 :             pPathBox->SetTab( i, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT );
         [ #  # ][ #  # ]
     380                 :            :         }
     381                 :            :     }
     382                 :          0 :     return 1;
     383                 :            : }
     384                 :            : // -----------------------------------------------------------------------
     385                 :            : 
     386                 :          0 : IMPL_LINK_NOARG(DbRegistrationOptionsPage, PathSelect_Impl)
     387                 :            : {
     388                 :          0 :     SvLBoxEntry* pEntry = pPathBox->FirstSelected();
     389                 :            : 
     390                 :          0 :     bool bReadOnly = true;
     391         [ #  # ]:          0 :     if ( pEntry )
     392                 :            :     {
     393                 :          0 :         DatabaseRegistration* pRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() );
     394                 :          0 :         bReadOnly = pRegistration->bReadOnly;
     395                 :            :     }
     396                 :            : 
     397                 :          0 :     m_aEdit.Enable( !bReadOnly );
     398                 :          0 :     m_aDelete.Enable( !bReadOnly );
     399                 :          0 :     return 0;
     400                 :            : }
     401                 :            : // -----------------------------------------------------------------------------
     402                 :          0 : void DbRegistrationOptionsPage::insertNewEntry( const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation, const bool _bReadOnly )
     403                 :            : {
     404         [ #  # ]:          0 :     String aStr( _sName );
     405         [ #  # ]:          0 :     aStr += '\t';
     406 [ #  # ][ #  # ]:          0 :     aStr += String(_sLocation);
                 [ #  # ]
     407                 :            : 
     408                 :          0 :     SvLBoxEntry* pEntry = NULL;
     409         [ #  # ]:          0 :     if ( _bReadOnly )
     410                 :            :     {
     411 [ #  # ][ #  # ]:          0 :         Image aLocked( CUI_RES( RID_SVXBMP_LOCK ) );
     412 [ #  # ][ #  # ]:          0 :         pEntry = pPathBox->InsertEntry( aStr, aLocked, aLocked );
     413                 :            :     }
     414                 :            :     else
     415                 :            :     {
     416         [ #  # ]:          0 :         pEntry = pPathBox->InsertEntry( aStr );
     417                 :            :     }
     418                 :            : 
     419 [ #  # ][ #  # ]:          0 :     pEntry->SetUserData( new DatabaseRegistration( _sLocation, _bReadOnly ) );
     420                 :          0 : }
     421                 :            : 
     422                 :            : // -----------------------------------------------------------------------------
     423                 :          0 : void DbRegistrationOptionsPage::openLinkDialog(const String& _sOldName,const String& _sOldLocation,SvLBoxEntry* _pEntry)
     424                 :            : {
     425         [ #  # ]:          0 :     ODocumentLinkDialog aDlg(this,_pEntry == NULL);
     426                 :            : 
     427         [ #  # ]:          0 :     aDlg.set(_sOldName,_sOldLocation);
     428         [ #  # ]:          0 :     aDlg.setNameValidator(LINK( this, DbRegistrationOptionsPage, NameValidator ) );
     429                 :            : 
     430 [ #  # ][ #  # ]:          0 :     if ( aDlg.Execute() == RET_OK )
     431                 :            :     {
     432 [ #  # ][ #  # ]:          0 :         String sNewName,sNewLocation;
     433         [ #  # ]:          0 :         aDlg.get(sNewName,sNewLocation);
     434 [ #  # ][ #  # ]:          0 :         if ( _pEntry == NULL || sNewName != _sOldName || sNewLocation != _sOldLocation )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     435                 :            :         {
     436         [ #  # ]:          0 :             if ( _pEntry )
     437                 :            :             {
     438         [ #  # ]:          0 :                 delete static_cast< DatabaseRegistration* >( _pEntry->GetUserData() );
     439         [ #  # ]:          0 :                 pPathBox->GetModel()->Remove( _pEntry );
     440                 :            :             }
     441 [ #  # ][ #  # ]:          0 :             insertNewEntry( sNewName, sNewLocation, false );
                 [ #  # ]
     442                 :          0 :             m_bModified = sal_True;
     443 [ #  # ][ #  # ]:          0 :         }
     444         [ #  # ]:          0 :     }
     445                 :          0 : }
     446                 :            : // -----------------------------------------------------------------------------
     447                 :          0 : IMPL_LINK( DbRegistrationOptionsPage, NameValidator, String*, _pName )
     448                 :            : {
     449         [ #  # ]:          0 :     if ( _pName )
     450                 :            :     {
     451                 :          0 :         sal_uLong nCount = pPathBox->GetEntryCount();
     452         [ #  # ]:          0 :         for ( sal_uLong i = 0; i < nCount; ++i )
     453                 :            :         {
     454                 :          0 :             SvLBoxEntry* pEntry = pPathBox->GetEntry(i);
     455 [ #  # ][ #  # ]:          0 :             if ( (!m_pCurEntry || m_pCurEntry != pEntry) && pPathBox->GetEntryText(pEntry,0) == *_pName )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     456                 :          0 :                 return 0L;
     457                 :            :         }
     458                 :            :     }
     459                 :          0 :     return 1L;
     460                 :            : }
     461                 :            : //........................................................................
     462                 :            : }   // namespace svx
     463                 :            : //........................................................................
     464                 :            : 
     465                 :            : 
     466                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10