1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TaskPaneControlFactory.hxx,v $
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 #ifndef SD_TASKPANE_CONTROL_FACTORY_HXX
32 #define SD_TASKPANE_CONTROL_FACTORY_HXX
34 #include "taskpane/TaskPaneTreeNode.hxx"
42 namespace sd
{ namespace toolpanel
{
49 namespace sd
{ namespace toolpanel
{
51 /** A simple factory base class defines the interface that is used by
52 some of the control containers of the task pane to create controls on
53 demand when they are about to be displayed for the first time.
55 It provides the InternalCreateControl() method as hook that can be
56 overloaded by derived classes to provide a new control.
61 ControlFactory (void);
62 virtual ~ControlFactory (void);
64 /** Derived classes should overload InternalCreateControl(), not this
67 ::std::auto_ptr
<TreeNode
> CreateControl (TreeNode
* pTreeNode
);
70 /** This is the internal hook for derived classes to overload in order
71 to provide a new control instance.
73 virtual TreeNode
* InternalCreateControl (TreeNode
* pTreeNode
) = 0;
78 /** A simple helper class that realizes a ControlFactory that provides its
79 newly created controls with one additional argument (additional to the
82 template<class ControlType
, class ArgumentType
>
83 class ControlFactoryWithArgs1
84 : public ControlFactory
87 ControlFactoryWithArgs1 (ArgumentType
& rArgument
)
88 : mrArgument(rArgument
)
92 virtual TreeNode
* InternalCreateControl (TreeNode
* pTreeNode
)
94 return new ControlType(pTreeNode
, mrArgument
);
98 ArgumentType
& mrArgument
;
102 } } // end of namespace ::sd::toolpanel