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 WINE_DEFAULT_DEBUG_CHANNEL(browseui
);
26 void CACLMulti::release_obj(struct ACLMultiSublist
*obj
)
30 obj
->pEnum
->Release();
35 CACLMulti::CACLMulti()
42 CACLMulti::~CACLMulti()
46 TRACE("destroying %p\n", this);
47 for (i
= 0; i
< fObjectCount
; i
++)
48 release_obj(&fObjects
[i
]);
49 CoTaskMemFree(fObjects
);
52 HRESULT STDMETHODCALLTYPE
CACLMulti::Append(IUnknown
*punk
)
54 TRACE("(%p, %p)\n", this, punk
);
58 fObjects
= reinterpret_cast<struct ACLMultiSublist
*>(CoTaskMemRealloc(fObjects
, sizeof(fObjects
[0]) * (fObjectCount
+ 1)));
59 fObjects
[fObjectCount
].punk
= punk
;
61 if (FAILED(punk
->QueryInterface(IID_IEnumString
, (void **)&fObjects
[fObjectCount
].pEnum
)))
62 fObjects
[fObjectCount
].pEnum
= NULL
;
63 if (FAILED(punk
->QueryInterface(IID_IACList
, (void **)&fObjects
[fObjectCount
].pACL
)))
64 fObjects
[fObjectCount
].pACL
= NULL
;
69 HRESULT STDMETHODCALLTYPE
CACLMulti::Remove(IUnknown
*punk
)
73 TRACE("(%p, %p)\n", this, punk
);
74 for (i
= 0; i
< fObjectCount
; i
++)
75 if (fObjects
[i
].punk
== punk
)
77 release_obj(&fObjects
[i
]);
78 memmove(&fObjects
[i
], &fObjects
[i
+ 1], (fObjectCount
- i
- 1) * sizeof(struct ACLMultiSublist
));
80 fObjects
= reinterpret_cast<struct ACLMultiSublist
*>(CoTaskMemRealloc(fObjects
, sizeof(fObjects
[0]) * fObjectCount
));
87 HRESULT STDMETHODCALLTYPE
CACLMulti::Next(ULONG celt
, LPOLESTR
*rgelt
, ULONG
*pceltFetched
)
89 TRACE("(%p, %d, %p, %p)\n", this, celt
, rgelt
, pceltFetched
);
90 while (fCurrentObject
< fObjectCount
)
92 if (fObjects
[fCurrentObject
].pEnum
)
94 /* native browseui 6.0 also returns only one element */
95 HRESULT ret
= fObjects
[fCurrentObject
].pEnum
->Next(1, rgelt
, pceltFetched
);
108 HRESULT STDMETHODCALLTYPE
CACLMulti::Reset()
113 for (i
= 0; i
< fObjectCount
; i
++)
115 if (fObjects
[i
].pEnum
)
116 fObjects
[i
].pEnum
->Reset();
121 HRESULT STDMETHODCALLTYPE
CACLMulti::Skip(ULONG celt
)
123 /* native browseui 6.0 returns this: */
127 HRESULT STDMETHODCALLTYPE
CACLMulti::Clone(IEnumString
**ppOut
)
130 /* native browseui 6.0 returns this: */
131 return E_OUTOFMEMORY
;
134 HRESULT STDMETHODCALLTYPE
CACLMulti::Expand(LPCWSTR wstr
)
139 for (i
= 0; i
< fObjectCount
; i
++)
141 if (!fObjects
[i
].pACL
)
143 res
= fObjects
[i
].pACL
->Expand(wstr
);