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