Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/uui/source/openlocked.cxx
Line
Count
Source
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 <strings.hrc>
21
#include "openlocked.hxx"
22
#include <officecfg/Office/Common.hxx>
23
#include <vcl/vclenum.hxx>
24
#include <vcl/weld/Builder.hxx>
25
#include <vcl/weld/Dialog.hxx>
26
#include <vcl/weld/weldutils.hxx>
27
28
using namespace vcl;
29
30
IMPL_LINK(OpenLockedQueryBox, ClickHdl, weld::Button&, rButton, void)
31
0
{
32
0
    if (&rButton == mxOpenReadOnlyBtn.get())
33
0
    {
34
0
        if (mxNotifyBtn->get_active())
35
0
            m_xDialog->response(RET_RETRY);
36
0
        else
37
0
            m_xDialog->response(RET_YES);
38
0
    }
39
0
    else if (&rButton == mxOpenCopyBtn.get())
40
0
    {
41
0
        m_xDialog->response(RET_NO);
42
0
    }
43
0
    else if (&rButton == mxOpenBtn.get())
44
0
    {
45
0
        m_xDialog->response(RET_IGNORE);
46
0
    }
47
0
    else if (&rButton == mxCancelBtn.get())
48
0
    {
49
0
        m_xDialog->response(RET_CANCEL);
50
0
    }
51
0
}
52
53
OpenLockedQueryBox::OpenLockedQueryBox(weld::Window* pParent, const OUString& rHiddenData, bool bEnableOverride)
54
0
    : GenericDialogController(pParent, u"vcl/ui/openlockedquerybox.ui"_ustr, u"OpenLockedQueryBox"_ustr)
55
0
    , mxQuestionMarkImage(m_xBuilder->weld_image(u"questionmark"_ustr))
56
0
    , mxOpenReadOnlyBtn(m_xBuilder->weld_button(u"readonly"_ustr))
57
0
    , mxOpenCopyBtn(m_xBuilder->weld_button(u"opencopy"_ustr))
58
0
    , mxOpenBtn(m_xBuilder->weld_button(u"open"_ustr))
59
0
    , mxCancelBtn(m_xBuilder->weld_button(u"cancel"_ustr))
60
0
    , mxNotifyBtn(m_xBuilder->weld_check_button(u"notify"_ustr))
61
0
    , mxHiddenText(m_xBuilder->weld_label(u"hiddentext"_ustr))
62
0
{
63
    //setup click hdl
64
0
    mxOpenReadOnlyBtn->connect_clicked(LINK(this, OpenLockedQueryBox, ClickHdl));
65
0
    mxOpenCopyBtn->connect_clicked(LINK(this, OpenLockedQueryBox, ClickHdl));
66
0
    mxOpenBtn->connect_clicked(LINK(this, OpenLockedQueryBox, ClickHdl));
67
0
    mxCancelBtn->connect_clicked(LINK(this, OpenLockedQueryBox, ClickHdl));
68
69
0
    if (!(bEnableOverride && officecfg::Office::Common::Misc::AllowOverrideLocking::get()))
70
0
    {
71
        //disable option to ignore the (stale?) lock file and open the document
72
0
        mxOpenBtn->set_sensitive(false);
73
0
    }
74
75
0
    mxHiddenText->set_label(rHiddenData);
76
0
    m_xDialog->set_centered_on_parent(true);
77
0
}
78
79
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */