1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_cui.hxx" 26 #include <com/sun/star/beans/XPropertySet.hpp> 27 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 28 #include <com/sun/star/loader/CannotActivateFactoryException.hpp> 29 #include <com/sun/star/linguistic2/XDictionaryList.hpp> 30 #include <com/sun/star/frame/XDesktop.hpp> 31 #include <com/sun/star/frame/XFrame.hpp> 32 #include <com/sun/star/frame/XModuleManager.hpp> 33 #include <com/sun/star/util/XMacroExpander.hpp> 34 #include <osl/module.hxx> 35 #include <com/sun/star/util/XCloseable.hpp> 36 #include <com/sun/star/frame/XLoadable.hpp> 37 #include <tools/rcid.h> 38 #include <tools/shl.hxx> 39 #include <tools/urlobj.hxx> 40 #include <comphelper/processfactory.hxx> 41 #include <toolkit/helper/vclunohelper.hxx> 42 #include <com/sun/star/beans/PropertyValue.hpp> 43 #include <com/sun/star/container/XNameContainer.hpp> 44 #include <com/sun/star/container/XNameAccess.hpp> 45 #include <com/sun/star/oooimprovement/XCoreController.hpp> 46 #include <comphelper/configurationhelper.hxx> 47 #include <com/sun/star/awt/XDialogProvider.hpp> 48 #include <com/sun/star/awt/XDialogProvider2.hpp> 49 #include <com/sun/star/awt/XContainerWindowProvider.hpp> 50 #include <com/sun/star/awt/XDialogEventHandler.hpp> 51 #include <com/sun/star/awt/XContainerWindowEventHandler.hpp> 52 #include <com/sun/star/awt/PosSize.hpp> 53 #include <com/sun/star/awt/XTopWindow.hpp> 54 #include <com/sun/star/awt/XControl.hpp> 55 #include <com/sun/star/awt/XTabController.hpp> 56 #include <vcl/help.hxx> 57 #include <linguistic/misc.hxx> 58 #include <svtools/helpopt.hxx> 59 #include <unotools/moduleoptions.hxx> 60 #include <svl/languageoptions.hxx> 61 #include <unotools/optionsdlg.hxx> 62 #include <sfx2/module.hxx> 63 #include <vcl/msgbox.hxx> 64 #include <sfx2/dispatch.hxx> 65 #include <vcl/waitobj.hxx> 66 #include <svl/slstitm.hxx> 67 #include <sfx2/viewfrm.hxx> 68 #include <unotools/viewoptions.hxx> 69 #include <sfx2/printopt.hxx> 70 #include <osl/module.h> 71 #include <osl/process.h> 72 #include <rtl/bootstrap.hxx> 73 #include <unotools/misccfg.hxx> 74 #include <sfx2/objsh.hxx> 75 #include <sfx2/viewsh.hxx> 76 #include <sfx2/tplpitem.hxx> 77 #include <svtools/apearcfg.hxx> 78 #include <unotools/linguprops.hxx> 79 #include <sfx2/app.hxx> 80 #include <svx/xdef.hxx> 81 #include <svx/xflclit.hxx> 82 #include <svx/xpool.hxx> 83 #include "cuitabarea.hxx" 84 #include <svx/ofaitem.hxx> 85 #include "opthtml.hxx" 86 #include "optcolor.hxx" 87 #include "optctl.hxx" 88 #include "optjava.hxx" 89 #include "optsave.hxx" 90 #include "optpath.hxx" 91 #include "cuioptgenrl.hxx" 92 #include "optlingu.hxx" 93 #include "optinet2.hxx" 94 #include "optasian.hxx" 95 #include "optaccessibility.hxx" 96 #include "optjsearch.hxx" 97 #include "connpooloptions.hxx" 98 #include "optupdt.hxx" 99 #include <optimprove.hxx> 100 #include "optchart.hxx" 101 #include "optgdlg.hxx" 102 #include "optmemory.hxx" 103 #include "optfltr.hxx" 104 #include <cuires.hrc> 105 #include "helpid.hrc" 106 #include <dialmgr.hxx> 107 #include "treeopt.hxx" 108 #include "treeopt.hrc" 109 #include "fontsubs.hxx" 110 #include <editeng/unolingu.hxx> 111 #include <svx/xtable.hxx> 112 #include "connpoolconfig.hxx" 113 #include "dbregister.hxx" 114 #include "dbregisterednamesconfig.hxx" 115 #include "cfgchart.hxx" 116 #include <svx/dialogs.hrc> 117 118 #ifndef _SVX_LANGITEM_HXX 119 #define ITEMID_LANGUAGE SID_ATTR_CHAR_LANGUAGE 120 #include <editeng/langitem.hxx> 121 #endif 122 123 124 #include <editeng/optitems.hxx> 125 126 #include <svx/drawitem.hxx> 127 #include <rtl/uri.hxx> 128 129 #ifdef LINUX 130 #include <string.h> 131 #include <sys/types.h> 132 #include <sys/stat.h> 133 #include <unistd.h> 134 #endif 135 136 using namespace ::com::sun::star; 137 using namespace ::com::sun::star::beans; 138 using namespace ::com::sun::star::container; 139 using namespace ::com::sun::star::frame; 140 using namespace ::com::sun::star::lang; 141 using namespace ::com::sun::star::linguistic2; 142 using namespace ::com::sun::star::uno; 143 using namespace ::com::sun::star::util; 144 145 #ifdef C2U 146 #error "Who define C2U before! I use it to create const ascii strings ..." 147 #else 148 #define C2U(cChar) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( cChar ) ) 149 #endif 150 151 #define HINT_TIMEOUT 200 152 #define SELECT_FIRST_TIMEOUT 0 153 #define SELECT_TIMEOUT 300 154 #define COLORPAGE_UNKNOWN ((sal_uInt16)0xFFFF) 155 #define EXPAND_PROTOCOL "vnd.sun.star.expand:" 156 157 LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL; 158 159 // some stuff for easier changes for SvtViewOptions 160 static const sal_Char* pViewOptDataName = "page data"; 161 #define VIEWOPT_DATANAME rtl::OUString::createFromAscii( pViewOptDataName ) 162 163 static XOutdevItemPool* mpStaticXOutdevItemPool = 0L; 164 165 static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const String& rData ) 166 { 167 rOpt.SetUserItem( VIEWOPT_DATANAME, makeAny( rtl::OUString( rData ) ) ); 168 } 169 170 static inline String GetViewOptUserItem( const SvtViewOptions& rOpt ) 171 { 172 Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) ); 173 rtl::OUString aUserData; 174 aAny >>= aUserData; 175 176 return String( aUserData ); 177 } 178 179 struct ModuleToGroupNameMap_Impl 180 { 181 const char* m_pModule; 182 String m_sGroupName; 183 sal_uInt16 m_nNodeId; 184 }; 185 186 static OfaPageResource* pPageRes = NULL; 187 188 static ModuleToGroupNameMap_Impl ModuleMap[] = 189 { 190 { "ProductName", String::EmptyString(), SID_GENERAL_OPTIONS }, 191 { "LanguageSettings", String::EmptyString(), SID_LANGUAGE_OPTIONS }, 192 { "Internet", String::EmptyString(), SID_INET_DLG }, 193 { "LoadSave", String::EmptyString(), SID_FILTER_DLG }, 194 { "Writer", String::EmptyString(), SID_SW_EDITOPTIONS }, 195 { "WriterWeb", String::EmptyString(), SID_SW_ONLINEOPTIONS }, 196 { "Math", String::EmptyString(), SID_SM_EDITOPTIONS }, 197 { "Calc", String::EmptyString(), SID_SC_EDITOPTIONS }, 198 { "Impress", String::EmptyString(), SID_SD_EDITOPTIONS }, 199 { "Draw", String::EmptyString(), SID_SD_GRAPHIC_OPTIONS }, 200 { "Charts", String::EmptyString(), SID_SCH_EDITOPTIONS }, 201 { "Base", String::EmptyString(), SID_SB_STARBASEOPTIONS }, 202 203 { NULL, String::EmptyString(), 0xFFFF } 204 }; 205 206 static void setGroupName( const rtl::OUString& rModule, const String& rGroupName ) 207 { 208 sal_uInt16 nIndex = 0; 209 while ( ModuleMap[ nIndex ].m_pModule ) 210 { 211 rtl::OUString sTemp = 212 rtl::OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule ); 213 if ( sTemp == rModule ) 214 { 215 ModuleMap[ nIndex ].m_sGroupName = rGroupName; 216 break; 217 } 218 ++nIndex; 219 } 220 } 221 222 static String getGroupName( const rtl::OUString& rModule, bool bForced ) 223 { 224 String sGroupName; 225 sal_uInt16 nIndex = 0; 226 while ( ModuleMap[ nIndex ].m_pModule ) 227 { 228 rtl::OUString sTemp = 229 rtl::OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule ); 230 if ( sTemp == rModule ) 231 { 232 sGroupName = ModuleMap[ nIndex ].m_sGroupName; 233 break; 234 } 235 ++nIndex; 236 } 237 238 if ( sGroupName.Len() == 0 && bForced ) 239 { 240 if ( !pPageRes ) 241 pPageRes = new OfaPageResource; 242 243 if ( rModule == C2U("Writer") ) 244 sGroupName = pPageRes->GetTextArray().GetString(0); 245 else if ( rModule == C2U("WriterWeb") ) 246 sGroupName = pPageRes->GetHTMLArray().GetString(0); 247 else if ( rModule == C2U("Calc") ) 248 sGroupName = pPageRes->GetCalcArray().GetString(0); 249 else if ( rModule == C2U("Impress") ) 250 sGroupName = pPageRes->GetImpressArray().GetString(0); 251 else if ( rModule == C2U("Draw") ) 252 sGroupName = pPageRes->GetDrawArray().GetString(0); 253 else if ( rModule == C2U("Math") ) 254 sGroupName = pPageRes->GetStarMathArray().GetString(0); 255 else if ( rModule == C2U("Base") ) 256 sGroupName = pPageRes->GetDatasourcesArray().GetString(0); 257 } 258 return sGroupName; 259 } 260 261 static void deleteGroupNames() 262 { 263 sal_uInt16 nIndex = 0; 264 while ( ModuleMap[ nIndex ].m_pModule ) 265 ModuleMap[ nIndex++ ].m_sGroupName = String::EmptyString(); 266 } 267 268 static sal_uInt16 getGroupNodeId( const rtl::OUString& rModule ) 269 { 270 sal_uInt16 nNodeId = 0xFFFF, nIndex = 0; 271 while ( ModuleMap[ nIndex ].m_pModule ) 272 { 273 rtl::OUString sTemp = 274 rtl::OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule ); 275 if ( sTemp == rModule ) 276 { 277 nNodeId = ModuleMap[ nIndex ].m_nNodeId; 278 break; 279 } 280 ++nIndex; 281 } 282 283 return nNodeId; 284 } 285 286 /*-- 29.10.2004 13:57:25--------------------------------------------------- 287 288 -----------------------------------------------------------------------*/ 289 class MailMergeCfg_Impl : public utl::ConfigItem 290 { 291 friend class SvxEMailTabPage; 292 // variables 293 sal_Bool bIsEmailSupported; 294 295 public: 296 MailMergeCfg_Impl(); 297 virtual ~MailMergeCfg_Impl(); 298 299 virtual void Commit(); 300 virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames); 301 302 sal_Bool IsEmailSupported() const {return bIsEmailSupported;} 303 304 }; 305 /*-- 29.10.2004 13:57:25--------------------------------------------------- 306 307 -----------------------------------------------------------------------*/ 308 MailMergeCfg_Impl::MailMergeCfg_Impl() : 309 utl::ConfigItem(C2U("Office.Writer/MailMergeWizard")), 310 bIsEmailSupported(sal_False) 311 { 312 Sequence<rtl::OUString> aNames(1); 313 aNames.getArray()[0] = C2U("EMailSupported"); 314 const Sequence< Any > aValues = GetProperties(aNames); 315 const Any* pValues = aValues.getConstArray(); 316 if(aValues.getLength() && pValues[0].hasValue()) 317 pValues[0] >>= bIsEmailSupported; 318 } 319 /*-- 29.10.2004 13:57:25--------------------------------------------------- 320 321 -----------------------------------------------------------------------*/ 322 MailMergeCfg_Impl::~MailMergeCfg_Impl() 323 { 324 } 325 /* -------------------------------------------------------------------------*/ 326 void MailMergeCfg_Impl::Commit() 327 { 328 } 329 330 void MailMergeCfg_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& ) 331 { 332 } 333 334 //typedef SfxTabPage* (*FNCreateTabPage)( Window *pParent, const SfxItemSet &rAttrSet ); 335 SfxTabPage* CreateGeneralTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet ) 336 { 337 CreateTabPage fnCreate = 0; 338 switch(nId) 339 { 340 case RID_SFXPAGE_SAVE: fnCreate = &SvxSaveTabPage::Create; break; 341 case RID_SFXPAGE_PATH: fnCreate = &SvxPathTabPage::Create; break; 342 case RID_SFXPAGE_GENERAL: fnCreate = &SvxGeneralTabPage::Create; break; 343 case RID_SFXPAGE_PRINTOPTIONS: fnCreate = &SfxCommonPrintOptionsTabPage::Create; break; 344 case OFA_TP_LANGUAGES: fnCreate = &OfaLanguagesTabPage::Create; break; 345 case RID_SFXPAGE_LINGU: fnCreate = &SvxLinguTabPage::Create; break; 346 case RID_SVXPAGE_COLOR: fnCreate = &SvxColorTabPage::Create; break; 347 case OFA_TP_VIEW: fnCreate = &OfaViewTabPage::Create; break; 348 case OFA_TP_MISC: fnCreate = &OfaMiscTabPage::Create; break; 349 case OFA_TP_MEMORY: fnCreate = &OfaMemoryOptionsPage::Create; break; 350 case RID_SVXPAGE_ASIAN_LAYOUT: fnCreate = &SvxAsianLayoutPage::Create; break; 351 case RID_SVX_FONT_SUBSTITUTION: fnCreate = &SvxFontSubstTabPage::Create; break; 352 case RID_SVXPAGE_INET_PROXY: fnCreate = &SvxProxyTabPage::Create; break; 353 case RID_SVXPAGE_INET_SEARCH: fnCreate = &SvxSearchTabPage::Create; break; 354 case RID_SVXPAGE_INET_SECURITY: fnCreate = &SvxSecurityTabPage::Create; break; 355 case RID_SVXPAGE_INET_MAIL: fnCreate = &SvxEMailTabPage::Create; break; 356 case RID_SVXPAGE_COLORCONFIG: fnCreate = &SvxColorOptionsTabPage::Create; break; 357 case RID_OFAPAGE_HTMLOPT: fnCreate = &OfaHtmlTabPage::Create; break; 358 case SID_OPTFILTER_MSOFFICE: fnCreate = &OfaMSFilterTabPage::Create; break; 359 case RID_OFAPAGE_MSFILTEROPT2: fnCreate = &OfaMSFilterTabPage2::Create; break; 360 case RID_SVXPAGE_JSEARCH_OPTIONS: fnCreate = &SvxJSearchOptionsPage::Create ; break; 361 case SID_SB_CONNECTIONPOOLING: fnCreate = &::offapp::ConnectionPoolOptionsPage::Create; break; 362 case SID_SB_DBREGISTEROPTIONS: fnCreate = &::svx::DbRegistrationOptionsPage::Create; break; 363 case RID_SVXPAGE_ACCESSIBILITYCONFIG: fnCreate = &SvxAccessibilityOptionsTabPage::Create; break; 364 case RID_SVXPAGE_SSO: fnCreate = GetSSOCreator(); break; 365 case RID_SVXPAGE_OPTIONS_CTL: fnCreate = &SvxCTLOptionsPage::Create ; break; 366 //added by jmeng begin 367 case RID_SVXPAGE_INET_MOZPLUGIN: fnCreate = &MozPluginTabPage::Create; break; 368 //added by jmeng end 369 case RID_SVXPAGE_OPTIONS_JAVA: fnCreate = &SvxJavaOptionsPage::Create ; break; 370 case RID_SVXPAGE_ONLINEUPDATE: fnCreate = &SvxOnlineUpdateTabPage::Create; break; 371 case RID_OPTPAGE_CHART_DEFCOLORS: fnCreate = &SvxDefaultColorOptPage::Create; break; 372 case RID_SVXPAGE_IMPROVEMENT: fnCreate = &SvxImprovementOptionsPage::Create; break; 373 } 374 375 SfxTabPage* pRet = fnCreate ? (*fnCreate)( pParent, rSet ) : NULL; 376 return pRet; 377 } 378 379 380 struct OptionsMapping_Impl 381 { 382 const char* m_pGroupName; 383 const char* m_pPageName; 384 sal_uInt16 m_nPageId; 385 }; 386 387 static OptionsMapping_Impl __READONLY_DATA OptionsMap_Impl[] = 388 { 389 // GROUP PAGE PAGE-ID 390 { "ProductName", NULL, SID_GENERAL_OPTIONS }, 391 { "ProductName", "UserData", RID_SFXPAGE_GENERAL }, 392 { "ProductName", "General", OFA_TP_MISC }, 393 { "ProductName", "Memory", OFA_TP_MEMORY }, 394 { "ProductName", "View", OFA_TP_VIEW }, 395 { "ProductName", "Print", RID_SFXPAGE_PRINTOPTIONS }, 396 { "ProductName", "Paths", RID_SFXPAGE_PATH }, 397 { "ProductName", "Colors", RID_SVXPAGE_COLOR }, 398 { "ProductName", "Fonts", RID_SVX_FONT_SUBSTITUTION }, 399 { "ProductName", "Security", RID_SVXPAGE_INET_SECURITY }, 400 { "ProductName", "Appearance", RID_SVXPAGE_COLORCONFIG }, 401 { "ProductName", "Accessibility", RID_SVXPAGE_ACCESSIBILITYCONFIG }, 402 { "ProductName", "Java", RID_SVXPAGE_OPTIONS_JAVA }, 403 { "ProductName", "NetworkIdentity", RID_SVXPAGE_SSO }, 404 { "ProductName", "OnlineUpdate", RID_SVXPAGE_ONLINEUPDATE }, 405 { "ProductName", "ImprovementProgram", RID_SVXPAGE_IMPROVEMENT }, 406 { "LanguageSettings", NULL, SID_LANGUAGE_OPTIONS }, 407 { "LanguageSettings", "Languages", OFA_TP_LANGUAGES }, 408 { "LanguageSettings", "WritingAids", RID_SFXPAGE_LINGU }, 409 { "LanguageSettings", "SearchingInJapanese", RID_SVXPAGE_JSEARCH_OPTIONS }, 410 { "LanguageSettings", "AsianLayout", RID_SVXPAGE_ASIAN_LAYOUT }, 411 { "LanguageSettings", "ComplexTextLayout", RID_SVXPAGE_OPTIONS_CTL }, 412 { "Internet", NULL, SID_INET_DLG }, 413 { "Internet", "Proxy", RID_SVXPAGE_INET_PROXY }, 414 { "Internet", "Search", RID_SVXPAGE_INET_SEARCH }, 415 { "Internet", "Email", RID_SVXPAGE_INET_MAIL }, 416 { "Internet", "MozillaPlugin", RID_SVXPAGE_INET_MOZPLUGIN }, 417 { "LoadSave", NULL, SID_FILTER_DLG }, 418 { "LoadSave", "General", RID_SFXPAGE_SAVE }, 419 { "LoadSave", "VBAProperties", SID_OPTFILTER_MSOFFICE }, 420 { "LoadSave", "MicrosoftOffice", RID_OFAPAGE_MSFILTEROPT2 }, 421 { "LoadSave", "HTMLCompatibility", RID_OFAPAGE_HTMLOPT }, 422 { "Writer", NULL, SID_SW_EDITOPTIONS }, 423 { "Writer", "General", RID_SW_TP_OPTLOAD_PAGE }, 424 { "Writer", "View", RID_SW_TP_CONTENT_OPT }, 425 { "Writer", "FormattingAids", RID_SW_TP_OPTSHDWCRSR }, 426 { "Writer", "Grid", RID_SVXPAGE_GRID }, 427 { "Writer", "BasicFontsWestern", RID_SW_TP_STD_FONT }, 428 { "Writer", "BasicFontsAsian", RID_SW_TP_STD_FONT_CJK }, 429 { "Writer", "BasicFontsCTL", RID_SW_TP_STD_FONT_CTL }, 430 { "Writer", "Print", RID_SW_TP_OPTPRINT_PAGE }, 431 { "Writer", "Table", RID_SW_TP_OPTTABLE_PAGE }, 432 { "Writer", "Changes", RID_SW_TP_REDLINE_OPT }, 433 { "Writer", "Compatibility", RID_SW_TP_OPTCOMPATIBILITY_PAGE }, 434 { "Writer", "AutoCaption", RID_SW_TP_OPTCAPTION_PAGE }, 435 { "Writer", "MailMerge", RID_SW_TP_MAILCONFIG }, 436 { "WriterWeb", NULL, SID_SW_ONLINEOPTIONS }, 437 { "WriterWeb", "View", RID_SW_TP_HTML_CONTENT_OPT }, 438 { "WriterWeb", "FormattingAids", RID_SW_TP_HTML_OPTSHDWCRSR }, 439 { "WriterWeb", "Grid", RID_SW_TP_HTML_OPTGRID_PAGE }, 440 { "WriterWeb", "Print", RID_SW_TP_HTML_OPTPRINT_PAGE }, 441 { "WriterWeb", "Table", RID_SW_TP_HTML_OPTTABLE_PAGE }, 442 { "WriterWeb", "Background", RID_SW_TP_BACKGROUND }, 443 { "Math", NULL, SID_SM_EDITOPTIONS }, 444 { "Math", "Settings", SID_SM_TP_PRINTOPTIONS }, 445 { "Calc", NULL, SID_SC_EDITOPTIONS }, 446 { "Calc", "General", SID_SC_TP_LAYOUT }, 447 { "Calc", "View", SID_SC_TP_CONTENT }, 448 { "Calc", "International", RID_OFA_TP_INTERNATIONAL }, 449 { "Calc", "Calculate", SID_SC_TP_CALC }, 450 { "Calc", "SortLists", SID_SC_TP_USERLISTS }, 451 { "Calc", "Changes", SID_SC_TP_CHANGES }, 452 { "Calc", "Grid", SID_SC_TP_GRID }, 453 { "Calc", "Print", RID_SC_TP_PRINT }, 454 { "Impress", NULL, SID_SD_EDITOPTIONS }, 455 { "Impress", "General", SID_SI_TP_MISC }, 456 { "Impress", "View", SID_SI_TP_CONTENTS }, 457 { "Impress", "Grid", SID_SI_TP_SNAP }, 458 { "Impress", "Print", SID_SI_TP_PRINT }, 459 { "Draw", NULL, SID_SD_GRAPHIC_OPTIONS }, 460 { "Draw", "General", SID_SD_TP_MISC }, 461 { "Draw", "View", SID_SD_TP_CONTENTS }, 462 { "Draw", "Grid", SID_SD_TP_SNAP }, 463 { "Draw", "Print", SID_SD_TP_PRINT }, 464 { "Charts", NULL, SID_SCH_EDITOPTIONS }, 465 { "Charts", "DefaultColors", RID_OPTPAGE_CHART_DEFCOLORS }, 466 { "Base", NULL, SID_SB_STARBASEOPTIONS }, 467 { "Base", "Connections", SID_SB_CONNECTIONPOOLING }, 468 { "Base", "Databases", SID_SB_DBREGISTEROPTIONS }, 469 { NULL, NULL, 0 } 470 }; 471 472 static sal_Bool lcl_getStringFromID( sal_uInt16 _nPageId, String& _rGroupName, String& _rPageName ) 473 { 474 sal_Bool bRet = sal_False; 475 476 sal_uInt16 nIdx = 0; 477 while ( OptionsMap_Impl[nIdx].m_pGroupName != NULL ) 478 { 479 if ( _nPageId == OptionsMap_Impl[nIdx].m_nPageId ) 480 { 481 bRet = sal_True; 482 _rGroupName = String( OptionsMap_Impl[nIdx].m_pGroupName, RTL_TEXTENCODING_ASCII_US ); 483 if ( OptionsMap_Impl[nIdx].m_pPageName != NULL ) 484 _rPageName = String( OptionsMap_Impl[nIdx].m_pPageName, RTL_TEXTENCODING_ASCII_US ); 485 break; 486 } 487 ++nIdx; 488 } 489 490 return bRet; 491 } 492 493 static sal_Bool lcl_isOptionHidden( sal_uInt16 _nPageId, const SvtOptionsDialogOptions& _rOptOptions ) 494 { 495 sal_Bool bIsHidden = sal_False; 496 String sGroupName, sPageName; 497 if ( lcl_getStringFromID( _nPageId, sGroupName, sPageName ) ) 498 { 499 if ( sPageName.Len() == 0 ) 500 bIsHidden = _rOptOptions.IsGroupHidden( sGroupName ); 501 else 502 bIsHidden = _rOptOptions.IsPageHidden( sPageName, sGroupName ); 503 } 504 return bIsHidden; 505 } 506 507 /* -----------------11.02.99 09:56------------------- 508 * 509 * --------------------------------------------------*/ 510 struct OptionsPageInfo 511 { 512 SfxTabPage* m_pPage; 513 sal_uInt16 m_nPageId; 514 rtl::OUString m_sPageURL; 515 rtl::OUString m_sEventHdl; 516 ExtensionsTabPage* m_pExtPage; 517 518 OptionsPageInfo( sal_uInt16 nId ) : m_pPage( NULL ), m_nPageId( nId ), m_pExtPage( NULL ) {} 519 }; 520 521 struct OptionsGroupInfo 522 { 523 SfxItemSet* m_pInItemSet; 524 SfxItemSet* m_pOutItemSet; 525 SfxShell* m_pShell; // used to create the page 526 SfxModule* m_pModule; // used to create the ItemSet 527 sal_uInt16 m_nDialogId; // Id of the former dialog 528 sal_Bool m_bLoadError; // load fails? 529 rtl::OUString m_sPageURL; 530 ExtensionsTabPage* m_pExtPage; 531 532 OptionsGroupInfo( SfxShell* pSh, SfxModule* pMod, sal_uInt16 nId ) : 533 m_pInItemSet( NULL ), m_pOutItemSet( NULL ), m_pShell( pSh ), 534 m_pModule( pMod ), m_nDialogId( nId ), m_bLoadError( sal_False ), 535 m_sPageURL( rtl::OUString() ), m_pExtPage( NULL ) {} 536 ~OptionsGroupInfo() { delete m_pInItemSet; delete m_pOutItemSet; } 537 }; 538 539 /* -----------------04.05.99 15:51------------------- 540 * 541 * --------------------------------------------------*/ 542 sal_Bool OfaOptionsTreeListBox::Collapse( SvLBoxEntry* pParent ) 543 { 544 bInCollapse = sal_True; 545 sal_Bool bRet = SvTreeListBox::Collapse(pParent); 546 bInCollapse = sal_False; 547 return bRet; 548 } 549 550 // ----------------------------------------------------------------------- 551 552 #define INI_LIST() \ 553 aOkPB ( this, CUI_RES( PB_OK ) ),\ 554 aCancelPB ( this, CUI_RES( PB_CANCEL ) ),\ 555 aHelpPB ( this, CUI_RES( PB_HELP ) ),\ 556 aBackPB ( this, CUI_RES( PB_BACK ) ),\ 557 aHiddenGB ( this, CUI_RES( FB_BORDER ) ),\ 558 aPageTitleFT ( this, CUI_RES( FT_PAGE_TITLE ) ),\ 559 aLine1FL ( this, CUI_RES( FL_LINE_1 ) ),\ 560 aHelpFT ( this, CUI_RES( FT_HELPTEXT ) ),\ 561 aHelpImg ( this, CUI_RES( IMG_HELP ) ),\ 562 aHelpTextsArr ( CUI_RES( STR_HELPTEXTS ) ),\ 563 aTreeLB ( this, CUI_RES( TLB_PAGES ) ),\ 564 sTitle ( GetText() ),\ 565 sNotLoadedError ( CUI_RES( ST_LOAD_ERROR ) ),\ 566 pCurrentPageEntry ( NULL ),\ 567 pColorPageItemSet ( NULL ),\ 568 pColorTab ( NULL ),\ 569 nChangeType ( CT_NONE ),\ 570 nUnknownType ( COLORPAGE_UNKNOWN ),\ 571 nUnknownPos ( COLORPAGE_UNKNOWN ),\ 572 bIsAreaTP ( sal_False ),\ 573 bForgetSelection ( sal_False ),\ 574 bImageResized ( sal_False ),\ 575 bInSelectHdl_Impl ( false ),\ 576 bIsFromExtensionManager( false ), \ 577 bIsForSetDocumentLanguage( false ) 578 579 // Ctor() with Frame ----------------------------------------------------- 580 using namespace ::com::sun::star; 581 OfaTreeOptionsDialog::OfaTreeOptionsDialog( 582 Window* pParent, 583 const Reference< XFrame >& _xFrame, 584 bool bActivateLastSelection ) : 585 586 SfxModalDialog( pParent, CUI_RES( RID_OFADLG_OPTIONS_TREE ) ), 587 INI_LIST() 588 { 589 FreeResource(); 590 591 InitTreeAndHandler(); 592 Initialize( _xFrame ); 593 LoadExtensionOptions( rtl::OUString() ); 594 ResizeTreeLB(); 595 if (bActivateLastSelection) 596 ActivateLastSelection(); 597 598 aTreeLB.SetAccessibleName(GetDisplayText()); 599 } 600 601 // Ctor() with ExtensionId ----------------------------------------------- 602 603 OfaTreeOptionsDialog::OfaTreeOptionsDialog( Window* pParent, const rtl::OUString& rExtensionId ) : 604 605 SfxModalDialog( pParent, CUI_RES( RID_OFADLG_OPTIONS_TREE ) ), 606 607 INI_LIST() 608 609 { 610 FreeResource(); 611 612 bIsFromExtensionManager = ( rExtensionId.getLength() > 0 ); 613 InitTreeAndHandler(); 614 LoadExtensionOptions( rExtensionId ); 615 ResizeTreeLB(); 616 ActivateLastSelection(); 617 } 618 619 /* -----------------11.02.99 07:58------------------- 620 * 621 * --------------------------------------------------*/ 622 623 OfaTreeOptionsDialog::~OfaTreeOptionsDialog() 624 { 625 SvLBoxEntry* pEntry = aTreeLB.First(); 626 // first children 627 while(pEntry) 628 { 629 // if Child (has parent), then OptionsPageInfo 630 if(aTreeLB.GetParent(pEntry)) 631 { 632 OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData(); 633 if(pPageInfo->m_pPage) 634 { 635 pPageInfo->m_pPage->FillUserData(); 636 String aPageData(pPageInfo->m_pPage->GetUserData()); 637 if ( aPageData.Len() ) 638 { 639 SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pPageInfo->m_nPageId ) ); 640 SetViewOptUserItem( aTabPageOpt, aPageData ); 641 } 642 delete pPageInfo->m_pPage; 643 } 644 645 if (pPageInfo->m_nPageId == RID_SFXPAGE_LINGU) 646 { 647 // write personal dictionaries 648 Reference< XDictionaryList > xDicList( SvxGetDictionaryList() ); 649 if (xDicList.is()) 650 { 651 linguistic::SaveDictionaries( xDicList ); 652 } 653 } 654 655 if( pPageInfo->m_pExtPage ) 656 delete pPageInfo->m_pExtPage; 657 658 delete pPageInfo; 659 } 660 pEntry = aTreeLB.Next(pEntry); 661 } 662 663 // and parents 664 pEntry = aTreeLB.First(); 665 while(pEntry) 666 { 667 if(!aTreeLB.GetParent(pEntry)) 668 { 669 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pEntry->GetUserData(); 670 if ( pGroupInfo && pGroupInfo->m_pExtPage ) 671 delete pGroupInfo->m_pExtPage; 672 delete pGroupInfo; 673 } 674 pEntry = aTreeLB.Next(pEntry); 675 } 676 delete pColorPageItemSet; 677 deleteGroupNames(); 678 } 679 680 /* -----------------11.02.99 08:21------------------- 681 * 682 * --------------------------------------------------*/ 683 OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage( 684 sal_uInt16 nId, const String& rPageName, sal_uInt16 nGroup ) 685 { 686 OptionsPageInfo* pPageInfo = new OptionsPageInfo( nId ); 687 SvLBoxEntry* pParent = aTreeLB.GetEntry( 0, nGroup ); 688 DBG_ASSERT( pParent, "OfaTreeOptionsDialog::AddTabPage(): no group found" ); 689 SvLBoxEntry* pEntry = aTreeLB.InsertEntry( rPageName, pParent ); 690 pEntry->SetUserData( pPageInfo ); 691 return pPageInfo; 692 } 693 694 /* -----------------11.02.99 10:02------------------- 695 * der ItemSet* geht in den Besitz des Dialogs 696 * --------------------------------------------------*/ 697 sal_uInt16 OfaTreeOptionsDialog::AddGroup(const String& rGroupName, 698 SfxShell* pCreateShell, 699 SfxModule* pCreateModule, 700 sal_uInt16 nDialogId ) 701 { 702 SvLBoxEntry* pEntry = aTreeLB.InsertEntry(rGroupName); 703 OptionsGroupInfo* pInfo = 704 new OptionsGroupInfo( pCreateShell, pCreateModule, nDialogId ); 705 pEntry->SetUserData(pInfo); 706 sal_uInt16 nRet = 0; 707 pEntry = aTreeLB.First(); 708 while(pEntry) 709 { 710 if(!aTreeLB.GetParent(pEntry)) 711 nRet++; 712 pEntry = aTreeLB.Next(pEntry); 713 } 714 return nRet - 1; 715 } 716 717 /* -----------------11.02.99 10:31------------------- 718 * 719 * --------------------------------------------------*/ 720 IMPL_LINK(OfaTreeOptionsDialog, ShowPageHdl_Impl, SvTreeListBox*, EMPTYARG) 721 { 722 if ( aSelectTimer.GetTimeout() == SELECT_FIRST_TIMEOUT ) 723 { 724 aSelectTimer.SetTimeout( SELECT_TIMEOUT ); 725 SelectHdl_Impl( NULL ); 726 } 727 else if ( aSelectTimer.GetTimeout() == SELECT_TIMEOUT ) 728 aSelectTimer.Start(); 729 730 return 0; 731 } 732 /* -----------------11.02.99 10:49------------------- 733 * 734 * --------------------------------------------------*/ 735 IMPL_LINK( OfaTreeOptionsDialog, BackHdl_Impl, PushButton*, EMPTYARG ) 736 { 737 if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) ) 738 { 739 OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pCurrentPageEntry->GetUserData(); 740 if ( pPageInfo->m_pPage ) 741 { 742 OptionsGroupInfo* pGroupInfo = 743 (OptionsGroupInfo*)aTreeLB.GetParent( pCurrentPageEntry )->GetUserData(); 744 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId ) 745 pPageInfo->m_pPage->Reset( *pColorPageItemSet ); 746 else 747 pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet ); 748 } 749 else if ( pPageInfo->m_pExtPage ) 750 pPageInfo->m_pExtPage->ResetPage(); 751 } 752 return 0; 753 } 754 /* -----------------11.02.99 16:45------------------- 755 * 756 * --------------------------------------------------*/ 757 IMPL_LINK( OfaTreeOptionsDialog, OKHdl_Impl, Button *, EMPTYARG ) 758 { 759 aTreeLB.EndSelection(); 760 if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) ) 761 { 762 OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pCurrentPageEntry->GetUserData(); 763 if ( pPageInfo->m_pPage ) 764 { 765 OptionsGroupInfo* pGroupInfo = 766 (OptionsGroupInfo *)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData(); 767 if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId 768 && pPageInfo->m_pPage->HasExchangeSupport() ) 769 { 770 int nLeave = pPageInfo->m_pPage->DeactivatePage(pGroupInfo->m_pOutItemSet); 771 if ( nLeave == SfxTabPage::KEEP_PAGE ) 772 { 773 //die Seite darf nicht verlassen werden! 774 aTreeLB.Select(pCurrentPageEntry); 775 return 0; 776 } 777 } 778 pPageInfo->m_pPage->Hide(); 779 } 780 } 781 782 SvLBoxEntry* pEntry = aTreeLB.First(); 783 while ( pEntry ) 784 { 785 if ( aTreeLB.GetParent( pEntry ) ) 786 { 787 OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pEntry->GetUserData(); 788 if ( pPageInfo->m_pPage && !pPageInfo->m_pPage->HasExchangeSupport() ) 789 { 790 OptionsGroupInfo* pGroupInfo = 791 (OptionsGroupInfo*)aTreeLB.GetParent(pEntry)->GetUserData(); 792 pPageInfo->m_pPage->FillItemSet(*pGroupInfo->m_pOutItemSet); 793 } 794 795 if ( pPageInfo->m_pExtPage ) 796 { 797 pPageInfo->m_pExtPage->DeactivatePage(); 798 pPageInfo->m_pExtPage->SavePage(); 799 } 800 } 801 pEntry = aTreeLB.Next(pEntry); 802 } 803 EndDialog(RET_OK); 804 return 0; 805 } 806 807 /* -----------------17.02.99 09:15------------------- 808 * Eine aufgeklappte Gruppe soll vollstaendig sichtbar sein 809 * --------------------------------------------------*/ 810 IMPL_LINK(OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox*, pBox ) 811 { 812 pBox->Update(); 813 pBox->InitStartEntry(); 814 SvLBoxEntry* pEntry = pBox->GetHdlEntry(); 815 if(pEntry && pBox->IsExpanded(pEntry)) 816 { 817 sal_uInt32 nChildCount = pBox->GetChildCount( pEntry ); 818 819 SvLBoxEntry* pNext = pEntry; 820 for(sal_uInt32 i = 0; i < nChildCount;i++) 821 { 822 pNext = pBox->GetNextEntryInView(pNext); 823 if(!pNext) 824 { 825 pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) ); 826 break; 827 } 828 else 829 { 830 Size aSz(pBox->GetOutputSizePixel()); 831 int nHeight = pBox->GetEntryHeight(); 832 Point aPos(pBox->GetEntryPosition(pNext)); 833 if(aPos.Y()+nHeight > aSz.Height()) 834 { 835 pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) ); 836 break; 837 } 838 } 839 } 840 } 841 return 0; 842 } 843 844 /* -----------------11.02.99 10:49------------------- 845 * 846 * --------------------------------------------------*/ 847 void OfaTreeOptionsDialog::ApplyItemSets() 848 { 849 SvLBoxEntry* pEntry = aTreeLB.First(); 850 while(pEntry) 851 { 852 if(!aTreeLB.GetParent(pEntry)) 853 { 854 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pEntry->GetUserData(); 855 if(pGroupInfo->m_pOutItemSet) 856 { 857 if(pGroupInfo->m_pShell) 858 pGroupInfo->m_pShell->ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet); 859 else 860 ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet); 861 } 862 } 863 pEntry = aTreeLB.Next(pEntry); 864 } 865 } 866 867 void OfaTreeOptionsDialog::InitTreeAndHandler() 868 { 869 aTreeLB.SetNodeDefaultImages(); 870 aPageImages = ImageList( CUI_RES( RID_IMGLIST_TREEOPT ) ); 871 aPageImagesHC = ImageList( CUI_RES( RID_IMGLIST_TREEOPT_HC ) ); 872 873 aTreeLB.SetHelpId( HID_OFADLG_TREELISTBOX ); 874 aTreeLB.SetStyle( aTreeLB.GetStyle()|WB_HASBUTTONS | WB_HASBUTTONSATROOT | 875 WB_HASLINES | WB_HASLINESATROOT | 876 WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE | WB_QUICK_SEARCH ); 877 aTreeLB.SetSpaceBetweenEntries( 0 ); 878 aTreeLB.SetSelectionMode( SINGLE_SELECTION ); 879 aTreeLB.SetSublistOpenWithLeftRight( sal_True ); 880 aTreeLB.SetExpandedHdl( LINK( this, OfaTreeOptionsDialog, ExpandedHdl_Impl ) ); 881 aTreeLB.SetSelectHdl( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) ); 882 aBackPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) ); 883 aOkPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, OKHdl_Impl ) ); 884 885 aHiddenGB.Show(); 886 aSelectTimer.SetTimeout( SELECT_FIRST_TIMEOUT ); 887 aSelectTimer.SetTimeoutHdl( LINK( this, OfaTreeOptionsDialog, SelectHdl_Impl ) ); 888 } 889 890 /* -----------------17.02.99 09:51------------------- 891 * 892 * --------------------------------------------------*/ 893 void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId ) 894 { 895 bIsForSetDocumentLanguage = false; 896 if ( nResId == OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE ) 897 { 898 bIsForSetDocumentLanguage = true; 899 nResId = OFA_TP_LANGUAGES; 900 } 901 902 DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" ); 903 if ( !pLastPageSaver ) 904 pLastPageSaver = new LastPageSaver; 905 bForgetSelection = sal_True; 906 sal_uInt16 nTemp = pLastPageSaver->m_nLastPageId; 907 pLastPageSaver->m_nLastPageId = nResId; 908 ActivateLastSelection(); 909 pLastPageSaver->m_nLastPageId = nTemp; 910 } 911 912 void OfaTreeOptionsDialog::ActivatePage( const String& rPageURL ) 913 { 914 DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" ); 915 if ( !pLastPageSaver ) 916 pLastPageSaver = new LastPageSaver; 917 bForgetSelection = sal_True; 918 pLastPageSaver->m_nLastPageId = 0; 919 pLastPageSaver->m_sLastPageURL_Tools = rPageURL; 920 ActivateLastSelection(); 921 } 922 923 /* -----------------16.02.99 13:17------------------- 924 * 925 * --------------------------------------------------*/ 926 void OfaTreeOptionsDialog::ActivateLastSelection() 927 { 928 SvLBoxEntry* pEntry = NULL; 929 if ( pLastPageSaver ) 930 { 931 String sExpand( RTL_CONSTASCII_STRINGPARAM( EXPAND_PROTOCOL ) ); 932 String sLastURL = bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr 933 : pLastPageSaver->m_sLastPageURL_Tools; 934 if ( sLastURL.Len() == 0 ) 935 { 936 sLastURL = !bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr 937 : pLastPageSaver->m_sLastPageURL_Tools; 938 } 939 940 // MacroExpander to convert "expand"-URL to "file"-URL 941 Reference< XMacroExpander > m_xMacroExpander; 942 bool bMustExpand = ( INetURLObject( sLastURL ).GetProtocol() == INET_PROT_FILE ); 943 944 if ( bMustExpand ) 945 { 946 Reference< XComponentContext > xContext; 947 Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY ); 948 xProps->getPropertyValue( 949 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext; 950 if ( xContext.is() ) 951 m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >( 952 xContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 953 "/singletons/com.sun.star.util.theMacroExpander" ) ) ), UNO_QUERY ); 954 } 955 956 SvLBoxEntry* pTemp = aTreeLB.First(); 957 while( !pEntry && pTemp ) 958 { 959 // restore only selection of a leaf 960 if ( aTreeLB.GetParent( pTemp ) && pTemp->GetUserData() ) 961 { 962 OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pTemp->GetUserData(); 963 String sPageURL = pPageInfo->m_sPageURL; 964 if ( bMustExpand 965 && sPageURL.Len() > 0 966 && sExpand.Match( sPageURL ) == STRING_MATCH ) 967 { 968 // cut protocol 969 ::rtl::OUString sTemp( sPageURL.Copy( sizeof( EXPAND_PROTOCOL ) -1 ) ); 970 // decode uri class chars 971 sTemp = ::rtl::Uri::decode( 972 sTemp, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); 973 // expand string 974 sPageURL = m_xMacroExpander->expandMacros( sTemp ); 975 } 976 977 if ( ( !bIsFromExtensionManager 978 && pPageInfo->m_nPageId && pPageInfo->m_nPageId == pLastPageSaver->m_nLastPageId ) 979 || ( !pPageInfo->m_nPageId && sLastURL == sPageURL ) ) 980 pEntry = pTemp; 981 } 982 pTemp = aTreeLB.Next(pTemp); 983 } 984 } 985 986 if ( !pEntry ) 987 { 988 pEntry = aTreeLB.First(); 989 pEntry = aTreeLB.Next(pEntry); 990 } 991 992 SvLBoxEntry* pParent = aTreeLB.GetParent(pEntry); 993 aTreeLB.Expand(pParent); 994 aTreeLB.MakeVisible(pParent); 995 aTreeLB.MakeVisible(pEntry); 996 aTreeLB.Select(pEntry); 997 aTreeLB.GrabFocus(); 998 } 999 1000 /* -----------------22.02.99 08:52------------------- 1001 * 1002 * --------------------------------------------------*/ 1003 long OfaTreeOptionsDialog::Notify( NotifyEvent& rNEvt ) 1004 { 1005 if ( rNEvt.GetType() == EVENT_KEYINPUT ) 1006 { 1007 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 1008 const KeyCode aKeyCode = pKEvt->GetKeyCode(); 1009 1010 if( aKeyCode.GetCode() == KEY_PAGEUP || 1011 aKeyCode.GetCode() == KEY_PAGEDOWN) 1012 { 1013 SvLBoxEntry* pCurEntry = aTreeLB.FirstSelected(); 1014 SvLBoxEntry* pTemp = 0; 1015 if(aKeyCode.GetCode() == KEY_PAGEDOWN) 1016 { 1017 pTemp = aTreeLB.Next( pCurEntry ) ; 1018 if(pTemp && !aTreeLB.GetParent(pTemp)) 1019 { 1020 pTemp = aTreeLB.Next( pTemp ) ; 1021 aTreeLB.Select(pTemp); 1022 } 1023 } 1024 else 1025 { 1026 pTemp = aTreeLB.Prev( pCurEntry ) ; 1027 if(pTemp && !aTreeLB.GetParent(pTemp)) 1028 { 1029 pTemp = aTreeLB.Prev( pTemp ) ; 1030 } 1031 } 1032 if(pTemp) 1033 { 1034 if(!aTreeLB.IsExpanded(aTreeLB.GetParent(pTemp))) 1035 aTreeLB.Expand(aTreeLB.GetParent(pTemp)); 1036 aTreeLB.MakeVisible(pTemp); 1037 aTreeLB.Select(pTemp); 1038 } 1039 } 1040 } 1041 return SfxModalDialog::Notify(rNEvt); 1042 } 1043 1044 // -------------------------------------------------------------------- 1045 1046 void OfaTreeOptionsDialog::DataChanged( const DataChangedEvent& rDCEvt ) 1047 { 1048 SfxModalDialog::DataChanged( rDCEvt ); 1049 1050 SvLBoxEntry* pEntry = aTreeLB.GetCurEntry(); 1051 if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) && 1052 !aTreeLB.GetParent(pEntry)) 1053 { 1054 OptionsGroupInfo* pInfo = static_cast<OptionsGroupInfo*>(pEntry->GetUserData()); 1055 bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 1056 ImageList* pImgLst = bHighContrast ? &aPageImagesHC : &aPageImages; 1057 for ( sal_uInt16 i = 0; i < aHelpTextsArr.Count(); ++i ) 1058 { 1059 if ( aHelpTextsArr.GetValue(i) == pInfo->m_nDialogId ) 1060 { 1061 aHelpImg.SetImage( pImgLst->GetImage( pInfo->m_nDialogId ) ); 1062 break; 1063 } 1064 } 1065 } 1066 } 1067 class FlagSet_Impl 1068 { 1069 bool & rFlag; 1070 public: 1071 FlagSet_Impl(bool& bFlag) : rFlag(bFlag){rFlag = true;} 1072 ~FlagSet_Impl(){rFlag = false;} 1073 }; 1074 1075 IMPL_LINK( OfaTreeOptionsDialog, SelectHdl_Impl, Timer*, EMPTYARG ) 1076 { 1077 SvTreeListBox* pBox = &aTreeLB; 1078 SvLBoxEntry* pEntry = pBox->GetCurEntry(); 1079 SvLBoxEntry* pParent = pBox->GetParent(pEntry); 1080 pBox->EndSelection(); 1081 1082 DBG_ASSERT(!bInSelectHdl_Impl, "Timeout handler called twice"); 1083 if(bInSelectHdl_Impl || pCurrentPageEntry == pEntry) 1084 return 0; 1085 //#111938# lock the SelectHdl_Impl to prevent multiple executes 1086 FlagSet_Impl aFlag(bInSelectHdl_Impl); 1087 TabPage* pOldPage = NULL; 1088 TabPage* pNewPage = NULL; 1089 OptionsPageInfo* pOptPageInfo = ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) ) 1090 ? (OptionsPageInfo*)pCurrentPageEntry->GetUserData() : NULL; 1091 1092 if ( pOptPageInfo && pOptPageInfo->m_pPage && pOptPageInfo->m_pPage->IsVisible() ) 1093 { 1094 pOldPage = pOptPageInfo->m_pPage; 1095 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData(); 1096 int nLeave = SfxTabPage::LEAVE_PAGE; 1097 if ( RID_SVXPAGE_COLOR != pOptPageInfo->m_nPageId && pOptPageInfo->m_pPage->HasExchangeSupport() ) 1098 nLeave = pOptPageInfo->m_pPage->DeactivatePage( pGroupInfo->m_pOutItemSet ); 1099 1100 if ( nLeave == SfxTabPage::KEEP_PAGE ) 1101 { 1102 // we cannot leave this page 1103 pBox->Select( pCurrentPageEntry ); 1104 return 0; 1105 } 1106 else 1107 pOptPageInfo->m_pPage->Hide(); 1108 } 1109 else if ( pOptPageInfo && pOptPageInfo->m_pExtPage ) 1110 { 1111 pOptPageInfo->m_pExtPage->Hide(); 1112 pOptPageInfo->m_pExtPage->DeactivatePage(); 1113 } 1114 else if ( pCurrentPageEntry && !aTreeLB.GetParent( pCurrentPageEntry ) ) 1115 { 1116 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pCurrentPageEntry->GetUserData(); 1117 if ( pGroupInfo && pGroupInfo->m_pExtPage ) 1118 { 1119 pGroupInfo->m_pExtPage->Hide(); 1120 pGroupInfo->m_pExtPage->DeactivatePage(); 1121 } 1122 } 1123 if ( pParent ) 1124 { 1125 aPageTitleFT.Hide(); 1126 aLine1FL.Hide(); 1127 aHelpFT.Hide(); 1128 aHelpImg.Hide(); 1129 OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData(); 1130 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pParent->GetUserData(); 1131 if(!pPageInfo->m_pPage && pPageInfo->m_nPageId > 0) 1132 { 1133 if(pGroupInfo->m_bLoadError) 1134 return 0; 1135 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId ) 1136 { 1137 if(!pColorPageItemSet) 1138 { 1139 // Move usage of a static XOutdevItemPool instance here 1140 if(!mpStaticXOutdevItemPool) 1141 { 1142 mpStaticXOutdevItemPool = new XOutdevItemPool(); 1143 } 1144 pColorPageItemSet = new SfxItemSet( *mpStaticXOutdevItemPool, XATTR_FILLSTYLE, XATTR_FILLCOLOR); 1145 pColorPageItemSet->Put( XFillColorItem() ); 1146 } 1147 } 1148 else 1149 { 1150 if(pGroupInfo->m_pModule /*&& !pGroupInfo->pModule->IsLoaded()*/) 1151 { 1152 SfxModule* pOldModule = pGroupInfo->m_pModule; 1153 sal_Bool bIdentical = pGroupInfo->m_pModule == pGroupInfo->m_pShell; 1154 1155 WaitObject aWait(this); 1156 //pGroupInfo->pModule = pGroupInfo->pModule->Load(); 1157 if(!pGroupInfo->m_pModule) 1158 { 1159 pGroupInfo->m_bLoadError = sal_True; 1160 InfoBox(pBox, sNotLoadedError).Execute(); 1161 return 0; 1162 } 1163 if(bIdentical) 1164 pGroupInfo->m_pShell = pGroupInfo->m_pModule; 1165 //jetzt noch testen, ob es auch in anderen Gruppen das gleiche Module gab (z.B. Text+HTML) 1166 SvLBoxEntry* pTemp = aTreeLB.First(); 1167 while(pTemp) 1168 { 1169 if(!aTreeLB.GetParent(pTemp) && pTemp != pEntry) 1170 { 1171 OptionsGroupInfo* pTGInfo = (OptionsGroupInfo *)pTemp->GetUserData(); 1172 if(pTGInfo->m_pModule == pOldModule) 1173 { 1174 pTGInfo->m_pModule = pGroupInfo->m_pModule; 1175 if(bIdentical) 1176 pTGInfo->m_pShell = pGroupInfo->m_pModule; 1177 } 1178 } 1179 pTemp = aTreeLB.Next(pTemp); 1180 } 1181 } 1182 1183 // if ( pPageInfo->nPageId != RID_OPTPAGE_CHART_DEFCOLORS ) 1184 { 1185 if(!pGroupInfo->m_pInItemSet) 1186 pGroupInfo->m_pInItemSet = pGroupInfo->m_pShell 1187 ? pGroupInfo->m_pShell->CreateItemSet( pGroupInfo->m_nDialogId ) 1188 : CreateItemSet( pGroupInfo->m_nDialogId ); 1189 if(!pGroupInfo->m_pOutItemSet) 1190 pGroupInfo->m_pOutItemSet = new SfxItemSet( 1191 *pGroupInfo->m_pInItemSet->GetPool(), 1192 pGroupInfo->m_pInItemSet->GetRanges()); 1193 } 1194 } 1195 1196 if(pGroupInfo->m_pModule) 1197 { 1198 pPageInfo->m_pPage = pGroupInfo->m_pModule->CreateTabPage( 1199 pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet ); 1200 } 1201 else if(RID_SVXPAGE_COLOR != pPageInfo->m_nPageId) 1202 pPageInfo->m_pPage = ::CreateGeneralTabPage( pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet ); 1203 else 1204 { 1205 pPageInfo->m_pPage = ::CreateGeneralTabPage( 1206 pPageInfo->m_nPageId, this, *pColorPageItemSet ); 1207 SvxColorTabPage& rColPage = *(SvxColorTabPage*)pPageInfo->m_pPage; 1208 const OfaPtrItem* pPtr = NULL; 1209 if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() ) 1210 pPtr = (const OfaPtrItem*)SfxViewFrame::Current()-> 1211 GetDispatcher()->Execute( SID_GET_COLORTABLE, SFX_CALLMODE_SYNCHRON ); 1212 pColorTab = pPtr ? (XColorTable*)pPtr->GetValue() : XColorTable::GetStdColorTable(); 1213 1214 rColPage.SetColorTable( pColorTab ); 1215 rColPage.SetPageType( &nUnknownType ); 1216 rColPage.SetDlgType( &nUnknownType ); 1217 rColPage.SetPos( &nUnknownPos ); 1218 rColPage.SetAreaTP( &bIsAreaTP ); 1219 rColPage.SetColorChgd( (ChangeType*)&nChangeType ); 1220 rColPage.Construct(); 1221 } 1222 1223 DBG_ASSERT( pPageInfo->m_pPage, "tabpage could not created"); 1224 if ( pPageInfo->m_pPage ) 1225 { 1226 SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pPageInfo->m_nPageId ) ); 1227 pPageInfo->m_pPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) ); 1228 1229 Point aTreePos(aTreeLB.GetPosPixel()); 1230 Size aTreeSize(aTreeLB.GetSizePixel()); 1231 Point aGBPos(aHiddenGB.GetPosPixel()); 1232 Size aPageSize(pPageInfo->m_pPage->GetSizePixel()); 1233 Size aGBSize(aHiddenGB.GetSizePixel()); 1234 Point aPagePos( aGBPos.X() + ( aGBSize.Width() - aPageSize.Width() ) / 2, 1235 aGBPos.Y() + ( aGBSize.Height() - aPageSize.Height() ) / 2 ); 1236 pPageInfo->m_pPage->SetPosPixel( aPagePos ); 1237 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId ) 1238 { 1239 pPageInfo->m_pPage->Reset( *pColorPageItemSet ); 1240 pPageInfo->m_pPage->ActivatePage( *pColorPageItemSet ); 1241 } 1242 else 1243 { 1244 pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet ); 1245 } 1246 } 1247 } 1248 else if ( 0 == pPageInfo->m_nPageId && !pPageInfo->m_pExtPage ) 1249 { 1250 if ( !m_xContainerWinProvider.is() ) 1251 { 1252 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 1253 m_xContainerWinProvider = Reference < awt::XContainerWindowProvider >( 1254 xFactory->createInstance( 1255 C2U("com.sun.star.awt.ContainerWindowProvider") ), UNO_QUERY ); 1256 DBG_ASSERT( m_xContainerWinProvider.is(), "service com.sun.star.awt.ContainerWindowProvider could not be loaded" ); 1257 } 1258 1259 pPageInfo->m_pExtPage = new ExtensionsTabPage( 1260 this, 0, pPageInfo->m_sPageURL, pPageInfo->m_sEventHdl, m_xContainerWinProvider ); 1261 Size aSize = aHiddenGB.GetSizePixel(); 1262 aSize.Width() = aSize.Width() - 4; 1263 aSize.Height() = aSize.Height() - 4; 1264 Point aPos = aHiddenGB.GetPosPixel(); 1265 aPos.X() = aPos.X() + 2; 1266 aPos.Y() = aPos.Y() + 2; 1267 pPageInfo->m_pExtPage->SetPosSizePixel( aPos, aSize ); 1268 } 1269 1270 if ( pPageInfo->m_pPage ) 1271 { 1272 if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId && 1273 pPageInfo->m_pPage->HasExchangeSupport()) 1274 { 1275 pPageInfo->m_pPage->ActivatePage(*pGroupInfo->m_pOutItemSet); 1276 } 1277 pPageInfo->m_pPage->Show(); 1278 } 1279 else if ( pPageInfo->m_pExtPage ) 1280 { 1281 pPageInfo->m_pExtPage->Show(); 1282 pPageInfo->m_pExtPage->ActivatePage(); 1283 } 1284 1285 String sTmpTitle = sTitle; 1286 sTmpTitle += String::CreateFromAscii(" - "); 1287 sTmpTitle += aTreeLB.GetEntryText(pParent); 1288 sTmpTitle += String::CreateFromAscii(" - "); 1289 sTmpTitle += aTreeLB.GetEntryText(pEntry); 1290 SetText(sTmpTitle); 1291 pCurrentPageEntry = pEntry; 1292 if ( !bForgetSelection ) 1293 { 1294 if ( !pLastPageSaver ) 1295 pLastPageSaver = new LastPageSaver; 1296 if ( !bIsFromExtensionManager ) 1297 pLastPageSaver->m_nLastPageId = pPageInfo->m_nPageId; 1298 if ( pPageInfo->m_pExtPage ) 1299 { 1300 if ( bIsFromExtensionManager ) 1301 pLastPageSaver->m_sLastPageURL_ExtMgr = pPageInfo->m_sPageURL; 1302 else 1303 pLastPageSaver->m_sLastPageURL_Tools = pPageInfo->m_sPageURL; 1304 } 1305 } 1306 pNewPage = pPageInfo->m_pPage; 1307 } 1308 else 1309 { 1310 OptionsGroupInfo* pTGInfo = (OptionsGroupInfo *)pEntry->GetUserData(); 1311 if ( pTGInfo->m_sPageURL.getLength() == 0 ) 1312 { 1313 bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 1314 ImageList* pImgLst = bHighContrast ? &aPageImagesHC : &aPageImages; 1315 //hier den Hilfetext anzeigen 1316 for ( sal_uInt16 i = 0; i < aHelpTextsArr.Count(); ++i ) 1317 { 1318 if ( aHelpTextsArr.GetValue(i) == pTGInfo->m_nDialogId ) 1319 { 1320 aHelpFT.SetText(aHelpTextsArr.GetString(i)); 1321 aHelpImg.SetImage(pImgLst->GetImage(pTGInfo->m_nDialogId)); 1322 break; 1323 } 1324 } 1325 1326 aPageTitleFT.Show(); 1327 aLine1FL.Show(); 1328 aHelpFT.Show(); 1329 aHelpImg.Show(); 1330 1331 //auf die Groesse der Bitmap anpassen 1332 if(!bImageResized) 1333 { 1334 const long nCtrlDist = 2; 1335 bImageResized = sal_True; 1336 Point aImgPos(aHelpImg.GetPosPixel()); 1337 Size aImgSize(aHelpImg.GetSizePixel()); 1338 Point aTitlePos(aPageTitleFT.GetPosPixel()); 1339 Point aLinePos(aLine1FL.GetPosPixel()); 1340 Point aHelpPos(aHelpFT.GetPosPixel()); 1341 Size aHelpSize(aHelpFT.GetSizePixel()); 1342 long nXDiff = 0; 1343 long nYDiff = 0; 1344 if(aTitlePos.X() <= (aImgPos.X() + aImgSize.Width() + nCtrlDist)) 1345 { 1346 nXDiff = aImgPos.X() + aImgSize.Width() + nCtrlDist - aTitlePos.X(); 1347 } 1348 if(aLinePos.Y() <= (aImgPos.Y() + aImgSize.Height() + nCtrlDist)) 1349 { 1350 nYDiff = aImgPos.Y() + aImgSize.Height() + nCtrlDist - aLinePos.Y(); 1351 } 1352 aLinePos.Y() += nYDiff; 1353 aLine1FL.SetPosPixel(aLinePos); 1354 1355 aTitlePos.X() += nXDiff; 1356 aPageTitleFT.SetPosPixel(aTitlePos); 1357 1358 aHelpPos.X() += nXDiff; 1359 aHelpPos.Y() += nYDiff; 1360 aHelpSize.Width() -= nXDiff; 1361 aHelpSize.Height() -= nYDiff; 1362 aHelpFT.SetPosSizePixel(aHelpPos, aHelpSize); 1363 1364 Font aFont = aHelpFT.GetFont(); 1365 Size aSz = aFont.GetSize(); 1366 aSz.Height() = (aSz.Height() * 14 ) / 10; 1367 aFont.SetSize(aSz); 1368 aPageTitleFT.SetFont(aFont); 1369 } 1370 1371 String sTmpTitle = sTitle; 1372 sTmpTitle += String::CreateFromAscii(" - "); 1373 aPageTitleFT.SetText(aTreeLB.GetEntryText(pEntry)); 1374 sTmpTitle += aPageTitleFT.GetText(); 1375 SetText(sTmpTitle); 1376 pCurrentPageEntry = NULL; 1377 } 1378 else 1379 { 1380 if ( !pTGInfo->m_pExtPage ) 1381 { 1382 if ( !m_xContainerWinProvider.is() ) 1383 { 1384 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 1385 m_xContainerWinProvider = Reference < awt::XContainerWindowProvider >( 1386 xFactory->createInstance( 1387 C2U("com.sun.star.awt.ContainerWindowProvider") ), UNO_QUERY ); 1388 DBG_ASSERT( m_xContainerWinProvider.is(), "service com.sun.star.awt.ContainerWindowProvider could not be loaded" ); 1389 } 1390 1391 pTGInfo->m_pExtPage = 1392 new ExtensionsTabPage( this, 0, pTGInfo->m_sPageURL, rtl::OUString(), m_xContainerWinProvider ); 1393 Size aSize = aHiddenGB.GetSizePixel(); 1394 aSize.Width() = aSize.Width() - 4; 1395 aSize.Height() = aSize.Height() - 4; 1396 Point aPos = aHiddenGB.GetPosPixel(); 1397 aPos.X() = aPos.X() + 2; 1398 aPos.Y() = aPos.Y() + 2; 1399 pTGInfo->m_pExtPage->SetPosSizePixel( aPos, aSize ); 1400 } 1401 1402 if ( pTGInfo->m_pExtPage ) 1403 { 1404 pTGInfo->m_pExtPage->Show(); 1405 pTGInfo->m_pExtPage->ActivatePage(); 1406 } 1407 1408 pCurrentPageEntry = pEntry; 1409 } 1410 } 1411 1412 // restore lost focus, if necessary 1413 Window* pFocusWin = Application::GetFocusWindow(); 1414 // if the focused window is not the options treebox and the old page has the focus 1415 if ( pFocusWin && pFocusWin != pBox && pOldPage && pOldPage->HasChildPathFocus() ) 1416 // then set the focus to the new page or if we are on a group set the focus to the options treebox 1417 pNewPage ? pNewPage->GrabFocus() : pBox->GrabFocus(); 1418 1419 return 0; 1420 } 1421 1422 /* -----------------11.02.99 15:51------------------- 1423 * 1424 * --------------------------------------------------*/ 1425 1426 OfaPageResource::OfaPageResource() : 1427 Resource(CUI_RES(RID_OFADLG_OPTIONS_TREE_PAGES)), 1428 aGeneralDlgAry(CUI_RES(SID_GENERAL_OPTIONS)), 1429 aInetDlgAry(CUI_RES(SID_INET_DLG)), 1430 aLangDlgAry(CUI_RES(SID_LANGUAGE_OPTIONS)), 1431 aTextDlgAry(CUI_RES(SID_SW_EDITOPTIONS)), 1432 aHTMLDlgAry(CUI_RES(SID_SW_ONLINEOPTIONS)), 1433 aCalcDlgAry(CUI_RES(SID_SC_EDITOPTIONS)), 1434 aStarMathDlgAry(CUI_RES(SID_SM_EDITOPTIONS)), 1435 aImpressDlgAry(CUI_RES(SID_SD_EDITOPTIONS)), 1436 aDrawDlgAry(CUI_RES(SID_SD_GRAPHIC_OPTIONS)), 1437 aChartDlgAry(CUI_RES(SID_SCH_EDITOPTIONS)), 1438 aFilterDlgAry(CUI_RES(SID_FILTER_DLG)), 1439 aDatasourcesDlgAry(CUI_RES(SID_SB_STARBASEOPTIONS)) 1440 { 1441 FreeResource(); 1442 } 1443 1444 sal_Bool EnableSSO( void ) 1445 { 1446 // SSO must be enabled if the configuration manager bootstrap settings 1447 // are configured as follows ... 1448 // CFG_Offline=false 1449 // CFG_ServerType=uno ( or unspecified ) 1450 // CFG_BackendService= 1451 // com.sun.star.comp.configuration.backend.LdapSingleBackend 1452 1453 rtl::OUString theIniFile; 1454 osl_getExecutableFile( &theIniFile.pData ); 1455 theIniFile = theIniFile.copy( 0, theIniFile.lastIndexOf( '/' ) + 1 ) + 1456 rtl::OUString::createFromAscii( SAL_CONFIGFILE( "configmgr" ) ); 1457 ::rtl::Bootstrap theBootstrap( theIniFile ); 1458 1459 rtl::OUString theOfflineValue; 1460 rtl::OUString theDefaultOfflineValue = rtl::OUString::createFromAscii( "false" ); 1461 theBootstrap.getFrom( rtl::OUString::createFromAscii( "CFG_Offline" ), 1462 theOfflineValue, 1463 theDefaultOfflineValue ); 1464 1465 rtl::OUString theServerTypeValue; 1466 theBootstrap.getFrom( rtl::OUString::createFromAscii( "CFG_ServerType" ), 1467 theServerTypeValue ); 1468 1469 rtl::OUString theBackendServiceTypeValue; 1470 theBootstrap.getFrom( rtl::OUString::createFromAscii( "CFG_BackendService" ), 1471 theBackendServiceTypeValue ); 1472 1473 sal_Bool bSSOEnabled = 1474 ( theOfflineValue == theDefaultOfflineValue && 1475 ( theServerTypeValue.getLength() == 0 || 1476 theServerTypeValue == rtl::OUString::createFromAscii( "uno" ) ) && 1477 theBackendServiceTypeValue == 1478 rtl::OUString::createFromAscii( 1479 "com.sun.star.comp.configuration.backend.LdapSingleBackend" ) ); 1480 if ( bSSOEnabled && GetSSOCreator() == 0 ) 1481 { 1482 bSSOEnabled = sal_False; 1483 } 1484 return bSSOEnabled; 1485 } 1486 1487 extern "C" { static void SAL_CALL thisModule() {} } 1488 1489 CreateTabPage GetSSOCreator( void ) 1490 { 1491 static CreateTabPage theSymbol = 0; 1492 if ( theSymbol == 0 ) 1493 { 1494 osl::Module aModule; 1495 rtl::OUString theModuleName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "ssoopt" ) ) ); 1496 if( aModule.loadRelative( 1497 &thisModule, theModuleName, SAL_LOADMODULE_DEFAULT ) ) 1498 { 1499 rtl::OUString theSymbolName( rtl::OUString::createFromAscii( "CreateSSOTabPage" ) ); 1500 theSymbol = reinterpret_cast<CreateTabPage>(aModule.getFunctionSymbol( theSymbolName )); 1501 } 1502 } 1503 1504 return theSymbol; 1505 } 1506 1507 SfxItemSet* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) 1508 { 1509 Reference< XPropertySet > xProp( SvxGetLinguPropertySet() ); 1510 SfxItemSet* pRet = 0; 1511 switch(nId) 1512 { 1513 case SID_GENERAL_OPTIONS: 1514 { 1515 pRet = new SfxItemSet( 1516 SFX_APP()->GetPool(), 1517 SID_ATTR_METRIC, SID_ATTR_SPELL, 1518 SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK, 1519 SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER, 1520 SID_ATTR_YEAR2000, SID_ATTR_YEAR2000, 1521 SID_HTML_MODE, SID_HTML_MODE, 1522 0 ); 1523 1524 SfxItemSet aOptSet( SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER ); 1525 SFX_APP()->GetOptions(aOptSet); 1526 pRet->Put(aOptSet); 1527 1528 utl::MiscCfg aMisc; 1529 const SfxPoolItem* pItem; 1530 SfxViewFrame* pViewFrame = SfxViewFrame::Current(); 1531 if ( pViewFrame ) 1532 { 1533 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); 1534 1535 // Sonstiges - Year2000 1536 if( SFX_ITEM_AVAILABLE <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) ) 1537 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, ((const SfxUInt16Item*)pItem)->GetValue() ) ); 1538 else 1539 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) ); 1540 } 1541 else 1542 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) ); 1543 1544 1545 // Sonstiges - Tabulator 1546 pRet->Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN, aMisc.IsNotFoundWarning())); 1547 1548 sal_uInt16 nFlag = aMisc.IsPaperSizeWarning() ? SFX_PRINTER_CHG_SIZE : 0; 1549 nFlag |= aMisc.IsPaperOrientationWarning() ? SFX_PRINTER_CHG_ORIENTATION : 0; 1550 pRet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, nFlag )); 1551 1552 } 1553 break; 1554 case SID_LANGUAGE_OPTIONS : 1555 { 1556 pRet = new SfxItemSet(SFX_APP()->GetPool(), 1557 SID_ATTR_LANGUAGE, SID_AUTOSPELL_CHECK, 1558 SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE, 1559 SID_OPT_LOCALE_CHANGED, SID_OPT_LOCALE_CHANGED, 1560 SID_SET_DOCUMENT_LANGUAGE, SID_SET_DOCUMENT_LANGUAGE, 1561 0 ); 1562 1563 // fuer die Linguistik 1564 1565 Reference< XSpellChecker1 > xSpell = SvxGetSpellChecker(); 1566 pRet->Put(SfxSpellCheckItem( xSpell, SID_ATTR_SPELL )); 1567 SfxHyphenRegionItem aHyphen( SID_ATTR_HYPHENREGION ); 1568 1569 sal_Int16 nMinLead = 2, 1570 nMinTrail = 2; 1571 if (xProp.is()) 1572 { 1573 xProp->getPropertyValue( String::CreateFromAscii( 1574 UPN_HYPH_MIN_LEADING) ) >>= nMinLead; 1575 xProp->getPropertyValue( String::CreateFromAscii( 1576 UPN_HYPH_MIN_TRAILING) ) >>= nMinTrail; 1577 } 1578 aHyphen.GetMinLead() = (sal_uInt8)nMinLead; 1579 aHyphen.GetMinTrail() = (sal_uInt8)nMinTrail; 1580 1581 const SfxPoolItem* pItem; 1582 SfxPoolItem* pClone; 1583 SfxViewFrame* pViewFrame = SfxViewFrame::Current(); 1584 if ( pViewFrame ) 1585 { 1586 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); 1587 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem)) 1588 pRet->Put(SfxUInt16Item(SID_ATTR_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage())); 1589 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem)) 1590 pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CJK_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage())); 1591 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem)) 1592 pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CTL_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage())); 1593 1594 pRet->Put(aHyphen); 1595 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem)) 1596 { 1597 pClone = pItem->Clone(); 1598 pRet->Put(*pClone); 1599 delete pClone; 1600 } 1601 else 1602 { 1603 sal_Bool bVal = sal_False; 1604 if (xProp.is()) 1605 { 1606 xProp->getPropertyValue( String::CreateFromAscii( UPN_IS_SPELL_AUTO) ) >>= bVal; 1607 } 1608 1609 pRet->Put(SfxBoolItem(SID_AUTOSPELL_CHECK, bVal)); 1610 } 1611 } 1612 pRet->Put( SfxBoolItem( SID_SET_DOCUMENT_LANGUAGE, bIsForSetDocumentLanguage ) ); 1613 } 1614 break; 1615 case SID_INET_DLG : 1616 pRet = new SfxItemSet( SFX_APP()->GetPool(), 1617 SID_BASIC_ENABLED, SID_BASIC_ENABLED, 1618 //SID_OPTIONS_START - ..END 1619 SID_INET_EMAIL_NAME, SID_INET_PROXY_PORT, 1620 SID_SAVEREL_INET, SID_SAVEREL_FSYS, 1621 SID_INET_SMTPSERVER, SID_INET_SMTPSERVER, 1622 SID_INET_NOPROXY, SID_INET_SOCKS_PROXY_PORT, 1623 SID_INET_DNS_AUTO, SID_INET_DNS_SERVER, 1624 SID_SECURE_URL, SID_SECURE_URL, 1625 0L ); 1626 SFX_APP()->GetOptions(*pRet); 1627 break; 1628 case SID_FILTER_DLG: 1629 pRet = new SfxItemSet( SFX_APP()->GetPool(), 1630 SID_ATTR_DOCINFO, SID_ATTR_AUTOSAVEMINUTE, 1631 SID_SAVEREL_INET, SID_SAVEREL_FSYS, 1632 SID_ATTR_PRETTYPRINTING, SID_ATTR_PRETTYPRINTING, 1633 SID_ATTR_WARNALIENFORMAT, SID_ATTR_WARNALIENFORMAT, 1634 0 ); 1635 SFX_APP()->GetOptions(*pRet); 1636 break; 1637 1638 case SID_SB_STARBASEOPTIONS: 1639 pRet = new SfxItemSet( SFX_APP()->GetPool(), 1640 SID_SB_POOLING_ENABLED, SID_SB_DB_REGISTER, 1641 0 ); 1642 ::offapp::ConnectionPoolConfig::GetOptions(*pRet); 1643 ::svx::DbRegisteredNamesConfig::GetOptions(*pRet); 1644 break; 1645 1646 case SID_SCH_EDITOPTIONS: 1647 { 1648 SvxChartOptions aChartOpt; 1649 pRet = new SfxItemSet( SFX_APP()->GetPool(), SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS ); 1650 pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) ); 1651 break; 1652 } 1653 } 1654 return pRet; 1655 } 1656 1657 void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) 1658 { 1659 switch(nId) 1660 { 1661 case SID_GENERAL_OPTIONS: 1662 { 1663 utl::MiscCfg aMisc; 1664 const SfxPoolItem* pItem; 1665 SfxItemSet aOptSet(SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER ); 1666 aOptSet.Put(rSet); 1667 if(aOptSet.Count()) 1668 SFX_APP()->SetOptions( aOptSet ); 1669 // Dispatcher neu holen, weil SetOptions() ggf. den Dispatcher zerst"ort hat 1670 SfxViewFrame *pViewFrame = SfxViewFrame::Current(); 1671 // ------------------------------------------------------------------------- 1672 // Year2000 auswerten 1673 // ------------------------------------------------------------------------- 1674 sal_uInt16 nY2K = USHRT_MAX; 1675 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_YEAR2000, sal_False, &pItem ) ) 1676 nY2K = ((const SfxUInt16Item*)pItem)->GetValue(); 1677 if( USHRT_MAX != nY2K ) 1678 { 1679 if ( pViewFrame ) 1680 { 1681 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); 1682 pDispatch->Execute( SID_ATTR_YEAR2000, SFX_CALLMODE_ASYNCHRON, pItem, 0L); 1683 } 1684 aMisc.SetYear2000(nY2K); 1685 } 1686 1687 // ------------------------------------------------------------------------- 1688 // Drucken auswerten 1689 // ------------------------------------------------------------------------- 1690 if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_NOTFOUND_WARN, sal_False, &pItem)) 1691 aMisc.SetNotFoundWarning(((const SfxBoolItem*)pItem)->GetValue()); 1692 1693 if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_CHANGESTODOC, sal_False, &pItem)) 1694 { 1695 const SfxFlagItem* pFlag = (const SfxFlagItem*)pItem; 1696 aMisc.SetPaperSizeWarning(0 != (pFlag->GetValue() & SFX_PRINTER_CHG_SIZE )); 1697 aMisc.SetPaperOrientationWarning(0 != (pFlag->GetValue() & SFX_PRINTER_CHG_ORIENTATION )); 1698 } 1699 // ------------------------------------------------------------------------- 1700 // evaluate help options 1701 // ------------------------------------------------------------------------- 1702 if ( SvtHelpOptions().IsHelpTips() != Help::IsQuickHelpEnabled() ) 1703 SvtHelpOptions().IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp(); 1704 if ( SvtHelpOptions().IsExtendedHelp() != Help::IsBalloonHelpEnabled() ) 1705 SvtHelpOptions().IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp(); 1706 } 1707 break; 1708 case SID_LANGUAGE_OPTIONS : 1709 { 1710 OfaTreeOptionsDialog::ApplyLanguageOptions(rSet); 1711 } 1712 break; 1713 case SID_INET_DLG : 1714 case SID_FILTER_DLG: 1715 SFX_APP()->SetOptions( rSet ); 1716 break; 1717 1718 case SID_SB_STARBASEOPTIONS: 1719 ::offapp::ConnectionPoolConfig::SetOptions( rSet ); 1720 ::svx::DbRegisteredNamesConfig::SetOptions(rSet); 1721 break; 1722 1723 case SID_SCH_EDITOPTIONS: 1724 // nothing to do. Chart options only apply to newly created charts 1725 break; 1726 1727 default: 1728 { 1729 DBG_ERROR( "Unhandled option in ApplyItemSet" ); 1730 } 1731 break; 1732 } 1733 1734 } 1735 void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet) 1736 { 1737 sal_Bool bSaveSpellCheck = sal_False; 1738 const SfxPoolItem* pItem; 1739 1740 if ( SFX_ITEM_SET == rSet.GetItemState( SID_SPELL_MODIFIED, sal_False, &pItem ) ) 1741 { 1742 bSaveSpellCheck = ( (const SfxBoolItem*)pItem )->GetValue(); 1743 } 1744 Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); 1745 Reference< XPropertySet > xProp( 1746 xMgr->createInstance( ::rtl::OUString::createFromAscii( 1747 "com.sun.star.linguistic2.LinguProperties") ), 1748 UNO_QUERY ); 1749 if ( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_HYPHENREGION, sal_False, &pItem ) ) 1750 { 1751 const SfxHyphenRegionItem* pHyphenItem = (const SfxHyphenRegionItem*)pItem; 1752 1753 if (xProp.is()) 1754 { 1755 xProp->setPropertyValue( 1756 String::CreateFromAscii(UPN_HYPH_MIN_LEADING), 1757 makeAny((sal_Int16) pHyphenItem->GetMinLead()) ); 1758 xProp->setPropertyValue( 1759 String::CreateFromAscii(UPN_HYPH_MIN_TRAILING), 1760 makeAny((sal_Int16) pHyphenItem->GetMinTrail()) ); 1761 } 1762 bSaveSpellCheck = sal_True; 1763 } 1764 1765 SfxViewFrame *pViewFrame = SfxViewFrame::Current(); 1766 if ( pViewFrame ) 1767 { 1768 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); 1769 pItem = 0; 1770 if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_LANGUAGE, sal_False, &pItem )) 1771 { 1772 pDispatch->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L); 1773 bSaveSpellCheck = sal_True; 1774 } 1775 if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE, sal_False, &pItem )) 1776 { 1777 pDispatch->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L); 1778 bSaveSpellCheck = sal_True; 1779 } 1780 if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE, sal_False, &pItem )) 1781 { 1782 pDispatch->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L); 1783 bSaveSpellCheck = sal_True; 1784 } 1785 1786 if( SFX_ITEM_SET == rSet.GetItemState(SID_AUTOSPELL_CHECK, sal_False, &pItem )) 1787 { 1788 sal_Bool bOnlineSpelling = ((const SfxBoolItem*)pItem)->GetValue(); 1789 pDispatch->Execute(SID_AUTOSPELL_CHECK, 1790 SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD, pItem, 0L); 1791 1792 if (xProp.is()) 1793 { 1794 xProp->setPropertyValue( 1795 String::CreateFromAscii(UPN_IS_SPELL_AUTO), 1796 makeAny(bOnlineSpelling) ); 1797 } 1798 } 1799 1800 if( bSaveSpellCheck ) 1801 { 1802 //! the config item has changed since we modified the 1803 //! property set it uses 1804 pDispatch->Execute(SID_SPELLCHECKER_CHANGED, SFX_CALLMODE_ASYNCHRON); 1805 } 1806 } 1807 1808 if( SFX_ITEM_SET == rSet.GetItemState(SID_OPT_LOCALE_CHANGED, sal_False, &pItem )) 1809 { 1810 SfxViewFrame* _pViewFrame = SfxViewFrame::GetFirst(); 1811 while ( _pViewFrame ) 1812 { 1813 _pViewFrame->GetDispatcher()->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L); 1814 _pViewFrame = SfxViewFrame::GetNext( *_pViewFrame ); 1815 } 1816 } 1817 } 1818 1819 rtl::OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame ) 1820 { 1821 rtl::OUString sIdentifier; 1822 Reference < XFrame > xCurrentFrame( _xFrame ); 1823 Reference < XModuleManager > xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance( 1824 DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY ); 1825 if ( !xCurrentFrame.is() ) 1826 { 1827 Reference< XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( 1828 DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY ); 1829 if ( xDesktop.is() ) 1830 xCurrentFrame = xDesktop->getCurrentFrame(); 1831 } 1832 1833 if ( xCurrentFrame.is() && xModuleManager.is() ) 1834 { 1835 try 1836 { 1837 sIdentifier = xModuleManager->identify( xCurrentFrame ); 1838 } 1839 catch ( ::com::sun::star::frame::UnknownModuleException& ) 1840 { 1841 DBG_WARNING( "getActiveModule_Impl(): unknown module" ); 1842 } 1843 catch ( Exception& ) 1844 { 1845 DBG_ERRORFILE( "getActiveModule_Impl(): exception of XModuleManager::identify()" ); 1846 } 1847 } 1848 1849 return sIdentifier; 1850 } 1851 1852 void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) 1853 { 1854 OfaPageResource aDlgResource; 1855 sal_uInt16 nGroup = 0; 1856 1857 SvtOptionsDialogOptions aOptionsDlgOpt; 1858 sal_uInt16 i, nPageId; 1859 1860 // %PRODUCTNAME options 1861 sal_Bool isSSOEnabled = EnableSSO(); 1862 if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS, aOptionsDlgOpt ) ) 1863 { 1864 ResStringArray& rGeneralArray = aDlgResource.GetGeneralArray(); 1865 setGroupName( C2U("ProductName"), rGeneralArray.GetString(0) ); 1866 nGroup = AddGroup( rGeneralArray.GetString(0), 0, 0, SID_GENERAL_OPTIONS ); 1867 sal_uInt16 nEnd = static_cast< sal_uInt16 >( rGeneralArray.Count() ); 1868 String sPageTitle; 1869 1870 for ( i = 1; i < nEnd; ++i ) 1871 { 1872 String sNewTitle = rGeneralArray.GetString(i); 1873 nPageId = (sal_uInt16)rGeneralArray.GetValue(i); 1874 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 1875 continue; 1876 1877 // Disable Online Update page if service not installed 1878 if( RID_SVXPAGE_ONLINEUPDATE == nPageId ) 1879 { 1880 const ::rtl::OUString sService = C2U("com.sun.star.setup.UpdateCheck"); 1881 1882 try 1883 { 1884 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 1885 Reference < XInterface > xService( xFactory->createInstance( sService ) ); 1886 1887 if( ! xService.is() ) 1888 continue; 1889 } 1890 catch ( ::com::sun::star::loader::CannotActivateFactoryException& ) 1891 { 1892 continue; 1893 } 1894 } 1895 // Disable OOoImprovement page if not enabled 1896 if( RID_SVXPAGE_IMPROVEMENT == nPageId ) 1897 { 1898 continue; 1899 } 1900 if ( nPageId != RID_SVXPAGE_SSO || isSSOEnabled ) 1901 { 1902 AddTabPage( nPageId, sNewTitle, nGroup ); 1903 } 1904 } 1905 // private iteration hack for Improvement Program 1906 // hack for OOo 3.1 1907 // should not be in found in any later release 1908 for(bool bOnce = false; bOnce==false; bOnce=true) 1909 { 1910 String sNewTitle = C2U("Improvement Program"); 1911 { 1912 SvxImprovementPage aTempTabPage(this); 1913 sNewTitle = aTempTabPage.GetTitleText(); 1914 } 1915 nPageId = RID_SVXPAGE_IMPROVEMENT; 1916 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 1917 continue; 1918 // Disable OOoImprovement page if not enabled 1919 { 1920 const ::rtl::OUString sService = C2U("com.sun.star.oooimprovement.CoreController"); 1921 try 1922 { 1923 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 1924 Reference < ::com::sun::star::oooimprovement::XCoreController > xService( xFactory->createInstance( sService ), UNO_QUERY ); 1925 1926 if( ! xService.is() ) 1927 continue; 1928 if( ! xService->showBuiltinOptionsPage(1)) 1929 continue; 1930 } 1931 catch ( ::com::sun::star::loader::CannotActivateFactoryException& ) 1932 { 1933 continue; 1934 } 1935 } 1936 if ( nPageId != RID_SVXPAGE_SSO || isSSOEnabled ) 1937 { 1938 AddTabPage( nPageId, sNewTitle, nGroup ); 1939 } 1940 } 1941 } 1942 1943 // Load and Save options 1944 if ( !lcl_isOptionHidden( SID_FILTER_DLG, aOptionsDlgOpt ) ) 1945 { 1946 ResStringArray& rFilterArray = aDlgResource.GetFilterArray(); 1947 setGroupName( C2U("LoadSave"), rFilterArray.GetString(0) ); 1948 nGroup = AddGroup( rFilterArray.GetString(0), 0, 0, SID_FILTER_DLG ); 1949 for ( i = 1; i < rFilterArray.Count(); ++i ) 1950 { 1951 nPageId = (sal_uInt16)rFilterArray.GetValue(i); 1952 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 1953 AddTabPage( nPageId, rFilterArray.GetString(i), nGroup ); 1954 } 1955 } 1956 1957 // Language options 1958 SvtLanguageOptions aLanguageOptions; 1959 if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS, aOptionsDlgOpt ) ) 1960 { 1961 ResStringArray& rLangArray = aDlgResource.GetLangArray(); 1962 setGroupName( C2U("LanguageSettings"), rLangArray.GetString(0) ); 1963 nGroup = AddGroup( rLangArray.GetString(0), 0, 0, SID_LANGUAGE_OPTIONS ); 1964 for ( i = 1; i < rLangArray.Count(); ++i ) 1965 { 1966 nPageId = (sal_uInt16)rLangArray.GetValue(i); 1967 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 1968 continue; 1969 if ( ( RID_SVXPAGE_JSEARCH_OPTIONS != nPageId || aLanguageOptions.IsJapaneseFindEnabled() ) && 1970 ( RID_SVXPAGE_ASIAN_LAYOUT != nPageId || aLanguageOptions.IsAsianTypographyEnabled() ) && 1971 ( RID_SVXPAGE_OPTIONS_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) ) 1972 AddTabPage( nPageId, rLangArray.GetString(i), nGroup ); 1973 } 1974 } 1975 1976 1977 rtl::OUString aFactory = getCurrentFactory_Impl( _xFrame ); 1978 rtl::OUString sTemp = GetModuleIdentifier( comphelper::getProcessServiceFactory(), _xFrame ); 1979 DBG_ASSERT( sTemp == aFactory, "S H I T!!!" ); 1980 1981 // Writer and Writer/Web options 1982 sal_Bool bHasAnyFilter = sal_False; 1983 SvtModuleOptions aModuleOpt; 1984 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) 1985 { 1986 // Textdokument 1987 bHasAnyFilter = sal_True; 1988 ResStringArray& rTextArray = aDlgResource.GetTextArray(); 1989 if ( aFactory.equalsAscii( "com.sun.star.text.TextDocument" ) 1990 || aFactory.equalsAscii( "com.sun.star.text.WebDocument" ) 1991 || aFactory.equalsAscii( "com.sun.star.text.GlobalDocument" ) ) 1992 { 1993 SfxModule* pSwMod = (*(SfxModule**) GetAppData(SHL_WRITER)); 1994 if ( !lcl_isOptionHidden( SID_SW_EDITOPTIONS, aOptionsDlgOpt ) ) 1995 { 1996 if ( aFactory.equalsAscii( "com.sun.star.text.WebDocument" ) ) 1997 setGroupName( C2U("WriterWeb"), rTextArray.GetString(0) ); 1998 else 1999 setGroupName( C2U("Writer"), rTextArray.GetString(0) ); 2000 nGroup = AddGroup(rTextArray.GetString(0), pSwMod, pSwMod, SID_SW_EDITOPTIONS ); 2001 for ( i = 1; i < rTextArray.Count(); ++i ) 2002 { 2003 nPageId = (sal_uInt16)rTextArray.GetValue(i); 2004 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 2005 continue; 2006 if ( ( RID_SW_TP_STD_FONT_CJK != nPageId || aLanguageOptions.IsCJKFontEnabled() ) && 2007 ( RID_SW_TP_STD_FONT_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) && 2008 ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfg_Impl().IsEmailSupported() ) ) 2009 AddTabPage( nPageId, rTextArray.GetString(i), nGroup ); 2010 } 2011 #ifdef DBG_UTIL 2012 AddTabPage( RID_SW_TP_OPTTEST_PAGE, String::CreateFromAscii("Interner Test"), nGroup ); 2013 #endif 2014 } 2015 2016 // HTML-Dokument 2017 if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS, aOptionsDlgOpt ) ) 2018 { 2019 ResStringArray& rHTMLArray = aDlgResource.GetHTMLArray(); 2020 nGroup = AddGroup(rHTMLArray.GetString(0), pSwMod, pSwMod, SID_SW_ONLINEOPTIONS ); 2021 for( i = 1; i < rHTMLArray.Count(); ++i ) 2022 { 2023 nPageId = (sal_uInt16)rHTMLArray.GetValue(i); 2024 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 2025 AddTabPage( nPageId, rHTMLArray.GetString(i), nGroup ); 2026 } 2027 #ifdef DBG_UTIL 2028 AddTabPage( RID_SW_TP_OPTTEST_PAGE, String::CreateFromAscii("Interner Test"), nGroup ); 2029 #endif 2030 } 2031 } 2032 } 2033 2034 // Calc options 2035 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) 2036 { 2037 bHasAnyFilter = sal_True; 2038 if ( aFactory.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" )) 2039 { 2040 if ( !lcl_isOptionHidden( SID_SC_EDITOPTIONS, aOptionsDlgOpt ) ) 2041 { 2042 ResStringArray& rCalcArray = aDlgResource.GetCalcArray(); 2043 SfxModule* pScMod = ( *( SfxModule** ) GetAppData( SHL_CALC ) ); 2044 setGroupName( C2U("Calc"), rCalcArray.GetString(0) ); 2045 nGroup = AddGroup( rCalcArray.GetString( 0 ), pScMod, pScMod, SID_SC_EDITOPTIONS ); 2046 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rCalcArray.Count() ); 2047 for ( i = 1; i < nCount; ++i ) 2048 { 2049 nPageId = (sal_uInt16)rCalcArray.GetValue(i); 2050 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 2051 continue; 2052 // if( bCTL || nId != RID_OFA_TP_INTERNATIONAL ) 2053 // #103755# if an international tabpage is need one day, this should be used again... ;-) 2054 if ( nPageId != RID_OFA_TP_INTERNATIONAL ) 2055 AddTabPage( nPageId, rCalcArray.GetString( i ), nGroup ); 2056 } 2057 } 2058 } 2059 } 2060 2061 // Impress options 2062 SfxModule* pSdMod = ( *( SfxModule** ) GetAppData( SHL_DRAW ) ); 2063 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) 2064 { 2065 bHasAnyFilter = sal_True; 2066 if ( aFactory.equalsAscii( "com.sun.star.presentation.PresentationDocument" )) 2067 { 2068 if ( !lcl_isOptionHidden( SID_SD_EDITOPTIONS, aOptionsDlgOpt ) ) 2069 { 2070 ResStringArray& rImpressArray = aDlgResource.GetImpressArray(); 2071 setGroupName( C2U("Impress"), rImpressArray.GetString(0) ); 2072 nGroup = AddGroup( rImpressArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_EDITOPTIONS ); 2073 const sal_Bool bCTL = aLanguageOptions.IsCTLFontEnabled(); 2074 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rImpressArray.Count() ); 2075 for ( i = 1; i < nCount; ++i ) 2076 { 2077 nPageId = (sal_uInt16)rImpressArray.GetValue(i); 2078 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 2079 continue; 2080 if ( bCTL || nPageId != RID_OFA_TP_INTERNATIONAL_IMPR ) 2081 AddTabPage( nPageId, rImpressArray.GetString(i), nGroup ); 2082 } 2083 } 2084 } 2085 } 2086 2087 // Draw options 2088 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) 2089 { 2090 if ( aFactory.equalsAscii( "com.sun.star.drawing.DrawingDocument" )) 2091 { 2092 if ( !lcl_isOptionHidden( SID_SD_GRAPHIC_OPTIONS, aOptionsDlgOpt ) ) 2093 { 2094 ResStringArray& rDrawArray = aDlgResource.GetDrawArray(); 2095 setGroupName( C2U("Draw"), rDrawArray.GetString(0) ); 2096 nGroup = AddGroup( rDrawArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS ); 2097 const sal_Bool bCTL = aLanguageOptions.IsCTLFontEnabled(); 2098 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rDrawArray.Count() ); 2099 for ( i = 1; i < nCount; ++i ) 2100 { 2101 nPageId = (sal_uInt16)rDrawArray.GetValue(i); 2102 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 2103 continue; 2104 if ( bCTL || nPageId != RID_OFA_TP_INTERNATIONAL_SD ) 2105 AddTabPage( nPageId, rDrawArray.GetString(i), nGroup ); 2106 } 2107 } 2108 } 2109 } 2110 2111 // Math options 2112 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) ) 2113 { 2114 if ( aFactory.equalsAscii( "com.sun.star.formula.FormulaProperties" )) 2115 { 2116 if ( !lcl_isOptionHidden( SID_SM_EDITOPTIONS, aOptionsDlgOpt ) ) 2117 { 2118 ResStringArray& rStarMathArray = aDlgResource.GetStarMathArray(); 2119 SfxModule* pSmMod = (*(SfxModule**) GetAppData(SHL_SM)); 2120 setGroupName( C2U("Math"), rStarMathArray.GetString(0) ); 2121 nGroup = AddGroup(rStarMathArray.GetString(0), pSmMod, pSmMod, SID_SM_EDITOPTIONS ); 2122 for ( i = 1; i < rStarMathArray.Count(); ++i ) 2123 { 2124 nPageId = (sal_uInt16)rStarMathArray.GetValue(i); 2125 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 2126 AddTabPage( nPageId, rStarMathArray.GetString(i), nGroup ); 2127 } 2128 } 2129 } 2130 } 2131 2132 // Database - needed only if there is an application which integrates with databases 2133 if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS, aOptionsDlgOpt ) && 2134 ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) 2135 || aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) 2136 || aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) 2137 ) ) 2138 { 2139 ResStringArray& rDSArray = aDlgResource.GetDatasourcesArray(); 2140 setGroupName( C2U("Base"), rDSArray.GetString(0) ); 2141 nGroup = AddGroup( rDSArray.GetString(0), 0, NULL, SID_SB_STARBASEOPTIONS ); 2142 for ( i = 1; i < rDSArray.Count(); ++i ) 2143 { 2144 nPageId = (sal_uInt16)rDSArray.GetValue(i); 2145 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 2146 AddTabPage( nPageId, rDSArray.GetString(i), nGroup ); 2147 } 2148 } 2149 2150 // Chart options (always installed and active) 2151 if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS, aOptionsDlgOpt ) ) 2152 { 2153 ResStringArray& rChartArray = aDlgResource.GetChartArray(); 2154 setGroupName( C2U("Charts"), rChartArray.GetString(0) ); 2155 nGroup = AddGroup( rChartArray.GetString(0), 0, 0, SID_SCH_EDITOPTIONS ); 2156 for ( i = 1; i < rChartArray.Count(); ++i ) 2157 { 2158 nPageId = (sal_uInt16)rChartArray.GetValue(i); 2159 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 2160 AddTabPage( nPageId, rChartArray.GetString(i), nGroup ); 2161 } 2162 } 2163 2164 // Internet options 2165 if ( !lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) ) 2166 { 2167 ResStringArray& rInetArray = aDlgResource.GetInetArray(); 2168 setGroupName( C2U("Internet"), rInetArray.GetString(0) ); 2169 nGroup = AddGroup(rInetArray.GetString(0), 0, 0, SID_INET_DLG ); 2170 2171 for ( i = 1; i < rInetArray.Count(); ++i ) 2172 { 2173 nPageId = (sal_uInt16)rInetArray.GetValue(i); 2174 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) 2175 continue; 2176 #if defined WNT 2177 // Disable E-mail tab-page on Windows 2178 if ( nPageId == RID_SVXPAGE_INET_MAIL ) 2179 continue; 2180 #endif 2181 #if defined MACOSX 2182 // Disable Mozilla Plug-in tab-page on Mac 2183 if ( nPageId == RID_SVXPAGE_INET_MOZPLUGIN ) 2184 continue; 2185 #endif 2186 #ifdef LINUX 2187 // Disable Mozilla Plug-in tab-page on Linux if we find a 2188 // globally installed plugin 2189 if ( nPageId == RID_SVXPAGE_INET_MOZPLUGIN ) { 2190 struct stat sb; 2191 char *p; 2192 bool bHaveSystemWidePlugin = false; 2193 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"; 2194 2195 p = strtok(mozpaths, ":"); 2196 while (p != NULL) { 2197 if (stat(p, &sb) != -1) { 2198 bHaveSystemWidePlugin = true; 2199 break; 2200 } 2201 p = strtok(NULL, ":"); 2202 } 2203 2204 if (bHaveSystemWidePlugin == true) 2205 continue; 2206 } 2207 #endif 2208 AddTabPage( nPageId, rInetArray.GetString(i), nGroup ); 2209 } 2210 } 2211 2212 /*!!! 2213 ResizeTreeLB(); 2214 ActivateLastSelection(); 2215 */ 2216 } 2217 2218 namespace 2219 { 2220 void MoveControl( Control& _rCtrl, long _nDeltaPixel ) 2221 { 2222 Point aPt( _rCtrl.GetPosPixel() ); 2223 aPt.X() += _nDeltaPixel; 2224 _rCtrl.SetPosPixel( aPt ); 2225 } 2226 } 2227 2228 void OfaTreeOptionsDialog::ResizeTreeLB( void ) 2229 { 2230 const long nMax = aHiddenGB.GetSizePixel().Width() * 42 / 100; 2231 // don't ask where 42 comes from... but it looks / feels ok ;-) 2232 long nDelta = 50; // min. 2233 sal_uInt16 nDepth = 0; 2234 const long nIndent0 = PixelToLogic( Size( 28, 0 ) ).Width(); 2235 const long nIndent1 = PixelToLogic( Size( 52, 0 ) ).Width(); 2236 2237 SvTreeList* pTreeList = aTreeLB.GetModel(); 2238 DBG_ASSERT( pTreeList, "-OfaTreeOptionsDialog::ResizeTreeLB(): no model, no cookies!" ); 2239 2240 SvListEntry* pEntry = pTreeList->First(); 2241 while( pEntry ) 2242 { 2243 long n = aTreeLB.GetTextWidth( aTreeLB.GetEntryText( static_cast< SvLBoxEntry* >( pEntry ) ) ); 2244 n += ( nDepth == 0 )? nIndent0 : nIndent1; 2245 2246 if( n > nDelta ) 2247 nDelta = n; 2248 2249 pEntry = pTreeList->Next( pEntry, &nDepth ); 2250 } 2251 2252 nDelta = LogicToPixel( Size( nDelta + 3, 0 ) ).Width(); // + extra space [logic] 2253 nDelta += GetSettings().GetStyleSettings().GetScrollBarSize(); // + scroll bar, in case it's needed 2254 2255 if( nDelta > nMax ) 2256 nDelta = nMax; 2257 2258 // starting resizing with this 2259 Size aSize( GetSizePixel() ); 2260 aSize.Width() += nDelta; 2261 SetSizePixel( aSize ); 2262 2263 // resize treelistbox 2264 aSize = aTreeLB.GetSizePixel(); 2265 aSize.Width() += nDelta; 2266 aTreeLB.SetSizePixel( aSize ); 2267 2268 // ... and move depending controls 2269 MoveControl( aOkPB, nDelta ); 2270 MoveControl( aCancelPB, nDelta ); 2271 MoveControl( aHelpPB, nDelta ); 2272 MoveControl( aBackPB, nDelta ); 2273 MoveControl( aHiddenGB, nDelta ); 2274 MoveControl( aPageTitleFT, nDelta ); 2275 MoveControl( aLine1FL, nDelta ); 2276 MoveControl( aHelpFT, nDelta ); 2277 MoveControl( aHelpImg, nDelta ); 2278 } 2279 2280 bool isNodeActive( OptionsNode* pNode, Module* pModule ) 2281 { 2282 if ( pNode ) 2283 { 2284 // Node for all modules actine? 2285 if ( pNode->m_bAllModules ) 2286 return true; 2287 2288 // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted 2289 if ( getGroupName( pNode->m_sId, false ).Len() > 0 ) 2290 return true; 2291 2292 // no module -> not active 2293 if ( !pModule ) 2294 return false; 2295 2296 // search node in active module 2297 if ( pModule->m_bActive ) 2298 { 2299 for ( sal_uInt32 j = 0; j < pModule->m_aNodeList.size(); ++j ) 2300 if ( pModule->m_aNodeList[j]->m_sId == pNode->m_sId ) 2301 return true; 2302 } 2303 } 2304 return false; 2305 } 2306 2307 void OfaTreeOptionsDialog::LoadExtensionOptions( const rtl::OUString& rExtensionId ) 2308 { 2309 Module* pModule = NULL; 2310 Reference< XMultiServiceFactory > xMSFac = comphelper::getProcessServiceFactory(); 2311 // open optionsdialog.xcu 2312 Reference< XNameAccess > xRoot( 2313 ::comphelper::ConfigurationHelper::openConfig( 2314 xMSFac, C2U("org.openoffice.Office.OptionsDialog"), 2315 ::comphelper::ConfigurationHelper::E_READONLY ), UNO_QUERY ); 2316 DBG_ASSERT( xRoot.is(), "OfaTreeOptionsDialog::LoadExtensionOptions(): no config" ); 2317 // when called by Tools - Options then load nodes of active module 2318 if ( rExtensionId.getLength() == 0 ) 2319 pModule = LoadModule( GetModuleIdentifier( xMSFac, Reference< XFrame >() ), xRoot ); 2320 2321 VectorOfNodes aNodeList; 2322 LoadNodes( xRoot, pModule, rExtensionId, aNodeList ); 2323 InsertNodes( aNodeList ); 2324 } 2325 2326 rtl::OUString OfaTreeOptionsDialog::GetModuleIdentifier( 2327 const Reference< XMultiServiceFactory >& xMFac, const Reference< XFrame >& rFrame ) 2328 { 2329 rtl::OUString sModule; 2330 Reference < XFrame > xCurrentFrame( rFrame ); 2331 Reference < XModuleManager > xModuleManager( xMFac->createInstance( 2332 C2U("com.sun.star.frame.ModuleManager") ), UNO_QUERY ); 2333 2334 if ( !xCurrentFrame.is() ) 2335 { 2336 Reference < XDesktop > xDesktop( xMFac->createInstance( 2337 C2U("com.sun.star.frame.Desktop") ), UNO_QUERY ); 2338 if ( xDesktop.is() ) 2339 xCurrentFrame = xDesktop->getCurrentFrame(); 2340 } 2341 2342 if ( xCurrentFrame.is() && xModuleManager.is() ) 2343 { 2344 try 2345 { 2346 sModule = xModuleManager->identify( xCurrentFrame ); 2347 } 2348 catch ( ::com::sun::star::frame::UnknownModuleException& ) 2349 { 2350 DBG_WARNING( "OfaTreeOptionsDialog::GetModuleIdentifier(): unknown module" ); 2351 } 2352 catch ( Exception& ) 2353 { 2354 DBG_ERRORFILE( "OfaTreeOptionsDialog::GetModuleIdentifier(): exception of XModuleManager::identify()" ); 2355 } 2356 } 2357 return sModule; 2358 } 2359 2360 Module* OfaTreeOptionsDialog::LoadModule( 2361 const rtl::OUString& rModuleIdentifier, const Reference< XNameAccess >& xRoot ) 2362 { 2363 Module* pModule = NULL; 2364 Reference< XNameAccess > xSet; 2365 2366 if ( xRoot->hasByName( C2U("Modules") ) ) 2367 { 2368 xRoot->getByName( C2U("Modules") ) >>= xSet; 2369 if ( xSet.is() ) 2370 { 2371 Sequence< rtl::OUString > seqNames = xSet->getElementNames(); 2372 for ( int i = 0; i < seqNames.getLength(); ++i ) 2373 { 2374 rtl::OUString sModule( seqNames[i] ); 2375 if ( rModuleIdentifier == sModule ) 2376 { 2377 // current active module found 2378 pModule = new Module( sModule ); 2379 pModule->m_bActive = true; 2380 2381 Reference< XNameAccess > xModAccess; 2382 xSet->getByName( seqNames[i] ) >>= xModAccess; 2383 if ( xModAccess.is() ) 2384 { 2385 // load the nodes of this module 2386 Reference< XNameAccess > xNodeAccess; 2387 xModAccess->getByName( C2U("Nodes") ) >>= xNodeAccess; 2388 if ( xNodeAccess.is() ) 2389 { 2390 Sequence< rtl::OUString > xTemp = xNodeAccess->getElementNames(); 2391 Reference< XNameAccess > xAccess; 2392 sal_Int32 nIndex = -1; 2393 for ( int x = 0; x < xTemp.getLength(); ++x ) 2394 { 2395 xNodeAccess->getByName( xTemp[x] ) >>= xAccess; 2396 if ( xAccess.is() ) 2397 { 2398 xAccess->getByName( C2U("Index") ) >>= nIndex; 2399 if ( nIndex < 0 ) 2400 // append nodes with index < 0 2401 pModule->m_aNodeList.push_back( 2402 new OrderedEntry( nIndex, xTemp[x] ) ); 2403 else 2404 { 2405 // search position of the node 2406 sal_uInt32 y = 0; 2407 for ( ; y < pModule->m_aNodeList.size(); ++y ) 2408 { 2409 sal_Int32 nNodeIdx = pModule->m_aNodeList[y]->m_nIndex; 2410 if ( nNodeIdx < 0 || nNodeIdx > nIndex ) 2411 break; 2412 } 2413 // and insert the node on this position 2414 pModule->m_aNodeList.insert( 2415 pModule->m_aNodeList.begin() + y, 2416 new OrderedEntry( nIndex, xTemp[x] ) ); 2417 } 2418 } 2419 } 2420 } 2421 } 2422 } 2423 } 2424 } 2425 } 2426 return pModule; 2427 } 2428 2429 void OfaTreeOptionsDialog::LoadNodes( 2430 const Reference< XNameAccess >& xRoot, Module* pModule, 2431 const rtl::OUString& rExtensionId, VectorOfNodes& rOutNodeList ) 2432 { 2433 Reference< XNameAccess > xSet; 2434 if ( xRoot->hasByName( C2U("Nodes") ) ) 2435 { 2436 xRoot->getByName( C2U("Nodes") ) >>= xSet; 2437 if ( xSet.is() ) 2438 { 2439 VectorOfNodes aNodeList; 2440 Sequence< rtl::OUString > seqNames = xSet->getElementNames(); 2441 2442 for ( int i = 0; i < seqNames.getLength(); ++i ) 2443 { 2444 String sGroupName( seqNames[i] ); 2445 Reference< XNameAccess > xNodeAccess; 2446 xSet->getByName( seqNames[i] ) >>= xNodeAccess; 2447 2448 if ( xNodeAccess.is() ) 2449 { 2450 rtl::OUString sNodeId, sLabel, sPageURL, sGroupId; 2451 bool bAllModules = false; 2452 sal_Int32 nGroupIndex = 0; 2453 2454 sNodeId = seqNames[i]; 2455 xNodeAccess->getByName( C2U("Label") ) >>= sLabel; 2456 xNodeAccess->getByName( C2U("OptionsPage") ) >>= sPageURL; 2457 xNodeAccess->getByName( C2U("AllModules") ) >>= bAllModules; 2458 xNodeAccess->getByName( C2U("GroupId") ) >>= sGroupId; 2459 xNodeAccess->getByName( C2U("GroupIndex") ) >>= nGroupIndex; 2460 2461 if ( sLabel.getLength() == 0 ) 2462 sLabel = sGroupName; 2463 String sTemp = getGroupName( sLabel, rExtensionId.getLength() > 0 ); 2464 if ( sTemp.Len() > 0 ) 2465 sLabel = sTemp; 2466 OptionsNode* pNode = 2467 new OptionsNode( sNodeId, sLabel, sPageURL, bAllModules, sGroupId, nGroupIndex ); 2468 2469 if ( !rExtensionId.getLength() && !isNodeActive( pNode, pModule ) ) 2470 { 2471 delete pNode; 2472 continue; 2473 } 2474 2475 Reference< XNameAccess > xLeavesSet; 2476 xNodeAccess->getByName( C2U( "Leaves" ) ) >>= xLeavesSet; 2477 if ( xLeavesSet.is() ) 2478 { 2479 Sequence< rtl::OUString > seqLeaves = xLeavesSet->getElementNames(); 2480 for ( int j = 0; j < seqLeaves.getLength(); ++j ) 2481 { 2482 Reference< XNameAccess > xLeaveAccess; 2483 xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess; 2484 2485 if ( xLeaveAccess.is() ) 2486 { 2487 rtl::OUString sId, sLeafLabel, sEventHdl, sLeafURL, sLeafGrpId; 2488 sal_Int32 nLeafGrpIdx = 0; 2489 2490 xLeaveAccess->getByName( C2U("Id") ) >>= sId; 2491 xLeaveAccess->getByName( C2U("Label") ) >>= sLeafLabel; 2492 xLeaveAccess->getByName( C2U("OptionsPage") ) >>= sLeafURL; 2493 xLeaveAccess->getByName( C2U("EventHandlerService") ) >>= sEventHdl; 2494 xLeaveAccess->getByName( C2U("GroupId") ) >>= sLeafGrpId; 2495 xLeaveAccess->getByName( C2U("GroupIndex") ) >>= nLeafGrpIdx; 2496 2497 if ( !rExtensionId.getLength() || sId == rExtensionId ) 2498 { 2499 OptionsLeaf* pLeaf = new OptionsLeaf( 2500 sId, sLeafLabel, sLeafURL, sEventHdl, sLeafGrpId, nLeafGrpIdx ); 2501 2502 if ( sLeafGrpId.getLength() > 0 ) 2503 { 2504 bool bAlreadyOpened = false; 2505 if ( pNode->m_aGroupedLeaves.size() > 0 ) 2506 { 2507 for ( sal_uInt32 k = 0; 2508 k < pNode->m_aGroupedLeaves.size(); ++k ) 2509 { 2510 if ( pNode->m_aGroupedLeaves[k].size() > 0 && 2511 pNode->m_aGroupedLeaves[k][0]->m_sGroupId 2512 == sLeafGrpId ) 2513 { 2514 sal_uInt32 l = 0; 2515 for ( ; l < pNode->m_aGroupedLeaves[k].size(); ++l ) 2516 { 2517 if ( pNode->m_aGroupedLeaves[k][l]-> 2518 m_nGroupIndex >= nLeafGrpIdx ) 2519 break; 2520 } 2521 pNode->m_aGroupedLeaves[k].insert( 2522 pNode->m_aGroupedLeaves[k].begin() + l, pLeaf ); 2523 bAlreadyOpened = true; 2524 break; 2525 } 2526 } 2527 } 2528 if ( !bAlreadyOpened ) 2529 { 2530 VectorOfLeaves aGroupedLeaves; 2531 aGroupedLeaves.push_back( pLeaf ); 2532 pNode->m_aGroupedLeaves.push_back( aGroupedLeaves ); 2533 } 2534 } 2535 else 2536 pNode->m_aLeaves.push_back( 2537 new OptionsLeaf( 2538 sId, sLeafLabel, sLeafURL, 2539 sEventHdl, sLeafGrpId, nLeafGrpIdx ) ); 2540 } 2541 } 2542 } 2543 } 2544 2545 // do not insert nodes without leaves 2546 if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 ) 2547 { 2548 pModule ? aNodeList.push_back( pNode ) : rOutNodeList.push_back( pNode ); 2549 } 2550 } 2551 } 2552 2553 if ( pModule && aNodeList.size() > 0 ) 2554 { 2555 sal_uInt32 i = 0, j = 0; 2556 for ( ; i < pModule->m_aNodeList.size(); ++i ) 2557 { 2558 rtl::OUString sNodeId = pModule->m_aNodeList[i]->m_sId; 2559 for ( j = 0; j < aNodeList.size(); ++j ) 2560 { 2561 OptionsNode* pNode = aNodeList[j]; 2562 if ( pNode->m_sId == sNodeId ) 2563 { 2564 rOutNodeList.push_back( pNode ); 2565 aNodeList.erase( aNodeList.begin() + j ); 2566 break; 2567 } 2568 } 2569 } 2570 2571 for ( i = 0; i < aNodeList.size(); ++i ) 2572 rOutNodeList.push_back( aNodeList[i] ); 2573 } 2574 } 2575 } 2576 } 2577 2578 sal_uInt16 lcl_getGroupId( const rtl::OUString& rGroupName, const SvTreeListBox& rTreeLB ) 2579 { 2580 String sGroupName( rGroupName ); 2581 sal_uInt16 nRet = 0; 2582 SvLBoxEntry* pEntry = rTreeLB.First(); 2583 while( pEntry ) 2584 { 2585 if ( !rTreeLB.GetParent( pEntry ) ) 2586 { 2587 String sTemp( rTreeLB.GetEntryText( pEntry ) ); 2588 if ( sTemp == sGroupName ) 2589 return nRet; 2590 nRet++; 2591 } 2592 pEntry = rTreeLB.Next( pEntry ); 2593 } 2594 2595 return USHRT_MAX; 2596 } 2597 2598 void lcl_insertLeaf( 2599 OfaTreeOptionsDialog* pDlg, OptionsNode* pNode, OptionsLeaf* pLeaf, const SvTreeListBox& rTreeLB ) 2600 { 2601 sal_uInt16 nGrpId = lcl_getGroupId( pNode->m_sLabel, rTreeLB ); 2602 if ( USHRT_MAX == nGrpId ) 2603 { 2604 sal_uInt16 nNodeGrpId = getGroupNodeId( pNode->m_sId ); 2605 nGrpId = pDlg->AddGroup( pNode->m_sLabel, NULL, NULL, nNodeGrpId ); 2606 if ( pNode->m_sPageURL.getLength() > 0 ) 2607 { 2608 SvLBoxEntry* pGrpEntry = rTreeLB.GetEntry( 0, nGrpId ); 2609 DBG_ASSERT( pGrpEntry, "OfaTreeOptionsDialog::InsertNodes(): no group" ); 2610 if ( pGrpEntry ) 2611 { 2612 OptionsGroupInfo* pGrpInfo = 2613 static_cast<OptionsGroupInfo*>(pGrpEntry->GetUserData()); 2614 pGrpInfo->m_sPageURL = pNode->m_sPageURL; 2615 } 2616 } 2617 } 2618 OptionsPageInfo* pInfo = pDlg->AddTabPage( 0, pLeaf->m_sLabel, nGrpId ); 2619 pInfo->m_sPageURL = pLeaf->m_sPageURL; 2620 pInfo->m_sEventHdl = pLeaf->m_sEventHdl; 2621 } 2622 2623 void OfaTreeOptionsDialog::InsertNodes( const VectorOfNodes& rNodeList ) 2624 { 2625 for ( sal_uInt32 i = 0; i < rNodeList.size(); ++i ) 2626 { 2627 OptionsNode* pNode = rNodeList[i]; 2628 2629 if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 ) 2630 { 2631 sal_uInt32 j = 0; 2632 for ( ; j < pNode->m_aGroupedLeaves.size(); ++j ) 2633 { 2634 for ( sal_uInt32 k = 0; k < pNode->m_aGroupedLeaves[j].size(); ++k ) 2635 { 2636 OptionsLeaf* pLeaf = pNode->m_aGroupedLeaves[j][k]; 2637 lcl_insertLeaf( this, pNode, pLeaf, aTreeLB ); 2638 } 2639 } 2640 2641 for ( j = 0; j < pNode->m_aLeaves.size(); ++j ) 2642 { 2643 OptionsLeaf* pLeaf = pNode->m_aLeaves[j]; 2644 lcl_insertLeaf( this, pNode, pLeaf, aTreeLB ); 2645 } 2646 } 2647 } 2648 } 2649 2650 short OfaTreeOptionsDialog::Execute() 2651 { 2652 ::std::auto_ptr< SvxDicListChgClamp > pClamp; 2653 if ( !bIsFromExtensionManager ) 2654 { 2655 // collect all DictionaryList Events while the dialog is executed 2656 Reference<com::sun::star::linguistic2::XDictionaryList> xDictionaryList(SvxGetDictionaryList()); 2657 pClamp = ::std::auto_ptr< SvxDicListChgClamp >( new SvxDicListChgClamp( xDictionaryList ) ); 2658 } 2659 short nRet = SfxModalDialog::Execute(); 2660 2661 if( RET_OK == nRet ) 2662 { 2663 ApplyItemSets(); 2664 if( GetColorTable() ) 2665 { 2666 GetColorTable()->Save(); 2667 2668 // notify current viewframe it it uses the same color table 2669 if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() ) 2670 { 2671 const OfaPtrItem* pPtr = (const OfaPtrItem*)SfxViewFrame::Current()->GetDispatcher()->Execute( SID_GET_COLORTABLE, SFX_CALLMODE_SYNCHRON ); 2672 if( pPtr ) 2673 { 2674 XColorTable* _pColorTab = (XColorTable*)pPtr->GetValue(); 2675 2676 if( _pColorTab && 2677 _pColorTab->GetPath() == GetColorTable()->GetPath() && 2678 _pColorTab->GetName() == GetColorTable()->GetName() ) 2679 SfxObjectShell::Current()->PutItem( SvxColorTableItem( GetColorTable(), SID_COLOR_TABLE ) ); 2680 } 2681 } 2682 } 2683 2684 utl::ConfigManager::GetConfigManager()->StoreConfigItems(); 2685 } 2686 2687 return nRet; 2688 } 2689 2690 // class ExtensionsTabPage ----------------------------------------------- 2691 2692 ExtensionsTabPage::ExtensionsTabPage( 2693 Window* pParent, WinBits nStyle, const rtl::OUString& rPageURL, 2694 const rtl::OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) : 2695 2696 TabPage( pParent, nStyle ), 2697 2698 m_sPageURL ( rPageURL ), 2699 m_sEventHdl ( rEvtHdl ), 2700 m_xWinProvider ( rProvider ), 2701 m_bIsWindowHidden ( false ) 2702 2703 { 2704 } 2705 2706 // ----------------------------------------------------------------------- 2707 2708 ExtensionsTabPage::~ExtensionsTabPage() 2709 { 2710 Hide(); 2711 DeactivatePage(); 2712 } 2713 2714 // ----------------------------------------------------------------------- 2715 2716 void ExtensionsTabPage::CreateDialogWithHandler() 2717 { 2718 try 2719 { 2720 bool bWithHandler = ( m_sEventHdl.getLength() > 0 ); 2721 if ( bWithHandler ) 2722 { 2723 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 2724 m_xEventHdl = Reference< awt::XContainerWindowEventHandler >( 2725 xFactory->createInstance( m_sEventHdl ), UNO_QUERY ); 2726 } 2727 2728 if ( !bWithHandler || m_xEventHdl.is() ) 2729 { 2730 SetStyle( GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL ); 2731 Reference< awt::XWindowPeer > xParent( VCLUnoHelper::GetInterface( this ), UNO_QUERY ); 2732 m_xPage = Reference < awt::XWindow >( 2733 m_xWinProvider->createContainerWindow( 2734 m_sPageURL, rtl::OUString(), xParent, m_xEventHdl ), UNO_QUERY ); 2735 2736 Reference< awt::XControl > xPageControl( m_xPage, UNO_QUERY ); 2737 if ( xPageControl.is() ) 2738 { 2739 Reference< awt::XWindowPeer > xWinPeer( xPageControl->getPeer() ); 2740 if ( xWinPeer.is() ) 2741 { 2742 Window* pWindow = VCLUnoHelper::GetWindow( xWinPeer ); 2743 if ( pWindow ) 2744 pWindow->SetStyle( pWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL ); 2745 } 2746 } 2747 } 2748 } 2749 catch ( ::com::sun::star::lang::IllegalArgumentException& ) 2750 { 2751 DBG_ERRORFILE( "ExtensionsTabPage::CreateDialogWithHandler(): illegal argument" ); 2752 } 2753 catch ( Exception& ) 2754 { 2755 DBG_ERRORFILE( "ExtensionsTabPage::CreateDialogWithHandler(): exception of XDialogProvider2::createDialogWithHandler()" ); 2756 } 2757 } 2758 2759 // ----------------------------------------------------------------------- 2760 2761 sal_Bool ExtensionsTabPage::DispatchAction( const rtl::OUString& rAction ) 2762 { 2763 sal_Bool bRet = sal_False; 2764 if ( m_xEventHdl.is() ) 2765 { 2766 try 2767 { 2768 bRet = m_xEventHdl->callHandlerMethod( m_xPage, makeAny( rAction ), C2U("external_event") ); 2769 } 2770 catch ( Exception& ) 2771 { 2772 DBG_ERRORFILE( "ExtensionsTabPage::DispatchAction(): exception of XDialogEventHandler::callHandlerMethod()" ); 2773 } 2774 } 2775 return bRet; 2776 } 2777 2778 // ----------------------------------------------------------------------- 2779 2780 void ExtensionsTabPage::ActivatePage() 2781 { 2782 TabPage::ActivatePage(); 2783 2784 if ( !m_xPage.is() ) 2785 { 2786 CreateDialogWithHandler(); 2787 2788 if ( m_xPage.is() ) 2789 { 2790 Point aPos = Point(); 2791 Size aSize = GetSizePixel(); 2792 m_xPage->setPosSize( aPos.X() + 1, aPos.Y() + 1, 2793 aSize.Width() - 2, aSize.Height() - 2, awt::PosSize::POSSIZE ); 2794 if ( m_sEventHdl.getLength() > 0 ) 2795 DispatchAction( C2U("initialize") ); 2796 } 2797 } 2798 2799 if ( m_xPage.is() ) 2800 { 2801 m_xPage->setVisible( sal_True ); 2802 m_bIsWindowHidden = false; 2803 } 2804 } 2805 2806 // ----------------------------------------------------------------------- 2807 2808 void ExtensionsTabPage::DeactivatePage() 2809 { 2810 TabPage::DeactivatePage(); 2811 2812 if ( m_xPage.is() ) 2813 m_xPage->setVisible( sal_False ); 2814 } 2815 2816 // ----------------------------------------------------------------------- 2817 2818 void ExtensionsTabPage::ResetPage() 2819 { 2820 DispatchAction( C2U("back") ); 2821 ActivatePage(); 2822 } 2823 2824 // ----------------------------------------------------------------------- 2825 2826 void ExtensionsTabPage::SavePage() 2827 { 2828 DispatchAction( C2U("ok") ); 2829 } 2830