To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=116753
                 Issue #|116753
                 Summary|getByName after an insertByName throws NoSuchElementEx
                        |ception
               Component|Word processor
                 Version|OOO330m20
                Platform|PC
                     URL|
              OS/Version|Windows XP
                  Status|UNCONFIRMED
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|programming
             Assigned to|writerneedsconfirm
             Reported by|lzu





------- Additional comments from [email protected] Tue Feb  1 13:18:31 +0000 
2011 -------
When a getByName is invoked after an insertByName a NoSuchElementException is
thrown.
I've tried with a code that works fine with OO 3.2.1. The same code doesn't work
with OO 3.3

This is my java code:
        private void insertImage(XTextDocument textDocument, XTextRange
searchTextRange, ImageResource imageResource) throws OfficeException {
                
                try {
                        XMultiServiceFactory xMultiServiceFactory =
(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class,
document);
                        Object bitmapTable =
xMultiServiceFactory.createInstance("com.sun.star.drawing.BitmapTable");
                        XNameContainer xBitmapContainer =
(XNameContainer)UnoRuntime.queryInterface(XNameContainer.class, bitmapTable);

                        String internalName = 
imageResource.getUrl().getPath().replace("/",
"_").replace(":", "_") + System.currentTimeMillis() + "_" + Math.random();
                        
                        xBitmapContainer.insertByName(internalName,
imageResource.getUrl().toExternalForm());
                        Object internalUrl = 
xBitmapContainer.getByName(internalName);
                        
                        Object image =
xMultiServiceFactory.createInstance("com.sun.star.text.TextGraphicObject");
                        XTextContent xImage =
(XTextContent)UnoRuntime.queryInterface(XTextContent.class, image);
                XPropertySet xPropertySet =
(com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
xImage);
                
                xPropertySet.setPropertyValue("GraphicURL", internalUrl);
                xPropertySet.setPropertyValue("Width", 
imageResource.getWidth());
                xPropertySet.setPropertyValue("Height", 
imageResource.getHeight());
                        
                        
textDocument.getText().insertTextContent(searchTextRange, xImage, true);

                } catch (Exception e) {
                        e.printStackTrace();
                        throw new OfficeException("Eccezione durante 
l'inserimento dell'immagine", e);
                }
                
        }

ImageResource is just a bean POJO.

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to