SidebarController.cxx (a5297daf) SidebarController.cxx (3091fa8a)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 69 unchanged lines hidden (view full) ---

78 const static sal_Int32 gnMaximumSidebarWidth (400);
79 const static sal_Int32 gnWidthCloseThreshold (70);
80 const static sal_Int32 gnWidthOpenThreshold (40);
81}
82
83
84namespace sfx2 { namespace sidebar {
85
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 69 unchanged lines hidden (view full) ---

78 const static sal_Int32 gnMaximumSidebarWidth (400);
79 const static sal_Int32 gnWidthCloseThreshold (70);
80 const static sal_Int32 gnWidthOpenThreshold (40);
81}
82
83
84namespace sfx2 { namespace sidebar {
85
86SidebarController::SidebarControllerContainer SidebarController::maSidebarControllerContainer;
87
86namespace {
87 enum MenuId
88 {
89 MID_UNLOCK_TASK_PANEL = 1,
90 MID_LOCK_TASK_PANEL,
91 MID_CUSTOMIZATION,
92 MID_RESTORE_DEFAULT,
93 MID_FIRST_PANEL,

--- 20 unchanged lines hidden (view full) ---

114 mxFrame(rxFrame),
115 maCurrentContext(OUString(), OUString()),
116 maRequestedContext(),
117 mnRequestedForceFlags(SwitchFlag_NoForce),
118 msCurrentDeckId(gsDefaultDeckId),
119 msCurrentDeckTitle(),
120 maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)),
121 maContextChangeUpdate(::boost::bind(&SidebarController::UpdateConfigurations, this)),
88namespace {
89 enum MenuId
90 {
91 MID_UNLOCK_TASK_PANEL = 1,
92 MID_LOCK_TASK_PANEL,
93 MID_CUSTOMIZATION,
94 MID_RESTORE_DEFAULT,
95 MID_FIRST_PANEL,

--- 20 unchanged lines hidden (view full) ---

116 mxFrame(rxFrame),
117 maCurrentContext(OUString(), OUString()),
118 maRequestedContext(),
119 mnRequestedForceFlags(SwitchFlag_NoForce),
120 msCurrentDeckId(gsDefaultDeckId),
121 msCurrentDeckTitle(),
122 maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)),
123 maContextChangeUpdate(::boost::bind(&SidebarController::UpdateConfigurations, this)),
124 maAsynchronousDeckSwitch(),
122 mbIsDeckRequestedOpen(),
123 mbIsDeckOpen(),
124 mbCanDeckBeOpened(true),
125 mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()),
126 maFocusManager(::boost::bind(&SidebarController::ShowPanel, this, _1)),
127 mxReadOnlyModeDispatch(),
128 mbIsDocumentReadOnly(false),
129 mpSplitWindow(NULL),

--- 26 unchanged lines hidden (view full) ---

156 // Get the dispatch object as preparation to listen for changes of
157 // the read-only state.
158 const util::URL aURL (Tools::GetURL(gsReadOnlyCommandName));
159 mxReadOnlyModeDispatch = Tools::GetDispatch(mxFrame, aURL);
160 if (mxReadOnlyModeDispatch.is())
161 mxReadOnlyModeDispatch->addStatusListener(this, aURL);
162
163 SwitchToDeck(A2S("default"));
125 mbIsDeckRequestedOpen(),
126 mbIsDeckOpen(),
127 mbCanDeckBeOpened(true),
128 mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()),
129 maFocusManager(::boost::bind(&SidebarController::ShowPanel, this, _1)),
130 mxReadOnlyModeDispatch(),
131 mbIsDocumentReadOnly(false),
132 mpSplitWindow(NULL),

--- 26 unchanged lines hidden (view full) ---

159 // Get the dispatch object as preparation to listen for changes of
160 // the read-only state.
161 const util::URL aURL (Tools::GetURL(gsReadOnlyCommandName));
162 mxReadOnlyModeDispatch = Tools::GetDispatch(mxFrame, aURL);
163 if (mxReadOnlyModeDispatch.is())
164 mxReadOnlyModeDispatch->addStatusListener(this, aURL);
165
166 SwitchToDeck(A2S("default"));
167
168 WeakReference<SidebarController> xWeakController (this);
169 maSidebarControllerContainer.insert(
170 SidebarControllerContainer::value_type(
171 rxFrame,
172 xWeakController));
164}
165
166
167
168
169SidebarController::~SidebarController (void)
170{
171}
172
173
174
175
173}
174
175
176
177
178SidebarController::~SidebarController (void)
179{
180}
181
182
183
184
185SidebarController* SidebarController::GetSidebarControllerForFrame (
186 const cssu::Reference<css::frame::XFrame>& rxFrame)
187{
188 SidebarControllerContainer::iterator iEntry (maSidebarControllerContainer.find(rxFrame));
189 if (iEntry == maSidebarControllerContainer.end())
190 return NULL;
191
192 cssu::Reference<XInterface> xController (iEntry->second.get());
193 if ( ! xController.is())
194 return NULL;
195
196 return dynamic_cast<SidebarController*>(xController.get());
197}
198
199
200
201
176void SAL_CALL SidebarController::disposing (void)
177{
202void SAL_CALL SidebarController::disposing (void)
203{
204 SidebarControllerContainer::iterator iEntry (maSidebarControllerContainer.find(mxFrame));
205 if (iEntry != maSidebarControllerContainer.end())
206 maSidebarControllerContainer.erase(iEntry);
207
178 maFocusManager.Clear();
179
180 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
181 css::ui::ContextChangeEventMultiplexer::get(
182 ::comphelper::getProcessComponentContext()));
183 if (xMultiplexer.is())
184 xMultiplexer->removeAllContextChangeEventListeners(
185 static_cast<css::ui::XContextChangeEventListener*>(this));

--- 21 unchanged lines hidden (view full) ---

207
208 mpTabBar.reset();
209
210 Theme::GetPropertySet()->removePropertyChangeListener(
211 A2S(""),
212 static_cast<css::beans::XPropertyChangeListener*>(this));
213
214 maContextChangeUpdate.CancelRequest();
208 maFocusManager.Clear();
209
210 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
211 css::ui::ContextChangeEventMultiplexer::get(
212 ::comphelper::getProcessComponentContext()));
213 if (xMultiplexer.is())
214 xMultiplexer->removeAllContextChangeEventListeners(
215 static_cast<css::ui::XContextChangeEventListener*>(this));

