1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #include <hintids.hxx> 33 34 #include <tools/datetime.hxx> 35 #include <vcl/svapp.hxx> 36 #include <unotools/collatorwrapper.hxx> 37 #include <svl/urihelper.hxx> 38 #include <svl/stritem.hxx> 39 #include <unotools/syslocale.hxx> 40 #include <sfx2/app.hxx> 41 #include <sfx2/docfile.hxx> 42 #include <sfx2/docfilt.hxx> 43 #include <editeng/pmdlitem.hxx> 44 #ifndef _SVX_TSTPITEM_HXX //autogen 45 #include <editeng/tstpitem.hxx> 46 #endif 47 #include <editeng/boxitem.hxx> 48 #include <editeng/sizeitem.hxx> 49 #include <svx/pageitem.hxx> 50 #include <editeng/lrspitem.hxx> 51 #include <svl/style.hxx> 52 #ifndef _VCL_LSTBOX_HXX //autogen 53 #include <vcl/lstbox.hxx> 54 #endif 55 #include <unotools/localedatawrapper.hxx> 56 #include <com/sun/star/frame/XDispatch.hpp> 57 #include <com/sun/star/frame/XDispatchProvider.hpp> 58 #include <com/sun/star/util/XURLTransformer.hpp> 59 #include <comphelper/processfactory.hxx> 60 #include <sfx2/viewfrm.hxx> 61 #include <fmtornt.hxx> 62 #include <tabcol.hxx> 63 #include <edtwin.hxx> 64 #include <fmtfsize.hxx> 65 #include <fmthdft.hxx> 66 #include <fmtpdsc.hxx> 67 #include <wview.hxx> 68 #include <uiitems.hxx> 69 #ifndef _DOCSH_HXX 70 #include <docsh.hxx> 71 #endif 72 #include <wrtsh.hxx> 73 #include <swmodule.hxx> 74 #ifndef _VIEW_HXX 75 #include <view.hxx> 76 #endif 77 #include <uitool.hxx> 78 #include <frmatr.hxx> 79 #include <paratr.hxx> 80 #include <fmtcol.hxx> 81 #include <poolfmt.hxx> 82 #include "usrpref.hxx" 83 84 #ifndef _ERROR_H 85 #include <error.h> 86 #endif 87 #ifndef _CMDID_H 88 #include <cmdid.h> 89 #endif 90 #ifndef _GLOBALS_HRC 91 #include <globals.hrc> 92 #endif 93 #ifndef _UTLUI_HRC 94 #include <utlui.hrc> 95 #endif 96 #include <doc.hxx> 97 #include <docary.hxx> 98 #include <charfmt.hxx> 99 #include <SwStyleNameMapper.hxx> 100 // 50 cm 28350 101 // 102 #define MAXHEIGHT 28350 103 #define MAXWIDTH 28350 104 105 using namespace ::com::sun::star; 106 /*-------------------------------------------------------------------- 107 Beschreibung: Allgemeine List von StringPointern 108 --------------------------------------------------------------------*/ 109 110 111 /*-------------------------------------------------------------------- 112 Beschreibung: Metric umschalten 113 --------------------------------------------------------------------*/ 114 115 116 void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit) 117 { 118 SwTwips nMin = static_cast< SwTwips >(rCtrl.GetMin(FUNIT_TWIP)); 119 SwTwips nMax = static_cast< SwTwips >(rCtrl.GetMax(FUNIT_TWIP)); 120 121 rCtrl.SetUnit(eUnit); 122 123 rCtrl.SetMin(nMin, FUNIT_TWIP); 124 rCtrl.SetMax(nMax, FUNIT_TWIP); 125 } 126 127 /*-------------------------------------------------------------------- 128 Beschreibung: Boxinfo-Attribut setzen 129 --------------------------------------------------------------------*/ 130 131 132 void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh) 133 { 134 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); 135 const SfxPoolItem *pBoxInfo; 136 if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER, 137 sal_True, &pBoxInfo)) 138 aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo; 139 140 // Tabellenvariante, wenn mehrere Tabellenzellen selektiert 141 rSh.GetCrsr(); //Damit GetCrsrCnt() auch das Richtige liefert 142 aBoxInfo.SetTable (rSh.IsTableMode() && rSh.GetCrsrCnt() > 1); 143 // Abstandsfeld immer anzeigen 144 aBoxInfo.SetDist ((sal_Bool) sal_True); 145 // Minimalgroesse in Tabellen und Absaetzen setzen 146 aBoxInfo.SetMinDist (rSh.IsTableMode() || rSh.GetSelectionType() & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL)); 147 // Default-Abstand immer setzen 148 aBoxInfo.SetDefDist (MIN_BORDER_DIST); 149 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben 150 aBoxInfo.SetValid(VALID_DISABLE, !rSh.IsTableMode()); 151 152 rSet.Put(aBoxInfo); 153 } 154 155 /*-------------------------------------------------------------------- 156 Beschreibung: Header Footer fuellen 157 --------------------------------------------------------------------*/ 158 159 160 void FillHdFt(SwFrmFmt* pFmt, const SfxItemSet& rSet) 161 { 162 SwAttrSet aSet(pFmt->GetAttrSet()); 163 aSet.Put(rSet); 164 165 const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE); 166 const SfxBoolItem& rDynamic = (const SfxBoolItem&)rSet.Get(SID_ATTR_PAGE_DYNAMIC); 167 168 // Groesse umsetzen 169 // 170 SwFmtFrmSize aFrmSize(rDynamic.GetValue() ? ATT_MIN_SIZE : ATT_FIX_SIZE, 171 rSize.GetSize().Width(), 172 rSize.GetSize().Height()); 173 aSet.Put(aFrmSize); 174 pFmt->SetFmtAttr(aSet); 175 } 176 177 /*-------------------------------------------------------------------- 178 Beschreibung: PageDesc <-> in Sets wandeln und zurueck 179 --------------------------------------------------------------------*/ 180 181 182 void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) 183 { 184 SwFrmFmt& rMaster = rPageDesc.GetMaster(); 185 186 // alle allgemeinen Rahmen-Attribute uebertragen 187 // 188 rMaster.SetFmtAttr(rSet); 189 190 // PageData 191 // 192 if(rSet.GetItemState(SID_ATTR_PAGE) == SFX_ITEM_SET) 193 { 194 const SvxPageItem& rPageItem = (const SvxPageItem&)rSet.Get(SID_ATTR_PAGE); 195 196 sal_uInt16 nUse = (sal_uInt16)rPageItem.GetPageUsage(); 197 if(nUse & 0x04) 198 nUse |= 0x03; 199 if(nUse) 200 rPageDesc.SetUseOn( (UseOnPage) nUse ); 201 rPageDesc.SetLandscape(rPageItem.IsLandscape()); 202 SvxNumberType aNumType; 203 aNumType.SetNumberingType( static_cast< sal_Int16 >(rPageItem.GetNumType()) ); 204 rPageDesc.SetNumType(aNumType); 205 } 206 // Groesse 207 // 208 if(rSet.GetItemState(SID_ATTR_PAGE_SIZE) == SFX_ITEM_SET) 209 { 210 const SvxSizeItem& rSizeItem = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE); 211 SwFmtFrmSize aSize(ATT_FIX_SIZE); 212 aSize.SetSize(rSizeItem.GetSize()); 213 rMaster.SetFmtAttr(aSize); 214 } 215 // Kopzeilen-Attribute auswerten 216 // 217 const SfxPoolItem* pItem; 218 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_HEADERSET, 219 sal_False, &pItem ) ) 220 { 221 const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet(); 222 const SfxBoolItem& rHeaderOn = (const SfxBoolItem&)rHeaderSet.Get(SID_ATTR_PAGE_ON); 223 224 if(rHeaderOn.GetValue()) 225 { 226 // Werte uebernehmen 227 if(!rMaster.GetHeader().IsActive()) 228 rMaster.SetFmtAttr(SwFmtHeader(sal_True)); 229 230 // Das Headerformat rausholen und anpassen 231 // 232 SwFmtHeader aHeaderFmt(rMaster.GetHeader()); 233 SwFrmFmt *pHeaderFmt = aHeaderFmt.GetHeaderFmt(); 234 ASSERT(pHeaderFmt != 0, "kein HeaderFormat"); 235 236 ::FillHdFt(pHeaderFmt, rHeaderSet); 237 238 rPageDesc.ChgHeaderShare(((const SfxBoolItem&) 239 rHeaderSet.Get(SID_ATTR_PAGE_SHARED)).GetValue()); 240 } 241 else 242 { // Header ausschalten 243 // 244 if(rMaster.GetHeader().IsActive()) 245 { 246 rMaster.SetFmtAttr(SwFmtHeader(sal_Bool(sal_False))); 247 rPageDesc.ChgHeaderShare(sal_False); 248 } 249 } 250 } 251 252 // Fusszeilen-Attribute auswerten 253 // 254 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_FOOTERSET, 255 sal_False, &pItem ) ) 256 { 257 const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet(); 258 const SfxBoolItem& rFooterOn = (const SfxBoolItem&)rFooterSet.Get(SID_ATTR_PAGE_ON); 259 260 if(rFooterOn.GetValue()) 261 { 262 // Werte uebernehmen 263 if(!rMaster.GetFooter().IsActive()) 264 rMaster.SetFmtAttr(SwFmtFooter(sal_True)); 265 266 // Das Footerformat rausholen und anpassen 267 // 268 SwFmtFooter aFooterFmt(rMaster.GetFooter()); 269 SwFrmFmt *pFooterFmt = aFooterFmt.GetFooterFmt(); 270 ASSERT(pFooterFmt != 0, "kein FooterFormat"); 271 272 ::FillHdFt(pFooterFmt, rFooterSet); 273 274 rPageDesc.ChgFooterShare(((const SfxBoolItem&) 275 rFooterSet.Get(SID_ATTR_PAGE_SHARED)).GetValue()); 276 } 277 else 278 { // Footer ausschalten 279 // 280 if(rMaster.GetFooter().IsActive()) 281 { 282 rMaster.SetFmtAttr(SwFmtFooter(sal_Bool(sal_False))); 283 rPageDesc.ChgFooterShare(sal_False); 284 } 285 } 286 } 287 288 // Fussnoten 289 // 290 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_FTN_INFO, 291 sal_False, &pItem ) ) 292 rPageDesc.SetFtnInfo( ((SwPageFtnInfoItem*)pItem)->GetPageFtnInfo() ); 293 294 295 // 296 // Columns 297 // 298 299 // Registerhaltigkeit 300 301 if(SFX_ITEM_SET == rSet.GetItemState( 302 SID_SWREGISTER_MODE, sal_False, &pItem)) 303 { 304 sal_Bool bSet = ((const SfxBoolItem*)pItem)->GetValue(); 305 if(!bSet) 306 rPageDesc.SetRegisterFmtColl(0); 307 else if(SFX_ITEM_SET == rSet.GetItemState( 308 SID_SWREGISTER_COLLECTION, sal_False, &pItem)) 309 { 310 const String& rColl = ((const SfxStringItem*)pItem)->GetValue(); 311 SwDoc& rDoc = *rMaster.GetDoc(); 312 SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( rColl ); 313 if( !pColl ) 314 { 315 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rColl, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); 316 if( USHRT_MAX != nId ) 317 pColl = rDoc.GetTxtCollFromPool( nId ); 318 else 319 pColl = rDoc.MakeTxtFmtColl( rColl, 320 (SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl() ); 321 } 322 if( pColl ) 323 pColl->SetFmtAttr( SwRegisterItem ( sal_True )); 324 rPageDesc.SetRegisterFmtColl( pColl ); 325 } 326 } 327 } 328 329 /*-------------------------------------------------------------------- 330 Beschreibung: 331 --------------------------------------------------------------------*/ 332 333 334 void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) 335 { 336 const SwFrmFmt& rMaster = rPageDesc.GetMaster(); 337 338 // Seitendaten 339 // 340 SvxPageItem aPageItem(SID_ATTR_PAGE); 341 aPageItem.SetDescName(rPageDesc.GetName()); 342 aPageItem.SetPageUsage(rPageDesc.GetUseOn()); 343 aPageItem.SetLandscape(rPageDesc.GetLandscape()); 344 aPageItem.SetNumType((SvxNumType)rPageDesc.GetNumType().GetNumberingType()); 345 rSet.Put(aPageItem); 346 347 // Groesse 348 SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, rMaster.GetFrmSize().GetSize()); 349 rSet.Put(aSizeItem); 350 351 // Maximale Groesse 352 SvxSizeItem aMaxSizeItem(SID_ATTR_PAGE_MAXSIZE, Size(MAXWIDTH, MAXHEIGHT)); 353 rSet.Put(aMaxSizeItem); 354 355 // Raender, Umrandung und das andere Zeug 356 // 357 rSet.Put(rMaster.GetAttrSet()); 358 359 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); 360 const SfxPoolItem *pBoxInfo; 361 if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER, 362 sal_True, &pBoxInfo) ) 363 aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo; 364 365 aBoxInfo.SetTable( sal_False ); 366 // Abstandsfeld immer anzeigen 367 aBoxInfo.SetDist( sal_True); 368 // Minimalgroesse in Tabellen und Absaetzen setzen 369 aBoxInfo.SetMinDist( sal_False ); 370 // Default-Abstand immer setzen 371 aBoxInfo.SetDefDist( MIN_BORDER_DIST ); 372 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben 373 aBoxInfo.SetValid( VALID_DISABLE ); 374 rSet.Put( aBoxInfo ); 375 376 377 SfxStringItem aFollow(SID_ATTR_PAGE_EXT1, aEmptyStr); 378 if(rPageDesc.GetFollow()) 379 aFollow.SetValue(rPageDesc.GetFollow()->GetName()); 380 rSet.Put(aFollow); 381 382 // Header 383 // 384 if(rMaster.GetHeader().IsActive()) 385 { 386 const SwFmtHeader &rHeaderFmt = rMaster.GetHeader(); 387 const SwFrmFmt *pHeaderFmt = rHeaderFmt.GetHeaderFmt(); 388 ASSERT(pHeaderFmt != 0, kein HeaderFormat.); 389 390 // HeaderInfo, Raender, Hintergrund, Umrandung 391 // 392 SfxItemSet aHeaderSet( *rSet.GetPool(), 393 SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED, 394 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 395 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 396 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 397 0); 398 399 // dynamische oder feste Hoehe 400 // 401 SfxBoolItem aOn(SID_ATTR_PAGE_ON, sal_True); 402 aHeaderSet.Put(aOn); 403 404 const SwFmtFrmSize &rFrmSize = pHeaderFmt->GetFrmSize(); 405 const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType(); 406 SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE); 407 aHeaderSet.Put(aDynamic); 408 409 // Links gleich rechts 410 // 411 SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsHeaderShared()); 412 aHeaderSet.Put(aShared); 413 414 // Groesse 415 SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize())); 416 aHeaderSet.Put(aSize); 417 418 // Rahmen-Attribute umschaufeln 419 // 420 aHeaderSet.Put(pHeaderFmt->GetAttrSet()); 421 aHeaderSet.Put( aBoxInfo ); 422 423 // SetItem erzeugen 424 // 425 SvxSetItem aSetItem(SID_ATTR_PAGE_HEADERSET, aHeaderSet); 426 rSet.Put(aSetItem); 427 } 428 429 // Footer 430 if(rMaster.GetFooter().IsActive()) 431 { 432 const SwFmtFooter &rFooterFmt = rMaster.GetFooter(); 433 const SwFrmFmt *pFooterFmt = rFooterFmt.GetFooterFmt(); 434 ASSERT(pFooterFmt != 0, kein FooterFormat.); 435 436 // FooterInfo, Raender, Hintergrund, Umrandung 437 // 438 SfxItemSet aFooterSet( *rSet.GetPool(), 439 SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED, 440 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 441 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 442 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 443 0); 444 445 // dynamische oder feste Hoehe 446 // 447 SfxBoolItem aOn(SID_ATTR_PAGE_ON, sal_True); 448 aFooterSet.Put(aOn); 449 450 const SwFmtFrmSize &rFrmSize = pFooterFmt->GetFrmSize(); 451 const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType(); 452 SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE); 453 aFooterSet.Put(aDynamic); 454 455 // Links gleich rechts 456 // 457 SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsFooterShared()); 458 aFooterSet.Put(aShared); 459 460 // Groesse 461 SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize())); 462 aFooterSet.Put(aSize); 463 464 // Rahmen-Attribute umschaufeln 465 // 466 aFooterSet.Put(pFooterFmt->GetAttrSet()); 467 aFooterSet.Put( aBoxInfo ); 468 469 // SetItem erzeugen 470 // 471 SvxSetItem aSetItem(SID_ATTR_PAGE_FOOTERSET, aFooterSet); 472 rSet.Put(aSetItem); 473 } 474 475 // Fussnoten einbauen 476 // 477 SwPageFtnInfo& rInfo = (SwPageFtnInfo&)rPageDesc.GetFtnInfo(); 478 SwPageFtnInfoItem aFtnItem(FN_PARAM_FTN_INFO, rInfo); 479 rSet.Put(aFtnItem); 480 481 // Registerhaltigkeit 482 483 const SwTxtFmtColl* pCol = rPageDesc.GetRegisterFmtColl(); 484 SwRegisterItem aReg(pCol != 0); 485 aReg.SetWhich(SID_SWREGISTER_MODE); 486 rSet.Put(aReg); 487 if(pCol) 488 rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, pCol->GetName())); 489 490 } 491 492 493 /*-------------------------------------------------------------------- 494 Beschreibung: DefaultTabs setzen 495 --------------------------------------------------------------------*/ 496 497 498 void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs) 499 { 500 if( rTabs.Count() ) 501 return; 502 { 503 SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT ); 504 rTabs.Insert( aSwTabStop ); 505 } 506 } 507 508 /*-------------------------------------------------------------------- 509 Beschreibung: Abstand zwischen zwei Tabs 510 --------------------------------------------------------------------*/ 511 512 513 sal_uInt16 GetTabDist(const SvxTabStopItem& rTabs) 514 { 515 sal_uInt16 nDefDist; 516 if( rTabs.Count() ) 517 nDefDist = (sal_uInt16)( rTabs[0].GetTabPos() ); 518 else 519 nDefDist = 1134; // 2cm 520 return nDefDist; 521 } 522 523 524 // erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese 525 void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet ) 526 { 527 const SfxPoolItem* pItem; 528 SwFmtPageDesc aPgDesc; 529 530 sal_Bool bChanged = sal_False; 531 // Seitennummer 532 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, sal_False, &pItem)) 533 { 534 aPgDesc.SetNumOffset(((SfxUInt16Item*)pItem)->GetValue()); 535 bChanged = sal_True; 536 } 537 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, sal_False, &pItem )) 538 { 539 const String& rDescName = ((SvxPageModelItem*)pItem)->GetValue(); 540 if( rDescName.Len() ) // kein Name -> PageDesc ausschalten! 541 { 542 // nur loeschen, wenn PageDesc eingschaltet wird! 543 rSet.ClearItem( RES_BREAK ); 544 SwPageDesc* pDesc = ((SwWrtShell&)rShell).FindPageDescByName( 545 rDescName, sal_True ); 546 if( pDesc ) 547 aPgDesc.RegisterToPageDesc( *pDesc ); 548 } 549 rSet.ClearItem( SID_ATTR_PARA_MODEL ); 550 bChanged = sal_True; 551 } 552 else 553 { 554 SfxItemSet aCoreSet(rShell.GetView().GetPool(), RES_PAGEDESC, RES_PAGEDESC ); 555 rShell.GetCurAttr( aCoreSet ); 556 if(SFX_ITEM_SET == aCoreSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) 557 { 558 if( ((SwFmtPageDesc*)pItem)->GetPageDesc() ) 559 { 560 aPgDesc.RegisterToPageDesc( *((SwFmtPageDesc*)pItem)->GetPageDesc() ); 561 } 562 } 563 } 564 565 566 if(bChanged) 567 rSet.Put( aPgDesc ); 568 } 569 570 571 // erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese 572 void SwToSfxPageDescAttr( SfxItemSet& rCoreSet ) 573 { 574 const SfxPoolItem* pItem = 0; 575 String aName; 576 sal_uInt16 nPageNum = 0; 577 sal_Bool bPut = sal_True; 578 switch( rCoreSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) 579 { 580 case SFX_ITEM_SET: 581 { 582 if( ((SwFmtPageDesc*)pItem)->GetPageDesc() ) 583 { 584 aName = ((SwFmtPageDesc*)pItem)->GetPageDesc()->GetName(); 585 nPageNum = ((SwFmtPageDesc*)pItem)->GetNumOffset(); 586 } 587 rCoreSet.ClearItem( RES_PAGEDESC ); 588 // Seitennummer 589 } 590 break; 591 592 case SFX_ITEM_AVAILABLE: 593 break; 594 595 default: 596 bPut = sal_False; 597 } 598 SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM, nPageNum ); 599 rCoreSet.Put( aPageNum ); 600 601 if(bPut) 602 rCoreSet.Put( SvxPageModelItem( aName, sal_True, SID_ATTR_PARA_MODEL ) ); 603 } 604 605 /*-------------------------------------------------------------------- 606 Beschreibung: Metric ermitteln 607 --------------------------------------------------------------------*/ 608 609 610 FieldUnit GetDfltMetric(sal_Bool bWeb) 611 { 612 return SW_MOD()->GetUsrPref(bWeb)->GetMetric(); 613 } 614 615 /*-------------------------------------------------------------------- 616 Beschreibung: Metric ermitteln 617 --------------------------------------------------------------------*/ 618 619 620 void SetDfltMetric( FieldUnit eMetric, sal_Bool bWeb ) 621 { 622 SW_MOD()->ApplyUserMetric(eMetric, bWeb); 623 } 624 625 /*-----------------09.04.98 16:58------------------- 626 627 --------------------------------------------------*/ 628 sal_uInt16 InsertStringSorted(const String& rEntry, ListBox& rToFill, sal_uInt16 nOffset ) 629 { 630 sal_uInt16 i = nOffset; 631 CollatorWrapper& rCaseColl = ::GetAppCaseCollator(); 632 633 for( ; i < rToFill.GetEntryCount(); i++ ) 634 { 635 if( 0 < rCaseColl.compareString( rToFill.GetEntry(i), rEntry )) 636 break; 637 } 638 return rToFill.InsertEntry(rEntry, i); 639 } 640 void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, sal_Bool bSorted, sal_Bool bWithDefault) 641 { 642 sal_Bool bHasOffset = rToFill.GetEntryCount() > 0; 643 SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool(); 644 pPool->SetSearchMask(SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL); 645 SwDoc* pDoc = pDocSh->GetDoc(); 646 const SfxStyleSheetBase* pBase = pPool->First(); 647 String sStandard; 648 SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sStandard ); 649 while(pBase) 650 { 651 if(bWithDefault || pBase->GetName() != sStandard) 652 { 653 sal_uInt16 nPos; 654 if(bSorted) 655 nPos = InsertStringSorted(pBase->GetName(), rToFill, bHasOffset ); 656 else 657 nPos = rToFill.InsertEntry(pBase->GetName()); 658 long nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( pBase->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); 659 rToFill.SetEntryData( nPos, (void*) (nPoolId)); 660 } 661 pBase = pPool->Next(); 662 } 663 // non-pool styles 664 const SwCharFmts* pFmts = pDoc->GetCharFmts(); 665 for(sal_uInt16 i = 0; i < pFmts->Count(); i++) 666 { 667 const SwCharFmt* pFmt = (*pFmts)[i]; 668 if(pFmt->IsDefault()) 669 continue; 670 const String& rName = pFmt->GetName(); 671 if(rToFill.GetEntryPos(rName) == LISTBOX_ENTRY_NOTFOUND) 672 { 673 sal_uInt16 nPos; 674 if(bSorted) 675 nPos = InsertStringSorted(rName, rToFill, bHasOffset ); 676 else 677 nPos = rToFill.InsertEntry(rName); 678 long nPoolId = USHRT_MAX; 679 rToFill.SetEntryData( nPos, (void*) (nPoolId)); 680 } 681 } 682 }; 683 684 /* -----------------27.04.98 08:26------------------- 685 * 686 * --------------------------------------------------*/ 687 SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, sal_uInt16 *pPercent, 688 SwWrtShell* pSh ) 689 { 690 //Die Breite zu besorgen ist etwas komplizierter. 691 SwTwips nWidth = 0; 692 const sal_Int16 eOri = pFmt->GetHoriOrient().GetHoriOrient(); 693 switch(eOri) 694 { 695 case text::HoriOrientation::FULL: nWidth = rCols.GetRight(); break; 696 case text::HoriOrientation::LEFT_AND_WIDTH: 697 case text::HoriOrientation::LEFT: 698 case text::HoriOrientation::RIGHT: 699 case text::HoriOrientation::CENTER: 700 nWidth = pFmt->GetFrmSize().GetWidth(); 701 break; 702 default: 703 { 704 if(pSh) 705 { 706 const SwFrmFmt *pFlyFmt; 707 if ( 0 == (pFlyFmt = pSh->GetFlyFrmFmt()) ) 708 { 709 nWidth = pSh->GetAnyCurRect(RECT_PAGE_PRT).Width(); 710 } 711 else 712 { 713 nWidth = pSh->GetAnyCurRect(RECT_FLY_PRT_EMBEDDED).Width(); 714 } 715 } 716 else 717 { 718 DBG_ERROR("wo soll die Breite denn herkommen?"); 719 } 720 const SvxLRSpaceItem& rLRSpace = pFmt->GetLRSpace(); 721 nWidth -= (rLRSpace.GetRight() + rLRSpace.GetLeft()); 722 } 723 } 724 if (pPercent) 725 *pPercent = pFmt->GetFrmSize().GetWidthPercent(); 726 return nWidth; 727 } 728 729 /*------------------------------------------------------------------------*/ 730 731 String GetAppLangDateTimeString( const DateTime& rDT ) 732 { 733 const SvtSysLocale aSysLocale; 734 const LocaleDataWrapper& rAppLclData = aSysLocale.GetLocaleData(); 735 String sRet( rAppLclData.getDate( rDT )); 736 ( sRet += ' ' ) += rAppLclData.getTime( rDT, sal_False, sal_False ); 737 return sRet; 738 } 739 740 /*-- 26.01.2006 08:06:33--------------------------------------------------- 741 742 -----------------------------------------------------------------------*/ 743 bool ExecuteMenuCommand( PopupMenu& rMenu, SfxViewFrame& rViewFrame, sal_uInt16 nId ) 744 { 745 bool bRet = false; 746 sal_uInt16 nItemCount = rMenu.GetItemCount(); 747 String sCommand; 748 for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem) 749 { 750 PopupMenu* pPopup = rMenu.GetPopupMenu( rMenu.GetItemId( nItem ) ); 751 if(pPopup) 752 { 753 sCommand = pPopup->GetItemCommand(nId); 754 if(sCommand.Len()) 755 break; 756 } 757 } 758 if(sCommand.Len()) 759 { 760 uno::Reference< frame::XFrame > xFrame = rViewFrame.GetFrame().GetFrameInterface(); 761 uno::Reference < frame::XDispatchProvider > xProv( xFrame, uno::UNO_QUERY ); 762 util::URL aURL; 763 aURL.Complete = sCommand; 764 uno::Reference < util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), uno::UNO_QUERY ); 765 xTrans->parseStrict( aURL ); 766 uno::Reference< frame::XDispatch > xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 ); 767 if( xDisp.is() ) 768 { 769 uno::Sequence< beans::PropertyValue > aSeq; 770 xDisp->dispatch( aURL, aSeq ); 771 bRet = true; 772 } 773 } 774 return bRet; 775 } 776