コード例 #1
0
        void PerformLoad()
        {
            // Start LibreOffice and load file
            unoidl.com.sun.star.uno.XComponentContext     localContext        = uno.util.Bootstrap.bootstrap();
            unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory = (unoidl.com.sun.star.lang.XMultiServiceFactory)localContext.getServiceManager();
            desktop = (XDesktop)multiServiceFactory.createInstance("com.sun.star.frame.Desktop");
            var componentLoader = (XComponentLoader)desktop;

            component = componentLoader.loadComponentFromURL(CreateFileUrl(file.FullName), "_blank", 0, new PropertyValue[] { });

            // TODO: while/before loading, set the viewsettings ViewId:=view1, PageKind:=0 to reset to the default view
            // (instead of notes or outline view). Unfortunately these settings aren't accesible in the API ...

            // Get the main window's handle and hide the window
            document = (XModel)component;
            XWindow window = document.getCurrentController().getFrame().getContainerWindow();

            window.setVisible(false);
            XSystemDependentWindowPeer xWindowPeer = (XSystemDependentWindowPeer)(window);

            mainHandle = new IntPtr((int)xWindowPeer.getWindowHandle(new byte[] { }, SystemDependent.SYSTEM_WIN32).Value);
            //ShowWindow(mainHandle, 0);

            presentation = (XPresentation2)((XPresentationSupplier)component).getPresentation();

            CreateThumbnails();

            listener.SlideTransitionStarted += (sender, args) =>
            {
                OnSlideIndexChanged();
            };

            Start();
            controller.gotoSlideIndex(0);

            LoadPreviewProvider();

            base.OnLoaded(true);
        }
コード例 #2
0
        /// <summary>
        /// Try to get the window handle of the window peer for WIN_32 Systems.
        /// </summary>
        /// <param name="windowPeer">The window peer.</param>
        /// <returns>the window handle or IntPtr.Zero</returns>
        public static IntPtr GetWindowHandle(XSystemDependentWindowPeer windowPeer)
        {
            IntPtr wHnd = IntPtr.Zero;

            if (windowPeer != null)
            {
                int pId = OoUtils.GetOoProcessID();
                if (pId > 0)
                {
                    var whnd = windowPeer.getWindowHandle(BitConverter.GetBytes(pId), (short)1);
                    if (whnd.hasValue())
                    {
                        try
                        {
                            int val = (int)whnd.Value;
                            wHnd = new IntPtr(val);
                        }
                        catch { }
                    }
                }
            }
            return(wHnd);
        }
コード例 #3
0
 /// <summary>
 /// Try to get the window handle of the window peer for WIN_32 Systems.
 /// </summary>
 /// <param name="windowPeer">The window peer.</param>
 /// <returns>the window handle or IntPtr.Zero</returns>
 public static IntPtr GetWindowHandle(XSystemDependentWindowPeer windowPeer)
 {
     IntPtr wHnd = IntPtr.Zero;
     if (windowPeer != null)
     {
         int pId = OoUtils.GetOoProcessID();
         if (pId > 0)
         {
             var whnd = windowPeer.getWindowHandle(BitConverter.GetBytes(pId), (short)1);
             if (whnd.hasValue())
             {
                 try
                 {
                     int val = (int)whnd.Value;
                     wHnd = new IntPtr(val);
                 }
                 catch { }
             }
         }
     }
     return wHnd;
 }