Skip to content

Commit

Permalink
i121577 - Allow setting toolbar name in Addons.xcu
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/openoffice/trunk@1429069 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
arielch committed Jan 4, 2013
1 parent 2616934 commit bb0b566
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 15 deletions.
7 changes: 7 additions & 0 deletions main/framework/inc/framework/addonsoptions.hxx
Expand Up @@ -279,6 +279,13 @@ class FWE_DLLPUBLIC AddonsOptions

const ::rtl::OUString GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const;

/**
* @short Gets the UI name of a single addon toolbar
* @return The UI name of the toolbar as specified in the Addons.xcu configuration
* @onerror Returns an empty string
*/
const ::rtl::OUString GetAddonsToolbarUIName( sal_uInt32 nIndex ) const;

/*-****************************************************************************************************//**
@short Retrieves all available merge instructions for the Office menu bar
@descr -
Expand Down
77 changes: 69 additions & 8 deletions main/framework/source/fwe/classes/addonsoptions.cxx
Expand Up @@ -64,9 +64,11 @@ using namespace ::com::sun::star::lang ;
// const
//_________________________________________________________________________________________________________________

#define STR_TOOLBARITEMS "ToolBarItems"

#define ROOTNODE_ADDONMENU ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Addons" ))
#define PATHDELIMITER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
#define TOOLBARITEMS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ToolBarItems" ))
#define TOOLBARITEMS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_TOOLBARITEMS))
#define SEPARATOR_URL_STR "private:separator"
#define SEPARATOR_URL_LEN 17
#define SEPARATOR_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SEPARATOR_URL_STR ))
Expand All @@ -79,6 +81,7 @@ using namespace ::com::sun::star::lang ;
#define PROPERTYNAME_SUBMENU ADDONSMENUITEM_PROPERTYNAME_SUBMENU
#define PROPERTYNAME_CONTROLTYPE ADDONSMENUITEM_PROPERTYNAME_CONTROLTYPE
#define PROPERTYNAME_WIDTH ADDONSMENUITEM_PROPERTYNAME_WIDTH
#define PROPERTYNAME_TOOLBARITEMS TOOLBARITEMS

#define PROPERTYNAME_ALIGN STATUSBARITEM_PROPERTYNAME_ALIGN
#define PROPERTYNAME_AUTOSIZE STATUSBARITEM_PROPERTYNAME_AUTOSIZE
Expand Down Expand Up @@ -110,7 +113,7 @@ using namespace ::com::sun::star::lang ;
#define PROPERTYNAME_MERGETOOLBAR_MERGECOMMANDPARAMETER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommandParameter" ))
#define PROPERTYNAME_MERGETOOLBAR_MERGEFALLBACK ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeFallback" ))
#define PROPERTYNAME_MERGETOOLBAR_MERGECONTEXT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeContext" ))
#define PROPERTYNAME_MERGETOOLBAR_TOOLBARITEMS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ToolBarItems" ))
#define PROPERTYNAME_MERGETOOLBAR_TOOLBARITEMS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_TOOLBARITEMS ))

#define PROPERTYNAME_MERGESTATUSBAR_MERGEPOINT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergePoint" ))
#define PROPERTYNAME_MERGESTATUSBAR_MERGECOMMAND ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommand" ))
Expand All @@ -131,7 +134,8 @@ using namespace ::com::sun::star::lang ;
#define INDEX_ALIGN 8
#define INDEX_AUTOSIZE 9
#define INDEX_OWNERDRAW 10
#define PROPERTYCOUNT_INDEX 11
#define INDEX_TOOLBARITEMS 11
#define PROPERTYCOUNT_INDEX 12

// The following order is mandatory. Please add properties at the end!
#define PROPERTYCOUNT_MENUITEM 6
Expand All @@ -149,6 +153,11 @@ using namespace ::com::sun::star::lang ;
#define OFFSET_POPUPMENU_SUBMENU 2
#define OFFSET_POPUPMENU_URL 3 // Used for property set

// The following order is mandatory. Please add properties at the end!
#define PROPERTYCOUNT_TOOLBAR 2
#define OFFSET_TOOLBAR_TITLE 0
#define OFFSET_TOOLBAR_TOOLBARITEMS 1

// The following order is mandatory. Please add properties at the end!
#define PROPERTYCOUNT_TOOLBARITEM 7
#define OFFSET_TOOLBARITEM_URL 0
Expand Down Expand Up @@ -296,6 +305,7 @@ class AddonsOptions_Impl : public ConfigItem
const Sequence< Sequence< PropertyValue > >& GetAddonsMenuBarPart () const ;
const Sequence< Sequence< PropertyValue > >& GetAddonsToolBarPart ( sal_uInt32 nIndex ) const ;
const ::rtl::OUString GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const;
const ::rtl::OUString GetAddonsToolbarUIName( sal_uInt32 nIndex ) const;
const Sequence< Sequence< PropertyValue > >& GetAddonsHelpMenu () const ;
Image GetImageFromURL( const rtl::OUString& aURL, sal_Bool bBig, sal_Bool bHiContrast, sal_Bool bNoScale ) const;
const MergeMenuInstructionContainer& GetMergeMenuInstructions() const;
Expand Down Expand Up @@ -348,7 +358,9 @@ class AddonsOptions_Impl : public ConfigItem

sal_Bool ReadAddonMenuSet( Sequence< Sequence< PropertyValue > >& aAddonMenuSeq );
sal_Bool ReadOfficeMenuBarSet( Sequence< Sequence< PropertyValue > >& aAddonOfficeMenuBarSeq );
sal_Bool ReadOfficeToolBarSet( AddonToolBars& rAddonOfficeToolBars, std::vector< rtl::OUString >& rAddonOfficeToolBarResNames );
sal_Bool ReadOfficeToolBarSet( AddonToolBars& rAddonOfficeToolBars,
std::vector< rtl::OUString >& rAddonOfficeToolBarResNames,
std::vector< rtl::OUString >& rAddonOfficeToolBarUINames );
sal_Bool ReadToolBarItemSet( const rtl::OUString rToolBarItemSetNodeName, Sequence< Sequence< PropertyValue > >& aAddonOfficeToolBarSeq );
sal_Bool ReadOfficeHelpSet( Sequence< Sequence< PropertyValue > >& aAddonOfficeHelpMenuSeq );
sal_Bool ReadImages( ImageManager& aImageManager );
Expand Down Expand Up @@ -378,6 +390,7 @@ class AddonsOptions_Impl : public ConfigItem
Sequence< ::rtl::OUString > GetPropertyNamesMergeMenuInstruction( const ::rtl::OUString& aPropertyRootName ) const;
Sequence< ::rtl::OUString > GetPropertyNamesMenuItem( const ::rtl::OUString& aPropertyRootNode ) const;
Sequence< ::rtl::OUString > GetPropertyNamesPopupMenu( const ::rtl::OUString& aPropertyRootNode ) const;
Sequence< ::rtl::OUString > GetPropertyNamesToolBar( const ::rtl::OUString& aPropertyRootNode ) const;
Sequence< ::rtl::OUString > GetPropertyNamesToolBarItem( const ::rtl::OUString& aPropertyRootNode ) const;
Sequence< ::rtl::OUString > GetPropertyNamesStatusbarItem( const ::rtl::OUString& aPropertyRootNode ) const;
Sequence< ::rtl::OUString > GetPropertyNamesImages( const ::rtl::OUString& aPropertyRootNode ) const;
Expand Down Expand Up @@ -405,6 +418,7 @@ class AddonsOptions_Impl : public ConfigItem
Sequence< Sequence< PropertyValue > > m_aCachedMenuBarPartProperties;
AddonToolBars m_aCachedToolBarPartProperties;
std::vector< rtl::OUString > m_aCachedToolBarPartResourceNames;
std::vector< rtl::OUString > m_aCachedToolBarPartUINames;
Sequence< Sequence< PropertyValue > > m_aCachedHelpMenuProperties;
Reference< com::sun::star::util::XMacroExpander > m_xMacroExpander;
ImageManager m_aImageManager;
Expand Down Expand Up @@ -442,6 +456,7 @@ AddonsOptions_Impl::AddonsOptions_Impl()
m_aPropNames[ INDEX_ALIGN ] = PROPERTYNAME_ALIGN;
m_aPropNames[ INDEX_AUTOSIZE ] = PROPERTYNAME_AUTOSIZE;
m_aPropNames[ INDEX_OWNERDRAW ] = PROPERTYNAME_OWNERDRAW;
m_aPropNames[ INDEX_TOOLBARITEMS ] = PROPERTYNAME_TOOLBARITEMS;

// initialize array with fixed images property names
m_aPropImagesNames[ OFFSET_IMAGES_SMALL ] = PROPERTYNAME_IMAGESMALL;
Expand Down Expand Up @@ -515,11 +530,14 @@ void AddonsOptions_Impl::ReadConfigurationData()
m_aCachedToolBarPartProperties = AddonToolBars();
m_aCachedHelpMenuProperties = Sequence< Sequence< PropertyValue > >();
m_aCachedToolBarPartResourceNames.clear();
m_aCachedToolBarPartUINames.clear();
m_aImageManager = ImageManager();

ReadAddonMenuSet( m_aCachedMenuProperties );
ReadOfficeMenuBarSet( m_aCachedMenuBarPartProperties );
ReadOfficeToolBarSet( m_aCachedToolBarPartProperties, m_aCachedToolBarPartResourceNames );
ReadOfficeToolBarSet( m_aCachedToolBarPartProperties,
m_aCachedToolBarPartResourceNames,
m_aCachedToolBarPartUINames );

ReadOfficeHelpSet( m_aCachedHelpMenuProperties );
ReadImages( m_aImageManager );
Expand Down Expand Up @@ -611,6 +629,15 @@ const ::rtl::OUString AddonsOptions_Impl::GetAddonsToolbarResourceName( sal_uInt
return rtl::OUString();
}


const ::rtl::OUString AddonsOptions_Impl::GetAddonsToolbarUIName( sal_uInt32 nIndex ) const
{
if ( nIndex < m_aCachedToolBarPartUINames.size() )
return m_aCachedToolBarPartUINames[nIndex];
else
return rtl::OUString();
}

//*****************************************************************************************************************
// public method
//*****************************************************************************************************************
Expand Down Expand Up @@ -815,7 +842,10 @@ sal_Bool AddonsOptions_Impl::ReadOfficeMenuBarSet( Sequence< Sequence< PropertyV
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
sal_Bool AddonsOptions_Impl::ReadOfficeToolBarSet( AddonToolBars& rAddonOfficeToolBars, std::vector< rtl::OUString >& rAddonOfficeToolBarResNames )
sal_Bool AddonsOptions_Impl::ReadOfficeToolBarSet(
AddonToolBars& rAddonOfficeToolBars,
std::vector< rtl::OUString >& rAddonOfficeToolBarResNames,
std::vector< rtl::OUString >& rAddonOfficeToolBarUINames )
{
// Read the OfficeToolBar set and fill property sequences
::rtl::OUString aAddonToolBarNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeToolBar" ));
Expand All @@ -826,10 +856,24 @@ sal_Bool AddonsOptions_Impl::ReadOfficeToolBarSet( AddonToolBars& rAddonOfficeTo

for ( sal_uInt32 n = 0; n < nCount; n++ )
{
::rtl::OUString aToolBarItemNode( aAddonToolBarNode + aAddonToolBarNodeSeq[n] );
::rtl::OUString aToolBarNode( aAddonToolBarNode + aAddonToolBarNodeSeq[n] + m_aPathDelimiter );
rAddonOfficeToolBarResNames.push_back( aAddonToolBarNodeSeq[n] );
rAddonOfficeToolBars.push_back( m_aEmptyAddonToolBar );
ReadToolBarItemSet( aToolBarItemNode, rAddonOfficeToolBars[n] );

Sequence< Any > aToolBarNodeValues = GetProperties( GetPropertyNamesToolBar( aToolBarNode ) );

rtl::OUString aUIName;
aToolBarNodeValues[OFFSET_TOOLBAR_TITLE] >>= aUIName;
rAddonOfficeToolBarUINames.push_back( aUIName );

Reference < XInterface > xToolbarItems;
if ( ( aToolBarNodeValues[OFFSET_TOOLBAR_TOOLBARITEMS] >>= xToolbarItems ) && xToolbarItems.is() )
{
::rtl::OUStringBuffer aBuffer;
aBuffer.append( aToolBarNode );
aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( STR_TOOLBARITEMS ) );
ReadToolBarItemSet( aBuffer.makeStringAndClear(), rAddonOfficeToolBars[n] );
}
}

return ( !rAddonOfficeToolBars.empty() );
Expand Down Expand Up @@ -1812,6 +1856,17 @@ Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesPopupMenu( const
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesToolBar( const ::rtl::OUString& aPropertyRootNode ) const
{
Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_TOOLBAR );

// Create property names dependent from the root node name
lResult[OFFSET_TOOLBAR_TITLE] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TITLE ] );
lResult[OFFSET_TOOLBAR_TOOLBARITEMS] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TOOLBARITEMS ] );

return lResult;
}

Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesToolBarItem( const ::rtl::OUString& aPropertyRootNode ) const
{
Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_TOOLBARITEM );
Expand Down Expand Up @@ -1971,6 +2026,12 @@ const ::rtl::OUString AddonsOptions::GetAddonsToolbarResourceName( sal_uInt32 nI
return m_pDataContainer->GetAddonsToolbarResourceName( nIndex );
}

const ::rtl::OUString AddonsOptions::GetAddonsToolbarUIName( sal_uInt32 nIndex ) const
{
MutexGuard aGuard( GetOwnStaticMutex() );
return m_pDataContainer->GetAddonsToolbarUIName( nIndex );
}

//*****************************************************************************************************************
// public method
//*****************************************************************************************************************
Expand Down
7 changes: 4 additions & 3 deletions main/framework/source/layoutmanager/toolbarlayoutmanager.cxx
Expand Up @@ -1005,7 +1005,8 @@ void ToolbarLayoutManager::implts_createAddonsToolBars()
}

::rtl::OUString aAddonUIName = m_pAddonOptions->GetAddonsToolbarUIName( i );
::rtl::OUString aAddonTitle = aAddonUIName.getLength() ?
const bool bAddonUIName = aAddonUIName.getLength();
::rtl::OUString aAddonTitle = bAddonUIName ?
aAddonUIName : implts_generateGenericAddonToolbarTitle( i+1 );

if ( aElement.m_aName.getLength() > 0 )
Expand All @@ -1014,7 +1015,7 @@ void ToolbarLayoutManager::implts_createAddonsToolBars()
// UI changes for this document.
implts_setElementData( aElement, xDockWindow );
aElement.m_xUIElement = xUIElement;
if ( aElement.m_aUIName.getLength() == 0 )
if ( aElement.m_aUIName.getLength() == 0 && !bAddonUIName)
{
aElement.m_aUIName = aAddonTitle;
implts_writeWindowStateData( aElement );
Expand All @@ -1027,7 +1028,7 @@ void ToolbarLayoutManager::implts_createAddonsToolBars()
aNewToolbar.m_bFloating = true;
implts_readWindowStateData( aAddonToolBarName, aNewToolbar );
implts_setElementData( aNewToolbar, xDockWindow );
if ( aNewToolbar.m_aUIName.getLength() == 0 )
if ( aNewToolbar.m_aUIName.getLength() == 0 && !bAddonUIName)
{
aNewToolbar.m_aUIName = aAddonTitle;
implts_writeWindowStateData( aNewToolbar );
Expand Down
24 changes: 20 additions & 4 deletions main/officecfg/registry/schema/org/openoffice/Office/Addons.xcs
Expand Up @@ -157,6 +157,22 @@
</info>
</set>
</group>
<group oor:name="ToolBar">
<info>
<desc>Contains the structure of a toolbar.</desc>
</info>
<prop oor:name="Title" oor:type="xs:string" oor:localized="true">
<info>
<desc>A localized string used as the toolbar title.</desc>
</info>
<value></value>
</prop>
<set oor:name="ToolBarItems" oor:node-type="ToolBarItem">
<info>
<desc>Contains a list of sets of toolbar items that are part of add-on toolbars.</desc>
</info>
</set>
</group>
<group oor:name="ToolBarItem">
<info>
<desc>Describes a toolbar item representing a function of of an external component. The name must be unique and should be written using a package-scheme like org.openoffice.external.applicationexecuter to minimize name clashes.</desc>
Expand Down Expand Up @@ -400,10 +416,10 @@
<desc>Contains a list of menu merging instructions of different add-ons.</desc>
</info>
</set>
<set oor:name="OfficeToolBar" oor:node-type="ToolBarItems">
<info>
<desc>Contains a list of sets of toolbar items that are part of add-on toolbars.</desc>
</info>
<set oor:name="OfficeToolBar" oor:node-type="ToolBar">
<info>
<desc>Contains a lists of addon toolbars.</desc>
</info>
</set>
<set oor:name="OfficeToolbarMerging" oor:node-type="MergeToolBarItems">
<info>
Expand Down

0 comments on commit bb0b566

Please sign in to comment.