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 <svtools/miscopt.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  SvtMiscOptions aMiscOpt;
38  m_xWarningOnBox->set_active(aMiscOpt.ShowLinkWarningDialog());
39  m_xWarningOnBox->set_sensitive(!aMiscOpt.IsShowLinkWarningDialogReadOnly());
40 }
41 
43 {
44  try
45  {
46  // save value of "warning off" checkbox, if necessary
47  SvtMiscOptions aMiscOpt;
48  bool bChecked = m_xWarningOnBox->get_active();
49  if (aMiscOpt.ShowLinkWarningDialog() != bChecked)
50  aMiscOpt.SetShowLinkWarningDialog(bChecked);
51  }
52  catch (...)
53  {
54  }
55 }
56 
57 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool ShowLinkWarningDialog() const
std::unique_ptr< weld::CheckButton > m_xWarningOnBox
Definition: linkwarn.hxx:29
bool IsShowLinkWarningDialogReadOnly() const
std::unique_ptr< weld::CheckButton > m_xWarningOnBox
SvxLinkWarningDialog(weld::Widget *pParent, const OUString &_rFileName)
Definition: linkwarn.cxx:24
void SetShowLinkWarningDialog(bool bSet)
virtual ~SvxLinkWarningDialog() override
Definition: linkwarn.cxx:42
std::unique_ptr< weld::MessageDialog > m_xDialog