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