LibreOffice Module svx (master)  1
linkwarn.cxx
Go to the documentation of this file.
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 <osl/file.hxx>
21 #include <svx/linkwarn.hxx>
22 #include <officecfg/Office/Common.hxx>
23 
24 SvxLinkWarningDialog::SvxLinkWarningDialog(weld::Widget* pParent, const OUString& _rFileName)
25  : MessageDialogController(pParent, "svx/ui/linkwarndialog.ui", "LinkWarnDialog", "ask")
26  , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
27 {
28  // replace filename
29  OUString sInfoText = m_xDialog->get_primary_text();
30  OUString aPath;
31  if (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(_rFileName, aPath))
32  aPath = _rFileName;
33  sInfoText = sInfoText.replaceAll("%FILENAME", aPath);
34  m_xDialog->set_primary_text(sInfoText);
35 
36  // load state of "warning on" checkbox from misc options
37  m_xWarningOnBox->set_active(officecfg::Office::Common::Misc::ShowLinkWarningDialog::get());
38  m_xWarningOnBox->set_sensitive(
39  !officecfg::Office::Common::Misc::ShowLinkWarningDialog::isReadOnly());
40 }
41 
43 {
44  try
45  {
46  // save value of "warning off" checkbox, if necessary
47  bool bChecked = m_xWarningOnBox->get_active();
48  if (officecfg::Office::Common::Misc::ShowLinkWarningDialog::get() != bChecked)
49  {
50  std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
52  officecfg::Office::Common::Misc::ShowLinkWarningDialog::set(bChecked, xChanges);
53  xChanges->commit();
54  }
55  }
56  catch (...)
57  {
58  }
59 }
60 
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::CheckButton > m_xWarningOnBox
Definition: linkwarn.hxx:29
static std::shared_ptr< ConfigurationChanges > create(css::uno::Reference< css::uno::XComponentContext > const &context=comphelper::getProcessComponentContext())
std::unique_ptr< weld::CheckButton > m_xWarningOnBox
SvxLinkWarningDialog(weld::Widget *pParent, const OUString &_rFileName)
Definition: linkwarn.cxx:24
virtual ~SvxLinkWarningDialog() override
Definition: linkwarn.cxx:42
std::unique_ptr< weld::MessageDialog > m_xDialog