comparison dwt/ole/win32/OleClientSite.d @ 212:ab60f3309436

reverted the char[] to String and use the an alias.
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:12:38 +0200
parents 619faee45ef6
children fd9c62a2998e
comparison
equal deleted inserted replaced
211:ff59aeb96cac 212:ab60f3309436
123 private RECT indent; 123 private RECT indent;
124 private bool inUpdate = false; 124 private bool inUpdate = false;
125 private bool inInit = true; 125 private bool inInit = true;
126 private bool inDispose = false; 126 private bool inDispose = false;
127 127
128 private static const char[] WORDPROGID = "Word.Document"; //$NON-NLS-1$ 128 private static const String WORDPROGID = "Word.Document"; //$NON-NLS-1$
129 129
130 private Listener listener; 130 private Listener listener;
131 131
132 enum{ 132 enum{
133 STATE_NONE = 0, 133 STATE_NONE = 0,
264 * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread 264 * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
265 * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID 265 * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
266 * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object 266 * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
267 * </ul> 267 * </ul>
268 */ 268 */
269 public this(Composite parent, int style, char[] progId) { 269 public this(Composite parent, int style, String progId) {
270 this(parent, style); 270 this(parent, style);
271 try { 271 try {
272 appClsid = getClassID(progId); 272 appClsid = getClassID(progId);
273 if (appClsid is null) 273 if (appClsid is null)
274 OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_CLASSID); 274 OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_CLASSID);
318 * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID 318 * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
319 * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object 319 * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
320 * <li>ERROR_CANNOT_OPEN_FILE when failed to open file 320 * <li>ERROR_CANNOT_OPEN_FILE when failed to open file
321 * </ul> 321 * </ul>
322 */ 322 */
323 public this(Composite parent, int style, char[] progId, File file) { 323 public this(Composite parent, int style, String progId, File file) {
324 this(parent, style); 324 this(parent, style);
325 try { 325 try {
326 if (file is null || file.isDirectory() || !file.exists()) OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_ARGUMENT); 326 if (file is null || file.isDirectory() || !file.exists()) OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_ARGUMENT);
327 appClsid = getClassID(progId); 327 appClsid = getClassID(progId);
328 if (appClsid is null) OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_CLASSID); 328 if (appClsid is null) OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_CLASSID);
593 IDispatch ppvObject; 593 IDispatch ppvObject;
594 if (objIUnknown.QueryInterface(&COM.IIDIDispatch, cast(void**)&ppvObject) !is COM.S_OK) 594 if (objIUnknown.QueryInterface(&COM.IIDIDispatch, cast(void**)&ppvObject) !is COM.S_OK)
595 return null; 595 return null;
596 return ppvObject; 596 return ppvObject;
597 } 597 }
598 protected GUID* getClassID(char[] clientName) { 598 protected GUID* getClassID(String clientName) {
599 // create a GUID struct to hold the result 599 // create a GUID struct to hold the result
600 GUID* guid = new GUID(); 600 GUID* guid = new GUID();
601 601
602 // create a null terminated array of char 602 // create a null terminated array of char
603 wchar* buffer = null; 603 wchar* buffer = null;
639 /** 639 /**
640 * Returns the program ID of the OLE Document or ActiveX Control. 640 * Returns the program ID of the OLE Document or ActiveX Control.
641 * 641 *
642 * @return the program ID of the OLE Document or ActiveX Control 642 * @return the program ID of the OLE Document or ActiveX Control
643 */ 643 */
644 public char[] getProgramID(){ 644 public String getProgramID(){
645 if (appClsid !is null){ 645 if (appClsid !is null){
646 wchar* hMem; 646 wchar* hMem;
647 if (COM.ProgIDFromCLSID(appClsid, &hMem) is COM.S_OK) { 647 if (COM.ProgIDFromCLSID(appClsid, &hMem) is COM.S_OK) {
648 int length = OS.GlobalSize(hMem); 648 int length = OS.GlobalSize(hMem);
649 auto ptr = OS.GlobalLock(hMem); 649 auto ptr = OS.GlobalLock(hMem);
650 wchar[] buffer = new wchar[length]; 650 wchar[] buffer = new wchar[length];
651 COM.MoveMemory(buffer.ptr, ptr, length); 651 COM.MoveMemory(buffer.ptr, ptr, length);
652 OS.GlobalUnlock(hMem); 652 OS.GlobalUnlock(hMem);
653 OS.GlobalFree(hMem); 653 OS.GlobalFree(hMem);
654 654
655 char[] result = WCHARzToStr(buffer.ptr); 655 String result = WCHARzToStr(buffer.ptr);
656 // remove null terminator 656 // remove null terminator
657 //int index = result.indexOf("\0"); 657 //int index = result.indexOf("\0");
658 return result;//.substring(0, index); 658 return result;//.substring(0, index);
659 } 659 }
660 } 660 }
937 *ppvObject = cast(void*)cast(IOleInPlaceSite)iOleInPlaceSite; 937 *ppvObject = cast(void*)cast(IOleInPlaceSite)iOleInPlaceSite;
938 AddRef(); 938 AddRef();
939 return COM.S_OK; 939 return COM.S_OK;
940 } 940 }
941 if (COM.IsEqualGUID(guid, &COM.IIDIOleDocumentSite )) { 941 if (COM.IsEqualGUID(guid, &COM.IIDIOleDocumentSite )) {
942 char[] progID = getProgramID(); 942 String progID = getProgramID();
943 if (!progID.startsWith("PowerPoint")) { //$NON-NLS-1$ 943 if (!progID.startsWith("PowerPoint")) { //$NON-NLS-1$
944 *ppvObject = cast(void*)cast(IOleDocumentSite)iOleDocumentSite; 944 *ppvObject = cast(void*)cast(IOleDocumentSite)iOleDocumentSite;
945 AddRef(); 945 AddRef();
946 return COM.S_OK; 946 return COM.S_OK;
947 } 947 }
1235 * Displays a dialog with the property information for this OLE Object. The OLE Document or 1235 * Displays a dialog with the property information for this OLE Object. The OLE Document or
1236 * ActiveX Control must support the ISpecifyPropertyPages interface. 1236 * ActiveX Control must support the ISpecifyPropertyPages interface.
1237 * 1237 *
1238 * @param title the name that will appear in the titlebar of the dialog 1238 * @param title the name that will appear in the titlebar of the dialog
1239 */ 1239 */
1240 public void showProperties(char[] title) { 1240 public void showProperties(String title) {
1241 1241
1242 // Get the Property Page information from the OLE Object 1242 // Get the Property Page information from the OLE Object
1243 ISpecifyPropertyPages objISPP; 1243 ISpecifyPropertyPages objISPP;
1244 if (objIUnknown.QueryInterface(&COM.IIDISpecifyPropertyPages, cast(void**)&objISPP) !is COM.S_OK) return; 1244 if (objIUnknown.QueryInterface(&COM.IIDISpecifyPropertyPages, cast(void**)&objISPP) !is COM.S_OK) return;
1245 CAUUID* caGUID = new CAUUID(); 1245 CAUUID* caGUID = new CAUUID();