xref: /AOO41X/main/extensions/source/propctrlr/propertyeditor.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_extensions.hxx"
30*cdf0e10cSrcweir #include "propertyeditor.hxx"
31*cdf0e10cSrcweir #include "browserpage.hxx"
32*cdf0e10cSrcweir #include "linedescriptor.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir /** === begin UNO includes === **/
35*cdf0e10cSrcweir /** === end UNO includes === **/
36*cdf0e10cSrcweir #include <tools/debug.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir //............................................................................
39*cdf0e10cSrcweir namespace pcr
40*cdf0e10cSrcweir {
41*cdf0e10cSrcweir //............................................................................
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir     #define LAYOUT_BORDER_LEFT      3
44*cdf0e10cSrcweir     #define LAYOUT_BORDER_TOP       3
45*cdf0e10cSrcweir     #define LAYOUT_BORDER_RIGHT     3
46*cdf0e10cSrcweir     #define LAYOUT_BORDER_BOTTOM    3
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir     /** === begin UNO using === **/
49*cdf0e10cSrcweir     using ::com::sun::star::uno::Any;
50*cdf0e10cSrcweir     using ::com::sun::star::inspection::XPropertyControl;
51*cdf0e10cSrcweir     using ::com::sun::star::uno::Reference;
52*cdf0e10cSrcweir     /** === end UNO using === **/
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir     //==================================================================
55*cdf0e10cSrcweir     // class OPropertyEditor
56*cdf0e10cSrcweir     //==================================================================
57*cdf0e10cSrcweir     DBG_NAME(OPropertyEditor)
58*cdf0e10cSrcweir     //------------------------------------------------------------------
59*cdf0e10cSrcweir     OPropertyEditor::OPropertyEditor( Window* pParent, WinBits nWinStyle)
60*cdf0e10cSrcweir             :Control(pParent, nWinStyle)
61*cdf0e10cSrcweir             ,m_aTabControl( this )
62*cdf0e10cSrcweir             ,m_nNextId(1)
63*cdf0e10cSrcweir             ,m_bHasHelpSection( false )
64*cdf0e10cSrcweir             ,m_nMinHelpLines( 0 )
65*cdf0e10cSrcweir             ,m_nMaxHelpLines( 0 )
66*cdf0e10cSrcweir     {
67*cdf0e10cSrcweir         DBG_CTOR(OPropertyEditor,NULL);
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir         m_aTabControl.Show();
70*cdf0e10cSrcweir         m_aTabControl.SetDeactivatePageHdl(LINK(this, OPropertyEditor, OnPageDeactivate));
71*cdf0e10cSrcweir         m_aTabControl.SetActivatePageHdl(LINK(this, OPropertyEditor, OnPageActivate));
72*cdf0e10cSrcweir         m_aTabControl.SetBackground(GetBackground());
73*cdf0e10cSrcweir         m_aTabControl.SetPaintTransparent(sal_True);
74*cdf0e10cSrcweir     }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     //------------------------------------------------------------------
77*cdf0e10cSrcweir     OPropertyEditor::~OPropertyEditor()
78*cdf0e10cSrcweir     {
79*cdf0e10cSrcweir         Hide();
80*cdf0e10cSrcweir         ClearAll();
81*cdf0e10cSrcweir         DBG_DTOR(OPropertyEditor,NULL);
82*cdf0e10cSrcweir     }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     //------------------------------------------------------------------
85*cdf0e10cSrcweir     void OPropertyEditor::ClearAll()
86*cdf0e10cSrcweir     {
87*cdf0e10cSrcweir         m_nNextId=1;
88*cdf0e10cSrcweir         sal_uInt16 nCount = m_aTabControl.GetPageCount();
89*cdf0e10cSrcweir         for(long i = nCount-1; i >= 0; --i)
90*cdf0e10cSrcweir         {
91*cdf0e10cSrcweir             sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i);
92*cdf0e10cSrcweir             OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
93*cdf0e10cSrcweir             if (pPage)
94*cdf0e10cSrcweir             {
95*cdf0e10cSrcweir                 pPage->EnableInput(sal_False);
96*cdf0e10cSrcweir                 m_aTabControl.RemovePage(nID);
97*cdf0e10cSrcweir                 delete pPage;
98*cdf0e10cSrcweir             }
99*cdf0e10cSrcweir         }
100*cdf0e10cSrcweir         m_aTabControl.Clear();
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir         {
103*cdf0e10cSrcweir             MapStringToPageId aEmpty;
104*cdf0e10cSrcweir             m_aPropertyPageIds.swap( aEmpty );
105*cdf0e10cSrcweir         }
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir         while ( !m_aHiddenPages.empty() )
108*cdf0e10cSrcweir         {
109*cdf0e10cSrcweir             delete m_aHiddenPages.begin()->second.pPage;
110*cdf0e10cSrcweir             m_aHiddenPages.erase( m_aHiddenPages.begin() );
111*cdf0e10cSrcweir         }
112*cdf0e10cSrcweir     }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     //------------------------------------------------------------------
115*cdf0e10cSrcweir     sal_Int32 OPropertyEditor::getMinimumHeight()
116*cdf0e10cSrcweir     {
117*cdf0e10cSrcweir         sal_Int32 nMinHeight( LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM );
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir         if ( m_aTabControl.GetPageCount() > 0 )
120*cdf0e10cSrcweir         {
121*cdf0e10cSrcweir             sal_uInt16 nFirstID = m_aTabControl.GetPageId( 0 );
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir             // reserve space for the tabs themself
124*cdf0e10cSrcweir             Rectangle aTabArea( m_aTabControl.GetTabBounds( nFirstID ) );
125*cdf0e10cSrcweir             nMinHeight += aTabArea.GetHeight();
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir             // ask the page how much it requires
128*cdf0e10cSrcweir             OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nFirstID ) );
129*cdf0e10cSrcweir             if ( pPage )
130*cdf0e10cSrcweir                 nMinHeight += pPage->getMinimumHeight();
131*cdf0e10cSrcweir         }
132*cdf0e10cSrcweir         else
133*cdf0e10cSrcweir             nMinHeight += 250;  // arbitrary ...
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir         return nMinHeight;
136*cdf0e10cSrcweir     }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     //------------------------------------------------------------------
139*cdf0e10cSrcweir     sal_Int32 OPropertyEditor::getMinimumWidth()
140*cdf0e10cSrcweir     {
141*cdf0e10cSrcweir         sal_uInt16 nCount = m_aTabControl.GetPageCount();
142*cdf0e10cSrcweir         sal_Int32 nPageMinWidth = 0;
143*cdf0e10cSrcweir         for(long i = nCount-1; i >= 0; --i)
144*cdf0e10cSrcweir         {
145*cdf0e10cSrcweir             sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i);
146*cdf0e10cSrcweir             OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
147*cdf0e10cSrcweir             if (pPage)
148*cdf0e10cSrcweir             {
149*cdf0e10cSrcweir                 sal_Int32 nCurPageMinWidth = pPage->getMinimumWidth();
150*cdf0e10cSrcweir                 if( nCurPageMinWidth > nPageMinWidth )
151*cdf0e10cSrcweir                     nPageMinWidth = nCurPageMinWidth;
152*cdf0e10cSrcweir             }
153*cdf0e10cSrcweir         }
154*cdf0e10cSrcweir         return nPageMinWidth+6;
155*cdf0e10cSrcweir     }
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     //------------------------------------------------------------------
158*cdf0e10cSrcweir     void OPropertyEditor::CommitModified()
159*cdf0e10cSrcweir     {
160*cdf0e10cSrcweir         // commit all of my pages, if necessary
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir         sal_uInt16 nCount = m_aTabControl.GetPageCount();
163*cdf0e10cSrcweir         for ( sal_uInt16 i=0; i<nCount; ++i )
164*cdf0e10cSrcweir         {
165*cdf0e10cSrcweir             sal_uInt16 nID = m_aTabControl.GetPageId( i );
166*cdf0e10cSrcweir             OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) );
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir             if ( pPage && pPage->getListBox().IsModified() )
169*cdf0e10cSrcweir                 pPage->getListBox().CommitModified();
170*cdf0e10cSrcweir         }
171*cdf0e10cSrcweir     }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     //------------------------------------------------------------------
174*cdf0e10cSrcweir     void OPropertyEditor::GetFocus()
175*cdf0e10cSrcweir     {
176*cdf0e10cSrcweir         m_aTabControl.GrabFocus();
177*cdf0e10cSrcweir     }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     //------------------------------------------------------------------
180*cdf0e10cSrcweir     OBrowserPage* OPropertyEditor::getPage( const ::rtl::OUString& _rPropertyName )
181*cdf0e10cSrcweir     {
182*cdf0e10cSrcweir         OBrowserPage* pPage = NULL;
183*cdf0e10cSrcweir         MapStringToPageId::const_iterator aPropertyPageIdPos = m_aPropertyPageIds.find( _rPropertyName );
184*cdf0e10cSrcweir         if ( aPropertyPageIdPos != m_aPropertyPageIds.end() )
185*cdf0e10cSrcweir             pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( aPropertyPageIdPos->second ) );
186*cdf0e10cSrcweir         return pPage;
187*cdf0e10cSrcweir     }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir     //------------------------------------------------------------------
190*cdf0e10cSrcweir     const OBrowserPage* OPropertyEditor::getPage( const ::rtl::OUString& _rPropertyName ) const
191*cdf0e10cSrcweir     {
192*cdf0e10cSrcweir         return const_cast< OPropertyEditor* >( this )->getPage( _rPropertyName );
193*cdf0e10cSrcweir     }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     //------------------------------------------------------------------
196*cdf0e10cSrcweir     OBrowserPage* OPropertyEditor::getPage( sal_uInt16& _rPageId )
197*cdf0e10cSrcweir     {
198*cdf0e10cSrcweir         return static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( _rPageId ) );
199*cdf0e10cSrcweir     }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir     //------------------------------------------------------------------
202*cdf0e10cSrcweir     const OBrowserPage* OPropertyEditor::getPage( sal_uInt16& _rPageId ) const
203*cdf0e10cSrcweir     {
204*cdf0e10cSrcweir         return const_cast< OPropertyEditor* >( this )->getPage( _rPageId );
205*cdf0e10cSrcweir     }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     //------------------------------------------------------------------
208*cdf0e10cSrcweir     void OPropertyEditor::Resize()
209*cdf0e10cSrcweir     {
210*cdf0e10cSrcweir         Rectangle aPlayground(
211*cdf0e10cSrcweir             Point( LAYOUT_BORDER_LEFT, LAYOUT_BORDER_TOP ),
212*cdf0e10cSrcweir             Size(
213*cdf0e10cSrcweir                 GetOutputSizePixel().Width() - LAYOUT_BORDER_LEFT - LAYOUT_BORDER_RIGHT,
214*cdf0e10cSrcweir                 GetOutputSizePixel().Height() - LAYOUT_BORDER_TOP - LAYOUT_BORDER_BOTTOM
215*cdf0e10cSrcweir             )
216*cdf0e10cSrcweir         );
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir         Rectangle aTabArea( aPlayground );
219*cdf0e10cSrcweir         m_aTabControl.SetPosSizePixel( aTabArea.TopLeft(), aTabArea.GetSize() );
220*cdf0e10cSrcweir     }
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     //------------------------------------------------------------------
223*cdf0e10cSrcweir     sal_uInt16 OPropertyEditor::AppendPage( const String & _rText, const rtl::OString& _rHelpId )
224*cdf0e10cSrcweir     {
225*cdf0e10cSrcweir         // obtain a new id
226*cdf0e10cSrcweir         sal_uInt16 nId = m_nNextId++;
227*cdf0e10cSrcweir         // insert the id
228*cdf0e10cSrcweir         m_aTabControl.InsertPage(nId, _rText);
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir         // create a new page
231*cdf0e10cSrcweir         OBrowserPage* pPage = new OBrowserPage(&m_aTabControl);
232*cdf0e10cSrcweir         pPage->SetText( _rText );
233*cdf0e10cSrcweir         // some knittings
234*cdf0e10cSrcweir         pPage->SetSizePixel(m_aTabControl.GetTabPageSizePixel());
235*cdf0e10cSrcweir         pPage->getListBox().SetListener(m_pListener);
236*cdf0e10cSrcweir         pPage->getListBox().SetObserver(m_pObserver);
237*cdf0e10cSrcweir         pPage->getListBox().EnableHelpSection( m_bHasHelpSection );
238*cdf0e10cSrcweir         pPage->getListBox().SetHelpLineLimites( m_nMinHelpLines, m_nMaxHelpLines );
239*cdf0e10cSrcweir         pPage->SetHelpId( _rHelpId );
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir         // immediately activate the page
242*cdf0e10cSrcweir         m_aTabControl.SetTabPage(nId, pPage);
243*cdf0e10cSrcweir         m_aTabControl.SetCurPageId(nId);
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir         return nId;
246*cdf0e10cSrcweir     }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     //------------------------------------------------------------------
249*cdf0e10cSrcweir     void OPropertyEditor::SetHelpId( const rtl::OString& rHelpId )
250*cdf0e10cSrcweir     {
251*cdf0e10cSrcweir         Control::SetHelpId("");
252*cdf0e10cSrcweir         m_aTabControl.SetHelpId(rHelpId);
253*cdf0e10cSrcweir     }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     //------------------------------------------------------------------
256*cdf0e10cSrcweir     void OPropertyEditor::RemovePage(sal_uInt16 nID)
257*cdf0e10cSrcweir     {
258*cdf0e10cSrcweir         OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir         if (pPage)
261*cdf0e10cSrcweir             pPage->EnableInput(sal_False);
262*cdf0e10cSrcweir         m_aTabControl.RemovePage(nID);
263*cdf0e10cSrcweir         if (pPage)
264*cdf0e10cSrcweir             delete pPage;
265*cdf0e10cSrcweir     }
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir     //------------------------------------------------------------------
268*cdf0e10cSrcweir     void OPropertyEditor::SetPage(sal_uInt16 nId)
269*cdf0e10cSrcweir     {
270*cdf0e10cSrcweir         m_aTabControl.SetCurPageId(nId);
271*cdf0e10cSrcweir     }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir     //------------------------------------------------------------------
274*cdf0e10cSrcweir     sal_uInt16 OPropertyEditor::GetCurPage()
275*cdf0e10cSrcweir     {
276*cdf0e10cSrcweir         if(m_aTabControl.GetPageCount()>0)
277*cdf0e10cSrcweir             return m_aTabControl.GetCurPageId();
278*cdf0e10cSrcweir         else
279*cdf0e10cSrcweir             return 0;
280*cdf0e10cSrcweir     }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir     //------------------------------------------------------------------
283*cdf0e10cSrcweir     void OPropertyEditor::Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction)
284*cdf0e10cSrcweir     {
285*cdf0e10cSrcweir         // forward this to all our pages
286*cdf0e10cSrcweir         sal_uInt16 nCount = m_aTabControl.GetPageCount();
287*cdf0e10cSrcweir         for (sal_uInt16 i=0;i<nCount;++i)
288*cdf0e10cSrcweir         {
289*cdf0e10cSrcweir             sal_uInt16 nID = m_aTabControl.GetPageId(i);
290*cdf0e10cSrcweir             OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
291*cdf0e10cSrcweir             if (pPage)
292*cdf0e10cSrcweir                 _aUpdateFunction(&pPage->getListBox());
293*cdf0e10cSrcweir         }
294*cdf0e10cSrcweir     }
295*cdf0e10cSrcweir     //------------------------------------------------------------------
296*cdf0e10cSrcweir     void OPropertyEditor::EnableUpdate()
297*cdf0e10cSrcweir     {
298*cdf0e10cSrcweir         Update(::std::mem_fun(&OBrowserListBox::EnableUpdate));
299*cdf0e10cSrcweir     }
300*cdf0e10cSrcweir     //------------------------------------------------------------------
301*cdf0e10cSrcweir     void OPropertyEditor::DisableUpdate()
302*cdf0e10cSrcweir     {
303*cdf0e10cSrcweir         Update(::std::mem_fun(&OBrowserListBox::DisableUpdate));
304*cdf0e10cSrcweir     }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir     //------------------------------------------------------------------
307*cdf0e10cSrcweir     void OPropertyEditor::forEachPage( PageOperation _pOperation, const void* _pArgument )
308*cdf0e10cSrcweir     {
309*cdf0e10cSrcweir         sal_uInt16 nCount = m_aTabControl.GetPageCount();
310*cdf0e10cSrcweir         for ( sal_uInt16 i=0; i<nCount; ++i )
311*cdf0e10cSrcweir         {
312*cdf0e10cSrcweir             sal_uInt16 nID = m_aTabControl.GetPageId(i);
313*cdf0e10cSrcweir             OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) );
314*cdf0e10cSrcweir             if ( !pPage )
315*cdf0e10cSrcweir                 continue;
316*cdf0e10cSrcweir             (this->*_pOperation)( *pPage, _pArgument );
317*cdf0e10cSrcweir         }
318*cdf0e10cSrcweir     }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     //------------------------------------------------------------------
321*cdf0e10cSrcweir     void OPropertyEditor::setPageLineListener( OBrowserPage& _rPage, const void* )
322*cdf0e10cSrcweir     {
323*cdf0e10cSrcweir         _rPage.getListBox().SetListener( m_pListener );
324*cdf0e10cSrcweir     }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir     //------------------------------------------------------------------
327*cdf0e10cSrcweir     void OPropertyEditor::SetLineListener(IPropertyLineListener* _pListener)
328*cdf0e10cSrcweir     {
329*cdf0e10cSrcweir         m_pListener = _pListener;
330*cdf0e10cSrcweir         forEachPage( &OPropertyEditor::setPageLineListener );
331*cdf0e10cSrcweir     }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir     //------------------------------------------------------------------
334*cdf0e10cSrcweir     void OPropertyEditor::setPageControlObserver( OBrowserPage& _rPage, const void* )
335*cdf0e10cSrcweir     {
336*cdf0e10cSrcweir         _rPage.getListBox().SetObserver( m_pObserver );
337*cdf0e10cSrcweir     }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir     //------------------------------------------------------------------
340*cdf0e10cSrcweir     void OPropertyEditor::SetControlObserver( IPropertyControlObserver* _pObserver )
341*cdf0e10cSrcweir     {
342*cdf0e10cSrcweir         m_pObserver = _pObserver;
343*cdf0e10cSrcweir         forEachPage( &OPropertyEditor::setPageControlObserver );
344*cdf0e10cSrcweir     }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir     //------------------------------------------------------------------
347*cdf0e10cSrcweir     void OPropertyEditor::EnableHelpSection( bool _bEnable )
348*cdf0e10cSrcweir     {
349*cdf0e10cSrcweir         m_bHasHelpSection = _bEnable;
350*cdf0e10cSrcweir         forEachPage( &OPropertyEditor::enableHelpSection );
351*cdf0e10cSrcweir     }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir     //------------------------------------------------------------------
354*cdf0e10cSrcweir     bool OPropertyEditor::HasHelpSection() const
355*cdf0e10cSrcweir     {
356*cdf0e10cSrcweir         return m_bHasHelpSection;
357*cdf0e10cSrcweir     }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir     //------------------------------------------------------------------
360*cdf0e10cSrcweir     void OPropertyEditor::SetHelpText( const ::rtl::OUString& _rHelpText )
361*cdf0e10cSrcweir     {
362*cdf0e10cSrcweir         forEachPage( &OPropertyEditor::setHelpSectionText, &_rHelpText );
363*cdf0e10cSrcweir     }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     //------------------------------------------------------------------
366*cdf0e10cSrcweir     void OPropertyEditor::SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
367*cdf0e10cSrcweir     {
368*cdf0e10cSrcweir         m_nMinHelpLines = _nMinLines;
369*cdf0e10cSrcweir         m_nMaxHelpLines = _nMaxLines;
370*cdf0e10cSrcweir         forEachPage( &OPropertyEditor::setHelpLineLimits );
371*cdf0e10cSrcweir     }
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir     //------------------------------------------------------------------
374*cdf0e10cSrcweir     void OPropertyEditor::enableHelpSection( OBrowserPage& _rPage, const void* )
375*cdf0e10cSrcweir     {
376*cdf0e10cSrcweir         _rPage.getListBox().EnableHelpSection( m_bHasHelpSection );
377*cdf0e10cSrcweir     }
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     //------------------------------------------------------------------
380*cdf0e10cSrcweir     void OPropertyEditor::setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString )
381*cdf0e10cSrcweir     {
382*cdf0e10cSrcweir         OSL_ENSURE( _pPointerToOUString, "OPropertyEditor::setHelpSectionText: invalid argument!" );
383*cdf0e10cSrcweir         if ( !_pPointerToOUString )
384*cdf0e10cSrcweir             return;
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir         const ::rtl::OUString& rText( *(const ::rtl::OUString*)_pPointerToOUString );
387*cdf0e10cSrcweir         _rPage.getListBox().SetHelpText( rText );
388*cdf0e10cSrcweir     }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir     //------------------------------------------------------------------
391*cdf0e10cSrcweir     void OPropertyEditor::setHelpLineLimits( OBrowserPage& _rPage, const void* )
392*cdf0e10cSrcweir     {
393*cdf0e10cSrcweir         _rPage.getListBox().SetHelpLineLimites( m_nMinHelpLines, m_nMaxHelpLines );
394*cdf0e10cSrcweir     }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir     //------------------------------------------------------------------
397*cdf0e10cSrcweir     sal_uInt16 OPropertyEditor::InsertEntry( const OLineDescriptor& rData, sal_uInt16 _nPageId, sal_uInt16 nPos )
398*cdf0e10cSrcweir     {
399*cdf0e10cSrcweir         // let the current page handle this
400*cdf0e10cSrcweir         OBrowserPage* pPage = getPage( _nPageId );
401*cdf0e10cSrcweir         DBG_ASSERT( pPage, "OPropertyEditor::InsertEntry: don't have such a page!" );
402*cdf0e10cSrcweir         if ( !pPage )
403*cdf0e10cSrcweir             return LISTBOX_ENTRY_NOTFOUND;
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir         sal_uInt16 nEntry = pPage->getListBox().InsertEntry( rData, nPos );
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir         OSL_ENSURE( m_aPropertyPageIds.find( rData.sName ) == m_aPropertyPageIds.end(),
408*cdf0e10cSrcweir             "OPropertyEditor::InsertEntry: property already present in the map!" );
409*cdf0e10cSrcweir         m_aPropertyPageIds.insert( MapStringToPageId::value_type( rData.sName, _nPageId ) );
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir         return nEntry;
412*cdf0e10cSrcweir     }
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir     //------------------------------------------------------------------
415*cdf0e10cSrcweir     void OPropertyEditor::RemoveEntry( const ::rtl::OUString& _rName )
416*cdf0e10cSrcweir     {
417*cdf0e10cSrcweir         OBrowserPage* pPage = getPage( _rName );
418*cdf0e10cSrcweir         if ( pPage )
419*cdf0e10cSrcweir         {
420*cdf0e10cSrcweir             OSL_VERIFY( pPage->getListBox().RemoveEntry( _rName ) );
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir             OSL_ENSURE( m_aPropertyPageIds.find( _rName ) != m_aPropertyPageIds.end(),
423*cdf0e10cSrcweir                 "OPropertyEditor::RemoveEntry: property not present in the map!" );
424*cdf0e10cSrcweir             m_aPropertyPageIds.erase( _rName );
425*cdf0e10cSrcweir         }
426*cdf0e10cSrcweir     }
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir     //------------------------------------------------------------------
429*cdf0e10cSrcweir     void OPropertyEditor::ChangeEntry( const OLineDescriptor& rData )
430*cdf0e10cSrcweir     {
431*cdf0e10cSrcweir         OBrowserPage* pPage = getPage( rData.sName );
432*cdf0e10cSrcweir         if ( pPage )
433*cdf0e10cSrcweir             pPage->getListBox().ChangeEntry( rData, EDITOR_LIST_REPLACE_EXISTING );
434*cdf0e10cSrcweir     }
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir     //------------------------------------------------------------------
437*cdf0e10cSrcweir     void OPropertyEditor::SetPropertyValue( const ::rtl::OUString& rEntryName, const Any& _rValue, bool _bUnknownValue )
438*cdf0e10cSrcweir     {
439*cdf0e10cSrcweir         OBrowserPage* pPage = getPage( rEntryName );
440*cdf0e10cSrcweir         if ( pPage )
441*cdf0e10cSrcweir             pPage->getListBox().SetPropertyValue( rEntryName, _rValue, _bUnknownValue );
442*cdf0e10cSrcweir     }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir     //------------------------------------------------------------------
445*cdf0e10cSrcweir     sal_uInt16 OPropertyEditor::GetPropertyPos( const ::rtl::OUString& rEntryName ) const
446*cdf0e10cSrcweir     {
447*cdf0e10cSrcweir         sal_uInt16 nVal=LISTBOX_ENTRY_NOTFOUND;
448*cdf0e10cSrcweir         const OBrowserPage* pPage = getPage( rEntryName );
449*cdf0e10cSrcweir         if ( pPage )
450*cdf0e10cSrcweir             nVal = pPage->getListBox().GetPropertyPos( rEntryName );
451*cdf0e10cSrcweir         return nVal;
452*cdf0e10cSrcweir     }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir     //------------------------------------------------------------------
455*cdf0e10cSrcweir     void OPropertyEditor::ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow )
456*cdf0e10cSrcweir     {
457*cdf0e10cSrcweir         if ( !_bShow )
458*cdf0e10cSrcweir         {
459*cdf0e10cSrcweir             sal_uInt16 nPagePos = m_aTabControl.GetPagePos( _nPageId );
460*cdf0e10cSrcweir             if ( TAB_PAGE_NOTFOUND == nPagePos )
461*cdf0e10cSrcweir                 return;
462*cdf0e10cSrcweir             DBG_ASSERT( m_aHiddenPages.find( _nPageId ) == m_aHiddenPages.end(), "OPropertyEditor::ShowPropertyPage: page already hidden!" );
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir             m_aHiddenPages[ _nPageId ] = HiddenPage( nPagePos, m_aTabControl.GetTabPage( _nPageId ) );
465*cdf0e10cSrcweir             m_aTabControl.RemovePage( _nPageId );
466*cdf0e10cSrcweir         }
467*cdf0e10cSrcweir         else
468*cdf0e10cSrcweir         {
469*cdf0e10cSrcweir             ::std::map< sal_uInt16, HiddenPage >::iterator aPagePos = m_aHiddenPages.find( _nPageId );
470*cdf0e10cSrcweir             if ( aPagePos == m_aHiddenPages.end() )
471*cdf0e10cSrcweir                 return;
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir             aPagePos->second.pPage->SetSizePixel( m_aTabControl.GetTabPageSizePixel() );
474*cdf0e10cSrcweir             m_aTabControl.InsertPage( aPagePos->first, aPagePos->second.pPage->GetText(), aPagePos->second.nPos );
475*cdf0e10cSrcweir             m_aTabControl.SetTabPage( aPagePos->first, aPagePos->second.pPage );
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir             m_aHiddenPages.erase( aPagePos );
478*cdf0e10cSrcweir         }
479*cdf0e10cSrcweir     }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir     //------------------------------------------------------------------
482*cdf0e10cSrcweir     void OPropertyEditor::EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable )
483*cdf0e10cSrcweir     {
484*cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < m_aTabControl.GetPageCount(); ++i )
485*cdf0e10cSrcweir         {
486*cdf0e10cSrcweir             OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) );
487*cdf0e10cSrcweir             if ( pPage )
488*cdf0e10cSrcweir                 pPage->getListBox().EnablePropertyControls( _rEntryName, _nControls, _bEnable );
489*cdf0e10cSrcweir         }
490*cdf0e10cSrcweir     }
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir     //------------------------------------------------------------------
493*cdf0e10cSrcweir     void OPropertyEditor::EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable )
494*cdf0e10cSrcweir     {
495*cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < m_aTabControl.GetPageCount(); ++i )
496*cdf0e10cSrcweir         {
497*cdf0e10cSrcweir             OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) );
498*cdf0e10cSrcweir             if ( pPage )
499*cdf0e10cSrcweir                 pPage->getListBox().EnablePropertyLine( _rEntryName, _bEnable );
500*cdf0e10cSrcweir         }
501*cdf0e10cSrcweir     }
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir     //------------------------------------------------------------------
504*cdf0e10cSrcweir     Reference< XPropertyControl > OPropertyEditor::GetPropertyControl(const ::rtl::OUString& rEntryName)
505*cdf0e10cSrcweir     {
506*cdf0e10cSrcweir         Reference< XPropertyControl > xControl;
507*cdf0e10cSrcweir         // let the current page handle this
508*cdf0e10cSrcweir         OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(m_aTabControl.GetCurPageId()));
509*cdf0e10cSrcweir         if (pPage)
510*cdf0e10cSrcweir             xControl = pPage->getListBox().GetPropertyControl(rEntryName);
511*cdf0e10cSrcweir         return xControl;
512*cdf0e10cSrcweir     }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir     //------------------------------------------------------------------
515*cdf0e10cSrcweir     IMPL_LINK(OPropertyEditor, OnPageActivate, TabControl*, EMPTYARG)
516*cdf0e10cSrcweir     {
517*cdf0e10cSrcweir         if (m_aPageActivationHandler.IsSet())
518*cdf0e10cSrcweir             m_aPageActivationHandler.Call(NULL);
519*cdf0e10cSrcweir         return 0L;
520*cdf0e10cSrcweir     }
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir     //------------------------------------------------------------------
523*cdf0e10cSrcweir     IMPL_LINK(OPropertyEditor, OnPageDeactivate, TabControl*, EMPTYARG)
524*cdf0e10cSrcweir     {
525*cdf0e10cSrcweir         // commit the data on the current (to-be-decativated) tab page
526*cdf0e10cSrcweir         // (79404)
527*cdf0e10cSrcweir         sal_Int32 nCurrentId = m_aTabControl.GetCurPageId();
528*cdf0e10cSrcweir         OBrowserPage* pCurrentPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage((sal_uInt16)nCurrentId));
529*cdf0e10cSrcweir         if ( !pCurrentPage )
530*cdf0e10cSrcweir             return 1L;
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir         if ( pCurrentPage->getListBox().IsModified() )
533*cdf0e10cSrcweir             pCurrentPage->getListBox().CommitModified();
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir         return 1L;
536*cdf0e10cSrcweir     }
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir //............................................................................
539*cdf0e10cSrcweir } // namespace pcr
540*cdf0e10cSrcweir //............................................................................
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 
543