/** Use a heuristic based on the URL of a top-level template folder to assignaprioritythatisusedtosortthefolders.
*/ int Classify (std::u16string_view rsURL)
{ int nPriority (0);
if (rsURL.empty())
nPriority = 100; elseif (rsURL.find(u"presnt") != std::u16string_view::npos)
{
nPriority = 30;
} elseif (rsURL.find(u"layout") != std::u16string_view::npos)
{
nPriority = 20;
} elseif (rsURL.find(u"educate") != std::u16string_view::npos)
{
nPriority = 40;
} elseif (rsURL.find(u"finance") != std::u16string_view::npos)
{
nPriority = 40;
} else
{ // All other folders are taken for user supplied and have the // highest priority.
nPriority = 10;
}
return nPriority;
}
} // end of anonymous namespace
namespace sd
{
class TemplateScanner::FolderDescriptorList
: public ::std::multiset<FolderDescriptor,FolderDescriptor::Comparator>
{
};
TemplateScanner::State TemplateScanner::InitializeEntryScanning()
{
State eNextState (SCAN_ENTRY);
if (maFolderContent.isFolder())
{
mxEntryEnvironment.clear();
// Create a cursor to iterate over the templates in this folders. // We are interested only in three properties: the entry's name, // its URL, and its content type.
mxEntryResultSet.set( maFolderContent.createCursor({ TITLE, u"TargetURL"_ustr, u"TypeDescription"_ustr }, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY));
} else
eNextState = ERROR;
return eNextState;
}
TemplateScanner::State TemplateScanner::ScanEntry()
{
State eNextState (ERROR);
OUString aId = xContentAccess->queryContentIdentifierString();
::ucbhelper::Content aContent(aId, mxEntryEnvironment, comphelper::getProcessComponentContext()); if (aContent.isDocument ())
{ // Check whether the entry is an impress template. If so // add a new entry to the resulting list (which is created // first if necessary). // These strings are used to find impress templates in the tree of // template files. Should probably be determined dynamically. if ( (sContentType == MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE_ASCII)
|| (sContentType == MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII)
|| (sContentType == "application/vnd.stardivision.impress")
|| (sContentType == MIMETYPE_VND_SUN_XML_IMPRESS_ASCII) // The following id comes from the bugdoc in #i2764#.
|| (sContentType == "Impress 2.0"))
{
OUString sLocalisedTitle = SfxDocumentTemplates::ConvertResourceString(sTitle);
mpTemplateEntries.push_back(std::make_unique<TemplateEntry>(sLocalisedTitle, sTargetURL));
}
}
// Continue scanning entries.
eNextState = SCAN_ENTRY;
} else
{ // Continue with scanning the next folder.
eNextState = SCAN_FOLDER;
}
}
return eNextState;
}
TemplateScanner::State TemplateScanner::InitializeFolderScanning()
{
State eNextState (ERROR);
TemplateScanner::State TemplateScanner::ScanFolder()
{
State eNextState (ERROR);
if (!mpFolderDescriptors->empty())
{
FolderDescriptor aDescriptor (*mpFolderDescriptors->begin());
mpFolderDescriptors->erase(mpFolderDescriptors->begin());
OUString aId (aDescriptor.msContentIdentifier);
maFolderContent = ::ucbhelper::Content (aId, aDescriptor.mxFolderEnvironment, comphelper::getProcessComponentContext()); if (maFolderContent.isFolder())
{ // Scan the folder and insert it into the list of template // folders. // Continue with scanning all entries in the folder.
mpTemplateEntries.clear();
eNextState = INITIALIZE_ENTRY_SCAN;
}
} else
{
eNextState = DONE;
}
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.