如何使用OpenOffice :: OODoc为图像添加文本标题?

Ale*_*ird 6 perl openoffice.org odf libreoffice

我有以下代码创建带有标题和图片的odf文档:

#!/usr/bin/perl 

use strict;
use warnings;
use OpenOffice::OODoc;

my $doc = odfDocument(
    file   => 'test.odt',
    create => 'text'
);

my $head = $doc->appendHeading(
    text  => "This is a Test",
    style => 'Heading 1'
);

my $style = $doc->createImageStyle("Photo");
my $image = $doc->createImageElement(
    'some picture',
    style      => 'Photo',
    attachment => $head,
    size       => '4cm, 12cm',
    link       => '/full/path/to/picture.png'
);

$doc->save();
Run Code Online (Sandbox Code Playgroud)

如何在图片中添加文字标题?当我在LibreOffice中创建文本标题时,创建标题的'content.xml'部分就是这样的.

<draw:frame draw:style-name="fr1" draw:name="Frame1" text:anchor-type="as-char" svg:y="0cm" svg:width="4.001cm" draw:z-index="0">
  <draw:text-box fo:min-height="12cm">
    <text:p text:style-name="Caption">
      <draw:frame draw:style-name="fr2" draw:name="Eiffel Tower" text:anchor-type="paragraph" svg:x="0.004cm" svg:y="0.002cm" svg:width="4.001cm" style:rel-width="100%" svg:height="12cm" style:rel-height="scale" draw:z-index="1">
        <draw:image xlink:href="full/path/to/picture.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
      </draw:frame>
      test caption
    </text:p>
  </draw:text-box>
</draw:frame> 
Run Code Online (Sandbox Code Playgroud)

我认为它会创建一个框架,然后将图像和标题文本放在其中.我迷失在这一点上.我找不到有关在文档中添加元素到框架的东西.

小智 1

查看 perl 创建的 xml 会很有趣,但除此之外,您可以在写出之前使用 Xpath 模块修改 XML。但实际上,我们需要查看基本输出才能了解出了什么问题。例如,框架嵌套可能是错误的。