LCOV - code coverage report
Current view: top level - sd/source/ui/toolpanel/controls - PreviewValueSet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 84 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 56 0.0 %

           Branch data     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 "PreviewValueSet.hxx"
      22                 :            : #include <vcl/image.hxx>
      23                 :            : #include "taskpane/TaskPaneTreeNode.hxx"
      24                 :            : 
      25                 :            : namespace sd { namespace toolpanel { namespace controls {
      26                 :            : 
      27                 :            : 
      28                 :          0 : PreviewValueSet::PreviewValueSet (TreeNode* pParent)
      29                 :          0 :     : ValueSet (pParent->GetWindow(), WB_TABSTOP),
      30                 :            :       mpParent(pParent),
      31                 :            :       maPreviewSize(10,10),
      32                 :            :       mnBorderWidth(3),
      33                 :            :       mnBorderHeight(3),
      34 [ #  # ][ #  # ]:          0 :       mnMaxColumnCount(-1)
      35                 :            : {
      36                 :            :     SetStyle (
      37         [ #  # ]:          0 :         GetStyle()
      38                 :            :         & ~(WB_ITEMBORDER)// | WB_MENUSTYLEVALUESET)
      39                 :            :         //        | WB_FLATVALUESET);
      40         [ #  # ]:          0 :         );
      41                 :            : 
      42         [ #  # ]:          0 :     SetColCount(2);
      43                 :            :     //  SetLineCount(1);
      44         [ #  # ]:          0 :     SetExtraSpacing (2);
      45                 :          0 : }
      46                 :            : 
      47                 :            : 
      48                 :            : 
      49                 :            : 
      50                 :          0 : PreviewValueSet::~PreviewValueSet (void)
      51                 :            : {
      52         [ #  # ]:          0 : }
      53                 :            : 
      54                 :            : 
      55                 :            : 
      56                 :            : 
      57                 :          0 : void PreviewValueSet::SetPreviewSize (const Size& rSize)
      58                 :            : {
      59                 :          0 :     maPreviewSize = rSize;
      60                 :          0 : }
      61                 :            : 
      62                 :            : 
      63                 :            : 
      64                 :            : 
      65                 :          0 : void PreviewValueSet::SetRightMouseClickHandler (const Link& rLink)
      66                 :            : {
      67                 :          0 :     maRightMouseClickHandler = rLink;
      68                 :          0 : }
      69                 :            : 
      70                 :            : 
      71                 :            : 
      72                 :            : 
      73                 :          0 : void PreviewValueSet::MouseButtonDown (const MouseEvent& rEvent)
      74                 :            : {
      75         [ #  # ]:          0 :     if (rEvent.IsRight())
      76                 :            :         maRightMouseClickHandler.Call(reinterpret_cast<void*>(
      77                 :          0 :             &const_cast<MouseEvent&>(rEvent)));
      78                 :            :     else
      79                 :          0 :         ValueSet::MouseButtonDown (rEvent);
      80                 :            : 
      81                 :          0 : }
      82                 :            : 
      83                 :            : 
      84                 :            : 
      85                 :            : 
      86                 :          0 : void PreviewValueSet::Paint (const Rectangle& rRect)
      87                 :            : {
      88         [ #  # ]:          0 :     SetBackground (GetSettings().GetStyleSettings().GetWindowColor());
      89                 :            : 
      90                 :          0 :     ValueSet::Paint (rRect);
      91                 :            : 
      92         [ #  # ]:          0 :     SetBackground (Wallpaper());
      93                 :          0 : }
      94                 :            : 
      95                 :            : 
      96                 :            : 
      97                 :            : 
      98                 :          0 : void PreviewValueSet::Resize (void)
      99                 :            : {
     100         [ #  # ]:          0 :     ValueSet::Resize ();
     101                 :            : 
     102                 :          0 :     Size aWindowSize (GetOutputSizePixel());
     103 [ #  # ][ #  # ]:          0 :     if (aWindowSize.Width()>0 && aWindowSize.Height()>0)
                 [ #  # ]
     104                 :            :     {
     105         [ #  # ]:          0 :         Rearrange();
     106                 :            :     }
     107                 :          0 : }
     108                 :            : 
     109                 :            : 
     110                 :            : 
     111                 :            : 
     112                 :          0 : void PreviewValueSet::Command (const CommandEvent& rEvent)
     113                 :            : {
     114         [ #  # ]:          0 :     switch (rEvent.GetCommand())
     115                 :            :     {
     116                 :            :         case COMMAND_CONTEXTMENU:
     117                 :            :         {
     118                 :          0 :             CommandEvent aNonConstEventCopy (rEvent);
     119         [ #  # ]:          0 :             maContextMenuCallback.Call(&aNonConstEventCopy);
     120                 :            :         }
     121                 :          0 :         break;
     122                 :            : 
     123                 :            :         default:
     124                 :          0 :             ValueSet::Command(rEvent);
     125                 :          0 :             break;
     126                 :            :     }
     127                 :          0 : }
     128                 :            : 
     129                 :            : 
     130                 :            : 
     131                 :            : 
     132                 :          0 : void PreviewValueSet::Rearrange (bool bForceRequestResize)
     133                 :            : {
     134                 :          0 :     sal_uInt16 nOldColumnCount (GetColCount());
     135                 :          0 :     sal_uInt16 nOldRowCount (GetLineCount());
     136                 :            : 
     137                 :            :     sal_uInt16 nNewColumnCount (CalculateColumnCount (
     138                 :          0 :         GetOutputSizePixel().Width()));
     139                 :          0 :     sal_uInt16 nNewRowCount (CalculateRowCount (nNewColumnCount));
     140                 :            : 
     141                 :          0 :     SetColCount(nNewColumnCount);
     142                 :          0 :     SetLineCount(nNewRowCount);
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 :     if (bForceRequestResize
                 [ #  # ]
     145                 :            :         || nOldColumnCount != nNewColumnCount
     146                 :            :         || nOldRowCount != nNewRowCount)
     147                 :          0 :         mpParent->RequestResize();
     148                 :          0 : }
     149                 :            : 
     150                 :            : 
     151                 :            : 
     152                 :            : 
     153                 :          0 : void PreviewValueSet::SetContextMenuCallback (const Link& rLink)
     154                 :            : {
     155                 :          0 :     maContextMenuCallback = rLink;
     156                 :          0 : }
     157                 :            : 
     158                 :            : 
     159                 :            : 
     160                 :            : 
     161                 :          0 : sal_uInt16 PreviewValueSet::CalculateColumnCount (int nWidth) const
     162                 :            : {
     163                 :          0 :     int nColumnCount = 0;
     164         [ #  # ]:          0 :     if (nWidth > 0)
     165                 :            :     {
     166                 :          0 :         nColumnCount = nWidth / (maPreviewSize.Width() + 2*mnBorderWidth);
     167         [ #  # ]:          0 :         if (nColumnCount < 1)
     168                 :          0 :             nColumnCount = 1;
     169 [ #  # ][ #  # ]:          0 :         else if (mnMaxColumnCount>0 && nColumnCount>mnMaxColumnCount)
     170                 :          0 :             nColumnCount = mnMaxColumnCount;
     171                 :            :     }
     172                 :          0 :     return (sal_uInt16)nColumnCount;
     173                 :            : }
     174                 :            : 
     175                 :            : 
     176                 :            : 
     177                 :            : 
     178                 :          0 : sal_uInt16 PreviewValueSet::CalculateRowCount (sal_uInt16 nColumnCount) const
     179                 :            : {
     180                 :          0 :     int nRowCount = 0;
     181                 :          0 :     int nItemCount = GetItemCount();
     182         [ #  # ]:          0 :     if (nColumnCount > 0)
     183                 :            :     {
     184                 :          0 :         nRowCount = (nItemCount+nColumnCount-1) / nColumnCount;
     185         [ #  # ]:          0 :         if (nRowCount < 1)
     186                 :          0 :             nRowCount = 1;
     187                 :            :     }
     188                 :            : 
     189                 :          0 :     return (sal_uInt16)nRowCount;
     190                 :            : }
     191                 :            : 
     192                 :            : 
     193                 :            : 
     194                 :            : 
     195                 :          0 : sal_Int32 PreviewValueSet::GetPreferredWidth (sal_Int32 nHeight)
     196                 :            : {
     197                 :          0 :     int nPreferredWidth (maPreviewSize.Width() + 2*mnBorderWidth);
     198                 :            : 
     199                 :            :     // Get height of each row.
     200                 :          0 :     int nItemHeight (maPreviewSize.Height() + 2*mnBorderHeight);
     201                 :            : 
     202                 :            :     // Calculate the row- and column count and from the later the preferred
     203                 :            :     // width.
     204                 :          0 :     int nRowCount = nHeight / nItemHeight;
     205         [ #  # ]:          0 :     if (nRowCount > 0)
     206                 :            :     {
     207                 :          0 :         int nColumnCount = (GetItemCount()+nRowCount-1) / nRowCount;
     208         [ #  # ]:          0 :         if (nColumnCount > 0)
     209                 :          0 :             nPreferredWidth = (maPreviewSize.Width() + 2*mnBorderWidth)
     210                 :          0 :                 * nColumnCount;
     211                 :            :     }
     212                 :            : 
     213                 :          0 :     return nPreferredWidth;
     214                 :            : }
     215                 :            : 
     216                 :            : 
     217                 :            : 
     218                 :            : 
     219                 :          0 : sal_Int32 PreviewValueSet::GetPreferredHeight (sal_Int32 nWidth)
     220                 :            : {
     221                 :          0 :     int nRowCount (CalculateRowCount(CalculateColumnCount(nWidth)));
     222                 :          0 :     int nItemHeight (maPreviewSize.Height());
     223                 :            : 
     224                 :          0 :     return nRowCount * (nItemHeight + 2*mnBorderHeight);
     225                 :            : }
     226                 :            : 
     227                 :            : 
     228                 :            : 
     229                 :            : 
     230                 :            : } } } // end of namespace ::sd::toolpanel::controls
     231                 :            : 
     232                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10