Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Excel/OLE problem..
Excel/OLE problem.. [message #373055] Fri, 29 August 2003 21:22 Go to next message
Avneesh Saxena is currently offline Avneesh SaxenaFriend
Messages: 12
Registered: July 2009
Junior Member
I'm trying to open an webbrowser control with an excel sheet embedded in it.
Everything works fine and the frame come up nicely. However, if I take focus
away from the frame and bring it back, the embedded excel document become
uneditable. I'm attaching the code below - it represents the widget I'm
trying to create; I haven't added the code for OleFrame and like.... I would
appreciate if someone can help me figure what's going on.

public class ExcelWorkbookView extends Composite {
protected static final String SHELL_EXPLORER_PROG_ID = "Shell.Explorer";
protected final OleFrame oleFrame;
protected final OleControlSite explorerControlSite;
protected final OleAutomation explorer;

protected static final String EXCEL_PROG_ID = "Excel.Sheet";
protected final OleAutomation excelWorkbook;
protected final OleAutomation excelApplication;

protected final ExplorerEventListener explorerEventListener;

/**
* Keeps track of when the excel document is loaded completely.
* @see #customizeExcel()
* TH-safety: protected by {@link this}
**/
protected boolean explorerInitialized = false;

/**
*
* @param parent
* @param swtStyle
* @param xlsFile A excel file that is to be used. If null, a new file
will be created
*/
public ExcelWorkbookView(final Composite parent, final int swtStyle,
File xlsFile) {
super(parent, swtStyle);

/** set the layout as a grid layout **/
this.setLayout(new GridLayout(1, false));

/** try to instantiate the frame **/
oleFrame = new OleFrame(this, SWT.NONE);
oleFrame.setLayoutData(new GridData(GridData.FILL_BOTH));

try {

/** make sure that we have a file to work on **/
final OleClientSite _excelClientSite;
if (xlsFile == null) {
_excelClientSite = new OleClientSite(oleFrame, SWT.NONE,
EXCEL_PROG_ID);
try {
/** create a new temp file **/
xlsFile = File.createTempFile("sailfish", ".xls");
xlsFile.deleteOnExit(); /** allow deletion on exit **/
/** save as ole file **/
if (_excelClientSite.save(xlsFile, true) == false) {
/** Yikees! save failed so try to exit **/
OLE.error(OLE.ERROR_CANNOT_CREATE_FILE);
}
} catch (IOException e) {
/** Oops, error creating file... **/
Syslog.error(this, e);
OLE.error(OLE.ERROR_CANNOT_CREATE_FILE);
}
} else {
_excelClientSite = new OleClientSite(oleFrame, SWT.NONE,
EXCEL_PROG_ID, xlsFile);
}

/** dispose of excel for now **/
_excelClientSite.dispose();

/** Now try to get the interface to shell explorer **/
explorerControlSite = new OleControlSite(oleFrame, SWT.NONE,
SHELL_EXPLORER_PROG_ID);
explorer = new OleAutomation(explorerControlSite);

/** register listener **/
explorerEventListener = new ExplorerEventListener();


explorerControlSite.addEventListener(ExplorerEventListener.D OCUMENT_COMPLETE
, explorerEventListener);

/**
* Load the excel file into the control:
* [id(0x00000068), helpstring("Navigates to a URL or file.")]
void Navigate(
[in] BSTR URL,
[in, optional] VARIANT* Flags,
[in, optional] VARIANT* TargetFrameName,
[in, optional] VARIANT* PostData,
[in, optional] VARIANT* Headers);
*/
{
int ids[] = explorer.getIDsOfNames(new String[] {
"Navigate", "URL" });
final Variant result =
explorer.invoke(
ids[0],
new Variant[] { new
Variant(xlsFile.getAbsolutePath())},
new int[] { ids[1] });
if (result == null) {
Syslog.error(this, explorer.getLastError());
OLE.error(OLE.ERROR_CANNOT_OPEN_FILE);
}
}

/**
* Get the embedded document interface:
* [id(0x000000cb), propget, helpstring("Returns the active
Document automation object, if any.")]
IDispatch* Document();
*/
final Variant _document = explorer.getProperty(0x000000cb);
if (_document == null || _document.getType() != OLE.VT_DISPATCH)
{
final String errMsg =
"[Error while trying to get interface to doc("
+ xlsFile
+ "). Error("
+ explorer.getLastError()
+ ")]";
Syslog.error(this, errMsg);
OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND);
}

/** get interface to underlying excel doc **/
excelWorkbook = _document.getAutomation();

/**
* Get the application:
* [id(0x00000094), propget, helpcontext(0x00010094)]
HRESULT Application([out, retval] Application** RHS);
*/
final Variant _excelApplication =
excelWorkbook.getProperty(0x00000094);
excelApplication = _excelApplication.getAutomation();
} catch (Throwable e) {
/** if any error, dispose the frame **/
this.dispose();
Syslog.error(this, LogUtil.getFullDesc(e));
throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED);
}
}

/**
* Disposes the oleFrame so that we free all the resources allocated to
Excel/Explorer.
*/
public void dispose() {
/** remember to dispose the frame **/
oleFrame.dispose();
/** delete the file **/
}

/**
*
* @param shell Automation on Explorer. This method is invoked after the
explorer is showing.
*/
protected void customizeExplorer() {
/** Make sure this method is called only once **/
synchronized (this) {
Assert.neqTrue(explorerInitialized, "explorerInitialized");
explorerInitialized = true;
}

Assert.neqNull(explorer, "explorer");
}

/**
* Customizes excel contained in the explorer.
*
*/
protected void customizeExcel() {
int ids[];
Variant retVal;

final int OLECMDID_HIDETOOLBARS = 24;
/**
* Enable tools bars on excel:
* [id(0x000001f6), helpstring("IOleCommandTarget::Exec")]
HRESULT ExecWB(
[in] OLECMDID cmdID,
[in] OLECMDEXECOPT cmdexecopt,
[in, optional] VARIANT* pvaIn,
[in, out, optional] VARIANT* pvaOut);
LECMDEXECOPT_DONTPROMPTUSER = 2,
*
*/
ids = explorer.getIDsOfNames(new String[] { "ExecWB", "cmdID",
"cmdexecopt" });
retVal =
explorer.invoke(
ids[0],
new Variant[] { new Variant(OLECMDID_HIDETOOLBARS), new
Variant(2)},
new int[] { ids[1], ids[2] });
if (retVal == null) {
Syslog.debug(this, "[Error enabling toolbars(" +
explorer.getLastError() + ")]");
}

}

protected class ExplorerEventListener implements OleListener {
protected final static int DOCUMENT_COMPLETE = 0x00000103;

/* (non-Javadoc)
* @see
org.eclipse.swt.ole.win32.OleListener#handleEvent(org.eclips e.swt.ole.win32.
OleEvent)
*/
public void handleEvent(OleEvent event) {
Require.neqNull(event, "event");

switch (event.type) {
case DOCUMENT_COMPLETE : //document complete
Syslog.debug(this, "Document loaded");
/** attach listeners **/
final Listener listener = new Listener() {
public void handleEvent(final Event event) {
switch (event.type) {
case SWT.Activate :
if
(explorerControlSite.doVerb(OLE.OLEIVERB_UIACTIVATE) != OLE.S_OK) {
Syslog.error(this, "[Error in
explorer: can't activate]");
} else {
customizeExplorer();
customizeExcel();
}
break;
case SWT.Deactivate :
if
(explorerControlSite.doVerb(OLE.OLEIVERB_HIDE) != OLE.S_OK) {
Syslog.error(this, "[Error in
explorer: can't deactivate]");
}
break;

default :
break;
}
}

};

/** add listeners **/
// addListener(SWT.Activate,
listener);
// addListener(SWT.Deactivate,
listener);

/** force the first event **/
final Event firstEvent = new Event();
firstEvent.type = SWT.Activate;
listener.handleEvent(firstEvent);

break;
default :
Syslog.debug(this, "[Got event type(" + event.type + "),
detail(" + event.detail + ")]");
break;
}
}
}

/**
* All the other actions inherit from this one.
*/
public abstract class ExcelAction extends Action {
public ExcelAction(final String actionName, final String
resourceName) {
super(actionName);
//TODO: load resources
}

public void run() {
/** Runs the underlying action **/
doRun();
}

/**
* Subclasses should implement this function on invocation.
*
*/
protected abstract void doRun();
}

}
Re: Excel/OLE problem.. [message #373181 is a reply to message #373055] Wed, 03 September 2003 18:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: veronika_irvine.oti.com

I get the same behaviour dragging an excel document onto standalone Internet
Explorer (running as a standalone application, not embedded in SWT).

Appears to be a bug in IE not in SWT.

"Avneesh Saxena" <as2uv@cs.virginia.edu> wrote in message
news:biog5k$kpo$1@eclipse.org...
> I'm trying to open an webbrowser control with an excel sheet embedded in
it.
> Everything works fine and the frame come up nicely. However, if I take
focus
> away from the frame and bring it back, the embedded excel document become
> uneditable. I'm attaching the code below - it represents the widget I'm
> trying to create; I haven't added the code for OleFrame and like.... I
would
> appreciate if someone can help me figure what's going on.
>
> public class ExcelWorkbookView extends Composite {
> protected static final String SHELL_EXPLORER_PROG_ID =
"Shell.Explorer";
> protected final OleFrame oleFrame;
> protected final OleControlSite explorerControlSite;
> protected final OleAutomation explorer;
>
> protected static final String EXCEL_PROG_ID = "Excel.Sheet";
> protected final OleAutomation excelWorkbook;
> protected final OleAutomation excelApplication;
>
> protected final ExplorerEventListener explorerEventListener;
>
> /**
> * Keeps track of when the excel document is loaded completely.
> * @see #customizeExcel()
> * TH-safety: protected by {@link this}
> **/
> protected boolean explorerInitialized = false;
>
> /**
> *
> * @param parent
> * @param swtStyle
> * @param xlsFile A excel file that is to be used. If null, a new file
> will be created
> */
> public ExcelWorkbookView(final Composite parent, final int swtStyle,
> File xlsFile) {
> super(parent, swtStyle);
>
> /** set the layout as a grid layout **/
> this.setLayout(new GridLayout(1, false));
>
> /** try to instantiate the frame **/
> oleFrame = new OleFrame(this, SWT.NONE);
> oleFrame.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> try {
>
> /** make sure that we have a file to work on **/
> final OleClientSite _excelClientSite;
> if (xlsFile == null) {
> _excelClientSite = new OleClientSite(oleFrame, SWT.NONE,
> EXCEL_PROG_ID);
> try {
> /** create a new temp file **/
> xlsFile = File.createTempFile("sailfish", ".xls");
> xlsFile.deleteOnExit(); /** allow deletion on exit **/
> /** save as ole file **/
> if (_excelClientSite.save(xlsFile, true) == false) {
> /** Yikees! save failed so try to exit **/
> OLE.error(OLE.ERROR_CANNOT_CREATE_FILE);
> }
> } catch (IOException e) {
> /** Oops, error creating file... **/
> Syslog.error(this, e);
> OLE.error(OLE.ERROR_CANNOT_CREATE_FILE);
> }
> } else {
> _excelClientSite = new OleClientSite(oleFrame, SWT.NONE,
> EXCEL_PROG_ID, xlsFile);
> }
>
> /** dispose of excel for now **/
> _excelClientSite.dispose();
>
> /** Now try to get the interface to shell explorer **/
> explorerControlSite = new OleControlSite(oleFrame, SWT.NONE,
> SHELL_EXPLORER_PROG_ID);
> explorer = new OleAutomation(explorerControlSite);
>
> /** register listener **/
> explorerEventListener = new ExplorerEventListener();
>
>
>
explorerControlSite.addEventListener(ExplorerEventListener.D OCUMENT_COMPLETE
> , explorerEventListener);
>
> /**
> * Load the excel file into the control:
> * [id(0x00000068), helpstring("Navigates to a URL or file.")]
> void Navigate(
> [in] BSTR URL,
> [in, optional] VARIANT* Flags,
> [in, optional] VARIANT* TargetFrameName,
> [in, optional] VARIANT* PostData,
> [in, optional] VARIANT* Headers);
> */
> {
> int ids[] = explorer.getIDsOfNames(new String[] {
> "Navigate", "URL" });
> final Variant result =
> explorer.invoke(
> ids[0],
> new Variant[] { new
> Variant(xlsFile.getAbsolutePath())},
> new int[] { ids[1] });
> if (result == null) {
> Syslog.error(this, explorer.getLastError());
> OLE.error(OLE.ERROR_CANNOT_OPEN_FILE);
> }
> }
>
> /**
> * Get the embedded document interface:
> * [id(0x000000cb), propget, helpstring("Returns the active
> Document automation object, if any.")]
> IDispatch* Document();
> */
> final Variant _document = explorer.getProperty(0x000000cb);
> if (_document == null || _document.getType() !=
OLE.VT_DISPATCH)
> {
> final String errMsg =
> "[Error while trying to get interface to doc("
> + xlsFile
> + "). Error("
> + explorer.getLastError()
> + ")]";
> Syslog.error(this, errMsg);
> OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND);
> }
>
> /** get interface to underlying excel doc **/
> excelWorkbook = _document.getAutomation();
>
> /**
> * Get the application:
> * [id(0x00000094), propget, helpcontext(0x00010094)]
> HRESULT Application([out, retval] Application** RHS);
> */
> final Variant _excelApplication =
> excelWorkbook.getProperty(0x00000094);
> excelApplication = _excelApplication.getAutomation();
> } catch (Throwable e) {
> /** if any error, dispose the frame **/
> this.dispose();
> Syslog.error(this, LogUtil.getFullDesc(e));
> throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED);
> }
> }
>
> /**
> * Disposes the oleFrame so that we free all the resources allocated
to
> Excel/Explorer.
> */
> public void dispose() {
> /** remember to dispose the frame **/
> oleFrame.dispose();
> /** delete the file **/
> }
>
> /**
> *
> * @param shell Automation on Explorer. This method is invoked after
the
> explorer is showing.
> */
> protected void customizeExplorer() {
> /** Make sure this method is called only once **/
> synchronized (this) {
> Assert.neqTrue(explorerInitialized, "explorerInitialized");
> explorerInitialized = true;
> }
>
> Assert.neqNull(explorer, "explorer");
> }
>
> /**
> * Customizes excel contained in the explorer.
> *
> */
> protected void customizeExcel() {
> int ids[];
> Variant retVal;
>
> final int OLECMDID_HIDETOOLBARS = 24;
> /**
> * Enable tools bars on excel:
> * [id(0x000001f6), helpstring("IOleCommandTarget::Exec")]
> HRESULT ExecWB(
> [in] OLECMDID cmdID,
> [in] OLECMDEXECOPT cmdexecopt,
> [in, optional] VARIANT* pvaIn,
> [in, out, optional] VARIANT* pvaOut);
> LECMDEXECOPT_DONTPROMPTUSER = 2,
> *
> */
> ids = explorer.getIDsOfNames(new String[] { "ExecWB", "cmdID",
> "cmdexecopt" });
> retVal =
> explorer.invoke(
> ids[0],
> new Variant[] { new Variant(OLECMDID_HIDETOOLBARS), new
> Variant(2)},
> new int[] { ids[1], ids[2] });
> if (retVal == null) {
> Syslog.debug(this, "[Error enabling toolbars(" +
> explorer.getLastError() + ")]");
> }
>
> }
>
> protected class ExplorerEventListener implements OleListener {
> protected final static int DOCUMENT_COMPLETE = 0x00000103;
>
> /* (non-Javadoc)
> * @see
>
org.eclipse.swt.ole.win32.OleListener#handleEvent(org.eclips e.swt.ole.win32.
> OleEvent)
> */
> public void handleEvent(OleEvent event) {
> Require.neqNull(event, "event");
>
> switch (event.type) {
> case DOCUMENT_COMPLETE : //document complete
> Syslog.debug(this, "Document loaded");
> /** attach listeners **/
> final Listener listener = new Listener() {
> public void handleEvent(final Event event) {
> switch (event.type) {
> case SWT.Activate :
> if
> (explorerControlSite.doVerb(OLE.OLEIVERB_UIACTIVATE) != OLE.S_OK) {
> Syslog.error(this, "[Error in
> explorer: can't activate]");
> } else {
> customizeExplorer();
> customizeExcel();
> }
> break;
> case SWT.Deactivate :
> if
> (explorerControlSite.doVerb(OLE.OLEIVERB_HIDE) != OLE.S_OK) {
> Syslog.error(this, "[Error in
> explorer: can't deactivate]");
> }
> break;
>
> default :
> break;
> }
> }
>
> };
>
> /** add listeners **/
> // addListener(SWT.Activate,
> listener);
> // addListener(SWT.Deactivate,
> listener);
>
> /** force the first event **/
> final Event firstEvent = new Event();
> firstEvent.type = SWT.Activate;
> listener.handleEvent(firstEvent);
>
> break;
> default :
> Syslog.debug(this, "[Got event type(" + event.type +
"),
> detail(" + event.detail + ")]");
> break;
> }
> }
> }
>
> /**
> * All the other actions inherit from this one.
> */
> public abstract class ExcelAction extends Action {
> public ExcelAction(final String actionName, final String
> resourceName) {
> super(actionName);
> //TODO: load resources
> }
>
> public void run() {
> /** Runs the underlying action **/
> doRun();
> }
>
> /**
> * Subclasses should implement this function on invocation.
> *
> */
> protected abstract void doRun();
> }
>
> }
>
>
Re: Excel/OLE problem.. [message #373312 is a reply to message #373181] Fri, 05 September 2003 19:45 Go to previous messageGo to next message
Avneesh Saxena is currently offline Avneesh SaxenaFriend
Messages: 12
Registered: July 2009
Junior Member
IE works fine for me. After attaching a debugger it seems to me that for a
control site a focus listener has been attached. If focus is taken away from
the embedded control, objIOleInPlaceObject.UIDeactivate() is called from
OleControlSite.onFocusOut(). This, in turn, is invoking
OleClientSite.OnUIDeactivate() that calls OleFrame.SetActiveObject(0,0).
This causes the OleFrame to lose the direct connection to the displayed
inPlaceOleObject. However, this connection is never established again even
if the focus comes back to the OleControlSite, i.e,
OleFrame.SetActiveObject() is never set to the inPlaceOleObject ever again.
This is obviously a problem because the frame can no longer communicate with
the inplace object again.

Thanks,
--Avs

wrote in message news:bj5bs5$5c8$1@eclipse.org...
> I get the same behaviour dragging an excel document onto standalone
Internet
> Explorer (running as a standalone application, not embedded in SWT).
>
> Appears to be a bug in IE not in SWT.
>
> "Avneesh Saxena" <as2uv@cs.virginia.edu> wrote in message
> news:biog5k$kpo$1@eclipse.org...
> > I'm trying to open an webbrowser control with an excel sheet embedded in
> it.
> > Everything works fine and the frame come up nicely. However, if I take
> focus
> > away from the frame and bring it back, the embedded excel document
become
> > uneditable. I'm attaching the code below - it represents the widget I'm
> > trying to create; I haven't added the code for OleFrame and like.... I
> would
> > appreciate if someone can help me figure what's going on.
> >
> > public class ExcelWorkbookView extends Composite {
> > protected static final String SHELL_EXPLORER_PROG_ID =
> "Shell.Explorer";
> > protected final OleFrame oleFrame;
> > protected final OleControlSite explorerControlSite;
> > protected final OleAutomation explorer;
> >
> > protected static final String EXCEL_PROG_ID = "Excel.Sheet";
> > protected final OleAutomation excelWorkbook;
> > protected final OleAutomation excelApplication;
> >
> > protected final ExplorerEventListener explorerEventListener;
> >
> > /**
> > * Keeps track of when the excel document is loaded completely.
> > * @see #customizeExcel()
> > * TH-safety: protected by {@link this}
> > **/
> > protected boolean explorerInitialized = false;
> >
> > /**
> > *
> > * @param parent
> > * @param swtStyle
> > * @param xlsFile A excel file that is to be used. If null, a new
file
> > will be created
> > */
> > public ExcelWorkbookView(final Composite parent, final int swtStyle,
> > File xlsFile) {
> > super(parent, swtStyle);
> >
> > /** set the layout as a grid layout **/
> > this.setLayout(new GridLayout(1, false));
> >
> > /** try to instantiate the frame **/
> > oleFrame = new OleFrame(this, SWT.NONE);
> > oleFrame.setLayoutData(new GridData(GridData.FILL_BOTH));
> >
> > try {
> >
> > /** make sure that we have a file to work on **/
> > final OleClientSite _excelClientSite;
> > if (xlsFile == null) {
> > _excelClientSite = new OleClientSite(oleFrame, SWT.NONE,
> > EXCEL_PROG_ID);
> > try {
> > /** create a new temp file **/
> > xlsFile = File.createTempFile("sailfish", ".xls");
> > xlsFile.deleteOnExit(); /** allow deletion on exit
**/
> > /** save as ole file **/
> > if (_excelClientSite.save(xlsFile, true) == false) {
> > /** Yikees! save failed so try to exit **/
> > OLE.error(OLE.ERROR_CANNOT_CREATE_FILE);
> > }
> > } catch (IOException e) {
> > /** Oops, error creating file... **/
> > Syslog.error(this, e);
> > OLE.error(OLE.ERROR_CANNOT_CREATE_FILE);
> > }
> > } else {
> > _excelClientSite = new OleClientSite(oleFrame, SWT.NONE,
> > EXCEL_PROG_ID, xlsFile);
> > }
> >
> > /** dispose of excel for now **/
> > _excelClientSite.dispose();
> >
> > /** Now try to get the interface to shell explorer **/
> > explorerControlSite = new OleControlSite(oleFrame, SWT.NONE,
> > SHELL_EXPLORER_PROG_ID);
> > explorer = new OleAutomation(explorerControlSite);
> >
> > /** register listener **/
> > explorerEventListener = new ExplorerEventListener();
> >
> >
> >
>
explorerControlSite.addEventListener(ExplorerEventListener.D OCUMENT_COMPLETE
> > , explorerEventListener);
> >
> > /**
> > * Load the excel file into the control:
> > * [id(0x00000068), helpstring("Navigates to a URL or
file.")]
> > void Navigate(
> > [in] BSTR URL,
> > [in, optional] VARIANT* Flags,
> > [in, optional] VARIANT* TargetFrameName,
> > [in, optional] VARIANT* PostData,
> > [in, optional] VARIANT* Headers);
> > */
> > {
> > int ids[] = explorer.getIDsOfNames(new String[] {
> > "Navigate", "URL" });
> > final Variant result =
> > explorer.invoke(
> > ids[0],
> > new Variant[] { new
> > Variant(xlsFile.getAbsolutePath())},
> > new int[] { ids[1] });
> > if (result == null) {
> > Syslog.error(this, explorer.getLastError());
> > OLE.error(OLE.ERROR_CANNOT_OPEN_FILE);
> > }
> > }
> >
> > /**
> > * Get the embedded document interface:
> > * [id(0x000000cb), propget, helpstring("Returns the active
> > Document automation object, if any.")]
> > IDispatch* Document();
> > */
> > final Variant _document = explorer.getProperty(0x000000cb);
> > if (_document == null || _document.getType() !=
> OLE.VT_DISPATCH)
> > {
> > final String errMsg =
> > "[Error while trying to get interface to doc("
> > + xlsFile
> > + "). Error("
> > + explorer.getLastError()
> > + ")]";
> > Syslog.error(this, errMsg);
> > OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND);
> > }
> >
> > /** get interface to underlying excel doc **/
> > excelWorkbook = _document.getAutomation();
> >
> > /**
> > * Get the application:
> > * [id(0x00000094), propget, helpcontext(0x00010094)]
> > HRESULT Application([out, retval] Application** RHS);
> > */
> > final Variant _excelApplication =
> > excelWorkbook.getProperty(0x00000094);
> > excelApplication = _excelApplication.getAutomation();
> > } catch (Throwable e) {
> > /** if any error, dispose the frame **/
> > this.dispose();
> > Syslog.error(this, LogUtil.getFullDesc(e));
> > throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED);
> > }
> > }
> >
> > /**
> > * Disposes the oleFrame so that we free all the resources allocated
> to
> > Excel/Explorer.
> > */
> > public void dispose() {
> > /** remember to dispose the frame **/
> > oleFrame.dispose();
> > /** delete the file **/
> > }
> >
> > /**
> > *
> > * @param shell Automation on Explorer. This method is invoked after
> the
> > explorer is showing.
> > */
> > protected void customizeExplorer() {
> > /** Make sure this method is called only once **/
> > synchronized (this) {
> > Assert.neqTrue(explorerInitialized, "explorerInitialized");
> > explorerInitialized = true;
> > }
> >
> > Assert.neqNull(explorer, "explorer");
> > }
> >
> > /**
> > * Customizes excel contained in the explorer.
> > *
> > */
> > protected void customizeExcel() {
> > int ids[];
> > Variant retVal;
> >
> > final int OLECMDID_HIDETOOLBARS = 24;
> > /**
> > * Enable tools bars on excel:
> > * [id(0x000001f6), helpstring("IOleCommandTarget::Exec")]
> > HRESULT ExecWB(
> > [in] OLECMDID cmdID,
> > [in] OLECMDEXECOPT cmdexecopt,
> > [in, optional] VARIANT* pvaIn,
> > [in, out, optional] VARIANT* pvaOut);
> > LECMDEXECOPT_DONTPROMPTUSER = 2,
> > *
> > */
> > ids = explorer.getIDsOfNames(new String[] { "ExecWB", "cmdID",
> > "cmdexecopt" });
> > retVal =
> > explorer.invoke(
> > ids[0],
> > new Variant[] { new Variant(OLECMDID_HIDETOOLBARS), new
> > Variant(2)},
> > new int[] { ids[1], ids[2] });
> > if (retVal == null) {
> > Syslog.debug(this, "[Error enabling toolbars(" +
> > explorer.getLastError() + ")]");
> > }
> >
> > }
> >
> > protected class ExplorerEventListener implements OleListener {
> > protected final static int DOCUMENT_COMPLETE = 0x00000103;
> >
> > /* (non-Javadoc)
> > * @see
> >
>
org.eclipse.swt.ole.win32.OleListener#handleEvent(org.eclips e.swt.ole.win32.
> > OleEvent)
> > */
> > public void handleEvent(OleEvent event) {
> > Require.neqNull(event, "event");
> >
> > switch (event.type) {
> > case DOCUMENT_COMPLETE : //document complete
> > Syslog.debug(this, "Document loaded");
> > /** attach listeners **/
> > final Listener listener = new Listener() {
> > public void handleEvent(final Event event) {
> > switch (event.type) {
> > case SWT.Activate :
> > if
> > (explorerControlSite.doVerb(OLE.OLEIVERB_UIACTIVATE) != OLE.S_OK) {
> > Syslog.error(this, "[Error in
> > explorer: can't activate]");
> > } else {
> > customizeExplorer();
> > customizeExcel();
> > }
> > break;
> > case SWT.Deactivate :
> > if
> > (explorerControlSite.doVerb(OLE.OLEIVERB_HIDE) != OLE.S_OK) {
> > Syslog.error(this, "[Error in
> > explorer: can't deactivate]");
> > }
> > break;
> >
> > default :
> > break;
> > }
> > }
> >
> > };
> >
> > /** add listeners **/
> > // addListener(SWT.Activate,
> > listener);
> > // addListener(SWT.Deactivate,
> > listener);
> >
> > /** force the first event **/
> > final Event firstEvent = new Event();
> > firstEvent.type = SWT.Activate;
> > listener.handleEvent(firstEvent);
> >
> > break;
> > default :
> > Syslog.debug(this, "[Got event type(" + event.type +
> "),
> > detail(" + event.detail + ")]");
> > break;
> > }
> > }
> > }
> >
> > /**
> > * All the other actions inherit from this one.
> > */
> > public abstract class ExcelAction extends Action {
> > public ExcelAction(final String actionName, final String
> > resourceName) {
> > super(actionName);
> > //TODO: load resources
> > }
> >
> > public void run() {
> > /** Runs the underlying action **/
> > doRun();
> > }
> >
> > /**
> > * Subclasses should implement this function on invocation.
> > *
> > */
> > protected abstract void doRun();
> > }
> >
> > }
> >
> >
>
>
Re: Excel/OLE problem.. [message #682239 is a reply to message #373055] Fri, 10 June 2011 17:20 Go to previous message
Shyam  is currently offline Shyam Friend
Messages: 1
Registered: June 2011
Junior Member
Hello,

Is this bug resolved? Did you happen to file a bug report about it?

What was your final solution?

Thanks,
Shyam
Previous Topic:TrayItem title
Next Topic:Please delete this post
Goto Forum:
  


Current Time: Thu Feb 27 03:23:24 GMT 2020

Powered by FUDForum. Page generated in 0.01597 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top