Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sw/inc/postithelper.hxx
Line
Count
Source (jump to first uncovered line)
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
#ifndef INCLUDED_SW_INC_POSTITHELPER_HXX
20
#define INCLUDED_SW_INC_POSTITHELPER_HXX
21
22
#include "swrect.hxx"
23
#include "fmtfld.hxx"
24
#include <cstddef>
25
#include <vcl/vclptr.hxx>
26
#include "SidebarWindowsTypes.hxx"
27
#include "nodeoffset.hxx"
28
29
class Outliner;
30
class SfxBroadcaster;
31
class SwRootFrame;
32
class SwPostItMgr;
33
class SwEditWin;
34
class SwFrame;
35
class IDocumentRedlineAccess;
36
namespace sw::annotation { class SwAnnotationWin; }
37
namespace sw::mark { class MarkBase; }
38
39
struct SwPosition;
40
41
struct SwLayoutInfo
42
{
43
    const SwFrame* mpAnchorFrame;
44
    SwRect mPosition;
45
46
    // optional start of the annotation
47
    SwNodeOffset mnStartNodeIdx;
48
    sal_Int32 mnStartContent;
49
50
    SwRect mPageFrame;
51
    SwRect mPagePrtArea;
52
    tools::ULong mnPageNumber;
53
54
    sw::sidebarwindows::SidebarPosition meSidebarPosition;
55
56
    std::size_t mRedlineAuthor;
57
58
    /**
59
     * If true, the overlay arrow points to the comment anchor, otherwise it points to the commented
60
     * frame.
61
     */
62
    bool mPositionFromCommentAnchor;
63
64
    SwLayoutInfo()
65
3
        : mpAnchorFrame(nullptr)
66
3
        , mPosition()
67
3
        , mnStartNodeIdx( 0 )
68
3
        , mnStartContent( -1 )
69
3
        , mPageFrame()
70
3
        , mPagePrtArea()
71
3
        , mnPageNumber(1)
72
3
        , meSidebarPosition(sw::sidebarwindows::SidebarPosition::NONE)
73
3
        , mRedlineAuthor(0)
74
3
        , mPositionFromCommentAnchor(true)
75
3
    {}
76
};
77
78
namespace SwPostItHelper
79
{
80
    enum SwLayoutStatus
81
    {
82
        INVISIBLE, VISIBLE, INSERTED, DELETED, NONE, HIDDEN
83
    };
84
85
    SwLayoutStatus getLayoutInfos(
86
        SwLayoutInfo& o_rInfo,
87
        const SwPosition& rAnchorPos,
88
        const sw::mark::MarkBase* pAnnotationMark = nullptr );
89
90
    tools::Long getLayoutHeight( const SwRootFrame* pRoot );
91
    void setSidebarChanged( SwRootFrame* pRoot, bool bBrowseMode );
92
    tools::ULong getPageInfo( SwRect& rPageFrame, const SwRootFrame* , const Point& );
93
94
    void ImportHTML(Outliner& rOutliner, const OUString& rHtml);
95
}
96
97
class SAL_DLLPUBLIC_RTTI SwAnnotationItem final
98
{
99
public:
100
    VclPtr<sw::annotation::SwAnnotationWin> mpPostIt;
101
    bool mbShow;
102
    bool mbFocus;
103
    bool mbPendingLayout;
104
    SwPostItHelper::SwLayoutStatus mLayoutStatus;
105
    SwLayoutInfo maLayoutInfo;
106
107
    SwAnnotationItem(
108
        SwFormatField& rFormatField,
109
        const bool aFocus);
110
    ~SwAnnotationItem();
111
112
    SwAnnotationItem(SwAnnotationItem const &) = default;
113
    SwAnnotationItem(SwAnnotationItem &&) = default;
114
115
    SwPosition GetAnchorPosition() const;
116
    bool UseElement(SwRootFrame const&, IDocumentRedlineAccess const&);
117
    const SwFormatField& GetFormatField() const
118
0
    {
119
0
        return mrFormatField;
120
0
    }
121
    SwFormatField& GetFormatField()
122
4
    {
123
4
        return mrFormatField;
124
4
    }
125
    const SfxBroadcaster* GetBroadcaster() const
126
3
    {
127
3
        return &mrFormatField;
128
3
    }
129
    VclPtr<sw::annotation::SwAnnotationWin> GetSidebarWindow(
130
        SwEditWin& rEditWin,
131
        SwPostItMgr& aMgr );
132
133
private:
134
    SwFormatField& mrFormatField;
135
};
136
137
#endif // INCLUDED_SW_INC_POSTITHELPER_HXX
138
139
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */