Update ooo320-m1
[ooovba.git] / sw / source / ui / envelp / envfmt.cxx
blobd10ceb30e515aa7fd0bea77bc48cc8dda7d2bf68
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: envfmt.cxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
36 #endif
41 #include <hintids.hxx>
43 #include <tools/pstm.hxx>
45 #define _SVSTDARR_LONGSSORT
46 #define _SVSTDARR_LONGS
47 #include <svtools/svstdarr.hxx>
48 #include <svx/paperinf.hxx>
49 #ifndef _SVX_TSTPITEM_HXX //autogen
50 #include <svx/tstpitem.hxx>
51 #endif
52 #include <svx/lrspitem.hxx>
53 #include <svx/brshitem.hxx>
54 #ifndef _MSGBOX_HXX //autogen
55 #include <vcl/msgbox.hxx>
56 #endif
57 #ifndef _MENU_HXX //autogen
58 #include <vcl/menu.hxx>
59 #endif
61 #ifndef _CMDID_H
62 #include <cmdid.h>
63 #endif
64 #include <frmatr.hxx>
65 #include <swtypes.hxx>
66 #include <wrtsh.hxx>
67 #ifndef _VIEW_HXX
68 #include <view.hxx>
69 #endif
70 #ifndef _BASESH_HXX
71 #include <basesh.hxx>
72 #endif
73 #include <drpcps.hxx>
74 #include <envfmt.hxx>
75 #include <fmtcol.hxx>
76 #ifndef _PARDLG_HXX
77 #include "swuipardlg.hxx"
78 #endif
79 #include <pattern.hxx>
80 #include <poolfmt.hxx>
81 #include <uiborder.hxx>
82 #include <uitool.hxx>
84 #ifndef _ENVFMT_HRC
85 #include <envfmt.hrc>
86 #endif
88 #include "swabstdlg.hxx"
89 #include "chrdlg.hrc"
91 namespace swui
93 SwAbstractDialogFactory * GetFactory();
96 static PopupMenu *pMenu;
97 static long lUserW = 5669; // 10 cm
98 static long lUserH = 5669; // 10 cm
100 // --------------------------------------------------------------------------
103 SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet) :
105 SfxTabPage(pParent, SW_RES(TP_ENV_FMT), rSet),
107 aAddrFL (this, SW_RES( FL_ADDRESSEE )),
108 aAddrPosInfo (this, SW_RES( TXT_ADDR_POS )),
109 aAddrLeftText (this, SW_RES( TXT_ADDR_LEFT )),
110 aAddrLeftField (this, SW_RES( FLD_ADDR_LEFT )),
111 aAddrTopText (this, SW_RES( TXT_ADDR_TOP )),
112 aAddrTopField (this, SW_RES( FLD_ADDR_TOP )),
113 aAddrFormatInfo (this, SW_RES( TXT_ADDR_FORMAT )),
114 aAddrEditButton (this, SW_RES( BTN_ADDR_EDIT )),
115 aSendFL (this, SW_RES( FL_SENDER )),
116 aSendPosInfo (this, SW_RES( TXT_SEND_POS )),
117 aSendLeftText (this, SW_RES( TXT_SEND_LEFT )),
118 aSendLeftField (this, SW_RES( FLD_SEND_LEFT )),
119 aSendTopText (this, SW_RES( TXT_SEND_TOP )),
120 aSendTopField (this, SW_RES( FLD_SEND_TOP )),
121 aSendFormatInfo (this, SW_RES( TXT_SEND_FORMAT )),
122 aSendEditButton (this, SW_RES( BTN_SEND_EDIT )),
123 aSizeFL (this, SW_RES( FL_SIZE )),
124 aSizeFormatText (this, SW_RES( TXT_SIZE_FORMAT )),
125 aSizeFormatBox (this, SW_RES( BOX_SIZE_FORMAT )),
126 aSizeWidthText (this, SW_RES( TXT_SIZE_WIDTH )),
127 aSizeWidthField (this, SW_RES( FLD_SIZE_WIDTH )),
128 aSizeHeightText (this, SW_RES( TXT_SIZE_HEIGHT )),
129 aSizeHeightField (this, SW_RES( FLD_SIZE_HEIGHT )),
130 aPreview (this, SW_RES( WIN_PREVIEW ))
133 FreeResource();
134 SetExchangeSupport();
136 // Metriken
137 FieldUnit aMetric = ::GetDfltMetric(FALSE);
138 SetMetric(aAddrLeftField, aMetric);
139 SetMetric(aAddrTopField, aMetric);
140 SetMetric(aSendLeftField, aMetric);
141 SetMetric(aSendTopField, aMetric);
142 SetMetric(aSizeWidthField, aMetric);
143 SetMetric(aSizeHeightField, aMetric);
145 // Menues einhaengen
146 ::pMenu = new PopupMenu(SW_RES(MNU_EDIT));
147 aAddrEditButton.SetPopupMenu(::pMenu);
148 aSendEditButton.SetPopupMenu(::pMenu);
150 // Handler installieren
151 Link aLk = LINK(this, SwEnvFmtPage, ModifyHdl);
152 aAddrLeftField .SetUpHdl( aLk );
153 aAddrTopField .SetUpHdl( aLk );
154 aSendLeftField .SetUpHdl( aLk );
155 aSendTopField .SetUpHdl( aLk );
156 aSizeWidthField .SetUpHdl( aLk );
157 aSizeHeightField.SetUpHdl( aLk );
159 aAddrLeftField .SetDownHdl( aLk );
160 aAddrTopField .SetDownHdl( aLk );
161 aSendLeftField .SetDownHdl( aLk );
162 aSendTopField .SetDownHdl( aLk );
163 aSizeWidthField .SetDownHdl( aLk );
164 aSizeHeightField.SetDownHdl( aLk );
166 aAddrLeftField .SetLoseFocusHdl( aLk );
167 aAddrTopField .SetLoseFocusHdl( aLk );
168 aSendLeftField .SetLoseFocusHdl( aLk );
169 aSendTopField .SetLoseFocusHdl( aLk );
170 aSizeWidthField .SetLoseFocusHdl( aLk );
171 aSizeHeightField.SetLoseFocusHdl( aLk );
173 aLk = LINK(this, SwEnvFmtPage, EditHdl );
174 aAddrEditButton.SetSelectHdl( aLk );
175 aSendEditButton.SetSelectHdl( aLk );
177 aPreview.SetBorderStyle( WINDOW_BORDER_MONO );
179 aSizeFormatBox .SetSelectHdl(LINK(this, SwEnvFmtPage, FormatHdl));
181 // aSizeFormatBox
182 for (USHORT i = PAPER_A3; i <= PAPER_KAI32BIG; i++)
184 if (i != PAPER_USER)
186 String aPaperName = SvxPaperInfo::GetName((Paper) i),
187 aEntryName;
189 USHORT nPos = 0;
190 BOOL bFound = FALSE;
191 while (nPos < aSizeFormatBox.GetEntryCount() && !bFound)
193 aEntryName = aSizeFormatBox.GetEntry(i);
194 if (aEntryName < aPaperName)
195 nPos++;
196 else
197 bFound = TRUE;
199 aSizeFormatBox.InsertEntry(aPaperName, nPos);
200 aIDs.Insert((USHORT) i, nPos);
203 aSizeFormatBox.InsertEntry(SvxPaperInfo::GetName(PAPER_USER));
204 aIDs.Insert((USHORT) PAPER_USER, aIDs.Count());
208 // --------------------------------------------------------------------------
211 __EXPORT SwEnvFmtPage::~SwEnvFmtPage()
213 aAddrEditButton.SetPopupMenu(0);
214 aSendEditButton.SetPopupMenu(0);
215 delete ::pMenu;
218 // --------------------------------------------------------------------------
221 IMPL_LINK_INLINE_START( SwEnvFmtPage, ModifyHdl, Edit *, pEdit )
223 long lWVal = static_cast< long >(GetFldVal(aSizeWidthField ));
224 long lHVal = static_cast< long >(GetFldVal(aSizeHeightField));
226 long lWidth = Max(lWVal, lHVal);
227 long lHeight = Min(lWVal, lHVal);
229 if (pEdit == &aSizeWidthField || pEdit == &aSizeHeightField)
231 Paper ePaper = SvxPaperInfo::GetSvxPaper(
232 Size(lHeight, lWidth), MAP_TWIP, TRUE);
233 for (USHORT i = 0; i < aIDs.Count(); i++)
234 if (aIDs[i] == (USHORT)ePaper)
235 aSizeFormatBox.SelectEntryPos(i);
237 // Benutzergroesse merken
238 if (aIDs[aSizeFormatBox.GetSelectEntryPos()] == (USHORT)PAPER_USER)
240 lUserW = lWidth ;
241 lUserH = lHeight;
244 aSizeFormatBox.GetSelectHdl().Call(&aSizeFormatBox);
246 else
248 FillItem(GetParent()->aEnvItem);
249 SetMinMax();
250 aPreview.Invalidate();
252 return 0;
254 IMPL_LINK_INLINE_END( SwEnvFmtPage, ModifyHdl, Edit *, pEdit )
256 // --------------------------------------------------------------------------
259 IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton )
261 SwWrtShell* pSh = GetParent()->pSh;
262 ASSERT(pSh, "Shell fehlt");
264 // Collection-Ptr ermitteln
265 BOOL bSender = pButton != &aAddrEditButton;
267 SwTxtFmtColl* pColl = pSh->GetTxtCollFromPool( static_cast< USHORT >(
268 bSender ? RES_POOLCOLL_SENDADRESS : RES_POOLCOLL_JAKETADRESS));
269 ASSERT(pColl, "Text-Collection fehlt");
271 switch (pButton->GetCurItemId())
273 case MID_CHAR:
275 SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender);
277 // Damit die Hintergrundfarbe nicht uebergebuegelt wird:
278 SfxAllItemSet aTmpSet(*pCollSet);
280 // Das CHRATR_BACKGROUND-Attribut wird fuer den Dialog in
281 // ein RES_BACKGROUND verwandelt und wieder zurueck ...
282 const SfxPoolItem *pTmpBrush;
284 if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_CHRATR_BACKGROUND,
285 TRUE, &pTmpBrush ) )
287 SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
288 aTmpBrush.SetWhich( RES_BACKGROUND );
289 aTmpSet.Put( aTmpBrush );
291 else
292 aTmpSet.ClearItem( RES_BACKGROUND );
294 SwAbstractDialogFactory* pFact = swui::GetFactory();
295 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
297 SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( GetParent(), pSh->GetView(), aTmpSet, DLG_CHAR ,&pColl->GetName() );
298 DBG_ASSERT(pDlg, "Dialogdiet fail!");
299 if (pDlg->Execute() == RET_OK)
301 SfxItemSet aOutputSet( *pDlg->GetOutputItemSet() );
302 if( SFX_ITEM_SET == aOutputSet.GetItemState( RES_BACKGROUND,
303 FALSE, &pTmpBrush ) )
305 SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
306 aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
307 pCollSet->Put( aTmpBrush );
309 aOutputSet.ClearItem( RES_BACKGROUND );
310 //pColl->SetAttr( aTmpSet );
311 pCollSet->Put(aOutputSet);
313 delete pDlg;
315 break;
317 case MID_PARA:
319 SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender);
321 // Damit die Tabulatoren nicht uebergebuegelt werden:
322 SfxAllItemSet aTmpSet(*pCollSet);
324 // Tabulatoren, DefaultTabs ins ItemSet Stecken
325 const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
326 pSh->GetView().GetCurShell()->GetPool().GetDefaultItem(RES_PARATR_TABSTOP);
328 USHORT nDefDist = ::GetTabDist( rDefTabs );
329 SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist );
330 aTmpSet.Put( aDefDistItem );
332 // Aktueller Tab
333 SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 );
334 aTmpSet.Put( aTabPos );
336 // linker Rand als Offset
337 const long nOff = ((SvxLRSpaceItem&)aTmpSet.Get( RES_LR_SPACE )).
338 GetTxtLeft();
339 SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
340 aTmpSet.Put( aOff );
342 // BoxInfo setzen
343 ::PrepareBoxInfo( aTmpSet, *pSh );
345 SwParaDlg *pDlg = new SwParaDlg(GetParent(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &pColl->GetName());
347 if ( pDlg->Execute() == RET_OK )
349 // Defaults evtl umsetzen
350 const SfxPoolItem* pItem = 0;
351 SfxItemSet* pOutputSet = (SfxItemSet*)pDlg->GetOutputItemSet();
352 USHORT nNewDist;
353 if( SFX_ITEM_SET == pOutputSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS,
354 FALSE, &pItem ) &&
355 nDefDist != (nNewDist = ((SfxUInt16Item*)pItem)->GetValue()) )
357 SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
358 MakeDefTabs( nNewDist, aDefTabs );
359 pSh->SetDefault( aDefTabs );
360 pOutputSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS );
362 if( pOutputSet->Count() )
364 //pColl->SetAttr( *pOutputSet );
365 pCollSet->Put(*pOutputSet);
368 delete pDlg;
370 break;
372 return 0;
375 /*------------------------------------------------------------------------
376 Beschreibung: Ein temporaeres Itemset, das bei Abbruch verworfen wird
377 ------------------------------------------------------------------------*/
379 SfxItemSet *SwEnvFmtPage::GetCollItemSet(SwTxtFmtColl* pColl, BOOL bSender)
381 SfxItemSet *&pAddrSet = bSender ? GetParent()->pSenderSet : GetParent()->pAddresseeSet;
383 if (!pAddrSet)
385 // Range ermitteln (Ranges beider Itemsets mergen)
386 const USHORT *pRanges = pColl->GetAttrSet().GetRanges();
388 static USHORT __READONLY_DATA aRanges[] =
390 RES_PARATR_BEGIN, RES_PARATR_ADJUST,
391 RES_PARATR_TABSTOP, RES_PARATR_END-1,
392 RES_LR_SPACE, RES_UL_SPACE,
393 RES_BACKGROUND, RES_SHADOW,
394 SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS,
395 SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS,
396 SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
397 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
398 0, 0
401 // BruteForce-Merge, weil MergeRange in SvTools buggy ist:
402 USHORT i = 0;
403 SvLongsSort aMergedRanges( 0, 10 );
405 while (pRanges[i])
407 for (USHORT nPos = pRanges[i]; nPos <= pRanges[i+1]; nPos++)
408 aMergedRanges.Insert(nPos);
409 i += 2;
412 i = 0;
414 while (aRanges[i])
416 for (USHORT nPos = aRanges[i]; nPos <= aRanges[i+1]; nPos++)
417 aMergedRanges.Insert(nPos);
418 i += 2;
421 // Ranges kompaktieren
422 SvLongs aCompactedRanges( 0, 10 );
424 aCompactedRanges.Insert(aMergedRanges[0], aCompactedRanges.Count());
426 for (i = 0; i < aMergedRanges.Count(); i++)
428 while (i + 1 < aMergedRanges.Count() &&
429 aMergedRanges[i+1] - aMergedRanges[i] == 1)
431 i++;
433 long nEnd = aMergedRanges[i];
434 aCompactedRanges.Insert(nEnd, aCompactedRanges.Count());
436 if (i + 1 < aMergedRanges.Count())
438 long nStart = aMergedRanges[i+1];
439 aCompactedRanges.Insert(nStart, aCompactedRanges.Count());
443 // Neue Ranges erzeugen
444 USHORT *pNewRanges = new USHORT[aCompactedRanges.Count() + 1];
445 for (i = 0; i < aCompactedRanges.Count(); i++)
446 pNewRanges[i] = (USHORT)aCompactedRanges[i];
448 pNewRanges[i] = 0;
450 pAddrSet = new SfxItemSet(GetParent()->pSh->GetView().GetCurShell()->GetPool(),
451 pNewRanges);
453 pAddrSet->Put(pColl->GetAttrSet());
454 delete[] pNewRanges;
457 return pAddrSet;
460 // --------------------------------------------------------------------------
463 IMPL_LINK( SwEnvFmtPage, FormatHdl, ListBox *, EMPTYARG )
465 long lWidth;
466 long lHeight;
467 long lSendFromLeft;
468 long lSendFromTop;
469 long lAddrFromLeft;
470 long lAddrFromTop;
472 USHORT nPaper = aIDs[aSizeFormatBox.GetSelectEntryPos()];
473 if (nPaper != (USHORT)PAPER_USER)
475 Size aSz = SvxPaperInfo::GetPaperSize((Paper)nPaper);
476 lWidth = Max(aSz.Width(), aSz.Height());
477 lHeight = Min(aSz.Width(), aSz.Height());
479 else
481 lWidth = lUserW;
482 lHeight = lUserH;
485 lSendFromLeft = 566; // 1cm
486 lSendFromTop = 566; // 1cm
487 lAddrFromLeft = lWidth / 2;
488 lAddrFromTop = lHeight / 2;
490 SetFldVal(aAddrLeftField, lAddrFromLeft);
491 SetFldVal(aAddrTopField , lAddrFromTop );
492 SetFldVal(aSendLeftField, lSendFromLeft);
493 SetFldVal(aSendTopField , lSendFromTop );
495 SetFldVal(aSizeWidthField , lWidth );
496 SetFldVal(aSizeHeightField, lHeight);
498 SetMinMax();
500 FillItem(GetParent()->aEnvItem);
501 aPreview.Invalidate();
502 return 0;
505 // --------------------------------------------------------------------------
508 void SwEnvFmtPage::SetMinMax()
510 long lWVal = static_cast< long >(GetFldVal(aSizeWidthField ));
511 long lHVal = static_cast< long >(GetFldVal(aSizeHeightField));
513 long lWidth = Max(lWVal, lHVal),
514 lHeight = Min(lWVal, lHVal);
516 // Min und Max
517 aAddrLeftField.SetMin((long) 100 * (GetFldVal(aSendLeftField) + 566), FUNIT_TWIP);
518 aAddrLeftField.SetMax((long) 100 * (lWidth - 2 * 566), FUNIT_TWIP);
519 aAddrTopField .SetMin((long) 100 * (GetFldVal(aSendTopField ) + 2 * 566), FUNIT_TWIP);
520 aAddrTopField .SetMax((long) 100 * (lHeight - 2 * 566), FUNIT_TWIP);
521 aSendLeftField.SetMin((long) 100 * (566), FUNIT_TWIP);
522 aSendLeftField.SetMax((long) 100 * (GetFldVal(aAddrLeftField) - 566), FUNIT_TWIP);
523 aSendTopField .SetMin((long) 100 * (566), FUNIT_TWIP);
524 aSendTopField .SetMax((long) 100 * (GetFldVal(aAddrTopField ) - 2 * 566), FUNIT_TWIP);
526 // First und Last
527 aAddrLeftField.SetFirst(aAddrLeftField.GetMin());
528 aAddrLeftField.SetLast (aAddrLeftField.GetMax());
529 aAddrTopField .SetFirst(aAddrTopField .GetMin());
530 aAddrTopField .SetLast (aAddrTopField .GetMax());
531 aSendLeftField.SetFirst(aSendLeftField.GetMin());
532 aSendLeftField.SetLast (aSendLeftField.GetMax());
533 aSendTopField .SetFirst(aSendTopField .GetMin());
534 aSendTopField .SetLast (aSendTopField .GetMax());
536 // Fields neu formatieren
537 aAddrLeftField .Reformat();
538 aAddrTopField .Reformat();
539 aSendLeftField .Reformat();
540 aSendTopField .Reformat();
541 aSizeWidthField .Reformat();
542 aSizeHeightField.Reformat();
545 // --------------------------------------------------------------------------
548 SfxTabPage* __EXPORT SwEnvFmtPage::Create(Window* pParent, const SfxItemSet& rSet)
550 return new SwEnvFmtPage(pParent, rSet);
553 // ----------------------------------------------------------------------------
556 void __EXPORT SwEnvFmtPage::ActivatePage(const SfxItemSet& rSet)
558 SfxItemSet aSet(rSet);
559 aSet.Put(GetParent()->aEnvItem);
560 Reset(aSet);
563 // ----------------------------------------------------------------------------
566 int __EXPORT SwEnvFmtPage::DeactivatePage(SfxItemSet* _pSet)
568 if( _pSet )
569 FillItemSet(*_pSet);
570 return SfxTabPage::LEAVE_PAGE;
573 // --------------------------------------------------------------------------
576 void SwEnvFmtPage::FillItem(SwEnvItem& rItem)
578 rItem.lAddrFromLeft = static_cast< sal_Int32 >(GetFldVal(aAddrLeftField));
579 rItem.lAddrFromTop = static_cast< sal_Int32 >(GetFldVal(aAddrTopField ));
580 rItem.lSendFromLeft = static_cast< sal_Int32 >(GetFldVal(aSendLeftField));
581 rItem.lSendFromTop = static_cast< sal_Int32 >(GetFldVal(aSendTopField ));
583 USHORT nPaper = aIDs[aSizeFormatBox.GetSelectEntryPos()];
584 if (nPaper == (USHORT)PAPER_USER)
586 long lWVal = static_cast< long >(GetFldVal(aSizeWidthField ));
587 long lHVal = static_cast< long >(GetFldVal(aSizeHeightField));
588 rItem.lWidth = Max(lWVal, lHVal);
589 rItem.lHeight = Min(lWVal, lHVal);
591 else
593 long lWVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Width ();
594 long lHVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Height();
595 rItem.lWidth = Max(lWVal, lHVal);
596 rItem.lHeight = Min(lWVal, lHVal);
600 // --------------------------------------------------------------------------
603 BOOL __EXPORT SwEnvFmtPage::FillItemSet(SfxItemSet& rSet)
605 FillItem(GetParent()->aEnvItem);
606 rSet.Put(GetParent()->aEnvItem);
607 return TRUE;
610 // --------------------------------------------------------------------------
613 void __EXPORT SwEnvFmtPage::Reset(const SfxItemSet& rSet)
615 const SwEnvItem& rItem = (const SwEnvItem&) rSet.Get(FN_ENVELOP);
617 Paper ePaper = SvxPaperInfo::GetSvxPaper(
618 Size( Min(rItem.lWidth, rItem.lHeight),
619 Max(rItem.lWidth, rItem.lHeight)), MAP_TWIP, TRUE);
620 for (USHORT i = 0; i < (USHORT) aIDs.Count(); i++)
621 if (aIDs[i] == (USHORT)ePaper)
622 aSizeFormatBox.SelectEntryPos(i);
624 // Die MetricFields
625 SetFldVal(aAddrLeftField, rItem.lAddrFromLeft);
626 SetFldVal(aAddrTopField , rItem.lAddrFromTop );
627 SetFldVal(aSendLeftField, rItem.lSendFromLeft);
628 SetFldVal(aSendTopField , rItem.lSendFromTop );
629 SetFldVal(aSizeWidthField , Max(rItem.lWidth, rItem.lHeight));
630 SetFldVal(aSizeHeightField , Min(rItem.lWidth, rItem.lHeight));
631 SetMinMax();
633 DELETEZ(GetParent()->pSenderSet);
634 DELETEZ(GetParent()->pAddresseeSet);