1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svtools/libcall.hxx>
21 #include <vcl/msgbox.hxx>
22 #include <vcl/window.hxx>
23 #include <vcl/button.hxx>
24 #include <vcl/field.hxx>
25 #include <vcl/fixed.hxx>
26 #include <vcl/help.hxx>
27 #include <usr/conver.hxx>
28 #include <usr/uno.hxx>
29 #include <usr/refl.hxx>
30 #include <stardiv/one/frame/xcollect.hxx>
31 #include <stardiv/one/text/offfield.hxx>
32 #include <stardiv/one/offmisc.hxx>
33 #include <stardiv/one/sheet/offtable.hxx>
34 #include <stardiv/one/text/offtext.hxx>
35 #include <stardiv/one/offstyle.hxx>
36 #include <stardiv/one/offview.hxx>
37 #include <stardiv/uno/repos/serinfo.hxx>
38 #include <stardiv/one/sheet/sctypes.hxx>
39 #include <stardiv/one/sheet/scmodel.hxx>
40 #include <stardiv/one/sheet/sccells.hxx>
41 #include <stardiv/one/sheet/sctables.hxx>
42 #include <stardiv/one/sheet/sctable.hxx>
43 #include <stardiv/one/sheet/sccell.hxx>
44 #include <stardiv/one/sheet/scpostit.hxx>
45 #include <stardiv/one/sheet/scview.hxx>
46 #include <stardiv/one/sheet/scdata.hxx>
47 #include <stardiv/one/sheet/scattr.hxx>
49 //! das muss als Konstante in irgendeine idl-Datei!!!!
50 #define TEXTCONTROLCHAR_PARAGRAPH_BREAK 0
52 class MyFixedText
: public FixedText
55 void RequestHelp( const HelpEvent
& rHEvt
);
57 MyFixedText(vcl::Window
* pParent
) : FixedText(pParent
) {}
60 class MyWindow
: public vcl::Window
63 NumericField aCountField
;
64 PushButton aCountButton
;
65 MyFixedText aTimeText
;
66 NumericField aColField
;
67 NumericField aRowField
;
68 NumericField aPosField
;
69 NumericField aLenField
;
71 PushButton aTextButton
;
72 PushButton aBlaButton
;
73 PushButton aTabButton
;
74 PushButton aViewButton
;
77 MyWindow( vcl::Window
*pParent
);
79 DECL_LINK(CountHdl
, PushButton
*);
80 DECL_LINK(TextHdl
, PushButton
*);
81 DECL_LINK(BlaHdl
, PushButton
*);
82 DECL_LINK(TabHdl
, PushButton
*);
83 DECL_LINK(ViewHdl
, PushButton
*);
86 class ScTestListener
: public XSelectionChangeListener
, public UsrObject
89 FixedText
* pFixedText
;
92 ScTestListener(FixedText
* pF
);
93 virtual ~ScTestListener();
95 SMART_UNO_DECLARATION( ScTestListener
, UsrObject
);
97 virtual XInterface
* queryInterface( UsrUik
);
98 virtual XIdlClassRef
getIdlClass();
100 virtual void disposing(const EventObject
& Source
);
102 // XSelectionChangeListener
103 virtual void selectionChanged(const EventObject
& aEvent
);
106 static long nBla
= 0;
108 static XCellRef xGlobalCell
;
110 ScTestListener::ScTestListener(FixedText
* pF
) :
115 ScTestListener::~ScTestListener()
119 XInterface
* ScTestListener::queryInterface( UsrUik aUIK
)
121 if ( aUIK
== XSelectionChangeListener::getSmartUik() )
122 return (XSelectionChangeListener
*) this;
124 return UsrObject::queryInterface( aUIK
);
127 XIdlClassRef
ScTestListener::getIdlClass()
129 static XIdlClassRef xClass
= createStandardClass( L
"ScTestListener",
130 UsrObject::getUsrObjectIdlClass(),
131 1, XSelectionChangeListener_getReflection() );
135 void ScTestListener::disposing(const EventObject
& Source
)
139 // XSelectionChangeListener
141 void ScTestListener::selectionChanged(const EventObject
& aEvent
)
143 static sal_uInt16 nBla
= 0;
144 pFixedText
->SetText(++nBla
);
146 XInterfaceRef xInt
= aEvent
.Source
;
148 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
150 XInterfaceRef xSelInt
= xView
->getSelection();
151 if (!xSelInt
) return;
152 XCellCollectionRef xCells
= (XCellCollection
*)
153 xSelInt
->queryInterface(XCellCollection::getSmartUik());
156 String aStr
= OUStringToString( xCells
->getAddress(), CHARSET_SYSTEM
);
157 pFixedText
->SetText(aStr
);
160 extern "C" vcl::Window
* SAL_CALL
CreateWindow( vcl::Window
*pParent
, const String
& rParam
)
162 MyWindow
*pWin
= new MyWindow( pParent
);
166 void MyFixedText::RequestHelp( const HelpEvent
& rHEvt
)
168 String aTxtStr
=GetText();
169 Size aTxtSize
=GetTextSize(aTxtStr
);
170 Point aShowPoint
= OutputToScreenPixel(Point(0,0));
171 if ( ( rHEvt
.GetMode() & HELPMODE_QUICK
) == HELPMODE_QUICK
&&
172 aTxtSize
.Width()>GetSizePixel().Width())
173 Help::ShowQuickHelp( Rectangle(aShowPoint
,aTxtSize
), aTxtStr
, QuickHelpFlags::Top
|QuickHelpFlags::Left
);
175 FixedText::RequestHelp( rHEvt
);
178 MyWindow::MyWindow( vcl::Window
*pParent
) :
180 aCountField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
181 aCountButton( this ),
183 aColField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
184 aRowField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
185 aPosField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
186 aLenField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
187 aTextEdit( this, WinBits(WB_BORDER
) ),
193 aCountField
.SetPosSizePixel( Point(10,10), Size(40,20) );
194 aCountField
.SetValue(1);
196 aCountButton
.SetPosSizePixel( Point(10,40), Size(100,30) );
197 aCountButton
.SetText("hochzaehlen");
199 aTimeText
.SetPosSizePixel( Point(10,80), Size(100,20) );
201 aColField
.SetPosSizePixel( Point(10,120), Size(40,20) );
202 aRowField
.SetPosSizePixel( Point(60,120), Size(40,20) );
203 aPosField
.SetPosSizePixel( Point(10,150), Size(40,20) );
204 aLenField
.SetPosSizePixel( Point(60,150), Size(40,20) );
205 aTextEdit
.SetPosSizePixel( Point(10,180), Size(100,20) );
207 aTextButton
.SetPosSizePixel( Point(10,210), Size(100,30) );
208 aTextButton
.SetText("col/row/pos/len");
210 aBlaButton
.SetPosSizePixel( Point(10,260), Size(100,30) );
211 aBlaButton
.SetText("Bla");
213 aTabButton
.SetPosSizePixel( Point(10,310), Size(100,30) );
214 aTabButton
.SetText("Tabellen");
216 aViewButton
.SetPosSizePixel( Point(10,360), Size(100,30) );
217 aViewButton
.SetText("Pfui");
219 aCountButton
.SetClickHdl(LINK(this, MyWindow
, CountHdl
));
220 aTextButton
.SetClickHdl(LINK(this, MyWindow
, TextHdl
));
221 aBlaButton
.SetClickHdl(LINK(this, MyWindow
, BlaHdl
));
222 aTabButton
.SetClickHdl(LINK(this, MyWindow
, TabHdl
));
223 aViewButton
.SetClickHdl(LINK(this, MyWindow
, ViewHdl
));
239 XSpreadsheetDocumentRef
lcl_GetDocument()
241 XServiceManagerRef xProv
= getGlobalServiceManager();
242 OSL_ENSURE( xProv
.is(), "Kein ServiceManager!" );
244 XServiceRegistryRef xReg
= (XServiceRegistry
*)xProv
->queryInterface(XServiceRegistry::getSmartUik());
248 Sequence
<Uik
> aIfaces( 1 );
249 aIfaces
.getArray()[0] = XModelCollection::getSmartUik();
250 XServiceProviderRef xSSI
= xProv
->getServiceProvider( L
"stardiv.desktop.ModelCollection",
251 aIfaces
, Sequence
<Uik
>() );
253 XModelCollectionRef aCollRef
= (XModelCollection
*)
254 xSSI
->newInstance()->queryInterface( XModelCollection::getSmartUik() );
255 sal_uInt16 nCount
= aCollRef
->getCount();
257 XSpreadsheetDocumentRef xModel
; // Calc-Model
258 for (sal_uInt16 nMod
=0; nMod
<nCount
&& !xModel
; nMod
++) // Calc-Doc suchen
260 XModelRef aRef
= aCollRef
->getItemByIndex( nMod
);
264 xModel
= (XSpreadsheetDocument
*) aRef
->queryInterface( XSpreadsheetDocument::getSmartUik() );
271 XInterfaceRef
lcl_GetView()
274 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
276 xView
= xDoc
->getDDELinks(); //! temporaer zum Testen !!!!!!!!!
281 void lcl_OutputNames( const XInterfaceRef
& xSource
, // XNameAccess
282 const XSpreadsheetDocumentRef
& xDoc
,
283 sal_uInt16 nCol
, sal_uInt16 nRow
, sal_uInt16 nTab
)
290 XNameAccessRef xNames
= (XNameAccess
*)xSource
->queryInterface(XNameAccess::getSmartUik());
292 Sequence
<UString
> aSeq
= xNames
->getElementNames();
294 sal_uInt16 nLen
= (sal_uInt16
)aSeq
.getLen();
296 XCellRef xCell
= xDoc
->getCell(aAdr
);
298 xCell
->setValue( nLen
);
301 UString
* pAry
= aSeq
.getArray();
302 for (sal_uInt16 i
=0; i
<nLen
; i
++)
304 xCell
= xDoc
->getCell(aAdr
);
306 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
308 xText
->setText( pAry
[i
] );
313 void lcl_SetText( const XTextRef
& xText
)
315 if (!xText
.is()) return;
316 XTextCursorRef xCursor
= xText
->createTextCursor();
317 if (!xCursor
.is()) return;
318 XTextPositionRef xPos
= (XTextPosition
*)xCursor
->queryInterface(XTextPosition::getSmartUik());
319 XPropertySetRef xProp
= (XPropertySet
*)xCursor
->queryInterface(XPropertySet::getSmartUik());
320 XControlCharacterInsertableRef xControl
= (XControlCharacterInsertable
*)
321 xCursor
->queryInterface(XControlCharacterInsertable::getSmartUik());
322 XParagraphCursorRef xPara
= (XParagraphCursor
*)
323 xCursor
->queryInterface(XParagraphCursor::getSmartUik());
325 if (!xPos
.is() || !xControl
.is() || !xPara
.is()) return; // PropertySet kann fehlen
327 xText
->setText(L
"bla fasel");
328 xCursor
->gotoEnd(false);
329 xControl
->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK
);
330 xPos
->collapseToEnd();
331 xPos
->setText(L
"s\xFClz"); // zweiter Absatz
333 xCursor
->gotoStart(false);
334 xPara
->gotoEndOfParagraph(false);
335 xCursor
->goLeft(5, true); // letzte 5 Zeichen im 1. Absatz
337 xProp
->setPropertyValue(L
"Bold", UsrAny((sal_Bool
)true));
342 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
345 XActionLockableRef xLock
= (XActionLockable
*)
346 xDoc
->queryInterface(XActionLockable::getSmartUik());
347 XCalculateRef xCalc
= (XCalculate
*)
348 xDoc
->queryInterface(XCalculate::getSmartUik());
350 xLock
->addActionLock(); // nicht zwischendurch painten
352 xCalc
->setAutomaticCalculation(false);
357 for (sal_uInt16 nRow
= 0; nRow
< 20; nRow
++)
360 for (sal_uInt16 nCol
= 0; nCol
< 10; nCol
++)
363 XCellRef xCell
= xDoc
->getCell(aPos
);
366 // Wert der Zelle um 1 hochzaehlen
368 double fVal
= xCell
->getValue();
370 xCell
->setValue( fVal
);
376 xCalc
->setAutomaticCalculation(true);
378 xLock
->removeActionLock();
382 void lcl_GlobalCell()
386 String aStr
= OUStringToString( xGlobalCell
->getFormula(), CHARSET_SYSTEM
);
388 xGlobalCell
->setFormula( StringToOUString( aStr
, CHARSET_SYSTEM
) );
392 void lcl_Annotations( FixedText
& aTimeText
)
394 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
401 XCellRef xCell
= xDoc
->getCell(aPos
);
404 XSheetAnnotationAnchorRef xAnchor
=
405 (XSheetAnnotationAnchor
*)xCell
->queryInterface(XSheetAnnotationAnchor::getSmartUik());
408 XSheetAnnotationRef xAnnotation
= xAnchor
->getAnnotation();
411 String aBlubb
= OUStringToString( xAnnotation
->getAuthor(), CHARSET_SYSTEM
)+
413 OUStringToString( xAnnotation
->getDate(), CHARSET_SYSTEM
);
414 aTimeText
.SetText(aBlubb
);
416 XTextRef xAnnotationText
=
417 (XText
*)xAnnotation
->queryInterface(XText::getSmartUik());
418 if ( xAnnotationText
)
420 XTextCursorRef xCursor
= xAnnotationText
->createTextCursor();
423 XTextPositionRef xPos
= (XTextPosition
*)
424 xCursor
->queryInterface(XTextPosition::getSmartUik());
425 XControlCharacterInsertableRef xControl
= (XControlCharacterInsertable
*)
426 xCursor
->queryInterface(XControlCharacterInsertable::getSmartUik());
428 if (xPos
&& xControl
)
430 sal_uInt64 nStart
= tools::Time::GetSystemTicks();
432 xAnnotationText
->setText(L
"bla");
433 xCursor
->gotoEnd(false);
434 xCursor
->goLeft(1,true);
435 xPos
->setText(L
"ubb");
436 for (sal_uInt16 i
=0; i
<10; i
++)
438 xPos
->collapseToEnd();
439 xControl
->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK
);
440 xPos
->collapseToEnd();
441 xPos
->setText(L
"dumdi");
444 sal_uInt64 nEnd
= tools::Time::GetSystemTicks();
445 aTimeText
.SetText(String(nEnd
-nStart
)+String(" ms"));
455 void lcl_Cursor( FixedText
& aTimeText
)
457 aTimeText
.SetText( "..." );
458 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
461 XActionLockableRef xLock
= (XActionLockable
*)
462 xDoc
->queryInterface(XActionLockable::getSmartUik());
464 xLock
->addActionLock();
470 XCellRef xCell
= xDoc
->getCell(aPos
);
473 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
474 XCellCollectionRef xColl
= (XCellCollection
*)xCell
->queryInterface(XCellCollection::getSmartUik());
475 if ( xText
&& xColl
)
477 xText
->setText(L
"bla");
478 XLineCursorRef xCursor
= xColl
->createCursor();
481 XCellCursorRef xCC
= (XCellCursor
*)xCursor
->queryInterface(XCellCursor::getSmartUik());
482 XCellRangesCursorRef xRC
= (XCellRangesCursor
*)
483 xCursor
->queryInterface(XCellRangesCursor::getSmartUik());
487 xCursor
->goDown( 1, false );
489 xColl
= xCC
->getRanges();
492 // XText ist drin, wenn's ne einzelne Zelle ist
493 xText
= (XText
*)xColl
->queryInterface(XText::getSmartUik());
496 xText
->setText(L
"fasel");
500 CellRangeAddress aSecond
;
502 aSecond
.StartColumn
= 3;
503 aSecond
.StartRow
= 4;
504 aSecond
.EndColumn
= 3;
506 xRC
->gotoUnion(aSecond
);
508 xColl
= xCC
->getRanges();
511 XPropertySetRef xProp
= (XPropertySet
*)
512 xColl
->queryInterface(XPropertySet::getSmartUik());
517 aAny
= xProp
->getPropertyValue(L
"ShadowFormat");
518 if ( aAny
.getReflection()->getName() ==
519 ShadowFormat_getReflection()->getName() )
521 //ShadowFormat* pOld = (ShadowFormat*)aAny.get();
523 aNew
.Location
= SHADOWLOCATION_BOTTOMRIGHT
;
524 aNew
.ShadowWidth
= 100;
525 aNew
.IsTransparent
= false;
526 aNew
.Color
= 0xff0000L
;
527 aAny
.set( &aNew
, aAny
.getReflection() );
528 xProp
->setPropertyValue(L
"ShadowFormat", aAny
);
531 aAny
= xProp
->getPropertyValue(L
"RotationValue");
533 xProp
->setPropertyValue(L
"RotationValue", aAny
);
535 aAny
= xProp
->getPropertyValue(L
"FontHeight");
537 xProp
->setPropertyValue(L
"FontHeight", aAny
);
539 aAny
= xProp
->getPropertyValue(L
"TransparentBackground");
541 xProp
->setPropertyValue(L
"TransparentBackground", aAny
);
543 aAny
= xProp
->getPropertyValue(L
"BackgroundColor");
544 aAny
.setUINT32(0xffff00);
545 xProp
->setPropertyValue(L
"BackgroundColor", aAny
);
547 aAny
= xProp
->getPropertyValue(L
"CellProtection");
548 if ( aAny
.getReflection()->getName() ==
549 CellProtection_getReflection()->getName() )
551 //CellProtection* pOld = (CellProtection*)aAny.get();
554 aNew
.FormulaHidden
= false;
556 aNew
.PrintHidden
= false;
557 aAny
.set( &aNew
, aAny
.getReflection() );
558 xProp
->setPropertyValue(L
"CellProtection", aAny
);
562 // XIndexAccess gibts nur wenn's mehrere sind (??!??!)
563 XIndexAccessRef xIndex
= (XIndexAccess
*)
564 xColl
->queryInterface(XIndexAccess::getSmartUik());
567 sal_uInt16 nCount
= (sal_uInt16
)xIndex
->getCount();
568 aTimeText
.SetText( String(nCount
) );
577 xLock
->removeActionLock();
581 void lcl_Cells( FixedText
& aTimeText
)
583 aTimeText
.SetText( "..." );
584 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
588 sal_uInt64 nStart
= tools::Time::GetSystemTicks();
590 XActionLockableRef xLock
= (XActionLockable
*)
591 xDoc
->queryInterface(XActionLockable::getSmartUik());
593 // xLock->addActionLock();
595 CellRangeAddress aRngAddr
;
597 aRngAddr
.StartColumn
= 0;
598 aRngAddr
.StartRow
= 0;
599 aRngAddr
.EndColumn
= 9;
600 aRngAddr
.EndRow
= 19;
601 XCellRangeRef xRange
= xDoc
->getCellRange(aRngAddr
);
604 XCellCollectionRef xColl
= (XCellCollection
*)
605 xRange
->queryInterface(XCellCollection::getSmartUik());
608 XEnumerationAccessRef xEnAcc
= xColl
->getCells();
611 XEnumerationRef xEnum
= xEnAcc
->getEnumeration();
614 while (xEnum
->hasMoreElements())
616 XInterfaceRef xInt
= xEnum
->nextElement();
627 sal_uInt64 nEnd
= tools::Time::GetSystemTicks();
628 aTimeText
.SetText(String(nCount
)+String(" ")+String(nEnd
-nStart
)+String(" ms"));
631 // xLock->removeActionLock();
635 void lcl_Sheet( FixedText
& aTimeText
)
637 aTimeText
.SetText( "..." );
638 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
640 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
641 if (!xSheets
) return;
642 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
644 XNamedRef xNamed
= (XNamed
*)xSheet
->queryInterface(XNamed::getSmartUik());
647 String aName
= OUStringToString( xNamed
->getName(), CHARSET_SYSTEM
);
649 xNamed
->setName(StringToOUString( aName
, CHARSET_SYSTEM
));
651 XCellRangeRef xRange
= (XCellRange
*)xSheet
->queryInterface(XCellRange::getSmartUik());
653 XCellRef xCell
= xRange
->getCell(2,1);
655 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
657 String aBla
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
659 xText
->setText(StringToOUString( aBla
, CHARSET_SYSTEM
));
661 XColumnRowRangeRef xCRR
= (XColumnRowRange
*)xSheet
->queryInterface(XColumnRowRange::getSmartUik());
664 XTableColumnsRef xCols
= xCRR
->getColumns();
666 XPropertySetRef xCol
= xCols
->getColumnByIndex(2);
669 UINT16 nWidth
= TypeConversion::toUINT16(xCol
->getPropertyValue(L
"Width"));
670 // UINT16 nNewWidth = nWidth + 100;
671 // xCol->setPropertyValue(L"Width", UsrAny(nNewWidth));
673 xCol
->setPropertyValue(L
"OptimalWidth", UsrAny((sal_Bool
)true));
674 xCol
->setPropertyValue(L
"NewPage", UsrAny((sal_Bool
)false));
676 UsrAny aAny
= xCol
->getPropertyValue(L
"ShadowFormat");
677 if ( aAny
.getReflection()->getName() ==
678 ShadowFormat_getReflection()->getName() )
680 //ShadowFormat* pOld = (ShadowFormat*)aAny.get();
682 aNew
.Location
= SHADOWLOCATION_BOTTOMRIGHT
;
683 aNew
.ShadowWidth
= 100;
684 aNew
.IsTransparent
= false;
685 aNew
.Color
= 0xff0000L
;
686 aAny
.set( &aNew
, aAny
.getReflection() );
687 xCol
->setPropertyValue(L
"ShadowFormat", aAny
);
690 XTableRowsRef xRows
= xCRR
->getRows();
692 XPropertySetRef xRow
= xRows
->getRowByIndex(1);
695 xRows
->removeRowsByIndex( 2, 1 );
697 UINT16 nHeight
= TypeConversion::toUINT16(xRow
->getPropertyValue(L
"Height"));
698 sal_Bool bOptH
= TypeConversion::toBOOL(xRow
->getPropertyValue(L
"OptimalHeight"));
700 UINT16 nNewHeight
= nHeight
+ 100;
701 xRow
->setPropertyValue(L
"Height", UsrAny(nNewHeight
));
703 aTimeText
.SetText(String("W:")+String(nWidth
)+String(" H:")+String(nHeight
)+
704 String(" ")+String((sal_uInt16
)bOptH
));
707 void lcl_Names( FixedText
& aTimeText
)
709 aTimeText
.SetText( "..." );
710 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
712 XNamedRangesRef xNames
= xDoc
->getNamedRanges();
714 XNamedRangeRef xName
= xNames
->getRangeByName(L
"bla");
716 String aCont
= OUStringToString( xName
->getContent(), CHARSET_SYSTEM
);
717 aTimeText
.SetText(aCont
);
719 XCellRangeSourceRef xSource
= (XCellRangeSource
*)
720 xName
->queryInterface(XCellRangeSource::getSmartUik());
721 if (!xSource
) return;
722 XCellRangeRef xRange
= xSource
->getReferredCells();
724 XPropertySetRef xProp
= (XPropertySet
*)xRange
->queryInterface(XPropertySet::getSmartUik());
726 UsrAny aAny
= xProp
->getPropertyValue(L
"RotationValue");
728 xProp
->setPropertyValue(L
"RotationValue", aAny
);
731 void lcl_Sheets( FixedText
& aTimeText
)
733 aTimeText
.SetText( "..." );
734 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
736 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
737 if (!xSheets
) return;
739 xSheets
->moveSheet(0, 1, true);
740 xSheets
->moveSheet(0, 2, false);
743 void lcl_Goal( FixedText
& aTimeText
)
745 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
747 XGoalSeekRef xGoal
= (XGoalSeek
*)xDoc
->queryInterface(XGoalSeek::getSmartUik());
751 CellAddress aFormula
; // A1
755 CellAddress aVar
; // A2
759 sal_Bool bFound
= xGoal
->doGoalSeek(fResult
, aFormula
, aVar
, L
"42");
763 CellAddress aOut
; // A3
768 XCellRef xCell
= xDoc
->getCell(aOut
);
770 xCell
->setValue(fResult
);
774 void lcl_TabOp( FixedText
& aTimeText
)
776 // Mehrfachoperation auf Tabelle2
777 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
780 XCellRangeRef xRange
;
781 XTableOperationRef xGoal
;
782 CellRangeAddress aRangeAddr
;
783 CellRangeAddress aFormulaRange
;
784 CellAddress aColumnCell
;
785 CellAddress aRowCell
;
786 TableOperationMode nMode
;
788 aRangeAddr
.Sheet
= 1; // c9:e11
789 aRangeAddr
.StartColumn
= 2;
790 aRangeAddr
.StartRow
= 8;
791 aRangeAddr
.EndColumn
= 4;
792 aRangeAddr
.EndRow
= 10;
793 aFormulaRange
.Sheet
= 1; // c6:c7
794 aFormulaRange
.StartColumn
= 2;
795 aFormulaRange
.StartRow
= 5;
796 aFormulaRange
.EndColumn
= 2;
797 aFormulaRange
.EndRow
= 6;
798 aColumnCell
.Sheet
= 0; // nicht benutzt
799 aColumnCell
.Column
= 0;
801 aRowCell
.Sheet
= 1; // c5
806 xRange
= xDoc
->getCellRange(aRangeAddr
);
808 xGoal
= (XTableOperation
*)xRange
->queryInterface(XTableOperation::getSmartUik());
810 xGoal
->setTableOperation( nMode
, aFormulaRange
, aColumnCell
, aRowCell
);
812 aRangeAddr
.Sheet
= 1; // b19:d21
813 aRangeAddr
.StartColumn
= 1;
814 aRangeAddr
.StartRow
= 18;
815 aRangeAddr
.EndColumn
= 3;
816 aRangeAddr
.EndRow
= 20;
817 aFormulaRange
.Sheet
= 1; // c16:d16
818 aFormulaRange
.StartColumn
= 2;
819 aFormulaRange
.StartRow
= 15;
820 aFormulaRange
.EndColumn
= 3;
821 aFormulaRange
.EndRow
= 15;
822 aColumnCell
.Sheet
= 1; // b16
823 aColumnCell
.Column
= 1;
824 aColumnCell
.Row
= 15;
825 aRowCell
.Sheet
= 0; // nicht benutzt
828 nMode
= TABLEOP_COLUMN
;
830 xRange
= xDoc
->getCellRange(aRangeAddr
);
832 xGoal
= (XTableOperation
*)xRange
->queryInterface(XTableOperation::getSmartUik());
834 xGoal
->setTableOperation( nMode
, aFormulaRange
, aColumnCell
, aRowCell
);
836 aRangeAddr
.Sheet
= 1; // b29:e32
837 aRangeAddr
.StartColumn
= 1;
838 aRangeAddr
.StartRow
= 28;
839 aRangeAddr
.EndColumn
= 4;
840 aRangeAddr
.EndRow
= 31;
841 aFormulaRange
.Sheet
= 1; // c27:c27
842 aFormulaRange
.StartColumn
= 2;
843 aFormulaRange
.StartRow
= 26;
844 aFormulaRange
.EndColumn
= 2;
845 aFormulaRange
.EndRow
= 26;
846 aColumnCell
.Sheet
= 1; // c25
847 aColumnCell
.Column
= 2;
848 aColumnCell
.Row
= 24;
849 aRowCell
.Sheet
= 1; // c26
852 nMode
= TABLEOP_BOTH
;
854 xRange
= xDoc
->getCellRange(aRangeAddr
);
856 xGoal
= (XTableOperation
*)xRange
->queryInterface(XTableOperation::getSmartUik());
858 xGoal
->setTableOperation( nMode
, aFormulaRange
, aColumnCell
, aRowCell
);
861 void lcl_Fill( FixedText
& aTimeText
)
863 XInterfaceRef xInt
= lcl_GetView();
865 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
868 XInterfaceRef xSelInt
= xView
->getSelection();
869 if (!xSelInt
) return;
871 XCellSeriesRef xFill
= (XCellSeries
*)xSelInt
->queryInterface(XCellSeries::getSmartUik());
874 // xFill->fillAuto( FILL_DIRECTION_TO_BOTTOM, 2 );
876 xFill
->fillSeries( FILL_DIRECTION_TO_LEFT
, FILL_MODE_GROWTH
, FILL_DATE_DAY
,
880 void lcl_Audi( FixedText
& aTimeText
)
882 aTimeText
.SetText( "..." );
883 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
885 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
886 if (!xSheets
) return;
887 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
890 XSheetAuditingRef xAudi
= (XSheetAuditing
*)xSheet
->queryInterface(XSheetAuditing::getSmartUik());
893 CellAddress aPosition
;
895 aPosition
.Column
= 0;
897 xAudi
->showDependents(aPosition
);
900 void lcl_Consoli( FixedText
& aTimeText
)
902 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
904 XConsolidationRef xCons
= (XConsolidation
*)xDoc
->queryInterface(XConsolidation::getSmartUik());
906 XConsolidationDescriptorRef xDesc
= xCons
->createConsolidationDescriptor(false);
908 xDesc
->setFunction(SUMMARY_COUNTNUMS
);
909 xCons
->consolidate(xDesc
);
912 void lcl_Sort( FixedText
& aTimeText
)
914 XInterfaceRef xInt
= lcl_GetView();
916 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
918 XInterfaceRef xSelInt
= xView
->getSelection();
919 if (!xSelInt
) return;
920 XSortableRef xSort
= (XSortable
*)xSelInt
->queryInterface(XSortable::getSmartUik());
922 XSortDescriptorRef xDesc
= xSort
->createSortDescriptor(false);
924 Sequence
<SortField
> aFields
= xDesc
->getSortFields();
925 if (aFields
.getLen())
928 SortField
* pAry
= aFields
.getArray();
930 pAry
[0].Ascending
= !pAry
[0].Ascending
;
932 else // neue Sequence, 1. Spalte aufsteigend
934 aFields
= Sequence
<SortField
>(1);
935 SortField
* pAry
= aFields
.getArray();
938 pAry
[0].Ascending
= true;
939 pAry
[0].Type
= SORT_FIELD_AUTOMATIC
;
941 xDesc
->setSortFields(aFields
);
943 XTableSortDescriptorRef xTableSort
= (XTableSortDescriptor
*)
944 xDesc
->queryInterface(XTableSortDescriptor::getSmartUik());
945 if (!xTableSort
) return;
950 xTableSort
->setUseOutputPosition(true);
951 xTableSort
->setOutputPosition(aOutPos
);
953 XPropertySetRef xPropSet
= (XPropertySet
*)
954 xDesc
->queryInterface(XPropertySet::getSmartUik());
955 if (!xPropSet
) return;
956 xPropSet
->setPropertyValue(L
"IncludeFormats", UsrAny((sal_Bool
)false));
961 void lcl_Filter( FixedText
& aTimeText
)
963 aTimeText
.SetText("...");
965 XInterfaceRef xInt
= lcl_GetView();
967 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
969 XInterfaceRef xSelInt
= xView
->getSelection();
970 if (!xSelInt
) return;
971 XFilterableRef xFilter
= (XFilterable
*)xSelInt
->queryInterface(XFilterable::getSmartUik());
972 if (!xFilter
) return;
974 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
976 CellRangeAddress aAddress
;
978 aAddress
.StartColumn
= 0;
979 aAddress
.StartRow
= 0;
980 aAddress
.EndColumn
= 1;
982 XCellRangeRef xRange
= xDoc
->getCellRange(aAddress
);
984 XAdvancedFilterSourceRef xSource
= (XAdvancedFilterSource
*)
985 xRange
->queryInterface(XAdvancedFilterSource::getSmartUik());
986 if (!xSource
) return;
988 XTableFilterDescriptorRef xDesc
= xSource
->createAdvancedFilter(xFilter
);
991 aTimeText
.SetText("kein Filter");
994 aTimeText
.SetText("Filter gefunden");
995 xFilter
->filter(xDesc
);
998 void lcl_AutoFilter( FixedText
& aTimeText
)
1000 XInterfaceRef xInt
= lcl_GetView();
1002 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1004 XInterfaceRef xSelInt
= xView
->getSelection();
1005 if (!xSelInt
) return;
1006 XFilterableRef xFilter
= (XFilterable
*)xSelInt
->queryInterface(XFilterable::getSmartUik());
1007 if (!xFilter
) return;
1009 sal_Bool bAuto
= xFilter
->getAutoFilter();
1010 xFilter
->setAutoFilter(!bAuto
);
1013 void lcl_Merge( FixedText
& aTimeText
)
1015 static sal_Bool bMerged
= false;
1017 XInterfaceRef xInt
= lcl_GetView();
1019 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1021 XInterfaceRef xSelInt
= xView
->getSelection();
1022 if (!xSelInt
) return;
1023 XMergeableRef xMerge
= (XMergeable
*)xSelInt
->queryInterface(XMergeable::getSmartUik());
1024 if (!xMerge
) return;
1027 xMerge
->unmergeCells();
1029 xMerge
->mergeCells();
1033 void lcl_Outline( FixedText
& aTimeText
)
1035 static sal_Bool bOutline
= false;
1037 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1039 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1040 if (!xSheets
) return;
1041 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
1042 if (!xSheet
) return;
1043 XSheetOutlineRef xOut
= (XSheetOutline
*)xSheet
->queryInterface(XSheetOutline::getSmartUik());
1046 XInterfaceRef xInt
= lcl_GetView();
1048 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1050 XInterfaceRef xSelInt
= xView
->getSelection();
1051 if (!xSelInt
) return;
1052 XAddressableCellRangeRef xRange
= (XAddressableCellRange
*)
1053 xSelInt
->queryInterface(XAddressableCellRange::getSmartUik());
1054 if (!xRange
) return;
1055 CellRangeAddress aRange
= xRange
->getRangeAddress();
1058 xOut
->showDetail( aRange
);
1060 xOut
->hideDetail( aRange
);
1062 bOutline
= !bOutline
;
1065 void lcl_Bla( FixedText
& aTimeText
)
1067 aTimeText
.SetText("...");
1069 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1071 XActionLockableRef xLock
= (XActionLockable
*)xDoc
->queryInterface(XActionLockable::getSmartUik());
1073 xLock
->addActionLock();
1074 xLock
->addActionLock();
1075 sal_uInt16 nCount
= xLock
->resetActionLocks(); // sollte 2 sein
1076 String aBla
= nCount
;
1077 xLock
->setActionLocks(nCount
);
1078 xLock
->removeActionLock();
1079 xLock
->removeActionLock();
1081 aBla
+= '/'; aBla
+= xLock
->resetActionLocks(); // sollte 0 sein
1083 aTimeText
.SetText(aBla
);
1086 void lcl_CellCursor( FixedText
& aTimeText
)
1088 static int nCursorCount
= 0;
1090 XInterfaceRef xInt
= lcl_GetView();
1092 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1094 XInterfaceRef xSelInt
= xView
->getSelection();
1095 if (!xSelInt
) return;
1096 XCellCollectionRef xColl
= (XCellCollection
*)xSelInt
->queryInterface(XCellCollection::getSmartUik());
1099 XLineCursorRef xCursor
= xColl
->createCursor();
1100 if (!xCursor
) return;
1101 XCellCursorRef xCC
= (XCellCursor
*)xCursor
->queryInterface(XCellCursor::getSmartUik());
1103 XCellRangesCursorRef xCRC
= (XCellRangesCursor
*)xCursor
->queryInterface(XCellRangesCursor::getSmartUik());
1105 XCellRangeCursorRef xCR
= (XCellRangeCursor
*)xCursor
->queryInterface(XCellRangeCursor::getSmartUik());
1107 XCellContentCursorRef xCCC
= (XCellContentCursor
*)xCursor
->queryInterface(XCellContentCursor::getSmartUik());
1109 XFormulaCursorRef xFC
= (XFormulaCursor
*)xCursor
->queryInterface(XFormulaCursor::getSmartUik());
1113 aPos
.Sheet
= 0; // ignored
1117 switch (nCursorCount
++)
1120 xFC
->gotoDependents(false);
1123 xFC
->gotoDependents(true);
1126 xFC
->gotoPrecedents(false);
1129 xFC
->gotoPrecedents(true);
1135 XCellCollectionRef xNew
= xCC
->getRanges();
1137 xView
->select( xNew
);
1140 void lcl_Notes( FixedText
& aTimeText
)
1142 aTimeText
.SetText( "..." );
1143 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1145 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1146 if (!xSheets
) return;
1147 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
1148 if (!xSheet
) return;
1150 XSheetAnnotationsRef xNotes
= xSheet
->getAnnotations();
1151 if (!xNotes
) return;
1152 XIndexAccessRef xNIndex
= (XIndexAccess
*)xNotes
->queryInterface(XIndexAccess::getSmartUik());
1153 if (!xNIndex
) return;
1159 xNotes
->addAnnotation( L
"neu", aPos
);
1161 sal_uLong nCount
= xNIndex
->getCount();
1162 for (sal_uLong i
=0; i
<nCount
; i
++)
1164 XSheetAnnotationRef xAnn
= xNotes
->getAnnotationByIndex((UINT16
)i
);
1165 XTextRef xText
= (XText
*)xAnn
->queryInterface(XText::getSmartUik());
1168 String aStr
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
1170 xText
->setText(StringToOUString( aStr
, CHARSET_SYSTEM
));
1175 void lcl_Scenario( FixedText
& aTimeText
)
1177 aTimeText
.SetText( "..." );
1178 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1180 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1181 if (!xSheets
) return;
1182 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
1183 if (!xSheet
) return;
1185 XScenariosRef xColl
= xSheet
->getScenarios();
1188 Sequence
<CellRangeAddress
> aRanges(2);
1189 CellRangeAddress
* pAry
= aRanges
.getArray();
1192 pAry
[0].StartColumn
= 0;
1193 pAry
[0].StartRow
= 0;
1194 pAry
[0].EndColumn
= 1;
1197 pAry
[1].StartColumn
= 3;
1198 pAry
[1].StartRow
= 3;
1199 pAry
[1].EndColumn
= 4;
1202 xColl
->addScenario( aRanges
, L
"bla", L
"bla blubb" );
1204 XIndexAccessRef xIndex
= (XIndexAccess
*)xColl
->queryInterface(XIndexAccess::getSmartUik());
1205 if (!xIndex
) return;
1206 sal_uLong nCount
= xIndex
->getCount();
1207 aTimeText
.SetText( nCount
);
1209 XScenarioRef xScen
= xColl
->getScenarioByIndex(0);
1212 aRanges
= Sequence
<CellRangeAddress
>(1);
1213 pAry
= aRanges
.getArray();
1216 pAry
[0].StartColumn
= 6;
1217 pAry
[0].StartRow
= 6;
1218 pAry
[0].EndColumn
= 7;
1221 xScen
->addRanges( aRanges
);
1223 XTableSheetRef xSh2
= xSheets
->getSheetByIndex(1);
1226 xSh2
->setVisible( true );
1227 xSh2
->setVisible( false );
1230 void lcl_Formula( FixedText
& aTimeText
)
1232 aTimeText
.SetText("...");
1234 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1240 XCellRef xCell
= xDoc
->getCell(aPos
);
1243 // String aStr = OUStringToString( xCell->getFormula(), CHARSET_SYSTEM );
1244 // aTimeText.SetText(aStr);
1246 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1248 String aStr
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
1249 aTimeText
.SetText(aStr
);
1252 void lcl_DBRange( FixedText
& aTimeText
) // 23
1254 aTimeText
.SetText("...");
1256 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1258 XDatabaseRangesRef xDBs
= xDoc
->getDatabaseRanges();
1261 CellRangeAddress aRange
;
1263 aRange
.StartColumn
= 1;
1264 aRange
.StartRow
= 1;
1265 aRange
.EndColumn
= 3;
1268 xDBs
->addRange( L
"blubb", aRange
);
1270 xDBs
->removeRangeByName( L
"gaga" );
1272 XDatabaseRangeRef xDB
= xDBs
->getRangeByName( L
"blubb" );
1275 String aName
= OUStringToString( xDB
->getName(), CHARSET_SYSTEM
);
1276 aTimeText
.SetText(aName
);
1278 xDB
->setName( L
"gaga" );
1280 CellRangeAddress aDBRange
= xDB
->getDataArea();
1282 xDB
->setDataArea(aDBRange
);
1285 void lcl_FillTab( FixedText
& aTimeText
) // 24
1287 aTimeText
.SetText("...");
1289 XInterfaceRef xInt
= lcl_GetView();
1291 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1293 XInterfaceRef xSelInt
= xView
->getSelection();
1294 if (!xSelInt
) return;
1296 XCellRangesRef xRanges
= (XCellRanges
*)xSelInt
->queryInterface(XCellRanges::getSmartUik());
1297 XIndexAccessRef xIndex
= (XIndexAccess
*)xSelInt
->queryInterface(XIndexAccess::getSmartUik());
1298 if (!xRanges
|| !xIndex
) return;
1300 sal_uLong nCount
= xIndex
->getCount();
1301 aTimeText
.SetText(nCount
);
1304 void lcl_Listener( FixedText
& aTimeText
) // 25
1306 XInterfaceRef xInt
= lcl_GetView();
1308 XStarCalcViewRef xView
= (XStarCalcView
*)xInt
->queryInterface(XStarCalcView::getSmartUik());
1310 xView
->addSelectionChangeListener( new ScTestListener(&aTimeText
) );
1313 void lcl_CellAttrib( FixedText
& aTimeText
) // 26
1315 XInterfaceRef xInt
= lcl_GetView();
1317 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1319 XInterfaceRef xSelInt
= xView
->getSelection();
1320 if (!xSelInt
) return;
1321 XTextRef xText
= (XText
*)xSelInt
->queryInterface(XText::getSmartUik());
1324 XTextCursorRef xCursor
= xText
->createTextCursor();
1325 if (!xCursor
) return;
1327 XTextPositionRef xPos
= (XTextPosition
*)xCursor
->queryInterface(XTextPosition::getSmartUik());
1328 XPropertySetRef xProp
= (XPropertySet
*)xCursor
->queryInterface(XPropertySet::getSmartUik());
1329 XParagraphCursorRef xPar
= (XParagraphCursor
*)xCursor
->queryInterface(XParagraphCursor::getSmartUik());
1330 if (!xPos
|| !xProp
|| !xPar
) return;
1332 xCursor
->gotoStart(false);
1333 xCursor
->goRight(1,false);
1334 xCursor
->goRight(1,true);
1336 UsrAny aAny
= xProp
->getPropertyValue(L
"FontHeight");
1337 sal_uInt32 nOld
= aAny
.getUINT32();
1338 aAny
.setUINT32(nOld
*11/10);
1339 xProp
->setPropertyValue(L
"FontHeight", aAny
);
1341 xPos
->collapseToEnd();
1342 xCursor
->goRight(1,true);
1344 xProp
->setPropertyValue(L
"Bold", UsrAny((sal_Bool
)true));
1346 xPos
->setText(L
"x");
1348 xPos
->collapseToEnd();
1349 xPar
->gotoNextParagraph(false,true);
1350 xProp
->setPropertyValue(L
"Italic", UsrAny((sal_Bool
)true));
1351 xProp
->setPropertyValue(L
"Underlined", UsrAny((sal_Bool
)true));
1354 void lcl_Styles( FixedText
& aTimeText
) // 27
1356 aTimeText
.SetText("...");
1357 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1359 XStyleFamiliesRef xFamilies
= xDoc
->getStyleFamilies();
1360 if (!xFamilies
) return;
1361 XStyleFamilyRef xFamily
= xFamilies
->getStyleFamilyByType( STYLE_FAMILY_CELL
);
1362 // XStyleFamilyRef xFamily = xFamilies->getStyleFamilyByType( STYLE_FAMILY_PAGE );
1363 if (!xFamily
) return;
1364 long nCount
= xFamily
->getCount();
1365 aTimeText
.SetText(nCount
);
1367 XStyleRef xStyle
= xFamily
->getStyleByName(L
"rot");
1368 if (!xStyle
) return;
1369 // XPropertySetRef xProp = (XPropertySet*)xStyle->queryInterface(XPropertySet::getSmartUik());
1370 // if (!xProp) return;
1372 XStyleRef xNew
= xFamily
->addStyle( L
"gaga", xStyle
);
1374 XPropertySetRef xProp
= (XPropertySet
*)xNew
->queryInterface(XPropertySet::getSmartUik());
1378 aAny
= xProp
->getPropertyValue(L
"TransparentBackground");
1379 aAny
.setBOOL(false);
1380 xProp
->setPropertyValue(L
"TransparentBackground", aAny
);
1381 aAny
= xProp
->getPropertyValue(L
"BackgroundColor");
1382 aAny
.setUINT32(0xffff00);
1383 xProp
->setPropertyValue(L
"BackgroundColor", aAny
);
1385 xFamily
->removeStyle( L
"rot" );
1388 void lcl_PageStyle( FixedText
& aTimeText
) // 28
1390 aTimeText
.SetText("...");
1392 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1394 XStyleFamiliesRef xFamilies
= xDoc
->getStyleFamilies();
1395 if (!xFamilies
) return;
1396 XStyleFamilyRef xFamily
= xFamilies
->getStyleFamilyByType( STYLE_FAMILY_PAGE
);
1397 if (!xFamily
) return;
1398 XStyleRef xStyle
= xFamily
->getStyleByName(L
"Standard");
1399 if (!xStyle
) return;
1400 XPropertySetRef xProp
= (XPropertySet
*)xStyle
->queryInterface(XPropertySet::getSmartUik());
1404 aAny
= xProp
->getPropertyValue(L
"RightPageHeaderContent");
1407 // if ( !XHeaderFooterContent_getReflection()->equals(*aAny.getReflection()) )
1410 XHeaderFooterContentRef
* pxContent
= (XHeaderFooterContentRef
*)aAny
.get();
1411 if (!pxContent
|| !pxContent
->is()) return;
1413 XTextRef xText
= (*pxContent
)->getCenterText();
1416 String aVal
= OUStringToString(xText
->getText(), CHARSET_SYSTEM
);
1417 aTimeText
.SetText(aVal
);
1419 // xText->setText(L"Bla fasel s\xFClz");
1422 xProp
->setPropertyValue(L
"RightPageHeaderContent", aAny
);
1425 void lcl_AutoForm( FixedText
& aTimeText
) // 29
1427 XInterfaceRef xInt
= lcl_GetView();
1430 XTableAutoFormatsRef xFormats
;
1432 XTableAutoFormatRef xFormat
= xFormats
->getAutoFormatByName(L
"gaga");
1433 if (!xFormat
) return;
1434 XPropertySetRef xProp
= (XPropertySet
*)xFormat
->queryInterface(XPropertySet::getSmartUik());
1437 sal_Bool bVal
= TypeConversion::toBOOL(xProp
->getPropertyValue(L
"IncludeBackground"));
1438 xProp
->setPropertyValue(L
"IncludeBackground", UsrAny(sal_Bool(!bVal
)));
1440 XNamedRef xNamed
= (XNamed
*)xFormat
->queryInterface(XNamed::getSmartUik());
1441 if (!xNamed
) return;
1442 xNamed
->setName(L
"zzz");
1444 xFormats
->addAutoFormat(L
"gaga");
1445 XTableAutoFormatRef xNew
= xFormats
->getAutoFormatByName(L
"gaga");
1448 for (sal_uInt16 i
=0; i
<16; i
++)
1450 XPropertySetRef xNewProp
= xNew
->getFieldByIndex(i
);
1451 if (!xNewProp
) return;
1453 xNewProp
->setPropertyValue(L
"TransparentBackground", UsrAny(sal_Bool(false)));
1454 sal_uInt32 nColor
= 0x111100 * i
;
1455 xNewProp
->setPropertyValue(L
"BackgroundColor", UsrAny(nColor
));
1459 void lcl_Pivot( FixedText
& aTimeText
) // 30
1461 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1464 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1465 if (!xSheets
) return;
1466 XIndexAccessRef xInd
= (XIndexAccess
*)xSheets
->queryInterface(XIndexAccess::getSmartUik());
1468 sal_uInt16 nCount
= (sal_uInt16
)xInd
->getCount();
1470 for (sal_uInt16 nTab
=0; nTab
<nCount
; nTab
++)
1472 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(nTab
);
1473 if (!xSheet
) return;
1474 XDataPilotTablesRef xPivots
= xSheet
->getDataPilotTables();
1475 if (!xPivots
) return;
1476 lcl_OutputNames( xPivots
, xDoc
, nTab
,0,0 );
1477 XIndexAccessRef xPInd
= (XIndexAccess
*)xPivots
->queryInterface(XIndexAccess::getSmartUik());
1479 sal_uInt16 nPCount
= (sal_uInt16
)xPInd
->getCount();
1480 for (sal_uInt16 nP
=0; nP
<nPCount
; nP
++)
1482 XDataPilotTableRef xTable
= xPivots
->getTableByIndex(nP
);
1483 if (!xTable
) return;
1485 // xTable->refreshTable();
1487 XDataPilotDescriptorRef xDesc
= (XDataPilotDescriptor
*)
1488 xTable
->queryInterface(XDataPilotDescriptor::getSmartUik());
1490 CellRangeAddress aSource
= xDesc
->getSourceRange();
1492 xDesc
->setSourceRange(aSource
);
1494 CellRangeAddress aAddr
= xTable
->getOutputRange();
1495 XCellRangeRef xRange
= xDoc
->getCellRange(aAddr
);
1496 if (!xRange
) return;
1497 XPropertySetRef xProp
= (XPropertySet
*)xRange
->queryInterface(XPropertySet::getSmartUik());
1499 xProp
->setPropertyValue(L
"TransparentBackground", UsrAny(sal_Bool(false)));
1500 xProp
->setPropertyValue(L
"BackgroundColor", UsrAny((sal_uInt32
)0x00FF00));
1505 IMPL_LINK_NOARG(MyWindow
, CountHdl
)
1508 long nCount
= aCountField
.GetValue();
1513 sal_uInt64 nStart
= tools::Time::GetSystemTicks();
1515 sal_uInt64 nEnd
= tools::Time::GetSystemTicks();
1516 aTimeText
.SetText(String("Count: ")+String(nEnd
-nStart
)+String(" ms"));
1523 lcl_Annotations(aTimeText
);
1526 lcl_Cursor(aTimeText
);
1529 lcl_Cells(aTimeText
);
1532 lcl_Sheet(aTimeText
);
1535 lcl_Names(aTimeText
);
1538 lcl_Sheets(aTimeText
);
1541 lcl_Goal(aTimeText
);
1544 lcl_TabOp(aTimeText
);
1547 lcl_Fill(aTimeText
);
1550 lcl_Audi(aTimeText
);
1553 lcl_Consoli(aTimeText
);
1556 lcl_Sort(aTimeText
);
1559 lcl_Filter(aTimeText
);
1562 lcl_AutoFilter(aTimeText
);
1565 lcl_Merge(aTimeText
);
1568 lcl_Outline(aTimeText
);
1574 lcl_CellCursor(aTimeText
);
1577 lcl_Notes(aTimeText
);
1580 lcl_Scenario(aTimeText
);
1583 lcl_Formula(aTimeText
);
1586 lcl_DBRange(aTimeText
);
1589 lcl_FillTab(aTimeText
);
1592 lcl_Listener(aTimeText
);
1595 lcl_CellAttrib(aTimeText
);
1598 lcl_Styles(aTimeText
);
1601 lcl_PageStyle(aTimeText
);
1604 lcl_AutoForm(aTimeText
);
1607 lcl_Pivot(aTimeText
);
1614 IMPL_LINK_NOARG(MyWindow
, TextHdl
)
1616 sal_uInt16 nCol
= (sal_uInt16
)aColField
.GetValue();
1617 sal_uInt16 nRow
= (sal_uInt16
)aRowField
.GetValue();
1618 sal_uInt16 nPos
= (sal_uInt16
)aPosField
.GetValue();
1619 sal_uInt16 nLen
= (sal_uInt16
)aLenField
.GetValue();
1620 String aStr
= aTextEdit
.GetText();
1622 aTimeText
.SetText("...");
1624 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1627 sal_uInt16 nTab
= 0;
1632 XCellRef xCell
= xDoc
->getCell(aPos
);
1635 XTextRef xCellText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1638 XTextCursorRef xCursor
= xCellText
->createTextCursor();
1641 XTextPositionRef xPos
= (XTextPosition
*)
1642 xCursor
->queryInterface(XTextPosition::getSmartUik());
1643 XControlCharacterInsertableRef xControl
= (XControlCharacterInsertable
*)
1644 xCursor
->queryInterface(XControlCharacterInsertable::getSmartUik());
1646 if (xPos
&& xControl
)
1648 xCursor
->gotoStart(false);
1649 xCursor
->goRight(11,true);
1650 String aVal
= OUStringToString( xPos
->getText(), CHARSET_SYSTEM
);
1651 aTimeText
.SetText(aVal
);
1661 IMPL_LINK_NOARG(MyWindow
, BlaHdl
)
1663 aTimeText
.SetText("...");
1665 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1672 XCellRef xCell
= xDoc
->getCell(aPos
);
1675 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1676 XFieldContainerRef xCont
= (XFieldContainer
*)
1677 xCell
->queryInterface(XFieldContainer::getSmartUik());
1679 if ( xText
&& xCont
)
1681 XFieldTypesRef xTypes
= xCont
->getFieldTypes();
1684 XTextFieldTypeRef xType
= xTypes
->getFieldType( FIELDTYPE_INTERNET
);
1685 XTextCursorRef xCursor
= xText
->createTextCursor();
1686 if ( xCursor
&& xType
)
1689 // letztes Feld loeschen
1690 XIndexAccessRef xIndex
= (XIndexAccess
*)
1691 xType
->queryInterface(XIndexAccess::getSmartUik());
1695 sal_uLong nCount
= xIndex
->getCount();
1696 for (sal_uLong i
=0; i
<nCount
; i
++)
1698 XInterfaceRef xInt
= xIndex
->getElementByIndex(i
);
1701 XPropertySetRef xProp
= (XPropertySet
*)xInt
->
1702 queryInterface(XPropertySet::getSmartUik());
1705 if (aBla
.Len()) aBla
+= ',';
1706 aBla
+= OUStringToString(
1707 TypeConversion::toString(
1708 xProp
->getPropertyValue(L
"URL") ),
1711 if ( i
+1 == nCount
) // letztes
1713 XTextFieldRef xField
= (XTextField
*)xInt
->
1714 queryInterface(XTextField::getSmartUik());
1716 xTypes
->removeTextField(xField
);
1720 aTimeText
.SetText(aBla
);
1727 xGlobalCell
= xCell
;
1732 IMPL_LINK_NOARG(MyWindow
, TabHdl
)
1736 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1739 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1742 XIndexAccessRef xIndex
= (XIndexAccess
*)xSheets
->queryInterface(XIndexAccess::getSmartUik());
1745 sal_uInt16 nCount
= (sal_uInt16
) xIndex
->getCount();
1746 for (sal_uInt16 nTab
=0; nTab
<nCount
; nTab
++)
1748 XInterfaceRef xInt
= xIndex
->getElementByIndex(nTab
);
1751 XNamedRef xNamed
= (XNamed
*)xInt
->queryInterface(XNamed::getSmartUik());
1756 aResult
+= OUStringToString( xNamed
->getName(), CHARSET_SYSTEM
);
1767 XEnumerationAccessRef xEAcc
= (XEnumerationAccess
*)
1768 xSheets
->queryInterface(XEnumerationAccess::getSmartUik());
1771 XEnumerationRef xEnum
= xEAcc
->getEnumeration();
1774 while (xEnum
->hasMoreElements())
1776 XInterfaceRef xInt
= xEnum
->nextElement();
1779 XNamedRef xNamed
= (XNamed
*)xInt
->queryInterface(XNamed::getSmartUik());
1782 UString aName
= xNamed
->getName();
1783 XCellRef xCell
= xDoc
->getCell(aPos
);
1786 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1787 xText
->setText( aName
);
1798 aTimeText
.SetText(aResult
);
1803 void lcl_FillCells(XCellCollectionRef xColl
)
1805 XEnumerationAccessRef xEnAcc
= xColl
->getCells();
1806 if (!xEnAcc
) return;
1807 XEnumerationRef xEnum
= xEnAcc
->getEnumeration();
1809 while (xEnum
->hasMoreElements())
1811 XInterfaceRef xInt
= xEnum
->nextElement();
1814 XCellRef xCell
= (XCell
*)xInt
->queryInterface(XCell::getSmartUik());
1817 xCell
->setValue(42.0);
1823 IMPL_LINK_NOARG(MyWindow
, ViewHdl
)
1825 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1826 XInterfaceRef xInt
= lcl_GetView();
1827 if (!xInt
) return 0;
1828 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1829 if (!xView
) return 0;
1831 XInterfaceRef xSelInt
= xView
->getSelection();
1832 if (!xSelInt
) return 0;
1834 XAutoFormattableRef xAuto
= (XAutoFormattable
*)xSelInt
->
1835 queryInterface(XAutoFormattable::getSmartUik());
1837 xAuto
->applyAutoFormat( L
"gaga" );
1839 XFormulaArrayRef xArr
= (XFormulaArray
*)xSelInt
->queryInterface(XFormulaArray::getSmartUik());
1842 // xArr->setFormulaArray( "123" );
1843 String aFormula
= OUStringToString( xArr
->getFormulaArray(), CHARSET_SYSTEM
);
1844 aTimeText
.SetText(aFormula
);
1847 aTimeText
.SetText("...");
1849 XTextRef xText
= (XText
*)xSelInt
->queryInterface(XText::getSmartUik());
1852 String aStr
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
1854 xText
->setText(StringToOUString(aStr
, CHARSET_SYSTEM
));
1857 XPrintableRef xPrint
= (XPrintable
*)xInt
->queryInterface(XPrintable::getSmartUik());
1858 String aName
= OUStringToString( xPrint
->getPrinterName(), CHARSET_SYSTEM
);
1859 // aTimeText.SetText(aName);
1861 xPrint
->setPrinterName(L
"HP5_2");
1862 // xPrint->setPrinterName(L"blubb");
1864 // XPropertySetRef xOptions;
1865 // xPrint->print(xOptions);
1867 /* XViewPaneRef xPane = (XViewPane*)xInt->queryInterface(XViewPane::getSmartUik());
1868 if (!xPane) return 0;
1869 xPane->setScrollRow( 2 );
1872 XCellRangeSourceRef xSrc
= (XCellRangeSource
*)
1873 xInt
->queryInterface(XCellRangeSource::getSmartUik());
1874 if (!xSrc
) return 0;
1875 XCellRangeRef xRange
= xSrc
->getReferredCells();
1876 if (!xRange
) return 0;
1877 XCellCollectionRef xColl
= (XCellCollection
*)
1878 xRange
->queryInterface(XCellCollection::getSmartUik());
1879 if (!xColl
) return 0;
1881 XActionLockableRef xLock
= (XActionLockable
*)
1882 xDoc
->queryInterface(XActionLockable::getSmartUik());
1884 xLock
->addActionLock(); // nicht zwischendurch painten
1886 // lcl_FillCells(xColl);
1889 xLock
->removeActionLock(); // nicht zwischendurch painten
1891 XStarCalcViewRef xCalc
= (XStarCalcView
*)xInt
->queryInterface(XStarCalcView::getSmartUik());
1892 if (!xCalc
) return 0;
1897 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */