xref: /AOO41X/main/svx/source/dialog/rubydialog.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir #include <svx/rubydialog.hxx>
31*cdf0e10cSrcweir #include <tools/shl.hxx>
32*cdf0e10cSrcweir #include <svx/dialmgr.hxx>
33*cdf0e10cSrcweir #include <svx/dialogs.hrc>
34*cdf0e10cSrcweir #include <rubydialog.hrc>
35*cdf0e10cSrcweir #include <sfx2/app.hxx>
36*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
37*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
38*cdf0e10cSrcweir #include <svl/eitem.hxx>
39*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/text/XRubySelection.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValues.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/text/RubyAdjust.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionChangeListener.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp>
50*cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE3_HXX_
51*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
52*cdf0e10cSrcweir #endif
53*cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir using namespace com::sun::star::uno;
56*cdf0e10cSrcweir using namespace com::sun::star::frame;
57*cdf0e10cSrcweir using namespace com::sun::star::text;
58*cdf0e10cSrcweir using namespace com::sun::star::beans;
59*cdf0e10cSrcweir using namespace com::sun::star::style;
60*cdf0e10cSrcweir using namespace com::sun::star::text;
61*cdf0e10cSrcweir using namespace com::sun::star::view;
62*cdf0e10cSrcweir using namespace com::sun::star::lang;
63*cdf0e10cSrcweir using namespace com::sun::star::container;
64*cdf0e10cSrcweir using rtl::OUString;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #define C2U(cChar) rtl::OUString::createFromAscii(cChar)
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir SFX_IMPL_CHILDWINDOW( SvxRubyChildWindow, SID_RUBY_DIALOG );
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir static const sal_Char cRubyBaseText[] = "RubyBaseText";
71*cdf0e10cSrcweir static const sal_Char cRubyText[] = "RubyText";
72*cdf0e10cSrcweir static const sal_Char cCharacterStyles[] = "CharacterStyles";
73*cdf0e10cSrcweir static const sal_Char cRubyAdjust[] = "RubyAdjust";
74*cdf0e10cSrcweir static const sal_Char cRubyIsAbove[] = "RubyIsAbove";
75*cdf0e10cSrcweir static const sal_Char cDisplayName[] = "DisplayName";
76*cdf0e10cSrcweir static const sal_Char cRubyCharStyleName[] = "RubyCharStyleName";
77*cdf0e10cSrcweir static const sal_Char cRubies[] = "Rubies";
78*cdf0e10cSrcweir /* -----------------------------09.01.01 17:24--------------------------------
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
81*cdf0e10cSrcweir SvxRubyChildWindow::SvxRubyChildWindow( Window* _pParent, sal_uInt16 nId,
82*cdf0e10cSrcweir 	SfxBindings* pBindings, SfxChildWinInfo* pInfo) :
83*cdf0e10cSrcweir 	SfxChildWindow(_pParent, nId)
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir 	pWindow = new SvxRubyDialog( pBindings, this, _pParent, SVX_RES( RID_SVXDLG_RUBY ) );
86*cdf0e10cSrcweir 	SvxRubyDialog* pDlg = (SvxRubyDialog*) pWindow;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
89*cdf0e10cSrcweir 		pDlg->RollUp();
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	eChildAlignment = SFX_ALIGN_NOALIGNMENT;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     pDlg->Initialize( pInfo );
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir /* -----------------------------10.01.01 13:53--------------------------------
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
98*cdf0e10cSrcweir SfxChildWinInfo SvxRubyChildWindow::GetInfo() const
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir 	return SfxChildWindow::GetInfo();
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir /* -----------------------------09.01.01 17:17--------------------------------
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
105*cdf0e10cSrcweir class SvxRubyData_Impl : public cppu::WeakImplHelper1
106*cdf0e10cSrcweir                                 <  ::com::sun::star::view::XSelectionChangeListener >
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir     Reference<XModel>               xModel;
109*cdf0e10cSrcweir 	Reference<XRubySelection> 		xSelection;
110*cdf0e10cSrcweir 	Sequence<PropertyValues>		aRubyValues;
111*cdf0e10cSrcweir     Reference<XController>          xController;
112*cdf0e10cSrcweir     sal_Bool                        bHasSelectionChanged;
113*cdf0e10cSrcweir     public:
114*cdf0e10cSrcweir         SvxRubyData_Impl();
115*cdf0e10cSrcweir         ~SvxRubyData_Impl();
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     void    SetController(Reference<XController> xCtrl);
118*cdf0e10cSrcweir     Reference<XModel>               GetModel()
119*cdf0e10cSrcweir                                     {
120*cdf0e10cSrcweir                                         if(!xController.is())
121*cdf0e10cSrcweir                                             xModel = 0;
122*cdf0e10cSrcweir                                         else
123*cdf0e10cSrcweir                                             xModel = xController->getModel();
124*cdf0e10cSrcweir                                         return xModel;
125*cdf0e10cSrcweir                                     }
126*cdf0e10cSrcweir     sal_Bool                        HasSelectionChanged() const{return bHasSelectionChanged;}
127*cdf0e10cSrcweir     Reference<XRubySelection>       GetRubySelection()
128*cdf0e10cSrcweir                                     {
129*cdf0e10cSrcweir                                         xSelection = Reference<XRubySelection>(xController, UNO_QUERY);
130*cdf0e10cSrcweir                                         return xSelection;
131*cdf0e10cSrcweir                                     }
132*cdf0e10cSrcweir     void                            UpdateRubyValues(sal_Bool bAutoUpdate)
133*cdf0e10cSrcweir                                     {
134*cdf0e10cSrcweir                                         if(!xSelection.is())
135*cdf0e10cSrcweir                                             aRubyValues.realloc(0);
136*cdf0e10cSrcweir                                         else
137*cdf0e10cSrcweir                                             aRubyValues = xSelection->getRubyList(bAutoUpdate);
138*cdf0e10cSrcweir 										bHasSelectionChanged = sal_False;
139*cdf0e10cSrcweir                                     }
140*cdf0e10cSrcweir     Sequence<PropertyValues>&       GetRubyValues() {return aRubyValues;}
141*cdf0e10cSrcweir     void                            AssertOneEntry();
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent ) throw (RuntimeException);
144*cdf0e10cSrcweir     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (RuntimeException);
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir };
147*cdf0e10cSrcweir //-----------------------------------------------------------------------------
148*cdf0e10cSrcweir SvxRubyData_Impl::SvxRubyData_Impl() :
149*cdf0e10cSrcweir     bHasSelectionChanged(sal_False)
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir //-----------------------------------------------------------------------------
153*cdf0e10cSrcweir SvxRubyData_Impl::~SvxRubyData_Impl()
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir }
156*cdf0e10cSrcweir //-----------------------------------------------------------------------------
157*cdf0e10cSrcweir void    SvxRubyData_Impl::SetController(Reference<XController> xCtrl)
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir     if(xCtrl.get() != xController.get())
160*cdf0e10cSrcweir     {
161*cdf0e10cSrcweir         try
162*cdf0e10cSrcweir         {
163*cdf0e10cSrcweir             Reference<XSelectionSupplier> xSelSupp(xController, UNO_QUERY);
164*cdf0e10cSrcweir             if(xSelSupp.is())
165*cdf0e10cSrcweir                 xSelSupp->removeSelectionChangeListener(this);
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir             bHasSelectionChanged = sal_True;
168*cdf0e10cSrcweir             xController = xCtrl;
169*cdf0e10cSrcweir             xSelSupp = Reference<XSelectionSupplier>(xController, UNO_QUERY);
170*cdf0e10cSrcweir             if(xSelSupp.is())
171*cdf0e10cSrcweir                 xSelSupp->addSelectionChangeListener(this);
172*cdf0e10cSrcweir         }
173*cdf0e10cSrcweir         catch(Exception&)
174*cdf0e10cSrcweir         {}
175*cdf0e10cSrcweir     }
176*cdf0e10cSrcweir }
177*cdf0e10cSrcweir //-----------------------------------------------------------------------------
178*cdf0e10cSrcweir void SvxRubyData_Impl::selectionChanged( const EventObject& ) throw (RuntimeException)
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir     bHasSelectionChanged = sal_True;
181*cdf0e10cSrcweir }
182*cdf0e10cSrcweir //-----------------------------------------------------------------------------
183*cdf0e10cSrcweir void SvxRubyData_Impl::disposing( const EventObject&) throw (RuntimeException)
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir     try
186*cdf0e10cSrcweir     {
187*cdf0e10cSrcweir         Reference<XSelectionSupplier> xSelSupp(xController, UNO_QUERY);
188*cdf0e10cSrcweir         if(xSelSupp.is())
189*cdf0e10cSrcweir             xSelSupp->removeSelectionChangeListener(this);
190*cdf0e10cSrcweir     }
191*cdf0e10cSrcweir     catch(Exception&)
192*cdf0e10cSrcweir     {}
193*cdf0e10cSrcweir     xController = 0;
194*cdf0e10cSrcweir }
195*cdf0e10cSrcweir //-----------------------------------------------------------------------------
196*cdf0e10cSrcweir void  SvxRubyData_Impl::AssertOneEntry()
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir     //create one entry
199*cdf0e10cSrcweir     if(!aRubyValues.getLength())
200*cdf0e10cSrcweir     {
201*cdf0e10cSrcweir         aRubyValues.realloc(1);
202*cdf0e10cSrcweir         Sequence<PropertyValue>& rValues = aRubyValues.getArray()[0];
203*cdf0e10cSrcweir         rValues.realloc(5);
204*cdf0e10cSrcweir         PropertyValue* pValues = rValues.getArray();
205*cdf0e10cSrcweir         pValues[0].Name = C2U(cRubyBaseText);
206*cdf0e10cSrcweir         pValues[1].Name = C2U(cRubyText);
207*cdf0e10cSrcweir         pValues[2].Name = C2U(cRubyAdjust);
208*cdf0e10cSrcweir         pValues[3].Name = C2U(cRubyIsAbove);
209*cdf0e10cSrcweir         pValues[4].Name = C2U(cRubyCharStyleName);
210*cdf0e10cSrcweir     }
211*cdf0e10cSrcweir }
212*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
215*cdf0e10cSrcweir SvxRubyDialog::SvxRubyDialog( SfxBindings *pBind, SfxChildWindow *pCW,
216*cdf0e10cSrcweir 									Window* _pParent, const ResId& rResId ) :
217*cdf0e10cSrcweir 	SfxModelessDialog( pBind, pCW, _pParent, rResId ),
218*cdf0e10cSrcweir     aLeftFT(this,               ResId(FT_LEFT,*rResId.GetResMgr() )),
219*cdf0e10cSrcweir     aLeft1ED(this,              ResId(ED_LEFT_1,*rResId.GetResMgr()  )),
220*cdf0e10cSrcweir     aRightFT(this,              ResId(FT_RIGHT,*rResId.GetResMgr()  )),
221*cdf0e10cSrcweir 	aRight1ED(this, 			ResId(ED_RIGHT_1,*rResId.GetResMgr() )),
222*cdf0e10cSrcweir 	aLeft2ED(this, 				ResId(ED_LEFT_2,*rResId.GetResMgr()  )),
223*cdf0e10cSrcweir 	aRight2ED(this, 			ResId(ED_RIGHT_2,*rResId.GetResMgr() )),
224*cdf0e10cSrcweir 	aLeft3ED(this, 				ResId(ED_LEFT_3,*rResId.GetResMgr()  )),
225*cdf0e10cSrcweir 	aRight3ED(this, 			ResId(ED_RIGHT_3,*rResId.GetResMgr() )),
226*cdf0e10cSrcweir 	aLeft4ED(this, 				ResId(ED_LEFT_4,*rResId.GetResMgr()  )),
227*cdf0e10cSrcweir 	aRight4ED(this, 			ResId(ED_RIGHT_4,*rResId.GetResMgr() )),
228*cdf0e10cSrcweir 	aScrollSB(this, 			ResId(SB_SCROLL,*rResId.GetResMgr()  )),
229*cdf0e10cSrcweir 	aAutoDetectionCB(this, 		ResId(CB_AUTO_DETECT,*rResId.GetResMgr()	)),
230*cdf0e10cSrcweir 	aAdjustFT(this, 			ResId(FT_ADJUST,*rResId.GetResMgr()		)),
231*cdf0e10cSrcweir 	aAdjustLB(this, 			ResId(LB_ADJUST,*rResId.GetResMgr()		)),
232*cdf0e10cSrcweir 	aPositionFT(this,           ResId(FT_POSITION,*rResId.GetResMgr()     )),
233*cdf0e10cSrcweir     aPositionLB(this,           ResId(LB_POSITION,*rResId.GetResMgr()     )),
234*cdf0e10cSrcweir 	aCharStyleFT(this,          ResId(FT_CHAR_STYLE,*rResId.GetResMgr()     )),
235*cdf0e10cSrcweir 	aCharStyleLB(this, 			ResId(LB_CHAR_STYLE,*rResId.GetResMgr()		)),
236*cdf0e10cSrcweir 	aStylistPB(this, 			ResId(PB_STYLIST,*rResId.GetResMgr()		)),
237*cdf0e10cSrcweir 	aPreviewFT(this, 			ResId(FT_PREVIEW,*rResId.GetResMgr()		)),
238*cdf0e10cSrcweir 	aPreviewWin(*this, 			ResId(WIN_PREVIEW,*rResId.GetResMgr()		)),
239*cdf0e10cSrcweir 	aApplyPB(this, 				ResId(PB_APPLY,*rResId.GetResMgr()			)),
240*cdf0e10cSrcweir 	aClosePB(this, 				ResId(PB_CLOSE,*rResId.GetResMgr()			)),
241*cdf0e10cSrcweir 	aHelpPB(this, 				ResId(PB_HELP,*rResId.GetResMgr()			)),
242*cdf0e10cSrcweir 	nLastPos(0),
243*cdf0e10cSrcweir     nCurrentEdit(0),
244*cdf0e10cSrcweir 	bModified(sal_False),
245*cdf0e10cSrcweir 	pBindings(pBind)
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir     xImpl = pImpl = new SvxRubyData_Impl;
248*cdf0e10cSrcweir     FreeResource();
249*cdf0e10cSrcweir     //#85638# automatic detection not yet available
250*cdf0e10cSrcweir     aAutoDetectionCB.Hide();
251*cdf0e10cSrcweir 	aEditArr[0] = &aLeft1ED; aEditArr[1] = &aRight1ED;
252*cdf0e10cSrcweir 	aEditArr[2] = &aLeft2ED; aEditArr[3] = &aRight2ED;
253*cdf0e10cSrcweir 	aEditArr[4] = &aLeft3ED; aEditArr[5] = &aRight3ED;
254*cdf0e10cSrcweir 	aEditArr[6] = &aLeft4ED; aEditArr[7] = &aRight4ED;
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 	aApplyPB.SetClickHdl(LINK(this, SvxRubyDialog, ApplyHdl_Impl));
257*cdf0e10cSrcweir 	aClosePB.SetClickHdl(LINK(this, SvxRubyDialog, CloseHdl_Impl));
258*cdf0e10cSrcweir 	aStylistPB.SetClickHdl(LINK(this, SvxRubyDialog, StylistHdl_Impl));
259*cdf0e10cSrcweir 	aAutoDetectionCB.SetClickHdl(LINK(this, SvxRubyDialog, AutomaticHdl_Impl));
260*cdf0e10cSrcweir 	aAdjustLB.SetSelectHdl(LINK(this, SvxRubyDialog, AdjustHdl_Impl));
261*cdf0e10cSrcweir     aPositionLB.SetSelectHdl(LINK(this, SvxRubyDialog, PositionHdl_Impl));
262*cdf0e10cSrcweir     aCharStyleLB.SetSelectHdl(LINK(this, SvxRubyDialog, CharStyleHdl_Impl));
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 	Link aScrLk(LINK(this, SvxRubyDialog, ScrollHdl_Impl));
265*cdf0e10cSrcweir 	aScrollSB.SetScrollHdl( aScrLk );
266*cdf0e10cSrcweir 	aScrollSB.SetEndScrollHdl( aScrLk );
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 	Link aEditLk(LINK(this, SvxRubyDialog, EditModifyHdl_Impl));
269*cdf0e10cSrcweir     Link aScrollLk(LINK(this, SvxRubyDialog, EditScrollHdl_Impl));
270*cdf0e10cSrcweir     Link aJumpLk(LINK(this, SvxRubyDialog, EditJumpHdl_Impl));
271*cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < 8; i++)
272*cdf0e10cSrcweir     {
273*cdf0e10cSrcweir 		aEditArr[i]->SetModifyHdl(aEditLk);
274*cdf0e10cSrcweir         aEditArr[i]->SetJumpHdl(aJumpLk);
275*cdf0e10cSrcweir         if(!i || 7 == i)
276*cdf0e10cSrcweir             aEditArr[i]->SetScrollHdl(aScrollLk);
277*cdf0e10cSrcweir     }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 	UpdateColors();
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 	String leftLabelName = aLeftFT.GetText(), rightLabelName = aRightFT.GetText();
282*cdf0e10cSrcweir 	aLeft2ED.SetAccessibleName(leftLabelName);
283*cdf0e10cSrcweir 	aLeft3ED.SetAccessibleName(leftLabelName);
284*cdf0e10cSrcweir 	aLeft4ED.SetAccessibleName(leftLabelName);
285*cdf0e10cSrcweir 	aRight2ED.SetAccessibleName(rightLabelName);
286*cdf0e10cSrcweir 	aRight3ED.SetAccessibleName(rightLabelName);
287*cdf0e10cSrcweir 	aRight4ED.SetAccessibleName(rightLabelName);
288*cdf0e10cSrcweir }
289*cdf0e10cSrcweir /* -----------------------------09.01.01 17:17--------------------------------
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
292*cdf0e10cSrcweir SvxRubyDialog::~SvxRubyDialog()
293*cdf0e10cSrcweir {
294*cdf0e10cSrcweir 	ClearCharStyleList();
295*cdf0e10cSrcweir     EventObject aEvent;
296*cdf0e10cSrcweir     xImpl->disposing(aEvent);
297*cdf0e10cSrcweir }
298*cdf0e10cSrcweir /* -----------------------------01.02.01 10:29--------------------------------
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
301*cdf0e10cSrcweir void SvxRubyDialog::ClearCharStyleList()
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir     for(sal_uInt16 i = 0; i < aCharStyleLB.GetEntryCount(); i++)
304*cdf0e10cSrcweir 	{
305*cdf0e10cSrcweir 		void* pData = aCharStyleLB.GetEntryData(i);
306*cdf0e10cSrcweir 		delete (OUString*)pData;
307*cdf0e10cSrcweir     }
308*cdf0e10cSrcweir     aCharStyleLB.Clear();
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir /* -----------------------------09.01.01 17:17--------------------------------
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
313*cdf0e10cSrcweir sal_Bool 	SvxRubyDialog::Close()
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir 	pBindings->GetDispatcher()->Execute( SID_RUBY_DIALOG,
316*cdf0e10cSrcweir 		                      SFX_CALLMODE_ASYNCHRON |
317*cdf0e10cSrcweir 							  SFX_CALLMODE_RECORD);
318*cdf0e10cSrcweir 	return sal_True;
319*cdf0e10cSrcweir }
320*cdf0e10cSrcweir /* -----------------------------29.01.01 15:26--------------------------------
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
323*cdf0e10cSrcweir void SvxRubyDialog::Activate()
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir 	SfxModelessDialog::Activate();
326*cdf0e10cSrcweir 	SfxPoolItem* pState = 0;
327*cdf0e10cSrcweir 	SfxItemState	eState = pBindings->QueryState( SID_STYLE_DESIGNER, pState );
328*cdf0e10cSrcweir     sal_Bool bEnable = (eState < SFX_ITEM_AVAILABLE) || !pState || !((SfxBoolItem*)pState)->GetValue();
329*cdf0e10cSrcweir     aStylistPB.Enable(bEnable);
330*cdf0e10cSrcweir 	//get selection from current view frame
331*cdf0e10cSrcweir 	SfxViewFrame* pCurFrm = SfxViewFrame::Current();
332*cdf0e10cSrcweir     Reference< XController > xCtrl = pCurFrm->GetFrame().GetController();
333*cdf0e10cSrcweir     pImpl->SetController(xCtrl);
334*cdf0e10cSrcweir     if(pImpl->HasSelectionChanged())
335*cdf0e10cSrcweir     {
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir         Reference< XRubySelection > xRubySel = pImpl->GetRubySelection();
338*cdf0e10cSrcweir         pImpl->UpdateRubyValues(aAutoDetectionCB.IsChecked());
339*cdf0e10cSrcweir         EnableControls(xRubySel.is());
340*cdf0e10cSrcweir         if(xRubySel.is())
341*cdf0e10cSrcweir         {
342*cdf0e10cSrcweir             Reference< XModel > xModel = pImpl->GetModel();
343*cdf0e10cSrcweir             const String sCharStyleSelect = aCharStyleLB.GetSelectEntry();
344*cdf0e10cSrcweir             ClearCharStyleList();
345*cdf0e10cSrcweir             Reference<XStyleFamiliesSupplier> xSupplier(xModel, UNO_QUERY);
346*cdf0e10cSrcweir             if(xSupplier.is())
347*cdf0e10cSrcweir             {
348*cdf0e10cSrcweir                 try
349*cdf0e10cSrcweir                 {
350*cdf0e10cSrcweir                     Reference<XNameAccess> xFam = xSupplier->getStyleFamilies();
351*cdf0e10cSrcweir                     Any aChar = xFam->getByName(C2U(cCharacterStyles));
352*cdf0e10cSrcweir                     Reference<XNameContainer> xChar;
353*cdf0e10cSrcweir                     aChar >>= xChar;
354*cdf0e10cSrcweir                     Reference<XIndexAccess> xCharIdx(xChar, UNO_QUERY);
355*cdf0e10cSrcweir                     if(xCharIdx.is())
356*cdf0e10cSrcweir                     {
357*cdf0e10cSrcweir                         OUString sUIName(C2U(cDisplayName));
358*cdf0e10cSrcweir                         for(sal_Int32 nStyle = 0; nStyle < xCharIdx->getCount(); nStyle++)
359*cdf0e10cSrcweir                         {
360*cdf0e10cSrcweir                             Any aStyle = xCharIdx->getByIndex(nStyle);
361*cdf0e10cSrcweir                             Reference<XStyle> xStyle;
362*cdf0e10cSrcweir                             aStyle >>= xStyle;
363*cdf0e10cSrcweir                             Reference<XPropertySet> xPrSet(xStyle, UNO_QUERY);
364*cdf0e10cSrcweir                             OUString sName, sCoreName;
365*cdf0e10cSrcweir                             if(xPrSet.is())
366*cdf0e10cSrcweir                             {
367*cdf0e10cSrcweir                                 Reference<XPropertySetInfo> xInfo = xPrSet->getPropertySetInfo();
368*cdf0e10cSrcweir                                 if(xInfo->hasPropertyByName(sUIName))
369*cdf0e10cSrcweir                                 {
370*cdf0e10cSrcweir                                     Any aName = xPrSet->getPropertyValue(sUIName);
371*cdf0e10cSrcweir                                     aName >>= sName;
372*cdf0e10cSrcweir                                 }
373*cdf0e10cSrcweir                             }
374*cdf0e10cSrcweir                             Reference<XNamed> xNamed(xStyle, UNO_QUERY);
375*cdf0e10cSrcweir                             if(xNamed.is())
376*cdf0e10cSrcweir                             {
377*cdf0e10cSrcweir                                 sCoreName = xNamed->getName();
378*cdf0e10cSrcweir                                 if(!sName.getLength())
379*cdf0e10cSrcweir                                     sName = sCoreName;
380*cdf0e10cSrcweir                             }
381*cdf0e10cSrcweir                             if(sName.getLength())
382*cdf0e10cSrcweir                             {
383*cdf0e10cSrcweir                                 sal_uInt16 nPos = aCharStyleLB.InsertEntry(sName);
384*cdf0e10cSrcweir                                 aCharStyleLB.SetEntryData( nPos, new OUString(sCoreName) );
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir                             }
387*cdf0e10cSrcweir                         }
388*cdf0e10cSrcweir                     }
389*cdf0e10cSrcweir                 }
390*cdf0e10cSrcweir                 catch(Exception&)
391*cdf0e10cSrcweir                 {
392*cdf0e10cSrcweir                     DBG_ERROR("exception in style access");
393*cdf0e10cSrcweir                 }
394*cdf0e10cSrcweir                 if(sCharStyleSelect.Len())
395*cdf0e10cSrcweir                     aCharStyleLB.SelectEntry(sCharStyleSelect);
396*cdf0e10cSrcweir             }
397*cdf0e10cSrcweir             aCharStyleLB.Enable(xSupplier.is());
398*cdf0e10cSrcweir             aCharStyleFT.Enable(xSupplier.is());
399*cdf0e10cSrcweir         }
400*cdf0e10cSrcweir 		Update();
401*cdf0e10cSrcweir 		aPreviewWin.Invalidate();
402*cdf0e10cSrcweir 	}
403*cdf0e10cSrcweir }
404*cdf0e10cSrcweir /* -----------------------------29.01.01 15:26--------------------------------
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
407*cdf0e10cSrcweir void	SvxRubyDialog::Deactivate()
408*cdf0e10cSrcweir {
409*cdf0e10cSrcweir 	SfxModelessDialog::Deactivate();
410*cdf0e10cSrcweir }
411*cdf0e10cSrcweir /* -----------------------------30.01.01 15:35--------------------------------
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
414*cdf0e10cSrcweir void SvxRubyDialog::SetText(sal_Int32 nPos, Edit& rLeft, Edit& rRight)
415*cdf0e10cSrcweir {
416*cdf0e10cSrcweir 	OUString sLeft, sRight;
417*cdf0e10cSrcweir     const Sequence<PropertyValues>&  aRubyValues = pImpl->GetRubyValues();
418*cdf0e10cSrcweir     sal_Bool bEnable = aRubyValues.getLength() > nPos;
419*cdf0e10cSrcweir 	if(bEnable)
420*cdf0e10cSrcweir 	{
421*cdf0e10cSrcweir         const Sequence<PropertyValue> aProps = aRubyValues.getConstArray()[nPos];
422*cdf0e10cSrcweir 		const PropertyValue* pProps = aProps.getConstArray();
423*cdf0e10cSrcweir 		for(sal_Int32 nProp = 0; nProp < aProps.getLength(); nProp++)
424*cdf0e10cSrcweir 		{
425*cdf0e10cSrcweir 			if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyBaseText)))
426*cdf0e10cSrcweir 				pProps[nProp].Value >>= sLeft;
427*cdf0e10cSrcweir 			else if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyText)))
428*cdf0e10cSrcweir 				pProps[nProp].Value >>= sRight;
429*cdf0e10cSrcweir 		}
430*cdf0e10cSrcweir 	}
431*cdf0e10cSrcweir 	else if(!nPos)
432*cdf0e10cSrcweir         bEnable = sal_True;
433*cdf0e10cSrcweir 	rLeft.Enable(bEnable);
434*cdf0e10cSrcweir 	rRight.Enable(bEnable);
435*cdf0e10cSrcweir 	rLeft.SetText(sLeft);
436*cdf0e10cSrcweir 	rRight.SetText(sRight);
437*cdf0e10cSrcweir 	rLeft.SaveValue();
438*cdf0e10cSrcweir 	rRight.SaveValue();
439*cdf0e10cSrcweir }
440*cdf0e10cSrcweir //-----------------------------------------------------------------------------
441*cdf0e10cSrcweir void SvxRubyDialog::GetText()
442*cdf0e10cSrcweir {
443*cdf0e10cSrcweir 	long nTempLastPos = GetLastPos();
444*cdf0e10cSrcweir 	for(int i = 0; i < 8; i+=2)
445*cdf0e10cSrcweir 	{
446*cdf0e10cSrcweir         if(aEditArr[i]->IsEnabled() &&
447*cdf0e10cSrcweir 			(aEditArr[i]->GetText() != aEditArr[i]->GetSavedValue() ||
448*cdf0e10cSrcweir 			aEditArr[i + 1]->GetText() != aEditArr[i + 1]->GetSavedValue()))
449*cdf0e10cSrcweir 		{
450*cdf0e10cSrcweir             Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
451*cdf0e10cSrcweir             DBG_ASSERT(aRubyValues.getLength() > (i / 2 + nTempLastPos), "wrong index" );
452*cdf0e10cSrcweir 			SetModified(sal_True);
453*cdf0e10cSrcweir             Sequence<PropertyValue> &rProps = aRubyValues.getArray()[i / 2 + nTempLastPos];
454*cdf0e10cSrcweir 			PropertyValue* pProps = rProps.getArray();
455*cdf0e10cSrcweir 			for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
456*cdf0e10cSrcweir 			{
457*cdf0e10cSrcweir 				if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyBaseText)))
458*cdf0e10cSrcweir 					pProps[nProp].Value <<= OUString(aEditArr[i]->GetText());
459*cdf0e10cSrcweir 				else if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyText)))
460*cdf0e10cSrcweir 					pProps[nProp].Value <<= OUString(aEditArr[i + 1]->GetText());
461*cdf0e10cSrcweir 			}
462*cdf0e10cSrcweir 		}
463*cdf0e10cSrcweir 	}
464*cdf0e10cSrcweir }
465*cdf0e10cSrcweir //-----------------------------------------------------------------------------
466*cdf0e10cSrcweir void SvxRubyDialog::Update()
467*cdf0e10cSrcweir {
468*cdf0e10cSrcweir     const Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
469*cdf0e10cSrcweir     sal_Int32 nLen = aRubyValues.getLength();
470*cdf0e10cSrcweir 	aScrollSB.Enable(nLen > 4);
471*cdf0e10cSrcweir 	aScrollSB.SetRange( Range(0, nLen > 4 ? nLen - 4 : 0));
472*cdf0e10cSrcweir 	aScrollSB.SetThumbPos(0);
473*cdf0e10cSrcweir 	SetLastPos(0);
474*cdf0e10cSrcweir 	SetModified(sal_False);
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir 	sal_Int16 nAdjust = -1;
477*cdf0e10cSrcweir     sal_Int16 nPosition = -1;
478*cdf0e10cSrcweir 	OUString sCharStyleName, sTmp;
479*cdf0e10cSrcweir 	sal_Bool bCharStyleEqual = sal_True;
480*cdf0e10cSrcweir 	for(sal_Int32 nRuby = 0; nRuby < nLen; nRuby++)
481*cdf0e10cSrcweir 	{
482*cdf0e10cSrcweir         const Sequence<PropertyValue> &rProps = aRubyValues.getConstArray()[nRuby];
483*cdf0e10cSrcweir         const PropertyValue* pProps = rProps.getConstArray();
484*cdf0e10cSrcweir 		for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
485*cdf0e10cSrcweir 		{
486*cdf0e10cSrcweir 			if(nAdjust > -2 &&
487*cdf0e10cSrcweir 				pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyAdjust)))
488*cdf0e10cSrcweir 			{
489*cdf0e10cSrcweir                 sal_Int16 nTmp = sal_Int16();
490*cdf0e10cSrcweir 				pProps[nProp].Value >>= nTmp;
491*cdf0e10cSrcweir 				if(!nRuby)
492*cdf0e10cSrcweir 					nAdjust = nTmp;
493*cdf0e10cSrcweir 				else if(nAdjust != nTmp)
494*cdf0e10cSrcweir 					nAdjust = -2;
495*cdf0e10cSrcweir 			}
496*cdf0e10cSrcweir             if(nPosition > -2 &&
497*cdf0e10cSrcweir                 pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyIsAbove)))
498*cdf0e10cSrcweir             {
499*cdf0e10cSrcweir                 sal_Bool bTmp = *(sal_Bool*)pProps[nProp].Value.getValue();
500*cdf0e10cSrcweir                 if(!nRuby)
501*cdf0e10cSrcweir                     nPosition = bTmp ? 0 : 1;
502*cdf0e10cSrcweir                 else if( (!nPosition && !bTmp) || (nPosition == 1 && bTmp)  )
503*cdf0e10cSrcweir                     nPosition = -2;
504*cdf0e10cSrcweir             }
505*cdf0e10cSrcweir 			if(bCharStyleEqual &&
506*cdf0e10cSrcweir 				pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyCharStyleName)))
507*cdf0e10cSrcweir 			{
508*cdf0e10cSrcweir 				pProps[nProp].Value >>= sTmp;
509*cdf0e10cSrcweir 				if(!nRuby)
510*cdf0e10cSrcweir 					sCharStyleName = sTmp;
511*cdf0e10cSrcweir 				else if(sCharStyleName != sTmp)
512*cdf0e10cSrcweir 					bCharStyleEqual = sal_False;
513*cdf0e10cSrcweir 			}
514*cdf0e10cSrcweir 		}
515*cdf0e10cSrcweir 	}
516*cdf0e10cSrcweir     if(!nLen)
517*cdf0e10cSrcweir     {
518*cdf0e10cSrcweir         //enable selection if the ruby list is empty
519*cdf0e10cSrcweir         nAdjust = 0;
520*cdf0e10cSrcweir         nPosition = 0;
521*cdf0e10cSrcweir     }
522*cdf0e10cSrcweir     if(nAdjust > -1)
523*cdf0e10cSrcweir 		aAdjustLB.SelectEntryPos(nAdjust);
524*cdf0e10cSrcweir 	else
525*cdf0e10cSrcweir 		aAdjustLB.SetNoSelection();
526*cdf0e10cSrcweir     if(nPosition > -1)
527*cdf0e10cSrcweir         aPositionLB.SelectEntryPos(nPosition ? 1 : 0);
528*cdf0e10cSrcweir     if(!nLen || (bCharStyleEqual && !sCharStyleName.getLength()))
529*cdf0e10cSrcweir         sCharStyleName = C2U(cRubies);
530*cdf0e10cSrcweir     if(sCharStyleName.getLength())
531*cdf0e10cSrcweir     {
532*cdf0e10cSrcweir         for(sal_uInt16 i = 0; i < aCharStyleLB.GetEntryCount(); i++)
533*cdf0e10cSrcweir         {
534*cdf0e10cSrcweir             const OUString* pCoreName = (const OUString*)aCharStyleLB.GetEntryData(i);
535*cdf0e10cSrcweir             if(pCoreName && sCharStyleName == *pCoreName)
536*cdf0e10cSrcweir             {
537*cdf0e10cSrcweir                 aCharStyleLB.SelectEntryPos(i);
538*cdf0e10cSrcweir                 break;
539*cdf0e10cSrcweir             }
540*cdf0e10cSrcweir         }
541*cdf0e10cSrcweir     }
542*cdf0e10cSrcweir     else
543*cdf0e10cSrcweir 		aCharStyleLB.SetNoSelection();
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir 	ScrollHdl_Impl(&aScrollSB);
546*cdf0e10cSrcweir }
547*cdf0e10cSrcweir /* -----------------------------16.02.01 14:01--------------------------------
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
550*cdf0e10cSrcweir void	SvxRubyDialog::GetCurrentText(String& rBase, String& rRuby)
551*cdf0e10cSrcweir {
552*cdf0e10cSrcweir 	rBase = aEditArr[nCurrentEdit * 2]->GetText();
553*cdf0e10cSrcweir 	rRuby = aEditArr[nCurrentEdit * 2 + 1]->GetText();
554*cdf0e10cSrcweir }
555*cdf0e10cSrcweir /* -----------------------------31.01.01 14:09--------------------------------
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
558*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, ScrollHdl_Impl, ScrollBar*, pScroll)
559*cdf0e10cSrcweir {
560*cdf0e10cSrcweir 	long nPos = pScroll->GetThumbPos();
561*cdf0e10cSrcweir 	if(GetLastPos() != nPos)
562*cdf0e10cSrcweir 	{
563*cdf0e10cSrcweir 		GetText();
564*cdf0e10cSrcweir 	}
565*cdf0e10cSrcweir 	SetText(nPos++, aLeft1ED, aRight1ED);
566*cdf0e10cSrcweir 	SetText(nPos++, aLeft2ED, aRight2ED);
567*cdf0e10cSrcweir 	SetText(nPos++, aLeft3ED, aRight3ED);
568*cdf0e10cSrcweir 	SetText(nPos, aLeft4ED, aRight4ED);
569*cdf0e10cSrcweir 	SetLastPos(nPos - 3);
570*cdf0e10cSrcweir 	aPreviewWin.Invalidate();
571*cdf0e10cSrcweir 	return 0;
572*cdf0e10cSrcweir }
573*cdf0e10cSrcweir /* -----------------------------30.01.01 14:48--------------------------------
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
576*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, ApplyHdl_Impl, PushButton*, EMPTYARG)
577*cdf0e10cSrcweir {
578*cdf0e10cSrcweir     const Sequence<PropertyValues>&  aRubyValues = pImpl->GetRubyValues();
579*cdf0e10cSrcweir     if(!aRubyValues.getLength())
580*cdf0e10cSrcweir     {
581*cdf0e10cSrcweir         AssertOneEntry();
582*cdf0e10cSrcweir         PositionHdl_Impl(&aPositionLB);
583*cdf0e10cSrcweir         AdjustHdl_Impl(&aAdjustLB);
584*cdf0e10cSrcweir         CharStyleHdl_Impl(&aCharStyleLB);
585*cdf0e10cSrcweir     }
586*cdf0e10cSrcweir     GetText();
587*cdf0e10cSrcweir 	//reset all edit fields - SaveValue is called
588*cdf0e10cSrcweir 	ScrollHdl_Impl(&aScrollSB);
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir     Reference<XRubySelection>  xSelection = pImpl->GetRubySelection();
591*cdf0e10cSrcweir     if(IsModified() && xSelection.is())
592*cdf0e10cSrcweir     {
593*cdf0e10cSrcweir         try
594*cdf0e10cSrcweir         {
595*cdf0e10cSrcweir             xSelection->setRubyList(aRubyValues, aAutoDetectionCB.IsChecked());
596*cdf0e10cSrcweir         }
597*cdf0e10cSrcweir         catch(Exception& )
598*cdf0e10cSrcweir         {
599*cdf0e10cSrcweir             DBG_ERROR("Exception caught");
600*cdf0e10cSrcweir         }
601*cdf0e10cSrcweir     }
602*cdf0e10cSrcweir 	return 0;
603*cdf0e10cSrcweir }
604*cdf0e10cSrcweir /* -----------------------------29.01.01 09:38--------------------------------
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
607*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, CloseHdl_Impl, PushButton*, EMPTYARG)
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir 	Close();
610*cdf0e10cSrcweir 	return 0;
611*cdf0e10cSrcweir }
612*cdf0e10cSrcweir /* -----------------------------29.01.01 15:10--------------------------------
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
615*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, StylistHdl_Impl, PushButton*, EMPTYARG)
616*cdf0e10cSrcweir {
617*cdf0e10cSrcweir 	SfxPoolItem* pState = 0;
618*cdf0e10cSrcweir 	SfxItemState	eState = pBindings->QueryState( SID_STYLE_DESIGNER, pState );
619*cdf0e10cSrcweir 	if(eState <= SFX_ITEM_SET || !pState || !((SfxBoolItem*)pState)->GetValue())
620*cdf0e10cSrcweir 	{
621*cdf0e10cSrcweir 		pBindings->GetDispatcher()->Execute( SID_STYLE_DESIGNER,
622*cdf0e10cSrcweir 		                      SFX_CALLMODE_ASYNCHRON |
623*cdf0e10cSrcweir 							  SFX_CALLMODE_RECORD);
624*cdf0e10cSrcweir 	}
625*cdf0e10cSrcweir 	return 0;
626*cdf0e10cSrcweir }
627*cdf0e10cSrcweir /* -----------------------------30.01.01 15:32--------------------------------
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
630*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, AutomaticHdl_Impl, CheckBox*, pBox)
631*cdf0e10cSrcweir {
632*cdf0e10cSrcweir     pImpl->UpdateRubyValues(pBox->IsChecked());
633*cdf0e10cSrcweir     Update();
634*cdf0e10cSrcweir 	return 0;
635*cdf0e10cSrcweir }
636*cdf0e10cSrcweir /* -----------------------------31.01.01 16:37--------------------------------
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
639*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, AdjustHdl_Impl, ListBox*, pBox)
640*cdf0e10cSrcweir {
641*cdf0e10cSrcweir     AssertOneEntry();
642*cdf0e10cSrcweir     sal_Int16 nAdjust = pBox->GetSelectEntryPos();
643*cdf0e10cSrcweir     Sequence<PropertyValues>&  aRubyValues = pImpl->GetRubyValues();
644*cdf0e10cSrcweir     for(sal_Int32 nRuby = 0; nRuby < aRubyValues.getLength(); nRuby++)
645*cdf0e10cSrcweir 	{
646*cdf0e10cSrcweir         Sequence<PropertyValue> &rProps = aRubyValues.getArray()[nRuby];
647*cdf0e10cSrcweir 		PropertyValue* pProps = rProps.getArray();
648*cdf0e10cSrcweir 		for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
649*cdf0e10cSrcweir 		{
650*cdf0e10cSrcweir 			if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyAdjust)))
651*cdf0e10cSrcweir 				pProps[nProp].Value <<= nAdjust;
652*cdf0e10cSrcweir 		}
653*cdf0e10cSrcweir 		SetModified(sal_True);
654*cdf0e10cSrcweir 	}
655*cdf0e10cSrcweir 	aPreviewWin.Invalidate();
656*cdf0e10cSrcweir 	return 0;
657*cdf0e10cSrcweir }
658*cdf0e10cSrcweir /* -----------------------------01.06.01 10:24--------------------------------
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
661*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, PositionHdl_Impl, ListBox*, pBox)
662*cdf0e10cSrcweir {
663*cdf0e10cSrcweir     AssertOneEntry();
664*cdf0e10cSrcweir     sal_Bool bAbove = !pBox->GetSelectEntryPos();
665*cdf0e10cSrcweir     const Type& rType = ::getBooleanCppuType();
666*cdf0e10cSrcweir     Sequence<PropertyValues>&  aRubyValues = pImpl->GetRubyValues();
667*cdf0e10cSrcweir     for(sal_Int32 nRuby = 0; nRuby < aRubyValues.getLength(); nRuby++)
668*cdf0e10cSrcweir 	{
669*cdf0e10cSrcweir         Sequence<PropertyValue> &rProps = aRubyValues.getArray()[nRuby];
670*cdf0e10cSrcweir 		PropertyValue* pProps = rProps.getArray();
671*cdf0e10cSrcweir 		for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
672*cdf0e10cSrcweir 		{
673*cdf0e10cSrcweir             if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyIsAbove)))
674*cdf0e10cSrcweir                 pProps[nProp].Value.setValue(&bAbove, rType);
675*cdf0e10cSrcweir 		}
676*cdf0e10cSrcweir 		SetModified(sal_True);
677*cdf0e10cSrcweir 	}
678*cdf0e10cSrcweir 	aPreviewWin.Invalidate();
679*cdf0e10cSrcweir 	return 0;
680*cdf0e10cSrcweir }
681*cdf0e10cSrcweir /* -----------------------------01.02.01 10:06--------------------------------
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
684*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, CharStyleHdl_Impl, ListBox*, EMPTYARG )
685*cdf0e10cSrcweir {
686*cdf0e10cSrcweir     AssertOneEntry();
687*cdf0e10cSrcweir     OUString sStyleName;
688*cdf0e10cSrcweir 	if(LISTBOX_ENTRY_NOTFOUND != aCharStyleLB.GetSelectEntryPos())
689*cdf0e10cSrcweir 		sStyleName = *(OUString*) aCharStyleLB.GetEntryData(aCharStyleLB.GetSelectEntryPos());
690*cdf0e10cSrcweir     Sequence<PropertyValues>&  aRubyValues = pImpl->GetRubyValues();
691*cdf0e10cSrcweir     for(sal_Int32 nRuby = 0; nRuby < aRubyValues.getLength(); nRuby++)
692*cdf0e10cSrcweir 	{
693*cdf0e10cSrcweir         Sequence<PropertyValue> &rProps = aRubyValues.getArray()[nRuby];
694*cdf0e10cSrcweir 		PropertyValue* pProps = rProps.getArray();
695*cdf0e10cSrcweir 		for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
696*cdf0e10cSrcweir 		{
697*cdf0e10cSrcweir 			if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyCharStyleName)))
698*cdf0e10cSrcweir 			{
699*cdf0e10cSrcweir 				pProps[nProp].Value <<= sStyleName;
700*cdf0e10cSrcweir 			}
701*cdf0e10cSrcweir 		}
702*cdf0e10cSrcweir 		SetModified(sal_True);
703*cdf0e10cSrcweir 	}
704*cdf0e10cSrcweir 	return 0;
705*cdf0e10cSrcweir }
706*cdf0e10cSrcweir /* -----------------------------16.02.01 08:35--------------------------------
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
709*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, EditModifyHdl_Impl, Edit*, pEdit)
710*cdf0e10cSrcweir {
711*cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < 8; i++)
712*cdf0e10cSrcweir 	{
713*cdf0e10cSrcweir 		if(pEdit == aEditArr[i])
714*cdf0e10cSrcweir 		{
715*cdf0e10cSrcweir 			nCurrentEdit = i / 2;
716*cdf0e10cSrcweir 			break;
717*cdf0e10cSrcweir 		}
718*cdf0e10cSrcweir 	}
719*cdf0e10cSrcweir 	aPreviewWin.Invalidate();
720*cdf0e10cSrcweir 	return 0;
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir /* -----------------------------17.07.01 09:11--------------------------------
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
725*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, EditScrollHdl_Impl, sal_Int32*, pParam)
726*cdf0e10cSrcweir {
727*cdf0e10cSrcweir     long nRet = 0;
728*cdf0e10cSrcweir     if(aScrollSB.IsEnabled())
729*cdf0e10cSrcweir     {
730*cdf0e10cSrcweir         //scroll forward
731*cdf0e10cSrcweir         if(*pParam > 0 && (aEditArr[7]->HasFocus() || aEditArr[6]->HasFocus() ))
732*cdf0e10cSrcweir         {
733*cdf0e10cSrcweir             if(aScrollSB.GetRangeMax() > aScrollSB.GetThumbPos())
734*cdf0e10cSrcweir             {
735*cdf0e10cSrcweir                 aScrollSB.SetThumbPos(aScrollSB.GetThumbPos() + 1);
736*cdf0e10cSrcweir                 aEditArr[6]->GrabFocus();
737*cdf0e10cSrcweir                 nRet = 1;
738*cdf0e10cSrcweir             }
739*cdf0e10cSrcweir         }
740*cdf0e10cSrcweir         //scroll backward
741*cdf0e10cSrcweir         else if(aScrollSB.GetThumbPos() && (aEditArr[0]->HasFocus()||aEditArr[1]->HasFocus()) )
742*cdf0e10cSrcweir         {
743*cdf0e10cSrcweir             aScrollSB.SetThumbPos(aScrollSB.GetThumbPos() - 1);
744*cdf0e10cSrcweir             aEditArr[1]->GrabFocus();
745*cdf0e10cSrcweir             nRet = 1;
746*cdf0e10cSrcweir         }
747*cdf0e10cSrcweir         if(nRet)
748*cdf0e10cSrcweir             ScrollHdl_Impl(&aScrollSB);
749*cdf0e10cSrcweir     }
750*cdf0e10cSrcweir     return nRet;
751*cdf0e10cSrcweir }
752*cdf0e10cSrcweir /* -----------------------------20.07.2001 15:18------------------------------
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
755*cdf0e10cSrcweir IMPL_LINK(SvxRubyDialog, EditJumpHdl_Impl, sal_Int32*, pParam)
756*cdf0e10cSrcweir {
757*cdf0e10cSrcweir     sal_uInt16 nIndex = USHRT_MAX;
758*cdf0e10cSrcweir     for(sal_uInt16 i = 0; i < 8; i++)
759*cdf0e10cSrcweir     {
760*cdf0e10cSrcweir         if(aEditArr[i]->HasFocus())
761*cdf0e10cSrcweir             nIndex = i;
762*cdf0e10cSrcweir     }
763*cdf0e10cSrcweir     if(nIndex < 8)
764*cdf0e10cSrcweir     {
765*cdf0e10cSrcweir         if(*pParam > 0)
766*cdf0e10cSrcweir         {
767*cdf0e10cSrcweir             if(nIndex < 6)
768*cdf0e10cSrcweir                 aEditArr[nIndex + 2]->GrabFocus();
769*cdf0e10cSrcweir             else if( EditScrollHdl_Impl(pParam))
770*cdf0e10cSrcweir                 aEditArr[nIndex]->GrabFocus();
771*cdf0e10cSrcweir         }
772*cdf0e10cSrcweir         else
773*cdf0e10cSrcweir         {
774*cdf0e10cSrcweir             if(nIndex > 1)
775*cdf0e10cSrcweir                 aEditArr[nIndex - 2]->GrabFocus();
776*cdf0e10cSrcweir             else if( EditScrollHdl_Impl(pParam))
777*cdf0e10cSrcweir                 aEditArr[nIndex]->GrabFocus();
778*cdf0e10cSrcweir         }
779*cdf0e10cSrcweir     }
780*cdf0e10cSrcweir     return 0;
781*cdf0e10cSrcweir };
782*cdf0e10cSrcweir /* -----------------------------19.06.01 11:33--------------------------------
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
785*cdf0e10cSrcweir void SvxRubyDialog::AssertOneEntry()
786*cdf0e10cSrcweir {
787*cdf0e10cSrcweir     pImpl->AssertOneEntry();
788*cdf0e10cSrcweir }
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir // ----------------------------------------------------------------------------
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir void SvxRubyDialog::UpdateColors( void )
793*cdf0e10cSrcweir {
794*cdf0e10cSrcweir 	const StyleSettings&	rStyleSettings = GetSettings().GetStyleSettings();
795*cdf0e10cSrcweir 	svtools::ColorConfig		aColorConfig;
796*cdf0e10cSrcweir 
797*cdf0e10cSrcweir 	Font					aFnt( aPreviewWin.GetFont() );
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir 	Color					aNewTextCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
800*cdf0e10cSrcweir 	Color					aNewFillCol( rStyleSettings.GetWindowColor() );
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir 	if( aNewFillCol != aFnt.GetFillColor() || aNewTextCol != aFnt.GetColor() )
803*cdf0e10cSrcweir 	{
804*cdf0e10cSrcweir 		aFnt.SetFillColor( aNewFillCol );
805*cdf0e10cSrcweir 		aFnt.SetColor( aNewTextCol );
806*cdf0e10cSrcweir 		aPreviewWin.SetFont( aFnt );
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir 		aPreviewWin.Invalidate();
809*cdf0e10cSrcweir 	}
810*cdf0e10cSrcweir }
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir // ----------------------------------------------------------------------------
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir void SvxRubyDialog::DataChanged( const DataChangedEvent& rDCEvt )
815*cdf0e10cSrcweir {
816*cdf0e10cSrcweir 	SfxModelessDialog::DataChanged( rDCEvt );
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir 	if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
819*cdf0e10cSrcweir 		UpdateColors();
820*cdf0e10cSrcweir }
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir /* -----------------------------29.01.01 15:44--------------------------------
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
825*cdf0e10cSrcweir void lcl_MoveBox(long nOffset, Edit& rLeft, Edit& rRight)
826*cdf0e10cSrcweir {
827*cdf0e10cSrcweir 	Size aLeftSz(rLeft.GetSizePixel());
828*cdf0e10cSrcweir 	Point aRightPos(rRight.GetPosPixel());
829*cdf0e10cSrcweir 	Size aRightSz(rRight.GetSizePixel());
830*cdf0e10cSrcweir 	aLeftSz.Width() += nOffset;
831*cdf0e10cSrcweir 	aRightSz.Width() -= nOffset;
832*cdf0e10cSrcweir 	aRightPos.X() += nOffset;
833*cdf0e10cSrcweir 	rLeft.SetSizePixel(aLeftSz);
834*cdf0e10cSrcweir 	rRight.SetPosSizePixel(aRightPos, aRightSz);
835*cdf0e10cSrcweir 
836*cdf0e10cSrcweir }
837*cdf0e10cSrcweir /* -----------------------------16.02.01 08:09--------------------------------
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
840*cdf0e10cSrcweir RubyPreview::RubyPreview(SvxRubyDialog& rParent, const ResId& rResId) :
841*cdf0e10cSrcweir 		Window(&rParent, rResId),
842*cdf0e10cSrcweir 		rParentDlg(rParent)
843*cdf0e10cSrcweir {
844*cdf0e10cSrcweir 	SetMapMode(MAP_TWIP);
845*cdf0e10cSrcweir 	Size aWinSize = GetOutputSize();
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir 	Font aFont = GetFont();
848*cdf0e10cSrcweir 	aFont.SetHeight(aWinSize.Height() / 4);
849*cdf0e10cSrcweir 	SetFont(aFont);
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir 	SetBorderStyle( WINDOW_BORDER_MONO );
852*cdf0e10cSrcweir }
853*cdf0e10cSrcweir /* -----------------------------29.01.01 14:05--------------------------------
854*cdf0e10cSrcweir 
855*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
856*cdf0e10cSrcweir void RubyPreview::Paint( const Rectangle& /* rRect */ )
857*cdf0e10cSrcweir {
858*cdf0e10cSrcweir     Font aRubyFont = GetFont();
859*cdf0e10cSrcweir     Font aSaveFont(aRubyFont);
860*cdf0e10cSrcweir     aRubyFont.SetHeight(aRubyFont.GetHeight() * 70 / 100);
861*cdf0e10cSrcweir 
862*cdf0e10cSrcweir     Size aWinSize = GetOutputSize();
863*cdf0e10cSrcweir 	Rectangle aRect(Point(0, 0), aWinSize);
864*cdf0e10cSrcweir 	SetLineColor();
865*cdf0e10cSrcweir 	SetFillColor( aSaveFont.GetFillColor() );
866*cdf0e10cSrcweir 	DrawRect(aRect);
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir 	String sBaseText, sRubyText;
869*cdf0e10cSrcweir 	rParentDlg.GetCurrentText(sBaseText, sRubyText);
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir 	long nTextHeight = GetTextHeight();
872*cdf0e10cSrcweir 	long nBaseWidth = GetTextWidth(sBaseText);
873*cdf0e10cSrcweir     SetFont(aRubyFont);
874*cdf0e10cSrcweir     long nRubyWidth = GetTextWidth(sRubyText);
875*cdf0e10cSrcweir     SetFont(aSaveFont);
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir 	sal_uInt16 nAdjust = rParentDlg.aAdjustLB.GetSelectEntryPos();
878*cdf0e10cSrcweir 	//use center if no adjustment is available
879*cdf0e10cSrcweir 	if(nAdjust > 4)
880*cdf0e10cSrcweir 		nAdjust = 1;
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir     //which part is stretched ?
883*cdf0e10cSrcweir 	sal_Bool bRubyStretch = nBaseWidth >= nRubyWidth;
884*cdf0e10cSrcweir 
885*cdf0e10cSrcweir 	long nCenter = aWinSize.Width() / 2;
886*cdf0e10cSrcweir 	long nLeftStart = nCenter - (bRubyStretch ? (nBaseWidth / 2) : (nRubyWidth / 2));
887*cdf0e10cSrcweir 	long nRightEnd = nCenter + (bRubyStretch ? (nBaseWidth / 2) : (nRubyWidth / 2));
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir 	long nYRuby = aWinSize.Height() / 4 - nTextHeight / 2;
890*cdf0e10cSrcweir 	long nYBase = aWinSize.Height() * 3 / 4 - nTextHeight / 2;
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir     //use above also if no selection is set
893*cdf0e10cSrcweir     sal_Bool bAbove = rParentDlg.aPositionLB.GetSelectEntryPos() != 1;
894*cdf0e10cSrcweir     if(!bAbove)
895*cdf0e10cSrcweir     {
896*cdf0e10cSrcweir         long nTmp = nYRuby;
897*cdf0e10cSrcweir         nYRuby = nYBase;
898*cdf0e10cSrcweir         nYBase = nTmp;
899*cdf0e10cSrcweir     }
900*cdf0e10cSrcweir 	long nYOutput, nOutTextWidth;
901*cdf0e10cSrcweir 	String sOutputText;
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir     if(bRubyStretch)
905*cdf0e10cSrcweir 	{
906*cdf0e10cSrcweir 		DrawText( Point( nLeftStart , nYBase),  sBaseText );
907*cdf0e10cSrcweir 		nYOutput = nYRuby;
908*cdf0e10cSrcweir 		sOutputText = sRubyText;
909*cdf0e10cSrcweir 		nOutTextWidth = nRubyWidth;
910*cdf0e10cSrcweir         SetFont(aRubyFont);
911*cdf0e10cSrcweir 	}
912*cdf0e10cSrcweir 	else
913*cdf0e10cSrcweir 	{
914*cdf0e10cSrcweir         SetFont(aRubyFont);
915*cdf0e10cSrcweir         DrawText( Point( nLeftStart , nYRuby),  sRubyText );
916*cdf0e10cSrcweir 		nYOutput = nYBase;
917*cdf0e10cSrcweir 		sOutputText = sBaseText;
918*cdf0e10cSrcweir 		nOutTextWidth = nBaseWidth;
919*cdf0e10cSrcweir         SetFont(aSaveFont);
920*cdf0e10cSrcweir     }
921*cdf0e10cSrcweir 
922*cdf0e10cSrcweir 	switch(nAdjust)
923*cdf0e10cSrcweir 	{
924*cdf0e10cSrcweir 		case RubyAdjust_LEFT:
925*cdf0e10cSrcweir 			DrawText( Point( nLeftStart , nYOutput),  sOutputText );
926*cdf0e10cSrcweir 		break;
927*cdf0e10cSrcweir 		case RubyAdjust_RIGHT:
928*cdf0e10cSrcweir 			DrawText( Point( nRightEnd - nOutTextWidth, nYOutput),  sOutputText );
929*cdf0e10cSrcweir 		break;
930*cdf0e10cSrcweir 		case RubyAdjust_INDENT_BLOCK:
931*cdf0e10cSrcweir 		{
932*cdf0e10cSrcweir 			long nCharWidth = GetTextWidth(String::CreateFromAscii("X"));
933*cdf0e10cSrcweir 			if(nOutTextWidth < (nRightEnd - nLeftStart - nCharWidth))
934*cdf0e10cSrcweir 			{
935*cdf0e10cSrcweir 				nCharWidth /= 2;
936*cdf0e10cSrcweir 				nLeftStart += nCharWidth;
937*cdf0e10cSrcweir 				nRightEnd -= nCharWidth;
938*cdf0e10cSrcweir 			}
939*cdf0e10cSrcweir 		}
940*cdf0e10cSrcweir 		// no break!
941*cdf0e10cSrcweir 		case RubyAdjust_BLOCK:
942*cdf0e10cSrcweir 		if(sOutputText.Len() > 1)
943*cdf0e10cSrcweir 		{
944*cdf0e10cSrcweir 			xub_StrLen nCount = sOutputText.Len();
945*cdf0e10cSrcweir 			long nSpace = ((nRightEnd - nLeftStart) - GetTextWidth(sOutputText)) / (nCount - 1);
946*cdf0e10cSrcweir 			for(xub_StrLen i = 0; i < nCount; i++)
947*cdf0e10cSrcweir 			{
948*cdf0e10cSrcweir 				sal_Unicode cChar = sOutputText.GetChar(i);
949*cdf0e10cSrcweir 				DrawText( Point( nLeftStart , nYOutput),  cChar);
950*cdf0e10cSrcweir 				long nCharWidth = GetTextWidth(cChar);
951*cdf0e10cSrcweir 				nLeftStart += nCharWidth + nSpace;
952*cdf0e10cSrcweir 			}
953*cdf0e10cSrcweir 			break;
954*cdf0e10cSrcweir 		}
955*cdf0e10cSrcweir 		//no break;
956*cdf0e10cSrcweir 		case RubyAdjust_CENTER:
957*cdf0e10cSrcweir 			DrawText( Point( nCenter - nOutTextWidth / 2 , nYOutput),  sOutputText );
958*cdf0e10cSrcweir 		break;
959*cdf0e10cSrcweir 	}
960*cdf0e10cSrcweir     SetFont(aSaveFont);
961*cdf0e10cSrcweir }
962*cdf0e10cSrcweir /* -----------------------------16.02.01 15:12--------------------------------
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
965*cdf0e10cSrcweir void RubyEdit::GetFocus()
966*cdf0e10cSrcweir {
967*cdf0e10cSrcweir 	GetModifyHdl().Call(this);
968*cdf0e10cSrcweir 	Edit::GetFocus();
969*cdf0e10cSrcweir }
970*cdf0e10cSrcweir /* -----------------------------17.07.01 09:00--------------------------------
971*cdf0e10cSrcweir 
972*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
973*cdf0e10cSrcweir long  RubyEdit::PreNotify( NotifyEvent& rNEvt )
974*cdf0e10cSrcweir {
975*cdf0e10cSrcweir     long nHandled = 0;
976*cdf0e10cSrcweir 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
977*cdf0e10cSrcweir 	{
978*cdf0e10cSrcweir         const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
979*cdf0e10cSrcweir         const KeyCode&  rKeyCode = pKEvt->GetKeyCode();
980*cdf0e10cSrcweir         sal_uInt16 nMod = rKeyCode.GetModifier();
981*cdf0e10cSrcweir         sal_uInt16 nCode = rKeyCode.GetCode();
982*cdf0e10cSrcweir         if( nCode == KEY_TAB && (!nMod || KEY_SHIFT == nMod))
983*cdf0e10cSrcweir         {
984*cdf0e10cSrcweir             sal_Int32 nParam = KEY_SHIFT == nMod ? -1 : 1;
985*cdf0e10cSrcweir             if(aScrollHdl.IsSet() && aScrollHdl.Call(&nParam))
986*cdf0e10cSrcweir                 nHandled = 1;
987*cdf0e10cSrcweir         }
988*cdf0e10cSrcweir         else if(KEY_UP == nCode || KEY_DOWN == nCode)
989*cdf0e10cSrcweir         {
990*cdf0e10cSrcweir             sal_Int32 nParam = KEY_UP == nCode ? -1 : 1;
991*cdf0e10cSrcweir             aJumpHdl.Call(&nParam);
992*cdf0e10cSrcweir         }
993*cdf0e10cSrcweir 	}
994*cdf0e10cSrcweir 	if(!nHandled)
995*cdf0e10cSrcweir         nHandled = Edit::PreNotify(rNEvt);
996*cdf0e10cSrcweir 	return nHandled;
997*cdf0e10cSrcweir }
998*cdf0e10cSrcweir 
999