Files
libreoffice/sd/source/ui/func/futhes.cxx

200 lines
6.0 KiB
C++
Raw Normal View History

2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* $RCSfile: futhes.cxx,v $
2000-09-18 16:07:07 +00:00
*
* $Revision: 1.12 $
2000-09-18 16:07:07 +00:00
*
* last change: $Author: rt $ $Date: 2005-12-14 17:05:32 $
2000-09-18 16:07:07 +00:00
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
2000-09-18 16:07:07 +00:00
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
2000-09-18 16:07:07 +00:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
2000-09-18 16:07:07 +00:00
*
* This library 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 for more details.
2000-09-18 16:07:07 +00:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
2000-09-18 16:07:07 +00:00
*
************************************************************************/
#pragma hdrstop
#include "futhes.hxx"
2000-09-18 16:07:07 +00:00
#include <tools/pstm.hxx>
#include <svx/outliner.hxx>
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SVDOBJ_HXX //autogen
#include <svx/svdobj.hxx>
#endif
#ifndef _SVDOTEXT_HXX //autogen
#include <svx/svdotext.hxx>
#endif
2000-12-08 12:31:46 +00:00
#ifndef _EEITEM_HXX
#include <svx/eeitem.hxx>
#endif
2000-09-18 16:07:07 +00:00
#define ITEMID_LANGUAGE SID_ATTR_CHAR_LANGUAGE
#include <svx/dialogs.hrc>
#include <svx/svxerr.hxx>
#include <svx/dialmgr.hxx>
#ifndef _UNO_LINGU_HXX
#include <svx/unolingu.hxx>
#endif
2000-11-17 10:13:31 +00:00
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
2000-09-18 16:07:07 +00:00
#include "app.hrc"
#include "strings.hrc"
#include "drawdoc.hxx"
#include "app.hxx"
#ifndef SD_VIEW_HXX
#include "View.hxx"
#endif
#ifndef SD_OUTLINER_HXX
#include "Outliner.hxx"
#endif
#ifndef SD_DRAW_VIEW_SHELL_HXX
#include "DrawViewShell.hxx"
#endif
#ifndef SD_OUTLINE_VIEW_SHELL_HXX
#include "OutlineViewShell.hxx"
#endif
#ifndef SD_WINDOW_SHELL_HXX
#include "Window.hxx"
#endif
2000-09-18 16:07:07 +00:00
#include "sdresid.hxx"
using ::rtl::OUString;
2000-09-18 16:07:07 +00:00
using namespace ::com::sun::star;
2000-10-25 09:34:04 +00:00
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::linguistic2;
2000-09-18 16:07:07 +00:00
class SfxRequest;
namespace sd {
2000-09-18 16:07:07 +00:00
TYPEINIT1( FuThesaurus, FuPoor );
/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/
FuThesaurus::FuThesaurus( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
2000-09-18 16:07:07 +00:00
SdDrawDocument* pDoc, SfxRequest& rReq )
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
{
}
FunctionReference FuThesaurus::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{
FunctionReference xFunc( new FuThesaurus( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute(rReq);
return xFunc;
}
void FuThesaurus::DoExecute( SfxRequest& rReq )
2000-09-18 16:07:07 +00:00
{
SfxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, String(),
pWindow, RID_SVXERRCTX, DIALOG_MGR() );
2000-09-18 16:07:07 +00:00
if( pViewShell && pViewShell->ISA(DrawViewShell) )
2000-09-18 16:07:07 +00:00
{
SdrTextObj* pTextObj = NULL;
if ( pView->AreObjectsMarked() )
2000-09-18 16:07:07 +00:00
{
const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
2000-09-18 16:07:07 +00:00
if ( rMarkList.GetMarkCount() == 1 )
{
SdrMark* pMark = rMarkList.GetMark(0);
SdrObject* pObj = pMark->GetObj();
if ( pObj->ISA(SdrTextObj) )
{
pTextObj = (SdrTextObj*) pObj;
}
}
}
::Outliner* pOutliner = pView->GetTextEditOutliner();
2000-09-18 16:07:07 +00:00
const OutlinerView* pOutlView = pView->GetTextEditOutlinerView();
if ( pTextObj && pOutliner && pOutlView )
{
if ( !pOutliner->GetSpeller().is() )
{
Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
if ( xSpellChecker.is() )
pOutliner->SetSpeller( xSpellChecker );
2000-10-25 09:34:04 +00:00
Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
if( xHyphenator.is() )
pOutliner->SetHyphenator( xHyphenator );
2000-09-18 16:07:07 +00:00
2000-12-08 12:31:46 +00:00
pOutliner->SetDefaultLanguage( pDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
2000-09-18 16:07:07 +00:00
}
2001-04-12 13:29:25 +00:00
EESpellState eState = ( (OutlinerView*) pOutlView)->StartThesaurus();
2000-09-18 16:07:07 +00:00
DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker");
if (eState == EE_SPELL_NOLANGUAGE)
{
ErrorBox(pWindow, WB_OK, String(SdResId(STR_NOLANGUAGE))).Execute();
}
}
}
else if ( pViewShell->ISA(OutlineViewShell) )
2000-09-18 16:07:07 +00:00
{
Outliner* pOutliner = pDoc->GetOutliner();
OutlinerView* pOutlView = pOutliner->GetView(0);
if ( !pOutliner->GetSpeller().is() )
{
Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
if ( xSpellChecker.is() )
pOutliner->SetSpeller( xSpellChecker );
2000-09-18 16:07:07 +00:00
Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
if( xHyphenator.is() )
pOutliner->SetHyphenator( xHyphenator );
2000-09-18 16:07:07 +00:00
2000-12-08 12:31:46 +00:00
pOutliner->SetDefaultLanguage( pDoc->GetLanguage( EE_CHAR_LANGUAGE ) );
2000-09-18 16:07:07 +00:00
}
2001-04-12 13:29:25 +00:00
EESpellState eState = pOutlView->StartThesaurus();
2000-09-18 16:07:07 +00:00
DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker");
if (eState == EE_SPELL_NOLANGUAGE)
{
ErrorBox(pWindow, WB_OK, String(SdResId(STR_NOLANGUAGE))).Execute();
}
}
}
} // end of namespace sd