LCOV - code coverage report
Current view: top level - fpicker/source/office - iodlgimp.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 106 0.9 %
Date: 2015-06-13 12:38:46 Functions: 2 26 7.7 %
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 <osl/getglobalmutex.hxx>
      41             : #include <svl/svl.hrc>
      42             : 
      43             : using namespace ::com::sun::star::uno;
      44             : using namespace ::com::sun::star::lang;
      45             : using namespace ::utl;
      46             : 
      47             : 
      48             : // ResMgrHolder / SvtSimpleResId
      49             : 
      50             : namespace
      51             : {
      52             :     struct ResMgrHolder
      53             :     {
      54           0 :         ResMgr * operator ()()
      55             :         {
      56           0 :             return ResMgr::CreateResMgr ("svl");
      57             :         }
      58           0 :         static ResMgr * getOrCreate()
      59             :         {
      60             :             return rtl_Instance<
      61             :                 ResMgr, ResMgrHolder,
      62             :                 osl::MutexGuard, osl::GetGlobalMutex >::create (
      63           0 :                     ResMgrHolder(), osl::GetGlobalMutex());
      64             :         }
      65             :     };
      66             : 
      67             :     struct SvtSimpleResId : public ResId
      68             :     {
      69           0 :         SvtSimpleResId (sal_uInt16 nId) : ResId (nId, *ResMgrHolder::getOrCreate()) {}
      70             :     };
      71             : }
      72             : 
      73           0 : SvtFileDialogFilter_Impl::SvtFileDialogFilter_Impl( const OUString& rName, const OUString& rType )
      74             :     :m_aName( rName )
      75           0 :     ,m_aType( rType )
      76             : {
      77           0 :     m_aType = m_aType.toAsciiLowerCase();
      78           0 : }
      79             : 
      80             : 
      81             : 
      82           0 : SvtFileDialogFilter_Impl::~SvtFileDialogFilter_Impl()
      83             : {
      84           0 : }
      85             : 
      86             : 
      87             : // SvtFileDialogFilterList_Impl
      88             : 
      89             : 
      90             : 
      91             : //= SvtFileDialogURLSelector
      92             : 
      93             : 
      94             : 
      95           0 : SvtFileDialogURLSelector::SvtFileDialogURLSelector( vcl::Window* _pParent, SvtFileDialog* _pDlg, WinBits nBits, sal_uInt16 _nButtonId )
      96             :     :MenuButton ( _pParent, nBits )
      97             :     ,m_pDlg     ( _pDlg )
      98           0 :     ,m_pMenu    ( new PopupMenu )
      99             : {
     100           0 :     SetStyle( GetStyle() | WB_NOPOINTERFOCUS | WB_RECTSTYLE | WB_SMALLSTYLE );
     101           0 :     SetModeImage( _pDlg->GetButtonImage( _nButtonId ) );
     102           0 :     SetMenuMode( MENUBUTTON_MENUMODE_TIMED );
     103           0 :     SetDropDown( PushButtonDropdownStyle::Toolbox );
     104           0 : }
     105             : 
     106             : 
     107           0 : SvtFileDialogURLSelector::~SvtFileDialogURLSelector()
     108             : {
     109           0 :     disposeOnce();
     110           0 : }
     111             : 
     112           0 : void SvtFileDialogURLSelector::dispose()
     113             : {
     114           0 :     delete m_pMenu;
     115           0 :     m_pDlg.clear();
     116           0 :     MenuButton::dispose();
     117           0 : }
     118             : 
     119             : 
     120           0 : void SvtFileDialogURLSelector::Activate()
     121             : {
     122           0 :     m_pMenu->Clear();
     123             : 
     124           0 :     FillURLMenu( m_pMenu );
     125             : 
     126           0 :     SetPopupMenu( m_pMenu );
     127           0 : }
     128             : 
     129             : 
     130             : //= SvtUpButton_Impl
     131             : 
     132             : 
     133             : 
     134           0 : SvtUpButton_Impl::SvtUpButton_Impl( vcl::Window *pParent, SvtFileDialog* pDlg, WinBits nBits )
     135           0 :     :SvtFileDialogURLSelector( pParent, pDlg, nBits, IMG_FILEDLG_BTN_UP )
     136             : {
     137           0 : }
     138             : 
     139             : 
     140           0 : SvtUpButton_Impl::~SvtUpButton_Impl()
     141             : {
     142           0 : }
     143             : 
     144             : 
     145           0 : void SvtUpButton_Impl::FillURLMenu( PopupMenu* _pMenu )
     146             : {
     147           0 :     SvtFileView* pBox = GetDialogParent()->GetView();
     148             : 
     149           0 :     sal_uInt16 nItemId = 1;
     150             : 
     151           0 :     _aURLs.clear();
     152             : 
     153             :     // determine parent levels
     154           0 :     INetURLObject aObject( pBox->GetViewURL() );
     155           0 :     sal_Int32 nCount = aObject.getSegmentCount();
     156             : 
     157             :     ::svtools::VolumeInfo aVolInfo( true /* volume */, false /* remote */,
     158             :                                     false /* removable */, false /* floppy */,
     159           0 :                                     false /* compact disk */ );
     160           0 :     Image aVolumeImage( SvFileInformationManager::GetFolderImage( aVolInfo ) );
     161             : 
     162           0 :     while ( nCount >= 1 )
     163             :     {
     164           0 :         aObject.removeSegment();
     165           0 :         OUString aParentURL(aObject.GetMainURL(INetURLObject::NO_DECODE));
     166             : 
     167           0 :         OUString aTitle;
     168             :         // 97148# --------------------------------
     169           0 :         if (!GetDialogParent()->ContentGetTitle(aParentURL, aTitle) || aTitle.isEmpty())
     170           0 :             aTitle = aObject.getName();
     171             : 
     172             :         Image aImage = ( nCount > 1 ) // if nCount == 1 means workplace, which detects the wrong image
     173           0 :             ? SvFileInformationManager::GetImage( aObject ) : aVolumeImage;
     174             : 
     175           0 :         _pMenu->InsertItem( nItemId++, aTitle, aImage );
     176           0 :         _aURLs.push_back(aParentURL);
     177             : 
     178           0 :         if ( nCount == 1 )
     179             :         {
     180             :             // adjust the title of the top level entry (the workspace)
     181           0 :             _pMenu->SetItemText( --nItemId, SvtSimpleResId(STR_SVT_MIMETYPE_CNT_FSYSBOX).toString() );
     182             :         }
     183           0 :         --nCount;
     184           0 :     }
     185           0 : }
     186             : 
     187             : 
     188           0 : void SvtUpButton_Impl::Select()
     189             : {
     190           0 :     sal_uInt16 nId = GetCurItemId();
     191             : 
     192           0 :     if ( nId )
     193             :     {
     194           0 :         --nId;
     195             :         DBG_ASSERT( nId <= _aURLs.size(), "SvtUpButton_Impl:falscher Index" );
     196             : 
     197           0 :         GetDialogParent()->OpenURL_Impl(_aURLs[nId]);
     198             :     }
     199           0 : }
     200             : 
     201           0 : void SvtUpButton_Impl::Click()
     202             : {
     203           0 :     GetDialogParent()->PrevLevel_Impl();
     204           0 : }
     205             : 
     206           0 : Size SvtUpButton_Impl::GetOptimalSize() const
     207             : {
     208           0 :     return LogicToPixel(Size(12, 12), MAP_APPFONT);
     209             : }
     210             : 
     211             : // SvtExpFileDlg_Impl
     212           0 : SvtExpFileDlg_Impl::SvtExpFileDlg_Impl( WinBits )   :
     213             : 
     214             :     _pCurFilter         ( NULL ),
     215           0 :     _pFilter            ( new SvtFileDialogFilterList_Impl() ),
     216             :     _pUserFilter        ( NULL ),
     217             :     _pFtFileName        ( NULL ),
     218             :     _pEdFileName        ( NULL ),
     219             :     _pFtFileVersion     ( NULL ),
     220             :     _pLbFileVersion     ( NULL ),
     221             :     _pFtTemplates       ( NULL ),
     222             :     _pLbTemplates       ( NULL ),
     223             :     _pFtImageTemplates  ( NULL ),
     224             :     _pLbImageTemplates  ( NULL ),
     225             :     _pFtFileType        ( NULL ),
     226             :     _pLbFilter          ( NULL ),
     227             :     _pBtnFileOpen       ( NULL ),
     228             :     _pBtnCancel         ( NULL ),
     229             :     _pBtnHelp           ( NULL ),
     230             :     _pBtnUp             ( NULL ),
     231             :     _pBtnNewFolder      ( NULL ),
     232             :     _pCbPassword        ( NULL ),
     233             :     _pEdCurrentPath     ( NULL ),
     234             :     _pCbAutoExtension   ( NULL ),
     235             :     _pCbOptions         ( NULL ),
     236             :     _pPlaces            ( NULL ),
     237             :     _pBtnConnectToServer( NULL ),
     238             :     _eMode              ( FILEDLG_MODE_OPEN ),
     239             :     _eDlgType           ( FILEDLG_TYPE_FILEDLG ),
     240             :     _nState             ( FILEDLG_STATE_REMOTE ),
     241             :     _nStyle             ( 0 ),
     242             :     _bDoubleClick       ( false ),
     243             :     m_bNeedDelayedFilterExecute ( false ),
     244             :     _pDefaultFilter     ( NULL ),
     245             :     _bMultiSelection    ( false ),
     246           0 :     _bFolderHasOpened   ( false )
     247             : {
     248           0 : }
     249             : 
     250             : 
     251             : 
     252           0 : SvtExpFileDlg_Impl::~SvtExpFileDlg_Impl()
     253             : {
     254           0 :     _pBtnUp.disposeAndClear();
     255           0 :     delete _pUserFilter;
     256           0 :     delete _pFilter;
     257           0 :     _pPlaces.disposeAndClear();
     258           0 : }
     259             : 
     260             : 
     261             : 
     262           0 : void SvtExpFileDlg_Impl::SetStandardDir( const OUString& _rDir )
     263             : {
     264           0 :     _aStdDir = _rDir;
     265           0 :     if ( _aStdDir.isEmpty() )
     266           0 :         _aStdDir = "file:///";
     267           0 : }
     268             : 
     269             : 
     270             : #if defined DBG_UTIL
     271             : 
     272             : namespace {
     273             :     OUString lcl_DecoratedFilter( const OUString& _rOriginalFilter )
     274             :     {
     275             :         OUStringBuffer aDecoratedFilter;
     276             :         aDecoratedFilter.append('<');
     277             :         aDecoratedFilter.append(_rOriginalFilter);
     278             :         aDecoratedFilter.append('>');
     279             :         return aDecoratedFilter.makeStringAndClear();
     280             :     }
     281             : }
     282             : #endif
     283             : 
     284             : 
     285           0 : void SvtExpFileDlg_Impl::ClearFilterList( )
     286             : {
     287           0 :     _pLbFilter->Clear();
     288           0 : }
     289             : 
     290             : 
     291           0 : void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl* pFilter, const OUString& rDisplayName )
     292             : {
     293             :     DBG_ASSERT( pFilter, "SvtExpFileDlg_Impl::SetCurFilter: invalid filter!" );
     294             :     DBG_ASSERT( ( rDisplayName == pFilter->GetName() )
     295             :             ||  ( rDisplayName == lcl_DecoratedFilter( pFilter->GetName() ) ),
     296             :             "SvtExpFileDlg_Impl::SetCurFilter: arguments are inconsistent!" );
     297             : 
     298           0 :     _pCurFilter = pFilter;
     299           0 :     m_sCurrentFilterDisplayName = rDisplayName;
     300           0 : }
     301             : 
     302             : 
     303           0 : void SvtExpFileDlg_Impl::InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc )
     304             : {
     305           0 :     OUString sName = _pFilterDesc->GetName();
     306           0 :     if ( _pFilterDesc->isGroupSeparator() )
     307           0 :         sName = "------------------------------------------";
     308             :     else
     309           0 :         sName = _pFilterDesc->GetName();
     310             : 
     311             :     // insert an set user data
     312           0 :     sal_uInt16 nPos = _pLbFilter->InsertEntry( sName );
     313           0 :     _pLbFilter->SetEntryData( nPos, const_cast< void* >( static_cast< const void* >( _pFilterDesc ) ) );
     314           0 : }
     315             : 
     316             : 
     317             : 
     318           0 : void SvtExpFileDlg_Impl::InitFilterList( )
     319             : {
     320             :     // clear the current list
     321           0 :     ClearFilterList( );
     322             : 
     323             :     // reinit it
     324           0 :     sal_uInt16 nPos = _pFilter->size();
     325             : 
     326             :     // search for the first entry which is no group separator
     327           0 :     while ( nPos-- && (*_pFilter)[ nPos ].isGroupSeparator() )
     328             :         ;
     329             : 
     330             :     // add all following entries
     331           0 :     while ( (sal_Int16)nPos >= 0 )
     332           0 :         InsertFilterListEntry( &(*_pFilter)[ nPos-- ] );
     333           3 : }
     334             : 
     335             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11