Support unrar64.dll
[xy_vsfilter.git] / include / atl / atlhtml.h
blob4922e580def5bdbcd1c08acb43af0db681bb7e57
1 // This is a part of the Active Template Library.
2 // Copyright (C) Microsoft Corporation
3 // All rights reserved.
4 //
5 // This source code is only intended as a supplement to the
6 // Active Template Library Reference and related
7 // electronic documentation provided with the library.
8 // See these sources for detailed information regarding the
9 // Active Template Library product.
11 #ifndef __ATLHTML_H__
12 #define __ATLHTML_H__
14 #pragma once
16 #include <atlstr.h>
17 #include <atlsiface.h>
18 #include <atlconv.h>
22 #pragma pack(push,_ATL_PACKING)
23 namespace ATL {
25 #define TAGF_NONE 0
26 #define TAGF_HASEND 1
27 #define TAGF_BLOCK 2
30 struct ATL_HTML_TAG
32 LPCTSTR szTagName;
33 UINT uFlags;
36 enum ATL_HTML_TAGS {
37 ATL_HTML_TAG_BODY,
38 ATL_HTML_TAG_A,
39 ATL_HTML_TAG_B,
40 ATL_HTML_TAG_I,
41 ATL_HTML_TAG_U,
42 ATL_HTML_TAG_FONT,
43 ATL_HTML_TAG_IMG,
44 ATL_HTML_TAG_HR,
45 ATL_HTML_TAG_BR,
46 ATL_HTML_TAG_DIV,
47 ATL_HTML_TAG_BLOCKQUOTE,
48 ATL_HTML_TAG_ADDRESS,
49 ATL_HTML_TAG_P,
50 ATL_HTML_TAG_H1,
51 ATL_HTML_TAG_H2,
52 ATL_HTML_TAG_H3,
53 ATL_HTML_TAG_H4,
54 ATL_HTML_TAG_H5,
55 ATL_HTML_TAG_H6,
56 ATL_HTML_TAG_PRE,
57 ATL_HTML_TAG_Q,
58 ATL_HTML_TAG_SUB,
59 ATL_HTML_TAG_SUP,
60 ATL_HTML_TAG_INS,
61 ATL_HTML_TAG_DEL,
62 ATL_HTML_TAG_EM,
63 ATL_HTML_TAG_STRONG,
64 ATL_HTML_TAG_DFN,
65 ATL_HTML_TAG_CODE,
66 ATL_HTML_TAG_SAMP,
67 ATL_HTML_TAG_KBD,
68 ATL_HTML_TAG_VAR,
69 ATL_HTML_TAG_CITE,
70 ATL_HTML_TAG_ABBR,
71 ATL_HTML_TAG_ACRONYM,
72 ATL_HTML_TAG_OL,
73 ATL_HTML_TAG_UL,
74 ATL_HTML_TAG_LI,
75 ATL_HTML_TAG_DL,
76 ATL_HTML_TAG_DT,
77 ATL_HTML_TAG_DD,
78 ATL_HTML_TAG_TABLE,
79 ATL_HTML_TAG_TR,
80 ATL_HTML_TAG_TD,
81 ATL_HTML_TAG_FORM,
82 ATL_HTML_TAG_INPUT,
83 ATL_HTML_TAG_SELECT,
84 ATL_HTML_TAG_OPTION,
85 ATL_HTML_TAG_HEAD,
86 ATL_HTML_TAG_HTML,
87 ATL_HTML_TAG_MAP,
88 ATL_HTML_TAG_AREA,
89 ATL_HTML_TAG_BASE,
90 ATL_HTML_TAG_BDO,
91 ATL_HTML_TAG_BIG,
92 ATL_HTML_TAG_BUTTON,
93 ATL_HTML_TAG_IFRAME,
94 ATL_HTML_TAG_LABEL,
95 ATL_HTML_TAG_LINK,
96 ATL_HTML_TAG_META,
97 ATL_HTML_TAG_NOFRAMES,
98 ATL_HTML_TAG_NOSCRIPT,
99 ATL_HTML_TAG_COL,
100 ATL_HTML_TAG_COLGROUP,
101 ATL_HTML_TAG_FIELDSET,
102 ATL_HTML_TAG_LEGEND,
103 ATL_HTML_TAG_TBODY,
104 ATL_HTML_TAG_TEXTAREA,
105 ATL_HTML_TAG_TFOOT,
106 ATL_HTML_TAG_TH,
107 ATL_HTML_TAG_TITLE,
108 ATL_HTML_TAG_TT,
109 ATL_HTML_TAG_SMALL,
110 ATL_HTML_TAG_SPAN,
111 ATL_HTML_TAG_OBJECT,
112 ATL_HTML_TAG_PARAM,
113 ATL_HTML_TAG_LAST };
115 extern __declspec(selectany) const ATL_HTML_TAG s_tags[] =
117 { _T("body"), TAGF_HASEND | TAGF_BLOCK },
118 { _T("a"), TAGF_HASEND },
119 { _T("b"), TAGF_HASEND },
120 { _T("i"), TAGF_HASEND },
121 { _T("u"), TAGF_HASEND },
122 { _T("font"), TAGF_HASEND },
123 { _T("img"), TAGF_NONE },
124 { _T("hr"), TAGF_NONE },
125 { _T("br"), TAGF_NONE },
126 { _T("div"), TAGF_HASEND | TAGF_BLOCK },
127 { _T("blockquote"), TAGF_HASEND | TAGF_BLOCK },
128 { _T("adress"), TAGF_HASEND },
129 { _T("p"), TAGF_HASEND | TAGF_BLOCK },
130 { _T("h1"), TAGF_HASEND | TAGF_BLOCK},
131 { _T("h2"), TAGF_HASEND | TAGF_BLOCK},
132 { _T("h3"), TAGF_HASEND | TAGF_BLOCK },
133 { _T("h4"), TAGF_HASEND | TAGF_BLOCK },
134 { _T("h5"), TAGF_HASEND | TAGF_BLOCK },
135 { _T("h6"), TAGF_HASEND | TAGF_BLOCK },
136 { _T("pre"), TAGF_HASEND | TAGF_BLOCK },
137 { _T("q"), TAGF_HASEND },
138 { _T("sub"), TAGF_HASEND },
139 { _T("sup"), TAGF_HASEND },
140 { _T("ins"), TAGF_HASEND },
141 { _T("del"), TAGF_HASEND },
142 { _T("em"), TAGF_HASEND },
143 { _T("strong"), TAGF_HASEND },
144 { _T("dfn"), TAGF_HASEND },
145 { _T("code"), TAGF_HASEND },
146 { _T("samp"), TAGF_HASEND },
147 { _T("kbd"), TAGF_HASEND },
148 { _T("var"), TAGF_HASEND },
149 { _T("cite"), TAGF_HASEND },
150 { _T("abbr"), TAGF_HASEND },
151 { _T("acronym"), TAGF_HASEND },
152 { _T("ol"), TAGF_HASEND | TAGF_BLOCK },
153 { _T("ul"), TAGF_HASEND | TAGF_BLOCK },
154 { _T("li"), TAGF_HASEND },
155 { _T("dl"), TAGF_HASEND | TAGF_BLOCK },
156 { _T("dt"), TAGF_HASEND },
157 { _T("dd"), TAGF_HASEND },
158 { _T("table"), TAGF_HASEND },
159 { _T("tr"), TAGF_HASEND },
160 { _T("td"), TAGF_HASEND },
161 { _T("form"), TAGF_HASEND },
162 { _T("input"), TAGF_HASEND },
163 { _T("select"), TAGF_HASEND },
164 { _T("option"), TAGF_HASEND },
165 { _T("head"), TAGF_HASEND | TAGF_BLOCK },
166 { _T("html"), TAGF_HASEND | TAGF_BLOCK },
167 { _T("map"), TAGF_HASEND | TAGF_BLOCK },
168 { _T("area"), TAGF_BLOCK },
169 { _T("base"), TAGF_BLOCK },
170 { _T("bdo"), TAGF_HASEND },
171 { _T("big"), TAGF_HASEND },
172 { _T("button"), TAGF_HASEND },
173 { _T("iframe"), TAGF_HASEND },
174 { _T("label"), TAGF_HASEND },
175 { _T("link"), TAGF_NONE },
176 { _T("meta"), TAGF_BLOCK },
177 { _T("noframes"), TAGF_BLOCK },
178 { _T("noscript"), TAGF_BLOCK },
179 { _T("col"), TAGF_BLOCK },
180 { _T("colgroup"), TAGF_HASEND | TAGF_BLOCK },
181 { _T("fieldset"), TAGF_HASEND | TAGF_BLOCK },
182 { _T("legend"), TAGF_HASEND | TAGF_BLOCK },
183 { _T("tbody"), TAGF_HASEND | TAGF_BLOCK },
184 { _T("textarea"), TAGF_HASEND | TAGF_BLOCK },
185 { _T("tfoot"), TAGF_HASEND | TAGF_BLOCK },
186 { _T("th"), TAGF_HASEND | TAGF_BLOCK },
187 { _T("title"), TAGF_HASEND | TAGF_BLOCK },
188 { _T("tt"), TAGF_HASEND },
189 { _T("small"), TAGF_HASEND },
190 { _T("span"), TAGF_HASEND },
191 { _T("object"), TAGF_HASEND | TAGF_BLOCK },
192 { _T("param"), TAGF_NONE },
195 class AtlHtmlAttrs
197 public:
198 CString m_strAttrs;
200 AtlHtmlAttrs()
205 #pragma warning(push)
206 #pragma warning(disable : 4793)
207 AtlHtmlAttrs(int nCount, ...)
209 va_list args;
211 va_start(args, nCount);
212 for (int i=0; i<nCount; i++)
214 LPCTSTR szName = va_arg(args, LPCTSTR);
215 LPCTSTR szVal = va_arg(args, LPCTSTR);
216 Add(szName, szVal);
218 va_end(args);
220 #pragma warning(pop)
222 #pragma warning(push)
223 #pragma warning(disable : 4793)
224 AtlHtmlAttrs(LPCTSTR szFormat, ...)
226 if (!szFormat || !*szFormat)
227 return;
229 va_list args;
231 va_start(args, szFormat);
233 CString strTmp;
234 strTmp.FormatV(szFormat, args);
235 va_end(args);
237 m_strAttrs += _T(" ");
238 m_strAttrs += strTmp;
240 #pragma warning(pop)
242 BOOL Add(LPCTSTR szName, LPCTSTR szValue)
244 if (szValue)
245 m_strAttrs.AppendFormat(_T(" %s=\"%s\""), szName, szValue);
246 else
247 m_strAttrs.AppendFormat(_T(" %s"), szName);
248 return TRUE;
251 #pragma warning(push)
252 #pragma warning(disable : 4793)
253 void AddFormat(LPCTSTR szFormat, ...)
255 va_list args;
257 va_start(args, szFormat);
259 CString strTmp;
260 strTmp.FormatV(szFormat, args);
261 va_end(args);
263 m_strAttrs += _T(" ");
264 m_strAttrs += strTmp;
266 #pragma warning(pop)
268 void Set(LPCTSTR szAttrs)
270 if (szAttrs)
272 m_strAttrs.Empty();
273 #ifndef UNICODE
274 if (!isspace(static_cast<unsigned char>(szAttrs[0])))
275 #else
276 if (!iswspace(szAttrs[0]))
277 #endif
278 m_strAttrs = _T(" ");
279 m_strAttrs += szAttrs;
283 operator LPCTSTR()
285 return m_strAttrs;
290 class CStreamOnWriteStream : public IStream
292 public:
293 IWriteStream *m_pWriteStream;
295 CStreamOnWriteStream()
297 m_pWriteStream = NULL;
300 void Init(IWriteStream *pWriteStream)
302 m_pWriteStream = pWriteStream;
305 // IUnknown methods
306 STDMETHOD(QueryInterface)(REFIID riid, void **ppv)
308 if (!ppv)
309 return E_POINTER;
311 *ppv = NULL;
313 if (IsEqualGUID(riid, IID_IUnknown) ||
314 IsEqualGUID(riid, IID_IStream) ||
315 IsEqualGUID(riid, IID_ISequentialStream))
317 *ppv = (IStream *) this;
319 if (!*ppv)
320 return E_NOINTERFACE;
321 return S_OK;
324 ULONG __stdcall AddRef()
326 return 1;
329 ULONG __stdcall Release()
331 return 1;
334 // ISequentialStream methods
335 HRESULT STDMETHODCALLTYPE Read(void * /*pDest*/, ULONG /*dwMaxLen*/, ULONG * /*pdwRead*/)
337 return E_NOTIMPL;
340 HRESULT STDMETHODCALLTYPE Write(const void *pv, ULONG cb, ULONG *pcbWritten)
342 ATLASSUME(m_pWriteStream);
343 HRESULT hr = m_pWriteStream->WriteStream((const char *) pv, cb, pcbWritten);
344 return (hr==S_OK) ? S_OK : STG_E_WRITEFAULT;
347 // IStream methods
348 HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER /*dlibMove*/, DWORD /*dwOrigin*/, ULARGE_INTEGER * /*plibNewPosition*/)
350 return E_NOTIMPL;
353 HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER /*libNewSize*/)
355 return E_NOTIMPL;
358 HRESULT STDMETHODCALLTYPE CopyTo(IStream * /*pstm*/, ULARGE_INTEGER /*cb*/, ULARGE_INTEGER * /*pcbRead*/, ULARGE_INTEGER * /*pcbWritten*/)
360 return E_NOTIMPL;
363 HRESULT STDMETHODCALLTYPE Commit(DWORD /*grfCommitFlags*/)
365 return E_NOTIMPL;
368 HRESULT STDMETHODCALLTYPE Revert(void)
370 return E_NOTIMPL;
373 HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER /*libOffset*/, ULARGE_INTEGER /*cb*/, DWORD /*dwLockType*/)
375 return E_NOTIMPL;
378 HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER /*libOffset*/, ULARGE_INTEGER /*cb*/, DWORD /*dwLockType*/)
380 return E_NOTIMPL;
383 HRESULT STDMETHODCALLTYPE Stat(STATSTG * /*pstatstg*/, DWORD /*grfStatFlag*/)
385 return E_NOTIMPL;
389 HRESULT STDMETHODCALLTYPE Clone(IStream ** /*ppstm*/)
391 return E_NOTIMPL;
395 class CStreamFormatter
397 protected:
398 CStreamOnWriteStream m_sows;
399 IStream *m_pStream;
400 BOOL m_bAddCRLF;
401 BOOL m_bEmitUnicode;
402 UINT m_nConversionCodepage;
404 public:
405 CStreamFormatter()
407 m_pStream = NULL;
408 m_bAddCRLF = TRUE;
409 m_bEmitUnicode = FALSE;
410 m_nConversionCodepage = _AtlGetConversionACP();
413 void Initialize(IStream *pStream, BOOL bAddCRLF=TRUE)
415 m_pStream = pStream;
416 m_bAddCRLF = bAddCRLF;
419 void Initialize(IWriteStream *pWriteStream, BOOL bAddCRLF=TRUE)
421 m_bAddCRLF = bAddCRLF;
422 m_sows.Init(pWriteStream);
423 m_pStream = &m_sows;
426 void EmitUnicode(BOOL bEmitUnicode)
428 m_bEmitUnicode = bEmitUnicode;
431 void SetConversionCodepage(UINT nConversionCodepage)
433 m_nConversionCodepage = nConversionCodepage;
436 void AddCRLF(bool bNewVal)
438 m_bAddCRLF = bNewVal;
441 HRESULT WriteRaw(LPCTSTR szString, int nCount=-1)
443 ATLENSURE_RETURN(szString != NULL);
444 if (!m_pStream)
445 return E_FAIL;
447 if (m_bEmitUnicode)
449 #ifdef _UNICODE
450 LPCWSTR sz = szString;
451 if (nCount == -1)
452 nCount = (int) wcslen(szString);
453 #else
454 CA2W sz(szString, m_nConversionCodepage);
455 nCount = (int) wcslen(sz);
456 #endif
457 DWORD dwWritten;
458 return m_pStream->Write(sz, (DWORD) nCount*sizeof(WCHAR), &dwWritten);
460 else
462 #ifdef _UNICODE
463 CW2A sz(szString, m_nConversionCodepage);
464 nCount = (int) strlen(sz);
465 #else
466 LPCSTR sz = szString;
467 if (nCount == -1)
468 nCount = (int) strlen(szString);
469 #endif
470 DWORD dwWritten;
471 return m_pStream->Write(sz, (DWORD) nCount, &dwWritten);
475 HRESULT StartTag(int nTagIndex, LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
477 if (nTagIndex < 0 || nTagIndex >= ATL_HTML_TAG_LAST)
478 return E_INVALIDARG;
479 if (m_bAddCRLF && (s_tags[nTagIndex].uFlags & TAGF_BLOCK))
480 WriteRaw(_T("\r\n"));
481 HRESULT hr = StartTag(s_tags[nTagIndex].szTagName, szContent, szAttrs);
482 if (FAILED(hr))
483 return hr;
484 if (m_bAddCRLF && (s_tags[nTagIndex].uFlags & TAGF_BLOCK))
485 WriteRaw(_T("\r\n"));
486 return S_OK;
489 HRESULT StartTag(LPCTSTR szTag, LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
491 HRESULT hr;
492 hr = WriteRaw(_T("<"));
493 if (FAILED(hr))
494 return hr;
495 hr = WriteRaw(szTag);
496 if (FAILED(hr))
497 return hr;
498 hr = WriteAttributes(szAttrs);
499 if (FAILED(hr))
500 return hr;
501 hr = WriteRaw(_T(">"));
502 if (FAILED(hr))
503 return hr;
504 if (szContent && *szContent)
506 WriteRaw(szContent);
507 EndTag(szTag);
509 return S_OK;
512 HRESULT EndTag(int nTagIndex)
514 if (nTagIndex < 0 || nTagIndex >= ATL_HTML_TAG_LAST)
515 return E_INVALIDARG;
516 if (m_bAddCRLF && (s_tags[nTagIndex].uFlags & TAGF_BLOCK))
517 WriteRaw(_T("\r\n"));
518 HRESULT hr = EndTag(s_tags[nTagIndex].szTagName);
519 if (FAILED(hr))
520 return hr;
521 if (m_bAddCRLF && (s_tags[nTagIndex].uFlags & TAGF_BLOCK))
522 WriteRaw(_T("\r\n"));
523 return S_OK;
526 HRESULT EndTag(LPCTSTR szTag)
528 HRESULT hr = WriteRaw(_T("</"));
529 if (FAILED(hr))
530 return hr;
531 hr = WriteRaw(szTag);
532 if (FAILED(hr))
533 return hr;
534 return WriteRaw(_T(">"));
537 HRESULT WriteAttributes(LPCTSTR szAttrs)
539 if (szAttrs && szAttrs[0])
541 #ifndef UNICODE
542 if (!isspace(static_cast<unsigned char>(szAttrs[0])))
543 #else
544 if (!iswspace(szAttrs[0]))
545 #endif
546 WriteRaw(_T(" "));
547 return WriteRaw(szAttrs);
550 return S_OK;
553 #pragma warning(push)
554 #pragma warning(disable : 4793)
555 HRESULT WriteFormatted(LPCTSTR szFormat, ...)
557 ATLASSERT(szFormat != NULL);
558 if (!m_pStream)
559 return E_FAIL;
561 va_list args;
562 va_start(args, szFormat);
565 TCHAR buffFixed[1024];
566 CTempBuffer<TCHAR> buffHeap;
567 TCHAR *szTemp = buffFixed;
568 int nCount = _vstprintf_s((LPTSTR)szTemp, _countof(buffFixed), szFormat, args);
569 if (nCount < 0)
571 // we'll have to dynamically allocate the buffer
572 nCount = _vsctprintf(szFormat, args);
573 szTemp = NULL;
574 ATLTRY(szTemp = buffHeap.Allocate(nCount + 1));
575 if (!szTemp)
576 return E_OUTOFMEMORY;
577 nCount = _vstprintf_s(szTemp, nCount+1, szFormat, args);
580 va_end(args);
582 if (nCount > 0)
583 return WriteRaw(szTemp, (DWORD) nCount);
584 return E_UNEXPECTED;
586 #pragma warning(pop)
589 template <typename TData, int nMax=64>
590 class CSimpleStack
592 public:
593 int m_nTop;
594 TData m_Data[nMax];
596 CSimpleStack()
598 m_nTop = -1;
601 bool IsEmpty()
603 return (m_nTop == -1);
606 bool Push(const TData *pData)
608 if (m_nTop + 1 >= nMax)
609 return false;
611 m_nTop++;
613 m_Data[m_nTop] = *pData;
614 return true;
617 bool Pop(TData *pData)
619 if (m_nTop < 0)
620 return false;
622 *pData = m_Data[m_nTop];
623 m_nTop--;
624 return true;
629 struct HTML_SCHEME
631 CString strBgColor;
632 CString strLinkColor;
633 CString strVLinkColor;
634 CString strALinkColor;
635 CString strBackground;
636 int nTopMargin;
637 int nLeftMargin;
639 CString strTdBgColor;
640 CString strTableBgColor;
641 CString strTrBgColor;
643 HTML_SCHEME()
645 nTopMargin = -1;
646 nLeftMargin = -1;
650 template <class T>
651 class CHtmlGenBase : public CStreamFormatter
653 public:
654 T* GetOuter()
656 return static_cast<T*>(this);
659 enum ATL_HTML_FORM_METHOD { ATL_HTML_FORM_METHOD_NONE=0, ATL_HTML_FORM_METHOD_GET, ATL_HTML_FORM_METHOD_POST, ATL_HTML_FORM_METHOD_MULTIPART };
661 CHtmlGenBase()
663 m_nWidthPercent = -1;
664 m_nHeightPercent = -1;
665 m_nFormMethod = ATL_HTML_FORM_METHOD_NONE;
666 m_pScheme = NULL;
669 void SetScheme(HTML_SCHEME *pScheme)
671 m_pScheme = pScheme;
674 HRESULT body(LPCTSTR szBgColor=NULL, LPCTSTR szBackground=NULL, LPCTSTR szTopMargin=NULL, LPCTSTR szLeftMargin=NULL,
675 LPCTSTR szAttrs=NULL)
677 AtlHtmlAttrs Attrs;
678 Attrs.Set(szAttrs);
680 if (szBgColor && *szBgColor)
681 Attrs.Add(_T("bgColor"), szBgColor);
682 else if (m_pScheme && m_pScheme->strBgColor.GetLength())
683 Attrs.Add(_T("bgColor"), m_pScheme->strBgColor);
685 if (szBackground && *szBackground)
686 Attrs.Add(_T("background"), szBackground);
687 else if (m_pScheme && m_pScheme->strBackground.GetLength())
688 Attrs.Add(_T("background"), m_pScheme->strBackground);
690 if (m_pScheme && m_pScheme->strLinkColor.GetLength())
691 Attrs.Add(_T("link"), m_pScheme->strLinkColor);
693 if (m_pScheme && m_pScheme->strALinkColor.GetLength())
694 Attrs.Add(_T("alink"), m_pScheme->strALinkColor);
696 if (m_pScheme && m_pScheme->strVLinkColor.GetLength())
697 Attrs.Add(_T("vlink"), m_pScheme->strVLinkColor);
699 if (szTopMargin && *szTopMargin)
700 Attrs.Add(_T("topmargin"), szTopMargin);
701 else if (m_pScheme && m_pScheme->nTopMargin != -1)
702 Attrs.AddFormat(_T("topmargin=\"%d\""), m_pScheme->nTopMargin);
704 if (szLeftMargin && *szLeftMargin)
705 Attrs.Add(_T("leftmargin"), szLeftMargin);
706 else if (m_pScheme && m_pScheme->nLeftMargin != -1)
707 Attrs.AddFormat(_T("leftmargin=\"%d\""), m_pScheme->nLeftMargin);
709 return GetOuter()->StartTag(ATL_HTML_TAG_BODY, NULL, Attrs);
712 HRESULT bodyEnd()
714 return GetOuter()->EndTag(ATL_HTML_TAG_BODY);
717 HRESULT a(LPCTSTR szHref, LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
719 AtlHtmlAttrs Attrs;
720 Attrs.Set(szAttrs);
722 if (m_strState.GetLength()==0)
724 if (szHref && *szHref)
725 Attrs.Add(_T("href"), szHref);
726 return GetOuter()->StartTag(ATL_HTML_TAG_A, szContent, Attrs);
729 const TCHAR *szQuestion = NULL;
730 if(szHref)
731 szQuestion = _tcschr(szHref, '?');
733 CString strHref = szHref;
734 if (!szQuestion)
735 strHref.Append("?");
736 else
737 strHref.Append("&");
739 strHref += m_strState;
741 if (szHref && *szHref)
742 Attrs.Add(_T("href"), strHref);
744 return GetOuter()->StartTag(ATL_HTML_TAG_A, szContent, Attrs);
747 HRESULT aEnd()
749 return GetOuter()->EndTag(ATL_HTML_TAG_A);
752 HRESULT b(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
754 return GetOuter()->StartTag(ATL_HTML_TAG_B, szContent, szAttrs);
757 HRESULT bEnd()
759 return GetOuter()->EndTag(ATL_HTML_TAG_B);
762 HRESULT i(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
764 return GetOuter()->StartTag(ATL_HTML_TAG_I, szContent, szAttrs);
767 HRESULT iEnd()
769 return GetOuter()->EndTag(ATL_HTML_TAG_I);
772 HRESULT u(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
774 return GetOuter()->StartTag(ATL_HTML_TAG_U, szContent, szAttrs);
777 HRESULT uEnd()
779 return GetOuter()->EndTag(ATL_HTML_TAG_U);
782 HRESULT font(LPCTSTR szFace, LPCTSTR szSize=NULL, LPCTSTR szColor=NULL, LPCTSTR szAttrs=NULL)
784 AtlHtmlAttrs Attrs;
785 Attrs.Set(szAttrs);
786 if (szFace && *szFace)
787 Attrs.Add(_T("face"), szFace);
788 if (szSize && *szSize)
789 Attrs.Add(_T("size"), szSize);
790 if (szColor && *szColor)
791 Attrs.Add(_T("color"), szColor);
792 return GetOuter()->StartTag(ATL_HTML_TAG_FONT, NULL, Attrs);
795 HRESULT font(COLORREF clrColor, LPCTSTR szAttrs=NULL)
797 TCHAR szColor[8];
798 _stprintf_s(szColor, _countof(szColor), _T("#%02x%02x%02x"), GetRValue(clrColor),
799 GetGValue(clrColor), GetBValue(clrColor));
800 return GetOuter()->font(NULL, NULL, szColor, szAttrs);
803 HRESULT fontEnd()
805 return GetOuter()->EndTag(ATL_HTML_TAG_FONT);
808 HRESULT img(LPCTSTR szSrc, LPCTSTR szAttrs=NULL)
810 ATLASSERT(szSrc && *szSrc);
812 AtlHtmlAttrs Attrs;
813 Attrs.Set(szAttrs);
815 Attrs.Add(_T("src"), szSrc);
817 return GetOuter()->StartTag(ATL_HTML_TAG_IMG, NULL, Attrs);
820 HRESULT br(LPCTSTR szAttrs=NULL)
822 return GetOuter()->StartTag(ATL_HTML_TAG_BR, NULL, szAttrs);
825 HRESULT hr(LPCTSTR szAttrs=NULL)
827 return GetOuter()->StartTag(ATL_HTML_TAG_HR, NULL, szAttrs);
830 HRESULT div(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
832 return GetOuter()->StartTag(ATL_HTML_TAG_DIV, szContent, szAttrs);
835 HRESULT divEnd()
837 return GetOuter()->EndTag(ATL_HTML_TAG_DIV);
840 HRESULT blockquote(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
842 return GetOuter()->StartTag(ATL_HTML_TAG_BLOCKQUOTE, szContent, szAttrs);
845 HRESULT blockquoteEnd()
847 return GetOuter()->EndTag(ATL_HTML_TAG_BLOCKQUOTE);
850 HRESULT address(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
852 return GetOuter()->StartTag(ATL_HTML_TAG_ADDRESS, szContent, szAttrs);
855 HRESULT addressEnd()
857 return GetOuter()->EndTag(ATL_HTML_TAG_ADDRESS);
860 HRESULT p(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
862 return GetOuter()->StartTag(ATL_HTML_TAG_P, szContent, szAttrs);
865 HRESULT pEnd()
867 return GetOuter()->EndTag(ATL_HTML_TAG_P);
870 HRESULT h(int nLevel=1, LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
872 if (nLevel < 1 || nLevel > 6)
873 return E_INVALIDARG;
874 return GetOuter()->StartTag(ATL_HTML_TAG_H1+nLevel-1, szContent, szAttrs);
877 HRESULT hEnd(int nLevel=1)
879 if (nLevel < 1 || nLevel > 6)
880 return E_INVALIDARG;
881 return GetOuter()->EndTag(ATL_HTML_TAG_H1+nLevel-1);
884 HRESULT pre(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
886 return GetOuter()->StartTag(ATL_HTML_TAG_PRE, szContent, szAttrs);
889 HRESULT preEnd()
891 return GetOuter()->EndTag(ATL_HTML_TAG_PRE);
894 HRESULT q(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
896 return GetOuter()->StartTag(ATL_HTML_TAG_Q, szContent, szAttrs);
899 HRESULT qEnd()
901 return GetOuter()->EndTag(ATL_HTML_TAG_Q);
904 HRESULT sub(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
906 return GetOuter()->StartTag(ATL_HTML_TAG_SUB, szContent, szAttrs);
909 HRESULT subEnd()
911 return GetOuter()->EndTag(ATL_HTML_TAG_SUB);
914 HRESULT sup(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
916 return GetOuter()->StartTag(ATL_HTML_TAG_SUP, szContent, szAttrs);
919 HRESULT supEnd()
921 return GetOuter()->EndTag(ATL_HTML_TAG_SUP);
924 HRESULT ins(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
926 return GetOuter()->StartTag(ATL_HTML_TAG_INS, szContent, szAttrs);
929 HRESULT insEnd()
931 return GetOuter()->EndTag(ATL_HTML_TAG_INS);
934 HRESULT del(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
936 return GetOuter()->StartTag(ATL_HTML_TAG_DEL, szContent, szAttrs);
939 HRESULT delEnd()
941 return GetOuter()->EndTag(ATL_HTML_TAG_DEL);
945 HRESULT em(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
947 return GetOuter()->StartTag(ATL_HTML_TAG_EM, szContent, szAttrs);
950 HRESULT emEnd()
952 return GetOuter()->EndTag(ATL_HTML_TAG_EM);
955 HRESULT strong(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
957 return GetOuter()->StartTag(ATL_HTML_TAG_STRONG, szContent, szAttrs);
960 HRESULT strongEnd()
962 return GetOuter()->EndTag(ATL_HTML_TAG_STRONG);
965 HRESULT dfn(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
967 return GetOuter()->StartTag(ATL_HTML_TAG_DFN, szContent, szAttrs);
970 HRESULT dfnEnd()
972 return GetOuter()->EndTag(ATL_HTML_TAG_DFN);
975 HRESULT code(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
977 return GetOuter()->StartTag(ATL_HTML_TAG_CODE, szContent, szAttrs);
980 HRESULT codeEnd()
982 return GetOuter()->EndTag(ATL_HTML_TAG_CODE);
985 HRESULT samp(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
987 return GetOuter()->StartTag(ATL_HTML_TAG_SAMP, szContent, szAttrs);
990 HRESULT sampEnd()
992 return GetOuter()->EndTag(ATL_HTML_TAG_SAMP);
995 HRESULT kbd(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
997 return GetOuter()->StartTag(ATL_HTML_TAG_KBD, szContent, szAttrs);
1000 HRESULT kbdEnd()
1002 return GetOuter()->EndTag(ATL_HTML_TAG_KBD);
1005 HRESULT var(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1007 return GetOuter()->StartTag(ATL_HTML_TAG_VAR, szContent, szAttrs);
1010 HRESULT varEnd()
1012 return GetOuter()->EndTag(ATL_HTML_TAG_VAR);
1015 HRESULT cite(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1017 return GetOuter()->StartTag(ATL_HTML_TAG_CITE, szContent, szAttrs);
1020 HRESULT citeEnd()
1022 return GetOuter()->EndTag(ATL_HTML_TAG_CITE);
1025 HRESULT abbr(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1027 return GetOuter()->StartTag(ATL_HTML_TAG_ABBR, szContent, szAttrs);
1030 HRESULT abbrEnd()
1032 return GetOuter()->EndTag(ATL_HTML_TAG_ABBR);
1035 HRESULT acronym(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1037 return GetOuter()->StartTag(ATL_HTML_TAG_ACRONYM, szContent, szAttrs);
1040 HRESULT acronymEnd()
1042 return GetOuter()->EndTag(ATL_HTML_TAG_ACRONYM);
1046 HRESULT ol(LPCTSTR szAttrs=NULL)
1048 return GetOuter()->StartTag(ATL_HTML_TAG_OL, NULL, szAttrs);
1051 HRESULT ul(LPCTSTR szAttrs=NULL)
1053 return GetOuter()->StartTag(ATL_HTML_TAG_UL, NULL, szAttrs);
1056 HRESULT olEnd()
1058 return GetOuter()->EndTag(ATL_HTML_TAG_OL);
1061 HRESULT ulEnd()
1063 return GetOuter()->EndTag(ATL_HTML_TAG_UL);
1066 HRESULT li(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1068 return GetOuter()->StartTag(ATL_HTML_TAG_LI, szContent, szAttrs);
1071 HRESULT liEnd()
1073 return GetOuter()->EndTag(ATL_HTML_TAG_LI);
1076 HRESULT dl(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1078 return GetOuter()->StartTag(ATL_HTML_TAG_DL, szContent, szAttrs);
1081 HRESULT dlEnd()
1083 return GetOuter()->EndTag(ATL_HTML_TAG_DL);
1086 HRESULT dt(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1088 return GetOuter()->StartTag(ATL_HTML_TAG_DT, szContent, szAttrs);
1091 HRESULT dtEnd()
1093 return GetOuter()->EndTag(ATL_HTML_TAG_DT);
1096 HRESULT dd(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1098 return GetOuter()->StartTag(ATL_HTML_TAG_DD, szContent, szAttrs);
1101 HRESULT ddEnd()
1103 return GetOuter()->EndTag(ATL_HTML_TAG_DD);
1106 void SetSizePercent(int nWidth, int nHeight)
1108 m_nWidthPercent = nWidth;
1109 m_nHeightPercent = nHeight;
1112 HRESULT table(int nBorderWidth=0, LPCTSTR szAttrs=NULL)
1114 AtlHtmlAttrs Attrs;
1115 Attrs.Set(szAttrs);
1117 m_RowStack.Push(&m_tableState);
1118 m_tableState.Clear();
1120 Attrs.AddFormat(_T("border=\"%d\""), nBorderWidth);
1122 if (m_nWidthPercent != -1)
1123 Attrs.AddFormat(_T("width=\"%d%%\""), m_nWidthPercent);
1124 if (m_nHeightPercent != -1)
1125 Attrs.AddFormat(_T("height=\"%d%%\""), m_nHeightPercent);
1127 if (m_pScheme && m_pScheme->strTableBgColor.GetLength())
1128 Attrs.Add(_T("bgcolor"), m_pScheme->strTableBgColor);
1130 m_nWidthPercent = -1;
1131 m_nHeightPercent = -1;
1132 return GetOuter()->StartTag(ATL_HTML_TAG_TABLE, NULL, Attrs);
1135 HRESULT tableEnd()
1137 if (m_tableState.m_bRowOpen)
1138 GetOuter()->trEnd();
1139 m_RowStack.Pop(&m_tableState);
1140 return GetOuter()->EndTag(ATL_HTML_TAG_TABLE);
1143 HRESULT tr(LPCTSTR szAttrs=NULL)
1145 AtlHtmlAttrs Attrs;
1146 Attrs.Set(szAttrs);
1148 if (m_RowStack.IsEmpty())
1149 GetOuter()->table();
1150 if (m_tableState.m_bRowOpen)
1151 GetOuter()->trEnd();
1152 m_tableState.m_bRowOpen = true;
1154 if (m_pScheme && m_pScheme->strTrBgColor.GetLength())
1155 Attrs.Add(_T("bgcolor"), m_pScheme->strTrBgColor);
1156 return GetOuter()->StartTag(ATL_HTML_TAG_TR, NULL, Attrs);
1159 HRESULT td(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1161 AtlHtmlAttrs Attrs;
1162 Attrs.Set(szAttrs);
1164 if (!m_tableState.m_bRowOpen)
1165 GetOuter()->tr();
1166 m_tableState.m_bDataOpen = true;
1167 if (m_pScheme && m_pScheme->strTdBgColor.GetLength())
1168 Attrs.Add(_T("bgColor"), m_pScheme->strTdBgColor);
1170 HRESULT hr = GetOuter()->StartTag(ATL_HTML_TAG_TD, szContent, Attrs);
1171 if (FAILED(hr))
1172 return hr;
1173 if (szContent)
1174 m_tableState.m_bDataOpen = false;
1175 return S_OK;
1178 HRESULT tdEnd()
1180 if (!m_tableState.m_bDataOpen)
1181 return S_OK;
1182 m_tableState.m_bDataOpen = false;
1183 return GetOuter()->EndTag(ATL_HTML_TAG_TD);
1186 HRESULT trEnd()
1188 if (!m_tableState.m_bRowOpen)
1189 return S_OK;
1190 if (m_tableState.m_bDataOpen)
1191 GetOuter()->tdEnd();
1192 m_tableState.m_bRowOpen = false;
1193 return GetOuter()->EndTag(ATL_HTML_TAG_TR);
1196 HRESULT form(LPCTSTR szAction, ATL_HTML_FORM_METHOD nMethod=ATL_HTML_FORM_METHOD_GET, LPCTSTR szAttrs=NULL)
1198 static const LPCTSTR s_szFormMethods[] = { NULL, _T("get"), _T("post"), _T("multipart-www-url-encoded") };
1199 return GetOuter()->form(szAction, s_szFormMethods[nMethod], szAttrs);
1202 HRESULT form(LPCTSTR szAction, LPCTSTR szMethod, LPCTSTR szAttrs=NULL)
1204 AtlHtmlAttrs Attrs;
1205 Attrs.Set(szAttrs);
1207 if (szAction && *szAction)
1208 Attrs.Add(_T("action"), szAction);
1209 if (szMethod && *szMethod)
1210 Attrs.Add(_T("method"), szMethod);
1212 return GetOuter()->StartTag(ATL_HTML_TAG_FORM, NULL, Attrs);
1215 HRESULT input(LPCTSTR szType, LPCTSTR szName, LPCTSTR szValue, LPCTSTR szAttrs=NULL)
1217 AtlHtmlAttrs Attrs;
1218 Attrs.Set(szAttrs);
1220 if (szType && *szType)
1221 Attrs.Add(_T("type"), szType);
1222 if (szName && *szName)
1223 Attrs.Add(_T("name"), szName);
1224 if (szValue && *szValue)
1225 Attrs.Add(_T("value"), szValue);
1226 return GetOuter()->StartTag(ATL_HTML_TAG_INPUT, NULL, Attrs);
1229 HRESULT submit(LPCTSTR szValue=NULL, LPCTSTR szName=NULL, LPCTSTR szAttrs=NULL)
1231 return input(_T("submit"), szName, szValue, szAttrs);
1234 HRESULT textarea(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1236 return GetOuter()->StartTag(ATL_HTML_TAG_TEXTAREA, szContent, szAttrs);
1239 HRESULT textareaEnd()
1241 return GetOuter()->EndTag(ATL_HTML_TAG_TEXTAREA);
1244 HRESULT formEnd()
1246 return GetOuter()->EndTag(ATL_HTML_TAG_FORM);
1250 HRESULT select(LPCTSTR szName, BOOL bMultiple=FALSE, LPCTSTR szAttrs=NULL)
1252 ATLASSERT(szName && *szName);
1254 AtlHtmlAttrs Attrs;
1255 Attrs.Set(szAttrs);
1257 Attrs.Add(_T("name"), szName);
1258 if (bMultiple)
1259 Attrs.Add(_T("multiple"), NULL);
1260 return GetOuter()->StartTag(ATL_HTML_TAG_SELECT, NULL, Attrs);
1263 HRESULT option(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1265 return GetOuter()->StartTag(ATL_HTML_TAG_OPTION, szContent, szAttrs);
1268 HRESULT optionEnd()
1270 return GetOuter()->EndTag(ATL_HTML_TAG_OPTION);
1273 HRESULT selectEnd()
1275 return GetOuter()->EndTag(ATL_HTML_TAG_SELECT);
1279 HRESULT head(LPCTSTR szAttrs=NULL)
1281 return GetOuter()->StartTag(ATL_HTML_TAG_HEAD, NULL, szAttrs);
1284 HRESULT headEnd()
1286 return GetOuter()->EndTag(ATL_HTML_TAG_HEAD);
1289 HRESULT html(LPCTSTR szAttrs=NULL)
1291 return GetOuter()->StartTag(ATL_HTML_TAG_HTML, NULL, szAttrs);
1294 HRESULT htmlEnd()
1296 return GetOuter()->EndTag(ATL_HTML_TAG_HTML);
1299 HRESULT map(LPCTSTR szName, LPCTSTR szAttrs=NULL)
1301 ATLASSERT(szName && *szName);
1303 AtlHtmlAttrs Attrs;
1304 Attrs.Set(szAttrs);
1306 Attrs.Add(_T("name"), szName);
1307 return GetOuter()->StartTag(ATL_HTML_TAG_MAP, NULL, Attrs);
1310 HRESULT mapEnd()
1312 return GetOuter()->EndTag(ATL_HTML_TAG_MAP);
1315 HRESULT area(LPCTSTR szAlt, LPCTSTR szHref=NULL, LPCTSTR szAttrs=NULL)
1317 AtlHtmlAttrs Attrs;
1318 Attrs.Set(szAttrs);
1320 if (szAlt && *szAlt)
1321 Attrs.Add(_T("alt"), szAlt);
1322 if (szHref && *szHref)
1323 Attrs.Add(_T("href"), szHref);
1324 return GetOuter()->StartTag(ATL_HTML_TAG_AREA, NULL, Attrs);
1327 HRESULT base(LPCTSTR szHref, LPCTSTR szAttrs=NULL)
1329 ATLASSERT(szHref && *szHref);
1331 AtlHtmlAttrs Attrs;
1332 Attrs.Set(szAttrs);
1334 Attrs.Add(_T("href"), szHref);
1335 return GetOuter()->StartTag(ATL_HTML_TAG_BASE, NULL, Attrs);
1338 HRESULT bdo(LPCTSTR szDir, LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1340 ATLASSERT(szDir&& *szDir);
1342 AtlHtmlAttrs Attrs;
1343 Attrs.Set(szAttrs);
1345 Attrs.Add(_T("dir"), szDir);
1346 return GetOuter()->StartTag(ATL_HTML_TAG_BDO, szContent, Attrs);
1349 HRESULT bdoEnd()
1351 return GetOuter()->EndTag(ATL_HTML_TAG_BDO);
1354 HRESULT big(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1356 return GetOuter()->StartTag(ATL_HTML_TAG_BIG, szContent, szAttrs);
1359 HRESULT bigEnd()
1361 return GetOuter()->EndTag(ATL_HTML_TAG_BIG);
1364 HRESULT button(LPCTSTR szName=NULL, LPCTSTR szValue=NULL, LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1366 AtlHtmlAttrs Attrs;
1367 Attrs.Set(szAttrs);
1369 if (szName && *szName)
1370 Attrs.Add(_T("name"), szName);
1371 if (szValue && *szValue)
1372 Attrs.Add(_T("value"), szValue);
1373 return GetOuter()->StartTag(ATL_HTML_TAG_BUTTON, szContent, Attrs);
1376 HRESULT buttonEnd()
1378 return GetOuter()->EndTag(ATL_HTML_TAG_BUTTON);
1381 HRESULT iframe(LPCTSTR szSrc=NULL, LPCTSTR szWidth=NULL, LPCTSTR szHeight=NULL, LPCTSTR szAttrs=NULL)
1383 AtlHtmlAttrs Attrs;
1384 Attrs.Set(szAttrs);
1386 if (szSrc && *szSrc)
1387 Attrs.Add(_T("src"), szSrc);
1388 if (szWidth && *szWidth)
1389 Attrs.Add(_T("width"), szWidth);
1390 if (szHeight && *szHeight)
1391 Attrs.Add(_T("height"), szHeight);
1392 return GetOuter()->StartTag(ATL_HTML_TAG_IFRAME, NULL, Attrs);
1395 HRESULT iframeEnd()
1397 return GetOuter()->EndTag(ATL_HTML_TAG_IFRAME);
1400 HRESULT label(LPCTSTR szFor=NULL, LPCTSTR szAccessKey=NULL, LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1402 AtlHtmlAttrs Attrs;
1403 Attrs.Set(szAttrs);
1405 if (szFor && *szFor)
1406 Attrs.Add(_T("for"), szFor);
1407 if (szAccessKey && *szAccessKey)
1408 Attrs.Add(_T("accesskey"), szAccessKey);
1409 return GetOuter()->StartTag(ATL_HTML_TAG_LABEL, szContent, Attrs);
1412 HRESULT labelEnd()
1414 return GetOuter()->EndTag(ATL_HTML_TAG_LABEL);
1417 HRESULT link(LPCTSTR szRel=NULL, LPCTSTR szHref=NULL, LPCTSTR szAttrs=NULL)
1419 AtlHtmlAttrs Attrs;
1420 Attrs.Set(szAttrs);
1422 if (szRel && *szRel)
1423 Attrs.Add(_T("rel"), szRel);
1424 if (szHref && *szHref)
1425 Attrs.Add(_T("href"), szHref);
1426 return GetOuter()->StartTag(ATL_HTML_TAG_LINK, NULL, Attrs);
1429 HRESULT meta(LPCTSTR szName=NULL, LPCTSTR szContent=NULL, LPCTSTR szHttpEquiv=NULL, LPCTSTR szAttrs=NULL)
1431 AtlHtmlAttrs Attrs;
1432 Attrs.Set(szAttrs);
1434 if (szName && *szName)
1435 Attrs.Add(_T("name"), szName);
1436 if (szContent && *szContent)
1437 Attrs.Add(_T("content"), szContent);
1438 if (szHttpEquiv && *szHttpEquiv)
1439 Attrs.Add(_T("http-equiv"), szHttpEquiv);
1440 return GetOuter()->StartTag(ATL_HTML_TAG_META, NULL, Attrs);
1443 HRESULT noframes(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1445 return GetOuter()->StartTag(ATL_HTML_TAG_NOFRAMES, szContent, szAttrs);
1448 HRESULT noframesEnd()
1450 return GetOuter()->EndTag(ATL_HTML_TAG_NOFRAMES);
1453 HRESULT noscript(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1455 return GetOuter()->StartTag(ATL_HTML_TAG_NOSCRIPT, szContent, szAttrs);
1458 HRESULT noscriptEnd()
1460 return GetOuter()->EndTag(ATL_HTML_TAG_NOSCRIPT);
1463 HRESULT col(int nSpan=1, LPCTSTR szWidth=NULL, LPCTSTR szHeight=NULL, LPCTSTR szVAlign=NULL,
1464 LPCTSTR szHAlign=NULL, LPCTSTR szAttrs=NULL)
1466 AtlHtmlAttrs Attrs;
1467 Attrs.Set(szAttrs);
1470 if (nSpan != 1)
1471 Attrs.AddFormat(_T("span"), _T("\"%d\""), nSpan);
1472 if (szWidth && *szWidth)
1473 Attrs.Add(_T("width"), szWidth);
1474 if (szHeight && *szHeight)
1475 Attrs.Add(_T("height"), szHeight);
1476 if (szVAlign && *szVAlign)
1477 Attrs.Add(_T("valign"), szVAlign);
1478 if (szHAlign && *szHAlign)
1479 Attrs.Add(_T("align"), szHAlign);
1480 return GetOuter()->StartTag(ATL_HTML_TAG_COL, NULL, Attrs);
1483 HRESULT colgroup(int nSpan=1, LPCTSTR szWidth=NULL, LPCTSTR szHeight=NULL, LPCTSTR szVAlign=NULL,
1484 LPCTSTR szHAlign=NULL, LPCTSTR szAttrs=NULL)
1486 AtlHtmlAttrs Attrs;
1487 Attrs.Set(szAttrs);
1489 if (nSpan != 1)
1490 Attrs.AddFormat(_T("span"), _T("\"%d\""), nSpan);
1491 if (szWidth && *szWidth)
1492 Attrs.Add(_T("width"), szWidth);
1493 if (szHeight && *szHeight)
1494 Attrs.Add(_T("height"), szHeight);
1495 if (szVAlign && *szVAlign)
1496 Attrs.Add(_T("valign"), szVAlign);
1497 if (szHAlign && *szHAlign)
1498 Attrs.Add(_T("align"), szHAlign);
1499 return GetOuter()->StartTag(ATL_HTML_TAG_COL, NULL, Attrs);
1502 HRESULT colgroupEnd()
1504 return GetOuter()->EndTag(ATL_HTML_TAG_COLGROUP);
1507 HRESULT fieldset(LPCTSTR szAttrs=NULL)
1509 return GetOuter()->StartTag(ATL_HTML_TAG_FIELDSET, NULL, szAttrs);
1512 HRESULT fieldsetEnd()
1514 return GetOuter()->EndTag(ATL_HTML_TAG_FIELDSET);
1517 HRESULT legend(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1519 return GetOuter()->StartTag(ATL_HTML_TAG_LEGEND, szContent, szAttrs);
1522 HRESULT legendEnd()
1524 return GetOuter()->EndTag(ATL_HTML_TAG_LEGEND);
1527 HRESULT tbody(LPCTSTR szAttrs=NULL)
1529 return GetOuter()->StartTag(ATL_HTML_TAG_TBODY, NULL, szAttrs);
1532 HRESULT tbodyEnd()
1534 return GetOuter()->StartTag(ATL_HTML_TAG_TBODY);
1537 HRESULT tfoot(LPCTSTR szAttrs=NULL)
1539 return GetOuter()->StartTag(ATL_HTML_TAG_TFOOT, NULL, szAttrs);
1542 HRESULT tfootEnd()
1544 return GetOuter()->StartTag(ATL_HTML_TAG_TFOOT);
1547 HRESULT th(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1549 if (!m_tableState.m_bRowOpen)
1550 GetOuter()->tr();
1551 m_tableState.m_bDataOpen = true;
1552 return GetOuter()->StartTag(ATL_HTML_TAG_TH, szContent, szAttrs);
1555 HRESULT thEnd()
1557 ATLASSUME(m_tableState.m_bDataOpen);
1558 m_tableState.m_bDataOpen = false;
1559 return GetOuter()->EndTag(ATL_HTML_TAG_TH);
1562 HRESULT title(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1564 return GetOuter()->StartTag(ATL_HTML_TAG_TITLE, szContent, szAttrs);
1567 HRESULT titleEnd()
1569 return GetOuter()->EndTag(ATL_HTML_TAG_TITLE);
1572 HRESULT tt(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1574 return GetOuter()->StartTag(ATL_HTML_TAG_TT, szContent, szAttrs);
1577 HRESULT ttEnd()
1579 return GetOuter()->EndTag(ATL_HTML_TAG_TT);
1582 // unfortunately, we can't use small since it is defined as char
1583 // in rpcndr.h!
1584 HRESULT _small(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1586 return GetOuter()->StartTag(ATL_HTML_TAG_SMALL, szContent, szAttrs);
1589 HRESULT _smallEnd()
1591 return GetOuter()->EndTag(ATL_HTML_TAG_SMALL);
1594 HRESULT span(LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1596 return GetOuter()->StartTag(ATL_HTML_TAG_SPAN, szContent, szAttrs);
1599 HRESULT spanEnd()
1601 return GetOuter()->EndTag(ATL_HTML_TAG_SPAN);
1604 HRESULT object(LPCTSTR szClassId, LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1606 AtlHtmlAttrs Attrs;
1607 Attrs.Set(szAttrs);
1608 if (szClassId && *szClassId)
1609 Attrs.Add(_T("classid"), szClassId);
1610 return GetOuter()->StartTag(ATL_HTML_TAG_OBJECT, szContent, Attrs);
1613 HRESULT object(REFCLSID rclsid, LPCTSTR szContent=NULL, LPCTSTR szAttrs=NULL)
1615 USES_CONVERSION_EX;
1616 OLECHAR szClsid[64];
1617 CString strClassId;
1618 int i = StringFromGUID2(rclsid, szClsid, 64);
1619 if (!i)
1620 return E_FAIL;
1621 szClsid[i-2] = 0; // don't want curly braces
1622 strClassId.Format(_T("clsid:%s"), OLE2T_EX_DEF(szClsid+1));
1623 return object(strClassId, szContent, szAttrs);
1626 HRESULT objectEnd()
1628 return GetOuter()->EndTag(ATL_HTML_TAG_OBJECT);
1631 HRESULT param(LPCTSTR szName, LPCTSTR szValue, LPCTSTR szAttrs=NULL)
1633 ATLASSERT(szName && *szName);
1635 AtlHtmlAttrs Attrs;
1636 Attrs.Set(szAttrs);
1638 Attrs.Add(_T("name"), szName);
1639 if (szValue && *szValue)
1640 Attrs.Add(_T("value"), szValue);
1641 return GetOuter()->StartTag(ATL_HTML_TAG_PARAM, NULL, Attrs);
1644 private:
1645 CString m_strState;
1646 HTML_SCHEME *m_pScheme;
1648 struct TableState
1650 TableState() : m_bRowOpen(false), m_bDataOpen(false)
1655 void Clear()
1657 m_bRowOpen = false;
1658 m_bDataOpen = false;
1661 bool m_bRowOpen;
1662 bool m_bDataOpen;
1665 ATL_HTML_FORM_METHOD m_nFormMethod;
1667 TableState m_tableState;
1668 CSimpleStack<TableState> m_RowStack;
1670 int m_nWidthPercent;
1671 int m_nHeightPercent;
1674 class CHtmlGen : public CHtmlGenBase<CHtmlGen>
1676 public:
1679 } // namespace ATL
1680 #pragma pack(pop)
1682 #endif // __ATLHTML_H__