1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_cui.hxx" 24 25 // include --------------------------------------------------------------- 26 #include <sfx2/app.hxx> 27 #include <sfx2/objsh.hxx> 28 #include <tools/resary.hxx> 29 #include <vcl/graph.hxx> 30 #include <sfx2/viewsh.hxx> 31 #include <svl/itemiter.hxx> 32 #include <svl/languageoptions.hxx> 33 #include <vcl/msgbox.hxx> 34 #include <unotools/configitem.hxx> 35 #include "svx/htmlmode.hxx" 36 37 #define _SVX_PAGE_CXX 38 39 #include <cuires.hrc> 40 #include "page.hrc" 41 #include "helpid.hrc" 42 #include "page.hxx" 43 #include <svx/pageitem.hxx> 44 #include <editeng/brshitem.hxx> 45 #include <editeng/boxitem.hxx> 46 #include <editeng/shaditem.hxx> 47 #include <editeng/pbinitem.hxx> 48 #include <editeng/lrspitem.hxx> 49 #include <editeng/ulspitem.hxx> 50 #include <editeng/sizeitem.hxx> 51 #include <editeng/frmdiritem.hxx> 52 #include "svx/dlgutil.hxx" 53 #include <dialmgr.hxx> 54 #include <editeng/paperinf.hxx> 55 #include <dialmgr.hxx> 56 #include <sfx2/module.hxx> 57 #include <svl/stritem.hxx> 58 #include <svx/dialogs.hrc> // for RID_SVXPAGE_PAGE 59 #include <editeng/eerdll.hxx> 60 #include <editeng/editrids.hrc> // for RID_SVXSTR_PAPERBIN..., 61 #include <svx/svxids.hrc> 62 #include <svtools/optionsdrawinglayer.hxx> 63 #include <svl/slstitm.hxx> //CHINA001 64 #include <svl/aeitem.hxx> //CHINA001 65 #include <sfx2/request.hxx> //CHINA001 66 67 //UUUU 68 #include <svx/xdef.hxx> 69 #include <svx/unobrushitemhelper.hxx> 70 71 // configuration helper ======================================================= 72 73 /** Helper to get a configuration setting. 74 @descr This is a HACK to get a configuration item directly. Normally the 75 OfaHtmlOptions class from 'offmgr' project would do the job, but we cannot 76 use it here. On the other hand, the OfaHtmlOptions cannot be moved to 77 'svtools', because it uses 'svx' itself... 78 The correct way would be to move OfaHtmlOptions to 'svtools' anyway, and to 79 remove the dependency from 'svx' (a call to the static function 80 SvxTextEncodingBox::GetBestMimeEncoding(), which contains low level 81 operations that can be moved to lower projects, i.e. 'rtl'). Then this 82 class can be removed, and the OfaHtmlOptions can be used instead. */ 83 class SvxHtmlExportModeConfigItem_Impl : public utl::ConfigItem 84 { 85 public: 86 explicit SvxHtmlExportModeConfigItem_Impl(); 87 88 /** Returns the HTML export mode, as read from the configuration. */ 89 inline sal_Int32 GetExportMode() const { return mnExpMode; } 90 91 /** Returns true, if the current HTML export mode is set to HTML 3.2. */ 92 inline bool IsExportModeHTML32() const { return mnExpMode == 0; } // 0 == HTML_CFG_HTML32, see offmgr/htmlcfg.hxx 93 94 virtual void Commit(); 95 virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames); 96 97 private: 98 sal_Int32 mnExpMode; 99 }; 100 101 SvxHtmlExportModeConfigItem_Impl::SvxHtmlExportModeConfigItem_Impl() : 102 utl::ConfigItem( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/HTML/Export" ) ) ), 103 mnExpMode( 3 ) // default to 3 == HTML_CFG_NS40, see offmgr/htmlcfg.hxx 104 { 105 using com::sun::star::uno::Sequence; 106 using com::sun::star::uno::Any; 107 108 Sequence< rtl::OUString > aPropNames( 1 ); 109 aPropNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Browser" ) ); 110 Sequence< Any > aPropValues( GetProperties( aPropNames ) ); 111 if( aPropValues.getLength() == 1 ) 112 aPropValues[ 0 ] >>= mnExpMode; 113 } 114 115 void SvxHtmlExportModeConfigItem_Impl::Commit() 116 { 117 } 118 119 void SvxHtmlExportModeConfigItem_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& ) 120 { 121 } 122 123 // static ---------------------------------------------------------------- 124 125 static const long MINBODY = 284; // 0,5cm in twips aufgerundet 126 //static const long PRINT_OFFSET = 17; // 0,03cm in twips abgerundet 127 static const long PRINT_OFFSET = 0; // why was this ever set to 17 ? it led to wrong right and bottom margins. 128 129 static sal_uInt16 pRanges[] = 130 { 131 SID_ATTR_BORDER_OUTER, 132 SID_ATTR_BORDER_SHADOW, 133 SID_ATTR_LRSPACE, 134 SID_ATTR_PAGE_SHARED, 135 SID_SWREGISTER_COLLECTION, 136 SID_SWREGISTER_MODE, 137 0 138 }; 139 140 // ------- Mapping Seitenlayout ------------------------------------------ 141 142 sal_uInt16 aArr[] = 143 { 144 SVX_PAGE_ALL, 145 SVX_PAGE_MIRROR, 146 SVX_PAGE_RIGHT, 147 SVX_PAGE_LEFT 148 }; 149 150 // ----------------------------------------------------------------------- 151 152 sal_uInt16 PageUsageToPos_Impl( sal_uInt16 nUsage ) 153 { 154 const sal_uInt16 nCount = sizeof(aArr) / sizeof(sal_uInt16); 155 156 for ( sal_uInt16 i = 0; i < nCount; ++i ) 157 if ( aArr[i] == ( nUsage & 0x000f ) ) 158 return i; 159 return SVX_PAGE_ALL; 160 } 161 162 // ----------------------------------------------------------------------- 163 164 sal_uInt16 PosToPageUsage_Impl( sal_uInt16 nPos ) 165 { 166 const sal_uInt16 nCount = sizeof(aArr) / sizeof(sal_uInt16); 167 168 if ( nPos >= nCount ) 169 return 0; 170 return aArr[nPos]; 171 } 172 173 // ----------------------------------------------------------------------- 174 175 Size GetMinBorderSpace_Impl( const SvxShadowItem& rShadow, const SvxBoxItem& rBox ) 176 { 177 Size aSz; 178 aSz.Height() = rShadow.CalcShadowSpace( SHADOW_BOTTOM ) + rBox.CalcLineSpace( BOX_LINE_BOTTOM ); 179 aSz.Height() += rShadow.CalcShadowSpace( SHADOW_TOP ) + rBox.CalcLineSpace( BOX_LINE_TOP ); 180 aSz.Width() = rShadow.CalcShadowSpace( SHADOW_LEFT ) + rBox.CalcLineSpace( BOX_LINE_LEFT ); 181 aSz.Width() += rShadow.CalcShadowSpace( SHADOW_RIGHT ) + rBox.CalcLineSpace( BOX_LINE_RIGHT ); 182 return aSz; 183 } 184 185 // ----------------------------------------------------------------------- 186 187 long ConvertLong_Impl( const long nIn, SfxMapUnit eUnit ) 188 { 189 return OutputDevice::LogicToLogic( nIn, (MapUnit)eUnit, MAP_TWIP ); 190 } 191 192 sal_Bool IsEqualSize_Impl( const SvxSizeItem* pSize, const Size& rSize ) 193 { 194 if ( pSize ) 195 { 196 Size aSize = pSize->GetSize(); 197 long nDiffW = Abs( rSize.Width () - aSize.Width () ); 198 long nDiffH = Abs( rSize.Height() - aSize.Height() ); 199 return ( nDiffW < 10 && nDiffH < 10 ); 200 } 201 else 202 return sal_False; 203 } 204 205 // ----------------------------------------------------------------------- 206 207 #define MARGIN_LEFT ( (MarginPosition)0x0001 ) 208 #define MARGIN_RIGHT ( (MarginPosition)0x0002 ) 209 #define MARGIN_TOP ( (MarginPosition)0x0004 ) 210 #define MARGIN_BOTTOM ( (MarginPosition)0x0008 ) 211 212 //UUUU 213 //struct SvxPage_Impl 214 //{ 215 // MarginPosition m_nPos; 216 // Printer* mpDefPrinter; 217 // bool mbDelPrinter; 218 // 219 // SvxPage_Impl() : 220 // m_nPos( 0 ), 221 // mpDefPrinter( 0 ), 222 // mbDelPrinter( false ) {} 223 // 224 // ~SvxPage_Impl() { if ( mbDelPrinter ) delete mpDefPrinter; } 225 //}; 226 227 // class SvxPageDescPage -------------------------------------------------- 228 229 // gibt den Bereich der Which-Werte zur"uck 230 231 sal_uInt16* SvxPageDescPage::GetRanges() 232 { 233 return pRanges; 234 } 235 236 // ----------------------------------------------------------------------- 237 238 SfxTabPage* SvxPageDescPage::Create( Window* pParent, const SfxItemSet& rSet ) 239 { 240 return new SvxPageDescPage( pParent, rSet ); 241 } 242 243 // ----------------------------------------------------------------------- 244 245 SvxPageDescPage::SvxPageDescPage( Window* pParent, const SfxItemSet& rAttr ) 246 : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_PAGE ), rAttr ), 247 aPaperSizeFl ( this, CUI_RES( FL_PAPER_SIZE ) ), 248 aPaperFormatText ( this, CUI_RES( FT_PAPER_FORMAT ) ), 249 aPaperSizeBox ( this, CUI_RES( LB_PAPER_SIZE ) ), 250 aPaperWidthText ( this, CUI_RES( FT_PAPER_WIDTH ) ), 251 aPaperWidthEdit ( this, CUI_RES( ED_PAPER_WIDTH ) ), 252 aPaperHeightText ( this, CUI_RES( FT_PAPER_HEIGHT ) ), 253 aPaperHeightEdit ( this, CUI_RES( ED_PAPER_HEIGHT ) ), 254 aOrientationFT ( this, CUI_RES( FT_ORIENTATION ) ), 255 aPortraitBtn ( this, CUI_RES( RB_PORTRAIT ) ), 256 aLandscapeBtn ( this, CUI_RES( RB_LANDSCAPE ) ), 257 aBspWin ( this, CUI_RES( WN_BSP ) ), 258 aTextFlowLbl ( this, CUI_RES( FT_TEXT_FLOW ) ), 259 aTextFlowBox ( this, CUI_RES( LB_TEXT_FLOW ) ), 260 aPaperTrayLbl ( this, CUI_RES( FT_PAPER_TRAY ) ), 261 aPaperTrayBox ( this, CUI_RES( LB_PAPER_TRAY ) ), 262 aMarginFl ( this, CUI_RES( FL_MARGIN ) ), 263 aLeftMarginLbl ( this, CUI_RES( FT_LEFT_MARGIN ) ), 264 aLeftMarginEdit ( this, CUI_RES( ED_LEFT_MARGIN ) ), 265 aRightMarginLbl ( this, CUI_RES( FT_RIGHT_MARGIN ) ), 266 aRightMarginEdit ( this, CUI_RES( ED_RIGHT_MARGIN ) ), 267 aTopMarginLbl ( this, CUI_RES( FT_TOP_MARGIN ) ), 268 aTopMarginEdit ( this, CUI_RES( ED_TOP_MARGIN ) ), 269 aBottomMarginLbl ( this, CUI_RES( FT_BOTTOM_MARGIN ) ), 270 aBottomMarginEdit ( this, CUI_RES( ED_BOTTOM_MARGIN ) ), 271 aBottomSeparatorFl ( this, CUI_RES( FL_BOTTOM_SEP ) ), 272 aLayoutFL ( this, CUI_RES( FL_LAYOUT ) ), 273 aPageText ( this, CUI_RES( FT_PAGELAYOUT ) ), 274 aLayoutBox ( this, CUI_RES( LB_LAYOUT ) ), 275 aNumberFormatText ( this, CUI_RES( FT_NUMBER_FORMAT ) ), 276 aNumberFormatBox ( this, CUI_RES( LB_NUMBER_FORMAT ) ), 277 aTblAlignFT ( this, CUI_RES( FT_TBL_ALIGN ) ), 278 aHorzBox ( this, CUI_RES( CB_HORZ ) ), 279 aVertBox ( this, CUI_RES( CB_VERT ) ), 280 aAdaptBox ( this, CUI_RES( CB_ADAPT ) ), 281 aRegisterCB ( this, CUI_RES( CB_REGISTER ) ), 282 aRegisterFT ( this, CUI_RES( FT_REGISTER ) ), 283 aRegisterLB ( this, CUI_RES( LB_REGISTER ) ), 284 285 aInsideText ( CUI_RES( STR_INSIDE ) ), 286 aOutsideText ( CUI_RES( STR_OUTSIDE ) ), 287 aPrintRangeQueryText( CUI_RES( STR_QUERY_PRINTRANGE ) ), 288 289 bLandscape ( sal_False ), 290 eMode ( SVX_PAGE_MODE_STANDARD ), 291 ePaperStart ( PAPER_A3 ), 292 ePaperEnd ( PAPER_ENV_DL ), 293 294 //UUUU 295 // pImpl ( new SvxPage_Impl ), 296 297 //UUUU 298 m_nPos( 0 ), 299 mpDefPrinter( 0 ), 300 mbDelPrinter( false ), 301 302 //UUUU 303 mbEnableDrawingLayerFillStyles(false) 304 { 305 bBorderModified = sal_False; 306 FreeResource(); 307 aBspWin.EnableRTL( sal_False ); 308 309 // diese Page braucht ExchangeSupport 310 SetExchangeSupport(); 311 312 SvtLanguageOptions aLangOptions; 313 sal_Bool bCJK = aLangOptions.IsAsianTypographyEnabled(); 314 sal_Bool bCTL = aLangOptions.IsCTLFontEnabled(); 315 sal_Bool bWeb = sal_False; 316 const SfxPoolItem* pItem; 317 318 SfxObjectShell* pShell; 319 if(SFX_ITEM_SET == rAttr.GetItemState(SID_HTML_MODE, sal_False, &pItem) || 320 ( 0 != (pShell = SfxObjectShell::Current()) && 321 0 != (pItem = pShell->GetItem(SID_HTML_MODE)))) 322 bWeb = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON); 323 324 // #109989# get the HTML export setting from configuration. 325 // !! This is a hack, see comments in SvxHtmlExportModeConfigItem_Impl class above. 326 bool bHTML32 = SvxHtmlExportModeConfigItem_Impl().IsExportModeHTML32(); 327 328 // fill text flow listbox with valid entries 329 aTextFlowBox.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_HORI ), FRMDIR_HORI_LEFT_TOP ); 330 if( bCTL ) 331 aTextFlowBox.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_HORI ), FRMDIR_HORI_RIGHT_TOP ); 332 // #109989# do not show vertical directions in Writer/Web 333 if( !bWeb ) 334 { 335 if( bCJK ) 336 { 337 aTextFlowBox.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_VERT ), FRMDIR_VERT_TOP_RIGHT ); 338 // aTextFlowBox.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_VERT ), FRMDIR_VERT_TOP_LEFT ); 339 } 340 } 341 342 // #109989# show the text direction box in Writer/Web too, but only, if HTML export mode is not HTML3.2. 343 if( !(bWeb && bHTML32) && (bCJK || bCTL) && 344 SFX_ITEM_UNKNOWN < rAttr.GetItemState(GetWhich( SID_ATTR_FRAMEDIRECTION ))) 345 { 346 aTextFlowLbl.Show(); 347 aTextFlowBox.Show(); 348 aTextFlowBox.SetSelectHdl(LINK(this, SvxPageDescPage, FrameDirectionModify_Impl )); 349 350 aBspWin.EnableFrameDirection(sal_True); 351 } 352 Init_Impl(); 353 354 FieldUnit eFUnit = GetModuleFieldUnit( rAttr ); 355 SetFieldUnit( aLeftMarginEdit, eFUnit ); 356 SetFieldUnit( aRightMarginEdit, eFUnit ); 357 SetFieldUnit( aTopMarginEdit, eFUnit ); 358 SetFieldUnit( aBottomMarginEdit, eFUnit ); 359 SetFieldUnit( aPaperWidthEdit, eFUnit ); 360 SetFieldUnit( aPaperHeightEdit, eFUnit ); 361 362 if ( SfxViewShell::Current() && SfxViewShell::Current()->GetPrinter() ) 363 { 364 mpDefPrinter = (Printer*)SfxViewShell::Current()->GetPrinter(); 365 } 366 else 367 { 368 mpDefPrinter = new Printer; 369 mbDelPrinter = true; 370 } 371 372 MapMode aOldMode = mpDefPrinter->GetMapMode(); 373 mpDefPrinter->SetMapMode( MAP_TWIP ); 374 375 // First- und Last-Werte f"ur die R"ander setzen 376 Size aPaperSize = mpDefPrinter->GetPaperSize(); 377 Size aPrintSize = mpDefPrinter->GetOutputSize(); 378 /* 379 * einen Punkt ( 0,0 ) in logische Koordinaten zu konvertieren, 380 * sieht aus wie Unsinn; ist aber sinnvoll, wenn der Ursprung des 381 * Koordinatensystems verschoben ist. 382 */ 383 Point aPrintOffset = mpDefPrinter->GetPageOffset() - mpDefPrinter->PixelToLogic( Point() ); 384 mpDefPrinter->SetMapMode( aOldMode ); 385 386 long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET; 387 aLeftMarginEdit.SetFirst( aLeftMarginEdit.Normalize( aPrintOffset.X() ), FUNIT_TWIP ); 388 nFirstLeftMargin = static_cast<long>(aLeftMarginEdit.GetFirst()); 389 aRightMarginEdit.SetFirst( aRightMarginEdit.Normalize( 390 aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset ), FUNIT_TWIP); 391 nFirstRightMargin = static_cast<long>(aRightMarginEdit.GetFirst()); 392 aTopMarginEdit.SetFirst( aTopMarginEdit.Normalize( aPrintOffset.Y() ), FUNIT_TWIP ); 393 nFirstTopMargin = static_cast<long>(aTopMarginEdit.GetFirst()); 394 aBottomMarginEdit.SetFirst( aBottomMarginEdit.Normalize( 395 aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset ), FUNIT_TWIP ); 396 nFirstBottomMargin = static_cast<long>(aBottomMarginEdit.GetFirst()); 397 aLeftMarginEdit.SetLast( aLeftMarginEdit.Normalize( 398 aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP ); 399 nLastLeftMargin = static_cast<long>(aLeftMarginEdit.GetLast()); 400 aRightMarginEdit.SetLast( aRightMarginEdit.Normalize( 401 aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP ); 402 nLastRightMargin = static_cast<long>(aRightMarginEdit.GetLast()); 403 aTopMarginEdit.SetLast( aTopMarginEdit.Normalize( 404 aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP ); 405 nLastTopMargin = static_cast<long>(aTopMarginEdit.GetLast()); 406 aBottomMarginEdit.SetLast( aBottomMarginEdit.Normalize( 407 aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP ); 408 nLastBottomMargin = static_cast<long>(aBottomMarginEdit.GetLast()); 409 410 // #i4219# get DrawingLayer options 411 const SvtOptionsDrawinglayer aDrawinglayerOpt; 412 413 // #i4219# take Maximum now from configuration (1/100th cm) 414 // was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000 415 aPaperWidthEdit.SetMax(aPaperWidthEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM); 416 aPaperWidthEdit.SetLast(aPaperWidthEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM); 417 aPaperHeightEdit.SetMax(aPaperHeightEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM); 418 aPaperHeightEdit.SetLast(aPaperHeightEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM); 419 420 // #i4219# also for margins (1/100th cm). Was: 9999, keeping. 421 aLeftMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperLeftMargin()); 422 aLeftMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperLeftMargin()); 423 aRightMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperRightMargin()); 424 aRightMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperRightMargin()); 425 aTopMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperTopMargin()); 426 aTopMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperTopMargin()); 427 aBottomMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperBottomMargin()); 428 aBottomMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperBottomMargin()); 429 430 aPortraitBtn.SetAccessibleRelationMemberOf(&aOrientationFT); 431 aLandscapeBtn.SetAccessibleRelationMemberOf(&aOrientationFT); 432 } 433 434 // ----------------------------------------------------------------------- 435 436 SvxPageDescPage::~SvxPageDescPage() 437 { 438 if(mbDelPrinter) 439 { 440 delete mpDefPrinter; 441 } 442 } 443 444 // ----------------------------------------------------------------------- 445 446 void SvxPageDescPage::Init_Impl() 447 { 448 aLeftText = aLeftMarginLbl.GetText(); 449 aRightText = aRightMarginLbl.GetText(); 450 451 // Handler einstellen 452 aLayoutBox.SetSelectHdl( LINK( this, SvxPageDescPage, LayoutHdl_Impl ) ); 453 aPaperSizeBox.SetDropDownLineCount(10); 454 455 aPaperTrayBox.SetGetFocusHdl( 456 LINK( this, SvxPageDescPage, PaperBinHdl_Impl ) ); 457 aPaperSizeBox.SetSelectHdl( 458 LINK( this, SvxPageDescPage, PaperSizeSelect_Impl ) ); 459 aPaperWidthEdit.SetModifyHdl( 460 LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) ); 461 aPaperHeightEdit.SetModifyHdl( 462 LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) ); 463 aLandscapeBtn.SetClickHdl( 464 LINK( this, SvxPageDescPage, SwapOrientation_Impl ) ); 465 aPortraitBtn.SetClickHdl( 466 LINK( this, SvxPageDescPage, SwapOrientation_Impl ) ); 467 468 Link aLink = LINK( this, SvxPageDescPage, BorderModify_Impl ); 469 aLeftMarginEdit.SetModifyHdl( aLink ); 470 aRightMarginEdit.SetModifyHdl( aLink ); 471 aTopMarginEdit.SetModifyHdl( aLink ); 472 aBottomMarginEdit.SetModifyHdl( aLink ); 473 474 aLink = LINK( this, SvxPageDescPage, RangeHdl_Impl ); 475 aPaperWidthEdit.SetLoseFocusHdl( aLink ); 476 aPaperHeightEdit.SetLoseFocusHdl( aLink ); 477 aLeftMarginEdit.SetLoseFocusHdl( aLink ); 478 aRightMarginEdit.SetLoseFocusHdl( aLink ); 479 aTopMarginEdit.SetLoseFocusHdl( aLink ); 480 aBottomMarginEdit.SetLoseFocusHdl( aLink ); 481 482 aHorzBox.SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) ); 483 aVertBox.SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) ); 484 485 } 486 487 // ----------------------------------------------------------------------- 488 489 void SvxPageDescPage::Reset( const SfxItemSet& rSet ) 490 { 491 SfxItemPool* pPool = rSet.GetPool(); 492 DBG_ASSERT( pPool, "Wo ist der Pool" ); 493 SfxMapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ); 494 495 // R"ander (Links/Rechts) einstellen 496 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_LRSPACE ); 497 498 if ( pItem ) 499 { 500 const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)*pItem; 501 SetMetricValue( aLeftMarginEdit, rLRSpace.GetLeft(), eUnit ); 502 aBspWin.SetLeft( 503 (sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetLeft(), eUnit ) ); 504 SetMetricValue( aRightMarginEdit, rLRSpace.GetRight(), eUnit ); 505 aBspWin.SetRight( 506 (sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetRight(), eUnit ) ); 507 } 508 509 // R"ander (Oben/Unten) einstellen 510 pItem = GetItem( rSet, SID_ATTR_ULSPACE ); 511 512 if ( pItem ) 513 { 514 const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)*pItem; 515 SetMetricValue( aTopMarginEdit, rULSpace.GetUpper(), eUnit ); 516 aBspWin.SetTop( 517 (sal_uInt16)ConvertLong_Impl( (long)rULSpace.GetUpper(), eUnit ) ); 518 SetMetricValue( aBottomMarginEdit, rULSpace.GetLower(), eUnit ); 519 aBspWin.SetBottom( 520 (sal_uInt16)ConvertLong_Impl( (long)rULSpace.GetLower(), eUnit ) ); 521 } 522 523 // allgemeine Seitendaten 524 SvxNumType eNumType = SVX_ARABIC; 525 bLandscape = ( mpDefPrinter->GetOrientation() == ORIENTATION_LANDSCAPE ); 526 sal_uInt16 nUse = (sal_uInt16)SVX_PAGE_ALL; 527 pItem = GetItem( rSet, SID_ATTR_PAGE ); 528 529 if ( pItem ) 530 { 531 const SvxPageItem& rItem = (const SvxPageItem&)*pItem; 532 eNumType = rItem.GetNumType(); 533 nUse = rItem.GetPageUsage(); 534 bLandscape = rItem.IsLandscape(); 535 } 536 537 // Ausrichtung 538 aLayoutBox.SelectEntryPos( ::PageUsageToPos_Impl( nUse ) ); 539 aBspWin.SetUsage( nUse ); 540 LayoutHdl_Impl( 0 ); 541 542 // Numerierungsart der Seitenvorlage einstellen 543 aNumberFormatBox.SelectEntryPos( sal::static_int_cast< sal_uInt16 >(eNumType) ); 544 545 // Aktueller Papierschacht 546 aPaperTrayBox.Clear(); 547 sal_uInt8 nPaperBin = PAPERBIN_PRINTER_SETTINGS; 548 pItem = GetItem( rSet, SID_ATTR_PAGE_PAPERBIN ); 549 550 if ( pItem ) 551 { 552 nPaperBin = ( (const SvxPaperBinItem*)pItem )->GetValue(); 553 554 if ( nPaperBin >= mpDefPrinter->GetPaperBinCount() ) 555 nPaperBin = PAPERBIN_PRINTER_SETTINGS; 556 } 557 558 String aBinName; 559 560 if ( PAPERBIN_PRINTER_SETTINGS == nPaperBin ) 561 aBinName = EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS ); 562 else 563 aBinName = mpDefPrinter->GetPaperBinName( (sal_uInt16)nPaperBin ); 564 565 sal_uInt16 nEntryPos = aPaperTrayBox.InsertEntry( aBinName ); 566 aPaperTrayBox.SetEntryData( nEntryPos, (void*)(sal_uLong)nPaperBin ); 567 aPaperTrayBox.SelectEntry( aBinName ); 568 569 // Size rausholen 570 Size aPaperSize = SvxPaperInfo::GetPaperSize( mpDefPrinter ); 571 pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE ); 572 573 if ( pItem ) 574 aPaperSize = ( (const SvxSizeItem*)pItem )->GetSize(); 575 576 FASTBOOL bOrientationSupport = 577 mpDefPrinter->HasSupport( SUPPORT_SET_ORIENTATION ); 578 #ifdef OS2 579 // unter OS/2 wird bei HasSupport() immer sal_True returned 580 // aber nur als Dummy, deshalb FALSE 581 bOrientationSupport = sal_False; 582 #endif 583 584 if ( !bOrientationSupport && 585 aPaperSize.Width() > aPaperSize.Height() ) 586 bLandscape = sal_True; 587 588 aLandscapeBtn.Check( bLandscape ); 589 aPortraitBtn.Check( !bLandscape ); 590 591 aBspWin.SetSize( Size( ConvertLong_Impl( aPaperSize.Width(), eUnit ), 592 ConvertLong_Impl( aPaperSize.Height(), eUnit ) ) ); 593 594 aPaperSize = OutputDevice::LogicToLogic(aPaperSize, (MapUnit)eUnit, MAP_100TH_MM); 595 if ( bLandscape ) 596 Swap( aPaperSize ); 597 598 // Actual Paper Format 599 Paper ePaper = SvxPaperInfo::GetSvxPaper( aPaperSize, MAP_100TH_MM, sal_True ); 600 601 if ( PAPER_USER != ePaper ) 602 aPaperSize = SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM ); 603 604 if ( bLandscape ) 605 Swap( aPaperSize ); 606 607 // Werte in die Edits eintragen 608 SetMetricValue( aPaperHeightEdit, aPaperSize.Height(), SFX_MAPUNIT_100TH_MM ); 609 SetMetricValue( aPaperWidthEdit, aPaperSize.Width(), SFX_MAPUNIT_100TH_MM ); 610 aPaperSizeBox.Clear(); 611 612 sal_uInt16 nActPos = LISTBOX_ENTRY_NOTFOUND; 613 sal_uInt16 nAryId = RID_SVXSTRARY_PAPERSIZE_STD; 614 615 if ( ePaperStart != PAPER_A3 ) 616 nAryId = RID_SVXSTRARY_PAPERSIZE_DRAW; 617 ResStringArray aPaperAry( CUI_RES( nAryId ) ); 618 sal_uInt32 nCnt = aPaperAry.Count(); 619 620 sal_uInt16 nUserPos = LISTBOX_ENTRY_NOTFOUND; 621 for ( sal_uInt32 i = 0; i < nCnt; ++i ) 622 { 623 String aStr = aPaperAry.GetString(i); 624 Paper eSize = (Paper)aPaperAry.GetValue(i); 625 sal_uInt16 nPos = aPaperSizeBox.InsertEntry( aStr ); 626 aPaperSizeBox.SetEntryData( nPos, (void*)(sal_uLong)eSize ); 627 628 if ( eSize == ePaper ) 629 nActPos = nPos; 630 if( eSize == PAPER_USER ) 631 nUserPos = nPos; 632 } 633 // preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead 634 aPaperSizeBox.SelectEntryPos( nActPos != LISTBOX_ENTRY_NOTFOUND ? nActPos : nUserPos ); 635 636 // Applikationsspezifisch 637 638 switch ( eMode ) 639 { 640 case SVX_PAGE_MODE_CENTER: 641 { 642 aTblAlignFT.Show(); 643 aHorzBox.Show(); 644 aVertBox.Show(); 645 DisableVerticalPageDir(); 646 647 // Horizontale Ausrichtung 648 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 ); 649 aHorzBox.Check( pItem ? ( (const SfxBoolItem*)pItem )->GetValue() 650 : sal_False ); 651 652 // Vertikale Ausrichtung 653 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 ); 654 aVertBox.Check( pItem ? ( (const SfxBoolItem*)pItem )->GetValue() 655 : sal_False ); 656 657 // Beispiel-Fenster auf Tabelle setzen 658 aBspWin.SetTable( sal_True ); 659 aBspWin.SetHorz( aHorzBox.IsChecked() ); 660 aBspWin.SetVert( aVertBox.IsChecked() ); 661 662 break; 663 } 664 665 case SVX_PAGE_MODE_PRESENTATION: 666 { 667 DisableVerticalPageDir(); 668 aAdaptBox.Show(); 669 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 ); 670 aAdaptBox.Check( pItem ? 671 ( (const SfxBoolItem*)pItem )->GetValue() : sal_False ); 672 673 //!!! hidden, weil von StarDraw nicht implementiert 674 aLayoutBox.Hide(); 675 aPageText.Hide(); 676 677 break; 678 } 679 default: ;//prevent warning 680 } 681 682 683 // im Beispiel Hintergrund und Umrandung anzeigen 684 ResetBackground_Impl( rSet ); 685 //! UpdateExample_Impl(); 686 RangeHdl_Impl( 0 ); 687 688 // Header Footer anzeigen 689 InitHeadFoot_Impl( rSet ); 690 691 // R"ander auf Hoch/Quer updaten, dann Beispiel updaten 692 bBorderModified = sal_False; 693 SwapFirstValues_Impl( sal_False ); 694 UpdateExample_Impl(); 695 696 // Alte Werte sichern 697 aLeftMarginEdit.SaveValue(); 698 aRightMarginEdit.SaveValue(); 699 aTopMarginEdit.SaveValue(); 700 aBottomMarginEdit.SaveValue(); 701 aLayoutBox.SaveValue(); 702 aNumberFormatBox.SaveValue(); 703 aPaperSizeBox.SaveValue(); 704 aPaperWidthEdit.SaveValue(); 705 aPaperHeightEdit.SaveValue(); 706 aPortraitBtn.SaveValue(); 707 aLandscapeBtn.SaveValue(); 708 aPaperTrayBox.SaveValue(); 709 aVertBox.SaveValue(); 710 aHorzBox.SaveValue(); 711 aAdaptBox.SaveValue(); 712 713 CheckMarginEdits( true ); 714 715 // Registerhaltigkeit 716 if(SFX_ITEM_SET == rSet.GetItemState(SID_SWREGISTER_MODE)) 717 { 718 aRegisterCB.Check(((const SfxBoolItem&)rSet.Get( 719 SID_SWREGISTER_MODE)).GetValue()); 720 aRegisterCB.SaveValue(); 721 RegisterModify(&aRegisterCB); 722 } 723 if(SFX_ITEM_SET == rSet.GetItemState(SID_SWREGISTER_COLLECTION)) 724 { 725 aRegisterLB.SelectEntry( 726 ((const SfxStringItem&)rSet.Get(SID_SWREGISTER_COLLECTION)).GetValue()); 727 aRegisterLB.SaveValue(); 728 } 729 730 SfxItemState eState = rSet.GetItemState( GetWhich( SID_ATTR_FRAMEDIRECTION ), 731 sal_True, &pItem ); 732 if( SFX_ITEM_UNKNOWN != eState ) 733 { 734 sal_uInt32 nVal = SFX_ITEM_SET == eState 735 ? ((SvxFrameDirectionItem*)pItem)->GetValue() 736 : 0; 737 aTextFlowBox.SelectEntryValue( static_cast< SvxFrameDirection >( nVal ) ); 738 aTextFlowBox.SaveValue(); 739 aBspWin.SetFrameDirection(nVal); 740 } 741 } 742 743 // ----------------------------------------------------------------------- 744 745 void SvxPageDescPage::FillUserData() 746 { 747 if ( SVX_PAGE_MODE_PRESENTATION == eMode ) 748 SetUserData( UniString::CreateFromInt32( (sal_Int32)aAdaptBox.IsChecked() ) ); 749 } 750 751 // ----------------------------------------------------------------------- 752 753 sal_Bool SvxPageDescPage::FillItemSet( SfxItemSet& rSet ) 754 { 755 sal_Bool bModified = sal_False; 756 const SfxItemSet& rOldSet = GetItemSet(); 757 SfxItemPool* pPool = rOldSet.GetPool(); 758 DBG_ASSERT( pPool, "Wo ist der Pool" ); 759 sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE ); 760 SfxMapUnit eUnit = pPool->GetMetric( nWhich ); 761 const SfxPoolItem* pOld = 0; 762 763 // alten linken und rechten Rand kopieren 764 SvxLRSpaceItem aMargin( (const SvxLRSpaceItem&)rOldSet.Get( nWhich ) ); 765 766 // alten oberen und unteren Rand kopieren 767 nWhich = GetWhich( SID_ATTR_ULSPACE ); 768 SvxULSpaceItem aTopMargin( (const SvxULSpaceItem&)rOldSet.Get( nWhich ) ); 769 770 if ( aLeftMarginEdit.GetText() != aLeftMarginEdit.GetSavedValue() ) 771 { 772 aMargin.SetLeft( (sal_uInt16)GetCoreValue( aLeftMarginEdit, eUnit ) ); 773 bModified |= sal_True; 774 } 775 776 if ( aRightMarginEdit.GetText() != aRightMarginEdit.GetSavedValue() ) 777 { 778 aMargin.SetRight( (sal_uInt16)GetCoreValue( aRightMarginEdit, eUnit ) ); 779 bModified |= sal_True; 780 } 781 782 // Linken und rechten Rand setzen 783 if ( bModified ) 784 { 785 pOld = GetOldItem( rSet, SID_ATTR_LRSPACE ); 786 787 if ( !pOld || !( *(const SvxLRSpaceItem*)pOld == aMargin ) ) 788 rSet.Put( aMargin ); 789 else 790 bModified = sal_False; 791 } 792 793 sal_Bool bMod = sal_False; 794 795 if ( aTopMarginEdit.GetText() != aTopMarginEdit.GetSavedValue() ) 796 { 797 aTopMargin.SetUpper( (sal_uInt16)GetCoreValue( aTopMarginEdit, eUnit ) ); 798 bMod |= sal_True; 799 } 800 801 if ( aBottomMarginEdit.GetText() != aBottomMarginEdit.GetSavedValue() ) 802 { 803 aTopMargin.SetLower( (sal_uInt16)GetCoreValue( aBottomMarginEdit, eUnit ) ); 804 bMod |= sal_True; 805 } 806 807 // unteren oberen Rand setzen 808 // 809 if ( bMod ) 810 { 811 pOld = GetOldItem( rSet, SID_ATTR_ULSPACE ); 812 813 if ( !pOld || !( *(const SvxULSpaceItem*)pOld == aTopMargin ) ) 814 { 815 bModified |= sal_True; 816 rSet.Put( aTopMargin ); 817 } 818 } 819 820 // Druckerschacht 821 nWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN ); 822 sal_uInt16 nPos = aPaperTrayBox.GetSelectEntryPos(); 823 sal_uInt16 nBin = (sal_uInt16)(sal_uLong)aPaperTrayBox.GetEntryData( nPos ); 824 pOld = GetOldItem( rSet, SID_ATTR_PAGE_PAPERBIN ); 825 826 if ( !pOld || ( (const SvxPaperBinItem*)pOld )->GetValue() != nBin ) 827 { 828 rSet.Put( SvxPaperBinItem( nWhich, (sal_uInt8)nBin ) ); 829 bModified |= sal_True; 830 } 831 832 nPos = aPaperSizeBox.GetSelectEntryPos(); 833 Paper ePaper = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData( nPos ); 834 const sal_uInt16 nOld = aPaperSizeBox.GetSavedValue(); 835 sal_Bool bChecked = aLandscapeBtn.IsChecked(); 836 837 if ( PAPER_USER == ePaper ) 838 { 839 if ( nOld != nPos || 840 aPaperWidthEdit.IsValueModified() || 841 aPaperHeightEdit.IsValueModified() || 842 bChecked != aLandscapeBtn.GetSavedValue() ) 843 { 844 Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ), 845 GetCoreValue( aPaperHeightEdit, eUnit ) ); 846 pOld = GetOldItem( rSet, SID_ATTR_PAGE_SIZE ); 847 848 if ( !pOld || ( (const SvxSizeItem*)pOld )->GetSize() != aSize ) 849 { 850 rSet.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) ); 851 bModified |= sal_True; 852 } 853 } 854 } 855 else 856 { 857 if ( nOld != nPos || bChecked != aLandscapeBtn.GetSavedValue() ) 858 { 859 Size aSize( SvxPaperInfo::GetPaperSize( ePaper, (MapUnit)eUnit ) ); 860 861 if ( bChecked ) 862 Swap( aSize ); 863 864 pOld = GetOldItem( rSet, SID_ATTR_PAGE_SIZE ); 865 866 if ( !pOld || ( (const SvxSizeItem*)pOld )->GetSize() != aSize ) 867 { 868 rSet.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) ); 869 bModified |= sal_True; 870 } 871 } 872 } 873 874 // sonstiges Zeug der Page 875 nWhich = GetWhich( SID_ATTR_PAGE ); 876 SvxPageItem aPage( (const SvxPageItem&)rOldSet.Get( nWhich ) ); 877 bMod = aLayoutBox.GetSelectEntryPos() != aLayoutBox.GetSavedValue(); 878 879 if ( bMod ) 880 aPage.SetPageUsage( 881 ::PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() ) ); 882 883 if ( bChecked != aLandscapeBtn.GetSavedValue() ) 884 { 885 aPage.SetLandscape(bChecked); 886 bMod |= sal_True; 887 } 888 889 // Einstellen der Numerierungsart der Seite 890 nPos = aNumberFormatBox.GetSelectEntryPos(); 891 892 if ( nPos != aNumberFormatBox.GetSavedValue() ) 893 { 894 aPage.SetNumType( (SvxNumType)nPos ); 895 bMod |= sal_True; 896 } 897 898 if ( bMod ) 899 { 900 pOld = GetOldItem( rSet, SID_ATTR_PAGE ); 901 902 if ( !pOld || !( *(const SvxPageItem*)pOld == aPage ) ) 903 { 904 rSet.Put( aPage ); 905 bModified |= sal_True; 906 } 907 } 908 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich ) ) 909 rSet.ClearItem( nWhich ); 910 else 911 rSet.Put( rOldSet.Get( nWhich ) ); 912 913 // Modispezifische Controls auswerten 914 915 switch ( eMode ) 916 { 917 case SVX_PAGE_MODE_CENTER: 918 { 919 if ( aHorzBox.IsChecked() != aHorzBox.GetSavedValue() ) 920 { 921 SfxBoolItem aHorz( GetWhich( SID_ATTR_PAGE_EXT1 ), 922 aHorzBox.IsChecked() ); 923 rSet.Put( aHorz ); 924 bModified |= sal_True; 925 } 926 927 if ( aVertBox.IsChecked() != aVertBox.GetSavedValue() ) 928 { 929 SfxBoolItem aVert( GetWhich( SID_ATTR_PAGE_EXT2 ), 930 aVertBox.IsChecked() ); 931 rSet.Put( aVert ); 932 bModified |= sal_True; 933 } 934 break; 935 } 936 937 case SVX_PAGE_MODE_PRESENTATION: 938 { 939 // immer putten, damit Draw das auswerten kann 940 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_PAGE_EXT1 ), 941 aAdaptBox.IsChecked() ) ); 942 bModified |= sal_True; 943 break; 944 } 945 default: ;//prevent warning 946 947 } 948 949 if(aRegisterCB.IsVisible() && 950 (aRegisterCB.IsChecked() || aRegisterCB.GetSavedValue() != aRegisterCB.IsChecked())) 951 { 952 const SfxBoolItem& rRegItem = (const SfxBoolItem&)rOldSet.Get(SID_SWREGISTER_MODE); 953 SfxBoolItem* pRegItem = (SfxBoolItem*)rRegItem.Clone(); 954 sal_Bool bCheck = aRegisterCB.IsChecked(); 955 pRegItem->SetValue(bCheck); 956 rSet.Put(*pRegItem); 957 bModified |= sal_True; 958 if(bCheck) 959 { 960 bModified |= sal_True; 961 rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, 962 aRegisterLB.GetSelectEntry())); 963 } 964 delete pRegItem; 965 } 966 967 SvxFrameDirection eDirection = aTextFlowBox.GetSelectEntryValue(); 968 if( aTextFlowBox.IsVisible() && (eDirection != aTextFlowBox.GetSavedValue()) ) 969 { 970 rSet.Put( SvxFrameDirectionItem( eDirection, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) ); 971 bModified = sal_True; 972 } 973 974 return bModified; 975 } 976 977 // ----------------------------------------------------------------------- 978 979 IMPL_LINK( SvxPageDescPage, LayoutHdl_Impl, ListBox *, EMPTYARG ) 980 { 981 // innen au\sen umschalten 982 const sal_uInt16 nPos = PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() ); 983 984 if ( nPos == SVX_PAGE_MIRROR ) 985 { 986 if ( aLeftMarginLbl.GetText() != aInsideText ) 987 aLeftMarginLbl.SetText( aInsideText ); 988 989 if ( aRightMarginLbl.GetText() != aOutsideText ) 990 aRightMarginLbl.SetText( aOutsideText ); 991 } 992 else 993 { 994 if ( aLeftMarginLbl.GetText() != aLeftText ) 995 aLeftMarginLbl.SetText( aLeftText ); 996 997 if ( aRightMarginLbl.GetText() != aRightText ) 998 aRightMarginLbl.SetText( aRightText ); 999 } 1000 UpdateExample_Impl( true ); 1001 return 0; 1002 } 1003 1004 // ----------------------------------------------------------------------- 1005 1006 IMPL_LINK( SvxPageDescPage, PaperBinHdl_Impl, ListBox *, EMPTYARG ) 1007 { 1008 if ( aPaperTrayBox.GetEntryCount() > 1 ) 1009 // schon gef"ullt 1010 return 0; 1011 1012 // Schacht-Box initialisieren 1013 String aOldName = aPaperTrayBox.GetSelectEntry(); 1014 aPaperTrayBox.SetUpdateMode( sal_False ); 1015 aPaperTrayBox.Clear(); 1016 sal_uInt16 nEntryPos = aPaperTrayBox.InsertEntry( 1017 EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS ) ); 1018 aPaperTrayBox.SetEntryData( nEntryPos, 1019 (void*)(sal_uLong)PAPERBIN_PRINTER_SETTINGS ); 1020 String aPaperBin( EditResId( RID_SVXSTR_PAPERBIN ) ); 1021 sal_uInt16 nBinCount = mpDefPrinter->GetPaperBinCount(); 1022 1023 for ( sal_uInt16 i = 0; i < nBinCount; ++i ) 1024 { 1025 String aName = mpDefPrinter->GetPaperBinName(i); 1026 1027 if ( !aName.Len() ) 1028 { 1029 aName = aPaperBin; 1030 aName.Append( sal_Unicode(' ') ); 1031 aName.Append( UniString::CreateFromInt32( i+1 ) ); 1032 } 1033 nEntryPos = aPaperTrayBox.InsertEntry( aName ); 1034 aPaperTrayBox.SetEntryData( nEntryPos, (void*)(sal_uLong)i ); 1035 } 1036 aPaperTrayBox.SelectEntry( aOldName ); 1037 aPaperTrayBox.SetUpdateMode( sal_True ); 1038 1039 return 0; 1040 } 1041 1042 // ----------------------------------------------------------------------- 1043 1044 IMPL_LINK( SvxPageDescPage, PaperSizeSelect_Impl, ListBox *, pBox ) 1045 { 1046 const sal_uInt16 nPos = pBox->GetSelectEntryPos(); 1047 Paper ePaper = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData( nPos ); 1048 1049 if ( ePaper != PAPER_USER ) 1050 { 1051 Size aSize( SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM ) ); 1052 1053 if ( aLandscapeBtn.IsChecked() ) 1054 Swap( aSize ); 1055 1056 if ( aSize.Height() < aPaperHeightEdit.GetMin( FUNIT_100TH_MM ) ) 1057 aPaperHeightEdit.SetMin( 1058 aPaperHeightEdit.Normalize( aSize.Height() ), FUNIT_100TH_MM ); 1059 if ( aSize.Width() < aPaperWidthEdit.GetMin( FUNIT_100TH_MM ) ) 1060 aPaperWidthEdit.SetMin( 1061 aPaperWidthEdit.Normalize( aSize.Width() ), FUNIT_100TH_MM ); 1062 SetMetricValue( aPaperHeightEdit, aSize.Height(), SFX_MAPUNIT_100TH_MM ); 1063 SetMetricValue( aPaperWidthEdit, aSize.Width(), SFX_MAPUNIT_100TH_MM ); 1064 1065 // R"ander ggf. neu berechnen 1066 CalcMargin_Impl(); 1067 1068 RangeHdl_Impl( 0 ); 1069 UpdateExample_Impl( true ); 1070 1071 if ( eMode == SVX_PAGE_MODE_PRESENTATION ) 1072 { 1073 // Draw: bei Papierformat soll der Rand 1cm betragen 1074 long nTmp = 0; 1075 sal_Bool bScreen = ( PAPER_SCREEN == ePaper ); 1076 1077 if ( !bScreen ) 1078 // bei Bildschirm keinen Rand 1079 nTmp = 1; // entspr. 1cm 1080 1081 // Abfragen, ob fuer Raender 0 gesetzt ist: 1082 if ( bScreen || aRightMarginEdit.GetValue() == 0 ) 1083 { 1084 SetMetricValue( aRightMarginEdit, nTmp, SFX_MAPUNIT_CM ); 1085 if ( !bScreen && 1086 aRightMarginEdit.GetFirst() > aRightMarginEdit.GetValue() ) 1087 aRightMarginEdit.SetValue( aRightMarginEdit.GetFirst() ); 1088 } 1089 if ( bScreen || aLeftMarginEdit.GetValue() == 0 ) 1090 { 1091 SetMetricValue( aLeftMarginEdit, nTmp, SFX_MAPUNIT_CM ); 1092 if ( !bScreen && 1093 aLeftMarginEdit.GetFirst() > aLeftMarginEdit.GetValue() ) 1094 aLeftMarginEdit.SetValue( aLeftMarginEdit.GetFirst() ); 1095 } 1096 if ( bScreen || aBottomMarginEdit.GetValue() == 0 ) 1097 { 1098 SetMetricValue( aBottomMarginEdit, nTmp, SFX_MAPUNIT_CM ); 1099 if ( !bScreen && 1100 aBottomMarginEdit.GetFirst() > aBottomMarginEdit.GetValue() ) 1101 aBottomMarginEdit.SetValue( aBottomMarginEdit.GetFirst() ); 1102 } 1103 if ( bScreen || aTopMarginEdit.GetValue() == 0 ) 1104 { 1105 SetMetricValue( aTopMarginEdit, nTmp, SFX_MAPUNIT_CM ); 1106 if ( !bScreen && 1107 aTopMarginEdit.GetFirst() > aTopMarginEdit.GetValue() ) 1108 aTopMarginEdit.SetValue( aTopMarginEdit.GetFirst() ); 1109 } 1110 UpdateExample_Impl( true ); 1111 } 1112 } 1113 return 0; 1114 } 1115 1116 // ----------------------------------------------------------------------- 1117 1118 IMPL_LINK( SvxPageDescPage, PaperSizeModify_Impl, Edit *, EMPTYARG ) 1119 { 1120 sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE ); 1121 SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWhich ); 1122 Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ), 1123 GetCoreValue( aPaperHeightEdit, eUnit ) ); 1124 Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, (MapUnit)eUnit, sal_True ); 1125 sal_uInt16 nEntryCount = aPaperSizeBox.GetEntryCount(); 1126 1127 for ( sal_uInt16 i = 0; i < nEntryCount; ++i ) 1128 { 1129 Paper eTmp = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData(i); 1130 1131 if ( eTmp == ePaper ) 1132 { 1133 aPaperSizeBox.SelectEntryPos(i); 1134 break; 1135 } 1136 } 1137 UpdateExample_Impl( true ); 1138 return 0; 1139 } 1140 1141 // ----------------------------------------------------------------------- 1142 1143 IMPL_LINK( SvxPageDescPage, SwapOrientation_Impl, RadioButton *, pBtn ) 1144 { 1145 if ( 1146 (!bLandscape && pBtn == &aLandscapeBtn) || 1147 (bLandscape && pBtn == &aPortraitBtn) 1148 ) 1149 { 1150 bLandscape = aLandscapeBtn.IsChecked(); 1151 1152 const long lWidth = GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_100TH_MM ); 1153 const long lHeight = GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_100TH_MM ); 1154 1155 // swap with and height 1156 SetMetricValue( aPaperWidthEdit, lHeight, SFX_MAPUNIT_100TH_MM ); 1157 SetMetricValue( aPaperHeightEdit, lWidth, SFX_MAPUNIT_100TH_MM ); 1158 1159 // recalculate margins if necessary 1160 CalcMargin_Impl(); 1161 1162 PaperSizeSelect_Impl( &aPaperSizeBox ); 1163 RangeHdl_Impl( 0 ); 1164 SwapFirstValues_Impl( bBorderModified ); 1165 UpdateExample_Impl( true ); 1166 } 1167 return 0; 1168 } 1169 1170 // ----------------------------------------------------------------------- 1171 1172 void SvxPageDescPage::SwapFirstValues_Impl( FASTBOOL bSet ) 1173 { 1174 MapMode aOldMode = mpDefPrinter->GetMapMode(); 1175 Orientation eOri = ORIENTATION_PORTRAIT; 1176 1177 if ( bLandscape ) 1178 eOri = ORIENTATION_LANDSCAPE; 1179 Orientation eOldOri = mpDefPrinter->GetOrientation(); 1180 mpDefPrinter->SetOrientation( eOri ); 1181 mpDefPrinter->SetMapMode( MAP_TWIP ); 1182 1183 // First- und Last-Werte f"ur die R"ander setzen 1184 Size aPaperSize = mpDefPrinter->GetPaperSize(); 1185 Size aPrintSize = mpDefPrinter->GetOutputSize(); 1186 /* 1187 * einen Punkt ( 0,0 ) in logische Koordinaten zu konvertieren, 1188 * sieht aus wie Unsinn; ist aber sinnvoll, wenn der Ursprung des 1189 * Koordinatensystems verschoben ist. 1190 */ 1191 Point aPrintOffset = mpDefPrinter->GetPageOffset() - mpDefPrinter->PixelToLogic( Point() ); 1192 mpDefPrinter->SetMapMode( aOldMode ); 1193 mpDefPrinter->SetOrientation( eOldOri ); 1194 1195 sal_Int64 nSetL = aLeftMarginEdit.Denormalize( 1196 aLeftMarginEdit.GetValue( FUNIT_TWIP ) ); 1197 sal_Int64 nSetR = aRightMarginEdit.Denormalize( 1198 aRightMarginEdit.GetValue( FUNIT_TWIP ) ); 1199 sal_Int64 nSetT = aTopMarginEdit.Denormalize( 1200 aTopMarginEdit.GetValue( FUNIT_TWIP ) ); 1201 sal_Int64 nSetB = aBottomMarginEdit.Denormalize( 1202 aBottomMarginEdit.GetValue( FUNIT_TWIP ) ); 1203 1204 long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET; 1205 long nNewL = aPrintOffset.X(); 1206 long nNewR = 1207 aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset; 1208 long nNewT = aPrintOffset.Y(); 1209 long nNewB = 1210 aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset; 1211 1212 aLeftMarginEdit.SetFirst( aLeftMarginEdit.Normalize( nNewL ), FUNIT_TWIP ); 1213 nFirstLeftMargin = static_cast<long>(aLeftMarginEdit.GetFirst()); 1214 aRightMarginEdit.SetFirst( aRightMarginEdit.Normalize( nNewR ), FUNIT_TWIP ); 1215 nFirstRightMargin = static_cast<long>(aRightMarginEdit.GetFirst()); 1216 aTopMarginEdit.SetFirst( aTopMarginEdit.Normalize( nNewT ), FUNIT_TWIP ); 1217 nFirstTopMargin = static_cast<long>(aTopMarginEdit.GetFirst()); 1218 aBottomMarginEdit.SetFirst( aBottomMarginEdit.Normalize( nNewB ), FUNIT_TWIP ); 1219 nFirstBottomMargin = static_cast<long>(aBottomMarginEdit.GetFirst()); 1220 1221 if ( bSet ) 1222 { 1223 // ggf. auch die Werte umsetzen, 1224 if ( nSetL < nNewL ) 1225 aLeftMarginEdit.SetValue( aLeftMarginEdit.Normalize( nNewL ), 1226 FUNIT_TWIP ); 1227 if ( nSetR < nNewR ) 1228 aRightMarginEdit.SetValue( aRightMarginEdit.Normalize( nNewR ), 1229 FUNIT_TWIP ); 1230 if ( nSetT < nNewT ) 1231 aTopMarginEdit.SetValue( aTopMarginEdit.Normalize( nNewT ), 1232 FUNIT_TWIP ); 1233 if ( nSetB < nNewB ) 1234 aBottomMarginEdit.SetValue( aBottomMarginEdit.Normalize( nNewB ), 1235 FUNIT_TWIP ); 1236 } 1237 } 1238 1239 // ----------------------------------------------------------------------- 1240 1241 IMPL_LINK_INLINE_START( SvxPageDescPage, BorderModify_Impl, MetricField *, EMPTYARG ) 1242 { 1243 if ( !bBorderModified ) 1244 bBorderModified = sal_True; 1245 UpdateExample_Impl(); 1246 return 0; 1247 } 1248 IMPL_LINK_INLINE_END( SvxPageDescPage, BorderModify_Impl, MetricField *, EMPTYARG ) 1249 1250 // ----------------------------------------------------------------------- 1251 1252 void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground ) 1253 { 1254 // Size 1255 Size aSize( GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_TWIP ), 1256 GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_TWIP ) ); 1257 1258 aBspWin.SetSize( aSize ); 1259 1260 // R"ander 1261 aBspWin.SetTop( GetCoreValue( aTopMarginEdit, SFX_MAPUNIT_TWIP ) ); 1262 aBspWin.SetBottom( GetCoreValue( aBottomMarginEdit, SFX_MAPUNIT_TWIP ) ); 1263 aBspWin.SetLeft( GetCoreValue( aLeftMarginEdit, SFX_MAPUNIT_TWIP ) ); 1264 aBspWin.SetRight( GetCoreValue( aRightMarginEdit, SFX_MAPUNIT_TWIP ) ); 1265 1266 // Layout 1267 aBspWin.SetUsage( PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() ) ); 1268 if ( bResetbackground ) 1269 aBspWin.ResetBackground(); 1270 aBspWin.Invalidate(); 1271 } 1272 1273 // ----------------------------------------------------------------------- 1274 1275 void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet& rSet) 1276 { 1277 sal_uInt16 nWhich(GetWhich(SID_ATTR_PAGE_HEADERSET)); 1278 1279 if(SFX_ITEM_SET == rSet.GetItemState(nWhich, sal_False)) 1280 { 1281 const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, sal_False)); 1282 const SfxItemSet& rTmpSet = rSetItem.GetItemSet(); 1283 const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON))); 1284 1285 if(rOn.GetValue()) 1286 { 1287 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes; 1288 1289 if(mbEnableDrawingLayerFillStyles) 1290 { 1291 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1292 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet)); 1293 } 1294 else 1295 { 1296 nWhich = GetWhich(SID_ATTR_BRUSH); 1297 1298 if(SFX_ITEM_SET == rTmpSet.GetItemState(nWhich)) 1299 { 1300 //UUUU create FillAttributes from SvxBrushItem 1301 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich)); 1302 SfxItemSet aTempSet(*rTmpSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1303 1304 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1305 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1306 } 1307 } 1308 1309 aBspWin.setHeaderFillAttributes(aHeaderFillAttributes); 1310 nWhich = GetWhich(SID_ATTR_BORDER_OUTER); 1311 1312 if(rTmpSet.GetItemState(nWhich) == SFX_ITEM_SET) 1313 { 1314 const SvxBoxItem& rItem = static_cast< const SvxBoxItem& >(rTmpSet.Get(nWhich)); 1315 aBspWin.SetHdBorder(rItem); 1316 } 1317 } 1318 } 1319 1320 nWhich = GetWhich(SID_ATTR_PAGE_FOOTERSET); 1321 1322 if(SFX_ITEM_SET == rSet.GetItemState(nWhich, sal_False)) 1323 { 1324 const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich,sal_False)); 1325 const SfxItemSet& rTmpSet = rSetItem.GetItemSet(); 1326 const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON))); 1327 1328 if(rOn.GetValue()) 1329 { 1330 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes; 1331 1332 if(mbEnableDrawingLayerFillStyles) 1333 { 1334 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1335 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet)); 1336 } 1337 else 1338 { 1339 nWhich = GetWhich(SID_ATTR_BRUSH); 1340 1341 if(SFX_ITEM_SET == rTmpSet.GetItemState(nWhich)) 1342 { 1343 //UUUU create FillAttributes from SvxBrushItem 1344 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich)); 1345 SfxItemSet aTempSet(*rTmpSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1346 1347 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1348 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1349 } 1350 } 1351 1352 aBspWin.setFooterFillAttributes(aFooterFillAttributes); 1353 nWhich = GetWhich(SID_ATTR_BORDER_OUTER); 1354 1355 if(rTmpSet.GetItemState(nWhich) == SFX_ITEM_SET) 1356 { 1357 const SvxBoxItem& rItem = static_cast< const SvxBoxItem& >(rTmpSet.Get(nWhich)); 1358 aBspWin.SetFtBorder(rItem); 1359 } 1360 } 1361 } 1362 1363 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aPageFillAttributes; 1364 const SfxPoolItem* pItem = 0; 1365 1366 if(mbEnableDrawingLayerFillStyles) 1367 { 1368 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1369 aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rSet)); 1370 } 1371 else 1372 { 1373 pItem = GetItem(rSet, SID_ATTR_BRUSH); 1374 1375 if(pItem) 1376 { 1377 //UUUU create FillAttributes from SvxBrushItem 1378 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(*pItem); 1379 SfxItemSet aTempSet(*rSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1380 1381 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1382 aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1383 } 1384 } 1385 1386 aBspWin.setPageFillAttributes(aPageFillAttributes); 1387 pItem = GetItem(rSet, SID_ATTR_BORDER_OUTER); 1388 1389 if(pItem) 1390 { 1391 aBspWin.SetBorder(static_cast< const SvxBoxItem& >(*pItem)); 1392 } 1393 } 1394 1395 // ----------------------------------------------------------------------- 1396 1397 void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet ) 1398 { 1399 bLandscape = aLandscapeBtn.IsChecked(); 1400 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE ); 1401 1402 if ( pItem ) 1403 aBspWin.SetSize( ( (const SvxSizeItem*)pItem )->GetSize() ); 1404 1405 const SvxSetItem* pSetItem = 0; 1406 1407 // Kopfzeilen-Attribute auswerten 1408 1409 if ( SFX_ITEM_SET == 1410 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ), 1411 sal_False, (const SfxPoolItem**)&pSetItem ) ) 1412 { 1413 const SfxItemSet& rHeaderSet = pSetItem->GetItemSet(); 1414 const SfxBoolItem& rHeaderOn = 1415 (const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ); 1416 1417 if ( rHeaderOn.GetValue() ) 1418 { 1419 const SvxSizeItem& rSize = (const SvxSizeItem&) 1420 rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ); 1421 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&) 1422 rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) ); 1423 long nDist = rUL.GetLower(); 1424 aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist ); 1425 aBspWin.SetHdDist( nDist ); 1426 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&) 1427 rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); 1428 aBspWin.SetHdLeft( rLR.GetLeft() ); 1429 aBspWin.SetHdRight( rLR.GetRight() ); 1430 aBspWin.SetHeader( sal_True ); 1431 } 1432 else 1433 aBspWin.SetHeader( sal_False ); 1434 1435 // im Beispiel Hintergrund und Umrandung anzeigen 1436 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes; 1437 1438 if(mbEnableDrawingLayerFillStyles) 1439 { 1440 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1441 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rHeaderSet)); 1442 } 1443 else 1444 { 1445 const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH)); 1446 1447 if(rHeaderSet.GetItemState(nWhich) >= SFX_ITEM_AVAILABLE) 1448 { 1449 //UUUU aBspWin.SetHdColor(rItem.GetColor()); 1450 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rHeaderSet.Get(nWhich)); 1451 SfxItemSet aTempSet(*rHeaderSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1452 1453 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1454 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1455 } 1456 } 1457 1458 aBspWin.setHeaderFillAttributes(aHeaderFillAttributes); 1459 const sal_uInt16 nWhich(GetWhich(SID_ATTR_BORDER_OUTER)); 1460 1461 if ( rHeaderSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE ) 1462 { 1463 const SvxBoxItem& rItem = 1464 (const SvxBoxItem&)rHeaderSet.Get( nWhich ); 1465 aBspWin.SetHdBorder( rItem ); 1466 } 1467 } 1468 1469 // Fusszeilen-Attribute auswerten 1470 1471 if ( SFX_ITEM_SET == 1472 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ), 1473 sal_False, (const SfxPoolItem**)&pSetItem ) ) 1474 { 1475 const SfxItemSet& rFooterSet = pSetItem->GetItemSet(); 1476 const SfxBoolItem& rFooterOn = 1477 (const SfxBoolItem&)rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ); 1478 1479 if ( rFooterOn.GetValue() ) 1480 { 1481 const SvxSizeItem& rSize = (const SvxSizeItem&) 1482 rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ); 1483 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&) 1484 rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) ); 1485 long nDist = rUL.GetUpper(); 1486 aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist ); 1487 aBspWin.SetFtDist( nDist ); 1488 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&) 1489 rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); 1490 aBspWin.SetFtLeft( rLR.GetLeft() ); 1491 aBspWin.SetFtRight( rLR.GetRight() ); 1492 aBspWin.SetFooter( sal_True ); 1493 } 1494 else 1495 aBspWin.SetFooter( sal_False ); 1496 1497 // im Beispiel Hintergrund und Umrandung anzeigen 1498 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes; 1499 1500 if(mbEnableDrawingLayerFillStyles) 1501 { 1502 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1503 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rFooterSet)); 1504 } 1505 else 1506 { 1507 const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH)); 1508 1509 if(rFooterSet.GetItemState(nWhich) >= SFX_ITEM_AVAILABLE) 1510 { 1511 //UUUU aBspWin.SetFtColor(rItem.GetColor()); 1512 const SvxBrushItem& rItem = (const SvxBrushItem&)rFooterSet.Get(nWhich); 1513 SfxItemSet aTempSet(*rFooterSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1514 1515 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1516 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1517 } 1518 } 1519 1520 aBspWin.setFooterFillAttributes(aFooterFillAttributes); 1521 const sal_uInt16 nWhich(GetWhich(SID_ATTR_BORDER_OUTER)); 1522 1523 if ( rFooterSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE ) 1524 { 1525 const SvxBoxItem& rItem = 1526 (const SvxBoxItem&)rFooterSet.Get( nWhich ); 1527 aBspWin.SetFtBorder( rItem ); 1528 } 1529 } 1530 } 1531 1532 // ----------------------------------------------------------------------- 1533 1534 void SvxPageDescPage::ActivatePage( const SfxItemSet& rSet ) 1535 { 1536 InitHeadFoot_Impl( rSet ); 1537 UpdateExample_Impl(); 1538 ResetBackground_Impl( rSet ); 1539 RangeHdl_Impl( 0 ); 1540 } 1541 1542 // ----------------------------------------------------------------------- 1543 1544 int SvxPageDescPage::DeactivatePage( SfxItemSet* _pSet ) 1545 { 1546 // Abfrage, ob die Seitenr"ander ausserhalb des Druckbereichs liegen 1547 // Wenn nicht, dann den Anwender fragen, ob sie "ubernommen werden sollen. 1548 // Wenn nicht, dann auf der TabPage bleiben. 1549 sal_uInt16 nPos = aPaperSizeBox.GetSelectEntryPos(); 1550 Paper ePaper = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData( nPos ); 1551 1552 if ( ePaper != PAPER_SCREEN && IsMarginOutOfRange() ) 1553 { 1554 if ( QueryBox( this, WB_YES_NO | WB_DEF_NO, aPrintRangeQueryText ).Execute() == RET_NO ) 1555 { 1556 MetricField* pField = NULL; 1557 if ( IsPrinterRangeOverflow( aLeftMarginEdit, nFirstLeftMargin, nLastLeftMargin, MARGIN_LEFT ) ) 1558 pField = &aLeftMarginEdit; 1559 if ( IsPrinterRangeOverflow( aRightMarginEdit, nFirstRightMargin, nLastRightMargin, MARGIN_RIGHT ) 1560 && !pField ) 1561 pField = &aRightMarginEdit; 1562 if ( IsPrinterRangeOverflow( aTopMarginEdit, nFirstTopMargin, nLastTopMargin, MARGIN_TOP ) 1563 && !pField ) 1564 pField = &aTopMarginEdit; 1565 if ( IsPrinterRangeOverflow( aBottomMarginEdit, nFirstBottomMargin, nLastBottomMargin, MARGIN_BOTTOM ) 1566 && !pField ) 1567 pField = &aBottomMarginEdit; 1568 if ( pField ) 1569 pField->GrabFocus(); 1570 UpdateExample_Impl(); 1571 return KEEP_PAGE; 1572 } 1573 else 1574 CheckMarginEdits( false ); 1575 } 1576 1577 if ( _pSet ) 1578 { 1579 FillItemSet( *_pSet ); 1580 1581 // ggf. hoch/quer putten 1582 sal_uInt16 nWh = GetWhich( SID_ATTR_PAGE_SIZE ); 1583 SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWh ); 1584 Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ), 1585 GetCoreValue( aPaperHeightEdit, eUnit ) ); 1586 1587 // putten, wenn aktuelle Gr"o/se unterschiedlich zum Wert in _pSet 1588 const SvxSizeItem* pSize = (const SvxSizeItem*)GetItem( *_pSet, SID_ATTR_PAGE_SIZE ); 1589 if ( aSize.Width() && ( !pSize || !IsEqualSize_Impl( pSize, aSize ) ) ) 1590 _pSet->Put( SvxSizeItem( nWh, aSize ) ); 1591 } 1592 1593 return LEAVE_PAGE; 1594 } 1595 1596 // ----------------------------------------------------------------------- 1597 1598 IMPL_LINK( SvxPageDescPage, RangeHdl_Impl, Edit *, EMPTYARG ) 1599 { 1600 // Aktuelle Header-Breite/H"ohe aus dem Bsp 1601 long nHHeight = aBspWin.GetHdHeight(); 1602 long nHDist = aBspWin.GetHdDist(); 1603 1604 // Aktuelle Footer-Breite/H"ohe aus dem Bsp 1605 long nFHeight = aBspWin.GetFtHeight(); 1606 long nFDist = aBspWin.GetFtDist(); 1607 1608 // Aktuelle Header/Footer-R"ander aus dem Bsp 1609 long nHFLeft = Max( aBspWin.GetHdLeft(), aBspWin.GetFtLeft() ); 1610 long nHFRight = Max( aBspWin.GetHdRight(), aBspWin.GetFtRight() ); 1611 1612 // Aktuelle Werte der Seitenr"ander 1613 long nBT = static_cast<long>(aTopMarginEdit.Denormalize(aTopMarginEdit.GetValue(FUNIT_TWIP))); 1614 long nBB = static_cast<long>(aBottomMarginEdit.Denormalize(aBottomMarginEdit.GetValue(FUNIT_TWIP))); 1615 long nBL = static_cast<long>(aLeftMarginEdit.Denormalize(aLeftMarginEdit.GetValue(FUNIT_TWIP))); 1616 long nBR = static_cast<long>(aRightMarginEdit.Denormalize(aRightMarginEdit.GetValue(FUNIT_TWIP))); 1617 1618 // Breite Umrandung der Seite berechnen 1619 const SfxItemSet* _pSet = &GetItemSet(); 1620 Size aBorder; 1621 1622 if ( _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_SHADOW) ) >= 1623 SFX_ITEM_AVAILABLE && 1624 _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_OUTER) ) >= 1625 SFX_ITEM_AVAILABLE ) 1626 { 1627 aBorder = ( GetMinBorderSpace_Impl( 1628 (const SvxShadowItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW)), 1629 (const SvxBoxItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER)))); 1630 } 1631 1632 long nH = static_cast<long>(aPaperHeightEdit.Denormalize(aPaperHeightEdit.GetValue(FUNIT_TWIP))); 1633 long nW = static_cast<long>(aPaperWidthEdit.Denormalize(aPaperWidthEdit.GetValue(FUNIT_TWIP))); 1634 1635 // Grenzen Papier 1636 // Maximum liegt bei 54cm 1637 // 1638 long nMin = nHHeight + nHDist + nFDist + nFHeight + nBT + nBB + 1639 MINBODY + aBorder.Height(); 1640 aPaperHeightEdit.SetMin(aPaperHeightEdit.Normalize(nMin), FUNIT_TWIP); 1641 1642 nMin = MINBODY + nBL + nBR + aBorder.Width(); 1643 aPaperWidthEdit.SetMin(aPaperWidthEdit.Normalize(nMin), FUNIT_TWIP); 1644 1645 // Falls sich die Papiergr"o\se ge"adert hat 1646 nH = static_cast<long>(aPaperHeightEdit.Denormalize(aPaperHeightEdit.GetValue(FUNIT_TWIP))); 1647 nW = static_cast<long>(aPaperWidthEdit.Denormalize(aPaperWidthEdit.GetValue(FUNIT_TWIP))); 1648 1649 // Top 1650 long nMax = nH - nBB - aBorder.Height() - MINBODY - 1651 nFDist - nFHeight - nHDist - nHHeight; 1652 1653 aTopMarginEdit.SetMax(aTopMarginEdit.Normalize(nMax), FUNIT_TWIP); 1654 1655 // Bottom 1656 nMax = nH - nBT - aBorder.Height() - MINBODY - 1657 nFDist - nFHeight - nHDist - nHHeight; 1658 1659 aBottomMarginEdit.SetMax(aTopMarginEdit.Normalize(nMax), FUNIT_TWIP); 1660 1661 // Left 1662 nMax = nW - nBR - MINBODY - aBorder.Width() - nHFLeft - nHFRight; 1663 aLeftMarginEdit.SetMax(aLeftMarginEdit.Normalize(nMax), FUNIT_TWIP); 1664 1665 // Right 1666 nMax = nW - nBL - MINBODY - aBorder.Width() - nHFLeft - nHFRight; 1667 aRightMarginEdit.SetMax(aRightMarginEdit.Normalize(nMax), FUNIT_TWIP); 1668 return 0; 1669 } 1670 1671 // ----------------------------------------------------------------------- 1672 1673 void SvxPageDescPage::CalcMargin_Impl() 1674 { 1675 // Aktuelle Werte der Seitenr"ander 1676 long nBT = GetCoreValue( aTopMarginEdit, SFX_MAPUNIT_TWIP ); 1677 long nBB = GetCoreValue( aBottomMarginEdit, SFX_MAPUNIT_TWIP ); 1678 1679 long nBL = GetCoreValue( aLeftMarginEdit, SFX_MAPUNIT_TWIP ); 1680 long nBR = GetCoreValue( aRightMarginEdit, SFX_MAPUNIT_TWIP ); 1681 1682 long nH = GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_TWIP ); 1683 long nW = GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_TWIP ); 1684 1685 long nWidth = nBL + nBR + MINBODY; 1686 long nHeight = nBT + nBB + MINBODY; 1687 1688 if ( nWidth > nW || nHeight > nH ) 1689 { 1690 if ( nWidth > nW ) 1691 { 1692 long nTmp = nBL <= nBR ? nBR : nBL; 1693 nTmp -= nWidth - nW; 1694 1695 if ( nBL <= nBR ) 1696 SetMetricValue( aRightMarginEdit, nTmp, SFX_MAPUNIT_TWIP ); 1697 else 1698 SetMetricValue( aLeftMarginEdit, nTmp, SFX_MAPUNIT_TWIP ); 1699 } 1700 1701 if ( nHeight > nH ) 1702 { 1703 long nTmp = nBT <= nBB ? nBB : nBT; 1704 nTmp -= nHeight - nH; 1705 1706 if ( nBT <= nBB ) 1707 SetMetricValue( aBottomMarginEdit, nTmp, SFX_MAPUNIT_TWIP ); 1708 else 1709 SetMetricValue( aTopMarginEdit, nTmp, SFX_MAPUNIT_TWIP ); 1710 } 1711 } 1712 } 1713 1714 // ----------------------------------------------------------------------- 1715 1716 IMPL_LINK_INLINE_START( SvxPageDescPage, CenterHdl_Impl, CheckBox *, EMPTYARG ) 1717 { 1718 aBspWin.SetHorz( aHorzBox.IsChecked() ); 1719 aBspWin.SetVert( aVertBox.IsChecked() ); 1720 UpdateExample_Impl(); 1721 return 0; 1722 } 1723 IMPL_LINK_INLINE_END( SvxPageDescPage, CenterHdl_Impl, CheckBox *, EMPTYARG ) 1724 1725 // ----------------------------------------------------------------------- 1726 1727 void SvxPageDescPage::SetCollectionList(const List* pList) 1728 { 1729 sStandardRegister = *(String*)pList->GetObject(0); 1730 for( sal_uInt16 i = 1; i < pList->Count(); i++ ) 1731 { 1732 aRegisterLB.InsertEntry(*(String*)pList->GetObject(i)); 1733 } 1734 1735 aRegisterCB .Show(); 1736 aRegisterFT .Show(); 1737 aRegisterLB.Show(); 1738 aRegisterCB.SetClickHdl(LINK(this, SvxPageDescPage, RegisterModify)); 1739 } 1740 1741 // ----------------------------------------------------------------------- 1742 1743 IMPL_LINK( SvxPageDescPage, RegisterModify, CheckBox*, pBox ) 1744 { 1745 sal_Bool bEnable = sal_False; 1746 if(pBox->IsChecked()) 1747 { 1748 bEnable = sal_True; 1749 if(USHRT_MAX == aRegisterLB.GetSelectEntryPos()) 1750 aRegisterLB.SelectEntry(sStandardRegister); 1751 } 1752 aRegisterFT.Enable( bEnable ); 1753 aRegisterLB.Enable( bEnable ); 1754 return 0; 1755 } 1756 1757 // ---------------------------------------------------------------------------- 1758 1759 void SvxPageDescPage::DisableVerticalPageDir() 1760 { 1761 aTextFlowBox.RemoveEntryValue( FRMDIR_VERT_TOP_RIGHT ); 1762 aTextFlowBox.RemoveEntryValue( FRMDIR_VERT_TOP_LEFT ); 1763 if( aTextFlowBox.GetEntryCount() < 2 ) 1764 { 1765 aTextFlowLbl.Hide(); 1766 aTextFlowBox.Hide(); 1767 aBspWin.EnableFrameDirection( sal_False ); 1768 } 1769 } 1770 1771 IMPL_LINK( SvxPageDescPage, FrameDirectionModify_Impl, ListBox*, EMPTYARG) 1772 { 1773 aBspWin.SetFrameDirection( (sal_uInt32) aTextFlowBox.GetSelectEntryValue() ); 1774 aBspWin.Invalidate(); 1775 return 0; 1776 } 1777 1778 bool SvxPageDescPage::IsPrinterRangeOverflow( 1779 MetricField& rField, long nFirstMargin, long nLastMargin, MarginPosition nPos ) 1780 { 1781 bool bRet = false; 1782 bool bCheck = ( ( m_nPos & nPos ) == 0 ); 1783 long nValue = static_cast<long>(rField.GetValue()); 1784 if ( bCheck && 1785 ( nValue < nFirstMargin || nValue > nLastMargin ) && 1786 rField.GetText() != rField.GetSavedValue() ) 1787 { 1788 rField.SetValue( nValue < nFirstMargin ? nFirstMargin : nLastMargin ); 1789 bRet = true; 1790 } 1791 1792 return bRet; 1793 } 1794 1795 /** Check if a value of a margin edit is outside the printer paper margins 1796 and save this information. 1797 */ 1798 void SvxPageDescPage::CheckMarginEdits( bool _bClear ) 1799 { 1800 if ( _bClear ) 1801 m_nPos = 0; 1802 1803 sal_Int64 nValue = aLeftMarginEdit.GetValue(); 1804 if ( nValue < nFirstLeftMargin || nValue > nLastLeftMargin ) 1805 m_nPos |= MARGIN_LEFT; 1806 nValue = aRightMarginEdit.GetValue(); 1807 if ( nValue < nFirstRightMargin || nValue > nLastRightMargin ) 1808 m_nPos |= MARGIN_RIGHT; 1809 nValue = aTopMarginEdit.GetValue(); 1810 if ( nValue < nFirstTopMargin || nValue > nLastTopMargin ) 1811 m_nPos |= MARGIN_TOP; 1812 nValue = aBottomMarginEdit.GetValue(); 1813 if ( nValue < nFirstBottomMargin || nValue > nLastBottomMargin ) 1814 m_nPos |= MARGIN_BOTTOM; 1815 } 1816 1817 bool SvxPageDescPage::IsMarginOutOfRange() 1818 { 1819 bool bRet = ( ( ( !( m_nPos & MARGIN_LEFT ) && 1820 ( aLeftMarginEdit.GetText() != aLeftMarginEdit.GetSavedValue() ) ) && 1821 ( aLeftMarginEdit.GetValue() < nFirstLeftMargin || 1822 aLeftMarginEdit.GetValue() > nLastLeftMargin ) ) || 1823 ( ( !( m_nPos & MARGIN_RIGHT ) && 1824 ( aRightMarginEdit.GetText() != aRightMarginEdit.GetSavedValue() ) ) && 1825 ( aRightMarginEdit.GetValue() < nFirstRightMargin || 1826 aRightMarginEdit.GetValue() > nLastRightMargin ) ) || 1827 ( ( !( m_nPos & MARGIN_TOP ) && 1828 ( aTopMarginEdit.GetText() != aTopMarginEdit.GetSavedValue() ) ) && 1829 ( aTopMarginEdit.GetValue() < nFirstTopMargin || 1830 aTopMarginEdit.GetValue() > nLastTopMargin ) ) || 1831 ( ( !( m_nPos & MARGIN_BOTTOM ) && 1832 ( aBottomMarginEdit.GetText() != aBottomMarginEdit.GetSavedValue() ) ) && 1833 ( aBottomMarginEdit.GetValue() < nFirstBottomMargin || 1834 aBottomMarginEdit.GetValue() > nLastBottomMargin ) ) ); 1835 return bRet; 1836 } 1837 1838 void SvxPageDescPage::PageCreated(SfxAllItemSet aSet) //add CHINA001 1839 { 1840 SFX_ITEMSET_ARG(&aSet,pModeItem,SfxAllEnumItem,SID_ENUM_PAGE_MODE,sal_False); 1841 SFX_ITEMSET_ARG(&aSet,pPaperStartItem,SfxAllEnumItem,SID_PAPER_START,sal_False); 1842 SFX_ITEMSET_ARG(&aSet,pPaperEndItem,SfxAllEnumItem,SID_PAPER_END,sal_False); 1843 SFX_ITEMSET_ARG(&aSet,pCollectListItem,SfxStringListItem,SID_COLLECT_LIST,sal_False); 1844 1845 //UUUU 1846 SFX_ITEMSET_ARG (&aSet, pSupportDrawingLayerFillStyleItem, SfxBoolItem, SID_DRAWINGLAYER_FILLSTYLES, sal_False); 1847 1848 if(pModeItem) 1849 { 1850 SetMode((SvxModeType)pModeItem->GetEnumValue()); 1851 } 1852 1853 if(pPaperStartItem && pPaperEndItem) 1854 { 1855 SetPaperFormatRanges((Paper)pPaperStartItem->GetEnumValue(),(Paper)pPaperEndItem->GetEnumValue()); 1856 } 1857 1858 if(pCollectListItem) 1859 { 1860 SetCollectionList(pCollectListItem->GetList()); 1861 } 1862 1863 if(pSupportDrawingLayerFillStyleItem) 1864 { 1865 const bool bNew(pSupportDrawingLayerFillStyleItem->GetValue()); 1866 1867 EnableDrawingLayerFillStyles(bNew); 1868 } 1869 } 1870 1871 //eof 1872