Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <hintids.hxx>
21 :
22 : #include <editeng/paperinf.hxx>
23 : #include <editeng/tstpitem.hxx>
24 : #include <editeng/lrspitem.hxx>
25 : #include <editeng/brushitem.hxx>
26 : #include <vcl/msgbox.hxx>
27 : #include <vcl/menu.hxx>
28 :
29 : #include <cmdid.h>
30 : #include <frmatr.hxx>
31 : #include <swtypes.hxx>
32 : #include <wrtsh.hxx>
33 : #include <view.hxx>
34 : #include <basesh.hxx>
35 : #include <drpcps.hxx>
36 : #include <envfmt.hxx>
37 : #include <fmtcol.hxx>
38 : #include "swuipardlg.hxx"
39 : #include <chrdlgmodes.hxx>
40 : #include <pattern.hxx>
41 : #include <poolfmt.hxx>
42 : #include <uitool.hxx>
43 :
44 : #include <vector>
45 : #include <algorithm>
46 :
47 : #include <boost/scoped_array.hpp>
48 : #include <boost/scoped_ptr.hpp>
49 :
50 : #include "swabstdlg.hxx"
51 : #include "chrdlg.hrc"
52 : #include <swuiexp.hxx>
53 :
54 : namespace {
55 : /// Converts a ranges array to a list containing one entry for each
56 : /// element covered by the ranges.
57 : /// @param aRanges An array containing zero or more range specifications and
58 : /// terminated by one or more zero entries. A range
59 : /// specification is two consecutive entries that specify
60 : /// the start and end points of the range.
61 : /// @returns A vector containing one element for each item covered by the
62 : /// ranges. This is not gauranteed to be sorted and may contain
63 : /// duplicates if the original ranges contained overlaps.
64 0 : static std::vector<sal_uInt16> lcl_convertRangesToList(const sal_uInt16 aRanges[]) {
65 0 : std::vector<sal_uInt16> aVec;
66 0 : int i = 0;
67 0 : while (aRanges[i])
68 : {
69 0 : for (sal_uInt16 n = aRanges[i]; n <= aRanges[i+1]; ++n)
70 : {
71 0 : aVec.push_back(n);
72 : }
73 0 : i += 2;
74 : }
75 0 : return aVec;
76 : }
77 :
78 : /// Converts a list of elements to a ranges array.
79 : /// @param rElements Vector of the initial elements, this need not be sorted,
80 : /// and may contain duplicate items. The vector is sorted
81 : /// on exit from this function but may still contain duplicates.
82 : /// @returns An array containing zero or more range specifications and
83 : /// terminated by one or more zero entries. A range specification
84 : /// is two consecutive entries that specify the start and end
85 : /// points of the range. This list will be sorted and will not
86 : /// contain any overlapping ranges.
87 0 : static sal_uInt16* lcl_convertListToRanges(std::vector<sal_uInt16> &rElements) {
88 0 : std::sort(rElements.begin(), rElements.end());
89 0 : std::vector<sal_uInt16> aRanges;
90 : size_t i;
91 0 : for (i = 0; i < rElements.size(); ++i)
92 : {
93 : //Push the start of the this range.
94 0 : aRanges.push_back(rElements[i]);
95 : //Seek to the end of this range.
96 0 : while (i + 1 < rElements.size() && rElements[i+1] - rElements[i] <= 1)
97 : {
98 0 : ++i;
99 : }
100 : //Push the end of this range (may be the same as the start).
101 0 : aRanges.push_back( rElements[i] );
102 : }
103 :
104 : // Convert the vector to an array with terminating zero
105 0 : sal_uInt16 *pNewRanges = new sal_uInt16[aRanges.size() + 1];
106 0 : for (i = 0; i < aRanges.size(); ++i)
107 : {
108 0 : pNewRanges[i] = aRanges[i];
109 : }
110 0 : pNewRanges[i] = 0;
111 0 : return pNewRanges;
112 : }
113 :
114 : }
115 :
116 : static long lUserW = 5669; // 10 cm
117 : static long lUserH = 5669; // 10 cm
118 :
119 0 : SwEnvFmtPage::SwEnvFmtPage(vcl::Window* pParent, const SfxItemSet& rSet)
120 : : SfxTabPage(pParent, "EnvFormatPage",
121 0 : "modules/swriter/ui/envformatpage.ui", &rSet)
122 : {
123 0 : get(m_pAddrLeftField, "leftaddr");
124 0 : get(m_pAddrTopField, "topaddr");
125 0 : get(m_pSendLeftField,"leftsender");
126 0 : get(m_pSendTopField, "topsender");
127 0 : get(m_pSizeFormatBox, "format");
128 0 : get(m_pSizeWidthField, "width");
129 0 : get(m_pSizeHeightField, "height");
130 0 : get(m_pPreview, "preview");
131 0 : get(m_pAddrEditButton, "addredit");
132 0 : get(m_pSendEditButton, "senderedit");
133 0 : SetExchangeSupport();
134 :
135 : // Metrics
136 0 : FieldUnit aMetric = ::GetDfltMetric(false);
137 0 : SetMetric(*m_pAddrLeftField, aMetric);
138 0 : SetMetric(*m_pAddrTopField, aMetric);
139 0 : SetMetric(*m_pSendLeftField, aMetric);
140 0 : SetMetric(*m_pSendTopField, aMetric);
141 0 : SetMetric(*m_pSizeWidthField, aMetric);
142 0 : SetMetric(*m_pSizeHeightField, aMetric);
143 :
144 : // Install handlers
145 0 : Link aLk = LINK(this, SwEnvFmtPage, ModifyHdl);
146 0 : m_pAddrLeftField->SetUpHdl( aLk );
147 0 : m_pAddrTopField->SetUpHdl( aLk );
148 0 : m_pSendLeftField->SetUpHdl( aLk );
149 0 : m_pSendTopField->SetUpHdl( aLk );
150 0 : m_pSizeWidthField->SetUpHdl( aLk );
151 0 : m_pSizeHeightField->SetUpHdl( aLk );
152 :
153 0 : m_pAddrLeftField->SetDownHdl( aLk );
154 0 : m_pAddrTopField->SetDownHdl( aLk );
155 0 : m_pSendLeftField->SetDownHdl( aLk );
156 0 : m_pSendTopField->SetDownHdl( aLk );
157 0 : m_pSizeWidthField->SetDownHdl( aLk );
158 0 : m_pSizeHeightField->SetDownHdl( aLk );
159 :
160 0 : m_pAddrLeftField->SetLoseFocusHdl( aLk );
161 0 : m_pAddrTopField->SetLoseFocusHdl( aLk );
162 0 : m_pSendLeftField->SetLoseFocusHdl( aLk );
163 0 : m_pSendTopField->SetLoseFocusHdl( aLk );
164 0 : m_pSizeWidthField->SetLoseFocusHdl( aLk );
165 0 : m_pSizeHeightField->SetLoseFocusHdl( aLk );
166 :
167 0 : aLk = LINK(this, SwEnvFmtPage, EditHdl );
168 0 : m_pAddrEditButton->SetSelectHdl( aLk );
169 0 : m_pSendEditButton->SetSelectHdl( aLk );
170 :
171 0 : m_pPreview->SetBorderStyle( WindowBorderStyle::MONO );
172 :
173 0 : m_pSizeFormatBox->SetSelectHdl(LINK(this, SwEnvFmtPage, FormatHdl));
174 :
175 : // m_pSizeFormatBox
176 0 : for (sal_uInt16 i = PAPER_A3; i <= PAPER_KAI32BIG; i++)
177 : {
178 0 : if (i != PAPER_USER)
179 : {
180 0 : const OUString aPaperName = SvxPaperInfo::GetName((Paper) i);
181 :
182 0 : if (aPaperName.isEmpty())
183 0 : continue;
184 :
185 0 : sal_Int32 nPos = 0;
186 0 : while (nPos < m_pSizeFormatBox->GetEntryCount() &&
187 0 : m_pSizeFormatBox->GetEntry(nPos) < aPaperName)
188 : {
189 0 : ++nPos;
190 : }
191 0 : m_pSizeFormatBox->InsertEntry(aPaperName, nPos);
192 0 : aIDs.insert( aIDs.begin() + nPos, i);
193 : }
194 : }
195 0 : m_pSizeFormatBox->InsertEntry(SvxPaperInfo::GetName(PAPER_USER));
196 0 : aIDs.push_back( (sal_uInt16) PAPER_USER );
197 :
198 0 : }
199 :
200 0 : IMPL_LINK_INLINE_START( SwEnvFmtPage, ModifyHdl, Edit *, pEdit )
201 : {
202 0 : long lWVal = static_cast< long >(GetFldVal(*m_pSizeWidthField ));
203 0 : long lHVal = static_cast< long >(GetFldVal(*m_pSizeHeightField));
204 :
205 0 : long lWidth = std::max(lWVal, lHVal);
206 0 : long lHeight = std::min(lWVal, lHVal);
207 :
208 0 : if (pEdit == m_pSizeWidthField || pEdit == m_pSizeHeightField)
209 : {
210 : Paper ePaper = SvxPaperInfo::GetSvxPaper(
211 0 : Size(lHeight, lWidth), MAP_TWIP, true);
212 0 : for (size_t i = 0; i < aIDs.size(); ++i)
213 0 : if (aIDs[i] == (sal_uInt16)ePaper)
214 0 : m_pSizeFormatBox->SelectEntryPos(static_cast<sal_Int32>(i));
215 :
216 : // remember user size
217 0 : if (aIDs[m_pSizeFormatBox->GetSelectEntryPos()] == (sal_uInt16)PAPER_USER)
218 : {
219 0 : lUserW = lWidth ;
220 0 : lUserH = lHeight;
221 : }
222 :
223 0 : m_pSizeFormatBox->GetSelectHdl().Call(m_pSizeFormatBox);
224 : }
225 : else
226 : {
227 0 : FillItem(GetParentSwEnvDlg()->aEnvItem);
228 0 : SetMinMax();
229 0 : m_pPreview->Invalidate();
230 : }
231 0 : return 0;
232 : }
233 0 : IMPL_LINK_INLINE_END( SwEnvFmtPage, ModifyHdl, Edit *, pEdit )
234 :
235 0 : IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton )
236 : {
237 0 : SwWrtShell* pSh = GetParentSwEnvDlg()->pSh;
238 : OSL_ENSURE(pSh, "Shell missing");
239 :
240 : // determine collection-ptr
241 0 : bool bSender = pButton != m_pAddrEditButton;
242 :
243 : SwTxtFmtColl* pColl = pSh->GetTxtCollFromPool( static_cast< sal_uInt16 >(
244 0 : bSender ? RES_POOLCOLL_SENDADRESS : RES_POOLCOLL_JAKETADRESS));
245 : OSL_ENSURE(pColl, "Text collection missing");
246 :
247 0 : OString sIdent(pButton->GetCurItemIdent());
248 :
249 0 : if (sIdent == "character")
250 : {
251 0 : SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender);
252 :
253 : // In order for the background color not to get ironed over:
254 0 : SfxAllItemSet aTmpSet(*pCollSet);
255 0 : ::ConvertAttrCharToGen(aTmpSet, CONV_ATTR_ENV);
256 :
257 0 : SwAbstractDialogFactory* pFact = swui::GetFactory();
258 : OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
259 :
260 0 : const OUString sFmtStr = pColl->GetName();
261 0 : boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_CHAR_ENV, &sFmtStr));
262 : OSL_ENSURE(pDlg, "Dialog creation failed!");
263 0 : if (pDlg->Execute() == RET_OK)
264 : {
265 0 : SfxItemSet aOutputSet( *pDlg->GetOutputItemSet() );
266 0 : ::ConvertAttrGenToChar(aOutputSet, CONV_ATTR_ENV);
267 0 : pCollSet->Put(aOutputSet);
268 0 : }
269 : }
270 0 : else if (sIdent == "paragraph")
271 : {
272 0 : SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender);
273 :
274 : // In order for the tabulators not to get ironed over:
275 0 : SfxAllItemSet aTmpSet(*pCollSet);
276 :
277 : // Insert tabs, default tabs into ItemSet
278 : const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
279 0 : pSh->GetView().GetCurShell()->GetPool().GetDefaultItem(RES_PARATR_TABSTOP);
280 :
281 0 : const sal_uInt16 nDefDist = static_cast<sal_uInt16>(::GetTabDist( rDefTabs ));
282 0 : SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist );
283 0 : aTmpSet.Put( aDefDistItem );
284 :
285 : // Current tab
286 0 : SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 );
287 0 : aTmpSet.Put( aTabPos );
288 :
289 : // left border as offset
290 0 : const long nOff = ((SvxLRSpaceItem&)aTmpSet.Get( RES_LR_SPACE )).
291 0 : GetTxtLeft();
292 0 : SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
293 0 : aTmpSet.Put( aOff );
294 :
295 : // set BoxInfo
296 0 : ::PrepareBoxInfo( aTmpSet, *pSh );
297 :
298 0 : const OUString sFmtStr = pColl->GetName();
299 0 : boost::scoped_ptr<SwParaDlg> pDlg(new SwParaDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFmtStr));
300 :
301 0 : if ( pDlg->Execute() == RET_OK )
302 : {
303 : // maybe relocate defaults
304 0 : const SfxPoolItem* pItem = 0;
305 0 : SfxItemSet* pOutputSet = (SfxItemSet*)pDlg->GetOutputItemSet();
306 : sal_uInt16 nNewDist;
307 :
308 0 : if( SfxItemState::SET == pOutputSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS,
309 0 : false, &pItem ) &&
310 0 : nDefDist != (nNewDist = ((SfxUInt16Item*)pItem)->GetValue()) )
311 : {
312 0 : SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
313 0 : MakeDefTabs( nNewDist, aDefTabs );
314 0 : pSh->SetDefault( aDefTabs );
315 0 : pOutputSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS );
316 : }
317 0 : if( pOutputSet->Count() )
318 : {
319 0 : pCollSet->Put(*pOutputSet);
320 : }
321 0 : }
322 : }
323 0 : return 0;
324 : }
325 :
326 : // A temporary Itemset that gets discarded at abort
327 0 : SfxItemSet *SwEnvFmtPage::GetCollItemSet(SwTxtFmtColl* pColl, bool bSender)
328 : {
329 0 : SfxItemSet *&pAddrSet = bSender ? GetParentSwEnvDlg()->pSenderSet : GetParentSwEnvDlg()->pAddresseeSet;
330 0 : if (!pAddrSet)
331 : {
332 : // determine range (merge both Itemsets' ranges)
333 0 : const sal_uInt16 *pRanges = pColl->GetAttrSet().GetRanges();
334 :
335 : static sal_uInt16 const aRanges[] =
336 : {
337 : RES_PARATR_BEGIN, RES_PARATR_ADJUST,
338 : RES_PARATR_TABSTOP, RES_PARATR_END-1,
339 : RES_LR_SPACE, RES_UL_SPACE,
340 : RES_BACKGROUND, RES_SHADOW,
341 : SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS,
342 : SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS,
343 : SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
344 : SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
345 : 0, 0
346 : };
347 :
348 : // BruteForce merge because MergeRange in SvTools is buggy:
349 0 : std::vector<sal_uInt16> pVec = ::lcl_convertRangesToList(pRanges);
350 0 : std::vector<sal_uInt16> aVec = ::lcl_convertRangesToList(aRanges);
351 0 : pVec.insert(pVec.end(), aVec.begin(), aVec.end());
352 0 : boost::scoped_array<sal_uInt16> pNewRanges(::lcl_convertListToRanges(pVec));
353 :
354 0 : pAddrSet = new SfxItemSet(GetParentSwEnvDlg()->pSh->GetView().GetCurShell()->GetPool(),
355 0 : pNewRanges.get());
356 0 : pAddrSet->Put(pColl->GetAttrSet());
357 : }
358 :
359 0 : return pAddrSet;
360 : }
361 :
362 0 : IMPL_LINK_NOARG(SwEnvFmtPage, FormatHdl)
363 : {
364 : long lWidth;
365 : long lHeight;
366 : long lSendFromLeft;
367 : long lSendFromTop;
368 : long lAddrFromLeft;
369 : long lAddrFromTop;
370 :
371 0 : const sal_uInt16 nPaper = aIDs[m_pSizeFormatBox->GetSelectEntryPos()];
372 0 : if (nPaper != (sal_uInt16)PAPER_USER)
373 : {
374 0 : Size aSz = SvxPaperInfo::GetPaperSize((Paper)nPaper);
375 0 : lWidth = std::max(aSz.Width(), aSz.Height());
376 0 : lHeight = std::min(aSz.Width(), aSz.Height());
377 : }
378 : else
379 : {
380 0 : lWidth = lUserW;
381 0 : lHeight = lUserH;
382 : }
383 :
384 0 : lSendFromLeft = 566; // 1cm
385 0 : lSendFromTop = 566; // 1cm
386 0 : lAddrFromLeft = lWidth / 2;
387 0 : lAddrFromTop = lHeight / 2;
388 :
389 0 : SetFldVal(*m_pAddrLeftField, lAddrFromLeft);
390 0 : SetFldVal(*m_pAddrTopField , lAddrFromTop );
391 0 : SetFldVal(*m_pSendLeftField, lSendFromLeft);
392 0 : SetFldVal(*m_pSendTopField , lSendFromTop );
393 :
394 0 : SetFldVal(*m_pSizeWidthField , lWidth );
395 0 : SetFldVal(*m_pSizeHeightField, lHeight);
396 :
397 0 : SetMinMax();
398 :
399 0 : FillItem(GetParentSwEnvDlg()->aEnvItem);
400 0 : m_pPreview->Invalidate();
401 0 : return 0;
402 : }
403 :
404 0 : void SwEnvFmtPage::SetMinMax()
405 : {
406 0 : long lWVal = static_cast< long >(GetFldVal(*m_pSizeWidthField ));
407 0 : long lHVal = static_cast< long >(GetFldVal(*m_pSizeHeightField));
408 :
409 0 : long lWidth = std::max(lWVal, lHVal),
410 0 : lHeight = std::min(lWVal, lHVal);
411 :
412 : // Min and Max
413 0 : m_pAddrLeftField->SetMin((long) 100 * (GetFldVal(*m_pSendLeftField) + 566), FUNIT_TWIP);
414 0 : m_pAddrLeftField->SetMax((long) 100 * (lWidth - 2 * 566), FUNIT_TWIP);
415 0 : m_pAddrTopField->SetMin((long) 100 * (GetFldVal(*m_pSendTopField ) + 2 * 566), FUNIT_TWIP);
416 0 : m_pAddrTopField->SetMax((long) 100 * (lHeight - 2 * 566), FUNIT_TWIP);
417 0 : m_pSendLeftField->SetMin((long) 100 * (566), FUNIT_TWIP);
418 0 : m_pSendLeftField->SetMax((long) 100 * (GetFldVal(*m_pAddrLeftField) - 566), FUNIT_TWIP);
419 0 : m_pSendTopField->SetMin((long) 100 * (566), FUNIT_TWIP);
420 0 : m_pSendTopField->SetMax((long) 100 * (GetFldVal(*m_pAddrTopField ) - 2 * 566), FUNIT_TWIP);
421 :
422 : // First and last
423 0 : m_pAddrLeftField->SetFirst(m_pAddrLeftField->GetMin());
424 0 : m_pAddrLeftField->SetLast(m_pAddrLeftField->GetMax());
425 0 : m_pAddrTopField->SetFirst(m_pAddrTopField->GetMin());
426 0 : m_pAddrTopField->SetLast(m_pAddrTopField->GetMax());
427 0 : m_pSendLeftField->SetFirst(m_pSendLeftField->GetMin());
428 0 : m_pSendLeftField->SetLast(m_pSendLeftField->GetMax());
429 0 : m_pSendTopField->SetFirst(m_pSendTopField->GetMin());
430 0 : m_pSendTopField->SetLast(m_pSendTopField->GetMax());
431 :
432 : // Reformat fields
433 0 : m_pAddrLeftField->Reformat();
434 0 : m_pAddrTopField->Reformat();
435 0 : m_pSendLeftField->Reformat();
436 0 : m_pSendTopField->Reformat();
437 0 : m_pSizeWidthField->Reformat();
438 0 : m_pSizeHeightField->Reformat();
439 0 : }
440 :
441 0 : SfxTabPage* SwEnvFmtPage::Create(vcl::Window* pParent, const SfxItemSet* rSet)
442 : {
443 0 : return new SwEnvFmtPage(pParent, *rSet);
444 : }
445 :
446 0 : void SwEnvFmtPage::ActivatePage(const SfxItemSet& rSet)
447 : {
448 0 : SfxItemSet aSet(rSet);
449 0 : aSet.Put(GetParentSwEnvDlg()->aEnvItem);
450 0 : Reset(&aSet);
451 0 : }
452 :
453 0 : int SwEnvFmtPage::DeactivatePage(SfxItemSet* _pSet)
454 : {
455 0 : if( _pSet )
456 0 : FillItemSet(_pSet);
457 0 : return SfxTabPage::LEAVE_PAGE;
458 : }
459 :
460 0 : void SwEnvFmtPage::FillItem(SwEnvItem& rItem)
461 : {
462 0 : rItem.lAddrFromLeft = static_cast< sal_Int32 >(GetFldVal(*m_pAddrLeftField));
463 0 : rItem.lAddrFromTop = static_cast< sal_Int32 >(GetFldVal(*m_pAddrTopField ));
464 0 : rItem.lSendFromLeft = static_cast< sal_Int32 >(GetFldVal(*m_pSendLeftField));
465 0 : rItem.lSendFromTop = static_cast< sal_Int32 >(GetFldVal(*m_pSendTopField ));
466 :
467 0 : const sal_uInt16 nPaper = aIDs[m_pSizeFormatBox->GetSelectEntryPos()];
468 0 : if (nPaper == (sal_uInt16)PAPER_USER)
469 : {
470 0 : long lWVal = static_cast< long >(GetFldVal(*m_pSizeWidthField ));
471 0 : long lHVal = static_cast< long >(GetFldVal(*m_pSizeHeightField));
472 0 : rItem.lWidth = std::max(lWVal, lHVal);
473 0 : rItem.lHeight = std::min(lWVal, lHVal);
474 : }
475 : else
476 : {
477 0 : long lWVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Width ();
478 0 : long lHVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Height();
479 0 : rItem.lWidth = std::max(lWVal, lHVal);
480 0 : rItem.lHeight = std::min(lWVal, lHVal);
481 : }
482 0 : }
483 :
484 0 : bool SwEnvFmtPage::FillItemSet(SfxItemSet* rSet)
485 : {
486 0 : FillItem(GetParentSwEnvDlg()->aEnvItem);
487 0 : rSet->Put(GetParentSwEnvDlg()->aEnvItem);
488 0 : return true;
489 : }
490 :
491 0 : void SwEnvFmtPage::Reset(const SfxItemSet* rSet)
492 : {
493 0 : const SwEnvItem& rItem = (const SwEnvItem&) rSet->Get(FN_ENVELOP);
494 :
495 : Paper ePaper = SvxPaperInfo::GetSvxPaper(
496 0 : Size( std::min(rItem.lWidth, rItem.lHeight),
497 0 : std::max(rItem.lWidth, rItem.lHeight)), MAP_TWIP, true);
498 0 : for (size_t i = 0; i < aIDs.size(); ++i)
499 0 : if (aIDs[i] == (sal_uInt16)ePaper)
500 0 : m_pSizeFormatBox->SelectEntryPos(static_cast<sal_Int32>(i));
501 :
502 : // Metric fields
503 0 : SetFldVal(*m_pAddrLeftField, rItem.lAddrFromLeft);
504 0 : SetFldVal(*m_pAddrTopField, rItem.lAddrFromTop );
505 0 : SetFldVal(*m_pSendLeftField, rItem.lSendFromLeft);
506 0 : SetFldVal(*m_pSendTopField, rItem.lSendFromTop );
507 0 : SetFldVal(*m_pSizeWidthField , std::max(rItem.lWidth, rItem.lHeight));
508 0 : SetFldVal(*m_pSizeHeightField , std::min(rItem.lWidth, rItem.lHeight));
509 0 : SetMinMax();
510 :
511 0 : DELETEZ(GetParentSwEnvDlg()->pSenderSet);
512 0 : DELETEZ(GetParentSwEnvDlg()->pAddresseeSet);
513 0 : }
514 :
515 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|