LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/cui/source/options - treeopt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1185 0.0 %
Date: 2013-07-09 Functions: 0 75 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "cuires.hrc"
      21             : #include "helpid.hrc"
      22             : #include "treeopt.hrc"
      23             : 
      24             : #include <svx/dialogs.hrc>
      25             : 
      26             : #include "cfgchart.hxx"
      27             : #include "connpoolconfig.hxx"
      28             : #include "connpooloptions.hxx"
      29             : #include "cuioptgenrl.hxx"
      30             : #include "cuitabarea.hxx"
      31             : #include "dbregister.hxx"
      32             : #include "dbregisterednamesconfig.hxx"
      33             : #include "dialmgr.hxx"
      34             : #include "fontsubs.hxx"
      35             : #include "optaccessibility.hxx"
      36             : #include "optasian.hxx"
      37             : #include "optchart.hxx"
      38             : #include "optcolor.hxx"
      39             : #include "optctl.hxx"
      40             : #include "optfltr.hxx"
      41             : #include "optgdlg.hxx"
      42             : #include "opthtml.hxx"
      43             : #include "optinet2.hxx"
      44             : #include "optjava.hxx"
      45             : #include "optjsearch.hxx"
      46             : #include "optlingu.hxx"
      47             : #include "optmemory.hxx"
      48             : #include "optpath.hxx"
      49             : #include "optsave.hxx"
      50             : #include "optupdt.hxx"
      51             : #include "personalization.hxx"
      52             : #include "treeopt.hxx"
      53             : 
      54             : #include <com/sun/star/awt/XContainerWindowEventHandler.hpp>
      55             : #include <com/sun/star/awt/ContainerWindowProvider.hpp>
      56             : #include <com/sun/star/awt/XControl.hpp>
      57             : #include <com/sun/star/awt/PosSize.hpp>
      58             : #include <com/sun/star/frame/Desktop.hpp>
      59             : #include <com/sun/star/frame/ModuleManager.hpp>
      60             : #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
      61             : #include <com/sun/star/linguistic2/LinguProperties.hpp>
      62             : #include <com/sun/star/util/theMacroExpander.hpp>
      63             : #include <com/sun/star/setup/UpdateCheck.hpp>
      64             : #include <comphelper/processfactory.hxx>
      65             : #include <editeng/langitem.hxx>
      66             : #include <editeng/optitems.hxx>
      67             : #include <editeng/unolingu.hxx>
      68             : #include <linguistic/misc.hxx>
      69             : #include <officecfg/Office/OptionsDialog.hxx>
      70             : #include <osl/module.hxx>
      71             : #include <osl/process.h>
      72             : #include <rtl/bootstrap.hxx>
      73             : #include <rtl/uri.hxx>
      74             : #include <sfx2/app.hxx>
      75             : #include <sfx2/dispatch.hxx>
      76             : #include <sfx2/module.hxx>
      77             : #include <sfx2/printopt.hxx>
      78             : #include <sfx2/shell.hxx>
      79             : #include <sfx2/tplpitem.hxx>
      80             : #include <sfx2/viewsh.hxx>
      81             : #include <svl/languageoptions.hxx>
      82             : #include <svtools/helpopt.hxx>
      83             : #include <svx/drawitem.hxx>
      84             : #include <svx/xtable.hxx>
      85             : #include <svx/xpool.hxx>
      86             : #include <toolkit/helper/vclunohelper.hxx>
      87             : #include <tools/shl.hxx>
      88             : #include <tools/urlobj.hxx>
      89             : #include <unotools/linguprops.hxx>
      90             : #include <unotools/misccfg.hxx>
      91             : #include <unotools/moduleoptions.hxx>
      92             : #include <unotools/optionsdlg.hxx>
      93             : #include <unotools/viewoptions.hxx>
      94             : #include <vcl/help.hxx>
      95             : #include <vcl/layout.hxx>
      96             : #include <vcl/msgbox.hxx>
      97             : #include <vcl/waitobj.hxx>
      98             : #include "svtools/treelistentry.hxx"
      99             : 
     100             : #ifdef LINUX
     101             : #include <sys/stat.h>
     102             : #endif
     103             : 
     104             : using namespace ::com::sun::star;
     105             : using namespace ::com::sun::star::beans;
     106             : using namespace ::com::sun::star::container;
     107             : using namespace ::com::sun::star::frame;
     108             : using namespace ::com::sun::star::lang;
     109             : using namespace ::com::sun::star::linguistic2;
     110             : using namespace ::com::sun::star::uno;
     111             : using namespace ::com::sun::star::util;
     112             : 
     113             : #define EXPAND_PROTOCOL         "vnd.sun.star.expand:"
     114             : 
     115             : LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL;
     116             : 
     117             : // some stuff for easier changes for SvtViewOptions
     118             : static const sal_Char*      pViewOptDataName = "page data";
     119             : #define VIEWOPT_DATANAME    OUString::createFromAscii( pViewOptDataName )
     120             : 
     121             : static XOutdevItemPool* mpStaticXOutdevItemPool = 0L;
     122             : 
     123           0 : static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const String& rData )
     124             : {
     125           0 :     rOpt.SetUserItem( VIEWOPT_DATANAME, makeAny( OUString( rData ) ) );
     126           0 : }
     127             : 
     128           0 : static inline String GetViewOptUserItem( const SvtViewOptions& rOpt )
     129             : {
     130           0 :     Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
     131           0 :     OUString aUserData;
     132           0 :     aAny >>= aUserData;
     133             : 
     134           0 :     return String( aUserData );
     135             : }
     136             : 
     137           0 : struct ModuleToGroupNameMap_Impl
     138             : {
     139             :     const char* m_pModule;
     140             :     String      m_sGroupName;
     141             :     sal_uInt16      m_nNodeId;
     142             : };
     143             : 
     144             : static OfaPageResource* pPageRes = NULL;
     145             : 
     146           0 : static ModuleToGroupNameMap_Impl ModuleMap[] =
     147             : {
     148           0 :     { "ProductName", String::EmptyString(), SID_GENERAL_OPTIONS },
     149           0 :     { "LanguageSettings", String::EmptyString(), SID_LANGUAGE_OPTIONS },
     150           0 :     { "Internet", String::EmptyString(), SID_INET_DLG },
     151           0 :     { "LoadSave", String::EmptyString(), SID_FILTER_DLG },
     152           0 :     { "Writer", String::EmptyString(), SID_SW_EDITOPTIONS },
     153           0 :     { "WriterWeb", String::EmptyString(), SID_SW_ONLINEOPTIONS },
     154           0 :     { "Math", String::EmptyString(), SID_SM_EDITOPTIONS },
     155           0 :     { "Calc", String::EmptyString(), SID_SC_EDITOPTIONS },
     156           0 :     { "Impress", String::EmptyString(), SID_SD_EDITOPTIONS },
     157           0 :     { "Draw", String::EmptyString(), SID_SD_GRAPHIC_OPTIONS },
     158           0 :     { "Charts", String::EmptyString(), SID_SCH_EDITOPTIONS },
     159           0 :     { "Base", String::EmptyString(), SID_SB_STARBASEOPTIONS },
     160             : 
     161           0 :     { NULL, String::EmptyString(), 0xFFFF }
     162           0 : };
     163             : 
     164           0 : static void setGroupName( const OUString& rModule, const String& rGroupName )
     165             : {
     166           0 :     sal_uInt16 nIndex = 0;
     167           0 :     while ( ModuleMap[ nIndex ].m_pModule )
     168             :     {
     169             :         OUString sTemp =
     170           0 :             OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
     171           0 :         if ( sTemp == rModule )
     172             :         {
     173           0 :             ModuleMap[ nIndex ].m_sGroupName = rGroupName;
     174           0 :             break;
     175             :         }
     176           0 :         ++nIndex;
     177           0 :     }
     178           0 : }
     179             : 
     180           0 : static String getGroupName( const OUString& rModule, bool bForced )
     181             : {
     182           0 :     String sGroupName;
     183           0 :     sal_uInt16 nIndex = 0;
     184           0 :     while ( ModuleMap[ nIndex ].m_pModule )
     185             :     {
     186             :         OUString sTemp =
     187           0 :             OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
     188           0 :         if ( sTemp == rModule )
     189             :         {
     190           0 :             sGroupName = ModuleMap[ nIndex ].m_sGroupName;
     191           0 :             break;
     192             :         }
     193           0 :         ++nIndex;
     194           0 :     }
     195             : 
     196           0 :     if ( sGroupName.Len() == 0 && bForced )
     197             :     {
     198           0 :         if ( !pPageRes )
     199           0 :             pPageRes = new OfaPageResource;
     200             : 
     201           0 :         if ( rModule == "Writer" )
     202           0 :             sGroupName = pPageRes->GetTextArray().GetString(0);
     203           0 :         else if ( rModule == "WriterWeb" )
     204           0 :             sGroupName = pPageRes->GetHTMLArray().GetString(0);
     205           0 :         else if ( rModule == "Calc" )
     206           0 :             sGroupName = pPageRes->GetCalcArray().GetString(0);
     207           0 :         else if ( rModule == "Impress" )
     208           0 :             sGroupName = pPageRes->GetImpressArray().GetString(0);
     209           0 :         else if ( rModule == "Draw" )
     210           0 :             sGroupName = pPageRes->GetDrawArray().GetString(0);
     211           0 :         else if ( rModule == "Math" )
     212           0 :             sGroupName = pPageRes->GetStarMathArray().GetString(0);
     213           0 :         else if ( rModule == "Base" )
     214           0 :             sGroupName = pPageRes->GetDatasourcesArray().GetString(0);
     215             :     }
     216           0 :     return sGroupName;
     217             : }
     218             : 
     219           0 : static void deleteGroupNames()
     220             : {
     221           0 :     sal_uInt16 nIndex = 0;
     222           0 :     while ( ModuleMap[ nIndex ].m_pModule )
     223           0 :         ModuleMap[ nIndex++ ].m_sGroupName = String::EmptyString();
     224           0 : }
     225             : 
     226           0 : static sal_uInt16 getGroupNodeId( const OUString& rModule )
     227             : {
     228           0 :     sal_uInt16 nNodeId = 0xFFFF, nIndex = 0;
     229           0 :     while ( ModuleMap[ nIndex ].m_pModule )
     230             :     {
     231             :         OUString sTemp =
     232           0 :             OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
     233           0 :         if ( sTemp == rModule )
     234             :         {
     235           0 :             nNodeId = ModuleMap[ nIndex ].m_nNodeId;
     236           0 :             break;
     237             :         }
     238           0 :         ++nIndex;
     239           0 :     }
     240             : 
     241           0 :     return nNodeId;
     242             : }
     243             : 
     244             : class MailMergeCfg_Impl : public utl::ConfigItem
     245             : {
     246             :     friend class SvxEMailTabPage;
     247             :     // variables
     248             :     sal_Bool bIsEmailSupported;
     249             : 
     250             : public:
     251             :     MailMergeCfg_Impl();
     252             :     virtual ~MailMergeCfg_Impl();
     253             : 
     254             :     virtual void    Commit();
     255             :     virtual void Notify( const com::sun::star::uno::Sequence< OUString >& _rPropertyNames);
     256             : 
     257           0 :     sal_Bool IsEmailSupported() const {return bIsEmailSupported;}
     258             : 
     259             : };
     260             : 
     261           0 : MailMergeCfg_Impl::MailMergeCfg_Impl() :
     262             :     utl::ConfigItem("Office.Writer/MailMergeWizard"),
     263           0 :     bIsEmailSupported(sal_False)
     264             : {
     265           0 :     Sequence<OUString> aNames(1);
     266           0 :     aNames.getArray()[0] = "EMailSupported";
     267           0 :     const Sequence< Any > aValues = GetProperties(aNames);
     268           0 :     const Any* pValues = aValues.getConstArray();
     269           0 :     if(aValues.getLength() && pValues[0].hasValue())
     270           0 :         pValues[0] >>= bIsEmailSupported;
     271           0 : }
     272             : 
     273           0 : MailMergeCfg_Impl::~MailMergeCfg_Impl()
     274             : {
     275           0 : }
     276             : /* -------------------------------------------------------------------------*/
     277           0 : void MailMergeCfg_Impl::Commit()
     278             : {
     279           0 : }
     280             : 
     281           0 : void MailMergeCfg_Impl::Notify( const com::sun::star::uno::Sequence< OUString >& )
     282             : {
     283           0 : }
     284             : 
     285             : //typedef SfxTabPage* (*FNCreateTabPage)( Window *pParent, const SfxItemSet &rAttrSet );
     286           0 : SfxTabPage* CreateGeneralTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
     287             : {
     288           0 :     CreateTabPage fnCreate = 0;
     289           0 :     switch(nId)
     290             :     {
     291           0 :         case RID_SFXPAGE_SAVE:                      fnCreate = &SvxSaveTabPage::Create; break;
     292           0 :         case RID_SFXPAGE_PATH:                      fnCreate = &SvxPathTabPage::Create; break;
     293           0 :         case RID_SFXPAGE_GENERAL:                   fnCreate = &SvxGeneralTabPage::Create; break;
     294           0 :         case RID_SFXPAGE_PRINTOPTIONS:              fnCreate = &SfxCommonPrintOptionsTabPage::Create; break;
     295           0 :         case OFA_TP_LANGUAGES:                      fnCreate = &OfaLanguagesTabPage::Create; break;
     296           0 :         case RID_SFXPAGE_LINGU:                     fnCreate = &SvxLinguTabPage::Create; break;
     297           0 :         case RID_SVXPAGE_COLOR:                     fnCreate = &SvxColorTabPage::Create; break;
     298           0 :         case OFA_TP_VIEW:                           fnCreate = &OfaViewTabPage::Create; break;
     299           0 :         case OFA_TP_MISC:                           fnCreate = &OfaMiscTabPage::Create; break;
     300           0 :         case OFA_TP_MEMORY:                         fnCreate = &OfaMemoryOptionsPage::Create; break;
     301           0 :         case RID_SVXPAGE_ASIAN_LAYOUT:              fnCreate = &SvxAsianLayoutPage::Create; break;
     302           0 :         case RID_SVX_FONT_SUBSTITUTION:             fnCreate = &SvxFontSubstTabPage::Create; break;
     303           0 :         case RID_SVXPAGE_INET_PROXY:                fnCreate = &SvxProxyTabPage::Create; break;
     304           0 :         case RID_SVXPAGE_INET_SECURITY:             fnCreate = &SvxSecurityTabPage::Create; break;
     305           0 :         case RID_SVXPAGE_INET_MAIL:                 fnCreate = &SvxEMailTabPage::Create; break;
     306           0 :         case RID_SVXPAGE_PERSONALIZATION:           fnCreate = &SvxPersonalizationTabPage::Create; break;
     307           0 :         case RID_SVXPAGE_COLORCONFIG:               fnCreate = &SvxColorOptionsTabPage::Create; break;
     308           0 :         case RID_OFAPAGE_HTMLOPT:                   fnCreate = &OfaHtmlTabPage::Create; break;
     309           0 :         case SID_OPTFILTER_MSOFFICE:                fnCreate = &OfaMSFilterTabPage::Create; break;
     310           0 :         case RID_OFAPAGE_MSFILTEROPT2:              fnCreate = &OfaMSFilterTabPage2::Create; break;
     311           0 :         case RID_SVXPAGE_JSEARCH_OPTIONS:           fnCreate = &SvxJSearchOptionsPage::Create ; break;
     312           0 :         case SID_SB_CONNECTIONPOOLING:              fnCreate = &::offapp::ConnectionPoolOptionsPage::Create; break;
     313           0 :         case SID_SB_DBREGISTEROPTIONS:              fnCreate = &::svx::DbRegistrationOptionsPage::Create; break;
     314           0 :         case RID_SVXPAGE_ACCESSIBILITYCONFIG:       fnCreate = &SvxAccessibilityOptionsTabPage::Create; break;
     315           0 :         case RID_SVXPAGE_OPTIONS_CTL:               fnCreate = &SvxCTLOptionsPage::Create ; break;
     316           0 :         case RID_SVXPAGE_INET_MOZPLUGIN:            fnCreate = &MozPluginTabPage::Create; break;
     317           0 :         case RID_SVXPAGE_OPTIONS_JAVA:              fnCreate = &SvxJavaOptionsPage::Create ; break;
     318           0 :         case RID_SVXPAGE_ONLINEUPDATE:              fnCreate = &SvxOnlineUpdateTabPage::Create; break;
     319           0 :         case RID_OPTPAGE_CHART_DEFCOLORS:           fnCreate = &SvxDefaultColorOptPage::Create; break;
     320             :     }
     321             : 
     322           0 :     SfxTabPage* pRet = fnCreate ? (*fnCreate)( pParent, rSet ) : NULL;
     323           0 :     return pRet;
     324             : }
     325             : 
     326             : struct OptionsMapping_Impl
     327             : {
     328             :     const char* m_pGroupName;
     329             :     const char* m_pPageName;
     330             :     sal_uInt16      m_nPageId;
     331             : };
     332             : 
     333             : static OptionsMapping_Impl const OptionsMap_Impl[] =
     334             : {
     335             : //    GROUP                 PAGE                    PAGE-ID
     336             :     { "ProductName",        NULL,                   SID_GENERAL_OPTIONS },
     337             :     { "ProductName",        "UserData",             RID_SFXPAGE_GENERAL },
     338             :     { "ProductName",        "General",              OFA_TP_MISC },
     339             :     { "ProductName",        "Memory",               OFA_TP_MEMORY },
     340             :     { "ProductName",        "View",                 OFA_TP_VIEW },
     341             :     { "ProductName",        "Print",                RID_SFXPAGE_PRINTOPTIONS },
     342             :     { "ProductName",        "Paths",                RID_SFXPAGE_PATH },
     343             :     { "ProductName",        "Colors",               RID_SVXPAGE_COLOR },
     344             :     { "ProductName",        "Fonts",                RID_SVX_FONT_SUBSTITUTION },
     345             :     { "ProductName",        "Security",             RID_SVXPAGE_INET_SECURITY },
     346             :     { "ProductName",        "Personalization",      RID_SVXPAGE_PERSONALIZATION },
     347             :     { "ProductName",        "Appearance",           RID_SVXPAGE_COLORCONFIG },
     348             :     { "ProductName",        "Accessibility",        RID_SVXPAGE_ACCESSIBILITYCONFIG },
     349             :     { "ProductName",        "Java",                 RID_SVXPAGE_OPTIONS_JAVA },
     350             :     { "ProductName",        "OnlineUpdate",         RID_SVXPAGE_ONLINEUPDATE },
     351             :     { "LanguageSettings",   NULL,                   SID_LANGUAGE_OPTIONS },
     352             :     { "LanguageSettings",   "Languages",            OFA_TP_LANGUAGES  },
     353             :     { "LanguageSettings",   "WritingAids",          RID_SFXPAGE_LINGU },
     354             :     { "LanguageSettings",   "SearchingInJapanese",  RID_SVXPAGE_JSEARCH_OPTIONS },
     355             :     { "LanguageSettings",   "AsianLayout",          RID_SVXPAGE_ASIAN_LAYOUT },
     356             :     { "LanguageSettings",   "ComplexTextLayout",    RID_SVXPAGE_OPTIONS_CTL },
     357             :     { "Internet",           NULL,                   SID_INET_DLG },
     358             :     { "Internet",           "Proxy",                RID_SVXPAGE_INET_PROXY },
     359             :     { "Internet",           "Email",                RID_SVXPAGE_INET_MAIL },
     360             :     { "Internet",           "MozillaPlugin",        RID_SVXPAGE_INET_MOZPLUGIN },
     361             :     { "LoadSave",           NULL,                   SID_FILTER_DLG },
     362             :     { "LoadSave",           "General",              RID_SFXPAGE_SAVE },
     363             :     { "LoadSave",           "VBAProperties",        SID_OPTFILTER_MSOFFICE },
     364             :     { "LoadSave",           "MicrosoftOffice",      RID_OFAPAGE_MSFILTEROPT2 },
     365             :     { "LoadSave",           "HTMLCompatibility",    RID_OFAPAGE_HTMLOPT },
     366             :     { "Writer",             NULL,                   SID_SW_EDITOPTIONS },
     367             :     { "Writer",             "General",              RID_SW_TP_OPTLOAD_PAGE },
     368             :     { "Writer",             "View",                 RID_SW_TP_CONTENT_OPT },
     369             :     { "Writer",             "FormattingAids",       RID_SW_TP_OPTSHDWCRSR },
     370             :     { "Writer",             "Grid",                 RID_SVXPAGE_GRID },
     371             :     { "Writer",             "BasicFontsWestern",    RID_SW_TP_STD_FONT },
     372             :     { "Writer",             "BasicFontsAsian",      RID_SW_TP_STD_FONT_CJK },
     373             :     { "Writer",             "BasicFontsCTL",        RID_SW_TP_STD_FONT_CTL },
     374             :     { "Writer",             "Print",                RID_SW_TP_OPTPRINT_PAGE },
     375             :     { "Writer",             "Table",                RID_SW_TP_OPTTABLE_PAGE },
     376             :     { "Writer",             "Changes",              RID_SW_TP_REDLINE_OPT },
     377             :     { "Writer",             "Comparison",           RID_SW_TP_COMPARISON_OPT },
     378             :     { "Writer",             "Compatibility",        RID_SW_TP_OPTCOMPATIBILITY_PAGE },
     379             :     { "Writer",             "AutoCaption",          RID_SW_TP_OPTCAPTION_PAGE },
     380             :     { "Writer",             "MailMerge",            RID_SW_TP_MAILCONFIG },
     381             :     { "WriterWeb",          NULL,                   SID_SW_ONLINEOPTIONS },
     382             :     { "WriterWeb",          "View",                 RID_SW_TP_HTML_CONTENT_OPT },
     383             :     { "WriterWeb",          "FormattingAids",       RID_SW_TP_HTML_OPTSHDWCRSR },
     384             :     { "WriterWeb",          "Grid",                 RID_SW_TP_HTML_OPTGRID_PAGE },
     385             :     { "WriterWeb",          "Print",                RID_SW_TP_HTML_OPTPRINT_PAGE },
     386             :     { "WriterWeb",          "Table",                RID_SW_TP_HTML_OPTTABLE_PAGE },
     387             :     { "WriterWeb",          "Background",           RID_SW_TP_BACKGROUND },
     388             :     { "Math",               NULL,                   SID_SM_EDITOPTIONS },
     389             :     { "Math",               "Settings",             SID_SM_TP_PRINTOPTIONS },
     390             :     { "Calc",               NULL,                   SID_SC_EDITOPTIONS },
     391             :     { "Calc",               "General",              SID_SC_TP_LAYOUT },
     392             :     { "Calc",               "View",                 SID_SC_TP_CONTENT },
     393             :     { "Calc",               "International",        RID_OFA_TP_INTERNATIONAL },
     394             :     { "Calc",               "Calculate",            SID_SC_TP_CALC },
     395             :     { "Calc",               "Formula",              SID_SC_TP_FORMULA },
     396             :     { "Calc",               "SortLists",            SID_SC_TP_USERLISTS },
     397             :     { "Calc",               "Changes",              SID_SC_TP_CHANGES },
     398             :     { "Calc",               "Compatibility",        SID_SC_TP_COMPATIBILITY },
     399             :     { "Calc",               "Grid",                 SID_SC_TP_GRID },
     400             :     { "Calc",               "Print",                RID_SC_TP_PRINT },
     401             :     { "Impress",            NULL,                   SID_SD_EDITOPTIONS },
     402             :     { "Impress",            "General",              SID_SI_TP_MISC },
     403             :     { "Impress",            "View",                 SID_SI_TP_CONTENTS },
     404             :     { "Impress",            "Grid",                 SID_SI_TP_SNAP },
     405             :     { "Impress",            "Print",                SID_SI_TP_PRINT },
     406             :     { "Draw",               NULL,                   SID_SD_GRAPHIC_OPTIONS },
     407             :     { "Draw",               "General",              SID_SD_TP_MISC },
     408             :     { "Draw",               "View",                 SID_SD_TP_CONTENTS },
     409             :     { "Draw",               "Grid",                 SID_SD_TP_SNAP },
     410             :     { "Draw",               "Print",                SID_SD_TP_PRINT },
     411             :     { "Charts",             NULL,                   SID_SCH_EDITOPTIONS },
     412             :     { "Charts",             "DefaultColors",        RID_OPTPAGE_CHART_DEFCOLORS },
     413             :     { "Base",               NULL,                   SID_SB_STARBASEOPTIONS },
     414             :     { "Base",               "Connections",          SID_SB_CONNECTIONPOOLING },
     415             :     { "Base",               "Databases",            SID_SB_DBREGISTEROPTIONS },
     416             :     { NULL,                 NULL,                   0 }
     417             : };
     418             : 
     419           0 : static sal_Bool lcl_getStringFromID( sal_uInt16 _nPageId, String& _rGroupName, String& _rPageName )
     420             : {
     421           0 :     sal_Bool bRet = sal_False;
     422             : 
     423           0 :     sal_uInt16 nIdx = 0;
     424           0 :     while ( OptionsMap_Impl[nIdx].m_pGroupName != NULL )
     425             :     {
     426           0 :         if ( _nPageId == OptionsMap_Impl[nIdx].m_nPageId )
     427             :         {
     428           0 :             bRet = sal_True;
     429           0 :             _rGroupName = String( OptionsMap_Impl[nIdx].m_pGroupName, RTL_TEXTENCODING_ASCII_US );
     430           0 :             if ( OptionsMap_Impl[nIdx].m_pPageName != NULL )
     431           0 :                 _rPageName = String( OptionsMap_Impl[nIdx].m_pPageName, RTL_TEXTENCODING_ASCII_US );
     432           0 :             break;
     433             :         }
     434           0 :         ++nIdx;
     435             :     }
     436             : 
     437           0 :     return bRet;
     438             : }
     439             : 
     440           0 : static sal_Bool lcl_isOptionHidden( sal_uInt16 _nPageId, const SvtOptionsDialogOptions& _rOptOptions )
     441             : {
     442           0 :     sal_Bool bIsHidden = sal_False;
     443           0 :     String sGroupName, sPageName;
     444           0 :     if ( lcl_getStringFromID( _nPageId, sGroupName, sPageName ) )
     445             :     {
     446           0 :         if ( sPageName.Len() == 0 )
     447           0 :             bIsHidden =  _rOptOptions.IsGroupHidden( sGroupName );
     448             :         else
     449           0 :             bIsHidden =  _rOptOptions.IsPageHidden( sPageName, sGroupName );
     450             :     }
     451           0 :     return bIsHidden;
     452             : }
     453             : 
     454           0 : struct OptionsPageInfo
     455             : {
     456             :     SfxTabPage*         m_pPage;
     457             :     sal_uInt16          m_nPageId;
     458             :     OUString       m_sPageURL;
     459             :     OUString       m_sEventHdl;
     460             :     ExtensionsTabPage*  m_pExtPage;
     461             : 
     462           0 :     OptionsPageInfo( sal_uInt16 nId ) : m_pPage( NULL ), m_nPageId( nId ), m_pExtPage( NULL ) {}
     463             : };
     464             : 
     465             : struct OptionsGroupInfo
     466             : {
     467             :     SfxItemSet*         m_pInItemSet;
     468             :     SfxItemSet*         m_pOutItemSet;
     469             :     SfxShell*           m_pShell;       // used to create the page
     470             :     SfxModule*          m_pModule;      // used to create the ItemSet
     471             :     sal_uInt16          m_nDialogId;    // Id of the former dialog
     472             :     sal_Bool            m_bLoadError;   // load fails?
     473             :     OUString       m_sPageURL;
     474             :     ExtensionsTabPage*  m_pExtPage;
     475             : 
     476           0 :     OptionsGroupInfo( SfxShell* pSh, SfxModule* pMod, sal_uInt16 nId ) :
     477             :         m_pInItemSet( NULL ), m_pOutItemSet( NULL ), m_pShell( pSh ),
     478             :         m_pModule( pMod ), m_nDialogId( nId ), m_bLoadError( sal_False ),
     479           0 :         m_sPageURL( OUString() ), m_pExtPage( NULL ) {}
     480           0 :     ~OptionsGroupInfo() { delete m_pInItemSet; delete m_pOutItemSet; }
     481             : };
     482             : 
     483             : // -----------------------------------------------------------------------
     484             : 
     485             : #define INI_LIST() \
     486             :     pCurrentPageEntry   ( NULL ),\
     487             :     aOkPB               ( this, CUI_RES( PB_OK ) ),\
     488             :     aCancelPB           ( this, CUI_RES( PB_CANCEL ) ),\
     489             :     aHelpPB             ( this, CUI_RES( PB_HELP ) ),\
     490             :     aBackPB             ( this, CUI_RES( PB_BACK ) ),\
     491             :     aSeparatorFL        ( this, CUI_RES( FL_SEPARATOR ) ),\
     492             :     aTreeLB             ( this, CUI_RES( TLB_PAGES ) ),\
     493             :     sTitle              ( GetText() ),\
     494             :     sNotLoadedError     (       CUI_RES( ST_LOAD_ERROR ) ),\
     495             :     pColorPageItemSet   ( NULL ),\
     496             :     mpColorPage         ( NULL ),\
     497             :     bForgetSelection    ( sal_False ),\
     498             :     bIsFromExtensionManager( false ), \
     499             :     bIsForSetDocumentLanguage( false )
     500             : 
     501             : // Ctor() with Frame -----------------------------------------------------
     502             : using namespace ::com::sun::star;
     503           0 : OfaTreeOptionsDialog::OfaTreeOptionsDialog(
     504             :     Window* pParent,
     505             :     const Reference< XFrame >& _xFrame,
     506             :     bool bActivateLastSelection ) :
     507             : 
     508           0 :     SfxModalDialog( pParent, CUI_RES( RID_OFADLG_OPTIONS_TREE ) ),
     509           0 :     INI_LIST()
     510             : {
     511           0 :     FreeResource();
     512             : 
     513           0 :     InitTreeAndHandler();
     514           0 :     Initialize( _xFrame );
     515           0 :     LoadExtensionOptions( OUString() );
     516           0 :     ResizeTreeLB();
     517           0 :     if (bActivateLastSelection)
     518           0 :         ActivateLastSelection();
     519             : 
     520           0 :     aTreeLB.SetAccessibleName(GetDisplayText());
     521           0 : }
     522             : 
     523             : // Ctor() with ExtensionId -----------------------------------------------
     524             : 
     525           0 : OfaTreeOptionsDialog::OfaTreeOptionsDialog( Window* pParent, const OUString& rExtensionId ) :
     526             : 
     527           0 :     SfxModalDialog( pParent, CUI_RES( RID_OFADLG_OPTIONS_TREE ) ),
     528           0 :     INI_LIST()
     529             : {
     530           0 :     FreeResource();
     531             : 
     532           0 :     bIsFromExtensionManager = ( !rExtensionId.isEmpty() );
     533           0 :     InitTreeAndHandler();
     534           0 :     LoadExtensionOptions( rExtensionId );
     535           0 :     ResizeTreeLB();
     536           0 :     ActivateLastSelection();
     537           0 : }
     538             : 
     539           0 : OfaTreeOptionsDialog::~OfaTreeOptionsDialog()
     540             : {
     541           0 :     maTreeLayoutTimer.Stop();
     542           0 :     pCurrentPageEntry = NULL;
     543           0 :     SvTreeListEntry* pEntry = aTreeLB.First();
     544             :     // first children
     545           0 :     while(pEntry)
     546             :     {
     547             :         // if Child (has parent), then OptionsPageInfo
     548           0 :         if(aTreeLB.GetParent(pEntry))
     549             :         {
     550           0 :             OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
     551           0 :             if(pPageInfo->m_pPage)
     552             :             {
     553           0 :                 pPageInfo->m_pPage->FillUserData();
     554           0 :                 String aPageData(pPageInfo->m_pPage->GetUserData());
     555           0 :                 if ( aPageData.Len() )
     556             :                 {
     557           0 :                     SvtViewOptions aTabPageOpt( E_TABPAGE, OUString::number( pPageInfo->m_nPageId) );
     558           0 :                     SetViewOptUserItem( aTabPageOpt, aPageData );
     559             :                 }
     560           0 :                 delete pPageInfo->m_pPage;
     561             :             }
     562             : 
     563           0 :             if (pPageInfo->m_nPageId == RID_SFXPAGE_LINGU)
     564             :             {
     565             :                 // write personal dictionaries
     566           0 :                 Reference< XSearchableDictionaryList >  xDicList( SvxGetDictionaryList() );
     567           0 :                 if (xDicList.is())
     568             :                 {
     569           0 :                     linguistic::SaveDictionaries( xDicList );
     570           0 :                 }
     571             :             }
     572             : 
     573           0 :             if( pPageInfo->m_pExtPage )
     574           0 :                 delete pPageInfo->m_pExtPage;
     575             : 
     576           0 :             delete pPageInfo;
     577             :         }
     578           0 :         pEntry = aTreeLB.Next(pEntry);
     579             :     }
     580             : 
     581             :     // and parents
     582           0 :     pEntry = aTreeLB.First();
     583           0 :     while(pEntry)
     584             :     {
     585           0 :         if(!aTreeLB.GetParent(pEntry))
     586             :         {
     587           0 :             OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pEntry->GetUserData();
     588           0 :             if ( pGroupInfo && pGroupInfo->m_pExtPage )
     589           0 :                 delete pGroupInfo->m_pExtPage;
     590           0 :             delete pGroupInfo;
     591             :         }
     592           0 :         pEntry = aTreeLB.Next(pEntry);
     593             :     }
     594           0 :     delete pColorPageItemSet;
     595           0 :     deleteGroupNames();
     596           0 : }
     597             : 
     598           0 : OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage(
     599             :     sal_uInt16 nId, const String& rPageName, sal_uInt16 nGroup )
     600             : {
     601           0 :     OptionsPageInfo* pPageInfo = new OptionsPageInfo( nId );
     602           0 :     SvTreeListEntry* pParent = aTreeLB.GetEntry( 0, nGroup );
     603             :     DBG_ASSERT( pParent, "OfaTreeOptionsDialog::AddTabPage(): no group found" );
     604           0 :     SvTreeListEntry* pEntry = aTreeLB.InsertEntry( rPageName, pParent );
     605           0 :     pEntry->SetUserData( pPageInfo );
     606           0 :     return pPageInfo;
     607             : }
     608             : 
     609             : // the ItemSet* is passed on to the dialog's ownership
     610           0 : sal_uInt16  OfaTreeOptionsDialog::AddGroup(const String& rGroupName,
     611             :                                         SfxShell* pCreateShell,
     612             :                                         SfxModule* pCreateModule,
     613             :                                         sal_uInt16 nDialogId )
     614             : {
     615           0 :     SvTreeListEntry* pEntry = aTreeLB.InsertEntry(rGroupName);
     616             :     OptionsGroupInfo* pInfo =
     617           0 :         new OptionsGroupInfo( pCreateShell, pCreateModule, nDialogId );
     618           0 :     pEntry->SetUserData(pInfo);
     619           0 :     sal_uInt16 nRet = 0;
     620           0 :     pEntry = aTreeLB.First();
     621           0 :     while(pEntry)
     622             :     {
     623           0 :         if(!aTreeLB.GetParent(pEntry))
     624           0 :             nRet++;
     625           0 :         pEntry = aTreeLB.Next(pEntry);
     626             :     }
     627           0 :     return nRet - 1;
     628             : }
     629             : 
     630           0 : IMPL_LINK_NOARG(OfaTreeOptionsDialog, ShowPageHdl_Impl)
     631             : {
     632           0 :     SelectHdl_Impl();
     633           0 :     return 0;
     634             : }
     635             : 
     636           0 : IMPL_LINK_NOARG(OfaTreeOptionsDialog, BackHdl_Impl)
     637             : {
     638           0 :     if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
     639             :     {
     640           0 :         OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pCurrentPageEntry->GetUserData();
     641           0 :         if ( pPageInfo->m_pPage )
     642             :         {
     643             :             OptionsGroupInfo* pGroupInfo =
     644           0 :                 (OptionsGroupInfo*)aTreeLB.GetParent( pCurrentPageEntry )->GetUserData();
     645           0 :             if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
     646           0 :                 pPageInfo->m_pPage->Reset( *pColorPageItemSet );
     647             :             else
     648           0 :                 pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet );
     649             :         }
     650           0 :         else if ( pPageInfo->m_pExtPage )
     651           0 :             pPageInfo->m_pExtPage->ResetPage();
     652             :     }
     653           0 :     return 0;
     654             : }
     655             : 
     656           0 : IMPL_LINK_NOARG(OfaTreeOptionsDialog, OKHdl_Impl)
     657             : {
     658           0 :     aTreeLB.EndSelection();
     659           0 :     if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
     660             :     {
     661           0 :         OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pCurrentPageEntry->GetUserData();
     662           0 :         if ( pPageInfo->m_pPage )
     663             :         {
     664             :             OptionsGroupInfo* pGroupInfo =
     665           0 :                 (OptionsGroupInfo *)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData();
     666           0 :             if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId
     667           0 :                 && pPageInfo->m_pPage->HasExchangeSupport() )
     668             :             {
     669           0 :                 int nLeave = pPageInfo->m_pPage->DeactivatePage(pGroupInfo->m_pOutItemSet);
     670           0 :                 if ( nLeave == SfxTabPage::KEEP_PAGE )
     671             :                 {
     672             :                     // the page mustn't be left
     673           0 :                     aTreeLB.Select(pCurrentPageEntry);
     674           0 :                     return 0;
     675             :                 }
     676             :             }
     677           0 :             pPageInfo->m_pPage->Hide();
     678             :         }
     679             :     }
     680             : 
     681           0 :     SvTreeListEntry* pEntry = aTreeLB.First();
     682           0 :     while ( pEntry )
     683             :     {
     684           0 :         if ( aTreeLB.GetParent( pEntry ) )
     685             :         {
     686           0 :             OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
     687           0 :             if ( pPageInfo->m_pPage && !pPageInfo->m_pPage->HasExchangeSupport() )
     688             :             {
     689             :                 OptionsGroupInfo* pGroupInfo =
     690           0 :                     (OptionsGroupInfo*)aTreeLB.GetParent(pEntry)->GetUserData();
     691           0 :                 pPageInfo->m_pPage->FillItemSet(*pGroupInfo->m_pOutItemSet);
     692             :             }
     693             : 
     694           0 :             if ( pPageInfo->m_pExtPage )
     695             :             {
     696           0 :                 pPageInfo->m_pExtPage->DeactivatePage();
     697           0 :                 pPageInfo->m_pExtPage->SavePage();
     698             :             }
     699             :         }
     700           0 :         pEntry = aTreeLB.Next(pEntry);
     701             :     }
     702           0 :     EndDialog(RET_OK);
     703           0 :     return 0;
     704             : }
     705             : 
     706             : // an opened group shall be completely visible
     707           0 : IMPL_LINK(OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox*, pBox )
     708             : {
     709           0 :     pBox->Update();
     710           0 :     pBox->InitStartEntry();
     711           0 :     SvTreeListEntry* pEntry = pBox->GetHdlEntry();
     712           0 :     if(pEntry && pBox->IsExpanded(pEntry))
     713             :     {
     714           0 :         sal_uInt32 nChildCount = pBox->GetChildCount( pEntry );
     715             : 
     716           0 :         SvTreeListEntry* pNext = pEntry;
     717           0 :         for(sal_uInt32 i = 0; i < nChildCount;i++)
     718             :         {
     719           0 :             pNext = pBox->GetNextEntryInView(pNext);
     720           0 :             if(!pNext)
     721             :             {
     722           0 :                 pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
     723           0 :                 break;
     724             :             }
     725             :             else
     726             :             {
     727           0 :                 Size aSz(pBox->GetOutputSizePixel());
     728           0 :                 int nHeight = pBox->GetEntryHeight();
     729           0 :                 Point aPos(pBox->GetEntryPosition(pNext));
     730           0 :                 if(aPos.Y()+nHeight > aSz.Height())
     731             :                 {
     732           0 :                     pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
     733           0 :                     break;
     734             :                 }
     735             :             }
     736             :         }
     737             :     }
     738           0 :     return 0;
     739             : }
     740             : 
     741           0 : void OfaTreeOptionsDialog::ApplyItemSets()
     742             : {
     743           0 :     SvTreeListEntry* pEntry = aTreeLB.First();
     744           0 :     while(pEntry)
     745             :     {
     746           0 :         if(!aTreeLB.GetParent(pEntry))
     747             :         {
     748           0 :             OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pEntry->GetUserData();
     749           0 :             if(pGroupInfo->m_pOutItemSet)
     750             :             {
     751           0 :                 if(pGroupInfo->m_pShell)
     752           0 :                     pGroupInfo->m_pShell->ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
     753             :                 else
     754           0 :                     ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
     755             :             }
     756             :         }
     757           0 :         pEntry = aTreeLB.Next(pEntry);
     758             :     }
     759           0 : }
     760             : 
     761           0 : void OfaTreeOptionsDialog::InitTreeAndHandler()
     762             : {
     763           0 :     maTreeLayoutTimer.SetTimeout(50);
     764           0 :     maTreeLayoutTimer.SetTimeoutHdl( LINK( this, OfaTreeOptionsDialog, ImplHandleTreeLayoutTimerHdl ) );
     765             : 
     766           0 :     aTreeLB.SetNodeDefaultImages();
     767             : 
     768           0 :     aTreeLB.SetHelpId( HID_OFADLG_TREELISTBOX );
     769           0 :     aTreeLB.SetStyle( aTreeLB.GetStyle()|WB_HASBUTTONS | WB_HASBUTTONSATROOT |
     770             :                            WB_HASLINES | WB_HASLINESATROOT |
     771           0 :                            WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE | WB_QUICK_SEARCH );
     772           0 :     aTreeLB.SetSpaceBetweenEntries( 0 );
     773           0 :     aTreeLB.SetSelectionMode( SINGLE_SELECTION );
     774           0 :     aTreeLB.SetSublistOpenWithLeftRight( sal_True );
     775           0 :     aTreeLB.SetExpandedHdl( LINK( this, OfaTreeOptionsDialog, ExpandedHdl_Impl ) );
     776           0 :     aTreeLB.SetSelectHdl( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) );
     777           0 :     aBackPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) );
     778           0 :     aOkPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, OKHdl_Impl ) );
     779           0 : }
     780             : 
     781           0 : void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId )
     782             : {
     783           0 :     bIsForSetDocumentLanguage = false;
     784           0 :     if ( nResId == OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE )
     785             :     {
     786           0 :         bIsForSetDocumentLanguage = true;
     787           0 :         nResId = OFA_TP_LANGUAGES;
     788             :     }
     789             : 
     790             :     DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
     791           0 :     if ( !pLastPageSaver )
     792           0 :         pLastPageSaver = new LastPageSaver;
     793           0 :     bForgetSelection = sal_True;
     794           0 :     sal_uInt16 nTemp = pLastPageSaver->m_nLastPageId;
     795           0 :     pLastPageSaver->m_nLastPageId = nResId;
     796           0 :     ActivateLastSelection();
     797           0 :     pLastPageSaver->m_nLastPageId = nTemp;
     798           0 : }
     799             : 
     800           0 : void OfaTreeOptionsDialog::ActivatePage( const String& rPageURL )
     801             : {
     802             :     DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
     803           0 :     if ( !pLastPageSaver )
     804           0 :         pLastPageSaver = new LastPageSaver;
     805           0 :     bForgetSelection = sal_True;
     806           0 :     pLastPageSaver->m_nLastPageId = 0;
     807           0 :     pLastPageSaver->m_sLastPageURL_Tools = rPageURL;
     808           0 :     ActivateLastSelection();
     809           0 : }
     810             : 
     811           0 : void OfaTreeOptionsDialog::ActivateLastSelection()
     812             : {
     813           0 :     SvTreeListEntry* pEntry = NULL;
     814           0 :     if ( pLastPageSaver )
     815             :     {
     816           0 :         String sExpand( EXPAND_PROTOCOL  );
     817             :         String sLastURL = bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
     818           0 :                                                   : pLastPageSaver->m_sLastPageURL_Tools;
     819           0 :         if ( sLastURL.Len() == 0 )
     820             :         {
     821           0 :             sLastURL = !bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
     822           0 :                                                 : pLastPageSaver->m_sLastPageURL_Tools;
     823             :         }
     824             : 
     825             :         // MacroExpander to convert "expand"-URL to "file"-URL
     826           0 :         Reference< XMacroExpander > xMacroExpander;
     827           0 :         bool bMustExpand = ( INetURLObject( sLastURL ).GetProtocol() == INET_PROT_FILE );
     828             : 
     829           0 :         if ( bMustExpand )
     830             :         {
     831             :             Reference< XComponentContext > xContext(
     832           0 :                 comphelper::getProcessComponentContext() );
     833           0 :             xMacroExpander = theMacroExpander::get(xContext);
     834             :         }
     835             : 
     836           0 :         SvTreeListEntry* pTemp = aTreeLB.First();
     837           0 :         while( !pEntry && pTemp )
     838             :         {
     839             :             // restore only selection of a leaf
     840           0 :             if ( aTreeLB.GetParent( pTemp ) && pTemp->GetUserData() )
     841             :             {
     842           0 :                 OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pTemp->GetUserData();
     843           0 :                 String sPageURL = pPageInfo->m_sPageURL;
     844           0 :                 if ( bMustExpand
     845           0 :                     && sPageURL.Len() > 0
     846           0 :                     && sExpand.Match( sPageURL ) == STRING_MATCH )
     847             :                 {
     848             :                     // cut protocol
     849           0 :                     OUString sTemp( sPageURL.Copy( sizeof( EXPAND_PROTOCOL ) -1 ) );
     850             :                     // decode uri class chars
     851           0 :                     sTemp = ::rtl::Uri::decode(
     852           0 :                         sTemp, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
     853             :                     // expand string
     854           0 :                     sPageURL = xMacroExpander->expandMacros( sTemp );
     855             :                 }
     856             : 
     857           0 :                 if ( ( !bIsFromExtensionManager
     858           0 :                         && pPageInfo->m_nPageId && pPageInfo->m_nPageId == pLastPageSaver->m_nLastPageId )
     859           0 :                             || ( !pPageInfo->m_nPageId && sLastURL == sPageURL ) )
     860           0 :                     pEntry = pTemp;
     861             :             }
     862           0 :             pTemp = aTreeLB.Next(pTemp);
     863           0 :         }
     864             :     }
     865             : 
     866           0 :     if ( !pEntry )
     867             :     {
     868           0 :         pEntry = aTreeLB.First();
     869           0 :         pEntry = aTreeLB.Next(pEntry);
     870             :     }
     871             : 
     872           0 :     SvTreeListEntry* pParent = aTreeLB.GetParent(pEntry);
     873           0 :     aTreeLB.Expand(pParent);
     874           0 :     aTreeLB.MakeVisible(pParent);
     875           0 :     aTreeLB.MakeVisible(pEntry);
     876           0 :     aTreeLB.Select(pEntry);
     877           0 :     aTreeLB.GrabFocus();
     878           0 : }
     879             : 
     880           0 : long    OfaTreeOptionsDialog::Notify( NotifyEvent& rNEvt )
     881             : {
     882           0 :     if ( rNEvt.GetType() == EVENT_KEYINPUT )
     883             :     {
     884           0 :         const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
     885           0 :         const KeyCode aKeyCode = pKEvt->GetKeyCode();
     886             : 
     887           0 :         if( aKeyCode.GetCode() == KEY_PAGEUP ||
     888           0 :                 aKeyCode.GetCode() == KEY_PAGEDOWN)
     889             :         {
     890           0 :             SvTreeListEntry* pCurEntry = aTreeLB.FirstSelected();
     891           0 :             SvTreeListEntry*  pTemp = 0;
     892           0 :             if(aKeyCode.GetCode() == KEY_PAGEDOWN)
     893             :             {
     894           0 :                 pTemp =  aTreeLB.Next( pCurEntry ) ;
     895           0 :                 if(pTemp && !aTreeLB.GetParent(pTemp))
     896             :                 {
     897           0 :                     pTemp =  aTreeLB.Next( pTemp ) ;
     898           0 :                     aTreeLB.Select(pTemp);
     899             :                 }
     900             :             }
     901             :             else
     902             :             {
     903           0 :                 pTemp =  aTreeLB.Prev( pCurEntry ) ;
     904           0 :                 if(pTemp && !aTreeLB.GetParent(pTemp))
     905             :                 {
     906           0 :                     pTemp =  aTreeLB.Prev( pTemp ) ;
     907             :                 }
     908             :             }
     909           0 :             if(pTemp)
     910             :             {
     911           0 :                 if(!aTreeLB.IsExpanded(aTreeLB.GetParent(pTemp)))
     912           0 :                     aTreeLB.Expand(aTreeLB.GetParent(pTemp));
     913           0 :                 aTreeLB.MakeVisible(pTemp);
     914           0 :                 aTreeLB.Select(pTemp);
     915             :             }
     916             :         }
     917             :     }
     918           0 :     return SfxModalDialog::Notify(rNEvt);
     919             : }
     920             : 
     921           0 : bool OfaTreeOptionsDialog::hasTreePendingLayout() const
     922             : {
     923           0 :     return maTreeLayoutTimer.IsActive();
     924             : }
     925             : 
     926           0 : void OfaTreeOptionsDialog::queue_layout()
     927             : {
     928           0 :     if (hasTreePendingLayout())
     929           0 :         return;
     930           0 :     if (IsInClose())
     931           0 :         return;
     932           0 :     maTreeLayoutTimer.Start();
     933             : }
     934             : 
     935           0 : IMPL_LINK( OfaTreeOptionsDialog, ImplHandleTreeLayoutTimerHdl, void*, EMPTYARG )
     936             : {
     937           0 :     if (pCurrentPageEntry && aTreeLB.GetParent(pCurrentPageEntry))
     938             :     {
     939           0 :         OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pCurrentPageEntry->GetUserData();
     940           0 :         if (pPageInfo->m_pPage && ::isLayoutEnabled(pPageInfo->m_pPage))
     941           0 :             SetPaneSize(pPageInfo->m_pPage);
     942             :     }
     943           0 :     return 0;
     944             : }
     945             : 
     946             : // --------------------------------------------------------------------
     947           0 : void OfaTreeOptionsDialog::SetPaneSize(Window *pPane)
     948             : {
     949             :     //The OfaTreeOptionsDialog is not fully widget layout enabled
     950             :     //yet so it's a classic fixed dimension dialog, but to make
     951             :     //it possible to incrementally convert it over each pane
     952             :     //can be converted to .ui layout format and the fixed area
     953             :     //size reserved for panes is allocated to them here
     954           0 :     Point aPos(aSeparatorFL.GetPosPixel().X(), aTreeLB.GetPosPixel().Y());
     955           0 :     Size aSize(aSeparatorFL.GetSizePixel().Width(),
     956           0 :                aSeparatorFL.GetPosPixel().Y() - aTreeLB.GetPosPixel().Y());
     957           0 :     pPane->SetPosSizePixel( aPos, aSize );
     958           0 : }
     959             : 
     960           0 : void OfaTreeOptionsDialog::SelectHdl_Impl()
     961             : {
     962           0 :     SvTreeListBox* pBox = &aTreeLB;
     963             : 
     964           0 :     if(pCurrentPageEntry == pBox->GetCurEntry())
     965             :     {
     966           0 :         pBox->EndSelection();
     967           0 :         return;
     968             :     }
     969             : 
     970           0 :     SvTreeListEntry* pEntry = pBox->GetCurEntry();
     971           0 :     SvTreeListEntry* pParent = pBox->GetParent(pEntry);
     972             : 
     973             :     // If the user has selected a category, automatically switch to a suitable
     974             :     // default sub-page instead.
     975           0 :     if (!pParent)
     976             :     {
     977           0 :         pBox->EndSelection();
     978           0 :         return;
     979             :     }
     980             : 
     981           0 :     pBox->EndSelection();
     982             : 
     983           0 :     TabPage* pOldPage = NULL;
     984           0 :     TabPage* pNewPage = NULL;
     985           0 :     OptionsPageInfo* pOptPageInfo = ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
     986           0 :         ? (OptionsPageInfo*)pCurrentPageEntry->GetUserData() : NULL;
     987             : 
     988           0 :     if ( pOptPageInfo && pOptPageInfo->m_pPage && pOptPageInfo->m_pPage->IsVisible() )
     989             :     {
     990           0 :         pOldPage = pOptPageInfo->m_pPage;
     991           0 :         OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData();
     992           0 :         int nLeave = SfxTabPage::LEAVE_PAGE;
     993           0 :         if ( RID_SVXPAGE_COLOR != pOptPageInfo->m_nPageId && pOptPageInfo->m_pPage->HasExchangeSupport() )
     994           0 :            nLeave = pOptPageInfo->m_pPage->DeactivatePage( pGroupInfo->m_pOutItemSet );
     995             : 
     996           0 :         if ( nLeave == SfxTabPage::KEEP_PAGE )
     997             :         {
     998             :             // we cannot leave this page
     999           0 :             pBox->Select( pCurrentPageEntry );
    1000           0 :             return;
    1001             :         }
    1002             :         else
    1003           0 :             pOptPageInfo->m_pPage->Hide();
    1004             :     }
    1005           0 :     else if ( pOptPageInfo && pOptPageInfo->m_pExtPage )
    1006             :     {
    1007           0 :         pOptPageInfo->m_pExtPage->Hide();
    1008           0 :         pOptPageInfo->m_pExtPage->DeactivatePage();
    1009             :     }
    1010           0 :     else if ( pCurrentPageEntry && !aTreeLB.GetParent( pCurrentPageEntry ) )
    1011             :     {
    1012           0 :         OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pCurrentPageEntry->GetUserData();
    1013           0 :         if ( pGroupInfo && pGroupInfo->m_pExtPage )
    1014             :         {
    1015           0 :             pGroupInfo->m_pExtPage->Hide();
    1016           0 :             pGroupInfo->m_pExtPage->DeactivatePage();
    1017             :         }
    1018             :     }
    1019             : 
    1020           0 :     OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
    1021           0 :     OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pParent->GetUserData();
    1022           0 :     if(!pPageInfo->m_pPage && pPageInfo->m_nPageId > 0)
    1023             :     {
    1024           0 :         if(pGroupInfo->m_bLoadError)
    1025           0 :             return;
    1026           0 :         if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
    1027             :         {
    1028           0 :             if(!pColorPageItemSet)
    1029             :             {
    1030             :                 // Move usage of a static XOutdevItemPool instance here
    1031           0 :                 if(!mpStaticXOutdevItemPool)
    1032           0 :                     mpStaticXOutdevItemPool = new XOutdevItemPool();
    1033             : 
    1034           0 :                 pColorPageItemSet = new SfxItemSet( *mpStaticXOutdevItemPool, XATTR_FILLSTYLE, XATTR_FILLCOLOR);
    1035           0 :                 pColorPageItemSet->Put( XFillColorItem() );
    1036             :             }
    1037             :         }
    1038             :         else
    1039             :         {
    1040           0 :             if(pGroupInfo->m_pModule /*&& !pGroupInfo->pModule->IsLoaded()*/)
    1041             :             {
    1042           0 :                 SfxModule* pOldModule = pGroupInfo->m_pModule;
    1043           0 :                 sal_Bool bIdentical = pGroupInfo->m_pModule == pGroupInfo->m_pShell;
    1044             : 
    1045           0 :                 WaitObject aWait(this);
    1046             :                 //pGroupInfo->pModule = pGroupInfo->pModule->Load();
    1047           0 :                 if(!pGroupInfo->m_pModule)
    1048             :                 {
    1049           0 :                     pGroupInfo->m_bLoadError = sal_True;
    1050           0 :                     InfoBox(pBox, sNotLoadedError).Execute();
    1051           0 :                     return;
    1052             :                 }
    1053           0 :                 if(bIdentical)
    1054           0 :                     pGroupInfo->m_pShell = pGroupInfo->m_pModule;
    1055             :                 // now test whether there was the same module in other groups, too (e. g. Text+HTML)
    1056           0 :                 SvTreeListEntry* pTemp = aTreeLB.First();
    1057           0 :                 while(pTemp)
    1058             :                 {
    1059           0 :                     if(!aTreeLB.GetParent(pTemp) && pTemp != pEntry)
    1060             :                     {
    1061           0 :                         OptionsGroupInfo* pTGInfo = (OptionsGroupInfo *)pTemp->GetUserData();
    1062           0 :                         if(pTGInfo->m_pModule == pOldModule)
    1063             :                         {
    1064           0 :                             pTGInfo->m_pModule = pGroupInfo->m_pModule;
    1065           0 :                             if(bIdentical)
    1066           0 :                                 pTGInfo->m_pShell = pGroupInfo->m_pModule;
    1067             :                         }
    1068             :                     }
    1069           0 :                     pTemp = aTreeLB.Next(pTemp);
    1070           0 :                 }
    1071             :             }
    1072             : 
    1073           0 :             if(!pGroupInfo->m_pInItemSet)
    1074             :                 pGroupInfo->m_pInItemSet = pGroupInfo->m_pShell
    1075           0 :                     ? pGroupInfo->m_pShell->CreateItemSet( pGroupInfo->m_nDialogId )
    1076           0 :                     : CreateItemSet( pGroupInfo->m_nDialogId );
    1077           0 :             if(!pGroupInfo->m_pOutItemSet)
    1078             :                 pGroupInfo->m_pOutItemSet = new SfxItemSet(
    1079           0 :                     *pGroupInfo->m_pInItemSet->GetPool(),
    1080           0 :                     pGroupInfo->m_pInItemSet->GetRanges());
    1081             :         }
    1082             : 
    1083           0 :         if(pPageInfo->m_nPageId == RID_SVXPAGE_COLOR)
    1084             :         {
    1085             :             pPageInfo->m_pPage = ::CreateGeneralTabPage(
    1086           0 :                 pPageInfo->m_nPageId, this, *pColorPageItemSet );
    1087           0 :             mpColorPage = (SvxColorTabPage*)pPageInfo->m_pPage;
    1088           0 :             mpColorPage->SetupForViewFrame( SfxViewFrame::Current() );
    1089             :         }
    1090             :         else
    1091             :         {
    1092           0 :             pPageInfo->m_pPage = ::CreateGeneralTabPage(pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet );
    1093             : 
    1094           0 :             if(!pPageInfo->m_pPage && pGroupInfo->m_pModule)
    1095           0 :                 pPageInfo->m_pPage = pGroupInfo->m_pModule->CreateTabPage(pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet);
    1096             : 
    1097             :         }
    1098             : 
    1099             :         DBG_ASSERT( pPageInfo->m_pPage, "tabpage could not created");
    1100           0 :         if ( pPageInfo->m_pPage )
    1101             :         {
    1102           0 :             SvtViewOptions aTabPageOpt( E_TABPAGE, OUString::number( pPageInfo->m_nPageId) );
    1103           0 :             pPageInfo->m_pPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) );
    1104             : 
    1105           0 :             Point aPagePos( aSeparatorFL.GetPosPixel().X(), aTreeLB.GetPosPixel().Y());
    1106           0 :             pPageInfo->m_pPage->SetPosPixel( aPagePos );
    1107           0 :             if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
    1108             :             {
    1109           0 :                 pPageInfo->m_pPage->Reset( *pColorPageItemSet );
    1110           0 :                 pPageInfo->m_pPage->ActivatePage( *pColorPageItemSet );
    1111             :             }
    1112             :             else
    1113             :             {
    1114           0 :                 pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet );
    1115             :             }
    1116           0 :             if (::isLayoutEnabled(pPageInfo->m_pPage))
    1117           0 :                 SetPaneSize(pPageInfo->m_pPage);
    1118           0 :         }
    1119             :     }
    1120           0 :     else if ( 0 == pPageInfo->m_nPageId && !pPageInfo->m_pExtPage )
    1121             :     {
    1122           0 :         if ( !m_xContainerWinProvider.is() )
    1123             :         {
    1124           0 :             m_xContainerWinProvider = awt::ContainerWindowProvider::create( ::comphelper::getProcessComponentContext() );
    1125             :         }
    1126             : 
    1127             :         pPageInfo->m_pExtPage = new ExtensionsTabPage(
    1128           0 :             this, 0, pPageInfo->m_sPageURL, pPageInfo->m_sEventHdl, m_xContainerWinProvider );
    1129             : 
    1130           0 :         SetPaneSize(pPageInfo->m_pExtPage);
    1131             :     }
    1132             : 
    1133           0 :     if ( pPageInfo->m_pPage )
    1134             :     {
    1135           0 :         if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId &&
    1136           0 :              pPageInfo->m_pPage->HasExchangeSupport())
    1137             :         {
    1138           0 :             pPageInfo->m_pPage->ActivatePage(*pGroupInfo->m_pOutItemSet);
    1139             :         }
    1140           0 :         pPageInfo->m_pPage->Show();
    1141             :     }
    1142           0 :     else if ( pPageInfo->m_pExtPage )
    1143             :     {
    1144           0 :         pPageInfo->m_pExtPage->Show();
    1145           0 :         pPageInfo->m_pExtPage->ActivatePage();
    1146             :     }
    1147             : 
    1148             :     {
    1149           0 :         OUStringBuffer sTitleBuf(sTitle);
    1150           0 :         sTitleBuf.appendAscii(RTL_CONSTASCII_STRINGPARAM(" - "));
    1151           0 :         sTitleBuf.append(aTreeLB.GetEntryText(pParent));
    1152           0 :         sTitleBuf.appendAscii(RTL_CONSTASCII_STRINGPARAM(" - "));
    1153           0 :         sTitleBuf.append(aTreeLB.GetEntryText(pEntry));
    1154           0 :         SetText(sTitleBuf.makeStringAndClear());
    1155             :     }
    1156             : 
    1157           0 :     pCurrentPageEntry = pEntry;
    1158           0 :     if ( !bForgetSelection )
    1159             :     {
    1160           0 :         if ( !pLastPageSaver )
    1161           0 :             pLastPageSaver = new LastPageSaver;
    1162           0 :         if ( !bIsFromExtensionManager )
    1163           0 :             pLastPageSaver->m_nLastPageId = pPageInfo->m_nPageId;
    1164           0 :         if ( pPageInfo->m_pExtPage )
    1165             :         {
    1166           0 :             if ( bIsFromExtensionManager )
    1167           0 :                 pLastPageSaver->m_sLastPageURL_ExtMgr = pPageInfo->m_sPageURL;
    1168             :             else
    1169           0 :                 pLastPageSaver->m_sLastPageURL_Tools = pPageInfo->m_sPageURL;
    1170             :         }
    1171             :     }
    1172           0 :     pNewPage = pPageInfo->m_pPage;
    1173             : 
    1174             :     // restore lost focus, if necessary
    1175           0 :     Window* pFocusWin = Application::GetFocusWindow();
    1176             :     // if the focused window is not the options treebox and the old page has the focus
    1177           0 :     if ( pFocusWin && pFocusWin != pBox && pOldPage && pOldPage->HasChildPathFocus() )
    1178             :         // then set the focus to the new page or if we are on a group set the focus to the options treebox
    1179           0 :         pNewPage ? pNewPage->GrabFocus() : pBox->GrabFocus();
    1180             : 
    1181           0 :     return;
    1182             : }
    1183             : 
    1184           0 : OfaPageResource::OfaPageResource() :
    1185           0 :     Resource(CUI_RES(RID_OFADLG_OPTIONS_TREE_PAGES)),
    1186           0 :     aGeneralDlgAry(CUI_RES(SID_GENERAL_OPTIONS)),
    1187           0 :     aInetDlgAry(CUI_RES(SID_INET_DLG)),
    1188           0 :     aLangDlgAry(CUI_RES(SID_LANGUAGE_OPTIONS)),
    1189           0 :     aTextDlgAry(CUI_RES(SID_SW_EDITOPTIONS)),
    1190           0 :     aHTMLDlgAry(CUI_RES(SID_SW_ONLINEOPTIONS)),
    1191           0 :     aCalcDlgAry(CUI_RES(SID_SC_EDITOPTIONS)),
    1192           0 :     aStarMathDlgAry(CUI_RES(SID_SM_EDITOPTIONS)),
    1193           0 :     aImpressDlgAry(CUI_RES(SID_SD_EDITOPTIONS)),
    1194           0 :     aDrawDlgAry(CUI_RES(SID_SD_GRAPHIC_OPTIONS)),
    1195           0 :     aChartDlgAry(CUI_RES(SID_SCH_EDITOPTIONS)),
    1196           0 :     aFilterDlgAry(CUI_RES(SID_FILTER_DLG)),
    1197           0 :     aDatasourcesDlgAry(CUI_RES(SID_SB_STARBASEOPTIONS))
    1198             : {
    1199           0 :     FreeResource();
    1200           0 : }
    1201             : 
    1202           0 : SfxItemSet* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
    1203             : {
    1204           0 :     Reference< XLinguProperties >  xProp( SvxGetLinguPropertySet() );
    1205           0 :     SfxItemSet* pRet = 0;
    1206           0 :     switch(nId)
    1207             :     {
    1208             :         case SID_GENERAL_OPTIONS:
    1209             :         {
    1210             :             pRet = new SfxItemSet(
    1211           0 :                 SFX_APP()->GetPool(),
    1212             :                 SID_ATTR_METRIC, SID_ATTR_SPELL,
    1213             :                 SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK,
    1214             :                 SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER,
    1215             :                 SID_ATTR_YEAR2000, SID_ATTR_YEAR2000,
    1216             :                 SID_HTML_MODE, SID_HTML_MODE,
    1217           0 :                 0 );
    1218             : 
    1219           0 :             SfxItemSet aOptSet( SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
    1220           0 :             SFX_APP()->GetOptions(aOptSet);
    1221           0 :             pRet->Put(aOptSet);
    1222             : 
    1223           0 :             utl::MiscCfg    aMisc;
    1224             :             const SfxPoolItem* pItem;
    1225           0 :             SfxViewFrame* pViewFrame = SfxViewFrame::Current();
    1226           0 :             if ( pViewFrame )
    1227             :             {
    1228           0 :                 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
    1229             : 
    1230             :                 // miscellaneous - Year2000
    1231           0 :                 if( SFX_ITEM_AVAILABLE <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) )
    1232           0 :                     pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, ((const SfxUInt16Item*)pItem)->GetValue() ) );
    1233             :                 else
    1234           0 :                     pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) );
    1235             :             }
    1236             :             else
    1237           0 :                 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) );
    1238             : 
    1239             : 
    1240             :             // miscellaneous - Tabulator
    1241           0 :             pRet->Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN, aMisc.IsNotFoundWarning()));
    1242             : 
    1243           0 :             sal_uInt16 nFlag = aMisc.IsPaperSizeWarning() ? SFX_PRINTER_CHG_SIZE : 0;
    1244           0 :             nFlag  |= aMisc.IsPaperOrientationWarning()  ? SFX_PRINTER_CHG_ORIENTATION : 0;
    1245           0 :             pRet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, nFlag ));
    1246             : 
    1247             :         }
    1248           0 :         break;
    1249             :         case SID_LANGUAGE_OPTIONS :
    1250             :         {
    1251           0 :             pRet = new SfxItemSet(SFX_APP()->GetPool(),
    1252             :                     SID_ATTR_LANGUAGE, SID_AUTOSPELL_CHECK,
    1253             :                     SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE,
    1254             :                     SID_OPT_LOCALE_CHANGED, SID_OPT_LOCALE_CHANGED,
    1255             :                     SID_SET_DOCUMENT_LANGUAGE, SID_SET_DOCUMENT_LANGUAGE,
    1256           0 :                     0 );
    1257             : 
    1258             :             // for linguistic
    1259             : 
    1260           0 :             Reference< XSpellChecker1 >  xSpell = SvxGetSpellChecker();
    1261           0 :             pRet->Put(SfxSpellCheckItem( xSpell, SID_ATTR_SPELL ));
    1262           0 :             SfxHyphenRegionItem aHyphen( SID_ATTR_HYPHENREGION );
    1263             : 
    1264           0 :             sal_Int16   nMinLead  = 2,
    1265           0 :                         nMinTrail = 2;
    1266           0 :             if (xProp.is())
    1267             :             {
    1268           0 :                 nMinLead = xProp->getHyphMinLeading();
    1269           0 :                 nMinTrail = xProp->getHyphMinTrailing();
    1270             :             }
    1271           0 :             aHyphen.GetMinLead()  = (sal_uInt8)nMinLead;
    1272           0 :             aHyphen.GetMinTrail() = (sal_uInt8)nMinTrail;
    1273             : 
    1274             :             const SfxPoolItem* pItem;
    1275             :             SfxPoolItem* pClone;
    1276           0 :             SfxViewFrame* pViewFrame = SfxViewFrame::Current();
    1277           0 :             if ( pViewFrame )
    1278             :             {
    1279           0 :                 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
    1280           0 :                 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem))
    1281           0 :                     pRet->Put(SfxUInt16Item(SID_ATTR_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
    1282           0 :                 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem))
    1283           0 :                     pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CJK_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
    1284           0 :                 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem))
    1285           0 :                     pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CTL_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
    1286             : 
    1287           0 :                 pRet->Put(aHyphen);
    1288           0 :                 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem))
    1289             :                 {
    1290           0 :                     pClone = pItem->Clone();
    1291           0 :                     pRet->Put(*pClone);
    1292           0 :                     delete pClone;
    1293             :                 }
    1294             :                 else
    1295             :                 {
    1296           0 :                         sal_Bool bVal = sal_False;
    1297           0 :                         if (xProp.is())
    1298             :                         {
    1299           0 :                             bVal = xProp->getIsSpellAuto();
    1300             :                         }
    1301             : 
    1302           0 :                         pRet->Put(SfxBoolItem(SID_AUTOSPELL_CHECK, bVal));
    1303             :                 }
    1304             :             }
    1305           0 :             pRet->Put( SfxBoolItem( SID_SET_DOCUMENT_LANGUAGE, bIsForSetDocumentLanguage ) );
    1306             :         }
    1307           0 :         break;
    1308             :         case SID_INET_DLG :
    1309           0 :                 pRet = new SfxItemSet( SFX_APP()->GetPool(),
    1310             :                                 SID_BASIC_ENABLED, SID_BASIC_ENABLED,
    1311             :                 //SID_OPTIONS_START - ..END
    1312             :                                 SID_INET_PROXY_TYPE, SID_INET_PROXY_PORT,
    1313             :                                 SID_SAVEREL_INET, SID_SAVEREL_FSYS,
    1314             :                                 SID_INET_SMTPSERVER, SID_INET_SMTPSERVER,
    1315             :                                 SID_INET_NOPROXY, SID_INET_SOCKS_PROXY_PORT,
    1316             :                                 SID_INET_DNS_AUTO, SID_INET_DNS_SERVER,
    1317             :                                 SID_SECURE_URL, SID_SECURE_URL,
    1318           0 :                                 0L );
    1319           0 :                 SFX_APP()->GetOptions(*pRet);
    1320           0 :         break;
    1321             :         case SID_FILTER_DLG:
    1322           0 :             pRet = new SfxItemSet( SFX_APP()->GetPool(),
    1323             :             SID_ATTR_DOCINFO, SID_ATTR_AUTOSAVEMINUTE,
    1324             :             SID_SAVEREL_INET, SID_SAVEREL_FSYS,
    1325             :             SID_ATTR_PRETTYPRINTING, SID_ATTR_PRETTYPRINTING,
    1326             :             SID_ATTR_WARNALIENFORMAT, SID_ATTR_WARNALIENFORMAT,
    1327           0 :             0 );
    1328           0 :             SFX_APP()->GetOptions(*pRet);
    1329           0 :             break;
    1330             : 
    1331             :         case SID_SB_STARBASEOPTIONS:
    1332           0 :             pRet = new SfxItemSet( SFX_APP()->GetPool(),
    1333             :             SID_SB_POOLING_ENABLED, SID_SB_DB_REGISTER,
    1334           0 :             0 );
    1335           0 :             ::offapp::ConnectionPoolConfig::GetOptions(*pRet);
    1336           0 :             ::svx::DbRegisteredNamesConfig::GetOptions(*pRet);
    1337           0 :             break;
    1338             : 
    1339             :         case SID_SCH_EDITOPTIONS:
    1340             :         {
    1341           0 :             SvxChartOptions aChartOpt;
    1342           0 :             pRet = new SfxItemSet( SFX_APP()->GetPool(), SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS );
    1343           0 :             pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) );
    1344           0 :             break;
    1345             :         }
    1346             :     }
    1347           0 :     return pRet;
    1348             : }
    1349             : 
    1350           0 : void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
    1351             : {
    1352           0 :     switch(nId)
    1353             :     {
    1354             :         case SID_GENERAL_OPTIONS:
    1355             :         {
    1356           0 :             utl::MiscCfg    aMisc;
    1357             :             const SfxPoolItem* pItem;
    1358           0 :             SfxItemSet aOptSet(SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
    1359           0 :             aOptSet.Put(rSet);
    1360           0 :             if(aOptSet.Count())
    1361           0 :                 SFX_APP()->SetOptions( aOptSet );
    1362             :             // get dispatcher anew, because SetOptions() might have destroyed the dispatcher
    1363           0 :             SfxViewFrame *pViewFrame = SfxViewFrame::Current();
    1364             : // -------------------------------------------------------------------------
    1365             : //          evaluate Year2000
    1366             : // -------------------------------------------------------------------------
    1367           0 :             sal_uInt16 nY2K = USHRT_MAX;
    1368           0 :             if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_YEAR2000, sal_False, &pItem ) )
    1369           0 :                 nY2K = ((const SfxUInt16Item*)pItem)->GetValue();
    1370           0 :             if( USHRT_MAX != nY2K )
    1371             :             {
    1372           0 :                 if ( pViewFrame )
    1373             :                 {
    1374           0 :                     SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
    1375           0 :                     pDispatch->Execute( SID_ATTR_YEAR2000, SFX_CALLMODE_ASYNCHRON, pItem, 0L);
    1376             :                 }
    1377           0 :                 aMisc.SetYear2000(nY2K);
    1378             :             }
    1379             : 
    1380             : // -------------------------------------------------------------------------
    1381             : //          evaluate print
    1382             : // -------------------------------------------------------------------------
    1383           0 :             if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_NOTFOUND_WARN, sal_False, &pItem))
    1384           0 :                 aMisc.SetNotFoundWarning(((const SfxBoolItem*)pItem)->GetValue());
    1385             : 
    1386           0 :             if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_CHANGESTODOC, sal_False, &pItem))
    1387             :             {
    1388           0 :                 const SfxFlagItem* pFlag = (const SfxFlagItem*)pItem;
    1389           0 :                 aMisc.SetPaperSizeWarning(0 != (pFlag->GetValue() &  SFX_PRINTER_CHG_SIZE ));
    1390           0 :                 aMisc.SetPaperOrientationWarning(0 !=  (pFlag->GetValue() & SFX_PRINTER_CHG_ORIENTATION ));
    1391             :             }
    1392             : // -------------------------------------------------------------------------
    1393             : //          evaluate help options
    1394             : // -------------------------------------------------------------------------
    1395           0 :             if ( SvtHelpOptions().IsHelpTips() != Help::IsQuickHelpEnabled() )
    1396           0 :                 SvtHelpOptions().IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp();
    1397           0 :             if ( SvtHelpOptions().IsExtendedHelp() != Help::IsBalloonHelpEnabled() )
    1398           0 :                 SvtHelpOptions().IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp();
    1399             :         }
    1400           0 :         break;
    1401             :         case SID_LANGUAGE_OPTIONS :
    1402             :         {
    1403           0 :             OfaTreeOptionsDialog::ApplyLanguageOptions(rSet);
    1404             :         }
    1405           0 :         break;
    1406             :         case SID_INET_DLG :
    1407             :         case SID_FILTER_DLG:
    1408           0 :             SFX_APP()->SetOptions( rSet );
    1409           0 :         break;
    1410             : 
    1411             :         case SID_SB_STARBASEOPTIONS:
    1412           0 :             ::offapp::ConnectionPoolConfig::SetOptions( rSet );
    1413           0 :             ::svx::DbRegisteredNamesConfig::SetOptions(rSet);
    1414           0 :             break;
    1415             : 
    1416             :         case SID_SCH_EDITOPTIONS:
    1417             :             // nothing to do. Chart options only apply to newly created charts
    1418           0 :             break;
    1419             : 
    1420             :         default:
    1421             :         {
    1422             :             OSL_FAIL( "Unhandled option in ApplyItemSet" );
    1423             :         }
    1424           0 :         break;
    1425             :     }
    1426             : 
    1427           0 : }
    1428           0 : void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet)
    1429             : {
    1430           0 :     sal_Bool bSaveSpellCheck = sal_False;
    1431             :     const SfxPoolItem* pItem;
    1432             : 
    1433           0 :     if ( SFX_ITEM_SET == rSet.GetItemState( SID_SPELL_MODIFIED, sal_False, &pItem ) )
    1434             :     {
    1435           0 :         bSaveSpellCheck = ( (const SfxBoolItem*)pItem )->GetValue();
    1436             :     }
    1437           0 :     Reference< XComponentContext >  xContext( ::comphelper::getProcessComponentContext() );
    1438           0 :     Reference< XLinguProperties >  xProp = LinguProperties::create( xContext );
    1439           0 :     if ( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_HYPHENREGION, sal_False, &pItem ) )
    1440             :     {
    1441           0 :         const SfxHyphenRegionItem* pHyphenItem = (const SfxHyphenRegionItem*)pItem;
    1442             : 
    1443           0 :         xProp->setHyphMinLeading( (sal_Int16) pHyphenItem->GetMinLead() );
    1444           0 :         xProp->setHyphMinTrailing( (sal_Int16) pHyphenItem->GetMinTrail() );
    1445           0 :         bSaveSpellCheck = sal_True;
    1446             :     }
    1447             : 
    1448           0 :     SfxViewFrame *pViewFrame = SfxViewFrame::Current();
    1449           0 :     if ( pViewFrame )
    1450             :     {
    1451           0 :         SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
    1452           0 :         pItem = 0;
    1453           0 :         if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_LANGUAGE, sal_False, &pItem ))
    1454             :         {
    1455           0 :             pDispatch->Execute(pItem->Which(),    SFX_CALLMODE_ASYNCHRON, pItem, 0L);
    1456           0 :             bSaveSpellCheck = sal_True;
    1457             :         }
    1458           0 :         if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE, sal_False, &pItem ))
    1459             :         {
    1460           0 :             pDispatch->Execute(pItem->Which(),    SFX_CALLMODE_ASYNCHRON, pItem, 0L);
    1461           0 :             bSaveSpellCheck = sal_True;
    1462             :         }
    1463           0 :         if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE, sal_False, &pItem ))
    1464             :         {
    1465           0 :             pDispatch->Execute(pItem->Which(),    SFX_CALLMODE_ASYNCHRON, pItem, 0L);
    1466           0 :             bSaveSpellCheck = sal_True;
    1467             :         }
    1468             : 
    1469           0 :         if( SFX_ITEM_SET == rSet.GetItemState(SID_AUTOSPELL_CHECK, sal_False, &pItem ))
    1470             :         {
    1471           0 :             sal_Bool bOnlineSpelling = ((const SfxBoolItem*)pItem)->GetValue();
    1472             :             pDispatch->Execute(SID_AUTOSPELL_CHECK,
    1473           0 :                 SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD, pItem, 0L);
    1474             : 
    1475           0 :             xProp->setIsSpellAuto( bOnlineSpelling );
    1476             :         }
    1477             : 
    1478           0 :         if( bSaveSpellCheck )
    1479             :         {
    1480             :             //! the config item has changed since we modified the
    1481             :             //! property set it uses
    1482           0 :             pDispatch->Execute(SID_SPELLCHECKER_CHANGED, SFX_CALLMODE_ASYNCHRON);
    1483             :         }
    1484             :     }
    1485             : 
    1486           0 :     if( SFX_ITEM_SET == rSet.GetItemState(SID_OPT_LOCALE_CHANGED, sal_False, &pItem ))
    1487             :     {
    1488           0 :         SfxViewFrame* _pViewFrame = SfxViewFrame::GetFirst();
    1489           0 :         while ( _pViewFrame )
    1490             :         {
    1491           0 :             _pViewFrame->GetDispatcher()->Execute(pItem->Which(),    SFX_CALLMODE_ASYNCHRON, pItem, 0L);
    1492           0 :             _pViewFrame = SfxViewFrame::GetNext( *_pViewFrame );
    1493             :         }
    1494           0 :     }
    1495           0 : }
    1496             : 
    1497           0 : OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame )
    1498             : {
    1499           0 :     OUString sIdentifier;
    1500           0 :     Reference < XFrame > xCurrentFrame( _xFrame );
    1501           0 :     Reference < XModuleManager2 > xModuleManager = ModuleManager::create(::comphelper::getProcessComponentContext());
    1502           0 :     if ( !xCurrentFrame.is() )
    1503             :     {
    1504           0 :         Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
    1505           0 :         xCurrentFrame = xDesktop->getCurrentFrame();
    1506             :     }
    1507             : 
    1508           0 :     if ( xCurrentFrame.is() )
    1509             :     {
    1510             :         try
    1511             :         {
    1512           0 :             sIdentifier = xModuleManager->identify( xCurrentFrame );
    1513             :         }
    1514           0 :         catch ( ::com::sun::star::frame::UnknownModuleException& )
    1515             :         {
    1516             :             DBG_WARNING( "getActiveModule_Impl(): unknown module" );
    1517             :         }
    1518           0 :         catch ( Exception& )
    1519             :         {
    1520             :             SAL_WARN( "cui.options", "getActiveModule_Impl(): exception of XModuleManager::identify()" );
    1521             :         }
    1522             :     }
    1523             : 
    1524           0 :     return sIdentifier;
    1525             : }
    1526             : 
    1527           0 : void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame )
    1528             : {
    1529           0 :     OfaPageResource aDlgResource;
    1530           0 :     sal_uInt16 nGroup = 0;
    1531             : 
    1532           0 :     SvtOptionsDialogOptions aOptionsDlgOpt;
    1533             :     sal_uInt16 i, nPageId;
    1534             : 
    1535             :     // %PRODUCTNAME options
    1536           0 :     if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS, aOptionsDlgOpt ) )
    1537             :     {
    1538           0 :         ResStringArray& rGeneralArray = aDlgResource.GetGeneralArray();
    1539           0 :         setGroupName( "ProductName", rGeneralArray.GetString(0) );
    1540           0 :         nGroup = AddGroup( rGeneralArray.GetString(0), 0, 0, SID_GENERAL_OPTIONS );
    1541           0 :         sal_uInt16 nEnd = static_cast< sal_uInt16 >( rGeneralArray.Count() );
    1542             : 
    1543           0 :         for ( i = 1; i < nEnd; ++i )
    1544             :         {
    1545           0 :             String sNewTitle = rGeneralArray.GetString(i);
    1546           0 :             nPageId = (sal_uInt16)rGeneralArray.GetValue(i);
    1547           0 :             if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1548           0 :                 continue;
    1549             : 
    1550             :             // Disable Online Update page if service not installed
    1551           0 :             if( RID_SVXPAGE_ONLINEUPDATE == nPageId )
    1552             :             {
    1553             :                 try
    1554             :                 {
    1555           0 :                     Reference < XInterface > xService( setup::UpdateCheck::create( ::comphelper::getProcessComponentContext() ) );
    1556           0 :                     if( ! xService.is() )
    1557           0 :                         continue;
    1558             :                 }
    1559           0 :                 catch ( ::com::sun::star::uno::DeploymentException& )
    1560             :                 {
    1561           0 :                     continue;
    1562             :                 }
    1563             :             }
    1564           0 :             AddTabPage( nPageId, sNewTitle, nGroup );
    1565           0 :         }
    1566             :     }
    1567             : 
    1568             :     // Load and Save options
    1569           0 :     if ( !lcl_isOptionHidden( SID_FILTER_DLG, aOptionsDlgOpt ) )
    1570             :     {
    1571           0 :         ResStringArray& rFilterArray = aDlgResource.GetFilterArray();
    1572           0 :         setGroupName( "LoadSave", rFilterArray.GetString(0) );
    1573           0 :         nGroup = AddGroup( rFilterArray.GetString(0), 0, 0, SID_FILTER_DLG );
    1574           0 :         for ( i = 1; i < rFilterArray.Count(); ++i )
    1575             :         {
    1576           0 :             nPageId = (sal_uInt16)rFilterArray.GetValue(i);
    1577           0 :             if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1578           0 :                 AddTabPage( nPageId, rFilterArray.GetString(i), nGroup );
    1579             :         }
    1580             :     }
    1581             : 
    1582             :     // Language options
    1583           0 :     SvtLanguageOptions aLanguageOptions;
    1584           0 :     if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS, aOptionsDlgOpt ) )
    1585             :     {
    1586           0 :         ResStringArray& rLangArray = aDlgResource.GetLangArray();
    1587           0 :         setGroupName( "LanguageSettings", rLangArray.GetString(0) );
    1588           0 :         nGroup = AddGroup( rLangArray.GetString(0), 0, 0, SID_LANGUAGE_OPTIONS );
    1589           0 :         for ( i = 1; i < rLangArray.Count(); ++i )
    1590             :         {
    1591           0 :             nPageId = (sal_uInt16)rLangArray.GetValue(i);
    1592           0 :             if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1593           0 :                 continue;
    1594           0 :             if ( ( RID_SVXPAGE_JSEARCH_OPTIONS != nPageId || aLanguageOptions.IsJapaneseFindEnabled() ) &&
    1595           0 :                  ( RID_SVXPAGE_ASIAN_LAYOUT != nPageId    || aLanguageOptions.IsAsianTypographyEnabled() ) &&
    1596           0 :                  ( RID_SVXPAGE_OPTIONS_CTL != nPageId     || aLanguageOptions.IsCTLFontEnabled() ) )
    1597           0 :                 AddTabPage( nPageId, rLangArray.GetString(i), nGroup );
    1598             :         }
    1599             :     }
    1600             : 
    1601             : 
    1602           0 :     OUString aFactory = getCurrentFactory_Impl( _xFrame );
    1603           0 :     OUString sTemp = GetModuleIdentifier( _xFrame );
    1604             :     DBG_ASSERT( sTemp == aFactory, "S H I T!!!" );
    1605             : 
    1606             :     // Writer and Writer/Web options
    1607           0 :     SvtModuleOptions aModuleOpt;
    1608           0 :     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
    1609             :     {
    1610             :         // text document
    1611           0 :         ResStringArray& rTextArray = aDlgResource.GetTextArray();
    1612           0 :         if (   aFactory.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.text.TextDocument" ) )
    1613           0 :             || aFactory.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.text.WebDocument" ) )
    1614           0 :             || aFactory.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.text.GlobalDocument" ) ) )
    1615             :         {
    1616           0 :             SfxModule* pSwMod = (*(SfxModule**) GetAppData(SHL_WRITER));
    1617           0 :             if ( !lcl_isOptionHidden( SID_SW_EDITOPTIONS, aOptionsDlgOpt ) )
    1618             :             {
    1619           0 :                 if ( aFactory == "com.sun.star.text.WebDocument" )
    1620           0 :                     setGroupName( "WriterWeb", rTextArray.GetString(0) );
    1621             :                 else
    1622           0 :                     setGroupName( "Writer", rTextArray.GetString(0) );
    1623           0 :                 nGroup = AddGroup(rTextArray.GetString(0), pSwMod, pSwMod, SID_SW_EDITOPTIONS );
    1624           0 :                 for ( i = 1; i < rTextArray.Count(); ++i )
    1625             :                 {
    1626           0 :                     nPageId = (sal_uInt16)rTextArray.GetValue(i);
    1627           0 :                     if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1628           0 :                         continue;
    1629           0 :                     if ( ( RID_SW_TP_STD_FONT_CJK != nPageId || aLanguageOptions.IsCJKFontEnabled() ) &&
    1630           0 :                          ( RID_SW_TP_STD_FONT_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) &&
    1631           0 :                          ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfg_Impl().IsEmailSupported() ) )
    1632           0 :                         AddTabPage( nPageId, rTextArray.GetString(i), nGroup );
    1633             :                 }
    1634             : #ifdef DBG_UTIL
    1635             :                 AddTabPage( RID_SW_TP_OPTTEST_PAGE, OUString("Internal Test"), nGroup );
    1636             : #endif
    1637             :             }
    1638             : 
    1639             :             // HTML documents
    1640           0 :             if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS, aOptionsDlgOpt ) )
    1641             :             {
    1642           0 :                 ResStringArray& rHTMLArray = aDlgResource.GetHTMLArray();
    1643           0 :                 nGroup = AddGroup(rHTMLArray.GetString(0), pSwMod, pSwMod, SID_SW_ONLINEOPTIONS );
    1644           0 :                 for( i = 1; i < rHTMLArray.Count(); ++i )
    1645             :                 {
    1646           0 :                     nPageId = (sal_uInt16)rHTMLArray.GetValue(i);
    1647           0 :                     if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1648           0 :                         AddTabPage( nPageId, rHTMLArray.GetString(i), nGroup );
    1649             :                 }
    1650             : #ifdef DBG_UTIL
    1651             :                 AddTabPage( RID_SW_TP_OPTTEST_PAGE, OUString("Internal Test"), nGroup );
    1652             : #endif
    1653             :             }
    1654             :         }
    1655             :     }
    1656             : 
    1657             :     // Calc options
    1658           0 :     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
    1659             :     {
    1660           0 :         if ( aFactory == "com.sun.star.sheet.SpreadsheetDocument" )
    1661             :         {
    1662           0 :             if ( !lcl_isOptionHidden( SID_SC_EDITOPTIONS, aOptionsDlgOpt ) )
    1663             :             {
    1664           0 :                 ResStringArray& rCalcArray = aDlgResource.GetCalcArray();
    1665           0 :                 SfxModule* pScMod = ( *( SfxModule** ) GetAppData( SHL_CALC ) );
    1666           0 :                 setGroupName( "Calc", rCalcArray.GetString(0) );
    1667           0 :                 nGroup = AddGroup( rCalcArray.GetString( 0 ), pScMod, pScMod, SID_SC_EDITOPTIONS );
    1668           0 :                 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rCalcArray.Count() );
    1669           0 :                 for ( i = 1; i < nCount; ++i )
    1670             :                 {
    1671           0 :                     nPageId = (sal_uInt16)rCalcArray.GetValue(i);
    1672           0 :                     if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1673           0 :                         continue;
    1674             : //                  if( bCTL || nId != RID_OFA_TP_INTERNATIONAL )
    1675             : //                  #103755# if an international tabpage is need one day, this should be used again... ;-)
    1676           0 :                     if ( nPageId != RID_OFA_TP_INTERNATIONAL )
    1677           0 :                         AddTabPage( nPageId, rCalcArray.GetString( i ), nGroup );
    1678             :                 }
    1679             :             }
    1680             :         }
    1681             :     }
    1682             : 
    1683             :     // Impress options
    1684           0 :     SfxModule* pSdMod = ( *( SfxModule** ) GetAppData( SHL_DRAW ) );
    1685           0 :     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
    1686             :     {
    1687           0 :         if ( aFactory == "com.sun.star.presentation.PresentationDocument" )
    1688             :         {
    1689           0 :             if ( !lcl_isOptionHidden( SID_SD_EDITOPTIONS, aOptionsDlgOpt ) )
    1690             :             {
    1691           0 :                 ResStringArray& rImpressArray = aDlgResource.GetImpressArray();
    1692           0 :                 setGroupName( "Impress", rImpressArray.GetString(0) );
    1693           0 :                 nGroup = AddGroup( rImpressArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_EDITOPTIONS );
    1694           0 :                 const sal_Bool bCTL = aLanguageOptions.IsCTLFontEnabled();
    1695           0 :                 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rImpressArray.Count() );
    1696           0 :                 for ( i = 1; i < nCount; ++i )
    1697             :                 {
    1698           0 :                     nPageId = (sal_uInt16)rImpressArray.GetValue(i);
    1699           0 :                     if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1700           0 :                         continue;
    1701           0 :                     if ( bCTL || nPageId != RID_OFA_TP_INTERNATIONAL_IMPR )
    1702           0 :                         AddTabPage( nPageId, rImpressArray.GetString(i), nGroup );
    1703             :                 }
    1704             :             }
    1705             :         }
    1706             :     }
    1707             : 
    1708             :     // Draw options
    1709           0 :     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
    1710             :     {
    1711           0 :         if ( aFactory == "com.sun.star.drawing.DrawingDocument" )
    1712             :         {
    1713           0 :             if ( !lcl_isOptionHidden( SID_SD_GRAPHIC_OPTIONS, aOptionsDlgOpt ) )
    1714             :             {
    1715           0 :                 ResStringArray& rDrawArray = aDlgResource.GetDrawArray();
    1716           0 :                 setGroupName( "Draw", rDrawArray.GetString(0) );
    1717           0 :                 nGroup = AddGroup( rDrawArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS );
    1718           0 :                 const sal_Bool bCTL = aLanguageOptions.IsCTLFontEnabled();
    1719           0 :                 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rDrawArray.Count() );
    1720           0 :                 for ( i = 1; i < nCount; ++i )
    1721             :                 {
    1722           0 :                     nPageId = (sal_uInt16)rDrawArray.GetValue(i);
    1723           0 :                     if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1724           0 :                         continue;
    1725           0 :                     if ( bCTL || nPageId != RID_OFA_TP_INTERNATIONAL_SD )
    1726           0 :                         AddTabPage( nPageId, rDrawArray.GetString(i), nGroup );
    1727             :                 }
    1728             :             }
    1729             :         }
    1730             :     }
    1731             : 
    1732             :     // Math options
    1733           0 :     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
    1734             :     {
    1735           0 :         if ( aFactory == "com.sun.star.formula.FormulaProperties" )
    1736             :         {
    1737           0 :             if ( !lcl_isOptionHidden( SID_SM_EDITOPTIONS, aOptionsDlgOpt ) )
    1738             :             {
    1739           0 :                 ResStringArray& rStarMathArray = aDlgResource.GetStarMathArray();
    1740           0 :                 SfxModule* pSmMod = (*(SfxModule**) GetAppData(SHL_SM));
    1741           0 :                 setGroupName( "Math", rStarMathArray.GetString(0) );
    1742           0 :                 nGroup = AddGroup(rStarMathArray.GetString(0), pSmMod, pSmMod, SID_SM_EDITOPTIONS );
    1743           0 :                 for ( i = 1; i < rStarMathArray.Count(); ++i )
    1744             :                 {
    1745           0 :                     nPageId = (sal_uInt16)rStarMathArray.GetValue(i);
    1746           0 :                     if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1747           0 :                         AddTabPage( nPageId, rStarMathArray.GetString(i), nGroup );
    1748             :                 }
    1749             :             }
    1750             :         }
    1751             :     }
    1752             : 
    1753             :     // Database - needed only if there is an application which integrates with databases
    1754           0 :     if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS, aOptionsDlgOpt ) &&
    1755           0 :         (   aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE )
    1756           0 :         ||  aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER )
    1757           0 :         ||  aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC )
    1758             :         ) )
    1759             :     {
    1760           0 :         ResStringArray& rDSArray = aDlgResource.GetDatasourcesArray();
    1761           0 :         setGroupName( "Base", rDSArray.GetString(0) );
    1762           0 :         nGroup = AddGroup( rDSArray.GetString(0), 0, NULL, SID_SB_STARBASEOPTIONS );
    1763           0 :         for ( i = 1; i < rDSArray.Count(); ++i )
    1764             :         {
    1765           0 :             nPageId = (sal_uInt16)rDSArray.GetValue(i);
    1766           0 :             if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1767           0 :                 AddTabPage( nPageId, rDSArray.GetString(i), nGroup );
    1768             :         }
    1769             :     }
    1770             : 
    1771             :     // Chart options (always installed and active)
    1772           0 :     if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS, aOptionsDlgOpt ) )
    1773             :     {
    1774           0 :         ResStringArray& rChartArray = aDlgResource.GetChartArray();
    1775           0 :         setGroupName( "Charts", rChartArray.GetString(0) );
    1776           0 :         nGroup = AddGroup( rChartArray.GetString(0), 0, 0, SID_SCH_EDITOPTIONS );
    1777           0 :         for ( i = 1; i < rChartArray.Count(); ++i )
    1778             :         {
    1779           0 :             nPageId = (sal_uInt16)rChartArray.GetValue(i);
    1780           0 :             if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1781           0 :                AddTabPage( nPageId, rChartArray.GetString(i), nGroup );
    1782             :         }
    1783             :     }
    1784             : 
    1785             :     // Internet options
    1786           0 :     if ( !lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) )
    1787             :     {
    1788           0 :         ResStringArray& rInetArray = aDlgResource.GetInetArray();
    1789           0 :         setGroupName( "Internet", rInetArray.GetString(0) );
    1790           0 :         nGroup = AddGroup(rInetArray.GetString(0), 0, 0, SID_INET_DLG );
    1791             : 
    1792           0 :         for ( i = 1; i < rInetArray.Count(); ++i )
    1793             :         {
    1794           0 :             nPageId = (sal_uInt16)rInetArray.GetValue(i);
    1795           0 :             if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
    1796           0 :                 continue;
    1797             : #if defined WNT
    1798             :             // Disable E-mail tab-page on Windows
    1799             :             if ( nPageId == RID_SVXPAGE_INET_MAIL )
    1800             :                 continue;
    1801             : #endif
    1802             : #if defined MACOSX
    1803             :             // Disable Mozilla Plug-in tab-page on Mac
    1804             :             if ( nPageId == RID_SVXPAGE_INET_MOZPLUGIN )
    1805             :                 continue;
    1806             : #endif
    1807             : #ifdef LINUX
    1808             :             // Disable Mozilla Plug-in tab-page on Linux if we find a
    1809             :             // globally installed plugin
    1810           0 :             if ( nPageId == RID_SVXPAGE_INET_MOZPLUGIN ) {
    1811             :                 struct stat sb;
    1812             :                 char *p;
    1813           0 :                 bool bHaveSystemWidePlugin = false;
    1814           0 :                 char mozpaths[]="/usr/lib/mozilla/plugins/libnpsoplugin.so:/usr/lib/firefox/plugins/libnpsoplugin.so:/usr/lib/mozilla-firefox/plugins/libnpsoplugin.so:/usr/lib/iceweasel/plugins/libnpsoplugin.so:/usr/lib/iceape/plugins/libnpsoplugin.so:/usr/lib/browser-plugins/libnpsoplugin.so:/usr/lib64/browser-plugins/libnpsoplugin.so";
    1815             : 
    1816           0 :                 p = strtok(mozpaths, ":");
    1817           0 :                 while (p != NULL) {
    1818           0 :                     if (stat(p, &sb) != -1) {
    1819           0 :                          bHaveSystemWidePlugin = true;
    1820           0 :                          break;
    1821             :                     }
    1822           0 :                     p = strtok(NULL, ":");
    1823             :                 }
    1824             : 
    1825           0 :                 if (bHaveSystemWidePlugin == true)
    1826           0 :                     continue;
    1827             :             }
    1828             : #endif
    1829           0 :             AddTabPage( nPageId, rInetArray.GetString(i), nGroup );
    1830             :         }
    1831           0 :     }
    1832             : 
    1833             : /*!!!
    1834             :     ResizeTreeLB();
    1835             :     ActivateLastSelection();
    1836             :  */
    1837           0 : }
    1838             : 
    1839             : namespace
    1840             : {
    1841           0 :     void MoveControl( Control& _rCtrl, long _nDeltaPixel )
    1842             :     {
    1843           0 :         Point   aPt( _rCtrl.GetPosPixel() );
    1844           0 :         aPt.X() += _nDeltaPixel;
    1845           0 :         _rCtrl.SetPosPixel( aPt );
    1846           0 :     }
    1847             : }
    1848             : 
    1849           0 : void OfaTreeOptionsDialog::ResizeTreeLB( void )
    1850             : {
    1851           0 :     const long  nMax = aSeparatorFL.GetSizePixel().Width() * 42 / 100;
    1852             :                                             // don't ask where 42 comes from... but it looks / feels ok ;-)
    1853           0 :     long        nDelta = 50;                // min.
    1854           0 :     sal_uInt16      nDepth = 0;
    1855           0 :     const long  nIndent0 = PixelToLogic( Size( 28, 0 ) ).Width();
    1856           0 :     const long  nIndent1 = PixelToLogic( Size( 52, 0 ) ).Width();
    1857             : 
    1858           0 :     SvTreeList* pTreeList = aTreeLB.GetModel();
    1859             :     DBG_ASSERT( pTreeList, "-OfaTreeOptionsDialog::ResizeTreeLB(): no model, no cookies!" );
    1860             : 
    1861           0 :     SvTreeListEntry* pEntry = pTreeList->First();
    1862           0 :     while( pEntry )
    1863             :     {
    1864           0 :         long n = aTreeLB.GetTextWidth(aTreeLB.GetEntryText(pEntry));
    1865           0 :         n += ((nDepth == 0) ? nIndent0 : nIndent1);
    1866             : 
    1867           0 :         if( n > nDelta )
    1868           0 :             nDelta = n;
    1869             : 
    1870           0 :         pEntry = pTreeList->Next( pEntry, &nDepth );
    1871             :     }
    1872             : 
    1873           0 :     nDelta = LogicToPixel( Size( nDelta + 3, 0 ) ).Width();         // + extra space [logic]
    1874           0 :     nDelta += GetSettings().GetStyleSettings().GetScrollBarSize();  // + scroll bar, in case it's needed
    1875             : 
    1876           0 :     if( nDelta > nMax )
    1877           0 :         nDelta = nMax;
    1878             : 
    1879             :     // starting resizing with this
    1880           0 :     Size            aSize( GetSizePixel() );
    1881           0 :     aSize.Width() += nDelta;
    1882           0 :     SetSizePixel( aSize );
    1883             : 
    1884             :     // resize treelistbox
    1885           0 :     aSize = aTreeLB.GetSizePixel();
    1886           0 :     aSize.Width() += nDelta;
    1887           0 :     aTreeLB.SetSizePixel( aSize );
    1888             : 
    1889             :     // ... and move depending controls
    1890           0 :     MoveControl( aOkPB, nDelta );
    1891           0 :     MoveControl( aCancelPB, nDelta );
    1892           0 :     MoveControl( aHelpPB, nDelta );
    1893           0 :     MoveControl( aBackPB, nDelta );
    1894           0 :     MoveControl( aSeparatorFL, nDelta );
    1895           0 : }
    1896             : 
    1897           0 : bool isNodeActive( OptionsNode* pNode, Module* pModule )
    1898             : {
    1899           0 :     if ( pNode )
    1900             :     {
    1901             :         // Node for all modules actine?
    1902           0 :         if ( pNode->m_bAllModules )
    1903           0 :             return true;
    1904             : 
    1905             :         // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted
    1906           0 :         if ( getGroupName( pNode->m_sId, false ).Len() > 0 )
    1907           0 :             return true;
    1908             : 
    1909             :         // no module -> not active
    1910           0 :         if ( !pModule )
    1911           0 :             return false;
    1912             : 
    1913             :         // search node in active module
    1914           0 :         if ( pModule->m_bActive )
    1915             :         {
    1916           0 :             for ( sal_uInt32 j = 0; j < pModule->m_aNodeList.size(); ++j )
    1917           0 :                 if ( pModule->m_aNodeList[j]->m_sId == pNode->m_sId )
    1918           0 :                     return true;
    1919             :         }
    1920             :     }
    1921           0 :     return false;
    1922             : }
    1923             : 
    1924           0 : void OfaTreeOptionsDialog::LoadExtensionOptions( const OUString& rExtensionId )
    1925             : {
    1926           0 :     Module* pModule = NULL;
    1927             : 
    1928             :     // when called by Tools - Options then load nodes of active module
    1929           0 :     if ( rExtensionId.isEmpty() )
    1930             :     {
    1931           0 :         pModule = LoadModule( GetModuleIdentifier( Reference< XFrame >() ) );
    1932             :     }
    1933             : 
    1934           0 :     VectorOfNodes aNodeList = LoadNodes( pModule, rExtensionId );
    1935           0 :     InsertNodes( aNodeList );
    1936             : 
    1937           0 :     delete pModule;
    1938           0 : }
    1939             : 
    1940           0 : OUString OfaTreeOptionsDialog::GetModuleIdentifier( const Reference< XFrame >& rFrame )
    1941             : {
    1942           0 :     OUString sModule;
    1943           0 :     Reference < XFrame > xCurrentFrame( rFrame );
    1944           0 :     Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
    1945           0 :     Reference < XModuleManager2 > xModuleManager = ModuleManager::create(xContext);
    1946             : 
    1947           0 :     if ( !xCurrentFrame.is() )
    1948             :     {
    1949           0 :         Reference < XDesktop2 > xDesktop = Desktop::create( xContext );
    1950           0 :         xCurrentFrame = xDesktop->getCurrentFrame();
    1951             :     }
    1952             : 
    1953           0 :     if ( xCurrentFrame.is() )
    1954             :     {
    1955             :         try
    1956             :         {
    1957           0 :             sModule = xModuleManager->identify( xCurrentFrame );
    1958             :         }
    1959           0 :         catch ( ::com::sun::star::frame::UnknownModuleException& )
    1960             :         {
    1961             :             DBG_WARNING( "OfaTreeOptionsDialog::GetModuleIdentifier(): unknown module" );
    1962             :         }
    1963           0 :         catch ( Exception& )
    1964             :         {
    1965             :             SAL_WARN( "cui.options", "OfaTreeOptionsDialog::GetModuleIdentifier(): exception of XModuleManager::identify()" );
    1966             :         }
    1967             :     }
    1968           0 :     return sModule;
    1969             : }
    1970             : 
    1971           0 : Module* OfaTreeOptionsDialog::LoadModule(
    1972             :     const OUString& rModuleIdentifier )
    1973             : {
    1974           0 :     Module* pModule = NULL;
    1975             :     Reference< XNameAccess > xSet(
    1976           0 :         officecfg::Office::OptionsDialog::Modules::get());
    1977             : 
    1978           0 :     Sequence< OUString > seqNames = xSet->getElementNames();
    1979           0 :     for ( int i = 0; i < seqNames.getLength(); ++i )
    1980             :     {
    1981           0 :         OUString sModule( seqNames[i] );
    1982           0 :         if ( rModuleIdentifier == sModule )
    1983             :         {
    1984             :             // current active module found
    1985           0 :             pModule = new Module( sModule );
    1986           0 :             pModule->m_bActive = true;
    1987             : 
    1988           0 :             Reference< XNameAccess > xModAccess;
    1989           0 :             xSet->getByName( seqNames[i] ) >>= xModAccess;
    1990           0 :             if ( xModAccess.is() )
    1991             :             {
    1992             :                 // load the nodes of this module
    1993           0 :                 Reference< XNameAccess > xNodeAccess;
    1994           0 :                 xModAccess->getByName( "Nodes" ) >>= xNodeAccess;
    1995           0 :                 if ( xNodeAccess.is() )
    1996             :                 {
    1997           0 :                     Sequence< OUString > xTemp = xNodeAccess->getElementNames();
    1998           0 :                     Reference< XNameAccess > xAccess;
    1999           0 :                     sal_Int32 nIndex = -1;
    2000           0 :                     for ( int x = 0; x < xTemp.getLength(); ++x )
    2001             :                     {
    2002           0 :                         xNodeAccess->getByName( xTemp[x] ) >>= xAccess;
    2003           0 :                         if ( xAccess.is() )
    2004             :                         {
    2005           0 :                             xAccess->getByName( "Index" ) >>= nIndex;
    2006           0 :                             if ( nIndex < 0 )
    2007             :                                 // append nodes with index < 0
    2008             :                                 pModule->m_aNodeList.push_back(
    2009           0 :                                     new OrderedEntry( nIndex, xTemp[x] ) );
    2010             :                             else
    2011             :                             {
    2012             :                                 // search position of the node
    2013           0 :                                 sal_uInt32 y = 0;
    2014           0 :                                 for ( ; y < pModule->m_aNodeList.size(); ++y )
    2015             :                                 {
    2016           0 :                                     sal_Int32 nNodeIdx = pModule->m_aNodeList[y]->m_nIndex;
    2017           0 :                                     if ( nNodeIdx < 0 || nNodeIdx > nIndex )
    2018             :                                         break;
    2019             :                                 }
    2020             :                                 // and insert the node on this position
    2021             :                                 pModule->m_aNodeList.insert(
    2022           0 :                                     pModule->m_aNodeList.begin() + y,
    2023           0 :                                     new OrderedEntry( nIndex, xTemp[x] ) );
    2024             :                             }
    2025             :                         }
    2026           0 :                     }
    2027           0 :                 }
    2028           0 :             }
    2029             :         }
    2030           0 :     }
    2031           0 :     return pModule;
    2032             : }
    2033             : 
    2034           0 : VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
    2035             :     Module* pModule, const OUString& rExtensionId)
    2036             : {
    2037           0 :     VectorOfNodes aOutNodeList;
    2038             : 
    2039             :     Reference< XNameAccess > xSet(
    2040           0 :         officecfg::Office::OptionsDialog::Nodes::get());
    2041           0 :     VectorOfNodes aNodeList;
    2042           0 :     Sequence< OUString > seqNames = xSet->getElementNames();
    2043             : 
    2044           0 :     for ( int i = 0; i < seqNames.getLength(); ++i )
    2045             :     {
    2046           0 :         String sGroupName( seqNames[i] );
    2047           0 :         Reference< XNameAccess > xNodeAccess;
    2048           0 :         xSet->getByName( seqNames[i] ) >>= xNodeAccess;
    2049             : 
    2050           0 :         if ( xNodeAccess.is() )
    2051             :         {
    2052           0 :             OUString sNodeId, sLabel, sPageURL, sGroupId;
    2053           0 :             bool bAllModules = false;
    2054           0 :             sal_Int32 nGroupIndex = 0;
    2055             : 
    2056           0 :             sNodeId = seqNames[i];
    2057           0 :             xNodeAccess->getByName( "Label" ) >>= sLabel;
    2058           0 :             xNodeAccess->getByName( "OptionsPage" ) >>= sPageURL;
    2059           0 :             xNodeAccess->getByName( "AllModules" ) >>= bAllModules;
    2060           0 :             xNodeAccess->getByName( "GroupId" ) >>= sGroupId;
    2061           0 :             xNodeAccess->getByName( "GroupIndex" ) >>= nGroupIndex;
    2062             : 
    2063           0 :             if ( sLabel.isEmpty() )
    2064           0 :                 sLabel = sGroupName;
    2065           0 :             String sTemp = getGroupName( sLabel, !rExtensionId.isEmpty() );
    2066           0 :             if ( sTemp.Len() > 0 )
    2067           0 :                 sLabel = sTemp;
    2068             :             OptionsNode* pNode =
    2069           0 :                 new OptionsNode( sNodeId, sLabel, sPageURL, bAllModules, sGroupId, nGroupIndex );
    2070             : 
    2071           0 :             if ( rExtensionId.isEmpty() && !isNodeActive( pNode, pModule ) )
    2072             :             {
    2073           0 :                 delete pNode;
    2074           0 :                 continue;
    2075             :             }
    2076             : 
    2077           0 :             Reference< XNameAccess > xLeavesSet;
    2078           0 :             xNodeAccess->getByName( "Leaves" ) >>= xLeavesSet;
    2079           0 :             if ( xLeavesSet.is() )
    2080             :             {
    2081           0 :                 Sequence< OUString > seqLeaves = xLeavesSet->getElementNames();
    2082           0 :                 for ( int j = 0; j < seqLeaves.getLength(); ++j )
    2083             :                 {
    2084           0 :                     Reference< XNameAccess > xLeaveAccess;
    2085           0 :                     xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess;
    2086             : 
    2087           0 :                     if ( xLeaveAccess.is() )
    2088             :                     {
    2089           0 :                         OUString sId, sLeafLabel, sEventHdl, sLeafURL, sLeafGrpId;
    2090           0 :                         sal_Int32 nLeafGrpIdx = 0;
    2091             : 
    2092           0 :                         xLeaveAccess->getByName( "Id" ) >>= sId;
    2093           0 :                         xLeaveAccess->getByName( "Label" ) >>= sLeafLabel;
    2094           0 :                         xLeaveAccess->getByName( "OptionsPage" ) >>= sLeafURL;
    2095           0 :                         xLeaveAccess->getByName( "EventHandlerService" ) >>= sEventHdl;
    2096           0 :                         xLeaveAccess->getByName( "GroupId" ) >>= sLeafGrpId;
    2097           0 :                         xLeaveAccess->getByName( "GroupIndex" ) >>= nLeafGrpIdx;
    2098             : 
    2099           0 :                         if ( rExtensionId.isEmpty() || sId == rExtensionId )
    2100             :                         {
    2101             :                             OptionsLeaf* pLeaf = new OptionsLeaf(
    2102           0 :                                 sId, sLeafLabel, sLeafURL, sEventHdl, sLeafGrpId, nLeafGrpIdx );
    2103             : 
    2104           0 :                             if ( !sLeafGrpId.isEmpty() )
    2105             :                             {
    2106           0 :                                 bool bAlreadyOpened = false;
    2107           0 :                                 if ( pNode->m_aGroupedLeaves.size() > 0 )
    2108             :                                 {
    2109           0 :                                     for ( sal_uInt32 k = 0;
    2110           0 :                                           k < pNode->m_aGroupedLeaves.size(); ++k )
    2111             :                                     {
    2112           0 :                                         if ( pNode->m_aGroupedLeaves[k].size() > 0 &&
    2113           0 :                                              pNode->m_aGroupedLeaves[k][0]->m_sGroupId
    2114           0 :                                              == sLeafGrpId )
    2115             :                                         {
    2116           0 :                                             sal_uInt32 l = 0;
    2117           0 :                                             for ( ; l < pNode->m_aGroupedLeaves[k].size(); ++l )
    2118             :                                             {
    2119           0 :                                                 if ( pNode->m_aGroupedLeaves[k][l]->
    2120           0 :                                                      m_nGroupIndex >= nLeafGrpIdx )
    2121           0 :                                                     break;
    2122             :                                             }
    2123           0 :                                             pNode->m_aGroupedLeaves[k].insert(
    2124           0 :                                                 pNode->m_aGroupedLeaves[k].begin() + l, pLeaf );
    2125           0 :                                             bAlreadyOpened = true;
    2126           0 :                                             break;
    2127             :                                         }
    2128             :                                     }
    2129             :                                 }
    2130           0 :                                 if ( !bAlreadyOpened )
    2131             :                                 {
    2132           0 :                                     VectorOfLeaves aGroupedLeaves;
    2133           0 :                                     aGroupedLeaves.push_back( pLeaf );
    2134           0 :                                     pNode->m_aGroupedLeaves.push_back( aGroupedLeaves );
    2135             :                                 }
    2136             :                             }
    2137             :                             else
    2138           0 :                                 pNode->m_aLeaves.push_back( pLeaf );
    2139           0 :                         }
    2140             :                     }
    2141           0 :                 }
    2142             :             }
    2143             : 
    2144             :             // do not insert nodes without leaves
    2145           0 :             if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
    2146             :             {
    2147           0 :                 pModule ? aNodeList.push_back( pNode ) : aOutNodeList.push_back( pNode );
    2148           0 :             }
    2149             :         }
    2150           0 :     }
    2151             : 
    2152           0 :     if ( pModule && aNodeList.size() > 0 )
    2153             :     {
    2154           0 :         sal_uInt32 i = 0, j = 0;
    2155           0 :         for ( ; i < pModule->m_aNodeList.size(); ++i )
    2156             :         {
    2157           0 :             OUString sNodeId = pModule->m_aNodeList[i]->m_sId;
    2158           0 :             for ( j = 0; j < aNodeList.size(); ++j )
    2159             :             {
    2160           0 :                 OptionsNode* pNode = aNodeList[j];
    2161           0 :                 if ( pNode->m_sId == sNodeId )
    2162             :                 {
    2163           0 :                     aOutNodeList.push_back( pNode );
    2164           0 :                     aNodeList.erase( aNodeList.begin() + j );
    2165           0 :                     break;
    2166             :                 }
    2167             :             }
    2168           0 :         }
    2169             : 
    2170           0 :         for ( i = 0; i < aNodeList.size(); ++i )
    2171           0 :             aOutNodeList.push_back( aNodeList[i] );
    2172             :     }
    2173           0 :     return aOutNodeList;
    2174             : }
    2175             : 
    2176           0 : static sal_uInt16 lcl_getGroupId( const OUString& rGroupName, const SvTreeListBox& rTreeLB )
    2177             : {
    2178           0 :     String sGroupName( rGroupName );
    2179           0 :     sal_uInt16 nRet = 0;
    2180           0 :     SvTreeListEntry* pEntry = rTreeLB.First();
    2181           0 :     while( pEntry )
    2182             :     {
    2183           0 :         if ( !rTreeLB.GetParent( pEntry ) )
    2184             :         {
    2185           0 :             String sTemp( rTreeLB.GetEntryText( pEntry ) );
    2186           0 :             if ( sTemp == sGroupName )
    2187           0 :                 return nRet;
    2188           0 :             nRet++;
    2189             :         }
    2190           0 :         pEntry = rTreeLB.Next( pEntry );
    2191             :     }
    2192             : 
    2193           0 :     return USHRT_MAX;
    2194             : }
    2195             : 
    2196           0 : static void lcl_insertLeaf(
    2197             :     OfaTreeOptionsDialog* pDlg, OptionsNode* pNode, OptionsLeaf* pLeaf, const SvTreeListBox& rTreeLB )
    2198             : {
    2199           0 :     sal_uInt16 nGrpId = lcl_getGroupId( pNode->m_sLabel, rTreeLB );
    2200           0 :     if ( USHRT_MAX == nGrpId )
    2201             :     {
    2202           0 :         sal_uInt16 nNodeGrpId = getGroupNodeId( pNode->m_sId );
    2203           0 :         nGrpId = pDlg->AddGroup( pNode->m_sLabel, NULL, NULL, nNodeGrpId );
    2204           0 :         if ( !pNode->m_sPageURL.isEmpty() )
    2205             :         {
    2206           0 :             SvTreeListEntry* pGrpEntry = rTreeLB.GetEntry( 0, nGrpId );
    2207             :             DBG_ASSERT( pGrpEntry, "OfaTreeOptionsDialog::InsertNodes(): no group" );
    2208           0 :             if ( pGrpEntry )
    2209             :             {
    2210             :                 OptionsGroupInfo* pGrpInfo =
    2211           0 :                     static_cast<OptionsGroupInfo*>(pGrpEntry->GetUserData());
    2212           0 :                 pGrpInfo->m_sPageURL = pNode->m_sPageURL;
    2213             :             }
    2214             :         }
    2215             :     }
    2216           0 :     OptionsPageInfo* pInfo = pDlg->AddTabPage( 0, pLeaf->m_sLabel, nGrpId );
    2217           0 :     pInfo->m_sPageURL = pLeaf->m_sPageURL;
    2218           0 :     pInfo->m_sEventHdl = pLeaf->m_sEventHdl;
    2219           0 : }
    2220             : 
    2221           0 : void  OfaTreeOptionsDialog::InsertNodes( const VectorOfNodes& rNodeList )
    2222             : {
    2223           0 :     for ( sal_uInt32 i = 0; i < rNodeList.size(); ++i )
    2224             :     {
    2225           0 :         OptionsNode* pNode = rNodeList[i];
    2226             : 
    2227           0 :         if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
    2228             :         {
    2229           0 :             sal_uInt32 j = 0;
    2230           0 :             for ( ; j < pNode->m_aGroupedLeaves.size(); ++j )
    2231             :             {
    2232           0 :                 for ( sal_uInt32 k = 0; k < pNode->m_aGroupedLeaves[j].size(); ++k )
    2233             :                 {
    2234           0 :                     OptionsLeaf* pLeaf = pNode->m_aGroupedLeaves[j][k];
    2235           0 :                     lcl_insertLeaf( this, pNode, pLeaf, aTreeLB );
    2236             :                 }
    2237             :             }
    2238             : 
    2239           0 :             for ( j = 0; j < pNode->m_aLeaves.size(); ++j )
    2240             :             {
    2241           0 :                 OptionsLeaf* pLeaf = pNode->m_aLeaves[j];
    2242           0 :                 lcl_insertLeaf( this, pNode, pLeaf, aTreeLB );
    2243             :             }
    2244             :         }
    2245             :     }
    2246           0 : }
    2247             : 
    2248           0 : short OfaTreeOptionsDialog::Execute()
    2249             : {
    2250           0 :     ::std::auto_ptr< SvxDicListChgClamp > pClamp;
    2251           0 :     if ( !bIsFromExtensionManager )
    2252             :     {
    2253             :         // collect all DictionaryList Events while the dialog is executed
    2254           0 :         Reference<com::sun::star::linguistic2::XSearchableDictionaryList> xDictionaryList(SvxGetDictionaryList());
    2255           0 :         pClamp = ::std::auto_ptr< SvxDicListChgClamp >( new SvxDicListChgClamp( xDictionaryList ) );
    2256             :     }
    2257           0 :     short nRet = SfxModalDialog::Execute();
    2258             : 
    2259           0 :     if( RET_OK == nRet )
    2260             :     {
    2261           0 :         ApplyItemSets();
    2262           0 :         if( mpColorPage )
    2263           0 :             mpColorPage->SaveToViewFrame( SfxViewFrame::Current() );
    2264           0 :         utl::ConfigManager::storeConfigItems();
    2265             :     }
    2266             : 
    2267           0 :     return nRet;
    2268             : }
    2269             : 
    2270             : // class ExtensionsTabPage -----------------------------------------------
    2271             : 
    2272           0 : ExtensionsTabPage::ExtensionsTabPage(
    2273             :     Window* pParent, WinBits nStyle, const OUString& rPageURL,
    2274             :     const OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) :
    2275             : 
    2276             :     TabPage( pParent, nStyle ),
    2277             : 
    2278             :     m_sPageURL          ( rPageURL ),
    2279             :     m_sEventHdl         ( rEvtHdl ),
    2280             :     m_xWinProvider      ( rProvider ),
    2281           0 :     m_bIsWindowHidden   ( false )
    2282             : 
    2283             : {
    2284           0 : }
    2285             : 
    2286             : // -----------------------------------------------------------------------
    2287             : 
    2288           0 : ExtensionsTabPage::~ExtensionsTabPage()
    2289             : {
    2290           0 :     Hide();
    2291           0 :     DeactivatePage();
    2292           0 : }
    2293             : 
    2294             : // -----------------------------------------------------------------------
    2295             : 
    2296           0 : void ExtensionsTabPage::CreateDialogWithHandler()
    2297             : {
    2298             :     try
    2299             :     {
    2300           0 :         bool bWithHandler = ( !m_sEventHdl.isEmpty() );
    2301           0 :         if ( bWithHandler )
    2302             :         {
    2303           0 :             Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
    2304           0 :             m_xEventHdl = Reference< awt::XContainerWindowEventHandler >(
    2305           0 :                 xFactory->createInstance( m_sEventHdl ), UNO_QUERY );
    2306             :         }
    2307             : 
    2308           0 :         if ( !bWithHandler || m_xEventHdl.is() )
    2309             :         {
    2310           0 :             SetStyle( GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
    2311           0 :             Reference< awt::XWindowPeer > xParent( VCLUnoHelper::GetInterface( this ), UNO_QUERY );
    2312           0 :             m_xPage = Reference < awt::XWindow >(
    2313           0 :                 m_xWinProvider->createContainerWindow(
    2314           0 :                     m_sPageURL, OUString(), xParent, m_xEventHdl ), UNO_QUERY );
    2315             : 
    2316           0 :             Reference< awt::XControl > xPageControl( m_xPage, UNO_QUERY );
    2317           0 :             if ( xPageControl.is() )
    2318             :             {
    2319           0 :                 Reference< awt::XWindowPeer > xWinPeer( xPageControl->getPeer() );
    2320           0 :                 if ( xWinPeer.is() )
    2321             :                 {
    2322           0 :                     Window* pWindow = VCLUnoHelper::GetWindow( xWinPeer );
    2323           0 :                     if ( pWindow )
    2324           0 :                         pWindow->SetStyle( pWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
    2325           0 :                 }
    2326           0 :             }
    2327             :         }
    2328             :     }
    2329           0 :     catch ( ::com::sun::star::lang::IllegalArgumentException& )
    2330             :     {
    2331             :         SAL_WARN( "cui.options", "ExtensionsTabPage::CreateDialogWithHandler(): illegal argument" );
    2332             :     }
    2333           0 :     catch ( Exception& )
    2334             :     {
    2335             :         SAL_WARN( "cui.options", "ExtensionsTabPage::CreateDialogWithHandler(): exception of XDialogProvider2::createDialogWithHandler()" );
    2336             :     }
    2337           0 : }
    2338             : 
    2339             : // -----------------------------------------------------------------------
    2340             : 
    2341           0 : sal_Bool ExtensionsTabPage::DispatchAction( const OUString& rAction )
    2342             : {
    2343           0 :     sal_Bool bRet = sal_False;
    2344           0 :     if ( m_xEventHdl.is() )
    2345             :     {
    2346             :         try
    2347             :         {
    2348           0 :             bRet = m_xEventHdl->callHandlerMethod( m_xPage, makeAny( rAction ), "external_event" );
    2349             :         }
    2350           0 :         catch ( Exception& )
    2351             :         {
    2352             :             SAL_WARN( "cui.options", "ExtensionsTabPage::DispatchAction(): exception of XDialogEventHandler::callHandlerMethod()" );
    2353             :         }
    2354             :     }
    2355           0 :     return bRet;
    2356             : }
    2357             : 
    2358             : // -----------------------------------------------------------------------
    2359             : 
    2360           0 : void ExtensionsTabPage::ActivatePage()
    2361             : {
    2362           0 :     TabPage::ActivatePage();
    2363             : 
    2364           0 :     if ( !m_xPage.is() )
    2365             :     {
    2366           0 :         CreateDialogWithHandler();
    2367             : 
    2368           0 :         if ( m_xPage.is() )
    2369             :         {
    2370           0 :             Point aPos = Point();
    2371           0 :             Size aSize = GetSizePixel();
    2372           0 :             m_xPage->setPosSize( aPos.X() + 1, aPos.Y() + 1,
    2373           0 :                                  aSize.Width() - 2, aSize.Height() - 2, awt::PosSize::POSSIZE );
    2374           0 :             if ( !m_sEventHdl.isEmpty() )
    2375           0 :                 DispatchAction( "initialize" );
    2376             :         }
    2377             :     }
    2378             : 
    2379           0 :     if ( m_xPage.is() )
    2380             :     {
    2381           0 :         m_xPage->setVisible( sal_True );
    2382           0 :         m_bIsWindowHidden = false;
    2383             :     }
    2384           0 : }
    2385             : 
    2386             : // -----------------------------------------------------------------------
    2387             : 
    2388           0 : void ExtensionsTabPage::DeactivatePage()
    2389             : {
    2390           0 :     TabPage::DeactivatePage();
    2391             : 
    2392           0 :     if ( m_xPage.is() )
    2393           0 :         m_xPage->setVisible( sal_False );
    2394           0 : }
    2395             : 
    2396             : // -----------------------------------------------------------------------
    2397             : 
    2398           0 : void ExtensionsTabPage::ResetPage()
    2399             : {
    2400           0 :     DispatchAction( "back" );
    2401           0 :     ActivatePage();
    2402           0 : }
    2403             : 
    2404             : // -----------------------------------------------------------------------
    2405             : 
    2406           0 : void ExtensionsTabPage::SavePage()
    2407             : {
    2408           0 :     DispatchAction( "ok" );
    2409           0 : }
    2410             : 
    2411             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10