1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef INCLUDED_SW_INC_POSTITMGR_HXX
21 #define INCLUDED_SW_INC_POSTITMGR_HXX
25 #include <editeng/outlobj.hxx>
26 #include <rtl/ustring.hxx>
27 #include <sal/log.hxx>
28 #include <tools/link.hxx>
30 #include <unotools/configitem.hxx>
31 #include <unotools/options.hxx>
32 #include <com/sun/star/util/SearchOptions.hpp>
33 #include <com/sun/star/uno/Any.hxx>
34 #include <SidebarWindowsTypes.hxx>
35 #include <svl/lstner.hxx>
36 #include <vcl/vclptr.hxx>
52 class SvxLanguageItem
;
53 namespace sw
{ namespace annotation
{
54 class SwAnnotationWin
;
56 namespace sw
{ namespace sidebarwindows
{
58 class SwFrmSidebarWinContainer
;
62 namespace vcl
{ class Window
; }
65 #define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0)
66 #define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153)
68 typedef std::list
<SwSidebarItem
*> SwSidebarItem_list
;
69 typedef std::list
<SwSidebarItem
*>::iterator SwSidebarItem_iterator
;
71 struct SwPostItPageItem
74 sw::sidebarwindows::SidebarPosition eSidebarPosition
;
77 SwSidebarItem_list
* mList
;
78 SwPostItPageItem(): bScrollbar(false), eSidebarPosition( sw::sidebarwindows::SidebarPosition::LEFT
), lOffset(0)
80 mList
= new SwSidebarItem_list
;
90 struct FieldShadowState
92 const SwPostItField
* mpShadowField
;
95 FieldShadowState(): mpShadowField(0),bCursor(false),bMouse(false)
100 class SwNoteProps
: public utl::ConfigItem
105 virtual void ImplCommit() SAL_OVERRIDE
;
109 : ConfigItem(OUString("Office.Writer/Notes"))
110 , bIsShowAnchor(false)
112 const ::com::sun::star::uno::Sequence
< OUString
>& rNames
= GetPropertyNames();
113 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aValues
= GetProperties(rNames
);
114 const ::com::sun::star::uno::Any
* pValues
= aValues
.getConstArray();
115 SAL_WARN_IF(aValues
.getLength() != rNames
.getLength(), "sw", "GetProperties failed");
116 if (aValues
.getLength())
117 pValues
[0]>>=bIsShowAnchor
;
122 return bIsShowAnchor
;
124 static ::com::sun::star::uno::Sequence
< OUString
>& GetPropertyNames()
126 static ::com::sun::star::uno::Sequence
< OUString
> aNames
;
127 if(!aNames
.getLength())
130 OUString
* pNames
= aNames
.getArray();
131 pNames
[0] = "ShowAnkor";
136 virtual void Notify( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
) SAL_OVERRIDE
;
139 class SwPostItMgr
: public SfxListener
143 SwWrtShell
* mpWrtShell
;
144 VclPtr
<SwEditWin
> mpEditWin
;
145 std::list
< SwSidebarItem
*> mvPostItFields
;
146 std::vector
<SwPostItPageItem
*> mPages
;
147 ImplSVEvent
* mnEventId
;
148 bool mbWaitingForCalcRects
;
149 VclPtr
<sw::sidebarwindows::SwSidebarWin
> mpActivePostIt
;
155 FieldShadowState mShadowState
;
156 OutlinerParaObject
* mpAnswer
;
159 // data structure to collect the <SwSidebarWin> instances for certain <SwFrm> instances.
160 sw::sidebarwindows::SwFrmSidebarWinContainer
* mpFrmSidebarWinContainer
;
162 typedef std::list
<sw::sidebarwindows::SwSidebarWin
*>::iterator SwSidebarWin_iterator
;
164 void AddPostIts(bool bCheckExistance
= true,bool bFocus
= true);
165 void RemoveSidebarWin();
166 void PreparePageContainer();
167 void Scroll(const long lScroll
,const unsigned long aPage
);
168 void AutoScroll(const sw::sidebarwindows::SwSidebarWin
* pPostIt
,const unsigned long aPage
);
169 bool ScrollbarHit(const unsigned long aPage
,const Point
&aPoint
);
170 bool LayoutByPage( std::list
<sw::sidebarwindows::SwSidebarWin
*> &aVisiblePostItList
,
171 const Rectangle
& rBorder
,
173 void CheckForRemovedPostIts();
174 bool ArrowEnabled(sal_uInt16 aDirection
,unsigned long aPage
) const;
175 bool BorderOverPageBorder(unsigned long aPage
) const;
176 bool HasScrollbars() const;
177 void Focus(SfxBroadcaster
& rBC
);
179 sal_Int32
GetInitialAnchorDistance() const;
180 sal_Int32
GetScrollSize() const;
181 sal_Int32
GetSpaceBetween() const;
182 void SetReadOnlyState();
183 DECL_LINK( CalcHdl
, void*);
185 sw::sidebarwindows::SwSidebarWin
* GetSidebarWin(const SfxBroadcaster
* pBroadcaster
) const;
187 void InsertItem( SfxBroadcaster
* pItem
, bool bCheckExistance
, bool bFocus
);
188 void RemoveItem( SfxBroadcaster
* pBroadcast
);
193 SwPostItMgr(SwView
* aDoc
);
194 virtual ~SwPostItMgr();
196 typedef std::list
< SwSidebarItem
* >::const_iterator const_iterator
;
197 const_iterator
begin() const { return mvPostItFields
.begin(); }
198 const_iterator
end() const { return mvPostItFields
.end(); }
200 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
202 void LayoutPostIts();
205 void MakeVisible( const sw::sidebarwindows::SwSidebarWin
* pPostIt
,
208 bool ShowScrollbar(const unsigned long aPage
) const;
209 bool HasNotes() const ;
210 bool ShowNotes() const;
211 bool IsShowAnchor() { return mbIsShowAnchor
;}
212 unsigned long GetSidebarWidth(bool bPx
= false) const;
213 unsigned long GetSidebarBorderWidth(bool bPx
= false) const;
214 unsigned long GetNoteWidth();
216 void PrepareView(bool bIgnoreCount
= false);
218 void CorrectPositions();
220 void SetLayout() { mbLayout
= true; };
221 void Delete(const OUString
& aAuthor
);
224 void ExecuteFormatAllDialog(SwView
& rView
);
225 void FormatAll(const SfxItemSet
&rNewAttr
);
227 void Hide( const OUString
& rAuthor
);
233 Rectangle
GetBottomScrollRect(const unsigned long aPage
) const;
234 Rectangle
GetTopScrollRect(const unsigned long aPage
) const;
236 bool IsHit(const Point
&aPointPixel
);
237 Color
GetArrowColor(sal_uInt16 aDirection
,unsigned long aPage
) const;
239 sw::annotation::SwAnnotationWin
* GetAnnotationWin(const SwPostItField
* pField
) const;
241 sw::sidebarwindows::SwSidebarWin
* GetNextPostIt( sal_uInt16 aDirection
,
242 sw::sidebarwindows::SwSidebarWin
* aPostIt
);
243 long GetNextBorder();
245 sw::sidebarwindows::SwSidebarWin
* GetActiveSidebarWin() { return mpActivePostIt
; }
246 void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin
* p
);
247 bool HasActiveSidebarWin() const;
248 bool HasActiveAnnotationWin() const;
249 void GrabFocusOnActiveSidebarWin();
250 void UpdateDataOnActiveSidebarWin();
251 void DeleteActiveSidebarWin();
252 void HideActiveSidebarWin();
253 void ToggleInsModeOnActiveSidebarWin();
255 sal_Int32
GetMinimumSizeWithMeta() const;
256 sal_Int32
GetSidebarScrollerHeight() const;
258 void SetShadowState(const SwPostItField
* pField
,bool bCursor
= true);
260 void SetSpellChecking();
262 static Color
GetColorDark(sal_uInt16 aAuthorIndex
);
263 static Color
GetColorLight(sal_uInt16 aAuthorIndex
);
264 static Color
GetColorAnchor(sal_uInt16 aAuthorIndex
);
266 void RegisterAnswer(OutlinerParaObject
* pAnswer
) { mpAnswer
= pAnswer
;}
267 OutlinerParaObject
* IsAnswer() {return mpAnswer
;}
268 void CheckMetaText();
269 void StartSpelling();
271 sal_uInt16
Replace(SvxSearchItem
* pItem
);
272 sal_uInt16
SearchReplace(const SwFormatField
&pField
, const ::com::sun::star::util::SearchOptions
& rSearchOptions
,bool bSrchForward
);
273 sal_uInt16
FinishSearchReplace(const ::com::sun::star::util::SearchOptions
& rSearchOptions
,bool bSrchForward
);
275 // get the PostIt window by index
276 sal_Int32
GetPostItCount() const {return mvPostItFields
.size();}
277 void AssureStdModeAtShell();
279 void ConnectSidebarWinToFrm( const SwFrm
& rFrm
,
280 const SwFormatField
& rFormatField
,
281 sw::sidebarwindows::SwSidebarWin
& rSidebarWin
);
282 void DisconnectSidebarWinFromFrm( const SwFrm
& rFrm
,
283 sw::sidebarwindows::SwSidebarWin
& rSidebarWin
);
284 bool HasFrmConnectedSidebarWins( const SwFrm
& rFrm
);
285 vcl::Window
* GetSidebarWinForFrmByIndex( const SwFrm
& rFrm
,
286 const sal_Int32 nIndex
);
287 void GetAllSidebarWinForFrm( const SwFrm
& rFrm
,
288 std::vector
< vcl::Window
* >* pChildren
);
290 void DrawNotesForPage(OutputDevice
*pOutDev
, sal_uInt32 nPage
);
295 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */