1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_ 29 #define _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_ 30 31 #include "pcrcommon.hxx" 32 33 /** === begin UNO includes === **/ 34 #include <com/sun/star/inspection/XPropertyControl.hpp> 35 /** === end UNO includes === **/ 36 #include <vcl/tabctrl.hxx> 37 #include <comphelper/stl_types.hxx> 38 #include <boost/mem_fn.hpp> 39 #include <map> 40 41 //............................................................................ 42 namespace pcr 43 { 44 //............................................................................ 45 46 class IPropertyLineListener; 47 class IPropertyControlObserver; 48 class OBrowserPage; 49 struct OLineDescriptor; 50 class OBrowserListBox; 51 52 //======================================================================== 53 //= OPropertyEditor 54 //======================================================================== 55 class OPropertyEditor : public Control 56 { 57 private: 58 typedef ::std::map< ::rtl::OUString, sal_uInt16 > MapStringToPageId; 59 struct HiddenPage 60 { 61 sal_uInt16 nPos; 62 TabPage* pPage; 63 HiddenPage() : nPos( 0 ), pPage( NULL ) { } 64 HiddenPage( sal_uInt16 _nPos, TabPage* _pPage ) : nPos( _nPos ), pPage( _pPage ) { } 65 }; 66 67 private: 68 TabControl m_aTabControl; 69 IPropertyLineListener* m_pListener; 70 IPropertyControlObserver* m_pObserver; 71 sal_uInt16 m_nNextId; 72 Link m_aPageActivationHandler; 73 bool m_bHasHelpSection; 74 sal_Int32 m_nMinHelpLines; 75 sal_Int32 m_nMaxHelpLines; 76 77 MapStringToPageId m_aPropertyPageIds; 78 ::std::map< sal_uInt16, HiddenPage > m_aHiddenPages; 79 80 protected: 81 void Resize(); 82 void GetFocus(); 83 84 public: 85 OPropertyEditor (Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL); 86 87 ~OPropertyEditor(); 88 89 void EnableUpdate(); 90 void DisableUpdate(); 91 92 void SetLineListener( IPropertyLineListener* ); 93 void SetControlObserver( IPropertyControlObserver* ); 94 95 void EnableHelpSection( bool _bEnable ); 96 bool HasHelpSection() const; 97 void SetHelpText( const ::rtl::OUString& _rHelpText ); 98 void SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines ); 99 100 void SetHelpId( const rtl::OString& sHelpId ); 101 sal_uInt16 AppendPage( const String& r, const rtl::OString& _rHelpId ); 102 void SetPage( sal_uInt16 ); 103 void RemovePage(sal_uInt16 nID); 104 sal_uInt16 GetCurPage(); 105 void ClearAll(); 106 107 void SetPropertyValue(const ::rtl::OUString& _rEntryName, const ::com::sun::star::uno::Any& _rValue, bool _bUnknownValue ); 108 ::com::sun::star::uno::Any GetPropertyValue(const ::rtl::OUString& rEntryName ) const; 109 sal_uInt16 GetPropertyPos(const ::rtl::OUString& rEntryName ) const; 110 ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > 111 GetPropertyControl( const ::rtl::OUString& rEntryName ); 112 void EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable ); 113 void EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable ); 114 115 void ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow ); 116 117 sal_uInt16 InsertEntry( const OLineDescriptor&, sal_uInt16 _nPageId, sal_uInt16 nPos = EDITOR_LIST_APPEND ); 118 void RemoveEntry( const ::rtl::OUString& _rName ); 119 void ChangeEntry( const OLineDescriptor& ); 120 121 void setPageActivationHandler(const Link& _rHdl) { m_aPageActivationHandler = _rHdl; } 122 Link getPageActivationHandler() const { return m_aPageActivationHandler; } 123 124 // #95343# ------------------------------- 125 sal_Int32 getMinimumWidth(); 126 sal_Int32 getMinimumHeight(); 127 128 void CommitModified(); 129 130 protected: 131 using Window::SetHelpText; 132 using Window::Update; 133 134 private: 135 OBrowserPage* getPage( sal_uInt16& _rPageId ); 136 const OBrowserPage* getPage( sal_uInt16& _rPageId ) const; 137 138 OBrowserPage* getPage( const ::rtl::OUString& _rPropertyName ); 139 const OBrowserPage* getPage( const ::rtl::OUString& _rPropertyName ) const; 140 141 void Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction); 142 143 typedef void (OPropertyEditor::*PageOperation)( OBrowserPage&, const void* ); 144 void forEachPage( PageOperation _pOperation, const void* _pArgument = NULL ); 145 146 void setPageLineListener( OBrowserPage& _rPage, const void* ); 147 void setPageControlObserver( OBrowserPage& _rPage, const void* ); 148 void enableHelpSection( OBrowserPage& _rPage, const void* ); 149 void setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString ); 150 void setHelpLineLimits( OBrowserPage& _rPage, const void* ); 151 152 protected: 153 DECL_LINK(OnPageDeactivate, TabControl*); 154 DECL_LINK(OnPageActivate, TabControl*); 155 }; 156 157 //............................................................................ 158 } // namespace pcr 159 //............................................................................ 160 161 #endif // _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_ 162 163 164