LCOV - code coverage report
Current view: top level - fpicker/source/office - iodlgimp.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 101 1.0 %
Date: 2014-11-03 Functions: 2 25 8.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( vcl::Window* _pParent, SvtFileDialog* _pDlg, WinBits nBits, sal_uInt16 _nButtonId )
      95             :     :MenuButton ( _pParent, nBits )
      96             :     ,m_pDlg     ( _pDlg )
      97           0 :     ,m_pMenu    ( new PopupMenu )
      98             : {
      99           0 :     SetStyle( GetStyle() | WB_NOPOINTERFOCUS | WB_RECTSTYLE | WB_SMALLSTYLE );
     100           0 :     SetModeImage( _pDlg->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( vcl::Window *pParent, SvtFileDialog* pDlg, WinBits nBits )
     127           0 :     :SvtFileDialogURLSelector( pParent, pDlg, nBits, 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           0 : void SvtUpButton_Impl::Click()
     194             : {
     195           0 :     GetDialogParent()->PrevLevel_Impl();
     196           0 : }
     197             : 
     198           0 : Size SvtUpButton_Impl::GetOptimalSize() const
     199             : {
     200           0 :     return LogicToPixel(Size(12, 12), MAP_APPFONT);
     201             : }
     202             : 
     203             : // SvtExpFileDlg_Impl
     204           0 : SvtExpFileDlg_Impl::SvtExpFileDlg_Impl( WinBits )   :
     205             : 
     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             :     _pLbFilter          ( NULL ),
     219             :     _pBtnFileOpen       ( NULL ),
     220             :     _pBtnCancel         ( NULL ),
     221             :     _pBtnHelp           ( NULL ),
     222             :     _pBtnUp             ( NULL ),
     223             :     _pBtnNewFolder      ( NULL ),
     224             :     _pCbPassword        ( NULL ),
     225             :     _pEdCurrentPath     ( NULL ),
     226             :     _pCbAutoExtension   ( NULL ),
     227             :     _pCbOptions         ( NULL ),
     228             :     _pPlaces            ( NULL ),
     229             :     _pBtnConnectToServer( NULL ),
     230             :     _eMode              ( FILEDLG_MODE_OPEN ),
     231             :     _eDlgType           ( FILEDLG_TYPE_FILEDLG ),
     232             :     _nState             ( FILEDLG_STATE_REMOTE ),
     233             :     _nStyle             ( 0 ),
     234             :     _bDoubleClick       ( false ),
     235             :     m_bNeedDelayedFilterExecute ( false ),
     236             :     _pDefaultFilter     ( NULL ),
     237             :     _bMultiSelection    ( false ),
     238           0 :     _bFolderHasOpened   ( false )
     239             : {
     240           0 : }
     241             : 
     242             : 
     243             : 
     244           0 : SvtExpFileDlg_Impl::~SvtExpFileDlg_Impl()
     245             : {
     246           0 :     delete _pBtnUp;
     247           0 :     delete _pUserFilter;
     248           0 :     delete _pFilter;
     249           0 :     delete _pPlaces;
     250           0 : }
     251             : 
     252             : 
     253             : 
     254           0 : void SvtExpFileDlg_Impl::SetStandardDir( const OUString& _rDir )
     255             : {
     256           0 :     _aStdDir = _rDir;
     257           0 :     if ( _aStdDir.isEmpty() )
     258           0 :         _aStdDir = "file:///";
     259           0 : }
     260             : 
     261             : 
     262             : #if defined DBG_UTIL
     263             : 
     264             : namespace {
     265             :     OUString lcl_DecoratedFilter( const OUString& _rOriginalFilter )
     266             :     {
     267             :         OUStringBuffer aDecoratedFilter;
     268             :         aDecoratedFilter.append('<');
     269             :         aDecoratedFilter.append(_rOriginalFilter);
     270             :         aDecoratedFilter.append('>');
     271             :         return aDecoratedFilter.makeStringAndClear();
     272             :     }
     273             : }
     274             : #endif
     275             : 
     276             : 
     277           0 : void SvtExpFileDlg_Impl::ClearFilterList( )
     278             : {
     279           0 :     _pLbFilter->Clear();
     280           0 : }
     281             : 
     282             : 
     283           0 : void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl* pFilter, const OUString& rDisplayName )
     284             : {
     285             :     DBG_ASSERT( pFilter, "SvtExpFileDlg_Impl::SetCurFilter: invalid filter!" );
     286             :     DBG_ASSERT( ( rDisplayName == pFilter->GetName() )
     287             :             ||  ( rDisplayName == lcl_DecoratedFilter( pFilter->GetName() ) ),
     288             :             "SvtExpFileDlg_Impl::SetCurFilter: arguments are inconsistent!" );
     289             : 
     290           0 :     _pCurFilter = pFilter;
     291           0 :     m_sCurrentFilterDisplayName = rDisplayName;
     292           0 : }
     293             : 
     294             : 
     295           0 : void SvtExpFileDlg_Impl::InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc )
     296             : {
     297           0 :     OUString sName = _pFilterDesc->GetName();
     298           0 :     if ( _pFilterDesc->isGroupSeparator() )
     299           0 :         sName = "------------------------------------------";
     300             :     else
     301           0 :         sName = _pFilterDesc->GetName();
     302             : 
     303             :     // insert an set user data
     304           0 :     sal_uInt16 nPos = _pLbFilter->InsertEntry( sName );
     305           0 :     _pLbFilter->SetEntryData( nPos, const_cast< void* >( static_cast< const void* >( _pFilterDesc ) ) );
     306           0 : }
     307             : 
     308             : 
     309             : 
     310           0 : void SvtExpFileDlg_Impl::InitFilterList( )
     311             : {
     312             :     // clear the current list
     313           0 :     ClearFilterList( );
     314             : 
     315             :     // reinit it
     316           0 :     sal_uInt16 nPos = _pFilter->size();
     317             : 
     318             :     // search for the first entry which is no group separator
     319           0 :     while ( nPos-- && (*_pFilter)[ nPos ].isGroupSeparator() )
     320             :         ;
     321             : 
     322             :     // add all following entries
     323           0 :     while ( (sal_Int16)nPos >= 0 )
     324           0 :         InsertFilterListEntry( &(*_pFilter)[ nPos-- ] );
     325           6 : }
     326             : 
     327             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10