public void LoadFileDeleteGraphic()
{
string fileName = "hallo_rem_graphic.odt";
string graphicFile = "";
TextDocument document = new TextDocument();
document.Load(AARunMeFirstAndOnce.inPutFolder+"hallo.odt");
foreach(IContent iContent in document.Content)
{
if (iContent is Paragraph && ((Paragraph)iContent).Content.Count > 0
&& ((Paragraph)iContent).Content[0] is Frame)
{
Frame frame = ((Paragraph)iContent).Content[0] as Frame;
Assert.IsTrue(frame.Content[0] is Graphic, "Must be a graphic!");
Graphic graphic = frame.Content[0] as Graphic;
//now access the full qualified graphic path
Assert.IsNotNull(graphic.GraphicRealPath, "The graphic real path must exist!");
Assert.IsTrue(File.Exists(graphic.GraphicRealPath));
graphicFile = graphic.GraphicRealPath;
//Delete the graphic
frame.Content.Remove(graphic);
}
}
document.SaveTo(AARunMeFirstAndOnce.outPutFolder+fileName);
//Special case, only for this test neccessary
document.Dispose();
//Load file again
TextDocument documentRel = new TextDocument();
documentRel.Load(AARunMeFirstAndOnce.outPutFolder+fileName);
Assert.IsFalse(File.Exists(graphicFile), "This file must be removed from this file!");
}