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ück 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ür die Ränder 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änder (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änder (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änder 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ßen 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üllt 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änder 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_4_BY_3 == ePaper ) || 1076 ( PAPER_SCREEN_16_BY_9 == ePaper ) || 1077 ( PAPER_SCREEN_16_BY_10 == ePaper ); 1078 1079 if ( !bScreen ) 1080 // bei Bildschirm keinen Rand 1081 nTmp = 1; // entspr. 1cm 1082 1083 // Abfragen, ob für Ränder 0 gesetzt ist: 1084 if ( bScreen || aRightMarginEdit.GetValue() == 0 ) 1085 { 1086 SetMetricValue( aRightMarginEdit, nTmp, SFX_MAPUNIT_CM ); 1087 if ( !bScreen && 1088 aRightMarginEdit.GetFirst() > aRightMarginEdit.GetValue() ) 1089 aRightMarginEdit.SetValue( aRightMarginEdit.GetFirst() ); 1090 } 1091 if ( bScreen || aLeftMarginEdit.GetValue() == 0 ) 1092 { 1093 SetMetricValue( aLeftMarginEdit, nTmp, SFX_MAPUNIT_CM ); 1094 if ( !bScreen && 1095 aLeftMarginEdit.GetFirst() > aLeftMarginEdit.GetValue() ) 1096 aLeftMarginEdit.SetValue( aLeftMarginEdit.GetFirst() ); 1097 } 1098 if ( bScreen || aBottomMarginEdit.GetValue() == 0 ) 1099 { 1100 SetMetricValue( aBottomMarginEdit, nTmp, SFX_MAPUNIT_CM ); 1101 if ( !bScreen && 1102 aBottomMarginEdit.GetFirst() > aBottomMarginEdit.GetValue() ) 1103 aBottomMarginEdit.SetValue( aBottomMarginEdit.GetFirst() ); 1104 } 1105 if ( bScreen || aTopMarginEdit.GetValue() == 0 ) 1106 { 1107 SetMetricValue( aTopMarginEdit, nTmp, SFX_MAPUNIT_CM ); 1108 if ( !bScreen && 1109 aTopMarginEdit.GetFirst() > aTopMarginEdit.GetValue() ) 1110 aTopMarginEdit.SetValue( aTopMarginEdit.GetFirst() ); 1111 } 1112 UpdateExample_Impl( true ); 1113 } 1114 } 1115 return 0; 1116 } 1117 1118 // ----------------------------------------------------------------------- 1119 1120 IMPL_LINK( SvxPageDescPage, PaperSizeModify_Impl, Edit *, EMPTYARG ) 1121 { 1122 sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE ); 1123 SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWhich ); 1124 Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ), 1125 GetCoreValue( aPaperHeightEdit, eUnit ) ); 1126 Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, (MapUnit)eUnit, sal_True ); 1127 sal_uInt16 nEntryCount = aPaperSizeBox.GetEntryCount(); 1128 1129 for ( sal_uInt16 i = 0; i < nEntryCount; ++i ) 1130 { 1131 Paper eTmp = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData(i); 1132 1133 if ( eTmp == ePaper ) 1134 { 1135 aPaperSizeBox.SelectEntryPos(i); 1136 break; 1137 } 1138 } 1139 UpdateExample_Impl( true ); 1140 return 0; 1141 } 1142 1143 // ----------------------------------------------------------------------- 1144 1145 IMPL_LINK( SvxPageDescPage, SwapOrientation_Impl, RadioButton *, pBtn ) 1146 { 1147 if ( 1148 (!bLandscape && pBtn == &aLandscapeBtn) || 1149 (bLandscape && pBtn == &aPortraitBtn) 1150 ) 1151 { 1152 bLandscape = aLandscapeBtn.IsChecked(); 1153 1154 const long lWidth = GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_100TH_MM ); 1155 const long lHeight = GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_100TH_MM ); 1156 1157 // swap with and height 1158 SetMetricValue( aPaperWidthEdit, lHeight, SFX_MAPUNIT_100TH_MM ); 1159 SetMetricValue( aPaperHeightEdit, lWidth, SFX_MAPUNIT_100TH_MM ); 1160 1161 // recalculate margins if necessary 1162 CalcMargin_Impl(); 1163 1164 PaperSizeSelect_Impl( &aPaperSizeBox ); 1165 RangeHdl_Impl( 0 ); 1166 SwapFirstValues_Impl( bBorderModified ); 1167 UpdateExample_Impl( true ); 1168 } 1169 return 0; 1170 } 1171 1172 // ----------------------------------------------------------------------- 1173 1174 void SvxPageDescPage::SwapFirstValues_Impl( FASTBOOL bSet ) 1175 { 1176 MapMode aOldMode = mpDefPrinter->GetMapMode(); 1177 Orientation eOri = ORIENTATION_PORTRAIT; 1178 1179 if ( bLandscape ) 1180 eOri = ORIENTATION_LANDSCAPE; 1181 Orientation eOldOri = mpDefPrinter->GetOrientation(); 1182 mpDefPrinter->SetOrientation( eOri ); 1183 mpDefPrinter->SetMapMode( MAP_TWIP ); 1184 1185 // First- und Last-Werte für die Ränder setzen 1186 Size aPaperSize = mpDefPrinter->GetPaperSize(); 1187 Size aPrintSize = mpDefPrinter->GetOutputSize(); 1188 /* 1189 * einen Punkt ( 0,0 ) in logische Koordinaten zu konvertieren, 1190 * sieht aus wie Unsinn; ist aber sinnvoll, wenn der Ursprung des 1191 * Koordinatensystems verschoben ist. 1192 */ 1193 Point aPrintOffset = mpDefPrinter->GetPageOffset() - mpDefPrinter->PixelToLogic( Point() ); 1194 mpDefPrinter->SetMapMode( aOldMode ); 1195 mpDefPrinter->SetOrientation( eOldOri ); 1196 1197 sal_Int64 nSetL = aLeftMarginEdit.Denormalize( 1198 aLeftMarginEdit.GetValue( FUNIT_TWIP ) ); 1199 sal_Int64 nSetR = aRightMarginEdit.Denormalize( 1200 aRightMarginEdit.GetValue( FUNIT_TWIP ) ); 1201 sal_Int64 nSetT = aTopMarginEdit.Denormalize( 1202 aTopMarginEdit.GetValue( FUNIT_TWIP ) ); 1203 sal_Int64 nSetB = aBottomMarginEdit.Denormalize( 1204 aBottomMarginEdit.GetValue( FUNIT_TWIP ) ); 1205 1206 long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET; 1207 long nNewL = aPrintOffset.X(); 1208 long nNewR = 1209 aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset; 1210 long nNewT = aPrintOffset.Y(); 1211 long nNewB = 1212 aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset; 1213 1214 aLeftMarginEdit.SetFirst( aLeftMarginEdit.Normalize( nNewL ), FUNIT_TWIP ); 1215 nFirstLeftMargin = static_cast<long>(aLeftMarginEdit.GetFirst()); 1216 aRightMarginEdit.SetFirst( aRightMarginEdit.Normalize( nNewR ), FUNIT_TWIP ); 1217 nFirstRightMargin = static_cast<long>(aRightMarginEdit.GetFirst()); 1218 aTopMarginEdit.SetFirst( aTopMarginEdit.Normalize( nNewT ), FUNIT_TWIP ); 1219 nFirstTopMargin = static_cast<long>(aTopMarginEdit.GetFirst()); 1220 aBottomMarginEdit.SetFirst( aBottomMarginEdit.Normalize( nNewB ), FUNIT_TWIP ); 1221 nFirstBottomMargin = static_cast<long>(aBottomMarginEdit.GetFirst()); 1222 1223 if ( bSet ) 1224 { 1225 // ggf. auch die Werte umsetzen, 1226 if ( nSetL < nNewL ) 1227 aLeftMarginEdit.SetValue( aLeftMarginEdit.Normalize( nNewL ), 1228 FUNIT_TWIP ); 1229 if ( nSetR < nNewR ) 1230 aRightMarginEdit.SetValue( aRightMarginEdit.Normalize( nNewR ), 1231 FUNIT_TWIP ); 1232 if ( nSetT < nNewT ) 1233 aTopMarginEdit.SetValue( aTopMarginEdit.Normalize( nNewT ), 1234 FUNIT_TWIP ); 1235 if ( nSetB < nNewB ) 1236 aBottomMarginEdit.SetValue( aBottomMarginEdit.Normalize( nNewB ), 1237 FUNIT_TWIP ); 1238 } 1239 } 1240 1241 // ----------------------------------------------------------------------- 1242 1243 IMPL_LINK_INLINE_START( SvxPageDescPage, BorderModify_Impl, MetricField *, EMPTYARG ) 1244 { 1245 if ( !bBorderModified ) 1246 bBorderModified = sal_True; 1247 UpdateExample_Impl(); 1248 return 0; 1249 } 1250 IMPL_LINK_INLINE_END( SvxPageDescPage, BorderModify_Impl, MetricField *, EMPTYARG ) 1251 1252 // ----------------------------------------------------------------------- 1253 1254 void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground ) 1255 { 1256 // Size 1257 Size aSize( GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_TWIP ), 1258 GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_TWIP ) ); 1259 1260 aBspWin.SetSize( aSize ); 1261 1262 // Ränder 1263 aBspWin.SetTop( GetCoreValue( aTopMarginEdit, SFX_MAPUNIT_TWIP ) ); 1264 aBspWin.SetBottom( GetCoreValue( aBottomMarginEdit, SFX_MAPUNIT_TWIP ) ); 1265 aBspWin.SetLeft( GetCoreValue( aLeftMarginEdit, SFX_MAPUNIT_TWIP ) ); 1266 aBspWin.SetRight( GetCoreValue( aRightMarginEdit, SFX_MAPUNIT_TWIP ) ); 1267 1268 // Layout 1269 aBspWin.SetUsage( PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() ) ); 1270 if ( bResetbackground ) 1271 aBspWin.ResetBackground(); 1272 aBspWin.Invalidate(); 1273 } 1274 1275 // ----------------------------------------------------------------------- 1276 1277 void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet& rSet) 1278 { 1279 sal_uInt16 nWhich(GetWhich(SID_ATTR_PAGE_HEADERSET)); 1280 1281 if(SFX_ITEM_SET == rSet.GetItemState(nWhich, sal_False)) 1282 { 1283 const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, sal_False)); 1284 const SfxItemSet& rTmpSet = rSetItem.GetItemSet(); 1285 const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON))); 1286 1287 if(rOn.GetValue()) 1288 { 1289 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes; 1290 1291 if(mbEnableDrawingLayerFillStyles) 1292 { 1293 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1294 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet)); 1295 } 1296 else 1297 { 1298 nWhich = GetWhich(SID_ATTR_BRUSH); 1299 1300 if(SFX_ITEM_SET == rTmpSet.GetItemState(nWhich)) 1301 { 1302 //UUUU create FillAttributes from SvxBrushItem 1303 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich)); 1304 SfxItemSet aTempSet(*rTmpSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1305 1306 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1307 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1308 } 1309 } 1310 1311 aBspWin.setHeaderFillAttributes(aHeaderFillAttributes); 1312 nWhich = GetWhich(SID_ATTR_BORDER_OUTER); 1313 1314 if(rTmpSet.GetItemState(nWhich) == SFX_ITEM_SET) 1315 { 1316 const SvxBoxItem& rItem = static_cast< const SvxBoxItem& >(rTmpSet.Get(nWhich)); 1317 aBspWin.SetHdBorder(rItem); 1318 } 1319 } 1320 } 1321 1322 nWhich = GetWhich(SID_ATTR_PAGE_FOOTERSET); 1323 1324 if(SFX_ITEM_SET == rSet.GetItemState(nWhich, sal_False)) 1325 { 1326 const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich,sal_False)); 1327 const SfxItemSet& rTmpSet = rSetItem.GetItemSet(); 1328 const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON))); 1329 1330 if(rOn.GetValue()) 1331 { 1332 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes; 1333 1334 if(mbEnableDrawingLayerFillStyles) 1335 { 1336 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1337 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet)); 1338 } 1339 else 1340 { 1341 nWhich = GetWhich(SID_ATTR_BRUSH); 1342 1343 if(SFX_ITEM_SET == rTmpSet.GetItemState(nWhich)) 1344 { 1345 //UUUU create FillAttributes from SvxBrushItem 1346 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich)); 1347 SfxItemSet aTempSet(*rTmpSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1348 1349 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1350 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1351 } 1352 } 1353 1354 aBspWin.setFooterFillAttributes(aFooterFillAttributes); 1355 nWhich = GetWhich(SID_ATTR_BORDER_OUTER); 1356 1357 if(rTmpSet.GetItemState(nWhich) == SFX_ITEM_SET) 1358 { 1359 const SvxBoxItem& rItem = static_cast< const SvxBoxItem& >(rTmpSet.Get(nWhich)); 1360 aBspWin.SetFtBorder(rItem); 1361 } 1362 } 1363 } 1364 1365 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aPageFillAttributes; 1366 const SfxPoolItem* pItem = 0; 1367 1368 if(mbEnableDrawingLayerFillStyles) 1369 { 1370 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1371 aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rSet)); 1372 } 1373 else 1374 { 1375 pItem = GetItem(rSet, SID_ATTR_BRUSH); 1376 1377 if(pItem) 1378 { 1379 //UUUU create FillAttributes from SvxBrushItem 1380 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(*pItem); 1381 SfxItemSet aTempSet(*rSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1382 1383 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1384 aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1385 } 1386 } 1387 1388 aBspWin.setPageFillAttributes(aPageFillAttributes); 1389 pItem = GetItem(rSet, SID_ATTR_BORDER_OUTER); 1390 1391 if(pItem) 1392 { 1393 aBspWin.SetBorder(static_cast< const SvxBoxItem& >(*pItem)); 1394 } 1395 } 1396 1397 // ----------------------------------------------------------------------- 1398 1399 void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet ) 1400 { 1401 bLandscape = aLandscapeBtn.IsChecked(); 1402 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE ); 1403 1404 if ( pItem ) 1405 aBspWin.SetSize( ( (const SvxSizeItem*)pItem )->GetSize() ); 1406 1407 const SvxSetItem* pSetItem = 0; 1408 1409 // Kopfzeilen-Attribute auswerten 1410 1411 if ( SFX_ITEM_SET == 1412 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ), 1413 sal_False, (const SfxPoolItem**)&pSetItem ) ) 1414 { 1415 const SfxItemSet& rHeaderSet = pSetItem->GetItemSet(); 1416 const SfxBoolItem& rHeaderOn = 1417 (const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ); 1418 1419 if ( rHeaderOn.GetValue() ) 1420 { 1421 const SvxSizeItem& rSize = (const SvxSizeItem&) 1422 rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ); 1423 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&) 1424 rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) ); 1425 long nDist = rUL.GetLower(); 1426 aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist ); 1427 aBspWin.SetHdDist( nDist ); 1428 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&) 1429 rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); 1430 aBspWin.SetHdLeft( rLR.GetLeft() ); 1431 aBspWin.SetHdRight( rLR.GetRight() ); 1432 aBspWin.SetHeader( sal_True ); 1433 } 1434 else 1435 aBspWin.SetHeader( sal_False ); 1436 1437 // im Beispiel Hintergrund und Umrandung anzeigen 1438 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes; 1439 1440 if(mbEnableDrawingLayerFillStyles) 1441 { 1442 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1443 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rHeaderSet)); 1444 } 1445 else 1446 { 1447 const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH)); 1448 1449 if(rHeaderSet.GetItemState(nWhich) >= SFX_ITEM_AVAILABLE) 1450 { 1451 //UUUU aBspWin.SetHdColor(rItem.GetColor()); 1452 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rHeaderSet.Get(nWhich)); 1453 SfxItemSet aTempSet(*rHeaderSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1454 1455 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1456 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1457 } 1458 } 1459 1460 aBspWin.setHeaderFillAttributes(aHeaderFillAttributes); 1461 const sal_uInt16 nWhich(GetWhich(SID_ATTR_BORDER_OUTER)); 1462 1463 if ( rHeaderSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE ) 1464 { 1465 const SvxBoxItem& rItem = 1466 (const SvxBoxItem&)rHeaderSet.Get( nWhich ); 1467 aBspWin.SetHdBorder( rItem ); 1468 } 1469 } 1470 1471 // Fusszeilen-Attribute auswerten 1472 1473 if ( SFX_ITEM_SET == 1474 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ), 1475 sal_False, (const SfxPoolItem**)&pSetItem ) ) 1476 { 1477 const SfxItemSet& rFooterSet = pSetItem->GetItemSet(); 1478 const SfxBoolItem& rFooterOn = 1479 (const SfxBoolItem&)rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ); 1480 1481 if ( rFooterOn.GetValue() ) 1482 { 1483 const SvxSizeItem& rSize = (const SvxSizeItem&) 1484 rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ); 1485 const SvxULSpaceItem& rUL = (const SvxULSpaceItem&) 1486 rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) ); 1487 long nDist = rUL.GetUpper(); 1488 aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist ); 1489 aBspWin.SetFtDist( nDist ); 1490 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&) 1491 rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); 1492 aBspWin.SetFtLeft( rLR.GetLeft() ); 1493 aBspWin.SetFtRight( rLR.GetRight() ); 1494 aBspWin.SetFooter( sal_True ); 1495 } 1496 else 1497 aBspWin.SetFooter( sal_False ); 1498 1499 // im Beispiel Hintergrund und Umrandung anzeigen 1500 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes; 1501 1502 if(mbEnableDrawingLayerFillStyles) 1503 { 1504 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries 1505 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rFooterSet)); 1506 } 1507 else 1508 { 1509 const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH)); 1510 1511 if(rFooterSet.GetItemState(nWhich) >= SFX_ITEM_AVAILABLE) 1512 { 1513 //UUUU aBspWin.SetFtColor(rItem.GetColor()); 1514 const SvxBrushItem& rItem = (const SvxBrushItem&)rFooterSet.Get(nWhich); 1515 SfxItemSet aTempSet(*rFooterSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 1516 1517 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 1518 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); 1519 } 1520 } 1521 1522 aBspWin.setFooterFillAttributes(aFooterFillAttributes); 1523 const sal_uInt16 nWhich(GetWhich(SID_ATTR_BORDER_OUTER)); 1524 1525 if ( rFooterSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE ) 1526 { 1527 const SvxBoxItem& rItem = 1528 (const SvxBoxItem&)rFooterSet.Get( nWhich ); 1529 aBspWin.SetFtBorder( rItem ); 1530 } 1531 } 1532 } 1533 1534 // ----------------------------------------------------------------------- 1535 1536 void SvxPageDescPage::ActivatePage( const SfxItemSet& rSet ) 1537 { 1538 InitHeadFoot_Impl( rSet ); 1539 UpdateExample_Impl(); 1540 ResetBackground_Impl( rSet ); 1541 RangeHdl_Impl( 0 ); 1542 } 1543 1544 // ----------------------------------------------------------------------- 1545 1546 int SvxPageDescPage::DeactivatePage( SfxItemSet* _pSet ) 1547 { 1548 // Abfrage, ob die Seitenränder ausserhalb des Druckbereichs liegen 1549 // Wenn nicht, dann den Anwender fragen, ob sie übernommen werden sollen. 1550 // Wenn nicht, dann auf der TabPage bleiben. 1551 sal_uInt16 nPos = aPaperSizeBox.GetSelectEntryPos(); 1552 Paper ePaper = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData( nPos ); 1553 1554 if ( ePaper != PAPER_SCREEN_4_BY_3 && IsMarginOutOfRange() || 1555 ePaper != PAPER_SCREEN_16_BY_9 && IsMarginOutOfRange() || 1556 ePaper != PAPER_SCREEN_16_BY_10 && IsMarginOutOfRange() ) 1557 { 1558 if ( QueryBox( this, WB_YES_NO | WB_DEF_NO, aPrintRangeQueryText ).Execute() == RET_NO ) 1559 { 1560 MetricField* pField = NULL; 1561 if ( IsPrinterRangeOverflow( aLeftMarginEdit, nFirstLeftMargin, nLastLeftMargin, MARGIN_LEFT ) ) 1562 pField = &aLeftMarginEdit; 1563 if ( IsPrinterRangeOverflow( aRightMarginEdit, nFirstRightMargin, nLastRightMargin, MARGIN_RIGHT ) 1564 && !pField ) 1565 pField = &aRightMarginEdit; 1566 if ( IsPrinterRangeOverflow( aTopMarginEdit, nFirstTopMargin, nLastTopMargin, MARGIN_TOP ) 1567 && !pField ) 1568 pField = &aTopMarginEdit; 1569 if ( IsPrinterRangeOverflow( aBottomMarginEdit, nFirstBottomMargin, nLastBottomMargin, MARGIN_BOTTOM ) 1570 && !pField ) 1571 pField = &aBottomMarginEdit; 1572 if ( pField ) 1573 pField->GrabFocus(); 1574 UpdateExample_Impl(); 1575 return KEEP_PAGE; 1576 } 1577 else 1578 CheckMarginEdits( false ); 1579 } 1580 1581 if ( _pSet ) 1582 { 1583 FillItemSet( *_pSet ); 1584 1585 // ggf. hoch/quer putten 1586 sal_uInt16 nWh = GetWhich( SID_ATTR_PAGE_SIZE ); 1587 SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWh ); 1588 Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ), 1589 GetCoreValue( aPaperHeightEdit, eUnit ) ); 1590 1591 // putten, wenn aktuelle Größe unterschiedlich zum Wert in _pSet 1592 const SvxSizeItem* pSize = (const SvxSizeItem*)GetItem( *_pSet, SID_ATTR_PAGE_SIZE ); 1593 if ( aSize.Width() && ( !pSize || !IsEqualSize_Impl( pSize, aSize ) ) ) 1594 _pSet->Put( SvxSizeItem( nWh, aSize ) ); 1595 } 1596 1597 return LEAVE_PAGE; 1598 } 1599 1600 // ----------------------------------------------------------------------- 1601 1602 IMPL_LINK( SvxPageDescPage, RangeHdl_Impl, Edit *, EMPTYARG ) 1603 { 1604 // Aktuelle Header-Breite/Höhe aus dem Bsp 1605 long nHHeight = aBspWin.GetHdHeight(); 1606 long nHDist = aBspWin.GetHdDist(); 1607 1608 // Aktuelle Footer-Breite/Höhe aus dem Bsp 1609 long nFHeight = aBspWin.GetFtHeight(); 1610 long nFDist = aBspWin.GetFtDist(); 1611 1612 // Aktuelle Header/Footer-Ränder aus dem Bsp 1613 long nHFLeft = Max( aBspWin.GetHdLeft(), aBspWin.GetFtLeft() ); 1614 long nHFRight = Max( aBspWin.GetHdRight(), aBspWin.GetFtRight() ); 1615 1616 // Aktuelle Werte der Seitenränder 1617 long nBT = static_cast<long>(aTopMarginEdit.Denormalize(aTopMarginEdit.GetValue(FUNIT_TWIP))); 1618 long nBB = static_cast<long>(aBottomMarginEdit.Denormalize(aBottomMarginEdit.GetValue(FUNIT_TWIP))); 1619 long nBL = static_cast<long>(aLeftMarginEdit.Denormalize(aLeftMarginEdit.GetValue(FUNIT_TWIP))); 1620 long nBR = static_cast<long>(aRightMarginEdit.Denormalize(aRightMarginEdit.GetValue(FUNIT_TWIP))); 1621 1622 // Breite Umrandung der Seite berechnen 1623 const SfxItemSet* _pSet = &GetItemSet(); 1624 Size aBorder; 1625 1626 if ( _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_SHADOW) ) >= 1627 SFX_ITEM_AVAILABLE && 1628 _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_OUTER) ) >= 1629 SFX_ITEM_AVAILABLE ) 1630 { 1631 aBorder = ( GetMinBorderSpace_Impl( 1632 (const SvxShadowItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW)), 1633 (const SvxBoxItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER)))); 1634 } 1635 1636 long nH = static_cast<long>(aPaperHeightEdit.Denormalize(aPaperHeightEdit.GetValue(FUNIT_TWIP))); 1637 long nW = static_cast<long>(aPaperWidthEdit.Denormalize(aPaperWidthEdit.GetValue(FUNIT_TWIP))); 1638 1639 // Grenzen Papier 1640 // Maximum liegt bei 54cm 1641 // 1642 long nMin = nHHeight + nHDist + nFDist + nFHeight + nBT + nBB + 1643 MINBODY + aBorder.Height(); 1644 aPaperHeightEdit.SetMin(aPaperHeightEdit.Normalize(nMin), FUNIT_TWIP); 1645 1646 nMin = MINBODY + nBL + nBR + aBorder.Width(); 1647 aPaperWidthEdit.SetMin(aPaperWidthEdit.Normalize(nMin), FUNIT_TWIP); 1648 1649 // Falls sich die Papiergröße geändert hat 1650 nH = static_cast<long>(aPaperHeightEdit.Denormalize(aPaperHeightEdit.GetValue(FUNIT_TWIP))); 1651 nW = static_cast<long>(aPaperWidthEdit.Denormalize(aPaperWidthEdit.GetValue(FUNIT_TWIP))); 1652 1653 // Top 1654 long nMax = nH - nBB - aBorder.Height() - MINBODY - 1655 nFDist - nFHeight - nHDist - nHHeight; 1656 1657 aTopMarginEdit.SetMax(aTopMarginEdit.Normalize(nMax), FUNIT_TWIP); 1658 1659 // Bottom 1660 nMax = nH - nBT - aBorder.Height() - MINBODY - 1661 nFDist - nFHeight - nHDist - nHHeight; 1662 1663 aBottomMarginEdit.SetMax(aTopMarginEdit.Normalize(nMax), FUNIT_TWIP); 1664 1665 // Left 1666 nMax = nW - nBR - MINBODY - aBorder.Width() - nHFLeft - nHFRight; 1667 aLeftMarginEdit.SetMax(aLeftMarginEdit.Normalize(nMax), FUNIT_TWIP); 1668 1669 // Right 1670 nMax = nW - nBL - MINBODY - aBorder.Width() - nHFLeft - nHFRight; 1671 aRightMarginEdit.SetMax(aRightMarginEdit.Normalize(nMax), FUNIT_TWIP); 1672 return 0; 1673 } 1674 1675 // ----------------------------------------------------------------------- 1676 1677 void SvxPageDescPage::CalcMargin_Impl() 1678 { 1679 // Aktuelle Werte der Seitenränder 1680 long nBT = GetCoreValue( aTopMarginEdit, SFX_MAPUNIT_TWIP ); 1681 long nBB = GetCoreValue( aBottomMarginEdit, SFX_MAPUNIT_TWIP ); 1682 1683 long nBL = GetCoreValue( aLeftMarginEdit, SFX_MAPUNIT_TWIP ); 1684 long nBR = GetCoreValue( aRightMarginEdit, SFX_MAPUNIT_TWIP ); 1685 1686 long nH = GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_TWIP ); 1687 long nW = GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_TWIP ); 1688 1689 long nWidth = nBL + nBR + MINBODY; 1690 long nHeight = nBT + nBB + MINBODY; 1691 1692 if ( nWidth > nW || nHeight > nH ) 1693 { 1694 if ( nWidth > nW ) 1695 { 1696 long nTmp = nBL <= nBR ? nBR : nBL; 1697 nTmp -= nWidth - nW; 1698 1699 if ( nBL <= nBR ) 1700 SetMetricValue( aRightMarginEdit, nTmp, SFX_MAPUNIT_TWIP ); 1701 else 1702 SetMetricValue( aLeftMarginEdit, nTmp, SFX_MAPUNIT_TWIP ); 1703 } 1704 1705 if ( nHeight > nH ) 1706 { 1707 long nTmp = nBT <= nBB ? nBB : nBT; 1708 nTmp -= nHeight - nH; 1709 1710 if ( nBT <= nBB ) 1711 SetMetricValue( aBottomMarginEdit, nTmp, SFX_MAPUNIT_TWIP ); 1712 else 1713 SetMetricValue( aTopMarginEdit, nTmp, SFX_MAPUNIT_TWIP ); 1714 } 1715 } 1716 } 1717 1718 // ----------------------------------------------------------------------- 1719 1720 IMPL_LINK_INLINE_START( SvxPageDescPage, CenterHdl_Impl, CheckBox *, EMPTYARG ) 1721 { 1722 aBspWin.SetHorz( aHorzBox.IsChecked() ); 1723 aBspWin.SetVert( aVertBox.IsChecked() ); 1724 UpdateExample_Impl(); 1725 return 0; 1726 } 1727 IMPL_LINK_INLINE_END( SvxPageDescPage, CenterHdl_Impl, CheckBox *, EMPTYARG ) 1728 1729 // ----------------------------------------------------------------------- 1730 1731 void SvxPageDescPage::SetCollectionList(const List* pList) 1732 { 1733 sStandardRegister = *(String*)pList->GetObject(0); 1734 for( sal_uInt16 i = 1; i < pList->Count(); i++ ) 1735 { 1736 aRegisterLB.InsertEntry(*(String*)pList->GetObject(i)); 1737 } 1738 1739 aRegisterCB .Show(); 1740 aRegisterFT .Show(); 1741 aRegisterLB.Show(); 1742 aRegisterCB.SetClickHdl(LINK(this, SvxPageDescPage, RegisterModify)); 1743 } 1744 1745 // ----------------------------------------------------------------------- 1746 1747 IMPL_LINK( SvxPageDescPage, RegisterModify, CheckBox*, pBox ) 1748 { 1749 sal_Bool bEnable = sal_False; 1750 if(pBox->IsChecked()) 1751 { 1752 bEnable = sal_True; 1753 if(USHRT_MAX == aRegisterLB.GetSelectEntryPos()) 1754 aRegisterLB.SelectEntry(sStandardRegister); 1755 } 1756 aRegisterFT.Enable( bEnable ); 1757 aRegisterLB.Enable( bEnable ); 1758 return 0; 1759 } 1760 1761 // ---------------------------------------------------------------------------- 1762 1763 void SvxPageDescPage::DisableVerticalPageDir() 1764 { 1765 aTextFlowBox.RemoveEntryValue( FRMDIR_VERT_TOP_RIGHT ); 1766 aTextFlowBox.RemoveEntryValue( FRMDIR_VERT_TOP_LEFT ); 1767 if( aTextFlowBox.GetEntryCount() < 2 ) 1768 { 1769 aTextFlowLbl.Hide(); 1770 aTextFlowBox.Hide(); 1771 aBspWin.EnableFrameDirection( sal_False ); 1772 } 1773 } 1774 1775 IMPL_LINK( SvxPageDescPage, FrameDirectionModify_Impl, ListBox*, EMPTYARG) 1776 { 1777 aBspWin.SetFrameDirection( (sal_uInt32) aTextFlowBox.GetSelectEntryValue() ); 1778 aBspWin.Invalidate(); 1779 return 0; 1780 } 1781 1782 bool SvxPageDescPage::IsPrinterRangeOverflow( 1783 MetricField& rField, long nFirstMargin, long nLastMargin, MarginPosition nPos ) 1784 { 1785 bool bRet = false; 1786 bool bCheck = ( ( m_nPos & nPos ) == 0 ); 1787 long nValue = static_cast<long>(rField.GetValue()); 1788 if ( bCheck && 1789 ( nValue < nFirstMargin || nValue > nLastMargin ) && 1790 rField.GetText() != rField.GetSavedValue() ) 1791 { 1792 rField.SetValue( nValue < nFirstMargin ? nFirstMargin : nLastMargin ); 1793 bRet = true; 1794 } 1795 1796 return bRet; 1797 } 1798 1799 /** Check if a value of a margin edit is outside the printer paper margins 1800 and save this information. 1801 */ 1802 void SvxPageDescPage::CheckMarginEdits( bool _bClear ) 1803 { 1804 if ( _bClear ) 1805 m_nPos = 0; 1806 1807 sal_Int64 nValue = aLeftMarginEdit.GetValue(); 1808 if ( nValue < nFirstLeftMargin || nValue > nLastLeftMargin ) 1809 m_nPos |= MARGIN_LEFT; 1810 nValue = aRightMarginEdit.GetValue(); 1811 if ( nValue < nFirstRightMargin || nValue > nLastRightMargin ) 1812 m_nPos |= MARGIN_RIGHT; 1813 nValue = aTopMarginEdit.GetValue(); 1814 if ( nValue < nFirstTopMargin || nValue > nLastTopMargin ) 1815 m_nPos |= MARGIN_TOP; 1816 nValue = aBottomMarginEdit.GetValue(); 1817 if ( nValue < nFirstBottomMargin || nValue > nLastBottomMargin ) 1818 m_nPos |= MARGIN_BOTTOM; 1819 } 1820 1821 bool SvxPageDescPage::IsMarginOutOfRange() 1822 { 1823 bool bRet = ( ( ( !( m_nPos & MARGIN_LEFT ) && 1824 ( aLeftMarginEdit.GetText() != aLeftMarginEdit.GetSavedValue() ) ) && 1825 ( aLeftMarginEdit.GetValue() < nFirstLeftMargin || 1826 aLeftMarginEdit.GetValue() > nLastLeftMargin ) ) || 1827 ( ( !( m_nPos & MARGIN_RIGHT ) && 1828 ( aRightMarginEdit.GetText() != aRightMarginEdit.GetSavedValue() ) ) && 1829 ( aRightMarginEdit.GetValue() < nFirstRightMargin || 1830 aRightMarginEdit.GetValue() > nLastRightMargin ) ) || 1831 ( ( !( m_nPos & MARGIN_TOP ) && 1832 ( aTopMarginEdit.GetText() != aTopMarginEdit.GetSavedValue() ) ) && 1833 ( aTopMarginEdit.GetValue() < nFirstTopMargin || 1834 aTopMarginEdit.GetValue() > nLastTopMargin ) ) || 1835 ( ( !( m_nPos & MARGIN_BOTTOM ) && 1836 ( aBottomMarginEdit.GetText() != aBottomMarginEdit.GetSavedValue() ) ) && 1837 ( aBottomMarginEdit.GetValue() < nFirstBottomMargin || 1838 aBottomMarginEdit.GetValue() > nLastBottomMargin ) ) ); 1839 return bRet; 1840 } 1841 1842 void SvxPageDescPage::PageCreated(SfxAllItemSet aSet) //add CHINA001 1843 { 1844 SFX_ITEMSET_ARG(&aSet,pModeItem,SfxAllEnumItem,SID_ENUM_PAGE_MODE,sal_False); 1845 SFX_ITEMSET_ARG(&aSet,pPaperStartItem,SfxAllEnumItem,SID_PAPER_START,sal_False); 1846 SFX_ITEMSET_ARG(&aSet,pPaperEndItem,SfxAllEnumItem,SID_PAPER_END,sal_False); 1847 SFX_ITEMSET_ARG(&aSet,pCollectListItem,SfxStringListItem,SID_COLLECT_LIST,sal_False); 1848 1849 //UUUU 1850 SFX_ITEMSET_ARG (&aSet, pSupportDrawingLayerFillStyleItem, SfxBoolItem, SID_DRAWINGLAYER_FILLSTYLES, sal_False); 1851 1852 if(pModeItem) 1853 { 1854 SetMode((SvxModeType)pModeItem->GetEnumValue()); 1855 } 1856 1857 if(pPaperStartItem && pPaperEndItem) 1858 { 1859 SetPaperFormatRanges((Paper)pPaperStartItem->GetEnumValue(),(Paper)pPaperEndItem->GetEnumValue()); 1860 } 1861 1862 if(pCollectListItem) 1863 { 1864 SetCollectionList(pCollectListItem->GetList()); 1865 } 1866 1867 if(pSupportDrawingLayerFillStyleItem) 1868 { 1869 const bool bNew(pSupportDrawingLayerFillStyleItem->GetValue()); 1870 1871 EnableDrawingLayerFillStyles(bNew); 1872 } 1873 } 1874 1875 //eof 1876