1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
25 #define _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
26 
27 #include "pcrcommon.hxx"
28 
29 /** === begin UNO includes === **/
30 #include <com/sun/star/inspection/XPropertyControl.hpp>
31 /** === end UNO includes === **/
32 #include <vcl/tabctrl.hxx>
33 #include <comphelper/stl_types.hxx>
34 #include <boost/mem_fn.hpp>
35 #include <map>
36 
37 //............................................................................
38 namespace pcr
39 {
40 //............................................................................
41 
42 	class IPropertyLineListener;
43     class IPropertyControlObserver;
44     class OBrowserPage;
45 	struct OLineDescriptor;
46     class OBrowserListBox;
47 
48 	//========================================================================
49 	//= OPropertyEditor
50 	//========================================================================
51 	class OPropertyEditor : public Control
52 	{
53     private:
54         typedef ::std::map< ::rtl::OUString, sal_uInt16 >   MapStringToPageId;
55         struct HiddenPage
56         {
57             sal_uInt16  nPos;
58             TabPage*    pPage;
HiddenPagepcr::OPropertyEditor::HiddenPage59             HiddenPage() : nPos( 0 ), pPage( NULL ) { }
HiddenPagepcr::OPropertyEditor::HiddenPage60             HiddenPage( sal_uInt16 _nPos, TabPage* _pPage ) : nPos( _nPos ), pPage( _pPage ) { }
61         };
62 
63     private:
64         TabControl                  m_aTabControl;
65         IPropertyLineListener*      m_pListener;
66         IPropertyControlObserver*   m_pObserver;
67         sal_uInt16                  m_nNextId;
68         Link                        m_aPageActivationHandler;
69         bool                        m_bHasHelpSection;
70         sal_Int32                   m_nMinHelpLines;
71         sal_Int32                   m_nMaxHelpLines;
72 
73         MapStringToPageId                       m_aPropertyPageIds;
74         ::std::map< sal_uInt16, HiddenPage >    m_aHiddenPages;
75 
76     protected:
77         void                        Resize();
78         void                        GetFocus();
79 
80     public:
81                                     OPropertyEditor (Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL);
82 
83                                     ~OPropertyEditor();
84 
85         void                        EnableUpdate();
86         void                        DisableUpdate();
87 
88         void                        SetLineListener( IPropertyLineListener* );
89         void                        SetControlObserver( IPropertyControlObserver* );
90 
91         void                        EnableHelpSection( bool _bEnable );
92         bool                        HasHelpSection() const;
93         void                        SetHelpText( const ::rtl::OUString& _rHelpText );
94         void                        SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines );
95 
96         void                        SetHelpId( const rtl::OString& sHelpId );
97         sal_uInt16                  AppendPage( const String& r, const rtl::OString& _rHelpId );
98         void                        SetPage( sal_uInt16 );
99         void                        RemovePage(sal_uInt16 nID);
100         sal_uInt16                  GetCurPage();
101         void                        ClearAll();
102 
103         void                        SetPropertyValue(const ::rtl::OUString& _rEntryName, const ::com::sun::star::uno::Any& _rValue, bool _bUnknownValue );
104         ::com::sun::star::uno::Any  GetPropertyValue(const ::rtl::OUString& rEntryName ) const;
105         sal_uInt16                  GetPropertyPos(const ::rtl::OUString& rEntryName ) const;
106         ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
107                                     GetPropertyControl( const ::rtl::OUString& rEntryName );
108         void                        EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable );
109         void                        EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable );
110 
111         void                        ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow );
112 
113         sal_uInt16                  InsertEntry( const OLineDescriptor&, sal_uInt16 _nPageId, sal_uInt16 nPos = EDITOR_LIST_APPEND );
114         void                        RemoveEntry( const ::rtl::OUString& _rName );
115         void                        ChangeEntry( const OLineDescriptor& );
116 
setPageActivationHandler(const Link & _rHdl)117 		void	setPageActivationHandler(const Link& _rHdl) { m_aPageActivationHandler = _rHdl; }
getPageActivationHandler() const118 		Link	getPageActivationHandler() const { return m_aPageActivationHandler; }
119 
120         // #95343# -------------------------------
121 		sal_Int32 getMinimumWidth();
122 		sal_Int32 getMinimumHeight();
123 
124 		void	                    CommitModified();
125 
126     protected:
127         using Window::SetHelpText;
128         using Window::Update;
129 
130     private:
131         OBrowserPage* getPage( sal_uInt16& _rPageId );
132         const OBrowserPage* getPage( sal_uInt16& _rPageId ) const;
133 
134         OBrowserPage* getPage( const ::rtl::OUString& _rPropertyName );
135         const OBrowserPage* getPage( const ::rtl::OUString& _rPropertyName ) const;
136 
137         void Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction);
138 
139         typedef void (OPropertyEditor::*PageOperation)( OBrowserPage&, const void* );
140         void    forEachPage( PageOperation _pOperation, const void* _pArgument = NULL );
141 
142         void    setPageLineListener( OBrowserPage& _rPage, const void* );
143         void    setPageControlObserver( OBrowserPage& _rPage, const void* );
144         void    enableHelpSection( OBrowserPage& _rPage, const void* );
145         void    setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString );
146         void    setHelpLineLimits( OBrowserPage& _rPage, const void* );
147 
148 	protected:
149 		DECL_LINK(OnPageDeactivate, TabControl*);
150 		DECL_LINK(OnPageActivate, TabControl*);
151 	};
152 
153 //............................................................................
154 } // namespace pcr
155 //............................................................................
156 
157 #endif // _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
158 
159 
160