sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |    5 +
 sw/source/filter/ww8/docxattributeoutput.cxx |   86 +++++++++++++++++++--------
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 
 writerfilter/source/dmapper/DomainMapper.cxx |   21 ++++++
 writerfilter/source/dmapper/PropertyIds.cxx  |    3 
 writerfilter/source/dmapper/PropertyIds.hxx  |    3 
 6 files changed, 95 insertions(+), 25 deletions(-)

New commits:
commit 25dc9aaf693ba1e4aac75659f0762f5169c10f28
Author: Jacobo Aragunde Pérez <jaragu...@igalia.com>
Date:   Tue Dec 17 14:12:57 2013 +0100

    ooxml: preserve font theme color shade property
    
    Change-Id: I40fa3f172f98b319a97a855231b854651be2d784

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 9cbaaf6..e8279c0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2062,6 +2062,8 @@ DECLARE_OOXMLEXPORT_TEST(testThemePreservation, 
"theme-preservation.docx")
 
     // check theme font color value has been preserved
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeColor", "accent3");
+    OUString sThemeShade = getXPath(pXmlDocument, 
"/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeShade");
+    CPPUNIT_ASSERT_EQUAL(sThemeShade.toInt32(16), 0xbf);
 
     // check the themeFontLang values in settings file
     xmlDocPtr pXmlSettings = parseExport("word/settings.xml");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 7d32238..ff041dc 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6216,6 +6216,15 @@ void DocxAttributeOutput::CharGrabBag( const 
SfxGrabBagItem& rItem )
             m_pColorAttrList->add( FSNS( XML_w, XML_themeColor ),
                                    OUStringToOString( str, 
RTL_TEXTENCODING_UTF8 ) );
         }
+        else if ( i->first == "CharThemeColorShade" )
+        {
+            i->second >>= str;
+            if( !m_pColorAttrList )
+                m_pColorAttrList = m_pSerializer->createAttrList();
+
+            m_pColorAttrList->add( FSNS( XML_w, XML_themeShade ),
+                                   OUStringToOString( str, 
RTL_TEXTENCODING_UTF8 ) );
+        }
         else if( i->first == "CharThemeFontNameCs"   ||
                 i->first == "CharThemeFontNameAscii" ||
                 i->first == "CharThemeFontNameEastAsia" ||
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 357faa3..1ee9e2d 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3110,6 +3110,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, 
PropertyMapPtr rContext, SprmType
                     
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_ORIGINAL_COLOR, aIter->Value, 
true, CHAR_GRAB_BAG);
                 else if (aIter->Name == "themeColor")
                     m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR, 
aIter->Value, true, CHAR_GRAB_BAG);
+                else if (aIter->Name == "themeShade")
+                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_SHADE, aIter->Value, 
true, CHAR_GRAB_BAG);
             }
             if (m_pImpl->m_aInteropGrabBagName == "TempColorPropsGrabBag")
             {
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx 
b/writerfilter/source/dmapper/PropertyIds.cxx
index a38b19c..8916ff8 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -357,6 +357,7 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds 
eId ) const
             case PROP_CHAR_THEME_FONT_NAME_EAST_ASIA:   sName = 
"CharThemeFontNameEastAsia"; break;
             case PROP_CHAR_THEME_COLOR              :   sName = 
"CharThemeColor"; break;
             case PROP_CHAR_THEME_ORIGINAL_COLOR     :   sName = 
"CharThemeOriginalColor"; break;
+            case PROP_CHAR_THEME_COLOR_SHADE        :   sName = 
"CharThemeColorShade"; break;
         }
         ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
                 m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, 
sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx 
b/writerfilter/source/dmapper/PropertyIds.hxx
index e804686..8f1fa11 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -328,6 +328,7 @@ enum PropertyIds
         ,PROP_CHAR_THEME_FONT_NAME_EAST_ASIA
         ,PROP_CHAR_THEME_COLOR
         ,PROP_CHAR_THEME_ORIGINAL_COLOR
+        ,PROP_CHAR_THEME_COLOR_SHADE
     };
 struct PropertyNameSupplier_Impl;
 class PropertyNameSupplier
