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