Re: Integrating help texts and tool tips for extension

2015-09-13 Thread Bernard Marcelly

Hi Keith,
Your need is similar to a question asked here some months ago.
Read my answer in archives :


Regards
Bernard

Keith Alcock a écrit le 2015-09-11 18:55 :

Tsutomu,

Thank you, however this doesn't work for me on OpenOffice 4.0.1 and
Windows.  I will double check on Linux.

2015-09-08 5:19 GMT+09:00 Keith Alcock :


API,

I noticed that the standard menus for Writer (File, Edit, View,...)

when

open and hovered over will show tooltips.  For Edit, this is "This

menu

contains commands for editing the contents of the current document."

My

extension also has a menu, specified in Addons.xcu, but there is no

such

tooltip.


-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: How can I define long tooltips for toolbars?

2015-06-23 Thread Bernard Marcelly

Jörg Schmidt a écrit le 2015-06-21 12:56 :

Hello,

In toolbars of OpenOffice, there are buttons with long tooltips.

For example, has in the Format-toolbar the button bold, the tooltip (in a 
german OO):
Stellt den ausgewählten Text fett dar. Befindet sich der Cursor in einem Wort, so 
wird das gesamte Wort fett dargestellt. Wenn die Auswahl bzw. das Wort bereits fett ist, 
wird diese Formatierung aufgehoben.

But how I can for your own macros (in Extensions) realize such long tooltips? 
Is there for example a solution using the addon.xcu, see:
https://wiki.openoffice.org/wiki/Extensions/Extensions_and_Apache_OpenOffice_4.0#addons.xcu_changes



Hi Jörg,
This feature is called : Extended tip. You can enable or disable extended tips 
display in Tools  Options  OpenOffice  General dialog page. Or, by pressing 
Shift+F1, you can show extended tips for the objects under the mouse pointer.


Note that:
- few users know of the Shift-F1 trick, or use it
- most users disable the automatic display of extended tips
- texts of extended tips cannot have formatting
- information is more clear with help pages.

Extended tip is handled by the Application Help, using the help pages of the 
extension. Creating help pages is complex.


With my tool Extension Compiler you can create an extension with help pages. 
Extension Compiler provides a helper to write these files, and add Extended Tips 
for your commands.


https://wiki.openoffice.org/wiki/Extensions_Packager#Extension_Compiler
Be prepared to spend some time reading and understanding the document, and 
creating/testing your extension and its help.


Regards / Bernard

-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: Disable underline - UnoControlFixedHyperlinkModel

2015-04-23 Thread Bernard Marcelly

Hi Jörg,
That's the usual problem of a structure inside a structure : you must use a 
temporary variable.


Dim fd As Object

With fhm
  ' 
  fd = .FontDescriptor
  fd.Underline = com.sun.star.awt.FontUnderline.NONE
  .FontDescriptor = fd
End With

Remark : there is a side effect, the text color is now black. If you want to 
color the text, add this instruction:


  .TextColor = RGB(0,0,250)

Regards / Bernard

Jörg Schmidt a écrit le 2015-04-23 08:26 :

Hello,

How can I stop underlining of hyperlinks in UnoControlFixedHyperlinkModel?

My current code is:

Dim dia_ueber
Dim frm_ueber
Dim fhm

GlobalScope.BasicLibraries.LoadLibrary(jum)
GlobalScope.DialogLibraries.LoadLibrary(jum)
frm_ueber = DialogLibraries.jum.dlg_ueber
dia_ueber = CreateUnoDialog(frm_ueber)

'dia_ueber.Model.getByName(lbl_version).Label = ex_ver

fhm = 
dia_ueber.Model.createInstance(com.sun.star.awt.UnoControlFixedHyperlinkModel)
With fhm
.Name = Hyperlink1
.PositionX = 10
.PositionY = 64
.Width = 80
.Height = 14
.Label = www.jm-schmidt.de
.URL = http://www.jm-schmidt.de/;
End With
dia_ueber.Model.insertByName(fhm.Name, fhm)

dia_ueber.execute


An experiment with:

