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

Generated by: LCOV version 1.10