Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8219611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:13:54+00:00 2026-06-07T13:13:54+00:00

I have various text documents (.odt, .doc) etc. which i use as templates for

  • 0

I have various text documents (.odt, .doc) etc. which i use as templates for populating them with text using Java. In order to achieve that i have added TextFields to the documents on every position that i would like to insert text and i enumerate the TextFields set and assign values to them. However what i really want to do, since these documents are only for printing, is to be able to use bookmarks instead of TextFields (which when not populated are still there emtpy and looking funny). However no matter how many bookmarks i insert by hand on the document templates whenever i try to retrieve the document’s XBookmarksSupplier i get a null value i.e.

XBookmarksSupplier bookmarksSupplier = (XBookmarksSupplier)
UnoRuntime.queryInterface(XBookmarksSupplier.class, document);

is null. The parameter document is the XComponent that i get by creating an in memory copy of the document that i use as a template in the following way:

XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop); 

List<PropertyValue> props = new ArrayList<PropertyValue>(); 
PropertyValue p = null; 

p = new PropertyValue(); 
p.Name = "AsTemplate"; 
p.Value = new Boolean (true); 
props.add(p); 

p = new PropertyValue(); 
p.Name = "DocumentTitle"; 
p.Value = "New doc"; 
props.add(p); 

p = new PropertyValue(); 
p.Name = "Hidden"; 
p.Value = new Boolean(true); 
props.add(p);

PropertyValue[] properties = new PropertyValue[props.size()]; 
props.toArray(properties); 

XComponent document = null;

String templateFileURL = filePathToURL(templateFile); 
document = loader.loadComponentFromURL(templateFileURL, "_blank", 0, properties);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:13:55+00:00Added an answer on June 7, 2026 at 1:13 pm

    Well, finally i figured it out. By Using Eclipse auto-suggest i had imported mistakingly com.sun.star.sdb.XBookmarksSupplier instead of com.sun.star.text.XBookmarksSupplier which is the correct Class. Due to various copy-pasting all my tests where using the same wrong Class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found various examples of using jquery to wrap selected text from a
I need to cluster some text documents and have been researching various options. It
On my website I have various containers with content <div> s text in them.
I need to have various text view on a single line. And I want
I have a custom textblock that has various text properties for left, right and
I have two text files with various columns, each column is separated by a
I have a populated SqlCommand object containing the command text and parameters of various
I have seen config files(yes, text files) for various console applications that look like
I have various class which perform save and update operations of GUI elements, it
I have various settings in my ccnet.config file and wish to pass them to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.