@Test public void testPrintBlockCommand() throws UnoHelperException, InvalidCommandException, IOException, SyntaxErrorException { XTextDocument doc = UNO.XTextDocument(loadComponent("private:factory/swriter", false, true)); XTextCursor cursor = doc.getText().createTextCursor(); cursor.setString("ABC"); String conf = "WM(CMD 'allVersions' HIGHLIGHT_COLOR 'ffffc8')"; Bookmark bm = new Bookmark(conf, doc, cursor); PrintBlockCommand cmd = new PrintBlockCommand(new ConfigThingy("", null, new StringReader(conf)), bm); assertEquals(TextRangeRelation.A_MATCH_B, TextRangeRelation.compareTextRanges(cursor, cmd.getAnchor()), "wrong cursor"); assertEquals("ffffc8", cmd.getHighlightColor(), "wrong color"); assertEquals(PrintBlockSignature.ALL_VERSIONS, cmd.getName()); assertEquals(0, cmd.execute(new PrintBlockProcessor()), "Command executed with errors"); assertEquals(Integer.parseInt(cmd.getHighlightColor(), 16), UnoProperty.getProperty(cursor, UnoProperty.CHAR_BACK_COLOR), "Wrong background not set"); assertTrue(cmd.isDone(), "Command should be done"); assertFalse(cmd.hasError(), "Command shouldn't have errors"); cmd.showHighlightColor(false); assertEquals(-1, UnoProperty.getProperty(cursor, UnoProperty.CHAR_BACK_COLOR), "Wrong background not reset"); assertThrows(InvalidCommandException.class, () -> new PrintBlockCommand( new ConfigThingy("", null, new StringReader("WM(CMD 'foo' HIGHLIGHT_COLOR 'ffffc8')")), bm)); }
public PrintBlockCommand(ConfigThingy wmCmd, Bookmark bookmark) throws InvalidCommandException { super(wmCmd, bookmark); try { name = PrintBlockSignature.valueOfIgnoreCase(wmCmd.getString("CMD", "")); } catch (IllegalArgumentException ex) { throw new InvalidCommandException("Unknown command.", ex); } try { highlightColor = wmCmd.get("WM").get("HIGHLIGHT_COLOR").toString(); } catch (NodeNotFoundException e) { } }
PrintBlockCommand extends DocumentCommand { public PrintBlockCommand(ConfigThingy wmCmd, Bookmark bookmark) throws InvalidCommandException { super(wmCmd, bookmark); try { name = PrintBlockSignature.valueOfIgnoreCase(wmCmd.getString("CMD", "")); } catch (IllegalArgumentException ex) { throw new InvalidCommandException("Unknown command.", ex); } try { highlightColor = wmCmd.get("WM").get("HIGHLIGHT_COLOR").toString(); } catch (NodeNotFoundException e) { } } }
PrintBlockCommand extends DocumentCommand { public PrintBlockCommand(ConfigThingy wmCmd, Bookmark bookmark) throws InvalidCommandException { super(wmCmd, bookmark); try { name = PrintBlockSignature.valueOfIgnoreCase(wmCmd.getString("CMD", "")); } catch (IllegalArgumentException ex) { throw new InvalidCommandException("Unknown command.", ex); } try { highlightColor = wmCmd.get("WM").get("HIGHLIGHT_COLOR").toString(); } catch (NodeNotFoundException e) { } } PrintBlockCommand(ConfigThingy wmCmd, Bookmark bookmark); }
PrintBlockCommand extends DocumentCommand { public PrintBlockCommand(ConfigThingy wmCmd, Bookmark bookmark) throws InvalidCommandException { super(wmCmd, bookmark); try { name = PrintBlockSignature.valueOfIgnoreCase(wmCmd.getString("CMD", "")); } catch (IllegalArgumentException ex) { throw new InvalidCommandException("Unknown command.", ex); } try { highlightColor = wmCmd.get("WM").get("HIGHLIGHT_COLOR").toString(); } catch (NodeNotFoundException e) { } } PrintBlockCommand(ConfigThingy wmCmd, Bookmark bookmark); String getHighlightColor(); PrintBlockSignature getName(); @Override int execute(DocumentCommand.Executor visitable); void showHighlightColor(boolean showHighlightColor); }
PrintBlockCommand extends DocumentCommand { public PrintBlockCommand(ConfigThingy wmCmd, Bookmark bookmark) throws InvalidCommandException { super(wmCmd, bookmark); try { name = PrintBlockSignature.valueOfIgnoreCase(wmCmd.getString("CMD", "")); } catch (IllegalArgumentException ex) { throw new InvalidCommandException("Unknown command.", ex); } try { highlightColor = wmCmd.get("WM").get("HIGHLIGHT_COLOR").toString(); } catch (NodeNotFoundException e) { } } PrintBlockCommand(ConfigThingy wmCmd, Bookmark bookmark); String getHighlightColor(); PrintBlockSignature getName(); @Override int execute(DocumentCommand.Executor visitable); void showHighlightColor(boolean showHighlightColor);  }