Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/envelp/syncbtn.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 <sfx2/viewfrm.hxx>
21
#include <sfx2/dispatch.hxx>
22
#include <vcl/windowstate.hxx>
23
24
#include <cmdid.h>
25
#include <swmodule.hxx>
26
#include <view.hxx>
27
#include <edtwin.hxx>
28
29
#include <syncbtn.hxx>
30
31
SFX_IMPL_MODELESSDIALOGCONTOLLER(SwSyncChildWin, FN_SYNC_LABELS)
32
33
SwSyncChildWin::SwSyncChildWin(vcl::Window* _pParent,
34
                               sal_uInt16 nId,
35
                               SfxBindings* pBindings,
36
                               SfxChildWinInfo* pInfo)
37
0
    : SfxChildWindow(_pParent, nId)
38
0
{
39
0
    SetController(std::make_shared<SwSyncBtnDlg>(pBindings, this, _pParent->GetFrameWeld()));
40
0
    SwSyncBtnDlg* pBtnDlg = static_cast<SwSyncBtnDlg*>(GetController().get());
41
42
0
    if (!pInfo->aSize.Width() || !pInfo->aSize.Height())
43
0
    {
44
0
        weld::Dialog* pDlg = pBtnDlg->getDialog();
45
0
        Point aPos;
46
47
0
        if (SwView* pActiveView = GetActiveView())
48
0
        {
49
0
            const SwEditWin &rEditWin = pActiveView->GetEditWin();
50
0
            aPos = rEditWin.OutputToScreenPixel(Point(0, 0));
51
0
        }
52
0
        else
53
0
            aPos = _pParent->OutputToScreenPixel(Point(0, 0));
54
55
0
        vcl::WindowData aState;
56
0
        aState.setMask(vcl::WindowDataMask::Pos);
57
0
        aState.setPos(aPos);
58
0
        pDlg->set_window_state(aState.toStr());
59
60
0
        pInfo->aPos = pDlg->get_position();
61
0
        pInfo->aSize = pDlg->get_size();
62
0
    }
63
64
0
    pBtnDlg->Initialize(pInfo);
65
0
}
66
67
SwSyncBtnDlg::SwSyncBtnDlg(SfxBindings* pBindings,
68
                           SfxChildWindow* pChild,
69
                           weld::Window *pParent)
70
0
    : SfxModelessDialogController(pBindings, pChild, pParent, u"modules/swriter/ui/floatingsync.ui"_ustr, u"FloatingSync"_ustr)
71
0
    , m_xSyncBtn(m_xBuilder->weld_button(u"sync"_ustr))
72
0
{
73
0
    m_xSyncBtn->connect_clicked(LINK(this, SwSyncBtnDlg, BtnHdl));
74
0
}
75
76
SwSyncBtnDlg::~SwSyncBtnDlg()
77
0
{
78
0
}
79
80
IMPL_STATIC_LINK_NOARG(SwSyncBtnDlg, BtnHdl, weld::Button&, void)
81
0
{
82
0
    if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
83
0
        pViewFrm->GetDispatcher()->Execute(FN_UPDATE_ALL_LINKS, SfxCallMode::ASYNCHRON);
84
0
}
85
86
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */