tbx
0.7.6
|
Class to provide an OleClient to edit a document externally for an application. More...
#include <oleclient.h>
Public Member Functions | |
OleClient (int file_type, const char *temp_prefix=0) | |
Construct OleClient for a file type. More... | |
bool | find_server (bool use_ole_support=true) |
Find the server for this OleClient. More... | |
std::string | get_scrap_file_name () |
Get file name suitable for scrap file for edit session. More... | |
void | edit_file (std::string file_name, tbx::Window file_window, int x_offset, int y_offset, OleClientHandler *handler) |
Edit the given file using OLE. More... | |
void | edit_text (std::string text, tbx::Window file_window, int x_offset, int y_offset, OleClientHandler *handler) |
Edit the given text using OLE. More... | |
void | closed_in_client () |
Called to close OLE editing from the client. | |
bool | delete_file () const |
Check if file should be deleted. More... | |
void | delete_file (bool del) |
Set if file used to pass data to OLE server should be deleted when editing session is closed. More... | |
bool | in_progress () const |
Check if OLE edit is in progress. More... | |
virtual void | acknowledge_message (tbx::WimpMessageEvent &event) |
Handle OLE acknowledge message. | |
virtual void | user_message (tbx::WimpMessageEvent &event) |
Handle messages from the OLE server. | |
Static Public Member Functions | |
static void | client_closed () |
Client application has closed so broadcast a message to close any open OLE sessions in the third party applications. More... | |
static int | open_count () |
Return the number of currently open OLE sessions. | |
Class to provide an OleClient to edit a document externally for an application.
An application that supports OLE editing for the given file type needs to have been seen by the filer.
The find_server method will also attempt to use the OLESupport module (if available in !System) if no other OLE server is registered for the file type.
Pseudo code example of use OleClient text_client(0xFFF); // 0xFFF is file type for text files
if (text_client.find_server()) { std::string temp_file = text_client.get_scrap_file_name(); // Save data to be edited to the file std::ofstream os(temp_file); os << text_to_be_edited; os.close();
text_client.edit_file(temp_name, from_window, 0, 0, my_handler) // see OleClientHandler for how to proceed
// A shortcut has been provided to just edit text in a string text_client.edit_text(text_to_be_edited, from_window, 0, 0, my_handler) }
tbx::ext::OleClient::OleClient | ( | int | file_type, |
const char * | temp_prefix = 0 |
||
) |
Construct OleClient for a file type.
file_type | Type of file to use client |
temp_prefix | prefix used for temporary file used in edit (or 0 for application directory name) |
|
static |
Client application has closed so broadcast a message to close any open OLE sessions in the third party applications.
Does nothing if no sessions are open
|
inline |
Check if file should be deleted.
|
inline |
Set if file used to pass data to OLE server should be deleted when editing session is closed.
This is normally false, but is set to true by the edit_text method.
del | true if file should be deleted when closed |
void tbx::ext::OleClient::edit_file | ( | std::string | file_name, |
tbx::Window | file_window, | ||
int | x_offset, | ||
int | y_offset, | ||
OleClientHandler * | handler | ||
) |
Edit the given file using OLE.
If editing a part of the document a suitable file name can be obtained from the get_scrap_file_name method. If the file is temporary, set delete_file(true) if you want the client to delete the file after use.
file_name | the name of the file containing the value to edit |
file_window | the window the text is from |
x_offset | the x-coordinate of the text in the window (or 0 if none) |
y_offset | the y-coordinate of the text in the window (or 0 if none) |
handler | OleClientHandler to be informed of progress and updates to the text |
void tbx::ext::OleClient::edit_text | ( | std::string | text, |
tbx::Window | file_window, | ||
int | x_offset, | ||
int | y_offset, | ||
OleClientHandler * | handler | ||
) |
Edit the given text using OLE.
The text is written to a temporary file (which will be deleted at the end of the session).
text | the text to edit |
file_window | the window the text is from |
x_offset | the x-coordinate of the text in the window (or 0 if none) |
y_offset | the y-coordinate of the text in the window (or 0 if none) |
handler | OleClientHandler to be informed of progress and updates to the text |
bool tbx::ext::OleClient::find_server | ( | bool | use_ole_support = true | ) |
Find the server for this OleClient.
Should be called before each edit as the server may change during the lifetime of the application.
use_ole_support | use OLESupport module if no registered server |
std::string tbx::ext::OleClient::get_scrap_file_name | ( | ) |
Get file name suitable for scrap file for edit session.
A new file name is returned with every call.
|
inline |
Check if OLE edit is in progress.