INTEGRATION: CWS taskpane (1.4.116); FILE MERGED
2006/03/24 12:59:54 af 1.4.116.3: #i61115# Replaced auto_ptr by scoped_ptr. 2006/03/24 10:56:23 af 1.4.116.2: #i61115# Ordering template folders so that user supplied templates come first. 2006/02/17 12:53:24 af 1.4.116.1: #i61359# Added support for the AsynchronousTask interface.
This commit is contained in:
parent
f965e17a84
commit
ef91ddebf3
1 changed files with 129 additions and 65 deletions
|
@ -4,9 +4,9 @@
|
||||||
*
|
*
|
||||||
* $RCSfile: TemplateScanner.hxx,v $
|
* $RCSfile: TemplateScanner.hxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
*
|
*
|
||||||
* last change: $Author: rt $ $Date: 2005-09-09 05:17:13 $
|
* last change: $Author: kz $ $Date: 2006-04-26 20:46:11 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to
|
* The Contents of this file are made available subject to
|
||||||
* the terms of GNU Lesser General Public License Version 2.1.
|
* the terms of GNU Lesser General Public License Version 2.1.
|
||||||
|
@ -36,52 +36,47 @@
|
||||||
#ifndef _TEMPLATE_SCANNER_HXX
|
#ifndef _TEMPLATE_SCANNER_HXX
|
||||||
#define _TEMPLATE_SCANNER_HXX
|
#define _TEMPLATE_SCANNER_HXX
|
||||||
|
|
||||||
#ifndef _UCBHELPER_CONTENT_HXX
|
#include "tools/AsynchronousTask.hxx"
|
||||||
#include <ucbhelper/content.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _COM_SUN_STAR_FRAME_XDOCUMENTTEMPLATES_HPP_
|
|
||||||
#include <com/sun/star/frame/XDocumentTemplates.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
|
|
||||||
#include <comphelper/processfactory.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_HPP_
|
|
||||||
#include <com/sun/star/ucb/XContentAccess.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
|
|
||||||
#include <com/sun/star/sdbc/XRow.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _STRING_HXX
|
|
||||||
#include <tools/string.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef INCLUDED_SDDLLAPI_H
|
#ifndef INCLUDED_SDDLLAPI_H
|
||||||
#include "sddllapi.h"
|
#include "sddllapi.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef INCLUDED_VECTOR
|
#ifndef _UCBHELPER_CONTENT_HXX
|
||||||
#include <vector>
|
#include <ucbhelper/content.hxx>
|
||||||
#define INCLUDED_VECTOR
|
#endif
|
||||||
|
#ifndef _STRING_HXX
|
||||||
|
#include <tools/string.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace sd
|
#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
|
||||||
{
|
#include "com/sun/star/uno/Reference.hxx"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
namespace com { namespace sun { namespace star { namespace ucb {
|
||||||
|
class XContent;
|
||||||
|
class XCommandEnvironment;
|
||||||
|
} } } }
|
||||||
|
|
||||||
|
namespace com { namespace sun { namespace star { namespace sdbc {
|
||||||
|
class XResultSet;
|
||||||
|
} } } }
|
||||||
|
|
||||||
|
namespace sd {
|
||||||
|
|
||||||
/** Representation of a template or layout file.
|
/** Representation of a template or layout file.
|
||||||
*/
|
*/
|
||||||
class TemplateEntry
|
class TemplateEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TemplateEntry (const String& rTitle, const String& rPath)
|
TemplateEntry (const String& rsTitle, const String& rsPath)
|
||||||
: m_aTitle (rTitle), m_aPath (rPath) {}
|
: msTitle(rsTitle), msPath(rsPath) {}
|
||||||
|
|
||||||
String m_aTitle;
|
String msTitle;
|
||||||
String m_aPath;
|
String msPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,26 +87,30 @@ public:
|
||||||
class TemplateDir
|
class TemplateDir
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TemplateDir (const String & rRegion, const String & rUrl )
|
TemplateDir (const String& rsRegion, const String& rsUrl )
|
||||||
: m_aRegion(rRegion), m_aUrl(rUrl) {}
|
: msRegion(rsRegion), msUrl(rsUrl), maEntries() {}
|
||||||
|
|
||||||
String m_aRegion;
|
String msRegion;
|
||||||
String m_aUrl;
|
String msUrl;
|
||||||
std::vector<TemplateEntry*> m_aEntries;
|
::std::vector<TemplateEntry*> maEntries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** This class scans the template folders for impress templates and puts
|
/** This class scans the template folders for impress templates. There are
|
||||||
them into listboxes. While scanning the found templates are collected
|
two ways to use this class.
|
||||||
in a local list. After completing the scan an object of this class may
|
1. The old and deprecated way is to call Scan() to scan all templates
|
||||||
be called to offer this list to transfer its contents to the caller.
|
and collect the supported ones in a tree structure. This structure is
|
||||||
Every remaining entries are deleted from the local list in the
|
returned by GetFolderList().
|
||||||
destructor. An easy way to transfer the whole list is to call the swap
|
2. The new way implements the AsynchronousTask interface. Call
|
||||||
method on an STL vector with the list as argument.
|
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.
|
||||||
*/
|
*/
|
||||||
class SD_DLLPUBLIC TemplateScanner
|
class SD_DLLPUBLIC TemplateScanner
|
||||||
|
: public ::sd::tools::AsynchronousTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Create a new template scanner and prepare but do not execute the scanning.
|
/** Create a new template scanner and prepare but do not execute the scanning.
|
||||||
|
@ -136,40 +135,105 @@ public:
|
||||||
*/
|
*/
|
||||||
std::vector<TemplateDir*>& GetFolderList (void);
|
std::vector<TemplateDir*>& GetFolderList (void);
|
||||||
|
|
||||||
protected:
|
/** Implementation of the AsynchronousTask interface method.
|
||||||
/** Set the member mxTemplateRoot to the XContent that represents the
|
|
||||||
root of the template tree.
|
|
||||||
*/
|
*/
|
||||||
void ScanFolders (void);
|
virtual void RunNextStep (void);
|
||||||
|
|
||||||
/** Scan the given template folder for impress templates and insert them
|
/** Implementation of the AsynchronousTask interface method.
|
||||||
into the given list.
|
|
||||||
@param rRoot
|
|
||||||
specifies the folder to search.
|
|
||||||
@param pDir
|
|
||||||
The list into which the entries for the impress templates are to
|
|
||||||
be inserted.
|
|
||||||
*/
|
*/
|
||||||
void ScanEntries (::ucb::Content& rRoot, TemplateDir* pDir);
|
virtual bool HasNextStep (void);
|
||||||
|
|
||||||
/** Obtain the root folder of the template folder hierarchy. The result
|
/** Return the TemplateDir object that was last added to
|
||||||
is stored in mxTemplateRoot for later use.
|
mpTemplateDirectory.
|
||||||
|
@return
|
||||||
|
<NULL/> is returned either before the template scanning is
|
||||||
|
started or after it has ended.
|
||||||
*/
|
*/
|
||||||
void GetTemplateRoot (void);
|
const TemplateEntry* GetLastAddedEntry (void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/** The current state determines which step will be executed next by
|
||||||
|
RunNextStep().
|
||||||
|
*/
|
||||||
|
enum State {
|
||||||
|
INITIALIZE_SCANNING,
|
||||||
|
INITIALIZE_FOLDER_SCANNING,
|
||||||
|
GATHER_FOLDER_LIST,
|
||||||
|
SCAN_FOLDER,
|
||||||
|
INITIALIZE_ENTRY_SCAN,
|
||||||
|
SCAN_ENTRY,
|
||||||
|
DONE,
|
||||||
|
ERROR
|
||||||
|
};
|
||||||
|
State meState;
|
||||||
|
|
||||||
|
::ucb::Content maFolderContent;
|
||||||
|
TemplateDir* mpTemplateDirectory;
|
||||||
|
|
||||||
/** The data structure that is to be filled with information about the
|
/** The data structure that is to be filled with information about the
|
||||||
template files.
|
template files.
|
||||||
*/
|
*/
|
||||||
std::vector<TemplateDir*> maFolderList;
|
std::vector<TemplateDir*> maFolderList;
|
||||||
|
|
||||||
/** The root folder of the template folders.
|
/** This member points into the maFolderList to the member that was most
|
||||||
|
recently added.
|
||||||
*/
|
*/
|
||||||
com::sun::star::uno::Reference<com::sun::star::ucb::XContent>
|
TemplateEntry* mpLastAddedEntry;
|
||||||
mxTemplateRoot;
|
|
||||||
|
/** The folders that are collected by GatherFolderList().
|
||||||
|
*/
|
||||||
|
class FolderDescriptorList;
|
||||||
|
::boost::scoped_ptr<FolderDescriptorList> mpFolderDescriptors;
|
||||||
|
|
||||||
|
/** Set of state variables used by the methods
|
||||||
|
InitializeFolderScanning(), GatherFolderList(), ScanFolder(),
|
||||||
|
InitializeEntryScanning(), and ScanEntry().
|
||||||
|
*/
|
||||||
|
com::sun::star::uno::Reference<com::sun::star::ucb::XContent> mxTemplateRoot;
|
||||||
|
com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> mxFolderEnvironment;
|
||||||
|
com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> mxEntryEnvironment;
|
||||||
|
com::sun::star::uno::Reference<com::sun::star::sdbc::XResultSet> mxFolderResultSet;
|
||||||
|
com::sun::star::uno::Reference<com::sun::star::sdbc::XResultSet> mxEntryResultSet;
|
||||||
|
|
||||||
|
/** Obtain the root folder of the template folder hierarchy. The result
|
||||||
|
is stored in mxTemplateRoot for later use.
|
||||||
|
*/
|
||||||
|
State GetTemplateRoot (void);
|
||||||
|
|
||||||
|
/** Initialize the scanning of folders. This is called exactly once.
|
||||||
|
@return
|
||||||
|
Returns one of the two states ERROR or GATHER_FOLDER_LIST.
|
||||||
|
*/
|
||||||
|
State InitializeFolderScanning (void);
|
||||||
|
|
||||||
|
/** Collect all available top-level folders in an ordered list which can
|
||||||
|
then be processed by ScanFolder().
|
||||||
|
@return
|
||||||
|
Returns one of the two states ERROR or SCAN_FOLDER.
|
||||||
|
*/
|
||||||
|
State GatherFolderList (void);
|
||||||
|
|
||||||
|
/** From the list of top-level folders collected by GatherFolderList()
|
||||||
|
the one with highest priority is processed.
|
||||||
|
@return
|
||||||
|
Returns one of the states ERROR, DONE, or INITILIZE_ENTRY_SCAN.
|
||||||
|
*/
|
||||||
|
State ScanFolder (void);
|
||||||
|
|
||||||
|
/** Initialize the scanning of entries of a top-level folder.
|
||||||
|
@return
|
||||||
|
Returns one of the states ERROR or SCAN_ENTRY.
|
||||||
|
*/
|
||||||
|
State InitializeEntryScanning (void);
|
||||||
|
|
||||||
|
/** Scan one entry. When this entry matches the recognized template
|
||||||
|
types it is appended to the result set.
|
||||||
|
@return
|
||||||
|
Returns one of the states ERROR, SCAN_ENTRY, or SCAN_FOLDER.
|
||||||
|
*/
|
||||||
|
State ScanEntry (void);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // end of namespace sd
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue