LibreOffice Module sd (master) 1
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
sd::TemplateScanner Class Referencefinal

This class scans the template folders for impress templates. More...

#include <TemplateScanner.hxx>

Inheritance diagram for sd::TemplateScanner:
[legend]
Collaboration diagram for sd::TemplateScanner:
[legend]

Classes

class  FolderDescriptorList
 

Public Member Functions

 TemplateScanner ()
 Create a new template scanner and prepare but do not execute the scanning. More...
 
virtual ~TemplateScanner ()
 The destructor deletes any remaining entries of the local list of templates. More...
 
virtual void RunNextStep () override
 Implementation of the AsynchronousTask interface method. More...
 
virtual bool HasNextStep () override
 Implementation of the AsynchronousTask interface method. More...
 
const TemplateEntryGetLastAddedEntry () const
 Return the TemplateDir object that was last added to mpTemplateEntries. More...
 
virtual void RunNextStep ()=0
 Run the next step of the task. More...
 
virtual bool HasNextStep ()=0
 Return <TRUE> when there is at least one more step to execute. More...
 

Private Types

enum  State {
  INITIALIZE_SCANNING ,
  INITIALIZE_FOLDER_SCANNING ,
  GATHER_FOLDER_LIST ,
  SCAN_FOLDER ,
  INITIALIZE_ENTRY_SCAN ,
  SCAN_ENTRY ,
  DONE ,
  ERROR
}
 The current state determines which step will be executed next by RunNextStep(). More...
 

Private Member Functions

State GetTemplateRoot ()
 Obtain the root folder of the template folder hierarchy. More...
 
State InitializeFolderScanning ()
 Initialize the scanning of folders. More...
 
State GatherFolderList ()
 Collect all available top-level folders in an ordered list which can then be processed by ScanFolder(). More...
 
State ScanFolder ()
 From the list of top-level folders collected by GatherFolderList() the one with highest priority is processed. More...
 
State InitializeEntryScanning ()
 Initialize the scanning of entries of a top-level folder. More...
 
State ScanEntry ()
 Scan one entry. More...
 

Private Attributes

State meState
 
::ucbhelper::Content maFolderContent
 
::std::vector< std::unique_ptr< TemplateEntry > > mpTemplateEntries
 
std::unique_ptr< FolderDescriptorListmpFolderDescriptors
 
css::uno::Reference< css::ucb::XContent > mxTemplateRoot
 Set of state variables used by the methods InitializeFolderScanning(), GatherFolderList(), ScanFolder(), InitializeEntryScanning(), and ScanEntry(). More...
 
css::uno::Reference< css::ucb::XCommandEnvironment > mxFolderEnvironment
 
css::uno::Reference< css::ucb::XCommandEnvironment > mxEntryEnvironment
 
css::uno::Reference< css::sdbc::XResultSet > mxFolderResultSet
 
css::uno::Reference< css::sdbc::XResultSet > mxEntryResultSet
 

Additional Inherited Members

- Protected Member Functions inherited from sd::tools::AsynchronousTask
 ~AsynchronousTask ()
 

Detailed Description

This class scans the template folders for impress templates.

There are two ways to use this class.

  1. The old and deprecated way is to call Scan() to scan all templates and collect the supported ones in a tree structure. This structure is returned by GetFolderList().
  2. The new way implements the AsynchronousTask interface. Call RunNextStep() as long HasNextStep() returns <TRUE>. After every step GetLastAddedEntry() returns the template that was scanned (and has a supported format) last. When a step does not add a new template then the value of the previous step is returned.

Definition at line 69 of file TemplateScanner.hxx.

Member Enumeration Documentation

◆ State

The current state determines which step will be executed next by RunNextStep().

Enumerator
INITIALIZE_SCANNING 
INITIALIZE_FOLDER_SCANNING 
GATHER_FOLDER_LIST 
SCAN_FOLDER 
INITIALIZE_ENTRY_SCAN 
SCAN_ENTRY 
DONE 
ERROR 

Definition at line 104 of file TemplateScanner.hxx.

Constructor & Destructor Documentation

◆ TemplateScanner()

sd::TemplateScanner::TemplateScanner ( )

Create a new template scanner and prepare but do not execute the scanning.

Definition at line 111 of file TemplateScanner.cxx.

◆ ~TemplateScanner()

sd::TemplateScanner::~TemplateScanner ( )
virtual

The destructor deletes any remaining entries of the local list of templates.

Definition at line 118 of file TemplateScanner.cxx.

Member Function Documentation

◆ GatherFolderList()

TemplateScanner::State sd::TemplateScanner::GatherFolderList ( )
private

Collect all available top-level folders in an ordered list which can then be processed by ScanFolder().

Returns
Returns one of the two states ERROR or SCAN_FOLDER.

Definition at line 224 of file TemplateScanner.cxx.

References ERROR, mpFolderDescriptors, mxFolderEnvironment, mxFolderResultSet, and SCAN_FOLDER.

Referenced by RunNextStep().

◆ GetLastAddedEntry()

const TemplateEntry * sd::TemplateScanner::GetLastAddedEntry ( ) const
inline

Return the TemplateDir object that was last added to mpTemplateEntries.

Returns
<nullptr> is returned either before the template scanning is started or after it has ended.

Definition at line 95 of file TemplateScanner.hxx.

References mpTemplateEntries.

◆ GetTemplateRoot()

TemplateScanner::State sd::TemplateScanner::GetTemplateRoot ( )
private

Obtain the root folder of the template folder hierarchy.

The result is stored in mxTemplateRoot for later use.

Definition at line 122 of file TemplateScanner.cxx.

References INITIALIZE_FOLDER_SCANNING, and mxTemplateRoot.

Referenced by RunNextStep().

◆ HasNextStep()

bool sd::TemplateScanner::HasNextStep ( )
overridevirtual

Implementation of the AsynchronousTask interface method.

Implements sd::tools::AsynchronousTask.

Definition at line 328 of file TemplateScanner.cxx.

References DONE, ERROR, and meState.

◆ InitializeEntryScanning()

TemplateScanner::State sd::TemplateScanner::InitializeEntryScanning ( )
private

Initialize the scanning of entries of a top-level folder.

Returns
Returns one of the states ERROR or SCAN_ENTRY.

Definition at line 131 of file TemplateScanner.cxx.

References ucbhelper::Content::createCursor(), ERROR, ucbhelper::Content::isFolder(), maFolderContent, mxEntryEnvironment, mxEntryResultSet, and SCAN_ENTRY.

Referenced by RunNextStep().

◆ InitializeFolderScanning()

TemplateScanner::State sd::TemplateScanner::InitializeFolderScanning ( )
private

Initialize the scanning of folders.

This is called exactly once.

Returns
Returns one of the two states ERROR or GATHER_FOLDER_LIST.

Definition at line 199 of file TemplateScanner.cxx.

References ucbhelper::Content::createCursor(), ERROR, GATHER_FOLDER_LIST, comphelper::getProcessComponentContext(), mxFolderEnvironment, mxFolderResultSet, and mxTemplateRoot.

Referenced by RunNextStep().

◆ RunNextStep()

void sd::TemplateScanner::RunNextStep ( )
overridevirtual

◆ ScanEntry()

TemplateScanner::State sd::TemplateScanner::ScanEntry ( )
private

Scan one entry.

When this entry matches the recognized template types it is appended to the result set.

Returns
Returns one of the states ERROR, SCAN_ENTRY, or SCAN_FOLDER.

Definition at line 150 of file TemplateScanner.cxx.

References SfxDocumentTemplates::ConvertResourceString(), ERROR, comphelper::getProcessComponentContext(), ucbhelper::Content::isDocument(), MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII, MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE_ASCII, MIMETYPE_VND_SUN_XML_IMPRESS_ASCII, mpTemplateEntries, mxEntryEnvironment, mxEntryResultSet, SCAN_ENTRY, and SCAN_FOLDER.

Referenced by RunNextStep().

◆ ScanFolder()

TemplateScanner::State sd::TemplateScanner::ScanFolder ( )
private

From the list of top-level folders collected by GatherFolderList() the one with highest priority is processed.

Returns
Returns one of the states ERROR, DONE, or INITIALIZE_ENTRY_SCAN.

Definition at line 253 of file TemplateScanner.cxx.

References DONE, ERROR, comphelper::getProcessComponentContext(), INITIALIZE_ENTRY_SCAN, ucbhelper::Content::isFolder(), maFolderContent, mpFolderDescriptors, and mpTemplateEntries.

Referenced by RunNextStep().

Member Data Documentation

◆ maFolderContent

::ucbhelper::Content sd::TemplateScanner::maFolderContent
private

Definition at line 117 of file TemplateScanner.hxx.

Referenced by InitializeEntryScanning(), and ScanFolder().

◆ meState

State sd::TemplateScanner::meState
private

Definition at line 115 of file TemplateScanner.hxx.

Referenced by HasNextStep(), and RunNextStep().

◆ mpFolderDescriptors

std::unique_ptr<FolderDescriptorList> sd::TemplateScanner::mpFolderDescriptors
private

Definition at line 123 of file TemplateScanner.hxx.

Referenced by GatherFolderList(), and ScanFolder().

◆ mpTemplateEntries

::std::vector<std::unique_ptr<TemplateEntry> > sd::TemplateScanner::mpTemplateEntries
private

Definition at line 118 of file TemplateScanner.hxx.

Referenced by GetLastAddedEntry(), ScanEntry(), and ScanFolder().

◆ mxEntryEnvironment

css::uno::Reference<css::ucb::XCommandEnvironment> sd::TemplateScanner::mxEntryEnvironment
private

Definition at line 131 of file TemplateScanner.hxx.

Referenced by InitializeEntryScanning(), RunNextStep(), and ScanEntry().

◆ mxEntryResultSet

css::uno::Reference<css::sdbc::XResultSet> sd::TemplateScanner::mxEntryResultSet
private

Definition at line 133 of file TemplateScanner.hxx.

Referenced by InitializeEntryScanning(), RunNextStep(), and ScanEntry().

◆ mxFolderEnvironment

css::uno::Reference<css::ucb::XCommandEnvironment> sd::TemplateScanner::mxFolderEnvironment
private

Definition at line 130 of file TemplateScanner.hxx.

Referenced by GatherFolderList(), InitializeFolderScanning(), and RunNextStep().

◆ mxFolderResultSet

css::uno::Reference<css::sdbc::XResultSet> sd::TemplateScanner::mxFolderResultSet
private

Definition at line 132 of file TemplateScanner.hxx.

Referenced by GatherFolderList(), InitializeFolderScanning(), and RunNextStep().

◆ mxTemplateRoot

css::uno::Reference<css::ucb::XContent> sd::TemplateScanner::mxTemplateRoot
private

The documentation for this class was generated from the following files: