Trying and failing to find usage of a character style in open office writer

Warning: this procedure does not work. I documented it because I wasted an hour trying it and don’t want to go down this path again.

 

My Open Office document listed an odd Character Style as being in use. Figure out where it was used wasn’t easy/obvious, so I’m writing it up. Searching for paragraph styles is easy. You do a search and choose “move options” > “search for styles.” Character styles not so easy.

How to view character styles in use

  1. Format > Formatting and Styles
  2. Click the second button which is a picture of an A and says “Character Styles” as you mouse over.
  3. Choose “Applied Styles” in the pulldown

Download a PDF print driver

On Windows, PrimoPDF is good. On Mac, the functionality is built in. You can download PDFWriter if you really need an external one. Both are free, at least for personal use.

Configure the PDF print driver (if needed – it wasn’t for me)

  1. File > Print
  2. Under printer pulldown, select “Add Printer”
  3. Click PDFWriter
  4. Click Add
  5. Mac configures the driver
  6. Cancel

“Print” the styles

complements of this thread

  1. File > Templates > Organize
  2. Double click document in the right list. This expands it to show Styles.
  3. Right click styles > Print
  4. Click PDF pull down in the bottom left corner
  5. Open PDF in preview

This gave me a 37 page PDF (for my 100 page document.) It listed the modified styles but not where they were used. I wound up deleting the bad style by right clicking it in applied styles since it wasn’t one I intended to use in the document.

 

 

java 8 – writing a timer

A member at CodeRanch asked a question that prompted me to write a qucik program to determine which of two String operations were faster. This is the first time my instinct was to use Java 8 functionality to do it.

The interesting features:

  1. Uses Instant and Duration instead of System.currentTimeMillis().
  2. Uses functional programming to pass the expression to run to the timer rather than duplicating the timer logic or using a subclass
  3. Uses underscores to make # iterations more readable. (Ok, this is Java 7 not Java 8)
public class PlayTest {

	public static void main(String[] args) throws Exception {

		timer("string concatenation", () -> "/root/" + getFolderName()
				+ "/subfolder");
		timer("string format",
				() -> String.format("/root/%s/subfolder", getFolderName()));

	}

	private static void timer(String message, Supplier<String> candidate) {
		Instant start = Instant.now();
		int times = 1_000_000;

		for (int i = 0; i < times; i++) {
			candidate.get();
		}
		Instant end = Instant.now();
		System.out.println(message + " : " + Duration.between(start, end));
	}

	private static String getFolderName() {
		return "foo";
	}

}

The old way (for comparison)

public static void oldWay() {
		long before = System.currentTimeMillis();
		int times = 1_000_000;

		for (int i = 0; i < times; i++) {
			String s = "/root/" + getFolderName() + "/subfolder";
		}
		long after = System.currentTimeMillis();
		System.out.println("String concatenation: " + (after - before));
	}

The output

The output is also clearer.

string concatenation : PT0.5533S

Vs

string concatenation : 553

I actually get units of time without doing anything special now. And in case you are wondering, the conclusion is that string concatenation is faster. I expected that. It was way faster than I expected though. Twenty times faster.