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 <com/sun/star/drawing/BitmapMode.hpp> 28 #include <com/sun/star/style/XStyle.hpp> 29 #include <com/sun/star/text/WritingMode.hpp> 30 #include <com/sun/star/table/TableBorder.hpp> 31 32 #include <cppuhelper/typeprovider.hxx> 33 #include <svl/style.hxx> 34 #include <svl/itemset.hxx> 35 36 #include <vos/mutex.hxx> 37 #include <vcl/svapp.hxx> 38 39 #include "svx/sdr/properties/textproperties.hxx" 40 #include "editeng/outlobj.hxx" 41 #include "editeng/writingmodeitem.hxx" 42 #include "svx/svdotable.hxx" 43 #include "svx/svdoutl.hxx" 44 #include "svx/unoshtxt.hxx" 45 #include "svx/svdmodel.hxx" 46 47 #include "tableundo.hxx" 48 #include "cell.hxx" 49 #include "svx/svdotable.hxx" 50 #include "svx/svdoutl.hxx" 51 #include "svx/unoshtxt.hxx" 52 #include "svx/unoshprp.hxx" 53 #include "svx/unoshape.hxx" 54 #include "editeng/editobj.hxx" 55 #include "editeng/boxitem.hxx" 56 #include "svx/xflbstit.hxx" 57 #include "svx/xflbmtit.hxx" 58 #include <svx/svdpool.hxx> 59 60 // ----------------------------------------------------------------------------- 61 62 using ::rtl::OUString; 63 using ::vos::OGuard; 64 using namespace ::com::sun::star::uno; 65 using namespace ::com::sun::star::beans; 66 using namespace ::com::sun::star::lang; 67 using namespace ::com::sun::star::text; 68 using namespace ::com::sun::star::table; 69 using namespace ::com::sun::star::drawing; 70 using namespace ::com::sun::star::style; 71 using namespace ::com::sun::star::container; 72 73 // ----------------------------------------------------------------------------- 74 75 static const SvxItemPropertySet* ImplGetSvxCellPropertySet() 76 { 77 // Propertymap fuer einen Outliner Text 78 static const SfxItemPropertyMapEntry aSvxCellPropertyMap[] = 79 { 80 FILL_PROPERTIES 81 // { MAP_CHAR_LEN("HasLevels"), OWN_ATTR_HASLEVELS, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, 82 { MAP_CHAR_LEN("Style"), OWN_ATTR_STYLE, &::com::sun::star::style::XStyle::static_type(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, 83 { MAP_CHAR_LEN(UNO_NAME_TEXT_WRITINGMODE), SDRATTR_TEXTDIRECTION, &::getCppuType( (::com::sun::star::text::WritingMode*) 0 ), 0, 0}, 84 { MAP_CHAR_LEN(UNO_NAME_TEXT_HORZADJUST), SDRATTR_TEXT_HORZADJUST, &::getCppuType((const ::com::sun::star::drawing::TextHorizontalAdjust*)0), 0, 0}, \ 85 { MAP_CHAR_LEN(UNO_NAME_TEXT_LEFTDIST), SDRATTR_TEXT_LEFTDIST, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, \ 86 { MAP_CHAR_LEN(UNO_NAME_TEXT_LOWERDIST), SDRATTR_TEXT_LOWERDIST, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, \ 87 { MAP_CHAR_LEN(UNO_NAME_TEXT_RIGHTDIST), SDRATTR_TEXT_RIGHTDIST, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, \ 88 { MAP_CHAR_LEN(UNO_NAME_TEXT_UPPERDIST), SDRATTR_TEXT_UPPERDIST, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, \ 89 { MAP_CHAR_LEN(UNO_NAME_TEXT_VERTADJUST), SDRATTR_TEXT_VERTADJUST, &::getCppuType((const ::com::sun::star::drawing::TextVerticalAdjust*)0), 0, 0},\ 90 { MAP_CHAR_LEN(UNO_NAME_TEXT_WORDWRAP), SDRATTR_TEXT_WORDWRAP, &::getBooleanCppuType(), 0, 0}, \ 91 92 { MAP_CHAR_LEN("TableBorder"), OWN_ATTR_TABLEBORDER, &::getCppuType((const TableBorder*)0), 0, 0 }, \ 93 { MAP_CHAR_LEN("TopBorder"), SDRATTR_TABLE_BORDER, &::getCppuType((const BorderLine*)0), 0, TOP_BORDER }, \ 94 { MAP_CHAR_LEN("BottomBorder"), SDRATTR_TABLE_BORDER, &::getCppuType((const BorderLine*)0), 0, BOTTOM_BORDER }, \ 95 { MAP_CHAR_LEN("LeftBorder"), SDRATTR_TABLE_BORDER, &::getCppuType((const BorderLine*)0), 0, LEFT_BORDER }, \ 96 { MAP_CHAR_LEN("RightBorder"), SDRATTR_TABLE_BORDER, &::getCppuType((const BorderLine*)0), 0, RIGHT_BORDER }, \ 97 98 SVX_UNOEDIT_OUTLINER_PROPERTIES, 99 SVX_UNOEDIT_CHAR_PROPERTIES, 100 SVX_UNOEDIT_PARA_PROPERTIES, 101 {0,0,0,0,0,0} 102 }; 103 104 static SvxItemPropertySet aSvxCellPropertySet( aSvxCellPropertyMap, SdrObject::GetGlobalDrawObjectItemPool() ); 105 return &aSvxCellPropertySet; 106 } 107 108 namespace sdr 109 { 110 namespace properties 111 { 112 class CellProperties : public TextProperties 113 { 114 protected: 115 // create a new itemset 116 SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& rPool); 117 118 public: 119 // basic constructor 120 CellProperties(SdrObject& rObj, sdr::table::Cell* pCell ); 121 122 // constructor for copying, but using new object 123 CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell); 124 125 // destructor 126 ~CellProperties(); 127 128 // Clone() operator, normally just calls the local copy constructor 129 BaseProperties& Clone(SdrObject& rObj) const; 130 131 void ForceDefaultAttributes(); 132 133 void ItemSetChanged(const SfxItemSet& rSet); 134 135 void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem); 136 137 void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr); 138 139 sdr::table::CellRef mxCell; 140 }; 141 142 // create a new itemset 143 SfxItemSet& CellProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) 144 { 145 return *(new SfxItemSet(rPool, 146 147 // range from SdrAttrObj 148 SDRATTR_START, SDRATTR_SHADOW_LAST, 149 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, 150 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 151 152 // range for SdrTableObj 153 SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST, 154 155 // range from SdrTextObj 156 EE_ITEMS_START, EE_ITEMS_END, 157 158 // end 159 0, 0)); 160 } 161 162 CellProperties::CellProperties(SdrObject& rObj, sdr::table::Cell* pCell) 163 : TextProperties(rObj) 164 , mxCell(pCell) 165 { 166 } 167 168 CellProperties::CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell) 169 : TextProperties(rProps, rObj) 170 , mxCell( pCell ) 171 { 172 } 173 174 CellProperties::~CellProperties() 175 { 176 } 177 178 BaseProperties& CellProperties::Clone(SdrObject& rObj) const 179 { 180 DBG_ERROR("CellProperties::Clone(), does not work yet!"); 181 return *(new CellProperties(*this, rObj,0)); 182 } 183 184 void CellProperties::ForceDefaultAttributes() 185 { 186 } 187 188 void CellProperties::ItemSetChanged(const SfxItemSet& rSet ) 189 { 190 SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); 191 192 if( mxCell.is() ) 193 { 194 OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject(); 195 196 bool bOwnParaObj = pParaObj != 0; 197 198 if( pParaObj == 0 ) 199 pParaObj = mxCell->GetOutlinerParaObject(); 200 201 if(pParaObj) 202 { 203 // handle outliner attributes 204 Outliner* pOutliner = 0; 205 206 if(mxCell->IsTextEditActive()) 207 { 208 pOutliner = rObj.GetTextEditOutliner(); 209 } 210 else 211 { 212 pOutliner = &rObj.ImpGetDrawOutliner(); 213 pOutliner->SetText(*pParaObj); 214 } 215 216 sal_uInt32 nParaCount(pOutliner->GetParagraphCount()); 217 218 for(sal_uInt32 nPara = 0; nPara < nParaCount; nPara++) 219 { 220 SfxItemSet aSet(pOutliner->GetParaAttribs(nPara)); 221 aSet.Put(rSet); 222 pOutliner->SetParaAttribs(nPara, aSet); 223 } 224 225 if(!mxCell->IsTextEditActive()) 226 { 227 if(nParaCount) 228 { 229 // force ItemSet 230 GetObjectItemSet(); 231 232 SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L)); 233 mpItemSet->Put(aNewSet); 234 } 235 236 OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount); 237 pOutliner->Clear(); 238 239 mxCell->SetOutlinerParaObject(pTemp); 240 } 241 242 if( bOwnParaObj ) 243 delete pParaObj; 244 } 245 } 246 247 // call parent 248 AttributeProperties::ItemSetChanged(rSet); 249 250 if( mxCell.is() ) 251 mxCell->notifyModified(); 252 } 253 254 void CellProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem) 255 { 256 if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich)) 257 { 258 sal_Bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue()); 259 260 sdr::table::SdrTableObj& rObj = (sdr::table::SdrTableObj&)GetSdrObject(); 261 if( rObj.IsVerticalWriting() != bVertical ) 262 rObj.SetVerticalWriting(bVertical); 263 264 // Set a cell vertical property 265 OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject(); 266 if( pParaObj == 0 ) 267 pParaObj = mxCell->GetOutlinerParaObject(); 268 if(pParaObj) 269 { 270 pParaObj->SetVertical(bVertical); 271 } 272 273 } 274 275 // call parent 276 AttributeProperties::ItemChange( nWhich, pNewItem ); 277 } 278 279 void CellProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr) 280 { 281 TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr ); 282 } 283 } // end of namespace properties 284 } // end of namespace sdr 285 286 namespace sdr { namespace table { 287 288 // ----------------------------------------------------------------------------- 289 // Cell 290 // ----------------------------------------------------------------------------- 291 292 rtl::Reference< Cell > Cell::create( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) 293 { 294 rtl::Reference< Cell > xCell( new Cell( rTableObj, pOutlinerParaObject ) ); 295 if( xCell->mxTable.is() ) 296 { 297 Reference< XEventListener > xListener( xCell.get() ); 298 xCell->mxTable->addEventListener( xListener ); 299 } 300 return xCell; 301 } 302 303 // ----------------------------------------------------------------------------- 304 305 Cell::Cell( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) throw() 306 : SdrText( rTableObj, pOutlinerParaObject ) 307 , SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() ) 308 , mpPropSet( ImplGetSvxCellPropertySet() ) 309 , mpProperties( new sdr::properties::CellProperties( rTableObj, this ) ) 310 , mnCellContentType( CellContentType_EMPTY ) 311 , mfValue( 0.0 ) 312 , mnError( 0 ) 313 , mbMerged( sal_False ) 314 , mnRowSpan( 1 ) 315 , mnColSpan( 1 ) 316 , mxTable( rTableObj.getTable() ) 317 { 318 if( rTableObj.GetModel() ) 319 SetModel( rTableObj.GetModel() ); 320 } 321 322 // ----------------------------------------------------------------------------- 323 324 Cell::~Cell() throw() 325 { 326 dispose(); 327 } 328 329 // ----------------------------------------------------------------------------- 330 331 void Cell::dispose() 332 { 333 if( mxTable.is() ) 334 { 335 try 336 { 337 Reference< XEventListener > xThis( this ); 338 mxTable->removeEventListener( xThis ); 339 } 340 catch( Exception& ) 341 { 342 DBG_ERROR("Cell::dispose(), exception caught!"); 343 } 344 mxTable.clear(); 345 } 346 347 if( mpProperties ) 348 { 349 delete mpProperties; 350 mpProperties = 0; 351 } 352 SetOutlinerParaObject( 0 ); 353 } 354 355 // ----------------------------------------------------------------------------- 356 357 void Cell::SetModel(SdrModel* pNewModel) 358 { 359 SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( GetEditSource() ); 360 if( (GetModel() != pNewModel) || ( pNewModel && !pTextEditSource) ) 361 { 362 if( mpProperties ) 363 { 364 SfxItemPool* pItemPool = mpProperties->GetObjectItemSet().GetPool(); 365 366 // test for correct pool in ItemSet; move to new pool if necessary 367 if( pNewModel && pItemPool && pItemPool != &pNewModel->GetItemPool()) 368 mpProperties->MoveToItemPool(pItemPool, &pNewModel->GetItemPool(), pNewModel); 369 } 370 371 if( pTextEditSource ) 372 { 373 pTextEditSource->ChangeModel( pNewModel ); 374 } 375 else 376 { 377 SetEditSource( new SvxTextEditSource( &GetObject(), this, static_cast< XWeak * >( this ) ) ); 378 } 379 380 SetStyleSheet( 0, sal_True ); 381 SdrText::SetModel( pNewModel ); 382 ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT ); 383 } 384 } 385 386 // ----------------------------------------------------------------------------- 387 388 void Cell::merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan ) 389 { 390 if( (mnColSpan != nColumnSpan) || (mnRowSpan != nRowSpan) || (mbMerged != sal_False) ) 391 { 392 mnColSpan = nColumnSpan; 393 mnRowSpan = nRowSpan; 394 mbMerged = sal_False; 395 notifyModified(); 396 } 397 } 398 399 // ----------------------------------------------------------------------------- 400 401 void Cell::mergeContent( const CellRef& xSourceCell ) 402 { 403 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); 404 405 if( xSourceCell->hasText() ) 406 { 407 SdrOutliner& rOutliner=rTableObj.ImpGetDrawOutliner(); 408 rOutliner.SetUpdateMode(sal_True); 409 410 if( hasText() ) 411 { 412 rOutliner.SetText(*GetOutlinerParaObject()); 413 rOutliner.AddText(*xSourceCell->GetOutlinerParaObject()); 414 } 415 else 416 { 417 rOutliner.SetText(*xSourceCell->GetOutlinerParaObject()); 418 } 419 420 SetOutlinerParaObject( rOutliner.CreateParaObject() ); 421 rOutliner.Clear(); 422 xSourceCell->SetOutlinerParaObject(rOutliner.CreateParaObject()); 423 rOutliner.Clear(); 424 SetStyleSheet( GetStyleSheet(), sal_True ); 425 } 426 } 427 428 // ----------------------------------------------------------------------------- 429 430 void Cell::cloneFrom( const CellRef& xCell ) 431 { 432 if( xCell.is() ) 433 { 434 replaceContentAndFormating( xCell ); 435 436 mnCellContentType = xCell->mnCellContentType; 437 438 msFormula = xCell->msFormula; 439 mfValue = xCell->mfValue; 440 mnError = xCell->mnError; 441 442 mbMerged = xCell->mbMerged; 443 mnRowSpan = xCell->mnRowSpan; 444 mnColSpan = xCell->mnColSpan; 445 446 } 447 notifyModified(); 448 } 449 450 void Cell::replaceContentAndFormating( const CellRef& xSourceCell ) 451 { 452 if( xSourceCell.is() && mpProperties ) 453 { 454 mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() ); 455 SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) ); 456 457 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); 458 SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() ); 459 460 if(rSourceTableObj.GetModel() != rTableObj.GetModel()) 461 { 462 SetStyleSheet( 0, sal_True ); 463 } 464 } 465 } 466 467 // ----------------------------------------------------------------------------- 468 469 void Cell::setMerged() 470 { 471 if( !mbMerged ) 472 { 473 mbMerged = sal_True; 474 notifyModified(); 475 } 476 } 477 478 // ----------------------------------------------------------------------------- 479 480 void Cell::notifyModified() 481 { 482 if( mxTable.is() ) 483 mxTable->setModified( sal_True ); 484 } 485 486 // ----------------------------------------------------------------------------- 487 // SdrTextShape proxy 488 // ----------------------------------------------------------------------------- 489 490 bool Cell::IsTextEditActive() 491 { 492 bool isActive = false; 493 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); 494 if(rTableObj.getActiveCell().get() == this ) 495 { 496 OutlinerParaObject* pParaObj = rTableObj.GetEditOutlinerParaObject(); 497 if( pParaObj != 0 ) 498 { 499 isActive = true; 500 delete pParaObj; 501 } 502 } 503 return isActive; 504 } 505 506 // ----------------------------------------------------------------------------- 507 508 bool Cell::hasText() const 509 { 510 OutlinerParaObject* pParaObj = GetOutlinerParaObject(); 511 if( pParaObj ) 512 { 513 const EditTextObject& rTextObj = pParaObj->GetTextObject(); 514 if( rTextObj.GetParagraphCount() >= 1 ) 515 { 516 if( rTextObj.GetParagraphCount() == 1 ) 517 { 518 if( rTextObj.GetText(0).Len() == 0 ) 519 return false; 520 } 521 return true; 522 } 523 } 524 525 return false; 526 } 527 528 // ----------------------------------------------------------------------------- 529 530 OutlinerParaObject* Cell::GetEditOutlinerParaObject() const 531 { 532 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); 533 if( rTableObj.getActiveCell().get() == this ) 534 return rTableObj.GetEditOutlinerParaObject(); 535 return 0; 536 } 537 538 // ----------------------------------------------------------------------------- 539 540 void Cell::SetStyleSheet( SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr ) 541 { 542 // only allow cell styles for cells 543 if( pStyleSheet && pStyleSheet->GetFamily() != SFX_STYLE_FAMILY_FRAME ) 544 return; 545 546 if( mpProperties && (mpProperties->GetStyleSheet() != pStyleSheet) ) 547 { 548 mpProperties->SetStyleSheet( pStyleSheet, bDontRemoveHardAttr ); 549 } 550 } 551 552 // ----------------------------------------------------------------------------- 553 554 const SfxItemSet& Cell::GetObjectItemSet() 555 { 556 if( mpProperties ) 557 { 558 return mpProperties->GetObjectItemSet(); 559 } 560 else 561 { 562 DBG_ERROR("Cell::GetObjectItemSet(), called without properties!"); 563 return GetObject().GetObjectItemSet(); 564 } 565 } 566 567 void Cell::SetObjectItem(const SfxPoolItem& rItem) 568 { 569 if( mpProperties ) 570 { 571 mpProperties->SetObjectItem( rItem ); 572 notifyModified(); 573 } 574 } 575 576 void Cell::SetMergedItem(const SfxPoolItem& rItem) 577 { 578 SetObjectItem(rItem); 579 } 580 581 SfxStyleSheet* Cell::GetStyleSheet() const 582 { 583 if( mpProperties ) 584 return mpProperties->GetStyleSheet(); 585 else 586 return 0; 587 } 588 589 // ----------------------------------------------------------------------------- 590 591 SfxStyleSheetPool* Cell::GetStyleSheetPool() const 592 { 593 if( mpProperties && mpProperties->GetStyleSheet() ) 594 return dynamic_cast< SfxStyleSheetPool* >( &mpProperties->GetStyleSheet()->GetPool() ); 595 else 596 return 0; 597 } 598 599 // ----------------------------------------------------------------------------- 600 601 const Rectangle& Cell::GetCurrentBoundRect() const 602 { 603 return maCellRect; 604 } 605 606 // ----------------------------------------------------------------------------- 607 608 void Cell::TakeTextAnchorRect(Rectangle& rAnchorRect) const 609 { 610 rAnchorRect.nLeft = maCellRect.nLeft + GetTextLeftDistance(); 611 rAnchorRect.nRight = maCellRect.nRight - GetTextRightDistance(); 612 rAnchorRect.nTop = maCellRect.nTop + GetTextUpperDistance(); 613 rAnchorRect.nBottom = maCellRect.nBottom - GetTextLowerDistance(); 614 } 615 616 // ----------------------------------------------------------------------------- 617 618 const SfxItemSet& Cell::GetItemSet() const 619 { 620 return mpProperties->GetObjectItemSet(); 621 } 622 623 // ----------------------------------------------------------------------------- 624 625 void Cell::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems) 626 { 627 if( mpProperties ) 628 { 629 mpProperties->SetMergedItemSetAndBroadcast(rSet, bClearAllItems); 630 notifyModified(); 631 } 632 } 633 634 // ----------------------------------------------------------------------------- 635 636 sal_Int32 Cell::getMinimumWidth() 637 { 638 return GetTextLeftDistance() + GetTextRightDistance() + 100; 639 } 640 641 // ----------------------------------------------------------------------------- 642 643 sal_Int32 Cell::getMinimumHeight() 644 { 645 if( !mpProperties ) 646 return 0; 647 648 SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); 649 sal_Int32 nMinimumHeight = 0; 650 651 Rectangle aTextRect; 652 TakeTextAnchorRect( aTextRect ); 653 Size aSize( aTextRect.GetSize() ); 654 aSize.Height()=0x0FFFFFFF; 655 656 SdrOutliner* pEditOutliner = rTableObj.GetCellTextEditOutliner( *this ); 657 if(pEditOutliner) 658 { 659 pEditOutliner->SetMaxAutoPaperSize(aSize); 660 nMinimumHeight = pEditOutliner->GetTextHeight()+1; 661 } 662 else /*if ( hasText() )*/ 663 { 664 Outliner& rOutliner=rTableObj.ImpGetDrawOutliner(); 665 rOutliner.SetPaperSize(aSize); 666 rOutliner.SetUpdateMode(sal_True); 667 ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT ); 668 669 if( GetOutlinerParaObject() ) 670 { 671 rOutliner.SetText(*GetOutlinerParaObject()); 672 } 673 nMinimumHeight=rOutliner.GetTextHeight()+1; 674 rOutliner.Clear(); 675 } 676 677 nMinimumHeight += GetTextUpperDistance() + GetTextLowerDistance(); 678 return nMinimumHeight; 679 } 680 681 // ----------------------------------------------------------------------------- 682 683 long Cell::GetTextLeftDistance() const 684 { 685 return ((SdrTextLeftDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue(); 686 } 687 688 // ----------------------------------------------------------------------------- 689 690 long Cell::GetTextRightDistance() const 691 { 692 return ((SdrTextRightDistItem&)(GetItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue(); 693 } 694 695 // ----------------------------------------------------------------------------- 696 697 long Cell::GetTextUpperDistance() const 698 { 699 return ((SdrTextUpperDistItem&)(GetItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue(); 700 } 701 702 // ----------------------------------------------------------------------------- 703 704 long Cell::GetTextLowerDistance() const 705 { 706 return ((SdrTextLowerDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue(); 707 } 708 709 // ----------------------------------------------------------------------------- 710 711 SdrTextVertAdjust Cell::GetTextVerticalAdjust() const 712 { 713 return ((SdrTextVertAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_VERTADJUST))).GetValue(); 714 } 715 716 // ----------------------------------------------------------------------------- 717 718 SdrTextHorzAdjust Cell::GetTextHorizontalAdjust() const 719 { 720 return ((SdrTextHorzAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_HORZADJUST))).GetValue(); 721 } 722 723 // ----------------------------------------------------------------------------- 724 725 void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject ) 726 { 727 SdrText::SetOutlinerParaObject( pTextObject ); 728 maSelection.nStartPara = 0xffff; 729 730 if( pTextObject == 0 ) 731 ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT ); 732 } 733 734 // ----------------------------------------------------------------------------- 735 736 void Cell::AddUndo() 737 { 738 SdrObject& rObj = GetObject(); 739 if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() ) 740 { 741 CellRef xCell( this ); 742 GetModel()->AddUndo( new CellUndo( &rObj, xCell ) ); 743 } 744 } 745 746 // ----------------------------------------------------------------------------- 747 748 sdr::properties::TextProperties* Cell::CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell ) 749 { 750 if( pProperties ) 751 return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties*>(pProperties), rNewObj, &rNewCell ); 752 else 753 return 0; 754 } 755 756 // ----------------------------------------------------------------------------- 757 758 sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell ) 759 { 760 return CloneProperties(mpProperties,rNewObj,rNewCell); 761 } 762 763 // ----------------------------------------------------------------------------- 764 // XInterface 765 // ----------------------------------------------------------------------------- 766 767 Any SAL_CALL Cell::queryInterface( const Type & rType ) throw(RuntimeException) 768 { 769 if( rType == XMergeableCell::static_type() ) 770 return Any( Reference< XMergeableCell >( this ) ); 771 772 if( rType == XCell::static_type() ) 773 return Any( Reference< XCell >( this ) ); 774 775 if( rType == XLayoutConstrains::static_type() ) 776 return Any( Reference< XLayoutConstrains >( this ) ); 777 778 if( rType == XEventListener::static_type() ) 779 return Any( Reference< XEventListener >( this ) ); 780 781 Any aRet( SvxUnoTextBase::queryAggregation( rType ) ); 782 if( aRet.hasValue() ) 783 return aRet; 784 785 return ::cppu::OWeakObject::queryInterface( rType ); 786 } 787 788 // ----------------------------------------------------------------------------- 789 790 void SAL_CALL Cell::acquire() throw () 791 { 792 ::cppu::OWeakObject::acquire(); 793 } 794 795 // ----------------------------------------------------------------------------- 796 797 void SAL_CALL Cell::release() throw () 798 { 799 ::cppu::OWeakObject::release(); 800 } 801 802 // ----------------------------------------------------------------------------- 803 // XTypeProvider 804 // ----------------------------------------------------------------------------- 805 806 Sequence< Type > SAL_CALL Cell::getTypes( ) throw (RuntimeException) 807 { 808 Sequence< Type > aTypes( SvxUnoTextBase::getTypes() ); 809 810 sal_Int32 nLen = aTypes.getLength(); 811 aTypes.realloc(nLen + 2); 812 aTypes[nLen++] = XMergeableCell::static_type(); 813 aTypes[nLen++] = XLayoutConstrains::static_type(); 814 815 return aTypes; 816 } 817 818 // ----------------------------------------------------------------------------- 819 820 Sequence< sal_Int8 > SAL_CALL Cell::getImplementationId( ) throw (RuntimeException) 821 { 822 static ::cppu::OImplementationId* pId = 0; 823 if (! pId) 824 { 825 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 826 if (! pId) 827 { 828 static ::cppu::OImplementationId aId; 829 pId = &aId; 830 } 831 } 832 return pId->getImplementationId(); 833 } 834 835 // ----------------------------------------------------------------------------- 836 // XServiceInfo 837 // ----------------------------------------------------------------------------- 838 839 OUString SAL_CALL Cell::getImplementationName( ) throw (RuntimeException) 840 { 841 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.table.Cell" ) ); 842 } 843 844 // ----------------------------------------------------------------------------- 845 846 sal_Bool SAL_CALL Cell::supportsService( const OUString& ServiceName ) throw (RuntimeException) 847 { 848 if( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.table.cell" ) ) == 0 ) 849 return sal_True; 850 851 if( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.cell" ) ) == 0 ) 852 return sal_True; 853 854 return SvxUnoTextBase::supportsService( ServiceName ); 855 } 856 857 // ----------------------------------------------------------------------------- 858 859 Sequence< OUString > SAL_CALL Cell::getSupportedServiceNames( ) throw (RuntimeException) 860 { 861 Sequence< OUString > aSeq( SvxUnoTextBase::getSupportedServiceNames() ); 862 sal_Int32 nIndex = aSeq.getLength(); 863 aSeq.realloc( nIndex + 2 ); 864 aSeq[nIndex++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.cell" ) ); 865 aSeq[nIndex++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.cell" ) ); 866 return aSeq; 867 } 868 869 // ----------------------------------------------------------------------------- 870 // XLayoutConstrains 871 // ----------------------------------------------------------------------------- 872 873 ::com::sun::star::awt::Size SAL_CALL Cell::getMinimumSize( ) throw (RuntimeException) 874 { 875 return ::com::sun::star::awt::Size( getMinimumWidth(), getMinimumHeight() ); 876 } 877 878 // ----------------------------------------------------------------------------- 879 880 ::com::sun::star::awt::Size SAL_CALL Cell::getPreferredSize( ) throw (RuntimeException) 881 { 882 return getMinimumSize(); 883 } 884 885 // ----------------------------------------------------------------------------- 886 887 ::com::sun::star::awt::Size SAL_CALL Cell::calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw (RuntimeException) 888 { 889 return aNewSize; 890 } 891 892 // ----------------------------------------------------------------------------- 893 // XMergeableCell 894 // ----------------------------------------------------------------------------- 895 896 sal_Int32 SAL_CALL Cell::getRowSpan() throw (RuntimeException) 897 { 898 return mnRowSpan; 899 } 900 901 // ----------------------------------------------------------------------------- 902 903 sal_Int32 SAL_CALL Cell::getColumnSpan() throw (RuntimeException) 904 { 905 return mnColSpan; 906 } 907 908 // ----------------------------------------------------------------------------- 909 910 sal_Bool SAL_CALL Cell::isMerged() throw (RuntimeException) 911 { 912 return mbMerged; 913 } 914 915 // ----------------------------------------------------------------------------- 916 // XCell 917 // ----------------------------------------------------------------------------- 918 919 OUString SAL_CALL Cell::getFormula( ) throw (RuntimeException) 920 { 921 return msFormula; 922 } 923 924 // ----------------------------------------------------------------------------- 925 926 void SAL_CALL Cell::setFormula( const OUString& aFormula ) throw (RuntimeException) 927 { 928 if( msFormula != aFormula ) 929 { 930 msFormula = aFormula; 931 } 932 } 933 934 // ----------------------------------------------------------------------------- 935 936 double SAL_CALL Cell::getValue( ) throw (RuntimeException) 937 { 938 return mfValue; 939 } 940 941 // ----------------------------------------------------------------------------- 942 943 void SAL_CALL Cell::setValue( double nValue ) throw (RuntimeException) 944 { 945 if( mfValue == nValue ) 946 { 947 mfValue = nValue; 948 mnCellContentType = CellContentType_VALUE; 949 } 950 } 951 952 // ----------------------------------------------------------------------------- 953 954 CellContentType SAL_CALL Cell::getType() throw (RuntimeException) 955 { 956 return mnCellContentType; 957 } 958 959 // ----------------------------------------------------------------------------- 960 961 sal_Int32 SAL_CALL Cell::getError( ) throw (RuntimeException) 962 { 963 return mnError; 964 } 965 966 // ----------------------------------------------------------------------------- 967 // XPropertySet 968 // ----------------------------------------------------------------------------- 969 970 Any Cell::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap ) 971 { 972 Any aAny( SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet ) ); 973 974 if( *pMap->pType != aAny.getValueType() ) 975 { 976 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here 977 if( ( *pMap->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) ) 978 { 979 sal_Int32 nValue = 0; 980 aAny >>= nValue; 981 aAny <<= (sal_Int16)nValue; 982 } 983 else 984 { 985 DBG_ERROR("GetAnyForItem() Returnvalue has wrong Type!" ); 986 } 987 } 988 989 return aAny; 990 } 991 992 Reference< XPropertySetInfo > SAL_CALL Cell::getPropertySetInfo() throw(RuntimeException) 993 { 994 return mpPropSet->getPropertySetInfo(); 995 } 996 997 // ----------------------------------------------------------------------------- 998 999 void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any& rValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) 1000 { 1001 OGuard aGuard( Application::GetSolarMutex() ); 1002 1003 if( (mpProperties == 0) || (GetModel() == 0) ) 1004 throw DisposedException(); 1005 1006 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName); 1007 if( pMap ) 1008 { 1009 if( (pMap->nFlags & PropertyAttribute::READONLY ) != 0 ) 1010 throw PropertyVetoException(); 1011 1012 switch( pMap->nWID ) 1013 { 1014 case OWN_ATTR_STYLE: 1015 { 1016 Reference< XStyle > xStyle; 1017 if( !( rValue >>= xStyle ) ) 1018 throw IllegalArgumentException(); 1019 1020 SfxUnoStyleSheet* pStyle = SfxUnoStyleSheet::getUnoStyleSheet(xStyle); 1021 SetStyleSheet( pStyle, sal_True ); 1022 return; 1023 } 1024 case OWN_ATTR_TABLEBORDER: 1025 { 1026 if(rValue.getValueType() != ::getCppuType((const TableBorder*)0) ) 1027 break; 1028 1029 const TableBorder* pBorder = (const TableBorder* )rValue.getValue(); 1030 if( pBorder == NULL ) 1031 break; 1032 1033 SvxBoxItem aBox( SDRATTR_TABLE_BORDER ); 1034 SvxBoxInfoItem aBoxInfo( SDRATTR_TABLE_BORDER_INNER ); 1035 SvxBorderLine aLine; 1036 1037 sal_Bool bSet = SvxBoxItem::LineToSvxLine(pBorder->TopLine, aLine, false); 1038 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_TOP); 1039 aBoxInfo.SetValid(VALID_TOP, pBorder->IsTopLineValid); 1040 1041 bSet = SvxBoxItem::LineToSvxLine(pBorder->BottomLine, aLine, false); 1042 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM); 1043 aBoxInfo.SetValid(VALID_BOTTOM, pBorder->IsBottomLineValid); 1044 1045 bSet = SvxBoxItem::LineToSvxLine(pBorder->LeftLine, aLine, false); 1046 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT); 1047 aBoxInfo.SetValid(VALID_LEFT, pBorder->IsLeftLineValid); 1048 1049 bSet = SvxBoxItem::LineToSvxLine(pBorder->RightLine, aLine, false); 1050 aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT); 1051 aBoxInfo.SetValid(VALID_RIGHT, pBorder->IsRightLineValid); 1052 1053 bSet = SvxBoxItem::LineToSvxLine(pBorder->HorizontalLine, aLine, false); 1054 aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_HORI); 1055 aBoxInfo.SetValid(VALID_HORI, pBorder->IsHorizontalLineValid); 1056 1057 bSet = SvxBoxItem::LineToSvxLine(pBorder->VerticalLine, aLine, false); 1058 aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_VERT); 1059 aBoxInfo.SetValid(VALID_VERT, pBorder->IsVerticalLineValid); 1060 1061 aBox.SetDistance(pBorder->Distance, false); 1062 aBoxInfo.SetValid(VALID_DISTANCE, pBorder->IsDistanceValid); 1063 1064 mpProperties->SetObjectItem(aBox); 1065 mpProperties->SetObjectItem(aBoxInfo); 1066 return; 1067 } 1068 case OWN_ATTR_FILLBMP_MODE: 1069 { 1070 BitmapMode eMode; 1071 if(!(rValue >>= eMode) ) 1072 { 1073 sal_Int32 nMode = 0; 1074 if(!(rValue >>= nMode)) 1075 throw IllegalArgumentException(); 1076 1077 eMode = (BitmapMode)nMode; 1078 } 1079 1080 mpProperties->SetObjectItem( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) ); 1081 mpProperties->SetObjectItem( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) ); 1082 return; 1083 } 1084 default: 1085 { 1086 SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID); 1087 aSet.Put(mpProperties->GetItem(pMap->nWID)); 1088 1089 bool bSpecial = false; 1090 1091 switch( pMap->nWID ) 1092 { 1093 case XATTR_FILLBITMAP: 1094 case XATTR_FILLGRADIENT: 1095 case XATTR_FILLHATCH: 1096 case XATTR_FILLFLOATTRANSPARENCE: 1097 case XATTR_LINEEND: 1098 case XATTR_LINESTART: 1099 case XATTR_LINEDASH: 1100 { 1101 if( pMap->nMemberId == MID_NAME ) 1102 { 1103 OUString aApiName; 1104 if( rValue >>= aApiName ) 1105 { 1106 if( SvxShape::SetFillAttribute( pMap->nWID, aApiName, aSet, GetModel() ) ) 1107 bSpecial = true; 1108 } 1109 } 1110 } 1111 break; 1112 } 1113 1114 if( !bSpecial ) 1115 { 1116 1117 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pMap, rValue, aSet )) 1118 { 1119 if( aSet.GetItemState( pMap->nWID ) != SFX_ITEM_SET ) 1120 { 1121 // Default aus ItemPool holen 1122 if(GetModel()->GetItemPool().IsWhich(pMap->nWID)) 1123 aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID)); 1124 } 1125 1126 if( aSet.GetItemState( pMap->nWID ) == SFX_ITEM_SET ) 1127 { 1128 SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rValue, aSet ); 1129 } 1130 } 1131 } 1132 1133 GetModel()->SetChanged(); 1134 mpProperties->SetMergedItemSetAndBroadcast( aSet ); 1135 return; 1136 } 1137 } 1138 } 1139 throw UnknownPropertyException(); 1140 } 1141 1142 // ----------------------------------------------------------------------------- 1143 1144 Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1145 { 1146 OGuard aGuard( Application::GetSolarMutex() ); 1147 1148 if( (mpProperties == 0) || (GetModel() == 0) ) 1149 throw DisposedException(); 1150 1151 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName); 1152 if( pMap ) 1153 { 1154 switch( pMap->nWID ) 1155 { 1156 /* 1157 case OWN_ATTR_HASLEVELS: 1158 { 1159 return Any( hasLevels() ); 1160 } 1161 */ 1162 case OWN_ATTR_STYLE: 1163 { 1164 return Any( Reference< XStyle >( dynamic_cast< SfxUnoStyleSheet* >( GetStyleSheet() ) ) ); 1165 } 1166 case OWN_ATTR_TABLEBORDER: 1167 { 1168 const SvxBoxInfoItem& rBoxInfoItem = static_cast<const SvxBoxInfoItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER_INNER)); 1169 const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER)); 1170 1171 TableBorder aTableBorder; 1172 aTableBorder.TopLine = SvxBoxItem::SvxLineToLine(rBox.GetTop(), false); 1173 aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(VALID_TOP); 1174 aTableBorder.BottomLine = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), false); 1175 aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(VALID_BOTTOM); 1176 aTableBorder.LeftLine = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), false); 1177 aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(VALID_LEFT); 1178 aTableBorder.RightLine = SvxBoxItem::SvxLineToLine(rBox.GetRight(), false); 1179 aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(VALID_RIGHT ); 1180 aTableBorder.HorizontalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), false); 1181 aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(VALID_HORI); 1182 aTableBorder.VerticalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), false); 1183 aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(VALID_VERT); 1184 aTableBorder.Distance = rBox.GetDistance(); 1185 aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(VALID_DISTANCE); 1186 1187 return Any( aTableBorder ); 1188 } 1189 case OWN_ATTR_FILLBMP_MODE: 1190 { 1191 const XFillBmpStretchItem& rStretchItem = static_cast<const XFillBmpStretchItem&>(mpProperties->GetItem(XATTR_FILLBMP_STRETCH)); 1192 const XFillBmpTileItem& rTileItem = static_cast<const XFillBmpTileItem&>(mpProperties->GetItem(XATTR_FILLBMP_TILE)); 1193 if( rTileItem.GetValue() ) 1194 { 1195 return Any( BitmapMode_REPEAT ); 1196 } 1197 else if( rStretchItem.GetValue() ) 1198 { 1199 return Any( BitmapMode_STRETCH ); 1200 } 1201 else 1202 { 1203 return Any( BitmapMode_NO_REPEAT ); 1204 } 1205 } 1206 default: 1207 { 1208 SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID); 1209 aSet.Put(mpProperties->GetItem(pMap->nWID)); 1210 1211 Any aAny; 1212 if(!SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny )) 1213 { 1214 if(!aSet.Count()) 1215 { 1216 // Default aus ItemPool holen 1217 if(GetModel()->GetItemPool().IsWhich(pMap->nWID)) 1218 aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID)); 1219 } 1220 1221 if( aSet.Count() ) 1222 aAny = GetAnyForItem( aSet, pMap ); 1223 } 1224 1225 return aAny; 1226 } 1227 } 1228 } 1229 throw UnknownPropertyException(); 1230 } 1231 1232 // ----------------------------------------------------------------------------- 1233 1234 void SAL_CALL Cell::addPropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1235 { 1236 } 1237 1238 // ----------------------------------------------------------------------------- 1239 1240 void SAL_CALL Cell::removePropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1241 { 1242 } 1243 1244 // ----------------------------------------------------------------------------- 1245 1246 void SAL_CALL Cell::addVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1247 { 1248 } 1249 1250 // ----------------------------------------------------------------------------- 1251 1252 void SAL_CALL Cell::removeVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1253 { 1254 } 1255 1256 // ----------------------------------------------------------------------------- 1257 // XMultiPropertySet 1258 // ----------------------------------------------------------------------------- 1259 1260 void SAL_CALL Cell::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) 1261 { 1262 OGuard aSolarGuard( Application::GetSolarMutex() ); 1263 1264 if( (mpProperties == 0) || (GetModel() == 0) ) 1265 throw DisposedException(); 1266 1267 const sal_Int32 nCount = aPropertyNames.getLength(); 1268 1269 const OUString* pNames = aPropertyNames.getConstArray(); 1270 const Any* pValues = aValues.getConstArray(); 1271 1272 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ ) 1273 { 1274 try 1275 { 1276 setPropertyValue( *pNames, *pValues ); 1277 } 1278 catch( UnknownPropertyException& ) 1279 { 1280 DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" ); 1281 } 1282 catch( Exception& ) 1283 { 1284 DBG_ERROR("svx::Cell::setPropertyValues(), Exception caught!" ); 1285 } 1286 } 1287 } 1288 1289 // ----------------------------------------------------------------------------- 1290 1291 Sequence< Any > SAL_CALL Cell::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException) 1292 { 1293 OGuard aSolarGuard( Application::GetSolarMutex() ); 1294 1295 if( (mpProperties == 0) || (GetModel() == 0) ) 1296 throw DisposedException(); 1297 1298 const sal_Int32 nCount = aPropertyNames.getLength(); 1299 const OUString* pNames = aPropertyNames.getConstArray(); 1300 1301 Sequence< Any > aRet( nCount ); 1302 Any* pValue = aRet.getArray(); 1303 1304 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ ) 1305 { 1306 try 1307 { 1308 *pValue = getPropertyValue( *pNames ); 1309 } 1310 catch( UnknownPropertyException& ) 1311 { 1312 DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" ); 1313 } 1314 catch( Exception& ) 1315 { 1316 DBG_ERROR( "svx::Cell::getPropertyValues(), Exception caught!" ); 1317 } 1318 } 1319 1320 return aRet; 1321 } 1322 1323 // ----------------------------------------------------------------------------- 1324 1325 void SAL_CALL Cell::addPropertiesChangeListener( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException) 1326 { 1327 } 1328 1329 // ----------------------------------------------------------------------------- 1330 1331 void SAL_CALL Cell::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException) 1332 { 1333 } 1334 1335 // ----------------------------------------------------------------------------- 1336 1337 void SAL_CALL Cell::firePropertiesChangeEvent( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException) 1338 { 1339 } 1340 1341 // ----------------------------------------------------------------------------- 1342 // XPropertyState 1343 // ----------------------------------------------------------------------------- 1344 1345 PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException) 1346 { 1347 OGuard aGuard( Application::GetSolarMutex() ); 1348 1349 if( (mpProperties == 0) || (GetModel() == 0) ) 1350 throw DisposedException(); 1351 1352 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName); 1353 1354 if( pMap ) 1355 { 1356 PropertyState eState; 1357 switch( pMap->nWID ) 1358 { 1359 case OWN_ATTR_FILLBMP_MODE: 1360 { 1361 const SfxItemSet& rSet = mpProperties->GetMergedItemSet(); 1362 1363 const bool bStretch = rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET; 1364 const bool bTile = rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET; 1365 if( bStretch || bTile ) 1366 { 1367 eState = PropertyState_DIRECT_VALUE; 1368 } 1369 else 1370 { 1371 eState = PropertyState_DEFAULT_VALUE; 1372 } 1373 } 1374 /* 1375 case OWN_ATTR_HASLEVELS: 1376 { 1377 return PropertyState_DIRECT_VALUE; 1378 } 1379 */ 1380 case OWN_ATTR_STYLE: 1381 { 1382 return PropertyState_DIRECT_VALUE; 1383 } 1384 case OWN_ATTR_TABLEBORDER: 1385 { 1386 const SfxItemSet& rSet = mpProperties->GetMergedItemSet(); 1387 if( (rSet.GetItemState( SDRATTR_TABLE_BORDER_INNER, sal_False ) == SFX_ITEM_DEFAULT) && (rSet.GetItemState( SDRATTR_TABLE_BORDER, sal_False ) == SFX_ITEM_DEFAULT) ) 1388 return PropertyState_DEFAULT_VALUE; 1389 1390 return PropertyState_DIRECT_VALUE; 1391 } 1392 default: 1393 { 1394 const SfxItemSet& rSet = mpProperties->GetMergedItemSet(); 1395 1396 switch( rSet.GetItemState( pMap->nWID, sal_False ) ) 1397 { 1398 case SFX_ITEM_READONLY: 1399 case SFX_ITEM_SET: 1400 eState = PropertyState_DIRECT_VALUE; 1401 break; 1402 case SFX_ITEM_DEFAULT: 1403 eState = PropertyState_DEFAULT_VALUE; 1404 break; 1405 // case SFX_ITEM_UNKNOWN: 1406 // case SFX_ITEM_DONTCARE: 1407 // case SFX_ITEM_DISABLED: 1408 default: 1409 eState = PropertyState_AMBIGUOUS_VALUE; 1410 break; 1411 } 1412 1413 // if a item is set, this doesn't mean we want it :) 1414 if( ( PropertyState_DIRECT_VALUE == eState ) ) 1415 { 1416 switch( pMap->nWID ) 1417 { 1418 // the following items are disabled by changing the 1419 // fill style or the line style. so there is no need 1420 // to export items without names which should be empty 1421 case XATTR_FILLBITMAP: 1422 case XATTR_FILLGRADIENT: 1423 case XATTR_FILLHATCH: 1424 case XATTR_LINEDASH: 1425 { 1426 NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID); 1427 if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) ) 1428 eState = PropertyState_DEFAULT_VALUE; 1429 } 1430 break; 1431 1432 // #i36115# 1433 // If e.g. the LineStart is on NONE and thus the string has length 0, it still 1434 // may be a hard attribute covering the set LineStart of the parent (Style). 1435 // #i37644# 1436 // same is for fill float transparency 1437 case XATTR_LINEEND: 1438 case XATTR_LINESTART: 1439 case XATTR_FILLFLOATTRANSPARENCE: 1440 { 1441 NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID); 1442 if( pItem == NULL ) 1443 eState = PropertyState_DEFAULT_VALUE; 1444 } 1445 break; 1446 } 1447 } 1448 } 1449 } 1450 return eState; 1451 } 1452 throw UnknownPropertyException(); 1453 } 1454 1455 // ----------------------------------------------------------------------------- 1456 1457 Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUString >& aPropertyName ) throw(UnknownPropertyException, RuntimeException) 1458 { 1459 OGuard aGuard( Application::GetSolarMutex() ); 1460 1461 if( (mpProperties == 0) || (GetModel() == 0) ) 1462 throw DisposedException(); 1463 1464 const sal_Int32 nCount = aPropertyName.getLength(); 1465 1466 Sequence< PropertyState > aRet( nCount ); 1467 1468 const OUString* pNames = aPropertyName.getConstArray(); 1469 PropertyState* pState = aRet.getArray(); 1470 1471 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pState++ ) 1472 { 1473 try 1474 { 1475 *pState = getPropertyState( *pNames ); 1476 } 1477 catch( Exception& ) 1478 { 1479 *pState = PropertyState_AMBIGUOUS_VALUE; 1480 } 1481 } 1482 1483 return aRet; 1484 } 1485 1486 // ----------------------------------------------------------------------------- 1487 1488 void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException) 1489 { 1490 OGuard aGuard( Application::GetSolarMutex() ); 1491 1492 if( (mpProperties == 0) || (GetModel() == 0) ) 1493 throw DisposedException(); 1494 1495 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName); 1496 if( pMap ) 1497 { 1498 switch( pMap->nWID ) 1499 { 1500 case OWN_ATTR_FILLBMP_MODE: 1501 { 1502 mpProperties->ClearObjectItem( XATTR_FILLBMP_STRETCH ); 1503 mpProperties->ClearObjectItem( XATTR_FILLBMP_TILE ); 1504 break; 1505 } 1506 // case OWN_ATTR_HASLEVELS: 1507 case OWN_ATTR_STYLE: 1508 break; 1509 1510 case OWN_ATTR_TABLEBORDER: 1511 { 1512 mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER_INNER ); 1513 mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER ); 1514 break; 1515 } 1516 1517 default: 1518 { 1519 mpProperties->ClearObjectItem( pMap->nWID ); 1520 } 1521 } 1522 1523 GetModel()->SetChanged(); 1524 return; 1525 } 1526 throw UnknownPropertyException(); 1527 } 1528 1529 // ----------------------------------------------------------------------------- 1530 1531 Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1532 { 1533 OGuard aGuard( Application::GetSolarMutex() ); 1534 1535 if( (mpProperties == 0) || (GetModel() == 0) ) 1536 throw DisposedException(); 1537 1538 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName); 1539 if( pMap ) 1540 { 1541 switch( pMap->nWID ) 1542 { 1543 case OWN_ATTR_FILLBMP_MODE: 1544 return Any( BitmapMode_NO_REPEAT ); 1545 1546 /* 1547 case OWN_ATTR_HASLEVELS: 1548 return Any( sal_False ); 1549 */ 1550 case OWN_ATTR_STYLE: 1551 { 1552 Reference< XStyle > xStyle; 1553 return Any( xStyle ); 1554 } 1555 1556 case OWN_ATTR_TABLEBORDER: 1557 { 1558 TableBorder aBorder; 1559 return Any( aBorder ); 1560 } 1561 1562 default: 1563 { 1564 if( GetModel()->GetItemPool().IsWhich(pMap->nWID) ) 1565 { 1566 SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID); 1567 aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID)); 1568 return GetAnyForItem( aSet, pMap ); 1569 } 1570 } 1571 } 1572 } 1573 throw UnknownPropertyException(); 1574 } 1575 1576 // ----------------------------------------------------------------------------- 1577 // XMultiPropertyStates 1578 // ----------------------------------------------------------------------------- 1579 1580 void SAL_CALL Cell::setAllPropertiesToDefault( ) throw (RuntimeException) 1581 { 1582 if( mpProperties ) 1583 delete mpProperties; 1584 mpProperties = new sdr::properties::CellProperties( static_cast< SdrTableObj& >( GetObject() ), this ); 1585 1586 SdrOutliner& rOutliner = GetObject().ImpGetDrawOutliner(); 1587 1588 OutlinerParaObject* pParaObj = GetOutlinerParaObject(); 1589 if( pParaObj ) 1590 { 1591 rOutliner.SetText(*pParaObj); 1592 sal_uInt32 nParaCount(rOutliner.GetParagraphCount()); 1593 1594 if(nParaCount) 1595 { 1596 ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL); 1597 rOutliner.RemoveAttribs(aSelection, sal_True, 0); 1598 1599 OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount); 1600 rOutliner.Clear(); 1601 1602 SetOutlinerParaObject(pTemp); 1603 } 1604 } 1605 } 1606 1607 // ----------------------------------------------------------------------------- 1608 1609 void SAL_CALL Cell::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, RuntimeException) 1610 { 1611 sal_Int32 nCount = aPropertyNames.getLength(); 1612 const OUString* pName = aPropertyNames.getConstArray(); 1613 1614 while(nCount--) 1615 setPropertyToDefault( *pName++ ); 1616 } 1617 1618 // ----------------------------------------------------------------------------- 1619 1620 Sequence< Any > SAL_CALL Cell::getPropertyDefaults( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) 1621 { 1622 sal_Int32 nCount = aPropertyNames.getLength(); 1623 Sequence< Any > aDefaults( nCount ); 1624 Any* pDefaults = aDefaults.getArray(); 1625 const OUString* pName = aPropertyNames.getConstArray(); 1626 1627 while(nCount--) 1628 *pDefaults++ = getPropertyDefault( *pName++ ); 1629 1630 return aDefaults; 1631 } 1632 1633 // ----------------------------------------------------------------------------- 1634 // XFastPropertySet 1635 // ----------------------------------------------------------------------------- 1636 1637 void SAL_CALL Cell::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) 1638 { 1639 (void)aValue; 1640 (void)nHandle; 1641 throw UnknownPropertyException(); 1642 } 1643 1644 // ----------------------------------------------------------------------------- 1645 // TODO: Refactor this method! 1646 Any SAL_CALL Cell::getFastPropertyValue( sal_Int32 nHandle ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) 1647 { 1648 (void)nHandle; 1649 throw UnknownPropertyException(); 1650 } 1651 1652 // ----------------------------------------------------------------------------- 1653 // XText 1654 // ----------------------------------------------------------------------------- 1655 1656 void SAL_CALL Cell::insertTextContent( const Reference< XTextRange >& xRange, const Reference< XTextContent >& xContent, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException) 1657 { 1658 SvxUnoTextBase::insertTextContent( xRange, xContent, bAbsorb ); 1659 notifyModified(); 1660 } 1661 1662 // ----------------------------------------------------------------------------- 1663 1664 void SAL_CALL Cell::removeTextContent( const Reference< XTextContent >& xContent ) throw (NoSuchElementException, RuntimeException) 1665 { 1666 SvxUnoTextBase::removeTextContent( xContent ); 1667 notifyModified(); 1668 } 1669 1670 // ----------------------------------------------------------------------------- 1671 // XSimpleText 1672 // ----------------------------------------------------------------------------- 1673 1674 Reference< XTextCursor > SAL_CALL Cell::createTextCursor( ) throw (RuntimeException) 1675 { 1676 return SvxUnoTextBase::createTextCursor(); 1677 } 1678 1679 // ----------------------------------------------------------------------------- 1680 1681 Reference< XTextCursor > SAL_CALL Cell::createTextCursorByRange( const Reference< XTextRange >& aTextPosition ) throw (RuntimeException) 1682 { 1683 return SvxUnoTextBase::createTextCursorByRange( aTextPosition ); 1684 } 1685 1686 // ----------------------------------------------------------------------------- 1687 1688 void SAL_CALL Cell::insertString( const Reference< XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) throw (RuntimeException) 1689 { 1690 SvxUnoTextBase::insertString( xRange, aString, bAbsorb ); 1691 notifyModified(); 1692 } 1693 1694 // ----------------------------------------------------------------------------- 1695 1696 void SAL_CALL Cell::insertControlCharacter( const Reference< XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException) 1697 { 1698 SvxUnoTextBase::insertControlCharacter( xRange, nControlCharacter, bAbsorb ); 1699 notifyModified(); 1700 } 1701 1702 // ----------------------------------------------------------------------------- 1703 // XTextRange 1704 // ----------------------------------------------------------------------------- 1705 1706 Reference< XText > SAL_CALL Cell::getText( ) throw (RuntimeException) 1707 { 1708 return SvxUnoTextBase::getText(); 1709 } 1710 1711 // ----------------------------------------------------------------------------- 1712 1713 Reference< XTextRange > SAL_CALL Cell::getStart( ) throw (RuntimeException) 1714 { 1715 return SvxUnoTextBase::getStart(); 1716 } 1717 1718 // ----------------------------------------------------------------------------- 1719 1720 Reference< XTextRange > SAL_CALL Cell::getEnd( ) throw (RuntimeException) 1721 { 1722 return SvxUnoTextBase::getEnd(); 1723 } 1724 1725 // ----------------------------------------------------------------------------- 1726 1727 OUString SAL_CALL Cell::getString( ) throw (RuntimeException) 1728 { 1729 maSelection.nStartPara = 0xffff; 1730 return SvxUnoTextBase::getString(); 1731 } 1732 1733 // ----------------------------------------------------------------------------- 1734 1735 void SAL_CALL Cell::setString( const OUString& aString ) throw (RuntimeException) 1736 { 1737 SvxUnoTextBase::setString( aString ); 1738 notifyModified(); 1739 } 1740 1741 // XEventListener 1742 void SAL_CALL Cell::disposing( const EventObject& /*Source*/ ) throw (RuntimeException) 1743 { 1744 mxTable.clear(); 1745 dispose(); 1746 } 1747 1748 static OUString getCellName( sal_Int32 nCol, sal_Int32 nRow ) 1749 { 1750 rtl::OUStringBuffer aBuf; 1751 1752 if (nCol < 26*26) 1753 { 1754 if (nCol < 26) 1755 aBuf.append( static_cast<sal_Unicode>( 'A' + 1756 static_cast<sal_uInt16>(nCol))); 1757 else 1758 { 1759 aBuf.append( static_cast<sal_Unicode>( 'A' + 1760 (static_cast<sal_uInt16>(nCol) / 26) - 1)); 1761 aBuf.append( static_cast<sal_Unicode>( 'A' + 1762 (static_cast<sal_uInt16>(nCol) % 26))); 1763 } 1764 } 1765 else 1766 { 1767 String aStr; 1768 while (nCol >= 26) 1769 { 1770 sal_Int32 nC = nCol % 26; 1771 aStr += static_cast<sal_Unicode>( 'A' + 1772 static_cast<sal_uInt16>(nC)); 1773 nCol = nCol - nC; 1774 nCol = nCol / 26 - 1; 1775 } 1776 aStr += static_cast<sal_Unicode>( 'A' + 1777 static_cast<sal_uInt16>(nCol)); 1778 aStr.Reverse(); 1779 aBuf.append( aStr); 1780 } 1781 aBuf.append( OUString::valueOf(nRow+1) ); 1782 return aBuf.makeStringAndClear(); 1783 } 1784 1785 OUString Cell::getName() 1786 { 1787 // todo: optimize! 1788 OUString sName; 1789 if( mxTable.is() ) try 1790 { 1791 Reference< XCell > xThis( static_cast< XCell* >( this ) ); 1792 1793 sal_Int32 nRowCount = mxTable->getRowCount(); 1794 sal_Int32 nColCount = mxTable->getColumnCount(); 1795 for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ ) 1796 { 1797 for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ ) 1798 { 1799 Reference< XCell > xCell( mxTable->getCellByPosition( nCol, nRow ) ); 1800 if( xCell == xThis ) 1801 { 1802 return getCellName( nCol, nRow ); 1803 } 1804 } 1805 } 1806 } 1807 catch( Exception& ) 1808 { 1809 } 1810 1811 return sName; 1812 } 1813 1814 } } 1815 1816