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