Donaueschingen, den 28.06.2007


Dear OpenOffice-Team,

I try to develop an application which generates an new document for 'Writer'
and fill it with informations. In the same project I must search
textfields(input) and read the content, value, name and instanceName
but I don't know how realize.

//************************************ Sample code 
************************************************

static String ouStrConvToStr(const OUString &enter){
   OString firstStepOStr;
   enter.convertToString(&firstStepOStr, 1, RTL_UNICODETOTEXT_FLAGS_FLUSH);
   String s= firstStepOStr;
   return s;
   };

...
   Reference<XTextDocument>        thisDoc         ( dat->xcomponent, UNO_QUERY 
);        // XText
   Reference<XMultiServiceFactory> thisDocFact     ( thisDoc, UNO_QUERY );      
          // MxDocFactory
   Reference<XTextFieldsSupplier>  thisDocSupp     ( thisDoc, UNO_QUERY );      
          // XDocumentSupplierer
   Reference<XEnumerationAccess>   thisDocEnumAcc  = 
thisDocSupp->getTextFields();        // getEnumeration
   Reference<XEnumeration>         thisDocEnnm     = 
thisDocEnumAcc->createEnumeration(); // create Enum
   Reference<XNameAccess>          enumMst         = 
thisDocSupp->getTextFieldMasters();  // create an Name Access
   Sequence<OUString>              enumMstSequ     = 
enumMst->getElementNames();          // create an Array with all fileds

   /// -------------- Don't know if it is right 
-----------------------------------------
   for (int x = 0; x< enumMstSequ.getLength(); x++){                            
          // start loop
      const OUString&  txtField = enumMstSequ[x];                               
          // fill the string with the value of the sequence

      String newText = ouStrConvToStr(txtField);
      String end = newText.removeLastToken(SDOT,true);                          
          // own function: that removes i.e. 'field' from 
'com.sun.star.text.FieldMaster.User.field'

      if ( !newText.isEqualCaseIndep("com.sun.star.text.FieldMaster.User"))     
          // own function: compare two strings and ignore if they are the same 
(case independent)
         continue;


      Reference<XInterface>oMasterPropSet          ( 
thisDocFact->createInstance (
           OUString::createFromAscii(newText)));                                
          // create a new instance-interface
      Reference<XPropertySet>propertySet           ( oMasterPropSet, 
UNO_QUERY);          // access the XPropertySet
      Reference<XPropertySetInfo>propertySetInf    ( 
propertySet->getPropertySetInfo() ); // access the XPropertySetInfo
      Sequence<Property> propert                   = 
propertySetInf->getProperties(  ) ;  // get all properties from this textfield

      for (int r = 0; r < propert.getLength(); r++){
         Property & myproperty = propert[r];                                    
          // fill the property

     /// ------------ I try it only with OUString and Double, if anybody know 
how to do it
     /// with sal_Int32 or other types please sand me a sample!!! 
-----------------------

          const Any &a = propertySet->getPropertyValue(myproperty.Name);        
          // get the property and write it in the type Any

          cout << " Propertyname : " << ouStrConvToStr(myproperty.Name) << 
endl;          // write the name of the property
          cout << " Valuetype : " << ouStrConvToStr(a.getValueTypeName()) << 
endl;        // get the format from the type in the Any


            if( a.getValueTypeClass() == TypeClass_DOUBLE){                     
          // compare the format with the typeClass
               const double* d2 =  (const double*) a.getValue();                
          // make an hard cast from *void to *double
               if (d2)
                    cout << "   " << text << "Value : " << *d2 << endl;         
          // write out the value
               }

            if( a.getValueTypeClass() == TypeClass_STRING){                     
          // compare the format with the typeClass
               const OUString* str = reinterpret_cast < const OUString*  > 
(a.getValue());// make an hard cast from *void to *oustring
               if (str)
                  cout << "   " << text << "Value : " << ouStrConvToStr(*str) 
<< endl;    // write out the value
               }

         }

//************************************ Code End 
***************************************************

I use:

     > Microsoft Windows XP Professional SP2
     > Microsoft Visual Studio 2005 C++ Express Edition
     > OpenOffice.org 2.1 Software Development Kit (SDK)

I hope you can help me soon

best regards

Alexander Jaag
B&B Ingenieurgesellschaft mbH
Raiffeisenstr. 40, 78166 Donaueschingen
Tel: 0771 83 262-0   Fax: 0771 83 262-50
E-Mail: [EMAIL PROTECTED]
Homepage: www.bbsoft.de
Handelsregister Freiburg HRB 611358
Geschäftsführer: Dipl.Ing. Achim Bäuerle,  Dipl.Ing.(FH) Wolfgang Burgert

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

Antwort per Email an