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

Resolves: #i122394# Force creation of new sidebar panels on DATACHANGED events

(cherry picked from commit c726a12e)

Conflicts:
	sfx2/source/sidebar/SidebarController.cxx

Change-Id: Ie28ff4371e42fd57534eeca75dab1a4bfda2ead6
üst c723428d
...@@ -106,6 +106,7 @@ SidebarController::SidebarController ( ...@@ -106,6 +106,7 @@ SidebarController::SidebarController (
mxFrame(rxFrame), mxFrame(rxFrame),
maCurrentContext(OUString(), OUString()), maCurrentContext(OUString(), OUString()),
maRequestedContext(), maRequestedContext(),
mnRequestedForceFlags(SwitchFlag_NoForce),
msCurrentDeckId(gsDefaultDeckId), msCurrentDeckId(gsDefaultDeckId),
msCurrentDeckTitle(), msCurrentDeckTitle(),
maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)),
...@@ -260,7 +261,7 @@ void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEv ...@@ -260,7 +261,7 @@ void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEv
// Force the current deck to update its panel list. // Force the current deck to update its panel list.
if ( ! mbIsDocumentReadOnly) if ( ! mbIsDocumentReadOnly)
msCurrentDeckId = gsDefaultDeckId; msCurrentDeckId = gsDefaultDeckId;
maCurrentContext = Context(); mnRequestedForceFlags |= SwitchFlag_ForceSwitch;
maContextChangeUpdate.RequestCall(); maContextChangeUpdate.RequestCall();
} }
} }
...@@ -381,7 +382,8 @@ void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth) ...@@ -381,7 +382,8 @@ void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth)
void SidebarController::UpdateConfigurations (void) void SidebarController::UpdateConfigurations (void)
{ {
if (maCurrentContext != maRequestedContext) if (maCurrentContext != maRequestedContext
|| mnRequestedForceFlags!=SwitchFlag_NoForce)
{ {
maCurrentContext = maRequestedContext; maCurrentContext = maRequestedContext;
...@@ -461,7 +463,9 @@ void SidebarController::OpenThenSwitchToDeck ( ...@@ -461,7 +463,9 @@ void SidebarController::OpenThenSwitchToDeck (
void SidebarController::SwitchToDeck ( void SidebarController::SwitchToDeck (
const ::rtl::OUString& rsDeckId) const ::rtl::OUString& rsDeckId)
{ {
if ( ! msCurrentDeckId.equals(rsDeckId) || ! mbIsDeckOpen) if ( ! msCurrentDeckId.equals(rsDeckId)
|| ! mbIsDeckOpen
|| mnRequestedForceFlags!=SwitchFlag_NoForce)
{ {
const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId); const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId);
if (pDeckDescriptor != NULL) if (pDeckDescriptor != NULL)
...@@ -478,7 +482,12 @@ void SidebarController::SwitchToDeck ( ...@@ -478,7 +482,12 @@ void SidebarController::SwitchToDeck (
{ {
maFocusManager.Clear(); maFocusManager.Clear();
if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)) const bool bForceNewDeck ((mnRequestedForceFlags&SwitchFlag_ForceNewDeck)!=0);
const bool bForceNewPanels ((mnRequestedForceFlags&SwitchFlag_ForceNewPanels)!=0);
mnRequestedForceFlags = SwitchFlag_NoForce;
if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)
|| bForceNewDeck)
{ {
// When the deck changes then destroy the deck and all panels // When the deck changes then destroy the deck and all panels
// and create everything new. // and create everything new.
...@@ -552,10 +561,20 @@ void SidebarController::SwitchToDeck ( ...@@ -552,10 +561,20 @@ void SidebarController::SwitchToDeck (
// Find the corresponding panel among the currently active // Find the corresponding panel among the currently active
// panels. // panels.
SharedPanelContainer::const_iterator iPanel (::std::find_if( SharedPanelContainer::const_iterator iPanel;
if (bForceNewPanels)
{
// All panels have to be created in any case. There is no
// point in searching already existing panels.
iPanel = rCurrentPanels.end();
}
else
{
iPanel = ::std::find_if(
rCurrentPanels.begin(), rCurrentPanels.begin(),
rCurrentPanels.end(), rCurrentPanels.end(),
::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId)))); ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId)));
}
if (iPanel != rCurrentPanels.end()) if (iPanel != rCurrentPanels.end())
{ {
// Panel already exists in current deck. Reuse it. // Panel already exists in current deck. Reuse it.
...@@ -564,7 +583,8 @@ void SidebarController::SwitchToDeck ( ...@@ -564,7 +583,8 @@ void SidebarController::SwitchToDeck (
} }
else else
{ {
// Panel does not yet exist. Create it. // Panel does not yet exist or creation of new panels is forced.
// Create it.
aNewPanels[nWriteIndex] = CreatePanel( aNewPanels[nWriteIndex] = CreatePanel(
rPanelContexDescriptor.msId, rPanelContexDescriptor.msId,
mpCurrentDeck->GetPanelParentWindow(), mpCurrentDeck->GetPanelParentWindow(),
...@@ -615,30 +635,6 @@ void SidebarController::SwitchToDeck ( ...@@ -615,30 +635,6 @@ void SidebarController::SwitchToDeck (
bool SidebarController::ArePanelSetsEqual (
const SharedPanelContainer& rCurrentPanels,
const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels)
{
if (rCurrentPanels.size() != rRequestedPanels.size())
return false;
for (sal_Int32 nIndex=0,nCount=rCurrentPanels.size(); nIndex<nCount; ++nIndex)
{
if (rCurrentPanels[nIndex] == 0)
return false;
if ( ! rCurrentPanels[nIndex]->GetId().equals(rRequestedPanels[nIndex].msId))
return false;
// Check if the panels still can be displayed. This may not be the case when
// the document just become rea-only.
if (mbIsDocumentReadOnly && ! rRequestedPanels[nIndex].mbShowForReadOnlyDocuments)
return false;
}
return true;
}
SharedPanel SidebarController::CreatePanel ( SharedPanel SidebarController::CreatePanel (
const OUString& rsPanelId, const OUString& rsPanelId,
::Window* pParentWindow, ::Window* pParentWindow,
...@@ -753,6 +749,8 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) ...@@ -753,6 +749,8 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent)
Theme::HandleDataChange(); Theme::HandleDataChange();
UpdateTitleBarIcons(); UpdateTitleBarIcons();
mpParentWindow->Invalidate(); mpParentWindow->Invalidate();
mnRequestedForceFlags |= SwitchFlag_ForceNewDeck | SwitchFlag_ForceNewPanels;
maContextChangeUpdate.RequestCall();
break; break;
case SFX_HINT_DYING: case SFX_HINT_DYING:
......
...@@ -98,6 +98,17 @@ public: ...@@ -98,6 +98,17 @@ public:
void NotifyResize (void); void NotifyResize (void);
/** In some situations it is necessary to force an update of the
current deck and its panels. One reason is a change of the
view scale. Some panels can handle this only when
constructed. In this case we have to a context change and
also force that all panels are destroyed and created new.
*/
const static sal_Int32 SwitchFlag_NoForce = 0x00;
const static sal_Int32 SwitchFlag_ForceSwitch = 0x01;
const static sal_Int32 SwitchFlag_ForceNewDeck = 0x02;
const static sal_Int32 SwitchFlag_ForceNewPanels = 0x02;
void SwitchToDeck ( void SwitchToDeck (
const ::rtl::OUString& rsDeckId); const ::rtl::OUString& rsDeckId);
void OpenThenSwitchToDeck ( void OpenThenSwitchToDeck (
...@@ -120,6 +131,8 @@ private: ...@@ -120,6 +131,8 @@ private:
cssu::Reference<css::frame::XFrame> mxFrame; cssu::Reference<css::frame::XFrame> mxFrame;
Context maCurrentContext; Context maCurrentContext;
Context maRequestedContext; Context maRequestedContext;
/// Use a combination of SwitchFlag_* as value.
sal_Int32 mnRequestedForceFlags;
::rtl::OUString msCurrentDeckId; ::rtl::OUString msCurrentDeckId;
::rtl::OUString msCurrentDeckTitle; ::rtl::OUString msCurrentDeckTitle;
AsynchronousCall maPropertyChangeForwarder; AsynchronousCall maPropertyChangeForwarder;
...@@ -160,9 +173,6 @@ private: ...@@ -160,9 +173,6 @@ private:
*/ */
void UpdateConfigurations (void); void UpdateConfigurations (void);
bool ArePanelSetsEqual (
const SharedPanelContainer& rCurrentPanels,
const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels);
cssu::Reference<css::ui::XUIElement> CreateUIElement ( cssu::Reference<css::ui::XUIElement> CreateUIElement (
const cssu::Reference<css::awt::XWindowPeer>& rxWindow, const cssu::Reference<css::awt::XWindowPeer>& rxWindow,
const ::rtl::OUString& rsImplementationURL, const ::rtl::OUString& rsImplementationURL,
......
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