With fhm
'...
.FontDescriptor.Underline = 0
End With

it does not work.


Gretings,

Jörg


-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: OpenOffice Calc Javascript Function

2015-03-15 Thread Bernard Marcelly

Igal @ Lucee.org a écrit le 2015-03-15 20:41 :

it works.  thank you Bernard!

one last question -- how do I get the libraries to refresh?  when I
make a change to the libraries, sometimes it's visible immediately, and
some times I need to close OpenOffice and re-open it in order to make
sure that the new code is running.  is there a better way to refresh the
libs?


I have not seen such problem, using the Rhino JavaScript debugger.
Don't forget to save from the Rhino window (Ctrl-N or File  Save).



thanks,

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/



-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: [EXT][UI] Static text hyperlink in a dialog

2014-11-17 Thread Bernard Marcelly

Hi,

Since OpenOffice.org version 3.3 there is a control called FixedHyperlink.
However it is not available in the palette of controls in the IDE. So you have 
to insert it by program.

Suppose your dialog is in variable dlg.

Dim dlg As Object
Dim fhm As Object

dlg = CreateUnoDialog(.)

fhm = dlg.Model.createInstance(com.sun.star.awt.UnoControlFixedHyperlinkModel)
With fhm
  .Name = Hyperlink1
  .PositionX = 10
  .PositionY = 10
  .Width = 50
  .Height = 15
  .Label = Apache OpenOffice
  .URL = http://www.openoffice.org/;
End With
dlg.Model.insertByName(fhm.Name, fhm)

dlg.execute


Regards
  Bernard


Message de W. Amenel VOGLOZIN  date 2014-11-17 16:42 :

Hi,

I would like to add a static text (Label Field) to a dialog and the text would act as an 
HTTP hyperlink. It would be similar (including the hand pointer) to the Get more 
extensions online that can be found in the lower right corner of the Extension 
Manager and the text would trigger the opening of the specified link in a Web browser.


Unfortunately, I don't see in the developer guide and published service 
specifications anything that would allow me to do just that. Could someone 
point me into the right direction?

Thank you.



-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: Programmatically (C++) closing frame with chance to save

2014-10-28 Thread Bernard Marcelly

Hi Keith,
Method close() does what it says...
You have to verify if the document was modified.
Use method isModified() from interface com.sun.star.util.XModifiable.
Then you ask for saving, and store it with interface 
com.sunstar.frame.XStorable.

See 
https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Component/Models#XModifiable


Regards
  Bernard

Message de Keith Alcock  date 2014-10-28 15:32 :

API experts,

I need to close some of the open document windows from within a C++
addon.  Some of the documents may have been modified, so there should
be a chance to save them or even abort the close, just like you get
with the Close command from the UI.  It seems like XCloseable is just
the thing for this, but when I perform xCloseable-close() on either
the XFrame or XModel, the window summarily closes even with a modified
document.  Am I calling it on the wrong object or is this not how the
functionality should be implemented or is something else wrong?  Here
is an incomplete code that approximates what I'm doing:

ReferenceXEnumerationAccess xEnumerationAccess = xDesktop-getComponents();
ReferenceXEnumeration xEnumeration = xEnumerationAccess-createEnumeration();

while (xEnumeration-hasMoreElements() == sal_True) {
 ReferenceXComponent xComponent;
 Any any = xEnumeration-nextElement();
 any = xComponent;

 ReferenceXModel xModel(xComponent, UNO_QUERY);
 ReferenceXController xController = xModel-getCurrentController();
 ReferenceXFrame xFrame = xController-getFrame();

 ReferenceXCloseable xCloseableFrame(xFrame, UNO_QUERY);
 xCloseableFrame-close(sal_True);
 return;
}

The frame closes nicely, but no messages about needing to save the
document appear.  Any ideas?  Thanks.

Keith

-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: RTF parsing with OOo

2014-08-22 Thread Bernard Marcelly

Hello Elena,

When OpenOffice opens a text document, it looks the same from the API, be it a 
.rtf or .doc or .odt document. There is no RTF parsing available from the API, 
the job is done by the import filter during loading of the document.


With the API you can load a .rtf document and find if it contains a form and if 
the form contains controls of the type you want.
The explanations in the Developer's Guide are indeed very abstract (chapter 
Forms). In fact it is simply embedded containers.

- a text document has a DrawPage
- the Drawpage contains shapes, and gives access to a container of Forms.
- the container of Forms may contain one form, rarely several forms.
- a Form is a container of controls
- each type of control supports a specific service.

So you can explore your document and find the controls it contains.
Here is an example in OpenOffice Basic (I don't practice Java). It may help 
understand the Java examples of the Developer's Guide.


Dim aDoc As Object, aPage As Object
Dim allForms As Object, allControls As Object
Dim aForm As Object, aControl As Object
Dim x As Long, y As Long
Dim nbCheckBox As Long, nbTextF As Long, nbCtrl As Long

nbCheckBox = 0
nbTextF = 0
nbCtrl = 0
aDoc = ThisComponent

aPage = aDoc.getDrawpage()
allForms = aPage.getForms()
for x = 0 to allForms.getCount() -1
  aForm = allForms.getByIndex(x)
  nbCtrl = nbCtrl +aForm.getCount()
  for y = 0 to aForm.getCount() -1
aControl = aForm.getByIndex(y)
if aControl.supportsService(com.sun.star.form.component.CheckBox)  then
  nbCheckBox = nbCheckBox +1
end if
if aControl.supportsService(com.sun.star.form.component.TextField)  then
  nbTextF = nbTextF +1
end if
  next
next

MsgBox(Number of controls :   nbCtrl  chr(13)  _
  CheckBoxes :   nbCheckBoxTextFields :   nbTextF)


Regards
  Bernard

Message de Elena Sergienko  date 2014-08-21 16:49 :

Dear OpenOffice API community,

I have a set of RTF files. My project is to write a Java program to
identify which of those files contain form elements like checkboxes and
edit fields. Upon my long hours of researching online on how to do it I was
not able to find an obvious way to parse RTF file structure and identify
its elements besides the plain text. I installed OOo 4.1.0 and OOo SDK
4.1.0 hoping that it offers RTF parsing.
Please confirm whether OOo has the relative to my problem solution, and if
so I am hoping you can point me in the right direction.

Thank you,
Elena



-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: selecting more than one sheet (Calc / StarBasic)

2014-08-12 Thread Bernard Marcelly

Hello Jörg,
Use the dispatcher.

Dim dispatcher As Object, curWin As Object
Dim args(0) As New com.sun.star.beans.PropertyValue

curWin = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(com.sun.star.frame.DispatchHelper)
args(0).Name = Tables
args(0).Value = Array(1,2,4) ' list of sheet numbers to select
dispatcher.executeDispatch(curWin, .uno:SelectTables, , 0, args())


Regards
  Bernard


Message de Jörg Schmidt  date 2014-08-12 08:57 :

Hello,

I want to select multiple sheets in Calc simultaneously with StarBasic.
Is there only the indirect method via the range-object? for example: 
https://forum.openoffice.org/en/forum/viewtopic.php?f=20t=45389hilit=select+sheets#p209791



-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: Some questions about undo

2014-03-07 Thread Bernard Marcelly

Hello,
For your information, the rework of the Undo manager was done in january 2011.
See https://issues.apache.org/ooo/show_bug.cgi?id=33781

See also the messages titled info/CWS undoapi: ... in the archives of the 
defunct interface-announce mailing-list.

http://www.mail-archive.com/interface-announce%40openoffice.org/

Regards
  Bernard


-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: Help with pdf import extension download

2014-01-15 Thread Bernard Marcelly

Hello Melinda,
Your message does not show us which version of OpenOffice you use, and from 
which adddress you downloaded the extension. And your image did not pass through.


There is currently a pitfall when searching for PDF import.
Oracle PDF import extension appears as the most popular extension. However it is 
_not_ the correct extension for Apache OpenOffice 4.0.


You can see an ambiguous phrase at top of the description : If you are using 
Apache OpenOffice 4.0, use this version.
Few people will remark that this version is a link to another extension, 
specific to Apache OpenOffice.



The extension PDF Import for Apache OpenOffice is available from
http://extensions.openoffice.org/en/node/17351
Click on the green button to display the download page.
I downloaded the oxt file without problem.

Regards
  Bernard

Message de Melinda Marasch  date 2014-01-15 19:19 :

Hi,

I've tried several times to download the pdf import extension for OpenOffice  I
keep getting this error.

Inline image 1



-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: Detect page break in long tables (Writer)

2014-01-11 Thread Bernard Marcelly

Hi Ralf,
You have to put the view cursor in a cell. The view cursor shows the page number 
where it is situated.


Here is a proof of concept, in OpenOffice Basic.
In a Writer document, insert a table with only one row (the title row).
The macro will insert 100 lines and show you the row numbers where the page has 
changed:


Sub Main1
Dim myDoc As Object, tb As Object, rws As Object
Dim vCurs As Object, curs1 As Object
Dim p1 As Long, p2 As Long, x As Long

myDoc = ThisComponent
tb = myDoc.getTextTables.getByIndex(0)
rws = tb.getRows
curs1 = tb.getCellByPosition(0,0)
myDoc.getCurrentController.select(curs1)
vCurs = myDoc.getCurrentController.getViewCursor
p1 = vCurs.getPage
for x = 1 to 100
  rws.insertByIndex(rws.getCount, 1)
  vCurs.goDown(1, False)
  p2 = vCurs.getPage
  if p2  p1  then
MsgBox(New page at line   x)
p1 = p2
  end if
next
End Sub


Regards
  Bernard

Message de Ralf Heydenreich  date 2014-01-10 21:47 :

Hi all,
I've a Writer document with a table an some placeholders in it. Now, if
I replace these placeholders from my Java application, the table
sometimes gets too long and split over multiple pages. Since it is a
kind of invoice table I want to put a subtotal at the end of each page.
How can I achieve this? How can I detect a page break while filling the
placeholders?

TIA,
Ralf.

-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: com.sun.star.text.SectionFileLink

2013-10-13 Thread Bernard Marcelly

Message de Peter Eberlein  date 2013-10-11 15:50 :

Hi,

if I break the link of a TextSection (which is linked to another section in
another document) by setting the FileLink property (FileURL is empty), then the
content of the section vanishes.

If I do the same with GUI, then the content isn't lost.

Any ideas how to preserve the content?



Hi,
If you simply do this instead :
   yourSection.dispose()
then the text content of the section remains, but the section is removed.


Regards
  Bernard

-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: Basic macro – Retrieve folder of the current spreadsheet

2013-09-29 Thread Bernard Marcelly

Message de Johnny Rosenberg  date 2013-09-28 17:03 :


Is there a similar way to get the folder name directly? I couldn't find it


Not directly. But you can use a routine from the Tools library:

Dim docFolder As String

GlobalScope.BasicLibraries.loadLibrary(Tools)
docFolder = DirectoryNameoutofPath(ThisComponent.URL, /)
MsgBox(docFolder, 0, Folder of this document)

And, referring to your code, you don't need to ConvertToURL() what is already an 
URL address ;-)


Regards
  Bernard

-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: Backward incompatibility of System Mail API

2013-07-30 Thread Bernard Marcelly

Hanya's page should be inserted or linked to in the official AOO 4.0 Release 
Notes.

Regards
  Bernard

Message de Alexandro Colorado  date 2013-07-29 22:03 :

Good link, this should be a blog post letting people know the changes as
well as generate documentation to transition to the 4.0 API.

My question here is this is the definite list or are there other's missing
on the latest iterations?


On Mon, Jul 29, 2013 at 1:48 PM, Mauricio Baeza
maurici...@correolibre.orgwrote:


On 07/29/2013 01:43 PM, Bernard Marcelly wrote:

Hi,
I compared the IDL references of Apache OpenOffice 3.4.1 and 4.0.0.

I found that these services are no longer present:
com.sun.star.system.SimpleCommandMail
com.sun.star.system.SimpleSystemMail

They are replaced by com.sun.star.system.SystemMailProvider.


This is not described in the AOO 4.0 Release Notes. I think it should
be indicated in the chapter Changes that Impact Backwards
Compatibility.


Regards
   Bernard



There are more services method and changed ... Here are some:

http://wiki.openoffice.org/wiki/User:Hanya/API_Changes_on_4.0_since_3.4


Best regards



-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: UNP API

