merge the formfield patch from ooo-build
[ooovba.git] / svx / source / cui / page.cxx
blob2ebbf8bcde5bef68b455044a27cb24c43696a905
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: page.cxx,v $
10 * $Revision: 1.42 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
38 // include ---------------------------------------------------------------
49 #include <sfx2/app.hxx>
50 #include <sfx2/objsh.hxx>
51 #ifndef _RESARY_HXX //autogen
52 #include <tools/resary.hxx>
53 #endif
54 #ifndef _GRAPH_HXX //autogen
55 #include <vcl/graph.hxx>
56 #endif
57 #include <sfx2/viewsh.hxx>
58 #include <svtools/itemiter.hxx>
59 #include <svtools/languageoptions.hxx>
60 #include <vcl/msgbox.hxx>
61 #include <unotools/configitem.hxx>
62 #include "htmlmode.hxx"
64 #define _SVX_PAGE_CXX
66 #include <svx/dialogs.hrc>
67 #include "page.hrc"
68 #include "helpid.hrc"
74 #include "page.hxx"
75 #include <svx/pageitem.hxx>
76 #include <svx/brshitem.hxx>
77 #include <svx/boxitem.hxx>
78 #include <svx/shaditem.hxx>
79 #include <svx/pbinitem.hxx>
80 #include <svx/lrspitem.hxx>
81 #include <svx/ulspitem.hxx>
82 #include <svx/sizeitem.hxx>
83 #include <svx/frmdiritem.hxx>
84 //CHINA001 #include "bbdlg.hxx"
85 #include "dlgutil.hxx"
86 #include <svx/dialmgr.hxx>
87 #include <svx/paperinf.hxx>
88 #include <svx/dialmgr.hxx>
89 #include <sfx2/module.hxx>
92 #include <svtools/stritem.hxx>
94 #include <svx/svxids.hrc> //CHINA001
96 // #i4219#
97 #include <svtools/optionsdrawinglayer.hxx>
98 #include <svtools/slstitm.hxx> //CHINA001
99 #include <svtools/aeitem.hxx> //CHINA001
100 #include <sfx2/request.hxx> //CHINA001
101 // configuration helper =======================================================
103 /** Helper to get a configuration setting.
104 @descr This is a HACK to get a configuration item directly. Normally the
105 OfaHtmlOptions class from 'offmgr' project would do the job, but we cannot
106 use it here. On the other hand, the OfaHtmlOptions cannot be moved to
107 'svtools', because it uses 'svx' itself...
108 The correct way would be to move OfaHtmlOptions to 'svtools' anyway, and to
109 remove the dependency from 'svx' (a call to the static function
110 SvxTextEncodingBox::GetBestMimeEncoding(), which contains low level
111 operations that can be moved to lower projects, i.e. 'rtl'). Then this
112 class can be removed, and the OfaHtmlOptions can be used instead. */
113 class SvxHtmlExportModeConfigItem_Impl : public utl::ConfigItem
115 public:
116 explicit SvxHtmlExportModeConfigItem_Impl();
118 /** Returns the HTML export mode, as read from the configuration. */
119 inline sal_Int32 GetExportMode() const { return mnExpMode; }
121 /** Returns true, if the current HTML export mode is set to HTML 3.2. */
122 inline bool IsExportModeHTML32() const { return mnExpMode == 0; } // 0 == HTML_CFG_HTML32, see offmgr/htmlcfg.hxx
124 private:
125 sal_Int32 mnExpMode;
128 SvxHtmlExportModeConfigItem_Impl::SvxHtmlExportModeConfigItem_Impl() :
129 utl::ConfigItem( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/HTML/Export" ) ) ),
130 mnExpMode( 3 ) // default to 3 == HTML_CFG_NS40, see offmgr/htmlcfg.hxx
132 using com::sun::star::uno::Sequence;
133 using com::sun::star::uno::Any;
135 Sequence< rtl::OUString > aPropNames( 1 );
136 aPropNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Browser" ) );
137 Sequence< Any > aPropValues( GetProperties( aPropNames ) );
138 if( aPropValues.getLength() == 1 )
139 aPropValues[ 0 ] >>= mnExpMode;
143 // static ----------------------------------------------------------------
145 static const long MINBODY = 284; // 0,5cm in twips aufgerundet
146 //static const long PRINT_OFFSET = 17; // 0,03cm in twips abgerundet
147 static const long PRINT_OFFSET = 0; // why was this ever set to 17 ? it led to wrong right and bottom margins.
149 static USHORT pRanges[] =
151 SID_ATTR_BORDER_OUTER,
152 SID_ATTR_BORDER_SHADOW,
153 SID_ATTR_LRSPACE,
154 SID_ATTR_PAGE_SHARED,
155 SID_SWREGISTER_COLLECTION,
156 SID_SWREGISTER_MODE,
160 // ------- Mapping Seitenlayout ------------------------------------------
162 USHORT aArr[] =
164 SVX_PAGE_ALL,
165 SVX_PAGE_MIRROR,
166 SVX_PAGE_RIGHT,
167 SVX_PAGE_LEFT
170 // -----------------------------------------------------------------------
172 USHORT PageUsageToPos_Impl( USHORT nUsage )
174 const USHORT nCount = sizeof(aArr) / sizeof(USHORT);
176 for ( USHORT i = 0; i < nCount; ++i )
177 if ( aArr[i] == ( nUsage & 0x000f ) )
178 return i;
179 return SVX_PAGE_ALL;
182 // -----------------------------------------------------------------------
184 USHORT PosToPageUsage_Impl( USHORT nPos )
186 const USHORT nCount = sizeof(aArr) / sizeof(USHORT);
188 if ( nPos >= nCount )
189 return 0;
190 return aArr[nPos];
193 // -----------------------------------------------------------------------
195 Size GetMinBorderSpace_Impl( const SvxShadowItem& rShadow, const SvxBoxItem& rBox )
197 Size aSz;
198 aSz.Height() = rShadow.CalcShadowSpace( SHADOW_BOTTOM ) + rBox.CalcLineSpace( BOX_LINE_BOTTOM );
199 aSz.Height() += rShadow.CalcShadowSpace( SHADOW_TOP ) + rBox.CalcLineSpace( BOX_LINE_TOP );
200 aSz.Width() = rShadow.CalcShadowSpace( SHADOW_LEFT ) + rBox.CalcLineSpace( BOX_LINE_LEFT );
201 aSz.Width() += rShadow.CalcShadowSpace( SHADOW_RIGHT ) + rBox.CalcLineSpace( BOX_LINE_RIGHT );
202 return aSz;
205 // -----------------------------------------------------------------------
207 long ConvertLong_Impl( const long nIn, SfxMapUnit eUnit )
209 return OutputDevice::LogicToLogic( nIn, (MapUnit)eUnit, MAP_TWIP );
212 BOOL IsEqualSize_Impl( const SvxSizeItem* pSize, const Size& rSize )
214 if ( pSize )
216 Size aSize = pSize->GetSize();
217 long nDiffW = Abs( rSize.Width () - aSize.Width () );
218 long nDiffH = Abs( rSize.Height() - aSize.Height() );
219 return ( nDiffW < 10 && nDiffH < 10 );
221 else
222 return FALSE;
225 // -----------------------------------------------------------------------
227 #define MARGIN_LEFT ( (MarginPosition)0x0001 )
228 #define MARGIN_RIGHT ( (MarginPosition)0x0002 )
229 #define MARGIN_TOP ( (MarginPosition)0x0004 )
230 #define MARGIN_BOTTOM ( (MarginPosition)0x0008 )
232 struct SvxPage_Impl
234 MarginPosition m_nPos;
235 Printer* mpDefPrinter;
236 bool mbDelPrinter;
238 SvxPage_Impl() :
239 m_nPos( 0 ),
240 mpDefPrinter( 0 ),
241 mbDelPrinter( false ) {}
243 ~SvxPage_Impl() { if ( mbDelPrinter ) delete mpDefPrinter; }
246 // class SvxPageDescPage --------------------------------------------------
248 // gibt den Bereich der Which-Werte zur"uck
250 USHORT* SvxPageDescPage::GetRanges()
252 return pRanges;
255 // -----------------------------------------------------------------------
257 SfxTabPage* SvxPageDescPage::Create( Window* pParent, const SfxItemSet& rSet )
259 return new SvxPageDescPage( pParent, rSet );
262 // -----------------------------------------------------------------------
264 SvxPageDescPage::SvxPageDescPage( Window* pParent, const SfxItemSet& rAttr ) :
266 SfxTabPage( pParent, SVX_RES( RID_SVXPAGE_PAGE ), rAttr ),
268 aPaperSizeFl ( this, SVX_RES( FL_PAPER_SIZE ) ),
269 aPaperFormatText ( this, SVX_RES( FT_PAPER_FORMAT ) ),
270 aPaperSizeBox ( this, SVX_RES( LB_PAPER_SIZE ) ),
271 aPaperWidthText ( this, SVX_RES( FT_PAPER_WIDTH ) ),
272 aPaperWidthEdit ( this, SVX_RES( ED_PAPER_WIDTH ) ),
273 aPaperHeightText ( this, SVX_RES( FT_PAPER_HEIGHT ) ),
274 aPaperHeightEdit ( this, SVX_RES( ED_PAPER_HEIGHT ) ),
275 aOrientationFT ( this, SVX_RES( FT_ORIENTATION ) ),
276 aPortraitBtn ( this, SVX_RES( RB_PORTRAIT ) ),
277 aLandscapeBtn ( this, SVX_RES( RB_LANDSCAPE ) ),
278 aBspWin ( this, SVX_RES( WN_BSP ) ),
279 aTextFlowLbl ( this, SVX_RES( FT_TEXT_FLOW ) ),
280 aTextFlowBox ( this, SVX_RES( LB_TEXT_FLOW ) ),
281 aPaperTrayLbl ( this, SVX_RES( FT_PAPER_TRAY ) ),
282 aPaperTrayBox ( this, SVX_RES( LB_PAPER_TRAY ) ),
283 aMarginFl ( this, SVX_RES( FL_MARGIN ) ),
284 aLeftMarginLbl ( this, SVX_RES( FT_LEFT_MARGIN ) ),
285 aLeftMarginEdit ( this, SVX_RES( ED_LEFT_MARGIN ) ),
286 aRightMarginLbl ( this, SVX_RES( FT_RIGHT_MARGIN ) ),
287 aRightMarginEdit ( this, SVX_RES( ED_RIGHT_MARGIN ) ),
288 aTopMarginLbl ( this, SVX_RES( FT_TOP_MARGIN ) ),
289 aTopMarginEdit ( this, SVX_RES( ED_TOP_MARGIN ) ),
290 aBottomMarginLbl ( this, SVX_RES( FT_BOTTOM_MARGIN ) ),
291 aBottomMarginEdit ( this, SVX_RES( ED_BOTTOM_MARGIN ) ),
293 aLayoutFL ( this, SVX_RES( FL_LAYOUT ) ),
294 aPageText ( this, SVX_RES( FT_PAGELAYOUT ) ),
295 aLayoutBox ( this, SVX_RES( LB_LAYOUT ) ),
296 aNumberFormatText ( this, SVX_RES( FT_NUMBER_FORMAT ) ),
297 aNumberFormatBox ( this, SVX_RES( LB_NUMBER_FORMAT ) ),
298 aBottomSeparatorFl ( this, SVX_RES( FL_BOTTOM_SEP ) ),
299 aTblAlignFT ( this, SVX_RES( FT_TBL_ALIGN ) ),
300 aHorzBox ( this, SVX_RES( CB_HORZ ) ),
301 aVertBox ( this, SVX_RES( CB_VERT ) ),
302 aAdaptBox ( this, SVX_RES( CB_ADAPT ) ),
303 aRegisterCB ( this, SVX_RES( CB_REGISTER ) ),
304 aRegisterFT ( this, SVX_RES( FT_REGISTER ) ),
305 aRegisterLB ( this, SVX_RES( LB_REGISTER ) ),
307 aInsideText ( SVX_RES( STR_INSIDE ) ),
308 aOutsideText ( SVX_RES( STR_OUTSIDE ) ),
309 aPrintRangeQueryText( SVX_RES( STR_QUERY_PRINTRANGE ) ),
311 bLandscape ( FALSE ),
312 eMode ( SVX_PAGE_MODE_STANDARD ),
313 ePaperStart ( PAPER_A3 ),
314 ePaperEnd ( PAPER_ENV_DL ),
315 pImpl ( new SvxPage_Impl )
318 bBorderModified = FALSE;
319 FreeResource();
320 aBspWin.EnableRTL( FALSE );
322 // diese Page braucht ExchangeSupport
323 SetExchangeSupport();
325 SvtLanguageOptions aLangOptions;
326 sal_Bool bCJK = aLangOptions.IsAsianTypographyEnabled();
327 sal_Bool bCTL = aLangOptions.IsCTLFontEnabled();
328 sal_Bool bWeb = sal_False;
329 const SfxPoolItem* pItem;
331 SfxObjectShell* pShell;
332 if(SFX_ITEM_SET == rAttr.GetItemState(SID_HTML_MODE, FALSE, &pItem) ||
333 ( 0 != (pShell = SfxObjectShell::Current()) &&
334 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
335 bWeb = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
337 // #109989# get the HTML export setting from configuration.
338 // !! This is a hack, see comments in SvxHtmlExportModeConfigItem_Impl class above.
339 bool bHTML32 = SvxHtmlExportModeConfigItem_Impl().IsExportModeHTML32();
341 // fill text flow listbox with valid entries
342 aTextFlowBox.InsertEntryValue( SVX_RESSTR( RID_SVXSTR_PAGEDIR_LTR_HORI ), FRMDIR_HORI_LEFT_TOP );
343 if( bCTL )
344 aTextFlowBox.InsertEntryValue( SVX_RESSTR( RID_SVXSTR_PAGEDIR_RTL_HORI ), FRMDIR_HORI_RIGHT_TOP );
345 // #109989# do not show vertical directions in Writer/Web
346 if( !bWeb )
348 if( bCJK )
349 aTextFlowBox.InsertEntryValue( SVX_RESSTR( RID_SVXSTR_PAGEDIR_RTL_VERT ), FRMDIR_VERT_TOP_RIGHT );
350 // if( ... )
351 // aTextFlowBox.InsertEntryValue( SVX_RESSTR( RID_SVXSTR_PAGEDIR_LTR_VERT ), FRMDIR_VERT_TOP_LEFT );
354 // #109989# show the text direction box in Writer/Web too, but only, if HTML export mode is not HTML3.2.
355 if( !(bWeb && bHTML32) && (bCJK || bCTL) &&
356 SFX_ITEM_UNKNOWN < rAttr.GetItemState(GetWhich( SID_ATTR_FRAMEDIRECTION )))
358 aTextFlowLbl.Show();
359 aTextFlowBox.Show();
360 aTextFlowBox.SetSelectHdl(LINK(this, SvxPageDescPage, FrameDirectionModify_Impl ));
362 aBspWin.EnableFrameDirection(sal_True);
364 Init_Impl();
366 FieldUnit eFUnit = GetModuleFieldUnit( &rAttr );
367 SetFieldUnit( aLeftMarginEdit, eFUnit );
368 SetFieldUnit( aRightMarginEdit, eFUnit );
369 SetFieldUnit( aTopMarginEdit, eFUnit );
370 SetFieldUnit( aBottomMarginEdit, eFUnit );
371 SetFieldUnit( aPaperWidthEdit, eFUnit );
372 SetFieldUnit( aPaperHeightEdit, eFUnit );
374 if ( SfxViewShell::Current() && SfxViewShell::Current()->GetPrinter() )
375 pImpl->mpDefPrinter = (Printer*)SfxViewShell::Current()->GetPrinter();
376 else
378 pImpl->mpDefPrinter = new Printer;
379 pImpl->mbDelPrinter = true;
382 MapMode aOldMode = pImpl->mpDefPrinter->GetMapMode();
383 pImpl->mpDefPrinter->SetMapMode( MAP_TWIP );
385 // First- und Last-Werte f"ur die R"ander setzen
386 Size aPaperSize = pImpl->mpDefPrinter->GetPaperSize();
387 Size aPrintSize = pImpl->mpDefPrinter->GetOutputSize();
389 * einen Punkt ( 0,0 ) in logische Koordinaten zu konvertieren,
390 * sieht aus wie Unsinn; ist aber sinnvoll, wenn der Ursprung des
391 * Koordinatensystems verschoben ist.
393 Point aPrintOffset = pImpl->mpDefPrinter->GetPageOffset() -
394 pImpl->mpDefPrinter->PixelToLogic( Point() );
395 pImpl->mpDefPrinter->SetMapMode( aOldMode );
397 long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET;
398 aLeftMarginEdit.SetFirst( aLeftMarginEdit.Normalize( aPrintOffset.X() ), FUNIT_TWIP );
399 nFirstLeftMargin = static_cast<long>(aLeftMarginEdit.GetFirst());
400 aRightMarginEdit.SetFirst( aRightMarginEdit.Normalize(
401 aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset ), FUNIT_TWIP);
402 nFirstRightMargin = static_cast<long>(aRightMarginEdit.GetFirst());
403 aTopMarginEdit.SetFirst( aTopMarginEdit.Normalize( aPrintOffset.Y() ), FUNIT_TWIP );
404 nFirstTopMargin = static_cast<long>(aTopMarginEdit.GetFirst());
405 aBottomMarginEdit.SetFirst( aBottomMarginEdit.Normalize(
406 aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset ), FUNIT_TWIP );
407 nFirstBottomMargin = static_cast<long>(aBottomMarginEdit.GetFirst());
408 aLeftMarginEdit.SetLast( aLeftMarginEdit.Normalize(
409 aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP );
410 nLastLeftMargin = static_cast<long>(aLeftMarginEdit.GetLast());
411 aRightMarginEdit.SetLast( aRightMarginEdit.Normalize(
412 aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP );
413 nLastRightMargin = static_cast<long>(aRightMarginEdit.GetLast());
414 aTopMarginEdit.SetLast( aTopMarginEdit.Normalize(
415 aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP );
416 nLastTopMargin = static_cast<long>(aTopMarginEdit.GetLast());
417 aBottomMarginEdit.SetLast( aBottomMarginEdit.Normalize(
418 aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP );
419 nLastBottomMargin = static_cast<long>(aBottomMarginEdit.GetLast());
421 // #i4219# get DrawingLayer options
422 const SvtOptionsDrawinglayer aDrawinglayerOpt;
424 // #i4219# take Maximum now from configuration (1/100th cm)
425 // was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000
426 aPaperWidthEdit.SetMax(aPaperWidthEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
427 aPaperWidthEdit.SetLast(aPaperWidthEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
428 aPaperHeightEdit.SetMax(aPaperHeightEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
429 aPaperHeightEdit.SetLast(aPaperHeightEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
431 // #i4219# also for margins (1/100th cm). Was: 9999, keeping.
432 aLeftMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperLeftMargin());
433 aLeftMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperLeftMargin());
434 aRightMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperRightMargin());
435 aRightMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperRightMargin());
436 aTopMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperTopMargin());
437 aTopMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperTopMargin());
438 aBottomMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperBottomMargin());
439 aBottomMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperBottomMargin());
442 // -----------------------------------------------------------------------
444 SvxPageDescPage::~SvxPageDescPage()
446 delete pImpl;
449 // -----------------------------------------------------------------------
451 void SvxPageDescPage::Init_Impl()
453 aLeftText = aLeftMarginLbl.GetText();
454 aRightText = aRightMarginLbl.GetText();
456 // Handler einstellen
457 aLayoutBox.SetSelectHdl( LINK( this, SvxPageDescPage, LayoutHdl_Impl ) );
458 aPaperSizeBox.SetDropDownLineCount(10);
460 aPaperTrayBox.SetGetFocusHdl(
461 LINK( this, SvxPageDescPage, PaperBinHdl_Impl ) );
462 aPaperSizeBox.SetSelectHdl(
463 LINK( this, SvxPageDescPage, PaperSizeSelect_Impl ) );
464 aPaperWidthEdit.SetModifyHdl(
465 LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) );
466 aPaperHeightEdit.SetModifyHdl(
467 LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) );
468 aLandscapeBtn.SetClickHdl(
469 LINK( this, SvxPageDescPage, SwapOrientation_Impl ) );
470 aPortraitBtn.SetClickHdl(
471 LINK( this, SvxPageDescPage, SwapOrientation_Impl ) );
473 Link aLink = LINK( this, SvxPageDescPage, BorderModify_Impl );
474 aLeftMarginEdit.SetModifyHdl( aLink );
475 aRightMarginEdit.SetModifyHdl( aLink );
476 aTopMarginEdit.SetModifyHdl( aLink );
477 aBottomMarginEdit.SetModifyHdl( aLink );
479 aLink = LINK( this, SvxPageDescPage, RangeHdl_Impl );
480 aPaperWidthEdit.SetLoseFocusHdl( aLink );
481 aPaperHeightEdit.SetLoseFocusHdl( aLink );
482 aLeftMarginEdit.SetLoseFocusHdl( aLink );
483 aRightMarginEdit.SetLoseFocusHdl( aLink );
484 aTopMarginEdit.SetLoseFocusHdl( aLink );
485 aBottomMarginEdit.SetLoseFocusHdl( aLink );
487 aHorzBox.SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) );
488 aVertBox.SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) );
492 // -----------------------------------------------------------------------
494 void SvxPageDescPage::Reset( const SfxItemSet& rSet )
496 SfxItemPool* pPool = rSet.GetPool();
497 DBG_ASSERT( pPool, "Wo ist der Pool" );
498 SfxMapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) );
500 // R"ander (Links/Rechts) einstellen
501 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_LRSPACE );
503 if ( pItem )
505 const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)*pItem;
506 SetMetricValue( aLeftMarginEdit, rLRSpace.GetLeft(), eUnit );
507 aBspWin.SetLeft(
508 (USHORT)ConvertLong_Impl( (long)rLRSpace.GetLeft(), eUnit ) );
509 SetMetricValue( aRightMarginEdit, rLRSpace.GetRight(), eUnit );
510 aBspWin.SetRight(
511 (USHORT)ConvertLong_Impl( (long)rLRSpace.GetRight(), eUnit ) );
514 // R"ander (Oben/Unten) einstellen
515 pItem = GetItem( rSet, SID_ATTR_ULSPACE );
517 if ( pItem )
519 const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)*pItem;
520 SetMetricValue( aTopMarginEdit, rULSpace.GetUpper(), eUnit );
521 aBspWin.SetTop(
522 (USHORT)ConvertLong_Impl( (long)rULSpace.GetUpper(), eUnit ) );
523 SetMetricValue( aBottomMarginEdit, rULSpace.GetLower(), eUnit );
524 aBspWin.SetBottom(
525 (USHORT)ConvertLong_Impl( (long)rULSpace.GetLower(), eUnit ) );
528 // allgemeine Seitendaten
529 SvxNumType eNumType = SVX_ARABIC;
530 bLandscape = ( pImpl->mpDefPrinter->GetOrientation() == ORIENTATION_LANDSCAPE );
531 USHORT nUse = (USHORT)SVX_PAGE_ALL;
532 pItem = GetItem( rSet, SID_ATTR_PAGE );
534 if ( pItem )
536 const SvxPageItem& rItem = (const SvxPageItem&)*pItem;
537 eNumType = rItem.GetNumType();
538 nUse = rItem.GetPageUsage();
539 bLandscape = rItem.IsLandscape();
542 // Ausrichtung
543 aLayoutBox.SelectEntryPos( ::PageUsageToPos_Impl( nUse ) );
544 aBspWin.SetUsage( nUse );
545 LayoutHdl_Impl( 0 );
547 // Numerierungsart der Seitenvorlage einstellen
548 aNumberFormatBox.SelectEntryPos( sal::static_int_cast< USHORT >(eNumType) );
550 // Aktueller Papierschacht
551 aPaperTrayBox.Clear();
552 BYTE nPaperBin = PAPERBIN_PRINTER_SETTINGS;
553 pItem = GetItem( rSet, SID_ATTR_PAGE_PAPERBIN );
555 if ( pItem )
557 nPaperBin = ( (const SvxPaperBinItem*)pItem )->GetValue();
559 if ( nPaperBin >= pImpl->mpDefPrinter->GetPaperBinCount() )
560 nPaperBin = PAPERBIN_PRINTER_SETTINGS;
563 String aBinName;
565 if ( PAPERBIN_PRINTER_SETTINGS == nPaperBin )
566 aBinName = SVX_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS );
567 else
568 aBinName = pImpl->mpDefPrinter->GetPaperBinName( (USHORT)nPaperBin );
570 USHORT nEntryPos = aPaperTrayBox.InsertEntry( aBinName );
571 aPaperTrayBox.SetEntryData( nEntryPos, (void*)(ULONG)nPaperBin );
572 aPaperTrayBox.SelectEntry( aBinName );
574 // Size rausholen
575 Size aPaperSize = SvxPaperInfo::GetPaperSize( pImpl->mpDefPrinter );
576 pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
578 if ( pItem )
579 aPaperSize = ( (const SvxSizeItem*)pItem )->GetSize();
581 FASTBOOL bOrientationSupport =
582 pImpl->mpDefPrinter->HasSupport( SUPPORT_SET_ORIENTATION );
583 #ifdef OS2
584 // unter OS/2 wird bei HasSupport() immer TRUE returned
585 // aber nur als Dummy, deshalb FALSE
586 bOrientationSupport = FALSE;
587 #endif
589 if ( !bOrientationSupport &&
590 aPaperSize.Width() > aPaperSize.Height() )
591 bLandscape = TRUE;
593 aLandscapeBtn.Check( bLandscape );
594 aPortraitBtn.Check( !bLandscape );
596 aBspWin.SetSize( Size( ConvertLong_Impl( aPaperSize.Width(), eUnit ),
597 ConvertLong_Impl( aPaperSize.Height(), eUnit ) ) );
599 aPaperSize = OutputDevice::LogicToLogic(aPaperSize, (MapUnit)eUnit, MAP_100TH_MM);
600 if ( bLandscape )
601 Swap( aPaperSize );
603 // Actual Paper Format
604 Paper ePaper = SvxPaperInfo::GetSvxPaper( aPaperSize, MAP_100TH_MM, TRUE );
606 if ( PAPER_USER != ePaper )
607 aPaperSize = SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM );
609 if ( bLandscape )
610 Swap( aPaperSize );
612 // Werte in die Edits eintragen
613 SetMetricValue( aPaperHeightEdit, aPaperSize.Height(), SFX_MAPUNIT_100TH_MM );
614 SetMetricValue( aPaperWidthEdit, aPaperSize.Width(), SFX_MAPUNIT_100TH_MM );
615 aPaperSizeBox.Clear();
617 USHORT nActPos = LISTBOX_ENTRY_NOTFOUND;
618 USHORT nAryId = RID_SVXSTRARY_PAPERSIZE_STD;
620 if ( ePaperStart != PAPER_A3 )
621 nAryId = RID_SVXSTRARY_PAPERSIZE_DRAW;
622 ResStringArray aPaperAry( SVX_RES( nAryId ) );
623 sal_uInt32 nCnt = aPaperAry.Count();
625 for ( sal_uInt32 i = 0; i < nCnt; ++i )
627 String aStr = aPaperAry.GetString(i);
628 Paper eSize = (Paper)aPaperAry.GetValue(i);
629 USHORT nPos = aPaperSizeBox.InsertEntry( aStr );
630 aPaperSizeBox.SetEntryData( nPos, (void*)(ULONG)eSize );
632 if ( eSize == ePaper )
633 nActPos = nPos;
635 // aktuelles Papierformat selektieren
636 aPaperSizeBox.SelectEntryPos( nActPos );
638 // Applikationsspezifisch
640 switch ( eMode )
642 case SVX_PAGE_MODE_CENTER:
644 aTblAlignFT.Show();
645 aHorzBox.Show();
646 aVertBox.Show();
647 DisableVerticalPageDir();
649 // Horizontale Ausrichtung
650 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
651 aHorzBox.Check( pItem ? ( (const SfxBoolItem*)pItem )->GetValue()
652 : FALSE );
654 // Vertikale Ausrichtung
655 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 );
656 aVertBox.Check( pItem ? ( (const SfxBoolItem*)pItem )->GetValue()
657 : FALSE );
659 // Beispiel-Fenster auf Tabelle setzen
660 aBspWin.SetTable( TRUE );
661 aBspWin.SetHorz( aHorzBox.IsChecked() );
662 aBspWin.SetVert( aVertBox.IsChecked() );
664 break;
667 case SVX_PAGE_MODE_PRESENTATION:
669 DisableVerticalPageDir();
670 aAdaptBox.Show();
671 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
672 aAdaptBox.Check( pItem ?
673 ( (const SfxBoolItem*)pItem )->GetValue() : FALSE );
675 //!!! hidden, weil von StarDraw nicht implementiert
676 aLayoutBox.Hide();
677 aPageText.Hide();
679 break;
681 default: ;//prevent warning
685 // im Beispiel Hintergrund und Umrandung anzeigen
686 ResetBackground_Impl( rSet );
687 //! UpdateExample_Impl();
688 RangeHdl_Impl( 0 );
690 // Header Footer anzeigen
691 InitHeadFoot_Impl( rSet );
693 // R"ander auf Hoch/Quer updaten, dann Beispiel updaten
694 bBorderModified = FALSE;
695 SwapFirstValues_Impl( FALSE );
696 UpdateExample_Impl();
698 // Alte Werte sichern
699 aLeftMarginEdit.SaveValue();
700 aRightMarginEdit.SaveValue();
701 aTopMarginEdit.SaveValue();
702 aBottomMarginEdit.SaveValue();
703 aLayoutBox.SaveValue();
704 aNumberFormatBox.SaveValue();
705 aPaperSizeBox.SaveValue();
706 aPaperWidthEdit.SaveValue();
707 aPaperHeightEdit.SaveValue();
708 aPortraitBtn.SaveValue();
709 aLandscapeBtn.SaveValue();
710 aPaperTrayBox.SaveValue();
711 aVertBox.SaveValue();
712 aHorzBox.SaveValue();
713 aAdaptBox.SaveValue();
715 CheckMarginEdits( true );
717 // Registerhaltigkeit
718 if(SFX_ITEM_SET == rSet.GetItemState(SID_SWREGISTER_MODE))
720 aRegisterCB.Check(((const SfxBoolItem&)rSet.Get(
721 SID_SWREGISTER_MODE)).GetValue());
722 aRegisterCB.SaveValue();
723 RegisterModify(&aRegisterCB);
725 if(SFX_ITEM_SET == rSet.GetItemState(SID_SWREGISTER_COLLECTION))
727 aRegisterLB.SelectEntry(
728 ((const SfxStringItem&)rSet.Get(SID_SWREGISTER_COLLECTION)).GetValue());
729 aRegisterLB.SaveValue();
732 SfxItemState eState = rSet.GetItemState( GetWhich( SID_ATTR_FRAMEDIRECTION ),
733 TRUE, &pItem );
734 if( SFX_ITEM_UNKNOWN != eState )
736 sal_uInt32 nVal = SFX_ITEM_SET == eState
737 ? ((SvxFrameDirectionItem*)pItem)->GetValue()
738 : 0;
739 aTextFlowBox.SelectEntryValue( static_cast< SvxFrameDirection >( nVal ) );
740 aTextFlowBox.SaveValue();
741 aBspWin.SetFrameDirection(nVal);
745 // -----------------------------------------------------------------------
747 void SvxPageDescPage::FillUserData()
749 if ( SVX_PAGE_MODE_PRESENTATION == eMode )
750 SetUserData( UniString::CreateFromInt32( (sal_Int32)aAdaptBox.IsChecked() ) );
753 // -----------------------------------------------------------------------
755 BOOL SvxPageDescPage::FillItemSet( SfxItemSet& rSet )
757 BOOL bModified = FALSE;
758 const SfxItemSet& rOldSet = GetItemSet();
759 SfxItemPool* pPool = rOldSet.GetPool();
760 DBG_ASSERT( pPool, "Wo ist der Pool" );
761 USHORT nWhich = GetWhich( SID_ATTR_LRSPACE );
762 SfxMapUnit eUnit = pPool->GetMetric( nWhich );
763 const SfxPoolItem* pOld = 0;
765 // alten linken und rechten Rand kopieren
766 SvxLRSpaceItem aMargin( (const SvxLRSpaceItem&)rOldSet.Get( nWhich ) );
768 // alten oberen und unteren Rand kopieren
769 nWhich = GetWhich( SID_ATTR_ULSPACE );
770 SvxULSpaceItem aTopMargin( (const SvxULSpaceItem&)rOldSet.Get( nWhich ) );
772 if ( aLeftMarginEdit.GetText() != aLeftMarginEdit.GetSavedValue() )
774 aMargin.SetLeft( (USHORT)GetCoreValue( aLeftMarginEdit, eUnit ) );
775 bModified |= TRUE;
778 if ( aRightMarginEdit.GetText() != aRightMarginEdit.GetSavedValue() )
780 aMargin.SetRight( (USHORT)GetCoreValue( aRightMarginEdit, eUnit ) );
781 bModified |= TRUE;
784 // Linken und rechten Rand setzen
785 if ( bModified )
787 pOld = GetOldItem( rSet, SID_ATTR_LRSPACE );
789 if ( !pOld || !( *(const SvxLRSpaceItem*)pOld == aMargin ) )
790 rSet.Put( aMargin );
791 else
792 bModified = FALSE;
795 BOOL bMod = FALSE;
797 if ( aTopMarginEdit.GetText() != aTopMarginEdit.GetSavedValue() )
799 aTopMargin.SetUpper( (USHORT)GetCoreValue( aTopMarginEdit, eUnit ) );
800 bMod |= TRUE;
803 if ( aBottomMarginEdit.GetText() != aBottomMarginEdit.GetSavedValue() )
805 aTopMargin.SetLower( (USHORT)GetCoreValue( aBottomMarginEdit, eUnit ) );
806 bMod |= TRUE;
809 // unteren oberen Rand setzen
811 if ( bMod )
813 pOld = GetOldItem( rSet, SID_ATTR_ULSPACE );
815 if ( !pOld || !( *(const SvxULSpaceItem*)pOld == aTopMargin ) )
817 bModified |= TRUE;
818 rSet.Put( aTopMargin );
822 // Druckerschacht
823 nWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN );
824 USHORT nPos = aPaperTrayBox.GetSelectEntryPos();
825 USHORT nBin = (USHORT)(ULONG)aPaperTrayBox.GetEntryData( nPos );
826 pOld = GetOldItem( rSet, SID_ATTR_PAGE_PAPERBIN );
828 if ( !pOld || ( (const SvxPaperBinItem*)pOld )->GetValue() != nBin )
830 rSet.Put( SvxPaperBinItem( nWhich, (BYTE)nBin ) );
831 bModified |= TRUE;
834 nPos = aPaperSizeBox.GetSelectEntryPos();
835 Paper ePaper = (Paper)(ULONG)aPaperSizeBox.GetEntryData( nPos );
836 const USHORT nOld = aPaperSizeBox.GetSavedValue();
837 BOOL bChecked = aLandscapeBtn.IsChecked();
839 if ( PAPER_USER == ePaper )
841 if ( nOld != nPos ||
842 aPaperWidthEdit.IsValueModified() ||
843 aPaperHeightEdit.IsValueModified() ||
844 bChecked != aLandscapeBtn.GetSavedValue() )
846 Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ),
847 GetCoreValue( aPaperHeightEdit, eUnit ) );
848 pOld = GetOldItem( rSet, SID_ATTR_PAGE_SIZE );
850 if ( !pOld || ( (const SvxSizeItem*)pOld )->GetSize() != aSize )
852 rSet.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
853 bModified |= TRUE;
857 else
859 if ( nOld != nPos || bChecked != aLandscapeBtn.GetSavedValue() )
861 Size aSize( SvxPaperInfo::GetPaperSize( ePaper, (MapUnit)eUnit ) );
863 if ( bChecked )
864 Swap( aSize );
866 pOld = GetOldItem( rSet, SID_ATTR_PAGE_SIZE );
868 if ( !pOld || ( (const SvxSizeItem*)pOld )->GetSize() != aSize )
870 rSet.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
871 bModified |= TRUE;
876 // sonstiges Zeug der Page
877 nWhich = GetWhich( SID_ATTR_PAGE );
878 SvxPageItem aPage( (const SvxPageItem&)rOldSet.Get( nWhich ) );
879 bMod = aLayoutBox.GetSelectEntryPos() != aLayoutBox.GetSavedValue();
881 if ( bMod )
882 aPage.SetPageUsage(
883 ::PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() ) );
885 if ( bChecked != aLandscapeBtn.GetSavedValue() )
887 aPage.SetLandscape(bChecked);
888 bMod |= TRUE;
891 // Einstellen der Numerierungsart der Seite
892 nPos = aNumberFormatBox.GetSelectEntryPos();
894 if ( nPos != aNumberFormatBox.GetSavedValue() )
896 aPage.SetNumType( (SvxNumType)nPos );
897 bMod |= TRUE;
900 if ( bMod )
902 pOld = GetOldItem( rSet, SID_ATTR_PAGE );
904 if ( !pOld || !( *(const SvxPageItem*)pOld == aPage ) )
906 rSet.Put( aPage );
907 bModified |= TRUE;
910 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich ) )
911 rSet.ClearItem( nWhich );
912 else
913 rSet.Put( rOldSet.Get( nWhich ) );
915 // Modispezifische Controls auswerten
917 switch ( eMode )
919 case SVX_PAGE_MODE_CENTER:
921 if ( aHorzBox.IsChecked() != aHorzBox.GetSavedValue() )
923 SfxBoolItem aHorz( GetWhich( SID_ATTR_PAGE_EXT1 ),
924 aHorzBox.IsChecked() );
925 rSet.Put( aHorz );
926 bModified |= TRUE;
929 if ( aVertBox.IsChecked() != aVertBox.GetSavedValue() )
931 SfxBoolItem aVert( GetWhich( SID_ATTR_PAGE_EXT2 ),
932 aVertBox.IsChecked() );
933 rSet.Put( aVert );
934 bModified |= TRUE;
936 break;
939 case SVX_PAGE_MODE_PRESENTATION:
941 // immer putten, damit Draw das auswerten kann
942 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_PAGE_EXT1 ),
943 aAdaptBox.IsChecked() ) );
944 bModified |= TRUE;
945 break;
947 default: ;//prevent warning
951 if(aRegisterCB.IsVisible() &&
952 (aRegisterCB.IsChecked() || aRegisterCB.GetSavedValue() != aRegisterCB.IsChecked()))
954 const SfxBoolItem& rRegItem = (const SfxBoolItem&)rOldSet.Get(SID_SWREGISTER_MODE);
955 SfxBoolItem* pRegItem = (SfxBoolItem*)rRegItem.Clone();
956 BOOL bCheck = aRegisterCB.IsChecked();
957 pRegItem->SetValue(bCheck);
958 rSet.Put(*pRegItem);
959 bModified |= TRUE;
960 if(bCheck)
962 bModified |= TRUE;
963 rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION,
964 aRegisterLB.GetSelectEntry()));
966 delete pRegItem;
969 SvxFrameDirection eDirection = aTextFlowBox.GetSelectEntryValue();
970 if( aTextFlowBox.IsVisible() && (eDirection != aTextFlowBox.GetSavedValue()) )
972 rSet.Put( SvxFrameDirectionItem( eDirection, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
973 bModified = TRUE;
976 return bModified;
979 // -----------------------------------------------------------------------
981 IMPL_LINK( SvxPageDescPage, LayoutHdl_Impl, ListBox *, EMPTYARG )
983 // innen au\sen umschalten
984 const USHORT nPos = PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() );
986 if ( nPos == SVX_PAGE_MIRROR )
988 if ( aLeftMarginLbl.GetText() != aInsideText )
989 aLeftMarginLbl.SetText( aInsideText );
991 if ( aRightMarginLbl.GetText() != aOutsideText )
992 aRightMarginLbl.SetText( aOutsideText );
994 else
996 if ( aLeftMarginLbl.GetText() != aLeftText )
997 aLeftMarginLbl.SetText( aLeftText );
999 if ( aRightMarginLbl.GetText() != aRightText )
1000 aRightMarginLbl.SetText( aRightText );
1002 UpdateExample_Impl( true );
1003 return 0;
1006 // -----------------------------------------------------------------------
1008 IMPL_LINK( SvxPageDescPage, PaperBinHdl_Impl, ListBox *, EMPTYARG )
1010 if ( aPaperTrayBox.GetEntryCount() > 1 )
1011 // schon gef"ullt
1012 return 0;
1014 // Schacht-Box initialisieren
1015 String aOldName = aPaperTrayBox.GetSelectEntry();
1016 aPaperTrayBox.SetUpdateMode( FALSE );
1017 aPaperTrayBox.Clear();
1018 USHORT nEntryPos = aPaperTrayBox.InsertEntry(
1019 SVX_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS ) );
1020 aPaperTrayBox.SetEntryData( nEntryPos,
1021 (void*)(ULONG)PAPERBIN_PRINTER_SETTINGS );
1022 String aPaperBin( SVX_RES( RID_SVXSTR_PAPERBIN ) );
1023 USHORT nBinCount = pImpl->mpDefPrinter->GetPaperBinCount();
1025 for ( USHORT i = 0; i < nBinCount; ++i )
1027 String aName = pImpl->mpDefPrinter->GetPaperBinName(i);
1029 if ( !aName.Len() )
1031 aName = aPaperBin;
1032 aName.Append( sal_Unicode(' ') );
1033 aName.Append( UniString::CreateFromInt32( i+1 ) );
1035 nEntryPos = aPaperTrayBox.InsertEntry( aName );
1036 aPaperTrayBox.SetEntryData( nEntryPos, (void*)(ULONG)i );
1038 aPaperTrayBox.SelectEntry( aOldName );
1039 aPaperTrayBox.SetUpdateMode( TRUE );
1041 return 0;
1044 // -----------------------------------------------------------------------
1046 IMPL_LINK( SvxPageDescPage, PaperSizeSelect_Impl, ListBox *, pBox )
1048 const USHORT nPos = pBox->GetSelectEntryPos();
1049 Paper ePaper = (Paper)(ULONG)aPaperSizeBox.GetEntryData( nPos );
1051 if ( ePaper != PAPER_USER )
1053 Size aSize( SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM ) );
1055 if ( aLandscapeBtn.IsChecked() )
1056 Swap( aSize );
1058 if ( aSize.Height() < aPaperHeightEdit.GetMin( FUNIT_100TH_MM ) )
1059 aPaperHeightEdit.SetMin(
1060 aPaperHeightEdit.Normalize( aSize.Height() ), FUNIT_100TH_MM );
1061 if ( aSize.Width() < aPaperWidthEdit.GetMin( FUNIT_100TH_MM ) )
1062 aPaperWidthEdit.SetMin(
1063 aPaperWidthEdit.Normalize( aSize.Width() ), FUNIT_100TH_MM );
1064 SetMetricValue( aPaperHeightEdit, aSize.Height(), SFX_MAPUNIT_100TH_MM );
1065 SetMetricValue( aPaperWidthEdit, aSize.Width(), SFX_MAPUNIT_100TH_MM );
1067 // R"ander ggf. neu berechnen
1068 CalcMargin_Impl();
1070 RangeHdl_Impl( 0 );
1071 UpdateExample_Impl( true );
1073 if ( eMode == SVX_PAGE_MODE_PRESENTATION )
1075 // Draw: bei Papierformat soll der Rand 1cm betragen
1076 long nTmp = 0;
1077 BOOL bScreen = ( PAPER_SCREEN == ePaper );
1079 if ( !bScreen )
1080 // bei Bildschirm keinen Rand
1081 nTmp = 1; // entspr. 1cm
1083 // Abfragen, ob fuer Raender 0 gesetzt ist:
1084 if ( bScreen || aRightMarginEdit.GetValue() == 0 )
1086 SetMetricValue( aRightMarginEdit, nTmp, SFX_MAPUNIT_CM );
1087 if ( !bScreen &&
1088 aRightMarginEdit.GetFirst() > aRightMarginEdit.GetValue() )
1089 aRightMarginEdit.SetValue( aRightMarginEdit.GetFirst() );
1091 if ( bScreen || aLeftMarginEdit.GetValue() == 0 )
1093 SetMetricValue( aLeftMarginEdit, nTmp, SFX_MAPUNIT_CM );
1094 if ( !bScreen &&
1095 aLeftMarginEdit.GetFirst() > aLeftMarginEdit.GetValue() )
1096 aLeftMarginEdit.SetValue( aLeftMarginEdit.GetFirst() );
1098 if ( bScreen || aBottomMarginEdit.GetValue() == 0 )
1100 SetMetricValue( aBottomMarginEdit, nTmp, SFX_MAPUNIT_CM );
1101 if ( !bScreen &&
1102 aBottomMarginEdit.GetFirst() > aBottomMarginEdit.GetValue() )
1103 aBottomMarginEdit.SetValue( aBottomMarginEdit.GetFirst() );
1105 if ( bScreen || aTopMarginEdit.GetValue() == 0 )
1107 SetMetricValue( aTopMarginEdit, nTmp, SFX_MAPUNIT_CM );
1108 if ( !bScreen &&
1109 aTopMarginEdit.GetFirst() > aTopMarginEdit.GetValue() )
1110 aTopMarginEdit.SetValue( aTopMarginEdit.GetFirst() );
1112 UpdateExample_Impl( true );
1115 return 0;
1118 // -----------------------------------------------------------------------
1120 IMPL_LINK( SvxPageDescPage, PaperSizeModify_Impl, Edit *, EMPTYARG )
1122 USHORT nWhich = GetWhich( SID_ATTR_LRSPACE );
1123 SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWhich );
1124 Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ),
1125 GetCoreValue( aPaperHeightEdit, eUnit ) );
1126 Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, (MapUnit)eUnit, TRUE );
1127 USHORT nEntryCount = aPaperSizeBox.GetEntryCount();
1129 for ( USHORT i = 0; i < nEntryCount; ++i )
1131 Paper eTmp = (Paper)(ULONG)aPaperSizeBox.GetEntryData(i);
1133 if ( eTmp == ePaper )
1135 aPaperSizeBox.SelectEntryPos(i);
1136 break;
1139 UpdateExample_Impl( true );
1140 return 0;
1143 // -----------------------------------------------------------------------
1145 IMPL_LINK( SvxPageDescPage, SwapOrientation_Impl, RadioButton *, pBtn )
1147 if (
1148 (!bLandscape && pBtn == &aLandscapeBtn) ||
1149 (bLandscape && pBtn == &aPortraitBtn)
1152 bLandscape = aLandscapeBtn.IsChecked();
1154 const long lWidth = GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_100TH_MM );
1155 const long lHeight = GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_100TH_MM );
1157 // swap with and height
1158 SetMetricValue( aPaperWidthEdit, lHeight, SFX_MAPUNIT_100TH_MM );
1159 SetMetricValue( aPaperHeightEdit, lWidth, SFX_MAPUNIT_100TH_MM );
1161 // recalculate margins if necessary
1162 CalcMargin_Impl();
1164 PaperSizeSelect_Impl( &aPaperSizeBox );
1165 RangeHdl_Impl( 0 );
1166 SwapFirstValues_Impl( bBorderModified );
1167 UpdateExample_Impl( true );
1169 return 0;
1172 // -----------------------------------------------------------------------
1174 void SvxPageDescPage::SwapFirstValues_Impl( FASTBOOL bSet )
1176 MapMode aOldMode = pImpl->mpDefPrinter->GetMapMode();
1177 Orientation eOri = ORIENTATION_PORTRAIT;
1179 if ( bLandscape )
1180 eOri = ORIENTATION_LANDSCAPE;
1181 Orientation eOldOri = pImpl->mpDefPrinter->GetOrientation();
1182 pImpl->mpDefPrinter->SetOrientation( eOri );
1183 pImpl->mpDefPrinter->SetMapMode( MAP_TWIP );
1185 // First- und Last-Werte f"ur die R"ander setzen
1186 Size aPaperSize = pImpl->mpDefPrinter->GetPaperSize();
1187 Size aPrintSize = pImpl->mpDefPrinter->GetOutputSize();
1189 * einen Punkt ( 0,0 ) in logische Koordinaten zu konvertieren,
1190 * sieht aus wie Unsinn; ist aber sinnvoll, wenn der Ursprung des
1191 * Koordinatensystems verschoben ist.
1193 Point aPrintOffset = pImpl->mpDefPrinter->GetPageOffset() -
1194 pImpl->mpDefPrinter->PixelToLogic( Point() );
1195 pImpl->mpDefPrinter->SetMapMode( aOldMode );
1196 pImpl->mpDefPrinter->SetOrientation( eOldOri );
1198 sal_Int64 nSetL = aLeftMarginEdit.Denormalize(
1199 aLeftMarginEdit.GetValue( FUNIT_TWIP ) );
1200 sal_Int64 nSetR = aRightMarginEdit.Denormalize(
1201 aRightMarginEdit.GetValue( FUNIT_TWIP ) );
1202 sal_Int64 nSetT = aTopMarginEdit.Denormalize(
1203 aTopMarginEdit.GetValue( FUNIT_TWIP ) );
1204 sal_Int64 nSetB = aBottomMarginEdit.Denormalize(
1205 aBottomMarginEdit.GetValue( FUNIT_TWIP ) );
1207 long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET;
1208 long nNewL = aPrintOffset.X();
1209 long nNewR =
1210 aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset;
1211 long nNewT = aPrintOffset.Y();
1212 long nNewB =
1213 aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset;
1215 aLeftMarginEdit.SetFirst( aLeftMarginEdit.Normalize( nNewL ), FUNIT_TWIP );
1216 nFirstLeftMargin = static_cast<long>(aLeftMarginEdit.GetFirst());
1217 aRightMarginEdit.SetFirst( aRightMarginEdit.Normalize( nNewR ), FUNIT_TWIP );
1218 nFirstRightMargin = static_cast<long>(aRightMarginEdit.GetFirst());
1219 aTopMarginEdit.SetFirst( aTopMarginEdit.Normalize( nNewT ), FUNIT_TWIP );
1220 nFirstTopMargin = static_cast<long>(aTopMarginEdit.GetFirst());
1221 aBottomMarginEdit.SetFirst( aBottomMarginEdit.Normalize( nNewB ), FUNIT_TWIP );
1222 nFirstBottomMargin = static_cast<long>(aBottomMarginEdit.GetFirst());
1224 if ( bSet )
1226 // ggf. auch die Werte umsetzen,
1227 if ( nSetL < nNewL )
1228 aLeftMarginEdit.SetValue( aLeftMarginEdit.Normalize( nNewL ),
1229 FUNIT_TWIP );
1230 if ( nSetR < nNewR )
1231 aRightMarginEdit.SetValue( aRightMarginEdit.Normalize( nNewR ),
1232 FUNIT_TWIP );
1233 if ( nSetT < nNewT )
1234 aTopMarginEdit.SetValue( aTopMarginEdit.Normalize( nNewT ),
1235 FUNIT_TWIP );
1236 if ( nSetB < nNewB )
1237 aBottomMarginEdit.SetValue( aBottomMarginEdit.Normalize( nNewB ),
1238 FUNIT_TWIP );
1242 // -----------------------------------------------------------------------
1244 IMPL_LINK_INLINE_START( SvxPageDescPage, BorderModify_Impl, MetricField *, EMPTYARG )
1246 if ( !bBorderModified )
1247 bBorderModified = TRUE;
1248 UpdateExample_Impl();
1249 return 0;
1251 IMPL_LINK_INLINE_END( SvxPageDescPage, BorderModify_Impl, MetricField *, EMPTYARG )
1253 // -----------------------------------------------------------------------
1255 void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground )
1257 // Size
1258 Size aSize( GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_TWIP ),
1259 GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_TWIP ) );
1261 aBspWin.SetSize( aSize );
1263 // R"ander
1264 aBspWin.SetTop( GetCoreValue( aTopMarginEdit, SFX_MAPUNIT_TWIP ) );
1265 aBspWin.SetBottom( GetCoreValue( aBottomMarginEdit, SFX_MAPUNIT_TWIP ) );
1266 aBspWin.SetLeft( GetCoreValue( aLeftMarginEdit, SFX_MAPUNIT_TWIP ) );
1267 aBspWin.SetRight( GetCoreValue( aRightMarginEdit, SFX_MAPUNIT_TWIP ) );
1269 // Layout
1270 aBspWin.SetUsage( PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() ) );
1271 if ( bResetbackground )
1272 aBspWin.ResetBackground();
1273 aBspWin.Invalidate();
1276 // -----------------------------------------------------------------------
1278 void SvxPageDescPage::ResetBackground_Impl( const SfxItemSet& rSet )
1280 USHORT nWhich = GetWhich( SID_ATTR_PAGE_HEADERSET );
1282 if ( rSet.GetItemState( nWhich, FALSE ) == SFX_ITEM_SET )
1284 const SvxSetItem& rSetItem =
1285 (const SvxSetItem&)rSet.Get( nWhich, FALSE );
1286 const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1287 const SfxBoolItem& rOn =
1288 (const SfxBoolItem&)rTmpSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1290 if ( rOn.GetValue() )
1292 nWhich = GetWhich( SID_ATTR_BRUSH );
1294 if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1296 const SvxBrushItem& rItem =
1297 (const SvxBrushItem&)rTmpSet.Get( nWhich );
1298 aBspWin.SetHdColor( rItem.GetColor() );
1300 nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1302 if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1304 const SvxBoxItem& rItem =
1305 (const SvxBoxItem&)rTmpSet.Get( nWhich );
1306 aBspWin.SetHdBorder( rItem );
1311 nWhich = GetWhich( SID_ATTR_PAGE_FOOTERSET );
1313 if ( rSet.GetItemState( nWhich, FALSE ) == SFX_ITEM_SET )
1315 const SvxSetItem& rSetItem =
1316 (const SvxSetItem&)rSet.Get( nWhich, FALSE );
1317 const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1318 const SfxBoolItem& rOn =
1319 (const SfxBoolItem&)rTmpSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1321 if ( rOn.GetValue() )
1323 nWhich = GetWhich( SID_ATTR_BRUSH );
1325 if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1327 const SvxBrushItem& rItem =
1328 (const SvxBrushItem&)rTmpSet.Get( nWhich );
1329 aBspWin.SetFtColor( rItem.GetColor() );
1331 nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1333 if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1335 const SvxBoxItem& rItem =
1336 (const SvxBoxItem&)rTmpSet.Get( nWhich );
1337 aBspWin.SetFtBorder( rItem );
1342 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_BRUSH );
1344 if ( pItem )
1346 aBspWin.SetColor( ( (const SvxBrushItem*)pItem )->GetColor() );
1347 const Graphic* pGrf = ( (const SvxBrushItem*)pItem )->GetGraphic();
1349 if ( pGrf )
1351 Bitmap aBitmap = pGrf->GetBitmap();
1352 aBspWin.SetBitmap( &aBitmap );
1354 else
1355 aBspWin.SetBitmap( NULL );
1358 pItem = GetItem( rSet, SID_ATTR_BORDER_OUTER );
1360 if ( pItem )
1361 aBspWin.SetBorder( (SvxBoxItem&)*pItem );
1364 // -----------------------------------------------------------------------
1366 void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet )
1368 bLandscape = aLandscapeBtn.IsChecked();
1369 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
1371 if ( pItem )
1372 aBspWin.SetSize( ( (const SvxSizeItem*)pItem )->GetSize() );
1374 const SvxSetItem* pSetItem = 0;
1376 // Kopfzeilen-Attribute auswerten
1378 if ( SFX_ITEM_SET ==
1379 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ),
1380 FALSE, (const SfxPoolItem**)&pSetItem ) )
1382 const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
1383 const SfxBoolItem& rHeaderOn =
1384 (const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1386 if ( rHeaderOn.GetValue() )
1388 const SvxSizeItem& rSize = (const SvxSizeItem&)
1389 rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
1390 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
1391 rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
1392 long nDist = rUL.GetLower();
1393 aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist );
1394 aBspWin.SetHdDist( nDist );
1395 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
1396 rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
1397 aBspWin.SetHdLeft( rLR.GetLeft() );
1398 aBspWin.SetHdRight( rLR.GetRight() );
1399 aBspWin.SetHeader( TRUE );
1401 else
1402 aBspWin.SetHeader( FALSE );
1404 // im Beispiel Hintergrund und Umrandung anzeigen
1405 USHORT nWhich = GetWhich( SID_ATTR_BRUSH );
1407 if ( rHeaderSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1409 const SvxBrushItem& rItem =
1410 (const SvxBrushItem&)rHeaderSet.Get( nWhich );
1411 aBspWin.SetHdColor( rItem.GetColor() );
1413 nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1415 if ( rHeaderSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1417 const SvxBoxItem& rItem =
1418 (const SvxBoxItem&)rHeaderSet.Get( nWhich );
1419 aBspWin.SetHdBorder( rItem );
1423 // Fusszeilen-Attribute auswerten
1425 if ( SFX_ITEM_SET ==
1426 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ),
1427 FALSE, (const SfxPoolItem**)&pSetItem ) )
1429 const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
1430 const SfxBoolItem& rFooterOn =
1431 (const SfxBoolItem&)rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1433 if ( rFooterOn.GetValue() )
1435 const SvxSizeItem& rSize = (const SvxSizeItem&)
1436 rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
1437 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
1438 rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
1439 long nDist = rUL.GetUpper();
1440 aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist );
1441 aBspWin.SetFtDist( nDist );
1442 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
1443 rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
1444 aBspWin.SetFtLeft( rLR.GetLeft() );
1445 aBspWin.SetFtRight( rLR.GetRight() );
1446 aBspWin.SetFooter( TRUE );
1448 else
1449 aBspWin.SetFooter( FALSE );
1451 // im Beispiel Hintergrund und Umrandung anzeigen
1452 USHORT nWhich = GetWhich( SID_ATTR_BRUSH );
1454 if ( rFooterSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1456 const SvxBrushItem& rItem =
1457 (const SvxBrushItem&)rFooterSet.Get( nWhich );
1458 aBspWin.SetFtColor( rItem.GetColor() );
1460 nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1462 if ( rFooterSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1464 const SvxBoxItem& rItem =
1465 (const SvxBoxItem&)rFooterSet.Get( nWhich );
1466 aBspWin.SetFtBorder( rItem );
1471 // -----------------------------------------------------------------------
1473 void SvxPageDescPage::ActivatePage( const SfxItemSet& rSet )
1475 InitHeadFoot_Impl( rSet );
1476 ResetBackground_Impl( rSet );
1477 RangeHdl_Impl( 0 );
1480 // -----------------------------------------------------------------------
1482 int SvxPageDescPage::DeactivatePage( SfxItemSet* _pSet )
1484 // Abfrage, ob die Seitenr"ander ausserhalb des Druckbereichs liegen
1485 // Wenn nicht, dann den Anwender fragen, ob sie "ubernommen werden sollen.
1486 // Wenn nicht, dann auf der TabPage bleiben.
1487 USHORT nPos = aPaperSizeBox.GetSelectEntryPos();
1488 Paper ePaper = (Paper)(ULONG)aPaperSizeBox.GetEntryData( nPos );
1490 if ( ePaper != PAPER_SCREEN && IsMarginOutOfRange() )
1492 if ( QueryBox( this, WB_YES_NO | WB_DEF_NO, aPrintRangeQueryText ).Execute() == RET_NO )
1494 MetricField* pField = NULL;
1495 if ( IsPrinterRangeOverflow( aLeftMarginEdit, nFirstLeftMargin, nLastLeftMargin, MARGIN_LEFT ) )
1496 pField = &aLeftMarginEdit;
1497 if ( IsPrinterRangeOverflow( aRightMarginEdit, nFirstRightMargin, nLastRightMargin, MARGIN_RIGHT )
1498 && !pField )
1499 pField = &aRightMarginEdit;
1500 if ( IsPrinterRangeOverflow( aTopMarginEdit, nFirstTopMargin, nLastTopMargin, MARGIN_TOP )
1501 && !pField )
1502 pField = &aTopMarginEdit;
1503 if ( IsPrinterRangeOverflow( aBottomMarginEdit, nFirstBottomMargin, nLastBottomMargin, MARGIN_BOTTOM )
1504 && !pField )
1505 pField = &aBottomMarginEdit;
1506 if ( pField )
1507 pField->GrabFocus();
1508 UpdateExample_Impl();
1509 return KEEP_PAGE;
1511 else
1512 CheckMarginEdits( false );
1515 if ( _pSet )
1517 FillItemSet( *_pSet );
1519 // ggf. hoch/quer putten
1520 USHORT nWh = GetWhich( SID_ATTR_PAGE_SIZE );
1521 SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWh );
1522 Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ),
1523 GetCoreValue( aPaperHeightEdit, eUnit ) );
1525 // putten, wenn aktuelle Gr"o/se unterschiedlich zum Wert in _pSet
1526 const SvxSizeItem* pSize = (const SvxSizeItem*)GetItem( *_pSet, SID_ATTR_PAGE_SIZE );
1527 if ( aSize.Width() && ( !pSize || !IsEqualSize_Impl( pSize, aSize ) ) )
1528 _pSet->Put( SvxSizeItem( nWh, aSize ) );
1531 return LEAVE_PAGE;
1534 // -----------------------------------------------------------------------
1536 IMPL_LINK( SvxPageDescPage, RangeHdl_Impl, Edit *, EMPTYARG )
1538 // Aktuelle Header-Breite/H"ohe aus dem Bsp
1539 long nHHeight = aBspWin.GetHdHeight();
1540 long nHDist = aBspWin.GetHdDist();
1542 // Aktuelle Footer-Breite/H"ohe aus dem Bsp
1543 long nFHeight = aBspWin.GetFtHeight();
1544 long nFDist = aBspWin.GetFtDist();
1546 // Aktuelle Header/Footer-R"ander aus dem Bsp
1547 long nHFLeft = Max( aBspWin.GetHdLeft(), aBspWin.GetFtLeft() );
1548 long nHFRight = Max( aBspWin.GetHdRight(), aBspWin.GetFtRight() );
1550 // Aktuelle Werte der Seitenr"ander
1551 long nBT = static_cast<long>(aTopMarginEdit.Denormalize(aTopMarginEdit.GetValue(FUNIT_TWIP)));
1552 long nBB = static_cast<long>(aBottomMarginEdit.Denormalize(aBottomMarginEdit.GetValue(FUNIT_TWIP)));
1553 long nBL = static_cast<long>(aLeftMarginEdit.Denormalize(aLeftMarginEdit.GetValue(FUNIT_TWIP)));
1554 long nBR = static_cast<long>(aRightMarginEdit.Denormalize(aRightMarginEdit.GetValue(FUNIT_TWIP)));
1556 // Breite Umrandung der Seite berechnen
1557 const SfxItemSet* _pSet = &GetItemSet();
1558 Size aBorder;
1560 if ( _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_SHADOW) ) >=
1561 SFX_ITEM_AVAILABLE &&
1562 _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_OUTER) ) >=
1563 SFX_ITEM_AVAILABLE )
1565 aBorder = ( GetMinBorderSpace_Impl(
1566 (const SvxShadowItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW)),
1567 (const SvxBoxItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER))));
1570 long nH = static_cast<long>(aPaperHeightEdit.Denormalize(aPaperHeightEdit.GetValue(FUNIT_TWIP)));
1571 long nW = static_cast<long>(aPaperWidthEdit.Denormalize(aPaperWidthEdit.GetValue(FUNIT_TWIP)));
1573 // Grenzen Papier
1574 // Maximum liegt bei 54cm
1576 long nMin = nHHeight + nHDist + nFDist + nFHeight + nBT + nBB +
1577 MINBODY + aBorder.Height();
1578 aPaperHeightEdit.SetMin(aPaperHeightEdit.Normalize(nMin), FUNIT_TWIP);
1580 nMin = MINBODY + nBL + nBR + aBorder.Width();
1581 aPaperWidthEdit.SetMin(aPaperWidthEdit.Normalize(nMin), FUNIT_TWIP);
1583 // Falls sich die Papiergr"o\se ge"adert hat
1584 nH = static_cast<long>(aPaperHeightEdit.Denormalize(aPaperHeightEdit.GetValue(FUNIT_TWIP)));
1585 nW = static_cast<long>(aPaperWidthEdit.Denormalize(aPaperWidthEdit.GetValue(FUNIT_TWIP)));
1587 // Top
1588 long nMax = nH - nBB - aBorder.Height() - MINBODY -
1589 nFDist - nFHeight - nHDist - nHHeight;
1591 aTopMarginEdit.SetMax(aTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
1593 // Bottom
1594 nMax = nH - nBT - aBorder.Height() - MINBODY -
1595 nFDist - nFHeight - nHDist - nHHeight;
1597 aBottomMarginEdit.SetMax(aTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
1599 // Left
1600 nMax = nW - nBR - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1601 aLeftMarginEdit.SetMax(aLeftMarginEdit.Normalize(nMax), FUNIT_TWIP);
1603 // Right
1604 nMax = nW - nBL - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1605 aRightMarginEdit.SetMax(aRightMarginEdit.Normalize(nMax), FUNIT_TWIP);
1606 return 0;
1609 // -----------------------------------------------------------------------
1611 void SvxPageDescPage::CalcMargin_Impl()
1613 // Aktuelle Werte der Seitenr"ander
1614 long nBT = GetCoreValue( aTopMarginEdit, SFX_MAPUNIT_TWIP );
1615 long nBB = GetCoreValue( aBottomMarginEdit, SFX_MAPUNIT_TWIP );
1617 long nBL = GetCoreValue( aLeftMarginEdit, SFX_MAPUNIT_TWIP );
1618 long nBR = GetCoreValue( aRightMarginEdit, SFX_MAPUNIT_TWIP );
1620 long nH = GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_TWIP );
1621 long nW = GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_TWIP );
1623 long nWidth = nBL + nBR + MINBODY;
1624 long nHeight = nBT + nBB + MINBODY;
1626 if ( nWidth > nW || nHeight > nH )
1628 if ( nWidth > nW )
1630 long nTmp = nBL <= nBR ? nBR : nBL;
1631 nTmp -= nWidth - nW;
1633 if ( nBL <= nBR )
1634 SetMetricValue( aRightMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1635 else
1636 SetMetricValue( aLeftMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1639 if ( nHeight > nH )
1641 long nTmp = nBT <= nBB ? nBB : nBT;
1642 nTmp -= nHeight - nH;
1644 if ( nBT <= nBB )
1645 SetMetricValue( aBottomMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1646 else
1647 SetMetricValue( aTopMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1652 // -----------------------------------------------------------------------
1654 IMPL_LINK_INLINE_START( SvxPageDescPage, CenterHdl_Impl, CheckBox *, EMPTYARG )
1656 aBspWin.SetHorz( aHorzBox.IsChecked() );
1657 aBspWin.SetVert( aVertBox.IsChecked() );
1658 UpdateExample_Impl();
1659 return 0;
1661 IMPL_LINK_INLINE_END( SvxPageDescPage, CenterHdl_Impl, CheckBox *, EMPTYARG )
1663 // -----------------------------------------------------------------------
1665 void SvxPageDescPage::SetCollectionList(const List* pList)
1667 sStandardRegister = *(String*)pList->GetObject(0);
1668 for( USHORT i = 1; i < pList->Count(); i++ )
1670 aRegisterLB.InsertEntry(*(String*)pList->GetObject(i));
1673 aRegisterCB .Show();
1674 aRegisterFT .Show();
1675 aRegisterLB.Show();
1676 aRegisterCB.SetClickHdl(LINK(this, SvxPageDescPage, RegisterModify));
1679 // -----------------------------------------------------------------------
1681 IMPL_LINK( SvxPageDescPage, RegisterModify, CheckBox*, pBox )
1683 BOOL bEnable = FALSE;
1684 if(pBox->IsChecked())
1686 bEnable = TRUE;
1687 if(USHRT_MAX == aRegisterLB.GetSelectEntryPos())
1688 aRegisterLB.SelectEntry(sStandardRegister);
1690 aRegisterFT.Enable( bEnable );
1691 aRegisterLB.Enable( bEnable );
1692 return 0;
1695 // ----------------------------------------------------------------------------
1697 void SvxPageDescPage::DisableVerticalPageDir()
1699 aTextFlowBox.RemoveEntryValue( FRMDIR_VERT_TOP_RIGHT );
1700 aTextFlowBox.RemoveEntryValue( FRMDIR_VERT_TOP_LEFT );
1701 if( aTextFlowBox.GetEntryCount() < 2 )
1703 aTextFlowLbl.Hide();
1704 aTextFlowBox.Hide();
1705 aBspWin.EnableFrameDirection( sal_False );
1709 IMPL_LINK( SvxPageDescPage, FrameDirectionModify_Impl, ListBox*, EMPTYARG)
1711 aBspWin.SetFrameDirection( (sal_uInt32) aTextFlowBox.GetSelectEntryValue() );
1712 aBspWin.Invalidate();
1713 return 0;
1716 bool SvxPageDescPage::IsPrinterRangeOverflow(
1717 MetricField& rField, long nFirstMargin, long nLastMargin, MarginPosition nPos )
1719 bool bRet = false;
1720 bool bCheck = ( ( pImpl->m_nPos & nPos ) == 0 );
1721 long nValue = static_cast<long>(rField.GetValue());
1722 if ( bCheck &&
1723 ( nValue < nFirstMargin || nValue > nLastMargin ) &&
1724 rField.GetText() != rField.GetSavedValue() )
1726 rField.SetValue( nValue < nFirstMargin ? nFirstMargin : nLastMargin );
1727 bRet = true;
1730 return bRet;
1733 /** Check if a value of a margin edit is outside the printer paper margins
1734 and save this information.
1736 void SvxPageDescPage::CheckMarginEdits( bool _bClear )
1738 if ( _bClear )
1739 pImpl->m_nPos = 0;
1741 sal_Int64 nValue = aLeftMarginEdit.GetValue();
1742 if ( nValue < nFirstLeftMargin || nValue > nLastLeftMargin )
1743 pImpl->m_nPos |= MARGIN_LEFT;
1744 nValue = aRightMarginEdit.GetValue();
1745 if ( nValue < nFirstRightMargin || nValue > nLastRightMargin )
1746 pImpl->m_nPos |= MARGIN_RIGHT;
1747 nValue = aTopMarginEdit.GetValue();
1748 if ( nValue < nFirstTopMargin || nValue > nLastTopMargin )
1749 pImpl->m_nPos |= MARGIN_TOP;
1750 nValue = aBottomMarginEdit.GetValue();
1751 if ( nValue < nFirstBottomMargin || nValue > nLastBottomMargin )
1752 pImpl->m_nPos |= MARGIN_BOTTOM;
1755 bool SvxPageDescPage::IsMarginOutOfRange()
1757 bool bRet = ( ( ( !( pImpl->m_nPos & MARGIN_LEFT ) &&
1758 ( aLeftMarginEdit.GetText() != aLeftMarginEdit.GetSavedValue() ) ) &&
1759 ( aLeftMarginEdit.GetValue() < nFirstLeftMargin ||
1760 aLeftMarginEdit.GetValue() > nLastLeftMargin ) ) ||
1761 ( ( !( pImpl->m_nPos & MARGIN_RIGHT ) &&
1762 ( aRightMarginEdit.GetText() != aRightMarginEdit.GetSavedValue() ) ) &&
1763 ( aRightMarginEdit.GetValue() < nFirstRightMargin ||
1764 aRightMarginEdit.GetValue() > nLastRightMargin ) ) ||
1765 ( ( !( pImpl->m_nPos & MARGIN_TOP ) &&
1766 ( aTopMarginEdit.GetText() != aTopMarginEdit.GetSavedValue() ) ) &&
1767 ( aTopMarginEdit.GetValue() < nFirstTopMargin ||
1768 aTopMarginEdit.GetValue() > nLastTopMargin ) ) ||
1769 ( ( !( pImpl->m_nPos & MARGIN_BOTTOM ) &&
1770 ( aBottomMarginEdit.GetText() != aBottomMarginEdit.GetSavedValue() ) ) &&
1771 ( aBottomMarginEdit.GetValue() < nFirstBottomMargin ||
1772 aBottomMarginEdit.GetValue() > nLastBottomMargin ) ) );
1773 return bRet;
1776 void SvxPageDescPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
1778 SFX_ITEMSET_ARG (&aSet,pModeItem,SfxAllEnumItem,SID_ENUM_PAGE_MODE,sal_False);
1779 SFX_ITEMSET_ARG (&aSet,pPaperStartItem,SfxAllEnumItem,SID_PAPER_START,sal_False);
1780 SFX_ITEMSET_ARG (&aSet,pPaperEndItem,SfxAllEnumItem,SID_PAPER_END,sal_False);
1781 SFX_ITEMSET_ARG (&aSet,pCollectListItem,SfxStringListItem,SID_COLLECT_LIST,sal_False);
1782 if (pModeItem)
1783 SetMode((SvxModeType)pModeItem->GetEnumValue());
1784 if (pPaperStartItem && pPaperEndItem)
1785 SetPaperFormatRanges( (Paper)pPaperStartItem->GetEnumValue(), (Paper)pPaperEndItem->GetEnumValue() );
1786 if (pCollectListItem)
1787 SetCollectionList(pCollectListItem->GetList());