Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / postithelper.hxx
blob47e8c3fb9721c592198f8acddb557634a5a890de
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 <redline.hxx>
25 #include <vector>
26 #include <vcl/window.hxx>
27 #include <SidebarWindowsTypes.hxx>
29 class SfxBroadcaster;
30 class SwTextField;
31 class SwRootFrm;
32 class SwPostItMgr;
33 class SwEditWin;
34 namespace sw { namespace sidebarwindows {
35 class SwSidebarWin;
36 } }
38 struct SwPosition;
40 typedef sal_Int64 SwPostItBits;
42 struct SwLayoutInfo
44 const SwFrm* mpAnchorFrm;
45 SwRect mPosition;
47 // optional start of the annotation
48 sal_uLong mnStartNodeIdx;
49 sal_Int32 mnStartContent;
51 SwRect mPageFrame;
52 SwRect mPagePrtArea;
53 unsigned long mnPageNumber;
55 sw::sidebarwindows::SidebarPosition meSidebarPosition;
57 sal_uInt16 mRedlineAuthor;
59 SwLayoutInfo()
60 : mpAnchorFrm(0)
61 , mPosition()
62 , mnStartNodeIdx( 0 )
63 , mnStartContent( -1 )
64 , mPageFrame()
65 , mPagePrtArea()
66 , mnPageNumber(1)
67 , meSidebarPosition(sw::sidebarwindows::SidebarPosition::NONE)
68 , mRedlineAuthor(0)
72 namespace SwPostItHelper
74 enum SwLayoutStatus
76 INVISIBLE, VISIBLE, INSERTED, DELETED, NONE, HIDDEN
79 SwLayoutStatus getLayoutInfos(
80 SwLayoutInfo& o_rInfo,
81 const SwPosition& rAnchorPos,
82 const SwPosition* pAnnotationStartPos = NULL );
84 long getLayoutHeight( const SwRootFrm* pRoot );
85 void setSidebarChanged( SwRootFrm* pRoot, bool bBrowseMode );
86 unsigned long getPageInfo( SwRect& rPageFrm, const SwRootFrm* , const Point& );
89 class SwSidebarItem
91 public:
92 VclPtr<sw::sidebarwindows::SwSidebarWin> pPostIt;
93 bool bShow;
94 bool bFocus;
96 SwPostItHelper::SwLayoutStatus mLayoutStatus;
97 SwLayoutInfo maLayoutInfo;
99 SwSidebarItem( const bool aShow,
100 const bool aFocus)
101 : pPostIt(0)
102 , bShow(aShow)
103 , bFocus(aFocus)
104 , mLayoutStatus( SwPostItHelper::INVISIBLE )
105 , maLayoutInfo()
109 virtual ~SwSidebarItem()
113 virtual SwPosition GetAnchorPosition() const = 0;
114 virtual bool UseElement() = 0;
115 virtual const SwFormatField& GetFormatField() const = 0;
116 virtual const SfxBroadcaster* GetBroadCaster() const = 0;
117 virtual VclPtr<sw::sidebarwindows::SwSidebarWin> GetSidebarWindow( SwEditWin& rEditWin,
118 WinBits nBits,
119 SwPostItMgr& aMgr,
120 SwPostItBits aBits) = 0;
123 class SwAnnotationItem: public SwSidebarItem
125 public:
126 SwAnnotationItem(
127 SwFormatField& rFormatField,
128 const bool aShow,
129 const bool aFocus)
130 : SwSidebarItem( aShow, aFocus )
131 , mrFormatField( rFormatField )
135 virtual ~SwAnnotationItem()
139 virtual SwPosition GetAnchorPosition() const SAL_OVERRIDE;
140 virtual bool UseElement() SAL_OVERRIDE;
141 virtual const SwFormatField& GetFormatField() const SAL_OVERRIDE
143 return mrFormatField;
145 virtual const SfxBroadcaster* GetBroadCaster() const SAL_OVERRIDE
147 return dynamic_cast<const SfxBroadcaster *> (&mrFormatField);
149 virtual VclPtr<sw::sidebarwindows::SwSidebarWin> GetSidebarWindow(
150 SwEditWin& rEditWin,
151 WinBits nBits,
152 SwPostItMgr& aMgr,
153 SwPostItBits aBits ) SAL_OVERRIDE;
155 private:
156 SwFormatField& mrFormatField;
159 #endif // INCLUDED_SW_INC_POSTITHELPER_HXX
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */