예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SPBasicSuiteProvider"/> class.
        /// </summary>
        /// <param name="picaSuiteData">The filter record provider.</param>
        /// <param name="propertySuite">The property suite.</param>
        /// <param name="colorPicker">The color picker.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="picaSuiteData"/> is null.
        /// </exception>
        public SPBasicSuiteProvider(IPICASuiteDataProvider picaSuiteData, IPropertySuite propertySuite, IColorPicker colorPicker)
        {
            if (picaSuiteData == null)
            {
                throw new ArgumentNullException(nameof(picaSuiteData));
            }

            this.picaSuiteData      = picaSuiteData;
            this.propertySuite      = propertySuite;
            this.colorPicker        = colorPicker;
            spAcquireSuite          = new SPBasicAcquireSuite(SPBasicAcquireSuite);
            spReleaseSuite          = new SPBasicReleaseSuite(SPBasicReleaseSuite);
            spIsEqual               = new SPBasicIsEqual(SPBasicIsEqual);
            spAllocateBlock         = new SPBasicAllocateBlock(SPBasicAllocateBlock);
            spFreeBlock             = new SPBasicFreeBlock(SPBasicFreeBlock);
            spReallocateBlock       = new SPBasicReallocateBlock(SPBasicReallocateBlock);
            spUndefined             = new SPBasicUndefined(SPBasicUndefined);
            actionSuites            = new ActionSuiteProvider();
            activePICASuites        = new ActivePICASuites();
            descriptorRegistrySuite = null;
            bufferSuite             = null;
            colorSpaceSuite         = null;
            errorSuite              = null;
            handleSuite             = null;
            disposed = false;
        }
예제 #2
0
        private int AllocatePICASuite(ActivePICASuites.PICASuiteKey suiteKey, ref IntPtr suitePointer)
        {
            try
            {
                string suiteName = suiteKey.Name;
                int    version   = suiteKey.Version;

                if (suiteName.Equals(PSConstants.PICA.BufferSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (bufferSuite == null)
                    {
                        bufferSuite = new PICABufferSuite();
                    }

                    PSBufferSuite1 suite = bufferSuite.CreateBufferSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                }
                else if (suiteName.Equals(PSConstants.PICA.HandleSuite, StringComparison.Ordinal))
                {
                    if (version != 1 && version != 2)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (handleSuite == null)
                    {
                        handleSuite = new PICAHandleSuite();
                    }

                    if (version == 1)
                    {
                        PSHandleSuite1 suite = handleSuite.CreateHandleSuite1();
                        suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                    }
                    else if (version == 2)
                    {
                        PSHandleSuite2 suite = handleSuite.CreateHandleSuite2();
                        suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                    }
                }
                else if (suiteName.Equals(PSConstants.PICA.PropertySuite, StringComparison.Ordinal))
                {
                    // The property suite can be null when the filter is showing its about box.
                    if (propertySuite == null || version != PSConstants.kCurrentPropertyProcsVersion)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    PropertyProcs suite = propertySuite.CreatePropertySuite();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                }
                else if (suiteName.Equals(PSConstants.PICA.UIHooksSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (uiHooksSuite == null)
                    {
                        uiHooksSuite = new PICAUIHooksSuite(picaSuiteData.ParentWindowHandle, pluginName, ASZStringSuite);
                    }

                    PSUIHooksSuite1 suite = uiHooksSuite.CreateUIHooksSuite1(picaSuiteData);
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ActionDescriptorSuite, StringComparison.Ordinal))
                {
                    if (version != 2)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }
                    if (!actionSuites.DescriptorSuiteCreated)
                    {
                        CreateActionDescriptorSuite();
                    }

                    PSActionDescriptorProc actionDescriptor = actionSuites.DescriptorSuite.CreateActionDescriptorSuite2();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, actionDescriptor);
                }
                else if (suiteName.Equals(PSConstants.PICA.ActionListSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }
                    if (!actionSuites.ListSuiteCreated)
                    {
                        actionSuites.CreateListSuite(ASZStringSuite);
                    }

                    PSActionListProcs listSuite = actionSuites.ListSuite.CreateActionListSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, listSuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ActionReferenceSuite, StringComparison.Ordinal))
                {
                    if (version != 2)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }
                    if (!actionSuites.ReferenceSuiteCreated)
                    {
                        actionSuites.CreateReferenceSuite();
                    }

                    PSActionReferenceProcs referenceSuite = actionSuites.ReferenceSuite.CreateActionReferenceSuite2();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, referenceSuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ASZStringSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    ASZStringSuite1 stringSuite = ASZStringSuite.CreateASZStringSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, stringSuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ColorSpaceSuite, StringComparison.Ordinal))
                {
                    // The color picker can be null when the filter is showing its about box.
                    if (colorPicker == null || version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (colorSpaceSuite == null)
                    {
                        colorSpaceSuite = new PICAColorSpaceSuite(ASZStringSuite, colorPicker);
                    }

                    PSColorSpaceSuite1 csSuite = colorSpaceSuite.CreateColorSpaceSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, csSuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.DescriptorRegistrySuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (descriptorRegistrySuite == null)
                    {
                        if (!actionSuites.DescriptorSuiteCreated)
                        {
                            CreateActionDescriptorSuite();
                        }

                        descriptorRegistrySuite = new DescriptorRegistrySuite(actionSuites.DescriptorSuite);
                        if (pluginSettings != null)
                        {
                            descriptorRegistrySuite.SetPluginSettings(pluginSettings);
                        }
                    }

                    PSDescriptorRegistryProcs registrySuite = descriptorRegistrySuite.CreateDescriptorRegistrySuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, registrySuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ErrorSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (errorSuite == null)
                    {
                        errorSuite = new ErrorSuite(ASZStringSuite);
                    }

                    PSErrorSuite1 errorProcs = errorSuite.CreateErrorSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, errorProcs);
                }
#if PICASUITEDEBUG
                else if (suiteName.Equals(PSConstants.PICA.SPPluginsSuite, StringComparison.Ordinal))
                {
                    if (version != 4)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    SPPluginsSuite4 plugs = PICASPPluginsSuite.CreateSPPluginsSuite4();

                    suitePointer = this.activePICASuites.AllocateSuite(suiteKey, plugs);
                }
#endif
                else
                {
                    return(PSError.kSPSuiteNotFoundError);
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }