merged tag ooo/DEV300_m102
[LibreOffice.git] / fpicker / source / win32 / filepicker / customcontrolcontainer.cxx
blobe1afa16868f2409bc52faf3924f6c45c166bbc96
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_fpicker.hxx"
30 #include "customcontrolcontainer.hxx"
32 #include <algorithm>
33 #include <functional>
35 //-----------------------------------
37 //-----------------------------------
39 namespace /* private */
41 void DeleteCustomControl(CCustomControl* aCustomControl)
43 delete aCustomControl;
46 void AlignCustomControl(CCustomControl* aCustomControl)
48 aCustomControl->Align();
51 class CSetFontHelper
53 public:
54 CSetFontHelper(HFONT hFont) :
55 m_hFont(hFont)
59 void SAL_CALL operator()(CCustomControl* aCustomControl)
61 aCustomControl->SetFont(m_hFont);
64 private:
65 HFONT m_hFont;
69 //-----------------------------------
71 //-----------------------------------
73 CCustomControlContainer::~CCustomControlContainer()
75 RemoveAllControls();
78 //-----------------------------------
80 //-----------------------------------
82 void SAL_CALL CCustomControlContainer::Align()
84 std::for_each(
85 m_ControlContainer.begin(),
86 m_ControlContainer.end(),
87 AlignCustomControl);
90 //-----------------------------------
92 //-----------------------------------
94 void SAL_CALL CCustomControlContainer::SetFont(HFONT hFont)
96 CSetFontHelper aSetFontHelper(hFont);
98 std::for_each(
99 m_ControlContainer.begin(),
100 m_ControlContainer.end(),
101 aSetFontHelper);
104 //-----------------------------------
106 //-----------------------------------
108 void SAL_CALL CCustomControlContainer::AddControl(CCustomControl* aCustomControl)
110 m_ControlContainer.push_back(aCustomControl);
113 //-----------------------------------
115 //-----------------------------------
117 void SAL_CALL CCustomControlContainer::RemoveControl(CCustomControl* aCustomControl)
119 ControlContainer_t::iterator iter_end = m_ControlContainer.end();
121 ControlContainer_t::iterator iter =
122 std::find(m_ControlContainer.begin(),iter_end,aCustomControl);
124 if (iter != iter_end)
126 delete *iter;
127 m_ControlContainer.remove(aCustomControl);
131 //-----------------------------------
133 //-----------------------------------
135 void SAL_CALL CCustomControlContainer::RemoveAllControls()
137 std::for_each(
138 m_ControlContainer.begin(),
139 m_ControlContainer.end(),
140 DeleteCustomControl);
142 m_ControlContainer.clear();