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

Generated by: LCOV version 1.10