<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - Embedding external (links) images programmatically no longer works"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=121536">121536</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Embedding external (links) images programmatically no longer works
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.1.0.3 release
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Writer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ikharus@hotmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Before 6.1.0.3, it was possible to embed all external (linked) images into a
document programmatically using the following function: 

  public static void convertLinkedImagesToEmbeded(XComponent document) throws
Exception {

    XTextGraphicObjectsSupplier graphicObjSupplier =
        (XTextGraphicObjectsSupplier)
            UnoRuntime.queryInterface(XTextGraphicObjectsSupplier.class,
document);
    XNameAccess nameAccess = graphicObjSupplier.getGraphicObjects();
    String[] names = nameAccess.getElementNames();
    for (int i = 0; i < names.length; i++) {
      Any xImageAny = (Any) nameAccess.getByName(names[i]);
      Object xImageObject = xImageAny.getObject();
      XTextContent xImage = (XTextContent) xImageObject;
      XServiceInfo xInfo = (XServiceInfo)
UnoRuntime.queryInterface(XServiceInfo.class, xImage);
      if (xInfo.supportsService("com.sun.star.text.TextGraphicObject")) {
        XPropertySet xPropSet =
            (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
xImage);
        String name = xPropSet.getPropertyValue("LinkDisplayName").toString();
        String graphicURL = xPropSet.getPropertyValue("GraphicURL").toString();
        // only ones that are not embedded
        if (graphicURL.indexOf("vnd.sun.") == -1) {
          XMultiServiceFactory multiServiceFactory =
              (XMultiServiceFactory)
                  UnoRuntime.queryInterface(XMultiServiceFactory.class,
document);
          XNameContainer xBitmapContainer =
              (XNameContainer)
                  UnoRuntime.queryInterface(
                      XNameContainer.class,
                     
multiServiceFactory.createInstance("com.sun.star.drawing.BitmapTable"));
          if (!xBitmapContainer.hasByName(name)) {
            xBitmapContainer.insertByName(name, graphicURL);
            String newGraphicURL = xBitmapContainer.getByName(name).toString();
            xPropSet.setPropertyValue("GraphicURL", newGraphicURL);
          }
        }
      }
    }
  }

I have read a lot about the image handling rework and I know that the
GraphicURL property can no longer be used for that but I couldn't find a way to
make the function work again. All the examples available out there that show
how to programmatically break links use the property GraphicURL and the
documentation only tell us to use Graphic instead of GraphicURL, but that
doesn't work in this particular case. After several hours of trying to make it
work, give up!

So, is it still possible to programatically embed linked images since 6.1.0.3+
?? What changes should I make to the function above to support both the
6.1.0.3+ and previous versions ?

Many thanks.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>