1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include <com/sun/star/uno/Reference.h> 25 #include <sfx2/basedlgs.hxx> 26 #include <sfx2/tabdlg.hxx> 27 #include <svtools/svtreebx.hxx> 28 #include <tools/resary.hxx> 29 #include <vcl/image.hxx> 30 #include <vcl/fixbrd.hxx> 31 #include <vcl/fixed.hxx> 32 33 #include <vector> 34 35 // static ---------------------------------------------------------------- 36 37 sal_Bool EnableSSO(); 38 CreateTabPage GetSSOCreator( void ); 39 40 // class OfaOptionsTreeListBox ------------------------------------------- 41 42 //!#define NUMBER_OF_OPTION_PAGES 12 43 class SfxModule; 44 class SfxShell; 45 class SfxItemSet; 46 class XColorTable; 47 class OfaOptionsTreeListBox : public SvTreeListBox 48 { 49 using SvListView::Collapse; 50 51 private: 52 sal_Bool bInCollapse; 53 54 public: 55 OfaOptionsTreeListBox(Window* pParent, const ResId& rResId) : 56 SvTreeListBox( pParent, rResId ), bInCollapse(sal_False) {} 57 58 virtual sal_Bool Collapse( SvLBoxEntry* pParent ); 59 sal_Bool IsInCollapse()const {return bInCollapse;} 60 }; 61 62 // struct OrderedEntry --------------------------------------------------- 63 64 struct OrderedEntry 65 { 66 sal_Int32 m_nIndex; 67 rtl::OUString m_sId; 68 69 OrderedEntry( sal_Int32 nIndex, const rtl::OUString& rId ) : 70 m_nIndex( nIndex ), m_sId( rId ) {} 71 }; 72 73 typedef std::vector< OrderedEntry* > VectorOfOrderedEntries; 74 75 // struct Module --------------------------------------------------------- 76 77 struct Module 78 { 79 rtl::OUString m_sName; 80 bool m_bActive; 81 VectorOfOrderedEntries m_aNodeList; 82 83 Module( const rtl::OUString& rName ) : m_sName( rName ), m_bActive( false ) {} 84 }; 85 86 // struct OptionsLeaf ---------------------------------------------------- 87 88 struct OptionsLeaf 89 { 90 rtl::OUString m_sId; 91 rtl::OUString m_sLabel; 92 rtl::OUString m_sPageURL; 93 rtl::OUString m_sEventHdl; 94 rtl::OUString m_sGroupId; 95 sal_Int32 m_nGroupIndex; 96 97 OptionsLeaf( const rtl::OUString& rId, 98 const rtl::OUString& rLabel, 99 const rtl::OUString& rPageURL, 100 const rtl::OUString& rEventHdl, 101 const rtl::OUString& rGroupId, 102 sal_Int32 nGroupIndex ) : 103 m_sId( rId ), 104 m_sLabel( rLabel ), 105 m_sPageURL( rPageURL ), 106 m_sEventHdl( rEventHdl ), 107 m_sGroupId( rGroupId ), 108 m_nGroupIndex( nGroupIndex ) {} 109 }; 110 111 typedef ::std::vector< OptionsLeaf* > VectorOfLeaves; 112 typedef ::std::vector< VectorOfLeaves > VectorOfGroupedLeaves; 113 114 // struct OptionsNode ---------------------------------------------------- 115 116 struct OptionsNode 117 { 118 rtl::OUString m_sId; 119 rtl::OUString m_sLabel; 120 rtl::OUString m_sPageURL; 121 bool m_bAllModules; 122 rtl::OUString m_sGroupId; 123 sal_Int32 m_nGroupIndex; 124 VectorOfLeaves m_aLeaves; 125 VectorOfGroupedLeaves m_aGroupedLeaves; 126 127 OptionsNode( const rtl::OUString& rId, 128 const rtl::OUString& rLabel, 129 const rtl::OUString& rPageURL, 130 bool bAllModules, 131 const rtl::OUString& rGroupId, 132 sal_Int32 nGroupIndex ) : 133 m_sId( rId ), 134 m_sLabel( rLabel ), 135 m_sPageURL( rPageURL ), 136 m_bAllModules( bAllModules ), 137 m_sGroupId( rGroupId ), 138 m_nGroupIndex( nGroupIndex ) {} 139 140 ~OptionsNode() 141 { 142 for ( sal_uInt32 i = 0; i < m_aLeaves.size(); ++i ) 143 delete m_aLeaves[i]; 144 m_aLeaves.clear(); 145 m_aGroupedLeaves.clear(); 146 } 147 }; 148 149 typedef ::std::vector< OptionsNode* > VectorOfNodes; 150 151 struct LastPageSaver 152 { 153 sal_uInt16 m_nLastPageId; 154 rtl::OUString m_sLastPageURL_Tools; 155 rtl::OUString m_sLastPageURL_ExtMgr; 156 157 LastPageSaver() : m_nLastPageId( USHRT_MAX ) {} 158 }; 159 160 // class OfaTreeOptionsDialog -------------------------------------------- 161 162 namespace com { namespace sun { namespace star { namespace frame { class XFrame; } } } } 163 namespace com { namespace sun { namespace star { namespace container { class XNameAccess; } } } } 164 namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } } 165 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowProvider; } } } } 166 167 struct OptionsPageInfo; 168 struct Module; 169 class ExtensionsTabPage; 170 typedef std::vector< ExtensionsTabPage* > VectorOfPages; 171 172 class OfaTreeOptionsDialog : public SfxModalDialog 173 { 174 private: 175 OKButton aOkPB; 176 CancelButton aCancelPB; 177 HelpButton aHelpPB; 178 PushButton aBackPB; 179 180 FixedBorder aHiddenGB; 181 FixedText aPageTitleFT; 182 FixedLine aLine1FL; 183 FixedText aHelpFT; 184 FixedImage aHelpImg; 185 186 ImageList aPageImages; 187 ImageList aPageImagesHC; 188 189 ResStringArray aHelpTextsArr; 190 191 OfaOptionsTreeListBox aTreeLB; 192 193 String sTitle; 194 String sNotLoadedError; 195 196 SvLBoxEntry* pCurrentPageEntry; 197 198 // for the ColorTabPage 199 SfxItemSet* pColorPageItemSet; 200 XColorTable* pColorTab; 201 sal_uInt16 nChangeType; 202 sal_uInt16 nUnknownType; 203 sal_uInt16 nUnknownPos; 204 sal_Bool bIsAreaTP; 205 206 sal_Bool bForgetSelection; 207 sal_Bool bExternBrowserActive; 208 sal_Bool bImageResized; 209 bool bInSelectHdl_Impl; 210 bool bIsFromExtensionManager; 211 212 // check "for the current document only" and set focus to "Western" languages box 213 bool bIsForSetDocumentLanguage; 214 215 Timer aSelectTimer; 216 217 com::sun::star::uno::Reference < com::sun::star::awt::XContainerWindowProvider > 218 m_xContainerWinProvider; 219 220 static LastPageSaver* pLastPageSaver; 221 222 SfxItemSet* CreateItemSet( sal_uInt16 nId ); 223 void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ); 224 void InitTreeAndHandler(); 225 void Initialize( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& _xFrame ); 226 void ResizeTreeLB( void ); // resizes dialog so that treelistbox has no horizontal scroll bar 227 228 void LoadExtensionOptions( const rtl::OUString& rExtensionId ); 229 rtl::OUString GetModuleIdentifier( const com::sun::star::uno::Reference< 230 com::sun::star::lang::XMultiServiceFactory >& xMFac, 231 const com::sun::star::uno::Reference< 232 com::sun::star::frame::XFrame >& xFrame ); 233 Module* LoadModule( const rtl::OUString& rModuleIdentifier, 234 const com::sun::star::uno::Reference< 235 com::sun::star::container::XNameAccess >& xRoot ); 236 void LoadNodes( const com::sun::star::uno::Reference< 237 com::sun::star::container::XNameAccess >& xRoot, 238 Module* pModule, 239 const rtl::OUString& rExtensionId, 240 VectorOfNodes& rOutNodeList ); 241 void InsertNodes( const VectorOfNodes& rNodeList ); 242 243 protected: 244 DECL_LINK(ExpandedHdl_Impl, SvTreeListBox* ); 245 DECL_LINK(ShowPageHdl_Impl, SvTreeListBox* ); 246 DECL_LINK(BackHdl_Impl, PushButton* ); 247 DECL_LINK( OKHdl_Impl, Button * ); 248 DECL_LINK( HintHdl_Impl, Timer * ); 249 DECL_LINK( SelectHdl_Impl, Timer * ); 250 251 virtual long Notify( NotifyEvent& rNEvt ); 252 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 253 virtual short Execute(); 254 255 public: 256 OfaTreeOptionsDialog( Window* pParent, 257 const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& _xFrame, 258 bool bActivateLastSelection = true ); 259 OfaTreeOptionsDialog( Window* pParent, const rtl::OUString& rExtensionId ); 260 ~OfaTreeOptionsDialog(); 261 262 OptionsPageInfo* AddTabPage( sal_uInt16 nId, const String& rPageName, sal_uInt16 nGroup ); 263 sal_uInt16 AddGroup( const String& rGroupName, SfxShell* pCreateShell, 264 SfxModule* pCreateModule, sal_uInt16 nDialogId ); 265 266 void ActivateLastSelection(); 267 void ActivatePage( sal_uInt16 nResId ); 268 void ActivatePage( const String& rPageURL ); 269 void ApplyItemSets(); 270 271 sal_uInt16 GetColorChanged() const { return nChangeType; } 272 XColorTable* GetColorTable() { return pColorTab; } 273 274 // helper functions to call the language settings TabPage from the SpellDialog 275 static void ApplyLanguageOptions(const SfxItemSet& rSet); 276 }; 277 278 // class OfaPageResource ------------------------------------------------- 279 280 class OfaPageResource : public Resource 281 { 282 ResStringArray aGeneralDlgAry; 283 ResStringArray aInetDlgAry; 284 ResStringArray aLangDlgAry; 285 ResStringArray aTextDlgAry; 286 ResStringArray aHTMLDlgAry; 287 ResStringArray aCalcDlgAry; 288 ResStringArray aStarMathDlgAry; 289 ResStringArray aImpressDlgAry; 290 ResStringArray aDrawDlgAry; 291 ResStringArray aChartDlgAry; 292 ResStringArray aFilterDlgAry; 293 ResStringArray aDatasourcesDlgAry; 294 295 public: 296 OfaPageResource(); 297 298 ResStringArray& GetGeneralArray() {return aGeneralDlgAry;} 299 ResStringArray& GetInetArray() {return aInetDlgAry;} 300 ResStringArray& GetLangArray() {return aLangDlgAry;} 301 ResStringArray& GetTextArray() {return aTextDlgAry;} 302 ResStringArray& GetHTMLArray() {return aHTMLDlgAry;} 303 ResStringArray& GetCalcArray() {return aCalcDlgAry;} 304 ResStringArray& GetStarMathArray() {return aStarMathDlgAry;} 305 ResStringArray& GetImpressArray() {return aImpressDlgAry;} 306 ResStringArray& GetDrawArray() {return aDrawDlgAry;} 307 ResStringArray& GetChartArray() {return aChartDlgAry;} 308 ResStringArray& GetFilterArray() {return aFilterDlgAry;} 309 ResStringArray& GetDatasourcesArray() {return aDatasourcesDlgAry;} 310 }; 311 312 // class ExtensionsTabPage ----------------------------------------------- 313 314 namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } } 315 namespace com { namespace sun { namespace star { namespace awt { class XContainerWindowEventHandler; } } } } 316 317 class ExtensionsTabPage : public TabPage 318 { 319 private: 320 rtl::OUString m_sPageURL; 321 com::sun::star::uno::Reference< com::sun::star::awt::XWindow > 322 m_xPage; 323 rtl::OUString m_sEventHdl; 324 com::sun::star::uno::Reference< com::sun::star::awt::XContainerWindowEventHandler > 325 m_xEventHdl; 326 com::sun::star::uno::Reference< com::sun::star::awt::XContainerWindowProvider > 327 m_xWinProvider; 328 bool m_bIsWindowHidden; 329 330 void CreateDialogWithHandler(); 331 sal_Bool DispatchAction( const rtl::OUString& rAction ); 332 333 public: 334 ExtensionsTabPage( 335 Window* pParent, WinBits nStyle, 336 const rtl::OUString& rPageURL, const rtl::OUString& rEvtHdl, 337 const com::sun::star::uno::Reference< 338 com::sun::star::awt::XContainerWindowProvider >& rProvider ); 339 340 virtual ~ExtensionsTabPage(); 341 342 virtual void ActivatePage(); 343 virtual void DeactivatePage(); 344 345 void ResetPage(); 346 void SavePage(); 347 }; 348 349