--- 21 unchanged lines hidden (view full) ---

237
238 mpTabBar.reset();
239
240 Theme::GetPropertySet()->removePropertyChangeListener(
241 A2S(""),
242 static_cast<css::beans::XPropertyChangeListener*>(this));
243
244 maContextChangeUpdate.CancelRequest();
245 maAsynchronousDeckSwitch.CancelRequest();
215}
216
217
218
219
220void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent)
221 throw(cssu::RuntimeException)
222{
223 // Update to the requested new context asynchronously to avoid
224 // subtle errors caused by SFX2 which in rare cases can not
225 // properly handle a synchronous update.
226 maRequestedContext = Context(
227 rEvent.ApplicationName,
228 rEvent.ContextName);
229 if (maRequestedContext != maCurrentContext)
246}
247
248
249
250
251void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent)
252 throw(cssu::RuntimeException)
253{
254 // Update to the requested new context asynchronously to avoid
255 // subtle errors caused by SFX2 which in rare cases can not
256 // properly handle a synchronous update.
257 maRequestedContext = Context(
258 rEvent.ApplicationName,
259 rEvent.ContextName);
260 if (maRequestedContext != maCurrentContext)
261 {
262 maAsynchronousDeckSwitch.CancelRequest();
230 maContextChangeUpdate.RequestCall();
263 maContextChangeUpdate.RequestCall();
264 }
231}
232
233
234
235
236void SAL_CALL SidebarController::disposing (const css::lang::EventObject& rEventObject)
237 throw(cssu::RuntimeException)
238{

--- 26 unchanged lines hidden (view full) ---

265 if (mbIsDocumentReadOnly != !bIsReadWrite)
266 {
267 mbIsDocumentReadOnly = !bIsReadWrite;
268
269 // Force the current deck to update its panel list.
270 if ( ! mbIsDocumentReadOnly)
271 msCurrentDeckId = gsDefaultDeckId;
272 mnRequestedForceFlags |= SwitchFlag_ForceSwitch;
265}
266
267
268
269
270void SAL_CALL SidebarController::disposing (const css::lang::EventObject& rEventObject)
271 throw(cssu::RuntimeException)
272{

--- 26 unchanged lines hidden (view full) ---

299 if (mbIsDocumentReadOnly != !bIsReadWrite)
300 {
301 mbIsDocumentReadOnly = !bIsReadWrite;
302
303 // Force the current deck to update its panel list.
304 if ( ! mbIsDocumentReadOnly)
305 msCurrentDeckId = gsDefaultDeckId;
306 mnRequestedForceFlags |= SwitchFlag_ForceSwitch;
307 maAsynchronousDeckSwitch.CancelRequest();
273 maContextChangeUpdate.RequestCall();
274 }
275}
276
277
278
279
280void SAL_CALL SidebarController::requestLayout (void)

--- 156 unchanged lines hidden (view full) ---

437
438 // Tell the tab bar to highlight the button associated
439 // with the deck.
440 mpTabBar->HighlightDeck(sNewDeckId);
441
442 SwitchToDeck(
443 *ResourceManager::Instance().GetDeckDescriptor(sNewDeckId),
444 maCurrentContext);
308 maContextChangeUpdate.RequestCall();
309 }
310}
311
312
313
314
315void SAL_CALL SidebarController::requestLayout (void)

--- 156 unchanged lines hidden (view full) ---

