LCOV - code coverage report
Current view: top level - uui/source - nameclashdlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 41 2.4 %
Date: 2014-11-03 Functions: 2 5 40.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/layout.hxx>
      21             : #include <osl/file.hxx>
      22             : 
      23             : #include "ids.hrc"
      24             : #include "nameclashdlg.hxx"
      25             : 
      26             : // NameClashDialog ---------------------------------------------------------
      27             : 
      28           0 : IMPL_LINK( NameClashDialog, ButtonHdl_Impl, PushButton *, pBtn )
      29             : {
      30           0 :     long nRet = (long) ABORT;
      31           0 :     if ( m_pBtnRename == pBtn )
      32             :     {
      33           0 :         nRet = (long) RENAME;
      34           0 :         OUString aNewName = m_pEDNewName->GetText();
      35           0 :         if ( ( aNewName == maNewName ) || aNewName.isEmpty() )
      36             :         {
      37           0 :             MessageDialog aError(NULL, maSameName);
      38           0 :             aError.Execute();
      39           0 :             return 1;
      40             :         }
      41           0 :         maNewName = aNewName;
      42             :     }
      43           0 :     else if ( m_pBtnOverwrite == pBtn )
      44           0 :         nRet = (long) OVERWRITE;
      45             : 
      46           0 :     EndDialog( nRet );
      47             : 
      48           0 :     return 1;
      49             : }
      50             : 
      51             : 
      52           0 : NameClashDialog::NameClashDialog( vcl::Window* pParent, ResMgr* pResMgr,
      53             :                                   OUString const & rTargetFolderURL,
      54             :                                   OUString const & rClashingName,
      55             :                                   OUString const & rProposedNewName,
      56             :                                   bool bAllowOverwrite )
      57             :     : ModalDialog( pParent, "SimpleNameClashDialog", "uui/ui/simplenameclash.ui" ),
      58           0 :     maNewName              ( rClashingName )
      59             : {
      60           0 :     get(m_pFTMessage, "warning");
      61           0 :     get(m_pEDNewName, "newname");
      62           0 :     get(m_pBtnOverwrite, "replace");
      63           0 :     get(m_pBtnRename, "rename");
      64           0 :     get(m_pBtnCancel, "cancel");
      65             : 
      66           0 :     Link aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) );
      67           0 :     m_pBtnOverwrite->SetClickHdl( aLink );
      68           0 :     m_pBtnRename->SetClickHdl( aLink );
      69           0 :     m_pBtnCancel->SetClickHdl( aLink );
      70             : 
      71           0 :     OUString aInfo;
      72           0 :     if ( bAllowOverwrite )
      73             :     {
      74           0 :         aInfo = ResId(STR_RENAME_OR_REPLACE, *pResMgr).toString();
      75             :     }
      76             :     else
      77             :     {
      78           0 :         aInfo = ResId(STR_NAME_CLASH_RENAME_ONLY, *pResMgr).toString();
      79           0 :         m_pBtnOverwrite->Hide();
      80             :     }
      81             : 
      82           0 :     OUString aPath;
      83           0 :     if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( rTargetFolderURL, aPath ) )
      84           0 :         aPath = rTargetFolderURL;
      85             : 
      86           0 :     maSameName = ResId(STR_SAME_NAME_USED, *pResMgr).toString();
      87             : 
      88           0 :     aInfo = aInfo.replaceFirst( "%NAME", rClashingName );
      89           0 :     aInfo = aInfo.replaceFirst( "%FOLDER", aPath );
      90           0 :     m_pFTMessage->SetText( aInfo );
      91           0 :     if ( !rProposedNewName.isEmpty() )
      92           0 :         m_pEDNewName->SetText( rProposedNewName );
      93             :     else
      94           0 :         m_pEDNewName->SetText( rClashingName );
      95         180 : }
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10