Kaydet (Commit) 536c259c authored tarafından Laurent Godard's avatar Laurent Godard Kaydeden (comit) Katarina Behrens

tdf#67770 store sidebar elements states

deck & panel states at user registry level
when disposing a sidebar

if a shared deck (with "any" context application) is modified,
it apply to all applications (eg. Gallery between calc and writer); TODO ?

clean ResourceManager Get/Set const/non-const

add panels when deck is created & refactoring

* macro example

Sub Main

controller = thisComponent.currentcontroller
sidebar = thisComponent.currentcontroller.getSidebar()

sidebar.setVisible(true)

decks = sidebar.getdecks()
deck = decks.getByName("PropertyDeck")

deck.activate(true)
deck.setTitle("new deck title")
deck.moveLast()

panels = deck.getPanels()
panel = panels.getByName("TextPropertyPanel")

panel.setTitle("new panel title")
panel.expand(true) ' expand and collapse other
panel.moveLast()

End Sub

Change-Id: I2552000af92a366ebb51a479962a094b72e400b6
Reviewed-on: https://gerrit.libreoffice.org/17992Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
Tested-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst ce6170da
......@@ -55,6 +55,8 @@ public:
const bool bIsInitiallyVisible,
const ::rtl::OUString& rsMenuCommand);
const ::std::vector<Entry>& GetEntries() const {return maEntries;};
private:
::std::vector<Entry> maEntries;
......
......@@ -94,6 +94,7 @@ private:
DECL_LINK_TYPED(HandleVerticalScrollBarChange, ScrollBar*, void);
bool ProcessWheelEvent(CommandEvent* pCommandEvent);
};
} } // end of namespace sfx2::sidebar
......
......@@ -42,6 +42,8 @@ public:
sal_Int32 mnOrderIndex;
bool mbExperimental;
OUString msNodeName; // some impress deck nodes names are different from their Id
VclPtr<Deck> mpDeck;
DeckDescriptor();
......
......@@ -41,6 +41,8 @@ public:
bool mbWantsCanvas;
bool mbExperimental;
OUString msNodeName; // some impress panel nodes names are different from their Id
PanelDescriptor();
PanelDescriptor (const PanelDescriptor& rPanelDescriptor);
~PanelDescriptor();
......
......@@ -43,30 +43,18 @@ public:
ResourceManager();
~ResourceManager();
static ResourceManager& Instance();
const DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId) const;
const PanelDescriptor* GetPanelDescriptor(const OUString& rsPanelId) const;
/** Excluded or include a deck from being displayed in the tab
bar.
Note that this value is not persistent.
The flag can not be set directly at a DeckDescriptor object
because the ResourceManager gives access to them only
read-only.
*/
void SetIsDeckEnabled(const OUString& rsDeckId, const bool bIsEnabled);
void SetDeckTitle(const OUString& rsDeckId, const OUString& sTitle);
void SetDeckToDescriptor(const OUString& rsDeckId, VclPtr<Deck> aDeck);
DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId);
void SetDeckOrderIndex(const OUString& rsDeckId, const sal_Int32 orderIndex);
void SetPanelOrderIndex(const OUString& rsPanelId, const sal_Int32 orderIndex);
const PanelDescriptor* GetPanelDescriptor(const OUString& rsPanelId) const;
PanelDescriptor* GetPanelDescriptor(const OUString& rsPanelId);
void UpdateModel(css::uno::Reference<css::frame::XModel> xModel);
void InitDeckContext(const Context& rContex);
void SaveDecksSettings(const Context& rContext);
void SaveDeckSettings(const DeckDescriptor* pDeckDesc);
void disposeDecks();
class DeckContextDescriptor
......@@ -100,7 +88,6 @@ public:
const css::uno::Reference<css::frame::XController>& rxController);
/** Remember the expansions state per panel and context.
This is not persistent past application end.
*/
void StorePanelExpansionState(const OUString& rsPanelId,
const bool bExpansionState,
......@@ -123,13 +110,19 @@ private:
static void ReadContextList(const utl::OConfigurationNode& rNode,
ContextList& rContextList,
const OUString& rsDefaultMenuCommand);
css::uno::Sequence<OUString> BuildContextList (ContextList rContextList, bool isDeckEnabled);
void ReadLegacyAddons(const css::uno::Reference<css::frame::XController>& rxController);
static utl::OConfigurationTreeRoot GetLegacyAddonRootNode(const OUString& rsModuleName);
static void GetToolPanelNodeNames(std::vector<OUString>& rMatchingNames,
const utl::OConfigurationTreeRoot& aRoot);
static bool IsDeckEnabled(const OUString& rsDeckId,
bool IsDeckEnabled(const OUString& rsDeckId,
const Context& rContext,
const css::uno::Reference<css::frame::XController>& rxController);
const DeckDescriptor* ImplGetDeckDescriptor(const OUString& rsDeckId) const;
const PanelDescriptor* ImplGetPanelDescriptor(const OUString& rsPanelId) const;
};
} } // end of namespace sfx2::sidebar
......
......@@ -151,7 +151,8 @@ public:
void SwitchToDeck ( const ::rtl::OUString& rsDeckId);
void SwitchToDefaultDeck();
void CreateDeck(const ::rtl::OUString& rDeckId);
void CreateDeck(const ::rtl::OUString& rDeckId, bool bForceCreate = false);
void CreatePanels(const ::rtl::OUString& rDeckId);
ResourceManager::DeckContextDescriptorContainer GetMatchingDecks();
ResourceManager::PanelContextDescriptorContainer GetMatchingPanels( const ::rtl::OUString& rDeckId);
......@@ -223,7 +224,8 @@ private:
const ::rtl::OUString& rsPanelId,
vcl::Window* pParentWindow,
const bool bIsInitiallyExpanded,
const Context& rContext);
const Context& rContext,
VclPtr<Deck> pDeck);
void SwitchToDeck (
const DeckDescriptor& rDeckDescriptor,
......
......@@ -132,8 +132,8 @@ void TabBar::SetDecks(const ResourceManager::DeckContextDescriptorContainer& rDe
rItem.mpButton = CreateTabItem(*pDescriptor);
rItem.mpButton->SetClickHdl(LINK(&rItem, TabBar::Item, HandleClick));
rItem.maDeckActivationFunctor = maDeckActivationFunctor;
rItem.mbIsHiddenByDefault = false;
rItem.mbIsHidden = ! pDescriptor->mbIsEnabled;
rItem.mbIsHiddenByDefault = rItem.mbIsHidden; // the default is the state while creating
rItem.mpButton->Enable(iDeck->mbIsEnabled);
}
......@@ -335,9 +335,10 @@ void TabBar::ToggleHideFlag (const sal_Int32 nIndex)
{
maItems[nIndex].mbIsHidden = ! maItems[nIndex].mbIsHidden;
pParentSidebarController->GetResourceManager()->SetIsDeckEnabled(
maItems[nIndex].msDeckId,
maItems[nIndex].mbIsHidden);
DeckDescriptor* pDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(maItems[nIndex].msDeckId);
if (pDeckDescriptor)
pDeckDescriptor->mbIsEnabled = ! maItems[nIndex].mbIsHidden;
Layout();
}
}
......@@ -351,6 +352,11 @@ void TabBar::RestoreHideFlags()
{
iItem->mbIsHidden = iItem->mbIsHiddenByDefault;
bNeedsLayout = true;
DeckDescriptor* pDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId);
if (pDeckDescriptor)
pDeckDescriptor->mbIsEnabled = ! iItem->mbIsHidden;
}
}
if (bNeedsLayout)
......
......@@ -67,15 +67,19 @@ void SAL_CALL SfxUnoDeck::setTitle( const OUString& newTitle )
SidebarController* pSidebarController = getSidebarController();
pSidebarController->CreateDeck(mDeckId);
Deck* pDeck = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck;
DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
DeckTitleBar* pTitleBar = pDeck->GetTitleBar();
pTitleBar->SetTitle(newTitle);
if (pDeckDescriptor)
{
Deck* pDeck = pDeckDescriptor->mpDeck;
DeckTitleBar* pTitleBar = pDeck->GetTitleBar();
pTitleBar->SetTitle(newTitle);
// update the ResourceManager
pSidebarController->GetResourceManager()->SetDeckTitle(mDeckId, newTitle);
pSidebarController->notifyDeckTitle(mDeckId);
pDeckDescriptor->msTitle = newTitle;
pDeckDescriptor->msHelpText = newTitle;
pSidebarController->notifyDeckTitle(mDeckId);
}
}
sal_Bool SAL_CALL SfxUnoDeck::isActive()
......@@ -129,10 +133,14 @@ void SAL_CALL SfxUnoDeck::setOrderIndex( const sal_Int32 newOrderIndex )
SolarMutexGuard aGuard;
SidebarController* pSidebarController = getSidebarController();
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, newOrderIndex);
DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
// update the sidebar
pSidebarController->NotifyResize();
if (pDeckDescriptor)
{
pDeckDescriptor->mnOrderIndex = newOrderIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
void SAL_CALL SfxUnoDeck::moveFirst()
......@@ -149,8 +157,13 @@ void SAL_CALL SfxUnoDeck::moveFirst()
if (curOrderIndex != minIndex) // is deck already in place ?
{
minIndex -= 1;
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, minIndex);
pSidebarController->NotifyResize();
DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
if (pDeckDescriptor)
{
pDeckDescriptor->mnOrderIndex = minIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
}
......@@ -168,8 +181,13 @@ void SAL_CALL SfxUnoDeck::moveLast()
if (curOrderIndex != maxIndex) // is deck already in place ?
{
maxIndex += 1;
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, maxIndex);
pSidebarController->NotifyResize();
DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
if (pDeckDescriptor)
{
pDeckDescriptor->mnOrderIndex = maxIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
}
......@@ -196,8 +214,13 @@ void SAL_CALL SfxUnoDeck::moveUp()
if (curOrderIndex != previousIndex) // is deck already in place ?
{
previousIndex -= 1;
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, previousIndex);
pSidebarController->NotifyResize();
DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
if (pDeckDescriptor)
{
pDeckDescriptor->mnOrderIndex = previousIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
}
......@@ -225,8 +248,13 @@ void SAL_CALL SfxUnoDeck::moveDown()
if (curOrderIndex != nextIndex) // is deck already in place ?
{
nextIndex += 1;
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, nextIndex);
pSidebarController->NotifyResize();
DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
if (pDeckDescriptor)
{
pDeckDescriptor->mnOrderIndex = nextIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
}
......
......@@ -31,9 +31,11 @@ mpPanel()
{
SidebarController* pSidebarController = getSidebarController();
pSidebarController->CreateDeck(mDeckId); // creates deck object is not already
mpDeck = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck;
mpPanel = mpDeck->GetPanel(mPanelId);
}
SidebarController* SfxUnoPanel::getSidebarController()
{
return SidebarController::GetSidebarControllerForFrame(xFrame);
......@@ -61,8 +63,16 @@ void SAL_CALL SfxUnoPanel::setTitle( const OUString& newTitle )
{
SolarMutexGuard aGuard;
PanelTitleBar* pTitleBar = mpPanel->GetTitleBar();
pTitleBar->SetTitle(newTitle);
SidebarController* pSidebarController = getSidebarController();
PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
if (pPanelDescriptor)
{
pPanelDescriptor->msTitle = newTitle;
PanelTitleBar* pTitleBar = mpPanel->GetTitleBar();
if (pTitleBar)
pTitleBar->SetTitle(newTitle);
}
}
sal_Bool SAL_CALL SfxUnoPanel::isExpanded()
......@@ -97,6 +107,9 @@ void SAL_CALL SfxUnoPanel::expand( const sal_Bool bCollapseOther )
}
}
SidebarController* pSidebarController = getSidebarController();
pSidebarController->NotifyResize();
}
void SAL_CALL SfxUnoPanel::collapse()
......@@ -105,6 +118,8 @@ void SAL_CALL SfxUnoPanel::collapse()
SolarMutexGuard aGuard;
mpPanel->SetExpanded(false);
SidebarController* pSidebarController = getSidebarController();
pSidebarController->NotifyResize();
}
uno::Reference<awt::XWindow> SAL_CALL SfxUnoPanel::getDialog()
......@@ -132,9 +147,14 @@ void SAL_CALL SfxUnoPanel::setOrderIndex( const sal_Int32 newOrderIndex )
SolarMutexGuard aGuard;
SidebarController* pSidebarController = getSidebarController();
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, newOrderIndex);
PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
pSidebarController->NotifyResize();
if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = newOrderIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
void SAL_CALL SfxUnoPanel::moveFirst()
......@@ -151,8 +171,13 @@ void SAL_CALL SfxUnoPanel::moveFirst()
if (curOrderIndex != minIndex) // is current panel already in place ?
{
minIndex -= 1;
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, minIndex);
pSidebarController->NotifyResize();
PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = minIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
}
......@@ -170,8 +195,13 @@ void SAL_CALL SfxUnoPanel::moveLast()
if (curOrderIndex != maxIndex) // is current panel already in place ?
{
maxIndex += 1;
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, maxIndex);
pSidebarController->NotifyResize();
PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = maxIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
}
......@@ -198,8 +228,13 @@ void SAL_CALL SfxUnoPanel::moveUp()
if (curOrderIndex != previousIndex) // is current panel already in place ?
{
previousIndex -= 1;
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, previousIndex);
pSidebarController->NotifyResize();
PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = previousIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
}
......@@ -226,8 +261,13 @@ void SAL_CALL SfxUnoPanel::moveDown()
if (curOrderIndex != nextIndex) // is current panel already in place ?
{
nextIndex += 1;
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, nextIndex);
pSidebarController->NotifyResize();
PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = nextIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
}
}
......
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