You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by af...@apache.org on 2013/03/18 18:14:07 UTC
svn commit: r1457873 [2/3] - in /openoffice/branches/sidebar/main:
officecfg/registry/data/org/openoffice/Office/UI/
officecfg/registry/schema/org/openoffice/Office/UI/ sc/source/ui/drawfunc/
sc/source/ui/inc/ sc/source/ui/view/ sd/source/ui/func/ sd/s...
Modified: openoffice/branches/sidebar/main/sfx2/source/sidebar/ResourceManager.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sfx2/source/sidebar/ResourceManager.cxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sfx2/source/sidebar/ResourceManager.cxx (original)
+++ openoffice/branches/sidebar/main/sfx2/source/sidebar/ResourceManager.cxx Mon Mar 18 17:14:04 2013
@@ -95,31 +95,14 @@ const DeckDescriptor* ResourceManager::G
{
ReadLegacyAddons(rxFrame);
- sal_Int32 nBestMatch (EnumContext::NoMatch);
- const DeckContainer::const_iterator iEnd (maDecks.end());
- DeckContainer::const_iterator iBestDeck (iEnd);
-
- for (DeckContainer::const_iterator iDeck(maDecks.begin());
+ for (DeckContainer::const_iterator iDeck(maDecks.begin()), iEnd(maDecks.end());
iDeck!=iEnd;
++iDeck)
{
- const sal_Int32 nMatch (iDeck->maContextMatcher.EvaluateMatch(rContext));
- if (nMatch < nBestMatch)
- {
- // Found a better matching deck.
- nBestMatch = nMatch;
- iBestDeck = iDeck;
- if (nBestMatch == EnumContext::OptimalMatch)
- {
- // We will not find a better match.
- break;
- }
- }
+ if (iDeck->maContextList.GetMatch(rContext) != NULL)
+ return &*iDeck;
}
- if (iBestDeck != iEnd)
- return &*iBestDeck;
- else
- return NULL;
+ return NULL;
}
@@ -197,7 +180,7 @@ const ResourceManager::IdContainer& Reso
++iDeck)
{
const DeckDescriptor& rDeckDescriptor (*iDeck);
- if (rDeckDescriptor.maContextMatcher.EvaluateMatch(rContext) != EnumContext::NoMatch)
+ if (rDeckDescriptor.maContextList.GetMatch(rContext) != NULL)
aOrderedIds.insert(::std::multimap<sal_Int32,OUString>::value_type(
rDeckDescriptor.mnOrderIndex,
rDeckDescriptor.msId));
@@ -218,15 +201,15 @@ const ResourceManager::IdContainer& Reso
-const ResourceManager::IdContainer& ResourceManager::GetMatchingPanels (
- IdContainer& rPanelIds,
+const ResourceManager::PanelContextDescriptorContainer& ResourceManager::GetMatchingPanels (
+ PanelContextDescriptorContainer& rPanelIds,
const Context& rContext,
const ::rtl::OUString& rsDeckId,
const Reference<frame::XFrame>& rxFrame)
{
ReadLegacyAddons(rxFrame);
- ::std::multimap<sal_Int32,OUString> aOrderedIds;
+ ::std::multimap<sal_Int32,PanelContextDescriptor> aOrderedIds;
for (PanelContainer::const_iterator
iPanel(maPanels.begin()),
iEnd(maPanels.end());
@@ -235,13 +218,22 @@ const ResourceManager::IdContainer& Reso
{
const PanelDescriptor& rPanelDescriptor (*iPanel);
if (rPanelDescriptor.msDeckId.equals(rsDeckId))
- if (rPanelDescriptor.maContextMatcher.EvaluateMatch(rContext) != EnumContext::NoMatch)
- aOrderedIds.insert(::std::multimap<sal_Int32,OUString>::value_type(
+ {
+ const ContextList::Entry* pEntry = rPanelDescriptor.maContextList.GetMatch(rContext);
+ if (pEntry != NULL)
+ {
+ PanelContextDescriptor aPanelContextDescriptor;
+ aPanelContextDescriptor.msId = rPanelDescriptor.msId;
+ aPanelContextDescriptor.msMenuCommand = pEntry->msMenuCommand;
+ aPanelContextDescriptor.mbIsInitiallyVisible = pEntry->mbIsInitiallyVisible;
+ aOrderedIds.insert(::std::multimap<sal_Int32,PanelContextDescriptor>::value_type(
rPanelDescriptor.mnOrderIndex,
- rPanelDescriptor.msId));
+ aPanelContextDescriptor));
+ }
+ }
}
- for (::std::multimap<sal_Int32,OUString>::const_iterator
+ for (::std::multimap<sal_Int32,PanelContextDescriptor>::const_iterator
iId(aOrderedIds.begin()),
iEnd(aOrderedIds.end());
iId!=iEnd;
@@ -293,7 +285,10 @@ void ResourceManager::ReadDeckList (void
rDeckDescriptor.mnOrderIndex = ::comphelper::getINT32(
aDeckNode.getNodeValue("OrderIndex"));
- ReadContextMatcher(aDeckNode.openNode("ContextMatchers"), rDeckDescriptor.maContextMatcher);
+ ReadContextList(
+ aDeckNode,
+ rDeckDescriptor.maContextList,
+ OUString());
}
// When there where invalid nodes then we have to adapt the size
@@ -341,11 +336,15 @@ void ResourceManager::ReadPanelList (voi
aPanelNode.getNodeValue("ImplementationURL"));
rPanelDescriptor.mnOrderIndex = ::comphelper::getINT32(
aPanelNode.getNodeValue("OrderIndex"));
- rPanelDescriptor.mbHasMenu = ::comphelper::getBOOL(
- aPanelNode.getNodeValue("HasMenu"));
rPanelDescriptor.mbWantsCanvas = ::comphelper::getBOOL(
aPanelNode.getNodeValue("WantsCanvas"));
- ReadContextMatcher(aPanelNode.openNode("ContextMatchers"), rPanelDescriptor.maContextMatcher);
+ const OUString sDefaultMenuCommand (::comphelper::getString(
+ aPanelNode.getNodeValue("DefaultMenuCommand")));
+
+ ReadContextList(
+ aPanelNode,
+ rPanelDescriptor.maContextList,
+ sDefaultMenuCommand);
}
// When there where invalid nodes then we have to adapt the size
@@ -357,41 +356,132 @@ void ResourceManager::ReadPanelList (voi
-void ResourceManager::ReadContextMatcher (
- const ::utl::OConfigurationNode& rNode,
- ContextMatcher& rContextMatcher) const
-{
- const Sequence<OUString> aMatcherNodeNames (rNode.getNodeNames());
- const sal_Int32 nMatcherCount (aMatcherNodeNames.getLength());
- for (sal_Int32 nMatcherIndex(0); nMatcherIndex<nMatcherCount; ++nMatcherIndex)
+void ResourceManager::ReadContextList (
+ const ::utl::OConfigurationNode& rParentNode,
+ ContextList& rContextList,
+ const OUString& rsDefaultMenuCommand) const
+{
+ const Any aValue = rParentNode.getNodeValue("ContextList");
+ Sequence<OUString> aValues;
+ sal_Int32 nCount;
+ if (aValue >>= aValues)
+ nCount = aValues.getLength();
+ else
+ nCount = 0;
+
+ for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
{
- const ::utl::OConfigurationNode aMatcherNode (rNode.openNode(aMatcherNodeNames[nMatcherIndex]));
+ const OUString sValue (aValues[nIndex]);
+ sal_Int32 nCharacterIndex (0);
+ const OUString sApplicationName (sValue.getToken(0, ',', nCharacterIndex).trim());
+ if (nCharacterIndex < 0)
+ {
+ if (sApplicationName.getLength() == 0)
+ {
+ // This is a valid case: in the XML file the separator
+ // was used as terminator. Using it in the last line
+ // creates an additional but empty entry.
+ break;
+ }
+ else
+ {
+ OSL_ASSERT("expecting three or four values per ContextList entry, separated by comma");
+ continue;
+ }
+ }
- const OUString sApplicationName (
- ::comphelper::getString(aMatcherNode.getNodeValue("Application")));
- const bool bIsContextListNegated (
- ::comphelper::getBOOL(aMatcherNode.getNodeValue("IsContextListNegated")));
-
- // Read the context names.
- Any aContextListValue (aMatcherNode.getNodeValue("ContextList"));
- Sequence<OUString> aContextList;
- ::std::vector<OUString> aContextVector;
- if (aContextListValue >>= aContextList)
+ const OUString sContextName (sValue.getToken(0, ',', nCharacterIndex).trim());
+ if (nCharacterIndex < 0)
{
- aContextVector.reserve(aContextList.getLength());
- ::std::copy(
- ::comphelper::stl_begin(aContextList),
- ::comphelper::stl_end(aContextList),
- ::std::back_inserter(aContextVector));
+ OSL_ASSERT("expecting three or four values per ContextList entry, separated by comma");
+ continue;
+ }
+
+ const OUString sInitialState (sValue.getToken(0, ',', nCharacterIndex).trim());
+
+ // The fourth argument is optional.
+ const OUString sMenuCommandOverride (
+ nCharacterIndex<0
+ ? OUString()
+ : sValue.getToken(0, ',', nCharacterIndex).trim());
+ const OUString sMenuCommand (
+ sMenuCommandOverride.getLength()>0
+ ? (sMenuCommandOverride.equalsAscii("none")
+ ? OUString()
+ : sMenuCommandOverride)
+ : rsDefaultMenuCommand);
+
+ EnumContext::Application eApplication (EnumContext::GetApplicationEnum(sApplicationName));
+ bool bApplicationIsDrawAndImpress = false;
+ if (eApplication == EnumContext::Application_None
+ && !sApplicationName.equals(EnumContext::GetApplicationName(EnumContext::Application_None)))
+ {
+ // Handle some special names: abbreviations that make
+ // context descriptions more readable.
+ if (sApplicationName.equalsAscii("Writer"))
+ eApplication = EnumContext::Application_Writer;
+ else if (sApplicationName.equalsAscii("Calc"))
+ eApplication = EnumContext::Application_Calc;
+ else if (sApplicationName.equalsAscii("Draw"))
+ eApplication = EnumContext::Application_Draw;
+ else if (sApplicationName.equalsAscii("Impress"))
+ eApplication = EnumContext::Application_Impress;
+ else if (sApplicationName.equalsAscii("DrawImpress"))
+ {
+ // A special case among the special names: it is
+ // common to use the same context descriptions for
+ // both Draw and Impress. This special case helps to
+ // avoid duplication in the .xcu file.
+ bApplicationIsDrawAndImpress = true;
+ }
+ else
+ {
+ OSL_ASSERT("application name not recognized");
+ continue;
+ }
}
- // Empty list defaults to "any".
- if (aContextVector.empty())
- aContextVector.push_back(A2S("any"));
- rContextMatcher.AddMatcher(
- sApplicationName,
- aContextVector,
- bIsContextListNegated);
+ const EnumContext::Context eContext (EnumContext::GetContextEnum(sContextName));
+ if (eContext == EnumContext::Context_Unknown)
+ {
+ OSL_ASSERT("context name not recognized");
+ continue;
+ }
+
+ bool bIsInitiallyVisible;
+ if (sInitialState.equalsAscii("visible"))
+ bIsInitiallyVisible = true;
+ else if (sInitialState.equalsAscii("hidden"))
+ bIsInitiallyVisible = false;
+ else
+ {
+ OSL_ASSERT("unrecognized state");
+ continue;
+ }
+
+ if (bApplicationIsDrawAndImpress)
+ {
+ // Add the context description for both Draw and Impress.
+ rContextList.AddContextDescription(
+ Context(
+ EnumContext::GetApplicationName(EnumContext::Application_Draw),
+ EnumContext::GetContextName(eContext)),
+ bIsInitiallyVisible,
+ sMenuCommand);
+ rContextList.AddContextDescription(
+ Context(
+ EnumContext::GetApplicationName(EnumContext::Application_Impress),
+ EnumContext::GetContextName(eContext)),
+ bIsInitiallyVisible,
+ sMenuCommand);
+ }
+ else
+ rContextList.AddContextDescription(
+ Context(
+ EnumContext::GetApplicationName(eApplication),
+ EnumContext::GetContextName(eContext)),
+ bIsInitiallyVisible,
+ sMenuCommand);
}
}
@@ -443,7 +533,7 @@ void ResourceManager::ReadLegacyAddons (
rDeckDescriptor.msHighContrastIconURL = rDeckDescriptor.msIconURL;
rDeckDescriptor.msHelpURL = ::comphelper::getString(aChildNode.getNodeValue("HelpURL"));
rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle;
- rDeckDescriptor.maContextMatcher.AddMatcher(sModuleName, A2S("any"));
+ rDeckDescriptor.maContextList.AddContextDescription(Context(sModuleName, A2S("any")), true, OUString());
rDeckDescriptor.mbIsEnabled = true;
PanelDescriptor& rPanelDescriptor (maPanels[nPanelWriteIndex++]);
@@ -452,7 +542,7 @@ void ResourceManager::ReadLegacyAddons (
rPanelDescriptor.msId = rsNodeName;
rPanelDescriptor.msDeckId = rsNodeName;
rPanelDescriptor.msHelpURL = ::comphelper::getString(aChildNode.getNodeValue("HelpURL"));
- rPanelDescriptor.maContextMatcher.AddMatcher(sModuleName, A2S("any"));
+ rPanelDescriptor.maContextList.AddContextDescription(Context(sModuleName, A2S("any")), true, OUString());
rPanelDescriptor.msImplementationURL = rsNodeName;
}
Modified: openoffice/branches/sidebar/main/sfx2/source/sidebar/ResourceManager.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sfx2/source/sidebar/ResourceManager.hxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sfx2/source/sidebar/ResourceManager.hxx (original)
+++ openoffice/branches/sidebar/main/sfx2/source/sidebar/ResourceManager.hxx Mon Mar 18 17:14:04 2013
@@ -37,6 +37,7 @@ namespace cssu = ::com::sun::star::uno;
namespace sfx2 { namespace sidebar {
class Context;
+class ContextList;
/** Read the content of the Sidebar.xcu file and provide access
methods so that the sidebar can easily decide which content panels
@@ -68,14 +69,22 @@ public:
const bool bIsEnabled);
typedef ::std::vector<rtl::OUString> IdContainer;
-
+ class PanelContextDescriptor
+ {
+ public:
+ ::rtl::OUString msId;
+ ::rtl::OUString msMenuCommand;
+ bool mbIsInitiallyVisible;
+ };
+ typedef ::std::vector<PanelContextDescriptor> PanelContextDescriptorContainer;
+
const IdContainer& GetMatchingDecks (
IdContainer& rDeckDescriptors,
const Context& rContext,
const cssu::Reference<css::frame::XFrame>& rxFrame);
- const IdContainer& GetMatchingPanels (
- IdContainer& rPanelDescriptors,
+ const PanelContextDescriptorContainer& GetMatchingPanels (
+ PanelContextDescriptorContainer& rPanelDescriptors,
const Context& rContext,
const ::rtl::OUString& rsDeckId,
const cssu::Reference<css::frame::XFrame>& rxFrame);
@@ -97,9 +106,10 @@ private:
void ReadDeckList (void);
void ReadPanelList (void);
- void ReadContextMatcher (
+ void ReadContextList (
const ::utl::OConfigurationNode& rNode,
- ContextMatcher& rContextMatcher) const;
+ ContextList& rContextList,
+ const ::rtl::OUString& rsDefaultMenuCommand) const;
void ReadLegacyAddons (
const cssu::Reference<css::frame::XFrame>& rxFrame);
::utl::OConfigurationTreeRoot GetLegacyAddonRootNode (
Modified: openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.cxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.cxx (original)
+++ openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.cxx Mon Mar 18 17:14:04 2013
@@ -23,7 +23,6 @@
#include "SidebarController.hxx"
#include "Deck.hxx"
-#include "DeckConfiguration.hxx"
#include "DeckTitleBar.hxx"
#include "Panel.hxx"
#include "SidebarPanel.hxx"
@@ -46,12 +45,16 @@
#include <comphelper/componentcontext.hxx>
#include <comphelper/namedvaluecollection.hxx>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/ui/ContextChangeEventObject.hpp>
#include <com/sun/star/ui/XUIElementFactory.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/util/URL.hpp>
#include <boost/bind.hpp>
+#include <boost/function.hpp>
#include <boost/scoped_array.hpp>
@@ -82,7 +85,7 @@ SidebarController::SidebarController (
SidebarDockingWindow* pParentWindow,
const cssu::Reference<css::frame::XFrame>& rxFrame)
: SidebarControllerInterfaceBase(m_aMutex),
- mpCurrentConfiguration(),
+ mpCurrentDeck(),
mpParentWindow(pParentWindow),
mpTabBar(new TabBar(
mpParentWindow,
@@ -118,6 +121,8 @@ SidebarController::SidebarController (
Theme::GetPropertySet()->addPropertyChangeListener(
A2S(""),
static_cast<css::beans::XPropertyChangeListener*>(this));
+
+ SwitchToDeck(A2S("default"));
}
@@ -145,10 +150,12 @@ void SAL_CALL SidebarController::disposi
mpParentWindow = NULL;
}
- if (mpCurrentConfiguration)
+ if (mpCurrentDeck)
{
- mpCurrentConfiguration->Dispose();
- mpCurrentConfiguration.reset();
+ mpCurrentDeck->Dispose();
+ OSL_TRACE("deleting deck window subtree");
+ mpCurrentDeck->PrintWindowTree();
+ mpCurrentDeck.reset();
}
mpTabBar.reset();
@@ -177,13 +184,8 @@ void SAL_CALL SidebarController::disposi
throw(cssu::RuntimeException)
{
(void)rEventObject;
-
- if (mpCurrentConfiguration)
- {
- mpCurrentConfiguration->Dispose();
- mpCurrentConfiguration.reset();
- }
- mpTabBar.reset();
+
+ dispose();
}
@@ -203,8 +205,8 @@ void SAL_CALL SidebarController::propert
void SAL_CALL SidebarController::requestLayout (void)
throw(cssu::RuntimeException)
{
- if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL)
- mpCurrentConfiguration->mpDeck->RequestLayout();
+ if (mpCurrentDeck)
+ mpCurrentDeck->RequestLayout();
RestrictWidth();
}
@@ -235,20 +237,15 @@ void SidebarController::NotifyResize (vo
const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height());
// Place the deck.
- Deck* pDeck = NULL;
- if (mpCurrentConfiguration != NULL && ! mbIsDeckClosed)
+ if ( ! mbIsDeckClosed)
{
- pDeck = mpCurrentConfiguration->mpDeck;
- if (pDeck == NULL)
- {
- OSL_ASSERT(mpCurrentConfiguration->mpDeck!=NULL);
- }
+ OSL_ASSERT(mpCurrentDeck!=NULL);
}
- if (pDeck != NULL)
+ if (mpCurrentDeck)
{
- pDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight);
- pDeck->Show();
- pDeck->RequestLayout();
+ mpCurrentDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight);
+ mpCurrentDeck->Show();
+ mpCurrentDeck->RequestLayout();
}
// Place the tab bar.
@@ -256,9 +253,9 @@ void SidebarController::NotifyResize (vo
mpTabBar->Show();
// Determine if the closer of the deck can be shown.
- if (pDeck!=NULL)
+ if (mpCurrentDeck)
{
- DeckTitleBar* pTitleBar = pDeck->GetTitleBar();
+ DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
if (pTitleBar != NULL && pTitleBar->IsVisible())
pTitleBar->SetCloserVisible(CanModifyChildWindowWidth());
}
@@ -268,13 +265,13 @@ void SidebarController::NotifyResize (vo
RestrictWidth();
#ifdef DEBUG
- if (mpCurrentConfiguration != NULL)
+ if (mpCurrentDeck)
{
- mpCurrentConfiguration->mpDeck->PrintWindowTree();
+ mpCurrentDeck->PrintWindowTree();
sal_Int32 nPanelIndex (0);
- for (::std::vector<Panel*>::const_iterator
- iPanel(mpCurrentConfiguration->maPanels.begin()),
- iEnd(mpCurrentConfiguration->maPanels.end());
+ for (SharedPanelContainer::const_iterator
+ iPanel(mpCurrentDeck->GetPanels().begin()),
+ iEnd(mpCurrentDeck->GetPanels().end());
iPanel!=iEnd;
++iPanel,++nPanelIndex)
{
@@ -319,10 +316,7 @@ void SidebarController::UpdateConfigurat
DeckDescriptor const* pDeckDescriptor = NULL;
if ( ! bCurrentDeckMatches)
- {
pDeckDescriptor = ResourceManager::Instance().GetBestMatchingDeck(rContext, mxFrame);
- msCurrentDeckId = pDeckDescriptor->msId;
- }
else
pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(msCurrentDeckId);
if (pDeckDescriptor != NULL)
@@ -358,10 +352,10 @@ void SidebarController::SwitchToDeck (
{
// When the deck changes then destroy the deck and all panels
// and create everything new.
- if (mpCurrentConfiguration)
+ if (mpCurrentDeck)
{
- mpCurrentConfiguration->Dispose();
- mpCurrentConfiguration.reset();
+ mpCurrentDeck->Dispose();
+ mpCurrentDeck.reset();
}
msCurrentDeckId = rDeckDescriptor.msId;
@@ -371,15 +365,15 @@ void SidebarController::SwitchToDeck (
OpenDeck();
// Determine the panels to display in the deck.
- ResourceManager::IdContainer aPanelIds;
+ ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors;
ResourceManager::Instance().GetMatchingPanels(
- aPanelIds,
+ aPanelContextDescriptors,
rContext,
rDeckDescriptor.msId,
mxFrame);
- if (mpCurrentConfiguration
- && ArePanelSetsEqual(mpCurrentConfiguration->maPanels, aPanelIds))
+ if (mpCurrentDeck
+ && ArePanelSetsEqual(mpCurrentDeck->GetPanels(), aPanelContextDescriptors))
{
// Requested set of panels is identical to the current set of
// panels => Nothing to do.
@@ -387,78 +381,70 @@ void SidebarController::SwitchToDeck (
}
// Provide a configuration and Deck object.
- if ( ! mpCurrentConfiguration)
+ if ( ! mpCurrentDeck)
{
- mpCurrentConfiguration.reset(new DeckConfiguration);
- mpCurrentConfiguration->mpDeck = new Deck(
- rDeckDescriptor,
- mpParentWindow,
- ::boost::bind(&SidebarController::CloseDeck, this));
+ mpCurrentDeck.reset(
+ new Deck(
+ rDeckDescriptor,
+ mpParentWindow,
+ ::boost::bind(&SidebarController::CloseDeck, this)));
}
-
+ if ( ! mpCurrentDeck)
+ return;
+
// Update the panel list.
- const sal_Int32 nNewPanelCount (aPanelIds.size());
- ::std::vector<Panel*> aNewPanels;
- ::std::vector<Panel*> aCurrentPanels;
- if (mpCurrentConfiguration)
- aCurrentPanels.swap(mpCurrentConfiguration->maPanels);
+ const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
+ SharedPanelContainer aNewPanels;
+ const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels());
aNewPanels.resize(nNewPanelCount);
sal_Int32 nWriteIndex (0);
bool bHasPanelSetChanged (false);
for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex)
{
- const OUString& rsPanelId (aPanelIds[nReadIndex]);
+ const ResourceManager::PanelContextDescriptor& rPanelContexDescriptor (
+ aPanelContextDescriptors[nReadIndex]);
// Find the corresponding panel among the currently active
// panels.
- ::std::vector<Panel*>::iterator iPanel (::std::find_if(
- aCurrentPanels.begin(),
- aCurrentPanels.end(),
- ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rsPanelId))));
- if (iPanel != aCurrentPanels.end())
+ SharedPanelContainer::const_iterator iPanel (::std::find_if(
+ rCurrentPanels.begin(),
+ rCurrentPanels.end(),
+ ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId))));
+ if (iPanel != rCurrentPanels.end())
{
- // Panel already exists in current configuration. Move it
- // to new configuration.
+ // Panel already exists in current deck. Reuse it.
aNewPanels[nWriteIndex] = *iPanel;
- aCurrentPanels[::std::distance(aCurrentPanels.begin(), iPanel)] = NULL;
- OSL_TRACE(" reusing panel %s", S2A(rsPanelId));
+ OSL_TRACE(" reusing panel %s", S2A(rPanelContexDescriptor.msId));
}
else
{
// Panel does not yet exist. Create it.
aNewPanels[nWriteIndex] = CreatePanel(
- rsPanelId,
- mpCurrentConfiguration->mpDeck->GetPanelParentWindow());
- OSL_TRACE(" creating panel %s", S2A(rsPanelId));
+ rPanelContexDescriptor.msId,
+ mpCurrentDeck->GetPanelParentWindow(),
+ rPanelContexDescriptor.msMenuCommand);
+ OSL_TRACE(" creating panel %s", S2A(rPanelContexDescriptor.msId));
bHasPanelSetChanged = true;
}
if (aNewPanels[nWriteIndex] != NULL)
- ++nWriteIndex;
- }
- aNewPanels.resize(nWriteIndex);
-
- // Destroy all panels that are not used in the new configuration.
- for (::std::vector<Panel*>::const_iterator iPanel(aCurrentPanels.begin()),iEnd(aCurrentPanels.end());
- iPanel!=iEnd;
- ++iPanel)
- {
- if (*iPanel != NULL)
{
- (*iPanel)->Dispose();
- OSL_TRACE(" releasing panel %s", S2A((*iPanel)->GetId()));
- bHasPanelSetChanged = true;
+ // Depending on the context we have to collapse the panel.
+ aNewPanels[nWriteIndex]->SetExpanded(rPanelContexDescriptor.mbIsInitiallyVisible);
+
+ ++nWriteIndex;
}
+
}
+ aNewPanels.resize(nWriteIndex);
// Activate the deck and the new set of panels.
- mpCurrentConfiguration->maPanels.swap(aNewPanels);
- mpCurrentConfiguration->mpDeck->SetPosSizePixel(
+ mpCurrentDeck->SetPosSizePixel(
0,
0,
mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth(),
mpParentWindow->GetSizePixel().Height());
- mpCurrentConfiguration->mpDeck->SetPanels(mpCurrentConfiguration->maPanels);
- mpCurrentConfiguration->mpDeck->Show();
+ mpCurrentDeck->SetPanels(aNewPanels);
+ mpCurrentDeck->Show();
// Tell the tab bar to highlight the button associated with the
// deck.
@@ -474,11 +460,11 @@ void SidebarController::SwitchToDeck (
bool SidebarController::ArePanelSetsEqual (
- const ::std::vector<Panel*>& rCurrentPanels,
- const ResourceManager::IdContainer& rRequestedPanelIds)
+ const SharedPanelContainer& rCurrentPanels,
+ const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels)
{
OSL_TRACE("current panel list:");
- for (std::vector<Panel*>::const_iterator
+ for (SharedPanelContainer::const_iterator
iPanel(rCurrentPanels.begin()),
iEnd(rCurrentPanels.end());
iPanel!=iEnd;
@@ -488,22 +474,22 @@ bool SidebarController::ArePanelSetsEqua
}
OSL_TRACE("requested panels: ");
- for (ResourceManager::IdContainer::const_iterator
- iId(rRequestedPanelIds.begin()),
- iEnd(rRequestedPanelIds.end());
+ for (ResourceManager::PanelContextDescriptorContainer::const_iterator
+ iId(rRequestedPanels.begin()),
+ iEnd(rRequestedPanels.end());
iId!=iEnd;
++iId)
{
- OSL_TRACE(" panel %s", S2A(*iId));
+ OSL_TRACE(" panel %s", S2A(iId->msId));
}
- if (rCurrentPanels.size() != rRequestedPanelIds.size())
+ if (rCurrentPanels.size() != rRequestedPanels.size())
return false;
for (sal_Int32 nIndex=0,nCount=rCurrentPanels.size(); nIndex<nCount; ++nIndex)
{
if (rCurrentPanels[nIndex] == NULL)
return false;
- if ( ! rCurrentPanels[nIndex]->GetId().equals(rRequestedPanelIds[nIndex]))
+ if ( ! rCurrentPanels[nIndex]->GetId().equals(rRequestedPanels[nIndex].msId))
return false;
}
return true;
@@ -512,13 +498,14 @@ bool SidebarController::ArePanelSetsEqua
-Panel* SidebarController::CreatePanel (
+SharedPanel SidebarController::CreatePanel (
const OUString& rsPanelId,
- ::Window* pParentWindow)
+ ::Window* pParentWindow,
+ const OUString& rsMenuCommand)
{
const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId);
if (pPanelDescriptor == NULL)
- return NULL;
+ return SharedPanel();
#ifdef DEBUG
// Prevent the panel not being created in the same memory of an old panel.
@@ -527,16 +514,18 @@ Panel* SidebarController::CreatePanel (
#endif
// Create the panel which is the parent window of the UIElement.
- Panel* pPanel = new Panel(
+ SharedPanel pPanel (new Panel(
*pPanelDescriptor,
pParentWindow,
- ::boost::bind(&Deck::RequestLayout,mpCurrentConfiguration->mpDeck));
+ ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()),
+ rsMenuCommand.getLength()>0
+ ? ::boost::bind(&SidebarController::ShowDetailMenu,this,rsMenuCommand)
+ : ::boost::function<void(void)>()));
// Create the XUIElement.
Reference<ui::XUIElement> xUIElement (CreateUIElement(
pPanel->GetComponentInterface(),
- pPanelDescriptor->msImplementationURL,
- pPanel));
+ pPanelDescriptor->msImplementationURL));
if (xUIElement.is())
{
// Initialize the panel and add it to the active deck.
@@ -544,8 +533,7 @@ Panel* SidebarController::CreatePanel (
}
else
{
- delete pPanel;
- pPanel = NULL;
+ pPanel.reset();
}
return pPanel;
@@ -556,11 +544,8 @@ Panel* SidebarController::CreatePanel (
Reference<ui::XUIElement> SidebarController::CreateUIElement (
const Reference<awt::XWindowPeer>& rxWindow,
- const ::rtl::OUString& rsImplementationURL,
- Panel* pPanel)
+ const ::rtl::OUString& rsImplementationURL)
{
- (void)pPanel;
-
try
{
const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory());
@@ -656,6 +641,33 @@ void SidebarController::ShowPopupMenu (
+void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const
+{
+ try
+ {
+ util::URL aURL;
+ aURL.Complete = rsMenuCommand;
+
+ const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory());
+ const Reference<util::XURLTransformer> xParser (
+ aComponentContext.createComponent("com.sun.star.util.URLTransformer"),
+ UNO_QUERY_THROW);
+ xParser->parseStrict(aURL);
+ Reference<frame::XDispatchProvider> xProvider (mxFrame, UNO_QUERY_THROW);
+ Reference<frame::XDispatch> xDispatch (xProvider->queryDispatch(aURL, OUString(), 0));
+ if (xDispatch.is())
+ xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>());
+ }
+ catch(Exception& rException)
+ {
+ OSL_TRACE("caught exception: %s",
+ OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr());
+ }
+}
+
+
+
+
::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu (
const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData,
const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const
@@ -778,8 +790,8 @@ void SidebarController::CloseDeck (void)
mnSavedSidebarWidth = SetChildWindowWidth(TabBar::GetDefaultWidth());
mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE);
- if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL)
- mpCurrentConfiguration->mpDeck->Hide();
+ if (mpCurrentDeck)
+ mpCurrentDeck->Hide();
NotifyResize();
}
@@ -795,8 +807,8 @@ void SidebarController::OpenDeck (void)
mbIsDeckClosed = false;
SetChildWindowWidth(mnSavedSidebarWidth);
- if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL)
- mpCurrentConfiguration->mpDeck->Show();
+ if (mpCurrentDeck)
+ mpCurrentDeck->Show();
NotifyResize();
}
Modified: openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.hxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.hxx (original)
+++ openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.hxx Mon Mar 18 17:14:04 2013
@@ -26,6 +26,7 @@
#include "AsynchronousCall.hxx"
#include "TabBar.hxx"
#include "Context.hxx"
+#include "Panel.hxx"
#include <vcl/menu.hxx>
@@ -56,9 +57,7 @@ namespace sfx2 { namespace sidebar {
class ContentPanelDescriptor;
class Deck;
-class DeckConfiguration;
class DeckDescriptor;
-class Panel;
class SidebarDockingWindow;
class TabBar;
class TabBarConfiguration;
@@ -104,7 +103,7 @@ public:
void OpenDeck (void);
private:
- ::boost::shared_ptr<DeckConfiguration> mpCurrentConfiguration;
+ ::boost::scoped_ptr<Deck> mpCurrentDeck;
SidebarDockingWindow* mpParentWindow;
::boost::scoped_ptr<TabBar> mpTabBar;
cssu::Reference<css::frame::XFrame> mxFrame;
@@ -120,15 +119,15 @@ private:
DECL_LINK(WindowEventHandler, VclWindowEvent*);
void UpdateConfigurations (const Context& rContext);
bool ArePanelSetsEqual (
- const ::std::vector<Panel*>& rCurrentPanels,
- const ResourceManager::IdContainer& rRequestedPanelIds);
+ const SharedPanelContainer& rCurrentPanels,
+ const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels);
cssu::Reference<css::ui::XUIElement> CreateUIElement (
const cssu::Reference<css::awt::XWindowPeer>& rxWindow,
- const ::rtl::OUString& rsImplementationURL,
- Panel* pPanel);
- Panel* CreatePanel (
+ const ::rtl::OUString& rsImplementationURL);
+ SharedPanel CreatePanel (
const ::rtl::OUString& rsPanelId,
- ::Window* pParentWindow);
+ ::Window* pParentWindow,
+ const ::rtl::OUString& rsMenuCommand);
void SwitchToDeck (
const DeckDescriptor& rDeckDescriptor,
const Context& rContext);
@@ -136,6 +135,7 @@ private:
const Rectangle& rButtonBox,
const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData,
const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const;
+ void ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const;
::boost::shared_ptr<PopupMenu> CreatePopupMenu (
const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData,
const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const;
Modified: openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarPanelBase.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarPanelBase.cxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarPanelBase.cxx (original)
+++ openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarPanelBase.cxx Mon Mar 18 17:14:04 2013
@@ -24,6 +24,7 @@
#include "sfx2/sidebar/SidebarPanelBase.hxx"
#include "sfx2/sidebar/Theme.hxx"
#include "sfx2/sidebar/ILayoutableWindow.hxx"
+#include "sfx2/sidebar/IContextChangeReceiver.hxx"
#include "sfx2/imagemgr.hxx"
#include <vcl/ctrl.hxx>
#include <comphelper/processfactory.hxx>
@@ -144,8 +145,8 @@ void SAL_CALL SidebarPanelBase::notifyCo
{
OSL_TRACE("SidebarPanelBase notified at %x with control at %x", this, mpControl);
- ContextChangeReceiverInterface* pContextChangeReceiver
- = dynamic_cast<ContextChangeReceiverInterface*>(mpControl);
+ IContextChangeReceiver* pContextChangeReceiver
+ = dynamic_cast<IContextChangeReceiver*>(mpControl);
if (pContextChangeReceiver != NULL)
{
const EnumContext aContext(
Modified: openoffice/branches/sidebar/main/sfx2/source/sidebar/Theme.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sfx2/source/sidebar/Theme.cxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sfx2/source/sidebar/Theme.cxx (original)
+++ openoffice/branches/sidebar/main/sfx2/source/sidebar/Theme.cxx Mon Mar 18 17:14:04 2013
@@ -105,6 +105,8 @@ Color Theme::GetColor (const ThemeItem e
return rTheme.maColors[nIndex];
else if (eType == PT_Paint)
return rTheme.maPaints[nIndex].GetColor();
+ else
+ return COL_WHITE;
}
Modified: openoffice/branches/sidebar/main/svx/Library_svx.mk
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/Library_svx.mk?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/svx/Library_svx.mk (original)
+++ openoffice/branches/sidebar/main/svx/Library_svx.mk Mon Mar 18 17:14:04 2013
@@ -170,8 +170,13 @@ $(eval $(call gb_Library_add_exception_o
svx/source/mnuctrls/fntszctl \
svx/source/mnuctrls/SmartTagCtl \
svx/source/sidebar/ContextChangeEventMultiplexer \
+ svx/source/sidebar/EmptyPanel \
svx/source/sidebar/PanelFactory \
- svx/source/sidebar/ColorPanel \
+ svx/source/sidebar/SelectionAnalyzer \
+ svx/source/sidebar/SelectionChangeHandler \
+ svx/source/sidebar/debug/ColorPanel \
+ svx/source/sidebar/debug/ContextPanel \
+ svx/source/sidebar/debug/NotYetImplementedPanel \
svx/source/sidebar/text/SvxSBFontNameBox \
svx/source/sidebar/text/TextPropertyPanel \
svx/source/sidebar/area/AreaPropertyPanel \
Modified: openoffice/branches/sidebar/main/svx/Package_inc.mk
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/Package_inc.mk?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/svx/Package_inc.mk (original)
+++ openoffice/branches/sidebar/main/svx/Package_inc.mk Mon Mar 18 17:14:04 2013
@@ -560,5 +560,7 @@ $(eval $(call gb_Package_add_file,svx_in
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/Popup.hxx,svx/sidebar/Popup.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/PopupContainer.hxx,svx/sidebar/PopupContainer.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/PopupControl.hxx,svx/sidebar/PopupControl.hxx))
+$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/SelectionAnalyzer.hxx,svx/sidebar/SelectionAnalyzer.hxx))
+$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/SelectionChangeHandler.hxx,svx/sidebar/SelectionChangeHandler.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/ValueSetWithTextControl.hxx,svx/sidebar/ValueSetWithTextControl.hxx))
Modified: openoffice/branches/sidebar/main/svx/inc/svx/sidebar/ContextChangeEventMultiplexer.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/inc/svx/sidebar/ContextChangeEventMultiplexer.hxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/svx/inc/svx/sidebar/ContextChangeEventMultiplexer.hxx (original)
+++ openoffice/branches/sidebar/main/svx/inc/svx/sidebar/ContextChangeEventMultiplexer.hxx Mon Mar 18 17:14:04 2013
@@ -30,15 +30,36 @@
namespace css = ::com::sun::star;
namespace cssu = ::com::sun::star::uno;
+class SfxViewShell;
+
/** Convenience frontend for com::sun::star::ui::ContextChangeEventMultiplexer
*/
class SVX_DLLPUBLIC ContextChangeEventMultiplexer
{
public:
+ /** Notify the activation of a context.
+ @param rxController
+ This controller is used to determine the module (ie
+ application like Writer or Calc).
+ @param eContext
+ The activated context.
+ */
static void NotifyContextChange (
const cssu::Reference<css::frame::XController>& rxController,
const ::sfx2::sidebar::EnumContext::Context eContext);
+ /** Notify the activation of a context.
+ @param pViewShell
+ This view shell is used to determine the module (ie
+ application like Writer or Calc). When <NULL/> then no
+ notification is made.
+ @param eContext
+ The activated context.
+ */
+ static void NotifyContextChange (
+ SfxViewShell* pViewShell,
+ const ::sfx2::sidebar::EnumContext::Context eContext);
+
private:
static ::rtl::OUString GetModuleName (
const cssu::Reference<css::frame::XFrame>& rxFrame);
Added: openoffice/branches/sidebar/main/svx/inc/svx/sidebar/SelectionAnalyzer.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/inc/svx/sidebar/SelectionAnalyzer.hxx?rev=1457873&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/inc/svx/sidebar/SelectionAnalyzer.hxx (added)
+++ openoffice/branches/sidebar/main/svx/inc/svx/sidebar/SelectionAnalyzer.hxx Mon Mar 18 17:14:04 2013
@@ -0,0 +1,66 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef _SVX_SIDEBAR_SELECTION_ANALYZER_HXX_
+#define _SVX_SIDEBAR_SELECTION_ANALYZER_HXX_
+
+#include <sfx2/sidebar/EnumContext.hxx>
+#include "svx/svxdllapi.h"
+
+class SdrMarkList;
+class SdrObject;
+
+
+namespace svx { namespace sidebar {
+
+class SVX_DLLPUBLIC SelectionAnalyzer
+{
+public :
+ static sfx2::sidebar::EnumContext::Context GetContextForSelection_SC (
+ const SdrMarkList& rMarkList);
+ static sfx2::sidebar::EnumContext::Context GetContextForSelection_SD (
+ const SdrMarkList& rMarkList,
+ const bool bIsMasterPage,
+ const bool bIsHandoutPage,
+ const bool bIsNotesPage);
+
+private:
+ static sfx2::sidebar::EnumContext::Context GetContextForObjectId_SC (
+ const sal_uInt16 nObjectId);
+ static sfx2::sidebar::EnumContext::Context GetContextForObjectId_SD (
+ const sal_uInt16 nObjectId,
+ const bool bIsHandoutPage,
+ const bool bIsNotesPage);
+ static sal_uInt32 GetInventorTypeFromMark (
+ const SdrMarkList& rMarkList);
+ static sal_uInt16 GetObjectTypeFromMark (
+ const SdrMarkList& rMarkList);
+ static sal_uInt16 GetObjectTypeFromGroup (
+ const SdrObject* pObj);
+ static bool IsShapeType (
+ const sal_uInt16 nType);
+ static bool IsTextObjType (
+ const sal_uInt16 nType);
+};
+
+} } // end of namespace svx::sidebar
+
+#endif
Added: openoffice/branches/sidebar/main/svx/inc/svx/sidebar/SelectionChangeHandler.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/inc/svx/sidebar/SelectionChangeHandler.hxx?rev=1457873&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/inc/svx/sidebar/SelectionChangeHandler.hxx (added)
+++ openoffice/branches/sidebar/main/svx/inc/svx/sidebar/SelectionChangeHandler.hxx Mon Mar 18 17:14:04 2013
@@ -0,0 +1,89 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef _SVX_SIDEBAR_SELECTION_CHANGE_HANDLER_HXX_
+#define _SVX_SIDEBAR_SELECTION_CHANGE_HANDLER_HXX_
+
+#include "svx/svxdllapi.h"
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
+
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <boost/noncopyable.hpp>
+#include <boost/function.hpp>
+
+namespace css = ::com::sun::star;
+namespace cssu = ::com::sun::star::uno;
+
+
+class SdrMarkView;
+
+
+namespace svx { namespace sidebar {
+
+namespace {
+ typedef ::cppu::WeakComponentImplHelper1 <
+ css::view::XSelectionChangeListener
+ > SelectionChangeHandlerInterfaceBase;
+}
+
+
+class SVX_DLLPUBLIC SelectionChangeHandler
+ : private ::boost::noncopyable,
+ private ::cppu::BaseMutex,
+ public SelectionChangeHandlerInterfaceBase
+{
+public:
+ SelectionChangeHandler (
+ const boost::function<sfx2::sidebar::EnumContext::Context(void)>& rSelectionChangeCallback,
+ const cssu::Reference<css::frame::XController>& rxController,
+ const sfx2::sidebar::EnumContext::Context eDefaultContext);
+ virtual ~SelectionChangeHandler (void);
+
+ virtual void SAL_CALL selectionChanged (const css::lang::EventObject& rEvent)
+ throw (cssu::RuntimeException);
+
+ virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
+ throw (cssu::RuntimeException);
+
+ virtual void SAL_CALL disposing (void)
+ throw (cssu::RuntimeException);
+
+ void Connect (void);
+ void Disconnect (void);
+
+private:
+ const boost::function<sfx2::sidebar::EnumContext::Context(void)> maSelectionChangeCallback;
+ cssu::Reference<css::frame::XController> mxController;
+ const sfx2::sidebar::EnumContext::Context meDefaultContext;
+ bool mbIsConnected;
+};
+
+
+} } // end of namespace svx::sidebar
+
+
+#endif
+
Modified: openoffice/branches/sidebar/main/svx/source/sidebar/ContextChangeEventMultiplexer.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/ContextChangeEventMultiplexer.cxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/ContextChangeEventMultiplexer.cxx (original)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/ContextChangeEventMultiplexer.cxx Mon Mar 18 17:14:04 2013
@@ -29,13 +29,12 @@
#include <com/sun/star/frame/XModuleManager.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/componentcontext.hxx>
-
+#include <sfx2/viewsh.hxx>
#include <tools/diagnose_ex.h>
using namespace css;
using namespace cssu;
-#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
void ContextChangeEventMultiplexer::NotifyContextChange (
const cssu::Reference<css::frame::XController>& rxController,
@@ -59,6 +58,17 @@ void ContextChangeEventMultiplexer::Noti
+void ContextChangeEventMultiplexer::NotifyContextChange (
+ SfxViewShell* pViewShell,
+ const ::sfx2::sidebar::EnumContext::Context eContext)
+{
+ if (pViewShell != NULL)
+ NotifyContextChange(pViewShell->GetController(), eContext);
+}
+
+
+
+
::rtl::OUString ContextChangeEventMultiplexer::GetModuleName (
const cssu::Reference<css::frame::XFrame>& rxFrame)
{
@@ -77,5 +87,5 @@ void ContextChangeEventMultiplexer::Noti
// Ignore it.
}
return ::sfx2::sidebar::EnumContext::GetApplicationName(
- ::sfx2::sidebar::EnumContext::Application_Unknown);
+ ::sfx2::sidebar::EnumContext::Application_None);
}
Added: openoffice/branches/sidebar/main/svx/source/sidebar/EmptyPanel.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/EmptyPanel.cxx?rev=1457873&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/EmptyPanel.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/EmptyPanel.cxx Mon Mar 18 17:14:04 2013
@@ -0,0 +1,49 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include "EmptyPanel.hxx"
+
+namespace svx { namespace sidebar {
+
+EmptyPanel::EmptyPanel (::Window* pParent)
+ : Window(pParent, 0),
+ maMessageControl(this, 0)
+{
+ maMessageControl.SetPosSizePixel(5,5, 250,15);
+ maMessageControl.SetText(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Intentionally letft blank")));
+
+ maMessageControl.Show();
+ Show();
+}
+
+
+
+
+EmptyPanel::~EmptyPanel (void)
+{
+}
+
+
+
+
+} } // end of namespace ::svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/EmptyPanel.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/EmptyPanel.hxx?rev=1457873&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/EmptyPanel.hxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/EmptyPanel.hxx Mon Mar 18 17:14:04 2013
@@ -0,0 +1,48 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef SVX_SIDEBAR_DEBUG_EMPTY_PANEL_HXX
+#define SVX_SIDEBAR_DEBUG_EMPTY_PANEL_HXX
+
+#include <vcl/window.hxx>
+#include <vcl/fixed.hxx>
+
+
+namespace svx { namespace sidebar {
+
+
+/** Display a panel that tells the user that the current deck is
+ intentionally empty.
+*/
+class EmptyPanel
+ : public Window
+{
+public:
+ EmptyPanel (::Window* pParent);
+ virtual ~EmptyPanel (void);
+
+private:
+ FixedText maMessageControl;
+};
+
+} } // end of namespace ::svx::sidebar
+
+#endif
Modified: openoffice/branches/sidebar/main/svx/source/sidebar/PanelFactory.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/PanelFactory.cxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/PanelFactory.cxx (original)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/PanelFactory.cxx Mon Mar 18 17:14:04 2013
@@ -27,7 +27,10 @@
#include "line/LinePropertyPanel.hxx"
#include "possize/PosSizePropertyPanel.hxx"
#include "gallery/GalleryControl.hxx"
-#include "ColorPanel.hxx"
+#include "debug/ColorPanel.hxx"
+#include "debug/ContextPanel.hxx"
+#include "debug/NotYetImplementedPanel.hxx"
+#include "EmptyPanel.hxx"
#include <sfx2/sidebar/SidebarPanelBase.hxx>
#include <sfx2/sfxbasecontroller.hxx>
#include <toolkit/helper/vclunohelper.hxx>
@@ -193,15 +196,44 @@ Reference<ui::XUIElement> SAL_CALL Panel
}
else if (DoesResourceEndWith("/Debug_ColorPanel"))
{
- ColorPanel* pColorPanel = new ColorPanel(
- pParentWindow);
+ ColorPanel* pPanel = new ColorPanel(pParentWindow);
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL,
xFrame,
- pColorPanel,
+ pPanel,
::boost::function<void(void)>(),
ui::LayoutSize(300,-1,400));
}
+ else if (DoesResourceEndWith("/Debug_ContextPanel"))
+ {
+ ContextPanel* pPanel = new ContextPanel(pParentWindow);
+ xElement = sfx2::sidebar::SidebarPanelBase::Create(
+ rsResourceURL,
+ xFrame,
+ pPanel,
+ ::boost::function<void(void)>(),
+ ui::LayoutSize(45,45,45));
+ }
+ else if (DoesResourceEndWith("/Debug_NotYetImplementedPanel"))
+ {
+ NotYetImplementedPanel* pPanel = new NotYetImplementedPanel(pParentWindow);
+ xElement = sfx2::sidebar::SidebarPanelBase::Create(
+ rsResourceURL,
+ xFrame,
+ pPanel,
+ ::boost::function<void(void)>(),
+ ui::LayoutSize(20,25,25));
+ }
+ else if (DoesResourceEndWith("/EmptyPanel"))
+ {
+ EmptyPanel* pPanel = new EmptyPanel(pParentWindow);
+ xElement = sfx2::sidebar::SidebarPanelBase::Create(
+ rsResourceURL,
+ xFrame,
+ pPanel,
+ ::boost::function<void(void)>(),
+ ui::LayoutSize(20,25,25));
+ }
#undef DoesResourceEndWith
return xElement;
Added: openoffice/branches/sidebar/main/svx/source/sidebar/SelectionAnalyzer.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/SelectionAnalyzer.cxx?rev=1457873&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/SelectionAnalyzer.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/SelectionAnalyzer.cxx Mon Mar 18 17:14:04 2013
@@ -0,0 +1,461 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include "svx/sidebar/SelectionAnalyzer.hxx"
+#include "svx/svdmrkv.hxx"
+#include "svx/svdobj.hxx"
+#include "svx/svdpage.hxx"
+#include "svx/fmglob.hxx"
+#include "svx/globl3d.hxx"
+
+using sfx2::sidebar::EnumContext;
+
+
+namespace svx { namespace sidebar {
+
+EnumContext::Context SelectionAnalyzer::GetContextForSelection_SC (const SdrMarkList& rMarkList)
+{
+ EnumContext::Context eContext = EnumContext::Context_Unknown;
+
+ switch (rMarkList.GetMarkCount())
+ {
+ case 0:
+ // Empty selection. Return Context_Unknown to let the caller
+ // substitute it with the default context.
+ break;
+
+ case 1:
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ const sal_uInt32 nInv = pObj->GetObjInventor();
+ const sal_uInt16 nObjId = pObj->GetObjIdentifier();
+ if (nInv == SdrInventor)
+ eContext = GetContextForObjectId_SC(nObjId);
+ else if (nInv == FmFormInventor)
+ eContext = EnumContext::Context_Form;
+ break;
+ }
+
+ default:
+ {
+ // Multi selection.
+ switch (GetInventorTypeFromMark(rMarkList))
+ {
+ case SdrInventor:
+ {
+ const sal_uInt16 nObjId (GetObjectTypeFromMark(rMarkList));
+ if (nObjId == 0)
+ eContext = EnumContext::Context_MultiObject;
+ else
+ eContext = GetContextForObjectId_SC(nObjId);
+ break;
+ }
+
+ case FmFormInventor:
+ eContext = EnumContext::Context_Form;
+ break;
+
+ case 0:
+ eContext = EnumContext::Context_MultiObject;
+ break;
+ }
+ }
+ }
+
+ return eContext;
+}
+
+
+
+
+EnumContext::Context SelectionAnalyzer::GetContextForSelection_SD (
+ const SdrMarkList& rMarkList,
+ const bool bIsMasterPage,
+ const bool bIsHandoutPage,
+ const bool bIsNotesPage)
+{
+ EnumContext::Context eContext = EnumContext::Context_Unknown;
+
+ // Note that some cases are handled by the caller. They rely on
+ // sd specific data.
+ switch (rMarkList.GetMarkCount())
+ {
+ case 0:
+ if (bIsHandoutPage)
+ eContext = EnumContext::Context_HandoutPage;
+ else if (bIsNotesPage)
+ eContext = EnumContext::Context_NotesPage;
+ else if (bIsMasterPage)
+ eContext = EnumContext::Context_MasterPage;
+ else
+ eContext = EnumContext::Context_DrawPage;
+ break;
+
+ case 1:
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ const sal_uInt32 nInv = pObj->GetObjInventor();
+ sal_uInt16 nObjId = pObj->GetObjIdentifier();
+ if (nInv == SdrInventor)
+ {
+ if (nObjId == OBJ_GRUP)
+ {
+ nObjId = GetObjectTypeFromGroup(pObj);
+ if (nObjId == 0)
+ nObjId = OBJ_GRUP;
+ }
+ eContext = GetContextForObjectId_SD(nObjId, bIsHandoutPage, bIsNotesPage);
+ }
+ else if (nInv == E3dInventor)
+ {
+ eContext = EnumContext::Context_3DObject;
+ }
+ else if (nInv == FmFormInventor)
+ {
+ eContext = EnumContext::Context_Form;
+ }
+ break;
+ }
+
+ default:
+ {
+ switch (GetInventorTypeFromMark(rMarkList))
+ {
+ case SdrInventor:
+ {
+ const sal_uInt16 nObjId = GetObjectTypeFromMark(rMarkList);
+ if (nObjId == 0)
+ eContext = EnumContext::Context_MultiObject;
+ else
+ eContext = GetContextForObjectId_SD(nObjId, bIsHandoutPage, bIsNotesPage);
+ break;
+ }
+
+ case E3dInventor:
+ eContext = EnumContext::Context_3DObject;
+ break;
+
+ case FmFormInventor:
+ eContext = EnumContext::Context_Form;
+ break;
+
+ case 0:
+ eContext = EnumContext::Context_MultiObject;
+ break;
+ }
+ break;
+ }
+ }
+
+ return eContext;
+}
+
+
+
+
+EnumContext::Context SelectionAnalyzer::GetContextForObjectId_SC (const sal_uInt16 nObjectId)
+{
+ switch (nObjectId)
+ {
+ case OBJ_CAPTION:
+ case OBJ_TITLETEXT:
+ case OBJ_OUTLINETEXT:
+ case OBJ_TEXT:
+ case OBJ_TEXTEXT:
+ case OBJ_PATHLINE:
+ case OBJ_PLIN:
+ case OBJ_FREELINE:
+ case OBJ_EDGE:
+ case OBJ_LINE:
+ case OBJ_MEASURE:
+ case OBJ_RECT:
+ case OBJ_CIRC:
+ case OBJ_FREEFILL:
+ case OBJ_PATHFILL:
+ case OBJ_POLY:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT:
+ case OBJ_CUSTOMSHAPE:
+ case OBJ_GRUP:
+ return EnumContext::Context_Draw;
+
+ case OBJ_GRAF:
+ return EnumContext::Context_Graphic;
+
+ case OBJ_OLE2:
+ return EnumContext::Context_OLE;
+
+ case OBJ_MEDIA:
+ return EnumContext::Context_Media;
+ break;
+
+ default:
+ return EnumContext::Context_Unknown;
+ }
+}
+
+
+
+
+EnumContext::Context SelectionAnalyzer::GetContextForObjectId_SD (
+ const sal_uInt16 nObjectId,
+ const bool bIsHandoutPage,
+ const bool bIsNotesPage)
+{
+ switch (nObjectId)
+ {
+ case OBJ_CAPTION:
+ case OBJ_PATHLINE:
+ case OBJ_PLIN:
+ case OBJ_FREELINE:
+ case OBJ_EDGE:
+ case OBJ_LINE:
+ case OBJ_MEASURE:
+ case OBJ_RECT:
+ case OBJ_CIRC:
+ case OBJ_FREEFILL:
+ case OBJ_PATHFILL:
+ case OBJ_POLY:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT:
+ case OBJ_CUSTOMSHAPE:
+ case OBJ_GRUP:
+ return EnumContext::Context_Draw;
+
+ case OBJ_TITLETEXT:
+ case OBJ_OUTLINETEXT:
+ case OBJ_TEXT:
+ case OBJ_TEXTEXT:
+ return EnumContext::Context_TextObject;
+
+ case OBJ_GRAF:
+ return EnumContext::Context_Graphic;
+
+ case OBJ_OLE2:
+ return EnumContext::Context_OLE;
+
+ case OBJ_MEDIA:
+ return EnumContext::Context_Media;
+
+ case OBJ_TABLE:
+ return EnumContext::Context_Table;
+
+ case OBJ_PAGE:
+ if (bIsHandoutPage)
+ return EnumContext::Context_HandoutPage;
+ else if (bIsNotesPage)
+ return EnumContext::Context_NotesPage;
+ else
+ return EnumContext::Context_Unknown;
+
+ default:
+ return EnumContext::Context_Unknown;
+ }
+}
+
+
+
+
+sal_uInt32 SelectionAnalyzer::GetInventorTypeFromMark (const SdrMarkList& rMarkList)
+{
+ const sal_uLong nMarkCount (rMarkList.GetMarkCount());
+
+ if (nMarkCount < 1)
+ return 0;
+
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ const sal_uInt32 nFirstInv = pObj->GetObjInventor();
+
+ for (sal_uLong nIndex=1; nIndex<nMarkCount; ++nIndex)
+ {
+ pMark = rMarkList.GetMark(nIndex);
+ pObj = pMark->GetMarkedSdrObj();
+ const sal_uInt32 nInv (pObj->GetObjInventor());
+
+ if (nInv != nFirstInv)
+ return 0;
+ }
+
+ return nFirstInv;
+}
+
+
+
+
+sal_uInt16 SelectionAnalyzer::GetObjectTypeFromGroup (const SdrObject* pObj)
+{
+ SdrObjList* pObjList = pObj->GetSubList();
+ if (pObjList)
+ {
+ const sal_uLong nSubObjCount (pObjList->GetObjCount());
+
+ if (nSubObjCount>0)
+ {
+ SdrObject* pObj = pObjList->GetObj(0);
+ sal_uInt16 nResultType = pObj->GetObjIdentifier();
+
+ if (nResultType == OBJ_GRUP)
+ nResultType = GetObjectTypeFromGroup(pObj);
+
+ if (IsShapeType(nResultType))
+ nResultType = OBJ_CUSTOMSHAPE;
+
+ if (IsTextObjType(nResultType))
+ nResultType = OBJ_TEXT;
+
+ for (sal_uInt16 nIndex=1; nIndex<nSubObjCount; ++nIndex)
+ {
+ pObj = pObjList->GetObj(nIndex);
+ sal_uInt16 nType (pObj->GetObjIdentifier());
+
+ if(nType == OBJ_GRUP)
+ nType = GetObjectTypeFromGroup(pObj);
+
+ if (IsShapeType(nType))
+ nType = OBJ_CUSTOMSHAPE;
+
+ if ((nType == OBJ_CUSTOMSHAPE) && (nResultType == OBJ_TEXT))
+ nType = OBJ_TEXT;
+
+ if (IsTextObjType(nType))
+ nType = OBJ_TEXT;
+
+ if ((nType == OBJ_TEXT) && (nResultType == OBJ_CUSTOMSHAPE))
+ nResultType = OBJ_TEXT;
+
+ if (nType != nResultType)
+ return 0;
+ }
+
+ return nResultType;
+ }
+ }
+
+ return 0;
+}
+
+
+
+
+sal_uInt16 SelectionAnalyzer::GetObjectTypeFromMark (const SdrMarkList& rMarkList)
+{
+ const sal_uLong nMarkCount (rMarkList.GetMarkCount());
+
+ if (nMarkCount < 1)
+ return 0;
+
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ sal_uInt16 nResultType = pObj->GetObjIdentifier();
+
+ if(nResultType == OBJ_GRUP)
+ nResultType = GetObjectTypeFromGroup(pObj);
+
+ if (IsShapeType(nResultType))
+ nResultType = OBJ_CUSTOMSHAPE;
+
+ if (IsTextObjType(nResultType))
+ nResultType = OBJ_TEXT;
+
+ for (sal_uLong nIndex=1; nIndex<nMarkCount; ++nIndex)
+ {
+ pMark = rMarkList.GetMark(nIndex);
+ pObj = pMark->GetMarkedSdrObj();
+ sal_uInt16 nType = pObj->GetObjIdentifier();
+
+ if(nType == OBJ_GRUP)
+ nType = GetObjectTypeFromGroup(pObj);
+
+ if (IsShapeType(nType))
+ nType = OBJ_CUSTOMSHAPE;
+
+ if ((nType == OBJ_CUSTOMSHAPE) && (nResultType == OBJ_TEXT))
+ nType = OBJ_TEXT;
+
+ if (IsTextObjType(nType))
+ nType = OBJ_TEXT;
+
+ if ((nType == OBJ_TEXT) && (nResultType == OBJ_CUSTOMSHAPE))
+ nResultType = OBJ_TEXT;
+
+ if (nType != nResultType)
+ return 0;
+ }
+
+ return nResultType;
+}
+
+
+
+
+bool SelectionAnalyzer::IsShapeType (const sal_uInt16 nType)
+{
+ switch (nType)
+ {
+ case OBJ_LINE:
+ case OBJ_CARC:
+ case OBJ_PLIN:
+ case OBJ_PATHLINE:
+ case OBJ_RECT:
+ case OBJ_CIRC:
+ case OBJ_SECT:
+ case OBJ_CCUT:
+ case OBJ_PATHFILL:
+ case OBJ_CUSTOMSHAPE:
+ case OBJ_CAPTION:
+ case OBJ_MEASURE:
+ case OBJ_EDGE:
+ case OBJ_POLY:
+ case OBJ_FREELINE:
+ case OBJ_FREEFILL:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+
+
+
+bool SelectionAnalyzer::IsTextObjType (const sal_uInt16 nType)
+{
+ switch(nType)
+ {
+ case OBJ_TEXT:
+ case OBJ_TEXTEXT:
+ case OBJ_TITLETEXT:
+ case OBJ_OUTLINETEXT:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+
+
+} } // end of namespace ::svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/SelectionChangeHandler.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/SelectionChangeHandler.cxx?rev=1457873&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/SelectionChangeHandler.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/SelectionChangeHandler.cxx Mon Mar 18 17:14:04 2013
@@ -0,0 +1,119 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "svx/sidebar/SelectionChangeHandler.hxx"
+#include "svx/sidebar/SelectionAnalyzer.hxx"
+#include "svx/sidebar/ContextChangeEventMultiplexer.hxx"
+#include "svx/svdmrkv.hxx"
+
+#include <sfx2/sidebar/EnumContext.hxx>
+#include <sfx2/shell.hxx>
+
+
+using namespace css;
+using namespace cssu;
+
+using namespace sfx2::sidebar;
+
+namespace svx { namespace sidebar {
+
+SelectionChangeHandler::SelectionChangeHandler (
+ const boost::function<sfx2::sidebar::EnumContext::Context(void)>& rSelectionChangeCallback,
+ const Reference<frame::XController>& rxController,
+ const EnumContext::Context eDefaultContext)
+ : SelectionChangeHandlerInterfaceBase(m_aMutex),
+ maSelectionChangeCallback(rSelectionChangeCallback),
+ mxController(rxController),
+ meDefaultContext(eDefaultContext),
+ mbIsConnected(false)
+{
+}
+
+
+
+
+SelectionChangeHandler::~SelectionChangeHandler (void)
+{
+}
+
+
+
+
+void SAL_CALL SelectionChangeHandler::selectionChanged (const lang::EventObject&)
+ throw (uno::RuntimeException)
+{
+ if (maSelectionChangeCallback)
+ {
+ const EnumContext::Context eContext (maSelectionChangeCallback());
+ ContextChangeEventMultiplexer::NotifyContextChange(
+ mxController,
+ eContext==EnumContext::Context_Unknown
+ ? meDefaultContext
+ : eContext);
+ }
+}
+
+
+
+
+void SAL_CALL SelectionChangeHandler::disposing (const lang::EventObject&)
+ throw (uno::RuntimeException)
+{
+}
+
+
+
+
+void SAL_CALL SelectionChangeHandler::disposing (void)
+ throw (uno::RuntimeException)
+{
+ if (mbIsConnected)
+ Disconnect();
+}
+
+
+
+
+void SelectionChangeHandler::Connect (void)
+{
+ uno::Reference<view::XSelectionSupplier> xSupplier (mxController, uno::UNO_QUERY);
+ if (xSupplier.is())
+ {
+ mbIsConnected = true;
+ xSupplier->addSelectionChangeListener(this);
+ }
+}
+
+
+
+
+void SelectionChangeHandler::Disconnect (void)
+{
+ uno::Reference<view::XSelectionSupplier> xSupplier (mxController, uno::UNO_QUERY);
+ if (xSupplier.is())
+ {
+ mbIsConnected = false;
+ xSupplier->removeSelectionChangeListener(this);
+ }
+}
+
+
+} } // end of namespace svx::sidebar
Modified: openoffice/branches/sidebar/main/svx/source/sidebar/area/AreaPropertyPanel.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/area/AreaPropertyPanel.hxx?rev=1457873&r1=1457872&r2=1457873&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/area/AreaPropertyPanel.hxx (original)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/area/AreaPropertyPanel.hxx Mon Mar 18 17:14:04 2013
@@ -27,6 +27,7 @@
#include <vcl/ctrl.hxx>
#include <sfx2/sidebar/SidebarPanelBase.hxx>
#include <sfx2/sidebar/ControllerItem.hxx>
+#include <sfx2/sidebar/IContextChangeReceiver.hxx>
#include <svx/xgrad.hxx>
#include <svx/itemwin.hxx>
#include <svx/xfillit0.hxx>
@@ -55,7 +56,7 @@ class AreaTransparencyGradientControl;
class AreaPropertyPanel
: public Control,
- public ::sfx2::sidebar::SidebarPanelBase::ContextChangeReceiverInterface,
+ public ::sfx2::sidebar::IContextChangeReceiver,
public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
{
public:
Added: openoffice/branches/sidebar/main/svx/source/sidebar/debug/ColorPanel.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/debug/ColorPanel.cxx?rev=1457873&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/debug/ColorPanel.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/debug/ColorPanel.cxx Mon Mar 18 17:14:04 2013
@@ -0,0 +1,233 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include "ColorPanel.hxx"
+
+#include <vcl/image.hxx>
+#include <vcl/svapp.hxx>
+
+namespace svx { namespace sidebar {
+
+ColorPanel::ColorPanel (::Window* pParent)
+ : ValueSet(pParent),
+ mnPreferredColumnCount(2)
+{
+ WinBits aStyle =
+ WB_ITEMBORDER
+ | WB_DOUBLEBORDER
+ | WB_NAMEFIELD
+ | WB_FLATVALUESET
+ | WB_TABSTOP
+ | WB_VSCROLL;
+
+ SetStyle(GetStyle() | aStyle);
+ SetExtraSpacing(2);
+
+ Fill ();
+ Show();
+}
+
+
+
+
+ColorPanel::~ColorPanel (void)
+{
+}
+
+
+
+
+sal_Int32 ColorPanel::GetPreferredHeight (sal_Int32 nWidth)
+{
+ sal_Int32 nPreferredHeight = 0;
+ if (GetItemCount()>0)
+ {
+ Image aImage = GetItemImage(GetItemId(0));
+ Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel());
+ if (nWidth>0 && aItemSize.Width()>0)
+ {
+ int nColumnCount = nWidth / aItemSize.Width();
+ if (nColumnCount <= 0)
+ nColumnCount = 1;
+ else if (nColumnCount > 4)
+ nColumnCount = 4;
+ int nRowCount = (GetItemCount() + nColumnCount-1)
+ / nColumnCount;
+ nPreferredHeight = nRowCount * aItemSize.Height();
+ }
+ }
+ return nPreferredHeight;
+}
+
+
+
+
+void ColorPanel::Resize (void)
+{
+ ::Window::Resize();
+ Size aWindowSize = GetOutputSizePixel();
+ SetPosSizePixel(Point(0,0), aWindowSize);
+ if (IsVisible() && aWindowSize.Width() > 0)
+ {
+ // Calculate the number of rows and columns.
+ if (GetItemCount() > 0)
+ {
+ Image aImage = GetItemImage(GetItemId(0));
+ Size aItemSize = CalcItemSizePixel (
+ aImage.GetSizePixel());
+ int nColumnCount = aWindowSize.Width() / 30;
+ if (nColumnCount < 1)
+ nColumnCount = 1;
+ else if (nColumnCount > 4)
+ nColumnCount = 4;
+
+ sal_uInt16 nRowCount = (sal_uInt16)CalculateRowCount(aItemSize, nColumnCount);
+
+ SetColCount((sal_uInt16)nColumnCount);
+ SetLineCount(nRowCount);
+ }
+ }
+
+}
+
+
+
+
+int ColorPanel::CalculateRowCount (const Size&, int nColumnCount)
+{
+ int nRowCount = 0;
+
+ if (GetItemCount()>0 && nColumnCount>0)
+ {
+ nRowCount = GetOutputSizePixel().Height() / 30;
+ if (nRowCount < 1)
+ nRowCount = 1;
+ }
+
+ return nRowCount;
+}
+
+
+
+
+void ColorPanel::DataChanged (const DataChangedEvent& rEvent)
+{
+ Fill();
+}
+
+
+
+
+void ColorPanel::Fill (void)
+{
+ const StyleSettings& rSettings (
+ Application::GetSettings().GetStyleSettings());
+ Clear();
+ SetItemWidth (30);
+ SetItemHeight (30);
+ sal_uInt16 i = 0;
+ InsertItem (++i, rSettings.GetFaceColor());
+ SetItemText (i, String::CreateFromAscii("FaceColor"));
+ InsertItem (++i, rSettings.GetCheckedColor());
+ SetItemText (i, String::CreateFromAscii("CheckedColor"));
+ InsertItem (++i, rSettings.GetLightColor());
+ SetItemText (i, String::CreateFromAscii("LightColor"));
+ InsertItem (++i, rSettings.GetLightBorderColor());
+ SetItemText (i, String::CreateFromAscii("LightBorderColor"));
+ InsertItem (++i, rSettings.GetShadowColor());
+ SetItemText (i, String::CreateFromAscii("ShadowColor"));
+ InsertItem (++i, rSettings.GetDarkShadowColor());
+ SetItemText (i, String::CreateFromAscii("DarkShadowColor"));
+ InsertItem (++i, rSettings.GetButtonTextColor());
+ SetItemText (i, String::CreateFromAscii("ButtonTextColor"));
+ InsertItem (++i, rSettings.GetRadioCheckTextColor());
+ SetItemText (i, String::CreateFromAscii("RadioCheckTextColor"));
+ InsertItem (++i, rSettings.GetGroupTextColor());
+ SetItemText (i, String::CreateFromAscii("GroupTextColor"));
+ InsertItem (++i, rSettings.GetLabelTextColor());
+ SetItemText (i, String::CreateFromAscii("LabelTextColor"));
+ InsertItem (++i, rSettings.GetInfoTextColor());
+ SetItemText (i, String::CreateFromAscii("InfoTextColor"));
+ InsertItem (++i, rSettings.GetWindowColor());
+ SetItemText (i, String::CreateFromAscii("WindowColor"));
+ InsertItem (++i, rSettings.GetWindowTextColor());
+ SetItemText (i, String::CreateFromAscii("WindowTextColor"));
+ InsertItem (++i, rSettings.GetDialogColor());
+ SetItemText (i, String::CreateFromAscii("DialogColor"));
+ InsertItem (++i, rSettings.GetDialogTextColor());
+ SetItemText (i, String::CreateFromAscii("DialogTextColor"));
+ InsertItem (++i, rSettings.GetWorkspaceColor());
+ SetItemText (i, String::CreateFromAscii("WorkspaceColor"));
+ InsertItem (++i, rSettings.GetFieldColor());
+ SetItemText (i, String::CreateFromAscii("FieldColor"));
+ InsertItem (++i, rSettings.GetFieldTextColor());
+ SetItemText (i, String::CreateFromAscii("FieldTextColor"));
+ InsertItem (++i, rSettings.GetActiveColor());
+ SetItemText (i, String::CreateFromAscii("ActiveColor"));
+ InsertItem (++i, rSettings.GetActiveColor2());
+ SetItemText (i, String::CreateFromAscii("ActiveColor2"));
+ InsertItem (++i, rSettings.GetActiveTextColor());
+ SetItemText (i, String::CreateFromAscii("ActiveTextColor"));
+ InsertItem (++i, rSettings.GetActiveBorderColor());
+ SetItemText (i, String::CreateFromAscii("ActiveBorderColor"));
+ InsertItem (++i, rSettings.GetDeactiveColor());
+ SetItemText (i, String::CreateFromAscii("DeactiveColor"));
+ InsertItem (++i, rSettings.GetDeactiveColor2());
+ SetItemText (i, String::CreateFromAscii("DeactiveColor2"));
+ InsertItem (++i, rSettings.GetDeactiveTextColor());
+ SetItemText (i, String::CreateFromAscii("DeactiveTextColor"));
+ InsertItem (++i, rSettings.GetDeactiveBorderColor());
+ SetItemText (i, String::CreateFromAscii("DeactiveBorderColor"));
+ InsertItem (++i, rSettings.GetHighlightColor());
+ SetItemText (i, String::CreateFromAscii("HighlightColor"));
+ InsertItem (++i, rSettings.GetHighlightTextColor());
+ SetItemText (i, String::CreateFromAscii("HighlightTextColor"));
+ InsertItem (++i, rSettings.GetDisableColor());
+ SetItemText (i, String::CreateFromAscii("DisableColor"));
+ InsertItem (++i, rSettings.GetHelpColor());
+ SetItemText (i, String::CreateFromAscii("HelpColor"));
+ InsertItem (++i, rSettings.GetHelpTextColor());
+ SetItemText (i, String::CreateFromAscii("HelpTextColor"));
+ InsertItem (++i, rSettings.GetMenuColor());
+ SetItemText (i, String::CreateFromAscii("MenuColor"));
+ InsertItem (++i, rSettings.GetMenuBarColor());
+ SetItemText (i, String::CreateFromAscii("MenuBarColor"));
+ InsertItem (++i, rSettings.GetMenuBorderColor());
+ SetItemText (i, String::CreateFromAscii("MenuBorderColor"));
+ InsertItem (++i, rSettings.GetMenuTextColor());
+ SetItemText (i, String::CreateFromAscii("MenuTextColor"));
+ InsertItem (++i, rSettings.GetMenuHighlightColor());
+ SetItemText (i, String::CreateFromAscii("MenuHighlightColor"));
+ InsertItem (++i, rSettings.GetMenuHighlightTextColor());
+ SetItemText (i, String::CreateFromAscii("MenuHighlightTextColor"));
+ InsertItem (++i, rSettings.GetLinkColor());
+ SetItemText (i, String::CreateFromAscii("LinkColor"));
+ InsertItem (++i, rSettings.GetVisitedLinkColor());
+ SetItemText (i, String::CreateFromAscii("VisitedLinkColor"));
+ InsertItem (++i, rSettings.GetHighlightLinkColor());
+ SetItemText (i, String::CreateFromAscii("HighlightLinkColor"));
+ InsertItem (++i, rSettings.GetFontColor());
+ SetItemText (i, String::CreateFromAscii("FontColor"));
+}
+
+} } // end of namespace ::svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/debug/ColorPanel.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/debug/ColorPanel.hxx?rev=1457873&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/debug/ColorPanel.hxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/debug/ColorPanel.hxx Mon Mar 18 17:14:04 2013
@@ -0,0 +1,61 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef SVX_SIDEBAR_COLOR_PANEL_HXX
+#define SVX_SIDEBAR_COLOR_PANEL_HXX
+
+#include <svtools/valueset.hxx>
+#include <vcl/window.hxx>
+
+
+namespace svx { namespace sidebar {
+
+
+/** This demo panel shows the colors that are available from the
+ StyleSettings.
+*/
+class ColorPanel
+ : public ValueSet
+{
+public:
+ ColorPanel (::Window* pParent);
+ virtual ~ColorPanel (void);
+
+ // From ::Window
+ virtual void Resize (void);
+ virtual void DataChanged (const DataChangedEvent& rEvent);
+
+private:
+ int mnPreferredColumnCount;
+
+ /** Depending on the given number of columns and the item size
+ calculate the number of rows that are necessary to display all
+ items.
+ */
+ int CalculateRowCount (const Size& rItemSize, int nColumnCount);
+ void Fill (void);
+
+ sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
+};
+
+} } // end of namespace ::svx::sidebar
+
+#endif
Added: openoffice/branches/sidebar/main/svx/source/sidebar/debug/ContextPanel.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/debug/ContextPanel.cxx?rev=1457873&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/debug/ContextPanel.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/debug/ContextPanel.cxx Mon Mar 18 17:14:04 2013
@@ -0,0 +1,69 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include "ContextPanel.hxx"
+
+namespace svx { namespace sidebar {
+
+ContextPanel::ContextPanel (::Window* pParent)
+ : Window(pParent, 0),
+ maApplicationName(this, 0),
+ maContextName(this, 0)
+{
+ maApplicationName.SetPosSizePixel(5,5, 250,15);
+ maContextName.SetPosSizePixel(5,25, 250,15);
+
+ maApplicationName.Show();
+ maContextName.Show();
+ Show();
+}
+
+
+
+
+ContextPanel::~ContextPanel (void)
+{
+}
+
+
+
+
+sal_Int32 ContextPanel::GetPreferredHeight (sal_Int32 nWidth)
+{
+ const sal_Int32 nHeight (maContextName.GetPosPixel().Y() + maContextName.GetSizePixel().Height() + 5);
+ return nHeight;
+}
+
+
+
+
+void ContextPanel::HandleContextChange (const sfx2::sidebar::EnumContext aContext)
+{
+ maApplicationName.SetText(aContext.GetApplicationName());
+ maContextName.SetText(aContext.GetContextName());
+}
+
+
+
+
+} } // end of namespace ::svx::sidebar