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 <boost/mem_fn.hpp>
28 : #include <map>
29 :
30 :
31 : namespace pcr
32 : {
33 :
34 :
35 : class IPropertyLineListener;
36 : class IPropertyControlObserver;
37 : class OBrowserPage;
38 : struct OLineDescriptor;
39 : class OBrowserListBox;
40 :
41 :
42 : //= OPropertyEditor
43 :
44 : class OPropertyEditor : public Control
45 : {
46 : private:
47 : typedef ::std::map< OUString, sal_uInt16 > MapStringToPageId;
48 : struct HiddenPage
49 : {
50 : sal_uInt16 nPos;
51 : TabPage* pPage;
52 0 : HiddenPage() : nPos( 0 ), pPage( NULL ) { }
53 0 : HiddenPage( sal_uInt16 _nPos, TabPage* _pPage ) : nPos( _nPos ), pPage( _pPage ) { }
54 : };
55 :
56 : private:
57 : TabControl m_aTabControl;
58 : IPropertyLineListener* m_pListener;
59 : IPropertyControlObserver* m_pObserver;
60 : sal_uInt16 m_nNextId;
61 : Link m_aPageActivationHandler;
62 : bool m_bHasHelpSection;
63 : sal_Int32 m_nMinHelpLines;
64 : sal_Int32 m_nMaxHelpLines;
65 :
66 : MapStringToPageId m_aPropertyPageIds;
67 : ::std::map< sal_uInt16, HiddenPage > m_aHiddenPages;
68 :
69 : protected:
70 : void Resize() SAL_OVERRIDE;
71 : void GetFocus() SAL_OVERRIDE;
72 :
73 : public:
74 : OPropertyEditor (Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL);
75 :
76 : virtual ~OPropertyEditor();
77 :
78 : void EnableUpdate();
79 : void DisableUpdate();
80 :
81 : void SetLineListener( IPropertyLineListener* );
82 : void SetControlObserver( IPropertyControlObserver* );
83 :
84 : void EnableHelpSection( bool _bEnable );
85 : bool HasHelpSection() const;
86 : void SetHelpText( const OUString& _rHelpText );
87 : void SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines );
88 :
89 : void SetHelpId( const OString& sHelpId );
90 : sal_uInt16 AppendPage( const OUString& r, const OString& _rHelpId );
91 : void SetPage( sal_uInt16 );
92 : void RemovePage(sal_uInt16 nID);
93 : sal_uInt16 GetCurPage();
94 : void ClearAll();
95 :
96 : void SetPropertyValue(const OUString& _rEntryName, const ::com::sun::star::uno::Any& _rValue, bool _bUnknownValue );
97 : ::com::sun::star::uno::Any GetPropertyValue(const OUString& rEntryName ) const;
98 : sal_uInt16 GetPropertyPos(const OUString& rEntryName ) const;
99 : ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
100 : GetPropertyControl( const OUString& rEntryName );
101 : void EnablePropertyLine( const OUString& _rEntryName, bool _bEnable );
102 : void EnablePropertyControls( const OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable );
103 :
104 : void ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow );
105 :
106 : sal_uInt16 InsertEntry( const OLineDescriptor&, sal_uInt16 _nPageId, sal_uInt16 nPos = EDITOR_LIST_APPEND );
107 : void RemoveEntry( const OUString& _rName );
108 : void ChangeEntry( const OLineDescriptor& );
109 :
110 0 : void setPageActivationHandler(const Link& _rHdl) { m_aPageActivationHandler = _rHdl; }
111 : Link getPageActivationHandler() const { return m_aPageActivationHandler; }
112 :
113 : // #95343# -------------------------------
114 : sal_Int32 getMinimumWidth();
115 : sal_Int32 getMinimumHeight();
116 :
117 : void CommitModified();
118 :
119 : protected:
120 : using Window::SetHelpText;
121 : using Window::Update;
122 :
123 : private:
124 : OBrowserPage* getPage( sal_uInt16& _rPageId );
125 : const OBrowserPage* getPage( sal_uInt16& _rPageId ) const;
126 :
127 : OBrowserPage* getPage( const OUString& _rPropertyName );
128 : const OBrowserPage* getPage( const OUString& _rPropertyName ) const;
129 :
130 : void Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction);
131 :
132 : typedef void (OPropertyEditor::*PageOperation)( OBrowserPage&, const void* );
133 : void forEachPage( PageOperation _pOperation, const void* _pArgument = NULL );
134 :
135 : void setPageLineListener( OBrowserPage& _rPage, const void* );
136 : void setPageControlObserver( OBrowserPage& _rPage, const void* );
137 : void enableHelpSection( OBrowserPage& _rPage, const void* );
138 : void setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString );
139 : void setHelpLineLimits( OBrowserPage& _rPage, const void* );
140 :
141 : protected:
142 : DECL_LINK(OnPageDeactivate, void *);
143 : DECL_LINK(OnPageActivate, void *);
144 : };
145 :
146 :
147 : } // namespace pcr
148 :
149 :
150 : #endif // _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
151 :
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|