Bump version to 21.06.18.1
[LibreOffice.git] / sw / inc / postithelper.hxx
blob356f42e114db4de7cf7af9c711be8e267a613fd0
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 .
19 #ifndef INCLUDED_SW_INC_POSTITHELPER_HXX
20 #define INCLUDED_SW_INC_POSTITHELPER_HXX
22 #include "swrect.hxx"
23 #include "fmtfld.hxx"
24 #include <cstddef>
25 #include <vcl/vclptr.hxx>
26 #include <tools/solar.h>
27 #include "SidebarWindowsTypes.hxx"
29 class SfxBroadcaster;
30 class SwRootFrame;
31 class SwPostItMgr;
32 class SwEditWin;
33 class SwFrame;
34 class IDocumentRedlineAccess;
35 namespace sw::annotation { class SwAnnotationWin; }
36 namespace sw::mark { class IMark; }
38 struct SwPosition;
40 struct SwLayoutInfo
42 const SwFrame* mpAnchorFrame;
43 SwRect mPosition;
45 // optional start of the annotation
46 sal_uLong mnStartNodeIdx;
47 sal_Int32 mnStartContent;
49 SwRect mPageFrame;
50 SwRect mPagePrtArea;
51 tools::ULong mnPageNumber;
53 sw::sidebarwindows::SidebarPosition meSidebarPosition;
55 std::size_t mRedlineAuthor;
57 /**
58 * If true, the overlay arrow points to the comment anchor, otherwise it points to the commented
59 * frame.
61 bool mPositionFromCommentAnchor;
63 SwLayoutInfo()
64 : mpAnchorFrame(nullptr)
65 , mPosition()
66 , mnStartNodeIdx( 0 )
67 , mnStartContent( -1 )
68 , mPageFrame()
69 , mPagePrtArea()
70 , mnPageNumber(1)
71 , meSidebarPosition(sw::sidebarwindows::SidebarPosition::NONE)
72 , mRedlineAuthor(0)
73 , mPositionFromCommentAnchor(true)
77 namespace SwPostItHelper
79 enum SwLayoutStatus
81 INVISIBLE, VISIBLE, INSERTED, DELETED, NONE, HIDDEN
84 SwLayoutStatus getLayoutInfos(
85 SwLayoutInfo& o_rInfo,
86 const SwPosition& rAnchorPos,
87 const sw::mark::IMark* pAnnotationMark = nullptr );
89 tools::Long getLayoutHeight( const SwRootFrame* pRoot );
90 void setSidebarChanged( SwRootFrame* pRoot, bool bBrowseMode );
91 tools::ULong getPageInfo( SwRect& rPageFrame, const SwRootFrame* , const Point& );
94 class SAL_DLLPUBLIC_RTTI SwSidebarItem
96 public:
97 VclPtr<sw::annotation::SwAnnotationWin> mpPostIt;
98 bool mbShow;
99 bool mbFocus;
100 bool mbPendingLayout;
102 SwPostItHelper::SwLayoutStatus mLayoutStatus;
103 SwLayoutInfo maLayoutInfo;
105 SwSidebarItem( const bool aFocus);
107 virtual ~SwSidebarItem();
109 SwSidebarItem(SwSidebarItem const &) = default;
110 SwSidebarItem(SwSidebarItem &&) = default;
111 SwSidebarItem & operator =(SwSidebarItem const &) = default;
112 SwSidebarItem & operator =(SwSidebarItem &&) = default;
114 virtual SwPosition GetAnchorPosition() const = 0;
115 virtual bool UseElement(SwRootFrame const&, IDocumentRedlineAccess const&) = 0;
116 virtual const SwFormatField& GetFormatField() const = 0;
117 virtual const SfxBroadcaster* GetBroadcaster() const = 0;
118 virtual VclPtr<sw::annotation::SwAnnotationWin> GetSidebarWindow( SwEditWin& rEditWin,
119 SwPostItMgr& aMgr) = 0;
122 class SwAnnotationItem final : public SwSidebarItem
124 public:
125 SwAnnotationItem(
126 SwFormatField& rFormatField,
127 const bool aFocus)
128 : SwSidebarItem( aFocus )
129 , mrFormatField( rFormatField )
133 virtual SwPosition GetAnchorPosition() const override;
134 virtual bool UseElement(SwRootFrame const&, IDocumentRedlineAccess const&) override;
135 virtual const SwFormatField& GetFormatField() const override
137 return mrFormatField;
139 virtual const SfxBroadcaster* GetBroadcaster() const override
141 return dynamic_cast<const SfxBroadcaster *> (&mrFormatField);
143 virtual VclPtr<sw::annotation::SwAnnotationWin> GetSidebarWindow(
144 SwEditWin& rEditWin,
145 SwPostItMgr& aMgr ) override;
147 private:
148 SwFormatField& mrFormatField;
151 #endif // INCLUDED_SW_INC_POSTITHELPER_HXX
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */