1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tphfedit.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 //------------------------------------------------------------------
39 #include "scitems.hxx"
40 #include <svx/eeitem.hxx>
43 //CHINA001 #include <svx/chardlg.hxx>
44 #include <svx/editobj.hxx>
45 #include <svx/editstat.hxx>
46 #include <svx/editview.hxx>
47 #include <svx/flditem.hxx>
48 #include <svx/adjitem.hxx>
49 #include <sfx2/basedlgs.hxx>
50 #include <sfx2/objsh.hxx>
51 #include <vcl/msgbox.hxx>
52 #include <vcl/svapp.hxx>
54 #include "tphfedit.hxx"
55 #include "editutil.hxx"
58 #include "patattr.hxx"
59 #include "scresid.hxx"
61 #include "globstr.hrc"
62 #include "tabvwsh.hxx"
63 #include "prevwsh.hxx"
64 #include "hfedtdlg.hrc"
65 //CHINA001 #include "textdlgs.hxx"
66 #include "AccessibleEditObject.hxx"
68 #include "scabstdlg.hxx" //CHINA001
71 // STATIC DATA -----------------------------------------------------------
72 static ScEditWindow
* pActiveEdWnd
= NULL
;
74 ScEditWindow
* GetScEditWindow ()
80 //CHINA001 static USHORT pPageRightHeaderRanges[] = { SID_SCATTR_PAGE_HEADERRIGHT,
81 //CHINA001 SID_SCATTR_PAGE_HEADERRIGHT,
84 //CHINA001 static USHORT pPageRightFooterRanges[] = { SID_SCATTR_PAGE_FOOTERRIGHT,
85 //CHINA001 SID_SCATTR_PAGE_FOOTERRIGHT,
88 //CHINA001 static USHORT pPageLeftHeaderRanges[] = { SID_SCATTR_PAGE_HEADERLEFT,
89 //CHINA001 SID_SCATTR_PAGE_HEADERLEFT,
92 //CHINA001 static USHORT pPageLeftFooterRanges[] = { SID_SCATTR_PAGE_FOOTERLEFT,
93 //CHINA001 SID_SCATTR_PAGE_FOOTERLEFT,
96 //CHINA001 static ScEditWindow* pActiveEdWnd = NULL;
100 //CHINA001 //========================================================================
101 //CHINA001 // class ScHFEditPage
104 //CHINA001 ScHFEditPage::ScHFEditPage( Window* pParent,
105 //CHINA001 USHORT nResId,
106 //CHINA001 const SfxItemSet& rCoreAttrs,
107 //CHINA001 USHORT nWhichId )
109 //CHINA001 : SfxTabPage ( pParent, ScResId( nResId ), rCoreAttrs ),
111 //CHINA001 aWndLeft ( this, ScResId( WND_LEFT ), Left ),
112 //CHINA001 aWndCenter ( this, ScResId( WND_CENTER ), Center ),
113 //CHINA001 aWndRight ( this, ScResId( WND_RIGHT ), Right ),
114 //CHINA001 aFtLeft ( this, ScResId( FT_LEFT ) ),
115 //CHINA001 aFtCenter ( this, ScResId( FT_CENTER ) ),
116 //CHINA001 aFtRight ( this, ScResId( FT_RIGHT ) ),
117 //CHINA001 aFlInfo ( this, ScResId( FL_INFO ) ),
118 //CHINA001 aFtInfo ( this, ScResId( FT_INFO ) ),
119 //CHINA001 aBtnText ( this, ScResId( BTN_TEXT ) ),
120 //CHINA001 aBtnPage ( this, ScResId( BTN_PAGE ) ),
121 //CHINA001 aBtnLastPage ( this, ScResId( BTN_PAGES ) ),
122 //CHINA001 aBtnDate ( this, ScResId( BTN_DATE ) ),
123 //CHINA001 aBtnTime ( this, ScResId( BTN_TIME ) ),
124 //CHINA001 aBtnFile ( this, ScResId( BTN_FILE ) ),
125 //CHINA001 aBtnTable ( this, ScResId( BTN_TABLE ) ),
126 //CHINA001 aPopUpFile ( ScResId( RID_POPUP_FCOMMAND) ),
127 //CHINA001 nWhich ( nWhichId )
129 //CHINA001 //! use default style from current document?
130 //CHINA001 //! if font color is used, header/footer background color must be set
132 //CHINA001 ScPatternAttr aPatAttr( rCoreAttrs.GetPool() );
134 //CHINA001 aBtnFile.SetPopupMenu(&aPopUpFile);
136 //CHINA001 aBtnFile.SetMenuHdl( LINK( this, ScHFEditPage, MenuHdl ) );
137 //CHINA001 aBtnText .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
138 //CHINA001 aBtnPage .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
139 //CHINA001 aBtnLastPage.SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
140 //CHINA001 aBtnDate .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
141 //CHINA001 aBtnTime .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
142 //CHINA001 aBtnFile .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
143 //CHINA001 aBtnTable .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
145 //CHINA001 aBtnText .SetModeImage( Image( ScResId( IMG_TEXT_H ) ), BMP_COLOR_HIGHCONTRAST );
146 //CHINA001 aBtnFile .SetModeImage( Image( ScResId( IMG_FILE_H ) ), BMP_COLOR_HIGHCONTRAST );
147 //CHINA001 aBtnTable .SetModeImage( Image( ScResId( IMG_TABLE_H ) ), BMP_COLOR_HIGHCONTRAST );
148 //CHINA001 aBtnPage .SetModeImage( Image( ScResId( IMG_PAGE_H ) ), BMP_COLOR_HIGHCONTRAST );
149 //CHINA001 aBtnLastPage.SetModeImage( Image( ScResId( IMG_PAGES_H ) ), BMP_COLOR_HIGHCONTRAST );
150 //CHINA001 aBtnDate .SetModeImage( Image( ScResId( IMG_DATE_H ) ), BMP_COLOR_HIGHCONTRAST );
151 //CHINA001 aBtnTime .SetModeImage( Image( ScResId( IMG_TIME_H ) ), BMP_COLOR_HIGHCONTRAST );
153 //CHINA001 aWndLeft. SetFont( aPatAttr );
154 //CHINA001 aWndCenter. SetFont( aPatAttr );
155 //CHINA001 aWndRight. SetFont( aPatAttr );
157 //CHINA001 FillCmdArr();
159 //CHINA001 aWndLeft.GrabFocus();
161 //CHINA001 FreeResource();
164 //CHINA001 // -----------------------------------------------------------------------
166 //CHINA001 __EXPORT ScHFEditPage::~ScHFEditPage()
170 //CHINA001 void ScHFEditPage::SetNumType(SvxNumType eNumType)
172 //CHINA001 aWndLeft.SetNumType(eNumType);
173 //CHINA001 aWndCenter.SetNumType(eNumType);
174 //CHINA001 aWndRight.SetNumType(eNumType);
177 //CHINA001 // -----------------------------------------------------------------------
179 //CHINA001 #define IS_AVAILABLE(w)(rCoreSet.GetItemState( (w) ) >= SFX_ITEM_AVAILABLE)
181 //CHINA001 void __EXPORT ScHFEditPage::Reset( const SfxItemSet& rCoreSet )
183 //CHINA001 if ( IS_AVAILABLE( nWhich ) )
185 //CHINA001 const ScPageHFItem& rItem = (const ScPageHFItem&)(rCoreSet.Get( nWhich ));
187 //CHINA001 const EditTextObject* pLeft = rItem.GetLeftArea();
188 //CHINA001 const EditTextObject* pCenter = rItem.GetCenterArea();
189 //CHINA001 const EditTextObject* pRight = rItem.GetRightArea();
191 //CHINA001 if ( pLeft && pCenter && pRight )
193 //CHINA001 aWndLeft .SetText( *pLeft );
194 //CHINA001 aWndCenter .SetText( *pCenter );
195 //CHINA001 aWndRight .SetText( *pRight );
200 //CHINA001 #undef IS_AVAILABLE
202 //CHINA001 // -----------------------------------------------------------------------
204 //CHINA001 BOOL __EXPORT ScHFEditPage::FillItemSet( SfxItemSet& rCoreSet )
206 //CHINA001 ScPageHFItem aItem( nWhich );
207 //CHINA001 EditTextObject* pLeft = aWndLeft .CreateTextObject();
208 //CHINA001 EditTextObject* pCenter = aWndCenter.CreateTextObject();
209 //CHINA001 EditTextObject* pRight = aWndRight .CreateTextObject();
211 //CHINA001 aItem.SetLeftArea ( *pLeft );
212 //CHINA001 aItem.SetCenterArea( *pCenter );
213 //CHINA001 aItem.SetRightArea ( *pRight );
214 //CHINA001 delete pLeft;
215 //CHINA001 delete pCenter;
216 //CHINA001 delete pRight;
218 //CHINA001 rCoreSet.Put( aItem );
220 //CHINA001 return TRUE;
223 //CHINA001 // -----------------------------------------------------------------------
225 //CHINA001 #define SET_CMD(i,id) x
226 //CHINA001 aCmd = aDel; x
227 //CHINA001 aCmd += ScGlobal::GetRscString( id ); x
228 //CHINA001 aCmd += aDel; x
229 //CHINA001 aCmdArr[i] = aCmd;
231 //CHINA001 // -----------------------------------------------------------------------
233 //CHINA001 void ScHFEditPage::FillCmdArr()
235 //CHINA001 String aDel( ScGlobal::GetRscString( STR_HFCMD_DELIMITER ) );
236 //CHINA001 String aCmd;
238 //CHINA001 SET_CMD( 0, STR_HFCMD_PAGE )
239 //CHINA001 SET_CMD( 1, STR_HFCMD_PAGES )
240 //CHINA001 SET_CMD( 2, STR_HFCMD_DATE )
241 //CHINA001 SET_CMD( 3, STR_HFCMD_TIME )
242 //CHINA001 SET_CMD( 4, STR_HFCMD_FILE )
243 //CHINA001 SET_CMD( 5, STR_HFCMD_TABLE )
246 //CHINA001 #undef SET_CMD
248 //CHINA001 //-----------------------------------------------------------------------
249 //CHINA001 // Handler:
250 //CHINA001 //-----------------------------------------------------------------------
252 //CHINA001 IMPL_LINK( ScHFEditPage, ClickHdl, ImageButton*, pBtn )
254 //CHINA001 if ( !pActiveEdWnd )
257 //CHINA001 if ( pBtn == &aBtnText )
259 //CHINA001 pActiveEdWnd->SetCharAttriutes();
263 //CHINA001 if ( pBtn == &aBtnPage )
264 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxPageField()) );
265 //CHINA001 else if ( pBtn == &aBtnLastPage )
266 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxPagesField()) );
267 //CHINA001 else if ( pBtn == &aBtnDate )
268 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR)) );
269 //CHINA001 else if ( pBtn == &aBtnTime )
270 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxTimeField()) );
271 //CHINA001 else if ( pBtn == &aBtnFile )
273 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField() ) );
275 //CHINA001 else if ( pBtn == &aBtnTable )
276 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem(SvxTableField()) );
278 //CHINA001 pActiveEdWnd->GrabFocus();
283 //CHINA001 IMPL_LINK( ScHFEditPage, MenuHdl, ScExtIButton*, pBtn )
285 //CHINA001 if ( !pActiveEdWnd )
288 //CHINA001 if(pBtn!=NULL)
290 //CHINA001 switch(pBtn->GetSelected())
292 //CHINA001 case FILE_COMMAND_TITEL:
293 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField() ) );
295 //CHINA001 case FILE_COMMAND_FILENAME:
296 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
297 //CHINA001 EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_NAME_EXT ) ) );
299 //CHINA001 case FILE_COMMAND_PATH:
300 //CHINA001 pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
301 //CHINA001 EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ) ) );
308 //CHINA001 //========================================================================
309 //CHINA001 // class ScRightHeaderEditPage
310 //CHINA001 //========================================================================
312 //CHINA001 ScRightHeaderEditPage::ScRightHeaderEditPage( Window* pParent, const SfxItemSet& rCoreSet )
313 //CHINA001 : ScHFEditPage( pParent, RID_SCPAGE_HFED_HR, rCoreSet,
314 //CHINA001 rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERRIGHT) )
317 //CHINA001 // -----------------------------------------------------------------------
319 //CHINA001 USHORT* __EXPORT ScRightHeaderEditPage::GetRanges()
320 //CHINA001 { return pPageRightHeaderRanges; }
322 //CHINA001 // -----------------------------------------------------------------------
324 //CHINA001 SfxTabPage* __EXPORT ScRightHeaderEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
325 //CHINA001 { return ( new ScRightHeaderEditPage( pParent, rCoreSet ) ); };
328 //CHINA001 //========================================================================
329 //CHINA001 // class ScLeftHeaderEditPage
330 //CHINA001 //========================================================================
332 //CHINA001 ScLeftHeaderEditPage::ScLeftHeaderEditPage( Window* pParent, const SfxItemSet& rCoreSet )
333 //CHINA001 : ScHFEditPage( pParent, RID_SCPAGE_HFED_HL, rCoreSet,
334 //CHINA001 rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERLEFT) )
337 //CHINA001 // -----------------------------------------------------------------------
339 //CHINA001 USHORT* __EXPORT ScLeftHeaderEditPage::GetRanges()
340 //CHINA001 { return pPageLeftHeaderRanges; }
342 //CHINA001 // -----------------------------------------------------------------------
344 //CHINA001 SfxTabPage* __EXPORT ScLeftHeaderEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
345 //CHINA001 { return ( new ScLeftHeaderEditPage( pParent, rCoreSet ) ); };
347 //CHINA001 //========================================================================
348 //CHINA001 // class ScRightFooterEditPage
349 //CHINA001 //========================================================================
351 //CHINA001 ScRightFooterEditPage::ScRightFooterEditPage( Window* pParent, const SfxItemSet& rCoreSet )
352 //CHINA001 : ScHFEditPage( pParent, RID_SCPAGE_HFED_FR, rCoreSet,
353 //CHINA001 rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERRIGHT) )
356 //CHINA001 // -----------------------------------------------------------------------
358 //CHINA001 USHORT* __EXPORT ScRightFooterEditPage::GetRanges()
359 //CHINA001 { return pPageRightFooterRanges; }
361 //CHINA001 // -----------------------------------------------------------------------
363 //CHINA001 SfxTabPage* __EXPORT ScRightFooterEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
364 //CHINA001 { return ( new ScRightFooterEditPage( pParent, rCoreSet ) ); };
366 //CHINA001 //========================================================================
367 //CHINA001 // class ScLeftFooterEditPage
368 //CHINA001 //========================================================================
370 //CHINA001 ScLeftFooterEditPage::ScLeftFooterEditPage( Window* pParent, const SfxItemSet& rCoreSet )
371 //CHINA001 : ScHFEditPage( pParent, RID_SCPAGE_HFED_FL, rCoreSet,
372 //CHINA001 rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERLEFT) )
375 //CHINA001 // -----------------------------------------------------------------------
377 //CHINA001 USHORT* __EXPORT ScLeftFooterEditPage::GetRanges()
378 //CHINA001 { return pPageLeftFooterRanges; }
380 //CHINA001 // -----------------------------------------------------------------------
382 //CHINA001 SfxTabPage* __EXPORT ScLeftFooterEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
383 //CHINA001 { return ( new ScLeftFooterEditPage( pParent, rCoreSet ) ); };
385 //========================================================================
387 void lcl_GetFieldData( ScHeaderFieldData
& rData
)
389 SfxViewShell
* pShell
= SfxViewShell::Current();
392 if (pShell
->ISA(ScTabViewShell
))
393 ((ScTabViewShell
*)pShell
)->FillFieldData(rData
);
394 else if (pShell
->ISA(ScPreviewShell
))
395 ((ScPreviewShell
*)pShell
)->FillFieldData(rData
);
399 //========================================================================
400 // class ScEditWindow
401 //========================================================================
403 ScEditWindow::ScEditWindow( Window
* pParent
, const ResId
& rResId
, ScEditWindowLocation eLoc
)
404 : Control( pParent
, rResId
),
410 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
411 Color aBgColor
= rStyleSettings
.GetWindowColor();
413 SetMapMode( MAP_TWIP
);
414 SetPointer( POINTER_TEXT
);
415 SetBackground( aBgColor
);
417 Size
aSize( GetOutputSize() );
420 pEdEngine
= new ScHeaderEditEngine( EditEngine::CreatePool(), TRUE
);
421 pEdEngine
->SetPaperSize( aSize
);
422 pEdEngine
->SetRefDevice( this );
424 ScHeaderFieldData aData
;
425 lcl_GetFieldData( aData
);
428 pEdEngine
->SetData( aData
);
429 pEdEngine
->SetControlWord( pEdEngine
->GetControlWord() | EE_CNTRL_MARKFIELDS
);
430 mbRTL
= ScGlobal::IsSystemRTL();
432 pEdEngine
->SetDefaultHorizontalTextDirection(EE_HTEXTDIR_R2L
);
434 pEdView
= new EditView( pEdEngine
, this );
435 pEdView
->SetOutputArea( Rectangle( Point(0,0), GetOutputSize() ) );
437 pEdView
->SetBackgroundColor( aBgColor
);
438 pEdEngine
->InsertView( pEdView
);
441 // -----------------------------------------------------------------------
443 __EXPORT
ScEditWindow::~ScEditWindow()
445 // delete Accessible object before deleting EditEngine and EditView
448 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> xTemp
= xAcc
;
456 // -----------------------------------------------------------------------
458 void ScEditWindow::SetNumType(SvxNumType eNumType
)
460 pEdEngine
->SetNumType(eNumType
);
461 pEdEngine
->UpdateFields();
464 // -----------------------------------------------------------------------
466 EditTextObject
* __EXPORT
ScEditWindow::CreateTextObject()
468 // wegen #38841# die Absatzattribute zuruecksetzen
469 // (GetAttribs beim Format-Dialog-Aufruf gibt immer gesetzte Items zurueck)
471 const SfxItemSet
& rEmpty
= pEdEngine
->GetEmptyItemSet();
472 USHORT nParCnt
= pEdEngine
->GetParagraphCount();
473 for (USHORT i
=0; i
<nParCnt
; i
++)
474 pEdEngine
->SetParaAttribs( i
, rEmpty
);
476 return pEdEngine
->CreateTextObject();
479 // -----------------------------------------------------------------------
481 void ScEditWindow::SetFont( const ScPatternAttr
& rPattern
)
483 SfxItemSet
* pSet
= new SfxItemSet( pEdEngine
->GetEmptyItemSet() );
484 rPattern
.FillEditItemSet( pSet
);
485 // FillEditItemSet adjusts font height to 1/100th mm,
486 // but for header/footer twips is needed, as in the PatternAttr:
487 pSet
->Put( rPattern
.GetItem(ATTR_FONT_HEIGHT
), EE_CHAR_FONTHEIGHT
);
488 pSet
->Put( rPattern
.GetItem(ATTR_CJK_FONT_HEIGHT
), EE_CHAR_FONTHEIGHT_CJK
);
489 pSet
->Put( rPattern
.GetItem(ATTR_CTL_FONT_HEIGHT
), EE_CHAR_FONTHEIGHT_CTL
);
491 pSet
->Put( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
492 pEdEngine
->SetDefaults( pSet
);
495 // -----------------------------------------------------------------------
497 void ScEditWindow::SetText( const EditTextObject
& rTextObject
)
499 pEdEngine
->SetText( rTextObject
);
502 // -----------------------------------------------------------------------
504 void ScEditWindow::InsertField( const SvxFieldItem
& rFld
)
506 pEdView
->InsertField( rFld
);
509 // -----------------------------------------------------------------------
511 void ScEditWindow::SetCharAttriutes()
513 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
515 SfxViewShell
* pViewSh
= SfxViewShell::Current();
517 ScTabViewShell
* pTabViewSh
= PTR_CAST(ScTabViewShell
, SfxViewShell::Current());
520 DBG_ASSERT( pDocSh
, "Current DocShell not found" );
521 DBG_ASSERT( pViewSh
, "Current ViewShell not found" );
523 if ( pDocSh
&& pViewSh
)
525 if(pTabViewSh
!=NULL
) pTabViewSh
->SetInFormatDialog(TRUE
);
527 SfxItemSet
aSet( pEdView
->GetAttribs() );
529 //CHINA001 ScCharDlg* pDlg = new ScCharDlg( GetParent(), &aSet, pDocSh );
530 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
531 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
533 SfxAbstractTabDialog
* pDlg
= pFact
->CreateScCharDlg( GetParent(), &aSet
,
534 pDocSh
,RID_SCDLG_CHAR
);
535 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
536 pDlg
->SetText( ScGlobal::GetRscString( STR_TEXTATTRS
) );
537 if ( pDlg
->Execute() == RET_OK
)
540 aSet
.Put( *pDlg
->GetOutputItemSet() );
541 pEdView
->SetAttribs( aSet
);
544 if(pTabViewSh
!=NULL
) pTabViewSh
->SetInFormatDialog(FALSE
);
549 // -----------------------------------------------------------------------
551 void __EXPORT
ScEditWindow::Paint( const Rectangle
& rRec
)
553 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
554 Color aBgColor
= rStyleSettings
.GetWindowColor();
556 pEdView
->SetBackgroundColor( aBgColor
);
558 SetBackground( aBgColor
);
560 Control::Paint( rRec
);
562 pEdView
->Paint( rRec
);
565 // -----------------------------------------------------------------------
567 void __EXPORT
ScEditWindow::MouseMove( const MouseEvent
& rMEvt
)
569 pEdView
->MouseMove( rMEvt
);
572 // -----------------------------------------------------------------------
574 void __EXPORT
ScEditWindow::MouseButtonDown( const MouseEvent
& rMEvt
)
579 pEdView
->MouseButtonDown( rMEvt
);
582 // -----------------------------------------------------------------------
584 void __EXPORT
ScEditWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
586 pEdView
->MouseButtonUp( rMEvt
);
589 // -----------------------------------------------------------------------
591 void __EXPORT
ScEditWindow::KeyInput( const KeyEvent
& rKEvt
)
593 USHORT nKey
= rKEvt
.GetKeyCode().GetModifier()
594 + rKEvt
.GetKeyCode().GetCode();
596 if ( nKey
== KEY_TAB
|| nKey
== KEY_TAB
+ KEY_SHIFT
)
598 Control::KeyInput( rKEvt
);
600 else if ( !pEdView
->PostKeyEvent( rKEvt
) )
602 Control::KeyInput( rKEvt
);
606 // -----------------------------------------------------------------------
608 void ScEditWindow::Command( const CommandEvent
& rCEvt
)
610 pEdView
->Command( rCEvt
);
613 // -----------------------------------------------------------------------
615 void __EXPORT
ScEditWindow::GetFocus()
619 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> xTemp
= xAcc
;
620 if (xTemp
.is() && pAcc
)
628 void __EXPORT
ScEditWindow::LoseFocus()
630 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> xTemp
= xAcc
;
631 if (xTemp
.is() && pAcc
)
639 // -----------------------------------------------------------------------
641 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> ScEditWindow::CreateAccessible()
644 String
sDescription(GetHelpText());
649 sName
= String(ScResId(STR_ACC_LEFTAREA_NAME
));
650 // sDescription = String(ScResId(STR_ACC_LEFTAREA_DESCR));
655 sName
= String(ScResId(STR_ACC_CENTERAREA_NAME
));
656 // sDescription = String(ScResId(STR_ACC_CENTERAREA_DESCR));
661 sName
= String(ScResId(STR_ACC_RIGHTAREA_NAME
));
662 // sDescription = String(ScResId(STR_ACC_RIGHTAREA_DESCR));
666 pAcc
= new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), pEdView
, this,
667 rtl::OUString(sName
), rtl::OUString(sDescription
), EditControl
);
668 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> xAccessible
= pAcc
;
674 class ScExtIButton : public ImageButton
679 ScPopupMenu* pPopupMenu;
681 DECL_LINK( TimerHdl, Timer*);
687 virtual void MouseButtonDown( const MouseEvent& rMEvt );
688 virtual void MouseButtonUp( const MouseEvent& rMEvt);
690 virtual void StartPopup();
694 ScExtIButton(Window* pParent, const ResId& rResId );
696 void SetPopupMenu(ScPopupMenu* pPopUp);
698 USHORT GetSelected();
700 void SetMenuHdl( const Link& rLink ) { aFxLink = rLink; }
701 const Link& GetMenuHdl() const { return aFxLink; }
705 ScExtIButton::ScExtIButton(Window
* pParent
, const ResId
& rResId
)
706 : ImageButton(pParent
,rResId
),
710 aTimer
.SetTimeout(600);
716 void ScExtIButton::SetPopupMenu(ScPopupMenu
* pPopUp
)
721 USHORT
ScExtIButton::GetSelected()
726 void ScExtIButton::MouseButtonDown( const MouseEvent
& rMEvt
)
728 if(!aTimer
.IsActive())
731 aTimer
.SetTimeoutHdl(LINK( this, ScExtIButton
, TimerHdl
));
734 ImageButton::MouseButtonDown(rMEvt
);
736 void ScExtIButton::MouseButtonUp( const MouseEvent
& rMEvt
)
739 aTimer
.SetTimeoutHdl(Link());
740 ImageButton::MouseButtonUp(rMEvt
);
743 void ScExtIButton::Click()
746 aTimer
.SetTimeoutHdl(Link());
747 ImageButton::Click();
750 void ScExtIButton::StartPopup()
759 aPoint
.Y()=GetOutputSizePixel().Height();
761 nSelected
=pPopupMenu
->Execute( this, aPoint
);
771 long ScExtIButton::PreNotify( NotifyEvent
& rNEvt
)
773 USHORT nSwitch
=rNEvt
.GetType();
774 if(nSwitch
==EVENT_MOUSEBUTTONUP
)
776 MouseButtonUp(*rNEvt
.GetMouseEvent());
779 return ImageButton::PreNotify(rNEvt
);
782 IMPL_LINK( ScExtIButton
, TimerHdl
, Timer
*, EMPTYARG
)
789 static void ImplDrawToolArrow( ToolBox* pBox, long nX, long nY, BOOL bBlack,
790 BOOL bLeft = FALSE, BOOL bTop = FALSE )
792 Color aOldFillColor = pBox->GetFillColor();
793 WindowAlign eAlign = pBox->meAlign;
795 eAlign = WINDOWALIGN_RIGHT;
797 eAlign = WINDOWALIGN_BOTTOM;
801 case WINDOWALIGN_LEFT:
803 pBox->SetFillColor( Color( COL_BLACK ) );
804 pBox->DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
805 pBox->DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
806 pBox->DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
807 pBox->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
810 pBox->SetFillColor( aOldFillColor );
811 pBox->DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
812 pBox->DrawRect( Rectangle( nX+2, nY+3, nX+2, nY+3 ) );
815 case WINDOWALIGN_TOP:
817 pBox->SetFillColor( Color( COL_BLACK ) );
818 pBox->DrawRect( Rectangle( nX+0, nY+0, nX+6, nY+0 ) );
819 pBox->DrawRect( Rectangle( nX+1, nY+1, nX+5, nY+1 ) );
820 pBox->DrawRect( Rectangle( nX+2, nY+2, nX+4, nY+2 ) );
821 pBox->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
824 pBox->SetFillColor( aOldFillColor );
825 pBox->DrawRect( Rectangle( nX+2, nY+1, nX+4, nY+1 ) );
826 pBox->DrawRect( Rectangle( nX+3, nY+2, nX+3, nY+2 ) );
829 case WINDOWALIGN_RIGHT:
831 pBox->SetFillColor( Color( COL_BLACK ) );
832 pBox->DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
833 pBox->DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
834 pBox->DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
835 pBox->DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
838 pBox->SetFillColor( aOldFillColor );
839 pBox->DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
840 pBox->DrawRect( Rectangle( nX+1, nY+3, nX+1, nY+3 ) );
843 case WINDOWALIGN_BOTTOM:
845 pBox->SetFillColor( Color( COL_BLACK ) );
846 pBox->DrawRect( Rectangle( nX+0, nY+3, nX+6, nY+3 ) );
847 pBox->DrawRect( Rectangle( nX+1, nY+2, nX+5, nY+2 ) );
848 pBox->DrawRect( Rectangle( nX+2, nY+1, nX+4, nY+1 ) );
849 pBox->DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+0 ) );
852 pBox->SetFillColor( aOldFillColor );
853 pBox->DrawRect( Rectangle( nX+2, nY+2, nX+4, nY+2 ) );
854 pBox->DrawRect( Rectangle( nX+3, nY+1, nX+3, nY+1 ) );
868 - SetPressed( TRUE );
871 - SetPressed( FALSE );