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