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