LCOV - code coverage report
Current view: top level - libreoffice/fpicker/source/office - iodlgimp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 125 0.0 %
Date: 2012-12-27 Functions: 0 23 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 :         if (GetDialogParent()->isUrlAllowed(aParentURL))
     186             :         {
     187           0 :             String aTitle;
     188             :             // 97148# --------------------------------
     189           0 :             if (!GetDialogParent()->ContentGetTitle(aParentURL, aTitle) || aTitle.Len() == 0)
     190           0 :                 aTitle = aObject.getName();
     191             : 
     192             :             Image aImage = ( nCount > 1 ) // if nCount == 1 means workplace, which detects the wrong image
     193           0 :                 ? SvFileInformationManager::GetImage( aObject ) : aVolumeImage;
     194             : 
     195           0 :             _pMenu->InsertItem( nItemId++, aTitle, aImage );
     196           0 :             _aURLs.push_back(aParentURL);
     197             : 
     198           0 :             if ( nCount == 1 )
     199             :             {
     200             :                 // adjust the title of the top level entry (the workspace)
     201           0 :                 _pMenu->SetItemText( --nItemId, SvtSimpleResId( STR_SVT_MIMETYPE_CNT_FSYSBOX ) );
     202           0 :             }
     203             :         }
     204             : 
     205           0 :         --nCount;
     206           0 :     }
     207           0 : }
     208             : 
     209             : //-----------------------------------------------------------------------------
     210           0 : void SvtUpButton_Impl::Select()
     211             : {
     212           0 :     sal_uInt16 nId = GetCurItemId();
     213             : 
     214           0 :     if ( nId )
     215             :     {
     216           0 :         --nId;
     217             :         DBG_ASSERT( nId <= _aURLs.size(), "SvtUpButton_Impl:falscher Index" );
     218             : 
     219           0 :         GetDialogParent()->OpenURL_Impl(_aURLs[nId]);
     220             :     }
     221           0 : }
     222             : 
     223             : //-----------------------------------------------------------------------------
     224           0 : void SvtUpButton_Impl::Click()
     225             : {
     226           0 :     GetDialogParent()->PrevLevel_Impl();
     227           0 : }
     228             : 
     229             : //*****************************************************************************
     230             : // SvtExpFileDlg_Impl
     231             : //*****************************************************************************
     232             : 
     233           0 : SvtExpFileDlg_Impl::SvtExpFileDlg_Impl( WinBits )   :
     234             : 
     235             :     _pLbFilter          ( NULL ),
     236             :     _pCurFilter         ( NULL ),
     237           0 :     _pFilter            ( new SvtFileDialogFilterList_Impl() ),
     238             :     _pUserFilter        ( NULL ),
     239             :     _pFtFileName        ( NULL ),
     240             :     _pEdFileName        ( NULL ),
     241             :     _pFtFileVersion     ( NULL ),
     242             :     _pLbFileVersion     ( NULL ),
     243             :     _pFtTemplates       ( NULL ),
     244             :     _pLbTemplates       ( NULL ),
     245             :     _pFtImageTemplates  ( NULL ),
     246             :     _pLbImageTemplates  ( NULL ),
     247             :     _pFtFileType        ( NULL ),
     248             :     _pBtnFileOpen       ( NULL ),
     249             :     _pBtnCancel         ( NULL ),
     250             :     _pBtnHelp           ( NULL ),
     251             :     _pBtnUp             ( NULL ),
     252             :     _pBtnNewFolder      ( NULL ),
     253             :     _pCbPassword        ( NULL ),
     254             :     _pEdCurrentPath     ( NULL ),
     255             :     _pCbAutoExtension   ( NULL ),
     256             :     _pCbOptions         ( NULL ),
     257             :     _pPlaces            ( NULL ),
     258             :     _pBtnConnectToServer( NULL ),
     259             :     _nState             ( FILEDLG_STATE_REMOTE ),
     260             :     _nStyle             ( 0 ),
     261             :     _bDoubleClick       ( sal_False ),
     262             :     m_bNeedDelayedFilterExecute ( sal_False ),
     263             :     _pDefaultFilter     ( NULL ),
     264             :     _bMultiSelection    ( sal_False ),
     265             :     _nFixDeltaHeight    ( 0 ),
     266           0 :     _bFolderHasOpened   ( sal_False )
     267             : {
     268           0 : }
     269             : 
     270             : //*****************************************************************************
     271             : 
     272           0 : SvtExpFileDlg_Impl::~SvtExpFileDlg_Impl()
     273             : {
     274           0 :     delete _pEdCurrentPath;
     275           0 :     delete _pCbPassword;
     276           0 :     delete _pCbAutoExtension;
     277           0 :     delete _pCbOptions;
     278           0 :     delete _pBtnNewFolder;
     279           0 :     delete _pBtnUp;
     280           0 :     delete _pBtnHelp;
     281           0 :     delete _pBtnCancel;
     282           0 :     delete _pBtnFileOpen;
     283           0 :     delete _pLbFilter;
     284           0 :     delete _pFtFileType;
     285           0 :     delete _pLbFileVersion;
     286           0 :     delete _pFtFileVersion;
     287           0 :     delete _pFtTemplates;
     288           0 :     delete _pLbTemplates;
     289           0 :     delete _pFtImageTemplates;
     290           0 :     delete _pLbImageTemplates;
     291           0 :     delete _pEdFileName;
     292           0 :     delete _pFtFileName;
     293           0 :     delete _pUserFilter;
     294           0 :     delete _pFilter;
     295           0 :     delete _pPlaces;
     296           0 :     delete _pBtnConnectToServer;
     297           0 : }
     298             : 
     299             : //*****************************************************************************
     300             : 
     301           0 : void SvtExpFileDlg_Impl::SetStandardDir( const String& _rDir )
     302             : {
     303           0 :     _aStdDir = _rDir;
     304           0 :     if ( 0 == _aStdDir.Len() )
     305           0 :         _aStdDir.AssignAscii( "file:///" );
     306           0 : }
     307             : 
     308             : //*****************************************************************************
     309             : #if defined DBG_UTIL
     310             : //-----------------------------------------------------------------------------
     311             : namespace {
     312             :     String lcl_DecoratedFilter( const String& _rOriginalFilter )
     313             :     {
     314             :         OUStringBuffer aDecoratedFilter;
     315             :         aDecoratedFilter.append('<');
     316             :         aDecoratedFilter.append(_rOriginalFilter);
     317             :         aDecoratedFilter.append('>');
     318             :         return aDecoratedFilter.makeStringAndClear();
     319             :     }
     320             : }
     321             : #endif
     322             : //-----------------------------------------------------------------------------
     323             : 
     324           0 : void SvtExpFileDlg_Impl::ClearFilterList( )
     325             : {
     326           0 :     _pLbFilter->Clear();
     327           0 : }
     328             : 
     329             : //-----------------------------------------------------------------------------
     330           0 : void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl* pFilter, const String& rDisplayName )
     331             : {
     332             :     DBG_ASSERT( pFilter, "SvtExpFileDlg_Impl::SetCurFilter: invalid filter!" );
     333             :     DBG_ASSERT( ( rDisplayName == pFilter->GetName() )
     334             :             ||  ( rDisplayName == lcl_DecoratedFilter( pFilter->GetName() ) ),
     335             :             "SvtExpFileDlg_Impl::SetCurFilter: arguments are inconsistent!" );
     336             : 
     337           0 :     _pCurFilter = pFilter;
     338           0 :     m_sCurrentFilterDisplayName = rDisplayName;
     339           0 : }
     340             : 
     341             : //-----------------------------------------------------------------------------
     342           0 : void SvtExpFileDlg_Impl::InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc )
     343             : {
     344           0 :     String sName = _pFilterDesc->GetName();
     345           0 :     if ( _pFilterDesc->isGroupSeparator() )
     346           0 :         sName = OUString( "------------------------------------------" );
     347             :     else
     348           0 :         sName = _pFilterDesc->GetName();
     349             : 
     350             :     // insert an set user data
     351           0 :     sal_uInt16 nPos = _pLbFilter->InsertEntry( sName );
     352           0 :     _pLbFilter->SetEntryData( nPos, const_cast< void* >( static_cast< const void* >( _pFilterDesc ) ) );
     353           0 : }
     354             : 
     355             : //-----------------------------------------------------------------------------
     356             : 
     357           0 : void SvtExpFileDlg_Impl::InitFilterList( )
     358             : {
     359             :     // clear the current list
     360           0 :     ClearFilterList( );
     361             : 
     362             :     // reinit it
     363           0 :     sal_uInt16 nPos = _pFilter->size();
     364             : 
     365             :     // search for the first entry which is no group separator
     366           0 :     while ( nPos-- && (*_pFilter)[ nPos ].isGroupSeparator() )
     367             :         ;
     368             : 
     369             :     // add all following entries
     370           0 :     while ( (sal_Int16)nPos >= 0 )
     371           0 :         InsertFilterListEntry( &(*_pFilter)[ nPos-- ] );
     372           0 : }
     373             : 
     374             : //-----------------------------------------------------------------------------
     375             : 
     376           0 : void SvtExpFileDlg_Impl::CreateFilterListControl( Window* _pParent, const ResId& _rId )
     377             : {
     378             :     DBG_ASSERT( !_pLbFilter, "SvtExpFileDlg_Impl::CreateFilterListControl: already created the control!" );
     379           0 :     if ( !_pLbFilter )
     380             :     {
     381           0 :         _pLbFilter = new ListBox( _pParent, _rId );
     382           0 :         _pLbFilter->SetDropDownLineCount( 10 );
     383             :     }
     384           0 : }
     385             : 
     386             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10