| View previous topic :: View next topic |
| Author |
Message |
oeurun General User

Joined: 23 Nov 2005 Posts: 8
|
Posted: Mon Feb 27, 2006 5:09 am Post subject: Losing data while saving odt file |
|
|
I develop a delpi program that write to open office writer. I can edit text, draw shape, insert table but i have a problem with saving file.
After save the odt file, i open the saved file but not it is true. border styles and shapes are lost.
is there anybody who can help me? |
|
| Back to top |
|
 |
oeurun General User

Joined: 23 Nov 2005 Posts: 8
|
Posted: Mon Feb 27, 2006 7:02 am Post subject: Adding previous message |
|
|
My code is below.
Operating System : XP + SP 2
OOffice Version 2.0
My document appear fine but after close and open saved file some data is lost.
WHY?
--------------------------------------------------------------
procedure TForm6.Button1Click(Sender: TObject);
var
fDosyaAdi, strHeader,s: string;
strContent: array[1..5] of string;
fOOffice, fDesktop, wProperties, Struct, fDocument: variant;
Cursor, text, oTable, Struct2: variant;
PageStyles, PageNumber, PageCount, stdPage, FooterCursor, HeaderCursor, VariantArr: variant;
StructShapeSize, oshape, ocols, ocol, ocell, oCursor, otext: variant;
StructLineSpacing, StructShapePosition, oTblColSeps, sCellnames, sCellName: variant;
pageWidth, rightMargin, adet, i, iCellcounter: integer;
begin
fDosyaAdi := 'c:\deneme.odt';
fOOffice := CreateOleObject('com.sun.star.ServiceManager');
fDesktop := fOOffice.createInstance('com.sun.star.frame.Desktop');
wProperties := VarArrayCreate([0, 0], varVariant);
// wProperties[0] := PropertyYaz('Hidden', false);
Struct := fOOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
Struct.Name := 'Hidden';
Struct.Value := false;
wProperties[0] := Struct;
// fDocument := fDesktop.loadComponentFromURL('file:///' + StringReplace(fDosyaAdi, '\', '/', [rfIgnoreCase]), '_blank', 0, wProperties);
fDocument := fDesktop.LoadComponentFromUrl('private:factory/swriter', '_blank', 0, wProperties);
PageStyles := fDocument.StyleFamilies.getByName('PageStyles');
StdPage := PageStyles.getByName('Varsayılan'); //('Default');
//---------------------------- SAYFANIN ÇERÇEVESİ ----------------------------
Struct2 := fOOffice.Bridge_GetStruct('com.sun.star.table.BorderLine');
Struct2.Color := 129589;
Struct2.InnerLineWidth := 0;
Struct2.OuterLineWidth := 1;
Struct2.LineDistance := 100;
StdPage.SetPropertyValue('TopBorder', Struct2);
StdPage.SetPropertyValue('LeftBorder', Struct2);
StdPage.SetPropertyValue('RightBorder', Struct2);
StdPage.SetPropertyValue('BottomBorder', Struct2);
//-------------------------------- INSERT TEXT ----------------------------
strContent[1] := 'The hierarchy is separated for Basic source code and dialogs, ';
strContent[2] := 'that is, a Basic library container';
strContent[3] := ' only contains Basic libraries containing Basic source code ';
strContent[4] := 'modules and a dialog library container only contains dialog ';
strContent[5] := 'libraries containing dialogs.';
text := fDocument.Gettext;
Cursor := text.CreateTextCursor;
StructLineSpacing := fOOffice.Bridge_GetStruct('com.sun.star.style.LineSpacing');
StructLineSpacing.Height := 1000;
StructLineSpacing.Mode := 1;
Cursor.SetPropertyValue('ParaStyleName', 'Başlık 1');
Cursor.SetPropertyValue('ParaAdjust', 3);
Cursor.SetPropertyValue('ParaLineSpacing', StructLineSpacing);
Text.InsertString(Cursor, 'Burası Başlık 1 Özelliğinde', false);
Text.InsertControlCharacter(Cursor, 0, false);
Text.InsertString(Cursor, strContent[1], false);
Cursor.SetPropertyValue('CharWeight', 200);
Text.InsertString(Cursor, strContent[2], false);
Cursor.SetPropertyValue('CharPosture', 200);
Cursor.SetPropertyValue('CharFontName', 'Arial');
Cursor.SetPropertyValue('CharUnderline', 200);
Text.InsertString(Cursor, strContent[3], false);
Cursor.SetPropertyValue('CharColor', 255);
Cursor.SetPropertyValue('CharShadowed', false);
Cursor.SetPropertyValue('CharHeight', 6);
Text.InsertString(Cursor, strContent[4], false);
Text.InsertString(Cursor, strContent[5], false);
Cursor.SetPropertyValue('ParaAdjust', 2);
Cursor.SetPropertyValue('ParaLeftMargin', 500);
Cursor.SetPropertyValue('CharHeight', 14);
Cursor.SetPropertyValue('ParaRightMargin', 500);
Cursor.SetPropertyValue('ParaFirstLineIndent', 2000);
Text.InsertControlCharacter(Cursor, 0, false);
//-------------------------- TABLE ---------------------------------------
oTable := fDocument.createInstance('com.sun.star.text.TextTable');
oTable.setName('T1');
oTable.initialize(4, 2);
oTable.SetPropertyValue('HoriOrient', 0); //0-->iki yana uzat, 1--> sağa, 2--> ortala, 3--> sola
oTable.SetPropertyValue('Width', 4000); /// 4000=7cm oluyo
oTable.SetPropertyValue('LeftMargin', 2000);
fDocument.Text.InsertTextContent(Cursor, oTable, true);
sCellnames := oTable.getCellNames;
for iCellcounter := VarArrayLowBound(sCellnames, 1) to VarArrayHighBound(sCellnames, 1) do
begin
sCellName := sCellnames[iCellcounter];
oCell := oTable.getCellByName(sCellName);
oText := oCell.getText;
oCursor := oText.createTextCursor;
oCursor.SetPropertyValue('ParaAdjust', 3); //1--> sola 2--> sağa 3--> ortala
oText.insertString(oCursor, 'www', False);
oCell.SetPropertyValue('LeftBorder', Struct2);
end;
oTblColSeps := oTable.TableColumnSeparators;
oTblColSeps[0].Position := 2000;
// oTblColSeps[1].Position := 4000;
oTable.TableColumnSeparators := oTblColSeps;
Text.InsertString(Cursor, 'fdsgdfgdsg dfsd erlw ewth ektkek' +
'ewlr tewlktlerwtle rwjtlekrjtl kerjtler lewr jel' +
'g dsg fdg d', false);
//--------------------- Şekil Ekleme ---------------------------
adet := 28000 - StdPage.GetPropertyValue('TopMargin') - StdPage.GetPropertyValue('BottomMargin');
adet := round(adet / 4000);
pageWidth := stdPage.GetPropertyValue('Width');
rightMargin := StdPage.GetPropertyValue('RightMargin');
for i := 0 to 2 do
begin
StructShapeSize := fOOffice.Bridge_GetStruct('com.sun.star.awt.Size');
StructShapeSize.Width := 2000;
StructShapeSize.Height := 3000;
StructShapePosition := fOOffice.Bridge_GetStruct('com.sun.star.awt.Point');
StructShapePosition.X := pageWidth - rightMargin - StructShapeSize.Width - 200;
if (i >= adet) then
StructShapePosition.Y := StdPage.GetPropertyValue('TopMargin') + (i * 4000) + 6800
else
StructShapePosition.Y := StdPage.GetPropertyValue('TopMargin') + 1000 + (i * 4000);
oShape := fDocument.createInstance('com.sun.star.drawing.RectangleShape');
oShape.SetPropertyValue('SizeProtect', false);
oShape.size := StructShapeSize;
oshape.SetPropertyValue('FillColor', 255255255);
oshape.Position := StructShapePosition;
oshape.SetPropertyValue('SurroundContour', true);
oshape.SetPropertyValue('AnchorType', 2); // 2-> Sayfaya, 3-> Karakter olarak, 4->Karaktere, 5->Paragrafa
oshape.SetPropertyValue('TextWrap', 4);
Cursor.gotoendOfParagraph(False);
Text.InsertControlCharacter(Cursor, 0, false);
fDocument.Text.InsertTextContent(Cursor, oShape, true);
end;
//----------------------- Save As -------------------------------
VariantArr := VarArrayCreate([0, 0], varVariant);
VariantArr[0] := fOOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
s := 'file:///'+ StringReplace('c:\d.odt', '\', '/', [rfIgnoreCase]);
fDocument.StoreToURL(s, VariantArr);
end; |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Mon Feb 27, 2006 11:20 am Post subject: |
|
|
If this is reproducable, then check against the latest release candidate and then open a bug report. _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
oeurun General User

Joined: 23 Nov 2005 Posts: 8
|
Posted: Tue Feb 28, 2006 1:23 am Post subject: |
|
|
I think it should be related to document properties. Maybe, I should set some document properties while open or save document. So far, I don't have anything to fit this problem.
I get your book two months ago, it help me to fit my other problems but not found anything about this problem...
Also, maybe it related to version of openoffice, so i am downloading 2.0.1 engilish version now. Because i use turkish version of openoffice 2.0.
Finally, How can i a bug report for this problem? |
|
| Back to top |
|
 |
|
|
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
|