Difference between revisions of "Documentation/DevGuide/UCB/Setting Content Properties"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (1 revision(s))
Line 15: Line 15:
 
Setting property values of a UCB content:  
 
Setting property values of a UCB content:  
 
<!--[SOURCE:UCB/PropertiesComposer.java]-->
 
<!--[SOURCE:UCB/PropertiesComposer.java]-->
 
+
  <source lang="java">
 
   import com.sun.star.ucb.*;
 
   import com.sun.star.ucb.*;
 
   import com.sun.star.beans.PropertyValue;
 
   import com.sun.star.beans.PropertyValue;
Line 48: Line 48:
 
       }
 
       }
 
   }
 
   }
 
+
  </source>
 
{{PDL1}}
 
{{PDL1}}
 
[[Category: Universal Content Broker]]
 
[[Category: Universal Content Broker]]

Revision as of 21:36, 14 March 2008



A UCB content maintains a set of properties. It supports the command "setPropertyValues", that is used to set one or more property values of a content. This command takes a sequence of com.sun.star.beans.PropertyValue and returns void. To set property values of a UCB content:

  •  ::Define a sequence of property values you want to set.
  •  ::Let the UCB content execute the command "setPropertyValues".

Note that the command is not aborted if one or more of the property values cannot be set, because the requested property is not supported by the content or because it is read-only. Currently, there is no other method to check if a property value was set successfully other than to obtain the property value after a set-operation. This may change when status information could be returned by the command "setPropertyValues".

Setting property values of a UCB content:

  import com.sun.star.ucb.*;
  import com.sun.star.beans.PropertyValue;
 
  {
      XContent xContent = ...
      String aNewTitle = "NewTitle";
 
      /////////////////////////////////////////////////////////////////////
      // Set value of the string property Title...
      /////////////////////////////////////////////////////////////////////
 
      // Define property value sequence.
 
      PropertyValue[] aProps = new PropertyValue[ 1 ];
      PropertyValue aProp = new PropertyValue();
      aProp.Name = "Title";
      aProp.Handle = -1;// n/a
      aProp.Value = aNewTitle;
      aProps[0] = aProp;
 
      try {
          // Execute command "setPropertyValues".
          // using helper method executeCommand (see [CHAPTER:UCB.Using.Commands]).
          executeCommand(xContent, "setPropertyValues", aProps);
      }
      catch (com.sun.star.ucb.CommandAbortedException e) {
          ... error ...
      }
      catch (com.sun.star.uno.Exception e) {
          ... error ...
      }
  }
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools