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