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