2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 12:32:05 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:32:05 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:32:05 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:32:05 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:32:05 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:32:05 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2001-03-09 12:53:33 +00:00
|
|
|
#include <hintids.hxx>
|
2004-01-06 17:15:37 +00:00
|
|
|
#include <tools/poly.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/stritem.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <svx/contdlg.hxx>
|
2001-05-04 07:49:08 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <docary.hxx>
|
2001-03-09 12:53:33 +00:00
|
|
|
#include <doc.hxx>
|
|
|
|
#include <fmtcol.hxx>
|
|
|
|
#include <ndnotxt.hxx>
|
|
|
|
#include <ndgrf.hxx>
|
|
|
|
#include <ndole.hxx>
|
|
|
|
#include <ndindex.hxx>
|
2012-08-13 19:01:29 +02:00
|
|
|
#include <hints.hxx>
|
2006-12-01 14:41:36 +00:00
|
|
|
#include <istyleaccess.hxx>
|
|
|
|
#include <SwStyleNameMapper.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2011-02-02 20:41:40 +09:00
|
|
|
#include <frmfmt.hxx> // #i73249#
|
2009-08-27 11:59:20 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
SwNoTxtNode::SwNoTxtNode( const SwNodeIndex & rWhere,
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_uInt8 nNdType,
|
2000-09-18 23:08:29 +00:00
|
|
|
SwGrfFmtColl *pGrfColl,
|
|
|
|
SwAttrSet* pAutoAttr ) :
|
|
|
|
SwCntntNode( rWhere, nNdType, pGrfColl ),
|
2001-04-24 09:07:58 +00:00
|
|
|
pContour( 0 ),
|
2011-01-17 15:06:54 +01:00
|
|
|
bAutomaticContour( sal_False ),
|
|
|
|
bContourMapModeValid( sal_True ),
|
|
|
|
bPixelContour( sal_False )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-08-13 19:01:29 +02:00
|
|
|
// Should this set a hard attribute?
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pAutoAttr )
|
|
|
|
SetAttr( *pAutoAttr );
|
|
|
|
}
|
|
|
|
|
|
|
|
SwNoTxtNode::~SwNoTxtNode()
|
|
|
|
{
|
|
|
|
delete pContour;
|
|
|
|
}
|
|
|
|
|
2012-08-13 19:01:29 +02:00
|
|
|
/// Creates an AttrSet for all derivations with ranges for frame-
|
|
|
|
/// and graphics-attributes.
|
2000-09-18 23:08:29 +00:00
|
|
|
void SwNoTxtNode::NewAttrSet( SwAttrPool& rPool )
|
|
|
|
{
|
2012-08-13 19:01:29 +02:00
|
|
|
OSL_ENSURE( !mpAttrSet.get(), "AttrSet is already set" );
|
2006-12-01 14:41:36 +00:00
|
|
|
SwAttrSet aNewAttrSet( rPool, aNoTxtNodeSetRange );
|
|
|
|
|
|
|
|
// put names of parent style and conditional style:
|
|
|
|
const SwFmtColl* pFmtColl = GetFmtColl();
|
|
|
|
String sVal;
|
2012-10-10 07:34:19 +09:00
|
|
|
SwStyleNameMapper::FillProgName( pFmtColl->GetName(), sVal, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, true );
|
2006-12-01 14:41:36 +00:00
|
|
|
SfxStringItem aFmtColl( RES_FRMATR_STYLE_NAME, sVal );
|
|
|
|
aNewAttrSet.Put( aFmtColl );
|
|
|
|
|
|
|
|
aNewAttrSet.SetParent( &GetFmtColl()->GetAttrSet() );
|
|
|
|
mpAttrSet = GetDoc()->GetIStyleAccess().getAutomaticStyle( aNewAttrSet, IStyleAccess::AUTO_STYLE_NOTXT );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2012-08-13 19:01:29 +02:00
|
|
|
/// Dummies for loading/saving of persistent data
|
|
|
|
/// when working with graphics and OLE objects
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwNoTxtNode::RestorePersistentData()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwNoTxtNode::SavePersistentData()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwNoTxtNode::SetContour( const PolyPolygon *pPoly, sal_Bool bAutomatic )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
delete pContour;
|
|
|
|
if ( pPoly )
|
|
|
|
pContour = new PolyPolygon( *pPoly );
|
|
|
|
else
|
|
|
|
pContour = 0;
|
2001-04-24 09:07:58 +00:00
|
|
|
bAutomaticContour = bAutomatic;
|
2011-01-17 15:06:54 +01:00
|
|
|
bContourMapModeValid = sal_True;
|
|
|
|
bPixelContour = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwNoTxtNode::CreateContour()
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !pContour, "Contour available." );
|
2001-04-24 09:07:58 +00:00
|
|
|
pContour = new PolyPolygon(SvxContourDlg::CreateAutoContour(GetGraphic()));
|
2011-01-17 15:06:54 +01:00
|
|
|
bAutomaticContour = sal_True;
|
|
|
|
bContourMapModeValid = sal_True;
|
|
|
|
bPixelContour = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2001-05-04 07:49:08 +00:00
|
|
|
const PolyPolygon *SwNoTxtNode::HasContour() const
|
|
|
|
{
|
|
|
|
if( !bContourMapModeValid )
|
|
|
|
{
|
|
|
|
const MapMode aGrfMap( GetGraphic().GetPrefMapMode() );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bPixelGrf = aGrfMap.GetMapUnit() == MAP_PIXEL;
|
2001-05-04 07:49:08 +00:00
|
|
|
const MapMode aContourMap( bPixelGrf ? MAP_PIXEL : MAP_100TH_MM );
|
|
|
|
if( bPixelGrf ? !bPixelContour : aGrfMap != aContourMap )
|
|
|
|
{
|
2011-04-22 15:10:19 +02:00
|
|
|
// #i102238#
|
2011-03-16 17:44:08 +01:00
|
|
|
double nGrfDPIx = 0.0;
|
|
|
|
double nGrfDPIy = 0.0;
|
|
|
|
{
|
|
|
|
if ( !bPixelGrf && bPixelContour )
|
|
|
|
{
|
|
|
|
const Size aGrfPixelSize( GetGraphic().GetSizePixel() );
|
|
|
|
const Size aGrfPrefMapModeSize( GetGraphic().GetPrefSize() );
|
|
|
|
if ( aGrfMap.GetMapUnit() == MAP_INCH )
|
|
|
|
{
|
|
|
|
nGrfDPIx = aGrfPixelSize.Width() / ( (double)aGrfMap.GetScaleX() * aGrfPrefMapModeSize.Width() );
|
|
|
|
nGrfDPIy = aGrfPixelSize.Height() / ( (double)aGrfMap.GetScaleY() * aGrfPrefMapModeSize.Height() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const Size aGrf1000thInchSize =
|
|
|
|
OutputDevice::LogicToLogic( aGrfPrefMapModeSize,
|
|
|
|
aGrfMap, MAP_1000TH_INCH );
|
|
|
|
nGrfDPIx = 1000.0 * aGrfPixelSize.Width() / aGrf1000thInchSize.Width();
|
|
|
|
nGrfDPIy = 1000.0 * aGrfPixelSize.Height() / aGrf1000thInchSize.Height();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !bPixelGrf || aGrfMap == aContourMap,
|
2011-05-24 01:39:42 +02:00
|
|
|
"scale factor for pixel unsupported" );
|
2001-05-04 07:49:08 +00:00
|
|
|
OutputDevice* pOutDev =
|
|
|
|
(bPixelGrf || bPixelContour) ? Application::GetDefaultDevice()
|
|
|
|
: 0;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPolyCount = pContour->Count();
|
|
|
|
for( sal_uInt16 j=0; j<nPolyCount; j++ )
|
2001-05-04 07:49:08 +00:00
|
|
|
{
|
|
|
|
Polygon& rPoly = (*pContour)[j];
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nCount = rPoly.GetSize();
|
|
|
|
for( sal_uInt16 i=0 ; i<nCount; i++ )
|
2001-05-04 07:49:08 +00:00
|
|
|
{
|
|
|
|
if( bPixelGrf )
|
|
|
|
rPoly[i] = pOutDev->LogicToPixel( rPoly[i],
|
|
|
|
aContourMap );
|
|
|
|
else if( bPixelContour )
|
2011-03-16 17:44:08 +01:00
|
|
|
{
|
2001-05-04 07:49:08 +00:00
|
|
|
rPoly[i] = pOutDev->PixelToLogic( rPoly[i], aGrfMap );
|
2011-04-22 15:10:19 +02:00
|
|
|
// #i102238#
|
2011-03-16 17:44:08 +01:00
|
|
|
if ( nGrfDPIx != 0 && nGrfDPIy != 0 )
|
|
|
|
{
|
|
|
|
rPoly[i] = Point( rPoly[i].X() * pOutDev->ImplGetDPIX() / nGrfDPIx,
|
|
|
|
rPoly[i].Y() * pOutDev->ImplGetDPIY() / nGrfDPIy );
|
|
|
|
}
|
|
|
|
}
|
2001-05-04 07:49:08 +00:00
|
|
|
else
|
|
|
|
rPoly[i] = OutputDevice::LogicToLogic( rPoly[i],
|
|
|
|
aContourMap,
|
|
|
|
aGrfMap );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
((SwNoTxtNode *)this)->bContourMapModeValid = sal_True;
|
|
|
|
((SwNoTxtNode *)this)->bPixelContour = sal_False;
|
2001-05-04 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pContour;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
void SwNoTxtNode::GetContour( PolyPolygon &rPoly ) const
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pContour, "Contour not available." );
|
2001-05-04 07:49:08 +00:00
|
|
|
rPoly = *HasContour();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwNoTxtNode::SetContourAPI( const PolyPolygon *pPoly )
|
|
|
|
{
|
|
|
|
delete pContour;
|
|
|
|
if ( pPoly )
|
|
|
|
pContour = new PolyPolygon( *pPoly );
|
|
|
|
else
|
|
|
|
pContour = 0;
|
2011-01-17 15:06:54 +01:00
|
|
|
bContourMapModeValid = sal_False;
|
2001-05-04 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwNoTxtNode::GetContourAPI( PolyPolygon &rContour ) const
|
2001-05-04 07:49:08 +00:00
|
|
|
{
|
|
|
|
if( !pContour )
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2001-05-04 07:49:08 +00:00
|
|
|
|
|
|
|
rContour = *pContour;
|
|
|
|
if( bContourMapModeValid )
|
|
|
|
{
|
|
|
|
const MapMode aGrfMap( GetGraphic().GetPrefMapMode() );
|
|
|
|
const MapMode aContourMap( MAP_100TH_MM );
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( aGrfMap.GetMapUnit() != MAP_PIXEL ||
|
2001-05-04 07:49:08 +00:00
|
|
|
aGrfMap == MapMode( MAP_PIXEL ),
|
|
|
|
"scale factor for pixel unsupported" );
|
|
|
|
if( aGrfMap.GetMapUnit() != MAP_PIXEL &&
|
|
|
|
aGrfMap != aContourMap )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPolyCount = rContour.Count();
|
|
|
|
for( sal_uInt16 j=0; j<nPolyCount; j++ )
|
2001-05-04 07:49:08 +00:00
|
|
|
{
|
2011-03-16 17:44:08 +01:00
|
|
|
// --> OD #i102238# - use the right <PolyPolygon> instance
|
|
|
|
Polygon& rPoly = rContour[j];
|
|
|
|
// <--
|
2001-05-04 07:49:08 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nCount = rPoly.GetSize();
|
|
|
|
for( sal_uInt16 i=0 ; i<nCount; i++ )
|
2001-05-04 07:49:08 +00:00
|
|
|
{
|
|
|
|
rPoly[i] = OutputDevice::LogicToLogic( rPoly[i], aGrfMap,
|
|
|
|
aContourMap );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2001-05-04 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwNoTxtNode::IsPixelContour() const
|
2001-05-04 07:49:08 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRet;
|
2001-05-04 07:49:08 +00:00
|
|
|
if( bContourMapModeValid )
|
|
|
|
{
|
|
|
|
const MapMode aGrfMap( GetGraphic().GetPrefMapMode() );
|
|
|
|
bRet = aGrfMap.GetMapUnit() == MAP_PIXEL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bRet = bPixelContour;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Graphic SwNoTxtNode::GetGraphic() const
|
|
|
|
{
|
|
|
|
Graphic aRet;
|
|
|
|
if ( GetGrfNode() )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
((SwGrfNode*)this)->SwapIn( sal_True );
|
2000-09-18 23:08:29 +00:00
|
|
|
aRet = ((SwGrfNode*)this)->GetGrf();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( GetOLENode(), "new type of Node?" );
|
2004-10-04 18:04:22 +00:00
|
|
|
aRet = *((SwOLENode*)this)->SwOLENode::GetGraphic();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2011-02-02 20:41:40 +09:00
|
|
|
// #i73249#
|
2009-08-27 11:59:20 +00:00
|
|
|
void SwNoTxtNode::SetTitle( const String& rTitle, bool bBroadcast )
|
|
|
|
{
|
|
|
|
// Title attribute of <SdrObject> replaces own AlternateText attribute
|
|
|
|
SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(GetFlyFmt());
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pFlyFmt,
|
2009-08-27 11:59:20 +00:00
|
|
|
"<SwNoTxtNode::SetTitle(..)> - missing <SwFlyFrmFmt> instance" );
|
|
|
|
if ( !pFlyFmt )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-27 11:59:20 +00:00
|
|
|
pFlyFmt->SetObjTitle( rTitle, bBroadcast );
|
|
|
|
}
|
|
|
|
|
|
|
|
const String SwNoTxtNode::GetTitle() const
|
2002-07-25 14:47:22 +00:00
|
|
|
{
|
2009-08-27 11:59:20 +00:00
|
|
|
const SwFlyFrmFmt* pFlyFmt = dynamic_cast<const SwFlyFrmFmt*>(GetFlyFmt());
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pFlyFmt,
|
2009-08-27 11:59:20 +00:00
|
|
|
"<SwNoTxtNode::GetTitle(..)> - missing <SwFlyFrmFmt> instance" );
|
|
|
|
if ( !pFlyFmt )
|
2002-07-25 14:47:22 +00:00
|
|
|
{
|
2009-08-27 11:59:20 +00:00
|
|
|
return aEmptyStr;
|
2002-07-25 14:47:22 +00:00
|
|
|
}
|
2009-08-27 11:59:20 +00:00
|
|
|
|
|
|
|
return pFlyFmt->GetObjTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwNoTxtNode::SetDescription( const String& rDescription, bool bBroadcast )
|
|
|
|
{
|
|
|
|
SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(GetFlyFmt());
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pFlyFmt,
|
2009-08-27 11:59:20 +00:00
|
|
|
"<SwNoTxtNode::SetDescription(..)> - missing <SwFlyFrmFmt> instance" );
|
|
|
|
if ( !pFlyFmt )
|
2002-07-25 14:47:22 +00:00
|
|
|
{
|
2009-08-27 11:59:20 +00:00
|
|
|
return;
|
2002-07-25 14:47:22 +00:00
|
|
|
}
|
2009-08-27 11:59:20 +00:00
|
|
|
|
|
|
|
pFlyFmt->SetObjDescription( rDescription, bBroadcast );
|
2002-07-25 14:47:22 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-27 11:59:20 +00:00
|
|
|
const String SwNoTxtNode::GetDescription() const
|
|
|
|
{
|
|
|
|
const SwFlyFrmFmt* pFlyFmt = dynamic_cast<const SwFlyFrmFmt*>(GetFlyFmt());
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pFlyFmt,
|
2009-08-27 11:59:20 +00:00
|
|
|
"<SwNoTxtNode::GetDescription(..)> - missing <SwFlyFrmFmt> instance" );
|
|
|
|
if ( !pFlyFmt )
|
|
|
|
{
|
|
|
|
return aEmptyStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pFlyFmt->GetObjDescription();
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|