1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <osl/diagnose.h>
22 #include <swrenamexnameddlg.hxx>
24 using namespace ::com::sun::star
;
26 SwRenameXNamedDlg::SwRenameXNamedDlg(weld::Window
* pWin
,
27 uno::Reference
< container::XNamed
> & xN
,
28 uno::Reference
< container::XNameAccess
> & xNA
)
29 : GenericDialogController(pWin
, "modules/swriter/ui/renameobjectdialog.ui", "RenameObjectDialog")
32 , m_xNewNameED(m_xBuilder
->weld_entry("entry"))
33 , m_xOk(m_xBuilder
->weld_button("ok"))
35 m_xNewNameED
->connect_insert_text(LINK(this, SwRenameXNamedDlg
, TextFilterHdl
));
37 OUString
sTmp(m_xDialog
->get_title());
38 m_xNewNameED
->set_text(xNamed
->getName());
39 m_xNewNameED
->select_region(0, -1);
40 sTmp
+= xNamed
->getName();
41 m_xDialog
->set_title(sTmp
);
43 m_xOk
->connect_clicked(LINK(this, SwRenameXNamedDlg
, OkHdl
));
44 m_xNewNameED
->connect_changed(LINK(this, SwRenameXNamedDlg
, ModifyHdl
));
45 m_xOk
->set_sensitive(false);
48 IMPL_LINK(SwRenameXNamedDlg
, TextFilterHdl
, OUString
&, rTest
, bool)
50 rTest
= m_aTextFilter
.filter(rTest
);
54 IMPL_LINK_NOARG(SwRenameXNamedDlg
, OkHdl
, weld::Button
&, void)
58 xNamed
->setName(m_xNewNameED
->get_text());
60 catch (const uno::RuntimeException
&)
62 OSL_FAIL("name wasn't changed");
64 m_xDialog
->response(RET_OK
);
67 IMPL_LINK(SwRenameXNamedDlg
, ModifyHdl
, weld::Entry
&, rEdit
, void)
69 OUString
sTmp(rEdit
.get_text());
71 m_xOk
->set_sensitive(!sTmp
.isEmpty()
72 && !xNameAccess
->hasByName(sTmp
)
73 && (!xSecondAccess
.is() || !xSecondAccess
->hasByName(sTmp
))
74 && (!xThirdAccess
.is() || !xThirdAccess
->hasByName(sTmp
))
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */