Best effort to create directories of SAL_LOG_FILE
[LibreOffice.git] / svx / source / dialog / linkwarn.cxx
blob852c92af1089bf75e29d06628f6278fd8c4c8e83
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 <osl/file.hxx>
21 #include <svx/linkwarn.hxx>
22 #include <officecfg/Office/Common.hxx>
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"))
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);
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());
42 SvxLinkWarningDialog::~SvxLinkWarningDialog()
44 try
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)
50 std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
51 comphelper::ConfigurationChanges::create());
52 officecfg::Office::Common::Misc::ShowLinkWarningDialog::set(bChecked, xChanges);
53 xChanges->commit();
56 catch (...)
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */