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