Kaydet (Commit) ddcd36d9 authored tarafından tagezi's avatar tagezi Kaydeden (comit) Katarina Behrens

tdf#39593 deduplicate code in TreeListBox

Separates filling treelist for macros and dialogs to function

Change-Id: I5803b94617ed6136f97be922c9da9d705f30b9b0
Reviewed-on: https://gerrit.libreoffice.org/63346
Tested-by: Jenkins
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst e136583e
......@@ -316,23 +316,7 @@ void TreeListBox::ImpCreateLibSubEntries( SvTreeListEntry* pLibRootEntry, const
if ( nMode & BrowseMode::Subs )
{
Sequence< OUString > aNames = GetMethodNames( rDocument, rLibName, aModName );
sal_Int32 nCount = aNames.getLength();
const OUString* pNames = aNames.getConstArray();
for ( sal_Int32 j = 0 ; j < nCount ; j++ )
{
OUString aName = pNames[ j ];
SvTreeListEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
if ( !pEntry )
{
AddEntry(
aName,
Image(BitmapEx(RID_BMP_MACRO)),
pModuleEntry, false,
o3tl::make_unique<Entry>(
OBJ_TYPE_METHOD));
}
}
FillTreeListBox( pModuleEntry, aNames, OBJ_TYPE_METHOD, RID_BMP_MACRO );
}
}
}
......@@ -355,22 +339,7 @@ void TreeListBox::ImpCreateLibSubEntries( SvTreeListEntry* pLibRootEntry, const
{
// get a sorted list of dialog names
Sequence< OUString > aDlgNames( rDocument.getObjectNames( E_DIALOGS, rLibName ) );
sal_Int32 nDlgCount = aDlgNames.getLength();
const OUString* pDlgNames = aDlgNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
{
OUString aDlgName = pDlgNames[ i ];
SvTreeListEntry* pDialogEntry = FindEntry( pLibRootEntry, aDlgName, OBJ_TYPE_DIALOG );
if ( !pDialogEntry )
{
AddEntry(
aDlgName,
Image(BitmapEx(RID_BMP_DIALOG)),
pLibRootEntry, false,
o3tl::make_unique<Entry>(OBJ_TYPE_DIALOG));
}
}
FillTreeListBox( pLibRootEntry, aDlgNames, OBJ_TYPE_DIALOG, RID_BMP_DIALOG );
}
catch (const container::NoSuchElementException& )
{
......@@ -472,22 +441,7 @@ void TreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvTreeListEntry* pLibSubRo
if ( nMode & BrowseMode::Subs )
{
Sequence< OUString > aNames = GetMethodNames( rDocument, rLibName, aModName );
sal_Int32 nCount = aNames.getLength();
const OUString* pNames = aNames.getConstArray();
for ( sal_Int32 j = 0 ; j < nCount ; j++ )
{
OUString aName = pNames[ j ];
SvTreeListEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
if ( !pEntry )
{
AddEntry(
aName,
Image(BitmapEx(RID_BMP_MACRO)),
pModuleEntry, false,
o3tl::make_unique<Entry>(OBJ_TYPE_METHOD));
}
}
FillTreeListBox( pModuleEntry, aNames, OBJ_TYPE_METHOD, RID_BMP_MACRO );
}
}
}
......@@ -691,6 +645,29 @@ bool TreeListBox::IsEntryProtected( SvTreeListEntry* pEntry )
return bProtected;
}
//Fills up treelist for macros and dialogs
void TreeListBox::FillTreeListBox( SvTreeListEntry* pRootEntry, const Sequence< OUString >& rNames,
const EntryType& eType, const OUString& aBmpMacro )
{
sal_Int32 nCount = rNames.getLength();
const OUString* pNames = rNames.getConstArray();
for ( sal_Int32 j = 0 ; j < nCount ; j++ )
{
OUString aName = pNames[ j ];
SvTreeListEntry* pEntry = FindEntry( pRootEntry, aName, eType );
if ( !pEntry )
{
AddEntry(
aName,
Image(BitmapEx( aBmpMacro )),
pRootEntry, false,
o3tl::make_unique<Entry>( eType ));
}
}
}
SvTreeListEntry* TreeListBox::AddEntry(
OUString const& rText,
const Image& rImage,
......
......@@ -49,6 +49,7 @@ namespace o3tl {
namespace basctl
{
using namespace ::com::sun::star::uno;
enum EntryType
{
......@@ -149,16 +150,12 @@ public:
EntryType eType
);
ScriptDocument const& GetDocument() const { return m_aDocument; }
LibraryLocation GetLocation() const { return m_eLocation; }
const OUString& GetLibName() const { return m_aLibName; }
ScriptDocument const& GetDocument() const { return m_aDocument; }
LibraryLocation GetLocation() const { return m_eLocation; }
const OUString& GetLibName() const { return m_aLibName; }
const OUString& GetLibSubName() const { return m_aLibSubName; }
const OUString& GetName() const { return m_aName; }
const OUString& GetName() const { return m_aName; }
const OUString& GetMethodName() const { return m_aMethodName; }
void SetMethodName( const OUString& aMethodName ) { m_aMethodName = aMethodName; }
......@@ -235,6 +232,8 @@ public:
static ItemType ConvertType (EntryType eType);
bool IsValidEntry( SvTreeListEntry* pEntry );
void FillTreeListBox( SvTreeListEntry* pRootEntry, const Sequence< OUString >& rNames,
const EntryType& eType, const OUString& aBmpMacro );
SvTreeListEntry* AddEntry(
const OUString& rText, const Image& rImage,
SvTreeListEntry* pParent, bool bChildrenOnDemand,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment