[Libreoffice-commits] core.git: sw/qa writerfilter/source

Mark Hung marklh9 at gmail.com
Fri Jun 16 13:54:52 UTC 2017


 sw/qa/extras/ooxmlexport/data/tdf85161.docx       |binary
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx     |    5 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   44 +++++++++++++++++++++-
 3 files changed, 47 insertions(+), 2 deletions(-)

New commits:
commit dfed429eaceb4ec8316b06ad18a8473ff1d34a2b
Author: Mark Hung <marklh9 at gmail.com>
Date:   Sun Jun 11 08:55:05 2017 +0800

    tdf#85161 implement ooxml SYMBOL field instruction
    
    Only font name switch (f) is implemented.
    
    Change-Id: I09df8230dff3cf0619065da69bfaf3caad0a39ae
    Reviewed-on: https://gerrit.libreoffice.org/38654
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf85161.docx b/sw/qa/extras/ooxmlexport/data/tdf85161.docx
new file mode 100755
index 000000000000..e079b4906617
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf85161.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index db20995238e3..c3b2af4bc065 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -687,6 +687,11 @@ DECLARE_OOXMLEXPORT_TEST(testOO39845, "ooo39845-7.odt")
         assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:hyperlink[1]", "anchor", "Figure4|graphic");
 }
 
+DECLARE_OOXMLEXPORT_TEST( testTdf85161, "tdf85161.docx" )
+{
+    CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
+    CPPUNIT_ASSERT_EQUAL(OUString(u'\x5e'),getParagraph(1)->getString());
+}
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 4c29c1f7cc34..4949deb0a030 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -67,6 +67,7 @@
 #include <com/sun/star/drawing/XControlShape.hpp>
 #include <com/sun/star/text/ControlCharacter.hpp>
 #include <com/sun/star/text/XTextColumns.hpp>
+#include <com/sun/star/awt/CharSet.hpp>
 
 #include <oox/mathml/import.hxx>
 #include <rtl/uri.hxx>
@@ -2937,7 +2938,7 @@ if(!bFilled)
 //            {OUString("SKIPIF"),"",                                 FIELD_SKIPIF       },
 //            {OUString("STYLEREF"),"",                               FIELD_STYLEREF     },
             {OUString("SUBJECT"),       "DocInfo.Subject",          FIELD_SUBJECT      },
-//            {OUString("SYMBOL"),"",                                FIELD_SYMBOL       },
+            {OUString("SYMBOL"),"",                                FIELD_SYMBOL       },
             {OUString("TEMPLATE"),      "TemplateName",             FIELD_TEMPLATE},
             {OUString("TIME"),          "DateTime",                 FIELD_TIME         },
             {OUString("TITLE"),         "DocInfo.Title",            FIELD_TITLE        },
@@ -3733,6 +3734,7 @@ void DomainMapper_Impl::CloseFieldCommand()
                 case FIELD_TC:
                 case FIELD_EQ:
                 case FIELD_INCLUDEPICTURE:
+                case FIELD_SYMBOL:
                         bCreateField = false;
                         break;
                 case FIELD_FORMCHECKBOX :
@@ -4239,7 +4241,45 @@ void DomainMapper_Impl::CloseFieldCommand()
                         }
                     }
                     break;
-                    case FIELD_SYMBOL       : break;
+                    case FIELD_SYMBOL:
+                    {
+                        uno::Reference< text::XTextAppend >  xTextAppend = m_aTextAppendStack.top().xTextAppend;
+                        OUString sSymbol( sal_Unicode( sFirstParam.startsWithIgnoreAsciiCase("0x") ?  sFirstParam.copy(2).toUInt32(16) : sFirstParam.toUInt32() ) );
+                        OUString sFont;
+                        bool bHasFont = lcl_FindInCommand( pContext->GetCommand(), 'f', sFont);
+                        if ( bHasFont )
+                        {
+                            sFont = sFont.trim();
+                            if (sFont.startsWith("\""))
+                                sFont = sFont.copy(1);
+                            if (sFont.endsWith("\""))
+                                sFont = sFont.copy(0,sFont.getLength()-1);
+                        }
+
+
+
+                        if (xTextAppend.is())
+                        {
+                            uno::Reference< text::XTextCursor > xCrsr = xTextAppend->getText()->createTextCursor();
+                            uno::Reference< text::XText > xText = xTextAppend->getText();
+                            if(xCrsr.is() && xText.is())
+                            {
+                                xCrsr->gotoEnd(false);
+                                xText->insertString(xCrsr, sSymbol, true);
+                                uno::Reference< beans::XPropertySet > xProp( xCrsr, uno::UNO_QUERY );
+                                xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_CHAR_SET), uno::makeAny(awt::CharSet::SYMBOL));
+                                if(bHasFont)
+                                {
+                                    uno::Any    aVal = uno::makeAny( sFont );
+                                    xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME), aVal);
+                                    xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME_ASIAN), aVal);
+                                    xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME_COMPLEX), aVal);
+
+                                }
+                            }
+                        }
+                    }
+                    break;
                     case FIELD_TEMPLATE: break;
                     case FIELD_TIME         :
                     {


More information about the Libreoffice-commits mailing list