1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
32 #include <sfx2/app.hxx>
33 #include <sfx2/objsh.hxx>
34 #include <tools/resary.hxx>
35 #include <vcl/graph.hxx>
36 #include <sfx2/viewsh.hxx>
37 #include <svl/itemiter.hxx>
38 #include <svl/languageoptions.hxx>
39 #include <vcl/msgbox.hxx>
40 #include <unotools/configitem.hxx>
41 #include "svx/htmlmode.hxx"
49 #include <svx/pageitem.hxx>
50 #include <editeng/brshitem.hxx>
51 #include <editeng/boxitem.hxx>
52 #include <editeng/shaditem.hxx>
53 #include <editeng/pbinitem.hxx>
54 #include <editeng/lrspitem.hxx>
55 #include <editeng/ulspitem.hxx>
56 #include <editeng/sizeitem.hxx>
57 #include <editeng/frmdiritem.hxx>
58 #include "svx/dlgutil.hxx"
59 #include <dialmgr.hxx>
60 #include <editeng/paperinf.hxx>
61 #include <dialmgr.hxx>
62 #include <sfx2/module.hxx>
63 #include <svl/stritem.hxx>
64 #include <svx/dialogs.hrc> // for RID_SVXPAGE_PAGE
65 #include <editeng/eerdll.hxx>
66 #include <editeng/editrids.hrc> // for RID_SVXSTR_PAPERBIN...,
67 #include <svx/svxids.hrc>
70 #include <svtools/optionsdrawinglayer.hxx>
71 #include <svl/slstitm.hxx> //CHINA001
72 #include <svl/aeitem.hxx> //CHINA001
73 #include <sfx2/request.hxx> //CHINA001
74 // configuration helper =======================================================
76 /** Helper to get a configuration setting.
77 @descr This is a HACK to get a configuration item directly. Normally the
78 OfaHtmlOptions class from 'offmgr' project would do the job, but we cannot
79 use it here. On the other hand, the OfaHtmlOptions cannot be moved to
80 'svtools', because it uses 'svx' itself...
81 The correct way would be to move OfaHtmlOptions to 'svtools' anyway, and to
82 remove the dependency from 'svx' (a call to the static function
83 SvxTextEncodingBox::GetBestMimeEncoding(), which contains low level
84 operations that can be moved to lower projects, i.e. 'rtl'). Then this
85 class can be removed, and the OfaHtmlOptions can be used instead. */
86 class SvxHtmlExportModeConfigItem_Impl
: public utl::ConfigItem
89 explicit SvxHtmlExportModeConfigItem_Impl();
91 /** Returns the HTML export mode, as read from the configuration. */
92 inline sal_Int32
GetExportMode() const { return mnExpMode
; }
94 /** Returns true, if the current HTML export mode is set to HTML 3.2. */
95 inline bool IsExportModeHTML32() const { return mnExpMode
== 0; } // 0 == HTML_CFG_HTML32, see offmgr/htmlcfg.hxx
97 virtual void Commit();
98 virtual void Notify( const com::sun::star::uno::Sequence
< rtl::OUString
>& _rPropertyNames
);
104 SvxHtmlExportModeConfigItem_Impl::SvxHtmlExportModeConfigItem_Impl() :
105 utl::ConfigItem( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/HTML/Export" ) ) ),
106 mnExpMode( 3 ) // default to 3 == HTML_CFG_NS40, see offmgr/htmlcfg.hxx
108 using com::sun::star::uno::Sequence
;
109 using com::sun::star::uno::Any
;
111 Sequence
< rtl::OUString
> aPropNames( 1 );
112 aPropNames
[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Browser" ) );
113 Sequence
< Any
> aPropValues( GetProperties( aPropNames
) );
114 if( aPropValues
.getLength() == 1 )
115 aPropValues
[ 0 ] >>= mnExpMode
;
118 void SvxHtmlExportModeConfigItem_Impl::Commit()
122 void SvxHtmlExportModeConfigItem_Impl::Notify( const com::sun::star::uno::Sequence
< rtl::OUString
>& )
126 // static ----------------------------------------------------------------
128 static const long MINBODY
= 284; // 0,5cm in twips aufgerundet
129 //static const long PRINT_OFFSET = 17; // 0,03cm in twips abgerundet
130 static const long PRINT_OFFSET
= 0; // why was this ever set to 17 ? it led to wrong right and bottom margins.
132 static sal_uInt16 pRanges
[] =
134 SID_ATTR_BORDER_OUTER
,
135 SID_ATTR_BORDER_SHADOW
,
137 SID_ATTR_PAGE_SHARED
,
138 SID_SWREGISTER_COLLECTION
,
143 // ------- Mapping Seitenlayout ------------------------------------------
153 // -----------------------------------------------------------------------
155 sal_uInt16
PageUsageToPos_Impl( sal_uInt16 nUsage
)
157 const sal_uInt16 nCount
= sizeof(aArr
) / sizeof(sal_uInt16
);
159 for ( sal_uInt16 i
= 0; i
< nCount
; ++i
)
160 if ( aArr
[i
] == ( nUsage
& 0x000f ) )
165 // -----------------------------------------------------------------------
167 sal_uInt16
PosToPageUsage_Impl( sal_uInt16 nPos
)
169 const sal_uInt16 nCount
= sizeof(aArr
) / sizeof(sal_uInt16
);
171 if ( nPos
>= nCount
)
176 // -----------------------------------------------------------------------
178 Size
GetMinBorderSpace_Impl( const SvxShadowItem
& rShadow
, const SvxBoxItem
& rBox
)
181 aSz
.Height() = rShadow
.CalcShadowSpace( SHADOW_BOTTOM
) + rBox
.CalcLineSpace( BOX_LINE_BOTTOM
);
182 aSz
.Height() += rShadow
.CalcShadowSpace( SHADOW_TOP
) + rBox
.CalcLineSpace( BOX_LINE_TOP
);
183 aSz
.Width() = rShadow
.CalcShadowSpace( SHADOW_LEFT
) + rBox
.CalcLineSpace( BOX_LINE_LEFT
);
184 aSz
.Width() += rShadow
.CalcShadowSpace( SHADOW_RIGHT
) + rBox
.CalcLineSpace( BOX_LINE_RIGHT
);
188 // -----------------------------------------------------------------------
190 long ConvertLong_Impl( const long nIn
, SfxMapUnit eUnit
)
192 return OutputDevice::LogicToLogic( nIn
, (MapUnit
)eUnit
, MAP_TWIP
);
195 sal_Bool
IsEqualSize_Impl( const SvxSizeItem
* pSize
, const Size
& rSize
)
199 Size aSize
= pSize
->GetSize();
200 long nDiffW
= Abs( rSize
.Width () - aSize
.Width () );
201 long nDiffH
= Abs( rSize
.Height() - aSize
.Height() );
202 return ( nDiffW
< 10 && nDiffH
< 10 );
208 // -----------------------------------------------------------------------
210 #define MARGIN_LEFT ( (MarginPosition)0x0001 )
211 #define MARGIN_RIGHT ( (MarginPosition)0x0002 )
212 #define MARGIN_TOP ( (MarginPosition)0x0004 )
213 #define MARGIN_BOTTOM ( (MarginPosition)0x0008 )
217 MarginPosition m_nPos
;
218 Printer
* mpDefPrinter
;
224 mbDelPrinter( false ) {}
226 ~SvxPage_Impl() { if ( mbDelPrinter
) delete mpDefPrinter
; }
229 // class SvxPageDescPage --------------------------------------------------
231 // gibt den Bereich der Which-Werte zur"uck
233 sal_uInt16
* SvxPageDescPage::GetRanges()
238 // -----------------------------------------------------------------------
240 SfxTabPage
* SvxPageDescPage::Create( Window
* pParent
, const SfxItemSet
& rSet
)
242 return new SvxPageDescPage( pParent
, rSet
);
245 // -----------------------------------------------------------------------
247 SvxPageDescPage::SvxPageDescPage( Window
* pParent
, const SfxItemSet
& rAttr
) :
249 SfxTabPage( pParent
, CUI_RES( RID_SVXPAGE_PAGE
), rAttr
),
251 aPaperSizeFl ( this, CUI_RES( FL_PAPER_SIZE
) ),
252 aPaperFormatText ( this, CUI_RES( FT_PAPER_FORMAT
) ),
253 aPaperSizeBox ( this, CUI_RES( LB_PAPER_SIZE
) ),
254 aPaperWidthText ( this, CUI_RES( FT_PAPER_WIDTH
) ),
255 aPaperWidthEdit ( this, CUI_RES( ED_PAPER_WIDTH
) ),
256 aPaperHeightText ( this, CUI_RES( FT_PAPER_HEIGHT
) ),
257 aPaperHeightEdit ( this, CUI_RES( ED_PAPER_HEIGHT
) ),
258 aOrientationFT ( this, CUI_RES( FT_ORIENTATION
) ),
259 aPortraitBtn ( this, CUI_RES( RB_PORTRAIT
) ),
260 aLandscapeBtn ( this, CUI_RES( RB_LANDSCAPE
) ),
261 aBspWin ( this, CUI_RES( WN_BSP
) ),
262 aTextFlowLbl ( this, CUI_RES( FT_TEXT_FLOW
) ),
263 aTextFlowBox ( this, CUI_RES( LB_TEXT_FLOW
) ),
264 aPaperTrayLbl ( this, CUI_RES( FT_PAPER_TRAY
) ),
265 aPaperTrayBox ( this, CUI_RES( LB_PAPER_TRAY
) ),
266 aMarginFl ( this, CUI_RES( FL_MARGIN
) ),
267 aLeftMarginLbl ( this, CUI_RES( FT_LEFT_MARGIN
) ),
268 aLeftMarginEdit ( this, CUI_RES( ED_LEFT_MARGIN
) ),
269 aRightMarginLbl ( this, CUI_RES( FT_RIGHT_MARGIN
) ),
270 aRightMarginEdit ( this, CUI_RES( ED_RIGHT_MARGIN
) ),
271 aTopMarginLbl ( this, CUI_RES( FT_TOP_MARGIN
) ),
272 aTopMarginEdit ( this, CUI_RES( ED_TOP_MARGIN
) ),
273 aBottomMarginLbl ( this, CUI_RES( FT_BOTTOM_MARGIN
) ),
274 aBottomMarginEdit ( this, CUI_RES( ED_BOTTOM_MARGIN
) ),
275 aBottomSeparatorFl ( this, CUI_RES( FL_BOTTOM_SEP
) ),
276 aLayoutFL ( this, CUI_RES( FL_LAYOUT
) ),
277 aPageText ( this, CUI_RES( FT_PAGELAYOUT
) ),
278 aLayoutBox ( this, CUI_RES( LB_LAYOUT
) ),
279 aNumberFormatText ( this, CUI_RES( FT_NUMBER_FORMAT
) ),
280 aNumberFormatBox ( this, CUI_RES( LB_NUMBER_FORMAT
) ),
281 aTblAlignFT ( this, CUI_RES( FT_TBL_ALIGN
) ),
282 aHorzBox ( this, CUI_RES( CB_HORZ
) ),
283 aVertBox ( this, CUI_RES( CB_VERT
) ),
284 aAdaptBox ( this, CUI_RES( CB_ADAPT
) ),
285 aRegisterCB ( this, CUI_RES( CB_REGISTER
) ),
286 aRegisterFT ( this, CUI_RES( FT_REGISTER
) ),
287 aRegisterLB ( this, CUI_RES( LB_REGISTER
) ),
289 aInsideText ( CUI_RES( STR_INSIDE
) ),
290 aOutsideText ( CUI_RES( STR_OUTSIDE
) ),
291 aPrintRangeQueryText( CUI_RES( STR_QUERY_PRINTRANGE
) ),
293 bLandscape ( sal_False
),
294 eMode ( SVX_PAGE_MODE_STANDARD
),
295 ePaperStart ( PAPER_A3
),
296 ePaperEnd ( PAPER_ENV_DL
),
297 pImpl ( new SvxPage_Impl
)
300 bBorderModified
= sal_False
;
302 aBspWin
.EnableRTL( sal_False
);
304 // diese Page braucht ExchangeSupport
305 SetExchangeSupport();
307 SvtLanguageOptions aLangOptions
;
308 sal_Bool bCJK
= aLangOptions
.IsAsianTypographyEnabled();
309 sal_Bool bCTL
= aLangOptions
.IsCTLFontEnabled();
310 sal_Bool bWeb
= sal_False
;
311 const SfxPoolItem
* pItem
;
313 SfxObjectShell
* pShell
;
314 if(SFX_ITEM_SET
== rAttr
.GetItemState(SID_HTML_MODE
, sal_False
, &pItem
) ||
315 ( 0 != (pShell
= SfxObjectShell::Current()) &&
316 0 != (pItem
= pShell
->GetItem(SID_HTML_MODE
))))
317 bWeb
= 0 != (((const SfxUInt16Item
*)pItem
)->GetValue() & HTMLMODE_ON
);
319 // #109989# get the HTML export setting from configuration.
320 // !! This is a hack, see comments in SvxHtmlExportModeConfigItem_Impl class above.
321 bool bHTML32
= SvxHtmlExportModeConfigItem_Impl().IsExportModeHTML32();
323 // fill text flow listbox with valid entries
324 aTextFlowBox
.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_HORI
), FRMDIR_HORI_LEFT_TOP
);
326 aTextFlowBox
.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_HORI
), FRMDIR_HORI_RIGHT_TOP
);
327 // #109989# do not show vertical directions in Writer/Web
332 aTextFlowBox
.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_VERT
), FRMDIR_VERT_TOP_RIGHT
);
333 // aTextFlowBox.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_VERT ), FRMDIR_VERT_TOP_LEFT );
337 // #109989# show the text direction box in Writer/Web too, but only, if HTML export mode is not HTML3.2.
338 if( !(bWeb
&& bHTML32
) && (bCJK
|| bCTL
) &&
339 SFX_ITEM_UNKNOWN
< rAttr
.GetItemState(GetWhich( SID_ATTR_FRAMEDIRECTION
)))
343 aTextFlowBox
.SetSelectHdl(LINK(this, SvxPageDescPage
, FrameDirectionModify_Impl
));
345 aBspWin
.EnableFrameDirection(sal_True
);
349 FieldUnit eFUnit
= GetModuleFieldUnit( rAttr
);
350 SetFieldUnit( aLeftMarginEdit
, eFUnit
);
351 SetFieldUnit( aRightMarginEdit
, eFUnit
);
352 SetFieldUnit( aTopMarginEdit
, eFUnit
);
353 SetFieldUnit( aBottomMarginEdit
, eFUnit
);
354 SetFieldUnit( aPaperWidthEdit
, eFUnit
);
355 SetFieldUnit( aPaperHeightEdit
, eFUnit
);
357 if ( SfxViewShell::Current() && SfxViewShell::Current()->GetPrinter() )
358 pImpl
->mpDefPrinter
= (Printer
*)SfxViewShell::Current()->GetPrinter();
361 pImpl
->mpDefPrinter
= new Printer
;
362 pImpl
->mbDelPrinter
= true;
365 MapMode aOldMode
= pImpl
->mpDefPrinter
->GetMapMode();
366 pImpl
->mpDefPrinter
->SetMapMode( MAP_TWIP
);
368 // First- und Last-Werte f"ur die R"ander setzen
369 Size aPaperSize
= pImpl
->mpDefPrinter
->GetPaperSize();
370 Size aPrintSize
= pImpl
->mpDefPrinter
->GetOutputSize();
372 * einen Punkt ( 0,0 ) in logische Koordinaten zu konvertieren,
373 * sieht aus wie Unsinn; ist aber sinnvoll, wenn der Ursprung des
374 * Koordinatensystems verschoben ist.
376 Point aPrintOffset
= pImpl
->mpDefPrinter
->GetPageOffset() -
377 pImpl
->mpDefPrinter
->PixelToLogic( Point() );
378 pImpl
->mpDefPrinter
->SetMapMode( aOldMode
);
380 long nOffset
= !aPrintOffset
.X() && !aPrintOffset
.Y() ? 0 : PRINT_OFFSET
;
381 aLeftMarginEdit
.SetFirst( aLeftMarginEdit
.Normalize( aPrintOffset
.X() ), FUNIT_TWIP
);
382 nFirstLeftMargin
= static_cast<long>(aLeftMarginEdit
.GetFirst());
383 aRightMarginEdit
.SetFirst( aRightMarginEdit
.Normalize(
384 aPaperSize
.Width() - aPrintSize
.Width() - aPrintOffset
.X() + nOffset
), FUNIT_TWIP
);
385 nFirstRightMargin
= static_cast<long>(aRightMarginEdit
.GetFirst());
386 aTopMarginEdit
.SetFirst( aTopMarginEdit
.Normalize( aPrintOffset
.Y() ), FUNIT_TWIP
);
387 nFirstTopMargin
= static_cast<long>(aTopMarginEdit
.GetFirst());
388 aBottomMarginEdit
.SetFirst( aBottomMarginEdit
.Normalize(
389 aPaperSize
.Height() - aPrintSize
.Height() - aPrintOffset
.Y() + nOffset
), FUNIT_TWIP
);
390 nFirstBottomMargin
= static_cast<long>(aBottomMarginEdit
.GetFirst());
391 aLeftMarginEdit
.SetLast( aLeftMarginEdit
.Normalize(
392 aPrintOffset
.X() + aPrintSize
.Width() ), FUNIT_TWIP
);
393 nLastLeftMargin
= static_cast<long>(aLeftMarginEdit
.GetLast());
394 aRightMarginEdit
.SetLast( aRightMarginEdit
.Normalize(
395 aPrintOffset
.X() + aPrintSize
.Width() ), FUNIT_TWIP
);
396 nLastRightMargin
= static_cast<long>(aRightMarginEdit
.GetLast());
397 aTopMarginEdit
.SetLast( aTopMarginEdit
.Normalize(
398 aPrintOffset
.Y() + aPrintSize
.Height() ), FUNIT_TWIP
);
399 nLastTopMargin
= static_cast<long>(aTopMarginEdit
.GetLast());
400 aBottomMarginEdit
.SetLast( aBottomMarginEdit
.Normalize(
401 aPrintOffset
.Y() + aPrintSize
.Height() ), FUNIT_TWIP
);
402 nLastBottomMargin
= static_cast<long>(aBottomMarginEdit
.GetLast());
404 // #i4219# get DrawingLayer options
405 const SvtOptionsDrawinglayer aDrawinglayerOpt
;
407 // #i4219# take Maximum now from configuration (1/100th cm)
408 // was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000
409 aPaperWidthEdit
.SetMax(aPaperWidthEdit
.Normalize(aDrawinglayerOpt
.GetMaximumPaperWidth()), FUNIT_CM
);
410 aPaperWidthEdit
.SetLast(aPaperWidthEdit
.Normalize(aDrawinglayerOpt
.GetMaximumPaperWidth()), FUNIT_CM
);
411 aPaperHeightEdit
.SetMax(aPaperHeightEdit
.Normalize(aDrawinglayerOpt
.GetMaximumPaperHeight()), FUNIT_CM
);
412 aPaperHeightEdit
.SetLast(aPaperHeightEdit
.Normalize(aDrawinglayerOpt
.GetMaximumPaperHeight()), FUNIT_CM
);
414 // #i4219# also for margins (1/100th cm). Was: 9999, keeping.
415 aLeftMarginEdit
.SetMax(aDrawinglayerOpt
.GetMaximumPaperLeftMargin());
416 aLeftMarginEdit
.SetLast(aDrawinglayerOpt
.GetMaximumPaperLeftMargin());
417 aRightMarginEdit
.SetMax(aDrawinglayerOpt
.GetMaximumPaperRightMargin());
418 aRightMarginEdit
.SetLast(aDrawinglayerOpt
.GetMaximumPaperRightMargin());
419 aTopMarginEdit
.SetMax(aDrawinglayerOpt
.GetMaximumPaperTopMargin());
420 aTopMarginEdit
.SetLast(aDrawinglayerOpt
.GetMaximumPaperTopMargin());
421 aBottomMarginEdit
.SetMax(aDrawinglayerOpt
.GetMaximumPaperBottomMargin());
422 aBottomMarginEdit
.SetLast(aDrawinglayerOpt
.GetMaximumPaperBottomMargin());
424 aPortraitBtn
.SetAccessibleRelationMemberOf(&aOrientationFT
);
425 aLandscapeBtn
.SetAccessibleRelationMemberOf(&aOrientationFT
);
428 // -----------------------------------------------------------------------
430 SvxPageDescPage::~SvxPageDescPage()
435 // -----------------------------------------------------------------------
437 void SvxPageDescPage::Init_Impl()
439 aLeftText
= aLeftMarginLbl
.GetText();
440 aRightText
= aRightMarginLbl
.GetText();
442 // Handler einstellen
443 aLayoutBox
.SetSelectHdl( LINK( this, SvxPageDescPage
, LayoutHdl_Impl
) );
444 aPaperSizeBox
.SetDropDownLineCount(10);
446 aPaperTrayBox
.SetGetFocusHdl(
447 LINK( this, SvxPageDescPage
, PaperBinHdl_Impl
) );
448 aPaperSizeBox
.SetSelectHdl(
449 LINK( this, SvxPageDescPage
, PaperSizeSelect_Impl
) );
450 aPaperWidthEdit
.SetModifyHdl(
451 LINK( this, SvxPageDescPage
, PaperSizeModify_Impl
) );
452 aPaperHeightEdit
.SetModifyHdl(
453 LINK( this, SvxPageDescPage
, PaperSizeModify_Impl
) );
454 aLandscapeBtn
.SetClickHdl(
455 LINK( this, SvxPageDescPage
, SwapOrientation_Impl
) );
456 aPortraitBtn
.SetClickHdl(
457 LINK( this, SvxPageDescPage
, SwapOrientation_Impl
) );
459 Link aLink
= LINK( this, SvxPageDescPage
, BorderModify_Impl
);
460 aLeftMarginEdit
.SetModifyHdl( aLink
);
461 aRightMarginEdit
.SetModifyHdl( aLink
);
462 aTopMarginEdit
.SetModifyHdl( aLink
);
463 aBottomMarginEdit
.SetModifyHdl( aLink
);
465 aLink
= LINK( this, SvxPageDescPage
, RangeHdl_Impl
);
466 aPaperWidthEdit
.SetLoseFocusHdl( aLink
);
467 aPaperHeightEdit
.SetLoseFocusHdl( aLink
);
468 aLeftMarginEdit
.SetLoseFocusHdl( aLink
);
469 aRightMarginEdit
.SetLoseFocusHdl( aLink
);
470 aTopMarginEdit
.SetLoseFocusHdl( aLink
);
471 aBottomMarginEdit
.SetLoseFocusHdl( aLink
);
473 aHorzBox
.SetClickHdl( LINK( this, SvxPageDescPage
, CenterHdl_Impl
) );
474 aVertBox
.SetClickHdl( LINK( this, SvxPageDescPage
, CenterHdl_Impl
) );
478 // -----------------------------------------------------------------------
480 void SvxPageDescPage::Reset( const SfxItemSet
& rSet
)
482 SfxItemPool
* pPool
= rSet
.GetPool();
483 DBG_ASSERT( pPool
, "Wo ist der Pool" );
484 SfxMapUnit eUnit
= pPool
->GetMetric( GetWhich( SID_ATTR_LRSPACE
) );
486 // R"ander (Links/Rechts) einstellen
487 const SfxPoolItem
* pItem
= GetItem( rSet
, SID_ATTR_LRSPACE
);
491 const SvxLRSpaceItem
& rLRSpace
= (const SvxLRSpaceItem
&)*pItem
;
492 SetMetricValue( aLeftMarginEdit
, rLRSpace
.GetLeft(), eUnit
);
494 (sal_uInt16
)ConvertLong_Impl( (long)rLRSpace
.GetLeft(), eUnit
) );
495 SetMetricValue( aRightMarginEdit
, rLRSpace
.GetRight(), eUnit
);
497 (sal_uInt16
)ConvertLong_Impl( (long)rLRSpace
.GetRight(), eUnit
) );
500 // R"ander (Oben/Unten) einstellen
501 pItem
= GetItem( rSet
, SID_ATTR_ULSPACE
);
505 const SvxULSpaceItem
& rULSpace
= (const SvxULSpaceItem
&)*pItem
;
506 SetMetricValue( aTopMarginEdit
, rULSpace
.GetUpper(), eUnit
);
508 (sal_uInt16
)ConvertLong_Impl( (long)rULSpace
.GetUpper(), eUnit
) );
509 SetMetricValue( aBottomMarginEdit
, rULSpace
.GetLower(), eUnit
);
511 (sal_uInt16
)ConvertLong_Impl( (long)rULSpace
.GetLower(), eUnit
) );
514 // allgemeine Seitendaten
515 SvxNumType eNumType
= SVX_ARABIC
;
516 bLandscape
= ( pImpl
->mpDefPrinter
->GetOrientation() == ORIENTATION_LANDSCAPE
);
517 sal_uInt16 nUse
= (sal_uInt16
)SVX_PAGE_ALL
;
518 pItem
= GetItem( rSet
, SID_ATTR_PAGE
);
522 const SvxPageItem
& rItem
= (const SvxPageItem
&)*pItem
;
523 eNumType
= rItem
.GetNumType();
524 nUse
= rItem
.GetPageUsage();
525 bLandscape
= rItem
.IsLandscape();
529 aLayoutBox
.SelectEntryPos( ::PageUsageToPos_Impl( nUse
) );
530 aBspWin
.SetUsage( nUse
);
533 // Numerierungsart der Seitenvorlage einstellen
534 aNumberFormatBox
.SelectEntryPos( sal::static_int_cast
< sal_uInt16
>(eNumType
) );
536 // Aktueller Papierschacht
537 aPaperTrayBox
.Clear();
538 sal_uInt8 nPaperBin
= PAPERBIN_PRINTER_SETTINGS
;
539 pItem
= GetItem( rSet
, SID_ATTR_PAGE_PAPERBIN
);
543 nPaperBin
= ( (const SvxPaperBinItem
*)pItem
)->GetValue();
545 if ( nPaperBin
>= pImpl
->mpDefPrinter
->GetPaperBinCount() )
546 nPaperBin
= PAPERBIN_PRINTER_SETTINGS
;
551 if ( PAPERBIN_PRINTER_SETTINGS
== nPaperBin
)
552 aBinName
= EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS
);
554 aBinName
= pImpl
->mpDefPrinter
->GetPaperBinName( (sal_uInt16
)nPaperBin
);
556 sal_uInt16 nEntryPos
= aPaperTrayBox
.InsertEntry( aBinName
);
557 aPaperTrayBox
.SetEntryData( nEntryPos
, (void*)(sal_uLong
)nPaperBin
);
558 aPaperTrayBox
.SelectEntry( aBinName
);
561 Size aPaperSize
= SvxPaperInfo::GetPaperSize( pImpl
->mpDefPrinter
);
562 pItem
= GetItem( rSet
, SID_ATTR_PAGE_SIZE
);
565 aPaperSize
= ( (const SvxSizeItem
*)pItem
)->GetSize();
567 FASTBOOL bOrientationSupport
=
568 pImpl
->mpDefPrinter
->HasSupport( SUPPORT_SET_ORIENTATION
);
570 // unter OS/2 wird bei HasSupport() immer sal_True returned
571 // aber nur als Dummy, deshalb FALSE
572 bOrientationSupport
= sal_False
;
575 if ( !bOrientationSupport
&&
576 aPaperSize
.Width() > aPaperSize
.Height() )
577 bLandscape
= sal_True
;
579 aLandscapeBtn
.Check( bLandscape
);
580 aPortraitBtn
.Check( !bLandscape
);
582 aBspWin
.SetSize( Size( ConvertLong_Impl( aPaperSize
.Width(), eUnit
),
583 ConvertLong_Impl( aPaperSize
.Height(), eUnit
) ) );
585 aPaperSize
= OutputDevice::LogicToLogic(aPaperSize
, (MapUnit
)eUnit
, MAP_100TH_MM
);
589 // Actual Paper Format
590 Paper ePaper
= SvxPaperInfo::GetSvxPaper( aPaperSize
, MAP_100TH_MM
, sal_True
);
592 if ( PAPER_USER
!= ePaper
)
593 aPaperSize
= SvxPaperInfo::GetPaperSize( ePaper
, MAP_100TH_MM
);
598 // Werte in die Edits eintragen
599 SetMetricValue( aPaperHeightEdit
, aPaperSize
.Height(), SFX_MAPUNIT_100TH_MM
);
600 SetMetricValue( aPaperWidthEdit
, aPaperSize
.Width(), SFX_MAPUNIT_100TH_MM
);
601 aPaperSizeBox
.Clear();
603 sal_uInt16 nActPos
= LISTBOX_ENTRY_NOTFOUND
;
604 sal_uInt16 nAryId
= RID_SVXSTRARY_PAPERSIZE_STD
;
606 if ( ePaperStart
!= PAPER_A3
)
607 nAryId
= RID_SVXSTRARY_PAPERSIZE_DRAW
;
608 ResStringArray
aPaperAry( CUI_RES( nAryId
) );
609 sal_uInt32 nCnt
= aPaperAry
.Count();
611 sal_uInt16 nUserPos
= LISTBOX_ENTRY_NOTFOUND
;
612 for ( sal_uInt32 i
= 0; i
< nCnt
; ++i
)
614 String aStr
= aPaperAry
.GetString(i
);
615 Paper eSize
= (Paper
)aPaperAry
.GetValue(i
);
616 sal_uInt16 nPos
= aPaperSizeBox
.InsertEntry( aStr
);
617 aPaperSizeBox
.SetEntryData( nPos
, (void*)(sal_uLong
)eSize
);
619 if ( eSize
== ePaper
)
621 if( eSize
== PAPER_USER
)
624 // preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead
625 aPaperSizeBox
.SelectEntryPos( nActPos
!= LISTBOX_ENTRY_NOTFOUND
? nActPos
: nUserPos
);
627 // Applikationsspezifisch
631 case SVX_PAGE_MODE_CENTER
:
636 DisableVerticalPageDir();
638 // Horizontale Ausrichtung
639 pItem
= GetItem( rSet
, SID_ATTR_PAGE_EXT1
);
640 aHorzBox
.Check( pItem
? ( (const SfxBoolItem
*)pItem
)->GetValue()
643 // Vertikale Ausrichtung
644 pItem
= GetItem( rSet
, SID_ATTR_PAGE_EXT2
);
645 aVertBox
.Check( pItem
? ( (const SfxBoolItem
*)pItem
)->GetValue()
648 // Beispiel-Fenster auf Tabelle setzen
649 aBspWin
.SetTable( sal_True
);
650 aBspWin
.SetHorz( aHorzBox
.IsChecked() );
651 aBspWin
.SetVert( aVertBox
.IsChecked() );
656 case SVX_PAGE_MODE_PRESENTATION
:
658 DisableVerticalPageDir();
660 pItem
= GetItem( rSet
, SID_ATTR_PAGE_EXT1
);
661 aAdaptBox
.Check( pItem
?
662 ( (const SfxBoolItem
*)pItem
)->GetValue() : sal_False
);
664 //!!! hidden, weil von StarDraw nicht implementiert
670 default: ;//prevent warning
674 // im Beispiel Hintergrund und Umrandung anzeigen
675 ResetBackground_Impl( rSet
);
676 //! UpdateExample_Impl();
679 // Header Footer anzeigen
680 InitHeadFoot_Impl( rSet
);
682 // R"ander auf Hoch/Quer updaten, dann Beispiel updaten
683 bBorderModified
= sal_False
;
684 SwapFirstValues_Impl( sal_False
);
685 UpdateExample_Impl();
687 // Alte Werte sichern
688 aLeftMarginEdit
.SaveValue();
689 aRightMarginEdit
.SaveValue();
690 aTopMarginEdit
.SaveValue();
691 aBottomMarginEdit
.SaveValue();
692 aLayoutBox
.SaveValue();
693 aNumberFormatBox
.SaveValue();
694 aPaperSizeBox
.SaveValue();
695 aPaperWidthEdit
.SaveValue();
696 aPaperHeightEdit
.SaveValue();
697 aPortraitBtn
.SaveValue();
698 aLandscapeBtn
.SaveValue();
699 aPaperTrayBox
.SaveValue();
700 aVertBox
.SaveValue();
701 aHorzBox
.SaveValue();
702 aAdaptBox
.SaveValue();
704 CheckMarginEdits( true );
706 // Registerhaltigkeit
707 if(SFX_ITEM_SET
== rSet
.GetItemState(SID_SWREGISTER_MODE
))
709 aRegisterCB
.Check(((const SfxBoolItem
&)rSet
.Get(
710 SID_SWREGISTER_MODE
)).GetValue());
711 aRegisterCB
.SaveValue();
712 RegisterModify(&aRegisterCB
);
714 if(SFX_ITEM_SET
== rSet
.GetItemState(SID_SWREGISTER_COLLECTION
))
716 aRegisterLB
.SelectEntry(
717 ((const SfxStringItem
&)rSet
.Get(SID_SWREGISTER_COLLECTION
)).GetValue());
718 aRegisterLB
.SaveValue();
721 SfxItemState eState
= rSet
.GetItemState( GetWhich( SID_ATTR_FRAMEDIRECTION
),
723 if( SFX_ITEM_UNKNOWN
!= eState
)
725 sal_uInt32 nVal
= SFX_ITEM_SET
== eState
726 ? ((SvxFrameDirectionItem
*)pItem
)->GetValue()
728 aTextFlowBox
.SelectEntryValue( static_cast< SvxFrameDirection
>( nVal
) );
729 aTextFlowBox
.SaveValue();
730 aBspWin
.SetFrameDirection(nVal
);
734 // -----------------------------------------------------------------------
736 void SvxPageDescPage::FillUserData()
738 if ( SVX_PAGE_MODE_PRESENTATION
== eMode
)
739 SetUserData( UniString::CreateFromInt32( (sal_Int32
)aAdaptBox
.IsChecked() ) );
742 // -----------------------------------------------------------------------
744 sal_Bool
SvxPageDescPage::FillItemSet( SfxItemSet
& rSet
)
746 sal_Bool bModified
= sal_False
;
747 const SfxItemSet
& rOldSet
= GetItemSet();
748 SfxItemPool
* pPool
= rOldSet
.GetPool();
749 DBG_ASSERT( pPool
, "Wo ist der Pool" );
750 sal_uInt16 nWhich
= GetWhich( SID_ATTR_LRSPACE
);
751 SfxMapUnit eUnit
= pPool
->GetMetric( nWhich
);
752 const SfxPoolItem
* pOld
= 0;
754 // alten linken und rechten Rand kopieren
755 SvxLRSpaceItem
aMargin( (const SvxLRSpaceItem
&)rOldSet
.Get( nWhich
) );
757 // alten oberen und unteren Rand kopieren
758 nWhich
= GetWhich( SID_ATTR_ULSPACE
);
759 SvxULSpaceItem
aTopMargin( (const SvxULSpaceItem
&)rOldSet
.Get( nWhich
) );
761 if ( aLeftMarginEdit
.GetText() != aLeftMarginEdit
.GetSavedValue() )
763 aMargin
.SetLeft( (sal_uInt16
)GetCoreValue( aLeftMarginEdit
, eUnit
) );
764 bModified
|= sal_True
;
767 if ( aRightMarginEdit
.GetText() != aRightMarginEdit
.GetSavedValue() )
769 aMargin
.SetRight( (sal_uInt16
)GetCoreValue( aRightMarginEdit
, eUnit
) );
770 bModified
|= sal_True
;
773 // Linken und rechten Rand setzen
776 pOld
= GetOldItem( rSet
, SID_ATTR_LRSPACE
);
778 if ( !pOld
|| !( *(const SvxLRSpaceItem
*)pOld
== aMargin
) )
781 bModified
= sal_False
;
784 sal_Bool bMod
= sal_False
;
786 if ( aTopMarginEdit
.GetText() != aTopMarginEdit
.GetSavedValue() )
788 aTopMargin
.SetUpper( (sal_uInt16
)GetCoreValue( aTopMarginEdit
, eUnit
) );
792 if ( aBottomMarginEdit
.GetText() != aBottomMarginEdit
.GetSavedValue() )
794 aTopMargin
.SetLower( (sal_uInt16
)GetCoreValue( aBottomMarginEdit
, eUnit
) );
798 // unteren oberen Rand setzen
802 pOld
= GetOldItem( rSet
, SID_ATTR_ULSPACE
);
804 if ( !pOld
|| !( *(const SvxULSpaceItem
*)pOld
== aTopMargin
) )
806 bModified
|= sal_True
;
807 rSet
.Put( aTopMargin
);
812 nWhich
= GetWhich( SID_ATTR_PAGE_PAPERBIN
);
813 sal_uInt16 nPos
= aPaperTrayBox
.GetSelectEntryPos();
814 sal_uInt16 nBin
= (sal_uInt16
)(sal_uLong
)aPaperTrayBox
.GetEntryData( nPos
);
815 pOld
= GetOldItem( rSet
, SID_ATTR_PAGE_PAPERBIN
);
817 if ( !pOld
|| ( (const SvxPaperBinItem
*)pOld
)->GetValue() != nBin
)
819 rSet
.Put( SvxPaperBinItem( nWhich
, (sal_uInt8
)nBin
) );
820 bModified
|= sal_True
;
823 nPos
= aPaperSizeBox
.GetSelectEntryPos();
824 Paper ePaper
= (Paper
)(sal_uLong
)aPaperSizeBox
.GetEntryData( nPos
);
825 const sal_uInt16 nOld
= aPaperSizeBox
.GetSavedValue();
826 sal_Bool bChecked
= aLandscapeBtn
.IsChecked();
828 if ( PAPER_USER
== ePaper
)
831 aPaperWidthEdit
.IsValueModified() ||
832 aPaperHeightEdit
.IsValueModified() ||
833 bChecked
!= aLandscapeBtn
.GetSavedValue() )
835 Size
aSize( GetCoreValue( aPaperWidthEdit
, eUnit
),
836 GetCoreValue( aPaperHeightEdit
, eUnit
) );
837 pOld
= GetOldItem( rSet
, SID_ATTR_PAGE_SIZE
);
839 if ( !pOld
|| ( (const SvxSizeItem
*)pOld
)->GetSize() != aSize
)
841 rSet
.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE
), aSize
) );
842 bModified
|= sal_True
;
848 if ( nOld
!= nPos
|| bChecked
!= aLandscapeBtn
.GetSavedValue() )
850 Size
aSize( SvxPaperInfo::GetPaperSize( ePaper
, (MapUnit
)eUnit
) );
855 pOld
= GetOldItem( rSet
, SID_ATTR_PAGE_SIZE
);
857 if ( !pOld
|| ( (const SvxSizeItem
*)pOld
)->GetSize() != aSize
)
859 rSet
.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE
), aSize
) );
860 bModified
|= sal_True
;
865 // sonstiges Zeug der Page
866 nWhich
= GetWhich( SID_ATTR_PAGE
);
867 SvxPageItem
aPage( (const SvxPageItem
&)rOldSet
.Get( nWhich
) );
868 bMod
= aLayoutBox
.GetSelectEntryPos() != aLayoutBox
.GetSavedValue();
872 ::PosToPageUsage_Impl( aLayoutBox
.GetSelectEntryPos() ) );
874 if ( bChecked
!= aLandscapeBtn
.GetSavedValue() )
876 aPage
.SetLandscape(bChecked
);
880 // Einstellen der Numerierungsart der Seite
881 nPos
= aNumberFormatBox
.GetSelectEntryPos();
883 if ( nPos
!= aNumberFormatBox
.GetSavedValue() )
885 aPage
.SetNumType( (SvxNumType
)nPos
);
891 pOld
= GetOldItem( rSet
, SID_ATTR_PAGE
);
893 if ( !pOld
|| !( *(const SvxPageItem
*)pOld
== aPage
) )
896 bModified
|= sal_True
;
899 else if ( SFX_ITEM_DEFAULT
== rOldSet
.GetItemState( nWhich
) )
900 rSet
.ClearItem( nWhich
);
902 rSet
.Put( rOldSet
.Get( nWhich
) );
904 // Modispezifische Controls auswerten
908 case SVX_PAGE_MODE_CENTER
:
910 if ( aHorzBox
.IsChecked() != aHorzBox
.GetSavedValue() )
912 SfxBoolItem
aHorz( GetWhich( SID_ATTR_PAGE_EXT1
),
913 aHorzBox
.IsChecked() );
915 bModified
|= sal_True
;
918 if ( aVertBox
.IsChecked() != aVertBox
.GetSavedValue() )
920 SfxBoolItem
aVert( GetWhich( SID_ATTR_PAGE_EXT2
),
921 aVertBox
.IsChecked() );
923 bModified
|= sal_True
;
928 case SVX_PAGE_MODE_PRESENTATION
:
930 // immer putten, damit Draw das auswerten kann
931 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_PAGE_EXT1
),
932 aAdaptBox
.IsChecked() ) );
933 bModified
|= sal_True
;
936 default: ;//prevent warning
940 if(aRegisterCB
.IsVisible() &&
941 (aRegisterCB
.IsChecked() || aRegisterCB
.GetSavedValue() != aRegisterCB
.IsChecked()))
943 const SfxBoolItem
& rRegItem
= (const SfxBoolItem
&)rOldSet
.Get(SID_SWREGISTER_MODE
);
944 SfxBoolItem
* pRegItem
= (SfxBoolItem
*)rRegItem
.Clone();
945 sal_Bool bCheck
= aRegisterCB
.IsChecked();
946 pRegItem
->SetValue(bCheck
);
948 bModified
|= sal_True
;
951 bModified
|= sal_True
;
952 rSet
.Put(SfxStringItem(SID_SWREGISTER_COLLECTION
,
953 aRegisterLB
.GetSelectEntry()));
958 SvxFrameDirection eDirection
= aTextFlowBox
.GetSelectEntryValue();
959 if( aTextFlowBox
.IsVisible() && (eDirection
!= aTextFlowBox
.GetSavedValue()) )
961 rSet
.Put( SvxFrameDirectionItem( eDirection
, GetWhich( SID_ATTR_FRAMEDIRECTION
) ) );
962 bModified
= sal_True
;
968 // -----------------------------------------------------------------------
970 IMPL_LINK( SvxPageDescPage
, LayoutHdl_Impl
, ListBox
*, EMPTYARG
)
972 // innen au\sen umschalten
973 const sal_uInt16 nPos
= PosToPageUsage_Impl( aLayoutBox
.GetSelectEntryPos() );
975 if ( nPos
== SVX_PAGE_MIRROR
)
977 if ( aLeftMarginLbl
.GetText() != aInsideText
)
978 aLeftMarginLbl
.SetText( aInsideText
);
980 if ( aRightMarginLbl
.GetText() != aOutsideText
)
981 aRightMarginLbl
.SetText( aOutsideText
);
985 if ( aLeftMarginLbl
.GetText() != aLeftText
)
986 aLeftMarginLbl
.SetText( aLeftText
);
988 if ( aRightMarginLbl
.GetText() != aRightText
)
989 aRightMarginLbl
.SetText( aRightText
);
991 UpdateExample_Impl( true );
995 // -----------------------------------------------------------------------
997 IMPL_LINK( SvxPageDescPage
, PaperBinHdl_Impl
, ListBox
*, EMPTYARG
)
999 if ( aPaperTrayBox
.GetEntryCount() > 1 )
1003 // Schacht-Box initialisieren
1004 String aOldName
= aPaperTrayBox
.GetSelectEntry();
1005 aPaperTrayBox
.SetUpdateMode( sal_False
);
1006 aPaperTrayBox
.Clear();
1007 sal_uInt16 nEntryPos
= aPaperTrayBox
.InsertEntry(
1008 EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS
) );
1009 aPaperTrayBox
.SetEntryData( nEntryPos
,
1010 (void*)(sal_uLong
)PAPERBIN_PRINTER_SETTINGS
);
1011 String
aPaperBin( EditResId( RID_SVXSTR_PAPERBIN
) );
1012 sal_uInt16 nBinCount
= pImpl
->mpDefPrinter
->GetPaperBinCount();
1014 for ( sal_uInt16 i
= 0; i
< nBinCount
; ++i
)
1016 String aName
= pImpl
->mpDefPrinter
->GetPaperBinName(i
);
1021 aName
.Append( sal_Unicode(' ') );
1022 aName
.Append( UniString::CreateFromInt32( i
+1 ) );
1024 nEntryPos
= aPaperTrayBox
.InsertEntry( aName
);
1025 aPaperTrayBox
.SetEntryData( nEntryPos
, (void*)(sal_uLong
)i
);
1027 aPaperTrayBox
.SelectEntry( aOldName
);
1028 aPaperTrayBox
.SetUpdateMode( sal_True
);
1033 // -----------------------------------------------------------------------
1035 IMPL_LINK( SvxPageDescPage
, PaperSizeSelect_Impl
, ListBox
*, pBox
)
1037 const sal_uInt16 nPos
= pBox
->GetSelectEntryPos();
1038 Paper ePaper
= (Paper
)(sal_uLong
)aPaperSizeBox
.GetEntryData( nPos
);
1040 if ( ePaper
!= PAPER_USER
)
1042 Size
aSize( SvxPaperInfo::GetPaperSize( ePaper
, MAP_100TH_MM
) );
1044 if ( aLandscapeBtn
.IsChecked() )
1047 if ( aSize
.Height() < aPaperHeightEdit
.GetMin( FUNIT_100TH_MM
) )
1048 aPaperHeightEdit
.SetMin(
1049 aPaperHeightEdit
.Normalize( aSize
.Height() ), FUNIT_100TH_MM
);
1050 if ( aSize
.Width() < aPaperWidthEdit
.GetMin( FUNIT_100TH_MM
) )
1051 aPaperWidthEdit
.SetMin(
1052 aPaperWidthEdit
.Normalize( aSize
.Width() ), FUNIT_100TH_MM
);
1053 SetMetricValue( aPaperHeightEdit
, aSize
.Height(), SFX_MAPUNIT_100TH_MM
);
1054 SetMetricValue( aPaperWidthEdit
, aSize
.Width(), SFX_MAPUNIT_100TH_MM
);
1056 // R"ander ggf. neu berechnen
1060 UpdateExample_Impl( true );
1062 if ( eMode
== SVX_PAGE_MODE_PRESENTATION
)
1064 // Draw: bei Papierformat soll der Rand 1cm betragen
1066 sal_Bool bScreen
= ( PAPER_SCREEN
== ePaper
);
1069 // bei Bildschirm keinen Rand
1070 nTmp
= 1; // entspr. 1cm
1072 // Abfragen, ob fuer Raender 0 gesetzt ist:
1073 if ( bScreen
|| aRightMarginEdit
.GetValue() == 0 )
1075 SetMetricValue( aRightMarginEdit
, nTmp
, SFX_MAPUNIT_CM
);
1077 aRightMarginEdit
.GetFirst() > aRightMarginEdit
.GetValue() )
1078 aRightMarginEdit
.SetValue( aRightMarginEdit
.GetFirst() );
1080 if ( bScreen
|| aLeftMarginEdit
.GetValue() == 0 )
1082 SetMetricValue( aLeftMarginEdit
, nTmp
, SFX_MAPUNIT_CM
);
1084 aLeftMarginEdit
.GetFirst() > aLeftMarginEdit
.GetValue() )
1085 aLeftMarginEdit
.SetValue( aLeftMarginEdit
.GetFirst() );
1087 if ( bScreen
|| aBottomMarginEdit
.GetValue() == 0 )
1089 SetMetricValue( aBottomMarginEdit
, nTmp
, SFX_MAPUNIT_CM
);
1091 aBottomMarginEdit
.GetFirst() > aBottomMarginEdit
.GetValue() )
1092 aBottomMarginEdit
.SetValue( aBottomMarginEdit
.GetFirst() );
1094 if ( bScreen
|| aTopMarginEdit
.GetValue() == 0 )
1096 SetMetricValue( aTopMarginEdit
, nTmp
, SFX_MAPUNIT_CM
);
1098 aTopMarginEdit
.GetFirst() > aTopMarginEdit
.GetValue() )
1099 aTopMarginEdit
.SetValue( aTopMarginEdit
.GetFirst() );
1101 UpdateExample_Impl( true );
1107 // -----------------------------------------------------------------------
1109 IMPL_LINK( SvxPageDescPage
, PaperSizeModify_Impl
, Edit
*, EMPTYARG
)
1111 sal_uInt16 nWhich
= GetWhich( SID_ATTR_LRSPACE
);
1112 SfxMapUnit eUnit
= GetItemSet().GetPool()->GetMetric( nWhich
);
1113 Size
aSize( GetCoreValue( aPaperWidthEdit
, eUnit
),
1114 GetCoreValue( aPaperHeightEdit
, eUnit
) );
1115 Paper ePaper
= SvxPaperInfo::GetSvxPaper( aSize
, (MapUnit
)eUnit
, sal_True
);
1116 sal_uInt16 nEntryCount
= aPaperSizeBox
.GetEntryCount();
1118 for ( sal_uInt16 i
= 0; i
< nEntryCount
; ++i
)
1120 Paper eTmp
= (Paper
)(sal_uLong
)aPaperSizeBox
.GetEntryData(i
);
1122 if ( eTmp
== ePaper
)
1124 aPaperSizeBox
.SelectEntryPos(i
);
1128 UpdateExample_Impl( true );
1132 // -----------------------------------------------------------------------
1134 IMPL_LINK( SvxPageDescPage
, SwapOrientation_Impl
, RadioButton
*, pBtn
)
1137 (!bLandscape
&& pBtn
== &aLandscapeBtn
) ||
1138 (bLandscape
&& pBtn
== &aPortraitBtn
)
1141 bLandscape
= aLandscapeBtn
.IsChecked();
1143 const long lWidth
= GetCoreValue( aPaperWidthEdit
, SFX_MAPUNIT_100TH_MM
);
1144 const long lHeight
= GetCoreValue( aPaperHeightEdit
, SFX_MAPUNIT_100TH_MM
);
1146 // swap with and height
1147 SetMetricValue( aPaperWidthEdit
, lHeight
, SFX_MAPUNIT_100TH_MM
);
1148 SetMetricValue( aPaperHeightEdit
, lWidth
, SFX_MAPUNIT_100TH_MM
);
1150 // recalculate margins if necessary
1153 PaperSizeSelect_Impl( &aPaperSizeBox
);
1155 SwapFirstValues_Impl( bBorderModified
);
1156 UpdateExample_Impl( true );
1161 // -----------------------------------------------------------------------
1163 void SvxPageDescPage::SwapFirstValues_Impl( FASTBOOL bSet
)
1165 MapMode aOldMode
= pImpl
->mpDefPrinter
->GetMapMode();
1166 Orientation eOri
= ORIENTATION_PORTRAIT
;
1169 eOri
= ORIENTATION_LANDSCAPE
;
1170 Orientation eOldOri
= pImpl
->mpDefPrinter
->GetOrientation();
1171 pImpl
->mpDefPrinter
->SetOrientation( eOri
);
1172 pImpl
->mpDefPrinter
->SetMapMode( MAP_TWIP
);
1174 // First- und Last-Werte f"ur die R"ander setzen
1175 Size aPaperSize
= pImpl
->mpDefPrinter
->GetPaperSize();
1176 Size aPrintSize
= pImpl
->mpDefPrinter
->GetOutputSize();
1178 * einen Punkt ( 0,0 ) in logische Koordinaten zu konvertieren,
1179 * sieht aus wie Unsinn; ist aber sinnvoll, wenn der Ursprung des
1180 * Koordinatensystems verschoben ist.
1182 Point aPrintOffset
= pImpl
->mpDefPrinter
->GetPageOffset() -
1183 pImpl
->mpDefPrinter
->PixelToLogic( Point() );
1184 pImpl
->mpDefPrinter
->SetMapMode( aOldMode
);
1185 pImpl
->mpDefPrinter
->SetOrientation( eOldOri
);
1187 sal_Int64 nSetL
= aLeftMarginEdit
.Denormalize(
1188 aLeftMarginEdit
.GetValue( FUNIT_TWIP
) );
1189 sal_Int64 nSetR
= aRightMarginEdit
.Denormalize(
1190 aRightMarginEdit
.GetValue( FUNIT_TWIP
) );
1191 sal_Int64 nSetT
= aTopMarginEdit
.Denormalize(
1192 aTopMarginEdit
.GetValue( FUNIT_TWIP
) );
1193 sal_Int64 nSetB
= aBottomMarginEdit
.Denormalize(
1194 aBottomMarginEdit
.GetValue( FUNIT_TWIP
) );
1196 long nOffset
= !aPrintOffset
.X() && !aPrintOffset
.Y() ? 0 : PRINT_OFFSET
;
1197 long nNewL
= aPrintOffset
.X();
1199 aPaperSize
.Width() - aPrintSize
.Width() - aPrintOffset
.X() + nOffset
;
1200 long nNewT
= aPrintOffset
.Y();
1202 aPaperSize
.Height() - aPrintSize
.Height() - aPrintOffset
.Y() + nOffset
;
1204 aLeftMarginEdit
.SetFirst( aLeftMarginEdit
.Normalize( nNewL
), FUNIT_TWIP
);
1205 nFirstLeftMargin
= static_cast<long>(aLeftMarginEdit
.GetFirst());
1206 aRightMarginEdit
.SetFirst( aRightMarginEdit
.Normalize( nNewR
), FUNIT_TWIP
);
1207 nFirstRightMargin
= static_cast<long>(aRightMarginEdit
.GetFirst());
1208 aTopMarginEdit
.SetFirst( aTopMarginEdit
.Normalize( nNewT
), FUNIT_TWIP
);
1209 nFirstTopMargin
= static_cast<long>(aTopMarginEdit
.GetFirst());
1210 aBottomMarginEdit
.SetFirst( aBottomMarginEdit
.Normalize( nNewB
), FUNIT_TWIP
);
1211 nFirstBottomMargin
= static_cast<long>(aBottomMarginEdit
.GetFirst());
1215 // ggf. auch die Werte umsetzen,
1216 if ( nSetL
< nNewL
)
1217 aLeftMarginEdit
.SetValue( aLeftMarginEdit
.Normalize( nNewL
),
1219 if ( nSetR
< nNewR
)
1220 aRightMarginEdit
.SetValue( aRightMarginEdit
.Normalize( nNewR
),
1222 if ( nSetT
< nNewT
)
1223 aTopMarginEdit
.SetValue( aTopMarginEdit
.Normalize( nNewT
),
1225 if ( nSetB
< nNewB
)
1226 aBottomMarginEdit
.SetValue( aBottomMarginEdit
.Normalize( nNewB
),
1231 // -----------------------------------------------------------------------
1233 IMPL_LINK_INLINE_START( SvxPageDescPage
, BorderModify_Impl
, MetricField
*, EMPTYARG
)
1235 if ( !bBorderModified
)
1236 bBorderModified
= sal_True
;
1237 UpdateExample_Impl();
1240 IMPL_LINK_INLINE_END( SvxPageDescPage
, BorderModify_Impl
, MetricField
*, EMPTYARG
)
1242 // -----------------------------------------------------------------------
1244 void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground
)
1247 Size
aSize( GetCoreValue( aPaperWidthEdit
, SFX_MAPUNIT_TWIP
),
1248 GetCoreValue( aPaperHeightEdit
, SFX_MAPUNIT_TWIP
) );
1250 aBspWin
.SetSize( aSize
);
1253 aBspWin
.SetTop( GetCoreValue( aTopMarginEdit
, SFX_MAPUNIT_TWIP
) );
1254 aBspWin
.SetBottom( GetCoreValue( aBottomMarginEdit
, SFX_MAPUNIT_TWIP
) );
1255 aBspWin
.SetLeft( GetCoreValue( aLeftMarginEdit
, SFX_MAPUNIT_TWIP
) );
1256 aBspWin
.SetRight( GetCoreValue( aRightMarginEdit
, SFX_MAPUNIT_TWIP
) );
1259 aBspWin
.SetUsage( PosToPageUsage_Impl( aLayoutBox
.GetSelectEntryPos() ) );
1260 if ( bResetbackground
)
1261 aBspWin
.ResetBackground();
1262 aBspWin
.Invalidate();
1265 // -----------------------------------------------------------------------
1267 void SvxPageDescPage::ResetBackground_Impl( const SfxItemSet
& rSet
)
1269 sal_uInt16 nWhich
= GetWhich( SID_ATTR_PAGE_HEADERSET
);
1271 if ( rSet
.GetItemState( nWhich
, sal_False
) == SFX_ITEM_SET
)
1273 const SvxSetItem
& rSetItem
=
1274 (const SvxSetItem
&)rSet
.Get( nWhich
, sal_False
);
1275 const SfxItemSet
& rTmpSet
= rSetItem
.GetItemSet();
1276 const SfxBoolItem
& rOn
=
1277 (const SfxBoolItem
&)rTmpSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
1279 if ( rOn
.GetValue() )
1281 nWhich
= GetWhich( SID_ATTR_BRUSH
);
1283 if ( rTmpSet
.GetItemState( nWhich
) == SFX_ITEM_SET
)
1285 const SvxBrushItem
& rItem
=
1286 (const SvxBrushItem
&)rTmpSet
.Get( nWhich
);
1287 aBspWin
.SetHdColor( rItem
.GetColor() );
1289 nWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
1291 if ( rTmpSet
.GetItemState( nWhich
) == SFX_ITEM_SET
)
1293 const SvxBoxItem
& rItem
=
1294 (const SvxBoxItem
&)rTmpSet
.Get( nWhich
);
1295 aBspWin
.SetHdBorder( rItem
);
1300 nWhich
= GetWhich( SID_ATTR_PAGE_FOOTERSET
);
1302 if ( rSet
.GetItemState( nWhich
, sal_False
) == SFX_ITEM_SET
)
1304 const SvxSetItem
& rSetItem
=
1305 (const SvxSetItem
&)rSet
.Get( nWhich
, sal_False
);
1306 const SfxItemSet
& rTmpSet
= rSetItem
.GetItemSet();
1307 const SfxBoolItem
& rOn
=
1308 (const SfxBoolItem
&)rTmpSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
1310 if ( rOn
.GetValue() )
1312 nWhich
= GetWhich( SID_ATTR_BRUSH
);
1314 if ( rTmpSet
.GetItemState( nWhich
) == SFX_ITEM_SET
)
1316 const SvxBrushItem
& rItem
=
1317 (const SvxBrushItem
&)rTmpSet
.Get( nWhich
);
1318 aBspWin
.SetFtColor( rItem
.GetColor() );
1320 nWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
1322 if ( rTmpSet
.GetItemState( nWhich
) == SFX_ITEM_SET
)
1324 const SvxBoxItem
& rItem
=
1325 (const SvxBoxItem
&)rTmpSet
.Get( nWhich
);
1326 aBspWin
.SetFtBorder( rItem
);
1331 const SfxPoolItem
* pItem
= GetItem( rSet
, SID_ATTR_BRUSH
);
1335 aBspWin
.SetColor( ( (const SvxBrushItem
*)pItem
)->GetColor() );
1336 const Graphic
* pGrf
= ( (const SvxBrushItem
*)pItem
)->GetGraphic();
1340 Bitmap aBitmap
= pGrf
->GetBitmap();
1341 aBspWin
.SetBitmap( &aBitmap
);
1344 aBspWin
.SetBitmap( NULL
);
1347 pItem
= GetItem( rSet
, SID_ATTR_BORDER_OUTER
);
1350 aBspWin
.SetBorder( (SvxBoxItem
&)*pItem
);
1353 // -----------------------------------------------------------------------
1355 void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet
& rSet
)
1357 bLandscape
= aLandscapeBtn
.IsChecked();
1358 const SfxPoolItem
* pItem
= GetItem( rSet
, SID_ATTR_PAGE_SIZE
);
1361 aBspWin
.SetSize( ( (const SvxSizeItem
*)pItem
)->GetSize() );
1363 const SvxSetItem
* pSetItem
= 0;
1365 // Kopfzeilen-Attribute auswerten
1367 if ( SFX_ITEM_SET
==
1368 rSet
.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET
),
1369 sal_False
, (const SfxPoolItem
**)&pSetItem
) )
1371 const SfxItemSet
& rHeaderSet
= pSetItem
->GetItemSet();
1372 const SfxBoolItem
& rHeaderOn
=
1373 (const SfxBoolItem
&)rHeaderSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
1375 if ( rHeaderOn
.GetValue() )
1377 const SvxSizeItem
& rSize
= (const SvxSizeItem
&)
1378 rHeaderSet
.Get( GetWhich( SID_ATTR_PAGE_SIZE
) );
1379 const SvxULSpaceItem
& rUL
= (const SvxULSpaceItem
&)
1380 rHeaderSet
.Get( GetWhich( SID_ATTR_ULSPACE
) );
1381 long nDist
= rUL
.GetLower();
1382 aBspWin
.SetHdHeight( rSize
.GetSize().Height() - nDist
);
1383 aBspWin
.SetHdDist( nDist
);
1384 const SvxLRSpaceItem
& rLR
= (const SvxLRSpaceItem
&)
1385 rHeaderSet
.Get( GetWhich( SID_ATTR_LRSPACE
) );
1386 aBspWin
.SetHdLeft( rLR
.GetLeft() );
1387 aBspWin
.SetHdRight( rLR
.GetRight() );
1388 aBspWin
.SetHeader( sal_True
);
1391 aBspWin
.SetHeader( sal_False
);
1393 // im Beispiel Hintergrund und Umrandung anzeigen
1394 sal_uInt16 nWhich
= GetWhich( SID_ATTR_BRUSH
);
1396 if ( rHeaderSet
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
1398 const SvxBrushItem
& rItem
=
1399 (const SvxBrushItem
&)rHeaderSet
.Get( nWhich
);
1400 aBspWin
.SetHdColor( rItem
.GetColor() );
1402 nWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
1404 if ( rHeaderSet
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
1406 const SvxBoxItem
& rItem
=
1407 (const SvxBoxItem
&)rHeaderSet
.Get( nWhich
);
1408 aBspWin
.SetHdBorder( rItem
);
1412 // Fusszeilen-Attribute auswerten
1414 if ( SFX_ITEM_SET
==
1415 rSet
.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET
),
1416 sal_False
, (const SfxPoolItem
**)&pSetItem
) )
1418 const SfxItemSet
& rFooterSet
= pSetItem
->GetItemSet();
1419 const SfxBoolItem
& rFooterOn
=
1420 (const SfxBoolItem
&)rFooterSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
1422 if ( rFooterOn
.GetValue() )
1424 const SvxSizeItem
& rSize
= (const SvxSizeItem
&)
1425 rFooterSet
.Get( GetWhich( SID_ATTR_PAGE_SIZE
) );
1426 const SvxULSpaceItem
& rUL
= (const SvxULSpaceItem
&)
1427 rFooterSet
.Get( GetWhich( SID_ATTR_ULSPACE
) );
1428 long nDist
= rUL
.GetUpper();
1429 aBspWin
.SetFtHeight( rSize
.GetSize().Height() - nDist
);
1430 aBspWin
.SetFtDist( nDist
);
1431 const SvxLRSpaceItem
& rLR
= (const SvxLRSpaceItem
&)
1432 rFooterSet
.Get( GetWhich( SID_ATTR_LRSPACE
) );
1433 aBspWin
.SetFtLeft( rLR
.GetLeft() );
1434 aBspWin
.SetFtRight( rLR
.GetRight() );
1435 aBspWin
.SetFooter( sal_True
);
1438 aBspWin
.SetFooter( sal_False
);
1440 // im Beispiel Hintergrund und Umrandung anzeigen
1441 sal_uInt16 nWhich
= GetWhich( SID_ATTR_BRUSH
);
1443 if ( rFooterSet
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
1445 const SvxBrushItem
& rItem
=
1446 (const SvxBrushItem
&)rFooterSet
.Get( nWhich
);
1447 aBspWin
.SetFtColor( rItem
.GetColor() );
1449 nWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
1451 if ( rFooterSet
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
1453 const SvxBoxItem
& rItem
=
1454 (const SvxBoxItem
&)rFooterSet
.Get( nWhich
);
1455 aBspWin
.SetFtBorder( rItem
);
1460 // -----------------------------------------------------------------------
1462 void SvxPageDescPage::ActivatePage( const SfxItemSet
& rSet
)
1464 InitHeadFoot_Impl( rSet
);
1465 ResetBackground_Impl( rSet
);
1469 // -----------------------------------------------------------------------
1471 int SvxPageDescPage::DeactivatePage( SfxItemSet
* _pSet
)
1473 // Abfrage, ob die Seitenr"ander ausserhalb des Druckbereichs liegen
1474 // Wenn nicht, dann den Anwender fragen, ob sie "ubernommen werden sollen.
1475 // Wenn nicht, dann auf der TabPage bleiben.
1476 sal_uInt16 nPos
= aPaperSizeBox
.GetSelectEntryPos();
1477 Paper ePaper
= (Paper
)(sal_uLong
)aPaperSizeBox
.GetEntryData( nPos
);
1479 if ( ePaper
!= PAPER_SCREEN
&& IsMarginOutOfRange() )
1481 if ( QueryBox( this, WB_YES_NO
| WB_DEF_NO
, aPrintRangeQueryText
).Execute() == RET_NO
)
1483 MetricField
* pField
= NULL
;
1484 if ( IsPrinterRangeOverflow( aLeftMarginEdit
, nFirstLeftMargin
, nLastLeftMargin
, MARGIN_LEFT
) )
1485 pField
= &aLeftMarginEdit
;
1486 if ( IsPrinterRangeOverflow( aRightMarginEdit
, nFirstRightMargin
, nLastRightMargin
, MARGIN_RIGHT
)
1488 pField
= &aRightMarginEdit
;
1489 if ( IsPrinterRangeOverflow( aTopMarginEdit
, nFirstTopMargin
, nLastTopMargin
, MARGIN_TOP
)
1491 pField
= &aTopMarginEdit
;
1492 if ( IsPrinterRangeOverflow( aBottomMarginEdit
, nFirstBottomMargin
, nLastBottomMargin
, MARGIN_BOTTOM
)
1494 pField
= &aBottomMarginEdit
;
1496 pField
->GrabFocus();
1497 UpdateExample_Impl();
1501 CheckMarginEdits( false );
1506 FillItemSet( *_pSet
);
1508 // ggf. hoch/quer putten
1509 sal_uInt16 nWh
= GetWhich( SID_ATTR_PAGE_SIZE
);
1510 SfxMapUnit eUnit
= GetItemSet().GetPool()->GetMetric( nWh
);
1511 Size
aSize( GetCoreValue( aPaperWidthEdit
, eUnit
),
1512 GetCoreValue( aPaperHeightEdit
, eUnit
) );
1514 // putten, wenn aktuelle Gr"o/se unterschiedlich zum Wert in _pSet
1515 const SvxSizeItem
* pSize
= (const SvxSizeItem
*)GetItem( *_pSet
, SID_ATTR_PAGE_SIZE
);
1516 if ( aSize
.Width() && ( !pSize
|| !IsEqualSize_Impl( pSize
, aSize
) ) )
1517 _pSet
->Put( SvxSizeItem( nWh
, aSize
) );
1523 // -----------------------------------------------------------------------
1525 IMPL_LINK( SvxPageDescPage
, RangeHdl_Impl
, Edit
*, EMPTYARG
)
1527 // Aktuelle Header-Breite/H"ohe aus dem Bsp
1528 long nHHeight
= aBspWin
.GetHdHeight();
1529 long nHDist
= aBspWin
.GetHdDist();
1531 // Aktuelle Footer-Breite/H"ohe aus dem Bsp
1532 long nFHeight
= aBspWin
.GetFtHeight();
1533 long nFDist
= aBspWin
.GetFtDist();
1535 // Aktuelle Header/Footer-R"ander aus dem Bsp
1536 long nHFLeft
= Max( aBspWin
.GetHdLeft(), aBspWin
.GetFtLeft() );
1537 long nHFRight
= Max( aBspWin
.GetHdRight(), aBspWin
.GetFtRight() );
1539 // Aktuelle Werte der Seitenr"ander
1540 long nBT
= static_cast<long>(aTopMarginEdit
.Denormalize(aTopMarginEdit
.GetValue(FUNIT_TWIP
)));
1541 long nBB
= static_cast<long>(aBottomMarginEdit
.Denormalize(aBottomMarginEdit
.GetValue(FUNIT_TWIP
)));
1542 long nBL
= static_cast<long>(aLeftMarginEdit
.Denormalize(aLeftMarginEdit
.GetValue(FUNIT_TWIP
)));
1543 long nBR
= static_cast<long>(aRightMarginEdit
.Denormalize(aRightMarginEdit
.GetValue(FUNIT_TWIP
)));
1545 // Breite Umrandung der Seite berechnen
1546 const SfxItemSet
* _pSet
= &GetItemSet();
1549 if ( _pSet
->GetItemState( GetWhich(SID_ATTR_BORDER_SHADOW
) ) >=
1550 SFX_ITEM_AVAILABLE
&&
1551 _pSet
->GetItemState( GetWhich(SID_ATTR_BORDER_OUTER
) ) >=
1552 SFX_ITEM_AVAILABLE
)
1554 aBorder
= ( GetMinBorderSpace_Impl(
1555 (const SvxShadowItem
&)_pSet
->Get(GetWhich(SID_ATTR_BORDER_SHADOW
)),
1556 (const SvxBoxItem
&)_pSet
->Get(GetWhich(SID_ATTR_BORDER_OUTER
))));
1559 long nH
= static_cast<long>(aPaperHeightEdit
.Denormalize(aPaperHeightEdit
.GetValue(FUNIT_TWIP
)));
1560 long nW
= static_cast<long>(aPaperWidthEdit
.Denormalize(aPaperWidthEdit
.GetValue(FUNIT_TWIP
)));
1563 // Maximum liegt bei 54cm
1565 long nMin
= nHHeight
+ nHDist
+ nFDist
+ nFHeight
+ nBT
+ nBB
+
1566 MINBODY
+ aBorder
.Height();
1567 aPaperHeightEdit
.SetMin(aPaperHeightEdit
.Normalize(nMin
), FUNIT_TWIP
);
1569 nMin
= MINBODY
+ nBL
+ nBR
+ aBorder
.Width();
1570 aPaperWidthEdit
.SetMin(aPaperWidthEdit
.Normalize(nMin
), FUNIT_TWIP
);
1572 // Falls sich die Papiergr"o\se ge"adert hat
1573 nH
= static_cast<long>(aPaperHeightEdit
.Denormalize(aPaperHeightEdit
.GetValue(FUNIT_TWIP
)));
1574 nW
= static_cast<long>(aPaperWidthEdit
.Denormalize(aPaperWidthEdit
.GetValue(FUNIT_TWIP
)));
1577 long nMax
= nH
- nBB
- aBorder
.Height() - MINBODY
-
1578 nFDist
- nFHeight
- nHDist
- nHHeight
;
1580 aTopMarginEdit
.SetMax(aTopMarginEdit
.Normalize(nMax
), FUNIT_TWIP
);
1583 nMax
= nH
- nBT
- aBorder
.Height() - MINBODY
-
1584 nFDist
- nFHeight
- nHDist
- nHHeight
;
1586 aBottomMarginEdit
.SetMax(aTopMarginEdit
.Normalize(nMax
), FUNIT_TWIP
);
1589 nMax
= nW
- nBR
- MINBODY
- aBorder
.Width() - nHFLeft
- nHFRight
;
1590 aLeftMarginEdit
.SetMax(aLeftMarginEdit
.Normalize(nMax
), FUNIT_TWIP
);
1593 nMax
= nW
- nBL
- MINBODY
- aBorder
.Width() - nHFLeft
- nHFRight
;
1594 aRightMarginEdit
.SetMax(aRightMarginEdit
.Normalize(nMax
), FUNIT_TWIP
);
1598 // -----------------------------------------------------------------------
1600 void SvxPageDescPage::CalcMargin_Impl()
1602 // Aktuelle Werte der Seitenr"ander
1603 long nBT
= GetCoreValue( aTopMarginEdit
, SFX_MAPUNIT_TWIP
);
1604 long nBB
= GetCoreValue( aBottomMarginEdit
, SFX_MAPUNIT_TWIP
);
1606 long nBL
= GetCoreValue( aLeftMarginEdit
, SFX_MAPUNIT_TWIP
);
1607 long nBR
= GetCoreValue( aRightMarginEdit
, SFX_MAPUNIT_TWIP
);
1609 long nH
= GetCoreValue( aPaperHeightEdit
, SFX_MAPUNIT_TWIP
);
1610 long nW
= GetCoreValue( aPaperWidthEdit
, SFX_MAPUNIT_TWIP
);
1612 long nWidth
= nBL
+ nBR
+ MINBODY
;
1613 long nHeight
= nBT
+ nBB
+ MINBODY
;
1615 if ( nWidth
> nW
|| nHeight
> nH
)
1619 long nTmp
= nBL
<= nBR
? nBR
: nBL
;
1620 nTmp
-= nWidth
- nW
;
1623 SetMetricValue( aRightMarginEdit
, nTmp
, SFX_MAPUNIT_TWIP
);
1625 SetMetricValue( aLeftMarginEdit
, nTmp
, SFX_MAPUNIT_TWIP
);
1630 long nTmp
= nBT
<= nBB
? nBB
: nBT
;
1631 nTmp
-= nHeight
- nH
;
1634 SetMetricValue( aBottomMarginEdit
, nTmp
, SFX_MAPUNIT_TWIP
);
1636 SetMetricValue( aTopMarginEdit
, nTmp
, SFX_MAPUNIT_TWIP
);
1641 // -----------------------------------------------------------------------
1643 IMPL_LINK_INLINE_START( SvxPageDescPage
, CenterHdl_Impl
, CheckBox
*, EMPTYARG
)
1645 aBspWin
.SetHorz( aHorzBox
.IsChecked() );
1646 aBspWin
.SetVert( aVertBox
.IsChecked() );
1647 UpdateExample_Impl();
1650 IMPL_LINK_INLINE_END( SvxPageDescPage
, CenterHdl_Impl
, CheckBox
*, EMPTYARG
)
1652 // -----------------------------------------------------------------------
1654 void SvxPageDescPage::SetCollectionList(const List
* pList
)
1656 sStandardRegister
= *(String
*)pList
->GetObject(0);
1657 for( sal_uInt16 i
= 1; i
< pList
->Count(); i
++ )
1659 aRegisterLB
.InsertEntry(*(String
*)pList
->GetObject(i
));
1662 aRegisterCB
.Show();
1663 aRegisterFT
.Show();
1665 aRegisterCB
.SetClickHdl(LINK(this, SvxPageDescPage
, RegisterModify
));
1668 // -----------------------------------------------------------------------
1670 IMPL_LINK( SvxPageDescPage
, RegisterModify
, CheckBox
*, pBox
)
1672 sal_Bool bEnable
= sal_False
;
1673 if(pBox
->IsChecked())
1676 if(USHRT_MAX
== aRegisterLB
.GetSelectEntryPos())
1677 aRegisterLB
.SelectEntry(sStandardRegister
);
1679 aRegisterFT
.Enable( bEnable
);
1680 aRegisterLB
.Enable( bEnable
);
1684 // ----------------------------------------------------------------------------
1686 void SvxPageDescPage::DisableVerticalPageDir()
1688 aTextFlowBox
.RemoveEntryValue( FRMDIR_VERT_TOP_RIGHT
);
1689 aTextFlowBox
.RemoveEntryValue( FRMDIR_VERT_TOP_LEFT
);
1690 if( aTextFlowBox
.GetEntryCount() < 2 )
1692 aTextFlowLbl
.Hide();
1693 aTextFlowBox
.Hide();
1694 aBspWin
.EnableFrameDirection( sal_False
);
1698 IMPL_LINK( SvxPageDescPage
, FrameDirectionModify_Impl
, ListBox
*, EMPTYARG
)
1700 aBspWin
.SetFrameDirection( (sal_uInt32
) aTextFlowBox
.GetSelectEntryValue() );
1701 aBspWin
.Invalidate();
1705 bool SvxPageDescPage::IsPrinterRangeOverflow(
1706 MetricField
& rField
, long nFirstMargin
, long nLastMargin
, MarginPosition nPos
)
1709 bool bCheck
= ( ( pImpl
->m_nPos
& nPos
) == 0 );
1710 long nValue
= static_cast<long>(rField
.GetValue());
1712 ( nValue
< nFirstMargin
|| nValue
> nLastMargin
) &&
1713 rField
.GetText() != rField
.GetSavedValue() )
1715 rField
.SetValue( nValue
< nFirstMargin
? nFirstMargin
: nLastMargin
);
1722 /** Check if a value of a margin edit is outside the printer paper margins
1723 and save this information.
1725 void SvxPageDescPage::CheckMarginEdits( bool _bClear
)
1730 sal_Int64 nValue
= aLeftMarginEdit
.GetValue();
1731 if ( nValue
< nFirstLeftMargin
|| nValue
> nLastLeftMargin
)
1732 pImpl
->m_nPos
|= MARGIN_LEFT
;
1733 nValue
= aRightMarginEdit
.GetValue();
1734 if ( nValue
< nFirstRightMargin
|| nValue
> nLastRightMargin
)
1735 pImpl
->m_nPos
|= MARGIN_RIGHT
;
1736 nValue
= aTopMarginEdit
.GetValue();
1737 if ( nValue
< nFirstTopMargin
|| nValue
> nLastTopMargin
)
1738 pImpl
->m_nPos
|= MARGIN_TOP
;
1739 nValue
= aBottomMarginEdit
.GetValue();
1740 if ( nValue
< nFirstBottomMargin
|| nValue
> nLastBottomMargin
)
1741 pImpl
->m_nPos
|= MARGIN_BOTTOM
;
1744 bool SvxPageDescPage::IsMarginOutOfRange()
1746 bool bRet
= ( ( ( !( pImpl
->m_nPos
& MARGIN_LEFT
) &&
1747 ( aLeftMarginEdit
.GetText() != aLeftMarginEdit
.GetSavedValue() ) ) &&
1748 ( aLeftMarginEdit
.GetValue() < nFirstLeftMargin
||
1749 aLeftMarginEdit
.GetValue() > nLastLeftMargin
) ) ||
1750 ( ( !( pImpl
->m_nPos
& MARGIN_RIGHT
) &&
1751 ( aRightMarginEdit
.GetText() != aRightMarginEdit
.GetSavedValue() ) ) &&
1752 ( aRightMarginEdit
.GetValue() < nFirstRightMargin
||
1753 aRightMarginEdit
.GetValue() > nLastRightMargin
) ) ||
1754 ( ( !( pImpl
->m_nPos
& MARGIN_TOP
) &&
1755 ( aTopMarginEdit
.GetText() != aTopMarginEdit
.GetSavedValue() ) ) &&
1756 ( aTopMarginEdit
.GetValue() < nFirstTopMargin
||
1757 aTopMarginEdit
.GetValue() > nLastTopMargin
) ) ||
1758 ( ( !( pImpl
->m_nPos
& MARGIN_BOTTOM
) &&
1759 ( aBottomMarginEdit
.GetText() != aBottomMarginEdit
.GetSavedValue() ) ) &&
1760 ( aBottomMarginEdit
.GetValue() < nFirstBottomMargin
||
1761 aBottomMarginEdit
.GetValue() > nLastBottomMargin
) ) );
1765 void SvxPageDescPage::PageCreated (SfxAllItemSet aSet
) //add CHINA001
1767 SFX_ITEMSET_ARG (&aSet
,pModeItem
,SfxAllEnumItem
,SID_ENUM_PAGE_MODE
,sal_False
);
1768 SFX_ITEMSET_ARG (&aSet
,pPaperStartItem
,SfxAllEnumItem
,SID_PAPER_START
,sal_False
);
1769 SFX_ITEMSET_ARG (&aSet
,pPaperEndItem
,SfxAllEnumItem
,SID_PAPER_END
,sal_False
);
1770 SFX_ITEMSET_ARG (&aSet
,pCollectListItem
,SfxStringListItem
,SID_COLLECT_LIST
,sal_False
);
1772 SetMode((SvxModeType
)pModeItem
->GetEnumValue());
1773 if (pPaperStartItem
&& pPaperEndItem
)
1774 SetPaperFormatRanges( (Paper
)pPaperStartItem
->GetEnumValue(), (Paper
)pPaperEndItem
->GetEnumValue() );
1775 if (pCollectListItem
)
1776 SetCollectionList(pCollectListItem
->GetList());