LCOV - code coverage report
Current view: top level - sw/source/core/uibase/docvw - OverlayRanges.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 67 0.0 %
Date: 2014-04-14 Functions: 0 9 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             : #include <OverlayRanges.hxx>
      21             : #include <view.hxx>
      22             : #include <svx/sdrpaintwindow.hxx>
      23             : #include <svx/svdview.hxx>
      24             : #include <svx/sdr/overlay/overlaymanager.hxx>
      25             : #include <basegfx/polygon/b2dpolygon.hxx>
      26             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      27             : #include <basegfx/polygon/b2dpolygontools.hxx>
      28             : #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
      29             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      30             : #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
      31             : 
      32             : namespace
      33             : {
      34             :     // combine ranges geometrically to a single, ORed polygon
      35           0 :     basegfx::B2DPolyPolygon impCombineRangesToPolyPolygon(const std::vector< basegfx::B2DRange >& rRanges)
      36             :     {
      37           0 :         const sal_uInt32 nCount(rRanges.size());
      38           0 :         basegfx::B2DPolyPolygon aRetval;
      39             : 
      40           0 :         for(sal_uInt32 a(0); a < nCount; a++)
      41             :         {
      42           0 :             const basegfx::B2DPolygon aDiscretePolygon(basegfx::tools::createPolygonFromRect(rRanges[a]));
      43             : 
      44           0 :             if(0 == a)
      45             :             {
      46           0 :                 aRetval.append(aDiscretePolygon);
      47             :             }
      48             :             else
      49             :             {
      50           0 :                 aRetval = basegfx::tools::solvePolygonOperationOr(aRetval, basegfx::B2DPolyPolygon(aDiscretePolygon));
      51             :             }
      52           0 :         }
      53             : 
      54           0 :         return aRetval;
      55             :     }
      56             : }
      57             : 
      58             : namespace sw
      59             : {
      60             :     namespace overlay
      61             :     {
      62           0 :         drawinglayer::primitive2d::Primitive2DSequence OverlayRanges::createOverlayObjectPrimitive2DSequence()
      63             :         {
      64           0 :             const sal_uInt32 nCount(getRanges().size());
      65           0 :             drawinglayer::primitive2d::Primitive2DSequence aRetval;
      66           0 :             aRetval.realloc(nCount);
      67           0 :             for ( sal_uInt32 a = 0; a < nCount; ++a )
      68             :             {
      69           0 :                 const basegfx::BColor aRGBColor(getBaseColor().getBColor());
      70           0 :                 const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(maRanges[a]));
      71           0 :                 aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
      72             :                     new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
      73             :                     basegfx::B2DPolyPolygon(aPolygon),
      74           0 :                     aRGBColor));
      75           0 :             }
      76             :             // embed all rectangles in transparent paint
      77           0 :             const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
      78           0 :             const sal_uInt16 nTransparence( aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() );
      79           0 :             const double fTransparence( nTransparence / 100.0 );
      80             :             const drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparence(
      81             :                 new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
      82             :                 aRetval,
      83           0 :                 fTransparence));
      84             : 
      85           0 :             if ( mbShowSolidBorder )
      86             :             {
      87           0 :                 const basegfx::BColor aRGBColor(getBaseColor().getBColor());
      88           0 :                 const basegfx::B2DPolyPolygon aPolyPolygon(impCombineRangesToPolyPolygon(getRanges()));
      89             :                 const drawinglayer::primitive2d::Primitive2DReference aOutline(
      90             :                     new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D(
      91             :                     aPolyPolygon,
      92           0 :                     aRGBColor));
      93             : 
      94           0 :                 aRetval.realloc(2);
      95           0 :                 aRetval[0] = aUnifiedTransparence;
      96           0 :                 aRetval[1] = aOutline;
      97             :             }
      98             :             else
      99             :             {
     100           0 :                 aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparence, 1);
     101             :             }
     102             : 
     103           0 :             return aRetval;
     104             :         }
     105             : 
     106           0 :         /*static*/ OverlayRanges* OverlayRanges::CreateOverlayRange(
     107             :             SwView& rDocView,
     108             :             const Color& rColor,
     109             :             const std::vector< basegfx::B2DRange >& rRanges,
     110             :             const bool bShowSolidBorder )
     111             :         {
     112           0 :             OverlayRanges* pOverlayRanges = NULL;
     113             : 
     114           0 :             SdrView* pView = rDocView.GetDrawView();
     115           0 :             if ( pView != NULL )
     116             :             {
     117           0 :                 SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
     118           0 :                 rtl::Reference<sdr::overlay::OverlayManager> xTargetOverlay = pCandidate->GetOverlayManager();
     119             : 
     120           0 :                 if ( xTargetOverlay.is() )
     121             :                 {
     122           0 :                     pOverlayRanges = new sw::overlay::OverlayRanges( rColor, rRanges, bShowSolidBorder );
     123           0 :                     xTargetOverlay->add( *pOverlayRanges );
     124           0 :                 }
     125             :             }
     126             : 
     127           0 :             return pOverlayRanges;
     128             :         }
     129             : 
     130           0 :         OverlayRanges::OverlayRanges(
     131             :             const Color& rColor,
     132             :             const std::vector< basegfx::B2DRange >& rRanges,
     133             :             const bool bShowSolidBorder )
     134             :             : sdr::overlay::OverlayObject( rColor )
     135             :             , maRanges( rRanges )
     136           0 :             , mbShowSolidBorder( bShowSolidBorder )
     137             :         {
     138             :             // no AA for highlight overlays
     139           0 :             allowAntiAliase(false);
     140           0 :         }
     141             : 
     142           0 :         OverlayRanges::~OverlayRanges()
     143             :         {
     144           0 :             if( getOverlayManager() )
     145             :             {
     146           0 :                 getOverlayManager()->remove(*this);
     147             :             }
     148           0 :         }
     149             : 
     150           0 :         void OverlayRanges::setRanges(const std::vector< basegfx::B2DRange >& rNew)
     151             :         {
     152           0 :             if(rNew != maRanges)
     153             :             {
     154           0 :                 maRanges = rNew;
     155           0 :                 objectChange();
     156             :             }
     157           0 :         }
     158             : 
     159           0 :         void OverlayRanges::ShowSolidBorder()
     160             :         {
     161           0 :             if ( !mbShowSolidBorder )
     162             :             {
     163           0 :                 mbShowSolidBorder = true;
     164           0 :                 objectChange();
     165             :             }
     166           0 :         }
     167             : 
     168           0 :         void OverlayRanges::HideSolidBorder()
     169             :         {
     170           0 :             if ( mbShowSolidBorder )
     171             :             {
     172           0 :                 mbShowSolidBorder = false;
     173           0 :                 objectChange();
     174             :             }
     175           0 :         }
     176             : 
     177             :     } // end of namespace overlay
     178             : } // end of namespace sdr
     179             : 
     180             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10