コード例 #1
0
        /// <summary>
        /// Gets all named elements of the object.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="debug">if set to <c>true</c> the named children will be printed
        /// to the System.Diagnostics.Debug output.</param>
        /// <returns>
        /// A dictionary with the named elements. The name is the key an the value
        /// is set as uno.Any. You can access the real value by using uno.Any.Value
        /// </returns>
        public static Dictionary <string, uno.Any> GetAllNamedElements(XNameAccess obj, bool debug = true)
        {
            Dictionary <string, uno.Any> elements = new Dictionary <string, uno.Any>();

            if (obj != null)
            {
                string[] names = obj.getElementNames();

                if (debug)
                {
                    System.Diagnostics.Debug.WriteLine("Object [" + obj + "] has " + names.Length + " Properties:");
                }

                foreach (var name in names)
                {
                    uno.Any element = obj.getByName(name);
                    elements.Add(name, element);

                    if (debug)
                    {
                        try
                        {
                            System.Diagnostics.Debug.WriteLine("\tProperty: " + name + " = " + element);
                        }
                        catch (System.Exception)
                        {
                            System.Diagnostics.Debug.WriteLine("Can't get property - " + name);
                        }
                    }
                }
            }
            return(elements);
        }
        public DrawDocLayerManager(XLayerSupplier drwaDoc)
        {
            if (drwaDoc == null)
                throw new ArgumentNullException("drwaDoc", "The XLayerSupplier is null");

            _layerManger = drwaDoc.getLayerManager();
            XModifyBroadcaster debc = drwaDoc as XModifyBroadcaster;
            if (debc != null)
                ((XModifyBroadcaster) drwaDoc).addModifyListener(this);
        }      
コード例 #3
0
        /// <summary>
        /// Gets a named property of an XNameAccess object.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <param name="propName">Name of the property.</param>
        /// <returns>The property or null</returns>
        public static Object GetNamedProperty(XNameAccess obj, String propName)
        {
            Object prop = null;

            if (obj != null)
            {
                if (obj.hasByName(propName))
                {
                    prop = obj.getByName(propName);
                }
            }
            return(prop);
        }
コード例 #4
0
        public DrawDocLayerManager(XLayerSupplier drwaDoc)
        {
            if (drwaDoc == null)
            {
                throw new ArgumentNullException("drwaDoc", "The XLayerSupplier is null");
            }

            _layerManger = drwaDoc.getLayerManager();
            XModifyBroadcaster debc = drwaDoc as XModifyBroadcaster;

            if (debc != null)
            {
                ((XModifyBroadcaster)drwaDoc).addModifyListener(this);
            }
        }
コード例 #5
0
        /// <summary>
        /// Makes a String unique by appending a numerical suffix.
        /// </summary>
        /// <param name="_xElementContainer">the com.sun.star.container.XNameAccess container
        /// that the new Element is going to be inserted to</param>
        /// <param name="_sElementName"the StemName of the Element.</param>
        /// <returns>A String unique by appending a numerical suffix</returns>
        public static String createUniqueName(XNameAccess _xElementContainer, String _sElementName)
        {
            bool   bElementexists = true;
            int    i        = 1;
            String BaseName = _sElementName;

            while (bElementexists)
            {
                bElementexists = _xElementContainer.hasByName(_sElementName);
                if (bElementexists)
                {
                    i            += 1;
                    _sElementName = BaseName + i;
                }
            }
            return(_sElementName);
        }
コード例 #6
0
        public virtual string GetOpenOfficeProperty(string nodePath, string node)
        {
            if (!nodePath.StartsWith("/"))
            {
                nodePath = "/" + nodePath;
            }
            Any property;

            // create the provider and remember it as a XMultiServiceFactory
            try
            {
                const string         sProviderService = "com.sun.star.configuration.ConfigurationProvider";
                object               configProvider   = _connection.RemoteServiceManager.createInstanceWithContext(sProviderService, _connection.ComponentContext);
                XMultiServiceFactory xConfigProvider  = (XMultiServiceFactory)configProvider;

                // The service name: Need only read access:
                const string sReadOnlyView = "com.sun.star.configuration.ConfigurationAccess";
                // creation arguments: nodepath
                PropertyValue aPathArgument = new PropertyValue
                {
                    Name  = "nodepath",
                    Value = new Any(nodePath)
                };
                Any[] aArguments = new Any[1];
                aArguments[0] = aPathArgument.Value;

                // create the view
                //XInterface xElement = (XInterface) xConfigProvider.createInstanceWithArguments(sReadOnlyView, aArguments);
                XNameAccess xChildAccess = (XNameAccess)xConfigProvider.createInstanceWithArguments(sReadOnlyView, aArguments);

                // get the value
                property = xChildAccess.getByName(node);
            }
            catch (Exception exception)
            {
                throw new OpenOfficeException("Could not retrieve property", exception);
            }
            return(property.ToString());
        }
 /// <summary>
 /// Makes a String unique by appending a numerical suffix.
 /// </summary>
 /// <param name="_xElementContainer">the com.sun.star.container.XNameAccess container
 /// that the new Element is going to be inserted to</param>
 /// <param name="_sElementName"the StemName of the Element.</param>
 /// <returns>A String unique by appending a numerical suffix</returns>
 public static String createUniqueName(XNameAccess _xElementContainer, String _sElementName)
 {
     bool bElementexists = true;
     int i = 1;
     String BaseName = _sElementName;
     while (bElementexists)
     {
         bElementexists = _xElementContainer.hasByName(_sElementName);
         if (bElementexists)
         {
             i += 1;
             _sElementName = BaseName + i;
         }
     }
     return _sElementName;
 }
コード例 #8
0
        /// <summary>
        /// Gets all named elements of the object.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="debug">if set to <c>true</c> the named children will be printed
        /// to the System.Diagnostics.Debug output.</param>
        /// <returns>
        /// A dictionary with the named elements. The name is the key an the value
        /// is set as uno.Any. You can access the real value by using uno.Any.Value
        /// </returns>
        public static Dictionary<string, uno.Any> GetAllNamedElements(XNameAccess obj, bool debug = true)
        {
            Dictionary<string, uno.Any> elements = new Dictionary<string, uno.Any>();
            if (obj != null)
            {
                string[] names = obj.getElementNames();

                if (debug)
                    System.Diagnostics.Debug.WriteLine("Object [" + obj + "] has " + names.Length + " Properties:");

                foreach (var name in names)
                {

                    uno.Any element = obj.getByName(name);
                    elements.Add(name, element);

                    if (debug)
                        try
                        {
                            System.Diagnostics.Debug.WriteLine("\tProperty: " + name + " = " + element);
                        }
                        catch (System.Exception)
                        {
                            System.Diagnostics.Debug.WriteLine("Can't get property - " + name);
                        }

                }

            }
            return elements;
        }
コード例 #9
0
 /// <summary>
 /// Gets a named property of an XNameAccess object.
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <param name="propName">Name of the property.</param>
 /// <returns>The property or null</returns>
 public static Object GetNamedProperty(XNameAccess obj, String propName)
 {
     Object prop = null;
     if (obj != null)
     {
         if (obj.hasByName(propName))
         {
             prop = obj.getByName(propName);
         }
     }
     return prop;
 }