summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sdext/source/pdfimport/inc/genericelements.hxx5
-rw-r--r--sdext/source/pdfimport/tree/drawtreevisiting.cxx20
-rw-r--r--sdext/source/pdfimport/tree/genericelements.cxx15
3 files changed, 22 insertions, 18 deletions
diff --git a/sdext/source/pdfimport/inc/genericelements.hxx b/sdext/source/pdfimport/inc/genericelements.hxx
index 1fec2e6f4042..37b448d2b613 100644
--- a/sdext/source/pdfimport/inc/genericelements.hxx
+++ b/sdext/source/pdfimport/inc/genericelements.hxx
@@ -25,12 +25,15 @@
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/i18n/BreakIterator.hpp>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <list>
+using namespace com::sun::star;
+
namespace pdfi
{
class XmlEmitter;
@@ -309,6 +312,8 @@ namespace pdfi
static std::shared_ptr<DocumentElement> createDocumentElement()
{ return std::make_shared<DocumentElement>(); }
};
+
+ bool isComplex(const uno::Reference<i18n::XBreakIterator>& rBreakIterator, TextElement* const pTextElem);
}
#endif
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
index 64aca46ce18b..b94a302a5583 100644
--- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
@@ -682,17 +682,10 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent)
if( pCur )
{
TextElement* pNext = (*next)->dynCastAsTextElement();
- bool isComplex = false;
- OUString str(pCur->Text.toString());
- for(int i=0; i< str.getLength(); i++)
- {
- sal_Int16 nType = GetBreakIterator()->getScriptType( str, i );
- if (nType == css::i18n::ScriptType::COMPLEX)
- isComplex = true;
- }
+ OUString str;
bool bPara = strspn("ParagraphElement", typeid(rParent).name());
ParagraphElement* pPara = dynamic_cast<ParagraphElement*>(&rParent);
- if (bPara && pPara && isComplex)
+ if (bPara && pPara && isComplex(GetBreakIterator(), pCur))
pPara->bRtl = true;
if( pNext )
{
@@ -756,14 +749,7 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent)
pCur->Text.append( pNext->Text );
}
- str = pCur->Text.toString();
- for(int i=0; i< str.getLength(); i++)
- {
- sal_Int16 nType = GetBreakIterator()->getScriptType( str, i );
- if (nType == css::i18n::ScriptType::COMPLEX)
- isComplex = true;
- }
- if (bPara && pPara && isComplex)
+ if (bPara && pPara && isComplex(GetBreakIterator(), pCur))
pPara->bRtl = true;
// append eventual children to current element
// and clear children (else the children just
diff --git a/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx
index 7f751e18ba5c..c3c816aecdf2 100644
--- a/sdext/source/pdfimport/tree/genericelements.cxx
+++ b/sdext/source/pdfimport/tree/genericelements.cxx
@@ -22,7 +22,8 @@
#include <pdfiprocessor.hxx>
#include <pdfihelper.hxx>
-
+#include <com/sun/star/i18n/BreakIterator.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/range/b2drange.hxx>
#include <sal/log.hxx>
@@ -430,6 +431,18 @@ void DocumentElement::visitedBy( ElementTreeVisitor& rV
rVisitor.visit(*this, rParentIt);
}
+bool isComplex(const uno::Reference<i18n::XBreakIterator>& rBreakIterator, TextElement* const pTextElem) {
+ OUString str(pTextElem->Text.toString());
+ for(int i=0; i< str.getLength(); i++)
+ {
+ sal_Int16 nType = rBreakIterator->getScriptType(str, i);
+ if (nType == i18n::ScriptType::COMPLEX)
+ {
+ return true;
+ }
+ }
+ return false;
+}
}