LCOV - code coverage report
Current view: top level - sfx2/source/control - templateviewitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 54 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 168 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/templateviewitem.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 <vcl/button.hxx>
      22                 :            : 
      23                 :            : #define SUBTITLE_SCALE_FACTOR 0.85
      24                 :            : 
      25                 :            : using namespace basegfx;
      26                 :            : using namespace basegfx::tools;
      27                 :            : using namespace drawinglayer::attribute;
      28                 :            : using namespace drawinglayer::primitive2d;
      29                 :            : 
      30                 :          0 : TemplateViewItem::TemplateViewItem (ThumbnailView &rView, Window *pParent)
      31                 :          0 :     : ThumbnailViewItem(rView,pParent)
      32                 :            : {
      33                 :          0 : }
      34                 :            : 
      35                 :          0 : TemplateViewItem::~TemplateViewItem ()
      36                 :            : {
      37         [ #  # ]:          0 : }
      38                 :            : 
      39                 :          0 : void TemplateViewItem::calculateItemsPosition(const long nThumbnailHeight, const long nDisplayHeight,
      40                 :            :                                               const long nPadding, sal_uInt32 nMaxTextLenght,
      41                 :            :                                               const ThumbnailItemAttributes *pAttrs)
      42                 :            : {
      43                 :          0 :     ThumbnailViewItem::calculateItemsPosition(nThumbnailHeight,nDisplayHeight,nPadding,nMaxTextLenght, pAttrs);
      44                 :            : 
      45         [ #  # ]:          0 :     if (!maSubTitle.isEmpty())
      46                 :            :     {
      47         [ #  # ]:          0 :         Size aRectSize = maDrawArea.GetSize();
      48                 :            : 
      49         [ #  # ]:          0 :         drawinglayer::primitive2d::TextLayouterDevice aTextDev;
      50                 :            :         aTextDev.setFontAttribute(pAttrs->aFontAttr,
      51                 :            :                                   pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(),
      52         [ #  # ]:          0 :                                   com::sun::star::lang::Locale() );
      53                 :            : 
      54         [ #  # ]:          0 :         long nSpace = (nDisplayHeight + nPadding - 2*aTextDev.getTextHeight()) / 3;
      55                 :            : 
      56                 :            :         // Set title position
      57         [ #  # ]:          0 :         maTextPos.setY(maDrawArea.getY() + nThumbnailHeight + nPadding + nSpace + aTextDev.getTextHeight());
      58                 :            : 
      59                 :            :         // Set subtitle position
      60         [ #  # ]:          0 :         maSubTitlePos.setY(maTextPos.getY() + nSpace + aTextDev.getTextHeight());
      61                 :          0 :         maSubTitlePos.setX(maDrawArea.Left() +
      62 [ #  # ][ #  # ]:          0 :                            (aRectSize.Width() - aTextDev.getTextWidth(maSubTitle,0,nMaxTextLenght)*SUBTITLE_SCALE_FACTOR)/2);
         [ #  # ][ #  # ]
      63                 :            :     }
      64                 :          0 : }
      65                 :            : 
      66                 :          0 : void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProcessor,
      67                 :            :                                    const ThumbnailItemAttributes *pAttrs)
      68                 :            : {
      69                 :          0 :     BColor aFillColor = pAttrs->aFillColor;
      70                 :            : 
      71         [ #  # ]:          0 :     int nCount = maSubTitle.isEmpty() ? 7 : 8;
      72         [ #  # ]:          0 :     Primitive2DSequence aSeq(nCount);
      73                 :            : 
      74                 :            :     // Draw background
      75 [ #  # ][ #  # ]:          0 :     if ( mbSelected || mbHover )
      76         [ #  # ]:          0 :         aFillColor = pAttrs->aHighlightColor;
      77                 :            : 
      78         [ #  # ]:          0 :     aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
      79                 :            :                                                B2DPolyPolygon(Polygon(maDrawArea,5,5).getB2DPolygon()),
      80 [ #  # ][ #  # ]:          0 :                                                aFillColor));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      81                 :            : 
      82                 :            :     // Draw thumbnail
      83                 :          0 :     Size aImageSize = maPreview1.GetSizePixel();
      84                 :            : 
      85         [ #  # ]:          0 :     aSeq[1] = Primitive2DReference( new FillBitmapPrimitive2D(
      86                 :          0 :                                         createTranslateB2DHomMatrix(maPrev1Pos.X(),maPrev1Pos.Y()),
      87                 :            :                                         FillBitmapAttribute(maPreview1,
      88                 :            :                                                             B2DPoint(0,0),
      89                 :          0 :                                                             B2DVector(aImageSize.Width(),aImageSize.Height()),
      90                 :            :                                                             false)
      91 [ #  # ][ #  # ]:          0 :                                         ));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
      92                 :            : 
      93                 :            :     // draw thumbnail borders
      94                 :          0 :     float fWidth = aImageSize.Width();
      95                 :          0 :     float fHeight = aImageSize.Height();
      96                 :          0 :     float fPosX = maPrev1Pos.getX();
      97                 :          0 :     float fPosY = maPrev1Pos.getY();
      98                 :            : 
      99         [ #  # ]:          0 :     aSeq[2] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY),
     100 [ #  # ][ #  # ]:          0 :                                                            B2DPoint(fPosX+fWidth,fPosY)));
         [ #  # ][ #  # ]
     101         [ #  # ]:          0 :     aSeq[3] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY),
     102 [ #  # ][ #  # ]:          0 :                                                            B2DPoint(fPosX+fWidth,fPosY+fHeight)));
         [ #  # ][ #  # ]
     103         [ #  # ]:          0 :     aSeq[4] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight),
     104 [ #  # ][ #  # ]:          0 :                                                            B2DPoint(fPosX,fPosY+fHeight)));
         [ #  # ][ #  # ]
     105         [ #  # ]:          0 :     aSeq[5] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight),
     106 [ #  # ][ #  # ]:          0 :                                                            B2DPoint(fPosX,fPosY)));
         [ #  # ][ #  # ]
     107                 :            : 
     108                 :            :     // Draw centered text below thumbnail
     109                 :            : 
     110                 :            :     // Create the text primitive
     111                 :            :     basegfx::B2DHomMatrix aTitleMatrix( createScaleTranslateB2DHomMatrix(
     112                 :            :                 pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(),
     113         [ #  # ]:          0 :                 double( maTextPos.X() ), double( maTextPos.Y() ) ) );
     114                 :            : 
     115         [ #  # ]:          0 :     aSeq[6] = Primitive2DReference(
     116                 :            :                 new TextSimplePortionPrimitive2D(aTitleMatrix,
     117                 :            :                                                  maTitle,0,pAttrs->nMaxTextLenght,
     118                 :            :                                                  std::vector< double >( ),
     119                 :            :                                                  pAttrs->aFontAttr,
     120                 :            :                                                  com::sun::star::lang::Locale(),
     121 [ #  # ][ #  # ]:          0 :                                                  Color(COL_BLACK).getBColor() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     122                 :            : 
     123         [ #  # ]:          0 :     if (!maSubTitle.isEmpty())
     124                 :            :     {
     125                 :            :         basegfx::B2DHomMatrix aSubTitleMatrix( createScaleTranslateB2DHomMatrix(
     126                 :          0 :                     pAttrs->aFontSize.getX()*SUBTITLE_SCALE_FACTOR, pAttrs->aFontSize.getY()*SUBTITLE_SCALE_FACTOR,
     127         [ #  # ]:          0 :                     double( maSubTitlePos.X() ), double( maSubTitlePos.Y() ) ) );
     128                 :            : 
     129         [ #  # ]:          0 :         aSeq[7] = Primitive2DReference(
     130                 :            :                     new TextSimplePortionPrimitive2D(aSubTitleMatrix,
     131                 :            :                                                      maSubTitle,0,pAttrs->nMaxTextLenght,
     132                 :            :                                                      std::vector< double >( ),
     133                 :            :                                                      pAttrs->aFontAttr,
     134                 :            :                                                      com::sun::star::lang::Locale(),
     135 [ #  # ][ #  # ]:          0 :                                                      Color(COL_BLACK).getBColor() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     136                 :            :     }
     137                 :            : 
     138         [ #  # ]:          0 :     pProcessor->process(aSeq);
     139                 :            : 
     140 [ #  # ][ #  # ]:          0 :     if (mbMode || mbHover || mbSelected)
                 [ #  # ]
     141 [ #  # ][ #  # ]:          0 :         mpSelectBox->Paint(maDrawArea);
                 [ #  # ]
     142                 :          0 : }
     143                 :            : 
     144                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
     145                 :            : 
     146                 :            : 

Generated by: LCOV version 1.10