Kaydet (Commit) e2e2b03b authored tarafından Jan Holesovsky's avatar Jan Holesovsky

vcl: Virtual functions do not work in constructors, avoid IsMenuBar() there.

Actually, this cleans this up further - Menu is an abstract class, so make its
constructor protected; which allows us to move the native menu construction
accordingly.

Change-Id: I774cf4ed0cd62b54074fa287d1a7192aced7efee
üst 2be52713
...@@ -153,7 +153,6 @@ private: ...@@ -153,7 +153,6 @@ private:
SalMenu* mpSalMenu; SalMenu* mpSalMenu;
protected: protected:
SAL_DLLPRIVATE void ImplInit();
SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
SAL_DLLPRIVATE Menu* ImplGetStartMenu(); SAL_DLLPRIVATE Menu* ImplGetStartMenu();
SAL_DLLPRIVATE Menu* ImplFindSelectMenu(); SAL_DLLPRIVATE Menu* ImplFindSelectMenu();
...@@ -203,8 +202,16 @@ public: ...@@ -203,8 +202,16 @@ public:
SAL_DLLPRIVATE Window* ImplGetWindow() const { return pWindow; } SAL_DLLPRIVATE Window* ImplGetWindow() const { return pWindow; }
void ImplSelectWithStart( Menu* pStartMenu = NULL ); void ImplSelectWithStart( Menu* pStartMenu = NULL );
protected:
/** The Menu constructor is protected.
The callers are supposed to instantiate either PopupMenu or MenuBar, but
not a Menu directly.
*/
Menu();
public: public:
Menu();
virtual ~Menu(); virtual ~Menu();
virtual void Activate(); virtual void Activate();
......
...@@ -111,8 +111,22 @@ static void ImplSetMenuItemData( MenuItemData* pData ) ...@@ -111,8 +111,22 @@ static void ImplSetMenuItemData( MenuItemData* pData )
} }
Menu::Menu() Menu::Menu()
: mpFirstDel(NULL),
pItemList(new MenuItemList),
pLogo(NULL),
pStartedFrom(NULL),
pWindow(NULL),
nEventId(0),
mnHighlightedItemPos(ITEMPOS_INVALID),
nMenuFlags(0),
nDefaultItem(0),
nSelectedId(0),
bCanceled(false),
bInCallback(false),
bKilled(false),
mpLayoutData(NULL),
mpSalMenu(NULL)
{ {
ImplInit();
} }
Menu::~Menu() Menu::~Menu()
...@@ -161,27 +175,6 @@ Menu::~Menu() ...@@ -161,27 +175,6 @@ Menu::~Menu()
ImplSetSalMenu( NULL ); ImplSetSalMenu( NULL );
} }
void Menu::ImplInit()
{
mnHighlightedItemPos = ITEMPOS_INVALID;
mpSalMenu = NULL;
nMenuFlags = 0;
nDefaultItem = 0;
nSelectedId = 0;
pItemList = new MenuItemList;
pLogo = NULL;
pStartedFrom = NULL;
pWindow = NULL;
nEventId = 0;
bCanceled = false;
bInCallback = false;
bKilled = false;
mpLayoutData = NULL;
mpFirstDel = NULL; // Dtor notification list
// Native-support: returns NULL if not supported
mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(IsMenuBar(), this);
}
void Menu::ImplLoadRes( const ResId& rResId ) void Menu::ImplLoadRes( const ResId& rResId )
{ {
ResMgr* pMgr = rResId.GetResMgr(); ResMgr* pMgr = rResId.GetResMgr();
...@@ -2472,21 +2465,25 @@ void Menu::HighlightItem( sal_uInt16 nItemPos ) ...@@ -2472,21 +2465,25 @@ void Menu::HighlightItem( sal_uInt16 nItemPos )
// - MenuBar - // - MenuBar -
MenuBar::MenuBar() : Menu() MenuBar::MenuBar()
: Menu(),
mbCloserVisible(false),
mbFloatBtnVisible(false),
mbHideBtnVisible(false),
mbDisplayable(true)
{ {
mbDisplayable = true; mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(true, this);
mbCloserVisible = false;
mbFloatBtnVisible = false;
mbHideBtnVisible = false;
} }
MenuBar::MenuBar( const MenuBar& rMenu ) : Menu() MenuBar::MenuBar( const MenuBar& rMenu )
: Menu(),
mbCloserVisible(false),
mbFloatBtnVisible(false),
mbHideBtnVisible(false),
mbDisplayable(true)
{ {
mbDisplayable = true; mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(true, this);
mbCloserVisible = false; *this = rMenu;
mbFloatBtnVisible = false;
mbHideBtnVisible = false;
*this = rMenu;
} }
MenuBar::~MenuBar() MenuBar::~MenuBar()
...@@ -2694,19 +2691,23 @@ bool MenuBar::HandleMenuButtonEvent( Menu *, sal_uInt16 i_nButtonId ) const ...@@ -2694,19 +2691,23 @@ bool MenuBar::HandleMenuButtonEvent( Menu *, sal_uInt16 i_nButtonId ) const
// bool PopupMenu::bAnyPopupInExecute = false; // bool PopupMenu::bAnyPopupInExecute = false;
PopupMenu::PopupMenu() PopupMenu::PopupMenu()
: pRefAutoSubMenu(NULL)
{ {
pRefAutoSubMenu = NULL; mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this);
} }
PopupMenu::PopupMenu( const ResId& rResId ) PopupMenu::PopupMenu( const ResId& rResId )
: pRefAutoSubMenu(NULL)
{ {
pRefAutoSubMenu = NULL; mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this);
ImplLoadRes( rResId ); ImplLoadRes( rResId );
} }
PopupMenu::PopupMenu( const PopupMenu& rMenu ) : Menu() PopupMenu::PopupMenu( const PopupMenu& rMenu )
: Menu(),
pRefAutoSubMenu(NULL)
{ {
pRefAutoSubMenu = NULL; mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this);
*this = rMenu; *this = rMenu;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment