Back to index

lightning-sunbird  0.9+nobinonly
IEHtmlDocument.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Adam Lock <adamlock@eircom.net>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #include "stdafx.h"
00039 #include "IEHtmlDocument.h"
00040 #include "IEHtmlElementCollection.h"
00041 #include "IEHtmlElement.h"
00042 
00043 #include "nsIDOMHTMLDocument.h"
00044 #include "nsIDOMNSHTMLDocument.h"
00045 #include "nsIDOMNSDocument.h"
00046 
00047 #include "MozillaBrowser.h"
00048 
00049 #include "IEHtmlSelectionObject.h"
00050 
00051 CIEHtmlDocument::CIEHtmlDocument() :
00052     mControl(NULL)
00053 {
00054 }
00055 
00056 
00057 CIEHtmlDocument::~CIEHtmlDocument()
00058 {
00059 }
00060 
00061 
00062 void CIEHtmlDocument::SetParent(CMozillaBrowser *parent)
00063 {
00064     mControl = parent;
00065 }
00066 
00067 
00068 void CIEHtmlDocument::SetNative(nsIDOMHTMLDocument *native)
00069 {
00070     mDOMDocument = native;
00071 }
00072 
00073 
00075 // IHTMLDocument methods
00076 
00077 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_Script(IDispatch __RPC_FAR *__RPC_FAR *p)
00078 {
00079     return E_NOTIMPL;
00080 }
00081 
00083 // IHTMLDocument2 methods
00084 
00085 struct HtmlPos
00086 {
00087     CComQIPtr<IHTMLElementCollection> m_cpCollection;
00088     long m_nPos;
00089 
00090     HtmlPos(IHTMLElementCollection *pCol, long nPos) :
00091         m_cpCollection(pCol),
00092         m_nPos(nPos)
00093     {
00094     }
00095 };
00096 
00097 
00098 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_all(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
00099 {
00100     // Validate parameters
00101     if (p == NULL)
00102     {
00103         return E_INVALIDARG;
00104     }
00105 
00106     *p = NULL;
00107 
00108     // Get all elements
00109     CIEHtmlElementCollectionInstance *pCollection = NULL;
00110     CIEHtmlElementCollection::CreateFromParentNode(this, TRUE, (CIEHtmlElementCollection **) &pCollection);
00111     if (pCollection)
00112     {
00113         pCollection->QueryInterface(IID_IHTMLElementCollection, (void **) p);
00114     }
00115 
00116     return S_OK;
00117 }
00118 
00119 
00120 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_body(IHTMLElement __RPC_FAR *__RPC_FAR *p)
00121 {
00122     // Validate parameters
00123     if (p == NULL)
00124     {
00125         return E_INVALIDARG;
00126     }
00127     *p = NULL;
00128 
00129     nsCOMPtr<nsIDOMHTMLElement> bodyElement;
00130 
00131     mDOMDocument->GetBody(getter_AddRefs(bodyElement));
00132     if (bodyElement)
00133     {
00134         nsCOMPtr<nsIDOMNode> bodyNode = do_QueryInterface(bodyElement);
00135 
00136         // get or create com object:
00137         CComPtr<IUnknown> pNode;
00138         HRESULT hr = CIEHtmlDomNode::FindOrCreateFromDOMNode(bodyNode, &pNode);
00139         if (FAILED(hr))
00140             return hr;
00141         if (FAILED(pNode->QueryInterface(IID_IHTMLElement, (void **)p)))
00142             return E_UNEXPECTED;
00143     }
00144 
00145     return S_OK;
00146 }
00147 
00148 
00149 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_activeElement(IHTMLElement __RPC_FAR *__RPC_FAR *p)
00150 {
00151     *p = NULL;
00152     return E_NOTIMPL;
00153 }
00154 
00155 
00156 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_images(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
00157 {
00158     // Validate parameters
00159     if (p == NULL)
00160     {
00161         return E_INVALIDARG;
00162     }
00163 
00164     *p = NULL;
00165 
00166     nsCOMPtr<nsIDOMHTMLCollection> nodeList;
00167     mDOMDocument->GetImages(getter_AddRefs(nodeList));
00168 
00169     // Get all elements
00170     CIEHtmlElementCollectionInstance *pCollection = NULL;
00171     CIEHtmlElementCollection::CreateFromDOMHTMLCollection(this, nodeList, (CIEHtmlElementCollection **) &pCollection);
00172     if (pCollection)
00173     {
00174         pCollection->QueryInterface(IID_IHTMLElementCollection, (void **) p);
00175     }
00176 
00177     return S_OK;
00178 }
00179 
00180 
00181 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_applets(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
00182 {
00183     // Validate parameters
00184     if (p == NULL)
00185     {
00186         return E_INVALIDARG;
00187     }
00188 
00189     *p = NULL;
00190 
00191     nsCOMPtr<nsIDOMHTMLCollection> nodeList;
00192     mDOMDocument->GetApplets(getter_AddRefs(nodeList));
00193 
00194     // Get all elements
00195     CIEHtmlElementCollectionInstance *pCollection = NULL;
00196     CIEHtmlElementCollection::CreateFromDOMHTMLCollection(this, nodeList, (CIEHtmlElementCollection **) &pCollection);
00197     if (pCollection)
00198     {
00199         pCollection->QueryInterface(IID_IHTMLElementCollection, (void **) p);
00200     }
00201 
00202     return S_OK;
00203 }
00204 
00205 
00206 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_links(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
00207 {
00208     // Validate parameters
00209     if (p == NULL)
00210     {
00211         return E_INVALIDARG;
00212     }
00213 
00214     *p = NULL;
00215 
00216     nsCOMPtr<nsIDOMHTMLCollection> nodeList;
00217     mDOMDocument->GetLinks(getter_AddRefs(nodeList));
00218 
00219     // Get all elements
00220     CIEHtmlElementCollectionInstance *pCollection = NULL;
00221     CIEHtmlElementCollection::CreateFromDOMHTMLCollection(this, nodeList, (CIEHtmlElementCollection **) &pCollection);
00222     if (pCollection)
00223     {
00224         pCollection->QueryInterface(IID_IHTMLElementCollection, (void **) p);
00225     }
00226 
00227     return S_OK;
00228 }
00229 
00230 
00231 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_forms(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
00232 {
00233     // Validate parameters
00234     if (p == NULL)
00235     {
00236         return E_INVALIDARG;
00237     }
00238 
00239     *p = NULL;
00240 
00241     nsCOMPtr<nsIDOMHTMLCollection> nodeList;
00242     mDOMDocument->GetForms(getter_AddRefs(nodeList));
00243 
00244     // Get all elements
00245     CIEHtmlElementCollectionInstance *pCollection = NULL;
00246     CIEHtmlElementCollection::CreateFromDOMHTMLCollection(this, nodeList, (CIEHtmlElementCollection **) &pCollection);
00247     if (pCollection)
00248     {
00249         pCollection->QueryInterface(IID_IHTMLElementCollection, (void **) p);
00250     }
00251 
00252     return S_OK;
00253 }
00254 
00255 
00256 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_anchors(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
00257 {
00258     // Validate parameters
00259     if (p == NULL)
00260     {
00261         return E_INVALIDARG;
00262     }
00263 
00264     *p = NULL;
00265 
00266     nsCOMPtr<nsIDOMHTMLCollection> nodeList;
00267     mDOMDocument->GetAnchors(getter_AddRefs(nodeList));
00268 
00269     // Get all elements
00270     CIEHtmlElementCollectionInstance *pCollection = NULL;
00271     CIEHtmlElementCollection::CreateFromDOMHTMLCollection(this, nodeList, (CIEHtmlElementCollection **) &pCollection);
00272     if (pCollection)
00273     {
00274         pCollection->QueryInterface(IID_IHTMLElementCollection, (void **) p);
00275     }
00276 
00277     return S_OK;
00278 }
00279 
00280 
00281 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_title(BSTR v)
00282 {
00283     if (mDOMDocument)
00284     {
00285         nsAutoString newTitle((PRUnichar *) v);
00286         mDOMDocument->SetTitle(newTitle);
00287     }
00288     return S_OK;
00289 }
00290 
00291 
00292 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_title(BSTR __RPC_FAR *p)
00293 {
00294     nsAutoString value;
00295     if (mDOMDocument == NULL || mDOMDocument->GetTitle(value))
00296     {
00297         return E_FAIL;
00298     }
00299     *p = SysAllocString(value.get()); 
00300     return p ? S_OK : E_OUTOFMEMORY;
00301 }
00302 
00303 
00304 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_scripts(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
00305 {
00306     *p = NULL;
00307     return E_NOTIMPL;
00308 }
00309 
00310 
00311 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_designMode(BSTR v)
00312 {
00313     return E_NOTIMPL;
00314 }
00315 
00316 
00317 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_designMode(BSTR __RPC_FAR *p)
00318 {
00319     *p = NULL;
00320     return E_NOTIMPL;
00321 }
00322 
00323 
00324 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_selection(IHTMLSelectionObject __RPC_FAR *__RPC_FAR *p)
00325 {
00326     if (p == NULL)
00327     {
00328         return E_INVALIDARG;
00329     }
00330     *p = NULL;
00331 
00332     // create com object:
00333     CIEHtmlSelectionObjectInstance *pSelectionObject = NULL;
00334     CIEHtmlSelectionObjectInstance::CreateInstance(&pSelectionObject);
00335     if (!pSelectionObject)
00336         return E_FAIL;
00337     // get selection:
00338     nsCOMPtr<nsIDOMWindow> domWindow;
00339     mControl->GetDOMWindow(getter_AddRefs(domWindow));
00340     if (!domWindow)
00341         return E_FAIL;
00342     nsCOMPtr<nsISelection> selection;
00343     domWindow->GetSelection(getter_AddRefs(selection));
00344     if (!selection)
00345         return E_FAIL;
00346     // gives the selection to the com object:
00347     pSelectionObject->SetSelection(selection);
00348     nsCOMPtr<nsIDOMDocumentRange> domDocumentRange = do_QueryInterface(mDOMDocument);
00349     pSelectionObject->SetDOMDocumentRange(domDocumentRange);
00350     // return com object:
00351     pSelectionObject->QueryInterface(IID_IHTMLSelectionObject, (void **)p);
00352 
00353     return S_OK;
00354 }
00355 
00356 
00357 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_readyState(BSTR __RPC_FAR *p)
00358 {
00359     *p = NULL;
00360     return E_NOTIMPL;
00361 }
00362 
00363 
00364 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_frames(IHTMLFramesCollection2 __RPC_FAR *__RPC_FAR *p)
00365 {
00366     *p = NULL;
00367     return E_NOTIMPL;
00368 }
00369 
00370 
00371 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_embeds(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
00372 {
00373     // Validate parameters
00374     if (p == NULL)
00375     {
00376         return E_INVALIDARG;
00377     }
00378     *p = NULL;
00379 
00380     nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mDOMDocument);
00381     if (!htmlDoc)
00382         return E_FAIL;
00383 
00384     nsCOMPtr<nsIDOMHTMLCollection> nodeList;
00385     htmlDoc->GetEmbeds(getter_AddRefs(nodeList));
00386 
00387     // Get all elements
00388     CIEHtmlElementCollectionInstance *pCollection = NULL;
00389     CIEHtmlElementCollection::CreateFromDOMHTMLCollection(this, nodeList, (CIEHtmlElementCollection **) &pCollection);
00390     if (pCollection)
00391     {
00392         pCollection->QueryInterface(IID_IHTMLElementCollection, (void **) p);
00393     }
00394 
00395     return S_OK;
00396 }
00397 
00398 
00399 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_plugins(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
00400 {
00401     *p = NULL;
00402     return E_NOTIMPL;
00403 }
00404 
00405 #define IMPL_SET_COLOR(name, v) \
00406     CComVariant vStr; \
00407     if (FAILED(::VariantChangeType(&vStr, &v, 0, VT_BSTR))) \
00408         return E_INVALIDARG; \
00409     if (!mDOMDocument) \
00410         return E_UNEXPECTED; \
00411     nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mDOMDocument); \
00412     if (!htmlDoc) \
00413         return E_FAIL; \
00414     USES_CONVERSION; \
00415     nsAutoString val(OLE2W(vStr.bstrVal)); \
00416     htmlDoc->Set ## name(val); \
00417     return S_OK;
00418 
00419 #define IMPL_GET_COLOR(name, v) \
00420     if (p == NULL) return E_INVALIDARG; \
00421     if (!mDOMDocument) return E_UNEXPECTED; \
00422     nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mDOMDocument); \
00423     if (!htmlDoc) return E_FAIL; \
00424     USES_CONVERSION; \
00425     nsAutoString val; \
00426     htmlDoc->Get ## name(val); \
00427     p->vt = VT_BSTR; \
00428     p->bstrVal = ::SysAllocString(W2COLE(val.get())); \
00429     return S_OK;
00430 
00431 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_alinkColor(VARIANT v)
00432 {
00433     IMPL_SET_COLOR(AlinkColor, v);
00434 }
00435 
00436 
00437 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_alinkColor(VARIANT __RPC_FAR *p)
00438 {
00439     IMPL_GET_COLOR(AlinkColor, p);
00440 }
00441 
00442 
00443 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_bgColor(VARIANT v)
00444 {
00445     IMPL_SET_COLOR(BgColor, v);
00446 }
00447 
00448 
00449 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_bgColor(VARIANT __RPC_FAR *p)
00450 {
00451     IMPL_GET_COLOR(BgColor, p);
00452 }
00453 
00454 
00455 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_fgColor(VARIANT v)
00456 {
00457     IMPL_SET_COLOR(FgColor, v);
00458 }
00459 
00460 
00461 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_fgColor(VARIANT __RPC_FAR *p)
00462 {
00463     IMPL_GET_COLOR(FgColor, p);
00464 }
00465 
00466 
00467 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_linkColor(VARIANT v)
00468 {
00469     IMPL_SET_COLOR(LinkColor, v);
00470 }
00471 
00472 
00473 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_linkColor(VARIANT __RPC_FAR *p)
00474 {
00475     IMPL_GET_COLOR(LinkColor, p);
00476 }
00477 
00478 
00479 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_vlinkColor(VARIANT v)
00480 {
00481     IMPL_SET_COLOR(VlinkColor, v);
00482 }
00483 
00484 
00485 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_vlinkColor(VARIANT __RPC_FAR *p)
00486 {
00487     IMPL_GET_COLOR(VlinkColor, p);
00488 }
00489 
00490 
00491 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_referrer(BSTR __RPC_FAR *p)
00492 {
00493     *p = NULL;
00494     return E_NOTIMPL;
00495 }
00496 
00497 
00498 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_location(IHTMLLocation __RPC_FAR *__RPC_FAR *p)
00499 {
00500     *p = NULL;
00501     return E_NOTIMPL;
00502 }
00503 
00504 
00505 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_lastModified(BSTR __RPC_FAR *p)
00506 {
00507     if (p == NULL)
00508     {
00509         return E_INVALIDARG;
00510     }
00511     *p = NULL;
00512     if (!mDOMDocument)
00513     {
00514         return E_UNEXPECTED;
00515     }
00516     nsCOMPtr<nsIDOMNSDocument> doc = do_QueryInterface(mDOMDocument);
00517     if (!doc)
00518     {
00519         return E_FAIL;
00520     }
00521     USES_CONVERSION;
00522     nsAutoString val;
00523     doc->GetLastModified(val);
00524     *p = ::SysAllocString(W2COLE(val.get()));
00525     return S_OK;
00526 }
00527 
00528 
00529 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_URL(BSTR v)
00530 {
00531     return E_NOTIMPL;
00532 }
00533 
00534 
00535 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_URL(BSTR __RPC_FAR *p)
00536 {
00537     *p = NULL;
00538     return E_NOTIMPL;
00539 }
00540 
00541 
00542 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_domain(BSTR v)
00543 {
00544     return E_NOTIMPL;
00545 }
00546 
00547 
00548 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_domain(BSTR __RPC_FAR *p)
00549 {
00550     *p = NULL;
00551     return E_NOTIMPL;
00552 }
00553 
00554 
00555 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_cookie(BSTR v)
00556 {
00557     return E_NOTIMPL;
00558 }
00559 
00560 
00561 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_cookie(BSTR __RPC_FAR *p)
00562 {
00563     if (!p)
00564         return E_INVALIDARG;
00565     *p = NULL;
00566 
00567     nsAutoString strCookie;
00568     nsresult rv = mDOMDocument->GetCookie(strCookie);
00569     NS_ENSURE_SUCCESS(rv,rv);
00570     *p = SysAllocString(strCookie.get());
00571     return (*p) ? S_OK : E_OUTOFMEMORY;
00572 }
00573 
00574 
00575 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_expando(VARIANT_BOOL v)
00576 {
00577     return E_NOTIMPL;
00578 }
00579 
00580 
00581 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_expando(VARIANT_BOOL __RPC_FAR *p)
00582 {
00583     *p = NULL;
00584     return E_NOTIMPL;
00585 }
00586 
00587 
00588 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_charset(BSTR v)
00589 {
00590     return E_NOTIMPL;
00591 }
00592 
00593 
00594 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_charset(BSTR __RPC_FAR *p)
00595 {
00596     *p = NULL;
00597     return E_NOTIMPL;
00598 }
00599 
00600 
00601 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_defaultCharset(BSTR v)
00602 {
00603     return E_NOTIMPL;
00604 }
00605 
00606 
00607 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_defaultCharset(BSTR __RPC_FAR *p)
00608 {
00609     *p = NULL;
00610     return E_NOTIMPL;
00611 }
00612 
00613 
00614 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_mimeType(BSTR __RPC_FAR *p)
00615 {
00616     *p = NULL;
00617     return E_NOTIMPL;
00618 }
00619 
00620 
00621 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_fileSize(BSTR __RPC_FAR *p)
00622 {
00623     *p = NULL;
00624     return E_NOTIMPL;
00625 }
00626 
00627 
00628 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_fileCreatedDate(BSTR __RPC_FAR *p)
00629 {
00630     *p = NULL;
00631     return E_NOTIMPL;
00632 }
00633 
00634 
00635 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_fileModifiedDate(BSTR __RPC_FAR *p)
00636 {
00637     *p = NULL;
00638     return E_NOTIMPL;
00639 }
00640 
00641 
00642 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_fileUpdatedDate(BSTR __RPC_FAR *p)
00643 {
00644     *p = NULL;
00645     return E_NOTIMPL;
00646 }
00647 
00648 
00649 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_security(BSTR __RPC_FAR *p)
00650 {
00651     *p = NULL;
00652     return E_NOTIMPL;
00653 }
00654 
00655 
00656 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_protocol(BSTR __RPC_FAR *p)
00657 {
00658     *p = NULL;
00659     return E_NOTIMPL;
00660 }
00661 
00662 
00663 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_nameProp(BSTR __RPC_FAR *p)
00664 {
00665     *p = NULL;
00666     return E_NOTIMPL;
00667 }
00668 
00669 
00670 HRESULT CIEHtmlDocument::WriteCommon(SAFEARRAY __RPC_FAR * psarray, int bLn)
00671 {
00672     if (psarray->cDims != 1)
00673     {
00674         return E_INVALIDARG;
00675     }
00676     if (!(psarray->fFeatures & (FADF_BSTR | FADF_VARIANT)))
00677     {
00678         return E_INVALIDARG;
00679     }
00680 
00681     HRESULT hr;
00682 
00683     hr = SafeArrayLock(psarray);
00684     if (FAILED(hr))
00685     {
00686         return hr;
00687     }
00688 
00689     for (DWORD i = 0; i < psarray->rgsabound[0].cElements; i++)
00690     {
00691         nsAutoString str;
00692         if (psarray->fFeatures & FADF_BSTR)
00693         {
00694             USES_CONVERSION;
00695             BSTR *bstrArray = (BSTR *) psarray->pvData;
00696             str = OLE2W(bstrArray[i]);
00697         }
00698         else if (psarray->fFeatures & FADF_VARIANT)
00699         {
00700             USES_CONVERSION;
00701             VARIANT *vArray = (VARIANT *) psarray->pvData;
00702             VARIANT vStr;
00703             VariantInit(&vStr);
00704             hr = VariantChangeType(&vStr, &vArray[i], 0, VT_BSTR);
00705             if (FAILED(hr))
00706             {
00707                 SafeArrayUnlock(psarray);
00708                 return hr;
00709             }
00710             str = OLE2W(vStr.bstrVal);
00711             VariantClear(&vStr);
00712         }
00713 
00714         if (bLn && !i)
00715         {
00716             if (mDOMDocument->Writeln(str))
00717             {
00718                 SafeArrayUnlock(psarray);
00719                 return E_FAIL;
00720             }
00721         }
00722         else
00723         {
00724             if (mDOMDocument->Write(str))
00725             {
00726                 SafeArrayUnlock(psarray);
00727                 return E_FAIL;
00728             }
00729         }
00730     }
00731     
00732     hr = SafeArrayUnlock(psarray);
00733     if (FAILED(hr))
00734     {
00735         return hr;
00736     }
00737 
00738     return S_OK;
00739 }
00740 
00741 
00742 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::write(SAFEARRAY __RPC_FAR * psarray)
00743 {
00744        return WriteCommon(psarray, 0);
00745 }
00746 
00747 
00748 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::writeln(SAFEARRAY __RPC_FAR * psarray)
00749 {
00750       return WriteCommon(psarray, 1);
00751 }
00752 
00753 
00754 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::open(BSTR url, VARIANT name, VARIANT features, VARIANT replace, IDispatch __RPC_FAR *__RPC_FAR *pomWindowResult)
00755 {
00756     if (mDOMDocument == NULL || mDOMDocument->Open())
00757     {
00758         return E_FAIL;
00759     }
00760     return S_OK;
00761 }
00762 
00763 
00764 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::close(void)
00765 {
00766     if (mDOMDocument == NULL || mDOMDocument->Close())
00767     {
00768         return E_FAIL;
00769     }
00770     return S_OK;
00771 }
00772 
00773 
00774 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::clear(void)
00775 {
00776     return E_NOTIMPL;
00777 }
00778 
00779 
00780 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::queryCommandSupported(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
00781 {
00782     return E_NOTIMPL;
00783 }
00784 
00785 
00786 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::queryCommandEnabled(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
00787 {
00788     return E_NOTIMPL;
00789 }
00790 
00791 
00792 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::queryCommandState(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
00793 {
00794     return E_NOTIMPL;
00795 }
00796 
00797 
00798 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::queryCommandIndeterm(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
00799 {
00800     return E_NOTIMPL;
00801 }
00802 
00803 
00804 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::queryCommandText(BSTR cmdID, BSTR __RPC_FAR *pcmdText)
00805 {
00806     return E_NOTIMPL;
00807 }
00808 
00809 
00810 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::queryCommandValue(BSTR cmdID, VARIANT __RPC_FAR *pcmdValue)
00811 {
00812     return E_NOTIMPL;
00813 }
00814 
00815 
00816 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::execCommand(BSTR cmdID, VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL __RPC_FAR *pfRet)
00817 {
00818     return E_NOTIMPL;
00819 }
00820 
00821 
00822 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::execCommandShowHelp(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
00823 {
00824     return E_NOTIMPL;
00825 }
00826 
00827 
00828 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::createElement(BSTR eTag, IHTMLElement __RPC_FAR *__RPC_FAR *newElem)
00829 {
00830     return E_NOTIMPL;
00831 }
00832 
00833 
00834 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onhelp(VARIANT v)
00835 {
00836     return E_NOTIMPL;
00837 }
00838 
00839 
00840 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onhelp(VARIANT __RPC_FAR *p)
00841 {
00842     return E_NOTIMPL;
00843 }
00844 
00845 
00846 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onclick(VARIANT v)
00847 {
00848     return E_NOTIMPL;
00849 }
00850 
00851 
00852 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onclick(VARIANT __RPC_FAR *p)
00853 {
00854     return E_NOTIMPL;
00855 }
00856 
00857 
00858 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_ondblclick(VARIANT v)
00859 {
00860     return E_NOTIMPL;
00861 }
00862 
00863 
00864 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_ondblclick(VARIANT __RPC_FAR *p)
00865 {
00866     return E_NOTIMPL;
00867 }
00868 
00869 
00870 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onkeyup(VARIANT v)
00871 {
00872     return E_NOTIMPL;
00873 }
00874 
00875 
00876 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onkeyup(VARIANT __RPC_FAR *p)
00877 {
00878     return E_NOTIMPL;
00879 
00880 }
00881 
00882 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onkeydown(VARIANT v)
00883 {
00884     return E_NOTIMPL;
00885 }
00886 
00887 
00888 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onkeydown(VARIANT __RPC_FAR *p)
00889 {
00890     return E_NOTIMPL;
00891 }
00892 
00893 
00894 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onkeypress(VARIANT v)
00895 {
00896     return E_NOTIMPL;
00897 }
00898 
00899 
00900 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onkeypress(VARIANT __RPC_FAR *p)
00901 {
00902     return E_NOTIMPL;
00903 }
00904 
00905 
00906 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onmouseup(VARIANT v)
00907 {
00908     return E_NOTIMPL;
00909 }
00910 
00911 
00912 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onmouseup(VARIANT __RPC_FAR *p)
00913 {
00914     return E_NOTIMPL;
00915 }
00916 
00917 
00918 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onmousedown(VARIANT v)
00919 {
00920     return E_NOTIMPL;
00921 }
00922 
00923 
00924 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onmousedown(VARIANT __RPC_FAR *p)
00925 {
00926     return E_NOTIMPL;
00927 }
00928 
00929 
00930 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onmousemove(VARIANT v)
00931 {
00932     return E_NOTIMPL;
00933 }
00934 
00935 
00936 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onmousemove(VARIANT __RPC_FAR *p)
00937 {
00938     return E_NOTIMPL;
00939 }
00940 
00941 
00942 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onmouseout(VARIANT v)
00943 {
00944     return E_NOTIMPL;
00945 }
00946 
00947 
00948 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onmouseout(VARIANT __RPC_FAR *p)
00949 {
00950     return E_NOTIMPL;
00951 }
00952 
00953 
00954 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onmouseover(VARIANT v)
00955 {
00956     return E_NOTIMPL;
00957 }
00958 
00959 
00960 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onmouseover(VARIANT __RPC_FAR *p)
00961 {
00962     return E_NOTIMPL;
00963 }
00964 
00965 
00966 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onreadystatechange(VARIANT v)
00967 {
00968     return E_NOTIMPL;
00969 }
00970 
00971 
00972 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onreadystatechange(VARIANT __RPC_FAR *p)
00973 {
00974     return E_NOTIMPL;
00975 }
00976 
00977 
00978 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onafterupdate(VARIANT v)
00979 {
00980     return E_NOTIMPL;
00981 }
00982 
00983 
00984 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onafterupdate(VARIANT __RPC_FAR *p)
00985 {
00986     return E_NOTIMPL;
00987 }
00988 
00989 
00990 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onrowexit(VARIANT v)
00991 {
00992     return E_NOTIMPL;
00993 }
00994 
00995 
00996 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onrowexit(VARIANT __RPC_FAR *p)
00997 {
00998     return E_NOTIMPL;
00999 }
01000 
01001 
01002 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onrowenter(VARIANT v)
01003 {
01004     return E_NOTIMPL;
01005 }
01006 
01007 
01008 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onrowenter(VARIANT __RPC_FAR *p)
01009 {
01010     return E_NOTIMPL;
01011 }
01012 
01013 
01014 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_ondragstart(VARIANT v)
01015 {
01016     return E_NOTIMPL;
01017 }
01018 
01019 
01020 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_ondragstart(VARIANT __RPC_FAR *p)
01021 {
01022     return E_NOTIMPL;
01023 }
01024 
01025 
01026 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onselectstart(VARIANT v)
01027 {
01028     return E_NOTIMPL;
01029 }
01030 
01031 
01032 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onselectstart(VARIANT __RPC_FAR *p)
01033 {
01034     return E_NOTIMPL;
01035 }
01036 
01037 
01038 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::elementFromPoint(long x, long y, IHTMLElement __RPC_FAR *__RPC_FAR *elementHit)
01039 {
01040     return E_NOTIMPL;
01041 }
01042 
01043 
01044 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_parentWindow(IHTMLWindow2 __RPC_FAR *__RPC_FAR *p)
01045 {
01046     return E_NOTIMPL;
01047 }
01048 
01049 
01050 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_styleSheets(IHTMLStyleSheetsCollection __RPC_FAR *__RPC_FAR *p)
01051 {
01052     return E_NOTIMPL;
01053 }
01054 
01055 
01056 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onbeforeupdate(VARIANT v)
01057 {
01058     return E_NOTIMPL;
01059 }
01060 
01061 
01062 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onbeforeupdate(VARIANT __RPC_FAR *p)
01063 {
01064     return E_NOTIMPL;
01065 }
01066 
01067 
01068 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_onerrorupdate(VARIANT v)
01069 {
01070     return E_NOTIMPL;
01071 }
01072 
01073 
01074 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_onerrorupdate(VARIANT __RPC_FAR *p)
01075 {
01076     return E_NOTIMPL;
01077 }
01078 
01079 
01080 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::toString(BSTR __RPC_FAR *String)
01081 {
01082     return E_NOTIMPL;
01083 }
01084 
01085 
01086 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::createStyleSheet(BSTR bstrHref, long lIndex, IHTMLStyleSheet __RPC_FAR *__RPC_FAR *ppnewStyleSheet)
01087 {
01088     return E_NOTIMPL;
01089 }
01090 
01091 
01093 // IOleCommandTarget implementation
01094 
01095 
01096 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::QueryStatus(const GUID __RPC_FAR *pguidCmdGroup, ULONG cCmds, OLECMD __RPC_FAR prgCmds[], OLECMDTEXT __RPC_FAR *pCmdText)
01097 {
01098     HRESULT hr = E_NOTIMPL;
01099     if(mControl)
01100     {
01101         hr = mControl->QueryStatus(pguidCmdGroup,cCmds,prgCmds,pCmdText);
01102     }
01103     return hr;
01104 }
01105 
01106 
01107 HRESULT STDMETHODCALLTYPE CIEHtmlDocument::Exec(const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT __RPC_FAR *pvaIn, VARIANT __RPC_FAR *pvaOut)
01108 {
01109     HRESULT hr = E_NOTIMPL;
01110     if(mControl)
01111     {
01112         hr = mControl->Exec(pguidCmdGroup,nCmdID,nCmdexecopt,pvaIn,pvaOut);
01113     }
01114     return hr;
01115 }
01116