SidebarController.cxx (c545150f) SidebarController.cxx (13e1c3b4)
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

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

24#include "SidebarController.hxx"
25#include "Deck.hxx"
26#include "DeckTitleBar.hxx"
27#include "Panel.hxx"
28#include "SidebarPanel.hxx"
29#include "SidebarResource.hxx"
30#include "TabBar.hxx"
31#include "sfx2/sidebar/Theme.hxx"
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

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

24#include "SidebarController.hxx"
25#include "Deck.hxx"
26#include "DeckTitleBar.hxx"
27#include "Panel.hxx"
28#include "SidebarPanel.hxx"
29#include "SidebarResource.hxx"
30#include "TabBar.hxx"
31#include "sfx2/sidebar/Theme.hxx"
32#include "sfx2/sidebar/SidebarChildWindow.hxx"
32#include "SidebarDockingWindow.hxx"
33#include "Context.hxx"
34#include "Tools.hxx"
35
36#include "sfxresid.hxx"
37#include "sfx2/sfxsids.hrc"
38#include "sfx2/titledockwin.hxx"
39#include "sfxlocal.hrc"
40#include <vcl/floatwin.hxx>
33#include "SidebarDockingWindow.hxx"
34#include "Context.hxx"
35#include "Tools.hxx"
36
37#include "sfxresid.hxx"
38#include "sfx2/sfxsids.hrc"
39#include "sfx2/titledockwin.hxx"
40#include "sfxlocal.hrc"
41#include <vcl/floatwin.hxx>
42#include <vcl/fixed.hxx>
41#include "splitwin.hxx"
42#include <svl/smplhint.hxx>
43#include <tools/link.hxx>
44#include <toolkit/helper/vclunohelper.hxx>
45
46#include <comphelper/componentfactory.hxx>
47#include <comphelper/processfactory.hxx>
48#include <comphelper/componentcontext.hxx>

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

64
65using namespace css;
66using namespace cssu;
67using ::rtl::OUString;
68
69
70#undef VERBOSE
71
43#include "splitwin.hxx"
44#include <svl/smplhint.hxx>
45#include <tools/link.hxx>
46#include <toolkit/helper/vclunohelper.hxx>
47
48#include <comphelper/componentfactory.hxx>
49#include <comphelper/processfactory.hxx>
50#include <comphelper/componentcontext.hxx>

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

66
67using namespace css;
68using namespace cssu;
69using ::rtl::OUString;
70
71
72#undef VERBOSE
73
74namespace
75{
76 const static OUString gsReadOnlyCommandName (A2S(".uno:EditDoc"));
77 const static sal_Int32 gnMaximumSidebarWidth (400);
78 const static sal_Int32 gnWidthCloseThreshold (70);
79 const static sal_Int32 gnWidthOpenThreshold (40);
80}
81
82
72namespace sfx2 { namespace sidebar {
73
74namespace {
75 enum MenuId
76 {
77 MID_UNLOCK_TASK_PANEL = 1,
78 MID_LOCK_TASK_PANEL,
79 MID_CUSTOMIZATION,

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

88 SidebarDockingWindow* pParentWindow,
89 const cssu::Reference<css::frame::XFrame>& rxFrame)
90 : SidebarControllerInterfaceBase(m_aMutex),
91 mpCurrentDeck(),
92 mpParentWindow(pParentWindow),
93 mpTabBar(new TabBar(
94 mpParentWindow,
95 rxFrame,
83namespace sfx2 { namespace sidebar {
84
85namespace {
86 enum MenuId
87 {
88 MID_UNLOCK_TASK_PANEL = 1,
89 MID_LOCK_TASK_PANEL,
90 MID_CUSTOMIZATION,

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

99 SidebarDockingWindow* pParentWindow,
100 const cssu::Reference<css::frame::XFrame>& rxFrame)
101 : SidebarControllerInterfaceBase(m_aMutex),
102 mpCurrentDeck(),
103 mpParentWindow(pParentWindow),
104 mpTabBar(new TabBar(
105 mpParentWindow,
106 rxFrame,
96 ::boost::bind(&SidebarController::SwitchToDeck, this, _1),
107 ::boost::bind(&SidebarController::OpenThenSwitchToDeck, this, _1),
97 ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2,_3))),
98 mxFrame(rxFrame),
99 maCurrentContext(OUString(), OUString()),
100 msCurrentDeckId(A2S("PropertyDeck")),
101 maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)),
102 maContextChangeUpdate(::boost::bind(&SidebarController::UpdateConfigurations, this)),
108 ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2,_3))),
109 mxFrame(rxFrame),
110 maCurrentContext(OUString(), OUString()),
111 msCurrentDeckId(A2S("PropertyDeck")),
112 maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)),
113 maContextChangeUpdate(::boost::bind(&SidebarController::UpdateConfigurations, this)),
103 mbIsDeckClosed(false),
104 mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width())
114 mbIsDeckRequestedOpen(),
115 mbIsDeckOpen(),
116 mbCanDeckBeOpened(true),
117 mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()),
118 mxReadOnlyModeDispatch(),
119 mbIsDocumentReadOnly(false),
120 mpSplitWindow(NULL),
121 mnWidthOnSplitterButtonDown(0),
122 mpCloseIndicator()
105{
106 if (pParentWindow == NULL)
107 {
108 OSL_ASSERT(pParentWindow!=NULL);
109 return;
110 }
111
112 // Listen for context change events.

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

121 // Listen for window events.
122 mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler));
123
124 // Listen for theme property changes.
125 Theme::GetPropertySet()->addPropertyChangeListener(
126 A2S(""),
127 static_cast<css::beans::XPropertyChangeListener*>(this));
128
123{
124 if (pParentWindow == NULL)
125 {
126 OSL_ASSERT(pParentWindow!=NULL);
127 return;
128 }
129
130 // Listen for context change events.

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

139 // Listen for window events.
140 mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler));
141
142 // Listen for theme property changes.
143 Theme::GetPropertySet()->addPropertyChangeListener(
144 A2S(""),
145 static_cast<css::beans::XPropertyChangeListener*>(this));
146
147 // Get the dispatch object as preparation to listen for changes of
148 // the read-only state.
149 const util::URL aURL (GetURL(gsReadOnlyCommandName));
150 mxReadOnlyModeDispatch = GetDispatch(aURL);
151 if (mxReadOnlyModeDispatch.is())
152 mxReadOnlyModeDispatch->addStatusListener(this, aURL);
153
129 SwitchToDeck(A2S("default"));
130}
131
132
133
134
135SidebarController::~SidebarController (void)
136{

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

145
146 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
147 css::ui::ContextChangeEventMultiplexer::get(
148 ::comphelper::getProcessComponentContext()));
149 if (xMultiplexer.is())
150 xMultiplexer->removeAllContextChangeEventListeners(
151 static_cast<css::ui::XContextChangeEventListener*>(this));
152
154 SwitchToDeck(A2S("default"));
155}
156
157
158
159
160SidebarController::~SidebarController (void)
161{

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

170
171 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
172 css::ui::ContextChangeEventMultiplexer::get(
173 ::comphelper::getProcessComponentContext()));
174 if (xMultiplexer.is())
175 xMultiplexer->removeAllContextChangeEventListeners(
176 static_cast<css::ui::XContextChangeEventListener*>(this));
177
178 if (mxReadOnlyModeDispatch.is())
179 mxReadOnlyModeDispatch->removeStatusListener(this, GetURL(gsReadOnlyCommandName));
180 if (mpSplitWindow != NULL)
181 {
182 mpSplitWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler));
183 mpSplitWindow = NULL;
184 }
185
153 if (mpParentWindow != NULL)
154 {
155 mpParentWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler));
156 mpParentWindow = NULL;
157 }
158
159 if (mpCurrentDeck)
160 {

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

206 (void)rEvent;
207
208 maPropertyChangeForwarder.RequestCall();
209}
210
211
212
213
186 if (mpParentWindow != NULL)
187 {
188 mpParentWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler));
189 mpParentWindow = NULL;
190 }
191
192 if (mpCurrentDeck)
193 {

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

239 (void)rEvent;
240
241 maPropertyChangeForwarder.RequestCall();
242}
243
244
245
246
247void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEvent& rEvent)
248 throw(cssu::RuntimeException)
249{
250 bool bIsReadWrite (true);
251 if (rEvent.IsEnabled)
252 rEvent.State >>= bIsReadWrite;
253
254 if (mbIsDocumentReadOnly != !bIsReadWrite)
255 {
256 mbIsDocumentReadOnly = !bIsReadWrite;
257
258 // Force the current deck to update its panel list.
259 SwitchToDeck(msCurrentDeckId);
260 }
261}
262
263
264
265
214void SAL_CALL SidebarController::requestLayout (void)
215 throw(cssu::RuntimeException)
216{
217 if (mpCurrentDeck)
218 mpCurrentDeck->RequestLayout();
219 RestrictWidth();
220}
221

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

240 return;
241 }
242
243 Window* pParentWindow = mpTabBar->GetParent();
244
245 const sal_Int32 nWidth (pParentWindow->GetSizePixel().Width());
246 const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height());
247
266void SAL_CALL SidebarController::requestLayout (void)
267 throw(cssu::RuntimeException)
268{
269 if (mpCurrentDeck)
270 mpCurrentDeck->RequestLayout();
271 RestrictWidth();
272}
273

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

