LCOV - code coverage report
Current view: top level - svx/source/dialog - rubydialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 532 0.2 %
Date: 2012-08-25 Functions: 1 56 1.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 890 0.1 %

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

Generated by: LCOV version 1.10