Code Monkey home page Code Monkey logo

Comments (7)

PrzemyslawKlys avatar PrzemyslawKlys commented on May 23, 2024 1

You can always try fixing it, I will need to look at code to be able to tell whether that's the simplest way to fix it. for me if you have optional parameter that requires you to "fix" this or it throws an error - it's not good design. I would prefer something automatic, so when user does AddImage it just works without thinking on "paragraphs", but maybe there's no other way. I'll take a look when I get some time, but if you want you can always play with it.

from officeimo.

tmheath avatar tmheath commented on May 23, 2024

image
Seen above the documentation implies the result is going to be a paragraph. Seen below there is a failure
since the parent is null but the method used to create the parent does not return nullable.
image
The code in question is below.
((addParagraph "").AddImage (image.path, image.width, image.height, wrap)).AddParagraphAfterSelf() |> ignore
I got this from adding the call to addparagraphafterself to try checking if it was due to the requirement to end a cell with a paragraph. This tells me that AddImage is returning null, I can't say more than this as I don't know the codebase.

from officeimo.

tmheath avatar tmheath commented on May 23, 2024
    public WordParagraph AddImage(string filePathImage, double? width = null, double? height = null, WrapTextImage wrapImageText = WrapTextImage.InLineWithText, string description = "") {
        var wordImage = new WordImage(_document, this, filePathImage, width, height, wrapImageText, description);
        // Why was this change made?
        //var wordImage = new WordImage(_document, filePathImage, width, height);
        var paragraph = new WordParagraph(_document);
        VerifyRun();
        _run.Append(wordImage._Image);
        return paragraph;

from officeimo.

tmheath avatar tmheath commented on May 23, 2024

Looked around some, thinking I'm going to be looking around the Table Cell code in the morning.

from officeimo.

tmheath avatar tmheath commented on May 23, 2024

@PrzemyslawKlys

I believe that I found the problem.
WordTableCell creates a brand new WordParagraph via call to the default constructor with no arguments using new.
This causes the paragraph not to have it's own reference to _document, the field will be left null, and so when addImage
is called on this paragraph, there is an error because _wordimage is passed the null reference to the document from
the paragraph so the image resource cannot be added to the root of the document.
WordParagraph public methods
WordParagraph constructor definition
WordTableCell

Should I submit a PR adding an optional argument for the _document reference to the addImage method on WordParagraph?

from officeimo.

tmheath avatar tmheath commented on May 23, 2024

The alternative short term fix for adding an image into a table looks like the user needs to explicitly create a WordParagraph from the document or directly and then add this paragraph into the table cell.

from officeimo.

tmheath avatar tmheath commented on May 23, 2024

Just looked over the existing PR for improving the table class and this fix is not yet present there, maybe better to fix there idk.

from officeimo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.