merge the formfield patch from ooo-build
[ooovba.git] / fpicker / source / win32 / filepicker / customcontrolfactory.cxx
blob8fbfc6c660440b2596a93324e570b87dc12cb177
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: customcontrolfactory.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_fpicker.hxx"
34 #include <tchar.h>
35 #include "customcontrolfactory.hxx"
36 #include "customcontrolcontainer.hxx"
37 #include "dialogcustomcontrols.hxx"
38 #include <osl/diagnose.h>
40 //-----------------------------------
41 //
42 //-----------------------------------
44 CCustomControl* CCustomControlFactory::CreateCustomControl(HWND aControlHandle, HWND aParentHandle)
46 OSL_PRECOND(IsWindow(aControlHandle),"Invalid control handle");
47 OSL_PRECOND(IsWindow(aControlHandle),"Invalid parent handle");
49 // get window class
50 // if static text create static text control etc.
52 TCHAR aClsName[256];
53 ZeroMemory(aClsName,sizeof(aClsName));
54 if (GetClassName(aControlHandle,aClsName,sizeof(aClsName)) == 0) {
55 OSL_ENSURE(false,"Invalid window handle");
58 if (0 == _tcsicmp(aClsName,TEXT("button")))
60 // button means many things so we have
61 // to find out what button it is
62 LONG lBtnStyle = GetWindowLong(aControlHandle,GWL_STYLE);
64 if (lBtnStyle & BS_CHECKBOX)
65 return new CCheckboxCustomControl(aControlHandle,aParentHandle);
67 if ( ((lBtnStyle & BS_PUSHBUTTON) == 0) || (lBtnStyle & BS_DEFPUSHBUTTON))
68 return new CPushButtonCustomControl(aControlHandle,aParentHandle);
70 return new CDummyCustomControl(aControlHandle,aParentHandle);
73 if (0 == _tcsicmp(aClsName,TEXT("listbox")) || 0 == _tcsicmp(aClsName,TEXT("combobox")))
74 return new CComboboxCustomControl(aControlHandle,aParentHandle);
76 if (0 == _tcsicmp(aClsName,TEXT("static")))
77 return new CStaticCustomControl(aControlHandle,aParentHandle);
79 return new CDummyCustomControl(aControlHandle,aParentHandle);
82 //-----------------------------------
83 //
84 //-----------------------------------
86 CCustomControl* CCustomControlFactory::CreateCustomControlContainer()
88 return new CCustomControlContainer();