LCOV - code coverage report
Current view: top level - uui/source - nameclashdlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 37 0.0 %
Date: 2014-04-14 Functions: 0 3 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 "vcl/msgbox.hxx"
      21             : #include "osl/file.hxx"
      22             : 
      23             : #include "ids.hrc"
      24             : #include "nameclashdlg.hrc"
      25             : #include "nameclashdlg.hxx"
      26             : 
      27             : // NameClashDialog ---------------------------------------------------------
      28             : 
      29           0 : IMPL_LINK( NameClashDialog, ButtonHdl_Impl, PushButton *, pBtn )
      30             : {
      31           0 :     long nRet = (long) ABORT;
      32           0 :     if ( &maBtnRename == pBtn )
      33             :     {
      34           0 :         nRet = (long) RENAME;
      35           0 :         OUString aNewName = maEDNewName.GetText();
      36           0 :         if ( ( aNewName == maNewName ) || aNewName.isEmpty() )
      37             :         {
      38           0 :             ErrorBox aError( NULL, WB_OK, maSameName );
      39           0 :             aError.Execute();
      40           0 :             return 1;
      41             :         }
      42           0 :         maNewName = aNewName;
      43             :     }
      44           0 :     else if ( &maBtnOverwrite == pBtn )
      45           0 :         nRet = (long) OVERWRITE;
      46             : 
      47           0 :     EndDialog( nRet );
      48             : 
      49           0 :     return 1;
      50             : }
      51             : 
      52             : 
      53           0 : NameClashDialog::NameClashDialog( Window* pParent, ResMgr* pResMgr,
      54             :                                   OUString const & rTargetFolderURL,
      55             :                                   OUString const & rClashingName,
      56             :                                   OUString const & rProposedNewName,
      57             :                                   bool bAllowOverwrite )
      58             :     : ModalDialog( pParent, ResId( DLG_SIMPLE_NAME_CLASH, *pResMgr ) ),
      59             :     maFTMessage            ( this, ResId( FT_FILE_EXISTS_WARNING, *pResMgr ) ),
      60             :     maEDNewName            ( this, ResId( EDIT_NEW_NAME, *pResMgr ) ),
      61             :     maBtnOverwrite         ( this, ResId( BTN_OVERWRITE, *pResMgr ) ),
      62             :     maBtnRename            ( this, ResId( BTN_RENAME, *pResMgr ) ),
      63             :     maBtnCancel            ( this, ResId( BTN_CANCEL, *pResMgr ) ),
      64             :     maBtnHelp              ( this, ResId( BTN_HELP, *pResMgr ) ),
      65           0 :     maNewName              ( rClashingName )
      66             : {
      67           0 :     FreeResource();
      68             : 
      69           0 :     Link aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) );
      70           0 :     maBtnOverwrite.SetClickHdl( aLink );
      71           0 :     maBtnRename.SetClickHdl( aLink );
      72           0 :     maBtnCancel.SetClickHdl( aLink );
      73             : 
      74           0 :     OUString aInfo;
      75           0 :     if ( bAllowOverwrite )
      76             :     {
      77           0 :         aInfo = ResId(STR_RENAME_OR_REPLACE, *pResMgr).toString();
      78             :     }
      79             :     else
      80             :     {
      81           0 :         aInfo = ResId(STR_NAME_CLASH_RENAME_ONLY, *pResMgr).toString();
      82           0 :         maBtnOverwrite.Hide();
      83             :     }
      84             : 
      85           0 :     OUString aPath;
      86           0 :     if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( rTargetFolderURL, aPath ) )
      87           0 :         aPath = rTargetFolderURL;
      88             : 
      89           0 :     maSameName = ResId(STR_SAME_NAME_USED, *pResMgr).toString();
      90             : 
      91           0 :     aInfo = aInfo.replaceFirst( "%NAME", rClashingName );
      92           0 :     aInfo = aInfo.replaceFirst( "%FOLDER", aPath );
      93           0 :     maFTMessage.SetText( aInfo );
      94           0 :     if ( !rProposedNewName.isEmpty() )
      95           0 :         maEDNewName.SetText( rProposedNewName );
      96             :     else
      97           0 :         maEDNewName.SetText( rClashingName );
      98           0 : }
      99             : 
     100             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10