Package com.sun.star.util

Examples of com.sun.star.util.Duration


            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)
View Full Code Here


            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,
                new Boolean(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) {
                assure("removeProperty failed", false);
            }

            try {
                udpc.addProperty("Forbidden", PropertyAttribute.REMOVEABLE,
                    new String[] { "foo", "bar" });
                assure("inserting value of non-supported type did not fail",
                    false);
            } catch (IllegalTypeException e) {
                // ignore
            }

            assure ("UserDefined bool", new Boolean(b).equals(
                    udps.getPropertyValue("Frobnicate")));
            assure ("UserDefined duration", eqDuration(dur, (Duration)
                    udps.getPropertyValue("FrobDuration")));
            assure ("UserDefined time", eqTime(t, (Time)
                    udps.getPropertyValue("FrobDuration2")));
            assure ("UserDefined date", eqDate(date, (Date)
                    udps.getPropertyValue("FrobEndDate")));
            assure ("UserDefined datetime", eqDateTime(dt, (DateTime)
                    udps.getPropertyValue("FrobStartTime")));
            assure ("UserDefined float", new Double(d).equals(
                    udps.getPropertyValue("Pi")));
            assure ("UserDefined string", "bar".equals(
                    udps.getPropertyValue("Foo")));
            assure ("UserDefined empty name", "eeeeek".equals(
                    udps.getPropertyValue("")));

            try {
                udps.getPropertyValue("Removed");
                assure("UserDefined remove didn't", false);
            } catch (UnknownPropertyException e) {
                // ok
            }

            log.println("...done");

            log.println("Checking storing meta-data to file...");

            xDP.storeToMedium(temp + "TEST.odt", mimeArgs);

            log.println("...done");

            log.println("Checking loading meta-data from stored file...");

            xDP.loadFromMedium(temp + "TEST.odt", noArgs);

            log.println("...done");

            log.println("Checking user-defined meta-data from stored file...");

            udpc = xDP.getUserDefinedProperties();
            udps = (XPropertySet) UnoRuntime.queryInterface(
                XPropertySet.class, udpc);

            assure ("UserDefined bool", new Boolean(b).equals(
                    udps.getPropertyValue("Frobnicate")));
            assure ("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));
            assure ("UserDefined time", eqDuration(t_dur, (Duration)
                    udps.getPropertyValue("FrobDuration2")));
            assure ("UserDefined date", eqDate(date, (Date)
View Full Code Here

TOP

Related Classes of com.sun.star.util.Duration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.