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