thx 4 die links, hab ma mal alles genau angeschaut allerdings steh ich momentan gerade an und weis nicht weiter
hab mal per php folgendes versucht:
1) datei context.xml erstellen
2) inhalt einfügen
3) xml dateien unkomprimiert packen
4) in odt bzw sxw format speichern
Code: Alles auswählen
$filename = "content.xml";
$content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE office:document-content PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"office.dtd\"><office:document-content xmlns:office=\"http://openoffice.org/2000/office\" xmlns:style=\"http://openoffice.org/2000/style\" xmlns:text=\"http://openoffice.org/2000/text\" xmlns:table=\"http://openoffice.org/2000/table\" xmlns:draw=\"http://openoffice.org/2000/drawing\" xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:number=\"http://openoffice.org/2000/datastyle\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:chart=\"http://openoffice.org/2000/chart\" xmlns:dr3d=\"http://openoffice.org/2000/dr3d\" xmlns:math=\"http://www.w3.org/1998/Math/MathML\" xmlns:form=\"http://openoffice.org/2000/form\" xmlns:script=\"http://openoffice.org/2000/script\" office:class=\"text\" office:version=\"1.0\"><office:script/><office:font-decls><style:font-decl style:name=\"Tahoma1\" fo:font-family=\"Tahoma\"/><style:font-decl style:name=\"Arial Unicode MS\" fo:font-family=\"'Arial Unicode MS'\" style:font-pitch=\"variable\"/><style:font-decl style:name=\"Tahoma\" fo:font-family=\"Tahoma\" style:font-pitch=\"variable\"/><style:font-decl style:name=\"Times New Roman\" fo:font-family=\"'Times New Roman'\" style:font-family-generic=\"roman\" style:font-pitch=\"variable\"/></office:font-decls><office:automatic-styles><style:style style:name=\"P1\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"><style:properties fo:font-size=\"14pt\" style:font-size-asian=\"14pt\" style:font-size-complex=\"14pt\"/></style:style><style:style style:name=\"P2\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"><style:properties fo:font-size=\"14pt\" fo:font-weight=\"bold\" style:font-size-asian=\"14pt\" style:font-weight-asian=\"bold\" style:font-size-complex=\"14pt\" style:font-weight-complex=\"bold\"/></style:style><style:style style:name=\"P3\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"><style:properties fo:font-size=\"15pt\" fo:font-weight=\"bold\" style:font-size-asian=\"15pt\" style:font-weight-asian=\"bold\" style:font-size-complex=\"15pt\" style:font-weight-complex=\"bold\"/></style:style><style:style style:name=\"P4\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"><style:properties fo:font-size=\"15pt\" style:font-size-asian=\"15pt\" style:font-size-complex=\"15pt\"/></style:style></office:automatic-styles><office:body><text:sequence-decls><text:sequence-decl text:display-outline-level=\"0\" text:name=\"Illustration\"/><text:sequence-decl text:display-outline-level=\"0\" text:name=\"Table\"/><text:sequence-decl text:display-outline-level=\"0\" text:name=\"Text\"/><text:sequence-decl text:display-outline-level=\"0\" text:name=\"Drawing\"/></text:sequence-decls><text:p text:style-name=\"Standard\">Tadaa</text:p><text:p text:style-name=\"P1\">Tadaa</text:p><text:p text:style-name=\"P2\">Tadaa</text:p><text:p text:style-name=\"P3\"/><text:p text:style-name=\"P3\">Tadaa</text:p><text:p text:style-name=\"P4\"/></office:body></office:document-content>";
if (file_exists($filename))
unlink($filename);
$dataFile = fopen($filename, "a" ) ;
if ($dataFile)
{
while (!feof($dataFile))
{
$buffer = fgets($dataFile, 4096);
echo $buffer;
}
fclose($dataFile);
}
else
{
die( "fopen failed for $filename" ) ;
}
// check file
if (is_writable($filename))
{
if (!$handle = fopen($filename, "a"))
{
echo "error: file $filename corrupted<br>";
exit;
}
// write data to file
if (!fwrite($handle, $content))
{
echo "error: unable to edit $filename<br>";
exit;
}
fclose($handle);
}
else
echo "error: unable to edit $filename<br>";
//zip files
ob_start();
require('zip.lib.php');
$zipfile = new zipfile('oo.sxw');
$zipfile->addFileAndRead('content.xml');
$zipfile->addFileAndRead('meta-inf/manifest.xml');
$zipfile->addFileAndRead('meta.xml');
$zipfile->addFileAndRead('mimetype');
$zipfile->addFileAndRead('settings.xml');
$zipfile->addFileAndRead('styles.xml');
echo $zipfile->file();
funktioniert theoretisch - praktisch streikt OOo wenn ich nicht die original datei verwende (content.xml) obwohl sich in der erzeugten kopie davon der identische inhalt befindet.
btw: hab die folgenden files zum zippen verwendet
http://www.php-resource.de/forum/attach ... tid=357551
hab dann das ganze auf eine andere variante probiert:
Code: Alles auswählen
$oArgs = array();
$objServiceManager = new COM( "com.sun.star.ServiceManager" );
$Stardesktop = $objServiceManager->createInstance( "com.sun.star.frame.Desktop" );
$doc = $Stardesktop->loadComponentFromURL("private:factory/swriter", "_blank", 0, $oArgs );
$text = $doc->getText();
$text->setString("Hello World");
hier bekomme ich allerdings die meldung:
Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `com.sun.star.ServiceManager': Ungültige Syntax ' in C:\Programme\xampp\htdocs\rudL\test\oO2\oo.php:4 Stack trace: #0 C:\Programme\xampp\htdocs\rudL\test\oO2\oo.php(4): com->com('com.sun.star.Se...') #1 {main} thrown in C:\Programme\xampp\htdocs\rudL\test\oO2\oo.php on line 4
habe OpenOffice.org1.1.2 installiert (die ver OpenOffice.org 2.0 ist inzwischen wieder herunten)
OpenOffice.org1.1_SDK
jre1.5.0_06
und php 5
kenn mi inzwischen scho überhaupt nix mehr aus und weiß net was i jetzt für die 2te variante alles installiert haben soll und wo ich was downloaden kann *confused*
thx im voraus,
rudL