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 <sal/config.h>
21 :
22 : #include <cstdlib>
23 :
24 : #include "PageMarginControl.hxx"
25 : #include "PagePropertyPanel.hxx"
26 : #include "PagePropertyPanel.hrc"
27 :
28 : #include <swtypes.hxx>
29 :
30 : #include <svx/sidebar/ValueSetWithTextControl.hxx>
31 : #include <vcl/settings.hxx>
32 :
33 : #define SWPAGE_LEFT_GVALUE "Sw_Page_Left"
34 : #define SWPAGE_RIGHT_GVALUE "Sw_Page_Right"
35 : #define SWPAGE_TOP_GVALUE "Sw_Page_Top"
36 : #define SWPAGE_DOWN_GVALUE "Sw_Page_Down"
37 : #define SWPAGE_MIRROR_GVALUE "Sw_Page_Mirrored"
38 :
39 : namespace sw { namespace sidebar {
40 :
41 0 : PageMarginControl::PageMarginControl(
42 : vcl::Window* pParent,
43 : PagePropertyPanel& rPanel,
44 : const SvxLongLRSpaceItem& aPageLRMargin,
45 : const SvxLongULSpaceItem& aPageULMargin,
46 : const bool bMirrored,
47 : const Size aPageSize,
48 : const bool bLandscape,
49 : const FieldUnit eFUnit,
50 : const SfxMapUnit eUnit )
51 : : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_MARGIN) )
52 0 : , mpMarginValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_MARGIN) ) )
53 : , maCustom(this, SW_RES(FT_CUSTOM))
54 : , maLeft(this, SW_RES(FT_LEFT))
55 : , maInner(this, SW_RES(FT_INNER))
56 : , maLeftMarginEdit(this, SW_RES(MF_SWLEFT_MARGIN))
57 : , maRight(this, SW_RES(FT_RIGHT))
58 : , maOuter(this, SW_RES(FT_OUTER))
59 : , maRightMarginEdit(this, SW_RES(MF_SWRIGHT_MARGIN))
60 : , maTop(this, SW_RES(FT_TOP))
61 : , maTopMarginEdit(this, SW_RES(MF_SWTOP_MARGIN))
62 : , maBottom(this, SW_RES(FT_BOTTOM))
63 : , maBottomMarginEdit(this, SW_RES(MF_SWBOTTOM_MARGIN))
64 : , maWidthHeightField( this, SW_RES(FLD_WIDTH_HEIGHT) )
65 0 : , mnPageLeftMargin( aPageLRMargin.GetLeft() )
66 0 : , mnPageRightMargin( aPageLRMargin.GetRight() )
67 0 : , mnPageTopMargin( aPageULMargin.GetUpper() )
68 0 : , mnPageBottomMargin( aPageULMargin.GetLower() )
69 : , mbMirrored( bMirrored )
70 : , meUnit( eUnit )
71 : , mbUserCustomValuesAvailable(false)
72 : , mnUserCustomPageLeftMargin(0)
73 : , mnUserCustomPageRightMargin(0)
74 : , mnUserCustomPageTopMargin(0)
75 : , mnUserCustomPageBottomMargin(0)
76 : , mbUserCustomMirrored(false)
77 : , mbCustomValuesUsed( false )
78 0 : , mrPagePropPanel(rPanel)
79 : {
80 0 : maWidthHeightField.Hide();
81 0 : SetFieldUnit( maWidthHeightField, eFUnit );
82 :
83 0 : mbUserCustomValuesAvailable = GetUserCustomValues();
84 :
85 0 : mpMarginValueSet->SetStyle( mpMarginValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
86 0 : mpMarginValueSet->SetColor( GetSettings().GetStyleSettings().GetMenuColor() );
87 :
88 0 : FillValueSet( bLandscape, mbUserCustomValuesAvailable );
89 :
90 0 : mpMarginValueSet->SetNoSelection();
91 0 : mpMarginValueSet->SetSelectHdl( LINK(this, PageMarginControl,ImplMarginHdl ) );
92 0 : mpMarginValueSet->Show();
93 :
94 0 : SelectValueSetItem();
95 :
96 0 : SetFieldUnit( maLeftMarginEdit, eFUnit );
97 0 : Link aLinkLR = LINK( this, PageMarginControl, ModifyLRMarginHdl );
98 0 : maLeftMarginEdit.SetModifyHdl( aLinkLR );
99 0 : SetMetricValue( maLeftMarginEdit, mnPageLeftMargin, meUnit );
100 :
101 0 : SetFieldUnit( maRightMarginEdit, eFUnit );
102 0 : maRightMarginEdit.SetModifyHdl( aLinkLR );
103 0 : SetMetricValue( maRightMarginEdit, mnPageRightMargin, meUnit );
104 :
105 0 : Link aLinkUL = LINK( this, PageMarginControl, ModifyULMarginHdl );
106 0 : SetFieldUnit( maTopMarginEdit, eFUnit );
107 0 : maTopMarginEdit.SetModifyHdl( aLinkUL );
108 0 : SetMetricValue( maTopMarginEdit, mnPageTopMargin, meUnit );
109 :
110 0 : SetFieldUnit( maBottomMarginEdit, eFUnit );
111 0 : maBottomMarginEdit.SetModifyHdl( aLinkUL );
112 0 : SetMetricValue( maBottomMarginEdit, mnPageBottomMargin, meUnit );
113 :
114 0 : SetMetricFieldMaxValues( aPageSize );
115 :
116 0 : if ( mbMirrored )
117 : {
118 0 : maLeft.Hide();
119 0 : maRight.Hide();
120 0 : maInner.Show();
121 0 : maOuter.Show();
122 : }
123 : else
124 : {
125 0 : maLeft.Show();
126 0 : maRight.Show();
127 0 : maInner.Hide();
128 0 : maOuter.Hide();
129 : }
130 :
131 0 : FreeResource();
132 0 : }
133 :
134 0 : PageMarginControl::~PageMarginControl(void)
135 : {
136 0 : delete mpMarginValueSet;
137 :
138 0 : StoreUserCustomValues();
139 0 : }
140 :
141 0 : void PageMarginControl::SetMetricFieldMaxValues( const Size aPageSize )
142 : {
143 0 : const long nML = maLeftMarginEdit.Denormalize( maLeftMarginEdit.GetValue(FUNIT_TWIP) );
144 0 : const long nMR = maRightMarginEdit.Denormalize( maRightMarginEdit.GetValue(FUNIT_TWIP) );
145 0 : const long nMT = maTopMarginEdit.Denormalize(maTopMarginEdit.GetValue(FUNIT_TWIP) );
146 0 : const long nMB = maBottomMarginEdit.Denormalize( maBottomMarginEdit.GetValue(FUNIT_TWIP) );
147 :
148 0 : const long nPH = LogicToLogic( aPageSize.Height(), (MapUnit)meUnit, MAP_TWIP );
149 0 : const long nPW = LogicToLogic( aPageSize.Width(), (MapUnit)meUnit, MAP_TWIP );
150 :
151 : // Left
152 0 : long nMax = nPW - nMR - MINBODY;
153 0 : maLeftMarginEdit.SetMax(maLeftMarginEdit.Normalize(nMax), FUNIT_TWIP);
154 :
155 : // Right
156 0 : nMax = nPW - nML - MINBODY;
157 0 : maRightMarginEdit.SetMax(maRightMarginEdit.Normalize(nMax), FUNIT_TWIP);
158 :
159 : //Top
160 0 : nMax = nPH - nMB - MINBODY;
161 0 : maTopMarginEdit.SetMax(maTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
162 :
163 : //Bottom
164 0 : nMax = nPH - nMT - MINBODY;
165 0 : maBottomMarginEdit.SetMax(maTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
166 0 : }
167 :
168 0 : void PageMarginControl::FillValueSet(
169 : const bool bLandscape,
170 : const bool bUserCustomValuesAvailable )
171 : {
172 0 : const OUString aLeft = SW_RESSTR(STR_MARGIN_TOOLTIP_LEFT);
173 0 : const OUString aRight = SW_RESSTR(STR_MARGIN_TOOLTIP_RIGHT);
174 0 : const OUString aTop = SW_RESSTR(STR_MARGIN_TOOLTIP_TOP);
175 0 : const OUString aBottom = SW_RESSTR(STR_MARGIN_TOOLTIP_BOT);
176 :
177 0 : SetMetricValue( maWidthHeightField, SWPAGE_NARROW_VALUE, meUnit );
178 0 : const OUString aNarrowValText = maWidthHeightField.GetText();
179 0 : OUString aHelpText = aLeft;
180 0 : aHelpText += aNarrowValText;
181 0 : aHelpText += aRight;
182 0 : aHelpText += aNarrowValText;
183 0 : aHelpText += aTop;
184 0 : aHelpText += aNarrowValText;
185 0 : aHelpText += aBottom;
186 0 : aHelpText += aNarrowValText;
187 : mpMarginValueSet->AddItem(
188 : Image((bLandscape) ? SW_RES(IMG_NARROW_L) : SW_RES(IMG_NARROW)), 0,
189 0 : SW_RESSTR(STR_NARROW), &aHelpText );
190 :
191 0 : SetMetricValue( maWidthHeightField, SWPAGE_NORMAL_VALUE, meUnit );
192 0 : const OUString aNormalValText = maWidthHeightField.GetText();
193 0 : aHelpText = aLeft;
194 0 : aHelpText += aNormalValText;
195 0 : aHelpText += aRight;
196 0 : aHelpText += aNormalValText;
197 0 : aHelpText += aTop;
198 0 : aHelpText += aNormalValText;
199 0 : aHelpText += aBottom;
200 0 : aHelpText += aNormalValText;
201 : mpMarginValueSet->AddItem(
202 : Image((bLandscape) ? SW_RES(IMG_NORMAL_L) : SW_RES(IMG_NORMAL)), 0,
203 0 : SW_RESSTR(STR_NORMAL), &aHelpText );
204 :
205 0 : SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE1, meUnit );
206 0 : const OUString aWide1ValText = maWidthHeightField.GetText();
207 0 : SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE2, meUnit );
208 0 : const OUString aWide2ValText = maWidthHeightField.GetText();
209 0 : aHelpText = aLeft;
210 0 : aHelpText += aWide2ValText;
211 0 : aHelpText += aRight;
212 0 : aHelpText += aWide2ValText;
213 0 : aHelpText += aTop;
214 0 : aHelpText += aWide1ValText;
215 0 : aHelpText += aBottom;
216 0 : aHelpText += aWide1ValText;
217 : mpMarginValueSet->AddItem(
218 : Image((bLandscape) ? SW_RES(IMG_WIDE_L) : SW_RES(IMG_WIDE)), 0,
219 0 : SW_RESSTR(STR_WIDE), &aHelpText );
220 :
221 0 : const OUString aInner = SW_RESSTR(STR_MARGIN_TOOLTIP_INNER);
222 0 : const OUString aOuter = SW_RESSTR(STR_MARGIN_TOOLTIP_OUTER);
223 :
224 0 : SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE3, meUnit );
225 0 : const OUString aWide3ValText = maWidthHeightField.GetText();
226 0 : aHelpText = aInner;
227 0 : aHelpText += aWide3ValText;
228 0 : aHelpText += aOuter;
229 0 : aHelpText += aWide3ValText;
230 0 : aHelpText += aTop;
231 0 : aHelpText += aWide1ValText;
232 0 : aHelpText += aBottom;
233 0 : aHelpText += aWide1ValText;
234 : mpMarginValueSet->AddItem(
235 : Image((bLandscape) ? SW_RES(IMG_MIRRORED_L) : SW_RES(IMG_MIRRORED)), 0,
236 0 : SW_RESSTR(STR_MIRRORED), &aHelpText );
237 :
238 0 : if ( bUserCustomValuesAvailable )
239 : {
240 0 : aHelpText = mbUserCustomMirrored ? aInner : aLeft;
241 0 : SetMetricValue( maWidthHeightField, mnUserCustomPageLeftMargin, meUnit );
242 0 : aHelpText += maWidthHeightField.GetText();
243 0 : aHelpText += mbUserCustomMirrored ? aOuter : aRight;
244 0 : SetMetricValue( maWidthHeightField, mnUserCustomPageRightMargin, meUnit );
245 0 : aHelpText += maWidthHeightField.GetText();
246 0 : aHelpText += aTop;
247 0 : SetMetricValue( maWidthHeightField, mnUserCustomPageTopMargin, meUnit );
248 0 : aHelpText += maWidthHeightField.GetText();
249 0 : aHelpText += aBottom;
250 0 : SetMetricValue( maWidthHeightField, mnUserCustomPageBottomMargin, meUnit );
251 0 : aHelpText += maWidthHeightField.GetText();
252 : }
253 : else
254 : {
255 0 : aHelpText = OUString();
256 : }
257 : mpMarginValueSet->AddItem(
258 : Image((bUserCustomValuesAvailable) ? SW_RES(IMG_CUSTOM) : SW_RES(IMG_CUSTOM_DIS)), 0,
259 0 : SW_RESSTR(STR_LCVALUE), &aHelpText );
260 0 : }
261 :
262 0 : void PageMarginControl::SelectValueSetItem()
263 : {
264 0 : const long cTolerance = 5;
265 :
266 0 : if( std::abs(mnPageLeftMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
267 0 : std::abs(mnPageRightMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
268 0 : std::abs(mnPageTopMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
269 0 : std::abs(mnPageBottomMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
270 0 : !mbMirrored )
271 : {
272 0 : mpMarginValueSet->SelectItem(1);
273 : }
274 0 : else if( std::abs(mnPageLeftMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
275 0 : std::abs(mnPageRightMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
276 0 : std::abs(mnPageTopMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
277 0 : std::abs(mnPageBottomMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
278 0 : !mbMirrored )
279 : {
280 0 : mpMarginValueSet->SelectItem(2);
281 : }
282 0 : else if( std::abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
283 0 : std::abs(mnPageRightMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
284 0 : std::abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
285 0 : std::abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
286 0 : !mbMirrored )
287 : {
288 0 : mpMarginValueSet->SelectItem(3);
289 : }
290 0 : else if( std::abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE3) <= cTolerance &&
291 0 : std::abs(mnPageRightMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
292 0 : std::abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
293 0 : std::abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
294 : mbMirrored )
295 : {
296 0 : mpMarginValueSet->SelectItem(4);
297 : }
298 : else
299 : {
300 0 : mpMarginValueSet->SelectItem(0);
301 : }
302 :
303 0 : mpMarginValueSet->Format();
304 0 : mpMarginValueSet->StartSelection();
305 0 : };
306 :
307 0 : IMPL_LINK(PageMarginControl, ImplMarginHdl, void *, pControl)
308 : {
309 0 : if ( pControl == mpMarginValueSet )
310 : {
311 0 : bool bMirrored = false;
312 0 : bool bApplyNewPageMargins = true;
313 0 : switch ( mpMarginValueSet->GetSelectItemId() )
314 : {
315 : case 1:
316 0 : mnPageLeftMargin = SWPAGE_NARROW_VALUE;
317 0 : mnPageRightMargin = SWPAGE_NARROW_VALUE;
318 0 : mnPageTopMargin = SWPAGE_NARROW_VALUE;
319 0 : mnPageBottomMargin = SWPAGE_NARROW_VALUE;
320 0 : bMirrored = false;
321 0 : break;
322 : case 2:
323 0 : mnPageLeftMargin = SWPAGE_NORMAL_VALUE;
324 0 : mnPageRightMargin = SWPAGE_NORMAL_VALUE;
325 0 : mnPageTopMargin = SWPAGE_NORMAL_VALUE;
326 0 : mnPageBottomMargin = SWPAGE_NORMAL_VALUE;
327 0 : bMirrored = false;
328 0 : break;
329 : case 3:
330 0 : mnPageLeftMargin = SWPAGE_WIDE_VALUE2;
331 0 : mnPageRightMargin = SWPAGE_WIDE_VALUE2;
332 0 : mnPageTopMargin = SWPAGE_WIDE_VALUE1;
333 0 : mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
334 0 : bMirrored = false;
335 0 : break;
336 : case 4:
337 0 : mnPageLeftMargin = SWPAGE_WIDE_VALUE3;
338 0 : mnPageRightMargin = SWPAGE_WIDE_VALUE1;
339 0 : mnPageTopMargin = SWPAGE_WIDE_VALUE1;
340 0 : mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
341 0 : bMirrored = true;
342 0 : break;
343 : case 5:
344 0 : if ( mbUserCustomValuesAvailable )
345 : {
346 0 : mnPageLeftMargin = mnUserCustomPageLeftMargin;
347 0 : mnPageRightMargin = mnUserCustomPageRightMargin;
348 0 : mnPageTopMargin = mnUserCustomPageTopMargin;
349 0 : mnPageBottomMargin = mnUserCustomPageBottomMargin;
350 0 : bMirrored = mbUserCustomMirrored;
351 : }
352 : else
353 : {
354 0 : bApplyNewPageMargins = false;
355 : }
356 0 : break;
357 : }
358 :
359 0 : if ( bApplyNewPageMargins )
360 : {
361 0 : mrPagePropPanel.StartUndo();
362 0 : mpMarginValueSet->SetNoSelection();
363 0 : mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
364 0 : mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
365 0 : if ( mbMirrored != bMirrored )
366 : {
367 0 : mbMirrored = bMirrored;
368 0 : mrPagePropPanel.ExecutePageLayoutChange( mbMirrored );
369 : }
370 0 : mrPagePropPanel.EndUndo();
371 :
372 0 : mbCustomValuesUsed = false;
373 0 : mrPagePropPanel.ClosePageMarginPopup();
374 : }
375 : else
376 : {
377 : // back to initial selection
378 0 : SelectValueSetItem();
379 : }
380 : }
381 :
382 0 : return 0;
383 : }
384 :
385 0 : IMPL_LINK( PageMarginControl, ModifyLRMarginHdl, MetricField *, EMPTYARG )
386 : {
387 0 : mpMarginValueSet->SetNoSelection();
388 0 : mpMarginValueSet->SelectItem(0);
389 0 : mpMarginValueSet->Format();
390 0 : mpMarginValueSet->StartSelection();
391 :
392 0 : mnPageLeftMargin = GetCoreValue( maLeftMarginEdit, meUnit );
393 0 : mnPageRightMargin = GetCoreValue( maRightMarginEdit, meUnit );
394 0 : mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
395 0 : mbCustomValuesUsed = true;
396 0 : return 0;
397 : }
398 :
399 0 : IMPL_LINK( PageMarginControl, ModifyULMarginHdl, MetricField *, EMPTYARG )
400 : {
401 0 : mpMarginValueSet->SetNoSelection();
402 0 : mpMarginValueSet->SelectItem(0);
403 0 : mpMarginValueSet->Format();
404 0 : mpMarginValueSet->StartSelection();
405 :
406 0 : mnPageTopMargin = GetCoreValue( maTopMarginEdit, meUnit );
407 0 : mnPageBottomMargin = GetCoreValue( maBottomMarginEdit, meUnit );
408 0 : mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
409 0 : mbCustomValuesUsed = true;
410 0 : return 0;
411 : }
412 :
413 0 : bool PageMarginControl::GetUserCustomValues()
414 : {
415 0 : bool bUserCustomValuesAvailable = false;
416 :
417 0 : SvtViewOptions aWinOpt( E_WINDOW, SWPAGE_LEFT_GVALUE );
418 0 : if ( aWinOpt.Exists() )
419 : {
420 0 : ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
421 0 : ::rtl::OUString aTmp;
422 0 : if ( aSeq.getLength())
423 0 : aSeq[0].Value >>= aTmp;
424 0 : OUString aWinData( aTmp );
425 0 : mnUserCustomPageLeftMargin = aWinData.toInt32();
426 0 : bUserCustomValuesAvailable = true;
427 : }
428 :
429 0 : SvtViewOptions aWinOpt2( E_WINDOW, SWPAGE_RIGHT_GVALUE );
430 0 : if ( aWinOpt2.Exists() )
431 : {
432 0 : ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
433 0 : ::rtl::OUString aTmp;
434 0 : if ( aSeq.getLength())
435 0 : aSeq[0].Value >>= aTmp;
436 0 : OUString aWinData( aTmp );
437 0 : mnUserCustomPageRightMargin = aWinData.toInt32();
438 0 : bUserCustomValuesAvailable = true;
439 : }
440 :
441 0 : SvtViewOptions aWinOpt3( E_WINDOW, SWPAGE_TOP_GVALUE );
442 0 : if ( aWinOpt3.Exists() )
443 : {
444 0 : ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt3.GetUserData();
445 0 : ::rtl::OUString aTmp;
446 0 : if ( aSeq.getLength())
447 0 : aSeq[0].Value >>= aTmp;
448 0 : OUString aWinData( aTmp );
449 0 : mnUserCustomPageTopMargin = aWinData.toInt32();
450 0 : bUserCustomValuesAvailable = true;
451 : }
452 :
453 0 : SvtViewOptions aWinOpt4( E_WINDOW, SWPAGE_DOWN_GVALUE );
454 0 : if ( aWinOpt4.Exists() )
455 : {
456 0 : ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt4.GetUserData();
457 0 : ::rtl::OUString aTmp;
458 0 : if ( aSeq.getLength())
459 0 : aSeq[0].Value >>= aTmp;
460 0 : OUString aWinData( aTmp );
461 0 : mnUserCustomPageBottomMargin = aWinData.toInt32();
462 0 : bUserCustomValuesAvailable = true;
463 : }
464 :
465 0 : SvtViewOptions aWinOpt5( E_WINDOW, SWPAGE_MIRROR_GVALUE );
466 0 : if ( aWinOpt5.Exists() )
467 : {
468 0 : ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt5.GetUserData();
469 0 : ::rtl::OUString aTmp;
470 0 : if ( aSeq.getLength())
471 0 : aSeq[0].Value >>= aTmp;
472 0 : OUString aWinData( aTmp );
473 0 : mbUserCustomMirrored = aWinData.toInt32() == 0 ? false : true;
474 0 : bUserCustomValuesAvailable = true;
475 : }
476 :
477 0 : return bUserCustomValuesAvailable;
478 : }
479 :
480 0 : void PageMarginControl::StoreUserCustomValues()
481 : {
482 0 : if ( !mbCustomValuesUsed )
483 : {
484 0 : return;
485 : }
486 :
487 0 : ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
488 0 : SvtViewOptions aWinOpt( E_WINDOW, SWPAGE_LEFT_GVALUE );
489 :
490 0 : aSeq[0].Name = "mnPageLeftMargin";
491 0 : aSeq[0].Value <<= ::rtl::OUString::number( mnPageLeftMargin );
492 0 : aWinOpt.SetUserData( aSeq );
493 :
494 0 : SvtViewOptions aWinOpt2( E_WINDOW, SWPAGE_RIGHT_GVALUE );
495 0 : aSeq[0].Name = "mnPageRightMargin";
496 0 : aSeq[0].Value <<= ::rtl::OUString::number( mnPageRightMargin );
497 0 : aWinOpt2.SetUserData( aSeq );
498 :
499 0 : SvtViewOptions aWinOpt3( E_WINDOW, SWPAGE_TOP_GVALUE );
500 0 : aSeq[0].Name = "mnPageTopMargin";
501 0 : aSeq[0].Value <<= ::rtl::OUString::number( mnPageTopMargin );
502 0 : aWinOpt3.SetUserData( aSeq );
503 :
504 0 : SvtViewOptions aWinOpt4( E_WINDOW, SWPAGE_DOWN_GVALUE );
505 0 : aSeq[0].Name = "mnPageBottomMargin";
506 0 : aSeq[0].Value <<= ::rtl::OUString::number( mnPageBottomMargin );
507 0 : aWinOpt4.SetUserData( aSeq );
508 :
509 0 : SvtViewOptions aWinOpt5( E_WINDOW, SWPAGE_MIRROR_GVALUE );
510 0 : aSeq[0].Name = "mbMirrored";
511 0 : aSeq[0].Value <<= ::rtl::OUString::number( (mbMirrored ? 1 : 0) );
512 0 : aWinOpt5.SetUserData( aSeq );
513 : }
514 :
515 270 : } } // end of namespace sw::sidebar
516 :
517 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|