Update ooo320-m1
[ooovba.git] / fpicker / source / win32 / filepicker / customcontrolcontainer.cxx
blob3d1d8ff91a5f8441c907ce24c2db4b870aab537e
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: customcontrolcontainer.cxx,v $
10 * $Revision: 1.4 $
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"
33 #include "customcontrolcontainer.hxx"
35 #include <algorithm>
36 #include <functional>
38 //-----------------------------------
40 //-----------------------------------
42 namespace /* private */
44 void DeleteCustomControl(CCustomControl* aCustomControl)
46 delete aCustomControl;
49 void AlignCustomControl(CCustomControl* aCustomControl)
51 aCustomControl->Align();
54 class CSetFontHelper
56 public:
57 CSetFontHelper(HFONT hFont) :
58 m_hFont(hFont)
62 void SAL_CALL operator()(CCustomControl* aCustomControl)
64 aCustomControl->SetFont(m_hFont);
67 private:
68 HFONT m_hFont;
72 //-----------------------------------
74 //-----------------------------------
76 CCustomControlContainer::~CCustomControlContainer()
78 RemoveAllControls();
81 //-----------------------------------
83 //-----------------------------------
85 void SAL_CALL CCustomControlContainer::Align()
87 std::for_each(
88 m_ControlContainer.begin(),
89 m_ControlContainer.end(),
90 AlignCustomControl);
93 //-----------------------------------
95 //-----------------------------------
97 void SAL_CALL CCustomControlContainer::SetFont(HFONT hFont)
99 CSetFontHelper aSetFontHelper(hFont);
101 std::for_each(
102 m_ControlContainer.begin(),
103 m_ControlContainer.end(),
104 aSetFontHelper);
107 //-----------------------------------
109 //-----------------------------------
111 void SAL_CALL CCustomControlContainer::AddControl(CCustomControl* aCustomControl)
113 m_ControlContainer.push_back(aCustomControl);
116 //-----------------------------------
118 //-----------------------------------
120 void SAL_CALL CCustomControlContainer::RemoveControl(CCustomControl* aCustomControl)
122 ControlContainer_t::iterator iter_end = m_ControlContainer.end();
124 ControlContainer_t::iterator iter =
125 std::find(m_ControlContainer.begin(),iter_end,aCustomControl);
127 if (iter != iter_end)
129 delete *iter;
130 m_ControlContainer.remove(aCustomControl);
134 //-----------------------------------
136 //-----------------------------------
138 void SAL_CALL CCustomControlContainer::RemoveAllControls()
140 std::for_each(
141 m_ControlContainer.begin(),
142 m_ControlContainer.end(),
143 DeleteCustomControl);
145 m_ControlContainer.clear();