1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26
27
28
29 //------------------------------------------------------------------
30
31 #define _TPHFEDIT_CXX
32 #include "scitems.hxx"
33 #include <editeng/eeitem.hxx>
34
35
36 //CHINA001 #include <svx/chardlg.hxx>
37 #include <editeng/editobj.hxx>
38 #include <editeng/editstat.hxx>
39 #include <editeng/editview.hxx>
40 #include <editeng/flditem.hxx>
41 #include <editeng/adjitem.hxx>
42 #include <sfx2/basedlgs.hxx>
43 #include <sfx2/objsh.hxx>
44 #include <vcl/msgbox.hxx>
45 #include <vcl/svapp.hxx>
46
47 #include "tphfedit.hxx"
48 #include "editutil.hxx"
49 #include "global.hxx"
50 #include "attrib.hxx"
51 #include "patattr.hxx"
52 #include "scresid.hxx"
53 #include "sc.hrc"
54 #include "globstr.hrc"
55 #include "tabvwsh.hxx"
56 #include "prevwsh.hxx"
57 #include "hfedtdlg.hrc"
58 //CHINA001 #include "textdlgs.hxx"
59 #include "AccessibleEditObject.hxx"
60
61 #include "scabstdlg.hxx" //CHINA001
62
63
64 // STATIC DATA -----------------------------------------------------------
65 static ScEditWindow* pActiveEdWnd = NULL;
66
GetScEditWindow()67 ScEditWindow* GetScEditWindow ()
68 {
69 return pActiveEdWnd;
70 }
71
72 //CHINA001
73 //CHINA001 static sal_uInt16 pPageRightHeaderRanges[] = { SID_SCATTR_PAGE_HEADERRIGHT,
74 //CHINA001 SID_SCATTR_PAGE_HEADERRIGHT,
75 //CHINA001 0 };
76 //CHINA001
77 //CHINA001 static sal_uInt16 pPageRightFooterRanges[] = { SID_SCATTR_PAGE_FOOTERRIGHT,
78 //CHINA001 SID_SCATTR_PAGE_FOOTERRIGHT,
79 //CHINA001 0 };
80 //CHINA001
81 //CHINA001 static sal_uInt16 pPageLeftHeaderRanges[] = { SID_SCATTR_PAGE_HEADERLEFT,
82 //CHINA001 SID_SCATTR_PAGE_HEADERLEFT,
83 //CHINA001 0 };
84 //CHINA001
85 //CHINA001 static sal_uInt16 pPageLeftFooterRanges[] = { SID_SCATTR_PAGE_FOOTERLEFT,
86 //CHINA001 SID_SCATTR_PAGE_FOOTERLEFT,
87 //CHINA001 0 };
88 //CHINA001
89 //CHINA001 static ScEditWindow* pActiveEdWnd = NULL;
90 //CHINA001
91 //CHINA001
92 //CHINA001
93 //CHINA001 //========================================================================
94 //CHINA001 // class ScHFEditPage
95 //CHINA001 //
96 //CHINA001
97 //CHINA001 ScHFEditPage::ScHFEditPage( Window* pParent,
98 //CHINA001 sal_uInt16 nResId,
99 //CHINA001 const SfxItemSet& rCoreAttrs,
100 //CHINA001 sal_uInt16 nWhichId )
101 //CHINA001
102 //CHINA001 : SfxTabPage ( pParent, ScResId( nResId ), rCoreAttrs ),
103 //CHINA001
104 //CHINA001 aWndLeft ( this, ScResId( WND_LEFT ), Left ),
105 //CHINA001 aWndCenter ( this, ScResId( WND_CENTER ), Center ),
106 //CHINA001 aWndRight ( this, ScResId( WND_RIGHT ), Right ),
107 //CHINA001 aFtLeft ( this, ScResId( FT_LEFT ) ),
108 //CHINA001 aFtCenter ( this, ScResId( FT_CENTER ) ),
109 //CHINA001 aFtRight ( this, ScResId( FT_RIGHT ) ),
110 //CHINA001 aFlInfo ( this, ScResId( FL_INFO ) ),
111 //CHINA001 aFtInfo ( this, ScResId( FT_INFO ) ),
112 //CHINA001 aBtnText ( this, ScResId( BTN_TEXT ) ),
113 //CHINA001 aBtnPage ( this, ScResId( BTN_PAGE ) ),
114 //CHINA001 aBtnLastPage ( this, ScResId( BTN_PAGES ) ),
115 //CHINA001 aBtnDate ( this, ScResId( BTN_DATE ) ),
116 //CHINA001 aBtnTime ( this, ScResId( BTN_TIME ) ),
117 //CHINA001 aBtnFile ( this, ScResId( BTN_FILE ) ),
118 //CHINA001 aBtnTable ( this, ScResId( BTN_TABLE ) ),
119 //CHINA001 aPopUpFile ( ScResId( RID_POPUP_FCOMMAND) ),
120 //CHINA001 nWhich ( nWhichId )
121 //CHINA001 {
122 //CHINA001 //! use default style from current document?
123 //CHINA001 //! if font color is used, header/footer background color must be set
124 //CHINA001
125 //CHINA001 ScPatternAttr aPatAttr( rCoreAttrs.GetPool() );
126 //CHINA001
127 //CHINA001 aBtnFile.SetPopupMenu(&aPopUpFile);
128 //CHINA001
129 //CHINA001 aBtnFile.SetMenuHdl( LINK( this, ScHFEditPage, MenuHdl ) );
130 //CHINA001 aBtnText .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
131 //CHINA001 aBtnPage .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
132 //CHINA001 aBtnLastPage.SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
133 //CHINA001 aBtnDate .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
134 //CHINA001 aBtnTime .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
135 //CHINA001 aBtnFile .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
136 //CHINA001 aBtnTable .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
137 //CHINA001
138 //CHINA001 aBtnText .SetModeImage( Image( ScResId( IMG_TEXT_H ) ), BMP_COLOR_HIGHCONTRAST );
139 //CHINA001 aBtnFile .SetModeImage( Image( ScResId( IMG_FILE_H ) ), BMP_COLOR_HIGHCONTRAST );
140 //CHINA001 aBtnTable .SetModeImage( Image( ScResId( IMG_TABLE_H ) ), BMP_COLOR_HIGHCONTRAST );
141 //CHINA001 aBtnPage .SetModeImage( Image( ScResId( IMG_PAGE_H ) ), BMP_COLOR_HIGHCONTRAST );
142 //CHINA001 aBtnLastPage.SetModeImage( Image( ScResId( IMG_PAGES_H ) ), BMP_COLOR_HIGHCONTRAST );
143 //CHINA001 aBtnDate .SetModeImage( Image( ScResId( IMG_DATE_H ) ), BMP_COLOR_HIGHCONTRAST );
144 //CHINA001 aBtnTime .SetModeImage( Image( ScResId( IMG_TIME_H ) ), BMP_COLOR_HIGHCONTRAST );
145 //CHINA001
146 //CHINA001 aWndLeft. SetFont( aPatAttr );
147 //CHINA001 aWndCenter. SetFont( aPatAttr );
148 //CHINA001 aWndRight. SetFont( aPatAttr );
149 //CHINA001
150 //CHINA001 FillCmdArr();
151 //CHINA001
152 //CHINA001 aWndLeft.GrabFocus();
153 //CHINA001
154 //CHINA001 FreeResource();
155 //CHINA001 }
156 //CHINA001
157 //CHINA001 // -----------------------------------------------------------------------
158 //CHINA001
159 //CHINA001 __EXPORT ScHFEditPage::~ScHFEditPage()
160 //CHINA001 {
161 //CHINA001 }
162 //CHINA001
163 //CHINA001 void ScHFEditPage::SetNumType(SvxNumType eNumType)
164 //CHINA001 {
165 //CHINA001 aWndLeft.SetNumType(eNumType);
166 //CHINA001 aWndCenter.SetNumType(eNumType);
167 //CHINA001 aWndRight.SetNumType(eNumType);
168 //CHINA001 }
169 //CHINA001
170 //CHINA001 // -----------------------------------------------------------------------
171 //CHINA001
172 //CHINA001 #define IS_AVAILABLE(w)(rCoreSet.GetItemState( (w) ) >= SFX_ITEM_AVAILABLE)
173 //CHINA001
174 //CHINA001 void __EXPORT ScHFEditPage::Reset( const SfxItemSet& rCoreSet )
175 //CHINA001 {
176 //CHINA001 if ( IS_AVAILABLE( nWhich ) )
177 //CHINA001 {
178 //CHINA001 const ScPageHFItem& rItem = (const ScPageHFItem&)(rCoreSet.Get( nWhich ));
179 //CHINA001
180 //CHINA001 const EditTextObject* pLeft = rItem.GetLeftArea();
181 //CHINA001 const EditTextObject* pCenter = rItem.GetCenterArea();
182 //CHINA001 const EditTextObject* pRight = rItem.GetRightArea();
183 //CHINA001
184 //CHINA001 if ( pLeft && pCenter && pRight )
185 //CHINA001 {
186 //CHINA001 aWndLeft .SetText( *pLeft );
187 //CHINA001 aWndCenter .SetText( *pCenter );
188 //CHINA001 aWndRight .SetText( *pRight );
189 //CHINA001 }
190 //CHINA001 }
191 //CHINA001 }
192 //CHINA001
193 //CHINA001 #undef IS_AVAILABLE
194 //CHINA001
195 //CHINA001 // -----------------------------------------------------------------------
196 //CHINA001
197 //CHINA001 sal_Bool __EXPORT ScHFEditPage::FillItemSet( SfxItemSet& rCoreSet )
198 //CHINA001 {
199 //CHINA001 ScPageHFItem aItem( nWhich );
200 //CHINA001 EditTextObject* pLeft = aWndLeft .CreateTextObject();
201 //CHINA001 EditTextObject* pCenter = aWndCenter.CreateTextObject();
202 //CHINA001 EditTextObject* pRight = aWndRight .CreateTextObject();
203 //CHINA001
204 //CHINA001 aItem.SetLeftArea ( *pLeft );
205 //CHINA001 aItem.SetCenterArea( *pCenter );
206 //CHINA001 aItem.SetRightArea ( *pRight );
207 //CHINA001 delete pLeft;
208 //CHINA001 delete pCenter;
209 //CHINA001 delete pRight;
210 //CHINA001
211 //CHINA001 rCoreSet.Put( aItem );
212 //CHINA001
213 //CHINA001 return sal_True;
214 //CHINA001 }
215 //CHINA001
216 //CHINA001 // -----------------------------------------------------------------------
217 //CHINA001
218 //CHINA001 #define SET_CMD(i,id) x
219 //CHINA001 aCmd = aDel; x
220 //CHINA001 aCmd += ScGlobal::GetRscString( id ); x
221 //CHINA001 aCmd += aDel; x
222 //CHINA001 aCmdArr[i] = aCmd;
223 //CHINA001
224 //CHINA001 // -----------------------------------------------------------------------
225 //CHINA001
226 //CHINA001 void ScHFEditPage::FillCmdArr()
227 //CHINA001 {
228 //CHINA001 String aDel( ScGlobal::GetRscString( STR_HFCMD_DELIMITER ) );
229 //CHINA001 String aCmd;
230 //CHINA001
231 //CHINA001 SET_CMD( 0, STR_HFCMD_PAGE )
232 //CHINA001 SET_CMD( 1, STR_HFCMD_PAGES )
233 //CHINA001 SET_CMD( 2, STR_HFCMD_DATE )
234 //CHINA001 SET_CMD( 3, STR_HFCMD_TIME )
235 //CHINA001 SET_CMD( 4, STR_HFCMD_FILE )
236 //CHINA001 SET_CMD( 5, STR_HFCMD_TABLE )
237 //CHINA001 }
238 //CHINA001
239 //CHINA001 #undef SET_CMD
240 //CHINA001
241 //CHINA001 //-----------------------------------------------------------------------
242 //CHINA001 // Handler:
243 //CHINA001 //-----------------------------------------------------------------------
244 //CHINA001
245 //CHINA001 IMPL_LINK( ScHFEditPage, ClickHdl, ImageButton*, pBtn )
246 //CHINA001 {
247 //CHINA001 if ( !pActiveEdWnd )
248 //CHINA001 return 0;
249 //CHINA001
250 //CHINA001 if ( pBtn == &aBtnText )
251 //CHINA001 {
252 //CHINA001 pActiveEdWnd->SetCharAttriutes();
253 //CHINA001 }
254 //CHINA001 else
255 //CHINA001 {
256 //CHINA001 if ( pBtn == &aBtnPage )
257 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxPageField()) );
258 //CHINA001 else if ( pBtn == &aBtnLastPage )
259 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxPagesField()) );
260 //CHINA001 else if ( pBtn == &aBtnDate )
261 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR)) );
262 //CHINA001 else if ( pBtn == &aBtnTime )
263 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxTimeField()) );
264 //CHINA001 else if ( pBtn == &aBtnFile )
265 //CHINA001 {
266 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField() ) );
267 //CHINA001 }
268 //CHINA001 else if ( pBtn == &aBtnTable )
269 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxTableField()) );
270 //CHINA001 }
271 //CHINA001 pActiveEdWnd->GrabFocus();
272 //CHINA001
273 //CHINA001 return 0;
274 //CHINA001 }
275 //CHINA001
276 //CHINA001 IMPL_LINK( ScHFEditPage, MenuHdl, ScExtIButton*, pBtn )
277 //CHINA001 {
278 //CHINA001 if ( !pActiveEdWnd )
279 //CHINA001 return 0;
280 //CHINA001
281 //CHINA001 if(pBtn!=NULL)
282 //CHINA001 {
283 //CHINA001 switch(pBtn->GetSelected())
284 //CHINA001 {
285 //CHINA001 case FILE_COMMAND_TITEL:
286 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField() ) );
287 //CHINA001 break;
288 //CHINA001 case FILE_COMMAND_FILENAME:
289 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
290 //CHINA001 EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_NAME_EXT ) ) );
291 //CHINA001 break;
292 //CHINA001 case FILE_COMMAND_PATH:
293 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
294 //CHINA001 EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ) ) );
295 //CHINA001 break;
296 //CHINA001 }
297 //CHINA001 }
298 //CHINA001 return 0;
299 //CHINA001 }
300 //CHINA001
301 //CHINA001 //========================================================================
302 //CHINA001 // class ScRightHeaderEditPage
303 //CHINA001 //========================================================================
304 //CHINA001
305 //CHINA001 ScRightHeaderEditPage::ScRightHeaderEditPage( Window* pParent, const SfxItemSet& rCoreSet )
306 //CHINA001 : ScHFEditPage( pParent, RID_SCPAGE_HFED_HR, rCoreSet,
307 //CHINA001 rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERRIGHT) )
308 //CHINA001 {}
309 //CHINA001
310 //CHINA001 // -----------------------------------------------------------------------
311 //CHINA001
312 //CHINA001 sal_uInt16* __EXPORT ScRightHeaderEditPage::GetRanges()
313 //CHINA001 { return pPageRightHeaderRanges; }
314 //CHINA001
315 //CHINA001 // -----------------------------------------------------------------------
316 //CHINA001
317 //CHINA001 SfxTabPage* __EXPORT ScRightHeaderEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
318 //CHINA001 { return ( new ScRightHeaderEditPage( pParent, rCoreSet ) ); };
319 //CHINA001
320 //CHINA001
321 //CHINA001 //========================================================================
322 //CHINA001 // class ScLeftHeaderEditPage
323 //CHINA001 //========================================================================
324 //CHINA001
325 //CHINA001 ScLeftHeaderEditPage::ScLeftHeaderEditPage( Window* pParent, const SfxItemSet& rCoreSet )
326 //CHINA001 : ScHFEditPage( pParent, RID_SCPAGE_HFED_HL, rCoreSet,
327 //CHINA001 rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERLEFT) )
328 //CHINA001 {}
329 //CHINA001
330 //CHINA001 // -----------------------------------------------------------------------
331 //CHINA001
332 //CHINA001 sal_uInt16* __EXPORT ScLeftHeaderEditPage::GetRanges()
333 //CHINA001 { return pPageLeftHeaderRanges; }
334 //CHINA001
335 //CHINA001 // -----------------------------------------------------------------------
336 //CHINA001
337 //CHINA001 SfxTabPage* __EXPORT ScLeftHeaderEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
338 //CHINA001 { return ( new ScLeftHeaderEditPage( pParent, rCoreSet ) ); };
339 //CHINA001
340 //CHINA001 //========================================================================
341 //CHINA001 // class ScRightFooterEditPage
342 //CHINA001 //========================================================================
343 //CHINA001
344 //CHINA001 ScRightFooterEditPage::ScRightFooterEditPage( Window* pParent, const SfxItemSet& rCoreSet )
345 //CHINA001 : ScHFEditPage( pParent, RID_SCPAGE_HFED_FR, rCoreSet,
346 //CHINA001 rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERRIGHT) )
347 //CHINA001 {}
348 //CHINA001
349 //CHINA001 // -----------------------------------------------------------------------
350 //CHINA001
351 //CHINA001 sal_uInt16* __EXPORT ScRightFooterEditPage::GetRanges()
352 //CHINA001 { return pPageRightFooterRanges; }
353 //CHINA001
354 //CHINA001 // -----------------------------------------------------------------------
355 //CHINA001
356 //CHINA001 SfxTabPage* __EXPORT ScRightFooterEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
357 //CHINA001 { return ( new ScRightFooterEditPage( pParent, rCoreSet ) ); };
358 //CHINA001
359 //CHINA001 //========================================================================
360 //CHINA001 // class ScLeftFooterEditPage
361 //CHINA001 //========================================================================
362 //CHINA001
363 //CHINA001 ScLeftFooterEditPage::ScLeftFooterEditPage( Window* pParent, const SfxItemSet& rCoreSet )
364 //CHINA001 : ScHFEditPage( pParent, RID_SCPAGE_HFED_FL, rCoreSet,
365 //CHINA001 rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERLEFT) )
366 //CHINA001 {}
367 //CHINA001
368 //CHINA001 // -----------------------------------------------------------------------
369 //CHINA001
370 //CHINA001 sal_uInt16* __EXPORT ScLeftFooterEditPage::GetRanges()
371 //CHINA001 { return pPageLeftFooterRanges; }
372 //CHINA001
373 //CHINA001 // -----------------------------------------------------------------------
374 //CHINA001
375 //CHINA001 SfxTabPage* __EXPORT ScLeftFooterEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
376 //CHINA001 { return ( new ScLeftFooterEditPage( pParent, rCoreSet ) ); };
377
378 //========================================================================
379
lcl_GetFieldData(ScHeaderFieldData & rData)380 void lcl_GetFieldData( ScHeaderFieldData& rData )
381 {
382 SfxViewShell* pShell = SfxViewShell::Current();
383 if (pShell)
384 {
385 if (pShell->ISA(ScTabViewShell))
386 ((ScTabViewShell*)pShell)->FillFieldData(rData);
387 else if (pShell->ISA(ScPreviewShell))
388 ((ScPreviewShell*)pShell)->FillFieldData(rData);
389 }
390 }
391
392 //========================================================================
393 // class ScEditWindow
394 //========================================================================
395
ScEditWindow(Window * pParent,const ResId & rResId,ScEditWindowLocation eLoc)396 ScEditWindow::ScEditWindow( Window* pParent, const ResId& rResId, ScEditWindowLocation eLoc )
397 : Control( pParent, rResId ),
398 eLocation(eLoc),
399 pAcc(NULL)
400 {
401 EnableRTL(sal_False);
402
403 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
404 Color aBgColor = rStyleSettings.GetWindowColor();
405
406 SetMapMode( MAP_TWIP );
407 SetPointer( POINTER_TEXT );
408 SetBackground( aBgColor );
409
410 Size aSize( GetOutputSize() );
411 aSize.Height() *= 4;
412
413 pEdEngine = new ScHeaderEditEngine( EditEngine::CreatePool(), sal_True );
414 pEdEngine->SetPaperSize( aSize );
415 pEdEngine->SetRefDevice( this );
416
417 ScHeaderFieldData aData;
418 lcl_GetFieldData( aData );
419
420 // Feldbefehle:
421 pEdEngine->SetData( aData );
422 pEdEngine->SetControlWord( pEdEngine->GetControlWord() | EE_CNTRL_MARKFIELDS );
423 mbRTL = ScGlobal::IsSystemRTL();
424 if (mbRTL)
425 pEdEngine->SetDefaultHorizontalTextDirection(EE_HTEXTDIR_R2L);
426
427 pEdView = new EditView( pEdEngine, this );
428 pEdView->SetOutputArea( Rectangle( Point(0,0), GetOutputSize() ) );
429
430 pEdView->SetBackgroundColor( aBgColor );
431 pEdEngine->InsertView( pEdView );
432 }
433
434 // -----------------------------------------------------------------------
435
~ScEditWindow()436 __EXPORT ScEditWindow::~ScEditWindow()
437 {
438 // delete Accessible object before deleting EditEngine and EditView
439 if (pAcc)
440 {
441 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xTemp = xAcc;
442 if (xTemp.is())
443 pAcc->dispose();
444 }
445 delete pEdEngine;
446 delete pEdView;
447 }
448
449 // -----------------------------------------------------------------------
450
SetNumType(SvxNumType eNumType)451 void ScEditWindow::SetNumType(SvxNumType eNumType)
452 {
453 pEdEngine->SetNumType(eNumType);
454 pEdEngine->UpdateFields();
455 }
456
457 // -----------------------------------------------------------------------
458
CreateTextObject()459 EditTextObject* __EXPORT ScEditWindow::CreateTextObject()
460 {
461 // wegen #38841# die Absatzattribute zuruecksetzen
462 // (GetAttribs beim Format-Dialog-Aufruf gibt immer gesetzte Items zurueck)
463
464 const SfxItemSet& rEmpty = pEdEngine->GetEmptyItemSet();
465 sal_uInt32 nParCnt = pEdEngine->GetParagraphCount();
466 for (sal_uInt32 i=0; i<nParCnt; i++)
467 pEdEngine->SetParaAttribs( i, rEmpty );
468
469 return pEdEngine->CreateTextObject();
470 }
471
472 // -----------------------------------------------------------------------
473
SetFont(const ScPatternAttr & rPattern)474 void ScEditWindow::SetFont( const ScPatternAttr& rPattern )
475 {
476 SfxItemSet* pSet = new SfxItemSet( pEdEngine->GetEmptyItemSet() );
477 rPattern.FillEditItemSet( pSet );
478 // FillEditItemSet adjusts font height to 1/100th mm,
479 // but for header/footer twips is needed, as in the PatternAttr:
480 pSet->Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
481 pSet->Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
482 pSet->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
483 if (mbRTL)
484 pSet->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
485 pEdEngine->SetDefaults( pSet );
486 }
487
488 // -----------------------------------------------------------------------
489
SetText(const EditTextObject & rTextObject)490 void ScEditWindow::SetText( const EditTextObject& rTextObject )
491 {
492 pEdEngine->SetText( rTextObject );
493 }
494
495 // -----------------------------------------------------------------------
496
InsertField(const SvxFieldItem & rFld)497 void ScEditWindow::InsertField( const SvxFieldItem& rFld )
498 {
499 pEdView->InsertField( rFld );
500 }
501
502 // -----------------------------------------------------------------------
503
SetCharAttriutes()504 void ScEditWindow::SetCharAttriutes()
505 {
506 SfxObjectShell* pDocSh = SfxObjectShell::Current();
507
508 SfxViewShell* pViewSh = SfxViewShell::Current();
509
510 ScTabViewShell* pTabViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
511
512
513 DBG_ASSERT( pDocSh, "Current DocShell not found" );
514 DBG_ASSERT( pViewSh, "Current ViewShell not found" );
515
516 if ( pDocSh && pViewSh )
517 {
518 if(pTabViewSh!=NULL) pTabViewSh->SetInFormatDialog(sal_True);
519
520 SfxItemSet aSet( pEdView->GetAttribs() );
521
522 //CHINA001 ScCharDlg* pDlg = new ScCharDlg( GetParent(), &aSet, pDocSh );
523 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
524 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
525
526 SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( GetParent(), &aSet,
527 pDocSh,RID_SCDLG_CHAR );
528 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
529 pDlg->SetText( ScGlobal::GetRscString( STR_TEXTATTRS ) );
530 if ( pDlg->Execute() == RET_OK )
531 {
532 aSet.ClearItem();
533 aSet.Put( *pDlg->GetOutputItemSet() );
534 pEdView->SetAttribs( aSet );
535 }
536
537 if(pTabViewSh!=NULL) pTabViewSh->SetInFormatDialog(sal_False);
538 delete pDlg;
539 }
540 }
541
542 // -----------------------------------------------------------------------
543
Paint(const Rectangle & rRec)544 void __EXPORT ScEditWindow::Paint( const Rectangle& rRec )
545 {
546 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
547 Color aBgColor = rStyleSettings.GetWindowColor();
548
549 pEdView->SetBackgroundColor( aBgColor );
550
551 SetBackground( aBgColor );
552
553 Control::Paint( rRec );
554
555 pEdView->Paint( rRec );
556 if( HasFocus() )
557 pEdView->ShowCursor(sal_True,sal_True);
558 }
559
560 // -----------------------------------------------------------------------
561
MouseMove(const MouseEvent & rMEvt)562 void __EXPORT ScEditWindow::MouseMove( const MouseEvent& rMEvt )
563 {
564 pEdView->MouseMove( rMEvt );
565 }
566
567 // -----------------------------------------------------------------------
568
MouseButtonDown(const MouseEvent & rMEvt)569 void __EXPORT ScEditWindow::MouseButtonDown( const MouseEvent& rMEvt )
570 {
571 if ( !HasFocus() )
572 GrabFocus();
573
574 pEdView->MouseButtonDown( rMEvt );
575 }
576
577 // -----------------------------------------------------------------------
578
MouseButtonUp(const MouseEvent & rMEvt)579 void __EXPORT ScEditWindow::MouseButtonUp( const MouseEvent& rMEvt )
580 {
581 pEdView->MouseButtonUp( rMEvt );
582 }
583
584 // -----------------------------------------------------------------------
585
KeyInput(const KeyEvent & rKEvt)586 void __EXPORT ScEditWindow::KeyInput( const KeyEvent& rKEvt )
587 {
588 sal_uInt16 nKey = rKEvt.GetKeyCode().GetModifier()
589 + rKEvt.GetKeyCode().GetCode();
590
591 if ( nKey == KEY_TAB || nKey == KEY_TAB + KEY_SHIFT )
592 {
593 Control::KeyInput( rKEvt );
594 }
595 else if ( !pEdView->PostKeyEvent( rKEvt ) )
596 {
597 Control::KeyInput( rKEvt );
598 }
599 else if ( !rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsShift() &&
600 rKEvt.GetKeyCode().IsMod2() && rKEvt.GetKeyCode().GetCode() == KEY_DOWN )
601 {
602 if (aObjectSelectLink.IsSet() )
603 aObjectSelectLink.Call(this);
604 }
605 }
606
607 // -----------------------------------------------------------------------
608
Command(const CommandEvent & rCEvt)609 void ScEditWindow::Command( const CommandEvent& rCEvt )
610 {
611 pEdView->Command( rCEvt );
612 }
613
614 // -----------------------------------------------------------------------
615
GetFocus()616 void __EXPORT ScEditWindow::GetFocus()
617 {
618 pEdView->ShowCursor(sal_True,sal_True);
619 pActiveEdWnd = this;
620
621 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xTemp = xAcc;
622 if (xTemp.is() && pAcc)
623 {
624 pAcc->GotFocus();
625 }
626 else
627 pAcc = NULL;
628 }
629
LoseFocus()630 void __EXPORT ScEditWindow::LoseFocus()
631 {
632 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xTemp = xAcc;
633 if (xTemp.is() && pAcc)
634 {
635 pAcc->LostFocus();
636 }
637 else
638 pAcc = NULL;
639 }
640
641 // -----------------------------------------------------------------------
642
CreateAccessible()643 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ScEditWindow::CreateAccessible()
644 {
645 String sName;
646 String sDescription(GetHelpText());
647 switch (eLocation)
648 {
649 case Left:
650 {
651 sName = String(ScResId(STR_ACC_LEFTAREA_NAME));
652 // sDescription = String(ScResId(STR_ACC_LEFTAREA_DESCR));
653 }
654 break;
655 case Center:
656 {
657 sName = String(ScResId(STR_ACC_CENTERAREA_NAME));
658 // sDescription = String(ScResId(STR_ACC_CENTERAREA_DESCR));
659 }
660 break;
661 case Right:
662 {
663 sName = String(ScResId(STR_ACC_RIGHTAREA_NAME));
664 // sDescription = String(ScResId(STR_ACC_RIGHTAREA_DESCR));
665 }
666 break;
667 }
668 pAcc = new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), pEdView, this,
669 rtl::OUString(sName), rtl::OUString(sDescription), EditControl);
670 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible = pAcc;
671 xAcc = xAccessible;
672 return pAcc;
673 }
674
675 /*
676 class ScExtIButton : public ImageButton
677 {
678 private:
679
680 Timer aTimer;
681 ScPopupMenu* pPopupMenu;
682
683 DECL_LINK( TimerHdl, Timer*);
684
685 void DrawArrow();
686
687 protected:
688
689 virtual void MouseButtonDown( const MouseEvent& rMEvt );
690 virtual void MouseButtonUp( const MouseEvent& rMEvt);
691
692 virtual void StartPopup();
693
694 public:
695
696 ScExtIButton(Window* pParent, const ResId& rResId );
697
698 void SetPopupMenu(ScPopupMenu* pPopUp);
699
700 sal_uInt16 GetSelected();
701
702 void SetMenuHdl( const Link& rLink ) { aFxLink = rLink; }
703 const Link& GetMenuHdl() const { return aFxLink; }
704
705 }
706 */
ScExtIButton(Window * pParent,const ResId & rResId)707 ScExtIButton::ScExtIButton(Window* pParent, const ResId& rResId )
708 : ImageButton(pParent,rResId),
709 pPopupMenu(NULL)
710 {
711 nSelected=0;
712 aTimer.SetTimeout(600);
713 SetDropDown( sal_True);
714
715 // DrawArrow();
716 }
717
SetPopupMenu(ScPopupMenu * pPopUp)718 void ScExtIButton::SetPopupMenu(ScPopupMenu* pPopUp)
719 {
720 pPopupMenu=pPopUp;
721 }
722
GetSelected()723 sal_uInt16 ScExtIButton::GetSelected()
724 {
725 return nSelected;
726 }
727
MouseButtonDown(const MouseEvent & rMEvt)728 void ScExtIButton::MouseButtonDown( const MouseEvent& rMEvt )
729 {
730 if(!aTimer.IsActive())
731 {
732 aTimer.Start();
733 aTimer.SetTimeoutHdl(LINK( this, ScExtIButton, TimerHdl));
734 }
735
736 ImageButton::MouseButtonDown(rMEvt );
737 }
MouseButtonUp(const MouseEvent & rMEvt)738 void ScExtIButton::MouseButtonUp( const MouseEvent& rMEvt)
739 {
740 aTimer.Stop();
741 aTimer.SetTimeoutHdl(Link());
742 ImageButton::MouseButtonUp(rMEvt );
743 }
744
Click()745 void ScExtIButton::Click()
746 {
747 aTimer.Stop();
748 aTimer.SetTimeoutHdl(Link());
749 ImageButton::Click();
750 }
751
StartPopup()752 void ScExtIButton::StartPopup()
753 {
754 nSelected=0;
755
756 if(pPopupMenu!=NULL)
757 {
758 SetPressed( sal_True );
759 EndSelection();
760 Point aPoint(0,0);
761 aPoint.Y()=GetOutputSizePixel().Height();
762
763 nSelected=pPopupMenu->Execute( this, aPoint );
764
765 if(nSelected)
766 {
767 aMLink.Call(this);
768 }
769 SetPressed( sal_False);
770 }
771 }
772
PreNotify(NotifyEvent & rNEvt)773 long ScExtIButton::PreNotify( NotifyEvent& rNEvt )
774 {
775 sal_uInt16 nSwitch=rNEvt.GetType();
776 if(nSwitch==EVENT_MOUSEBUTTONUP)
777 {
778 MouseButtonUp(*rNEvt.GetMouseEvent());
779 }
780
781 return ImageButton::PreNotify(rNEvt );
782 }
783
IMPL_LINK(ScExtIButton,TimerHdl,Timer *,EMPTYARG)784 IMPL_LINK( ScExtIButton, TimerHdl, Timer*, EMPTYARG )
785 {
786 StartPopup();
787 return 0;
788 }
789
790 /*
791 static void ImplDrawToolArrow( ToolBox* pBox, long nX, long nY, sal_Bool bBlack,
792 sal_Bool bLeft = sal_False, sal_Bool bTop = sal_False )
793 {
794 Color aOldFillColor = pBox->GetFillColor();
795 WindowAlign eAlign = pBox->meAlign;
796 if ( bLeft )
797 eAlign = WINDOWALIGN_RIGHT;
798 else if ( bTop )
799 eAlign = WINDOWALIGN_BOTTOM;
800
801 switch ( eAlign )
802 {
803 case WINDOWALIGN_LEFT:
804 if ( bBlack )
805 pBox->SetFillColor( Color( COL_BLACK ) );
806 pBox->DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
807 pBox->DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
808 pBox->DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
809 pBox->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
810 if ( bBlack )
811 {
812 pBox->SetFillColor( aOldFillColor );
813 pBox->DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
814 pBox->DrawRect( Rectangle( nX+2, nY+3, nX+2, nY+3 ) );
815 }
816 break;
817 case WINDOWALIGN_TOP:
818 if ( bBlack )
819 pBox->SetFillColor( Color( COL_BLACK ) );
820 pBox->DrawRect( Rectangle( nX+0, nY+0, nX+6, nY+0 ) );
821 pBox->DrawRect( Rectangle( nX+1, nY+1, nX+5, nY+1 ) );
822 pBox->DrawRect( Rectangle( nX+2, nY+2, nX+4, nY+2 ) );
823 pBox->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
824 if ( bBlack )
825 {
826 pBox->SetFillColor( aOldFillColor );
827 pBox->DrawRect( Rectangle( nX+2, nY+1, nX+4, nY+1 ) );
828 pBox->DrawRect( Rectangle( nX+3, nY+2, nX+3, nY+2 ) );
829 }
830 break;
831 case WINDOWALIGN_RIGHT:
832 if ( bBlack )
833 pBox->SetFillColor( Color( COL_BLACK ) );
834 pBox->DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
835 pBox->DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
836 pBox->DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
837 pBox->DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
838 if ( bBlack )
839 {
840 pBox->SetFillColor( aOldFillColor );
841 pBox->DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
842 pBox->DrawRect( Rectangle( nX+1, nY+3, nX+1, nY+3 ) );
843 }
844 break;
845 case WINDOWALIGN_BOTTOM:
846 if ( bBlack )
847 pBox->SetFillColor( Color( COL_BLACK ) );
848 pBox->DrawRect( Rectangle( nX+0, nY+3, nX+6, nY+3 ) );
849 pBox->DrawRect( Rectangle( nX+1, nY+2, nX+5, nY+2 ) );
850 pBox->DrawRect( Rectangle( nX+2, nY+1, nX+4, nY+1 ) );
851 pBox->DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+0 ) );
852 if ( bBlack )
853 {
854 pBox->SetFillColor( aOldFillColor );
855 pBox->DrawRect( Rectangle( nX+2, nY+2, nX+4, nY+2 ) );
856 pBox->DrawRect( Rectangle( nX+3, nY+1, nX+3, nY+1 ) );
857 }
858 break;
859 }
860 }
861 Down
862 - Timer starten
863
864 Click
865 - Timer abbrechen
866
867 Timer
868 if ( ??? )
869 {
870 - SetPressed( sal_True );
871 - EndSelection();
872 - Menu anzeigen
873 - SetPressed( sal_False );
874 }
875
876
877 */
878
879
880