summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2018-05-21 15:41:52 +0200
committerEike Rathke <erack@redhat.com>2018-05-22 19:25:01 +0200
commit98908d79a4b145f3c04d98812b2207bf433fcf1b (patch)
tree40bdac737cd54e6a32e3bd4caeb285d09e5734b7 /i18npool
parent6924586821805b7a338c8e746141f51e3ba29560 (diff)
Fold BreakIterator_CTL into BreakIterator_th
The split is pointless and misleading, there are no other subclasses of BreakIterator_CTL. Change-Id: I66e66834e6e064cea29f543434a35682ee7cd35d Reviewed-on: https://gerrit.libreoffice.org/54638 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/Library_i18npool.mk1
-rw-r--r--i18npool/inc/breakiterator_ctl.hxx59
-rw-r--r--i18npool/inc/breakiterator_th.hxx29
-rw-r--r--i18npool/source/breakiterator/breakiterator_ctl.cxx132
-rw-r--r--i18npool/source/breakiterator/breakiterator_th.cxx93
5 files changed, 112 insertions, 202 deletions
diff --git a/i18npool/Library_i18npool.mk b/i18npool/Library_i18npool.mk
index be21f8b45fa5..6bbab747d462 100644
--- a/i18npool/Library_i18npool.mk
+++ b/i18npool/Library_i18npool.mk
@@ -42,7 +42,6 @@ endif
$(eval $(call gb_Library_add_exception_objects,i18npool,\
i18npool/source/breakiterator/breakiterator_cjk \
- i18npool/source/breakiterator/breakiterator_ctl \
i18npool/source/breakiterator/breakiteratorImpl \
i18npool/source/breakiterator/breakiterator_th \
i18npool/source/breakiterator/breakiterator_unicode \
diff --git a/i18npool/inc/breakiterator_ctl.hxx b/i18npool/inc/breakiterator_ctl.hxx
deleted file mode 100644
index a533b4bb7a15..000000000000
--- a/i18npool/inc/breakiterator_ctl.hxx
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * 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 .
- */
-#ifndef INCLUDED_I18NPOOL_INC_BREAKITERATOR_CTL_HXX
-#define INCLUDED_I18NPOOL_INC_BREAKITERATOR_CTL_HXX
-
-#include "breakiterator_unicode.hxx"
-#include "xdictionary.hxx"
-
-namespace i18npool {
-
-
-// class BreakIterator_CTL
-
-class BreakIterator_CTL : public BreakIterator_Unicode
-{
-public:
- BreakIterator_CTL();
- virtual ~BreakIterator_CTL() override;
- virtual sal_Int32 SAL_CALL previousCharacters(const OUString& text, sal_Int32 start,
- const css::lang::Locale& nLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 count,
- sal_Int32& nDone) override;
- virtual sal_Int32 SAL_CALL nextCharacters(const OUString& text, sal_Int32 start,
- const css::lang::Locale& rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 count,
- sal_Int32& nDone) override;
- virtual css::i18n::LineBreakResults SAL_CALL getLineBreak( const OUString& Text, sal_Int32 nStartPos,
- const css::lang::Locale& nLocale, sal_Int32 nMinBreakPos,
- const css::i18n::LineBreakHyphenationOptions& hOptions,
- const css::i18n::LineBreakUserOptions& bOptions ) override;
-protected:
- OUString cachedText; // for cell index
- sal_Int32* nextCellIndex;
- sal_Int32* previousCellIndex;
- sal_Int32 cellIndexSize;
-
- /// @throws css::uno::RuntimeException
- virtual void makeIndex(const OUString& text, sal_Int32 pos);
-};
-
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/i18npool/inc/breakiterator_th.hxx b/i18npool/inc/breakiterator_th.hxx
index 112d4327a56d..5c0119fbe919 100644
--- a/i18npool/inc/breakiterator_th.hxx
+++ b/i18npool/inc/breakiterator_th.hxx
@@ -18,25 +18,42 @@
*/
#ifndef INCLUDED_I18NPOOL_INC_BREAKITERATOR_TH_HXX
#define INCLUDED_I18NPOOL_INC_BREAKITERATOR_TH_HXX
-#include "breakiterator_ctl.hxx"
+
+#include "breakiterator_unicode.hxx"
+#include "xdictionary.hxx"
namespace i18npool {
// class BreakIterator_th
-class BreakIterator_th : public BreakIterator_CTL
+class BreakIterator_th : public BreakIterator_Unicode
{
public:
BreakIterator_th();
virtual ~BreakIterator_th() override;
-
-protected:
- void makeIndex(const OUString& text, sal_Int32 pos) override;
+ virtual sal_Int32 SAL_CALL previousCharacters(const OUString& text, sal_Int32 start,
+ const css::lang::Locale& nLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 count,
+ sal_Int32& nDone) override;
+ virtual sal_Int32 SAL_CALL nextCharacters(const OUString& text, sal_Int32 start,
+ const css::lang::Locale& rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 count,
+ sal_Int32& nDone) override;
+ virtual css::i18n::LineBreakResults SAL_CALL getLineBreak( const OUString& Text, sal_Int32 nStartPos,
+ const css::lang::Locale& nLocale, sal_Int32 nMinBreakPos,
+ const css::i18n::LineBreakHyphenationOptions& hOptions,
+ const css::i18n::LineBreakUserOptions& bOptions ) override;
+
+private:
+ OUString cachedText; // for cell index
+ sal_Int32* nextCellIndex;
+ sal_Int32* previousCellIndex;
+ sal_Int32 cellIndexSize;
+
+ void makeIndex(const OUString& text, sal_Int32 pos);
};
}
-#endif // INCLUDED_I18NPOOL_INC_BREAKITERATOR_TH_HXX
+#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/i18npool/source/breakiterator/breakiterator_ctl.cxx b/i18npool/source/breakiterator/breakiterator_ctl.cxx
deleted file mode 100644
index 932fb1b77182..000000000000
--- a/i18npool/source/breakiterator/breakiterator_ctl.cxx
+++ /dev/null
@@ -1,132 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * 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 .
- */
-
-
-#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
-#include <breakiterator_ctl.hxx>
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::i18n;
-using namespace ::com::sun::star::lang;
-
-namespace i18npool {
-
-/**
- * Constructor.
- */
-BreakIterator_CTL::BreakIterator_CTL() :
- cachedText(),
- nextCellIndex( nullptr ),
- previousCellIndex( nullptr ),
- cellIndexSize( 512 )
-{
- cBreakIterator = "com.sun.star.i18n.BreakIterator_CTL";
- // to improve performance, alloc big enough memory in construct.
- nextCellIndex = static_cast<sal_Int32*>(calloc(cellIndexSize, sizeof(sal_Int32)));
- previousCellIndex = static_cast<sal_Int32*>(calloc(cellIndexSize, sizeof(sal_Int32)));
-}
-
-/**
- * Deconstructor.
- */
-BreakIterator_CTL::~BreakIterator_CTL()
-{
- free(nextCellIndex);
- free(previousCellIndex);
-}
-
-sal_Int32 SAL_CALL BreakIterator_CTL::previousCharacters( const OUString& Text,
- sal_Int32 nStartPos, const lang::Locale& rLocale,
- sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, sal_Int32& nDone )
-{
- if (nCharacterIteratorMode == CharacterIteratorMode::SKIPCELL ) {
- nDone = 0;
- if (nStartPos > 0) { // for others to skip cell.
- makeIndex(Text, nStartPos);
-
- if (nextCellIndex[nStartPos-1] == 0) // not a CTL character
- return BreakIterator_Unicode::previousCharacters(Text, nStartPos, rLocale,
- nCharacterIteratorMode, nCount, nDone);
- else while (nCount > 0 && nextCellIndex[nStartPos - 1] > 0) {
- nCount--; nDone++;
- nStartPos = previousCellIndex[nStartPos - 1];
- }
- } else
- nStartPos = 0;
- } else { // for BS to delete one char.
- for (nDone = 0; nDone < nCount && nStartPos > 0; nDone++)
- Text.iterateCodePoints(&nStartPos, -1);
- }
-
- return nStartPos;
-}
-
-sal_Int32 SAL_CALL BreakIterator_CTL::nextCharacters(const OUString& Text,
- sal_Int32 nStartPos, const lang::Locale& rLocale,
- sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, sal_Int32& nDone)
-{
- sal_Int32 len = Text.getLength();
- if (nCharacterIteratorMode == CharacterIteratorMode::SKIPCELL ) {
- nDone = 0;
- if (nStartPos < len) {
- makeIndex(Text, nStartPos);
-
- if (nextCellIndex[nStartPos] == 0) // not a CTL character
- return BreakIterator_Unicode::nextCharacters(Text, nStartPos, rLocale,
- nCharacterIteratorMode, nCount, nDone);
- else while (nCount > 0 && nextCellIndex[nStartPos] > 0) {
- nCount--; nDone++;
- nStartPos = nextCellIndex[nStartPos];
- }
- } else
- nStartPos = len;
- } else {
- for (nDone = 0; nDone < nCount && nStartPos < Text.getLength(); nDone++)
- Text.iterateCodePoints(&nStartPos);
- }
-
- return nStartPos;
-}
-
-// This method should be overwritten by derived language specific class.
-void BreakIterator_CTL::makeIndex(const OUString& /*text*/, sal_Int32 /*pos*/)
-{
- throw RuntimeException();
-}
-
-// Make sure line is broken on cell boundary if we implement cell iterator.
-LineBreakResults SAL_CALL BreakIterator_CTL::getLineBreak(
- const OUString& Text, sal_Int32 nStartPos,
- const lang::Locale& rLocale, sal_Int32 nMinBreakPos,
- const LineBreakHyphenationOptions& hOptions,
- const LineBreakUserOptions& bOptions )
-{
- LineBreakResults lbr = BreakIterator_Unicode::getLineBreak(Text, nStartPos,
- rLocale, nMinBreakPos, hOptions, bOptions );
- if (lbr.breakIndex < Text.getLength()) {
- makeIndex(Text, lbr.breakIndex);
- lbr.breakIndex = previousCellIndex[ lbr.breakIndex ];
- }
- return lbr;
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/i18npool/source/breakiterator/breakiterator_th.cxx b/i18npool/source/breakiterator/breakiterator_th.cxx
index 49f81047247c..aa9d4e8b6ea5 100644
--- a/i18npool/source/breakiterator/breakiterator_th.cxx
+++ b/i18npool/source/breakiterator/breakiterator_th.cxx
@@ -17,28 +17,113 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+
+#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
#include <breakiterator_th.hxx>
#include <wtt.h>
#include <string.h>
#include <algorithm>
+using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::lang;
namespace i18npool {
-
-// class Breakiterator_th
-// ----------------------------------------------------;
-BreakIterator_th::BreakIterator_th()
+/**
+ * Constructor.
+ */
+BreakIterator_th::BreakIterator_th() :
+ cachedText(),
+ nextCellIndex( nullptr ),
+ previousCellIndex( nullptr ),
+ cellIndexSize( 512 )
{
cBreakIterator = "com.sun.star.i18n.BreakIterator_th";
+ // to improve performance, alloc big enough memory in construct.
+ nextCellIndex = static_cast<sal_Int32*>(calloc(cellIndexSize, sizeof(sal_Int32)));
+ previousCellIndex = static_cast<sal_Int32*>(calloc(cellIndexSize, sizeof(sal_Int32)));
lineRule=nullptr;
}
+/**
+ * Deconstructor.
+ */
BreakIterator_th::~BreakIterator_th()
{
+ free(nextCellIndex);
+ free(previousCellIndex);
+}
+
+sal_Int32 SAL_CALL BreakIterator_th::previousCharacters( const OUString& Text,
+ sal_Int32 nStartPos, const lang::Locale& rLocale,
+ sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, sal_Int32& nDone )
+{
+ if (nCharacterIteratorMode == CharacterIteratorMode::SKIPCELL ) {
+ nDone = 0;
+ if (nStartPos > 0) { // for others to skip cell.
+ makeIndex(Text, nStartPos);
+
+ if (nextCellIndex[nStartPos-1] == 0) // not a CTL character
+ return BreakIterator_Unicode::previousCharacters(Text, nStartPos, rLocale,
+ nCharacterIteratorMode, nCount, nDone);
+ else while (nCount > 0 && nextCellIndex[nStartPos - 1] > 0) {
+ nCount--; nDone++;
+ nStartPos = previousCellIndex[nStartPos - 1];
+ }
+ } else
+ nStartPos = 0;
+ } else { // for BS to delete one char.
+ for (nDone = 0; nDone < nCount && nStartPos > 0; nDone++)
+ Text.iterateCodePoints(&nStartPos, -1);
+ }
+
+ return nStartPos;
+}
+
+sal_Int32 SAL_CALL BreakIterator_th::nextCharacters(const OUString& Text,
+ sal_Int32 nStartPos, const lang::Locale& rLocale,
+ sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, sal_Int32& nDone)
+{
+ sal_Int32 len = Text.getLength();
+ if (nCharacterIteratorMode == CharacterIteratorMode::SKIPCELL ) {
+ nDone = 0;
+ if (nStartPos < len) {
+ makeIndex(Text, nStartPos);
+
+ if (nextCellIndex[nStartPos] == 0) // not a CTL character
+ return BreakIterator_Unicode::nextCharacters(Text, nStartPos, rLocale,
+ nCharacterIteratorMode, nCount, nDone);
+ else while (nCount > 0 && nextCellIndex[nStartPos] > 0) {
+ nCount--; nDone++;
+ nStartPos = nextCellIndex[nStartPos];
+ }
+ } else
+ nStartPos = len;
+ } else {
+ for (nDone = 0; nDone < nCount && nStartPos < Text.getLength(); nDone++)
+ Text.iterateCodePoints(&nStartPos);
+ }
+
+ return nStartPos;
+}
+
+// Make sure line is broken on cell boundary if we implement cell iterator.
+LineBreakResults SAL_CALL BreakIterator_th::getLineBreak(
+ const OUString& Text, sal_Int32 nStartPos,
+ const lang::Locale& rLocale, sal_Int32 nMinBreakPos,
+ const LineBreakHyphenationOptions& hOptions,
+ const LineBreakUserOptions& bOptions )
+{
+ LineBreakResults lbr = BreakIterator_Unicode::getLineBreak(Text, nStartPos,
+ rLocale, nMinBreakPos, hOptions, bOptions );
+ if (lbr.breakIndex < Text.getLength()) {
+ makeIndex(Text, lbr.breakIndex);
+ lbr.breakIndex = previousCellIndex[ lbr.breakIndex ];
+ }
+ return lbr;
}
#define SARA_AM 0x0E33