472
473 // Tell the tab bar to highlight the button associated
474 // with the deck.
475 mpTabBar->HighlightDeck(sNewDeckId);
476
477 SwitchToDeck(
478 *ResourceManager::Instance().GetDeckDescriptor(sNewDeckId),
479 maCurrentContext);
445
446#ifdef DEBUG
447 // Show the context name in the deck title bar.
448 if (mpCurrentDeck)
449 {
450 DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
451 if (pTitleBar != NULL)
452 pTitleBar->SetTitle(msCurrentDeckTitle+A2S(" (")+maCurrentContext.msContext+A2S(")"));
453 }
454#endif
455 }
456}
457
458
459
460
461void SidebarController::OpenThenSwitchToDeck (
462 const ::rtl::OUString& rsDeckId)
463{
464 RequestOpenDeck();
465 SwitchToDeck(rsDeckId);
480 }
481}
482
483
484
485
486void SidebarController::OpenThenSwitchToDeck (
487 const ::rtl::OUString& rsDeckId)
488{
489 RequestOpenDeck();
490 SwitchToDeck(rsDeckId);
491 mpTabBar->Invalidate();
466}
467
468
469
470
492}
493
494
495
496
497void SidebarController::RequestSwitchToDeck (
498 const ::rtl::OUString& rsDeckId)
499{
500 maContextChangeUpdate.CancelRequest();
501 maAsynchronousDeckSwitch.RequestCall(
502 ::boost::bind(&SidebarController::OpenThenSwitchToDeck, this, rsDeckId));
503}
504
505
506
507
471void SidebarController::SwitchToDeck (
472 const ::rtl::OUString& rsDeckId)
473{
474 if ( ! msCurrentDeckId.equals(rsDeckId)
475 || ! mbIsDeckOpen
476 || mnRequestedForceFlags!=SwitchFlag_NoForce)
477 {
478 const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId);

--- 62 unchanged lines hidden (view full) ---

541 if ( ! mpCurrentDeck)
542 {
543 mpCurrentDeck.reset(
544 new Deck(
545 rDeckDescriptor,
546 mpParentWindow,
547 ::boost::bind(&SidebarController::RequestCloseDeck, this)));
548 msCurrentDeckTitle = rDeckDescriptor.msTitle;
508void SidebarController::SwitchToDeck (
509 const ::rtl::OUString& rsDeckId)
510{
511 if ( ! msCurrentDeckId.equals(rsDeckId)
512 || ! mbIsDeckOpen
513 || mnRequestedForceFlags!=SwitchFlag_NoForce)
514 {
515 const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId);

--- 62 unchanged lines hidden (view full) ---

578 if ( ! mpCurrentDeck)
579 {
580 mpCurrentDeck.reset(
581 new Deck(
582 rDeckDescriptor,
583 mpParentWindow,
584 ::boost::bind(&SidebarController::RequestCloseDeck, this)));
585 msCurrentDeckTitle = rDeckDescriptor.msTitle;
586
549 }
550 if ( ! mpCurrentDeck)
551 return;
587 }
588 if ( ! mpCurrentDeck)
589 return;
552
590
591#ifdef DEBUG
592 // Show the context name in the deck title bar.
593 DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
594 if (pTitleBar != NULL)
595 pTitleBar->SetTitle(rDeckDescriptor.msTitle+A2S(" (")+maCurrentContext.msContext+A2S(")"));
596#endif
597
553 // Update the panel list.
554 const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
555 SharedPanelContainer aNewPanels;
556 const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels());
557 aNewPanels.resize(nNewPanelCount);
558 sal_Int32 nWriteIndex (0);
559 bool bHasPanelSetChanged (false);
560 for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex)

--- 192 unchanged lines hidden (view full) ---

753
754 case VCLEVENT_WINDOW_DATACHANGED:
755 // Force an update of deck and tab bar to reflect
756 // changes in theme (high contrast mode).
757 Theme::HandleDataChange();
758 UpdateTitleBarIcons();
759 mpParentWindow->Invalidate();
760 mnRequestedForceFlags |= SwitchFlag_ForceNewDeck | SwitchFlag_ForceNewPanels;
598 // Update the panel list.
599 const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
600 SharedPanelContainer aNewPanels;
601 const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels());
602 aNewPanels.resize(nNewPanelCount);
603 sal_Int32 nWriteIndex (0);
604 bool bHasPanelSetChanged (false);
605 for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex)

--- 192 unchanged lines hidden (view full) ---

798
799 case VCLEVENT_WINDOW_DATACHANGED:
800 // Force an update of deck and tab bar to reflect
801 // changes in theme (high contrast mode).
802 Theme::HandleDataChange();
803 UpdateTitleBarIcons();
804 mpParentWindow->Invalidate();
805 mnRequestedForceFlags |= SwitchFlag_ForceNewDeck | SwitchFlag_ForceNewPanels;
806 maAsynchronousDeckSwitch.CancelRequest();
761 maContextChangeUpdate.RequestCall();
762 break;
763
764 case SFX_HINT_DYING:
765 dispose();
766 break;
767
768 case VCLEVENT_WINDOW_PAINT:

--- 431 unchanged lines hidden ---
807 maContextChangeUpdate.RequestCall();
808 break;
809
810 case SFX_HINT_DYING:
811 dispose();
812 break;
813
814 case VCLEVENT_WINDOW_PAINT:

--- 431 unchanged lines hidden ---