LCOV - code coverage report
Current view: top level - sc/source/ui/view - notemark.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 82 1.2 %
Date: 2014-11-03 Functions: 2 10 20.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svx/svdoutl.hxx>
      21             : #include <svx/svdmodel.hxx>
      22             : #include <svx/svdpage.hxx>
      23             : #include <svx/svdocapt.hxx>
      24             : #include <sfx2/printer.hxx>
      25             : #include <unotools/pathoptions.hxx>
      26             : #include <svl/itempool.hxx>
      27             : #include <vcl/svapp.hxx>
      28             : #include <vcl/settings.hxx>
      29             : 
      30             : #include "notemark.hxx"
      31             : #include "document.hxx"
      32             : #include "postit.hxx"
      33             : 
      34             : #define SC_NOTEMARK_TIME    800
      35             : #define SC_NOTEMARK_SHORT   70
      36             : 
      37           0 : ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window* pBottom, vcl::Window* pDiagonal,
      38             :                             ScDocument* pD, ScAddress aPos, const OUString& rUser,
      39             :                             const MapMode& rMap, bool bLeftEdge, bool bForce, bool bKeyboard ) :
      40             :     pWindow( pWin ),
      41             :     pRightWin( pRight ),
      42             :     pBottomWin( pBottom ),
      43             :     pDiagWin( pDiagonal ),
      44             :     pDoc( pD ),
      45             :     aDocPos( aPos ),
      46             :     aUserText( rUser ),
      47             :     aMapMode( rMap ),
      48             :     bLeft( bLeftEdge ),
      49             :     bByKeyboard( bKeyboard ),
      50             :     pModel( NULL ),
      51             :     pObject( NULL ),
      52           0 :     bVisible( false )
      53             : {
      54           0 :     Size aSizePixel = pWindow->GetOutputSizePixel();
      55           0 :     if( pRightWin )
      56           0 :         aSizePixel.Width() += pRightWin->GetOutputSizePixel().Width();
      57           0 :     if( pBottomWin )
      58           0 :         aSizePixel.Height() += pBottomWin->GetOutputSizePixel().Height();
      59           0 :     Rectangle aVisPixel( Point( 0, 0 ), aSizePixel );
      60           0 :     aVisRect = pWindow->PixelToLogic( aVisPixel, aMapMode );
      61             : 
      62           0 :     aTimer.SetTimeoutHdl( LINK( this, ScNoteMarker, TimeHdl ) );
      63           0 :     aTimer.SetTimeout( bForce ? SC_NOTEMARK_SHORT : SC_NOTEMARK_TIME );
      64           0 :     aTimer.Start();
      65           0 : }
      66             : 
      67           0 : ScNoteMarker::~ScNoteMarker()
      68             : {
      69           0 :     InvalidateWin();
      70             : 
      71           0 :     delete pModel;
      72           0 : }
      73             : 
      74           0 : IMPL_LINK_NOARG(ScNoteMarker, TimeHdl)
      75             : {
      76           0 :     if (!bVisible)
      77             :     {
      78           0 :         SvtPathOptions aPathOpt;
      79           0 :         OUString aPath = aPathOpt.GetPalettePath();
      80           0 :         pModel = new SdrModel(aPath, NULL, NULL, false, false);
      81           0 :         pModel->SetScaleUnit(MAP_100TH_MM);
      82           0 :         SfxItemPool& rPool = pModel->GetItemPool();
      83           0 :         rPool.SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
      84           0 :         rPool.FreezeIdRanges();
      85             : 
      86           0 :         OutputDevice* pPrinter = pDoc->GetRefDevice();
      87           0 :         if (pPrinter)
      88             :         {
      89             :             //  Am Outliner des Draw-Model ist auch der Drucker als RefDevice gesetzt,
      90             :             //  und es soll einheitlich aussehen.
      91           0 :             Outliner& rOutliner = pModel->GetDrawOutliner();
      92           0 :             rOutliner.SetRefDevice(pPrinter);
      93             :         }
      94             : 
      95           0 :         if( SdrPage* pPage = pModel->AllocPage( false ) )
      96             :         {
      97           0 :             pObject = ScNoteUtil::CreateTempCaption( *pDoc, aDocPos, *pPage, aUserText, aVisRect, bLeft );
      98           0 :             if( pObject )
      99             :             {
     100           0 :                 pObject->SetGridOffset( aGridOff );
     101           0 :                 aRect = pObject->GetCurrentBoundRect();
     102             :             }
     103             : 
     104             :             // Page einfuegen damit das Model sie kennt und auch deleted
     105           0 :             pModel->InsertPage( pPage );
     106             : 
     107             :         }
     108           0 :         bVisible = true;
     109             :     }
     110             : 
     111           0 :     Draw();
     112           0 :     return 0;
     113             : }
     114             : 
     115           0 : static void lcl_DrawWin( SdrObject* pObject, vcl::Window* pWindow, const MapMode& rMap )
     116             : {
     117           0 :     MapMode aOld = pWindow->GetMapMode();
     118           0 :     pWindow->SetMapMode( rMap );
     119             : 
     120           0 :     sal_uLong nOldDrawMode = pWindow->GetDrawMode();
     121           0 :     if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
     122             :     {
     123             :         pWindow->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
     124           0 :                             DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
     125             :     }
     126             : 
     127           0 :     pObject->SingleObjectPainter( *pWindow ); // #110094#-17
     128             : 
     129           0 :     pWindow->SetDrawMode( nOldDrawMode );
     130           0 :     pWindow->SetMapMode( aOld );
     131           0 : }
     132             : 
     133           0 : static MapMode lcl_MoveMapMode( const MapMode& rMap, const Size& rMove )
     134             : {
     135           0 :     MapMode aNew = rMap;
     136           0 :     Point aOrigin = aNew.GetOrigin();
     137           0 :     aOrigin.X() -= rMove.Width();
     138           0 :     aOrigin.Y() -= rMove.Height();
     139           0 :     aNew.SetOrigin(aOrigin);
     140           0 :     return aNew;
     141             : }
     142             : 
     143           0 : void ScNoteMarker::Draw()
     144             : {
     145           0 :     if ( pObject && bVisible )
     146             :     {
     147           0 :         lcl_DrawWin( pObject, pWindow, aMapMode );
     148             : 
     149           0 :         if ( pRightWin || pBottomWin )
     150             :         {
     151           0 :             Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode );
     152           0 :             if ( pRightWin )
     153             :                 lcl_DrawWin( pObject, pRightWin,
     154           0 :                                 lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ) );
     155           0 :             if ( pBottomWin )
     156             :                 lcl_DrawWin( pObject, pBottomWin,
     157           0 :                                 lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ) );
     158           0 :             if ( pDiagWin )
     159           0 :                 lcl_DrawWin( pObject, pDiagWin, lcl_MoveMapMode( aMapMode, aWinSize ) );
     160             :         }
     161             :     }
     162           0 : }
     163             : 
     164           0 : void ScNoteMarker::InvalidateWin()
     165             : {
     166           0 :     if (bVisible)
     167             :     {
     168           0 :         pWindow->Invalidate( OutputDevice::LogicToLogic(aRect, aMapMode, pWindow->GetMapMode()) );
     169             : 
     170           0 :         if ( pRightWin || pBottomWin )
     171             :         {
     172           0 :             Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode );
     173           0 :             if ( pRightWin )
     174             :                 pRightWin->Invalidate( OutputDevice::LogicToLogic(aRect,
     175           0 :                                         lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ),
     176           0 :                                         pRightWin->GetMapMode()) );
     177           0 :             if ( pBottomWin )
     178             :                 pBottomWin->Invalidate( OutputDevice::LogicToLogic(aRect,
     179           0 :                                         lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ),
     180           0 :                                         pBottomWin->GetMapMode()) );
     181           0 :             if ( pDiagWin )
     182             :                 pDiagWin->Invalidate( OutputDevice::LogicToLogic(aRect,
     183             :                                         lcl_MoveMapMode( aMapMode, aWinSize ),
     184           0 :                                         pDiagWin->GetMapMode()) );
     185             :         }
     186             :     }
     187         228 : }
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10