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
53 class MyFixedText
: public FixedText
56 void RequestHelp( const HelpEvent
& rHEvt
);
58 MyFixedText(Window
* pParent
) : FixedText(pParent
) {}
61 class MyWindow
: public Window
64 NumericField aCountField
;
65 PushButton aCountButton
;
66 MyFixedText aTimeText
;
67 NumericField aColField
;
68 NumericField aRowField
;
69 NumericField aPosField
;
70 NumericField aLenField
;
72 PushButton aTextButton
;
73 PushButton aBlaButton
;
74 PushButton aTabButton
;
75 PushButton aViewButton
;
78 MyWindow( Window
*pParent
);
80 DECL_LINK(CountHdl
, PushButton
*);
81 DECL_LINK(TextHdl
, PushButton
*);
82 DECL_LINK(BlaHdl
, PushButton
*);
83 DECL_LINK(TabHdl
, PushButton
*);
84 DECL_LINK(ViewHdl
, PushButton
*);
87 //-----------------------------------------------------------------------
89 class ScTestListener
: public XSelectionChangeListener
, public UsrObject
92 FixedText
* pFixedText
;
95 ScTestListener(FixedText
* pF
);
96 virtual ~ScTestListener();
98 SMART_UNO_DECLARATION( ScTestListener
, UsrObject
);
100 virtual XInterface
* queryInterface( UsrUik
);
101 virtual XIdlClassRef
getIdlClass(void);
103 virtual void disposing(const EventObject
& Source
);
105 // XSelectionChangeListener
106 virtual void selectionChanged(const EventObject
& aEvent
);
109 //-----------------------------------------------------------------------
111 static long nBla
= 0;
113 static XCellRef xGlobalCell
;
115 //-----------------------------------------------------------------------
117 ScTestListener::ScTestListener(FixedText
* pF
) :
122 ScTestListener::~ScTestListener()
126 XInterface
* ScTestListener::queryInterface( UsrUik aUIK
)
128 if ( aUIK
== XSelectionChangeListener::getSmartUik() )
129 return (XSelectionChangeListener
*) this;
131 return UsrObject::queryInterface( aUIK
);
134 XIdlClassRef
ScTestListener::getIdlClass(void)
136 static XIdlClassRef xClass
= createStandardClass( L
"ScTestListener",
137 UsrObject::getUsrObjectIdlClass(),
138 1, XSelectionChangeListener_getReflection() );
142 void ScTestListener::disposing(const EventObject
& Source
)
146 // XSelectionChangeListener
148 void ScTestListener::selectionChanged(const EventObject
& aEvent
)
150 static sal_uInt16 nBla
= 0;
151 pFixedText
->SetText(++nBla
);
153 XInterfaceRef xInt
= aEvent
.Source
;
155 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
157 XInterfaceRef xSelInt
= xView
->getSelection();
158 if (!xSelInt
) return;
159 XCellCollectionRef xCells
= (XCellCollection
*)
160 xSelInt
->queryInterface(XCellCollection::getSmartUik());
163 String aStr
= OUStringToString( xCells
->getAddress(), CHARSET_SYSTEM
);
164 pFixedText
->SetText(aStr
);
168 //-----------------------------------------------------------------------
170 extern "C" Window
* SAL_CALL
CreateWindow( Window
*pParent
, const String
& rParam
)
172 MyWindow
*pWin
= new MyWindow( pParent
);
176 void MyFixedText::RequestHelp( const HelpEvent
& rHEvt
)
178 String aTxtStr
=GetText();
179 Size aTxtSize
=GetTextSize(aTxtStr
);
180 Point aShowPoint
= OutputToScreenPixel(Point(0,0));
181 if ( ( rHEvt
.GetMode() & HELPMODE_QUICK
) == HELPMODE_QUICK
&&
182 aTxtSize
.Width()>GetSizePixel().Width())
183 Help::ShowQuickHelp( Rectangle(aShowPoint
,aTxtSize
), aTxtStr
, QUICKHELP_TOP
|QUICKHELP_LEFT
);
185 FixedText::RequestHelp( rHEvt
);
188 MyWindow::MyWindow( Window
*pParent
) :
190 aCountField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
191 aCountButton( this ),
193 aColField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
194 aRowField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
195 aPosField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
196 aLenField( this, WinBits(WB_SPIN
| WB_REPEAT
| WB_BORDER
) ),
197 aTextEdit( this, WinBits(WB_BORDER
) ),
203 aCountField
.SetPosSizePixel( Point(10,10), Size(40,20) );
204 aCountField
.SetValue(1);
206 aCountButton
.SetPosSizePixel( Point(10,40), Size(100,30) );
207 aCountButton
.SetText("hochzaehlen");
209 aTimeText
.SetPosSizePixel( Point(10,80), Size(100,20) );
211 aColField
.SetPosSizePixel( Point(10,120), Size(40,20) );
212 aRowField
.SetPosSizePixel( Point(60,120), Size(40,20) );
213 aPosField
.SetPosSizePixel( Point(10,150), Size(40,20) );
214 aLenField
.SetPosSizePixel( Point(60,150), Size(40,20) );
215 aTextEdit
.SetPosSizePixel( Point(10,180), Size(100,20) );
217 aTextButton
.SetPosSizePixel( Point(10,210), Size(100,30) );
218 aTextButton
.SetText("col/row/pos/len");
220 aBlaButton
.SetPosSizePixel( Point(10,260), Size(100,30) );
221 aBlaButton
.SetText("Bla");
223 aTabButton
.SetPosSizePixel( Point(10,310), Size(100,30) );
224 aTabButton
.SetText("Tabellen");
226 aViewButton
.SetPosSizePixel( Point(10,360), Size(100,30) );
227 aViewButton
.SetText("Pfui");
229 aCountButton
.SetClickHdl(LINK(this, MyWindow
, CountHdl
));
230 aTextButton
.SetClickHdl(LINK(this, MyWindow
, TextHdl
));
231 aBlaButton
.SetClickHdl(LINK(this, MyWindow
, BlaHdl
));
232 aTabButton
.SetClickHdl(LINK(this, MyWindow
, TabHdl
));
233 aViewButton
.SetClickHdl(LINK(this, MyWindow
, ViewHdl
));
249 //-----------------------------------------------------------------------
251 XSpreadsheetDocumentRef
lcl_GetDocument()
253 XServiceManagerRef xProv
= getGlobalServiceManager();
254 OSL_ENSURE( xProv
.is(), "Kein ServiceManager!" );
256 XServiceRegistryRef xReg
= (XServiceRegistry
*)xProv
->queryInterface(XServiceRegistry::getSmartUik());
260 Sequence
<Uik
> aIfaces( 1 );
261 aIfaces
.getArray()[0] = XModelCollection::getSmartUik();
262 XServiceProviderRef xSSI
= xProv
->getServiceProvider( L
"stardiv.desktop.ModelCollection",
263 aIfaces
, Sequence
<Uik
>() );
265 XModelCollectionRef aCollRef
= (XModelCollection
*)
266 xSSI
->newInstance()->queryInterface( XModelCollection::getSmartUik() );
267 sal_uInt16 nCount
= aCollRef
->getCount();
269 XSpreadsheetDocumentRef xModel
; // Calc-Model
270 for (sal_uInt16 nMod
=0; nMod
<nCount
&& !xModel
; nMod
++) // Calc-Doc suchen
272 XModelRef aRef
= aCollRef
->getItemByIndex( nMod
);
276 xModel
= (XSpreadsheetDocument
*) aRef
->queryInterface( XSpreadsheetDocument::getSmartUik() );
283 XInterfaceRef
lcl_GetView()
286 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
288 xView
= xDoc
->getDDELinks(); //! temporaer zum Testen !!!!!!!!!
293 //-----------------------------------------------------------------------
295 void lcl_OutputNames( const XInterfaceRef
& xSource
, // XNameAccess
296 const XSpreadsheetDocumentRef
& xDoc
,
297 sal_uInt16 nCol
, sal_uInt16 nRow
, sal_uInt16 nTab
)
304 XNameAccessRef xNames
= (XNameAccess
*)xSource
->queryInterface(XNameAccess::getSmartUik());
306 Sequence
<UString
> aSeq
= xNames
->getElementNames();
308 sal_uInt16 nLen
= (sal_uInt16
)aSeq
.getLen();
310 XCellRef xCell
= xDoc
->getCell(aAdr
);
312 xCell
->setValue( nLen
);
315 UString
* pAry
= aSeq
.getArray();
316 for (sal_uInt16 i
=0; i
<nLen
; i
++)
318 xCell
= xDoc
->getCell(aAdr
);
320 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
322 xText
->setText( pAry
[i
] );
327 //-----------------------------------------------------------------------
329 void lcl_SetText( const XTextRef
& xText
)
331 if (!xText
.is()) return;
332 XTextCursorRef xCursor
= xText
->createTextCursor();
333 if (!xCursor
.is()) return;
334 XTextPositionRef xPos
= (XTextPosition
*)xCursor
->queryInterface(XTextPosition::getSmartUik());
335 XPropertySetRef xProp
= (XPropertySet
*)xCursor
->queryInterface(XPropertySet::getSmartUik());
336 XControlCharacterInsertableRef xControl
= (XControlCharacterInsertable
*)
337 xCursor
->queryInterface(XControlCharacterInsertable::getSmartUik());
338 XParagraphCursorRef xPara
= (XParagraphCursor
*)
339 xCursor
->queryInterface(XParagraphCursor::getSmartUik());
341 if (!xPos
.is() || !xControl
.is() || !xPara
.is()) return; // PropertySet kann fehlen
343 xText
->setText(L
"bla fasel");
344 xCursor
->gotoEnd(false);
345 xControl
->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK
);
346 xPos
->collapseToEnd();
347 xPos
->setText(L
"s\xFClz"); // zweiter Absatz
349 xCursor
->gotoStart(false);
350 xPara
->gotoEndOfParagraph(false);
351 xCursor
->goLeft(5, true); // letzte 5 Zeichen im 1. Absatz
353 xProp
->setPropertyValue(L
"Bold", UsrAny((sal_Bool
)true));
356 //-----------------------------------------------------------------------
360 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
363 XActionLockableRef xLock
= (XActionLockable
*)
364 xDoc
->queryInterface(XActionLockable::getSmartUik());
365 XCalculateRef xCalc
= (XCalculate
*)
366 xDoc
->queryInterface(XCalculate::getSmartUik());
368 xLock
->addActionLock(); // nicht zwischendurch painten
370 xCalc
->setAutomaticCalculation(false);
375 for (sal_uInt16 nRow
= 0; nRow
< 20; nRow
++)
378 for (sal_uInt16 nCol
= 0; nCol
< 10; nCol
++)
381 XCellRef xCell
= xDoc
->getCell(aPos
);
384 // Wert der Zelle um 1 hochzaehlen
386 double fVal
= xCell
->getValue();
388 xCell
->setValue( fVal
);
394 xCalc
->setAutomaticCalculation(true);
396 xLock
->removeActionLock();
401 void lcl_GlobalCell()
405 String aStr
= OUStringToString( xGlobalCell
->getFormula(), CHARSET_SYSTEM
);
407 xGlobalCell
->setFormula( StringToOUString( aStr
, CHARSET_SYSTEM
) );
412 void lcl_Annotations( FixedText
& aTimeText
)
414 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
421 XCellRef xCell
= xDoc
->getCell(aPos
);
424 XSheetAnnotationAnchorRef xAnchor
=
425 (XSheetAnnotationAnchor
*)xCell
->queryInterface(XSheetAnnotationAnchor::getSmartUik());
428 XSheetAnnotationRef xAnnotation
= xAnchor
->getAnnotation();
431 String aBlubb
= OUStringToString( xAnnotation
->getAuthor(), CHARSET_SYSTEM
)+
433 OUStringToString( xAnnotation
->getDate(), CHARSET_SYSTEM
);
434 aTimeText
.SetText(aBlubb
);
436 XTextRef xAnnotationText
=
437 (XText
*)xAnnotation
->queryInterface(XText::getSmartUik());
438 if ( xAnnotationText
)
440 XTextCursorRef xCursor
= xAnnotationText
->createTextCursor();
443 XTextPositionRef xPos
= (XTextPosition
*)
444 xCursor
->queryInterface(XTextPosition::getSmartUik());
445 XControlCharacterInsertableRef xControl
= (XControlCharacterInsertable
*)
446 xCursor
->queryInterface(XControlCharacterInsertable::getSmartUik());
448 if (xPos
&& xControl
)
450 sal_uLong nStart
= Time::GetSystemTicks();
452 xAnnotationText
->setText(L
"bla");
453 xCursor
->gotoEnd(false);
454 xCursor
->goLeft(1,true);
455 xPos
->setText(L
"ubb");
456 for (sal_uInt16 i
=0; i
<10; i
++)
458 xPos
->collapseToEnd();
459 xControl
->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK
);
460 xPos
->collapseToEnd();
461 xPos
->setText(L
"dumdi");
464 sal_uLong nEnd
= Time::GetSystemTicks();
465 aTimeText
.SetText(String(nEnd
-nStart
)+String(" ms"));
476 void lcl_Cursor( FixedText
& aTimeText
)
478 aTimeText
.SetText( "..." );
479 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
482 XActionLockableRef xLock
= (XActionLockable
*)
483 xDoc
->queryInterface(XActionLockable::getSmartUik());
485 xLock
->addActionLock();
491 XCellRef xCell
= xDoc
->getCell(aPos
);
494 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
495 XCellCollectionRef xColl
= (XCellCollection
*)xCell
->queryInterface(XCellCollection::getSmartUik());
496 if ( xText
&& xColl
)
498 xText
->setText(L
"bla");
499 XLineCursorRef xCursor
= xColl
->createCursor();
502 XCellCursorRef xCC
= (XCellCursor
*)xCursor
->queryInterface(XCellCursor::getSmartUik());
503 XCellRangesCursorRef xRC
= (XCellRangesCursor
*)
504 xCursor
->queryInterface(XCellRangesCursor::getSmartUik());
508 xCursor
->goDown( 1, false );
510 xColl
= xCC
->getRanges();
513 // XText ist drin, wenn's ne einzelne Zelle ist
514 xText
= (XText
*)xColl
->queryInterface(XText::getSmartUik());
517 xText
->setText(L
"fasel");
521 CellRangeAddress aSecond
;
523 aSecond
.StartColumn
= 3;
524 aSecond
.StartRow
= 4;
525 aSecond
.EndColumn
= 3;
527 xRC
->gotoUnion(aSecond
);
529 xColl
= xCC
->getRanges();
532 XPropertySetRef xProp
= (XPropertySet
*)
533 xColl
->queryInterface(XPropertySet::getSmartUik());
538 aAny
= xProp
->getPropertyValue(L
"ShadowFormat");
539 if ( aAny
.getReflection()->getName() ==
540 ShadowFormat_getReflection()->getName() )
542 //ShadowFormat* pOld = (ShadowFormat*)aAny.get();
544 aNew
.Location
= SHADOWLOCATION_BOTTOMRIGHT
;
545 aNew
.ShadowWidth
= 100;
546 aNew
.IsTransparent
= false;
547 aNew
.Color
= 0xff0000L
;
548 aAny
.set( &aNew
, aAny
.getReflection() );
549 xProp
->setPropertyValue(L
"ShadowFormat", aAny
);
552 aAny
= xProp
->getPropertyValue(L
"RotationValue");
554 xProp
->setPropertyValue(L
"RotationValue", aAny
);
556 aAny
= xProp
->getPropertyValue(L
"FontHeight");
558 xProp
->setPropertyValue(L
"FontHeight", aAny
);
560 aAny
= xProp
->getPropertyValue(L
"TransparentBackground");
562 xProp
->setPropertyValue(L
"TransparentBackground", aAny
);
564 aAny
= xProp
->getPropertyValue(L
"BackgroundColor");
565 aAny
.setUINT32(0xffff00);
566 xProp
->setPropertyValue(L
"BackgroundColor", aAny
);
568 aAny
= xProp
->getPropertyValue(L
"CellProtection");
569 if ( aAny
.getReflection()->getName() ==
570 CellProtection_getReflection()->getName() )
572 //CellProtection* pOld = (CellProtection*)aAny.get();
575 aNew
.FormulaHidden
= false;
577 aNew
.PrintHidden
= false;
578 aAny
.set( &aNew
, aAny
.getReflection() );
579 xProp
->setPropertyValue(L
"CellProtection", aAny
);
583 // XIndexAccess gibts nur wenn's mehrere sind (??!??!)
584 XIndexAccessRef xIndex
= (XIndexAccess
*)
585 xColl
->queryInterface(XIndexAccess::getSmartUik());
588 sal_uInt16 nCount
= (sal_uInt16
)xIndex
->getCount();
589 aTimeText
.SetText( String(nCount
) );
598 xLock
->removeActionLock();
603 void lcl_Cells( FixedText
& aTimeText
)
605 aTimeText
.SetText( "..." );
606 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
610 sal_uLong nStart
= Time::GetSystemTicks();
612 XActionLockableRef xLock
= (XActionLockable
*)
613 xDoc
->queryInterface(XActionLockable::getSmartUik());
615 // xLock->addActionLock();
617 CellRangeAddress aRngAddr
;
619 aRngAddr
.StartColumn
= 0;
620 aRngAddr
.StartRow
= 0;
621 aRngAddr
.EndColumn
= 9;
622 aRngAddr
.EndRow
= 19;
623 XCellRangeRef xRange
= xDoc
->getCellRange(aRngAddr
);
626 XCellCollectionRef xColl
= (XCellCollection
*)
627 xRange
->queryInterface(XCellCollection::getSmartUik());
630 XEnumerationAccessRef xEnAcc
= xColl
->getCells();
633 XEnumerationRef xEnum
= xEnAcc
->getEnumeration();
636 while (xEnum
->hasMoreElements())
638 XInterfaceRef xInt
= xEnum
->nextElement();
649 sal_uLong nEnd
= Time::GetSystemTicks();
650 aTimeText
.SetText(String(nCount
)+String(" ")+String(nEnd
-nStart
)+String(" ms"));
654 // xLock->removeActionLock();
658 void lcl_Sheet( FixedText
& aTimeText
)
660 aTimeText
.SetText( "..." );
661 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
663 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
664 if (!xSheets
) return;
665 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
667 XNamedRef xNamed
= (XNamed
*)xSheet
->queryInterface(XNamed::getSmartUik());
670 String aName
= OUStringToString( xNamed
->getName(), CHARSET_SYSTEM
);
672 xNamed
->setName(StringToOUString( aName
, CHARSET_SYSTEM
));
674 XCellRangeRef xRange
= (XCellRange
*)xSheet
->queryInterface(XCellRange::getSmartUik());
676 XCellRef xCell
= xRange
->getCell(2,1);
678 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
680 String aBla
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
682 xText
->setText(StringToOUString( aBla
, CHARSET_SYSTEM
));
684 XColumnRowRangeRef xCRR
= (XColumnRowRange
*)xSheet
->queryInterface(XColumnRowRange::getSmartUik());
687 XTableColumnsRef xCols
= xCRR
->getColumns();
689 XPropertySetRef xCol
= xCols
->getColumnByIndex(2);
692 UINT16 nWidth
= TypeConversion::toUINT16(xCol
->getPropertyValue(L
"Width"));
693 // UINT16 nNewWidth = nWidth + 100;
694 // xCol->setPropertyValue(L"Width", UsrAny(nNewWidth));
696 xCol
->setPropertyValue(L
"OptimalWidth", UsrAny((sal_Bool
)true));
697 xCol
->setPropertyValue(L
"NewPage", UsrAny((sal_Bool
)false));
699 UsrAny aAny
= xCol
->getPropertyValue(L
"ShadowFormat");
700 if ( aAny
.getReflection()->getName() ==
701 ShadowFormat_getReflection()->getName() )
703 //ShadowFormat* pOld = (ShadowFormat*)aAny.get();
705 aNew
.Location
= SHADOWLOCATION_BOTTOMRIGHT
;
706 aNew
.ShadowWidth
= 100;
707 aNew
.IsTransparent
= false;
708 aNew
.Color
= 0xff0000L
;
709 aAny
.set( &aNew
, aAny
.getReflection() );
710 xCol
->setPropertyValue(L
"ShadowFormat", aAny
);
713 XTableRowsRef xRows
= xCRR
->getRows();
715 XPropertySetRef xRow
= xRows
->getRowByIndex(1);
718 xRows
->removeRowsByIndex( 2, 1 );
720 UINT16 nHeight
= TypeConversion::toUINT16(xRow
->getPropertyValue(L
"Height"));
721 sal_Bool bOptH
= TypeConversion::toBOOL(xRow
->getPropertyValue(L
"OptimalHeight"));
723 UINT16 nNewHeight
= nHeight
+ 100;
724 xRow
->setPropertyValue(L
"Height", UsrAny(nNewHeight
));
726 aTimeText
.SetText(String("W:")+String(nWidth
)+String(" H:")+String(nHeight
)+
727 String(" ")+String((sal_uInt16
)bOptH
));
730 void lcl_Names( FixedText
& aTimeText
)
732 aTimeText
.SetText( "..." );
733 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
735 XNamedRangesRef xNames
= xDoc
->getNamedRanges();
737 XNamedRangeRef xName
= xNames
->getRangeByName(L
"bla");
739 String aCont
= OUStringToString( xName
->getContent(), CHARSET_SYSTEM
);
740 aTimeText
.SetText(aCont
);
742 XCellRangeSourceRef xSource
= (XCellRangeSource
*)
743 xName
->queryInterface(XCellRangeSource::getSmartUik());
744 if (!xSource
) return;
745 XCellRangeRef xRange
= xSource
->getReferredCells();
747 XPropertySetRef xProp
= (XPropertySet
*)xRange
->queryInterface(XPropertySet::getSmartUik());
749 UsrAny aAny
= xProp
->getPropertyValue(L
"RotationValue");
751 xProp
->setPropertyValue(L
"RotationValue", aAny
);
754 void lcl_Sheets( FixedText
& aTimeText
)
756 aTimeText
.SetText( "..." );
757 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
759 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
760 if (!xSheets
) return;
762 xSheets
->moveSheet(0, 1, true);
763 xSheets
->moveSheet(0, 2, false);
766 void lcl_Goal( FixedText
& aTimeText
)
768 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
770 XGoalSeekRef xGoal
= (XGoalSeek
*)xDoc
->queryInterface(XGoalSeek::getSmartUik());
774 CellAddress aFormula
; // A1
778 CellAddress aVar
; // A2
782 sal_Bool bFound
= xGoal
->doGoalSeek(fResult
, aFormula
, aVar
, L
"42");
786 CellAddress aOut
; // A3
791 XCellRef xCell
= xDoc
->getCell(aOut
);
793 xCell
->setValue(fResult
);
797 void lcl_TabOp( FixedText
& aTimeText
)
799 // Mehrfachoperation auf Tabelle2
800 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
803 XCellRangeRef xRange
;
804 XTableOperationRef xGoal
;
805 CellRangeAddress aRangeAddr
;
806 CellRangeAddress aFormulaRange
;
807 CellAddress aColumnCell
;
808 CellAddress aRowCell
;
809 TableOperationMode nMode
;
811 aRangeAddr
.Sheet
= 1; // c9:e11
812 aRangeAddr
.StartColumn
= 2;
813 aRangeAddr
.StartRow
= 8;
814 aRangeAddr
.EndColumn
= 4;
815 aRangeAddr
.EndRow
= 10;
816 aFormulaRange
.Sheet
= 1; // c6:c7
817 aFormulaRange
.StartColumn
= 2;
818 aFormulaRange
.StartRow
= 5;
819 aFormulaRange
.EndColumn
= 2;
820 aFormulaRange
.EndRow
= 6;
821 aColumnCell
.Sheet
= 0; // nicht benutzt
822 aColumnCell
.Column
= 0;
824 aRowCell
.Sheet
= 1; // c5
829 xRange
= xDoc
->getCellRange(aRangeAddr
);
831 xGoal
= (XTableOperation
*)xRange
->queryInterface(XTableOperation::getSmartUik());
833 xGoal
->setTableOperation( nMode
, aFormulaRange
, aColumnCell
, aRowCell
);
835 aRangeAddr
.Sheet
= 1; // b19:d21
836 aRangeAddr
.StartColumn
= 1;
837 aRangeAddr
.StartRow
= 18;
838 aRangeAddr
.EndColumn
= 3;
839 aRangeAddr
.EndRow
= 20;
840 aFormulaRange
.Sheet
= 1; // c16:d16
841 aFormulaRange
.StartColumn
= 2;
842 aFormulaRange
.StartRow
= 15;
843 aFormulaRange
.EndColumn
= 3;
844 aFormulaRange
.EndRow
= 15;
845 aColumnCell
.Sheet
= 1; // b16
846 aColumnCell
.Column
= 1;
847 aColumnCell
.Row
= 15;
848 aRowCell
.Sheet
= 0; // nicht benutzt
851 nMode
= TABLEOP_COLUMN
;
853 xRange
= xDoc
->getCellRange(aRangeAddr
);
855 xGoal
= (XTableOperation
*)xRange
->queryInterface(XTableOperation::getSmartUik());
857 xGoal
->setTableOperation( nMode
, aFormulaRange
, aColumnCell
, aRowCell
);
859 aRangeAddr
.Sheet
= 1; // b29:e32
860 aRangeAddr
.StartColumn
= 1;
861 aRangeAddr
.StartRow
= 28;
862 aRangeAddr
.EndColumn
= 4;
863 aRangeAddr
.EndRow
= 31;
864 aFormulaRange
.Sheet
= 1; // c27:c27
865 aFormulaRange
.StartColumn
= 2;
866 aFormulaRange
.StartRow
= 26;
867 aFormulaRange
.EndColumn
= 2;
868 aFormulaRange
.EndRow
= 26;
869 aColumnCell
.Sheet
= 1; // c25
870 aColumnCell
.Column
= 2;
871 aColumnCell
.Row
= 24;
872 aRowCell
.Sheet
= 1; // c26
875 nMode
= TABLEOP_BOTH
;
877 xRange
= xDoc
->getCellRange(aRangeAddr
);
879 xGoal
= (XTableOperation
*)xRange
->queryInterface(XTableOperation::getSmartUik());
881 xGoal
->setTableOperation( nMode
, aFormulaRange
, aColumnCell
, aRowCell
);
884 void lcl_Fill( FixedText
& aTimeText
)
886 XInterfaceRef xInt
= lcl_GetView();
888 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
891 XInterfaceRef xSelInt
= xView
->getSelection();
892 if (!xSelInt
) return;
894 XCellSeriesRef xFill
= (XCellSeries
*)xSelInt
->queryInterface(XCellSeries::getSmartUik());
897 // xFill->fillAuto( FILL_DIRECTION_TO_BOTTOM, 2 );
899 xFill
->fillSeries( FILL_DIRECTION_TO_LEFT
, FILL_MODE_GROWTH
, FILL_DATE_DAY
,
903 void lcl_Audi( FixedText
& aTimeText
)
905 aTimeText
.SetText( "..." );
906 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
908 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
909 if (!xSheets
) return;
910 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
913 XSheetAuditingRef xAudi
= (XSheetAuditing
*)xSheet
->queryInterface(XSheetAuditing::getSmartUik());
916 CellAddress aPosition
;
918 aPosition
.Column
= 0;
920 xAudi
->showDependents(aPosition
);
923 void lcl_Consoli( FixedText
& aTimeText
)
925 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
927 XConsolidationRef xCons
= (XConsolidation
*)xDoc
->queryInterface(XConsolidation::getSmartUik());
929 XConsolidationDescriptorRef xDesc
= xCons
->createConsolidationDescriptor(false);
931 xDesc
->setFunction(SUMMARY_COUNTNUMS
);
932 xCons
->consolidate(xDesc
);
935 void lcl_Sort( FixedText
& aTimeText
)
937 XInterfaceRef xInt
= lcl_GetView();
939 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
941 XInterfaceRef xSelInt
= xView
->getSelection();
942 if (!xSelInt
) return;
943 XSortableRef xSort
= (XSortable
*)xSelInt
->queryInterface(XSortable::getSmartUik());
945 XSortDescriptorRef xDesc
= xSort
->createSortDescriptor(false);
947 Sequence
<SortField
> aFields
= xDesc
->getSortFields();
948 if (aFields
.getLen())
951 SortField
* pAry
= aFields
.getArray();
953 pAry
[0].Ascending
= !pAry
[0].Ascending
;
955 else // neue Sequence, 1. Spalte aufsteigend
957 aFields
= Sequence
<SortField
>(1);
958 SortField
* pAry
= aFields
.getArray();
961 pAry
[0].Ascending
= true;
962 pAry
[0].Type
= SORT_FIELD_AUTOMATIC
;
964 xDesc
->setSortFields(aFields
);
966 XTableSortDescriptorRef xTableSort
= (XTableSortDescriptor
*)
967 xDesc
->queryInterface(XTableSortDescriptor::getSmartUik());
968 if (!xTableSort
) return;
973 xTableSort
->setUseOutputPosition(true);
974 xTableSort
->setOutputPosition(aOutPos
);
976 XPropertySetRef xPropSet
= (XPropertySet
*)
977 xDesc
->queryInterface(XPropertySet::getSmartUik());
978 if (!xPropSet
) return;
979 xPropSet
->setPropertyValue(L
"IncludeFormats", UsrAny((sal_Bool
)false));
984 void lcl_Filter( FixedText
& aTimeText
)
986 aTimeText
.SetText("...");
988 XInterfaceRef xInt
= lcl_GetView();
990 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
992 XInterfaceRef xSelInt
= xView
->getSelection();
993 if (!xSelInt
) return;
994 XFilterableRef xFilter
= (XFilterable
*)xSelInt
->queryInterface(XFilterable::getSmartUik());
995 if (!xFilter
) return;
997 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
999 CellRangeAddress aAddress
;
1001 aAddress
.StartColumn
= 0;
1002 aAddress
.StartRow
= 0;
1003 aAddress
.EndColumn
= 1;
1004 aAddress
.EndRow
= 2;
1005 XCellRangeRef xRange
= xDoc
->getCellRange(aAddress
);
1006 if (!xRange
) return;
1007 XAdvancedFilterSourceRef xSource
= (XAdvancedFilterSource
*)
1008 xRange
->queryInterface(XAdvancedFilterSource::getSmartUik());
1009 if (!xSource
) return;
1011 XTableFilterDescriptorRef xDesc
= xSource
->createAdvancedFilter(xFilter
);
1014 aTimeText
.SetText("kein Filter");
1017 aTimeText
.SetText("Filter gefunden");
1018 xFilter
->filter(xDesc
);
1021 void lcl_AutoFilter( FixedText
& aTimeText
)
1023 XInterfaceRef xInt
= lcl_GetView();
1025 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1027 XInterfaceRef xSelInt
= xView
->getSelection();
1028 if (!xSelInt
) return;
1029 XFilterableRef xFilter
= (XFilterable
*)xSelInt
->queryInterface(XFilterable::getSmartUik());
1030 if (!xFilter
) return;
1032 sal_Bool bAuto
= xFilter
->getAutoFilter();
1033 xFilter
->setAutoFilter(!bAuto
);
1036 void lcl_Merge( FixedText
& aTimeText
)
1038 static sal_Bool bMerged
= false;
1040 XInterfaceRef xInt
= lcl_GetView();
1042 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1044 XInterfaceRef xSelInt
= xView
->getSelection();
1045 if (!xSelInt
) return;
1046 XMergeableRef xMerge
= (XMergeable
*)xSelInt
->queryInterface(XMergeable::getSmartUik());
1047 if (!xMerge
) return;
1050 xMerge
->unmergeCells();
1052 xMerge
->mergeCells();
1056 void lcl_Outline( FixedText
& aTimeText
)
1058 static sal_Bool bOutline
= false;
1060 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1062 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1063 if (!xSheets
) return;
1064 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
1065 if (!xSheet
) return;
1066 XSheetOutlineRef xOut
= (XSheetOutline
*)xSheet
->queryInterface(XSheetOutline::getSmartUik());
1069 XInterfaceRef xInt
= lcl_GetView();
1071 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1073 XInterfaceRef xSelInt
= xView
->getSelection();
1074 if (!xSelInt
) return;
1075 XAddressableCellRangeRef xRange
= (XAddressableCellRange
*)
1076 xSelInt
->queryInterface(XAddressableCellRange::getSmartUik());
1077 if (!xRange
) return;
1078 CellRangeAddress aRange
= xRange
->getRangeAddress();
1081 xOut
->showDetail( aRange
);
1083 xOut
->hideDetail( aRange
);
1085 bOutline
= !bOutline
;
1088 void lcl_Bla( FixedText
& aTimeText
)
1090 aTimeText
.SetText("...");
1092 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1094 XActionLockableRef xLock
= (XActionLockable
*)xDoc
->queryInterface(XActionLockable::getSmartUik());
1096 xLock
->addActionLock();
1097 xLock
->addActionLock();
1098 sal_uInt16 nCount
= xLock
->resetActionLocks(); // sollte 2 sein
1099 String aBla
= nCount
;
1100 xLock
->setActionLocks(nCount
);
1101 xLock
->removeActionLock();
1102 xLock
->removeActionLock();
1104 aBla
+= '/'; aBla
+= xLock
->resetActionLocks(); // sollte 0 sein
1106 aTimeText
.SetText(aBla
);
1109 void lcl_CellCursor( FixedText
& aTimeText
)
1111 static int nCursorCount
= 0;
1113 XInterfaceRef xInt
= lcl_GetView();
1115 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1117 XInterfaceRef xSelInt
= xView
->getSelection();
1118 if (!xSelInt
) return;
1119 XCellCollectionRef xColl
= (XCellCollection
*)xSelInt
->queryInterface(XCellCollection::getSmartUik());
1122 XLineCursorRef xCursor
= xColl
->createCursor();
1123 if (!xCursor
) return;
1124 XCellCursorRef xCC
= (XCellCursor
*)xCursor
->queryInterface(XCellCursor::getSmartUik());
1126 XCellRangesCursorRef xCRC
= (XCellRangesCursor
*)xCursor
->queryInterface(XCellRangesCursor::getSmartUik());
1128 XCellRangeCursorRef xCR
= (XCellRangeCursor
*)xCursor
->queryInterface(XCellRangeCursor::getSmartUik());
1130 XCellContentCursorRef xCCC
= (XCellContentCursor
*)xCursor
->queryInterface(XCellContentCursor::getSmartUik());
1132 XFormulaCursorRef xFC
= (XFormulaCursor
*)xCursor
->queryInterface(XFormulaCursor::getSmartUik());
1136 aPos
.Sheet
= 0; // ignored
1140 switch (nCursorCount
++)
1143 xFC
->gotoDependents(false);
1146 xFC
->gotoDependents(true);
1149 xFC
->gotoPrecedents(false);
1152 xFC
->gotoPrecedents(true);
1158 XCellCollectionRef xNew
= xCC
->getRanges();
1160 xView
->select( xNew
);
1163 void lcl_Notes( FixedText
& aTimeText
)
1165 aTimeText
.SetText( "..." );
1166 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1168 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1169 if (!xSheets
) return;
1170 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
1171 if (!xSheet
) return;
1173 XSheetAnnotationsRef xNotes
= xSheet
->getAnnotations();
1174 if (!xNotes
) return;
1175 XIndexAccessRef xNIndex
= (XIndexAccess
*)xNotes
->queryInterface(XIndexAccess::getSmartUik());
1176 if (!xNIndex
) return;
1182 xNotes
->addAnnotation( L
"neu", aPos
);
1184 sal_uLong nCount
= xNIndex
->getCount();
1185 for (sal_uLong i
=0; i
<nCount
; i
++)
1187 XSheetAnnotationRef xAnn
= xNotes
->getAnnotationByIndex((UINT16
)i
);
1188 XTextRef xText
= (XText
*)xAnn
->queryInterface(XText::getSmartUik());
1191 String aStr
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
1193 xText
->setText(StringToOUString( aStr
, CHARSET_SYSTEM
));
1198 void lcl_Scenario( FixedText
& aTimeText
)
1200 aTimeText
.SetText( "..." );
1201 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1203 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1204 if (!xSheets
) return;
1205 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(0);
1206 if (!xSheet
) return;
1208 XScenariosRef xColl
= xSheet
->getScenarios();
1211 Sequence
<CellRangeAddress
> aRanges(2);
1212 CellRangeAddress
* pAry
= aRanges
.getArray();
1215 pAry
[0].StartColumn
= 0;
1216 pAry
[0].StartRow
= 0;
1217 pAry
[0].EndColumn
= 1;
1220 pAry
[1].StartColumn
= 3;
1221 pAry
[1].StartRow
= 3;
1222 pAry
[1].EndColumn
= 4;
1225 xColl
->addScenario( aRanges
, L
"bla", L
"bla blubb" );
1227 XIndexAccessRef xIndex
= (XIndexAccess
*)xColl
->queryInterface(XIndexAccess::getSmartUik());
1228 if (!xIndex
) return;
1229 sal_uLong nCount
= xIndex
->getCount();
1230 aTimeText
.SetText( nCount
);
1232 XScenarioRef xScen
= xColl
->getScenarioByIndex(0);
1235 aRanges
= Sequence
<CellRangeAddress
>(1);
1236 pAry
= aRanges
.getArray();
1239 pAry
[0].StartColumn
= 6;
1240 pAry
[0].StartRow
= 6;
1241 pAry
[0].EndColumn
= 7;
1244 xScen
->addRanges( aRanges
);
1246 XTableSheetRef xSh2
= xSheets
->getSheetByIndex(1);
1249 xSh2
->setVisible( true );
1250 xSh2
->setVisible( false );
1253 void lcl_Formula( FixedText
& aTimeText
)
1255 aTimeText
.SetText("...");
1257 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1263 XCellRef xCell
= xDoc
->getCell(aPos
);
1266 // String aStr = OUStringToString( xCell->getFormula(), CHARSET_SYSTEM );
1267 // aTimeText.SetText(aStr);
1269 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1271 String aStr
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
1272 aTimeText
.SetText(aStr
);
1275 void lcl_DBRange( FixedText
& aTimeText
) // 23
1277 aTimeText
.SetText("...");
1279 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1281 XDatabaseRangesRef xDBs
= xDoc
->getDatabaseRanges();
1284 CellRangeAddress aRange
;
1286 aRange
.StartColumn
= 1;
1287 aRange
.StartRow
= 1;
1288 aRange
.EndColumn
= 3;
1291 xDBs
->addRange( L
"blubb", aRange
);
1293 xDBs
->removeRangeByName( L
"gaga" );
1295 XDatabaseRangeRef xDB
= xDBs
->getRangeByName( L
"blubb" );
1298 String aName
= OUStringToString( xDB
->getName(), CHARSET_SYSTEM
);
1299 aTimeText
.SetText(aName
);
1301 xDB
->setName( L
"gaga" );
1303 CellRangeAddress aDBRange
= xDB
->getDataArea();
1305 xDB
->setDataArea(aDBRange
);
1308 void lcl_FillTab( FixedText
& aTimeText
) // 24
1310 aTimeText
.SetText("...");
1312 XInterfaceRef xInt
= lcl_GetView();
1314 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1316 XInterfaceRef xSelInt
= xView
->getSelection();
1317 if (!xSelInt
) return;
1319 XCellRangesRef xRanges
= (XCellRanges
*)xSelInt
->queryInterface(XCellRanges::getSmartUik());
1320 XIndexAccessRef xIndex
= (XIndexAccess
*)xSelInt
->queryInterface(XIndexAccess::getSmartUik());
1321 if (!xRanges
|| !xIndex
) return;
1323 sal_uLong nCount
= xIndex
->getCount();
1324 aTimeText
.SetText(nCount
);
1327 void lcl_Listener( FixedText
& aTimeText
) // 25
1329 XInterfaceRef xInt
= lcl_GetView();
1331 XStarCalcViewRef xView
= (XStarCalcView
*)xInt
->queryInterface(XStarCalcView::getSmartUik());
1333 xView
->addSelectionChangeListener( new ScTestListener(&aTimeText
) );
1336 void lcl_CellAttrib( FixedText
& aTimeText
) // 26
1338 XInterfaceRef xInt
= lcl_GetView();
1340 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1342 XInterfaceRef xSelInt
= xView
->getSelection();
1343 if (!xSelInt
) return;
1344 XTextRef xText
= (XText
*)xSelInt
->queryInterface(XText::getSmartUik());
1347 XTextCursorRef xCursor
= xText
->createTextCursor();
1348 if (!xCursor
) return;
1350 XTextPositionRef xPos
= (XTextPosition
*)xCursor
->queryInterface(XTextPosition::getSmartUik());
1351 XPropertySetRef xProp
= (XPropertySet
*)xCursor
->queryInterface(XPropertySet::getSmartUik());
1352 XParagraphCursorRef xPar
= (XParagraphCursor
*)xCursor
->queryInterface(XParagraphCursor::getSmartUik());
1353 if (!xPos
|| !xProp
|| !xPar
) return;
1355 xCursor
->gotoStart(false);
1356 xCursor
->goRight(1,false);
1357 xCursor
->goRight(1,true);
1359 UsrAny aAny
= xProp
->getPropertyValue(L
"FontHeight");
1360 sal_uInt32 nOld
= aAny
.getUINT32();
1361 aAny
.setUINT32(nOld
*11/10);
1362 xProp
->setPropertyValue(L
"FontHeight", aAny
);
1364 xPos
->collapseToEnd();
1365 xCursor
->goRight(1,true);
1367 xProp
->setPropertyValue(L
"Bold", UsrAny((sal_Bool
)true));
1369 xPos
->setText(L
"x");
1371 xPos
->collapseToEnd();
1372 xPar
->gotoNextParagraph(false,true);
1373 xProp
->setPropertyValue(L
"Italic", UsrAny((sal_Bool
)true));
1374 xProp
->setPropertyValue(L
"Underlined", UsrAny((sal_Bool
)true));
1377 void lcl_Styles( FixedText
& aTimeText
) // 27
1379 aTimeText
.SetText("...");
1380 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1382 XStyleFamiliesRef xFamilies
= xDoc
->getStyleFamilies();
1383 if (!xFamilies
) return;
1384 XStyleFamilyRef xFamily
= xFamilies
->getStyleFamilyByType( STYLE_FAMILY_CELL
);
1385 // XStyleFamilyRef xFamily = xFamilies->getStyleFamilyByType( STYLE_FAMILY_PAGE );
1386 if (!xFamily
) return;
1387 long nCount
= xFamily
->getCount();
1388 aTimeText
.SetText(nCount
);
1390 XStyleRef xStyle
= xFamily
->getStyleByName(L
"rot");
1391 if (!xStyle
) return;
1392 // XPropertySetRef xProp = (XPropertySet*)xStyle->queryInterface(XPropertySet::getSmartUik());
1393 // if (!xProp) return;
1395 XStyleRef xNew
= xFamily
->addStyle( L
"gaga", xStyle
);
1397 XPropertySetRef xProp
= (XPropertySet
*)xNew
->queryInterface(XPropertySet::getSmartUik());
1401 aAny
= xProp
->getPropertyValue(L
"TransparentBackground");
1402 aAny
.setBOOL(false);
1403 xProp
->setPropertyValue(L
"TransparentBackground", aAny
);
1404 aAny
= xProp
->getPropertyValue(L
"BackgroundColor");
1405 aAny
.setUINT32(0xffff00);
1406 xProp
->setPropertyValue(L
"BackgroundColor", aAny
);
1408 xFamily
->removeStyle( L
"rot" );
1411 void lcl_PageStyle( FixedText
& aTimeText
) // 28
1413 aTimeText
.SetText("...");
1415 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1417 XStyleFamiliesRef xFamilies
= xDoc
->getStyleFamilies();
1418 if (!xFamilies
) return;
1419 XStyleFamilyRef xFamily
= xFamilies
->getStyleFamilyByType( STYLE_FAMILY_PAGE
);
1420 if (!xFamily
) return;
1421 XStyleRef xStyle
= xFamily
->getStyleByName(L
"Standard");
1422 if (!xStyle
) return;
1423 XPropertySetRef xProp
= (XPropertySet
*)xStyle
->queryInterface(XPropertySet::getSmartUik());
1427 aAny
= xProp
->getPropertyValue(L
"RightPageHeaderContent");
1430 // if ( !XHeaderFooterContent_getReflection()->equals(*aAny.getReflection()) )
1433 XHeaderFooterContentRef
* pxContent
= (XHeaderFooterContentRef
*)aAny
.get();
1434 if (!pxContent
|| !pxContent
->is()) return;
1436 XTextRef xText
= (*pxContent
)->getCenterText();
1439 String aVal
= OUStringToString(xText
->getText(), CHARSET_SYSTEM
);
1440 aTimeText
.SetText(aVal
);
1442 // xText->setText(L"Bla fasel s\xFClz");
1445 xProp
->setPropertyValue(L
"RightPageHeaderContent", aAny
);
1448 void lcl_AutoForm( FixedText
& aTimeText
) // 29
1450 XInterfaceRef xInt
= lcl_GetView();
1453 XTableAutoFormatsRef xFormats
;
1455 XTableAutoFormatRef xFormat
= xFormats
->getAutoFormatByName(L
"gaga");
1456 if (!xFormat
) return;
1457 XPropertySetRef xProp
= (XPropertySet
*)xFormat
->queryInterface(XPropertySet::getSmartUik());
1460 sal_Bool bVal
= TypeConversion::toBOOL(xProp
->getPropertyValue(L
"IncludeBackground"));
1461 xProp
->setPropertyValue(L
"IncludeBackground", UsrAny(sal_Bool(!bVal
)));
1463 XNamedRef xNamed
= (XNamed
*)xFormat
->queryInterface(XNamed::getSmartUik());
1464 if (!xNamed
) return;
1465 xNamed
->setName(L
"zzz");
1467 xFormats
->addAutoFormat(L
"gaga");
1468 XTableAutoFormatRef xNew
= xFormats
->getAutoFormatByName(L
"gaga");
1471 for (sal_uInt16 i
=0; i
<16; i
++)
1473 XPropertySetRef xNewProp
= xNew
->getFieldByIndex(i
);
1474 if (!xNewProp
) return;
1476 xNewProp
->setPropertyValue(L
"TransparentBackground", UsrAny(sal_Bool(false)));
1477 sal_uInt32 nColor
= 0x111100 * i
;
1478 xNewProp
->setPropertyValue(L
"BackgroundColor", UsrAny(nColor
));
1482 void lcl_Pivot( FixedText
& aTimeText
) // 30
1484 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1487 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1488 if (!xSheets
) return;
1489 XIndexAccessRef xInd
= (XIndexAccess
*)xSheets
->queryInterface(XIndexAccess::getSmartUik());
1491 sal_uInt16 nCount
= (sal_uInt16
)xInd
->getCount();
1493 for (sal_uInt16 nTab
=0; nTab
<nCount
; nTab
++)
1495 XTableSheetRef xSheet
= xSheets
->getSheetByIndex(nTab
);
1496 if (!xSheet
) return;
1497 XDataPilotTablesRef xPivots
= xSheet
->getDataPilotTables();
1498 if (!xPivots
) return;
1499 lcl_OutputNames( xPivots
, xDoc
, nTab
,0,0 );
1500 XIndexAccessRef xPInd
= (XIndexAccess
*)xPivots
->queryInterface(XIndexAccess::getSmartUik());
1502 sal_uInt16 nPCount
= (sal_uInt16
)xPInd
->getCount();
1503 for (sal_uInt16 nP
=0; nP
<nPCount
; nP
++)
1505 XDataPilotTableRef xTable
= xPivots
->getTableByIndex(nP
);
1506 if (!xTable
) return;
1508 // xTable->refreshTable();
1510 XDataPilotDescriptorRef xDesc
= (XDataPilotDescriptor
*)
1511 xTable
->queryInterface(XDataPilotDescriptor::getSmartUik());
1513 CellRangeAddress aSource
= xDesc
->getSourceRange();
1515 xDesc
->setSourceRange(aSource
);
1517 CellRangeAddress aAddr
= xTable
->getOutputRange();
1518 XCellRangeRef xRange
= xDoc
->getCellRange(aAddr
);
1519 if (!xRange
) return;
1520 XPropertySetRef xProp
= (XPropertySet
*)xRange
->queryInterface(XPropertySet::getSmartUik());
1522 xProp
->setPropertyValue(L
"TransparentBackground", UsrAny(sal_Bool(false)));
1523 xProp
->setPropertyValue(L
"BackgroundColor", UsrAny((sal_uInt32
)0x00FF00));
1528 IMPL_LINK_NOARG(MyWindow
, CountHdl
)
1531 long nCount
= aCountField
.GetValue();
1536 sal_uLong nStart
= Time::GetSystemTicks();
1538 sal_uLong nEnd
= Time::GetSystemTicks();
1539 aTimeText
.SetText(String("Count: ")+String(nEnd
-nStart
)+String(" ms"));
1546 lcl_Annotations(aTimeText
);
1549 lcl_Cursor(aTimeText
);
1552 lcl_Cells(aTimeText
);
1555 lcl_Sheet(aTimeText
);
1558 lcl_Names(aTimeText
);
1561 lcl_Sheets(aTimeText
);
1564 lcl_Goal(aTimeText
);
1567 lcl_TabOp(aTimeText
);
1570 lcl_Fill(aTimeText
);
1573 lcl_Audi(aTimeText
);
1576 lcl_Consoli(aTimeText
);
1579 lcl_Sort(aTimeText
);
1582 lcl_Filter(aTimeText
);
1585 lcl_AutoFilter(aTimeText
);
1588 lcl_Merge(aTimeText
);
1591 lcl_Outline(aTimeText
);
1597 lcl_CellCursor(aTimeText
);
1600 lcl_Notes(aTimeText
);
1603 lcl_Scenario(aTimeText
);
1606 lcl_Formula(aTimeText
);
1609 lcl_DBRange(aTimeText
);
1612 lcl_FillTab(aTimeText
);
1615 lcl_Listener(aTimeText
);
1618 lcl_CellAttrib(aTimeText
);
1621 lcl_Styles(aTimeText
);
1624 lcl_PageStyle(aTimeText
);
1627 lcl_AutoForm(aTimeText
);
1630 lcl_Pivot(aTimeText
);
1637 //-----------------------------------------------------------------------
1639 IMPL_LINK_NOARG(MyWindow
, TextHdl
)
1641 sal_uInt16 nCol
= (sal_uInt16
)aColField
.GetValue();
1642 sal_uInt16 nRow
= (sal_uInt16
)aRowField
.GetValue();
1643 sal_uInt16 nPos
= (sal_uInt16
)aPosField
.GetValue();
1644 sal_uInt16 nLen
= (sal_uInt16
)aLenField
.GetValue();
1645 String aStr
= aTextEdit
.GetText();
1647 aTimeText
.SetText("...");
1649 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1652 sal_uInt16 nTab
= 0;
1657 XCellRef xCell
= xDoc
->getCell(aPos
);
1660 XTextRef xCellText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1663 XTextCursorRef xCursor
= xCellText
->createTextCursor();
1666 XTextPositionRef xPos
= (XTextPosition
*)
1667 xCursor
->queryInterface(XTextPosition::getSmartUik());
1668 XControlCharacterInsertableRef xControl
= (XControlCharacterInsertable
*)
1669 xCursor
->queryInterface(XControlCharacterInsertable::getSmartUik());
1671 if (xPos
&& xControl
)
1673 xCursor
->gotoStart(false);
1674 xCursor
->goRight(11,true);
1675 String aVal
= OUStringToString( xPos
->getText(), CHARSET_SYSTEM
);
1676 aTimeText
.SetText(aVal
);
1686 //-----------------------------------------------------------------------
1688 IMPL_LINK_NOARG(MyWindow
, BlaHdl
)
1690 aTimeText
.SetText("...");
1692 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1699 XCellRef xCell
= xDoc
->getCell(aPos
);
1702 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1703 XFieldContainerRef xCont
= (XFieldContainer
*)
1704 xCell
->queryInterface(XFieldContainer::getSmartUik());
1706 if ( xText
&& xCont
)
1708 XFieldTypesRef xTypes
= xCont
->getFieldTypes();
1711 XTextFieldTypeRef xType
= xTypes
->getFieldType( FIELDTYPE_INTERNET
);
1712 XTextCursorRef xCursor
= xText
->createTextCursor();
1713 if ( xCursor
&& xType
)
1716 // letztes Feld loeschen
1717 XIndexAccessRef xIndex
= (XIndexAccess
*)
1718 xType
->queryInterface(XIndexAccess::getSmartUik());
1722 sal_uLong nCount
= xIndex
->getCount();
1723 for (sal_uLong i
=0; i
<nCount
; i
++)
1725 XInterfaceRef xInt
= xIndex
->getElementByIndex(i
);
1728 XPropertySetRef xProp
= (XPropertySet
*)xInt
->
1729 queryInterface(XPropertySet::getSmartUik());
1732 if (aBla
.Len()) aBla
+= ',';
1733 aBla
+= OUStringToString(
1734 TypeConversion::toString(
1735 xProp
->getPropertyValue(L
"URL") ),
1738 if ( i
+1 == nCount
) // letztes
1740 XTextFieldRef xField
= (XTextField
*)xInt
->
1741 queryInterface(XTextField::getSmartUik());
1743 xTypes
->removeTextField(xField
);
1747 aTimeText
.SetText(aBla
);
1754 xGlobalCell
= xCell
;
1760 //-----------------------------------------------------------------------
1762 IMPL_LINK_NOARG(MyWindow
, TabHdl
)
1766 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1769 XSpreadsheetsRef xSheets
= xDoc
->getSheets();
1772 XIndexAccessRef xIndex
= (XIndexAccess
*)xSheets
->queryInterface(XIndexAccess::getSmartUik());
1775 sal_uInt16 nCount
= (sal_uInt16
) xIndex
->getCount();
1776 for (sal_uInt16 nTab
=0; nTab
<nCount
; nTab
++)
1778 XInterfaceRef xInt
= xIndex
->getElementByIndex(nTab
);
1781 XNamedRef xNamed
= (XNamed
*)xInt
->queryInterface(XNamed::getSmartUik());
1786 aResult
+= OUStringToString( xNamed
->getName(), CHARSET_SYSTEM
);
1797 XEnumerationAccessRef xEAcc
= (XEnumerationAccess
*)
1798 xSheets
->queryInterface(XEnumerationAccess::getSmartUik());
1801 XEnumerationRef xEnum
= xEAcc
->getEnumeration();
1804 while (xEnum
->hasMoreElements())
1806 XInterfaceRef xInt
= xEnum
->nextElement();
1809 XNamedRef xNamed
= (XNamed
*)xInt
->queryInterface(XNamed::getSmartUik());
1812 UString aName
= xNamed
->getName();
1813 XCellRef xCell
= xDoc
->getCell(aPos
);
1816 XTextRef xText
= (XText
*)xCell
->queryInterface(XText::getSmartUik());
1817 xText
->setText( aName
);
1828 aTimeText
.SetText(aResult
);
1833 //-----------------------------------------------------------------------
1835 void lcl_FillCells(XCellCollectionRef xColl
)
1837 XEnumerationAccessRef xEnAcc
= xColl
->getCells();
1838 if (!xEnAcc
) return;
1839 XEnumerationRef xEnum
= xEnAcc
->getEnumeration();
1841 while (xEnum
->hasMoreElements())
1843 XInterfaceRef xInt
= xEnum
->nextElement();
1846 XCellRef xCell
= (XCell
*)xInt
->queryInterface(XCell::getSmartUik());
1849 xCell
->setValue(42.0);
1855 IMPL_LINK_NOARG(MyWindow
, ViewHdl
)
1857 XSpreadsheetDocumentRef xDoc
= lcl_GetDocument(); // Calc-Model
1858 XInterfaceRef xInt
= lcl_GetView();
1859 if (!xInt
) return 0;
1860 XDocumentViewRef xView
= (XDocumentView
*)xInt
->queryInterface(XDocumentView::getSmartUik());
1861 if (!xView
) return 0;
1863 XInterfaceRef xSelInt
= xView
->getSelection();
1864 if (!xSelInt
) return 0;
1866 XAutoFormattableRef xAuto
= (XAutoFormattable
*)xSelInt
->
1867 queryInterface(XAutoFormattable::getSmartUik());
1869 xAuto
->applyAutoFormat( L
"gaga" );
1871 XFormulaArrayRef xArr
= (XFormulaArray
*)xSelInt
->queryInterface(XFormulaArray::getSmartUik());
1874 // xArr->setFormulaArray( "123" );
1875 String aFormula
= OUStringToString( xArr
->getFormulaArray(), CHARSET_SYSTEM
);
1876 aTimeText
.SetText(aFormula
);
1879 aTimeText
.SetText("...");
1881 XTextRef xText
= (XText
*)xSelInt
->queryInterface(XText::getSmartUik());
1884 String aStr
= OUStringToString( xText
->getText(), CHARSET_SYSTEM
);
1886 xText
->setText(StringToOUString(aStr
, CHARSET_SYSTEM
));
1889 XPrintableRef xPrint
= (XPrintable
*)xInt
->queryInterface(XPrintable::getSmartUik());
1890 String aName
= OUStringToString( xPrint
->getPrinterName(), CHARSET_SYSTEM
);
1891 // aTimeText.SetText(aName);
1893 xPrint
->setPrinterName(L
"HP5_2");
1894 // xPrint->setPrinterName(L"blubb");
1896 // XPropertySetRef xOptions;
1897 // xPrint->print(xOptions);
1899 /* XViewPaneRef xPane = (XViewPane*)xInt->queryInterface(XViewPane::getSmartUik());
1900 if (!xPane) return 0;
1901 xPane->setScrollRow( 2 );
1904 XCellRangeSourceRef xSrc
= (XCellRangeSource
*)
1905 xInt
->queryInterface(XCellRangeSource::getSmartUik());
1906 if (!xSrc
) return 0;
1907 XCellRangeRef xRange
= xSrc
->getReferredCells();
1908 if (!xRange
) return 0;
1909 XCellCollectionRef xColl
= (XCellCollection
*)
1910 xRange
->queryInterface(XCellCollection::getSmartUik());
1911 if (!xColl
) return 0;
1913 XActionLockableRef xLock
= (XActionLockable
*)
1914 xDoc
->queryInterface(XActionLockable::getSmartUik());
1916 xLock
->addActionLock(); // nicht zwischendurch painten
1918 // lcl_FillCells(xColl);
1921 xLock
->removeActionLock(); // nicht zwischendurch painten
1923 XStarCalcViewRef xCalc
= (XStarCalcView
*)xInt
->queryInterface(XStarCalcView::getSmartUik());
1924 if (!xCalc
) return 0;
1929 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */