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 #include <tools/debug.hxx> 25 #include <svtools/libcall.hxx> 26 #include <vcl/msgbox.hxx> 27 #include <vcl/window.hxx> 28 #include <vcl/button.hxx> 29 #include <vcl/field.hxx> 30 #include <vcl/fixed.hxx> 31 #include <vcl/help.hxx> 32 #include <usr/conver.hxx> 33 #include <usr/uno.hxx> 34 #include <usr/refl.hxx> 35 #include <stardiv/one/frame/xcollect.hxx> 36 #include <stardiv/one/text/offfield.hxx> 37 #include <stardiv/one/offmisc.hxx> 38 #include <stardiv/one/sheet/offtable.hxx> 39 #include <stardiv/one/text/offtext.hxx> 40 #include <stardiv/one/offstyle.hxx> 41 #include <stardiv/one/offview.hxx> 42 #include <stardiv/uno/repos/serinfo.hxx> 43 #include <stardiv/one/sheet/sctypes.hxx> 44 #include <stardiv/one/sheet/scmodel.hxx> 45 #include <stardiv/one/sheet/sccells.hxx> 46 #include <stardiv/one/sheet/sctables.hxx> 47 #include <stardiv/one/sheet/sctable.hxx> 48 #include <stardiv/one/sheet/sccell.hxx> 49 #include <stardiv/one/sheet/scpostit.hxx> 50 #include <stardiv/one/sheet/scview.hxx> 51 #include <stardiv/one/sheet/scdata.hxx> 52 #include <stardiv/one/sheet/scattr.hxx> 53 54 //! das muss als Konstante in irgendeine idl-Datei!!!! 55 #define TEXTCONTROLCHAR_PARAGRAPH_BREAK 0 56 57 58 class MyFixedText : public FixedText 59 { 60 protected: 61 void RequestHelp( const HelpEvent& rHEvt ); 62 public: 63 MyFixedText(Window* pParent) : FixedText(pParent) {} 64 }; 65 66 class MyWindow : public Window 67 { 68 private: 69 NumericField aCountField; 70 PushButton aCountButton; 71 MyFixedText aTimeText; 72 NumericField aColField; 73 NumericField aRowField; 74 NumericField aPosField; 75 NumericField aLenField; 76 Edit aTextEdit; 77 PushButton aTextButton; 78 PushButton aBlaButton; 79 PushButton aTabButton; 80 PushButton aViewButton; 81 82 public: 83 MyWindow( Window *pParent ); 84 85 DECL_LINK(CountHdl, PushButton*); 86 DECL_LINK(TextHdl, PushButton*); 87 DECL_LINK(BlaHdl, PushButton*); 88 DECL_LINK(TabHdl, PushButton*); 89 DECL_LINK(ViewHdl, PushButton*); 90 }; 91 92 //----------------------------------------------------------------------- 93 94 class ScTestListener : public XSelectionChangeListener, public UsrObject 95 { 96 private: 97 FixedText* pFixedText; 98 99 public: 100 ScTestListener(FixedText* pF); 101 virtual ~ScTestListener(); 102 103 SMART_UNO_DECLARATION( ScTestListener, UsrObject ); 104 105 virtual XInterface * queryInterface( UsrUik ); 106 virtual XIdlClassRef getIdlClass(void); 107 108 virtual void disposing(const EventObject& Source); 109 110 // XSelectionChangeListener 111 virtual void selectionChanged(const EventObject& aEvent); 112 }; 113 114 //----------------------------------------------------------------------- 115 116 static long nBla = 0; 117 118 static XCellRef xGlobalCell; 119 120 //----------------------------------------------------------------------- 121 122 ScTestListener::ScTestListener(FixedText* pF) : 123 pFixedText( pF ) 124 { 125 } 126 127 ScTestListener::~ScTestListener() 128 { 129 } 130 131 XInterface* ScTestListener::queryInterface( UsrUik aUIK ) 132 { 133 if ( aUIK == XSelectionChangeListener::getSmartUik() ) 134 return (XSelectionChangeListener*) this; 135 136 return UsrObject::queryInterface( aUIK ); 137 } 138 139 XIdlClassRef ScTestListener::getIdlClass(void) 140 { 141 static XIdlClassRef xClass = createStandardClass( L"ScTestListener", 142 UsrObject::getUsrObjectIdlClass(), 143 1, XSelectionChangeListener_getReflection() ); 144 return xClass; 145 } 146 147 void ScTestListener::disposing(const EventObject& Source) 148 { 149 } 150 151 // XSelectionChangeListener 152 153 void ScTestListener::selectionChanged(const EventObject& aEvent) 154 { 155 static USHORT nBla = 0; 156 pFixedText->SetText(++nBla); 157 158 XInterfaceRef xInt = aEvent.Source; 159 if (!xInt) return; 160 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 161 if (!xView) return; 162 XInterfaceRef xSelInt = xView->getSelection(); 163 if (!xSelInt) return; 164 XCellCollectionRef xCells = (XCellCollection*) 165 xSelInt->queryInterface(XCellCollection::getSmartUik()); 166 if (!xCells) return; 167 168 String aStr = OUStringToString( xCells->getAddress(), CHARSET_SYSTEM ); 169 pFixedText->SetText(aStr); 170 } 171 172 173 //----------------------------------------------------------------------- 174 175 extern "C" Window* __LOADONCALLAPI CreateWindow( Window *pParent, const String& rParam ) 176 { 177 MyWindow *pWin = new MyWindow( pParent ); 178 return pWin; 179 } 180 181 void MyFixedText::RequestHelp( const HelpEvent& rHEvt ) 182 { 183 String aTxtStr=GetText(); 184 Size aTxtSize=GetTextSize(aTxtStr); 185 Point aShowPoint= OutputToScreenPixel(Point(0,0)); 186 if ( ( rHEvt.GetMode() & HELPMODE_QUICK ) == HELPMODE_QUICK && 187 aTxtSize.Width()>GetSizePixel().Width()) 188 Help::ShowQuickHelp( Rectangle(aShowPoint,aTxtSize), aTxtStr, QUICKHELP_TOP|QUICKHELP_LEFT ); 189 else 190 FixedText::RequestHelp( rHEvt ); 191 } 192 193 MyWindow::MyWindow( Window *pParent ) : 194 Window( pParent ), 195 aCountField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), 196 aCountButton( this ), 197 aTimeText( this ), 198 aColField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), 199 aRowField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), 200 aPosField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), 201 aLenField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), 202 aTextEdit( this, WinBits(WB_BORDER) ), 203 aTextButton( this ), 204 aBlaButton( this ), 205 aTabButton( this ), 206 aViewButton( this ) 207 { 208 aCountField.SetPosSizePixel( Point(10,10), Size(40,20) ); 209 aCountField.SetValue(1); 210 211 aCountButton.SetPosSizePixel( Point(10,40), Size(100,30) ); 212 aCountButton.SetText("hochzaehlen"); 213 214 aTimeText.SetPosSizePixel( Point(10,80), Size(100,20) ); 215 216 aColField.SetPosSizePixel( Point(10,120), Size(40,20) ); 217 aRowField.SetPosSizePixel( Point(60,120), Size(40,20) ); 218 aPosField.SetPosSizePixel( Point(10,150), Size(40,20) ); 219 aLenField.SetPosSizePixel( Point(60,150), Size(40,20) ); 220 aTextEdit.SetPosSizePixel( Point(10,180), Size(100,20) ); 221 222 aTextButton.SetPosSizePixel( Point(10,210), Size(100,30) ); 223 aTextButton.SetText("col/row/pos/len"); 224 225 aBlaButton.SetPosSizePixel( Point(10,260), Size(100,30) ); 226 aBlaButton.SetText("Bla"); 227 228 aTabButton.SetPosSizePixel( Point(10,310), Size(100,30) ); 229 aTabButton.SetText("Tabellen"); 230 231 aViewButton.SetPosSizePixel( Point(10,360), Size(100,30) ); 232 aViewButton.SetText("Pfui"); 233 234 aCountButton.SetClickHdl(LINK(this, MyWindow, CountHdl)); 235 aTextButton.SetClickHdl(LINK(this, MyWindow, TextHdl)); 236 aBlaButton.SetClickHdl(LINK(this, MyWindow, BlaHdl)); 237 aTabButton.SetClickHdl(LINK(this, MyWindow, TabHdl)); 238 aViewButton.SetClickHdl(LINK(this, MyWindow, ViewHdl)); 239 240 aCountField.Show(); 241 aCountButton.Show(); 242 aTimeText.Show(); 243 aColField.Show(); 244 aRowField.Show(); 245 aPosField.Show(); 246 aLenField.Show(); 247 aTextEdit.Show(); 248 aTextButton.Show(); 249 aBlaButton.Show(); 250 aTabButton.Show(); 251 aViewButton.Show(); 252 } 253 254 //----------------------------------------------------------------------- 255 256 XSpreadsheetDocumentRef lcl_GetDocument() 257 { 258 XServiceManagerRef xProv = getGlobalServiceManager(); 259 DBG_ASSERT( xProv.is(), "Kein ServiceManager!" ); 260 261 XServiceRegistryRef xReg = (XServiceRegistry*)xProv->queryInterface(XServiceRegistry::getSmartUik()); 262 if ( !xReg ) 263 return NULL; 264 265 Sequence<Uik> aIfaces( 1 ); 266 aIfaces.getArray()[0] = XModelCollection::getSmartUik(); 267 XServiceProviderRef xSSI = xProv->getServiceProvider( L"stardiv.desktop.ModelCollection", 268 aIfaces, Sequence<Uik>() ); 269 270 XModelCollectionRef aCollRef = (XModelCollection*) 271 xSSI->newInstance()->queryInterface( XModelCollection::getSmartUik() ); 272 USHORT nCount = aCollRef->getCount(); 273 274 XSpreadsheetDocumentRef xModel; // Calc-Model 275 for (USHORT nMod=0; nMod<nCount && !xModel; nMod++) // Calc-Doc suchen 276 { 277 XModelRef aRef = aCollRef->getItemByIndex( nMod ); 278 if ( aRef ) 279 { 280 aRef->acquire(); 281 xModel = (XSpreadsheetDocument*) aRef->queryInterface( XSpreadsheetDocument::getSmartUik() ); 282 aRef->release(); 283 } 284 } 285 return xModel; 286 } 287 288 XInterfaceRef lcl_GetView() 289 { 290 XInterfaceRef xView; 291 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 292 if (xDoc) 293 xView = xDoc->getDDELinks(); //! temporaer zum Testen !!!!!!!!! 294 295 return xView; 296 } 297 298 //----------------------------------------------------------------------- 299 300 void lcl_OutputNames( const XInterfaceRef& xSource, // XNameAccess 301 const XSpreadsheetDocumentRef& xDoc, 302 USHORT nCol, USHORT nRow, USHORT nTab ) 303 { 304 CellAddress aAdr; 305 aAdr.Sheet = nTab; 306 aAdr.Column = nCol; 307 aAdr.Row = nRow; 308 309 XNameAccessRef xNames = (XNameAccess*)xSource->queryInterface(XNameAccess::getSmartUik()); 310 if (!xNames) return; 311 Sequence<UString> aSeq = xNames->getElementNames(); 312 313 USHORT nLen = (USHORT)aSeq.getLen(); 314 315 XCellRef xCell = xDoc->getCell(aAdr); 316 if (!xCell) return; 317 xCell->setValue( nLen ); 318 ++aAdr.Row; 319 320 UString* pAry = aSeq.getArray(); 321 for (USHORT i=0; i<nLen; i++) 322 { 323 xCell = xDoc->getCell(aAdr); 324 if (!xCell) return; 325 XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); 326 if (!xText) return; 327 xText->setText( pAry[i] ); 328 ++aAdr.Row; 329 } 330 } 331 332 //----------------------------------------------------------------------- 333 334 void lcl_SetText( const XTextRef& xText ) 335 { 336 if (!xText.is()) return; 337 XTextCursorRef xCursor = xText->createTextCursor(); 338 if (!xCursor.is()) return; 339 XTextPositionRef xPos = (XTextPosition*)xCursor->queryInterface(XTextPosition::getSmartUik()); 340 XPropertySetRef xProp = (XPropertySet*)xCursor->queryInterface(XPropertySet::getSmartUik()); 341 XControlCharacterInsertableRef xControl = (XControlCharacterInsertable*) 342 xCursor->queryInterface(XControlCharacterInsertable::getSmartUik()); 343 XParagraphCursorRef xPara = (XParagraphCursor*) 344 xCursor->queryInterface(XParagraphCursor::getSmartUik()); 345 346 if (!xPos.is() || !xControl.is() || !xPara.is()) return; // PropertySet kann fehlen 347 348 xText->setText(L"bla fasel"); 349 xCursor->gotoEnd(FALSE); 350 xControl->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK ); 351 xPos->collapseToEnd(); 352 xPos->setText(L"s\xFClz"); // zweiter Absatz 353 354 xCursor->gotoStart(FALSE); 355 xPara->gotoEndOfParagraph(FALSE); 356 xCursor->goLeft(5, TRUE); // letzte 5 Zeichen im 1. Absatz 357 if (xProp.is()) 358 xProp->setPropertyValue(L"Bold", UsrAny((BOOL)TRUE)); 359 } 360 361 //----------------------------------------------------------------------- 362 363 void lcl_DoCount() 364 { 365 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 366 if (xDoc) 367 { 368 XActionLockableRef xLock = (XActionLockable*) 369 xDoc->queryInterface(XActionLockable::getSmartUik()); 370 XCalculateRef xCalc = (XCalculate*) 371 xDoc->queryInterface(XCalculate::getSmartUik()); 372 if (xLock) 373 xLock->addActionLock(); // nicht zwischendurch painten 374 if (xCalc) 375 xCalc->setAutomaticCalculation(FALSE); 376 377 CellAddress aPos; 378 aPos.Sheet = 0; 379 380 for (USHORT nRow = 0; nRow < 20; nRow++) 381 { 382 aPos.Row = nRow; 383 for (USHORT nCol = 0; nCol < 10; nCol++) 384 { 385 aPos.Column = nCol; 386 XCellRef xCell = xDoc->getCell(aPos); 387 if ( xCell ) 388 { 389 // Wert der Zelle um 1 hochzaehlen 390 391 double fVal = xCell->getValue(); 392 fVal += 1.0; 393 xCell->setValue( fVal ); 394 } 395 } 396 } 397 398 if (xCalc) 399 xCalc->setAutomaticCalculation(TRUE); 400 if (xLock) 401 xLock->removeActionLock(); 402 } 403 } 404 405 406 void lcl_GlobalCell() 407 { 408 if ( xGlobalCell ) 409 { 410 String aStr = OUStringToString( xGlobalCell->getFormula(), CHARSET_SYSTEM ); 411 aStr+='0'; 412 xGlobalCell->setFormula( StringToOUString( aStr, CHARSET_SYSTEM ) ); 413 } 414 } 415 416 417 void lcl_Annotations( FixedText& aTimeText ) 418 { 419 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 420 if (xDoc) 421 { 422 CellAddress aPos; 423 aPos.Sheet = 0; 424 aPos.Column = 1; 425 aPos.Row = 2; 426 XCellRef xCell = xDoc->getCell(aPos); 427 if ( xCell ) 428 { 429 XSheetAnnotationAnchorRef xAnchor = 430 (XSheetAnnotationAnchor*)xCell->queryInterface(XSheetAnnotationAnchor::getSmartUik()); 431 if ( xAnchor ) 432 { 433 XSheetAnnotationRef xAnnotation = xAnchor->getAnnotation(); 434 if ( xAnnotation ) 435 { 436 String aBlubb = OUStringToString( xAnnotation->getAuthor(), CHARSET_SYSTEM )+ 437 String(" - ")+ 438 OUStringToString( xAnnotation->getDate(), CHARSET_SYSTEM ); 439 aTimeText.SetText(aBlubb); 440 441 XTextRef xAnnotationText = 442 (XText*)xAnnotation->queryInterface(XText::getSmartUik()); 443 if ( xAnnotationText ) 444 { 445 XTextCursorRef xCursor = xAnnotationText->createTextCursor(); 446 if (xCursor) 447 { 448 XTextPositionRef xPos = (XTextPosition*) 449 xCursor->queryInterface(XTextPosition::getSmartUik()); 450 XControlCharacterInsertableRef xControl = (XControlCharacterInsertable*) 451 xCursor->queryInterface(XControlCharacterInsertable::getSmartUik()); 452 453 if (xPos && xControl) 454 { 455 ULONG nStart = Time::GetSystemTicks(); 456 457 xAnnotationText->setText(L"bla"); 458 xCursor->gotoEnd(FALSE); 459 xCursor->goLeft(1,TRUE); 460 xPos->setText(L"ubb"); 461 for (USHORT i=0; i<10; i++) 462 { 463 xPos->collapseToEnd(); 464 xControl->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK ); 465 xPos->collapseToEnd(); 466 xPos->setText(L"dumdi"); 467 } 468 469 ULONG nEnd = Time::GetSystemTicks(); 470 aTimeText.SetText(String(nEnd-nStart)+String(" ms")); 471 } 472 } 473 } 474 } 475 } 476 } 477 } 478 } 479 480 481 void lcl_Cursor( FixedText& aTimeText ) 482 { 483 aTimeText.SetText( "..." ); 484 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 485 if (xDoc) 486 { 487 XActionLockableRef xLock = (XActionLockable*) 488 xDoc->queryInterface(XActionLockable::getSmartUik()); 489 if (xLock) 490 xLock->addActionLock(); 491 492 CellAddress aPos; 493 aPos.Sheet = 0; 494 aPos.Column = 1; 495 aPos.Row = 2; 496 XCellRef xCell = xDoc->getCell(aPos); 497 if ( xCell ) 498 { 499 XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); 500 XCellCollectionRef xColl = (XCellCollection*)xCell->queryInterface(XCellCollection::getSmartUik()); 501 if ( xText && xColl ) 502 { 503 xText->setText(L"bla"); 504 XLineCursorRef xCursor = xColl->createCursor(); 505 if ( xCursor ) 506 { 507 XCellCursorRef xCC = (XCellCursor*)xCursor->queryInterface(XCellCursor::getSmartUik()); 508 XCellRangesCursorRef xRC = (XCellRangesCursor*) 509 xCursor->queryInterface(XCellRangesCursor::getSmartUik()); 510 511 if ( xCC && xRC ) 512 { 513 xCursor->goDown( 1, FALSE ); 514 515 xColl = xCC->getRanges(); 516 if ( xColl ) 517 { 518 // XText ist drin, wenn's ne einzelne Zelle ist 519 xText = (XText*)xColl->queryInterface(XText::getSmartUik()); 520 if ( xText ) 521 { 522 xText->setText(L"fasel"); 523 } 524 } 525 526 CellRangeAddress aSecond; 527 aSecond.Sheet = 0; 528 aSecond.StartColumn = 3; 529 aSecond.StartRow = 4; 530 aSecond.EndColumn = 3; 531 aSecond.EndRow = 4; 532 xRC->gotoUnion(aSecond); 533 534 xColl = xCC->getRanges(); 535 if ( xColl ) 536 { 537 XPropertySetRef xProp = (XPropertySet*) 538 xColl->queryInterface(XPropertySet::getSmartUik()); 539 if ( xProp ) 540 { 541 UsrAny aAny; 542 543 aAny = xProp->getPropertyValue(L"ShadowFormat"); 544 if ( aAny.getReflection()->getName() == 545 ShadowFormat_getReflection()->getName() ) 546 { 547 //ShadowFormat* pOld = (ShadowFormat*)aAny.get(); 548 ShadowFormat aNew; 549 aNew.Location = SHADOWLOCATION_BOTTOMRIGHT; 550 aNew.ShadowWidth = 100; 551 aNew.IsTransparent = FALSE; 552 aNew.Color = 0xff0000L; 553 aAny.set( &aNew, aAny.getReflection() ); 554 xProp->setPropertyValue(L"ShadowFormat", aAny); 555 } 556 557 aAny = xProp->getPropertyValue(L"RotationValue"); 558 aAny.setINT32(4500); 559 xProp->setPropertyValue(L"RotationValue", aAny); 560 561 aAny = xProp->getPropertyValue(L"FontHeight"); 562 aAny.setUINT32(280); 563 xProp->setPropertyValue(L"FontHeight", aAny); 564 565 aAny = xProp->getPropertyValue(L"TransparentBackground"); 566 aAny.setBOOL(FALSE); 567 xProp->setPropertyValue(L"TransparentBackground", aAny); 568 569 aAny = xProp->getPropertyValue(L"BackgroundColor"); 570 aAny.setUINT32(0xffff00); 571 xProp->setPropertyValue(L"BackgroundColor", aAny); 572 573 aAny = xProp->getPropertyValue(L"CellProtection"); 574 if ( aAny.getReflection()->getName() == 575 CellProtection_getReflection()->getName() ) 576 { 577 //CellProtection* pOld = (CellProtection*)aAny.get(); 578 CellProtection aNew; 579 aNew.Locked = FALSE; 580 aNew.FormulaHidden = FALSE; 581 aNew.Hidden = FALSE; 582 aNew.PrintHidden = FALSE; 583 aAny.set( &aNew, aAny.getReflection() ); 584 xProp->setPropertyValue(L"CellProtection", aAny); 585 } 586 } 587 588 // XIndexAccess gibts nur wenn's mehrere sind (??!??!) 589 XIndexAccessRef xIndex = (XIndexAccess*) 590 xColl->queryInterface(XIndexAccess::getSmartUik()); 591 if ( xIndex ) 592 { 593 USHORT nCount = (USHORT)xIndex->getCount(); 594 aTimeText.SetText( String(nCount) ); 595 } 596 } 597 } 598 } 599 } 600 } 601 602 if (xLock) 603 xLock->removeActionLock(); 604 } 605 } 606 607 608 void lcl_Cells( FixedText& aTimeText ) 609 { 610 aTimeText.SetText( "..." ); 611 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 612 if (xDoc) 613 { 614 long nCount = 0; 615 ULONG nStart = Time::GetSystemTicks(); 616 617 XActionLockableRef xLock = (XActionLockable*) 618 xDoc->queryInterface(XActionLockable::getSmartUik()); 619 // if (xLock) 620 // xLock->addActionLock(); 621 622 CellRangeAddress aRngAddr; 623 aRngAddr.Sheet = 0; 624 aRngAddr.StartColumn = 0; 625 aRngAddr.StartRow = 0; 626 aRngAddr.EndColumn = 9; 627 aRngAddr.EndRow = 19; 628 XCellRangeRef xRange = xDoc->getCellRange(aRngAddr); 629 if (xRange) 630 { 631 XCellCollectionRef xColl = (XCellCollection*) 632 xRange->queryInterface(XCellCollection::getSmartUik()); 633 if (xColl) 634 { 635 XEnumerationAccessRef xEnAcc = xColl->getCells(); 636 if (xEnAcc) 637 { 638 XEnumerationRef xEnum = xEnAcc->getEnumeration(); 639 if (xEnum) 640 { 641 while (xEnum->hasMoreElements()) 642 { 643 XInterfaceRef xInt = xEnum->nextElement(); 644 if (xInt) 645 { 646 ++nCount; 647 } 648 } 649 } 650 } 651 } 652 } 653 654 ULONG nEnd = Time::GetSystemTicks(); 655 aTimeText.SetText(String(nCount)+String(" ")+String(nEnd-nStart)+String(" ms")); 656 657 658 // if (xLock) 659 // xLock->removeActionLock(); 660 } 661 } 662 663 void lcl_Sheet( FixedText& aTimeText ) 664 { 665 aTimeText.SetText( "..." ); 666 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 667 if (!xDoc) return; 668 XSpreadsheetsRef xSheets = xDoc->getSheets(); 669 if (!xSheets) return; 670 XTableSheetRef xSheet = xSheets->getSheetByIndex(0); 671 if (!xSheet) return; 672 XNamedRef xNamed = (XNamed*)xSheet->queryInterface(XNamed::getSmartUik()); 673 if (!xNamed) return; 674 675 String aName = OUStringToString( xNamed->getName(), CHARSET_SYSTEM ); 676 aName += 'X'; 677 xNamed->setName(StringToOUString( aName, CHARSET_SYSTEM )); 678 679 XCellRangeRef xRange = (XCellRange*)xSheet->queryInterface(XCellRange::getSmartUik()); 680 if (!xRange) return; 681 XCellRef xCell = xRange->getCell(2,1); 682 if (!xCell) return; 683 XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); 684 if (!xText) return; 685 String aBla = OUStringToString( xText->getText(), CHARSET_SYSTEM ); 686 aBla += "bla"; 687 xText->setText(StringToOUString( aBla, CHARSET_SYSTEM )); 688 689 XColumnRowRangeRef xCRR = (XColumnRowRange*)xSheet->queryInterface(XColumnRowRange::getSmartUik()); 690 if (!xCRR) return; 691 692 XTableColumnsRef xCols = xCRR->getColumns(); 693 if (!xCols) return; 694 XPropertySetRef xCol = xCols->getColumnByIndex(2); 695 if (!xCol) return; 696 697 UINT16 nWidth = TypeConversion::toUINT16(xCol->getPropertyValue(L"Width")); 698 // UINT16 nNewWidth = nWidth + 100; 699 // xCol->setPropertyValue(L"Width", UsrAny(nNewWidth)); 700 701 xCol->setPropertyValue(L"OptimalWidth", UsrAny((BOOL)TRUE)); 702 xCol->setPropertyValue(L"NewPage", UsrAny((BOOL)FALSE)); 703 704 UsrAny aAny = xCol->getPropertyValue(L"ShadowFormat"); 705 if ( aAny.getReflection()->getName() == 706 ShadowFormat_getReflection()->getName() ) 707 { 708 //ShadowFormat* pOld = (ShadowFormat*)aAny.get(); 709 ShadowFormat aNew; 710 aNew.Location = SHADOWLOCATION_BOTTOMRIGHT; 711 aNew.ShadowWidth = 100; 712 aNew.IsTransparent = FALSE; 713 aNew.Color = 0xff0000L; 714 aAny.set( &aNew, aAny.getReflection() ); 715 xCol->setPropertyValue(L"ShadowFormat", aAny); 716 } 717 718 XTableRowsRef xRows = xCRR->getRows(); 719 if (!xRows) return; 720 XPropertySetRef xRow = xRows->getRowByIndex(1); 721 if (!xRow) return; 722 723 xRows->removeRowsByIndex( 2, 1 ); 724 725 UINT16 nHeight = TypeConversion::toUINT16(xRow->getPropertyValue(L"Height")); 726 BOOL bOptH = TypeConversion::toBOOL(xRow->getPropertyValue(L"OptimalHeight")); 727 728 UINT16 nNewHeight = nHeight + 100; 729 xRow->setPropertyValue(L"Height", UsrAny(nNewHeight)); 730 731 aTimeText.SetText(String("W:")+String(nWidth)+String(" H:")+String(nHeight)+ 732 String(" ")+String((USHORT)bOptH)); 733 } 734 735 void lcl_Names( FixedText& aTimeText ) 736 { 737 aTimeText.SetText( "..." ); 738 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 739 if (!xDoc) return; 740 XNamedRangesRef xNames = xDoc->getNamedRanges(); 741 if (!xNames) return; 742 XNamedRangeRef xName = xNames->getRangeByName(L"bla"); 743 if (!xName) return; 744 String aCont = OUStringToString( xName->getContent(), CHARSET_SYSTEM ); 745 aTimeText.SetText(aCont); 746 747 XCellRangeSourceRef xSource = (XCellRangeSource*) 748 xName->queryInterface(XCellRangeSource::getSmartUik()); 749 if (!xSource) return; 750 XCellRangeRef xRange = xSource->getReferredCells(); 751 if (!xRange) return; 752 XPropertySetRef xProp = (XPropertySet*)xRange->queryInterface(XPropertySet::getSmartUik()); 753 if (!xProp) return; 754 UsrAny aAny = xProp->getPropertyValue(L"RotationValue"); 755 aAny.setINT32(3000); 756 xProp->setPropertyValue(L"RotationValue", aAny); 757 } 758 759 void lcl_Sheets( FixedText& aTimeText ) 760 { 761 aTimeText.SetText( "..." ); 762 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 763 if (!xDoc) return; 764 XSpreadsheetsRef xSheets = xDoc->getSheets(); 765 if (!xSheets) return; 766 767 #if 0 768 xSheets->insertSheet( "hinten", 100 ); 769 xSheets->insertSheet( "vorne", 0 ); 770 xSheets->removeSheetByName( "hinten" ); 771 xSheets->removeSheetByName( "vorne" ); 772 #endif 773 774 xSheets->moveSheet(0, 1, TRUE); 775 xSheets->moveSheet(0, 2, FALSE); 776 } 777 778 void lcl_Goal( FixedText& aTimeText ) 779 { 780 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 781 if (!xDoc) return; 782 XGoalSeekRef xGoal = (XGoalSeek*)xDoc->queryInterface(XGoalSeek::getSmartUik()); 783 if (!xGoal) return; 784 785 double fResult; 786 CellAddress aFormula; // A1 787 aFormula.Sheet = 0; 788 aFormula.Column = 0; 789 aFormula.Row = 0; 790 CellAddress aVar; // A2 791 aVar.Sheet = 0; 792 aVar.Column = 0; 793 aVar.Row = 1; 794 BOOL bFound = xGoal->doGoalSeek(fResult, aFormula, aVar, L"42"); 795 796 if (bFound) 797 { 798 CellAddress aOut; // A3 799 aOut.Sheet = 0; 800 aOut.Column = 0; 801 aOut.Row = 2; 802 803 XCellRef xCell = xDoc->getCell(aOut); 804 if (!xCell) return; 805 xCell->setValue(fResult); 806 } 807 } 808 809 void lcl_TabOp( FixedText& aTimeText ) 810 { 811 // Mehrfachoperation auf Tabelle2 812 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 813 if (!xDoc) return; 814 815 XCellRangeRef xRange; 816 XTableOperationRef xGoal; 817 CellRangeAddress aRangeAddr; 818 CellRangeAddress aFormulaRange; 819 CellAddress aColumnCell; 820 CellAddress aRowCell; 821 TableOperationMode nMode; 822 823 aRangeAddr.Sheet = 1; // c9:e11 824 aRangeAddr.StartColumn = 2; 825 aRangeAddr.StartRow = 8; 826 aRangeAddr.EndColumn = 4; 827 aRangeAddr.EndRow = 10; 828 aFormulaRange.Sheet = 1; // c6:c7 829 aFormulaRange.StartColumn = 2; 830 aFormulaRange.StartRow = 5; 831 aFormulaRange.EndColumn = 2; 832 aFormulaRange.EndRow = 6; 833 aColumnCell.Sheet = 0; // nicht benutzt 834 aColumnCell.Column = 0; 835 aColumnCell.Row = 0; 836 aRowCell.Sheet = 1; // c5 837 aRowCell.Column = 2; 838 aRowCell.Row = 4; 839 nMode = TABLEOP_ROW; 840 841 xRange = xDoc->getCellRange(aRangeAddr); 842 if (!xRange) return; 843 xGoal = (XTableOperation*)xRange->queryInterface(XTableOperation::getSmartUik()); 844 if (!xGoal) return; 845 xGoal->setTableOperation( nMode, aFormulaRange, aColumnCell, aRowCell ); 846 847 aRangeAddr.Sheet = 1; // b19:d21 848 aRangeAddr.StartColumn = 1; 849 aRangeAddr.StartRow = 18; 850 aRangeAddr.EndColumn = 3; 851 aRangeAddr.EndRow = 20; 852 aFormulaRange.Sheet = 1; // c16:d16 853 aFormulaRange.StartColumn = 2; 854 aFormulaRange.StartRow = 15; 855 aFormulaRange.EndColumn = 3; 856 aFormulaRange.EndRow = 15; 857 aColumnCell.Sheet = 1; // b16 858 aColumnCell.Column = 1; 859 aColumnCell.Row = 15; 860 aRowCell.Sheet = 0; // nicht benutzt 861 aRowCell.Column = 0; 862 aRowCell.Row = 0; 863 nMode = TABLEOP_COLUMN; 864 865 xRange = xDoc->getCellRange(aRangeAddr); 866 if (!xRange) return; 867 xGoal = (XTableOperation*)xRange->queryInterface(XTableOperation::getSmartUik()); 868 if (!xGoal) return; 869 xGoal->setTableOperation( nMode, aFormulaRange, aColumnCell, aRowCell ); 870 871 aRangeAddr.Sheet = 1; // b29:e32 872 aRangeAddr.StartColumn = 1; 873 aRangeAddr.StartRow = 28; 874 aRangeAddr.EndColumn = 4; 875 aRangeAddr.EndRow = 31; 876 aFormulaRange.Sheet = 1; // c27:c27 877 aFormulaRange.StartColumn = 2; 878 aFormulaRange.StartRow = 26; 879 aFormulaRange.EndColumn = 2; 880 aFormulaRange.EndRow = 26; 881 aColumnCell.Sheet = 1; // c25 882 aColumnCell.Column = 2; 883 aColumnCell.Row = 24; 884 aRowCell.Sheet = 1; // c26 885 aRowCell.Column = 2; 886 aRowCell.Row = 25; 887 nMode = TABLEOP_BOTH; 888 889 xRange = xDoc->getCellRange(aRangeAddr); 890 if (!xRange) return; 891 xGoal = (XTableOperation*)xRange->queryInterface(XTableOperation::getSmartUik()); 892 if (!xGoal) return; 893 xGoal->setTableOperation( nMode, aFormulaRange, aColumnCell, aRowCell ); 894 } 895 896 void lcl_Fill( FixedText& aTimeText ) 897 { 898 XInterfaceRef xInt = lcl_GetView(); 899 if (!xInt) return; 900 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 901 if (!xView) return; 902 903 XInterfaceRef xSelInt = xView->getSelection(); 904 if (!xSelInt) return; 905 906 XCellSeriesRef xFill = (XCellSeries*)xSelInt->queryInterface(XCellSeries::getSmartUik()); 907 if (!xFill) return; 908 909 // xFill->fillAuto( FILL_DIRECTION_TO_BOTTOM, 2 ); 910 911 xFill->fillSeries( FILL_DIRECTION_TO_LEFT, FILL_MODE_GROWTH, FILL_DATE_DAY, 912 2.0, 1000.0 ); 913 } 914 915 void lcl_Audi( FixedText& aTimeText ) 916 { 917 aTimeText.SetText( "..." ); 918 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 919 if (!xDoc) return; 920 XSpreadsheetsRef xSheets = xDoc->getSheets(); 921 if (!xSheets) return; 922 XTableSheetRef xSheet = xSheets->getSheetByIndex(0); 923 if (!xSheet) return; 924 925 XSheetAuditingRef xAudi = (XSheetAuditing*)xSheet->queryInterface(XSheetAuditing::getSmartUik()); 926 if (!xAudi) return; 927 928 CellAddress aPosition; 929 aPosition.Sheet = 0; 930 aPosition.Column = 0; 931 aPosition.Row = 0; 932 xAudi->showDependents(aPosition); 933 } 934 935 void lcl_Consoli( FixedText& aTimeText ) 936 { 937 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 938 if (!xDoc) return; 939 XConsolidationRef xCons = (XConsolidation*)xDoc->queryInterface(XConsolidation::getSmartUik()); 940 if (!xCons) return; 941 XConsolidationDescriptorRef xDesc = xCons->createConsolidationDescriptor(FALSE); 942 if (!xDesc) return; 943 xDesc->setFunction(SUMMARY_COUNTNUMS); 944 xCons->consolidate(xDesc); 945 } 946 947 void lcl_Sort( FixedText& aTimeText ) 948 { 949 XInterfaceRef xInt = lcl_GetView(); 950 if (!xInt) return; 951 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 952 if (!xView) return; 953 XInterfaceRef xSelInt = xView->getSelection(); 954 if (!xSelInt) return; 955 XSortableRef xSort = (XSortable*)xSelInt->queryInterface(XSortable::getSmartUik()); 956 if (!xSort) return; 957 XSortDescriptorRef xDesc = xSort->createSortDescriptor(FALSE); 958 if (!xDesc) return; 959 Sequence<SortField> aFields = xDesc->getSortFields(); 960 if (aFields.getLen()) 961 { 962 // 1.Feld umkehren 963 SortField* pAry = aFields.getArray(); 964 if (!pAry) return; 965 pAry[0].Ascending = !pAry[0].Ascending; 966 } 967 else // neue Sequence, 1. Spalte aufsteigend 968 { 969 aFields = Sequence<SortField>(1); 970 SortField* pAry = aFields.getArray(); 971 if (!pAry) return; 972 pAry[0].Field = 0; 973 pAry[0].Ascending = TRUE; 974 pAry[0].Type = SORT_FIELD_AUTOMATIC; 975 } 976 xDesc->setSortFields(aFields); 977 978 XTableSortDescriptorRef xTableSort = (XTableSortDescriptor*) 979 xDesc->queryInterface(XTableSortDescriptor::getSmartUik()); 980 if (!xTableSort) return; 981 CellAddress aOutPos; 982 aOutPos.Sheet = 2; 983 aOutPos.Column = 0; 984 aOutPos.Row = 0; 985 xTableSort->setUseOutputPosition(TRUE); 986 xTableSort->setOutputPosition(aOutPos); 987 988 XPropertySetRef xPropSet = (XPropertySet*) 989 xDesc->queryInterface(XPropertySet::getSmartUik()); 990 if (!xPropSet) return; 991 xPropSet->setPropertyValue(L"IncludeFormats", UsrAny((BOOL)FALSE)); 992 993 xSort->sort(xDesc); 994 } 995 996 void lcl_Filter( FixedText& aTimeText ) 997 { 998 aTimeText.SetText("..."); 999 1000 XInterfaceRef xInt = lcl_GetView(); 1001 if (!xInt) return; 1002 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 1003 if (!xView) return; 1004 XInterfaceRef xSelInt = xView->getSelection(); 1005 if (!xSelInt) return; 1006 XFilterableRef xFilter = (XFilterable*)xSelInt->queryInterface(XFilterable::getSmartUik()); 1007 if (!xFilter) return; 1008 1009 #if 0 1010 XTableFilterDescriptorRef xDesc = xFilter->createFilterDescriptor(FALSE); 1011 if (!xDesc) return; 1012 Sequence<TableFilterField> aFields = xDesc->getFilterFields(); 1013 if (aFields.getLen()) 1014 { 1015 // 1.Feld zwischen 1. und 2. Spalte toggeln 1016 TableFilterField* pAry = aFields.getArray(); 1017 if (!pAry) return; 1018 pAry[0].Field = pAry[0].Field ? 0 : 1; 1019 } 1020 xDesc->setFilterFields(aFields); 1021 xFilter->filter(xDesc); 1022 #endif 1023 1024 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1025 if (!xDoc) return; 1026 CellRangeAddress aAddress; 1027 aAddress.Sheet = 3; 1028 aAddress.StartColumn = 0; 1029 aAddress.StartRow = 0; 1030 aAddress.EndColumn = 1; 1031 aAddress.EndRow = 2; 1032 XCellRangeRef xRange = xDoc->getCellRange(aAddress); 1033 if (!xRange) return; 1034 XAdvancedFilterSourceRef xSource = (XAdvancedFilterSource*) 1035 xRange->queryInterface(XAdvancedFilterSource::getSmartUik()); 1036 if (!xSource) return; 1037 1038 XTableFilterDescriptorRef xDesc = xSource->createAdvancedFilter(xFilter); 1039 if (!xDesc) 1040 { 1041 aTimeText.SetText("kein Filter"); 1042 return; 1043 } 1044 aTimeText.SetText("Filter gefunden"); 1045 xFilter->filter(xDesc); 1046 } 1047 1048 void lcl_AutoFilter( FixedText& aTimeText ) 1049 { 1050 XInterfaceRef xInt = lcl_GetView(); 1051 if (!xInt) return; 1052 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 1053 if (!xView) return; 1054 XInterfaceRef xSelInt = xView->getSelection(); 1055 if (!xSelInt) return; 1056 XFilterableRef xFilter = (XFilterable*)xSelInt->queryInterface(XFilterable::getSmartUik()); 1057 if (!xFilter) return; 1058 1059 BOOL bAuto = xFilter->getAutoFilter(); 1060 xFilter->setAutoFilter(!bAuto); 1061 } 1062 1063 void lcl_Merge( FixedText& aTimeText ) 1064 { 1065 static BOOL bMerged = FALSE; 1066 1067 XInterfaceRef xInt = lcl_GetView(); 1068 if (!xInt) return; 1069 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 1070 if (!xView) return; 1071 XInterfaceRef xSelInt = xView->getSelection(); 1072 if (!xSelInt) return; 1073 XMergeableRef xMerge = (XMergeable*)xSelInt->queryInterface(XMergeable::getSmartUik()); 1074 if (!xMerge) return; 1075 1076 if (bMerged) 1077 xMerge->unmergeCells(); 1078 else 1079 xMerge->mergeCells(); 1080 bMerged = !bMerged; 1081 } 1082 1083 void lcl_Outline( FixedText& aTimeText ) 1084 { 1085 static BOOL bOutline = FALSE; 1086 1087 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1088 if (!xDoc) return; 1089 XSpreadsheetsRef xSheets = xDoc->getSheets(); 1090 if (!xSheets) return; 1091 XTableSheetRef xSheet = xSheets->getSheetByIndex(0); 1092 if (!xSheet) return; 1093 XSheetOutlineRef xOut = (XSheetOutline*)xSheet->queryInterface(XSheetOutline::getSmartUik()); 1094 if (!xOut) return; 1095 1096 XInterfaceRef xInt = lcl_GetView(); 1097 if (!xInt) return; 1098 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 1099 if (!xView) return; 1100 XInterfaceRef xSelInt = xView->getSelection(); 1101 if (!xSelInt) return; 1102 XAddressableCellRangeRef xRange = (XAddressableCellRange*) 1103 xSelInt->queryInterface(XAddressableCellRange::getSmartUik()); 1104 if (!xRange) return; 1105 CellRangeAddress aRange = xRange->getRangeAddress(); 1106 1107 if (bOutline) 1108 xOut->showDetail( aRange ); 1109 else 1110 xOut->hideDetail( aRange ); 1111 1112 bOutline = !bOutline; 1113 } 1114 1115 void lcl_Bla( FixedText& aTimeText ) 1116 { 1117 aTimeText.SetText("..."); 1118 1119 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1120 if (!xDoc) return; 1121 XActionLockableRef xLock = (XActionLockable*)xDoc->queryInterface(XActionLockable::getSmartUik()); 1122 if (!xLock) return; 1123 xLock->addActionLock(); 1124 xLock->addActionLock(); 1125 USHORT nCount = xLock->resetActionLocks(); // sollte 2 sein 1126 String aBla = nCount; 1127 xLock->setActionLocks(nCount); 1128 xLock->removeActionLock(); 1129 xLock->removeActionLock(); 1130 1131 aBla += '/'; aBla += xLock->resetActionLocks(); // sollte 0 sein 1132 1133 aTimeText.SetText(aBla); 1134 } 1135 1136 void lcl_CellCursor( FixedText& aTimeText ) 1137 { 1138 static int nCursorCount = 0; 1139 1140 XInterfaceRef xInt = lcl_GetView(); 1141 if (!xInt) return; 1142 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 1143 if (!xView) return; 1144 XInterfaceRef xSelInt = xView->getSelection(); 1145 if (!xSelInt) return; 1146 XCellCollectionRef xColl = (XCellCollection*)xSelInt->queryInterface(XCellCollection::getSmartUik()); 1147 if (!xColl) return; 1148 1149 XLineCursorRef xCursor = xColl->createCursor(); 1150 if (!xCursor) return; 1151 XCellCursorRef xCC = (XCellCursor*)xCursor->queryInterface(XCellCursor::getSmartUik()); 1152 if (!xCC) return; 1153 XCellRangesCursorRef xCRC = (XCellRangesCursor*)xCursor->queryInterface(XCellRangesCursor::getSmartUik()); 1154 if (!xCRC) return; 1155 XCellRangeCursorRef xCR = (XCellRangeCursor*)xCursor->queryInterface(XCellRangeCursor::getSmartUik()); 1156 if (!xCR) return; 1157 XCellContentCursorRef xCCC = (XCellContentCursor*)xCursor->queryInterface(XCellContentCursor::getSmartUik()); 1158 if (!xCCC) return; 1159 XFormulaCursorRef xFC = (XFormulaCursor*)xCursor->queryInterface(XFormulaCursor::getSmartUik()); 1160 if (!xFC) return; 1161 1162 CellAddress aPos; 1163 aPos.Sheet = 0; // ignored 1164 aPos.Row = 3; 1165 aPos.Column = 2; 1166 1167 switch (nCursorCount++) 1168 { 1169 case 0: 1170 xFC->gotoDependents(FALSE); 1171 break; 1172 case 1: 1173 xFC->gotoDependents(TRUE); 1174 break; 1175 case 2: 1176 xFC->gotoPrecedents(FALSE); 1177 break; 1178 case 3: 1179 xFC->gotoPrecedents(TRUE); 1180 1181 nCursorCount = 0; 1182 break; 1183 } 1184 1185 XCellCollectionRef xNew = xCC->getRanges(); 1186 if (!xNew) return; 1187 xView->select( xNew ); 1188 } 1189 1190 void lcl_Notes( FixedText& aTimeText ) 1191 { 1192 aTimeText.SetText( "..." ); 1193 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1194 if (!xDoc) return; 1195 XSpreadsheetsRef xSheets = xDoc->getSheets(); 1196 if (!xSheets) return; 1197 XTableSheetRef xSheet = xSheets->getSheetByIndex(0); 1198 if (!xSheet) return; 1199 1200 XSheetAnnotationsRef xNotes = xSheet->getAnnotations(); 1201 if (!xNotes) return; 1202 XIndexAccessRef xNIndex = (XIndexAccess*)xNotes->queryInterface(XIndexAccess::getSmartUik()); 1203 if (!xNIndex) return; 1204 1205 CellAddress aPos; 1206 aPos.Column = 0; 1207 aPos.Row = 0; 1208 aPos.Sheet = 0; 1209 xNotes->addAnnotation( L"neu", aPos ); 1210 1211 ULONG nCount = xNIndex->getCount(); 1212 for (ULONG i=0; i<nCount; i++) 1213 { 1214 XSheetAnnotationRef xAnn = xNotes->getAnnotationByIndex((UINT16)i); 1215 XTextRef xText = (XText*)xAnn->queryInterface(XText::getSmartUik()); 1216 if (xText) 1217 { 1218 String aStr = OUStringToString( xText->getText(), CHARSET_SYSTEM ); 1219 aStr += "x"; 1220 xText->setText(StringToOUString( aStr, CHARSET_SYSTEM )); 1221 } 1222 } 1223 } 1224 1225 void lcl_Scenario( FixedText& aTimeText ) 1226 { 1227 aTimeText.SetText( "..." ); 1228 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1229 if (!xDoc) return; 1230 XSpreadsheetsRef xSheets = xDoc->getSheets(); 1231 if (!xSheets) return; 1232 XTableSheetRef xSheet = xSheets->getSheetByIndex(0); 1233 if (!xSheet) return; 1234 1235 XScenariosRef xColl = xSheet->getScenarios(); 1236 if (!xColl) return; 1237 1238 Sequence<CellRangeAddress> aRanges(2); 1239 CellRangeAddress* pAry = aRanges.getArray(); 1240 if (!pAry) return; 1241 pAry[0].Sheet = 0; 1242 pAry[0].StartColumn = 0; 1243 pAry[0].StartRow = 0; 1244 pAry[0].EndColumn = 1; 1245 pAry[0].EndRow = 1; 1246 pAry[1].Sheet = 0; 1247 pAry[1].StartColumn = 3; 1248 pAry[1].StartRow = 3; 1249 pAry[1].EndColumn = 4; 1250 pAry[1].EndRow = 4; 1251 1252 xColl->addScenario( aRanges, L"bla", L"bla blubb" ); 1253 1254 XIndexAccessRef xIndex = (XIndexAccess*)xColl->queryInterface(XIndexAccess::getSmartUik()); 1255 if (!xIndex) return; 1256 ULONG nCount = xIndex->getCount(); 1257 aTimeText.SetText( nCount ); 1258 1259 XScenarioRef xScen = xColl->getScenarioByIndex(0); 1260 if (!xScen) return; 1261 1262 aRanges = Sequence<CellRangeAddress>(1); 1263 pAry = aRanges.getArray(); 1264 if (!pAry) return; 1265 pAry[0].Sheet = 0; 1266 pAry[0].StartColumn = 6; 1267 pAry[0].StartRow = 6; 1268 pAry[0].EndColumn = 7; 1269 pAry[0].EndRow = 7; 1270 1271 xScen->addRanges( aRanges ); 1272 1273 XTableSheetRef xSh2 = xSheets->getSheetByIndex(1); 1274 if (!xSh2) return; 1275 1276 xSh2->setVisible( TRUE ); 1277 xSh2->setVisible( FALSE ); 1278 } 1279 1280 void lcl_Formula( FixedText& aTimeText ) 1281 { 1282 aTimeText.SetText("..."); 1283 1284 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1285 if (!xDoc) return; 1286 CellAddress aPos; 1287 aPos.Sheet = 0; 1288 aPos.Column = 0; 1289 aPos.Row = 0; 1290 XCellRef xCell = xDoc->getCell(aPos); 1291 if (!xCell) return; 1292 1293 // String aStr = OUStringToString( xCell->getFormula(), CHARSET_SYSTEM ); 1294 // aTimeText.SetText(aStr); 1295 1296 XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); 1297 if (!xText) return; 1298 String aStr = OUStringToString( xText->getText(), CHARSET_SYSTEM ); 1299 aTimeText.SetText(aStr); 1300 } 1301 1302 void lcl_DBRange( FixedText& aTimeText ) // 23 1303 { 1304 aTimeText.SetText("..."); 1305 1306 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1307 if (!xDoc) return; 1308 XDatabaseRangesRef xDBs = xDoc->getDatabaseRanges(); 1309 if (!xDBs) return; 1310 1311 CellRangeAddress aRange; 1312 aRange.Sheet = 0; 1313 aRange.StartColumn = 1; 1314 aRange.StartRow = 1; 1315 aRange.EndColumn = 3; 1316 aRange.EndRow = 10; 1317 1318 xDBs->addRange( L"blubb", aRange ); 1319 1320 xDBs->removeRangeByName( L"gaga" ); 1321 1322 XDatabaseRangeRef xDB = xDBs->getRangeByName( L"blubb" ); 1323 if (!xDB) return; 1324 1325 String aName = OUStringToString( xDB->getName(), CHARSET_SYSTEM ); 1326 aTimeText.SetText(aName); 1327 1328 xDB->setName( L"gaga" ); 1329 1330 CellRangeAddress aDBRange = xDB->getDataArea(); 1331 ++aDBRange.Sheet; 1332 xDB->setDataArea(aDBRange); 1333 } 1334 1335 void lcl_FillTab( FixedText& aTimeText ) // 24 1336 { 1337 aTimeText.SetText("..."); 1338 1339 XInterfaceRef xInt = lcl_GetView(); 1340 if (!xInt) return; 1341 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 1342 if (!xView) return; 1343 XInterfaceRef xSelInt = xView->getSelection(); 1344 if (!xSelInt) return; 1345 1346 XCellRangesRef xRanges = (XCellRanges*)xSelInt->queryInterface(XCellRanges::getSmartUik()); 1347 XIndexAccessRef xIndex = (XIndexAccess*)xSelInt->queryInterface(XIndexAccess::getSmartUik()); 1348 if (!xRanges || !xIndex) return; 1349 1350 ULONG nCount = xIndex->getCount(); 1351 aTimeText.SetText(nCount); 1352 } 1353 1354 void lcl_Listener( FixedText& aTimeText ) // 25 1355 { 1356 XInterfaceRef xInt = lcl_GetView(); 1357 if (!xInt) return; 1358 XStarCalcViewRef xView = (XStarCalcView*)xInt->queryInterface(XStarCalcView::getSmartUik()); 1359 if (!xView) return; 1360 xView->addSelectionChangeListener( new ScTestListener(&aTimeText) ); 1361 } 1362 1363 void lcl_CellAttrib( FixedText& aTimeText ) // 26 1364 { 1365 XInterfaceRef xInt = lcl_GetView(); 1366 if (!xInt) return; 1367 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 1368 if (!xView) return; 1369 XInterfaceRef xSelInt = xView->getSelection(); 1370 if (!xSelInt) return; 1371 XTextRef xText = (XText*)xSelInt->queryInterface(XText::getSmartUik()); 1372 if (!xText) return; 1373 1374 XTextCursorRef xCursor = xText->createTextCursor(); 1375 if (!xCursor) return; 1376 1377 XTextPositionRef xPos = (XTextPosition*)xCursor->queryInterface(XTextPosition::getSmartUik()); 1378 XPropertySetRef xProp = (XPropertySet*)xCursor->queryInterface(XPropertySet::getSmartUik()); 1379 XParagraphCursorRef xPar = (XParagraphCursor*)xCursor->queryInterface(XParagraphCursor::getSmartUik()); 1380 if (!xPos || !xProp || !xPar) return; 1381 1382 xCursor->gotoStart(FALSE); 1383 xCursor->goRight(1,FALSE); 1384 xCursor->goRight(1,TRUE); 1385 1386 UsrAny aAny = xProp->getPropertyValue(L"FontHeight"); 1387 UINT32 nOld = aAny.getUINT32(); 1388 aAny.setUINT32(nOld*11/10); 1389 xProp->setPropertyValue(L"FontHeight", aAny); 1390 1391 xPos->collapseToEnd(); 1392 xCursor->goRight(1,TRUE); 1393 1394 xProp->setPropertyValue(L"Bold", UsrAny((BOOL)TRUE)); 1395 1396 xPos->setText(L"x"); 1397 1398 xPos->collapseToEnd(); 1399 xPar->gotoNextParagraph(FALSE,TRUE); 1400 xProp->setPropertyValue(L"Italic", UsrAny((BOOL)TRUE)); 1401 xProp->setPropertyValue(L"Underlined", UsrAny((BOOL)TRUE)); 1402 } 1403 1404 void lcl_Styles( FixedText& aTimeText ) // 27 1405 { 1406 aTimeText.SetText("..."); 1407 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1408 if (!xDoc) return; 1409 XStyleFamiliesRef xFamilies = xDoc->getStyleFamilies(); 1410 if (!xFamilies) return; 1411 XStyleFamilyRef xFamily = xFamilies->getStyleFamilyByType( STYLE_FAMILY_CELL ); 1412 // XStyleFamilyRef xFamily = xFamilies->getStyleFamilyByType( STYLE_FAMILY_PAGE ); 1413 if (!xFamily) return; 1414 long nCount = xFamily->getCount(); 1415 aTimeText.SetText(nCount); 1416 1417 XStyleRef xStyle = xFamily->getStyleByName(L"rot"); 1418 if (!xStyle) return; 1419 // XPropertySetRef xProp = (XPropertySet*)xStyle->queryInterface(XPropertySet::getSmartUik()); 1420 // if (!xProp) return; 1421 1422 XStyleRef xNew = xFamily->addStyle( L"gaga", xStyle ); 1423 if (!xNew) return; 1424 XPropertySetRef xProp = (XPropertySet*)xNew->queryInterface(XPropertySet::getSmartUik()); 1425 if (!xProp) return; 1426 1427 UsrAny aAny; 1428 aAny = xProp->getPropertyValue(L"TransparentBackground"); 1429 aAny.setBOOL(FALSE); 1430 xProp->setPropertyValue(L"TransparentBackground", aAny); 1431 aAny = xProp->getPropertyValue(L"BackgroundColor"); 1432 aAny.setUINT32(0xffff00); 1433 xProp->setPropertyValue(L"BackgroundColor", aAny); 1434 1435 xFamily->removeStyle( L"rot" ); 1436 } 1437 1438 void lcl_PageStyle( FixedText& aTimeText ) // 28 1439 { 1440 aTimeText.SetText("..."); 1441 1442 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1443 if (!xDoc) return; 1444 XStyleFamiliesRef xFamilies = xDoc->getStyleFamilies(); 1445 if (!xFamilies) return; 1446 XStyleFamilyRef xFamily = xFamilies->getStyleFamilyByType( STYLE_FAMILY_PAGE ); 1447 if (!xFamily) return; 1448 XStyleRef xStyle = xFamily->getStyleByName(L"Standard"); 1449 if (!xStyle) return; 1450 XPropertySetRef xProp = (XPropertySet*)xStyle->queryInterface(XPropertySet::getSmartUik()); 1451 if (!xProp) return; 1452 1453 UsrAny aAny; 1454 aAny = xProp->getPropertyValue(L"RightPageHeaderContent"); 1455 1456 // geht nicht: 1457 // if ( !XHeaderFooterContent_getReflection()->equals(*aAny.getReflection()) ) 1458 // return; 1459 1460 XHeaderFooterContentRef* pxContent = (XHeaderFooterContentRef*)aAny.get(); 1461 if (!pxContent || !pxContent->is()) return; 1462 1463 XTextRef xText = (*pxContent)->getCenterText(); 1464 if (!xText) return; 1465 1466 String aVal = OUStringToString(xText->getText(), CHARSET_SYSTEM); 1467 aTimeText.SetText(aVal); 1468 1469 // xText->setText(L"Bla fasel s\xFClz"); 1470 lcl_SetText(xText); 1471 1472 xProp->setPropertyValue(L"RightPageHeaderContent", aAny); 1473 } 1474 1475 void lcl_AutoForm( FixedText& aTimeText ) // 29 1476 { 1477 XInterfaceRef xInt = lcl_GetView(); 1478 if (!xInt) return; 1479 1480 #if 0 1481 //! Test - AutoFormat muss von der App kommen 1482 XStarCalcViewRef xView = (XStarCalcView*)xInt->queryInterface(XStarCalcView::getSmartUik()); 1483 if (!xView) return; 1484 XTableAutoFormatsRef xFormats = xView->getTableAutoFormats(); 1485 if (!xFormats) return; 1486 //! Test 1487 #endif 1488 XTableAutoFormatsRef xFormats; 1489 1490 XTableAutoFormatRef xFormat = xFormats->getAutoFormatByName(L"gaga"); 1491 if (!xFormat) return; 1492 XPropertySetRef xProp = (XPropertySet*)xFormat->queryInterface(XPropertySet::getSmartUik()); 1493 if (!xProp) return; 1494 1495 BOOL bVal = TypeConversion::toBOOL(xProp->getPropertyValue(L"IncludeBackground")); 1496 xProp->setPropertyValue(L"IncludeBackground", UsrAny(BOOL(!bVal))); 1497 1498 XNamedRef xNamed = (XNamed*)xFormat->queryInterface(XNamed::getSmartUik()); 1499 if (!xNamed) return; 1500 xNamed->setName(L"zzz"); 1501 1502 xFormats->addAutoFormat(L"gaga"); 1503 XTableAutoFormatRef xNew = xFormats->getAutoFormatByName(L"gaga"); 1504 if (!xNew) return; 1505 1506 for (USHORT i=0; i<16; i++) 1507 { 1508 XPropertySetRef xNewProp = xNew->getFieldByIndex(i); 1509 if (!xNewProp) return; 1510 1511 xNewProp->setPropertyValue(L"TransparentBackground", UsrAny(BOOL(FALSE))); 1512 UINT32 nColor = 0x111100 * i; 1513 xNewProp->setPropertyValue(L"BackgroundColor", UsrAny(nColor)); 1514 } 1515 } 1516 1517 void lcl_Pivot( FixedText& aTimeText ) // 30 1518 { 1519 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1520 if (!xDoc) return; 1521 1522 XSpreadsheetsRef xSheets = xDoc->getSheets(); 1523 if (!xSheets) return; 1524 XIndexAccessRef xInd = (XIndexAccess*)xSheets->queryInterface(XIndexAccess::getSmartUik()); 1525 if (!xInd) return; 1526 USHORT nCount = (USHORT)xInd->getCount(); 1527 1528 for (USHORT nTab=0; nTab<nCount; nTab++) 1529 { 1530 XTableSheetRef xSheet = xSheets->getSheetByIndex(nTab); 1531 if (!xSheet) return; 1532 XDataPilotTablesRef xPivots = xSheet->getDataPilotTables(); 1533 if (!xPivots) return; 1534 lcl_OutputNames( xPivots, xDoc, nTab,0,0 ); 1535 XIndexAccessRef xPInd = (XIndexAccess*)xPivots->queryInterface(XIndexAccess::getSmartUik()); 1536 if (!xPInd) return; 1537 USHORT nPCount = (USHORT)xPInd->getCount(); 1538 for (USHORT nP=0; nP<nPCount; nP++) 1539 { 1540 XDataPilotTableRef xTable = xPivots->getTableByIndex(nP); 1541 if (!xTable) return; 1542 1543 // xTable->refreshTable(); 1544 1545 XDataPilotDescriptorRef xDesc = (XDataPilotDescriptor*) 1546 xTable->queryInterface(XDataPilotDescriptor::getSmartUik()); 1547 if (!xDesc) return; 1548 CellRangeAddress aSource = xDesc->getSourceRange(); 1549 ++aSource.Sheet; 1550 xDesc->setSourceRange(aSource); 1551 1552 CellRangeAddress aAddr = xTable->getOutputRange(); 1553 XCellRangeRef xRange = xDoc->getCellRange(aAddr); 1554 if (!xRange) return; 1555 XPropertySetRef xProp = (XPropertySet*)xRange->queryInterface(XPropertySet::getSmartUik()); 1556 if (!xProp) return; 1557 xProp->setPropertyValue(L"TransparentBackground", UsrAny(BOOL(FALSE))); 1558 xProp->setPropertyValue(L"BackgroundColor", UsrAny((UINT32)0x00FF00)); 1559 } 1560 } 1561 } 1562 1563 IMPL_LINK(MyWindow, CountHdl, PushButton*, EMPTYARG) 1564 { 1565 #if 0 1566 1567 long nCount = aCountField.GetValue(); 1568 if (nCount < 1) 1569 nCount = 1; 1570 1571 ULONG nStart = Time::GetSystemTicks(); 1572 for (long i=0; i<nCount; i++) 1573 lcl_DoCount(); 1574 ULONG nEnd = Time::GetSystemTicks(); 1575 aTimeText.SetText(String(nCount)+String(" x Count: ")+String(nEnd-nStart)+String(" ms")); 1576 1577 #else 1578 1579 long nCount = aCountField.GetValue(); 1580 switch ( nCount ) 1581 { 1582 case 0: 1583 { 1584 ULONG nStart = Time::GetSystemTicks(); 1585 lcl_DoCount(); 1586 ULONG nEnd = Time::GetSystemTicks(); 1587 aTimeText.SetText(String("Count: ")+String(nEnd-nStart)+String(" ms")); 1588 } 1589 break; 1590 case 1: 1591 lcl_GlobalCell(); 1592 break; 1593 case 2: 1594 lcl_Annotations(aTimeText); 1595 break; 1596 case 3: 1597 lcl_Cursor(aTimeText); 1598 break; 1599 case 4: 1600 lcl_Cells(aTimeText); 1601 break; 1602 case 5: 1603 lcl_Sheet(aTimeText); 1604 break; 1605 case 6: 1606 lcl_Names(aTimeText); 1607 break; 1608 case 7: 1609 lcl_Sheets(aTimeText); 1610 break; 1611 case 8: 1612 lcl_Goal(aTimeText); 1613 break; 1614 case 9: 1615 lcl_TabOp(aTimeText); 1616 break; 1617 case 10: 1618 lcl_Fill(aTimeText); 1619 break; 1620 case 11: 1621 lcl_Audi(aTimeText); 1622 break; 1623 case 12: 1624 lcl_Consoli(aTimeText); 1625 break; 1626 case 13: 1627 lcl_Sort(aTimeText); 1628 break; 1629 case 14: 1630 lcl_Filter(aTimeText); 1631 break; 1632 case 15: 1633 lcl_AutoFilter(aTimeText); 1634 break; 1635 case 16: 1636 lcl_Merge(aTimeText); 1637 break; 1638 case 17: 1639 lcl_Outline(aTimeText); 1640 break; 1641 case 18: 1642 lcl_Bla(aTimeText); 1643 break; 1644 case 19: 1645 lcl_CellCursor(aTimeText); 1646 break; 1647 case 20: 1648 lcl_Notes(aTimeText); 1649 break; 1650 case 21: 1651 lcl_Scenario(aTimeText); 1652 break; 1653 case 22: 1654 lcl_Formula(aTimeText); 1655 break; 1656 case 23: 1657 lcl_DBRange(aTimeText); 1658 break; 1659 case 24: 1660 lcl_FillTab(aTimeText); 1661 break; 1662 case 25: 1663 lcl_Listener(aTimeText); 1664 break; 1665 case 26: 1666 lcl_CellAttrib(aTimeText); 1667 break; 1668 case 27: 1669 lcl_Styles(aTimeText); 1670 break; 1671 case 28: 1672 lcl_PageStyle(aTimeText); 1673 break; 1674 case 29: 1675 lcl_AutoForm(aTimeText); 1676 break; 1677 case 30: 1678 lcl_Pivot(aTimeText); 1679 break; 1680 } 1681 1682 #endif 1683 1684 return 0; 1685 } 1686 1687 //----------------------------------------------------------------------- 1688 1689 IMPL_LINK(MyWindow, TextHdl, PushButton*, EMPTYARG) 1690 { 1691 USHORT nTab = 0; 1692 USHORT nCol = (USHORT)aColField.GetValue(); 1693 USHORT nRow = (USHORT)aRowField.GetValue(); 1694 USHORT nPos = (USHORT)aPosField.GetValue(); 1695 USHORT nLen = (USHORT)aLenField.GetValue(); 1696 String aStr = aTextEdit.GetText(); 1697 1698 aTimeText.SetText("..."); 1699 1700 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1701 if (xDoc) 1702 { 1703 CellAddress aPos; 1704 aPos.Sheet = nTab; 1705 aPos.Column = nCol; 1706 aPos.Row = nRow; 1707 XCellRef xCell = xDoc->getCell(aPos); 1708 if ( xCell ) 1709 { 1710 XTextRef xCellText = (XText*)xCell->queryInterface(XText::getSmartUik()); 1711 if (xCellText) 1712 { 1713 XTextCursorRef xCursor = xCellText->createTextCursor(); 1714 if (xCursor) 1715 { 1716 XTextPositionRef xPos = (XTextPosition*) 1717 xCursor->queryInterface(XTextPosition::getSmartUik()); 1718 XControlCharacterInsertableRef xControl = (XControlCharacterInsertable*) 1719 xCursor->queryInterface(XControlCharacterInsertable::getSmartUik()); 1720 1721 if (xPos && xControl) 1722 { 1723 xCursor->gotoStart(FALSE); 1724 xCursor->goRight(11,TRUE); 1725 String aVal = OUStringToString( xPos->getText(), CHARSET_SYSTEM ); 1726 aTimeText.SetText(aVal); 1727 } 1728 } 1729 } 1730 } 1731 } 1732 1733 return 0; 1734 } 1735 1736 //----------------------------------------------------------------------- 1737 1738 IMPL_LINK(MyWindow, BlaHdl, PushButton*, EMPTYARG) 1739 { 1740 aTimeText.SetText("..."); 1741 1742 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1743 if (xDoc) 1744 { 1745 CellAddress aPos; 1746 aPos.Sheet = 0; 1747 aPos.Column = 1; 1748 aPos.Row = 2; 1749 XCellRef xCell = xDoc->getCell(aPos); 1750 if ( xCell ) 1751 { 1752 XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); 1753 XFieldContainerRef xCont = (XFieldContainer*) 1754 xCell->queryInterface(XFieldContainer::getSmartUik()); 1755 1756 if ( xText && xCont ) 1757 { 1758 XFieldTypesRef xTypes = xCont->getFieldTypes(); 1759 if ( xTypes ) 1760 { 1761 XTextFieldTypeRef xType = xTypes->getFieldType( FIELDTYPE_INTERNET ); 1762 XTextCursorRef xCursor = xText->createTextCursor(); 1763 if ( xCursor && xType ) 1764 { 1765 #if 0 1766 // Feld einfuegen 1767 XTextPositionRef xPos = (XTextPosition*) 1768 xCursor->queryInterface(XTextPosition::getSmartUik()); 1769 if ( xPos ) 1770 { 1771 xCursor->gotoEnd(FALSE); 1772 XTextFieldRef xField = xTypes->insertTextField( xType, xPos ); 1773 if (xField) 1774 { 1775 // Eigenschaften setzen 1776 XPropertySetRef xProp = (XPropertySet*)xField-> 1777 queryInterface(XPropertySet::getSmartUik()); 1778 if ( xProp ) 1779 { 1780 xProp->setPropertyValue(L"URL", 1781 UsrAny(String("http://www.mopo.de/"))); 1782 xProp->setPropertyValue(L"Representation", 1783 UsrAny(String("ein Hyperlink"))); 1784 } 1785 } 1786 } 1787 #endif 1788 1789 // letztes Feld loeschen 1790 XIndexAccessRef xIndex = (XIndexAccess*) 1791 xType->queryInterface(XIndexAccess::getSmartUik()); 1792 if (xIndex) 1793 { 1794 String aBla; 1795 ULONG nCount = xIndex->getCount(); 1796 for (ULONG i=0; i<nCount; i++) 1797 { 1798 XInterfaceRef xInt = xIndex->getElementByIndex(i); 1799 if (xInt) 1800 { 1801 XPropertySetRef xProp = (XPropertySet*)xInt-> 1802 queryInterface(XPropertySet::getSmartUik()); 1803 if ( xProp ) 1804 { 1805 if (aBla.Len()) aBla += ','; 1806 aBla += OUStringToString( 1807 TypeConversion::toString( 1808 xProp->getPropertyValue(L"URL") ), 1809 CHARSET_SYSTEM ); 1810 } 1811 if ( i+1 == nCount ) // letztes 1812 { 1813 XTextFieldRef xField = (XTextField*)xInt-> 1814 queryInterface(XTextField::getSmartUik()); 1815 if (xField) 1816 xTypes->removeTextField(xField); 1817 } 1818 } 1819 } 1820 aTimeText.SetText(aBla); 1821 } 1822 } 1823 } 1824 } 1825 } 1826 1827 xGlobalCell = xCell; 1828 } 1829 return 0; 1830 } 1831 1832 1833 //----------------------------------------------------------------------- 1834 1835 IMPL_LINK(MyWindow, TabHdl, PushButton*, EMPTYARG) 1836 { 1837 String aResult; 1838 1839 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1840 if (xDoc) 1841 { 1842 XSpreadsheetsRef xSheets = xDoc->getSheets(); 1843 if (xSheets) 1844 { 1845 XIndexAccessRef xIndex = (XIndexAccess*)xSheets->queryInterface(XIndexAccess::getSmartUik()); 1846 if (xIndex) 1847 { 1848 USHORT nCount = (USHORT) xIndex->getCount(); 1849 for (USHORT nTab=0; nTab<nCount; nTab++) 1850 { 1851 XInterfaceRef xInt = xIndex->getElementByIndex(nTab); 1852 if (xInt) 1853 { 1854 XNamedRef xNamed = (XNamed*)xInt->queryInterface(XNamed::getSmartUik()); 1855 if (xNamed) 1856 { 1857 if (nTab) 1858 aResult += ","; 1859 aResult += OUStringToString( xNamed->getName(), CHARSET_SYSTEM ); 1860 } 1861 } 1862 } 1863 } 1864 1865 CellAddress aPos; 1866 aPos.Sheet = 0; 1867 aPos.Column = 0; 1868 aPos.Row = 0; 1869 1870 XEnumerationAccessRef xEAcc = (XEnumerationAccess*) 1871 xSheets->queryInterface(XEnumerationAccess::getSmartUik()); 1872 if (xEAcc) 1873 { 1874 XEnumerationRef xEnum = xEAcc->getEnumeration(); 1875 if (xEnum) 1876 { 1877 while (xEnum->hasMoreElements()) 1878 { 1879 XInterfaceRef xInt = xEnum->nextElement(); 1880 if (xInt) 1881 { 1882 XNamedRef xNamed = (XNamed*)xInt->queryInterface(XNamed::getSmartUik()); 1883 if (xNamed) 1884 { 1885 UString aName = xNamed->getName(); 1886 XCellRef xCell = xDoc->getCell(aPos); 1887 if ( xCell ) 1888 { 1889 XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); 1890 xText->setText( aName ); 1891 ++aPos.Row; 1892 } 1893 } 1894 } 1895 } 1896 } 1897 } 1898 } 1899 } 1900 1901 aTimeText.SetText(aResult); 1902 1903 return 0; 1904 } 1905 1906 //----------------------------------------------------------------------- 1907 1908 void lcl_FillCells(XCellCollectionRef xColl) 1909 { 1910 XEnumerationAccessRef xEnAcc = xColl->getCells(); 1911 if (!xEnAcc) return; 1912 XEnumerationRef xEnum = xEnAcc->getEnumeration(); 1913 if (!xEnum) return; 1914 while (xEnum->hasMoreElements()) 1915 { 1916 XInterfaceRef xInt = xEnum->nextElement(); 1917 if (xInt) 1918 { 1919 XCellRef xCell = (XCell*)xInt->queryInterface(XCell::getSmartUik()); 1920 if (xCell) 1921 { 1922 xCell->setValue(42.0); 1923 } 1924 } 1925 } 1926 } 1927 1928 IMPL_LINK(MyWindow, ViewHdl, PushButton*, EMPTYARG) 1929 { 1930 XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model 1931 XInterfaceRef xInt = lcl_GetView(); 1932 if (!xInt) return 0; 1933 XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); 1934 if (!xView) return 0; 1935 1936 XInterfaceRef xSelInt = xView->getSelection(); 1937 if (!xSelInt) return 0; 1938 1939 #if 0 1940 XPropertySetRef xProp = (XPropertySet*)xSelInt->queryInterface(XPropertySet::getSmartUik()); 1941 if ( xProp ) 1942 { 1943 UsrAny aAny; 1944 1945 aAny = xProp->getPropertyValue(L"TransparentBackground"); 1946 aAny.setBOOL(FALSE); 1947 xProp->setPropertyValue(L"TransparentBackground", aAny); 1948 1949 aAny = xProp->getPropertyValue(L"BackgroundColor"); 1950 aAny.setUINT32(0xffff00); 1951 xProp->setPropertyValue(L"BackgroundColor", aAny); 1952 } 1953 XIndentRef xInd = (XIndent*)xSelInt->queryInterface(XIndent::getSmartUik()); 1954 if ( xInd ) 1955 { 1956 xInd->incrementIndent(); 1957 } 1958 #endif 1959 1960 XAutoFormattableRef xAuto = (XAutoFormattable*)xSelInt-> 1961 queryInterface(XAutoFormattable::getSmartUik()); 1962 if ( xAuto ) 1963 xAuto->applyAutoFormat( L"gaga" ); 1964 1965 XFormulaArrayRef xArr = (XFormulaArray*)xSelInt->queryInterface(XFormulaArray::getSmartUik()); 1966 if ( xArr ) 1967 { 1968 // xArr->setFormulaArray( "123" ); 1969 String aFormula = OUStringToString( xArr->getFormulaArray(), CHARSET_SYSTEM ); 1970 aTimeText.SetText(aFormula); 1971 } 1972 else 1973 aTimeText.SetText("..."); 1974 1975 XTextRef xText = (XText*)xSelInt->queryInterface(XText::getSmartUik()); 1976 if ( xText ) 1977 { 1978 String aStr = OUStringToString( xText->getText(), CHARSET_SYSTEM ); 1979 aStr += 'X'; 1980 xText->setText(StringToOUString(aStr, CHARSET_SYSTEM)); 1981 } 1982 1983 // Zelle selektieren 1984 1985 #if 0 1986 if (xDoc) 1987 { 1988 CellAddress aPos; 1989 aPos.Sheet = 0; 1990 aPos.Column = 1; 1991 aPos.Row = 2; 1992 XCellRef xCell = xDoc->getCell(aPos); 1993 if ( xCell ) 1994 xView->select( xCell ); 1995 } 1996 #endif 1997 1998 XPrintableRef xPrint = (XPrintable*)xInt->queryInterface(XPrintable::getSmartUik()); 1999 String aName = OUStringToString( xPrint->getPrinterName(), CHARSET_SYSTEM ); 2000 // aTimeText.SetText(aName); 2001 2002 xPrint->setPrinterName(L"HP5_2"); 2003 // xPrint->setPrinterName(L"blubb"); 2004 2005 // XPropertySetRef xOptions; 2006 // xPrint->print(xOptions); 2007 2008 /* XViewPaneRef xPane = (XViewPane*)xInt->queryInterface(XViewPane::getSmartUik()); 2009 if (!xPane) return 0; 2010 xPane->setScrollRow( 2 ); 2011 */ 2012 2013 XCellRangeSourceRef xSrc = (XCellRangeSource*) 2014 xInt->queryInterface(XCellRangeSource::getSmartUik()); 2015 if (!xSrc) return 0; 2016 XCellRangeRef xRange = xSrc->getReferredCells(); 2017 if (!xRange) return 0; 2018 XCellCollectionRef xColl = (XCellCollection*) 2019 xRange->queryInterface(XCellCollection::getSmartUik()); 2020 if (!xColl) return 0; 2021 2022 XActionLockableRef xLock = (XActionLockable*) 2023 xDoc->queryInterface(XActionLockable::getSmartUik()); 2024 if (xLock) 2025 xLock->addActionLock(); // nicht zwischendurch painten 2026 2027 // lcl_FillCells(xColl); 2028 2029 if (xLock) 2030 xLock->removeActionLock(); // nicht zwischendurch painten 2031 2032 XStarCalcViewRef xCalc = (XStarCalcView*)xInt->queryInterface(XStarCalcView::getSmartUik()); 2033 if (!xCalc) return 0; 2034 2035 return 0; 2036 } 2037 2038