Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /************************************************************************* *
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <SidebarWin.hxx>
31 : : #include <SidebarWinAcc.hxx>
32 : : #include <PostItMgr.hxx>
33 : :
34 : : #include <SidebarTxtControl.hxx>
35 : : #include <AnchorOverlayObject.hxx>
36 : : #include <ShadowOverlayObject.hxx>
37 : :
38 : : #include <annotation.hrc>
39 : : #include <popup.hrc>
40 : : #include <docvw.hrc>
41 : : #include <app.hrc>
42 : : #include <access.hrc>
43 : :
44 : : #include <viewopt.hxx>
45 : : #include <cmdid.h>
46 : :
47 : : #include <editeng/fontitem.hxx>
48 : : #include <editeng/fhgtitem.hxx>
49 : : #include <editeng/langitem.hxx>
50 : : #include <editeng/editview.hxx>
51 : : #include <editeng/outliner.hxx>
52 : : #include <editeng/editeng.hxx>
53 : : #include <editeng/eeitem.hxx>
54 : :
55 : : #include <svl/zforlist.hxx>
56 : : #include <svl/undo.hxx>
57 : : #include <svl/stritem.hxx>
58 : :
59 : : #include <sfx2/viewfrm.hxx>
60 : : #include <sfx2/bindings.hxx>
61 : : #include <sfx2/dispatch.hxx>
62 : :
63 : : #include <vcl/scrbar.hxx>
64 : : #include <vcl/svapp.hxx>
65 : : #include <vcl/menubtn.hxx>
66 : :
67 : : #include <edtwin.hxx>
68 : : #include <view.hxx>
69 : : #include <docsh.hxx>
70 : : #include <wrtsh.hxx>
71 : : #include <doc.hxx>
72 : : #include <swmodule.hxx>
73 : : #include <langhelper.hxx>
74 : :
75 : : #include <sw_primitivetypes2d.hxx>
76 : : #include <drawinglayer/primitive2d/primitivetools2d.hxx>
77 : : #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
78 : : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
79 : : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
80 : : #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
81 : :
82 : : namespace css = ::com::sun::star;
83 : :
84 : : namespace sw { namespace sidebarwindows {
85 : :
86 : : #define METABUTTON_WIDTH 16
87 : : #define METABUTTON_HEIGHT 18
88 : : #define METABUTTON_AREA_WIDTH 30
89 : : #define POSTIT_META_HEIGHT (sal_Int32) 30
90 : : #define POSTIT_MINIMUMSIZE_WITHOUT_META 50
91 : :
92 : : #define EMPTYSTRING rtl::OUString()
93 : :
94 : : /************** SwSidebarWin************************************/
95 : 18 : SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin,
96 : : WinBits nBits,
97 : : SwPostItMgr& aMgr,
98 : : SwPostItBits aBits,
99 : : SwSidebarItem& rSidebarItem )
100 : : : Window(&rEditWin, nBits)
101 : : , mrMgr(aMgr)
102 : 18 : , mrView( rEditWin.GetView() )
103 : : , nFlags(aBits)
104 : : , mnEventId(0)
105 : : , mpOutlinerView(0)
106 : : , mpOutliner(0)
107 : : , mpSidebarTxtControl(0)
108 : : , mpVScrollbar(0)
109 : : , mpMetadataAuthor(0)
110 : : , mpMetadataDate(0)
111 : : , mpMenuButton(0)
112 : : , mpAnchor(0)
113 : : , mpShadow(0)
114 : : , mColorAnchor()
115 : : , mColorDark()
116 : : , mColorLight()
117 : : , mChangeColor()
118 : : , meSidebarPosition( sw::sidebarwindows::SIDEBAR_NONE )
119 : : , mPosSize()
120 : : , mAnchorRect()
121 : : , mPageBorder( 0 )
122 : : , mbMouseOver( false )
123 : : , mLayoutStatus( SwPostItHelper::INVISIBLE )
124 : : , mbReadonly( false )
125 : : , mbIsFollow( false )
126 : : , mrSidebarItem( rSidebarItem )
127 [ + - ]: 36 : , mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm )
128 : : {
129 [ + - ]: 18 : mpShadow = ShadowOverlayObject::CreateShadowOverlayObject( mrView );
130 [ + - ]: 18 : if ( mpShadow )
131 : : {
132 [ + - ]: 18 : mpShadow->setVisible(false);
133 : : }
134 : :
135 : : mrMgr.ConnectSidebarWinToFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
136 [ + - ]: 18 : *(mrSidebarItem.GetFmtFld()),
137 [ + - ]: 18 : *this );
138 : 18 : }
139 : :
140 : 15 : SwSidebarWin::~SwSidebarWin()
141 : : {
142 : : mrMgr.DisconnectSidebarWinFromFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
143 [ + - ]: 15 : *this );
144 : :
145 [ + - ]: 15 : Disable();
146 : :
147 [ + - ]: 15 : if ( mpSidebarTxtControl )
148 : : {
149 [ + - ]: 15 : if ( mpOutlinerView )
150 : : {
151 [ + - ]: 15 : mpOutlinerView->SetWindow( 0 );
152 : : }
153 [ + - ][ + - ]: 15 : delete mpSidebarTxtControl;
154 : 15 : mpSidebarTxtControl = 0;
155 : : }
156 : :
157 [ + - ]: 15 : if ( mpOutlinerView )
158 : : {
159 [ + - ][ + - ]: 15 : delete mpOutlinerView;
160 : 15 : mpOutlinerView = 0;
161 : : }
162 : :
163 [ + - ]: 15 : if (mpOutliner)
164 : : {
165 [ + - ][ + - ]: 15 : delete mpOutliner;
166 : 15 : mpOutliner = 0;
167 : : }
168 : :
169 [ + - ]: 15 : if (mpMetadataAuthor)
170 : : {
171 [ + - ][ + - ]: 15 : mpMetadataAuthor->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
172 [ + - ][ + - ]: 15 : delete mpMetadataAuthor;
173 : 15 : mpMetadataAuthor = 0;
174 : : }
175 : :
176 [ + - ]: 15 : if (mpMetadataDate)
177 : : {
178 [ + - ][ + - ]: 15 : mpMetadataDate->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
179 [ + - ][ + - ]: 15 : delete mpMetadataDate;
180 : 15 : mpMetadataDate = 0;
181 : : }
182 : :
183 [ + - ]: 15 : if (mpVScrollbar)
184 : : {
185 [ + - ][ + - ]: 15 : mpVScrollbar->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
186 [ + - ][ + - ]: 15 : delete mpVScrollbar;
187 : 15 : mpVScrollbar = 0;
188 : : }
189 : :
190 [ + - ]: 15 : AnchorOverlayObject::DestroyAnchorOverlayObject( mpAnchor );
191 : 15 : mpAnchor = 0;
192 : :
193 [ + - ]: 15 : ShadowOverlayObject::DestroyShadowOverlayObject( mpShadow );
194 : 15 : mpShadow = 0;
195 : :
196 [ + - ][ + - ]: 15 : delete mpMenuButton;
197 : 15 : mpMenuButton = 0;
198 : :
199 [ - + ]: 15 : if (mnEventId)
200 [ # # ]: 0 : Application::RemoveUserEvent( mnEventId );
201 [ - + ]: 15 : }
202 : :
203 : 0 : void SwSidebarWin::Paint( const Rectangle& rRect)
204 : : {
205 : 0 : Window::Paint(rRect);
206 : :
207 [ # # ]: 0 : if (mpMetadataAuthor->IsVisible() )
208 : : {
209 : : //draw left over space
210 [ # # ]: 0 : if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
211 : : {
212 [ # # ]: 0 : SetFillColor(COL_BLACK);
213 : : }
214 : : else
215 : : {
216 : 0 : SetFillColor(mColorDark);
217 : : }
218 : 0 : SetLineColor();
219 : : DrawRect( PixelToLogic(
220 [ # # ]: 0 : Rectangle( Point( mpMetadataAuthor->GetPosPixel().X() +
221 [ # # ]: 0 : mpMetadataAuthor->GetSizePixel().Width(),
222 [ # # ]: 0 : mpMetadataAuthor->GetPosPixel().Y() ),
223 : : Size( GetMetaButtonAreaWidth(),
224 : 0 : mpMetadataAuthor->GetSizePixel().Height() +
225 [ # # ][ # # ]: 0 : mpMetadataDate->GetSizePixel().Height() ) ) ) );
[ # # ][ # # ]
226 : : }
227 : 0 : }
228 : :
229 : 78 : void SwSidebarWin::SetPosSizePixelRect( long nX,
230 : : long nY,
231 : : long nWidth,
232 : : long nHeight,
233 : : const SwRect &aRect,
234 : : const long aPageBorder)
235 : : {
236 [ + - ]: 78 : mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
237 : 78 : mAnchorRect = aRect;
238 : 78 : mPageBorder = aPageBorder;
239 : 78 : }
240 : :
241 : 0 : void SwSidebarWin::SetSize( const Size& rNewSize )
242 : : {
243 : 0 : mPosSize.SetSize(rNewSize);
244 : 0 : }
245 : :
246 : 0 : void SwSidebarWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize)
247 : : {
248 : 0 : mPosSize = Rectangle(aPoint,aSize);
249 : 0 : }
250 : :
251 : 0 : void SwSidebarWin::TranslateTopPosition(const long aAmount)
252 : : {
253 : 0 : mPosSize.Move(0,aAmount);
254 : 0 : }
255 : :
256 : 0 : void SwSidebarWin::ShowAnchorOnly(const Point &aPoint)
257 : : {
258 : 0 : HideNote();
259 : 0 : SetPosAndSize();
260 [ # # ]: 0 : if (mpAnchor)
261 : : {
262 [ # # ]: 0 : mpAnchor->SetSixthPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
263 [ # # ]: 0 : mpAnchor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
264 : 0 : mpAnchor->SetAnchorState(AS_ALL);
265 : 0 : mpAnchor->setVisible(true);
266 : : }
267 [ # # ]: 0 : if (mpShadow)
268 : 0 : mpShadow->setVisible(false);
269 : 0 : }
270 : :
271 : 24 : SfxItemSet SwSidebarWin::DefaultItem()
272 : : {
273 : 24 : SfxItemSet aItem( mrView.GetDocShell()->GetPool() );
274 [ + - ][ + - ]: 24 : aItem.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
[ + - ]
275 [ + - ]: 24 : aItem.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
276 [ + - ][ + - ]: 48 : EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
[ + - ][ + - ]
[ + - ]
277 : 24 : return aItem;
278 : : }
279 : :
280 : 18 : void SwSidebarWin::InitControls()
281 : : {
282 [ + - ]: 18 : AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
283 : :
284 : : // actual window which holds the user text
285 : : mpSidebarTxtControl = new SidebarTxtControl( *this,
286 : : WB_NODIALOGCONTROL,
287 [ + - ]: 18 : mrView, mrMgr );
288 [ + - ]: 18 : mpSidebarTxtControl->SetPointer(Pointer(POINTER_TEXT));
289 : :
290 : : // window controls for author and date
291 [ + - ]: 18 : mpMetadataAuthor = new Edit( this, 0 );
292 [ + - ][ + - ]: 18 : mpMetadataAuthor->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_AUTHOR_NAME ) );
[ + - ]
293 : 18 : mpMetadataAuthor->SetReadOnly();
294 : 18 : mpMetadataAuthor->AlwaysDisableInput(true);
295 : 18 : mpMetadataAuthor->SetCallHandlersOnInputDisabled(true);
296 [ + - ]: 18 : mpMetadataAuthor->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
297 : : // we should leave this setting alone, but for this we need a better layout algo
298 : : // with variable meta size height
299 : : {
300 [ + - ]: 18 : AllSettings aSettings = mpMetadataAuthor->GetSettings();
301 [ + - ]: 18 : StyleSettings aStyleSettings = aSettings.GetStyleSettings();
302 [ + - ]: 18 : Font aFont = aStyleSettings.GetFieldFont();
303 [ + - ]: 18 : aFont.SetHeight(8);
304 [ + - ]: 18 : aStyleSettings.SetFieldFont(aFont);
305 [ + - ]: 18 : aSettings.SetStyleSettings(aStyleSettings);
306 [ + - ][ + - ]: 18 : mpMetadataAuthor->SetSettings(aSettings);
[ + - ][ + - ]
307 : : }
308 : :
309 [ + - ]: 18 : mpMetadataDate = new Edit( this, 0 );
310 [ + - ][ + - ]: 18 : mpMetadataDate->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_DATE_NAME ) );
[ + - ]
311 : 18 : mpMetadataDate->SetReadOnly();
312 : 18 : mpMetadataDate->AlwaysDisableInput(true);
313 : 18 : mpMetadataDate->SetCallHandlersOnInputDisabled(true);
314 [ + - ]: 18 : mpMetadataDate->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
315 : : // we should leave this setting alone, but for this we need a better layout algo
316 : : // with variable meta size height
317 : : {
318 [ + - ]: 18 : AllSettings aSettings = mpMetadataDate->GetSettings();
319 [ + - ]: 18 : StyleSettings aStyleSettings = aSettings.GetStyleSettings();
320 [ + - ]: 18 : Font aFont = aStyleSettings.GetFieldFont();
321 [ + - ]: 18 : aFont.SetHeight(8);
322 [ + - ]: 18 : aStyleSettings.SetFieldFont(aFont);
323 [ + - ]: 18 : aSettings.SetStyleSettings(aStyleSettings);
324 [ + - ][ + - ]: 18 : mpMetadataDate->SetSettings(aSettings);
[ + - ][ + - ]
325 : : }
326 : :
327 : :
328 : 18 : SwDocShell* aShell = mrView.GetDocShell();
329 [ + - ]: 18 : mpOutliner = new Outliner(&aShell->GetPool(),OUTLINERMODE_TEXTOBJECT);
330 : 18 : aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner );
331 : 18 : mpOutliner->SetUpdateMode( sal_True );
332 : 18 : Rescale();
333 : :
334 [ + - ]: 18 : mpOutlinerView = new OutlinerView ( mpOutliner, mpSidebarTxtControl );
335 [ + - ]: 18 : mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT);
336 : 18 : mpOutliner->InsertView(mpOutlinerView );
337 [ + - ][ + - ]: 18 : mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) );
338 : :
339 [ + - ]: 18 : mpOutlinerView->SetAttribs(DefaultItem());
340 : :
341 : : // TODO: ??
342 [ - + ]: 18 : EEHorizontalTextDirection aDefHoriTextDir = Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
343 : 18 : mpOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
344 : :
345 : : //create Scrollbars
346 [ + - ]: 18 : mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
347 : 18 : mpVScrollbar->EnableNativeWidget(false);
348 : 18 : mpVScrollbar->EnableRTL( false );
349 : 18 : mpVScrollbar->SetScrollHdl(LINK(this, SwSidebarWin, ScrollHdl));
350 : 18 : mpVScrollbar->EnableDrag();
351 [ + - ]: 18 : mpVScrollbar->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) );
352 : :
353 : 18 : const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions();
354 : 18 : sal_uLong nCntrl = mpOutliner->GetControlWord();
355 : : // TODO: crash when AUTOCOMPLETE enabled
356 : 18 : nCntrl |= EE_CNTRL_MARKFIELDS | EE_CNTRL_PASTESPECIAL | EE_CNTRL_AUTOCORRECT | EV_CNTRL_AUTOSCROLL | EE_CNTRL_URLSFXEXECUTE; // | EE_CNTRL_AUTOCOMPLETE;
357 [ + - ]: 18 : if (pVOpt->IsFieldShadings())
358 : 18 : nCntrl |= EE_CNTRL_MARKFIELDS;
359 : : else
360 : 0 : nCntrl &= ~EE_CNTRL_MARKFIELDS;
361 [ + - ]: 18 : if (pVOpt->IsOnlineSpell())
362 : 18 : nCntrl |= EE_CNTRL_ONLINESPELLING;
363 : : else
364 : 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
365 : 18 : mpOutliner->SetControlWord(nCntrl);
366 : :
367 [ + - ][ + - ]: 18 : sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor());
368 : : SetColor( mrMgr.GetColorDark(aIndex),
369 : : mrMgr.GetColorLight(aIndex),
370 : 18 : mrMgr.GetColorAnchor(aIndex));
371 : :
372 : 18 : CheckMetaText();
373 : :
374 : 18 : mpMenuButton = CreateMenuButton();
375 : :
376 [ + - ]: 18 : SetLanguage(GetLanguage());
377 : 18 : GetOutlinerView()->StartSpeller();
378 : 18 : SetPostItText();
379 : 18 : Engine()->CompleteOnlineSpelling();
380 : :
381 : 18 : mpSidebarTxtControl->Show();
382 : 18 : mpMetadataAuthor->Show();
383 : 18 : mpMetadataDate->Show();
384 : 18 : mpVScrollbar->Show();
385 : 18 : }
386 : :
387 : 18 : void SwSidebarWin::CheckMetaText()
388 : : {
389 [ + - ]: 18 : const SvtSysLocale aSysLocale;
390 [ + - ]: 18 : const LocaleDataWrapper& rLocalData = aSysLocale.GetLocaleData();
391 [ + - ]: 18 : String sMeta = GetAuthor();
392 [ - + ]: 18 : if (sMeta.Len() == 0)
393 : : {
394 [ # # ][ # # ]: 0 : sMeta = String(SW_RES(STR_NOAUTHOR));
[ # # ]
395 : : }
396 [ - + ]: 18 : else if (sMeta.Len() > 22)
397 : : {
398 [ # # ]: 0 : sMeta.Erase(20);
399 [ # # ][ # # ]: 0 : sMeta = sMeta + rtl::OUString("...");
400 : : }
401 [ + - ][ + - ]: 18 : if ( mpMetadataAuthor->GetText() != sMeta )
[ + - ][ + - ]
402 : : {
403 [ + - ]: 18 : mpMetadataAuthor->SetText(sMeta);
404 : : }
405 : :
406 [ + - ]: 18 : Date aSysDate( Date::SYSTEM );
407 [ + - ]: 18 : Date aDate = GetDate();
408 [ - + ]: 18 : if (aDate==aSysDate)
409 : : {
410 [ # # ][ # # ]: 0 : sMeta = String(SW_RES(STR_POSTIT_TODAY));
[ # # ]
411 : : }
412 [ + - ][ - + ]: 18 : else if (aDate == Date(aSysDate-1))
413 : : {
414 [ # # ][ # # ]: 0 : sMeta = String(SW_RES(STR_POSTIT_YESTERDAY));
[ # # ]
415 : : }
416 [ + - ][ + + ]: 18 : else if (aDate.IsValidAndGregorian() )
417 : : {
418 [ + - ][ + - ]: 12 : sMeta = rLocalData.getDate(aDate);
419 : : }
420 : : else
421 : : {
422 [ + - ][ + - ]: 6 : sMeta = String(SW_RES(STR_NODATE));
[ + - ]
423 : : }
424 [ + - ][ + + ]: 18 : if (GetTime()!=0)
425 : : {
426 [ + - ][ + - ]: 12 : sMeta = sMeta + rtl::OUString(" ") + rLocalData.getTime( GetTime(),false );
[ + - ][ + - ]
427 : : }
428 [ + - ][ + - ]: 18 : if ( mpMetadataDate->GetText() != sMeta )
[ + - ][ + - ]
429 : : {
430 [ + - ]: 18 : mpMetadataDate->SetText(sMeta);
431 [ + - ][ + - ]: 18 : }
432 : :
433 : 18 : }
434 : :
435 : 42 : void SwSidebarWin::Rescale()
436 : : {
437 [ + - ][ + - ]: 42 : MapMode aMode = GetParent()->GetMapMode();
438 [ + - ]: 42 : aMode.SetOrigin( Point() );
439 [ + - ]: 42 : mpOutliner->SetRefMapMode( aMode );
440 [ + - ]: 42 : SetMapMode( aMode );
441 [ + - ]: 42 : mpSidebarTxtControl->SetMapMode( aMode );
442 [ + - ]: 42 : if ( mpMetadataAuthor )
443 : : {
444 [ + - ]: 42 : Font aFont( mpMetadataAuthor->GetSettings().GetStyleSettings().GetFieldFont() );
445 [ + - ]: 42 : sal_Int32 nHeight = aFont.GetHeight();
446 : 42 : nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator();
447 [ + - ]: 42 : aFont.SetHeight( nHeight );
448 [ + - ][ + - ]: 42 : mpMetadataAuthor->SetControlFont( aFont );
449 : : }
450 [ + - ]: 42 : if ( mpMetadataDate )
451 : : {
452 [ + - ]: 42 : Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() );
453 [ + - ]: 42 : sal_Int32 nHeight = aFont.GetHeight();
454 : 42 : nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator();
455 [ + - ]: 42 : aFont.SetHeight( nHeight );
456 [ + - ][ + - ]: 42 : mpMetadataDate->SetControlFont( aFont );
457 [ + - ]: 42 : }
458 : 42 : }
459 : :
460 : 78 : void SwSidebarWin::SetPosAndSize()
461 : : {
462 : 78 : bool bChange = false;
463 : :
464 [ + - ][ + + ]: 78 : if (GetSizePixel() != mPosSize.GetSize())
465 : : {
466 : 18 : bChange = true;
467 [ + - ]: 18 : SetSizePixel(mPosSize.GetSize());
468 : 18 : DoResize();
469 : : }
470 : :
471 [ + - ][ + + ]: 78 : if (GetPosPixel().X() != mPosSize.TopLeft().X() || (abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) )
[ + - ][ - + ]
[ + + ][ + + ]
[ + - ][ + - ]
[ + + # #
# # # # #
# ]
472 : : {
473 : 18 : bChange = true;
474 [ + - ]: 18 : SetPosPixel(mPosSize.TopLeft());
475 : :
476 : 18 : Point aLineStart;
477 : 18 : Point aLineEnd ;
478 [ - + - ]: 18 : switch ( meSidebarPosition )
479 : : {
480 : : case sw::sidebarwindows::SIDEBAR_LEFT:
481 : : {
482 [ # # ][ # # ]: 0 : aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
[ # # ][ # # ]
483 [ # # ][ # # ]: 0 : aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
[ # # ]
484 : : }
485 : 0 : break;
486 : : case sw::sidebarwindows::SIDEBAR_RIGHT:
487 : : {
488 [ + - ][ + - ]: 18 : aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
[ + - ]
489 [ + - ][ + - ]: 18 : aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
[ + - ][ + - ]
490 : : }
491 : 18 : break;
492 : : default:
493 : : OSL_FAIL( "<SwSidebarWin::SetPosAndSize()> - unexpected position of sidebar" );
494 : 0 : break;
495 : : }
496 : :
497 [ + - ]: 18 : if (!IsPreview())
498 : : {
499 [ - + ]: 18 : if (mpAnchor)
500 : : {
501 : 0 : mpAnchor->SetAllPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
502 : 0 : basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
503 : 0 : basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
504 : 0 : basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
505 : 0 : basegfx::B2DPoint( mPageBorder ,mAnchorRect.Bottom()+2*15),
506 : 0 : basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
507 [ # # ]: 0 : basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()));
508 : 0 : mpAnchor->SetHeight(mAnchorRect.Height());
509 : : }
510 : : else
511 : : {
512 : : mpAnchor = AnchorOverlayObject::CreateAnchorOverlayObject( mrView,
513 : : mAnchorRect,
514 : : mPageBorder,
515 : : aLineStart,
516 : : aLineEnd,
517 [ + - ]: 18 : mColorAnchor );
518 [ + - ]: 18 : if ( mpAnchor )
519 : : {
520 : 18 : mpAnchor->SetHeight(mAnchorRect.Height());
521 [ + - ]: 18 : mpAnchor->setVisible(true);
522 [ + - ]: 18 : mpAnchor->SetAnchorState(AS_TRI);
523 [ + - ][ - + ]: 18 : if (HasChildPathFocus())
524 : : {
525 [ # # ]: 18 : mpAnchor->setLineSolid(true);
526 : : }
527 : : }
528 : : }
529 : : }
530 : : }
531 : : else
532 : : {
533 [ + - - + ]: 180 : if ( mpAnchor &&
[ - + ]
534 [ + - ]: 120 : ( mpAnchor->getBasePosition() != basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom()-5*15) ) )
535 : : {
536 : 0 : mpAnchor->SetTriPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15),
537 : 0 : basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15),
538 : 0 : basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15),
539 : 0 : basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15),
540 [ # # ]: 0 : basegfx::B2DPoint( mPageBorder , mAnchorRect.Bottom()+2*15));
541 : : }
542 : : }
543 : :
544 [ + + ]: 78 : if (bChange)
545 : : {
546 [ + - ][ + - ]: 18 : Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
[ + - ]
547 [ + - ][ + - ]: 18 : Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
[ + - ][ + - ]
548 [ + - ]: 18 : mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
549 : : }
550 : :
551 [ + - ]: 78 : if (mrMgr.ShowNotes())
552 : : {
553 [ - + ][ # # ]: 78 : if (IsFollow() && !HasChildPathFocus())
[ - + ]
554 : : {
555 : : // #i111964#
556 [ # # ]: 0 : if ( mpAnchor )
557 : : {
558 : 0 : mpAnchor->SetAnchorState(AS_END);
559 : : }
560 : : }
561 : : else
562 : : {
563 : : // #i111964#
564 [ + - ]: 78 : if ( mpAnchor )
565 : : {
566 : 78 : mpAnchor->SetAnchorState(AS_ALL);
567 : : }
568 : 78 : SwSidebarWin* pWin = GetTopReplyNote();
569 : : // #i111964#
570 [ # # ][ - + ]: 78 : if ( pWin && pWin->Anchor() )
[ - + ]
571 : : {
572 : 0 : pWin->Anchor()->SetAnchorState(AS_END);
573 : : }
574 : : }
575 : : }
576 : 78 : }
577 : :
578 : 18 : void SwSidebarWin::DoResize()
579 : : {
580 [ + - ][ + - ]: 18 : long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height();
581 [ + - ]: 18 : long aHeight = GetSizePixel().Height();
582 [ + - ]: 18 : unsigned long aWidth = GetSizePixel().Width();
583 : :
584 : 18 : aHeight -= GetMetaHeight();
585 [ + - ]: 18 : mpMetadataAuthor->Show();
586 [ + - ]: 18 : mpMetadataDate->Show();
587 [ + - ][ + - ]: 18 : mpSidebarTxtControl->SetQuickHelpText(EMPTYSTRING);
[ + - ]
588 : :
589 [ # # ][ - + ]: 18 : if ((aTextHeight > aHeight) && !IsPreview())
[ - + ]
590 : : { // we need vertical scrollbars and have to reduce the width
591 : 0 : aWidth -= GetScrollbarWidth();
592 [ # # ]: 0 : mpVScrollbar->Show();
593 : : }
594 : : else
595 : : {
596 [ + - ]: 18 : mpVScrollbar->Hide();
597 : : }
598 : :
599 : : {
600 [ + - ]: 18 : const Size aSizeOfMetadataControls( GetSizePixel().Width() - GetMetaButtonAreaWidth(),
601 : 36 : GetMetaHeight()/2 );
602 : : mpMetadataAuthor->SetPosSizePixel( 0,
603 : : aHeight,
604 : : aSizeOfMetadataControls.Width(),
605 [ + - ]: 18 : aSizeOfMetadataControls.Height() );
606 : : mpMetadataDate->SetPosSizePixel( 0,
607 : 18 : aHeight + aSizeOfMetadataControls.Height(),
608 : : aSizeOfMetadataControls.Width(),
609 [ + - ]: 36 : aSizeOfMetadataControls.Height() );
610 : : }
611 : :
612 [ + - ][ + - ]: 18 : mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ;
613 [ + - ][ + - ]: 18 : mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
[ + - ]
614 [ + - ][ + - ]: 18 : if (!mpVScrollbar->IsVisible())
615 : : { // if we do not have a scrollbar anymore, we want to see the complete text
616 [ + - ][ + - ]: 18 : mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
[ + - ]
617 : : }
618 : :
619 [ + - ][ + - ]: 18 : if (!Application::GetSettings().GetLayoutRTL())
[ + - ]
620 : : {
621 [ + - ]: 18 : mpSidebarTxtControl->SetPosSizePixel(0, 0, aWidth, aHeight);
622 [ + - ]: 18 : mpVScrollbar->SetPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight);
623 : : }
624 : : else
625 : : {
626 : 0 : mpSidebarTxtControl->SetPosSizePixel( ( (aTextHeight > aHeight) && !IsPreview()
627 : : ? GetScrollbarWidth() : 0 ) , 0,
628 [ # # # # ]: 0 : aWidth, aHeight);
[ # # ]
629 [ # # ]: 0 : mpVScrollbar->SetPosSizePixel( 0, 0, GetScrollbarWidth(), aHeight);
630 : : }
631 : :
632 [ + - ][ + - ]: 18 : mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() );
633 [ + - ]: 18 : mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 );
634 [ + - ]: 18 : mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 );
635 [ + - ]: 18 : SetScrollbar();
636 [ + - ][ + - ]: 18 : mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight()));
637 : :
638 : : //calculate rects for meta- button
639 : 18 : const Fraction& fx( GetMapMode().GetScaleX() );
640 : 18 : const Fraction& fy( GetMapMode().GetScaleY() );
641 : :
642 [ + - ]: 18 : const Point aPos( mpMetadataAuthor->GetPosPixel());
643 [ + - ]: 18 : Rectangle aRectMetaButton;
644 [ - + ]: 18 : if (IsPreview())
645 : : {
646 : : aRectMetaButton = PixelToLogic(
647 [ # # ]: 0 : Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH*4+10)*fx.GetNumerator()/fx.GetDenominator(),
648 : 0 : aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
649 : 0 : Size( METABUTTON_WIDTH*4*fx.GetNumerator()/fx.GetDenominator(),
650 [ # # ][ # # ]: 0 : METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
651 : : }
652 : : else
653 : : {
654 : : aRectMetaButton = PixelToLogic(
655 [ + - ]: 18 : Rectangle( Point( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.GetNumerator()/fx.GetDenominator(),
656 : 18 : aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
657 : 18 : Size( METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(),
658 [ + - ][ + - ]: 54 : METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
659 : : }
660 : :
661 : : {
662 [ + - ]: 18 : const Rectangle aRectMetaButtonPixel( LogicToPixel( aRectMetaButton ) );
663 : : mpMenuButton->SetPosSizePixel( aRectMetaButtonPixel.Left(),
664 : : aRectMetaButtonPixel.Top(),
665 : : aRectMetaButtonPixel.GetWidth(),
666 [ + - ][ + - ]: 18 : aRectMetaButtonPixel.GetHeight() );
[ + - ]
667 : : }
668 : 18 : }
669 : :
670 : 18 : void SwSidebarWin::SetSizePixel( const Size& rNewSize )
671 : : {
672 : 18 : Window::SetSizePixel(rNewSize);
673 : :
674 [ + - ]: 18 : if (mpShadow)
675 : : {
676 [ + - ][ + - ]: 18 : Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
[ + - ]
677 [ + - ][ + - ]: 18 : Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
[ + - ][ + - ]
678 [ + - ]: 18 : mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
679 : : }
680 : 18 : }
681 : :
682 : 18 : void SwSidebarWin::SetScrollbar()
683 : : {
684 [ + - ][ + - ]: 18 : mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY());
685 : 18 : }
686 : :
687 : 0 : void SwSidebarWin::ResizeIfNeccessary(long aOldHeight, long aNewHeight)
688 : : {
689 [ # # ]: 0 : if (aOldHeight != aNewHeight)
690 : : {
691 : : //check for lower border or next note
692 : 0 : long aBorder = mrMgr.GetNextBorder();
693 [ # # ]: 0 : if (aBorder != -1)
694 : : {
695 [ # # ]: 0 : if (aNewHeight > GetMinimumSizeWithoutMeta())
696 : : {
697 : 0 : long aNewLowerValue = GetPosPixel().Y() + aNewHeight + GetMetaHeight();
698 [ # # ]: 0 : if (aNewLowerValue < aBorder)
699 [ # # ]: 0 : SetSizePixel(Size(GetSizePixel().Width(),aNewHeight+GetMetaHeight()));
700 : : else
701 [ # # ][ # # ]: 0 : SetSizePixel(Size(GetSizePixel().Width(),aBorder - GetPosPixel().Y()));
702 : 0 : DoResize();
703 : 0 : Invalidate();
704 : : }
705 : : else
706 : : {
707 [ # # ]: 0 : if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight())
708 [ # # ]: 0 : SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight()));
709 : 0 : DoResize();
710 : 0 : Invalidate();
711 : : }
712 : : }
713 : : else
714 : : {
715 : 0 : DoResize();
716 : 0 : Invalidate();
717 : : }
718 : : }
719 : : else
720 : : {
721 : 0 : SetScrollbar();
722 : : }
723 : 0 : }
724 : :
725 : 18 : void SwSidebarWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor)
726 : : {
727 : 18 : mColorDark = aColorDark;
728 : 18 : mColorLight = aColorLight;
729 : 18 : mColorAnchor = aColorAnchor;
730 : :
731 [ + - ]: 18 : if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
732 : : {
733 : : {
734 [ + - ]: 18 : mpMetadataAuthor->SetControlBackground(mColorDark);
735 [ + - ]: 18 : AllSettings aSettings = mpMetadataAuthor->GetSettings();
736 [ + - ]: 18 : StyleSettings aStyleSettings = aSettings.GetStyleSettings();
737 [ + - ]: 18 : aStyleSettings.SetFieldTextColor(aColorAnchor);
738 [ + - ]: 18 : aSettings.SetStyleSettings(aStyleSettings);
739 [ + - ][ + - ]: 18 : mpMetadataAuthor->SetSettings(aSettings);
[ + - ]
740 : : }
741 : :
742 : : {
743 [ + - ]: 18 : mpMetadataDate->SetControlBackground(mColorDark);
744 [ + - ]: 18 : AllSettings aSettings = mpMetadataDate->GetSettings();
745 [ + - ]: 18 : StyleSettings aStyleSettings = aSettings.GetStyleSettings();
746 [ + - ]: 18 : aStyleSettings.SetFieldTextColor(aColorAnchor);
747 [ + - ]: 18 : aSettings.SetStyleSettings(aStyleSettings);
748 [ + - ][ + - ]: 18 : mpMetadataDate->SetSettings(aSettings);
[ + - ]
749 : : }
750 : :
751 [ + - ]: 18 : AllSettings aSettings2 = mpVScrollbar->GetSettings();
752 [ + - ]: 18 : StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings();
753 [ + - ]: 18 : aStyleSettings2.SetButtonTextColor(Color(0,0,0));
754 [ + - ]: 18 : aStyleSettings2.SetCheckedColor(mColorLight); // backgound
755 [ + - ]: 18 : aStyleSettings2.SetShadowColor(mColorAnchor);
756 [ + - ]: 18 : aStyleSettings2.SetFaceColor(mColorDark);
757 [ + - ]: 18 : aSettings2.SetStyleSettings(aStyleSettings2);
758 [ + - ][ + - ]: 18 : mpVScrollbar->SetSettings(aSettings2);
[ + - ]
759 : : }
760 : 18 : }
761 : :
762 : 78 : void SwSidebarWin::SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition)
763 : : {
764 : 78 : meSidebarPosition = eSidebarPosition;
765 : 78 : }
766 : :
767 : 18 : void SwSidebarWin::SetReadonly(sal_Bool bSet)
768 : : {
769 : 18 : mbReadonly = bSet;
770 : 18 : GetOutlinerView()->SetReadOnly(bSet);
771 : 18 : }
772 : :
773 : 18 : void SwSidebarWin::SetLanguage(const SvxLanguageItem aNewItem)
774 : : {
775 [ + - ]: 18 : Link pLink = Engine()->GetModifyHdl();
776 [ + - ][ + - ]: 18 : Engine()->SetModifyHdl( Link() );
777 [ + - ]: 18 : ESelection aOld = GetOutlinerView()->GetSelection();
778 : :
779 [ + - ]: 18 : ESelection aNewSelection( 0, 0, (sal_uInt16)Engine()->GetParagraphCount()-1, USHRT_MAX );
780 [ + - ]: 18 : GetOutlinerView()->SetSelection( aNewSelection );
781 [ + - ]: 18 : SfxItemSet aEditAttr(GetOutlinerView()->GetAttribs());
782 [ + - ]: 18 : aEditAttr.Put(aNewItem);
783 [ + - ]: 18 : GetOutlinerView()->SetAttribs( aEditAttr );
784 : :
785 [ + - ]: 18 : GetOutlinerView()->SetSelection(aOld);
786 [ + - ]: 18 : Engine()->SetModifyHdl( pLink );
787 : :
788 : 18 : const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions();
789 [ + - ]: 18 : sal_uLong nCntrl = Engine()->GetControlWord();
790 : : // turn off
791 : 18 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
792 [ + - ]: 18 : Engine()->SetControlWord(nCntrl);
793 : :
794 : : //turn back on
795 [ + - ]: 18 : if (pVOpt->IsOnlineSpell())
796 : 18 : nCntrl |= EE_CNTRL_ONLINESPELLING;
797 : : else
798 : 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
799 [ + - ]: 18 : Engine()->SetControlWord(nCntrl);
800 : :
801 [ + - ]: 18 : Engine()->CompleteOnlineSpelling();
802 [ + - ][ + - ]: 18 : Invalidate();
803 : 18 : }
804 : :
805 : 0 : void SwSidebarWin::DataChanged( const DataChangedEvent& aEvent)
806 : : {
807 : 0 : Window::DataChanged( aEvent );
808 : 0 : }
809 : :
810 : 0 : void SwSidebarWin::GetFocus()
811 : : {
812 [ # # ]: 0 : if (mpSidebarTxtControl)
813 : 0 : mpSidebarTxtControl->GrabFocus();
814 : 0 : }
815 : :
816 : 0 : void SwSidebarWin::LoseFocus()
817 : : {
818 : 0 : }
819 : :
820 : 78 : void SwSidebarWin::ShowNote()
821 : : {
822 : 78 : SetPosAndSize();
823 [ + + ]: 78 : if (!IsVisible())
824 : 18 : Window::Show();
825 [ + - ][ + + ]: 78 : if (mpShadow && !mpShadow->isVisible())
[ + + ]
826 : 18 : mpShadow->setVisible(true);
827 [ + - ][ - + ]: 78 : if (mpAnchor && !mpAnchor->isVisible())
[ - + ]
828 : 0 : mpAnchor->setVisible(true);
829 : 78 : }
830 : :
831 : 0 : void SwSidebarWin::HideNote()
832 : : {
833 [ # # ]: 0 : if (IsVisible())
834 : 0 : Window::Hide();
835 [ # # ]: 0 : if (mpAnchor)
836 : : {
837 [ # # ]: 0 : if (mrMgr.IsShowAnchor())
838 : 0 : mpAnchor->SetAnchorState(AS_TRI);
839 : : else
840 : 0 : mpAnchor->setVisible(false);
841 : : }
842 [ # # ][ # # ]: 0 : if (mpShadow && mpShadow->isVisible())
[ # # ]
843 : 0 : mpShadow->setVisible(false);
844 : 0 : }
845 : :
846 : 0 : void SwSidebarWin::ActivatePostIt()
847 : : {
848 : 0 : mrMgr.AssureStdModeAtShell();
849 : :
850 : 0 : mpOutliner->ClearModifyFlag();
851 : 0 : mpOutliner->GetUndoManager().Clear();
852 : :
853 : 0 : CheckMetaText();
854 : 0 : SetViewState(VS_EDIT);
855 : 0 : GetOutlinerView()->ShowCursor();
856 : :
857 : 0 : mpOutlinerView->GetEditView().SetInsertMode(mrView.GetWrtShellPtr()->IsInsMode());
858 : :
859 [ # # ]: 0 : if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
860 : 0 : GetOutlinerView()->SetBackgroundColor(mColorDark);
861 : 0 : }
862 : :
863 : 0 : void SwSidebarWin::DeactivatePostIt()
864 : : {
865 : : // remove selection, #i87073#
866 [ # # ]: 0 : if (GetOutlinerView()->GetEditView().HasSelection())
867 : : {
868 [ # # ]: 0 : ESelection aSelection = GetOutlinerView()->GetEditView().GetSelection();
869 : 0 : aSelection.nEndPara = aSelection.nStartPara;
870 : 0 : aSelection.nEndPos = aSelection.nStartPos;
871 [ # # ]: 0 : GetOutlinerView()->GetEditView().SetSelection(aSelection);
872 : : }
873 : :
874 : 0 : mpOutliner->CompleteOnlineSpelling();
875 : :
876 : 0 : SetViewState(VS_NORMAL);
877 : : // write the visible text back into the SwField
878 : 0 : UpdateData();
879 : :
880 [ # # ]: 0 : if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
881 [ # # ]: 0 : GetOutlinerView()->SetBackgroundColor(COL_TRANSPARENT);
882 : :
883 : :
884 [ # # ][ # # ]: 0 : if ( !IsProtected() &&
[ # # ][ # # ]
885 [ # # ][ # # ]: 0 : Engine()->GetEditEngine().GetText()==String(EMPTYSTRING) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
886 : : {
887 [ # # ]: 0 : mnEventId = Application::PostUserEvent( LINK( this, SwSidebarWin, DeleteHdl), 0 );
888 : : }
889 : 0 : }
890 : :
891 : 0 : void SwSidebarWin::ToggleInsMode()
892 : : {
893 [ # # ]: 0 : if (!mrView.GetWrtShell().IsRedlineOn())
894 : : {
895 : : //change outliner
896 : 0 : mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode());
897 : : //change document
898 : 0 : mrView.GetWrtShell().ToggleInsMode();
899 : : //update statusbar
900 : 0 : SfxBindings &rBnd = mrView.GetViewFrame()->GetBindings();
901 : 0 : rBnd.Invalidate(SID_ATTR_INSERT);
902 : 0 : rBnd.Update(SID_ATTR_INSERT);
903 : : }
904 : 0 : }
905 : :
906 : 0 : void SwSidebarWin::ExecuteCommand(sal_uInt16 nSlot)
907 : : {
908 : 0 : mrMgr.AssureStdModeAtShell();
909 : :
910 [ # # # # : 0 : switch (nSlot)
# ]
911 : : {
912 : : case FN_POSTIT:
913 : : case FN_REPLY:
914 : : {
915 : : // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note
916 : : // will be created
917 [ # # ][ # # ]: 0 : if (Engine()->GetEditEngine().GetText() != String(EMPTYSTRING))
[ # # ][ # # ]
[ # # ][ # # ]
918 : : {
919 [ # # ][ # # ]: 0 : OutlinerParaObject* pPara = new OutlinerParaObject(*GetOutlinerView()->GetEditView().CreateTextObject());
920 : 0 : mrMgr.RegisterAnswer(pPara);
921 : : }
922 [ # # ]: 0 : if (mrMgr.HasActiveSidebarWin())
923 : 0 : mrMgr.SetActiveSidebarWin(0);
924 : 0 : SwitchToFieldPos();
925 : 0 : mrView.GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
926 : 0 : break;
927 : : }
928 : : case FN_DELETE_COMMENT:
929 : :
930 : : //Delete(); // do not kill the parent of our open popup menu
931 [ # # ]: 0 : mnEventId = Application::PostUserEvent( LINK( this, SwSidebarWin, DeleteHdl), 0 );
932 : 0 : break;
933 : : case FN_DELETE_ALL_NOTES:
934 : : case FN_HIDE_ALL_NOTES:
935 : : // not possible as slot as this would require that "this" is the active postit
936 : 0 : mrView.GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON );
937 : 0 : break;
938 : : case FN_DELETE_NOTE_AUTHOR:
939 : : case FN_HIDE_NOTE_AUTHOR:
940 : : {
941 : : // not possible as slot as this would require that "this" is the active postit
942 [ # # ][ # # ]: 0 : SfxStringItem aItem( nSlot, GetAuthor() );
[ # # ]
943 : : const SfxPoolItem* aItems[2];
944 : 0 : aItems[0] = &aItem;
945 : 0 : aItems[1] = 0;
946 [ # # ][ # # ]: 0 : mrView.GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON );
947 : : }
948 : : default:
949 : 0 : mrView.GetViewFrame()->GetBindings().Execute( nSlot );
950 : 0 : break;
951 : : }
952 : 0 : }
953 : :
954 : 108 : SwEditWin* SwSidebarWin::EditWin()
955 : : {
956 : 108 : return &mrView.GetEditWin();
957 : : }
958 : :
959 : 78 : long SwSidebarWin::GetPostItTextHeight()
960 : : {
961 [ + - ][ + - ]: 78 : return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0;
[ + - ][ + - ]
[ + - ]
[ # # # # ]
962 : : }
963 : :
964 : 0 : void SwSidebarWin::SwitchToPostIt(sal_uInt16 aDirection)
965 : : {
966 : 0 : SwSidebarWin* pPostIt = mrMgr.GetNextPostIt(aDirection, this);
967 [ # # ]: 0 : if (pPostIt)
968 : 0 : pPostIt->GrabFocus();
969 : 0 : }
970 : :
971 : 990 : IMPL_LINK( SwSidebarWin, WindowEventListener, VclSimpleEvent*, pEvent )
972 : : {
973 [ - + ]: 990 : VclWindowEvent* pWinEvent = dynamic_cast<VclWindowEvent*>(pEvent);
974 [ + - ]: 990 : if ( pWinEvent )
975 : : {
976 [ - + ]: 990 : if ( pWinEvent->GetId() == VCLEVENT_WINDOW_MOUSEMOVE )
977 : : {
978 : 0 : MouseEvent* pMouseEvt = (MouseEvent*)pWinEvent->GetData();
979 [ # # ]: 0 : if ( pMouseEvt->IsEnterWindow() )
980 : : {
981 : 0 : mbMouseOver = true;
982 [ # # ]: 0 : if ( !HasFocus() )
983 : : {
984 : 0 : SetViewState(VS_VIEW);
985 : 0 : Invalidate();
986 : : }
987 : : }
988 [ # # ]: 0 : else if ( pMouseEvt->IsLeaveWindow())
989 : : {
990 [ # # ]: 0 : if (!IsPreview())
991 : : {
992 : 0 : mbMouseOver = false;
993 [ # # ]: 0 : if ( !HasFocus() )
994 : : {
995 : 0 : SetViewState(VS_NORMAL);
996 : 0 : Invalidate();
997 : : }
998 : : }
999 : : }
1000 : : }
1001 [ - + # # ]: 990 : else if ( pWinEvent->GetId() == VCLEVENT_WINDOW_ACTIVATE &&
[ - + ]
1002 : 0 : pWinEvent->GetWindow() == mpSidebarTxtControl )
1003 : : {
1004 : 0 : const sal_Bool bLockView = mrView.GetWrtShell().IsViewLocked();
1005 : 0 : mrView.GetWrtShell().LockView( sal_True );
1006 : :
1007 [ # # ]: 0 : if ( !IsPreview() )
1008 : : {
1009 : 0 : mrMgr.SetActiveSidebarWin( this );
1010 : : }
1011 : :
1012 : 0 : mrView.GetWrtShell().LockView( bLockView );
1013 : 0 : mrMgr.MakeVisible( this );
1014 : : }
1015 : : }
1016 : 990 : return sal_True;
1017 : : }
1018 : :
1019 : 0 : void SwSidebarWin::Delete()
1020 : : {
1021 [ # # ]: 0 : if ( mrMgr.GetActiveSidebarWin() == this)
1022 : : {
1023 : 0 : mrMgr.SetActiveSidebarWin(0);
1024 : : // if the note is empty, the previous line will send a delete event, but we are already there
1025 [ # # ]: 0 : if (mnEventId)
1026 : : {
1027 : 0 : Application::RemoveUserEvent( mnEventId );
1028 : 0 : mnEventId = 0;
1029 : : }
1030 : : }
1031 : 0 : }
1032 : :
1033 : 0 : IMPL_LINK(SwSidebarWin, ScrollHdl, ScrollBar*, pScroll)
1034 : : {
1035 : 0 : long nDiff = GetOutlinerView()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos();
1036 : 0 : GetOutlinerView()->Scroll( 0, nDiff );
1037 : 0 : return 0;
1038 : : }
1039 : :
1040 : 0 : IMPL_LINK_NOARG(SwSidebarWin, ModifyHdl)
1041 : : {
1042 : 0 : mrView.GetDocShell()->SetModified(sal_True);
1043 : 0 : return 0;
1044 : : }
1045 : :
1046 : 0 : IMPL_LINK_NOARG(SwSidebarWin, DeleteHdl)
1047 : : {
1048 : 0 : mnEventId = 0;
1049 : 0 : Delete();
1050 : 0 : return 0;
1051 : : }
1052 : :
1053 : :
1054 : 0 : void SwSidebarWin::ResetAttributes()
1055 : : {
1056 : 0 : mpOutlinerView->RemoveAttribsKeepLanguages(sal_True);
1057 : 0 : mpOutliner->RemoveFields(sal_True);
1058 [ # # ]: 0 : mpOutlinerView->SetAttribs(DefaultItem());
1059 : 0 : }
1060 : :
1061 : 18 : sal_Int32 SwSidebarWin::GetScrollbarWidth()
1062 : : {
1063 : 18 : return mrView.GetWrtShell().GetViewOptions()->GetZoom() / 10;
1064 : : }
1065 : :
1066 : 18 : sal_Int32 SwSidebarWin::GetMetaButtonAreaWidth()
1067 : : {
1068 : 18 : const Fraction& f( GetMapMode().GetScaleX() );
1069 [ - + ]: 18 : if (IsPreview())
1070 : 0 : return 3 * METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
1071 : : else
1072 : 18 : return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
1073 : : }
1074 : :
1075 : 114 : sal_Int32 SwSidebarWin::GetMetaHeight()
1076 : : {
1077 : 114 : const Fraction& f( GetMapMode().GetScaleY() );
1078 : 114 : return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator();
1079 : : }
1080 : :
1081 : 0 : sal_Int32 SwSidebarWin::GetMinimumSizeWithMeta()
1082 : : {
1083 : 0 : return mrMgr.GetMinimumSizeWithMeta();
1084 : : }
1085 : :
1086 : 156 : sal_Int32 SwSidebarWin::GetMinimumSizeWithoutMeta()
1087 : : {
1088 : 156 : const Fraction& f( GetMapMode().GetScaleY() );
1089 : 156 : return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator();
1090 : : }
1091 : :
1092 : 0 : void SwSidebarWin::SetSpellChecking()
1093 : : {
1094 : 0 : const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions();
1095 : 0 : sal_uLong nCntrl = mpOutliner->GetControlWord();
1096 [ # # ]: 0 : if (pVOpt->IsOnlineSpell())
1097 : 0 : nCntrl |= EE_CNTRL_ONLINESPELLING;
1098 : : else
1099 : 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1100 : 0 : mpOutliner->SetControlWord(nCntrl);
1101 : :
1102 : 0 : mpOutliner->CompleteOnlineSpelling();
1103 : 0 : Invalidate();
1104 : 0 : }
1105 : :
1106 : 0 : void SwSidebarWin::SetViewState(ViewState bViewState)
1107 : : {
1108 [ # # # # ]: 0 : switch (bViewState)
1109 : : {
1110 : : case VS_EDIT:
1111 : : {
1112 [ # # ]: 0 : if (mpAnchor)
1113 : : {
1114 : 0 : mpAnchor->SetAnchorState(AS_ALL);
1115 : 0 : SwSidebarWin* pWin = GetTopReplyNote();
1116 : : // #i111964#
1117 [ # # ][ # # ]: 0 : if ( pWin && pWin->Anchor() )
[ # # ]
1118 : : {
1119 : 0 : pWin->Anchor()->SetAnchorState(AS_END);
1120 : : }
1121 : 0 : mpAnchor->setLineSolid(true);
1122 : : }
1123 [ # # ]: 0 : if (mpShadow)
1124 : 0 : mpShadow->SetShadowState(SS_EDIT);
1125 : 0 : break;
1126 : : }
1127 : : case VS_VIEW:
1128 : : {
1129 [ # # ]: 0 : if (mpAnchor)
1130 : 0 : mpAnchor->setLineSolid(true);
1131 [ # # ]: 0 : if (mpShadow)
1132 : 0 : mpShadow->SetShadowState(SS_VIEW);
1133 : 0 : break;
1134 : : }
1135 : : case VS_NORMAL:
1136 : : {
1137 [ # # ]: 0 : if (mpAnchor)
1138 : : {
1139 [ # # ]: 0 : if (IsFollow())
1140 : : {
1141 : : // if there is no visible parent note, we want to see the complete anchor ??
1142 : : //if (IsAnyStackParentVisible())
1143 : 0 : mpAnchor->SetAnchorState(AS_END);
1144 : 0 : SwSidebarWin* pTopWinSelf = GetTopReplyNote();
1145 : 0 : SwSidebarWin* pTopWinActive = mrMgr.HasActiveSidebarWin()
1146 : 0 : ? mrMgr.GetActiveSidebarWin()->GetTopReplyNote()
1147 [ # # ]: 0 : : 0;
1148 : : // #i111964#
1149 [ # # ]: 0 : if ( pTopWinSelf && ( pTopWinSelf != pTopWinActive ) &&
[ # # # # ]
[ # # ]
1150 : 0 : pTopWinSelf->Anchor() )
1151 : : {
1152 [ # # ]: 0 : if ( pTopWinSelf != mrMgr.GetActiveSidebarWin() )
1153 : : {
1154 : 0 : pTopWinSelf->Anchor()->setLineSolid(false);
1155 : : }
1156 : 0 : pTopWinSelf->Anchor()->SetAnchorState(AS_ALL);
1157 : : }
1158 : : }
1159 : 0 : mpAnchor->setLineSolid(false);
1160 : : }
1161 [ # # ]: 0 : if ( mpShadow )
1162 : : {
1163 : 0 : mpShadow->SetShadowState(SS_NORMAL);
1164 : : }
1165 : 0 : break;
1166 : : }
1167 : : }
1168 : 0 : }
1169 : :
1170 : 78 : SwSidebarWin* SwSidebarWin::GetTopReplyNote()
1171 : : {
1172 : 78 : SwSidebarWin* pTopNote = 0;
1173 [ - + ]: 78 : SwSidebarWin* pSidebarWin = IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, this) : 0;
1174 [ - + ]: 78 : while (pSidebarWin)
1175 : : {
1176 : 0 : pTopNote = pSidebarWin;
1177 [ # # ]: 0 : pSidebarWin = pSidebarWin->IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, pSidebarWin) : 0;
1178 : : }
1179 : 78 : return pTopNote;
1180 : : }
1181 : :
1182 : 0 : void SwSidebarWin::SwitchToFieldPos()
1183 : : {
1184 [ # # ]: 0 : if ( mrMgr.GetActiveSidebarWin() == this )
1185 : 0 : mrMgr.SetActiveSidebarWin(0);
1186 : 0 : GotoPos();
1187 : 0 : sal_uInt32 aCount = MoveCaret();
1188 [ # # ]: 0 : if (aCount)
1189 : 0 : mrView.GetDocShell()->GetWrtShell()->SwCrsrShell::Right(aCount, 0, sal_False);
1190 : 0 : GrabFocusToDocument();
1191 : 0 : }
1192 : :
1193 : 0 : SvxLanguageItem SwSidebarWin::GetLanguage(void)
1194 : : {
1195 : 0 : return SvxLanguageItem(SwLangHelper::GetLanguage(mrView.GetWrtShell(),RES_CHRATR_LANGUAGE),RES_CHRATR_LANGUAGE);
1196 : : }
1197 : :
1198 : 78 : void SwSidebarWin::SetChangeTracking( const SwPostItHelper::SwLayoutStatus aLayoutStatus,
1199 : : const Color& aChangeColor )
1200 : : {
1201 [ + + - + ]: 138 : if ( (mLayoutStatus != aLayoutStatus) ||
[ + + ]
1202 : 60 : (mChangeColor != aChangeColor) )
1203 : : {
1204 : 18 : mLayoutStatus = aLayoutStatus;
1205 : 18 : mChangeColor = aChangeColor;
1206 : 18 : Invalidate();
1207 : : }
1208 : 78 : }
1209 : :
1210 : 0 : bool SwSidebarWin::HasScrollbar() const
1211 : : {
1212 : 0 : return mpVScrollbar != 0;
1213 : : }
1214 : :
1215 : 0 : bool SwSidebarWin::IsScrollbarVisible() const
1216 : : {
1217 [ # # ][ # # ]: 0 : return HasScrollbar() && mpVScrollbar->IsVisible();
1218 : : }
1219 : :
1220 : 78 : void SwSidebarWin::ChangeSidebarItem( SwSidebarItem& rSidebarItem )
1221 : : {
1222 : 78 : const bool bAnchorChanged = mpAnchorFrm != rSidebarItem.maLayoutInfo.mpAnchorFrm;
1223 [ - + ]: 78 : if ( bAnchorChanged )
1224 : : {
1225 : 0 : mrMgr.DisconnectSidebarWinFromFrm( *(mpAnchorFrm), *this );
1226 : : }
1227 : :
1228 : 78 : mrSidebarItem = rSidebarItem;
1229 : 78 : mpAnchorFrm = mrSidebarItem.maLayoutInfo.mpAnchorFrm;
1230 : :
1231 [ - + ]: 78 : if ( GetWindowPeer() )
1232 : : {
1233 : : SidebarWinAccessible* pAcc =
1234 : 0 : static_cast<SidebarWinAccessible*>( GetWindowPeer() );
1235 : : OSL_ENSURE( dynamic_cast<SidebarWinAccessible*>( GetWindowPeer() ),
1236 : : "<SwSidebarWin::ChangeSidebarItem(..)> - unexpected type of window peer -> crash possible!" );
1237 : 0 : pAcc->ChangeSidebarItem( mrSidebarItem );
1238 : : }
1239 : :
1240 [ - + ]: 78 : if ( bAnchorChanged )
1241 : : {
1242 : : mrMgr.ConnectSidebarWinToFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
1243 : 0 : *(mrSidebarItem.GetFmtFld()),
1244 : 0 : *this );
1245 : : }
1246 : 78 : }
1247 : :
1248 : 0 : css::uno::Reference< css::accessibility::XAccessible > SwSidebarWin::CreateAccessible()
1249 : : {
1250 : : SidebarWinAccessible* pAcc( new SidebarWinAccessible( *this,
1251 : 0 : mrView.GetWrtShell(),
1252 [ # # ]: 0 : mrSidebarItem ) );
1253 [ # # ][ # # ]: 0 : css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc );
1254 [ # # ]: 0 : SetWindowPeer( xWinPeer, pAcc );
1255 : :
1256 [ # # ]: 0 : css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY );
1257 : 0 : return xAcc;
1258 : : }
1259 : :
1260 : : } } // eof of namespace sw::sidebarwindows
1261 : :
1262 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|