1*efeef26fSAndrew Rist /**************************************************************
2*efeef26fSAndrew Rist  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <SidebarTxtControl.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <SidebarTxtControlAcc.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <SidebarWin.hxx>
32cdf0e10cSrcweir #include <PostItMgr.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <cmdid.h>
35cdf0e10cSrcweir #include <docvw.hrc>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <unotools/securityoptions.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
40cdf0e10cSrcweir #include <sfx2/bindings.hxx>
41cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
42cdf0e10cSrcweir #include <sfx2/mnumgr.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <vcl/svapp.hxx>
45cdf0e10cSrcweir #include <vcl/help.hxx>
46cdf0e10cSrcweir #include <vcl/msgbox.hxx>
47cdf0e10cSrcweir #include <vcl/gradient.hxx>
48cdf0e10cSrcweir #include <vcl/scrbar.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <editeng/outliner.hxx>
51cdf0e10cSrcweir #include <editeng/editeng.hxx>
52cdf0e10cSrcweir #include <editeng/editview.hxx>
53cdf0e10cSrcweir #include <editeng/flditem.hxx>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #include <uitool.hxx>
56cdf0e10cSrcweir #include <view.hxx>
57cdf0e10cSrcweir #include <wrtsh.hxx>
58cdf0e10cSrcweir #include <shellres.hxx>
59cdf0e10cSrcweir #include <SwRewriter.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir namespace css = ::com::sun::star;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir namespace sw { namespace sidebarwindows {
64cdf0e10cSrcweir 
SidebarTxtControl(SwSidebarWin & rSidebarWin,WinBits nBits,SwView & rDocView,SwPostItMgr & rPostItMgr)65cdf0e10cSrcweir SidebarTxtControl::SidebarTxtControl( SwSidebarWin& rSidebarWin,
66cdf0e10cSrcweir                                       WinBits nBits,
67cdf0e10cSrcweir                                       SwView& rDocView,
68cdf0e10cSrcweir                                       SwPostItMgr& rPostItMgr )
69cdf0e10cSrcweir     : Control( &rSidebarWin, nBits )
70cdf0e10cSrcweir     , mrSidebarWin( rSidebarWin )
71cdf0e10cSrcweir     , mrDocView( rDocView )
72cdf0e10cSrcweir     , mrPostItMgr( rPostItMgr )
73cdf0e10cSrcweir     , mbMouseOver( false )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     AddEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
~SidebarTxtControl()78cdf0e10cSrcweir SidebarTxtControl::~SidebarTxtControl()
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     RemoveEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) );
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
GetTextView() const83cdf0e10cSrcweir OutlinerView* SidebarTxtControl::GetTextView() const
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     return mrSidebarWin.GetOutlinerView();
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
GetFocus()88cdf0e10cSrcweir void SidebarTxtControl::GetFocus()
89cdf0e10cSrcweir {
90cdf0e10cSrcweir     Window::GetFocus();
91cdf0e10cSrcweir     if ( !mrSidebarWin.IsMouseOver() )
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir         Invalidate();
94cdf0e10cSrcweir     }
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
LoseFocus()97cdf0e10cSrcweir void SidebarTxtControl::LoseFocus()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir     // write the visible text back into the SwField
100cdf0e10cSrcweir     mrSidebarWin.UpdateData();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     Window::LoseFocus();
103cdf0e10cSrcweir     if ( !mrSidebarWin.IsMouseOver() )
104cdf0e10cSrcweir     {
105cdf0e10cSrcweir         Invalidate();
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
RequestHelp(const HelpEvent & rEvt)109cdf0e10cSrcweir void SidebarTxtControl::RequestHelp(const HelpEvent &rEvt)
110cdf0e10cSrcweir {
111cdf0e10cSrcweir     sal_uInt16 nResId = 0;
112cdf0e10cSrcweir     switch( mrSidebarWin.GetLayoutStatus() )
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir         case SwPostItHelper::INSERTED:  nResId = STR_REDLINE_INSERT; break;
115cdf0e10cSrcweir         case SwPostItHelper::DELETED:   nResId = STR_REDLINE_DELETE; break;
116cdf0e10cSrcweir         default: nResId = 0;
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
120cdf0e10cSrcweir     if ( nResId &&
121cdf0e10cSrcweir          mrDocView.GetWrtShell().GetContentAtPos( mrSidebarWin.GetAnchorPos(), aCntntAtPos ) )
122cdf0e10cSrcweir     {
123cdf0e10cSrcweir         String sTxt;
124cdf0e10cSrcweir         sTxt = SW_RESSTR( nResId );
125cdf0e10cSrcweir         sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": " ));
126cdf0e10cSrcweir         sTxt += aCntntAtPos.aFnd.pRedl->GetAuthorString();
127cdf0e10cSrcweir         sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ));
128cdf0e10cSrcweir         sTxt += GetAppLangDateTimeString( aCntntAtPos.aFnd.pRedl->GetTimeStamp() );
129cdf0e10cSrcweir         Help::ShowQuickHelp( this,PixelToLogic(Rectangle(rEvt.GetMousePosPixel(),Size(50,10))),sTxt);
130cdf0e10cSrcweir     }
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
Paint(const Rectangle & rRect)133cdf0e10cSrcweir void SidebarTxtControl::Paint( const Rectangle& rRect)
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
136cdf0e10cSrcweir     {
137cdf0e10cSrcweir         if ( mrSidebarWin.IsMouseOverSidebarWin() ||
138cdf0e10cSrcweir              HasFocus() )
139cdf0e10cSrcweir         {
140cdf0e10cSrcweir             DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ),
141cdf0e10cSrcweir                           Gradient( GRADIENT_LINEAR,
142cdf0e10cSrcweir                                     mrSidebarWin.ColorDark(),
143cdf0e10cSrcweir                                     mrSidebarWin.ColorDark() ) );
144cdf0e10cSrcweir         }
145cdf0e10cSrcweir         else
146cdf0e10cSrcweir         {
147cdf0e10cSrcweir             DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ),
148cdf0e10cSrcweir                           Gradient( GRADIENT_LINEAR,
149cdf0e10cSrcweir                                     mrSidebarWin.ColorLight(),
150cdf0e10cSrcweir                                     mrSidebarWin.ColorDark()));
151cdf0e10cSrcweir         }
152cdf0e10cSrcweir     }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     if ( GetTextView() )
155cdf0e10cSrcweir     {
156cdf0e10cSrcweir         GetTextView()->Paint( rRect );
157cdf0e10cSrcweir     }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     if ( mrSidebarWin.GetLayoutStatus()==SwPostItHelper::DELETED )
160cdf0e10cSrcweir     {
161cdf0e10cSrcweir         SetLineColor(mrSidebarWin.GetChangeColor());
162cdf0e10cSrcweir         DrawLine( PixelToLogic( GetPosPixel() ),
163cdf0e10cSrcweir                   PixelToLogic( GetPosPixel() +
164cdf0e10cSrcweir                                 Point( GetSizePixel().Width(),
165cdf0e10cSrcweir                                        GetSizePixel().Height() ) ) );
166cdf0e10cSrcweir         DrawLine( PixelToLogic( GetPosPixel() +
167cdf0e10cSrcweir                                 Point( GetSizePixel().Width(),0) ),
168cdf0e10cSrcweir                   PixelToLogic( GetPosPixel() +
169cdf0e10cSrcweir                                 Point( 0, GetSizePixel().Height() ) ) );
170cdf0e10cSrcweir     }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKeyEvt)173cdf0e10cSrcweir void SidebarTxtControl::KeyInput( const KeyEvent& rKeyEvt )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     const KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
176cdf0e10cSrcweir     sal_uInt16 nKey = rKeyCode.GetCode();
177cdf0e10cSrcweir     if ( ( rKeyCode.IsMod1() && rKeyCode.IsMod2() ) &&
178cdf0e10cSrcweir          ( (nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN) ) )
179cdf0e10cSrcweir     {
180cdf0e10cSrcweir         mrSidebarWin.SwitchToPostIt(nKey);
181cdf0e10cSrcweir     }
182cdf0e10cSrcweir     else if ( nKey == KEY_ESCAPE ||
183cdf0e10cSrcweir               ( rKeyCode.IsMod1() &&
184cdf0e10cSrcweir                 ( nKey == KEY_PAGEUP ||
185cdf0e10cSrcweir                   nKey == KEY_PAGEDOWN ) ) )
186cdf0e10cSrcweir     {
187cdf0e10cSrcweir         mrSidebarWin.SwitchToFieldPos();
188cdf0e10cSrcweir     }
189cdf0e10cSrcweir     else if ( nKey == KEY_INSERT )
190cdf0e10cSrcweir     {
191cdf0e10cSrcweir         if ( !rKeyCode.IsMod1() && !rKeyCode.IsMod2() )
192cdf0e10cSrcweir         {
193cdf0e10cSrcweir             mrSidebarWin.ToggleInsMode();
194cdf0e10cSrcweir         }
195cdf0e10cSrcweir     }
196cdf0e10cSrcweir     else
197cdf0e10cSrcweir     {
198cdf0e10cSrcweir         //let's make sure we see our note
199cdf0e10cSrcweir         mrPostItMgr.MakeVisible(&mrSidebarWin);
200cdf0e10cSrcweir 
201cdf0e10cSrcweir         long aOldHeight = mrSidebarWin.GetPostItTextHeight();
202cdf0e10cSrcweir         bool bDone = false;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir         /// HACK: need to switch off processing of Undo/Redo in Outliner
205cdf0e10cSrcweir         if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) )
206cdf0e10cSrcweir         {
207cdf0e10cSrcweir             bool bIsProtected = mrSidebarWin.IsProtected();
208cdf0e10cSrcweir             if ( !bIsProtected ||
209cdf0e10cSrcweir                  ( bIsProtected &&
210cdf0e10cSrcweir                    !mrSidebarWin.GetOutlinerView()->GetOutliner()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) )
211cdf0e10cSrcweir             {
212cdf0e10cSrcweir                 bDone = GetTextView() && GetTextView()->PostKeyEvent( rKeyEvt );
213cdf0e10cSrcweir             }
214cdf0e10cSrcweir             else
215cdf0e10cSrcweir             {
216cdf0e10cSrcweir                 InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute();
217cdf0e10cSrcweir             }
218cdf0e10cSrcweir         }
219cdf0e10cSrcweir         if (bDone)
220cdf0e10cSrcweir             mrSidebarWin.ResizeIfNeccessary( aOldHeight, mrSidebarWin.GetPostItTextHeight() );
221cdf0e10cSrcweir         else
222cdf0e10cSrcweir         {
223cdf0e10cSrcweir             // write back data first when showing navigator
224cdf0e10cSrcweir             if ( nKey==KEY_F5 )
225cdf0e10cSrcweir                 mrSidebarWin.UpdateData();
226cdf0e10cSrcweir             if (!mrDocView.KeyInput(rKeyEvt))
227cdf0e10cSrcweir                 Window::KeyInput(rKeyEvt);
228cdf0e10cSrcweir         }
229cdf0e10cSrcweir     }
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     mrDocView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)234cdf0e10cSrcweir void SidebarTxtControl::MouseMove( const MouseEvent& rMEvt )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir     if ( GetTextView() )
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         OutlinerView* pOutlinerView( GetTextView() );
239cdf0e10cSrcweir         pOutlinerView->MouseMove( rMEvt );
240cdf0e10cSrcweir         // mba: why does OutlinerView not handle the modifier setting?!
241cdf0e10cSrcweir         // this forces the postit to handle *all* pointer types
242cdf0e10cSrcweir         SetPointer( pOutlinerView->GetPointer( rMEvt.GetPosPixel() ) );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir         const EditView& aEV = pOutlinerView->GetEditView();
245cdf0e10cSrcweir         const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
246cdf0e10cSrcweir         if ( pItem )
247cdf0e10cSrcweir         {
248cdf0e10cSrcweir             const SvxFieldData* pFld = pItem->GetField();
249cdf0e10cSrcweir             const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
250cdf0e10cSrcweir             if ( pURL )
251cdf0e10cSrcweir             {
252cdf0e10cSrcweir                 String sURL( pURL->GetURL() );
253cdf0e10cSrcweir                 SvtSecurityOptions aSecOpts;
254cdf0e10cSrcweir                 if ( aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK) )
255cdf0e10cSrcweir                 {
256cdf0e10cSrcweir                     sURL.InsertAscii( ": ", 0 );
257cdf0e10cSrcweir                     sURL.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
258cdf0e10cSrcweir                 }
259cdf0e10cSrcweir                 Help::ShowQuickHelp( this,PixelToLogic(Rectangle(GetPosPixel(),Size(50,10))),sURL);
260cdf0e10cSrcweir             }
261cdf0e10cSrcweir         }
262cdf0e10cSrcweir     }
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)265cdf0e10cSrcweir void SidebarTxtControl::MouseButtonDown( const MouseEvent& rMEvt )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir     if ( GetTextView() )
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         SvtSecurityOptions aSecOpts;
270cdf0e10cSrcweir         bool bExecuteMod = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK);
271cdf0e10cSrcweir 
272cdf0e10cSrcweir         if ( !bExecuteMod || (bExecuteMod && rMEvt.GetModifier() == KEY_MOD1))
273cdf0e10cSrcweir         {
274cdf0e10cSrcweir             const EditView& aEV = GetTextView()->GetEditView();
275cdf0e10cSrcweir             const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
276cdf0e10cSrcweir             if ( pItem )
277cdf0e10cSrcweir             {
278cdf0e10cSrcweir                 const SvxFieldData* pFld = pItem->GetField();
279cdf0e10cSrcweir                 const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
280cdf0e10cSrcweir                 if ( pURL )
281cdf0e10cSrcweir                 {
282cdf0e10cSrcweir                     GetTextView()->MouseButtonDown( rMEvt );
283cdf0e10cSrcweir                     SwWrtShell &rSh = mrDocView.GetWrtShell();
284cdf0e10cSrcweir                     String sURL( pURL->GetURL() );
285cdf0e10cSrcweir                     String sTarget( pURL->GetTargetFrame() );
286cdf0e10cSrcweir                     ::LoadURL( sURL, &rSh, URLLOAD_NOFILTER, &sTarget);
287cdf0e10cSrcweir                     return;
288cdf0e10cSrcweir                 }
289cdf0e10cSrcweir             }
290cdf0e10cSrcweir         }
291cdf0e10cSrcweir     }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     GrabFocus();
294cdf0e10cSrcweir     if ( GetTextView() )
295cdf0e10cSrcweir     {
296cdf0e10cSrcweir         GetTextView()->MouseButtonDown( rMEvt );
297cdf0e10cSrcweir     }
298cdf0e10cSrcweir     mrDocView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)301cdf0e10cSrcweir void SidebarTxtControl::MouseButtonUp( const MouseEvent& rMEvt )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir     if ( GetTextView() )
304cdf0e10cSrcweir         GetTextView()->MouseButtonUp( rMEvt );
305cdf0e10cSrcweir }
306cdf0e10cSrcweir 
IMPL_LINK(SidebarTxtControl,OnlineSpellCallback,SpellCallbackInfo *,pInfo)307cdf0e10cSrcweir IMPL_LINK( SidebarTxtControl, OnlineSpellCallback, SpellCallbackInfo*, pInfo )
308cdf0e10cSrcweir {
309cdf0e10cSrcweir     if ( pInfo->nCommand == SPELLCMD_STARTSPELLDLG )
310cdf0e10cSrcweir     {
311cdf0e10cSrcweir         mrDocView.GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
312cdf0e10cSrcweir     }
313cdf0e10cSrcweir     return 0;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
IMPL_LINK(SidebarTxtControl,Select,Menu *,pSelMenu)316cdf0e10cSrcweir IMPL_LINK( SidebarTxtControl, Select, Menu*, pSelMenu )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir     mrSidebarWin.ExecuteCommand( pSelMenu->GetCurItemId() );
319cdf0e10cSrcweir     return 0;
320cdf0e10cSrcweir }
321cdf0e10cSrcweir 
Command(const CommandEvent & rCEvt)322cdf0e10cSrcweir void SidebarTxtControl::Command( const CommandEvent& rCEvt )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir     if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
325cdf0e10cSrcweir     {
326cdf0e10cSrcweir         if ( !mrSidebarWin.IsProtected() &&
327cdf0e10cSrcweir              GetTextView() &&
328cdf0e10cSrcweir              GetTextView()->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),sal_True ))
329cdf0e10cSrcweir         {
330cdf0e10cSrcweir             Link aLink = LINK(this, SidebarTxtControl, OnlineSpellCallback);
331cdf0e10cSrcweir             GetTextView()->ExecuteSpellPopup(rCEvt.GetMousePosPixel(),&aLink);
332cdf0e10cSrcweir         }
333cdf0e10cSrcweir         else
334cdf0e10cSrcweir         {
335cdf0e10cSrcweir             SfxPopupMenuManager* pMgr = mrDocView.GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel());
336cdf0e10cSrcweir             ((PopupMenu*)pMgr->GetSVMenu())->SetSelectHdl( LINK(this, SidebarTxtControl, Select) );
337cdf0e10cSrcweir 
338cdf0e10cSrcweir             {
339cdf0e10cSrcweir                 XubString aText = ((PopupMenu*)pMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR );
340cdf0e10cSrcweir                 SwRewriter aRewriter;
341cdf0e10cSrcweir                 aRewriter.AddRule(UNDO_ARG1, mrSidebarWin.GetAuthor());
342cdf0e10cSrcweir                 aText = aRewriter.Apply(aText);
343cdf0e10cSrcweir                 ((PopupMenu*)pMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
344cdf0e10cSrcweir             }
345cdf0e10cSrcweir 
346cdf0e10cSrcweir             Point aPos;
347cdf0e10cSrcweir             if (rCEvt.IsMouseEvent())
348cdf0e10cSrcweir                 aPos = rCEvt.GetMousePosPixel();
349cdf0e10cSrcweir             else
350cdf0e10cSrcweir             {
351cdf0e10cSrcweir                 const Size aSize = GetSizePixel();
352cdf0e10cSrcweir                 aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
353cdf0e10cSrcweir             }
354cdf0e10cSrcweir 
355cdf0e10cSrcweir             //!! call different Execute function to get rid of the new thesaurus sub menu
356cdf0e10cSrcweir             //!! pointer created in the call to Popup.
357cdf0e10cSrcweir             //!! Otherwise we would have a memory leak (see also #i107205#)
358cdf0e10cSrcweir             //((PopupMenu*)pMgr->GetSVMenu())->Execute( this, aPos );
359cdf0e10cSrcweir             pMgr->Execute( aPos, this );
360cdf0e10cSrcweir 			delete pMgr;
361cdf0e10cSrcweir         }
362cdf0e10cSrcweir     }
363cdf0e10cSrcweir     else
364cdf0e10cSrcweir     if (rCEvt.GetCommand() == COMMAND_WHEEL)
365cdf0e10cSrcweir     {
366cdf0e10cSrcweir         if (mrSidebarWin.IsScrollbarVisible())
367cdf0e10cSrcweir         {
368cdf0e10cSrcweir             const CommandWheelData* pData = rCEvt.GetWheelData();
369cdf0e10cSrcweir             if (pData->IsShift() || pData->IsMod1() || pData->IsMod2())
370cdf0e10cSrcweir             {
371cdf0e10cSrcweir                 mrDocView.HandleWheelCommands(rCEvt);
372cdf0e10cSrcweir             }
373cdf0e10cSrcweir             else
374cdf0e10cSrcweir             {
375cdf0e10cSrcweir                 HandleScrollCommand( rCEvt, 0 , mrSidebarWin.Scrollbar());
376cdf0e10cSrcweir             }
377cdf0e10cSrcweir         }
378cdf0e10cSrcweir         else
379cdf0e10cSrcweir         {
380cdf0e10cSrcweir             mrDocView.HandleWheelCommands(rCEvt);
381cdf0e10cSrcweir         }
382cdf0e10cSrcweir     }
383cdf0e10cSrcweir     else
384cdf0e10cSrcweir     {
385cdf0e10cSrcweir         if ( GetTextView() )
386cdf0e10cSrcweir             GetTextView()->Command( rCEvt );
387cdf0e10cSrcweir         else
388cdf0e10cSrcweir             Window::Command(rCEvt);
389cdf0e10cSrcweir     }
390cdf0e10cSrcweir }
391cdf0e10cSrcweir 
GetSurroundingText() const392cdf0e10cSrcweir XubString SidebarTxtControl::GetSurroundingText() const
393cdf0e10cSrcweir {
394cdf0e10cSrcweir     if( GetTextView() )
395cdf0e10cSrcweir         return GetTextView()->GetSurroundingText();
396cdf0e10cSrcweir     else
397cdf0e10cSrcweir         return XubString::EmptyString();
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
GetSurroundingTextSelection() const400cdf0e10cSrcweir Selection SidebarTxtControl::GetSurroundingTextSelection() const
401cdf0e10cSrcweir {
402cdf0e10cSrcweir     if( GetTextView() )
403cdf0e10cSrcweir         return GetTextView()->GetSurroundingTextSelection();
404cdf0e10cSrcweir     else
405cdf0e10cSrcweir         return Selection( 0, 0 );
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
CreateAccessible()408cdf0e10cSrcweir css::uno::Reference< css::accessibility::XAccessible > SidebarTxtControl::CreateAccessible()
409cdf0e10cSrcweir {
410cdf0e10cSrcweir 
411cdf0e10cSrcweir     SidebarTxtControlAccessible* pAcc( new SidebarTxtControlAccessible( *this ) );
412cdf0e10cSrcweir     css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc );
413cdf0e10cSrcweir     SetWindowPeer( xWinPeer, pAcc );
414cdf0e10cSrcweir 
415cdf0e10cSrcweir     css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY );
416cdf0e10cSrcweir     return xAcc;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir 
419cdf0e10cSrcweir } } // end of namespace sw::sidebarwindows
420cdf0e10cSrcweir 
421