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 <sfx2/app.hxx>
21 : #include <sfx2/objsh.hxx>
22 : #include <tools/resary.hxx>
23 : #include <vcl/graph.hxx>
24 : #include <sfx2/viewsh.hxx>
25 : #include <svl/itemiter.hxx>
26 : #include <svl/languageoptions.hxx>
27 : #include <vcl/msgbox.hxx>
28 : #include <unotools/configitem.hxx>
29 : #include <sfx2/htmlmode.hxx>
30 : #include <sal/macros.h>
31 :
32 : #include <cuires.hrc>
33 : #include "helpid.hrc"
34 : #include "page.hxx"
35 : #include <svx/pageitem.hxx>
36 : #include <editeng/brushitem.hxx>
37 : #include <editeng/boxitem.hxx>
38 : #include <editeng/shaditem.hxx>
39 : #include <editeng/pbinitem.hxx>
40 : #include <editeng/lrspitem.hxx>
41 : #include <editeng/ulspitem.hxx>
42 : #include <editeng/sizeitem.hxx>
43 : #include <editeng/frmdiritem.hxx>
44 : #include "svx/dlgutil.hxx"
45 : #include <editeng/paperinf.hxx>
46 : #include <dialmgr.hxx>
47 : #include <sfx2/module.hxx>
48 : #include <svl/stritem.hxx>
49 : #include <svx/dialogs.hrc>
50 : #include <editeng/eerdll.hxx>
51 : #include <editeng/editrids.hrc>
52 : #include <svx/svxids.hrc>
53 : #include <svtools/optionsdrawinglayer.hxx>
54 : #include <svl/slstitm.hxx>
55 : #include <svl/aeitem.hxx>
56 : #include <sfx2/request.hxx>
57 :
58 : //UUUU
59 : #include <svx/xdef.hxx>
60 : #include <svx/unobrushitemhelper.hxx>
61 :
62 : #include <numpages.hxx>
63 : #include <boost/scoped_ptr.hpp>
64 :
65 : // static ----------------------------------------------------------------
66 :
67 : static const long MINBODY = 284; // 0,5 cm rounded up in twips
68 : //static const long PRINT_OFFSET = 17; // 0,03 cm rounded down in twips
69 : static const long PRINT_OFFSET = 0; // why was this ever set to 17 ? it led to wrong right and bottom margins.
70 :
71 : static const sal_uInt16 pRanges[] =
72 : {
73 : SID_ATTR_BORDER_OUTER,
74 : SID_ATTR_BORDER_SHADOW,
75 : SID_ATTR_LRSPACE,
76 : SID_ATTR_PAGE_SHARED,
77 : SID_SWREGISTER_COLLECTION,
78 : SID_SWREGISTER_MODE,
79 : 0
80 : };
81 : // ------- Mapping page layout ------------------------------------------
82 :
83 : const sal_uInt16 aArr[] =
84 : {
85 : SVX_PAGE_ALL,
86 : SVX_PAGE_MIRROR,
87 : SVX_PAGE_RIGHT,
88 : SVX_PAGE_LEFT
89 : };
90 :
91 :
92 :
93 0 : sal_uInt16 PageUsageToPos_Impl( sal_uInt16 nUsage )
94 : {
95 0 : for ( sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aArr); ++i )
96 0 : if ( aArr[i] == ( nUsage & 0x000f ) )
97 0 : return i;
98 0 : return SVX_PAGE_ALL;
99 : }
100 :
101 :
102 :
103 0 : sal_uInt16 PosToPageUsage_Impl( sal_uInt16 nPos )
104 : {
105 0 : if ( nPos >= SAL_N_ELEMENTS(aArr) )
106 0 : return 0;
107 0 : return aArr[nPos];
108 : }
109 :
110 :
111 :
112 0 : Size GetMinBorderSpace_Impl( const SvxShadowItem& rShadow, const SvxBoxItem& rBox )
113 : {
114 0 : Size aSz;
115 0 : aSz.Height() = rShadow.CalcShadowSpace( SHADOW_BOTTOM ) + rBox.CalcLineSpace( BOX_LINE_BOTTOM );
116 0 : aSz.Height() += rShadow.CalcShadowSpace( SHADOW_TOP ) + rBox.CalcLineSpace( BOX_LINE_TOP );
117 0 : aSz.Width() = rShadow.CalcShadowSpace( SHADOW_LEFT ) + rBox.CalcLineSpace( BOX_LINE_LEFT );
118 0 : aSz.Width() += rShadow.CalcShadowSpace( SHADOW_RIGHT ) + rBox.CalcLineSpace( BOX_LINE_RIGHT );
119 0 : return aSz;
120 : }
121 :
122 :
123 :
124 0 : long ConvertLong_Impl( const long nIn, SfxMapUnit eUnit )
125 : {
126 0 : return OutputDevice::LogicToLogic( nIn, (MapUnit)eUnit, MAP_TWIP );
127 : }
128 :
129 0 : bool IsEqualSize_Impl( const SvxSizeItem* pSize, const Size& rSize )
130 : {
131 0 : if ( pSize )
132 : {
133 0 : Size aSize = pSize->GetSize();
134 0 : long nDiffW = std::abs( rSize.Width () - aSize.Width () );
135 0 : long nDiffH = std::abs( rSize.Height() - aSize.Height() );
136 0 : return ( nDiffW < 10 && nDiffH < 10 );
137 : }
138 : else
139 0 : return false;
140 : }
141 :
142 :
143 :
144 : #define MARGIN_LEFT ( (MarginPosition)0x0001 )
145 : #define MARGIN_RIGHT ( (MarginPosition)0x0002 )
146 : #define MARGIN_TOP ( (MarginPosition)0x0004 )
147 : #define MARGIN_BOTTOM ( (MarginPosition)0x0008 )
148 :
149 : //UUUU
150 : //struct SvxPage_Impl
151 : //{
152 : // MarginPosition m_nPos;
153 : // Printer* mpDefPrinter;
154 : // bool mbDelPrinter;
155 : //
156 : // SvxPage_Impl() :
157 : // m_nPos( 0 ),
158 : // mpDefPrinter( 0 ),
159 : // mbDelPrinter( false ) {}
160 : //
161 : // ~SvxPage_Impl() { if ( mbDelPrinter ) delete mpDefPrinter; }
162 : //};
163 :
164 : // class SvxPageDescPage --------------------------------------------------
165 :
166 : // returns the range of the Which values
167 0 : const sal_uInt16* SvxPageDescPage::GetRanges()
168 : {
169 0 : return pRanges;
170 : }
171 :
172 :
173 :
174 0 : SfxTabPage* SvxPageDescPage::Create( vcl::Window* pParent, const SfxItemSet* rSet )
175 : {
176 0 : return new SvxPageDescPage( pParent, *rSet );
177 : }
178 :
179 0 : SvxPageDescPage::SvxPageDescPage( vcl::Window* pParent, const SfxItemSet& rAttr ) :
180 :
181 : SfxTabPage( pParent, "PageFormatPage", "cui/ui/pageformatpage.ui", &rAttr ),
182 :
183 : bLandscape ( false ),
184 : eMode ( SVX_PAGE_MODE_STANDARD ),
185 : ePaperStart ( PAPER_A3 ),
186 : ePaperEnd ( PAPER_ENV_DL ),
187 :
188 : //UUUU
189 : // pImpl ( new SvxPage_Impl ),
190 :
191 : //UUUU
192 : m_nPos( 0 ),
193 : mpDefPrinter( 0 ),
194 : mbDelPrinter( false ),
195 :
196 : //UUUU
197 0 : mbEnableDrawingLayerFillStyles(false)
198 : {
199 0 : get(m_pPaperSizeBox,"comboPageFormat");
200 0 : get(m_pPaperWidthEdit,"spinWidth");
201 0 : get(m_pPaperHeightEdit,"spinHeight");
202 :
203 0 : get(m_pOrientationFT,"labelOrientation");
204 0 : get(m_pPortraitBtn,"radiobuttonPortrait");
205 0 : get(m_pLandscapeBtn,"radiobuttonLandscape");
206 :
207 0 : get(m_pBspWin,"drawingareaPageDirection");
208 0 : get(m_pTextFlowLbl,"labelTextFlow");
209 0 : get(m_pTextFlowBox,"comboTextFlowBox");
210 0 : get(m_pPaperTrayBox,"comboPaperTray");
211 :
212 0 : get(m_pLeftMarginLbl,"labelLeftMargin");
213 0 : get(m_pLeftMarginEdit,"spinMargLeft");
214 0 : get(m_pRightMarginLbl,"labelRightMargin");
215 0 : get(m_pRightMarginEdit,"spinMargRight");
216 :
217 0 : get(m_pTopMarginEdit,"spinMargTop");
218 :
219 0 : get(m_pBottomMarginEdit,"spinMargBot");
220 :
221 0 : get(m_pPageText,"labelPageLayout");
222 0 : get(m_pLayoutBox,"comboPageLayout");
223 0 : get(m_pNumberFormatBox,"comboLayoutFormat");
224 :
225 0 : get(m_pRegisterCB,"checkRegisterTrue");
226 0 : get(m_pRegisterFT,"labelRegisterStyle");
227 0 : get(m_pRegisterLB,"comboRegisterStyle");
228 :
229 0 : get(m_pTblAlignFT,"labelTblAlign");
230 0 : get(m_pHorzBox,"checkbuttonHorz");
231 0 : get(m_pVertBox,"checkbuttonVert");
232 :
233 0 : get(m_pAdaptBox,"checkAdaptBox");
234 : // Strings stored in UI
235 0 : get(m_pInsideLbl,"labelInner");
236 0 : get(m_pOutsideLbl,"labelOuter");
237 0 : get(m_pPrintRangeQueryText,"labelMsg");
238 :
239 0 : bBorderModified = false;
240 0 : m_pBspWin->EnableRTL( false );
241 :
242 : // this page needs ExchangeSupport
243 0 : SetExchangeSupport();
244 :
245 0 : SvtLanguageOptions aLangOptions;
246 0 : bool bCJK = aLangOptions.IsAsianTypographyEnabled();
247 0 : bool bCTL = aLangOptions.IsCTLFontEnabled();
248 0 : bool bWeb = false;
249 : const SfxPoolItem* pItem;
250 :
251 : SfxObjectShell* pShell;
252 0 : if(SfxItemState::SET == rAttr.GetItemState(SID_HTML_MODE, false, &pItem) ||
253 0 : ( 0 != (pShell = SfxObjectShell::Current()) &&
254 0 : 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
255 0 : bWeb = 0 != (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON);
256 :
257 : // fill text flow listbox with valid entries
258 :
259 0 : m_pTextFlowBox->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_HORI ), FRMDIR_HORI_LEFT_TOP );
260 :
261 :
262 0 : if( bCTL )
263 0 : m_pTextFlowBox->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_HORI ), FRMDIR_HORI_RIGHT_TOP );
264 :
265 :
266 : // #109989# do not show vertical directions in Writer/Web
267 0 : if( !bWeb )
268 : {
269 0 : if( bCJK )
270 : {
271 0 : m_pTextFlowBox->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_VERT ), FRMDIR_VERT_TOP_RIGHT );
272 : // m_pTextFlowBox->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_VERT ), FRMDIR_VERT_TOP_LEFT );
273 : }
274 : }
275 :
276 : // #109989# show the text direction box in Writer/Web too
277 0 : if( (bCJK || bCTL) &&
278 0 : SfxItemState::UNKNOWN < rAttr.GetItemState(GetWhich( SID_ATTR_FRAMEDIRECTION )))
279 : {
280 0 : m_pTextFlowLbl->Show();
281 0 : m_pTextFlowBox->Show();
282 0 : m_pTextFlowBox->SetSelectHdl(LINK(this, SvxPageDescPage, FrameDirectionModify_Impl ));
283 :
284 0 : m_pBspWin->EnableFrameDirection(true);
285 : }
286 0 : Init_Impl();
287 :
288 0 : FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
289 0 : SetFieldUnit( *m_pLeftMarginEdit, eFUnit );
290 0 : SetFieldUnit( *m_pRightMarginEdit, eFUnit );
291 0 : SetFieldUnit( *m_pTopMarginEdit, eFUnit );
292 0 : SetFieldUnit( *m_pBottomMarginEdit, eFUnit );
293 0 : SetFieldUnit( *m_pPaperWidthEdit, eFUnit );
294 0 : SetFieldUnit( *m_pPaperHeightEdit, eFUnit );
295 :
296 0 : if ( SfxViewShell::Current() && SfxViewShell::Current()->GetPrinter() )
297 : {
298 0 : mpDefPrinter = (Printer*)SfxViewShell::Current()->GetPrinter();
299 : }
300 : else
301 : {
302 0 : mpDefPrinter = new Printer;
303 0 : mbDelPrinter = true;
304 : }
305 :
306 0 : MapMode aOldMode = mpDefPrinter->GetMapMode();
307 0 : mpDefPrinter->SetMapMode( MAP_TWIP );
308 :
309 : // set first- and last-values for the margins
310 0 : Size aPaperSize = mpDefPrinter->GetPaperSize();
311 0 : Size aPrintSize = mpDefPrinter->GetOutputSize();
312 : /*
313 : * To convert a point ( 0,0 ) into logic coordinates
314 : * looks like nonsense; but it makes sense when the
315 : * coordinate system's origin has been moved.
316 : */
317 0 : Point aPrintOffset = mpDefPrinter->GetPageOffset() - mpDefPrinter->PixelToLogic( Point() );
318 0 : mpDefPrinter->SetMapMode( aOldMode );
319 :
320 0 : long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET;
321 0 : m_pLeftMarginEdit->SetFirst( m_pLeftMarginEdit->Normalize( aPrintOffset.X() ), FUNIT_TWIP );
322 0 : nFirstLeftMargin = static_cast<long>(m_pLeftMarginEdit->GetFirst());
323 :
324 0 : m_pRightMarginEdit->SetFirst( m_pRightMarginEdit->Normalize( aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset ), FUNIT_TWIP);
325 0 : nFirstRightMargin = static_cast<long>(m_pRightMarginEdit->GetFirst());
326 :
327 0 : m_pTopMarginEdit->SetFirst( m_pTopMarginEdit->Normalize( aPrintOffset.Y() ), FUNIT_TWIP );
328 0 : nFirstTopMargin = static_cast<long>(m_pTopMarginEdit->GetFirst());
329 :
330 0 : m_pBottomMarginEdit->SetFirst( m_pBottomMarginEdit->Normalize( aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset ), FUNIT_TWIP );
331 0 : nFirstBottomMargin = static_cast<long>(m_pBottomMarginEdit->GetFirst());
332 :
333 0 : m_pLeftMarginEdit->SetLast( m_pLeftMarginEdit->Normalize( aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP );
334 0 : nLastLeftMargin = static_cast<long>(m_pLeftMarginEdit->GetLast());
335 :
336 0 : m_pRightMarginEdit->SetLast( m_pRightMarginEdit->Normalize( aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP );
337 0 : nLastRightMargin = static_cast<long>(m_pRightMarginEdit->GetLast());
338 :
339 0 : m_pTopMarginEdit->SetLast( m_pTopMarginEdit->Normalize( aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP );
340 0 : nLastTopMargin = static_cast<long>(m_pTopMarginEdit->GetLast());
341 :
342 0 : m_pBottomMarginEdit->SetLast( m_pBottomMarginEdit->Normalize( aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP );
343 0 : nLastBottomMargin = static_cast<long>(m_pBottomMarginEdit->GetLast());
344 :
345 : // #i4219# get DrawingLayer options
346 0 : const SvtOptionsDrawinglayer aDrawinglayerOpt;
347 :
348 : // #i4219# take Maximum now from configuration (1/100th cm)
349 : // was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000
350 0 : m_pPaperWidthEdit->SetMax(m_pPaperWidthEdit->Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
351 0 : m_pPaperWidthEdit->SetLast(m_pPaperWidthEdit->Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
352 0 : m_pPaperHeightEdit->SetMax(m_pPaperHeightEdit->Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
353 0 : m_pPaperHeightEdit->SetLast(m_pPaperHeightEdit->Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
354 :
355 : // #i4219# also for margins (1/100th cm). Was: 9999, keeping.
356 0 : m_pLeftMarginEdit->SetMax(aDrawinglayerOpt.GetMaximumPaperLeftMargin());
357 0 : m_pLeftMarginEdit->SetLast(aDrawinglayerOpt.GetMaximumPaperLeftMargin());
358 0 : m_pRightMarginEdit->SetMax(aDrawinglayerOpt.GetMaximumPaperRightMargin());
359 0 : m_pRightMarginEdit->SetLast(aDrawinglayerOpt.GetMaximumPaperRightMargin());
360 0 : m_pTopMarginEdit->SetMax(aDrawinglayerOpt.GetMaximumPaperTopMargin());
361 0 : m_pTopMarginEdit->SetLast(aDrawinglayerOpt.GetMaximumPaperTopMargin());
362 0 : m_pBottomMarginEdit->SetMax(aDrawinglayerOpt.GetMaximumPaperBottomMargin());
363 0 : m_pBottomMarginEdit->SetLast(aDrawinglayerOpt.GetMaximumPaperBottomMargin());
364 :
365 0 : m_pPortraitBtn->SetAccessibleRelationMemberOf(m_pOrientationFT);
366 0 : m_pLandscapeBtn->SetAccessibleRelationMemberOf(m_pOrientationFT);
367 :
368 : // Get the i18n framework numberings and add them to the listbox.
369 0 : SvxNumOptionsTabPage::GetI18nNumbering( *m_pNumberFormatBox, ::std::numeric_limits<sal_uInt16>::max());
370 0 : }
371 :
372 :
373 :
374 0 : SvxPageDescPage::~SvxPageDescPage()
375 : {
376 0 : if(mbDelPrinter)
377 : {
378 0 : delete mpDefPrinter;
379 : }
380 0 : }
381 :
382 :
383 :
384 0 : void SvxPageDescPage::Init_Impl()
385 : {
386 : // adjust the handler
387 0 : m_pLayoutBox->SetSelectHdl( LINK( this, SvxPageDescPage, LayoutHdl_Impl ) );
388 0 : m_pPaperSizeBox->SetDropDownLineCount(10);
389 :
390 0 : m_pPaperTrayBox->SetGetFocusHdl( LINK( this, SvxPageDescPage, PaperBinHdl_Impl ) );
391 0 : m_pPaperSizeBox->SetSelectHdl( LINK( this, SvxPageDescPage, PaperSizeSelect_Impl ) );
392 0 : m_pPaperWidthEdit->SetModifyHdl( LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) );
393 0 : m_pPaperHeightEdit->SetModifyHdl( LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) );
394 0 : m_pLandscapeBtn->SetClickHdl( LINK( this, SvxPageDescPage, SwapOrientation_Impl ) );
395 0 : m_pPortraitBtn->SetClickHdl( LINK( this, SvxPageDescPage, SwapOrientation_Impl ) );
396 :
397 0 : Link aLink = LINK( this, SvxPageDescPage, BorderModify_Impl );
398 0 : m_pLeftMarginEdit->SetModifyHdl( aLink );
399 0 : m_pRightMarginEdit->SetModifyHdl( aLink );
400 0 : m_pTopMarginEdit->SetModifyHdl( aLink );
401 0 : m_pBottomMarginEdit->SetModifyHdl( aLink );
402 :
403 0 : aLink = LINK( this, SvxPageDescPage, RangeHdl_Impl );
404 0 : m_pPaperWidthEdit->SetLoseFocusHdl( aLink );
405 0 : m_pPaperHeightEdit->SetLoseFocusHdl( aLink );
406 0 : m_pLeftMarginEdit->SetLoseFocusHdl( aLink );
407 0 : m_pRightMarginEdit->SetLoseFocusHdl( aLink );
408 0 : m_pTopMarginEdit->SetLoseFocusHdl( aLink );
409 0 : m_pBottomMarginEdit->SetLoseFocusHdl( aLink );
410 :
411 0 : m_pHorzBox->SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) );
412 0 : m_pVertBox->SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) );
413 :
414 0 : }
415 :
416 :
417 :
418 0 : void SvxPageDescPage::Reset( const SfxItemSet* rSet )
419 : {
420 0 : SfxItemPool* pPool = rSet->GetPool();
421 : DBG_ASSERT( pPool, "Wo ist der Pool" );
422 0 : SfxMapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) );
423 :
424 : // adjust margins (right/left)
425 0 : const SfxPoolItem* pItem = GetItem( *rSet, SID_ATTR_LRSPACE );
426 :
427 0 : if ( pItem )
428 : {
429 0 : const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(*pItem);
430 0 : SetMetricValue( *m_pLeftMarginEdit, rLRSpace.GetLeft(), eUnit );
431 : m_pBspWin->SetLeft(
432 0 : (sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetLeft(), eUnit ) );
433 0 : SetMetricValue( *m_pRightMarginEdit, rLRSpace.GetRight(), eUnit );
434 : m_pBspWin->SetRight(
435 0 : (sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetRight(), eUnit ) );
436 : }
437 :
438 : // adjust margins (top/bottom)
439 0 : pItem = GetItem( *rSet, SID_ATTR_ULSPACE );
440 :
441 0 : if ( pItem )
442 : {
443 0 : const SvxULSpaceItem& rULSpace = static_cast<const SvxULSpaceItem&>(*pItem);
444 0 : SetMetricValue( *m_pTopMarginEdit, rULSpace.GetUpper(), eUnit );
445 : m_pBspWin->SetTop(
446 0 : (sal_uInt16)ConvertLong_Impl( (long)rULSpace.GetUpper(), eUnit ) );
447 0 : SetMetricValue( *m_pBottomMarginEdit, rULSpace.GetLower(), eUnit );
448 : m_pBspWin->SetBottom(
449 0 : (sal_uInt16)ConvertLong_Impl( (long)rULSpace.GetLower(), eUnit ) );
450 : }
451 :
452 : // general page data
453 0 : SvxNumType eNumType = SVX_ARABIC;
454 0 : bLandscape = ( mpDefPrinter->GetOrientation() == ORIENTATION_LANDSCAPE );
455 0 : sal_uInt16 nUse = (sal_uInt16)SVX_PAGE_ALL;
456 0 : pItem = GetItem( *rSet, SID_ATTR_PAGE );
457 :
458 0 : if ( pItem )
459 : {
460 0 : const SvxPageItem& rItem = static_cast<const SvxPageItem&>(*pItem);
461 0 : eNumType = rItem.GetNumType();
462 0 : nUse = rItem.GetPageUsage();
463 0 : bLandscape = rItem.IsLandscape();
464 : }
465 :
466 : // alignment
467 0 : m_pLayoutBox->SelectEntryPos( ::PageUsageToPos_Impl( nUse ) );
468 0 : m_pBspWin->SetUsage( nUse );
469 0 : LayoutHdl_Impl( 0 );
470 :
471 : //adjust numeration type of the page style
472 : //Get the Position of the saved NumType
473 0 : for(int i=0; i<m_pNumberFormatBox->GetEntryCount(); i++)
474 0 : if(eNumType == (sal_uInt16)reinterpret_cast<sal_uLong>(m_pNumberFormatBox->GetEntryData(i)))
475 : {
476 0 : m_pNumberFormatBox->SelectEntryPos( i );
477 0 : break;
478 : }
479 :
480 0 : m_pPaperTrayBox->Clear();
481 0 : sal_uInt8 nPaperBin = PAPERBIN_PRINTER_SETTINGS;
482 0 : pItem = GetItem( *rSet, SID_ATTR_PAGE_PAPERBIN );
483 :
484 0 : if ( pItem )
485 : {
486 0 : nPaperBin = static_cast<const SvxPaperBinItem*>(pItem)->GetValue();
487 :
488 0 : if ( nPaperBin >= mpDefPrinter->GetPaperBinCount() )
489 0 : nPaperBin = PAPERBIN_PRINTER_SETTINGS;
490 : }
491 :
492 0 : OUString aBinName;
493 :
494 0 : if ( PAPERBIN_PRINTER_SETTINGS == nPaperBin )
495 0 : aBinName = EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS );
496 : else
497 0 : aBinName = mpDefPrinter->GetPaperBinName( (sal_uInt16)nPaperBin );
498 :
499 0 : sal_uInt16 nEntryPos = m_pPaperTrayBox->InsertEntry( aBinName );
500 0 : m_pPaperTrayBox->SetEntryData( nEntryPos, reinterpret_cast<void*>((sal_uLong)nPaperBin) );
501 0 : m_pPaperTrayBox->SelectEntry( aBinName );
502 :
503 0 : Size aPaperSize = SvxPaperInfo::GetPaperSize( mpDefPrinter );
504 0 : pItem = GetItem( *rSet, SID_ATTR_PAGE_SIZE );
505 :
506 0 : if ( pItem )
507 0 : aPaperSize = static_cast<const SvxSizeItem*>(pItem)->GetSize();
508 :
509 : bool bOrientationSupport =
510 0 : mpDefPrinter->HasSupport( SUPPORT_SET_ORIENTATION );
511 :
512 0 : if ( !bOrientationSupport &&
513 0 : aPaperSize.Width() > aPaperSize.Height() )
514 0 : bLandscape = true;
515 :
516 0 : m_pLandscapeBtn->Check( bLandscape );
517 0 : m_pPortraitBtn->Check( !bLandscape );
518 :
519 0 : m_pBspWin->SetSize( Size( ConvertLong_Impl( aPaperSize.Width(), eUnit ),
520 0 : ConvertLong_Impl( aPaperSize.Height(), eUnit ) ) );
521 :
522 0 : aPaperSize = OutputDevice::LogicToLogic(aPaperSize, (MapUnit)eUnit, MAP_100TH_MM);
523 0 : if ( bLandscape )
524 0 : Swap( aPaperSize );
525 :
526 : // Actual Paper Format
527 0 : Paper ePaper = SvxPaperInfo::GetSvxPaper( aPaperSize, MAP_100TH_MM, true );
528 :
529 0 : if ( PAPER_USER != ePaper )
530 0 : aPaperSize = SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM );
531 :
532 0 : if ( bLandscape )
533 0 : Swap( aPaperSize );
534 :
535 : // write values into the edits
536 0 : SetMetricValue( *m_pPaperHeightEdit, aPaperSize.Height(), SFX_MAPUNIT_100TH_MM );
537 0 : SetMetricValue( *m_pPaperWidthEdit, aPaperSize.Width(), SFX_MAPUNIT_100TH_MM );
538 0 : m_pPaperSizeBox->Clear();
539 :
540 0 : sal_Int32 nActPos = LISTBOX_ENTRY_NOTFOUND;
541 0 : sal_uInt16 nAryId = RID_SVXSTRARY_PAPERSIZE_STD;
542 :
543 0 : if ( ePaperStart != PAPER_A3 )
544 0 : nAryId = RID_SVXSTRARY_PAPERSIZE_DRAW;
545 0 : ResStringArray aPaperAry( CUI_RES( nAryId ) );
546 0 : sal_uInt32 nCnt = aPaperAry.Count();
547 :
548 0 : sal_Int32 nUserPos = LISTBOX_ENTRY_NOTFOUND;
549 0 : for ( sal_uInt32 i = 0; i < nCnt; ++i )
550 : {
551 0 : OUString aStr = aPaperAry.GetString(i);
552 0 : Paper eSize = (Paper)aPaperAry.GetValue(i);
553 0 : sal_Int32 nPos = m_pPaperSizeBox->InsertEntry( aStr );
554 0 : m_pPaperSizeBox->SetEntryData( nPos, reinterpret_cast<void*>((sal_uLong)eSize) );
555 :
556 0 : if ( eSize == ePaper )
557 0 : nActPos = nPos;
558 0 : if( eSize == PAPER_USER )
559 0 : nUserPos = nPos;
560 0 : }
561 : // preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead
562 0 : m_pPaperSizeBox->SelectEntryPos( nActPos != LISTBOX_ENTRY_NOTFOUND ? nActPos : nUserPos );
563 :
564 : // application specific
565 :
566 0 : switch ( eMode )
567 : {
568 : case SVX_PAGE_MODE_CENTER:
569 : {
570 0 : m_pTblAlignFT->Show();
571 0 : m_pHorzBox->Show();
572 0 : m_pVertBox->Show();
573 0 : DisableVerticalPageDir();
574 :
575 : // horizontal alignment
576 0 : pItem = GetItem( *rSet, SID_ATTR_PAGE_EXT1 );
577 0 : m_pHorzBox->Check( pItem ? static_cast<const SfxBoolItem*>(pItem)->GetValue()
578 0 : : sal_False );
579 :
580 : // vertical alignment
581 0 : pItem = GetItem( *rSet, SID_ATTR_PAGE_EXT2 );
582 0 : m_pVertBox->Check( pItem ? static_cast<const SfxBoolItem*>(pItem)->GetValue()
583 0 : : sal_False );
584 :
585 : // set example window on the table
586 0 : m_pBspWin->SetTable( true );
587 0 : m_pBspWin->SetHorz( m_pHorzBox->IsChecked() );
588 0 : m_pBspWin->SetVert( m_pVertBox->IsChecked() );
589 :
590 0 : break;
591 : }
592 :
593 : case SVX_PAGE_MODE_PRESENTATION:
594 : {
595 0 : DisableVerticalPageDir();
596 0 : m_pAdaptBox->Show();
597 0 : pItem = GetItem( *rSet, SID_ATTR_PAGE_EXT1 );
598 : m_pAdaptBox->Check( pItem ?
599 0 : static_cast<const SfxBoolItem*>(pItem)->GetValue() : sal_False );
600 :
601 : //!!! hidden, because not implemented by StarDraw
602 0 : m_pLayoutBox->Hide();
603 0 : m_pPageText->Hide();
604 :
605 0 : break;
606 : }
607 : default: ;//prevent warning
608 : }
609 :
610 :
611 : // display background and border in the example
612 0 : ResetBackground_Impl( *rSet );
613 : //! UpdateExample_Impl();
614 0 : RangeHdl_Impl( 0 );
615 :
616 0 : InitHeadFoot_Impl( *rSet );
617 :
618 0 : bBorderModified = false;
619 0 : SwapFirstValues_Impl( false );
620 0 : UpdateExample_Impl();
621 :
622 0 : m_pLeftMarginEdit->SaveValue();
623 0 : m_pRightMarginEdit->SaveValue();
624 0 : m_pTopMarginEdit->SaveValue();
625 0 : m_pBottomMarginEdit->SaveValue();
626 0 : m_pLayoutBox->SaveValue();
627 0 : m_pNumberFormatBox->SaveValue();
628 0 : m_pPaperSizeBox->SaveValue();
629 0 : m_pPaperWidthEdit->SaveValue();
630 0 : m_pPaperHeightEdit->SaveValue();
631 0 : m_pPortraitBtn->SaveValue();
632 0 : m_pLandscapeBtn->SaveValue();
633 0 : m_pPaperTrayBox->SaveValue();
634 0 : m_pVertBox->SaveValue();
635 0 : m_pHorzBox->SaveValue();
636 0 : m_pAdaptBox->SaveValue();
637 :
638 0 : CheckMarginEdits( true );
639 :
640 :
641 0 : if(SfxItemState::SET == rSet->GetItemState(SID_SWREGISTER_MODE))
642 : {
643 : m_pRegisterCB->Check(static_cast<const SfxBoolItem&>(rSet->Get(
644 0 : SID_SWREGISTER_MODE)).GetValue());
645 0 : m_pRegisterCB->SaveValue();
646 0 : RegisterModify(m_pRegisterCB);
647 : }
648 0 : if(SfxItemState::SET == rSet->GetItemState(SID_SWREGISTER_COLLECTION))
649 : {
650 : m_pRegisterLB->SelectEntry(
651 0 : static_cast<const SfxStringItem&>(rSet->Get(SID_SWREGISTER_COLLECTION)).GetValue());
652 0 : m_pRegisterLB->SaveValue();
653 : }
654 :
655 0 : SfxItemState eState = rSet->GetItemState( GetWhich( SID_ATTR_FRAMEDIRECTION ),
656 0 : true, &pItem );
657 0 : if( SfxItemState::UNKNOWN != eState )
658 : {
659 : sal_uInt32 nVal = SfxItemState::SET == eState
660 0 : ? static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue()
661 0 : : 0;
662 0 : m_pTextFlowBox->SelectEntryValue( static_cast< SvxFrameDirection >( nVal ) );
663 :
664 0 : m_pTextFlowBox->SaveValue();
665 0 : m_pBspWin->SetFrameDirection(nVal);
666 0 : }
667 0 : }
668 :
669 :
670 :
671 0 : void SvxPageDescPage::FillUserData()
672 : {
673 0 : if ( SVX_PAGE_MODE_PRESENTATION == eMode )
674 0 : SetUserData( m_pAdaptBox->IsChecked() ? OUString("1") : OUString("0") ) ;
675 :
676 0 : }
677 :
678 :
679 :
680 0 : bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet )
681 : {
682 0 : bool bModified = false;
683 0 : const SfxItemSet& rOldSet = GetItemSet();
684 0 : SfxItemPool* pPool = rOldSet.GetPool();
685 : DBG_ASSERT( pPool, "Wo ist der Pool" );
686 0 : sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE );
687 0 : SfxMapUnit eUnit = pPool->GetMetric( nWhich );
688 0 : const SfxPoolItem* pOld = 0;
689 :
690 : // copy old left and right margins
691 0 : SvxLRSpaceItem aMargin( static_cast<const SvxLRSpaceItem&>(rOldSet.Get( nWhich )) );
692 :
693 : // copy old top and bottom margins
694 0 : nWhich = GetWhich( SID_ATTR_ULSPACE );
695 0 : SvxULSpaceItem aTopMargin( static_cast<const SvxULSpaceItem&>(rOldSet.Get( nWhich )) );
696 :
697 0 : if ( m_pLeftMarginEdit->IsValueChangedFromSaved() )
698 : {
699 0 : aMargin.SetLeft( (sal_uInt16)GetCoreValue( *m_pLeftMarginEdit, eUnit ) );
700 0 : bModified = true;
701 : }
702 :
703 0 : if ( m_pRightMarginEdit->IsValueChangedFromSaved() )
704 : {
705 0 : aMargin.SetRight( (sal_uInt16)GetCoreValue( *m_pRightMarginEdit, eUnit ) );
706 0 : bModified = true;
707 : }
708 :
709 : // set left and right margins
710 0 : if ( bModified )
711 : {
712 0 : pOld = GetOldItem( *rSet, SID_ATTR_LRSPACE );
713 :
714 0 : if ( !pOld || !( *static_cast<const SvxLRSpaceItem*>(pOld) == aMargin ) )
715 0 : rSet->Put( aMargin );
716 : else
717 0 : bModified = false;
718 : }
719 :
720 0 : bool bMod = false;
721 :
722 0 : if ( m_pTopMarginEdit->IsValueChangedFromSaved() )
723 : {
724 0 : aTopMargin.SetUpper( (sal_uInt16)GetCoreValue( *m_pTopMarginEdit, eUnit ) );
725 0 : bMod = true;
726 : }
727 :
728 0 : if ( m_pBottomMarginEdit->IsValueChangedFromSaved() )
729 : {
730 0 : aTopMargin.SetLower( (sal_uInt16)GetCoreValue( *m_pBottomMarginEdit, eUnit ) );
731 0 : bMod = true;
732 : }
733 :
734 : // set top and bottom margins
735 :
736 0 : if ( bMod )
737 : {
738 0 : pOld = GetOldItem( *rSet, SID_ATTR_ULSPACE );
739 :
740 0 : if ( !pOld || !( *static_cast<const SvxULSpaceItem*>(pOld) == aTopMargin ) )
741 : {
742 0 : bModified = true;
743 0 : rSet->Put( aTopMargin );
744 : }
745 : }
746 :
747 : // paper tray
748 0 : nWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN );
749 0 : sal_Int32 nPos = m_pPaperTrayBox->GetSelectEntryPos();
750 0 : sal_uInt16 nBin = (sal_uInt16)reinterpret_cast<sal_uLong>(m_pPaperTrayBox->GetEntryData( nPos ));
751 0 : pOld = GetOldItem( *rSet, SID_ATTR_PAGE_PAPERBIN );
752 :
753 0 : if ( !pOld || static_cast<const SvxPaperBinItem*>(pOld)->GetValue() != nBin )
754 : {
755 0 : rSet->Put( SvxPaperBinItem( nWhich, (sal_uInt8)nBin ) );
756 0 : bModified = true;
757 : }
758 :
759 0 : nPos = m_pPaperSizeBox->GetSelectEntryPos();
760 0 : Paper ePaper = (Paper)reinterpret_cast<sal_uLong>(m_pPaperSizeBox->GetEntryData( nPos ));
761 0 : const sal_Int32 nOld = m_pPaperSizeBox->GetSavedValue();
762 0 : bool bChecked = m_pLandscapeBtn->IsChecked();
763 :
764 0 : if ( PAPER_USER == ePaper )
765 : {
766 0 : if ( nOld != nPos ||
767 0 : m_pPaperWidthEdit->IsValueModified() ||
768 0 : m_pPaperHeightEdit->IsValueModified() ||
769 0 : m_pLandscapeBtn->IsValueChangedFromSaved() )
770 : {
771 : Size aSize( GetCoreValue( *m_pPaperWidthEdit, eUnit ),
772 0 : GetCoreValue( *m_pPaperHeightEdit, eUnit ) );
773 0 : pOld = GetOldItem( *rSet, SID_ATTR_PAGE_SIZE );
774 :
775 0 : if ( !pOld || static_cast<const SvxSizeItem*>(pOld)->GetSize() != aSize )
776 : {
777 0 : rSet->Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
778 0 : bModified = true;
779 : }
780 : }
781 : }
782 : else
783 : {
784 0 : if ( nOld != nPos || m_pLandscapeBtn->IsValueChangedFromSaved() )
785 : {
786 0 : Size aSize( SvxPaperInfo::GetPaperSize( ePaper, (MapUnit)eUnit ) );
787 :
788 0 : if ( bChecked )
789 0 : Swap( aSize );
790 :
791 0 : pOld = GetOldItem( *rSet, SID_ATTR_PAGE_SIZE );
792 :
793 0 : if ( !pOld || static_cast<const SvxSizeItem*>(pOld)->GetSize() != aSize )
794 : {
795 0 : rSet->Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
796 0 : bModified = true;
797 : }
798 : }
799 : }
800 :
801 0 : nWhich = GetWhich( SID_ATTR_PAGE );
802 0 : SvxPageItem aPage( static_cast<const SvxPageItem&>(rOldSet.Get( nWhich )) );
803 0 : bMod = m_pLayoutBox->IsValueChangedFromSaved();
804 :
805 0 : if ( bMod )
806 : aPage.SetPageUsage(
807 0 : ::PosToPageUsage_Impl( m_pLayoutBox->GetSelectEntryPos() ) );
808 :
809 0 : if ( m_pLandscapeBtn->IsValueChangedFromSaved() )
810 : {
811 0 : aPage.SetLandscape(bChecked);
812 0 : bMod = true;
813 : }
814 :
815 : //Get the NumType value
816 0 : nPos = m_pNumberFormatBox->GetSelectEntryPos();
817 0 : sal_uInt16 nEntryData = (sal_uInt16)reinterpret_cast<sal_uLong>(m_pNumberFormatBox->GetEntryData(nPos));
818 0 : if ( m_pNumberFormatBox->IsValueChangedFromSaved() )
819 : {
820 0 : aPage.SetNumType( (SvxNumType)nEntryData );
821 0 : bMod = true;
822 : }
823 :
824 0 : if ( bMod )
825 : {
826 0 : pOld = GetOldItem( *rSet, SID_ATTR_PAGE );
827 :
828 0 : if ( !pOld || !( *static_cast<const SvxPageItem*>(pOld) == aPage ) )
829 : {
830 0 : rSet->Put( aPage );
831 0 : bModified = true;
832 : }
833 : }
834 0 : else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich ) )
835 0 : rSet->ClearItem( nWhich );
836 : else
837 0 : rSet->Put( rOldSet.Get( nWhich ) );
838 :
839 : // evaluate mode specific controls
840 :
841 0 : switch ( eMode )
842 : {
843 : case SVX_PAGE_MODE_CENTER:
844 : {
845 0 : if ( m_pHorzBox->IsValueChangedFromSaved() )
846 : {
847 0 : SfxBoolItem aHorz( GetWhich( SID_ATTR_PAGE_EXT1 ),
848 0 : m_pHorzBox->IsChecked() );
849 0 : rSet->Put( aHorz );
850 0 : bModified = true;
851 : }
852 :
853 0 : if ( m_pVertBox->IsValueChangedFromSaved() )
854 : {
855 0 : SfxBoolItem aVert( GetWhich( SID_ATTR_PAGE_EXT2 ),
856 0 : m_pVertBox->IsChecked() );
857 0 : rSet->Put( aVert );
858 0 : bModified = true;
859 : }
860 0 : break;
861 : }
862 :
863 : case SVX_PAGE_MODE_PRESENTATION:
864 : {
865 : // always put so that draw can evaluate this
866 0 : rSet->Put( SfxBoolItem( GetWhich( SID_ATTR_PAGE_EXT1 ),
867 0 : m_pAdaptBox->IsChecked() ) );
868 0 : bModified = true;
869 0 : break;
870 : }
871 : default: ;//prevent warning
872 :
873 : }
874 :
875 0 : if(m_pRegisterCB->IsVisible() &&
876 0 : (m_pRegisterCB->IsChecked() || m_pRegisterCB->IsValueChangedFromSaved()))
877 : {
878 0 : const SfxBoolItem& rRegItem = static_cast<const SfxBoolItem&>(rOldSet.Get(SID_SWREGISTER_MODE));
879 0 : boost::scoped_ptr<SfxBoolItem> pRegItem(static_cast<SfxBoolItem*>(rRegItem.Clone()));
880 0 : bool bCheck = m_pRegisterCB->IsChecked();
881 0 : pRegItem->SetValue(bCheck);
882 0 : rSet->Put(*pRegItem);
883 0 : bModified = true;
884 0 : if(bCheck)
885 : {
886 0 : bModified = true;
887 : rSet->Put(SfxStringItem(SID_SWREGISTER_COLLECTION,
888 0 : m_pRegisterLB->GetSelectEntry()));
889 0 : }
890 : }
891 :
892 0 : SvxFrameDirection eDirection = m_pTextFlowBox->GetSelectEntryValue();
893 0 : if( m_pTextFlowBox->IsVisible() && m_pTextFlowBox->IsValueChangedFromSaved() )
894 : {
895 0 : rSet->Put( SvxFrameDirectionItem( eDirection, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
896 0 : bModified = true;
897 : }
898 :
899 0 : return bModified;
900 : }
901 :
902 :
903 :
904 0 : IMPL_LINK_NOARG(SvxPageDescPage, LayoutHdl_Impl)
905 : {
906 : // switch inside outside
907 0 : const sal_uInt16 nPos = PosToPageUsage_Impl( m_pLayoutBox->GetSelectEntryPos() );
908 :
909 0 : if ( nPos == SVX_PAGE_MIRROR )
910 : {
911 0 : m_pLeftMarginLbl->Hide();
912 0 : m_pRightMarginLbl->Hide();
913 0 : m_pInsideLbl->Show();
914 0 : m_pOutsideLbl->Show();
915 : }
916 : else
917 : {
918 0 : m_pLeftMarginLbl->Show();
919 0 : m_pRightMarginLbl->Show();
920 0 : m_pInsideLbl->Hide();
921 0 : m_pOutsideLbl->Hide();
922 : }
923 0 : UpdateExample_Impl( true );
924 0 : return 0;
925 : }
926 :
927 :
928 :
929 0 : IMPL_LINK_NOARG(SvxPageDescPage, PaperBinHdl_Impl)
930 : {
931 0 : if ( m_pPaperTrayBox->GetEntryCount() > 1 )
932 : // already filled
933 0 : return 0;
934 :
935 0 : OUString aOldName = m_pPaperTrayBox->GetSelectEntry();
936 0 : m_pPaperTrayBox->SetUpdateMode( false );
937 0 : m_pPaperTrayBox->Clear();
938 : sal_Int32 nEntryPos = m_pPaperTrayBox->InsertEntry(
939 0 : EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS ) );
940 : m_pPaperTrayBox->SetEntryData( nEntryPos,
941 0 : reinterpret_cast<void*>((sal_uLong)PAPERBIN_PRINTER_SETTINGS) );
942 0 : OUString aPaperBin( EditResId( RID_SVXSTR_PAPERBIN ) );
943 0 : sal_uInt16 nBinCount = mpDefPrinter->GetPaperBinCount();
944 :
945 0 : for ( sal_uInt16 i = 0; i < nBinCount; ++i )
946 : {
947 0 : OUString aName = mpDefPrinter->GetPaperBinName(i);
948 :
949 0 : if ( aName.isEmpty() )
950 : {
951 0 : aName = aPaperBin;
952 0 : aName += " ";
953 0 : aName += OUString::number( i+1 );
954 : }
955 0 : nEntryPos = m_pPaperTrayBox->InsertEntry( aName );
956 0 : m_pPaperTrayBox->SetEntryData( nEntryPos, reinterpret_cast<void*>((sal_uLong)i) );
957 0 : }
958 0 : m_pPaperTrayBox->SelectEntry( aOldName );
959 0 : m_pPaperTrayBox->SetUpdateMode( true );
960 :
961 0 : return 0;
962 : }
963 :
964 :
965 :
966 0 : IMPL_LINK( SvxPageDescPage, PaperSizeSelect_Impl, ListBox *, pBox )
967 : {
968 0 : const sal_Int32 nPos = pBox->GetSelectEntryPos();
969 0 : Paper ePaper = (Paper)reinterpret_cast<sal_uLong>(m_pPaperSizeBox->GetEntryData( nPos ));
970 :
971 0 : if ( ePaper != PAPER_USER )
972 : {
973 0 : Size aSize( SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM ) );
974 :
975 0 : if ( m_pLandscapeBtn->IsChecked() )
976 0 : Swap( aSize );
977 :
978 0 : if ( aSize.Height() < m_pPaperHeightEdit->GetMin( FUNIT_100TH_MM ) )
979 : m_pPaperHeightEdit->SetMin(
980 0 : m_pPaperHeightEdit->Normalize( aSize.Height() ), FUNIT_100TH_MM );
981 0 : if ( aSize.Width() < m_pPaperWidthEdit->GetMin( FUNIT_100TH_MM ) )
982 : m_pPaperWidthEdit->SetMin(
983 0 : m_pPaperWidthEdit->Normalize( aSize.Width() ), FUNIT_100TH_MM );
984 0 : SetMetricValue( *m_pPaperHeightEdit, aSize.Height(), SFX_MAPUNIT_100TH_MM );
985 0 : SetMetricValue( *m_pPaperWidthEdit, aSize.Width(), SFX_MAPUNIT_100TH_MM );
986 :
987 0 : CalcMargin_Impl();
988 :
989 0 : RangeHdl_Impl( 0 );
990 0 : UpdateExample_Impl( true );
991 :
992 0 : if ( eMode == SVX_PAGE_MODE_PRESENTATION )
993 : {
994 : // Draw: if paper format the margin shall be 1 cm
995 0 : long nTmp = 0;
996 0 : bool bScreen = (( PAPER_SCREEN_4_3 == ePaper )||( PAPER_SCREEN_16_9 == ePaper)||( PAPER_SCREEN_16_10 == ePaper));
997 :
998 0 : if ( !bScreen )
999 : // no margin if screen
1000 0 : nTmp = 1; // accordingly 1 cm
1001 :
1002 0 : if ( bScreen || m_pRightMarginEdit->GetValue() == 0 )
1003 : {
1004 0 : SetMetricValue( *m_pRightMarginEdit, nTmp, SFX_MAPUNIT_CM );
1005 0 : if ( !bScreen &&
1006 0 : m_pRightMarginEdit->GetFirst() > m_pRightMarginEdit->GetValue() )
1007 0 : m_pRightMarginEdit->SetValue( m_pRightMarginEdit->GetFirst() );
1008 : }
1009 0 : if ( bScreen || m_pLeftMarginEdit->GetValue() == 0 )
1010 : {
1011 0 : SetMetricValue( *m_pLeftMarginEdit, nTmp, SFX_MAPUNIT_CM );
1012 0 : if ( !bScreen &&
1013 0 : m_pLeftMarginEdit->GetFirst() > m_pLeftMarginEdit->GetValue() )
1014 0 : m_pLeftMarginEdit->SetValue( m_pLeftMarginEdit->GetFirst() );
1015 : }
1016 0 : if ( bScreen || m_pBottomMarginEdit->GetValue() == 0 )
1017 : {
1018 0 : SetMetricValue( *m_pBottomMarginEdit, nTmp, SFX_MAPUNIT_CM );
1019 0 : if ( !bScreen &&
1020 0 : m_pBottomMarginEdit->GetFirst() > m_pBottomMarginEdit->GetValue() )
1021 0 : m_pBottomMarginEdit->SetValue( m_pBottomMarginEdit->GetFirst() );
1022 : }
1023 0 : if ( bScreen || m_pTopMarginEdit->GetValue() == 0 )
1024 : {
1025 0 : SetMetricValue( *m_pTopMarginEdit, nTmp, SFX_MAPUNIT_CM );
1026 0 : if ( !bScreen &&
1027 0 : m_pTopMarginEdit->GetFirst() > m_pTopMarginEdit->GetValue() )
1028 0 : m_pTopMarginEdit->SetValue( m_pTopMarginEdit->GetFirst() );
1029 : }
1030 0 : UpdateExample_Impl( true );
1031 : }
1032 : }
1033 0 : return 0;
1034 : }
1035 :
1036 :
1037 :
1038 0 : IMPL_LINK_NOARG(SvxPageDescPage, PaperSizeModify_Impl)
1039 : {
1040 0 : sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE );
1041 0 : SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWhich );
1042 : Size aSize( GetCoreValue( *m_pPaperWidthEdit, eUnit ),
1043 0 : GetCoreValue( *m_pPaperHeightEdit, eUnit ) );
1044 0 : Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, (MapUnit)eUnit, true );
1045 0 : sal_Int32 nEntryCount = m_pPaperSizeBox->GetEntryCount();
1046 :
1047 0 : for ( sal_Int32 i = 0; i < nEntryCount; ++i )
1048 : {
1049 0 : Paper eTmp = (Paper)reinterpret_cast<sal_uLong>(m_pPaperSizeBox->GetEntryData(i));
1050 :
1051 0 : if ( eTmp == ePaper )
1052 : {
1053 0 : m_pPaperSizeBox->SelectEntryPos(i);
1054 0 : break;
1055 : }
1056 : }
1057 0 : UpdateExample_Impl( true );
1058 0 : return 0;
1059 : }
1060 :
1061 :
1062 :
1063 0 : IMPL_LINK( SvxPageDescPage, SwapOrientation_Impl, RadioButton *, pBtn )
1064 : {
1065 0 : if (
1066 0 : (!bLandscape && pBtn == m_pLandscapeBtn) ||
1067 0 : (bLandscape && pBtn == m_pPortraitBtn)
1068 : )
1069 : {
1070 0 : bLandscape = m_pLandscapeBtn->IsChecked();
1071 :
1072 0 : const long lWidth = GetCoreValue( *m_pPaperWidthEdit, SFX_MAPUNIT_100TH_MM );
1073 0 : const long lHeight = GetCoreValue( *m_pPaperHeightEdit, SFX_MAPUNIT_100TH_MM );
1074 :
1075 : // swap with and height
1076 0 : SetMetricValue( *m_pPaperWidthEdit, lHeight, SFX_MAPUNIT_100TH_MM );
1077 0 : SetMetricValue( *m_pPaperHeightEdit, lWidth, SFX_MAPUNIT_100TH_MM );
1078 :
1079 : // recalculate margins if necessary
1080 0 : CalcMargin_Impl();
1081 :
1082 0 : PaperSizeSelect_Impl( m_pPaperSizeBox );
1083 0 : RangeHdl_Impl( 0 );
1084 0 : SwapFirstValues_Impl( bBorderModified );
1085 0 : UpdateExample_Impl( true );
1086 : }
1087 0 : return 0;
1088 : }
1089 :
1090 :
1091 :
1092 0 : void SvxPageDescPage::SwapFirstValues_Impl( bool bSet )
1093 : {
1094 0 : MapMode aOldMode = mpDefPrinter->GetMapMode();
1095 0 : Orientation eOri = ORIENTATION_PORTRAIT;
1096 :
1097 0 : if ( bLandscape )
1098 0 : eOri = ORIENTATION_LANDSCAPE;
1099 0 : Orientation eOldOri = mpDefPrinter->GetOrientation();
1100 0 : mpDefPrinter->SetOrientation( eOri );
1101 0 : mpDefPrinter->SetMapMode( MAP_TWIP );
1102 :
1103 : // set first- and last-values for margins
1104 0 : Size aPaperSize = mpDefPrinter->GetPaperSize();
1105 0 : Size aPrintSize = mpDefPrinter->GetOutputSize();
1106 : /*
1107 : * To convert a point ( 0,0 ) into logic coordinates
1108 : * looks like nonsense; but it makes sense if the
1109 : * coordinate system's origin has been moved.
1110 : */
1111 0 : Point aPrintOffset = mpDefPrinter->GetPageOffset() - mpDefPrinter->PixelToLogic( Point() );
1112 0 : mpDefPrinter->SetMapMode( aOldMode );
1113 0 : mpDefPrinter->SetOrientation( eOldOri );
1114 :
1115 : sal_Int64 nSetL = m_pLeftMarginEdit->Denormalize(
1116 0 : m_pLeftMarginEdit->GetValue( FUNIT_TWIP ) );
1117 : sal_Int64 nSetR = m_pRightMarginEdit->Denormalize(
1118 0 : m_pRightMarginEdit->GetValue( FUNIT_TWIP ) );
1119 : sal_Int64 nSetT = m_pTopMarginEdit->Denormalize(
1120 0 : m_pTopMarginEdit->GetValue( FUNIT_TWIP ) );
1121 : sal_Int64 nSetB = m_pBottomMarginEdit->Denormalize(
1122 0 : m_pBottomMarginEdit->GetValue( FUNIT_TWIP ) );
1123 :
1124 0 : long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET;
1125 0 : long nNewL = aPrintOffset.X();
1126 : long nNewR =
1127 0 : aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset;
1128 0 : long nNewT = aPrintOffset.Y();
1129 : long nNewB =
1130 0 : aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset;
1131 :
1132 0 : m_pLeftMarginEdit->SetFirst( m_pLeftMarginEdit->Normalize( nNewL ), FUNIT_TWIP );
1133 0 : nFirstLeftMargin = static_cast<long>(m_pLeftMarginEdit->GetFirst());
1134 0 : m_pRightMarginEdit->SetFirst( m_pRightMarginEdit->Normalize( nNewR ), FUNIT_TWIP );
1135 0 : nFirstRightMargin = static_cast<long>(m_pRightMarginEdit->GetFirst());
1136 0 : m_pTopMarginEdit->SetFirst( m_pTopMarginEdit->Normalize( nNewT ), FUNIT_TWIP );
1137 0 : nFirstTopMargin = static_cast<long>(m_pTopMarginEdit->GetFirst());
1138 0 : m_pBottomMarginEdit->SetFirst( m_pBottomMarginEdit->Normalize( nNewB ), FUNIT_TWIP );
1139 0 : nFirstBottomMargin = static_cast<long>(m_pBottomMarginEdit->GetFirst());
1140 :
1141 0 : if ( bSet )
1142 : {
1143 0 : if ( nSetL < nNewL )
1144 : m_pLeftMarginEdit->SetValue( m_pLeftMarginEdit->Normalize( nNewL ),
1145 0 : FUNIT_TWIP );
1146 0 : if ( nSetR < nNewR )
1147 : m_pRightMarginEdit->SetValue( m_pRightMarginEdit->Normalize( nNewR ),
1148 0 : FUNIT_TWIP );
1149 0 : if ( nSetT < nNewT )
1150 : m_pTopMarginEdit->SetValue( m_pTopMarginEdit->Normalize( nNewT ),
1151 0 : FUNIT_TWIP );
1152 0 : if ( nSetB < nNewB )
1153 : m_pBottomMarginEdit->SetValue( m_pBottomMarginEdit->Normalize( nNewB ),
1154 0 : FUNIT_TWIP );
1155 0 : }
1156 0 : }
1157 :
1158 :
1159 :
1160 0 : IMPL_LINK_NOARG_INLINE_START(SvxPageDescPage, BorderModify_Impl)
1161 : {
1162 0 : if ( !bBorderModified )
1163 0 : bBorderModified = true;
1164 0 : UpdateExample_Impl();
1165 0 : return 0;
1166 : }
1167 0 : IMPL_LINK_NOARG_INLINE_END(SvxPageDescPage, BorderModify_Impl)
1168 :
1169 :
1170 :
1171 0 : void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground )
1172 : {
1173 : // Size
1174 : Size aSize( GetCoreValue( *m_pPaperWidthEdit, SFX_MAPUNIT_TWIP ),
1175 0 : GetCoreValue( *m_pPaperHeightEdit, SFX_MAPUNIT_TWIP ) );
1176 :
1177 0 : m_pBspWin->SetSize( aSize );
1178 :
1179 : // Margins
1180 0 : m_pBspWin->SetTop( GetCoreValue( *m_pTopMarginEdit, SFX_MAPUNIT_TWIP ) );
1181 0 : m_pBspWin->SetBottom( GetCoreValue( *m_pBottomMarginEdit, SFX_MAPUNIT_TWIP ) );
1182 0 : m_pBspWin->SetLeft( GetCoreValue( *m_pLeftMarginEdit, SFX_MAPUNIT_TWIP ) );
1183 0 : m_pBspWin->SetRight( GetCoreValue( *m_pRightMarginEdit, SFX_MAPUNIT_TWIP ) );
1184 :
1185 : // Layout
1186 0 : m_pBspWin->SetUsage( PosToPageUsage_Impl( m_pLayoutBox->GetSelectEntryPos() ) );
1187 0 : if ( bResetbackground )
1188 0 : m_pBspWin->ResetBackground();
1189 0 : m_pBspWin->Invalidate();
1190 0 : }
1191 :
1192 :
1193 :
1194 0 : void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet& rSet)
1195 : {
1196 0 : sal_uInt16 nWhich(GetWhich(SID_ATTR_PAGE_HEADERSET));
1197 :
1198 0 : if (SfxItemState::SET == rSet.GetItemState(nWhich, false))
1199 : {
1200 0 : const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, false));
1201 0 : const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1202 0 : const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)));
1203 :
1204 0 : if(rOn.GetValue())
1205 : {
1206 0 : drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes;
1207 :
1208 0 : if(mbEnableDrawingLayerFillStyles)
1209 : {
1210 : //UUUU create FillAttributes directly from DrawingLayer FillStyle entries
1211 0 : aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet));
1212 : }
1213 : else
1214 : {
1215 0 : nWhich = GetWhich(SID_ATTR_BRUSH);
1216 :
1217 0 : if(SfxItemState::SET == rTmpSet.GetItemState(nWhich))
1218 : {
1219 : //UUUU create FillAttributes from SvxBrushItem
1220 0 : const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich));
1221 0 : SfxItemSet aTempSet(*rTmpSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
1222 :
1223 0 : setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
1224 0 : aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
1225 : }
1226 : }
1227 :
1228 0 : m_pBspWin->setHeaderFillAttributes(aHeaderFillAttributes);
1229 0 : nWhich = GetWhich(SID_ATTR_BORDER_OUTER);
1230 :
1231 0 : if(rTmpSet.GetItemState(nWhich) == SfxItemState::SET)
1232 : {
1233 : const SvxBoxItem& rItem =
1234 0 : static_cast<const SvxBoxItem&>(rTmpSet.Get( nWhich ));
1235 0 : m_pBspWin->SetHdBorder( rItem );
1236 0 : }
1237 : }
1238 : }
1239 :
1240 0 : nWhich = GetWhich(SID_ATTR_PAGE_FOOTERSET);
1241 :
1242 0 : if (SfxItemState::SET == rSet.GetItemState(nWhich, false))
1243 : {
1244 0 : const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich,false));
1245 0 : const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1246 0 : const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)));
1247 :
1248 0 : if(rOn.GetValue())
1249 : {
1250 0 : drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes;
1251 :
1252 0 : if(mbEnableDrawingLayerFillStyles)
1253 : {
1254 : //UUUU create FillAttributes directly from DrawingLayer FillStyle entries
1255 0 : aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet));
1256 : }
1257 : else
1258 : {
1259 0 : nWhich = GetWhich(SID_ATTR_BRUSH);
1260 :
1261 0 : if(SfxItemState::SET == rTmpSet.GetItemState(nWhich))
1262 : {
1263 : //UUUU create FillAttributes from SvxBrushItem
1264 0 : const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich));
1265 0 : SfxItemSet aTempSet(*rTmpSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
1266 :
1267 0 : setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
1268 0 : aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
1269 : }
1270 : }
1271 :
1272 0 : m_pBspWin->setFooterFillAttributes(aFooterFillAttributes);
1273 0 : nWhich = GetWhich(SID_ATTR_BORDER_OUTER);
1274 :
1275 0 : if(rTmpSet.GetItemState(nWhich) == SfxItemState::SET)
1276 : {
1277 0 : const SvxBoxItem& rItem = static_cast< const SvxBoxItem& >(rTmpSet.Get(nWhich));
1278 0 : m_pBspWin->SetFtBorder(rItem);
1279 0 : }
1280 : }
1281 : }
1282 :
1283 0 : drawinglayer::attribute::SdrAllFillAttributesHelperPtr aPageFillAttributes;
1284 0 : const SfxPoolItem* pItem = 0;
1285 :
1286 0 : if(mbEnableDrawingLayerFillStyles)
1287 : {
1288 : //UUUU create FillAttributes directly from DrawingLayer FillStyle entries
1289 0 : aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rSet));
1290 : }
1291 : else
1292 : {
1293 0 : pItem = GetItem(rSet, SID_ATTR_BRUSH);
1294 :
1295 0 : if(pItem)
1296 : {
1297 : //UUUU create FillAttributes from SvxBrushItem
1298 0 : const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(*pItem);
1299 0 : SfxItemSet aTempSet(*rSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
1300 :
1301 0 : setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
1302 0 : aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
1303 : }
1304 : }
1305 :
1306 0 : m_pBspWin->setPageFillAttributes(aPageFillAttributes);
1307 0 : pItem = GetItem(rSet, SID_ATTR_BORDER_OUTER);
1308 :
1309 0 : if(pItem)
1310 : {
1311 0 : m_pBspWin->SetBorder(static_cast< const SvxBoxItem& >(*pItem));
1312 0 : }
1313 0 : }
1314 :
1315 0 : void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet )
1316 : {
1317 0 : bLandscape = m_pLandscapeBtn->IsChecked();
1318 0 : const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
1319 :
1320 0 : if ( pItem )
1321 0 : m_pBspWin->SetSize( static_cast<const SvxSizeItem*>(pItem)->GetSize() );
1322 :
1323 0 : const SvxSetItem* pSetItem = 0;
1324 :
1325 : // evaluate header attributes
1326 :
1327 0 : if ( SfxItemState::SET ==
1328 0 : rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ),
1329 0 : false, (const SfxPoolItem**)&pSetItem ) )
1330 : {
1331 0 : const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
1332 : const SfxBoolItem& rHeaderOn =
1333 0 : static_cast<const SfxBoolItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ));
1334 :
1335 0 : if ( rHeaderOn.GetValue() )
1336 : {
1337 : const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(
1338 0 : rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ));
1339 : const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(
1340 0 : rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) ));
1341 0 : long nDist = rUL.GetLower();
1342 0 : m_pBspWin->SetHdHeight( rSize.GetSize().Height() - nDist );
1343 0 : m_pBspWin->SetHdDist( nDist );
1344 : const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(
1345 0 : rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
1346 0 : m_pBspWin->SetHdLeft( rLR.GetLeft() );
1347 0 : m_pBspWin->SetHdRight( rLR.GetRight() );
1348 0 : m_pBspWin->SetHeader( true );
1349 : }
1350 : else
1351 0 : m_pBspWin->SetHeader( false );
1352 :
1353 : // show background and border in the example
1354 0 : drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes;
1355 :
1356 0 : if(mbEnableDrawingLayerFillStyles)
1357 : {
1358 : //UUUU create FillAttributes directly from DrawingLayer FillStyle entries
1359 0 : aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rHeaderSet));
1360 : }
1361 : else
1362 : {
1363 0 : const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH));
1364 :
1365 0 : if(rHeaderSet.GetItemState(nWhich) >= SfxItemState::DEFAULT)
1366 : {
1367 : //UUUU aBspWin.SetHdColor(rItem.GetColor());
1368 0 : const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rHeaderSet.Get(nWhich));
1369 0 : SfxItemSet aTempSet(*rHeaderSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
1370 :
1371 0 : setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
1372 0 : aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
1373 : }
1374 : }
1375 :
1376 0 : m_pBspWin->setHeaderFillAttributes(aHeaderFillAttributes);
1377 0 : const sal_uInt16 nWhich(GetWhich(SID_ATTR_BORDER_OUTER));
1378 :
1379 0 : if ( rHeaderSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT )
1380 : {
1381 : const SvxBoxItem& rItem =
1382 0 : static_cast<const SvxBoxItem&>(rHeaderSet.Get( nWhich ));
1383 0 : m_pBspWin->SetHdBorder( rItem );
1384 0 : }
1385 : }
1386 :
1387 : // evaluate footer attributes
1388 :
1389 0 : if ( SfxItemState::SET ==
1390 0 : rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ),
1391 0 : false, (const SfxPoolItem**)&pSetItem ) )
1392 : {
1393 0 : const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
1394 : const SfxBoolItem& rFooterOn =
1395 0 : static_cast<const SfxBoolItem&>(rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ));
1396 :
1397 0 : if ( rFooterOn.GetValue() )
1398 : {
1399 : const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(
1400 0 : rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ));
1401 : const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(
1402 0 : rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) ));
1403 0 : long nDist = rUL.GetUpper();
1404 0 : m_pBspWin->SetFtHeight( rSize.GetSize().Height() - nDist );
1405 0 : m_pBspWin->SetFtDist( nDist );
1406 : const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(
1407 0 : rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
1408 0 : m_pBspWin->SetFtLeft( rLR.GetLeft() );
1409 0 : m_pBspWin->SetFtRight( rLR.GetRight() );
1410 0 : m_pBspWin->SetFooter( true );
1411 : }
1412 : else
1413 0 : m_pBspWin->SetFooter( false );
1414 :
1415 : // show background and border in the example
1416 0 : drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes;
1417 :
1418 0 : if(mbEnableDrawingLayerFillStyles)
1419 : {
1420 : //UUUU create FillAttributes directly from DrawingLayer FillStyle entries
1421 0 : aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rFooterSet));
1422 : }
1423 : else
1424 : {
1425 0 : const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH));
1426 :
1427 0 : if(rFooterSet.GetItemState(nWhich) >= SfxItemState::DEFAULT)
1428 : {
1429 : //UUUU aBspWin.SetFtColor(rItem.GetColor());
1430 0 : const SvxBrushItem& rItem = static_cast<const SvxBrushItem&>(rFooterSet.Get(nWhich));
1431 0 : SfxItemSet aTempSet(*rFooterSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
1432 :
1433 0 : setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
1434 0 : aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
1435 : }
1436 : }
1437 :
1438 0 : m_pBspWin->setFooterFillAttributes(aFooterFillAttributes);
1439 0 : const sal_uInt16 nWhich(GetWhich(SID_ATTR_BORDER_OUTER));
1440 :
1441 0 : if ( rFooterSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT )
1442 : {
1443 : const SvxBoxItem& rItem =
1444 0 : static_cast<const SvxBoxItem&>(rFooterSet.Get( nWhich ));
1445 0 : m_pBspWin->SetFtBorder( rItem );
1446 0 : }
1447 : }
1448 0 : }
1449 :
1450 :
1451 :
1452 0 : void SvxPageDescPage::ActivatePage( const SfxItemSet& rSet )
1453 : {
1454 0 : InitHeadFoot_Impl( rSet );
1455 0 : UpdateExample_Impl();
1456 0 : ResetBackground_Impl( rSet );
1457 0 : RangeHdl_Impl( 0 );
1458 0 : }
1459 :
1460 :
1461 :
1462 0 : int SvxPageDescPage::DeactivatePage( SfxItemSet* _pSet )
1463 : {
1464 : // Inquiry whether the page margins are beyond the printing area.
1465 : // If not, ask user whether they shall be taken.
1466 : // If not, stay on the TabPage.
1467 0 : sal_Int32 nPos = m_pPaperSizeBox->GetSelectEntryPos();
1468 0 : Paper ePaper = (Paper)reinterpret_cast<sal_uLong>(m_pPaperSizeBox->GetEntryData( nPos ));
1469 :
1470 0 : if ( ePaper != PAPER_SCREEN_4_3 && ePaper != PAPER_SCREEN_16_9 && ePaper != PAPER_SCREEN_16_10 && IsMarginOutOfRange() )
1471 : {
1472 0 : if ( QueryBox( this, WB_YES_NO | WB_DEF_NO, m_pPrintRangeQueryText->GetText() ).Execute() == RET_NO )
1473 : {
1474 0 : MetricField* pField = NULL;
1475 0 : if ( IsPrinterRangeOverflow( *m_pLeftMarginEdit, nFirstLeftMargin, nLastLeftMargin, MARGIN_LEFT ) )
1476 0 : pField = m_pLeftMarginEdit;
1477 0 : if ( IsPrinterRangeOverflow( *m_pRightMarginEdit, nFirstRightMargin, nLastRightMargin, MARGIN_RIGHT )
1478 0 : && !pField )
1479 0 : pField = m_pRightMarginEdit;
1480 0 : if ( IsPrinterRangeOverflow( *m_pTopMarginEdit, nFirstTopMargin, nLastTopMargin, MARGIN_TOP )
1481 0 : && !pField )
1482 0 : pField = m_pTopMarginEdit;
1483 0 : if ( IsPrinterRangeOverflow( *m_pBottomMarginEdit, nFirstBottomMargin, nLastBottomMargin, MARGIN_BOTTOM )
1484 0 : && !pField )
1485 0 : pField = m_pBottomMarginEdit;
1486 0 : if ( pField )
1487 0 : pField->GrabFocus();
1488 0 : UpdateExample_Impl();
1489 0 : return KEEP_PAGE;
1490 : }
1491 : else
1492 0 : CheckMarginEdits( false );
1493 : }
1494 :
1495 0 : if ( _pSet )
1496 : {
1497 0 : FillItemSet( _pSet );
1498 :
1499 : // put portray/landscape if applicable
1500 0 : sal_uInt16 nWh = GetWhich( SID_ATTR_PAGE_SIZE );
1501 0 : SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWh );
1502 : Size aSize( GetCoreValue( *m_pPaperWidthEdit, eUnit ),
1503 0 : GetCoreValue( *m_pPaperHeightEdit, eUnit ) );
1504 :
1505 : // put, if current size is different to the value in _pSet
1506 0 : const SvxSizeItem* pSize = static_cast<const SvxSizeItem*>(GetItem( *_pSet, SID_ATTR_PAGE_SIZE ));
1507 0 : if ( aSize.Width() && ( !pSize || !IsEqualSize_Impl( pSize, aSize ) ) )
1508 0 : _pSet->Put( SvxSizeItem( nWh, aSize ) );
1509 : }
1510 :
1511 0 : return LEAVE_PAGE;
1512 : }
1513 :
1514 :
1515 :
1516 0 : IMPL_LINK_NOARG(SvxPageDescPage, RangeHdl_Impl)
1517 : {
1518 : // example window
1519 0 : long nHHeight = m_pBspWin->GetHdHeight();
1520 0 : long nHDist = m_pBspWin->GetHdDist();
1521 :
1522 0 : long nFHeight = m_pBspWin->GetFtHeight();
1523 0 : long nFDist = m_pBspWin->GetFtDist();
1524 :
1525 0 : long nHFLeft = std::max( m_pBspWin->GetHdLeft(), m_pBspWin->GetFtLeft() );
1526 0 : long nHFRight = std::max( m_pBspWin->GetHdRight(), m_pBspWin->GetFtRight() );
1527 :
1528 : // current values for page margins
1529 0 : long nBT = static_cast<long>(m_pTopMarginEdit->Denormalize(m_pTopMarginEdit->GetValue(FUNIT_TWIP)));
1530 0 : long nBB = static_cast<long>(m_pBottomMarginEdit->Denormalize(m_pBottomMarginEdit->GetValue(FUNIT_TWIP)));
1531 0 : long nBL = static_cast<long>(m_pLeftMarginEdit->Denormalize(m_pLeftMarginEdit->GetValue(FUNIT_TWIP)));
1532 0 : long nBR = static_cast<long>(m_pRightMarginEdit->Denormalize(m_pRightMarginEdit->GetValue(FUNIT_TWIP)));
1533 :
1534 : // calculate width of page border
1535 0 : const SfxItemSet* _pSet = &GetItemSet();
1536 0 : Size aBorder;
1537 :
1538 0 : if ( _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_SHADOW) ) >=
1539 0 : SfxItemState::DEFAULT &&
1540 0 : _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_OUTER) ) >=
1541 : SfxItemState::DEFAULT )
1542 : {
1543 : aBorder = GetMinBorderSpace_Impl(
1544 0 : static_cast<const SvxShadowItem&>(_pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW))),
1545 0 : static_cast<const SvxBoxItem&>(_pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER))));
1546 : }
1547 :
1548 : // limits paper
1549 : // maximum is 54 cm
1550 :
1551 0 : long nMin = nHHeight + nHDist + nFDist + nFHeight + nBT + nBB +
1552 0 : MINBODY + aBorder.Height();
1553 0 : m_pPaperHeightEdit->SetMin(m_pPaperHeightEdit->Normalize(nMin), FUNIT_TWIP);
1554 :
1555 0 : nMin = MINBODY + nBL + nBR + aBorder.Width();
1556 0 : m_pPaperWidthEdit->SetMin(m_pPaperWidthEdit->Normalize(nMin), FUNIT_TWIP);
1557 :
1558 0 : long nH = static_cast<long>(m_pPaperHeightEdit->Denormalize(m_pPaperHeightEdit->GetValue(FUNIT_TWIP)));
1559 0 : long nW = static_cast<long>(m_pPaperWidthEdit->Denormalize(m_pPaperWidthEdit->GetValue(FUNIT_TWIP)));
1560 :
1561 : // Top
1562 0 : long nMax = nH - nBB - aBorder.Height() - MINBODY -
1563 0 : nFDist - nFHeight - nHDist - nHHeight;
1564 :
1565 0 : m_pTopMarginEdit->SetMax(m_pTopMarginEdit->Normalize(nMax), FUNIT_TWIP);
1566 :
1567 : // Bottom
1568 0 : nMax = nH - nBT - aBorder.Height() - MINBODY -
1569 0 : nFDist - nFHeight - nHDist - nHHeight;
1570 :
1571 0 : m_pBottomMarginEdit->SetMax(m_pTopMarginEdit->Normalize(nMax), FUNIT_TWIP);
1572 :
1573 : // Left
1574 0 : nMax = nW - nBR - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1575 0 : m_pLeftMarginEdit->SetMax(m_pLeftMarginEdit->Normalize(nMax), FUNIT_TWIP);
1576 :
1577 : // Right
1578 0 : nMax = nW - nBL - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1579 0 : m_pRightMarginEdit->SetMax(m_pRightMarginEdit->Normalize(nMax), FUNIT_TWIP);
1580 0 : return 0;
1581 : }
1582 :
1583 :
1584 :
1585 0 : void SvxPageDescPage::CalcMargin_Impl()
1586 : {
1587 : // current values for page margins
1588 0 : long nBT = GetCoreValue( *m_pTopMarginEdit, SFX_MAPUNIT_TWIP );
1589 0 : long nBB = GetCoreValue( *m_pBottomMarginEdit, SFX_MAPUNIT_TWIP );
1590 :
1591 0 : long nBL = GetCoreValue( *m_pLeftMarginEdit, SFX_MAPUNIT_TWIP );
1592 0 : long nBR = GetCoreValue( *m_pRightMarginEdit, SFX_MAPUNIT_TWIP );
1593 :
1594 0 : long nH = GetCoreValue( *m_pPaperHeightEdit, SFX_MAPUNIT_TWIP );
1595 0 : long nW = GetCoreValue( *m_pPaperWidthEdit, SFX_MAPUNIT_TWIP );
1596 :
1597 0 : long nWidth = nBL + nBR + MINBODY;
1598 0 : long nHeight = nBT + nBB + MINBODY;
1599 :
1600 0 : if ( nWidth > nW || nHeight > nH )
1601 : {
1602 0 : if ( nWidth > nW )
1603 : {
1604 0 : long nTmp = nBL <= nBR ? nBR : nBL;
1605 0 : nTmp -= nWidth - nW;
1606 :
1607 0 : if ( nBL <= nBR )
1608 0 : SetMetricValue( *m_pRightMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1609 : else
1610 0 : SetMetricValue( *m_pLeftMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1611 : }
1612 :
1613 0 : if ( nHeight > nH )
1614 : {
1615 0 : long nTmp = nBT <= nBB ? nBB : nBT;
1616 0 : nTmp -= nHeight - nH;
1617 :
1618 0 : if ( nBT <= nBB )
1619 0 : SetMetricValue( *m_pBottomMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1620 : else
1621 0 : SetMetricValue( *m_pTopMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1622 : }
1623 : }
1624 0 : }
1625 :
1626 :
1627 :
1628 0 : IMPL_LINK_NOARG_INLINE_START(SvxPageDescPage, CenterHdl_Impl)
1629 : {
1630 0 : m_pBspWin->SetHorz( m_pHorzBox->IsChecked() );
1631 0 : m_pBspWin->SetVert( m_pVertBox->IsChecked() );
1632 0 : UpdateExample_Impl();
1633 0 : return 0;
1634 : }
1635 0 : IMPL_LINK_NOARG_INLINE_END(SvxPageDescPage, CenterHdl_Impl)
1636 :
1637 :
1638 :
1639 0 : void SvxPageDescPage::SetCollectionList(const std::vector<OUString> &aList)
1640 : {
1641 : OSL_ENSURE(!aList.empty(), "Empty string list");
1642 :
1643 0 : sStandardRegister = aList[0];
1644 0 : for( size_t i = 1; i < aList.size(); i++ )
1645 0 : m_pRegisterLB->InsertEntry(aList[i]);
1646 :
1647 0 : m_pRegisterCB->Show();
1648 0 : m_pRegisterFT->Show();
1649 0 : m_pRegisterLB->Show();
1650 0 : m_pRegisterCB->SetClickHdl(LINK(this, SvxPageDescPage, RegisterModify));
1651 0 : }
1652 :
1653 :
1654 :
1655 0 : IMPL_LINK( SvxPageDescPage, RegisterModify, CheckBox*, pBox )
1656 : {
1657 0 : bool bEnable = false;
1658 0 : if(pBox->IsChecked())
1659 : {
1660 0 : bEnable = true;
1661 0 : if(USHRT_MAX == m_pRegisterLB->GetSelectEntryPos())
1662 0 : m_pRegisterLB->SelectEntry(sStandardRegister);
1663 : }
1664 0 : m_pRegisterFT->Enable( bEnable );
1665 0 : m_pRegisterLB->Enable( bEnable );
1666 0 : return 0;
1667 : }
1668 :
1669 :
1670 :
1671 0 : void SvxPageDescPage::DisableVerticalPageDir()
1672 : {
1673 0 : m_pTextFlowBox->RemoveEntryValue( FRMDIR_VERT_TOP_RIGHT );
1674 0 : m_pTextFlowBox->RemoveEntryValue( FRMDIR_VERT_TOP_LEFT );
1675 0 : if( m_pTextFlowBox->GetEntryCount() < 2 )
1676 : {
1677 0 : m_pTextFlowLbl->Hide();
1678 0 : m_pTextFlowBox->Hide();
1679 0 : m_pBspWin->EnableFrameDirection( false );
1680 : }
1681 0 : }
1682 :
1683 0 : IMPL_LINK( SvxPageDescPage, FrameDirectionModify_Impl, ListBox*, EMPTYARG)
1684 : {
1685 0 : m_pBspWin->SetFrameDirection( (sal_uInt32) m_pTextFlowBox->GetSelectEntryValue() );
1686 0 : m_pBspWin->Invalidate();
1687 0 : return 0;
1688 : }
1689 :
1690 0 : bool SvxPageDescPage::IsPrinterRangeOverflow(
1691 : MetricField& rField, long nFirstMargin, long nLastMargin, MarginPosition nPos )
1692 : {
1693 0 : bool bRet = false;
1694 0 : bool bCheck = ( ( m_nPos & nPos ) == 0 );
1695 0 : long nValue = static_cast<long>(rField.GetValue());
1696 0 : if ( bCheck &&
1697 0 : ( nValue < nFirstMargin || nValue > nLastMargin ) &&
1698 0 : rField.IsValueChangedFromSaved() )
1699 : {
1700 0 : rField.SetValue( nValue < nFirstMargin ? nFirstMargin : nLastMargin );
1701 0 : bRet = true;
1702 : }
1703 :
1704 0 : return bRet;
1705 : }
1706 :
1707 : /** Check if a value of a margin edit is outside the printer paper margins
1708 : and save this information.
1709 : */
1710 0 : void SvxPageDescPage::CheckMarginEdits( bool _bClear )
1711 : {
1712 0 : if ( _bClear )
1713 0 : m_nPos = 0;
1714 :
1715 0 : sal_Int64 nValue = m_pLeftMarginEdit->GetValue();
1716 0 : if ( nValue < nFirstLeftMargin || nValue > nLastLeftMargin )
1717 0 : m_nPos |= MARGIN_LEFT;
1718 0 : nValue = m_pRightMarginEdit->GetValue();
1719 0 : if ( nValue < nFirstRightMargin || nValue > nLastRightMargin )
1720 0 : m_nPos |= MARGIN_RIGHT;
1721 0 : nValue = m_pTopMarginEdit->GetValue();
1722 0 : if ( nValue < nFirstTopMargin || nValue > nLastTopMargin )
1723 0 : m_nPos |= MARGIN_TOP;
1724 0 : nValue = m_pBottomMarginEdit->GetValue();
1725 0 : if ( nValue < nFirstBottomMargin || nValue > nLastBottomMargin )
1726 0 : m_nPos |= MARGIN_BOTTOM;
1727 0 : }
1728 :
1729 0 : bool SvxPageDescPage::IsMarginOutOfRange()
1730 : {
1731 0 : bool bRet = ( ( ( !( m_nPos & MARGIN_LEFT ) &&
1732 0 : m_pLeftMarginEdit->IsValueChangedFromSaved() ) &&
1733 0 : ( m_pLeftMarginEdit->GetValue() < nFirstLeftMargin ||
1734 0 : m_pLeftMarginEdit->GetValue() > nLastLeftMargin ) ) ||
1735 0 : ( ( !( m_nPos & MARGIN_RIGHT ) &&
1736 0 : m_pRightMarginEdit->IsValueChangedFromSaved() ) &&
1737 0 : ( m_pRightMarginEdit->GetValue() < nFirstRightMargin ||
1738 0 : m_pRightMarginEdit->GetValue() > nLastRightMargin ) ) ||
1739 0 : ( ( !( m_nPos & MARGIN_TOP ) &&
1740 0 : m_pTopMarginEdit->IsValueChangedFromSaved() ) &&
1741 0 : ( m_pTopMarginEdit->GetValue() < nFirstTopMargin ||
1742 0 : m_pTopMarginEdit->GetValue() > nLastTopMargin ) ) ||
1743 0 : ( ( !( m_nPos & MARGIN_BOTTOM ) &&
1744 0 : m_pBottomMarginEdit->IsValueChangedFromSaved() ) &&
1745 0 : ( m_pBottomMarginEdit->GetValue() < nFirstBottomMargin ||
1746 0 : m_pBottomMarginEdit->GetValue() > nLastBottomMargin ) ) );
1747 0 : return bRet;
1748 : }
1749 :
1750 0 : void SvxPageDescPage::PageCreated(const SfxAllItemSet& aSet)
1751 : {
1752 0 : SFX_ITEMSET_ARG (&aSet,pModeItem,SfxAllEnumItem,SID_ENUM_PAGE_MODE,false);
1753 0 : SFX_ITEMSET_ARG (&aSet,pPaperStartItem,SfxAllEnumItem,SID_PAPER_START,false);
1754 0 : SFX_ITEMSET_ARG (&aSet,pPaperEndItem,SfxAllEnumItem,SID_PAPER_END,false);
1755 0 : SFX_ITEMSET_ARG (&aSet,pCollectListItem,SfxStringListItem,SID_COLLECT_LIST,false);
1756 :
1757 : //UUUU
1758 0 : SFX_ITEMSET_ARG (&aSet, pSupportDrawingLayerFillStyleItem, SfxBoolItem, SID_DRAWINGLAYER_FILLSTYLES, false);
1759 :
1760 0 : if (pModeItem)
1761 : {
1762 0 : SetMode((SvxModeType)pModeItem->GetEnumValue());
1763 : }
1764 :
1765 0 : if(pPaperStartItem && pPaperEndItem)
1766 : {
1767 0 : SetPaperFormatRanges((Paper)pPaperStartItem->GetEnumValue(),(Paper)pPaperEndItem->GetEnumValue());
1768 : }
1769 :
1770 0 : if(pCollectListItem)
1771 : {
1772 0 : SetCollectionList(pCollectListItem->GetList());
1773 : }
1774 :
1775 0 : if(pSupportDrawingLayerFillStyleItem)
1776 : {
1777 0 : const bool bNew(pSupportDrawingLayerFillStyleItem->GetValue());
1778 :
1779 0 : EnableDrawingLayerFillStyles(bNew);
1780 : }
1781 0 : }
1782 :
1783 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|