292 return;
293 }
294
295 Window* pParentWindow = mpTabBar->GetParent();
296
297 const sal_Int32 nWidth (pParentWindow->GetSizePixel().Width());
298 const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height());
299
300 mbIsDeckOpen = (nWidth > TabBar::GetDefaultWidth());
301
302 if (mnSavedSidebarWidth <= 0)
303 mnSavedSidebarWidth = nWidth;
304
305 bool bIsDeckVisible;
306 if (mbCanDeckBeOpened)
307 {
308 const bool bIsOpening (nWidth > mnWidthOnSplitterButtonDown);
309 if (bIsOpening)
310 bIsDeckVisible = nWidth >= TabBar::GetDefaultWidth() + gnWidthOpenThreshold;
311 else
312 bIsDeckVisible = nWidth >= TabBar::GetDefaultWidth() + gnWidthCloseThreshold;
313 mbIsDeckRequestedOpen = bIsDeckVisible;
314 UpdateCloseIndicator(!bIsDeckVisible);
315 }
316 else
317 bIsDeckVisible = false;
318
248 // Place the deck.
249 if (mpCurrentDeck)
250 {
319 // Place the deck.
320 if (mpCurrentDeck)
321 {
251 mpCurrentDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight);
252 mpCurrentDeck->Show();
253 mpCurrentDeck->RequestLayout();
322 if (bIsDeckVisible)
323 {
324 mpCurrentDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight);
325 mpCurrentDeck->Show();
326 mpCurrentDeck->RequestLayout();
327 }
328 else
329 mpCurrentDeck->Hide();
254 }
255
256 // Place the tab bar.
257 mpTabBar->SetPosSizePixel(nWidth-TabBar::GetDefaultWidth(),0,TabBar::GetDefaultWidth(),nHeight);
258 mpTabBar->Show();
259
260 // Determine if the closer of the deck can be shown.
261 if (mpCurrentDeck)
262 {
263 DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
264 if (pTitleBar != NULL && pTitleBar->IsVisible())
265 pTitleBar->SetCloserVisible(CanModifyChildWindowWidth());
266 }
267
330 }
331
332 // Place the tab bar.
333 mpTabBar->SetPosSizePixel(nWidth-TabBar::GetDefaultWidth(),0,TabBar::GetDefaultWidth(),nHeight);
334 mpTabBar->Show();
335
336 // Determine if the closer of the deck can be shown.
337 if (mpCurrentDeck)
338 {
339 DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
340 if (pTitleBar != NULL && pTitleBar->IsVisible())
341 pTitleBar->SetCloserVisible(CanModifyChildWindowWidth());
342 }
343
268 if (nWidth > TabBar::GetDefaultWidth())
269 mnSavedSidebarWidth = nWidth;
270
271 RestrictWidth();
344 RestrictWidth();
272#ifdef VERBOSE
273 if (mpCurrentDeck)
345}
346
347
348
349
350void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth)
351{
352 if ( ! mbIsDeckRequestedOpen)
353 return;
354
355 if (mbIsDeckRequestedOpen.get())
356 {
357 // Deck became large enough to be shown. Show it.
358 mnSavedSidebarWidth = nNewWidth;
359 RequestOpenDeck();
360 }
361 else
274 {
362 {
275 mpCurrentDeck->PrintWindowTree();
276 sal_Int32 nPanelIndex (0);
277 for (SharedPanelContainer::const_iterator
278 iPanel(mpCurrentDeck->GetPanels().begin()),
279 iEnd(mpCurrentDeck->GetPanels().end());
280 iPanel!=iEnd;
281 ++iPanel,++nPanelIndex)
282 {
283 OSL_TRACE("panel %d:", nPanelIndex);
284 (*iPanel)->PrintWindowTree();
285 }
363 // Deck became too small. Close it completely.
364 // If window is wider than the tab bar then mark the deck as being visible, even when it its not.
365 // This is to trigger an adjustment of the width to the width of the tab bar.
366 mbIsDeckOpen = true;
367 RequestCloseDeck();
368
369 if (mnWidthOnSplitterButtonDown > TabBar::GetDefaultWidth())
370 mnSavedSidebarWidth = mnWidthOnSplitterButtonDown;
286 }
371 }
287#endif
288}
289
290
291
292
293void SidebarController::UpdateConfigurations (void)
294{
295 if (maCurrentContext != maRequestedContext)
296 {
297 maCurrentContext = maRequestedContext;
298
372}
373
374
375
376
377void SidebarController::UpdateConfigurations (void)
378{
379 if (maCurrentContext != maRequestedContext)
380 {
381 maCurrentContext = maRequestedContext;
382
299 // Notify the tab bar about the updated set of decks.
300 ResourceManager::IdContainer aDeckIds;
383 // Find the set of decks that could be displayed for the new context.
384 ResourceManager::DeckContextDescriptorContainer aDecks;
301 ResourceManager::Instance().GetMatchingDecks (
385 ResourceManager::Instance().GetMatchingDecks (
302 aDeckIds,
386 aDecks,
303 maCurrentContext,
387 maCurrentContext,
388 mbIsDocumentReadOnly,
304 mxFrame);
389 mxFrame);
305 mpTabBar->SetDecks(aDeckIds);
390 mpTabBar->SetDecks(aDecks);
306
391
307 // Check if the current deck is among the matching decks.
308 bool bCurrentDeckMatches (false);
309 for (ResourceManager::IdContainer::const_iterator
310 iDeck(aDeckIds.begin()),
311 iEnd(aDeckIds.end());
392 // Notify the tab bar about the updated set of decks.
393 mpTabBar->SetDecks(aDecks);
394
395 // Find the new deck. By default that is the same as the old
396 // one. If that is not set or not enabled, then choose the
397 // first enabled deck.
398 OUString sNewDeckId;
399 for (ResourceManager::DeckContextDescriptorContainer::const_iterator
400 iDeck(aDecks.begin()),
401 iEnd(aDecks.end());
312 iDeck!=iEnd;
313 ++iDeck)
314 {
402 iDeck!=iEnd;
403 ++iDeck)
404 {
315 if (iDeck->equals(msCurrentDeckId))
405 if (iDeck->mbIsEnabled)
316 {
406 {
317 bCurrentDeckMatches = true;
318 break;
407 if (iDeck->msId.equals(msCurrentDeckId))
408 {
409 sNewDeckId = msCurrentDeckId;
410 break;
411 }
412 else if (sNewDeckId.getLength() == 0)
413 sNewDeckId = iDeck->msId;
319 }
320 }
321
414 }
415 }
416
322 DeckDescriptor const* pDeckDescriptor = NULL;
323 if ( ! bCurrentDeckMatches)
324 pDeckDescriptor = ResourceManager::Instance().GetBestMatchingDeck(maCurrentContext, mxFrame);
325 else
326 pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(msCurrentDeckId);
327 if (pDeckDescriptor != NULL)
417 if (sNewDeckId.getLength() == 0)
328 {
418 {
329 msCurrentDeckId = pDeckDescriptor->msId;
330 SwitchToDeck(*pDeckDescriptor, maCurrentContext);
331
419 // We did not find a valid deck.
420 RequestCloseDeck();
421 return;
422
332 // Tell the tab bar to highlight the button associated
333 // with the deck.
423 // Tell the tab bar to highlight the button associated
424 // with the deck.
334 mpTabBar->HighlightDeck(msCurrentDeckId);
425 mpTabBar->HighlightDeck(sNewDeckId);
335 }
426 }
427
428 msCurrentDeckId = sNewDeckId;
429 SwitchToDeck(
430 *ResourceManager::Instance().GetDeckDescriptor(sNewDeckId),
431 maCurrentContext);
336
337#ifdef DEBUG
338 // Show the context name in the deck title bar.
339 if (mpCurrentDeck)
340 {
341 DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
342 if (pTitleBar != NULL)
343 pTitleBar->SetTitle(msCurrentDeckTitle+A2S(" (")+maCurrentContext.msContext+A2S(")"));
344 }
345#endif
346 }
347}
348
349
350
351
432
433#ifdef DEBUG
434 // Show the context name in the deck title bar.
435 if (mpCurrentDeck)
436 {
437 DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
438 if (pTitleBar != NULL)
439 pTitleBar->SetTitle(msCurrentDeckTitle+A2S(" (")+maCurrentContext.msContext+A2S(")"));
440 }
441#endif
442 }
443}
444
445
446
447
448void SidebarController::OpenThenSwitchToDeck (
449 const ::rtl::OUString& rsDeckId)
450{
451 RequestOpenDeck();
452 SwitchToDeck(rsDeckId);
453}
454
455
456
457
352void SidebarController::SwitchToDeck (
353 const ::rtl::OUString& rsDeckId)
354{
458void SidebarController::SwitchToDeck (
459 const ::rtl::OUString& rsDeckId)
460{
355 if ( ! msCurrentDeckId.equals(rsDeckId) || mbIsDeckClosed)
461 if ( ! msCurrentDeckId.equals(rsDeckId) || ! mbIsDeckOpen)
356 {
357 const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId);
358 if (pDeckDescriptor != NULL)
359 SwitchToDeck(*pDeckDescriptor, maCurrentContext);
360 }
361}
362
363

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

