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

Vitaliy Anderson vanderson at smartru.com
Fri Mar 31 12:04:17 UTC 2017


 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx        |    3 +
 writerfilter/source/dmapper/NumberingManager.cxx |   35 ++++++++++++++---------
 writerfilter/source/dmapper/NumberingManager.hxx |    4 ++
 writerfilter/source/dmapper/PropertyIds.cxx      |    1 
 writerfilter/source/dmapper/PropertyIds.hxx      |    1 
 5 files changed, 30 insertions(+), 14 deletions(-)

New commits:
commit df30caea7979235b5d1a6a038133dbac2ef7ecac
Author: Vitaliy Anderson <vanderson at smartru.com>
Date:   Tue Mar 21 18:31:37 2017 +0300

    tdf#106849: don't reduce quality of picture in bullet list.
    
    An image saved in cache when NS_ooxml::LN_CT_NumPicBullet_pict
    property is processed should not to be resized. It reduce quality
    the image.
    
    Just set the property "GraphicSize" of current level of the NumRule
    instead of resize the image when processing
    NS_ooxml::LN_CT_Lvl_lvlPicBulletId property.
    
    Change-Id: I8ac80643decb7794de7a295cc7c2895a5bd24e2d
    Reviewed-on: https://gerrit.libreoffice.org/35592
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 874f9f80f966..1d94e25938aa 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -350,7 +350,8 @@ DECLARE_OOXMLEXPORT_TEST(testFDO74215, "FDO74215.docx")
     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
     if (!pXmlDoc)
         return;
-    assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:7.9pt;height:7.9pt");
+    // tdf#106849 NumPicBullet xShape should not to be resized.
+    assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:6.4pt;height:6.4pt");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero,"fdo74153.docx")
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 87c30c5bd336..325cef9fd982 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -279,7 +279,10 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
         if (!m_sGraphicURL.isEmpty())
             aNumberingProperties.push_back(lcl_makePropVal(PROP_GRAPHIC_URL, m_sGraphicURL));
         if (m_sGraphicBitmap.is())
+        {
             aNumberingProperties.push_back(lcl_makePropVal(PROP_GRAPHIC_BITMAP, m_sGraphicBitmap));
+            aNumberingProperties.push_back(lcl_makePropVal(PROP_GRAPHIC_SIZE, m_aGraphicSize));
+        }
     }
 
     aNumberingProperties.push_back(lcl_makePropVal(PROP_LISTTAB_STOP_POSITION, m_nTabstop));
@@ -867,19 +870,6 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
             {
                 uno::Reference<drawing::XShape> xShape = m_rDMapper.PopPendingShape();
 
-                // Respect only the aspect ratio of the picture, not its size.
-                awt::Size aPrefSize = xShape->getSize();
-                // See SwDefBulletConfig::InitFont(), default height is 14.
-                const int nFontHeight = 14;
-                // Point -> mm100.
-                const int nHeight = nFontHeight * 35;
-                if (aPrefSize.Height * aPrefSize.Width != 0)
-                {
-                    int nWidth = (nHeight * aPrefSize.Width) / aPrefSize.Height;
-                    awt::Size aSize(nWidth, nHeight);
-                    xShape->setSize(aSize);
-                }
-
                 m_pCurrentNumPicBullet->SetShape(xShape);
             }
             break;
@@ -911,6 +901,25 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
                         m_pCurrentDefinition->GetCurrentLevel()->SetGraphicBitmap( gr );
                     } catch(const beans::UnknownPropertyException&)
                     {}
+
+                    // Respect only the aspect ratio of the picture, not its size.
+                    awt::Size aPrefSize = xShape->getSize();
+                    // See SwDefBulletConfig::InitFont(), default height is 14.
+                    const int nFontHeight = 14;
+                    // Point -> mm100.
+                    const int nHeight = nFontHeight * 35;
+                    if ( aPrefSize.Height * aPrefSize.Width != 0 )
+                    {
+                        int nWidth = (nHeight * aPrefSize.Width) / aPrefSize.Height;
+
+                        awt::Size aSize( convertMm100ToTwip(nWidth), convertMm100ToTwip(nHeight) );
+                        m_pCurrentDefinition->GetCurrentLevel()->SetGraphicSize( aSize );
+                    }
+                    else
+                    {
+                        awt::Size aSize( convertMm100ToTwip(aPrefSize.Width), convertMm100ToTwip(aPrefSize.Height) );
+                        m_pCurrentDefinition->GetCurrentLevel()->SetGraphicSize( aSize );
+                    }
                 }
             }
             break;
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index 1aec2a1e05b8..cd09b3d10f9d 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -51,6 +51,7 @@ class ListLevel : public PropertyMap
     sal_Int16                                     m_nXChFollow;      //LN_IXCHFOLLOW
     OUString                               m_sBulletChar;
     OUString                               m_sGraphicURL;
+    css::awt::Size                         m_aGraphicSize;
     css::uno::Reference<css::graphic::XGraphic> m_sGraphicBitmap;
     sal_Int32                                     m_nTabstop;
     std::shared_ptr< StyleSheetEntry >          m_pParaStyle;
@@ -77,12 +78,15 @@ public:
     void SetValue( Id nId, sal_Int32 nValue );
     void SetBulletChar( const OUString& sValue ) { m_sBulletChar = sValue; };
     void SetGraphicURL( const OUString& sValue ) { m_sGraphicURL = sValue; };
+    void SetGraphicSize( const css::awt::Size& aValue ) { m_aGraphicSize = aValue; };
+
     void SetGraphicBitmap(css::uno::Reference<css::graphic::XGraphic> const& sValue)
         { m_sGraphicBitmap = sValue; }
     void SetParaStyle( const std::shared_ptr< StyleSheetEntry >& pStyle );
 
     // Getters
     const OUString& GetBulletChar( ) { return m_sBulletChar; };
+    const css::awt::Size& GetGraphicSize( ) { return m_aGraphicSize; };
     const std::shared_ptr< StyleSheetEntry >& GetParaStyle( ) { return m_pParaStyle; };
     bool isOutlineNumbering() const { return m_outline; }
 
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index a807c47c58b2..9182ac48b3f9 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -292,6 +292,7 @@ OUString getPropertyName( PropertyIds eId )
         case PROP_IS_WIDTH_RELATIVE: sName = "IsWidthRelative"; break;
         case PROP_GRAPHIC_URL: sName = "GraphicURL"; break;
         case PROP_GRAPHIC_BITMAP: sName = "GraphicBitmap"; break;
+        case PROP_GRAPHIC_SIZE: sName = "GraphicSize"; break;
         case PROP_CHAR_SHADING_VALUE: sName = "CharShadingValue"; break;
         case PROP_CHAR_SHADING_MARKER: sName = "CharShadingMarker"; break;
         case PROP_LABEL_CATEGORY: sName = "LabelCategory"; break;
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 1a97ca5c28bb..4bf8bf84c6ce 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -289,6 +289,7 @@ enum PropertyIds
         ,PROP_IS_WIDTH_RELATIVE
         ,PROP_GRAPHIC_URL
         ,PROP_GRAPHIC_BITMAP
+        ,PROP_GRAPHIC_SIZE
         ,PROP_CHAR_SHADING_VALUE
         ,PROP_CHAR_SHADING_MARKER
         ,PROP_MIRROR_INDENTS


More information about the Libreoffice-commits mailing list