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_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <svx/svdoutl.hxx> 32*cdf0e10cSrcweir #include <svx/svdmodel.hxx> 33*cdf0e10cSrcweir #include <svx/svdpage.hxx> 34*cdf0e10cSrcweir #include <svx/svdocapt.hxx> 35*cdf0e10cSrcweir #include <sfx2/printer.hxx> 36*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 37*cdf0e10cSrcweir #include <svl/itempool.hxx> 38*cdf0e10cSrcweir #include <vcl/svapp.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include "notemark.hxx" 41*cdf0e10cSrcweir #include "document.hxx" 42*cdf0e10cSrcweir #include "postit.hxx" 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #define SC_NOTEMARK_TIME 800 45*cdf0e10cSrcweir #define SC_NOTEMARK_SHORT 70 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir // ----------------------------------------------------------------------- 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir ScNoteMarker::ScNoteMarker( Window* pWin, Window* pRight, Window* pBottom, Window* pDiagonal, 50*cdf0e10cSrcweir ScDocument* pD, ScAddress aPos, const String& rUser, 51*cdf0e10cSrcweir const MapMode& rMap, sal_Bool bLeftEdge, sal_Bool bForce, sal_Bool bKeyboard ) : 52*cdf0e10cSrcweir pWindow( pWin ), 53*cdf0e10cSrcweir pRightWin( pRight ), 54*cdf0e10cSrcweir pBottomWin( pBottom ), 55*cdf0e10cSrcweir pDiagWin( pDiagonal ), 56*cdf0e10cSrcweir pDoc( pD ), 57*cdf0e10cSrcweir aDocPos( aPos ), 58*cdf0e10cSrcweir aUserText( rUser ), 59*cdf0e10cSrcweir aMapMode( rMap ), 60*cdf0e10cSrcweir bLeft( bLeftEdge ), 61*cdf0e10cSrcweir bByKeyboard( bKeyboard ), 62*cdf0e10cSrcweir pModel( NULL ), 63*cdf0e10cSrcweir pObject( NULL ), 64*cdf0e10cSrcweir bVisible( sal_False ) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir Size aSizePixel = pWindow->GetOutputSizePixel(); 67*cdf0e10cSrcweir if( pRightWin ) 68*cdf0e10cSrcweir aSizePixel.Width() += pRightWin->GetOutputSizePixel().Width(); 69*cdf0e10cSrcweir if( pBottomWin ) 70*cdf0e10cSrcweir aSizePixel.Height() += pBottomWin->GetOutputSizePixel().Height(); 71*cdf0e10cSrcweir Rectangle aVisPixel( Point( 0, 0 ), aSizePixel ); 72*cdf0e10cSrcweir aVisRect = pWindow->PixelToLogic( aVisPixel, aMapMode ); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir aTimer.SetTimeoutHdl( LINK( this, ScNoteMarker, TimeHdl ) ); 75*cdf0e10cSrcweir aTimer.SetTimeout( bForce ? SC_NOTEMARK_SHORT : SC_NOTEMARK_TIME ); 76*cdf0e10cSrcweir aTimer.Start(); 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir ScNoteMarker::~ScNoteMarker() 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir InvalidateWin(); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir delete pModel; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir IMPL_LINK( ScNoteMarker, TimeHdl, Timer*, EMPTYARG ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir if (!bVisible) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir SvtPathOptions aPathOpt; 91*cdf0e10cSrcweir String aPath = aPathOpt.GetPalettePath(); 92*cdf0e10cSrcweir pModel = new SdrModel(aPath); 93*cdf0e10cSrcweir pModel->SetScaleUnit(MAP_100TH_MM); 94*cdf0e10cSrcweir SfxItemPool& rPool = pModel->GetItemPool(); 95*cdf0e10cSrcweir rPool.SetDefaultMetric(SFX_MAPUNIT_100TH_MM); 96*cdf0e10cSrcweir rPool.FreezeIdRanges(); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir OutputDevice* pPrinter = pDoc->GetRefDevice(); 99*cdf0e10cSrcweir if (pPrinter) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir // Am Outliner des Draw-Model ist auch der Drucker als RefDevice gesetzt, 102*cdf0e10cSrcweir // und es soll einheitlich aussehen. 103*cdf0e10cSrcweir Outliner& rOutliner = pModel->GetDrawOutliner(); 104*cdf0e10cSrcweir rOutliner.SetRefDevice(pPrinter); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir if( SdrPage* pPage = pModel->AllocPage( sal_False ) ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir pObject = ScNoteUtil::CreateTempCaption( *pDoc, aDocPos, *pPage, aUserText, aVisRect, bLeft ); 110*cdf0e10cSrcweir if( pObject ) 111*cdf0e10cSrcweir aRect = pObject->GetCurrentBoundRect(); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir // #39351# Page einfuegen damit das Model sie kennt und auch deleted 114*cdf0e10cSrcweir pModel->InsertPage( pPage ); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir bVisible = sal_True; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir Draw(); 121*cdf0e10cSrcweir return 0; 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir void lcl_DrawWin( SdrObject* pObject, Window* pWindow, const MapMode& rMap ) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir MapMode aOld = pWindow->GetMapMode(); 127*cdf0e10cSrcweir pWindow->SetMapMode( rMap ); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir sal_uLong nOldDrawMode = pWindow->GetDrawMode(); 130*cdf0e10cSrcweir if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir pWindow->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | 133*cdf0e10cSrcweir DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT ); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir pObject->SingleObjectPainter( *pWindow ); // #110094#-17 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir pWindow->SetDrawMode( nOldDrawMode ); 139*cdf0e10cSrcweir pWindow->SetMapMode( aOld ); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir MapMode lcl_MoveMapMode( const MapMode& rMap, const Size& rMove ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir MapMode aNew = rMap; 145*cdf0e10cSrcweir Point aOrigin = aNew.GetOrigin(); 146*cdf0e10cSrcweir aOrigin.X() -= rMove.Width(); 147*cdf0e10cSrcweir aOrigin.Y() -= rMove.Height(); 148*cdf0e10cSrcweir aNew.SetOrigin(aOrigin); 149*cdf0e10cSrcweir return aNew; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir void ScNoteMarker::Draw() 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir if ( pObject && bVisible ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir lcl_DrawWin( pObject, pWindow, aMapMode ); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir if ( pRightWin || pBottomWin ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode ); 161*cdf0e10cSrcweir if ( pRightWin ) 162*cdf0e10cSrcweir lcl_DrawWin( pObject, pRightWin, 163*cdf0e10cSrcweir lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ) ); 164*cdf0e10cSrcweir if ( pBottomWin ) 165*cdf0e10cSrcweir lcl_DrawWin( pObject, pBottomWin, 166*cdf0e10cSrcweir lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ) ); 167*cdf0e10cSrcweir if ( pDiagWin ) 168*cdf0e10cSrcweir lcl_DrawWin( pObject, pDiagWin, lcl_MoveMapMode( aMapMode, aWinSize ) ); 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir void ScNoteMarker::InvalidateWin() 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if (bVisible) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir pWindow->Invalidate( pWindow->LogicToLogic(aRect, aMapMode, pWindow->GetMapMode()) ); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir if ( pRightWin || pBottomWin ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode ); 182*cdf0e10cSrcweir if ( pRightWin ) 183*cdf0e10cSrcweir pRightWin->Invalidate( pRightWin->LogicToLogic(aRect, 184*cdf0e10cSrcweir lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ), 185*cdf0e10cSrcweir pRightWin->GetMapMode()) ); 186*cdf0e10cSrcweir if ( pBottomWin ) 187*cdf0e10cSrcweir pBottomWin->Invalidate( pBottomWin->LogicToLogic(aRect, 188*cdf0e10cSrcweir lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ), 189*cdf0e10cSrcweir pBottomWin->GetMapMode()) ); 190*cdf0e10cSrcweir if ( pDiagWin ) 191*cdf0e10cSrcweir pDiagWin->Invalidate( pDiagWin->LogicToLogic(aRect, 192*cdf0e10cSrcweir lcl_MoveMapMode( aMapMode, aWinSize ), 193*cdf0e10cSrcweir pDiagWin->GetMapMode()) ); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir 201