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 #ifdef SW_DLLIMPLEMENTATION 32 #undef SW_DLLIMPLEMENTATION 33 #endif 34 35 36 37 38 #include <hintids.hxx> 39 40 #include <tools/pstm.hxx> 41 42 #define _SVSTDARR_LONGSSORT 43 #define _SVSTDARR_LONGS 44 #include <svl/svstdarr.hxx> 45 #include <editeng/paperinf.hxx> 46 #ifndef _SVX_TSTPITEM_HXX //autogen 47 #include <editeng/tstpitem.hxx> 48 #endif 49 #include <editeng/lrspitem.hxx> 50 #include <editeng/brshitem.hxx> 51 #ifndef _MSGBOX_HXX //autogen 52 #include <vcl/msgbox.hxx> 53 #endif 54 #ifndef _MENU_HXX //autogen 55 #include <vcl/menu.hxx> 56 #endif 57 58 #ifndef _CMDID_H 59 #include <cmdid.h> 60 #endif 61 #include <frmatr.hxx> 62 #include <swtypes.hxx> 63 #include <wrtsh.hxx> 64 #ifndef _VIEW_HXX 65 #include <view.hxx> 66 #endif 67 #ifndef _BASESH_HXX 68 #include <basesh.hxx> 69 #endif 70 #include <drpcps.hxx> 71 #include <envfmt.hxx> 72 #include <fmtcol.hxx> 73 #ifndef _PARDLG_HXX 74 #include "swuipardlg.hxx" 75 #endif 76 #include <pattern.hxx> 77 #include <poolfmt.hxx> 78 #include <uiborder.hxx> 79 #include <uitool.hxx> 80 81 #ifndef _ENVFMT_HRC 82 #include <envfmt.hrc> 83 #endif 84 85 #include "swabstdlg.hxx" 86 #include "chrdlg.hrc" 87 88 namespace swui 89 { 90 SwAbstractDialogFactory * GetFactory(); 91 } 92 93 static PopupMenu *pMenu; 94 static long lUserW = 5669; // 10 cm 95 static long lUserH = 5669; // 10 cm 96 97 // -------------------------------------------------------------------------- 98 99 100 SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet) : 101 102 SfxTabPage(pParent, SW_RES(TP_ENV_FMT), rSet), 103 104 aAddrFL (this, SW_RES( FL_ADDRESSEE )), 105 aAddrPosInfo (this, SW_RES( TXT_ADDR_POS )), 106 aAddrLeftText (this, SW_RES( TXT_ADDR_LEFT )), 107 aAddrLeftField (this, SW_RES( FLD_ADDR_LEFT )), 108 aAddrTopText (this, SW_RES( TXT_ADDR_TOP )), 109 aAddrTopField (this, SW_RES( FLD_ADDR_TOP )), 110 aAddrFormatInfo (this, SW_RES( TXT_ADDR_FORMAT )), 111 aAddrEditButton (this, SW_RES( BTN_ADDR_EDIT )), 112 aSendFL (this, SW_RES( FL_SENDER )), 113 aSendPosInfo (this, SW_RES( TXT_SEND_POS )), 114 aSendLeftText (this, SW_RES( TXT_SEND_LEFT )), 115 aSendLeftField (this, SW_RES( FLD_SEND_LEFT )), 116 aSendTopText (this, SW_RES( TXT_SEND_TOP )), 117 aSendTopField (this, SW_RES( FLD_SEND_TOP )), 118 aSendFormatInfo (this, SW_RES( TXT_SEND_FORMAT )), 119 aSendEditButton (this, SW_RES( BTN_SEND_EDIT )), 120 aSizeFL (this, SW_RES( FL_SIZE )), 121 aSizeFormatText (this, SW_RES( TXT_SIZE_FORMAT )), 122 aSizeFormatBox (this, SW_RES( BOX_SIZE_FORMAT )), 123 aSizeWidthText (this, SW_RES( TXT_SIZE_WIDTH )), 124 aSizeWidthField (this, SW_RES( FLD_SIZE_WIDTH )), 125 aSizeHeightText (this, SW_RES( TXT_SIZE_HEIGHT )), 126 aSizeHeightField (this, SW_RES( FLD_SIZE_HEIGHT )), 127 aPreview (this, SW_RES( WIN_PREVIEW )) 128 129 { 130 FreeResource(); 131 SetExchangeSupport(); 132 133 // Metriken 134 FieldUnit aMetric = ::GetDfltMetric(sal_False); 135 SetMetric(aAddrLeftField, aMetric); 136 SetMetric(aAddrTopField, aMetric); 137 SetMetric(aSendLeftField, aMetric); 138 SetMetric(aSendTopField, aMetric); 139 SetMetric(aSizeWidthField, aMetric); 140 SetMetric(aSizeHeightField, aMetric); 141 142 // Menues einhaengen 143 ::pMenu = new PopupMenu(SW_RES(MNU_EDIT)); 144 aAddrEditButton.SetPopupMenu(::pMenu); 145 aSendEditButton.SetPopupMenu(::pMenu); 146 147 // Handler installieren 148 Link aLk = LINK(this, SwEnvFmtPage, ModifyHdl); 149 aAddrLeftField .SetUpHdl( aLk ); 150 aAddrTopField .SetUpHdl( aLk ); 151 aSendLeftField .SetUpHdl( aLk ); 152 aSendTopField .SetUpHdl( aLk ); 153 aSizeWidthField .SetUpHdl( aLk ); 154 aSizeHeightField.SetUpHdl( aLk ); 155 156 aAddrLeftField .SetDownHdl( aLk ); 157 aAddrTopField .SetDownHdl( aLk ); 158 aSendLeftField .SetDownHdl( aLk ); 159 aSendTopField .SetDownHdl( aLk ); 160 aSizeWidthField .SetDownHdl( aLk ); 161 aSizeHeightField.SetDownHdl( aLk ); 162 163 aAddrLeftField .SetLoseFocusHdl( aLk ); 164 aAddrTopField .SetLoseFocusHdl( aLk ); 165 aSendLeftField .SetLoseFocusHdl( aLk ); 166 aSendTopField .SetLoseFocusHdl( aLk ); 167 aSizeWidthField .SetLoseFocusHdl( aLk ); 168 aSizeHeightField.SetLoseFocusHdl( aLk ); 169 170 aLk = LINK(this, SwEnvFmtPage, EditHdl ); 171 aAddrEditButton.SetSelectHdl( aLk ); 172 aSendEditButton.SetSelectHdl( aLk ); 173 174 aPreview.SetBorderStyle( WINDOW_BORDER_MONO ); 175 176 aSizeFormatBox .SetSelectHdl(LINK(this, SwEnvFmtPage, FormatHdl)); 177 178 // aSizeFormatBox 179 for (sal_uInt16 i = PAPER_A3; i <= PAPER_KAI32BIG; i++) 180 { 181 if (i != PAPER_USER) 182 { 183 String aPaperName = SvxPaperInfo::GetName((Paper) i), 184 aEntryName; 185 186 sal_uInt16 nPos = 0; 187 sal_Bool bFound = sal_False; 188 while (nPos < aSizeFormatBox.GetEntryCount() && !bFound) 189 { 190 aEntryName = aSizeFormatBox.GetEntry(i); 191 if (aEntryName < aPaperName) 192 nPos++; 193 else 194 bFound = sal_True; 195 } 196 aSizeFormatBox.InsertEntry(aPaperName, nPos); 197 aIDs.Insert((sal_uInt16) i, nPos); 198 } 199 } 200 aSizeFormatBox.InsertEntry(SvxPaperInfo::GetName(PAPER_USER)); 201 aIDs.Insert((sal_uInt16) PAPER_USER, aIDs.Count()); 202 203 } 204 205 // -------------------------------------------------------------------------- 206 207 208 __EXPORT SwEnvFmtPage::~SwEnvFmtPage() 209 { 210 aAddrEditButton.SetPopupMenu(0); 211 aSendEditButton.SetPopupMenu(0); 212 delete ::pMenu; 213 } 214 215 // -------------------------------------------------------------------------- 216 217 218 IMPL_LINK_INLINE_START( SwEnvFmtPage, ModifyHdl, Edit *, pEdit ) 219 { 220 long lWVal = static_cast< long >(GetFldVal(aSizeWidthField )); 221 long lHVal = static_cast< long >(GetFldVal(aSizeHeightField)); 222 223 long lWidth = Max(lWVal, lHVal); 224 long lHeight = Min(lWVal, lHVal); 225 226 if (pEdit == &aSizeWidthField || pEdit == &aSizeHeightField) 227 { 228 Paper ePaper = SvxPaperInfo::GetSvxPaper( 229 Size(lHeight, lWidth), MAP_TWIP, sal_True); 230 for (sal_uInt16 i = 0; i < aIDs.Count(); i++) 231 if (aIDs[i] == (sal_uInt16)ePaper) 232 aSizeFormatBox.SelectEntryPos(i); 233 234 // Benutzergroesse merken 235 if (aIDs[aSizeFormatBox.GetSelectEntryPos()] == (sal_uInt16)PAPER_USER) 236 { 237 lUserW = lWidth ; 238 lUserH = lHeight; 239 } 240 241 aSizeFormatBox.GetSelectHdl().Call(&aSizeFormatBox); 242 } 243 else 244 { 245 FillItem(GetParent()->aEnvItem); 246 SetMinMax(); 247 aPreview.Invalidate(); 248 } 249 return 0; 250 } 251 IMPL_LINK_INLINE_END( SwEnvFmtPage, ModifyHdl, Edit *, pEdit ) 252 253 // -------------------------------------------------------------------------- 254 255 256 IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton ) 257 { 258 SwWrtShell* pSh = GetParent()->pSh; 259 ASSERT(pSh, "Shell fehlt"); 260 261 // Collection-Ptr ermitteln 262 sal_Bool bSender = pButton != &aAddrEditButton; 263 264 SwTxtFmtColl* pColl = pSh->GetTxtCollFromPool( static_cast< sal_uInt16 >( 265 bSender ? RES_POOLCOLL_SENDADRESS : RES_POOLCOLL_JAKETADRESS)); 266 ASSERT(pColl, "Text-Collection fehlt"); 267 268 switch (pButton->GetCurItemId()) 269 { 270 case MID_CHAR: 271 { 272 SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender); 273 274 // Damit die Hintergrundfarbe nicht uebergebuegelt wird: 275 SfxAllItemSet aTmpSet(*pCollSet); 276 277 // Das CHRATR_BACKGROUND-Attribut wird fuer den Dialog in 278 // ein RES_BACKGROUND verwandelt und wieder zurueck ... 279 const SfxPoolItem *pTmpBrush; 280 281 if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_CHRATR_BACKGROUND, 282 sal_True, &pTmpBrush ) ) 283 { 284 SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); 285 aTmpBrush.SetWhich( RES_BACKGROUND ); 286 aTmpSet.Put( aTmpBrush ); 287 } 288 else 289 aTmpSet.ClearItem( RES_BACKGROUND ); 290 291 SwAbstractDialogFactory* pFact = swui::GetFactory(); 292 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 293 294 SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( GetParent(), pSh->GetView(), aTmpSet, DLG_CHAR ,&pColl->GetName() ); 295 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 296 if (pDlg->Execute() == RET_OK) 297 { 298 SfxItemSet aOutputSet( *pDlg->GetOutputItemSet() ); 299 if( SFX_ITEM_SET == aOutputSet.GetItemState( RES_BACKGROUND, 300 sal_False, &pTmpBrush ) ) 301 { 302 SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); 303 aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); 304 pCollSet->Put( aTmpBrush ); 305 } 306 aOutputSet.ClearItem( RES_BACKGROUND ); 307 //pColl->SetAttr( aTmpSet ); 308 pCollSet->Put(aOutputSet); 309 } 310 delete pDlg; 311 } 312 break; 313 314 case MID_PARA: 315 { 316 SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender); 317 318 // Damit die Tabulatoren nicht uebergebuegelt werden: 319 SfxAllItemSet aTmpSet(*pCollSet); 320 321 // Tabulatoren, DefaultTabs ins ItemSet Stecken 322 const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&) 323 pSh->GetView().GetCurShell()->GetPool().GetDefaultItem(RES_PARATR_TABSTOP); 324 325 sal_uInt16 nDefDist = ::GetTabDist( rDefTabs ); 326 SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist ); 327 aTmpSet.Put( aDefDistItem ); 328 329 // Aktueller Tab 330 SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 ); 331 aTmpSet.Put( aTabPos ); 332 333 // linker Rand als Offset 334 const long nOff = ((SvxLRSpaceItem&)aTmpSet.Get( RES_LR_SPACE )). 335 GetTxtLeft(); 336 SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); 337 aTmpSet.Put( aOff ); 338 339 // BoxInfo setzen 340 ::PrepareBoxInfo( aTmpSet, *pSh ); 341 342 SwParaDlg *pDlg = new SwParaDlg(GetParent(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &pColl->GetName()); 343 344 if ( pDlg->Execute() == RET_OK ) 345 { 346 // Defaults evtl umsetzen 347 const SfxPoolItem* pItem = 0; 348 SfxItemSet* pOutputSet = (SfxItemSet*)pDlg->GetOutputItemSet(); 349 sal_uInt16 nNewDist; 350 if( SFX_ITEM_SET == pOutputSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS, 351 sal_False, &pItem ) && 352 nDefDist != (nNewDist = ((SfxUInt16Item*)pItem)->GetValue()) ) 353 { 354 SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ); 355 MakeDefTabs( nNewDist, aDefTabs ); 356 pSh->SetDefault( aDefTabs ); 357 pOutputSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS ); 358 } 359 if( pOutputSet->Count() ) 360 { 361 //pColl->SetAttr( *pOutputSet ); 362 pCollSet->Put(*pOutputSet); 363 } 364 } 365 delete pDlg; 366 } 367 break; 368 } 369 return 0; 370 } 371 372 /*------------------------------------------------------------------------ 373 Beschreibung: Ein temporaeres Itemset, das bei Abbruch verworfen wird 374 ------------------------------------------------------------------------*/ 375 376 SfxItemSet *SwEnvFmtPage::GetCollItemSet(SwTxtFmtColl* pColl, sal_Bool bSender) 377 { 378 SfxItemSet *&pAddrSet = bSender ? GetParent()->pSenderSet : GetParent()->pAddresseeSet; 379 380 if (!pAddrSet) 381 { 382 // Range ermitteln (Ranges beider Itemsets mergen) 383 const sal_uInt16 *pRanges = pColl->GetAttrSet().GetRanges(); 384 385 static sal_uInt16 __READONLY_DATA aRanges[] = 386 { 387 RES_PARATR_BEGIN, RES_PARATR_ADJUST, 388 RES_PARATR_TABSTOP, RES_PARATR_END-1, 389 RES_LR_SPACE, RES_UL_SPACE, 390 RES_BACKGROUND, RES_SHADOW, 391 SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS, 392 SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS, 393 SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET, 394 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 395 0, 0 396 }; 397 398 // BruteForce-Merge, weil MergeRange in SvTools buggy ist: 399 sal_uInt16 i = 0; 400 SvLongsSort aMergedRanges( 0, 10 ); 401 402 while (pRanges[i]) 403 { 404 for (sal_uInt16 nPos = pRanges[i]; nPos <= pRanges[i+1]; nPos++) 405 aMergedRanges.Insert(nPos); 406 i += 2; 407 } 408 409 i = 0; 410 411 while (aRanges[i]) 412 { 413 for (sal_uInt16 nPos = aRanges[i]; nPos <= aRanges[i+1]; nPos++) 414 aMergedRanges.Insert(nPos); 415 i += 2; 416 } 417 418 // Ranges kompaktieren 419 SvLongs aCompactedRanges( 0, 10 ); 420 421 aCompactedRanges.Insert(aMergedRanges[0], aCompactedRanges.Count()); 422 423 for (i = 0; i < aMergedRanges.Count(); i++) 424 { 425 while (i + 1 < aMergedRanges.Count() && 426 aMergedRanges[i+1] - aMergedRanges[i] == 1) 427 { 428 i++; 429 } 430 long nEnd = aMergedRanges[i]; 431 aCompactedRanges.Insert(nEnd, aCompactedRanges.Count()); 432 433 if (i + 1 < aMergedRanges.Count()) 434 { 435 long nStart = aMergedRanges[i+1]; 436 aCompactedRanges.Insert(nStart, aCompactedRanges.Count()); 437 } 438 } 439 440 // Neue Ranges erzeugen 441 sal_uInt16 *pNewRanges = new sal_uInt16[aCompactedRanges.Count() + 1]; 442 for (i = 0; i < aCompactedRanges.Count(); i++) 443 pNewRanges[i] = (sal_uInt16)aCompactedRanges[i]; 444 445 pNewRanges[i] = 0; 446 447 pAddrSet = new SfxItemSet(GetParent()->pSh->GetView().GetCurShell()->GetPool(), 448 pNewRanges); 449 450 pAddrSet->Put(pColl->GetAttrSet()); 451 delete[] pNewRanges; 452 } 453 454 return pAddrSet; 455 } 456 457 // -------------------------------------------------------------------------- 458 459 460 IMPL_LINK( SwEnvFmtPage, FormatHdl, ListBox *, EMPTYARG ) 461 { 462 long lWidth; 463 long lHeight; 464 long lSendFromLeft; 465 long lSendFromTop; 466 long lAddrFromLeft; 467 long lAddrFromTop; 468 469 sal_uInt16 nPaper = aIDs[aSizeFormatBox.GetSelectEntryPos()]; 470 if (nPaper != (sal_uInt16)PAPER_USER) 471 { 472 Size aSz = SvxPaperInfo::GetPaperSize((Paper)nPaper); 473 lWidth = Max(aSz.Width(), aSz.Height()); 474 lHeight = Min(aSz.Width(), aSz.Height()); 475 } 476 else 477 { 478 lWidth = lUserW; 479 lHeight = lUserH; 480 } 481 482 lSendFromLeft = 566; // 1cm 483 lSendFromTop = 566; // 1cm 484 lAddrFromLeft = lWidth / 2; 485 lAddrFromTop = lHeight / 2; 486 487 SetFldVal(aAddrLeftField, lAddrFromLeft); 488 SetFldVal(aAddrTopField , lAddrFromTop ); 489 SetFldVal(aSendLeftField, lSendFromLeft); 490 SetFldVal(aSendTopField , lSendFromTop ); 491 492 SetFldVal(aSizeWidthField , lWidth ); 493 SetFldVal(aSizeHeightField, lHeight); 494 495 SetMinMax(); 496 497 FillItem(GetParent()->aEnvItem); 498 aPreview.Invalidate(); 499 return 0; 500 } 501 502 // -------------------------------------------------------------------------- 503 504 505 void SwEnvFmtPage::SetMinMax() 506 { 507 long lWVal = static_cast< long >(GetFldVal(aSizeWidthField )); 508 long lHVal = static_cast< long >(GetFldVal(aSizeHeightField)); 509 510 long lWidth = Max(lWVal, lHVal), 511 lHeight = Min(lWVal, lHVal); 512 513 // Min und Max 514 aAddrLeftField.SetMin((long) 100 * (GetFldVal(aSendLeftField) + 566), FUNIT_TWIP); 515 aAddrLeftField.SetMax((long) 100 * (lWidth - 2 * 566), FUNIT_TWIP); 516 aAddrTopField .SetMin((long) 100 * (GetFldVal(aSendTopField ) + 2 * 566), FUNIT_TWIP); 517 aAddrTopField .SetMax((long) 100 * (lHeight - 2 * 566), FUNIT_TWIP); 518 aSendLeftField.SetMin((long) 100 * (566), FUNIT_TWIP); 519 aSendLeftField.SetMax((long) 100 * (GetFldVal(aAddrLeftField) - 566), FUNIT_TWIP); 520 aSendTopField .SetMin((long) 100 * (566), FUNIT_TWIP); 521 aSendTopField .SetMax((long) 100 * (GetFldVal(aAddrTopField ) - 2 * 566), FUNIT_TWIP); 522 523 // First und Last 524 aAddrLeftField.SetFirst(aAddrLeftField.GetMin()); 525 aAddrLeftField.SetLast (aAddrLeftField.GetMax()); 526 aAddrTopField .SetFirst(aAddrTopField .GetMin()); 527 aAddrTopField .SetLast (aAddrTopField .GetMax()); 528 aSendLeftField.SetFirst(aSendLeftField.GetMin()); 529 aSendLeftField.SetLast (aSendLeftField.GetMax()); 530 aSendTopField .SetFirst(aSendTopField .GetMin()); 531 aSendTopField .SetLast (aSendTopField .GetMax()); 532 533 // Fields neu formatieren 534 aAddrLeftField .Reformat(); 535 aAddrTopField .Reformat(); 536 aSendLeftField .Reformat(); 537 aSendTopField .Reformat(); 538 aSizeWidthField .Reformat(); 539 aSizeHeightField.Reformat(); 540 } 541 542 // -------------------------------------------------------------------------- 543 544 545 SfxTabPage* __EXPORT SwEnvFmtPage::Create(Window* pParent, const SfxItemSet& rSet) 546 { 547 return new SwEnvFmtPage(pParent, rSet); 548 } 549 550 // ---------------------------------------------------------------------------- 551 552 553 void __EXPORT SwEnvFmtPage::ActivatePage(const SfxItemSet& rSet) 554 { 555 SfxItemSet aSet(rSet); 556 aSet.Put(GetParent()->aEnvItem); 557 Reset(aSet); 558 } 559 560 // ---------------------------------------------------------------------------- 561 562 563 int __EXPORT SwEnvFmtPage::DeactivatePage(SfxItemSet* _pSet) 564 { 565 if( _pSet ) 566 FillItemSet(*_pSet); 567 return SfxTabPage::LEAVE_PAGE; 568 } 569 570 // -------------------------------------------------------------------------- 571 572 573 void SwEnvFmtPage::FillItem(SwEnvItem& rItem) 574 { 575 rItem.lAddrFromLeft = static_cast< sal_Int32 >(GetFldVal(aAddrLeftField)); 576 rItem.lAddrFromTop = static_cast< sal_Int32 >(GetFldVal(aAddrTopField )); 577 rItem.lSendFromLeft = static_cast< sal_Int32 >(GetFldVal(aSendLeftField)); 578 rItem.lSendFromTop = static_cast< sal_Int32 >(GetFldVal(aSendTopField )); 579 580 sal_uInt16 nPaper = aIDs[aSizeFormatBox.GetSelectEntryPos()]; 581 if (nPaper == (sal_uInt16)PAPER_USER) 582 { 583 long lWVal = static_cast< long >(GetFldVal(aSizeWidthField )); 584 long lHVal = static_cast< long >(GetFldVal(aSizeHeightField)); 585 rItem.lWidth = Max(lWVal, lHVal); 586 rItem.lHeight = Min(lWVal, lHVal); 587 } 588 else 589 { 590 long lWVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Width (); 591 long lHVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Height(); 592 rItem.lWidth = Max(lWVal, lHVal); 593 rItem.lHeight = Min(lWVal, lHVal); 594 } 595 } 596 597 // -------------------------------------------------------------------------- 598 599 600 sal_Bool __EXPORT SwEnvFmtPage::FillItemSet(SfxItemSet& rSet) 601 { 602 FillItem(GetParent()->aEnvItem); 603 rSet.Put(GetParent()->aEnvItem); 604 return sal_True; 605 } 606 607 // -------------------------------------------------------------------------- 608 609 610 void __EXPORT SwEnvFmtPage::Reset(const SfxItemSet& rSet) 611 { 612 const SwEnvItem& rItem = (const SwEnvItem&) rSet.Get(FN_ENVELOP); 613 614 Paper ePaper = SvxPaperInfo::GetSvxPaper( 615 Size( Min(rItem.lWidth, rItem.lHeight), 616 Max(rItem.lWidth, rItem.lHeight)), MAP_TWIP, sal_True); 617 for (sal_uInt16 i = 0; i < (sal_uInt16) aIDs.Count(); i++) 618 if (aIDs[i] == (sal_uInt16)ePaper) 619 aSizeFormatBox.SelectEntryPos(i); 620 621 // Die MetricFields 622 SetFldVal(aAddrLeftField, rItem.lAddrFromLeft); 623 SetFldVal(aAddrTopField , rItem.lAddrFromTop ); 624 SetFldVal(aSendLeftField, rItem.lSendFromLeft); 625 SetFldVal(aSendTopField , rItem.lSendFromTop ); 626 SetFldVal(aSizeWidthField , Max(rItem.lWidth, rItem.lHeight)); 627 SetFldVal(aSizeHeightField , Min(rItem.lWidth, rItem.lHeight)); 628 SetMinMax(); 629 630 DELETEZ(GetParent()->pSenderSet); 631 DELETEZ(GetParent()->pAddresseeSet); 632 } 633 634 635 636