Hello , 

You have helped me many times and now i need help again..I tried in the
previous posts to find it but i had no lack..
What i tried to do is change through java the value of a userfield..
That i have managed to do it..What is impossible is to update the field in
the document..
I have tried 2 ways but none of them works..

//The first method finds the name of userfield in the list and changes its
content.. Though nothing goes wrong and when i open the fields i can see the
new value , i don't see its value on the document..There i see the old value
not the new one..
/////////////////////////////////////////////////////////////////////////////
Here is my code

        XMultiServiceFactory xMultiServiceManager =
                (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, xComponent); 
        try{
            oUserField =
xMultiServiceManager.createInstance("com.sun.star.text.TextField.User");
        } catch(com.sun.star.uno.Exception e) {
            System.out.println(e);
        }
        xUserField =
(XDependentTextField)UnoRuntime.queryInterface(XDependentTextField.class, 
                    oUserField);

        try{
            oMasterPropSet =
xMultiServiceManager.createInstance("com.sun.star.text.FieldMaster.User");
        } catch(com.sun.star.uno.Exception e) {
            System.out.println(e);
        }

        XTextFieldsSupplier xTextFieldsSupplier =
(XTextFieldsSupplier)UnoRuntime.queryInterface(
                XTextFieldsSupplier.class, xComponent);
        // access the TextFields and the TextFieldMasters collections
        XNameAccess xNamedFieldMasters =
xTextFieldsSupplier.getTextFieldMasters();

        String[] fieldNames=xNamedFieldMasters.getElementNames();
        for (int ll=0;ll<fieldNames.length;ll++) {
          System.out.println("fieldNames[" + ll + "]" + fieldNames[ll]);
        } 
        
        
        for(int ll=0 ; ll<fields.length;ll++){
            ls_fullMasterName = fields[ll][0];
            ls_fullMasterValue = fields[ll][1];
            ls_fullMasterName  = "com.sun.star.text.FieldMaster.User." +
ls_fullMasterName;
            
            if (xNamedFieldMasters.hasByName(ls_fullMasterName)){ 
                Object oField;
                oField = xNamedFieldMasters.getByName(ls_fullMasterName);
                xMasterPropSet = (XPropertySet)UnoRuntime.queryInterface(
                        XPropertySet.class,oField); 
                xMasterPropSet.setPropertyValue("Content",
ls_fullMasterValue);
                xUserField.attachTextFieldMaster (xMasterPropSet);
            }
        }

THE CONTNENT HAS NEW VALUE BUT NOT THE DOCUMENT!!!!!!!!!!!!!!!!!!!

Another thing i tried is the following though 
////////////////////////////////////////////////////////////////
        
        XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class,
this.xComponent); 
        XController xController = xModel.getCurrentController();
        XDispatchProvider xDispatchProvider =
(XDispatchProvider)UnoRuntime.queryInterface(XDispatchProvider.class,
xController.getFrame());
        // Getting the Dispatch Helper 
        XMultiServiceFactory xMultiServiceManager =
                (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, xComponent); 
        
        Object oDispatchHelper = null; 
        try{ 
            oDispatchHelper = xMultiServiceManager.createInstance(
"com.sun.star.frame.DispatchHelper"); 
        } catch(com.sun.star.uno.Exception e) {
            
        } 
        XDispatchHelper xDispatchHelper = (XDispatchHelper)
UnoRuntime.queryInterface(XDispatchHelper.class,oDispatchHelper); 
        // Executing the commandURL 
        xDispatchHelper.executeDispatch(xDispatchProvider,
".uno:UpdateFields", "", 0, properties);

///////////////////////////////////////////////////////////////////////////////////////////////
But no lack either here..............................

I would be very grateful if you can give me a hint!!!!:-(
Thanks in advance
Ciao
-- 
View this message in context: 
http://www.nabble.com/UserFields-Does-not-Update-in-the-Document-Content-tp20833234p20833234.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to