1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _POSTITMGR_HXX
29 #define _POSTITMGR_HXX
33 #include <editeng/outlobj.hxx>
34 #include <tools/string.hxx>
35 #include <tools/link.hxx>
36 #include <tools/debug.hxx>
38 #include <unotools/configitem.hxx>
39 #include <unotools/options.hxx>
40 #include <com/sun/star/util/SearchOptions.hpp>
41 #include <com/sun/star/uno/Any.hxx>
42 #include <SidebarWindowsTypes.hxx>
43 #include <svl/lstner.hxx>
56 class SvxLanguageItem
;
57 namespace sw
{ namespace annotation
{
58 class SwAnnotationWin
;
60 namespace sw
{ namespace sidebarwindows
{
62 class SwFrmSidebarWinContainer
;
72 #define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0)
73 #define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153)
75 typedef std::list
<SwSidebarItem
*> SwSidebarItem_list
;
76 typedef std::list
<SwSidebarItem
*>::iterator SwSidebarItem_iterator
;
79 struct SwPostItPageItem
82 sw::sidebarwindows::SidebarPosition eSidebarPosition
;
85 SwSidebarItem_list
* mList
;
86 SwPostItPageItem(): bScrollbar(false),lOffset(0)
88 mList
= new SwSidebarItem_list
;
98 struct FieldShadowState
100 const SwPostItField
* mpShadowFld
;
103 FieldShadowState(): mpShadowFld(0),bCursor(false),bMouse(false)
108 class SwNoteProps
: public utl::ConfigItem
114 : ConfigItem(::rtl::OUString::createFromAscii("Office.Writer/Notes"))
115 , bIsShowAnchor(false)
117 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& rNames
= GetPropertyNames();
118 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aValues
= GetProperties(rNames
);
119 const ::com::sun::star::uno::Any
* pValues
= aValues
.getConstArray();
120 DBG_ASSERT(aValues
.getLength() == rNames
.getLength(), "GetProperties failed");
121 if (aValues
.getLength())
122 pValues
[0]>>=bIsShowAnchor
;
127 return bIsShowAnchor
;
129 ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& GetPropertyNames()
131 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> aNames
;
132 if(!aNames
.getLength())
134 static const char* aPropNames
[] =
138 const int nCount
= sizeof(aPropNames
)/sizeof(const char*);
139 aNames
.realloc(nCount
);
140 ::rtl::OUString
* pNames
= aNames
.getArray();
141 for(int i
= 0; i
< nCount
; i
++)
142 pNames
[i
] = ::rtl::OUString::createFromAscii(aPropNames
[i
]);
147 virtual void Commit();
148 virtual void Notify( const ::com::sun::star::uno::Sequence
< rtl::OUString
>& aPropertyNames
);
151 class SwPostItMgr
: public SfxListener
155 SwWrtShell
* mpWrtShell
;
156 SwEditWin
* mpEditWin
;
157 std::list
< SwSidebarItem
*> mvPostItFlds
;
158 std::vector
<SwPostItPageItem
*> mPages
;
160 bool mbWaitingForCalcRects
;
161 sw::sidebarwindows::SwSidebarWin
* mpActivePostIt
;
167 FieldShadowState mShadowState
;
168 OutlinerParaObject
* mpAnswer
;
171 // data structure to collect the <SwSidebarWin> instances for certain <SwFrm> instances.
172 sw::sidebarwindows::SwFrmSidebarWinContainer
* mpFrmSidebarWinContainer
;
174 typedef std::list
<sw::sidebarwindows::SwSidebarWin
*>::iterator SwSidebarWin_iterator
;
176 void AddPostIts(bool bCheckExistance
= true,bool bFocus
= true);
177 //void AddRedlineComments(bool bCheckExistance, bool bFocus);
178 void RemoveSidebarWin();
179 void PreparePageContainer();
180 void Scroll(const long lScroll
,const unsigned long aPage
);
181 void AutoScroll(const sw::sidebarwindows::SwSidebarWin
* pPostIt
,const unsigned long aPage
);
182 bool ScrollbarHit(const unsigned long aPage
,const Point
&aPoint
);
183 bool LayoutByPage( std::list
<sw::sidebarwindows::SwSidebarWin
*> &aVisiblePostItList
,
184 const Rectangle aBorder
,
186 void CheckForRemovedPostIts();
187 bool ArrowEnabled(USHORT aDirection
,unsigned long aPage
) const;
188 bool BorderOverPageBorder(unsigned long aPage
) const;
189 bool HasScrollbars() const;
190 void Focus(SfxBroadcaster
& rBC
);
192 sal_Int32
GetInitialAnchorDistance() const;
193 sal_Int32
GetScrollSize() const;
194 sal_Int32
GetSpaceBetween() const;
195 void SetReadOnlyState();
196 DECL_LINK( CalcHdl
, void*);
198 sw::sidebarwindows::SwSidebarWin
* GetSidebarWin(const SfxBroadcaster
* pBroadcaster
) const;
200 void InsertItem( SfxBroadcaster
* pItem
, bool bCheckExistance
, bool bFocus
);
201 void RemoveItem( SfxBroadcaster
* pBroadcast
);
203 void Sort(const short aType
);
206 SwPostItMgr(SwView
* aDoc
);
209 typedef std::list
< SwSidebarItem
* >::const_iterator const_iterator
;
210 const_iterator
begin() const { return mvPostItFlds
.begin(); }
211 const_iterator
end() const { return mvPostItFlds
.end(); }
213 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
215 void LayoutPostIts();
218 void MakeVisible( const sw::sidebarwindows::SwSidebarWin
* pPostIt
,
221 bool ShowScrollbar(const unsigned long aPage
) const;
222 bool HasNotes() const ;
223 bool ShowNotes() const;
224 bool IsShowAnchor() { return mbIsShowAnchor
;}
225 unsigned long GetSidebarWidth(bool bPx
= false) const;
226 unsigned long GetSidebarBorderWidth(bool bPx
= false) const;
227 unsigned long GetNoteWidth();
229 void PrepareView(bool bIgnoreCount
= false);
231 void CorrectPositions();
233 void SetLayout() { mbLayout
= true; };
234 void Delete(String aAuthor
);
238 void Hide( SwPostItField
* pPostItField
);
240 void Hide( const String
& rAuthor
);
246 Rectangle
GetBottomScrollRect(const unsigned long aPage
) const;
247 Rectangle
GetTopScrollRect(const unsigned long aPage
) const;
249 bool IsHit(const Point
&aPointPixel
);
250 Color
GetArrowColor(USHORT aDirection
,unsigned long aPage
) const;
252 sw::annotation::SwAnnotationWin
* GetAnnotationWin(const SwPostItField
* pFld
) const;
254 sw::sidebarwindows::SwSidebarWin
* GetNextPostIt( USHORT aDirection
,
255 sw::sidebarwindows::SwSidebarWin
* aPostIt
);
256 long GetNextBorder();
258 sw::sidebarwindows::SwSidebarWin
* GetActiveSidebarWin() { return mpActivePostIt
; }
259 void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin
* p
);
260 bool HasActiveSidebarWin() const;
261 bool HasActiveAnnotationWin() const;
262 void GrabFocusOnActiveSidebarWin();
263 void UpdateDataOnActiveSidebarWin();
264 void DeleteActiveSidebarWin();
265 void HideActiveSidebarWin();
266 void ToggleInsModeOnActiveSidebarWin();
268 sal_Int32
GetMinimumSizeWithMeta() const;
269 sal_Int32
GetSidebarScrollerHeight() const;
271 void SetShadowState(const SwPostItField
* pFld
,bool bCursor
= true);
273 void SetSpellChecking();
275 Color
GetColorDark(sal_uInt16 aAuthorIndex
);
276 Color
GetColorLight(sal_uInt16 aAuthorIndex
);
277 Color
GetColorAnchor(sal_uInt16 aAuthorIndex
);
280 void RegisterAnswer(OutlinerParaObject
* pAnswer
) { mpAnswer
= pAnswer
;}
281 OutlinerParaObject
* IsAnswer() {return mpAnswer
;}
282 void CheckMetaText();
283 void StartSpelling();
285 sal_uInt16
Replace(SvxSearchItem
* pItem
);
286 sal_uInt16
SearchReplace(const SwFmtFld
&pFld
, const ::com::sun::star::util::SearchOptions
& rSearchOptions
,bool bSrchForward
);
287 sal_uInt16
FinishSearchReplace(const ::com::sun::star::util::SearchOptions
& rSearchOptions
,bool bSrchForward
);
289 void AssureStdModeAtShell();
291 void ConnectSidebarWinToFrm( const SwFrm
& rFrm
,
292 const SwFmtFld
& rFmtFld
,
293 sw::sidebarwindows::SwSidebarWin
& rSidebarWin
);
294 void DisconnectSidebarWinFromFrm( const SwFrm
& rFrm
,
295 sw::sidebarwindows::SwSidebarWin
& rSidebarWin
);
296 bool HasFrmConnectedSidebarWins( const SwFrm
& rFrm
);
297 Window
* GetSidebarWinForFrmByIndex( const SwFrm
& rFrm
,
298 const sal_Int32 nIndex
);
299 void GetAllSidebarWinForFrm( const SwFrm
& rFrm
,
300 std::vector
< Window
* >* pChildren
);