diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-08-19 18:19:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-20 15:02:40 +0200 |
commit | fe195f2c7b0c22169f265b731981bef47119f166 (patch) | |
tree | 3580c44ad08eef60502871222823a51c06eda964 /sd/source/ui/dlg/TemplateScanner.cxx | |
parent | 9723634f70be3c8399d7b735d05c6cbb74a29f90 (diff) |
Related tdf#111892: revamp TemplateScanner
Remove EnableSorting since it was only used with false as argument
and unwind to remove too mpEntryCompare, mbSortingEnabled,
InsertEntry which become useless
Finally remove TemplateDir which becomes just a wrapper class for a vector
Change-Id: I1e4ead009711f67fe75f3231761cc8966a39f57b
Reviewed-on: https://gerrit.libreoffice.org/41333
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source/ui/dlg/TemplateScanner.cxx')
-rw-r--r-- | sd/source/ui/dlg/TemplateScanner.cxx | 61 |
1 files changed, 4 insertions, 57 deletions
diff --git a/sd/source/ui/dlg/TemplateScanner.cxx b/sd/source/ui/dlg/TemplateScanner.cxx index d6a447c36c14..106819e61512 100644 --- a/sd/source/ui/dlg/TemplateScanner.cxx +++ b/sd/source/ui/dlg/TemplateScanner.cxx @@ -107,40 +107,6 @@ int Classify (const OUString&, const OUString& rsURL) namespace sd { -TemplateEntryCompare::TemplateEntryCompare(): - mpStringSorter(new comphelper::string::NaturalStringSorter( - ::comphelper::getProcessComponentContext(), - Application::GetSettings().GetLanguageTag().getLocale())) {} - -bool TemplateEntryCompare::operator()(TemplateEntry const * pA, TemplateEntry const * pB) const -{ - return 0 > mpStringSorter->compare(pA->msTitle, pB->msTitle); -} - -void TemplateDir::EnableSorting(bool bSortingEnabled) -{ - mbSortingEnabled = bSortingEnabled; - if (mbSortingEnabled) - { - if (mpEntryCompare.get() == nullptr) - mpEntryCompare.reset(new TemplateEntryCompare); - - ::std::sort(maEntries.begin(), maEntries.end(), *mpEntryCompare); - } -} - -void TemplateDir::InsertEntry(TemplateEntry* pNewEntry) -{ - if (mbSortingEnabled) - { - ::std::vector<TemplateEntry*>::iterator aPlaceToInsert = - ::std::upper_bound(maEntries.begin(), maEntries.end(), pNewEntry, *mpEntryCompare); - maEntries.insert(aPlaceToInsert, pNewEntry); - } - else - maEntries.push_back(pNewEntry); -} - class TemplateScanner::FolderDescriptorList : public ::std::multiset<FolderDescriptor,FolderDescriptor::Comparator> { @@ -149,9 +115,7 @@ class TemplateScanner::FolderDescriptorList TemplateScanner::TemplateScanner() : meState(INITIALIZE_SCANNING), maFolderContent(), - mpTemplateDirectory(nullptr), maFolderList(), - mpLastAddedEntry(nullptr), mpFolderDescriptors(new FolderDescriptorList), mxTemplateRoot(), mxFolderEnvironment(), @@ -164,14 +128,6 @@ TemplateScanner::TemplateScanner() TemplateScanner::~TemplateScanner() { - mpFolderDescriptors.reset(); - - // Delete all entries of the template list that have not been - // transferred to another object. - std::vector<TemplateDir*>::iterator I; - for (I=maFolderList.begin(); I!=maFolderList.end(); ++I) - if (*I != nullptr) - delete *I; } TemplateScanner::State TemplateScanner::GetTemplateRoot() @@ -239,8 +195,7 @@ TemplateScanner::State TemplateScanner::ScanEntry() || (sContentType == "Impress 2.0")) { OUString sLocalisedTitle = SfxDocumentTemplates::ConvertResourceString(sTitle); - mpLastAddedEntry = new TemplateEntry(sLocalisedTitle, sTargetURL); - mpTemplateDirectory->InsertEntry(mpLastAddedEntry); + mpTemplateEntries.push_back(new TemplateEntry(sLocalisedTitle, sTargetURL)); } } @@ -249,15 +204,10 @@ TemplateScanner::State TemplateScanner::ScanEntry() } else { - if (mpTemplateDirectory->maEntries.empty()) - { - delete mpTemplateDirectory; - mpTemplateDirectory = nullptr; - } - else + if (!mpTemplateEntries.empty()) { SolarMutexGuard aGuard; - maFolderList.push_back(mpTemplateDirectory); + maFolderList.push_back(mpTemplateEntries); } // Continue with scanning the next folder. @@ -344,9 +294,8 @@ TemplateScanner::State TemplateScanner::ScanFolder() { // Scan the folder and insert it into the list of template // folders. - mpTemplateDirectory = new TemplateDir; - mpTemplateDirectory->EnableSorting(false); // Continue with scanning all entries in the folder. + mpTemplateEntries.clear(); eNextState = INITIALIZE_ENTRY_SCAN; } } @@ -394,12 +343,10 @@ void TemplateScanner::RunNextStep() case DONE: case ERROR: mxTemplateRoot.clear(); - mxTemplateRoot.clear(); mxFolderEnvironment.clear(); mxEntryEnvironment.clear(); mxFolderResultSet.clear(); mxEntryResultSet.clear(); - mpLastAddedEntry = nullptr; break; default: break; |