To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=52509
                  Issue #:|52509
                  Summary:|Problem with setting date through automation
                Component:|api
                  Version:|OOo 1.1.4
                 Platform:|All
                      URL:|
               OS/Version:|Windows 2000
                   Status:|UNCONFIRMED
        Status whiteboard:|
                 Keywords:|
               Resolution:|
               Issue type:|DEFECT
                 Priority:|P3
             Subcomponent:|code
              Assigned to:|sw
              Reported by:|bovlk





------- Additional comments from [EMAIL PROTECTED] Tue Jul 26 14:32:50 -0700 
2005 -------
Fourth, I tried to automatically create StarCalc documents with the following
C-code in Visual C++ 6

Code:

static HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp,
LPOLESTR ptName, int cArgs, ...)
{ // This code was copied from 
http://www.oooforum.org/forum/viewtopic.phtml?t=9815
  // with only minor changes
   /* Variables used... */
   va_list marker;
   DISPPARAMS dp = { NULL, NULL, 0, 0 };
   DISPID dispidNamed = DISPID_PROPERTYPUT;
   DISPID dispID;
   HRESULT hr;
   char szName[200];
   /* Allocate memory for arguments, should be on the safe-side with mul 100 */
   VARIANT *pArgs = (VARIANT *)malloc(sizeof(VARIANT) * 100);
   int i = 0;

   va_start(marker, cArgs);
   
   if(!pDisp) return -1;

   /* Convert down to ANSI */
   WideCharToMultiByte(CP_ACP, 0, ptName, -1, szName, 256, NULL, NULL);
   /* Get DISPID for name passed... */
   pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);   
     
   /* Extract arguments... */
   for(i=0; i<cArgs; i++)
      pArgs[i] = va_arg(marker, VARIANT);

   /* Build DISPPARAMS */
   dp.cArgs = cArgs;
   dp.rgvarg = pArgs;

   /* Handle special-case for property-puts! */
   if(autoType & DISPATCH_PROPERTYPUT) {
     dp.cNamedArgs = 1;
     dp.rgdispidNamedArgs = &dispidNamed;
   }

   /* Make the call! */
   hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &dp,
pvResult, NULL, NULL);   

//   char buffer[256];
//   FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0, hr, 0, buffer,
sizeof(buffer), 0);
//   MessageBox( 0, buffer, "Bla", MB_OK);

   if(FAILED(hr)) return hr;

   va_end(marker);
   free(pArgs);

   return hr;
}

// This is a function for statements
// of the type "Set cell name XXXX to YYYY"
// in which we want to ignore errors
// Possibly, it will show debug messages
void IGNORE_COM_ERRORS( IDispatch *pSheet, const TCHAR *name, VARIANT value)
{
  if (!pSheet || !name) return;

  IDispatch *pCell;
  VARIANT result;
  VARIANT parm[1];
  HRESULT h1;
     
  VariantInit(&parm[0]);
  parm[0].vt = VT_BSTR | VT_BYREF;
  _bstr_t cbs = name;
  BSTR bs = SysAllocString(cbs);
  parm[0].pbstrVal = &bs;

  h1=AutoWrap(DISPATCH_METHOD, &result, pSheet, L"getCellRangeByName", 1, 
parm[0]);
  pCell = result.pdispVal;
  VariantClear( &parm[0]);
  if (pCell && SUCCEEDED(h1))
     if (SUCCEEDED(AutoWrap(DISPATCH_METHOD, &result, pCell, L"setFormula", 1,
value))) return;

  if (bDebugTemplate) {
     CString s;
     s.Format( cLanguageInfo->pLang->msgDebug, name);
     MessageBox( 0, s, cLanguageInfo->pLang->msgDebugCaption, MB_OK |
MB_ICONINFORMATION);
  }
}

void IGNORE_COM_ERRORS( IDispatch *pSheet, const TCHAR *name, DATE value)
{
  VARIANT val;
  VariantInit( &val);
  val.vt = VT_DATE | VT_BYREF;
  val.pdate = &value;
  IGNORE_COM_ERRORS( pSheet, name, val);
}

main( ) {
  COleDateTime dt1( trans->when);
  COleDateTime dt2( 2005, 8, 3, 0, 0, 0);

  IGNORE_COM_ERRORS( pSheet, _T("DateIssue"), (DATE)dt2);
}


Well, this results in the month and day being swapped, ie. OOO reporst March
8th, 2005 instead of August 3rd, 2005.

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

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


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

Reply via email to