2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
re-base on ALv2 code. Includes (at least) relevant parts of:
linecap: Reintegrating finished LineCap feature
Patch contributed by Regina Henschel
http://svn.apache.org/viewvc?view=revision&revision=1232507
Patches contributed by Sven Jacobi
impress212: #i81610# fixed animation export
http://svn.apache.org/viewvc?view=revision&revision=1167620
impress212: drawinglayer gbuild environment changes
http://svn.apache.org/viewvc?view=revision&revision=1167627
http://svn.apache.org/viewvc?view=revision&revision=1167628
impress212: DffPropSet -> minor code improvements, removing table
http://svn.apache.org/viewvc?view=revision&revision=1167634
impress212: #158494# fixed excel import (text rotation)
http://svn.apache.org/viewvc?view=revision&revision=1167638
Patches contributed by Armin Le Grand
Svg: Reintegrated Svg replacement from /branches/alg/svgreplavement
http://svn.apache.org/viewvc?view=revision&revision=1220836
#118728# changed indentifying definitions for Svg file detection
http://svn.apache.org/viewvc?view=revision&revision=1229961
#118838# LineGeometry creation for complicated cases optimized to
create single Polygons
http://svn.apache.org/viewvc?view=revision&revision=1236232
#119176# corrected file type detection for SVG for svg files
without xml header
http://svn.apache.org/viewvc?view=revision&revision=1309445
#118728# Extended Svg file detection
http://svn.apache.org/viewvc?view=revision&revision=1230531
#118529# solve break converters and convert commands for OLEs and images
http://svn.apache.org/viewvc?view=revision&revision=1186168
svg: added WaE changes from branch svgreplacement to trunc
http://svn.apache.org/viewvc?view=revision&revision=1222974
svg: corrected missing member initialization
http://svn.apache.org/viewvc?view=revision&revision=1226134
fix for #118525#: Using primitives for chart sub-geometry visualisation
http://svn.apache.org/viewvc?view=revision&revision=1226879
#118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert
metafiles to bitmapEx ...
http://svn.apache.org/viewvc?view=revision&revision=1293316
fix for #118525#: removed no longer used variable maOriginalMapMode, one
more exception eliminated
http://svn.apache.org/viewvc?view=revision&revision=1227097
#16758# Added buffering to the VDev usages of the VclProcessor2D derivates...
http://svn.apache.org/viewvc?view=revision&revision=1229521
#116758# Secured VDev buffer device to Vcl deinit
http://svn.apache.org/viewvc?view=revision&revision=1230574
#116758# added remembering allocated VDevs for VDevBuffer to be able to also
delete these when vcl goes down; it should never happen, but You never know
http://svn.apache.org/viewvc?view=revision&revision=1230927
#118730# Changed SvgClipPathNode to use MaskPrimitive2D for primitive
representation instead of TransparencePrimitive2D
http://svn.apache.org/viewvc?view=revision&revision=1231198
#118822# secured 3D geometry creation (slices) by subdividing the 2D
source polyPolygon early
http://svn.apache.org/viewvc?view=revision&revision=1234749
#118829# enhanced Svg gradient quality, obstacles avoided
http://svn.apache.org/viewvc?view=revision&revision=1235361
#118834# Unified usage of TextBreakupHelper as single tooling class
for i18n text primitive breakup
http://svn.apache.org/viewvc?view=revision&revision=1236110
#118853# added square pixel size limit to conversion of
TransparencePrimitive2D to Metafile action
http://svn.apache.org/viewvc?view=revision&revision=1237656
#118824# coreccted mirroring and boundrect when the graphicmanager
is used for bitmap output
http://svn.apache.org/viewvc?view=revision&revision=1240097
#115092# Corrected VclProcessor2D::RenderPolygonStrokePrimitive2D for
various optimization scenarios
http://svn.apache.org/viewvc?view=revision&revision=1241434
#118783# Corrected errors in ID strings, corrected Svg line/fill export,
corrected polygon close state
http://svn.apache.org/viewvc?view=revision&revision=1232006
#118796# corrected null-pointer usage in SVG text exporter
http://svn.apache.org/viewvc?view=revision&revision=1240262
#118729# Use GraphicStreamUrl and GraphicUrl to allow multi image
import with linked graphics, too
http://svn.apache.org/viewvc?view=revision&revision=1229962
#118898# corrected error in GDIMetaFile::GetBoundRect in handling
MetaFloatTransparentAction
http://svn.apache.org/viewvc?view=revision&revision=1293349
#118855# Corrected handling of possibly created empty clipRegions
after PolyPolygon clipping
http://svn.apache.org/viewvc?view=revision&revision=1237725
#115962# Better (but not yet optimal, see comments in task) handling
of MetaFloatTransparentAction in PDF export
http://svn.apache.org/viewvc?view=revision&revision=1241078
IP clearance: #118466# This patch removes librsvg, libcroco, libgsf, ...
http://svn.apache.org/viewvc?view=revision&revision=1200879
118779# Added svg content streaming in/out to ImpGraphic stream operators
http://svn.apache.org/viewvc?view=revision&revision=1231908
linecap: correctons for WaE and mac drawing
http://svn.apache.org/viewvc?view=revision&revision=1232793
svg: uses current system Dpi for Svg replacement image creation
http://svn.apache.org/viewvc?view=revision&revision=1233948
Patches contributed by Mathias Bauer (and others)
gnumake4 work variously
http://svn.apache.org/viewvc?view=revision&revision=1394326
http://svn.apache.org/viewvc?view=revision&revision=1396797
http://svn.apache.org/viewvc?view=revision&revision=1397315
http://svn.apache.org/viewvc?view=revision&revision=1394326
Remove duplicate header includes.
cws mba34issues01: #i117720#: convert assertion into warning
http://svn.apache.org/viewvc?view=revision&revision=1172352
118485 - Styles for OLEs are not saved. Submitted by Armin Le Grand.
http://svn.apache.org/viewvc?view=revision&revision=1182166
cws mba34issues01: #i117714#: remove assertion
http://svn.apache.org/viewvc?view=revision&revision=1172357
Patch contributed by Jurgen Schmidt
add some additional checks to ensure proper reading operations
http://svn.apache.org/viewvc?view=revision&revision=1209022
mostly prefer our stream / bounds checking work.
Patches contributed by Herbert Duerr
#i118816# add clarifying comment regarding Font::*Color*() methods
http://svn.apache.org/viewvc?view=revision&revision=1233833
extend macro->string handling for empty strings
http://svn.apache.org/viewvc?view=revision&revision=1175801
avoid magic constants for SALCOLOR_NONE
http://svn.apache.org/viewvc?view=revision&revision=1177543
initialize slant properly in ImplFontMetricData constructor (author=iorsh)
http://svn.apache.org/viewvc?view=revision&revision=1177551
#i118675# make check for extension updates more stable
http://svn.apache.org/viewvc?view=revision&revision=1214797
#a118617# remove VBasicEventListener.dll binary
There are no known users depending on its CLSID
http://svn.apache.org/viewvc?view=revision&revision=1203697
Patches contributed by Ariel Constenla-Haile
Fix build breaker on Linux/gcc
http://svn.apache.org/viewvc?view=revision&revision=1221104
Fix crash when trying to instantiate css.graphic.GraphicRasterizer_RSVG
http://svn.apache.org/viewvc?view=revision&revision=1215559
Patches contributed by Oliver-Rainer Wittmann
sw34bf06: #i117962# - method <SwFlyFrm::IsPaint(..)> - consider
instances of <SwFlyDrawObj>
http://svn.apache.org/viewvc?view=revision&revision=1172120
sw34bf06: #i117783# - Writer's implementation of XPagePrintable -
apply print settings to new printing routines
http://svn.apache.org/viewvc?view=revision&revision=1172115
gnumake4 work variously from Hans-Joachim Lankenau
http://svn.apache.org/viewvc?view=revision&revision=1397315
http://svn.apache.org/viewvc?view=revision&revision=1396797
http://svn.apache.org/viewvc?view=revision&revision=1396782
http://svn.apache.org/viewvc?view=revision&revision=1394707
plus some amount of re-splitting of legacy headers.
Patch contributed by Pavel Janik
WaE: Remove unused variables.
http://svn.apache.org/viewvc?view=revision&revision=1230697
Patches contributed by Takashi Ono
mingwport35: i#117795: MinGW port fix for vcl2gnumake
http://svn.apache.org/viewvc?view=revision&revision=1172091
mingwport35: i#117795: MinGW port fix for vcl2gnumake
http://svn.apache.org/viewvc?view=revision&revision=1172091
Patch contributed by Christian Lippka
impress212: #i98044# re enable Text menu for outline and title shapes
http://svn.apache.org/viewvc?view=revision&revision=1167639
Patch contributed by Andre Fischer
118674: Made category B code optional and disabled by default.
http://svn.apache.org/viewvc?view=revision&revision=1215131
118881: Ignore empty paragraphs after bullets.
http://svn.apache.org/viewvc?view=revision&revision=1296205
Patches contributed by Philipp Lohmann
ooo340fixes: #i117780# use rtl allocator
http://svn.apache.org/viewvc?view=revision&revision=1172087
ooo34gsl02: #i117807# fix an off by one error (index actually
inside the pfb section header)
http://svn.apache.org/viewvc?view=revision&revision=1167576
various cleanups, related compilation fixes, warning cleanups, re-working
of obsolete stl template pieces to use boost instead, changed string
classes, re-adapt KDE about data, about dialog, fixing warnings,
and other fixes & improvements.
Disable svg import / render for about/ branding code-paths for now.
Restore full icon theme set.
Remove OS/2 conditionals and sources.
Remove conflicting gtk/full-screen monitors support.
Retain existing svg rasterizer files - temporarily disabled.
Standardize stringificaiton and fixup dllpostfix issues.
Rename SvgGradientHelper::== to equalTo to avoid overloading issues.
Use the flat GdiPlus API for LineCaps calls.
2012-10-09 12:22:23 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-04-15 13:43:13 +02:00
|
|
|
#include <rtl/ustring.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <vcl/wrkwin.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
2014-08-25 12:41:48 +01:00
|
|
|
#include <vcl/layout.hxx>
|
2009-12-10 18:36:58 +01:00
|
|
|
#include <svtools/langtab.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include <tools/errinf.hxx>
|
2010-01-06 19:26:54 +01:00
|
|
|
#include <editeng/unolingu.hxx>
|
2000-11-19 10:41:10 +00:00
|
|
|
#include <linguistic/lngprops.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <com/sun/star/frame/XStorable.hpp>
|
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
#include <map>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-01-06 19:26:54 +01:00
|
|
|
#include <editeng/svxenum.hxx>
|
2011-02-13 18:43:56 +01:00
|
|
|
#include <editeng/splwrap.hxx>
|
2010-01-06 19:26:54 +01:00
|
|
|
#include <editeng/edtdlg.hxx>
|
|
|
|
#include <editeng/eerdll.hxx>
|
|
|
|
#include <editeng/editrids.hrc>
|
|
|
|
#include <editeng/editids.hrc>
|
2010-01-07 18:52:36 +01:00
|
|
|
#include <editeng/editerr.hxx>
|
2014-08-25 10:22:59 +09:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2006-08-04 10:44:11 +00:00
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
#define WAIT_ON() if(pWin != nullptr) { pWin->EnterWait(); }
|
2006-08-04 10:44:11 +00:00
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
#define WAIT_OFF() if(pWin != nullptr) { pWin->LeaveWait(); }
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
2000-10-27 09:25:31 +00:00
|
|
|
using namespace ::com::sun::star::linguistic2;
|
2001-08-23 13:49:56 +00:00
|
|
|
|
|
|
|
|
2003-04-17 16:43:13 +00:00
|
|
|
// misc functions ---------------------------------------------
|
|
|
|
|
2013-09-06 15:32:23 +02:00
|
|
|
void SvxPrepareAutoCorrect( OUString &rOldText, const OUString &rNewText )
|
2003-04-17 16:43:13 +00:00
|
|
|
{
|
|
|
|
// This function should be used to strip (or add) trailing '.' from
|
|
|
|
// the strings before passing them on to the autocorrect function in
|
|
|
|
// order that the autocorrect function will hopefully
|
|
|
|
// works properly with normal words and abbreviations (with trailing '.')
|
|
|
|
// independ of if they are at the end of the sentence or not.
|
|
|
|
//
|
|
|
|
// rOldText: text to be replaced
|
|
|
|
// rNewText: replacement text
|
|
|
|
|
2014-02-05 12:18:53 -06:00
|
|
|
sal_Int32 nOldLen = rOldText.getLength();
|
|
|
|
sal_Int32 nNewLen = rNewText.getLength();
|
2003-04-17 16:43:13 +00:00
|
|
|
if (nOldLen && nNewLen)
|
|
|
|
{
|
2013-09-06 15:32:23 +02:00
|
|
|
bool bOldHasDot = '.' == rOldText[ nOldLen - 1 ],
|
|
|
|
bNewHasDot = '.' == rNewText[ nNewLen - 1 ];
|
2003-04-17 16:43:13 +00:00
|
|
|
if (bOldHasDot && !bNewHasDot
|
|
|
|
/*this is: !(bOldHasDot && bNewHasDot) && bOldHasDot*/)
|
2013-09-06 15:32:23 +02:00
|
|
|
rOldText = rOldText.copy( 0, nOldLen - 1 );
|
2003-04-17 16:43:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-23 13:49:56 +00:00
|
|
|
#define SVX_LANG_NEED_CHECK 0
|
|
|
|
#define SVX_LANG_OK 1
|
|
|
|
#define SVX_LANG_MISSING 2
|
|
|
|
#define SVX_LANG_MISSING_DO_WARN 3
|
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
struct lt_LanguageType
|
2001-08-23 13:49:56 +00:00
|
|
|
{
|
2007-09-05 16:44:47 +00:00
|
|
|
bool operator()( LanguageType n1, LanguageType n2 ) const
|
|
|
|
{
|
|
|
|
return n1 < n2;
|
|
|
|
}
|
|
|
|
};
|
2001-08-23 13:49:56 +00:00
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
typedef std::map< LanguageType, sal_uInt16, lt_LanguageType > LangCheckState_map_t;
|
2001-08-23 13:49:56 +00:00
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
static LangCheckState_map_t & GetLangCheckState()
|
2001-08-23 13:49:56 +00:00
|
|
|
{
|
2007-09-05 16:44:47 +00:00
|
|
|
static LangCheckState_map_t aLangCheckState;
|
|
|
|
return aLangCheckState;
|
2001-08-23 13:49:56 +00:00
|
|
|
}
|
|
|
|
|
2003-09-19 09:34:20 +00:00
|
|
|
void SvxSpellWrapper::ShowLanguageErrors()
|
2001-09-14 10:44:45 +00:00
|
|
|
{
|
|
|
|
// display message boxes for languages not available for
|
|
|
|
// spellchecking or hyphenation
|
2007-09-05 16:44:47 +00:00
|
|
|
LangCheckState_map_t &rLCS = GetLangCheckState();
|
|
|
|
LangCheckState_map_t::iterator aIt( rLCS.begin() );
|
|
|
|
while (aIt != rLCS.end())
|
2001-09-14 10:44:45 +00:00
|
|
|
{
|
2007-09-05 16:44:47 +00:00
|
|
|
LanguageType nLang = aIt->first;
|
|
|
|
sal_uInt16 nVal = aIt->second;
|
2001-09-14 10:44:45 +00:00
|
|
|
sal_uInt16 nTmpSpell = nVal & 0x00FF;
|
|
|
|
sal_uInt16 nTmpHyph = (nVal >> 8) & 0x00FF;
|
|
|
|
|
|
|
|
if (SVX_LANG_MISSING_DO_WARN == nTmpSpell)
|
|
|
|
{
|
2013-09-10 10:09:32 +02:00
|
|
|
OUString aErr( SvtLanguageTable::GetLanguageString( nLang ) );
|
2001-09-14 10:44:45 +00:00
|
|
|
ErrorHandler::HandleError(
|
|
|
|
*new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) );
|
|
|
|
nTmpSpell = SVX_LANG_MISSING;
|
|
|
|
}
|
|
|
|
if (SVX_LANG_MISSING_DO_WARN == nTmpHyph)
|
|
|
|
{
|
2013-09-10 10:09:32 +02:00
|
|
|
OUString aErr( SvtLanguageTable::GetLanguageString( nLang ) );
|
2001-09-14 10:44:45 +00:00
|
|
|
ErrorHandler::HandleError(
|
|
|
|
*new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) );
|
|
|
|
nTmpHyph = SVX_LANG_MISSING;
|
|
|
|
}
|
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
rLCS[ nLang ] = (nTmpHyph << 8) | nTmpSpell;
|
2007-11-09 10:01:49 +00:00
|
|
|
++aIt;
|
2001-09-14 10:44:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-10-12 11:27:00 +00:00
|
|
|
SvxSpellWrapper::~SvxSpellWrapper()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
/*--------------------------------------------------------------------
|
2011-02-16 16:34:02 -05:00
|
|
|
* Description: Constructor, the test sequence is determined
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
* !bStart && !bOtherCntnt: BODY_END, BODY_START, OTHER
|
|
|
|
* !bStart && bOtherCntnt: OTHER, BODY
|
|
|
|
* bStart && !bOtherCntnt: BODY_END, OTHER
|
|
|
|
* bStart && bOtherCntnt: OTHER
|
|
|
|
*
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SvxSpellWrapper::SvxSpellWrapper( vcl::Window* pWn,
|
2000-09-18 16:07:07 +00:00
|
|
|
Reference< XSpellChecker1 > &xSpellChecker,
|
2014-02-26 11:30:40 +02:00
|
|
|
const bool bStart, const bool bIsAllRight,
|
|
|
|
const bool bOther, const bool bRevAllow ) :
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pWin ( pWn ),
|
|
|
|
xSpell ( xSpellChecker ),
|
2013-11-26 14:25:22 +00:00
|
|
|
mpTextObj( NULL),
|
2000-09-18 16:07:07 +00:00
|
|
|
bOtherCntnt ( bOther ),
|
2014-02-26 11:30:40 +02:00
|
|
|
bDialog ( false ),
|
|
|
|
bHyphen ( false ),
|
|
|
|
bAuto ( false ),
|
2000-09-18 16:07:07 +00:00
|
|
|
bStartChk ( bOther ),
|
2008-04-24 13:18:21 +00:00
|
|
|
bRevAllowed ( bRevAllow ),
|
|
|
|
bAllRight ( bIsAllRight )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-13 10:43:34 +02:00
|
|
|
Reference< linguistic2::XLinguProperties > xProp( SvxGetLinguPropertySet() );
|
2014-02-26 11:30:40 +02:00
|
|
|
bool bWrapReverse = xProp.is() && xProp->getIsWrapReverse();
|
2000-09-18 16:07:07 +00:00
|
|
|
bReverse = bRevAllow && bWrapReverse;
|
|
|
|
bStartDone = bOther || ( !bReverse && bStart );
|
|
|
|
bEndDone = bReverse && bStart && !bOther;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SvxSpellWrapper::SvxSpellWrapper( vcl::Window* pWn,
|
2000-09-18 16:07:07 +00:00
|
|
|
Reference< XHyphenator > &xHyphenator,
|
2014-02-26 11:30:40 +02:00
|
|
|
const bool bStart, const bool bOther ) :
|
2000-09-18 16:07:07 +00:00
|
|
|
pWin ( pWn ),
|
|
|
|
xHyph ( xHyphenator ),
|
2013-11-26 14:25:22 +00:00
|
|
|
mpTextObj( NULL),
|
2000-09-18 16:07:07 +00:00
|
|
|
bOtherCntnt ( bOther ),
|
2014-02-26 11:30:40 +02:00
|
|
|
bDialog ( false ),
|
|
|
|
bHyphen ( false ),
|
|
|
|
bAuto ( false ),
|
|
|
|
bReverse ( false ),
|
2000-09-18 16:07:07 +00:00
|
|
|
bStartDone ( bOther || ( !bReverse && bStart ) ),
|
|
|
|
bEndDone ( bReverse && bStart && !bOther ),
|
|
|
|
bStartChk ( bOther ),
|
2014-02-26 11:30:40 +02:00
|
|
|
bRevAllowed ( false ),
|
|
|
|
bAllRight ( true )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
sal_Int16 SvxSpellWrapper::CheckSpellLang(
|
|
|
|
Reference< XSpellChecker1 > xSpell, sal_Int16 nLang)
|
|
|
|
{
|
2007-09-05 16:44:47 +00:00
|
|
|
LangCheckState_map_t &rLCS = GetLangCheckState();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
LangCheckState_map_t::iterator aIt( rLCS.find( nLang ) );
|
|
|
|
sal_uInt16 nVal = aIt == rLCS.end() ? SVX_LANG_NEED_CHECK : aIt->second;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
if (aIt == rLCS.end())
|
|
|
|
rLCS[ nLang ] = nVal;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (SVX_LANG_NEED_CHECK == (nVal & 0x00FF))
|
|
|
|
{
|
|
|
|
sal_uInt16 nTmpVal = SVX_LANG_MISSING_DO_WARN;
|
|
|
|
if (xSpell.is() && xSpell->hasLanguage( nLang ))
|
|
|
|
nTmpVal = SVX_LANG_OK;
|
|
|
|
nVal &= 0xFF00;
|
|
|
|
nVal |= nTmpVal;
|
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
rLCS[ nLang ] = nVal;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-08-23 13:49:56 +00:00
|
|
|
return (sal_Int16) nVal;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int16 SvxSpellWrapper::CheckHyphLang(
|
|
|
|
Reference< XHyphenator > xHyph, sal_Int16 nLang)
|
|
|
|
{
|
2007-09-05 16:44:47 +00:00
|
|
|
LangCheckState_map_t &rLCS = GetLangCheckState();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
LangCheckState_map_t::iterator aIt( rLCS.find( nLang ) );
|
|
|
|
sal_uInt16 nVal = aIt == rLCS.end() ? 0 : aIt->second;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
if (aIt == rLCS.end())
|
|
|
|
rLCS[ nLang ] = nVal;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (SVX_LANG_NEED_CHECK == ((nVal >> 8) & 0x00FF))
|
|
|
|
{
|
|
|
|
sal_uInt16 nTmpVal = SVX_LANG_MISSING_DO_WARN;
|
2013-07-13 02:54:05 +02:00
|
|
|
if (xHyph.is() && xHyph->hasLocale( LanguageTag::convertToLocale( nLang ) ))
|
2000-09-18 16:07:07 +00:00
|
|
|
nTmpVal = SVX_LANG_OK;
|
|
|
|
nVal &= 0x00FF;
|
|
|
|
nVal |= nTmpVal << 8;
|
|
|
|
|
2007-09-05 16:44:47 +00:00
|
|
|
rLCS[ nLang ] = nVal;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-08-23 13:49:56 +00:00
|
|
|
return (sal_Int16) nVal;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
2006-06-19 14:28:50 +00:00
|
|
|
void SvxSpellWrapper::SpellStart( SvxSpellArea /*eSpell*/ )
|
2011-02-16 16:34:02 -05:00
|
|
|
{ // Here, the necessary preparations be made for SpellContinue in the
|
|
|
|
} // given area.
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
2014-02-26 11:30:40 +02:00
|
|
|
bool SvxSpellWrapper::HasOtherCnt()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-02-26 11:30:40 +02:00
|
|
|
return false; // Is there a special area?
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
2014-02-26 11:30:40 +02:00
|
|
|
bool SvxSpellWrapper::SpellMore()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-02-26 11:30:40 +02:00
|
|
|
return false; // Should additional documents be examined?
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SvxSpellWrapper::SpellEnd()
|
2011-02-16 16:34:02 -05:00
|
|
|
{ // Area is complete, tidy up if necessary
|
2001-09-14 10:44:45 +00:00
|
|
|
|
|
|
|
// display error for last language not found
|
|
|
|
ShowLanguageErrors();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-26 11:30:40 +02:00
|
|
|
bool SvxSpellWrapper::SpellContinue()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-02-26 11:30:40 +02:00
|
|
|
return false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-09-06 15:32:23 +02:00
|
|
|
void SvxSpellWrapper::AutoCorrect( const OUString&, const OUString& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvxSpellWrapper::ScrollArea()
|
2011-02-16 16:34:02 -05:00
|
|
|
{ // Set Scroll area
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-09-06 15:32:23 +02:00
|
|
|
void SvxSpellWrapper::ChangeWord( const OUString&, const sal_uInt16 )
|
2011-02-16 16:34:02 -05:00
|
|
|
{ // Insert Word
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-09-06 15:32:23 +02:00
|
|
|
void SvxSpellWrapper::ChangeThesWord( const OUString& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-02-16 16:34:02 -05:00
|
|
|
// replace word due to Thesaurus.
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-09-06 15:32:23 +02:00
|
|
|
void SvxSpellWrapper::ReplaceAll( const OUString &, sal_Int16 )
|
2013-02-22 09:48:17 +02:00
|
|
|
{ // Replace Word from the Replace list
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-06-01 01:24:23 +02:00
|
|
|
void SvxSpellWrapper::InsertHyphen( const sal_Int32 )
|
2011-02-16 16:34:02 -05:00
|
|
|
{ // inserting and deleting Hyphae
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Testing of the document areas in the order specified by the flags
|
2000-09-18 16:07:07 +00:00
|
|
|
void SvxSpellWrapper::SpellDocument( )
|
|
|
|
{
|
|
|
|
if ( bOtherCntnt )
|
|
|
|
{
|
2014-02-26 11:30:40 +02:00
|
|
|
bReverse = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
SpellStart( SVX_SPELL_OTHER );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bStartChk = bReverse;
|
|
|
|
SpellStart( bReverse ? SVX_SPELL_BODY_START : SVX_SPELL_BODY_END );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( FindSpellError() )
|
|
|
|
{
|
|
|
|
Reference< XSpellAlternatives > xAlt( GetLast(), UNO_QUERY );
|
|
|
|
Reference< XHyphenatedWord > xHyphWord( GetLast(), UNO_QUERY );
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *pOld = pWin;
|
2014-02-26 11:30:40 +02:00
|
|
|
bDialog = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xHyphWord.is())
|
|
|
|
{
|
2010-01-06 19:26:54 +01:00
|
|
|
EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create();
|
2014-08-25 10:22:59 +09:00
|
|
|
boost::scoped_ptr<AbstractHyphenWordDialog> pDlg(pFact->CreateHyphenWordDialog( pWin,
|
2009-12-10 19:12:58 +01:00
|
|
|
xHyphWord->getWord(),
|
2012-11-24 18:54:09 +01:00
|
|
|
LanguageTag( xHyphWord->getLocale() ).getLanguageType(),
|
2014-08-25 10:22:59 +09:00
|
|
|
xHyph, this ));
|
2009-12-10 19:12:58 +01:00
|
|
|
pWin = pDlg->GetWindow();
|
2000-09-18 16:07:07 +00:00
|
|
|
pDlg->Execute();
|
|
|
|
}
|
2014-02-26 11:30:40 +02:00
|
|
|
bDialog = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
pWin = pOld;
|
2014-05-26 19:41:16 +02:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Select the next area
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
2014-02-26 11:30:40 +02:00
|
|
|
bool SvxSpellWrapper::SpellNext( )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-13 10:43:34 +02:00
|
|
|
Reference< linguistic2::XLinguProperties > xProp( SvxGetLinguPropertySet() );
|
2014-02-26 11:30:40 +02:00
|
|
|
bool bWrapReverse = xProp.is() && xProp->getIsWrapReverse();
|
|
|
|
bool bActRev = bRevAllowed && bWrapReverse;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// bActRev is the direction after Spell checking, bReverse is the one
|
|
|
|
// at the beginning.
|
2000-09-18 16:07:07 +00:00
|
|
|
if( bActRev == bReverse )
|
2011-02-16 16:34:02 -05:00
|
|
|
{ // No change of direction, thus is the
|
|
|
|
if( bStartChk ) // desired area ( bStartChk )
|
2014-02-26 11:30:40 +02:00
|
|
|
bStartDone = true; // completely processed.
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2014-02-26 11:30:40 +02:00
|
|
|
bEndDone = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2011-02-16 16:34:02 -05:00
|
|
|
else if( bReverse == bStartChk ) //For a change of direction, an area can
|
|
|
|
{ // be processed during certain circumstances
|
|
|
|
if( bStartChk ) // If the firdt part is spell checked in backwards
|
2014-02-26 11:30:40 +02:00
|
|
|
bEndDone = true; // and this is reversed in the process, then
|
2011-02-16 16:34:02 -05:00
|
|
|
else // then the end part is processed (and vice-versa).
|
2014-02-26 11:30:40 +02:00
|
|
|
bStartDone = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bReverse = bActRev;
|
2011-02-16 16:34:02 -05:00
|
|
|
if( bOtherCntnt && bStartDone && bEndDone ) // Document has been fully checked?
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-02-16 16:34:02 -05:00
|
|
|
if ( SpellMore() ) // spell check another document?
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-02-26 11:30:40 +02:00
|
|
|
bOtherCntnt = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
bStartDone = !bReverse;
|
|
|
|
bEndDone = bReverse;
|
|
|
|
SpellStart( SVX_SPELL_BODY );
|
2014-02-26 11:30:40 +02:00
|
|
|
return true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2014-02-26 11:30:40 +02:00
|
|
|
return false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-26 11:30:40 +02:00
|
|
|
bool bGoOn = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( bOtherCntnt )
|
|
|
|
{
|
2014-02-26 11:30:40 +02:00
|
|
|
bStartChk = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
SpellStart( SVX_SPELL_BODY );
|
2014-02-26 11:30:40 +02:00
|
|
|
bGoOn = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if ( bStartDone && bEndDone )
|
|
|
|
{
|
2014-02-26 11:30:40 +02:00
|
|
|
bool bIsSpellSpecial = xProp.is() && xProp->getIsSpellSpecial();
|
2011-02-16 16:34:02 -05:00
|
|
|
// Body area done, ask for special area
|
2000-09-18 16:07:07 +00:00
|
|
|
if( !IsHyphen() && bIsSpellSpecial && HasOtherCnt() )
|
|
|
|
{
|
|
|
|
SpellStart( SVX_SPELL_OTHER );
|
2014-02-26 11:30:40 +02:00
|
|
|
bOtherCntnt = bGoOn = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2011-02-16 16:34:02 -05:00
|
|
|
else if ( SpellMore() ) // check another document?
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-02-26 11:30:40 +02:00
|
|
|
bOtherCntnt = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
bStartDone = !bReverse;
|
|
|
|
bEndDone = bReverse;
|
|
|
|
SpellStart( SVX_SPELL_BODY );
|
2014-02-26 11:30:40 +02:00
|
|
|
return true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-16 16:34:02 -05:00
|
|
|
// a BODY_area done, ask for the other BODY_area
|
2000-09-18 16:07:07 +00:00
|
|
|
WAIT_OFF();
|
|
|
|
|
2014-08-25 12:41:48 +01:00
|
|
|
sal_uInt16 nResId = bReverse ? RID_SVXSTR_QUERY_BW_CONTINUE : RID_SVXSTR_QUERY_CONTINUE;
|
2015-03-31 23:04:14 +01:00
|
|
|
ScopedVclPtrInstance< MessageDialog > aBox(pWin, EditResId(nResId), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO);
|
2015-02-11 14:42:23 +02:00
|
|
|
if ( aBox->Execute() != RET_YES )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-02-16 16:34:02 -05:00
|
|
|
// sacrifice the other area if necessary ask for special area
|
2000-09-18 16:07:07 +00:00
|
|
|
WAIT_ON();
|
2014-02-26 11:30:40 +02:00
|
|
|
bStartDone = bEndDone = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
return SpellNext();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bStartChk = !bStartDone;
|
|
|
|
SpellStart( bStartChk ? SVX_SPELL_BODY_START : SVX_SPELL_BODY_END );
|
2014-02-26 11:30:40 +02:00
|
|
|
bGoOn = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
WAIT_ON();
|
|
|
|
}
|
|
|
|
return bGoOn;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-04-10 14:12:10 +02:00
|
|
|
Reference< XDictionary > SvxSpellWrapper::GetAllRightDic()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2008-12-15 12:01:46 +00:00
|
|
|
Reference< XDictionary > xDic;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-02-04 16:18:01 +02:00
|
|
|
Reference< XSearchableDictionaryList > xDicList( SvxGetDictionaryList() );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xDicList.is())
|
|
|
|
{
|
|
|
|
Sequence< Reference< XDictionary > > aDics( xDicList->getDictionaries() );
|
|
|
|
const Reference< XDictionary > *pDic = aDics.getConstArray();
|
|
|
|
sal_Int32 nCount = aDics.getLength();
|
|
|
|
|
|
|
|
sal_Int32 i = 0;
|
|
|
|
while (!xDic.is() && i < nCount)
|
|
|
|
{
|
2008-12-15 12:01:46 +00:00
|
|
|
Reference< XDictionary > xTmp( pDic[i], UNO_QUERY );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xTmp.is())
|
|
|
|
{
|
|
|
|
if ( xTmp->isActive() &&
|
|
|
|
xTmp->getDictionaryType() != DictionaryType_NEGATIVE &&
|
2012-11-24 18:54:09 +01:00
|
|
|
LanguageTag( xTmp->getLocale() ).getLanguageType() == LANGUAGE_NONE )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Reference< frame::XStorable > xStor( xTmp, UNO_QUERY );
|
|
|
|
if (xStor.is() && xStor->hasLocation() && !xStor->isReadonly())
|
|
|
|
{
|
|
|
|
xDic = xTmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!xDic.is())
|
|
|
|
{
|
|
|
|
xDic = SvxGetOrCreatePosDic( xDicList );
|
|
|
|
if (xDic.is())
|
|
|
|
xDic->setActive( sal_True );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return xDic;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-02-26 11:30:40 +02:00
|
|
|
bool SvxSpellWrapper::FindSpellError()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-09-14 10:44:45 +00:00
|
|
|
ShowLanguageErrors();
|
2001-08-23 13:49:56 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Reference< XInterface > xRef;
|
|
|
|
|
|
|
|
WAIT_ON();
|
2014-02-26 11:30:40 +02:00
|
|
|
bool bSpell = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
Reference< XDictionary > xAllRightDic;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (IsAllRight())
|
|
|
|
xAllRightDic = GetAllRightDic();
|
|
|
|
|
|
|
|
while ( bSpell )
|
|
|
|
{
|
|
|
|
SpellContinue();
|
|
|
|
|
|
|
|
Reference< XSpellAlternatives > xAlt( GetLast(), UNO_QUERY );
|
|
|
|
Reference< XHyphenatedWord > xHyphWord( GetLast(), UNO_QUERY );
|
|
|
|
|
|
|
|
if (xAlt.is())
|
|
|
|
{
|
|
|
|
if (IsAllRight() && xAllRightDic.is())
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
xAllRightDic->add( xAlt->getWord(), sal_False, OUString() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// look up in ChangeAllList for misspelled word
|
2008-12-15 12:01:46 +00:00
|
|
|
Reference< XDictionary > xChangeAllList(
|
2000-09-18 16:07:07 +00:00
|
|
|
SvxGetChangeAllList(), UNO_QUERY );
|
|
|
|
Reference< XDictionaryEntry > xEntry;
|
|
|
|
if (xChangeAllList.is())
|
|
|
|
xEntry = xChangeAllList->getEntry( xAlt->getWord() );
|
|
|
|
|
|
|
|
if (xEntry.is())
|
|
|
|
{
|
|
|
|
// replace word without asking
|
2000-10-27 09:25:31 +00:00
|
|
|
ReplaceAll( xEntry->getReplacementText(),
|
2012-11-24 18:54:09 +01:00
|
|
|
LanguageTag( xAlt->getLocale() ).getLanguageType() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2014-02-26 11:30:40 +02:00
|
|
|
bSpell = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (xHyphWord.is())
|
2014-02-26 11:30:40 +02:00
|
|
|
bSpell = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SpellEnd();
|
|
|
|
bSpell = SpellNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WAIT_OFF();
|
|
|
|
return GetLast().is();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-17 16:43:13 +00:00
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|