summaryrefslogtreecommitdiff
path: root/basctl/source/basicide/bastype2.cxx
diff options
context:
space:
mode:
authortagezi <lera.goncharuk@gmail.com>2018-11-14 00:30:45 +0300
committerKatarina Behrens <Katarina.Behrens@cib.de>2018-11-14 09:24:18 +0100
commitddcd36d9d6191bfba7dea179067767a9ee192608 (patch)
treebc50fb07124fadd381cc76e15325e7dc26882140 /basctl/source/basicide/bastype2.cxx
parente136583e533101e368e5db6fc93148f40f6a2184 (diff)
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: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'basctl/source/basicide/bastype2.cxx')
-rw-r--r--basctl/source/basicide/bastype2.cxx75
1 files changed, 26 insertions, 49 deletions
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index fb7843658f40..8066cf2f8814 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -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,