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 #ifndef _CFGUTIL_HXX 28 #define _CFGUTIL_HXX 29 30 #include <vector> 31 #include <rtl/ustring.hxx> 32 #include <tools/string.hxx> 33 34 #include <com/sun/star/frame/XModel.hpp> 35 #include <com/sun/star/frame/XFrame.hpp> 36 #include <com/sun/star/lang/XSingleComponentFactory.hpp> 37 #include <com/sun/star/container/XNameAccess.hpp> 38 #include <com/sun/star/script/browse/XBrowseNode.hpp> 39 40 #define _SVSTDARR_STRINGSDTOR 41 #include <svl/svstdarr.hxx> 42 43 #include <vcl/timer.hxx> 44 #include <svtools/svtabbx.hxx> 45 #include <svtools/svtreebx.hxx> 46 #include <vcl/image.hxx> 47 48 class BasicManager; 49 class SfxSlotPool; 50 class SfxStringItem; 51 class SfxFontItem; 52 class SfxMacroInfoItem; 53 struct SfxStyleInfo_Impl; 54 struct SfxStylesInfo_Impl; 55 56 #define css ::com::sun::star 57 58 struct SfxStyleInfo_Impl 59 { 60 ::rtl::OUString sFamily; 61 ::rtl::OUString sStyle; 62 ::rtl::OUString sCommand; 63 ::rtl::OUString sLabel; 64 65 SfxStyleInfo_Impl() 66 {} 67 68 SfxStyleInfo_Impl(const SfxStyleInfo_Impl& rCopy) 69 { 70 sFamily = rCopy.sFamily; 71 sStyle = rCopy.sStyle; 72 sCommand = rCopy.sCommand; 73 sLabel = rCopy.sLabel; 74 } 75 }; 76 77 struct SfxStylesInfo_Impl 78 { 79 private: 80 81 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDoc; 82 83 public: 84 85 SfxStylesInfo_Impl(); 86 void setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel); 87 88 sal_Bool parseStyleCommand(SfxStyleInfo_Impl& aStyle); 89 void getLabel4Style(SfxStyleInfo_Impl& aStyle); 90 91 ::std::vector< SfxStyleInfo_Impl > getStyleFamilies(); 92 ::std::vector< SfxStyleInfo_Impl > getStyles(const ::rtl::OUString& sFamily); 93 94 static ::rtl::OUString generateCommand(const ::rtl::OUString& sFamily, const ::rtl::OUString& sStyle); 95 }; 96 97 #define SFX_CFGGROUP_FUNCTION 1 98 #define SFX_CFGFUNCTION_SLOT 2 99 #define SFX_CFGGROUP_SCRIPTCONTAINER 3 100 #define SFX_CFGFUNCTION_SCRIPT 4 101 #define SFX_CFGGROUP_STYLES 5 102 103 struct SfxGroupInfo_Impl 104 { 105 sal_uInt16 nKind; 106 sal_uInt16 nUniqueID; 107 void* pObject; 108 sal_Bool bWasOpened; 109 String sCommand; 110 String sLabel; 111 112 SfxGroupInfo_Impl( sal_uInt16 n, sal_uInt16 nr, void* pObj = 0 ) : 113 nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(sal_False) {} 114 }; 115 116 struct CuiMacroInfo 117 { 118 }; 119 120 typedef SfxGroupInfo_Impl* SfxGroupInfoPtr; 121 SV_DECL_PTRARR_DEL(SfxGroupInfoArr_Impl, SfxGroupInfoPtr, 5, 5) 122 123 class SfxConfigFunctionListBox_Impl : public SvTreeListBox 124 { 125 friend class SfxConfigGroupListBox_Impl; 126 Timer aTimer; 127 SvLBoxEntry* pCurEntry; 128 SfxGroupInfoArr_Impl aArr; 129 SfxStylesInfo_Impl* pStylesInfo; 130 131 DECL_LINK( TimerHdl, Timer* ); 132 virtual void MouseMove( const MouseEvent& rMEvt ); 133 134 public: 135 SfxConfigFunctionListBox_Impl( Window*, const ResId& ); 136 ~SfxConfigFunctionListBox_Impl(); 137 138 void ClearAll(); 139 using Window::GetHelpText; 140 String GetHelpText( SvLBoxEntry *pEntry ); 141 String GetCurCommand(); 142 String GetCurLabel(); 143 String GetSelectedScriptURI(); 144 void FunctionSelected(); 145 void SetStylesInfo(SfxStylesInfo_Impl* pStyles); 146 }; 147 148 struct SvxConfigGroupBoxResource_Impl; 149 class SfxConfigGroupListBox_Impl : public SvTreeListBox 150 { 151 SvxConfigGroupBoxResource_Impl* pImp; 152 //SfxSlotPool* pSlotPool; 153 SfxConfigFunctionListBox_Impl* pFunctionListBox; 154 SfxGroupInfoArr_Impl aArr; 155 sal_uLong nMode; 156 157 ::rtl::OUString m_sModuleLongName; 158 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 159 css::uno::Reference< css::frame::XFrame > m_xFrame; 160 css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo; 161 css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo; 162 css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription; 163 164 Image GetImage( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > node, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx, bool bIsRootNode, bool bHighContrast ); 165 166 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDocumentModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx, ::rtl::OUString& docName ); 167 168 void InitModule(); 169 void InitBasic(); 170 void InitStyles(); 171 172 ::rtl::OUString MapCommand2UIName(const ::rtl::OUString& sCommand); 173 174 SfxStylesInfo_Impl* pStylesInfo; 175 176 protected: 177 virtual void RequestingChilds( SvLBoxEntry *pEntry); 178 using SvListView::Expand; 179 virtual sal_Bool Expand( SvLBoxEntry* pParent ); 180 181 public: 182 SfxConfigGroupListBox_Impl ( Window* pParent, 183 const ResId&, 184 sal_uLong nConfigMode = 0 ); 185 ~SfxConfigGroupListBox_Impl(); 186 void ClearAll(); 187 188 void Init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , 189 const css::uno::Reference< css::frame::XFrame >& xFrame , 190 const ::rtl::OUString& sModuleLongName); 191 void SetFunctionListBox( SfxConfigFunctionListBox_Impl *pBox ) 192 { pFunctionListBox = pBox; } 193 void Open( SvLBoxEntry*, sal_Bool ); 194 void GroupSelected(); 195 void SelectMacro( const SfxMacroInfoItem* ); 196 void SelectMacro( const String&, const String& ); 197 String GetGroup(); 198 void SetStylesInfo(SfxStylesInfo_Impl* pStyles); 199 }; 200 201 #undef css 202 203 #endif 204 205