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 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 #ifdef SD_DLLIMPLEMENTATION 28 #undef SD_DLLIMPLEMENTATION 29 #endif 30 31 32 #include <com/sun/star/document/PrinterIndependentLayout.hpp> 33 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 34 #include <com/sun/star/frame/XDesktop.hpp> 35 #include <com/sun/star/lang/XComponent.hpp> 36 #include <com/sun/star/container/XEnumerationAccess.hpp> 37 #include <comphelper/processfactory.hxx> 38 #include <com/sun/star/uno/Exception.hpp> 39 #include <sfx2/module.hxx> 40 #include <sfx2/app.hxx> 41 #include <svx/svxids.hrc> 42 #include <svx/dialogs.hrc> 43 #include <svx/strarray.hxx> 44 #include <svx/dlgutil.hxx> 45 #include <vcl/msgbox.hxx> 46 47 #include "sdattr.hxx" 48 #include "sdresid.hxx" 49 #include "optsitem.hxx" 50 #include "tpoption.hrc" 51 #include "tpoption.hxx" 52 #include "strings.hrc" 53 #include "app.hrc" 54 #include <svl/intitem.hxx> 55 #include <sfx2/request.hxx> 56 #define DLGWIN this->GetParent()->GetParent() 57 58 using namespace ::com::sun::star; 59 using namespace ::com::sun::star::uno; 60 61 /************************************************************************* 62 |* 63 |* TabPage zum Einstellen der Fang-Optionen 64 |* 65 \************************************************************************/ 66 67 SdTpOptionsSnap::SdTpOptionsSnap( Window* pParent, const SfxItemSet& rInAttrs ) : 68 SvxGridTabPage(pParent, rInAttrs) 69 { 70 aGrpSnap.Show(); 71 aCbxSnapHelplines.Show(); 72 aCbxSnapBorder.Show(); 73 aCbxSnapFrame.Show(); 74 aCbxSnapPoints.Show(); 75 aFtSnapArea.Show(); 76 aMtrFldSnapArea.Show(); 77 aGrpOrtho.Show(); 78 aCbxOrtho.Show(); 79 aCbxBigOrtho.Show(); 80 aCbxRotate.Show(); 81 aMtrFldAngle.Show(); 82 aFtBezAngle.Show(); 83 aMtrFldBezAngle.Show(); 84 aSeparatorFL.Show(); 85 } 86 87 // ----------------------------------------------------------------------- 88 89 SdTpOptionsSnap::~SdTpOptionsSnap() 90 { 91 } 92 93 // ----------------------------------------------------------------------- 94 95 sal_Bool SdTpOptionsSnap::FillItemSet( SfxItemSet& rAttrs ) 96 { 97 SvxGridTabPage::FillItemSet(rAttrs); 98 SdOptionsSnapItem* pOptsItem = NULL; 99 // if(SFX_ITEM_SET != rAttrs.GetItemState( ATTR_OPTIONS_SNAP, sal_False, (const SfxPoolItem**)&pOptsItem )) 100 // pExampleSet->GetItemState( ATTR_OPTIONS_SNAP, sal_False, (const SfxPoolItem**)&pOptsItem ); 101 102 SdOptionsSnapItem aOptsItem( ATTR_OPTIONS_SNAP ); 103 104 aOptsItem.GetOptionsSnap().SetSnapHelplines( aCbxSnapHelplines.IsChecked() ); 105 aOptsItem.GetOptionsSnap().SetSnapBorder( aCbxSnapBorder.IsChecked() ); 106 aOptsItem.GetOptionsSnap().SetSnapFrame( aCbxSnapFrame.IsChecked() ); 107 aOptsItem.GetOptionsSnap().SetSnapPoints( aCbxSnapPoints.IsChecked() ); 108 aOptsItem.GetOptionsSnap().SetOrtho( aCbxOrtho.IsChecked() ); 109 aOptsItem.GetOptionsSnap().SetBigOrtho( aCbxBigOrtho.IsChecked() ); 110 aOptsItem.GetOptionsSnap().SetRotate( aCbxRotate.IsChecked() ); 111 aOptsItem.GetOptionsSnap().SetSnapArea( (sal_Int16) aMtrFldSnapArea.GetValue() ); 112 aOptsItem.GetOptionsSnap().SetAngle( (sal_Int16) aMtrFldAngle.GetValue() ); 113 aOptsItem.GetOptionsSnap().SetEliminatePolyPointLimitAngle( (sal_Int16) aMtrFldBezAngle.GetValue() ); 114 115 if( pOptsItem == NULL || !(aOptsItem == *pOptsItem) ) 116 rAttrs.Put( aOptsItem ); 117 118 // Evtl. vorhandenes GridItem wird geholt, um nicht versehentlich 119 // irgendwelche Standardwerte einzustellen 120 return( sal_True ); 121 } 122 123 // ----------------------------------------------------------------------- 124 125 void SdTpOptionsSnap::Reset( const SfxItemSet& rAttrs ) 126 { 127 SvxGridTabPage::Reset(rAttrs); 128 129 SdOptionsSnapItem aOptsItem( (const SdOptionsSnapItem&) rAttrs. 130 Get( ATTR_OPTIONS_SNAP ) ); 131 132 aCbxSnapHelplines.Check( aOptsItem.GetOptionsSnap().IsSnapHelplines() ); 133 aCbxSnapBorder.Check( aOptsItem.GetOptionsSnap().IsSnapBorder() ); 134 aCbxSnapFrame.Check( aOptsItem.GetOptionsSnap().IsSnapFrame() ); 135 aCbxSnapPoints.Check( aOptsItem.GetOptionsSnap().IsSnapPoints() ); 136 aCbxOrtho.Check( aOptsItem.GetOptionsSnap().IsOrtho() ); 137 aCbxBigOrtho.Check( aOptsItem.GetOptionsSnap().IsBigOrtho() ); 138 aCbxRotate.Check( aOptsItem.GetOptionsSnap().IsRotate() ); 139 aMtrFldSnapArea.SetValue( aOptsItem.GetOptionsSnap().GetSnapArea() ); 140 aMtrFldAngle.SetValue( aOptsItem.GetOptionsSnap().GetAngle() ); 141 aMtrFldBezAngle.SetValue( aOptsItem.GetOptionsSnap().GetEliminatePolyPointLimitAngle() ); 142 143 aCbxRotate.GetClickHdl().Call(0); 144 } 145 146 // ----------------------------------------------------------------------- 147 148 SfxTabPage* SdTpOptionsSnap::Create( Window* pWindow, 149 const SfxItemSet& rAttrs ) 150 { 151 return( new SdTpOptionsSnap( pWindow, rAttrs ) ); 152 } 153 154 /************************************************************************* 155 |* 156 |* TabPage zum Einstellen der Inhalte-Optionen 157 |* 158 \************************************************************************/ 159 160 SdTpOptionsContents::SdTpOptionsContents( Window* pParent, const SfxItemSet& rInAttrs ) : 161 SfxTabPage ( pParent, SdResId( TP_OPTIONS_CONTENTS ), rInAttrs ), 162 aGrpDisplay ( this, SdResId( GRP_DISPLAY ) ), 163 aCbxRuler ( this, SdResId( CBX_RULER ) ), 164 aCbxDragStripes ( this, SdResId( CBX_HELPLINES ) ), 165 aCbxHandlesBezier ( this, SdResId( CBX_HANDLES_BEZIER ) ), 166 aCbxMoveOutline ( this, SdResId( CBX_MOVE_OUTLINE ) ) 167 { 168 FreeResource(); 169 } 170 171 // ----------------------------------------------------------------------- 172 173 SdTpOptionsContents::~SdTpOptionsContents() 174 { 175 } 176 177 // ----------------------------------------------------------------------- 178 179 sal_Bool SdTpOptionsContents::FillItemSet( SfxItemSet& rAttrs ) 180 { 181 sal_Bool bModified = sal_False; 182 183 if( aCbxRuler.GetSavedValue() != aCbxRuler.IsChecked() || 184 aCbxMoveOutline.GetSavedValue() != aCbxMoveOutline.IsChecked() || 185 aCbxDragStripes.GetSavedValue() != aCbxDragStripes.IsChecked() || 186 //aCbxHelplines.GetSavedValue() != aCbxHelplines.IsChecked() || 187 aCbxHandlesBezier.GetSavedValue() != aCbxHandlesBezier.IsChecked() ) 188 { 189 SdOptionsLayoutItem aOptsItem( ATTR_OPTIONS_LAYOUT ); 190 191 aOptsItem.GetOptionsLayout().SetRulerVisible( aCbxRuler.IsChecked() ); 192 aOptsItem.GetOptionsLayout().SetMoveOutline( aCbxMoveOutline.IsChecked() ); 193 aOptsItem.GetOptionsLayout().SetDragStripes( aCbxDragStripes.IsChecked() ); 194 aOptsItem.GetOptionsLayout().SetHandlesBezier( aCbxHandlesBezier.IsChecked() ); 195 //aOptsItem.GetOptionsLayout().SetHelplines( aCbxHelplines.IsChecked() ); 196 197 rAttrs.Put( aOptsItem ); 198 bModified = sal_True; 199 } 200 return( bModified ); 201 } 202 203 // ----------------------------------------------------------------------- 204 205 void SdTpOptionsContents::Reset( const SfxItemSet& rAttrs ) 206 { 207 SdOptionsContentsItem aOptsItem( (const SdOptionsContentsItem&) rAttrs. 208 Get( ATTR_OPTIONS_CONTENTS ) ); 209 210 SdOptionsLayoutItem aLayoutItem( (const SdOptionsLayoutItem&) rAttrs. 211 Get( ATTR_OPTIONS_LAYOUT ) ); 212 213 aCbxRuler.Check( aLayoutItem.GetOptionsLayout().IsRulerVisible() ); 214 aCbxMoveOutline.Check( aLayoutItem.GetOptionsLayout().IsMoveOutline() ); 215 aCbxDragStripes.Check( aLayoutItem.GetOptionsLayout().IsDragStripes() ); 216 aCbxHandlesBezier.Check( aLayoutItem.GetOptionsLayout().IsHandlesBezier() ); 217 //aCbxHelplines.Check( aLayoutItem.GetOptionsLayout().IsHelplines() ); 218 219 aCbxRuler.SaveValue(); 220 aCbxMoveOutline.SaveValue(); 221 aCbxDragStripes.SaveValue(); 222 aCbxHandlesBezier.SaveValue(); 223 //aCbxHelplines.SaveValue(); 224 } 225 226 // ----------------------------------------------------------------------- 227 228 SfxTabPage* SdTpOptionsContents::Create( Window* pWindow, 229 const SfxItemSet& rAttrs ) 230 { 231 return( new SdTpOptionsContents( pWindow, rAttrs ) ); 232 } 233 234 /************************************************************************* 235 |* 236 |* TabPage zum Einstellen der Sonstige-Optionen 237 |* 238 \************************************************************************/ 239 #define TABLE_COUNT 12 240 #define TOKEN (sal_Unicode(':')) 241 242 SdTpOptionsMisc::SdTpOptionsMisc( Window* pParent, const SfxItemSet& rInAttrs ) : 243 SfxTabPage ( pParent, SdResId( TP_OPTIONS_MISC ), rInAttrs ), 244 aGrpText ( this, SdResId( GRP_TEXT ) ), 245 aCbxQuickEdit ( this, SdResId( CBX_QUICKEDIT ) ), 246 aCbxPickThrough ( this, SdResId( CBX_PICKTHROUGH ) ), 247 248 // Template & Layout laufen z.Z. synchron! 249 aGrpProgramStart ( this, SdResId( GRP_PROGRAMSTART ) ), 250 aCbxStartWithTemplate ( this, SdResId( CBX_START_WITH_TEMPLATE ) ), 251 252 aGrpSettings ( this, SdResId( GRP_SETTINGS ) ), 253 aCbxMasterPageCache ( this, SdResId( CBX_MASTERPAGE_CACHE ) ), 254 aCbxCopy ( this, SdResId( CBX_COPY ) ), 255 aCbxMarkedHitMovesAlways ( this, SdResId( CBX_MARKED_HIT_MOVES_ALWAYS ) ), 256 aCbxCrookNoContortion ( this, SdResId( CBX_CROOK_NO_CONTORTION ) ), 257 258 aTxtMetric ( this, SdResId( FT_METRIC ) ), 259 aLbMetric ( this, SdResId( LB_METRIC ) ), 260 aTxtTabstop ( this, SdResId( FT_TABSTOP ) ), 261 aMtrFldTabstop ( this, SdResId( MTR_FLD_TABSTOP ) ), 262 263 aCbxStartWithActualPage ( this, SdResId( CBX_START_WITH_ACTUAL_PAGE ) ), 264 aGrpStartWithActualPage ( this, SdResId( GRP_START_WITH_ACTUAL_PAGE ) ), 265 aTxtCompatibility ( this, SdResId( FT_COMPATIBILITY ) ), 266 aCbxUsePrinterMetrics ( this, SdResId( CB_USE_PRINTER_METRICS ) ), 267 aCbxCompatibility ( this, SdResId( CB_MERGE_PARA_DIST ) ), 268 aGrpScale ( this, SdResId( GRP_SCALE ) ), 269 aFtScale ( this, SdResId( FT_SCALE ) ), 270 aCbScale ( this, SdResId( CB_SCALE ) ), 271 aFtOriginal ( this, SdResId( FT_ORIGINAL ) ), 272 aFtEquivalent ( this, SdResId( FT_EQUIVALENT ) ), 273 aFtPageWidth ( this, SdResId( FT_PAGEWIDTH ) ), 274 aFiInfo1 ( this, SdResId( FI_INFO_1 ) ), 275 aMtrFldOriginalWidth ( this, SdResId( MTR_FLD_ORIGINAL_WIDTH ) ), 276 aFtPageHeight ( this, SdResId( FT_PAGEHEIGHT ) ), 277 aFiInfo2 ( this, SdResId( FI_INFO_2 ) ), 278 aMtrFldOriginalHeight ( this, SdResId( MTR_FLD_ORIGINAL_HEIGHT ) ), 279 aMtrFldInfo1 ( this, WinBits( WB_HIDE ) ), 280 aMtrFldInfo2 ( this, WinBits( WB_HIDE ) ) 281 { 282 FreeResource(); 283 SetExchangeSupport(); 284 285 // Metrik einstellen 286 FieldUnit eFUnit; 287 288 sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC ); 289 if ( rInAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE ) 290 { 291 const SfxUInt16Item& rItem = (SfxUInt16Item&)rInAttrs.Get( nWhich ); 292 eFUnit = (FieldUnit)rItem.GetValue(); 293 } 294 else 295 eFUnit = SfxModule::GetCurrentFieldUnit(); 296 297 SetFieldUnit( aMtrFldTabstop, eFUnit ); 298 299 // ListBox mit Metriken f"ullen 300 SvxStringArray aMetricArr( RID_SVXSTR_FIELDUNIT_TABLE ); 301 sal_uInt16 i; 302 303 for ( i = 0; i < aMetricArr.Count(); ++i ) 304 { 305 String sMetric = aMetricArr.GetStringByPos( i ); 306 long nFieldUnit = aMetricArr.GetValue( i ); 307 sal_uInt16 nPos = aLbMetric.InsertEntry( sMetric ); 308 aLbMetric.SetEntryData( nPos, (void*)nFieldUnit ); 309 } 310 aLbMetric.SetSelectHdl( LINK( this, SdTpOptionsMisc, SelectMetricHdl_Impl ) ); 311 312 SetFieldUnit( aMtrFldOriginalWidth, eFUnit ); 313 SetFieldUnit( aMtrFldOriginalHeight, eFUnit ); 314 aMtrFldOriginalWidth.SetLast( 999999999 ); 315 aMtrFldOriginalWidth.SetMax( 999999999 ); 316 aMtrFldOriginalHeight.SetLast( 999999999 ); 317 aMtrFldOriginalHeight.SetMax( 999999999 ); 318 319 // Temporaere Fields fuer Info-Texte (fuer Formatierung/Berechnung) 320 aMtrFldInfo1.SetUnit( eFUnit ); 321 aMtrFldInfo1.SetMax( 999999999 ); 322 aMtrFldInfo1.SetDecimalDigits( 2 ); 323 aMtrFldInfo2.SetUnit( eFUnit ); 324 aMtrFldInfo2.SetMax( 999999999 ); 325 aMtrFldInfo2.SetDecimalDigits( 2 ); 326 327 // PoolUnit ermitteln 328 SfxItemPool* pPool = rInAttrs.GetPool(); 329 DBG_ASSERT( pPool, "Wo ist der Pool?" ); 330 ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH ); 331 332 // Fuellen der CB 333 sal_uInt16 aTable[ TABLE_COUNT ] = 334 { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 }; 335 336 for( i = 0; i < TABLE_COUNT; i++ ) 337 aCbScale.InsertEntry( GetScale( 1, aTable[i] ) ); 338 for( i = 1; i < TABLE_COUNT; i++ ) 339 aCbScale.InsertEntry( GetScale( aTable[i], 1 ) ); 340 } 341 342 // ----------------------------------------------------------------------- 343 344 SdTpOptionsMisc::~SdTpOptionsMisc() 345 { 346 } 347 // ----------------------------------------------------------------------- 348 void SdTpOptionsMisc::ActivatePage( const SfxItemSet& rSet ) 349 { 350 // Hier muss noch einmal SaveValue gerufen werden, da sonst u.U. 351 // der Wert in anderen TabPages keine Wirkung hat 352 aLbMetric.SaveValue(); 353 // Metrik ggfs. aendern (da TabPage im Dialog liegt, 354 // wo die Metrik eingestellt werden kann 355 const SfxPoolItem* pAttr = NULL; 356 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC , sal_False, 357 (const SfxPoolItem**)&pAttr )) 358 { 359 const SfxUInt16Item* pItem = (SfxUInt16Item*) pAttr; 360 361 FieldUnit eFUnit = (FieldUnit)(long)pItem->GetValue(); 362 363 if( eFUnit != aMtrFldOriginalWidth.GetUnit() ) 364 { 365 // Metriken einstellen 366 sal_Int64 nVal = aMtrFldOriginalWidth.Denormalize( aMtrFldOriginalWidth.GetValue( FUNIT_TWIP ) ); 367 SetFieldUnit( aMtrFldOriginalWidth, eFUnit, sal_True ); 368 aMtrFldOriginalWidth.SetValue( aMtrFldOriginalWidth.Normalize( nVal ), FUNIT_TWIP ); 369 370 nVal = aMtrFldOriginalHeight.Denormalize( aMtrFldOriginalHeight.GetValue( FUNIT_TWIP ) ); 371 SetFieldUnit( aMtrFldOriginalHeight, eFUnit, sal_True ); 372 aMtrFldOriginalHeight.SetValue( aMtrFldOriginalHeight.Normalize( nVal ), FUNIT_TWIP ); 373 374 375 if( nWidth != 0 && nHeight != 0 ) 376 { 377 aMtrFldInfo1.SetUnit( eFUnit ); 378 aMtrFldInfo2.SetUnit( eFUnit ); 379 380 SetMetricValue( aMtrFldInfo1, nWidth, ePoolUnit ); 381 aInfo1 = aMtrFldInfo1.GetText(); 382 aFiInfo1.SetText( aInfo1 ); 383 384 SetMetricValue( aMtrFldInfo2, nHeight, ePoolUnit ); 385 aInfo2 = aMtrFldInfo2.GetText(); 386 aFiInfo2.SetText( aInfo2 ); 387 } 388 } 389 } 390 } 391 392 // ----------------------------------------------------------------------- 393 394 int SdTpOptionsMisc::DeactivatePage( SfxItemSet* pActiveSet ) 395 { 396 // Parsercheck 397 sal_Int32 nX, nY; 398 if( SetScale( aCbScale.GetText(), nX, nY ) ) 399 { 400 if( pActiveSet ) 401 FillItemSet( *pActiveSet ); 402 return( LEAVE_PAGE ); 403 } 404 WarningBox aWarnBox( GetParent(), WB_YES_NO, String( SdResId( STR_WARN_SCALE_FAIL ) ) ); 405 short nReturn = aWarnBox.Execute(); 406 407 if( nReturn == RET_YES ) 408 return( KEEP_PAGE ); 409 410 if( pActiveSet ) 411 FillItemSet( *pActiveSet ); 412 413 return( LEAVE_PAGE ); 414 } 415 416 // ----------------------------------------------------------------------- 417 418 sal_Bool SdTpOptionsMisc::FillItemSet( SfxItemSet& rAttrs ) 419 { 420 sal_Bool bModified = sal_False; 421 422 if( aCbxStartWithTemplate.GetSavedValue() != aCbxStartWithTemplate.IsChecked() || 423 aCbxMarkedHitMovesAlways.GetSavedValue()!= aCbxMarkedHitMovesAlways.IsChecked() || 424 aCbxCrookNoContortion.GetSavedValue() != aCbxCrookNoContortion.IsChecked() || 425 aCbxQuickEdit.GetSavedValue() != aCbxQuickEdit.IsChecked() || 426 aCbxPickThrough.GetSavedValue() != aCbxPickThrough.IsChecked() || 427 aCbxMasterPageCache.GetSavedValue() != aCbxMasterPageCache.IsChecked() || 428 aCbxCopy.GetSavedValue() != aCbxCopy.IsChecked() || 429 aCbxStartWithActualPage.GetSavedValue() != aCbxStartWithActualPage.IsChecked() || 430 aCbxCompatibility.GetSavedValue() != aCbxCompatibility.IsChecked() || 431 aCbxUsePrinterMetrics.GetSavedValue() != aCbxUsePrinterMetrics.IsChecked() ) 432 { 433 SdOptionsMiscItem aOptsItem( ATTR_OPTIONS_MISC ); 434 435 aOptsItem.GetOptionsMisc().SetStartWithTemplate( aCbxStartWithTemplate.IsChecked() ); 436 aOptsItem.GetOptionsMisc().SetMarkedHitMovesAlways( aCbxMarkedHitMovesAlways.IsChecked() ); 437 aOptsItem.GetOptionsMisc().SetCrookNoContortion( aCbxCrookNoContortion.IsChecked() ); 438 aOptsItem.GetOptionsMisc().SetQuickEdit( aCbxQuickEdit.IsChecked() ); 439 aOptsItem.GetOptionsMisc().SetPickThrough( aCbxPickThrough.IsChecked() ); 440 aOptsItem.GetOptionsMisc().SetMasterPagePaintCaching( aCbxMasterPageCache.IsChecked() ); 441 aOptsItem.GetOptionsMisc().SetDragWithCopy( aCbxCopy.IsChecked() ); 442 aOptsItem.GetOptionsMisc().SetStartWithActualPage( aCbxStartWithActualPage.IsChecked() ); 443 aOptsItem.GetOptionsMisc().SetSummationOfParagraphs( aCbxCompatibility.IsChecked() ); 444 aOptsItem.GetOptionsMisc().SetPrinterIndependentLayout ( 445 aCbxUsePrinterMetrics.IsChecked() 446 ? ::com::sun::star::document::PrinterIndependentLayout::DISABLED 447 : ::com::sun::star::document::PrinterIndependentLayout::ENABLED); 448 rAttrs.Put( aOptsItem ); 449 450 bModified = sal_True; 451 } 452 453 // Metrik 454 const sal_uInt16 nMPos = aLbMetric.GetSelectEntryPos(); 455 if ( nMPos != aLbMetric.GetSavedValue() ) 456 { 457 sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbMetric.GetEntryData( nMPos ); 458 rAttrs.Put( SfxUInt16Item( GetWhich( SID_ATTR_METRIC ), 459 (sal_uInt16)nFieldUnit ) ); 460 bModified |= sal_True; 461 } 462 463 // Tabulatorabstand 464 if( aMtrFldTabstop.GetText() != aMtrFldTabstop.GetSavedValue() ) 465 { 466 sal_uInt16 nWh = GetWhich( SID_ATTR_DEFTABSTOP ); 467 SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWh ); 468 SfxUInt16Item aDef( nWh,(sal_uInt16)GetCoreValue( aMtrFldTabstop, eUnit ) ); 469 rAttrs.Put( aDef ); 470 bModified |= sal_True; 471 } 472 473 sal_Int32 nX, nY; 474 if( SetScale( aCbScale.GetText(), nX, nY ) ) 475 { 476 rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) ); 477 rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) ); 478 479 bModified = sal_True; 480 } 481 482 return( bModified ); 483 } 484 485 // ----------------------------------------------------------------------- 486 487 void SdTpOptionsMisc::Reset( const SfxItemSet& rAttrs ) 488 { 489 SdOptionsMiscItem aOptsItem( (const SdOptionsMiscItem&) rAttrs. 490 Get( ATTR_OPTIONS_MISC ) ); 491 492 aCbxStartWithTemplate.Check( aOptsItem.GetOptionsMisc().IsStartWithTemplate() ); 493 aCbxMarkedHitMovesAlways.Check( aOptsItem.GetOptionsMisc().IsMarkedHitMovesAlways() ); 494 aCbxCrookNoContortion.Check( aOptsItem.GetOptionsMisc().IsCrookNoContortion() ); 495 aCbxQuickEdit.Check( aOptsItem.GetOptionsMisc().IsQuickEdit() ); 496 aCbxPickThrough.Check( aOptsItem.GetOptionsMisc().IsPickThrough() ); 497 aCbxMasterPageCache.Check( aOptsItem.GetOptionsMisc().IsMasterPagePaintCaching() ); 498 aCbxCopy.Check( aOptsItem.GetOptionsMisc().IsDragWithCopy() ); 499 aCbxStartWithActualPage.Check( aOptsItem.GetOptionsMisc().IsStartWithActualPage() ); 500 aCbxCompatibility.Check( aOptsItem.GetOptionsMisc().IsSummationOfParagraphs() ); 501 aCbxUsePrinterMetrics.Check( aOptsItem.GetOptionsMisc().GetPrinterIndependentLayout()==1 ); 502 aCbxStartWithTemplate.SaveValue(); 503 aCbxMarkedHitMovesAlways.SaveValue(); 504 aCbxCrookNoContortion.SaveValue(); 505 aCbxQuickEdit.SaveValue(); 506 aCbxPickThrough.SaveValue(); 507 508 aCbxMasterPageCache.SaveValue(); 509 aCbxCopy.SaveValue(); 510 aCbxStartWithActualPage.SaveValue(); 511 aCbxCompatibility.SaveValue(); 512 aCbxUsePrinterMetrics.SaveValue(); 513 514 // Metrik 515 sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC ); 516 aLbMetric.SetNoSelection(); 517 518 if ( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE ) 519 { 520 const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich ); 521 long nFieldUnit = (long)rItem.GetValue(); 522 523 for ( sal_uInt16 i = 0; i < aLbMetric.GetEntryCount(); ++i ) 524 { 525 if ( (long)aLbMetric.GetEntryData( i ) == nFieldUnit ) 526 { 527 aLbMetric.SelectEntryPos( i ); 528 break; 529 } 530 } 531 } 532 533 // Tabulatorabstand 534 nWhich = GetWhich( SID_ATTR_DEFTABSTOP ); 535 if( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE ) 536 { 537 SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWhich ); 538 const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich ); 539 SetMetricValue( aMtrFldTabstop, rItem.GetValue(), eUnit ); 540 } 541 aLbMetric.SaveValue(); 542 aMtrFldTabstop.SaveValue(); 543 //Scale 544 sal_Int32 nX = ( (const SfxInt32Item&) rAttrs. 545 Get( ATTR_OPTIONS_SCALE_X ) ).GetValue(); 546 sal_Int32 nY = ( (const SfxInt32Item&) rAttrs. 547 Get( ATTR_OPTIONS_SCALE_Y ) ).GetValue(); 548 nWidth = ( (const SfxUInt32Item&) rAttrs. 549 Get( ATTR_OPTIONS_SCALE_WIDTH ) ).GetValue(); 550 nHeight = ( (const SfxUInt32Item&) rAttrs. 551 Get( ATTR_OPTIONS_SCALE_HEIGHT ) ).GetValue(); 552 553 aCbScale.SetText( GetScale( nX, nY ) ); 554 555 // #92067# broken feature disabled for 6.0 556 aFtOriginal.Hide(); 557 aFtEquivalent.Hide(); 558 aMtrFldOriginalWidth.Hide(); 559 aMtrFldOriginalWidth.SetText( aInfo1 ); // leer 560 aMtrFldOriginalHeight.Hide(); 561 aMtrFldOriginalHeight.SetText( aInfo2 ); //leer 562 aFtPageWidth.Hide(); 563 aFtPageHeight.Hide(); 564 aFiInfo1.Hide(); 565 aFiInfo2.Hide(); 566 567 UpdateCompatibilityControls (); 568 } 569 570 // ----------------------------------------------------------------------- 571 572 SfxTabPage* SdTpOptionsMisc::Create( Window* pWindow, 573 const SfxItemSet& rAttrs ) 574 { 575 return( new SdTpOptionsMisc( pWindow, rAttrs ) ); 576 } 577 //------------------------------------------------------------------------ 578 579 IMPL_LINK( SdTpOptionsMisc, SelectMetricHdl_Impl, ListBox *, EMPTYARG ) 580 { 581 sal_uInt16 nPos = aLbMetric.GetSelectEntryPos(); 582 583 if( nPos != LISTBOX_ENTRY_NOTFOUND ) 584 { 585 FieldUnit eUnit = (FieldUnit)(long)aLbMetric.GetEntryData( nPos ); 586 sal_Int64 nVal = 587 aMtrFldTabstop.Denormalize( aMtrFldTabstop.GetValue( FUNIT_TWIP ) ); 588 SetFieldUnit( aMtrFldTabstop, eUnit ); 589 aMtrFldTabstop.SetValue( aMtrFldTabstop.Normalize( nVal ), FUNIT_TWIP ); 590 } 591 return 0; 592 } 593 594 595 namespace { 596 void lcl_MoveWin( Window& rWin, long nYDiff) 597 { 598 Point aPos(rWin.GetPosPixel()); 599 aPos.Y() += nYDiff; 600 rWin.SetPosPixel (aPos); 601 } 602 603 void lcl_MoveWin( Window& rWin, long nXdiff, long nYdiff) 604 { 605 Point aPos(rWin.GetPosPixel()); 606 aPos.X() += nXdiff; 607 aPos.Y() += nYdiff; 608 rWin.SetPosPixel(aPos); 609 } 610 } 611 612 void SdTpOptionsMisc::SetImpressMode (void) 613 { 614 long nDialogWidth = GetSizePixel().Width(); 615 long nLineHeight = aCbxPickThrough.GetPosPixel().Y() 616 - aCbxQuickEdit.GetPosPixel().Y(); 617 618 // Put both "Text objects" check boxes side by side. 619 lcl_MoveWin (aCbxPickThrough, 620 nDialogWidth/2 - aCbxPickThrough.GetPosPixel().X(), 621 -nLineHeight); 622 623 // Move the other controls up one line. 624 lcl_MoveWin (aGrpProgramStart, -nLineHeight); 625 lcl_MoveWin (aCbxStartWithTemplate, -nLineHeight); 626 lcl_MoveWin (aGrpSettings, -nLineHeight); 627 lcl_MoveWin (aCbxMasterPageCache, -nLineHeight); 628 lcl_MoveWin (aCbxCopy, -nLineHeight); 629 lcl_MoveWin (aCbxMarkedHitMovesAlways, -nLineHeight); 630 lcl_MoveWin (aCbxCrookNoContortion, -nLineHeight); 631 lcl_MoveWin (aTxtMetric, -nLineHeight); 632 lcl_MoveWin (aLbMetric, -nLineHeight); 633 lcl_MoveWin (aTxtTabstop, -nLineHeight); 634 lcl_MoveWin (aMtrFldTabstop, -nLineHeight); 635 lcl_MoveWin (aGrpStartWithActualPage, -nLineHeight); 636 lcl_MoveWin (aCbxStartWithActualPage, -nLineHeight); 637 lcl_MoveWin (aTxtCompatibility, -nLineHeight); 638 639 // Move the printer-independent-metrics check box up two lines to change 640 // places with spacing-between-paragraphs check box. 641 lcl_MoveWin (aCbxUsePrinterMetrics, -2*nLineHeight); 642 } 643 644 void SdTpOptionsMisc::SetDrawMode() 645 { 646 aCbxStartWithTemplate.Hide(); 647 aGrpProgramStart.Hide(); 648 aCbxStartWithActualPage.Hide(); 649 aCbxCompatibility.Hide(); 650 aGrpStartWithActualPage.Hide(); 651 aCbxCrookNoContortion.Show(); 652 653 aGrpScale.Show(); 654 aFtScale.Show(); 655 aCbScale.Show(); 656 657 aFtOriginal.Show(); 658 aFtEquivalent.Show(); 659 660 aFtPageWidth.Show(); 661 aFiInfo1.Show(); 662 aMtrFldOriginalWidth.Show(); 663 664 aFtPageHeight.Show(); 665 aFiInfo2.Show(); 666 aMtrFldOriginalHeight.Show(); 667 668 long nDiff = aGrpSettings.GetPosPixel().Y() - aGrpProgramStart.GetPosPixel().Y(); 669 lcl_MoveWin( aGrpSettings, -nDiff ); 670 lcl_MoveWin( aCbxMasterPageCache, -nDiff ); 671 lcl_MoveWin( aCbxCopy, -nDiff ); 672 lcl_MoveWin( aCbxMarkedHitMovesAlways, -nDiff ); 673 lcl_MoveWin( aCbxCrookNoContortion, -nDiff ); 674 nDiff -= aCbxCrookNoContortion.GetPosPixel().Y() - aCbxMarkedHitMovesAlways.GetPosPixel().Y(); 675 lcl_MoveWin( aTxtMetric, -nDiff ); 676 lcl_MoveWin( aLbMetric, -nDiff ); 677 lcl_MoveWin( aTxtTabstop, -nDiff ); 678 lcl_MoveWin( aMtrFldTabstop, -nDiff ); 679 680 // Move the scale controls so that they are visually centered betwen the 681 // group controls above and below. 682 lcl_MoveWin (aFtScale, -17); 683 lcl_MoveWin (aCbScale, -17); 684 685 // Move the printer-independent-metrics check box in the place that the 686 // spacing-between-paragraphs check box normally is in. 687 aCbxUsePrinterMetrics.SetPosPixel (aCbxCompatibility.GetPosPixel()); 688 } 689 // ----------------------------------------------------------------------- 690 691 IMPL_LINK( SdTpOptionsMisc, ModifyScaleHdl, void *, EMPTYARG ) 692 { 693 // Originalgroesse berechnen 694 sal_Int32 nX, nY; 695 if( SetScale( aCbScale.GetText(), nX, nY ) ) 696 { 697 sal_Int32 nW = nWidth * nY / nX; 698 sal_Int32 nH = nHeight * nY / nX; 699 700 SetMetricValue( aMtrFldOriginalWidth, nW, ePoolUnit ); 701 SetMetricValue( aMtrFldOriginalHeight, nH, ePoolUnit ); 702 } 703 704 return( 0L ); 705 } 706 707 // ----------------------------------------------------------------------- 708 709 IMPL_LINK( SdTpOptionsMisc, ModifyOriginalScaleHdl, void *, EMPTYARG ) 710 { 711 // Berechnen des Massstabs 712 long nOrgW = static_cast<long>(aMtrFldOriginalWidth.GetValue()); 713 long nOrgH = static_cast<long>(aMtrFldOriginalHeight.GetValue()); 714 715 if( nOrgW == 0 || nOrgH == 0 ) 716 return( 0L ); 717 718 Fraction aFract1( nOrgW, static_cast<long>(aMtrFldInfo1.GetValue()) ); 719 Fraction aFract2( nOrgH, static_cast<long>(aMtrFldInfo2.GetValue()) ); 720 Fraction aFract( aFract1 > aFract2 ? aFract1 : aFract2 ); 721 722 long nValue; 723 if( aFract < Fraction( 1, 1 ) ) 724 { 725 // Fraction umdrehen 726 aFract1 = aFract; 727 aFract = Fraction( aFract1.GetDenominator(), aFract1.GetNumerator() ); 728 nValue = aFract; 729 730 // #92067# Swap nominator and denominator 731 aCbScale.SetText( GetScale( nValue, 1 ) ); 732 } 733 else 734 { 735 double fValue = aFract; 736 nValue = aFract; 737 if( fValue > (double)nValue ) 738 nValue++; 739 740 // #92067# Swap nominator and denominator 741 aCbScale.SetText( GetScale( 1, nValue ) ); 742 } 743 return( 0L ); 744 } 745 746 // ----------------------------------------------------------------------- 747 748 String SdTpOptionsMisc::GetScale( sal_Int32 nX, sal_Int32 nY ) 749 { 750 String aScale( UniString::CreateFromInt32( nX ) ); 751 aScale.Append( TOKEN ); 752 aScale.Append( UniString::CreateFromInt32( nY ) ); 753 754 return( aScale ); 755 } 756 757 // ----------------------------------------------------------------------- 758 759 sal_Bool SdTpOptionsMisc::SetScale( const String& aScale, sal_Int32& rX, sal_Int32& rY ) 760 { 761 if( aScale.GetTokenCount( TOKEN ) != 2 ) 762 return( sal_False ); 763 764 ByteString aTmp( aScale.GetToken( 0, TOKEN ), RTL_TEXTENCODING_ASCII_US ); 765 if( !aTmp.IsNumericAscii() ) 766 return( sal_False ); 767 768 rX = (long) aTmp.ToInt32(); 769 if( rX == 0 ) 770 return( sal_False ); 771 772 aTmp = ByteString( aScale.GetToken( 1, TOKEN ), RTL_TEXTENCODING_ASCII_US ); 773 if( !aTmp.IsNumericAscii() ) 774 return( sal_False ); 775 776 rY = (long) aTmp.ToInt32(); 777 if( rY == 0 ) 778 return( sal_False ); 779 780 return( sal_True ); 781 } 782 783 784 785 786 void SdTpOptionsMisc::UpdateCompatibilityControls (void) 787 { 788 // Disable the compatibility controls by default. Enable them only when 789 // there is at least one open document. 790 sal_Bool bIsEnabled = sal_False; 791 792 try 793 { 794 // Get a component enumeration from the desktop and search it for documents. 795 Reference<lang::XMultiServiceFactory> xFactory ( 796 ::comphelper::getProcessServiceFactory ()); 797 do 798 { 799 if ( ! xFactory.is()) 800 break; 801 802 Reference<frame::XDesktop> xDesktop (xFactory->createInstance ( 803 ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY); 804 if ( ! xDesktop.is()) 805 break; 806 807 Reference<container::XEnumerationAccess> xComponents ( 808 xDesktop->getComponents(), UNO_QUERY); 809 if ( ! xComponents.is()) 810 break; 811 812 Reference<container::XEnumeration> xEnumeration ( 813 xComponents->createEnumeration()); 814 if ( ! xEnumeration.is()) 815 break; 816 817 while (xEnumeration->hasMoreElements()) 818 { 819 Reference<frame::XModel> xModel (xEnumeration->nextElement(), UNO_QUERY); 820 if (xModel.is()) 821 { 822 // There is at leas one model/document: Enable the compatibility controls. 823 bIsEnabled = sal_True; 824 break; 825 } 826 } 827 828 } 829 while (false); // One 'loop'. 830 } 831 catch (uno::Exception e) 832 { 833 // When there is an exception then simply use the default value of 834 // bIsEnabled and disable the controls. 835 } 836 837 aTxtCompatibility.Enable (bIsEnabled); 838 aCbxCompatibility.Enable(bIsEnabled); 839 aCbxUsePrinterMetrics.Enable (bIsEnabled); 840 } 841 842 void SdTpOptionsMisc::PageCreated (SfxAllItemSet aSet) 843 { 844 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,sal_False); 845 if (pFlagItem) 846 { 847 sal_uInt32 nFlags=pFlagItem->GetValue(); 848 if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE ) 849 SetDrawMode(); 850 if ( ( nFlags & SD_IMPRESS_MODE ) == SD_IMPRESS_MODE ) 851 SetImpressMode(); 852 } 853 } 854 855