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