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

2014-10-28 Thread Ariel Constenla-Haile
On Tue, Oct 28, 2014 at 10:31:56PM +0100, Keith Alcock wrote:
 Thanks.  So are you saying that I need to reprogram the actions that
 the Close menu item seems to invoke?  I was hoping that there was more
 direct access to that functionality, perhaps by dispatching a
 .uno:CloseDoc somewhere.

Yes, if you want user interaction, it is better to dispatch
a .uno:Close, every Frame is a DispatchProvider - note it's simpler to
use the css.frame.DispatchHelper.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


signature.asc
Description: Digital signature


Re: Manipulate menu item titles (text) defined in Addons.xcu

2014-10-16 Thread Ariel Constenla-Haile
Hello Keith,

On Thu, Oct 16, 2014 at 11:13:19AM +0200, Keith Alcock wrote:
 API experts,
 
 This question below couldn't be answered in the forums, so I'll try here:
 
 I have a very nice addon programmed in C++ and the related menu items
 are stored in Addons.xcu. The addon would be even nicer if I could
 adjust the menu item texts as the user works, similarly to how the
 undo, redo, and repeat items function in the edit menu. I can't figure
 out how to get ahold of the XMenu associated with my addon. From there
 it seems that I could use setItemText(). Who knows how to get that
 XMenu and is willing to tell? Thanks.
 
 Additional information:
 
 I've seen examples (e.g.,
 https://issues.apache.org/ooo/show_bug.cgi?id=6778 and
 http://www.libreoffice-forum.de/viewtopic.php?f=12t=12691) of how so
 search through the standard OpenOffice menus, but I don't think that
 the addon menu items are included based on the popupCount I get from

You should *not* use the configuration API in order to change the text of
the menu item (a single change will cause the whole menubar to be
updated, and this is rather inefficient).

The text of the menu items can be changed at runtime by sending a status
update where the css.frame.FeatureStateEvent.State holds the string with
the new menu item text.

How does it work? The menu item is controlled in the application
framework by an object that listens for status updates at the dispatch object
you return in your ProtocolHandler implementation.

For this to work, you may need to modify your implementation of the
ProtocolHandler; usually, in most examples, like the ones on the SDK [1],
the dispatch provider and the dispatch object are implemented in the
same class and status listeners are not tracked.

[1] For example
sdk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx
https://svn.apache.org/viewvc/openoffice/trunk/main/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx?revision=1413471view=markup


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


signature.asc
Description: Digital signature


Re: access internal graphics of a writer-document

2014-10-16 Thread Ariel Constenla-Haile
Hello Jörg,

On Wed, Oct 15, 2014 at 07:31:44AM +0200, Jörg Schmidt wrote:
 Hello,
 
 With the StarBasic-Code: 
 
 ThisComponent.GraphicObjects(0).GraphicURL
 
 I can read the internal URL of an embedded graphic in
 a writer-document, for example
 vnd.sun.star.GraphicObject:13AC00DC178CAB87 
 
 But can I use this URL as .GraphicURL for a graphic control of
 a dialogue? If so, How?

Yes, you can. If the graphic inside the zip file is located in
Pictures/120101B1019D1E3B87B7.png use
vnd.sun.star.GraphicObject:120101B1019D1E3B87B7 that is the
protocol vnd.sun.star.GraphicObject: and the file name without the
extension (the image ID).

 
 What I mean is that
 vnd.sun.star.GraphicObject:13AC00DC178CAB87 is not
 the correct form of the URL what is needed for a graphics control,
 because this would be, for example:
 file:///C:/Users/xxx/Desktop/Hintergrund.png
 
 (or: C:\Users\Internet\Desktop\Hintergrund.png)

I guess you are using the Dialog Editor, I've tried the Property
Browser, and it does not work well with this protocol: setting
Graphics to
vnd.sun.star.GraphicObject:120101B1019D1E3B87B7 is then
converted to lower case, graphicobject, which does not work.

 please note: my document is unsaved, so I can not directly access the
 pictures folder in the *.odt file.

You can set the ImageURL property of the control model, it works with
vnd.sun.star.GraphicObject: protocol.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


signature.asc
Description: Digital signature


Re: [EXT] Actual expanded value of %origin% for toolbar and menu images

2014-08-11 Thread Ariel Constenla-Haile

Hello Amenel,

On Mon, Aug 11, 2014 at 09:57:56AM +0100, Amenel VOGLOZIN wrote:
 Hi, This message is just to bring a peculiarity of the SDK to the
 attention of the subscribers to this mailing list.
 
 Summary: as of AOO 4.1.0, %origin% is expanded into the Office
 folder in the registry subtree of your project (and installed
 extension).
 
 Details follow.

[...]

It is less error prone to use the vnd.sun.star.extension:// protocol,
see http://markmail.org/message/d3fgr74luh6ydl3p

[...]

 Can someone who has access to the Wiki update the relevant page?

I'm sure that, as you go reading the Developer's Guide, you'll find
other places that need correction; if you are willing to help in this
documentation area, you can request a wiki account as explained here
https://wiki.openoffice.org/wiki/Help:Logging_in and fix those places
yourself :)


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


signature.asc
Description: Digital signature


Re: [EXT][GUI] Behavior of the UnoControlGrid's horizontal scroll

2014-07-29 Thread Ariel Constenla-Haile
Hi Amenel,

On Tue, Jul 29, 2014 at 03:55:34PM +0100, Amenel VOGLOZIN wrote:
 Hi,
 
 I have been using a c.s.s.awt.UnoControlGrid to display tabular
 informationin an extension and I have noticed this oddity: the
 horizontal scrollbar is indexed on the number of columns.
 
 Here is my 5-column setup: * column 1: width 16 (non-resizeable)
 * column 2: width 16 too (non-resizeable) * column 3: resizeable, with
 column width=80 (min width=80)
 
 * column 4: resizeable, with column width=234 (min width=234)
 
 * column 5: resizeable, with column width=100 (min width=100)
 
 The width of the control (346) is such that columns 1 to 4 are
 entirely visible. Column 5 is not visible when the control loads but
 as a user, I see the scroll bar as a means to make the hidden part of
 the viewport visible, ie the missing width of 100.
 
 
 The problem is that I was expecting the horizontal scrollbar to
 represent a viewport ratio, i.e. what the currently (horizontally)
 visible part of the grid represents with respect to the cumulated
 width of all columns.
 
 What I get is that the scrollbar actually makes the viewport hop
 from one column to the other: the left of the control's viewport
 always coincides with the left border of a column (this is exactly the
 behavior that can be seen in Calc). As such, in case the last column
 is wider that the first non-visible column on the left of the control
 (in this case, col 5 is wider than col 2), the last column is **not**
 displayed in its entirety: it is clipped and there's no way to see its
 contents. For an illustration, please see the
 UnoControlGrid-scrollbar at far right position attachment.

Most attachments are stripped in the mailing lists (only plain text
attachments seem to pass).

The grid control has several bugs, this seems to be one, see
https://issues.apache.org/ooo/show_bug.cgi?id=125322


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


signature.asc
Description: Digital signature


Re: [EXT] Availability of standard OO documents icons to extensions

2014-07-23 Thread Ariel Constenla-Haile
Hi Amenel,

On Mon, Jul 21, 2014 at 05:36:25PM +0100, Amenel VOGLOZIN wrote:
 Hi all,
 
 I'd like to know whether MIME type icons (for ODT, ODS, ODP, etc.)
 that can be seen in the File  Newmenu entry are available to
 extensions, for instance when creating an XGraphic object.

All those images are stored in a zip file inside the office
installation, on Linux /opt/openoffice4/share/config/images.zip. You can
access those images using the
private:graphicrepository/path_inside_images.zip URL.

The main problem is that the location/name of the images is an
implementation detail, and there is no guarantee that it will be the
same between different releases. For example, you could get that the
icon for Writer documents is res/sx03251.png by reading some source code
(svtools/source/misc/imagemgr.*) or asking in this mailing list, but
there is no guarantee that res/sx03251.png won't change in the next
release, breaking your extension.

So it is better if you take the images you need, and pack them inside
your extension (the images, like the rest of AOO source, is released
under the Apache License v.2). Unzip images.zip, and search then inside
the /res folder; document images follow this scheme:

sximage_id.png - small images
sxhimage_id.png - small images, high-contrast

lximage_id.png - big images
lxhimage_id.png - big images, high-contrast

The image_id is not very simple to get, you need to read source code:

- this array will give you the image id for the extension:
  
http://svn.apache.org/viewvc/openoffice/trunk/main/svtools/source/misc/imagemgr.cxx?revision=1413471view=markup#l129
  For example, odt has image ID IMG_OO_WRITER_DOC

- IMG_OO_WRITER_DOC is defined as IMAGELIST_START + 175
  IMAGELIST_START is defined as 3076
  
http://svn.apache.org/viewvc/openoffice/trunk/main/svtools/inc/svtools/imagemgr.hrc?revision=1413471view=markup#l107
  
http://svn.apache.org/viewvc/openoffice/trunk/main/svtools/inc/svtools/imagemgr.hrc?revision=1413471view=markup#l29

This gives 3251, from there the sx03251.png.



Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


signature.asc
Description: Digital signature


Re: [EXT][GUI] How to define and use layout constraints

2014-07-15 Thread Ariel Constenla-Haile
Hello Amenel,

On Tue, Jul 15, 2014 at 03:22:38PM +0100, Amenel VOGLOZIN wrote:
 Hi all, I have built a dialog that contains labels, buttons and other
 controls. Since I need to make the dialog resizeable, I thought layout
 specifications would be better than the absolute X,Y values that i'm
 currently using.
 
 However, although the Wiki contains XLayoutRoot and XLayoutConstrains,
 there are no examples of how these should be used. This is true for
 the Wiki itself as well as for the examples of code that come with the
 SDK.
 
 Could someone point me in the right direction? That would be immensely
 useful.

