예제 #1
0
void Exceptions::load(ProgressIndicator* progressIndicator)
{
    DatabasePtr db = getDatabase();
    MetadataLoader* loader = db->getMetadataLoader();
    MetadataLoaderTransaction tr(loader);
    wxMBConv* converter = db->getCharsetConverter();

    IBPP::Statement& st1 = loader->getStatement(
        Exception::getLoadStatement(true));

    CollectionType exceptions;
    st1->Execute();
    checkProgressIndicatorCanceled(progressIndicator);
    while (st1->Fetch())
    {
        if (!st1->IsNull(1))
        {
            std::string s;
            st1->Get(1, s);
            wxString name(std2wxIdentifier(s, converter));

            ExceptionPtr exception = findByName(name);
            if (!exception)
            {
                exception.reset(new Exception(db, name));
                initializeLockCount(exception, getLockCount());
            }
            exceptions.push_back(exception);
            exception->loadProperties(st1, converter);
        }
        checkProgressIndicatorCanceled(progressIndicator);
    }

    setItems(exceptions);
}
예제 #2
0
 	Collection* generate() {
 		CollectionType *result = new CollectionType(numa::util::MmapAllocator<T>(thisBase()->from()));
 		result->reserve(thisBase()->elements());
 		for (int i = 0; i < thisBase()->elements(); i++) {
 			result->push_back(thisBase()->construct());
 		}
 		return new Collection(result);
 	}
예제 #3
0
 	void migrate(Collection *c) {
 		// build new collection, with newly constructed members
 		CollectionType *newcol = new CollectionType(numa::util::MmapAllocator<T>(thisBase()->to()));
 		CollectionType &old = **c;
 		newcol->reserve(old.size());
 		
		for (size_t i = 0; i < old.size(); i++) {
 			newcol->push_back(T(old[i]));
 		}
 		
 		delete *c;
 		*c = newcol;
 	}
예제 #4
0
OleProperties::OleProperties(OleStorage& storage) :
   m_pStorage(storage), m_wCodePage(ENCODING_NONE)
{     
   USES_CONVERSION;
   
   IPropertySetStoragePtr spPropertySetStorage(storage.GetInternalObject());

   IPropertyStorage* pPropertyStorage = 0;
   HRESULT hr = spPropertySetStorage->Open(FMTID_UserDefinedProperties, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &pPropertyStorage);
   if(STG_E_FILENOTFOUND == hr)
      return;

   if(FAILED(hr))  
   {
      std::wostringstream os; 
      os << L"Failed to open the user defined property set" << FMTID_UserDefinedProperties << std::ends; 
      LOG_WS_INFO(os.str().c_str());
      return;
   }

   IPropertyStoragePtr spPropertyStorage(pPropertyStorage, false);

   IEnumSTATPROPSTG* pEnumProp = 0;	
	hr = spPropertyStorage->Enum(&pEnumProp);
	if(FAILED(hr))  // if fails, it is an Office bug
   {
      std::wostringstream os; 
      os << _T("Failed to get an IEnumSTATPROPSTG enumerator from the property set. PropertySet ID:[") << FMTID_UserDefinedProperties << _T("]. Continue process as this is not critical.") << std::ends; 
      LOG_WS_INFO(os.str().c_str());
      return;
   }
	
   SetCodePageProperty(spPropertyStorage);

   CollectionType collection;
   try
   {
      IEnumSTATPROPSTGPtr spEnumProp(pEnumProp, false);

      STATPROPSTG propertyInfo;
	   ZeroMemory(&propertyInfo, sizeof(STATPROPSTG));   
      hr = pEnumProp->Next(1, &propertyInfo, NULL);  

      while(S_OK == hr)
      {
         PROPVARIANT propertyVariant;  
         PropVariantInit(&propertyVariant);		
         PROPSPEC propSpec;
         ZeroMemory(&propSpec, sizeof(PROPSPEC));
         propSpec.ulKind = PRSPEC_PROPID;
         propSpec.propid = propertyInfo.propid;

         // Read this property.
         hr = spPropertyStorage->ReadMultiple(1, &propSpec, &propertyVariant);
         if(SUCCEEDED(hr))
         {		   		   
            bool visibleInExplorer = false;
            switch(propertyVariant.vt)
            {
            case VT_LPSTR:
            case VT_FILETIME:
            case VT_I4:
            case VT_BOOL:
               visibleInExplorer = true;
            }

            std::wstring name; 
            if(propertyInfo.lpwstrName != 0)
               name = W2T(propertyInfo.lpwstrName);

            std::wstring value;

            if(PIDSI_EDITTIME == propSpec.propid)
               value =FiletimeAsTimeSpan(propertyVariant);
            else
			{
				if (m_wCodePage == ENCODING_UTF8 && propertyVariant.vt == VT_LPSTR)
					value = ConvertPropertyFromUTF8(propertyVariant.pszVal);
				else
					value = (LPCTSTR)PropVariantToString(propertyVariant);
			}

            collection.push_back(new OleProperty(OlePropertySetGroupUserProperties, propSpec.propid, name, value, visibleInExplorer));
         }		      
         hr = pEnumProp->Next(1, &propertyInfo, NULL);
      }
      
      m_collection = collection;
   }
   catch(...)
   {
      for(CollectionType::iterator i = collection.begin(); i != collection.end(); i++)
         delete *i;

      std::wostringstream os; 
      os << _T("Failed to read a property. PropertySet ID:[") << FMTID_UserDefinedProperties  << _T("]. Continue process as this is not critical.") << std::ends; 
      LOG_WS_INFO(os.str().c_str());
   }
}