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

From Apache OpenOffice Wiki
Jump to: navigation, search
(Initial author Sun Microsystems, Inc.)
 
 
(5 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
|NextPage=Documentation/DevGuide/UCB/Folders
 
|NextPage=Documentation/DevGuide/UCB/Folders
 
}}
 
}}
{{DISPLAYTITLE:Setting Content Properties}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/UCB/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:Setting Content Properties}}
 
A UCB content maintains a set of properties. It supports the command "<code>setPropertyValues</code>", that is used to set one or more property values of a content. This command takes a sequence of <idl>com.sun.star.beans.PropertyValue</idl> and returns void. To set property values of a UCB content:
 
A UCB content maintains a set of properties. It supports the command "<code>setPropertyValues</code>", that is used to set one or more property values of a content. This command takes a sequence of <idl>com.sun.star.beans.PropertyValue</idl> and returns void. To set property values of a UCB content:
  
Line 15: Line 16:
 
Setting property values of a UCB content:  
 
Setting property values of a UCB content:  
 
<!--[SOURCE:UCB/PropertiesComposer.java]-->
 
<!--[SOURCE:UCB/PropertiesComposer.java]-->
 
+
<syntaxhighlight 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 49:
 
       }
 
       }
 
   }
 
   }
 
+
</syntaxhighlight>
 
{{PDL1}}
 
{{PDL1}}
[[Category: Universal Content Broker]]
+
 
 +
[[Category:Documentation/Developer's Guide/Universal Content Broker]]

Latest revision as of 16:10, 21 December 2020



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
In other languages