OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Guide for develop OpenOffice apps with VC++ .net
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
LarsB
OOo Advocate
OOo Advocate


Joined: 31 Aug 2005
Posts: 445
Location: Hamburg, Germany

PostPosted: Wed Sep 14, 2005 3:24 am    Post subject: Guide for develop OpenOffice apps with VC++ .net Reply with quote

Hi,

after searching the www for a little tutorial for OpenOffice
development with VC++ .net without success. Here are
the steps you have to do to develop OpenOffice apps under
VC++ .net

Thanks @Cosmin for part 4 Smile

OpenOffice with Visual Studio .NET Steps:


1. Download and install OpenOffice.
2. Download and install OpenOffice SDK
3. Create a new folder inludecpp in <oo_sdk_path>
3. Open Dos console change directory to <oo_sdk_path>\windows\bin
3.1 run cppumaker with followig paramerers
cppumaker -BUCR -O <oo_sdk_path>\includecpp <office_programm_dir>\types.rdb
(Attention: If you recieve a init error, copy types.rdb into the <oo_sdk_path>\windows\bin folder!)
After that all hpp and hdl files should be created in <oo_sdk_path>\includecpp
4. Open Visual Studio and create a new Win32 Console Application.
Applay the following changes to your project.
4.1. Tools ->Options->Projects->VC++ Directories -> Include Files
Add \include directory and <oo_sdk_path>\includecpp
4.2. Tools ->Options->Projects->VC++ Directories -> Library files
Add <oo_sdk_path>\windows\lib directory
4.3. Tools ->Options->Projects->VC++ Directories -> Executable files
Add <office_programm_dir>\program directory (location where you installed the version of the OpenOffice)
4.4 Open the Project Settings
4.4.1 Change Configuration to all All Configuartions (the combobox in the left corner of the window)
4.4.2 Add the additional libaries
Properties->Linker->ComandLine in the Additional Options tab the library files
isal.lib icppu.lib icppuhelper.lib isal.lib isalhelper.lib ireg.lib irmcxt.lib stlport_vc71.lib
5. (example) Add the DocumentLoader.cxx from the cpp examples of the sdk
and compile. The source should compile without errors.

INFO : If you got the following error have a look at the solution 2 postings above!
Up to now, with the steps above i got the following error, when i run the DocumentLoader example.
The error is thrown, when the prog execution reach the following line:

Code:
 Reference< XSimpleRegistry > xSimpleRegistry(
        ::cppu::createSimpleRegistry() );


Code:
Error:
Window title:  Microsoft Visual C++ Debug Libary
Headline:  Debug Error
Msg: This application has requested the Runtime to terminate it in an usual way.
Please contact the support team for more information.


If somebody has experience with this kind of error it will be nice if he could
post a solution. So that here is a complete little guide for OpenOffice with VC++ .NET

Regards
Lars


Last edited by LarsB on Wed Sep 14, 2005 9:05 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
cosmyn11
General User
General User


Joined: 26 Apr 2005
Posts: 21

PostPosted: Wed Sep 14, 2005 3:56 am    Post subject: Guide for develop OpenOffice apps with VC++ .net Reply with quote

Hi Lars
I sended you an private message with the DocumentLoader sample modified which should works, but I think you don't receive yet ,because the message is in the Outbox and I don't know when you receive the message.
If you wanted send me your email address (to the private message)and I think you will receive fast the sample by mail.

Regards Cosmin
Back to top
View user's profile Send private message
LarsB
OOo Advocate
OOo Advocate


Joined: 31 Aug 2005
Posts: 445
Location: Hamburg, Germany

PostPosted: Wed Sep 14, 2005 8:55 am    Post subject: Solution Reply with quote

Hi,

i found the solution for the debug error messages. The app try to
load the rdb files types, services, .. from the debug folder instead
of the openoffice programm folder. After copy all rdb files from
openoffice programm folder into the debug folder.
The app runs
without an error!
Did somebody know why he search for this files in the debug
instead of the programm folder.

regards
lars
Back to top
View user's profile Send private message Visit poster's website
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Sat Sep 17, 2005 1:25 am    Post subject: Reply with quote

I have added this tutorial in my document.
Thank you
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
_francois_
General User
General User


Joined: 24 Nov 2005
Posts: 35

PostPosted: Tue Dec 27, 2005 5:46 am    Post subject: Reply with quote

I followed all the step and encountered two problems

* first in point 4.4.2
But there I guess it's because the procedure was meant for SDK 2 and I'm using SDK 1.1
The stlport_vc71.lib which you must include is distributed with the SDK 2 in the SDK 1.1 stlport_vc7.lib
you just need to include the stlport_vc7.lib instead of stlport_vc71.lib

