summaryrefslogtreecommitdiff
path: root/basctl
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
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')
-rw-r--r--basctl/source/basicide/bastype2.cxx75
-rw-r--r--basctl/source/inc/bastype2.hxx15
2 files changed, 33 insertions, 57 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,
diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx
index 8e699aafc7fc..5dccdb17bb09 100644
--- a/basctl/source/inc/bastype2.hxx
+++ b/basctl/source/inc/bastype2.hxx
@@ -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,