Kaydet (Commit) d456545f authored tarafından Andre Fischer's avatar Andre Fischer Kaydeden (comit) Caolán McNamara

Resolves: #i122352# Do not allow selection of disabled decks via menu

(cherry picked from commit b27563ac)

Change-Id: Id36b8fd12d0fce8f8717e5dd21538d1871a005b0
üst 9a32ed36
...@@ -102,7 +102,7 @@ SidebarController::SidebarController ( ...@@ -102,7 +102,7 @@ SidebarController::SidebarController (
mpParentWindow, mpParentWindow,
rxFrame, rxFrame,
::boost::bind(&SidebarController::OpenThenSwitchToDeck, this, _1), ::boost::bind(&SidebarController::OpenThenSwitchToDeck, this, _1),
::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2,_3))), ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2))),
mxFrame(rxFrame), mxFrame(rxFrame),
maCurrentContext(OUString(), OUString()), maCurrentContext(OUString(), OUString()),
maRequestedContext(), maRequestedContext(),
...@@ -794,10 +794,9 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) ...@@ -794,10 +794,9 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent)
void SidebarController::ShowPopupMenu ( void SidebarController::ShowPopupMenu (
const Rectangle& rButtonBox, const Rectangle& rButtonBox,
const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, const ::std::vector<TabBar::DeckMenuData>& rMenuData) const
const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const
{ {
::boost::shared_ptr<PopupMenu> pMenu = CreatePopupMenu(rDeckSelectionData, rDeckShowData); ::boost::shared_ptr<PopupMenu> pMenu = CreatePopupMenu(rMenuData);
pMenu->SetSelectHdl(LINK(this, SidebarController, OnMenuItemSelected)); pMenu->SetSelectHdl(LINK(this, SidebarController, OnMenuItemSelected));
// pass toolbox button rect so the menu can stay open on button up // pass toolbox button rect so the menu can stay open on button up
...@@ -829,9 +828,9 @@ void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) co ...@@ -829,9 +828,9 @@ void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) co
::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu ( ::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu (
const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, const ::std::vector<TabBar::DeckMenuData>& rMenuData) const
const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const
{ {
// Create the top level popup menu.
::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu()); ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu());
FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow());
if (pMenuWindow != NULL) if (pMenuWindow != NULL)
...@@ -839,21 +838,36 @@ void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) co ...@@ -839,21 +838,36 @@ void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) co
pMenuWindow->SetPopupModeFlags(pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); pMenuWindow->SetPopupModeFlags(pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE);
} }
// Create sub menu for customization (hiding of deck tabs.)
PopupMenu* pCustomizationMenu = new PopupMenu();
SidebarResource aLocalResource; SidebarResource aLocalResource;
// Add one entry for every tool panel element to individually make // Add one entry for every tool panel element to individually make
// them visible or hide them. // them visible or hide them.
sal_Int32 nIndex (0);
for(::std::vector<TabBar::DeckMenuData>::const_iterator
iItem(rMenuData.begin()),
iEnd(rMenuData.end());
iItem!=iEnd;
++iItem,++nIndex)
{ {
sal_Int32 nIndex (MID_FIRST_PANEL); const sal_Int32 nMenuIndex (nIndex+MID_FIRST_PANEL);
for(::std::vector<TabBar::DeckMenuData>::const_iterator pMenu->InsertItem(nMenuIndex, iItem->msDisplayName, MIB_RADIOCHECK);
iItem(rDeckSelectionData.begin()), pMenu->CheckItem(nMenuIndex, iItem->mbIsCurrentDeck ? sal_True : sal_False);
iEnd(rDeckSelectionData.end()); pMenu->EnableItem(nMenuIndex, (iItem->mbIsEnabled&&iItem->mbIsActive) ? sal_True : sal_False);
iItem!=iEnd;
++iItem) const sal_Int32 nSubMenuIndex (nIndex+MID_FIRST_HIDE);
if (iItem->mbIsCurrentDeck)
{
// Don't allow the currently visible deck to be disabled.
pCustomizationMenu->InsertItem(nSubMenuIndex, iItem->msDisplayName, MIB_RADIOCHECK);
pCustomizationMenu->CheckItem(nSubMenuIndex, sal_True);
}
else
{ {
pMenu->InsertItem(nIndex, iItem->get<0>(), MIB_RADIOCHECK); pCustomizationMenu->InsertItem(nSubMenuIndex, iItem->msDisplayName, MIB_CHECKABLE);
pMenu->CheckItem(nIndex, iItem->get<2>()); pCustomizationMenu->CheckItem(nSubMenuIndex, iItem->mbIsActive ? sal_True : sal_False);
++nIndex;
} }
} }
...@@ -865,22 +879,6 @@ void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) co ...@@ -865,22 +879,6 @@ void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) co
else else
pMenu->InsertItem(MID_UNLOCK_TASK_PANEL, String(SfxResId(STR_SFX_UNDOCK))); pMenu->InsertItem(MID_UNLOCK_TASK_PANEL, String(SfxResId(STR_SFX_UNDOCK)));
// Add sub menu for customization (hiding of deck tabs.)
PopupMenu* pCustomizationMenu = new PopupMenu();
{
sal_Int32 nIndex (MID_FIRST_HIDE);
for(::std::vector<TabBar::DeckMenuData>::const_iterator
iItem(rDeckShowData.begin()),
iEnd(rDeckShowData.end());
iItem!=iEnd;
++iItem)
{
pCustomizationMenu->InsertItem(nIndex, iItem->get<0>(), MIB_CHECKABLE);
pCustomizationMenu->CheckItem(nIndex, iItem->get<2>());
++nIndex;
}
}
pCustomizationMenu->InsertSeparator(); pCustomizationMenu->InsertSeparator();
pCustomizationMenu->InsertItem(MID_RESTORE_DEFAULT, String(SfxResId(STRING_RESTORE))); pCustomizationMenu->InsertItem(MID_RESTORE_DEFAULT, String(SfxResId(STRING_RESTORE)));
...@@ -926,7 +924,8 @@ IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu) ...@@ -926,7 +924,8 @@ IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu)
if (nIndex >= MID_FIRST_PANEL && nIndex<MID_FIRST_HIDE) if (nIndex >= MID_FIRST_PANEL && nIndex<MID_FIRST_HIDE)
SwitchToDeck(mpTabBar->GetDeckIdForIndex(nIndex - MID_FIRST_PANEL)); SwitchToDeck(mpTabBar->GetDeckIdForIndex(nIndex - MID_FIRST_PANEL));
else if (nIndex >=MID_FIRST_HIDE) else if (nIndex >=MID_FIRST_HIDE)
mpTabBar->ToggleHideFlag(nIndex-MID_FIRST_HIDE); if (pMenu->GetItemBits(nIndex) == MIB_CHECKABLE)
mpTabBar->ToggleHideFlag(nIndex-MID_FIRST_HIDE);
} }
catch (RuntimeException&) catch (RuntimeException&)
{ {
......
...@@ -178,12 +178,10 @@ private: ...@@ -178,12 +178,10 @@ private:
const Context& rContext); const Context& rContext);
void ShowPopupMenu ( void ShowPopupMenu (
const Rectangle& rButtonBox, const Rectangle& rButtonBox,
const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, const ::std::vector<TabBar::DeckMenuData>& rMenuData) const;
const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const;
void ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const; void ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const;
::boost::shared_ptr<PopupMenu> CreatePopupMenu ( ::boost::shared_ptr<PopupMenu> CreatePopupMenu (
const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, const ::std::vector<TabBar::DeckMenuData>& rMenuData) const;
const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const;
DECL_LINK(OnMenuItemSelected, Menu*); DECL_LINK(OnMenuItemSelected, Menu*);
void BroadcastPropertyChange (void); void BroadcastPropertyChange (void);
......
...@@ -363,8 +363,7 @@ void TabBar::UpdateFocusManager (FocusManager& rFocusManager) ...@@ -363,8 +363,7 @@ void TabBar::UpdateFocusManager (FocusManager& rFocusManager)
IMPL_LINK(TabBar, OnToolboxClicked, void*, EMPTYARG) IMPL_LINK(TabBar, OnToolboxClicked, void*, EMPTYARG)
{ {
::std::vector<DeckMenuData> aSelectionData; ::std::vector<DeckMenuData> aMenuData;
::std::vector<DeckMenuData> aShowData;
for(ItemContainer::const_iterator iItem(maItems.begin()),iEnd(maItems.end()); for(ItemContainer::const_iterator iItem(maItems.begin()),iEnd(maItems.end());
iItem!=iEnd; iItem!=iEnd;
...@@ -373,18 +372,14 @@ IMPL_LINK(TabBar, OnToolboxClicked, void*, EMPTYARG) ...@@ -373,18 +372,14 @@ IMPL_LINK(TabBar, OnToolboxClicked, void*, EMPTYARG)
const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(iItem->msDeckId); const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(iItem->msDeckId);
if (pDeckDescriptor != NULL) if (pDeckDescriptor != NULL)
{ {
if ( ! iItem->mbIsHidden) DeckMenuData aData;
aSelectionData.push_back( aData.msDisplayName = pDeckDescriptor->msTitle;
DeckMenuData( aData.msDeckId = pDeckDescriptor->msId;
pDeckDescriptor->msTitle, aData.mbIsCurrentDeck = iItem->mpButton->IsChecked();
pDeckDescriptor->msId, aData.mbIsActive = !iItem->mbIsHidden;
iItem->mpButton->IsChecked())); aData.mbIsEnabled = iItem->mpButton->IsEnabled();
aShowData.push_back( aMenuData.push_back(aData);
DeckMenuData(
pDeckDescriptor->msTitle,
pDeckDescriptor->msId,
!iItem->mbIsHidden));
} }
} }
...@@ -392,8 +387,7 @@ IMPL_LINK(TabBar, OnToolboxClicked, void*, EMPTYARG) ...@@ -392,8 +387,7 @@ IMPL_LINK(TabBar, OnToolboxClicked, void*, EMPTYARG)
Rectangle( Rectangle(
mpMenuButton->GetPosPixel(), mpMenuButton->GetPosPixel(),
mpMenuButton->GetSizePixel()), mpMenuButton->GetSizePixel()),
aSelectionData, aMenuData);
aShowData);
return 0; return 0;
} }
......
...@@ -52,11 +52,18 @@ public: ...@@ -52,11 +52,18 @@ public:
- isCurrentDeck for the deck selection data - isCurrentDeck for the deck selection data
- isEnabled for the show/hide menu - isEnabled for the show/hide menu
*/ */
typedef ::boost::tuple<rtl::OUString,rtl::OUString,bool> DeckMenuData; class DeckMenuData
{
public:
::rtl::OUString msDisplayName;
::rtl::OUString msDeckId;
bool mbIsCurrentDeck;
bool mbIsActive;
bool mbIsEnabled;
};
typedef ::boost::function<void( typedef ::boost::function<void(
const Rectangle&, const Rectangle&,
const ::std::vector<DeckMenuData>& rDeckSelectionData, const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider;
const ::std::vector<DeckMenuData>& rDeckShowData)> PopupMenuProvider;
TabBar ( TabBar (
Window* pParentWindow, Window* pParentWindow,
const cssu::Reference<css::frame::XFrame>& rxFrame, const cssu::Reference<css::frame::XFrame>& rxFrame,
......
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