2013-04-12 Thread Bernard Marcelly

Message de k.misha  date 2013-04-10 12:34 :


How can I select a sheet in calc document?



You probably mean : display a particular sheet of a spreadsheet document.
The currently displayed sheet is called the Active Sheet.
You have to set it with the desired sheet object as argument.

REM -- With OpenOffice Basic easy coding ! ---
Dim myDoc As Object, mySheet As Object
myDoc = ThisComponent
mySheet =  myDoc.Sheets.getByName(October)
myDoc.CurrentController.ActiveSheet = mySheet


With Java or C++ you will have to query and use the methods:

Methodfrom  interface
.getSheets()  com.sun.star.sheet.XSpreadsheetDocument
.getCurrentController() com.sun.star.frame.XModel
.setActiveSheet(mySheet)  com.sun.star.sheet.XSpreadsheetView


Regards
  Bernard

-
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



Re: Incompatible change for extensions

2013-01-23 Thread Bernard Marcelly

Hi Ariel and all,

Bug 121582 is very vague and does not detail the proposed changes. It looks like 
an intended obfuscation, so that nobody will react in time.

The XSimpleFileAccess is indicated as merely an example, but I will develop on 
it.

If bug 121582 proposes for Apache OpenOffice 4.0 to create a new 
service+interface _and_ suppress the old service+interfaces, then it is exactly 
the same problem and methodology error as bug 121577 : force application 
developers to change working code without benefits. The change is only for 
esthetical reason.


I remember a saying: If it ain't broke don't fix it.

And for the current multiplication of XSimpleFileAccess interfaces : this is 
completely transparent for programmers in OpenOffice Basic, Python, and 
COM-Automation, since they don't have to query interfaces. And they represent 
probably 90 per cent of all application codes.


If bug 121582 proposes to transfer the functions of XSimpleFileAccess2 and 
XSimpleFileAccess3 into XSimpleFileAccess, and then delete XSimpleFileAccess2 
and XSimpleFileAccess3 : the change will only affect Java, BeanShell, 
Javascript, C++ developers. I doubt they will appreciate.



As says Hans Zybura, in the real world, various versions of OpenOffice are used 
in schools, companies, etc. Forcing different codes between versions is in fact 
a strong incentive to _not_ update existing and working versions.


There is not enough good designers; better spend efforts on correcting reported 
real bugs, or on useful improvements (e.g. a real integration of Python into 
OpenOffice, like Basic; or add the new dialog controls in the IDE toolbox).


Regards
  Bernard


Message de Ariel Constenla-Haile  date 2013-01-22 12:51 :

Hi *,

Replaying in general to the thread, that is based mainly on bug 121577.

The discussion about incompatibility, centered on this bug, is
meaningless: bug https://issues.apache.org/ooo/show_bug.cgi?id=121582 is
the real code-incompatible change, every extension developer will have
to check the code and adapt it to API changes introduced by this task.

It would be interesting to hear arguments against implementing the
changes needed to perform the task for bug 121582.



Re: Incompatible change for extensions

2013-01-17 Thread Bernard Marcelly

Message de Jürgen Schmidt  date 2013-01-17 13:19 :


I disagree, the old mechanism is a design bug and should be resolved. It
was always planned to fix this a major release. Now with 4.0 we can make
such changes and we had long discussions about incompatible changes for
major releases. Extensions can be easy updated and by the way it is
always a good idea to add a max version dependency and release a new
version of your extension if you have ensured that it works with the
newest office version. How many unpublished API's are used in extensions
that can change at any time?

We probably don't have enough time to fix many more design bugs in the
API for 4.0 but this one is definitely worth the change. We will
document it and the fix is easy. But for all new extensions the usage is
much more intuitive and less error prone.



The current mechanism is not a design bug (because it works), rather a clumsy 
design.


To create a toolbar with the same name in Calc, Draw, Impress, you have to:
- create one WindowState xcu file
- make 2 copies of this file
- modify one line in each copy
- add entries for these files in the manifest.xml
Is this really complex, error prone ? I don't think so, compared to all other 
features of an extension.


About max version dependency : application developers don't see the future. It's 
not possible to know in advance when (and why) an extension will become 
incompatible.


In the context of a company that has created a specific extension, happily used 
for years, Apache OpenOffice 4.0 will be a bad surprise.
Releasing a new version will be difficult: the original developer may have gone, 
or have forgotten the building details of an extension; a new developer has to 
learn the syntax of an oxt file, and find out what has to be changed to make it 
work again. Costs, delays. Benefits ? None.


Regards
  Bernard


Re: Prevent closing with InstanceLocker

2012-12-27 Thread Bernard Marcelly

Does the InstanceLocker work if you provide an XActionsApproval (in
Basic, via a UNO listener)? In a dummy test, AOO crashed.


Indeed, it works for me if there is another OpenOffice window in the background. 
But running my routine allowClose still closes the window.


If the document is the unique window, the closing attempt still freezes 
OpenOffice.
Here is my new code.

Option Explicit

Global dontClose As Object, closeDenier As Object

Sub denyClose
if IsNull(dontClose)  then
  closeDenier = CreateUnoListener(nono_, 
com.sun.star.embed.XActionsApproval)
  dontClose = 
com.sun.star.embed.InstanceLocker.InstanceLockerCtor2(StarDesktop.CurrentFrame, 
com.sun.star.embed.Actions.PREVENT_CLOSE, closeDenier)

end if
End Sub


Sub allowClose
if not IsNull(dontClose)  then
  dontClose.dispose
  closeDenier = Nothing
  dontClose = Nothing
end if
End Sub


function nono_approveAction(nAction As Long) As Boolean
nono_approveAction = True
end function



Another thing that does not work is that disposing the InstanceLocker
that is vetoing the closing of the frame, the frame gets closed even if
I don't close it manually. I understood the specification as saying that
disposing the InstanceLocker will remove the close listener, not close
the instance. How do you interpret this?



After creation the service adds a listener of requested type ( close, terminate 
and/or etc. ) to the controlled object and let the listener throw related veto 
exception until the service is disposed.


I have the same interpretation. After disposal of the service the programmer 
should be free to let the window (or the document) open or close it.


Useful references from old mailing lists:
  Annoucement of service InstanceLocker (May 2006)
http://www.mail-archive.com/allfeatures@openoffice.org/msg00282.html
  Problem with InstanceLocker in Basic (Oct 2007)
http://www.mail-archive.com/dev@api.openoffice.org/msg06210.html

Regards
  Bernard




Prevent closing with InstanceLocker

2012-12-26 Thread Bernard Marcelly

Hello,

With OpenOffice Basic, I want to prevent a document from closing.
I tried this simple code, stored in a Writer document:

Option Explicit

Global dontClose As Object

Sub denyClose
if IsNull(dontClose)  then
  dontClose = 
com.sun.star.embed.InstanceLocker.InstanceLockerCtor1(ThisComponent, 
com.sun.star.embed.Actions.PREVENT_CLOSE)

end if
End Sub

Sub allowClose
if not IsNull(dontClose)  then
  dontClose.dispose
  dontClose = Nothing
end if
End Sub


The code was tested on AOO 3.4.1 with Windows XP Home.
1 - I run macro denyClose. I still can close the document.
2 - I load the document again, I run macro denyClose. Then I run macro 
allowClose : the document closes.


I changed the argument ThisComponent to : StarDesktop.CurrentFrame

I run macro denyClose. I can't close the document. But OpenOffice freezes and I 
have to kill it.


Does anybody have a working code in Basic ?

Regards
  Bernard