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 .
|
|
|
|
*/
|
2006-09-17 03:22:08 +00:00
|
|
|
|
2010-01-06 19:26:54 +01:00
|
|
|
#include <editeng/hangulhanja.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
2007-07-31 12:57:14 +00:00
|
|
|
#include <vcl/button.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/lingucfg.hxx>
|
|
|
|
#include <unotools/linguprops.hxx>
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <map>
|
2012-10-15 15:20:48 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2003-04-17 16:41:42 +00:00
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
2012-10-15 15:20:48 +02:00
|
|
|
#include <com/sun/star/i18n/BreakIterator.hpp>
|
2003-04-17 16:41:42 +00:00
|
|
|
#include <com/sun/star/i18n/ScriptType.hpp>
|
|
|
|
#include <com/sun/star/i18n/UnicodeScript.hpp>
|
2012-11-02 16:07:50 +02:00
|
|
|
#include <com/sun/star/i18n/TextConversion.hpp>
|
2005-11-08 08:13:44 +00:00
|
|
|
#include <com/sun/star/i18n/XExtendedTextConversion.hpp>
|
2003-04-17 16:41:42 +00:00
|
|
|
#include <com/sun/star/i18n/TextConversionType.hpp>
|
|
|
|
#include <com/sun/star/i18n/TextConversionOption.hpp>
|
|
|
|
#include <com/sun/star/i18n/WordType.hpp>
|
|
|
|
#include <vcl/stdtext.hxx>
|
|
|
|
#include <unotools/charclass.hxx>
|
|
|
|
|
2010-01-06 19:26:54 +01:00
|
|
|
#include <editeng/edtdlg.hxx>
|
|
|
|
#include <editeng/editrids.hrc>
|
|
|
|
#include <editeng/unolingu.hxx>
|
2004-09-17 12:44:46 +00:00
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
#define HHC HangulHanjaConversion
|
|
|
|
|
2014-02-25 18:24:10 +01:00
|
|
|
|
2010-01-06 19:26:54 +01:00
|
|
|
namespace editeng
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2014-02-25 18:24:10 +01:00
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2015-02-05 17:43:09 +01:00
|
|
|
using namespace ::com::sun::star;
|
2003-04-17 16:41:42 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::i18n;
|
|
|
|
using namespace ::com::sun::star::i18n::TextConversionOption;
|
|
|
|
using namespace ::com::sun::star::i18n::TextConversionType;
|
|
|
|
|
|
|
|
class HangulHanjaConversion_Impl
|
|
|
|
{
|
|
|
|
private:
|
2016-09-23 20:55:37 +01:00
|
|
|
typedef std::set<OUString> StringBag;
|
|
|
|
typedef std::map<OUString, OUString> StringMap;
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
private:
|
2004-11-26 13:32:06 +00:00
|
|
|
StringBag m_sIgnoreList;
|
|
|
|
StringMap m_aChangeList;
|
|
|
|
static StringMap m_aRecentlyUsedList;
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
// general
|
2016-09-21 14:48:15 +02:00
|
|
|
VclPtr<AbstractHangulHanjaConversionDialog>
|
2003-04-17 16:41:42 +00:00
|
|
|
m_pConversionDialog; // the dialog to display for user interaction
|
2015-03-09 14:29:30 +02:00
|
|
|
VclPtr<vcl::Window> m_pUIParent; // the parent window for any UI we raise
|
2012-11-02 16:07:50 +02:00
|
|
|
Reference< XComponentContext >
|
|
|
|
m_xContext; // the service factory to use
|
|
|
|
Reference< XExtendedTextConversion >
|
2003-04-17 16:41:42 +00:00
|
|
|
m_xConverter; // the text conversion service
|
2015-02-05 17:43:09 +01:00
|
|
|
lang::Locale m_aSourceLocale; // the locale we're working with
|
2004-09-17 12:44:46 +00:00
|
|
|
|
|
|
|
// additions for Chinese simplified / traditional conversion
|
|
|
|
HHC::ConversionType m_eConvType; // conversion type (Hangul/Hanja, simplified/traditional Chinese,...)
|
|
|
|
LanguageType m_nSourceLang; // just a 'copy' of m_aSourceLocale in order in order to
|
|
|
|
// save the applications from always converting to this
|
|
|
|
// type in their implementations
|
|
|
|
LanguageType m_nTargetLang; // target language of new replacement text
|
2014-09-16 10:09:58 +02:00
|
|
|
const vcl::Font* m_pTargetFont; // target font of new replacement text
|
2004-09-17 12:44:46 +00:00
|
|
|
sal_Int32 m_nConvOptions; // text conversion options (as used by 'getConversions')
|
2013-04-21 16:55:25 +02:00
|
|
|
bool m_bIsInteractive; // specifies if the conversion requires user interaction
|
2015-09-29 17:50:10 +02:00
|
|
|
// (and likely a specialised dialog) or if it is to run
|
2004-09-17 12:44:46 +00:00
|
|
|
// automatically without any user interaction.
|
|
|
|
// True for Hangul / Hanja conversion
|
|
|
|
// False for Chinese simlified / traditional conversion
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
HangulHanjaConversion* m_pAntiImpl; // our "anti-impl" instance
|
|
|
|
|
|
|
|
// options
|
2013-04-21 16:55:25 +02:00
|
|
|
bool m_bByCharacter; // are we in "by character" mode currently?
|
2003-04-17 16:41:42 +00:00
|
|
|
HHC::ConversionFormat m_eConversionFormat; // the current format for the conversion
|
2004-09-17 12:44:46 +00:00
|
|
|
HHC::ConversionDirection m_ePrimaryConversionDirection; // the primary conversion direction
|
|
|
|
HHC::ConversionDirection m_eCurrentConversionDirection; // the primary conversion direction
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
//options from Hangul/Hanja Options dialog (also saved to configuration)
|
|
|
|
bool m_bIgnorePostPositionalWord;
|
|
|
|
bool m_bShowRecentlyUsedFirst;
|
|
|
|
bool m_bAutoReplaceUnique;
|
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
// state
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString m_sCurrentPortion; // the text which we are currently working on
|
2005-04-04 07:28:58 +00:00
|
|
|
LanguageType m_nCurrentPortionLang; // language of m_sCurrentPortion found
|
2003-04-17 16:41:42 +00:00
|
|
|
sal_Int32 m_nCurrentStartIndex; // the start index within m_sCurrentPortion of the current convertible portion
|
|
|
|
sal_Int32 m_nCurrentEndIndex; // the end index (excluding) within m_sCurrentPortion of the current convertible portion
|
|
|
|
sal_Int32 m_nReplacementBaseIndex;// index which ReplaceUnit-calls need to be relative to
|
2005-11-08 08:13:44 +00:00
|
|
|
sal_Int32 m_nCurrentConversionOption;
|
|
|
|
sal_Int16 m_nCurrentConversionType;
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString >
|
2003-04-17 16:41:42 +00:00
|
|
|
m_aCurrentSuggestions; // the suggestions for the current unit
|
|
|
|
// (means for the text [m_nCurrentStartIndex, m_nCurrentEndIndex) in m_sCurrentPortion)
|
2013-04-21 16:55:25 +02:00
|
|
|
bool m_bTryBothDirections; // specifies if other conversion directions should be tried when looking for convertible characters
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
HangulHanjaConversion_Impl(
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* _pUIParent,
|
2012-11-02 16:07:50 +02:00
|
|
|
const Reference< XComponentContext >& rxContext,
|
2015-02-05 17:43:09 +01:00
|
|
|
const lang::Locale& _rSourceLocale,
|
|
|
|
const lang::Locale& _rTargetLocale,
|
2014-09-16 10:09:58 +02:00
|
|
|
const vcl::Font* _pTargetFont,
|
2004-09-17 12:44:46 +00:00
|
|
|
sal_Int32 _nConvOptions,
|
2013-04-21 16:55:25 +02:00
|
|
|
bool _bIsInteractive,
|
2003-04-17 16:41:42 +00:00
|
|
|
HangulHanjaConversion* _pAntiImpl );
|
|
|
|
|
|
|
|
public:
|
|
|
|
void DoDocumentConversion( );
|
|
|
|
|
2013-04-21 16:55:25 +02:00
|
|
|
inline bool IsValid() const { return m_xConverter.is(); }
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-09-17 12:44:46 +00:00
|
|
|
inline LanguageType GetSourceLang() const { return m_nSourceLang; }
|
|
|
|
inline LanguageType GetTargetLang() const { return m_nTargetLang; }
|
2014-09-16 10:09:58 +02:00
|
|
|
inline const vcl::Font * GetTargetFont() const { return m_pTargetFont; }
|
2004-09-17 12:44:46 +00:00
|
|
|
inline sal_Int32 GetConvOptions() const { return m_nConvOptions; }
|
2013-04-21 16:55:25 +02:00
|
|
|
inline bool IsInteractive() const { return m_bIsInteractive; }
|
2004-09-17 12:44:46 +00:00
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
protected:
|
|
|
|
void createDialog();
|
|
|
|
|
|
|
|
/** continue with the conversion, return <TRUE/> if and only if the complete conversion is done
|
|
|
|
@param _bRepeatCurrentUnit
|
|
|
|
if <TRUE/>, an implNextConvertible will be called initially to advance to the next convertible.
|
|
|
|
if <FALSE/>, the method will initially work with the current convertible unit
|
|
|
|
*/
|
2013-04-21 16:55:25 +02:00
|
|
|
bool ContinueConversion( bool _bRepeatCurrentUnit );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
private:
|
2016-10-05 07:56:12 +02:00
|
|
|
DECL_LINK( OnOptionsChanged, LinkParamNone*, void );
|
|
|
|
DECL_LINK( OnIgnore, Button*, void );
|
|
|
|
DECL_LINK( OnIgnoreAll, Button*, void );
|
|
|
|
DECL_LINK( OnChange, Button*, void );
|
|
|
|
DECL_LINK( OnChangeAll, Button*, void );
|
|
|
|
DECL_LINK( OnByCharClicked, CheckBox*, void );
|
|
|
|
DECL_LINK( OnConversionTypeChanged, Button*, void );
|
|
|
|
DECL_LINK( OnFind, Button*, void );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
/** proceed, after the current convertible has been handled
|
|
|
|
|
|
|
|
<p><b>Attention:</b>
|
|
|
|
When returning from this method, the dialog may have been deleted!</p>
|
|
|
|
|
|
|
|
@param _bRepeatCurrentUnit
|
|
|
|
will be passed to the <member>ContinueConversion</member> call
|
|
|
|
*/
|
|
|
|
void implProceed( bool _bRepeatCurrentUnit );
|
|
|
|
|
|
|
|
// change the current convertible, and do _not_ proceed
|
2013-04-07 12:06:47 +02:00
|
|
|
void implChange( const OUString& _rChangeInto );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
/** find the next convertible piece of text, with possibly advancing to the next portion
|
|
|
|
|
|
|
|
@see HangulHanjaConversion::GetNextPortion
|
|
|
|
*/
|
2013-04-21 16:55:25 +02:00
|
|
|
bool implNextConvertible( bool _bRepeatUnit );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
/** find the next convertible unit within the current portion
|
|
|
|
@param _bRepeatUnit
|
|
|
|
if <TRUE/>, the search will start at the beginning of the current unit,
|
|
|
|
if <FALSE/>, it will start at the end of the current unit
|
|
|
|
*/
|
|
|
|
bool implNextConvertibleUnit( const sal_Int32 _nStartAt );
|
|
|
|
|
|
|
|
/** retrieves the next portion, with setting the index members properly
|
|
|
|
@return
|
|
|
|
<TRUE/> if and only if there is a next portion
|
|
|
|
*/
|
|
|
|
bool implRetrieveNextPortion( );
|
|
|
|
|
2005-04-04 07:28:58 +00:00
|
|
|
/** determine the ConversionDirection for m_sCurrentPortion
|
2003-04-17 16:41:42 +00:00
|
|
|
@return
|
|
|
|
<FALSE/> if and only if something went wrong
|
|
|
|
*/
|
2005-04-04 07:28:58 +00:00
|
|
|
bool implGetConversionDirectionForCurrentPortion( HHC::ConversionDirection& rDirection );
|
2004-11-26 13:32:06 +00:00
|
|
|
|
|
|
|
/** member m_aCurrentSuggestions and m_nCurrentEndIndex are updated according to the other settings and current dictionaries
|
|
|
|
|
|
|
|
if _bAllowSearchNextConvertibleText is true _nStartAt is used as starting point to search the next
|
|
|
|
convertible text portion. This may result in changing of the member m_nCurrentStartIndex additionally.
|
|
|
|
|
|
|
|
@return
|
|
|
|
<TRUE/> if Suggestions were found
|
|
|
|
*/
|
|
|
|
bool implUpdateSuggestions( const bool _bAllowSearchNextConvertibleText=false, const sal_Int32 _nStartAt=-1 );
|
|
|
|
|
|
|
|
/** reads the options from Hangul/Hanja Options dialog that are saved to configuration
|
|
|
|
*/
|
|
|
|
void implReadOptionsFromConfiguration();
|
|
|
|
|
|
|
|
/** get the string currently considered to be replaced or ignored
|
|
|
|
*/
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString GetCurrentUnit() const;
|
2004-11-26 13:32:06 +00:00
|
|
|
|
|
|
|
/** read options from configuration, update suggestion list and dialog content
|
|
|
|
*/
|
|
|
|
void implUpdateData();
|
|
|
|
|
2005-04-04 07:28:58 +00:00
|
|
|
/** get the conversion direction dependent from m_eConvType and m_eCurrentConversionDirection
|
2004-11-26 13:32:06 +00:00
|
|
|
in case of switching the direction is allowed this can be triggered with parameter bSwitchDirection
|
|
|
|
*/
|
|
|
|
sal_Int16 implGetConversionType( bool bSwitchDirection=false ) const;
|
2003-04-17 16:41:42 +00:00
|
|
|
};
|
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
HangulHanjaConversion_Impl::StringMap HangulHanjaConversion_Impl::m_aRecentlyUsedList = HangulHanjaConversion_Impl::StringMap();
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
HangulHanjaConversion_Impl::HangulHanjaConversion_Impl( vcl::Window* _pUIParent,
|
2014-01-28 21:14:35 -06:00
|
|
|
const Reference< XComponentContext >& rxContext,
|
2015-02-05 17:43:09 +01:00
|
|
|
const lang::Locale& _rSourceLocale,
|
|
|
|
const lang::Locale& _rTargetLocale,
|
2014-09-16 10:09:58 +02:00
|
|
|
const vcl::Font* _pTargetFont,
|
2014-01-28 21:14:35 -06:00
|
|
|
sal_Int32 _nOptions,
|
|
|
|
bool _bIsInteractive,
|
|
|
|
HangulHanjaConversion* _pAntiImpl )
|
2016-09-21 14:48:15 +02:00
|
|
|
: m_pConversionDialog()
|
2014-01-28 21:14:35 -06:00
|
|
|
, m_pUIParent( _pUIParent )
|
|
|
|
, m_xContext( rxContext )
|
|
|
|
, m_aSourceLocale( _rSourceLocale )
|
|
|
|
, m_nSourceLang( LanguageTag::convertToLanguageType( _rSourceLocale ) )
|
|
|
|
, m_nTargetLang( LanguageTag::convertToLanguageType( _rTargetLocale ) )
|
|
|
|
, m_pTargetFont( _pTargetFont )
|
|
|
|
, m_nConvOptions(_nOptions)
|
|
|
|
, m_bIsInteractive( _bIsInteractive )
|
|
|
|
, m_pAntiImpl( _pAntiImpl )
|
2015-04-24 12:25:45 +02:00
|
|
|
, m_bByCharacter((_nOptions & CHARACTER_BY_CHARACTER) != 0)
|
2014-01-28 21:14:35 -06:00
|
|
|
, m_eConversionFormat( HHC::eSimpleConversion)
|
|
|
|
, m_ePrimaryConversionDirection( HHC::eHangulToHanja) // used for eConvHangulHanja
|
|
|
|
, m_eCurrentConversionDirection( HHC::eHangulToHanja) // used for eConvHangulHanja
|
|
|
|
, m_nCurrentPortionLang( LANGUAGE_NONE )
|
|
|
|
, m_nCurrentStartIndex( 0 )
|
|
|
|
, m_nCurrentEndIndex( 0 )
|
|
|
|
, m_nReplacementBaseIndex( 0 )
|
|
|
|
, m_nCurrentConversionOption( TextConversionOption::NONE )
|
|
|
|
, m_nCurrentConversionType( -1 ) // not yet known
|
|
|
|
, m_bTryBothDirections( true )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2004-11-26 13:32:06 +00:00
|
|
|
implReadOptionsFromConfiguration();
|
|
|
|
|
2012-11-02 16:07:50 +02:00
|
|
|
DBG_ASSERT( m_xContext.is(), "HangulHanjaConversion_Impl::HangulHanjaConversion_Impl: no ORB!" );
|
2004-09-17 12:44:46 +00:00
|
|
|
|
|
|
|
// determine conversion type
|
|
|
|
if (m_nSourceLang == LANGUAGE_KOREAN && m_nTargetLang == LANGUAGE_KOREAN)
|
|
|
|
m_eConvType = HHC::eConvHangulHanja;
|
2009-04-01 13:20:55 +00:00
|
|
|
else if ( (m_nSourceLang == LANGUAGE_CHINESE_TRADITIONAL && m_nTargetLang == LANGUAGE_CHINESE_SIMPLIFIED) ||
|
|
|
|
(m_nSourceLang == LANGUAGE_CHINESE_SIMPLIFIED && m_nTargetLang == LANGUAGE_CHINESE_TRADITIONAL) )
|
2004-09-17 12:44:46 +00:00
|
|
|
m_eConvType = HHC::eConvSimplifiedTraditional;
|
|
|
|
else
|
2008-10-10 13:02:43 +00:00
|
|
|
{
|
2014-01-28 21:14:35 -06:00
|
|
|
m_eConvType = HHC::eConvHangulHanja;
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "failed to determine conversion type from languages" );
|
2008-10-10 13:02:43 +00:00
|
|
|
}
|
2004-09-17 12:44:46 +00:00
|
|
|
|
2012-11-02 16:07:50 +02:00
|
|
|
m_xConverter = TextConversion::create( m_xContext );
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HangulHanjaConversion_Impl::createDialog()
|
|
|
|
{
|
2004-09-17 12:44:46 +00:00
|
|
|
DBG_ASSERT( m_bIsInteractive, "createDialog when the conversion should not be interactive?" );
|
|
|
|
if ( m_bIsInteractive && !m_pConversionDialog )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2010-01-06 19:26:54 +01:00
|
|
|
EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create();
|
2004-02-03 17:27:58 +00:00
|
|
|
if(pFact)
|
|
|
|
{
|
2009-11-02 20:49:14 +01:00
|
|
|
m_pConversionDialog = pFact->CreateHangulHanjaConversionDialog(m_pUIParent, m_ePrimaryConversionDirection );
|
2014-07-26 14:23:59 +02:00
|
|
|
DBG_ASSERT(m_pConversionDialog, "Dialog creation failed!");
|
2004-02-03 17:27:58 +00:00
|
|
|
|
2004-04-27 14:46:13 +00:00
|
|
|
m_pConversionDialog->EnableRubySupport( m_pAntiImpl->HasRubySupport() );
|
|
|
|
|
2004-02-03 17:27:58 +00:00
|
|
|
m_pConversionDialog->SetByCharacter( m_bByCharacter );
|
|
|
|
m_pConversionDialog->SetConversionFormat( m_eConversionFormat );
|
2004-11-26 13:32:06 +00:00
|
|
|
m_pConversionDialog->SetConversionDirectionState( m_bTryBothDirections, m_ePrimaryConversionDirection );
|
2004-02-03 17:27:58 +00:00
|
|
|
|
|
|
|
// the handlers
|
2004-11-26 13:32:06 +00:00
|
|
|
m_pConversionDialog->SetOptionsChangedHdl( LINK( this, HangulHanjaConversion_Impl, OnOptionsChanged ) );
|
2004-02-03 17:27:58 +00:00
|
|
|
m_pConversionDialog->SetIgnoreHdl( LINK( this, HangulHanjaConversion_Impl, OnIgnore ) );
|
|
|
|
m_pConversionDialog->SetIgnoreAllHdl( LINK( this, HangulHanjaConversion_Impl, OnIgnoreAll ) );
|
|
|
|
m_pConversionDialog->SetChangeHdl( LINK( this, HangulHanjaConversion_Impl, OnChange ) );
|
|
|
|
m_pConversionDialog->SetChangeAllHdl( LINK( this, HangulHanjaConversion_Impl, OnChangeAll ) );
|
|
|
|
m_pConversionDialog->SetClickByCharacterHdl( LINK( this, HangulHanjaConversion_Impl, OnByCharClicked ) );
|
|
|
|
m_pConversionDialog->SetConversionFormatChangedHdl( LINK( this, HangulHanjaConversion_Impl, OnConversionTypeChanged ) );
|
|
|
|
m_pConversionDialog->SetFindHdl( LINK( this, HangulHanjaConversion_Impl, OnFind ) );
|
|
|
|
}
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
sal_Int16 HangulHanjaConversion_Impl::implGetConversionType( bool bSwitchDirection ) const
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2004-09-17 12:44:46 +00:00
|
|
|
sal_Int16 nConversionType = -1;
|
|
|
|
if (m_eConvType == HHC::eConvHangulHanja)
|
2014-01-14 21:09:22 +01:00
|
|
|
nConversionType = ( HHC::eHangulToHanja == m_eCurrentConversionDirection && !bSwitchDirection ) ? TO_HANJA : TO_HANGUL;
|
2004-09-17 12:44:46 +00:00
|
|
|
else if (m_eConvType == HHC::eConvSimplifiedTraditional)
|
|
|
|
nConversionType = LANGUAGE_CHINESE_SIMPLIFIED == m_nTargetLang ? TO_SCHINESE : TO_TCHINESE;
|
|
|
|
DBG_ASSERT( nConversionType != -1, "unexpected conversion type" );
|
2004-11-26 13:32:06 +00:00
|
|
|
return nConversionType;
|
|
|
|
}
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
bool HangulHanjaConversion_Impl::implUpdateSuggestions( bool _bAllowSearchNextConvertibleText, const sal_Int32 _nStartAt )
|
|
|
|
{
|
|
|
|
// parameters for the converter
|
|
|
|
sal_Int32 nStartSearch = m_nCurrentStartIndex;
|
|
|
|
if( _bAllowSearchNextConvertibleText )
|
|
|
|
nStartSearch = _nStartAt;
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
sal_Int32 nLength = m_sCurrentPortion.getLength() - nStartSearch;
|
2005-11-08 08:13:44 +00:00
|
|
|
m_nCurrentConversionType = implGetConversionType();
|
2016-10-18 14:19:52 +02:00
|
|
|
m_nCurrentConversionOption = m_bByCharacter ? CHARACTER_BY_CHARACTER : css::i18n::TextConversionOption::NONE;
|
2004-11-26 13:32:06 +00:00
|
|
|
if( m_bIgnorePostPositionalWord )
|
2005-11-08 08:13:44 +00:00
|
|
|
m_nCurrentConversionOption = m_nCurrentConversionOption | IGNORE_POST_POSITIONAL_WORD;
|
|
|
|
|
|
|
|
// no need to check both directions for chinese conversion (saves time)
|
|
|
|
if (m_eConvType == HHC::eConvSimplifiedTraditional)
|
2013-04-21 16:55:25 +02:00
|
|
|
m_bTryBothDirections = false;
|
2004-09-17 12:44:46 +00:00
|
|
|
|
2013-04-21 16:55:25 +02:00
|
|
|
bool bFoundAny = true;
|
2003-04-17 16:41:42 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
TextConversionResult aResult = m_xConverter->getConversions(
|
|
|
|
m_sCurrentPortion,
|
2004-11-26 13:32:06 +00:00
|
|
|
nStartSearch,
|
2003-04-17 16:41:42 +00:00
|
|
|
nLength,
|
2004-09-17 12:44:46 +00:00
|
|
|
m_aSourceLocale,
|
2005-11-08 08:13:44 +00:00
|
|
|
m_nCurrentConversionType,
|
|
|
|
m_nCurrentConversionOption
|
2003-04-17 16:41:42 +00:00
|
|
|
);
|
2013-04-21 16:55:25 +02:00
|
|
|
const bool bFoundPrimary = aResult.Boundary.startPos < aResult.Boundary.endPos;
|
2003-04-17 16:41:42 +00:00
|
|
|
bFoundAny = bFoundPrimary;
|
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
if ( m_bTryBothDirections )
|
2003-04-17 16:41:42 +00:00
|
|
|
{ // see if we find another convertible when assuming the other direction
|
|
|
|
TextConversionResult aSecondResult = m_xConverter->getConversions(
|
|
|
|
m_sCurrentPortion,
|
2004-11-26 13:32:06 +00:00
|
|
|
nStartSearch,
|
2003-04-17 16:41:42 +00:00
|
|
|
nLength,
|
2004-09-17 12:44:46 +00:00
|
|
|
m_aSourceLocale,
|
2004-11-26 13:32:06 +00:00
|
|
|
implGetConversionType( true ), // switched!
|
2005-11-08 08:13:44 +00:00
|
|
|
m_nCurrentConversionOption
|
2003-04-17 16:41:42 +00:00
|
|
|
);
|
|
|
|
if ( aSecondResult.Boundary.startPos < aSecondResult.Boundary.endPos )
|
|
|
|
{ // we indeed found such a convertible
|
|
|
|
|
|
|
|
// in case the first attempt (with the original conversion direction)
|
|
|
|
// didn't find anything
|
|
|
|
if ( !bFoundPrimary
|
|
|
|
// or if the second location is _before_ the first one
|
|
|
|
|| ( aSecondResult.Boundary.startPos < aResult.Boundary.startPos )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// then use the second finding
|
|
|
|
aResult = aSecondResult;
|
|
|
|
|
|
|
|
// our current conversion direction changed now
|
2005-04-04 07:28:58 +00:00
|
|
|
m_eCurrentConversionDirection = ( HHC::eHangulToHanja == m_eCurrentConversionDirection )
|
2003-04-17 16:41:42 +00:00
|
|
|
? HHC::eHanjaToHangul : HHC::eHangulToHanja;
|
2013-04-21 16:55:25 +02:00
|
|
|
bFoundAny = true;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
if( _bAllowSearchNextConvertibleText )
|
|
|
|
{
|
|
|
|
//this might change the current position
|
|
|
|
m_aCurrentSuggestions = aResult.Candidates;
|
|
|
|
m_nCurrentStartIndex = aResult.Boundary.startPos;
|
|
|
|
m_nCurrentEndIndex = aResult.Boundary.endPos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//the change of starting position is not allowed
|
|
|
|
if( m_nCurrentStartIndex == aResult.Boundary.startPos
|
|
|
|
&& aResult.Boundary.endPos != aResult.Boundary.startPos )
|
|
|
|
{
|
|
|
|
m_aCurrentSuggestions = aResult.Candidates;
|
|
|
|
m_nCurrentEndIndex = aResult.Boundary.endPos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_aCurrentSuggestions.realloc( 0 );
|
|
|
|
if( m_sCurrentPortion.getLength() >= m_nCurrentStartIndex+1 )
|
|
|
|
m_nCurrentEndIndex = m_nCurrentStartIndex+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//put recently used string to front:
|
|
|
|
if( m_bShowRecentlyUsedFirst && m_aCurrentSuggestions.getLength()>1 )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCurrentUnit( GetCurrentUnit() );
|
2004-11-26 13:32:06 +00:00
|
|
|
StringMap::const_iterator aRecentlyUsed = m_aRecentlyUsedList.find( sCurrentUnit );
|
|
|
|
bool bUsedBefore = aRecentlyUsed != m_aRecentlyUsedList.end();
|
|
|
|
if( bUsedBefore && m_aCurrentSuggestions[0] != aRecentlyUsed->second )
|
|
|
|
{
|
|
|
|
sal_Int32 nCount = m_aCurrentSuggestions.getLength();
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > aTmp(nCount);
|
2004-11-26 13:32:06 +00:00
|
|
|
aTmp[0]=aRecentlyUsed->second;
|
|
|
|
sal_Int32 nDiff = 1;
|
|
|
|
for( sal_Int32 n=1; n<nCount; n++)//we had 0 already
|
|
|
|
{
|
|
|
|
if( nDiff && m_aCurrentSuggestions[n-nDiff]==aRecentlyUsed->second )
|
|
|
|
nDiff=0;
|
|
|
|
aTmp[n]=m_aCurrentSuggestions[n-nDiff];
|
|
|
|
}
|
|
|
|
m_aCurrentSuggestions = aTmp;
|
|
|
|
}
|
|
|
|
}
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
2006-06-19 14:11:47 +00:00
|
|
|
catch( const Exception& )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "HangulHanjaConversion_Impl::implNextConvertibleUnit: caught an exception!" );
|
2004-09-17 12:44:46 +00:00
|
|
|
|
|
|
|
//!!! at least we want to move on in the text in order
|
|
|
|
//!!! to avoid an endless loop...
|
|
|
|
return false;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
2004-11-26 13:32:06 +00:00
|
|
|
return bFoundAny;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HangulHanjaConversion_Impl::implNextConvertibleUnit( const sal_Int32 _nStartAt )
|
|
|
|
{
|
|
|
|
m_aCurrentSuggestions.realloc( 0 );
|
|
|
|
|
|
|
|
// ask the TextConversion service for the next convertible piece of text
|
|
|
|
|
2005-04-04 07:28:58 +00:00
|
|
|
// get current values from dialog
|
|
|
|
if( m_eConvType == HHC::eConvHangulHanja && m_pConversionDialog )
|
2004-11-26 13:32:06 +00:00
|
|
|
{
|
2005-04-04 07:28:58 +00:00
|
|
|
m_bTryBothDirections = m_pConversionDialog->GetUseBothDirections();
|
|
|
|
HHC::ConversionDirection eDialogDirection = HHC::eHangulToHanja;
|
|
|
|
eDialogDirection = m_pConversionDialog->GetDirection( eDialogDirection );
|
|
|
|
|
|
|
|
if( !m_bTryBothDirections && eDialogDirection != m_eCurrentConversionDirection )
|
|
|
|
{
|
|
|
|
m_eCurrentConversionDirection = eDialogDirection;
|
|
|
|
}
|
2004-11-26 13:32:06 +00:00
|
|
|
|
2015-02-24 23:49:49 +01:00
|
|
|
// save currently used value for possible later use
|
2016-08-25 17:16:14 +02:00
|
|
|
HangulHanjaConversion::m_bTryBothDirectionsSave = m_bTryBothDirections;
|
|
|
|
HangulHanjaConversion::m_ePrimaryConversionDirectionSave = m_eCurrentConversionDirection;
|
2004-11-26 13:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool bFoundAny = implUpdateSuggestions( true, _nStartAt );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
return bFoundAny &&
|
|
|
|
(m_nCurrentStartIndex < m_sCurrentPortion.getLength());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HangulHanjaConversion_Impl::implRetrieveNextPortion( )
|
|
|
|
{
|
2013-04-21 16:55:25 +02:00
|
|
|
const bool bAllowImplicitChanges = m_eConvType == HHC::eConvSimplifiedTraditional;
|
2005-10-05 13:38:13 +00:00
|
|
|
|
2014-11-12 14:24:10 +05:30
|
|
|
m_sCurrentPortion.clear();
|
2005-04-04 07:28:58 +00:00
|
|
|
m_nCurrentPortionLang = LANGUAGE_NONE;
|
2005-10-05 13:38:13 +00:00
|
|
|
m_pAntiImpl->GetNextPortion( m_sCurrentPortion, m_nCurrentPortionLang, bAllowImplicitChanges );
|
2003-04-17 16:41:42 +00:00
|
|
|
m_nReplacementBaseIndex = 0;
|
|
|
|
m_nCurrentStartIndex = m_nCurrentEndIndex = 0;
|
|
|
|
|
2011-12-23 10:25:18 -02:00
|
|
|
bool bRet = !m_sCurrentPortion.isEmpty();
|
2005-04-04 07:28:58 +00:00
|
|
|
|
|
|
|
if (m_eConvType == HHC::eConvHangulHanja && m_bTryBothDirections)
|
|
|
|
implGetConversionDirectionForCurrentPortion( m_eCurrentConversionDirection );
|
|
|
|
|
|
|
|
return bRet;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
2013-04-21 16:55:25 +02:00
|
|
|
bool HangulHanjaConversion_Impl::implNextConvertible( bool _bRepeatUnit )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
|
|
|
if ( _bRepeatUnit || ( m_nCurrentEndIndex < m_sCurrentPortion.getLength() ) )
|
|
|
|
{
|
|
|
|
if ( implNextConvertibleUnit(
|
|
|
|
_bRepeatUnit
|
2014-10-01 16:47:14 +01:00
|
|
|
? m_nCurrentStartIndex
|
2003-04-17 16:41:42 +00:00
|
|
|
: m_nCurrentEndIndex
|
|
|
|
) )
|
2013-04-21 16:55:25 +02:00
|
|
|
return true;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// no convertible text in the current portion anymore
|
|
|
|
// -> advance to the next portion
|
|
|
|
do
|
|
|
|
{
|
|
|
|
// next portion
|
|
|
|
if ( implRetrieveNextPortion( ) )
|
|
|
|
{ // there is a next portion
|
|
|
|
// -> find the next convertible unit in the current portion
|
|
|
|
if ( implNextConvertibleUnit( 0 ) )
|
2013-04-21 16:55:25 +02:00
|
|
|
return true;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-23 10:25:18 -02:00
|
|
|
while ( !m_sCurrentPortion.isEmpty() );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
// no more portions
|
2013-04-21 16:55:25 +02:00
|
|
|
return false;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString HangulHanjaConversion_Impl::GetCurrentUnit() const
|
2004-11-26 13:32:06 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( m_nCurrentStartIndex < m_sCurrentPortion.getLength(),
|
|
|
|
"HangulHanjaConversion_Impl::GetCurrentUnit: invalid index into current portion!" );
|
|
|
|
DBG_ASSERT( m_nCurrentEndIndex <= m_sCurrentPortion.getLength(),
|
|
|
|
"HangulHanjaConversion_Impl::GetCurrentUnit: invalid index into current portion!" );
|
|
|
|
DBG_ASSERT( m_nCurrentStartIndex <= m_nCurrentEndIndex,
|
|
|
|
"HangulHanjaConversion_Impl::GetCurrentUnit: invalid interval!" );
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCurrentUnit = m_sCurrentPortion.copy( m_nCurrentStartIndex, m_nCurrentEndIndex - m_nCurrentStartIndex );
|
2004-11-26 13:32:06 +00:00
|
|
|
return sCurrentUnit;
|
|
|
|
}
|
|
|
|
|
2013-04-21 16:55:25 +02:00
|
|
|
bool HangulHanjaConversion_Impl::ContinueConversion( bool _bRepeatCurrentUnit )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2013-04-21 17:48:41 +02:00
|
|
|
while ( implNextConvertible( _bRepeatCurrentUnit ) )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCurrentUnit( GetCurrentUnit() );
|
2004-11-26 13:32:06 +00:00
|
|
|
|
|
|
|
// do we need to ignore it?
|
2013-04-21 16:55:25 +02:00
|
|
|
const bool bAlwaysIgnoreThis = m_sIgnoreList.end() != m_sIgnoreList.find( sCurrentUnit );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
// do we need to change it?
|
|
|
|
StringMap::const_iterator aChangeListPos = m_aChangeList.find( sCurrentUnit );
|
2013-04-21 16:55:25 +02:00
|
|
|
const bool bAlwaysChangeThis = m_aChangeList.end() != aChangeListPos;
|
2004-11-26 13:32:06 +00:00
|
|
|
|
|
|
|
// do we automatically change this?
|
2013-04-21 16:55:25 +02:00
|
|
|
const bool bAutoChange = m_bAutoReplaceUnique && m_aCurrentSuggestions.getLength() == 1;
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-09-17 12:44:46 +00:00
|
|
|
if (!m_bIsInteractive)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2004-11-26 13:32:06 +00:00
|
|
|
// silent conversion (e.g. for simplified/traditional Chinese)...
|
|
|
|
if(m_aCurrentSuggestions.getLength()>0)
|
|
|
|
implChange( m_aCurrentSuggestions.getConstArray()[0] );
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
2004-11-26 13:32:06 +00:00
|
|
|
else if (bAutoChange)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2004-11-26 13:32:06 +00:00
|
|
|
implChange( m_aCurrentSuggestions.getConstArray()[0] );
|
|
|
|
}
|
|
|
|
else if ( bAlwaysChangeThis )
|
|
|
|
{
|
|
|
|
implChange( aChangeListPos->second );
|
|
|
|
}
|
|
|
|
else if ( !bAlwaysIgnoreThis )
|
|
|
|
{
|
|
|
|
// here we need to ask the user for what to do with the text
|
|
|
|
// for this, allow derivees to highlight the current text unit in a possible document view
|
|
|
|
m_pAntiImpl->HandleNewUnit( m_nCurrentStartIndex - m_nReplacementBaseIndex, m_nCurrentEndIndex - m_nReplacementBaseIndex );
|
2004-09-17 12:44:46 +00:00
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
DBG_ASSERT( m_pConversionDialog, "we should always have a dialog here!" );
|
|
|
|
if( m_pConversionDialog )
|
|
|
|
m_pConversionDialog->SetCurrentString( sCurrentUnit, m_aCurrentSuggestions );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
// do not look for the next convertible: We have to wait for the user to interactivly
|
|
|
|
// decide what happens with the current convertible
|
2013-04-21 17:48:41 +02:00
|
|
|
return false;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-21 17:48:41 +02:00
|
|
|
return true;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
2005-04-04 07:28:58 +00:00
|
|
|
bool HangulHanjaConversion_Impl::implGetConversionDirectionForCurrentPortion( HHC::ConversionDirection& rDirection )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2005-04-04 07:28:58 +00:00
|
|
|
// - For eConvHangulHanja the direction is determined by
|
2004-09-17 12:44:46 +00:00
|
|
|
// the first encountered Korean character.
|
|
|
|
// - For eConvSimplifiedTraditional the conversion direction
|
|
|
|
// is already specified by the source language.
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-09-17 12:44:46 +00:00
|
|
|
bool bSuccess = true;
|
|
|
|
|
2005-04-04 07:28:58 +00:00
|
|
|
if (m_eConvType == HHC::eConvHangulHanja)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2004-09-17 12:44:46 +00:00
|
|
|
bSuccess = false;
|
|
|
|
try
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2004-09-17 12:44:46 +00:00
|
|
|
// get the break iterator service
|
2015-02-05 18:03:06 +01:00
|
|
|
Reference< XBreakIterator > xBreakIter = i18n::BreakIterator::create( m_xContext );
|
2015-09-11 15:44:09 +02:00
|
|
|
sal_Int32 nNextAsianScript = xBreakIter->beginOfScript( m_sCurrentPortion, m_nCurrentStartIndex, css::i18n::ScriptType::ASIAN );
|
2012-10-15 15:20:48 +02:00
|
|
|
if ( -1 == nNextAsianScript )
|
2015-09-11 15:44:09 +02:00
|
|
|
nNextAsianScript = xBreakIter->nextScript( m_sCurrentPortion, m_nCurrentStartIndex, css::i18n::ScriptType::ASIAN );
|
2012-10-15 15:20:48 +02:00
|
|
|
if ( ( nNextAsianScript >= m_nCurrentStartIndex ) && ( nNextAsianScript < m_sCurrentPortion.getLength() ) )
|
|
|
|
{ // found asian text
|
|
|
|
|
|
|
|
// determine if it's Hangul
|
2012-11-23 23:06:10 +01:00
|
|
|
CharClass aCharClassificaton( m_xContext, LanguageTag( m_aSourceLocale) );
|
2012-10-15 15:20:48 +02:00
|
|
|
sal_Int16 nScript = aCharClassificaton.getScript( m_sCurrentPortion, sal::static_int_cast< sal_uInt16 >(nNextAsianScript) );
|
|
|
|
if ( ( UnicodeScript_kHangulJamo == nScript )
|
|
|
|
|| ( UnicodeScript_kHangulCompatibilityJamo == nScript )
|
|
|
|
|| ( UnicodeScript_kHangulSyllable == nScript )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
rDirection = HHC::eHangulToHanja;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rDirection = HHC::eHanjaToHangul;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
2012-10-15 15:20:48 +02:00
|
|
|
|
|
|
|
bSuccess = true;
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-19 14:11:47 +00:00
|
|
|
catch( const Exception& )
|
2004-09-17 12:44:46 +00:00
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "HangulHanjaConversion_Impl::implGetConversionDirectionForCurrentPortion: caught an exception!" );
|
2004-09-17 12:44:46 +00:00
|
|
|
}
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
2004-09-17 12:44:46 +00:00
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HangulHanjaConversion_Impl::DoDocumentConversion( )
|
|
|
|
{
|
|
|
|
// clear the change-all list - it's to be re-initialized for every single document
|
|
|
|
{
|
|
|
|
StringMap aEmpty;
|
|
|
|
m_aChangeList.swap( aEmpty );
|
|
|
|
}
|
|
|
|
|
|
|
|
// first of all, we need to guess the direction of our conversion - it is determined by the first
|
|
|
|
// hangul or hanja character in the first text
|
2004-11-26 13:32:06 +00:00
|
|
|
if ( !implRetrieveNextPortion() )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2015-10-19 11:55:44 +02:00
|
|
|
SAL_INFO( "editeng", "HangulHanjaConversion_Impl::DoDocumentConversion: why did you call me if you do have nothing to convert?" );
|
2003-04-17 16:41:42 +00:00
|
|
|
// nothing to do
|
|
|
|
return;
|
|
|
|
}
|
2005-04-04 07:28:58 +00:00
|
|
|
if( m_eConvType == HHC::eConvHangulHanja )
|
|
|
|
{
|
|
|
|
//init conversion direction from saved value
|
|
|
|
HHC::ConversionDirection eDirection = HHC::eHangulToHanja;
|
|
|
|
if(!implGetConversionDirectionForCurrentPortion( eDirection ))
|
|
|
|
// something went wrong, has already been asserted
|
|
|
|
return;
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2014-06-13 17:49:52 +02:00
|
|
|
if (HangulHanjaConversion::IsUseSavedConversionDirectionState())
|
2005-04-04 07:28:58 +00:00
|
|
|
{
|
2016-08-25 17:16:14 +02:00
|
|
|
m_ePrimaryConversionDirection = HangulHanjaConversion::m_ePrimaryConversionDirectionSave;
|
|
|
|
m_bTryBothDirections = HangulHanjaConversion::m_bTryBothDirectionsSave;
|
2005-04-04 07:28:58 +00:00
|
|
|
if( m_bTryBothDirections )
|
|
|
|
m_eCurrentConversionDirection = eDirection;
|
|
|
|
else
|
|
|
|
m_eCurrentConversionDirection = m_ePrimaryConversionDirection;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_ePrimaryConversionDirection = eDirection;
|
|
|
|
m_eCurrentConversionDirection = eDirection;
|
|
|
|
}
|
|
|
|
}
|
2004-11-26 13:32:06 +00:00
|
|
|
|
|
|
|
if (m_bIsInteractive && m_eConvType == HHC::eConvHangulHanja)
|
|
|
|
{
|
|
|
|
//always open dialog if at least having a hangul or hanja text portion
|
|
|
|
createDialog();
|
2014-06-13 17:49:52 +02:00
|
|
|
if(HangulHanjaConversion::IsUseSavedConversionDirectionState())
|
2013-04-21 16:55:25 +02:00
|
|
|
ContinueConversion( false );
|
2005-04-04 07:28:58 +00:00
|
|
|
else
|
|
|
|
implUpdateData();
|
2004-11-26 13:32:06 +00:00
|
|
|
m_pConversionDialog->Execute();
|
2016-09-21 14:48:15 +02:00
|
|
|
m_pConversionDialog.disposeAndClear();
|
2004-11-26 13:32:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-07-09 08:50:37 +02:00
|
|
|
const bool bCompletelyDone = ContinueConversion( false );
|
2004-11-26 13:32:06 +00:00
|
|
|
DBG_ASSERT( bCompletelyDone, "HangulHanjaConversion_Impl::DoDocumentConversion: ContinueConversion should have returned true here!" );
|
|
|
|
}
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HangulHanjaConversion_Impl::implProceed( bool _bRepeatCurrentUnit )
|
|
|
|
{
|
|
|
|
if ( ContinueConversion( _bRepeatCurrentUnit ) )
|
|
|
|
{ // we're done with the whole document
|
2004-09-17 12:44:46 +00:00
|
|
|
DBG_ASSERT( !m_bIsInteractive || m_pConversionDialog, "HangulHanjaConversion_Impl::implProceed: we should not reach this here without dialog!" );
|
2003-04-17 16:41:42 +00:00
|
|
|
if ( m_pConversionDialog )
|
|
|
|
m_pConversionDialog->EndDialog( RET_OK );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void HangulHanjaConversion_Impl::implChange( const OUString& _rChangeInto )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2011-12-23 10:25:18 -02:00
|
|
|
if( _rChangeInto.isEmpty() )
|
2004-11-26 13:32:06 +00:00
|
|
|
return;
|
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
// translate the conversion format into a replacement action
|
|
|
|
// this translation depends on whether we have a Hangul original, or a Hanja original
|
|
|
|
|
|
|
|
HHC::ReplacementAction eAction( HHC::eExchange );
|
2004-09-17 12:44:46 +00:00
|
|
|
|
|
|
|
if (m_eConvType == HHC::eConvHangulHanja)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2004-09-17 12:44:46 +00:00
|
|
|
// is the original we're about to change in Hangul?
|
2013-04-21 16:55:25 +02:00
|
|
|
const bool bOriginalIsHangul = HHC::eHangulToHanja == m_eCurrentConversionDirection;
|
2004-09-17 12:44:46 +00:00
|
|
|
|
|
|
|
switch ( m_eConversionFormat )
|
|
|
|
{
|
|
|
|
case HHC::eSimpleConversion: eAction = HHC::eExchange; break;
|
|
|
|
case HHC::eHangulBracketed: eAction = bOriginalIsHangul ? HHC::eOriginalBracketed : HHC::eReplacementBracketed; break;
|
|
|
|
case HHC::eHanjaBracketed: eAction = bOriginalIsHangul ? HHC::eReplacementBracketed : HHC::eOriginalBracketed; break;
|
|
|
|
case HHC::eRubyHanjaAbove: eAction = bOriginalIsHangul ? HHC::eReplacementAbove : HHC::eOriginalAbove; break;
|
|
|
|
case HHC::eRubyHanjaBelow: eAction = bOriginalIsHangul ? HHC::eReplacementBelow : HHC::eOriginalBelow; break;
|
|
|
|
case HHC::eRubyHangulAbove: eAction = bOriginalIsHangul ? HHC::eOriginalAbove : HHC::eReplacementAbove; break;
|
|
|
|
case HHC::eRubyHangulBelow: eAction = bOriginalIsHangul ? HHC::eOriginalBelow : HHC::eReplacementBelow; break;
|
|
|
|
default:
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "HangulHanjaConversion_Impl::implChange: invalid/unexpected conversion format!" );
|
2004-09-17 12:44:46 +00:00
|
|
|
}
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
2014-04-29 19:05:05 +00:00
|
|
|
// the proper indices (the wrapper implementation needs indices relative to the
|
2003-04-17 16:41:42 +00:00
|
|
|
// previous replacement)
|
|
|
|
DBG_ASSERT( ( m_nReplacementBaseIndex <= m_nCurrentStartIndex ) && ( m_nReplacementBaseIndex <= m_nCurrentEndIndex ),
|
|
|
|
"HangulHanjaConversion_Impl::implChange: invalid replacement base!" );
|
|
|
|
|
|
|
|
sal_Int32 nStartIndex = m_nCurrentStartIndex - m_nReplacementBaseIndex;
|
|
|
|
sal_Int32 nEndIndex = m_nCurrentEndIndex - m_nReplacementBaseIndex;
|
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
//remind this decision
|
|
|
|
m_aRecentlyUsedList[ GetCurrentUnit() ] = _rChangeInto;
|
|
|
|
|
2015-11-10 10:14:16 +01:00
|
|
|
LanguageType *pNewUnitLang = nullptr;
|
2005-04-04 07:28:58 +00:00
|
|
|
LanguageType nNewUnitLang = LANGUAGE_NONE;
|
|
|
|
if (m_eConvType == HHC::eConvSimplifiedTraditional)
|
|
|
|
{
|
|
|
|
// check if language needs to be changed
|
|
|
|
if ( m_pAntiImpl->GetTargetLanguage() == LANGUAGE_CHINESE_TRADITIONAL &&
|
2014-06-13 17:49:52 +02:00
|
|
|
!HangulHanjaConversion::IsTraditional( m_nCurrentPortionLang ))
|
2005-04-04 07:28:58 +00:00
|
|
|
nNewUnitLang = LANGUAGE_CHINESE_TRADITIONAL;
|
|
|
|
else if ( m_pAntiImpl->GetTargetLanguage() == LANGUAGE_CHINESE_SIMPLIFIED &&
|
2014-06-13 17:49:52 +02:00
|
|
|
!HangulHanjaConversion::IsSimplified( m_nCurrentPortionLang ))
|
2005-04-04 07:28:58 +00:00
|
|
|
nNewUnitLang = LANGUAGE_CHINESE_SIMPLIFIED;
|
|
|
|
if (nNewUnitLang != LANGUAGE_NONE)
|
|
|
|
pNewUnitLang = &nNewUnitLang;
|
|
|
|
}
|
|
|
|
|
2005-11-08 08:13:44 +00:00
|
|
|
// according to FT we should not (yet) bother about Hangul/Hanja conversion here
|
|
|
|
//
|
2014-11-10 15:05:25 +01:00
|
|
|
// aOffsets is needed in ReplaceUnit below in order to find out
|
2005-11-08 08:13:44 +00:00
|
|
|
// exactly which characters are really changed in order to keep as much
|
|
|
|
// from attributation for the text as possible.
|
|
|
|
Sequence< sal_Int32 > aOffsets;
|
|
|
|
Reference< XExtendedTextConversion > xExtConverter( m_xConverter, UNO_QUERY );
|
|
|
|
if (m_eConvType == HHC::eConvSimplifiedTraditional && xExtConverter.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-03-04 15:25:02 +01:00
|
|
|
xExtConverter->getConversionWithOffset(
|
2005-11-08 08:13:44 +00:00
|
|
|
m_sCurrentPortion,
|
|
|
|
m_nCurrentStartIndex,
|
|
|
|
m_nCurrentEndIndex - m_nCurrentStartIndex,
|
|
|
|
m_aSourceLocale,
|
|
|
|
m_nCurrentConversionType,
|
|
|
|
m_nCurrentConversionOption,
|
|
|
|
aOffsets
|
|
|
|
);
|
|
|
|
}
|
2006-10-12 11:13:46 +00:00
|
|
|
catch( const Exception& )
|
2005-11-08 08:13:44 +00:00
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "HangulHanjaConversion_Impl::implChange: caught unexpected exception!" );
|
2005-11-08 08:13:44 +00:00
|
|
|
aOffsets.realloc(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
// do the replacement
|
2005-11-08 08:13:44 +00:00
|
|
|
m_pAntiImpl->ReplaceUnit( nStartIndex, nEndIndex, m_sCurrentPortion,
|
|
|
|
_rChangeInto, aOffsets, eAction, pNewUnitLang );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
// adjust the replacement base
|
|
|
|
m_nReplacementBaseIndex = m_nCurrentEndIndex;
|
|
|
|
}
|
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
void HangulHanjaConversion_Impl::implReadOptionsFromConfiguration()
|
|
|
|
{
|
|
|
|
SvtLinguConfig aLngCfg;
|
|
|
|
aLngCfg.GetProperty( UPH_IS_IGNORE_POST_POSITIONAL_WORD ) >>= m_bIgnorePostPositionalWord;
|
|
|
|
aLngCfg.GetProperty( UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST ) >>= m_bShowRecentlyUsedFirst;
|
|
|
|
aLngCfg.GetProperty( UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES ) >>= m_bAutoReplaceUnique;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HangulHanjaConversion_Impl::implUpdateData()
|
|
|
|
{
|
|
|
|
implReadOptionsFromConfiguration();
|
|
|
|
implUpdateSuggestions();
|
|
|
|
|
|
|
|
if(m_pConversionDialog)
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCurrentUnit( GetCurrentUnit() );
|
2004-11-26 13:32:06 +00:00
|
|
|
|
|
|
|
m_pConversionDialog->SetCurrentString( sCurrentUnit, m_aCurrentSuggestions );
|
|
|
|
m_pConversionDialog->FocusSuggestion();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pAntiImpl->HandleNewUnit( m_nCurrentStartIndex - m_nReplacementBaseIndex, m_nCurrentEndIndex - m_nReplacementBaseIndex );
|
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(HangulHanjaConversion_Impl, OnOptionsChanged, LinkParamNone*, void)
|
2004-11-26 13:32:06 +00:00
|
|
|
{
|
|
|
|
//options and dictionaries might have been changed
|
|
|
|
//-> update our internal settings and the dialog
|
|
|
|
implUpdateData();
|
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(HangulHanjaConversion_Impl, OnIgnore, Button*, void)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
|
|
|
// simply ignore, and proceed
|
2013-04-21 16:55:25 +02:00
|
|
|
implProceed( false );
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(HangulHanjaConversion_Impl, OnIgnoreAll, Button*, void)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( m_pConversionDialog, "HangulHanjaConversion_Impl::OnIgnoreAll: no dialog! How this?" );
|
|
|
|
|
|
|
|
if ( m_pConversionDialog )
|
|
|
|
{
|
2013-09-10 10:09:32 +02:00
|
|
|
OUString sCurrentUnit = m_pConversionDialog->GetCurrentString();
|
2003-04-17 16:41:42 +00:00
|
|
|
DBG_ASSERT( m_sIgnoreList.end() == m_sIgnoreList.find( sCurrentUnit ),
|
|
|
|
"HangulHanjaConversion_Impl, OnIgnoreAll: shouldn't this have been ignored before" );
|
|
|
|
|
|
|
|
// put into the "ignore all" list
|
|
|
|
m_sIgnoreList.insert( sCurrentUnit );
|
|
|
|
|
|
|
|
// and proceed
|
2013-04-21 16:55:25 +02:00
|
|
|
implProceed( false );
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(HangulHanjaConversion_Impl, OnChange, Button*, void)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
|
|
|
// change
|
2004-11-26 13:32:06 +00:00
|
|
|
DBG_ASSERT( m_pConversionDialog, "we should always have a dialog here!" );
|
|
|
|
if( m_pConversionDialog )
|
|
|
|
implChange( m_pConversionDialog->GetCurrentSuggestion( ) );
|
2003-04-17 16:41:42 +00:00
|
|
|
// and proceed
|
2013-04-21 16:55:25 +02:00
|
|
|
implProceed( false );
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(HangulHanjaConversion_Impl, OnChangeAll, Button*, void)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( m_pConversionDialog, "HangulHanjaConversion_Impl::OnChangeAll: no dialog! How this?" );
|
|
|
|
if ( m_pConversionDialog )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCurrentUnit( m_pConversionDialog->GetCurrentString() );
|
|
|
|
OUString sChangeInto( m_pConversionDialog->GetCurrentSuggestion( ) );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2011-12-23 10:25:18 -02:00
|
|
|
if( !sChangeInto.isEmpty() )
|
2004-11-26 13:32:06 +00:00
|
|
|
{
|
2010-12-04 13:16:21 +09:00
|
|
|
// change the current occurrence
|
2004-11-26 13:32:06 +00:00
|
|
|
implChange( sChangeInto );
|
2003-04-17 16:41:42 +00:00
|
|
|
|
2004-11-26 13:32:06 +00:00
|
|
|
// put into the "change all" list
|
|
|
|
m_aChangeList.insert( StringMap::value_type( sCurrentUnit, sChangeInto ) );
|
|
|
|
}
|
2003-04-17 16:41:42 +00:00
|
|
|
|
|
|
|
// and proceed
|
2013-04-21 16:55:25 +02:00
|
|
|
implProceed( false );
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK( HangulHanjaConversion_Impl, OnByCharClicked, CheckBox*, _pBox, void )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
|
|
|
m_bByCharacter = _pBox->IsChecked();
|
|
|
|
|
|
|
|
// continue conversion, without advancing to the next unit, but instead continuing with the current unit
|
2013-04-21 16:55:25 +02:00
|
|
|
implProceed( true );
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(HangulHanjaConversion_Impl, OnConversionTypeChanged, Button*, void)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2004-11-26 13:32:06 +00:00
|
|
|
DBG_ASSERT( m_pConversionDialog, "we should always have a dialog here!" );
|
|
|
|
if( m_pConversionDialog )
|
|
|
|
m_eConversionFormat = m_pConversionDialog->GetConversionFormat( );
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(HangulHanjaConversion_Impl, OnFind, Button*, void)
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( m_pConversionDialog, "HangulHanjaConversion_Impl::OnFind: where did this come from?" );
|
|
|
|
if ( m_pConversionDialog )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sNewOriginal( m_pConversionDialog->GetCurrentSuggestion( ) );
|
|
|
|
Sequence< OUString > aSuggestions;
|
2004-11-26 13:32:06 +00:00
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
DBG_ASSERT( m_xConverter.is(), "HangulHanjaConversion_Impl::OnFind: no converter!" );
|
|
|
|
TextConversionResult aToHanja = m_xConverter->getConversions(
|
|
|
|
sNewOriginal,
|
|
|
|
0, sNewOriginal.getLength(),
|
2004-09-17 12:44:46 +00:00
|
|
|
m_aSourceLocale,
|
2003-04-17 16:41:42 +00:00
|
|
|
TextConversionType::TO_HANJA,
|
|
|
|
TextConversionOption::NONE
|
|
|
|
);
|
|
|
|
TextConversionResult aToHangul = m_xConverter->getConversions(
|
|
|
|
sNewOriginal,
|
|
|
|
0, sNewOriginal.getLength(),
|
2004-09-17 12:44:46 +00:00
|
|
|
m_aSourceLocale,
|
2003-04-17 16:41:42 +00:00
|
|
|
TextConversionType::TO_HANGUL,
|
|
|
|
TextConversionOption::NONE
|
|
|
|
);
|
|
|
|
|
|
|
|
bool bHaveToHanja = ( aToHanja.Boundary.startPos < aToHanja.Boundary.endPos );
|
|
|
|
bool bHaveToHangul = ( aToHangul.Boundary.startPos < aToHangul.Boundary.endPos );
|
|
|
|
|
2015-11-10 10:14:16 +01:00
|
|
|
TextConversionResult* pResult = nullptr;
|
2003-04-17 16:41:42 +00:00
|
|
|
if ( bHaveToHanja && bHaveToHangul )
|
|
|
|
{ // it found convertibles in both directions -> use the first
|
|
|
|
if ( aToHangul.Boundary.startPos < aToHanja.Boundary.startPos )
|
|
|
|
pResult = &aToHangul;
|
|
|
|
else
|
|
|
|
pResult = &aToHanja;
|
|
|
|
}
|
|
|
|
else if ( bHaveToHanja )
|
|
|
|
{ // only found toHanja
|
|
|
|
pResult = &aToHanja;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // only found toHangul
|
|
|
|
pResult = &aToHangul;
|
|
|
|
}
|
|
|
|
if ( pResult )
|
|
|
|
aSuggestions = pResult->Candidates;
|
|
|
|
|
|
|
|
m_pConversionDialog->SetCurrentString( sNewOriginal, aSuggestions, false );
|
|
|
|
m_pConversionDialog->FocusSuggestion();
|
|
|
|
}
|
2006-06-19 14:11:47 +00:00
|
|
|
catch( const Exception& )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "HangulHanjaConversion_Impl::OnFind: caught an exception!" );
|
2003-04-17 16:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-21 16:55:25 +02:00
|
|
|
bool HangulHanjaConversion::m_bUseSavedValues = false;
|
|
|
|
bool HangulHanjaConversion::m_bTryBothDirectionsSave = false;
|
2004-11-26 13:32:06 +00:00
|
|
|
HHC::ConversionDirection HangulHanjaConversion::m_ePrimaryConversionDirectionSave = HHC::eHangulToHanja;
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
HangulHanjaConversion::HangulHanjaConversion( vcl::Window* _pUIParent,
|
2012-11-02 16:07:50 +02:00
|
|
|
const Reference< XComponentContext >& rxContext,
|
2015-02-05 17:43:09 +01:00
|
|
|
const lang::Locale& _rSourceLocale, const lang::Locale& _rTargetLocale,
|
2014-09-16 10:09:58 +02:00
|
|
|
const vcl::Font* _pTargetFont,
|
2013-04-21 16:55:25 +02:00
|
|
|
sal_Int32 _nOptions, bool _bIsInteractive)
|
2012-11-02 16:07:50 +02:00
|
|
|
:m_pImpl( new HangulHanjaConversion_Impl( _pUIParent, rxContext, _rSourceLocale, _rTargetLocale, _pTargetFont, _nOptions, _bIsInteractive, this ) )
|
2003-04-17 16:41:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
HangulHanjaConversion::~HangulHanjaConversion( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-21 16:55:25 +02:00
|
|
|
void HangulHanjaConversion::SetUseSavedConversionDirectionState( bool bVal )
|
2004-11-26 13:32:06 +00:00
|
|
|
{
|
|
|
|
m_bUseSavedValues = bVal;
|
|
|
|
}
|
|
|
|
|
2013-04-21 16:55:25 +02:00
|
|
|
bool HangulHanjaConversion::IsUseSavedConversionDirectionState()
|
2004-11-26 13:32:06 +00:00
|
|
|
{
|
|
|
|
return m_bUseSavedValues;
|
|
|
|
}
|
|
|
|
|
2004-09-17 12:44:46 +00:00
|
|
|
LanguageType HangulHanjaConversion::GetSourceLanguage( ) const
|
|
|
|
{
|
|
|
|
return m_pImpl->GetSourceLang();
|
|
|
|
}
|
|
|
|
|
|
|
|
LanguageType HangulHanjaConversion::GetTargetLanguage( ) const
|
|
|
|
{
|
|
|
|
return m_pImpl->GetTargetLang();
|
|
|
|
}
|
|
|
|
|
2014-09-16 10:09:58 +02:00
|
|
|
const vcl::Font * HangulHanjaConversion::GetTargetFont( ) const
|
2004-09-17 12:44:46 +00:00
|
|
|
{
|
|
|
|
return m_pImpl->GetTargetFont();
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 HangulHanjaConversion::GetConversionOptions( ) const
|
|
|
|
{
|
|
|
|
return m_pImpl->GetConvOptions();
|
|
|
|
}
|
|
|
|
|
2013-04-21 16:55:25 +02:00
|
|
|
bool HangulHanjaConversion::IsInteractive( ) const
|
2004-09-17 12:44:46 +00:00
|
|
|
{
|
|
|
|
return m_pImpl->IsInteractive();
|
|
|
|
}
|
|
|
|
|
2003-04-17 16:41:42 +00:00
|
|
|
void HangulHanjaConversion::ConvertDocument()
|
|
|
|
{
|
|
|
|
if ( m_pImpl->IsValid() )
|
|
|
|
m_pImpl->DoDocumentConversion( );
|
|
|
|
}
|
|
|
|
|
2015-05-15 13:27:19 +02:00
|
|
|
}
|
2008-06-24 15:40:08 +00:00
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|