Those types in the css.awt module are a remaining of an attempt that was
never really implemented (it's strange they have been introduced, even
unpublished, considering the underlying implementation was never
available on an official build - compilation is conditional, and
currently broken, so this is all dead code).

In short, there is no layout algorithm in OpenOffice API; if you want to
resize the dialog window and its controls, you'll have to do it
manually.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


signature.asc
Description: Digital signature


Re: [EXT]How to declare a unique-instance and all-contexts component

2014-07-10 Thread Ariel Constenla-Haile
Hello Amenel,

On Thu, Jul 10, 2014 at 01:40:21PM +0100, Amenel VOGLOZIN wrote:
 Hi all,
 
 For a few weeks, I have been writing an extension that can be seen as
 a Recent files manager. I'm using Java and it's going great so far.
 
 
 The problem that I'm encountering is that (I have confirmed this fact
 several times) the extension is being instantiated once for each
 document that I open. It is also instantiated the first time that
 I click on its menu in the menu bar.
 
 
 There's probably something that I didn't do well. How can I make the
 extension's component a singleton? Should I add an entry in the
 service names in addition to com.sun.star.frame.ProtocolHandler? If
 yes, what value should I provide? Is it the fully qualified name of
 the main class?

You didn't do anything wrong, a ProtocolHandler is supposed to be
instantiated and initialized on a per Frame/UI element controller basis
(that is, add your command to a toolbar item and a menu bar item, then
you'll find that the component gets instantiated twice, or even more).

You can design UNO components as singletons, make the component factory
return always the same instance, etc.; but in this case, the
ProtocolHandler was not designed for that; it is better to implement the
singleton patter in another class. You have different options:

- it is a better practice to separate the implementation from the
  ProtocolHandler and the Dispatch object (I assume you are implementing
  both in the same class, and queryDispatch/es returns this) so that you
  have different roles and responsibilities; you can make the
  ProtocolHandle's return always the same dispatch object per Frame so
  that you have a n-1 relationship

- implement the singleton pattern on a helper class that handles all the
  recent documents handling

How are you tracking the recent documents? The ProtocolHandler is not
the place to do that ;)


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


signature.asc
Description: Digital signature


Re: [API] How to retrieve a document property

2014-06-26 Thread Ariel Constenla-Haile
On Thu, Jun 26, 2014 at 02:58:18PM +0100, Amenel VOGLOZIN wrote:
 Hi all,
 
 Alexandro, I had spotted the XDocumentProperties interface. I had seen
 it's meant to provide document properties but I had put it aside until
 I could get event notifications sorted out.

If you only want two (when a document is opened and closed), then you
should go for the css.task.Job, a global document event listener is an
overhead as it will listen to every event for every document.

 In that interface, there are only 2 suitable methods to read (or
 load) properties: loadFromStorage and loadFromMedium. Both of these
 have [in] parameters only and both return void... So I'm wondering,
 how is the client code supposed to retrieve the value of say, the
 ModifiedBy attribute?
 Therefore, as is, the call to loadFromMedium has no effect as far as
 my client code is concerned. I'm back to square one.

Don't use that, the document model implements
http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/XDocumentPropertiesSupplier.html
and this gives direct access to the interface's attributes, just use the
getters to retrieve the information.

 To sum up, I just want to sysout a property (e.g. the original author)
 of a document but I don't succeed in getting that information in
 a variable.

In Basic:
author = ThisComponent.getDocumentProperties().Author
MsgBox author


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


signature.asc
Description: Digital signature


Re: Some questions about undo

2014-03-07 Thread Ariel Constenla-Haile
On Thu, Mar 06, 2014 at 07:56:49PM +0100, Jörg Schmidt wrote:
  From: Ariel Constenla-Haile [mailto:arie...@apache.org] 
 
  This looks like an omission from the developer, you might 
  want to submit
  a bug.
 
 No, I think not. 
 
 Please consider the following example: 
 http://www.openoffice.org/api/docs/common/ref/com/sun/star/util/PathSettings.html
  
 
 I do not think there the entry Since OOo 1.1.2 an error hint is, but rather 
 the
 entry is intentional.  

That's precisely what omission from the developer meant: the @since
tag is not an automated feature, the developer must write it explicitly
in the IDL file, hence the omission in this case.

 
  The undo API seems to be new in 3.4 Beta:
  http://permalink.gmane.org/gmane.comp.openoffice.announce.interface/1218

With more exactitud, the integration of the undoapi CWS took place in
2011-01-28 (3.3 was released on 26th January 2011):

Changeset: 274602 (62ffe2f76cf3) CWS-TOOLING: integrate CWS undoapi
User: Vladimir Glazunov v...@openoffice.org
Date: 2011-01-28 11:59:17 +0100 (2011-01-28)
Parent: 274370 (8b4b777816a5) CWS-TOOLING: integrate CWS os147
274601 (51f1e1ceb095) undoapi: pulled and merged DEV300.m98
Child:  274621 (3b5ad50f5e72) CWS-TOOLING: integrate CWS tabcontrol


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpmSAXvUhedD.pgp
Description: PGP signature


Re: Some questions about undo

2014-03-06 Thread Ariel Constenla-Haile
Hi Jörg,

On Thu, Mar 06, 2014 at 10:37:10AM +0100, Jörg Schmidt wrote:
 in:
 http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/XUndoManager.h
 tml
 
 I find no evidence for the version of the OO interface XUndoManager works.
 
 Earlier there were in the IDL-reference for always indicative of the form 
 since
 OOo xy. 
 
 Is that no longer so? 

This looks like an omission from the developer, you might want to submit
a bug.

The undo API seems to be new in 3.4 Beta:
http://permalink.gmane.org/gmane.comp.openoffice.announce.interface/1218

 If yes, how can I know if something is a mistake or a non-existing function? 
 And
 how do I know at what point is a specific feature available?

Besides the @since tag in the IDL, you can check at runtime using
introspection; the simplest way in Basic is the HasUnoInterfaces
function, more complex stuff in the reflexion module
http://www.openoffice.org/api/docs/common/ref/com/sun/star/reflection/module-ix.html


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpQel15Gftd9.pgp
Description: PGP signature


Re: Some questions about undo

2014-02-28 Thread Ariel Constenla-Haile
Hi Jörg,

On Fri, Feb 28, 2014 at 06:47:37AM +0100, Jörg Schmidt wrote:
 Hello,
 
 (a)
 Is there a way to remove one or several undo actions from the stack, but not 
 all actions? 
 
 Exemple:
 
 My undo-stack is:
 
 Eingabe
 Attribute
 Eingabe
 
 and I would like to have the undo-stack:
 
 Eingabe
 Eingabe
 
That particular scenario can have a workaround only if your code is
controlling the undo context, otherwise you can only undo/redo the most
recent action. If you don't want the Attribute action to appear on the
undo stack, enter a hidden undo context.


 (b)
 How can I in general use the 'undo-API'? 

See http://people.apache.org/~arielch/api/UndoManager.odt

 But the following dont work for me (i get an error):
 
 Sub Main
   Msgbox ThisComponent.getCurrentUndoActionTitle()
 End Sub
 
 What am I doing wrong?

The document model does not support this function; this is something as
basic as knowing how to use the API reference:

- search getCurrentUndoActionTitle() in the general index:
  http://www.openoffice.org/api/docs/common/ref/index-files/index-7.html
  getCurrentUndoActionTitle() - function in interface
  ::com::sun::star::document:: .XUndoManager
  
http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/XUndoManager.html#getCurrentUndoActionTitle

- this is a function of the XUndoManager interface, how do you access
  this interface from the document model? See the interface uses:
  
http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/XUndoManager-xref.html

- the interface is used as return type of
  XUndoManagerSupplier::getUndoManager()

- go to the uses of XUndoManagerSupplier
  
http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/XUndoManagerSupplier-xref.html
  The interface is supported by all services implementing the document
  models

The document model implements XUndoManagerSupplier; use this interface
to access the undo manager. getCurrentUndoActionTitle() is a function of
the undo manager: the code without any check should be
ThisComponent.getUndoManager().getCurrentUndoActionTitle()


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpJuDsnHzptS.pgp
Description: PGP signature


Re: PackageInformationProvider::get() and subsequent ReferenceXPackageInformationProvider::getPackageLocation()

2014-02-24 Thread Ariel Constenla-Haile
Hi Keith,

On Mon, Feb 24, 2014 at 08:34:26AM -0700, Keith Alcock wrote:
 Ariel,
 
 The code is from the extension itself.  I get the feeling that the
 technique is not intended for that situation.

you are right

  ReferenceXComponentContext localContext =
  defaultBootstrap_InitialComponentContext();

your C++ extension has a DLL with one or more components, each component
is instantiated with a component context; do not bootstrap a component
context, just use the one the component is instantiated with.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpVAuMXGA73r.pgp
Description: PGP signature


Re: show sidebar by code in extension

2014-02-15 Thread Ariel Constenla-Haile
Hi Антон,

On Wed, Feb 12, 2014 at 02:21:19AM +0400, Антон Борисов wrote:
 Dear all,
  It's possible to show and hide Sidebar by java code in extension by
 dispatch framework or by another way ?
  I haven't found anything by searching

Are you trying to simply show/hide the sidebar? That would be
dispatching the respective command: .uno:Sidebar. Dispatching will
toggle the sidebar visibility. You can also dispatch only when needed,
get a single status update by adding and removing a status listener at
the dispatch object; in the .uno:Sidebar case,
css.frame.FeatureStateEvent.State is bool, where true means the sidebar is
visible, false it hidden.

If you want to display some specific deck or panel, then it is
impossible. In theory, panels are UI elements with resource URL schema
private:resource/toolpanel/, and the code is still there, but it is
broken, you cannot use the LayoutManager to show/hide panels.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpAIbGdAB6FO.pgp
Description: PGP signature


Re: PDF import

2014-01-25 Thread Ariel Constenla-Haile
On Sat, Jan 25, 2014 at 03:32:42PM +0100, Andrea Pescetti wrote:
 I am using OpenOffice 4.  I did try to download the extension for
 opening and modify a PDF document but there is no explanations about
 how to run and use such zipped files.
 
 Make sure you are using the version for OpenOffice 4.x (from the
 filenames you quote, you are already using it).

Not sure if he is using the one for AOO4 because he is mailing to this
list, as said in
http://extensions.openoffice.org/en/project/oracle-pdf-import-extension

To further improve this extension, please continue sending us feedback
at api@openoffice.apache.org.

@Roberto: can you please remove this sentence from that page?
And please follow the advice from Bernard Marcelly in another thread:

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.

Instead of If you are using Apache OpenOffice 4.0, use this version.,
please put something more clear, like If you are using Apache
OpenOffice 4.0, you *must* use *another* version. or something like
that.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpRwnXwAmX7V.pgp
Description: PGP signature


Re: css.system.XMailMessage vs. css.mail.XMailMessage

2013-12-18 Thread Ariel Constenla-Haile
Hi Peter,

On Wed, Dec 18, 2013 at 09:57:25AM +0100, Peter Eberlein wrote:
 Hi,
 
 first thanks to Ariel who simplified the system mail stuff.
 But this seems not suitable for html body. 

It depends on the MUA implementation, but in general you can assume the
string is a plain text body.

 So I tried:
 
 'a selection in the textdocument must be done before
 xTransferable = ThisComponent.CurrentController.getTransferable()
 dataflavors = xTransferable.getTransferDataFlavors()
 data = dataflavors(2)'html
 transferData = xtransferable.getTransferData(data)
 
 xMessage = 
 com.sun.star.mail.MailMessage.create(Array(t...@test.com),Array(t...@test.com),Subject,
 xTransferable )
 
 But this fails. Any ideas why? I think the xTransferable isn't the
 correct type, because it supports other mimetypes too.

Yes, this fails because the implementation only takes into account the
first data flavour, see
http://www.openoffice.org/api/docs/common/ref/com/sun/star/mail/XMailMessage.html#Body
The body of the mail message. It is expected that the transferable
delivers the data as a string. Although a transferable may support
multiple data flavors only the first data flavor supplied will be used
to retrieve the data and it is expected that the data will be provided
as a string.

You can find some examples on
http://people.apache.org/~arielch/api/MailApiTest.zip (they might look
a little overcomplicated, because I used them to test some bug fixes).

Pay attention to MAIN.Test_Html_Body and
Body.MailBody_CreateFromCurrentDocument, the last one creates a UNO
listener depending on the mime type (plain text or HTML); then
HTMLTextBodyFromCurrentDoc_getTransferData calls
__GetTransferDataFromCurrentDocument to do the job:

- export the current document to HTML
- read the HTML document as a string (this has a big limitation in
  Basic, where strings are implemented internally with an old class that
  has a 64k limit for the string's content).


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpCMXmh8gLci.pgp
Description: PGP signature


Re: API for setting a resultset to masterfields (com.sun.star.text.fieldmaster.Database)

2013-11-05 Thread Ariel Constenla-Haile
Hi Peter,

On Tue, Nov 05, 2013 at 03:12:45PM +0100, Peter Eberlein wrote:
 Hi,
 
 in the gui there's a command Data into fields for a selected row in
 Database sources.  Any ideas how to get the selected row (bookmark of
 the resultset) into these fields with api?  I remember that Fernand
 asked Frank S. a similar question, but didn't found it anymore.

AFAIK there is no API for that, but you can dispatch the UNO command
with the proper arguments sequence; see the attached example, it uses
record numbers instead of bookmarks, but it should work with bookmarks
too (set BookmarkSelection to True).


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina
REM  *  BASIC  *

Option Explicit

Sub Main
Dim oDoc as Object
Dim oFrame as Object
Dim oURLTransformer as Object
Dim oURL as new com.sun.star.util.URL
Dim oDispatch as Object

oDoc = 
StarDesktop.loadComponentFromURL(private:factory/swriter,_default,com.sun.star.frame.FrameSearchFlag.ALL,Array())
oFrame = oDoc.getCurrentController().getFrame()
oURLTransformer = CreateUnoService(com.sun.star.util.URLTransformer)
oURL.Complete = .uno:DataSourceBrowser/InsertContent
oURLTransformer.parseStrict(oURL)
oDispatch = 
oFrame.queryDispatch(oURL,_self,com.sun.star.frame.FrameSearchFlag.SELF)

If IsNULL(oDispatch) Then
Exit Sub
End If

Dim oMasters as Object
Dim oMasterID as Object
Dim oMasterAuthor as Object
Dim sMasterID$
Dim sMasterAuthor$

sMasterID = 
com.sun.star.text.fieldmaster.DataBase.Bibliography.biblio.Identifier
sMasterAuthor = 
com.sun.star.text.fieldmaster.DataBase.Bibliography.biblio.Author
oMasters = oDoc.getTextFieldMasters()

If oMasters.hasByName(sMasterID) Then
oMasterID = oMasters.getByName(sMasterID)
Else
oMasterID = 
oDoc.createInstance(com.sun.star.text.fieldmaster.Database)
With oMasterID
.DataBaseName = Bibliography
.DataCommandType = com.sun.star.sdb.CommandType.TABLE
.DataTableName = biblio
.DataColumnName = Identifier
End With
End If

If oMasters.hasByName(sMasterAuthor) Then
oMasterAuthor = oMasters.getByName(sMasterAuthor)
Else
oMasterAuthor = 
oDoc.createInstance(com.sun.star.text.fieldmaster.Database)
With oMasterAuthor
.DataBaseName = Bibliography
.DataCommandType = com.sun.star.sdb.CommandType.TABLE
.DataTableName = biblio
.DataColumnName = Author
End With
End If

Dim oText as Object
Dim oCursor as Object
oText = oDoc.getText()
oCursor = oText.createTextCursor()

oText.insertString(oCursor, Test:, False )

oText.insertControlCharacter(oCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False
 )

Dim nFields%
Dim oField as Object
For nFields = 0 To 3
oText.insertString(oCursor, CStr(nFields + 1) + : [, False )

oField = 
oDoc.createInstance(com.sun.star.text.textfield.Database)
oField.attachTextFieldMaster(oMasterID)
oText.insertTextContent(oCursor, oField, False )

oText.insertString(oCursor, ] , False )

oField = 
oDoc.createInstance(com.sun.star.text.textfield.Database)
oField.attachTextFieldMaster(oMasterAuthor)
oText.insertTextContent(oCursor, oField, False )

oField = 
oDoc.createInstance(com.sun.star.text.textfield.DatabaseNextSet)
oField.DataBaseName = Bibliography
oField.DataCommandType = com.sun.star.sdb.CommandType.TABLE
oField.DataTableName = biblio
oField.Condition = TRUE
oText.insertTextContent(oCursor, oField, False )

oText.insertString(oCursor, ., False )

oText.insertControlCharacter(oCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False
 )
Next


Dim oDS as Object
Dim oConnection as Object
Dim oDatabaseContext as Object
Dim oStatement as Object
Dim oResultSet as Object

oDatabaseContext = CreateUnoService(com.sun.star.sdb.DatabaseContext) 
oDS = oDatabaseContext.getByName(Bibliography)
oConnection = oDS.getConnection(,)
oStatement = oConnection.createStatement()
oResultSet = oStatement.executeQuery(SELECT * FROM biblio)

'Selection - a sequence of Any
' record

Re: inspector.oxt

2013-09-26 Thread Ariel Constenla-Haile
On Wed, Sep 25, 2013 at 04:43:33PM +0300, K.Misha wrote:
 When i'm installing Object inspector i have this error:

once again, we on the list don't see anything, you can check at
http://markmail.org/message/yw3ge5ykncjnnk6v how your message looks
like.

 Can you help me with this error? Maybe i have to install Java platform or
 something else?

This is a Java extension, it needs Java installed. Nevertheless, its
code is rather unmaintained, I doubt it will even work; so it's better to try
Tsutomu Uchino's object introspection tool for OpenOffice API

http://extensions.openoffice.org/en/project/MRI


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpQ5hS8yy_IB.pgp
Description: PGP signature


Re: Change text in writer without changing style and formats

2013-09-25 Thread Ariel Constenla-Haile
Hi,

On Tue, Sep 24, 2013 at 08:13:30PM +0300, K.Misha wrote:
 One more question... before changing text i have this:
   xTextCursor-setString(wVal);
 after this code all tables and other styles were deleted. How can i change
 text without deleting it?

please read the API documentation:
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/XTextRange.html#setString
the whole string of characters of this piece of text is replaced. All
styles are removed when applying this method.


You need to use css::text::XSimpleText::insertString(), vid.
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/XSimpleText.html#insertString


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpKYXWcVbLiN.pgp
Description: PGP signature


Re: Find\replace in writer

2013-09-25 Thread Ariel Constenla-Haile
On Wed, Sep 25, 2013 at 04:31:52PM +0300, K.Misha wrote:
 Hello!
 
  
 
 What interface i need to use to find\replace text in writer documet?

Search and Replace in text documents is described in the Developer's
Guide:
http://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Navigating#Search_and_Replace


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpzBXHvgWwY5.pgp
Description: PGP signature


Re: convert rtl::OUString to char *

2013-09-24 Thread Ariel Constenla-Haile
Hi,

On Tue, Sep 24, 2013 at 06:44:05PM +0300, K.Misha wrote:
 Hi!
 
  
 
 I habe this code:
 
  
 
 Reference  XTextDocument  xTextDocument (xWriterComponent,UNO_QUERY);
 
 Reference XText  xText = xTextDocument-getText();
 
  
 
 How can i convert xTextDocument-getText() to char * ?

First, the css.text.XText is not a string, use XTextRange::getString()
to get the rtl::OUString.

Then, convert the OUString to an OString and then use OString::getStr()

Reference XText  xText  = xTextDocument-getText();
const rtl::OUString uText = xText-getString();
const rtl::OString sText  = rtl::OUStringToOString( sText, 
RTL_TEXTENCODING_UTF8 );
const char *pzstr = sText.getStr();



Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpge2XRd6BvB.pgp
Description: PGP signature


Re: convert OUString to char *

2013-09-24 Thread Ariel Constenla-Haile
On Tue, Sep 24, 2013 at 08:07:59PM +0300, K.Misha wrote:
 This is original file:
 
 
 
  
 
 And this is my return str1:
 
 

I see only empty lines here, no text, so I don't get what the difference
could be. But are you watching the value of str1 inside the debugger, or
just printing that to a console?

The code attached has non-ASCII characters, it prints the string
returned by OString::getStr() in the standard output; it works (all
characters are displayed) fine on Linux, but on Windows you may have to
do system specific stuff (didn't try it right now).
 

Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina
/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * License); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */

#include cppuhelper/bootstrap.hxx

#include com/sun/star/beans/XPropertySet.hpp
#include com/sun/star/frame/FrameSearchFlag.hpp
#include com/sun/star/frame/XComponentLoader.hpp
#include com/sun/star/lang/XMultiServiceFactory.hpp
#include com/sun/star/text/XTextCursor.hpp
#include com/sun/star/text/XText.hpp
#include com/sun/star/text/XTextDocument.hpp
#include com/sun/star/text/XTextContent.hpp
#include com/sun/star/text/ControlCharacter.hpp
#include com/sun/star/uno/XComponentContext.hpp

#include iostream

namespace css = ::com::sun::star;
namespace ControlCharacter = css::text::ControlCharacter;
using rtl::OUString;


static const char DummyText[] = Als Gregor Samsa eines Morgens aus unruhigen 
Träumen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer 
verwandelt. Er lag auf seinem panzerartig harten Rücken und sah, wenn er den 
Kopf ein wenig hob, seinen gewölbten, braunen, von bogenförmigen Versteifungen 
geteilten Bauch, auf dessen Höhe sich die Bettdecke, zum gänzlichen 
Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu 
seinem sonstigen Umfang kläglich dünnen Beine flimmerten ihm hilflos vor den 
Augen.\n»Was ist mit mir geschehen?« dachte er. Es war kein Traum, sein Zimmer, 
ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier 
wohlbekannten Wänden, über dem Tisch, auf dem eine auseinandergepackte 
Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender -, hing 
das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten 
und in einem hübschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine 
Dame dar, die, mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasaß und 
einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem 
Beschauer entgegenhob.\nGregors Blick richtete sich dann zum Fenster, und das 
trübe Wetter - man hörte Regentropfen auf das Fensterblech aufschlagen - machte 
ihn ganz melancholisch. »Wie wäre es, wenn ich noch ein wenig weiterschliefe 
und alle Narrheiten vergäße,« dachte er, aber das war gänzlich undurchführbar, 
denn er war gewöhnt, auf der rechten Seite zu schlafen, konnte sich aber in 
seinem gegenwärtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er 
sich auch auf die rechte Seite warf, immer wieder schaukelte er in die 
Rückenlage zurück. Er versuchte es wohl hundertmal, schloß die Augen, um die 
zappelnden Beine nicht sehen zu müssen und ließ erst ab, als er in der Seite 
einen noch nie gefühlten, leichten, dumpfen Schmerz zu fühlen begann.;


template  typename T 
css::uno::Reference T 
LoadComponent(
const css::uno::Reference css::uno::XComponentContext  xContext,
css::uno::Reference css::frame::XComponentLoader   xLoader,
const rtl::OUString rURL,
const css::uno::Sequence  css::beans::PropertyValue  rMediaDescriptor
= css::uno::Sequence  css::beans::PropertyValue (),
const rtl::OUString rFrame
= OUString( RTL_CONSTASCII_USTRINGPARAM( _blank ) ),
sal_Int32 nFrameSearchFlag = css::frame::FrameSearchFlag::ALL )
throw ( css::uno::Exception )
{
css::uno::Reference  T  xDoc;

try
{
if ( !xLoader.is() )
{
xLoader.set(
xContext-getServiceManager()-createInstanceWithContext(
OUString( RTL_CONSTASCII_USTRINGPARAM(
  com.sun.star.frame.Desktop ) ), xContext

Re: inserting images in writer

2013-09-20 Thread Ariel Constenla-Haile
Hi,

On Thu, Sep 19, 2013 at 09:33:34PM +0300, K.Misha wrote:
 Hello!
 
 Can you send me some examples of using  images in writer?

An image in Writer is a com.sun.star.text.TextGraphicObject, see
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/TextGraphicObject.html
http://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Graphic_Objects

- create a graphic object at the document factory, call createInstance
  passing the service name

- you can insert a linked or an embedded graphic, in both cases you need
  to know the actual size of the image before setting the graphic object
  size. Use the GraphicProvider service to retrieve that information,
  then set the size with the Size property

- linked images are inserted setting the GraphicURL property, embedded
  images are inserted setting the Graphic property; the graphic object
  is a text content, you have to use insertTextContent to insert it.
  The red warning box at
  http://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Graphic_Objects
  is outdated: Embedding of graphics *is* supported by using the
  Graphic property instead of GraphicURL

- there are many other properties controlling the graphic object, they
  are documented in
  
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/TextGraphicObject.html
  
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/BaseFrameProperties.html


Attached is a variation of http://markmail.org/message/cl356hyng5utkuif


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina
/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * License); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */

#include cppuhelper/bootstrap.hxx

#include com/sun/star/awt/Size.hpp
#include com/sun/star/awt/XToolkit.hpp
#include com/sun/star/awt/XUnitConversion.hpp
#include com/sun/star/beans/XPropertySet.hpp
#include com/sun/star/container/XIndexAccess.hpp
#include com/sun/star/drawing/XDrawPageSupplier.hpp
#include com/sun/star/drawing/XDrawPagesSupplier.hpp
#include com/sun/star/frame/FrameSearchFlag.hpp
#include com/sun/star/frame/XComponentLoader.hpp
#include com/sun/star/graphic/GraphicType.hpp
#include com/sun/star/graphic/XGraphicProvider.hpp
#include com/sun/star/lang/XMultiServiceFactory.hpp
#include com/sun/star/text/XTextCursor.hpp
#include com/sun/star/text/XText.hpp
#include com/sun/star/text/XTextDocument.hpp
#include com/sun/star/text/XTextContent.hpp
#include com/sun/star/text/ControlCharacter.hpp
#include com/sun/star/uno/XComponentContext.hpp
#include com/sun/star/util/MeasureUnit.hpp

#include iostream

namespace css = ::com::sun::star;
using rtl::OUString;

inline bool operator!( const css::awt::Size aSize )
{
return aSize.Width == 0  aSize.Height == 0;
}

static css::uno::Reference css::graphic::XGraphic 
GetGraphicFromURL(
const css::uno::Reference css::uno::XComponentContext  rxContext,
const OUString rURL )
{
css::uno::Reference css::graphic::XGraphic  xGraphic;
try
{
css::uno::Reference css::graphic::XGraphicProvider  xGraphicProvider(
rxContext-getServiceManager()-createInstanceWithContext(
OUString( RTL_CONSTASCII_USTRINGPARAM(
  com.sun.star.graphic.GraphicProvider ) ), 
rxContext ),
css::uno::UNO_QUERY_THROW );

css::uno::Sequence css::beans::PropertyValue  aMediaProps( 1 );
aMediaProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( URL ) );
aMediaProps[0].Value = rURL;

xGraphic.set( xGraphicProvider-queryGraphic( aMediaProps ),
  css::uno::UNO_SET_THROW );
}
catch ( const css::uno::Exception e )
{
std::cerr  Caught an exception: 
   rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 
).getStr()
   '\n';
}

return xGraphic;
}

static void ConvertPixelTo100thMM(
css::awt::Size rSize100thMM,
const css::awt::Size aSizePixel,
const css::uno::Reference css::uno::XComponentContext  rxContext )
{
try
{
css::uno::Reference css::awt::XToolkit  xToolkit(
rxContext-getServiceManager()-createInstanceWithContext

Re: cppu::bootstrap() does not work with OpenOffice 4.0.0

2013-09-19 Thread Ariel Constenla-Haile
Hi,

On Thu, Sep 19, 2013 at 01:46:16PM +0800, Wei Min Teo wrote:
 Hi all, Thanks for all replies.  The OS that I tested on is Windows
 XP. The reason why I started a openoffice process in listening mode is
 to run an invisible instance that runs in the background for automated
 tasks.  Ariel Constenla-Haile have tested that the simple bootstrap
 example from the SDK. Anything else I can try? Are there alternate
 methods to bootstrap?

Yes. If the simple bootstrap mechanism is broken, you have to use the
old method of first starting the office listening for interprocess
connections.

Documentation:
http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/UNO_Interprocess_Connections
http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/Establishing_Interprocess_Connections

Sample code:
- in the SDK installation, C++ examples using the
  com.sun.star.bridge.UnoUrlResolver

examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.cxx
examples/cpp/DocumentLoader/DocumentLoader.cxx

- there is a C++ connection aware client in
  
http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/ConnectionAwareClient/



Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpGH7RRSvdw5.pgp
Description: PGP signature


Re: Change column property in XTextTable

2013-09-19 Thread Ariel Constenla-Haile
Hi,

On Thu, Sep 19, 2013 at 02:36:24PM +0300, K.Misha wrote:
 Can you help me with changing column properties in text table?

The columns width is handled by the property TableColumnSeparators of
the table, see
http://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Table_Properties

An example, assuming that you have a 6 columns table, each column will
have by default the same with, 16.6 %; we want the first column to be
only the 10%, and the other columns have the same width; the following
code snippet does this:


Reference XPropertySet  rTablePropertySet ( rTextTable, UNO_QUERY_THROW );

sal_Int16 nReltativeSum( 0 );
rTablePropertySet-getPropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM(
TableColumnRelativeSum ) ) ) = nReltativeSum;

// by default, every column has the same width
// with 6 columns, every column is 16.6 % of the column relative sum
// make the first column a 10 %
sal_Int16 nFirstColumn( nReltativeSum / 10 );
sal_Int16 nOtherCols( ( nReltativeSum - nFirstColumn ) / 5 );
sal_Int16 nPosition( nFirstColumn );

// in general, you get the sequence from the table's TableColumnSeparators
// but as we've just created the table and know the column count,
// there is no need to do so
Sequence TableColumnSeparator  aColSeparators( 5 );
aColSeparators[0].Position = nPosition;
aColSeparators[0].IsVisible = sal_True;
aColSeparators[1].Position = nPosition += nOtherCols;
aColSeparators[1].IsVisible = sal_True;
aColSeparators[2].Position = nPosition += nOtherCols;
aColSeparators[2].IsVisible = sal_True;
aColSeparators[3].Position = nPosition += nOtherCols;
aColSeparators[3].IsVisible = sal_True;
aColSeparators[4].Position = nPosition += nOtherCols;
aColSeparators[4].IsVisible = sal_True;

rTablePropertySet-setPropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM( TableColumnSeparators ) ),
makeAny( aColSeparators ) );


The full example is attached.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

#include iostream

#include cppuhelper/bootstrap.hxx
#include rtl/ustring.hxx

/** === begin UNO includes === **/
#include com/sun/star/beans/PropertyValue.hpp
#include com/sun/star/beans/XPropertySet.hpp
#include com/sun/star/chart/XChartData.hpp
#include com/sun/star/chart/XChartDataArray.hpp
#include com/sun/star/chart/XChartDocument.hpp
#include com/sun/star/document/XEmbeddedObjectSupplier.hpp
#include com/sun/star/frame/XComponentLoader.hpp
#include com/sun/star/lang/XComponent.hpp
#include com/sun/star/lang/XMultiComponentFactory.hpp
#include com/sun/star/lang/XMultiServiceFactory.hpp
#include com/sun/star/sheet/XCellRangeData.hpp
#include com/sun/star/sheet/XCellRangeData.hpp
#include com/sun/star/table/XCell.hpp
#include com/sun/star/table/XTableRows.hpp
#include com/sun/star/text/ControlCharacter.hpp
#include com/sun/star/text/TableColumnSeparator.hpp
#include com/sun/star/text/XText.hpp
#include com/sun/star/text/XTextContent.hpp
#include com/sun/star/text/XTextCursor.hpp
#include com/sun/star/text/XTextDocument.hpp
#include com/sun/star/text/XTextTable.hpp
#include com/sun/star/text/XTextTableCursor.hpp
#include com/sun/star/uno/XComponentContext.hpp
/** === end UNO includes === **/

/** === begin UNO using === **/
using ::com::sun::star::beans::PropertyValue;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::chart::XChartData;
using ::com::sun::star::chart::XChartDataArray;
using ::com::sun::star::chart::XChartDocument;
using ::com::sun::star::document::XEmbeddedObjectSupplier;
using ::com::sun::star::frame::XComponentLoader;
using ::com::sun::star::lang::XComponent;
using ::com::sun::star::lang::XMultiComponentFactory;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::sheet::XCellRangeData;
using ::com::sun::star::sheet::XCellRangeData;
using ::com::sun::star::table::XCell;
using ::com::sun::star::table::XTableRows;
using ::com::sun::star::text::TableColumnSeparator;
using ::com::sun::star::text::XText;
using ::com::sun::star::text::XTextContent;
using ::com::sun::star::text::XTextCursor;
using ::com::sun::star::text::XTextDocument;
using ::com::sun::star::text::XTextTable;
using ::com::sun::star::text::XTextTableCursor;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::XComponentContext;
using ::com::sun::star::uno::XInterface;
using ::com::sun::star::uno::makeAny;
/** === end UNO using === **/

using namespace std;
using rtl::OUString;
namespace ControlCharacter = ::com::sun::star::text::ControlCharacter;

int SAL_CALL main( int argc, char *argv[] )
{
try
{
// bootstrap the office
Reference XComponentContext  rContext ( ::cppu::bootstrap() );

Reference XMultiComponentFactory  rMCF = 
rContext

Re: Change column property in XTextTable

2013-09-19 Thread Ariel Constenla-Haile
Hi,

On Thu, Sep 19, 2013 at 11:32:50PM +0300, K.Misha wrote:
 Code in attached file makes TextTable like this:
 
 
 
  
 
 But how i can make table like this:

The answer is in the code snippet in the API documentation:
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/TextTable.html

Set the HoriOrient property to NONE and then set the LeftMargin and
RightMargin; or try other combinations, like in the attached example.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

#include iostream

#include cppuhelper/bootstrap.hxx
#include rtl/ustring.hxx

/** === begin UNO includes === **/
#include com/sun/star/beans/PropertyValue.hpp
#include com/sun/star/beans/XPropertySet.hpp
#include com/sun/star/chart/XChartData.hpp
#include com/sun/star/chart/XChartDataArray.hpp
#include com/sun/star/chart/XChartDocument.hpp
#include com/sun/star/document/XEmbeddedObjectSupplier.hpp
#include com/sun/star/frame/XComponentLoader.hpp
#include com/sun/star/lang/XComponent.hpp
#include com/sun/star/lang/XMultiComponentFactory.hpp
#include com/sun/star/lang/XMultiServiceFactory.hpp
#include com/sun/star/sheet/XCellRangeData.hpp
#include com/sun/star/sheet/XCellRangeData.hpp
#include com/sun/star/table/XCell.hpp
#include com/sun/star/table/XTableRows.hpp
#include com/sun/star/text/ControlCharacter.hpp
#include com/sun/star/text/TableColumnSeparator.hpp
#include com/sun/star/text/HoriOrientation.hpp
#include com/sun/star/text/XText.hpp
#include com/sun/star/text/XTextContent.hpp
#include com/sun/star/text/XTextCursor.hpp
#include com/sun/star/text/XTextDocument.hpp
#include com/sun/star/text/XTextTable.hpp
#include com/sun/star/text/XTextTableCursor.hpp
#include com/sun/star/uno/XComponentContext.hpp
/** === end UNO includes === **/

/** === begin UNO using === **/
using ::com::sun::star::beans::PropertyValue;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::chart::XChartData;
using ::com::sun::star::chart::XChartDataArray;
using ::com::sun::star::chart::XChartDocument;
using ::com::sun::star::document::XEmbeddedObjectSupplier;
using ::com::sun::star::frame::XComponentLoader;
using ::com::sun::star::lang::XComponent;
using ::com::sun::star::lang::XMultiComponentFactory;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::sheet::XCellRangeData;
using ::com::sun::star::sheet::XCellRangeData;
using ::com::sun::star::table::XCell;
using ::com::sun::star::table::XTableRows;
using ::com::sun::star::text::TableColumnSeparator;
using ::com::sun::star::text::XText;
using ::com::sun::star::text::XTextContent;
using ::com::sun::star::text::XTextCursor;
using ::com::sun::star::text::XTextDocument;
using ::com::sun::star::text::XTextTable;
using ::com::sun::star::text::XTextTableCursor;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::XComponentContext;
using ::com::sun::star::uno::XInterface;
using ::com::sun::star::uno::makeAny;
/** === end UNO using === **/

using namespace std;
using rtl::OUString;
namespace ControlCharacter = ::com::sun::star::text::ControlCharacter;

int SAL_CALL main( int argc, char *argv[] )
{
try
{
// bootstrap the office
Reference XComponentContext  rContext ( ::cppu::bootstrap() );
Reference XMultiComponentFactory  rMCF( rContext-getServiceManager() 
);

// instantiate the Desktop and get a reference to XComponentLoader
Reference  XComponentLoader  rComponentLoader(
rMCF-createInstanceWithContext( OUString( 
RTL_CONSTASCII_USTRINGPARAM(
com.sun.star.frame.Desktop ) ), rContext ), 
UNO_QUERY_THROW );

// load a new empty OOo Writer document
Reference XTextDocument  rTextDocument (
rComponentLoader-loadComponentFromURL(
OUString( RTL_CONSTASCII_USTRINGPARAM( 
private:factory/swriter ) ),
OUString( RTL_CONSTASCII_USTRINGPARAM( _blank ) ),
0,
Sequence  ::com::sun::star::beans::PropertyValue () ), 
UNO_QUERY_THROW );

// get the XText interface
Reference XText  rText = rTextDocument-getText();

// create a text cursor
Reference XTextCursor  rTextCursor = rText-createTextCursor();
rTextCursor-gotoStart( sal_False );

rText-insertString(
rTextCursor.get(),
OUString( RTL_CONSTASCII_USTRINGPARAM( Default table: ) ),
sal_False );

// insert a paragraph break
rText-insertControlCharacter(
rTextCursor.get(), ControlCharacter::PARAGRAPH_BREAK, sal_False );

// get the document's factory
Reference XMultiServiceFactory  rDocFactory( rTextDocument, 
UNO_QUERY_THROW );

// create a text table

Re: XText Interface of XTextSection

2013-09-18 Thread Ariel Constenla-Haile
Hi,

On Wed, Sep 18, 2013 at 12:29:54PM +0200, Peter Eberlein wrote:
 Hi,
 
 the service css.text.TextFrame exports the XTextFrame Interface with
 the getText() method.
 The service css.text.TextSection exports the XTextSection Interface,
 but I'm missing a convenient method to get the XText of the section.
 The XTextContent's anchor of the section gives me the XTextRange of
 the parent of the section.

a section does not have an XText of its own, so the anchor of the
section gives you access to its text.

If you want to insert text inside the section right after inserting the 
section, you may have to move the text cursor to the previous paragraph, 
because inserting a section inserts a new empty paragraph and positions the 
cursor in the next paragraph:

REM  *  BASIC  *

Option Explicit

Sub Main
Dim oDoc as Object
oDoc = 
StarDesktop.loadComponentFromURL(private:factory/swriter,_default,0,Array())

Dim oText as Object
Dim oCursor as Object
Dim oSection as Object
Dim sSection as String
Dim oSectionText as Object

sSection = Test section
oText = oDoc.getText()
oCursor = oText.createTextCursorByRange(oText.getStart())
oSection = oDoc.createInstance(com.sun.star.text.TextSection)
oSection.setName(sSection)

oText.insertString(oCursor, A new section:, False)
oText.insertControlCharacter(oCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,
 False)
oText.insertTextContent(oCursor, oSection, False)

'after inserting the section, the cursor is on the next paragraph
oCursor.gotoPreviousParagraph(False)
oText.insertString(oCursor, Text inside section, False)

 
 Any ideas? (I don't want to iterate over the paragraphs to obtain
 the section)?

If you know the name of the section, get the section by name; if you
have a reference to the already inserted section, simply create a text
cursor by range, using the section's anchor as parameter:

Dim oSections as Object
oSections = oDoc.getTextSections()
oSection = oSections.getByName(sSection)

'create a text cursor at the section anchor
oText = oSection.getAnchor().getText()
oCursor = oText.createTextCursorByRange(oSection.getAnchor())
oText.insertString(oCursor, More text inside the section, False)
oText.insertControlCharacter(oCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,
 False)


All together:

REM  *  BASIC  *

Option Explicit

Sub Main
Dim oDoc as Object
oDoc = 
StarDesktop.loadComponentFromURL(private:factory/swriter,_default,0,Array())

Dim oText as Object
Dim oCursor as Object
Dim oSection as Object
Dim sSection as String
Dim oSectionText as Object

sSection = Test section
oText = oDoc.getText()
oCursor = oText.createTextCursorByRange(oText.getStart())
oSection = oDoc.createInstance(com.sun.star.text.TextSection)
oSection.setName(sSection)

oText.insertString(oCursor, A new section:, False)
oText.insertControlCharacter(oCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,
 False)
oText.insertTextContent(oCursor, oSection, False)

'after insterting the section, the cursor is on the next paragraph
oCursor.gotoPreviousParagraph(False)
oText.insertString(oCursor, Text inside section, False)

'Access the section (not needed, as we already have a reference)
'Dim oSections as Object
'oSections = oDoc.getTextSections()
'oSection = oSections.getByName(sSection)

'create a text cursor at the section anchor
oText = oSection.getAnchor().getText()
oCursor = oText.createTextCursorByRange(oSection.getAnchor())
oText.insertString(oCursor, More text inside the section, False)
oText.insertControlCharacter(oCursor, 
com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)


End Sub


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpptS4iSDphR.pgp
Description: PGP signature


Re: insert image into calc document

2013-08-07 Thread Ariel Constenla-Haile
Hi,

On Mon, Aug 05, 2013 at 07:21:28PM +0300, K.Misha wrote:
 I have a problem with inserting image into calc document!
 
 I'm doing it this way:
 rColProps-setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(GraphicURL)),
  makeAny(sstring));

If you want the image embedded inside the document, instead of linked,
do not use the GraphicURL property, use Graphic. This property
requires an instance of com.sun.star.graphic.XGraphic. You can get one
using the service com.sun.star.graphic.GraphicProvider

See attached code.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina
#**
#
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  License); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing,
#  software distributed under the License is distributed on an
#  AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.
#
#**

# On *nix can be overridden with
# make PRJ=$OO_SDK_HOME
PRJ=../../../..
SETTINGS=$(PRJ)/settings

include $(SETTINGS)/settings.mk
include $(SETTINGS)/std.mk
include $(SETTINGS)/dk.mk

# Define non-platform/compiler specific settings
APP_NAME=InsertImage
MAINTARGET=$(APP_NAME)_Example

#this should be in odk/settings/std.mk
OUT_DEPLOY=$(OUT)/deploy

OUT_APP_INC=$(OUT_INC)/$(APP_NAME)
OUT_APP_GEN=$(OUT_MISC)/$(APP_NAME)
OUT_APP_OBJ=$(OUT_OBJ)/$(APP_NAME)
OUT_APP_LIB=$(SHAREDLIB_OUT)/$(APP_NAME)
OUT_APP_BIN=$(OUT_BIN)/$(APP_NAME)
OUT_APP_DEPLOY=$(OUT_DEPLOY)/$(APP_NAME)

CXXFILES = main.cxx

OBJFILES = $(patsubst %.cxx,$(OUT_APP_OBJ)/%.$(OBJ_EXT),$(CXXFILES))


ifneq $(DEBUG) 
CC_DEFINES+=-DOSL_DEBUG_LEVEL=3
endif

# Targets
.PHONY: ALL
ALL : \
$(MAINTARGET)

include $(SETTINGS)/stdtarget.mk

$(OUT_APP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(CC) $(CC_FLAGS) $(STL_INCLUDES) $(CC_INCLUDES) -I$(OUT_APP_INC) 
$(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $

$(OUT_APP_BIN)/_$(APP_NAME)$(EXE_EXT) : $(OBJFILES)
-$(MKDIR) $(subst /,$(PS),$(@D))
-$(MKDIR) $(subst /,$(PS),$(OUT_APP_GEN))
ifeq $(OS) WIN
$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_APP_GEN)/$(basename 
$(@F)).map \
$(OBJFILES) $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) 
$(SALLIB) $(STLPORTLIB)
else
$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $(OBJFILES) \
$(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) 
$(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) 
$(SALDYLIB)
ifeq $(OS) MACOSX
$(INSTALL_NAME_URELIBS_BIN)  $@
endif
endif

$(OUT_APP_BIN)/$(APP_NAME)$(EXE_EXT) : $(OUT_APP_BIN)/_$(APP_NAME)$(EXE_EXT)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(COPY) $(subst /,$(PS),$(BIN_DIR)/unoapploader$(EXE_EXT)) $(subst 
/,$(PS),$@)
# workaround for touch problem under Windows with full qualified paths
make -t $@

$(MAINTARGET) : $(OUT_APP_BIN)/$(APP_NAME)$(EXE_EXT)
@echo 

@echo Please use the following command to execute the example!
@echo -
@echo $(MAKE) $(APP_NAME).run
@echo 



$(APP_NAME).run: $(OUT_APP_BIN)/$(APP_NAME)$(EXE_EXT)
cd $(subst /,$(PS),$(OUT_APP_BIN))  $(basename $@)

.PHONY: clean
clean :
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_INC))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_GEN))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_OBJ))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_LIB))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_BIN))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_DEPLOY))
/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * License); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License

