Kaydet (Commit) 2b5bf2f1 authored tarafından Oliver Specht's avatar Oliver Specht

graphic import improved

üst 8b66e6b3
......@@ -4,9 +4,9 @@
*
* $RCSfile: ConversionHelper.cxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: os $ $Date: 2006-11-06 15:06:27 $
* last change: $Author: os $ $Date: 2006-11-20 12:19:03 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -51,6 +51,7 @@
using namespace com::sun::star;
namespace dmapper{
namespace ConversionHelper{
#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
......@@ -106,7 +107,7 @@ namespace dmapper{
#define DOUBLE_LINE10_IN LINE_WIDTH_0
#define DOUBLE_LINE10_DIST LINE_WIDTH_2
sal_Int32 ConversionHelper::MakeBorderLine( sal_Int32 nSprmValue, table::BorderLine& rToFill )
sal_Int32 MakeBorderLine( sal_Int32 nSprmValue, table::BorderLine& rToFill )
{
//Border
//borders are defined as:
......@@ -127,7 +128,7 @@ sal_Int32 ConversionHelper::MakeBorderLine( sal_Int32 nSprmValue, table::BorderL
sal_Int32 nLineThickness = TWIP_TO_MM100(nLineThicknessTwip);
return MakeBorderLine( nLineThickness, nLineType, nLineColor, nLineDistance, rToFill);
}
sal_Int32 ConversionHelper::MakeBorderLine( sal_Int32 nLineThickness, sal_Int32 nLineType,
sal_Int32 MakeBorderLine( sal_Int32 nLineThickness, sal_Int32 nLineType,
sal_Int32 nLineColor, sal_Int32 nLineDistance,
table::BorderLine& rToFill )
{
......@@ -346,7 +347,7 @@ bool lcl_IsNotAM(::rtl::OUString& rFmt, sal_Int32 nPos)
);
}
::rtl::OUString ConversionHelper::ConvertMSFormatStringToSO(
::rtl::OUString ConvertMSFormatStringToSO(
const ::rtl::OUString& rFormat, lang::Locale& rLocale, bool bHijri)
{
::rtl::OUString sFormat(rFormat);
......@@ -452,5 +453,12 @@ bool lcl_IsNotAM(::rtl::OUString& rFmt, sal_Int32 nPos)
return aNewFormat.makeStringAndClear();
}
/*-------------------------------------------------------------------------
-----------------------------------------------------------------------*/
sal_Int32 convertToMM100(sal_Int32 _t)
{
return TWIP_TO_MM100( _t );
}
} // namespace ConversionHelper
} //namespace dmapper
......@@ -4,9 +4,9 @@
*
* $RCSfile: ConversionHelper.hxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: os $ $Date: 2006-11-06 15:06:27 $
* last change: $Author: os $ $Date: 2006-11-20 12:19:03 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -62,6 +62,7 @@ namespace ConversionHelper{
//convert the number format string form MS format to SO format
::rtl::OUString ConvertMSFormatStringToSO(
const ::rtl::OUString& rFormat, ::com::sun::star::lang::Locale& rLocale, bool bHijri);
sal_Int32 convertToMM100(sal_Int32 _t);
} // namespace ConversionHelper
} //namespace dmapper
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: DomainMapper.cxx,v $
*
* $Revision: 1.6 $
* $Revision: 1.7 $
*
* last change: $Author: os $ $Date: 2006-11-06 15:06:27 $
* last change: $Author: os $ $Date: 2006-11-20 12:19:03 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -1582,11 +1582,11 @@ void DomainMapper::sprm( doctok::Sprm& sprm_, PropertyMapPtr rContext, SprmType
rContext->Insert(
eSprmType == SPRM_DEFAULT ? PROP_PARA_LEFT_MARGIN : PROP_LEFT_MARGIN,
uno::makeAny( lcl_convertToMM100(nIntValue ) ));
uno::makeAny( ConversionHelper::convertToMM100( nIntValue ) ));
else if(eSprmType == SPRM_DEFAULT)
rContext->Insert(
PROP_PARA_RIGHT_MARGIN,
uno::makeAny( lcl_convertToMM100(nIntValue ) ));
uno::makeAny( ConversionHelper::convertToMM100(nIntValue ) ));
//TODO: what happens to the right margins in numberings?
break;
case 18: // sprmPNest
......@@ -1599,7 +1599,7 @@ void DomainMapper::sprm( doctok::Sprm& sprm_, PropertyMapPtr rContext, SprmType
/* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 1 */
rContext->Insert(
eSprmType == SPRM_DEFAULT ? PROP_PARA_FIRST_LINE_INDENT : PROP_FIRST_LINE_OFFSET,
uno::makeAny( lcl_convertToMM100(nIntValue ) ));
uno::makeAny( ConversionHelper::convertToMM100(nIntValue ) ));
break;
case 20 : // sprmPDyaLine
case 0x6412: // sprmPDyaLine
......@@ -1618,12 +1618,12 @@ void DomainMapper::sprm( doctok::Sprm& sprm_, PropertyMapPtr rContext, SprmType
if(nDistance < 0)
{
aSpacing.Mode = style::LineSpacingMode::FIX;
aSpacing.Height = sal_Int16(lcl_convertToMM100(-nDistance));
aSpacing.Height = sal_Int16(ConversionHelper::convertToMM100(-nDistance));
}
else if(nDistance >0)
{
aSpacing.Mode = style::LineSpacingMode::MINIMUM;
aSpacing.Height = sal_Int16(lcl_convertToMM100(nDistance));
aSpacing.Height = sal_Int16(ConversionHelper::convertToMM100(nDistance));
}
}
rContext->Insert(PROP_PARA_LINE_SPACING, uno::makeAny( aSpacing ));
......@@ -1632,12 +1632,12 @@ void DomainMapper::sprm( doctok::Sprm& sprm_, PropertyMapPtr rContext, SprmType
case 21 : // legacy version
case 0xA413: // sprmPDyaBefore
/* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 1 */
rContext->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny( lcl_convertToMM100( nIntValue ) ));
rContext->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny( ConversionHelper::convertToMM100( nIntValue ) ));
break;
case 22 :
case 0xA414: // sprmPDyaAfter
/* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 1 */
rContext->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny( lcl_convertToMM100( nIntValue ) ));
rContext->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertToMM100( nIntValue ) ));
break;
case 23: //sprmPChgTabs
......@@ -2142,7 +2142,7 @@ void DomainMapper::sprm( doctok::Sprm& sprm_, PropertyMapPtr rContext, SprmType
//Kerning half point values
//TODO: there are two kerning values -
// in ww8par6.cxx 0x484b is used as boolean AutoKerning
rContext->Insert(PROP_CHAR_CHAR_KERNING, uno::makeAny( sal_Int16(lcl_convertToMM100(sal_Int16(nIntValue))) ) );
rContext->Insert(PROP_CHAR_CHAR_KERNING, uno::makeAny( sal_Int16(ConversionHelper::convertToMM100(sal_Int16(nIntValue))) ) );
break;
case 0x484B: // sprmCHpsKern auto kerning is bound to a minimum font size in Word - but not in Writer :-(
/* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */
......@@ -2777,7 +2777,11 @@ void DomainMapper::props(doctok::Reference<Properties>::Pointer_t ref)
string sType = ref->getType();
if( sType == "PICF" )
{
m_pImpl->ImportGraphic(ref);
m_pImpl->ImportGraphic(ref, false);
}
else if( sType == "FSPA" )
{
m_pImpl->ImportGraphic(ref, true);
}
else
ref->resolve(*this);
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: DomainMapper_Impl.cxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: os $ $Date: 2006-11-02 12:37:24 $
* last change: $Author: os $ $Date: 2006-11-20 12:19:03 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -505,14 +505,14 @@ void DomainMapper_Impl::ModifyCurrentTabStop( doctok::Id nId, sal_Int32 nValue)
{
case NS_rtf::LN_dxaAdd: //set tab
m_aCurrentTabStops.push_back(
DeletableTabStop(style::TabStop(lcl_convertToMM100(nValue), style::TabAlign_LEFT, ' ', ' ')));
DeletableTabStop(style::TabStop(ConversionHelper::convertToMM100(nValue), style::TabAlign_LEFT, ' ', ' ')));
break;
case NS_rtf::LN_dxaDel: //deleted tab
{
//mark the tab stop at the given position as deleted
::std::vector<DeletableTabStop>::iterator aIt = m_aCurrentTabStops.begin();
::std::vector<DeletableTabStop>::iterator aEndIt = m_aCurrentTabStops.end();
sal_Int32 nConverted = lcl_convertToMM100(nValue);
sal_Int32 nConverted = ConversionHelper::convertToMM100(nValue);
for( ; aIt != aEndIt; ++aIt)
{
if( aIt->Position == nConverted )
......@@ -784,13 +784,6 @@ void DomainMapper_Impl::PopPageHeaderFooter()
{
m_aTextAppendStack.pop();
}
/*-------------------------------------------------------------------------
-----------------------------------------------------------------------*/
sal_Int32 lcl_convertToMM100(sal_Int32 _t)
{
return TWIP_TO_MM100( _t );
}
/*-- 12.09.2006 08:07:55---------------------------------------------------
-----------------------------------------------------------------------*/
......@@ -1602,19 +1595,19 @@ uno::Reference< beans::XPropertySet > DomainMapper_Impl::FindOrCreateFieldMaster
/*-- 01.11.2006 14:57:44---------------------------------------------------
-----------------------------------------------------------------------*/
GraphicImportPtr DomainMapper_Impl::GetGraphicImport()
GraphicImportPtr DomainMapper_Impl::GetGraphicImport(bool bIsShape)
{
if(!m_pGraphicImport)
m_pGraphicImport.reset( new GraphicImport( m_xComponentContext, m_xTextFactory ) );
m_pGraphicImport.reset( new GraphicImport( m_xComponentContext, m_xTextFactory, bIsShape ) );
return m_pGraphicImport;
}
/*-- 01.11.2006 09:25:40---------------------------------------------------
-----------------------------------------------------------------------*/
void DomainMapper_Impl::ImportGraphic(doctok::Reference< doctok::Properties >::Pointer_t ref)
void DomainMapper_Impl::ImportGraphic(doctok::Reference< doctok::Properties >::Pointer_t ref, bool bIsShape)
{
//create the graphic
ref->resolve( *GetGraphicImport() );
ref->resolve( *GetGraphicImport(bIsShape) );
//insert it into the document at the current cursor position
appendTextContent( m_pGraphicImport->GetGraphicObject() );
m_pGraphicImport.reset();
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: DomainMapper_Impl.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: os $ $Date: 2006-11-02 12:37:24 $
* last change: $Author: os $ $Date: 2006-11-20 12:19:03 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -86,8 +86,8 @@ namespace dmapper {
using namespace writerfilter;
using namespace com::sun::star;
#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
sal_Int32 lcl_convertToMM100(sal_Int32 _t);
//#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
//sal_Int32 lcl_convertToMM100(sal_Int32 _t);
/*-- 14.06.2006 07:42:52---------------------------------------------------
property stack element
......@@ -236,9 +236,9 @@ public:
m_pLFOTable.reset( new LFOTable );
return m_pLFOTable;
}
GraphicImportPtr GetGraphicImport();
GraphicImportPtr GetGraphicImport(bool bIsShape );
// this method deletes the current m_pGraphicImport after import
void ImportGraphic(doctok::Reference< doctok::Properties>::Pointer_t );
void ImportGraphic(doctok::Reference< doctok::Properties>::Pointer_t, bool bIsShape );
void InitTabStopFromStyle( const ::com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop >& rInitTabStops );
void ModifyCurrentTabStop( doctok::Id nId, sal_Int32 nValue);
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: GraphicImport.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: hbrinkm $ $Date: 2006-11-08 09:50:27 $
* last change: $Author: os $ $Date: 2006-11-20 12:19:03 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -32,6 +32,7 @@
* MA 02111-1307 USA
*
************************************************************************/
#ifndef INCLUDED_GRAPHICIMPORT_HXX
#include <GraphicImport.hxx>
#endif
......@@ -41,6 +42,9 @@
#ifndef INCLUDED_RESOURCESIDS
#include <doctok/resourceids.hxx>
#endif
#ifndef INCLUDED_DMAPPER_CONVERSIONHELPER_HXX
#include <ConversionHelper.hxx>
#endif
#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
#include <com/sun/star/uno/XComponentContext.hpp>
#endif
......@@ -50,8 +54,11 @@
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#ifndef _COM_SUN_STAR_AWT_SIZE_HPP_
#include <com/sun/star/awt/Size.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_COLORMODE_HPP_
#include <com/sun/star/drawing/ColorMode.hpp>
#endif
#ifndef _COM_SUN_STAR_GRAPHIC_XGRAPHICPROVIDER_HPP_
#include <com/sun/star/graphic/XGraphicProvider.hpp>
......@@ -59,12 +66,31 @@
#ifndef _COM_SUN_STAR_GRAPHIC_XGRAPHIC_HPP_
#include <com/sun/star/graphic/XGraphicr.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_GRAPHICCROP_HPP_
#include <com/sun/star/text/GraphicCrop.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTCONTENT_HPP_
#include <com/sun/star/text/XTextContent.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP_
#include <com/sun/star/text/TextContentAnchorType.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_HORIORIENTATION_HDL_
#include <com/sun/star/text/HoriOrientation.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_RELORIENTATION_HDL_
#include <com/sun/star/text/RelOrientation.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_VERTORIENTATION_HDL_
#include <com/sun/star/text/VertOrientation.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_WRAPTEXTMODE_HPP_
#include <com/sun/star/text/WrapTextMode.hpp>
#endif
#include <iostream>
......@@ -173,15 +199,31 @@ struct GraphicBorderLine
};
struct GraphicImport_Impl
{
bool bIsShapeImport;
sal_Int32 nHoriScaling;
sal_Int32 nVertScaling;
sal_Int32 nXSize;
sal_Int32 nYSize;
sal_Int32 nLeftPosition;
sal_Int32 nTopPosition;
sal_Int32 nRightPosition;
sal_Int32 nBottomPosition;
sal_Int32 nLeftCrop;
sal_Int32 nTopCrop;
sal_Int32 nRightCrop;
sal_Int32 nBottomCrop;
sal_Int32 nWrap;
bool bContour;
bool bIgnoreWRK;
sal_Int32 nContrast;
sal_Int32 nBrightness;
double fGamma;
drawing::ColorMode eColorMode;
GraphicBorderLine aBorders[4];
sal_Int32 nCurrentBorderLine;
......@@ -192,11 +234,19 @@ struct GraphicImport_Impl
bool bHoriFlip;
bool bVertFlip;
GraphicImport_Impl() :
nHoriScaling(0)
bool bInShapeOptionMode;
sal_Int32 nShapeOptionType;
GraphicImport_Impl(bool bIsShape) :
bIsShapeImport( bIsShape )
,nHoriScaling(0)
,nVertScaling(0)
,nXSize(0)
,nYSize(0)
,nLeftPosition(0)
,nTopPosition(0)
,nRightPosition(0)
,nBottomPosition(0)
,nLeftCrop(0)
,nTopCrop (0)
,nRightCrop (0)
......@@ -207,14 +257,24 @@ struct GraphicImport_Impl
,nBitsPerPixel(0)
,bHoriFlip(false)
,bVertFlip(false)
,bInShapeOptionMode(false)
,nShapeOptionType(0)
,nWrap(0)
,bContour(false)
,bIgnoreWRK(true)
,nContrast(0)
,nBrightness(100)
,eColorMode( drawing::ColorMode_STANDARD )
,fGamma( -1.0 )
{}
};
/*-- 01.11.2006 09:42:42---------------------------------------------------
-----------------------------------------------------------------------*/
GraphicImport::GraphicImport(uno::Reference < uno::XComponentContext > xComponentContext,
uno::Reference< lang::XMultiServiceFactory > xTextFactory )
: m_pImpl( new GraphicImport_Impl)
uno::Reference< lang::XMultiServiceFactory > xTextFactory,
bool bIsShape )
: m_pImpl( new GraphicImport_Impl( bIsShape ))
,m_xComponentContext( xComponentContext )
,m_xTextFactory( xTextFactory)
{
......@@ -245,6 +305,8 @@ void GraphicImport::attribute(doctok::Id Name, doctok::Value & val)
case NS_rtf::LN_BRCLEFT: //left border
case NS_rtf::LN_BRCBOTTOM: //bottom border
case NS_rtf::LN_BRCRIGHT: //right border
case NS_rtf::LN_shape: //shape
case NS_rtf::LN_blip: //the binary graphic data in a shape
{
switch(Name)
{
......@@ -260,6 +322,9 @@ void GraphicImport::attribute(doctok::Id Name, doctok::Value & val)
case NS_rtf::LN_BRCRIGHT: //right border
m_pImpl->nCurrentBorderLine = BORDER_RIGHT;
break;
case NS_rtf::LN_shpopt:
m_pImpl->bInShapeOptionMode = true;
break;
default:;
}
doctok::Reference<Properties>::Pointer_t pProperties = val.getProperties();
......@@ -267,6 +332,13 @@ void GraphicImport::attribute(doctok::Id Name, doctok::Value & val)
{
pProperties->resolve(*this);
}
switch(Name)
{
case NS_rtf::LN_shpopt:
m_pImpl->bInShapeOptionMode = false;
break;
default:;
}
}
break;
case NS_rtf::LN_BM_RCWINMF: //windows bitmap structure - if it's a bitmap
......@@ -276,10 +348,10 @@ void GraphicImport::attribute(doctok::Id Name, doctok::Value & val)
break;
case NS_rtf::LN_MX: m_pImpl->nHoriScaling = nIntValue; break;// hori scaling in 0.001%
case NS_rtf::LN_MY: m_pImpl->nVertScaling = nIntValue; break;// vert scaling in 0.001%
case NS_rtf::LN_DXACROPLEFT: m_pImpl->nLeftCrop = nIntValue; break;// left crop in twips
case NS_rtf::LN_DYACROPTOP: m_pImpl->nTopCrop = nIntValue; break;// top crop in twips
case NS_rtf::LN_DXACROPRIGHT: m_pImpl->nRightCrop = nIntValue; break;// right crop in twips
case NS_rtf::LN_DYACROPBOTTOM: m_pImpl->nBottomCrop = nIntValue; break;// bottom crop in twips
case NS_rtf::LN_DXACROPLEFT: m_pImpl->nLeftCrop = ConversionHelper::convertToMM100(nIntValue); break;// left crop in twips
case NS_rtf::LN_DYACROPTOP: m_pImpl->nTopCrop = ConversionHelper::convertToMM100(nIntValue); break;// top crop in twips
case NS_rtf::LN_DXACROPRIGHT: m_pImpl->nRightCrop = ConversionHelper::convertToMM100(nIntValue); break;// right crop in twips
case NS_rtf::LN_DYACROPBOTTOM: m_pImpl->nBottomCrop = ConversionHelper::convertToMM100(nIntValue); break;// bottom crop in twips
case NS_rtf::LN_BRCL: break;//border type - legacy -
case NS_rtf::LN_FFRAMEEMPTY: break;// picture consists of a single frame
case NS_rtf::LN_FBITMAP: break;//1 if it's a bitmap ???
......@@ -329,10 +401,102 @@ void GraphicImport::attribute(doctok::Id Name, doctok::Value & val)
case NS_rtf::LN_shptypename: break;// shape type name
case NS_rtf::LN_shppid: break;
case NS_rtf::LN_shppid: m_pImpl->nShapeOptionType = nIntValue; break; //type of shape option
case NS_rtf::LN_shpfBid: break;
case NS_rtf::LN_shpfComplex:break;
case NS_rtf::LN_shpop: break;
case NS_rtf::LN_shpop:
{
sal_Int32 nTwipValue = ConversionHelper::convertToMM100(nIntValue);
switch( m_pImpl->nShapeOptionType )
{
case 256 : m_pImpl->nTopCrop = nTwipValue; break;// rtf:shpcropFromTop
case 257 : m_pImpl->nBottomCrop= nTwipValue; break;// rtf:shpcropFromBottom
case 258 : m_pImpl->nLeftCrop = nTwipValue; break;// rtf:shpcropFromLeft
case 259 : m_pImpl->nRightCrop = nTwipValue;break;// rtf:shpcropFromRight
case 260: break; // rtf:shppib
case 261: break; // rtf:shppibName
case 262: // rtf:shppibFlags
/*
* // MSOBLIPFLAGS flags for pictures
typedef enum
{
msoblipflagDefault = 0,
msoblipflagComment = 0, // Blip name is a comment
msoblipflagFile, // Blip name is a file name
msoblipflagURL, // Blip name is a full URL
msoblipflagType = 3, // Mask to extract type
// Or the following flags with any of the above.
msoblipflagDontSave = 4, // A "dont" is the depression in the metal
// body work of an automobile caused when a
// cyclist violently thrusts his or her nose
// at it, thus a DontSave is another name for
// a cycle lane.
msoblipflagDoNotSave = 4, // For those who prefer English
msoblipflagLinkToFile = 8,
};
*
* */
break;
case 264: // rtf:shppictureContrast docu: "1<<16"
/*
0x10000 is msoffice 50%
< 0x10000 is in units of 1/50th of 0x10000 per 1%
> 0x10000 is in units where
a msoffice x% is stored as 50/(100-x) * 0x10000
plus, a (ui) microsoft % ranges from 0 to 100, OOO
from -100 to 100, so also normalize into that range
*/
if ( nIntValue > 0x10000 )
{
double fX = nIntValue;
fX /= 0x10000;
fX /= 51; // 50 + 1 to round
fX = 1/fX;
m_pImpl->nContrast = static_cast<sal_Int32>(fX);
m_pImpl->nContrast -= 100;
m_pImpl->nContrast = -m_pImpl->nContrast;
m_pImpl->nContrast = (m_pImpl->nContrast-50)*2;
}
else if ( nIntValue == 0x10000 )
m_pImpl->nContrast = 0;
else
{
m_pImpl->nContrast = nIntValue * 101; //100 + 1 to round
m_pImpl->nContrast /= 0x10000;
m_pImpl->nContrast -= 100;
}
break;
case 265: // rtf:shppictureBrightness
m_pImpl->nBrightness = ( (sal_Int32) nIntValue / 327 );
break;
case 266: // rtf:shppictureGamma
m_pImpl->fGamma = double(nIntValue/655);
break;
case 267: break; // rtf:shppictureId
case 268: break; // rtf:shppictureDblCrMod
case 269: break; // rtf:shppictureFillCrMod
case 270: break; // rtf:shppictureLineCrMod
case 319: // rtf:shppictureActive
switch( nIntValue & 0x06 )
{
case 0 : m_pImpl->eColorMode = drawing::ColorMode_STANDARD; break;
case 4 : m_pImpl->eColorMode = drawing::ColorMode_GREYS; break;
case 6 : m_pImpl->eColorMode = drawing::ColorMode_MONO; break;
default:;
}
break;
case 385: break; // rtf:shpfillColor
case 386: break; // rtf:shpfillOpacity
case 447: break; // rtf:shpfNoFillHitTest
case 511: break; // rtf:shpfNoLineDrawDash
case 899: break; // rtf:shppWrapPolygonVertices
case 959: break; // rtf:shpfPrint
default:;
}
}
break;
case NS_rtf::LN_shpname: break;
case NS_rtf::LN_shpvalue: break;
......@@ -392,26 +556,75 @@ void GraphicImport::attribute(doctok::Id Name, doctok::Value & val)
// case NS_rtf::LN_LINEWIDTH = 10373;
// case NS_rtf::LN_LINETYPE = 10374;
// case NS_rtf::LN_SPID = 10407;
// case NS_rtf::LN_XALEFT = 10408;
// case NS_rtf::LN_YATOP = 10409;
// case NS_rtf::LN_XARIGHT = 10410;
// case NS_rtf::LN_YABOTTOM = 10411;
// case NS_rtf::LN_FHDR = 10412;
// case NS_rtf::LN_BX = 10413;
// case NS_rtf::LN_BY = 10414;
// case NS_rtf::LN_WR = 10415;
// case NS_rtf::LN_WRK = 10416;
// case NS_rtf::LN_FRCASIMPLE = 10417;
// case NS_rtf::LN_FBELOWTEXT = 10418;
// case NS_rtf::LN_FANCHORLOCK = 10419;
// case NS_rtf::LN_CTXBX = 10420;
// case NS_rtf::LN_CH = 10421;
// case NS_rtf::LN_UNUSED0_5 = 10422;
// case NS_rtf::LN_FLT = 10423;
// case NS_rtf::LN_shpLeft = 10424;
// case NS_rtf::LN_shpTop = 10425;
case NS_rtf::LN_SPID:
case NS_rtf::LN_XALEFT: m_pImpl->nLeftPosition = ConversionHelper::convertToMM100(nIntValue); break; //left position
case NS_rtf::LN_YATOP: m_pImpl->nTopPosition = ConversionHelper::convertToMM100(nIntValue); break; //top position
case NS_rtf::LN_XARIGHT: m_pImpl->nRightPosition = ConversionHelper::convertToMM100(nIntValue); break; //right position
case NS_rtf::LN_YABOTTOM: m_pImpl->nBottomPosition = ConversionHelper::convertToMM100(nIntValue); break;//bottom position
case NS_rtf::LN_FHDR:
case NS_rtf::LN_BX:
case NS_rtf::LN_BY: break;
case NS_rtf::LN_WR: //wrapping
switch( nIntValue )
{
case 0: //0 like 2, but doesn't require absolute object
m_pImpl->bIgnoreWRK = false;
case 2: //2 wrap around absolute object
m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
break;
case 1: //1 no text next to shape
m_pImpl->nWrap = text::WrapTextMode_NONE;
break;
case 3: //3 wrap as if no object present
m_pImpl->nWrap = text::WrapTextMode_THROUGHT;
break;
case 4: //4 wrap tightly around object
m_pImpl->bIgnoreWRK = false;
case 5: //5 wrap tightly, but allow holes
m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
m_pImpl->bContour = true;
break;
default:;
}
break;
case NS_rtf::LN_WRK:
if( !m_pImpl->bIgnoreWRK )
switch( nIntValue )
{
case 0: //0 like 2, but doesn't require absolute object
case 2: //2 wrap around absolute object
m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
break;
case 1: //1 no text next to shape
m_pImpl->nWrap = text::WrapTextMode_NONE;
break;
case 3: //3 wrap as if no object present
m_pImpl->nWrap = text::WrapTextMode_THROUGHT;
break;
case 4: //4 wrap tightly around object
case 5: //5 wrap tightly, but allow holes
m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
m_pImpl->bContour = true;
break;
default:;
}
break;
case NS_rtf::LN_FRCASIMPLE:
case NS_rtf::LN_FBELOWTEXT:
case NS_rtf::LN_FANCHORLOCK:
case NS_rtf::LN_CTXBX:
{
sal_Int32 nValue1 = val.getInt();
nValue1++;
}
break;
/* case NS_rtf::LN_CH = 10421;
case NS_rtf::LN_UNUSED0_5 = 10422;
case NS_rtf::LN_FLT = 10423;
case NS_rtf::LN_shpLeft = 10424;
case NS_rtf::LN_shpTop = 10425;
break;*/
default: val.getInt();
}
......@@ -428,7 +641,6 @@ void GraphicImport::sprm(doctok::Sprm & sprm_)
case 0xf004: //dff record
case 0xf00a: //part of 0xf004 - shape properties
case 0xf00b: //part of 0xf004
case 0xf010: //part of 0xf004 -
case 0xf007:
{
doctok::Reference<Properties>::Pointer_t pProperties = sprm_.getProps();
......@@ -445,6 +657,11 @@ void GraphicImport::sprm(doctok::Sprm & sprm_)
pPictureData->resolve(*this);
}
break;
case 0xf010:
case 0xf011:
case 0xf122:
//ignore - doesn't contain useful members
break;
default:
doctok::Value::Pointer_t pValue = sprm_.getValue();
if( pValue.get() )
......@@ -457,6 +674,16 @@ void GraphicImport::sprm(doctok::Sprm & sprm_)
void GraphicImport::entry(int /*pos*/, doctok::Reference<Properties>::Pointer_t /*ref*/)
{
}
/*-- 16.11.2006 16:14:32---------------------------------------------------
crop is stored as "fixed float" as 16.16 fraction value
related to width/or height
-----------------------------------------------------------------------*/
void lcl_CalcCrop( sal_Int32& nCrop, sal_Int32 nRef )
{
nCrop = ((nCrop >> 16 ) * nRef )
+ (((nCrop & 0xffff) * nRef ) >> 16);
}
/*-- 01.11.2006 09:45:02---------------------------------------------------
-----------------------------------------------------------------------*/
......@@ -471,8 +698,10 @@ void GraphicImport::data(const sal_uInt8* buf, size_t len, doctok::Reference<Pro
uno::UNO_QUERY_THROW );
uno::Reference< io::XInputStream > xIStream = new XInputStreamHelper( buf, len );
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
::com::sun::star::beans::PropertyValues aMediaProperties( 1 );
aMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream"));
aMediaProperties[0].Name = rPropNameSupplier.GetName(PROP_INPUT_STREAM);
aMediaProperties[0].Value <<= xIStream;
uno::Reference< graphic::XGraphic > xGraphic = xGraphicProvider->queryGraphic( aMediaProperties );
//
......@@ -480,16 +709,87 @@ void GraphicImport::data(const sal_uInt8* buf, size_t len, doctok::Reference<Pro
{
clog << "Graphic loaded" << endl;
uno::Reference< beans::XPropertySet > xGraphicProperties(
uno::Reference< beans::XPropertySet > xGraphicObjectProperties(
m_xTextFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextGraphicObject"))),
uno::UNO_QUERY_THROW);
xGraphicProperties->setPropertyValue(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Graphic")), uno::makeAny( xGraphic ));
xGraphicProperties->setPropertyValue(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorType")), uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ));
m_xGraphicObject = uno::Reference< text::XTextContent >( xGraphicProperties, uno::UNO_QUERY_THROW );
}
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_GRAPHIC), uno::makeAny( xGraphic ));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_ANCHOR_TYPE),
uno::makeAny( m_pImpl->bIsShapeImport ?
text::TextContentAnchorType_AT_CHARACTER :
text::TextContentAnchorType_AS_CHARACTER ));
m_xGraphicObject = uno::Reference< text::XTextContent >( xGraphicObjectProperties, uno::UNO_QUERY_THROW );
if( m_pImpl->bIsShapeImport )
{
sal_Int32 nWidth = m_pImpl->nRightPosition - m_pImpl->nLeftPosition;
sal_Int32 nHeight = m_pImpl->nBottomPosition - m_pImpl->nTopPosition;
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SIZE),
uno::makeAny( awt::Size( nWidth, nHeight )));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_ORIENT ),
uno::makeAny(text::HoriOrientation::NONE));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_ORIENT_POSITTION),
uno::makeAny(m_pImpl->nLeftPosition));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_ORIENT_RELATION ),
uno::makeAny(text::RelOrientation::PRINT_AREA));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_ORIENT ),
uno::makeAny(text::VertOrientation::NONE));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_ORIENT_POSITTION),
uno::makeAny(m_pImpl->nTopPosition));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_ORIENT_RELATION ),
uno::makeAny(text::RelOrientation::PRINT_AREA));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND ),
uno::makeAny(m_pImpl->nWrap));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND_CONTOUR ),
uno::makeAny(m_pImpl->bContour));
if( m_pImpl->eColorMode == drawing::ColorMode_STANDARD &&
m_pImpl->nContrast == -70 &&
m_pImpl->nBrightness == 70 )
{
// strange definition of WATERMARK!
m_pImpl->nContrast = 0;
m_pImpl->nBrightness = 0;
m_pImpl->eColorMode = drawing::ColorMode_WATERMARK;
}
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_ADJUST_CONTRAST ),
uno::makeAny((sal_Int16)m_pImpl->nContrast));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_ADJUST_LUMINANCE ),
uno::makeAny((sal_Int16)m_pImpl->nBrightness));
if(m_pImpl->eColorMode != drawing::ColorMode_STANDARD)
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_GRAPHIC_COLOR_MODE ),
uno::makeAny(m_pImpl->eColorMode));
if(m_pImpl->fGamma > 0. )
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_GAMMA ),
uno::makeAny(m_pImpl->fGamma ));
if(m_pImpl->bHoriFlip)
{
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_MIRRORED_ON_EVEN_PAGES ),
uno::makeAny( m_pImpl->bHoriFlip ));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_MIRRORED_ON_ODD_PAGES ),
uno::makeAny( m_pImpl->bHoriFlip ));
}
if( m_pImpl->bVertFlip )
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_MIRRORED ),
uno::makeAny( m_pImpl->bVertFlip ));
//there seems to be no way to detect the original size via _real_ API
uno::Reference< beans::XPropertySet > xGraphicProperties( xGraphic, uno::UNO_QUERY_THROW );
awt::Size aGraphicSize, aGraphicSizePixel;
xGraphicProperties->getPropertyValue(rPropNameSupplier.GetName( PROP_SIZE100th_M_M )) >>= aGraphicSize;
xGraphicProperties->getPropertyValue(rPropNameSupplier.GetName( PROP_SIZE_PIXEL )) >>= aGraphicSizePixel;
if( aGraphicSize.Width && aGraphicSize.Height )
{
//todo: i71651 graphic size is not provided by the GraphicDescriptor
lcl_CalcCrop( m_pImpl->nTopCrop, aGraphicSize.Height );
lcl_CalcCrop( m_pImpl->nBottomCrop, aGraphicSize.Height );
lcl_CalcCrop( m_pImpl->nLeftCrop, aGraphicSize.Width );
lcl_CalcCrop( m_pImpl->nRightCrop, aGraphicSize.Width );
xGraphicProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_GRAPHIC_CROP ),
uno::makeAny(text::GraphicCrop(m_pImpl->nTopCrop, m_pImpl->nBottomCrop, m_pImpl->nLeftCrop, m_pImpl->nRightCrop)));
}
}
}
}
catch( const uno::Exception& )
{
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: GraphicImport.hxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: os $ $Date: 2006-11-06 15:01:06 $
* last change: $Author: os $ $Date: 2006-11-20 12:19:03 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -67,8 +67,9 @@ class WRITERFILTER_DLLPRIVATE GraphicImport : public doctok::Properties, public
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > m_xGraphicObject;
public:
GraphicImport(::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext > xComponentContext,
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xTextFactory);
explicit GraphicImport(::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext > xComponentContext,
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xTextFactory,
bool bIsShape);
virtual ~GraphicImport();
// Properties
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: PropertyIds.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: os $ $Date: 2006-11-02 12:37:24 $
* last change: $Author: os $ $Date: 2006-11-20 12:19:04 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -191,7 +191,30 @@ const rtl::OUString& PropertyNameSupplier::GetName( PropertyIds eId )
case PROP_TITLE : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")); break;
case PROP_CONTENT : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Content")); break;
case PROP_DATA_COLUMN_NAME : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataColumnName")); break;
case PROP_INPUT_STREAM : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")); break;
case PROP_GRAPHIC : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Graphic")); break;
case PROP_ANCHOR_TYPE : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorType")); break;
case PROP_SIZE : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Size")); break;
case PROP_HORI_ORIENT : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")); break;
case PROP_HORI_ORIENT_POSITTION : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")); break;
case PROP_HORI_ORIENT_RELATION : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation")); break;
case PROP_VERT_ORIENT : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")); break;
case PROP_VERT_ORIENT_POSITTION : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")); break;
case PROP_VERT_ORIENT_RELATION : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientRelation")); break;
case PROP_GRAPHIC_CROP : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicCrop")); break;
case PROP_SIZE100th_M_M : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Size100thMM")); break;
case PROP_SIZE_PIXEL : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SizePixel")); break;
case PROP_SURROUND : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Surround")); break;
case PROP_SURROUND_CONTOUR : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SurroundContour")); break;
case PROP_ADJUST_CONTRAST : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AdjustContrast")); break;
case PROP_ADJUST_LUMINANCE : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AdjustLuminance")); break;
case PROP_GRAPHIC_COLOR_MODE : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicColorMode")); break;
case PROP_GAMMA : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Gamma")); break;
case PROP_HORI_MIRRORED_ON_EVEN_PAGES: sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HoriMirroredOnEvenPages")); break;
case PROP_HORI_MIRRORED_ON_ODD_PAGES : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HoriMirroredOnOddPages")); break;
case PROP_VERT_MIRRORED : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VertMirrored")); break;
// case : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")); break;
// case : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")); break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: PropertyIds.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: os $ $Date: 2006-11-02 12:37:24 $
* last change: $Author: os $ $Date: 2006-11-20 12:19:04 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -130,13 +130,35 @@ enum PropertyIds
/*88*/ , PROP_TITLE
/*89*/ , PROP_CONTENT
/*90*/ , PROP_DATA_COLUMN_NAME
///*91*/ , PROP_
///*92*/ , PROP_
///*93*/ , PROP_
///*94*/ , PROP_
///*95*/ , PROP_
///*96*/ , PROP_
///*97*/ , PROP_
/*91*/ , PROP_INPUT_STREAM
/*92*/ , PROP_GRAPHIC
/*93*/ , PROP_ANCHOR_TYPE
/*94*/ , PROP_SIZE
/*95*/ , PROP_HORI_ORIENT
/*96*/ , PROP_HORI_ORIENT_POSITTION
/*97*/ , PROP_HORI_ORIENT_RELATION
/*98*/ , PROP_VERT_ORIENT
/*99*/ , PROP_VERT_ORIENT_POSITTION
/*100*/ ,PROP_VERT_ORIENT_RELATION
/*101*/ , PROP_GRAPHIC_CROP
/*102*/ , PROP_SIZE100th_M_M
/*103*/ , PROP_SIZE_PIXEL
/*104*/ , PROP_SURROUND
/*105*/ , PROP_SURROUND_CONTOUR
/*106*/ , PROP_ADJUST_CONTRAST
/*107*/ , PROP_ADJUST_LUMINANCE
/*108*/ , PROP_GRAPHIC_COLOR_MODE
/*109*/ , PROP_GAMMA
/*110*/ , PROP_HORI_MIRRORED_ON_EVEN_PAGES
/*111*/ , PROP_HORI_MIRRORED_ON_ODD_PAGES
/*112*/ , PROP_VERT_MIRRORED
///*113*/ , PROP_
///*114*/ , PROP_
///*115*/ , PROP_
///*116*/ , PROP_
///*117*/ , PROP_
///*118*/ , PROP_
///*119*/ , PROP_
};
struct PropertyNameSupplier_Impl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment