2010-10-27 13:11:31 +01: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 .
|
|
|
|
*/
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2013-10-23 19:17:57 +02:00
|
|
|
#ifndef INCLUDED_EDITENG_SVXACORR_HXX
|
|
|
|
#define INCLUDED_EDITENG_SVXACORR_HXX
|
2007-04-11 15:29:45 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/embed/XStorage.hpp>
|
2012-07-25 12:23:17 +02:00
|
|
|
|
|
|
|
#include <o3tl/sorted_vector.hxx>
|
2014-04-07 12:31:09 +02:00
|
|
|
#include <sot/storage.hxx>
|
2007-04-11 15:29:45 +00:00
|
|
|
#include <tools/rtti.hxx>
|
2013-09-21 15:20:49 +02:00
|
|
|
#include <i18nlangtag/languagetag.hxx>
|
2007-04-11 15:29:45 +00:00
|
|
|
#include <tools/time.hxx>
|
|
|
|
#include <tools/date.hxx>
|
2010-01-06 19:26:54 +01:00
|
|
|
#include <editeng/swafopt.hxx>
|
2013-11-09 14:13:31 -06:00
|
|
|
#include <editeng/editengdllapi.h>
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-12-23 16:17:40 -05:00
|
|
|
#include <map>
|
2011-12-24 15:52:50 -05:00
|
|
|
#include <boost/ptr_container/ptr_map.hpp>
|
2011-12-23 16:17:40 -05:00
|
|
|
|
2007-04-11 15:29:45 +00:00
|
|
|
class CharClass;
|
|
|
|
class SfxPoolItem;
|
|
|
|
class SvxAutoCorrect;
|
|
|
|
class SfxObjectShell;
|
2014-09-23 11:20:40 +02:00
|
|
|
namespace vcl { class Window; }
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2012-07-25 12:23:17 +02:00
|
|
|
struct CompareSvStringsISortDtor
|
|
|
|
{
|
2013-09-05 17:03:39 +02:00
|
|
|
bool operator()( OUString const& lhs, OUString const& rhs ) const
|
2012-07-25 12:23:17 +02:00
|
|
|
{
|
2013-09-05 17:03:39 +02:00
|
|
|
return lhs.compareToIgnoreAsciiCase( rhs ) < 0;
|
2012-07-25 12:23:17 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class SvStringsISortDtor
|
2013-09-05 17:03:39 +02:00
|
|
|
: public o3tl::sorted_vector<OUString, CompareSvStringsISortDtor>
|
2012-07-25 12:23:17 +02:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Auto correct flags
|
|
|
|
const long CptlSttSntnc = 0x00000001; // Capital letters at the beginning of a sentence
|
|
|
|
const long CptlSttWrd = 0x00000002; // not two Capital letters at the beginning of a word
|
2011-10-24 11:01:36 +02:00
|
|
|
const long AddNonBrkSpace = 0x00000004; // Add non breaking space before :;?!%
|
2007-04-11 15:29:45 +00:00
|
|
|
const long ChgOrdinalNumber = 0x00000008; // Ordinal-Number 1st, 2nd,..
|
|
|
|
const long ChgToEnEmDash = 0x00000010; // - -> Endash/Emdash
|
2011-02-16 16:34:02 -05:00
|
|
|
const long ChgWeightUnderl = 0x00000020; // * -> Bold, _ -> Underscore
|
|
|
|
const long SetINetAttr = 0x00000040; // Set INetAttribut
|
|
|
|
const long Autocorrect = 0x00000080; // Call AutoCorrect
|
|
|
|
const long ChgQuotes = 0x00000100; // replace double quotes
|
|
|
|
const long SaveWordCplSttLst= 0x00000200; // Save Auto correction of Capital letter at beginning of sentence.
|
|
|
|
const long SaveWordWrdSttLst= 0x00000400; // Save Auto correction of 2 Capital letter at beginning of word.
|
|
|
|
const long IgnoreDoubleSpace= 0x00000800; // Ignore 2 Spaces
|
|
|
|
const long ChgSglQuotes = 0x00001000; // Replace simple quotes
|
2010-09-29 16:20:12 -04:00
|
|
|
const long CorrectCapsLock = 0x00002000; // Correct accidental use of cAPS LOCK key
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
const long ChgWordLstLoad = 0x20000000; // Replacement list loaded
|
|
|
|
const long CplSttLstLoad = 0x40000000; // Exception list for Capital letters Start loaded
|
|
|
|
const long WrdSttLstLoad = 0x80000000; // Exception list for Word Start loaded
|
2007-04-11 15:29:45 +00:00
|
|
|
|
|
|
|
// TODO: handle unicodes > U+FFFF and check users of this class
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// only a mapping class
|
2010-01-06 19:26:54 +01:00
|
|
|
class EDITENG_DLLPUBLIC SvxAutoCorrDoc
|
2007-04-11 15:29:45 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SvxAutoCorrDoc() {}
|
|
|
|
virtual ~SvxAutoCorrDoc();
|
|
|
|
|
2014-02-26 11:01:45 +02:00
|
|
|
virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) = 0;
|
|
|
|
virtual bool Insert( sal_Int32 nPos, const OUString& rTxt ) = 0;
|
|
|
|
virtual bool Replace( sal_Int32 nPos, const OUString& rTxt ) = 0;
|
|
|
|
virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rTxt ) = 0;
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2014-02-26 11:01:45 +02:00
|
|
|
virtual bool SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId,
|
2007-04-11 15:29:45 +00:00
|
|
|
SfxPoolItem& ) = 0;
|
|
|
|
|
2014-02-26 11:01:45 +02:00
|
|
|
virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) = 0;
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2013-09-06 12:01:31 +02:00
|
|
|
// Return the text of a previous paragraph.
|
|
|
|
// If no paragraph exits or just an empty one, then return an empty string.
|
2011-02-16 16:34:02 -05:00
|
|
|
// The flag indicates:
|
|
|
|
// TRUE: before the normal insertion position (TRUE)
|
|
|
|
// FALSE: in which the corrected word was inserted.
|
|
|
|
// (Does not to have to be the same paragraph !!!!)
|
2014-02-08 00:23:10 +01:00
|
|
|
virtual OUString const* GetPrevPara(bool bAtNormalPos) = 0;
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2013-09-18 13:51:35 +01:00
|
|
|
virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
|
2007-04-11 15:29:45 +00:00
|
|
|
SvxAutoCorrect& rACorrect,
|
2013-09-06 12:01:31 +02:00
|
|
|
OUString* pPara ) = 0;
|
2011-02-16 16:34:02 -05:00
|
|
|
// Is called after the change of the signs by the functions
|
2007-04-11 15:29:45 +00:00
|
|
|
// - FnCptlSttWrd
|
|
|
|
// - FnCptlSttSntnc
|
2011-02-16 16:34:02 -05:00
|
|
|
// As an option, the words can then be inserted into the exception lists.
|
2014-01-15 10:14:52 +00:00
|
|
|
virtual void SaveCpltSttWord( sal_uLong nFlag, sal_Int32 nPos,
|
2013-09-06 12:01:31 +02:00
|
|
|
const OUString& rExceptWord,
|
2007-04-11 15:29:45 +00:00
|
|
|
sal_Unicode cChar );
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// which language at the position?
|
2014-02-26 11:01:45 +02:00
|
|
|
virtual LanguageType GetLanguage( sal_Int32 nPos, bool bPrevPara = false ) const;
|
2007-04-11 15:29:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-01-06 19:26:54 +01:00
|
|
|
class EDITENG_DLLPUBLIC SvxAutocorrWord
|
2007-04-11 15:29:45 +00:00
|
|
|
{
|
2013-09-06 12:13:37 +02:00
|
|
|
OUString sShort, sLong;
|
2014-02-26 11:01:45 +02:00
|
|
|
bool bIsTxtOnly; // Is pure ASCII - Text
|
2007-04-11 15:29:45 +00:00
|
|
|
public:
|
2014-02-26 11:01:45 +02:00
|
|
|
SvxAutocorrWord( const OUString& rS, const OUString& rL, bool bFlag = true )
|
2007-04-11 15:29:45 +00:00
|
|
|
: sShort( rS ), sLong( rL ), bIsTxtOnly( bFlag )
|
|
|
|
{}
|
|
|
|
|
2013-09-06 12:13:37 +02:00
|
|
|
const OUString& GetShort() const { return sShort; }
|
|
|
|
const OUString& GetLong() const { return sLong; }
|
2014-02-26 11:01:45 +02:00
|
|
|
bool IsTextOnly() const { return bIsTxtOnly; }
|
2007-04-11 15:29:45 +00:00
|
|
|
};
|
|
|
|
|
2012-12-10 20:41:38 +00:00
|
|
|
class EDITENG_DLLPUBLIC SvxAutocorrWordList
|
2012-07-10 14:29:46 +02:00
|
|
|
{
|
2014-11-22 13:23:44 -05:00
|
|
|
struct Impl;
|
|
|
|
Impl* mpImpl;
|
|
|
|
|
2015-02-07 12:13:35 +01:00
|
|
|
SvxAutocorrWordList( const SvxAutocorrWordList& ) SAL_DELETED_FUNCTION;
|
|
|
|
const SvxAutocorrWordList& operator= ( const SvxAutocorrWordList& ) SAL_DELETED_FUNCTION;
|
2014-11-22 12:37:09 -05:00
|
|
|
|
2013-08-21 13:15:29 +02:00
|
|
|
const SvxAutocorrWord* WordMatches(const SvxAutocorrWord *pFnd,
|
2013-09-06 12:57:33 +02:00
|
|
|
const OUString &rTxt,
|
2013-09-18 13:51:35 +01:00
|
|
|
sal_Int32 &rStt,
|
|
|
|
sal_Int32 nEndPos) const;
|
2012-07-10 14:29:46 +02:00
|
|
|
public:
|
2014-11-22 12:37:09 -05:00
|
|
|
SvxAutocorrWordList();
|
2012-12-10 20:41:38 +00:00
|
|
|
// free any objects still in the set
|
|
|
|
~SvxAutocorrWordList();
|
|
|
|
void DeleteAndDestroyAll();
|
2013-08-21 13:15:29 +02:00
|
|
|
bool Insert(SvxAutocorrWord *pWord) const;
|
2012-12-10 20:41:38 +00:00
|
|
|
SvxAutocorrWord* FindAndRemove(SvxAutocorrWord *pWord);
|
2014-02-26 11:01:45 +02:00
|
|
|
void LoadEntry(const OUString& sWrong, const OUString& sRight, bool bOnlyTxt);
|
2012-12-10 20:41:38 +00:00
|
|
|
bool empty() const;
|
|
|
|
|
2012-12-10 16:57:36 +00:00
|
|
|
typedef std::vector<SvxAutocorrWord *> Content;
|
2012-12-10 20:41:38 +00:00
|
|
|
Content getSortedContent() const;
|
|
|
|
|
2013-09-18 13:51:35 +01:00
|
|
|
const SvxAutocorrWord* SearchWordsInList(const OUString& rTxt, sal_Int32& rStt, sal_Int32 nEndPos) const;
|
2012-07-10 14:29:46 +02:00
|
|
|
};
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2010-01-06 19:26:54 +01:00
|
|
|
class EDITENG_DLLPUBLIC SvxAutoCorrectLanguageLists
|
2007-04-11 15:29:45 +00:00
|
|
|
{
|
2013-09-06 14:32:54 +02:00
|
|
|
OUString sShareAutoCorrFile, sUserAutoCorrFile;
|
2011-02-16 16:34:02 -05:00
|
|
|
// If the AutoCorr file is newer
|
2007-04-11 15:29:45 +00:00
|
|
|
Date aModifiedDate;
|
2014-09-28 15:49:26 +02:00
|
|
|
tools::Time aModifiedTime, aLastCheckTime;
|
2007-04-11 15:29:45 +00:00
|
|
|
|
|
|
|
SvStringsISortDtor* pCplStt_ExcptLst;
|
|
|
|
SvStringsISortDtor* pWrdStt_ExcptLst;
|
|
|
|
SvxAutocorrWordList* pAutocorr_List;
|
|
|
|
SvxAutoCorrect& rAutoCorrect;
|
|
|
|
|
|
|
|
long nFlags;
|
|
|
|
|
2014-02-26 11:01:45 +02:00
|
|
|
bool IsFileChanged_Imp();
|
2007-04-11 15:29:45 +00:00
|
|
|
void LoadXMLExceptList_Imp( SvStringsISortDtor*& rpLst,
|
|
|
|
const sal_Char* pStrmName,
|
|
|
|
SotStorageRef& rStg);
|
2015-04-10 14:12:10 +02:00
|
|
|
static void SaveExceptList_Imp( const SvStringsISortDtor& rLst,
|
2007-04-11 15:29:45 +00:00
|
|
|
const sal_Char* pStrmName,
|
|
|
|
SotStorageRef& rStg,
|
2014-02-26 11:01:45 +02:00
|
|
|
bool bConvert = false);
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2014-02-26 11:01:45 +02:00
|
|
|
bool MakeBlocklist_Imp( SotStorage& rStg );
|
2013-09-06 14:32:54 +02:00
|
|
|
void RemoveStream_Imp( const OUString& rName );
|
2007-04-11 15:29:45 +00:00
|
|
|
void MakeUserStorage_Impl();
|
|
|
|
|
|
|
|
public:
|
|
|
|
SvxAutoCorrectLanguageLists( SvxAutoCorrect& rParent,
|
2013-09-06 14:32:54 +02:00
|
|
|
const OUString& rShareAutoCorrectFile,
|
|
|
|
const OUString& rUserAutoCorrectFile);
|
2007-04-11 15:29:45 +00:00
|
|
|
~SvxAutoCorrectLanguageLists();
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Load, Set, Get - the replacement list
|
2007-04-11 15:29:45 +00:00
|
|
|
SvxAutocorrWordList* LoadAutocorrWordList();
|
|
|
|
void SetAutocorrWordList( SvxAutocorrWordList* pList );
|
|
|
|
const SvxAutocorrWordList* GetAutocorrWordList();
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Load, Set, Get - the exception list for Capital letter at the
|
|
|
|
// beginning of a sentence
|
2007-04-11 15:29:45 +00:00
|
|
|
SvStringsISortDtor* LoadCplSttExceptList();
|
|
|
|
void SaveCplSttExceptList();
|
|
|
|
void SetCplSttExceptList( SvStringsISortDtor* pList );
|
|
|
|
SvStringsISortDtor* GetCplSttExceptList();
|
2014-02-26 11:01:45 +02:00
|
|
|
bool AddToCplSttExceptList(const OUString& rNew);
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Load, Set, Get the exception list for 2 Capital letters at the
|
2013-02-23 19:17:03 +01:00
|
|
|
// beginning of a word.
|
2007-04-11 15:29:45 +00:00
|
|
|
SvStringsISortDtor* LoadWrdSttExceptList();
|
|
|
|
void SaveWrdSttExceptList();
|
|
|
|
void SetWrdSttExceptList( SvStringsISortDtor* pList );
|
|
|
|
SvStringsISortDtor* GetWrdSttExceptList();
|
2014-02-26 11:01:45 +02:00
|
|
|
bool AddToWrdSttExceptList(const OUString& rNew);
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Save word substitutions:
|
|
|
|
// Store these directly in the storage. The word list is updated
|
|
|
|
// accordingly!
|
|
|
|
// - pure Text
|
2014-02-26 11:01:45 +02:00
|
|
|
bool PutText( const OUString& rShort, const OUString& rLong );
|
2011-02-16 16:34:02 -05:00
|
|
|
// - Text with attribution (only the SWG - SWG format!)
|
2014-02-26 11:01:45 +02:00
|
|
|
bool PutText( const OUString& rShort, SfxObjectShell& );
|
2011-02-16 16:34:02 -05:00
|
|
|
// - Deleting an entry
|
2014-02-26 11:01:45 +02:00
|
|
|
bool DeleteText( const OUString& rShort );
|
2012-09-23 21:49:45 +02:00
|
|
|
// - Make combined changes in one pass
|
2014-02-26 11:01:45 +02:00
|
|
|
bool MakeCombinedChanges( std::vector<SvxAutocorrWord>& aNewEntries, std::vector<SvxAutocorrWord>& aDeleteEntries );
|
2007-04-11 15:29:45 +00:00
|
|
|
};
|
|
|
|
|
2010-01-06 19:26:54 +01:00
|
|
|
class EDITENG_DLLPUBLIC SvxAutoCorrect
|
2007-04-11 15:29:45 +00:00
|
|
|
{
|
|
|
|
friend class SvxAutoCorrectLanguageLists;
|
|
|
|
|
2013-09-16 13:36:27 +02:00
|
|
|
OUString sShareAutoCorrFile, sUserAutoCorrFile;
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
SvxSwAutoFmtFlags aSwFlags; // StarWriter AutoFormat Flags
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// all languages in a table
|
2013-09-21 15:20:49 +02:00
|
|
|
boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists>* pLangTable;
|
|
|
|
std::map<LanguageTag, long> aLastFileTable;
|
2007-04-11 15:29:45 +00:00
|
|
|
CharClass* pCharClass;
|
|
|
|
|
2010-03-15 18:16:49 +01:00
|
|
|
bool bRunNext;
|
|
|
|
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eCharClassLang;
|
|
|
|
|
|
|
|
long nFlags;
|
|
|
|
sal_Unicode cStartDQuote, cEndDQuote, cStartSQuote, cEndSQuote,
|
|
|
|
cEmDash, cEnDash;
|
|
|
|
|
|
|
|
|
|
|
|
// private methods
|
|
|
|
SvxAutoCorrectLanguageLists& _GetLanguageList( LanguageType eLang );
|
|
|
|
|
|
|
|
void _GetCharClass( LanguageType eLang );
|
|
|
|
|
|
|
|
protected:
|
2011-02-16 16:34:02 -05:00
|
|
|
// - Text with attribution (only the SWG - SWG format!)
|
|
|
|
// rShort is the stream name - encrypted!
|
2014-02-26 11:01:45 +02:00
|
|
|
virtual bool PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg,
|
2013-09-16 14:20:18 +02:00
|
|
|
const OUString& rFileName, const OUString& rShort, SfxObjectShell&, OUString& );
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// required language in the table add if possible only when the file exists
|
2014-02-26 11:01:45 +02:00
|
|
|
bool CreateLanguageFile(const LanguageTag& rLanguageTag, bool bNewFile = true);
|
2011-02-16 16:34:02 -05:00
|
|
|
// - Return the replacement text (only for SWG format, all others can be
|
|
|
|
// taken from the word list!)
|
|
|
|
// rShort is the stream name - encrypted!
|
2007-04-11 15:29:45 +00:00
|
|
|
public:
|
2010-10-19 23:45:24 -05:00
|
|
|
|
2014-02-26 11:01:45 +02:00
|
|
|
sal_Unicode GetQuote( sal_Unicode cInsChar, bool bSttQuote,
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eLang ) const;
|
2014-10-30 14:53:48 +00:00
|
|
|
virtual bool GetLongText( const OUString& rShort, OUString& rLong );
|
|
|
|
|
|
|
|
virtual void refreshBlockList( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg);
|
2007-04-11 15:29:45 +00:00
|
|
|
|
|
|
|
TYPEINFO();
|
|
|
|
|
2013-09-16 13:36:27 +02:00
|
|
|
SvxAutoCorrect( const OUString& rShareAutocorrFile,
|
|
|
|
const OUString& rUserAutocorrFile );
|
2007-04-11 15:29:45 +00:00
|
|
|
SvxAutoCorrect( const SvxAutoCorrect& );
|
|
|
|
virtual ~SvxAutoCorrect();
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Execute an AutoCorrect.
|
|
|
|
// Returns what has been executed, according to the above flags
|
2013-06-06 20:51:05 +02:00
|
|
|
// FIXME: this has the horrible flaw that the rTxt must be a reference
|
|
|
|
// to the actual SwTxtNode/EditNode string because it inserts the character
|
|
|
|
// in rDoc and expects that to side-effect rTxt
|
2013-09-18 13:51:35 +01:00
|
|
|
sal_uLong DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
|
2014-09-23 11:20:40 +02:00
|
|
|
sal_Int32 nPos, sal_Unicode cInsChar, bool bInsert, vcl::Window* pFrameWin = NULL );
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Return for the autotext expansion the previous word,
|
|
|
|
// AutoCorrect - corresponding algorithm
|
2014-02-26 11:01:45 +02:00
|
|
|
bool GetPrevAutoCorrWord( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
|
2014-01-15 10:14:52 +00:00
|
|
|
sal_Int32 nPos, OUString& rWord ) const;
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2014-11-10 15:05:25 +01:00
|
|
|
// Search for the words in the replacement table.
|
2011-02-16 16:34:02 -05:00
|
|
|
// rText - check in this text the words of the list
|
|
|
|
// rStt - the detected starting position
|
|
|
|
// nEnd - to check position - as of this item forward
|
|
|
|
// rLang - Input: in which language is searched
|
|
|
|
// Output: in which "language list" was it found
|
2013-09-16 14:00:56 +02:00
|
|
|
const SvxAutocorrWord* SearchWordsInList( const OUString& rTxt,
|
2013-09-18 13:51:35 +01:00
|
|
|
sal_Int32& rStt, sal_Int32 nEndPos,
|
2007-04-11 15:29:45 +00:00
|
|
|
SvxAutoCorrDoc& rDoc,
|
2013-09-21 15:20:49 +02:00
|
|
|
LanguageTag& rLang );
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Query/Set the Character for the Quote substitution
|
2007-04-11 15:29:45 +00:00
|
|
|
sal_Unicode GetStartSingleQuote() const { return cStartSQuote; }
|
|
|
|
sal_Unicode GetEndSingleQuote() const { return cEndSQuote; }
|
|
|
|
sal_Unicode GetStartDoubleQuote() const { return cStartDQuote; }
|
|
|
|
sal_Unicode GetEndDoubleQuote() const { return cEndDQuote; }
|
|
|
|
|
|
|
|
void SetStartSingleQuote( const sal_Unicode cStart ) { cStartSQuote = cStart; }
|
|
|
|
void SetEndSingleQuote( const sal_Unicode cEnd ) { cEndSQuote = cEnd; }
|
|
|
|
void SetStartDoubleQuote( const sal_Unicode cStart ) { cStartDQuote = cStart; }
|
|
|
|
void SetEndDoubleQuote( const sal_Unicode cEnd ) { cEndDQuote = cEnd; }
|
|
|
|
|
2014-01-15 10:14:52 +00:00
|
|
|
OUString GetQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos,
|
2014-02-26 11:01:45 +02:00
|
|
|
sal_Unicode cInsChar, bool bSttQuote );
|
2014-01-15 10:14:52 +00:00
|
|
|
void InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos,
|
2014-02-26 11:01:45 +02:00
|
|
|
sal_Unicode cInsChar, bool bSttQuote, bool bIns );
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Query/Set the name of the AutoCorrect file
|
|
|
|
// the default is "autocorr.dat"
|
2013-09-21 15:20:49 +02:00
|
|
|
OUString GetAutoCorrFileName( const LanguageTag& rLanguageTag /* = LANGUAGE_SYSTEM */ ,
|
2014-02-26 11:01:45 +02:00
|
|
|
bool bNewFile = false,
|
2014-06-18 21:08:03 +02:00
|
|
|
bool bTstUserExist = false,
|
|
|
|
bool bUnlocalized = false ) const;
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Query/Set the current settings of AutoCorrect
|
2007-04-11 15:29:45 +00:00
|
|
|
long GetFlags() const { return nFlags; }
|
|
|
|
inline SvxSwAutoFmtFlags& GetSwFlags() { return aSwFlags;}
|
2014-02-26 11:01:45 +02:00
|
|
|
bool IsAutoCorrFlag( long nFlag ) const
|
2011-01-10 16:17:07 +01:00
|
|
|
{ return nFlags & nFlag ? sal_True : sal_False; }
|
2014-02-26 11:01:45 +02:00
|
|
|
void SetAutoCorrFlag( long nFlag, bool bOn = true );
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Load, Set, Get - the replacement list
|
2007-04-11 15:29:45 +00:00
|
|
|
SvxAutocorrWordList* LoadAutocorrWordList(
|
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM )
|
|
|
|
{ return _GetLanguageList( eLang ).LoadAutocorrWordList(); }
|
|
|
|
const SvxAutocorrWordList* GetAutocorrWordList(
|
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM )
|
|
|
|
{ return _GetLanguageList( eLang ).GetAutocorrWordList(); }
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Save word substitutions:
|
|
|
|
// Save these directly in the storage. The word list is updated
|
|
|
|
// accordingly!
|
|
|
|
// - pure Text
|
2014-02-26 11:01:45 +02:00
|
|
|
bool PutText( const OUString& rShort, const OUString& rLong, LanguageType eLang = LANGUAGE_SYSTEM );
|
2011-02-16 16:34:02 -05:00
|
|
|
// - Text with attribution (only in the SWG - SWG format!)
|
2014-02-26 11:01:45 +02:00
|
|
|
bool PutText( const OUString& rShort, SfxObjectShell& rShell,
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM )
|
|
|
|
{ return _GetLanguageList( eLang ).PutText(rShort, rShell ); }
|
|
|
|
|
2014-02-26 11:01:45 +02:00
|
|
|
bool MakeCombinedChanges( std::vector<SvxAutocorrWord>& aNewEntries,
|
2012-09-23 21:49:45 +02:00
|
|
|
std::vector<SvxAutocorrWord>& aDeleteEntries,
|
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM );
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Load, Set, Get - the exception list for capital letters at the
|
|
|
|
// beginning of a sentence
|
2007-04-11 15:29:45 +00:00
|
|
|
void SaveCplSttExceptList( LanguageType eLang = LANGUAGE_SYSTEM );
|
|
|
|
SvStringsISortDtor* LoadCplSttExceptList(
|
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM)
|
|
|
|
{ return _GetLanguageList( eLang ).LoadCplSttExceptList(); }
|
|
|
|
const SvStringsISortDtor* GetCplSttExceptList(
|
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM )
|
|
|
|
{ return _GetLanguageList( eLang ).GetCplSttExceptList(); }
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Adds a single word. The list will be immediately written to the file!
|
2014-02-26 11:01:45 +02:00
|
|
|
bool AddCplSttException( const OUString& rNew,
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM );
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Load, Set, Get the exception list for 2 Capital letters at the
|
|
|
|
// beginning of a word.
|
2007-04-11 15:29:45 +00:00
|
|
|
void SaveWrdSttExceptList( LanguageType eLang = LANGUAGE_SYSTEM );
|
|
|
|
SvStringsISortDtor* LoadWrdSttExceptList(
|
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM )
|
|
|
|
{ return _GetLanguageList( eLang ).LoadWrdSttExceptList(); }
|
|
|
|
const SvStringsISortDtor* GetWrdSttExceptList(
|
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM )
|
|
|
|
{ return _GetLanguageList( eLang ).GetWrdSttExceptList(); }
|
2011-02-16 16:34:02 -05:00
|
|
|
// Adds a single word. The list will be immediately written to the file!
|
2014-02-26 11:01:45 +02:00
|
|
|
bool AddWrtSttException( const OUString& rNew, LanguageType eLang = LANGUAGE_SYSTEM);
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Search through the Languages for the entry
|
2014-02-26 11:01:45 +02:00
|
|
|
bool FindInWrdSttExceptList( LanguageType eLang, const OUString& sWord );
|
|
|
|
bool FindInCplSttExceptList( LanguageType eLang, const OUString& sWord,
|
|
|
|
bool bAbbreviation = false);
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
// Methods for the auto-correction
|
2014-02-26 11:01:45 +02:00
|
|
|
bool FnCptlSttWrd( SvxAutoCorrDoc&, const OUString&,
|
2014-01-15 10:14:52 +00:00
|
|
|
sal_Int32 nSttPos, sal_Int32 nEndPos,
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM );
|
2014-02-26 11:01:45 +02:00
|
|
|
bool FnChgOrdinalNumber( SvxAutoCorrDoc&, const OUString&,
|
2014-01-15 10:14:52 +00:00
|
|
|
sal_Int32 nSttPos, sal_Int32 nEndPos,
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM );
|
2014-02-26 11:01:45 +02:00
|
|
|
bool FnChgToEnEmDash( SvxAutoCorrDoc&, const OUString&,
|
2014-01-15 10:14:52 +00:00
|
|
|
sal_Int32 nSttPos, sal_Int32 nEndPos,
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM );
|
2014-02-26 11:01:45 +02:00
|
|
|
bool FnAddNonBrkSpace( SvxAutoCorrDoc&, const OUString&,
|
2014-01-15 10:14:52 +00:00
|
|
|
sal_Int32 nSttPos, sal_Int32 nEndPos,
|
2009-11-16 16:49:18 +01:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM );
|
2014-02-26 11:01:45 +02:00
|
|
|
bool FnSetINetAttr( SvxAutoCorrDoc&, const OUString&,
|
2014-01-15 10:14:52 +00:00
|
|
|
sal_Int32 nSttPos, sal_Int32 nEndPos,
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM );
|
2014-02-26 11:01:45 +02:00
|
|
|
bool FnChgWeightUnderl( SvxAutoCorrDoc&, const OUString&,
|
2014-01-15 10:14:52 +00:00
|
|
|
sal_Int32 nSttPos, sal_Int32 nEndPos,
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM );
|
2014-02-26 11:01:45 +02:00
|
|
|
bool FnCptlSttSntnc( SvxAutoCorrDoc&, const OUString&, bool bNormalPos,
|
2014-01-15 10:14:52 +00:00
|
|
|
sal_Int32 nSttPos, sal_Int32 nEndPos,
|
2007-04-11 15:29:45 +00:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM);
|
2013-09-16 13:17:09 +02:00
|
|
|
bool FnCorrectCapsLock( SvxAutoCorrDoc&, const OUString&,
|
2014-01-15 10:14:52 +00:00
|
|
|
sal_Int32 nSttPos, sal_Int32 nEndPos,
|
2010-09-29 16:20:12 -04:00
|
|
|
LanguageType eLang = LANGUAGE_SYSTEM );
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2010-03-15 18:16:49 +01:00
|
|
|
bool HasRunNext() { return bRunNext; }
|
|
|
|
|
2007-04-11 15:29:45 +00:00
|
|
|
static long GetDefaultFlags();
|
|
|
|
|
2013-02-24 21:33:12 +01:00
|
|
|
// returns sal_True for characters where the function
|
2007-04-11 15:29:45 +00:00
|
|
|
// 'SvxAutoCorrect::AutoCorrect' should be called.
|
|
|
|
// (used to avoid occasional 'collisions' with (Thai) input-sequence-checking)
|
2014-02-26 11:01:45 +02:00
|
|
|
static bool IsAutoCorrectChar( sal_Unicode cChar );
|
2007-04-11 15:29:45 +00:00
|
|
|
|
2015-04-10 14:12:10 +02:00
|
|
|
static bool NeedsHardspaceAutocorr( sal_Unicode cChar );
|
2010-01-21 13:58:49 +01:00
|
|
|
|
2007-04-11 15:29:45 +00:00
|
|
|
CharClass& GetCharClass( LanguageType eLang )
|
|
|
|
{
|
|
|
|
if( !pCharClass || eLang != eCharClassLang )
|
|
|
|
_GetCharClass( eLang );
|
|
|
|
return *pCharClass;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-27 13:11:31 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|