Ask Your Question
0

argv rtl_getAppCommandArg [solved]

asked 2019-10-04 15:35:50 +0100

ArcadianSky gravatar image

updated 2019-10-04 17:43:19 +0100

I'm very sorry, but I don't understand, trying to write app for LibreOffice made using SDK.

Im trying to get argv from main command arguments I send string in command argument "file:///C:\Users\USER\CProjects\test\test2.docx"

And by the examples i have to get path arg sAbsoluteDocUrl with commands:

    OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl, sArgDocUrl;
    rtl_getAppCommandArg(0, &sArgDocUrl.pData);

    osl_getProcessWorkingDir(&sWorkingDir.pData);
    osl::FileBase::getFileURLFromSystemPath(sArgDocUrl, sDocPathUrl);
    osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);

and then make Reference< XComponent > xMainComponent = xDesktop2->loadComponentFromURL( sAbsoluteDocUrl, OUString("_blank"), 0, loadProps);

but sAbsoluteDocUrl don't have url finally

but if i put

    rtl::OUString path = "file:///C:\\Users\\USER\\CProjects\\test\\test2.docx";

and then run

    Reference< XComponent > xMainComponent = xDesktop2->loadComponentFromURL(
        path , OUString("_blank"),
        0, loadProps);

the document would run succesfully.

How to get args correctly? Is it realy nessesary run something like

    -env:URE_MORE_TYPES=\"file:///.../program/offapi.rdb\" \"file:///e:/temp/test.odt\"         \"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager\"\n"

as it described in DocumentLoader.cxx https://api.libreoffice.org/examples/...

edit retag flag offensive close merge delete

Comments

Note that using \ is illegal in URIs...

Mike Kaganski gravatar imageMike Kaganski ( 2019-10-04 15:40:12 +0100 )edit

I tried a lot of variants and using // not helped

ArcadianSky gravatar imageArcadianSky ( 2019-10-04 15:44:08 +0100 )edit

but sAbsoluteDocUrl don't have url finally

So what does it contain then?

And sArgDocUrl actually contains the argument passed?

erAck gravatar imageerAck ( 2019-10-04 15:49:53 +0100 )edit

getFileURLFromSystemPath doesn't work with URIs, it accepts system path only - i.e., it may take C:\path\file, but not file://C:/path/file. Do you check the result? You likely need to have a fallback to simply pass the initial string to the loadComponentFromURL in case getFileURLFromSystemPath failed because of invalid argument

Mike Kaganski gravatar imageMike Kaganski ( 2019-10-04 15:53:46 +0100 )edit

printf argv[1]=C://path//to//file printf sAbsoluteDocUrl returns smile printf sAbsoluteDocUrl.pData returns smile cout sAbsoluteDocUrl.pData returns 1000007FECCDCBCC8

caught UNO exception: Unsupported URL <>:from LoadEnv::initializeLoading

C://path/to/file - similar

C:/path/to/file - done!!!! thanks!!!!

ArcadianSky gravatar imageArcadianSky ( 2019-10-04 17:42:29 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-10-04 17:42:46 +0100

ArcadianSky gravatar image

updated 2019-10-04 17:44:21 +0100

printf argv[1]=C://path//to//file

printf sAbsoluteDocUrl returns smile

printf sAbsoluteDocUrl.pData returns smile

cout sAbsoluteDocUrl.pData returns 1000007FECCDCBCC8

caught UNO exception: Unsupported URL <>:from LoadEnv::initializeLoading

C://path/to/file - similar

C:/path/to/file - done!!!! thanks!!!!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-10-04 15:35:50 +0100

Seen: 14 times

Last updated: Oct 04