commit 3d126bcf1febe68919eab42c5cd2cd0d7db2f66b
Author: Jacobo Aragunde Pérez <jaragu...@igalia.com>
Date:   Tue Dec 17 13:19:16 2013 +0100

    ooxml: preserve font theme color property
    
    The property is called w:themeColor and it belongs to the w:color tag
    inside run properties.
    
    On import, the themeColor prop is stored in the character interop
    grab bag together with the val prop.
    
    On export, the current color of a text run is compared with the
    stored val prop to know if the color has been changed during the
    document edition. If it hasn't changed, the themeColor property
    must be written to the document; if it has, it must not be written to
    avoid overwriting the new color.
    
    Also added a unit test for this property.
    
    Change-Id: Icc95ee023aecc741adcba23d23206aadd6c30e1f

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 8759f61..9cbaaf6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2060,6 +2060,9 @@ DECLARE_OOXMLEXPORT_TEST(testThemePreservation, 
"theme-preservation.docx")
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "hAnsiTheme", "majorHAnsi");
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "asciiTheme", "majorHAnsi");
 
+    // check theme font color value has been preserved
+    assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeColor", "accent3");
+
     // check the themeFontLang values in settings file
     xmlDocPtr pXmlSettings = parseExport("word/settings.xml");
     if (!pXmlSettings)
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8e5ebbb..7d32238 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1234,6 +1234,14 @@ void DocxAttributeOutput::WriteCollectedRunProperties()
         m_pSerializer->singleElementNS( XML_w, XML_rFonts, xAttrList );
     }
 
+    if ( m_pColorAttrList )
+    {
+        XFastAttributeListRef xAttrList( m_pColorAttrList );
+        m_pColorAttrList = NULL;
+
+        m_pSerializer->singleElementNS( XML_w, XML_color, xAttrList );
+    }
+
     if ( m_pEastAsianLayoutAttrList )
     {
         XFastAttributeListRef xAttrList( m_pEastAsianLayoutAttrList );
@@ -3490,6 +3498,7 @@ void DocxAttributeOutput::WriteOutliner(const 
OutlinerParaObject& rParaObj)
             // Write run properties.
             m_pSerializer->startElementNS(XML_w, XML_rPr, FSEND);
             aAttrIter.OutAttr(nAktPos);
+            WriteCollectedRunProperties();
             m_pSerializer->endElementNS(XML_w, XML_rPr);
 
             bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
@@ -4342,8 +4351,10 @@ void DocxAttributeOutput::CharColor( const SvxColorItem& 
rColor )
 
     aColorString = msfilter::util::ConvertColor( aColor );
 
-    m_pSerializer->singleElementNS( XML_w, XML_color,
-            FSNS( XML_w, XML_val ), aColorString.getStr(), FSEND );
+    if( !m_pColorAttrList )
+        m_pColorAttrList = m_pSerializer->createAttrList();
+
+    m_pColorAttrList->add( FSNS( XML_w, XML_val ), aColorString.getStr() );
 }
 
 void DocxAttributeOutput::CharContour( const SvxContourItem& rContour )
@@ -6128,6 +6139,7 @@ void DocxAttributeOutput::CharGrabBag( const 
SfxGrabBagItem& rItem )
     sal_Bool bWriteCSTheme = sal_True;
     sal_Bool bWriteAsciiTheme = sal_True;
     sal_Bool bWriteEastAsiaTheme = sal_True;
+    sal_Bool bWriteThemeFontColor = sal_True;
     OUString sOriginalValue;
     for ( std::map< OUString, com::sun::star::uno::Any >::const_iterator i = 
rMap.begin(); i != rMap.end(); i++ )
     {
@@ -6149,6 +6161,12 @@ void DocxAttributeOutput::CharGrabBag( const 
SfxGrabBagItem& rItem )
                 bWriteEastAsiaTheme =
                         ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, 
XML_eastAsia ) ) == sOriginalValue );
         }
+        else if ( m_pColorAttrList && i->first == "CharThemeOriginalColor" )
+        {
+            if ( i->second >>= sOriginalValue )
+                bWriteThemeFontColor =
+                        ( m_pColorAttrList->getOptionalValue( FSNS( XML_w, 
XML_val ) ) == sOriginalValue );
+        }
     }
 
     // save theme attributes back to the run properties
@@ -6189,9 +6207,19 @@ void DocxAttributeOutput::CharGrabBag( const 
SfxGrabBagItem& rItem )
             m_pFontsAttrList->add( FSNS( XML_w, XML_hAnsiTheme ),
                                    OUStringToOString( str, 
RTL_TEXTENCODING_UTF8 ) );
         }
