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