LCOV - code coverage report
Current view: top level - fpicker/source/office - iodlgimp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 123 0.0 %
Date: 2014-04-14 Functions: 0 25 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "iodlgimp.hxx"
      21             : #include "svtools/headbar.hxx"
      22             : #include <tools/debug.hxx>
      23             : #include <tools/urlobj.hxx>
      24             : #include <vcl/menu.hxx>
      25             : #include <vcl/msgbox.hxx>
      26             : #include <vcl/lstbox.hxx>
      27             : #include <vcl/svapp.hxx>
      28             : // #97148# ---------------
      29             : #include "svl/ctypeitm.hxx"
      30             : #include "svl/eitem.hxx"
      31             : #include "unotools/viewoptions.hxx"
      32             : #include "svtools/fileview.hxx"
      33             : #include "svtools/inettbc.hxx"
      34             : #include "iodlg.hxx"
      35             : #include "iodlg.hrc"
      36             : #include "svtools/imagemgr.hxx"
      37             : #include <unotools/localfilehelper.hxx>
      38             : #include "unotools/useroptions.hxx"
      39             : #include "rtl/instance.hxx"
      40             : #include <svl/svl.hrc>
      41             : 
      42             : using namespace ::com::sun::star::uno;
      43             : using namespace ::com::sun::star::lang;
      44             : using namespace ::utl;
      45             : 
      46             : 
      47             : // ResMgrHolder / SvtSimpleResId
      48             : 
      49             : namespace
      50             : {
      51             :     struct ResMgrHolder
      52             :     {
      53           0 :         ResMgr * operator ()()
      54             :         {
      55           0 :             return ResMgr::CreateResMgr ("svl");
      56             :         }
      57           0 :         static ResMgr * getOrCreate()
      58             :         {
      59             :             return rtl_Instance<
      60             :                 ResMgr, ResMgrHolder,
      61             :                 osl::MutexGuard, osl::GetGlobalMutex >::create (
      62           0 :                     ResMgrHolder(), osl::GetGlobalMutex());
      63             :         }
      64             :     };
      65             : 
      66             :     struct SvtSimpleResId : public ResId
      67             :     {
      68           0 :         SvtSimpleResId (sal_uInt16 nId) : ResId (nId, *ResMgrHolder::getOrCreate()) {}
      69             :     };
      70             : }
      71             : 
      72           0 : SvtFileDialogFilter_Impl::SvtFileDialogFilter_Impl( const OUString& rName, const OUString& rType )
      73             :     :m_aName( rName )
      74           0 :     ,m_aType( rType )
      75             : {
      76           0 :     m_aType = m_aType.toAsciiLowerCase();
      77           0 : }
      78             : 
      79             : 
      80             : 
      81           0 : SvtFileDialogFilter_Impl::~SvtFileDialogFilter_Impl()
      82             : {
      83           0 : }
      84             : 
      85             : 
      86             : // SvtFileDialogFilterList_Impl
      87             : 
      88             : 
      89             : 
      90             : //= SvtFileDialogURLSelector
      91             : 
      92             : 
      93             : 
      94           0 : SvtFileDialogURLSelector::SvtFileDialogURLSelector( SvtFileDialog* _pParent, const ResId& _rResId, sal_uInt16 _nButtonId )
      95             :     :MenuButton ( _pParent, _rResId )
      96             :     ,m_pParent  ( _pParent )
      97           0 :     ,m_pMenu    ( new PopupMenu )
      98             : {
      99           0 :     SetStyle( GetStyle() | WB_NOPOINTERFOCUS | WB_RECTSTYLE | WB_SMALLSTYLE );
     100           0 :     SetModeImage( m_pParent->GetButtonImage( _nButtonId ) );
     101           0 :     SetMenuMode( MENUBUTTON_MENUMODE_TIMED );
     102           0 :     SetDropDown( PUSHBUTTON_DROPDOWN_TOOLBOX );
     103           0 : }
     104             : 
     105             : 
     106           0 : SvtFileDialogURLSelector::~SvtFileDialogURLSelector()
     107             : {
     108           0 :     delete m_pMenu;
     109           0 : }
     110             : 
     111             : 
     112           0 : void SvtFileDialogURLSelector::Activate()
     113             : {
     114           0 :     m_pMenu->Clear();
     115             : 
     116           0 :     FillURLMenu( m_pMenu );
     117             : 
     118           0 :     SetPopupMenu( m_pMenu );
     119           0 : }
     120             : 
     121             : 
     122             : //= SvtUpButton_Impl
     123             : 
     124             : 
     125             : 
     126           0 : SvtUpButton_Impl::SvtUpButton_Impl( SvtFileDialog* pParent, const ResId& rResId )
     127           0 :     :SvtFileDialogURLSelector( pParent, rResId, IMG_FILEDLG_BTN_UP )
     128             : {
     129           0 : }
     130             : 
     131             : 
     132           0 : SvtUpButton_Impl::~SvtUpButton_Impl()
     133             : {
     134           0 : }
     135             : 
     136             : 
     137           0 : void SvtUpButton_Impl::FillURLMenu( PopupMenu* _pMenu )
     138             : {
     139           0 :     SvtFileView* pBox = GetDialogParent()->GetView();
     140             : 
     141           0 :     sal_uInt16 nItemId = 1;
     142             : 
     143           0 :     _aURLs.clear();
     144             : 
     145             :     // determine parent levels
     146           0 :     INetURLObject aObject( pBox->GetViewURL() );
     147           0 :     sal_Int32 nCount = aObject.getSegmentCount();
     148             : 
     149             :     ::svtools::VolumeInfo aVolInfo( true /* volume */, false /* remote */,
     150             :                                     false /* removable */, false /* floppy */,
     151           0 :                                     false /* compact disk */ );
     152           0 :     Image aVolumeImage( SvFileInformationManager::GetFolderImage( aVolInfo ) );
     153             : 
     154           0 :     while ( nCount >= 1 )
     155             :     {
     156           0 :         aObject.removeSegment();
     157           0 :         OUString aParentURL(aObject.GetMainURL(INetURLObject::NO_DECODE));
     158             : 
     159           0 :         OUString aTitle;
     160             :         // 97148# --------------------------------
     161           0 :         if (!GetDialogParent()->ContentGetTitle(aParentURL, aTitle) || aTitle.isEmpty())
     162           0 :             aTitle = aObject.getName();
     163             : 
     164             :         Image aImage = ( nCount > 1 ) // if nCount == 1 means workplace, which detects the wrong image
     165           0 :             ? SvFileInformationManager::GetImage( aObject ) : aVolumeImage;
     166             : 
     167           0 :         _pMenu->InsertItem( nItemId++, aTitle, aImage );
     168           0 :         _aURLs.push_back(aParentURL);
     169             : 
     170           0 :         if ( nCount == 1 )
     171             :         {
     172             :             // adjust the title of the top level entry (the workspace)
     173           0 :             _pMenu->SetItemText( --nItemId, SvtSimpleResId(STR_SVT_MIMETYPE_CNT_FSYSBOX).toString() );
     174             :         }
     175           0 :         --nCount;
     176           0 :     }
     177           0 : }
     178             : 
     179             : 
     180           0 : void SvtUpButton_Impl::Select()
     181             : {
     182           0 :     sal_uInt16 nId = GetCurItemId();
     183             : 
     184           0 :     if ( nId )
     185             :     {
     186           0 :         --nId;
     187             :         DBG_ASSERT( nId <= _aURLs.size(), "SvtUpButton_Impl:falscher Index" );
     188             : 
     189           0 :         GetDialogParent()->OpenURL_Impl(_aURLs[nId]);
     190             :     }
     191           0 : }
     192             : 
     193             : 
     194           0 : void SvtUpButton_Impl::Click()
     195             : {
     196           0 :     GetDialogParent()->PrevLevel_Impl();
     197           0 : }
     198             : 
     199             : 
     200             : // SvtExpFileDlg_Impl
     201             : 
     202             : 
     203           0 : SvtExpFileDlg_Impl::SvtExpFileDlg_Impl( WinBits )   :
     204             : 
     205             :     _pLbFilter          ( NULL ),
     206             :     _pCurFilter         ( NULL ),
     207           0 :     _pFilter            ( new SvtFileDialogFilterList_Impl() ),
     208             :     _pUserFilter        ( NULL ),
     209             :     _pFtFileName        ( NULL ),
     210             :     _pEdFileName        ( NULL ),
     211             :     _pFtFileVersion     ( NULL ),
     212             :     _pLbFileVersion     ( NULL ),
     213             :     _pFtTemplates       ( NULL ),
     214             :     _pLbTemplates       ( NULL ),
     215             :     _pFtImageTemplates  ( NULL ),
     216             :     _pLbImageTemplates  ( NULL ),
     217             :     _pFtFileType        ( NULL ),
     218             :     _pBtnFileOpen       ( NULL ),
     219             :     _pBtnCancel         ( NULL ),
     220             :     _pBtnHelp           ( NULL ),
     221             :     _pBtnUp             ( NULL ),
     222             :     _pBtnNewFolder      ( NULL ),
     223             :     _pCbPassword        ( NULL ),
     224             :     _pEdCurrentPath     ( NULL ),
     225             :     _pCbAutoExtension   ( NULL ),
     226             :     _pCbOptions         ( NULL ),
     227             :     _pPlaces            ( NULL ),
     228             :     _pBtnConnectToServer( NULL ),
     229             :     _eMode              ( FILEDLG_MODE_OPEN ),
     230             :     _eDlgType           ( FILEDLG_TYPE_FILEDLG ),
     231             :     _nState             ( FILEDLG_STATE_REMOTE ),
     232             :     _nStyle             ( 0 ),
     233             :     _bDoubleClick       ( sal_False ),
     234             :     m_bNeedDelayedFilterExecute ( sal_False ),
     235             :     _pDefaultFilter     ( NULL ),
     236             :     _bMultiSelection    ( sal_False ),
     237             :     _nFixDeltaHeight    ( 0 ),
     238           0 :     _bFolderHasOpened   ( sal_False )
     239             : {
     240           0 : }
     241             : 
     242             : 
     243             : 
     244           0 : SvtExpFileDlg_Impl::~SvtExpFileDlg_Impl()
     245             : {
     246           0 :     delete _pEdCurrentPath;
     247           0 :     delete _pCbPassword;
     248           0 :     delete _pCbAutoExtension;
     249           0 :     delete _pCbOptions;
     250           0 :     delete _pBtnNewFolder;
     251           0 :     delete _pBtnUp;
     252           0 :     delete _pBtnHelp;
     253           0 :     delete _pBtnCancel;
     254           0 :     delete _pBtnFileOpen;
     255           0 :     delete _pLbFilter;
     256           0 :     delete _pFtFileType;
     257           0 :     delete _pLbFileVersion;
     258           0 :     delete _pFtFileVersion;
     259           0 :     delete _pFtTemplates;
     260           0 :     delete _pLbTemplates;
     261           0 :     delete _pFtImageTemplates;
     262           0 :     delete _pLbImageTemplates;
     263           0 :     delete _pEdFileName;
     264           0 :     delete _pFtFileName;
     265           0 :     delete _pUserFilter;
     266           0 :     delete _pFilter;
     267           0 :     delete _pPlaces;
     268           0 :     delete _pBtnConnectToServer;
     269           0 : }
     270             : 
     271             : 
     272             : 
     273           0 : void SvtExpFileDlg_Impl::SetStandardDir( const OUString& _rDir )
     274             : {
     275           0 :     _aStdDir = _rDir;
     276           0 :     if ( _aStdDir.isEmpty() )
     277           0 :         _aStdDir = "file:///";
     278           0 : }
     279             : 
     280             : 
     281             : #if defined DBG_UTIL
     282             : 
     283             : namespace {
     284             :     OUString lcl_DecoratedFilter( const OUString& _rOriginalFilter )
     285             :     {
     286             :         OUStringBuffer aDecoratedFilter;
     287             :         aDecoratedFilter.append('<');
     288             :         aDecoratedFilter.append(_rOriginalFilter);
     289             :         aDecoratedFilter.append('>');
     290             :         return aDecoratedFilter.makeStringAndClear();
     291             :     }
     292             : }
     293             : #endif
     294             : 
     295             : 
     296           0 : void SvtExpFileDlg_Impl::ClearFilterList( )
     297             : {
     298           0 :     _pLbFilter->Clear();
     299           0 : }
     300             : 
     301             : 
     302           0 : void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl* pFilter, const OUString& rDisplayName )
     303             : {
     304             :     DBG_ASSERT( pFilter, "SvtExpFileDlg_Impl::SetCurFilter: invalid filter!" );
     305             :     DBG_ASSERT( ( rDisplayName == pFilter->GetName() )
     306             :             ||  ( rDisplayName == lcl_DecoratedFilter( pFilter->GetName() ) ),
     307             :             "SvtExpFileDlg_Impl::SetCurFilter: arguments are inconsistent!" );
     308             : 
     309           0 :     _pCurFilter = pFilter;
     310           0 :     m_sCurrentFilterDisplayName = rDisplayName;
     311           0 : }
     312             : 
     313             : 
     314           0 : void SvtExpFileDlg_Impl::InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc )
     315             : {
     316           0 :     OUString sName = _pFilterDesc->GetName();
     317           0 :     if ( _pFilterDesc->isGroupSeparator() )
     318           0 :         sName = "------------------------------------------";
     319             :     else
     320           0 :         sName = _pFilterDesc->GetName();
     321             : 
     322             :     // insert an set user data
     323           0 :     sal_uInt16 nPos = _pLbFilter->InsertEntry( sName );
     324           0 :     _pLbFilter->SetEntryData( nPos, const_cast< void* >( static_cast< const void* >( _pFilterDesc ) ) );
     325           0 : }
     326             : 
     327             : 
     328             : 
     329           0 : void SvtExpFileDlg_Impl::InitFilterList( )
     330             : {
     331             :     // clear the current list
     332           0 :     ClearFilterList( );
     333             : 
     334             :     // reinit it
     335           0 :     sal_uInt16 nPos = _pFilter->size();
     336             : 
     337             :     // search for the first entry which is no group separator
     338           0 :     while ( nPos-- && (*_pFilter)[ nPos ].isGroupSeparator() )
     339             :         ;
     340             : 
     341             :     // add all following entries
     342           0 :     while ( (sal_Int16)nPos >= 0 )
     343           0 :         InsertFilterListEntry( &(*_pFilter)[ nPos-- ] );
     344           0 : }
     345             : 
     346             : 
     347             : 
     348           0 : void SvtExpFileDlg_Impl::CreateFilterListControl( Window* _pParent, const ResId& _rId )
     349             : {
     350             :     DBG_ASSERT( !_pLbFilter, "SvtExpFileDlg_Impl::CreateFilterListControl: already created the control!" );
     351           0 :     if ( !_pLbFilter )
     352             :     {
     353           0 :         _pLbFilter = new ListBox( _pParent, _rId );
     354           0 :         _pLbFilter->SetDropDownLineCount( 10 );
     355             :     }
     356           0 : }
     357             : 
     358             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10