2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-01-10 15:00:52 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 22:47:57 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-01-10 15:00:52 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-01-10 15:00:52 +00:00
|
|
|
*
|
2008-04-10 22:47:57 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-01-10 15:00:52 +00:00
|
|
|
*
|
2008-04-10 22:47:57 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-01-10 15:00:52 +00:00
|
|
|
*
|
2008-04-10 22:47:57 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-01-10 15:00:52 +00:00
|
|
|
*
|
2008-04-10 22:47:57 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-01-10 15:00:52 +00:00
|
|
|
*
|
2008-04-10 22:47:57 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-01-10 15:00:52 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 03:36:42 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_svx.hxx"
|
2010-04-20 15:55:51 +02:00
|
|
|
#include <svx/rubydialog.hxx>
|
2001-01-10 15:00:52 +00:00
|
|
|
#include <tools/shl.hxx>
|
2007-06-27 16:36:45 +00:00
|
|
|
#include <svx/dialmgr.hxx>
|
|
|
|
#include <svx/dialogs.hrc>
|
2001-01-10 15:00:52 +00:00
|
|
|
#include <rubydialog.hrc>
|
|
|
|
#include <sfx2/app.hxx>
|
2001-02-02 10:41:31 +00:00
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/eitem.hxx>
|
2001-02-02 10:41:31 +00:00
|
|
|
#include <com/sun/star/frame/XController.hpp>
|
|
|
|
#include <com/sun/star/style/XStyle.hpp>
|
|
|
|
#include <com/sun/star/text/XRubySelection.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyValues.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySetInfo.hpp>
|
|
|
|
#include <com/sun/star/container/XNameContainer.hpp>
|
|
|
|
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
|
2001-02-16 13:47:12 +00:00
|
|
|
#include <com/sun/star/text/RubyAdjust.hpp>
|
2001-11-02 10:11:18 +00:00
|
|
|
#include <com/sun/star/view/XSelectionChangeListener.hpp>
|
|
|
|
#include <com/sun/star/view/XSelectionSupplier.hpp>
|
|
|
|
#include <cppuhelper/implbase1.hxx>
|
2003-03-27 14:06:05 +00:00
|
|
|
#include <svtools/colorcfg.hxx>
|
|
|
|
|
2001-02-02 10:41:31 +00:00
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::frame;
|
|
|
|
using namespace com::sun::star::text;
|
|
|
|
using namespace com::sun::star::beans;
|
|
|
|
using namespace com::sun::star::style;
|
2001-02-16 13:47:12 +00:00
|
|
|
using namespace com::sun::star::text;
|
2001-11-02 10:11:18 +00:00
|
|
|
using namespace com::sun::star::view;
|
|
|
|
using namespace com::sun::star::lang;
|
2001-02-02 10:41:31 +00:00
|
|
|
using namespace com::sun::star::container;
|
2007-09-05 16:44:35 +00:00
|
|
|
using rtl::OUString;
|
2001-02-02 10:41:31 +00:00
|
|
|
|
|
|
|
#define C2U(cChar) rtl::OUString::createFromAscii(cChar)
|
2001-01-10 15:00:52 +00:00
|
|
|
|
|
|
|
SFX_IMPL_CHILDWINDOW( SvxRubyChildWindow, SID_RUBY_DIALOG );
|
2001-02-02 10:41:31 +00:00
|
|
|
|
|
|
|
static const sal_Char cRubyBaseText[] = "RubyBaseText";
|
|
|
|
static const sal_Char cRubyText[] = "RubyText";
|
|
|
|
static const sal_Char cCharacterStyles[] = "CharacterStyles";
|
|
|
|
static const sal_Char cRubyAdjust[] = "RubyAdjust";
|
2001-06-01 09:10:39 +00:00
|
|
|
static const sal_Char cRubyIsAbove[] = "RubyIsAbove";
|
2001-02-02 10:41:31 +00:00
|
|
|
static const sal_Char cDisplayName[] = "DisplayName";
|
2001-02-19 06:28:26 +00:00
|
|
|
static const sal_Char cRubyCharStyleName[] = "RubyCharStyleName";
|
2001-07-03 10:51:56 +00:00
|
|
|
static const sal_Char cRubies[] = "Rubies";
|
2001-01-10 15:00:52 +00:00
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
SvxRubyChildWindow::SvxRubyChildWindow( Window* _pParent, sal_uInt16 nId,
|
2001-01-10 15:00:52 +00:00
|
|
|
SfxBindings* pBindings, SfxChildWinInfo* pInfo) :
|
2006-06-19 14:27:24 +00:00
|
|
|
SfxChildWindow(_pParent, nId)
|
2001-01-10 15:00:52 +00:00
|
|
|
{
|
2006-06-19 14:27:24 +00:00
|
|
|
pWindow = new SvxRubyDialog( pBindings, this, _pParent, SVX_RES( RID_SVXDLG_RUBY ) );
|
2001-01-10 15:00:52 +00:00
|
|
|
SvxRubyDialog* pDlg = (SvxRubyDialog*) pWindow;
|
|
|
|
|
|
|
|
if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
|
|
|
|
pDlg->RollUp();
|
|
|
|
|
|
|
|
eChildAlignment = SFX_ALIGN_NOALIGNMENT;
|
2001-11-27 14:06:07 +00:00
|
|
|
|
|
|
|
pDlg->Initialize( pInfo );
|
2001-01-10 15:00:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SfxChildWinInfo SvxRubyChildWindow::GetInfo() const
|
|
|
|
{
|
|
|
|
return SfxChildWindow::GetInfo();
|
|
|
|
}
|
|
|
|
|
2001-11-02 10:11:18 +00:00
|
|
|
class SvxRubyData_Impl : public cppu::WeakImplHelper1
|
|
|
|
< ::com::sun::star::view::XSelectionChangeListener >
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
|
|
|
Reference<XModel> xModel;
|
|
|
|
Reference<XRubySelection> xSelection;
|
|
|
|
Sequence<PropertyValues> aRubyValues;
|
2001-11-02 10:11:18 +00:00
|
|
|
Reference<XController> xController;
|
|
|
|
sal_Bool bHasSelectionChanged;
|
|
|
|
public:
|
|
|
|
SvxRubyData_Impl();
|
|
|
|
~SvxRubyData_Impl();
|
|
|
|
|
|
|
|
void SetController(Reference<XController> xCtrl);
|
|
|
|
Reference<XModel> GetModel()
|
|
|
|
{
|
|
|
|
if(!xController.is())
|
|
|
|
xModel = 0;
|
|
|
|
else
|
|
|
|
xModel = xController->getModel();
|
|
|
|
return xModel;
|
|
|
|
}
|
|
|
|
sal_Bool HasSelectionChanged() const{return bHasSelectionChanged;}
|
|
|
|
Reference<XRubySelection> GetRubySelection()
|
|
|
|
{
|
|
|
|
xSelection = Reference<XRubySelection>(xController, UNO_QUERY);
|
|
|
|
return xSelection;
|
|
|
|
}
|
|
|
|
void UpdateRubyValues(sal_Bool bAutoUpdate)
|
|
|
|
{
|
|
|
|
if(!xSelection.is())
|
|
|
|
aRubyValues.realloc(0);
|
|
|
|
else
|
|
|
|
aRubyValues = xSelection->getRubyList(bAutoUpdate);
|
|
|
|
bHasSelectionChanged = sal_False;
|
|
|
|
}
|
|
|
|
Sequence<PropertyValues>& GetRubyValues() {return aRubyValues;}
|
|
|
|
void AssertOneEntry();
|
|
|
|
|
|
|
|
virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent ) throw (RuntimeException);
|
|
|
|
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (RuntimeException);
|
|
|
|
|
2001-02-02 10:41:31 +00:00
|
|
|
};
|
2001-11-02 10:11:18 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
SvxRubyData_Impl::SvxRubyData_Impl() :
|
|
|
|
bHasSelectionChanged(sal_False)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
SvxRubyData_Impl::~SvxRubyData_Impl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SvxRubyData_Impl::SetController(Reference<XController> xCtrl)
|
|
|
|
{
|
|
|
|
if(xCtrl.get() != xController.get())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference<XSelectionSupplier> xSelSupp(xController, UNO_QUERY);
|
|
|
|
if(xSelSupp.is())
|
|
|
|
xSelSupp->removeSelectionChangeListener(this);
|
|
|
|
|
|
|
|
bHasSelectionChanged = sal_True;
|
|
|
|
xController = xCtrl;
|
|
|
|
xSelSupp = Reference<XSelectionSupplier>(xController, UNO_QUERY);
|
|
|
|
if(xSelSupp.is())
|
|
|
|
xSelSupp->addSelectionChangeListener(this);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2006-06-19 14:27:24 +00:00
|
|
|
void SvxRubyData_Impl::selectionChanged( const EventObject& ) throw (RuntimeException)
|
2001-11-02 10:11:18 +00:00
|
|
|
{
|
|
|
|
bHasSelectionChanged = sal_True;
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2002-04-19 11:51:22 +00:00
|
|
|
void SvxRubyData_Impl::disposing( const EventObject&) throw (RuntimeException)
|
2001-11-02 10:11:18 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference<XSelectionSupplier> xSelSupp(xController, UNO_QUERY);
|
|
|
|
if(xSelSupp.is())
|
|
|
|
xSelSupp->removeSelectionChangeListener(this);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{}
|
|
|
|
xController = 0;
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SvxRubyData_Impl::AssertOneEntry()
|
|
|
|
{
|
|
|
|
//create one entry
|
|
|
|
if(!aRubyValues.getLength())
|
|
|
|
{
|
|
|
|
aRubyValues.realloc(1);
|
|
|
|
Sequence<PropertyValue>& rValues = aRubyValues.getArray()[0];
|
|
|
|
rValues.realloc(5);
|
|
|
|
PropertyValue* pValues = rValues.getArray();
|
|
|
|
pValues[0].Name = C2U(cRubyBaseText);
|
|
|
|
pValues[1].Name = C2U(cRubyText);
|
|
|
|
pValues[2].Name = C2U(cRubyAdjust);
|
|
|
|
pValues[3].Name = C2U(cRubyIsAbove);
|
|
|
|
pValues[4].Name = C2U(cRubyCharStyleName);
|
|
|
|
}
|
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
|
|
|
|
SvxRubyDialog::SvxRubyDialog( SfxBindings *pBind, SfxChildWindow *pCW,
|
2006-06-19 14:27:24 +00:00
|
|
|
Window* _pParent, const ResId& rResId ) :
|
|
|
|
SfxModelessDialog( pBind, pCW, _pParent, rResId ),
|
2007-04-26 06:41:53 +00:00
|
|
|
aLeftFT(this, ResId(FT_LEFT,*rResId.GetResMgr() )),
|
|
|
|
aLeft1ED(this, ResId(ED_LEFT_1,*rResId.GetResMgr() )),
|
|
|
|
aRightFT(this, ResId(FT_RIGHT,*rResId.GetResMgr() )),
|
|
|
|
aRight1ED(this, ResId(ED_RIGHT_1,*rResId.GetResMgr() )),
|
|
|
|
aLeft2ED(this, ResId(ED_LEFT_2,*rResId.GetResMgr() )),
|
|
|
|
aRight2ED(this, ResId(ED_RIGHT_2,*rResId.GetResMgr() )),
|
|
|
|
aLeft3ED(this, ResId(ED_LEFT_3,*rResId.GetResMgr() )),
|
|
|
|
aRight3ED(this, ResId(ED_RIGHT_3,*rResId.GetResMgr() )),
|
|
|
|
aLeft4ED(this, ResId(ED_LEFT_4,*rResId.GetResMgr() )),
|
|
|
|
aRight4ED(this, ResId(ED_RIGHT_4,*rResId.GetResMgr() )),
|
|
|
|
aScrollSB(this, ResId(SB_SCROLL,*rResId.GetResMgr() )),
|
|
|
|
aAutoDetectionCB(this, ResId(CB_AUTO_DETECT,*rResId.GetResMgr() )),
|
|
|
|
aAdjustFT(this, ResId(FT_ADJUST,*rResId.GetResMgr() )),
|
|
|
|
aAdjustLB(this, ResId(LB_ADJUST,*rResId.GetResMgr() )),
|
|
|
|
aPositionFT(this, ResId(FT_POSITION,*rResId.GetResMgr() )),
|
|
|
|
aPositionLB(this, ResId(LB_POSITION,*rResId.GetResMgr() )),
|
|
|
|
aCharStyleFT(this, ResId(FT_CHAR_STYLE,*rResId.GetResMgr() )),
|
|
|
|
aCharStyleLB(this, ResId(LB_CHAR_STYLE,*rResId.GetResMgr() )),
|
|
|
|
aStylistPB(this, ResId(PB_STYLIST,*rResId.GetResMgr() )),
|
|
|
|
aPreviewFT(this, ResId(FT_PREVIEW,*rResId.GetResMgr() )),
|
|
|
|
aPreviewWin(*this, ResId(WIN_PREVIEW,*rResId.GetResMgr() )),
|
|
|
|
aApplyPB(this, ResId(PB_APPLY,*rResId.GetResMgr() )),
|
|
|
|
aClosePB(this, ResId(PB_CLOSE,*rResId.GetResMgr() )),
|
|
|
|
aHelpPB(this, ResId(PB_HELP,*rResId.GetResMgr() )),
|
2001-02-02 10:41:31 +00:00
|
|
|
nLastPos(0),
|
2006-06-19 14:27:24 +00:00
|
|
|
nCurrentEdit(0),
|
2011-01-10 16:11:35 +01:00
|
|
|
bModified(sal_False),
|
2006-06-19 14:27:24 +00:00
|
|
|
pBindings(pBind)
|
2001-01-10 15:00:52 +00:00
|
|
|
{
|
2002-04-19 11:51:22 +00:00
|
|
|
xImpl = pImpl = new SvxRubyData_Impl;
|
2001-01-10 15:00:52 +00:00
|
|
|
FreeResource();
|
2011-02-21 23:29:31 +01:00
|
|
|
// automatic detection not yet available
|
2001-04-17 12:35:37 +00:00
|
|
|
aAutoDetectionCB.Hide();
|
2001-02-02 10:41:31 +00:00
|
|
|
aEditArr[0] = &aLeft1ED; aEditArr[1] = &aRight1ED;
|
2001-04-06 08:55:02 +00:00
|
|
|
aEditArr[2] = &aLeft2ED; aEditArr[3] = &aRight2ED;
|
|
|
|
aEditArr[4] = &aLeft3ED; aEditArr[5] = &aRight3ED;
|
|
|
|
aEditArr[6] = &aLeft4ED; aEditArr[7] = &aRight4ED;
|
2001-02-02 10:41:31 +00:00
|
|
|
|
|
|
|
aApplyPB.SetClickHdl(LINK(this, SvxRubyDialog, ApplyHdl_Impl));
|
|
|
|
aClosePB.SetClickHdl(LINK(this, SvxRubyDialog, CloseHdl_Impl));
|
|
|
|
aStylistPB.SetClickHdl(LINK(this, SvxRubyDialog, StylistHdl_Impl));
|
|
|
|
aAutoDetectionCB.SetClickHdl(LINK(this, SvxRubyDialog, AutomaticHdl_Impl));
|
|
|
|
aAdjustLB.SetSelectHdl(LINK(this, SvxRubyDialog, AdjustHdl_Impl));
|
2001-06-01 09:10:39 +00:00
|
|
|
aPositionLB.SetSelectHdl(LINK(this, SvxRubyDialog, PositionHdl_Impl));
|
2001-02-02 10:41:31 +00:00
|
|
|
aCharStyleLB.SetSelectHdl(LINK(this, SvxRubyDialog, CharStyleHdl_Impl));
|
|
|
|
|
|
|
|
Link aScrLk(LINK(this, SvxRubyDialog, ScrollHdl_Impl));
|
|
|
|
aScrollSB.SetScrollHdl( aScrLk );
|
|
|
|
aScrollSB.SetEndScrollHdl( aScrLk );
|
|
|
|
|
2001-02-16 13:47:12 +00:00
|
|
|
Link aEditLk(LINK(this, SvxRubyDialog, EditModifyHdl_Impl));
|
2001-07-17 07:17:55 +00:00
|
|
|
Link aScrollLk(LINK(this, SvxRubyDialog, EditScrollHdl_Impl));
|
2001-07-20 12:56:49 +00:00
|
|
|
Link aJumpLk(LINK(this, SvxRubyDialog, EditJumpHdl_Impl));
|
2011-01-10 16:11:35 +01:00
|
|
|
for(sal_uInt16 i = 0; i < 8; i++)
|
2001-07-17 07:17:55 +00:00
|
|
|
{
|
2001-02-16 13:47:12 +00:00
|
|
|
aEditArr[i]->SetModifyHdl(aEditLk);
|
2001-07-20 12:56:49 +00:00
|
|
|
aEditArr[i]->SetJumpHdl(aJumpLk);
|
2001-07-17 07:17:55 +00:00
|
|
|
if(!i || 7 == i)
|
|
|
|
aEditArr[i]->SetScrollHdl(aScrollLk);
|
|
|
|
}
|
2002-08-07 13:18:10 +00:00
|
|
|
|
|
|
|
UpdateColors();
|
2011-01-21 13:04:02 +01:00
|
|
|
|
|
|
|
String leftLabelName = aLeftFT.GetText(), rightLabelName = aRightFT.GetText();
|
|
|
|
aLeft2ED.SetAccessibleName(leftLabelName);
|
|
|
|
aLeft3ED.SetAccessibleName(leftLabelName);
|
|
|
|
aLeft4ED.SetAccessibleName(leftLabelName);
|
|
|
|
aRight2ED.SetAccessibleName(rightLabelName);
|
|
|
|
aRight3ED.SetAccessibleName(rightLabelName);
|
|
|
|
aRight4ED.SetAccessibleName(rightLabelName);
|
2001-01-10 15:00:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SvxRubyDialog::~SvxRubyDialog()
|
|
|
|
{
|
2001-02-02 10:41:31 +00:00
|
|
|
ClearCharStyleList();
|
2002-04-19 11:51:22 +00:00
|
|
|
EventObject aEvent;
|
|
|
|
xImpl->disposing(aEvent);
|
2001-01-10 15:00:52 +00:00
|
|
|
}
|
|
|
|
|
2001-02-02 10:41:31 +00:00
|
|
|
void SvxRubyDialog::ClearCharStyleList()
|
2001-01-10 15:00:52 +00:00
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
for(sal_uInt16 i = 0; i < aCharStyleLB.GetEntryCount(); i++)
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
|
|
|
void* pData = aCharStyleLB.GetEntryData(i);
|
|
|
|
delete (OUString*)pData;
|
|
|
|
}
|
2002-08-07 12:47:42 +00:00
|
|
|
aCharStyleLB.Clear();
|
2001-01-10 15:00:52 +00:00
|
|
|
}
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Bool SvxRubyDialog::Close()
|
2001-01-10 15:00:52 +00:00
|
|
|
{
|
2001-02-02 10:41:31 +00:00
|
|
|
pBindings->GetDispatcher()->Execute( SID_RUBY_DIALOG,
|
|
|
|
SFX_CALLMODE_ASYNCHRON |
|
|
|
|
SFX_CALLMODE_RECORD);
|
2011-01-10 16:11:35 +01:00
|
|
|
return sal_True;
|
2001-01-10 15:00:52 +00:00
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
|
|
|
|
void SvxRubyDialog::Activate()
|
|
|
|
{
|
|
|
|
SfxModelessDialog::Activate();
|
|
|
|
SfxPoolItem* pState = 0;
|
|
|
|
SfxItemState eState = pBindings->QueryState( SID_STYLE_DESIGNER, pState );
|
2001-07-03 10:51:56 +00:00
|
|
|
sal_Bool bEnable = (eState < SFX_ITEM_AVAILABLE) || !pState || !((SfxBoolItem*)pState)->GetValue();
|
|
|
|
aStylistPB.Enable(bEnable);
|
2001-02-02 10:41:31 +00:00
|
|
|
//get selection from current view frame
|
|
|
|
SfxViewFrame* pCurFrm = SfxViewFrame::Current();
|
2009-12-15 23:07:57 +01:00
|
|
|
Reference< XController > xCtrl = pCurFrm->GetFrame().GetController();
|
2001-11-02 10:11:18 +00:00
|
|
|
pImpl->SetController(xCtrl);
|
|
|
|
if(pImpl->HasSelectionChanged())
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
|
|
|
|
Reference< XRubySelection > xRubySel = pImpl->GetRubySelection();
|
|
|
|
pImpl->UpdateRubyValues(aAutoDetectionCB.IsChecked());
|
|
|
|
EnableControls(xRubySel.is());
|
|
|
|
if(xRubySel.is())
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
Reference< XModel > xModel = pImpl->GetModel();
|
|
|
|
const String sCharStyleSelect = aCharStyleLB.GetSelectEntry();
|
2001-02-02 10:41:31 +00:00
|
|
|
ClearCharStyleList();
|
2001-11-02 10:11:18 +00:00
|
|
|
Reference<XStyleFamiliesSupplier> xSupplier(xModel, UNO_QUERY);
|
2001-02-02 10:41:31 +00:00
|
|
|
if(xSupplier.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference<XNameAccess> xFam = xSupplier->getStyleFamilies();
|
|
|
|
Any aChar = xFam->getByName(C2U(cCharacterStyles));
|
|
|
|
Reference<XNameContainer> xChar;
|
|
|
|
aChar >>= xChar;
|
|
|
|
Reference<XIndexAccess> xCharIdx(xChar, UNO_QUERY);
|
|
|
|
if(xCharIdx.is())
|
|
|
|
{
|
|
|
|
OUString sUIName(C2U(cDisplayName));
|
|
|
|
for(sal_Int32 nStyle = 0; nStyle < xCharIdx->getCount(); nStyle++)
|
|
|
|
{
|
|
|
|
Any aStyle = xCharIdx->getByIndex(nStyle);
|
|
|
|
Reference<XStyle> xStyle;
|
|
|
|
aStyle >>= xStyle;
|
|
|
|
Reference<XPropertySet> xPrSet(xStyle, UNO_QUERY);
|
|
|
|
OUString sName, sCoreName;
|
|
|
|
if(xPrSet.is())
|
|
|
|
{
|
|
|
|
Reference<XPropertySetInfo> xInfo = xPrSet->getPropertySetInfo();
|
|
|
|
if(xInfo->hasPropertyByName(sUIName))
|
|
|
|
{
|
|
|
|
Any aName = xPrSet->getPropertyValue(sUIName);
|
|
|
|
aName >>= sName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Reference<XNamed> xNamed(xStyle, UNO_QUERY);
|
|
|
|
if(xNamed.is())
|
|
|
|
{
|
|
|
|
sCoreName = xNamed->getName();
|
|
|
|
if(!sName.getLength())
|
|
|
|
sName = sCoreName;
|
|
|
|
}
|
|
|
|
if(sName.getLength())
|
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nPos = aCharStyleLB.InsertEntry(sName);
|
2001-02-02 10:41:31 +00:00
|
|
|
aCharStyleLB.SetEntryData( nPos, new OUString(sCoreName) );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL("exception in style access");
|
2001-02-02 10:41:31 +00:00
|
|
|
}
|
2001-11-02 10:11:18 +00:00
|
|
|
if(sCharStyleSelect.Len())
|
|
|
|
aCharStyleLB.SelectEntry(sCharStyleSelect);
|
2001-02-02 10:41:31 +00:00
|
|
|
}
|
|
|
|
aCharStyleLB.Enable(xSupplier.is());
|
|
|
|
aCharStyleFT.Enable(xSupplier.is());
|
|
|
|
}
|
|
|
|
Update();
|
2001-02-16 13:47:12 +00:00
|
|
|
aPreviewWin.Invalidate();
|
2001-02-02 10:41:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvxRubyDialog::Deactivate()
|
|
|
|
{
|
|
|
|
SfxModelessDialog::Deactivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvxRubyDialog::SetText(sal_Int32 nPos, Edit& rLeft, Edit& rRight)
|
|
|
|
{
|
|
|
|
OUString sLeft, sRight;
|
2001-11-02 10:11:18 +00:00
|
|
|
const Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Bool bEnable = aRubyValues.getLength() > nPos;
|
2001-02-02 10:41:31 +00:00
|
|
|
if(bEnable)
|
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
const Sequence<PropertyValue> aProps = aRubyValues.getConstArray()[nPos];
|
2001-02-02 10:41:31 +00:00
|
|
|
const PropertyValue* pProps = aProps.getConstArray();
|
|
|
|
for(sal_Int32 nProp = 0; nProp < aProps.getLength(); nProp++)
|
|
|
|
{
|
|
|
|
if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyBaseText)))
|
|
|
|
pProps[nProp].Value >>= sLeft;
|
|
|
|
else if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyText)))
|
|
|
|
pProps[nProp].Value >>= sRight;
|
|
|
|
}
|
|
|
|
}
|
2001-06-19 09:32:09 +00:00
|
|
|
else if(!nPos)
|
2011-01-10 16:11:35 +01:00
|
|
|
bEnable = sal_True;
|
2001-02-02 10:41:31 +00:00
|
|
|
rLeft.Enable(bEnable);
|
|
|
|
rRight.Enable(bEnable);
|
|
|
|
rLeft.SetText(sLeft);
|
|
|
|
rRight.SetText(sRight);
|
|
|
|
rLeft.SaveValue();
|
|
|
|
rRight.SaveValue();
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SvxRubyDialog::GetText()
|
|
|
|
{
|
2006-06-19 14:27:24 +00:00
|
|
|
long nTempLastPos = GetLastPos();
|
2001-04-06 08:55:02 +00:00
|
|
|
for(int i = 0; i < 8; i+=2)
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
|
|
|
if(aEditArr[i]->IsEnabled() &&
|
|
|
|
(aEditArr[i]->GetText() != aEditArr[i]->GetSavedValue() ||
|
|
|
|
aEditArr[i + 1]->GetText() != aEditArr[i + 1]->GetSavedValue()))
|
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
|
2008-11-10 15:06:12 +00:00
|
|
|
DBG_ASSERT(aRubyValues.getLength() > (i / 2 + nTempLastPos), "wrong index" );
|
2011-01-10 16:11:35 +01:00
|
|
|
SetModified(sal_True);
|
2006-06-19 14:27:24 +00:00
|
|
|
Sequence<PropertyValue> &rProps = aRubyValues.getArray()[i / 2 + nTempLastPos];
|
2001-02-02 10:41:31 +00:00
|
|
|
PropertyValue* pProps = rProps.getArray();
|
|
|
|
for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
|
|
|
|
{
|
|
|
|
if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyBaseText)))
|
|
|
|
pProps[nProp].Value <<= OUString(aEditArr[i]->GetText());
|
|
|
|
else if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyText)))
|
|
|
|
pProps[nProp].Value <<= OUString(aEditArr[i + 1]->GetText());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SvxRubyDialog::Update()
|
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
const Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
|
|
|
|
sal_Int32 nLen = aRubyValues.getLength();
|
2001-02-02 10:41:31 +00:00
|
|
|
aScrollSB.Enable(nLen > 4);
|
|
|
|
aScrollSB.SetRange( Range(0, nLen > 4 ? nLen - 4 : 0));
|
|
|
|
aScrollSB.SetThumbPos(0);
|
|
|
|
SetLastPos(0);
|
2011-01-10 16:11:35 +01:00
|
|
|
SetModified(sal_False);
|
2001-02-02 10:41:31 +00:00
|
|
|
|
|
|
|
sal_Int16 nAdjust = -1;
|
2001-06-01 09:10:39 +00:00
|
|
|
sal_Int16 nPosition = -1;
|
2001-02-02 10:41:31 +00:00
|
|
|
OUString sCharStyleName, sTmp;
|
|
|
|
sal_Bool bCharStyleEqual = sal_True;
|
|
|
|
for(sal_Int32 nRuby = 0; nRuby < nLen; nRuby++)
|
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
const Sequence<PropertyValue> &rProps = aRubyValues.getConstArray()[nRuby];
|
|
|
|
const PropertyValue* pProps = rProps.getConstArray();
|
2001-02-02 10:41:31 +00:00
|
|
|
for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
|
|
|
|
{
|
|
|
|
if(nAdjust > -2 &&
|
|
|
|
pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyAdjust)))
|
|
|
|
{
|
2006-10-12 11:25:27 +00:00
|
|
|
sal_Int16 nTmp = sal_Int16();
|
2001-02-02 10:41:31 +00:00
|
|
|
pProps[nProp].Value >>= nTmp;
|
|
|
|
if(!nRuby)
|
|
|
|
nAdjust = nTmp;
|
|
|
|
else if(nAdjust != nTmp)
|
|
|
|
nAdjust = -2;
|
|
|
|
}
|
2001-06-01 09:10:39 +00:00
|
|
|
if(nPosition > -2 &&
|
|
|
|
pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyIsAbove)))
|
|
|
|
{
|
|
|
|
sal_Bool bTmp = *(sal_Bool*)pProps[nProp].Value.getValue();
|
|
|
|
if(!nRuby)
|
|
|
|
nPosition = bTmp ? 0 : 1;
|
2008-12-11 07:05:03 +00:00
|
|
|
else if( (!nPosition && !bTmp) || (nPosition == 1 && bTmp) )
|
2001-06-01 09:10:39 +00:00
|
|
|
nPosition = -2;
|
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
if(bCharStyleEqual &&
|
2001-02-19 06:28:26 +00:00
|
|
|
pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyCharStyleName)))
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
|
|
|
pProps[nProp].Value >>= sTmp;
|
|
|
|
if(!nRuby)
|
|
|
|
sCharStyleName = sTmp;
|
|
|
|
else if(sCharStyleName != sTmp)
|
|
|
|
bCharStyleEqual = sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-19 09:32:09 +00:00
|
|
|
if(!nLen)
|
|
|
|
{
|
|
|
|
//enable selection if the ruby list is empty
|
|
|
|
nAdjust = 0;
|
|
|
|
nPosition = 0;
|
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
if(nAdjust > -1)
|
|
|
|
aAdjustLB.SelectEntryPos(nAdjust);
|
|
|
|
else
|
|
|
|
aAdjustLB.SetNoSelection();
|
2001-06-01 09:10:39 +00:00
|
|
|
if(nPosition > -1)
|
|
|
|
aPositionLB.SelectEntryPos(nPosition ? 1 : 0);
|
2008-12-11 07:05:03 +00:00
|
|
|
if(!nLen || (bCharStyleEqual && !sCharStyleName.getLength()))
|
2001-07-03 10:51:56 +00:00
|
|
|
sCharStyleName = C2U(cRubies);
|
2001-02-02 10:41:31 +00:00
|
|
|
if(sCharStyleName.getLength())
|
2001-06-01 09:10:39 +00:00
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
for(sal_uInt16 i = 0; i < aCharStyleLB.GetEntryCount(); i++)
|
2001-06-01 09:10:39 +00:00
|
|
|
{
|
|
|
|
const OUString* pCoreName = (const OUString*)aCharStyleLB.GetEntryData(i);
|
|
|
|
if(pCoreName && sCharStyleName == *pCoreName)
|
|
|
|
{
|
|
|
|
aCharStyleLB.SelectEntryPos(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
else
|
|
|
|
aCharStyleLB.SetNoSelection();
|
|
|
|
|
|
|
|
ScrollHdl_Impl(&aScrollSB);
|
2001-02-16 13:47:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvxRubyDialog::GetCurrentText(String& rBase, String& rRuby)
|
|
|
|
{
|
|
|
|
rBase = aEditArr[nCurrentEdit * 2]->GetText();
|
|
|
|
rRuby = aEditArr[nCurrentEdit * 2 + 1]->GetText();
|
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, ScrollHdl_Impl, ScrollBar*, pScroll)
|
|
|
|
{
|
|
|
|
long nPos = pScroll->GetThumbPos();
|
2006-06-19 14:27:24 +00:00
|
|
|
if(GetLastPos() != nPos)
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
|
|
|
GetText();
|
|
|
|
}
|
|
|
|
SetText(nPos++, aLeft1ED, aRight1ED);
|
|
|
|
SetText(nPos++, aLeft2ED, aRight2ED);
|
|
|
|
SetText(nPos++, aLeft3ED, aRight3ED);
|
|
|
|
SetText(nPos, aLeft4ED, aRight4ED);
|
|
|
|
SetLastPos(nPos - 3);
|
2001-02-16 13:47:12 +00:00
|
|
|
aPreviewWin.Invalidate();
|
2001-02-02 10:41:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, ApplyHdl_Impl, PushButton*, EMPTYARG)
|
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
const Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
|
|
|
|
if(!aRubyValues.getLength())
|
2001-06-19 09:32:09 +00:00
|
|
|
{
|
|
|
|
AssertOneEntry();
|
|
|
|
PositionHdl_Impl(&aPositionLB);
|
|
|
|
AdjustHdl_Impl(&aAdjustLB);
|
|
|
|
CharStyleHdl_Impl(&aCharStyleLB);
|
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
GetText();
|
2002-09-04 09:55:00 +00:00
|
|
|
//reset all edit fields - SaveValue is called
|
|
|
|
ScrollHdl_Impl(&aScrollSB);
|
|
|
|
|
2001-11-02 10:11:18 +00:00
|
|
|
Reference<XRubySelection> xSelection = pImpl->GetRubySelection();
|
|
|
|
if(IsModified() && xSelection.is())
|
2001-07-24 06:51:06 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
xSelection->setRubyList(aRubyValues, aAutoDetectionCB.IsChecked());
|
2001-07-24 06:51:06 +00:00
|
|
|
}
|
|
|
|
catch(Exception& )
|
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL("Exception caught");
|
2001-07-24 06:51:06 +00:00
|
|
|
}
|
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, CloseHdl_Impl, PushButton*, EMPTYARG)
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, StylistHdl_Impl, PushButton*, EMPTYARG)
|
|
|
|
{
|
|
|
|
SfxPoolItem* pState = 0;
|
|
|
|
SfxItemState eState = pBindings->QueryState( SID_STYLE_DESIGNER, pState );
|
|
|
|
if(eState <= SFX_ITEM_SET || !pState || !((SfxBoolItem*)pState)->GetValue())
|
|
|
|
{
|
|
|
|
pBindings->GetDispatcher()->Execute( SID_STYLE_DESIGNER,
|
|
|
|
SFX_CALLMODE_ASYNCHRON |
|
|
|
|
SFX_CALLMODE_RECORD);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, AutomaticHdl_Impl, CheckBox*, pBox)
|
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
pImpl->UpdateRubyValues(pBox->IsChecked());
|
|
|
|
Update();
|
2001-02-02 10:41:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, AdjustHdl_Impl, ListBox*, pBox)
|
|
|
|
{
|
2001-06-19 09:32:09 +00:00
|
|
|
AssertOneEntry();
|
2001-02-02 10:41:31 +00:00
|
|
|
sal_Int16 nAdjust = pBox->GetSelectEntryPos();
|
2001-11-02 10:11:18 +00:00
|
|
|
Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
|
|
|
|
for(sal_Int32 nRuby = 0; nRuby < aRubyValues.getLength(); nRuby++)
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
Sequence<PropertyValue> &rProps = aRubyValues.getArray()[nRuby];
|
2001-02-02 10:41:31 +00:00
|
|
|
PropertyValue* pProps = rProps.getArray();
|
|
|
|
for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
|
|
|
|
{
|
|
|
|
if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyAdjust)))
|
|
|
|
pProps[nProp].Value <<= nAdjust;
|
|
|
|
}
|
2011-01-10 16:11:35 +01:00
|
|
|
SetModified(sal_True);
|
2001-02-02 10:41:31 +00:00
|
|
|
}
|
2001-02-16 13:47:12 +00:00
|
|
|
aPreviewWin.Invalidate();
|
2001-02-02 10:41:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2001-06-01 09:10:39 +00:00
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, PositionHdl_Impl, ListBox*, pBox)
|
|
|
|
{
|
2001-06-19 09:32:09 +00:00
|
|
|
AssertOneEntry();
|
2001-06-01 09:10:39 +00:00
|
|
|
sal_Bool bAbove = !pBox->GetSelectEntryPos();
|
|
|
|
const Type& rType = ::getBooleanCppuType();
|
2001-11-02 10:11:18 +00:00
|
|
|
Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
|
|
|
|
for(sal_Int32 nRuby = 0; nRuby < aRubyValues.getLength(); nRuby++)
|
2001-06-01 09:10:39 +00:00
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
Sequence<PropertyValue> &rProps = aRubyValues.getArray()[nRuby];
|
2001-06-01 09:10:39 +00:00
|
|
|
PropertyValue* pProps = rProps.getArray();
|
|
|
|
for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
|
|
|
|
{
|
|
|
|
if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyIsAbove)))
|
|
|
|
pProps[nProp].Value.setValue(&bAbove, rType);
|
|
|
|
}
|
2011-01-10 16:11:35 +01:00
|
|
|
SetModified(sal_True);
|
2001-06-01 09:10:39 +00:00
|
|
|
}
|
|
|
|
aPreviewWin.Invalidate();
|
|
|
|
return 0;
|
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
|
2006-06-19 14:27:24 +00:00
|
|
|
IMPL_LINK(SvxRubyDialog, CharStyleHdl_Impl, ListBox*, EMPTYARG )
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
2001-06-19 09:32:09 +00:00
|
|
|
AssertOneEntry();
|
2001-02-16 13:47:12 +00:00
|
|
|
OUString sStyleName;
|
2001-06-19 09:32:09 +00:00
|
|
|
if(LISTBOX_ENTRY_NOTFOUND != aCharStyleLB.GetSelectEntryPos())
|
2001-02-16 13:47:12 +00:00
|
|
|
sStyleName = *(OUString*) aCharStyleLB.GetEntryData(aCharStyleLB.GetSelectEntryPos());
|
2001-11-02 10:11:18 +00:00
|
|
|
Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
|
|
|
|
for(sal_Int32 nRuby = 0; nRuby < aRubyValues.getLength(); nRuby++)
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
Sequence<PropertyValue> &rProps = aRubyValues.getArray()[nRuby];
|
2001-02-02 10:41:31 +00:00
|
|
|
PropertyValue* pProps = rProps.getArray();
|
|
|
|
for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
|
|
|
|
{
|
2001-02-19 06:28:26 +00:00
|
|
|
if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyCharStyleName)))
|
2001-02-16 13:47:12 +00:00
|
|
|
{
|
|
|
|
pProps[nProp].Value <<= sStyleName;
|
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
}
|
2011-01-10 16:11:35 +01:00
|
|
|
SetModified(sal_True);
|
2001-02-02 10:41:31 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2001-02-16 13:47:12 +00:00
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, EditModifyHdl_Impl, Edit*, pEdit)
|
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
for(sal_uInt16 i = 0; i < 8; i++)
|
2001-02-16 13:47:12 +00:00
|
|
|
{
|
|
|
|
if(pEdit == aEditArr[i])
|
|
|
|
{
|
|
|
|
nCurrentEdit = i / 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aPreviewWin.Invalidate();
|
|
|
|
return 0;
|
|
|
|
}
|
2001-07-17 07:17:55 +00:00
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, EditScrollHdl_Impl, sal_Int32*, pParam)
|
|
|
|
{
|
|
|
|
long nRet = 0;
|
|
|
|
if(aScrollSB.IsEnabled())
|
|
|
|
{
|
|
|
|
//scroll forward
|
2001-07-20 12:56:49 +00:00
|
|
|
if(*pParam > 0 && (aEditArr[7]->HasFocus() || aEditArr[6]->HasFocus() ))
|
2001-07-17 07:17:55 +00:00
|
|
|
{
|
|
|
|
if(aScrollSB.GetRangeMax() > aScrollSB.GetThumbPos())
|
|
|
|
{
|
|
|
|
aScrollSB.SetThumbPos(aScrollSB.GetThumbPos() + 1);
|
|
|
|
aEditArr[6]->GrabFocus();
|
|
|
|
nRet = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//scroll backward
|
2001-07-20 12:56:49 +00:00
|
|
|
else if(aScrollSB.GetThumbPos() && (aEditArr[0]->HasFocus()||aEditArr[1]->HasFocus()) )
|
2001-07-17 07:17:55 +00:00
|
|
|
{
|
|
|
|
aScrollSB.SetThumbPos(aScrollSB.GetThumbPos() - 1);
|
|
|
|
aEditArr[1]->GrabFocus();
|
|
|
|
nRet = 1;
|
|
|
|
}
|
|
|
|
if(nRet)
|
|
|
|
ScrollHdl_Impl(&aScrollSB);
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
2001-07-20 12:56:49 +00:00
|
|
|
|
|
|
|
IMPL_LINK(SvxRubyDialog, EditJumpHdl_Impl, sal_Int32*, pParam)
|
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nIndex = USHRT_MAX;
|
|
|
|
for(sal_uInt16 i = 0; i < 8; i++)
|
2001-07-20 12:56:49 +00:00
|
|
|
{
|
|
|
|
if(aEditArr[i]->HasFocus())
|
|
|
|
nIndex = i;
|
|
|
|
}
|
|
|
|
if(nIndex < 8)
|
|
|
|
{
|
|
|
|
if(*pParam > 0)
|
|
|
|
{
|
|
|
|
if(nIndex < 6)
|
|
|
|
aEditArr[nIndex + 2]->GrabFocus();
|
|
|
|
else if( EditScrollHdl_Impl(pParam))
|
|
|
|
aEditArr[nIndex]->GrabFocus();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(nIndex > 1)
|
|
|
|
aEditArr[nIndex - 2]->GrabFocus();
|
|
|
|
else if( EditScrollHdl_Impl(pParam))
|
|
|
|
aEditArr[nIndex]->GrabFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
};
|
2001-02-16 13:47:12 +00:00
|
|
|
|
2001-06-19 09:32:09 +00:00
|
|
|
void SvxRubyDialog::AssertOneEntry()
|
|
|
|
{
|
2001-11-02 10:11:18 +00:00
|
|
|
pImpl->AssertOneEntry();
|
2001-06-19 09:32:09 +00:00
|
|
|
}
|
2002-08-07 13:18:10 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SvxRubyDialog::UpdateColors( void )
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
2003-03-27 14:06:05 +00:00
|
|
|
svtools::ColorConfig aColorConfig;
|
|
|
|
|
2002-08-12 08:35:38 +00:00
|
|
|
Font aFnt( aPreviewWin.GetFont() );
|
2003-03-27 14:06:05 +00:00
|
|
|
|
|
|
|
Color aNewTextCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
|
2002-08-12 08:35:38 +00:00
|
|
|
Color aNewFillCol( rStyleSettings.GetWindowColor() );
|
2002-08-07 13:18:10 +00:00
|
|
|
|
|
|
|
if( aNewFillCol != aFnt.GetFillColor() || aNewTextCol != aFnt.GetColor() )
|
|
|
|
{
|
|
|
|
aFnt.SetFillColor( aNewFillCol );
|
|
|
|
aFnt.SetColor( aNewTextCol );
|
|
|
|
aPreviewWin.SetFont( aFnt );
|
|
|
|
|
|
|
|
aPreviewWin.Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SvxRubyDialog::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
SfxModelessDialog::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
|
|
|
|
UpdateColors();
|
|
|
|
}
|
|
|
|
|
2001-02-16 13:47:12 +00:00
|
|
|
RubyPreview::RubyPreview(SvxRubyDialog& rParent, const ResId& rResId) :
|
|
|
|
Window(&rParent, rResId),
|
|
|
|
rParentDlg(rParent)
|
|
|
|
{
|
|
|
|
SetMapMode(MAP_TWIP);
|
|
|
|
Size aWinSize = GetOutputSize();
|
|
|
|
|
|
|
|
Font aFont = GetFont();
|
|
|
|
aFont.SetHeight(aWinSize.Height() / 4);
|
|
|
|
SetFont(aFont);
|
2002-08-12 08:35:38 +00:00
|
|
|
|
|
|
|
SetBorderStyle( WINDOW_BORDER_MONO );
|
2001-02-16 13:47:12 +00:00
|
|
|
}
|
2001-02-02 10:41:31 +00:00
|
|
|
|
2006-06-19 14:27:24 +00:00
|
|
|
void RubyPreview::Paint( const Rectangle& /* rRect */ )
|
2001-02-02 10:41:31 +00:00
|
|
|
{
|
2001-07-03 10:51:56 +00:00
|
|
|
Font aRubyFont = GetFont();
|
|
|
|
Font aSaveFont(aRubyFont);
|
|
|
|
aRubyFont.SetHeight(aRubyFont.GetHeight() * 70 / 100);
|
|
|
|
|
2001-02-16 13:47:12 +00:00
|
|
|
Size aWinSize = GetOutputSize();
|
2001-02-02 10:41:31 +00:00
|
|
|
Rectangle aRect(Point(0, 0), aWinSize);
|
2002-08-12 08:35:38 +00:00
|
|
|
SetLineColor();
|
2002-08-07 13:18:10 +00:00
|
|
|
SetFillColor( aSaveFont.GetFillColor() );
|
2001-02-02 10:41:31 +00:00
|
|
|
DrawRect(aRect);
|
2001-02-16 13:47:12 +00:00
|
|
|
|
|
|
|
String sBaseText, sRubyText;
|
|
|
|
rParentDlg.GetCurrentText(sBaseText, sRubyText);
|
|
|
|
|
|
|
|
long nTextHeight = GetTextHeight();
|
|
|
|
long nBaseWidth = GetTextWidth(sBaseText);
|
2001-07-03 10:51:56 +00:00
|
|
|
SetFont(aRubyFont);
|
2001-02-16 13:47:12 +00:00
|
|
|
long nRubyWidth = GetTextWidth(sRubyText);
|
2001-07-03 10:51:56 +00:00
|
|
|
SetFont(aSaveFont);
|
2001-02-16 13:47:12 +00:00
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nAdjust = rParentDlg.aAdjustLB.GetSelectEntryPos();
|
2001-02-16 13:47:12 +00:00
|
|
|
//use center if no adjustment is available
|
|
|
|
if(nAdjust > 4)
|
|
|
|
nAdjust = 1;
|
|
|
|
|
|
|
|
//which part is stretched ?
|
|
|
|
sal_Bool bRubyStretch = nBaseWidth >= nRubyWidth;
|
|
|
|
|
|
|
|
long nCenter = aWinSize.Width() / 2;
|
|
|
|
long nLeftStart = nCenter - (bRubyStretch ? (nBaseWidth / 2) : (nRubyWidth / 2));
|
|
|
|
long nRightEnd = nCenter + (bRubyStretch ? (nBaseWidth / 2) : (nRubyWidth / 2));
|
|
|
|
|
|
|
|
long nYRuby = aWinSize.Height() / 4 - nTextHeight / 2;
|
|
|
|
long nYBase = aWinSize.Height() * 3 / 4 - nTextHeight / 2;
|
2001-06-01 09:10:39 +00:00
|
|
|
|
|
|
|
//use above also if no selection is set
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Bool bAbove = rParentDlg.aPositionLB.GetSelectEntryPos() != 1;
|
2001-06-01 09:10:39 +00:00
|
|
|
if(!bAbove)
|
|
|
|
{
|
|
|
|
long nTmp = nYRuby;
|
|
|
|
nYRuby = nYBase;
|
|
|
|
nYBase = nTmp;
|
|
|
|
}
|
2001-02-16 13:47:12 +00:00
|
|
|
long nYOutput, nOutTextWidth;
|
|
|
|
String sOutputText;
|
|
|
|
|
2001-07-03 10:51:56 +00:00
|
|
|
|
2001-02-16 13:47:12 +00:00
|
|
|
if(bRubyStretch)
|
|
|
|
{
|
|
|
|
DrawText( Point( nLeftStart , nYBase), sBaseText );
|
|
|
|
nYOutput = nYRuby;
|
|
|
|
sOutputText = sRubyText;
|
|
|
|
nOutTextWidth = nRubyWidth;
|
2001-07-03 10:51:56 +00:00
|
|
|
SetFont(aRubyFont);
|
2001-02-16 13:47:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-03 10:51:56 +00:00
|
|
|
SetFont(aRubyFont);
|
2001-02-16 13:47:12 +00:00
|
|
|
DrawText( Point( nLeftStart , nYRuby), sRubyText );
|
|
|
|
nYOutput = nYBase;
|
|
|
|
sOutputText = sBaseText;
|
|
|
|
nOutTextWidth = nBaseWidth;
|
2001-07-03 10:51:56 +00:00
|
|
|
SetFont(aSaveFont);
|
2001-02-16 13:47:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(nAdjust)
|
|
|
|
{
|
|
|
|
case RubyAdjust_LEFT:
|
|
|
|
DrawText( Point( nLeftStart , nYOutput), sOutputText );
|
|
|
|
break;
|
|
|
|
case RubyAdjust_RIGHT:
|
|
|
|
DrawText( Point( nRightEnd - nOutTextWidth, nYOutput), sOutputText );
|
|
|
|
break;
|
|
|
|
case RubyAdjust_INDENT_BLOCK:
|
|
|
|
{
|
|
|
|
long nCharWidth = GetTextWidth(String::CreateFromAscii("X"));
|
|
|
|
if(nOutTextWidth < (nRightEnd - nLeftStart - nCharWidth))
|
|
|
|
{
|
|
|
|
nCharWidth /= 2;
|
|
|
|
nLeftStart += nCharWidth;
|
|
|
|
nRightEnd -= nCharWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// no break!
|
|
|
|
case RubyAdjust_BLOCK:
|
|
|
|
if(sOutputText.Len() > 1)
|
|
|
|
{
|
|
|
|
xub_StrLen nCount = sOutputText.Len();
|
|
|
|
long nSpace = ((nRightEnd - nLeftStart) - GetTextWidth(sOutputText)) / (nCount - 1);
|
|
|
|
for(xub_StrLen i = 0; i < nCount; i++)
|
|
|
|
{
|
|
|
|
sal_Unicode cChar = sOutputText.GetChar(i);
|
|
|
|
DrawText( Point( nLeftStart , nYOutput), cChar);
|
|
|
|
long nCharWidth = GetTextWidth(cChar);
|
|
|
|
nLeftStart += nCharWidth + nSpace;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//no break;
|
|
|
|
case RubyAdjust_CENTER:
|
|
|
|
DrawText( Point( nCenter - nOutTextWidth / 2 , nYOutput), sOutputText );
|
|
|
|
break;
|
|
|
|
}
|
2001-07-03 10:51:56 +00:00
|
|
|
SetFont(aSaveFont);
|
2001-02-16 13:47:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RubyEdit::GetFocus()
|
|
|
|
{
|
|
|
|
GetModifyHdl().Call(this);
|
|
|
|
Edit::GetFocus();
|
2001-02-02 10:41:31 +00:00
|
|
|
}
|
2001-01-10 15:00:52 +00:00
|
|
|
|
2001-07-17 07:17:55 +00:00
|
|
|
long RubyEdit::PreNotify( NotifyEvent& rNEvt )
|
|
|
|
{
|
|
|
|
long nHandled = 0;
|
|
|
|
if ( rNEvt.GetType() == EVENT_KEYINPUT )
|
|
|
|
{
|
|
|
|
const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
|
|
|
|
const KeyCode& rKeyCode = pKEvt->GetKeyCode();
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_uInt16 nMod = rKeyCode.GetModifier();
|
|
|
|
sal_uInt16 nCode = rKeyCode.GetCode();
|
2001-07-20 12:56:49 +00:00
|
|
|
if( nCode == KEY_TAB && (!nMod || KEY_SHIFT == nMod))
|
2001-07-17 07:17:55 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nParam = KEY_SHIFT == nMod ? -1 : 1;
|
|
|
|
if(aScrollHdl.IsSet() && aScrollHdl.Call(&nParam))
|
|
|
|
nHandled = 1;
|
|
|
|
}
|
2001-07-20 12:56:49 +00:00
|
|
|
else if(KEY_UP == nCode || KEY_DOWN == nCode)
|
|
|
|
{
|
|
|
|
sal_Int32 nParam = KEY_UP == nCode ? -1 : 1;
|
|
|
|
aJumpHdl.Call(&nParam);
|
|
|
|
}
|
2001-07-17 07:17:55 +00:00
|
|
|
}
|
|
|
|
if(!nHandled)
|
|
|
|
nHandled = Edit::PreNotify(rNEvt);
|
|
|
|
return nHandled;
|
|
|
|
}
|
2001-02-16 13:47:12 +00:00
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|