+        else if ( i->first == "CharThemeColor" && bWriteThemeFontColor )
+        {
+            i->second >>= str;
+            if( !m_pColorAttrList )
+                m_pColorAttrList = m_pSerializer->createAttrList();
+
+            m_pColorAttrList->add( FSNS( XML_w, XML_themeColor ),
+                                   OUStringToOString( str, 
RTL_TEXTENCODING_UTF8 ) );
+        }
         else if( i->first == "CharThemeFontNameCs"   ||
                 i->first == "CharThemeFontNameAscii" ||
-                i->first == "CharThemeFontNameEastAsia" )
+                i->first == "CharThemeFontNameEastAsia" ||
+                i->first == "CharThemeOriginalColor" )
         {
             // just skip these, they were processed before
         }
@@ -6214,6 +6242,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport 
&rExport, FSHelperPtr pSeri
       m_pFlyFillAttrList( NULL ),
       m_pFlyWrapAttrList( NULL ),
       m_pTextboxAttrList( NULL ),
+      m_pColorAttrList( NULL ),
       m_pFlyFrameSize(0),
       m_pFootnotesList( new ::docx::FootnotesList() ),
       m_pEndnotesList( new ::docx::FootnotesList() ),
@@ -6269,6 +6298,7 @@ DocxAttributeOutput::~DocxAttributeOutput()
     delete m_pHyperlinkAttrList, m_pHyperlinkAttrList = NULL;
     delete m_pFlyAttrList, m_pFlyAttrList = NULL;
     delete m_pTextboxAttrList, m_pTextboxAttrList = NULL;
+    delete m_pColorAttrList, m_pColorAttrList = NULL;
 
     delete m_pFootnotesList, m_pFootnotesList = NULL;
     delete m_pEndnotesList, m_pEndnotesList = NULL;
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 08ff82c..99bb35c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -682,6 +682,8 @@ private:
     ::sax_fastparser::FastAttributeList *m_pFlyWrapAttrList;
     /// Attributes of the next v:textbox element.
     ::sax_fastparser::FastAttributeList *m_pTextboxAttrList;
+    /// Attributes of the run color
+    ::sax_fastparser::FastAttributeList *m_pColorAttrList;
     /// When exporting fly frames, this holds the real size of the frame.
     const Size* m_pFlyFrameSize;
 
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 06efbf7..357faa3 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3091,6 +3091,9 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, 
PropertyMapPtr rContext, SprmType
     case NS_ooxml::LN_CT_PPrBase_numPr:
         if (nSprmId == NS_ooxml::LN_CT_PPr_sectPr)
             m_pImpl->SetParaSectpr(true);
+        else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color && 
m_pImpl->m_aInteropGrabBagName.isEmpty())
+            // if DomainMapper grab bag is not enabled, enable it temporarilly
+            m_pImpl->m_aInteropGrabBagName = OUString 
("TempColorPropsGrabBag");
         resolveSprmProps(*this, rSprm);
         if (nSprmId == NS_ooxml::LN_CT_PPrBase_spacing)
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "spacing", 
m_pImpl->m_aSubInteropGrabBag);
@@ -3099,7 +3102,23 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, 
PropertyMapPtr rContext, SprmType
         else if (nSprmId == NS_ooxml::LN_EG_RPrBase_lang)
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lang", 
m_pImpl->m_aSubInteropGrabBag);
         else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color)
+        {
+            std::vector<beans::PropertyValue>::iterator aIter = 
m_pImpl->m_aSubInteropGrabBag.begin();
+            for (; aIter != m_pImpl->m_aSubInteropGrabBag.end(); ++aIter)
+            {
+                if (aIter->Name == "val")
+                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_ORIGINAL_COLOR, aIter->Value, 
true, CHAR_GRAB_BAG);
+                else if (aIter->Name == "themeColor")
+                    m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR, 
aIter->Value, true, CHAR_GRAB_BAG);
+            }
+            if (m_pImpl->m_aInteropGrabBagName == "TempColorPropsGrabBag")
+            {
+                //disable and clear DomainMapper grab bag if it wasn't enabled 
before
+                m_pImpl->m_aInteropGrabBagName = OUString();
+                m_pImpl->m_aSubInteropGrabBag.clear();
+            }
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "color", 
m_pImpl->m_aSubInteropGrabBag);
+        }
         else if (nSprmId == NS_ooxml::LN_CT_PPrBase_ind)
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ind", 
m_pImpl->m_aSubInteropGrabBag);
     break;
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx 
b/writerfilter/source/dmapper/PropertyIds.cxx
index 09d8710..a38b19c 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -355,6 +355,8 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds 
eId ) const
             case PROP_CHAR_THEME_FONT_NAME_CS       :   sName = 
