X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ed5317e538f5d3d7b2731b1e4248137f014139a6..ebe47451544561fbe6e57808d604641d24109359:/src/msw/ole/automtn.cpp?ds=sidebyside diff --git a/src/msw/ole/automtn.cpp b/src/msw/ole/automtn.cpp index 063f4c4c7e..d0185644ae 100644 --- a/src/msw/ole/automtn.cpp +++ b/src/msw/ole/automtn.cpp @@ -6,10 +6,10 @@ // Created: 11/6/98 // RCS-ID: $Id$ // Copyright: (c) 1998, Julian Smart -// Licence: wxWindows Licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "automtn.h" #endif @@ -24,22 +24,32 @@ // Watcom C++ gives a linker error if this is compiled in. // With Borland C++, all samples crash if this is compiled in. -#if wxUSE_OLE &&!defined(__WATCOMC__) && !(defined(__BORLANDC__) && (__BORLANDC__ < 0x520)) && !defined(__CYGWIN10__) +#if wxUSE_OLE && !(defined(__BORLANDC__) && (__BORLANDC__ < 0x520)) && !defined(__CYGWIN10__) #define _FORCENAMELESSUNION #include "wx/log.h" +#include "wx/msw/private.h" #include "wx/msw/ole/oleutils.h" #include "wx/msw/ole/automtn.h" -#include "wx/msw/private.h" #include + +#ifdef __WXWINCE__ +#include "wx/msw/wince/time.h" +#else #include +#endif #include #include + #include #define _huge + +#ifndef __WXWINCE__ #include +#endif + #include // Verifies will fail if the needed buffer size is too large @@ -54,7 +64,9 @@ static int rgMonthDays[13] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; -#if wxUSE_TIMEDATE +#if wxUSE_DATETIME +#include "wx/datetime.h" + static BOOL OleDateFromTm(WORD wYear, WORD wMonth, WORD wDay, WORD wHour, WORD wMinute, WORD wSecond, DATE& dtDest); static BOOL TmFromOleDate(DATE dtSrc, struct tm& tmDest); @@ -587,7 +599,7 @@ bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant) { oleVariant.vt = VT_BOOL; // 'bool' required for VC++ 4 apparently -#if defined(__WATCOMC__) || (defined(__VISUALC__) && (__VISUALC__ <= 1000)) +#if (defined(__VISUALC__) && (__VISUALC__ <= 1000)) oleVariant.bool = variant.GetBool(); #else oleVariant.boolVal = variant.GetBool(); @@ -600,7 +612,8 @@ bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant) oleVariant.bstrVal = wxConvertStringToOle(str); } // For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled -#if wxUSE_TIMEDATE && !defined(__WATCOMC__) +// Now obsolete +#if 0 // wxUSE_TIMEDATE && !defined(__WATCOMC__) else if (type == wxT("date")) { wxDate date( variant.GetDate() ); @@ -619,6 +632,17 @@ bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant) time.GetHour(), time.GetMinute(), time.GetSecond(), oleVariant.date)) return FALSE; } +#endif +#if wxUSE_DATETIME + else if (type == wxT("datetime")) + { + wxDateTime date( variant.GetDateTime() ); + oleVariant.vt = VT_DATE; + + if (!OleDateFromTm(date.GetYear(), date.GetMonth(), date.GetDay(), + date.GetHour(), date.GetMinute(), date.GetSecond(), oleVariant.date)) + return FALSE; + } #endif else if (type == wxT("void*")) { @@ -695,15 +719,14 @@ bool wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant) } case VT_DATE: { -#if wxUSE_TIMEDATE +#if wxUSE_DATETIME struct tm tmTemp; if (!TmFromOleDate(oleVariant.date, tmTemp)) return FALSE; - wxDate date(tmTemp.tm_yday, tmTemp.tm_mon, tmTemp.tm_year); - wxTime time(date, tmTemp.tm_hour, tmTemp.tm_min, tmTemp.tm_sec); + wxDateTime date(tmTemp.tm_yday, (wxDateTime::Month) tmTemp.tm_mon, tmTemp.tm_year, tmTemp.tm_hour, tmTemp.tm_min, tmTemp.tm_sec); - variant = time; + variant = date; #endif break; @@ -721,7 +744,7 @@ bool wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant) case VT_BOOL: { -#if defined(__WATCOMC__) || (defined(_MSC_VER) && (_MSC_VER <= 1000) && !defined(__MWERKS__) ) //GC +#if (defined(_MSC_VER) && (_MSC_VER <= 1000) && !defined(__MWERKS__) ) //GC #ifndef HAVE_BOOL // Can't use bool operator if no native bool type variant = (long) (oleVariant.bool != 0); #else @@ -926,7 +949,6 @@ BOOL TmFromOleDate(DATE dtSrc, struct tm& tmDest) if (dtSrc > MAX_DATE || dtSrc < MIN_DATE) // about year 100 to about 9999 return FALSE; - long nDays; // Number of days since Dec. 30, 1899 long nDaysAbsolute; // Number of days since 1/1/0 long nSecsInDay; // Time in seconds since midnight long nMinutesInDay; // Minutes in day @@ -941,9 +963,6 @@ BOOL TmFromOleDate(DATE dtSrc, struct tm& tmDest) double dblDate = dtSrc; // tempory serial date - // If a valid date, then this conversion should not overflow - nDays = (long)dblDate; - // Round to the second dblDate += ((dtSrc > 0.0) ? HALF_SECOND : -HALF_SECOND); @@ -1030,7 +1049,8 @@ BOOL TmFromOleDate(DATE dtSrc, struct tm& tmDest) // Month number always >= n/32, so save some loop time */ for (tmDest.tm_mon = (n4Day >> 5) + 1; - n4Day > rgMonthDays[tmDest.tm_mon]; tmDest.tm_mon++); + n4Day > rgMonthDays[tmDest.tm_mon]; tmDest.tm_mon++) + ; tmDest.tm_mday = (int)(n4Day - rgMonthDays[tmDest.tm_mon-1]); @@ -1238,5 +1258,5 @@ void ShowException(LPOLESTR szMember, HRESULT hr, EXCEPINFO *pexcep, unsigned in #endif -#endif // __WATCOMC__ +#endif // wxUSE_OLE && !(defined(__BORLANDC__) && (__BORLANDC__ < 0x520)) && !defined(__CYGWIN10__)