LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/docvw - SidebarWin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 363 644 56.4 %
Date: 2013-07-09 Functions: 29 61 47.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10