"CharThemeFontNameCs"; break;
             case PROP_CHAR_THEME_FONT_NAME_H_ANSI   :   sName = 
"CharThemeFontNameHAnsi"; break;
             case PROP_CHAR_THEME_FONT_NAME_EAST_ASIA:   sName = 
"CharThemeFontNameEastAsia"; break;
+            case PROP_CHAR_THEME_COLOR              :   sName = 
"CharThemeColor"; break;
+            case PROP_CHAR_THEME_ORIGINAL_COLOR     :   sName = 
"CharThemeOriginalColor"; break;
         }
         ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
                 m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, 
sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx 
b/writerfilter/source/dmapper/PropertyIds.hxx
index 55b8a48..e804686 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -326,6 +326,8 @@ enum PropertyIds
         ,PROP_CHAR_THEME_FONT_NAME_CS
         ,PROP_CHAR_THEME_FONT_NAME_H_ANSI
         ,PROP_CHAR_THEME_FONT_NAME_EAST_ASIA
+        ,PROP_CHAR_THEME_COLOR
+        ,PROP_CHAR_THEME_ORIGINAL_COLOR
     };
 struct PropertyNameSupplier_Impl;
 class PropertyNameSupplier
commit 79aecccf048f98a187065fdfabbc911b0e499cdc
Author: Jacobo Aragunde Pérez <jaragu...@igalia.com>
Date:   Tue Dec 17 13:18:40 2013 +0100

    sw: Small code rewrite
    
    The purpose is improve legibility of future patches
    
    Change-Id: I15bcfdc74feab25cf3ce4dcf246969f3d9f152d2

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index f113f39..8e5ebbb 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6124,33 +6124,30 @@ void DocxAttributeOutput::CharGrabBag( const 
SfxGrabBagItem& rItem )
 {
     const std::map< OUString, com::sun::star::uno::Any >& rMap = 
rItem.GetGrabBag();
 
-    // get original font names and check if they have changed during the 
edition
+    // get original values of theme-derived properties to check if they have 
changed during the edition
     sal_Bool bWriteCSTheme = sal_True;
     sal_Bool bWriteAsciiTheme = sal_True;
     sal_Bool bWriteEastAsiaTheme = sal_True;
-    if ( m_pFontsAttrList )
+    OUString sOriginalValue;
+    for ( std::map< OUString, com::sun::star::uno::Any >::const_iterator i = 
rMap.begin(); i != rMap.end(); i++ )
     {
-        OUString sFontName;
-        for ( std::map< OUString, com::sun::star::uno::Any >::const_iterator i 
= rMap.begin(); i != rMap.end(); ++i )
+        if ( m_pFontsAttrList && i->first == "CharThemeFontNameCs" )
         {
-            if ( i->first == "CharThemeFontNameCs" )
-            {
-                if ( i->second >>= sFontName )
-                    bWriteCSTheme =
-                            ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, 
XML_cs ) ) == sFontName );
-            }
-            else if ( i->first == "CharThemeFontNameAscii" )
-            {
-                if ( i->second >>= sFontName )
-                    bWriteAsciiTheme =
-                            ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, 
XML_ascii ) ) == sFontName );
-            }
-            else if ( i->first == "CharThemeFontNameEastAsia" )
-            {
-                if ( i->second >>= sFontName )
-                    bWriteEastAsiaTheme =
-                            ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, 
XML_eastAsia ) ) == sFontName );
-            }
+            if ( i->second >>= sOriginalValue )
+                bWriteCSTheme =
+                        ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, 
XML_cs ) ) == sOriginalValue );
+        }
+        else if ( m_pFontsAttrList && i->first == "CharThemeFontNameAscii" )
+        {
+            if ( i->second >>= sOriginalValue )
+                bWriteAsciiTheme =
+                        ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, 
XML_ascii ) ) == sOriginalValue );
+        }
+        else if ( m_pFontsAttrList && i->first == "CharThemeFontNameEastAsia" )
+        {
+            if ( i->second >>= sOriginalValue )
+                bWriteEastAsiaTheme =
+                        ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, 
XML_eastAsia ) ) == sOriginalValue );
         }
     }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to