namespace
{ /*-**************************************************************************************************************** @descrsupportsimplemenustructuresandoperationsonit
****************************************************************************************************************-*/ struct SvtDynMenu
{ // append setup written menu entry // Don't touch name of entry. It was defined by setup and must be the same every time! // Look for double menu entries here too... may be some separator items are superfluous... void AppendSetupEntry( const SvtDynMenuEntry& rEntry )
{ if( lSetupEntries.empty() || lSetupEntries.rbegin()->sURL != rEntry.sURL )
lSetupEntries.push_back( rEntry );
}
// convert internal list to external format // for using it on right menus really // Notice: We build a property list with 4 entries and set it on result list then. // Separator entries will be packed in another way then normal entries! We define // special string "sSeparator" to perform too ...
std::vector< SvtDynMenuEntry > GetList() const
{
sal_Int32 nSetupCount = static_cast<sal_Int32>(lSetupEntries.size());
sal_Int32 nUserCount = static_cast<sal_Int32>(lUserEntries.size());
sal_Int32 nStep = 0;
std::vector< SvtDynMenuEntry > lResult ( nSetupCount+nUserCount );
OUString sSeparator ( u"private:separator"_ustr );
// Get names and values of all accessible menu entries and fill internal structures. // See impl_GetPropertyNames() for further information.
sal_uInt32 nNewCount = 0;
sal_uInt32 nWizardCount = 0;
Sequence< OUString > lNames = lcl_GetPropertyNames ( xHierarchyAccess, nNewCount ,
nWizardCount );
Sequence< Any > lValues = utl::ConfigItem::GetProperties( xHierarchyAccess, lNames, /*bAllLocales*/false );
// Safe impossible cases. // We need values from ALL configuration keys. // Follow assignment use order of values in relation to our list of key names!
DBG_ASSERT( !(lNames.getLength()!=lValues.getLength()), "SvtDynamicMenuOptions_Impl::SvtDynamicMenuOptions_Impl()\nI miss some values of configuration keys!\n" );
// Copy values from list in right order to our internal member. // Attention: List for names and values have an internal construction pattern!
// first "New" menu ... // Name Value // /New/1/URL "private:factory/swriter" // /New/1/Title "New Writer Document" // /New/1/ImageIdentifier "icon_writer" // /New/1/TargetName "_blank"
/*-**************************************************************************************************** @shortreturnlistofkeynamesofourconfigurationmanagementwhichrepresentourmoduletree @descrThismethodreturnsthecurrentlistofkeynames!Weneedittogetneededvaluesfromour configurationmanagementandsupportdynamicalmenuitemlists! @param"nNewCount",returnscountofmenuentriesfor"new" @param"nWizardCount",returnscountofmenuentriesfor"wizard" @returnAlistofconfigurationkeynamesisreturned.
*//*-*****************************************************************************************************/ static Sequence< OUString > lcl_GetPropertyNames(
css::uno::Reference<css::container::XHierarchicalNameAccess> const & xHierarchyAccess,
sal_uInt32& nNewCount, sal_uInt32& nWizardCount )
{ // First get ALL names of current existing list items in configuration!
Sequence< OUString > lNewItems = utl::ConfigItem::GetNodeNames( xHierarchyAccess, SETNODE_NEWMENU, utl::ConfigNameFormat::LocalPath );
Sequence< OUString > lWizardItems = utl::ConfigItem::GetNodeNames( xHierarchyAccess, SETNODE_WIZARDMENU, utl::ConfigNameFormat::LocalPath );
// Get information about list counts ...
nNewCount = lNewItems.getLength();
nWizardCount = lWizardItems.getLength();
// Sort and expand all three list to result list ...
Sequence< OUString > lProperties;
lcl_SortAndExpandPropertyNames( lNewItems , lProperties, SETNODE_NEWMENU );
lcl_SortAndExpandPropertyNames( lWizardItems , lProperties, SETNODE_WIZARDMENU );
staticvoid lcl_SortAndExpandPropertyNames( const Sequence< OUString >& lSource ,
Sequence< OUString >& lDestination ,
std::u16string_view sSetNode )
{ struct CountWithPrefixSort
{ booloperator() ( std::u16string_view s1, std::u16string_view s2 ) const
{ // Get order numbers from entry name without prefix. // e.g. "m10" => 10 // "m5" => 5
sal_Int32 n1 = o3tl::toInt32(s1.substr( 1 ));
sal_Int32 n2 = o3tl::toInt32(s2.substr( 1 )); // MUST be in [0,1] ... because it's a difference between // insert-positions of given entries in sorted list! return( n1<n2 );
}
}; struct SelectByPrefix
{ booloperator() ( std::u16string_view s ) const
{ // Prefer setup written entries by check first letter of given string. It must be a "s". return o3tl::starts_with( s, PATHPREFIX_SETUP );
}
};
std::vector< OUString > lTemp;
sal_Int32 nSourceCount = lSource.getLength();
sal_Int32 nDestinationStep = lDestination.getLength(); // start on end of current list ...!
lDestination.realloc( (nSourceCount*PROPERTYCOUNT)+nDestinationStep ); // get enough memory for copy operations after nDestination ... auto plDestination = lDestination.getArray();
// Copy all items to temp. vector to use fast sort operations :-)
lTemp.insert( lTemp.end(), lSource.begin(), lSource.end() );
// Sort all entries by number ...
std::stable_sort( lTemp.begin(), lTemp.end(), CountWithPrefixSort() ); // and split into setup & user written entries!
std::stable_partition( lTemp.begin(), lTemp.end(), SelectByPrefix() );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.