1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: test.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <tools/debug.hxx>
32 #include <svtools/libcall.hxx>
33 #include <vcl/msgbox.hxx>
34 #include <vcl/window.hxx>
35 #include <vcl/imagebtn.hxx>
36 #include <vcl/field.hxx>
37 #include <vcl/fixed.hxx>
38 #include <vcl/help.hxx>
39 #include <usr/conver.hxx>
40 #include <usr/uno.hxx>
41 #include <usr/refl.hxx>
42 #include <stardiv/one/frame/xcollect.hxx>
43 #include <stardiv/one/text/offfield.hxx>
44 #include <stardiv/one/offmisc.hxx>
45 #include <stardiv/one/sheet/offtable.hxx>
46 #include <stardiv/one/text/offtext.hxx>
47 #include <stardiv/one/offstyle.hxx>
48 #include <stardiv/one/offview.hxx>
49 #include <stardiv/uno/repos/serinfo.hxx>
50 #include <stardiv/one/sheet/sctypes.hxx>
51 #include <stardiv/one/sheet/scmodel.hxx>
52 #include <stardiv/one/sheet/sccells.hxx>
53 #include <stardiv/one/sheet/sctables.hxx>
54 #include <stardiv/one/sheet/sctable.hxx>
55 #include <stardiv/one/sheet/sccell.hxx>
56 #include <stardiv/one/sheet/scpostit.hxx>
57 #include <stardiv/one/sheet/scview.hxx>
58 #include <stardiv/one/sheet/scdata.hxx>
59 #include <stardiv/one/sheet/scattr.hxx>
61 //! das muss als Konstante in irgendeine idl-Datei!!!!
62 #define TEXTCONTROLCHAR_PARAGRAPH_BREAK 0
65 class MyFixedText
: public FixedText
68 void RequestHelp( const HelpEvent
& rHEvt
);
70 MyFixedText(Window
* pParent
) : FixedText(pParent
) {}
73 class MyWindow
: public Window
76 NumericField aCountField
;
77 PushButton aCountButton
;
78 MyFixedText aTimeText
;
79 NumericField aColField
;
80 NumericField aRowField
;
81 NumericField aPosField
;
82 NumericField aLenField
;
84 PushButton aTextButton
;
85 PushButton aBlaButton
;
86 PushButton aTabButton
;
87 PushButton aViewButton
;
90 MyWindow( Window
*pParent
);
92 DECL_LINK(CountHdl
, PushButton
*);
93 DECL_LINK(TextHdl
, PushButton
*);
94 DECL_LINK(BlaHdl
, PushButton
*);
95 DECL_LINK(TabHdl
, PushButton
*);
96 DECL_LINK(ViewHdl
, PushButton
*);
99 //-----------------------------------------------------------------------
101 class ScTestListener
: public XSelectionChangeListener
, public UsrObject
104 FixedText
* pFixedText
;
107 ScTestListener(FixedText
* pF
);
108 virtual ~ScTestListener();
110 SMART_UNO_DECLARATION( ScTestListener
, UsrObject
);
112 virtual XInterface
* queryInterface( UsrUik
);
113 virtual XIdlClassRef
getIdlClass(void);
115 virtual void disposing(const EventObject
& Source
);
117 // XSelectionChangeListener
118 virtual void selectionChanged(const EventObject
& aEvent
);
121 //-----------------------------------------------------------------------
123 static long nBla
= 0;
125 static XCellRef xGlobalCell
;
127 //-----------------------------------------------------------------------
129 ScTestListener::ScTestListener(FixedText
* pF
) :
134 ScTestListener::~ScTestListener()
138 XInterface
* ScTestListener::queryInterface( UsrUik aUIK
)
140 if ( aUIK
== XSelectionChangeListener::getSmartUik() )
141 return (XSelectionChangeListener
*) this;
143 return UsrObject::queryInterface( aUIK
);
146 XIdlClassRef
ScTestListener::getIdlClass(void)
148 static XIdlClassRef xClass
= createStandardClass( L
"ScTestListener",
149 UsrObject::getUsrObjectIdlClass(),
150 1, XSelectionChangeListener_getReflection() );
154 void ScTestListener::disposing(const EventObject
& Source
)
158 // XSelectionChangeListener
160 void ScTestListener::selectionChanged(const EventObject
& aEvent
)
162 static USHORT nBla
= 0;
163 pFixedText
->SetText(++nBla
);
165 XInterfaceRef xInt
= aEvent
.Source
;
167 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
169 XInterfaceRef xSelInt
= xView
->getSelection();
170 if (!xSelInt
) return;
171 XCellCollectionRef xCells
= (XCellCollection
*)
172 xSelInt
->queryInterface(XCellCollection::getSmartUik());
175 String aStr
= OUStringToString( xCells
->getAddress(), CHARSET_SYSTEM
);
176 pFixedText
->SetText(aStr
);
180 //-----------------------------------------------------------------------
182 extern "C" Window
* __LOADONCALLAPI
CreateWindow( Window
*pParent
, const String
& rParam
)
184 MyWindow
*pWin
= new MyWindow( pParent
);
188 void MyFixedText::RequestHelp( const HelpEvent
& rHEvt
)
190 String aTxtStr
=GetText();
191 Size aTxtSize
=GetTextSize(aTxtStr
);
192 Point aShowPoint
= OutputToScreenPixel(Point(0,0));
193 if ( ( rHEvt
.GetMode() & HELPMODE_QUICK
) == HELPMODE_QUICK
&&
194 aTxtSize
.Width()>GetSizePixel().Width())
195 Help::ShowQuickHelp( Rectangle(aShowPoint
,aTxtSize
), aTxtStr
, QUICKHELP_TOP
|QUICKHELP_LEFT
);
197 FixedText::RequestHelp( rHEvt
);
200 MyWindow::MyWindow( Window
*pParent
) :
202 aCountField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
203 aCountButton( this ),
205 aColField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
206 aRowField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
207 aPosField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
208 aLenField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
209 aTextEdit( this, WinBits(WB_BORDER
) ),
215 aCountField
.SetPosSizePixel( Point(10,10), Size(40,20) );
216 aCountField
.SetValue(1);
218 aCountButton
.SetPosSizePixel( Point(10,40), Size(100,30) );
219 aCountButton
.SetText("hochzaehlen");
221 aTimeText
.SetPosSizePixel( Point(10,80), Size(100,20) );
223 aColField
.SetPosSizePixel( Point(10,120), Size(40,20) );
224 aRowField
.SetPosSizePixel( Point(60,120), Size(40,20) );
225 aPosField
.SetPosSizePixel( Point(10,150), Size(40,20) );
226 aLenField
.SetPosSizePixel( Point(60,150), Size(40,20) );
227 aTextEdit
.SetPosSizePixel( Point(10,180), Size(100,20) );
229 aTextButton
.SetPosSizePixel( Point(10,210), Size(100,30) );
230 aTextButton
.SetText("col/row/pos/len");
232 aBlaButton
.SetPosSizePixel( Point(10,260), Size(100,30) );
233 aBlaButton
.SetText("Bla");
235 aTabButton
.SetPosSizePixel( Point(10,310), Size(100,30) );
236 aTabButton
.SetText("Tabellen");
238 aViewButton
.SetPosSizePixel( Point(10,360), Size(100,30) );
239 aViewButton
.SetText("Pfui");
241 aCountButton
.SetClickHdl(LINK(this, MyWindow
, CountHdl
));
242 aTextButton
.SetClickHdl(LINK(this, MyWindow
, TextHdl
));
243 aBlaButton
.SetClickHdl(LINK(this, MyWindow
, BlaHdl
));
244 aTabButton
.SetClickHdl(LINK(this, MyWindow
, TabHdl
));
245 aViewButton
.SetClickHdl(LINK(this, MyWindow
, ViewHdl
));
261 //-----------------------------------------------------------------------
263 XSpreadsheetDocumentRef
lcl_GetDocument()
265 XServiceManagerRef xProv
= getGlobalServiceManager();
266 DBG_ASSERT( xProv
.is(), "Kein ServiceManager!" );
268 XServiceRegistryRef xReg
= (XServiceRegistry
*)xProv
->queryInterface(XServiceRegistry::getSmartUik());
272 Sequence
<Uik
> aIfaces( 1 );
273 aIfaces
.getArray()[0] = XModelCollection::getSmartUik();
274 XServiceProviderRef xSSI
= xProv
->getServiceProvider( L
"stardiv.desktop.ModelCollection",
275 aIfaces
, Sequence
<Uik
>() );
277 XModelCollectionRef aCollRef
= (XModelCollection
*)
278 xSSI
->newInstance()->queryInterface( XModelCollection::getSmartUik() );
279 USHORT nCount
= aCollRef
->getCount();
281 XSpreadsheetDocumentRef xModel
; // Calc-Model
282 for (USHORT nMod
=0; nMod
<nCount
&& !xModel
; nMod
++) // Calc-Doc suchen
284 XModelRef aRef
= aCollRef
->getItemByIndex( nMod
);
288 xModel
= (XSpreadsheetDocument
*) aRef
->queryInterface( XSpreadsheetDocument::getSmartUik() );
295 XInterfaceRef
lcl_GetView()
298 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
300 xView
= xDoc
->getDDELinks(); //! temporaer zum Testen !!!!!!!!!
305 //-----------------------------------------------------------------------
307 void lcl_OutputNames( const XInterfaceRef
& xSource
, // XNameAccess
308 const XSpreadsheetDocumentRef
& xDoc
,
309 USHORT nCol
, USHORT nRow
, USHORT nTab
)
316 XNameAccessRef xNames
= (XNameAccess
*)xSource
->queryInterface(XNameAccess::getSmartUik());
318 Sequence
<UString
> aSeq
= xNames
->getElementNames();
320 USHORT nLen
= (USHORT
)aSeq
.getLen();
322 XCellRef xCell
= xDoc
->getCell(aAdr
);
324 xCell
->setValue( nLen
);
327 UString
* pAry
= aSeq
.getArray();
328 for (USHORT i
=0; i
<nLen
; i
++)
330 xCell
= xDoc
->getCell(aAdr
);
332 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
334 xText
->setText( pAry
[i
] );
339 //-----------------------------------------------------------------------
341 void lcl_SetText( const XTextRef
& xText
)
343 if (!xText
.is()) return;
344 XTextCursorRef xCursor
= xText
->createTextCursor();
345 if (!xCursor
.is()) return;
346 XTextPositionRef xPos
= (XTextPosition
*)xCursor
->queryInterface(XTextPosition::getSmartUik());
347 XPropertySetRef xProp
= (XPropertySet
*)xCursor
->queryInterface(XPropertySet::getSmartUik());
348 XControlCharacterInsertableRef xControl
= (XControlCharacterInsertable
*)
349 xCursor
->queryInterface(XControlCharacterInsertable::getSmartUik());
350 XParagraphCursorRef xPara
= (XParagraphCursor
*)
351 xCursor
->queryInterface(XParagraphCursor::getSmartUik());
353 if (!xPos
.is() || !xControl
.is() || !xPara
.is()) return; // PropertySet kann fehlen
355 xText
->setText(L
"bla fasel");
356 xCursor
->gotoEnd(FALSE
);
357 xControl
->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK
);
358 xPos
->collapseToEnd();
359 xPos
->setText(L
"s\xFClz"); // zweiter Absatz
361 xCursor
->gotoStart(FALSE
);
362 xPara
->gotoEndOfParagraph(FALSE
);
363 xCursor
->goLeft(5, TRUE
); // letzte 5 Zeichen im 1. Absatz
365 xProp
->setPropertyValue(L
"Bold", UsrAny((BOOL
)TRUE
));
368 //-----------------------------------------------------------------------
372 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
375 XActionLockableRef xLock
= (XActionLockable
*)
376 xDoc
->queryInterface(XActionLockable::getSmartUik());
377 XCalculateRef xCalc
= (XCalculate
*)
378 xDoc
->queryInterface(XCalculate::getSmartUik());
380 xLock
->addActionLock(); // nicht zwischendurch painten
382 xCalc
->setAutomaticCalculation(FALSE
);
387 for (USHORT nRow
= 0; nRow
< 20; nRow
++)
390 for (USHORT nCol
= 0; nCol
< 10; nCol
++)
393 XCellRef xCell
= xDoc
->getCell(aPos
);
396 // Wert der Zelle um 1 hochzaehlen
398 double fVal
= xCell
->getValue();
400 xCell
->setValue( fVal
);
406 xCalc
->setAutomaticCalculation(TRUE
);
408 xLock
->removeActionLock();
413 void lcl_GlobalCell()
417 String aStr
= OUStringToString( xGlobalCell
->getFormula(), CHARSET_SYSTEM
);
419 xGlobalCell
->setFormula( StringToOUString( aStr
, CHARSET_SYSTEM
) );
424 void lcl_Annotations( FixedText
& aTimeText
)
426 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
433 XCellRef xCell
= xDoc
->getCell(aPos
);
436 XSheetAnnotationAnchorRef xAnchor
=
437 (XSheetAnnotationAnchor
*)xCell
->queryInterface(XSheetAnnotationAnchor::getSmartUik());
440 XSheetAnnotationRef xAnnotation
= xAnchor
->getAnnotation();
443 String aBlubb
= OUStringToString( xAnnotation
->getAuthor(), CHARSET_SYSTEM
)+
445 OUStringToString( xAnnotation
->getDate(), CHARSET_SYSTEM
);
446 aTimeText
.SetText(aBlubb
);
448 XTextRef xAnnotationText
=
449 (XText
*)xAnnotation
->queryInterface(XText::getSmartUik());
450 if ( xAnnotationText
)
452 XTextCursorRef xCursor
= xAnnotationText
->createTextCursor();
455 XTextPositionRef xPos
= (XTextPosition
*)
456 xCursor
->queryInterface(XTextPosition::getSmartUik());
457 XControlCharacterInsertableRef xControl
= (XControlCharacterInsertable
*)
458 xCursor
->queryInterface(XControlCharacterInsertable::getSmartUik());
460 if (xPos
&& xControl
)
462 ULONG nStart
= Time::GetSystemTicks();
464 xAnnotationText
->setText(L
"bla");
465 xCursor
->gotoEnd(FALSE
);
466 xCursor
->goLeft(1,TRUE
);
467 xPos
->setText(L
"ubb");
468 for (USHORT i
=0; i
<10; i
++)
470 xPos
->collapseToEnd();
471 xControl
->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK
);
472 xPos
->collapseToEnd();
473 xPos
->setText(L
"dumdi");
476 ULONG nEnd
= Time::GetSystemTicks();
477 aTimeText
.SetText(String(nEnd
-nStart
)+String(" ms"));
488 void lcl_Cursor( FixedText
& aTimeText
)
490 aTimeText
.SetText( "..." );
491 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
494 XActionLockableRef xLock
= (XActionLockable
*)
495 xDoc
->queryInterface(XActionLockable::getSmartUik());
497 xLock
->addActionLock();
503 XCellRef xCell
= xDoc
->getCell(aPos
);
506 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
507 XCellCollectionRef xColl
= (XCellCollection
*)xCell
->queryInterface(XCellCollection::getSmartUik());
508 if ( xText
&& xColl
)
510 xText
->setText(L
"bla");
511 XLineCursorRef xCursor
= xColl
->createCursor();
514 XCellCursorRef xCC
= (XCellCursor
*)xCursor
->queryInterface(XCellCursor::getSmartUik());
515 XCellRangesCursorRef xRC
= (XCellRangesCursor
*)
516 xCursor
->queryInterface(XCellRangesCursor::getSmartUik());
520 xCursor
->goDown( 1, FALSE
);
522 xColl
= xCC
->getRanges();
525 // XText ist drin, wenn's ne einzelne Zelle ist
526 xText
= (XText
*)xColl
->queryInterface(XText::getSmartUik());
529 xText
->setText(L
"fasel");
533 CellRangeAddress aSecond
;
535 aSecond
.StartColumn
= 3;
536 aSecond
.StartRow
= 4;
537 aSecond
.EndColumn
= 3;
539 xRC
->gotoUnion(aSecond
);
541 xColl
= xCC
->getRanges();
544 XPropertySetRef xProp
= (XPropertySet
*)
545 xColl
->queryInterface(XPropertySet::getSmartUik());
550 aAny
= xProp
->getPropertyValue(L
"ShadowFormat");
551 if ( aAny
.getReflection()->getName() ==
552 ShadowFormat_getReflection()->getName() )
554 //ShadowFormat* pOld = (ShadowFormat*)aAny.get();
556 aNew
.Location
= SHADOWLOCATION_BOTTOMRIGHT
;
557 aNew
.ShadowWidth
= 100;
558 aNew
.IsTransparent
= FALSE
;
559 aNew
.Color
= 0xff0000L
;
560 aAny
.set( &aNew
, aAny
.getReflection() );
561 xProp
->setPropertyValue(L
"ShadowFormat", aAny
);
564 aAny
= xProp
->getPropertyValue(L
"RotationValue");
566 xProp
->setPropertyValue(L
"RotationValue", aAny
);
568 aAny
= xProp
->getPropertyValue(L
"FontHeight");
570 xProp
->setPropertyValue(L
"FontHeight", aAny
);
572 aAny
= xProp
->getPropertyValue(L
"TransparentBackground");
574 xProp
->setPropertyValue(L
"TransparentBackground", aAny
);
576 aAny
= xProp
->getPropertyValue(L
"BackgroundColor");
577 aAny
.setUINT32(0xffff00);
578 xProp
->setPropertyValue(L
"BackgroundColor", aAny
);
580 aAny
= xProp
->getPropertyValue(L
"CellProtection");
581 if ( aAny
.getReflection()->getName() ==
582 CellProtection_getReflection()->getName() )
584 //CellProtection* pOld = (CellProtection*)aAny.get();
587 aNew
.FormulaHidden
= FALSE
;
589 aNew
.PrintHidden
= FALSE
;
590 aAny
.set( &aNew
, aAny
.getReflection() );
591 xProp
->setPropertyValue(L
"CellProtection", aAny
);
595 // XIndexAccess gibts nur wenn's mehrere sind (??!??!)
596 XIndexAccessRef xIndex
= (XIndexAccess
*)
597 xColl
->queryInterface(XIndexAccess::getSmartUik());
600 USHORT nCount
= (USHORT
)xIndex
->getCount();
601 aTimeText
.SetText( String(nCount
) );
610 xLock
->removeActionLock();
615 void lcl_Cells( FixedText
& aTimeText
)
617 aTimeText
.SetText( "..." );
618 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
622 ULONG nStart
= Time::GetSystemTicks();
624 XActionLockableRef xLock
= (XActionLockable
*)
625 xDoc
->queryInterface(XActionLockable::getSmartUik());
627 // xLock->addActionLock();
629 CellRangeAddress aRngAddr
;
631 aRngAddr
.StartColumn
= 0;
632 aRngAddr
.StartRow
= 0;
633 aRngAddr
.EndColumn
= 9;
634 aRngAddr
.EndRow
= 19;
635 XCellRangeRef xRange
= xDoc
->getCellRange(aRngAddr
);
638 XCellCollectionRef xColl
= (XCellCollection
*)
639 xRange
->queryInterface(XCellCollection::getSmartUik());
642 XEnumerationAccessRef xEnAcc
= xColl
->getCells();
645 XEnumerationRef xEnum
= xEnAcc
->getEnumeration();
648 while (xEnum
->hasMoreElements())
650 XInterfaceRef xInt
= xEnum
->nextElement();
661 ULONG nEnd
= Time::GetSystemTicks();
662 aTimeText
.SetText(String(nCount
)+String(" ")+String(nEnd
-nStart
)+String(" ms"));
666 // xLock->removeActionLock();
670 void lcl_Sheet( FixedText
& aTimeText
)
672 aTimeText
.SetText( "..." );
673 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
675 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
676 if (!xSheets
) return;
677 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
679 XNamedRef xNamed
= (XNamed
*)xSheet
->queryInterface(XNamed::getSmartUik());
682 String aName
= OUStringToString( xNamed
->getName(), CHARSET_SYSTEM
);
684 xNamed
->setName(StringToOUString( aName
, CHARSET_SYSTEM
));
686 XCellRangeRef xRange
= (XCellRange
*)xSheet
->queryInterface(XCellRange::getSmartUik());
688 XCellRef xCell
= xRange
->getCell(2,1);
690 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
692 String aBla
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
694 xText
->setText(StringToOUString( aBla
, CHARSET_SYSTEM
));
696 XColumnRowRangeRef xCRR
= (XColumnRowRange
*)xSheet
->queryInterface(XColumnRowRange::getSmartUik());
699 XTableColumnsRef xCols
= xCRR
->getColumns();
701 XPropertySetRef xCol
= xCols
->getColumnByIndex(2);
704 UINT16 nWidth
= TypeConversion::toUINT16(xCol
->getPropertyValue(L
"Width"));
705 // UINT16 nNewWidth = nWidth + 100;
706 // xCol->setPropertyValue(L"Width", UsrAny(nNewWidth));
708 xCol
->setPropertyValue(L
"OptimalWidth", UsrAny((BOOL
)TRUE
));
709 xCol
->setPropertyValue(L
"NewPage", UsrAny((BOOL
)FALSE
));
711 UsrAny aAny
= xCol
->getPropertyValue(L
"ShadowFormat");
712 if ( aAny
.getReflection()->getName() ==
713 ShadowFormat_getReflection()->getName() )
715 //ShadowFormat* pOld = (ShadowFormat*)aAny.get();
717 aNew
.Location
= SHADOWLOCATION_BOTTOMRIGHT
;
718 aNew
.ShadowWidth
= 100;
719 aNew
.IsTransparent
= FALSE
;
720 aNew
.Color
= 0xff0000L
;
721 aAny
.set( &aNew
, aAny
.getReflection() );
722 xCol
->setPropertyValue(L
"ShadowFormat", aAny
);
725 XTableRowsRef xRows
= xCRR
->getRows();
727 XPropertySetRef xRow
= xRows
->getRowByIndex(1);
730 xRows
->removeRowsByIndex( 2, 1 );
732 UINT16 nHeight
= TypeConversion::toUINT16(xRow
->getPropertyValue(L
"Height"));
733 BOOL bOptH
= TypeConversion::toBOOL(xRow
->getPropertyValue(L
"OptimalHeight"));
735 UINT16 nNewHeight
= nHeight
+ 100;
736 xRow
->setPropertyValue(L
"Height", UsrAny(nNewHeight
));
738 aTimeText
.SetText(String("W:")+String(nWidth
)+String(" H:")+String(nHeight
)+
739 String(" ")+String((USHORT
)bOptH
));
742 void lcl_Names( FixedText
& aTimeText
)
744 aTimeText
.SetText( "..." );
745 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
747 XNamedRangesRef xNames
= xDoc
->getNamedRanges();
749 XNamedRangeRef xName
= xNames
->getRangeByName(L
"bla");
751 String aCont
= OUStringToString( xName
->getContent(), CHARSET_SYSTEM
);
752 aTimeText
.SetText(aCont
);
754 XCellRangeSourceRef xSource
= (XCellRangeSource
*)
755 xName
->queryInterface(XCellRangeSource::getSmartUik());
756 if (!xSource
) return;
757 XCellRangeRef xRange
= xSource
->getReferredCells();
759 XPropertySetRef xProp
= (XPropertySet
*)xRange
->queryInterface(XPropertySet::getSmartUik());
761 UsrAny aAny
= xProp
->getPropertyValue(L
"RotationValue");
763 xProp
->setPropertyValue(L
"RotationValue", aAny
);
766 void lcl_Sheets( FixedText
& aTimeText
)
768 aTimeText
.SetText( "..." );
769 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
771 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
772 if (!xSheets
) return;
775 xSheets
->insertSheet( "hinten", 100 );
776 xSheets
->insertSheet( "vorne", 0 );
777 xSheets
->removeSheetByName( "hinten" );
778 xSheets
->removeSheetByName( "vorne" );
781 xSheets
->moveSheet(0, 1, TRUE
);
782 xSheets
->moveSheet(0, 2, FALSE
);
785 void lcl_Goal( FixedText
& aTimeText
)
787 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
789 XGoalSeekRef xGoal
= (XGoalSeek
*)xDoc
->queryInterface(XGoalSeek::getSmartUik());
793 CellAddress aFormula
; // A1
797 CellAddress aVar
; // A2
801 BOOL bFound
= xGoal
->doGoalSeek(fResult
, aFormula
, aVar
, L
"42");
805 CellAddress aOut
; // A3
810 XCellRef xCell
= xDoc
->getCell(aOut
);
812 xCell
->setValue(fResult
);
816 void lcl_TabOp( FixedText
& aTimeText
)
818 // Mehrfachoperation auf Tabelle2
819 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
822 XCellRangeRef xRange
;
823 XTableOperationRef xGoal
;
824 CellRangeAddress aRangeAddr
;
825 CellRangeAddress aFormulaRange
;
826 CellAddress aColumnCell
;
827 CellAddress aRowCell
;
828 TableOperationMode nMode
;
830 aRangeAddr
.Sheet
= 1; // c9:e11
831 aRangeAddr
.StartColumn
= 2;
832 aRangeAddr
.StartRow
= 8;
833 aRangeAddr
.EndColumn
= 4;
834 aRangeAddr
.EndRow
= 10;
835 aFormulaRange
.Sheet
= 1; // c6:c7
836 aFormulaRange
.StartColumn
= 2;
837 aFormulaRange
.StartRow
= 5;
838 aFormulaRange
.EndColumn
= 2;
839 aFormulaRange
.EndRow
= 6;
840 aColumnCell
.Sheet
= 0; // nicht benutzt
841 aColumnCell
.Column
= 0;
843 aRowCell
.Sheet
= 1; // c5
848 xRange
= xDoc
->getCellRange(aRangeAddr
);
850 xGoal
= (XTableOperation
*)xRange
->queryInterface(XTableOperation::getSmartUik());
852 xGoal
->setTableOperation( nMode
, aFormulaRange
, aColumnCell
, aRowCell
);
854 aRangeAddr
.Sheet
= 1; // b19:d21
855 aRangeAddr
.StartColumn
= 1;
856 aRangeAddr
.StartRow
= 18;
857 aRangeAddr
.EndColumn
= 3;
858 aRangeAddr
.EndRow
= 20;
859 aFormulaRange
.Sheet
= 1; // c16:d16
860 aFormulaRange
.StartColumn
= 2;
861 aFormulaRange
.StartRow
= 15;
862 aFormulaRange
.EndColumn
= 3;
863 aFormulaRange
.EndRow
= 15;
864 aColumnCell
.Sheet
= 1; // b16
865 aColumnCell
.Column
= 1;
866 aColumnCell
.Row
= 15;
867 aRowCell
.Sheet
= 0; // nicht benutzt
870 nMode
= TABLEOP_COLUMN
;
872 xRange
= xDoc
->getCellRange(aRangeAddr
);
874 xGoal
= (XTableOperation
*)xRange
->queryInterface(XTableOperation::getSmartUik());
876 xGoal
->setTableOperation( nMode
, aFormulaRange
, aColumnCell
, aRowCell
);
878 aRangeAddr
.Sheet
= 1; // b29:e32
879 aRangeAddr
.StartColumn
= 1;
880 aRangeAddr
.StartRow
= 28;
881 aRangeAddr
.EndColumn
= 4;
882 aRangeAddr
.EndRow
= 31;
883 aFormulaRange
.Sheet
= 1; // c27:c27
884 aFormulaRange
.StartColumn
= 2;
885 aFormulaRange
.StartRow
= 26;
886 aFormulaRange
.EndColumn
= 2;
887 aFormulaRange
.EndRow
= 26;
888 aColumnCell
.Sheet
= 1; // c25
889 aColumnCell
.Column
= 2;
890 aColumnCell
.Row
= 24;
891 aRowCell
.Sheet
= 1; // c26
894 nMode
= TABLEOP_BOTH
;
896 xRange
= xDoc
->getCellRange(aRangeAddr
);
898 xGoal
= (XTableOperation
*)xRange
->queryInterface(XTableOperation::getSmartUik());
900 xGoal
->setTableOperation( nMode
, aFormulaRange
, aColumnCell
, aRowCell
);
903 void lcl_Fill( FixedText
& aTimeText
)
905 XInterfaceRef xInt
= lcl_GetView();
907 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
910 XInterfaceRef xSelInt
= xView
->getSelection();
911 if (!xSelInt
) return;
913 XCellSeriesRef xFill
= (XCellSeries
*)xSelInt
->queryInterface(XCellSeries::getSmartUik());
916 // xFill->fillAuto( FILL_DIRECTION_TO_BOTTOM, 2 );
918 xFill
->fillSeries( FILL_DIRECTION_TO_LEFT
, FILL_MODE_GROWTH
, FILL_DATE_DAY
,
922 void lcl_Audi( FixedText
& aTimeText
)
924 aTimeText
.SetText( "..." );
925 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
927 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
928 if (!xSheets
) return;
929 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
932 XSheetAuditingRef xAudi
= (XSheetAuditing
*)xSheet
->queryInterface(XSheetAuditing::getSmartUik());
935 CellAddress aPosition
;
937 aPosition
.Column
= 0;
939 xAudi
->showDependents(aPosition
);
942 void lcl_Consoli( FixedText
& aTimeText
)
944 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
946 XConsolidationRef xCons
= (XConsolidation
*)xDoc
->queryInterface(XConsolidation::getSmartUik());
948 XConsolidationDescriptorRef xDesc
= xCons
->createConsolidationDescriptor(FALSE
);
950 xDesc
->setFunction(SUMMARY_COUNTNUMS
);
951 xCons
->consolidate(xDesc
);
954 void lcl_Sort( FixedText
& aTimeText
)
956 XInterfaceRef xInt
= lcl_GetView();
958 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
960 XInterfaceRef xSelInt
= xView
->getSelection();
961 if (!xSelInt
) return;
962 XSortableRef xSort
= (XSortable
*)xSelInt
->queryInterface(XSortable::getSmartUik());
964 XSortDescriptorRef xDesc
= xSort
->createSortDescriptor(FALSE
);
966 Sequence
<SortField
> aFields
= xDesc
->getSortFields();
967 if (aFields
.getLen())
970 SortField
* pAry
= aFields
.getArray();
972 pAry
[0].Ascending
= !pAry
[0].Ascending
;
974 else // neue Sequence, 1. Spalte aufsteigend
976 aFields
= Sequence
<SortField
>(1);
977 SortField
* pAry
= aFields
.getArray();
980 pAry
[0].Ascending
= TRUE
;
981 pAry
[0].Type
= SORT_FIELD_AUTOMATIC
;
983 xDesc
->setSortFields(aFields
);
985 XTableSortDescriptorRef xTableSort
= (XTableSortDescriptor
*)
986 xDesc
->queryInterface(XTableSortDescriptor::getSmartUik());
987 if (!xTableSort
) return;
992 xTableSort
->setUseOutputPosition(TRUE
);
993 xTableSort
->setOutputPosition(aOutPos
);
995 XPropertySetRef xPropSet
= (XPropertySet
*)
996 xDesc
->queryInterface(XPropertySet::getSmartUik());
997 if (!xPropSet
) return;
998 xPropSet
->setPropertyValue(L
"IncludeFormats", UsrAny((BOOL
)FALSE
));
1003 void lcl_Filter( FixedText
& aTimeText
)
1005 aTimeText
.SetText("...");
1007 XInterfaceRef xInt
= lcl_GetView();
1009 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1011 XInterfaceRef xSelInt
= xView
->getSelection();
1012 if (!xSelInt
) return;
1013 XFilterableRef xFilter
= (XFilterable
*)xSelInt
->queryInterface(XFilterable::getSmartUik());
1014 if (!xFilter
) return;
1017 XTableFilterDescriptorRef xDesc
= xFilter
->createFilterDescriptor(FALSE
);
1019 Sequence
<TableFilterField
> aFields
= xDesc
->getFilterFields();
1020 if (aFields
.getLen())
1022 // 1.Feld zwischen 1. und 2. Spalte toggeln
1023 TableFilterField
* pAry
= aFields
.getArray();
1025 pAry
[0].Field
= pAry
[0].Field
? 0 : 1;
1027 xDesc
->setFilterFields(aFields
);
1028 xFilter
->filter(xDesc
);
1031 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1033 CellRangeAddress aAddress
;
1035 aAddress
.StartColumn
= 0;
1036 aAddress
.StartRow
= 0;
1037 aAddress
.EndColumn
= 1;
1038 aAddress
.EndRow
= 2;
1039 XCellRangeRef xRange
= xDoc
->getCellRange(aAddress
);
1040 if (!xRange
) return;
1041 XAdvancedFilterSourceRef xSource
= (XAdvancedFilterSource
*)
1042 xRange
->queryInterface(XAdvancedFilterSource::getSmartUik());
1043 if (!xSource
) return;
1045 XTableFilterDescriptorRef xDesc
= xSource
->createAdvancedFilter(xFilter
);
1048 aTimeText
.SetText("kein Filter");
1051 aTimeText
.SetText("Filter gefunden");
1052 xFilter
->filter(xDesc
);
1055 void lcl_AutoFilter( FixedText
& aTimeText
)
1057 XInterfaceRef xInt
= lcl_GetView();
1059 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1061 XInterfaceRef xSelInt
= xView
->getSelection();
1062 if (!xSelInt
) return;
1063 XFilterableRef xFilter
= (XFilterable
*)xSelInt
->queryInterface(XFilterable::getSmartUik());
1064 if (!xFilter
) return;
1066 BOOL bAuto
= xFilter
->getAutoFilter();
1067 xFilter
->setAutoFilter(!bAuto
);
1070 void lcl_Merge( FixedText
& aTimeText
)
1072 static BOOL bMerged
= FALSE
;
1074 XInterfaceRef xInt
= lcl_GetView();
1076 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1078 XInterfaceRef xSelInt
= xView
->getSelection();
1079 if (!xSelInt
) return;
1080 XMergeableRef xMerge
= (XMergeable
*)xSelInt
->queryInterface(XMergeable::getSmartUik());
1081 if (!xMerge
) return;
1084 xMerge
->unmergeCells();
1086 xMerge
->mergeCells();
1090 void lcl_Outline( FixedText
& aTimeText
)
1092 static BOOL bOutline
= FALSE
;
1094 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1096 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1097 if (!xSheets
) return;
1098 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
1099 if (!xSheet
) return;
1100 XSheetOutlineRef xOut
= (XSheetOutline
*)xSheet
->queryInterface(XSheetOutline::getSmartUik());
1103 XInterfaceRef xInt
= lcl_GetView();
1105 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1107 XInterfaceRef xSelInt
= xView
->getSelection();
1108 if (!xSelInt
) return;
1109 XAddressableCellRangeRef xRange
= (XAddressableCellRange
*)
1110 xSelInt
->queryInterface(XAddressableCellRange::getSmartUik());
1111 if (!xRange
) return;
1112 CellRangeAddress aRange
= xRange
->getRangeAddress();
1115 xOut
->showDetail( aRange
);
1117 xOut
->hideDetail( aRange
);
1119 bOutline
= !bOutline
;
1122 void lcl_Bla( FixedText
& aTimeText
)
1124 aTimeText
.SetText("...");
1126 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1128 XActionLockableRef xLock
= (XActionLockable
*)xDoc
->queryInterface(XActionLockable::getSmartUik());
1130 xLock
->addActionLock();
1131 xLock
->addActionLock();
1132 USHORT nCount
= xLock
->resetActionLocks(); // sollte 2 sein
1133 String aBla
= nCount
;
1134 xLock
->setActionLocks(nCount
);
1135 xLock
->removeActionLock();
1136 xLock
->removeActionLock();
1138 aBla
+= '/'; aBla
+= xLock
->resetActionLocks(); // sollte 0 sein
1140 aTimeText
.SetText(aBla
);
1143 void lcl_CellCursor( FixedText
& aTimeText
)
1145 static int nCursorCount
= 0;
1147 XInterfaceRef xInt
= lcl_GetView();
1149 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1151 XInterfaceRef xSelInt
= xView
->getSelection();
1152 if (!xSelInt
) return;
1153 XCellCollectionRef xColl
= (XCellCollection
*)xSelInt
->queryInterface(XCellCollection::getSmartUik());
1156 XLineCursorRef xCursor
= xColl
->createCursor();
1157 if (!xCursor
) return;
1158 XCellCursorRef xCC
= (XCellCursor
*)xCursor
->queryInterface(XCellCursor::getSmartUik());
1160 XCellRangesCursorRef xCRC
= (XCellRangesCursor
*)xCursor
->queryInterface(XCellRangesCursor::getSmartUik());
1162 XCellRangeCursorRef xCR
= (XCellRangeCursor
*)xCursor
->queryInterface(XCellRangeCursor::getSmartUik());
1164 XCellContentCursorRef xCCC
= (XCellContentCursor
*)xCursor
->queryInterface(XCellContentCursor::getSmartUik());
1166 XFormulaCursorRef xFC
= (XFormulaCursor
*)xCursor
->queryInterface(XFormulaCursor::getSmartUik());
1170 aPos
.Sheet
= 0; // ignored
1174 switch (nCursorCount
++)
1177 xFC
->gotoDependents(FALSE
);
1180 xFC
->gotoDependents(TRUE
);
1183 xFC
->gotoPrecedents(FALSE
);
1186 xFC
->gotoPrecedents(TRUE
);
1192 XCellCollectionRef xNew
= xCC
->getRanges();
1194 xView
->select( xNew
);
1197 void lcl_Notes( FixedText
& aTimeText
)
1199 aTimeText
.SetText( "..." );
1200 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1202 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1203 if (!xSheets
) return;
1204 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
1205 if (!xSheet
) return;
1207 XSheetAnnotationsRef xNotes
= xSheet
->getAnnotations();
1208 if (!xNotes
) return;
1209 XIndexAccessRef xNIndex
= (XIndexAccess
*)xNotes
->queryInterface(XIndexAccess::getSmartUik());
1210 if (!xNIndex
) return;
1216 xNotes
->addAnnotation( L
"neu", aPos
);
1218 ULONG nCount
= xNIndex
->getCount();
1219 for (ULONG i
=0; i
<nCount
; i
++)
1221 XSheetAnnotationRef xAnn
= xNotes
->getAnnotationByIndex((UINT16
)i
);
1222 XTextRef xText
= (XText
*)xAnn
->queryInterface(XText::getSmartUik());
1225 String aStr
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
1227 xText
->setText(StringToOUString( aStr
, CHARSET_SYSTEM
));
1232 void lcl_Scenario( FixedText
& aTimeText
)
1234 aTimeText
.SetText( "..." );
1235 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1237 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1238 if (!xSheets
) return;
1239 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
1240 if (!xSheet
) return;
1242 XScenariosRef xColl
= xSheet
->getScenarios();
1245 Sequence
<CellRangeAddress
> aRanges(2);
1246 CellRangeAddress
* pAry
= aRanges
.getArray();
1249 pAry
[0].StartColumn
= 0;
1250 pAry
[0].StartRow
= 0;
1251 pAry
[0].EndColumn
= 1;
1254 pAry
[1].StartColumn
= 3;
1255 pAry
[1].StartRow
= 3;
1256 pAry
[1].EndColumn
= 4;
1259 xColl
->addScenario( aRanges
, L
"bla", L
"bla blubb" );
1261 XIndexAccessRef xIndex
= (XIndexAccess
*)xColl
->queryInterface(XIndexAccess::getSmartUik());
1262 if (!xIndex
) return;
1263 ULONG nCount
= xIndex
->getCount();
1264 aTimeText
.SetText( nCount
);
1266 XScenarioRef xScen
= xColl
->getScenarioByIndex(0);
1269 aRanges
= Sequence
<CellRangeAddress
>(1);
1270 pAry
= aRanges
.getArray();
1273 pAry
[0].StartColumn
= 6;
1274 pAry
[0].StartRow
= 6;
1275 pAry
[0].EndColumn
= 7;
1278 xScen
->addRanges( aRanges
);
1280 XTableSheetRef xSh2
= xSheets
->getSheetByIndex(1);
1283 xSh2
->setVisible( TRUE
);
1284 xSh2
->setVisible( FALSE
);
1287 void lcl_Formula( FixedText
& aTimeText
)
1289 aTimeText
.SetText("...");
1291 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1297 XCellRef xCell
= xDoc
->getCell(aPos
);
1300 // String aStr = OUStringToString( xCell->getFormula(), CHARSET_SYSTEM );
1301 // aTimeText.SetText(aStr);
1303 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1305 String aStr
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
1306 aTimeText
.SetText(aStr
);
1309 void lcl_DBRange( FixedText
& aTimeText
) // 23
1311 aTimeText
.SetText("...");
1313 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1315 XDatabaseRangesRef xDBs
= xDoc
->getDatabaseRanges();
1318 CellRangeAddress aRange
;
1320 aRange
.StartColumn
= 1;
1321 aRange
.StartRow
= 1;
1322 aRange
.EndColumn
= 3;
1325 xDBs
->addRange( L
"blubb", aRange
);
1327 xDBs
->removeRangeByName( L
"gaga" );
1329 XDatabaseRangeRef xDB
= xDBs
->getRangeByName( L
"blubb" );
1332 String aName
= OUStringToString( xDB
->getName(), CHARSET_SYSTEM
);
1333 aTimeText
.SetText(aName
);
1335 xDB
->setName( L
"gaga" );
1337 CellRangeAddress aDBRange
= xDB
->getDataArea();
1339 xDB
->setDataArea(aDBRange
);
1342 void lcl_FillTab( FixedText
& aTimeText
) // 24
1344 aTimeText
.SetText("...");
1346 XInterfaceRef xInt
= lcl_GetView();
1348 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1350 XInterfaceRef xSelInt
= xView
->getSelection();
1351 if (!xSelInt
) return;
1353 XCellRangesRef xRanges
= (XCellRanges
*)xSelInt
->queryInterface(XCellRanges::getSmartUik());
1354 XIndexAccessRef xIndex
= (XIndexAccess
*)xSelInt
->queryInterface(XIndexAccess::getSmartUik());
1355 if (!xRanges
|| !xIndex
) return;
1357 ULONG nCount
= xIndex
->getCount();
1358 aTimeText
.SetText(nCount
);
1361 void lcl_Listener( FixedText
& aTimeText
) // 25
1363 XInterfaceRef xInt
= lcl_GetView();
1365 XStarCalcViewRef xView
= (XStarCalcView
*)xInt
->queryInterface(XStarCalcView::getSmartUik());
1367 xView
->addSelectionChangeListener( new ScTestListener(&aTimeText
) );
1370 void lcl_CellAttrib( FixedText
& aTimeText
) // 26
1372 XInterfaceRef xInt
= lcl_GetView();
1374 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1376 XInterfaceRef xSelInt
= xView
->getSelection();
1377 if (!xSelInt
) return;
1378 XTextRef xText
= (XText
*)xSelInt
->queryInterface(XText::getSmartUik());
1381 XTextCursorRef xCursor
= xText
->createTextCursor();
1382 if (!xCursor
) return;
1384 XTextPositionRef xPos
= (XTextPosition
*)xCursor
->queryInterface(XTextPosition::getSmartUik());
1385 XPropertySetRef xProp
= (XPropertySet
*)xCursor
->queryInterface(XPropertySet::getSmartUik());
1386 XParagraphCursorRef xPar
= (XParagraphCursor
*)xCursor
->queryInterface(XParagraphCursor::getSmartUik());
1387 if (!xPos
|| !xProp
|| !xPar
) return;
1389 xCursor
->gotoStart(FALSE
);
1390 xCursor
->goRight(1,FALSE
);
1391 xCursor
->goRight(1,TRUE
);
1393 UsrAny aAny
= xProp
->getPropertyValue(L
"FontHeight");
1394 UINT32 nOld
= aAny
.getUINT32();
1395 aAny
.setUINT32(nOld
*11/10);
1396 xProp
->setPropertyValue(L
"FontHeight", aAny
);
1398 xPos
->collapseToEnd();
1399 xCursor
->goRight(1,TRUE
);
1401 xProp
->setPropertyValue(L
"Bold", UsrAny((BOOL
)TRUE
));
1403 xPos
->setText(L
"x");
1405 xPos
->collapseToEnd();
1406 xPar
->gotoNextParagraph(FALSE
,TRUE
);
1407 xProp
->setPropertyValue(L
"Italic", UsrAny((BOOL
)TRUE
));
1408 xProp
->setPropertyValue(L
"Underlined", UsrAny((BOOL
)TRUE
));
1411 void lcl_Styles( FixedText
& aTimeText
) // 27
1413 aTimeText
.SetText("...");
1414 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1416 XStyleFamiliesRef xFamilies
= xDoc
->getStyleFamilies();
1417 if (!xFamilies
) return;
1418 XStyleFamilyRef xFamily
= xFamilies
->getStyleFamilyByType( STYLE_FAMILY_CELL
);
1419 // XStyleFamilyRef xFamily = xFamilies->getStyleFamilyByType( STYLE_FAMILY_PAGE );
1420 if (!xFamily
) return;
1421 long nCount
= xFamily
->getCount();
1422 aTimeText
.SetText(nCount
);
1424 XStyleRef xStyle
= xFamily
->getStyleByName(L
"rot");
1425 if (!xStyle
) return;
1426 // XPropertySetRef xProp = (XPropertySet*)xStyle->queryInterface(XPropertySet::getSmartUik());
1427 // if (!xProp) return;
1429 XStyleRef xNew
= xFamily
->addStyle( L
"gaga", xStyle
);
1431 XPropertySetRef xProp
= (XPropertySet
*)xNew
->queryInterface(XPropertySet::getSmartUik());
1435 aAny
= xProp
->getPropertyValue(L
"TransparentBackground");
1436 aAny
.setBOOL(FALSE
);
1437 xProp
->setPropertyValue(L
"TransparentBackground", aAny
);
1438 aAny
= xProp
->getPropertyValue(L
"BackgroundColor");
1439 aAny
.setUINT32(0xffff00);
1440 xProp
->setPropertyValue(L
"BackgroundColor", aAny
);
1442 xFamily
->removeStyle( L
"rot" );
1445 void lcl_PageStyle( FixedText
& aTimeText
) // 28
1447 aTimeText
.SetText("...");
1449 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1451 XStyleFamiliesRef xFamilies
= xDoc
->getStyleFamilies();
1452 if (!xFamilies
) return;
1453 XStyleFamilyRef xFamily
= xFamilies
->getStyleFamilyByType( STYLE_FAMILY_PAGE
);
1454 if (!xFamily
) return;
1455 XStyleRef xStyle
= xFamily
->getStyleByName(L
"Standard");
1456 if (!xStyle
) return;
1457 XPropertySetRef xProp
= (XPropertySet
*)xStyle
->queryInterface(XPropertySet::getSmartUik());
1461 aAny
= xProp
->getPropertyValue(L
"RightPageHeaderContent");
1464 // if ( !XHeaderFooterContent_getReflection()->equals(*aAny.getReflection()) )
1467 XHeaderFooterContentRef
* pxContent
= (XHeaderFooterContentRef
*)aAny
.get();
1468 if (!pxContent
|| !pxContent
->is()) return;
1470 XTextRef xText
= (*pxContent
)->getCenterText();
1473 String aVal
= OUStringToString(xText
->getText(), CHARSET_SYSTEM
);
1474 aTimeText
.SetText(aVal
);
1476 // xText->setText(L"Bla fasel s\xFClz");
1479 xProp
->setPropertyValue(L
"RightPageHeaderContent", aAny
);
1482 void lcl_AutoForm( FixedText
& aTimeText
) // 29
1484 XInterfaceRef xInt
= lcl_GetView();
1488 //! Test - AutoFormat muss von der App kommen
1489 XStarCalcViewRef xView
= (XStarCalcView
*)xInt
->queryInterface(XStarCalcView::getSmartUik());
1491 XTableAutoFormatsRef xFormats
= xView
->getTableAutoFormats();
1492 if (!xFormats
) return;
1495 XTableAutoFormatsRef xFormats
;
1497 XTableAutoFormatRef xFormat
= xFormats
->getAutoFormatByName(L
"gaga");
1498 if (!xFormat
) return;
1499 XPropertySetRef xProp
= (XPropertySet
*)xFormat
->queryInterface(XPropertySet::getSmartUik());
1502 BOOL bVal
= TypeConversion::toBOOL(xProp
->getPropertyValue(L
"IncludeBackground"));
1503 xProp
->setPropertyValue(L
"IncludeBackground", UsrAny(BOOL(!bVal
)));
1505 XNamedRef xNamed
= (XNamed
*)xFormat
->queryInterface(XNamed::getSmartUik());
1506 if (!xNamed
) return;
1507 xNamed
->setName(L
"zzz");
1509 xFormats
->addAutoFormat(L
"gaga");
1510 XTableAutoFormatRef xNew
= xFormats
->getAutoFormatByName(L
"gaga");
1513 for (USHORT i
=0; i
<16; i
++)
1515 XPropertySetRef xNewProp
= xNew
->getFieldByIndex(i
);
1516 if (!xNewProp
) return;
1518 xNewProp
->setPropertyValue(L
"TransparentBackground", UsrAny(BOOL(FALSE
)));
1519 UINT32 nColor
= 0x111100 * i
;
1520 xNewProp
->setPropertyValue(L
"BackgroundColor", UsrAny(nColor
));
1524 void lcl_Pivot( FixedText
& aTimeText
) // 30
1526 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1529 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1530 if (!xSheets
) return;
1531 XIndexAccessRef xInd
= (XIndexAccess
*)xSheets
->queryInterface(XIndexAccess::getSmartUik());
1533 USHORT nCount
= (USHORT
)xInd
->getCount();
1535 for (USHORT nTab
=0; nTab
<nCount
; nTab
++)
1537 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(nTab
);
1538 if (!xSheet
) return;
1539 XDataPilotTablesRef xPivots
= xSheet
->getDataPilotTables();
1540 if (!xPivots
) return;
1541 lcl_OutputNames( xPivots
, xDoc
, nTab
,0,0 );
1542 XIndexAccessRef xPInd
= (XIndexAccess
*)xPivots
->queryInterface(XIndexAccess::getSmartUik());
1544 USHORT nPCount
= (USHORT
)xPInd
->getCount();
1545 for (USHORT nP
=0; nP
<nPCount
; nP
++)
1547 XDataPilotTableRef xTable
= xPivots
->getTableByIndex(nP
);
1548 if (!xTable
) return;
1550 // xTable->refreshTable();
1552 XDataPilotDescriptorRef xDesc
= (XDataPilotDescriptor
*)
1553 xTable
->queryInterface(XDataPilotDescriptor::getSmartUik());
1555 CellRangeAddress aSource
= xDesc
->getSourceRange();
1557 xDesc
->setSourceRange(aSource
);
1559 CellRangeAddress aAddr
= xTable
->getOutputRange();
1560 XCellRangeRef xRange
= xDoc
->getCellRange(aAddr
);
1561 if (!xRange
) return;
1562 XPropertySetRef xProp
= (XPropertySet
*)xRange
->queryInterface(XPropertySet::getSmartUik());
1564 xProp
->setPropertyValue(L
"TransparentBackground", UsrAny(BOOL(FALSE
)));
1565 xProp
->setPropertyValue(L
"BackgroundColor", UsrAny((UINT32
)0x00FF00));
1570 IMPL_LINK(MyWindow
, CountHdl
, PushButton
*, EMPTYARG
)
1574 long nCount
= aCountField
.GetValue();
1578 ULONG nStart
= Time::GetSystemTicks();
1579 for (long i
=0; i
<nCount
; i
++)
1581 ULONG nEnd
= Time::GetSystemTicks();
1582 aTimeText
.SetText(String(nCount
)+String(" x Count: ")+String(nEnd
-nStart
)+String(" ms"));
1586 long nCount
= aCountField
.GetValue();
1591 ULONG nStart
= Time::GetSystemTicks();
1593 ULONG nEnd
= Time::GetSystemTicks();
1594 aTimeText
.SetText(String("Count: ")+String(nEnd
-nStart
)+String(" ms"));
1601 lcl_Annotations(aTimeText
);
1604 lcl_Cursor(aTimeText
);
1607 lcl_Cells(aTimeText
);
1610 lcl_Sheet(aTimeText
);
1613 lcl_Names(aTimeText
);
1616 lcl_Sheets(aTimeText
);
1619 lcl_Goal(aTimeText
);
1622 lcl_TabOp(aTimeText
);
1625 lcl_Fill(aTimeText
);
1628 lcl_Audi(aTimeText
);
1631 lcl_Consoli(aTimeText
);
1634 lcl_Sort(aTimeText
);
1637 lcl_Filter(aTimeText
);
1640 lcl_AutoFilter(aTimeText
);
1643 lcl_Merge(aTimeText
);
1646 lcl_Outline(aTimeText
);
1652 lcl_CellCursor(aTimeText
);
1655 lcl_Notes(aTimeText
);
1658 lcl_Scenario(aTimeText
);
1661 lcl_Formula(aTimeText
);
1664 lcl_DBRange(aTimeText
);
1667 lcl_FillTab(aTimeText
);
1670 lcl_Listener(aTimeText
);
1673 lcl_CellAttrib(aTimeText
);
1676 lcl_Styles(aTimeText
);
1679 lcl_PageStyle(aTimeText
);
1682 lcl_AutoForm(aTimeText
);
1685 lcl_Pivot(aTimeText
);
1694 //-----------------------------------------------------------------------
1696 IMPL_LINK(MyWindow
, TextHdl
, PushButton
*, EMPTYARG
)
1699 USHORT nCol
= (USHORT
)aColField
.GetValue();
1700 USHORT nRow
= (USHORT
)aRowField
.GetValue();
1701 USHORT nPos
= (USHORT
)aPosField
.GetValue();
1702 USHORT nLen
= (USHORT
)aLenField
.GetValue();
1703 String aStr
= aTextEdit
.GetText();
1705 aTimeText
.SetText("...");
1707 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1714 XCellRef xCell
= xDoc
->getCell(aPos
);
1717 XTextRef xCellText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1720 XTextCursorRef xCursor
= xCellText
->createTextCursor();
1723 XTextPositionRef xPos
= (XTextPosition
*)
1724 xCursor
->queryInterface(XTextPosition::getSmartUik());
1725 XControlCharacterInsertableRef xControl
= (XControlCharacterInsertable
*)
1726 xCursor
->queryInterface(XControlCharacterInsertable::getSmartUik());
1728 if (xPos
&& xControl
)
1730 xCursor
->gotoStart(FALSE
);
1731 xCursor
->goRight(11,TRUE
);
1732 String aVal
= OUStringToString( xPos
->getText(), CHARSET_SYSTEM
);
1733 aTimeText
.SetText(aVal
);
1743 //-----------------------------------------------------------------------
1745 IMPL_LINK(MyWindow
, BlaHdl
, PushButton
*, EMPTYARG
)
1747 aTimeText
.SetText("...");
1749 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1756 XCellRef xCell
= xDoc
->getCell(aPos
);
1759 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1760 XFieldContainerRef xCont
= (XFieldContainer
*)
1761 xCell
->queryInterface(XFieldContainer::getSmartUik());
1763 if ( xText
&& xCont
)
1765 XFieldTypesRef xTypes
= xCont
->getFieldTypes();
1768 XTextFieldTypeRef xType
= xTypes
->getFieldType( FIELDTYPE_INTERNET
);
1769 XTextCursorRef xCursor
= xText
->createTextCursor();
1770 if ( xCursor
&& xType
)
1774 XTextPositionRef xPos
= (XTextPosition
*)
1775 xCursor
->queryInterface(XTextPosition::getSmartUik());
1778 xCursor
->gotoEnd(FALSE
);
1779 XTextFieldRef xField
= xTypes
->insertTextField( xType
, xPos
);
1782 // Eigenschaften setzen
1783 XPropertySetRef xProp
= (XPropertySet
*)xField
->
1784 queryInterface(XPropertySet::getSmartUik());
1787 xProp
->setPropertyValue(L
"URL",
1788 UsrAny(String("http://www.mopo.de/")));
1789 xProp
->setPropertyValue(L
"Representation",
1790 UsrAny(String("ein Hyperlink")));
1796 // letztes Feld loeschen
1797 XIndexAccessRef xIndex
= (XIndexAccess
*)
1798 xType
->queryInterface(XIndexAccess::getSmartUik());
1802 ULONG nCount
= xIndex
->getCount();
1803 for (ULONG i
=0; i
<nCount
; i
++)
1805 XInterfaceRef xInt
= xIndex
->getElementByIndex(i
);
1808 XPropertySetRef xProp
= (XPropertySet
*)xInt
->
1809 queryInterface(XPropertySet::getSmartUik());
1812 if (aBla
.Len()) aBla
+= ',';
1813 aBla
+= OUStringToString(
1814 TypeConversion::toString(
1815 xProp
->getPropertyValue(L
"URL") ),
1818 if ( i
+1 == nCount
) // letztes
1820 XTextFieldRef xField
= (XTextField
*)xInt
->
1821 queryInterface(XTextField::getSmartUik());
1823 xTypes
->removeTextField(xField
);
1827 aTimeText
.SetText(aBla
);
1834 xGlobalCell
= xCell
;
1840 //-----------------------------------------------------------------------
1842 IMPL_LINK(MyWindow
, TabHdl
, PushButton
*, EMPTYARG
)
1846 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1849 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1852 XIndexAccessRef xIndex
= (XIndexAccess
*)xSheets
->queryInterface(XIndexAccess::getSmartUik());
1855 USHORT nCount
= (USHORT
) xIndex
->getCount();
1856 for (USHORT nTab
=0; nTab
<nCount
; nTab
++)
1858 XInterfaceRef xInt
= xIndex
->getElementByIndex(nTab
);
1861 XNamedRef xNamed
= (XNamed
*)xInt
->queryInterface(XNamed::getSmartUik());
1866 aResult
+= OUStringToString( xNamed
->getName(), CHARSET_SYSTEM
);
1877 XEnumerationAccessRef xEAcc
= (XEnumerationAccess
*)
1878 xSheets
->queryInterface(XEnumerationAccess::getSmartUik());
1881 XEnumerationRef xEnum
= xEAcc
->getEnumeration();
1884 while (xEnum
->hasMoreElements())
1886 XInterfaceRef xInt
= xEnum
->nextElement();
1889 XNamedRef xNamed
= (XNamed
*)xInt
->queryInterface(XNamed::getSmartUik());
1892 UString aName
= xNamed
->getName();
1893 XCellRef xCell
= xDoc
->getCell(aPos
);
1896 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1897 xText
->setText( aName
);
1908 aTimeText
.SetText(aResult
);
1913 //-----------------------------------------------------------------------
1915 void lcl_FillCells(XCellCollectionRef xColl
)
1917 XEnumerationAccessRef xEnAcc
= xColl
->getCells();
1918 if (!xEnAcc
) return;
1919 XEnumerationRef xEnum
= xEnAcc
->getEnumeration();
1921 while (xEnum
->hasMoreElements())
1923 XInterfaceRef xInt
= xEnum
->nextElement();
1926 XCellRef xCell
= (XCell
*)xInt
->queryInterface(XCell::getSmartUik());
1929 xCell
->setValue(42.0);
1935 IMPL_LINK(MyWindow
, ViewHdl
, PushButton
*, EMPTYARG
)
1937 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1938 XInterfaceRef xInt
= lcl_GetView();
1939 if (!xInt
) return 0;
1940 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1941 if (!xView
) return 0;
1943 XInterfaceRef xSelInt
= xView
->getSelection();
1944 if (!xSelInt
) return 0;
1947 XPropertySetRef xProp
= (XPropertySet
*)xSelInt
->queryInterface(XPropertySet::getSmartUik());
1952 aAny
= xProp
->getPropertyValue(L
"TransparentBackground");
1953 aAny
.setBOOL(FALSE
);
1954 xProp
->setPropertyValue(L
"TransparentBackground", aAny
);
1956 aAny
= xProp
->getPropertyValue(L
"BackgroundColor");
1957 aAny
.setUINT32(0xffff00);
1958 xProp
->setPropertyValue(L
"BackgroundColor", aAny
);
1960 XIndentRef xInd
= (XIndent
*)xSelInt
->queryInterface(XIndent::getSmartUik());
1963 xInd
->incrementIndent();
1967 XAutoFormattableRef xAuto
= (XAutoFormattable
*)xSelInt
->
1968 queryInterface(XAutoFormattable::getSmartUik());
1970 xAuto
->applyAutoFormat( L
"gaga" );
1972 XFormulaArrayRef xArr
= (XFormulaArray
*)xSelInt
->queryInterface(XFormulaArray::getSmartUik());
1975 // xArr->setFormulaArray( "123" );
1976 String aFormula
= OUStringToString( xArr
->getFormulaArray(), CHARSET_SYSTEM
);
1977 aTimeText
.SetText(aFormula
);
1980 aTimeText
.SetText("...");
1982 XTextRef xText
= (XText
*)xSelInt
->queryInterface(XText::getSmartUik());
1985 String aStr
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
1987 xText
->setText(StringToOUString(aStr
, CHARSET_SYSTEM
));
1990 // Zelle selektieren
1999 XCellRef xCell
= xDoc
->getCell(aPos
);
2001 xView
->select( xCell
);
2005 XPrintableRef xPrint
= (XPrintable
*)xInt
->queryInterface(XPrintable::getSmartUik());
2006 String aName
= OUStringToString( xPrint
->getPrinterName(), CHARSET_SYSTEM
);
2007 // aTimeText.SetText(aName);
2009 xPrint
->setPrinterName(L
"HP5_2");
2010 // xPrint->setPrinterName(L"blubb");
2012 // XPropertySetRef xOptions;
2013 // xPrint->print(xOptions);
2015 /* XViewPaneRef xPane = (XViewPane*)xInt->queryInterface(XViewPane::getSmartUik());
2016 if (!xPane) return 0;
2017 xPane->setScrollRow( 2 );
2020 XCellRangeSourceRef xSrc
= (XCellRangeSource
*)
2021 xInt
->queryInterface(XCellRangeSource::getSmartUik());
2022 if (!xSrc
) return 0;
2023 XCellRangeRef xRange
= xSrc
->getReferredCells();
2024 if (!xRange
) return 0;
2025 XCellCollectionRef xColl
= (XCellCollection
*)
2026 xRange
->queryInterface(XCellCollection::getSmartUik());
2027 if (!xColl
) return 0;
2029 XActionLockableRef xLock
= (XActionLockable
*)
2030 xDoc
->queryInterface(XActionLockable::getSmartUik());
2032 xLock
->addActionLock(); // nicht zwischendurch painten
2034 // lcl_FillCells(xColl);
2037 xLock
->removeActionLock(); // nicht zwischendurch painten
2039 XStarCalcViewRef xCalc
= (XStarCalcView
*)xInt
->queryInterface(XStarCalcView::getSmartUik());
2040 if (!xCalc
) return 0;