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