update credits
[LibreOffice.git] / cui / source / tabpages / page.cxx
blobda2ac1c37dbe39d2e32df50fbf253c7b7d604751
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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> // for RID_SVXPAGE_PAGE
50 #include <editeng/eerdll.hxx>
51 #include <editeng/editrids.hrc> // for RID_SVXSTR_PAPERBIN...,
52 #include <svx/svxids.hrc>
54 // #i4219#
55 #include <svtools/optionsdrawinglayer.hxx>
56 #include <svl/slstitm.hxx>
57 #include <svl/aeitem.hxx>
58 #include <sfx2/request.hxx>
60 #include <numpages.hxx> // for GetI18nNumbering()
62 // static ----------------------------------------------------------------
64 static const long MINBODY = 284; // 0,5 cm rounded up in twips
65 //static const long PRINT_OFFSET = 17; // 0,03 cm rounded down in twips
66 static const long PRINT_OFFSET = 0; // why was this ever set to 17 ? it led to wrong right and bottom margins.
68 static sal_uInt16 pRanges[] =
70 SID_ATTR_BORDER_OUTER,
71 SID_ATTR_BORDER_SHADOW,
72 SID_ATTR_LRSPACE,
73 SID_ATTR_PAGE_SHARED,
74 SID_SWREGISTER_COLLECTION,
75 SID_SWREGISTER_MODE,
78 // ------- Mapping page layout ------------------------------------------
80 sal_uInt16 aArr[] =
82 SVX_PAGE_ALL,
83 SVX_PAGE_MIRROR,
84 SVX_PAGE_RIGHT,
85 SVX_PAGE_LEFT
88 // -----------------------------------------------------------------------
90 sal_uInt16 PageUsageToPos_Impl( sal_uInt16 nUsage )
92 for ( sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aArr); ++i )
93 if ( aArr[i] == ( nUsage & 0x000f ) )
94 return i;
95 return SVX_PAGE_ALL;
98 // -----------------------------------------------------------------------
100 sal_uInt16 PosToPageUsage_Impl( sal_uInt16 nPos )
102 if ( nPos >= SAL_N_ELEMENTS(aArr) )
103 return 0;
104 return aArr[nPos];
107 // -----------------------------------------------------------------------
109 Size GetMinBorderSpace_Impl( const SvxShadowItem& rShadow, const SvxBoxItem& rBox )
111 Size aSz;
112 aSz.Height() = rShadow.CalcShadowSpace( SHADOW_BOTTOM ) + rBox.CalcLineSpace( BOX_LINE_BOTTOM );
113 aSz.Height() += rShadow.CalcShadowSpace( SHADOW_TOP ) + rBox.CalcLineSpace( BOX_LINE_TOP );
114 aSz.Width() = rShadow.CalcShadowSpace( SHADOW_LEFT ) + rBox.CalcLineSpace( BOX_LINE_LEFT );
115 aSz.Width() += rShadow.CalcShadowSpace( SHADOW_RIGHT ) + rBox.CalcLineSpace( BOX_LINE_RIGHT );
116 return aSz;
119 // -----------------------------------------------------------------------
121 long ConvertLong_Impl( const long nIn, SfxMapUnit eUnit )
123 return OutputDevice::LogicToLogic( nIn, (MapUnit)eUnit, MAP_TWIP );
126 sal_Bool IsEqualSize_Impl( const SvxSizeItem* pSize, const Size& rSize )
128 if ( pSize )
130 Size aSize = pSize->GetSize();
131 long nDiffW = std::abs( rSize.Width () - aSize.Width () );
132 long nDiffH = std::abs( rSize.Height() - aSize.Height() );
133 return ( nDiffW < 10 && nDiffH < 10 );
135 else
136 return sal_False;
139 // -----------------------------------------------------------------------
141 #define MARGIN_LEFT ( (MarginPosition)0x0001 )
142 #define MARGIN_RIGHT ( (MarginPosition)0x0002 )
143 #define MARGIN_TOP ( (MarginPosition)0x0004 )
144 #define MARGIN_BOTTOM ( (MarginPosition)0x0008 )
146 struct SvxPage_Impl
148 MarginPosition m_nPos;
149 Printer* mpDefPrinter;
150 bool mbDelPrinter;
152 SvxPage_Impl() :
153 m_nPos( 0 ),
154 mpDefPrinter( 0 ),
155 mbDelPrinter( false ) {}
157 ~SvxPage_Impl() { if ( mbDelPrinter ) delete mpDefPrinter; }
160 // class SvxPageDescPage --------------------------------------------------
162 // returns the range of the Which values
163 sal_uInt16* SvxPageDescPage::GetRanges()
165 return pRanges;
168 // -----------------------------------------------------------------------
170 SfxTabPage* SvxPageDescPage::Create( Window* pParent, const SfxItemSet& rSet )
172 return new SvxPageDescPage( pParent, rSet );
175 // -----------------------------------------------------------------------
177 SvxPageDescPage::SvxPageDescPage( Window* pParent, const SfxItemSet& rAttr ) :
179 SfxTabPage( pParent, "PageFormatPage", "cui/ui/pageformatpage.ui", rAttr ),
181 bLandscape ( sal_False ),
182 eMode ( SVX_PAGE_MODE_STANDARD ),
183 ePaperStart ( PAPER_A3 ),
184 ePaperEnd ( PAPER_ENV_DL ),
185 pImpl ( new SvxPage_Impl )
188 get(m_pPaperSizeBox,"comboPageFormat");
189 get(m_pPaperWidthEdit,"spinWidth");
190 get(m_pPaperHeightEdit,"spinHeight");
192 get(m_pOrientationFT,"labelOrientation");
193 get(m_pPortraitBtn,"radiobuttonPortrait");
194 get(m_pLandscapeBtn,"radiobuttonLandscape");
196 get(m_pBspWin,"drawingareaPageDirection");
197 get(m_pTextFlowLbl,"labelTextFlow");
198 get(m_pTextFlowBox,"comboTextFlowBox");
199 get(m_pPaperTrayBox,"comboPaperTray");
201 get(m_pLeftMarginLbl,"labelLeftMargin");
202 get(m_pLeftMarginEdit,"spinMargLeft");
203 get(m_pRightMarginLbl,"labelRightMargin");
204 get(m_pRightMarginEdit,"spinMargRight");
206 get(m_pTopMarginEdit,"spinMargTop");
208 get(m_pBottomMarginEdit,"spinMargBot");
210 get(m_pPageText,"labelPageLayout");
211 get(m_pLayoutBox,"comboPageLayout");
212 get(m_pNumberFormatBox,"comboLayoutFormat");
214 get(m_pRegisterCB,"checkRegisterTrue");
215 get(m_pRegisterFT,"labelRegisterStyle");
216 get(m_pRegisterLB,"comboRegisterStyle");
218 get(m_pTblAlignFT,"labelTblAlign");
219 get(m_pHorzBox,"checkbuttonHorz");
220 get(m_pVertBox,"checkbuttonVert");
222 get(m_pAdaptBox,"checkAdaptBox");
223 // Strings stored in UI
224 get(m_pInsideLbl,"labelInner");
225 get(m_pOutsideLbl,"labelOuter");
226 get(m_pPrintRangeQueryText,"labelMsg");
228 bBorderModified = sal_False;
229 m_pBspWin->EnableRTL( sal_False );
231 // this page needs ExchangeSupport
232 SetExchangeSupport();
234 SvtLanguageOptions aLangOptions;
235 sal_Bool bCJK = aLangOptions.IsAsianTypographyEnabled();
236 sal_Bool bCTL = aLangOptions.IsCTLFontEnabled();
237 sal_Bool bWeb = sal_False;
238 const SfxPoolItem* pItem;
240 SfxObjectShell* pShell;
241 if(SFX_ITEM_SET == rAttr.GetItemState(SID_HTML_MODE, sal_False, &pItem) ||
242 ( 0 != (pShell = SfxObjectShell::Current()) &&
243 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
244 bWeb = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
246 // fill text flow listbox with valid entries
248 m_pTextFlowBox->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_HORI ), FRMDIR_HORI_LEFT_TOP );
251 if( bCTL )
252 m_pTextFlowBox->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_HORI ), FRMDIR_HORI_RIGHT_TOP );
255 // #109989# do not show vertical directions in Writer/Web
256 if( !bWeb )
258 if( bCJK )
260 m_pTextFlowBox->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_VERT ), FRMDIR_VERT_TOP_RIGHT );
261 // m_pTextFlowBox->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_VERT ), FRMDIR_VERT_TOP_LEFT );
265 // #109989# show the text direction box in Writer/Web too
266 if( (bCJK || bCTL) &&
267 SFX_ITEM_UNKNOWN < rAttr.GetItemState(GetWhich( SID_ATTR_FRAMEDIRECTION )))
269 m_pTextFlowLbl->Show();
270 m_pTextFlowBox->Show();
271 m_pTextFlowBox->SetSelectHdl(LINK(this, SvxPageDescPage, FrameDirectionModify_Impl ));
273 m_pBspWin->EnableFrameDirection(sal_True);
275 Init_Impl();
277 FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
278 SetFieldUnit( *m_pLeftMarginEdit, eFUnit );
279 SetFieldUnit( *m_pRightMarginEdit, eFUnit );
280 SetFieldUnit( *m_pTopMarginEdit, eFUnit );
281 SetFieldUnit( *m_pBottomMarginEdit, eFUnit );
282 SetFieldUnit( *m_pPaperWidthEdit, eFUnit );
283 SetFieldUnit( *m_pPaperHeightEdit, eFUnit );
285 if ( SfxViewShell::Current() && SfxViewShell::Current()->GetPrinter() )
286 pImpl->mpDefPrinter = (Printer*)SfxViewShell::Current()->GetPrinter();
287 else
289 pImpl->mpDefPrinter = new Printer;
290 pImpl->mbDelPrinter = true;
293 MapMode aOldMode = pImpl->mpDefPrinter->GetMapMode();
294 pImpl->mpDefPrinter->SetMapMode( MAP_TWIP );
296 // set first- and last-values for the margins
297 Size aPaperSize = pImpl->mpDefPrinter->GetPaperSize();
298 Size aPrintSize = pImpl->mpDefPrinter->GetOutputSize();
300 * To convert a point ( 0,0 ) into logic coordinates
301 * looks like nonsense; but it makes sense when the
302 * coordinate system's origin has been moved.
304 Point aPrintOffset = pImpl->mpDefPrinter->GetPageOffset() -
305 pImpl->mpDefPrinter->PixelToLogic( Point() );
306 pImpl->mpDefPrinter->SetMapMode( aOldMode );
308 long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET;
309 m_pLeftMarginEdit->SetFirst( m_pLeftMarginEdit->Normalize( aPrintOffset.X() ), FUNIT_TWIP );
310 nFirstLeftMargin = static_cast<long>(m_pLeftMarginEdit->GetFirst());
312 m_pRightMarginEdit->SetFirst( m_pRightMarginEdit->Normalize( aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset ), FUNIT_TWIP);
313 nFirstRightMargin = static_cast<long>(m_pRightMarginEdit->GetFirst());
315 m_pTopMarginEdit->SetFirst( m_pTopMarginEdit->Normalize( aPrintOffset.Y() ), FUNIT_TWIP );
316 nFirstTopMargin = static_cast<long>(m_pTopMarginEdit->GetFirst());
318 m_pBottomMarginEdit->SetFirst( m_pBottomMarginEdit->Normalize( aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset ), FUNIT_TWIP );
319 nFirstBottomMargin = static_cast<long>(m_pBottomMarginEdit->GetFirst());
321 m_pLeftMarginEdit->SetLast( m_pLeftMarginEdit->Normalize( aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP );
322 nLastLeftMargin = static_cast<long>(m_pLeftMarginEdit->GetLast());
324 m_pRightMarginEdit->SetLast( m_pRightMarginEdit->Normalize( aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP );
325 nLastRightMargin = static_cast<long>(m_pRightMarginEdit->GetLast());
327 m_pTopMarginEdit->SetLast( m_pTopMarginEdit->Normalize( aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP );
328 nLastTopMargin = static_cast<long>(m_pTopMarginEdit->GetLast());
330 m_pBottomMarginEdit->SetLast( m_pBottomMarginEdit->Normalize( aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP );
331 nLastBottomMargin = static_cast<long>(m_pBottomMarginEdit->GetLast());
333 // #i4219# get DrawingLayer options
334 const SvtOptionsDrawinglayer aDrawinglayerOpt;
336 // #i4219# take Maximum now from configuration (1/100th cm)
337 // was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000
338 m_pPaperWidthEdit->SetMax(m_pPaperWidthEdit->Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
339 m_pPaperWidthEdit->SetLast(m_pPaperWidthEdit->Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
340 m_pPaperHeightEdit->SetMax(m_pPaperHeightEdit->Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
341 m_pPaperHeightEdit->SetLast(m_pPaperHeightEdit->Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
343 // #i4219# also for margins (1/100th cm). Was: 9999, keeping.
344 m_pLeftMarginEdit->SetMax(aDrawinglayerOpt.GetMaximumPaperLeftMargin());
345 m_pLeftMarginEdit->SetLast(aDrawinglayerOpt.GetMaximumPaperLeftMargin());
346 m_pRightMarginEdit->SetMax(aDrawinglayerOpt.GetMaximumPaperRightMargin());
347 m_pRightMarginEdit->SetLast(aDrawinglayerOpt.GetMaximumPaperRightMargin());
348 m_pTopMarginEdit->SetMax(aDrawinglayerOpt.GetMaximumPaperTopMargin());
349 m_pTopMarginEdit->SetLast(aDrawinglayerOpt.GetMaximumPaperTopMargin());
350 m_pBottomMarginEdit->SetMax(aDrawinglayerOpt.GetMaximumPaperBottomMargin());
351 m_pBottomMarginEdit->SetLast(aDrawinglayerOpt.GetMaximumPaperBottomMargin());
353 m_pPortraitBtn->SetAccessibleRelationMemberOf(m_pOrientationFT);
354 m_pLandscapeBtn->SetAccessibleRelationMemberOf(m_pOrientationFT);
356 // Get the i18n framework numberings and add them to the listbox.
357 SvxNumOptionsTabPage::GetI18nNumbering( *m_pNumberFormatBox, ::std::numeric_limits<sal_uInt16>::max());
360 // -----------------------------------------------------------------------
362 SvxPageDescPage::~SvxPageDescPage()
364 delete pImpl;
367 // -----------------------------------------------------------------------
369 void SvxPageDescPage::Init_Impl()
371 // adjust the handler
372 m_pLayoutBox->SetSelectHdl( LINK( this, SvxPageDescPage, LayoutHdl_Impl ) );
373 m_pPaperSizeBox->SetDropDownLineCount(10);
375 m_pPaperTrayBox->SetGetFocusHdl( LINK( this, SvxPageDescPage, PaperBinHdl_Impl ) );
376 m_pPaperSizeBox->SetSelectHdl( LINK( this, SvxPageDescPage, PaperSizeSelect_Impl ) );
377 m_pPaperWidthEdit->SetModifyHdl( LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) );
378 m_pPaperHeightEdit->SetModifyHdl( LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) );
379 m_pLandscapeBtn->SetClickHdl( LINK( this, SvxPageDescPage, SwapOrientation_Impl ) );
380 m_pPortraitBtn->SetClickHdl( LINK( this, SvxPageDescPage, SwapOrientation_Impl ) );
382 Link aLink = LINK( this, SvxPageDescPage, BorderModify_Impl );
383 m_pLeftMarginEdit->SetModifyHdl( aLink );
384 m_pRightMarginEdit->SetModifyHdl( aLink );
385 m_pTopMarginEdit->SetModifyHdl( aLink );
386 m_pBottomMarginEdit->SetModifyHdl( aLink );
388 aLink = LINK( this, SvxPageDescPage, RangeHdl_Impl );
389 m_pPaperWidthEdit->SetLoseFocusHdl( aLink );
390 m_pPaperHeightEdit->SetLoseFocusHdl( aLink );
391 m_pLeftMarginEdit->SetLoseFocusHdl( aLink );
392 m_pRightMarginEdit->SetLoseFocusHdl( aLink );
393 m_pTopMarginEdit->SetLoseFocusHdl( aLink );
394 m_pBottomMarginEdit->SetLoseFocusHdl( aLink );
396 m_pHorzBox->SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) );
397 m_pVertBox->SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) );
401 // -----------------------------------------------------------------------
403 void SvxPageDescPage::Reset( const SfxItemSet& rSet )
405 SfxItemPool* pPool = rSet.GetPool();
406 DBG_ASSERT( pPool, "Wo ist der Pool" );
407 SfxMapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) );
409 // adjust margins (right/left)
410 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_LRSPACE );
412 if ( pItem )
414 const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)*pItem;
415 SetMetricValue( *m_pLeftMarginEdit, rLRSpace.GetLeft(), eUnit );
416 m_pBspWin->SetLeft(
417 (sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetLeft(), eUnit ) );
418 SetMetricValue( *m_pRightMarginEdit, rLRSpace.GetRight(), eUnit );
419 m_pBspWin->SetRight(
420 (sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetRight(), eUnit ) );
423 // adjust margins (top/bottom)
424 pItem = GetItem( rSet, SID_ATTR_ULSPACE );
426 if ( pItem )
428 const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)*pItem;
429 SetMetricValue( *m_pTopMarginEdit, rULSpace.GetUpper(), eUnit );
430 m_pBspWin->SetTop(
431 (sal_uInt16)ConvertLong_Impl( (long)rULSpace.GetUpper(), eUnit ) );
432 SetMetricValue( *m_pBottomMarginEdit, rULSpace.GetLower(), eUnit );
433 m_pBspWin->SetBottom(
434 (sal_uInt16)ConvertLong_Impl( (long)rULSpace.GetLower(), eUnit ) );
437 // general page data
438 SvxNumType eNumType = SVX_ARABIC;
439 bLandscape = ( pImpl->mpDefPrinter->GetOrientation() == ORIENTATION_LANDSCAPE );
440 sal_uInt16 nUse = (sal_uInt16)SVX_PAGE_ALL;
441 pItem = GetItem( rSet, SID_ATTR_PAGE );
443 if ( pItem )
445 const SvxPageItem& rItem = (const SvxPageItem&)*pItem;
446 eNumType = rItem.GetNumType();
447 nUse = rItem.GetPageUsage();
448 bLandscape = rItem.IsLandscape();
451 // alignment
452 m_pLayoutBox->SelectEntryPos( ::PageUsageToPos_Impl( nUse ) );
453 m_pBspWin->SetUsage( nUse );
454 LayoutHdl_Impl( 0 );
456 //adjust numeration type of the page style
457 //Get the Position of the saved NumType
458 for(int i=0; i<m_pNumberFormatBox->GetEntryCount(); i++)
459 if(eNumType == (sal_uInt16)(sal_uLong)m_pNumberFormatBox->GetEntryData(i)){
460 m_pNumberFormatBox->SelectEntryPos( i );
461 break;
464 m_pPaperTrayBox->Clear();
465 sal_uInt8 nPaperBin = PAPERBIN_PRINTER_SETTINGS;
466 pItem = GetItem( rSet, SID_ATTR_PAGE_PAPERBIN );
468 if ( pItem )
470 nPaperBin = ( (const SvxPaperBinItem*)pItem )->GetValue();
472 if ( nPaperBin >= pImpl->mpDefPrinter->GetPaperBinCount() )
473 nPaperBin = PAPERBIN_PRINTER_SETTINGS;
476 String aBinName;
478 if ( PAPERBIN_PRINTER_SETTINGS == nPaperBin )
479 aBinName = EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS );
480 else
481 aBinName = pImpl->mpDefPrinter->GetPaperBinName( (sal_uInt16)nPaperBin );
483 sal_uInt16 nEntryPos = m_pPaperTrayBox->InsertEntry( aBinName );
484 m_pPaperTrayBox->SetEntryData( nEntryPos, (void*)(sal_uLong)nPaperBin );
485 m_pPaperTrayBox->SelectEntry( aBinName );
487 Size aPaperSize = SvxPaperInfo::GetPaperSize( pImpl->mpDefPrinter );
488 pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
490 if ( pItem )
491 aPaperSize = ( (const SvxSizeItem*)pItem )->GetSize();
493 bool bOrientationSupport =
494 pImpl->mpDefPrinter->HasSupport( SUPPORT_SET_ORIENTATION );
496 if ( !bOrientationSupport &&
497 aPaperSize.Width() > aPaperSize.Height() )
498 bLandscape = sal_True;
500 m_pLandscapeBtn->Check( bLandscape );
501 m_pPortraitBtn->Check( !bLandscape );
503 m_pBspWin->SetSize( Size( ConvertLong_Impl( aPaperSize.Width(), eUnit ),
504 ConvertLong_Impl( aPaperSize.Height(), eUnit ) ) );
506 aPaperSize = OutputDevice::LogicToLogic(aPaperSize, (MapUnit)eUnit, MAP_100TH_MM);
507 if ( bLandscape )
508 Swap( aPaperSize );
510 // Actual Paper Format
511 Paper ePaper = SvxPaperInfo::GetSvxPaper( aPaperSize, MAP_100TH_MM, sal_True );
513 if ( PAPER_USER != ePaper )
514 aPaperSize = SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM );
516 if ( bLandscape )
517 Swap( aPaperSize );
519 // write values into the edits
520 SetMetricValue( *m_pPaperHeightEdit, aPaperSize.Height(), SFX_MAPUNIT_100TH_MM );
521 SetMetricValue( *m_pPaperWidthEdit, aPaperSize.Width(), SFX_MAPUNIT_100TH_MM );
522 m_pPaperSizeBox->Clear();
524 sal_uInt16 nActPos = LISTBOX_ENTRY_NOTFOUND;
525 sal_uInt16 nAryId = RID_SVXSTRARY_PAPERSIZE_STD;
527 if ( ePaperStart != PAPER_A3 )
528 nAryId = RID_SVXSTRARY_PAPERSIZE_DRAW;
529 ResStringArray aPaperAry( CUI_RES( nAryId ) );
530 sal_uInt32 nCnt = aPaperAry.Count();
532 sal_uInt16 nUserPos = LISTBOX_ENTRY_NOTFOUND;
533 for ( sal_uInt32 i = 0; i < nCnt; ++i )
535 String aStr = aPaperAry.GetString(i);
536 Paper eSize = (Paper)aPaperAry.GetValue(i);
537 sal_uInt16 nPos = m_pPaperSizeBox->InsertEntry( aStr );
538 m_pPaperSizeBox->SetEntryData( nPos, (void*)(sal_uLong)eSize );
540 if ( eSize == ePaper )
541 nActPos = nPos;
542 if( eSize == PAPER_USER )
543 nUserPos = nPos;
545 // preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead
546 m_pPaperSizeBox->SelectEntryPos( nActPos != LISTBOX_ENTRY_NOTFOUND ? nActPos : nUserPos );
548 // application specific
550 switch ( eMode )
552 case SVX_PAGE_MODE_CENTER:
554 m_pTblAlignFT->Show();
555 m_pHorzBox->Show();
556 m_pVertBox->Show();
557 DisableVerticalPageDir();
559 // horizontal alignment
560 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
561 m_pHorzBox->Check( pItem ? ( (const SfxBoolItem*)pItem )->GetValue()
562 : sal_False );
564 // vertical alignment
565 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 );
566 m_pVertBox->Check( pItem ? ( (const SfxBoolItem*)pItem )->GetValue()
567 : sal_False );
569 // set example window on the table
570 m_pBspWin->SetTable( sal_True );
571 m_pBspWin->SetHorz( m_pHorzBox->IsChecked() );
572 m_pBspWin->SetVert( m_pVertBox->IsChecked() );
574 break;
577 case SVX_PAGE_MODE_PRESENTATION:
579 DisableVerticalPageDir();
580 m_pAdaptBox->Show();
581 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
582 m_pAdaptBox->Check( pItem ?
583 ( (const SfxBoolItem*)pItem )->GetValue() : sal_False );
585 //!!! hidden, because not implemented by StarDraw
586 m_pLayoutBox->Hide();
587 m_pPageText->Hide();
589 break;
591 default: ;//prevent warning
595 // display background and border in the example
596 ResetBackground_Impl( rSet );
597 //! UpdateExample_Impl();
598 RangeHdl_Impl( 0 );
600 InitHeadFoot_Impl( rSet );
602 bBorderModified = sal_False;
603 SwapFirstValues_Impl( sal_False );
604 UpdateExample_Impl();
606 m_pLeftMarginEdit->SaveValue();
607 m_pRightMarginEdit->SaveValue();
608 m_pTopMarginEdit->SaveValue();
609 m_pBottomMarginEdit->SaveValue();
610 m_pLayoutBox->SaveValue();
611 m_pNumberFormatBox->SaveValue();
612 m_pPaperSizeBox->SaveValue();
613 m_pPaperWidthEdit->SaveValue();
614 m_pPaperHeightEdit->SaveValue();
615 m_pPortraitBtn->SaveValue();
616 m_pLandscapeBtn->SaveValue();
617 m_pPaperTrayBox->SaveValue();
618 m_pVertBox->SaveValue();
619 m_pHorzBox->SaveValue();
620 m_pAdaptBox->SaveValue();
622 CheckMarginEdits( true );
625 if(SFX_ITEM_SET == rSet.GetItemState(SID_SWREGISTER_MODE))
627 m_pRegisterCB->Check(((const SfxBoolItem&)rSet.Get(
628 SID_SWREGISTER_MODE)).GetValue());
629 m_pRegisterCB->SaveValue();
630 RegisterModify(m_pRegisterCB);
632 if(SFX_ITEM_SET == rSet.GetItemState(SID_SWREGISTER_COLLECTION))
634 m_pRegisterLB->SelectEntry(
635 ((const SfxStringItem&)rSet.Get(SID_SWREGISTER_COLLECTION)).GetValue());
636 m_pRegisterLB->SaveValue();
639 SfxItemState eState = rSet.GetItemState( GetWhich( SID_ATTR_FRAMEDIRECTION ),
640 sal_True, &pItem );
641 if( SFX_ITEM_UNKNOWN != eState )
643 sal_uInt32 nVal = SFX_ITEM_SET == eState
644 ? ((SvxFrameDirectionItem*)pItem)->GetValue()
645 : 0;
646 m_pTextFlowBox->SelectEntryValue( static_cast< SvxFrameDirection >( nVal ) );
648 m_pTextFlowBox->SaveValue();
649 m_pBspWin->SetFrameDirection(nVal);
653 // -----------------------------------------------------------------------
655 void SvxPageDescPage::FillUserData()
657 if ( SVX_PAGE_MODE_PRESENTATION == eMode )
658 SetUserData( m_pAdaptBox->IsChecked() ? OUString("1") : OUString("0") ) ;
662 // -----------------------------------------------------------------------
664 sal_Bool SvxPageDescPage::FillItemSet( SfxItemSet& rSet )
666 sal_Bool bModified = sal_False;
667 const SfxItemSet& rOldSet = GetItemSet();
668 SfxItemPool* pPool = rOldSet.GetPool();
669 DBG_ASSERT( pPool, "Wo ist der Pool" );
670 sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE );
671 SfxMapUnit eUnit = pPool->GetMetric( nWhich );
672 const SfxPoolItem* pOld = 0;
674 // copy old left and right margins
675 SvxLRSpaceItem aMargin( (const SvxLRSpaceItem&)rOldSet.Get( nWhich ) );
677 // copy old top and bottom margins
678 nWhich = GetWhich( SID_ATTR_ULSPACE );
679 SvxULSpaceItem aTopMargin( (const SvxULSpaceItem&)rOldSet.Get( nWhich ) );
681 if ( m_pLeftMarginEdit->GetText() != m_pLeftMarginEdit->GetSavedValue() )
683 aMargin.SetLeft( (sal_uInt16)GetCoreValue( *m_pLeftMarginEdit, eUnit ) );
684 bModified |= sal_True;
687 if ( m_pRightMarginEdit->GetText() != m_pRightMarginEdit->GetSavedValue() )
689 aMargin.SetRight( (sal_uInt16)GetCoreValue( *m_pRightMarginEdit, eUnit ) );
690 bModified |= sal_True;
693 // set left and right margins
694 if ( bModified )
696 pOld = GetOldItem( rSet, SID_ATTR_LRSPACE );
698 if ( !pOld || !( *(const SvxLRSpaceItem*)pOld == aMargin ) )
699 rSet.Put( aMargin );
700 else
701 bModified = sal_False;
704 sal_Bool bMod = sal_False;
706 if ( m_pTopMarginEdit->GetText() != m_pTopMarginEdit->GetSavedValue() )
708 aTopMargin.SetUpper( (sal_uInt16)GetCoreValue( *m_pTopMarginEdit, eUnit ) );
709 bMod |= sal_True;
712 if ( m_pBottomMarginEdit->GetText() != m_pBottomMarginEdit->GetSavedValue() )
714 aTopMargin.SetLower( (sal_uInt16)GetCoreValue( *m_pBottomMarginEdit, eUnit ) );
715 bMod |= sal_True;
718 // set top and bottom margins
720 if ( bMod )
722 pOld = GetOldItem( rSet, SID_ATTR_ULSPACE );
724 if ( !pOld || !( *(const SvxULSpaceItem*)pOld == aTopMargin ) )
726 bModified |= sal_True;
727 rSet.Put( aTopMargin );
731 // paper tray
732 nWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN );
733 sal_uInt16 nPos = m_pPaperTrayBox->GetSelectEntryPos();
734 sal_uInt16 nBin = (sal_uInt16)(sal_uLong)m_pPaperTrayBox->GetEntryData( nPos );
735 pOld = GetOldItem( rSet, SID_ATTR_PAGE_PAPERBIN );
737 if ( !pOld || ( (const SvxPaperBinItem*)pOld )->GetValue() != nBin )
739 rSet.Put( SvxPaperBinItem( nWhich, (sal_uInt8)nBin ) );
740 bModified |= sal_True;
743 nPos = m_pPaperSizeBox->GetSelectEntryPos();
744 Paper ePaper = (Paper)(sal_uLong)m_pPaperSizeBox->GetEntryData( nPos );
745 const sal_uInt16 nOld = m_pPaperSizeBox->GetSavedValue();
746 sal_Bool bChecked = m_pLandscapeBtn->IsChecked();
748 if ( PAPER_USER == ePaper )
750 if ( nOld != nPos ||
751 m_pPaperWidthEdit->IsValueModified() ||
752 m_pPaperHeightEdit->IsValueModified() ||
753 bChecked != m_pLandscapeBtn->GetSavedValue() )
755 Size aSize( GetCoreValue( *m_pPaperWidthEdit, eUnit ),
756 GetCoreValue( *m_pPaperHeightEdit, eUnit ) );
757 pOld = GetOldItem( rSet, SID_ATTR_PAGE_SIZE );
759 if ( !pOld || ( (const SvxSizeItem*)pOld )->GetSize() != aSize )
761 rSet.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
762 bModified |= sal_True;
766 else
768 if ( nOld != nPos || bChecked != m_pLandscapeBtn->GetSavedValue() )
770 Size aSize( SvxPaperInfo::GetPaperSize( ePaper, (MapUnit)eUnit ) );
772 if ( bChecked )
773 Swap( aSize );
775 pOld = GetOldItem( rSet, SID_ATTR_PAGE_SIZE );
777 if ( !pOld || ( (const SvxSizeItem*)pOld )->GetSize() != aSize )
779 rSet.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
780 bModified |= sal_True;
785 nWhich = GetWhich( SID_ATTR_PAGE );
786 SvxPageItem aPage( (const SvxPageItem&)rOldSet.Get( nWhich ) );
787 bMod = m_pLayoutBox->GetSelectEntryPos() != m_pLayoutBox->GetSavedValue();
789 if ( bMod )
790 aPage.SetPageUsage(
791 ::PosToPageUsage_Impl( m_pLayoutBox->GetSelectEntryPos() ) );
793 if ( bChecked != m_pLandscapeBtn->GetSavedValue() )
795 aPage.SetLandscape(bChecked);
796 bMod |= sal_True;
799 //Get the NumType value
800 nPos = m_pNumberFormatBox->GetSelectEntryPos();
801 sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)m_pNumberFormatBox->GetEntryData(nPos);
802 if ( nPos != m_pNumberFormatBox->GetSavedValue() )
804 aPage.SetNumType( (SvxNumType)nEntryData );
805 bMod |= sal_True;
808 if ( bMod )
810 pOld = GetOldItem( rSet, SID_ATTR_PAGE );
812 if ( !pOld || !( *(const SvxPageItem*)pOld == aPage ) )
814 rSet.Put( aPage );
815 bModified |= sal_True;
818 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich ) )
819 rSet.ClearItem( nWhich );
820 else
821 rSet.Put( rOldSet.Get( nWhich ) );
823 // evaluate mode specific controls
825 switch ( eMode )
827 case SVX_PAGE_MODE_CENTER:
829 if ( m_pHorzBox->IsChecked() != m_pHorzBox->GetSavedValue() )
831 SfxBoolItem aHorz( GetWhich( SID_ATTR_PAGE_EXT1 ),
832 m_pHorzBox->IsChecked() );
833 rSet.Put( aHorz );
834 bModified |= sal_True;
837 if ( m_pVertBox->IsChecked() != m_pVertBox->GetSavedValue() )
839 SfxBoolItem aVert( GetWhich( SID_ATTR_PAGE_EXT2 ),
840 m_pVertBox->IsChecked() );
841 rSet.Put( aVert );
842 bModified |= sal_True;
844 break;
847 case SVX_PAGE_MODE_PRESENTATION:
849 // always put so that draw can evaluate this
850 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_PAGE_EXT1 ),
851 m_pAdaptBox->IsChecked() ) );
852 bModified |= sal_True;
853 break;
855 default: ;//prevent warning
859 if(m_pRegisterCB->IsVisible() &&
860 (m_pRegisterCB->IsChecked() || m_pRegisterCB->GetSavedValue() != m_pRegisterCB->IsChecked()))
862 const SfxBoolItem& rRegItem = (const SfxBoolItem&)rOldSet.Get(SID_SWREGISTER_MODE);
863 SfxBoolItem* pRegItem = (SfxBoolItem*)rRegItem.Clone();
864 sal_Bool bCheck = m_pRegisterCB->IsChecked();
865 pRegItem->SetValue(bCheck);
866 rSet.Put(*pRegItem);
867 bModified |= sal_True;
868 if(bCheck)
870 bModified |= sal_True;
871 rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION,
872 m_pRegisterLB->GetSelectEntry()));
874 delete pRegItem;
877 SvxFrameDirection eDirection = m_pTextFlowBox->GetSelectEntryValue();
878 if( m_pTextFlowBox->IsVisible() && (eDirection != m_pTextFlowBox->GetSavedValue()) )
880 rSet.Put( SvxFrameDirectionItem( eDirection, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
881 bModified = sal_True;
884 return bModified;
887 // -----------------------------------------------------------------------
889 IMPL_LINK_NOARG(SvxPageDescPage, LayoutHdl_Impl)
891 // switch inside outside
892 const sal_uInt16 nPos = PosToPageUsage_Impl( m_pLayoutBox->GetSelectEntryPos() );
894 if ( nPos == SVX_PAGE_MIRROR )
896 m_pLeftMarginLbl->Hide();
897 m_pRightMarginLbl->Hide();
898 m_pInsideLbl->Show();
899 m_pOutsideLbl->Show();
901 else
903 m_pLeftMarginLbl->Show();
904 m_pRightMarginLbl->Show();
905 m_pInsideLbl->Hide();
906 m_pOutsideLbl->Hide();
908 UpdateExample_Impl( true );
909 return 0;
912 // -----------------------------------------------------------------------
914 IMPL_LINK_NOARG(SvxPageDescPage, PaperBinHdl_Impl)
916 if ( m_pPaperTrayBox->GetEntryCount() > 1 )
917 // already filled
918 return 0;
920 String aOldName = m_pPaperTrayBox->GetSelectEntry();
921 m_pPaperTrayBox->SetUpdateMode( sal_False );
922 m_pPaperTrayBox->Clear();
923 sal_uInt16 nEntryPos = m_pPaperTrayBox->InsertEntry(
924 EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS ) );
925 m_pPaperTrayBox->SetEntryData( nEntryPos,
926 (void*)(sal_uLong)PAPERBIN_PRINTER_SETTINGS );
927 String aPaperBin( EditResId( RID_SVXSTR_PAPERBIN ) );
928 sal_uInt16 nBinCount = pImpl->mpDefPrinter->GetPaperBinCount();
930 for ( sal_uInt16 i = 0; i < nBinCount; ++i )
932 String aName = pImpl->mpDefPrinter->GetPaperBinName(i);
934 if ( !aName.Len() )
936 aName = aPaperBin;
937 aName.Append( sal_Unicode(' ') );
938 aName.Append( OUString::valueOf( static_cast<sal_Int32>(i+1) ) );
940 nEntryPos = m_pPaperTrayBox->InsertEntry( aName );
941 m_pPaperTrayBox->SetEntryData( nEntryPos, (void*)(sal_uLong)i );
943 m_pPaperTrayBox->SelectEntry( aOldName );
944 m_pPaperTrayBox->SetUpdateMode( sal_True );
946 return 0;
949 // -----------------------------------------------------------------------
951 IMPL_LINK( SvxPageDescPage, PaperSizeSelect_Impl, ListBox *, pBox )
953 const sal_uInt16 nPos = pBox->GetSelectEntryPos();
954 Paper ePaper = (Paper)(sal_uLong)m_pPaperSizeBox->GetEntryData( nPos );
956 if ( ePaper != PAPER_USER )
958 Size aSize( SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM ) );
960 if ( m_pLandscapeBtn->IsChecked() )
961 Swap( aSize );
963 if ( aSize.Height() < m_pPaperHeightEdit->GetMin( FUNIT_100TH_MM ) )
964 m_pPaperHeightEdit->SetMin(
965 m_pPaperHeightEdit->Normalize( aSize.Height() ), FUNIT_100TH_MM );
966 if ( aSize.Width() < m_pPaperWidthEdit->GetMin( FUNIT_100TH_MM ) )
967 m_pPaperWidthEdit->SetMin(
968 m_pPaperWidthEdit->Normalize( aSize.Width() ), FUNIT_100TH_MM );
969 SetMetricValue( *m_pPaperHeightEdit, aSize.Height(), SFX_MAPUNIT_100TH_MM );
970 SetMetricValue( *m_pPaperWidthEdit, aSize.Width(), SFX_MAPUNIT_100TH_MM );
972 CalcMargin_Impl();
974 RangeHdl_Impl( 0 );
975 UpdateExample_Impl( true );
977 if ( eMode == SVX_PAGE_MODE_PRESENTATION )
979 // Draw: if paper format the margin shall be 1 cm
980 long nTmp = 0;
981 sal_Bool bScreen = (( PAPER_SCREEN_4_3 == ePaper )||( PAPER_SCREEN_16_9 == ePaper)||( PAPER_SCREEN_16_10 == ePaper));
983 if ( !bScreen )
984 // no margin if screen
985 nTmp = 1; // accordingly 1 cm
987 if ( bScreen || m_pRightMarginEdit->GetValue() == 0 )
989 SetMetricValue( *m_pRightMarginEdit, nTmp, SFX_MAPUNIT_CM );
990 if ( !bScreen &&
991 m_pRightMarginEdit->GetFirst() > m_pRightMarginEdit->GetValue() )
992 m_pRightMarginEdit->SetValue( m_pRightMarginEdit->GetFirst() );
994 if ( bScreen || m_pLeftMarginEdit->GetValue() == 0 )
996 SetMetricValue( *m_pLeftMarginEdit, nTmp, SFX_MAPUNIT_CM );
997 if ( !bScreen &&
998 m_pLeftMarginEdit->GetFirst() > m_pLeftMarginEdit->GetValue() )
999 m_pLeftMarginEdit->SetValue( m_pLeftMarginEdit->GetFirst() );
1001 if ( bScreen || m_pBottomMarginEdit->GetValue() == 0 )
1003 SetMetricValue( *m_pBottomMarginEdit, nTmp, SFX_MAPUNIT_CM );
1004 if ( !bScreen &&
1005 m_pBottomMarginEdit->GetFirst() > m_pBottomMarginEdit->GetValue() )
1006 m_pBottomMarginEdit->SetValue( m_pBottomMarginEdit->GetFirst() );
1008 if ( bScreen || m_pTopMarginEdit->GetValue() == 0 )
1010 SetMetricValue( *m_pTopMarginEdit, nTmp, SFX_MAPUNIT_CM );
1011 if ( !bScreen &&
1012 m_pTopMarginEdit->GetFirst() > m_pTopMarginEdit->GetValue() )
1013 m_pTopMarginEdit->SetValue( m_pTopMarginEdit->GetFirst() );
1015 UpdateExample_Impl( true );
1018 return 0;
1021 // -----------------------------------------------------------------------
1023 IMPL_LINK_NOARG(SvxPageDescPage, PaperSizeModify_Impl)
1025 sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE );
1026 SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWhich );
1027 Size aSize( GetCoreValue( *m_pPaperWidthEdit, eUnit ),
1028 GetCoreValue( *m_pPaperHeightEdit, eUnit ) );
1029 Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, (MapUnit)eUnit, sal_True );
1030 sal_uInt16 nEntryCount = m_pPaperSizeBox->GetEntryCount();
1032 for ( sal_uInt16 i = 0; i < nEntryCount; ++i )
1034 Paper eTmp = (Paper)(sal_uLong)m_pPaperSizeBox->GetEntryData(i);
1036 if ( eTmp == ePaper )
1038 m_pPaperSizeBox->SelectEntryPos(i);
1039 break;
1042 UpdateExample_Impl( true );
1043 return 0;
1046 // -----------------------------------------------------------------------
1048 IMPL_LINK( SvxPageDescPage, SwapOrientation_Impl, RadioButton *, pBtn )
1050 if (
1051 (!bLandscape && pBtn == m_pLandscapeBtn) ||
1052 (bLandscape && pBtn == m_pPortraitBtn)
1055 bLandscape = m_pLandscapeBtn->IsChecked();
1057 const long lWidth = GetCoreValue( *m_pPaperWidthEdit, SFX_MAPUNIT_100TH_MM );
1058 const long lHeight = GetCoreValue( *m_pPaperHeightEdit, SFX_MAPUNIT_100TH_MM );
1060 // swap with and height
1061 SetMetricValue( *m_pPaperWidthEdit, lHeight, SFX_MAPUNIT_100TH_MM );
1062 SetMetricValue( *m_pPaperHeightEdit, lWidth, SFX_MAPUNIT_100TH_MM );
1064 // recalculate margins if necessary
1065 CalcMargin_Impl();
1067 PaperSizeSelect_Impl( m_pPaperSizeBox );
1068 RangeHdl_Impl( 0 );
1069 SwapFirstValues_Impl( bBorderModified );
1070 UpdateExample_Impl( true );
1072 return 0;
1075 // -----------------------------------------------------------------------
1077 void SvxPageDescPage::SwapFirstValues_Impl( bool bSet )
1079 MapMode aOldMode = pImpl->mpDefPrinter->GetMapMode();
1080 Orientation eOri = ORIENTATION_PORTRAIT;
1082 if ( bLandscape )
1083 eOri = ORIENTATION_LANDSCAPE;
1084 Orientation eOldOri = pImpl->mpDefPrinter->GetOrientation();
1085 pImpl->mpDefPrinter->SetOrientation( eOri );
1086 pImpl->mpDefPrinter->SetMapMode( MAP_TWIP );
1088 // set first- and last-values for margins
1089 Size aPaperSize = pImpl->mpDefPrinter->GetPaperSize();
1090 Size aPrintSize = pImpl->mpDefPrinter->GetOutputSize();
1092 * To convert a point ( 0,0 ) into logic coordinates
1093 * looks like nonsense; but it makes sense if the
1094 * coordinate system's origin has been moved.
1096 Point aPrintOffset = pImpl->mpDefPrinter->GetPageOffset() -
1097 pImpl->mpDefPrinter->PixelToLogic( Point() );
1098 pImpl->mpDefPrinter->SetMapMode( aOldMode );
1099 pImpl->mpDefPrinter->SetOrientation( eOldOri );
1101 sal_Int64 nSetL = m_pLeftMarginEdit->Denormalize(
1102 m_pLeftMarginEdit->GetValue( FUNIT_TWIP ) );
1103 sal_Int64 nSetR = m_pRightMarginEdit->Denormalize(
1104 m_pRightMarginEdit->GetValue( FUNIT_TWIP ) );
1105 sal_Int64 nSetT = m_pTopMarginEdit->Denormalize(
1106 m_pTopMarginEdit->GetValue( FUNIT_TWIP ) );
1107 sal_Int64 nSetB = m_pBottomMarginEdit->Denormalize(
1108 m_pBottomMarginEdit->GetValue( FUNIT_TWIP ) );
1110 long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET;
1111 long nNewL = aPrintOffset.X();
1112 long nNewR =
1113 aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset;
1114 long nNewT = aPrintOffset.Y();
1115 long nNewB =
1116 aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset;
1118 m_pLeftMarginEdit->SetFirst( m_pLeftMarginEdit->Normalize( nNewL ), FUNIT_TWIP );
1119 nFirstLeftMargin = static_cast<long>(m_pLeftMarginEdit->GetFirst());
1120 m_pRightMarginEdit->SetFirst( m_pRightMarginEdit->Normalize( nNewR ), FUNIT_TWIP );
1121 nFirstRightMargin = static_cast<long>(m_pRightMarginEdit->GetFirst());
1122 m_pTopMarginEdit->SetFirst( m_pTopMarginEdit->Normalize( nNewT ), FUNIT_TWIP );
1123 nFirstTopMargin = static_cast<long>(m_pTopMarginEdit->GetFirst());
1124 m_pBottomMarginEdit->SetFirst( m_pBottomMarginEdit->Normalize( nNewB ), FUNIT_TWIP );
1125 nFirstBottomMargin = static_cast<long>(m_pBottomMarginEdit->GetFirst());
1127 if ( bSet )
1129 if ( nSetL < nNewL )
1130 m_pLeftMarginEdit->SetValue( m_pLeftMarginEdit->Normalize( nNewL ),
1131 FUNIT_TWIP );
1132 if ( nSetR < nNewR )
1133 m_pRightMarginEdit->SetValue( m_pRightMarginEdit->Normalize( nNewR ),
1134 FUNIT_TWIP );
1135 if ( nSetT < nNewT )
1136 m_pTopMarginEdit->SetValue( m_pTopMarginEdit->Normalize( nNewT ),
1137 FUNIT_TWIP );
1138 if ( nSetB < nNewB )
1139 m_pBottomMarginEdit->SetValue( m_pBottomMarginEdit->Normalize( nNewB ),
1140 FUNIT_TWIP );
1144 // -----------------------------------------------------------------------
1146 IMPL_LINK_NOARG_INLINE_START(SvxPageDescPage, BorderModify_Impl)
1148 if ( !bBorderModified )
1149 bBorderModified = sal_True;
1150 UpdateExample_Impl();
1151 return 0;
1153 IMPL_LINK_NOARG_INLINE_END(SvxPageDescPage, BorderModify_Impl)
1155 // -----------------------------------------------------------------------
1157 void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground )
1159 // Size
1160 Size aSize( GetCoreValue( *m_pPaperWidthEdit, SFX_MAPUNIT_TWIP ),
1161 GetCoreValue( *m_pPaperHeightEdit, SFX_MAPUNIT_TWIP ) );
1163 m_pBspWin->SetSize( aSize );
1165 // Margins
1166 m_pBspWin->SetTop( GetCoreValue( *m_pTopMarginEdit, SFX_MAPUNIT_TWIP ) );
1167 m_pBspWin->SetBottom( GetCoreValue( *m_pBottomMarginEdit, SFX_MAPUNIT_TWIP ) );
1168 m_pBspWin->SetLeft( GetCoreValue( *m_pLeftMarginEdit, SFX_MAPUNIT_TWIP ) );
1169 m_pBspWin->SetRight( GetCoreValue( *m_pRightMarginEdit, SFX_MAPUNIT_TWIP ) );
1171 // Layout
1172 m_pBspWin->SetUsage( PosToPageUsage_Impl( m_pLayoutBox->GetSelectEntryPos() ) );
1173 if ( bResetbackground )
1174 m_pBspWin->ResetBackground();
1175 m_pBspWin->Invalidate();
1178 // -----------------------------------------------------------------------
1180 void SvxPageDescPage::ResetBackground_Impl( const SfxItemSet& rSet )
1182 sal_uInt16 nWhich = GetWhich( SID_ATTR_PAGE_HEADERSET );
1184 if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET )
1186 const SvxSetItem& rSetItem =
1187 (const SvxSetItem&)rSet.Get( nWhich, sal_False );
1188 const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1189 const SfxBoolItem& rOn =
1190 (const SfxBoolItem&)rTmpSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1192 if ( rOn.GetValue() )
1194 nWhich = GetWhich( SID_ATTR_BRUSH );
1196 if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1198 const SvxBrushItem& rItem =
1199 (const SvxBrushItem&)rTmpSet.Get( nWhich );
1200 m_pBspWin->SetHdColor( rItem.GetColor() );
1202 nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1204 if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1206 const SvxBoxItem& rItem =
1207 (const SvxBoxItem&)rTmpSet.Get( nWhich );
1208 m_pBspWin->SetHdBorder( rItem );
1213 nWhich = GetWhich( SID_ATTR_PAGE_FOOTERSET );
1215 if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET )
1217 const SvxSetItem& rSetItem =
1218 (const SvxSetItem&)rSet.Get( nWhich, sal_False );
1219 const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1220 const SfxBoolItem& rOn =
1221 (const SfxBoolItem&)rTmpSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1223 if ( rOn.GetValue() )
1225 nWhich = GetWhich( SID_ATTR_BRUSH );
1227 if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1229 const SvxBrushItem& rItem =
1230 (const SvxBrushItem&)rTmpSet.Get( nWhich );
1231 m_pBspWin->SetFtColor( rItem.GetColor() );
1233 nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1235 if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1237 const SvxBoxItem& rItem =
1238 (const SvxBoxItem&)rTmpSet.Get( nWhich );
1239 m_pBspWin->SetFtBorder( rItem );
1244 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_BRUSH );
1246 if ( pItem )
1248 m_pBspWin->SetColor( ( (const SvxBrushItem*)pItem )->GetColor() );
1249 const Graphic* pGrf = ( (const SvxBrushItem*)pItem )->GetGraphic();
1251 if ( pGrf )
1253 Bitmap aBitmap = pGrf->GetBitmap();
1254 m_pBspWin->SetBitmap( &aBitmap );
1256 else
1257 m_pBspWin->SetBitmap( NULL );
1260 pItem = GetItem( rSet, SID_ATTR_BORDER_OUTER );
1262 if ( pItem )
1263 m_pBspWin->SetBorder( (SvxBoxItem&)*pItem );
1266 // -----------------------------------------------------------------------
1268 void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet )
1270 bLandscape = m_pLandscapeBtn->IsChecked();
1271 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
1273 if ( pItem )
1274 m_pBspWin->SetSize( ( (const SvxSizeItem*)pItem )->GetSize() );
1276 const SvxSetItem* pSetItem = 0;
1278 // evaluate header attributes
1280 if ( SFX_ITEM_SET ==
1281 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ),
1282 sal_False, (const SfxPoolItem**)&pSetItem ) )
1284 const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
1285 const SfxBoolItem& rHeaderOn =
1286 (const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1288 if ( rHeaderOn.GetValue() )
1290 const SvxSizeItem& rSize = (const SvxSizeItem&)
1291 rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
1292 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
1293 rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
1294 long nDist = rUL.GetLower();
1295 m_pBspWin->SetHdHeight( rSize.GetSize().Height() - nDist );
1296 m_pBspWin->SetHdDist( nDist );
1297 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
1298 rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
1299 m_pBspWin->SetHdLeft( rLR.GetLeft() );
1300 m_pBspWin->SetHdRight( rLR.GetRight() );
1301 m_pBspWin->SetHeader( sal_True );
1303 else
1304 m_pBspWin->SetHeader( sal_False );
1306 // show background and border in the example
1307 sal_uInt16 nWhich = GetWhich( SID_ATTR_BRUSH );
1309 if ( rHeaderSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1311 const SvxBrushItem& rItem =
1312 (const SvxBrushItem&)rHeaderSet.Get( nWhich );
1313 m_pBspWin->SetHdColor( rItem.GetColor() );
1315 nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1317 if ( rHeaderSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1319 const SvxBoxItem& rItem =
1320 (const SvxBoxItem&)rHeaderSet.Get( nWhich );
1321 m_pBspWin->SetHdBorder( rItem );
1325 // evaluate footer attributes
1327 if ( SFX_ITEM_SET ==
1328 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ),
1329 sal_False, (const SfxPoolItem**)&pSetItem ) )
1331 const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
1332 const SfxBoolItem& rFooterOn =
1333 (const SfxBoolItem&)rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1335 if ( rFooterOn.GetValue() )
1337 const SvxSizeItem& rSize = (const SvxSizeItem&)
1338 rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
1339 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
1340 rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
1341 long nDist = rUL.GetUpper();
1342 m_pBspWin->SetFtHeight( rSize.GetSize().Height() - nDist );
1343 m_pBspWin->SetFtDist( nDist );
1344 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
1345 rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
1346 m_pBspWin->SetFtLeft( rLR.GetLeft() );
1347 m_pBspWin->SetFtRight( rLR.GetRight() );
1348 m_pBspWin->SetFooter( sal_True );
1350 else
1351 m_pBspWin->SetFooter( sal_False );
1353 // show background and border in the example
1354 sal_uInt16 nWhich = GetWhich( SID_ATTR_BRUSH );
1356 if ( rFooterSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1358 const SvxBrushItem& rItem =
1359 (const SvxBrushItem&)rFooterSet.Get( nWhich );
1360 m_pBspWin->SetFtColor( rItem.GetColor() );
1362 nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1364 if ( rFooterSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1366 const SvxBoxItem& rItem =
1367 (const SvxBoxItem&)rFooterSet.Get( nWhich );
1368 m_pBspWin->SetFtBorder( rItem );
1373 // -----------------------------------------------------------------------
1375 void SvxPageDescPage::ActivatePage( const SfxItemSet& rSet )
1377 InitHeadFoot_Impl( rSet );
1378 ResetBackground_Impl( rSet );
1379 RangeHdl_Impl( 0 );
1382 // -----------------------------------------------------------------------
1384 int SvxPageDescPage::DeactivatePage( SfxItemSet* _pSet )
1386 // Inquiry whether the page margins are beyond the printing area.
1387 // If not, ask user whether they shall be taken.
1388 // If not, stay on the TabPage.
1389 sal_uInt16 nPos = m_pPaperSizeBox->GetSelectEntryPos();
1390 Paper ePaper = (Paper)(sal_uLong)m_pPaperSizeBox->GetEntryData( nPos );
1392 if ( ePaper != PAPER_SCREEN_4_3 && ePaper != PAPER_SCREEN_16_9 && ePaper != PAPER_SCREEN_16_10 && IsMarginOutOfRange() )
1394 if ( QueryBox( this, WB_YES_NO | WB_DEF_NO, m_pPrintRangeQueryText->GetText() ).Execute() == RET_NO )
1396 MetricField* pField = NULL;
1397 if ( IsPrinterRangeOverflow( *m_pLeftMarginEdit, nFirstLeftMargin, nLastLeftMargin, MARGIN_LEFT ) )
1398 pField = m_pLeftMarginEdit;
1399 if ( IsPrinterRangeOverflow( *m_pRightMarginEdit, nFirstRightMargin, nLastRightMargin, MARGIN_RIGHT )
1400 && !pField )
1401 pField = m_pRightMarginEdit;
1402 if ( IsPrinterRangeOverflow( *m_pTopMarginEdit, nFirstTopMargin, nLastTopMargin, MARGIN_TOP )
1403 && !pField )
1404 pField = m_pTopMarginEdit;
1405 if ( IsPrinterRangeOverflow( *m_pBottomMarginEdit, nFirstBottomMargin, nLastBottomMargin, MARGIN_BOTTOM )
1406 && !pField )
1407 pField = m_pBottomMarginEdit;
1408 if ( pField )
1409 pField->GrabFocus();
1410 UpdateExample_Impl();
1411 return KEEP_PAGE;
1413 else
1414 CheckMarginEdits( false );
1417 if ( _pSet )
1419 FillItemSet( *_pSet );
1421 // put portray/landscape if applicable
1422 sal_uInt16 nWh = GetWhich( SID_ATTR_PAGE_SIZE );
1423 SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWh );
1424 Size aSize( GetCoreValue( *m_pPaperWidthEdit, eUnit ),
1425 GetCoreValue( *m_pPaperHeightEdit, eUnit ) );
1427 // put, if current size is different to the value in _pSet
1428 const SvxSizeItem* pSize = (const SvxSizeItem*)GetItem( *_pSet, SID_ATTR_PAGE_SIZE );
1429 if ( aSize.Width() && ( !pSize || !IsEqualSize_Impl( pSize, aSize ) ) )
1430 _pSet->Put( SvxSizeItem( nWh, aSize ) );
1433 return LEAVE_PAGE;
1436 // -----------------------------------------------------------------------
1438 IMPL_LINK_NOARG(SvxPageDescPage, RangeHdl_Impl)
1440 // example window
1441 long nHHeight = m_pBspWin->GetHdHeight();
1442 long nHDist = m_pBspWin->GetHdDist();
1444 long nFHeight = m_pBspWin->GetFtHeight();
1445 long nFDist = m_pBspWin->GetFtDist();
1447 long nHFLeft = std::max( m_pBspWin->GetHdLeft(), m_pBspWin->GetFtLeft() );
1448 long nHFRight = std::max( m_pBspWin->GetHdRight(), m_pBspWin->GetFtRight() );
1450 // current values for page margins
1451 long nBT = static_cast<long>(m_pTopMarginEdit->Denormalize(m_pTopMarginEdit->GetValue(FUNIT_TWIP)));
1452 long nBB = static_cast<long>(m_pBottomMarginEdit->Denormalize(m_pBottomMarginEdit->GetValue(FUNIT_TWIP)));
1453 long nBL = static_cast<long>(m_pLeftMarginEdit->Denormalize(m_pLeftMarginEdit->GetValue(FUNIT_TWIP)));
1454 long nBR = static_cast<long>(m_pRightMarginEdit->Denormalize(m_pRightMarginEdit->GetValue(FUNIT_TWIP)));
1456 // calculate width of page border
1457 const SfxItemSet* _pSet = &GetItemSet();
1458 Size aBorder;
1460 if ( _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_SHADOW) ) >=
1461 SFX_ITEM_AVAILABLE &&
1462 _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_OUTER) ) >=
1463 SFX_ITEM_AVAILABLE )
1465 aBorder = ( GetMinBorderSpace_Impl(
1466 (const SvxShadowItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW)),
1467 (const SvxBoxItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER))));
1470 long nH = static_cast<long>(m_pPaperHeightEdit->Denormalize(m_pPaperHeightEdit->GetValue(FUNIT_TWIP)));
1471 long nW = static_cast<long>(m_pPaperWidthEdit->Denormalize(m_pPaperWidthEdit->GetValue(FUNIT_TWIP)));
1473 // limits paper
1474 // maximum is 54 cm
1476 long nMin = nHHeight + nHDist + nFDist + nFHeight + nBT + nBB +
1477 MINBODY + aBorder.Height();
1478 m_pPaperHeightEdit->SetMin(m_pPaperHeightEdit->Normalize(nMin), FUNIT_TWIP);
1480 nMin = MINBODY + nBL + nBR + aBorder.Width();
1481 m_pPaperWidthEdit->SetMin(m_pPaperWidthEdit->Normalize(nMin), FUNIT_TWIP);
1483 // if the paper size has been changed
1484 nH = static_cast<long>(m_pPaperHeightEdit->Denormalize(m_pPaperHeightEdit->GetValue(FUNIT_TWIP)));
1485 nW = static_cast<long>(m_pPaperWidthEdit->Denormalize(m_pPaperWidthEdit->GetValue(FUNIT_TWIP)));
1487 // Top
1488 long nMax = nH - nBB - aBorder.Height() - MINBODY -
1489 nFDist - nFHeight - nHDist - nHHeight;
1491 m_pTopMarginEdit->SetMax(m_pTopMarginEdit->Normalize(nMax), FUNIT_TWIP);
1493 // Bottom
1494 nMax = nH - nBT - aBorder.Height() - MINBODY -
1495 nFDist - nFHeight - nHDist - nHHeight;
1497 m_pBottomMarginEdit->SetMax(m_pTopMarginEdit->Normalize(nMax), FUNIT_TWIP);
1499 // Left
1500 nMax = nW - nBR - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1501 m_pLeftMarginEdit->SetMax(m_pLeftMarginEdit->Normalize(nMax), FUNIT_TWIP);
1503 // Right
1504 nMax = nW - nBL - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1505 m_pRightMarginEdit->SetMax(m_pRightMarginEdit->Normalize(nMax), FUNIT_TWIP);
1506 return 0;
1509 // -----------------------------------------------------------------------
1511 void SvxPageDescPage::CalcMargin_Impl()
1513 // current values for page margins
1514 long nBT = GetCoreValue( *m_pTopMarginEdit, SFX_MAPUNIT_TWIP );
1515 long nBB = GetCoreValue( *m_pBottomMarginEdit, SFX_MAPUNIT_TWIP );
1517 long nBL = GetCoreValue( *m_pLeftMarginEdit, SFX_MAPUNIT_TWIP );
1518 long nBR = GetCoreValue( *m_pRightMarginEdit, SFX_MAPUNIT_TWIP );
1520 long nH = GetCoreValue( *m_pPaperHeightEdit, SFX_MAPUNIT_TWIP );
1521 long nW = GetCoreValue( *m_pPaperWidthEdit, SFX_MAPUNIT_TWIP );
1523 long nWidth = nBL + nBR + MINBODY;
1524 long nHeight = nBT + nBB + MINBODY;
1526 if ( nWidth > nW || nHeight > nH )
1528 if ( nWidth > nW )
1530 long nTmp = nBL <= nBR ? nBR : nBL;
1531 nTmp -= nWidth - nW;
1533 if ( nBL <= nBR )
1534 SetMetricValue( *m_pRightMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1535 else
1536 SetMetricValue( *m_pLeftMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1539 if ( nHeight > nH )
1541 long nTmp = nBT <= nBB ? nBB : nBT;
1542 nTmp -= nHeight - nH;
1544 if ( nBT <= nBB )
1545 SetMetricValue( *m_pBottomMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1546 else
1547 SetMetricValue( *m_pTopMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1552 // -----------------------------------------------------------------------
1554 IMPL_LINK_NOARG_INLINE_START(SvxPageDescPage, CenterHdl_Impl)
1556 m_pBspWin->SetHorz( m_pHorzBox->IsChecked() );
1557 m_pBspWin->SetVert( m_pVertBox->IsChecked() );
1558 UpdateExample_Impl();
1559 return 0;
1561 IMPL_LINK_NOARG_INLINE_END(SvxPageDescPage, CenterHdl_Impl)
1563 // -----------------------------------------------------------------------
1565 void SvxPageDescPage::SetCollectionList(const std::vector<String> &aList)
1567 OSL_ENSURE(!aList.empty(), "Empty string list");
1569 sStandardRegister = aList[0];
1570 for( sal_uInt16 i = 1; i < aList.size(); i++ )
1571 m_pRegisterLB->InsertEntry(aList[i]);
1573 m_pRegisterCB->Show();
1574 m_pRegisterFT->Show();
1575 m_pRegisterLB->Show();
1576 m_pRegisterCB->SetClickHdl(LINK(this, SvxPageDescPage, RegisterModify));
1579 // -----------------------------------------------------------------------
1581 IMPL_LINK( SvxPageDescPage, RegisterModify, CheckBox*, pBox )
1583 sal_Bool bEnable = sal_False;
1584 if(pBox->IsChecked())
1586 bEnable = sal_True;
1587 if(USHRT_MAX == m_pRegisterLB->GetSelectEntryPos())
1588 m_pRegisterLB->SelectEntry(sStandardRegister);
1590 m_pRegisterFT->Enable( bEnable );
1591 m_pRegisterLB->Enable( bEnable );
1592 return 0;
1595 // ----------------------------------------------------------------------------
1597 void SvxPageDescPage::DisableVerticalPageDir()
1599 m_pTextFlowBox->RemoveEntryValue( FRMDIR_VERT_TOP_RIGHT );
1600 m_pTextFlowBox->RemoveEntryValue( FRMDIR_VERT_TOP_LEFT );
1601 if( m_pTextFlowBox->GetEntryCount() < 2 )
1603 m_pTextFlowLbl->Hide();
1604 m_pTextFlowBox->Hide();
1605 m_pBspWin->EnableFrameDirection( sal_False );
1609 IMPL_LINK( SvxPageDescPage, FrameDirectionModify_Impl, ListBox*, EMPTYARG)
1611 m_pBspWin->SetFrameDirection( (sal_uInt32) m_pTextFlowBox->GetSelectEntryValue() );
1612 m_pBspWin->Invalidate();
1613 return 0;
1616 bool SvxPageDescPage::IsPrinterRangeOverflow(
1617 MetricField& rField, long nFirstMargin, long nLastMargin, MarginPosition nPos )
1619 bool bRet = false;
1620 bool bCheck = ( ( pImpl->m_nPos & nPos ) == 0 );
1621 long nValue = static_cast<long>(rField.GetValue());
1622 if ( bCheck &&
1623 ( nValue < nFirstMargin || nValue > nLastMargin ) &&
1624 rField.GetText() != rField.GetSavedValue() )
1626 rField.SetValue( nValue < nFirstMargin ? nFirstMargin : nLastMargin );
1627 bRet = true;
1630 return bRet;
1633 /** Check if a value of a margin edit is outside the printer paper margins
1634 and save this information.
1636 void SvxPageDescPage::CheckMarginEdits( bool _bClear )
1638 if ( _bClear )
1639 pImpl->m_nPos = 0;
1641 sal_Int64 nValue = m_pLeftMarginEdit->GetValue();
1642 if ( nValue < nFirstLeftMargin || nValue > nLastLeftMargin )
1643 pImpl->m_nPos |= MARGIN_LEFT;
1644 nValue = m_pRightMarginEdit->GetValue();
1645 if ( nValue < nFirstRightMargin || nValue > nLastRightMargin )
1646 pImpl->m_nPos |= MARGIN_RIGHT;
1647 nValue = m_pTopMarginEdit->GetValue();
1648 if ( nValue < nFirstTopMargin || nValue > nLastTopMargin )
1649 pImpl->m_nPos |= MARGIN_TOP;
1650 nValue = m_pBottomMarginEdit->GetValue();
1651 if ( nValue < nFirstBottomMargin || nValue > nLastBottomMargin )
1652 pImpl->m_nPos |= MARGIN_BOTTOM;
1655 bool SvxPageDescPage::IsMarginOutOfRange()
1657 bool bRet = ( ( ( !( pImpl->m_nPos & MARGIN_LEFT ) &&
1658 ( m_pLeftMarginEdit->GetText() != m_pLeftMarginEdit->GetSavedValue() ) ) &&
1659 ( m_pLeftMarginEdit->GetValue() < nFirstLeftMargin ||
1660 m_pLeftMarginEdit->GetValue() > nLastLeftMargin ) ) ||
1661 ( ( !( pImpl->m_nPos & MARGIN_RIGHT ) &&
1662 ( m_pRightMarginEdit->GetText() != m_pRightMarginEdit->GetSavedValue() ) ) &&
1663 ( m_pRightMarginEdit->GetValue() < nFirstRightMargin ||
1664 m_pRightMarginEdit->GetValue() > nLastRightMargin ) ) ||
1665 ( ( !( pImpl->m_nPos & MARGIN_TOP ) &&
1666 ( m_pTopMarginEdit->GetText() != m_pTopMarginEdit->GetSavedValue() ) ) &&
1667 ( m_pTopMarginEdit->GetValue() < nFirstTopMargin ||
1668 m_pTopMarginEdit->GetValue() > nLastTopMargin ) ) ||
1669 ( ( !( pImpl->m_nPos & MARGIN_BOTTOM ) &&
1670 ( m_pBottomMarginEdit->GetText() != m_pBottomMarginEdit->GetSavedValue() ) ) &&
1671 ( m_pBottomMarginEdit->GetValue() < nFirstBottomMargin ||
1672 m_pBottomMarginEdit->GetValue() > nLastBottomMargin ) ) );
1673 return bRet;
1676 void SvxPageDescPage::PageCreated (SfxAllItemSet aSet)
1678 SFX_ITEMSET_ARG (&aSet,pModeItem,SfxAllEnumItem,SID_ENUM_PAGE_MODE,sal_False);
1679 SFX_ITEMSET_ARG (&aSet,pPaperStartItem,SfxAllEnumItem,SID_PAPER_START,sal_False);
1680 SFX_ITEMSET_ARG (&aSet,pPaperEndItem,SfxAllEnumItem,SID_PAPER_END,sal_False);
1681 SFX_ITEMSET_ARG (&aSet,pCollectListItem,SfxStringListItem,SID_COLLECT_LIST,sal_False);
1682 if (pModeItem)
1683 SetMode((SvxModeType)pModeItem->GetEnumValue());
1684 if (pPaperStartItem && pPaperEndItem)
1685 SetPaperFormatRanges( (Paper)pPaperStartItem->GetEnumValue(), (Paper)pPaperEndItem->GetEnumValue() );
1686 if (pCollectListItem)
1687 SetCollectionList(pCollectListItem->GetList());
1690 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */