Exemplo n.º 1
0
        /// <summary>
        ///     Exports the loaded document to PDF format
        /// </summary>
        /// <param name="component"></param>
        /// <param name="inputFile"></param>
        /// <param name="outputFile"></param>
        private void ExportToPdf(XComponent component, string inputFile, string outputFile)
        {
            Logger.WriteToLog($"Exporting document to PDF file '{outputFile}'");

            var propertyValues = new PropertyValue[3];
            var filterData     = new PropertyValue[5];

            filterData[0] = new PropertyValue
            {
                Name  = "UseLosslessCompression",
                Value = new Any(false)
            };

            filterData[1] = new PropertyValue
            {
                Name  = "Quality",
                Value = new Any(90)
            };

            filterData[2] = new PropertyValue
            {
                Name  = "ReduceImageResolution",
                Value = new Any(true)
            };

            filterData[3] = new PropertyValue
            {
                Name  = "MaxImageResolution",
                Value = new Any(300)
            };

            filterData[4] = new PropertyValue
            {
                Name  = "ExportBookmarks",
                Value = new Any(false)
            };

            // Setting the filter name
            propertyValues[0] = new PropertyValue
            {
                Name  = "FilterName",
                Value = new Any(GetFilterType(inputFile))
            };

            // Setting the flag for overwriting
            propertyValues[1] = new PropertyValue {
                Name = "Overwrite", Value = new Any(true)
            };

            var polymorphicType = PolymorphicType.GetType(typeof(PropertyValue[]), "unoidl.com.sun.star.beans.PropertyValue[]");

            propertyValues[2] = new PropertyValue {
                Name = "FilterData", Value = new Any(polymorphicType, filterData)
            };

            // ReSharper disable once SuspiciousTypeConversion.Global
            ((XStorable)component).storeToURL(ConvertToUrl(outputFile), propertyValues);

            Logger.WriteToLog("Document exported to PDF");
        }
Exemplo n.º 2
0
        /* Attention: Debugging this code (probably in mixed mode) may lead to exceptions
         * which do not occur when running normally (Visual Studio 2003)
         */
        public void testConstructorsService(XComponentContext context)
        {
            Constructors.create1(context,
                                 true,
                                 0x80, // -128 in C++,
                                 Int16.MinValue,
                                 UInt16.MaxValue,
                                 Int32.MinValue,
                                 UInt32.MaxValue,
                                 Int64.MinValue,
                                 UInt64.MaxValue,
                                 0.123f,
                                 0.456,
                                 'X',
                                 "test",
                                 typeof(Any),
                                 new Any(true),
                                 new bool[] { true },
                                 new byte[] { 0x80 }, // in C++ the value is compared with SAL_MIN_INT8 which is -128
                                 new short[] { Int16.MinValue },
                                 new UInt16[] { UInt16.MaxValue },
                                 new Int32[] { Int32.MinValue },
                                 new UInt32[] { UInt32.MaxValue },
                                 new long[] { Int64.MinValue },
                                 new UInt64[] { UInt64.MaxValue },
                                 new float[] { 0.123f },
                                 new double[] { 0.456 },
                                 new char[] { 'X' },
                                 new string[] { "test" },
                                 new Type[] { typeof(Any) },
                                 new Any[] { new Any(true) },
                                 new bool[][] { new bool[] { true } },
                                 new Any[][] { new Any[] { new Any(true) } },
                                 new TestEnum[] { TestEnum.TWO },
                                 new TestStruct[] { new TestStruct(10) },
                                 new TestPolyStruct[] { new TestPolyStruct(true) },
                                 new TestPolyStruct[] { new TestPolyStruct(new Any(true)) },
                                 new object[] { null },
                                 TestEnum.TWO,
                                 new TestStruct(10),
                                 new TestPolyStruct(true),
                                 new TestPolyStruct(new Any(true)),
                                 null
                                 );

            Constructors.create2(context,
                                 new Any(true),
                                 new Any((System.Byte) 0x80),
                                 new Any(Int16.MinValue),
                                 new Any(UInt16.MaxValue),
                                 new Any(Int32.MinValue),
                                 new Any(UInt32.MaxValue),
                                 new Any(Int64.MinValue),
                                 new Any(UInt64.MaxValue),
                                 new Any(0.123f),
                                 new Any(0.456),
                                 new Any('X'),
                                 new Any("test"),
                                 new Any(typeof(Any)),
                                 new Any(true),
                                 new Any(typeof(bool[]), new bool[] { true }),
                                 new Any(typeof(byte[]), new byte[] { (System.Byte) 0x80 }),
                                 new Any(typeof(short[]), new short[] { Int16.MinValue }),
                                 new Any(typeof(UInt16[]), new UInt16[] { UInt16.MaxValue }),
                                 new Any(typeof(int[]), new int[] { Int32.MinValue }),
                                 new Any(typeof(UInt32[]), new UInt32[] { UInt32.MaxValue }),
                                 new Any(typeof(long[]), new long[] { Int64.MinValue }),
                                 new Any(typeof(UInt64[]), new UInt64[] { UInt64.MaxValue }),
                                 new Any(typeof(float[]), new float[] { 0.123f }),
                                 new Any(typeof(double[]), new double[] { 0.456 }),
                                 new Any(typeof(char[]), new char[] { 'X' }),
                                 new Any(typeof(string[]), new string[] { "test" }),
                                 new Any(typeof(Type[]), new Type[] { typeof(Any) }),
                                 new Any(typeof(Any[]), new Any[] { new Any(true) }),
                                 new Any(typeof(bool[][]), new bool[][] { new bool[] { true } }),
                                 new Any(
                                     typeof(Any[][]), new Any[][] { new Any[] { new Any(true) } }),
                                 new Any(typeof(TestEnum[]), new TestEnum[] { TestEnum.TWO }),
                                 new Any(
                                     typeof(TestStruct[]), new TestStruct[] { new TestStruct(10) }),
                                 new Any(
                                     PolymorphicType.GetType(
                                         typeof(TestPolyStruct[]),
                                         "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>[]"),
                                     new TestPolyStruct[] { new TestPolyStruct(true) }),
                                 new Any(
                                     PolymorphicType.GetType(
                                         typeof(TestPolyStruct[]),
                                         "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>[]"),
                                     new TestPolyStruct[] { new TestPolyStruct(new Any(true)) }),
                                 new Any(typeof(object[]) /*TODO*/, new object[] { null }),
                                 new Any(typeof(TestEnum), TestEnum.TWO),
                                 new Any(typeof(TestStruct), new TestStruct(10)),
                                 new Any(
                                     PolymorphicType.GetType(
                                         typeof(TestPolyStruct),
                                         "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>"),
                                     new TestPolyStruct(true)),
                                 new Any(
                                     PolymorphicType.GetType(
                                         typeof(TestPolyStruct),
                                         "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>"),
                                     new TestPolyStruct(new Any(true))),
                                 new Any(typeof(object), null)
                                 );


            XMultiBase1 xMulti = Constructors2.create1(
                context,
                new TestPolyStruct(typeof(int)),
                new TestPolyStruct(new Any(true)),
                new TestPolyStruct(true),
                new TestPolyStruct((Byte)0x80),
                new TestPolyStruct(Int16.MinValue),
                new TestPolyStruct(Int32.MinValue),
                new TestPolyStruct(Int64.MinValue),
                new TestPolyStruct('X'),
                new TestPolyStruct("test"),
                new TestPolyStruct(0.123f),
                new TestPolyStruct(0.456d),
                new TestPolyStruct(new object()),
                new TestPolyStruct(new uno.util.WeakComponentBase()),
                new TestPolyStruct(TestEnum.TWO),
                new TestPolyStruct(new TestPolyStruct2('X', new Any(true))),
                new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")),
                new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))),
                new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')),
                new TestPolyStruct(new Type[] { typeof(int) }),
                new TestPolyStruct(new Any[] { new Any(true) }),
                new TestPolyStruct(new bool[] { true }),
                new TestPolyStruct(new byte[] { 0x80 }),
                new TestPolyStruct(new short[] { Int16.MinValue }),
                new TestPolyStruct(new int[] { Int32.MinValue }),
                new TestPolyStruct(new long[] { Int64.MinValue }),
                new TestPolyStruct(new char[] { 'X' }),
                new TestPolyStruct(new string[] { "test" }),
                new TestPolyStruct(new float[] { 0.123f }),
                new TestPolyStruct(new double[] { 0.456d }),
                new TestPolyStruct(new object[] { new object() }),
                new TestPolyStruct(new unoidl.com.sun.star.lang.XComponent[] { new uno.util.WeakComponentBase() }),
                new TestPolyStruct(new TestEnum[] { TestEnum.TWO }),
                new TestPolyStruct(new TestPolyStruct2[] { new TestPolyStruct2('X', new Any[] { new Any(true) }) }),
                new TestPolyStruct(new TestPolyStruct2[] {
                new TestPolyStruct2(new TestPolyStruct('X'), new Any[] { new Any(true) })
            }),
                new TestPolyStruct(new int[][] { new int[] { Int32.MinValue } }),
                new TestPolyStruct[] { new TestPolyStruct(Int32.MinValue) },
                new TestPolyStruct[] { new TestPolyStruct(new TestPolyStruct2('X', new Any(true))) },
                new TestPolyStruct[] { new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")) },
                new TestPolyStruct2[] { new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))) },
                new TestPolyStruct2[] { new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')) },
                new TestPolyStruct[][] { new TestPolyStruct[] { new TestPolyStruct('X') } },
                new TestPolyStruct[][] { new TestPolyStruct[] { new TestPolyStruct(new TestPolyStruct2('X', new Any(true))) } },
                new TestPolyStruct[][] { new TestPolyStruct[] { new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")) } },
                new TestPolyStruct2[][] { new TestPolyStruct2[] { new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))) } },
                new TestPolyStruct2[][] { new TestPolyStruct2[] { new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')) } }
                );

            //test the returned interface
            xMulti.fn11(1);
        }