Re: insert image ino calc doc

2013-05-10 Thread Ariel Constenla-Haile
On Fri, May 10, 2013 at 02:24:56PM +0300, k.misha wrote:
 Hi!
 
 How I need to initialize XShapes and XShape interfaces?
 
 Reference XShapes  xShapes(?);

The draw page implements this interface. If we had more code
contributors, we could implement multiple inheritance; but that's not
the case, you have to live querying interfaces.

 Reference XShape  xShape(?);

You have to create a shape at the document model's factory:

- the document model implements css.lang.XMultiServiceFactory to
  instantiate different objects, specified by their service name.
  
file:///opt/openoffice.org/basis3.4/sdk/docs/common/ref/com/sun/star/lang/XMultiServiceFactory.html
  Use the service name com.sun.star.drawing.GraphicObjectShape to create
  an instance of a shape that holds an image
  
file:///opt/openoffice.org/basis3.4/sdk/docs/common/ref/com/sun/star/drawing/GraphicObjectShape.html

- XMultiServiceFactory::createInstance wil return a reference to
  a generic css.uno.XInterface; query that reference for the
  css.drawing.XShape interface. Usually you will also need the
  css.beans.XPropertySet interface, to set the shapes properties.



Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgp7xEABQTBEg.pgp
Description: PGP signature