* second problem after succesfuly compiling the DocumentLoader in Visual Studio I was getting the following error

Error:
Window title: Microsoft Visual C++ Debug Libary
Headline: Debug Error
Msg: This application has requested the Runtime to terminate it in an usual way.
Please contact the support team for more information.

after going on debug in the visual studio I found the following line was responsible
xSimpleRegistry->open( OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentLoader.rdb") ), sal_True, sal_False );

The DocumentLoader.rdb was missing ... I noticed that if I compiled the DocumentLoader exemples from command line with the makefile provided with the exemple a DocumentLoader.rdb was generated. I had a look at the Makefile I isolated the lines which seemed to generate the DocumentLoader.rdb into my Debug folder (or wherever your set your DocumentLoader.exe to be put by Visual Studio) in my Visual Studio project...

regmerge c:\travail\DocumentLoader\debug\DocumentLoader.rdb / "C:\ooo\office\program\types.rdb"

regcomp -register -r c:\travail\DocumentLoader\debug\DocumentLoader.rdb -c connector.uno.dll
regcomp -register -r c:\travail\DocumentLoader\debug\DocumentLoader.rdb -c remotebridge.uno.dll
regcomp -register -r c:\travail\DocumentLoader\debug\DocumentLoader.rdb -c bridgefac.uno.dll
regcomp -register -r c:\travail\DocumentLoader\debug\DocumentLoader.rdb -c uuresolver.uno.dll

I launched all the above lines in the prompt shell and it worked I had my DocumentLoader.rdb in my Debug folder

I launched my exe file and it worked, great...

Now I guess I still need to figure out which *.uno.dll needs to be included for which functions used in the programm, but still it's a good start.
If anyone has any information about that (It may actualy be documented somewhere) don't hesitate)
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Tue Dec 27, 2005 8:48 am    Post subject: Reply with quote

I am surprised you don't need cppuhelper dll to run. I can be wrong because my experience under Windows is not great enough.
In any case the problem you will face now is not to know what the library is needed (almost every time all) but to learn UNO API.
Have a look in my document (in my signature). The English is not great but I think it is understandable.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
LarsB
OOo Advocate
OOo Advocate


Joined: 31 Aug 2005
Posts: 445
Location: Hamburg, Germany

PostPosted: Tue Dec 27, 2005 9:15 am    Post subject: I think it's Reply with quote

Hi,

thank you for following my suggestion to post here what you find out.
I think until, no one is running into trouble with this solution they should
use this, if they found no other way to make their apps run Wink

Cheers
LarsB
_________________
AODC - A free OpenDocument Converter
AODL - An independent OpenDocument Library C#
EmbeddedOpenOffice .net UserControl C#
EmbeddedOpenOffice Visual Studio .net Add In

http://www.OpenDocument4all.com/
Back to top
View user's profile Send private message Visit poster's website
_francois_
General User
General User


Joined: 24 Nov 2005
Posts: 35

PostPosted: Mon Jan 02, 2006 8:51 am    Post subject: Reply with quote

because the customer was willing to switch to OpenOffice 2
I uninstalled OpenOffice 1 and the SDK 1.1
I installed OO 2.0.1 and the SDK 2.0 RC2 (on a Win XP Pro system)
I followed the procedures...

I managed to compile the DocumentLoader from the Shell it did run smoothly...
When I tried to compile it from Visual Studio .net 2003 I got an error in the types.h here

#if SAL_TYPES_SIZEOFSHORT == 2
typedef signed short sal_Int16;
typedef unsigned short sal_uInt16;
#else
#error "Could not find 16-bit type, add support for your architecture"
#endif


accoring to this
#if defined UNX
#include <sal/typesizes.h>
#elif defined WNT
/* FIXME: autogeneration of type sizes on Win32/Win64? */
#define SAL_TYPES_ALIGNMENT2 1
#define SAL_TYPES_ALIGNMENT4 1
#define SAL_TYPES_ALIGNMENT8 1
#define SAL_TYPES_SIZEOFSHORT 2
#define SAL_TYPES_SIZEOFINT 4
#define SAL_TYPES_SIZEOFLONG 4
#define SAL_TYPES_SIZEOFLONGLONG 8
#define SAL_TYPES_SIZEOFPOINTER 4
#endif


that means either UNX is defined or WNT is not defined

In my DocumentLoader.cxx if I add #define WNT
the programm will compile and run normaly...
Does someone have a clue about what I'm doing wrong ?

Edit:
I cut the remaining part because I just found out that I must have done something wrong with my .rdb file... I regenerated it and it worked...
Back to top
View user's profile Send private message
LarsB
OOo Advocate
OOo Advocate


Joined: 31 Aug 2005
Posts: 445
Location: Hamburg, Germany

PostPosted: Tue Jan 03, 2006 8:18 am    Post subject: I know this Reply with quote

Hi,

I know this errors. They only appear since the SDK 2.0, but also don't know
why this happens. Anyway this errors, doesn't have to do with a broken
SDK installation. It would be nice, if you post a solution if you found one Wink

Cheers
LarsB
_________________
AODC - A free OpenDocument Converter
AODL - An independent OpenDocument Library C#
EmbeddedOpenOffice .net UserControl C#
EmbeddedOpenOffice Visual Studio .net Add In

http://www.OpenDocument4all.com/
Back to top
View user's profile Send private message Visit poster's website
new.learner
General User
General User


Joined: 05 Apr 2006
Posts: 8

PostPosted: Thu Apr 06, 2006 5:27 am    Post subject: Compile problem with SDK 2.0.2 Reply with quote

I have followed all that has been discussed in this thread but I am facing compile problems with SDK 2.0.2.

I have tried working with the Visual Studio IDE and even compiled from the commandline. IN Both cases i get the following error

d:\OpenOffice.org_2.0_SDK\include\com\sun\star\uno\Any.hxx(215): error C2558: class 'com::sun::star::uno::Any' : no copy constructor available or copy constructor is declared 'explicit'

I havent found any solution as yet.
Back to top
View user's profile Send private message
candyania
General User
General User


Joined: 03 Sep 2006
Posts: 8

PostPosted: Sun Sep 03, 2006 11:05 pm    Post subject: There is something wrong~help me~ Reply with quote

Cannot open include file: 'com/sun/star/uno/Reference.h': No such file or directory

I have set the enviroment as you said, but there is an error message as above, how can I solve this problem?
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Mon Sep 04, 2006 8:41 am    Post subject: Reply with quote

This file is in the SDK. But your compiler has to find it : you have to put an option which say where to look for include files.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
candyania
General User
General User


Joined: 03 Sep 2006
Posts: 8

PostPosted: Tue Sep 05, 2006 5:50 pm    Post subject: A new error occurs~ Reply with quote

Thank you for all of your help, I have resovled the problem before. But I have a new problem in my program.
I am running the example program with the SDK, the program is used to connect the office. I have remerge the services.rdb and types.rdb to get the DownLoader.rdb for the
program, the error "The application request a RunTime terminate in a usual way..."occurs, so I used the methods "regcomp -register..."to resovle the error. All of the 4 dll files have been registered successfully and when I run the file connect program, a new error occurs:
Error: Couldn't instantiate com.sun.star.bridge.UnoUrlResolver service~
I don't understand what this error mean and how to resolve it~, I think maybe it occurs because the server manager cannot be get correctly, but why? I have test the port which is specified in the program:
"rInstance = rResolver->resolve( OUString::createFromAscii(
"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" ) );
"
but the 2083 port seems closed, and I try to use some open port which I find by using "netstat", but the error still there.
If anyone knows how to resolve the problem, please give me some clues... Thank you!
Back to top
View user's profile Send private message
candyania
General User
General User


