LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/writerfilter/source/dmapper - GraphicImport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 353 728 48.5 %
Date: 2013-07-09 Functions: 23 47 48.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <string.h>
      21             : 
      22             : #include <com/sun/star/awt/Size.hpp>
      23             : #include <com/sun/star/container/XNamed.hpp>
      24             : #include <com/sun/star/drawing/ColorMode.hpp>
      25             : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
      26             : #include <com/sun/star/drawing/XShape.hpp>
      27             : #include <com/sun/star/graphic/XGraphic.hpp>
      28             : #include <com/sun/star/graphic/GraphicProvider.hpp>
      29             : #include <com/sun/star/graphic/XGraphicProvider.hpp>
      30             : #include <com/sun/star/io/XInputStream.hpp>
      31             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      32             : #include <com/sun/star/table/BorderLine2.hpp>
      33             : #include <com/sun/star/text/GraphicCrop.hpp>
      34             : #include <com/sun/star/text/HoriOrientation.hpp>
      35             : #include <com/sun/star/text/RelOrientation.hpp>
      36             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      37             : #include <com/sun/star/text/VertOrientation.hpp>
      38             : #include <com/sun/star/text/WrapTextMode.hpp>
      39             : #include <com/sun/star/text/XTextContent.hpp>
      40             : #include <com/sun/star/uno/XComponentContext.hpp>
      41             : #include <com/sun/star/table/ShadowFormat.hpp>
      42             : 
      43             : #include <cppuhelper/implbase1.hxx>
      44             : #include <rtl/ustrbuf.hxx>
      45             : 
      46             : #include <dmapper/DomainMapper.hxx>
      47             : #include <doctok/resourceids.hxx>
      48             : #include <ooxml/resourceids.hxx>
      49             : #include <resourcemodel/ResourceModelHelper.hxx>
      50             : 
      51             : #include "ConversionHelper.hxx"
      52             : #include "GraphicHelpers.hxx"
      53             : #include "GraphicImport.hxx"
      54             : #include "PropertyMap.hxx"
      55             : #include "WrapPolygonHandler.hxx"
      56             : #include "dmapperLoggers.hxx"
      57             : 
      58             : namespace writerfilter {
      59             : 
      60             : using resourcemodel::resolveSprmProps;
      61             : 
      62             : namespace dmapper
      63             : {
      64             : using namespace ::std;
      65             : using namespace ::com::sun::star;
      66             : 
      67             : class XInputStreamHelper : public cppu::WeakImplHelper1
      68             : <    io::XInputStream   >
      69             : {
      70             :     const sal_uInt8* m_pBuffer;
      71             :     const sal_Int32  m_nLength;
      72             :     sal_Int32        m_nPosition;
      73             :     bool             m_bBmp;
      74             : 
      75             :     const sal_uInt8* m_pBMPHeader; //default BMP-header
      76             :     sal_Int32        m_nHeaderLength;
      77             : public:
      78             :     XInputStreamHelper(const sal_uInt8* buf, size_t len, bool bBmp);
      79             :     ~XInputStreamHelper();
      80             : 
      81             :     virtual ::sal_Int32 SAL_CALL readBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException);
      82             :     virtual ::sal_Int32 SAL_CALL readSomeBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException);
      83             :     virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException);
      84             :     virtual ::sal_Int32 SAL_CALL available(  ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException);
      85             :     virtual void SAL_CALL closeInput(  ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException);
      86             : };
      87             : 
      88             : 
      89           0 : XInputStreamHelper::XInputStreamHelper(const sal_uInt8* buf, size_t len, bool bBmp) :
      90             :         m_pBuffer( buf ),
      91             :         m_nLength( len ),
      92             :         m_nPosition( 0 ),
      93           0 :         m_bBmp( bBmp )
      94             : {
      95             :     static const sal_uInt8 aHeader[] =
      96             :         {0x42, 0x4d, 0xe6, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
      97           0 :     m_pBMPHeader = aHeader;
      98           0 :     m_nHeaderLength = m_bBmp ? sizeof( aHeader ) / sizeof(sal_uInt8) : 0;
      99             : 
     100           0 : }
     101             : 
     102             : 
     103           0 : XInputStreamHelper::~XInputStreamHelper()
     104             : {
     105           0 : }
     106             : 
     107             : 
     108           0 : ::sal_Int32 XInputStreamHelper::readBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead )
     109             :     throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
     110             : {
     111           0 :     return readSomeBytes( aData, nBytesToRead );
     112             : }
     113             : 
     114             : 
     115           0 : ::sal_Int32 XInputStreamHelper::readSomeBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead )
     116             :         throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
     117             : {
     118           0 :     sal_Int32 nRet = 0;
     119           0 :     if( nMaxBytesToRead > 0 )
     120             :     {
     121           0 :         if( nMaxBytesToRead > (m_nLength + m_nHeaderLength) - m_nPosition )
     122           0 :             nRet = (m_nLength + m_nHeaderLength) - m_nPosition;
     123             :         else
     124           0 :             nRet = nMaxBytesToRead;
     125           0 :         aData.realloc( nRet );
     126           0 :         sal_Int8* pData = aData.getArray();
     127           0 :         sal_Int32 nHeaderRead = 0;
     128           0 :         if( m_nPosition < m_nHeaderLength)
     129             :         {
     130             :             //copy header content first
     131           0 :             nHeaderRead = m_nHeaderLength - m_nPosition;
     132           0 :             memcpy( pData, m_pBMPHeader + (m_nPosition ), nHeaderRead );
     133           0 :             nRet -= nHeaderRead;
     134           0 :             m_nPosition += nHeaderRead;
     135             :         }
     136           0 :         if( nRet )
     137             :         {
     138           0 :             memcpy( pData + nHeaderRead, m_pBuffer + (m_nPosition - m_nHeaderLength), nRet );
     139           0 :             m_nPosition += nRet;
     140             :         }
     141             :     }
     142           0 :     return nRet;
     143             : }
     144             : 
     145             : 
     146           0 : void XInputStreamHelper::skipBytes( ::sal_Int32 nBytesToSkip ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
     147             : {
     148           0 :     if( nBytesToSkip < 0 || m_nPosition + nBytesToSkip > (m_nLength + m_nHeaderLength))
     149           0 :         throw io::BufferSizeExceededException();
     150           0 :     m_nPosition += nBytesToSkip;
     151           0 : }
     152             : 
     153             : 
     154           0 : ::sal_Int32 XInputStreamHelper::available(  ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException)
     155             : {
     156           0 :     return ( m_nLength + m_nHeaderLength ) - m_nPosition;
     157             : }
     158             : 
     159             : 
     160           0 : void XInputStreamHelper::closeInput(  ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException)
     161             : {
     162           0 : }
     163             : 
     164             : 
     165             : struct GraphicBorderLine
     166             : {
     167             :     sal_Int32   nLineWidth;
     168             :     sal_Int32   nLineColor;
     169             :     sal_Int32   nLineDistance;
     170             :     bool        bHasShadow;
     171             : 
     172         112 :     GraphicBorderLine() :
     173             :         nLineWidth(0)
     174             :         ,nLineColor(0)
     175             :         ,nLineDistance(0)
     176         112 :         ,bHasShadow(false)
     177         112 :         {}
     178             : 
     179             : };
     180             : 
     181          28 : class GraphicImport_Impl
     182             : {
     183             : private:
     184             :     sal_Int32 nXSize;
     185             :     bool      bXSizeValid;
     186             :     sal_Int32 nYSize;
     187             :     bool      bYSizeValid;
     188             : 
     189             : public:
     190             :     GraphicImportType eGraphicImportType;
     191             :     DomainMapper&   rDomainMapper;
     192             : 
     193             :     sal_Int32 nHoriScaling;
     194             :     sal_Int32 nVertScaling;
     195             :     sal_Int32 nLeftPosition;
     196             :     sal_Int32 nTopPosition;
     197             :     sal_Int32 nRightPosition;
     198             :     sal_Int32 nBottomPosition;
     199             :     sal_Int32 nLeftCrop;
     200             :     sal_Int32 nTopCrop;
     201             :     sal_Int32 nRightCrop;
     202             :     sal_Int32 nBottomCrop;
     203             : 
     204             :     bool      bUseSimplePos;
     205             :     sal_Int32 zOrder;
     206             : 
     207             :     sal_Int16 nHoriOrient;
     208             :     sal_Int16 nHoriRelation;
     209             :     bool      bPageToggle;
     210             :     sal_Int16 nVertOrient;
     211             :     sal_Int16 nVertRelation;
     212             :     sal_Int32 nWrap;
     213             :     bool      bOpaque;
     214             :     bool      bContour;
     215             :     bool      bContourOutside;
     216             :     WrapPolygon::Pointer_t mpWrapPolygon;
     217             :     bool      bIgnoreWRK;
     218             : 
     219             :     sal_Int32 nLeftMargin;
     220             :     sal_Int32 nRightMargin;
     221             :     sal_Int32 nTopMargin;
     222             :     sal_Int32 nBottomMargin;
     223             : 
     224             :     bool bShadow;
     225             :     sal_Int32 nShadowXDistance;
     226             :     sal_Int32 nShadowYDistance;
     227             :     sal_Int32 nShadowColor;
     228             :     sal_Int32 nShadowTransparence;
     229             : 
     230             :     sal_Int32 nContrast;
     231             :     sal_Int32 nBrightness;
     232             :     double    fGamma;
     233             : 
     234             :     sal_Int32 nFillColor;
     235             : 
     236             :     drawing::ColorMode eColorMode;
     237             : 
     238             :     GraphicBorderLine   aBorders[4];
     239             :     sal_Int32           nCurrentBorderLine;
     240             : 
     241             :     sal_Int32       nDffType;
     242             :     bool            bIsGraphic;
     243             :     bool            bIsBitmap;
     244             :     bool            bIsTiff;
     245             :     sal_Int32       nBitsPerPixel;
     246             : 
     247             :     bool            bHoriFlip;
     248             :     bool            bVertFlip;
     249             : 
     250             :     bool            bSizeProtected;
     251             :     bool            bPositionProtected;
     252             : 
     253             :     bool            bInShapeOptionMode;
     254             :     sal_Int32       nShapeOptionType;
     255             : 
     256             :     OUString sName;
     257             :     OUString sAlternativeText;
     258             :     OUString title;
     259             : 
     260          28 :     GraphicImport_Impl(GraphicImportType eImportType, DomainMapper&   rDMapper) :
     261             :         nXSize(0)
     262             :         ,bXSizeValid(false)
     263             :         ,nYSize(0)
     264             :         ,bYSizeValid(false)
     265             :         ,eGraphicImportType( eImportType )
     266             :         ,rDomainMapper( rDMapper )
     267             :         ,nHoriScaling(0)
     268             :         ,nVertScaling(0)
     269             :         ,nLeftPosition(0)
     270             :         ,nTopPosition(0)
     271             :         ,nRightPosition(0)
     272             :         ,nBottomPosition(0)
     273             :         ,nLeftCrop(0)
     274             :         ,nTopCrop (0)
     275             :         ,nRightCrop (0)
     276             :         ,nBottomCrop(0)
     277             :         ,bUseSimplePos(false)
     278             :         ,zOrder(-1)
     279             :         ,nHoriOrient(   text::HoriOrientation::NONE )
     280             :         ,nHoriRelation( text::RelOrientation::FRAME )
     281             :         ,bPageToggle( false )
     282             :         ,nVertOrient(  text::VertOrientation::NONE )
     283             :         ,nVertRelation( text::RelOrientation::FRAME )
     284             :         ,nWrap(0)
     285             :         ,bOpaque( true )
     286             :         ,bContour(false)
     287             :         ,bContourOutside(true)
     288             :         ,bIgnoreWRK(true)
     289             :         ,nLeftMargin(319)
     290             :         ,nRightMargin(319)
     291             :         ,nTopMargin(0)
     292             :         ,nBottomMargin(0)
     293             :         ,bShadow(false)
     294             :         ,nShadowXDistance(0)
     295             :         ,nShadowYDistance(0)
     296             :         ,nShadowColor(0)
     297             :         ,nShadowTransparence(0)
     298             :         ,nContrast(0)
     299             :         ,nBrightness(0)
     300             :         ,fGamma( -1.0 )
     301             :         ,nFillColor( 0xffffffff )
     302             :         ,eColorMode( drawing::ColorMode_STANDARD )
     303             :         ,nCurrentBorderLine(BORDER_TOP)
     304             :         ,nDffType( 0 )
     305             :         ,bIsGraphic(false)
     306             :         ,bIsBitmap(false)
     307             :         ,bIsTiff(false)
     308             :         ,nBitsPerPixel(0)
     309             :         ,bHoriFlip(false)
     310             :         ,bVertFlip(false)
     311             :         ,bSizeProtected(false)
     312             :         ,bPositionProtected(false)
     313          28 :         ,bInShapeOptionMode(false)
     314          28 :         {}
     315             : 
     316          28 :     void setXSize(sal_Int32 _nXSize)
     317             :     {
     318          28 :         nXSize = _nXSize;
     319          28 :         bXSizeValid = true;
     320          28 :     }
     321             : 
     322          54 :     sal_uInt32 getXSize() const
     323             :     {
     324          54 :         return nXSize;
     325             :     }
     326             : 
     327           2 :     bool isXSizeValid() const
     328             :     {
     329           2 :         return bXSizeValid;
     330             :     }
     331             : 
     332          28 :     void setYSize(sal_Int32 _nYSize)
     333             :     {
     334          28 :         nYSize = _nYSize;
     335          28 :         bYSizeValid = true;
     336          28 :     }
     337             : 
     338          54 :     sal_uInt32 getYSize() const
     339             :     {
     340          54 :         return nYSize;
     341             :     }
     342             : 
     343           2 :     bool isYSizeValis () const
     344             :     {
     345           2 :         return bYSizeValid;
     346             :     }
     347             : 
     348          35 :     void applyMargins(uno::Reference< beans::XPropertySet > xGraphicObjectProperties) const
     349             :     {
     350          35 :         PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
     351          35 :         xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_LEFT_MARGIN ), uno::makeAny(nLeftMargin));
     352          35 :         xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_RIGHT_MARGIN ), uno::makeAny(nRightMargin));
     353          35 :         xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_TOP_MARGIN ), uno::makeAny(nTopMargin));
     354          35 :         xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_BOTTOM_MARGIN ), uno::makeAny(nBottomMargin));
     355          35 :     }
     356             : };
     357             : 
     358             : 
     359          28 : GraphicImport::GraphicImport(uno::Reference < uno::XComponentContext >    xComponentContext,
     360             :                              uno::Reference< lang::XMultiServiceFactory > xTextFactory,
     361             :                              DomainMapper& rDMapper,
     362             :                              GraphicImportType eImportType )
     363             : : LoggedProperties(dmapper_logger, "GraphicImport")
     364             : , LoggedTable(dmapper_logger, "GraphicImport")
     365             : , LoggedStream(dmapper_logger, "GraphicImport")
     366          28 : , m_pImpl( new GraphicImport_Impl( eImportType, rDMapper ))
     367             : , m_xComponentContext( xComponentContext )
     368          56 : , m_xTextFactory( xTextFactory)
     369             : {
     370          28 : }
     371             : 
     372             : 
     373          84 : GraphicImport::~GraphicImport()
     374             : {
     375          28 :     delete m_pImpl;
     376          56 : }
     377             : 
     378           4 : void GraphicImport::handleWrapTextValue(sal_uInt32 nVal)
     379             : {
     380           4 :     switch (nVal)
     381             :     {
     382             :     case NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_bothSides: // 90920;
     383           0 :         m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
     384           0 :         break;
     385             :     case NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_left: // 90921;
     386           0 :         m_pImpl->nWrap = text::WrapTextMode_LEFT;
     387           0 :         break;
     388             :     case NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_right: // 90922;
     389           0 :         m_pImpl->nWrap = text::WrapTextMode_RIGHT;
     390           0 :         break;
     391             :     case NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_largest: // 90923;
     392           4 :         m_pImpl->nWrap = text::WrapTextMode_DYNAMIC;
     393           4 :         break;
     394             :     default:;
     395             :     }
     396           4 : }
     397             : 
     398             : 
     399             : 
     400         274 : void GraphicImport::lcl_attribute(Id nName, Value & val)
     401             : {
     402         274 :     sal_Int32 nIntValue = val.getInt();
     403         274 :     switch( nName )
     404             :     {
     405           0 :         case NS_rtf::LN_LCB: break;//byte count
     406           0 :         case NS_rtf::LN_CBHEADER: break;//ignored
     407             :         case NS_rtf::LN_MFP: //MetafilePict
     408             :         case NS_rtf::LN_DffRecord: //dff record - expands to an sprm which expands to ...
     409             :         case NS_rtf::LN_shpopt: //shape options
     410             :         case NS_rtf::LN_shpfbse: //BLIP store entry
     411             :         case NS_rtf::LN_BRCTOP: //top border
     412             :         case NS_rtf::LN_BRCLEFT: //left border
     413             :         case NS_rtf::LN_BRCBOTTOM: //bottom border
     414             :         case NS_rtf::LN_BRCRIGHT: //right border
     415             :         case NS_rtf::LN_shape: //shape
     416             :         case NS_rtf::LN_blip: //the binary graphic data in a shape
     417             :             {
     418           0 :                 switch(nName)
     419             :                 {
     420             :                     case NS_rtf::LN_BRCTOP: //top border
     421           0 :                         m_pImpl->nCurrentBorderLine = BORDER_TOP;
     422           0 :                     break;
     423             :                     case NS_rtf::LN_BRCLEFT: //left border
     424           0 :                         m_pImpl->nCurrentBorderLine = BORDER_LEFT;
     425           0 :                     break;
     426             :                     case NS_rtf::LN_BRCBOTTOM: //bottom border
     427           0 :                         m_pImpl->nCurrentBorderLine = BORDER_BOTTOM;
     428           0 :                     break;
     429             :                     case NS_rtf::LN_BRCRIGHT: //right border
     430           0 :                         m_pImpl->nCurrentBorderLine = BORDER_RIGHT;
     431           0 :                     break;
     432             :                     case NS_rtf::LN_shpopt:
     433           0 :                         m_pImpl->bInShapeOptionMode = true;
     434           0 :                     break;
     435             :                     default:;
     436             :                 }
     437           0 :             writerfilter::Reference<Properties>::Pointer_t pProperties = val.getProperties();
     438           0 :             if( pProperties.get())
     439             :             {
     440           0 :                 pProperties->resolve(*this);
     441             :             }
     442           0 :                 switch(nName)
     443             :                 {
     444             :                     case NS_rtf::LN_shpopt:
     445           0 :                         m_pImpl->bInShapeOptionMode = false;
     446           0 :                     break;
     447             :                     default:;
     448           0 :                 }
     449             :         }
     450           0 :         break;
     451             :         case NS_rtf::LN_payload :
     452             :         {
     453           0 :             writerfilter::Reference<BinaryObj>::Pointer_t pPictureData = val.getBinary();
     454           0 :             if( pPictureData.get())
     455           0 :                 pPictureData->resolve(*this);
     456             :         }
     457           0 :         break;
     458             :         case NS_rtf::LN_BM_RCWINMF: //windows bitmap structure - if it's a bitmap
     459           0 :         break;
     460             :         case NS_rtf::LN_DXAGOAL: //x-size in twip
     461             :         case NS_rtf::LN_DYAGOAL: //y-size in twip
     462           0 :             break;
     463             :         case NS_rtf::LN_MX:
     464           0 :             m_pImpl->nHoriScaling = nIntValue;
     465           0 :             break;// hori scaling in 0.001%
     466             :         case NS_rtf::LN_MY:
     467           0 :             m_pImpl->nVertScaling = nIntValue;
     468           0 :             break;// vert scaling in 0.001%
     469             :         case NS_rtf::LN_DXACROPLEFT:
     470           0 :             m_pImpl->nLeftCrop  = ConversionHelper::convertTwipToMM100(nIntValue);
     471           0 :             break;// left crop in twips
     472             :         case NS_rtf::LN_DYACROPTOP:
     473           0 :             m_pImpl->nTopCrop   = ConversionHelper::convertTwipToMM100(nIntValue);
     474           0 :             break;// top crop in twips
     475             :         case NS_rtf::LN_DXACROPRIGHT:
     476           0 :             m_pImpl->nRightCrop = ConversionHelper::convertTwipToMM100(nIntValue);
     477           0 :             break;// right crop in twips
     478             :         case NS_rtf::LN_DYACROPBOTTOM:
     479           0 :             m_pImpl->nBottomCrop = ConversionHelper::convertTwipToMM100(nIntValue);
     480           0 :             break;// bottom crop in twips
     481             :         case NS_rtf::LN_BRCL:
     482           0 :             break;//border type - legacy -
     483             :         case NS_rtf::LN_FFRAMEEMPTY:
     484           0 :             break;// picture consists of a single frame
     485             :         case NS_rtf::LN_FBITMAP:
     486           0 :             m_pImpl->bIsBitmap = nIntValue > 0 ? true : false;
     487           0 :         break;//1 if it's a bitmap ???
     488             :         case NS_rtf::LN_FDRAWHATCH:
     489           0 :             break;//1 if it's an active OLE object
     490             :         case NS_rtf::LN_FERROR:
     491           0 :             break;// 1 if picture is an error message
     492             :         case NS_rtf::LN_BPP:
     493           0 :             m_pImpl->nBitsPerPixel = nIntValue;
     494           0 :             break;//bits per pixel 0 - unknown, 1- mono, 4 - VGA
     495             : 
     496             :         case NS_rtf::LN_DXAORIGIN: //horizontal offset of hand annotation origin
     497             :         case NS_rtf::LN_DYAORIGIN: //vertical offset of hand annotation origin
     498           0 :         break;
     499           0 :         case NS_rtf::LN_CPROPS:break;// unknown - ignored
     500             :         //metafilepict
     501             :         case NS_rtf::LN_MM:
     502             : 
     503           0 :         break; //mapmode
     504             :         case NS_rtf::LN_XEXT:
     505          12 :             m_pImpl->setXSize(nIntValue);
     506          12 :             break; // x-size
     507             :         case NS_rtf::LN_YEXT:
     508          12 :             m_pImpl->setYSize(nIntValue);
     509          12 :             break; // y-size
     510           0 :         case NS_rtf::LN_HMF: break; //identifier - ignored
     511             : 
     512             :         //sprm 0xf004 and 0xf008, 0xf00b
     513             :         case NS_rtf::LN_dfftype://
     514           0 :             m_pImpl->nDffType = nIntValue;
     515           0 :         break;
     516             :         case NS_rtf::LN_dffinstance:
     517             :             //todo: does this still work for PICF?
     518             :             //in case of LN_dfftype == 0xf01f the instance contains the bitmap type:
     519           0 :             if(m_pImpl->nDffType == 0xf01f)
     520           0 :                 switch( nIntValue )
     521             :                 {
     522             :                     case 0x216 :            // Metafile header then compressed WMF
     523             : 
     524             :                     case 0x3D4 :           // Metafile header then compressed EMF
     525             : 
     526             :                     case 0x542 :            // Metafile hd. then compressed PICT
     527             : 
     528             :                     {
     529             : 
     530             :                     }
     531             : 
     532           0 :                     break;
     533             : 
     534           0 :                     case 0x46A :            break;// One byte tag then JPEG (= JFIF) data
     535             : 
     536           0 :                     case 0x6E0 :            break;// One byte tag then PNG data
     537             : 
     538           0 :                     case 0x7A8 : m_pImpl->bIsBitmap = true;
     539           0 :                     break;
     540             : 
     541             :                 }
     542           0 :         break;
     543             :         case NS_rtf::LN_dffversion://  ignored
     544           0 :         break;
     545             : 
     546             :         //sprm 0xf008
     547             :         case NS_rtf::LN_shptype:
     548           0 :             break;
     549             :         case NS_rtf::LN_shpid:
     550           0 :             break;
     551             :         case NS_rtf::LN_shpfGroup:
     552           0 :             break;// This shape is a group shape
     553             :         case NS_rtf::LN_shpfChild:
     554           0 :             break;// Not a top-level shape
     555             :         case NS_rtf::LN_shpfPatriarch:
     556           0 :             break;// This is the topmost group shape. Exactly one of these per drawing.
     557             :         case NS_rtf::LN_shpfDeleted:
     558           0 :             break;// The shape has been deleted
     559             :         case NS_rtf::LN_shpfOleShape:
     560           0 :             break;// The shape is an OLE object
     561             :         case NS_rtf::LN_shpfHaveMaster:
     562           0 :             break;// Shape has a hspMaster property
     563             :         case NS_rtf::LN_shpfFlipH:       // Shape is flipped horizontally
     564           0 :             m_pImpl->bHoriFlip = nIntValue ? true : false;
     565           0 :         break;
     566             :         case NS_rtf::LN_shpfFlipV:       // Shape is flipped vertically
     567           0 :             m_pImpl->bVertFlip = nIntValue ? true : false;
     568           0 :         break;
     569             :         case NS_rtf::LN_shpfConnector:
     570           0 :             break;// Connector type of shape
     571             :         case NS_rtf::LN_shpfHaveAnchor:
     572           0 :             break;// Shape has an anchor of some kind
     573             :         case NS_rtf::LN_shpfBackground:
     574           0 :             break;// Background shape
     575             :         case NS_rtf::LN_shpfHaveSpt:
     576           0 :             break;// Shape has a shape type property
     577             :         case NS_rtf::LN_shptypename:
     578           0 :             break;// shape type name
     579             :         case NS_rtf::LN_shppid:
     580           0 :             m_pImpl->nShapeOptionType = nIntValue;
     581           0 :             break; //type of shape option
     582             :         case NS_rtf::LN_shpfBid:
     583           0 :             break; //ignored
     584             :         case NS_rtf::LN_shpfComplex:
     585           0 :             break;
     586             :         case NS_rtf::LN_shpop:
     587             :         {
     588           0 :             if(NS_dff::LN_shpwzDescription != sal::static_int_cast<Id>(m_pImpl->nShapeOptionType) )
     589           0 :                 ProcessShapeOptions( val );
     590             :         }
     591           0 :         break;
     592             :         case NS_rtf::LN_shpname:
     593           0 :             break;
     594             :         case NS_rtf::LN_shpvalue:
     595             :         {
     596           0 :             if( NS_dff::LN_shpwzDescription == sal::static_int_cast<Id>(m_pImpl->nShapeOptionType) )
     597           0 :                 ProcessShapeOptions( val );
     598             :         }
     599           0 :         break;
     600             : 
     601             :         //BLIP store entry
     602             :         case NS_rtf::LN_shpbtWin32:
     603           0 :             break;
     604             :         case NS_rtf::LN_shpbtMacOS:
     605           0 :             break;
     606             :         case NS_rtf::LN_shprgbUid:
     607           0 :             break;
     608             :         case NS_rtf::LN_shptag:
     609           0 :             break;
     610             :         case NS_rtf::LN_shpsize:
     611           0 :             break;
     612             :         case NS_rtf::LN_shpcRef:
     613           0 :             break;
     614             :         case NS_rtf::LN_shpfoDelay:
     615           0 :             break;
     616             :         case NS_rtf::LN_shpusage:
     617           0 :             break;
     618             :         case NS_rtf::LN_shpcbName:
     619           0 :             break;
     620             :         case NS_rtf::LN_shpunused2:
     621           0 :             break;
     622             :         case NS_rtf::LN_shpunused3:
     623           0 :             break;
     624             : 
     625             :         //border properties
     626             :         case NS_rtf::LN_shpblipbname :
     627           0 :         break;
     628             : 
     629             :         case NS_rtf::LN_DPTLINEWIDTH:  // 0x1759
     630           0 :             m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineWidth = nIntValue;
     631           0 :         break;
     632             :         case NS_rtf::LN_BRCTYPE:   // 0x175a
     633             :             //graphic borders don't support different line types
     634           0 :         break;
     635             :         case NS_rtf::LN_ICO:   // 0x175b
     636           0 :             m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineColor = ConversionHelper::ConvertColor( nIntValue );
     637           0 :         break;
     638             :         case NS_rtf::LN_DPTSPACE:  // 0x175c
     639           0 :             m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineDistance = nIntValue;
     640           0 :         break;
     641             :         case NS_rtf::LN_FSHADOW:   // 0x175d
     642           0 :             m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].bHasShadow = nIntValue ? true : false;
     643           0 :         break;
     644             :         case NS_rtf::LN_FFRAME:            // ignored
     645             :         case NS_rtf::LN_UNUSED2_15: // ignored
     646           0 :             break;
     647             : 
     648             :         case NS_rtf::LN_SPID:
     649           0 :             break;
     650             :         case NS_rtf::LN_XALEFT:
     651           0 :             m_pImpl->nLeftPosition = ConversionHelper::convertTwipToMM100(nIntValue);
     652           0 :             break; //left position
     653             :         case NS_rtf::LN_YATOP:
     654           0 :             m_pImpl->nTopPosition = ConversionHelper::convertTwipToMM100(nIntValue);
     655           0 :             break; //top position
     656             :         case NS_rtf::LN_XARIGHT:
     657           0 :             m_pImpl->nRightPosition = ConversionHelper::convertTwipToMM100(nIntValue);
     658           0 :             break; //right position
     659             :         case NS_rtf::LN_YABOTTOM:
     660           0 :             m_pImpl->nBottomPosition = ConversionHelper::convertTwipToMM100(nIntValue);
     661           0 :             break;//bottom position
     662             :         case NS_rtf::LN_FHDR:
     663             :         case NS_rtf::LN_XAlign:
     664           0 :             if( nIntValue < 6 && nIntValue > 0 )
     665             :             {
     666             :                 static const sal_Int16 aHoriOrientTab[ 6 ] =
     667             :                 {
     668             :                     text::HoriOrientation::NONE,
     669             :                     text::HoriOrientation::LEFT,
     670             :                     text::HoriOrientation::CENTER,
     671             :                     text::HoriOrientation::RIGHT,
     672             :                     text::HoriOrientation::INSIDE,
     673             :                     text::HoriOrientation::OUTSIDE
     674             :                 };
     675           0 :                 m_pImpl->nHoriOrient = aHoriOrientTab[nIntValue];
     676           0 :                 m_pImpl->bPageToggle = nIntValue > 3;
     677             :             }
     678           0 :         break;
     679             :         case NS_rtf::LN_YAlign:
     680           0 :             if( nIntValue < 6 && nIntValue > 0)
     681             :             {
     682             :                 static const sal_Int16 aVertOrientTab[ 6 ] =
     683             :                 {
     684             :                     text::VertOrientation::NONE,         // From Top position
     685             :                     text::VertOrientation::TOP,          // top
     686             :                     text::VertOrientation::CENTER,       // centered
     687             :                     text::VertOrientation::BOTTOM,       // bottom
     688             :                     text::VertOrientation::LINE_TOP,     // inside (obscure)
     689             :                     text::VertOrientation::LINE_BOTTOM   // outside (obscure)
     690             :                 };
     691             :                 static const sal_Int16 aToLineVertOrientTab[ 6 ] =
     692             :                 {
     693             :                     text::VertOrientation::NONE,         // below
     694             :                     text::VertOrientation::LINE_BOTTOM,  // top
     695             :                     text::VertOrientation::LINE_CENTER,  // centered
     696             :                     text::VertOrientation::LINE_TOP,     // bottom
     697             :                     text::VertOrientation::LINE_BOTTOM,  // inside (obscure)
     698             :                     text::VertOrientation::LINE_TOP      // outside (obscure)
     699             :                 };
     700           0 :                 m_pImpl->nVertOrient = m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE ?
     701           0 :                     aToLineVertOrientTab[nIntValue] : aVertOrientTab[nIntValue];
     702             :             }
     703           0 :         break;
     704           0 :         case NS_rtf::LN_LayoutInTableCell: break; //currently unknown
     705             :         case NS_rtf::LN_XRelTo:
     706             :         case NS_rtf::LN_BX: //hori orient relation
     707           0 :             switch( nIntValue )
     708             :             {
     709           0 :                 case  0: m_pImpl->nHoriRelation = text::RelOrientation::PAGE_PRINT_AREA; break;
     710           0 :                 case  1: m_pImpl->nHoriRelation = text::RelOrientation::PAGE_FRAME; break;
     711           0 :                 case  2: m_pImpl->nHoriRelation = text::RelOrientation::FRAME; break;
     712             :                 //case  :
     713           0 :                 default:m_pImpl->nHoriRelation = text::RelOrientation::CHAR;
     714             :             }
     715           0 :         break;
     716             :         case NS_rtf::LN_YRelTo:
     717             :         case NS_rtf::LN_BY: //vert orient relation
     718           0 :             switch( nIntValue )
     719             :             {
     720           0 :                 case  0: m_pImpl->nVertRelation = text::RelOrientation::PAGE_PRINT_AREA; break;
     721           0 :                 case  1: m_pImpl->nVertRelation = text::RelOrientation::PAGE_FRAME; break;
     722           0 :                 case  2: m_pImpl->nVertRelation = text::RelOrientation::FRAME; break;
     723             :                 //case  :
     724           0 :                 default:m_pImpl->nVertRelation = text::RelOrientation::TEXT_LINE;
     725             :             }
     726             : 
     727           0 :         break;
     728             :         case NS_rtf::LN_WR: //wrapping
     729           3 :             switch( nIntValue )
     730             :             {
     731             :                 case 0: //0 like 2, but doesn't require absolute object
     732           0 :                     m_pImpl->bIgnoreWRK = false;
     733             :                 case 2: //2 wrap around absolute object
     734           0 :                     m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
     735           0 :                     break;
     736             :                 case 1: //1 no text next to shape
     737           0 :                     m_pImpl->nWrap = text::WrapTextMode_NONE;
     738           0 :                     break;
     739             :                 case 3: //3 wrap as if no object present
     740           3 :                     m_pImpl->nWrap = text::WrapTextMode_THROUGHT;
     741           3 :                     break;
     742             :                 case 4: //4 wrap tightly around object
     743           0 :                     m_pImpl->bIgnoreWRK = false;
     744             :                 case 5: //5 wrap tightly, but allow holes
     745           0 :                     m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
     746           0 :                     m_pImpl->bContour = true;
     747           0 :                 break;
     748             :                 default:;
     749             :             }
     750           3 :         break;
     751             :         case NS_rtf::LN_WRK:
     752           0 :             if( !m_pImpl->bIgnoreWRK )
     753           0 :                 switch( nIntValue )
     754             :                 {
     755             :                     case 0: //0 like 2, but doesn't require absolute object
     756             :                     case 2: //2 wrap around absolute object
     757           0 :                         m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
     758           0 :                         break;
     759             :                     case 1: //1 no text next to shape
     760           0 :                         m_pImpl->nWrap = text::WrapTextMode_NONE;
     761           0 :                         break;
     762             :                     case 3: //3 wrap as if no object present
     763           0 :                         m_pImpl->nWrap = text::WrapTextMode_THROUGHT;
     764           0 :                         break;
     765             :                     case 4: //4 wrap tightly around object
     766             :                     case 5: //5 wrap tightly, but allow holes
     767           0 :                         m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
     768           0 :                         m_pImpl->bContour = true;
     769           0 :                     break;
     770             :                     default:;
     771             :                 }
     772           0 :         break;
     773             :         case NS_rtf::LN_FRCASIMPLE:
     774             :         case NS_rtf::LN_FBELOWTEXT:
     775             :         case NS_rtf::LN_FANCHORLOCK:
     776             :         case NS_rtf::LN_CTXBX:
     777           0 :         break;
     778             :         case NS_rtf::LN_shptxt:
     779             :             //todo: text content
     780           0 :         break;
     781           0 :         case NS_rtf::LN_dffheader: break;
     782             :         case NS_ooxml::LN_CT_PositiveSize2D_cx:// 90407;
     783             :         case NS_ooxml::LN_CT_PositiveSize2D_cy:// 90408;
     784             :         {
     785          32 :             sal_Int32 nDim = ConversionHelper::convertEMUToMM100( nIntValue );
     786          32 :             if( nName == NS_ooxml::LN_CT_PositiveSize2D_cx )
     787          16 :                 m_pImpl->setXSize(nDim);
     788             :             else
     789          16 :                 m_pImpl->setYSize(nDim);
     790             :         }
     791          32 :         break;
     792             :         case NS_ooxml::LN_CT_EffectExtent_l:// 90907;
     793             :         case NS_ooxml::LN_CT_EffectExtent_t:// 90908;
     794             :         case NS_ooxml::LN_CT_EffectExtent_r:// 90909;
     795             :         case NS_ooxml::LN_CT_EffectExtent_b:// 90910;
     796             :             //todo: extends the wrapping size of the object, e.g. if shadow is added
     797           0 :         break;
     798             :         case NS_ooxml::LN_CT_NonVisualDrawingProps_id:// 90650;
     799             :             //id of the object - ignored
     800           0 :         break;
     801             :         case NS_ooxml::LN_CT_NonVisualDrawingProps_name:// 90651;
     802             :             //name of the object
     803          16 :             m_pImpl->sName = val.getString();
     804          16 :         break;
     805             :         case NS_ooxml::LN_CT_NonVisualDrawingProps_descr:// 90652;
     806             :             //alternative text
     807          12 :             m_pImpl->sAlternativeText = val.getString();
     808          12 :         break;
     809             :         case NS_ooxml::LN_CT_NonVisualDrawingProps_title:
     810             :             //alternative text
     811           1 :             m_pImpl->title = val.getString();
     812           1 :         break;
     813             :         case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noChangeAspect://90644;
     814             :             //disallow aspect ratio change - ignored
     815          14 :         break;
     816             :         case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noMove:// 90645;
     817           0 :             m_pImpl->bPositionProtected = true;
     818           0 :         break;
     819             :         case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noResize: // 90646;
     820           0 :             m_pImpl->bSizeProtected = true;
     821           0 :         break;
     822             :         case NS_ooxml::LN_CT_Anchor_distT: // 90983;
     823             :         case NS_ooxml::LN_CT_Anchor_distB: // 90984;
     824             :         case NS_ooxml::LN_CT_Anchor_distL: // 90985;
     825             :         case NS_ooxml::LN_CT_Anchor_distR: // 90986;
     826             :         {
     827             :             //redirect to shape option processing
     828          20 :             switch( nName )
     829             :             {
     830             :                 case NS_ooxml::LN_CT_Anchor_distT: // 90983;
     831           5 :                     m_pImpl->nShapeOptionType = NS_dff::LN_shpdyWrapDistTop;
     832           5 :                 break;
     833             :                 case NS_ooxml::LN_CT_Anchor_distB: // 90984;
     834           5 :                     m_pImpl->nShapeOptionType = NS_dff::LN_shpdyWrapDistBottom;
     835           5 :                 break;
     836             :                 case NS_ooxml::LN_CT_Anchor_distL: // 90985;
     837           5 :                     m_pImpl->nShapeOptionType = NS_dff::LN_shpdxWrapDistLeft;
     838           5 :                 break;
     839             :                 case NS_ooxml::LN_CT_Anchor_distR: // 90986;
     840           5 :                     m_pImpl->nShapeOptionType = NS_dff::LN_shpdxWrapDistRight;
     841           5 :                 break;
     842             :                 //m_pImpl->nShapeOptionType = NS_dff::LN_shpcropFromTop
     843             :                 default: ;
     844             :             }
     845          20 :             ProcessShapeOptions(val);
     846             :         }
     847          20 :         break;
     848             :         case NS_ooxml::LN_CT_Anchor_simplePos_attr: // 90987;
     849           5 :             m_pImpl->bUseSimplePos = nIntValue > 0;
     850           5 :         break;
     851             :         case NS_ooxml::LN_CT_Anchor_relativeHeight: // 90988;
     852           5 :             m_pImpl->zOrder = nIntValue;
     853           5 :         break;
     854             :         case NS_ooxml::LN_CT_Anchor_behindDoc: // 90989; - in background
     855           5 :             if( nIntValue > 0 )
     856           0 :                     m_pImpl->bOpaque = false;
     857           5 :         break;
     858             :         case NS_ooxml::LN_CT_Anchor_locked: // 90990; - ignored
     859             :         case NS_ooxml::LN_CT_Anchor_layoutInCell: // 90991; - ignored
     860             :         case NS_ooxml::LN_CT_Anchor_hidden: // 90992; - ignored
     861          10 :         break;
     862             :         case NS_ooxml::LN_CT_Anchor_allowOverlap: // 90993;
     863             :             //enable overlapping - ignored
     864           5 :         break;
     865             :         case NS_ooxml::LN_CT_Point2D_x: // 90405;
     866           5 :             m_pImpl->nLeftPosition = ConversionHelper::convertTwipToMM100(nIntValue);
     867           5 :             m_pImpl->nHoriRelation = text::RelOrientation::PAGE_FRAME;
     868           5 :             m_pImpl->nHoriOrient = text::HoriOrientation::NONE;
     869           5 :         break;
     870             :         case NS_ooxml::LN_CT_Point2D_y: // 90406;
     871           5 :             m_pImpl->nTopPosition = ConversionHelper::convertTwipToMM100(nIntValue);
     872           5 :             m_pImpl->nVertRelation = text::RelOrientation::PAGE_FRAME;
     873           5 :             m_pImpl->nVertOrient = text::VertOrientation::NONE;
     874           5 :         break;
     875             :         case NS_ooxml::LN_CT_WrapTight_wrapText: // 90934;
     876           0 :             m_pImpl->bContour = true;
     877           0 :             m_pImpl->bContourOutside = true;
     878             : 
     879           0 :             handleWrapTextValue(val.getInt());
     880             : 
     881           0 :             break;
     882             :         case NS_ooxml::LN_CT_WrapThrough_wrapText:
     883             :             /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */
     884           0 :             m_pImpl->bContour = true;
     885           0 :             m_pImpl->bContourOutside = false;
     886             : 
     887           0 :             handleWrapTextValue(val.getInt());
     888             : 
     889           0 :             break;
     890             :         case NS_ooxml::LN_CT_WrapSquare_wrapText: //90928;
     891             :             /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */
     892             : 
     893           4 :             handleWrapTextValue(val.getInt());
     894           4 :             break;
     895             :         case NS_ooxml::LN_shape:
     896             :             {
     897          28 :                 uno::Reference< drawing::XShape> xShape;
     898          28 :                 val.getAny( ) >>= xShape;
     899             : 
     900          28 :                 if ( xShape.is( ) )
     901             :                 {
     902             :                     // Is it a graphic image
     903          28 :                     bool bUseShape = true;
     904             :                     try
     905             :                     {
     906             :                         uno::Reference< beans::XPropertySet > xShapeProps
     907          28 :                             ( xShape, uno::UNO_QUERY_THROW );
     908             : 
     909          56 :                         OUString sUrl;
     910          30 :                         xShapeProps->getPropertyValue("GraphicURL") >>= sUrl;
     911             : 
     912          52 :                         ::com::sun::star::beans::PropertyValues aMediaProperties( 1 );
     913          26 :                         aMediaProperties[0].Name = "URL";
     914          26 :                         aMediaProperties[0].Value <<= sUrl;
     915             : 
     916          26 :                         xShapeProps->getPropertyValue("Shadow") >>= m_pImpl->bShadow;
     917          26 :                         if (m_pImpl->bShadow)
     918             :                         {
     919           6 :                             xShapeProps->getPropertyValue("ShadowXDistance") >>= m_pImpl->nShadowXDistance;
     920           6 :                             xShapeProps->getPropertyValue("ShadowYDistance") >>= m_pImpl->nShadowYDistance;
     921           6 :                             xShapeProps->getPropertyValue("ShadowColor") >>= m_pImpl->nShadowColor;
     922           6 :                             xShapeProps->getPropertyValue("ShadowTransparence") >>= m_pImpl->nShadowTransparence;
     923             :                         }
     924             : 
     925          26 :                         m_xGraphicObject = createGraphicObject( aMediaProperties );
     926             : 
     927          26 :                         bUseShape = !m_xGraphicObject.is( );
     928             : 
     929          26 :                         if ( !bUseShape )
     930             :                         {
     931             :                             // Define the object size
     932             :                             uno::Reference< beans::XPropertySet > xGraphProps( m_xGraphicObject,
     933          26 :                                     uno::UNO_QUERY );
     934          26 :                             awt::Size aSize = xShape->getSize( );
     935          26 :                             xGraphProps->setPropertyValue("Height",
     936          26 :                                    uno::makeAny( aSize.Height ) );
     937          26 :                             xGraphProps->setPropertyValue("Width",
     938          26 :                                    uno::makeAny( aSize.Width ) );
     939             : 
     940          26 :                             text::GraphicCrop aGraphicCrop( 0, 0, 0, 0 );
     941          52 :                             uno::Reference< beans::XPropertySet > xSourceGraphProps( xShape, uno::UNO_QUERY );
     942          52 :                             uno::Any aAny = xSourceGraphProps->getPropertyValue("GraphicCrop");
     943          26 :                             if(aAny >>= aGraphicCrop) {
     944          26 :                                 xGraphProps->setPropertyValue("GraphicCrop",
     945          26 :                                     uno::makeAny( aGraphicCrop ) );
     946             :                             }
     947             : 
     948             :                             // We need to drop the shape here somehow
     949          52 :                             uno::Reference< lang::XComponent > xShapeComponent( xShape, uno::UNO_QUERY );
     950          52 :                             xShapeComponent->dispose( );
     951          28 :                         }
     952             :                     }
     953           2 :                     catch( const beans::UnknownPropertyException & )
     954             :                     {
     955             :                         // It isn't a graphic image
     956             :                     }
     957             : 
     958          28 :                     if ( bUseShape )
     959           2 :                         m_xShape = xShape;
     960             : 
     961             : 
     962          28 :                     if ( m_xShape.is( ) )
     963             :                     {
     964             :                         uno::Reference< beans::XPropertySet > xShapeProps
     965           2 :                             (m_xShape, uno::UNO_QUERY_THROW);
     966             : 
     967             : 
     968             :                         PropertyNameSupplier& rPropNameSupplier =
     969           2 :                             PropertyNameSupplier::GetPropertyNameSupplier();
     970           2 :                         xShapeProps->setPropertyValue
     971           2 :                             (rPropNameSupplier.GetName(PROP_ANCHOR_TYPE),
     972             :                              uno::makeAny
     973           4 :                              (text::TextContentAnchorType_AS_CHARACTER));
     974           2 :                         xShapeProps->setPropertyValue
     975           2 :                             (rPropNameSupplier.GetName(PROP_TEXT_RANGE),
     976             :                              uno::makeAny
     977           4 :                              (m_pImpl->rDomainMapper.GetCurrentTextRange()));
     978             : 
     979           2 :                         awt::Size aSize(m_xShape->getSize());
     980             : 
     981           2 :                         if (m_pImpl->isXSizeValid())
     982           2 :                             aSize.Width = m_pImpl->getXSize();
     983           2 :                         if (m_pImpl->isYSizeValis())
     984           2 :                             aSize.Height = m_pImpl->getYSize();
     985             : 
     986           2 :                         m_xShape->setSize(aSize);
     987             : 
     988           2 :                         m_pImpl->bIsGraphic = true;
     989             :                     }
     990          28 :                 }
     991             :             }
     992          28 :         break;
     993             :         case NS_ooxml::LN_CT_Inline_distT:
     994          19 :             m_pImpl->nTopMargin = ConversionHelper::convertEMUToMM100(nIntValue);
     995          19 :         break;
     996             :         case NS_ooxml::LN_CT_Inline_distB:
     997          19 :             m_pImpl->nBottomMargin = ConversionHelper::convertEMUToMM100(nIntValue);
     998          19 :         break;
     999             :         case NS_ooxml::LN_CT_Inline_distL:
    1000          19 :             m_pImpl->nLeftMargin = ConversionHelper::convertEMUToMM100(nIntValue);
    1001          19 :         break;
    1002             :         case NS_ooxml::LN_CT_Inline_distR:
    1003          19 :             m_pImpl->nRightMargin = ConversionHelper::convertEMUToMM100(nIntValue);
    1004          19 :         break;
    1005             :         case NS_ooxml::LN_CT_GraphicalObjectData_uri:
    1006           0 :             val.getString();
    1007             :             //TODO: does it need to be handled?
    1008           0 :         break;
    1009             :         default:
    1010             : #ifdef DEBUG_DMAPPER_GRAPHIC_IMPORT
    1011             :             dmapper_logger->element("unhandled");
    1012             : #endif
    1013             :             ;
    1014             :     }
    1015         274 : }
    1016             : 
    1017          28 : uno::Reference<text::XTextContent> GraphicImport::GetGraphicObject()
    1018             : {
    1019          28 :     uno::Reference<text::XTextContent> xResult;
    1020             : 
    1021          28 :     if (m_xGraphicObject.is())
    1022          26 :         xResult = m_xGraphicObject;
    1023           2 :     else if (m_xShape.is())
    1024             :     {
    1025           2 :         xResult.set(m_xShape, uno::UNO_QUERY_THROW);
    1026             :     }
    1027             : 
    1028          28 :     return xResult;
    1029             : }
    1030             : 
    1031             : 
    1032             : 
    1033          20 : void GraphicImport::ProcessShapeOptions(Value& val)
    1034             : {
    1035          20 :     sal_Int32 nIntValue = val.getInt();
    1036          20 :     sal_Int32 nTwipValue = ConversionHelper::convertTwipToMM100(nIntValue);
    1037          20 :     switch( m_pImpl->nShapeOptionType )
    1038             :     {
    1039             :         case NS_dff::LN_shpcropFromTop /*256*/ :
    1040           0 :             m_pImpl->nTopCrop   = nTwipValue;
    1041           0 :             break;// rtf:shpcropFromTop
    1042             :         case NS_dff::LN_shpcropFromBottom /*257*/ :
    1043           0 :             m_pImpl->nBottomCrop= nTwipValue;
    1044           0 :             break;// rtf:shpcropFromBottom
    1045             :         case NS_dff::LN_shpcropFromLeft   /*258*/ :
    1046           0 :             m_pImpl->nLeftCrop  = nTwipValue;
    1047           0 :             break;// rtf:shpcropFromLeft
    1048             :         case NS_dff::LN_shpcropFromRight/*259*/ :
    1049           0 :             m_pImpl->nRightCrop = nTwipValue;
    1050           0 :             break;// rtf:shpcropFromRight
    1051             :         case NS_dff::LN_shppib/*260*/:
    1052           0 :             break;  // rtf:shppib
    1053             :         case NS_dff::LN_shppibName/*261*/:
    1054           0 :             break;  // rtf:shppibName
    1055             :         case NS_dff::LN_shppibFlags/*262*/:  // rtf:shppibFlags
    1056           0 :         break;
    1057             :         case NS_dff::LN_shppictureContrast/*264*/: // rtf:shppictureContrast docu: "1<<16"
    1058             :             /*
    1059             :             0x10000 is msoffice 50%
    1060             :             < 0x10000 is in units of 1/50th of 0x10000 per 1%
    1061             :             > 0x10000 is in units where
    1062             :             a msoffice x% is stored as 50/(100-x) * 0x10000
    1063             : 
    1064             :             plus, a (ui) microsoft % ranges from 0 to 100, OOO
    1065             :             from -100 to 100, so also normalize into that range
    1066             :             */
    1067           0 :             if ( nIntValue > 0x10000 )
    1068             :             {
    1069           0 :                 double fX = nIntValue;
    1070           0 :                 fX /= 0x10000;
    1071           0 :                 fX /= 51;   // 50 + 1 to round
    1072           0 :                 fX = 1/fX;
    1073           0 :                 m_pImpl->nContrast = static_cast<sal_Int32>(fX);
    1074           0 :                 m_pImpl->nContrast -= 100;
    1075           0 :                 m_pImpl->nContrast = -m_pImpl->nContrast;
    1076           0 :                 m_pImpl->nContrast = (m_pImpl->nContrast-50)*2;
    1077             :             }
    1078           0 :             else if ( nIntValue == 0x10000 )
    1079           0 :                 m_pImpl->nContrast = 0;
    1080             :             else
    1081             :             {
    1082           0 :                 m_pImpl->nContrast = nIntValue * 101;   //100 + 1 to round
    1083           0 :                 m_pImpl->nContrast /= 0x10000;
    1084           0 :                 m_pImpl->nContrast -= 100;
    1085             :             }
    1086           0 :         break;
    1087             :         case NS_dff::LN_shppictureBrightness/*265*/:  // rtf:shppictureBrightness
    1088           0 :             m_pImpl->nBrightness     = ( (sal_Int32) nIntValue / 327 );
    1089           0 :         break;
    1090             :         case NS_dff::LN_shppictureGamma/*266*/: // rtf:shppictureGamma
    1091             :             //todo check gamma value with _real_ document
    1092           0 :             m_pImpl->fGamma = double(nIntValue/655);
    1093           0 :         break;
    1094             :         case NS_dff::LN_shppictureId        /*267*/:
    1095           0 :             break;  // rtf:shppictureId
    1096             :         case NS_dff::LN_shppictureDblCrMod  /*268*/:
    1097           0 :             break;  // rtf:shppictureDblCrMod
    1098             :         case NS_dff::LN_shppictureFillCrMod /*269*/:
    1099           0 :             break;  // rtf:shppictureFillCrMod
    1100             :         case NS_dff::LN_shppictureLineCrMod /*270*/:
    1101           0 :             break;  // rtf:shppictureLineCrMod
    1102             : 
    1103             :         case NS_dff::LN_shppictureActive/*319*/: // rtf:shppictureActive
    1104           0 :             switch( nIntValue & 0x06 )
    1105             :             {
    1106           0 :                 case 0 : m_pImpl->eColorMode = drawing::ColorMode_STANDARD; break;
    1107           0 :                 case 4 : m_pImpl->eColorMode = drawing::ColorMode_GREYS; break;
    1108           0 :                 case 6 : m_pImpl->eColorMode = drawing::ColorMode_MONO; break;
    1109             :                 default:;
    1110             :             }
    1111           0 :         break;
    1112             :         case NS_dff::LN_shpfillColor           /*385*/:
    1113           0 :             m_pImpl->nFillColor = (m_pImpl->nFillColor & 0xff000000) + ConversionHelper::ConvertColor( nIntValue );
    1114           0 :         break;
    1115             :         case NS_dff::LN_shpfillOpacity         /*386*/:
    1116             :         {
    1117           0 :             sal_Int32 nTrans = 0xff - ( nIntValue * 0xff ) / 0xffff;
    1118           0 :             m_pImpl->nFillColor = (nTrans << 0x18 ) + (m_pImpl->nFillColor & 0xffffff);
    1119             :         }
    1120           0 :         break;
    1121             :         case NS_dff::LN_shpfNoFillHitTest      /*447*/:
    1122           0 :             break;  // rtf:shpfNoFillHitTest
    1123             :         case NS_dff::LN_shplineColor           /*448*/:
    1124           0 :             m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineColor = ConversionHelper::ConvertColor( nIntValue );
    1125           0 :         break;
    1126             :         case NS_dff::LN_shplineWidth           /*459*/:
    1127             :             //1pt == 12700 units
    1128           0 :             m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineWidth = ConversionHelper::convertTwipToMM100(nIntValue / 635);
    1129           0 :         break;
    1130             :         case NS_dff::LN_shplineDashing         /*462*/:
    1131             :             //graphic borders don't support different dashing
    1132             :             /*MSOLINEDASHING
    1133             :                 msolineSolid,              // Solid (continuous) pen
    1134             :                 msolineDashSys,            // PS_DASH system   dash style
    1135             :                 msolineDotSys,             // PS_DOT system   dash style
    1136             :                 msolineDashDotSys,         // PS_DASHDOT system dash style
    1137             :                 msolineDashDotDotSys,      // PS_DASHDOTDOT system dash style
    1138             :                 msolineDotGEL,             // square dot style
    1139             :                 msolineDashGEL,            // dash style
    1140             :                 msolineLongDashGEL,        // long dash style
    1141             :                 msolineDashDotGEL,         // dash short dash
    1142             :                 msolineLongDashDotGEL,     // long dash short dash
    1143             :                 msolineLongDashDotDotGEL   // long dash short dash short dash*/
    1144           0 :         break;
    1145             :         case NS_dff::LN_shpfNoLineDrawDash     /*511*/:
    1146           0 :         break;  // rtf:shpfNoLineDrawDash
    1147             :         case NS_dff::LN_shpwzDescription /*897*/: //alternative text
    1148           0 :             m_pImpl->sAlternativeText = val.getString();
    1149           0 :         break;
    1150             :         case NS_dff::LN_shppWrapPolygonVertices/*899*/:
    1151           0 :             break;  // rtf:shppWrapPolygonVertices
    1152             :         case NS_dff::LN_shpdxWrapDistLeft /*900*/: // contains a twip/635 value
    1153             :             //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustLRWrapForWordMargins()
    1154           5 :             m_pImpl->nLeftMargin = nIntValue / 360;
    1155           5 :         break;
    1156             :         case NS_dff::LN_shpdyWrapDistTop /*901*/:  // contains a twip/635 value
    1157             :             //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustULWrapForWordMargins()
    1158           5 :             m_pImpl->nTopMargin = nIntValue / 360;
    1159           5 :         break;
    1160             :         case NS_dff::LN_shpdxWrapDistRight /*902*/:// contains a twip/635 value
    1161             :             //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustLRWrapForWordMargins()
    1162           5 :             m_pImpl->nRightMargin = nIntValue / 360;
    1163           5 :         break;
    1164             :         case NS_dff::LN_shpdyWrapDistBottom /*903*/:// contains a twip/635 value
    1165             :             //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustULWrapForWordMargins()
    1166           5 :             m_pImpl->nBottomMargin = nIntValue / 360;
    1167           5 :         break;
    1168             :         case NS_dff::LN_shpfPrint              /*959*/:
    1169           0 :             break;  // rtf:shpfPrint
    1170             :         default:
    1171             :             OSL_FAIL( "shape option unsupported?");
    1172             :     }
    1173          20 : }
    1174             : 
    1175             : 
    1176         212 : void GraphicImport::lcl_sprm(Sprm & rSprm)
    1177             : {
    1178         212 :     sal_uInt32 nSprmId = rSprm.getId();
    1179         212 :     Value::Pointer_t pValue = rSprm.getValue();
    1180             : 
    1181         212 :     switch(nSprmId)
    1182             :     {
    1183             :         case 0xf004: //dff record
    1184             :         case 0xf00a: //part of 0xf004 - shape properties
    1185             :         case 0xf00b: //part of 0xf004
    1186             :         case 0xf007:
    1187             :         case 0xf122: //udefprop
    1188             :         case NS_ooxml::LN_CT_Inline_extent: // 90911;
    1189             :         case NS_ooxml::LN_CT_Inline_effectExtent: // 90912;
    1190             :         case NS_ooxml::LN_CT_Inline_docPr: // 90913;
    1191             :         case NS_ooxml::LN_CT_Inline_cNvGraphicFramePr: // 90914;
    1192             :         case NS_ooxml::LN_CT_NonVisualGraphicFrameProperties_graphicFrameLocks:// 90657
    1193             :         case NS_ooxml::LN_CT_Inline_a_graphic:// 90915
    1194             :         case NS_ooxml::LN_CT_Anchor_simplePos_elem: // 90975;
    1195             :         case NS_ooxml::LN_CT_Anchor_extent: // 90978;
    1196             :         case NS_ooxml::LN_CT_Anchor_effectExtent: // 90979;
    1197             :         case NS_ooxml::LN_EG_WrapType_wrapSquare: // 90945;
    1198             :         case NS_ooxml::LN_EG_WrapType_wrapTight: // 90946;
    1199             :         case NS_ooxml::LN_EG_WrapType_wrapThrough:
    1200             :         case NS_ooxml::LN_CT_Anchor_docPr: // 90980;
    1201             :         case NS_ooxml::LN_CT_Anchor_cNvGraphicFramePr: // 90981;
    1202             :         case NS_ooxml::LN_CT_Anchor_a_graphic: // 90982;
    1203             :         case NS_ooxml::LN_CT_WrapPath_start: // 90924;
    1204             :         case NS_ooxml::LN_CT_WrapPath_lineTo: // 90925;
    1205             :         case NS_ooxml::LN_graphic_graphic:
    1206             :         case NS_ooxml::LN_pic_pic:
    1207             :         case NS_ooxml::LN_dgm_relIds:
    1208             :         case NS_ooxml::LN_lc_lockedCanvas:
    1209             :         {
    1210         167 :             writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
    1211         167 :             if( pProperties.get())
    1212             :             {
    1213         167 :                 pProperties->resolve(*this);
    1214         167 :             }
    1215             :         }
    1216         167 :         break;
    1217             :         case NS_ooxml::LN_CT_WrapTight_wrapPolygon:
    1218             :         case NS_ooxml::LN_CT_WrapThrough_wrapPolygon:
    1219             :             /* WRITERFILTERSTATUS: done: 100, planned: 4, spent: 2 */
    1220             :             {
    1221           0 :                 WrapPolygonHandler aHandler;
    1222             : 
    1223           0 :                 resolveSprmProps(aHandler, rSprm);
    1224             : 
    1225           0 :                 m_pImpl->mpWrapPolygon = aHandler.getPolygon();
    1226             :             }
    1227           0 :             break;
    1228             :         case NS_ooxml::LN_CT_Anchor_positionH: // 90976;
    1229             :         {
    1230             :             // Use a special handler for the positionning
    1231           8 :             PositionHandlerPtr pHandler( new PositionHandler( false ));
    1232          16 :             writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
    1233           8 :             if( pProperties.get( ) )
    1234             :             {
    1235           8 :                 pProperties->resolve( *pHandler );
    1236           8 :                 if( !m_pImpl->bUseSimplePos )
    1237             :                 {
    1238           8 :                     m_pImpl->nHoriRelation = pHandler->relation();
    1239           8 :                     m_pImpl->nHoriOrient = pHandler->orientation();
    1240           8 :                     m_pImpl->nLeftPosition = pHandler->position();
    1241             :                 }
    1242           8 :             }
    1243             :         }
    1244           8 :         break;
    1245             :         case NS_ooxml::LN_CT_Anchor_positionV: // 90977;
    1246             :         {
    1247             :             // Use a special handler for the positionning
    1248           8 :             PositionHandlerPtr pHandler( new PositionHandler( true ));
    1249          16 :             writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
    1250           8 :             if( pProperties.get( ) )
    1251             :             {
    1252           8 :                 pProperties->resolve( *pHandler );
    1253           8 :                 if( !m_pImpl->bUseSimplePos )
    1254             :                 {
    1255           8 :                     m_pImpl->nVertRelation = pHandler->relation();
    1256           8 :                     m_pImpl->nVertOrient = pHandler->orientation();
    1257           8 :                     m_pImpl->nTopPosition = pHandler->position();
    1258             :                 }
    1259           8 :             }
    1260             :         }
    1261           8 :         break;
    1262             :         case 0x271b:
    1263             :         case 0x271c:
    1264             :         {
    1265           0 :             if( nSprmId != 0x271c || m_pImpl->nDffType == 0xf01f || m_pImpl->nDffType == 0xf01e )
    1266             :             {
    1267           0 :                 writerfilter::Reference<BinaryObj>::Pointer_t pPictureData = rSprm.getBinary();
    1268           0 :                 if( pPictureData.get())
    1269           0 :                     pPictureData->resolve(*this);
    1270             :             }
    1271             :         }
    1272           0 :         break;
    1273             :         case NS_ooxml::LN_EG_WrapType_wrapNone: // 90944; - doesn't contain attributes
    1274             :             //depending on the behindDoc attribute text wraps through behind or in fron of the object
    1275           1 :             m_pImpl->nWrap = text::WrapTextMode_THROUGHT;
    1276           1 :         break;
    1277             :         case NS_ooxml::LN_EG_WrapType_wrapTopAndBottom: // 90948;
    1278           0 :             m_pImpl->nWrap = text::WrapTextMode_NONE;
    1279           0 :         break;
    1280             :         case 0xf010:
    1281             :         case 0xf011:
    1282             :             //ignore - doesn't contain useful members
    1283           0 :         break;
    1284             :         case NS_ooxml::LN_CT_GraphicalObject_graphicData:// 90660;
    1285             :             {
    1286          28 :                 m_pImpl->bIsGraphic = true;
    1287             : 
    1288          28 :                 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
    1289          28 :                 if( pProperties.get())
    1290          28 :                     pProperties->resolve(*this);
    1291             :             }
    1292          28 :         break;
    1293             :         default:
    1294             : #if OSL_DEBUG_LEVEL > 0
    1295             :             OString sMessage( "GraphicImport::sprm() - Id: ");
    1296             :             sMessage += OString::valueOf( sal_Int32( nSprmId ), 10 );
    1297             :             sMessage += " / 0x";
    1298             :             sMessage += OString::valueOf( sal_Int32( nSprmId ), 16 );
    1299             :             SAL_WARN("writerfilter", sMessage.getStr());
    1300             : #endif
    1301             :             ;
    1302         212 :     }
    1303         212 : }
    1304             : 
    1305             : 
    1306           0 : void GraphicImport::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t /*ref*/)
    1307             : {
    1308           0 : }
    1309             : /*-------------------------------------------------------------------------
    1310             :     crop is stored as "fixed float" as 16.16 fraction value
    1311             :     related to width/or height
    1312             :   -----------------------------------------------------------------------*/
    1313          20 : void lcl_CalcCrop( sal_Int32& nCrop, sal_Int32 nRef )
    1314             : {
    1315          20 :     nCrop = ((nCrop >> 16   ) * nRef )
    1316          20 :        + (((nCrop & 0xffff) * nRef ) >> 16);
    1317          20 : }
    1318             : 
    1319          26 : uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const beans::PropertyValues& aMediaProperties )
    1320             : {
    1321          26 :     uno::Reference< text::XTextContent > xGraphicObject;
    1322             :     try
    1323             :     {
    1324          26 :         uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(m_xComponentContext) );
    1325          52 :         uno::Reference< graphic::XGraphic > xGraphic = xGraphicProvider->queryGraphic( aMediaProperties );
    1326             : 
    1327          26 :         if(xGraphic.is())
    1328             :         {
    1329          26 :             PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
    1330             : 
    1331             :             uno::Reference< beans::XPropertySet > xGraphicObjectProperties(
    1332          26 :             m_xTextFactory->createInstance("com.sun.star.text.TextGraphicObject"),
    1333          26 :                 uno::UNO_QUERY_THROW);
    1334          26 :             xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_GRAPHIC), uno::makeAny( xGraphic ));
    1335          52 :             xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_ANCHOR_TYPE),
    1336          52 :                 uno::makeAny( m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE || m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR ?
    1337             :                                     text::TextContentAnchorType_AT_CHARACTER :
    1338          87 :                                     text::TextContentAnchorType_AS_CHARACTER ));
    1339          26 :             xGraphicObject = uno::Reference< text::XTextContent >( xGraphicObjectProperties, uno::UNO_QUERY_THROW );
    1340             : 
    1341             :             //shapes have only one border, PICF might have four
    1342          26 :             table::BorderLine2 aBorderLine;
    1343         130 :             for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder )
    1344             :             {
    1345         104 :                 if( m_pImpl->eGraphicImportType == IMPORT_AS_GRAPHIC || !nBorder )
    1346             :                 {
    1347          26 :                     aBorderLine.Color = m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineColor;
    1348          26 :                     aBorderLine.InnerLineWidth = 0;
    1349          26 :                     aBorderLine.OuterLineWidth = (sal_Int16)m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineWidth;
    1350          26 :                     aBorderLine.LineDistance = 0;
    1351             :                 }
    1352             :                 PropertyIds aBorderProps[4] =
    1353             :                 {
    1354             :                     PROP_LEFT_BORDER,
    1355             :                     PROP_RIGHT_BORDER,
    1356             :                     PROP_TOP_BORDER,
    1357             :                     PROP_BOTTOM_BORDER
    1358         104 :                 };
    1359         104 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( aBorderProps[nBorder]), uno::makeAny(aBorderLine));
    1360             :             }
    1361             : 
    1362             :             // setting graphic object shadow proerties
    1363          26 :             if (m_pImpl->bShadow)
    1364             :             {
    1365             :                 // Shadow width is approximated by average of X and Y
    1366           6 :                 table::ShadowFormat aShadow;
    1367           6 :                 sal_Int32 nShadowColor = m_pImpl->nShadowColor;
    1368           6 :                 sal_Int32 nShadowWidth = (abs(m_pImpl->nShadowXDistance)
    1369           6 :                                           + abs(m_pImpl->nShadowYDistance)) / 2;
    1370             : 
    1371           6 :                 aShadow.ShadowWidth = nShadowWidth;
    1372           6 :                 aShadow.Color = nShadowColor;
    1373             :                 // Distances -ve for top and right, +ve for bottom and left
    1374           6 :                 if (m_pImpl->nShadowXDistance > 0)
    1375             :                 {
    1376           3 :                     if (m_pImpl->nShadowYDistance > 0)
    1377           2 :                         aShadow.Location = com::sun::star::table::ShadowLocation_BOTTOM_RIGHT;
    1378             :                     else
    1379           1 :                         aShadow.Location = com::sun::star::table::ShadowLocation_TOP_RIGHT;
    1380             :                 }
    1381             :                 else
    1382             :                 {
    1383           3 :                     if (m_pImpl->nShadowYDistance > 0)
    1384           1 :                         aShadow.Location = com::sun::star::table::ShadowLocation_BOTTOM_LEFT;
    1385             :                     else
    1386           2 :                         aShadow.Location = com::sun::star::table::ShadowLocation_TOP_LEFT;
    1387             :                 }
    1388             : 
    1389           6 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SHADOW_FORMAT), uno::makeAny(aShadow));
    1390             :             }
    1391             : 
    1392             :             // setting properties for all types
    1393          52 :             xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_DESCRIPTION ),
    1394          52 :                 uno::makeAny( m_pImpl->sAlternativeText ));
    1395          52 :             xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ),
    1396          52 :                 uno::makeAny( m_pImpl->title ));
    1397          26 :             if( m_pImpl->bPositionProtected )
    1398           0 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_POSITION_PROTECTED ),
    1399           0 :                     uno::makeAny(true));
    1400          26 :             if( m_pImpl->bSizeProtected )
    1401           0 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SIZE_PROTECTED ),
    1402           0 :                     uno::makeAny(true));
    1403             : 
    1404          26 :             if( m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE || m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR )
    1405             :             {
    1406           9 :                 sal_Int32 nWidth = m_pImpl->nRightPosition - m_pImpl->nLeftPosition;
    1407           9 :                 if( m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE )
    1408             :                 {
    1409           0 :                     sal_Int32 nHeight = m_pImpl->nBottomPosition - m_pImpl->nTopPosition;
    1410           0 :                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SIZE),
    1411           0 :                         uno::makeAny( awt::Size( nWidth, nHeight )));
    1412             :                 }
    1413             :                 //adjust margins
    1414           9 :                 if( (m_pImpl->nHoriOrient == text::HoriOrientation::LEFT &&
    1415           0 :                     (m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ||
    1416           9 :                         m_pImpl->nHoriRelation == text::RelOrientation::FRAME) ) ||
    1417           9 :                      (m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
    1418           0 :                        m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ))
    1419           0 :                     m_pImpl->nLeftMargin = 0;
    1420           9 :                 if((m_pImpl->nHoriOrient == text::HoriOrientation::RIGHT &&
    1421           0 :                         (m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ||
    1422           9 :                             m_pImpl->nHoriRelation == text::RelOrientation::FRAME) ) ||
    1423           9 :                     (m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
    1424           0 :                         m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ))
    1425           0 :                     m_pImpl->nRightMargin = 0;
    1426             :                 // adjust top/bottom margins
    1427          10 :                 if( m_pImpl->nVertOrient == text::VertOrientation::TOP &&
    1428           2 :                         ( m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA ||
    1429           1 :                             m_pImpl->nVertRelation == text::RelOrientation::PAGE_FRAME))
    1430           0 :                     m_pImpl->nTopMargin = 0;
    1431           9 :                 if( m_pImpl->nVertOrient == text::VertOrientation::BOTTOM &&
    1432           0 :                         ( m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA ||
    1433           0 :                             m_pImpl->nVertRelation == text::RelOrientation::PAGE_FRAME))
    1434           0 :                     m_pImpl->nBottomMargin = 0;
    1435           9 :                 if( m_pImpl->nVertOrient == text::VertOrientation::BOTTOM &&
    1436           0 :                         m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA )
    1437           0 :                     m_pImpl->nBottomMargin = 0;
    1438             : 
    1439             :                 //adjust alignment
    1440           9 :                 if( m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
    1441           0 :                         m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME )
    1442             :                 {
    1443             :                     // convert 'left to page' to 'from left -<width> to page text area'
    1444           0 :                     m_pImpl->nHoriOrient = text::HoriOrientation::NONE;
    1445           0 :                     m_pImpl->nHoriRelation = text::RelOrientation::PAGE_PRINT_AREA;
    1446           0 :                     m_pImpl->nLeftPosition = - nWidth;
    1447             :                 }
    1448           9 :                 else if( m_pImpl->nHoriOrient == text::HoriOrientation::OUTSIDE &&
    1449           0 :                         m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME )
    1450             :                 {
    1451             :                     // convert 'right to page' to 'from left 0 to right page border'
    1452           0 :                     m_pImpl->nHoriOrient = text::HoriOrientation::NONE;
    1453           0 :                     m_pImpl->nHoriRelation = text::RelOrientation::PAGE_RIGHT;
    1454           0 :                     m_pImpl->nLeftPosition = 0;
    1455             :                 }
    1456             : 
    1457          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_ORIENT          ),
    1458          18 :                     uno::makeAny(m_pImpl->nHoriOrient));
    1459          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_ORIENT_POSITION),
    1460          18 :                     uno::makeAny(m_pImpl->nLeftPosition));
    1461          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_ORIENT_RELATION ),
    1462          18 :                     uno::makeAny(m_pImpl->nHoriRelation));
    1463          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_TOGGLE ),
    1464          18 :                     uno::makeAny(m_pImpl->bPageToggle));
    1465          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_ORIENT          ),
    1466          18 :                     uno::makeAny(m_pImpl->nVertOrient));
    1467          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_ORIENT_POSITION),
    1468          18 :                     uno::makeAny(m_pImpl->nTopPosition));
    1469          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_ORIENT_RELATION ),
    1470          18 :                 uno::makeAny(m_pImpl->nVertRelation));
    1471             : 
    1472           9 :                 bool bOpaque = m_pImpl->bOpaque && !m_pImpl->rDomainMapper.IsInHeaderFooter( );
    1473           9 :                 if( !bOpaque )
    1474             :                 {
    1475           2 :                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_OPAQUE ),
    1476           2 :                         uno::makeAny(bOpaque));
    1477             :                 }
    1478          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND ),
    1479          18 :                         uno::makeAny(m_pImpl->nWrap));
    1480             : 
    1481          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND_CONTOUR ),
    1482          18 :                     uno::makeAny(m_pImpl->bContour));
    1483          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_CONTOUR_OUTSIDE ),
    1484          18 :                     uno::makeAny(m_pImpl->bContourOutside));
    1485           9 :                 m_pImpl->applyMargins(xGraphicObjectProperties);
    1486             : 
    1487          18 :                 if( m_pImpl->eColorMode == drawing::ColorMode_STANDARD &&
    1488           9 :                     m_pImpl->nContrast == -70 &&
    1489           0 :                     m_pImpl->nBrightness == 70 )
    1490             :                 {
    1491             :                     // strange definition of WATERMARK!
    1492           0 :                     m_pImpl->nContrast = 0;
    1493           0 :                     m_pImpl->nBrightness = 0;
    1494           0 :                     m_pImpl->eColorMode = drawing::ColorMode_WATERMARK;
    1495             :                 }
    1496             : 
    1497          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_ADJUST_CONTRAST ),
    1498          18 :                     uno::makeAny((sal_Int16)m_pImpl->nContrast));
    1499          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_ADJUST_LUMINANCE ),
    1500          18 :                     uno::makeAny((sal_Int16)m_pImpl->nBrightness));
    1501           9 :                 if(m_pImpl->eColorMode != drawing::ColorMode_STANDARD)
    1502           0 :                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_GRAPHIC_COLOR_MODE ),
    1503           0 :                         uno::makeAny(m_pImpl->eColorMode));
    1504           9 :                 if(m_pImpl->fGamma > 0. )
    1505           0 :                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_GAMMA ),
    1506           0 :                         uno::makeAny(m_pImpl->fGamma ));
    1507           9 :                 if(m_pImpl->bHoriFlip)
    1508             :                 {
    1509           0 :                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_MIRRORED_ON_EVEN_PAGES ),
    1510           0 :                         uno::makeAny( m_pImpl->bHoriFlip ));
    1511           0 :                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_MIRRORED_ON_ODD_PAGES ),
    1512           0 :                         uno::makeAny( m_pImpl->bHoriFlip ));
    1513             :                 }
    1514             : 
    1515           9 :                 if( m_pImpl->bVertFlip )
    1516           0 :                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_MIRRORED ),
    1517           0 :                         uno::makeAny( m_pImpl->bVertFlip ));
    1518          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_BACK_COLOR ),
    1519          18 :                     uno::makeAny( m_pImpl->nFillColor ));
    1520             : 
    1521           9 :                 if( m_pImpl->zOrder >= 0 )
    1522             :                 {
    1523           5 :                     GraphicZOrderHelper* zOrderHelper = m_pImpl->rDomainMapper.graphicZOrderHelper();
    1524          10 :                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_Z_ORDER ),
    1525          10 :                         uno::makeAny( zOrderHelper->findZOrder( m_pImpl->zOrder )));
    1526           5 :                     zOrderHelper->addItem( xGraphicObjectProperties, m_pImpl->zOrder );
    1527             :                 }
    1528             : 
    1529             :                 //there seems to be no way to detect the original size via _real_ API
    1530           9 :                 uno::Reference< beans::XPropertySet > xGraphicProperties( xGraphic, uno::UNO_QUERY_THROW );
    1531           9 :                 awt::Size aGraphicSize, aGraphicSizePixel;
    1532           9 :                 xGraphicProperties->getPropertyValue(rPropNameSupplier.GetName( PROP_SIZE100th_M_M )) >>= aGraphicSize;
    1533           9 :                 xGraphicProperties->getPropertyValue(rPropNameSupplier.GetName( PROP_SIZE_PIXEL )) >>= aGraphicSizePixel;
    1534             : 
    1535          18 :                 uno::Any aContourPolyPolygon;
    1536          14 :                 if( aGraphicSize.Width && aGraphicSize.Height &&
    1537           5 :                     m_pImpl->mpWrapPolygon.get() != NULL)
    1538             :                 {
    1539           0 :                     WrapPolygon::Pointer_t pCorrected = m_pImpl->mpWrapPolygon->correctWordWrapPolygon(aGraphicSize);
    1540           0 :                     aContourPolyPolygon <<= pCorrected->getPointSequenceSequence();
    1541             :                 }
    1542             : 
    1543          18 :                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_CONTOUR_POLY_POLYGON),
    1544          18 :                                                            aContourPolyPolygon);
    1545             : 
    1546           9 :                 if( aGraphicSize.Width && aGraphicSize.Height )
    1547             :                 {
    1548             :                     //todo: i71651 graphic size is not provided by the GraphicDescriptor
    1549           5 :                     lcl_CalcCrop( m_pImpl->nTopCrop, aGraphicSize.Height );
    1550           5 :                     lcl_CalcCrop( m_pImpl->nBottomCrop, aGraphicSize.Height );
    1551           5 :                     lcl_CalcCrop( m_pImpl->nLeftCrop, aGraphicSize.Width );
    1552           5 :                     lcl_CalcCrop( m_pImpl->nRightCrop, aGraphicSize.Width );
    1553             : 
    1554             : 
    1555             :                     // We need a separate try-catch here, otherwise a bad crop setting will also nuke the size settings as well.
    1556             :                     try
    1557             :                     {
    1558          10 :                         xGraphicProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_GRAPHIC_CROP ),
    1559          15 :                                 uno::makeAny(text::GraphicCrop(m_pImpl->nTopCrop, m_pImpl->nBottomCrop, m_pImpl->nLeftCrop, m_pImpl->nRightCrop)));
    1560             :                     }
    1561           5 :                     catch (const uno::Exception& e)
    1562             :                     {
    1563             :                         SAL_WARN("writerfilter", "failed. Message :" << e.Message);
    1564             :                     }
    1565           9 :                 }
    1566             : 
    1567             :             }
    1568             : 
    1569          26 :             if(m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_INLINE || m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR)
    1570             :             {
    1571          26 :                 if( m_pImpl->getXSize() && m_pImpl->getYSize() )
    1572          52 :                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SIZE),
    1573          52 :                         uno::makeAny( awt::Size( m_pImpl->getXSize(), m_pImpl->getYSize() )));
    1574          26 :                 m_pImpl->applyMargins(xGraphicObjectProperties);
    1575             :                 try
    1576             :                 {
    1577          26 :                     if( !m_pImpl->sName.isEmpty() )
    1578             :                     {
    1579          13 :                         uno::Reference< container::XNamed > xNamed( xGraphicObjectProperties, uno::UNO_QUERY_THROW );
    1580          13 :                         xNamed->setName( m_pImpl->sName );
    1581             :                     }
    1582             :                 }
    1583           0 :                 catch( const uno::Exception& e )
    1584             :                 {
    1585             :                     SAL_WARN("writerfilter", "failed. Message :" << e.Message);
    1586             :                 }
    1587          26 :             }
    1588          26 :         }
    1589             :     }
    1590           0 :     catch( const uno::Exception& e )
    1591             :     {
    1592             :         SAL_WARN("writerfilter", "failed. Message :" << e.Message);
    1593             :     }
    1594          26 :     return xGraphicObject;
    1595             : }
    1596             : 
    1597             : 
    1598             : 
    1599           0 : void GraphicImport::data(const sal_uInt8* buf, size_t len, writerfilter::Reference<Properties>::Pointer_t /*ref*/)
    1600             : {
    1601           0 :         PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
    1602             : 
    1603           0 :         ::com::sun::star::beans::PropertyValues aMediaProperties( 1 );
    1604           0 :         aMediaProperties[0].Name = rPropNameSupplier.GetName(PROP_INPUT_STREAM);
    1605             : 
    1606           0 :         uno::Reference< io::XInputStream > xIStream = new XInputStreamHelper( buf, len, m_pImpl->bIsBitmap );
    1607           0 :         aMediaProperties[0].Value <<= xIStream;
    1608             : 
    1609           0 :         m_xGraphicObject = createGraphicObject( aMediaProperties );
    1610           0 : }
    1611             : 
    1612             : 
    1613           0 : void GraphicImport::lcl_startSectionGroup()
    1614             : {
    1615           0 : }
    1616             : 
    1617             : 
    1618           0 : void GraphicImport::lcl_endSectionGroup()
    1619             : {
    1620           0 : }
    1621             : 
    1622             : 
    1623           0 : void GraphicImport::lcl_startParagraphGroup()
    1624             : {
    1625           0 : }
    1626             : 
    1627             : 
    1628           0 : void GraphicImport::lcl_endParagraphGroup()
    1629             : {
    1630           0 : }
    1631             : 
    1632             : 
    1633           0 : void GraphicImport::lcl_startCharacterGroup()
    1634             : {
    1635           0 : }
    1636             : 
    1637             : 
    1638           0 : void GraphicImport::lcl_endCharacterGroup()
    1639             : {
    1640           0 : }
    1641             : 
    1642             : 
    1643           0 : void GraphicImport::lcl_text(const sal_uInt8 * /*_data*/, size_t /*len*/)
    1644             : {
    1645           0 : }
    1646             : 
    1647             : 
    1648           0 : void GraphicImport::lcl_utext(const sal_uInt8 * /*_data*/, size_t /*len*/)
    1649             : {
    1650           0 : }
    1651             : 
    1652             : 
    1653           0 : void GraphicImport::lcl_props(writerfilter::Reference<Properties>::Pointer_t /*ref*/)
    1654             : {
    1655           0 : }
    1656             : 
    1657             : 
    1658           0 : void GraphicImport::lcl_table(Id /*name*/, writerfilter::Reference<Table>::Pointer_t /*ref*/)
    1659             : {
    1660           0 : }
    1661             : 
    1662             : 
    1663           0 : void GraphicImport::lcl_substream(Id /*name*/, ::writerfilter::Reference<Stream>::Pointer_t /*ref*/)
    1664             : {
    1665           0 : }
    1666             : 
    1667             : 
    1668           0 : void GraphicImport::lcl_info(const string & /*info*/)
    1669             : {
    1670           0 : }
    1671             : 
    1672           0 : void GraphicImport::lcl_startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > /*xShape*/ )
    1673             : {
    1674           0 : }
    1675             : 
    1676           0 : void GraphicImport::lcl_endShape( )
    1677             : {
    1678           0 : }
    1679             : 
    1680             : 
    1681             : 
    1682          28 : bool    GraphicImport::IsGraphic() const
    1683             : {
    1684          28 :     return m_pImpl->bIsGraphic;
    1685             : }
    1686             : 
    1687             : }
    1688          24 : }
    1689             : 
    1690             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10