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 : MenuUserDataReleaseFunction aUserValueReleaseFunc; // called when MenuItemData is destroyed
47 : Image aImage; // Image
48 : vcl::KeyCode aAccelKey; // Accelerator-Key
49 : bool bChecked; // Checked
50 : bool bEnabled; // Enabled
51 : bool bVisible; // Visible (note: this flag will not override MenuFlags::HideDisabledEntries when true)
52 : bool bIsTemporary; // Temporary inserted ('No selection possible')
53 : bool bMirrorMode;
54 : long nItemImageAngle;
55 : Size aSz; // only temporarily valid
56 : OUString aAccessibleName; // accessible name
57 : OUString aAccessibleDescription; // accessible description
58 :
59 : SalMenuItem* pSalMenuItem; // access to native menu
60 :
61 46810 : MenuItemData()
62 : : nId(0)
63 : , eType(MenuItemType::DONTKNOW)
64 : , nBits(MenuItemBits::NONE)
65 : , pSubMenu(NULL)
66 : , pAutoSubMenu(NULL)
67 : , nUserValue(0)
68 : , aUserValueReleaseFunc(0)
69 : , bChecked(false)
70 : , bEnabled(false)
71 : , bVisible(false)
72 : , bIsTemporary(false)
73 : , bMirrorMode(false)
74 : , nItemImageAngle(0)
75 46810 : , pSalMenuItem(NULL)
76 : {
77 46810 : }
78 246802 : MenuItemData( const OUString& rStr, const Image& rImage )
79 : : nId(0)
80 : , eType(MenuItemType::DONTKNOW)
81 : , nBits(MenuItemBits::NONE)
82 : , pSubMenu(NULL)
83 : , pAutoSubMenu(NULL)
84 : , aText(rStr)
85 : , nUserValue(0)
86 : , aUserValueReleaseFunc(0)
87 : , aImage(rImage)
88 : , bChecked(false)
89 : , bEnabled(false)
90 : , bVisible(false)
91 : , bIsTemporary(false)
92 : , bMirrorMode(false)
93 : , nItemImageAngle(0)
94 246802 : , pSalMenuItem(NULL)
95 : {
96 246802 : }
97 : ~MenuItemData();
98 458 : bool HasCheck() const
99 : {
100 458 : return bChecked || ( nBits & ( MenuItemBits::RADIOCHECK | MenuItemBits::CHECKABLE | MenuItemBits::AUTOCHECK ) );
101 : }
102 : };
103 :
104 : class MenuItemList
105 : {
106 : private:
107 : typedef ::std::vector< MenuItemData* > MenuItemDataList_impl;
108 : MenuItemDataList_impl maItemList;
109 :
110 : css::uno::Reference< css::i18n::XCharacterClassification > xCharClass;
111 :
112 : public:
113 77988 : MenuItemList() {}
114 : ~MenuItemList();
115 :
116 : MenuItemData* Insert(
117 : sal_uInt16 nId,
118 : MenuItemType eType,
119 : MenuItemBits nBits,
120 : const OUString& rStr,
121 : const Image& rImage,
122 : Menu* pMenu,
123 : size_t nPos,
124 : const OString &rIdent
125 : );
126 : void InsertSeparator(const OString &rIdent, size_t nPos);
127 : void Remove( size_t nPos );
128 :
129 : MenuItemData* GetData( sal_uInt16 nSVId, size_t& rPos ) const;
130 836082 : MenuItemData* GetData( sal_uInt16 nSVId ) const
131 : {
132 : size_t nTemp;
133 836082 : return GetData( nSVId, nTemp );
134 : }
135 710429 : MenuItemData* GetDataFromPos( size_t nPos ) const
136 : {
137 710429 : return ( nPos < maItemList.size() ) ? maItemList[ nPos ] : NULL;
138 : }
139 :
140 : MenuItemData* SearchItem(
141 : sal_Unicode cSelectChar,
142 : vcl::KeyCode aKeyCode,
143 : sal_uInt16& rPos,
144 : sal_uInt16& nDuplicates,
145 : sal_uInt16 nCurrentPos
146 : ) const;
147 : size_t GetItemCount( sal_Unicode cSelectChar ) const;
148 : size_t GetItemCount( vcl::KeyCode aKeyCode ) const;
149 471072 : size_t size()
150 : {
151 471072 : return maItemList.size();
152 : }
153 : };
154 :
155 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|