Joined: 03 Sep 2006
Posts: 8

PostPosted: Tue Sep 05, 2006 9:05 pm    Post subject: A new error occurs~ Reply with quote

Thank you for all of your help, I have resovled the problem before. But I have a new problem in my program.
I am running the example program with the SDK, the program is used to connect the office. I have remerge the services.rdb and types.rdb to get the DownLoader.rdb for the
program, the error "The application request a RunTime terminate in a usual way..."occurs, so I used the methods "regcomp -register..."to resovle the error. All of the 4 dll files have been registered successfully and when I run the file connect program, a new error occurs:
Error: Couldn't instantiate com.sun.star.bridge.UnoUrlResolver service~
I don't understand what this error mean and how to resolve it~, I think maybe it occurs because the server manager cannot be get correctly, but why? I have test the port which is specified in the program:
"rInstance = rResolver->resolve( OUString::createFromAscii(
"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" ) );
"
but the 2083 port seems closed, and I try to use some open port which I find by using "netstat", but the error still there.
If anyone knows how to resolve the problem, please give me some clues... Thank you!
Back to top
View user's profile Send private message
skalman
Newbie
Newbie


Joined: 27 Nov 2006
Posts: 1

PostPosted: Mon Nov 27, 2006 2:53 am    Post subject: Solution to the port problem Reply with quote

Hello!

A possible solution to that problem could be to start openoffice like this:

soffice.exe -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"

(This is a single line with spaces before the arguments -headless and -accept)

Idon't know if the -accept part is just one option or many.
The port can be change to any suitable
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group