Re: OO SDK

2013-05-08 Thread Ariel Constenla-Haile
Hi k. misha,

On Wed, May 08, 2013 at 02:56:31PM +0300, k.misha wrote:
 Hi!
 
  
 
 How I can insert Image to a calc document using oo sdk 3.4.1?

(Side note: please use descriptive subjects in the mails, something like
Inserting image in Calc)

Each spreadsheet is described here:
http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/Spreadsheet.html

As you can see, it supports ::com::sun::star::drawing::XDrawPageSupplier
Then:

- access a spreadsheet
- get the draw page for this spreadsheet
- create a com.sun.star.drawing.GraphicObjectShape at the document
  factory, set its size, position and graphic URL/css.graphic.XGraphic
- add the shape to the draw page.

Sample code in Basic:

REM  *  BASIC  *

Sub Main
Dim oDoc as Object
oDoc = StarDesktop.loadComponentFromURL(_
private:factory/scalc,_
_default,_
0,_
Array())

Dim oGraphic as Object
Dim oGraphicProvider as Object
oGraphicProvider = CreateUnoService(_
com.sun.star.graphic.GraphicProvider)
Dim aArgs(0) as new com.sun.star.beans.PropertyValue
aArgs(0).Name = URL
aArgs(0).Value = private:graphicrepository/framework/res/backing.png
oGraphic = oGraphicProvider.queryGraphic(aArgs)

If IsNull(oGraphic) OR oGraphic.getType() = 
com.sun.star.graphic.GraphicType.EMPTY Then
Exit Sub
End If
Dim oSize100thMM as Object
oSize100thMM = oGraphic.Size100thMM
If oSize100thMM.Width = 0 OR oSize100thMM.Height = 0 Then
Dim oSizePixel as Object
oSizePixel = oGraphic.SizePixel
If oSizePixel.Width = 0 OR oSizePixel.Height = 0 Then
Exit Sub
End If
Dim oUnitConversion as Object
oUnitConversion = 
oDoc.getCurrentController().getFrame().getContainerWindow()
oSize100thMM = 
oUnitConversion.convertSizeToLogic(oSizePixel,com.sun.star.util.MeasureUnit.MM_100TH)
End If

Dim oSheets as Object
Dim oSheet as Object
oSheets = oDoc.getSheets()
If NOT oSheets.hasElements() Then
'ToDo insert one
Exit Sub
End If
oSheet = oSheets.getByIndex(0)

Dim oDrawPage as Object
oDrawPage = oSheet.getDrawPage()

Dim oGraphicShape as Object
oGraphicShape = 
oDoc.createInstance(com.sun.star.drawing.GraphicObjectShape)

Dim oPoint as new com.sun.star.awt.Point
oPoint.X = 5000
oPoint.Y = 200

With oGraphicShape
.setPosition(oPoint)
.setSize(oSize100thMM)
.Graphic = oGraphic
End With
oDrawPage.add(oGraphicShape)
End Sub


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpgSsRF3rcmC.pgp
Description: PGP signature


Re: EXTERNAL: Re: soffice process still running

2013-05-07 Thread Ariel Constenla-Haile
Hi Raymond,

On Tue, May 07, 2013 at 04:25:57PM +, Steele, Raymond wrote:
 Ariel, 
 
 Thank you for the quick response.   I have narrowed the continued
 process down to a component.  However, the behavior is strange because
 I am not really opening the component in my code. My code opens
 a document using XComponentLoader::loadComponentFromURL(). I set the
 Hidden property to true so the user cannot see it.   The document
 that is open contains Dynamic Data Exchange (DDE) links to another
 closed document. The code then uses XRefreshable interface to refresh
 all the DDE links found in XIndexAccess.  Lastly, I export the
 document using the ODF Spreadsheet / calc8 filter name using
 XStore::storeToURL(). For some reason, this whole process opens
 (hidden) the other document to which the document I am refreshing
 contains DDE links to, even though I do not explicitly open it.
 Strange. 

It sounds logical that if you are refreshing the links, the application
opens documents that are linked; what sounds like a bug is that the
linked document isn't closed after the document containing the link is
closed. This might be worth a bug report.

 In my original query, I did not want to close documents that were not
 opened by my application. (i.e. the user opens it by clicking on the
 OpenOffice desktop icon).   My solution to this point for this issue
 is: if XEnumeration does have more elements, I create an enumeration
 from XEnumerationAccess, loop through it,  get the XComponent
 interface and XModel for each element, and XClose::close() the
 component if the XModel::getURL() matches a specific URL to the
 implicitly opened document. Lastly, if the enumeration does not have
 any more elements, I terminate the desktop. All of this prevents my
 application from inadvertently closing any documents that were not
 opened by my application.  
 
 Do you have any insight to this behavior or recommendations?

May be you can asume that hidden documents were not opened by the user,
and close them:

if the enumeration has elements
if all remaining documents are hidden
close the all

You can know if a document was loaded with Hidden set to true in the
media descriptor by looping through css.frame.XModel.getArgs()

REM  *  BASIC  *
Option Explicit

Sub Main
Dim aArgs(0) as new com.sun.star.beans.PropertyValue
aArgs(0).Name = Hidden
aArgs(0).Value = TRUE

Dim oDoc as Object
oDoc = StarDesktop.loadComponentFromURL(_
private:factory/swriter,_
_default,_
com.sun.star.frame.FrameSearchFlag.ALL,_
aArgs)

Dim aLoadArgs()
aLoadArgs = oDoc.getArgs()
Dim aPropVal
Dim bHidden as Boolean
bHidden = FALSE
For Each aPropVal In aLoadArgs
If aPropVal.Name = Hidden Then
bHidden = aPropVal.Value
Exit For
End If
Next
If bHidden Then
oDoc.close(TRUE)
End If
End Sub


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgplCMGGJhdKz.pgp
Description: PGP signature


Re: UNO API

2013-04-18 Thread Ariel Constenla-Haile
Hi k.misha,

On Thu, Apr 18, 2013 at 11:00:00PM +0300, k.misha wrote:
 Hi!
 
  
 
 I have a problem using this code:
 
  
 
 #define S_CURRENCY 106 // DOESN'T WORK =(
 
 #define S_PERCENT_SHORT 10 // 123%
 
 #define S_PERCENT 11 //123.00%
 
 #define S_DEFAULT 0
 
  
 
  
 
   Reference XSpreadsheet  rSpSheet (rSheet, UNO_QUERY);
 
   Reference XCell  rCell = rSpSheet-getCellByPosition(0, 0);
 
   Reference XPropertySet  xPropSet(rCell, UNO_QUERY);
 
  
 
  
 xPropSet-setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(NumberForma
 t)), makeAny(S_CURRENCY));
 
  
 
  
 
 All other properties(S_PERCENT_SHORT,S_PERCENT,S_DEFAULT) works
 greatly!  Only currency doesn't work =( What I'm doing wrong?

These constants are bad, you should use the number formats API:

http://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Number_Formats
Number formats are defined on the document level. A document displaying
formatted values has a collection of number formats, each with a unique
index key within that document. Identical formats are not necessarily
represented by the same index key in different documents.

Note the not necessarily. This means, you have to use 
http://www.openoffice.org/api/docs/common/ref/com/sun/star/util/XNumberFormats.html
http://www.openoffice.org/api/docs/common/ref/com/sun/star/util/XNumberFormatTypes.html
as explained here
http://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Managing_Number_Formats

See the code attached for an example.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina
#**
#
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  License); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing,
#  software distributed under the License is distributed on an
#  AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.
#
#**

# On *nix can be overridden with
# make PRJ=$OO_SDK_HOME
PRJ=../../../..
SETTINGS=$(PRJ)/settings

include $(SETTINGS)/settings.mk
include $(SETTINGS)/std.mk
include $(SETTINGS)/dk.mk

# Define non-platform/compiler specific settings
APP_NAME=NumberFormats
MAINTARGET=$(APP_NAME)_Example

#this should be in odk/settings/std.mk
OUT_DEPLOY=$(OUT)/deploy

OUT_APP_INC=$(OUT_INC)/$(APP_NAME)
OUT_APP_GEN=$(OUT_MISC)/$(APP_NAME)
OUT_APP_OBJ=$(OUT_OBJ)/$(APP_NAME)
OUT_APP_LIB=$(SHAREDLIB_OUT)/$(APP_NAME)
OUT_APP_BIN=$(OUT_BIN)/$(APP_NAME)
OUT_APP_DEPLOY=$(OUT_DEPLOY)/$(APP_NAME)

CXXFILES = main.cxx

OBJFILES = $(patsubst %.cxx,$(OUT_APP_OBJ)/%.$(OBJ_EXT),$(CXXFILES))


ifneq $(DEBUG) 
CC_DEFINES+=-DOSL_DEBUG_LEVEL=3
endif

# Targets
.PHONY: ALL
ALL : \
$(MAINTARGET)

include $(SETTINGS)/stdtarget.mk

$(OUT_APP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(CC) $(CC_FLAGS) $(STL_INCLUDES) $(CC_INCLUDES) -I$(OUT_APP_INC) 
$(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $

$(OUT_APP_BIN)/_$(APP_NAME)$(EXE_EXT) : $(OBJFILES)
-$(MKDIR) $(subst /,$(PS),$(@D))
-$(MKDIR) $(subst /,$(PS),$(OUT_APP_GEN))
ifeq $(OS) WIN
$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_APP_GEN)/$(basename 
$(@F)).map \
$(OBJFILES) $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) 
$(SALLIB) $(STLPORTLIB)
else
$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $(OBJFILES) \
$(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) 
$(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) 
$(SALDYLIB)
ifeq $(OS) MACOSX
$(INSTALL_NAME_URELIBS_BIN)  $@
endif
endif

$(OUT_APP_BIN)/$(APP_NAME)$(EXE_EXT) : $(OUT_APP_BIN)/_$(APP_NAME)$(EXE_EXT)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(COPY) $(subst /,$(PS),$(BIN_DIR)/unoapploader$(EXE_EXT)) $(subst 
/,$(PS),$@)
# workaround for touch problem under Windows with full qualified paths
make -t $@

$(MAINTARGET) : $(OUT_APP_BIN)/$(APP_NAME)$(EXE_EXT)
@echo 

@echo Please use the following command to execute the example!
@echo -
@echo $(MAKE) $(APP_NAME).run
@echo 



$(APP_NAME).run: $(OUT_APP_BIN)/$(APP_NAME)$(EXE_EXT)
cd $(subst /,$(PS),$(OUT_APP_BIN))  $(basename $@)

.PHONY: clean
clean

Re: uno api problem

2013-04-07 Thread Ariel Constenla-Haile
On Sun, Apr 07, 2013 at 04:06:19PM +0300, k.misha wrote:
 I already fixed this problem this way:
[...]

not portable at all. You may find useful the C++ UNO binding reference:
http://www.openoffice.org/api/docs/cpp/ref/names/index.html


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpOu55N5lgMb.pgp
Description: PGP signature


Re: uno api problem

2013-04-06 Thread Ariel Constenla-Haile
Hi k. misha,

On Thu, Apr 04, 2013 at 11:20:04AM +0300, k.misha wrote:
 Hi! 
 
  
 
 I have some problems using UNO API! I have this example:
 
  
 
 Int x = 0;
 
 Int y = 1;
 
 Char * fontName = Corbel;

Defined this way, fontName is a pointer

 Reference XSpreadsheet  rSpSheet (rSheet, UNO_QUERY);
 
 Reference XCell  rCell = rSpSheet-getCellByPosition(x, y);
 
 Reference XPropertySet  xPropSet(rCell, UNO_QUERY);
 
  
 
 OUString sstring = OUString(RTL_CONSTASCII_USTRINGPARAM(fontName));

The macro RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) expands to

constAsciiStr, ((sal_Int32)(sizeof(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US

so that

sizeof( pointer ) - 1

is 4 - 1 (in 32 bit arch.) or 8 - 1 (in 64 bit arch.)

 xPropSet-setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(CharFontNam
 e)), makeAny(sstring));
 
  
 
 But when I look into a cacl document, there is wrong value in cell(0,1). I's
 Cor. But must be Corbel.

Your OS is 32 bits: (sizeof( pointer ) - 1) is 3, thus Cor.

 
 Can you help me and show where I'm wrong?

Define the string literal as an array:

const char fontName[] = Corbel;

or simply avoid all these temporal variables:

xPropSet-setPropertyValue(
OUString(RTL_CONSTASCII_USTRINGPARAM(CharFontName)),
makeAny(OUString(RTL_CONSTASCII_USTRINGPARAM(Corbel;



Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgp8F0gaTmsIz.pgp
Description: PGP signature


Re: example of Frame with awt uno

2013-03-06 Thread Ariel Constenla-Haile
Hi,

On Tue, Mar 05, 2013 at 09:13:38PM -0600, Galileo Teco Juárez wrote:
 could give me a simple example of code
 a frame on .. with menus
 
 check
 http://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/XMenu.html #
 insertItem
 
 I find information: nItemID, nItemStyle,
 I do not understand why

A simple example depends on what you are trying to do. Are you trying to
modify the menu bar of on of the application? Are you trying to create
a window with a menu bar? Are you trying to create a button that when
pressed displays a popup menu? (I had a simple example for the later,
but I can't find it right know).


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpBkuJquW44p.pgp
Description: PGP signature


Re: example of Frame with awt uno

2013-03-06 Thread Ariel Constenla-Haile
On Wed, Mar 06, 2013 at 05:41:29PM -0300, Ariel Constenla-Haile wrote:
 Hi,
 
 On Tue, Mar 05, 2013 at 09:13:38PM -0600, Galileo Teco Juárez wrote:
  could give me a simple example of code
  a frame on .. with menus
  
  check
  http://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/XMenu.html #
  insertItem
  
  I find information: nItemID, nItemStyle,
  I do not understand why
 
 A simple example depends on what you are trying to do. Are you trying to
 modify the menu bar of on of the application? Are you trying to create
 a window with a menu bar? Are you trying to create a button that when
 pressed displays a popup menu? (I had a simple example for the later,
 but I can't find it right know).

I didn't find the example with the menu button, but found this one with
a context menu:
http://people.apache.org/~arielch/api/DIALOGO_EVENTOS.odt
(It's in Spanish)


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgp6FUtZ1iS6d.pgp
Description: PGP signature


Re: [MAC] Launching OO from another application using OSL_executeprocess

2013-02-21 Thread Ariel Constenla-Haile
Hi Anandha,

On Thu, Feb 21, 2013 at 02:28:19PM +0530, Anandha Kannan wrote:
 Hi Ariel,
 
 
 
 Thanks for the response. This helped me to correct few of
 my mistakes I had done.
 
 having modified my code, now after calling osl_executeprocess, my
 application tries to launch OO and executeProcess returns E_None, but OO
 quits and with,
 
 The application cannot be started.The component manager is not available.
 
 Some pages says, possible corrupt of services.rdb in OO installation. But
 am not sure what is causing this issue.
 
That error is produced because the application cannot bootstrap the
initial component context (similar to an external application when it
bootstraps the initial component context with the URE types); the error
message is too generic as to get an idea where the problem is (a broken
ini/rc file, broken registry database, essential libraries that cannot
be loaded - bootstrap.uno.so etc., ...).

If you are able to launch OpenOffice from the terminal, you should be
able to use osl_executeProcess(), this seems something logical. How are
you running the application that uses osl_executeProcess()? Which is the
current directory? Are you running as root or as normal user? Note that
in the example, both user+rights and working directory are NULL, which
will default to osl_getCurrentSecurity() and osl_getProcessWorkingDir(),
all of which is fine if you are running the application as a normal
user.

And finally, does the example [1] work? 
[1] 
http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/ProcessTest/


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpT4dHphsFEm.pgp
Description: PGP signature


Re: EXTERNAL: Re: soffice process still running

2013-02-01 Thread Ariel Constenla-Haile
On Thu, Jan 31, 2013 at 05:48:11PM +, Steele, Raymond wrote:
 Thanks for the feedback. 
 
 I implemented the following, but the method kills off any other
 instance of soffice that is running. 
 
 Desktop_obj
 = component_factory.createInstanceWithContext(com.sun.star.frame.Desktop,
 context); XDesktop desktop = UnoRuntime.queryInterface(XDesktop.class,
 desktop_obj); desktop.terminate();
 
 Any way that I can close the instance without killing off other
 soffice instances?

What do you mean by instance? There is only one instance of
soffice.bin per application using the same user installation directory.

If you mean that it closes all other documents, then you can check if
this document is the last opened document, and if true, terminate the
desktop:
http://www.openoffice.org/api/docs/common/ref/com/sun/star/frame/XDesktop.html#getComponents

XComponentLoader xComponentLoader = UnoRuntime.queryInterface(
XComponentLoader.class,
xContext.getServiceManager().createInstanceWithContext(
com.sun.star.frame.Desktop, xContext));
XTextDocument xTextDocument = UnoRuntime.queryInterface(
 XTextDocument.class,
 xComponentLoader.loadComponentFromURL(
private:factory/swriter,
_default,
FrameSearchFlag.ALL,
new PropertyValue[]{}));
xTextDocument.getText().setString(Dummy text.);

XCloseable xCloseable = UnoRuntime.queryInterface(
XCloseable.class, xTextDocument);
xCloseable.close(true);

XDesktop xDesktop = UnoRuntime.queryInterface(
XDesktop.class, xComponentLoader);
XEnumerationAccess xEnumerationAccess = xDesktop.getComponents();

if (!xEnumerationAccess.hasElements()) {
xDesktop.terminate();
}


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpnA9g8bsyQb.pgp
Description: PGP signature


Re: Regarding MSVCR80.dll

2013-01-31 Thread Ariel Constenla-Haile
On Fri, Jan 25, 2013 at 01:14:45PM +, Shukla, Mangesh wrote:
Hi,
I am using OpenOffice3.4.1 sdk to build an external dll (it does not add
any new types, and is based on the documentLoader example) , which
interacts with OpenOffice. I could build the dll using Visual studio 2012
and use it as well. However since the dll is supposed to be cross
platform, I moved the project to a Makefile. I have written a Makefile,
which creates the .dll, and .lib. However when I use it in a test
application, the application complains that the MSVCR80.dll is missing
from the computer. I have the following set for the CPP compiler
 
OO_SDK_CPP_HOME=C:\apps\MVS8\VC\bin
 
 
 
Changing the CPP home to use the Visual studio 2012 compiler, causes
compilation error.
 
I have all the versions from VS2005 to VS2012 installed on my PC.
 
I implemented a test application using VS2012 as well as VS2008, but both
applications complain about the MSVCR80.dll
 
At the same time I am able to use the DLL built using the VS2012 project,
and everything works fine
 
Please advise on what is the best way of compiling using the Makefile and
using the dll. Let me know if you need anymore clarification.

I only build with the VS2008 and it works fine. If you are distributing
your binaries, you'll have to include the redistributable. And if you
are planning to build your application for all supported platforms, I'd
suggest you use the SDK build environment (it will save you a lot of
time, the Cmake approach suggested on other mail will require that you
create a Cmake module to find the OpenOffice/SDK installation).

As a general suggestion, don't start with an IDE project, simply try to
get a working Makefile with the SDK environment and make sure it builds
fine in all supported platforms. It would also be easier to provide
advice if you can upload the source code somewhere (IIUC you are simply
playing with an SDK example, so there would no problem in showing the
code).


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpVQFfPH4Dy0.pgp
Description: PGP signature


Re: Prevent closing with InstanceLocker

2012-12-29 Thread Ariel Constenla-Haile
On Thu, Dec 27, 2012 at 04:50:13PM +0100, Bernard Marcelly wrote:
 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

Useful too a quick search in bugzilla shows:
https://issues.apache.org/ooo/buglist.cgi?quicksearch=InstanceLocker

https://issues.apache.org/ooo/show_bug.cgi?id=118965
https://issues.apache.org/ooo/show_bug.cgi?id=118966
https://issues.apache.org/ooo/show_bug.cgi?id=118896

Looks like this service didn't get enough qa and it's really broken.


Regard
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpu4xb0cs3Ok.pgp
Description: PGP signature