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 INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYEDITOR_HXX
21 : #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYEDITOR_HXX
22 :
23 : #include "pcrcommon.hxx"
24 :
25 : #include <com/sun/star/inspection/XPropertyControl.hpp>
26 : #include <vcl/tabctrl.hxx>
27 : #include <vcl/vclptr.hxx>
28 : #include <boost/mem_fn.hpp>
29 : #include <map>
30 :
31 : namespace pcr
32 : {
33 :
34 : class IPropertyLineListener;
35 : class IPropertyControlObserver;
36 : class OBrowserPage;
37 : struct OLineDescriptor;
38 : class OBrowserListBox;
39 :
40 :
41 : //= OPropertyEditor
42 :
43 : class OPropertyEditor : public Control
44 : {
45 : private:
46 : typedef ::std::map< OUString, sal_uInt16 > MapStringToPageId;
47 0 : struct HiddenPage
48 : {
49 : sal_uInt16 nPos;
50 : VclPtr<TabPage> pPage;
51 0 : HiddenPage() : nPos( 0 ), pPage( NULL ) { }
52 0 : HiddenPage( sal_uInt16 _nPos, TabPage* _pPage ) : nPos( _nPos ), pPage( _pPage ) { }
53 : };
54 :
55 : private:
56 : VclPtr<TabControl> m_aTabControl;
57 : IPropertyLineListener* m_pListener;
58 : IPropertyControlObserver* m_pObserver;
59 : sal_uInt16 m_nNextId;
60 : Link<> m_aPageActivationHandler;
61 : bool m_bHasHelpSection;
62 : sal_Int32 m_nMinHelpLines;
63 : sal_Int32 m_nMaxHelpLines;
64 :
65 : MapStringToPageId m_aPropertyPageIds;
66 : ::std::map< sal_uInt16, HiddenPage > m_aHiddenPages;
67 :
68 : protected:
69 : void Resize() SAL_OVERRIDE;
70 : void GetFocus() SAL_OVERRIDE;
71 :
72 : public:
73 : OPropertyEditor (vcl::Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL);
74 :
75 : virtual ~OPropertyEditor();
76 : virtual void dispose() SAL_OVERRIDE;
77 :
78 : void EnableUpdate();
79 : void DisableUpdate();
80 :
81 : void SetLineListener( IPropertyLineListener* );
82 : void SetControlObserver( IPropertyControlObserver* );
83 :
84 : void EnableHelpSection( bool _bEnable );
85 0 : bool HasHelpSection() const { return m_bHasHelpSection; }
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 2 : 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 : static void setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString );
139 : void setHelpLineLimits( OBrowserPage& _rPage, const void* );
140 :
141 : protected:
142 : DECL_LINK_TYPED(OnPageDeactivate, TabControl *, bool);
143 : DECL_LINK(OnPageActivate, void *);
144 : };
145 :
146 :
147 : } // namespace pcr
148 :
149 :
150 : #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYEDITOR_HXX
151 :
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|