bump product version to 5.0.4.1
[LibreOffice.git] / uui / source / nameclashdlg.cxx
blob0911605a786338cef144b84823c8c9b3312b2c1b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <vcl/layout.hxx>
21 #include <osl/file.hxx>
23 #include "ids.hrc"
24 #include "nameclashdlg.hxx"
26 // NameClashDialog ---------------------------------------------------------
28 IMPL_LINK( NameClashDialog, ButtonHdl_Impl, PushButton *, pBtn )
30 long nRet = (long) ABORT;
31 if ( m_pBtnRename == pBtn )
33 nRet = (long) RENAME;
34 OUString aNewName = m_pEDNewName->GetText();
35 if ( ( aNewName == maNewName ) || aNewName.isEmpty() )
37 ScopedVclPtrInstance< MessageDialog > aError(nullptr, maSameName);
38 aError->Execute();
39 return 1;
41 maNewName = aNewName;
43 else if ( m_pBtnOverwrite == pBtn )
44 nRet = (long) OVERWRITE;
46 EndDialog( nRet );
48 return 1;
52 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 maNewName ( rClashingName )
60 get(m_pFTMessage, "warning");
61 get(m_pEDNewName, "newname");
62 get(m_pBtnOverwrite, "replace");
63 get(m_pBtnRename, "rename");
64 get(m_pBtnCancel, "cancel");
66 Link<> aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) );
67 m_pBtnOverwrite->SetClickHdl( aLink );
68 m_pBtnRename->SetClickHdl( aLink );
69 m_pBtnCancel->SetClickHdl( aLink );
71 OUString aInfo;
72 if ( bAllowOverwrite )
74 aInfo = ResId(STR_RENAME_OR_REPLACE, *pResMgr).toString();
76 else
78 aInfo = ResId(STR_NAME_CLASH_RENAME_ONLY, *pResMgr).toString();
79 m_pBtnOverwrite->Hide();
82 OUString aPath;
83 if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( rTargetFolderURL, aPath ) )
84 aPath = rTargetFolderURL;
86 maSameName = ResId(STR_SAME_NAME_USED, *pResMgr).toString();
88 aInfo = aInfo.replaceFirst( "%NAME", rClashingName );
89 aInfo = aInfo.replaceFirst( "%FOLDER", aPath );
90 m_pFTMessage->SetText( aInfo );
91 if ( !rProposedNewName.isEmpty() )
92 m_pEDNewName->SetText( rProposedNewName );
93 else
94 m_pEDNewName->SetText( rClashingName );
97 NameClashDialog::~NameClashDialog()
99 disposeOnce();
102 void NameClashDialog::dispose()
104 m_pFTMessage.clear();
105 m_pEDNewName.clear();
106 m_pBtnOverwrite.clear();
107 m_pBtnRename.clear();
108 m_pBtnCancel.clear();
109 ModalDialog::dispose();
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */