LCOV - code coverage report
Current view: top level - sfx2/source/control - templatelocalviewitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 202 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Copyright 2012 LibreOffice contributors.
       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                 :            : 
      10                 :            : #include <sfx2/templatelocalviewitem.hxx>
      11                 :            : 
      12                 :            : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      13                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      14                 :            : #include <drawinglayer/attribute/fillbitmapattribute.hxx>
      15                 :            : #include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
      16                 :            : #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
      17                 :            : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      18                 :            : #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
      19                 :            : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
      20                 :            : #include <drawinglayer/processor2d/baseprocessor2d.hxx>
      21                 :            : #include <sfx2/templateviewitem.hxx>
      22                 :            : #include <vcl/button.hxx>
      23                 :            : 
      24                 :            : using namespace basegfx;
      25                 :            : using namespace basegfx::tools;
      26                 :            : using namespace drawinglayer::attribute;
      27                 :            : using namespace drawinglayer::primitive2d;
      28                 :            : 
      29                 :          0 : TemplateLocalViewItem::TemplateLocalViewItem (ThumbnailView &rView, Window *pParent)
      30 [ #  # ][ #  # ]:          0 :     : ThumbnailViewItem(rView,pParent)
      31                 :            : {
      32                 :          0 : }
      33                 :            : 
      34         [ #  # ]:          0 : TemplateLocalViewItem::~TemplateLocalViewItem ()
      35                 :            : {
      36         [ #  # ]:          0 : }
      37                 :            : 
      38                 :          0 : void TemplateLocalViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
      39                 :            :                                     const ThumbnailItemAttributes *pAttrs)
      40                 :            : {
      41                 :          0 :     int nCount = 0;
      42                 :          0 :     int nSeqSize = 2;
      43                 :            : 
      44 [ #  # ][ #  # ]:          0 :     if (!maPreview1.IsEmpty())
      45                 :          0 :         nSeqSize += 5;
      46                 :            : 
      47 [ #  # ][ #  # ]:          0 :     if (!maPreview2.IsEmpty())
      48                 :          0 :         nSeqSize += 5;
      49                 :            : 
      50                 :          0 :     BColor aFillColor = pAttrs->aFillColor;
      51         [ #  # ]:          0 :     Primitive2DSequence aSeq(nSeqSize);
      52                 :            : 
      53                 :            :     // Draw background
      54 [ #  # ][ #  # ]:          0 :     if ( mbSelected || mbHover )
      55         [ #  # ]:          0 :         aFillColor = pAttrs->aHighlightColor;
      56                 :            : 
      57         [ #  # ]:          0 :     aSeq[nCount++] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
      58                 :            :                                                B2DPolyPolygon(Polygon(maDrawArea,5,5).getB2DPolygon()),
      59 [ #  # ][ #  # ]:          0 :                                                aFillColor));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      60                 :            : 
      61                 :            :     // Draw thumbnail
      62                 :          0 :     Point aPos = maPrev1Pos;
      63                 :          0 :     Size aImageSize = maPreview1.GetSizePixel();
      64                 :            : 
      65                 :          0 :     float fScaleX = 1.0f;
      66                 :          0 :     float fScaleY = 1.0f;
      67                 :            : 
      68 [ #  # ][ #  # ]:          0 :     if (!maPreview2.IsEmpty())
      69                 :            :     {
      70                 :          0 :         fScaleX = 0.8f;
      71                 :          0 :         fScaleY = 0.8f;
      72                 :            : 
      73         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D(
      74                 :          0 :                                             createScaleTranslateB2DHomMatrix(fScaleX,fScaleY,aPos.X(),aPos.Y()),
      75                 :            :                                             FillBitmapAttribute(maPreview2,
      76                 :            :                                                                 B2DPoint(35,20),
      77                 :          0 :                                                                 B2DVector(aImageSize.Width(),aImageSize.Height()),
      78                 :            :                                                                 false)
      79 [ #  # ][ #  # ]:          0 :                                             ));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
      80                 :            : 
      81                 :            :         // draw thumbnail borders
      82                 :          0 :         float fWidth = aImageSize.Width()*fScaleX;
      83                 :          0 :         float fHeight = aImageSize.Height()*fScaleY;
      84                 :          0 :         float fPosX = aPos.getX()+35*fScaleX;
      85                 :          0 :         float fPosY = aPos.getY()+20*fScaleY;
      86                 :            : 
      87         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY),
      88 [ #  # ][ #  # ]:          0 :                                                                B2DPoint(fPosX+fWidth,fPosY)));
         [ #  # ][ #  # ]
      89         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY),
      90 [ #  # ][ #  # ]:          0 :                                                                B2DPoint(fPosX+fWidth,fPosY+fHeight)));
         [ #  # ][ #  # ]
      91         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight),
      92 [ #  # ][ #  # ]:          0 :                                                                B2DPoint(fPosX,fPosY+fHeight)));
         [ #  # ][ #  # ]
      93         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight),
      94 [ #  # ][ #  # ]:          0 :                                                                B2DPoint(fPosX,fPosY)));
         [ #  # ][ #  # ]
      95                 :            :     }
      96                 :            : 
      97 [ #  # ][ #  # ]:          0 :     if (!maPreview1.IsEmpty())
      98                 :            :     {
      99         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D(
     100                 :          0 :                                             createScaleTranslateB2DHomMatrix(fScaleX,fScaleY,aPos.X(),aPos.Y()),
     101                 :            :                                             FillBitmapAttribute(maPreview1,
     102                 :            :                                                                 B2DPoint(0,0),
     103                 :          0 :                                                                 B2DVector(aImageSize.Width(),aImageSize.Height()),
     104                 :            :                                                                 false)
     105 [ #  # ][ #  # ]:          0 :                                             ));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     106                 :            : 
     107                 :            :         // draw thumbnail borders
     108                 :          0 :         float fWidth = aImageSize.Width()*fScaleX;
     109                 :          0 :         float fHeight = aImageSize.Height()*fScaleY;
     110                 :          0 :         float fPosX = aPos.getX();
     111                 :          0 :         float fPosY = aPos.getY();
     112                 :            : 
     113         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY),
     114 [ #  # ][ #  # ]:          0 :                                                                B2DPoint(fPosX+fWidth,fPosY)));
         [ #  # ][ #  # ]
     115         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY),
     116 [ #  # ][ #  # ]:          0 :                                                                B2DPoint(fPosX+fWidth,fPosY+fHeight)));
         [ #  # ][ #  # ]
     117         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight),
     118 [ #  # ][ #  # ]:          0 :                                                                B2DPoint(fPosX,fPosY+fHeight)));
         [ #  # ][ #  # ]
     119         [ #  # ]:          0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight),
     120 [ #  # ][ #  # ]:          0 :                                                                B2DPoint(fPosX,fPosY)));
         [ #  # ][ #  # ]
     121                 :            :     }
     122                 :            : 
     123                 :            :     // Draw centered text below thumbnail
     124                 :          0 :     aPos = maTextPos;
     125                 :            : 
     126                 :            :     // Create the text primitive
     127                 :            :     basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
     128                 :            :                 pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(),
     129         [ #  # ]:          0 :                 double( aPos.X() ), double( aPos.Y() ) ) );
     130                 :            : 
     131         [ #  # ]:          0 :     aSeq[nCount++] = Primitive2DReference(
     132                 :            :                 new TextSimplePortionPrimitive2D(aTextMatrix,
     133                 :          0 :                                                  maTitle,0,maTitle.getLength(),
     134                 :            :                                                  std::vector< double >( ),
     135                 :            :                                                  pAttrs->aFontAttr,
     136                 :            :                                                  com::sun::star::lang::Locale(),
     137   [ #  #  #  # ]:          0 :                                                  Color(COL_BLACK).getBColor() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     138                 :            : 
     139         [ #  # ]:          0 :     pProcessor->process(aSeq);
     140                 :            : 
     141 [ #  # ][ #  # ]:          0 :     if (mbMode || mbHover || mbSelected)
                 [ #  # ]
     142 [ #  # ][ #  # ]:          0 :         mpSelectBox->Paint(maDrawArea);
                 [ #  # ]
     143                 :          0 : }
     144                 :            : 
     145                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
     146                 :            : 
     147                 :            : 

Generated by: LCOV version 1.10