Files
libreoffice/editeng/source/misc/txtrange.cxx

666 lines
21 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes (at least) relevant parts of: linecap: Reintegrating finished LineCap feature Patch contributed by Regina Henschel http://svn.apache.org/viewvc?view=revision&revision=1232507 Patches contributed by Sven Jacobi impress212: #i81610# fixed animation export http://svn.apache.org/viewvc?view=revision&revision=1167620 impress212: drawinglayer gbuild environment changes http://svn.apache.org/viewvc?view=revision&revision=1167627 http://svn.apache.org/viewvc?view=revision&revision=1167628 impress212: DffPropSet -> minor code improvements, removing table http://svn.apache.org/viewvc?view=revision&revision=1167634 impress212: #158494# fixed excel import (text rotation) http://svn.apache.org/viewvc?view=revision&revision=1167638 Patches contributed by Armin Le Grand Svg: Reintegrated Svg replacement from /branches/alg/svgreplavement http://svn.apache.org/viewvc?view=revision&revision=1220836 #118728# changed indentifying definitions for Svg file detection http://svn.apache.org/viewvc?view=revision&revision=1229961 #118838# LineGeometry creation for complicated cases optimized to create single Polygons http://svn.apache.org/viewvc?view=revision&revision=1236232 #119176# corrected file type detection for SVG for svg files without xml header http://svn.apache.org/viewvc?view=revision&revision=1309445 #118728# Extended Svg file detection http://svn.apache.org/viewvc?view=revision&revision=1230531 #118529# solve break converters and convert commands for OLEs and images http://svn.apache.org/viewvc?view=revision&revision=1186168 svg: added WaE changes from branch svgreplacement to trunc http://svn.apache.org/viewvc?view=revision&revision=1222974 svg: corrected missing member initialization http://svn.apache.org/viewvc?view=revision&revision=1226134 fix for #118525#: Using primitives for chart sub-geometry visualisation http://svn.apache.org/viewvc?view=revision&revision=1226879 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles to bitmapEx ... http://svn.apache.org/viewvc?view=revision&revision=1293316 fix for #118525#: removed no longer used variable maOriginalMapMode, one more exception eliminated http://svn.apache.org/viewvc?view=revision&revision=1227097 #16758# Added buffering to the VDev usages of the VclProcessor2D derivates... http://svn.apache.org/viewvc?view=revision&revision=1229521 #116758# Secured VDev buffer device to Vcl deinit http://svn.apache.org/viewvc?view=revision&revision=1230574 #116758# added remembering allocated VDevs for VDevBuffer to be able to also delete these when vcl goes down; it should never happen, but You never know http://svn.apache.org/viewvc?view=revision&revision=1230927 #118730# Changed SvgClipPathNode to use MaskPrimitive2D for primitive representation instead of TransparencePrimitive2D http://svn.apache.org/viewvc?view=revision&revision=1231198 #118822# secured 3D geometry creation (slices) by subdividing the 2D source polyPolygon early http://svn.apache.org/viewvc?view=revision&revision=1234749 #118829# enhanced Svg gradient quality, obstacles avoided http://svn.apache.org/viewvc?view=revision&revision=1235361 #118834# Unified usage of TextBreakupHelper as single tooling class for i18n text primitive breakup http://svn.apache.org/viewvc?view=revision&revision=1236110 #118853# added square pixel size limit to conversion of TransparencePrimitive2D to Metafile action http://svn.apache.org/viewvc?view=revision&revision=1237656 #118824# coreccted mirroring and boundrect when the graphicmanager is used for bitmap output http://svn.apache.org/viewvc?view=revision&revision=1240097 #115092# Corrected VclProcessor2D::RenderPolygonStrokePrimitive2D for various optimization scenarios http://svn.apache.org/viewvc?view=revision&revision=1241434 #118783# Corrected errors in ID strings, corrected Svg line/fill export, corrected polygon close state http://svn.apache.org/viewvc?view=revision&revision=1232006 #118796# corrected null-pointer usage in SVG text exporter http://svn.apache.org/viewvc?view=revision&revision=1240262 #118729# Use GraphicStreamUrl and GraphicUrl to allow multi image import with linked graphics, too http://svn.apache.org/viewvc?view=revision&revision=1229962 #118898# corrected error in GDIMetaFile::GetBoundRect in handling MetaFloatTransparentAction http://svn.apache.org/viewvc?view=revision&revision=1293349 #118855# Corrected handling of possibly created empty clipRegions after PolyPolygon clipping http://svn.apache.org/viewvc?view=revision&revision=1237725 #115962# Better (but not yet optimal, see comments in task) handling of MetaFloatTransparentAction in PDF export http://svn.apache.org/viewvc?view=revision&revision=1241078 IP clearance: #118466# This patch removes librsvg, libcroco, libgsf, ... http://svn.apache.org/viewvc?view=revision&revision=1200879 118779# Added svg content streaming in/out to ImpGraphic stream operators http://svn.apache.org/viewvc?view=revision&revision=1231908 linecap: correctons for WaE and mac drawing http://svn.apache.org/viewvc?view=revision&revision=1232793 svg: uses current system Dpi for Svg replacement image creation http://svn.apache.org/viewvc?view=revision&revision=1233948 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 http://svn.apache.org/viewvc?view=revision&revision=1394326 Remove duplicate header includes. cws mba34issues01: #i117720#: convert assertion into warning http://svn.apache.org/viewvc?view=revision&revision=1172352 118485 - Styles for OLEs are not saved. Submitted by Armin Le Grand. http://svn.apache.org/viewvc?view=revision&revision=1182166 cws mba34issues01: #i117714#: remove assertion http://svn.apache.org/viewvc?view=revision&revision=1172357 Patch contributed by Jurgen Schmidt add some additional checks to ensure proper reading operations http://svn.apache.org/viewvc?view=revision&revision=1209022 mostly prefer our stream / bounds checking work. Patches contributed by Herbert Duerr #i118816# add clarifying comment regarding Font::*Color*() methods http://svn.apache.org/viewvc?view=revision&revision=1233833 extend macro->string handling for empty strings http://svn.apache.org/viewvc?view=revision&revision=1175801 avoid magic constants for SALCOLOR_NONE http://svn.apache.org/viewvc?view=revision&revision=1177543 initialize slant properly in ImplFontMetricData constructor (author=iorsh) http://svn.apache.org/viewvc?view=revision&revision=1177551 #i118675# make check for extension updates more stable http://svn.apache.org/viewvc?view=revision&revision=1214797 #a118617# remove VBasicEventListener.dll binary There are no known users depending on its CLSID http://svn.apache.org/viewvc?view=revision&revision=1203697 Patches contributed by Ariel Constenla-Haile Fix build breaker on Linux/gcc http://svn.apache.org/viewvc?view=revision&revision=1221104 Fix crash when trying to instantiate css.graphic.GraphicRasterizer_RSVG http://svn.apache.org/viewvc?view=revision&revision=1215559 Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117962# - method <SwFlyFrm::IsPaint(..)> - consider instances of <SwFlyDrawObj> http://svn.apache.org/viewvc?view=revision&revision=1172120 sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 gnumake4 work variously from Hans-Joachim Lankenau http://svn.apache.org/viewvc?view=revision&revision=1397315 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1396782 http://svn.apache.org/viewvc?view=revision&revision=1394707 plus some amount of re-splitting of legacy headers. Patch contributed by Pavel Janik WaE: Remove unused variables. http://svn.apache.org/viewvc?view=revision&revision=1230697 Patches contributed by Takashi Ono mingwport35: i#117795: MinGW port fix for vcl2gnumake http://svn.apache.org/viewvc?view=revision&revision=1172091 mingwport35: i#117795: MinGW port fix for vcl2gnumake http://svn.apache.org/viewvc?view=revision&revision=1172091 Patch contributed by Christian Lippka impress212: #i98044# re enable Text menu for outline and title shapes http://svn.apache.org/viewvc?view=revision&revision=1167639 Patch contributed by Andre Fischer 118674: Made category B code optional and disabled by default. http://svn.apache.org/viewvc?view=revision&revision=1215131 118881: Ignore empty paragraphs after bullets. http://svn.apache.org/viewvc?view=revision&revision=1296205 Patches contributed by Philipp Lohmann ooo340fixes: #i117780# use rtl allocator http://svn.apache.org/viewvc?view=revision&revision=1172087 ooo34gsl02: #i117807# fix an off by one error (index actually inside the pfb section header) http://svn.apache.org/viewvc?view=revision&revision=1167576 various cleanups, related compilation fixes, warning cleanups, re-working of obsolete stl template pieces to use boost instead, changed string classes, re-adapt KDE about data, about dialog, fixing warnings, and other fixes & improvements. Disable svg import / render for about/ branding code-paths for now. Restore full icon theme set. Remove OS/2 conditionals and sources. Remove conflicting gtk/full-screen monitors support. Retain existing svg rasterizer files - temporarily disabled. Standardize stringificaiton and fixup dllpostfix issues. Rename SvgGradientHelper::== to equalTo to avoid overloading issues. Use the flat GdiPlus API for LineCaps calls.
2012-10-09 12:22:23 +01: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 <editeng/txtrange.hxx>
2000-09-18 16:07:07 +00:00
#include <math.h>
#include <tools/poly.hxx>
2000-09-18 16:07:07 +00:00
#include <tools/debug.hxx>
#include <tools/solar.h>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
2011-02-22 12:00:38 +00:00
#include <vector>
TextRanger::TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon,
const basegfx::B2DPolyPolygon* pLinePolyPolygon,
Merge remote-tracking branch 'origin/integration/dev300_m101' Conflicts: avmedia/source/framework/mediacontrol.cxx connectivity/source/commontools/DateConversion.cxx desktop/source/deployment/registry/component/dp_component.cxx editeng/inc/editeng/numitem.hxx editeng/inc/editeng/txtrange.hxx editeng/source/editeng/editobj.cxx editeng/source/editeng/editview.cxx editeng/source/editeng/eehtml.cxx editeng/source/editeng/impedit3.cxx editeng/source/editeng/impedit4.cxx editeng/source/misc/txtrange.cxx editeng/source/outliner/outlin2.cxx editeng/source/outliner/outlvw.cxx framework/source/layoutmanager/layoutmanager.cxx linguistic/source/lngsvcmgr.hxx sfx2/source/appl/app.cxx sfx2/source/appl/app.src sfx2/source/appl/appbas.cxx sfx2/source/appl/appcfg.cxx sfx2/source/appl/appdde.cxx sfx2/source/appl/appmain.cxx sfx2/source/appl/appopen.cxx sfx2/source/appl/appquit.cxx sfx2/source/appl/appserv.cxx sfx2/source/appl/childwin.cxx sfx2/source/appl/fileobj.cxx sfx2/source/appl/fileobj.hxx sfx2/source/appl/workwin.cxx sfx2/source/control/dispatch.cxx sfx2/source/control/macro.cxx sfx2/source/control/objface.cxx sfx2/source/control/request.cxx sfx2/source/control/shell.cxx sfx2/source/control/statcach.cxx sfx2/source/dialog/dinfdlg.cxx sfx2/source/dialog/dockwin.cxx sfx2/source/dialog/mailmodel.cxx sfx2/source/dialog/mailmodelapi.cxx sfx2/source/dialog/mgetempl.cxx sfx2/source/dialog/splitwin.cxx sfx2/source/dialog/styledlg.cxx sfx2/source/dialog/tabdlg.cxx sfx2/source/dialog/templdlg.cxx sfx2/source/dialog/tplcitem.cxx sfx2/source/dialog/tplpitem.cxx sfx2/source/doc/doctempl.cxx sfx2/source/doc/docvor.cxx sfx2/source/doc/new.cxx sfx2/source/doc/objcont.cxx sfx2/source/doc/objserv.cxx sfx2/source/doc/objxtor.cxx sfx2/source/inc/appdata.hxx sfx2/source/inc/helpid.hrc sfx2/source/inc/sfxlocal.hrc sfx2/source/inc/statcach.hxx sfx2/source/inc/templdgi.hxx sfx2/source/inc/virtmenu.hxx sfx2/source/inc/workwin.hxx sfx2/source/menu/mnumgr.cxx sfx2/source/menu/virtmenu.cxx sfx2/source/statbar/stbitem.cxx sfx2/source/view/frame.cxx sfx2/source/view/frame2.cxx sfx2/source/view/orgmgr.cxx sfx2/source/view/printer.cxx sfx2/source/view/prnmon.cxx sfx2/source/view/sfxbasecontroller.cxx sfx2/source/view/viewfrm.cxx sfx2/source/view/viewfrm2.cxx sfx2/source/view/viewprn.cxx sfx2/source/view/viewsh.cxx svx/inc/svx/svditer.hxx svx/source/dialog/sdstring.src svx/source/form/fmpage.cxx svx/source/form/formcontroller.cxx svx/source/svdraw/svdcrtv.cxx svx/source/svdraw/svditer.cxx svx/source/svdraw/svdview.cxx xmloff/source/forms/elementimport.cxx
2011-03-18 15:49:47 +01:00
sal_uInt16 nCacheSz, sal_uInt16 nLft, sal_uInt16 nRght,
bool bSimpl, bool bInnr, bool bVert ) :
pBound( nullptr ),
nCacheSize( nCacheSz ),
nRight( nRght ),
nLeft( nLft ),
nUpper( 0 ),
nLower( 0 ),
nPointCount( 0 ),
bSimple( bSimpl ),
bInner( bInnr ),
bVertical( bVert )
2000-09-18 16:07:07 +00:00
{
sal_uInt32 nCount(rPolyPolygon.count());
mpPolyPolygon = new tools::PolyPolygon( (sal_uInt16)nCount );
for(sal_uInt32 i(0L); i < nCount; i++)
2000-09-18 16:07:07 +00:00
{
const basegfx::B2DPolygon aCandidate(rPolyPolygon.getB2DPolygon(i).getDefaultAdaptiveSubdivision());
nPointCount += aCandidate.count();
mpPolyPolygon->Insert( tools::Polygon(aCandidate), (sal_uInt16)i );
2000-09-18 16:07:07 +00:00
}
if( pLinePolyPolygon )
2000-09-18 16:07:07 +00:00
{
nCount = pLinePolyPolygon->count();
mpLinePolyPolygon = new tools::PolyPolygon();
for(sal_uInt32 i(0L); i < nCount; i++)
2000-09-18 16:07:07 +00:00
{
const basegfx::B2DPolygon aCandidate(pLinePolyPolygon->getB2DPolygon(i).getDefaultAdaptiveSubdivision());
nPointCount += aCandidate.count();
mpLinePolyPolygon->Insert( tools::Polygon(aCandidate), (sal_uInt16)i );
2000-09-18 16:07:07 +00:00
}
}
else
mpLinePolyPolygon = nullptr;
2000-09-18 16:07:07 +00:00
}
TextRanger::~TextRanger()
{
mRangeCache.clear();
delete mpPolyPolygon;
delete mpLinePolyPolygon;
delete pBound;
2000-09-18 16:07:07 +00:00
}
/* TextRanger::SetVertical(..)
If there's is a change in the writing direction,
the cache has to be cleared.
*/
void TextRanger::SetVertical( bool bNew )
2000-11-17 08:45:51 +00:00
{
if( IsVertical() != bNew )
{
bVertical = bNew;
mRangeCache.clear();
2000-11-17 08:45:51 +00:00
}
}
//! SvxBoundArgs is used to perform temporary calculations on a range array.
//! Temporary instances are created in TextRanger::GetTextRanges()
2000-09-18 16:07:07 +00:00
class SvxBoundArgs
{
2011-02-22 12:00:38 +00:00
std::vector<bool> aBoolArr;
LongDqPtr pLongArr;
2000-09-18 16:07:07 +00:00
TextRanger *pTextRanger;
long nMin;
long nMax;
long nTop;
long nBottom;
long nUpDiff;
long nLowDiff;
long nUpper;
long nLower;
2000-11-16 15:06:31 +00:00
long nStart;
long nEnd;
sal_uInt16 nCut;
sal_uInt16 nLast;
sal_uInt16 nNext;
sal_uInt8 nAct;
sal_uInt8 nFirst;
bool bClosed : 1;
bool bInner : 1;
bool bMultiple : 1;
bool bConcat : 1;
bool bRotate : 1;
void NoteRange( bool bToggle );
2000-09-18 16:07:07 +00:00
long Cut( long nY, const Point& rPt1, const Point& rPt2 );
void Add();
void NoteFarPoint_( long nPx, long nPyDiff, long nDiff );
2000-09-18 16:07:07 +00:00
void NoteFarPoint( long nPx, long nPyDiff, long nDiff )
{ if( nDiff ) NoteFarPoint_( nPx, nPyDiff, nDiff ); }
2000-09-18 16:07:07 +00:00
long CalcMax( const Point& rPt1, const Point& rPt2, long nRange, long nFar );
void CheckCut( const Point& rLst, const Point& rNxt );
2000-11-16 15:06:31 +00:00
inline long A( const Point& rP ) const { return bRotate ? rP.Y() : rP.X(); }
inline long B( const Point& rP ) const { return bRotate ? rP.X() : rP.Y(); }
2000-09-18 16:07:07 +00:00
public:
SvxBoundArgs( TextRanger* pRanger, LongDqPtr pLong, const Range& rRange );
2000-11-16 15:06:31 +00:00
void NotePoint( const long nA ) { NoteMargin( nA - nStart, nA + nEnd ); }
2000-09-18 16:07:07 +00:00
void NoteMargin( const long nL, const long nR )
{ if( nMin > nL ) nMin = nL; if( nMax < nR ) nMax = nR; }
sal_uInt16 Area( const Point& rPt );
void NoteUpLow( long nA, const sal_uInt8 nArea );
void Calc( const tools::PolyPolygon& rPoly );
void Concat( const tools::PolyPolygon* pPoly );
2000-09-18 16:07:07 +00:00
// inlines
void NoteLast() { if( bMultiple ) NoteRange( nAct == nFirst ); }
void SetConcat( const bool bNew ){ bConcat = bNew; }
bool IsConcat() const { return bConcat; }
2000-09-18 16:07:07 +00:00
};
SvxBoundArgs::SvxBoundArgs( TextRanger* pRanger, LongDqPtr pLong,
2000-11-16 15:06:31 +00:00
const Range& rRange )
: pLongArr(pLong)
, pTextRanger(pRanger)
, nMin(0)
, nMax(0)
, nTop(rRange.Min())
, nBottom(rRange.Max())
, nCut(0)
, nLast(0)
, nNext(0)
, nAct(0)
, nFirst(0)
, bClosed(false)
, bInner(pRanger->IsInner())
, bMultiple(bInner || !pRanger->IsSimple())
, bConcat(false)
, bRotate(pRanger->IsVertical())
2000-11-16 15:06:31 +00:00
{
if( bRotate )
{
nStart = pRanger->GetUpper();
nEnd = pRanger->GetLower();
nLowDiff = pRanger->GetLeft();
nUpDiff = pRanger->GetRight();
}
else
{
nStart = pRanger->GetLeft();
nEnd = pRanger->GetRight();
nLowDiff = pRanger->GetUpper();
nUpDiff = pRanger->GetLower();
}
nUpper = nTop - nUpDiff;
nLower = nBottom + nLowDiff;
pLongArr->clear();
2000-11-16 15:06:31 +00:00
}
2000-09-18 16:07:07 +00:00
long SvxBoundArgs::CalcMax( const Point& rPt1, const Point& rPt2,
long nRange, long nFarRange )
{
2000-11-16 15:06:31 +00:00
double nDa = Cut( nRange, rPt1, rPt2 ) - Cut( nFarRange, rPt1, rPt2 );
double nB;
if( nDa < 0 )
2000-09-18 16:07:07 +00:00
{
2000-11-16 15:06:31 +00:00
nDa = -nDa;
nB = nEnd;
2000-09-18 16:07:07 +00:00
}
else
2000-11-16 15:06:31 +00:00
nB = nStart;
nB *= nB;
nB += nDa * nDa;
nB = nRange + nDa * ( nFarRange - nRange ) / sqrt( nB );
2000-09-18 16:07:07 +00:00
bool bNote;
2000-11-16 15:06:31 +00:00
if( nB < B(rPt2) )
bNote = nB > B(rPt1);
2000-09-18 16:07:07 +00:00
else
2000-11-16 15:06:31 +00:00
bNote = nB < B(rPt1);
2000-09-18 16:07:07 +00:00
if( bNote )
2000-11-16 15:06:31 +00:00
return( long( nB ) );
2000-09-18 16:07:07 +00:00
return 0;
}
void SvxBoundArgs::CheckCut( const Point& rLst, const Point& rNxt )
{
if( nCut & 1 )
NotePoint( Cut( nBottom, rLst, rNxt ) );
if( nCut & 2 )
NotePoint( Cut( nTop, rLst, rNxt ) );
if( rLst.X() != rNxt.X() && rLst.Y() != rNxt.Y() )
{
long nYps;
if( nLowDiff && ( ( nCut & 1 ) || nLast == 1 || nNext == 1 ) )
{
nYps = CalcMax( rLst, rNxt, nBottom, nLower );
if( nYps )
NoteFarPoint_( Cut( nYps, rLst, rNxt ), nLower-nYps, nLowDiff );
2000-09-18 16:07:07 +00:00
}
if( nUpDiff && ( ( nCut & 2 ) || nLast == 2 || nNext == 2 ) )
{
nYps = CalcMax( rLst, rNxt, nTop, nUpper );
if( nYps )
NoteFarPoint_( Cut( nYps, rLst, rNxt ), nYps-nUpper, nUpDiff );
2000-09-18 16:07:07 +00:00
}
}
}
void SvxBoundArgs::NoteFarPoint_( long nPa, long nPbDiff, long nDiff )
2000-09-18 16:07:07 +00:00
{
2000-11-16 15:06:31 +00:00
long nTmpA;
double nQuot = 2 * nDiff - nPbDiff;
nQuot *= nPbDiff;
nQuot = sqrt( nQuot );
nQuot /= nDiff;
nTmpA = nPa - long( nStart * nQuot );
nPbDiff = nPa + long( nEnd * nQuot );
NoteMargin( nTmpA, nPbDiff );
2000-09-18 16:07:07 +00:00
}
void SvxBoundArgs::NoteRange( bool bToggle )
2000-09-18 16:07:07 +00:00
{
DBG_ASSERT( nMax >= nMin || bInner, "NoteRange: Min > Max?");
if( nMax < nMin )
return;
if( !bClosed )
bToggle = false;
sal_uInt16 nIdx = 0;
Merge remote-tracking branch 'origin/integration/dev300_m101' Conflicts: avmedia/source/framework/mediacontrol.cxx connectivity/source/commontools/DateConversion.cxx desktop/source/deployment/registry/component/dp_component.cxx editeng/inc/editeng/numitem.hxx editeng/inc/editeng/txtrange.hxx editeng/source/editeng/editobj.cxx editeng/source/editeng/editview.cxx editeng/source/editeng/eehtml.cxx editeng/source/editeng/impedit3.cxx editeng/source/editeng/impedit4.cxx editeng/source/misc/txtrange.cxx editeng/source/outliner/outlin2.cxx editeng/source/outliner/outlvw.cxx framework/source/layoutmanager/layoutmanager.cxx linguistic/source/lngsvcmgr.hxx sfx2/source/appl/app.cxx sfx2/source/appl/app.src sfx2/source/appl/appbas.cxx sfx2/source/appl/appcfg.cxx sfx2/source/appl/appdde.cxx sfx2/source/appl/appmain.cxx sfx2/source/appl/appopen.cxx sfx2/source/appl/appquit.cxx sfx2/source/appl/appserv.cxx sfx2/source/appl/childwin.cxx sfx2/source/appl/fileobj.cxx sfx2/source/appl/fileobj.hxx sfx2/source/appl/workwin.cxx sfx2/source/control/dispatch.cxx sfx2/source/control/macro.cxx sfx2/source/control/objface.cxx sfx2/source/control/request.cxx sfx2/source/control/shell.cxx sfx2/source/control/statcach.cxx sfx2/source/dialog/dinfdlg.cxx sfx2/source/dialog/dockwin.cxx sfx2/source/dialog/mailmodel.cxx sfx2/source/dialog/mailmodelapi.cxx sfx2/source/dialog/mgetempl.cxx sfx2/source/dialog/splitwin.cxx sfx2/source/dialog/styledlg.cxx sfx2/source/dialog/tabdlg.cxx sfx2/source/dialog/templdlg.cxx sfx2/source/dialog/tplcitem.cxx sfx2/source/dialog/tplpitem.cxx sfx2/source/doc/doctempl.cxx sfx2/source/doc/docvor.cxx sfx2/source/doc/new.cxx sfx2/source/doc/objcont.cxx sfx2/source/doc/objserv.cxx sfx2/source/doc/objxtor.cxx sfx2/source/inc/appdata.hxx sfx2/source/inc/helpid.hrc sfx2/source/inc/sfxlocal.hrc sfx2/source/inc/statcach.hxx sfx2/source/inc/templdgi.hxx sfx2/source/inc/virtmenu.hxx sfx2/source/inc/workwin.hxx sfx2/source/menu/mnumgr.cxx sfx2/source/menu/virtmenu.cxx sfx2/source/statbar/stbitem.cxx sfx2/source/view/frame.cxx sfx2/source/view/frame2.cxx sfx2/source/view/orgmgr.cxx sfx2/source/view/printer.cxx sfx2/source/view/prnmon.cxx sfx2/source/view/sfxbasecontroller.cxx sfx2/source/view/viewfrm.cxx sfx2/source/view/viewfrm2.cxx sfx2/source/view/viewprn.cxx sfx2/source/view/viewsh.cxx svx/inc/svx/svditer.hxx svx/source/dialog/sdstring.src svx/source/form/fmpage.cxx svx/source/form/formcontroller.cxx svx/source/svdraw/svdcrtv.cxx svx/source/svdraw/svditer.cxx svx/source/svdraw/svdview.cxx xmloff/source/forms/elementimport.cxx
2011-03-18 15:49:47 +01:00
sal_uInt16 nCount = pLongArr->size();
2011-02-22 12:00:38 +00:00
DBG_ASSERT( nCount == 2 * aBoolArr.size(), "NoteRange: Incompatible Sizes" );
2000-09-18 16:07:07 +00:00
while( nIdx < nCount && (*pLongArr)[ nIdx ] < nMin )
++nIdx;
bool bOdd = (nIdx % 2) != 0;
2011-02-16 16:34:02 -05:00
// No overlap with existing intervals?
2000-09-18 16:07:07 +00:00
if( nIdx == nCount || ( !bOdd && nMax < (*pLongArr)[ nIdx ] ) )
2011-02-16 16:34:02 -05:00
{ // Then a new one is inserted ...
pLongArr->insert( pLongArr->begin() + nIdx, nMin );
pLongArr->insert( pLongArr->begin() + nIdx + 1, nMax );
2011-02-22 12:00:38 +00:00
aBoolArr.insert( aBoolArr.begin() + (nIdx/2), bToggle );
2000-09-18 16:07:07 +00:00
}
else
2011-02-16 16:34:02 -05:00
{ // expand an existing interval ...
sal_uInt16 nMaxIdx = nIdx;
2011-02-16 16:34:02 -05:00
// If we end up on a left interval boundary, it must be reduced to nMin.
2000-09-18 16:07:07 +00:00
if( bOdd )
--nIdx;
else
(*pLongArr)[ nIdx ] = nMin;
while( nMaxIdx < nCount && (*pLongArr)[ nMaxIdx ] < nMax )
++nMaxIdx;
DBG_ASSERT( nMaxIdx > nIdx || nMin == nMax, "NoteRange: Funny Situation." );
if( nMaxIdx )
--nMaxIdx;
if( nMaxIdx < nIdx )
nMaxIdx = nIdx;
2011-02-16 16:34:02 -05:00
// If we end up on a right interval boundary, it must be raised to nMax.
2000-09-18 16:07:07 +00:00
if( nMaxIdx % 2 )
(*pLongArr)[ nMaxIdx-- ] = nMax;
2011-02-16 16:34:02 -05:00
// Possible merge of intervals.
sal_uInt16 nDiff = nMaxIdx - nIdx;
2011-02-16 16:34:02 -05:00
nMaxIdx = nIdx / 2; // From here on is nMaxIdx the Index in BoolArray.
2000-09-18 16:07:07 +00:00
if( nDiff )
{
pLongArr->erase( pLongArr->begin() + nIdx + 1, pLongArr->begin() + nIdx + 1 + nDiff );
2000-09-18 16:07:07 +00:00
nDiff /= 2;
sal_uInt16 nStop = nMaxIdx + nDiff;
for( sal_uInt16 i = nMaxIdx; i < nStop; ++i )
2000-09-18 16:07:07 +00:00
bToggle ^= aBoolArr[ i ];
2010-10-01 01:57:06 +02:00
aBoolArr.erase( aBoolArr.begin() + nMaxIdx, aBoolArr.begin() + (nMaxIdx + nDiff) );
2000-09-18 16:07:07 +00:00
}
2011-02-22 12:00:38 +00:00
DBG_ASSERT( nMaxIdx < aBoolArr.size(), "NoteRange: Too much deleted" );
aBoolArr[ nMaxIdx ] = aBoolArr[ nMaxIdx ] != bToggle;
2000-09-18 16:07:07 +00:00
}
}
void SvxBoundArgs::Calc( const tools::PolyPolygon& rPoly )
2000-09-18 16:07:07 +00:00
{
sal_uInt16 nCount;
2000-09-18 16:07:07 +00:00
nAct = 0;
for( sal_uInt16 i = 0; i < rPoly.Count(); ++i )
2000-09-18 16:07:07 +00:00
{
const tools::Polygon& rPol = rPoly[ i ];
2000-09-18 16:07:07 +00:00
nCount = rPol.GetSize();
if( nCount )
{
const Point& rNull = rPol[ 0 ];
bClosed = IsConcat() || ( rNull == rPol[ nCount - 1 ] );
2000-09-18 16:07:07 +00:00
nLast = Area( rNull );
if( nLast & 12 )
{
nFirst = 3;
if( bMultiple )
nAct = 0;
}
else
{
2011-02-16 16:34:02 -05:00
// The first point of the polygon is within the line.
2000-09-18 16:07:07 +00:00
if( nLast )
{
if( bMultiple || !nAct )
{
nMin = USHRT_MAX;
nMax = 0;
}
if( nLast & 1 )
2000-11-16 15:06:31 +00:00
NoteFarPoint( A(rNull), nLower - B(rNull), nLowDiff );
2000-09-18 16:07:07 +00:00
else
2000-11-16 15:06:31 +00:00
NoteFarPoint( A(rNull), B(rNull) - nUpper, nUpDiff );
2000-09-18 16:07:07 +00:00
}
else
{
if( bMultiple || !nAct )
{
2000-11-17 08:45:51 +00:00
nMin = A(rNull);
nMax = nMin + nEnd;
nMin -= nStart;
2000-09-18 16:07:07 +00:00
}
else
2000-11-16 15:06:31 +00:00
NotePoint( A(rNull) );
2000-09-18 16:07:07 +00:00
}
2011-02-16 16:34:02 -05:00
nFirst = 0; // leaving the line in which direction?
nAct = 3; // we are within the line at the moment.
2000-09-18 16:07:07 +00:00
}
if( nCount > 1 )
{
sal_uInt16 nIdx = 1;
while( true )
2000-09-18 16:07:07 +00:00
{
const Point& rLast = rPol[ nIdx - 1 ];
if( nIdx == nCount )
nIdx = 0;
const Point& rNext = rPol[ nIdx ];
nNext = Area( rNext );
nCut = nNext ^ nLast;
sal_uInt16 nOldAct = nAct;
2000-09-18 16:07:07 +00:00
if( nAct )
CheckCut( rLast, rNext );
if( nCut & 4 )
{
NoteUpLow( Cut( nLower, rLast, rNext ), 2 );
if( nAct && nAct != nOldAct )
{
nOldAct = nAct;
CheckCut( rLast, rNext );
}
}
if( nCut & 8 )
{
NoteUpLow( Cut( nUpper, rLast, rNext ), 1 );
if( nAct && nAct != nOldAct )
CheckCut( rLast, rNext );
}
if( !nIdx )
{
if( !( nNext & 12 ) )
NoteLast();
break;
}
if( !( nNext & 12 ) )
{
if( !nNext )
2000-11-16 15:06:31 +00:00
NotePoint( A(rNext) );
2000-09-18 16:07:07 +00:00
else if( nNext & 1 )
2000-11-16 15:06:31 +00:00
NoteFarPoint( A(rNext), nLower-B(rNext), nLowDiff );
2000-09-18 16:07:07 +00:00
else
2000-11-16 15:06:31 +00:00
NoteFarPoint( A(rNext), B(rNext)-nUpper, nUpDiff );
2000-09-18 16:07:07 +00:00
}
nLast = nNext;
if( ++nIdx == nCount && !bClosed )
2000-09-18 16:07:07 +00:00
{
if( !( nNext & 12 ) )
NoteLast();
break;
}
}
}
if( bMultiple && IsConcat() )
{
Add();
nAct = 0;
}
}
}
if( !bMultiple )
{
2012-02-19 16:59:40 +04:00
DBG_ASSERT( pLongArr->empty(), "I said: Simple!" );
2000-09-18 16:07:07 +00:00
if( nAct )
{
if( bInner )
{
long nTmpMin = nMin + 2 * nStart;
long nTmpMax = nMax - 2 * nEnd;
if( nTmpMin <= nTmpMax )
2000-09-18 16:07:07 +00:00
{
pLongArr->push_front(nTmpMax);
pLongArr->push_front(nTmpMin);
2000-09-18 16:07:07 +00:00
}
}
else
{
pLongArr->push_front(nMax);
pLongArr->push_front(nMin);
2000-09-18 16:07:07 +00:00
}
}
}
else if( !IsConcat() )
Add();
}
void SvxBoundArgs::Add()
{
2010-09-30 21:28:31 +02:00
size_t nCount = aBoolArr.size();
2000-09-18 16:07:07 +00:00
if( nCount && ( !bInner || !pTextRanger->IsSimple() ) )
{
bool bDelete = aBoolArr.front();
2000-09-18 16:07:07 +00:00
if( bInner )
bDelete = !bDelete;
sal_uInt16 nLongIdx = 1;
2010-10-01 01:57:06 +02:00
for( size_t nBoolIdx = 1; nBoolIdx < nCount; ++nBoolIdx )
2000-09-18 16:07:07 +00:00
{
if( bDelete )
{
sal_uInt16 next = 2;
2000-09-18 16:07:07 +00:00
while( nBoolIdx < nCount && !aBoolArr[ nBoolIdx++ ] &&
(!bInner || nBoolIdx < nCount ) )
next += 2;
pLongArr->erase( pLongArr->begin() + nLongIdx, pLongArr->begin() + nLongIdx + next );
next /= 2;
nBoolIdx = nBoolIdx - next;
nCount = nCount - next;
2010-10-01 01:57:06 +02:00
aBoolArr.erase( aBoolArr.begin() + nBoolIdx, aBoolArr.begin() + (nBoolIdx + next) );
2000-09-18 16:07:07 +00:00
if( nBoolIdx )
aBoolArr[ nBoolIdx - 1 ] = false;
#if OSL_DEBUG_LEVEL > 1
2000-09-18 16:07:07 +00:00
else
++next;
2000-09-18 16:07:07 +00:00
#endif
}
bDelete = nBoolIdx < nCount && aBoolArr[ nBoolIdx ];
nLongIdx += 2;
DBG_ASSERT( nLongIdx == 2*nBoolIdx+1, "BoundArgs: Array-Idx Confusion" );
2011-03-10 06:58:30 +00:00
DBG_ASSERT( aBoolArr.size()*2 == pLongArr->size(),
2000-09-18 16:07:07 +00:00
"BoundArgs: Array-Count: Confusion" );
}
}
if( !pLongArr->empty() )
2000-09-18 16:07:07 +00:00
{
if( bInner )
{
pLongArr->pop_front();
pLongArr->pop_back();
2000-09-18 16:07:07 +00:00
2011-02-16 16:34:02 -05:00
// Here the line is held inside a large rectangle for "simple"
// contour wrap. Currently (April 1999) the EditEngine evaluates
// only the first rectangle. If it one day is able to output a line
// in several parts, it may be advisable to delete the following lines.
if( pTextRanger->IsSimple() && pLongArr->size() > 2 )
pLongArr->erase( pLongArr->begin() + 1, pLongArr->end() - 1 );
2000-09-18 16:07:07 +00:00
}
}
}
void SvxBoundArgs::Concat( const tools::PolyPolygon* pPoly )
2000-09-18 16:07:07 +00:00
{
SetConcat( true );
2000-09-18 16:07:07 +00:00
DBG_ASSERT( pPoly, "Nothing to do?" );
LongDqPtr pOld = pLongArr;
pLongArr = new std::deque<long>();
2011-02-22 12:00:38 +00:00
aBoolArr.clear();
bInner = false;
Calc( *pPoly ); // Note that this updates pLongArr, which is why we swapped it out earlier.
Merge remote-tracking branch 'origin/integration/dev300_m101' Conflicts: avmedia/source/framework/mediacontrol.cxx connectivity/source/commontools/DateConversion.cxx desktop/source/deployment/registry/component/dp_component.cxx editeng/inc/editeng/numitem.hxx editeng/inc/editeng/txtrange.hxx editeng/source/editeng/editobj.cxx editeng/source/editeng/editview.cxx editeng/source/editeng/eehtml.cxx editeng/source/editeng/impedit3.cxx editeng/source/editeng/impedit4.cxx editeng/source/misc/txtrange.cxx editeng/source/outliner/outlin2.cxx editeng/source/outliner/outlvw.cxx framework/source/layoutmanager/layoutmanager.cxx linguistic/source/lngsvcmgr.hxx sfx2/source/appl/app.cxx sfx2/source/appl/app.src sfx2/source/appl/appbas.cxx sfx2/source/appl/appcfg.cxx sfx2/source/appl/appdde.cxx sfx2/source/appl/appmain.cxx sfx2/source/appl/appopen.cxx sfx2/source/appl/appquit.cxx sfx2/source/appl/appserv.cxx sfx2/source/appl/childwin.cxx sfx2/source/appl/fileobj.cxx sfx2/source/appl/fileobj.hxx sfx2/source/appl/workwin.cxx sfx2/source/control/dispatch.cxx sfx2/source/control/macro.cxx sfx2/source/control/objface.cxx sfx2/source/control/request.cxx sfx2/source/control/shell.cxx sfx2/source/control/statcach.cxx sfx2/source/dialog/dinfdlg.cxx sfx2/source/dialog/dockwin.cxx sfx2/source/dialog/mailmodel.cxx sfx2/source/dialog/mailmodelapi.cxx sfx2/source/dialog/mgetempl.cxx sfx2/source/dialog/splitwin.cxx sfx2/source/dialog/styledlg.cxx sfx2/source/dialog/tabdlg.cxx sfx2/source/dialog/templdlg.cxx sfx2/source/dialog/tplcitem.cxx sfx2/source/dialog/tplpitem.cxx sfx2/source/doc/doctempl.cxx sfx2/source/doc/docvor.cxx sfx2/source/doc/new.cxx sfx2/source/doc/objcont.cxx sfx2/source/doc/objserv.cxx sfx2/source/doc/objxtor.cxx sfx2/source/inc/appdata.hxx sfx2/source/inc/helpid.hrc sfx2/source/inc/sfxlocal.hrc sfx2/source/inc/statcach.hxx sfx2/source/inc/templdgi.hxx sfx2/source/inc/virtmenu.hxx sfx2/source/inc/workwin.hxx sfx2/source/menu/mnumgr.cxx sfx2/source/menu/virtmenu.cxx sfx2/source/statbar/stbitem.cxx sfx2/source/view/frame.cxx sfx2/source/view/frame2.cxx sfx2/source/view/orgmgr.cxx sfx2/source/view/printer.cxx sfx2/source/view/prnmon.cxx sfx2/source/view/sfxbasecontroller.cxx sfx2/source/view/viewfrm.cxx sfx2/source/view/viewfrm2.cxx sfx2/source/view/viewprn.cxx sfx2/source/view/viewsh.cxx svx/inc/svx/svditer.hxx svx/source/dialog/sdstring.src svx/source/form/fmpage.cxx svx/source/form/formcontroller.cxx svx/source/svdraw/svdcrtv.cxx svx/source/svdraw/svditer.cxx svx/source/svdraw/svdview.cxx xmloff/source/forms/elementimport.cxx
2011-03-18 15:49:47 +01:00
sal_uInt16 nCount = pLongArr->size();
sal_uInt16 nIdx = 0;
sal_uInt16 i = 0;
bool bSubtract = pTextRanger->IsInner();
2000-09-18 16:07:07 +00:00
while( i < nCount )
{
Merge remote-tracking branch 'origin/integration/dev300_m101' Conflicts: avmedia/source/framework/mediacontrol.cxx connectivity/source/commontools/DateConversion.cxx desktop/source/deployment/registry/component/dp_component.cxx editeng/inc/editeng/numitem.hxx editeng/inc/editeng/txtrange.hxx editeng/source/editeng/editobj.cxx editeng/source/editeng/editview.cxx editeng/source/editeng/eehtml.cxx editeng/source/editeng/impedit3.cxx editeng/source/editeng/impedit4.cxx editeng/source/misc/txtrange.cxx editeng/source/outliner/outlin2.cxx editeng/source/outliner/outlvw.cxx framework/source/layoutmanager/layoutmanager.cxx linguistic/source/lngsvcmgr.hxx sfx2/source/appl/app.cxx sfx2/source/appl/app.src sfx2/source/appl/appbas.cxx sfx2/source/appl/appcfg.cxx sfx2/source/appl/appdde.cxx sfx2/source/appl/appmain.cxx sfx2/source/appl/appopen.cxx sfx2/source/appl/appquit.cxx sfx2/source/appl/appserv.cxx sfx2/source/appl/childwin.cxx sfx2/source/appl/fileobj.cxx sfx2/source/appl/fileobj.hxx sfx2/source/appl/workwin.cxx sfx2/source/control/dispatch.cxx sfx2/source/control/macro.cxx sfx2/source/control/objface.cxx sfx2/source/control/request.cxx sfx2/source/control/shell.cxx sfx2/source/control/statcach.cxx sfx2/source/dialog/dinfdlg.cxx sfx2/source/dialog/dockwin.cxx sfx2/source/dialog/mailmodel.cxx sfx2/source/dialog/mailmodelapi.cxx sfx2/source/dialog/mgetempl.cxx sfx2/source/dialog/splitwin.cxx sfx2/source/dialog/styledlg.cxx sfx2/source/dialog/tabdlg.cxx sfx2/source/dialog/templdlg.cxx sfx2/source/dialog/tplcitem.cxx sfx2/source/dialog/tplpitem.cxx sfx2/source/doc/doctempl.cxx sfx2/source/doc/docvor.cxx sfx2/source/doc/new.cxx sfx2/source/doc/objcont.cxx sfx2/source/doc/objserv.cxx sfx2/source/doc/objxtor.cxx sfx2/source/inc/appdata.hxx sfx2/source/inc/helpid.hrc sfx2/source/inc/sfxlocal.hrc sfx2/source/inc/statcach.hxx sfx2/source/inc/templdgi.hxx sfx2/source/inc/virtmenu.hxx sfx2/source/inc/workwin.hxx sfx2/source/menu/mnumgr.cxx sfx2/source/menu/virtmenu.cxx sfx2/source/statbar/stbitem.cxx sfx2/source/view/frame.cxx sfx2/source/view/frame2.cxx sfx2/source/view/orgmgr.cxx sfx2/source/view/printer.cxx sfx2/source/view/prnmon.cxx sfx2/source/view/sfxbasecontroller.cxx sfx2/source/view/viewfrm.cxx sfx2/source/view/viewfrm2.cxx sfx2/source/view/viewprn.cxx sfx2/source/view/viewsh.cxx svx/inc/svx/svditer.hxx svx/source/dialog/sdstring.src svx/source/form/fmpage.cxx svx/source/form/formcontroller.cxx svx/source/svdraw/svdcrtv.cxx svx/source/svdraw/svditer.cxx svx/source/svdraw/svdview.cxx xmloff/source/forms/elementimport.cxx
2011-03-18 15:49:47 +01:00
sal_uLong nOldCount = pOld->size();
2000-09-18 16:07:07 +00:00
if( nIdx == nOldCount )
2011-02-16 16:34:02 -05:00
{ // Reached the end of the old Array...
2000-09-18 16:07:07 +00:00
if( !bSubtract )
pOld->insert( pOld->begin() + nIdx, pLongArr->begin() + i, pLongArr->end() );
2000-09-18 16:07:07 +00:00
break;
}
long nLeft = (*pLongArr)[ i++ ];
long nRight = (*pLongArr)[ i++ ];
sal_uInt16 nLeftPos = nIdx + 1;
2000-09-18 16:07:07 +00:00
while( nLeftPos < nOldCount && nLeft > (*pOld)[ nLeftPos ] )
nLeftPos += 2;
if( nLeftPos >= nOldCount )
2011-02-16 16:34:02 -05:00
{ // The current interval belongs to the end of the old array ...
2000-09-18 16:07:07 +00:00
if( !bSubtract )
pOld->insert( pOld->begin() + nOldCount, pLongArr->begin() + i - 2, pLongArr->end() );
2000-09-18 16:07:07 +00:00
break;
}
sal_uInt16 nRightPos = nLeftPos - 1;
2000-09-18 16:07:07 +00:00
while( nRightPos < nOldCount && nRight >= (*pOld)[ nRightPos ] )
nRightPos += 2;
if( nRightPos < nLeftPos )
2011-02-16 16:34:02 -05:00
{ // The current interval belongs between two old intervals
2000-09-18 16:07:07 +00:00
if( !bSubtract )
pOld->insert( pOld->begin() + nRightPos, pLongArr->begin() + i - 2, pLongArr->begin() + i );
2000-09-18 16:07:07 +00:00
}
2011-02-16 16:34:02 -05:00
else if( bSubtract ) // Subtract, if necessary separate
2000-09-18 16:07:07 +00:00
{
const long nOld = (*pOld)[nLeftPos - 1];
if (nLeft > nOld)
2011-02-16 16:34:02 -05:00
{ // Now we split the left part...
2000-09-18 16:07:07 +00:00
if( nLeft - 1 > nOld )
{
pOld->insert( pOld->begin() + nLeftPos - 1, nOld );
pOld->insert( pOld->begin() + nLeftPos, nLeft - 1 );
2000-09-18 16:07:07 +00:00
nLeftPos += 2;
nRightPos += 2;
}
}
if( nRightPos - nLeftPos > 1 )
pOld->erase( pOld->begin() + nLeftPos, pOld->begin() + nRightPos - 1 );
if (++nRight >= (*pOld)[nLeftPos])
pOld->erase( pOld->begin() + nLeftPos - 1, pOld->begin() + nLeftPos + 1 );
2000-09-18 16:07:07 +00:00
else
(*pOld)[ nLeftPos - 1 ] = nRight;
}
2011-02-16 16:34:02 -05:00
else // Merge
2000-09-18 16:07:07 +00:00
{
if( nLeft < (*pOld)[ nLeftPos - 1 ] )
(*pOld)[ nLeftPos - 1 ] = nLeft;
if( nRight > (*pOld)[ nRightPos - 1 ] )
(*pOld)[ nRightPos - 1 ] = nRight;
if( nRightPos - nLeftPos > 1 )
pOld->erase( pOld->begin() + nLeftPos, pOld->begin() + nRightPos - 1 );
2000-09-18 16:07:07 +00:00
}
nIdx = nLeftPos - 1;
}
delete pLongArr;
}
/*************************************************************************
2011-02-16 16:34:02 -05:00
* SvxBoundArgs::Area returns the area in which the point is located.
* 0 = within the line
* 1 = below, but within the upper edge
* 2 = above, but within the lower edge
* 5 = below the upper edge
*10 = above the lower edge
2000-09-18 16:07:07 +00:00
*************************************************************************/
sal_uInt16 SvxBoundArgs::Area( const Point& rPt )
2000-09-18 16:07:07 +00:00
{
2000-11-16 15:06:31 +00:00
long nB = B( rPt );
if( nB >= nBottom )
2000-09-18 16:07:07 +00:00
{
2000-11-16 15:06:31 +00:00
if( nB >= nLower )
2000-09-18 16:07:07 +00:00
return 5;
return 1;
}
2000-11-16 15:06:31 +00:00
if( nB <= nTop )
2000-09-18 16:07:07 +00:00
{
2000-11-16 15:06:31 +00:00
if( nB <= nUpper )
2000-09-18 16:07:07 +00:00
return 10;
return 2;
}
return 0;
}
/*************************************************************************
2011-02-16 16:34:02 -05:00
* lcl_Cut calculates the X-Coordinate of the distance (Pt1-Pt2) at the
* Y-Coordinate nY.
* It is assumed that the one of the points are located above and the other
* one below the Y-Coordinate.
2000-09-18 16:07:07 +00:00
*************************************************************************/
2000-11-16 15:06:31 +00:00
long SvxBoundArgs::Cut( long nB, const Point& rPt1, const Point& rPt2 )
2000-09-18 16:07:07 +00:00
{
2000-11-16 15:06:31 +00:00
if( pTextRanger->IsVertical() )
{
double nQuot = nB - rPt1.X();
nQuot /= ( rPt2.X() - rPt1.X() );
nQuot *= ( rPt2.Y() - rPt1.Y() );
return long( rPt1.Y() + nQuot );
}
double nQuot = nB - rPt1.Y();
2000-09-18 16:07:07 +00:00
nQuot /= ( rPt2.Y() - rPt1.Y() );
nQuot *= ( rPt2.X() - rPt1.X() );
return long( rPt1.X() + nQuot );
}
void SvxBoundArgs::NoteUpLow( long nA, const sal_uInt8 nArea )
2000-09-18 16:07:07 +00:00
{
if( nAct )
{
2000-11-16 15:06:31 +00:00
NoteMargin( nA, nA );
2000-09-18 16:07:07 +00:00
if( bMultiple )
{
NoteRange( nArea != nAct );
nAct = 0;
}
if( !nFirst )
nFirst = nArea;
}
else
{
nAct = nArea;
2000-11-16 15:06:31 +00:00
nMin = nA;
nMax = nA;
2000-09-18 16:07:07 +00:00
}
}
LongDqPtr TextRanger::GetTextRanges( const Range& rRange )
2000-09-18 16:07:07 +00:00
{
DBG_ASSERT( rRange.Min() || rRange.Max(), "Zero-Range not allowed, Bye Bye" );
//Can we find the result we need in the cache?
2011-07-30 22:28:07 +02:00
for (std::deque<RangeCache>::iterator it = mRangeCache.begin(); it != mRangeCache.end(); ++it)
2000-09-18 16:07:07 +00:00
{
if (it->range == rRange)
return &(it->results);
2000-09-18 16:07:07 +00:00
}
//Calculate a new result
RangeCache rngCache(rRange);
SvxBoundArgs aArg( this, &(rngCache.results), rRange );
aArg.Calc( *mpPolyPolygon );
if( mpLinePolyPolygon )
aArg.Concat( mpLinePolyPolygon );
//Add new result to the cache
mRangeCache.push_back(rngCache);
if (mRangeCache.size() > nCacheSize)
mRangeCache.pop_front();
return &(mRangeCache.back().results);
2000-09-18 16:07:07 +00:00
}
const Rectangle& TextRanger::GetBoundRect_()
2000-09-18 16:07:07 +00:00
{
DBG_ASSERT( nullptr == pBound, "Don't call twice." );
pBound = new Rectangle( mpPolyPolygon->GetBoundRect() );
2000-09-18 16:07:07 +00:00
return *pBound;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */