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_sd.hxx" 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <editeng/fontitem.hxx> 31*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 32*cdf0e10cSrcweir #include <editeng/fhgtitem.hxx> 33*cdf0e10cSrcweir #include <editeng/bulitem.hxx> 34*cdf0e10cSrcweir #include <editeng/udlnitem.hxx> 35*cdf0e10cSrcweir #include <editeng/shdditem.hxx> 36*cdf0e10cSrcweir #include <editeng/flditem.hxx> 37*cdf0e10cSrcweir #include <editeng/frmdir.hxx> 38*cdf0e10cSrcweir #include <editeng/frmdiritem.hxx> 39*cdf0e10cSrcweir #include <editeng/langitem.hxx> 40*cdf0e10cSrcweir #include <editeng/adjitem.hxx> 41*cdf0e10cSrcweir #include <editeng/editview.hxx> 42*cdf0e10cSrcweir #include <svx/svdview.hxx> 43*cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx> 44*cdf0e10cSrcweir #include <svx/sdr/overlay/overlaymanager.hxx> 45*cdf0e10cSrcweir #include <editeng/editstat.hxx> //EditEngine flags 46*cdf0e10cSrcweir #include <editeng/outliner.hxx> 47*cdf0e10cSrcweir #include <editeng/editeng.hxx> 48*cdf0e10cSrcweir #include <editeng/editobj.hxx> 49*cdf0e10cSrcweir #include <editeng/unolingu.hxx> 50*cdf0e10cSrcweir #include <editeng/outlobj.hxx> 51*cdf0e10cSrcweir #include <editeng/postitem.hxx> 52*cdf0e10cSrcweir #include <editeng/wghtitem.hxx> 53*cdf0e10cSrcweir #include <editeng/udlnitem.hxx> 54*cdf0e10cSrcweir #include <editeng/crsditem.hxx> 55*cdf0e10cSrcweir #include <svx/svxids.hrc> 56*cdf0e10cSrcweir #include <svtools/langtab.hxx> 57*cdf0e10cSrcweir #include <svl/slstitm.hxx> 58*cdf0e10cSrcweir #include <unotools/securityoptions.hxx> 59*cdf0e10cSrcweir #include <unotools/useroptions.hxx> 60*cdf0e10cSrcweir #include <svl/languageoptions.hxx> 61*cdf0e10cSrcweir #include <svl/zforlist.hxx> 62*cdf0e10cSrcweir #include <svtools/svmedit.hxx> 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #include <linguistic/lngprops.hxx> 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir #include <sfx2/request.hxx> 67*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 68*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 69*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 70*cdf0e10cSrcweir #include <sfx2/mnumgr.hxx> 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir #include <vcl/vclenum.hxx> 73*cdf0e10cSrcweir #include <vcl/edit.hxx> 74*cdf0e10cSrcweir #include <vcl/help.hxx> 75*cdf0e10cSrcweir #include <vcl/scrbar.hxx> 76*cdf0e10cSrcweir #include <vcl/button.hxx> 77*cdf0e10cSrcweir #include <vcl/svapp.hxx> 78*cdf0e10cSrcweir #include <vcl/gradient.hxx> 79*cdf0e10cSrcweir #include <vcl/salbtype.hxx> // FRound 80*cdf0e10cSrcweir #include <vcl/cursor.hxx> 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 83*cdf0e10cSrcweir #include <basegfx/tuple/b2dtuple.hxx> 84*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir #include "annotations.hrc" 87*cdf0e10cSrcweir #include "annotationwindow.hxx" 88*cdf0e10cSrcweir #include "annotationmanagerimpl.hxx" 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir #include "DrawDocShell.hxx" 91*cdf0e10cSrcweir #include "ViewShell.hxx" 92*cdf0e10cSrcweir #include "drawdoc.hxx" 93*cdf0e10cSrcweir #include "View.hxx" 94*cdf0e10cSrcweir #include "textapi.hxx" 95*cdf0e10cSrcweir #include "sdresid.hxx" 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir using rtl::OUString; 98*cdf0e10cSrcweir using namespace ::sd; 99*cdf0e10cSrcweir using namespace ::com::sun::star; 100*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 101*cdf0e10cSrcweir using namespace ::com::sun::star::office; 102*cdf0e10cSrcweir using namespace ::com::sun::star::text; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir #define METABUTTON_WIDTH 16 105*cdf0e10cSrcweir #define METABUTTON_HEIGHT 18 106*cdf0e10cSrcweir #define METABUTTON_AREA_WIDTH 30 107*cdf0e10cSrcweir #define POSTIT_META_HEIGHT (sal_Int32) 30 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir #define EMPTYSTRING rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")) 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir namespace sd { 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir extern OUString getAnnotationDateTimeString( const Reference< XAnnotation >& xAnnotation ); 114*cdf0e10cSrcweir extern SfxItemPool* GetAnnotationPool(); 115*cdf0e10cSrcweir extern com::sun::star::util::DateTime getCurrentDateTime(); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir Color ColorFromAlphaColor(sal_uInt8 aTransparency, Color &aFront, Color &aBack ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir return Color((sal_uInt8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)), 120*cdf0e10cSrcweir (sal_uInt8)(aFront.GetGreen() * aTransparency/(double)255 + aBack.GetGreen() * (1-aTransparency/(double)255)), 121*cdf0e10cSrcweir (sal_uInt8)(aFront.GetBlue() * aTransparency/(double)255 + aBack.GetBlue() * (1-aTransparency/(double)255))); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir /************ AnnotationTextWindow **********************************/ 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir AnnotationTextWindow::AnnotationTextWindow( AnnotationWindow* pParent, WinBits nBits ) 127*cdf0e10cSrcweir : Control(pParent, nBits) 128*cdf0e10cSrcweir , mpOutlinerView(0) 129*cdf0e10cSrcweir , mpAnnotationWindow( pParent ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir AnnotationTextWindow::~AnnotationTextWindow() 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir void AnnotationTextWindow::Paint( const Rectangle& rRect) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir const bool bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); 140*cdf0e10cSrcweir if ( !bHighContrast ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())), 143*cdf0e10cSrcweir Gradient(GRADIENT_LINEAR,mpAnnotationWindow->maColorLight,mpAnnotationWindow->maColor)); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir if( mpOutlinerView ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir Color aBackgroundColor( mpAnnotationWindow->maColor ); 149*cdf0e10cSrcweir if( bHighContrast ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir aBackgroundColor = GetSettings().GetStyleSettings().GetWindowColor(); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir mpOutlinerView->SetBackgroundColor( aBackgroundColor ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir mpOutlinerView->Paint( rRect ); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir void AnnotationTextWindow::KeyInput( const KeyEvent& rKeyEvt ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir const KeyCode& rKeyCode = rKeyEvt.GetKeyCode(); 163*cdf0e10cSrcweir sal_uInt16 nKey = rKeyCode.GetCode(); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN))) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir SfxDispatcher* pDispatcher = mpAnnotationWindow->DocShell()->GetViewShell()->GetViewFrame()->GetDispatcher(); 168*cdf0e10cSrcweir if( pDispatcher ) 169*cdf0e10cSrcweir pDispatcher->Execute( nKey == KEY_PAGEDOWN ? SID_NEXT_POSTIT : SID_PREVIOUS_POSTIT ); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir else if (nKey == KEY_INSERT) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir if (!rKeyCode.IsMod1() && !rKeyCode.IsMod2()) 174*cdf0e10cSrcweir mpAnnotationWindow->ToggleInsMode(); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir else 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir long aOldHeight = mpAnnotationWindow->GetPostItTextHeight(); 179*cdf0e10cSrcweir bool bDone = false; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir /// HACK: need to switch off processing of Undo/Redo in Outliner 182*cdf0e10cSrcweir if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir bool bIsProtected = mpAnnotationWindow->IsProtected(); 185*cdf0e10cSrcweir if (!bIsProtected || (bIsProtected && !mpAnnotationWindow->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) ) 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir bDone = mpOutlinerView->PostKeyEvent( rKeyEvt ); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir if (bDone) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir mpAnnotationWindow->ResizeIfNeccessary(aOldHeight,mpAnnotationWindow->GetPostItTextHeight()); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir else 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir Control::KeyInput(rKeyEvt); 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir void AnnotationTextWindow::MouseMove( const MouseEvent& rMEvt ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir if ( mpOutlinerView ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir mpOutlinerView->MouseMove( rMEvt ); 205*cdf0e10cSrcweir SetPointer( mpOutlinerView->GetPointer( rMEvt.GetPosPixel() ) ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir void AnnotationTextWindow::MouseButtonDown( const MouseEvent& rMEvt ) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir GrabFocus(); 212*cdf0e10cSrcweir if ( mpOutlinerView ) 213*cdf0e10cSrcweir mpOutlinerView->MouseButtonDown( rMEvt ); 214*cdf0e10cSrcweir // todo mpOutlinerView->DocView()->GetViewFrame()->GetBindings().InvalidateAll(sal_False); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir void AnnotationTextWindow::MouseButtonUp( const MouseEvent& rMEvt ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir if ( mpOutlinerView ) 220*cdf0e10cSrcweir mpOutlinerView->MouseButtonUp( rMEvt ); 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir void AnnotationTextWindow::Command( const CommandEvent& rCEvt ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir mpAnnotationWindow->Command(rCEvt); 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir else 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir if ( mpOutlinerView ) 232*cdf0e10cSrcweir mpOutlinerView->Command( rCEvt ); 233*cdf0e10cSrcweir else 234*cdf0e10cSrcweir Window::Command(rCEvt); 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir void AnnotationTextWindow::GetFocus() 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir Window::GetFocus(); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir void AnnotationTextWindow::LoseFocus() 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir // if ( mpAnnotationWindow ) 246*cdf0e10cSrcweir // mpAnnotationWindow->UpdateAnnotation(); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir Window::LoseFocus(); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir XubString AnnotationTextWindow::GetSurroundingText() const 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir if( mpOutlinerView ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); 256*cdf0e10cSrcweir if( mpOutlinerView->HasSelection() ) 257*cdf0e10cSrcweir return mpOutlinerView->GetSelected(); 258*cdf0e10cSrcweir else 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); 261*cdf0e10cSrcweir XubString aStr = aEditEngine->GetText(aSelection.nStartPara); 262*cdf0e10cSrcweir return aStr; 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir else 266*cdf0e10cSrcweir return XubString::EmptyString(); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir Selection AnnotationTextWindow::GetSurroundingTextSelection() const 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir if( mpOutlinerView ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir if( mpOutlinerView->HasSelection() ) 274*cdf0e10cSrcweir return Selection( 0, mpOutlinerView->GetSelected().Len() ); 275*cdf0e10cSrcweir else 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); 278*cdf0e10cSrcweir return Selection( aSelection.nStartPos, aSelection.nEndPos ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir else 282*cdf0e10cSrcweir return Selection( 0, 0 ); 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir /************** AnnotationWindow***********************************++*/ 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir AnnotationWindow::AnnotationWindow( AnnotationManagerImpl& rManager, DrawDocShell* pDocShell, Window* pParent ) 288*cdf0e10cSrcweir : FloatingWindow(pParent, WB_SYSTEMWINDOW|WB_BORDER|WB_NEEDSFOCUS) 289*cdf0e10cSrcweir , mrManager( rManager ) 290*cdf0e10cSrcweir , mpDocShell( pDocShell ) 291*cdf0e10cSrcweir , mpView( pDocShell->GetViewShell()->GetView() ) 292*cdf0e10cSrcweir , mpDoc( pDocShell->GetDoc() ) 293*cdf0e10cSrcweir , mpOutlinerView(0) 294*cdf0e10cSrcweir , mpOutliner(0) 295*cdf0e10cSrcweir , mpVScrollbar(0) 296*cdf0e10cSrcweir , mbReadonly(pDocShell->IsReadOnly()) 297*cdf0e10cSrcweir , mbProtected(false) 298*cdf0e10cSrcweir , mbMouseOverButton(false) 299*cdf0e10cSrcweir , mpTextWindow(0) 300*cdf0e10cSrcweir , mpMeta(0) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir AnnotationWindow::~AnnotationWindow() 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir delete mpMeta; 307*cdf0e10cSrcweir delete mpOutlinerView; 308*cdf0e10cSrcweir delete mpOutliner; 309*cdf0e10cSrcweir delete mpVScrollbar; 310*cdf0e10cSrcweir delete mpTextWindow; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir void AnnotationWindow::InitControls() 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir // actual window which holds the user text 316*cdf0e10cSrcweir mpTextWindow = new AnnotationTextWindow(this, WB_NODIALOGCONTROL); 317*cdf0e10cSrcweir mpTextWindow->SetPointer(Pointer(POINTER_TEXT)); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir // window control for author and date 320*cdf0e10cSrcweir mpMeta = new MultiLineEdit(this,0); 321*cdf0e10cSrcweir mpMeta->SetReadOnly(); 322*cdf0e10cSrcweir mpMeta->SetRightToLeft(Application::GetSettings().GetLayoutRTL()); 323*cdf0e10cSrcweir mpMeta->AlwaysDisableInput(true); 324*cdf0e10cSrcweir mpMeta->SetCallHandlersOnInputDisabled(true); 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir // mpMeta->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) ); 327*cdf0e10cSrcweir // AddEventListener( LINK( mpTextWindow, PostItTxt, WindowEventListener ) ); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir // we should leave this setting alone, but for this we need a better layout algo 330*cdf0e10cSrcweir // with variable meta size height 331*cdf0e10cSrcweir AllSettings aSettings = mpMeta->GetSettings(); 332*cdf0e10cSrcweir StyleSettings aStyleSettings = aSettings.GetStyleSettings(); 333*cdf0e10cSrcweir Font aFont = aStyleSettings.GetFieldFont(); 334*cdf0e10cSrcweir aFont.SetHeight(8); 335*cdf0e10cSrcweir aStyleSettings.SetFieldFont(aFont); 336*cdf0e10cSrcweir aSettings.SetStyleSettings(aStyleSettings); 337*cdf0e10cSrcweir mpMeta->SetSettings(aSettings); 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir mpOutliner = new ::Outliner(GetAnnotationPool(),OUTLINERMODE_TEXTOBJECT); 340*cdf0e10cSrcweir Doc()->SetCalcFieldValueHdl( mpOutliner ); 341*cdf0e10cSrcweir mpOutliner->SetUpdateMode( sal_True ); 342*cdf0e10cSrcweir Rescale(); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir OutputDevice* pDev = Doc()->GetRefDevice(); 345*cdf0e10cSrcweir if( pDev ) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir mpOutliner->SetRefDevice( pDev ); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir mpOutlinerView = new OutlinerView ( mpOutliner, mpTextWindow ); 351*cdf0e10cSrcweir mpOutliner->InsertView(mpOutlinerView ); 352*cdf0e10cSrcweir mpTextWindow->SetOutlinerView(mpOutlinerView); 353*cdf0e10cSrcweir mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) ); 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir // SfxItemSet item(DocShell()->GetPool()); 356*cdf0e10cSrcweir // item.Put(SvxFontHeightItem(352,100,EE_CHAR_FONTHEIGHT)); 357*cdf0e10cSrcweir // mpOutlinerView->SetAttribs(item); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir // TODO: ?? 360*cdf0e10cSrcweir EEHorizontalTextDirection aDefHoriTextDir = Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R; 361*cdf0e10cSrcweir mpOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir ); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir //create Scrollbars 364*cdf0e10cSrcweir mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG); 365*cdf0e10cSrcweir mpVScrollbar->EnableNativeWidget(false); 366*cdf0e10cSrcweir mpVScrollbar->EnableRTL( false ); 367*cdf0e10cSrcweir mpVScrollbar->SetScrollHdl(LINK(this, AnnotationWindow, ScrollHdl)); 368*cdf0e10cSrcweir mpVScrollbar->EnableDrag(); 369*cdf0e10cSrcweir // mpVScrollbar->AddEventListener( LINK( this, AnnotationWindow, WindowEventListener ) ); 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir sal_uLong nCntrl = mpOutliner->GetControlWord(); 372*cdf0e10cSrcweir nCntrl |= EE_CNTRL_PASTESPECIAL | EE_CNTRL_AUTOCORRECT | EV_CNTRL_AUTOSCROLL | EE_CNTRL_NOCOLORS; 373*cdf0e10cSrcweir /* 374*cdf0e10cSrcweir if (pVOpt->IsFieldShadings()) 375*cdf0e10cSrcweir nCntrl |= EE_CNTRL_MARKFIELDS; 376*cdf0e10cSrcweir else 377*cdf0e10cSrcweir nCntrl &= ~EE_CNTRL_MARKFIELDS; 378*cdf0e10cSrcweir if (pVOpt->IsOnlineSpell()) 379*cdf0e10cSrcweir nCntrl |= EE_CNTRL_ONLINESPELLING; 380*cdf0e10cSrcweir else 381*cdf0e10cSrcweir nCntrl &= ~EE_CNTRL_ONLINESPELLING; 382*cdf0e10cSrcweir */ 383*cdf0e10cSrcweir mpOutliner->SetControlWord(nCntrl); 384*cdf0e10cSrcweir // mpOutliner->SetFlatMode( sal_True ); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir Engine()->SetModifyHdl( Link() ); 387*cdf0e10cSrcweir Engine()->EnableUndo( sal_False ); 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir Engine()->ClearModifyFlag(); 390*cdf0e10cSrcweir Engine()->GetUndoManager().Clear(); 391*cdf0e10cSrcweir Engine()->EnableUndo( sal_True ); 392*cdf0e10cSrcweir Engine()->SetModifyHdl( LINK( this, AnnotationWindow, ModifyHdl ) ); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir Invalidate(); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir SetLanguage(GetLanguage()); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir mpMeta->Show(); 399*cdf0e10cSrcweir mpVScrollbar->Show(); 400*cdf0e10cSrcweir mpTextWindow->Show(); 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir void AnnotationWindow::StartEdit() 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir getView()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF)); 406*cdf0e10cSrcweir getView()->ShowCursor(); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir void AnnotationWindow::Rescale() 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir MapMode aMode(MAP_100TH_MM); 412*cdf0e10cSrcweir aMode.SetOrigin( Point() ); 413*cdf0e10cSrcweir //aMode.SetScaleX( aMode.GetScaleX() * Fraction( 8, 10 ) ); 414*cdf0e10cSrcweir //aMode.SetScaleY( aMode.GetScaleY() * Fraction( 8, 10 ) ); 415*cdf0e10cSrcweir mpOutliner->SetRefMapMode( aMode ); 416*cdf0e10cSrcweir SetMapMode( aMode ); 417*cdf0e10cSrcweir mpTextWindow->SetMapMode( aMode ); 418*cdf0e10cSrcweir if ( mpMeta ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir Font aFont( mpMeta->GetSettings().GetStyleSettings().GetFieldFont() ); 421*cdf0e10cSrcweir sal_Int32 nHeight = aFont.GetHeight(); 422*cdf0e10cSrcweir nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator(); 423*cdf0e10cSrcweir aFont.SetHeight( nHeight ); 424*cdf0e10cSrcweir mpMeta->SetControlFont( aFont ); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir void AnnotationWindow::DoResize() 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir unsigned long aWidth = GetSizePixel().Width(); 431*cdf0e10cSrcweir long aHeight = GetSizePixel().Height() - POSTIT_META_HEIGHT; 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ; 434*cdf0e10cSrcweir long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir if( aTextHeight > aHeight ) 437*cdf0e10cSrcweir { // we need vertical scrollbars and have to reduce the width 438*cdf0e10cSrcweir aWidth -= GetScrollbarWidth(); 439*cdf0e10cSrcweir mpVScrollbar->Show(); 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir else 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir mpVScrollbar->Hide(); 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir mpTextWindow->SetPosSizePixel(0,0,aWidth, aHeight); 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir if( mbReadonly ) 449*cdf0e10cSrcweir mpMeta->SetPosSizePixel(0,aHeight,GetSizePixel().Width(),POSTIT_META_HEIGHT); 450*cdf0e10cSrcweir else 451*cdf0e10cSrcweir mpMeta->SetPosSizePixel(0,aHeight,GetSizePixel().Width()-METABUTTON_AREA_WIDTH,POSTIT_META_HEIGHT); 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ; 454*cdf0e10cSrcweir mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) ); 455*cdf0e10cSrcweir if (!mpVScrollbar->IsVisible()) 456*cdf0e10cSrcweir { // if we do not have a scrollbar anymore, we want to see the complete text 457*cdf0e10cSrcweir mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) ); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir mpVScrollbar->SetPosSizePixel( 0 + aWidth, 0, GetScrollbarWidth(), aHeight ); 460*cdf0e10cSrcweir mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() ); 461*cdf0e10cSrcweir mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 ); 462*cdf0e10cSrcweir mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 ); 463*cdf0e10cSrcweir SetScrollbar(); 464*cdf0e10cSrcweir mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight())); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir Point aPos( mpMeta->GetPosPixel()); 467*cdf0e10cSrcweir Point aBase( aPos.X() + aPos.X() + GetSizePixel().Width(), aPos.Y() ); 468*cdf0e10cSrcweir Point aLeft = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+5), aBase.Y()+17 ) ); 469*cdf0e10cSrcweir Point aRight = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH-1), aBase.Y()+17 ) ); 470*cdf0e10cSrcweir Point aBottom = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+2), aBase.Y()+20 ) ); 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir maPopupTriangle.clear(); 473*cdf0e10cSrcweir maPopupTriangle.append(basegfx::B2DPoint(aLeft.X(),aLeft.Y())); 474*cdf0e10cSrcweir maPopupTriangle.append(basegfx::B2DPoint(aRight.X(),aRight.Y())); 475*cdf0e10cSrcweir maPopupTriangle.append(basegfx::B2DPoint(aBottom.X(),aBottom.Y())); 476*cdf0e10cSrcweir maPopupTriangle.setClosed(true); 477*cdf0e10cSrcweir maRectMetaButton = PixelToLogic( Rectangle( Point( 478*cdf0e10cSrcweir aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10), 479*cdf0e10cSrcweir aPos.Y()+5 ), 480*cdf0e10cSrcweir Size( METABUTTON_WIDTH, METABUTTON_HEIGHT ) ) ); 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir void AnnotationWindow::SetSizePixel( const Size& rNewSize ) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir Window::SetSizePixel(rNewSize); 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir void AnnotationWindow::SetScrollbar() 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY()); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir void AnnotationWindow::ResizeIfNeccessary(long aOldHeight, long aNewHeight) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir if (aOldHeight != aNewHeight) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir DoResize(); 499*cdf0e10cSrcweir Invalidate(); 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir else 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir SetScrollbar(); 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir void AnnotationWindow::SetLanguage(const SvxLanguageItem aNewItem) 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir Engine()->SetModifyHdl( Link() ); 510*cdf0e10cSrcweir ESelection aOld = getView()->GetSelection(); 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir ESelection aNewSelection( 0, 0, (sal_uInt16)Engine()->GetParagraphCount()-1, USHRT_MAX ); 513*cdf0e10cSrcweir getView()->SetSelection( aNewSelection ); 514*cdf0e10cSrcweir SfxItemSet aEditAttr(getView()->GetAttribs()); 515*cdf0e10cSrcweir aEditAttr.Put(aNewItem); 516*cdf0e10cSrcweir getView()->SetAttribs( aEditAttr ); 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir getView()->SetSelection(aOld); 519*cdf0e10cSrcweir Engine()->SetModifyHdl( LINK( this, AnnotationWindow, ModifyHdl ) ); 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir Invalidate(); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir void AnnotationWindow::ToggleInsMode() 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir if( mpOutlinerView ) 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir SfxBindings &rBnd = mpDocShell->GetViewShell()->GetViewFrame()->GetBindings(); 529*cdf0e10cSrcweir rBnd.Invalidate(SID_ATTR_INSERT); 530*cdf0e10cSrcweir rBnd.Update(SID_ATTR_INSERT); 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir long AnnotationWindow::GetPostItTextHeight() 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0; 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir IMPL_LINK(AnnotationWindow, ScrollHdl, ScrollBar*, pScroll) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir long nDiff = getView()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos(); 542*cdf0e10cSrcweir getView()->Scroll( 0, nDiff ); 543*cdf0e10cSrcweir return 0; 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir IMPL_LINK(AnnotationWindow, ModifyHdl, void*, EMPTYARG) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir return 0; 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir sal_Int32 AnnotationWindow::GetScrollbarWidth() 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir return 16; 554*cdf0e10cSrcweir // return mpView->GetWrtShell().GetViewOptions()->GetZoom() / 10; 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir SvxLanguageItem AnnotationWindow::GetLanguage(void) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir return SvxLanguageItem( Doc()->GetLanguage( EE_CHAR_LANGUAGE ), SID_ATTR_LANGUAGE ); 560*cdf0e10cSrcweir } 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir // -------------------------------------------------------------------- 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir TextApiObject* getTextApiObject( const Reference< XAnnotation >& xAnnotation ) 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir if( xAnnotation.is() ) 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir Reference< XText > xText( xAnnotation->getTextRange() ); 569*cdf0e10cSrcweir return TextApiObject::getImplementation( xText ); 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir return 0; 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir // -------------------------------------------------------------------- 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir void AnnotationWindow::setAnnotation( const Reference< XAnnotation >& xAnnotation, bool bGrabFocus ) 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir if( (xAnnotation != mxAnnotation) && xAnnotation.is() ) 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir mxAnnotation = xAnnotation; 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir SetColor(); 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir SvtUserOptions aUserOptions; 585*cdf0e10cSrcweir mbProtected = aUserOptions.GetFullName() != xAnnotation->getAuthor(); 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir Engine()->Clear(); 588*cdf0e10cSrcweir TextApiObject* pTextApi = getTextApiObject( mxAnnotation ); 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir if( pTextApi ) 591*cdf0e10cSrcweir { 592*cdf0e10cSrcweir std::auto_ptr< OutlinerParaObject > pOPO( pTextApi->CreateText() ); 593*cdf0e10cSrcweir Engine()->SetText( *pOPO.get() ); 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir Engine()->SetModifyHdl( LINK( this, AnnotationWindow, ModifyHdl ) ); 597*cdf0e10cSrcweir Engine()->ClearModifyFlag(); 598*cdf0e10cSrcweir Engine()->GetUndoManager().Clear(); 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir Invalidate(); 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir OUString sMeta( xAnnotation->getAuthor() ); 603*cdf0e10cSrcweir OUString sDateTime( getAnnotationDateTimeString(xAnnotation) ); 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir if( sDateTime.getLength() != 0 ) 606*cdf0e10cSrcweir { 607*cdf0e10cSrcweir if( sMeta.getLength() != 0 ) 608*cdf0e10cSrcweir sMeta += OUString( RTL_CONSTASCII_USTRINGPARAM( "\n" ) ); 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir sMeta += sDateTime; 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir mpMeta->SetText(sMeta); 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir if( bGrabFocus ) 615*cdf0e10cSrcweir GrabFocus(); 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir void AnnotationWindow::SetColor() 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir sal_uInt16 nAuthorIdx = mpDoc->GetAnnotationAuthorIndex( mxAnnotation->getAuthor() ); 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir const bool bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); 624*cdf0e10cSrcweir if( bHighContrast ) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir StyleSettings aStyleSettings = GetSettings().GetStyleSettings(); 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir maColor = aStyleSettings.GetWindowColor(); 629*cdf0e10cSrcweir maColorDark = maColor; 630*cdf0e10cSrcweir maColorLight = aStyleSettings.GetWindowTextColor(); 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir else 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir maColor = mrManager.GetColor( nAuthorIdx ); 635*cdf0e10cSrcweir maColorDark = mrManager.GetColorDark( nAuthorIdx ); 636*cdf0e10cSrcweir maColorLight = mrManager.GetColorLight( nAuthorIdx ); 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir mpOutlinerView->SetBackgroundColor(maColor); 640*cdf0e10cSrcweir Engine()->SetBackgroundColor(maColor); 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir { 643*cdf0e10cSrcweir SvtAccessibilityOptions aOptions; 644*cdf0e10cSrcweir Engine()->ForceAutoColor( bHighContrast || aOptions.GetIsAutomaticFontColor() ); 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir mpMeta->SetControlBackground(maColor); 648*cdf0e10cSrcweir AllSettings aSettings = mpMeta->GetSettings(); 649*cdf0e10cSrcweir StyleSettings aStyleSettings = aSettings.GetStyleSettings(); 650*cdf0e10cSrcweir aStyleSettings.SetFieldTextColor( bHighContrast ? maColorLight : maColorDark); 651*cdf0e10cSrcweir aSettings.SetStyleSettings(aStyleSettings); 652*cdf0e10cSrcweir mpMeta->SetSettings(aSettings); 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir AllSettings aSettings2 = mpVScrollbar->GetSettings(); 655*cdf0e10cSrcweir StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings(); 656*cdf0e10cSrcweir aStyleSettings2.SetButtonTextColor(Color(0,0,0)); 657*cdf0e10cSrcweir aStyleSettings2.SetCheckedColor(maColorLight); //hintergund 658*cdf0e10cSrcweir aStyleSettings2.SetShadowColor(maColorDark); 659*cdf0e10cSrcweir aStyleSettings2.SetFaceColor(maColor); 660*cdf0e10cSrcweir aSettings2.SetStyleSettings(aStyleSettings2); 661*cdf0e10cSrcweir mpVScrollbar->SetSettings(aSettings2); 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir void AnnotationWindow::Deactivate() 665*cdf0e10cSrcweir { 666*cdf0e10cSrcweir Reference< XAnnotation > xAnnotation( mxAnnotation ); 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir // write changed text back to annotation 669*cdf0e10cSrcweir if ( Engine()->IsModified() ) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir TextApiObject* pTextApi = getTextApiObject( xAnnotation ); 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir if( pTextApi ) 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir OutlinerParaObject* pOPO = Engine()->CreateParaObject(); 676*cdf0e10cSrcweir if( pOPO ) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 679*cdf0e10cSrcweir mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_EDIT ) ) ); 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir pTextApi->SetText( *pOPO ); 682*cdf0e10cSrcweir delete pOPO; 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir // set current time to changed annotation 685*cdf0e10cSrcweir xAnnotation->setDateTime( getCurrentDateTime() ); 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 688*cdf0e10cSrcweir mpDoc->EndUndo(); 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir DocView()->GetDocSh()->SetModified(sal_True); 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir } 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir Engine()->ClearModifyFlag(); 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir Engine()->GetUndoManager().Clear(); 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir void AnnotationWindow::Paint( const Rectangle& rRect) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir FloatingWindow::Paint( rRect ); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir if(mpMeta->IsVisible() && !mbReadonly) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir const bool bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); 707*cdf0e10cSrcweir //draw left over space 708*cdf0e10cSrcweir if ( bHighContrast ) 709*cdf0e10cSrcweir SetFillColor(COL_BLACK); 710*cdf0e10cSrcweir else 711*cdf0e10cSrcweir SetFillColor(maColor); 712*cdf0e10cSrcweir SetLineColor(); 713*cdf0e10cSrcweir DrawRect(PixelToLogic(Rectangle(Point(mpMeta->GetPosPixel().X()+mpMeta->GetSizePixel().Width(),mpMeta->GetPosPixel().Y()),Size(METABUTTON_AREA_WIDTH,mpMeta->GetSizePixel().Height())))); 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir if ( bHighContrast ) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir //draw rect around button 718*cdf0e10cSrcweir SetFillColor(COL_BLACK); 719*cdf0e10cSrcweir SetLineColor(COL_WHITE); 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir else 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir //draw button 724*cdf0e10cSrcweir Gradient aGradient; 725*cdf0e10cSrcweir if (mbMouseOverButton) 726*cdf0e10cSrcweir aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(80,maColorDark,maColor),ColorFromAlphaColor(15,maColorDark,maColor)); 727*cdf0e10cSrcweir else 728*cdf0e10cSrcweir aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(15,maColorDark,maColor),ColorFromAlphaColor(80,maColorDark,maColor)); 729*cdf0e10cSrcweir DrawGradient(maRectMetaButton,aGradient); 730*cdf0e10cSrcweir //draw rect around button 731*cdf0e10cSrcweir SetFillColor(); 732*cdf0e10cSrcweir SetLineColor(ColorFromAlphaColor(90,maColorDark,maColor)); 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir DrawRect(maRectMetaButton); 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir //draw arrow 737*cdf0e10cSrcweir if( bHighContrast ) 738*cdf0e10cSrcweir SetFillColor(COL_WHITE); 739*cdf0e10cSrcweir else 740*cdf0e10cSrcweir SetFillColor(COL_BLACK); 741*cdf0e10cSrcweir SetLineColor(); 742*cdf0e10cSrcweir DrawPolygon(Polygon(maPopupTriangle)); 743*cdf0e10cSrcweir } 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir void AnnotationWindow::MouseMove( const MouseEvent& rMEvt ) 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir if( !mbReadonly ) 749*cdf0e10cSrcweir { 750*cdf0e10cSrcweir if (maRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel()))) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir if (!mbMouseOverButton) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir Invalidate(maRectMetaButton); 755*cdf0e10cSrcweir mbMouseOverButton = true; 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir else 759*cdf0e10cSrcweir { 760*cdf0e10cSrcweir if (mbMouseOverButton) 761*cdf0e10cSrcweir { 762*cdf0e10cSrcweir Invalidate(maRectMetaButton); 763*cdf0e10cSrcweir mbMouseOverButton = false; 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir } 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir void AnnotationWindow::MouseButtonDown( const MouseEvent& rMEvt ) 770*cdf0e10cSrcweir { 771*cdf0e10cSrcweir if (!mbReadonly && maRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft()) 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir // context menu 774*cdf0e10cSrcweir Rectangle aRect(LogicToPixel(maRectMetaButton.BottomLeft()),LogicToPixel(maRectMetaButton.BottomLeft())); 775*cdf0e10cSrcweir mrManager.ExecuteAnnotationContextMenu( mxAnnotation, (::Window*)this, aRect, true ); 776*cdf0e10cSrcweir } 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir void AnnotationWindow::Command( const CommandEvent& rCEvt ) 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir if( mpMeta->IsVisible() &&(mpMeta->GetPosPixel().Y() < rCEvt.GetMousePosPixel().Y()) ) 784*cdf0e10cSrcweir return; 785*cdf0e10cSrcweir mrManager.ExecuteAnnotationContextMenu( mxAnnotation, this, Rectangle(rCEvt.GetMousePosPixel(),Size(1,1)) ); 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir else 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir FloatingWindow::Command(rCEvt); 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir void AnnotationWindow::GetFocus() 794*cdf0e10cSrcweir { 795*cdf0e10cSrcweir if( mpTextWindow ) 796*cdf0e10cSrcweir mpTextWindow->GrabFocus(); 797*cdf0e10cSrcweir else 798*cdf0e10cSrcweir FloatingWindow::GetFocus(); 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir void AnnotationWindow::ExecuteSlot( sal_uInt16 nSID ) 802*cdf0e10cSrcweir { 803*cdf0e10cSrcweir if( nSID == SID_COPY ) 804*cdf0e10cSrcweir { 805*cdf0e10cSrcweir getView()->Copy(); 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir else if( nSID == SID_PASTE ) 808*cdf0e10cSrcweir { 809*cdf0e10cSrcweir getView()->PasteSpecial(); 810*cdf0e10cSrcweir DoResize(); 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir else 813*cdf0e10cSrcweir { 814*cdf0e10cSrcweir SfxItemSet aEditAttr(getView()->GetAttribs()); 815*cdf0e10cSrcweir SfxItemSet aNewAttr(mpOutliner->GetEmptyItemSet()); 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir switch( nSID ) 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir case SID_ATTR_CHAR_WEIGHT: 820*cdf0e10cSrcweir { 821*cdf0e10cSrcweir FontWeight eFW = ( (const SvxWeightItem&) aEditAttr.Get( EE_CHAR_WEIGHT ) ).GetWeight(); 822*cdf0e10cSrcweir aNewAttr.Put( SvxWeightItem( eFW == WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) ); 823*cdf0e10cSrcweir } 824*cdf0e10cSrcweir break; 825*cdf0e10cSrcweir case SID_ATTR_CHAR_POSTURE: 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir FontItalic eFI = ( (const SvxPostureItem&) aEditAttr.Get( EE_CHAR_ITALIC ) ).GetPosture(); 828*cdf0e10cSrcweir aNewAttr.Put( SvxPostureItem( eFI == ITALIC_NORMAL ? ITALIC_NONE : ITALIC_NORMAL, EE_CHAR_ITALIC ) ); 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir break; 831*cdf0e10cSrcweir case SID_ATTR_CHAR_UNDERLINE: 832*cdf0e10cSrcweir { 833*cdf0e10cSrcweir FontUnderline eFU = ( (const SvxUnderlineItem&) aEditAttr. Get( EE_CHAR_UNDERLINE ) ).GetLineStyle(); 834*cdf0e10cSrcweir aNewAttr.Put( SvxUnderlineItem( eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE ) ); 835*cdf0e10cSrcweir } 836*cdf0e10cSrcweir break; 837*cdf0e10cSrcweir case SID_ATTR_CHAR_STRIKEOUT: 838*cdf0e10cSrcweir { 839*cdf0e10cSrcweir FontStrikeout eFSO = ( ( (const SvxCrossedOutItem&) aEditAttr.Get( EE_CHAR_STRIKEOUT ) ).GetStrikeout() ); 840*cdf0e10cSrcweir aNewAttr.Put( SvxCrossedOutItem( eFSO == STRIKEOUT_SINGLE ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) ); 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir break; 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir getView()->SetAttribs( aNewAttr ); 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir } 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir } 849