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

Generated by: LCOV version 1.10