summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oox/source/drawingml/textrun.cxx95
-rw-r--r--sd/qa/unit/data/pptx/tdf106638.pptxbin0 -> 447309 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx24
3 files changed, 69 insertions, 50 deletions
diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx
index 45290aab3386..3f66c7a852e4 100644
--- a/oox/source/drawingml/textrun.cxx
+++ b/oox/source/drawingml/textrun.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/text/ControlCharacter.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/text/XTextField.hpp>
@@ -62,6 +63,11 @@ sal_Int32 TextRun::insertAt(
Reference< XTextRange > xStart = xAt;
PropertySet aPropSet( xStart );
+ Reference<XPropertyState> xState(xStart, UNO_QUERY);
+ Any aOldFontName = xState->getPropertyDefault("CharFontName");
+ Any aOldFontPitch = xState->getPropertyDefault("CharFontPitch");
+ Any aOldFontFamily = xState->getPropertyDefault("CharFontFamily");
+
TextCharacterProperties aTextCharacterProps( rTextCharacterStyle );
aTextCharacterProps.assignUsed( maTextCharacterProperties );
if ( aTextCharacterProps.moHeight.has() )
@@ -78,61 +84,50 @@ sal_Int32 TextRun::insertAt(
SAL_WARN("oox", "OOX: TextRun::insertAt() insert line break" );
xText->insertControlCharacter( xStart, ControlCharacter::LINE_BREAK, false );
}
- else
+ else if (!getText().isEmpty())
{
- OUString aSymbolFontName;
- sal_Int16 nSymbolFontFamily = 0, nSymbolFontPitch = 0;
-
- if ( !aTextCharacterProps.maSymbolFont.getFontData( aSymbolFontName, nSymbolFontPitch, nSymbolFontFamily, rFilterBase ) )
- xText->insertString( xStart, getText(), false );
- else if ( !getText().isEmpty() )
+ sal_Int32 nIndex = 0;
+ sal_Int32 nMax = getText().getLength();
+ while(true)
{
- // #i113673
- OUString aLatinFontName;
- sal_Int16 nLatinFontPitch = 0, nLatinFontFamily = 0;
- bool bLatinOk = aTextCharacterProps.maLatinFont.getFontData( aLatinFontName, nLatinFontPitch, nLatinFontFamily, rFilterBase );
+ bool bSymbol = (getText()[nIndex] & 0xff00) == 0xf000;
+ sal_Int32 nCount = 1;
+ while(nIndex + nCount < nMax
+ && ((getText()[nIndex + nCount] & 0xff00) == 0xf000) == bSymbol)
+ ++nCount;
+
+ OUString aFontName;
+ sal_Int16 nFontFamily = 0, nFontPitch = 0;
+ bool bReset = false;
+
+ // Direct formatting for symbols.
+ if (bSymbol && aTextCharacterProps.maSymbolFont.getFontData(aFontName, nFontPitch, nFontFamily, rFilterBase))
+
+ {
+ aPropSet.setAnyProperty(PROP_CharFontName, Any(aFontName));
+ aPropSet.setAnyProperty(PROP_CharFontPitch, Any(nFontPitch));
+ aPropSet.setAnyProperty(PROP_CharFontFamily, Any(nFontFamily));
+ bReset = true;
+ }
+
+ OUString aSubString(getText().copy(nIndex, nCount));
+ xText->insertString(xStart, aSubString, false);
- sal_Int32 nIndex = 0;
- while ( true )
+ aPropSet = PropertySet(xStart);
+ // Reset to whatever it was.
+ if (bReset)
{
- sal_Int32 nCount = 0;
- bool bSymbol = ( getText()[ nIndex ] & 0xff00 ) == 0xf000;
- if ( bSymbol )
- {
- do
- {
- nCount++;
- }
- while( ( ( nCount + nIndex ) < getText().getLength() ) && ( ( getText()[ nCount + nIndex ] & 0xff00 ) == 0xf000 ) );
- aPropSet.setAnyProperty( PROP_CharFontName, Any( aSymbolFontName ) );
- aPropSet.setAnyProperty( PROP_CharFontPitch, Any( nSymbolFontPitch ) );
- aPropSet.setAnyProperty( PROP_CharFontFamily, Any( nSymbolFontFamily ) );
- }
- else
- {
- do
- {
- nCount++;
- }
- while( ( ( nCount + nIndex ) < getText().getLength() ) && ( ( getText()[ nCount + nIndex ] & 0xff00 ) != 0xf000 ) );
- if (bLatinOk)
- {
- aPropSet.setAnyProperty( PROP_CharFontName, Any( aLatinFontName ) );
- aPropSet.setAnyProperty( PROP_CharFontPitch, Any( nLatinFontPitch ) );
- aPropSet.setAnyProperty( PROP_CharFontFamily, Any( nLatinFontFamily ) );
- }
- }
- OUString aSubString( getText().copy( nIndex, nCount ) );
- xText->insertString( xStart, aSubString, false );
- nIndex += nCount;
-
- if ( nIndex >= getText().getLength() )
- break;
-
- xStart = xAt;
- aPropSet = PropertySet( xStart );
- aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase );
+ aPropSet.setAnyProperty(PROP_CharFontName, aOldFontName);
+ aPropSet.setAnyProperty(PROP_CharFontPitch, aOldFontPitch);
+ aPropSet.setAnyProperty(PROP_CharFontFamily, aOldFontFamily);
}
+
+ nIndex += nCount;
+
+ if (nIndex >= nMax)
+ break;
+
+ aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase);
}
}
}
diff --git a/sd/qa/unit/data/pptx/tdf106638.pptx b/sd/qa/unit/data/pptx/tdf106638.pptx
new file mode 100644
index 000000000000..6a4d7819eee0
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf106638.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index a7f1a9a344e5..90c261c753e2 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -81,6 +81,7 @@
#include <com/sun/star/style/NumberingType.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/text/GraphicCrop.hpp>
+#include <com/sun/star/text/XTextCursor.hpp>
#include <com/sun/star/xml/dom/XDocument.hpp>
#include <stlpool.hxx>
@@ -210,6 +211,7 @@ public:
void testOOXTheme();
void testCropToShape();
void testTdf127964();
+ void testTdf106638();
CPPUNIT_TEST_SUITE(SdImportTest);
@@ -308,6 +310,7 @@ public:
CPPUNIT_TEST(testOOXTheme);
CPPUNIT_TEST(testCropToShape);
CPPUNIT_TEST(testTdf127964);
+ CPPUNIT_TEST(testTdf106638);
CPPUNIT_TEST_SUITE_END();
};
@@ -2982,6 +2985,27 @@ void SdImportTest::testTdf127964()
xDocShRef->DoClose();
}
+void SdImportTest::testTdf106638()
+{
+ sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf106638.pptx"), PPTX);
+ uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
+ uno::Reference<text::XTextRange> const xPara(getParagraphFromShape(1, xShape));
+ uno::Reference<text::XText> xText= xPara->getText();
+ uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursorByRange(xPara->getStart());
+ uno::Reference<beans::XPropertySet> xPropSet(xTextCursor, uno::UNO_QUERY_THROW );
+ OUString aCharFontName;
+ CPPUNIT_ASSERT(xTextCursor->goRight(1, true));
+ // First charcter U+f0fe that use Wingding
+ xPropSet->getPropertyValue("CharFontName") >>= aCharFontName;
+ CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), aCharFontName);
+
+ // The rest characters that do not use Wingding.
+ CPPUNIT_ASSERT(xTextCursor->goRight(45, true));
+ xPropSet->getPropertyValue("CharFontName") >>= aCharFontName;
+ CPPUNIT_ASSERT(aCharFontName != "Wingdings");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();