2000-09-18 11:07:07 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 14:29:50 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:29:50 -05:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:29:50 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:29:50 -05:00
|
|
|
* $RCSfile: outlinfo.cxx,v $
|
2008-08-19 18:14:38 -05:00
|
|
|
* $Revision: 1.16 $
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:29:50 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:29:50 -05: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 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:29:50 -05: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 11:07:07 -05:00
|
|
|
*
|
2008-04-10 14:29:50 -05: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 11:07:07 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 12:58:50 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
#include <vcl/metric.hxx>
|
|
|
|
#include <svx/outliner.hxx>
|
|
|
|
#include <svx/svdorect.hxx>
|
|
|
|
#include <svx/svdoutl.hxx>
|
|
|
|
#include <svx/svxfont.hxx>
|
|
|
|
#include "drawdoc.hxx"
|
|
|
|
#include "outlinfo.hxx"
|
2002-04-08 09:07:36 -05:00
|
|
|
#include <algorithm>
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2002-08-01 09:01:05 -05:00
|
|
|
// #101500#
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_
|
|
|
|
#include <com/sun/star/i18n/ScriptType.hdl>
|
|
|
|
#endif
|
|
|
|
#include <com/sun/star/i18n/XBreakIterator.hpp>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_I18N_CHARACTERITERATORMODE_HDL_
|
|
|
|
#include <com/sun/star/i18n/CharacterIteratorMode.hdl>
|
|
|
|
#endif
|
|
|
|
#include <svx/unolingu.hxx>
|
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::i18n;
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
// ----------------
|
|
|
|
// - OutlinerInfo -
|
|
|
|
// ----------------
|
|
|
|
|
|
|
|
OutlinerInfo::OutlinerInfo() :
|
|
|
|
pParagraphs ( NULL ),
|
|
|
|
nParaCount ( 0UL ),
|
|
|
|
nExtraData ( 0L )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OutlinerInfo::~OutlinerInfo()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2006-12-12 10:27:25 -06:00
|
|
|
void OutlinerInfo::SetTextObj( SdDrawDocument* pDoc, SdrRectObj* pObj, OutputDevice* pOut )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
SdrOutliner& rOutliner = pDoc->GetDrawOutliner();
|
|
|
|
|
2006-12-12 10:27:25 -06:00
|
|
|
mpOut = pOut;
|
2000-09-18 11:07:07 -05:00
|
|
|
rOutliner.SetText( *pObj->GetOutlinerParaObject() );
|
|
|
|
|
2003-11-24 10:16:25 -06:00
|
|
|
aObjBound = pObj->GetCurrentBoundRect();
|
2000-09-18 11:07:07 -05:00
|
|
|
nParaCount = rOutliner.GetParagraphCount();
|
|
|
|
nExtraData = 0L;
|
|
|
|
|
|
|
|
if( nParaCount )
|
|
|
|
{
|
2001-03-20 09:49:46 -06:00
|
|
|
mbVertical = rOutliner.IsVertical();
|
2000-09-18 11:07:07 -05:00
|
|
|
pObj->TakeTextRect( rOutliner, aParaBound, TRUE );
|
2001-03-20 09:49:46 -06:00
|
|
|
|
2002-04-04 09:14:24 -06:00
|
|
|
if( IsVertical() )
|
2001-03-20 09:49:46 -06:00
|
|
|
aTextOffset = aParaBound.TopRight();
|
|
|
|
else
|
|
|
|
aTextOffset = aParaBound.TopLeft();
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
nCurPara = 0;
|
|
|
|
bInit = TRUE;
|
|
|
|
|
|
|
|
rOutliner.SetDrawPortionHdl( LINK( this, OutlinerInfo, DrawPortionHdl ) );
|
|
|
|
pParagraphs = new OutlinerParagraph[ nParaCount ];
|
|
|
|
rOutliner.StripPortions();
|
|
|
|
rOutliner.SetDrawPortionHdl( Link() );
|
|
|
|
|
2002-04-04 09:14:24 -06:00
|
|
|
if( 1 == nParaCount )
|
|
|
|
pParagraphs[ 0 ].aRect = aParaBound;
|
|
|
|
else if( IsVertical() )
|
|
|
|
{
|
|
|
|
pParagraphs[ 0 ].aRect.Right() = aParaBound.Right();
|
|
|
|
|
2002-11-25 11:09:50 -06:00
|
|
|
for( USHORT i = 0; i < nParaCount; i++ )
|
|
|
|
{
|
|
|
|
if( i > 0 )
|
|
|
|
pParagraphs[i].aRect.Right() = pParagraphs[ i - 1 ].aRect.Left();
|
2002-04-04 09:14:24 -06:00
|
|
|
|
2002-11-25 11:09:50 -06:00
|
|
|
pParagraphs[i].aRect.Left() = pParagraphs[i].aRect.Right() - rOutliner.GetTextHeight( i );
|
|
|
|
}
|
2002-04-04 09:14:24 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pParagraphs[ 0 ].aRect.Top() = aParaBound.Top();
|
|
|
|
|
2002-11-25 11:09:50 -06:00
|
|
|
for( USHORT i = 0; i < nParaCount; i++ )
|
|
|
|
{
|
|
|
|
if( i > 0 )
|
|
|
|
pParagraphs[ i ].aRect.Top() = pParagraphs[ i - 1 ].aRect.Bottom();
|
2002-04-04 09:14:24 -06:00
|
|
|
|
2002-11-25 11:09:50 -06:00
|
|
|
pParagraphs[ i ].aRect.Bottom() = pParagraphs[ i ].aRect.Top() + rOutliner.GetTextHeight( i );
|
|
|
|
}
|
2002-04-04 09:14:24 -06:00
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pParagraphs = NULL;
|
|
|
|
aParaBound = Rectangle();
|
|
|
|
aTextOffset = Point();
|
|
|
|
}
|
|
|
|
|
|
|
|
nCurPara = 0;
|
|
|
|
bInit = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void OutlinerInfo::Clear()
|
|
|
|
{
|
|
|
|
for( void* pChar = aCharacterList.First(); pChar; pChar = aCharacterList.Next() )
|
|
|
|
delete (OutlinerCharacter*) pChar;
|
|
|
|
aCharacterList.Clear();
|
|
|
|
|
|
|
|
delete[] pParagraphs;
|
|
|
|
pParagraphs = NULL;
|
|
|
|
|
|
|
|
nCurPara = nParaCount = 0UL;
|
|
|
|
aObjBound = aParaBound = Rectangle();
|
|
|
|
aTextOffset = Point();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
const Rectangle& OutlinerInfo::GetParaRect( const ULONG nPara ) const
|
|
|
|
{
|
|
|
|
DBG_ASSERT( nPara < nParaCount, "Para out of range!" );
|
|
|
|
return pParagraphs[ nPara ].aRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL OutlinerInfo::GetParaCharCount( const ULONG nPara ) const
|
|
|
|
{
|
|
|
|
DBG_ASSERT( nPara < nParaCount, "Para out of range!" );
|
2001-05-29 03:03:03 -05:00
|
|
|
return (0 != pParagraphs[ nPara ].nCharCount);
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2002-08-01 09:01:05 -05:00
|
|
|
IMPL_LINK(OutlinerInfo, DrawPortionHdl, DrawPortionInfo*, pInfo)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2002-08-01 09:01:05 -05:00
|
|
|
// #101500#
|
|
|
|
Point aStart;
|
|
|
|
sal_Bool bIsVertical(IsVertical());
|
2008-08-19 18:14:38 -05:00
|
|
|
mpOut->SetFont((const Font&)pInfo->mrFont);
|
2006-12-12 10:27:25 -06:00
|
|
|
FontMetric aFontMetric(mpOut->GetFontMetric());
|
2002-08-01 09:01:05 -05:00
|
|
|
sal_Bool bUseBreakIterator(sal_False);
|
|
|
|
|
|
|
|
// initialize BreakIterator
|
|
|
|
Reference < com::sun::star::i18n::XBreakIterator > xBreak;
|
|
|
|
Reference < XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
|
|
|
|
Reference < XInterface > xInterface = xMSF->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator"));
|
2008-08-19 18:14:38 -05:00
|
|
|
::com::sun::star::lang::Locale aFontLocale = SvxCreateLocale(pInfo->mrFont.GetLanguage());
|
2002-08-01 09:01:05 -05:00
|
|
|
|
|
|
|
if(xInterface.is())
|
|
|
|
{
|
|
|
|
Any x = xInterface->queryInterface(::getCppuType((const Reference< XBreakIterator >*)0));
|
|
|
|
x >>= xBreak;
|
2002-04-04 09:14:24 -06:00
|
|
|
}
|
2001-03-20 09:49:46 -06:00
|
|
|
|
2002-08-01 09:01:05 -05:00
|
|
|
if(xBreak.is())
|
2002-04-04 09:14:24 -06:00
|
|
|
{
|
2002-08-01 09:01:05 -05:00
|
|
|
bUseBreakIterator = sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bIsVertical)
|
|
|
|
{
|
2008-08-19 18:14:38 -05:00
|
|
|
aStart.X() = pInfo->mrStartPos.X() + aTextOffset.X() - aFontMetric.GetDescent();
|
|
|
|
aStart.Y() = pInfo->mrStartPos.Y() + aTextOffset.Y();
|
2002-08-01 09:01:05 -05:00
|
|
|
|
|
|
|
const Point aTopLeft(aStart.X(), aParaBound.Top());
|
|
|
|
const Point aBottomRight(aStart.X() + aFontMetric.GetLineHeight(), aParaBound.Bottom());
|
|
|
|
const Rectangle aCurRect(aTopLeft, aBottomRight);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2008-08-19 18:14:38 -05:00
|
|
|
if(pInfo->mnPara != nCurPara)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2008-08-19 18:14:38 -05:00
|
|
|
nCurPara = pInfo->mnPara;
|
2002-08-01 09:01:05 -05:00
|
|
|
pParagraphs[nCurPara].aRect = aCurRect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pParagraphs[nCurPara].aRect.Union(aCurRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-19 18:14:38 -05:00
|
|
|
aStart.X() = pInfo->mrStartPos.X() + aTextOffset.X();
|
|
|
|
aStart.Y() = pInfo->mrStartPos.Y() + aTextOffset.Y() - aFontMetric.GetAscent();
|
2001-03-20 09:49:46 -06:00
|
|
|
|
2002-08-01 09:01:05 -05:00
|
|
|
const Point aTopLeft(aParaBound.Left(), aStart.Y());
|
|
|
|
const Point aBottomRight(aParaBound.Right(), aStart.Y() + aFontMetric.GetLineHeight());
|
|
|
|
const Rectangle aCurRect(aTopLeft, aBottomRight);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2008-08-19 18:14:38 -05:00
|
|
|
if(pInfo->mnPara != nCurPara)
|
2002-08-01 09:01:05 -05:00
|
|
|
{
|
2008-08-19 18:14:38 -05:00
|
|
|
nCurPara = pInfo->mnPara;
|
2002-08-01 09:01:05 -05:00
|
|
|
pParagraphs[nCurPara].aRect = aCurRect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pParagraphs[nCurPara].aRect.Union(aCurRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-19 18:14:38 -05:00
|
|
|
if(pInfo->mnTextLen && (0xFFFF != pInfo->mnIndex))
|
2002-08-01 09:01:05 -05:00
|
|
|
{
|
2008-08-19 18:14:38 -05:00
|
|
|
pParagraphs[nCurPara].nCharCount += pInfo->mnTextLen;
|
2006-12-12 10:27:25 -06:00
|
|
|
sal_uInt16 nInsertIndex(0xffff);
|
2002-08-01 09:01:05 -05:00
|
|
|
|
|
|
|
if(pInfo->IsRTL())
|
2004-01-20 04:23:11 -06:00
|
|
|
nInsertIndex = (sal_uInt16)aCharacterList.Count();
|
2002-08-01 09:01:05 -05:00
|
|
|
|
2008-08-19 18:14:38 -05:00
|
|
|
for(sal_uInt16 nCharIndex(0); nCharIndex < pInfo->mnTextLen; )
|
2002-08-01 09:01:05 -05:00
|
|
|
{
|
|
|
|
xub_StrLen nNextGlyphLen(1);
|
|
|
|
sal_Bool bIsSingleSpace(sal_False);
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2002-08-01 09:01:05 -05:00
|
|
|
if(bUseBreakIterator)
|
2002-04-04 09:14:24 -06:00
|
|
|
{
|
2002-08-01 09:01:05 -05:00
|
|
|
sal_Int32 nDone(0L);
|
2008-08-19 18:14:38 -05:00
|
|
|
nNextGlyphLen = (xub_StrLen)xBreak->nextCharacters( pInfo->mrText, pInfo->mnTextStart, aFontLocale,
|
|
|
|
CharacterIteratorMode::SKIPCELL, 1, nDone) - (pInfo->mnTextStart);
|
2002-08-01 09:01:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!bIsSingleSpace)
|
|
|
|
{
|
2008-08-19 18:14:38 -05:00
|
|
|
Size aGlyphSize(pInfo->mrFont.GetPhysTxtSize(mpOut,
|
|
|
|
pInfo->mrText, nCharIndex + pInfo->mnTextStart, nNextGlyphLen));
|
2002-08-01 09:01:05 -05:00
|
|
|
|
|
|
|
if(bIsVertical)
|
|
|
|
{
|
|
|
|
::std::swap(aGlyphSize.Width(), aGlyphSize.Height());
|
|
|
|
}
|
|
|
|
|
|
|
|
const Rectangle aRect(aStart, aGlyphSize);
|
|
|
|
|
|
|
|
aCharacterList.Insert(new OutlinerCharacter(
|
|
|
|
aRect,
|
2008-08-19 18:14:38 -05:00
|
|
|
pInfo->mnPara,
|
|
|
|
pInfo->mrFont.GetColor()),
|
2002-08-01 09:01:05 -05:00
|
|
|
nInsertIndex);
|
|
|
|
|
2002-12-02 08:34:40 -06:00
|
|
|
long dx = 0;
|
2008-08-19 18:14:38 -05:00
|
|
|
if( pInfo->mpDXArray )
|
|
|
|
dx = (pInfo->mpDXArray)[nCharIndex];
|
2002-12-02 08:34:40 -06:00
|
|
|
|
2002-08-01 09:01:05 -05:00
|
|
|
if(bIsVertical)
|
2008-08-19 18:14:38 -05:00
|
|
|
aStart.Y() = pInfo->mrStartPos.Y() + aTextOffset.Y() + dx;
|
2002-04-04 09:14:24 -06:00
|
|
|
else
|
2008-08-19 18:14:38 -05:00
|
|
|
aStart.X() = pInfo->mrStartPos.X() + aTextOffset.X() + dx;
|
2001-03-20 09:49:46 -06:00
|
|
|
}
|
2002-08-01 09:01:05 -05:00
|
|
|
|
2006-12-12 10:27:25 -06:00
|
|
|
nCharIndex = nCharIndex + nNextGlyphLen;
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
2002-08-01 09:01:05 -05:00
|
|
|
|
|
|
|
// eof
|