Line data Source code
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 <redline.hxx>
25 : #include <vector>
26 : #include <vcl/window.hxx>
27 : #include <SidebarWindowsTypes.hxx>
28 :
29 : class SfxBroadcaster;
30 : class SwTextField;
31 : class SwRootFrm;
32 : class SwPostItMgr;
33 : class SwEditWin;
34 : namespace sw { namespace sidebarwindows {
35 : class SwSidebarWin;
36 : } }
37 :
38 : struct SwPosition;
39 :
40 : typedef sal_Int64 SwPostItBits;
41 :
42 763 : struct SwLayoutInfo
43 : {
44 : const SwFrm* mpAnchorFrm;
45 : SwRect mPosition;
46 :
47 : // optional start of the annotation
48 : sal_uLong mnStartNodeIdx;
49 : sal_Int32 mnStartContent;
50 :
51 : SwRect mPageFrame;
52 : SwRect mPagePrtArea;
53 : unsigned long mnPageNumber;
54 :
55 : sw::sidebarwindows::SidebarPosition meSidebarPosition;
56 :
57 : sal_uInt16 mRedlineAuthor;
58 :
59 107 : 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 107 : , mRedlineAuthor(0)
69 107 : {}
70 : };
71 :
72 : namespace SwPostItHelper
73 : {
74 : enum SwLayoutStatus
75 : {
76 : INVISIBLE, VISIBLE, INSERTED, DELETED, NONE, HIDDEN
77 : };
78 :
79 : SwLayoutStatus getLayoutInfos(
80 : SwLayoutInfo& o_rInfo,
81 : const SwPosition& rAnchorPos,
82 : const SwPosition* pAnnotationStartPos = NULL );
83 :
84 : long getLayoutHeight( const SwRootFrm* pRoot );
85 : void setSidebarChanged( SwRootFrm* pRoot, bool bBrowseMode );
86 : unsigned long getPageInfo( SwRect& rPageFrm, const SwRootFrm* , const Point& );
87 : }
88 :
89 763 : class SwSidebarItem
90 : {
91 : public:
92 : VclPtr<sw::sidebarwindows::SwSidebarWin> pPostIt;
93 : bool bShow;
94 : bool bFocus;
95 :
96 : SwPostItHelper::SwLayoutStatus mLayoutStatus;
97 : SwLayoutInfo maLayoutInfo;
98 :
99 107 : SwSidebarItem( const bool aShow,
100 : const bool aFocus)
101 : : pPostIt(0)
102 : , bShow(aShow)
103 : , bFocus(aFocus)
104 : , mLayoutStatus( SwPostItHelper::INVISIBLE )
105 107 : , maLayoutInfo()
106 : {
107 107 : }
108 :
109 107 : virtual ~SwSidebarItem()
110 107 : {
111 107 : }
112 :
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;
121 : };
122 :
123 : class SwAnnotationItem: public SwSidebarItem
124 : {
125 : public:
126 107 : SwAnnotationItem(
127 : SwFormatField& rFormatField,
128 : const bool aShow,
129 : const bool aFocus)
130 : : SwSidebarItem( aShow, aFocus )
131 107 : , mrFormatField( rFormatField )
132 : {
133 107 : }
134 :
135 214 : virtual ~SwAnnotationItem()
136 107 : {
137 214 : }
138 :
139 : virtual SwPosition GetAnchorPosition() const SAL_OVERRIDE;
140 : virtual bool UseElement() SAL_OVERRIDE;
141 1665 : virtual const SwFormatField& GetFormatField() const SAL_OVERRIDE
142 : {
143 1665 : return mrFormatField;
144 : }
145 266 : virtual const SfxBroadcaster* GetBroadCaster() const SAL_OVERRIDE
146 : {
147 266 : return dynamic_cast<const SfxBroadcaster *> (&mrFormatField);
148 : }
149 : virtual VclPtr<sw::sidebarwindows::SwSidebarWin> GetSidebarWindow(
150 : SwEditWin& rEditWin,
151 : WinBits nBits,
152 : SwPostItMgr& aMgr,
153 : SwPostItBits aBits ) SAL_OVERRIDE;
154 :
155 : private:
156 : SwFormatField& mrFormatField;
157 : };
158 :
159 : #endif // INCLUDED_SW_INC_POSTITHELPER_HXX
160 :
161 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|