2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-21 22:06:52 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include <tools/stream.hxx>
|
2007-06-27 17:28:22 +00:00
|
|
|
#include <svx/grfcrop.hxx>
|
2010-01-07 18:52:36 +01:00
|
|
|
#include <editeng/itemtype.hxx>
|
2000-10-19 12:18:08 +00:00
|
|
|
#include <com/sun/star/text/GraphicCrop.hpp>
|
2014-04-04 13:39:38 +03:00
|
|
|
#include <tools/mapunit.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
SvxGrfCrop::SvxGrfCrop( sal_uInt16 nItemId )
|
2000-09-18 16:07:07 +00:00
|
|
|
: SfxPoolItem( nItemId ),
|
|
|
|
nLeft( 0 ), nRight( 0 ), nTop( 0 ), nBottom( 0 )
|
|
|
|
{}
|
|
|
|
|
|
|
|
SvxGrfCrop::SvxGrfCrop( sal_Int32 nL, sal_Int32 nR,
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Int32 nT, sal_Int32 nB, sal_uInt16 nItemId )
|
2000-09-18 16:07:07 +00:00
|
|
|
: SfxPoolItem( nItemId ),
|
|
|
|
nLeft( nL ), nRight( nR ), nTop( nT ), nBottom( nB )
|
|
|
|
{}
|
|
|
|
|
|
|
|
SvxGrfCrop::~SvxGrfCrop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-10 17:01:52 +01:00
|
|
|
bool SvxGrfCrop::operator==( const SfxPoolItem& rAttr ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( SfxPoolItem::operator==( rAttr ), "not equal attributes" );
|
2014-10-15 13:53:53 +02:00
|
|
|
const SvxGrfCrop& rCrop = static_cast<const SvxGrfCrop&>(rAttr);
|
|
|
|
return nLeft == rCrop.GetLeft() &&
|
|
|
|
nRight == rCrop.GetRight() &&
|
|
|
|
nTop == rCrop.GetTop() &&
|
|
|
|
nBottom == rCrop.GetBottom();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
SfxPoolItem* SvxGrfCrop::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Int32 top, left, right, bottom;
|
2014-02-05 10:41:04 +02:00
|
|
|
rStrm.ReadInt32( top ).ReadInt32( left ).ReadInt32( right ).ReadInt32( bottom );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if( GRFCROP_VERSION_SWDEFAULT == nVersion )
|
|
|
|
top = -top, bottom = -bottom, left = -left, right = -right;
|
|
|
|
|
2014-10-15 13:53:53 +02:00
|
|
|
SvxGrfCrop* pNew = static_cast<SvxGrfCrop*>(Clone());
|
2000-09-18 16:07:07 +00:00
|
|
|
pNew->SetLeft( left );
|
|
|
|
pNew->SetRight( right );
|
|
|
|
pNew->SetTop( top );
|
|
|
|
pNew->SetBottom( bottom );
|
|
|
|
return pNew;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
SvStream& SvxGrfCrop::Store( SvStream& rStrm, sal_uInt16 nVersion ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Int32 left = GetLeft(), right = GetRight(),
|
2000-09-18 16:07:07 +00:00
|
|
|
top = GetTop(), bottom = GetBottom();
|
|
|
|
if( GRFCROP_VERSION_SWDEFAULT == nVersion )
|
|
|
|
top = -top, bottom = -bottom, left = -left, right = -right;
|
|
|
|
|
2014-01-08 08:48:26 +02:00
|
|
|
rStrm.WriteInt32( top ).WriteInt32( left ).WriteInt32( right ).WriteInt32( bottom );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return rStrm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-03-12 02:42:58 +01:00
|
|
|
bool SvxGrfCrop::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-03-25 10:51:15 +09:00
|
|
|
bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
|
2000-10-19 12:18:08 +00:00
|
|
|
text::GraphicCrop aRet;
|
|
|
|
aRet.Left = nLeft;
|
|
|
|
aRet.Right = nRight;
|
|
|
|
aRet.Top = nTop;
|
|
|
|
aRet.Bottom = nBottom;
|
|
|
|
|
2002-05-22 11:05:15 +00:00
|
|
|
if( bConvert )
|
2000-10-19 12:18:08 +00:00
|
|
|
{
|
2014-04-04 13:39:38 +03:00
|
|
|
aRet.Right = convertTwipToMm100(aRet.Right );
|
|
|
|
aRet.Top = convertTwipToMm100(aRet.Top );
|
|
|
|
aRet.Left = convertTwipToMm100(aRet.Left );
|
|
|
|
aRet.Bottom = convertTwipToMm100(aRet.Bottom);
|
2000-10-19 12:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rVal <<= aRet;
|
2010-10-04 15:23:49 +01:00
|
|
|
return true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2011-03-12 02:42:58 +01:00
|
|
|
bool SvxGrfCrop::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-03-25 10:51:15 +09:00
|
|
|
bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
|
2000-10-19 12:18:08 +00:00
|
|
|
text::GraphicCrop aVal;
|
2000-11-02 15:08:52 +00:00
|
|
|
|
|
|
|
if(!(rVal >>= aVal))
|
2010-10-04 15:23:49 +01:00
|
|
|
return false;
|
2002-05-22 11:05:15 +00:00
|
|
|
if( bConvert )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-04-04 13:39:38 +03:00
|
|
|
aVal.Right = convertMm100ToTwip(aVal.Right );
|
|
|
|
aVal.Top = convertMm100ToTwip(aVal.Top );
|
|
|
|
aVal.Left = convertMm100ToTwip(aVal.Left );
|
|
|
|
aVal.Bottom = convertMm100ToTwip(aVal.Bottom);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2000-10-19 12:18:08 +00:00
|
|
|
|
|
|
|
nLeft = aVal.Left ;
|
|
|
|
nRight = aVal.Right ;
|
|
|
|
nTop = aVal.Top ;
|
|
|
|
nBottom = aVal.Bottom;
|
2010-10-04 15:23:49 +01:00
|
|
|
return true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-07-24 11:31:39 +02:00
|
|
|
bool SvxGrfCrop::GetPresentation(
|
2006-06-19 15:11:59 +00:00
|
|
|
SfxItemPresentation ePres, SfxMapUnit eCoreUnit, SfxMapUnit /*ePresUnit*/,
|
2013-01-23 12:41:52 +01:00
|
|
|
OUString &rText, const IntlWrapper* pIntl ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-11-12 14:24:10 +05:30
|
|
|
rText.clear();
|
2000-09-18 16:07:07 +00:00
|
|
|
switch( ePres )
|
|
|
|
{
|
|
|
|
case SFX_ITEM_PRESENTATION_NAMELESS:
|
2014-07-24 11:31:39 +02:00
|
|
|
return true;
|
2000-09-18 16:07:07 +00:00
|
|
|
case SFX_ITEM_PRESENTATION_COMPLETE:
|
2014-07-24 11:31:39 +02:00
|
|
|
rText = "L: " + OUString(::GetMetricText( GetLeft(), eCoreUnit, SFX_MAPUNIT_MM, pIntl )) +
|
|
|
|
" R: " + OUString(::GetMetricText( GetRight(), eCoreUnit, SFX_MAPUNIT_MM, pIntl )) +
|
|
|
|
" T: " + OUString(::GetMetricText( GetTop(), eCoreUnit, SFX_MAPUNIT_MM, pIntl )) +
|
|
|
|
" B: " + OUString(::GetMetricText( GetBottom(), eCoreUnit, SFX_MAPUNIT_MM, pIntl ));
|
|
|
|
return true;
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-07-24 11:31:39 +02:00
|
|
|
return false;
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|