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 : #include <svl/brdcst.hxx>
29 :
30 : class SwTxtFld;
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 0 : 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 0 : SwLayoutInfo()
60 : : mpAnchorFrm(0)
61 : , mPosition()
62 : , mnStartNodeIdx( 0 )
63 : , mnStartContent( -1 )
64 : , mPageFrame()
65 : , mPagePrtArea()
66 : , mnPageNumber(1)
67 : , meSidebarPosition(sw::sidebarwindows::SIDEBAR_NONE)
68 0 : , mRedlineAuthor(0)
69 0 : {}
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 0 : class SwSidebarItem
90 : {
91 : public:
92 : sw::sidebarwindows::SwSidebarWin* pPostIt;
93 : bool bShow;
94 : bool bFocus;
95 :
96 : SwPostItHelper::SwLayoutStatus mLayoutStatus;
97 : SwLayoutInfo maLayoutInfo;
98 :
99 0 : SwSidebarItem( const bool aShow,
100 : const bool aFocus)
101 : : pPostIt(0)
102 : , bShow(aShow)
103 : , bFocus(aFocus)
104 : , mLayoutStatus( SwPostItHelper::INVISIBLE )
105 0 : , maLayoutInfo()
106 : {
107 0 : }
108 :
109 0 : virtual ~SwSidebarItem()
110 0 : {
111 0 : }
112 :
113 : virtual SwPosition GetAnchorPosition() const = 0;
114 : virtual bool UseElement() = 0;
115 : virtual const SwFmtFld& GetFmtFld() const = 0;
116 : virtual const SfxBroadcaster* GetBroadCaster() const = 0;
117 : virtual 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 0 : SwAnnotationItem(
127 : SwFmtFld& rFmtFld,
128 : const bool aShow,
129 : const bool aFocus)
130 : : SwSidebarItem( aShow, aFocus )
131 0 : , mrFmtFld( rFmtFld )
132 : {
133 0 : }
134 :
135 0 : virtual ~SwAnnotationItem()
136 0 : {
137 0 : }
138 :
139 : virtual SwPosition GetAnchorPosition() const SAL_OVERRIDE;
140 : virtual bool UseElement() SAL_OVERRIDE;
141 0 : virtual const SwFmtFld& GetFmtFld() const SAL_OVERRIDE
142 : {
143 0 : return mrFmtFld;
144 : }
145 0 : virtual const SfxBroadcaster* GetBroadCaster() const SAL_OVERRIDE
146 : {
147 0 : return dynamic_cast<const SfxBroadcaster *> (&mrFmtFld);
148 : }
149 : virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow(
150 : SwEditWin& rEditWin,
151 : WinBits nBits,
152 : SwPostItMgr& aMgr,
153 : SwPostItBits aBits ) SAL_OVERRIDE;
154 :
155 : private:
156 : SwFmtFld& mrFmtFld;
157 : };
158 :
159 : #endif // INCLUDED_SW_INC_POSTITHELPER_HXX
160 :
161 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|