void COPropertySet::Read(IPropertySetStorage* pPropSetStg)
    { if( NULL!=pPropSetStg )
      { COMPtr<IPropertyStorage> pPropStg;
        COMPtr<IEnumSTATPROPSTG> pEnum;
        HRESULT                  hr = S_OK;
        STATPROPSTG              statpropstg;
        PROPSPEC                 propSpec;

        THROW_COMEXCEPTION( pPropSetStg->Open( m_fmtid, STGM_READ|STGM_SHARE_EXCLUSIVE,&pPropStg ) );
        THROW_COMEXCEPTION( pPropStg->Enum( &pEnum ) );

        statpropstg.lpwstrName = NULL;

        hr = pEnum->Next( 1, &statpropstg, NULL );
        THROW_COMEXCEPTION( hr );

        for( ;S_OK==hr; )
        { COPropVariant propValue;

          propSpec.ulKind = PRSPEC_PROPID;
          propSpec.propid = statpropstg.propid;

          const PROPVARIANT* p = propValue;

          THROW_COMEXCEPTION( pPropStg->ReadMultiple( 1, &propSpec, const_cast<PROPVARIANT*>(p) ) );

          PROPERTYMAP::iterator propIter = m_properties.find(propSpec.propid);

          if( m_properties.empty() || propIter==m_properties.end() )
            m_properties.insert( PROPERTYPAIR(propSpec.propid,propValue) );
          else
            propIter->second = propValue;

          if( NULL!=statpropstg.lpwstrName )
            AddPropertyName(propSpec.propid,statpropstg.lpwstrName);

          statpropstg.lpwstrName = NULL;

          hr = pEnum->Next( 1, &statpropstg, NULL );
          THROW_COMEXCEPTION( hr );
        } // of for

        PROPID propid = PID_DICTIONARY;

        if( NULL!=m_readFriendlySetName )
          ::CoTaskMemFree( m_readFriendlySetName );

        TCHAR* pwszFriendlyName = NULL;
        
        m_readFriendlySetName = NULL;

        if( SUCCEEDED(pPropStg->ReadPropertyNames( 1, &propid, &m_readFriendlySetName)) )
          m_friendlySetName = m_readFriendlySetName;
      } // of if
    } // of COPropertySet::Read()
