LCOV - code coverage report
Current view: top level - vcl/source/window - menuitemlist.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 15 15 100.0 %
Date: 2014-11-03 Functions: 7 7 100.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 <rsc/rsc-vcl-shared-types.hxx>
      21             : #include <vcl/image.hxx>
      22             : #include <vcl/keycod.hxx>
      23             : #include <vcl/menu.hxx>
      24             : 
      25             : #include <com/sun/star/i18n/XCharacterClassification.hpp>
      26             : 
      27             : #include <vector>
      28             : 
      29             : class SalMenuItem;
      30             : 
      31             : struct MenuItemData
      32             : {
      33             :     sal_uInt16      nId;                    // SV Id
      34             :     MenuItemType    eType;                  // MenuItem-Type
      35             :     MenuItemBits    nBits;                  // MenuItem-Bits
      36             :     Menu*           pSubMenu;               // Pointer to SubMenu
      37             :     Menu*           pAutoSubMenu;           // Pointer to SubMenu from Resource
      38             :     OUString        aText;                  // Menu-Text
      39             :     OUString        aHelpText;              // Help-String
      40             :     OUString        aTipHelpText;           // TipHelp-String (eg, expanded filenames)
      41             :     OUString        aCommandStr;            // CommandString
      42             :     OUString        aHelpCommandStr;        // Help command string (to reference external help)
      43             :     OString         sIdent;
      44             :     OString         aHelpId;                // Help-Id
      45             :     sal_uLong           nUserValue;             // User value
      46             :     Image           aImage;                 // Image
      47             :     vcl::KeyCode    aAccelKey;              // Accelerator-Key
      48             :     bool            bChecked;               // Checked
      49             :     bool            bEnabled;               // Enabled
      50             :     bool            bVisible;               // Visible (note: this flag will not override MENU_FLAG_HIDEDISABLEDENTRIES when true)
      51             :     bool            bIsTemporary;           // Temporary inserted ('No selection possible')
      52             :     bool            bMirrorMode;
      53             :     long            nItemImageAngle;
      54             :     Size            aSz;                    // only temporarily valid
      55             :     OUString        aAccessibleName;        // accessible name
      56             :     OUString        aAccessibleDescription; // accessible description
      57             : 
      58             :     SalMenuItem*    pSalMenuItem;           // access to native menu
      59             : 
      60       86272 :     MenuItemData()
      61             :         : nId(0)
      62             :         , eType(MenuItemType::DONTKNOW)
      63             :         , nBits(MenuItemBits::NONE)
      64             :         , pSubMenu(NULL)
      65             :         , pAutoSubMenu(NULL)
      66             :         , nUserValue(0)
      67             :         , bChecked(false)
      68             :         , bEnabled(false)
      69             :         , bVisible(false)
      70             :         , bIsTemporary(false)
      71             :         , bMirrorMode(false)
      72             :         , nItemImageAngle(0)
      73       86272 :         , pSalMenuItem(NULL)
      74             :     {
      75       86272 :     }
      76      490660 :     MenuItemData( const OUString& rStr, const Image& rImage )
      77             :         : nId(0)
      78             :         , eType(MenuItemType::DONTKNOW)
      79             :         , nBits(MenuItemBits::NONE)
      80             :         , pSubMenu(NULL)
      81             :         , pAutoSubMenu(NULL)
      82             :         , aText(rStr)
      83             :         , nUserValue(0)
      84             :         , aImage(rImage)
      85             :         , bChecked(false)
      86             :         , bEnabled(false)
      87             :         , bVisible(false)
      88             :         , bIsTemporary(false)
      89             :         , bMirrorMode(false)
      90             :         , nItemImageAngle(0)
      91      490660 :         , pSalMenuItem(NULL)
      92             :     {
      93      490660 :     }
      94             :     ~MenuItemData();
      95         870 :     bool HasCheck() const
      96             :     {
      97         870 :         return bChecked || ( nBits & ( MenuItemBits::RADIOCHECK | MenuItemBits::CHECKABLE | MenuItemBits::AUTOCHECK ) );
      98             :     }
      99             : };
     100             : 
     101             : class MenuItemList
     102             : {
     103             : private:
     104             :     typedef ::std::vector< MenuItemData* > MenuItemDataList_impl;
     105             :     MenuItemDataList_impl maItemList;
     106             : 
     107             :     css::uno::Reference< css::i18n::XCharacterClassification > xCharClass;
     108             : 
     109             : public:
     110      139892 :                     MenuItemList() {}
     111             :                     ~MenuItemList();
     112             : 
     113             :     MenuItemData*   Insert(
     114             :                         sal_uInt16 nId,
     115             :                         MenuItemType eType,
     116             :                         MenuItemBits nBits,
     117             :                         const OUString& rStr,
     118             :                         const Image& rImage,
     119             :                         Menu* pMenu,
     120             :                         size_t nPos,
     121             :                         const OString &rIdent
     122             :                     );
     123             :     void            InsertSeparator(const OString &rIdent, size_t nPos);
     124             :     void            Remove( size_t nPos );
     125             : 
     126             :     MenuItemData*   GetData( sal_uInt16 nSVId, size_t& rPos ) const;
     127     1638525 :     MenuItemData*   GetData( sal_uInt16 nSVId ) const
     128             :                     {
     129             :                         size_t nTemp;
     130     1638525 :                         return GetData( nSVId, nTemp );
     131             :                     }
     132     1395371 :     MenuItemData*   GetDataFromPos( size_t nPos ) const
     133             :                     {
     134     1395371 :                         return ( nPos < maItemList.size() ) ? maItemList[ nPos ] : NULL;
     135             :                     }
     136             : 
     137             :     MenuItemData*   SearchItem(
     138             :                         sal_Unicode cSelectChar,
     139             :                         vcl::KeyCode aKeyCode,
     140             :                         sal_uInt16& rPos,
     141             :                         sal_uInt16& nDuplicates,
     142             :                         sal_uInt16 nCurrentPos
     143             :                     ) const;
     144             :     size_t          GetItemCount( sal_Unicode cSelectChar ) const;
     145             :     size_t          GetItemCount( vcl::KeyCode aKeyCode ) const;
     146      929770 :     size_t          size()
     147             :                     {
     148      929770 :                         return maItemList.size();
     149             :                     }
     150             : };
     151             : 
     152             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10