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