Beispiel #2
0
// extensions beyond IE's API
HashSet<String> ClipboardWin::types() const
{ 
    HashSet<String> results; 
    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
        return results;

    if (!m_dataObject)
        return results;

    COMPtr<IEnumFORMATETC> itr;

    if (FAILED(m_dataObject->EnumFormatEtc(0, &itr)))
        return results;

    if (!itr)
        return results;

    FORMATETC data;

    while (SUCCEEDED(itr->Next(1, &data, 0))) {
        addMimeTypesForFormat(results, data);
    }

    return results;
}
Beispiel #3
0
bool ClipboardWin::hasData()
{
    if (!m_dataObject && m_dragDataMap.isEmpty())
        return false;

    if (m_dataObject) {
        COMPtr<IEnumFORMATETC> itr;
        if (FAILED(m_dataObject->EnumFormatEtc(DATADIR_GET, &itr)))
            return false;

        if (!itr)
            return false;

        FORMATETC data;

        // IEnumFORMATETC::Next returns S_FALSE if there are no more items.
        if (itr->Next(1, &data, 0) == S_OK) {
            // There is at least one item in the IDataObject
            return true;
        }

        return false;
    }
    return !m_dragDataMap.isEmpty();
}
Beispiel #4
0
// extensions beyond IE's API
ListHashSet<String> ClipboardWin::types() const
{ 
    ListHashSet<String> results;
    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
        return results;

    if (!m_dataObject && m_dragDataMap.isEmpty())
        return results;

    if (m_dataObject) {
        COMPtr<IEnumFORMATETC> itr;

        if (FAILED(m_dataObject->EnumFormatEtc(DATADIR_GET, &itr)))
            return results;

        if (!itr)
            return results;

        FORMATETC data;

        // IEnumFORMATETC::Next returns S_FALSE if there are no more items.
        while (itr->Next(1, &data, 0) == S_OK)
            addMimeTypesForFormat(results, data);
    } else {
        for (DragDataMap::const_iterator it = m_dragDataMap.begin(); it != m_dragDataMap.end(); ++it) {
            FORMATETC data;
            data.cfFormat = (*it).key;
            addMimeTypesForFormat(results, data);
        }
    }

    return results;
}
Beispiel #5
0
// extensions beyond IE's API
HashSet<String> ClipboardWin::types() const
{ 
    HashSet<String> results; 
    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
        return results;

    if (!m_dataObject)
        return results;

    COMPtr<IEnumFORMATETC> itr;

    if (FAILED(m_dataObject->EnumFormatEtc(DATADIR_GET, &itr)))
        return results;

    if (!itr)
        return results;

    FORMATETC data;

    // IEnumFORMATETC::Next returns S_FALSE if there are no more items.
    while (itr->Next(1, &data, 0) == S_OK) {
        addMimeTypesForFormat(results, data);
    }

    return results;
}
Beispiel #6
0
void WebEditorClient::checkGrammarOfString(const UChar* text, int length, Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
{
    details.clear();
    *badGrammarLocation = -1;
    *badGrammarLength = 0;

    COMPtr<IWebEditingDelegate> ed;
    if (FAILED(m_webView->editingDelegate(&ed)) || !ed.get())
        return;

    initViewSpecificSpelling(m_webView);
    COMPtr<IEnumWebGrammarDetails> enumDetailsObj;
    if (FAILED(ed->checkGrammarOfString(m_webView, text, length, &enumDetailsObj, badGrammarLocation, badGrammarLength)))
        return;

    while (true) {
        ULONG fetched;
        COMPtr<IWebGrammarDetail> detailObj;
        if (enumDetailsObj->Next(1, &detailObj, &fetched) != S_OK)
            break;

        GrammarDetail detail;
        if (FAILED(detailObj->length(&detail.length)))
            continue;
        if (FAILED(detailObj->location(&detail.location)))
            continue;
        BSTR userDesc;
        if (FAILED(detailObj->userDescription(&userDesc)))
            continue;
        detail.userDescription = String(userDesc, SysStringLen(userDesc));
        SysFreeString(userDesc);

        COMPtr<IEnumSpellingGuesses> enumGuessesObj;
        if (FAILED(detailObj->guesses(&enumGuessesObj)))
            continue;
        while (true) {
            BSTR guess;
            if (enumGuessesObj->Next(1, &guess, &fetched) != S_OK)
                break;
            detail.guesses.append(String(guess, SysStringLen(guess)));
            SysFreeString(guess);
        }

        details.append(detail);
    }
}
Beispiel #7
0
static wstring dumpFramesAsText(IWebFrame* frame)
{
    if (!frame)
        return L"";

    COMPtr<IDOMDocument> document;
    if (FAILED(frame->DOMDocument(&document)))
        return L"";

    COMPtr<IDOMElement> documentElement;
    if (FAILED(document->documentElement(&documentElement)))
        return L"";

    wstring result;

    // Add header for all but the main frame.
    COMPtr<IWebFrame> parent;
    if (FAILED(frame->parentFrame(&parent)))
        return L"";
    if (parent) {
        BSTR name = L"";
        if (FAILED(frame->name(&name)))
            return L"";

        result.append(L"\n--------\nFrame: '");
        result.append(name ? name : L"", SysStringLen(name));
        result.append(L"'\n--------\n");

        SysFreeString(name);
    }

    BSTR innerText = 0;
    COMPtr<IDOMElementPrivate> docPrivate;
    if (SUCCEEDED(documentElement->QueryInterface(&docPrivate)))
        docPrivate->innerText(&innerText);

    result.append(innerText ? innerText : L"", SysStringLen(innerText));
    result.append(L"\n");

    SysFreeString(innerText);

    if (::gLayoutTestController->dumpChildFramesAsText()) {
        COMPtr<IEnumVARIANT> enumKids;
        if (FAILED(frame->childFrames(&enumKids)))
            return L"";
        VARIANT var;
        VariantInit(&var);
        while (enumKids->Next(1, &var, 0) == S_OK) {
            ASSERT(V_VT(&var) == VT_UNKNOWN);
            COMPtr<IWebFrame> framePtr;
            V_UNKNOWN(&var)->QueryInterface(IID_IWebFrame, (void**)&framePtr);
            result.append(dumpFramesAsText(framePtr.get()));
            VariantClear(&var);
        }
    }

    return result;
}
  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& os, IPropertySetStorage *pPropSetStg)
  { COMPtr<IEnumSTATPROPSETSTG> penum;
    HRESULT                     hr = S_OK;
    STATPROPSETSTG              statpropsetstg;

    THROW_COMEXCEPTION( pPropSetStg->Enum( &penum ) );

    ::memset( &statpropsetstg, 0, sizeof(statpropsetstg) );

    hr = penum->Next( 1, &statpropsetstg, NULL );
    THROW_COMEXCEPTION( hr );

    while( S_OK==hr )
    { { auto_ptr<COM::COPropertySet> pPropertySet(new COM::COPropertySet(statpropsetstg.fmtid));

        pPropertySet->Read(pPropSetStg);

        os<<*pPropertySet;
      }

      hr = penum->Next( 1, &statpropsetstg, NULL );
      THROW_COMEXCEPTION( hr );
    } // of while

    try
    { auto_ptr<COM::COPropertySet> pPropertySet(new COM::COPropertySet(FMTID_UserDefinedProperties));

      pPropertySet->Read(pPropSetStg);

      os<<*pPropertySet;
    }
    catch(...)
    { }

    return os;
  } // of basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& os, IPropertySetStorage *pPropSetStg)
Beispiel #9
0
const DragDataMap& DragData::dragDataMap()
{
    if (!m_dragDataMap.isEmpty() || !m_platformDragData)
        return m_dragDataMap;
    // Enumerate clipboard content and load it in the map.
    COMPtr<IEnumFORMATETC> itr;

    if (FAILED(m_platformDragData->EnumFormatEtc(DATADIR_GET, &itr)) || !itr)
        return m_dragDataMap;

    FORMATETC dataFormat;
    while (itr->Next(1, &dataFormat, 0) == S_OK) {
        Vector<String> dataStrings;
        getClipboardData(m_platformDragData, &dataFormat, dataStrings);
        if (!dataStrings.isEmpty())
            m_dragDataMap.set(dataFormat.cfFormat, dataStrings);
    }
    return m_dragDataMap;
}
Beispiel #10
0
void dumpFrameScrollPosition(IWebFrame* frame)
{
    if (!frame)
        return;

    COMPtr<IWebFramePrivate> framePrivate;
    if (FAILED(frame->QueryInterface(&framePrivate)))
        return;

    SIZE scrollPosition;
    if (FAILED(framePrivate->scrollOffset(&scrollPosition)))
        return;

    if (abs(scrollPosition.cx) > 0.00000001 || abs(scrollPosition.cy) > 0.00000001) {
        COMPtr<IWebFrame> parent;
        if (FAILED(frame->parentFrame(&parent)))
            return;
        if (parent) {
            BSTR name;
            if (FAILED(frame->name(&name)))
                return;
            printf("frame '%S' ", name ? name : L"");
            SysFreeString(name);
        }
        printf("scrolled to %.f,%.f\n", (double)scrollPosition.cx, (double)scrollPosition.cy);
    }

    if (::gLayoutTestController->dumpChildFrameScrollPositions()) {
        COMPtr<IEnumVARIANT> enumKids;
        if (FAILED(frame->childFrames(&enumKids)))
            return;
        VARIANT var;
        VariantInit(&var);
        while (enumKids->Next(1, &var, 0) == S_OK) {
            ASSERT(V_VT(&var) == VT_UNKNOWN);
            COMPtr<IWebFrame> framePtr;
            V_UNKNOWN(&var)->QueryInterface(IID_IWebFrame, (void**)&framePtr);
            dumpFrameScrollPosition(framePtr.get());
            VariantClear(&var);
        }
    }
}
Beispiel #11
0
void WebEditorClient::getGuessesForWord(const String& word, const String& context, const VisibleSelection&, Vector<String>& guesses)
{
    guesses.clear();

    COMPtr<IWebEditingDelegate> ed;
    if (FAILED(m_webView->editingDelegate(&ed)) || !ed.get())
        return;

    COMPtr<IEnumSpellingGuesses> enumGuessesObj;
    if (FAILED(ed->guessesForWord(BString(word), &enumGuessesObj)))
        return;

    while (true) {
        ULONG fetched;
        BString guess;
        if (enumGuessesObj->Next(1, &guess, &fetched) != S_OK)
            break;
        guesses.append(String(guess, SysStringLen(guess)));
    }
}
Beispiel #12
0
bool ClipboardWin::hasData()
{
    if (!m_dataObject)
        return false;

    COMPtr<IEnumFORMATETC> itr;
    if (FAILED(m_dataObject->EnumFormatEtc(0, &itr)))
        return false;

    if (!itr)
        return false;

    FORMATETC data;

    if (SUCCEEDED(itr->Next(1, &data, 0))) {
        // There is at least one item in the IDataObject
        return true;
    }

    return false;
}
Beispiel #13
0
LanguageManager::LanguageManager()
{
    COMPtr<IMultiLanguage> multiLanguage;
    if (FAILED(::CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_INPROC_SERVER, IID_IMultiLanguage, reinterpret_cast<LPVOID*>(&multiLanguage))))
        return;

    COMPtr<IEnumCodePage> enumInterface;
    if (FAILED(multiLanguage->EnumCodePages(MIMECONTF_BROWSER, &enumInterface)))
        return;

    MIMECPINFO cpInfo;
    ULONG ccpInfo;
    while (SUCCEEDED(enumInterface->Next(1, &cpInfo, &ccpInfo)) && ccpInfo) {
        if (!IsValidCodePage(cpInfo.uiCodePage))
            continue;

        HashMap<UINT, CString>::iterator i = codePageCharsets().find(cpInfo.uiCodePage);

        CString name(String(cpInfo.wszWebCharset).latin1());
        if (i == codePageCharsets().end()) {
            CharsetInfo info;
            info.m_codePage = cpInfo.uiCodePage;
            knownCharsets().set(name.data(), info);
            i = codePageCharsets().set(cpInfo.uiCodePage, name).iterator;
        }
        if (i != codePageCharsets().end()) {
            HashMap<String, CharsetInfo>::iterator j = knownCharsets().find(String(i->value.data(), i->value.length()));
            ASSERT(j != knownCharsets().end());
            CharsetInfo& info = j->value;
            info.m_name = i->value.data();
            info.m_friendlyName = cpInfo.wszDescription;
            info.m_aliases.append(name);
            info.m_aliases.append(String(cpInfo.wszHeaderCharset).latin1());
            info.m_aliases.append(String(cpInfo.wszBodyCharset).latin1());
            String cpName = "cp" + String::number(cpInfo.uiCodePage);
            info.m_aliases.append(cpName.latin1());
            supportedCharsets().add(i->value.data());
        }
    }
}
  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& os, IStorage *pStg)
  { COMPtr<IPropertySetStorage> pPropSetStg;
    COMPtr<IEnumSTATSTG>        penum;
    HRESULT                     hr = S_OK;
    STATSTG                     statstg;
    int                         indent;

    LogStream<TCHAR>* logger = dynamic_cast< LogStream<TCHAR>* >(&os);
    
    if( NULL!=logger )
      indent = logger->GetIndent();

    ::memset( &statstg, 0, sizeof(statstg) );

    THROW_COMEXCEPTION( pStg->QueryInterface( IID_IPropertySetStorage,reinterpret_cast<void**>(&pPropSetStg) ) );

    os<<pPropSetStg;

    THROW_COMEXCEPTION( pStg->EnumElements( NULL, NULL, NULL, &penum ) );

    hr = penum->Next( 1, &statstg, 0 );
    THROW_COMEXCEPTION( hr );

    while( S_OK == hr )
    { 
      if( NULL!=logger )
        logger->SetIndent(indent);

      { if( STGTY_STORAGE==statstg.type )
          os<<_T("[");

        if( statstg.pwcsName[0]>_T('\x20') )
          os<<statstg.pwcsName;
        else
          os<<_T("'\\x")<<hex<<setw(2)<<setfill(_T('0'))<<(UINT)(statstg.pwcsName[0])<<_T("'")<<statstg.pwcsName+1;

        if( STGTY_STORAGE==statstg.type )
          os<<_T("]");

        if( _T('\005')==statstg.pwcsName[0] )
        { GUID fmtid;

          if( COM::COPropertySet::PropertySetNameToGuid(_tcslen(statstg.pwcsName),statstg.pwcsName,&fmtid) )
            os<<_T(" --> FMTID=")<<((const TString&)CGUID(fmtid)).c_str();
        } // of if

        os<<endl;
      } // of if

      if( STGTY_STORAGE==statstg.type && _T('\005')!=statstg.pwcsName[0] )
      { COMPtr<IStorage> pStgChild;

        THROW_COMEXCEPTION( pStg->OpenStorage( statstg.pwcsName,NULL,STGM_READ | STGM_SHARE_EXCLUSIVE,NULL, 0,&pStgChild ) );

        if( logger!=NULL )
          logger->SetIndent(indent+1);

        os<<pStgChild;
      } // of if

      ::CoTaskMemFree( statstg.pwcsName );
      statstg.pwcsName = NULL;

      hr = penum->Next( 1, &statstg, 0 );
      THROW_COMEXCEPTION( hr );
    } // of while
    
    return os;
  } // of basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& os, IStorage *pStg)