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 // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "sddll.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir //#include <com/sun/star/lang/XMultiServiceFactory.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/beans/XMultiPropertyStates.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/geometry/RealPoint2D.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/document/XEventBroadcaster.hpp> 41*cdf0e10cSrcweir #include <svx/svxids.hrc> 42*cdf0e10cSrcweir #include <vcl/menu.hxx> 43*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <svl/style.hxx> 46*cdf0e10cSrcweir #include <svl/itempool.hxx> 47*cdf0e10cSrcweir #include <unotools/useroptions.hxx> 48*cdf0e10cSrcweir #include <unotools/syslocale.hxx> 49*cdf0e10cSrcweir #include <unotools/saveopt.hxx> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #include <tools/datetime.hxx> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include <sfx2/imagemgr.hxx> 54*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 55*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 56*cdf0e10cSrcweir #include <sfx2/app.hxx> 57*cdf0e10cSrcweir #include <sfx2/request.hxx> 58*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 59*cdf0e10cSrcweir #include <sfx2/objface.hxx> 60*cdf0e10cSrcweir #include <sfx2/imagemgr.hxx> 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #include <editeng/editeng.hxx> 63*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 64*cdf0e10cSrcweir #include <editeng/fontitem.hxx> 65*cdf0e10cSrcweir #include <editeng/fhgtitem.hxx> 66*cdf0e10cSrcweir #include <editeng/outlobj.hxx> 67*cdf0e10cSrcweir #include <editeng/postitem.hxx> 68*cdf0e10cSrcweir #include <editeng/wghtitem.hxx> 69*cdf0e10cSrcweir #include <editeng/udlnitem.hxx> 70*cdf0e10cSrcweir #include <editeng/crsditem.hxx> 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir #include <svx/svdetc.hxx> 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir #include "annotationmanager.hxx" 75*cdf0e10cSrcweir #include "annotationmanagerimpl.hxx" 76*cdf0e10cSrcweir #include "annotationwindow.hxx" 77*cdf0e10cSrcweir #include "annotations.hrc" 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir #include "ToolBarManager.hxx" 80*cdf0e10cSrcweir #include "DrawDocShell.hxx" 81*cdf0e10cSrcweir #include "DrawViewShell.hxx" 82*cdf0e10cSrcweir #include "DrawController.hxx" 83*cdf0e10cSrcweir #include "glob.hrc" 84*cdf0e10cSrcweir #include "sdresid.hxx" 85*cdf0e10cSrcweir #include "EventMultiplexer.hxx" 86*cdf0e10cSrcweir #include "ViewShellManager.hxx" 87*cdf0e10cSrcweir #include "helpids.h" 88*cdf0e10cSrcweir #include "sdpage.hxx" 89*cdf0e10cSrcweir #include "drawdoc.hxx" 90*cdf0e10cSrcweir #include "textapi.hxx" 91*cdf0e10cSrcweir #include "optsitem.hxx" 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir #define C2U(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) ) 94*cdf0e10cSrcweir using ::rtl::OUString; 95*cdf0e10cSrcweir using namespace ::com::sun::star; 96*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 97*cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 98*cdf0e10cSrcweir using namespace ::com::sun::star::document; 99*cdf0e10cSrcweir using namespace ::com::sun::star::geometry; 100*cdf0e10cSrcweir using namespace ::com::sun::star::container; 101*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 102*cdf0e10cSrcweir using namespace ::com::sun::star::text; 103*cdf0e10cSrcweir using namespace ::com::sun::star::view; 104*cdf0e10cSrcweir using namespace ::com::sun::star::style; 105*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 106*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 107*cdf0e10cSrcweir using namespace ::com::sun::star::ui; 108*cdf0e10cSrcweir using namespace ::com::sun::star::task; 109*cdf0e10cSrcweir using namespace ::com::sun::star::office; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir namespace sd { 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir // -------------------------------------------------------------------- 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir extern TextApiObject* getTextApiObject( const Reference< XAnnotation >& xAnnotation ); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir // -------------------------------------------------------------------- 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir SfxItemPool* GetAnnotationPool() 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir static SfxItemPool* mpAnnotationPool = 0; 122*cdf0e10cSrcweir if( mpAnnotationPool == 0 ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir mpAnnotationPool = EditEngine::CreatePool( sal_False ); 125*cdf0e10cSrcweir mpAnnotationPool->SetPoolDefaultItem(SvxFontHeightItem(423,100,EE_CHAR_FONTHEIGHT)); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir Font aAppFont( Application::GetSettings().GetStyleSettings().GetAppFont() ); 128*cdf0e10cSrcweir String EMPTYSTRING; 129*cdf0e10cSrcweir mpAnnotationPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamily(),aAppFont.GetName(), EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir return mpAnnotationPool; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir // -------------------------------------------------------------------- 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir static SfxBindings* getBindings( ViewShellBase& rBase ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir if( rBase.GetMainViewShell().get() && rBase.GetMainViewShell()->GetViewFrame() ) 140*cdf0e10cSrcweir return &rBase.GetMainViewShell()->GetViewFrame()->GetBindings(); 141*cdf0e10cSrcweir else 142*cdf0e10cSrcweir return 0; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir // -------------------------------------------------------------------- 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir static SfxDispatcher* getDispatcher( ViewShellBase& rBase ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir if( rBase.GetMainViewShell().get() && rBase.GetMainViewShell()->GetViewFrame() ) 150*cdf0e10cSrcweir return rBase.GetMainViewShell()->GetViewFrame()->GetDispatcher(); 151*cdf0e10cSrcweir else 152*cdf0e10cSrcweir return 0; 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir com::sun::star::util::DateTime getCurrentDateTime() 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir DateTime aCurrentDate; 158*cdf0e10cSrcweir return com::sun::star::util::DateTime( 0, aCurrentDate.GetSec(), aCurrentDate.GetMin(), aCurrentDate.GetHour(), aCurrentDate.GetDay(), aCurrentDate.GetMonth(), aCurrentDate.GetYear() ); 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir OUString getAnnotationDateTimeString( const Reference< XAnnotation >& xAnnotation ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir OUString sRet; 164*cdf0e10cSrcweir if( xAnnotation.is() ) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData(); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir com::sun::star::util::DateTime aDateTime( xAnnotation->getDateTime() ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir Date aDate = Date( aDateTime.Day, aDateTime.Month, aDateTime.Year ); 171*cdf0e10cSrcweir if (aDate==Date()) 172*cdf0e10cSrcweir sRet = sRet + String(SdResId(STR_ANNOTATION_TODAY)); 173*cdf0e10cSrcweir else 174*cdf0e10cSrcweir if (aDate == Date(Date()-1)) 175*cdf0e10cSrcweir sRet = sRet + String(SdResId(STR_ANNOTATION_YESTERDAY)); 176*cdf0e10cSrcweir else 177*cdf0e10cSrcweir if (aDate.IsValid() ) 178*cdf0e10cSrcweir sRet = sRet + rLocalData.getDate(aDate); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir Time aTime( aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds ); 181*cdf0e10cSrcweir if(aTime.GetTime() != 0) 182*cdf0e10cSrcweir sRet = sRet + rtl::OUString::createFromAscii(" ") + rLocalData.getTime( aTime,false ); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir return sRet; 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir // -------------------------------------------------------------------- 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir AnnotationManagerImpl::AnnotationManagerImpl( ViewShellBase& rViewShellBase ) 190*cdf0e10cSrcweir : AnnotationManagerImplBase( m_aMutex ) 191*cdf0e10cSrcweir , mrBase( rViewShellBase ) 192*cdf0e10cSrcweir , mpDoc( rViewShellBase.GetDocument() ) 193*cdf0e10cSrcweir , mbShowAnnotations( true ) 194*cdf0e10cSrcweir , mnUpdateTagsEvent( 0 ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir SdOptions* pOptions = SD_MOD()->GetSdOptions(mpDoc->GetDocumentType()); 197*cdf0e10cSrcweir if( pOptions ) 198*cdf0e10cSrcweir mbShowAnnotations = pOptions->IsShowComments() == sal_True; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir // -------------------------------------------------------------------- 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir void AnnotationManagerImpl::init() 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir // get current controller and initialize listeners 206*cdf0e10cSrcweir try 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir addListener(); 209*cdf0e10cSrcweir mxView = Reference< XDrawView >::query(mrBase.GetController()); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir catch( Exception& e ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir (void)e; 214*cdf0e10cSrcweir DBG_ERROR( "sd::AnnotationManagerImpl::AnnotationManagerImpl(), Exception caught!" ); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir try 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir Reference<XEventBroadcaster> xModel (mrBase.GetDocShell()->GetModel(), UNO_QUERY_THROW ); 220*cdf0e10cSrcweir Reference<XEventListener> xListener( this ); 221*cdf0e10cSrcweir xModel->addEventListener( xListener ); 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir catch( Exception& ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir // -------------------------------------------------------------------- 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir // WeakComponentImplHelper1 231*cdf0e10cSrcweir void SAL_CALL AnnotationManagerImpl::disposing () 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir try 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir Reference<XEventBroadcaster> xModel (mrBase.GetDocShell()->GetModel(), UNO_QUERY_THROW ); 236*cdf0e10cSrcweir Reference<XEventListener> xListener( this ); 237*cdf0e10cSrcweir xModel->removeEventListener( xListener ); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir catch( Exception& ) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir removeListener(); 244*cdf0e10cSrcweir DisposeTags(); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir if( mnUpdateTagsEvent ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir Application::RemoveUserEvent( mnUpdateTagsEvent ); 249*cdf0e10cSrcweir mnUpdateTagsEvent = 0; 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir mxView.clear(); 253*cdf0e10cSrcweir mxCurrentPage.clear(); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir // -------------------------------------------------------------------- 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir // XEventListener 259*cdf0e10cSrcweir void SAL_CALL AnnotationManagerImpl::notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir if( aEvent.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnAnnotationInserted") ) || 262*cdf0e10cSrcweir aEvent.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnAnnotationRemoved") ) || 263*cdf0e10cSrcweir aEvent.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnAnnotationChanged" )) ) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir UpdateTags(); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir void SAL_CALL AnnotationManagerImpl::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir void AnnotationManagerImpl::ShowAnnotations( bool bShow ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir // enforce show annotations if a new annotation is inserted 276*cdf0e10cSrcweir if( mbShowAnnotations != bShow ) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir mbShowAnnotations = bShow; 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir SdOptions* pOptions = SD_MOD()->GetSdOptions(mpDoc->GetDocumentType()); 281*cdf0e10cSrcweir if( pOptions ) 282*cdf0e10cSrcweir pOptions->SetShowComments( mbShowAnnotations ? sal_True : sal_False ); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir UpdateTags(); 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir // -------------------------------------------------------------------- 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir void AnnotationManagerImpl::ExecuteAnnotation(SfxRequest& rReq ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir switch( rReq.GetSlot() ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir case SID_INSERT_POSTIT: 295*cdf0e10cSrcweir ExecuteInsertAnnotation( rReq ); 296*cdf0e10cSrcweir break; 297*cdf0e10cSrcweir case SID_DELETE_POSTIT: 298*cdf0e10cSrcweir case SID_DELETEALL_POSTIT: 299*cdf0e10cSrcweir case SID_DELETEALLBYAUTHOR_POSTIT: 300*cdf0e10cSrcweir ExecuteDeleteAnnotation( rReq ); 301*cdf0e10cSrcweir break; 302*cdf0e10cSrcweir case SID_PREVIOUS_POSTIT: 303*cdf0e10cSrcweir case SID_NEXT_POSTIT: 304*cdf0e10cSrcweir SelectNextAnnotation( rReq.GetSlot() == SID_NEXT_POSTIT ); 305*cdf0e10cSrcweir break; 306*cdf0e10cSrcweir case SID_REPLYTO_POSTIT: 307*cdf0e10cSrcweir ExecuteReplyToAnnotation( rReq ); 308*cdf0e10cSrcweir break; 309*cdf0e10cSrcweir case SID_SHOW_POSTIT: 310*cdf0e10cSrcweir ShowAnnotations( !mbShowAnnotations ); 311*cdf0e10cSrcweir break; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir // -------------------------------------------------------------------- 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir void AnnotationManagerImpl::ExecuteInsertAnnotation(SfxRequest& /*rReq*/) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir ShowAnnotations(true); 320*cdf0e10cSrcweir InsertAnnotation(); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir // -------------------------------------------------------------------- 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest& rReq) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir ShowAnnotations( true ); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir switch( rReq.GetSlot() ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir case SID_DELETEALL_POSTIT: 334*cdf0e10cSrcweir DeleteAllAnnotations(); 335*cdf0e10cSrcweir break; 336*cdf0e10cSrcweir case SID_DELETEALLBYAUTHOR_POSTIT: 337*cdf0e10cSrcweir if( pArgs ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir const SfxPoolItem* pPoolItem = NULL; 340*cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( SID_DELETEALLBYAUTHOR_POSTIT, sal_True, &pPoolItem ) ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir OUString sAuthor( (( const SfxStringItem* ) pPoolItem )->GetValue() ); 343*cdf0e10cSrcweir DeleteAnnotationsByAuthor( sAuthor ); 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir break; 347*cdf0e10cSrcweir case SID_DELETE_POSTIT: 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir Reference< XAnnotation > xAnnotation; 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir if( rReq.GetSlot() == SID_DELETE_POSTIT ) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir if( pArgs ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir const SfxPoolItem* pPoolItem = NULL; 356*cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( SID_DELETE_POSTIT, sal_True, &pPoolItem ) ) 357*cdf0e10cSrcweir ( ( const SfxUnoAnyItem* ) pPoolItem )->GetValue() >>= xAnnotation; 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir if( !xAnnotation.is() ) 362*cdf0e10cSrcweir GetSelectedAnnotation( xAnnotation ); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir DeleteAnnotation( xAnnotation ); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir break; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir UpdateTags(); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir // -------------------------------------------------------------------- 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir void AnnotationManagerImpl::InsertAnnotation() 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir SdPage* pPage = GetCurrentPage(); 377*cdf0e10cSrcweir if( pPage ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 380*cdf0e10cSrcweir mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_INSERT ) ) ); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir // find free space for new annotation 383*cdf0e10cSrcweir int y = 0, x = 0; 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir AnnotationVector aAnnotations( pPage->getAnnotations() ); 386*cdf0e10cSrcweir if( !aAnnotations.empty() ) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir const int page_width = pPage->GetSize().Width(); 389*cdf0e10cSrcweir const int width = 1000; 390*cdf0e10cSrcweir const int height = 800; 391*cdf0e10cSrcweir Rectangle aTagRect; 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir while( true ) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir Rectangle aNewRect( x, y, x + width - 1, y + height - 1 ); 396*cdf0e10cSrcweir bool bFree = true; 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir RealPoint2D aPoint( (*iter)->getPosition() ); 401*cdf0e10cSrcweir aTagRect.nLeft = sal::static_int_cast< long >( aPoint.X * 100.0 ); 402*cdf0e10cSrcweir aTagRect.nTop = sal::static_int_cast< long >( aPoint.Y * 100.0 ); 403*cdf0e10cSrcweir aTagRect.nRight = aTagRect.nLeft + width - 1; 404*cdf0e10cSrcweir aTagRect.nBottom = aTagRect.nTop + height - 1; 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir if( aNewRect.IsOver( aTagRect ) ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir bFree = false; 409*cdf0e10cSrcweir break; 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir if( bFree == false) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir x += width; 416*cdf0e10cSrcweir if( x > page_width ) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir x = 0; 419*cdf0e10cSrcweir y += height; 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir else 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir break; 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir Reference< XAnnotation > xAnnotation; 430*cdf0e10cSrcweir pPage->createAnnotation( xAnnotation ); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir // set current author to new annotation 433*cdf0e10cSrcweir SvtUserOptions aUserOptions; 434*cdf0e10cSrcweir xAnnotation->setAuthor( aUserOptions.GetFullName() ); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir // set current time to new annotation 437*cdf0e10cSrcweir xAnnotation->setDateTime( getCurrentDateTime() ); 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir // set position 440*cdf0e10cSrcweir RealPoint2D aPos( ((double)x) / 100.0, ((double)y) / 100.0 ); 441*cdf0e10cSrcweir xAnnotation->setPosition( aPos ); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 444*cdf0e10cSrcweir mpDoc->EndUndo(); 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir UpdateTags(true); 447*cdf0e10cSrcweir SelectAnnotation( xAnnotation, true ); 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir // -------------------------------------------------------------------- 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest& rReq ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir Reference< XAnnotation > xAnnotation; 456*cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 457*cdf0e10cSrcweir if( pArgs ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir const SfxPoolItem* pPoolItem = NULL; 460*cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( rReq.GetSlot(), sal_True, &pPoolItem ) ) 461*cdf0e10cSrcweir ( ( const SfxUnoAnyItem* ) pPoolItem )->GetValue() >>= xAnnotation; 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir TextApiObject* pTextApi = getTextApiObject( xAnnotation ); 466*cdf0e10cSrcweir if( pTextApi ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir std::auto_ptr< ::Outliner > pOutliner( new ::Outliner(GetAnnotationPool(),OUTLINERMODE_TEXTOBJECT) ); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir mpDoc->SetCalcFieldValueHdl( pOutliner.get() ); 471*cdf0e10cSrcweir pOutliner->SetUpdateMode( sal_True ); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir String aStr(SdResId(STR_ANNOTATION_REPLY)); 474*cdf0e10cSrcweir OUString sAuthor( xAnnotation->getAuthor() ); 475*cdf0e10cSrcweir if( sAuthor.getLength() == 0 ) 476*cdf0e10cSrcweir sAuthor = String( SdResId( STR_ANNOTATION_NOAUTHOR ) ); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir aStr.SearchAndReplaceAscii("%1", sAuthor); 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir aStr.Append( String(RTL_CONSTASCII_USTRINGPARAM(" (") ) ); 481*cdf0e10cSrcweir aStr.Append( String( getAnnotationDateTimeString( xAnnotation ) ) ); 482*cdf0e10cSrcweir aStr.Append( String(RTL_CONSTASCII_USTRINGPARAM("): \"") ) ); 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir String sQuote( pTextApi->GetText() ); 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir if( sQuote.Len() == 0 ) 487*cdf0e10cSrcweir sQuote = String( RTL_CONSTASCII_USTRINGPARAM( "..." ) ); 488*cdf0e10cSrcweir aStr.Append( sQuote ); 489*cdf0e10cSrcweir aStr.Append( String(RTL_CONSTASCII_USTRINGPARAM("\"\n") ) ); 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir sal_uInt16 nParaCount = aStr.GetTokenCount( '\n' ); 492*cdf0e10cSrcweir for( sal_uInt16 nPara = 0; nPara < nParaCount; nPara++ ) 493*cdf0e10cSrcweir pOutliner->Insert( aStr.GetToken( nPara, '\n' ), LIST_APPEND, -1 ); 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir if( pOutliner->GetParagraphCount() > 1 ) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir SfxItemSet aAnswerSet( pOutliner->GetEmptyItemSet() ); 498*cdf0e10cSrcweir aAnswerSet.Put(SvxPostureItem(ITALIC_NORMAL,EE_CHAR_ITALIC)); 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir ESelection aSel; 501*cdf0e10cSrcweir aSel.nEndPara = (sal_uInt16)pOutliner->GetParagraphCount()-2; 502*cdf0e10cSrcweir aSel.nEndPos = pOutliner->GetText( pOutliner->GetParagraph( aSel.nEndPara ) ).Len(); 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir pOutliner->QuickSetAttribs( aAnswerSet, aSel ); 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir std::auto_ptr< OutlinerParaObject > pOPO( pOutliner->CreateParaObject() ); 508*cdf0e10cSrcweir pTextApi->SetText( *pOPO.get() ); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir SvtUserOptions aUserOptions; 511*cdf0e10cSrcweir xAnnotation->setAuthor( aUserOptions.GetFullName() ); 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir // set current time to reply 514*cdf0e10cSrcweir xAnnotation->setDateTime( getCurrentDateTime() ); 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir UpdateTags(true); 517*cdf0e10cSrcweir SelectAnnotation( xAnnotation, true ); 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir // -------------------------------------------------------------------- 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir void AnnotationManagerImpl::DeleteAnnotation( Reference< XAnnotation > xAnnotation ) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir SdPage* pPage = GetCurrentPage(); 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir if( xAnnotation.is() && pPage ) 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 530*cdf0e10cSrcweir mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_DELETE ) ) ); 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir pPage->removeAnnotation( xAnnotation ); 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 535*cdf0e10cSrcweir mpDoc->EndUndo(); 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir UpdateTags(); 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir void AnnotationManagerImpl::DeleteAnnotationsByAuthor( const rtl::OUString& sAuthor ) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 544*cdf0e10cSrcweir mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_DELETE ) ) ); 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir SdPage* pPage = 0; 547*cdf0e10cSrcweir do 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir pPage = GetNextPage( pPage, true ); 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir if( pPage && !pPage->getAnnotations().empty() ) 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir AnnotationVector aAnnotations( pPage->getAnnotations() ); 554*cdf0e10cSrcweir for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir Reference< XAnnotation > xAnnotation( *iter ); 557*cdf0e10cSrcweir if( xAnnotation->getAuthor() == sAuthor ) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir if( mxSelectedAnnotation == xAnnotation ) 560*cdf0e10cSrcweir mxSelectedAnnotation.clear(); 561*cdf0e10cSrcweir pPage->removeAnnotation( xAnnotation ); 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir } while( pPage ); 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 568*cdf0e10cSrcweir mpDoc->EndUndo(); 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir void AnnotationManagerImpl::DeleteAllAnnotations() 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 574*cdf0e10cSrcweir mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_DELETE ) ) ); 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir SdPage* pPage = 0; 577*cdf0e10cSrcweir do 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir pPage = GetNextPage( pPage, true ); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir if( pPage && !pPage->getAnnotations().empty() ) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir AnnotationVector aAnnotations( pPage->getAnnotations() ); 585*cdf0e10cSrcweir for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir pPage->removeAnnotation( (*iter) ); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir while( pPage ); 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir mxSelectedAnnotation.clear(); 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir if( mpDoc->IsUndoEnabled() ) 596*cdf0e10cSrcweir mpDoc->EndUndo(); 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir // -------------------------------------------------------------------- 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir void AnnotationManagerImpl::GetAnnotationState(SfxItemSet& rSet) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir SdPage* pCurrentPage = GetCurrentPage(); 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir const bool bReadOnly = mrBase.GetDocShell()->IsReadOnly(); 606*cdf0e10cSrcweir const bool bWrongPageKind = (pCurrentPage == 0) || (pCurrentPage->GetPageKind() != PK_STANDARD); 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir if( bReadOnly || bWrongPageKind || (nCurrentODFVersion != SvtSaveOptions::ODFVER_LATEST) ) 611*cdf0e10cSrcweir rSet.DisableItem( SID_INSERT_POSTIT ); 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir rSet.Put(SfxBoolItem(SID_SHOW_POSTIT, mbShowAnnotations)); 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir Reference< XAnnotation > xAnnotation; 616*cdf0e10cSrcweir GetSelectedAnnotation( xAnnotation ); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir if( !xAnnotation.is() || bReadOnly ) 619*cdf0e10cSrcweir rSet.DisableItem( SID_DELETE_POSTIT ); 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir SdPage* pPage = 0; 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir bool bHasAnnotations = false; 624*cdf0e10cSrcweir do 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir pPage = GetNextPage( pPage, true ); 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir if( pPage && !pPage->getAnnotations().empty() ) 629*cdf0e10cSrcweir bHasAnnotations = true; 630*cdf0e10cSrcweir } 631*cdf0e10cSrcweir while( pPage && !bHasAnnotations ); 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir if( !bHasAnnotations || bReadOnly ) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir rSet.DisableItem( SID_DELETEALL_POSTIT ); 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir if( bWrongPageKind || !bHasAnnotations ) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir rSet.DisableItem( SID_PREVIOUS_POSTIT ); 641*cdf0e10cSrcweir rSet.DisableItem( SID_NEXT_POSTIT ); 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir // -------------------------------------------------------------------- 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir void AnnotationManagerImpl::SelectNextAnnotation(bool bForeward) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir ShowAnnotations( true ); 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir Reference< XAnnotation > xCurrent; 652*cdf0e10cSrcweir GetSelectedAnnotation( xCurrent ); 653*cdf0e10cSrcweir SdPage* pPage = GetCurrentPage(); 654*cdf0e10cSrcweir if( !pPage ) 655*cdf0e10cSrcweir return; 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir AnnotationVector aAnnotations( pPage->getAnnotations() ); 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir if( bForeward ) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir if( xCurrent.is() ) 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir if( (*iter) == xCurrent ) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir iter++; 668*cdf0e10cSrcweir if( iter != aAnnotations.end() ) 669*cdf0e10cSrcweir { 670*cdf0e10cSrcweir SelectAnnotation( (*iter) ); 671*cdf0e10cSrcweir return; 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir break; 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir else if( !aAnnotations.empty() ) 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir SelectAnnotation( *(aAnnotations.begin()) ); 680*cdf0e10cSrcweir return; 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir else 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir if( xCurrent.is() ) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) 688*cdf0e10cSrcweir { 689*cdf0e10cSrcweir if( (*iter) == xCurrent ) 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir if( iter != aAnnotations.begin() ) 692*cdf0e10cSrcweir { 693*cdf0e10cSrcweir iter--; 694*cdf0e10cSrcweir SelectAnnotation( (*iter) ); 695*cdf0e10cSrcweir return; 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir break; 699*cdf0e10cSrcweir } 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir else if( !aAnnotations.empty() ) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir AnnotationVector::iterator iter( aAnnotations.end() ); 705*cdf0e10cSrcweir SelectAnnotation( *(--iter) ); 706*cdf0e10cSrcweir return; 707*cdf0e10cSrcweir } 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir mxSelectedAnnotation.clear(); 711*cdf0e10cSrcweir do 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir do 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir pPage = GetNextPage( pPage, bForeward ); 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir if( pPage && !pPage->getAnnotations().empty() ) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir // switch to next/previous slide with annotations 720*cdf0e10cSrcweir ::boost::shared_ptr<DrawViewShell> pDrawViewShell(::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell())); 721*cdf0e10cSrcweir if (pDrawViewShell.get() != NULL) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir pDrawViewShell->ChangeEditMode(pPage->IsMasterPage() ? EM_MASTERPAGE : EM_PAGE, sal_False); 724*cdf0e10cSrcweir pDrawViewShell->SwitchPage((pPage->GetPageNum() - 1) >> 1); 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir SfxDispatcher* pDispatcher = getDispatcher( mrBase ); 727*cdf0e10cSrcweir if( pDispatcher ) 728*cdf0e10cSrcweir pDispatcher->Execute( bForeward ? SID_NEXT_POSTIT : SID_PREVIOUS_POSTIT ); 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir return; 731*cdf0e10cSrcweir } 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir while( pPage ); 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir // The question text depends on the search direction. 737*cdf0e10cSrcweir bool bImpress = mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS; 738*cdf0e10cSrcweir sal_uInt16 nStringId; 739*cdf0e10cSrcweir if(bForeward) 740*cdf0e10cSrcweir nStringId = bImpress ? STR_ANNOTATION_WRAP_FORWARD : STR_ANNOTATION_WRAP_FORWARD_DRAW; 741*cdf0e10cSrcweir else 742*cdf0e10cSrcweir nStringId = bImpress ? STR_ANNOTATION_WRAP_BACKWARD : STR_ANNOTATION_WRAP_BACKWARD_DRAW; 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir // Pop up question box that asks the user whether to wrap arround. 745*cdf0e10cSrcweir // The dialog is made modal with respect to the whole application. 746*cdf0e10cSrcweir QueryBox aQuestionBox ( 747*cdf0e10cSrcweir NULL, 748*cdf0e10cSrcweir WB_YES_NO | WB_DEF_YES, 749*cdf0e10cSrcweir String(SdResId(nStringId))); 750*cdf0e10cSrcweir aQuestionBox.SetImage (QueryBox::GetStandardImage()); 751*cdf0e10cSrcweir sal_uInt16 nBoxResult = aQuestionBox.Execute(); 752*cdf0e10cSrcweir if(nBoxResult != BUTTONID_YES) 753*cdf0e10cSrcweir break; 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir while( true ); 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir // -------------------------------------------------------------------- 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir void AnnotationManagerImpl::onTagSelected( AnnotationTag& rTag ) 761*cdf0e10cSrcweir { 762*cdf0e10cSrcweir mxSelectedAnnotation = rTag.GetAnnotation(); 763*cdf0e10cSrcweir invalidateSlots(); 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir // -------------------------------------------------------------------- 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir void AnnotationManagerImpl::onTagDeselected( AnnotationTag& rTag ) 769*cdf0e10cSrcweir { 770*cdf0e10cSrcweir if( rTag.GetAnnotation() == mxSelectedAnnotation ) 771*cdf0e10cSrcweir { 772*cdf0e10cSrcweir mxSelectedAnnotation.clear(); 773*cdf0e10cSrcweir invalidateSlots(); 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir } 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir // -------------------------------------------------------------------- 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir void AnnotationManagerImpl::SelectAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, bool bEdit /* = sal_False */ ) 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir mxSelectedAnnotation = xAnnotation; 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir for( AnnotationTagVector::iterator iter( maTagVector.begin() ); iter != maTagVector.end(); iter++ ) 784*cdf0e10cSrcweir { 785*cdf0e10cSrcweir if( (*iter)->GetAnnotation() == xAnnotation ) 786*cdf0e10cSrcweir { 787*cdf0e10cSrcweir SmartTagReference xTag( (*iter).get() ); 788*cdf0e10cSrcweir mrBase.GetMainViewShell()->GetView()->getSmartTags().select( xTag ); 789*cdf0e10cSrcweir (*iter)->OpenPopup( bEdit ); 790*cdf0e10cSrcweir break; 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir // -------------------------------------------------------------------- 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir void AnnotationManagerImpl::GetSelectedAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation ) 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir xAnnotation = mxSelectedAnnotation; 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir void AnnotationManagerImpl::invalidateSlots() 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir SfxBindings* pBindings = getBindings( mrBase ); 805*cdf0e10cSrcweir if( pBindings ) 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir pBindings->Invalidate( SID_INSERT_POSTIT ); 808*cdf0e10cSrcweir pBindings->Invalidate( SID_DELETE_POSTIT ); 809*cdf0e10cSrcweir pBindings->Invalidate( SID_DELETEALL_POSTIT ); 810*cdf0e10cSrcweir pBindings->Invalidate( SID_PREVIOUS_POSTIT ); 811*cdf0e10cSrcweir pBindings->Invalidate( SID_NEXT_POSTIT ); 812*cdf0e10cSrcweir pBindings->Invalidate( SID_UNDO ); 813*cdf0e10cSrcweir pBindings->Invalidate( SID_REDO ); 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir } 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir // -------------------------------------------------------------------- 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir void AnnotationManagerImpl::onSelectionChanged() 820*cdf0e10cSrcweir { 821*cdf0e10cSrcweir if( mxView.is() && mrBase.GetDrawView() ) try 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir Reference< XAnnotationAccess > xPage( mxView->getCurrentPage(), UNO_QUERY ); 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir if( xPage != mxCurrentPage ) 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir mxCurrentPage = xPage; 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir UpdateTags(true); 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir } 832*cdf0e10cSrcweir catch( Exception& ) 833*cdf0e10cSrcweir { 834*cdf0e10cSrcweir DBG_ERROR( "sd::AnnotationManagerImpl::onSelectionChanged(), exception caught!" ); 835*cdf0e10cSrcweir } 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir 838*cdf0e10cSrcweir void AnnotationManagerImpl::UpdateTags( bool bSynchron ) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir if( bSynchron ) 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir if( mnUpdateTagsEvent ) 843*cdf0e10cSrcweir Application::RemoveUserEvent( mnUpdateTagsEvent ); 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir UpdateTagsHdl(0); 846*cdf0e10cSrcweir } 847*cdf0e10cSrcweir else 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir if( !mnUpdateTagsEvent && mxView.is() ) 850*cdf0e10cSrcweir mnUpdateTagsEvent = Application::PostUserEvent( LINK( this, AnnotationManagerImpl, UpdateTagsHdl ) ); 851*cdf0e10cSrcweir } 852*cdf0e10cSrcweir } 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir IMPL_LINK(AnnotationManagerImpl,UpdateTagsHdl, void *, EMPTYARG) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir mnUpdateTagsEvent = 0; 857*cdf0e10cSrcweir DisposeTags(); 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir if( mbShowAnnotations ) 860*cdf0e10cSrcweir CreateTags(); 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir if( mrBase.GetDrawView() ) 863*cdf0e10cSrcweir static_cast< ::sd::View* >( mrBase.GetDrawView() )->updateHandles(); 864*cdf0e10cSrcweir 865*cdf0e10cSrcweir invalidateSlots(); 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir return 0; 868*cdf0e10cSrcweir } 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir void AnnotationManagerImpl::CreateTags() 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir if( mxCurrentPage.is() && mpDoc ) try 874*cdf0e10cSrcweir { 875*cdf0e10cSrcweir int nIndex = 1; 876*cdf0e10cSrcweir maFont = Application::GetSettings().GetStyleSettings().GetAppFont(); 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir rtl::Reference< AnnotationTag > xSelectedTag; 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir Reference< XAnnotationEnumeration > xEnum( mxCurrentPage->createAnnotationEnumeration() ); 881*cdf0e10cSrcweir while( xEnum->hasMoreElements() ) 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir Reference< XAnnotation > xAnnotation( xEnum->nextElement() ); 884*cdf0e10cSrcweir Color aColor( GetColorLight( mpDoc->GetAnnotationAuthorIndex( xAnnotation->getAuthor() ) ) ); 885*cdf0e10cSrcweir rtl::Reference< AnnotationTag > xTag( new AnnotationTag( *this, *mrBase.GetMainViewShell()->GetView(), xAnnotation, aColor, nIndex++, maFont ) ); 886*cdf0e10cSrcweir maTagVector.push_back(xTag); 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir if( xAnnotation == mxSelectedAnnotation ) 889*cdf0e10cSrcweir { 890*cdf0e10cSrcweir xSelectedTag = xTag; 891*cdf0e10cSrcweir } 892*cdf0e10cSrcweir } 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir if( xSelectedTag.is() ) 895*cdf0e10cSrcweir { 896*cdf0e10cSrcweir SmartTagReference xTag( xSelectedTag.get() ); 897*cdf0e10cSrcweir mrBase.GetMainViewShell()->GetView()->getSmartTags().select( xTag ); 898*cdf0e10cSrcweir } 899*cdf0e10cSrcweir else 900*cdf0e10cSrcweir { 901*cdf0e10cSrcweir // no tag, no selection! 902*cdf0e10cSrcweir mxSelectedAnnotation.clear(); 903*cdf0e10cSrcweir } 904*cdf0e10cSrcweir } 905*cdf0e10cSrcweir catch( Exception& ) 906*cdf0e10cSrcweir { 907*cdf0e10cSrcweir DBG_ERROR( "sd::AnnotationManagerImpl::onSelectionChanged(), exception caught!" ); 908*cdf0e10cSrcweir } 909*cdf0e10cSrcweir } 910*cdf0e10cSrcweir 911*cdf0e10cSrcweir // -------------------------------------------------------------------- 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir void AnnotationManagerImpl::DisposeTags() 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir if( !maTagVector.empty() ) 916*cdf0e10cSrcweir { 917*cdf0e10cSrcweir AnnotationTagVector::iterator iter = maTagVector.begin(); 918*cdf0e10cSrcweir do 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir (*iter++)->Dispose(); 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir while( iter != maTagVector.end() ); 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir maTagVector.clear(); 925*cdf0e10cSrcweir } 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir // -------------------------------------------------------------------- 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir void AnnotationManagerImpl::addListener() 931*cdf0e10cSrcweir { 932*cdf0e10cSrcweir Link aLink( LINK(this,AnnotationManagerImpl,EventMultiplexerListener) ); 933*cdf0e10cSrcweir mrBase.GetEventMultiplexer()->AddEventListener ( 934*cdf0e10cSrcweir aLink, 935*cdf0e10cSrcweir tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION 936*cdf0e10cSrcweir | tools::EventMultiplexerEvent::EID_CURRENT_PAGE 937*cdf0e10cSrcweir | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED 938*cdf0e10cSrcweir | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED); 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir 941*cdf0e10cSrcweir // -------------------------------------------------------------------- 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir void AnnotationManagerImpl::removeListener() 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir Link aLink( LINK(this,AnnotationManagerImpl,EventMultiplexerListener) ); 946*cdf0e10cSrcweir mrBase.GetEventMultiplexer()->RemoveEventListener( aLink ); 947*cdf0e10cSrcweir } 948*cdf0e10cSrcweir 949*cdf0e10cSrcweir // -------------------------------------------------------------------- 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir IMPL_LINK(AnnotationManagerImpl,EventMultiplexerListener, 952*cdf0e10cSrcweir tools::EventMultiplexerEvent*,pEvent) 953*cdf0e10cSrcweir { 954*cdf0e10cSrcweir switch (pEvent->meEventId) 955*cdf0e10cSrcweir { 956*cdf0e10cSrcweir case tools::EventMultiplexerEvent::EID_CURRENT_PAGE: 957*cdf0e10cSrcweir case tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION: 958*cdf0e10cSrcweir onSelectionChanged(); 959*cdf0e10cSrcweir break; 960*cdf0e10cSrcweir 961*cdf0e10cSrcweir case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED: 962*cdf0e10cSrcweir mxView = Reference<XDrawView>(); 963*cdf0e10cSrcweir onSelectionChanged(); 964*cdf0e10cSrcweir break; 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED: 967*cdf0e10cSrcweir mxView = Reference<XDrawView>::query( mrBase.GetController() ); 968*cdf0e10cSrcweir onSelectionChanged(); 969*cdf0e10cSrcweir break; 970*cdf0e10cSrcweir } 971*cdf0e10cSrcweir return 0; 972*cdf0e10cSrcweir } 973*cdf0e10cSrcweir #if 0 974*cdf0e10cSrcweir OUString AnnotationManagerImpl::GetHelpText( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation ) 975*cdf0e10cSrcweir { 976*cdf0e10cSrcweir OUString sRet; 977*cdf0e10cSrcweir if( xAnnotation.is() ) 978*cdf0e10cSrcweir { 979*cdf0e10cSrcweir OUString sAuthor( xAnnotation->getAuthor() ); 980*cdf0e10cSrcweir if( sAuthor.getLength() != 0 ) 981*cdf0e10cSrcweir { 982*cdf0e10cSrcweir sRet += sAuthor; 983*cdf0e10cSrcweir } 984*cdf0e10cSrcweir sRet += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) ); 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir sRet += getAnnotationDateTimeString( xAnnotation ); 987*cdf0e10cSrcweir sRet += OUString( RTL_CONSTASCII_USTRINGPARAM( "]\n" ) ); 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir Reference< XText > xText( xAnnotation->getTextRange() ); 990*cdf0e10cSrcweir if( xText.is() ) 991*cdf0e10cSrcweir sRet += xText->getString(); 992*cdf0e10cSrcweir } 993*cdf0e10cSrcweir 994*cdf0e10cSrcweir return sRet; 995*cdf0e10cSrcweir } 996*cdf0e10cSrcweir #endif 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir void AnnotationManagerImpl::ExecuteAnnotationContextMenu( Reference< XAnnotation > xAnnotation, ::Window* pParent, const Rectangle& rContextRect, bool bButtonMenu /* = false */ ) 999*cdf0e10cSrcweir { 1000*cdf0e10cSrcweir SfxDispatcher* pDispatcher( getDispatcher( mrBase ) ); 1001*cdf0e10cSrcweir if( !pDispatcher ) 1002*cdf0e10cSrcweir return; 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir const bool bReadOnly = mrBase.GetDocShell()->IsReadOnly(); 1005*cdf0e10cSrcweir 1006*cdf0e10cSrcweir AnnotationWindow* pAnnotationWindow = bButtonMenu ? 0 : dynamic_cast< AnnotationWindow* >( pParent ); 1007*cdf0e10cSrcweir 1008*cdf0e10cSrcweir if( bReadOnly && !pAnnotationWindow ) 1009*cdf0e10cSrcweir return; 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir std::auto_ptr< PopupMenu > pMenu( new PopupMenu( SdResId( pAnnotationWindow ? RID_ANNOTATION_CONTEXTMENU : RID_ANNOTATION_TAG_CONTEXTMENU ) ) ); 1012*cdf0e10cSrcweir 1013*cdf0e10cSrcweir SvtUserOptions aUserOptions; 1014*cdf0e10cSrcweir OUString sCurrentAuthor( aUserOptions.GetFullName() ); 1015*cdf0e10cSrcweir OUString sAuthor( xAnnotation->getAuthor() ); 1016*cdf0e10cSrcweir 1017*cdf0e10cSrcweir String aStr( pMenu->GetItemText( SID_DELETEALLBYAUTHOR_POSTIT ) ), aReplace( sAuthor ); 1018*cdf0e10cSrcweir if( aReplace.Len() == 0 ) 1019*cdf0e10cSrcweir aReplace = String( SdResId( STR_ANNOTATION_NOAUTHOR ) ); 1020*cdf0e10cSrcweir aStr.SearchAndReplaceAscii("%1", aReplace); 1021*cdf0e10cSrcweir pMenu->SetItemText( SID_DELETEALLBYAUTHOR_POSTIT, aStr ); 1022*cdf0e10cSrcweir pMenu->EnableItem( SID_REPLYTO_POSTIT, (sAuthor != sCurrentAuthor) && !bReadOnly ); 1023*cdf0e10cSrcweir pMenu->EnableItem( SID_DELETE_POSTIT, (xAnnotation.is() && !bReadOnly) ? sal_True : sal_False ); 1024*cdf0e10cSrcweir pMenu->EnableItem( SID_DELETEALLBYAUTHOR_POSTIT, !bReadOnly ); 1025*cdf0e10cSrcweir pMenu->EnableItem( SID_DELETEALL_POSTIT, !bReadOnly ); 1026*cdf0e10cSrcweir 1027*cdf0e10cSrcweir if( pAnnotationWindow ) 1028*cdf0e10cSrcweir { 1029*cdf0e10cSrcweir if( pAnnotationWindow->IsProtected() || bReadOnly ) 1030*cdf0e10cSrcweir { 1031*cdf0e10cSrcweir pMenu->EnableItem( SID_ATTR_CHAR_WEIGHT, sal_False ); 1032*cdf0e10cSrcweir pMenu->EnableItem( SID_ATTR_CHAR_POSTURE, sal_False ); 1033*cdf0e10cSrcweir pMenu->EnableItem( SID_ATTR_CHAR_UNDERLINE, sal_False ); 1034*cdf0e10cSrcweir pMenu->EnableItem( SID_ATTR_CHAR_STRIKEOUT, sal_False ); 1035*cdf0e10cSrcweir pMenu->EnableItem( SID_PASTE, sal_False ); 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir else 1038*cdf0e10cSrcweir { 1039*cdf0e10cSrcweir SfxItemSet aSet(pAnnotationWindow->getView()->GetAttribs()); 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir if ( aSet.GetItemState( EE_CHAR_WEIGHT ) == SFX_ITEM_ON ) 1042*cdf0e10cSrcweir { 1043*cdf0e10cSrcweir if( ((const SvxWeightItem&)aSet.Get( EE_CHAR_WEIGHT )).GetWeight() == WEIGHT_BOLD ) 1044*cdf0e10cSrcweir pMenu->CheckItem( SID_ATTR_CHAR_WEIGHT ); 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir if ( aSet.GetItemState( EE_CHAR_ITALIC ) == SFX_ITEM_ON ) 1048*cdf0e10cSrcweir { 1049*cdf0e10cSrcweir if( ((const SvxPostureItem&)aSet.Get( EE_CHAR_ITALIC )).GetPosture() != ITALIC_NONE ) 1050*cdf0e10cSrcweir pMenu->CheckItem( SID_ATTR_CHAR_POSTURE ); 1051*cdf0e10cSrcweir 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir if ( aSet.GetItemState( EE_CHAR_UNDERLINE ) == SFX_ITEM_ON ) 1054*cdf0e10cSrcweir { 1055*cdf0e10cSrcweir if( ((const SvxUnderlineItem&)aSet.Get( EE_CHAR_UNDERLINE )).GetLineStyle() != UNDERLINE_NONE ) 1056*cdf0e10cSrcweir pMenu->CheckItem( SID_ATTR_CHAR_UNDERLINE ); 1057*cdf0e10cSrcweir } 1058*cdf0e10cSrcweir 1059*cdf0e10cSrcweir if ( aSet.GetItemState( EE_CHAR_STRIKEOUT ) == SFX_ITEM_ON ) 1060*cdf0e10cSrcweir { 1061*cdf0e10cSrcweir if( ((const SvxCrossedOutItem&)aSet.Get( EE_CHAR_STRIKEOUT )).GetStrikeout() != STRIKEOUT_NONE ) 1062*cdf0e10cSrcweir pMenu->CheckItem( SID_ATTR_CHAR_STRIKEOUT ); 1063*cdf0e10cSrcweir } 1064*cdf0e10cSrcweir TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pAnnotationWindow ) ); 1065*cdf0e10cSrcweir pMenu->EnableItem( SID_PASTE, aDataHelper.GetFormatCount() != 0 ); 1066*cdf0e10cSrcweir } 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir pMenu->EnableItem( SID_COPY, pAnnotationWindow->getView()->HasSelection() ); 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir sal_uInt16 nId = 0; 1072*cdf0e10cSrcweir 1073*cdf0e10cSrcweir // set slot images 1074*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XFrame > xFrame( mrBase.GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface() ); 1075*cdf0e10cSrcweir if( xFrame.is() ) 1076*cdf0e10cSrcweir { 1077*cdf0e10cSrcweir const bool bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); 1078*cdf0e10cSrcweir for( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); nPos++ ) 1079*cdf0e10cSrcweir { 1080*cdf0e10cSrcweir nId = pMenu->GetItemId( nPos ); 1081*cdf0e10cSrcweir if( pMenu->IsItemEnabled( nId ) ) 1082*cdf0e10cSrcweir { 1083*cdf0e10cSrcweir OUString sSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); 1084*cdf0e10cSrcweir sSlotURL += OUString::valueOf( sal_Int32( nId )); 1085*cdf0e10cSrcweir 1086*cdf0e10cSrcweir Image aImage( GetImage( xFrame, sSlotURL, false, bHighContrast ) ); 1087*cdf0e10cSrcweir if( !!aImage ) 1088*cdf0e10cSrcweir pMenu->SetItemImage( nId, aImage ); 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir } 1091*cdf0e10cSrcweir } 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir nId = pMenu->Execute( pParent, rContextRect, POPUPMENU_EXECUTE_DOWN|POPUPMENU_NOMOUSEUPCLOSE ); 1094*cdf0e10cSrcweir switch( nId ) 1095*cdf0e10cSrcweir { 1096*cdf0e10cSrcweir case SID_REPLYTO_POSTIT: 1097*cdf0e10cSrcweir { 1098*cdf0e10cSrcweir const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( xAnnotation ) ); 1099*cdf0e10cSrcweir pDispatcher->Execute( SID_REPLYTO_POSTIT, SFX_CALLMODE_ASYNCHRON, &aItem, 0 ); 1100*cdf0e10cSrcweir break; 1101*cdf0e10cSrcweir } 1102*cdf0e10cSrcweir case SID_DELETE_POSTIT: 1103*cdf0e10cSrcweir { 1104*cdf0e10cSrcweir const SfxUnoAnyItem aItem( SID_DELETE_POSTIT, Any( xAnnotation ) ); 1105*cdf0e10cSrcweir pDispatcher->Execute( SID_DELETE_POSTIT, SFX_CALLMODE_ASYNCHRON, &aItem, 0 ); 1106*cdf0e10cSrcweir break; 1107*cdf0e10cSrcweir } 1108*cdf0e10cSrcweir case SID_DELETEALLBYAUTHOR_POSTIT: 1109*cdf0e10cSrcweir { 1110*cdf0e10cSrcweir const SfxStringItem aItem( SID_DELETEALLBYAUTHOR_POSTIT, sAuthor ); 1111*cdf0e10cSrcweir pDispatcher->Execute( SID_DELETEALLBYAUTHOR_POSTIT, SFX_CALLMODE_ASYNCHRON, &aItem, 0 ); 1112*cdf0e10cSrcweir break; 1113*cdf0e10cSrcweir } 1114*cdf0e10cSrcweir case SID_DELETEALL_POSTIT: 1115*cdf0e10cSrcweir pDispatcher->Execute( SID_DELETEALL_POSTIT ); 1116*cdf0e10cSrcweir break; 1117*cdf0e10cSrcweir case SID_COPY: 1118*cdf0e10cSrcweir case SID_PASTE: 1119*cdf0e10cSrcweir case SID_ATTR_CHAR_WEIGHT: 1120*cdf0e10cSrcweir case SID_ATTR_CHAR_POSTURE: 1121*cdf0e10cSrcweir case SID_ATTR_CHAR_UNDERLINE: 1122*cdf0e10cSrcweir case SID_ATTR_CHAR_STRIKEOUT: 1123*cdf0e10cSrcweir if( pAnnotationWindow ) 1124*cdf0e10cSrcweir pAnnotationWindow->ExecuteSlot( nId ); 1125*cdf0e10cSrcweir break; 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir } 1128*cdf0e10cSrcweir 1129*cdf0e10cSrcweir // ==================================================================== 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir Color AnnotationManagerImpl::GetColor(sal_uInt16 aAuthorIndex) 1132*cdf0e10cSrcweir { 1133*cdf0e10cSrcweir if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) 1134*cdf0e10cSrcweir { 1135*cdf0e10cSrcweir static const Color aArrayNormal[] = { 1136*cdf0e10cSrcweir COL_AUTHOR1_NORMAL, COL_AUTHOR2_NORMAL, COL_AUTHOR3_NORMAL, 1137*cdf0e10cSrcweir COL_AUTHOR4_NORMAL, COL_AUTHOR5_NORMAL, COL_AUTHOR6_NORMAL, 1138*cdf0e10cSrcweir COL_AUTHOR7_NORMAL, COL_AUTHOR8_NORMAL, COL_AUTHOR9_NORMAL }; 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir return Color( aArrayNormal[ aAuthorIndex % (sizeof( aArrayNormal )/ sizeof( aArrayNormal[0] ))]); 1141*cdf0e10cSrcweir } 1142*cdf0e10cSrcweir else 1143*cdf0e10cSrcweir return Color(COL_WHITE); 1144*cdf0e10cSrcweir } 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir Color AnnotationManagerImpl::GetColorLight(sal_uInt16 aAuthorIndex) 1147*cdf0e10cSrcweir { 1148*cdf0e10cSrcweir if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) 1149*cdf0e10cSrcweir { 1150*cdf0e10cSrcweir static const Color aArrayLight[] = { 1151*cdf0e10cSrcweir COL_AUTHOR1_LIGHT, COL_AUTHOR2_LIGHT, COL_AUTHOR3_LIGHT, 1152*cdf0e10cSrcweir COL_AUTHOR4_LIGHT, COL_AUTHOR5_LIGHT, COL_AUTHOR6_LIGHT, 1153*cdf0e10cSrcweir COL_AUTHOR7_LIGHT, COL_AUTHOR8_LIGHT, COL_AUTHOR9_LIGHT }; 1154*cdf0e10cSrcweir 1155*cdf0e10cSrcweir return Color( aArrayLight[ aAuthorIndex % (sizeof( aArrayLight )/ sizeof( aArrayLight[0] ))]); 1156*cdf0e10cSrcweir } 1157*cdf0e10cSrcweir else 1158*cdf0e10cSrcweir return Color(COL_WHITE); 1159*cdf0e10cSrcweir } 1160*cdf0e10cSrcweir 1161*cdf0e10cSrcweir Color AnnotationManagerImpl::GetColorDark(sal_uInt16 aAuthorIndex) 1162*cdf0e10cSrcweir { 1163*cdf0e10cSrcweir if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir static const Color aArrayAnkor[] = { 1166*cdf0e10cSrcweir COL_AUTHOR1_DARK, COL_AUTHOR2_DARK, COL_AUTHOR3_DARK, 1167*cdf0e10cSrcweir COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK, 1168*cdf0e10cSrcweir COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK }; 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir return Color( aArrayAnkor[ aAuthorIndex % (sizeof( aArrayAnkor ) / sizeof( aArrayAnkor[0] ))]); 1171*cdf0e10cSrcweir } 1172*cdf0e10cSrcweir else 1173*cdf0e10cSrcweir return Color(COL_WHITE); 1174*cdf0e10cSrcweir } 1175*cdf0e10cSrcweir 1176*cdf0e10cSrcweir SdPage* AnnotationManagerImpl::GetNextPage( SdPage* pPage, bool bForeward ) 1177*cdf0e10cSrcweir { 1178*cdf0e10cSrcweir if( pPage == 0 ) 1179*cdf0e10cSrcweir return bForeward ? GetFirstPage() : GetLastPage(); 1180*cdf0e10cSrcweir 1181*cdf0e10cSrcweir sal_uInt16 nPageNum = (pPage->GetPageNum() - 1) >> 1; 1182*cdf0e10cSrcweir 1183*cdf0e10cSrcweir // first all non master pages 1184*cdf0e10cSrcweir if( !pPage->IsMasterPage() ) 1185*cdf0e10cSrcweir { 1186*cdf0e10cSrcweir if( bForeward ) 1187*cdf0e10cSrcweir { 1188*cdf0e10cSrcweir if( nPageNum >= mpDoc->GetSdPageCount(PK_STANDARD)-1 ) 1189*cdf0e10cSrcweir { 1190*cdf0e10cSrcweir // we reached end of draw pages, start with master pages (skip handout master for draw) 1191*cdf0e10cSrcweir return mpDoc->GetMasterSdPage( (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ? 0 : 1, PK_STANDARD ); 1192*cdf0e10cSrcweir } 1193*cdf0e10cSrcweir nPageNum++; 1194*cdf0e10cSrcweir } 1195*cdf0e10cSrcweir else 1196*cdf0e10cSrcweir { 1197*cdf0e10cSrcweir if( nPageNum == 0 ) 1198*cdf0e10cSrcweir return 0; // we are already on the first draw page, finished 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir nPageNum--; 1201*cdf0e10cSrcweir } 1202*cdf0e10cSrcweir return mpDoc->GetSdPage(nPageNum, PK_STANDARD); 1203*cdf0e10cSrcweir } 1204*cdf0e10cSrcweir else 1205*cdf0e10cSrcweir { 1206*cdf0e10cSrcweir if( bForeward ) 1207*cdf0e10cSrcweir { 1208*cdf0e10cSrcweir if( nPageNum >= mpDoc->GetMasterSdPageCount(PK_STANDARD)-1 ) 1209*cdf0e10cSrcweir { 1210*cdf0e10cSrcweir return 0; // we reached the end, there is nothing more to see here 1211*cdf0e10cSrcweir } 1212*cdf0e10cSrcweir nPageNum++; 1213*cdf0e10cSrcweir } 1214*cdf0e10cSrcweir else 1215*cdf0e10cSrcweir { 1216*cdf0e10cSrcweir if( nPageNum == (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ? 0 : 1 ) 1217*cdf0e10cSrcweir { 1218*cdf0e10cSrcweir // we reached beginning of master pages, start with end if pages 1219*cdf0e10cSrcweir return mpDoc->GetSdPage( mpDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD ); 1220*cdf0e10cSrcweir } 1221*cdf0e10cSrcweir 1222*cdf0e10cSrcweir nPageNum--; 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir return mpDoc->GetMasterSdPage(nPageNum,PK_STANDARD); 1225*cdf0e10cSrcweir } 1226*cdf0e10cSrcweir } 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir SdPage* AnnotationManagerImpl::GetFirstPage() 1229*cdf0e10cSrcweir { 1230*cdf0e10cSrcweir // return first drawing page 1231*cdf0e10cSrcweir return mpDoc->GetSdPage(0, PK_STANDARD ); 1232*cdf0e10cSrcweir } 1233*cdf0e10cSrcweir 1234*cdf0e10cSrcweir SdPage* AnnotationManagerImpl::GetLastPage() 1235*cdf0e10cSrcweir { 1236*cdf0e10cSrcweir return mpDoc->GetMasterSdPage( mpDoc->GetMasterSdPageCount(PK_STANDARD) - 1, PK_STANDARD ); 1237*cdf0e10cSrcweir } 1238*cdf0e10cSrcweir 1239*cdf0e10cSrcweir SdPage* AnnotationManagerImpl::GetCurrentPage() 1240*cdf0e10cSrcweir { 1241*cdf0e10cSrcweir /* 1242*cdf0e10cSrcweir ::boost::shared_ptr<DrawViewShell> pDrawViewShell(::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell())); 1243*cdf0e10cSrcweir if (pDrawViewShell.get() != NULL) 1244*cdf0e10cSrcweir return pDrawViewShell->GetActualPage(); 1245*cdf0e10cSrcweir */ 1246*cdf0e10cSrcweir return mrBase.GetMainViewShell()->getCurrentPage(); 1247*cdf0e10cSrcweir } 1248*cdf0e10cSrcweir 1249*cdf0e10cSrcweir // ==================================================================== 1250*cdf0e10cSrcweir 1251*cdf0e10cSrcweir AnnotationManager::AnnotationManager( ViewShellBase& rViewShellBase ) 1252*cdf0e10cSrcweir : mxImpl( new AnnotationManagerImpl( rViewShellBase ) ) 1253*cdf0e10cSrcweir { 1254*cdf0e10cSrcweir mxImpl->init(); 1255*cdf0e10cSrcweir } 1256*cdf0e10cSrcweir 1257*cdf0e10cSrcweir AnnotationManager::~AnnotationManager() 1258*cdf0e10cSrcweir { 1259*cdf0e10cSrcweir mxImpl->dispose(); 1260*cdf0e10cSrcweir } 1261*cdf0e10cSrcweir 1262*cdf0e10cSrcweir void AnnotationManager::ExecuteAnnotation(SfxRequest& rRequest) 1263*cdf0e10cSrcweir { 1264*cdf0e10cSrcweir mxImpl->ExecuteAnnotation( rRequest ); 1265*cdf0e10cSrcweir } 1266*cdf0e10cSrcweir 1267*cdf0e10cSrcweir void AnnotationManager::GetAnnotationState(SfxItemSet& rItemSet) 1268*cdf0e10cSrcweir { 1269*cdf0e10cSrcweir mxImpl->GetAnnotationState(rItemSet); 1270*cdf0e10cSrcweir } 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir } 1273