To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=47495
Issue #:|47495
Summary:|Problems saving first sheet from SXC to TXT
Component:|Spreadsheet
Version:|OOo 2.0 Beta
Platform:|PC
URL:|
OS/Version:|Windows XP
Status:|UNCONFIRMED
Status whiteboard:|
Keywords:|
Resolution:|
Issue type:|DEFECT
Priority:|P5
Subcomponent:|save-export
Assigned to:|spreadsheet
Reported by:|ceekay
------- Additional comments from [EMAIL PROTECTED] Fri Apr 15 00:28:50 -0700
2005 -------
Hi,
I wrote a program that works in basic but doesn't work in C++.
I am quite sure I used the right methods.
The purpose is to set the first sheet as the active sheet and then save it as
TXT
Code in Basic :
Code:
Sub Main
Dim doc, sheet
doc = ThisComponent
sheet = doc.getSheets.getByIndex(0)
doc.currentcontroller.setActiveSheet(sheet)
cURL = ConvertToURL( "d:\test\x.txt")
doc.storeToURL(cURL, Array( MakePropertyValue( "FilterName", "Text - txt - csv
(StarCalc)" ) ) )
End Sub
Function MakePropertyValue( Optional cName As String, Optional uValue ) As
com.sun.star.beans.PropertyValue
oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
The same in c++ should be :
Code:
/* DOCUMENT SHOULD BE OPEN ... */
/* GET CURRENTCONTROLLER... */
VariantInit(&result);
AutoWrap (DISPATCH_METHOD, &result, document, L"getCurrentController",0);
octrl = result.pdispVal;
VariantInit(¶m1);
param1.vt = VT_INT;
param1.intVal = 0;
// I also tried this with long value
VariantInit(&result);
AutoWrap (DISPATCH_METHOD, &result, document, L"getSheets", 0);
osheets = result.pdispVal;
VariantInit(&result);
AutoWrap (DISPATCH_METHOD, &result, osheets, L"getByIndex", 1, param1);
osheet = result.pdispVal;
VariantInit(¶m1);
param1.vt = VT_DISPATCH;
param1.pdispVal = osheet;
AutoWrap (DISPATCH_METHOD, NULL, octrl, L"setActiveSheet", 1, param1);
/* GET PROPERTYVALUE ...*/
VariantInit(¶m1);
VariantInit(&result);
param1.vt = VT_BSTR;
param1.bstrVal = ::SysAllocString(L"com.sun.star.beans.PropertyValue");
AutoWrap (DISPATCH_METHOD, &result, service, L"Bridge_GetStruct", 1,
param1);
saveValue = result.pdispVal;
/* SET PROPERTYVALUE.NAME TO "FILTERNAME"... */
VariantInit (¶m1);
param1.vt = VT_BSTR;
param1.bstrVal = SysAllocString (L"FilterName");
AutoWrap (DISPATCH_PROPERTYPUT, NULL, saveValue, L"Name", 1, param1);
/* SET PROPERTYVALUE.VALUE TO "Text"...*/
VariantInit (¶m1);
param1.vt = VT_BSTR;
param1.bstrVal = SysAllocString (L"Text - txt - csv (StarCalc)");
AutoWrap (DISPATCH_PROPERTYPUT, NULL,saveValue,L"Value", 1,param1);
/* WRAP UP PROPERTYVALUES... */
idx2 = 0;
saveVals = SafeArrayCreateVector (VT_DISPATCH, 0,1);
SafeArrayPutElement (saveVals, &idx2, saveValue);
/* SET ALL PARAMETERS TO SAVE DOCUMENT... */
VARIANT savepms[2];
VariantInit(&savepms[1]);
savepms[1].vt = VT_ARRAY | VT_DISPATCH;
savepms[1].parray = saveVals;
VariantInit(&savepms[0]);
savepms[0].vt = VT_BSTR;
savepms[0].bstrVal = out2;
// out2 is the filepath for the output in linux-style
file:///c:/test.txt
/* SAVE FILE ... */
hr = AutoWrap (DISPATCH_METHOD, NULL, document, L"storeToURL", 2,
savepms[1], savepms[0]);
if(FAILED(hr)) printf("FAILED to save document");
The output is an empty txt file, the strange this is if I set another sheet as
active than it works fine
---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]