LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/fpicker/source/office - iodlgimp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 123 0.0 %
Date: 2013-07-09 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             : // some stuff for easier changes for SvtViewOptions
      47             : static const sal_Char*      pViewOptDataName = "dialog data";
      48             : #define VIEWOPT_DATANAME    OUString::createFromAscii( pViewOptDataName )
      49             : 
      50             : static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const String& rData )
      51             : {
      52             :     rOpt.SetUserItem( VIEWOPT_DATANAME, makeAny( OUString( rData ) ) );
      53             : }
      54             : 
      55             : static inline String GetViewOptUserItem( const SvtViewOptions& rOpt )
      56             : {
      57             :     Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
      58             :     OUString aUserData;
      59             :     aAny >>= aUserData;
      60             : 
      61             :     return String( aUserData );
      62             : }
      63             : 
      64             : //*****************************************************************************
      65             : // ResMgrHolder / SvtSimpleResId
      66             : //*****************************************************************************
      67             : namespace
      68             : {
      69             :     struct ResMgrHolder
      70             :     {
      71           0 :         ResMgr * operator ()()
      72             :         {
      73           0 :             return ResMgr::CreateResMgr ("svl");
      74             :         }
      75           0 :         static ResMgr * getOrCreate()
      76             :         {
      77             :             return rtl_Instance<
      78             :                 ResMgr, ResMgrHolder,
      79             :                 osl::MutexGuard, osl::GetGlobalMutex >::create (
      80           0 :                     ResMgrHolder(), osl::GetGlobalMutex());
      81             :         }
      82             :     };
      83             : 
      84             :     struct SvtSimpleResId : public ResId
      85             :     {
      86           0 :         SvtSimpleResId (sal_uInt16 nId) : ResId (nId, *ResMgrHolder::getOrCreate()) {}
      87             :     };
      88             : }
      89             : 
      90             : //*****************************************************************************
      91             : // SvtFileDialogFilter_Impl
      92             : //*****************************************************************************
      93             : 
      94             : DBG_NAME( SvtFileDialogFilter_Impl )
      95           0 : SvtFileDialogFilter_Impl::SvtFileDialogFilter_Impl( const String& rName, const String& rType )
      96             :     :m_aName( rName )
      97           0 :     ,m_aType( rType )
      98             : {
      99             :     DBG_CTOR( SvtFileDialogFilter_Impl, NULL );
     100             : 
     101           0 :     m_aType.ToLowerAscii();
     102           0 : }
     103             : 
     104             : //*****************************************************************************
     105             : 
     106           0 : SvtFileDialogFilter_Impl::~SvtFileDialogFilter_Impl()
     107             : {
     108             :     DBG_DTOR( SvtFileDialogFilter_Impl, NULL );
     109           0 : }
     110             : 
     111             : //*****************************************************************************
     112             : // SvtFileDialogFilterList_Impl
     113             : //*****************************************************************************
     114             : 
     115             : //=============================================================================
     116             : //= SvtFileDialogURLSelector
     117             : //=============================================================================
     118             : 
     119             : //-----------------------------------------------------------------------------
     120           0 : SvtFileDialogURLSelector::SvtFileDialogURLSelector( SvtFileDialog* _pParent, const ResId& _rResId, sal_uInt16 _nButtonId )
     121             :     :MenuButton ( _pParent, _rResId )
     122             :     ,m_pParent  ( _pParent )
     123           0 :     ,m_pMenu    ( new PopupMenu )
     124             : {
     125           0 :     SetStyle( GetStyle() | WB_NOPOINTERFOCUS | WB_RECTSTYLE | WB_SMALLSTYLE );
     126           0 :     SetModeImage( m_pParent->GetButtonImage( _nButtonId ) );
     127           0 :     SetMenuMode( MENUBUTTON_MENUMODE_TIMED );
     128           0 :     SetDropDown( PUSHBUTTON_DROPDOWN_TOOLBOX );
     129           0 : }
     130             : 
     131             : //-----------------------------------------------------------------------------
     132           0 : SvtFileDialogURLSelector::~SvtFileDialogURLSelector()
     133             : {
     134           0 :     delete m_pMenu;
     135           0 : }
     136             : 
     137             : //-----------------------------------------------------------------------------
     138           0 : void SvtFileDialogURLSelector::Activate()
     139             : {
     140           0 :     m_pMenu->Clear();
     141             : 
     142           0 :     FillURLMenu( m_pMenu );
     143             : 
     144           0 :     SetPopupMenu( m_pMenu );
     145           0 : }
     146             : 
     147             : //=============================================================================
     148             : //= SvtUpButton_Impl
     149             : //=============================================================================
     150             : 
     151             : //-----------------------------------------------------------------------------
     152           0 : SvtUpButton_Impl::SvtUpButton_Impl( SvtFileDialog* pParent, const ResId& rResId )
     153           0 :     :SvtFileDialogURLSelector( pParent, rResId, IMG_FILEDLG_BTN_UP )
     154             : {
     155           0 : }
     156             : 
     157             : //-----------------------------------------------------------------------------
     158           0 : SvtUpButton_Impl::~SvtUpButton_Impl()
     159             : {
     160           0 : }
     161             : 
     162             : //-----------------------------------------------------------------------------
     163           0 : void SvtUpButton_Impl::FillURLMenu( PopupMenu* _pMenu )
     164             : {
     165           0 :     SvtFileView* pBox = GetDialogParent()->GetView();
     166             : 
     167           0 :     sal_uInt16 nItemId = 1;
     168             : 
     169           0 :     _aURLs.clear();
     170             : 
     171             :     // determine parent levels
     172           0 :     INetURLObject aObject( pBox->GetViewURL() );
     173           0 :     sal_Int32 nCount = aObject.getSegmentCount();
     174             : 
     175             :     ::svtools::VolumeInfo aVolInfo( sal_True /* volume */, sal_False /* remote */,
     176             :                                     sal_False /* removable */, sal_False /* floppy */,
     177           0 :                                     sal_False /* compact disk */ );
     178           0 :     Image aVolumeImage( SvFileInformationManager::GetFolderImage( aVolInfo ) );
     179             : 
     180           0 :     while ( nCount >= 1 )
     181             :     {
     182           0 :         aObject.removeSegment();
     183           0 :         String aParentURL(aObject.GetMainURL(INetURLObject::NO_DECODE));
     184             : 
     185           0 :         String aTitle;
     186             :         // 97148# --------------------------------
     187           0 :         if (!GetDialogParent()->ContentGetTitle(aParentURL, aTitle) || aTitle.Len() == 0)
     188           0 :             aTitle = aObject.getName();
     189             : 
     190             :         Image aImage = ( nCount > 1 ) // if nCount == 1 means workplace, which detects the wrong image
     191           0 :             ? SvFileInformationManager::GetImage( aObject ) : aVolumeImage;
     192             : 
     193           0 :         _pMenu->InsertItem( nItemId++, aTitle, aImage );
     194           0 :         _aURLs.push_back(aParentURL);
     195             : 
     196           0 :         if ( nCount == 1 )
     197             :         {
     198             :             // adjust the title of the top level entry (the workspace)
     199           0 :             _pMenu->SetItemText( --nItemId, SvtSimpleResId( STR_SVT_MIMETYPE_CNT_FSYSBOX ) );
     200             :         }
     201           0 :         --nCount;
     202           0 :     }
     203           0 : }
     204             : 
     205             : //-----------------------------------------------------------------------------
     206           0 : void SvtUpButton_Impl::Select()
     207             : {
     208           0 :     sal_uInt16 nId = GetCurItemId();
     209             : 
     210           0 :     if ( nId )
     211             :     {
     212           0 :         --nId;
     213             :         DBG_ASSERT( nId <= _aURLs.size(), "SvtUpButton_Impl:falscher Index" );
     214             : 
     215           0 :         GetDialogParent()->OpenURL_Impl(_aURLs[nId]);
     216             :     }
     217           0 : }
     218             : 
     219             : //-----------------------------------------------------------------------------
     220           0 : void SvtUpButton_Impl::Click()
     221             : {
     222           0 :     GetDialogParent()->PrevLevel_Impl();
     223           0 : }
     224             : 
     225             : //*****************************************************************************
     226             : // SvtExpFileDlg_Impl
     227             : //*****************************************************************************
     228             : 
     229           0 : SvtExpFileDlg_Impl::SvtExpFileDlg_Impl( WinBits )   :
     230             : 
     231             :     _pLbFilter          ( NULL ),
     232             :     _pCurFilter         ( NULL ),
     233           0 :     _pFilter            ( new SvtFileDialogFilterList_Impl() ),
     234             :     _pUserFilter        ( NULL ),
     235             :     _pFtFileName        ( NULL ),
     236             :     _pEdFileName        ( NULL ),
     237             :     _pFtFileVersion     ( NULL ),
     238             :     _pLbFileVersion     ( NULL ),
     239             :     _pFtTemplates       ( NULL ),
     240             :     _pLbTemplates       ( NULL ),
     241             :     _pFtImageTemplates  ( NULL ),
     242             :     _pLbImageTemplates  ( NULL ),
     243             :     _pFtFileType        ( NULL ),
     244             :     _pBtnFileOpen       ( NULL ),
     245             :     _pBtnCancel         ( NULL ),
     246             :     _pBtnHelp           ( NULL ),
     247             :     _pBtnUp             ( NULL ),
     248             :     _pBtnNewFolder      ( NULL ),
     249             :     _pCbPassword        ( NULL ),
     250             :     _pEdCurrentPath     ( NULL ),
     251             :     _pCbAutoExtension   ( NULL ),
     252             :     _pCbOptions         ( NULL ),
     253             :     _pPlaces            ( NULL ),
     254             :     _pBtnConnectToServer( NULL ),
     255             :     _eMode              ( FILEDLG_MODE_OPEN ),
     256             :     _eDlgType           ( FILEDLG_TYPE_FILEDLG ),
     257             :     _nState             ( FILEDLG_STATE_REMOTE ),
     258             :     _nStyle             ( 0 ),
     259             :     _bDoubleClick       ( sal_False ),
     260             :     m_bNeedDelayedFilterExecute ( sal_False ),
     261             :     _pDefaultFilter     ( NULL ),
     262             :     _bMultiSelection    ( sal_False ),
     263             :     _nFixDeltaHeight    ( 0 ),
     264           0 :     _bFolderHasOpened   ( sal_False )
     265             : {
     266           0 : }
     267             : 
     268             : //*****************************************************************************
     269             : 
     270           0 : SvtExpFileDlg_Impl::~SvtExpFileDlg_Impl()
     271             : {
     272           0 :     delete _pEdCurrentPath;
     273           0 :     delete _pCbPassword;
     274           0 :     delete _pCbAutoExtension;
     275           0 :     delete _pCbOptions;
     276           0 :     delete _pBtnNewFolder;
     277           0 :     delete _pBtnUp;
     278           0 :     delete _pBtnHelp;
     279           0 :     delete _pBtnCancel;
     280           0 :     delete _pBtnFileOpen;
     281           0 :     delete _pLbFilter;
     282           0 :     delete _pFtFileType;
     283           0 :     delete _pLbFileVersion;
     284           0 :     delete _pFtFileVersion;
     285           0 :     delete _pFtTemplates;
     286           0 :     delete _pLbTemplates;
     287           0 :     delete _pFtImageTemplates;
     288           0 :     delete _pLbImageTemplates;
     289           0 :     delete _pEdFileName;
     290           0 :     delete _pFtFileName;
     291           0 :     delete _pUserFilter;
     292           0 :     delete _pFilter;
     293           0 :     delete _pPlaces;
     294           0 :     delete _pBtnConnectToServer;
     295           0 : }
     296             : 
     297             : //*****************************************************************************
     298             : 
     299           0 : void SvtExpFileDlg_Impl::SetStandardDir( const String& _rDir )
     300             : {
     301           0 :     _aStdDir = _rDir;
     302           0 :     if ( 0 == _aStdDir.Len() )
     303           0 :         _aStdDir.AssignAscii( "file:///" );
     304           0 : }
     305             : 
     306             : //*****************************************************************************
     307             : #if defined DBG_UTIL
     308             : //-----------------------------------------------------------------------------
     309             : namespace {
     310             :     String lcl_DecoratedFilter( const String& _rOriginalFilter )
     311             :     {
     312             :         OUStringBuffer aDecoratedFilter;
     313             :         aDecoratedFilter.append('<');
     314             :         aDecoratedFilter.append(_rOriginalFilter);
     315             :         aDecoratedFilter.append('>');
     316             :         return aDecoratedFilter.makeStringAndClear();
     317             :     }
     318             : }
     319             : #endif
     320             : //-----------------------------------------------------------------------------
     321             : 
     322           0 : void SvtExpFileDlg_Impl::ClearFilterList( )
     323             : {
     324           0 :     _pLbFilter->Clear();
     325           0 : }
     326             : 
     327             : //-----------------------------------------------------------------------------
     328           0 : void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl* pFilter, const String& rDisplayName )
     329             : {
     330             :     DBG_ASSERT( pFilter, "SvtExpFileDlg_Impl::SetCurFilter: invalid filter!" );
     331             :     DBG_ASSERT( ( rDisplayName == pFilter->GetName() )
     332             :             ||  ( rDisplayName == lcl_DecoratedFilter( pFilter->GetName() ) ),
     333             :             "SvtExpFileDlg_Impl::SetCurFilter: arguments are inconsistent!" );
     334             : 
     335           0 :     _pCurFilter = pFilter;
     336           0 :     m_sCurrentFilterDisplayName = rDisplayName;
     337           0 : }
     338             : 
     339             : //-----------------------------------------------------------------------------
     340           0 : void SvtExpFileDlg_Impl::InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc )
     341             : {
     342           0 :     String sName = _pFilterDesc->GetName();
     343           0 :     if ( _pFilterDesc->isGroupSeparator() )
     344           0 :         sName = OUString( "------------------------------------------" );
     345             :     else
     346           0 :         sName = _pFilterDesc->GetName();
     347             : 
     348             :     // insert an set user data
     349           0 :     sal_uInt16 nPos = _pLbFilter->InsertEntry( sName );
     350           0 :     _pLbFilter->SetEntryData( nPos, const_cast< void* >( static_cast< const void* >( _pFilterDesc ) ) );
     351           0 : }
     352             : 
     353             : //-----------------------------------------------------------------------------
     354             : 
     355           0 : void SvtExpFileDlg_Impl::InitFilterList( )
     356             : {
     357             :     // clear the current list
     358           0 :     ClearFilterList( );
     359             : 
     360             :     // reinit it
     361           0 :     sal_uInt16 nPos = _pFilter->size();
     362             : 
     363             :     // search for the first entry which is no group separator
     364           0 :     while ( nPos-- && (*_pFilter)[ nPos ].isGroupSeparator() )
     365             :         ;
     366             : 
     367             :     // add all following entries
     368           0 :     while ( (sal_Int16)nPos >= 0 )
     369           0 :         InsertFilterListEntry( &(*_pFilter)[ nPos-- ] );
     370           0 : }
     371             : 
     372             : //-----------------------------------------------------------------------------
     373             : 
     374           0 : void SvtExpFileDlg_Impl::CreateFilterListControl( Window* _pParent, const ResId& _rId )
     375             : {
     376             :     DBG_ASSERT( !_pLbFilter, "SvtExpFileDlg_Impl::CreateFilterListControl: already created the control!" );
     377           0 :     if ( !_pLbFilter )
     378             :     {
     379           0 :         _pLbFilter = new ListBox( _pParent, _rId );
     380           0 :         _pLbFilter->SetDropDownLineCount( 10 );
     381             :     }
     382           0 : }
     383             : 
     384             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10