LCOV - code coverage report
Current view: top level - cui/source/dialogs - multifil.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 196 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <tools/shl.hxx>
      30                 :            : #include <vcl/msgbox.hxx>
      31                 :            : #include <sfx2/filedlghelper.hxx>
      32                 :            : 
      33                 :            : #include <tools/urlobj.hxx>
      34                 :            : 
      35                 :            : #include "multipat.hxx"
      36                 :            : #include "multifil.hxx"
      37                 :            : #include <dialmgr.hxx>
      38                 :            : 
      39                 :            : #include "multipat.hrc"
      40                 :            : #include <cuires.hrc>
      41                 :            : 
      42                 :            : // #97807# -------------
      43                 :            : #include <com/sun/star/ucb/XContentProvider.hpp>
      44                 :            : #include <ucbhelper/contentbroker.hxx>
      45                 :            : 
      46                 :            : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
      47                 :            : 
      48                 :            : using namespace com::sun::star::ucb;
      49                 :            : using namespace com::sun::star::uno;
      50                 :            : 
      51                 :            : // class SvxMultiFileDialog ----------------------------------------------
      52                 :            : 
      53                 :          0 : IMPL_LINK( SvxMultiFileDialog, AddHdl_Impl, PushButton *, pBtn )
      54                 :            : {
      55                 :            :     sfx2::FileDialogHelper aDlg(
      56         [ #  # ]:          0 :         com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
      57                 :            : 
      58 [ #  # ][ #  # ]:          0 :     if ( IsClassPathMode() )
      59                 :            :     {
      60 [ #  # ][ #  # ]:          0 :         aDlg.SetTitle( CUI_RES( RID_SVXSTR_ARCHIVE_TITLE ) );
         [ #  # ][ #  # ]
      61 [ #  # ][ #  # ]:          0 :         aDlg.AddFilter( CUI_RES( RID_SVXSTR_ARCHIVE_HEADLINE ), rtl::OUString("*.jar;*.zip") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      62                 :            :     }
      63                 :            : 
      64 [ #  # ][ #  # ]:          0 :     if ( aDlg.Execute() == ERRCODE_NONE )
      65                 :            :     {
      66                 :            :         // #97807# URL content comparison of entries -----------
      67 [ #  # ][ #  # ]:          0 :         INetURLObject aFile( aDlg.GetPath() );
         [ #  # ][ #  # ]
      68 [ #  # ][ #  # ]:          0 :         String sInsFile = aFile.getFSysPath( INetURLObject::FSYS_DETECT );
      69 [ #  # ][ #  # ]:          0 :         ::ucbhelper::Content aContent( aFile.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >() );
      70         [ #  # ]:          0 :         Reference< XContent > xContent = aContent.get();
      71                 :            :         OSL_ENSURE( xContent.is(), "AddHdl_Impl: invalid content interface!" );
      72 [ #  # ][ #  # ]:          0 :         Reference< XContentIdentifier > xID = xContent->getIdentifier();
      73                 :            :         OSL_ENSURE( xID.is(), "AddHdl_Impl: invalid ID interface!" );
      74                 :            :         // ensure the content of files are valid
      75                 :            : 
      76         [ #  # ]:          0 :         sal_uInt16 nCount = aPathLB.GetEntryCount();
      77                 :          0 :         sal_Bool bDuplicated = sal_False;
      78                 :            :         try
      79                 :            :         {
      80         [ #  # ]:          0 :             if( nCount > 0 ) // start comparison
      81                 :            :             {
      82                 :            :                 sal_uInt16 i;
      83                 :          0 :                 ::ucbhelper::Content & VContent = aContent; // temporary Content reference
      84                 :          0 :                 Reference< XContent > xVContent;
      85                 :          0 :                 Reference< XContentIdentifier > xVID;
      86         [ #  # ]:          0 :                 for( i = 0; i < nCount; i++ )
      87                 :            :                 {
      88         [ #  # ]:          0 :                     String sVFile = aPathLB.GetEntry( i );
      89         [ #  # ]:          0 :                     std::map< String, ::ucbhelper::Content >::iterator aCur = aFileContentMap.find( sVFile );
      90 [ #  # ][ #  # ]:          0 :                     if( aCur == aFileContentMap.end() ) // look for File Content in aFileContentMap, but not find it.
      91                 :            :                     {
      92 [ #  # ][ #  # ]:          0 :                         INetURLObject aVFile( sVFile, INetURLObject::FSYS_DETECT );
      93 [ #  # ][ #  # ]:          0 :                         aFileContentMap[sVFile] = ::ucbhelper::Content( aVFile.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >() );
         [ #  # ][ #  # ]
                 [ #  # ]
      94 [ #  # ][ #  # ]:          0 :                         VContent = aFileContentMap.find( sVFile )->second;
         [ #  # ][ #  # ]
      95                 :            :                     }
      96                 :            :                     else
      97 [ #  # ][ #  # ]:          0 :                         VContent = aCur->second;
      98 [ #  # ][ #  # ]:          0 :                     xVContent = VContent.get();
      99                 :            :                     OSL_ENSURE( xVContent.is(), "AddHdl_Impl: invalid content interface!" );
     100 [ #  # ][ #  # ]:          0 :                     xVID = xVContent->getIdentifier();
                 [ #  # ]
     101                 :            :                     OSL_ENSURE( xVID.is(), "AddHdl_Impl: invalid ID interface!" );
     102 [ #  # ][ #  # ]:          0 :                     if ( xID.is() && xVID.is() )
                 [ #  # ]
     103                 :            :                     {
     104                 :            :                         // get a generic content provider
     105         [ #  # ]:          0 :                         ::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
     106                 :          0 :                         Reference< XContentProvider > xProvider;
     107         [ #  # ]:          0 :                         if ( pBroker )
     108 [ #  # ][ #  # ]:          0 :                             xProvider = pBroker->getContentProviderInterface();
     109         [ #  # ]:          0 :                         if ( xProvider.is() )
     110                 :            :                         {
     111 [ #  # ][ #  # ]:          0 :                             if ( 0 == xProvider->compareContentIds( xID, xVID ) )
                 [ #  # ]
     112                 :            :                             {
     113                 :          0 :                                 bDuplicated = sal_True;
     114                 :            :                                 break;
     115                 :            :                             }
     116         [ #  # ]:          0 :                         }
     117                 :            :                     }
     118 [ #  # ][ #  # ]:          0 :                 }
                 [ #  # ]
     119                 :            :             } // end of if the entries are more than zero.
     120                 :            :         } // end of try(}
     121         [ #  # ]:          0 :         catch( const Exception& ) // catch every exception of comparison
     122                 :            :            {
     123                 :            :             OSL_FAIL( "AddHdl_Impl: caught an unexpected exception!" );
     124                 :            :            }
     125                 :            : 
     126         [ #  # ]:          0 :         if ( bDuplicated ) // #97807# --------------------
     127                 :            :         {
     128 [ #  # ][ #  # ]:          0 :             String sMsg( CUI_RES( RID_SVXSTR_MULTIFILE_DBL_ERR ) );
     129         [ #  # ]:          0 :             sMsg.SearchAndReplaceAscii( "%1", sInsFile );
     130 [ #  # ][ #  # ]:          0 :             InfoBox( pBtn, sMsg ).Execute();
         [ #  # ][ #  # ]
     131                 :            :         }
     132                 :            :         else
     133                 :            :         {
     134         [ #  # ]:          0 :             sal_uInt16 nPos = aPathLB.InsertEntry( sInsFile, LISTBOX_APPEND );
     135 [ #  # ][ #  # ]:          0 :             aPathLB.SetEntryData( nPos, (void*) new String( sInsFile ) );
                 [ #  # ]
     136 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     137                 :            : 
     138                 :            :     } // end of if ( aDlg.Execute() == ERRCODE_NONE )
     139         [ #  # ]:          0 :     return 0;
     140                 :            : }
     141                 :            : 
     142                 :            : // -----------------------------------------------------------------------
     143                 :            : 
     144                 :          0 : IMPL_LINK_NOARG(SvxMultiFileDialog, DelHdl_Impl)
     145                 :            : {
     146                 :          0 :     sal_uInt16 nPos = aPathLB.GetSelectEntryPos();
     147                 :          0 :     aPathLB.RemoveEntry( nPos );
     148                 :          0 :     sal_uInt16 nCnt = aPathLB.GetEntryCount();
     149                 :            : 
     150         [ #  # ]:          0 :     if ( nCnt )
     151                 :            :     {
     152                 :          0 :         nCnt--;
     153                 :            : 
     154         [ #  # ]:          0 :         if ( nPos > nCnt )
     155                 :          0 :             nPos = nCnt;
     156                 :          0 :         aPathLB.SelectEntryPos( nPos );
     157                 :            :     }
     158                 :          0 :     return 0;
     159                 :            : }
     160                 :            : 
     161                 :            : // -----------------------------------------------------------------------
     162                 :            : 
     163                 :          0 : SvxMultiFileDialog::SvxMultiFileDialog( Window* pParent, sal_Bool bEmptyAllowed ) :
     164                 :            : 
     165         [ #  # ]:          0 :     SvxMultiPathDialog( pParent, bEmptyAllowed )
     166                 :            : 
     167                 :            : {
     168         [ #  # ]:          0 :     aAddBtn.SetClickHdl( LINK( this, SvxMultiFileDialog, AddHdl_Impl ) );
     169         [ #  # ]:          0 :     aDelBtn.SetClickHdl( LINK( this, SvxMultiFileDialog, DelHdl_Impl ) );
     170 [ #  # ][ #  # ]:          0 :     SetText( CUI_RES( RID_SVXSTR_FILE_TITLE ) );
         [ #  # ][ #  # ]
     171 [ #  # ][ #  # ]:          0 :     aPathFL.SetText( CUI_RES( RID_SVXSTR_FILE_HEADLINE ) );
         [ #  # ][ #  # ]
     172         [ #  # ]:          0 :     aDelBtn.Enable();
     173                 :          0 : }
     174                 :            : 
     175                 :            : // -----------------------------------------------------------------------
     176                 :            : 
     177                 :          0 : SvxMultiFileDialog::~SvxMultiFileDialog()
     178                 :            : {
     179         [ #  # ]:          0 : }
     180                 :            : 
     181                 :            : 
     182                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10