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 _POSTITMGR_HXX
21 #define _POSTITMGR_HXX
25 #include <editeng/outlobj.hxx>
26 #include <tools/string.hxx>
27 #include <tools/link.hxx>
29 #include <unotools/configitem.hxx>
30 #include <unotools/options.hxx>
31 #include <com/sun/star/util/SearchOptions.hpp>
32 #include <com/sun/star/uno/Any.hxx>
33 #include <SidebarWindowsTypes.hxx>
34 #include <svl/lstner.hxx>
47 class SvxLanguageItem
;
48 namespace sw
{ namespace annotation
{
49 class SwAnnotationWin
;
51 namespace sw
{ namespace sidebarwindows
{
53 class SwFrmSidebarWinContainer
;
63 #define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0)
64 #define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153)
66 typedef std::list
<SwSidebarItem
*> SwSidebarItem_list
;
67 typedef std::list
<SwSidebarItem
*>::iterator SwSidebarItem_iterator
;
70 struct SwPostItPageItem
73 sw::sidebarwindows::SidebarPosition eSidebarPosition
;
76 SwSidebarItem_list
* mList
;
77 SwPostItPageItem(): bScrollbar(false), eSidebarPosition( sw::sidebarwindows::SIDEBAR_LEFT
), lOffset(0)
79 mList
= new SwSidebarItem_list
;
89 struct FieldShadowState
91 const SwPostItField
* mpShadowFld
;
94 FieldShadowState(): mpShadowFld(0),bCursor(false),bMouse(false)
99 class SwNoteProps
: public utl::ConfigItem
105 : ConfigItem(OUString("Office.Writer/Notes"))
106 , bIsShowAnchor(false)
108 const ::com::sun::star::uno::Sequence
< OUString
>& rNames
= GetPropertyNames();
109 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aValues
= GetProperties(rNames
);
110 const ::com::sun::star::uno::Any
* pValues
= aValues
.getConstArray();
111 OSL_ENSURE(aValues
.getLength() == rNames
.getLength(), "GetProperties failed");
112 if (aValues
.getLength())
113 pValues
[0]>>=bIsShowAnchor
;
118 return bIsShowAnchor
;
120 ::com::sun::star::uno::Sequence
< OUString
>& GetPropertyNames()
122 static ::com::sun::star::uno::Sequence
< OUString
> aNames
;
123 if(!aNames
.getLength())
126 OUString
* pNames
= aNames
.getArray();
127 pNames
[0] = OUString("ShowAnkor");
132 virtual void Commit();
133 virtual void Notify( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
);
136 class SwPostItMgr
: public SfxListener
140 SwWrtShell
* mpWrtShell
;
141 SwEditWin
* mpEditWin
;
142 std::list
< SwSidebarItem
*> mvPostItFlds
;
143 std::vector
<SwPostItPageItem
*> mPages
;
145 bool mbWaitingForCalcRects
;
146 sw::sidebarwindows::SwSidebarWin
* mpActivePostIt
;
152 FieldShadowState mShadowState
;
153 OutlinerParaObject
* mpAnswer
;
156 // data structure to collect the <SwSidebarWin> instances for certain <SwFrm> instances.
157 sw::sidebarwindows::SwFrmSidebarWinContainer
* mpFrmSidebarWinContainer
;
159 typedef std::list
<sw::sidebarwindows::SwSidebarWin
*>::iterator SwSidebarWin_iterator
;
161 void AddPostIts(bool bCheckExistance
= true,bool bFocus
= true);
162 void RemoveSidebarWin();
163 void PreparePageContainer();
164 void Scroll(const long lScroll
,const unsigned long aPage
);
165 void AutoScroll(const sw::sidebarwindows::SwSidebarWin
* pPostIt
,const unsigned long aPage
);
166 bool ScrollbarHit(const unsigned long aPage
,const Point
&aPoint
);
167 bool LayoutByPage( std::list
<sw::sidebarwindows::SwSidebarWin
*> &aVisiblePostItList
,
168 const Rectangle aBorder
,
170 void CheckForRemovedPostIts();
171 bool ArrowEnabled(sal_uInt16 aDirection
,unsigned long aPage
) const;
172 bool BorderOverPageBorder(unsigned long aPage
) const;
173 bool HasScrollbars() const;
174 void Focus(SfxBroadcaster
& rBC
);
176 sal_Int32
GetInitialAnchorDistance() const;
177 sal_Int32
GetScrollSize() const;
178 sal_Int32
GetSpaceBetween() const;
179 void SetReadOnlyState();
180 DECL_LINK( CalcHdl
, void*);
182 sw::sidebarwindows::SwSidebarWin
* GetSidebarWin(const SfxBroadcaster
* pBroadcaster
) const;
184 void InsertItem( SfxBroadcaster
* pItem
, bool bCheckExistance
, bool bFocus
);
185 void RemoveItem( SfxBroadcaster
* pBroadcast
);
187 void Sort(const short aType
);
190 SwPostItMgr(SwView
* aDoc
);
193 typedef std::list
< SwSidebarItem
* >::const_iterator const_iterator
;
194 const_iterator
begin() const { return mvPostItFlds
.begin(); }
195 const_iterator
end() const { return mvPostItFlds
.end(); }
197 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
199 void LayoutPostIts();
202 void MakeVisible( const sw::sidebarwindows::SwSidebarWin
* pPostIt
,
205 bool ShowScrollbar(const unsigned long aPage
) const;
206 bool HasNotes() const ;
207 bool ShowNotes() const;
208 bool IsShowAnchor() { return mbIsShowAnchor
;}
209 unsigned long GetSidebarWidth(bool bPx
= false) const;
210 unsigned long GetSidebarBorderWidth(bool bPx
= false) const;
211 unsigned long GetNoteWidth();
213 void PrepareView(bool bIgnoreCount
= false);
215 void CorrectPositions();
217 void SetLayout() { mbLayout
= true; };
218 void Delete(String aAuthor
);
221 void Hide( const String
& rAuthor
);
227 Rectangle
GetBottomScrollRect(const unsigned long aPage
) const;
228 Rectangle
GetTopScrollRect(const unsigned long aPage
) const;
230 bool IsHit(const Point
&aPointPixel
);
231 Color
GetArrowColor(sal_uInt16 aDirection
,unsigned long aPage
) const;
233 sw::annotation::SwAnnotationWin
* GetAnnotationWin(const SwPostItField
* pFld
) const;
235 sw::sidebarwindows::SwSidebarWin
* GetNextPostIt( sal_uInt16 aDirection
,
236 sw::sidebarwindows::SwSidebarWin
* aPostIt
);
237 long GetNextBorder();
239 sw::sidebarwindows::SwSidebarWin
* GetActiveSidebarWin() { return mpActivePostIt
; }
240 void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin
* p
);
241 bool HasActiveSidebarWin() const;
242 bool HasActiveAnnotationWin() const;
243 void GrabFocusOnActiveSidebarWin();
244 void UpdateDataOnActiveSidebarWin();
245 void DeleteActiveSidebarWin();
246 void HideActiveSidebarWin();
247 void ToggleInsModeOnActiveSidebarWin();
249 sal_Int32
GetMinimumSizeWithMeta() const;
250 sal_Int32
GetSidebarScrollerHeight() const;
252 void SetShadowState(const SwPostItField
* pFld
,bool bCursor
= true);
254 void SetSpellChecking();
256 static Color
GetColorDark(sal_uInt16 aAuthorIndex
);
257 static Color
GetColorLight(sal_uInt16 aAuthorIndex
);
258 static Color
GetColorAnchor(sal_uInt16 aAuthorIndex
);
261 void RegisterAnswer(OutlinerParaObject
* pAnswer
) { mpAnswer
= pAnswer
;}
262 OutlinerParaObject
* IsAnswer() {return mpAnswer
;}
263 void CheckMetaText();
264 void StartSpelling();
266 sal_uInt16
Replace(SvxSearchItem
* pItem
);
267 sal_uInt16
SearchReplace(const SwFmtFld
&pFld
, const ::com::sun::star::util::SearchOptions
& rSearchOptions
,bool bSrchForward
);
268 sal_uInt16
FinishSearchReplace(const ::com::sun::star::util::SearchOptions
& rSearchOptions
,bool bSrchForward
);
270 void AssureStdModeAtShell();
272 void ConnectSidebarWinToFrm( const SwFrm
& rFrm
,
273 const SwFmtFld
& rFmtFld
,
274 sw::sidebarwindows::SwSidebarWin
& rSidebarWin
);
275 void DisconnectSidebarWinFromFrm( const SwFrm
& rFrm
,
276 sw::sidebarwindows::SwSidebarWin
& rSidebarWin
);
277 bool HasFrmConnectedSidebarWins( const SwFrm
& rFrm
);
278 Window
* GetSidebarWinForFrmByIndex( const SwFrm
& rFrm
,
279 const sal_Int32 nIndex
);
280 void GetAllSidebarWinForFrm( const SwFrm
& rFrm
,
281 std::vector
< Window
* >* pChildren
);
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */