Separatista
element.h
1 /***************************************************************************
2 * Copyright (C) 2016 by Okkel Klaver *
3 * info@vanhetland.nl *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 
21 #include <windows.h>
22 #include <separatista/separatista.h>
23 #include <separatista/element.h>
24 #include "separatista/debug/debug.h"
25 
26 #include "dispatch.h"
27 
28 #ifndef SEPARATISTA_CONTROL_ELEMENT_H
29 #define SEPARATISTA_CONTROL_ELEMENT_H
30 
31 // {006D9323-D6C2-4D53-9072-9AE379CEF7DE}
32 DEFINE_GUID(IID_ELEMENT ,
33  0x6d9323, 0xd6c2, 0x4d53, 0x90, 0x72, 0x9a, 0xe3, 0x79, 0xce, 0xf7, 0xde);
34 
35 // {0F74285B-C429-4A58-95AC-B1A05B856530}
36 DEFINE_GUID(CLSID_ELEMENT ,
37  0xf74285b, 0xc429, 0x4a58, 0x95, 0xac, 0xb1, 0xa0, 0x5b, 0x85, 0x65, 0x30);
38 
39 
40 struct IElement : public IDispatch
41 {
42  // IDispatch
43  STDMETHOD_(ULONG, AddRef)() PURE;
44  STDMETHOD_(ULONG, Release)() PURE;
45  STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) PURE;
46  STDMETHOD(GetTypeInfoCount)(UINT* pctinfo) PURE;
47  STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) PURE;
48  STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) PURE;
49  STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr) PURE;
50 
51  // IElement
52  STDMETHOD(GetTagName)(BSTR *pTagName) PURE;
53  STDMETHOD(GetValue)(BSTR *pValue) PURE;
54  STDMETHOD(SetValue)(BSTR Value) PURE;
55  STDMETHOD(GetCurrencyValue)(VARIANT *pValue) PURE;
56  STDMETHOD(SetCurrencyValue)(VARIANT Value) PURE;
57  STDMETHOD(GetDateValue)(DATE *pDateValue) PURE;
58  STDMETHOD(SetDateValue)(DATE DateValue) PURE;
59  STDMETHOD(SetDateTimeValue)(DATE DateTimeValue) PURE;
60  STDMETHOD(GetElementByTagName)(BSTR TagName, UINT index, IElement **ppElement) PURE;
61  STDMETHOD(CreateElementByTagName)(BSTR TagName, UINT index, IElement **ppElement) PURE;
62  STDMETHOD(DestroyElement)(IElement *pChildElement) PURE;
63  STDMETHOD(GetAttributeValue)(BSTR AttributeName, BSTR *pValue) PURE;
64  STDMETHOD(SetAttributeValue)(BSTR AttributeName, BSTR Value) PURE;
65  STDMETHOD(GetAllByTagName)(BSTR TagName, SAFEARRAY **ppArray) PURE;
66 
67 };
68 
69 struct __declspec(uuid("{006D9323-D6C2-4D53-9072-9AE379CEF7DE}")) IElement;
70 
75 class Element : public SepaControlDispatch<IElement>, public Separatista::ElementListener
76 {
77 public:
81  Element(Separatista::Element *pElement);
82 
83  // COM methods
84  // Subclass for ISupportErrorInfo
85  STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
86 
87  // Element Methods
88  STDMETHOD(GetTagName)(BSTR *pTagName);
89  STDMETHOD(GetValue)(BSTR *pValue);
90  STDMETHOD(SetValue)(BSTR Value);
91  STDMETHOD(GetCurrencyValue)(VARIANT *pValue);
92  STDMETHOD(SetCurrencyValue)(VARIANT Value);
93  STDMETHOD(GetDateValue)(DATE *pDateValue);
94  STDMETHOD(SetDateValue)(DATE DateValue);
95  STDMETHOD(SetDateTimeValue)(DATE DateTimeValue);
96  STDMETHOD(GetElementByTagName)(BSTR TagName, UINT index, IElement **ppElement);
97  STDMETHOD(CreateElementByTagName)(BSTR TagName, UINT index, IElement **ppElement);
98  STDMETHOD(DestroyElement)(IElement *pChildElement);
99  STDMETHOD(GetAttributeValue)(BSTR AttributeName, BSTR *pValue);
100  STDMETHOD(SetAttributeValue)(BSTR AttributeName, BSTR Value);
101  STDMETHOD(GetAllByTagName)(BSTR TagName, SAFEARRAY **ppArray);
102 
103 
104  // Elementlistener
105  void elementValueChanged(Separatista::Element *pElement, const wchar_t *pValue);
106  void elementCreated(Separatista::Element *pParentElement, Separatista::Element *pChildElement);
107  void elementDeleted(Separatista::Element *pChildElement);
108 
109 protected:
113  ~Element();
114 
119  Separatista::Element *getElement() const;
120 
125  void setElement(Separatista::Element *pElement);
126 
127 private:
128  Separatista::Element *m_pElement;
129 };
130 
131 class __declspec(uuid("{0F74285B-C429-4A58-95AC-B1A05B856530}")) Element;
132 
133 #endif // #define SEPARATISTA_CONTROL_ELEMENT_H
Definition: element.h:40