377 {
378 mpCurrentDeck->Dispose();
379 mpCurrentDeck.reset();
380 }
381
382 msCurrentDeckId = rDeckDescriptor.msId;
383 }
384
462 {
463 const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId);
464 if (pDeckDescriptor != NULL)
465 SwitchToDeck(*pDeckDescriptor, maCurrentContext);
466 }
467}
468
469

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

483 {
484 mpCurrentDeck->Dispose();
485 mpCurrentDeck.reset();
486 }
487
488 msCurrentDeckId = rDeckDescriptor.msId;
489 }
490
385 // Reopen the deck when necessary.
386 OpenDeck();
387
388 // Determine the panels to display in the deck.
389 ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors;
390 ResourceManager::Instance().GetMatchingPanels(
391 aPanelContextDescriptors,
392 rContext,
393 rDeckDescriptor.msId,
394 mxFrame);
395

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

415
416 if (mpCurrentDeck
417 && ArePanelSetsEqual(mpCurrentDeck->GetPanels(), aPanelContextDescriptors))
418 {
419 // Requested set of panels is identical to the current set of
420 // panels => Nothing to do.
421 return;
422 }
491 // Determine the panels to display in the deck.
492 ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors;
493 ResourceManager::Instance().GetMatchingPanels(
494 aPanelContextDescriptors,
495 rContext,
496 rDeckDescriptor.msId,
497 mxFrame);
498

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

518
519 if (mpCurrentDeck
520 && ArePanelSetsEqual(mpCurrentDeck->GetPanels(), aPanelContextDescriptors))
521 {
522 // Requested set of panels is identical to the current set of
523 // panels => Nothing to do.
524 return;
525 }
423
526
527 // When the document is read-only, check if there are any panels that can still be displayed.
528 if (mbIsDocumentReadOnly)
529 {
530 }
531
532
424 // Provide a configuration and Deck object.
425 if ( ! mpCurrentDeck)
426 {
427 mpCurrentDeck.reset(
428 new Deck(
429 rDeckDescriptor,
430 mpParentWindow,
533 // Provide a configuration and Deck object.
534 if ( ! mpCurrentDeck)
535 {
536 mpCurrentDeck.reset(
537 new Deck(
538 rDeckDescriptor,
539 mpParentWindow,
431 ::boost::bind(&SidebarController::CloseDeck, this)));
540 ::boost::bind(&SidebarController::RequestCloseDeck, this)));
432 msCurrentDeckTitle = rDeckDescriptor.msTitle;
433 }
434 if ( ! mpCurrentDeck)
435 return;
436
437 // Update the panel list.
438 const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
439 SharedPanelContainer aNewPanels;
440 const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels());
441 aNewPanels.resize(nNewPanelCount);
442 sal_Int32 nWriteIndex (0);
443 bool bHasPanelSetChanged (false);
444 for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex)
445 {
446 const ResourceManager::PanelContextDescriptor& rPanelContexDescriptor (
447 aPanelContextDescriptors[nReadIndex]);
448
541 msCurrentDeckTitle = rDeckDescriptor.msTitle;
542 }
543 if ( ! mpCurrentDeck)
544 return;
545
546 // Update the panel list.
547 const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
548 SharedPanelContainer aNewPanels;
549 const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels());
550 aNewPanels.resize(nNewPanelCount);
551 sal_Int32 nWriteIndex (0);
552 bool bHasPanelSetChanged (false);
553 for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex)
554 {
555 const ResourceManager::PanelContextDescriptor& rPanelContexDescriptor (
556 aPanelContextDescriptors[nReadIndex]);
557
558 // Determine if the panel can be displayed.
559 const bool bIsPanelVisible (!mbIsDocumentReadOnly || rPanelContexDescriptor.mbShowForReadOnlyDocuments);
560 if ( ! bIsPanelVisible)
561 continue;
562
449 // Find the corresponding panel among the currently active
450 // panels.
451 SharedPanelContainer::const_iterator iPanel (::std::find_if(
452 rCurrentPanels.begin(),
453 rCurrentPanels.end(),
454 ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId))));
455 if (iPanel != rCurrentPanels.end())
456 {

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

504
505
506
507
508bool SidebarController::ArePanelSetsEqual (
509 const SharedPanelContainer& rCurrentPanels,
510 const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels)
511{
563 // Find the corresponding panel among the currently active
564 // panels.
565 SharedPanelContainer::const_iterator iPanel (::std::find_if(
566 rCurrentPanels.begin(),
567 rCurrentPanels.end(),
568 ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId))));
569 if (iPanel != rCurrentPanels.end())
570 {

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

618
619
620
621
622bool SidebarController::ArePanelSetsEqual (
623 const SharedPanelContainer& rCurrentPanels,
624 const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels)
625{
512#ifdef VERBOSE
513 OSL_TRACE("current panel list:");
514 for (SharedPanelContainer::const_iterator
515 iPanel(rCurrentPanels.begin()),
516 iEnd(rCurrentPanels.end());
517 iPanel!=iEnd;
518 ++iPanel)
519 {
520 OSL_TRACE(" panel %s", S2A((*iPanel)->GetId()));
521 }
522
523 OSL_TRACE("requested panels: ");
524 for (ResourceManager::PanelContextDescriptorContainer::const_iterator
525 iId(rRequestedPanels.begin()),
526 iEnd(rRequestedPanels.end());
527 iId!=iEnd;
528 ++iId)
529 {
530 OSL_TRACE(" panel %s", S2A(iId->msId));
531 }
532#endif
533
534 if (rCurrentPanels.size() != rRequestedPanels.size())
535 return false;
536 for (sal_Int32 nIndex=0,nCount=rCurrentPanels.size(); nIndex<nCount; ++nIndex)
537 {
538 if (rCurrentPanels[nIndex] == NULL)
539 return false;
540 if ( ! rCurrentPanels[nIndex]->GetId().equals(rRequestedPanels[nIndex].msId))
541 return false;
626 if (rCurrentPanels.size() != rRequestedPanels.size())
627 return false;
628 for (sal_Int32 nIndex=0,nCount=rCurrentPanels.size(); nIndex<nCount; ++nIndex)
629 {
630 if (rCurrentPanels[nIndex] == NULL)
631 return false;
632 if ( ! rCurrentPanels[nIndex]->GetId().equals(rRequestedPanels[nIndex].msId))
633 return false;
634
635 // Check if the panels still can be displayed. This may not be the case when
636 // the document just become rea-only.
637 if (mbIsDocumentReadOnly && ! rRequestedPanels[nIndex].mbShowForReadOnlyDocuments)
638 return false;
542 }
543 return true;
544}
545
546
547
548
549SharedPanel SidebarController::CreatePanel (

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

629 }
630}
631
632
633
634
635IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent)
636{
639 }
640 return true;
641}
642
643
644
645
646SharedPanel SidebarController::CreatePanel (

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

726 }
727}
728
729
730
731
732IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent)
733{
637 if (pEvent != NULL)
734 if (pEvent==NULL)
735 return sal_False;
736
737 if (pEvent->GetWindow() == mpParentWindow)
638 {
639 switch (pEvent->GetId())
640 {
738 {
739 switch (pEvent->GetId())
740 {
641 case VCLEVENT_WINDOW_GETFOCUS:
642 case VCLEVENT_WINDOW_LOSEFOCUS:
643 break;
644
645 case VCLEVENT_WINDOW_SHOW:
646 case VCLEVENT_WINDOW_RESIZE:
647 NotifyResize();
648 break;
649
650 case VCLEVENT_WINDOW_DATACHANGED:
651 // Force an update of deck and tab bar to reflect
652 // changes in theme (high contrast mode).
653 Theme::HandleDataChange();
654 UpdateTitleBarIcons();
655 mpParentWindow->Invalidate();
656 break;
657
658 case SFX_HINT_DYING:
659 dispose();
660 break;
661
741 case VCLEVENT_WINDOW_SHOW:
742 case VCLEVENT_WINDOW_RESIZE:
743 NotifyResize();
744 break;
745
746 case VCLEVENT_WINDOW_DATACHANGED:
747 // Force an update of deck and tab bar to reflect
748 // changes in theme (high contrast mode).
749 Theme::HandleDataChange();
750 UpdateTitleBarIcons();
751 mpParentWindow->Invalidate();
752 break;
753
754 case SFX_HINT_DYING:
755 dispose();
756 break;
757
758 case VCLEVENT_WINDOW_PAINT:
759 OSL_TRACE("Paint");
760 break;
761
662 default:
663 break;
664 }
665 }
762 default:
763 break;
764 }
765 }
766 else if (pEvent->GetWindow()==mpSplitWindow && mpSplitWindow!=NULL)
767 {
768 switch (pEvent->GetId())
769 {
770 case VCLEVENT_WINDOW_MOUSEBUTTONDOWN:
771 mnWidthOnSplitterButtonDown = mpParentWindow->GetSizePixel().Width();
772 break;
666
773
774 case VCLEVENT_WINDOW_MOUSEBUTTONUP:
775 {
776 ProcessNewWidth(mpParentWindow->GetSizePixel().Width());
777 mnWidthOnSplitterButtonDown = 0;
778 break;
779 }
780
781 case SFX_HINT_DYING:
782 dispose();
783 break;
784 }
785 }
786
667 return sal_True;
668}
669
670
671
672
673void SidebarController::ShowPopupMenu (
674 const Rectangle& rButtonBox,

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

686
687
688
689
690void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const
691{
692 try
693 {
787 return sal_True;
788}
789
790
791
792
793void SidebarController::ShowPopupMenu (
794 const Rectangle& rButtonBox,

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

806
807
808
809
810void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const
811{
812 try
813 {
694 util::URL aURL;
695 aURL.Complete = rsMenuCommand;
696
697 const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory());
698 const Reference<util::XURLTransformer> xParser (
699 aComponentContext.createComponent("com.sun.star.util.URLTransformer"),
700 UNO_QUERY_THROW);
701 xParser->parseStrict(aURL);
702 Reference<frame::XDispatchProvider> xProvider (mxFrame, UNO_QUERY_THROW);
703 Reference<frame::XDispatch> xDispatch (xProvider->queryDispatch(aURL, OUString(), 0));
814 const util::URL aURL (GetURL(rsMenuCommand));
815 Reference<frame::XDispatch> xDispatch (GetDispatch(aURL));
704 if (xDispatch.is())
705 xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>());
706 }
707 catch(Exception& rException)
708 {
709 OSL_TRACE("caught exception: %s",
710 OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr());
711 }
712}
713
714
715
716
816 if (xDispatch.is())
817 xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>());
818 }
819 catch(Exception& rException)
820 {
821 OSL_TRACE("caught exception: %s",
822 OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr());
823 }
824}
825
826
827
828
829util::URL SidebarController::GetURL (const ::rtl::OUString& rsCommand) const
830{
831 util::URL aURL;
832 aURL.Complete = rsCommand;
833
834 const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory());
835 const Reference<util::XURLTransformer> xParser (
836 aComponentContext.createComponent("com.sun.star.util.URLTransformer"),
837 UNO_QUERY_THROW);
838 xParser->parseStrict(aURL);
839
840 return aURL;
841}
842
843
844
845
846Reference<frame::XDispatch> SidebarController::GetDispatch (const util::URL& rURL) const
847{
848 Reference<frame::XDispatchProvider> xProvider (mxFrame, UNO_QUERY_THROW);
849 Reference<frame::XDispatch> xDispatch (xProvider->queryDispatch(rURL, OUString(), 0));
850 return xDispatch;
851}
852
853
854
855
717::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu (
718 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData,
719 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const
720{
721 ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu());
722 FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow());
723 if (pMenuWindow != NULL)
724 {

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

822 }
823
824 return 1;
825}
826
827
828
829
856::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu (
857 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData,
858 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const
859{
860 ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu());
861 FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow());
862 if (pMenuWindow != NULL)
863 {

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

961 }
962
963 return 1;
964}
965
966
967
968
830void SidebarController::CloseDeck (void)
969void SidebarController::RequestCloseDeck (void)
831{
970{
832 if ( ! mbIsDeckClosed)
833 {
834 mbIsDeckClosed = true;
835 if ( ! mpParentWindow->IsFloatingMode())
836 mnSavedSidebarWidth = SetChildWindowWidth(TabBar::GetDefaultWidth());
837 mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE);
838
839 if (mpCurrentDeck)
840 mpCurrentDeck->Hide();
841
842 NotifyResize();
843 }
971 mbIsDeckRequestedOpen = false;
972 UpdateDeckOpenState();
844}
845
846
847
848
973}
974
975
976
977
849void SidebarController::OpenDeck (void)
978void SidebarController::RequestOpenDeck (void)
850{
979{
851 if (mbIsDeckClosed)
852 {
853 mbIsDeckClosed = false;
854 SetChildWindowWidth(mnSavedSidebarWidth);
980 mbIsDeckRequestedOpen = true;
981 UpdateDeckOpenState();
982}
855
983
856 if (mpCurrentDeck)
857 mpCurrentDeck->Show();
858
984
985
986
987void SidebarController::UpdateDeckOpenState (void)
988{
989 if ( ! mbIsDeckRequestedOpen)
990 // No state requested.
991 return;
992
993 // Update (change) the open state when it either has not yet been initialized
994 // or when its value differs from the requested state.
995 if ( ! mbIsDeckOpen
996 || mbIsDeckOpen.get() != mbIsDeckRequestedOpen.get())
997 {
998 if (mbIsDeckRequestedOpen.get())
999 {
1000 if (mnSavedSidebarWidth <= TabBar::GetDefaultWidth())
1001 SetChildWindowWidth(SidebarChildWindow::GetDefaultWidth(mpParentWindow));
1002 else
1003 SetChildWindowWidth(mnSavedSidebarWidth);
1004 }
1005 else
1006 {
1007 if ( ! mpParentWindow->IsFloatingMode())
1008 mnSavedSidebarWidth = SetChildWindowWidth(TabBar::GetDefaultWidth());
1009 if (mnWidthOnSplitterButtonDown > TabBar::GetDefaultWidth())
1010 mnSavedSidebarWidth = mnWidthOnSplitterButtonDown;
1011 mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE);
1012 }
1013
1014 mbIsDeckOpen = mbIsDeckRequestedOpen.get();
1015 if (mbIsDeckOpen.get() && mpCurrentDeck)
1016 mpCurrentDeck->Show(mbIsDeckOpen.get());
859 NotifyResize();
860 }
861}
862
863
864
865
866FocusManager& SidebarController::GetFocusManager (void)
867{
868 return maFocusManager;
869}
870
871
872
873
1017 NotifyResize();
1018 }
1019}
1020
1021
1022
1023
1024FocusManager& SidebarController::GetFocusManager (void)
1025{
1026 return maFocusManager;
1027}
1028
1029
1030
1031
874bool SidebarController::CanModifyChildWindowWidth (void) const
1032bool SidebarController::CanModifyChildWindowWidth (void)
875{
1033{
876 SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent());
1034 SfxSplitWindow* pSplitWindow = GetSplitWindow();
877 if (pSplitWindow == NULL)
1035 if (pSplitWindow == NULL)
878 {
879 return 0;
880 }
1036 return false;
881
882 sal_uInt16 nRow (0xffff);
883 sal_uInt16 nColumn (0xffff);
884 pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow);
885
886 sal_uInt16 nRowCount (pSplitWindow->GetWindowCount(nColumn));
887
1037
1038 sal_uInt16 nRow (0xffff);
1039 sal_uInt16 nColumn (0xffff);
1040 pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow);
1041
1042 sal_uInt16 nRowCount (pSplitWindow->GetWindowCount(nColumn));
1043
888 return nRowCount == 1;
1044 return nRowCount==1;
889}
890
891
892
893
894sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth)
895{
1045}
1046
1047
1048
1049
1050sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth)
1051{
896 SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent());
1052 SfxSplitWindow* pSplitWindow = GetSplitWindow();
897 if (pSplitWindow == NULL)
898 return 0;
899
900 sal_uInt16 nRow (0xffff);
901 sal_uInt16 nColumn (0xffff);
902 pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow);
903 const long nColumnWidth (pSplitWindow->GetLineSize(nColumn));
904
905 Window* pWindow = mpParentWindow;
906 const Point aWindowPosition (pWindow->GetPosPixel());
907 const Size aWindowSize (pWindow->GetSizePixel());
908
909 pSplitWindow->MoveWindow(
910 mpParentWindow,
911 Size(nNewWidth, aWindowSize.Height()),
912 nColumn,
913 nRow);
1053 if (pSplitWindow == NULL)
1054 return 0;
1055
1056 sal_uInt16 nRow (0xffff);
1057 sal_uInt16 nColumn (0xffff);
1058 pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow);
1059 const long nColumnWidth (pSplitWindow->GetLineSize(nColumn));
1060
1061 Window* pWindow = mpParentWindow;
1062 const Point aWindowPosition (pWindow->GetPosPixel());
1063 const Size aWindowSize (pWindow->GetSizePixel());
1064
1065 pSplitWindow->MoveWindow(
1066 mpParentWindow,
1067 Size(nNewWidth, aWindowSize.Height()),
1068 nColumn,
1069 nRow);
914
1070 static_cast<SplitWindow*>(pSplitWindow)->Split();
1071
915 return static_cast<sal_Int32>(nColumnWidth);
916}
917
918
919
920
921void SidebarController::RestrictWidth (void)
922{
1072 return static_cast<sal_Int32>(nColumnWidth);
1073}
1074
1075
1076
1077
1078void SidebarController::RestrictWidth (void)
1079{
923 SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent());
1080 SfxSplitWindow* pSplitWindow = GetSplitWindow();
924 if (pSplitWindow != NULL)
925 {
926 const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow));
927 const sal_uInt16 nSetId (pSplitWindow->GetSet(nId));
1081 if (pSplitWindow != NULL)
1082 {
1083 const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow));
1084 const sal_uInt16 nSetId (pSplitWindow->GetSet(nId));
928 // Minimum width is always that of the tabbar.
929 const sal_Int32 nMinimumWidth (TabBar::GetDefaultWidth());
930 // Maximum width depends on whether the deck is open or closed.
931 const sal_Int32 nMaximumWidth (
932 mbIsDeckClosed
933 ? TabBar::GetDefaultWidth()
934 : 400);
935 pSplitWindow->SetItemSizeRange(
936 nSetId,
1085 pSplitWindow->SetItemSizeRange(
1086 nSetId,
937 Range(nMinimumWidth, nMaximumWidth));
938 if (nMinimumWidth == nMaximumWidth)
939 pSplitWindow->SetItemSize(nSetId, nMinimumWidth);
1087 Range(TabBar::GetDefaultWidth(), gnMaximumSidebarWidth));
940 }
941}
942
943
944
945
1088 }
1089}
1090
1091
1092
1093
1094SfxSplitWindow* SidebarController::GetSplitWindow (void)
1095{
1096 if (mpSplitWindow == NULL)
1097 {
1098 if (mpParentWindow != NULL)
1099 {
1100 mpSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent());
1101 if (mpSplitWindow != NULL)
1102 mpSplitWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler));
1103 }
1104 }
1105
1106 return mpSplitWindow;
1107}
1108
1109
1110
1111
1112void SidebarController::UpdateCloseIndicator (const bool bCloseAfterDrag)
1113{
1114 if (mpParentWindow == NULL)
1115 return;
1116
1117 if (bCloseAfterDrag)
1118 {
1119 // Make sure that the indicator exists.
1120 if ( ! mpCloseIndicator)
1121 {
1122 mpCloseIndicator.reset(new FixedImage(mpParentWindow));
1123 FixedImage* pFixedImage = static_cast<FixedImage*>(mpCloseIndicator.get());
1124 const Image aImage (Theme::GetImage(Theme::Image_CloseIndicator));
1125 pFixedImage->SetImage(aImage);
1126 pFixedImage->SetSizePixel(aImage.GetSizePixel());
1127 pFixedImage->SetBackground(Theme::GetWallpaper(Theme::Paint_DeckBackground));
1128 }
1129
1130 // Place and show the indicator.
1131 const Size aWindowSize (mpParentWindow->GetSizePixel());
1132 const Size aImageSize (mpCloseIndicator->GetSizePixel());
1133 mpCloseIndicator->SetPosPixel(
1134 Point(
1135 aWindowSize.Width() - TabBar::GetDefaultWidth() - aImageSize.Width(),
1136 (aWindowSize.Height() - aImageSize.Height())/2));
1137 mpCloseIndicator->Show();
1138 }
1139 else
1140 {
1141 // Hide but don't delete the indicator.
1142 if (mpCloseIndicator)
1143 mpCloseIndicator->Hide();
1144 }
1145}
1146
1147
1148
1149
946void SidebarController::UpdateTitleBarIcons (void)
947{
948 if ( ! mpCurrentDeck)
949 return;
950
951 const bool bIsHighContrastModeActive (Theme::IsHighContrastMode());
952 const ResourceManager& rResourceManager (ResourceManager::Instance());
953

--- 35 unchanged lines hidden ---
1150void SidebarController::UpdateTitleBarIcons (void)
1151{
1152 if ( ! mpCurrentDeck)
1153 return;
1154
1155 const bool bIsHighContrastModeActive (Theme::IsHighContrastMode());
1156 const ResourceManager& rResourceManager (ResourceManager::Instance());
1157

--- 35 unchanged lines hidden ---