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