2 * Multisource AutoComplete list
4 * Copyright 2007 Mikolaj Zalewski
5 * Copyright 2009 Andrew Hill
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include <shlobj_undoc.h>
26 #include <shlguid_undoc.h>
32 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(browseui
);
37 void CACLMulti::release_obj(struct ACLMultiSublist
*obj
)
41 obj
->pEnum
->Release();
46 CACLMulti::CACLMulti()
53 CACLMulti::~CACLMulti()
57 TRACE("destroying %p\n", this);
58 for (i
= 0; i
< fObjectCount
; i
++)
59 release_obj(&fObjects
[i
]);
60 CoTaskMemFree(fObjects
);
63 HRESULT STDMETHODCALLTYPE
CACLMulti::Append(IUnknown
*punk
)
65 TRACE("(%p, %p)\n", this, punk
);
69 fObjects
= reinterpret_cast<struct ACLMultiSublist
*>(CoTaskMemRealloc(fObjects
, sizeof(fObjects
[0]) * (fObjectCount
+ 1)));
70 fObjects
[fObjectCount
].punk
= punk
;
72 if (FAILED(punk
->QueryInterface(IID_IEnumString
, (void **)&fObjects
[fObjectCount
].pEnum
)))
73 fObjects
[fObjectCount
].pEnum
= NULL
;
74 if (FAILED(punk
->QueryInterface(IID_IACList
, (void **)&fObjects
[fObjectCount
].pACL
)))
75 fObjects
[fObjectCount
].pACL
= NULL
;
80 HRESULT STDMETHODCALLTYPE
CACLMulti::Remove(IUnknown
*punk
)
84 TRACE("(%p, %p)\n", this, punk
);
85 for (i
= 0; i
< fObjectCount
; i
++)
86 if (fObjects
[i
].punk
== punk
)
88 release_obj(&fObjects
[i
]);
89 memmove(&fObjects
[i
], &fObjects
[i
+ 1], (fObjectCount
- i
- 1) * sizeof(struct ACLMultiSublist
));
91 fObjects
= reinterpret_cast<struct ACLMultiSublist
*>(CoTaskMemRealloc(fObjects
, sizeof(fObjects
[0]) * fObjectCount
));
98 HRESULT STDMETHODCALLTYPE
CACLMulti::Next(ULONG celt
, LPOLESTR
*rgelt
, ULONG
*pceltFetched
)
100 TRACE("(%p, %d, %p, %p)\n", this, celt
, rgelt
, pceltFetched
);
101 while (fCurrentObject
< fObjectCount
)
103 if (fObjects
[fCurrentObject
].pEnum
)
105 /* native browseui 6.0 also returns only one element */
106 HRESULT ret
= fObjects
[fCurrentObject
].pEnum
->Next(1, rgelt
, pceltFetched
);
119 HRESULT STDMETHODCALLTYPE
CACLMulti::Reset()
124 for (i
= 0; i
< fObjectCount
; i
++)
126 if (fObjects
[i
].pEnum
)
127 fObjects
[i
].pEnum
->Reset();
132 HRESULT STDMETHODCALLTYPE
CACLMulti::Skip(ULONG celt
)
134 /* native browseui 6.0 returns this: */
138 HRESULT STDMETHODCALLTYPE
CACLMulti::Clone(IEnumString
**ppOut
)
141 /* native browseui 6.0 returns this: */
142 return E_OUTOFMEMORY
;
145 HRESULT STDMETHODCALLTYPE
CACLMulti::Expand(LPCWSTR wstr
)
150 for (i
= 0; i
< fObjectCount
; i
++)
152 if (!fObjects
[i
].pACL
)
154 res
= fObjects
[i
].pACL
->Expand(wstr
);