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