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_svx.hxx" 26 27 #include <svx/svxitems.hrc> 28 29 30 #include <tools/stream.hxx> 31 #include <com/sun/star/table/BorderLine.hpp> 32 #include <com/sun/star/table/CellVertJustify.hpp> 33 #include <com/sun/star/table/ShadowLocation.hpp> 34 #include <com/sun/star/table/TableBorder.hpp> 35 #include <com/sun/star/table/ShadowFormat.hpp> 36 #include <com/sun/star/table/CellRangeAddress.hpp> 37 #include <com/sun/star/table/CellContentType.hpp> 38 #include <com/sun/star/table/TableOrientation.hpp> 39 #include <com/sun/star/table/CellHoriJustify.hpp> 40 #include <com/sun/star/style/ParagraphAdjust.hpp> 41 #include "com/sun/star/style/VerticalAlignment.hpp" 42 #include <com/sun/star/util/SortField.hpp> 43 #include <com/sun/star/util/SortFieldType.hpp> 44 #include <com/sun/star/table/CellOrientation.hpp> 45 #include <com/sun/star/table/CellAddress.hpp> 46 47 #include <svx/algitem.hxx> 48 #include <svx/dialmgr.hxx> 49 #include <editeng/itemtype.hxx> 50 #include <svx/unomid.hxx> 51 52 using namespace ::rtl; 53 using namespace ::com::sun::star; 54 55 // Konvertierung fuer UNO 56 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) 57 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L)) 58 59 // STATIC DATA ----------------------------------------------------------- 60 61 //TYPEINIT1_AUTOFACTORY( SvxHorJustifyItem, SfxEnumItem ); 62 TYPEINIT1_FACTORY( SvxHorJustifyItem, SfxEnumItem, new SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, 0)) 63 TYPEINIT1_FACTORY( SvxVerJustifyItem, SfxEnumItem, new SvxVerJustifyItem(SVX_VER_JUSTIFY_STANDARD, 0) ); 64 TYPEINIT1_FACTORY( SvxOrientationItem, SfxEnumItem, new SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0) ); 65 TYPEINIT1_FACTORY( SvxMarginItem, SfxPoolItem, new SvxMarginItem(0) ); 66 67 // class SvxHorJustifyItem ----------------------------------------------- 68 69 70 SvxHorJustifyItem::SvxHorJustifyItem( const sal_uInt16 nId ) : 71 SfxEnumItem( nId, (sal_uInt16)SVX_HOR_JUSTIFY_STANDARD ) 72 { 73 } 74 75 SvxHorJustifyItem::SvxHorJustifyItem( const SvxCellHorJustify eJustify, 76 const sal_uInt16 nId ) : 77 SfxEnumItem( nId, (sal_uInt16)eJustify ) 78 { 79 } 80 81 //------------------------------------------------------------------------ 82 83 SfxItemPresentation SvxHorJustifyItem::GetPresentation 84 ( 85 SfxItemPresentation ePres, 86 SfxMapUnit /*eCoreUnit*/, 87 SfxMapUnit /*ePresUnit*/, 88 XubString& rText, const IntlWrapper *) const 89 { 90 switch ( ePres ) 91 { 92 case SFX_ITEM_PRESENTATION_NONE: 93 rText.Erase(); 94 return SFX_ITEM_PRESENTATION_NONE; 95 case SFX_ITEM_PRESENTATION_NAMELESS: 96 case SFX_ITEM_PRESENTATION_COMPLETE: 97 rText = GetValueText( GetValue() ); 98 return SFX_ITEM_PRESENTATION_COMPLETE; 99 default: ; //prevent warning 100 } 101 return SFX_ITEM_PRESENTATION_NONE; 102 } 103 104 //------------------------------------------------------------------------ 105 106 sal_Bool SvxHorJustifyItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const 107 { 108 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 109 nMemberId &= ~CONVERT_TWIPS; 110 switch ( nMemberId ) 111 { 112 case MID_HORJUST_HORJUST: 113 { 114 table::CellHoriJustify eUno = table::CellHoriJustify_STANDARD; 115 switch ( (SvxCellHorJustify)GetValue() ) 116 { 117 case SVX_HOR_JUSTIFY_STANDARD: eUno = table::CellHoriJustify_STANDARD; break; 118 case SVX_HOR_JUSTIFY_LEFT: eUno = table::CellHoriJustify_LEFT; break; 119 case SVX_HOR_JUSTIFY_CENTER: eUno = table::CellHoriJustify_CENTER; break; 120 case SVX_HOR_JUSTIFY_RIGHT: eUno = table::CellHoriJustify_RIGHT; break; 121 case SVX_HOR_JUSTIFY_BLOCK: eUno = table::CellHoriJustify_BLOCK; break; 122 case SVX_HOR_JUSTIFY_REPEAT: eUno = table::CellHoriJustify_REPEAT; break; 123 } 124 rVal <<= eUno; 125 } 126 break; 127 case MID_HORJUST_ADJUST: 128 { 129 // ParagraphAdjust values, as in SvxAdjustItem 130 // (same value for ParaAdjust and ParaLastLineAdjust) 131 132 sal_Int16 nAdjust = style::ParagraphAdjust_LEFT; 133 switch ( (SvxCellHorJustify)GetValue() ) 134 { 135 // ParagraphAdjust_LEFT is used for STANDARD and REPEAT 136 case SVX_HOR_JUSTIFY_STANDARD: 137 case SVX_HOR_JUSTIFY_REPEAT: 138 case SVX_HOR_JUSTIFY_LEFT: nAdjust = style::ParagraphAdjust_LEFT; break; 139 case SVX_HOR_JUSTIFY_CENTER: nAdjust = style::ParagraphAdjust_CENTER; break; 140 case SVX_HOR_JUSTIFY_RIGHT: nAdjust = style::ParagraphAdjust_RIGHT; break; 141 case SVX_HOR_JUSTIFY_BLOCK: nAdjust = style::ParagraphAdjust_BLOCK; break; 142 } 143 rVal <<= nAdjust; // as sal_Int16 144 } 145 break; 146 } 147 return sal_True; 148 } 149 150 sal_Bool SvxHorJustifyItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) 151 { 152 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 153 nMemberId &= ~CONVERT_TWIPS; 154 switch ( nMemberId ) 155 { 156 case MID_HORJUST_HORJUST: 157 { 158 table::CellHoriJustify eUno; 159 if(!(rVal >>= eUno)) 160 { 161 sal_Int32 nValue = 0; 162 if(!(rVal >>= nValue)) 163 return sal_False; 164 eUno = (table::CellHoriJustify)nValue; 165 } 166 SvxCellHorJustify eSvx = SVX_HOR_JUSTIFY_STANDARD; 167 switch (eUno) 168 { 169 case table::CellHoriJustify_STANDARD: eSvx = SVX_HOR_JUSTIFY_STANDARD; break; 170 case table::CellHoriJustify_LEFT: eSvx = SVX_HOR_JUSTIFY_LEFT; break; 171 case table::CellHoriJustify_CENTER: eSvx = SVX_HOR_JUSTIFY_CENTER; break; 172 case table::CellHoriJustify_RIGHT: eSvx = SVX_HOR_JUSTIFY_RIGHT; break; 173 case table::CellHoriJustify_BLOCK: eSvx = SVX_HOR_JUSTIFY_BLOCK; break; 174 case table::CellHoriJustify_REPEAT: eSvx = SVX_HOR_JUSTIFY_REPEAT; break; 175 default: ; //prevent warning 176 } 177 SetValue( (sal_uInt16)eSvx ); 178 } 179 break; 180 case MID_HORJUST_ADJUST: 181 { 182 // property contains ParagraphAdjust values as sal_Int16 183 sal_Int16 nVal = sal_Int16(); 184 if(!(rVal >>= nVal)) 185 return sal_False; 186 187 SvxCellHorJustify eSvx = SVX_HOR_JUSTIFY_STANDARD; 188 switch (nVal) 189 { 190 // STRETCH is treated as BLOCK 191 case style::ParagraphAdjust_LEFT: eSvx = SVX_HOR_JUSTIFY_LEFT; break; 192 case style::ParagraphAdjust_RIGHT: eSvx = SVX_HOR_JUSTIFY_RIGHT; break; 193 case style::ParagraphAdjust_STRETCH: 194 case style::ParagraphAdjust_BLOCK: eSvx = SVX_HOR_JUSTIFY_BLOCK; break; 195 case style::ParagraphAdjust_CENTER: eSvx = SVX_HOR_JUSTIFY_CENTER; break; 196 } 197 SetValue( (sal_uInt16)eSvx ); 198 } 199 } 200 return sal_True; 201 } 202 203 //------------------------------------------------------------------------ 204 205 XubString SvxHorJustifyItem::GetValueText( sal_uInt16 nVal ) const 206 { 207 DBG_ASSERT( nVal <= SVX_HOR_JUSTIFY_REPEAT, "enum overflow!" ); 208 return SVX_RESSTR(RID_SVXITEMS_HORJUST_STANDARD + nVal); 209 } 210 211 //------------------------------------------------------------------------ 212 213 SfxPoolItem* SvxHorJustifyItem::Clone( SfxItemPool* ) const 214 { 215 return new SvxHorJustifyItem( *this ); 216 } 217 218 //------------------------------------------------------------------------ 219 220 SfxPoolItem* SvxHorJustifyItem::Create( SvStream& rStream, sal_uInt16 ) const 221 { 222 sal_uInt16 nVal; 223 rStream >> nVal; 224 return new SvxHorJustifyItem( (SvxCellHorJustify)nVal, Which() ); 225 } 226 //------------------------------------------------------------------------ 227 228 sal_uInt16 SvxHorJustifyItem::GetValueCount() const 229 { 230 return SVX_HOR_JUSTIFY_REPEAT + 1; // letzter Enum-Wert + 1 231 } 232 233 // class SvxVerJustifyItem ----------------------------------------------- 234 235 SvxVerJustifyItem::SvxVerJustifyItem( const sal_uInt16 nId ) : 236 SfxEnumItem( nId, (sal_uInt16)SVX_VER_JUSTIFY_STANDARD ) 237 { 238 } 239 240 SvxVerJustifyItem::SvxVerJustifyItem( const SvxCellVerJustify eJustify, 241 const sal_uInt16 nId ) : 242 SfxEnumItem( nId, (sal_uInt16)eJustify ) 243 { 244 } 245 246 //------------------------------------------------------------------------ 247 248 SfxItemPresentation SvxVerJustifyItem::GetPresentation 249 ( 250 SfxItemPresentation ePres, 251 SfxMapUnit /*eCoreUnit*/, 252 SfxMapUnit /*ePresUnit*/, 253 XubString& rText, 254 const IntlWrapper * ) const 255 { 256 switch ( ePres ) 257 { 258 case SFX_ITEM_PRESENTATION_NONE: 259 rText.Erase(); 260 return SFX_ITEM_PRESENTATION_NONE; 261 case SFX_ITEM_PRESENTATION_NAMELESS: 262 case SFX_ITEM_PRESENTATION_COMPLETE: 263 rText = GetValueText( GetValue() ); 264 return SFX_ITEM_PRESENTATION_COMPLETE; 265 default: ; //prevent warning 266 } 267 return SFX_ITEM_PRESENTATION_NONE; 268 } 269 270 //------------------------------------------------------------------------ 271 272 sal_Bool SvxVerJustifyItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const 273 { 274 nMemberId &= ~CONVERT_TWIPS; 275 switch ( nMemberId ) 276 { 277 case MID_HORJUST_ADJUST: 278 { 279 style::VerticalAlignment eUno = style::VerticalAlignment_TOP; 280 switch ( (SvxCellVerJustify)GetValue() ) 281 { 282 case SVX_VER_JUSTIFY_TOP: eUno = style::VerticalAlignment_TOP; break; 283 case SVX_VER_JUSTIFY_CENTER: eUno = style::VerticalAlignment_MIDDLE; break; 284 case SVX_VER_JUSTIFY_BOTTOM: eUno = style::VerticalAlignment_BOTTOM; break; 285 default: ; //prevent warning 286 } 287 rVal <<= eUno; 288 break; 289 } 290 default: 291 { 292 table::CellVertJustify eUno = table::CellVertJustify_STANDARD; 293 switch ( (SvxCellVerJustify)GetValue() ) 294 { 295 case SVX_VER_JUSTIFY_STANDARD: eUno = table::CellVertJustify_STANDARD; break; 296 case SVX_VER_JUSTIFY_TOP: eUno = table::CellVertJustify_TOP; break; 297 case SVX_VER_JUSTIFY_CENTER: eUno = table::CellVertJustify_CENTER; break; 298 case SVX_VER_JUSTIFY_BOTTOM: eUno = table::CellVertJustify_BOTTOM; break; 299 default: ; //prevent warning 300 } 301 rVal <<= eUno; 302 break; 303 } 304 } 305 return sal_True; 306 } 307 308 sal_Bool SvxVerJustifyItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) 309 { 310 nMemberId &= ~CONVERT_TWIPS; 311 switch ( nMemberId ) 312 { 313 case MID_HORJUST_ADJUST: 314 { 315 // property contains ParagraphAdjust values as sal_Int16 316 style::VerticalAlignment nVal = style::VerticalAlignment_TOP; 317 if(!(rVal >>= nVal)) 318 return sal_False; 319 320 SvxCellVerJustify eSvx = SVX_VER_JUSTIFY_STANDARD; 321 switch (nVal) 322 { 323 case style::VerticalAlignment_TOP: eSvx = SVX_VER_JUSTIFY_TOP; break; 324 case style::VerticalAlignment_MIDDLE: eSvx = SVX_VER_JUSTIFY_CENTER; break; 325 case style::VerticalAlignment_BOTTOM: eSvx = SVX_VER_JUSTIFY_BOTTOM; break; 326 default:; 327 } 328 SetValue( (sal_uInt16)eSvx ); 329 break; 330 } 331 default: 332 { 333 table::CellVertJustify eUno; 334 if(!(rVal >>= eUno)) 335 { 336 sal_Int32 nValue = 0; 337 if(!(rVal >>= nValue)) 338 return sal_False; 339 eUno = (table::CellVertJustify)nValue; 340 } 341 342 SvxCellVerJustify eSvx = SVX_VER_JUSTIFY_STANDARD; 343 switch (eUno) 344 { 345 case table::CellVertJustify_STANDARD: eSvx = SVX_VER_JUSTIFY_STANDARD; break; 346 case table::CellVertJustify_TOP: eSvx = SVX_VER_JUSTIFY_TOP; break; 347 case table::CellVertJustify_CENTER: eSvx = SVX_VER_JUSTIFY_CENTER; break; 348 case table::CellVertJustify_BOTTOM: eSvx = SVX_VER_JUSTIFY_BOTTOM; break; 349 default: ; //prevent warning 350 } 351 SetValue( (sal_uInt16)eSvx ); 352 break; 353 } 354 } 355 356 return sal_True; 357 } 358 359 //------------------------------------------------------------------------ 360 361 XubString SvxVerJustifyItem::GetValueText( sal_uInt16 nVal ) const 362 { 363 DBG_ASSERT( nVal <= SVX_VER_JUSTIFY_BOTTOM, "enum overflow!" ); 364 return SVX_RESSTR(RID_SVXITEMS_VERJUST_STANDARD + nVal); 365 } 366 367 //------------------------------------------------------------------------ 368 369 SfxPoolItem* SvxVerJustifyItem::Clone( SfxItemPool* ) const 370 { 371 return new SvxVerJustifyItem( *this ); 372 } 373 374 //------------------------------------------------------------------------ 375 376 SfxPoolItem* SvxVerJustifyItem::Create( SvStream& rStream, sal_uInt16 ) const 377 { 378 sal_uInt16 nVal; 379 rStream >> nVal; 380 return new SvxVerJustifyItem( (SvxCellVerJustify)nVal, Which() ); 381 } 382 383 //------------------------------------------------------------------------ 384 385 sal_uInt16 SvxVerJustifyItem::GetValueCount() const 386 { 387 return SVX_VER_JUSTIFY_BOTTOM + 1; // letzter Enum-Wert + 1 388 } 389 390 // class SvxOrientationItem ---------------------------------------------- 391 392 SvxOrientationItem::SvxOrientationItem( const SvxCellOrientation eOrientation, 393 const sal_uInt16 nId): 394 SfxEnumItem( nId, (sal_uInt16)eOrientation ) 395 { 396 } 397 398 SvxOrientationItem::SvxOrientationItem( sal_Int32 nRotation, sal_Bool bStacked, const sal_uInt16 nId ) : 399 SfxEnumItem( nId ) 400 { 401 SetFromRotation( nRotation, bStacked ); 402 } 403 404 //------------------------------------------------------------------------ 405 406 SfxItemPresentation SvxOrientationItem::GetPresentation 407 ( 408 SfxItemPresentation ePres, 409 SfxMapUnit /*eCoreUnit*/, 410 SfxMapUnit /*ePresUnit*/, 411 XubString& rText, const IntlWrapper * ) const 412 { 413 switch ( ePres ) 414 { 415 case SFX_ITEM_PRESENTATION_NONE: 416 rText.Erase(); 417 return SFX_ITEM_PRESENTATION_NONE; 418 case SFX_ITEM_PRESENTATION_NAMELESS: 419 case SFX_ITEM_PRESENTATION_COMPLETE: 420 rText = GetValueText( GetValue() ); 421 return SFX_ITEM_PRESENTATION_COMPLETE; 422 default: ; //prevent warning 423 } 424 return SFX_ITEM_PRESENTATION_NONE; 425 } 426 427 //------------------------------------------------------------------------ 428 429 sal_Bool SvxOrientationItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const 430 { 431 table::CellOrientation eUno = table::CellOrientation_STANDARD; 432 switch ( (SvxCellOrientation)GetValue() ) 433 { 434 case SVX_ORIENTATION_STANDARD: eUno = table::CellOrientation_STANDARD; break; 435 case SVX_ORIENTATION_TOPBOTTOM: eUno = table::CellOrientation_TOPBOTTOM; break; 436 case SVX_ORIENTATION_BOTTOMTOP: eUno = table::CellOrientation_BOTTOMTOP; break; 437 case SVX_ORIENTATION_STACKED: eUno = table::CellOrientation_STACKED; break; 438 } 439 rVal <<= eUno; 440 return sal_True; 441 } 442 443 sal_Bool SvxOrientationItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) 444 { 445 table::CellOrientation eOrient; 446 if(!(rVal >>= eOrient)) 447 { 448 sal_Int32 nValue = 0; 449 if(!(rVal >>= nValue)) 450 return sal_False; 451 eOrient = (table::CellOrientation)nValue; 452 } 453 SvxCellOrientation eSvx = SVX_ORIENTATION_STANDARD; 454 switch (eOrient) 455 { 456 case table::CellOrientation_STANDARD: eSvx = SVX_ORIENTATION_STANDARD; break; 457 case table::CellOrientation_TOPBOTTOM: eSvx = SVX_ORIENTATION_TOPBOTTOM; break; 458 case table::CellOrientation_BOTTOMTOP: eSvx = SVX_ORIENTATION_BOTTOMTOP; break; 459 case table::CellOrientation_STACKED: eSvx = SVX_ORIENTATION_STACKED; break; 460 default: ; //prevent warning 461 } 462 SetValue( (sal_uInt16)eSvx ); 463 return sal_True; 464 } 465 466 //------------------------------------------------------------------------ 467 468 XubString SvxOrientationItem::GetValueText( sal_uInt16 nVal ) const 469 { 470 DBG_ASSERT( nVal <= SVX_ORIENTATION_STACKED, "enum overflow!" ); 471 return SVX_RESSTR(RID_SVXITEMS_ORI_STANDARD + nVal); 472 } 473 474 //------------------------------------------------------------------------ 475 476 SfxPoolItem* SvxOrientationItem::Clone( SfxItemPool* ) const 477 { 478 return new SvxOrientationItem( *this ); 479 } 480 481 //------------------------------------------------------------------------ 482 483 SfxPoolItem* SvxOrientationItem::Create( SvStream& rStream, sal_uInt16 ) const 484 { 485 sal_uInt16 nVal; 486 rStream >> nVal; 487 return new SvxOrientationItem( (SvxCellOrientation)nVal, Which() ); 488 } 489 490 //------------------------------------------------------------------------ 491 492 sal_uInt16 SvxOrientationItem::GetValueCount() const 493 { 494 return SVX_ORIENTATION_STACKED + 1; // letzter Enum-Wert + 1 495 } 496 497 //------------------------------------------------------------------------ 498 499 sal_Bool SvxOrientationItem::IsStacked() const 500 { 501 return static_cast< SvxCellOrientation >( GetValue() ) == SVX_ORIENTATION_STACKED; 502 } 503 504 sal_Int32 SvxOrientationItem::GetRotation( sal_Int32 nStdAngle ) const 505 { 506 sal_Int32 nAngle = nStdAngle; 507 switch( static_cast< SvxCellOrientation >( GetValue() ) ) 508 { 509 case SVX_ORIENTATION_BOTTOMTOP: nAngle = 9000; 510 case SVX_ORIENTATION_TOPBOTTOM: nAngle = 27000; 511 default: ; //prevent warning 512 } 513 return nAngle; 514 } 515 516 void SvxOrientationItem::SetFromRotation( sal_Int32 nRotation, sal_Bool bStacked ) 517 { 518 if( bStacked ) 519 { 520 SetValue( SVX_ORIENTATION_STACKED ); 521 } 522 else switch( nRotation ) 523 { 524 case 9000: SetValue( SVX_ORIENTATION_BOTTOMTOP ); break; 525 case 27000: SetValue( SVX_ORIENTATION_TOPBOTTOM ); break; 526 default: SetValue( SVX_ORIENTATION_STANDARD ); 527 } 528 } 529 530 // class SvxMarginItem --------------------------------------------------- 531 532 SvxMarginItem::SvxMarginItem( const sal_uInt16 nId ) : 533 534 SfxPoolItem( nId ), 535 536 nLeftMargin ( 20 ), 537 nTopMargin ( 20 ), 538 nRightMargin ( 20 ), 539 nBottomMargin( 20 ) 540 { 541 } 542 543 //------------------------------------------------------------------------ 544 545 SvxMarginItem::SvxMarginItem( sal_Int16 nLeft, 546 sal_Int16 nTop, 547 sal_Int16 nRight, 548 sal_Int16 nBottom, 549 const sal_uInt16 nId ) : 550 SfxPoolItem( nId ), 551 552 nLeftMargin ( nLeft ), 553 nTopMargin ( nTop ), 554 nRightMargin ( nRight ), 555 nBottomMargin( nBottom ) 556 { 557 } 558 559 560 //------------------------------------------------------------------------ 561 562 SvxMarginItem::SvxMarginItem( const SvxMarginItem& rItem ) : 563 564 SfxPoolItem( rItem.Which() ) 565 { 566 nLeftMargin = rItem.nLeftMargin; 567 nTopMargin = rItem.nTopMargin; 568 nRightMargin = rItem.nRightMargin; 569 nBottomMargin = rItem.nBottomMargin; 570 } 571 572 //------------------------------------------------------------------------ 573 574 SfxItemPresentation SvxMarginItem::GetPresentation 575 ( 576 SfxItemPresentation ePres, 577 SfxMapUnit eCoreUnit, 578 SfxMapUnit ePresUnit, 579 XubString& rText, const IntlWrapper *pIntl 580 ) const 581 { 582 #ifndef SVX_LIGHT 583 switch ( ePres ) 584 { 585 case SFX_ITEM_PRESENTATION_NONE: 586 rText.Erase(); 587 return SFX_ITEM_PRESENTATION_NONE; 588 case SFX_ITEM_PRESENTATION_NAMELESS: 589 { 590 rText = GetMetricText( (long)nLeftMargin, eCoreUnit, ePresUnit, pIntl ); 591 rText += cpDelim; 592 rText += GetMetricText( (long)nTopMargin, eCoreUnit, ePresUnit, pIntl ); 593 rText += cpDelim; 594 rText += GetMetricText( (long)nRightMargin, eCoreUnit, ePresUnit, pIntl ); 595 rText += cpDelim; 596 rText += GetMetricText( (long)nBottomMargin, eCoreUnit, ePresUnit, pIntl ); 597 return SFX_ITEM_PRESENTATION_NAMELESS; 598 } 599 case SFX_ITEM_PRESENTATION_COMPLETE: 600 { 601 rText = SVX_RESSTR(RID_SVXITEMS_MARGIN_LEFT); 602 rText += GetMetricText( (long)nLeftMargin, eCoreUnit, ePresUnit, pIntl ); 603 rText += SVX_RESSTR(GetMetricId(ePresUnit)); 604 rText += cpDelim; 605 rText += SVX_RESSTR(RID_SVXITEMS_MARGIN_TOP); 606 rText += GetMetricText( (long)nTopMargin, eCoreUnit, ePresUnit, pIntl ); 607 rText += SVX_RESSTR(GetMetricId(ePresUnit)); 608 rText += cpDelim; 609 rText += SVX_RESSTR(RID_SVXITEMS_MARGIN_RIGHT); 610 rText += GetMetricText( (long)nRightMargin, eCoreUnit, ePresUnit, pIntl ); 611 rText += SVX_RESSTR(GetMetricId(ePresUnit)); 612 rText += cpDelim; 613 rText += SVX_RESSTR(RID_SVXITEMS_MARGIN_BOTTOM); 614 rText += GetMetricText( (long)nBottomMargin, eCoreUnit, ePresUnit, pIntl ); 615 rText += SVX_RESSTR(GetMetricId(ePresUnit)); 616 return SFX_ITEM_PRESENTATION_COMPLETE; 617 } 618 default: ; //prevent warning 619 } 620 #endif 621 return SFX_ITEM_PRESENTATION_NONE; 622 } 623 624 //------------------------------------------------------------------------ 625 626 int SvxMarginItem::operator==( const SfxPoolItem& rItem ) const 627 { 628 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" ); 629 630 return ( ( nLeftMargin == ( (SvxMarginItem&)rItem ).nLeftMargin ) && 631 ( nTopMargin == ( (SvxMarginItem&)rItem ).nTopMargin ) && 632 ( nRightMargin == ( (SvxMarginItem&)rItem ).nRightMargin ) && 633 ( nBottomMargin == ( (SvxMarginItem&)rItem ).nBottomMargin ) ); 634 } 635 636 //------------------------------------------------------------------------ 637 638 SfxPoolItem* SvxMarginItem::Clone( SfxItemPool* ) const 639 { 640 return new SvxMarginItem(*this); 641 } 642 643 //------------------------------------------------------------------------ 644 645 SfxPoolItem* SvxMarginItem::Create( SvStream& rStream, sal_uInt16 ) const 646 { 647 sal_Int16 nLeft; 648 sal_Int16 nTop; 649 sal_Int16 nRight; 650 sal_Int16 nBottom; 651 rStream >> nLeft; 652 rStream >> nTop; 653 rStream >> nRight; 654 rStream >> nBottom; 655 return new SvxMarginItem( nLeft, nTop, nRight, nBottom, Which() ); 656 } 657 658 //------------------------------------------------------------------------ 659 660 SvStream& SvxMarginItem::Store( SvStream &rStream, sal_uInt16 /*nItemVersion*/) const 661 { 662 rStream << nLeftMargin; 663 rStream << nTopMargin; 664 rStream << nRightMargin; 665 rStream << nBottomMargin; 666 return rStream; 667 } 668 669 670 //------------------------------------------------------------------------ 671 672 sal_Bool SvxMarginItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const 673 { 674 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 675 nMemberId &= ~CONVERT_TWIPS; 676 switch ( nMemberId ) 677 { 678 // jetzt alles signed 679 case MID_MARGIN_L_MARGIN: 680 rVal <<= (sal_Int32)( bConvert ? TWIP_TO_MM100(nLeftMargin) : nLeftMargin ); 681 break; 682 case MID_MARGIN_R_MARGIN: 683 rVal <<= (sal_Int32)( bConvert ? TWIP_TO_MM100(nRightMargin) : nRightMargin ); 684 break; 685 case MID_MARGIN_UP_MARGIN: 686 rVal <<= (sal_Int32)( bConvert ? TWIP_TO_MM100(nTopMargin) : nTopMargin ); 687 break; 688 case MID_MARGIN_LO_MARGIN: 689 rVal <<= (sal_Int32)( bConvert ? TWIP_TO_MM100(nBottomMargin) : nBottomMargin ); 690 break; 691 default: 692 DBG_ERROR("unknown MemberId"); 693 return sal_False; 694 } 695 return sal_True; 696 } 697 698 //------------------------------------------------------------------------ 699 700 sal_Bool SvxMarginItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) 701 { 702 sal_Bool bConvert = ( ( nMemberId & CONVERT_TWIPS ) != 0 ); 703 long nMaxVal = bConvert ? TWIP_TO_MM100(SHRT_MAX) : SHRT_MAX; // Members sind sal_Int16 704 sal_Int32 nVal = 0; 705 if(!(rVal >>= nVal) || (nVal > nMaxVal)) 706 return sal_False; 707 708 switch ( nMemberId & ~CONVERT_TWIPS ) 709 { 710 case MID_MARGIN_L_MARGIN: 711 nLeftMargin = (sal_Int16)( bConvert ? MM100_TO_TWIP(nVal) : nVal ); 712 break; 713 case MID_MARGIN_R_MARGIN: 714 nRightMargin = (sal_Int16)( bConvert ? MM100_TO_TWIP(nVal) : nVal ); 715 break; 716 case MID_MARGIN_UP_MARGIN: 717 nTopMargin = (sal_Int16)( bConvert ? MM100_TO_TWIP(nVal) : nVal ); 718 break; 719 case MID_MARGIN_LO_MARGIN: 720 nBottomMargin = (sal_Int16)( bConvert ? MM100_TO_TWIP(nVal) : nVal ); 721 break; 722 default: 723 DBG_ERROR("unknown MemberId"); 724 return sal_False; 725 } 726 return sal_True; 727 } 728 729 //------------------------------------------------------------------------ 730 731 sal_Bool SvxMarginItem::SetLeftMargin( sal_Int16 nLeft ) 732 { 733 nLeftMargin = nLeft; 734 return sal_True; 735 } 736 737 //------------------------------------------------------------------------ 738 739 sal_Bool SvxMarginItem::SetTopMargin( sal_Int16 nTop ) 740 { 741 nTopMargin = nTop; 742 return sal_True; 743 } 744 745 //------------------------------------------------------------------------ 746 747 sal_Bool SvxMarginItem::SetRightMargin( sal_Int16 nRight ) 748 { 749 nRightMargin = nRight; 750 return sal_True; 751 } 752 753 //------------------------------------------------------------------------ 754 755 sal_Bool SvxMarginItem::SetBottomMargin( sal_Int16 nBottom ) 756 { 757 nBottomMargin = nBottom; 758 return sal_True; 759 } 760 761 762