Date date = new Date();
date.Year = 2071;
date.Month = 2;
date.Day = 3;
dt.Year = 2065;
Duration dur = new Duration();
dur.Negative = true;
dur.Years = 1001;
dur.Months = 999;
dur.Days = 888;
dur.Hours = 777;
dur.Minutes = 666;
dur.Seconds = 555;
dur.MilliSeconds = 444;
udpc.addProperty("Frobnicate", PropertyAttribute.REMOVEABLE, b);
udpc.addProperty("FrobDuration", PropertyAttribute.REMOVEABLE, dur);
udpc.addProperty("FrobDuration2", PropertyAttribute.REMOVEABLE, t);
udpc.addProperty("FrobEndDate", PropertyAttribute.REMOVEABLE, date);
udpc.addProperty("FrobStartTime", PropertyAttribute.REMOVEABLE, dt);
udpc.addProperty("Pi", PropertyAttribute.REMOVEABLE, new Double(d));
udpc.addProperty("Foo", PropertyAttribute.REMOVEABLE, "bar");
udpc.addProperty("Removed", PropertyAttribute.REMOVEABLE, "bar");
// #i94175#: empty property name is valid ODF 1.1
udpc.addProperty("", PropertyAttribute.REMOVEABLE, "eeeeek");
try {
udpc.removeProperty("Info 1");
udpc.removeProperty("Removed");
} catch (UnknownPropertyException e) {
fail("removeProperty failed");
}
try {
udpc.addProperty("Forbidden", PropertyAttribute.REMOVEABLE,
new String[] { "foo", "bar" });
fail("inserting value of non-supported type did not fail");
} catch (IllegalTypeException e) {
// ignore
}
assertTrue("UserDefined bool", new Boolean(b).equals(
udps.getPropertyValue("Frobnicate")));
assertTrue("UserDefined duration", eqDuration(dur, (Duration)
udps.getPropertyValue("FrobDuration")));
assertTrue("UserDefined time", eqTime(t, (Time)
udps.getPropertyValue("FrobDuration2")));
assertTrue("UserDefined date", eqDate(date, (Date)
udps.getPropertyValue("FrobEndDate")));
assertTrue("UserDefined datetime", eqDateTime(dt, (DateTime)
udps.getPropertyValue("FrobStartTime")));
assertTrue("UserDefined float", new Double(d).equals(
udps.getPropertyValue("Pi")));
assertTrue("UserDefined string", "bar".equals(
udps.getPropertyValue("Foo")));
assertTrue("UserDefined empty name", "eeeeek".equals(
udps.getPropertyValue("")));
try {
udps.getPropertyValue("Removed");
fail("UserDefined remove didn't");
} catch (UnknownPropertyException e) {
// ok
}
System.out.println("...done");
System.out.println("Checking storing meta-data to file...");
xDP.storeToMedium(temp + "TEST.odt", mimeArgs);
System.out.println("...done");
System.out.println("Checking loading meta-data from stored file...");
xDP.loadFromMedium(temp + "TEST.odt", noArgs);
System.out.println("...done");
System.out.println("Checking user-defined meta-data from stored file...");
udpc = xDP.getUserDefinedProperties();
udps = UnoRuntime.queryInterface( XPropertySet.class, udpc );
assertTrue("UserDefined bool", new Boolean(b).equals(
udps.getPropertyValue("Frobnicate")));
assertTrue("UserDefined duration", eqDuration(dur, (Duration)
udps.getPropertyValue("FrobDuration")));
// this is now a Duration!
Duration t_dur = new Duration(false, (short)0, (short)0, (short)0,
t.Hours, t.Minutes, t.Seconds,
(short)(10 * t.HundredthSeconds));
assertTrue("UserDefined time", eqDuration(t_dur, (Duration)
udps.getPropertyValue("FrobDuration2")));
assertTrue("UserDefined date", eqDate(date, (Date)