LCOV - code coverage report
Current view: top level - sc/source/ui/view - notemark.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 81 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 174 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <svx/svdoutl.hxx>
      31                 :            : #include <svx/svdmodel.hxx>
      32                 :            : #include <svx/svdpage.hxx>
      33                 :            : #include <svx/svdocapt.hxx>
      34                 :            : #include <sfx2/printer.hxx>
      35                 :            : #include <unotools/pathoptions.hxx>
      36                 :            : #include <svl/itempool.hxx>
      37                 :            : #include <vcl/svapp.hxx>
      38                 :            : 
      39                 :            : #include "notemark.hxx"
      40                 :            : #include "document.hxx"
      41                 :            : #include "postit.hxx"
      42                 :            : 
      43                 :            : #define SC_NOTEMARK_TIME    800
      44                 :            : #define SC_NOTEMARK_SHORT   70
      45                 :            : 
      46                 :            : // -----------------------------------------------------------------------
      47                 :            : 
      48                 :          0 : ScNoteMarker::ScNoteMarker( Window* pWin, Window* pRight, Window* pBottom, Window* pDiagonal,
      49                 :            :                             ScDocument* pD, ScAddress aPos, const String& rUser,
      50                 :            :                             const MapMode& rMap, sal_Bool bLeftEdge, sal_Bool bForce, sal_Bool bKeyboard ) :
      51                 :            :     pWindow( pWin ),
      52                 :            :     pRightWin( pRight ),
      53                 :            :     pBottomWin( pBottom ),
      54                 :            :     pDiagWin( pDiagonal ),
      55                 :            :     pDoc( pD ),
      56                 :            :     aDocPos( aPos ),
      57                 :            :     aUserText( rUser ),
      58                 :            :     aMapMode( rMap ),
      59                 :            :     bLeft( bLeftEdge ),
      60                 :            :     bByKeyboard( bKeyboard ),
      61                 :            :     pModel( NULL ),
      62                 :            :     pObject( NULL ),
      63 [ #  # ][ #  # ]:          0 :     bVisible( false )
         [ #  # ][ #  # ]
      64                 :            : {
      65                 :          0 :     Size aSizePixel = pWindow->GetOutputSizePixel();
      66         [ #  # ]:          0 :     if( pRightWin )
      67                 :          0 :         aSizePixel.Width() += pRightWin->GetOutputSizePixel().Width();
      68         [ #  # ]:          0 :     if( pBottomWin )
      69                 :          0 :         aSizePixel.Height() += pBottomWin->GetOutputSizePixel().Height();
      70         [ #  # ]:          0 :     Rectangle aVisPixel( Point( 0, 0 ), aSizePixel );
      71         [ #  # ]:          0 :     aVisRect = pWindow->PixelToLogic( aVisPixel, aMapMode );
      72                 :            : 
      73         [ #  # ]:          0 :     aTimer.SetTimeoutHdl( LINK( this, ScNoteMarker, TimeHdl ) );
      74 [ #  # ][ #  # ]:          0 :     aTimer.SetTimeout( bForce ? SC_NOTEMARK_SHORT : SC_NOTEMARK_TIME );
      75         [ #  # ]:          0 :     aTimer.Start();
      76                 :          0 : }
      77                 :            : 
      78 [ #  # ][ #  # ]:          0 : ScNoteMarker::~ScNoteMarker()
      79                 :            : {
      80         [ #  # ]:          0 :     InvalidateWin();
      81                 :            : 
      82 [ #  # ][ #  # ]:          0 :     delete pModel;
      83                 :          0 : }
      84                 :            : 
      85                 :          0 : IMPL_LINK_NOARG(ScNoteMarker, TimeHdl)
      86                 :            : {
      87         [ #  # ]:          0 :     if (!bVisible)
      88                 :            :     {
      89         [ #  # ]:          0 :         SvtPathOptions aPathOpt;
      90 [ #  # ][ #  # ]:          0 :         String aPath = aPathOpt.GetPalettePath();
      91 [ #  # ][ #  # ]:          0 :         pModel = new SdrModel(aPath);
      92         [ #  # ]:          0 :         pModel->SetScaleUnit(MAP_100TH_MM);
      93                 :          0 :         SfxItemPool& rPool = pModel->GetItemPool();
      94         [ #  # ]:          0 :         rPool.SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
      95         [ #  # ]:          0 :         rPool.FreezeIdRanges();
      96                 :            : 
      97         [ #  # ]:          0 :         OutputDevice* pPrinter = pDoc->GetRefDevice();
      98         [ #  # ]:          0 :         if (pPrinter)
      99                 :            :         {
     100                 :            :             //  Am Outliner des Draw-Model ist auch der Drucker als RefDevice gesetzt,
     101                 :            :             //  und es soll einheitlich aussehen.
     102         [ #  # ]:          0 :             Outliner& rOutliner = pModel->GetDrawOutliner();
     103         [ #  # ]:          0 :             rOutliner.SetRefDevice(pPrinter);
     104                 :            :         }
     105                 :            : 
     106 [ #  # ][ #  # ]:          0 :         if( SdrPage* pPage = pModel->AllocPage( false ) )
     107                 :            :         {
     108 [ #  # ][ #  # ]:          0 :             pObject = ScNoteUtil::CreateTempCaption( *pDoc, aDocPos, *pPage, aUserText, aVisRect, bLeft );
     109         [ #  # ]:          0 :             if( pObject )
     110         [ #  # ]:          0 :                 aRect = pObject->GetCurrentBoundRect();
     111                 :            : 
     112                 :            :             // Page einfuegen damit das Model sie kennt und auch deleted
     113         [ #  # ]:          0 :             pModel->InsertPage( pPage );
     114                 :            : 
     115                 :            :         }
     116 [ #  # ][ #  # ]:          0 :         bVisible = true;
     117                 :            :     }
     118                 :            : 
     119                 :          0 :     Draw();
     120                 :          0 :     return 0;
     121                 :            : }
     122                 :            : 
     123                 :          0 : void lcl_DrawWin( SdrObject* pObject, Window* pWindow, const MapMode& rMap )
     124                 :            : {
     125         [ #  # ]:          0 :     MapMode aOld = pWindow->GetMapMode();
     126         [ #  # ]:          0 :     pWindow->SetMapMode( rMap );
     127                 :            : 
     128                 :          0 :     sal_uLong nOldDrawMode = pWindow->GetDrawMode();
     129 [ #  # ][ #  # ]:          0 :     if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
     130                 :            :     {
     131                 :            :         pWindow->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
     132         [ #  # ]:          0 :                             DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
     133                 :            :     }
     134                 :            : 
     135         [ #  # ]:          0 :     pObject->SingleObjectPainter( *pWindow ); // #110094#-17
     136                 :            : 
     137         [ #  # ]:          0 :     pWindow->SetDrawMode( nOldDrawMode );
     138 [ #  # ][ #  # ]:          0 :     pWindow->SetMapMode( aOld );
     139                 :          0 : }
     140                 :            : 
     141                 :          0 : MapMode lcl_MoveMapMode( const MapMode& rMap, const Size& rMove )
     142                 :            : {
     143         [ #  # ]:          0 :     MapMode aNew = rMap;
     144                 :          0 :     Point aOrigin = aNew.GetOrigin();
     145                 :          0 :     aOrigin.X() -= rMove.Width();
     146                 :          0 :     aOrigin.Y() -= rMove.Height();
     147         [ #  # ]:          0 :     aNew.SetOrigin(aOrigin);
     148                 :          0 :     return aNew;
     149                 :            : }
     150                 :            : 
     151                 :          0 : void ScNoteMarker::Draw()
     152                 :            : {
     153 [ #  # ][ #  # ]:          0 :     if ( pObject && bVisible )
     154                 :            :     {
     155                 :          0 :         lcl_DrawWin( pObject, pWindow, aMapMode );
     156                 :            : 
     157 [ #  # ][ #  # ]:          0 :         if ( pRightWin || pBottomWin )
     158                 :            :         {
     159         [ #  # ]:          0 :             Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode );
     160         [ #  # ]:          0 :             if ( pRightWin )
     161                 :            :                 lcl_DrawWin( pObject, pRightWin,
     162 [ #  # ][ #  # ]:          0 :                                 lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ) );
                 [ #  # ]
     163         [ #  # ]:          0 :             if ( pBottomWin )
     164                 :            :                 lcl_DrawWin( pObject, pBottomWin,
     165 [ #  # ][ #  # ]:          0 :                                 lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ) );
                 [ #  # ]
     166         [ #  # ]:          0 :             if ( pDiagWin )
     167 [ #  # ][ #  # ]:          0 :                 lcl_DrawWin( pObject, pDiagWin, lcl_MoveMapMode( aMapMode, aWinSize ) );
                 [ #  # ]
     168                 :            :         }
     169                 :            :     }
     170                 :          0 : }
     171                 :            : 
     172                 :          0 : void ScNoteMarker::InvalidateWin()
     173                 :            : {
     174         [ #  # ]:          0 :     if (bVisible)
     175                 :            :     {
     176         [ #  # ]:          0 :         pWindow->Invalidate( pWindow->LogicToLogic(aRect, aMapMode, pWindow->GetMapMode()) );
     177                 :            : 
     178 [ #  # ][ #  # ]:          0 :         if ( pRightWin || pBottomWin )
     179                 :            :         {
     180         [ #  # ]:          0 :             Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode );
     181         [ #  # ]:          0 :             if ( pRightWin )
     182                 :            :                 pRightWin->Invalidate( pRightWin->LogicToLogic(aRect,
     183                 :          0 :                                         lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ),
     184 [ #  # ][ #  # ]:          0 :                                         pRightWin->GetMapMode()) );
         [ #  # ][ #  # ]
     185         [ #  # ]:          0 :             if ( pBottomWin )
     186                 :            :                 pBottomWin->Invalidate( pBottomWin->LogicToLogic(aRect,
     187                 :          0 :                                         lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ),
     188 [ #  # ][ #  # ]:          0 :                                         pBottomWin->GetMapMode()) );
         [ #  # ][ #  # ]
     189         [ #  # ]:          0 :             if ( pDiagWin )
     190                 :            :                 pDiagWin->Invalidate( pDiagWin->LogicToLogic(aRect,
     191                 :            :                                         lcl_MoveMapMode( aMapMode, aWinSize ),
     192 [ #  # ][ #  # ]:          0 :                                         pDiagWin->GetMapMode()) );
         [ #  # ][ #  # ]
     193                 :            :         }
     194                 :            :     }
     195                 :          0 : }
     196                 :            : 
     197                 :            : 
     198                 :            : 
     199                 :            : 
     200                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10